예제 #1
0
        internal bool Matches(IContext context, Func <InvokeInfo, bool> validator, Invoke invoke)
        {
            var ignoreCase = context.IgnoreCase();

            if (!MethodName.Equals(invoke.MethodName, ignoreCase))
            {
                return(false);
            }

            var required = Parameters.Where(x => x.IsRequired).ToList();

            if (invoke.Arguments.Count < required.Count)
            {
                return(false);
            }

            var invokeInfo = GetInvokeInfo(context, invoke);

            if (!validator(invokeInfo))
            {
                return(false);
            }

            return(true);
        }
예제 #2
0
 public bool Equals(RemoteProcedureDescriptor other)
 {
     return(ServiceHash.Equals(other.ServiceHash) &&
            InterfaceHash.Equals(other.InterfaceHash) &&
            MethodName.Equals(other.MethodName) &&
            MethodSignature.Equals(other.MethodSignature));
 }
예제 #3
0
        /// <summary>
        /// Returns true if MethodInvoke instances are equal
        /// </summary>
        /// <param name="other">Instance of MethodInvoke to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(MethodInvoke other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     MethodName == other.MethodName ||
                     MethodName != null &&
                     MethodName.Equals(other.MethodName)
                     ) &&
                 (
                     Payload == other.Payload ||
                     Payload != null &&
                     Payload.Equals(other.Payload)
                 ) &&
                 (
                     ResponseTimeoutInSeconds == other.ResponseTimeoutInSeconds ||
                     ResponseTimeoutInSeconds != null &&
                     ResponseTimeoutInSeconds.Equals(other.ResponseTimeoutInSeconds)
                 ) &&
                 (
                     ConnectTimeoutInSeconds == other.ConnectTimeoutInSeconds ||
                     ConnectTimeoutInSeconds != null &&
                     ConnectTimeoutInSeconds.Equals(other.ConnectTimeoutInSeconds)
                 ));
        }
예제 #4
0
        public override bool Equals(object obj)
        {
            var item = obj as MethodIdentity;

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

            return(MethodName.Equals(item.MethodName) && MessageType == item.MessageType);
        }
            public bool Equals(MethodKey other)
            {
                if (Object.ReferenceEquals(other, null))
                {
                    return(false);
                }

                return(MethodName.Equals(other.MethodName) &&
                       TypeArguments == other.TypeArguments &&
                       Parameters.SequenceEqual(other.Parameters, ParameterInfoComparer.Default));
            }
예제 #6
0
        public bool Equals(XunitTestTheoryTask other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            // Do not include base.Equals, so we don't try to compare Id or ParentId,
            // which will be different for each instance, and we're trying to act like
            // a value type
            return(ProjectId.Equals(other.ProjectId) &&
                   TypeName.Equals(other.TypeName) &&
                   MethodName.Equals(other.MethodName) &&
                   TheoryName.Equals(other.TheoryName));
        }
예제 #7
0
        public bool Equals(InvocationExpression compareNode)
        {
            return
                (compareNode != null &&
                 MethodName?.Equals(compareNode.MethodName) != false &&
                 Modifiers?.Equals(compareNode.Modifiers) != false &&
                 SemanticNamespace?.Equals(compareNode.SemanticNamespace) != false &&
                 CallerIdentifier?.Equals(compareNode.CallerIdentifier) != false &&
                 SemanticClassType?.Equals(compareNode.SemanticClassType) != false &&
                 SemanticMethodSignature?.Equals(compareNode.SemanticMethodSignature) != false &&
#pragma warning disable CS0618 // Type or member is obsolete
                 Parameters?.SequenceEqual(compareNode.Parameters) != false &&
#pragma warning restore CS0618 // Type or member is obsolete
                 Arguments?.SequenceEqual(compareNode.Arguments) != false &&
                 SemanticReturnType?.Equals(compareNode.SemanticReturnType) != false &&
                 SemanticOriginalDefinition?.Equals(compareNode.SemanticOriginalDefinition) != false &&
                 IsExtension == compareNode.IsExtension &&
                 base.Equals(compareNode));
        }
