public void GetObjectData(SerializationInfo info, StreamingContext context) { if (context.State != StreamingContextStates.CrossAppDomain) { throw new InvalidOperationException("Serialization not supported"); } var gIdent = new GenericIdentity(Name, AuthenticationType); info.SetType(gIdent.GetType()); var serializableMembers = FormatterServices.GetSerializableMembers(gIdent.GetType()); var serializableValues = FormatterServices.GetObjectData(gIdent, serializableMembers); for (var i = 0; i < serializableMembers.Length; i++) { info.AddValue(serializableMembers[i].Name, serializableValues[i]); } }
public void GetObjectData(SerializationInfo info, StreamingContext context) { if (context.State == StreamingContextStates.CrossAppDomain) { GenericIdentity gIdent = new GenericIdentity(this.Name, this.AuthenticationType); info.SetType(gIdent.GetType()); System.Reflection.MemberInfo[] serializableMembers; object[] serializableValues; serializableMembers = FormatterServices.GetSerializableMembers(gIdent.GetType()); serializableValues = FormatterServices.GetObjectData(gIdent, serializableMembers); for (int i = 0; i < serializableMembers.Length; i++) { info.AddValue(serializableMembers[i].Name, serializableValues[i]); } } else { throw new InvalidOperationException("Serialization not supported"); } }