コード例 #1
0
 protected override void AssignValueField(AppenderValue currentValue, string fieldName, double d, string sNum, string sValue)
 {
     if (fieldName.Equals("unit", StringComparison.OrdinalIgnoreCase))
     {
         ((MetricDatumAppenderValue)currentValue).Unit = sValue;
     }
 }
コード例 #2
0
        protected override bool FillName(AppenderValue value)
        {
            switch (value.Name.ToLowerInvariant())
            {
            case "message":
            case "__cav_rest":
                if (!string.IsNullOrEmpty(_currentDatum.Message))
                {
                    break;
                }

                _currentDatum.Message = DefaultsOverridePattern ? DefaultMessage ?? value.sValue : value.sValue;
                break;

            case "streamname":
                if (!string.IsNullOrEmpty(_currentDatum.StreamName))
                {
                    return(false);
                }

                _currentDatum.StreamName = DefaultsOverridePattern ? DefaultStreamName ?? value.sValue : value.sValue;
                break;

            case "groupname":
                if (!string.IsNullOrEmpty(_currentDatum.GroupName))
                {
                    return(false);
                }

                _currentDatum.GroupName = DefaultsOverridePattern ? DefaultGroupName ?? value.sValue : value.sValue;
                break;

            case "timestamp":
                if (_currentDatum.Timestamp.HasValue)
                {
                    return(false);
                }

                _currentDatum.Timestamp = DefaultsOverridePattern ? DefaultTimestamp ?? value.Time.Value.DateTime : value.Time.Value.DateTime;
                break;
            }

            return(true);
        }
コード例 #3
0
        protected override bool FillName(AppenderValue value)
        {
            switch (value.Name.ToLowerInvariant())
            {
            case "__cav_rest":
                if (!string.IsNullOrEmpty(_currentDatum.Message))
                {
                    return(false);
                }

                _currentDatum.Message = DefaultsOverridePattern ? DefaultMessage ?? value.sValue : value.sValue;
                break;

            case "queuename":
                if (!string.IsNullOrEmpty(_currentDatum.QueueName))
                {
                    return(false);
                }

                _currentDatum.QueueName = DefaultsOverridePattern ? DefaultQueueName ?? value.sValue : value.sValue;
                break;

            case "delayseconds":
                if (_currentDatum.DelaySeconds.HasValue)
                {
                    return(false);
                }

                _currentDatum.DelaySeconds = DefaultsOverridePattern ? DefaultDelaySeconds ?? Convert.ToInt32(value.dValue) : Convert.ToInt32(value.dValue);
                break;

            case "id":
                if (!string.IsNullOrEmpty(_currentDatum.ID))
                {
                    return(false);
                }

                _currentDatum.ID = value.sValue;
                break;
            }

            return(true);
        }
