当前位置: 首页>>代码示例>>C#>>正文


C# Schema.getAttributes方法代码示例

本文整理汇总了C#中Schema.getAttributes方法的典型用法代码示例。如果您正苦于以下问题:C# Schema.getAttributes方法的具体用法?C# Schema.getAttributes怎么用?C# Schema.getAttributes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Schema的用法示例。


在下文中一共展示了Schema.getAttributes方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ReadAttributes

 /// <summary>
 /// This <c>readAttributes</c> method reads the attributes from
 /// the provided XML element. This will iterate over all attributes
 /// within the element and convert those attributes as primitives to
 /// contact values within the source object.
 /// <p>
 /// Once all attributes within the XML element have been evaluated
 /// the <c>Schema</c> is checked to ensure that there are no
 /// required contacts annotated with the <c>Attribute</c> that
 /// remain. If any required attribute remains an exception is thrown.
 /// </summary>
 /// <param name="node">
 /// this is the XML element to be evaluated
 /// </param>
 /// <param name="source">
 /// the type of the object that is being deserialized
 /// </param>
 /// <param name="schema">
 /// this is used to visit the attribute contacts
 /// </param>
 public void ReadAttributes(InputNode node, Object source, Schema schema) {
    NodeMap<InputNode> list = node.getAttributes();
    LabelMap map = schema.getAttributes();
    for(String name : list) {
       ReadAttribute(node.GetAttribute(name), source, map);
    }
    Validate(node, map, source);
 }
开发者ID:ngallagher,项目名称:simplexml,代码行数:28,代码来源:Composite.cs

示例2: ValidateAttributes

 /// <summary>
 /// This <c>validateAttributes</c> method validates the attributes
 /// from the provided XML element. This will iterate over all attributes
 /// within the element and validate those attributes as primitives to
 /// contact values within the source object.
 /// <p>
 /// Once all attributes within the XML element have been evaluated the
 /// <c>Schema</c> is checked to ensure that there are no required
 /// contacts annotated with the <c>Attribute</c> that remain. If
 /// any required attribute remains an exception is thrown.
 /// </summary>
 /// <param name="node">
 /// this is the XML element to be validated
 /// </param>
 /// <param name="schema">
 /// this is used to visit the attribute contacts
 /// </param>
 public void ValidateAttributes(InputNode node, Schema schema) {
    NodeMap<InputNode> list = node.getAttributes();
    LabelMap map = schema.getAttributes();
    for(String name : list) {
       ValidateAttribute(node.GetAttribute(name), map);
    }
    Validate(node, map);
 }
开发者ID:ngallagher,项目名称:simplexml,代码行数:25,代码来源:Composite.cs

示例3: WriteAttributes

 /// <summary>
 /// This write method is used to write all the attribute contacts from
 /// the provided source object to the XML element. This visits all
 /// the contacts marked with the <c>Attribute</c> annotation in
 /// the source object. All annotated contacts are written as attributes
 /// to the XML element. This will throw an exception if a required
 /// contact within the source object is null.
 /// </summary>
 /// <param name="source">
 /// this is the source object to be serialized
 /// </param>
 /// <param name="node">
 /// this is the XML element to write attributes to
 /// </param>
 /// <param name="schema">
 /// this is used to track the referenced attributes
 /// </param>
 public void WriteAttributes(OutputNode node, Object source, Schema schema) {
    LabelMap attributes = schema.getAttributes();
    for(Label label : attributes) {
       Contact contact = label.getContact();
       Object value = contact.Get(source);
       if(value == null) {
          value = label.getEmpty(context);
       }
       if(value == null && label.isRequired()) {
          throw new AttributeException("Value for %s is null", label);
       }
       WriteAttribute(node, value, label);
    }
 }
开发者ID:ngallagher,项目名称:simplexml,代码行数:31,代码来源:Composite.cs


注:本文中的Schema.getAttributes方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。