コード例 #1
0
ファイル: Reader.cs プロジェクト: lanicon/Galador.Reflection
 object Read(ReadArgs args)
 {
     if (readRecurseDepth++ == 0)
     {
         var sFlags = input.ReadVInt();
         settings.FromFlags((int)sFlags);
     }
     try
     {
         var result = ReadImpl(args);
         if (readRecurseDepth > 1)
             return result;
         return AsNormalData(result);
     }
     finally
     {
         if (--readRecurseDepth == 0)
         {
             foreach (var item in Objects.OfType<IDeserialized>())
             {
                 item.OnDeserialized(GetLost(item, false) ?? new LostData(item));
             }
             foreach (var item in Objects.OfType<SRS.IDeserializationCallback>())
             {
                 // Known Issue: native .NET serialization doesn't support breaking generic type parameter change
                 try { item.OnDeserialization(this); }
                 catch (InvalidCastException ex) { Log.Error(ex); }
             }
         }
     }
 }
コード例 #2
0
        /// <summary>
        /// Reads the next object from the <see cref="Reader"/>.
        /// </summary>
        /// <returns>The next object in the stream.</returns>
        public object Read()
        {
            if (recurseDepth++ == 0)
            {
                var sFlags = Reader.ReadVInt();
                settings.FromFlags((int)sFlags);
            }
            try
            {
                return(Read(ReflectType.RObject, null));
            }
            finally
            {
                if (--recurseDepth == 0)
                {
                    foreach (var item in Context.Objects.OfType <IDeserialized>())
                    {
                        item.Deserialized();
                    }
#if !__PCL__ && !__NETCORE__
                    foreach (var item in Context.Objects.OfType <SRS.IDeserializationCallback>())
                    {
                        item.OnDeserialization(this.Context);
                    }
#endif
                }
            }
        }