Ejemplo n.º 1
0
        public void AddProperty(string name, JsonSchemaSource prop)
        {
            if (name is null)
            {
                throw new ArgumentNullException();
            }
            if (prop.type == JsonSchemaType.Unknown)
            {
                if (name == "extensions" || name == "extras")
                {
                    // return;
                    prop.type = JsonSchemaType.Object;
                }
                else
                {
                    throw new NotImplementedException();
                }
            }

            if (m_properties is null)
            {
                m_properties = new List <KeyValuePair <string, JsonSchemaSource> >();
            }

            if (m_properties.Any(x => x.Key == name))
            {
                throw new ArgumentException($"{name}: is already exist");
            }
            m_properties.Add(new KeyValuePair <string, JsonSchemaSource>(name, prop));
        }
Ejemplo n.º 2
0
        public void AddJsonPath(string jsonPath, JsonSchemaSource source)
        {
            var(parent, child) = SplitParent(jsonPath);
            var parentSchema       = this.Get(parent);
            var materialExtensions = parentSchema;

            source.JsonPath = jsonPath;
            materialExtensions.AddProperty(child, source);
        }
        public JsonSchemaSource Load(string fileName, string jsonPath)
        {
            JsonSchemaSource loaded = null;

            foreach (var dir in m_dir)
            {
                var path = Path.Combine(dir.FullName, fileName);
                if (File.Exists(path))
                {
                    loaded = Load(new FileInfo(path), jsonPath);
                    break;
                }
            }

            if (loaded is null)
            {
                throw new FileNotFoundException(fileName);
            }
            return(loaded);
        }