• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# ObservableEventListener类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: 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


示例2: 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


示例3: 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


示例4: Start

        public void Start(TflProcess process) {
            if (_started)
                return;

            _started = true;
            Name = process.Name;
            foreach (var log in process.Log) {
                switch (log.Provider) {
                    case "file":
                        log.Folder = log.Folder.Replace('/', '\\');
                        log.File = log.File.Replace('/', '\\');
                        log.Folder = (log.Folder.Equals(Common.DefaultValue) ? "logs" : log.Folder).TrimEnd('\\') + "\\";
                        log.File = (log.File.Equals(Common.DefaultValue) ? "tfl-" + process.Name + ".log" : log.File).TrimStart('\\');

                        var fileListener = new ObservableEventListener();
                        fileListener.EnableEvents(TflEventSource.Log, (EventLevel)Enum.Parse(typeof(EventLevel), log.Level));
                        SinkSubscriptions.Add(fileListener.LogToRollingFlatFile(log.Folder + log.File, 5000, "yyyy-MM-dd", RollFileExistsBehavior.Increment, RollInterval.Day, new LegacyLogFormatter(), 0, log.Async));
                        EventListeners.Add(fileListener);
                        break;
                    case "mail":
                        if (log.Subject.Equals(Common.DefaultValue)) {
                            log.Subject = process.Name + " " + log.Level;
                        }
                        var mailListener = new ObservableEventListener();
                        mailListener.EnableEvents(TflEventSource.Log, EventLevel.Error);
                        SinkSubscriptions.Add(mailListener.LogToEmail(log));
                        EventListeners.Add(mailListener);
                        break;
                }

            }

        }
开发者ID:modulexcite,项目名称:Transformalize,代码行数:33,代码来源:RunLogger.cs


示例5: With1Listener

        public static void With1Listener(IEnumerable<EventSource> loggers, Action<ObservableEventListener, InMemoryEventListener> scenario)
        {
            using (var errorsListener = new InMemoryEventListener())
            using (var listener = new ObservableEventListener())
            {
                try
                {
                    errorsListener.EnableEvents(SemanticLoggingEventSource.Log, EventLevel.Verbose, Keywords.All);

                    scenario(listener, errorsListener);
                }
                finally
                {
                    foreach (var logger in loggers)
                    {
                        try
                        { listener.DisableEvents(logger); }
                        catch
                        { }
                    }

                    errorsListener.DisableEvents(SemanticLoggingEventSource.Log);
                }
            }
        }
开发者ID:calebjenkins,项目名称:semantic-logging,代码行数:25,代码来源:TestScenario.cs


示例6: SetUp

 public void SetUp()
 {
     AppDomain.CurrentDomain.SetData("APPBASE", Environment.CurrentDirectory);
     this.fileName = Path.ChangeExtension(Guid.NewGuid().ToString("N"), ".log");
     this.eventTextFormatter = new EventTextFormatter(EventTextFormatter.DashSeparator);
     this.listener = new ObservableEventListener();
 }
开发者ID:HondaBey,项目名称:EnterpriseLibrary6,代码行数:7,代码来源:FlatFileEventListenerTests.cs


示例7: 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


示例8: TestBase

 protected TestBase(ITestOutputHelper output)
 {
     this.Output = output;
     this.eventListener = new ObservableEventListener();
     this.eventListener.LogToTestOutput(output);
     this.eventListener.EnableEvents(DefaultEventSource.Log, EventLevel.Verbose);
 }
开发者ID:l1183479157,项目名称:DotNetty,代码行数:7,代码来源:TestBase.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: CreateListener

 /// <summary>
 /// Creates an event listener that logs using a <see cref="ElasticsearchSink" />.
 /// </summary>
 /// <param name="instanceName">The name of the instance originating the entries.</param>
 /// <param name="connectionString">The endpoint address for the Elasticsearch Service.</param>
 /// <param name="index">Index name prefix formatted as index-{0:yyyy.MM.DD}</param>
 /// <param name="type">The Elasticsearch entry type</param>
 /// <param name="flattenPayload">Flatten the payload collection when serializing event entries</param>
 /// <param name="bufferingInterval">The buffering interval between each batch publishing.</param>
 /// <param name="listenerDisposeTimeout">Defines a timeout interval for the flush operation when the listener is disposed.</param>
 /// <param name="maxBufferSize">The maximum number of entries that can be buffered while it's sending to Elasticsearch before the sink starts dropping entries.
 /// This means that if the timeout period elapses, some event entries will be dropped and not sent to the store. Calling <see cref="IDisposable.Dispose" /> on
 /// the <see cref="EventListener" /> will block until all the entries are flushed or the interval elapses.
 /// If <see langword="null" /> is specified, then the call will block indefinitely until the flush operation finishes.</param>
 /// <returns>
 /// An event listener that uses <see cref="ElasticsearchSink" /> to log events.
 /// </returns>
 public static EventListener CreateListener(string instanceName, string connectionString, string index, string type, bool flattenPayload = true,
     TimeSpan? bufferingInterval = null, TimeSpan? listenerDisposeTimeout = null, int maxBufferSize = Buffering.DefaultMaxBufferSize)
 {
     var listener = new ObservableEventListener();
     listener.LogToElasticsearch(instanceName, connectionString, index, type, flattenPayload, bufferingInterval,
         listenerDisposeTimeout, maxBufferSize);
     return listener;
 }
