コード例 #1
0
        private StandaloneMetadataStore LoadMetadataStore()
        {
            if (!File.Exists(_metadataPath))
            {
                return(CreateStandaloneMetadataStore());
            }

            using (var fileStream = new FileStream(_metadataPath, FileMode.Open, FileAccess.Read,
                                                   FileShare.None, BufferSize, true))
            {
                return(StandaloneMetadataStore.ReadFromStream(fileStream));
            }
        }
コード例 #2
0
        private void SetPropertiesImplementation()
        {
            using (var fileStream = new FileStream(_metadataPath, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None, BufferSize, true))
            {
                var metadataStore = fileStream.Length == 0
                    ? CreateStandaloneMetadataStore()
                    : StandaloneMetadataStore.ReadFromStream(fileStream);

                metadataStore.ContentType = _properties.ContentType;

                fileStream.SetLength(0);
                metadataStore.WriteToStreamAndClose(fileStream);
            }
        }
コード例 #3
0
        private void SetMetadataImplementation()
        {
            using (var fileStream = new FileStream(_metadataPath, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None, BufferSize, true))
            {
                var metadataStore = fileStream.Length == 0
                    ? CreateStandaloneMetadataStore()
                    : StandaloneMetadataStore.ReadFromStream(fileStream);

                foreach (var key in _metadata.Keys)
                {
                    metadataStore.Metadata[key] = _metadata[key];
                }

                fileStream.SetLength(0);
                metadataStore.WriteToStreamAndClose(fileStream);
            }
        }