Example #1
0
        public object Invoke(string proxyMethodName, string returnType, params object[] args)
        {
            if (proxyMethodName == "Url")
            {
                return(null);
            }
            ProxyMethodInfo pmi    = SimpleProxyMethodParser.ParseTypeAndNameOnly(proxyMethodName);
            string          method = pmi.TypeName + "." + pmi.MethodName;

            if (proxyMethodName == "task_get_record")
            {
                Proxy_Task task = new Proxy_Task()
                {
                    progress = 100, status = XenAPI.task_status_type.success.ToString(), result = ""
                };
                return(new Response <Proxy_Task>(task));
            }

            if (proxyMethodName == "host_call_plugin" && args != null && args.Length > 2 && "trim".Equals(args[2]))
            {
                return(new Response <string>("True"));
            }
            ;

            if (pmi.MethodName == "add_to_other_config" || pmi.MethodName == "remove_from_other_config")  // these calls are special because they can have per-key permissions
            {
                rbacMethods.Add(method, (string)args[2]);
            }
            else
            {
                rbacMethods.Add(method);
            }

            return(ResponseByType(returnType));
        }
Example #2
0
        private bool Build(ILInstruction instruction)
        {
            var methodRef = instruction.Value as MethodReference;

            if (methodRef == null)
            {
                return(false);
            }

            var opCode = instruction.OpCode;

            if (opCode != OpCodes.Call && opCode != OpCodes.Callvirt)
            {
                return(false);
            }

            if (!methodRef.HasThis ||
                methodRef.CallConv != MethodCallingConvention.Default ||
                methodRef.GenericParameterCount > 0)
            {
                return(false);
            }

            ProxyMethodInfo proxyMethod;

            if (!_proxyMethods.TryGetValue(methodRef, out proxyMethod))
            {
                proxyMethod        = new ProxyMethodInfo();
                proxyMethod.Method = CreateProxy(methodRef);
                proxyMethod.OpCode = opCode;
                _proxyMethods.Add(methodRef, proxyMethod);
            }

            instruction.Value  = proxyMethod.Method;
            instruction.OpCode = OpCodes.Call;

            return(true);
        }