Exemple #1
0
 public static bool CanChangeType(ScriptObject par, Type type)
 {
     if (type == TYPE_OBJECT || par.IsNull)
     {
         return(true);
     }
     else
     {
         if (par is ScriptString && Util.IsString(type))
         {
             return(true);
         }
         else if (par is ScriptNumber && (IsNumber(type) || IsEnum(type)))
         {
             return(true);
         }
         else if (par is ScriptBoolean && IsBool(type))
         {
             return(true);
         }
         else if (par is ScriptEnum && (par as ScriptEnum).EnumType == type)
         {
             return(true);
         }
         else if (par is ScriptArray && type.IsArray)
         {
             return(true);
         }
         else if (par is ScriptUserdata)
         {
             if (Util.IsType(type))
             {
                 return(true);
             }
             else if (type.IsAssignableFrom(((ScriptUserdata)par).ValueType))
             {
                 return(true);
             }
         }
         else if (type.IsAssignableFrom(par.GetType()))
         {
             return(true);
         }
     }
     return(false);
 }