object IDataContractSurrogate.GetObjectToSerialize( object obj, Type targetType) { if (obj.GetType().IsSubclassOf(typeof(OrganizationRequest))) { OrganizationRequest organizationRequest = (OrganizationRequest)obj; if (KnownProxyTypesProvider.GetInstance(this._proxyTypesAssembly != (Assembly)null).GetTypeForName(organizationRequest.RequestName, this._proxyTypesAssembly) == (Type)null) { return(obj); } return((object)new OrganizationRequest() { RequestName = organizationRequest.RequestName, Parameters = organizationRequest.Parameters, RequestId = organizationRequest.RequestId }); } if (!obj.GetType().IsSubclassOf(typeof(Entity))) { return(obj); } Entity entity = (Entity)obj; Entity target = new Entity(); entity.ShallowCopyTo(target); return((object)target); }