Ejemplo n.º 1
0
    private void LoadCommandTool()
    {
        string       path      = Storage.Instance.DataPathUserData;
        CommandStore storeComm = Serializator.LoadXml <CommandStore>(path);

        if (storeComm == null)
        {
            Debug.Log("############ LoadCommandTool storeComm is Empty  path=" + path);
            return;
        }
        else
        {
            if (storeComm.CommadsTemplate == null)
            {
                Debug.Log("############ LoadCommandTool storeComm  CommadsTemplate is Empty");
                return;
            }
            if (storeComm.CommadsTemplate.Count == 0)
            {
                Debug.Log("---- LoadCommandTool storeComm  CommadsTemplate is zero");
                return;
            }
            ClearAllCommandButtonsTool();
            foreach (string nameCommand in storeComm.CommadsTemplate)
            {
                CreateCommandLogButton(nameCommand, Color.white, ContentListLogCommand.transform, null, true);
            }

            //Debug.Log("---- LoadCommandTool Loaded..........");
        }
    }
Ejemplo n.º 2
0
    void GenerateAndOutput(CrossGenerator generator, CommandStore commands, int maxSolutionsCount)
    {
        int solutionsCount = 0;

        foreach (var solution in generator.Generate())
        {
            lock (commands.Lock)
            {
                Console.WriteLine($"Solution {solutionsCount} found:");
                using (var w = OpenConsoleWriter())
                    solution.WriteTo(w);
            }

            if (++solutionsCount == maxSolutionsCount)
            {
                Console.WriteLine($"{solutionsCount} solutions found.");
                break;
            }
        }

        if (solutionsCount == 0)
        {
            Console.WriteLine("Solution not found:");
        }
    }
Ejemplo n.º 3
0
        public void RolledBackCommandsAreSkipped(Tuple <List <JournalEntry>, string> testCase)
        {
            ICommandStore target = new InMemoryCommandStore(EngineConfiguration.Create().ForIsolatedTest());

            string failureMessage = testCase.Item2;
            var    testEntries    = testCase.Item1;

            //Act
            var actualCommandEntries = CommandStore.CommittedCommandEntries(() => testEntries).ToArray();

            ulong[] rolledBackIds = testEntries.OfType <JournalEntry <RollbackMarker> >().Select(e => e.Id).ToArray();
            int     expectedNumberOfCommandEntries = testEntries.Count - rolledBackIds.Length * 2;

            //Assert
            Assert.AreEqual(expectedNumberOfCommandEntries, actualCommandEntries.Length, failureMessage);

            ulong sequentialId = 1;

            foreach (JournalEntry <Command> journalEntry in actualCommandEntries)
            {
                if (!rolledBackIds.Contains(sequentialId))
                {
                    //TODO: Maybe we should return no-op commands instead of skipping rolled back
                    ulong expectedId = sequentialId + (ulong)rolledBackIds.Count(id => id < journalEntry.Id);
                    Assert.AreEqual(expectedId, journalEntry.Id, failureMessage);
                }
                sequentialId++;
            }
        }
Ejemplo n.º 4
0
        public static CompetencyAggregator GetChartManager()
        {
            if (manager != null)
            {
                return(manager);
            }

            manager = new CompetencyAggregator();

            var commands = CommandStore.ReadAll();

            foreach (var commandEnvelope in commands)
            {
                switch (commandEnvelope.CommandType)
                {
                case Commands.CompetenceUpdateCommandType:
                    var command = commandEnvelope.GetCommand <CompetenceUpdateCommand>();
                    manager.UserCompetenceChange(command);
                    break;

                default:
                    throw new InvalidOperationException();
                }
            }

            return(manager);
        }
Ejemplo n.º 5
0
        private static void Replay()
        {
            CommandStore = CommandStoreHelper.Load();
            Inventory    = InventoryHelper.LoadFromStore(CommandStore);

            InventoryHelper.Save(Inventory);
            CommandStoreHelper.Save(CommandStore);
        }
        public static void Save(CommandStore toSave)
        {
            var xs = new XmlSerializer(typeof(CommandStore));

            using (var fs = File.OpenWrite(Filename))
            {
                xs.Serialize(fs, toSave);
            }
        }
