コード例 #1
0
        /// <summary>
        /// Get the file from disk or from the storage cache.
        /// </summary>
        /// <param name="filePath">Full file path</param>
        /// <param name="access">If the file is opened for reading, file content is loaded</param>
        /// <param name="st">Serialization type for SAVING</param>
        /// <param name="password">File password</param>
        /// <param name="useCache"></param>
        /// <returns>Msnpsharp contact list file</returns>
        /// <remarks>This method is thread safe</remarks>
        public static MclFile Open(string filePath, FileAccess access, MclSerialization st, string password, bool useCache)
        {
            if (useCache)
            {
                if (storage.ContainsKey(filePath))
                {
                    lock (SyncObject)
                    {
                        if (storage[filePath].Refresh())
                        {
                            storage[filePath] = new MclInfo(new MclFile(filePath, st, access, password));
                        }
                    }
                }
                else
                {
                    lock (SyncObject)
                    {
                        if (!storage.ContainsKey(filePath))
                        {
                            storage[filePath] = new MclInfo(new MclFile(filePath, st, access, password));
                        }
                    }
                }

                return(storage[filePath].File);
            }
            else
            {
                return(new MclFile(filePath, st, access, password));
            }
        }
コード例 #2
0
ファイル: IO.cs プロジェクト: quynh68/msnp-sharp
        /// <summary>
        /// Get the file from disk or from the storage cache.
        /// </summary>
        /// <param name="filePath">Full file path</param>
        /// <param name="access">If the file is opened for reading, file content is loaded</param>
        /// <param name="st">Serialization type for SAVING</param>
        /// <param name="password">File password</param>
        /// <param name="useCache"></param>
        /// <returns>Msnpsharp contact list file</returns>
        /// <remarks>This method is thread safe</remarks>
        public static MclFile Open(string filePath, FileAccess access, MclSerialization st, string password, bool useCache)
        {
            if (useCache)
            {
                if (storage.ContainsKey(filePath))
                {
                    lock (SyncObject)
                    {
                        if (storage[filePath].Refresh())
                        {
                            storage[filePath] = new MclInfo(new MclFile(filePath, st, access, password));
                        }
                    }
                }
                else
                {
                    lock (SyncObject)
                    {
                        if (!storage.ContainsKey(filePath))
                        {
                            storage[filePath] = new MclInfo(new MclFile(filePath, st, access, password));
                        }
                    }
                }

                return storage[filePath].File;
            }
            else
            {
                return new MclFile(filePath, st, access, password);
            }
        }