Beispiel #1
0
 public Location(PProfProto.Location item, PProfInfo.Mapping mappingInfo, PProfInfo.Function functionInfo)
     : this(item, mappingInfo, new PProfInfo.Function[1] {
     functionInfo
 })
 {
     Validate.NotNull(functionInfo, nameof(functionInfo));
 }
Beispiel #2
0
            public Location(PProfProto.Location item, PProfInfo.Mapping mappingInfo, IReadOnlyList <PProfInfo.Function> functionInfos)
            {
                Validate.NotNull(item, nameof(item));
                Validate.NotNull(mappingInfo, nameof(mappingInfo));
                Validate.NotNull(functionInfos, nameof(functionInfos));

                if (functionInfos.Count < 1)
                {
                    throw new ArgumentException($"{nameof(functionInfos)} must contain at least one element.");
                }

                if (item.Line.Count != functionInfos.Count)
                {
                    throw new ArgumentException($"{nameof(item)}.{nameof(item.Line)}.{nameof(item.Line.Count)} (={item.Line.Count})"
                                                + $" must have the same value as {nameof(functionInfos)}.{nameof(functionInfos.Count)} (={functionInfos.Count}).");
                }

                for (int i = 0; i < functionInfos.Count; i++)
                {
                    if (functionInfos[i] == null)
                    {
                        throw new ArgumentException($"{nameof(functionInfos)} must not contain null elements, but element at index {i} is null.");
                    }
                }

                this.Item = item;
                this.IsIncludedInSession = false;
                this.MappingInfo         = mappingInfo;
                this.FunctionInfos       = functionInfos;
            }
Beispiel #3
0
        public PProfInfo.Location GetOrCreateLocationInfo(
            LocationDescriptor locationDescriptor,
            PProfInfo.Mapping mappingInfo,
            IReadOnlyList <PProfInfo.Function> functionInfos)
        {
            // locationDescriptor is value type so can never be null
            Validate.NotNull(mappingInfo, nameof(mappingInfo));
            Validate.NotNull(functionInfos, nameof(functionInfos));

            if (!_locations.TryGetValue(locationDescriptor, out PProfInfo.Location locationInfo))
            {
                var locationItem = new PProfProto.Location()
                {
                    Id        = NextIdForLocation(),
                    MappingId = mappingInfo.Item.Id,
                    Address   = ProtoConstants.NumericValue.UnsetUInt64,
                    IsFolded  = false
                };

                for (int i = 0; i < functionInfos.Count; i++)
                {
                    if (functionInfos[i] != null)
                    {
                        locationItem.Line.Add(new PProfProto.Line()
                        {
                            FunctionId = functionInfos[i].Item.Id,
                            Line_      = ProtoConstants.NumericValue.UnsetInt64
                        });
                    }
                }

                locationInfo = new PProfInfo.Location(locationItem, mappingInfo, functionInfos);
                _locations.Add(locationDescriptor, locationInfo);
            }

            return(locationInfo);
        }