本文整理汇总了C#中IClientChannel.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# IClientChannel.GetType方法的具体用法?C# IClientChannel.GetType怎么用?C# IClientChannel.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IClientChannel
的用法示例。
在下文中一共展示了IClientChannel.GetType方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BeforeSendRequest
public object BeforeSendRequest(ref Message request, IClientChannel channel)
{
try
{
var channelType = channel.GetType();
var serverContext = new ServerApplicationContext();
if (HttpContext.Current != null
&& HttpContext.Current.Items != null
&& HttpContext.Current.Items[AppInfoCenterConfiguration.Const.ContextIdentityKey] != null)
{
serverContext.RequestIdentity = HttpContext.Current.Items[AppInfoCenterConfiguration.Const.ContextIdentityKey].ToString();
}
else if (CallContext.GetData(AppInfoCenterConfiguration.Const.ContextIdentityKey) != null)
{
serverContext.RequestIdentity = CallContext.GetData(AppInfoCenterConfiguration.Const.ContextIdentityKey).ToString();
}
else
{
serverContext.RequestIdentity = Guid.NewGuid().ToString();
}
var clientContext = new ClientApplicationContext();
clientContext.RequestIdentity = serverContext.RequestIdentity;
ClientApplicationContext.Current = clientContext;
var setting = WcfSettingManager.CurrentClientSetting(channelType);
var securitySetting = setting.WcfSecuritySetting;
if (securitySetting.PasswordCheck.Enable)
{
if (securitySetting.PasswordCheck.Direction == OperationDirection.Both || securitySetting.PasswordCheck.Direction == OperationDirection.Request)
{
serverContext.Password = securitySetting.PasswordCheck.Password;
}
}
var logSetting = setting.WcfLogSetting;
if (logSetting.Enabled && logSetting.MessageInfoSetting.Enabled)
{
var direct = logSetting.MessageInfoSetting.MessageDirection;
if (direct == MessageDirection.Both || direct == MessageDirection.Send)
{
var log = WcfLogProvider.GetClientMessageInfo(
channelType.FullName,
ClientApplicationContext.Current.RequestIdentity,
"ClientMessageInspector.BeforeSendRequest",
MessageDirection.Send,
request.ToString());
MongodbService.MongodbInsertService.Insert(log);
}
}
serverContext.ClientMachineIP = CommonConfiguration.MachineIP;
if (!contractVersionCache.ContainsKey(channelType.FullName))
{
lock (locker)
{
if (!contractVersionCache.ContainsKey(channelType.FullName))
{
contractVersionCache.Add(channelType.FullName, channelType.Assembly.GetName().Version.ToString());
}
}
}
serverContext.ClientVersion = contractVersionCache[channelType.FullName];
request.SetApplicationContext(serverContext);
return channelType;
}
catch (Exception ex)
{
ex.Handle(WcfLogProvider.ModuleName, "ClientMessageInspector" , "BeforeSendRequest");
}
return channel.GetType();
}
示例2: BeforeSendRequest
public object BeforeSendRequest(ref Message request, IClientChannel channel)
{
#if DEBUG
var message = request.ToString();
Console.WriteLine("Client send message:" + message);
#endif
try
{
var channelType = channel.GetType();
var serverContext = new ServerApplicationContext();
var clientContext = new ClientApplicationContext();
clientContext.RequestIdentity = serverContext.RequestIdentity;
ClientApplicationContext.Current = clientContext;
var setting = WcfSettingManager.CurrentClientSetting(channelType);
var securitySetting = setting.WcfSecuritySetting;
if (securitySetting.PasswordCheck.Enable)
{
if (securitySetting.PasswordCheck.Direction == OperationDirection.Both || securitySetting.PasswordCheck.Direction == OperationDirection.Request)
{
serverContext.Password = securitySetting.PasswordCheck.Password;
}
}
var logSetting = setting.WcfLogSetting;
if (logSetting.Enabled && logSetting.MessageInfoSetting.Enabled)
{
var direct = logSetting.MessageInfoSetting.MessageDirection;
if (direct == MessageDirection.Both || direct == MessageDirection.Send)
{
var log = WcfLogProvider.GetClientMessageInfo(
channelType.FullName,
ClientApplicationContext.Current.RequestIdentity,
"ClientMessageInspector.BeforeSendRequest",
MessageDirection.Send,
request.ToString());
WcfServiceLocator.GetLogService().LogWithoutException(log);
}
}
serverContext.RequestIdentity = Guid.NewGuid().ToString();
serverContext.ClientMachineName = WcfLogProvider.MachineName;
if (!contractVersionCache.ContainsKey(channelType.FullName))
{
lock (locker)
{
if (!contractVersionCache.ContainsKey(channelType.FullName))
{
contractVersionCache.Add(channelType.FullName, channelType.Assembly.GetName().Version.ToString());
}
}
}
serverContext.ClientVersion = contractVersionCache[channelType.FullName];
request.SetApplicationContext(serverContext);
return channelType;
}
catch (Exception ex)
{
LocalLogService.Log(ex.ToString());
}
return channel.GetType();
}