/// <summary>
 /// Convert the PerformanceCounterType to the Wix type.
 /// </summary>
 /// <param name="performanceCounterType">Type to convert.</param>
 /// <returns>The wix performance counter type.</returns>
 private static Util.PerformanceCounterTypesType CounterTypeToWix(PerformanceCounterType performanceCounterType)
 {
     try
     {
         return(PerformanceCounterTypes.Single(e => string.Equals(e.ToString(), performanceCounterType.ToString(), StringComparison.OrdinalIgnoreCase)));
     }
     catch (Exception)
     {
         throw new WixException(UtilErrors.UnsupportedPerformanceCounterType(performanceCounterType.ToString()));
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Get the WiX performance counter type.
        /// </summary>
        /// <param name="pct">The performance counter value to get.</param>
        /// <returns>The WiX performance counter type.</returns>
        private Util.PerformanceCounterTypesType CounterTypeToWix(PerformanceCounterType pct)
        {
            Util.PerformanceCounterTypesType type;

            switch (pct)
            {
            case PerformanceCounterType.AverageBase:
                type = Util.PerformanceCounterTypesType.averageBase;
                break;

            case PerformanceCounterType.AverageCount64:
                type = Util.PerformanceCounterTypesType.averageCount64;
                break;

            case PerformanceCounterType.AverageTimer32:
                type = Util.PerformanceCounterTypesType.averageTimer32;
                break;

            case PerformanceCounterType.CounterDelta32:
                type = Util.PerformanceCounterTypesType.counterDelta32;
                break;

            case PerformanceCounterType.CounterTimerInverse:
                type = Util.PerformanceCounterTypesType.counterTimerInverse;
                break;

            case PerformanceCounterType.SampleFraction:
                type = Util.PerformanceCounterTypesType.sampleFraction;
                break;

            case PerformanceCounterType.Timer100Ns:
                type = Util.PerformanceCounterTypesType.timer100Ns;
                break;

            case PerformanceCounterType.CounterTimer:
                type = Util.PerformanceCounterTypesType.counterTimer;
                break;

            case PerformanceCounterType.RawFraction:
                type = Util.PerformanceCounterTypesType.rawFraction;
                break;

            case PerformanceCounterType.Timer100NsInverse:
                type = Util.PerformanceCounterTypesType.timer100NsInverse;
                break;

            case PerformanceCounterType.CounterMultiTimer:
                type = Util.PerformanceCounterTypesType.counterMultiTimer;
                break;

            case PerformanceCounterType.CounterMultiTimer100Ns:
                type = Util.PerformanceCounterTypesType.counterMultiTimer100Ns;
                break;

            case PerformanceCounterType.CounterMultiTimerInverse:
                type = Util.PerformanceCounterTypesType.counterMultiTimerInverse;
                break;

            case PerformanceCounterType.CounterMultiTimer100NsInverse:
                type = Util.PerformanceCounterTypesType.counterMultiTimer100NsInverse;
                break;

            case PerformanceCounterType.ElapsedTime:
                type = Util.PerformanceCounterTypesType.elapsedTime;
                break;

            case PerformanceCounterType.SampleBase:
                type = Util.PerformanceCounterTypesType.sampleBase;
                break;

            case PerformanceCounterType.RawBase:
                type = Util.PerformanceCounterTypesType.rawBase;
                break;

            case PerformanceCounterType.CounterMultiBase:
                type = Util.PerformanceCounterTypesType.counterMultiBase;
                break;

            case PerformanceCounterType.RateOfCountsPerSecond64:
                type = Util.PerformanceCounterTypesType.rateOfCountsPerSecond64;
                break;

            case PerformanceCounterType.RateOfCountsPerSecond32:
                type = Util.PerformanceCounterTypesType.rateOfCountsPerSecond32;
                break;

            case PerformanceCounterType.CountPerTimeInterval64:
                type = Util.PerformanceCounterTypesType.countPerTimeInterval64;
                break;

            case PerformanceCounterType.CountPerTimeInterval32:
                type = Util.PerformanceCounterTypesType.countPerTimeInterval32;
                break;

            case PerformanceCounterType.SampleCounter:
                type = Util.PerformanceCounterTypesType.sampleCounter;
                break;

            case PerformanceCounterType.CounterDelta64:
                type = Util.PerformanceCounterTypesType.counterDelta64;
                break;

            case PerformanceCounterType.NumberOfItems64:
                type = Util.PerformanceCounterTypesType.numberOfItems64;
                break;

            case PerformanceCounterType.NumberOfItems32:
                type = Util.PerformanceCounterTypesType.numberOfItems32;
                break;

            case PerformanceCounterType.NumberOfItemsHEX64:
                type = Util.PerformanceCounterTypesType.numberOfItemsHEX64;
                break;

            case PerformanceCounterType.NumberOfItemsHEX32:
                type = Util.PerformanceCounterTypesType.numberOfItemsHEX32;
                break;

            default:
                throw new WixException(UtilErrors.UnsupportedPerformanceCounterType(pct.ToString()));
            }

            return(type);
        }