Ejemplo n.º 7
0
        static void Main(string[] args)
        {
            Console.WriteLine("----- ParallelEnvs -----");
            Console.WriteLine("© 2019 Akihisa Yagi");
            Console.WriteLine();

            InitalizeSettings(out var settings);

            CommandStore.Initalize(settings);

            while (true)
            {
                Console.Write("Envs > ");
                var inputs = Separate(Console.ReadLine()).ToArray();

                if (inputs.Length == 0)
                {
                    continue;
                }

                if (inputs[0] == "exit")
                {
                    break;
                }

                Console.WriteLine();

                if (inputs[0] == "help")
                {
                    if (inputs.Length == 1)
                    {
                        foreach (var cmd in CommandStore.Commands)
                        {
                            Console.WriteLine($" - {cmd.CommandName}");
                        }
                    }
                    else
                    {
                        var commandName = inputs[1];
                        var helpText    = CommandStore.Commands
                                          .Where(cmd => (cmd.CommandName == commandName))
                                          .Select(cmd => cmd.Description)
                                          .FirstOrDefault();

                        Console.WriteLine(helpText);
                    }
                }

                var command = CommandStore.Commands
                              .Where(cmd => (cmd.CommandName == inputs[0]))
                              .FirstOrDefault();

                command?.Execute(inputs.Skip(1).ToList());

                Console.WriteLine();
            }
        }
        public static Inventory LoadFromStore(CommandStore store)
        {
            Inventory result = new Inventory(store);

            foreach (var item in store)
            {
                result.ProcessCommand(item);
            }

            return(result);
        }
Ejemplo n.º 9
0
    CrossGenerator CreateGenerator(string file, string dictFile, CommandStore commands)
    {
        DateTime startTime = DateTime.Now;
        var      cb        = CrossBoardCreator.CreateFromFile(file);
        var      dict      = new Dictionary(dictFile, cb.MaxWordLength);

        cb.Preprocess(dict);
        var gen = new CrossGenerator(dict, cb);

        gen.Watcher += GeneratorWatcher;
        return(gen);
    }
Ejemplo n.º 10
0
        private static void InsertTest()
        {
            CommandStore = CommandStoreHelper.Load();
            Inventory    = InventoryHelper.Load(CommandStore);

            var phone  = new InventoryItem("Blackberry Q10", "mobile phone");
            var phone1 = new InventoryItem("Blackberry Q10", "mobile phone");

            Inventory.AddItem(phone);
            Inventory.AddItem(phone1);

            InventoryHelper.Save(Inventory);
            CommandStoreHelper.Save(CommandStore);
        }
        public static CommandStore Load()
        {
            CommandStore result;

            if (!File.Exists(Filename))
            {
                result = new CommandStore();
            }
            else
            {
                var xs = new XmlSerializer(typeof(CommandStore));
                using (FileStream fs = File.OpenRead(Filename))
                {
                    result = (CommandStore)xs.Deserialize(fs);
                }
            }
            return(result);
        }
Ejemplo n.º 12
0
        public static void InitializeTimeline(int snapshotInterval, bool saveAllCommands, string databaseConnectionString, string offlineStorageFolder)
        {
            // Register the tenant and user identification service.

            IdentityService = new IdentityService();

            // Register the implementations for storing and sending commands.

            CommandStore = new CommandStore(new Serializer(), databaseConnectionString);
            CommandQueue = new CommandQueue(CommandStore, IdentityService, saveAllCommands);

            // Register the implementations for storing and publishing events.

            EventStore         = new EventStore(IdentityService, new Serializer(), databaseConnectionString, offlineStorageFolder);
            EventRepository    = new EventRepository(EventStore);
            SnapshotRepository = new SnapshotRepository(EventStore, EventRepository, new SnapshotStore(databaseConnectionString, offlineStorageFolder), new SnapshotStrategy(snapshotInterval));
            EventQueue         = new EventQueue();
        }
