public string MakeRightCase(string identifier) { if (UseCamelCasing) { return(CodeIdentifier.MakeCamel(identifier)); } else { return(CodeIdentifier.MakePascal(identifier)); } }
CodeTypeMember CreateFieldMember(CodeTypeDeclaration codeClass, CodeTypeReference type, string name, object defaultValue, TypeData defaultType, string documentation) { CodeMemberField codeField = null; CodeTypeMember codeProp = null; if ((options & CodeGenerationOptions.GenerateProperties) > 0) { string field = identifiers.AddUnique(CodeIdentifier.MakeCamel(name + "Field"), name); codeField = new CodeMemberField(type, field); codeField.Attributes = MemberAttributes.Private; codeClass.Members.Add(codeField); CodeMemberProperty prop = new CodeMemberProperty(); prop.Name = name; prop.Type = type; prop.Attributes = MemberAttributes.Public | MemberAttributes.Final; codeProp = prop; prop.HasGet = prop.HasSet = true; CodeExpression ce = new CodeFieldReferenceExpression(new CodeThisReferenceExpression(), field); prop.SetStatements.Add(new CodeAssignStatement(ce, new CodePropertySetValueReferenceExpression())); prop.GetStatements.Add(new CodeMethodReturnStatement(ce)); } else { codeField = new CodeMemberField(type, name); codeField.Attributes = MemberAttributes.Public; codeProp = codeField; } if (defaultValue != System.DBNull.Value) { GenerateDefaultAttribute(codeField, codeProp, defaultType, defaultValue); } AddComments(codeProp, documentation); codeClass.Members.Add(codeProp); return(codeProp); }