Ejemplo n.º 1
0
 public static IStringLayoutBuilder ColorConsole(this StringOutputer stringOutputer, Func<IConsoleBuilder, object> s)
 {
     ConsoleBuilder consoleBuilder = new ConsoleBuilder(((IStringOutputer)stringOutputer).ExecutionMode);
     s.Invoke(consoleBuilder);
     ((IStringOutputer) stringOutputer).AddLogger(consoleBuilder);
     return ((IStringOutputer)stringOutputer).Source;
 }
Ejemplo n.º 2
0
 public void Construct(ConsoleBuilder consoleBuilder)
 {
     consoleBuilder.AddName();
     consoleBuilder.AddGraphicsCard();
     consoleBuilder.AddProcessor();
     consoleBuilder.AddMemory();
     consoleBuilder.AddRam();
 }
Ejemplo n.º 3
0
 static Task Main(string[] args) =>
 // create console application with default settings
 ConsoleBuilder.CreateDefaultBuilder()
 // execute the app class on run
 .Execute <App>()
 // build the console app
 .Build()
 // run the app
 .Run(args);
Ejemplo n.º 4
0
 static void Main(string[] args)
 {
     var consoleBuilder = new ConsoleBuilder();
     var console        = consoleBuilder
                          .WithHardDrive("512 GB")
                          .WithNetwork("802.11ac")
                          .WithUsb("USB 3.1")
                          .WithHdmi()
                          .Build();
 }
Ejemplo n.º 5
0
        public void Console()
        {
            var             maxLine = 5;
            IConsoleBuilder builder = new ConsoleBuilder()
            {
                MaxLine = maxLine,
            };

            Enumerable.Range(0, 10).ToList().ForEach(x => builder.AppendLine(x.ToString() + "_" + Random2.GenerateRandomString(Random2.Next(1, x + 2))));
            var str   = builder.ToString();
            var array = str.Split(Environment.NewLine);

            TestContext.Write(str);
            Assert.IsTrue(maxLine == array.Length);
        }
Ejemplo n.º 6
0
        static IConsole Build() =>
        ConsoleBuilder.CreateDefaultBuilder()
        .ConfigureServices((context, services) =>
        {
            var mapper   = new TypeMapper();
            var assembly = typeof(Program).Assembly;
            mapper.MapEventImplementations(assembly);
            mapper.MapAggregateImplementations(assembly);

            services.AddSingleton <ITypeMapper>(mapper);
            services.AddSingleton <IEventStore, EventStore>();
            services.AddTransient <IPendingEventFactory, PendingEventFactory>();
            services.AddTransient <IRepository <BankAccount>, Repository <BankAccount> >();
        })
        .Execute <App>()
        .Build();
Ejemplo n.º 7
0
 static Task Main(string[] args) =>
 // create console application with default settings
 ConsoleBuilder.CreateDefaultBuilder()
 // configure dependency injection
 .ConfigureServices(services =>
 {
     // register ef core with dependency injection
     services.AddDbContext <ApplicationDbContext>(options => options.UseInMemoryDatabase("ApplicationDb"));
 })
 // execute the add users class on run
 .Execute <AddUsersFromConfiguration>()
 // execute the log users class on run
 .Execute <LogUsersInDatabase>()
 // build the console app
 .Build()
 // run the console app
 .Run(args);
Ejemplo n.º 8
0
        static IConsole Build() =>
        ConsoleBuilder.CreateDefaultBuilder()
        .ConfigureServices((context, services) =>
        {
            services.AddTransient <IEventSerializer, JsonEventSerializer>();

            var mapper = new TypeMapper();
            mapper.MapEventImplementations(typeof(Program).Assembly);
            mapper.MapAggregateImplementations(typeof(Program).Assembly);

            services.AddSingleton <ITypeMapper>(mapper);
            services.AddDbContext <IEventStore, EventStore>(options => options.UseSqlServer(context.Configuration.GetConnectionString("EventStore")));
            services.AddTransient <IPendingEventFactory, PendingEventFactory>();
            services.AddTransient <IRepository <Order>, Repository <Order> >();
        })
        //.Execute<CreateOrders>()
        .Execute <TestOrder>()
        .Execute <TestThroughput>()
        //.Execute<LogEvents>()
        .Build();
Ejemplo n.º 9
0
        static IConsole Build() =>
        ConsoleBuilder.CreateDefaultBuilder()
        .ConfigureServices((context, services) =>
        {
            services.AddTransient <IEventSerializer, JsonEventSerializer>();

            var mapper = new TypeMapper();
            mapper.MapEventImplementations(typeof(ShoppingCart).Assembly);
            mapper.MapAggregateImplementations(typeof(ShoppingCart).Assembly);

            services.AddSingleton(new EventStoreOptions()
            {
                ConnectionString = context.Configuration.GetConnectionString("EventStore")
            });
            services.AddSingleton <ITypeMapper>(mapper);
            services.AddTransient <IEventStore, EventStore>();
            services.AddSingleton <IEventReactor, EventReactor>();
        })
        //.Execute<LogLiveEventsReactively>()
        .Execute <LogLiveEventsByPolling>()
        .Build();
