Skip to content

Instantly share code, notes, and snippets.

View rippinrobr's full-sized avatar

Rob Rowe rippinrobr

View GitHub Profile
@rippinrobr
rippinrobr / gist:655545
Created October 30, 2010 17:24
Relating the getter and setter to the property
prop.SetGetMethod(get_method);
prop.SetSetMethod(set_method);
@rippinrobr
rippinrobr / gist:655624
Created October 30, 2010 18:55
Creating the Type for the class we just created.
model_type = class_obj.CreateType
@rippinrobr
rippinrobr / gist:655625
Created October 30, 2010 18:55
Creating the Type for the class we just created.
model_type = class_obj.CreateType
@rippinrobr
rippinrobr / gist:704509
Created November 18, 2010 01:47
Setup for CodeDom code creations
@target_unit = CodeCompileUnit.new
@nspace_holder = CodeNamespace.new(@namespace)
@nspace_holder.Imports.Add CodeNamespaceImport.new(@model_namespace)
@rippinrobr
rippinrobr / gist:704523
Created November 18, 2010 02:04
Creating the class's type
@target_class = CodeTypeDeclaration.new(@class_name)
@target_class.IsClass = true
@target_class.TypeAttributes = class_attrs
@nspace_holder.Types.Add(@target_class)
def add_field(name, type, attributes = MemberAttributes.Public)
field = CodeMemberField.new
field.Attributes = attributes
field.Name = name
field.Type = CodeTypeReference.new type
field.Comments.Add( CodeCommentStatement.new("Repository"))
@target_class.Members.Add(field)
end
@rippinrobr
rippinrobr / gist:706896
Created November 19, 2010 18:22
adding a constructor to our generated code
def add_constructor
arg_name = "repo"
# Create the constructor's object
ctor = CodeConstructor.new
ctor.Attributes = MemberAttributes.Public
ctor.Parameters.Add(CodeParameterDeclarationExpression.new("IRepository", arg_name))
# Grab the references for both the parameter we just added and the field we created
# earlier
arg_ref = CodeArgumentReferenceExpression.new(arg_name)
@rippinrobr
rippinrobr / gist:707143
Created November 19, 2010 20:46
create_if_else_statement
def create_if_else_statement(condition, true_statements, false_statements)
is_null_check = CodeConditionStatement.new
is_null_check.Condition = condition
is_null_check.TrueStatements.Add(true_statements)
is_null_check.FalseStatements.Add(false_statements)
is_null_check
end
@rippinrobr
rippinrobr / gist:707955
Created November 20, 2010 16:57
my method to set up creating a method with the CodeDom
def basic_method(name, return_type, attrs = MemberAttributes.Public)
method = CodeMemberMethod.new
method.Attributes = attrs
method.Name = name
method.ReturnType = return_type
method
end
@rippinrobr
rippinrobr / gist:707974
Created November 20, 2010 17:15
Creates a call to the repo class
def create_repo_method_call(method_name)
repo_call = CodeMethodInvokeExpression.new()
repo_call.Method = CodeMethodReferenceExpression.new(
CodeTypeReferenceExpression.new( CodeTypeReference.new("_repo")),
method_name,
@code_type_ref_of_model.ToArray)
repo_call
end