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; }
public override bool Add(Request item) { if (item == null) { throw new ArgumentNullException(nameof(item), "the request is null"); } if (item.Itens.IsNullOrEmpty()) { throw new ArgumentException("Every request need items"); } if (string.IsNullOrWhiteSpace(item.UserId)) { throw new InvalidOperationException("The request does not have an associated user"); } Contract.EndContractBlock(); foreach (var requestItem in item.Itens) { requestItem.Request = item; requestItem.RequestId = item.Id; } return(base.Add(item)); }
internal TraceLoggingTypeInfo( Type dataType, string name, EventLevel level, EventOpcode opcode, EventKeywords keywords, EventTags tags) { if (dataType == null) { throw new ArgumentNullException("dataType"); } if (name == null) { throw new ArgumentNullException("eventName"); } Contract.EndContractBlock(); Statics.CheckName(name); this.name = name; this.keywords = keywords; this.level = level; this.opcode = opcode; this.tags = tags; this.dataType = dataType; this.propertyValueFactory = PropertyValue.GetFactory(dataType); }
/// <summary> /// Initializes a new instance of the EventSourceActivity class that /// is attached to the specified event source. The new activity will /// not be attached to any related (parent) activity. /// The activity is created in the Initialized state. /// </summary> /// <param name="eventSource"> /// The event source to which the activity information is written. /// </param> public EventSourceActivity(EventSource eventSource) { if (eventSource == null) { throw new ArgumentNullException(nameof(eventSource)); } Contract.EndContractBlock(); this.eventSource = eventSource; }
public void OperateRange(int index, int count, ActionRef <T> operation) { Contract.Requires <ArgumentOutOfRangeException>(index >= 0); Contract.Requires <ArgumentOutOfRangeException>(count >= 0); Contract.Requires <ArgumentOutOfRangeException>(index + count <= Count); Contract.EndContractBlock(); if (count > 0) { tree.Operate(operation, index, index + count - 1); } }
public void Reverse(int index, int count) { Contract.Requires <ArgumentOutOfRangeException>(index >= 0); Contract.Requires <ArgumentOutOfRangeException>(count >= 0); Contract.Requires <ArgumentOutOfRangeException>(index + count <= Count); Contract.EndContractBlock(); if (count > 0) { tree.Reverse(index, index + count - 1); } }
internal TraceLoggingTypeInfo(Type dataType) { if (dataType == null) { throw new ArgumentNullException("dataType"); } Contract.EndContractBlock(); this.name = dataType.Name; this.dataType = dataType; }
private static TraceLoggingTypeInfo[] MakeArray( TraceLoggingTypeInfo[] typeInfos) { if (typeInfos == null) { throw new ArgumentNullException("typeInfos"); } Contract.EndContractBlock(); return((TraceLoggingTypeInfo[])typeInfos.Clone());; }
internal TraceLoggingTypeInfo(Type dataType) { if (dataType == null) { throw new ArgumentNullException("dataType"); } Contract.EndContractBlock(); this.name = dataType.Name; this.dataType = dataType; this.propertyValueFactory = PropertyValue.GetFactory(dataType); }
/// <summary> /// Construct an EventSource with a given name for non-contract based events (e.g. those using the Write() API). /// /// Also specify a list of key-value pairs called traits (you must pass an even number of strings). /// The first string is the key and the second is the value. These are not interpreted by EventSource /// itself but may be interprated the listeners. Can be fetched with GetTrait(string). /// </summary> /// <param name="eventSourceName"> /// The name of the event source. Must not be null. /// </param> /// <param name="config"> /// Configuration options for the EventSource as a whole. /// </param> /// <param name="traits">A collection of key-value strings (must be an even number).</param> public EventSource( string eventSourceName, EventSourceSettings config, params string[] traits) : this( eventSourceName == null ? new Guid() : GenerateGuidFromName(eventSourceName.ToUpperInvariant()), eventSourceName, config, traits) { if (eventSourceName == null) { throw new ArgumentNullException("eventSourceName"); } Contract.EndContractBlock(); }
/// <summary> /// Writes an event with no fields. /// (Native API: EventWriteTransfer) /// </summary> /// <param name="eventName">The name of the event. Must not be null.</param> /// <param name="options"> /// Options for the event, such as the level, keywords, and opcode. Unset /// options will be set to default values. /// </param> public unsafe void Write(string eventName, EventSourceOptions options) { if (eventName == null) { throw new ArgumentNullException(nameof(eventName)); } Contract.EndContractBlock(); if (!this.IsEnabled()) { return; } this.WriteImpl(eventName, ref options, null, null, null, SimpleEventTypes <EmptyStruct> .Instance); }
public IList <T> GetRange(int index, int count) { Contract.Requires <ArgumentOutOfRangeException>(index >= 0); Contract.Requires <ArgumentOutOfRangeException>(count >= 0); Contract.Requires <ArgumentOutOfRangeException>(index + count <= Count); Contract.Ensures(Contract.Result <IList <T> >() != null); Contract.EndContractBlock(); if (count > 0) { return(tree.Report(index, index + count - 1)); } else { return(new List <T>()); } }
public unsafe void Write(string eventName, EventSourceOptions options) { if (eventName == null) { throw new ArgumentNullException("eventName"); } Contract.EndContractBlock(); if (!this.IsEnabled()) { return; } var data = new EmptyStruct(); this.WriteImpl(eventName, ref options, ref data, null, null); }
private static TraceLoggingTypeInfo[] MakeArray(Type[] types) { if (types == null) { throw new ArgumentNullException("types"); } Contract.EndContractBlock(); var recursionCheck = new List <Type>(types.Length); var result = new TraceLoggingTypeInfo[types.Length]; for (int i = 0; i < types.Length; i++) { result[i] = TraceLoggingTypeInfo.GetInstance(types[i], recursionCheck); } return(result); }
private TraceLoggingTypeInfo[] MakeArray(System.Reflection.ParameterInfo[] paramInfos) { if (paramInfos == null) { throw new ArgumentNullException("paramInfos"); } Contract.EndContractBlock(); var recursionCheck = new List <Type>(paramInfos.Length); var result = new TraceLoggingTypeInfo[paramInfos.Length]; for (int i = 0; i < paramInfos.Length; ++i) { result[i] = TraceLoggingTypeInfo.GetInstance(paramInfos[i].ParameterType, recursionCheck); } return(result); }
public void RemoveRange(int index, int count) { Contract.Requires <ArgumentOutOfRangeException>(index >= 0); Contract.Requires <ArgumentOutOfRangeException>(count >= 0); Contract.Requires <ArgumentOutOfRangeException>(index + count <= Count); Contract.EndContractBlock(); // find end first to make hot node is located at start. var end = index + count; var endnode = Find(ref end); var start = index; var startnode = Find(ref start); if (ReferenceEquals(startnode, endnode)) { startnode.Delete(start, count); Count -= count; return; } endnode.Split(end, _new); // split last node startnode.Delete(start, startnode.Count - start); // remove from tail of first node var next = startnode.Next; startnode.Next = endnode.Next; //remove chain if (!typeof(TData).IsValueType) { while (!ReferenceEquals(next, endnode)) //clear chain { next.Clear(); next = next.Next; } endnode.Clear(); } FixNode(startnode); Count -= count; Version++; }
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; }
public IList <TData> GetRange(int index, int count) { Contract.Requires <ArgumentOutOfRangeException>(index >= 0); Contract.Requires <ArgumentOutOfRangeException>(count >= 0); Contract.Requires <ArgumentOutOfRangeException>(index + count <= Count); Contract.Ensures(Contract.Result <IList <TData> >() != null); Contract.EndContractBlock(); var start = index; var startnode = Find(ref start); var end = index + count; var endnode = Find(ref end); if (ReferenceEquals(startnode, endnode)) { var res = new TData[count]; Array.Copy(startnode._items, start, res, 0, count); return(res.ToList()); } List <TData> result = new List <TData>(count); for (int i = start; i < startnode.Count; i++) { result.Add(startnode._items[i]); } startnode = startnode.Next; while (!ReferenceEquals(startnode, endnode)) { result.AddRange(startnode._items.Take(startnode.Count)); startnode = startnode.Next; } result.AddRange(endnode._items.Take(end)); return(result); }