当前位置: 首页>>代码示例>>C#>>正文


C# IXmpMeta类代码示例

本文整理汇总了C#中IXmpMeta的典型用法代码示例。如果您正苦于以下问题:C# IXmpMeta类的具体用法?C# IXmpMeta怎么用?C# IXmpMeta使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


IXmpMeta类属于命名空间,在下文中一共展示了IXmpMeta类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SetIdentifiers

        /** Sets the identifier.
         *
         * @param xmpMeta
         * @param id
         */

        public static void SetIdentifiers(IXmpMeta xmpMeta, String[] id) {
            XmpUtils.RemoveProperties(xmpMeta, XmpConst.NS_DC, IDENTIFIER, true, true);
            for (int i = 0; i < id.Length; i++) {
                xmpMeta.AppendArrayItem(XmpConst.NS_DC, IDENTIFIER, new PropertyOptions(PropertyOptions.ARRAY), id[i],
                                        null);
            }
        }
开发者ID:Gianluigi,项目名称:dssnet,代码行数:13,代码来源:XmpBasicProperties.cs

示例2: CatenateArrayItems

        /// <param name="xmp">The XMP object containing the array to be catenated.</param>
        /// <param name="schemaNs">
        /// The schema namespace URI for the array. Must not be null or
        /// the empty string.
        /// </param>
        /// <param name="arrayName">
        /// The name of the array. May be a general path expression, must
        /// not be null or the empty string. Each item in the array must
        /// be a simple string value.
        /// </param>
        /// <param name="separator">
        /// The string to be used to separate the items in the catenated
        /// string. Defaults to &quot;; &quot;, ASCII semicolon and space
        /// (U+003B, U+0020).
        /// </param>
        /// <param name="quotes">
        /// The characters to be used as quotes around array items that
        /// contain a separator. Defaults to &apos;&quot;&apos;
        /// </param>
        /// <param name="allowCommas">Option flag to control the catenation.</param>
        /// <returns>Returns the string containing the catenated array items.</returns>
        /// <exception cref="XmpException">Forwards the Exceptions from the metadata processing</exception>
        public static string CatenateArrayItems(IXmpMeta xmp, string schemaNs, string arrayName, string separator, string quotes, bool allowCommas)
        {
            ParameterAsserts.AssertSchemaNs(schemaNs);
            ParameterAsserts.AssertArrayName(arrayName);
            ParameterAsserts.AssertImplementation(xmp);

            if (string.IsNullOrEmpty(separator))
                separator = "; ";
            if (string.IsNullOrEmpty(quotes))
                quotes = "\"";

            var xmpImpl = (XmpMeta)xmp;

            // Return an empty result if the array does not exist,
            // hurl if it isn't the right form.
            var arrayPath = XmpPathParser.ExpandXPath(schemaNs, arrayName);
            var arrayNode = XmpNodeUtils.FindNode(xmpImpl.GetRoot(), arrayPath, false, null);

            if (arrayNode == null)
                return string.Empty;
            if (!arrayNode.Options.IsArray || arrayNode.Options.IsArrayAlternate)
                throw new XmpException("Named property must be non-alternate array", XmpErrorCode.BadParam);

            // Make sure the separator is OK.
            CheckSeparator(separator);

            // Make sure the open and close quotes are a legitimate pair.
            var openQuote = quotes[0];
            var closeQuote = CheckQuotes(quotes, openQuote);

            // Build the result, quoting the array items, adding separators.
            // Hurl if any item isn't simple.
            var catenatedString = new StringBuilder();
            for (var it = arrayNode.IterateChildren(); it.HasNext(); )
            {
                var currItem = (XmpNode)it.Next();

                if (currItem.Options.IsCompositeProperty)
                    throw new XmpException("Array items must be simple", XmpErrorCode.BadParam);

                var str = ApplyQuotes(currItem.Value, openQuote, closeQuote, allowCommas);
                catenatedString.Append(str);

                if (it.HasNext())
                    catenatedString.Append(separator);
            }
            return catenatedString.ToString();
        }
开发者ID:tehkyle,项目名称:xmp-core-dotnet,代码行数:70,代码来源:XmpUtils.cs

