Exemplo n.º 1
0
 public ClassInfo(string name,
                  Dictionary <string, PropertyInfo> publicProperties,
                  string ns,
                  List <string> usings,
                  List <TypeParameter> typeParameters)
 {
     Name             = name;
     PublicProperties = publicProperties;
     Namespace        = ns;
     Usings           = usings;
     TypeParameters   = typeParameters;
     LowerCaseName    = SafeLowerCase.ToLowerCase(name);
 }
Exemplo n.º 2
0
        private static string GetCaseConstructorArguments(ClassInfo c, ClassInfo baseInfo, bool useBaseGenericTypes)
        {
            var caseArgs = c.PublicProperties.Select(p =>
            {
                var valueType = useBaseGenericTypes ? ReplaceTypeWithBaseType(c, p.Value.Type) : p.Value.Type;
                return(valueType + " " + SafeLowerCase.ToLowerCase(p.Key));
            });
            var baseArgs = baseInfo.PublicProperties.Select(p =>
            {
                var valueType = useBaseGenericTypes ? p.Value.Type : ReplaceTypeWithCaseType(c, p.Value.Type);
                return(valueType + " " + SafeLowerCase.ToLowerCase(p.Key));
            });

            return(string.Join(",", caseArgs.Concat(baseArgs)));
        }
Exemplo n.º 3
0
 private static string GetBaseConstructorCall(ClassInfo unionBase)
 {
     if (unionBase.PublicProperties.Count == 0)
     {
         return(string.Empty);
     }
     return(":base(" + string.Join(",", unionBase.PublicProperties.Select(p => SafeLowerCase.ToLowerCase(p.Key))) + ")");
 }
Exemplo n.º 4
0
 private static string GetBaseConstructorArguments(ClassInfo baseInfo)
 {
     return(string.Join(",", baseInfo.PublicProperties.Select(p => p.Value.Type + " " + SafeLowerCase.ToLowerCase(p.Key))));
 }
Exemplo n.º 5
0
 private static void FillBaseConstructor(ClassInfo baseInfo, StringBuilder result)
 {
     result.Replace("[Constructor]", Templates.BASE_CONSTRUCTOR);
     result.Replace("[ConstructorArguments]", GetBaseConstructorArguments(baseInfo));
     result.Replace("[BaseConstructorCall]", "");
     result.Replace("[ConstructorAssignments]",
                    string.Join(Environment.NewLine,
                                baseInfo.PublicProperties.Select(p => p.Key + " = " + SafeLowerCase.ToLowerCase(p.Key) + ";")));
 }
Exemplo n.º 6
0
 private static void FillCaseConstructor(UnionInfo unionInfo, StringBuilder result, ClassInfo c)
 {
     result.Replace("[Constructor]", Templates.CASE_CONSTRUCTOR);
     result.Replace("[ConstructorArguments]", GetCaseConstructorArguments(c, unionInfo.BaseClassInfo, useBaseGenericTypes: false));
     result.Replace("[BaseConstructorCall]", GetBaseConstructorCall(unionInfo.BaseClassInfo));
     result.Replace("[ConstructorAssignments]",
                    string.Join(Environment.NewLine,
                                c.PublicProperties.Select(p => p.Key + " = " + SafeLowerCase.ToLowerCase(p.Key) + ";")));
 }