GetProxy() public static method

public static GetProxy ( Type t ) : ZXPProxy
t Type
return ZXPProxy
Exemplo n.º 1
0
 public static void Write(StreamWriter writer, object o, ZXPProxy zpp, int spaces = 0)
 {
     foreach (var f in zpp.Data)
     {
         object value = f.GetValue(o);
         if (f.Converter == null)
         {
             if (value == null)
             {
                 writer.WriteLine("{2}{0} <{1}> {{ NULL }}", f.Key, f.Type.FullName, new string(' ', spaces));
             }
             else
             {
                 Type vType = value.GetType();
                 writer.WriteLine("{2}{0} <{1}> {{", f.Key, vType.FullName, new string(' ', spaces));
                 Write(writer, value, ZXPProxy.GetProxy(vType), spaces + 4);
                 writer.WriteLine("{0}", new string(' ', spaces) + "}");
             }
         }
         else
         {
             writer.WriteLine("{2}{0} [{1}]", f.Key, f.Converter.Convert(value), new string(' ', spaces));
         }
     }
 }
Exemplo n.º 2
0
        public static object ParseNew(string s, Type t)
        {
            // Check Arguments
            if (t == null || string.IsNullOrEmpty(s))
            {
                return(null);
            }

            // Attempt A Conversion
            IZXPConverter conv;

            if (GetConverter(t, out conv))
            {
                object value = null;
                conv.Convert(s, out value);
                return(value);
            }
            else if (t.IsArray)
            {
                object val = null;
                if (!t.HasElementType)
                {
                    return(null);
                }
                Type eType = t.GetElementType();
                if (ParseArray(eType, s, out val))
                {
                    return(val);
                }
                else
                {
                    return(null);
                }
            }

            // Create A Complex Value
            ZXPProxy zpp = ZXPProxy.GetProxy(t);
            object   o   = CreateDefaultFromType(zpp.Type);

            ParseInto(s, o, zpp);
            return(o);
        }
Exemplo n.º 3
0
 public static void Write(StreamWriter writer, object o)
 {
     Write(writer, o, ZXPProxy.GetProxy(o.GetType()));
 }
Exemplo n.º 4
0
        public static void ParseInto(string s, object o)
        {
            ZXPProxy zpp = ZXPProxy.GetProxy(o.GetType());

            ParseInto(s, o, zpp);
        }