Пример #1
0
 public override void WriteMetadata(
     TraceLoggingMetadataCollector collector,
     string name,
     EventFieldFormat format)
 {
     collector.AddGroup(name);
 }
 /// <summary>
 /// Creates a collector for a group.
 /// </summary>
 /// <param name="other">Parent collector</param>
 /// <param name="group">The field that starts the group</param>
 private TraceLoggingMetadataCollector(
     TraceLoggingMetadataCollector other,
     FieldMetadata group)
 {
     this.impl = other.impl;
     this.currentGroup = group;
 }
Пример #3
0
        public override void WriteMetadata(
            TraceLoggingMetadataCollector collector,
            string name,
            EventFieldFormat format)
        {
            var groupCollector = collector.AddGroup(name);
            if (this.properties != null)
            {
                foreach (var property in this.properties)
                {
                    var propertyFormat = EventFieldFormat.Default;
                    var propertyAttribute = property.fieldAttribute;
                    if (propertyAttribute != null)
                    {
                        groupCollector.Tags = propertyAttribute.Tags;
                        propertyFormat = propertyAttribute.Format;
                    }

                    property.typeInfo.WriteMetadata(
                        groupCollector,
                        property.name,
                        propertyFormat);
                }
            }
        }
Пример #4
0
 public override void WriteMetadata(
     TraceLoggingMetadataCollector collector,
     string name,
     EventFieldFormat format)
 {
     collector.BeginBufferedArray();
     this.elementInfo.WriteMetadata(collector, name, format);
     collector.EndBufferedArray();
 }
        /// <summary>
        /// Call this method to add a group to the event and to return
        /// a new metadata collector that can be used to add fields to the
        /// group. After all of the fields in the group have been written,
        /// switch back to the original metadata collector to add fields
        /// outside of the group.
        /// Special-case: if name is null, no group is created, and AddGroup
        /// returns the original metadata collector. This is useful when
        /// adding the top-level group for an event.
        /// Note: do not use the original metadata collector while the group's
        /// metadata collector is in use, and do not use the group's metadata
        /// collector after switching back to the original.
        /// </summary>
        /// <param name="name">
        /// The name of the group. If name is null, the call to AddGroup is a
        /// no-op (collector.AddGroup(null) returns collector).
        /// </param>
        /// <returns>
        /// A new metadata collector that can be used to add fields to the group.
        /// </returns>
        public TraceLoggingMetadataCollector AddGroup(string name)
        {
            TraceLoggingMetadataCollector result = this;

            if (name != null ||              // Normal.
                this.BeginningBufferedArray) // Error, FieldMetadata's constructor will throw the appropriate exception.
            {
                var newGroup = new FieldMetadata(
                    name,
                    TraceLoggingDataType.Struct,
                    this.Tags,
                    this.BeginningBufferedArray);
                this.AddField(newGroup);
                result = new TraceLoggingMetadataCollector(this, newGroup);
            }

            return(result);
        }
Пример #6
0
        public override void WriteMetadata(
            TraceLoggingMetadataCollector collector,
            string name,
            EventFieldFormat format)
        {
            switch (format)
            {
            default:
                collector.AddBinary(name, Statics.MakeDataType(TraceLoggingDataType.Binary, format));
                break;

            case EventFieldFormat.String:
                collector.AddBinary(name, TraceLoggingDataType.CountedMbcsString);
                break;

            case EventFieldFormat.Xml:
                collector.AddBinary(name, TraceLoggingDataType.CountedMbcsXml);
                break;

            case EventFieldFormat.Json:
                collector.AddBinary(name, TraceLoggingDataType.CountedMbcsJson);
                break;

            case EventFieldFormat.Boolean:
                collector.AddArray(name, TraceLoggingDataType.Boolean8);
                break;

            case EventFieldFormat.Hexadecimal:
                collector.AddArray(name, TraceLoggingDataType.HexInt8);
                break;

#if false
            case EventSourceFieldFormat.Signed:
                collector.AddArray(name, TraceLoggingDataType.Int8);
                break;

            case EventSourceFieldFormat.Unsigned:
                collector.AddArray(name, TraceLoggingDataType.UInt8);
                break;
#endif
            }
        }
Пример #7
0
        internal TraceLoggingEventTypes(
            string name,
            EventTags tags,
            System.Reflection.ParameterInfo[] paramInfos)
        {
            if (name == null)
            {
                throw new ArgumentNullException(nameof(name));
            }

            this.typeInfos = MakeArray(paramInfos);
#if FEATURE_PERFTRACING
            this.paramNames = MakeParamNameArray(paramInfos);
#endif
            this.name  = name;
            this.tags  = tags;
            this.level = Statics.DefaultLevel;

            var collector = new TraceLoggingMetadataCollector();
            for (int i = 0; i < typeInfos.Length; ++i)
            {
                var typeInfo = typeInfos[i];
                this.level     = Statics.Combine((int)typeInfo.Level, this.level);
                this.opcode    = Statics.Combine((int)typeInfo.Opcode, this.opcode);
                this.keywords |= typeInfo.Keywords;
                var paramName = paramInfos[i].Name;
                if (Statics.ShouldOverrideFieldName(paramName !))
                {
                    paramName = typeInfo.Name;
                }
                typeInfo.WriteMetadata(collector, paramName, EventFieldFormat.Default);
            }

            this.typeMetadata = collector.GetMetadata();
            this.scratchSize  = collector.ScratchSize;
            this.dataCount    = collector.DataCount;
            this.pinCount     = collector.PinCount;
        }
