Example #1
0
        public static void WriteTypedStreamSerializable(ITypedStreamSerializable victim, Stream sink)
        {
            if (victim == null)
            {
                WriteBool(false, sink);
            }
            else
            {
                WriteBool(true, sink);
                TypedStreamSerializableAttribute attribute = TypedStreamSerializableHelper.FindAttribute(victim);


                WriteString(attribute.Identifier, sink);
                victim.Write(sink);
            }
        }
Example #2
0
        public static ITypedStreamSerializable ReadTypedStreamSerializable(Stream src, params Assembly[] asms)
        {
            bool hasValue = ReadBool(src);

            if (hasValue == false)
            {
                return(null);
            }

            string identifier = ReadString(src);

            foreach (Assembly asm in asms)
            {
                Type t = TypedStreamSerializableHelper.FindTypedStreamSerializableType(identifier, asm);

                if (t != null)
                {
                    return(TypedStreamSerializableHelper.CreateTypedStreamSerializable(t, src));
                }
            }

            throw new ArgumentException(string.Format("Could not find TypedStreamSerializable-Type with identifier={0}", identifier));
        }