This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def define_property(tb, name, type, attributes=FieldAttributes.Public) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# atually creates the dynamic assembly and then the dynamic module | |
@assembly = AppDomain.CurrentDomain.DefineDynamicAssembly(@asm, | |
AssemblyBuilderAccess.RunAndSave) | |
@mod_builder = @assembly.DefineDynamicModule("#{@asm.Name}", | |
@dll_name, | |
false) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def create_models | |
# The where method here is from System.Linq | |
@elem_svc.get_views.where( lambda{ |w| w.end_date.nil? }).each do |e| | |
create_model(e) | |
end | |
end | |
# Creates each individual model for the assembly and queues up | |
# the domain level classes that are need to support the models | |
def create_model(view_obj) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#------------------------------------------------------------- | |
# Creates the class type and returns it to the calling method. | |
# Any fields, properties, or methods will need the object. If | |
# no interface is need the simple call is made creating the | |
# type object as a Public class. The first two parameters are | |
# the same in both DefineType calls. In the cases where we are | |
# implementing an interface we need to pass in the Object | |
# constructor and the interface type we are implementing. | |
#------------------------------------------------------------- | |
def define_class(class_name, interface=nil) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def generate(class_name, fields_to_gen) | |
class_obj = gen_class_type("Models", class_name) | |
tables = create_properties(class_obj, fields_to_gen) | |
model_type = class_obj.CreateType | |
puts "Done!" | |
[ model_type, tables ] | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
get_method = tb.DefineMethod("get_#{name}", get_set_attr, type, Type.EmptyTypes) prop_il.Emit(OpCodes.Ldarg_0) | |
prop_il.Emit(OpCodes.Ldfld, private_field) | |
prop_il.Emit(OpCodes.Ret) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Define "set" accessor method for the property. | |
set_params = System::Collections::Generic::List.of(Type).new | |
set_params.add type | |
set_method = tb.DefineMethod("set_#{name}", get_set_attr, nil, | |
set_params.ToArray) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private_field = tb.DefineField("_#{name.downcase}", type, | |
FieldAttributes.Private) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
prop = tb.DefineProperty(name, PropertyAttributes.HasDefault, | |
type, nil) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
prop_il.Emit(OpCodes.Ldarg_1) | |
prop_il.Emit(OpCodes.Stfld, private_field) |
OlderNewer