Dev2.Workspaces.WorkspaceRepository.ReadUserMap C# (CSharp) Method

ReadUserMap() static private method

static private ReadUserMap ( ) : Guid>.ConcurrentDictionary
return Guid>.ConcurrentDictionary
        static ConcurrentDictionary<string, Guid> ReadUserMap()
        {
            // force a lock on the file system ;)
            lock(UserMapLock)
            {
                var filePath = GetUserMapFileName();
                var fileExists = File.Exists(filePath);
                using(var stream = File.Open(filePath, FileMode.OpenOrCreate))
                {
                    var formatter = new BinaryFormatter();
                    if(fileExists)
                    {
                        try
                        {
                            return (ConcurrentDictionary<string, Guid>)formatter.Deserialize(stream);
                        }
                        // ReSharper disable EmptyGeneralCatchClause 
                        catch(Exception ex)
                        // ReSharper restore EmptyGeneralCatchClause
                        {
                            Dev2Logger.Log.Error("WorkspaceRepository", ex);
                            // Deserialization failed so overwrite with new one.
                        }
                    }

                    var result = new ConcurrentDictionary<string, Guid>();
                    formatter.Serialize(stream, result);
                    return result;
                }
            }
        }