Ejemplo n.º 1
0
        public EntityInformation ParseEntity(JObject entity)
        {
            var info = new EntityInformation();

            if (entity.Value <string>("Name") is string entityName)
            {
                info.HasName(entityName, entity.Value <string>("PluralName"));
            }

            if (entity.Value <string>("Alias") is string alias)
            {
                info.HasAlias(alias);
            }

            if (entity.Value <string>("Icon") is string icon)
            {
                info.HasIcon(icon, entity.Value <string?>("IconColor"));
            }

            if (entity.Value <string>("Output") is string outputItems)
            {
                info.ShouldOutput(outputItems.Split(new[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries));
            }

            if (entity.Value <JObject>("Properties") is JObject propsRoot &&
                propsRoot.Value <JArray>("$values") is JArray properties)
            {
                foreach (var property in properties.OfType <JObject>())
                {
                    info.AddProperty(_propertyParser.ParseProperty(info, property));
                }
            }

            return(info);
        }