开发者ID:MedAnd,项目名称:slab-sinks,代码行数:25,代码来源:ElasticsearchLog.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: CreateListener

 /// <summary>
 /// Creates an event listener that logs using a <see cref="LogglySink" />.
 /// </summary>
 /// <param name="instanceName">The name of the instance originating the entries.</param>
 /// <param name="connectionString">The endpoint address for the Loggly Service.</param>
 /// <param name="customerToken">The loggly customerToken that must be part of the Url.</param>
 /// <param name="tag">The tag used in loggly updates. Default is to use the instanceName.</param>
 /// <param name="flattenPayload">Flatten the payload if you want the parameters serialized.</param>
 /// <param name="bufferingInterval">The buffering interval between each batch publishing.</param>
 /// <param name="listenerDisposeTimeout">Defines a timeout interval for the flush operation when the listener is disposed.</param>
 /// <param name="maxBufferSize">The maximum number of entries that can be buffered while it's sending to Loggly before the sink starts dropping entries.
 /// This means that if the timeout period elapses, some event entries will be dropped and not sent to the store. Calling <see cref="IDisposable.Dispose" /> on
 /// the <see cref="EventListener" /> will block until all the entries are flushed or the interval elapses.
 /// If <see langword="null" /> is specified, then the call will block indefinitely until the flush operation finishes.</param>
 /// <returns>
 /// An event listener that uses <see cref="LogglySink" /> to log events.
 /// </returns>
 public static EventListener CreateListener(string instanceName, string connectionString, string customerToken, string tag, bool flattenPayload,
     TimeSpan? bufferingInterval = null, TimeSpan? listenerDisposeTimeout = null, int maxBufferSize = Buffering.DefaultMaxBufferSize)
 {
     var listener = new ObservableEventListener();
     listener.LogToLoggly(instanceName, connectionString, customerToken, tag, flattenPayload, 
         bufferingInterval, listenerDisposeTimeout, maxBufferSize);
     return listener;
 }
开发者ID:chrduf,项目名称:SemanticLogging.LogglySink,代码行数:25,代码来源:LogglyLog.cs


示例14: 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


示例15: 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(ChannelEventSource.Log, EventLevel.Verbose);
            eventListener.EnableEvents(BootstrapEventSource.Log, EventLevel.Verbose);
            eventListener.EnableEvents(ExecutorEventSource.Log, EventLevel.Verbose);
            eventListener.EnableEvents(MqttEventSource.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:nberdy,项目名称:azure-iot-protocol-gateway,代码行数:57,代码来源:Program.cs


示例16: 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


示例17: 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


示例18: InitializeDiagnostics

        partial void InitializeDiagnostics()
        {
            var connectionString = RoleEnvironment.GetConfigurationSettingValue(AzureLoggingConfigurationSettingName);

            this.listener = new ObservableEventListener();
            this.listener.LogToWindowsAzureTable(RoleEnvironment.CurrentRoleInstance.Id, connectionString, bufferingInterval: TimeSpan.FromSeconds(30));

            this.SetupListener();
            RoleEnvironment.Changed += RoleEnvironment_Changed;
        }
开发者ID:Brar,项目名称:entlib,代码行数:10,代码来源:Global.asax.slab.cs


示例19: Start

        public static void Start()
        {
            if (_listener != null)
            {
                throw new InvalidOperationException("Logging infrastucture already running");
            }

            _listener = new ObservableEventListener();
            _listener.EnableEvents(EtwSampleServerEventSource.Log, EventLevel.LogAlways);
            _listener.LogToConsole(new SampleFormatter());
        }
开发者ID:jakub-sturc,项目名称:EtwSampleServer,代码行数:11,代码来源:LoggingInfrastructure.cs


示例20: 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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# ObservableList类代码示例发布时间:2022-05-24
下一篇:
C# ObservableDummy类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap