/// <summary> /// Starts a new activity scope. /// </summary> public static IDisposable StartActivity(this ITraceSource source, string format, params object[] args) { Guard.NotNull(() => source, source); Guard.NotNullOrEmpty(() => format, format); return(new TraceActivity(source, format, args)); }
public void RegisterRequiredServicesIfMissingApplicationCatalogIsRegisteredWithContainer() { AggregateCatalog _catalog = new AggregateCatalog(new ApplicationCatalog()); AggregateCatalog _newCatalog = DefaultServiceRegistrar.RegisterRequiredServicesIfMissing(_catalog); using (CompositionContainer _container = new CompositionContainer(_newCatalog)) { //Assert.AreEqual<int>(3, _container.Catalog.Parts.Count<ComposablePartDefinition>()); foreach (ComposablePartDefinition _part in _container.Catalog.Parts) { foreach (ImportDefinition _import in _part.ImportDefinitions) { Debug.WriteLine(string.Format("Imported contracts name => '{0}'", _import.ContractName)); } foreach (ExportDefinition _export in _part.ExportDefinitions) { Debug.WriteLine(string.Format("Exported contracts name => '{0}'", _export.ContractName)); } } ITraceSource _exportedValue = _container.GetExportedValue <ITraceSource>(); Assert.IsNotNull(_exportedValue); IInterface _interface = _container.GetExportedValue <IInterface>(); Assert.IsNotNull(_interface); IMessageHandlerFactory _messageHandlerFactory = _container.GetExportedValue <IMessageHandlerFactory>(); Assert.IsNotNull(_messageHandlerFactory); } }
/// <summary> /// Starts a new activity scope. /// </summary> public static IDisposable StartActivity(this ITraceSource source, string displayName) { Guard.NotNull(() => source, source); Guard.NotNullOrEmpty(() => displayName, displayName); return(new TraceActivity(source, displayName)); }
public LogicalOperationScope(ITraceSource source, object operationId, int startId, int stopId, string startMessage, string stopMessage) { _source = source; _startId = startId; _stopId = stopId; _operationId = operationId; _startMessage = startMessage ?? Resource.LogicalOperationScope_Start; _stopMessage = stopMessage ?? Resource.LogicalOperationScope_Stop; // Start Logical Operation if (_operationId == null) { Trace.CorrelationManager.StartLogicalOperation(); } else { Trace.CorrelationManager.StartLogicalOperation(_operationId); } // Log Start Message if (_source != null) { _source.TraceEvent(TraceEventType.Start, _startId, _startMessage); } }
public ConstructorInjection(ITraceSource traceEngine) { if (traceEngine == null) { throw new ArgumentNullException(nameof(traceEngine)); } m_TraceEngine = traceEngine; }
public LogHandler( ITraceSource requestTraceSource, ITraceSource responseTraceSource, IContext context, IOptions options) { this.requestTraceSource = requestTraceSource; this.responseTraceSource = responseTraceSource; this.context = context; this.options = options; }
public LogFilter( ITraceSource requestTraceSource, ITraceSource responseTraceSource, IContext context, IOptions options) { this.requestTraceSource = requestTraceSource; this.responseTraceSource = responseTraceSource; this.context = context; this.options = options; fallbackTraceSource = new System.Diagnostics.TraceSource(fallbackKey); }
/// <summary> /// Initializes default settings for the context. /// </summary> private void Initialize() { // Setup the EF includer. We assume no two contexts will do the // same within an appdomain. QueryableExtensions.Includer = new DbIncluder(); this.tracer = Tracer.GetSourceFor(this.GetType()); this.Configuration.AutoDetectChangesEnabled = true; this.Configuration.LazyLoadingEnabled = true; this.Configuration.ProxyCreationEnabled = true; this.Configuration.ValidateOnSaveEnabled = true; OnContextCreated(); ((IObjectContextAdapter)this).ObjectContext.ObjectMaterialized += OnObjectMaterialized; }
public ActivityScope(ITraceSource source, int transferInId, int startId, int transferOutId, int stopId, string transferInMessage, string startMessage, string transferOutMessage, string stopMessage, string activityName) { _source = source; _startId = startId; _stopId = stopId; _transferInId = transferInId; _transferOutId = transferOutId; _previousActivityId = Trace.CorrelationManager.ActivityId; _transferInMessage = transferInMessage ?? Resource.ActivityScope_Transfer; _startMessage = startMessage ?? Resource.ActivityScope_Start; _transferOutMessage = transferOutMessage ?? Resource.ActivityScope_Transfer; _stopMessage = stopMessage ?? Resource.ActivityScope_Stop; _activityName = activityName; StartScope(); }
public TraceActivity(ITraceSource source, string format, params object[] args) { Guard.NotNullOrEmpty(() => format, format); Guard.NotNull(() => source, source); this.displayName = format; if (args != null && args.Length > 0) { this.args = args; } this.source = source; this.newId = Guid.NewGuid(); this.oldId = Trace.CorrelationManager.ActivityId; if (this.oldId != Guid.Empty) { if (this.args == null) { source.Trace(new TransferTraceEvent(this.newId, this.oldId + " > " + this.newId, displayName)); } else { source.Trace(new TransferTraceEvent(this.newId, this.oldId + " > " + this.newId, displayName, args)); } } Trace.CorrelationManager.ActivityId = newId; if (this.args == null) { this.source.Trace(new MessageTraceEvent(TraceEventType.Start, 0, this.displayName)); } else { this.source.Trace(new MessageTraceEvent(TraceEventType.Start, 0, this.displayName, args)); } }
internal static ITraceSource CreateInstance(Assembly pluginAssembly) { if (pluginAssembly == null) { throw new NullReferenceException(nameof(pluginAssembly)); } ITraceSource _serverConfiguration = null; string _iName = typeof(ITraceSource).ToString(); foreach (Type pluginType in pluginAssembly.GetExportedTypes()) { //Only look at public types if (pluginType.IsPublic && !pluginType.IsAbstract && pluginType.GetInterface(_iName) != null) { _serverConfiguration = (ITraceSource)Activator.CreateInstance(pluginType); break; } } if (_serverConfiguration == null) { throw new NullReferenceException(nameof(_serverConfiguration)); } return(_serverConfiguration); }
public LogicalOperationScope(ITraceSource source, object operationId, int startId, int stopId) : this(source, operationId, startId, stopId, null, null) { }
public TraceActivity(ITraceSource source, string displayName) : this(source, displayName, null) { }
/// <summary> /// Constructor. /// Encompass a logical operation using the specified object, /// and writing start and stop events to the specified source. /// </summary> public LogicalOperationScope(ITraceSource source, object operationId) : this(source, operationId, 0, 0, null, null) { }
public ActivityScope(ITraceSource source, int transferInId, int startId, int transferOutId, int stopId, string transferInMessage, string startMessage, string transferOutMessage, string stopMessage) : this(source, transferInId, startId, transferOutId, stopId, transferInMessage, startMessage, transferOutMessage, stopMessage, null) { }
/// <summary> /// Traces an event of type <see cref="TraceEventType.Error"/> with the given exception, format string and arguments. /// </summary> public static void TraceError(this ITraceSource source, Exception exception, string format, params object[] args) { Guard.NotNull(() => source, source); source.Trace(new ExceptionTraceEvent(TraceEventType.Error, 0, exception, format, args)); }
/// <summary> /// Constructor. Sets the ActivityId for the life of the object, logging events but without specific event IDs. /// </summary> public ActivityScope(ITraceSource source) : this(source, 0, 0, 0, 0, null, null, null, null, null) { }
public ActivityScope(ITraceSource source, int transferInId, int startId, int transferOutId, int stopId) : this(source, transferInId, startId, transferOutId, stopId, null, null, null, null, null) { }
public ConstructorInjection(ITraceSource traceEngine) { if (traceEngine == null) throw new ArgumentNullException(nameof(traceEngine)); m_TraceEngine = traceEngine; }
/// <summary> /// Traces an event of type <see cref="TraceEventType.Error"/> with the given message; /// </summary> public static void TraceError(this ITraceSource source, string message) { Guard.NotNull(() => source, source); source.Trace(new MessageTraceEvent(TraceEventType.Error, 0, message)); }
public TraceActivity(ITraceSource source, string format, params object[] args) { Guard.NotNullOrEmpty(() => format, format); Guard.NotNull(() => source, source); this.displayName = format; if (args != null && args.Length > 0) this.args = args; this.source = source; this.newId = Guid.NewGuid(); this.oldId = Trace.CorrelationManager.ActivityId; if (this.oldId != Guid.Empty) { if (this.args == null) source.Trace(new TransferTraceEvent(this.newId, this.oldId + " > " + this.newId, displayName)); else source.Trace(new TransferTraceEvent(this.newId, this.oldId + " > " + this.newId, displayName, args)); } Trace.CorrelationManager.ActivityId = newId; if (this.args == null) this.source.Trace(new MessageTraceEvent(TraceEventType.Start, 0, this.displayName)); else this.source.Trace(new MessageTraceEvent(TraceEventType.Start, 0, this.displayName, args)); }
/// <summary> /// Adds the data set configuration. /// </summary> /// <param name="newDataSetConfiguration">The new data set configuration.</param> /// <param name="inFileName">Name of the in file.</param> /// <param name="outFileName">Name of the out file.</param> /// <param name="writerId">The writer identifier.</param> /// <param name="traceSource">The trace source.</param> public static void AddDataSetConfiguration(this DataSetConfiguration newDataSetConfiguration, Tuple <string, ushort, Guid> writerId, string inFileName, string outFileName, ITraceSource traceSource) { traceSource.TraceData(TraceEventType.Verbose, 53, $"Entering {nameof(AddDataSetConfiguration)} method."); //open source configuration UANetworkingConfiguration <ConfigurationData> _newConfiguration = new UANetworkingConfiguration <ConfigurationData>(); FileInfo _file2ReadConfiguration = new FileInfo(inFileName); _newConfiguration.ReadConfiguration(_file2ReadConfiguration); traceSource.TraceData(TraceEventType.Verbose, 53, $"I have read the configuration form the file {_file2ReadConfiguration.FullName}."); _newConfiguration.TraceSource = traceSource; ConfigurationData _currentConfiguration = _newConfiguration.CurrentConfiguration; // ddd new DataSetConfiguration List <DataSetConfiguration> _dataSets = _currentConfiguration.DataSets.ToList <DataSetConfiguration>(); traceSource.TraceData(TraceEventType.Verbose, 53, $"Configuration contains {_dataSets.Count} item of type {nameof(DataSetConfiguration)}."); _dataSets.Add(newDataSetConfiguration); _currentConfiguration.DataSets = _dataSets.ToArray <DataSetConfiguration>(); traceSource.TraceData(TraceEventType.Verbose, 53, $"New {nameof(DataSetConfiguration)} has been added to the copnfiguration."); // add new association for this DataSet in selected MessageWriterConfiguration ProducerAssociationConfiguration _newAssociation = new ProducerAssociationConfiguration() { AssociationName = newDataSetConfiguration.AssociationName, DataSetWriterId = writerId.Item2, FieldEncoding = FieldEncodingEnum.VariantFieldEncoding, PublisherId = writerId.Item3 }; MessageWriterConfiguration _selectedWriterConfiguration = _currentConfiguration.MessageHandlers .Where <MessageHandlerConfiguration>(_hn => (_hn.Name == writerId.Item1) && (_hn is MessageWriterConfiguration)) .Cast <MessageWriterConfiguration>() .First <MessageWriterConfiguration>(); List <ProducerAssociationConfiguration> _associationsInWriterConfiguration = _selectedWriterConfiguration.ProducerAssociationConfigurations.ToList <ProducerAssociationConfiguration>(); _associationsInWriterConfiguration.Add(_newAssociation); _selectedWriterConfiguration.ProducerAssociationConfigurations = _associationsInWriterConfiguration.ToArray(); traceSource.TraceData(TraceEventType.Verbose, 53, $"New {nameof (ProducerAssociationConfiguration)} has been added to the {nameof(MessageWriterConfiguration)}[{writerId.Item1}]."); //save the output file FileInfo _file2SaveConfiguration = new FileInfo(outFileName); _newConfiguration.SaveConfiguration(_file2SaveConfiguration); traceSource.TraceData(TraceEventType.Verbose, 53, $"Configuration has been saved to the file {_file2SaveConfiguration.FullName}."); }
/// <summary> /// Creates the configuration. /// </summary> /// <param name="dataSourceFields">The data source fields.</param> /// <param name="associationName">Name of the association used to select the <see cref="DataSetConfiguration"/> to be modified and added to the output file.</param> /// <param name="inFileName">Name of the in file containing the configuration.</param> /// <param name="outFileName">Name of the out file containing the configuration.</param> /// <param name="traceSource">The trace source.</param> public static void ReplaceDataSetFields(FieldMetaData[] dataSourceFields, string associationName, string inFileName, string outFileName, ITraceSource traceSource) { traceSource.TraceData(TraceEventType.Verbose, 53, $"Entering {nameof(ReplaceDataSetFields)} method."); UANetworkingConfiguration <ConfigurationData> _newConfiguration = new UANetworkingConfiguration <ConfigurationData>(); FileInfo _file2ReadConfiguration = new FileInfo(inFileName); _newConfiguration.ReadConfiguration(_file2ReadConfiguration); traceSource.TraceData(TraceEventType.Verbose, 53, $"I have read the configuration form the file {_file2ReadConfiguration.FullName}."); _newConfiguration.TraceSource = traceSource; Dictionary <string, DataSetConfiguration> _dataSets = _newConfiguration.CurrentConfiguration.DataSets.ToDictionary <DataSetConfiguration, string>(_dsc => _dsc.AssociationName); traceSource.TraceData(TraceEventType.Verbose, 53, $"Configuration contains {_dataSets.Count} item of type {nameof(DataSetConfiguration)}."); _dataSets[associationName].DataSet = dataSourceFields; traceSource.TraceData(TraceEventType.Verbose, 53, $"{nameof(DataSetConfiguration.DataSet)} for the association {associationName} has been modified by array of {dataSourceFields.Length} instances."); //_newConfiguration.CurrentConfiguration.DataSets = new DataSetConfiguration[] { _dataSets[associationName] }; FileInfo _file2SaveConfiguration = new FileInfo(outFileName); _newConfiguration.SaveConfiguration(_file2SaveConfiguration); traceSource.TraceData(TraceEventType.Verbose, 53, $"Configuration has been saved to the file {_file2SaveConfiguration.FullName}."); }
/// <summary> /// Initializes a new instance of the a <see cref="SonarAuthPassthroughModule"/> object /// </summary> /// <param name="traceSource">Reference to the tracing object.</param> internal SonarAuthPassthroughModule(ISettings settings, ITraceSource traceSource) { this.settings = settings ?? throw new ArgumentNullException(nameof(settings)); this.traceSource = traceSource ?? throw new ArgumentNullException(nameof(traceSource)); }
/// <summary> /// Traces an event of type <see cref="TraceEventType.Verbose"/> with the given format string and arguments. /// </summary> public static void TraceVerbose(this ITraceSource source, string format, params object[] args) { Guard.NotNull(() => source, source); source.Trace(new MessageTraceEvent(TraceEventType.Verbose, 0, format, args)); }
/// <summary> /// Initializes a new instance of the <see cref="TodosController" /> class. /// </summary> /// <param name="repository">The repository.</param> public TodosController(IGenericRepository <TodoItem> repository, ITraceSource tracer) { this.repository = repository; this.tracer = tracer; }
internal void CreateConfiguration (XmlQualifiedName instanceType, string _associationName, XmlQualifiedName instanceSymbolicName, string fileName, Tuple <string, ushort, System.Guid> writerNameDataSetWriterIdPublisherId, ITraceSource _traceSource) { List <FieldMetaData> _lf = new List <FieldMetaData>(); foreach (KeyValuePair <string, IVariable> _item in this) { if (_item.Value.ValueType.BuiltInType == BuiltInType.Null) { continue; } FieldMetaData _field = new FieldMetaData() { ProcessValueName = _item.Key, SymbolicName = _item.Key, TypeInformation = _item.Value.ValueType }; _lf.Add(_field); } DataSetConfiguration _newDataSetConfiguration = new DataSetConfiguration() { AssociationName = _associationName, AssociationRole = AssociationRole.Producer, ConfigurationGuid = System.Guid.NewGuid(), ConfigurationVersion = new ConfigurationVersionDataType() { MajorVersion = 1, MinorVersion = 0 }, Id = System.Guid.NewGuid(), InformationModelURI = instanceSymbolicName.Namespace, DataSet = _lf.ToArray(), DataSymbolicName = _associationName, MaxBufferTime = 1000, PublishingInterval = 100, RepositoryGroup = _associationName, Root = new NodeDescriptor() { BindingDescription = "Binding Description", DataType = instanceType, InstanceDeclaration = false, NodeClass = InstanceNodeClassesEnum.Object, NodeIdentifier = instanceSymbolicName } }; ConfigurationManagement.AddDataSetConfiguration(_newDataSetConfiguration, writerNameDataSetWriterIdPublisherId, fileName, fileName, _traceSource); }
/// <summary> /// Traces data with the given associated <see cref="TraceEventType"/>. /// </summary> public static void TraceData(this ITraceSource source, TraceEventType eventType, object data) { Guard.NotNull(() => source, source); source.Trace(new DataTraceEvent(eventType, 0, data)); }
/// <summary> /// Initializes a new instance of the <see cref="DataObservable" /> class. /// </summary> /// <param name="filename">The filename to be scanned.</param> /// <param name="settings">The application user settings.</param> /// <param name="traceSource">The trace source.</param> /// <exception cref="System.ArgumentNullException"> /// settings /// or /// traceSource /// </exception> internal DataObservable(string filename, ITextReaderProtocolParameters settings, ITraceSource traceSource) { m_Settings = settings ?? throw new ArgumentNullException(nameof(settings)); TraceSource = traceSource ?? throw new ArgumentNullException(nameof(traceSource)); m_FileFullPath = Path.GetFullPath(filename); string _path = Path.GetDirectoryName(m_FileFullPath); string _fileName = Path.GetFileName(m_FileFullPath); m_FileSystemWatcher = new FileSystemWatcher(_path, _fileName) { IncludeSubdirectories = false, EnableRaisingEvents = true, NotifyFilter = NotifyFilters.LastWrite }; m_DataEntityObservable = Observable .FromEventPattern <FileSystemEventHandler, FileSystemEventArgs>(x => m_FileSystemWatcher.Changed += x, y => m_FileSystemWatcher.Changed -= y) .Buffer <EventPattern <FileSystemEventArgs> >(TimeSpan.FromMilliseconds(settings.DelayFileScan)) .Where <IList <EventPattern <FileSystemEventArgs> > >(_list => _list.Count > 0) .Select <IList <EventPattern <FileSystemEventArgs> >, FileSystemEventPattern>(x => new FileSystemEventPattern(x[x.Count - 1])) .Delay <FileSystemEventPattern>(TimeSpan.FromMilliseconds(settings.DelayFileScan)) .Select <FileSystemEventPattern, IDataEntity>(x => DataEntity.ReadFile(x.EventPattern.EventArgs.FullPath, x.TimeStamp, m_Settings.ColumnSeparator)) .Do <IDataEntity>(data => { }, exception => LogException(exception)); TraceSource.TraceMessage(TraceEventType.Verbose, 107, $"Successfully created data observer for the file {filename} with parameters {settings}"); }
public Application(ITraceSource <Application> trace) { this.trace = trace; }
/// <summary> /// Initializes a new instance of the TraceLog class, using the specified trace source. /// </summary> /// <param name="traceSource">ITraceSource to write trace events to</param> public TraceLog(ITraceSource traceSource) { _traceSource = traceSource; _exceptionFormat = Resource.TraceLog_AppendedExceptionFormat; _exceptionSeparator = Resource.TraceLog_ExceptionFormatSeparator; }
/// <summary> /// Traces an event of type <see cref="TraceEventType.Error"/> with the given exception, using the /// <see cref="Exception.Message"/> as the trace event message. /// </summary> public static void TraceError(this ITraceSource source, Exception exception) { Guard.NotNull(() => source, source); source.Trace(new ExceptionTraceEvent(TraceEventType.Error, 0, exception)); }