private WCFStandardsClient GetLocalWebClient() { WCFStandardsClient LocalWebClient = new WCFStandardsClient(WSBinding, WSEndPoint); LocalWebClient.ChannelFactory.Endpoint.Behaviors.Add (new HeaderInsertClientMessageInspector ()); LocalWebClient.ChannelFactory.Opened += new EventHandler (ChannelFactory_Opened); if (WMB.WPMediaApplicationState.Instance.Properties.ContainsKey ("UserName") ) LocalWebClient.ChannelFactory.Credentials.UserName.UserName = WMB.WPMediaApplicationState.Instance.Properties ["UserName"].ToString (); else { WMB.WPMediaApplicationState.Instance.Properties ["UserName"] = LoginHandler.DefaultUsedUserName; LocalWebClient.ChannelFactory.Credentials.UserName.UserName = WMB.WPMediaApplicationState.Instance.Properties["UserName"].ToString(); } if (String.IsNullOrEmpty (Thread.CurrentPrincipal.Identity.Name)) { GenericIdentity Ident = new GenericIdentity (WMB.WPMediaApplicationState.Instance.Properties["UserName"].ToString()); Thread.CurrentPrincipal = new GenericPrincipal(Ident, new string[0]); } LocalWebClient.InnerChannel.Faulted += new EventHandler (InnerChannel_Faulted); LocalWebClient.InnerChannel.Opened += new EventHandler (InnerChannel_Opened); IContextChannel ICC = LocalWebClient.InnerChannel as IContextChannel; m_OPC = new OperationContext (ICC); LocalWebClient.InnerChannel.OperationTimeout = TimeSpan.FromSeconds (60); return LocalWebClient; }
private void CloseLocalWebClient (WCFStandardsClient LocalWebClient) { if (LocalWebClient != null) LocalWebClient.Close (); }
private WCFStandardsClient GetLocalWebClient () { WCFStandardsClient LocalWebClient = new WCFStandardsClient (WSBinding, WSEndPoint); LocalWebClient.ChannelFactory.Endpoint.Behaviors.Add (new HeaderInsertClientMessageInspector ()); LocalWebClient.ChannelFactory.Opened += new EventHandler (ChannelFactory_Opened); if (WMB.WPMediaApplicationState.Instance.Properties.ContainsKey ("UserName") ) LocalWebClient.ChannelFactory.Credentials.UserName.UserName = WMB.WPMediaApplicationState.Instance.Properties ["UserName"].ToString (); LocalWebClient.InnerChannel.Faulted += new EventHandler (InnerChannel_Faulted); LocalWebClient.InnerChannel.Opened += new EventHandler (InnerChannel_Opened); IContextChannel ICC = LocalWebClient.InnerChannel as IContextChannel; m_OPC = new OperationContext (ICC); LocalWebClient.InnerChannel.OperationTimeout = TimeSpan.FromSeconds (60); return LocalWebClient; }