private void KeyCreator(IKey key, string filePath, string entityClassName) { string file = null; using (var sr = new StreamReader("./CodeTemplates/KeyTemplate.txt")) { file = sr.ReadToEnd(); } var className = KeyListFormatter.GetNameOfKey(key); var fileText = Smart.Format(file, new { Namespace = namespaceString, EntityClassName = entityClassName, ClassName = className, Annotations = key.GetAnnotations(), DeclaringEntityType = EntityListFormatter.GetNameOfIEntityType(key.DeclaringEntityType), Properties = key.Properties }); File.WriteAllText($"{filePath}/{className}.cs", fileText); }
private void ForeignKeyCreator(IForeignKey foreignKey, string filePath, string entityClassName) { string file = null; using (var sr = new StreamReader("./CodeTemplates/ForeignKeyTemplate.txt")) { file = sr.ReadToEnd(); } var className = ForeignKeyListFormatter.GetNameOfForeignKey(foreignKey); var fileText = Smart.Format(file, new { Namespace = namespaceString, EntityClassName = entityClassName, ClassName = className, IsUnique = foreignKey.IsUnique?"true":"false", IsRequired = foreignKey.IsRequired?"true":"false", IsOwnership = foreignKey.IsOwnership?"true":"false", DeleteBehavior = foreignKey.DeleteBehavior, Properties = foreignKey.Properties, DependentToPrincipal = foreignKey.DependentToPrincipal != null ?string.Format("{0}.GetInstance()", NavigationFormatter.GetNameOfNavigation(foreignKey.DependentToPrincipal)):"null", PrincipalToDependent = foreignKey.PrincipalToDependent != null ?string.Format("{0}.GetInstance()", NavigationFormatter.GetNameOfNavigation(foreignKey.PrincipalToDependent)):"null", PrincipalKey = foreignKey.PrincipalKey != null? string.Format("{0}.GetInstance()", KeyListFormatter.GetNameOfKey(foreignKey.PrincipalKey)):"null", PrincipalEntityType = foreignKey.PrincipalEntityType != null? string.Format("{0}.GetInstance()", EntityListFormatter.GetNameOfIEntityType(foreignKey.PrincipalEntityType)):"null", Annotations = foreignKey.GetAnnotations(), DeclaringEntityType = foreignKey.DeclaringEntityType != null? string.Format("{0}.GetInstance()", EntityListFormatter.GetNameOfIEntityType(foreignKey.DeclaringEntityType)):"null" }); File.WriteAllText($"{filePath}/{className}.cs", fileText); }