Ejemplo n.º 1
0
 private static bool IsAssignableFrom(Net.Vpc.Upa.Impl.Config.Callback.InvokeArgument a, System.Type type)
 {
     if (a.IsAcceptSubClasses())
     {
         return(a.GetPlatformType().IsAssignableFrom(type));
     }
     else
     {
         return(a.GetPlatformType().Equals(type));
     }
 }
Ejemplo n.º 2
0
 public static Net.Vpc.Upa.Impl.Config.Callback.MethodArgumentsConverter Create(Net.Vpc.Upa.Impl.Config.Callback.InvokeArgument[] userArgs, Net.Vpc.Upa.Impl.Config.Callback.InvokeArgument[] apiArguments, Net.Vpc.Upa.Impl.Config.Callback.InvokeArgument[] implicitArguments)
 {
     //        this.userTypes = userTypes;
     //        this.userNames = userNames;
     //        this.apiTypes = apiTypes;
     //        this.apiNames = apiNames;
     //        this.implicitArguments = implicitArguments;
     Net.Vpc.Upa.Impl.Config.Callback.InvokeArgument[] eval = new Net.Vpc.Upa.Impl.Config.Callback.InvokeArgument[userArgs.Length];
     for (int i = 0; i < userArgs.Length; i++)
     {
         string      un = userArgs[i].GetName();
         System.Type ut = userArgs[i].GetPlatformType();
         int         up = i;
         if (un != null)
         {
             Net.Vpc.Upa.Impl.Config.Callback.InvokeArgument aa = null;
             foreach (Net.Vpc.Upa.Impl.Config.Callback.InvokeArgument apiArgument in apiArguments)
             {
                 if (apiArgument.GetName().Equals(un))
                 {
                     if (IsAssignableFrom(apiArgument, ut))
                     {
                         aa = apiArgument;
                         break;
                     }
                     else
                     {
                         throw new System.ArgumentException("Invalid argument type : " + ut + " " + un + " at position " + up);
                     }
                 }
             }
             if (aa == null)
             {
                 foreach (Net.Vpc.Upa.Impl.Config.Callback.InvokeArgument implicitArgument in implicitArguments)
                 {
                     if (IsAssignableFrom(implicitArgument, ut))
                     {
                         aa = implicitArgument;
                         break;
                     }
                     else
                     {
                         throw new System.ArgumentException("Invalid argument type : " + ut + " " + un + " at position " + up);
                     }
                 }
             }
             if (aa != null)
             {
                 eval[i] = aa;
             }
             else
             {
                 throw new System.ArgumentException("Missing argument " + ut + " " + un + " at position " + up);
             }
         }
         else
         {
             if (IsAssignableFrom(apiArguments[i], ut))
             {
                 eval[i] = apiArguments[i];
             }
             else
             {
                 //check if the same type isnt called twice
                 int count = 0;
                 System.Collections.Generic.IList <Net.Vpc.Upa.Impl.Config.Callback.InvokeArgument> possible = new System.Collections.Generic.List <Net.Vpc.Upa.Impl.Config.Callback.InvokeArgument>();
                 foreach (Net.Vpc.Upa.Impl.Config.Callback.InvokeArgument apiArgument in apiArguments)
                 {
                     if (IsAssignableFrom(apiArgument, ut))
                     {
                         possible.Add(apiArgument);
                     }
                 }
                 foreach (Net.Vpc.Upa.Impl.Config.Callback.InvokeArgument implicitArgument in implicitArguments)
                 {
                     if (IsAssignableFrom(implicitArgument, ut))
                     {
                         possible.Add(implicitArgument);
                     }
                 }
                 if ((possible).Count == 0)
                 {
                     throw new System.ArgumentException("Missing argument " + ut + " " + un + " at position " + up);
                 }
                 else if ((possible).Count > 1)
                 {
                     throw new System.ArgumentException("Ambiguous argument " + ut + " " + un + " at position " + up);
                 }
                 else
                 {
                     eval[i] = possible[0];
                 }
             }
         }
     }
     return(new Net.Vpc.Upa.Impl.Config.Callback.DefaultMethodArgumentsConverter(eval));
 }