Пример #8
0
 public override void WriteMetadata(TraceLoggingMetadataCollector collector, string name, EventFieldFormat format)
 {
     collector.AddScalar(name, formatFunc(format, nativeFormat));
 }
Пример #9
0
 public override void WriteMetadata(TraceLoggingMetadataCollector collector, string name, EventFieldFormat format)
 {
     collector.AddBinary(name, Statics.MakeDataType(TraceLoggingDataType.CountedUtf16String, format));
 }
Пример #10
0
 public override void WriteMetadata(TraceLoggingMetadataCollector collector, string name, EventFieldFormat format)
 {
     collector.BeginBufferedArray();
     this.elementInfo.WriteMetadata(collector, name, format);
     collector.EndBufferedArray();
 }
Пример #11
0
 public override void WriteMetadata(TraceLoggingMetadataCollector collector, string name, EventFieldFormat format)
 {
     collector.AddArray(name, Statics.Format64(format, TraceLoggingDataType.Double));
 }
Пример #12
0
 public override void WriteMetadata(TraceLoggingMetadataCollector collector, string name, EventFieldFormat format)
 {
     collector.AddGroup(name);
 }
        /// <summary>
        /// Call this method to add a group to the event and to return
        /// a new metadata collector that can be used to add fields to the
        /// group. After all of the fields in the group have been written,
        /// switch back to the original metadata collector to add fields
        /// outside of the group.
        /// Special-case: if name is null, no group is created, and AddGroup
        /// returns the original metadata collector. This is useful when
        /// adding the top-level group for an event.
        /// Note: do not use the original metadata collector while the group's
        /// metadata collector is in use, and do not use the group's metadata
        /// collector after switching back to the original.
        /// </summary>
        /// <param name="name">
        /// The name of the group. If name is null, the call to AddGroup is a
        /// no-op (collector.AddGroup(null) returns collector).
        /// </param>
        /// <returns>
        /// A new metadata collector that can be used to add fields to the group.
        /// </returns>
        public TraceLoggingMetadataCollector AddGroup(string name)
        {
            TraceLoggingMetadataCollector result = this;

            if (name != null || // Normal.
                this.BeginningBufferedArray) // Error, FieldMetadata's constructor will throw the appropriate exception.
            {
                var newGroup = new FieldMetadata(
                    name,
                    TraceLoggingDataType.Struct,
                    0,
                    this.BeginningBufferedArray);
                this.AddField(newGroup);
                result = new TraceLoggingMetadataCollector(this, newGroup);
            }

            return result;
        }
Пример #14
0
 public override void WriteMetadata(
     TraceLoggingMetadataCollector collector,
     string name,
     EventFieldFormat format)
 {
     collector.AddScalar(name, Statics.MakeDataType(TraceLoggingDataType.Double, format));
 }
Пример #15
0
 public override void WriteMetadata(TraceLoggingMetadataCollector collector, string name, EventFieldFormat format)
 {
     var group = collector.AddGroup(name);
     group.AddScalar("Ticks", Statics.MakeDataType(TraceLoggingDataType.FileTime, format));
     group.AddScalar("Offset", TraceLoggingDataType.Int64);
 }
Пример #16
0
 public override void WriteMetadata(
     TraceLoggingMetadataCollector collector,
     string name,
     EventFieldFormat format)
 {
     collector.AddBinary(name, Statics.MakeDataType(TraceLoggingDataType.CountedUtf16String, format));
 }
Пример #17
0
 /// <summary>
 /// When overridden by a derived class, writes the metadata (schema) for
 /// this type. Note that the sequence of operations in WriteMetadata should be
 /// essentially identical to the sequence of operations in
 /// WriteData/WriteObjectData. Otherwise, the metadata and data will not match,
 /// which may cause trouble when decoding the event.
 /// </summary>
 /// <param name="collector">
 /// The object that collects metadata for this object's type. Metadata is written
 /// by calling methods on the collector object. Note that if the type contains
 /// sub-objects, the implementation of this method may need to call the
 /// WriteMetadata method for the type of the sub-object, e.g. by calling
 /// TraceLoggingTypeInfo&lt;SubType&gt;.Instance.WriteMetadata(...).
 /// </param>
 /// <param name="name">
 /// The name of the property that contains an object of this type, or null if this
 /// object is being written as a top-level object of an event. Typical usage
 /// is to pass this value to collector.AddGroup.
 /// </param>
 /// <param name="format">
 /// The format attribute for the field that contains an object of this type.
 /// </param>
 public abstract void WriteMetadata(
     TraceLoggingMetadataCollector collector,
     string name,
     EventFieldFormat format);