示例3: RemoveProperties

        /// <param name="xmp">The XMP object containing the properties to be removed.</param>
        /// <param name="schemaNs">
        /// Optional schema namespace URI for the properties to be
        /// removed.
        /// </param>
        /// <param name="propName">Optional path expression for the property to be removed.</param>
        /// <param name="doAllProperties">
        /// Option flag to control the deletion: do internal properties in
        /// addition to external properties.
        /// </param>
        /// <param name="includeAliases">
        /// Option flag to control the deletion: Include aliases in the
        /// "named schema" case above.
        /// </param>
        /// <exception cref="XmpException">If metadata processing fails</exception>
        public static void RemoveProperties(IXmpMeta xmp, string schemaNs, string propName, bool doAllProperties, bool includeAliases)
        {
            ParameterAsserts.AssertImplementation(xmp);

            var xmpImpl = (XmpMeta)xmp;
            if (!string.IsNullOrEmpty(propName))
            {
                // Remove just the one indicated property. This might be an alias,
                // the named schema might not actually exist. So don't lookup the
                // schema node.
                if (string.IsNullOrEmpty(schemaNs))
                    throw new XmpException("Property name requires schema namespace", XmpErrorCode.BadParam);

                var expPath = XmpPathParser.ExpandXPath(schemaNs, propName);
                var propNode = XmpNodeUtils.FindNode(xmpImpl.GetRoot(), expPath, false, null);
                if (propNode != null)
                {
                    if (doAllProperties || !Utils.IsInternalProperty(expPath.GetSegment(XmpPath.StepSchema).Name, expPath.GetSegment(XmpPath.StepRootProp).Name))
                    {
                        var parent = propNode.Parent;
                        parent.RemoveChild(propNode);
                        if (parent.Options.IsSchemaNode && !parent.HasChildren)
                        {
                            // remove empty schema node
                            parent.Parent.RemoveChild(parent);
                        }
                    }
                }
            }
            else
            {
                if (!string.IsNullOrEmpty(schemaNs))
                {
                    // Remove all properties from the named schema. Optionally include
                    // aliases, in which case
                    // there might not be an actual schema node.
                    // XMP_NodePtrPos schemaPos;
                    var schemaNode = XmpNodeUtils.FindSchemaNode(xmpImpl.GetRoot(), schemaNs, false);

                    if (schemaNode != null && RemoveSchemaChildren(schemaNode, doAllProperties))
                        xmpImpl.GetRoot().RemoveChild(schemaNode);

                    if (includeAliases)
                    {
                        // We're removing the aliases also. Look them up by their namespace prefix.
                        // But that takes more code and the extra speed isn't worth it.
                        // Lookup the XMP node from the alias, to make sure the actual exists.
                        foreach (var info in XmpMetaFactory.SchemaRegistry.FindAliases(schemaNs))
                        {
                            var path = XmpPathParser.ExpandXPath(info.Namespace, info.PropName);
                            var actualProp = XmpNodeUtils.FindNode(xmpImpl.GetRoot(), path, false, null);
                            if (actualProp != null)
                                actualProp.Parent.RemoveChild(actualProp);
                        }
                    }
                }
                else
                {
                    // Remove all appropriate properties from all schema. In this case
                    // we don't have to be
                    // concerned with aliases, they are handled implicitly from the
                    // actual properties.
                    for (var it = xmpImpl.GetRoot().IterateChildren(); it.HasNext(); )
                    {
                        var schema = (XmpNode)it.Next();
                        if (RemoveSchemaChildren(schema, doAllProperties))
                            it.Remove();
                    }
                }
            }
        }
开发者ID:tehkyle,项目名称:xmp-core-dotnet,代码行数:86,代码来源:XmpUtils.cs

示例4: SeparateArrayItems

 /// <summary>Separate a single edit string into an array of strings.</summary>
 /// <param name="xmp">The XMP object containing the array to be updated.</param>
 /// <param name="schemaNs">
 /// The schema namespace URI for the array. Must not be null or
 /// the empty string.
 /// </param>
 /// <param name="arrayName">
 /// The name of the array. May be a general path expression, must
 /// not be null or the empty string. Each item in the array must
 /// be a simple string value.
 /// </param>
 /// <param name="catedStr">The string to be separated into the array items.</param>
 /// <param name="arrayOptions">Option flags to control the separation.</param>
 /// <param name="preserveCommas">Flag if commas shall be preserved</param>
 /// <exception cref="XmpException">Forwards the Exceptions from the metadata processing</exception>
 /// <exception cref="XmpException"/>
 public static void SeparateArrayItems(IXmpMeta xmp, string schemaNs, string arrayName, string catedStr, PropertyOptions arrayOptions, bool preserveCommas)
 {
     Impl.XmpUtils.SeparateArrayItems(xmp, schemaNs, arrayName, catedStr, arrayOptions, preserveCommas);
 }
