Last active
December 11, 2015 08:58
-
-
Save jpolvora/4576913 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* REFERENCIAR o assembly System.ServiceModel.dll */ | |
using System.ServiceModel; | |
using System.ServiceModel.DomainServices.Client; | |
partial class MyDomainContext { | |
partial void OnCreated() { | |
var timeSpan = TimeSpan.FromSeconds(30); /* 30 segundos de timeout */ | |
DomainContextExtensions.ChangeWcfSendTimeout(this, timeSpan); | |
} | |
/* colocar este método numa classe static p/ extensões, por exemplo DomainContextExtensions.cs*/ | |
public static void ChangeWcfSendTimeout(DomainContext context, TimeSpan sendTimeout) { | |
var channelFactoryProperty = context.DomainClient.GetType().GetProperty("ChannelFactory"); | |
if (channelFactoryProperty == null) { | |
throw new InvalidOperationException("There is no 'ChannelFactory' property on the DomainClient."); | |
} | |
var factory = (ChannelFactory)channelFactoryProperty.GetValue(context.DomainClient, null); | |
factory.Endpoint.Binding.SendTimeout = sendTimeout; | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment