Esempio n. 1
0
 public void marshall(Object o, TextWriter w, IBaseMarshaller baseMarshaller, int flags, int depth)
 {
     if (o.GetType().IsArray)
     {
         baseMarshaller.marshallAsVector(o, w, flags, depth);
     }
     else if (baseMarshaller.canMarshallAsList(o))
     {
         baseMarshaller.marshallAsVector(o, w, flags, depth);
     }
     else if (o is Type)
     {
         baseMarshaller.marshallAtom(o.ToString(), w, flags, depth);
     }
     else
     {
         try
         {
             w.Write(" (");
             PropertyInfo[] props = o.GetType().GetProperties();
             for (int i = 0; i < props.Length; i++)
             {
                 PropertyInfo prop = props[i];
                 //skip getClass generated property
                 if (prop.Name.Equals("object"))
                 {
                     continue;
                 }
                 MethodInfo m = props[i].GetGetMethod();
                 //must be no-arg property getter
                 if (m != null && m.GetParameters().Length == 0)
                 {
                     w.Write("(:");                             //sent as keyword
                     w.Write(prop.Name);
                     w.Write(" . ");
                     baseMarshaller.marshallAtom(m.Invoke(o, null), w, flags, depth);
                     w.Write(')');
                 }
             }
             w.Write(')');
         }
         catch (Exception ex)
         {
             throw new IOException(ex.ToString());
         }
     }
 }
 public void marshall(Object o, TextWriter w, IBaseMarshaller baseMarshaller,int flags, int depth)
 {
     if(o.GetType().IsArray)
         baseMarshaller.marshallAsVector(o,w,flags,depth);
     else if(baseMarshaller.canMarshallAsList(o))
         baseMarshaller.marshallAsVector(o,w,flags,depth);
     else if(o is Type)
         baseMarshaller.marshallAtom(o.ToString(),w,flags,depth);
     else
     {
         try
         {
             w.Write(" (");
             PropertyInfo[] props = o.GetType().GetProperties();
             for(int i=0;i<props.Length;i++)
             {
                 PropertyInfo prop = props[i];
                 //skip getClass generated property
                 if(prop.Name.Equals("object"))
                     continue;
                 MethodInfo m = props[i].GetGetMethod();
                 //must be no-arg property getter
                 if(m != null && m.GetParameters().Length == 0)
                 {
                     w.Write("(:"); //sent as keyword
                     w.Write(prop.Name);
                     w.Write(" . ");
                     baseMarshaller.marshallAtom(m.Invoke(o,null),w,flags,depth);
                     w.Write(')');
                 }
             }
             w.Write(')');
         }
         catch(Exception ex)
         {
             throw new IOException(ex.ToString());
         }
     }
 }