Exemple #1
0
        private void LoadInternal(string folder, bool read)
        {
            _source = SIPackageFactory.Instance.GetPackage(folder, read);

            LoadData();
            InitializeStorages();
        }
Exemple #2
0
        private void SaveCore(ISIPackage package)
        {
            using (var stream = package.GetStream(ContentFileName, false).Stream)
            {
                using (var writer = XmlWriter.Create(stream))
                {
                    _package.WriteXml(writer);
                }
            }

            using (var stream = package.GetStream(TextsStorageName, AuthorsFileName, false).Stream)
            {
                using (var writer = XmlWriter.Create(stream))
                {
                    _authors.WriteXml(writer);
                }
            }

            using (var stream = package.GetStream(TextsStorageName, SourcesFileName, false).Stream)
            {
                using (var writer = XmlWriter.Create(stream))
                {
                    _sources.WriteXml(writer);
                }
            }

            package.Flush();
        }
Exemple #3
0
        private void LoadInternal(Stream stream, bool read)
        {
            _source = SIPackageFactory.Instance.GetPackage(stream, read);

            LoadData();
            InitializeStorages();
        }
Exemple #4
0
        public void ResetTo(Stream stream, bool read = true)
        {
            _source = SIPackageFactory.Instance.GetPackage(stream, read);

            _images.UpdateSource(_source);
            _audio.UpdateSource(_source);
            _video.UpdateSource(_source);
        }
Exemple #5
0
 public void Dispose()
 {
     if (_source != null)
     {
         _source.Dispose();
         _source = null;
     }
 }
Exemple #6
0
        /// <summary>
        /// Создание категории
        /// </summary>
        /// <param name="package">Документ-владелец</param>
        /// <param name="name">Имя категории</param>
        internal DataCollection(ISIPackage package, string name, string mediaType)
        {
            Name       = name;
            _mediaType = mediaType;
            _package   = package;

            _files = new List <string>(_package.GetEntries(Name));
        }
Exemple #7
0
        public static SIDocument Create(string name, string author, ISIPackage source)
        {
            var document = new SIDocument();

            document.CreateInternal(source, name, author);

            Init(document);

            return(document);
        }
Exemple #8
0
        public SIDocument SaveAs(Stream stream, bool switchTo)
        {
            var newSource = _source.CopyTo(stream, switchTo, out bool isNew);

            if (isNew)
            {
                newSource.CreateStream(ContentFileName, "si/xml");
                newSource.CreateStream(TextsStorageName, AuthorsFileName, "si/xml");
                newSource.CreateStream(TextsStorageName, SourcesFileName, "si/xml");
            }

            if (switchTo)
            {
                _source.Dispose();
                _source = newSource;

                _images.UpdateSource(_source);
                _audio.UpdateSource(_source);
                _video.UpdateSource(_source);
            }

            SaveCore(newSource);

            if (switchTo)
            {
                return(this);
            }

            var doc = new SIDocument {
                _source = newSource
            };

            doc.InitializeStorages();

            return(doc);
        }
Exemple #9
0
        private void CreateInternal(string folder, string name, string author)
        {
            _source = SIPackageFactory.Instance.CreatePackage(folder);

            CreateCore(name, author);
        }
Exemple #10
0
        private void CreateInternal(Stream stream, string name, string author)
        {
            _source = SIPackageFactory.Instance.CreatePackage(stream);

            CreateCore(name, author);
        }
Exemple #11
0
        private void CreateInternal(ISIPackage source, string name, string author)
        {
            _source = source;

            CreateCore(name, author);
        }
Exemple #12
0
 internal void UpdateSource(ISIPackage package)
 {
     _package = package;
 }