예제 #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);
        }