Ejemplo n.º 13
0
//#if UNITY_EDITOR
//    //[MenuItem("Assets/Create/SaveCommandTool")]
//    [MenuItem("Assets/Create/SaveCommandTool")]
    public void SaveCommandTool()
    {
        CommandStore storeComm = new CommandStore();

        var listSave = ListCommandsTool.ToList();

        if (listSave != null && listSave.Count > 0)
        {
            storeComm = new CommandStore()
            {
                CommadsTemplate = listSave
            };

            string path = Storage.Instance.DataPathUserData;
            Serializator.SaveXml <CommandStore>(storeComm, path, true);
        }
        Debug.Log("Save Commands Tool count : " + storeComm.CommadsTemplate.Count);
        //ListLogAdd = "Save Commands Tool count : " + storeComm.CommadsTemplate.Count;
    }
        public static Inventory Load(CommandStore commandStore)
        {
            Inventory result;

            if (!File.Exists(Filename))
            {
                result = new Inventory(commandStore);
            }
            else
            {
                var xs = new XmlSerializer(typeof(Inventory));

                using (FileStream fs = File.OpenRead(Filename))
                {
                    result = (Inventory)xs.Deserialize(fs);
                }
            }

            result.CommandStore = commandStore;

            return(result);
        }
        public UserCompetence Get(string userId)
        {
            var persister = new UserCompentencePersister();
            var state     = new UserCompetence.State(userId);
            var commands  = CommandStore.ReadFromStream(userId);

            foreach (var commandEnvelope in commands)
            {
                switch (commandEnvelope.CommandType)
                {
                case Commands.CompetenceUpdateCommandType:
                    var command = commandEnvelope.GetCommand <CompetenceUpdateCommand>();
                    state.Apply(command);
                    break;

                default:
                    throw new InvalidOperationException();
                }
            }


            return(new UserCompetence(state, persister));
        }
Ejemplo n.º 16
0
        public void MenuExample()
        {
            IRoseTree <string, string> editMenuTemplate =
                RoseTree.Node("Edit",
                              RoseTree.Node("Find and Replace",
                                            new RoseLeaf <string, string>("Find"),
                                            new RoseLeaf <string, string>("Replace")),
                              RoseTree.Node("Case",
                                            new RoseLeaf <string, string>("Upper"),
                                            new RoseLeaf <string, string>("Lower")),
                              new RoseLeaf <string, string>("Cut"),
                              new RoseLeaf <string, string>("Copy"),
                              new RoseLeaf <string, string>("Paste"));

            var commandStore = new CommandStore();
            IRoseTree <string, Command> editMenu =
                from name in editMenuTemplate
                select commandStore.Lookup(name);

            var roundTripped = from command in editMenu
                               select command.Name;

            Assert.Equal(editMenuTemplate, roundTripped);
        }
Ejemplo n.º 17
0
        /// <summary>
        /// Get a designated command.
        /// </summary>
        public TCommand GetCommand <TCommand>() where TCommand : ICommand
        {
            var command = CommandStore.GetCommand <TCommand>();

            return(command);
        }
Ejemplo n.º 18
0
 public Program()
 {
     _commandStore = new CommandStore();
 }
Ejemplo n.º 19
0
 public ReadInput(CommandStore aCommandStore)
 {
     _commandStore = aCommandStore;
 }
        public void Store(UserCompetence aggregate, CompetenceUpdateCommand command)
        {
            CommandStore.AppendToStream(aggregate.GetId(), command, Commands.CompetenceUpdateCommandType);

            Factory.GetChartManager().UserCompetenceChange(command);
        }
Ejemplo n.º 21
0
 public void AddItem(InventoryItem item)
 {
   itemsByKey.Add(item.Id, item);
   CommandStore.Add(new CreateInventoryItemCommand(item));
 }
Ejemplo n.º 22
0
 public Inventory(CommandStore commandStore)
 {
   this.CommandStore = commandStore;
 }