예제 #8
0
        public bool Equals(XunitTestTheoryTask other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            // Don't include base.Equals, as RemoteTask.Equals includes RemoteTask.Id
            // in the calculation, and this is a new guid generated for each new instance
            // Using RemoteTask.Id in the Equals means collapsing the return values of
            // IUnitTestElement.GetTaskSequence into a tree will fail (as no assembly,
            // or class tasks will return true from Equals)
            return(AssemblyLocation.Equals(other.AssemblyLocation) &&
                   TypeName.Equals(other.TypeName) &&
                   MethodName.Equals(other.MethodName) &&
                   TheoryName.Equals(other.TheoryName));
        }
예제 #9
0
        public override CILInstructionInstance Execute(CILInstructionInstance instructionInstance, CILProgramState state, CILProgramInstance programInstance, Stack <CILInstructionInstance> callStack)
        {
            var reflectedType   = TypeSpecification.GetTypeSpecified(programInstance);
            var reflectedMethod = (MethodBase)reflectedType.GetMethod(MethodName, GetMethodArgumentRuntimeTypes(programInstance).ToArray());

            if (reflectedMethod == null && MethodName.Equals(".ctor") && ParentMethod.IsConstructor)
            {
                return(instructionInstance.GetNextInstructionInstance());
            }

            var methodArguments = new List <object>();

            for (int i = 0; i < MethodArgumentTypes.Count; i++)
            {
                var argumentType = GetMethodArgumentRuntimeTypes(programInstance)[MethodArgumentTypes.Count - i - 1];

                var argument       = state.Stack.Pop();
                var methodArgument = ConvertHelper.ConvertIfPossible(argument, argumentType);
                methodArguments.Add(methodArgument);
            }
            methodArguments.Reverse();



            object methodObject = null;

            if (CallConvention.Instance)
            {
                methodObject = state.Stack.Pop();

                if (methodObject is Guid)
                {
                    var objectAddress = (Guid)methodObject;
                    methodObject = ParentMethod.GetLocalByAddress(objectAddress);
                }
            }

            var methodObjectToCall = methodObject;

            if (methodObjectToCall is CILClassInstance)
            {
                methodObjectToCall = (methodObjectToCall as CILClassInstance).BaseInstance;
            }

            if (methodObject is CILClassInstance)
            {
                var cilClass  = (methodObject as CILClassInstance)._cilClass;
                var cilMethod = cilClass.Methods.SingleOrDefault(m => m.MethodName == this.MethodName && CILantroType.CompareArgumentTypes(m.ArgumentTypes.Select(at => at.GetRuntimeType(programInstance)).ToArray(), this.GetMethodArgumentRuntimeTypes(programInstance).ToArray()));
                while (cilClass != null && cilMethod == null)
                {
                    cilClass = cilClass.ExtendsClass;
                    if (cilClass != null)
                    {
                        cilMethod = cilClass.Methods.SingleOrDefault(m => m.MethodName == this.MethodName && CILantroType.CompareArgumentTypes(m.ArgumentTypes.Select(at => at.GetRuntimeType(programInstance)).ToArray(), this.GetMethodArgumentRuntimeTypes(programInstance).ToArray()));
                    }
                }

                if (cilMethod != null)
                {
                    var newMethodInfo = new CILantroMethodInfo(cilMethod, programInstance, cilMethod.ReturnType.GetRuntimeType(programInstance));
                    reflectedMethod = newMethodInfo;
                }
            }

            if (reflectedMethod is CILantroMethodInfo)
            {
                callStack.Push(instructionInstance.GetNextInstructionInstance());

                var       cilantroMethodInfo = reflectedMethod as CILantroMethodInfo;
                CILMethod methodToCall       = null;

                object obj = methodObject;
                //object obj = null;
                if (CallConvention.Instance)
                {
                    //obj = state.Stack.Pop();
                    var cilClassInstance = obj as CILClassInstance;
                    var cilClass         = cilClassInstance._cilClass;

                    while (cilClass != null)
                    {
                        var matchingMethod = cilClass.Methods.FirstOrDefault(m => m.MethodName.Equals(MethodName) && CILantroType.CompareArgumentTypes(GetMethodArgumentRuntimeTypes(programInstance).ToArray(), m.ArgumentTypes.Select(ct => ct.GetRuntimeType(programInstance)).ToArray()));
                        if (matchingMethod != null)
                        {
                            methodToCall = matchingMethod;
                            break;
                        }

                        cilClass = programInstance.Program.Classes.FirstOrDefault(c => c.ClassName.UniqueName == cilClass.Extends.UniqueName);
                    }
                }

                if (methodToCall == null)
                {
                    methodToCall = cilantroMethodInfo.Method;
                }

                return(methodToCall.CreateInstance(obj, methodArguments.ToArray()).GetFirstInstructionInstance());
            }

            var methodResult = reflectedMethod.Invoke(methodObjectToCall, methodArguments.ToArray());

            if (MethodReturnType.GetRuntimeType(programInstance) != typeof(void))
            {
                state.Stack.Push(methodResult);
            }

            return(instructionInstance.GetNextInstructionInstance());
        }
