本文整理汇总了C#中Struct.AddAnnotation方法的典型用法代码示例。如果您正苦于以下问题:C# Struct.AddAnnotation方法的具体用法?C# Struct.AddAnnotation怎么用?C# Struct.AddAnnotation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Struct
的用法示例。
在下文中一共展示了Struct.AddAnnotation方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ImportPhase4ComplexType
private SoalType ImportPhase4ComplexType(Struct st, XElement elem)
{
if (st == null)
{
this.Importer.Diagnostics.AddError("Type is missing for the element.", this.Uri, this.GetTextSpan(elem));
return null;
}
string name = st.Name;
XElement complexContentElem = elem.Element(xsd + "complexContent");
XElement simpleContentElem = elem.Element(xsd + "simpleContent");
if (complexContentElem != null)
{
XElement restrictionElem = complexContentElem.Element(xsd + "restriction");
XElement extensionElem = complexContentElem.Element(xsd + "extension");
if (restrictionElem != null)
{
return st;
}
else if (extensionElem != null)
{
XAttribute baseRef = extensionElem.Attribute("base");
if (baseRef != null)
{
XName baseRefName = this.GetXName(extensionElem, baseRef.Value);
SoalType type = this.Importer.ResolveXsdType(baseRefName);
if (type != null)
{
elem = extensionElem;
}
else
{
return null;
}
}
else
{
return null;
}
}
else
{
// nop
}
}
else if (simpleContentElem != null)
{
XElement restrictionElem = simpleContentElem.Element(xsd + "restriction");
XElement extensionElem = simpleContentElem.Element(xsd + "extension");
if (restrictionElem != null)
{
return null;
}
else if (extensionElem != null)
{
return null;
}
else
{
return null;
}
}
XElement sequenceElem = elem.Element(xsd + "sequence");
XElement choiceElem = elem.Element(xsd + "choice");
XElement allElem = elem.Element(xsd + "all");
XElement complexElem = null;
if (sequenceElem != null)
{
complexElem = sequenceElem;
}
else if (choiceElem != null)
{
complexElem = choiceElem;
st.AddAnnotation(SoalAnnotations.Choice);
}
else if (allElem != null)
{
complexElem = allElem;
st.AddAnnotation(SoalAnnotations.All);
}
SoalType rt = this.Importer.ResolveXsdReplacementType(st);
if (complexElem != null)
{
foreach (var child in complexElem.Elements())
{
if (child.Name.Namespace == xsd)
{
if (child.Name.LocalName == "element")
{
this.ImportPhase4ElementProperty(st, rt, child, false);
}
}
}
}
foreach (var child in elem.Elements())
{
if (child.Name.Namespace == xsd)
{
if (child.Name.LocalName == "attribute")
{
this.ImportPhase4ElementProperty(st, rt, child, true);
//.........这里部分代码省略.........
示例2: ImportPhase4ElementProperty
//.........这里部分代码省略.........
else if (!int.TryParse(maxOccursAttr.Value, out maxOccurs))
{
maxOccurs = 1;
}
}
if (type is PrimitiveType)
{
if (nillable && type != SoalInstance.Object && type != SoalInstance.String)
{
NullableType nullable = SoalFactory.Instance.CreateNullableType();
nullable.InnerType = type;
type = nullable;
}
else if (!nillable && (type == SoalInstance.Object || type == SoalInstance.String))
{
NonNullableType nonNull = SoalFactory.Instance.CreateNonNullableType();
nonNull.InnerType = type;
type = nonNull;
}
}
else
{
if (!nillable)
{
NonNullableType nonNull = SoalFactory.Instance.CreateNonNullableType();
nonNull.InnerType = type;
type = nonNull;
}
}
Property prop = SoalFactory.Instance.CreateProperty();
string newName = this.GetNewPropertyName(st, name);
prop.Name = newName;
if (attribute)
{
prop.Type = type;
Annotation attrAnnot = prop.AddAnnotation(SoalAnnotations.Attribute);
if (required)
{
attrAnnot.SetPropertyValue(SoalAnnotationProperties.Required, true);
}
if (newName != name)
{
attrAnnot.SetPropertyValue(SoalAnnotationProperties.Name, name);
}
}
else
{
if (newName != name)
{
Annotation elemAnnot = prop.AddAnnotation(SoalAnnotations.Element);
elemAnnot.SetPropertyValue(SoalAnnotationProperties.Name, name);
}
if (rt != null && rt is ArrayType)
{
if (sap)
{
((ArrayType)rt).InnerType = sapArray.InnerType;
this.Importer.RegisterReplacementType(type, rt);
Annotation arrayAnnot = st.AddAnnotation(SoalAnnotations.Type);
arrayAnnot.SetPropertyValue(SoalAnnotationProperties.Wrapped, true);
arrayAnnot.SetPropertyValue(SoalAnnotationProperties.Items, sapName);
arrayAnnot.SetPropertyValue(SoalAnnotationProperties.Sap, true);
}
else
{
if (type.IsArrayType())
{
type = originalType;
this.Importer.Reference(type);
}
((ArrayType)rt).InnerType = type;
SoalType coreType = type.GetCoreType();
Annotation arrayAnnot = st.AddAnnotation(SoalAnnotations.Type);
arrayAnnot.SetPropertyValue(SoalAnnotationProperties.Wrapped, true);
if (coreType is NamedElement && ((NamedElement)coreType).Name != prop.Name)
{
arrayAnnot.SetPropertyValue(SoalAnnotationProperties.Items, prop.Name);
}
}
prop.Type = rt;
}
else
{
if (maxOccurs < 0 || maxOccurs > 1)
{
ArrayType array = SoalFactory.Instance.CreateArrayType();
array.InnerType = type;
type = array;
}
prop.Type = type;
}
if (minOccurs == 0 && maxOccurs == 1)
{
prop.SetAnnotationPropertyValue(SoalAnnotations.Element, SoalAnnotationProperties.Optional, true);
}
}
this.Importer.RegisterOriginalType((ModelObject)prop, originalType);
st.Properties.Add(prop);
return prop;
}