コード例 #1
0
ファイル: ObjectWriter.cs プロジェクト: antmicro/Migrant
 /// <summary>
 /// Writes the object using reflection.
 /// 
 /// REMARK: this method is not thread-safe!
 /// </summary>
 /// <param name="objectWriter">Object writer's object</param>
 /// <param name="o">Object to serialize</param>
 internal static void WriteObjectUsingReflection(ObjectWriter objectWriter, object o)
 {
     Helpers.InvokeAttribute(typeof(PreSerializationAttribute), o);
     if(!objectWriter.WriteSpecialObject(o, !objectWriter.treatCollectionAsUserObject))
     {
         objectWriter.WriteObjectsFields(o, o.GetType());
     }
 }
コード例 #2
0
 private static void WriteObjectUsingReflection(ObjectWriter objectWriter, PrimitiveWriter primitiveWriter, object o)
 {
     objectWriter.TouchAndWriteTypeId(o.GetType());
     // the primitiveWriter and parameter is not used here in fact, it is only to have
     // signature compatible with the generated method
     Helpers.InvokeAttribute(typeof(PreSerializationAttribute), o);
     try
     {
         var type = o.GetType();
         objectWriter.currentlyWrittenTypes.Push(type);
         if(!objectWriter.WriteSpecialObject(o))
         {
             objectWriter.WriteObjectsFields(o, type);
         }
         objectWriter.currentlyWrittenTypes.Pop();
     }
     finally
     {
         Helpers.InvokeAttribute(typeof(PostSerializationAttribute), o);
         var postHook = Helpers.GetDelegateWithAttribute(typeof(LatePostSerializationAttribute), o);
         if(postHook != null)
         {
             objectWriter.postSerializationHooks.Add(postHook);
         }
     }
 }
コード例 #3
0
 public abstract void Write(ObjectWriter writer);
コード例 #4
0
ファイル: Serializer.cs プロジェクト: tralivali1234/Migrant
 internal OpenStreamSerializer(ObjectWriter writer)
 {
     this.writer = writer;
 }