System.IO.Packaging.PackageProperties.LoadFrom C# (CSharp) Method

LoadFrom() private method

private LoadFrom ( System.Stream stream ) : void
stream System.Stream
return void
        internal virtual void LoadFrom(Stream stream)
        {
        }

Usage Example

示例#1
0
        void LoadRelationships()
        {
            relationships = new Dictionary <string, PackageRelationship> ();

            if (!PartExists(RelationshipUri))
            {
                return;
            }

            using (Stream stream = GetPart(RelationshipUri).GetStream())
            {
                XmlDocument doc = new XmlDocument();
                doc.Load(stream);
                XmlNamespaceManager manager = new XmlNamespaceManager(doc.NameTable);
                manager.AddNamespace("rel", RelationshipNamespace);

                foreach (XmlNode node in doc.SelectNodes("/rel:Relationships/*", manager))
                {
                    TargetMode mode = TargetMode.Internal;
                    if (node.Attributes["TargetMode"] != null)
                    {
                        mode = (TargetMode)Enum.Parse(typeof(TargetMode), node.Attributes ["TargetMode"].Value);
                    }

                    Uri uri;
                    try
                    {
                        uri = new Uri(node.Attributes ["Target"].Value.ToString(), UriKind.Relative);
                    }
                    catch
                    {
                        uri = new Uri(node.Attributes ["Target"].Value.ToString(), UriKind.Absolute);
                    }
                    CreateRelationship(uri,
                                       mode,
                                       node.Attributes["Type"].Value.ToString(),
                                       node.Attributes["Id"].Value.ToString(),
                                       true);
                }

                foreach (PackageRelationship r in relationships.Values)
                {
                    if (r.RelationshipType == System.IO.Packaging.PackageProperties.NSPackagePropertiesRelation)
                    {
                        PackagePart part = GetPart(PackUriHelper.ResolvePartUri(Uri, r.TargetUri));
                        packageProperties         = new PackagePropertiesPart();
                        packageProperties.Package = this;
                        packageProperties.Part    = part;
                        packageProperties.LoadFrom(part.GetStream());
                    }
                }
            }
        }
All Usage Examples Of System.IO.Packaging.PackageProperties::LoadFrom