Beispiel #1
0
        protected override IMetaNode VisitProperty(Property property)
        {
            var propertyLines = new List <string>();
            var propertyInfos = property.FieldSetting.GetType().GetProperties()
                                .Where(p => !FieldSettingPropertyBlackList.Contains(p.Name));

            foreach (var propertyInfo in propertyInfos)
            {
                var name  = propertyInfo.Name;
                var value = GetPropertyValue(property.FieldSetting, propertyInfo);
                if (value != null)
                {
                    propertyLines.Add($"{name}: {value}");
                }
            }
            _indentCount++;
            WriteLine("{");
            _indentCount++;
            WriteLine($"Type: \"{property.FieldSetting.GetType().Name}\",");
            for (int i = 0; i < propertyLines.Count; i++)
            {
                var comma = i < propertyLines.Count - 1 ? "," : "";
                WriteLine($"{propertyLines[i]}{comma}");
            }
            _indentCount--;
            WriteLine($"}} as FieldSettings.{property.FieldSetting.GetType().Name},");
            _indentCount--;
            return(base.VisitProperty(property));
        }
Beispiel #2
0
        protected override IMetaNode VisitProperty(Property property)
        {
            var propertyLines = new List <string>();
            var propertyInfos = property.FieldSetting.GetType().GetProperties()
                                .Where(p => !FieldSettingPropertyBlackList.Contains(p.Name));

            foreach (var propertyInfo in propertyInfos)
            {
                var name  = propertyInfo.Name;
                var value = GetPropertyValue(property.FieldSetting, propertyInfo);
                if (value != null)
                {
                    propertyLines.Add(name.ToCamelCase() + ": " + value);
                }
            }


            WriteLine("schema.FieldSettings.push(");
            _indentCount++;
            WriteLine($"new FieldSettings.{property.FieldSetting.GetType().Name}({{");
            _indentCount++;
            for (int i = 0; i < propertyLines.Count; i++)
            {
                var comma = i < propertyLines.Count - 1 ? "," : "";
                WriteLine($"{propertyLines[i]}{comma}");
            }
            _indentCount--;
            WriteLine("}));");
            _indentCount--;
            return(base.VisitProperty(property));
        }