本文整理匯總了C#中System.Xml.Linq.XElement.GetRequiredAttributeValue方法的典型用法代碼示例。如果您正苦於以下問題:C# XElement.GetRequiredAttributeValue方法的具體用法?C# XElement.GetRequiredAttributeValue怎麽用?C# XElement.GetRequiredAttributeValue使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Xml.Linq.XElement
的用法示例。
在下文中一共展示了XElement.GetRequiredAttributeValue方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: FromXElement
internal static ContentProjectItemNode FromXElement(XElement element)
{
if (element == null)
throw new ArgumentNullException("element");
ContentProjectItemNode item = new ContentProjectItemNode();
item.Name = element.GetRequiredAttributeValue("Name");
var importNode = element.Element("Import");
if (importNode != null)
item.Import = ContentProjectImportNode.FromXElement(importNode);
var processorsNode = element.Element("Processors");
if (processorsNode != null)
{
foreach (var processorNode in processorsNode.Elements())
{
item.Processors.Add(ContentProjectProcessorNode.FromXElement(processorNode));
}
}
var serializeNode = element.Element("Serialize");
if (serializeNode != null)
item.Serialize = ContentProjectSerializeNode.FromXElement(serializeNode);
return item;
}
示例2: FromXElement
internal static ContentProjectImportNode FromXElement(XElement element)
{
if (element == null)
throw new ArgumentNullException("element");
ContentProjectImportNode import = new ContentProjectImportNode();
import.FileName = element.GetRequiredAttributeValue("FileName");
return import;
}
示例3: FromXElement
internal static ContentProjectReferenceNode FromXElement(XElement element)
{
if (element == null)
throw new ArgumentNullException("element");
ContentProjectReferenceNode reference = new ContentProjectReferenceNode();
reference.FileName = element.GetRequiredAttributeValue("FileName");
return reference;
}
示例4: FromXElement
internal static ContentProjectSerializeNode FromXElement(XElement element)
{
if (element == null)
throw new ArgumentNullException("element");
ContentProjectSerializeNode serializer = new ContentProjectSerializeNode();
serializer.FileName = element.GetRequiredAttributeValue("FileName");
foreach (XAttribute attribute in element.Attributes().Where(x => x.Name != "FileName"))
{
serializer.Parameters[attribute.Name.ToString()] = attribute.Value;
}
return serializer;
}
示例5: RegisterNominalTypes
private void RegisterNominalTypes(XElement schemaElement)
{
this.AssertXsdlElement(schemaElement, "Schema");
string namespaceName = schemaElement.GetRequiredAttributeValue("Namespace");
foreach (var entityTypeElement in schemaElement.Elements().Where(el => this.IsXsdlElement(el, "EntityType")))
{
string name = entityTypeElement.GetRequiredAttributeValue("Name");
this.entityTypeFullNames.Add(namespaceName + "." + name);
}
foreach (var complexTypeElement in schemaElement.Elements().Where(el => this.IsXsdlElement(el, "ComplexType")))
{
string name = complexTypeElement.GetRequiredAttributeValue("Name");
this.complexTypeFullNames.Add(namespaceName + "." + name);
}
foreach (var enumTypeElement in schemaElement.Elements().Where(el => this.IsXsdlElement(el, "EnumType")))
{
string name = enumTypeElement.GetRequiredAttributeValue("Name");
this.enumTypeFullNames.Add(namespaceName + "." + name);
}
}
示例6: ParseAssociationSetEnd
private AssociationSetEnd ParseAssociationSetEnd(XElement associationSetEndElement)
{
string roleName = associationSetEndElement.GetRequiredAttributeValue("Role");
var entitySetName = associationSetEndElement.GetRequiredAttributeValue("EntitySet");
var associationSetEnd = new AssociationSetEnd(roleName, entitySetName);
this.ParseAnnotations(associationSetEnd, associationSetEndElement);
return associationSetEnd;
}
示例7: ParseAssociationSet
private AssociationSet ParseAssociationSet(XElement associationSetElement)
{
string associationSetName = associationSetElement.GetRequiredAttributeValue("Name");
string associationTypeNamespace = this.ParseEdmTypeName(associationSetElement.GetRequiredAttributeValue("Association"))[0];
string associationTypeName = this.ParseEdmTypeName(associationSetElement.GetRequiredAttributeValue("Association"))[1];
var associationSet = new AssociationSet(associationSetName, new AssociationTypeReference(associationTypeNamespace, associationTypeName));
foreach (var associationSetEndElement in associationSetElement.Elements().Where(el => this.IsXsdlElement(el, "End")))
{
associationSet.Ends.Add(this.ParseAssociationSetEnd(associationSetEndElement));
}
this.ParseAnnotations(associationSet, associationSetElement);
return associationSet;
}
示例8: ParseProperty
/// <summary>
/// Parse a Property from its XElement
/// </summary>
/// <param name="propertyElement">XElement to parse Property from</param>
/// <returns>A memberProperty</returns>
protected virtual MemberProperty ParseProperty(XElement propertyElement)
{
var name = propertyElement.GetRequiredAttributeValue("Name");
DataType dataType = this.ParsePropertyDataType(propertyElement);
var memberProperty = new MemberProperty(name, dataType);
if (propertyElement.GetOptionalAttributeValue("ConcurrencyMode", "None") == "Fixed")
{
memberProperty.Annotations.Add(new ConcurrencyTokenAnnotation());
}
this.ParseAnnotations(memberProperty, propertyElement);
return memberProperty;
}
示例9: ParseType
/// <summary>
/// Parses a XElement that contains type information
/// Accepts an element that is a CollectionType, RowType, ReferenceType, and TypeRef
/// </summary>
/// <param name="typeElement">XElement that contains a Type element</param>
/// <returns>DataType represented by the XElement</returns>
protected DataType ParseType(XElement typeElement)
{
if (typeElement.Name.LocalName == "CollectionType")
{
string elementTypeName = typeElement.GetOptionalAttributeValue("ElementType", null);
if (elementTypeName != null)
{
bool isNullable = XmlConvert.ToBoolean(typeElement.GetOptionalAttributeValue("Nullable", "true"));
DataType dataType = this.ParseType(elementTypeName, isNullable, typeElement.Attributes());
return DataTypes.CollectionType.WithElementDataType(dataType);
}
else
{
var elementType = typeElement.Elements().Single(e => this.IsXsdlNamespace(e.Name.NamespaceName));
return DataTypes.CollectionType.WithElementDataType(this.ParseType(elementType));
}
}
else if (typeElement.Name.LocalName == "RowType")
{
var row = new RowType();
foreach (var propertyElement in typeElement.Elements().Where(el => this.IsXsdlElement(el, "Property")))
{
row.Properties.Add(this.ParseProperty(propertyElement));
}
return DataTypes.RowType.WithDefinition(row);
}
else if (typeElement.Name.LocalName == "ReferenceType")
{
DataType dataType = this.ParseType(typeElement.GetRequiredAttributeValue("Type"), true, null);
return DataTypes.ReferenceType.WithEntityType((dataType as EntityDataType).Definition);
}
else if (typeElement.Name.LocalName == "TypeRef")
{
bool isNullable = XmlConvert.ToBoolean(typeElement.GetOptionalAttributeValue("Nullable", "true"));
DataType dataType = this.ParseType(typeElement.GetRequiredAttributeValue("Type"), isNullable, typeElement.Attributes());
return dataType;
}
else
{
throw new TaupoNotSupportedException("Unsupported data type element: " + typeElement.Name.LocalName);
}
}
示例10: ParseEnumMember
private EnumMember ParseEnumMember(XElement memberElement)
{
string name = memberElement.GetRequiredAttributeValue("Name");
string valueString = memberElement.GetOptionalAttributeValue("Value", null);
var member = new EnumMember(name, valueString);
this.ParseAnnotations(member, memberElement);
return member;
}
示例11: ParseAssociationEnd
private AssociationEnd ParseAssociationEnd(XElement associationEndElement)
{
var roleName = associationEndElement.GetRequiredAttributeValue("Role");
string entityTypeNamespace = this.ParseEdmTypeName(associationEndElement.GetRequiredAttributeValue("Type"))[0];
string entityTypeName = this.ParseEdmTypeName(associationEndElement.GetRequiredAttributeValue("Type"))[1];
EndMultiplicity multiplicity = this.ParseEndMultiplicity(associationEndElement.GetRequiredAttributeValue("Multiplicity"));
OperationAction onDeleteAction = associationEndElement.Descendants().Any(e => e.Name.LocalName.Equals("OnDelete") && e.Attribute("Action").Value.Equals("Cascade")) ? OperationAction.Cascade : OperationAction.None;
AssociationEnd end = new AssociationEnd(roleName, new EntityTypeReference(entityTypeNamespace, entityTypeName), multiplicity, onDeleteAction);
this.ParseAnnotations(end, associationEndElement);
return end;
}
示例12: ParseFunctionParameter
/// <summary>
/// Parses a function element
/// </summary>
/// <param name="parameterElement">the function element in the schema file</param>
/// <returns>the function parameter representation in the entity model schema</returns>
protected FunctionParameter ParseFunctionParameter(XElement parameterElement)
{
string parameterName = parameterElement.GetRequiredAttributeValue("Name");
DataType parameterType;
string parameterTypeName = parameterElement.GetOptionalAttributeValue("Type", null);
bool isNullable = XmlConvert.ToBoolean(parameterElement.GetOptionalAttributeValue("Nullable", "true"));
if (parameterTypeName != null)
{
parameterType = this.ParseType(parameterTypeName, isNullable, parameterElement.Attributes());
}
else
{
var parameterTypeElement = parameterElement.Elements().Single(e => this.IsXsdlNamespace(e.Name.NamespaceName));
parameterType = this.ParseType(parameterTypeElement);
}
FunctionParameter parameter = new FunctionParameter()
{
Name = parameterName,
DataType = parameterType,
};
string parameterMode = parameterElement.GetOptionalAttributeValue("Mode", null);
if (parameterMode != null)
{
parameter.Mode = (FunctionParameterMode)Enum.Parse(typeof(FunctionParameterMode), parameterMode, true);
}
this.ParseAnnotations(parameter, parameterElement);
return parameter;
}
示例13: ParseEntityType
/// <summary>
/// Parses an entity type element in the csdl/ssdl file.
/// </summary>
/// <param name="entityTypeElement">the entity type element to parse</param>
/// <returns>the parsed entity type object in the entity model schema</returns>
protected virtual EntityType ParseEntityType(XElement entityTypeElement)
{
string name = entityTypeElement.GetRequiredAttributeValue("Name");
var entityType = new EntityType(this.CurrentNamespace, name);
foreach (var propertyElement in entityTypeElement.Elements().Where(el => this.IsXsdlElement(el, "Property")))
{
entityType.Properties.Add(this.ParseProperty(propertyElement));
}
var keyElement = entityTypeElement.Elements().Where(c => this.IsXsdlElement(c, "Key")).SingleOrDefault();
if (keyElement != null)
{
foreach (var propertyRefElement in keyElement.Elements().Where(c => this.IsXsdlElement(c, "PropertyRef")))
{
string propertyName = propertyRefElement.GetRequiredAttributeValue("Name");
var property = entityType.Properties.Single(p => p.Name == propertyName);
property.IsPrimaryKey = true;
}
}
this.ParseAnnotations(entityType, entityTypeElement);
return entityType;
}
示例14: ParseEntityContainer
/// <summary>
/// Parses an entity container element in the csdl/ssdl file.
/// </summary>
/// <param name="entityContainerElement">the entity container element to parse</param>
/// <returns>the parsed entity container object in the entity model schema</returns>
protected virtual EntityContainer ParseEntityContainer(XElement entityContainerElement)
{
string name = entityContainerElement.GetRequiredAttributeValue("Name");
var entityContainer = new EntityContainer(name);
foreach (var entitySetElement in entityContainerElement.Elements().Where(el => this.IsXsdlElement(el, "EntitySet")))
{
entityContainer.Add(this.ParseEntitySet(entitySetElement));
}
foreach (var entitySetElement in entityContainerElement.Elements().Where(el => this.IsXsdlElement(el, "AssociationSet")))
{
entityContainer.Add(this.ParseAssociationSet(entitySetElement));
}
this.ParseAnnotations(entityContainer, entityContainerElement);
return entityContainer;
}
示例15: ParseComplexType
private ComplexType ParseComplexType(XElement complexTypeElement)
{
string name = complexTypeElement.GetRequiredAttributeValue("Name");
var complexType = new ComplexType(this.CurrentNamespace, name);
this.ParseNamedStructuralTypeAttributes(complexTypeElement, complexType);
foreach (var propertyElement in complexTypeElement.Elements().Where(el => this.IsXsdlElement(el, "Property")))
{
complexType.Properties.Add(this.ParseProperty(propertyElement));
}
this.ParseAnnotations(complexType, complexTypeElement);
return complexType;
}