/// <summary> /// Creates a Sink . Implementation of IServerChannelSink method /// Gets invoked by .Net Framework /// </summary> /// <param name="channel"></param> /// <returns></returns> public IServerChannelSink CreateSink(IChannelReceiver channel) { BaseCustomSink customSinkObject = null; bool keepCreatingInstance = false; // try to instantiate the custom sink // with a constructor that takes ServerSinkCreationData (or SinkCreationData) object[] par = { new ServerSinkData(this.data, channel) }; try { customSinkObject = (BaseCustomSink)Activator.CreateInstance(this.customSinkType, par); } catch (MissingMethodException) { // do nothing - try to create using a parameterless constructor keepCreatingInstance = true; } catch (Exception e) { ExamineConstructionException(e); } // if there is no constructor that takes ServerSinkCreationData or SinkCreationData, // look for a parameterless constructor if (keepCreatingInstance) { try { customSinkObject = (BaseCustomSink)Activator.CreateInstance(this.customSinkType); } catch (Exception e) { ExamineConstructionException(e); } } // create next sink in the chain IServerChannelSink next = this.Next.CreateSink(channel); if (customSinkObject != null) { customSinkObject.SetNextSink(next); return(customSinkObject); } else { return(next); } }
public IClientChannelSink CreateSink(IChannelSender channel, string url, object remoteChannelData) { BaseCustomSink customSinkObject = null; bool keepCreatingInstance = false; IClientChannelSink next = this.nextProvider.CreateSink(channel, url, remoteChannelData); object[] par = { new ClientSinkData(this.data, channel, url, remoteChannelData) }; try { customSinkObject = (BaseCustomSink)Activator.CreateInstance(this.customSinkType, par); } catch (MissingMethodException) { // do nothing - try to create using a parameterless constructor keepCreatingInstance = true; } catch (Exception e) { ExamineConstructionException(e); } if (keepCreatingInstance) { try { customSinkObject = (BaseCustomSink)Activator.CreateInstance(this.customSinkType); } catch (Exception e) { ExamineConstructionException(e); } } if (customSinkObject != null) { customSinkObject.SetNextSink(next); return(customSinkObject); } else { return(next); } }