当前位置: 首页>>代码示例>>C#>>正文


C# ObservableEventListener.EnableEvents方法代码示例

本文整理汇总了C#中ObservableEventListener.EnableEvents方法的典型用法代码示例。如果您正苦于以下问题:C# ObservableEventListener.EnableEvents方法的具体用法?C# ObservableEventListener.EnableEvents怎么用?C# ObservableEventListener.EnableEvents使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ObservableEventListener的用法示例。


在下文中一共展示了ObservableEventListener.EnableEvents方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Main

        static void Main(string[] args)
        {
            // optimizing IOCP performance
            int minWorkerThreads;
            int minCompletionPortThreads;
            ThreadPool.GetMinThreads(out minWorkerThreads, out minCompletionPortThreads);
            ThreadPool.SetMinThreads(minWorkerThreads, Math.Max(16, minCompletionPortThreads));

            int threadCount = Environment.ProcessorCount;
            if (args.Length > 0)
            {
                threadCount = int.Parse(args[0]);
            }

            var eventListener = new ObservableEventListener();
            eventListener.LogToConsole();
            eventListener.EnableEvents(BootstrapperEventSource.Log, EventLevel.Verbose);
            eventListener.EnableEvents(MqttIotHubAdapterEventSource.Log, EventLevel.Verbose);
            eventListener.EnableEvents(DefaultEventSource.Log, EventLevel.Verbose);
            
            try
            {
                var cts = new CancellationTokenSource();

                var certificate = new X509Certificate2("protocol-gateway.contoso.com.pfx", "password");
                var settingsProvider = new AppConfigSettingsProvider();
                BlobSessionStatePersistenceProvider blobSessionStateProvider = BlobSessionStatePersistenceProvider.CreateAsync(
                    settingsProvider.GetSetting("BlobSessionStatePersistenceProvider.StorageConnectionString"),
                    settingsProvider.GetSetting("BlobSessionStatePersistenceProvider.StorageContainerName")).Result;

                TableQos2StatePersistenceProvider tableQos2StateProvider = TableQos2StatePersistenceProvider.CreateAsync(
                    settingsProvider.GetSetting("TableQos2StatePersistenceProvider.StorageConnectionString"),
                    settingsProvider.GetSetting("TableQos2StatePersistenceProvider.StorageTableName")).Result;

                var bootstrapper = new Bootstrapper(settingsProvider, blobSessionStateProvider, tableQos2StateProvider);
                Task.Run(() => bootstrapper.RunAsync(certificate, threadCount, cts.Token), cts.Token);

                while (true)
                {
                    string input = Console.ReadLine();
                    if (input != null && input.ToLowerInvariant() == "exit")
                    {
                        break;
                    }
                }

                cts.Cancel();
                bootstrapper.CloseCompletion.Wait(TimeSpan.FromSeconds(20));
            }
            finally
            {
                eventListener.Dispose();
            }
        }
开发者ID:kdotchkoff,项目名称:azure-iot-protocol-gateway,代码行数:54,代码来源:Program.cs

示例2: Main

        static void Main(string[] args)
        {
            if (args.Length < 5)
            {
                Console.WriteLine("Mamemaki.Slab.BigQuery.PlayGround.exe <projectId> <datasetId> <tableId> <serviceAccountEmail> <privateKeyFile>");
                return;
            }
            var projectId = args[0];
            var datasetId = args[1];
            var tableId = args[2];
            var serviceAccountEmail = args[3];
            var privateKeyFile = args[4];
            var tableSchemaFile = args[5];

            using (var listenerConsole = new ObservableEventListener())
            using (var listener = new ObservableEventListener())
            {
                var formatterConsole = new EventTextFormatter(
                    "+=========================================+");

                // Setup listener for debug
                listenerConsole.EnableEvents(SemanticLoggingEventSource.Log, EventLevel.LogAlways);
                listenerConsole.EnableEvents(BigQuerySinkEventSource.Log, EventLevel.LogAlways);
                listenerConsole.LogToConsole(formatterConsole);

                // Setup listener for playgrond
                listener.EnableEvents(PlayGroundEventSource.Log, EventLevel.LogAlways);
                listener.LogToConsole(formatterConsole);
                listener.LogToBigQuery(
                    projectId: projectId,
                    datasetId: datasetId,
                    tableId: tableId,
                    authMethod: "private_key",
                    serviceAccountEmail: serviceAccountEmail,
                    privateKeyFile: privateKeyFile,
                    privateKeyPassphrase: "notasecret",
                    autoCreateTable: true,
                    tableSchemaFile: tableSchemaFile,
                    insertIdFieldName: "%uuid%",
                    bufferingInterval: TimeSpan.FromSeconds(1),
                    bufferingCount: 3,
                    bufferingFlushAllTimeout: Constants.DefaultBufferingFlushAllTimeout,
                    maxBufferSize: 30000);

                PlayGroundEventSource.Log.Trace("start");
                InsertRows(3);
                Thread.Sleep(1);
                InsertRows(3);
                PlayGroundEventSource.Log.Trace("end");
            }

            Console.WriteLine("Press any key to exit");
            Console.ReadLine();
        }
