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


C# Linq.XName類代碼示例

本文整理匯總了C#中System.Xml.Linq.XName的典型用法代碼示例。如果您正苦於以下問題:C# XName類的具體用法?C# XName怎麽用?C# XName使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


XName類屬於System.Xml.Linq命名空間,在下文中一共展示了XName類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: GetValueFromXml

        protected override object GetValueFromXml(XElement root, XName name, PropertyInfo prop)
        {
            var isAttribute = false;

            // Check for the DeserializeAs attribute on the property
            var options = prop.GetAttribute<DeserializeAsAttribute>();

            if (options != null)
            {
                name = options.Name ?? name;
                isAttribute = options.Attribute;
            }

            if (isAttribute)
            {
                var attributeVal = GetAttributeByName(root, name);

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

            return base.GetValueFromXml(root, name, prop);
        }
開發者ID:mgulubov,項目名稱:RestSharpHighQualityCodeTeamProject,代碼行數:25,代碼來源:XmlAttributeDeserializer.cs

示例2: PropertyManager

 /// <summary>
 /// Initializes a new instance of the <see cref="PropertyManager"/> class.
 /// </summary>
 public PropertyManager(string schema)
 {
     keyElementName = XName.Get("Key", schema);
     entityTypeName = XName.Get(entityTypeNameString, schema);
     entityContainerName = XName.Get("EntityContainer", schema);
     entitySetName = XName.Get("EntitySet", schema);
 }
開發者ID:mlzharov,項目名稱:Asp.Net-Identity-Tools-for-Entity-Framework-model,代碼行數:10,代碼來源:PropertyManager.cs

示例3: SetValue

        public static void SetValue(XElement _parent, PropertyExtensionContext _context, XName xName, bool value)
        {
            bool propertyValue = value;

            // Make changes to the .edmx document in an EntityDesignerChangeScope to enable undo/redo of changes.
            using (EntityDesignerChangeScope scope = _context.CreateChangeScope("Set EDMXFileTools"))
            {
                if (_parent.HasElements)
                {
                    XElement lastChild = _parent.Elements().Where<XElement>(element => element != null && element.Name == xName).LastOrDefault();
                    if (lastChild != null)
                    {
                        // Property element already exists under the EntityType element, so update its value.
                        lastChild.SetValue(propertyValue.ToString());
                    }
                    else
                    {
                        // Property element does not exist, so create a new one as the last child of the EntityType element.
                        _parent.Elements().Last().AddAfterSelf(new XElement(xName, propertyValue.ToString()));
                    }
                }
                else
                {
                    // The element has no child elements so create a new MyNewProperty element as its first child.
                    _parent.Add(new XElement(xName, propertyValue.ToString()));
                }

                // Commit the changes.
                scope.Complete();
            }
        }
開發者ID:jradxl,項目名稱:Generate-Database-Edmx-Automation,代碼行數:31,代碼來源:PropertyManager.cs

示例4: CreateDocument

 private static XDocument CreateDocument(XName rootName, IFileSystem fileSystem, string path)
 {
     XDocument document = new XDocument(new XElement(rootName));
     // Add it to the file system
     fileSystem.AddFile(path, document.Save);
     return document;
 }
開發者ID:OsirisTerje,項目名稱:sonarlint-vs,代碼行數:7,代碼來源:XmlUtility.cs

示例5: AddAttribute

        /// <summary>
        ///     Adds a new attribute to the element
        ///     Does not permit modification of an existing attribute.
        ///     Does not add empty or null attributes or values.
        /// </summary>
        /// <param name="element">The element to add the attribute to</param>
        /// <param name="attribute">The attribute to add</param>
        /// <param name="value">the value of the attribute to add</param>
        /// <returns>The element passed in. (Permits fluent usage)</returns>
        internal static XElement AddAttribute(this XElement element, XName attribute, string value) {
            if (element == null) {
                return null;
            }

            // we quietly ignore attempts to add empty data or attributes.
            if (string.IsNullOrWhiteSpace(value) || attribute == null || string.IsNullOrWhiteSpace(attribute.ToString())) {
                return element;
            }

            // Swidtag attributes can be added but not changed -- if it already exists, that's not permitted.
            var current = element.GetAttribute(attribute);
            if (!string.IsNullOrWhiteSpace(current)) {
                if (value != current) {
                    throw new Exception("Attempt to change Attribute '{0}' present in element '{1}'".format(attribute.LocalName, element.Name.LocalName));
                }

                // if the value was set to that already, don't worry about it.
                return element;
            }

            element.SetAttributeValue(attribute, value);

            return element;
        }
開發者ID:40a,項目名稱:PowerShell,代碼行數:34,代碼來源:Iso19770_2.cs

示例6: Ancestors

		public static IEnumerable<XElement> Ancestors(this XNode node, XName name, bool ignoreNamespace)
		{
			if (ignoreNamespace)
				return node.Ancestors().Where(e => e.Name.LocalName == name.LocalName);
			else
				return node.Ancestors(name);
		}
開發者ID:arajar,項目名稱:duality,代碼行數:7,代碼來源:ExtMethodsXml.cs

示例7: ElementsAfterSelf

		public static IEnumerable<XElement> ElementsAfterSelf(this XContainer node, XName name, bool ignoreNamespace)
		{
			if (ignoreNamespace)
				return node.ElementsAfterSelf().Where(e => e.Name.LocalName == name.LocalName);
			else
				return node.ElementsAfterSelf(name);
		}
開發者ID:arajar,項目名稱:duality,代碼行數:7,代碼來源:ExtMethodsXml.cs

示例8: ExecuteFSMSubGroup

        internal XElement ExecuteFSMSubGroup(IEnumerator<XElement> enumerator, XName[] namesInList) {
            
            Debug.Assert(namesInList != null);

            XElement currElem = null;
            WildCard matchingWildCard = null;
            XName matchingName = null;
            
            while(enumerator.MoveNext()){
                currElem = enumerator.Current;
                currentState = FsmMakeTransition(currentState, currElem.Name, out matchingName, out matchingWildCard);
                                 
                if (currentState!= FSM.InvalidState) {
                      if ( matchingName != null) 
                          for(int i =0; i < namesInList.Length; i++) {
                            if (namesInList.GetValue(i).Equals(currElem.Name)) return currElem;
                          }
                }
                else {//Get stuck. No recovery attempt is provided for now.
                    return null;
                }
            }
         
             //No matching elements/wildcards are found
             return null;
        }
開發者ID:pusp,項目名稱:o2platform,代碼行數:26,代碼來源:FsmXObjects.cs

示例9: ExecuteFSM

 internal XElement ExecuteFSM(IEnumerator<XElement> enumerator, XName requestingXName, WildCard requestingWildCard) {
     
     XElement currElem = null;
     WildCard matchingWildCard = null;
     XName matchingName = null;
     
     while(enumerator.MoveNext()){
         currElem = enumerator.Current;
         currentState = FsmMakeTransition(currentState, currElem.Name, out matchingName, out matchingWildCard);
                          
         if (currentState!= FSM.InvalidState) {
               if ( (requestingXName != null) && (matchingName != null)) {
                    if (requestingXName.Equals(currElem.Name)) return currElem;
               }
               else if ( (requestingWildCard != null) && (matchingWildCard != null) ){//requesting for ANY
                 if (requestingWildCard.Allows(currElem.Name)) //Make sure current element is allowed by requesting ANY property
                     return currElem;                            
             }
         } 
         else {//Get stuck. No recovery attempt is provided for now.
             return null;
         }
     }
  //No matching elements/wildcards are found
  return null;
 }
開發者ID:pusp,項目名稱:o2platform,代碼行數:26,代碼來源:FsmXObjects.cs

示例10: GenerateXElement

        internal XElement GenerateXElement(XName name)
        {
            XNamespace xmlns = name.Namespace;
            XElement element = new XElement(name);

            return element;
        }
開發者ID:onesimoh,項目名稱:Andamio,代碼行數:7,代碼來源:Table.cs

示例11: GetElementValue

 public static string GetElementValue(this XContainer elem, XName elementName)
 {
     XElement childElement = elem.Element(elementName);
     if (childElement != null)
         return childElement.Value;
     return null;
 }
開發者ID:Titaye,項目名稱:SLExtensions,代碼行數:7,代碼來源:XElementExtensions.cs

示例12: GetAttribute

 public static string GetAttribute(this XElement elem, XName attributeName)
 {
     XAttribute attribute = elem.Attribute(attributeName);
     if (attribute != null)
         return attribute.Value;
     return null;
 }
開發者ID:Titaye,項目名稱:SLExtensions,代碼行數:7,代碼來源:XElementExtensions.cs

示例13: AttributeValue

 internal static string AttributeValue(this XElement xml, XName attributeName)
 {
     var attribute = xml.Attribute(attributeName);
     if (null == attribute)
         return null;
     return attribute.Value;
 }
開發者ID:ahaadi,項目名稱:markdown-scanner,代碼行數:7,代碼來源:ExtensionMethods.cs

示例14: GetStringAttribute

 public static string GetStringAttribute(this XElement element, XName name)
 {
     XAttribute xattribute = element.Attribute(name);
     if (xattribute != null)
         return xattribute.Value;
     return string.Empty;
 }
開發者ID:Korshunoved,項目名稱:Win10reader,代碼行數:7,代碼來源:XmlExtensions.cs

示例15: Descendants

		public static IEnumerable<XElement> Descendants(this XContainer container, XName name, bool ignoreNamespace)
		{
			if (ignoreNamespace)
				return container.Descendants().Where(e => e.Name.LocalName == name.LocalName);
			else
				return container.Descendants(name);
		}
開發者ID:arajar,項目名稱:duality,代碼行數:7,代碼來源:ExtMethodsXml.cs


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