示例#1
0
        public void CreateChecker(String fileName, IDataModel model)
        {
            var parser = new TSDefParser(_reader, _path);

            _mm = parser.Parse(fileName);

            if (model == null || model.Metadata == null)
            {
                throw new TypeCheckerException($"TypeChecker. Date model is empty");
            }

            foreach (var kv in model.Metadata)
            {
                if (!_mm.ContainsKey(kv.Key))
                {
                    throw new TypeCheckerException($"Type '{kv.Key}' is in the model but not found in the description file");
                }
                CheckFields(kv.Key, kv.Value, _mm[kv.Key]);
            }
            foreach (var kv in _mm.Where(x => !x.Key.StartsWith("$")))
            {
                if (!model.Metadata.ContainsKey(kv.Key))
                {
                    throw new TypeCheckerException($"Type '{kv.Key}' is in the description file but not found in data model");
                }
            }
        }