Esempio n. 1
0
        public void GetInterfaceMapWorksWithVariantIfaces()
        {
            var m0  = typeof(IMethodInvoke <object>).GetMethod("Test");
            var m1  = typeof(IMethodInvoke <string>).GetMethod("Test");
            var obj = new MethodInvoke();

            Assert.AreEqual("MethodInvoke", m0.Invoke(obj, new Object [0]));
            Assert.AreEqual("MethodInvoke", m1.Invoke(obj, new Object [0]));
        }
Esempio n. 2
0
        /// <summary>
        /// Create a new Instance of the specified type.
        ///
        /// Type should have an empty constructor or a constructor with annotation.
        /// </summary>
        /// <param name="type">Type</param>
        /// <param name="node">Configuration node.</param>
        /// <returns>Created Instance</returns>
        public static object CreateInstance(Type type, ConfigPathNode node)
        {
            object target = null;

            ConstructorInfo[] constructors = type.GetConstructors(BindingFlags.Public | BindingFlags.Instance);
            if (constructors != null && constructors.Length > 0)
            {
                foreach (ConstructorInfo ci in constructors)
                {
                    MethodInvoke mi = (MethodInvoke)Attribute.GetCustomAttribute(ci, typeof(MethodInvoke));
                    if (mi != null)
                    {
                        ParameterInfo[] parameters = ci.GetParameters();
                        ConfigPathNode  nnode      = node;
                        if (parameters != null && parameters.Length > 0)
                        {
                            if (!String.IsNullOrWhiteSpace(mi.Path))
                            {
                                AbstractConfigNode cnode = nnode.Find(mi.Path);
                                if (cnode != null && cnode.GetType() == typeof(ConfigPathNode))
                                {
                                    nnode = (ConfigPathNode)cnode;
                                }
                            }
                            if (nnode != null)
                            {
                                ConfigParametersNode pnode = nnode.GetParameters();
                                if (pnode != null)
                                {
                                    List <object> values = FindParameters(pnode, ci.Name, parameters);
                                    if (values != null && values.Count > 0)
                                    {
                                        target = Activator.CreateInstance(type, values.ToArray());
                                    }
                                }
                            }
                        }
                        else
                        {
                            target = Activator.CreateInstance(type);
                        }
                    }
                }
            }

            if (target == null)
            {
                target = Activator.CreateInstance(type);
            }
            if (target != null)
            {
                target = ReadValues((ConfigPathNode)node, target, null);
                CallMethodInvokes((ConfigPathNode)node, target);
            }
            return(target);
        }
Esempio n. 3
0
        protected void AddFactorEdges(GraphWriter g, MethodInvoke mi)
        {
            var parameters = mi.method.GetParameters();

            for (int i = 0; i < mi.args.Count; i++)
            {
                var parameter = parameters[i];
                if (parameter.IsOut)
                {
                    AddEdge(g, mi, mi.args[i], parameter.Name);
                }
                else
                {
                    AddEdge(g, mi.args[i], mi, parameter.Name);
                }
            }
            if (mi.returnValue != null)
            {
                AddEdge(g, mi, mi.returnValue, "");
            }
            if (!UseContainers)
            {
                // add edges from condition variables to target (if there are no such edges already)
                IModelExpression      target   = (mi.returnValue != null) ? mi.returnValue : mi;
                Set <IStatementBlock> excluded = new Set <IStatementBlock>();
                if (target is Variable)
                {
                    // if target is in the ConditionBlock, then don't connect with the condition variable
                    Variable targetVar = (Variable)target;
                    excluded.AddRange(targetVar.Containers);
                }
                foreach (IStatementBlock block in mi.Containers)
                {
                    if (excluded.Contains(block))
                    {
                        continue;
                    }
                    if (block is ConditionBlock)
                    {
                        ConditionBlock  cb = (ConditionBlock)block;
                        Variable        c  = cb.ConditionVariableUntyped;
                        List <Variable> condVars;
                        if (!conditionVariables.TryGetValue(target, out condVars))
                        {
                            condVars = new List <Variable>();
                            conditionVariables[target] = condVars;
                        }
                        if (!condVars.Contains(c))
                        {
                            AddEdge(g, c, target, "condition");
                            condVars.Add(c);
                        }
                    }
                }
            }
        }
