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


C# ConsoleLogger类代码示例

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


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

示例1: GetCategoryService

		private ICategoryService GetCategoryService(UnitOfWork uow) {
			ICategoryRepository cateRepo = new CategoryRepository(uow);

			IState request = new DummyRequest();

			ILogger logger = new ConsoleLogger();

			IUserRepository userRepo = new UserRepository(uow);
			User user = userRepo.Create(new User {
				Name = "D. Ummy",
				ProviderId = "12345678",
				FullName = "Mr. Doh Ummy",
				EmailAddress = "[email protected]",
				Culture = "th-TH",
				TimeZone = "GMT Standard Time"
			});

			List<IEventSubscriber> subscribers = new List<IEventSubscriber>();

			IEventPublisher eventPublisher = new EventPublisher(subscribers, logger, request);
			IUserProvider userProvider = new DummyUserProvider(user);
			IPermissionService permService = new PermissionService();

			return new CategoryService(userProvider, cateRepo, eventPublisher, logger, permService);
		}
开发者ID:razzles67,项目名称:NForum,代码行数:25,代码来源:SetGetTests.cs

示例2: ComposeModules

        static void ComposeModules()
        {
            //Bootstrapping section
            //Wherein we select the modules this application will use.
            //This is referred to as the "composition root" of a modular application.
            //There are several ways of implementing it, but I'm doing the simple route of hard coding the modules.

            var defaultLogger = new ConsoleLogger();
            var defaultItemRepository = new ItemRepository();

            _defaultWorkflowEngine = new WorkflowEngine(defaultLogger);

            _defaultWorkflowProducer = new WorkflowProducer
                (
                    new FooWorkflowFactory
                        (
                            defaultItemRepository,
                            new FooProcessor(),
                            new FooSender(defaultLogger)
                        ),
                    new BarWorkflowFactory
                        (
                            defaultItemRepository,
                            new RecordDeleter(defaultLogger)
                        )
                );
        }
开发者ID:sphavens,项目名称:disample,代码行数:27,代码来源:Program.cs

示例3: Main

        static void Main(string[] args)
        {
            calculator culc = new calculator();

            //--- Add logers
            ConsoleLogger cLogger = new ConsoleLogger();
            culc.OperationCompleted += cLogger.Log;
            culc.OperationFailed += cLogger.Log;

            FileLogger fLogger = new FileLogger(@"D:\LogFile.log");
            culc.OperationCompleted += fLogger.Log;
            culc.OperationFailed += fLogger.Log;
            //----------------------------------------------------

            string operation = string.Empty;
            string arg1 = string.Empty;
            string arg2 = string.Empty;
            Console.WriteLine("Enter argument 1:\r\n");
            arg1 = Console.ReadLine();
            Console.WriteLine("Enter argument 2:\r\n");
            arg2 = Console.ReadLine();
            Console.WriteLine("Enter operation(+,-,*,/):\r\n");
            operation = Console.ReadLine();

            culc.DoOperation(operation, arg1, arg2);

            Console.ReadLine();
        }
开发者ID:AndreyZelik,项目名称:Lesson_4,代码行数:28,代码来源:Program.cs

示例4: ClearMeABus

        private void ClearMeABus()
        {
            // Filter types we care about to only our own test's namespace. It's a performance optimisation because creating and
            // deleting queues and topics is slow.
            var typeProvider = new TestHarnessTypeProvider(new[] {GetType().Assembly}, new[] {"Some.Namespace.That.Does.Not.Exist"});
            var messageBroker = new DefaultMessageHandlerFactory(typeProvider);

            var logger = new ConsoleLogger();

            var busBuilder = new BusBuilder().Configure()
                                             .WithNames("IntegrationTestHarness", Environment.MachineName)
                                             .WithConnectionString(CommonResources.ConnectionString)
                                             .WithTypesFrom(typeProvider)
                                             .WithCommandHandlerFactory(messageBroker)
                                             .WithRequestHandlerFactory(messageBroker)
                                             .WithMulticastEventHandlerFactory(messageBroker)
                                             .WithCompetingEventHandlerFactory(messageBroker)
                                             .WithMulticastRequestHandlerFactory(messageBroker)
                                             .WithDefaultTimeout(TimeSpan.FromSeconds(10))
                                             .WithLogger(logger)
                                             .WithDebugOptions(
                                                 dc =>
                                                     dc.RemoveAllExistingNamespaceElementsOnStartup(
                                                         "I understand this will delete EVERYTHING in my namespace. I promise to only use this for test suites."))
                ;

            using (var bus = busBuilder.Build())
            {
                bus.Start();
            }
        }
