public IChannel CreateChannelInstance( string channelName, IChannelDefinition definition ) { var factory = GetChannelFactory( definition ); IChannel channel = factory.CreateChannel( definition ); Channels.TryAdd( channelName, channel ); return channel; }
public IChannel CreateChannel( IChannelDefinition definition ) { var namedPipeChannelDefinition = definition as NamedPipeChannelDefinition; var serializer = Assimilate.GetInstanceOf( definition.SerializerType ) as IMessageSerializer; var proxy = new PipeProxy( namedPipeChannelDefinition, Dispatcher, serializer ); var namedPipeChannel = new NamedPipeChannel( namedPipeChannelDefinition, proxy, Dispatcher ); return namedPipeChannel; }
public IChannel CreateChannelInstance(string channelName, IChannelDefinition definition) { var factory = GetChannelFactory(definition); IChannel channel = factory.CreateChannel(definition); Channels.TryAdd(channelName, channel); return(channel); }
public IChannel CreateChannel( IChannelDefinition definition ) { var rabbitDef = definition as ChannelDefinition; var proxy = ProxyFactory.GetProxyForExchange( rabbitDef ); var serializer = Activator.CreateInstance( definition.SerializerType ) as IMessageSerializer; var channel = new RabbitChannel( proxy, serializer, rabbitDef, MessageDispatcher ) as IChannel; return channel; }
public void AddDefinition( IChannelDefinition definition ) { ValidateChannelDefinition( definition ); Definitions.AddOrUpdate( definition.Name, definition, ( x, y ) => definition ); }
public IChannel CreateChannel(IChannelDefinition definition) { var namedPipeChannelDefinition = definition as NamedPipeChannelDefinition; var serializer = Assimilate.GetInstanceOf(definition.SerializerType) as IMessageSerializer; var proxy = new PipeProxy(namedPipeChannelDefinition, Dispatcher, serializer); var namedPipeChannel = new NamedPipeChannel(namedPipeChannelDefinition, proxy, Dispatcher); return(namedPipeChannel); }
public void AddDefinition(IChannelDefinition definition) { ValidateChannelDefinition(definition); Definitions.AddOrUpdate( definition.Name, definition, (x, y) => definition); }
public IChannel CreateChannel(IChannelDefinition definition) { var rabbitDef = definition as ChannelDefinition; var proxy = ProxyFactory.GetProxyForExchange(rabbitDef); var serializer = Activator.CreateInstance(definition.SerializerType) as IMessageSerializer; var channel = new RabbitChannel(proxy, serializer, rabbitDef, MessageDispatcher) as IChannel; return(channel); }
/// <summary> /// Compares this instance to a specified object and returns an indication of their relative values. /// </summary> /// <param name="obj">An object to compare, or null.</param> /// <returns> /// A signed number indicating the relative values of this instance and value. Returns less than zero /// if this instance is less than value, zero if this instance is equal to value, or greater than zero /// if this instance is greater than value. /// </returns> /// <exception cref="ArgumentException">value is not an <see cref="IChannelDefinition"/>.</exception> public virtual int CompareTo(object obj) { IChannelDefinition other = obj as IChannelDefinition; if (other != null) { return(CompareTo(other)); } throw new ArgumentException("ChannelDefinition can only be compared to other IChannelDefinitions"); }
public IChannelFactory GetChannelFactory( IChannelDefinition definition ) { IChannelFactory factory; if ( !ChannelFactories.TryGetValue( definition.ChannelType, out factory ) ) { factory = Assimilate.GetInstanceOf( definition.FactoryType ) as IChannelFactory; ChannelFactories.TryAdd( definition.FactoryType, factory ); } return factory; }
public void ValidateChannelDefinition(IChannelDefinition definition) { var violations = GetDefinitionViolations(definition).ToList(); if (violations.Count > 0) { throw new InvalidChannelDefinitionException { Violations = violations } } ; }
public IChannelFactory GetChannelFactory(IChannelDefinition definition) { IChannelFactory factory; if (!ChannelFactories.TryGetValue(definition.ChannelType, out factory)) { factory = Assimilate.GetInstanceOf(definition.FactoryType) as IChannelFactory; ChannelFactories.TryAdd(definition.FactoryType, factory); } return(factory); }
public IEnumerable<string> GetDefinitionViolations( IChannelDefinition definition ) { if ( definition.FactoryType == null ) yield return "Channel definition must specify a channel factory type"; if ( definition.ChannelType == null ) yield return "Channel definition must specify a channel type"; if ( string.IsNullOrWhiteSpace( definition.Name ) ) yield return "Channel definition must specify a channel name"; yield break; }
public IEnumerable <string> GetDefinitionViolations(IChannelDefinition definition) { if (definition.FactoryType == null) { yield return("Channel definition must specify a channel factory type"); } if (definition.ChannelType == null) { yield return("Channel definition must specify a channel type"); } if (string.IsNullOrWhiteSpace(definition.Name)) { yield return("Channel definition must specify a channel name"); } yield break; }
/// <summary> /// Compares this instance to a specified <see cref="IChannelDefinition"/> object and returns an indication of their /// relative values. /// </summary> /// <param name="other">A <see cref="IChannelDefinition"/> object to compare.</param> /// <returns> /// A signed number indicating the relative values of this instance and value. Returns less than zero /// if this instance is less than value, zero if this instance is equal to value, or greater than zero /// if this instance is greater than value. /// </returns> public int CompareTo(IChannelDefinition other) { // We sort channel Definitions by index return(m_index.CompareTo(other.Index)); }
/// <summary> /// Returns a value indicating whether this instance is equal to specified <see cref="IChannelDefinition"/> value. /// </summary> /// <param name="other">A <see cref="IChannelDefinition"/> object to compare to this instance.</param> /// <returns> /// True if <paramref name="other"/> has the same value as this instance; otherwise, False. /// </returns> public bool Equals(IChannelDefinition other) { return(CompareTo(other) == 0); }
public IChannel CreateChannel( IChannelDefinition definition ) { var channel = new LocalChannel( Dispatcher, definition as LocalChannelDefinition ); return channel; }
public IChannel CreateChannel(IChannelDefinition definition) { var channel = new LocalChannel(Dispatcher, definition as LocalChannelDefinition); return(channel); }
/// <summary> /// Compares this instance to a specified <see cref="IChannelDefinition"/> object and returns an indication of their /// relative values. /// </summary> /// <param name="other">A <see cref="IChannelDefinition"/> object to compare.</param> /// <returns> /// A signed number indicating the relative values of this instance and value. Returns less than zero /// if this instance is less than value, zero if this instance is equal to value, or greater than zero /// if this instance is greater than value. /// </returns> public int CompareTo(IChannelDefinition other) { // We sort channel Definitions by index return m_index.CompareTo(other.Index); }
/// <summary> /// Returns a value indicating whether this instance is equal to specified <see cref="IChannelDefinition"/> value. /// </summary> /// <param name="other">A <see cref="IChannelDefinition"/> object to compare to this instance.</param> /// <returns> /// True if <paramref name="other"/> has the same value as this instance; otherwise, False. /// </returns> public bool Equals(IChannelDefinition other) { return (CompareTo(other) == 0); }
public void ValidateChannelDefinition( IChannelDefinition definition ) { var violations = GetDefinitionViolations( definition ).ToList(); if ( violations.Count > 0 ) throw new InvalidChannelDefinitionException {Violations = violations}; }