Пример #18
0
 public override void WriteMetadata(TraceLoggingMetadataCollector collector, string name, EventFieldFormat format)
 {
     collector.AddArray(name, Statics.FormatPtr(format, Statics.UIntPtrType));
 }
 /// <summary>
 /// When overridden by a derived class, writes the metadata (schema) for
 /// this type. Note that the sequence of operations in WriteMetadata should be
 /// essentially identical to the sequence of operations in
 /// WriteData/WriteObjectData. Otherwise, the metadata and data will not match,
 /// which may cause trouble when decoding the event.
 /// </summary>
 /// <param name="collector">
 /// The object that collects metadata for this object's type. Metadata is written
 /// by calling methods on the collector object. Note that if the type contains
 /// sub-objects, the implementation of this method may need to call the
 /// WriteMetadata method for the type of the sub-object, e.g. by calling
 /// TraceLoggingTypeInfo&lt;SubType&gt;.Instance.WriteMetadata(...).
 /// </param>
 /// <param name="name">
 /// The name of the property that contains an object of this type, or null if this
 /// object is being written as a top-level object of an event. Typical usage
 /// is to pass this value to collector.AddGroup.
 /// </param>
 /// <param name="format">
 /// The format attribute for the field that contains an object of this type.
 /// </param>
 public abstract void WriteMetadata(
     TraceLoggingMetadataCollector collector,
     string name,
     EventFieldFormat format);
Пример #20
0
 public override void WriteMetadata(
     TraceLoggingMetadataCollector collector,
     string name,
     EventFieldFormat format)
 {
     var group = collector.AddGroup(name);
     group.AddScalar("HasValue", TraceLoggingDataType.Boolean8);
     this.valueInfo.WriteMetadata(group, "Value", format);
 }
Пример #21
0
 public override void WriteMetadata(TraceLoggingMetadataCollector collector, string name, EventFieldFormat format)
 {
     collector.AddScalar(name, formatFunc(format, nativeFormat));
 }
Пример #22
0
        private TraceLoggingEventTypes(
            EventTags tags,
            string defaultName,
            TraceLoggingTypeInfo[] typeInfos)
        {
            if (defaultName == null)
            {
                throw new ArgumentNullException("defaultName");
            }

            Contract.EndContractBlock();

            this.typeInfos = typeInfos;
            this.name = defaultName;
            this.tags = tags;
            this.level = Statics.DefaultLevel;

            var collector = new TraceLoggingMetadataCollector();
            foreach (var typeInfo in typeInfos)
            {
                this.level = Statics.Combine((int)typeInfo.Level, this.level);
                this.opcode = Statics.Combine((int)typeInfo.Opcode, this.opcode);
                this.keywords |= typeInfo.Keywords;
                typeInfo.WriteMetadata(collector, null, EventFieldFormat.Default);
            }

            this.typeMetadata = collector.GetMetadata();
            this.scratchSize = collector.ScratchSize;
            this.dataCount = collector.DataCount;
            this.pinCount = collector.PinCount;
        }
Пример #23
0
 public override void WriteMetadata(TraceLoggingMetadataCollector collector, string name, EventFieldFormat format)
 {
     collector.AddScalar(name, Statics.MakeDataType(TraceLoggingDataType.Double, format));
 }
Пример #24
0
        internal TraceLoggingEventTypes(
            string name,
            EventTags tags,
            System.Reflection.ParameterInfo[] paramInfos)
        {
            if (name == null)
            {
                throw new ArgumentNullException("name");
            }

            Contract.EndContractBlock();

            this.typeInfos = MakeArray(paramInfos);
            this.name = name;
            this.tags = tags;
            this.level = Statics.DefaultLevel;

            var collector = new TraceLoggingMetadataCollector();
            for (int i = 0; i < typeInfos.Length; ++i)
            {
                var typeInfo = typeInfos[i];
                this.level = Statics.Combine((int)typeInfo.Level, this.level);
                this.opcode = Statics.Combine((int)typeInfo.Opcode, this.opcode);
                this.keywords |= typeInfo.Keywords;
                var paramName = paramInfos[i].Name;
                if (Statics.ShouldOverrideFieldName(paramName))
                {
                    paramName = typeInfo.Name;
                }
                typeInfo.WriteMetadata(collector, paramName, EventFieldFormat.Default);
            }

            this.typeMetadata = collector.GetMetadata();
            this.scratchSize = collector.ScratchSize;
            this.dataCount = collector.DataCount;
            this.pinCount = collector.PinCount;
        }
Пример #25
0
 public override void WriteMetadata(TraceLoggingMetadataCollector collector, string name, EventFieldFormat format)
 {
     collector.AddScalar(name, Statics.Format32(format, TraceLoggingDataType.Int32));
 }
Пример #26
0
 public override void WriteMetadata(TraceLoggingMetadataCollector collector, string?name, EventFieldFormat format)
 {
     collector.AddArray(name !, Statics.FormatScalar(format, nativeFormat));
 }