Ejemplo n.º 1
0
        protected object Invoke(object[] arguments)
        {
            var queuedArgSpecs = _argSpecificationDequeue.DequeueAllArgumentSpecificationsForMethod(MethodToInvoke);
            var call           = _callFactory.Create(MethodToInvoke, arguments, this, queuedArgSpecs, _parameterInfos);
            var result         = CallRouter.Route(call);

            return(EnsureResultCompatibleWithReturnType(result));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Creates a new ICall object.
        /// Only use this method to ensure that your software will keep working on other platforms supported in
        /// future versions of this library.
        /// </summary>
        /// <param name="config">Network configuration</param>
        /// <returns></returns>
        public ICall Create(NetworkConfig config = null)
        {
            ICall call = mFactory.Create(config);

            if (call == null)
            {
                Debug.LogError("Creation of call object failed. Platform not supported? Platform specific dll not included?");
            }
            return(call);
        }
Ejemplo n.º 3
0
        public ICall CreateCallToPropertyGetterFromSetterCall(ICall callToSetter)
        {
            var propertyInfo = GetPropertyFromSetterCallOrNull(callToSetter);

            if (!PropertySetterExistsAndHasAGetMethod(propertyInfo))
            {
                throw new InvalidOperationException("Could not find a GetMethod for \"" + callToSetter.GetMethodInfo() + "\"");
            }
            var setterArgs = callToSetter.GetArguments();
            var getter     = propertyInfo.GetGetMethod();
            var getterArgs = setterArgs.Take(setterArgs.Length - 1).ToArray();

            return(_callFactory.Create(getter, getterArgs, callToSetter.Target(), callToSetter.GetArgumentSpecifications()));
        }
Ejemplo n.º 4
0
        public ICall CreateCallToPropertyGetterFromSetterCall(ICall callToSetter)
        {
            var propertyInfo = GetPropertyFromSetterCallOrNull(callToSetter);

            if (!PropertySetterExistsAndHasAGetMethod(propertyInfo))
            {
                throw new InvalidOperationException("Could not find a GetMethod for \"" + callToSetter.GetMethodInfo() + "\"");
            }

            var getter     = propertyInfo.GetGetMethod();
            var getterArgs = SkipLast(callToSetter.GetOriginalArguments());
            var getterArgumentSpecifications = GetGetterCallSpecificationsFromSetterCall(callToSetter);

            return(_callFactory.Create(getter, getterArgs, callToSetter.Target(), getterArgumentSpecifications));
        }
Ejemplo n.º 5
0
        public virtual ICall Map(IInvocation castleInvocation)
        {
            Func <object>?baseMethod = null;

            if (castleInvocation.InvocationTarget != null &&
                castleInvocation.MethodInvocationTarget.IsVirtual &&
                !castleInvocation.MethodInvocationTarget.IsAbstract &&
                !castleInvocation.MethodInvocationTarget.IsFinal)
            {
                baseMethod = CreateBaseResultInvocation(castleInvocation);
            }

            var queuedArgSpecifications = _argSpecificationDequeue.DequeueAllArgumentSpecificationsForMethod(castleInvocation.Arguments.Length);

            return(_callFactory.Create(castleInvocation.Method, castleInvocation.Arguments, castleInvocation.Proxy, queuedArgSpecifications, baseMethod));
        }
Ejemplo n.º 6
0
        public virtual ICall Map(IInvocation castleInvocation)
        {
            Func <object> baseMethod = null;

            if (castleInvocation.InvocationTarget != null &&
                castleInvocation.MethodInvocationTarget.IsVirtual &&
                !castleInvocation.MethodInvocationTarget.IsAbstract &&
                !castleInvocation.MethodInvocationTarget.IsFinal)
            {
                Func <object> baseResult = () => { castleInvocation.Proceed(); return(castleInvocation.ReturnValue); };
                var           result     = new Lazy <object>(baseResult);
                baseMethod = () => result.Value;
            }

            var queuedArgSpecifications = _argSpecificationDequeue.DequeueAllArgumentSpecificationsForMethod(castleInvocation.Method);

            return(_callFactory.Create(castleInvocation.Method, castleInvocation.Arguments, castleInvocation.Proxy, queuedArgSpecifications, baseMethod));
        }