コード例 #4
0
        protected override bool FillName(AppenderValue value)
        {
            var metricValue = value as MetricDatumAppenderValue;

            switch (value.Name.ToLowerInvariant())
            {
            case "value":
                if (_currentDatum.Value.HasValue)
                {
                    return(false);
                }

                _currentDatum.Value = DefaultsOverridePattern ? DefaultValue ?? value.dValue.Value : value.dValue.Value;
                _currentDatum.Unit  = DefaultsOverridePattern ? DefaultUnit ?? metricValue.Unit : metricValue.Unit;
                break;

            case "unit":
                if (_currentDatum.Unit != null)
                {
                    return(false);
                }

                if (DefaultsOverridePattern)
                {
                    _currentDatum.Unit = DefaultUnit ?? value.sValue;
                }
                else
                {
                    _currentDatum.Unit = value.sValue;
                }
                break;

            case "metricname":
                if (!string.IsNullOrEmpty(_currentDatum.MetricName))
                {
                    return(false);
                }

                _currentDatum.MetricName = DefaultsOverridePattern ? DefaultMetricName ?? value.sValue : value.sValue;
                break;

            case "namespace":
                if (!string.IsNullOrEmpty(_currentDatum.NameSpace))
                {
                    return(false);
                }

                _currentDatum.NameSpace = DefaultsOverridePattern ? DefaultNameSpace ?? value.sValue : value.sValue;
                break;

            case "maximum":
                if (_currentDatum.Mode == DatumMode.StatisticsMode && _currentDatum.Maximum != 0.0)
                {
                    return(false);
                }

                _currentDatum.Maximum = DefaultsOverridePattern ? DefaultMaximum ?? value.dValue.Value : value.dValue.Value;
                _currentDatum.Unit    = DefaultsOverridePattern ? DefaultUnit ?? metricValue.Unit : metricValue.Unit;
                break;

            case "minimum":
                if (_currentDatum.Mode == DatumMode.StatisticsMode && _currentDatum.Minimum != 0.0)
                {
                    return(false);
                }
                _currentDatum.Minimum = DefaultsOverridePattern ? DefaultMinimum ?? value.dValue.Value : value.dValue.Value;
                _currentDatum.Unit    = DefaultsOverridePattern ? DefaultUnit ?? metricValue.Unit : metricValue.Unit;
                break;

            case "samplecount":
                if (_currentDatum.Mode == DatumMode.StatisticsMode && _currentDatum.SampleCount != 0.0)
                {
                    return(false);
                }

                _currentDatum.SampleCount = DefaultsOverridePattern ? DefaultSampleCount ?? value.dValue.Value : value.dValue.Value;
                _currentDatum.Unit        = DefaultsOverridePattern ? DefaultUnit ?? metricValue.Unit : metricValue.Unit;
                break;

            case "sum":
                if (_currentDatum.Mode == DatumMode.StatisticsMode && _currentDatum.Sum != 0.0)
                {
                    return(false);
                }

                _currentDatum.Sum  = DefaultsOverridePattern ? DefaultSum ?? value.dValue.Value : value.dValue.Value;
                _currentDatum.Unit = DefaultsOverridePattern ? DefaultUnit ?? metricValue.Unit : metricValue.Unit;
                break;

            case "timestamp":
                if (_currentDatum.Timestamp.HasValue)
                {
                    return(false);
                }

                _currentDatum.Timestamp = DefaultsOverridePattern ? DefaultTimestamp ?? value.Time.Value : value.Time.Value;
                break;

            case "__cav_rest":
                break;

            default:
                if (!Aggresive)
                {
                    break;
                }

                if (!string.IsNullOrEmpty(_currentDatum.MetricName))
                {
                    return(false);
                }

                _currentDatum.MetricName = DefaultsOverridePattern ? DefaultMetricName ?? value.Name : value.Name;
                _currentDatum.Value      = DefaultsOverridePattern ? DefaultValue ?? value.dValue.Value : value.dValue.Value;
                _currentDatum.Unit       = DefaultsOverridePattern ? DefaultUnit ?? metricValue.Unit : metricValue.Unit;

                break;
            }

            return(true);
        }
コード例 #5
0
        protected override void PostElementParse(ref List <Match> .Enumerator tokens, AppenderValue appenderValue, string aggregate = null)
        {
            string unit;

            if (!string.IsNullOrEmpty(aggregate))
            {
                var t = StandardUnit.FindValue(aggregate.ToLowerInvariant());
                if (t.ToString() != aggregate.ToLowerInvariant()) //If conversion capitalizes unit then it is valid and should not be included in rest.
                {
                    ((MetricDatumAppenderValue)appenderValue).Unit = aggregate;
                    return;
                }
            }

            if (tokens.MoveNext())
            {
                if (!string.IsNullOrEmpty(unit = tokens.Current.Groups["word"].Value))
                {
                    var t = StandardUnit.FindValue(unit.ToLowerInvariant());
                    if (t.ToString() != unit.ToLowerInvariant()) //If conversion capitalizes unit then it is valid and should not be included in rest.
                    {
                        tokens.MoveNext();
                        ((MetricDatumAppenderValue)appenderValue).Unit = unit;
                    }
                }
            }
        }