Esempio n. 1
0
            public void PrintOption()
            {
                Console.WriteLine($"_optionsMonitor1({_optionsMonitor1.GetHashCode()}):{_optionsMonitor1.AsFormatJsonStr()}");
                Console.WriteLine($"_optionsMonitor2({_optionsMonitor2.GetHashCode()}):{_optionsMonitor2.AsFormatJsonStr()}");

                Console.WriteLine($"_optionsMonitor1.foo:{_optionsMonitor1.Get("foo").AsFormatJsonStr()}");
            }
Esempio n. 2
0
            public void PrintOption()
            {
                Console.WriteLine($"_option1({_option1.GetHashCode()}):{_option1.AsFormatJsonStr()}");
                Console.WriteLine($"_option2({_option2.GetHashCode()}):{_option2.AsFormatJsonStr()}");

                Console.WriteLine($"_optionsMonitor1({_optionsMonitor1.GetHashCode()}):{_optionsMonitor1.AsFormatJsonStr()}");
                Console.WriteLine($"_optionsMonitor2({_optionsMonitor2.GetHashCode()}):{_optionsMonitor2.AsFormatJsonStr()}");

                Console.WriteLine($"_optionsSnapshot1({_optionsSnapshot1.GetHashCode()}):{_optionsSnapshot1.AsFormatJsonStr()}");
                Console.WriteLine($"_optionsSnapshot2({_optionsSnapshot2.GetHashCode()}):{_optionsSnapshot2.AsFormatJsonStr()}");
            }
Esempio n. 3
0
 public OrderService(IOptionsMonitor <OrderOption> optionsMonitor1, IOptionsMonitor <OrderOption> optionsMonitor2)
 {
     _optionsMonitor1 = optionsMonitor1;
     _optionsMonitor2 = optionsMonitor2;
     _optionsMonitor1.OnChange(x => Console.WriteLine($"_optionsMonitor1变更:{_optionsMonitor1.AsFormatJsonStr()}"));
     _optionsMonitor2.OnChange(x => Console.WriteLine($"_optionsMonitor2变更:{_optionsMonitor2.AsFormatJsonStr()}"));
     //这里并不是只监听到变更的,而是都会进来,即foo进一次bar进一次
 }
Esempio n. 4
0
 public OrderService(IOptions <OrderOption> option1, IOptions <OrderOption> option2,
                     IOptionsSnapshot <OrderOption> optionsSnapshot1, IOptionsSnapshot <OrderOption> optionsSnapshot2,
                     IOptionsMonitor <OrderOption> optionsMonitor1, IOptionsMonitor <OrderOption> optionsMonitor2)
 {
     _option1          = option1;
     _option2          = option2;
     _optionsSnapshot1 = optionsSnapshot1;
     _optionsSnapshot2 = optionsSnapshot2;
     _optionsMonitor1  = optionsMonitor1;
     _optionsMonitor2  = optionsMonitor2;
     _optionsMonitor1.OnChange(x => Console.WriteLine($"_optionsMonitor1变更:{_optionsMonitor1.AsFormatJsonStr()}"));
     _optionsMonitor2.OnChange(x => Console.WriteLine($"_optionsMonitor2变更:{_optionsMonitor2.AsFormatJsonStr()}"));
 }