public static object Deserialize(Stream strm)
        {
            if (strm == null)
            {
                throw new System.ArgumentNullException("strm");
            }

            using (var serializer = SPSerializer.Create())
            {
                var formatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
                return(serializer.Deserialize(formatter, strm));
            }
        }
        public static void Serialize(Stream strm, object obj)
        {
            if (strm == null)
            {
                throw new System.ArgumentNullException("strm");
            }

            if (obj != null)
            {
                using (var serializer = SPSerializer.Create())
                {
                    var formatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
                    serializer.Serialize(formatter, strm, obj);
                }
            }
        }
 public ISerializationSurrogate GetSurrogate(Type type, StreamingContext context, out ISurrogateSelector selector)
 {
     if (SPSerializer.IsSpeciallySerialized(type))
     {
         selector = this;
         return(this);
     }
     else if (_nextSelector != null)
     {
         return(_nextSelector.GetSurrogate(type, context, out selector));
     }
     else
     {
         selector = null;
         return(null);
     }
 }
        public override ISerializationSurrogate GetSurrogate(Type type, StreamingContext context, out ISurrogateSelector selector)
        {
            ISerializationSurrogate surrogate = null;

            selector = null;
            if (_formattersSurrogateSelector != null)
            {
                surrogate = _formattersSurrogateSelector.GetSurrogate(type, context, out selector);
            }
            if (surrogate == null)
            {
                surrogate = base.GetSurrogate(type, context, out selector);
            }
            if (surrogate == null && SPSerializer.IsSpeciallySerialized(type))
            {
                selector  = this;
                surrogate = _specialSurrogate;
            }

            return(surrogate);
        }