开发者ID:tehkyle,项目名称:xmp-core-dotnet,代码行数:20,代码来源:XMPUtils.cs

示例5: AppendProperties

 /// <summary>Append properties from one XMP object to another.</summary>
 /// <remarks>
 /// Append properties from one XMP object to another.
 /// <para />XMPUtils#appendProperties was created to support the File Info dialog's Append button, and
 /// has been been generalized somewhat from those specific needs. It appends information from one
 /// XMP object (source) to another (dest). The default operation is to append only external
 /// properties that do not already exist in the destination. The flag
 /// <c>doAllProperties</c> can be used to operate on all properties, external and internal.
 /// The flag <c>replaceOldValues</c> option can be used to replace the values
 /// of existing properties. The notion of external
 /// versus internal applies only to top level properties. The keep-or-replace-old notion applies
 /// within structs and arrays as described below.
 /// <list type="bullet">
 /// <item>If <c>replaceOldValues</c> is true then the processing is restricted to the top
 /// level properties. The processed properties from the source (according to
 /// <c>doAllProperties</c>) are propagated to the destination,
 /// replacing any existing values.Properties in the destination that are not in the source
 /// are left alone.</item>
 /// <item>If <c>replaceOldValues</c> is not passed then the processing is more complicated.
 /// Top level properties are added to the destination if they do not already exist.
 /// If they do exist but differ in form (simple/struct/array) then the destination is left alone.
 /// If the forms match, simple properties are left unchanged while structs and arrays are merged.</item>
 /// <item>If <c>deleteEmptyValues</c> is passed then an empty value in the source XMP causes
 /// the corresponding destination XMP property to be deleted. The default is to treat empty
 /// values the same as non-empty values. An empty value is any of a simple empty string, an array
 /// with no items, or a struct with no fields. Qualifiers are ignored.</item>
 /// </list>
 /// <para />The detailed behavior is defined by the following pseudo-code:
 /// <blockquote>
 /// <pre>
 /// appendProperties ( sourceXMP, destXMP, doAllProperties,
 /// replaceOldValues, deleteEmptyValues ):
 /// for all source schema (top level namespaces):
 /// for all top level properties in sourceSchema:
 /// if doAllProperties or prop is external:
 /// appendSubtree ( sourceNode, destSchema, replaceOldValues, deleteEmptyValues )
 /// appendSubtree ( sourceNode, destParent, replaceOldValues, deleteEmptyValues ):
 /// if deleteEmptyValues and source value is empty:
 /// delete the corresponding child from destParent
 /// else if sourceNode not in destParent (by name):
 /// copy sourceNode's subtree to destParent
 /// else if replaceOld:
 /// delete subtree from destParent
 /// copy sourceNode's subtree to destParent
 /// else:
 /// // Already exists in dest and not replacing, merge structs and arrays
 /// if sourceNode and destNode forms differ:
 /// return, leave the destNode alone
 /// else if form is a struct:
 /// for each field in sourceNode:
 /// AppendSubtree ( sourceNode.field, destNode, replaceOldValues )
 /// else if form is an alt-text array:
 /// copy new items by "xml:lang" value into the destination
 /// else if form is an array:
 /// copy new items by value into the destination, ignoring order and duplicates
 /// </pre>
 /// </blockquote>
 /// <para /><em>Note:</em> appendProperties can be expensive if replaceOldValues is not passed and
 /// the XMP contains large arrays. The array item checking described above is n-squared.
 /// Each source item is checked to see if it already exists in the destination,
 /// without regard to order or duplicates.
 /// <para />Simple items are compared by value and "xml:lang" qualifier, other qualifiers are ignored.
 /// Structs are recursively compared by field names, without regard to field order. Arrays are
 /// compared by recursively comparing all items.
 /// </remarks>
 /// <param name="source">The source XMP object.</param>
 /// <param name="dest">The destination XMP object.</param>
 /// <param name="doAllProperties">Do internal properties in addition to external properties.</param>
 /// <param name="replaceOldValues">Replace the values of existing properties.</param>
 /// <param name="deleteEmptyValues">Delete destination values if source property is empty.</param>
 /// <exception cref="XmpException">Forwards the Exceptions from the metadata processing</exception>
 /// <exception cref="XmpException"/>
 public static void AppendProperties(IXmpMeta source, IXmpMeta dest, bool doAllProperties, bool replaceOldValues, bool deleteEmptyValues = false)
 {
     Impl.XmpUtils.AppendProperties(source, dest, doAllProperties, replaceOldValues, deleteEmptyValues);
 }
