Пример #1
0
        /// <summary>
        /// Sets a core property value.
        /// Private method, for internal use only!
        /// </summary>
        /// <param name="nameSpace">The property's namespace</param>
        /// <param name="propertyName">The name of the property</param>
        /// <param name="propValue">The value of the property</param>
        private void SetCorePropertyValue(string nameSpace, string propertyName, string propValue)
        {
            string searchString = string.Format("//cp:coreProperties/{0}:{1}", nameSpace, propertyName);
            var    node         = CorePropertiesXml.XPathSelectElement(searchString, _nsManager);

            if (node == null)
            {
                // the property does not exist, so create the XML node
                string schema = schemaCore;
                switch (nameSpace)
                {
                case "cp": schema = schemaCore; break;

                case "dc": schema = schemaDc;   break;

                case "dcterms": schema = schemaDcTerms; break;

                case "dcmitype": schema = schemaDcmiType;       break;

                case "xsi": schema = schemaXsi; break;
                }
                node = new XElement(propertyName)
                       .AddSchemaAttribute(schema, nameSpace);
                CorePropertiesXml.Document.Add(node);
            }
            node.Value = propValue;
        }
Пример #2
0
        /// <summary>
        /// Gets the value of a core property
        /// Private method, for internal use only!
        /// </summary>
        /// <param name="nameSpace">The namespace of the property</param>
        /// <param name="propertyName">The property name</param>
        /// <returns>The current value of the property</returns>
        private string GetCorePropertyValue(string nameSpace, string propertyName)
        {
            string retValue     = null;
            string searchString = string.Format("//cp:coreProperties/{0}:{1}", nameSpace, propertyName);
            var    node         = CorePropertiesXml.XPathSelectElement(searchString, _nsManager);

            if (node != null)
            {
                retValue = node.Value;
            }
            return(retValue);
        }