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) { if (type.IsAbstract) { continue; } if (type.IsEnum) { var enumtranslator = new EnumJsonTranslator(type.Namespace, type.Name, type); fileDictionary.Add(type.Namespace + "." + type.Name, enumtranslator.TransformText()); continue; } var fileGenerator = new ClassWithConstructorArguments(type.GetProperties().ToList(), type.Namespace, type.Name, type.GetConstructors()); fileDictionary.Add(type.Namespace + "." + type.Name, fileGenerator.TransformText()); } return(fileDictionary); }