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


C# XmlElement.GetAttributeValue方法代碼示例

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


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

示例1: CsvQueryColumnConfiguration

        /// <summary>
        /// Instantiates a <see cref="CsvQueryColumnConfiguration"/>
        /// </summary>
        /// <param name="xmlElement"></param>
        public CsvQueryColumnConfiguration(XmlElement xmlElement)
        {
            // validate element
            xmlElement.ShouldBeNamed(ColumnElementName);

            // get attribute values
            _tag = xmlElement.GetAttributeValue(TagAttributeName);
            _description = xmlElement.GetAttributeValue(DescriptionAttributeName);
            _mappedProperty = xmlElement.GetAttributeValue(MappedPropertyAttributeName, false);
            _enabled = bool.Parse(xmlElement.GetAttributeValue(EnabledAttributeName));
        }
開發者ID:CarlosVV,項目名稱:mediavf,代碼行數:15,代碼來源:CsvQueryColumnConfiguration.cs

示例2: LoadXml

// パブリックメソッド

		public void LoadXml(XmlElement e){
			Name = e.GetAttributeValue(ExtInfoName);
			ContentType = e.GetAttributeValue(ExtInfoType);
			Charset = e.GetAttributeValue(ExtInfoCharset);
			Description = e.InnerText;

			string tempDisposition = e.GetAttributeValue(ExtInfoDisposition);
			if(!string.IsNullOrEmpty(tempDisposition)) Disposition = true;

			int maxAgeDays = e.GetAttributeInt(ExtInfoMaxAge);
			MaxAge = new TimeSpan(maxAgeDays, 0, 0, 0);
		}
開發者ID:bakera,項目名稱:Hatomaru.dll,代碼行數:14,代碼來源:extinfo.cs

示例3: YqlPropertyMappingElement

        /// <summary>
        /// Instantiates a <see cref="YqlPropertyMappingElement"/>
        /// </summary>
        /// <param name="xmlElement"></param>
        public YqlPropertyMappingElement(XmlElement xmlElement)
        {
            // validate element
            xmlElement.ShouldBeNamed(PropertyMappingElementName);

            // get attribute values
            _xmlElementName = xmlElement.GetAttributeValue(XmlElementNameAttributeName);
            _propertyName = xmlElement.GetAttributeValue(PropertyNameAttributeName);

            // set enabled, with a default value of false
            bool enabled;
            if (bool.TryParse(xmlElement.GetAttributeValue(EnabledAttributeName, false), out enabled))
                _enabled = enabled;
        }
開發者ID:CarlosVV,項目名稱:mediavf,代碼行數:18,代碼來源:YqlPropertyMappingElement.cs

示例4: HtmlAttribute

// コンストラクタ
		/// <summary>
		/// XmlNode を指定して、HtmlElement クラスのインスタンスを開始します。
		/// </summary>
		public HtmlAttribute(XmlElement e) : base(e){
			myNote = e.GetInnerText(HatomaruHtmlRef.NoteElementName);
			myDefault = e.GetInnerText(HatomaruHtmlRef.DefaultElementName);
			myFor = e.GetAttributeValue(HatomaruHtmlRef.ForAttributeName);
			if(string.IsNullOrEmpty(myId)){
				myId = myName;
				if(!string.IsNullOrEmpty(myFor)) myId += IdSeparator + myFor;
			}
		}
開發者ID:bakera,項目名稱:Hatomaru.dll,代碼行數:13,代碼來源:htmlAttribute.cs

示例5: Map

        public bool Map(object destinationObject, PropertyInfo destinationProperty, XmlElement element, XmlElement allConfig, ConfigMapper mapper)
        {
            var attributeValue = element.GetAttributeValue(AttributeName ??  destinationProperty.Name);

            if (attributeValue == null)
            {
                return false;
            }

            var destinationPropertyType = destinationProperty.PropertyType;

            if (destinationPropertyType.IsEnum)
            {
                var value = Enum.Parse(destinationPropertyType, attributeValue);
                destinationProperty.SetValue(destinationObject, value, null);
                return true;
            }

            if (destinationPropertyType.IsNullable())
            {
                if (attributeValue == "")
                {
                    destinationProperty.SetValue(destinationObject, null, null);
                    return true;
                }
                
                destinationPropertyType = destinationPropertyType.GetGenericArguments()[0];
            }

            if (destinationPropertyType.IsA<IConvertible>())
            {
                var value = Convert.ChangeType(attributeValue, destinationPropertyType);
                destinationProperty.SetValue(destinationObject, value, null);
                return true;
            }

            return false;
        }
開發者ID:bushadam,項目名稱:simple-config,代碼行數:38,代碼來源:AttributeValueAttribute.cs

示例6: GetLifetimeManager

 /// <summary>
 /// Gets a lifetime manager from an attribute of an element
 /// </summary>
 /// <param name="element"></param>
 /// <param name="attributeName"></param>
 /// <returns></returns>
 private static LifetimeManager GetLifetimeManager(XmlElement element, string attributeName)
 {
     return GetLifetimeManager(element.GetAttributeValue(attributeName));
 }
開發者ID:CarlosVV,項目名稱:mediavf,代碼行數:10,代碼來源:AssemblyConfigurationRegistrations.cs

示例7: Deserialize

        /// <exception cref="InvalidException">
        /// The save format is corrupt and could not be loaded.
        /// </exception>
        public override void Deserialize(DeserializeContext context, XmlElement root)
        {
            try
            {
                Language language = Language.GetLanguage(root.GetAttributeValue("Language", "UML"));
                if (language == null)
                    throw new InvalidDataException("Invalid project language.");

                this.language = language;
            }
            catch (Exception ex)
            {
                throw new InvalidException("Invalid project language.", ex);
            }
            base.Deserialize(context, root);
        }
開發者ID:BachelorEric,項目名稱:ModelFirst,代碼行數:19,代碼來源:Project.cs

示例8: CreateRegistration

        /// <summary>
        /// Gets a registration from an xml element
        /// </summary>
        /// <param name="registrationElement"></param>
        /// <returns></returns>
        private static Registration CreateRegistration(XmlElement registrationElement)
        {
            registrationElement.ShouldBeNamed(RegistrationElementName);

            // initialize injection constructor to null
            InjectionConstructor injectionConstructor = null;

            // check for an injection constructor element
            var injectionConstructorElement =
                registrationElement.ChildNodes.OfType<XmlElement>()
                                   .FirstOrDefault(x => x.Name == InjectionConstructorElementName);
            if (injectionConstructorElement != null)
                injectionConstructor = GetInjectionConstructor(injectionConstructorElement);

            return new Registration(registrationElement.GetTypeFromAttribute(RegistrationTypeAttributeName),
                registrationElement.GetTypeFromAttribute(RegistrationMapToAttributeName),
                GetLifetimeManager(registrationElement, RegistrationLifetimeAttributeName),
                registrationElement.GetAttributeValue(RegistrationNameAttributeName, false),
                injectionConstructor);
        }
開發者ID:CarlosVV,項目名稱:mediavf,代碼行數:25,代碼來源:AssemblyConfigurationRegistrations.cs

示例9: LoadSchemaInfo

 void LoadSchemaInfo(XmlElement child, Field field)
 {
     field.GenerateDbColumn = child.GetAttributeValue("GenColumn", false);
     if (field.GenerateDbColumn)
     {
         field.DbSchema.Initialing = true;
         field.DbSchema.Name = child.GetAttributeValue("Name", "");
         field.DbSchema.NotNull = child.GetAttributeValue("NotNull", false);
         field.DbSchema.AutoIncrement = child.GetAttributeValue("AutoIncrement", false);
         field.DbSchema.DbType = child.GetAttributeValue<System.Data.DbType?>("DbType", null);
         field.DbSchema.DefaultValue = child.GetAttributeValue("DefaultValue", "");
         field.DbSchema.Index = child.GetAttributeValue("Index", false);
         field.DbSchema.IsPrimaryKey = child.GetAttributeValue("IsPrimaryKey", false);
         field.DbSchema.Length = child.GetAttributeValue("Length", "");
         field.DbSchema.Initialing = false;
     }
 }