开发者ID:tsu1980,项目名称:SlabBigQuery,代码行数:54,代码来源:Program.cs

示例3: ConfigureLogging

 private void ConfigureLogging()
 {
     eventListener = new ObservableEventListener();
     eventListener.EnableEvents(SparkEngineEventSource.Log, EventLevel.LogAlways,
         Keywords.All);
     eventListener.EnableEvents(SparkMongoEventSource.Log, EventLevel.LogAlways,
         Keywords.All);
     eventListener.EnableEvents(SemanticLoggingEventSource.Log, EventLevel.LogAlways, Keywords.All);
     var formatter = new JsonEventTextFormatter(EventTextFormatting.Indented);
     eventListener.LogToFlatFile(@"C:\projects\fhir\log\spark.log", formatter);
 }
开发者ID:Condeti,项目名称:spark,代码行数:11,代码来源:Global.asax.cs

示例4: Main

        static void Main(string[] args)
        {
            Options options = new Options();

            CommandLine.Parser.Default.ParseArguments(args, options);

            if (!options.ShowingHelp)
            {
                ObservableEventListener Listener = new ObservableEventListener();
                Listener.EnableEvents((EventSource)Harmonize.Instrumentation.Error, EventLevel.LogAlways, Keywords.All);
                Listener.EnableEvents((EventSource)Harmonize.Instrumentation.Harmonization, EventLevel.LogAlways, Keywords.All);

                //ObservableEventListener harmonyEventListener = new ObservableEventListener();
                //harmonyEventListener.EnableEvents((EventSource)With.Harmony.Instrumentation.State, EventLevel.LogAlways, Keywords.All);

                //ObservableEventListener owlCommandEventListener = new ObservableEventListener();
                //owlCommandEventListener.EnableEvents((EventSource)With.Owl.Intuition.Instrumentation.Command.Endpoint, EventLevel.LogAlways, Keywords.All);

                //ObservableEventListener owlPacketEventListener = new ObservableEventListener();
                //owlPacketEventListener.EnableEvents((EventSource)With.Owl.Intuition.Instrumentation.Packet.Endpoint, EventLevel.LogAlways, Keywords.All);

                //ObservableEventListener owlStateEventListener = new ObservableEventListener();
                //owlStateEventListener.EnableEvents((EventSource)With.Owl.Intuition.Instrumentation.State.Machine, EventLevel.LogAlways, Keywords.All);

                //ObservableEventListener xmppEventListener = new ObservableEventListener();
                //xmppEventListener.EnableEvents((EventSource)With.Harmony.Instrumentation.Xmpp, EventLevel.LogAlways, Keywords.All);

                //ObservableEventListener alljoynEventListener = new ObservableEventListener();
                //alljoynEventListener.EnableEvents(With.Alljoyn.Instrumentation.Coordinator, EventLevel.LogAlways, Keywords.All);

                //ObservableEventListener storeEventListener = new ObservableEventListener();
                //storeEventListener.EnableEvents((EventSource)State.Instrumentation.Store, EventLevel.LogAlways, Keywords.All);

                //ObservableEventListener messagingEventListener = new ObservableEventListener();
                //messagingEventListener.EnableEvents((EventSource)With.Messaging.Instrumentation.Messages, EventLevel.LogAlways, Keywords.All);

                options.TraceEvents.Split(',').Select(name => Listener.EnableEvents(name, EventLevel.LogAlways, Keywords.All)).ForEach(Cons.WriteLine);

                using (new CompositeDisposable(Listener.LogToConsole()))
                {
                    Client client = new Client(options);

                    client.Start();

                    System.Console.WriteLine("Started");
                    System.Console.WriteLine("Hit Return to stop");
                    System.Console.ReadLine();

                    client.Stop();
                }
            }
        }