开发者ID:shingi,项目名称:Nimbus,代码行数:31,代码来源:WhenCreatingMultipleBusInstancesPointedAtTheSameEndpoint.cs

示例5: SendHttpRequest

        public async Task SendHttpRequest()
        {

            // Arrange
            var httpRequestMessage = new HttpRequestMessage() {
                RequestUri = new Uri("http://example.com/foo")
            };

            var httpMessage = new HttpMessage()
            {
                IsRequest = true,
                HttpRequestMessage = httpRequestMessage
            };

            var consoleLogger = new ConsoleLogger();
            var fakeMessageHandler = new FakeMessageHandler();
            var httpClient = new HttpClient(fakeMessageHandler);
            httpClient.BaseAddress = new Uri("http://api.runscope.com/");

            var message = new RunscopeHttpMessageProcessor(httpClient,consoleLogger);

            // Act
            await message.ProcessHttpMessage(httpMessage);

            // Assert
            Assert.NotNull(fakeMessageHandler.LastResponseMessage);
            Assert.Equal("api.runscope.com", fakeMessageHandler.LastResponseMessage.RequestMessage.RequestUri.Host);
        }
开发者ID:darrelmiller,项目名称:ApimEventProcessor,代码行数:28,代码来源:RunscopeHttpMessageProcessorTests.cs

示例6: ProcessCommand

		static bool ProcessCommand(IEnumerable<string> args)
		{
			if (args.Count() == 0)
				return true;
			ILogger logger = new ConsoleLogger(false);
			var commandName = args.First().ToLowerInvariant();
			args = args.Skip(1);
			switch (commandName) {
				case "quit":
				case "q":
				case "exit":
				case "e":
					return false;
				case "help":
				case "?":
					return HelpCommand(logger, args);
				default:
					foreach (ICommand command in _commands)
						if (command.Matches(commandName))
							using (logger.Block)
								return command.Process(logger, args, _metaProjectPersistence, _components, PackagesOutputDirectory);
					break;
			}
			logger.Error("Unknown command '{0}'", commandName);
			return true;
		}
开发者ID:monoman,项目名称:NugetCracker,代码行数:26,代码来源:Program.cs

示例7: CreateAndStart

        public async Task<Bus> CreateAndStart()
        {
            var logger = new ConsoleLogger();
            //var logger = new NullLogger();

            // Filter types we care about to only our own test's namespace. It's a performance optimisation because creating and
            // deleting queues and topics is slow.
            var typeProvider = new TestHarnessTypeProvider(new[] {_testFixtureType.Assembly}, new[] {_testFixtureType.Namespace});

            var bus = new BusBuilder().Configure()
                                      .WithNames("MyTestSuite", Environment.MachineName)
                                      .WithConnectionString(CommonResources.ServiceBusConnectionString)
                                      .WithTypesFrom(typeProvider)
                                      .WithGlobalInboundInterceptorTypes(typeProvider.InterceptorTypes.Where(t => typeof(IInboundInterceptor).IsAssignableFrom(t)).ToArray())
                                      .WithGlobalOutboundInterceptorTypes(typeProvider.InterceptorTypes.Where(t => typeof(IOutboundInterceptor).IsAssignableFrom(t)).ToArray())
                                      .WithDependencyResolver(new DependencyResolver(typeProvider))
                                      .WithDefaultTimeout(TimeSpan.FromSeconds(10))
                                      .WithLogger(logger)
                                      .WithDebugOptions(
                                          dc =>
                                              dc.RemoveAllExistingNamespaceElementsOnStartup(
                                                  "I understand this will delete EVERYTHING in my namespace. I promise to only use this for test suites."))
                                      .Build();
            await bus.Start(MessagePumpTypes.All);

            return bus;
        }
