The Scanner object performs the reflective inspection of a class and builds a map of attributes and elements for each annotated field. This acts as a cachable container for reflection actions performed on a specific type. When scanning the provided class this inserts the scanned field as a Label in to a map so that it can be retrieved by name. Annotations classified as attributes have the Attribute annotation, all other annotated fields are stored as elements.
Exemplo n.º 1
0
 /// <summary>
 /// This creates a <c>Scanner</c> object that can be used to
 /// examine the fields within the XML class schema. The scanner
 /// maintains information when a field from within the scanner is
 /// visited, this allows the serialization and deserialization
 /// process to determine if all required XML annotations are used.
 /// </summary>
 /// <param name="type">
 /// the schema class the scanner is created for
 /// </param>
 /// <returns>
 /// a scanner that can maintains information on the type
 /// </returns>
 public Scanner GetInstance(Class type) {
    Scanner schema = cache.get(type);
    if(schema == null) {
       schema = new Scanner(type);
       cache.put(type, schema);
    }
    return schema;
 }
Exemplo n.º 2
0
 /// <summary>
 /// Constructor for the <c>Schema</c> object. This is used
 /// to wrap the element and attribute XML annotations scanned from
 /// a class schema. The schema tracks all fields visited so that
 /// a converter can determine if all fields have been serialized.
 /// </summary>
 /// <param name="schema">
 /// this contains all labels scanned from the class
 /// </param>
 /// <param name="context">
 /// this is the context object for serialization
 /// </param>
 public ClassSchema(Scanner schema, Context context) {
    this.attributes = schema.getAttributes(context);
    this.elements = schema.getElements(context);
    this.caller = schema.getCaller(context);
    this.factory = schema.Creator;
    this.revision = schema.Revision;
    this.decorator = schema.Decorator;
    this.primitive = schema.IsPrimitive();
    this.version = schema.Version;
    this.text = schema.Text;
    this.type = schema.Type;
 }