Esempio n. 4
0
        public void CanCallInstanceMethodWithoutArgsButWithResult()
        {
            // Arrange
            // Act
            var result = MethodInvoke.InstanceMethod(target, "InstanceStringMethodWithoutArgs", new object[0]);

            // Assert
            Assert.True(result.HasResult);
            Assert.Equal("successInstanceStringMethodWithoutArgs", result.Value);
        }
Esempio n. 5
0
        public void CanCallInstanceMethodWithoutArgsAndWithoutResult()
        {
            // Arrange
            // Act
            var result = MethodInvoke.InstanceMethod(target, "InstanceVoidMethodWithoutArgs", new object[0]);

            // Assert
            Assert.False(result.HasResult);
            Assert.Null(result.Value);
        }
 internal void Compile(MethodInvoke method)
 {
     // name
     method.AddElement(this);
     method.AddCode(method.ParameterName);
     method.AddLiteral(this.TextCaseSpecified ? (object)this.TextCase : null);
     method.AddLiteral(this.Prefix);
     method.AddLiteral(this.Suffix);
     method.AddDefaultParameters();
 }
Esempio n. 7
0
        public void CanCallMethodWithNullArgs()
        {
            // Arrange
            // Act
            var result = (string)MethodInvoke
                         .InstanceMethod(target, "InstanceStringMethodWhichIsOkayWhenArgIsNull", new object[] { null })
                         .Value;

            // Assert
            Assert.Equal(result, "Arg is null");
        }
Esempio n. 8
0
        public static void AddSortComparerParameters(this MethodInvoke method, SortElement sort)
        {
            // find orders
            var keys = sort.Keys ?? new KeyElement[] { };

            // add
            foreach (var key in keys)
            {
                method.AddLiteral(key.SortOrderSpecified ? key.SortOrder : SortOrder.Ascending);
            }
        }
Esempio n. 9
0
        /// <summary>
        /// Check and Invoke annotated methods for this type.
        /// </summary>
        /// <typeparam name="T">Target Instance type</typeparam>
        /// <param name="node">Configuration node.</param>
        /// <param name="target">Target Type instance</param>
        private static void CallMethodInvokes <T>(ConfigPathNode node, T target)
        {
            Type type = target.GetType();

            MethodInfo[] methods = type.GetMethods(BindingFlags.Public | BindingFlags.Instance);
            if (methods != null)
            {
                foreach (MethodInfo method in methods)
                {
                    MethodInvoke mi = (MethodInvoke)Attribute.GetCustomAttribute(method, typeof(MethodInvoke));
                    if (mi != null)
                    {
                        bool            invoked    = false;
                        ParameterInfo[] parameters = method.GetParameters();
                        ConfigPathNode  nnode      = node;
                        if (parameters != null && parameters.Length > 0)
                        {
                            if (!String.IsNullOrWhiteSpace(mi.Path))
                            {
                                AbstractConfigNode cnode = nnode.Find(mi.Path);
                                if (cnode != null && cnode.GetType() == typeof(ConfigPathNode))
                                {
                                    nnode = (ConfigPathNode)cnode;
                                }
                            }
                            if (nnode != null)
                            {
                                ConfigParametersNode pnode = nnode.GetParameters();
                                if (pnode != null)
                                {
                                    List <object> values = FindParameters(pnode, method.Name, parameters);
                                    if (values != null && values.Count > 0)
                                    {
                                        method.Invoke(target, values.ToArray());
                                        invoked = true;
                                    }
                                }
                            }
                        }
                        else
                        {
                            method.Invoke(target, null);
                            invoked = true;
                        }

                        if (!invoked)
                        {
                            throw new AnnotationProcessorException(String.Format("Error Invoking Method : [mehtod={0}][node={1}]",
                                                                                 method.Name, node.GetSearchPath()));
                        }
                    }
                }
            }
        }
Esempio n. 10
0
        public void CanCallStaticMethodWithoutArgsAndWithoutResult()
        {
            // Arrange
            // Act
            var result = MethodInvoke
                         .StaticMethod <ClassWithPrivateMethods>("StaticVoidMethodWithoutArgs", new object[0]);

            // Assert
            Assert.False(result.HasResult);
            Assert.Null(result.Value);
        }
Esempio n. 11
0
        public void CanCallInstanceMethodWithArgsAndWithResult()
        {
            // Arrange
            // Act
            var result = MethodInvoke.InstanceMethod(target, "InstanceStringMethodWithArgs", new object[] { trackable });

            // Assert
            Assert.True(result.HasResult);
            Assert.Equal("success", result.Value);
            trackable.Received(1).Touch();
        }
