public string GenerateClassFileFromAssembly(string className) { var type = _types.SingleOrDefault(t => t.Name == className); Properties = type.GetProperties().ToList(); ClassName = type.Name; if (type.IsEnum) { var enumFileGenerator = new EnumJsonTranslator(Namespace, ClassName, type); return(enumFileGenerator.TransformText()); } else { var constructor = type.GetConstructor(Type.EmptyTypes); if (constructor == null) { var fileGenerator = new ClassWithConstructorArguments(type.GetProperties().ToList(), Namespace, type.Name, type.GetConstructors()); return(fileGenerator.TransformText()); } else { var fileGenerator = new FileGenerator(type.GetProperties().ToList(), Namespace, type.Name); return(fileGenerator.TransformText()); } } }
public Dictionary <string, string> TransformFiles() { var fileDictionary = new Dictionary <string, string>(); var typesTobeConverted = _assembly.GetTypes(); foreach (var type in typesTobeConverted) { var fileGenerator = new FileGenerator(type.GetProperties().ToList(), Namespace, type.Name); fileDictionary.Add(type.Name, fileGenerator.TransformText()); } return(fileDictionary); }
public string GenerateClassFileFromAssembly(string className) { var type = _types.SingleOrDefault(t => t.Name == className); Properties = type.GetProperties().ToList(); ClassName = type.Name; if (type.IsEnum) { var enumFileGenerator = new EnumJsonTranslator(Namespace, ClassName, type); return(enumFileGenerator.TransformText()); } else { var fileGenerator = new FileGenerator(type.GetProperties().ToList(), Namespace, type.Name); return(fileGenerator.TransformText()); } }