コード例 #1
0
        /// <summary>
        /// Provide a tool or information from the chained environments.
        /// </summary>
        /// <param name="name">
        /// An identifier for the needed object.
        /// </param>
        /// <typeparam name="TObject">Type of the required tool or information.</typeparam>
        /// <returns>
        /// The <typeparamref name="TObject"> returned from the first chain link that knows it.
        /// </returns>
        public override TObject Get <TObject> (InstanceName <TObject> name)
        {
            int lenght = _environments.Length;

            for (int i = 0; i < lenght; ++i)
            {
                EnvironmentChainLinkBase environment = _environments[i];
                TObject result;
                if (environment.TryGet <TObject>(name, out result))
                {
                    return(result);
                }
            }
            string message = string.Format("Can not find any {0} named {1} in the environment.", typeof(TObject).FullName, name);

            throw new KeyNotFoundException(message);
        }
コード例 #2
0
 public EnvironmentsChain CreateNewEnvironmentChainToTest(out EnvironmentChainLinkBase firstMockLink, out EnvironmentChainLinkBase secondMockLink)
 {
     firstMockLink  = MockRepository.GeneratePartialMock <EnvironmentChainLinkBase>();
     secondMockLink = MockRepository.GeneratePartialMock <EnvironmentChainLinkBase>();
     return(new EnvironmentsChain(firstMockLink, secondMockLink));
 }