Ejemplo n.º 10
0
        public void ConsoleException()
        {
            var             maxLine = 7;
            IConsoleBuilder builder = new ConsoleBuilder()
            {
                MaxLine = maxLine,
            };

            builder.AppendLine(new Exception("aaaaa").ToStringThrow());
            builder.AppendLine(new AccessViolationException("bbbb").ToStringThrow());
            builder.AppendLine(new AggregateException("ddd").ToStringThrow());
            builder.AppendLine(new IndexOutOfRangeException("ffff").ToStringThrow());
            builder.AppendLine(new ArgumentOutOfRangeException("ggg").ToStringThrow());
            builder.AppendLine(new BadImageFormatException("zzzz").ToStringThrow());
            builder.AppendLine(new DllNotFoundException("qqqqqqq").ToStringThrow());
            var str   = builder.ToString();
            var array = str.Split(Environment.NewLine);

            TestContext.Write(str);
            Assert.IsTrue(maxLine == array.Length);
        }
Ejemplo n.º 11
0
        static IConsole Build() =>
        ConsoleBuilder.CreateDefaultBuilder()
        .ConfigureServices((context, services) =>
        {
            services.AddTransient <IEventSerializer, JsonEventSerializer>();

            var mapper = new TypeMapper();
            mapper.MapEventImplementations(typeof(Program).Assembly);
            mapper.MapAggregateImplementations(typeof(Program).Assembly);

            services.AddSingleton(new EventStoreOptions()
            {
                ConnectionString = context.Configuration.GetConnectionString("EventStore")
            });
            services.AddSingleton <ITypeMapper>(mapper);
            services.AddTransient <IEventStore, EventStore>();
            services.AddTransient <IPendingEventFactory, PendingEventFactory>();
            services.AddTransient <IRepository <ShoppingCart>, Repository <ShoppingCart> >();
        })
        .Execute <RepositoryThroughput>()
        .Execute <EventStoreThroughput>()
        .Build();
Ejemplo n.º 12
0
        static IConsole Build() =>
        ConsoleBuilder.CreateDefaultBuilder()
        .ConfigureServices((context, services) =>
        {
            services.AddTransient <IEventSerializer, JsonEventSerializer>();

            var mapper = new TypeMapper();
            mapper.MapEventImplementations(typeof(Program).Assembly);
            mapper.MapAggregateImplementations(typeof(Program).Assembly);

            services.AddSingleton <ITypeMapper>(mapper);

            var connection = EventStoreConnection.Create(new IPEndPoint(IPAddress.Loopback, 1113));
            connection.ConnectAsync().Wait();

            services.AddSingleton(connection);

            services.AddTransient <IEventStore, EventSourcR.EventStore.EventStore>();
            services.AddTransient <IPendingEventFactory, PendingEventFactory>();
            services.AddTransient <IRepository <Ticket>, Repository <Ticket> >();
        })
        .Execute <TestThroughput>()
        .Build();
Ejemplo n.º 13
0
        static void Main(string[] args)
        {
            while (true)
            {
                points = 0;
                LevelEnum level = Menu.GetMenu();

                object   writerMutex = new object();
                IBuilder builder     = new ConsoleBuilder();
                var      mlist       = new Map(level, builder);


                var map = mlist.getMap() as List <LinkedList <IField> >;
                mlist.GetElems(ref keys, ref doors, ref coins, ref exit);
                Console.Clear();
                Console.SetWindowSize(150, 30);
                Console.Clear();

                for (int i = 0; i < map.Count; i++)
                {
                    foreach (var elem in map[i])
                    {
                        if (elem is KCKProjectAPI.Path)
                        {
                            Console.ForegroundColor = ConsoleColor.Black;
                        }
                        else if (elem is Wall)
                        {
                            Console.ForegroundColor = ConsoleColor.Red;
                        }
                        Console.Write(elem);
                    }
                    Console.Write('\n');
                }
                Console.ForegroundColor = ConsoleColor.White;
                Cursor.WriteString(map[0].Count + 3, 1, "Points: 0");
                Cursor.WriteString(map[0].Count + 3, 2, "Keys:   0");
                Console.ForegroundColor = ConsoleColor.White;
                Cursor.CursorFun(exit.x, exit.y, 'E');

                foreach (var key in keys)
                {
                    Console.ForegroundColor = ConsoleColor.Blue;
                    Cursor.CursorFun(key.x, key.y, 'K');
                }

                foreach (var door in doors)
                {
                    Console.ForegroundColor = ConsoleColor.DarkGray;
                    Cursor.CursorFun(door.x, door.y, 'D');
                }


                Thread CoinRotateThread = new Thread(() => ThreadProcClass.ThreadProcCoin(coins, ref writerMutex));
                CoinRotateThread.Start();

                Console.ForegroundColor = ConsoleColor.White;

                Console.CursorVisible = false;


                Player p = new Player {
                    X = 2, Y = 9
                };
                object mutex = new object();

                Thread PlayerThread = new Thread(() => ThreadProcClass.ThreadProcPlayer(ref p, ref mlist, ref ownedKeys, ref keys, ref doors, ref coins, ref exit, ref writerMutex, ref points));
                PlayerThread.Start();

                PlayerThread.Join();

                lock (writerMutex)
                {
                    coins.Clear();
                }
                Console.Clear();
                EndGameMenu.getMenu(points);
                Console.Clear();
            }
        }