コード例 #1
0
ファイル: Providers.cs プロジェクト: dekkerb115/Bam.Net
 /// <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));
     }
 }
コード例 #2
0
ファイル: Providers.cs プロジェクト: dekkerb115/Bam.Net
        /// <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));
        }