开发者ID:Zananok,项目名称:Harmonize,代码行数:52,代码来源:Program.cs

示例5: UnderReleaseBufferLeak

        public void UnderReleaseBufferLeak()
        {
            ResourceLeakDetector.DetectionLevel preservedLevel = ResourceLeakDetector.Level;
            try
            {
                ResourceLeakDetector.Level = ResourceLeakDetector.DetectionLevel.Paranoid;
                var eventListener = new ObservableEventListener();
                Mock<IObserver<EventEntry>> logListener = this.mockRepo.Create<IObserver<EventEntry>>();
                var eventTextFormatter = new EventTextFormatter();
                Func<EventEntry, bool> leakPredicate = y => y.TryFormatAsString(eventTextFormatter).Contains("LEAK");
                logListener.Setup(x => x.OnNext(It.Is<EventEntry>(y => leakPredicate(y)))).Verifiable();
                logListener.Setup(x => x.OnNext(It.Is<EventEntry>(y => !leakPredicate(y))));
                eventListener.Subscribe(logListener.Object);
                eventListener.EnableEvents(DefaultEventSource.Log, EventLevel.Verbose);

                this.CreateAndForgetBuffer();

                GC.Collect();
                GC.WaitForPendingFinalizers();

                this.mockRepo.Verify();
            }
            finally
            {
                ResourceLeakDetector.Level = preservedLevel;
            }
        }
开发者ID:RabbitTeam,项目名称:DotNetty,代码行数:27,代码来源:LeakDetectionTest.cs

示例6: TestEventSink

        public async Task TestEventSink()
        {
            var listener = new TcpListener(IPAddress.Loopback, 0);
            listener.Start();
            int port = ((IPEndPoint)listener.Server.LocalEndPoint).Port;

            var slabListener = new ObservableEventListener();
            slabListener.Subscribe(new TcpEventSink(IPAddress.Loopback, port, 
                new ExponentialBackoffTcpReconnectionPolicy(),
                new TestEventFormatter()));
            var source = TestEventSource.GetInstance();
            slabListener.EnableEvents(source, EventLevel.LogAlways, Keywords.All);

            var listenerClient = await listener.AcceptTcpClientAsync();

            source.Message("Boris", "Meep");

            var receiverReader = new StreamReader(listenerClient.GetStream());
            var line = await receiverReader.ReadLineAsync();

            Assert.Equal(
                "EventId=1 EventName=MessageInfo Level=Error \"FormattedMessage=Meep - Boris\" \"message=Boris\" \"caller=Meep\"",
                line);

            listenerClient.Close();
            listener.Stop();
            slabListener.Dispose();
        }
开发者ID:JimSimpkins13,项目名称:splunk-library-dotnetlogging,代码行数:28,代码来源:TestTcp.cs

示例7: EnableLoggingListener

 private void EnableLoggingListener()
 {
     listener = new ObservableEventListener();
     listener.LogToWindowsAzureTable("CustomEvents", "DefaultEndpointsProtocol=https;AccountName=musiccloudstorage;AccountKey=...");
     //listener.EnableEvents(AuditEvent.Log, EventLevel.LogAlways, Keywords.All);
     listener.EnableEvents(ErrorEvent.Log, EventLevel.LogAlways, Keywords.All);
 }
开发者ID:dmossberg,项目名称:MusicStoreMvcSource,代码行数:7,代码来源:Global.asax.cs

