Esempio n. 1
0
 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;
 }
Esempio n. 3
0
        public IChannel CreateChannelInstance(string channelName, IChannelDefinition definition)
        {
            var      factory = GetChannelFactory(definition);
            IChannel channel = factory.CreateChannel(definition);

            Channels.TryAdd(channelName, channel);
            return(channel);
        }
Esempio n. 4
0
 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;
 }
Esempio n. 5
0
        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);
        }
Esempio n. 7
0
        public void AddDefinition(IChannelDefinition definition)
        {
            ValidateChannelDefinition(definition);

            Definitions.AddOrUpdate(
                definition.Name,
                definition,
                (x, y) => definition);
        }
Esempio n. 8
0
        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);
        }
Esempio n. 9
0
        /// <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");
        }
Esempio n. 10
0
 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;
 }
Esempio n. 11
0
        public void ValidateChannelDefinition(IChannelDefinition definition)
        {
            var violations = GetDefinitionViolations(definition).ToList();

            if (violations.Count > 0)
            {
                throw new InvalidChannelDefinitionException {
                          Violations = violations
                }
            }
            ;
        }
Esempio n. 12
0
        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);
        }
Esempio n. 13
0
        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;
        }
Esempio n. 14
0
        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;
        }
Esempio n. 15
0
 /// <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));
 }
Esempio n. 16
0
 /// <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);
 }
Esempio n. 17
0
 public IChannel CreateChannel( IChannelDefinition definition )
 {
     var channel = new LocalChannel( Dispatcher, definition as LocalChannelDefinition );
     return channel;
 }
Esempio n. 18
0
        public IChannel CreateChannel(IChannelDefinition definition)
        {
            var channel = new LocalChannel(Dispatcher, definition as LocalChannelDefinition);

            return(channel);
        }
Esempio n. 19
0
 /// <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);
 }
Esempio n. 20
0
 /// <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);
 }
Esempio n. 21
0
 public void ValidateChannelDefinition( IChannelDefinition definition )
 {
     var violations = GetDefinitionViolations( definition ).ToList();
     if ( violations.Count > 0 )
         throw new InvalidChannelDefinitionException {Violations = violations};
 }