/// <summary> /// Constructor. /// </summary> /// <param name="coreProperties">core properties to filter</param> internal CorePropertiesFilter(PackageProperties coreProperties) { if (coreProperties == null) { throw new ArgumentNullException("coreProperties"); } _coreProperties = coreProperties; }
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()); } } } }
/// <summary> /// Constructor. /// </summary> /// <param name="coreProperties">CoreProperties to enumerate</param> /// <param name="grfFlags"> /// if IFILTER_INIT_APPLY_INDEX_ATTRIBUTES is specified, /// this indicates all core properties to be returned unless /// the parameter aAttributes is non-empty. /// </param> /// <param name="attributes"> /// attributes specified corresponding to the properties to filter. /// </param> internal CorePropertyEnumerator(PackageProperties coreProperties, IFILTER_INIT grfFlags, ManagedFullPropSpec[] attributes) { if (attributes != null && attributes.Length > 0) { // // If attruibutes list specified, // return core properties for only those attributes. // _attributes = attributes; } else if ((grfFlags & IFILTER_INIT.IFILTER_INIT_APPLY_INDEX_ATTRIBUTES) == IFILTER_INIT.IFILTER_INIT_APPLY_INDEX_ATTRIBUTES) { // // If no attributes list specified, // but IFILTER_INIT_APPLY_INDEX_ATTRIBUTES is present in grfFlags, // return all core properties. // _attributes = new ManagedFullPropSpec[] { // // SummaryInformation // new ManagedFullPropSpec(FormatId.SummaryInformation, PropertyId.Title), new ManagedFullPropSpec(FormatId.SummaryInformation, PropertyId.Subject), new ManagedFullPropSpec(FormatId.SummaryInformation, PropertyId.Creator), new ManagedFullPropSpec(FormatId.SummaryInformation, PropertyId.Keywords), new ManagedFullPropSpec(FormatId.SummaryInformation, PropertyId.Description), new ManagedFullPropSpec(FormatId.SummaryInformation, PropertyId.LastModifiedBy), new ManagedFullPropSpec(FormatId.SummaryInformation, PropertyId.Revision), new ManagedFullPropSpec(FormatId.SummaryInformation, PropertyId.LastPrinted), new ManagedFullPropSpec(FormatId.SummaryInformation, PropertyId.DateCreated), new ManagedFullPropSpec(FormatId.SummaryInformation, PropertyId.DateModified), // // DocumentSummaryInformation // new ManagedFullPropSpec(FormatId.DocumentSummaryInformation, PropertyId.Category), new ManagedFullPropSpec(FormatId.DocumentSummaryInformation, PropertyId.Identifier), new ManagedFullPropSpec(FormatId.DocumentSummaryInformation, PropertyId.ContentType), new ManagedFullPropSpec(FormatId.DocumentSummaryInformation, PropertyId.Language), new ManagedFullPropSpec(FormatId.DocumentSummaryInformation, PropertyId.Version), new ManagedFullPropSpec(FormatId.DocumentSummaryInformation, PropertyId.ContentStatus) }; } else { // No core properties to be returned. } _coreProperties = coreProperties; _currentIndex = -1; }
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 ()); } } } }