public void GetFileInfo_Test_txt_Text()
        {
            var fileProvider =
                new RelativeFileProvider(
                    new EmbeddedFileProvider(typeof(RelativeFileProviderTest).Assembly),
                    @"relative\path");

            var file = fileProvider.GetFileInfo(@"file.ext");

            Assert.IsFalse(file.Exists);
            Assert.IsTrue(SoftString.Comparer.Equals(@"Reusable\Tests\relative\path\file.ext", file.Path));
            //Assert.AreEqual("Resource1", file.ReadAllTextAsync().GetAwaiter().GetResult());
        }
Exemple #2
0
        public static void SemanticExtensions()
        {
            SmartPropertiesLayoutRenderer.Register();

            var fileProvider = new RelativeFileProvider(new PhysicalFileProvider(), typeof(Demo).Assembly.Location);

            var loggerFactory =
                new LoggerFactory()
                .UseSemanticExtensions("development", "Reusable.Apps.Console")
                .AddObserver <NLogRx>();
            //.UseConfiguration(LoggerFactoryConfiguration.Load(fileProvider.GetFileInfo(@"cfg\omnilog.json").CreateReadStream()));

            var logger = loggerFactory.CreateLogger("Demo");

            logger.Log(Abstraction.Layer.Infrastructure().Routine("SemLogTest").Running());

            // Opening outer-transaction.
            using (logger.BeginScope().WithCorrelationId().WithCorrelationContext(new { Name = "OuterScope", CustomerId = 123 }).AttachElapsed())
            {
                // Logging some single business variable and a message.
                logger.Log(Abstraction.Layer.Business().Variable(new { foo = "bar" }), log => log.Message("Hallo variable!"));

                // Opening innter-transaction.
                using (logger.BeginScope().WithCorrelationId().WithCorrelationContext(new { Name = "InnerScope", ItemId = 456 }).AttachElapsed())
                {
                    // Logging an entire object in a single line.
                    var customer = new { FirstName = "John", LastName = "Doe" };
                    logger.Log(Abstraction.Layer.Business().Variable(new { customer }));

                    // Logging multiple variables in a single line.
                    var baz = 123;
                    var qux = "quux";

                    logger.Log(Abstraction.Layer.Infrastructure().Composite(new { multiple = new { baz, qux } }));

                    // Logging action results.
                    logger.Log(Abstraction.Layer.Infrastructure().Routine("DoSomething").Running());
                    logger.Log(Abstraction.Layer.Infrastructure().Routine("DoSomething").Canceled(), "No connection.");
                    logger.Log(Abstraction.Layer.Infrastructure().Routine("DoSomething").Faulted(), new DivideByZeroException("Cannot divide."));
                }
            }
        }