开发者ID:mneelakanta,项目名称:Nimbus,代码行数:27,代码来源:TestHarnessBusFactory.cs

示例8: SetUp

        public void SetUp()
        {
            var connectionFactory = new ConnectionFactoryWrapper(new ConnectionFactory
            {
                HostName = "localhost",
                VirtualHost = "/",
                UserName = "guest",
                Password = "guest"
            });

            var serializer = new JsonSerializer();
            var logger = new ConsoleLogger();
            var consumerErrorStrategy = new DefaultConsumerErrorStrategy(connectionFactory, serializer, logger);
            var conventions = new Conventions();

            advancedBus = new RabbitAdvancedBus(
                connectionFactory,
                TypeNameSerializer.Serialize,
                serializer,
                new QueueingConsumerFactory(logger, consumerErrorStrategy),
                logger,
                CorrelationIdGenerator.GetCorrelationId,
                conventions);

            while (!advancedBus.IsConnected)
            {
                Thread.Sleep(10);
            }
        }
开发者ID:negy,项目名称:EasyNetQ,代码行数:29,代码来源:RabbitAdvancedBusTests.cs

示例9: Main

        public static void Main()
        {
            Console.Write("Enter pass: ");
            string password = Console.ReadLine();

            // Change connection string with your database name
            string connectionString = "Server=localhost;Database=library;Uid=root;Pwd=" + password + ";";

            MySqlLibraryProvider provider = new MySqlLibraryProvider(connectionString);
            ILogger logger = new ConsoleLogger();

            // List all books
            provider.ListBooks(logger);

            // Add new book
            string title = "It";
            bool isBookAdded = provider.AddBook(title, 2, new DateTime(), "A2123143234");
            if (isBookAdded)
            {
                logger.Log("Book added!");
            }

            // Get book by title
            string bookAsString = provider.GetBookByTitle(title);
            logger.Log("Book:");
            logger.Log(bookAsString);
        }
开发者ID:VDGone,项目名称:TelerikAcademy-1,代码行数:27,代码来源:MySqlLibrary.cs

示例10: ConsoleLoggerCanLogMessagesToConsole

        public void ConsoleLoggerCanLogMessagesToConsole()
        {
            string msg_text = "This is a test.";
            string actual = String.Empty;

            ConsoleLogger cl = new ConsoleLogger();

            TextWriter old_out = Console.Out;
            using (MemoryStream ms = new MemoryStream())
            {
                using (StreamWriter sw = new StreamWriter(ms, Encoding.UTF8, 512, true))
                {
                    Console.SetOut(sw);

                    cl.Log(new GeneralMessage(msg_text));
                }

                ms.Position = 0;
                using (StreamReader reader = new StreamReader(ms, Encoding.UTF8, true))
                {
                    actual = reader.ReadToEnd();
                }
            }

            Console.SetOut(old_out);

            Assert.AreEqual(msg_text + Environment.NewLine, actual);
        }
开发者ID:rbenitti,项目名称:InterviewCodeReview,代码行数:28,代码来源:ConsoleLoggerTests.cs

