示例#1
0
 public Module.ModuleExportsBind GetDynamicTypeBind(Type type, bool crossbind)
 {
     return(register =>
     {
         var dynamicType = new DynamicType(type, false);
         var cls = dynamicType.Bind(register, crossbind);
         _dynamicTypes[type] = dynamicType;
         return cls;
     });
 }
示例#2
0
        //TODO: 用于在动态类型注册过程中产生的关联类型注册
        public DynamicType RegisterDynamicType(TypeRegister register, Type type)
        {
            DynamicType dynamicType;

            if (_dynamicTypes.TryGetValue(type, out dynamicType))
            {
                return(dynamicType);
            }

            dynamicType = new DynamicType(type, false);
            dynamicType.Bind(register);
            _dynamicTypes[type] = dynamicType;
            return(dynamicType);
        }
示例#3
0
        public DynamicType GetDynamicType(Type type)
        {
            DynamicType dynamicType;

            if (_dynamicTypes.TryGetValue(type, out dynamicType))
            {
                return(dynamicType);
            }

            var register = new TypeRegister(_runtime, _context);

            dynamicType = new DynamicType(type);
            dynamicType.Bind(register);
            register.Finish();
            _dynamicTypes[type] = dynamicType;
            return(dynamicType);
        }
示例#4
0
        // 获取指定类型的动态绑定 (此方法仅用于用户运行时, 不适用于 RefectBind)
        public DynamicType GetDynamicType(Type type, bool privateAccess)
        {
            DynamicType dynamicType;

            if (_dynamicTypes.TryGetValue(type, out dynamicType))
            {
                if (privateAccess)
                {
                    dynamicType.OpenPrivateAccess();
                }
                return(dynamicType);
            }

            var register = _context.CreateTypeRegister();

            dynamicType = new DynamicType(type, privateAccess);
            dynamicType.Bind(register);
            _dynamicTypes[type] = dynamicType;

            register.Finish();
            return(dynamicType);
        }