Пример #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");
                }
            }
        }
Пример #2
0
        public void ParseFile()
        {
            var profiler   = new NullProfiler();
            var userLocale = new WebUserLocale();
            var host       = new WebApplicationHost(profiler, userLocale);

            host.StartApplication(false);
            var parser = new TSDefParser(host.ApplicationReader, "typescript");

            parser.Parse("model.d.ts");
        }