Beispiel #1
0
 private bool Equals(SerializableMethod other)
 {
     return(string.Equals(methodName, other.methodName) &&
            Equals(containingType, other.containingType) &&
            bindingFlags == other.bindingFlags &&
            isGeneric == other.isGeneric &&
            Util.ArraysEqual(parameterTypes, other.parameterTypes));
 }
        private static int MethodComparer(SerializableMethod method1, SerializableMethod method2)
        {
            var m1IsGetOrSet = IsGetter(method1.MethodInfo) || IsSetter(method1.MethodInfo);
            var m2IsGetOrSet = IsGetter(method2.MethodInfo) || IsSetter(method2.MethodInfo);

            if (m1IsGetOrSet == m2IsGetOrSet)
            {
                return(method1.MethodName.CompareTo(method2.MethodName));
            }
            if (m1IsGetOrSet)
            {
                return(1);
            }
            return(-1);
        }
        public SerializableAction_Single(Object targetObject, SerializableMethod target, params object[] parameters)
        {
            Assert.AreEqual(target.ParameterTypes.Length, parameters.Length);
            for (var i = 0; i < target.ParameterTypes.Length; i++)
            {
                var parameterType = target.ParameterTypes[i];
                Assert.IsTrue((parameters[i] == null && !parameterType.SystemType.IsValueType) || parameterType.SystemType.IsInstanceOfType(parameters[i]));
            }

            this.targetObject = targetObject;
            this.target       = new SerializableActionTarget(target);
            arguments         = new SerializableArgument[parameters.Length];
            for (int i = 0; i < arguments.Length; i++)
            {
                arguments[i] = new SerializableArgument(parameters[i], parameters[i].GetType(), target.ParameterNames[i]);
            }
        }
Beispiel #4
0
        private static string MethodName(SerializableMethod method)
        {
            var methodInfo = method.MethodInfo;

            if (methodInfo == null)
            {
                return("Null method");
            }

            var parameterTypes = method.ParameterTypes;
            var parameterNames = method.ParameterNames;

            if (MethodLister.IsSetter(methodInfo))
            {
                var nameBuilder = new StringBuilder(methodInfo.Name.Replace("_", " "));
                nameBuilder[0] = 'S'; //Upper case "set"
                return(string.Format("{0} ({1})", nameBuilder.ToString(), parameterTypes[0]));
            }

            string printData = methodInfo.Name;

            printData += "(";
            if (parameterTypes.Length > 0)
            {
                for (var i = 0; i < parameterTypes.Length; i++)
                {
                    printData += string.Format("{0} {1}", parameterTypes[i], parameterNames[i]);
                    if (i != parameterTypes.Length - 1)
                    {
                        printData += ", ";
                    }
                }
            }
            printData += ")";
            if (methodInfo.ReturnType != typeof(void))
            {
                printData += " => " + methodInfo.ReturnType.Name;
            }
            return(printData);
        }
Beispiel #5
0
 public SerializableActionTarget(SerializableMethod target)
 {
     TargetMethod = target;
 }