本文整理汇总了C#中System.Xml.Schema.XmlSchemaAnnotation类的典型用法代码示例。如果您正苦于以下问题:C# XmlSchemaAnnotation类的具体用法?C# XmlSchemaAnnotation怎么用?C# XmlSchemaAnnotation使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
XmlSchemaAnnotation类属于System.Xml.Schema命名空间,在下文中一共展示了XmlSchemaAnnotation类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SchemaDocumentation
public SchemaDocumentation(XmlSchemaAnnotation annotation)
{
this.annotation = annotation;
if (annotation != null) {
ReadDocumentationFromAnnotation(annotation.Items);
}
}
示例2: ProcessAnnotation
private static string ProcessAnnotation(XmlSchemaAnnotation schemaAnnotation)
{
StringBuilder result = new StringBuilder();
if (schemaAnnotation == null)
return result.ToString();
foreach (XmlSchemaObject schemaObject in schemaAnnotation.Items)
{
if (schemaObject is XmlSchemaAppInfo)
result.Append(ProcessAppInfo((XmlSchemaAppInfo)schemaObject));
else if (schemaObject is XmlSchemaDocumentation)
result.Append(ProcessDocumentation((XmlSchemaDocumentation)schemaObject));
else
result.AppendLine(string.Format("Unsupported annotation type: {0}", schemaObject));
}
return result.ToString();
}
示例3: ImportEnum
static WebServiceEnumData ImportEnum(string typeName, string typeNamespace, XmlQualifiedName typeQualifiedName, XmlSchemaSimpleTypeRestriction restriction, XmlSchemaAnnotation annotation) {
// CheckIfEnum has already checked if baseType of restriction is string
XmlQualifiedName baseTypeName = ImportActualType(annotation, new XmlQualifiedName("int", XmlSchema.Namespace), typeQualifiedName);
Type baseEnumType = _nameToType[baseTypeName];
bool isULong = (baseEnumType == typeof(ulong));
List<string> enumNames = new List<string>();
List<long> enumValues = new List<long>();
foreach (XmlSchemaFacet facet in restriction.Facets) {
XmlSchemaEnumerationFacet enumFacet = facet as XmlSchemaEnumerationFacet;
Debug.Assert(enumFacet != null);
Debug.Assert(enumFacet.Value != null);
string valueInnerText = GetInnerText(typeQualifiedName, ImportAnnotation(enumFacet.Annotation, EnumerationValueAnnotationName));
long value;
if (valueInnerText == null) {
// ASP .NET AJAX doesn't honor the Flags nature of Flags enums
// If it were to, we would assign Math.Pow(2, nameValues.Count) for Flags enums instead.
value = enumNames.Count;
}
else {
if (isULong) {
value = (long)ulong.Parse(valueInnerText, NumberFormatInfo.InvariantInfo);
}
else {
value = long.Parse(valueInnerText, NumberFormatInfo.InvariantInfo);
}
}
enumNames.Add(enumFacet.Value);
enumValues.Add(value);
}
return new WebServiceEnumData(typeName, typeNamespace, enumNames.ToArray(), enumValues.ToArray(), isULong);
}
示例4: Write5_XmlSchemaAnnotation
void Write5_XmlSchemaAnnotation(XmlSchemaAnnotation o) {
if ((object)o == null) return;
WriteStartElement("annotation");
WriteAttribute(@"id", @"", ((System.String)[email protected]));
WriteAttributes((XmlAttribute[])[email protected], o);
System.Xml.Schema.XmlSchemaObjectCollection a = (System.Xml.Schema.XmlSchemaObjectCollection)[email protected];
if (a != null) {
for (int ia = 0; ia < a.Count; ia++) {
XmlSchemaObject ai = (XmlSchemaObject)a[ia];
if (ai is XmlSchemaAppInfo) {
Write7_XmlSchemaAppInfo((XmlSchemaAppInfo)ai);
}
else if (ai is XmlSchemaDocumentation) {
Write6_XmlSchemaDocumentation((XmlSchemaDocumentation)ai);
}
}
}
WriteEndElement();
}
示例5: AddAnnotation
internal override void AddAnnotation(XmlSchemaAnnotation annotation)
{
this.annotation = annotation;
}
示例6: AddXmlnsAnnotation
private void AddXmlnsAnnotation(XmlSchemaComplexType type, string xmlnsMemberName)
{
XmlSchemaAnnotation annotation = new XmlSchemaAnnotation();
XmlSchemaAppInfo item = new XmlSchemaAppInfo();
XmlDocument document = new XmlDocument();
XmlElement element = document.CreateElement("keepNamespaceDeclarations");
if (xmlnsMemberName != null)
{
element.InsertBefore(document.CreateTextNode(xmlnsMemberName), null);
}
item.Markup = new XmlNode[] { element };
annotation.Items.Add(item);
type.Annotation = annotation;
}
示例7: HandleAnnotations
private void HandleAnnotations (XmlSchemaAnnotation an, bool nested)
{
foreach (XmlSchemaObject content in an.Items) {
XmlSchemaAppInfo ai = content as XmlSchemaAppInfo;
if (ai != null) {
foreach (XmlNode n in ai.Markup) {
XmlElement el = n as XmlElement;
if (el != null && el.LocalName == "Relationship" && el.NamespaceURI == XmlConstants.MsdataNamespace)
HandleRelationshipAnnotation (el, nested);
}
}
}
}
示例8: GetDocumentation
static string GetDocumentation(XmlSchemaAnnotation annotation)
{
return new SchemaDocumentation(annotation).ToString();
}
示例9: GetMarkup
static string GetMarkup(XmlSchemaAnnotation ann, string filter, string language)
{
StringBuilder sb = new StringBuilder();
foreach (XmlSchemaObject o in ann.Items) {
// for xs:documentation nodes
if (o is XmlSchemaDocumentation) {
XmlSchemaDocumentation d = (XmlSchemaDocumentation)o;
if (string.IsNullOrEmpty(language) || d.Language == language)
{
XmlNode[] ma = d.Markup;
if (ma != null)
{
// if we only have the xs:documentation node (no markup)...
foreach (XmlNode n in ma)
{
if (!string.IsNullOrEmpty(filter))
{
if (string.Compare(filter, n.LocalName, StringComparison.InvariantCultureIgnoreCase) == 0)
{
sb.Append(n.InnerText);
}
}
else
{
sb.Append(n.InnerText);
}
}
}
}
}
}
return sb.ToString();
}
示例10: GetDocumentation
/// <summary>
/// Gets the documentation from the annotation element.
/// </summary>
/// <remarks>
/// All documentation elements are added. All text nodes inside
/// the documentation element are added.
/// </remarks>
string GetDocumentation(XmlSchemaAnnotation annotation)
{
string documentation = String.Empty;
if (annotation != null) {
StringBuilder documentationBuilder = new StringBuilder();
foreach (XmlSchemaObject schemaObject in annotation.Items) {
XmlSchemaDocumentation schemaDocumentation = schemaObject as XmlSchemaDocumentation;
if (schemaDocumentation != null) {
foreach (XmlNode node in schemaDocumentation.Markup) {
XmlText textNode = node as XmlText;
if (textNode != null) {
if (textNode.Data != null) {
if (textNode.Data.Length > 0) {
documentationBuilder.Append(textNode.Data);
}
}
}
}
}
}
documentation = documentationBuilder.ToString();
}
return documentation;
}
示例11: AddElement
/// <summary>
/// Adds an element completion data to the collection if it does not
/// already exist.
/// </summary>
void AddElement(XmlCompletionDataCollection data, string name, string prefix, XmlSchemaAnnotation annotation)
{
// Get any annotation documentation.
string documentation = GetDocumentation(annotation);
AddElement(data, name, prefix, documentation);
}
示例12: AddAttributeValue
/// <summary>
/// Adds an attribute value to the completion data collection.
/// </summary>
void AddAttributeValue(XmlCompletionDataCollection data, string valueText, XmlSchemaAnnotation annotation)
{
string documentation = GetDocumentation(annotation);
XmlCompletionData completionData = new XmlCompletionData(valueText, documentation, XmlCompletionData.DataType.XmlAttributeValue);
data.Add(completionData);
}
示例13: setAnnotation
private void setAnnotation( AbstractDef def,
XmlSchemaAnnotation annotation )
{
if ( annotation != null ) {
string desc = string.Empty;
foreach ( XmlSchemaObject o in annotation.Items ) {
XmlSchemaDocumentation description = o as XmlSchemaDocumentation;
if ( description != null ) {
foreach ( XmlNode node in description.Markup ) {
desc += node.OuterXml;
}
}
else {
XmlSchemaAppInfo appinfo = o as XmlSchemaAppInfo;
if ( o != null ) {
def.SetFlags( appinfo.Markup[0].InnerText );
}
}
}
def.Desc = desc;
}
}
示例14: GetDescription
/// <summary>
/// Get the description from an xml schema object.
/// </summary>
/// <param name="annotation">The xml schema object.</param>
/// <returns>The description of the object.</returns>
private static string GetDescription(XmlSchemaAnnotation annotation)
{
StringBuilder documentation = new StringBuilder();
// retrieve the documentation nodes
foreach (XmlSchemaObject obj in annotation.Items)
{
XmlSchemaDocumentation doc = obj as XmlSchemaDocumentation;
if (doc != null)
{
foreach (XmlNode node in doc.Markup)
{
if (node is XmlText)
{
documentation.Append(((XmlText)node).OuterXml);
}
else if (node is XmlElement)
{
documentation.Append(((XmlElement)node).OuterXml);
}
}
}
}
documentation.Replace("\t", String.Empty);
documentation.Replace(String.Concat(Environment.NewLine, Environment.NewLine), "<br/><br/>");
documentation.Replace(Environment.NewLine, " ");
return htmlPrefix.Replace(documentation.ToString(), String.Empty);
}
示例15: Check
public virtual void Check (ConformanceCheckContext ctx, XmlSchemaAnnotation value) {}