开发者ID:tehkyle,项目名称:xmp-core-dotnet,代码行数:76,代码来源:XMPUtils.cs

示例6: SetSubject

        /**
         * Sets a subject.
         *
         * @param xmpMeta
         * @param subject array of subjects
         */

        public static void SetSubject(IXmpMeta xmpMeta, String[] subject) {
            XmpUtils.RemoveProperties(xmpMeta, XmpConst.NS_DC, SUBJECT, true, true);
            for (int i = 0; i < subject.Length; i++) {
                xmpMeta.AppendArrayItem(XmpConst.NS_DC, SUBJECT, new PropertyOptions(PropertyOptions.ARRAY), subject[i],
                                        null);
            }
        }
开发者ID:yu0410aries,项目名称:itextsharp,代码行数:14,代码来源:DublinCoreProperties.cs

示例7: AddSubject

        /**
         * Adds a subject.
         *
         * @param xmpMeta
         * @param subject
         */

        public static void AddSubject(IXmpMeta xmpMeta, String subject) {
            xmpMeta.AppendArrayItem(XmpConst.NS_DC, SUBJECT, new PropertyOptions(PropertyOptions.ARRAY), subject, null);
        }
开发者ID:yu0410aries,项目名称:itextsharp,代码行数:10,代码来源:DublinCoreProperties.cs

示例8: SetDescription

        /**
         * Sets a description.
         *
         * @param xmpMeta
         * @param desc
         * @param genericLang  The name of the generic language
         * @param specificLang The name of the specific language
         */

        public static void SetDescription(IXmpMeta xmpMeta, String desc, String genericLang, String specificLang) {
            xmpMeta.SetLocalizedText(XmpConst.NS_DC, DESCRIPTION, genericLang, specificLang, desc);
        }
开发者ID:yu0410aries,项目名称:itextsharp,代码行数:12,代码来源:DublinCoreProperties.cs

示例9: AddDescription

        /**
         * Adds a description.
         *
         * @param xmpMeta
         * @param desc
         */

        public static void AddDescription(IXmpMeta xmpMeta, String desc) {
            xmpMeta.AppendArrayItem(XmpConst.NS_DC, DESCRIPTION, new PropertyOptions(PropertyOptions.ARRAY_ALTERNATE),
                                    desc, null);

        }
开发者ID:yu0410aries,项目名称:itextsharp,代码行数:12,代码来源:DublinCoreProperties.cs

示例10: SetTitle

        /**
         * Sets a title.
         *
         * @param xmpMeta
         * @param title
         * @param genericLang  The name of the generic language
         * @param specificLang The name of the specific language
         */

        public static void SetTitle(IXmpMeta xmpMeta, String title, String genericLang, String specificLang) {
            xmpMeta.SetLocalizedText(XmpConst.NS_DC, TITLE, genericLang, specificLang, title);
        }
开发者ID:yu0410aries,项目名称:itextsharp,代码行数:12,代码来源:DublinCoreProperties.cs

