Ejemplo n.º 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));
            }
        }
Ejemplo n.º 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);
            }
        }
Ejemplo n.º 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);
            }
        }