예제 #1
0
        SmalltalkClass Map(Type type)
        {
            var properties = type
                             .GetProperties(BindingFlags.Public | BindingFlags.Instance)
                             .Select(x => ToSmalltalkProperty(x));
            var name = type.Name;

            if (type.IsAbstract)
            {
                name = "Abstract" + name;
            }
            if (type.IsGenericTypeDefinition)
            {
                name = name + $"_{string.Join("_", type.GetGenericArguments().Select(t => t))}";
            }
            string baseName = string.Empty;

            if (!type.BaseType.IsGenericType)
            {
                baseName = type.BaseType.Name;
            }
            else
            {
                var tempName = type.BaseType.Name;
                baseName  = tempName.Substring(0, tempName.Length - 2);
                baseName += string.Join("_", type.BaseType.GetGenericArguments().Select(t => t.Name));
            }
            var comment = type.FullName;
            var c       = new SmalltalkClass(baseName, name, properties.ToArray(), comment);

            return(c);
        }
예제 #2
0
        void CreatePropertiesJson(string classDirectory, SmalltalkClass smalltalkClass)
        {
            var poco = new ClassPropertiesJson()
            {
                Category          = category,
                Name              = smalltalkClass.ClassName,
                Super             = smalltalkClass.BaseTypeName,
                InstanceVariables = smalltalkClass.Properties.Select(t => t.Name).ToArray()//$"| {string.Join(" ", smalltalkClass.Properties.Select(t => t.Name))} |";
            };
            var methodPropertiesPath = Path.Combine(classDirectory, "properties.json");

            File.WriteAllText(methodPropertiesPath, JsonSerializer.Serialize(poco));
        }