This class maps a local type to a bus side type.
Beispiel #1
0
 /// <summary>
 /// Test if two types are equal
 /// </summary>
 /// <param name="remoteType">Remote Type</param>
 /// <param name="localType">Local Type</param>
 /// <returns>If to types are equal</returns>
 private static bool TypeIsEqual(string remoteType, Type localType, ParameterInfo[] parameterInfos)
 {
     if (localType.Equals(typeof(object))) return true;
     RemoteType remote_typ = new RemoteType(remoteType, parameterInfos);
     if (localType.Name.ToLower().Contains("nullable")) return (localType.FullName.Contains(remote_typ.Name));
     return (remote_typ.Name.ToUpper().Equals(localType.Name.ToUpper()));
 }
Beispiel #2
0
        /// <summary>
        /// Unmarshalls the arguments of a MethodCall.
        /// </summary>
        /// <param name="methodCall">MethodCall</param>
        /// <returns>Arguments</returns>
        protected object[] CreateMethodArguments(IMethodCall methodCall, MethodInfo methodInfo)
        {
            Type           extendtypeWith = typeof(IOpenEngSBModel);
            IList <object> args           = new List <object>();
            Assembly       asm            = typeof(domainServiceType).GetType().Assembly;

            for (int i = 0; i < methodCall.Args.Count; ++i)
            {
                Object arg         = methodCall.Args[i];
                String methodClass = methodCall.Classes[i];

                RemoteType remoteType = new RemoteType(methodClass, methodInfo.GetParameters());
                if (remoteType.LocalTypeFullName == null)
                {
                    args.Add(null);
                    continue;
                }

                Type type = asm.GetType(remoteType.LocalTypeFullName);
                if (type == null)
                {
                    type = Type.GetType(remoteType.LocalTypeFullName);
                }

                if (type == null)
                {
                    foreach (ParameterInfo param in methodInfo.GetParameters())
                    {
                        if (param.ParameterType.FullName.ToUpper().Equals(remoteType.LocalTypeFullName.ToUpper()))
                        {
                            type = param.ParameterType;
                        }
                    }
                }

                if (type == null)
                {
                    throw new BridgeException("no corresponding local type found");
                }


                object obj = null;
                if (type.IsInstanceOfType(arg))
                {
                    obj = arg;
                }
                else if (type.IsPrimitive || type.Equals(typeof(string)))
                {
                    obj = arg;
                }
                else if (type.IsEnum)
                {
                    obj = Enum.Parse(type, (string)arg);
                }
                else
                {
                    obj = Marshaller.UnmarshallObject(arg.ToString(), type);
                }

                args.Add(obj);
            }

            HelpMethods.AddTrueForSpecified(args, methodInfo);
            return(args.ToArray());
        }