public Type Resolve(TypeContext typeContext) { var index = _name.LastIndexOf('.'); // if name contains dots, then this is a namespace qualified name if (index != -1) { Type type = typeContext.GetByFullName(_name); // throw if type wasn't found if (type == null) throw new TypeNotFoundException("There is no type {0}", _name); } // check that this name not exists in global namespase: Type resolvedType = typeContext.GetByFullName(_name); if (resolvedType != null) return resolvedType; // try to find type walking through all usings foreach (var @using in _usings) { var typeName = Utils.ConcatNamespaces(@using, _name); Type type = typeContext.GetByFullName(typeName); if (type != null) return type; } throw new TypeNotFoundException("There is no type {0}. The following namespaces were checked: {1}", _name, String.Join(", ", _usings)); }
/// <summary> /// Protected initialization /// </summary> public FieldInfo(TypeContext typeContext, Int32 index, String name, TypeResolver typeResolver, FieldQualifier qualifier, Object defaultValue) { _typeContext = typeContext; _index = index; _name = name; _qualifier = qualifier; _typeResolver = typeResolver; _defaultValue = defaultValue; }
public TypeContext Build(String[] filePaths) { if (filePaths.Length <= 0) throw new SchematraException("Files were not specified"); var typeContext = new TypeContext(); var context = new Context(typeContext); foreach (var filePath in filePaths) { var tree = BuildParseTree(filePath); try { ParseUnit(tree, context); return typeContext; } catch (Exception ex) { var errorMessage = "Unaxpected exception while parsing schema file"; if (_currentNode != null) errorMessage = BuildErrorMessage(ex.Message, filePath, _currentNode.Span.Location.Line + 1, _currentNode.Span.Location.Column); throw new SchematraException(errorMessage); } } throw new SchematraException("Files were not specified"); }
public Context(TypeContext typeContext) { _typeContext = typeContext; }
protected EnumType(TypeContext typeContext) : base(typeContext) { }
/// <summary> /// Initialization /// </summary> protected Type(TypeContext typeContext) { _typeContext = typeContext; }
protected RecordType(TypeContext typeContext) : base(typeContext) { }
public EnumTypeBuilder(TypeContext typeContext) : base(typeContext) { }
public RecordTypeBuilder(TypeContext typeContext) : base(typeContext) { }
public PrimitiveTypeBuilder(TypeContext typeContext) : base(typeContext) { }
/// <summary> /// Initialization /// </summary> public Parser(CompilationDefinition compilation) { _compilation = compilation; _context = new TypeContext(); }