예제 #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()));
 }
예제 #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);
        }
예제 #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);
        }
예제 #5
0
 public static ISimpleLog CreateLogFor <T>(this ISimpleLogFactory factory)
 {
     return(factory.CreateLogFor(typeof(T)));
 }