Esempio n. 12
0
        public void CanCallInstanceMethodWithArgsButWithoutResult()
        {
            // Arrange
            // Act
            var result = MethodInvoke.InstanceMethod(target, "InstanceVoidMethodWithArgs", new object[] { trackable });

            // Assert
            Assert.False(result.HasResult);
            Assert.Null(result.Value);
            trackable.Received(1).Touch();
        }
Esempio n. 13
0
        public void CanCallStaticMethodWithoutArgsButWithResult()
        {
            // Arrange
            // Act
            var result = MethodInvoke
                         .StaticMethod <ClassWithPrivateMethods>("StaticStringMethodWithoutArgs", new object[0]);

            // Assert
            Assert.True(result.HasResult);
            Assert.Equal("successStaticStringMethodWithoutArgs", result.Value);
        }
Esempio n. 14
0
        public static void AddContextAndParameters(this MethodInvoke owner)
        {
            // context
            owner.AddCode(Compiler.CONTEXT_NAME);

            // parameters
            using (var method = owner.AddMethodInvoke("new Parameters", null))
            {
                method.AddCode(method.ParameterName);
                method.AddDefaultParameters();
            }
        }
Esempio n. 15
0
        public void CanCallStaticMethodWithArgsButWithoutResult()
        {
            // Arrange
            // Act
            var result = MethodInvoke
                         .StaticMethod <ClassWithPrivateMethods>("StaticVoidMethodWithArgs", new object[] { trackable });

            // Assert
            Assert.False(result.HasResult);
            Assert.Null(result.Value);
            trackable.Received(1).Touch();
        }
Esempio n. 16
0
        public void CallingStaticMethodWithNullForValueTypeParameterThrowsException()
        {
            // Arrange
            // Act
            var caught = Assert.Throws <InvalidOperationException>(() =>
                                                                   MethodInvoke.StaticMethod <ClassWithPrivateMethods>(
                                                                       "StaticVoidMethodWhichIsNotOkayWhenArgIsNull",
                                                                       new object[] { null }));

            // Assert
            Assert.Equal("Didn't find a method mathing passed parameters.", caught.Message);
        }
Esempio n. 17
0
 /// <summary>
 /// Draws a line to the target of a method invoke.
 /// Also draws a rect if it's parameter is one.
 /// </summary>
 /// <param name="methodInvoke">The method invoke to draw</param>
 /// <param name="separation">The separation of the line</param>
 private void DrawMethodInvoke(MethodInvoke methodInvoke, Vector3 separation = new Vector3())
 {
     if (methodInvoke.target != null) {
         Gizmos.DrawLine(transform.position + separation, methodInvoke.target.transform.position + separation);
         Color temp = Gizmos.color;
         Color newColor = Color.yellow;
         newColor.a = 0.25f;
         Gizmos.color = newColor;
         Gizmos.DrawCube(methodInvoke.RectParameter.center - methodInvoke.RectParameter.size / 2, methodInvoke.RectParameter.size);
         Gizmos.color = temp;
     }
 }
Esempio n. 18
0
        public void CanCallStaticMethodWithArgsAndWithResult()
        {
            // Arrange
            // Act
            var result = MethodInvoke
                         .StaticMethod <ClassWithPrivateMethods>("StaticStringMethodWithArgs", new object[] { trackable });

            // Assert
            Assert.True(result.HasResult);
            Assert.Equal("successStaticStringMethodWithArgs", result.Value);
            trackable.Received(1).Touch();
        }
Esempio n. 19
0
        public void CanCallStaticMethodWithNullArgs()
        {
            // Arrange
            // Act
            var result = (string)MethodInvoke
                         .StaticMethod <ClassWithPrivateMethods>(
                "StaticStringMethodWhichIsOkayWhenArgIsNull",
                new object[] { null })
                         .Value;

            // Assert
            Assert.Equal(result, "Arg is null");
        }
