/// <summary>
        /// Copy constructor.
        /// </summary>
        protected CounterSetRegistrarBase(
            CounterSetRegistrarBase srcCounterSetRegistrarBase)
        {
            if (srcCounterSetRegistrarBase == null)
            {
                throw new ArgumentNullException("srcCounterSetRegistrarBase");
            }

            ProviderId         = srcCounterSetRegistrarBase.ProviderId;
            CounterSetId       = srcCounterSetRegistrarBase.CounterSetId;
            CounterSetInstType = srcCounterSetRegistrarBase.CounterSetInstType;
            CounterSetName     = srcCounterSetRegistrarBase.CounterSetName;

            CounterInfo[] counterInfoArrayRef = srcCounterSetRegistrarBase.CounterInfoArray;
            CounterInfoArray = new CounterInfo[counterInfoArrayRef.Length];

            for (int i = 0; i < counterInfoArrayRef.Length; i++)
            {
                CounterInfoArray[i] =
                    new CounterInfo(
                        counterInfoArrayRef[i].Id,
                        counterInfoArrayRef[i].Type,
                        counterInfoArrayRef[i].Name);
            }
        }
예제 #2
0
        /// <summary>
        /// Method to register a counter set with the Performance Counters Manager.
        /// </summary>
        public bool AddCounterSetInstance(CounterSetRegistrarBase counterSetRegistrarInstance)
        {
            if (counterSetRegistrarInstance == null)
            {
                ArgumentNullException argNullException = new ArgumentNullException("counterSetRegistrarInstance");
                _tracer.TraceException(argNullException);
                return(false);
            }

            Guid   counterSetId   = counterSetRegistrarInstance.CounterSetId;
            string counterSetName = counterSetRegistrarInstance.CounterSetName;
            CounterSetInstanceBase counterSetInst = null;

            if (this.IsCounterSetRegistered(counterSetId, out counterSetInst))
            {
                InvalidOperationException invalidOperationException = new InvalidOperationException(
                    string.Format(
                        CultureInfo.InvariantCulture,
                        "A Counter Set Instance with id '{0}' is already registered",
                        counterSetId));
                _tracer.TraceException(invalidOperationException);
                return(false);
            }

            try
            {
                if (!string.IsNullOrWhiteSpace(counterSetName))
                {
                    Guid retrievedCounterSetId;
                    // verify that there doesn't exist another counter set with the same name
                    if (this.IsCounterSetRegistered(counterSetName, out retrievedCounterSetId))
                    {
                        InvalidOperationException invalidOperationException =
                            new InvalidOperationException(
                                string.Format(
                                    CultureInfo.InvariantCulture,
                                    "A Counter Set Instance with name '{0}' is already registered",
                                    counterSetName));
                        _tracer.TraceException(invalidOperationException);
                        return(false);
                    }

                    _CounterSetNameToIdMapping.TryAdd(counterSetName, counterSetId);
                }

                _CounterSetIdToInstanceMapping.TryAdd(
                    counterSetId,
                    counterSetRegistrarInstance.CounterSetInstance);
            }
            catch (OverflowException overflowException)
            {
                _tracer.TraceException(overflowException);
                return(false);
            }

            return(true);
        }
예제 #3
0
 protected CounterSetInstanceBase(CounterSetRegistrarBase counterSetRegistrarInst)
 {
     this._counterSetRegistrarBase = counterSetRegistrarInst;
     this._counterNameToIdMapping = new ConcurrentDictionary<string, int>();
     this._counterIdToTypeMapping = new ConcurrentDictionary<int, CounterType>();
     CounterInfo[] counterInfoArray = this._counterSetRegistrarBase.CounterInfoArray;
     for (int i = 0; i < counterInfoArray.Length; i++)
     {
         this._counterIdToTypeMapping.TryAdd(counterInfoArray[i].Id, counterInfoArray[i].Type);
         if (!string.IsNullOrWhiteSpace(counterInfoArray[i].Name))
         {
             this._counterNameToIdMapping.TryAdd(counterInfoArray[i].Name, counterInfoArray[i].Id);
         }
     }
 }
예제 #4
0
 protected CounterSetInstanceBase(CounterSetRegistrarBase counterSetRegistrarInst)
 {
     this._counterSetRegistrarBase = counterSetRegistrarInst;
     this._counterNameToIdMapping  = new ConcurrentDictionary <string, int>();
     this._counterIdToTypeMapping  = new ConcurrentDictionary <int, CounterType>();
     CounterInfo[] counterInfoArray = this._counterSetRegistrarBase.CounterInfoArray;
     for (int i = 0; i < counterInfoArray.Length; i++)
     {
         this._counterIdToTypeMapping.TryAdd(counterInfoArray[i].Id, counterInfoArray[i].Type);
         if (!string.IsNullOrWhiteSpace(counterInfoArray[i].Name))
         {
             this._counterNameToIdMapping.TryAdd(counterInfoArray[i].Name, counterInfoArray[i].Id);
         }
     }
 }