예제 #10
0
        private CodeFunction GetMethod()
        {
            CodeClass clazz = ProjectItemHelper.GetClass(ProjectItem);

            if (clazz != null)
            {
                foreach (CodeElement codeElement in clazz.Children)
                {
                    CodeFunction codeFunction = codeElement as CodeFunction;
                    if (codeFunction != null)
                    {
                        if (codeFunction.Parameters.Count == 0 && codeFunction.Type.TypeKind.Equals(vsCMTypeRef.vsCMTypeRefVoid) && MethodName.Equals(codeFunction.Name))
                        {
                            return(codeFunction);
                        }
                    }
                }
            }
            return(null);
        }
예제 #11
0
        public override CILInstructionInstance Execute(CILInstructionInstance instructionInstance, CILProgramState state, CILProgramInstance programInstance, Stack <CILInstructionInstance> callStack)
        {
            var reflectedType   = TypeSpecification.GetTypeSpecified(programInstance);
            var reflectedMethod = (MethodBase)reflectedType.GetMethod(MethodName, GetMethodArgumentRuntimeTypes(programInstance).ToArray());

            if (reflectedMethod == null && MethodName.Equals(".ctor"))
            {
                var reflectedConstructor = reflectedType.GetConstructor(GetMethodArgumentRuntimeTypes(programInstance).ToArray());
                if (reflectedConstructor == null)
                {
                    reflectedConstructor = reflectedType.GetConstructor(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance, null, GetMethodArgumentRuntimeTypes(programInstance).ToArray(), null);
                }
                reflectedMethod = (MethodBase)reflectedConstructor;
            }

            var methodArguments = new List <object>();

            for (int i = 0; i < MethodArgumentTypes.Count; i++)
            {
                var argumentType = GetMethodArgumentRuntimeTypes(programInstance)[MethodArgumentTypes.Count - i - 1];

                var argument       = state.Stack.Pop();
                var methodArgument = ConvertHelper.ConvertIfPossible(argument, argumentType);
                methodArguments.Add(methodArgument);
            }
            methodArguments.Reverse();

            if (reflectedMethod is CILantroMethodInfo)
            {
                callStack.Push(instructionInstance.GetNextInstructionInstance());

                object obj = null;
                if (CallConvention.Instance)
                {
                    obj = state.Stack.Pop();
                }

                var cilantroMethod = reflectedMethod as CILantroMethodInfo;
                return(cilantroMethod.Method.CreateInstance(obj, methodArguments.ToArray()).GetFirstInstructionInstance());
            }

            object methodObject = null;

            if (CallConvention.Instance)
            {
                methodObject = state.Stack.Pop();

                if (methodObject is Guid)
                {
                    var objectAddress = (Guid)methodObject;
                    methodObject = ParentMethod.GetLocalByAddress(objectAddress);
                }
            }

            var methodObjectToCall = methodObject;

            if (methodObjectToCall is CILClassInstance)
            {
                methodObjectToCall = (methodObjectToCall as CILClassInstance).BaseInstance;
            }

            var methodResult = reflectedMethod.Invoke(methodObjectToCall, methodArguments.ToArray());

            if (MethodReturnType.GetRuntimeType(programInstance) != typeof(void))
            {
                state.Stack.Push(methodResult);
            }
            else if (MethodName.Equals(".ctor"))
            {
                state.Stack.Push(methodObject);
            }

            return(instructionInstance.GetNextInstructionInstance());
        }
예제 #12
0
 public bool IsReduceByKey()
 {
     return(MethodName.Equals("reduceByKey", StringComparison.OrdinalIgnoreCase));
 }