Esempio n. 20
0
        private Task <Dictionary <string, ControllerDetail> > ResultInvoke(IList <ControllerDetail> objControllers, ReuseableParams objReuseableParams, List <ControllerDetail> lstApsExtraCompsInvoker)
        {
            Dictionary <string, ControllerDetail> result = new Dictionary <string, ControllerDetail>();
            MethodInvoke methodInvoke = new MethodInvoke();

            foreach (ControllerDetail item in objControllers)
            {
                ControllerDetail controllerDetail = methodInvoke.Execute(item, objReuseableParams, lstApsExtraCompsInvoker);
                if (!result.ContainsKey(controllerDetail.ComponentID.Trim()))
                {
                    result.Add(controllerDetail.ComponentID.Trim(), item);
                }
            }
            return(Task.FromResult(result));
        }
Esempio n. 21
0
 public Executer(object value = null, MethodInvoke method = null)
 {
     if (value == null)
     {
         return;
     }
     if (value is T)
     {
         Value = (T)value;
     }
     else
     {
         throw new ArgumentException("value");
     }
     m_Info = method;
 }
Esempio n. 22
0
        public static void AddSortComparer(this MethodInvoke method, EntryElement element)
        {
            // find orders
            var orders = (element == null || element.Sort == null || element.Sort.Keys == null ? new KeyElement[] { } : element.Sort.Keys)
                         .Select(key =>
            {
                // init
                var order = (key.SortOrderSpecified ? key.SortOrder : SortOrder.Ascending);

                // done
                return(Compiler.GetLiteral(order));
            })
                         .ToArray();

            // done
            method.AddCode("new SortComparer({0})", string.Join(", ", orders));
        }
Esempio n. 23
0
        public static void AddDefaultParameters(this MethodInvoke owner)
        {
            // init
            var context = owner.Context;

            // IFormattable
            owner.AddFromContext <IFormatting>(context, "fontStyle", x => x.FontStyleSpecified, x => x.FontStyle);
            owner.AddFromContext <IFormatting>(context, "fontVariant", x => x.FontVariantSpecified, x => x.FontVariant);
            owner.AddFromContext <IFormatting>(context, "fontWeight", x => x.FontWeightSpecified, x => x.FontWeight);
            owner.AddFromContext <IFormatting>(context, "textDecoration", x => x.TextDecorationSpecified, x => x.TextDecoration);
            owner.AddFromContext <IFormatting>(context, "verticalAlign", x => x.VerticalAlignSpecified, x => x.VerticalAlign);

            // strip periods
            owner.AddFromContext <IStripPeriods>(context, "stripPeriods", x => x.StripPeriodsSpecified, x => x.StripPeriods);

            // INamesOptions
            owner.AddFromContext <INamesOptions>(context, "namesDelimiter", x => x.Delimiter != null, x => x.Delimiter);

            // INameOptions
            owner.AddFromContext <INameOptions>(context, "and", x => x.AndSpecified, x => x.And);
            owner.AddFromContext <INameOptions>(context, "nameDelimiter", x => x.Delimiter != null, x => x.Delimiter);
            owner.AddFromContext <INameOptions>(context, "delimiterPrecedesEtAl", x => x.DelimiterPrecedesEtAlSpecified, x => x.DelimiterPrecedesEtAl);
            owner.AddFromContext <INameOptions>(context, "delimiterPrecedesLast", x => x.DelimiterPrecedesLastSpecified, x => x.DelimiterPrecedesLast);

            owner.AddFromContext <IEtAlOptions>(context, "etAlMin", x => x.EtAlMinSpecified, x => x.EtAlMin);
            owner.AddFromContext <IEtAlOptions>(context, "etAlUseFirst", x => x.EtAlUseFirstSpecified, x => x.EtAlUseFirst);
            owner.AddFromContext <IEtAlOptions>(context, "etAlSubsequentMin", x => x.EtAlSubsequentMinSpecified, x => x.EtAlSubsequentMin);
            owner.AddFromContext <IEtAlOptions>(context, "etAlSubsequentUseFirst", x => x.EtAlSubsequentUseFirstSpecified, x => x.EtAlSubsequentUseFirst);
            owner.AddFromContext <IEtAlOptions>(context, "etAlUseLast", x => x.EtAlUseLastSpecified, x => x.EtAlUseLast);

            owner.AddFromContext <INameOptions>(context, "nameFormat", x => x.FormatSpecified, x => x.Format);
            owner.AddFromContext <INameOptions>(context, "initialize", x => x.InitializeSpecified, x => x.Initialize);
            owner.AddFromContext <INameOptions>(context, "initializeWith", x => x.InitializeWith != null, x => x.InitializeWith);
            owner.AddFromContext <INameOptions>(context, "nameAsSortOrder", x => x.NameAsSortOrderSpecified, x => x.NameAsSortOrder);
            owner.AddFromContext <INameOptions>(context, "sortSeparator", x => x.SortSeparator != null, x => x.SortSeparator);
        }
