System.IO.Packaging.PackageProperties.Flush C# (CSharp) Метод

Flush() приватный Метод

private Flush ( ) : void
Результат void
        internal void Flush()
        {
            using (MemoryStream temp = new MemoryStream())
            {
                using (XmlTextWriter writer = new XmlTextWriter(temp, System.Text.Encoding.UTF8))
                {
                    WriteTo(writer);
                    writer.Flush();
                    if (temp.Length == 0)
                        return;
                }
            }

            if (Part == null)
            {
                int id = System.Threading.Interlocked.Increment(ref uuid);
                Uri uri = new Uri(string.Format("/package/services/metadata/core-properties/{0}.psmdcp", id), UriKind.Relative);
                Part = Package.CreatePart(uri, PackagePropertiesContentType);
                PackageRelationship rel = Package.CreateRelationship(uri, TargetMode.Internal, NSPackagePropertiesRelation);
            }

            using (Stream s = Part.GetStream(FileMode.Create))
            using (XmlTextWriter writer = new XmlTextWriter(s, System.Text.Encoding.UTF8))
                WriteTo(writer);
        }

Usage Example

Пример #1
0
        public void Flush()
        {
            if (FileOpenAccess == FileAccess.Read || flushing)
            {
                return;
            }

            flushing = true;

            // Ensure we've loaded the relationships, parts and properties
            int count = Relationships.Count;

            if (packageProperties != null)
            {
                packageProperties.Flush();
            }

            FlushCore();

            flushing = false;
        }