Self registered Classes without instance creation
<p>In my Application a have a set of Data Providers and Redis Cache. 
Each execution different providers are used, but they all store own Data in Redis:</p>

<pre><code>hset ProviderOne Data "..."
hset ProviderTwo Data "..."
</code></pre>

<p>I would like have one method That will delete Data for all providers that are present in code.</p>

<pre><code>del ProviderOne
del ProviderTwo
</code></pre>

<p>I have made next code:</p>

<pre><code>   void Main()
   {
       // Both providers have static field Hash with default value.
       // I expected that static fields should be initialized when application starts,
       // then initialization will call CacheRepository.Register&lt;T&gt;() method
       // and all classes will register them self in CacheRepository.RegisteredHashes.

       // But code start working only when i created this classes (at least once)
       // new ProviderOne();
       // new ProviderTwo();

       CacheRepository.Reset();
   }

   public abstract class AbstractProvider
   {
      //...
   }

   public class ProviderOne : AbstractProvider
   {
       public static readonly string Hash = 
          CacheRepository.Register&lt;ProviderOne&gt;();

       //...
   }

   public class ProviderTwo : AbstractProvider
   {
       public static readonly string Hash = 
          CacheRepository.Register&lt;ProviderTwo&gt;();

       //...
   }

   public class CacheRepository
    {
        protected static Lazy&lt;CacheRepository&gt; LazyInstance = new Lazy&lt;CacheRepository&gt;();

        public static CacheRepository Instance
        {
            get { return LazyInstance.Value; }
        }

        public ConcurrentBag&lt;string&gt; RegisteredHashes = new ConcurrentBag&lt;string&gt;();

        public static string Register&lt;T&gt;()
        {
            string hash = typeof(T).Name;

            if (!Instance.RegisteredHashes.Contains(hash))
            {
                Instance.RegisteredHashes.Add(hash);
            }

            return hash;
        }

        public static void Reset()
        {
            foreach (string registeredHash in Instance.RegisteredHashes)
            {
                Instance.Reset(registeredHash);
            }
        }

        protected void Reset(string hash);
    }



    interface IData{}

    interface IDataProvider
    {
       string GetRedisHash();
       IData GetData();
    }

    intefrace IRedisRepository
    {

    }
</code></pre>

<p>How make it working?</p>