Esempio n. 24
0
 protected void Mutate(IEvent e)
 {
     MethodInvoke.InvokeMethodOptional(State, RestoreMethodName, e);
     ++Version;
 }
Esempio n. 25
0
        /// <summary>
        /// Create a new Instance of the specified type.
        ///
        /// Type should have an empty constructor or a constructor with annotation.
        /// </summary>
        /// <typeparam name="T">Target Instance type</typeparam>
        /// <param name="type">Type</param>
        /// <param name="node">Configuration node.</param>
        /// <returns>Created Instance</returns>
        public static T CreateInstance <T>(Type type, ConfigPathNode node)
        {
            T target = default(T);

            ConstructorInfo[] constructors = type.GetConstructors(BindingFlags.Public | BindingFlags.Instance);
            if (constructors != null && constructors.Length > 0)
            {
                foreach (ConstructorInfo ci in constructors)
                {
                    MethodInvoke mi = (MethodInvoke)Attribute.GetCustomAttribute(ci, typeof(MethodInvoke));
                    if (mi != null)
                    {
                        ParameterInfo[] parameters = ci.GetParameters();
                        ConfigPathNode  nnode      = node;
                        if (parameters != null && parameters.Length > 0)
                        {
                            if (!String.IsNullOrWhiteSpace(mi.Path))
                            {
                                AbstractConfigNode cnode = nnode.Find(mi.Path);
                                if (cnode != null && cnode.GetType() == typeof(ConfigPathNode))
                                {
                                    nnode = (ConfigPathNode)cnode;
                                }
                            }
                            if (nnode != null)
                            {
                                ConfigParametersNode pnode = nnode.GetParameters();
                                if (pnode != null)
                                {
                                    List <object> values = FindParameters(pnode, ci.Name, parameters);
                                    if (values != null && values.Count > 0)
                                    {
                                        target = (T)Activator.CreateInstance(type, values.ToArray());
                                        break;
                                    }
                                }
                            }
                        }
                        else
                        {
                            target = Activator.CreateInstance <T>();
                            break;
                        }
                    }
                }
            }

            if (ReflectionUtils.IsNull(target))
            {
                target = Activator.CreateInstance <T>();
            }
            if (!ReflectionUtils.IsNull(target))
            {
                target = ReadValues((ConfigPathNode)node, target, null);
                CallMethodInvokes((ConfigPathNode)node, target);
            }
            else
            {
                throw new AnnotationProcessorException(String.Format("Error creating instance of Type: [path={0}][type={1}]", node.GetSearchPath(), type.FullName));
            }
            return(target);
        }
Esempio n. 26
0
 /// <summary>
 ///     The default constructor.
 /// </summary>
 protected BaseInterceptor()
 {
     MethodInvoker = new MethodInvoke();
 }
Esempio n. 27
0
 public void ToCall(string methodName)
 {
     MethodInvoke.InstanceMethod(@object, methodName, new object[0]);
 }
Esempio n. 28
0
        protected Node GetNode(GraphWriter g, IModelExpression expr)
        {
            if (nodeOfExpr.ContainsKey(expr))
            {
                return(nodeOfExpr[expr]);
            }
            Node nd = g.AddNode("node" + (Count++));

            nodeOfExpr[expr] = nd;
            nd.Label         = expr.ToString();
            nd.FontSize      = 9;
            if (expr is Variable)
            {
                Variable ve = (Variable)expr;
                if (ve.IsObserved)
                {
                    nd.Shape = ShapeStyle.None;

                    if (ve.IsBase)
                    {
                        // if the observed value is a ValueType, display it directly rather than the variable name
                        object value = ((HasObservedValue)ve).ObservedValue;
                        if (ReferenceEquals(value, null))
                        {
                            nd.Label = "null";
                        }
                        else if (value.GetType().IsValueType)
                        {
                            nd.Label = value.ToString();
                        }
                    }
                }
                if (!ve.IsReadOnly)
                {
                    nd.FontSize  = 10;
                    nd.FontColor = Color.Blue;
                }
                if (UseContainers && ve.Containers.Count > 0)
                {
                    var context = ConditionContext.GetContext(ve.Containers);
                    if (context != null)
                    {
                        var contextNode = GetNode(g, context);
                        AddGroupEdge(g, contextNode, nd);
                    }
                }
            }
            else if (expr is MethodInvoke)
            {
                MethodInvoke mi = (MethodInvoke)expr;
                nd.FillColor = Color.Black;
                nd.FontColor = Color.White;
                nd.Shape     = ShapeStyle.Box;
                nd.FontSize  = 8;
                string methodName = mi.method.Name;
                if (mi.op != null)
                {
                    methodName = mi.op.ToString();
                }
                nd.Label = methodName;
                if (UseContainers && mi.Containers.Count > 0)
                {
                    var context = ConditionContext.GetContext(mi.Containers);
                    if (context != null)
                    {
                        var contextNode = GetNode(g, context);
                        AddGroupEdge(g, contextNode, nd);
                    }
                }
            }
            return(nd);
        }
