Example #1
0
        public void SimpleLogFactoryConstructorTest()
        {
            ILog             log    = null; // TODO: Initialize to an appropriate value
            SimpleLogFactory target = new SimpleLogFactory(log);

            Assert.Inconclusive("TODO: Implement code to verify target");
        }
Example #2
0
        static void Main()
        {
            var simpleLogFactory = SimpleLogFactory.Resolve();
            var myLogFactory     = new MyLogFactory(simpleLogFactory);

            SimpleLogFactory.Resolve = () => myLogFactory;

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            var isAdministrator = IsAdministrator();

            if (!isAdministrator)
            {
                var message = string.Format("{0}{1}{2}", "服务的安装、卸载需要管理员身份!", Environment.NewLine,
                                            "请尝试使用右键,然后以管理员身份运行此程序!");
                MessageBox.Show(message);
                return;
            }

            var isDaemonForm = IsDaemonForm();

            if (isDaemonForm)
            {
                Application.Run(new DaemonForm());
            }
            else
            {
                Application.Run(new MainForm());
            }
        }
Example #3
0
        private static ISimpleLogFactory SetupAsyncLog()
        {
            var simpleLogFactory = SimpleLogFactory.Resolve();

            simpleLogFactory.LogWithSimpleEventBus();
            return(simpleLogFactory);
        }
Example #4
0
        public static ISimpleLogFactory Setup()
        {
            var simpleLogFactory = SimpleLogFactory.Resolve();

            simpleLogFactory.LogWithSimpleEventBus();
            return(simpleLogFactory);
        }
Example #5
0
        public void LogInfo(string message)
        {
            var simpleLogFactory = SimpleLogFactory.Resolve();
            var simpleLog        = simpleLogFactory.GetOrCreateLogFor <T>();

            simpleLog.LogInfo(message);
        }
Example #6
0
 private void AppendLogs(string message)
 {
     if (_log == null)
     {
         _log = SimpleLogFactory.Resolve().CreateLogFor(this);
     }
     _log.LogInfo(message);
 }
Example #7
0
 public ObjectCountController(ISimpleJson simpleJson, ISimpleJsonFile simpleJsonFile, ISimpleLogFactory simpleLogFactory, SimpleLogFactory simpleLogFactory2)
 {
     this.ReportAdd();
     _simpleJson        = simpleJson;
     _simpleJsonFile    = simpleJsonFile;
     _simpleLogFactory  = simpleLogFactory;
     _simpleLogFactory2 = simpleLogFactory2;
 }
Example #8
0
        public Task <IList <ObjectCountInfo> > GetInfos()
        {
            var simpleJson       = SimpleJson.Resolve();
            var simpleJsonFile   = SimpleJson.ResolveSimpleJsonFile();
            var simpleLogFactory = SimpleLogFactory.Resolve();

            var objectCountInfos = ObjectCountInfo.Create(ObjectCounter.Instance);

            return(Task.FromResult(objectCountInfos));
        }
Example #9
0
        public void GetLogTest()
        {
            SimpleLogFactory target   = new SimpleLogFactory(); // TODO: Initialize to an appropriate value
            string           name     = string.Empty;           // TODO: Initialize to an appropriate value
            ILog             expected = null;                   // TODO: Initialize to an appropriate value
            ILog             actual;

            actual = target.GetLog(name);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }
Example #10
0
        public AsyncLogForm()
        {
            InitializeComponent();

            var simpleLogFactory = SimpleLogFactory.Resolve();

            _simpleLog = simpleLogFactory.GetOrCreate("MockSomeLogger");

            this.cbxAutoLine.Checked = true;
            this.cbxAutoDate.Checked = true;

            MessageEventBusHelper = this.txtMessage.CreateAsyncUiHelperForMessageEventBus(message => { this.txtMessage.AppendText(message); });
        }
Example #11
0
        public static void AddCommon(this IServiceCollection services, IConfiguration configuration)
        {
            services.AddSingleton(SimpleJson.Resolve() as SimpleJson);
            services.AddSingleton(SimpleJson.Resolve());
            services.AddSingleton(SimpleJson.ResolveSimpleJsonFile());

            services.AddSingleton(SimpleLogFactory.Resolve() as SimpleLogFactory);
            services.AddSingleton(SimpleLogFactory.Resolve());

            services.AddSingleton(WebApiHelper.Resolve() as WebApiHelper);
            services.AddSingleton(WebApiHelper.Resolve());

            services.AddSingleton(AsyncFile.Instance);

            //also can use like this:
            //services.AddSingleton<WebApiHelper>();
            //services.AddSingleton<IWebApiHelper>(sp => sp.GetService<WebApiHelper>());
            //WebApiHelper.Resolve = () => app.ApplicationServices.GetService<IWebApiHelper>(); //in Config process
        }
Example #12
0
        public static ISimpleLogFactory SetupLogEx()
        {
            var simpleLogFactory = SimpleLogFactory.Resolve();
            var initLog          = simpleLogFactory.CreateLogFor <ExLogInit>();

            _folderPath = AppDomain.CurrentDomain.Combine("Logs");
            initLog.LogInfo(">>>> log folder path => " + _folderPath);

            var logActions = simpleLogFactory.LogActions;

            logActions["LogExToFile"] = new LogMessageAction("LogExToFile", true, args =>
            {
                if (args.Level.ShouldLog(SimpleLogLevel.Error))
                {
                    LogExToFile(args);
                }
            });

            return(simpleLogFactory);
        }
Example #13
0
        public void ShowInfos(ServiceLifetime lifetime)
        {
            var objectCounter = ObjectCounter.Instance;

            objectCounter.Enabled = true;
            var services = new ServiceCollection();

            services.Add(ServiceDescriptor.Describe(typeof(IFooService), typeof(FooService), lifetime));
            services.Add(ServiceDescriptor.Describe(typeof(BarService), typeof(BarService), lifetime));

            var simpleLogFactory = SimpleLogFactory.Resolve();

            simpleLogFactory.LogWithSimpleEventBus();
            services.AddSingleton(simpleLogFactory);

            using (var sp = services.BuildServiceProvider())
            {
                for (int i = 0; i < 2; i++)
                {
                    var barService = sp.GetService <BarService>();
                    Task.Delay(TimeSpan.FromMilliseconds(200)).Wait();
                }
            }
        }
Example #14
0
        public void SimpleLogFactoryConstructorTest1()
        {
            SimpleLogFactory target = new SimpleLogFactory();

            Assert.Inconclusive("TODO: Implement code to verify target");
        }
Example #15
0
 public LogApi()
 {
     Factory = SimpleLogFactory.Resolve();
 }