示例#1
0
        /// <summary>
        /// Intiailizes a new instance of the <see cref="MessengerChain"/> class by
        /// using the specified chain name and configuration object.
        /// </summary>
        /// <param name="name"></param>
        /// <returns>An instance of the <see cref="MessengerChain"/> class with
        /// name <paramref name="name"/> configured accordingly to the specified
        /// configuration object.</returns>
        /// <remarks>
        /// This method will try to get a chain with name <paramref name="name"/>
        /// from the configuration object and loop through the chain trying to get
        /// messengers with name equals to the name of each chain node.
        /// <para>
        /// If a chain with name <paramref name="name"/> was not found, a empty
        /// chain will be created.
        /// </para>
        /// </remarks>
        public MessengerChain CreateMessengerChain(string name,
                                                   Configuration.Configuration config)
        {
            MessengerChain messenger_chain = new MessengerChain(name);

            ChainNode chain = config.ChainNodes[name];

            if (chain != null)
            {
                string[] nodes = chain.Nodes;
                for (int i = 0, j = nodes.Length; i < j; i++)
                {
                    MessengerProviderNode node = config.MessengerProviderNodes[nodes[i]];
                    if (node != null)
                    {
                        IMessenger messenger = Messenger.CreateInstance(node);
                        messenger_chain.Add(messenger);
                    }
                }
            }
            return(messenger_chain);
        }
示例#2
0
    /// <summary>
    /// Intiailizes a new instance of the <see cref="MessengerChain"/> class by
    /// using the specified chain name and configuration object.
    /// </summary>
    /// <param name="name"></param>
    /// <returns>An instance of the <see cref="MessengerChain"/> class with
    /// name <paramref name="name"/> configured accordingly to the specified
    /// configuration object.</returns>
    /// <remarks>
    /// This method will try to get a chain with name <paramref name="name"/>
    /// from the configuration object and loop through the chain trying to get
    /// messengers with name equals to the name of each chain node.
    /// <para>
    /// If a chain with name <paramref name="name"/> was not found, a empty
    /// chain will be created.
    /// </para>
    /// </remarks>
    public MessengerChain CreateMessengerChain(string name,
      Configuration.Configuration config) {

      MessengerChain messenger_chain = new MessengerChain(name);

      ChainNode chain = config.ChainNodes[name];
      if (chain != null) {
        string[] nodes = chain.Nodes;
        for (int i = 0, j = nodes.Length; i < j; i++) {
          MessengerProviderNode node = config.MessengerProviderNodes[nodes[i]];
          if (node != null) {
            IMessenger messenger = Messenger.CreateInstance(node);
            messenger_chain.Add(messenger);
          }
        }
      }
      return messenger_chain;
    }