def get_type(local_assembly, type_name): """Gets the type's class via reflection The type is looked for in the local assembly first, if not found, it will be looked in the system assembly. :param Assembly local_assembly: Assembly object to look for. :param str type_name: The full name of the type. :return: A C# Type object. :rtype: Type """ local_type = local_assembly.GetType(type_name) if local_type is None: return Type.GetType(type_name) return local_type
def __init__(self, fileName): scriptEnv = Python.CreateRuntime() self.fileName = fileName self.engine = scriptEnv.GetEngine("python") self.context = HostingHelpers.GetLanguageContext(self.engine) scriptEnv.LoadAssembly(Type.GetType("System.String").Assembly) #mscorlib.dll scriptEnv.LoadAssembly(UriBuilder().GetType().Assembly) #System.dll self.InitializePath() executable = Assembly.GetEntryAssembly().Location prefix = Path.GetDirectoryName(executable) self.context.SystemState.executable = executable self.context.SystemState.exec_prefix = self.context.SystemState.prefix = prefix import imp mod = imp.new_module('__main__') mod.__file__ = fileName mod.__builtins__ = sys.modules['__builtin__'] self.context.SystemState.modules['__main__'] = mod self.mainScope = scriptEnv.CreateScope(mod.__dict__)
def get_clr_dir(): import clr from System import Type from System.IO import Path return Path.GetDirectoryName( Type.GetType('System.Int32').Assembly.Location)
def get_accepted_property_types(self): #Geo.Vector2.__clrtype__() return [Type.GetType("System.Single")]
def get_clr_type(obj): full_name = obj.__module__ + "." + obj.__name__ + ", GameHook" return Type.GetType(full_name)