本文整理匯總了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));
}
示例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);
}
示例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;
}
示例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;
}
}
示例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;
}
示例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));
}
示例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);
}
示例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);
}
示例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;
}
}
示例10: DateTimeFormat
internal DateTimeFormat(DateTimeFormatTypes dateTimeFormatTypes, XmlElement xmlElement)
{
Name = xmlElement.GetAttributeValue("name");
TypeId = int.Parse(xmlElement.GetAttributeValue("type"));
Example = xmlElement.GetAttributeValue("example");
_formatTypes = dateTimeFormatTypes;
}
示例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);
}
示例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);
}
示例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");
}
示例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);
}
示例15: HtmlItem
public HtmlItem(XmlElement e){
myXmlElement = e;
myId = e.GetAttributeValue(HatomaruHtmlRef.IdAttributeName);
myName = e.GetAttributeValue(HatomaruHtmlRef.NameAttributeName);
myDescription = e[HatomaruHtmlRef.DescElementName];
}