public void T2_UseGlobalEnumForGlobalEnumAttribute() { var type = GeneratedTypes.Single(type => type.Identifier.Text == nameof(GlobalEnumAttributeType)); var prop = type.Members.OfType <PropertyDeclarationSyntax>().SingleOrDefault(prop => prop.Identifier.Text == "language"); var getter = prop.AccessorList.Accessors.Single(accessor => accessor.IsKind(SyntaxKind.GetAccessorDeclaration)); var ret = getter.DescendantNodes().OfType <ReturnStatementSyntax>().Last(); Assert.IsTrue(ret.ToString().StartsWith($"return (({EnumTypesNamespace}.{nameof(LanguageCodeEnum)}")); }
public void T3_UseNestedEnumForNestedEnumElement() { var type = GeneratedTypes.Single(type => type.Identifier.Text == nameof(NestedEnumElementType)); Assert.AreEqual(1, type.Members.OfType <EnumDeclarationSyntax>().Count()); var prop = type.Members.OfType <PropertyDeclarationSyntax>().SingleOrDefault(prop => prop.Identifier.Text == "Language"); var getter = prop.AccessorList.Accessors.Single(accessor => accessor.IsKind(SyntaxKind.GetAccessorDeclaration)); var ret = getter.DescendantNodes().OfType <ReturnStatementSyntax>().Last(); Assert.IsTrue(ret.ToString().StartsWith($"return (({EnumTypesNamespace}.{nameof(NestedEnumElementType)}.{nameof(NestedEnumElementType.LanguageEnum)}")); }
public List <string> AllReferencedNamespaces() { var namespaces = GeneratedTypes .SelectMany(x => x.AllInjectedFields) .Select(x => x.ArgType.Namespace) .Concat(UsingNamespaces) .Distinct() .Where(x => x.IsNotEmpty()) // weed out blank namespaces, thank you F#! .ToList(); return(namespaces); }
public void RenderEntity(GeneratedTypes generateType, StoredProcedureSchema storedProcedure, StringBuilder dataLayerCode) { DALEntity entity = new DALEntity(storedProcedure); dataLayerCode.AppendLine(entity.TransformText()); //Entity entity = new Entity(); //entity.EntityType = generateType; //entity.StoredProcedure = new SchemaExplorer.CommandSchema(Database, storedProcedure, DatabaseObjectOwner, DateTime.Now); //Templates.ParsedStoredProcedureName parsedNames = TemplateHelper.ParseStoredProcedureName(entity.StoredProcedure); //entity.EntityName = parsedNames.EntityName; //entity.Database = Database; //entity.Render(this.Response); }
public DALHelperMethod(GenerationParameters generationParameters, StoredProcedureSchema storedProcedureSchema, GeneratedTypes entityType) { _storedProcedureSchema = storedProcedureSchema; var parsedNames = Utility.ParseStoredProcedureName(storedProcedureSchema.Name); //var sqlConnection = new SqlConnection(generationParameters.ConnectionString); ConnectionKey = generationParameters.ConnectionKey; DatabaseObjectOwner = generationParameters.DatabaseObjectOwner; EntityType = entityType; MethodName = parsedNames.HelperMethodName; CommandTimeout = generationParameters.CommandTimeout; EntityName = parsedNames.EntityName; Database = generationParameters.ConnectionKey; StoredProcedureName = storedProcedureSchema.Name; EnableTransactionSupport = generationParameters.EnableTransactionSupport; }
public void RenderHelperMethod(GeneratedTypes generateType, StoredProcedureSchema storedProcedure, StringBuilder dataLayerCode) { DALHelperMethod helperMethod = new DALHelperMethod(GenerationParameters, storedProcedure, generateType); dataLayerCode.AppendLine(helperMethod.TransformText()); //HelperMethod helperMethod = new HelperMethod(); //helperMethod.EntityType = generateType; //helperMethod.StoredProcedure = new SchemaExplorer.CommandSchema(Database, storedProcedure, DatabaseObjectOwner, DateTime.Now); //Templates.ParsedStoredProcedureName parsedNames = TemplateHelper.ParseStoredProcedureName(helperMethod.StoredProcedure); //helperMethod.EntityName = parsedNames.EntityName; //helperMethod.MethodName = parsedNames.HelperMethodName; //helperMethod.Database = Database; //helperMethod.CommandTimeout = CommandTimeout; //helperMethod.ConnectionKey = ConnectionKey; //helperMethod.DatabaseObjectOwner = DatabaseObjectOwner; //helperMethod.Render(this.Response); }
public void T5_DoNotRedefineDerivedNestedEnumAttribute() { var type = GeneratedTypes.Single(type => type.Identifier.Text == nameof(NestedDerivedEnumAttributeType)); Assert.AreEqual(1, type.Members.OfType <EnumDeclarationSyntax>().Count()); }