Example #1
0
 /// <summary>
 /// Gets a provider of the specified type T for the current session.  If it hasn't been
 /// set yet it will be set to the instance provided.  Once set it can only be set again
 /// if allowOverWrite is true.
 /// </summary>
 /// <typeparam name="T">The type implemented by the object to return.  This can be an interface an abstract
 /// class or any type in the inheritance hierarchy of the stored object.</typeparam>
 /// <param name="setToIfNotFound">The instance to set the session provider to if it has not already been set.</param>
 /// <returns></returns>
 public static T GetSessionProvider <T>(object setToIfNotFound, bool allowOverWrite)
 {
     lock (sessionProviderLock)
     {
         ImplementationProviders providers = GetSessionSingleton <ImplementationProviders>();
         return(providers.GetProvider <T>((T)setToIfNotFound, allowOverWrite));
     }
 }
Example #2
0
 /// <summary>
 /// Sets the session provider of Type T to the specified concrete instance provider.
 /// The generic argument T "should" be an interface so different implementations
 /// can be set and used for testing.
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="provider"></param>
 public static void SetSessionProvider <T>(object provider, bool allowReset)
 {
     lock (sessionProviderLock)
     {
         ImplementationProviders providers = GetSessionSingleton <ImplementationProviders>();
         providers.SetProvider <T>(provider, allowReset);
     }
 }
Example #3
0
        /// <summary>
        /// Get a singleton instance provider of the generic type T.  If not
        /// currently set it will be set to the object provided.  Once set
        /// the application provider of the specified type cannot be set to a different
        /// instance.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="setToIfNotFound"></param>
        /// <returns></returns>
        public static T GetApplicationProvider <T>(object setToIfNotFound)
        {
            ImplementationProviders providers = GetApplicationSingleton <ImplementationProviders>();

            return(providers.GetProvider <T>((T)setToIfNotFound));
        }
Example #4
0
        /// <summary>
        /// Set a singleton instance provider of the generic type T.
        /// Can only be called again if allowOverwrite is true.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="provider"></param>
        /// <param name="allowOverwrite"></param>
        public static void SetApplicationProvider <T>(object provider, bool allowOverwrite)
        {
            ImplementationProviders providers = GetApplicationSingleton <ImplementationProviders>();

            providers.SetProvider <T>(provider, allowOverwrite);
        }