/// <summary>
        /// Create a substitute component for the given type and add it to the GameObject
        /// </summary>
        /// <param name="type"></param>
        /// <param name="gameObject"></param>
        /// <returns></returns>
        public object CreateComponent(Type type, GameObject gameObject)
        {
            var callRouter = _callRouterFactory.Create(_context, SubstituteConfig.OverrideAllCalls);
            var proxy      = _proxyFactory.GenerateComponentProxy(callRouter, type, gameObject);

            _callRouterResolver.Register(proxy, callRouter);
            return(proxy);
        }
Esempio n. 2
0
        private object Create(Type[] typesToProxy, object[] constructorArguments, SubstituteConfig config)
        {
            var callRouter       = _callRouterFactory.Create(_context, config);
            var primaryProxyType = GetPrimaryProxyType(typesToProxy);
            var additionalTypes  = typesToProxy.Where(x => x != primaryProxyType).ToArray();
            var proxy            = _proxyFactory.GenerateProxy(callRouter, primaryProxyType, additionalTypes, constructorArguments);

            _callRouterResolver.Register(proxy, callRouter);
            return(proxy);
        }
Esempio n. 3
0
        public object Create(Type[] typesToProxy, object[] constructorArguments, bool callBaseByDefault)
        {
            var callRouter = _callRouterFactory.Create(_context);

            callRouter.CallBaseByDefault(callBaseByDefault);
            var primaryProxyType = GetPrimaryProxyType(typesToProxy);
            var additionalTypes  = typesToProxy.Where(x => x != primaryProxyType).ToArray();
            var proxy            = _proxyFactory.GenerateProxy(callRouter, primaryProxyType, additionalTypes, constructorArguments);

            _callRouterResolver.Register(proxy, callRouter);
            return(proxy);
        }