Exemplo n.º 1
0
        /// <summary>
        /// Gets the IFunctionalService witht he given name, checking to make sure that the name makes sense first.
        /// </summary>
        /// <param name="serviceName">The name of the service to find.</param>
        /// <returns>An IFunctionalService instance if found, otherwise an exception is thrown.</returns>
        protected virtual IFunctionalService getService(string serviceName)
        {
            if (!serviceName.ToLower().EndsWith("s"))
            {
                throw new InvalidOperationException("Found a functional service to support messages to " + serviceName + ", but its name isn't a plural (doesn't end in 's'). This will not work in the current framework.");
            }

            IService service = FunctionalServiceProviderFactory.GetInstance().GetProvider(serviceName);

            if (service == null)
            {
                throw new InvalidOperationException("No functional service found to support messages to " + serviceName);
            }

            if (!ProviderUtils.isFunctionalService(service.GetType()))
            {
                throw new InvalidOperationException("Service (" + service.GetType().Name + ") found for " + serviceName + " is not a functional service implementation");
            }

            return(service as IFunctionalService);
        }
Exemplo n.º 2
0
 /// <summary>
 /// Creates and configures the factory singleton instance.
 /// </summary>
 /// <returns>The factory singleton</returns>
 public static FunctionalServiceProviderFactory CreateFactory()
 {
     lock (locked)
     {
         log.Debug("Total Threads running before initialising provider Factory: " + Process.GetCurrentProcess().Threads.Count + " threads.");
         if (factory == null)
         {
             try
             {
                 factory = new FunctionalServiceProviderFactory();
             }
             catch (Exception ex)
             {
                 log.Error("Failed to initialise provider factory. Provider won't run.", ex);
                 factory = null;
             }
         }
         log.Debug("Total Threads running after initialising Provider Factory: " + Process.GetCurrentProcess().Threads.Count + " threads.");
         return(factory);
     }
 }