Exemplo n.º 1
0
            protected static void serialize(Serializer serializer, object value, Poperty property)
            {
                object propertyValue;

                if (property.IsSerialize(serializer, value, out propertyValue))
                {
                    PropertyInfo propertyInfo = property.PropertyInfo;
                    CharStream   charStream   = serializer.CharStream;
                    charStream.PrepLength(propertyInfo.Name.Length + 2);
                    charStream.UnsafeWrite('<');
                    charStream.UnsafeSimpleWrite(propertyInfo.Name);
                    charStream.UnsafeWrite('>');
                    property.Serialize(serializer, propertyValue);
                    charStream.PrepLength(propertyInfo.Name.Length + 3);
                    charStream.UnsafeWrite('<');
                    charStream.UnsafeWrite('/');
                    charStream.UnsafeSimpleWrite(propertyInfo.Name);
                    charStream.UnsafeWrite('>');
                }
            }
Exemplo n.º 2
0
 /// <summary>
 /// 序列化
 /// </summary>
 /// <param name="serializer"></param>
 /// <param name="value"></param>
 public void SerializeBox(Serializer serializer, valueType value)
 {
     if (fields.Length == 0)
     {
         Poperty property = properties[0];
         object  propertyValue;
         if (property.IsSerialize(serializer, value, out propertyValue))
         {
             property.Serialize(serializer, propertyValue);
         }
     }
     else
     {
         Field  field = fields[0];
         object fieldValue;
         if (field.IsSerialize(serializer, value, out fieldValue))
         {
             field.Serialize(serializer, fieldValue);
         }
     }
 }