本文整理汇总了C#中ConsoleLogger类的典型用法代码示例。如果您正苦于以下问题:C# ConsoleLogger类的具体用法?C# ConsoleLogger怎么用?C# ConsoleLogger使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ConsoleLogger类属于命名空间,在下文中一共展示了ConsoleLogger类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: ConfigureLogging
private static void ConfigureLogging(ContainerBuilder containerBuilder)
{
//var endpoint = new Uri(ConfigurationManager.AppSettings.Get("DocumentDbEndpoint"));
//var seed = ConfigurationManager.AppSettings.Get("DocumentDbSeed");
//ILogger seriLogger;
//try
//{
// seriLogger = new LoggerConfiguration()
// .WriteTo.AzureDocumentDB(endpoint, seed)
// .WriteTo.RollingFile("CheckSwpProject.log")
// .CreateLogger();
//}
//catch (Exception)
//{
// seriLogger = new LoggerConfiguration()
// .WriteTo.RollingFile("CheckSwpProject.log")
// .CreateLogger();
//}
var seriLogger = new LoggerConfiguration()
.WriteTo.RollingFile("CheckSwpProject.log")
.CreateLogger();
var consoleLogger = new ConsoleLogger(seriLogger);
containerBuilder.RegisterInstance(consoleLogger).As<ILoggerFacade>().SingleInstance();
}
开发者ID:fhtw-swp-tutorium,项目名称:dotNet-swp-test-tool,代码行数:29,代码来源:ContainerConfig.cs
示例17: Setup
public void Setup()
{
RenderConfigConfig config = GetConfigObject();
IRenderConfigLogger log = new ConsoleLogger();
RenderConfigEngine engine = new RenderConfigEngine(config, log);
engine.Render();
}
开发者ID:modulexcite,项目名称:renderconfig,代码行数:7,代码来源:IniFileModifierTests.cs
示例18: CreateLogger
/// <summary>
/// Creates an instance of the <see cref="ConsoleLogger"/> using
/// the specified <paramref name="options"/> object.
/// </summary>
/// <param name="options">
/// A <see cref="IDictionary{TKey,TValue}"/> object that contains the
/// options for the logger to be created.
/// </param>
/// <returns>
/// The newly created <see cref="ILogger"/> object.
/// </returns>
public ILogger CreateLogger(IDictionary<string, string> options) {
string layout_pattern = ProviderOptions.GetIfExists(options,
Strings.kLayoutPattern, AbstractLogger.kDefaultLogMessagePattern);
ConsoleLogger logger = new ConsoleLogger(layout_pattern);
logger.Configure();
return logger;
}
开发者ID:joethinh,项目名称:nohros-must,代码行数:18,代码来源:ConsoleLoggerFactory.cs
示例19: TranslateDocuments
/// <summary>
/// Initializes a new instance of the <see cref="TranslateDocuments" /> class.
/// </summary>
/// <param name="Logger">
/// The logger.
/// </param>
public TranslateDocuments(ConsoleLogger Logger)
: base(Logger)
{
TranslationServiceFacade.Initialize();
if (!TranslationServiceFacade.IsTranslationServiceReady())
{
this.Logger.WriteLine(LogLevel.Error, "Invalid translation service credentials. Use \"DocumentTranslatorCmd setcredentials\", or use the Document Translator Settings option.");
}
this.sourceDocuments = new SimpleStringArgument(
"SourceDocuments",
true,
new[] { ',' },
"Document to translate, or list of documents separated by comma, or a wildcard. Wildcard recurses through subfolders.");
this.sourceLanguage = new Argument(
"SourceLanguage",
false,
new[] { "Auto-Detect" },
TranslationServiceFacade.AvailableLanguages.Keys.ToArray(),
true,
"The source language. Auto-detect if no language specified.");
this.targetLanguages = new SimpleStringArgument(
"TargetLanguages",
true,
new string[] { },
TranslationServiceFacade.AvailableLanguages.Keys.ToArray(),
new[] { ',' },
"The target language code, or comma-separated list of language codes.");
this.Arguments = new ArgumentList(
new[] { this.sourceDocuments, this.sourceLanguage, this.targetLanguages },
Logger);
}
开发者ID:nitish-ms,项目名称:DocumentTranslator,代码行数:41,代码来源:TranslateDocuments.cs
示例20: Main
static void Main()
{
ILogger logger = new ConsoleLogger();
logger.WriteLine("First sequence");
var seqGen = Enumerable.Range(0, 10).Aggregate(
new FibSequence(),
(seqGenerator, iter) => {
logger.WriteLine(seqGenerator.Value);
return seqGenerator.Next();
});
var memento = ((ISaveable)seqGen).GetMemento();
logger.WriteLine("Second sequence[continued]");
Enumerable.Range(0, 10).Aggregate(
seqGen,
(seqGenerator, iter) => {
logger.WriteLine(seqGenerator.Value);
return seqGenerator.Next();
});
logger.WriteLine("Third sequence[from memento - should be like 2nd]");
Enumerable.Range(0, 10).Aggregate(
new FibSequence(memento),
(seqGenerator, iter) => {
logger.WriteLine(seqGenerator.Value);
return seqGenerator.Next();
});
Console.ReadLine();
}
开发者ID:lemmit,项目名称:DesignPatternsUsingImmutableClasses,代码行数:29,代码来源:Program.cs
注:本文中的ConsoleLogger类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论