public void SetInstance(MutableMetricsFactory factory)
 {
     lock (this)
     {
         DefaultMetricsFactory.mmfImpl = factory;
     }
 }
 public T GetInstance <T>()
 {
     System.Type cls = typeof(T);
     lock (this)
     {
         if (cls == typeof(MutableMetricsFactory))
         {
             if (DefaultMetricsFactory.mmfImpl == null)
             {
                 DefaultMetricsFactory.mmfImpl = new MutableMetricsFactory();
             }
             return((T)DefaultMetricsFactory.mmfImpl);
         }
         throw new MetricsException("Unknown metrics factory type: " + cls.FullName);
     }
 }
        internal MetricsSourceBuilder(object source, MutableMetricsFactory factory)
        {
            this.source  = Preconditions.CheckNotNull(source, "source");
            this.factory = Preconditions.CheckNotNull(factory, "mutable metrics factory");
            Type cls = source.GetType();

            registry = InitRegistry(source);
            foreach (FieldInfo field in ReflectionUtils.GetDeclaredFieldsIncludingInherited(cls
                                                                                            ))
            {
                Add(source, field);
            }
            foreach (MethodInfo method in ReflectionUtils.GetDeclaredMethodsIncludingInherited
                         (cls))
            {
                Add(source, method);
            }
        }