開發者ID:BachelorEric,項目名稱:ModelFirst,代碼行數:17,代碼來源:CompositeType.cs

示例10: DateTimeFormat

 internal DateTimeFormat(DateTimeFormatTypes dateTimeFormatTypes, XmlElement xmlElement)
 {
     Name = xmlElement.GetAttributeValue("name");
     TypeId = int.Parse(xmlElement.GetAttributeValue("type"));
     Example = xmlElement.GetAttributeValue("example");
     _formatTypes = dateTimeFormatTypes;
 }
開發者ID:erminas,項目名稱:smartapi,代碼行數:7,代碼來源:DateTimeFormat.cs

示例11: RunningSessionInfo

 internal RunningSessionInfo(XmlElement element)
 {
     _projectName = element.GetAttributeValue("projectname");
     _moduleName = element.GetAttributeValue("moduledescription");
     _loginDate = element.GetOADate("logindate").GetValueOrDefault();
     _lastActionDate = element.GetOADate("lastactiondate").GetValueOrDefault();
     element.TryGetGuid(out _loginGuid);
 }
開發者ID:erminas,項目名稱:smartapi,代碼行數:8,代碼來源:ISession.cs

示例12: Locale

 protected Locale(ISession session, XmlElement xmlElement)
 {
     _session = session;
     LanguageAbbreviation = xmlElement.GetAttributeValue("id");
     Country = xmlElement.GetAttributeValue("country");
     Language = xmlElement.GetAttributeValue("language");
     IsStandardLanguage = xmlElement.GetBoolAttributeValue("standardlanguage").GetValueOrDefault();
     LCID = xmlElement.GetIntAttributeValue("lcid").GetValueOrDefault();
     RFCLanguageId = xmlElement.GetAttributeValue("rfclanguageid");
     DateTimeFormats = new IndexedCachedList<int, IDateTimeFormat>(GetFormats, x => x.TypeId, Caching.Enabled);
 }
開發者ID:erminas,項目名稱:smartapi,代碼行數:11,代碼來源:Locales.cs

示例13: InfoAttribute

 internal InfoAttribute(XmlElement xmlElement)
 {
     Type = (InfoType) Enum.Parse(typeof (InfoType), xmlElement.Name, true);
     Id = int.Parse(xmlElement.GetAttributeValue("id"));
     Name = xmlElement.GetAttributeValue("name");
 }
開發者ID:erminas,項目名稱:smartapi,代碼行數:6,代碼來源:IInfoAttribute.cs

示例14: GetConstructorParameter

        /// <summary>
        /// Gets a parameter for a constructor from a parameter XmlElement
        /// </summary>
        /// <param name="parameterElement"></param>
        /// <returns></returns>
        private static object GetConstructorParameter(XmlElement parameterElement)
        {
            // ensure element is parameter element
            parameterElement.ShouldBeNamed(ParameterElementName);

            // get flag indicating whether or not to resolve the value of the parameter
            var resolve = parameterElement.GetAttributeValue(ResolveAttributeName).ConvertTo<bool>();

            // get the type of the parameter
            var type = parameterElement.GetTypeFromAttribute(TypeAttributeName);

            // get value to be passed in - if resolving, this is not required
            var value = parameterElement.GetAttributeValue(ValueAttributeName, !resolve);

            // get value for parameter
            return resolve
                ? new ResolvedParameter(type, string.IsNullOrWhiteSpace(value) ? value : null)
                : value.ConvertTo(type);
        }
開發者ID:CarlosVV,項目名稱:mediavf,代碼行數:24,代碼來源:AssemblyConfigurationRegistrations.cs

示例15: HtmlItem

		public HtmlItem(XmlElement e){
			myXmlElement = e;
			myId = e.GetAttributeValue(HatomaruHtmlRef.IdAttributeName);
			myName = e.GetAttributeValue(HatomaruHtmlRef.NameAttributeName);
			myDescription = e[HatomaruHtmlRef.DescElementName];
		}
開發者ID:bakera,項目名稱:Hatomaru.dll,代碼行數:6,代碼來源:htmlItem.cs


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