Exemplo n.º 1
0
 public static ISimpleLog CreateLogFor(this ISimpleLogFactory factory, object instance)
 {
     if (instance == null)
     {
         throw new ArgumentNullException(nameof(instance));
     }
     if (instance is Type type)
     {
         return(factory.CreateLogFor(type));
     }
     return(factory.CreateLogFor(instance.GetType()));
 }
Exemplo n.º 2
0
 public WebApiHelper(ISimpleLogFactory simpleLogFactory)
 {
     //todo: refactor code
     //var response = await httpClient.GetAsync(uri).ConfigureAwait(false);
     //var handler = new HttpClientHandler { AutomaticDecompression = DecompressionMethods.GZip };
     //_httpClient = new HttpClient(handler);
     _httpClient = new HttpClient();
     _simpleLog  = simpleLogFactory.CreateLogFor(this);
 }
        public static ISimpleLogFactory LogWithSimpleEventBus(this ISimpleLogFactory simpleLogFactory)
        {
            var logActions = simpleLogFactory.LogActions;

            logActions.SetActions(SimpleEventBus, true, LogMessage);

            var initLog = simpleLogFactory.CreateLogFor("SimpleEventBusExtensions");

            initLog.LogInfo(">>>> LogWithSimpleEventBus");
            return(simpleLogFactory);
        }
Exemplo n.º 4
0
        public static ISimpleLogFactory LogWithSimpleEventBus(this ISimpleLogFactory simpleLogFactory, ISimpleEventBus <AsyncMessageEvent> simpleEventBus = null)
        {
            simpleEventBus = simpleEventBus ?? SimpleEventBus <AsyncMessageEvent> .Resolve();

            var logActions = simpleLogFactory.LogActions;

            logActions.SetActions("LogWithSimpleEventBus", true, args =>
            {
                if (args?.Message != null)
                {
                    simpleEventBus.Raise(new AsyncMessageEvent(args.Message.ToString()));
                }
            });

            var initLog = simpleLogFactory.CreateLogFor("SimpleEventBusExtensions");

            initLog.LogInfo(">>>> LogWithSimpleEventBus");
            return(simpleLogFactory);
        }
Exemplo n.º 5
0
 public static ISimpleLog CreateLogFor <T>(this ISimpleLogFactory factory)
 {
     return(factory.CreateLogFor(typeof(T)));
 }