Created
October 30, 2010 14:59
-
-
Save rippinrobr/655372 to your computer and use it in GitHub Desktop.
GenerateAssembly.define_class method
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) | |
if interface.nil? | |
@mod_builder.DefineType("#{@namespace}.#{class_name}", | |
TypeAttributes.Public) | |
else | |
types = System::Collections::Generic::List.of(Type).new | |
types.add interface | |
tb = @mod_builder.DefineType("#{@namespace}.#{class_name}", | |
TypeAttributes.Public, | |
System::Object.to_clr_type, | |
types.ToArray) | |
tb | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment