/// <summary> /// Gets a code member field based on the provided column. /// </summary> private static CodeMemberField GetCodeMemberField(ILanguageProvider languageProvider, Smo.Column column) { var fieldName = languageProvider.GetFormattedInternalFieldName(column.Name); var typeName = languageProvider.GetTypeString(column.DataType); return(new CodeMemberField { Name = fieldName, Attributes = MemberAttributes.Private, Type = new CodeTypeReference(typeName) }); }
/// <summary> /// Gets a parameter based constructor object. /// </summary> private static CodeConstructor GetParameterBasedConstructor(ILanguageProvider languageProvider, Smo.TableViewBase tableView) { var retval = new CodeConstructor { Attributes = MemberAttributes.Public }; foreach (Smo.Column column in tableView.Columns) { var typeName = languageProvider.GetTypeString(column.DataType); var fieldName = languageProvider.GetFormattedInternalFieldName(column.Name); var methodParameterName = languageProvider.GetFormattedParamenterName(column.Name); retval.Parameters.Add(new CodeParameterDeclarationExpression(new CodeTypeReference(typeName), methodParameterName)); retval.Statements.Add(new CodeAssignStatement(new CodeFieldReferenceExpression(new CodeThisReferenceExpression(), fieldName), new CodeArgumentReferenceExpression(methodParameterName))); } return(retval); }
/// <summary> /// Gets a code member property based on the provided column. /// </summary> private static CodeMemberProperty GetCodeMemberProperty(ILanguageProvider languageProvider, Smo.Column column) { var typeName = languageProvider.GetTypeString(column.DataType); var fieldName = languageProvider.GetFormattedInternalFieldName(column.Name); var retval = new CodeMemberProperty { Name = column.Name, Attributes = MemberAttributes.Public | MemberAttributes.Final, Type = new CodeTypeReference(typeName), HasGet = true, HasSet = true }; retval.GetStatements.Add(new CodeMethodReturnStatement(new CodeFieldReferenceExpression(new CodeThisReferenceExpression(), fieldName))); retval.SetStatements.Add(new CodeAssignStatement(new CodeFieldReferenceExpression(new CodeThisReferenceExpression(), fieldName), new CodePropertySetValueReferenceExpression())); return(retval); }