예제 #1
0
            public ValueType(PProfSampleValueType valueTypeItems, PProfBuilder builder)
            {
                Validate.NotNull(builder, nameof(builder));

                _typeInfo = builder.GetOrCreateStringInfo(valueTypeItems.Type ?? string.Empty);
                _unitInfo = builder.GetOrCreateStringInfo(valueTypeItems.Unit ?? string.Empty);
            }
예제 #2
0
        public void SetSampleValueTypes(IEnumerable <PProfSampleValueType> valueTypes)
        {
            if (_buildState.Session != null && _buildState.Session.SamplesCount > 0)
            {
                throw new InvalidOperationException($"Cannot invoke {nameof(SetSampleValueTypes)}(..) when there is an active "
                                                    + $" {nameof(PProfBuildSession)} and {_buildState.Session.SamplesCount} samples have been added to that session.");
            }

            if (valueTypes == null)
            {
                SampleValueTypes     = new PProfSampleValueType[0];
                SampleValueTypeInfos = new PProfInfo.ValueType[0];
                SampleValuesUnset    = new long[0];
                return;
            }

            int valueTypesCount;

            if (valueTypes is ICollection <PProfSampleValueType> valueTypesCollection)
            {
                valueTypesCount = valueTypesCollection.Count;
            }
            else if (valueTypes is IReadOnlyCollection <PProfSampleValueType> valueTypesROCollection)
            {
                valueTypesCount = valueTypesROCollection.Count;
            }
            else
            {
                valueTypesCount = valueTypes.Count();
            }

            var newSampleValueTypes     = new PProfSampleValueType[valueTypesCount];
            var newSampleValueTypeInfos = new PProfInfo.ValueType[valueTypesCount];
            var newSampleValuesUnset    = new long[valueTypesCount];

            int i = 0;

            foreach (PProfSampleValueType vt in valueTypes)
            {
                newSampleValueTypes[i]     = vt;
                newSampleValueTypeInfos[i] = new PProfInfo.ValueType(vt, this);
                newSampleValuesUnset[i]    = ProtoConstants.NumericValue.UnsetInt64;
                i++;
            }

            SampleValueTypes     = newSampleValueTypes;
            SampleValueTypeInfos = newSampleValueTypeInfos;
            SampleValuesUnset    = newSampleValuesUnset;
        }