示例11: DomainServiceCatalog_Ctors

        public void DomainServiceCatalog_Ctors()
        {
            IEnumerable<string> empty = new string[0];
            ConsoleLogger logger = new ConsoleLogger();

            // Ctor taking assemblies -- null arg tests
            ExceptionHelper.ExpectArgumentNullExceptionStandard(() => new DomainServiceCatalog((IEnumerable<string>)null, logger), "assembliesToLoad");
            ExceptionHelper.ExpectArgumentNullExceptionStandard(() => new DomainServiceCatalog(empty, null), "logger");

            // Ctor taking one type -- null arg tests
            ExceptionHelper.ExpectArgumentNullExceptionStandard(() => new DomainServiceCatalog((Type) null, logger), "domainServiceType");
            ExceptionHelper.ExpectArgumentNullExceptionStandard(() => new DomainServiceCatalog(typeof(DSC_DomainServiceType), null), "logger");

            // Ctor taking multiple types -- null arg tests
            ExceptionHelper.ExpectArgumentNullExceptionStandard(() => new DomainServiceCatalog((IEnumerable<Type>)null, logger), "domainServiceTypes");
            ExceptionHelper.ExpectArgumentNullExceptionStandard(() => new DomainServiceCatalog(new Type[] {typeof(DSC_DomainServiceType)}, null), "logger");

            // Ctor taking assemblies -- legit
            string[] realAssemblies = new string[] { this.GetType().Assembly.Location,
                                                     typeof(string).Assembly.Location };

            // Assembly based ctors are tested more deeply in other test methods

            // Ctor taking one type -- legit
            DomainServiceCatalog dsc = new DomainServiceCatalog(typeof(DSC_DomainServiceType), logger);
            IEnumerable<DomainServiceDescription> descriptions = dsc.DomainServiceDescriptions;
            Assert.IsNotNull(descriptions, "Did not expect null descriptions");
            Assert.AreEqual(1, descriptions.Count(), "Expected exactly one domain service description");

            // Ctor taking multiple type -- legit
            dsc = new DomainServiceCatalog(new Type[] {typeof(DSC_DomainServiceType)}, logger);
            descriptions = dsc.DomainServiceDescriptions;
            Assert.IsNotNull(descriptions, "Did not expect null descriptions");
            Assert.AreEqual(1, descriptions.Count(), "Expected exactly one domain service description");
        }
开发者ID:OpenRIAServices,项目名称:OpenRiaServices,代码行数:35,代码来源:DomainServiceCatalogTests.cs

示例12: Just_verify_the_regular_write

        public void Just_verify_the_regular_write()
        {

            var sut = new ConsoleLogger(GetType());
            sut.Debug("Hello world");

        }
开发者ID:GitItInTheHub,项目名称:Griffin.Framework,代码行数:7,代码来源:ConsoleLoggerTests.cs

示例13: Just_verify_exception_Write

        public void Just_verify_exception_Write()
        {

            var sut = new ConsoleLogger(GetType());
            sut.Debug("Hello world", new Exception());

        }
开发者ID:GitItInTheHub,项目名称:Griffin.Framework,代码行数:7,代码来源:ConsoleLoggerTests.cs

示例14: Just_verify_formatted_Write

        public void Just_verify_formatted_Write()
        {

            var sut = new ConsoleLogger(GetType());
            sut.Debug("Hello {0}", "world");

        }
开发者ID:GitItInTheHub,项目名称:Griffin.Framework,代码行数:7,代码来源:ConsoleLoggerTests.cs

示例15: ClientCodeGenerationDispatcher_Finds_Derived_Custom

        public void ClientCodeGenerationDispatcher_Finds_Derived_Custom()
        {
            ConsoleLogger logger = new ConsoleLogger();
            ClientCodeGenerationOptions options = new ClientCodeGenerationOptions()
            {
                Language = "G#"
            };

            ICodeGenerationHost host = TestHelper.CreateMockCodeGenerationHost(logger, /*sharedTypeService*/ null);

            // Create a new dispatcher and call an internal extensibility point to add ourselves
            // into the MEF composition container
            using (ClientCodeGenerationDispatcher dispatcher = new ClientCodeGenerationDispatcher())
            {
                string[] compositionAssemblies = new string[] { Assembly.GetExecutingAssembly().Location };

                IDomainServiceClientCodeGenerator generator = dispatcher.FindCodeGenerator(host, options, compositionAssemblies, MockGSharpCodeGeneratorDerived.GeneratorName);
                Assert.IsNotNull(generator, "the dispatcher did not find any code generator");
                Assert.AreEqual(generator.GetType(), typeof(MockGSharpCodeGeneratorDerived), "dispatcher found " + generator.GetType() + " but should have found MockGSharpCodeGeneratorDerived");

                string generatedCode = generator.GenerateCode(host, Enumerable.Empty<DomainServiceDescription>(), options);

                Assert.AreEqual(MockGSharpCodeGeneratorDerived.DerivedGeneratedCode, generatedCode, "test code generator did not generate expected code.");
            }
        }
开发者ID:OpenRIAServices,项目名称:OpenRiaServices,代码行数:25,代码来源:ClientCodeGenerationDispatcherTests.cs


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