/// <summary> /// Pulls out a serialization context from a provided streaming context or creates a new one. /// </summary> /// <param name="context">The streaming context.</param> /// <returns>A <see cref="SerializationContext"/>.</returns> public static SerializationContext/*!*/ CreateFromStreamingContext(StreamingContext context) { SerializationContext result = context.Context as SerializationContext; if (result == null) result = new SerializationContext(); return result; }
/// <include file='Doc/Common.xml' path='/docs/method[@name="serialization.ctor"]/*'/> protected Deserializer(SerializationInfo info, StreamingContext context) { this.serInfo = info; this.context = SerializationContext.CreateFromStreamingContext(context); string class_name_str = info.GetString(__PHP_Incomplete_Class.ClassNameFieldName); if (String.IsNullOrEmpty(class_name_str)) { // note that we must never return null from GetRealObject (formatters do not like it) return; } instance = Serialization.GetUninitializedInstance(class_name_str, this.context.ScriptContext); if (instance == null) { throw new SerializationException(CoreResources.GetString("class_instantiation_failed", class_name_str)); } }