示例8: TestExporter

        public void TestExporter() {
            var listener = new ObservableEventListener();
            listener.EnableEvents(TflEventSource.Log, EventLevel.Verbose);
            var subscription = listener.LogToConsole(new LegacyLogFormatter());

            var file = Path.GetTempFileName();
            File.WriteAllText(file, @"t1,t2,t3,t4
Monday,10,1.1,1/1/2014
Tuesday,11,2.2,2/1/2014
Wednesday,12,3.3,3/1/2014
Wednesday,12,3.3,3/1/2014
Thursday,13,4.4,4/1/2014
Friday,14,5.5,5/1/2014
Saturday,15,6.6,6/1/2014");

            File.Delete(OUTPUT);

            var profile = new Profiler().Profile(file);
            new ProfileExporter().Export(profile, OUTPUT);

            subscription.Dispose();
            listener.DisableEvents(TflEventSource.Log);
            listener.Dispose();

            Assert.IsTrue(File.Exists(OUTPUT));
        }
开发者ID:modulexcite,项目名称:DataProfiler,代码行数:26,代码来源:Development.cs

示例9: Initialize

        public override void Initialize()
        {
            var eventListener = new ObservableEventListener();

            eventListener.EnableEvents(
                VirtoCommerceEventSource.Log,
                EventLevel.LogAlways,
                Keywords.All);

            

            var assetsConnection = ConfigurationManager.ConnectionStrings["AssetsConnectionString"];

            if (assetsConnection != null)
            {
                var properties = assetsConnection.ConnectionString.ToDictionary(";", "=");
                var provider = properties["provider"];
                var assetsConnectionString = properties.ToString(";", "=", "provider");

                if (string.Equals(provider, FileSystemBlobProvider.ProviderName, StringComparison.OrdinalIgnoreCase))
                {
                    eventListener.LogToRollingFlatFile("AvaTax.log",
                        10000,
                        "hh",
                        RollFileExistsBehavior.Increment,
                        RollInterval.Day);
                }
                else
                    if (string.Equals(provider, AzureBlobProvider.ProviderName, StringComparison.OrdinalIgnoreCase))
                    {
                        eventListener.LogToWindowsAzureTable(
                            "VirtoCommerce2", assetsConnectionString);

                    }
            }


            var settingsManager = _container.Resolve<ISettingsManager>();
            
            var avalaraTax = new AvaTaxSettings(_usernamePropertyName, _passwordPropertyName, _serviceUrlPropertyName, _companyCodePropertyName, _isEnabledPropertyName, _isValidateAddressPropertyName, settingsManager);
            
            _container.RegisterType<AvaTaxController>
                (new InjectionConstructor(
                    avalaraTax));

            _container.RegisterInstance<ITaxSettings>(avalaraTax);

            //Subscribe to cart changes. Calculate taxes   
            _container.RegisterType<IObserver<CartChangeEvent>, CalculateCartTaxesObserver>("CalculateCartTaxesObserver");

            //Subscribe to order changes. Calculate taxes   
            _container.RegisterType<IObserver<OrderChangeEvent>, CalculateOrderTaxesObserver>("CalculateOrderTaxesObserver");

            //Subscribe to order changes. Calculate taxes   
            _container.RegisterType<IObserver<OrderChangeEvent>, CancelOrderTaxesObserver>("CancelOrderTaxesObserver");

            //Subscribe to order changes. Adjust taxes   
            _container.RegisterType<IObserver<OrderChangeEvent>, CalculateTaxAdjustmentObserver>("CalculateTaxAdjustmentObserver");
        }
开发者ID:rajendra1809,项目名称:VirtoCommerce,代码行数:59,代码来源:Module.cs

示例10: RegisterEFLogger

        private static void RegisterEFLogger()
        {
            var listener = new ObservableEventListener();
            listener.EnableEvents(EFLogging.Logger, EventLevel.LogAlways, Keywords.All);

            listener.LogToFlatFile("EFSqls.log");
            listener.LogToWindowsAzureTable(instanceName: "Protiviti", connectionString: "UseDevelopmentStorage=true",tableAddress:"EFSqls");
        }
开发者ID:szwork2013,项目名称:BoiPlt,代码行数:8,代码来源:Bootstrapper.cs

示例11: RunAsync

        async Task RunAsync(CancellationToken cancellationToken)
        {
            var settingsProvider = new RoleEnvironmentSettingsProvider();

            var eventListener = new ObservableEventListener();
            eventListener.LogToWindowsAzureTable(RoleEnvironment.CurrentRoleInstance.Id, settingsProvider.GetSetting("BlobSessionStatePersistenceProvider.StorageConnectionString"), bufferingInterval: TimeSpan.FromMinutes(2));
            eventListener.EnableEvents(BootstrapperEventSource.Log, EventLevel.Informational);
            eventListener.EnableEvents(MqttIotHubAdapterEventSource.Log, EventLevel.Informational);
            eventListener.EnableEvents(DefaultEventSource.Log, EventLevel.Informational);
            
            int minWorkerThreads;
            int minCompletionPortThreads;
            ThreadPool.GetMinThreads(out minWorkerThreads, out minCompletionPortThreads);
            ThreadPool.SetMinThreads(minWorkerThreads, Math.Max(16, minCompletionPortThreads));

            int threadCount = Environment.ProcessorCount;
            
            BlobSessionStatePersistenceProvider blobSessionStateProvider =
                await BlobSessionStatePersistenceProvider.CreateAsync(
                    settingsProvider.GetSetting("BlobSessionStatePersistenceProvider.StorageConnectionString"),
                    settingsProvider.GetSetting("BlobSessionStatePersistenceProvider.StorageContainerName"));

            TableQos2StatePersistenceProvider tableQos2StateProvider =
                await TableQos2StatePersistenceProvider.CreateAsync(
                    settingsProvider.GetSetting("TableQos2StatePersistenceProvider.StorageConnectionString"),
                    settingsProvider.GetSetting("TableQos2StatePersistenceProvider.StorageTableName"));

            var bootstrapper = new Bootstrapper(
                settingsProvider,
                blobSessionStateProvider,
                tableQos2StateProvider);

            X509Certificate2 tlsCertificate = GetTlsCertificate(settingsProvider.GetSetting("TlsCertificateThumbprint"),
                StoreName.My, StoreLocation.LocalMachine);

            try
            {
                await bootstrapper.RunAsync(tlsCertificate, threadCount, cancellationToken);
            }
            catch (Exception ex)
            {
                Trace.TraceError(ex.ToString());
                throw;
            }
            await bootstrapper.CloseCompletion;
        }
开发者ID:troyanov,项目名称:azure-iot-protocol-gateway,代码行数:46,代码来源:WorkerRole.cs

示例12: TestBase

        /// <summary>
        ///     Initializes a new instance of the <see cref="TestBase" /> class.
        /// </summary>
        protected TestBase()
        {
            var observableEventListener = new ObservableEventListener();

            observableEventListener.EnableEvents(ExceptionLoggingEventSource.Log, EventLevel.LogAlways);

            observableEventListener.LogToConsole();
        }
开发者ID:Rolosoft,项目名称:Rsft.Identity3.CacheRedis,代码行数:11,代码来源:TestBase.cs

示例13: RegisterLogger

        private static void RegisterLogger()
        {
            var listener = new ObservableEventListener();
            listener.EnableEvents(WebApiTracing.Log, EventLevel.LogAlways, Keywords.All);

            listener.LogToConsole();
            listener.LogToFlatFile("test.log");
            listener.LogToWindowsAzureTable(instanceName: "Protiviti", connectionString: "UseDevelopmentStorage=true");
        }
开发者ID:szwork2013,项目名称:BoiPlt,代码行数:9,代码来源:Bootstrapper.cs

示例14: LogViewModel

 public LogViewModel()
 {
     LoggedItems = new ObservableCollection<string>();
     EventListener = new ObservableEventListener();
     EventListener.EnableEvents(Logger.Write, EventLevel.Verbose);
     _syncContext = SynchronizationContext.Current;
     EventListener.LogToCollection(PublishLogItem);
     // Can only be called on the dispatcher's thread. 
 }
开发者ID:leloulight,项目名称:EasyFarm,代码行数:9,代码来源:LogViewModel.cs

示例15: Given

 protected override void Given()
 {
     ColorMapper = new MockDefaultConsoleColorMapper();
     MockConsole = new MockConsoleOutput();
     Formatter = new EventTextFormatter(EventTextFormatter.DashSeparator) { VerbosityThreshold = EventLevel.Informational };
     Listener = new ObservableEventListener();
     Listener.LogToConsole(Formatter, ColorMapper);
     Listener.EnableEvents(TestEventSource.Log, EventLevel.LogAlways);
 }
开发者ID:HondaBey,项目名称:EnterpriseLibrary6,代码行数:9,代码来源:ConsoleEventListenerFixture.cs


注:本文中的ObservableEventListener.EnableEvents方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。