예제 #1
0
 public ReadingContext(VersionKey version)
 {
     Template           = null;
     Argument           = 0;
     Parent             = null;
     Version            = version;
     VersionInterpreter = new Interpreter(version.AsState());
 }
예제 #2
0
        public SchemaFieldBuilder(SchemaDocumentBuilder documentBuilder,
                                  VersionKey version)
        {
            Doc = documentBuilder;

            var state       = version.AsState();
            var interpreter = new Interpreter(state);

            var compoundFields = documentBuilder.Document
                                 .Compounds.Values
                                 .Select(c => (c.Name, c.Fields));
            var niObjectFields = documentBuilder.Document
                                 .NiObjects.Values
                                 .Select(ni => (ni.Name, ni.Fields));

            IncludedFieldsByTypeName = compoundFields.Concat(niObjectFields)
                                       .ToDictionary(
                p => p.Name,
                p => p.Fields
                .Where(f => IsFieldIncluded(f, interpreter, version))
                .ToList()
                );


            FieldTypes = IncludedFieldsByTypeName
                         .SelectMany(kvp =>
                                     kvp.Value.Select(field =>
                                                      (field, documentBuilder.SchemaTypes.GetFieldType(field))))
                         .ToDictionary(ft => ft.field, ft => ft.Item2);
            FieldTypes = IncludedFieldsByTypeName
                         .SelectMany(kvp =>
                                     kvp.Value.Select(field =>
                                                      (field, documentBuilder.SchemaTypes.GetFieldType(field))))
                         .ToDictionary(ft => ft.field, ft => ft.Item2);

            FieldBuilders = IncludedFieldsByTypeName
                            .SelectMany(kvp => kvp.Value.Select(field => (field, BuildField(kvp.Key, field))))
                            .ToDictionary(p => p.field, p => p.Item2);
        }