예제 #5
0
 protected CounterSetRegistrarBase(CounterSetRegistrarBase srcCounterSetRegistrarBase)
 {
     if (srcCounterSetRegistrarBase == null)
     {
         throw new ArgumentNullException("srcCounterSetRegistrarBase");
     }
     this._providerId             = srcCounterSetRegistrarBase._providerId;
     this._counterSetId           = srcCounterSetRegistrarBase._counterSetId;
     this._counterSetInstanceType = srcCounterSetRegistrarBase._counterSetInstanceType;
     this._counterSetName         = srcCounterSetRegistrarBase._counterSetName;
     CounterInfo[] infoArray = srcCounterSetRegistrarBase._counterInfoArray;
     this._counterInfoArray = new CounterInfo[infoArray.Length];
     for (int i = 0; i < infoArray.Length; i++)
     {
         this._counterInfoArray[i] = new CounterInfo(infoArray[i].Id, infoArray[i].Type, infoArray[i].Name);
     }
 }
예제 #6
0
 protected CounterSetRegistrarBase(CounterSetRegistrarBase srcCounterSetRegistrarBase)
 {
     if (srcCounterSetRegistrarBase == null)
     {
         throw new ArgumentNullException("srcCounterSetRegistrarBase");
     }
     this._providerId = srcCounterSetRegistrarBase._providerId;
     this._counterSetId = srcCounterSetRegistrarBase._counterSetId;
     this._counterSetInstanceType = srcCounterSetRegistrarBase._counterSetInstanceType;
     this._counterSetName = srcCounterSetRegistrarBase._counterSetName;
     CounterInfo[] infoArray = srcCounterSetRegistrarBase._counterInfoArray;
     this._counterInfoArray = new CounterInfo[infoArray.Length];
     for (int i = 0; i < infoArray.Length; i++)
     {
         this._counterInfoArray[i] = new CounterInfo(infoArray[i].Id, infoArray[i].Type, infoArray[i].Name);
     }
 }
예제 #7
0
        public bool AddCounterSetInstance(CounterSetRegistrarBase counterSetRegistrarInstance)
        {
            if (counterSetRegistrarInstance == null)
            {
                ArgumentNullException exception = new ArgumentNullException("counterSetRegistrarInstance");
                this._tracer.TraceException(exception);
                return(false);
            }
            Guid   counterSetId   = counterSetRegistrarInstance.CounterSetId;
            string counterSetName = counterSetRegistrarInstance.CounterSetName;
            CounterSetInstanceBase counterSetInst = null;

            if (this.IsCounterSetRegistered(counterSetId, out counterSetInst))
            {
                InvalidOperationException exception2 = new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, "A Counter Set Instance with id '{0}' is already registered", new object[] { counterSetId }));
                this._tracer.TraceException(exception2);
                return(false);
            }
            try
            {
                if (!string.IsNullOrWhiteSpace(counterSetName))
                {
                    Guid guid2;
                    if (this.IsCounterSetRegistered(counterSetName, out guid2))
                    {
                        InvalidOperationException exception3 = new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, "A Counter Set Instance with name '{0}' is already registered", new object[] { counterSetName }));
                        this._tracer.TraceException(exception3);
                        return(false);
                    }
                    this._CounterSetNameToIdMapping.TryAdd(counterSetName, counterSetId);
                }
                this._CounterSetIdToInstanceMapping.TryAdd(counterSetId, counterSetRegistrarInstance.CounterSetInstance);
            }
            catch (OverflowException exception4)
            {
                this._tracer.TraceException(exception4);
                return(false);
            }
            return(true);
        }
예제 #8
0
 public bool AddCounterSetInstance(CounterSetRegistrarBase counterSetRegistrarInstance)
 {
     if (counterSetRegistrarInstance == null)
     {
         ArgumentNullException exception = new ArgumentNullException("counterSetRegistrarInstance");
         this._tracer.TraceException(exception);
         return false;
     }
     Guid counterSetId = counterSetRegistrarInstance.CounterSetId;
     string counterSetName = counterSetRegistrarInstance.CounterSetName;
     CounterSetInstanceBase counterSetInst = null;
     if (this.IsCounterSetRegistered(counterSetId, out counterSetInst))
     {
         InvalidOperationException exception2 = new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, "A Counter Set Instance with id '{0}' is already registered", new object[] { counterSetId }));
         this._tracer.TraceException(exception2);
         return false;
     }
     try
     {
         if (!string.IsNullOrWhiteSpace(counterSetName))
         {
             Guid guid2;
             if (this.IsCounterSetRegistered(counterSetName, out guid2))
             {
                 InvalidOperationException exception3 = new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, "A Counter Set Instance with name '{0}' is already registered", new object[] { counterSetName }));
                 this._tracer.TraceException(exception3);
                 return false;
             }
             this._CounterSetNameToIdMapping.TryAdd(counterSetName, counterSetId);
         }
         this._CounterSetIdToInstanceMapping.TryAdd(counterSetId, counterSetRegistrarInstance.CounterSetInstance);
     }
     catch (OverflowException exception4)
     {
         this._tracer.TraceException(exception4);
         return false;
     }
     return true;
 }
 /// <summary>
 /// Constructor for creating an instance of PSCounterSetInstance.
 /// </summary>
 public PSCounterSetInstance(CounterSetRegistrarBase counterSetRegBaseObj)
     : base(counterSetRegBaseObj)
 {
     CreateCounterSetInstance();
 }