示例11: AppendProperties

        /// <param name="source">The source XMP object.</param>
        /// <param name="destination">The destination XMP object.</param>
        /// <param name="doAllProperties">Do internal properties in addition to external properties.</param>
        /// <param name="replaceOldValues">Replace the values of existing properties.</param>
        /// <param name="deleteEmptyValues">Delete destination values if source property is empty.</param>
        /// <exception cref="XmpException">Forwards the Exceptions from the metadata processing</exception>
        public static void AppendProperties(IXmpMeta source, IXmpMeta destination, bool doAllProperties, bool replaceOldValues, bool deleteEmptyValues)
        {
            ParameterAsserts.AssertImplementation(source);
            ParameterAsserts.AssertImplementation(destination);

            var src = (XmpMeta)source;
            var dest = (XmpMeta)destination;
            for (var it = src.GetRoot().IterateChildren(); it.HasNext(); )
            {
                var sourceSchema = (XmpNode)it.Next();

                // Make sure we have a destination schema node
                var destSchema = XmpNodeUtils.FindSchemaNode(dest.GetRoot(), sourceSchema.Name, false);
                var createdSchema = false;

                if (destSchema == null)
                {
                    destSchema = new XmpNode(sourceSchema.Name, sourceSchema.Value, new PropertyOptions { IsSchemaNode = true });
                    dest.GetRoot().AddChild(destSchema);
                    createdSchema = true;
                }

                // Process the source schema's children.
                for (var ic = sourceSchema.IterateChildren(); ic.HasNext(); )
                {
                    var sourceProp = (XmpNode)ic.Next();
                    if (doAllProperties || !Utils.IsInternalProperty(sourceSchema.Name, sourceProp.Name))
                        AppendSubtree(dest, sourceProp, destSchema, replaceOldValues, deleteEmptyValues);
                }

                if (!destSchema.HasChildren && (createdSchema || deleteEmptyValues))
                {
                    // Don't create an empty schema / remove empty schema.
                    dest.GetRoot().RemoveChild(destSchema);
                }
            }
        }
开发者ID:tehkyle,项目名称:xmp-core-dotnet,代码行数:43,代码来源:XmpUtils.cs

示例12: AddAuthor

        /**
         * Adds a single author.
         *
         * @param xmpMeta
         * @param author
         */

        public static void AddAuthor(IXmpMeta xmpMeta, String author) {
            xmpMeta.AppendArrayItem(XmpConst.NS_DC, CREATOR, new PropertyOptions(PropertyOptions.ARRAY_ORDERED), author,
                                    null);
        }
开发者ID:yu0410aries,项目名称:itextsharp,代码行数:11,代码来源:DublinCoreProperties.cs

示例13: SetAuthor

        /**
         * Sets an array of authors.
         *
         * @param xmpMeta
         * @param author
         */

        public static void SetAuthor(IXmpMeta xmpMeta, String[] author) {
            XmpUtils.RemoveProperties(xmpMeta, XmpConst.NS_DC, CREATOR, true, true);
            for (int i = 0; i < author.Length; i++) {
                xmpMeta.AppendArrayItem(XmpConst.NS_DC, CREATOR, new PropertyOptions(PropertyOptions.ARRAY_ORDERED),
                                        author[i], null);
            }
        }
开发者ID:yu0410aries,项目名称:itextsharp,代码行数:14,代码来源:DublinCoreProperties.cs

示例14: AddPublisher

        /**
         * Adds a single publisher.
         *
         * @param xmpMeta
         * @param publisher
         */

        public static void AddPublisher(IXmpMeta xmpMeta, String publisher) {
            xmpMeta.AppendArrayItem(XmpConst.NS_DC, PUBLISHER, new PropertyOptions(PropertyOptions.ARRAY_ORDERED),
                                    publisher, null);
        }
开发者ID:yu0410aries,项目名称:itextsharp,代码行数:11,代码来源:DublinCoreProperties.cs

示例15: AssertImplementation

 /// <summary>
 /// Asserts that the xmp object is of this implemention
 /// (<seealso cref="XmpMetaImpl"/>). </summary>
 /// <param name="xmp"> the XMP object </param>
 /// <exception cref="XmpException"> A wrong implentaion is used. </exception>
 public static void AssertImplementation(IXmpMeta xmp) {
     if (xmp == null) {
         throw new XmpException("Parameter must not be null", XmpError.BADPARAM);
     }
     if (!(xmp is XmpMetaImpl)) {
         throw new XmpException("The XMPMeta-object is not compatible with this implementation",
                                XmpError.BADPARAM);
     }
 }
开发者ID:Gianluigi,项目名称:dssnet,代码行数:14,代码来源:ParameterAsserts.cs


注:本文中的IXmpMeta类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。