private void AttachToProvider()
 {
     if (provider != null)
     {
         if (provider.GetValueProviderName() == baseValueName)
         {
             return;
         }
         provider.DetachConsumer(this);
         provider = null;
     }
     if (!(baseValueName == string.Empty) && IsConnectedInCollecton())
     {
         provider = LocateProviderByName(baseValueName);
         if (provider == null)
         {
             throw new ArgumentException(Utils.SRGetStr("ExceptioncalCulatedValueProvider", baseValueName));
         }
         provider.AttachConsumer(this);
         SetValueInternal(provider.GetValue(), provider.GetDate());
         ((IValueConsumer)this).Refresh();
     }
 }
        private void AttachToProvider(bool exact)
        {
            Hashtable hashtable = CollectValues();

            if (provider != null)
            {
                if (hashtable.ContainsKey(valueSource) && hashtable[valueSource] == provider)
                {
                    return;
                }
                provider.DetachConsumer(this);
                provider = null;
            }
            if (Common == null || Common.GaugeCore.isInitializing)
            {
                return;
            }
            if (valueSource == string.Empty)
            {
                SetValue(Value, initialize: true);
                return;
            }
            if (hashtable.ContainsKey(ValueSource))
            {
                provider = (IValueProvider)hashtable[ValueSource];
                provider.AttachConsumer(this);
            }
            else if (exact)
            {
                throw new ArgumentException(Utils.SRGetStr("ExceptionLocateCProviderFailed", valueSource));
            }
            if (provider != null)
            {
                SetValue(provider.GetValue(), initialize: true);
            }
        }