Esempio n. 29
0
        /// <summary>
        /// Add element to cache
        /// </summary>
        /// <param name="owner">The owner of value</param>
        /// <param name="value">Value to adapted</param>
        /// <param name="method">The method to execute when remove the item from cache</param>
        public void Add(object owner, T value, MethodInvoke method)
        {
            var item = Get_By_Owner(owner);

            if (item != null)
            {
                int index = item.Data.BinarySearch(new Executer <T> {
                    Value = value
                });
                // si esta lo sustituyo por el nuevo.
                if (index >= 0)
                {
                    RealSize        -= FromByteToKiloByte(value.get_Size());
                    item.Data[index] = new Executer <T> {
                        Value = value, m_Info = method
                    };
                    RealSize += FromByteToKiloByte(value.get_Size());
                    return;
                }
                // si no esta y cabe en la memoria
                if (RealSize + FromByteToKiloByte(value.get_Size()) <= Capacity)
                {
                    item.Data.Add(new Executer <T> {
                        Value = value, m_Info = method
                    });
                    RealSize += FromByteToKiloByte(value.get_Size());
                    return;
                }
                //no cabe, pero pudiera caber...
                if (item.get_Size() >= value.get_Size())
                {
                    while (RealSize + FromByteToKiloByte(value.get_Size()) > Capacity)
                    {
                        //eliminacion aleatoria de los elementos del cache
                        int pos = random.Next(item.Data.Count);
                        var x   = item.Data[pos];
                        //ejecutando la accion asociada
                        x.Execute();
                        item.Data.RemoveAt(pos);
                        RealSize -= FromByteToKiloByte(x.Value.get_Size());
                    }
                    item.Data.Add(new Executer <T> {
                        Value = value, m_Info = method
                    });
                    RealSize += FromByteToKiloByte(value.get_Size());
                    return;
                }
            }
            else
            {
                if (RealSize + FromByteToKiloByte(value.get_Size()) <= Capacity)
                {
                    data.Add(new CacheItem <T> {
                        Owner = owner, Data = new List <Executer <T> > {
                            new Executer <T> {
                                Value = value, m_Info = method
                            }
                        }
                    });
                    RealSize += FromByteToKiloByte(value.get_Size());
                    return;
                }
            }
            //si no lo puedo meter en el cache ejecutar la accion asociada
            new Executer <T> {
                Value = value, m_Info = method
            }.Execute();
        }
Esempio n. 30
0
        public async Task <object> InvokeDeviceMethodAsync(string connectionId, string deviceId, MethodInvoke methodInvokeParameters)
        {
            Console.WriteLine("InvokeDeviceMethodAsync received for {0} with deviceId {1} ", connectionId, deviceId);
            Console.WriteLine(methodInvokeParameters.ToString());
            var client  = objectMap[connectionId];
            var request = GlueUtils.CreateMethodRequest(methodInvokeParameters);

            Console.WriteLine("Invoking");
            var response = await client.InvokeMethodAsync(deviceId, request, CancellationToken.None).ConfigureAwait(false);

            Console.WriteLine("Response received:");
            Console.WriteLine(JsonConvert.SerializeObject(response));
            return(new JObject(
                       new JProperty("status", response.Status),
                       new JProperty("payload", response.ResultAsJson)
                       ));
        }
Esempio n. 31
0
 public R ToCall <R>(string methodName)
 {
     return((R)MethodInvoke.InstanceMethod(@object, methodName, new object[0]).Value);
 }