當前位置: 首頁>>代碼示例>>C#>>正文


C# XmpNode.FindChildByName方法代碼示例

本文整理匯總了C#中iTextSharp.xmp.impl.XmpNode.FindChildByName方法的典型用法代碼示例。如果您正苦於以下問題:C# XmpNode.FindChildByName方法的具體用法?C# XmpNode.FindChildByName怎麽用?C# XmpNode.FindChildByName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在iTextSharp.xmp.impl.XmpNode的用法示例。


在下文中一共展示了XmpNode.FindChildByName方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: FindChildNode

        /// <summary>
        /// Find or create a child node under a given parent node. If the parent node is no 
        /// Returns the found or created child node.
        /// </summary>
        /// <param name="parent">
        ///            the parent node </param>
        /// <param name="childName">
        ///            the node name to find </param>
        /// <param name="createNodes">
        ///            flag, if new nodes shall be created. </param>
        /// <returns> Returns the found or created node or <code>null</code>. </returns>
        /// <exception cref="XmpException"> Thrown if  </exception>
        internal static XmpNode FindChildNode(XmpNode parent, string childName, bool createNodes) {
            if (!parent.Options.SchemaNode && !parent.Options.Struct) {
                if (!parent.Implicit) {
                    throw new XmpException("Named children only allowed for schemas and structs",
                                           XmpError.BADXPATH);
                }
                if (parent.Options.Array) {
                    throw new XmpException("Named children not allowed for arrays", XmpError.BADXPATH);
                }
                if (createNodes) {
                    parent.Options.Struct = true;
                }
            }

            XmpNode childNode = parent.FindChildByName(childName);

            if (childNode == null && createNodes) {
                PropertyOptions options = new PropertyOptions();
                childNode = new XmpNode(childName, options);
                childNode.Implicit = true;
                parent.AddChild(childNode);
            }

            Debug.Assert(childNode != null || !createNodes);

            return childNode;
        }
開發者ID:Gianluigi,項目名稱:dssnet,代碼行數:39,代碼來源:XmpNodeUtils.cs

示例2: FindSchemaNode

        /// <summary>
        /// Find or create a schema node if <code>createNodes</code> is true.
        /// </summary>
        /// <param name="tree"> the root of the xmp tree. </param>
        /// <param name="namespaceUri"> a namespace </param>
        /// <param name="suggestedPrefix"> If a prefix is suggested, the namespace is allowed to be registered. </param>
        /// <param name="createNodes"> a flag indicating if the node shall be created if not found.
        /// 		  <em>Note:</em> The namespace must be registered prior to this call.
        /// </param>
        /// <returns> Returns the schema node if found, <code>null</code> otherwise.
        /// 		   Note: If <code>createNodes</code> is <code>true</code>, it is <b>always</b>
        /// 		   returned a valid node. </returns>
        /// <exception cref="XmpException"> An exception is only thrown if an error occurred, not if a
        ///         		node was not found. </exception>
        internal static XmpNode FindSchemaNode(XmpNode tree, string namespaceUri, string suggestedPrefix,
                                               bool createNodes) {
            Debug.Assert(tree.Parent == null); // make sure that its the root
            XmpNode schemaNode = tree.FindChildByName(namespaceUri);

            if (schemaNode == null && createNodes) {
                PropertyOptions propertyOptions = new PropertyOptions();
                propertyOptions.SchemaNode = true;
                schemaNode = new XmpNode(namespaceUri, propertyOptions);
                schemaNode.Implicit = true;

                // only previously registered schema namespaces are allowed in the XMP tree.
                string prefix = XMPMetaFactory.SchemaRegistry.GetNamespacePrefix(namespaceUri);
                if (prefix == null) {
                    if (!String.IsNullOrEmpty(suggestedPrefix)) {
                        prefix = XMPMetaFactory.SchemaRegistry.RegisterNamespace(namespaceUri, suggestedPrefix);
                    }
                    else {
                        throw new XmpException("Unregistered schema namespace URI", XmpError.BADSCHEMA);
                    }
                }

                schemaNode.Value = prefix;

                tree.AddChild(schemaNode);
            }

            return schemaNode;
        }
開發者ID:Gianluigi,項目名稱:dssnet,代碼行數:43,代碼來源:XmpNodeUtils.cs


注:本文中的iTextSharp.xmp.impl.XmpNode.FindChildByName方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。