Ejemplo n.º 1
0
		/// <summary>
		/// Disconnects this link from the WCF service, freeing all the server resources it might have been used. If it was
		/// not connected, this method merely returns.
		/// </summary>
		public virtual void ProxyDisconnect()
		{
			DEBUG.IndentLine( "\n-- [{0}] KLinkWCF.ProxyDisconnect()", _ProxyId.TagString() );

			if( _Proxy != null ) {
				_Proxy.ProxyDisconnect();
				_Proxy.Dispose();
				_Proxy = null;
				_ProxyId = Guid.Empty;

				_Package = null;
				_EndPoint = null;
				_DbCaseSensitiveNames = null;
			}

			DEBUG.Unindent();
		}
Ejemplo n.º 2
0
		/// <summary>
		/// Connects this link object with the WCF service. If it has been already connected, an exceptio will be thrown.
		/// </summary>
		/// <param name="endpoint">The endpoint to use to locate the WCF service.</param>
		/// <param name="package">The connection package to use by the service to modulate how it will connect with the real
		/// underlying database, if needed, or null if it is not needed.</param>
		public virtual void ProxyConnect( string endpoint, DeepObject package )
		{
			DEBUG.IndentLine( "\n-- KLinkWCF.ProxyConnect( EndPoint={0}, Package={1}", endpoint ?? "<null>", package == null ? "<null>" : package.ToString() );

			if( _Proxy != null ) throw new InvalidOperationException( "This link is already connected." );
			_EndPoint = endpoint.Validated( "EndPoint" );
			_Package = package;

			var channelFactory = new ChannelFactory<IKProxyWCF>( _EndPoint );
			_Proxy = channelFactory.CreateChannel();
			_ProxyId = _Proxy.ProxyConnect( _Package );

			DEBUG.WriteLine( "\n-- Connected with UID = {0}", _ProxyId.TagString() );
			DEBUG.Unindent();
		}