예제 #1
0
            public Label(PProfSampleLabel labelItems, PProfItemCache builderCache, PProfProto.Label item)
            {
                Validate.NotNull(builderCache, nameof(builderCache));
                Validate.NotNull(item, nameof(item));

                this.Item = item;

                _valueKind = labelItems.ValueKind;
                _keyInfo   = builderCache.GetOrCreateStringInfo(labelItems.Key ?? string.Empty);

                switch (labelItems.ValueKind)
                {
                case PProfSampleLabel.Kind.Number:
                    _numValue = labelItems.NumberValue;
                    _strValueOrNumUnitInfo = builderCache.GetOrCreateStringInfo(labelItems.NumberUnit ?? string.Empty);
                    break;

                case PProfSampleLabel.Kind.String:
                    _numValue = ProtoConstants.NumericValue.UnsetInt64;
                    _strValueOrNumUnitInfo = builderCache.GetOrCreateStringInfo(labelItems.StringValue ?? string.Empty);
                    break;

                case PProfSampleLabel.Kind.Unknown:
                default:
                    throw new InvalidOperationException($"Cannot create a {nameof(PProfInfo)}.{nameof(Label)},"
                                                        + $" because the {nameof(PProfSampleLabel.ValueKind)} of the"
                                                        + $" specified {nameof(PProfSampleLabel)} is {labelItems.ValueKind}."
                                                        + $" Either {PProfSampleLabel.Kind.Number} or {PProfSampleLabel.Kind.String} was expected."
                                                        + $" (Did you use the default ctor for {nameof(PProfSampleLabel)}?"
                                                        + " If so, use a different ctor overload.)");
                }
            }
예제 #2
0
 internal PProfInfo.String GetOrCreateStringInfo(string stringItem)
 {
     return(_cache.GetOrCreateStringInfo(stringItem));
 }