예제 #10
0
        /// <summary>
        /// Copy constructor
        /// </summary>
        protected CounterSetRegistrarBase(
            CounterSetRegistrarBase srcCounterSetRegistrarBase)
        {
            if (srcCounterSetRegistrarBase == null)
            {
                throw new ArgumentNullException("srcCounterSetRegistrarBase");
            }
            ProviderId = srcCounterSetRegistrarBase.ProviderId;
            CounterSetId = srcCounterSetRegistrarBase.CounterSetId;
            CounterSetInstType = srcCounterSetRegistrarBase.CounterSetInstType;
            CounterSetName = srcCounterSetRegistrarBase.CounterSetName;

            CounterInfo[] counterInfoArrayRef = srcCounterSetRegistrarBase.CounterInfoArray;
            CounterInfoArray = new CounterInfo[counterInfoArrayRef.Length];

            for (int i = 0; i < counterInfoArrayRef.Length; i++)
            {
                CounterInfoArray[i] =
                    new CounterInfo(
                        counterInfoArrayRef[i].Id,
                        counterInfoArrayRef[i].Type,
                        counterInfoArrayRef[i].Name);
            }
        }
예제 #11
0
 /// <summary>
 /// Constructor for creating an instance of PSCounterSetInstance
 /// </summary>
 public PSCounterSetInstance(CounterSetRegistrarBase counterSetRegBaseObj)
     : base(counterSetRegBaseObj)
 {
     CreateCounterSetInstance();
 }
예제 #12
0
        /// <summary>
        /// Method to register a counter set with the Performance Counters Manager.
        /// </summary>
        public bool AddCounterSetInstance(CounterSetRegistrarBase counterSetRegistrarInstance)
        {
            if (counterSetRegistrarInstance == null)
            {
                ArgumentNullException argNullException = new ArgumentNullException("counterSetRegistrarInstance");
                _tracer.TraceException(argNullException);
                return false;
            }

            Guid counterSetId = counterSetRegistrarInstance.CounterSetId;
            string counterSetName = counterSetRegistrarInstance.CounterSetName;
            CounterSetInstanceBase counterSetInst = null;

            if (this.IsCounterSetRegistered(counterSetId, out counterSetInst))
            {
                InvalidOperationException invalidOperationException = new InvalidOperationException(
                    String.Format(
                    CultureInfo.InvariantCulture,
                    "A Counter Set Instance with id '{0}' is already registered",
                    counterSetId));
                _tracer.TraceException(invalidOperationException);
                return false;
            }

            try
            {
                if (!string.IsNullOrWhiteSpace(counterSetName))
                {
                    Guid retrievedCounterSetId;
                    // verify that there doesn't exist another counter set with the same name
                    if (this.IsCounterSetRegistered(counterSetName, out retrievedCounterSetId))
                    {
                        InvalidOperationException invalidOperationException =
                            new InvalidOperationException(
                                String.Format(
                                CultureInfo.InvariantCulture,
                                "A Counter Set Instance with name '{0}' is already registered",
                                counterSetName));
                        _tracer.TraceException(invalidOperationException);
                        return false;
                    }
                    _CounterSetNameToIdMapping.TryAdd(counterSetName, counterSetId);
                }
                _CounterSetIdToInstanceMapping.TryAdd(
                    counterSetId,
                    counterSetRegistrarInstance.CounterSetInstance);
            }
            catch (OverflowException overflowException)
            {
                _tracer.TraceException(overflowException);
                return false;
            }
            return true;
        }
예제 #13
0
 public PSCounterSetInstance(CounterSetRegistrarBase counterSetRegBaseObj) : base(counterSetRegBaseObj)
 {
     this._tracer = PowerShellTraceSourceFactory.GetTraceSource();
     this.CreateCounterSetInstance();
 }
예제 #14
0
 public PSCounterSetInstance(CounterSetRegistrarBase counterSetRegBaseObj) : base(counterSetRegBaseObj)
 {
     this._tracer = PowerShellTraceSourceFactory.GetTraceSource();
     this.CreateCounterSetInstance();
 }