public void ShouldTrackingWhenAssigningValuesProperties() { var Person = LoggingProxy.Wrap(new Person()); Person.Name = "Cuong"; StringAssert.AreEqualIgnoringCase("method call: set_Name - parameter: Cuong", LoggingProxy.ChangeInfor); }
static void Main(string[] args) { var recordsPath = @$ "{Environment.CurrentDirectory}/text.csv"; var dataSource = @"(LocalDB)\MSSQLLocalDB"; var databaseFilename = @$ "{Directory.GetCurrentDirectory()}\WorkDatabase.mdf"; var connString = $@"Data Source={dataSource};AttachDbFilename={databaseFilename};Integrated Security=True;MultipleActiveResultSets=True"; CreateRecords(recordsPath); using (var csvRecords = new CsvEnumerable <Record>(recordsPath)) { var consoleLogger = new Logger(); using (IRepository <Record> repository = LoggingProxy <IRepository <Record> > .CreateInstance(new MSSQLLocalDBRepository(connString), consoleLogger)) { var tasks = new List <Task <int> >(); foreach (var record in csvRecords) { Console.WriteLine($"Name = {record.Name}, Number = {record.Number}"); tasks.Add(repository.CreateAsync(record)); } Task.WaitAll(tasks.ToArray()); } } }
public void ShouldNotTrackingWhenCallGetMethod() { var person = LoggingProxy.Wrap(new Person()); var name = person.Name; StringAssert.AreEqualIgnoringCase(null, LoggingProxy.ChangeInfor); }
public static IServiceCollection AddLogged <TServiceType, TImplementationType>(this IServiceCollection serviceCollection, ServiceLifetime serviceLifetime = ServiceLifetime.Scoped) where TImplementationType : TServiceType { var implementationServiceDescriptor = new ServiceDescriptor ( serviceType: typeof(TImplementationType), implementationType: typeof(TImplementationType), lifetime: serviceLifetime ); serviceCollection.Add(implementationServiceDescriptor); var loggedServiceDescriptor = new ServiceDescriptor ( serviceType: typeof(TServiceType), factory: serviceProvider => LoggingProxy <TServiceType> .Create(decorated: serviceProvider.GetRequiredService <TImplementationType>(), logger: serviceProvider.GetRequiredService <ILogger <TImplementationType> >()), lifetime: serviceLifetime ); serviceCollection.Add(loggedServiceDescriptor); return(serviceCollection); }
public static T Create() { LoggingProxy <T> realProxy = new LoggingProxy <T>(); T transparentProxy = (T)realProxy.GetTransparentProxy(); return(transparentProxy); }
private static void Main(string[] args) { LoggingProxy <Tutorial> tutorialProxy = new LoggingProxy <Tutorial>(); LoggingProxy <FrameProgram> frameProgramProxy = new LoggingProxy <FrameProgram>(); LoggingProxy <Participant> participantProxy = new LoggingProxy <Participant>(); LoggingProxy <Referee> refereeProxy = new LoggingProxy <Referee>(); LoggingProxy <Registration> registrationProxy = new LoggingProxy <Registration>(); }
public ProcessingManager(IFunctionExecutor functionExecutor) { this.functionExecutor = functionExecutor; applicationSequence = 0; transportSequence = 0; dom = ScadaProxyFactory.Instance().DOMProxy(); log = ScadaProxyFactory.Instance().LoggingProxy(); storage = ScadaProxyFactory.Instance().ScadaStorageProxy(); }
/// <summary> /// Initializes a new instance of the <see cref="Acquisitor"/> class. /// </summary> /// <param name="acquisitionTrigger">The acquisition trigger.</param> /// <param name="processingManager">The processing manager.</param> /// <param name="stateUpdater">The state updater.</param> public Acquisitor(IProcessingManager processingManager) { this.processingManager = processingManager; log = ScadaProxyFactory.Instance().LoggingProxy(); if (!Int32.TryParse(ConfigurationManager.AppSettings["AcquisitionInterval"], out acquisitionInterval)) { acquisitionInterval = 1000; } seconds = 0; this.InitializeAcquisitionThread(); this.StartAcquisitionThread(); }
public void Proxy() { ICommandHandler <MyCommand> commandHandler = LoggingProxy <ICommandHandler <MyCommand> > .Create(new MyCommandHandler()); commandHandler.Handle(new MyCommand()); IFoo f = LoggingProxy <IFoo> .Create(new Foo()); f.Add(); f.Delete(); }
public static void Main(string[] args) { LoggingProxy HamburgFlughafen = new LoggingProxy(3); Plane plane = HamburgFlughafen.AcquirePlane(); HamburgFlughafen.ReleasePlane(plane); AirportProtectingProxy LuebeckFlughafen = new AirportProtectingProxy(1); Plane plane2 = LuebeckFlughafen.AcquirePlane(); LuebeckFlughafen.ReleasePlane(plane2); }
static void Main(string[] args) { IRepository <Person> repository = LoggingProxy <IRepository <Person> > .CreateInstance(new Repository <Person>()); CsvEnumerable <Person> csvList = new CsvEnumerable <Person>(AppSettingsProvider.GetInstance().Settings.CsvFileName); try { foreach (Person p in csvList) { repository.Add(p); } } catch (Exception ex) { Console.Write(ex); } }
static void Main(string[] args) { ILogger consoleLogger = new LoggerBuilder() .AddConsoleProvider(LogMessageLevel.Info, ConsoleColor.Yellow) .AddConsoleProvider(LogMessageLevel.Error, ConsoleColor.Red) .ShowHeader() .SetName("wrapperLogger") .ShowName() .Build(); ILogger myLogger = new LoggerBuilder() .AddConsoleProvider(LogMessageLevel.All, ConsoleColor.Blue) .Build(); IFileStream file = new NewFileStream(Path.GetFullPath("./exampleFile"), FileMode.Create, FileAccess.ReadWrite); var wrappedFileStream = LoggingProxy.Create(file, consoleLogger); Random rand = new Random(); int length = 10000; byte[] randomValues = new byte[length]; rand.NextBytes(randomValues); myLogger.Info("Writing values synchronously."); wrappedFileStream.Write(randomValues, 0, length); myLogger.Info("End of synchronous writing."); myLogger.Info("Writing values asynchronously."); var writingTask = wrappedFileStream.WriteAsync(randomValues, 0, length); myLogger.Info("Keep processing main thread."); wrappedFileStream.Seek(0, SeekOrigin.Begin); myLogger.Info("Async reading"); var readingTask = wrappedFileStream.ReadAsync(randomValues, 0, length); myLogger.Info("Keep processing main thread."); writingTask.Wait(1000); readingTask.Wait(1000); myLogger.Info($"Readed {readingTask.Result}"); Console.WriteLine("Press F to exit..."); Console.ReadKey(); }
public void CreateProxySimpleTest() { IMyInterface intf = LoggingProxy <IMyInterface> .Create(new MyClass()); intf.MyProcedure(); }
public ProxiedWcfTraceListener() { proxyLogging = new LoggingProxy(); }