protected override ICmdHandler GetCommandHandler(ExecutionContext context)
        {
            var data = new CmdData(
                cmdName: nameof(ICreateStore),
                sequence: 0,
                createdAt: DateTime.UtcNow);

            data.Add(nameof(ICreateStore.StoreId), StoreId);
            data.Add(nameof(ICreateStore.Name), Name);
            data.Add(nameof(ICreateStore.Type), Type.ToString());

            return(new CreateStoreHandler(data));
        }
Beispiel #2
0
        protected override ICmdHandler GetCommandHandler(ExecutionContext context)
        {
            // Don't use context.CreateCmdData here because the command
            // will get added to the new branch (not the current one).

            var data = new CmdData(
                cmdName: nameof(ICreateBranch),
                sequence: 0,
                createdAt: DateTime.UtcNow);

            data.Add(nameof(ICreateBranch.Name), Name);
            data.Add(nameof(ICreateBranch.CommandCount), CommandCount);

            return(new CreateBranchHandler(data));
        }
Beispiel #3
0
        /// <summary>
        /// Performs any processing of the command data.
        /// </summary>
        /// <param name="data">The data to be processed.</param>
        /// <remarks>The supplied data is expected to be relevant to this
        /// processor (the caller should have already applied any filter
        /// to the command stream).</remarks>
        void ICmdProcessor.Process(CmdData data)
        {
            // The command names handled here need to be included
            // via the CmdFilter property

            if (data.CmdName == AddCmdLine.CmdName)
            {
                string name = data.GetValue <string>(nameof(AddCmdLine.Name));
                Names.Add(name);
            }
            else if (data.CmdName == CutCmdLine.CmdName)
            {
                string name = data.GetValue <string>(nameof(CutCmdLine.Name));
                int    nRem = Names.RemoveAll(x => x == name);

                // This is going to fail if this is getting called when we're rebuilding the model.
                // Cuts should be handled by marking the adds (to ignore them).
                // AltNames only works with the one branch
                data.Add(nameof(NameProcessor.CutCount), nRem);
            }
            else
            {
                throw new ProcessorException(this, "Unexpected command: " + data.CmdName);
            }
        }
Beispiel #4
0
        public void Process(ExecutionContext context)
        {
            Branch branch = context.Store.Current;

            if (branch.IsRemote)
            {
                branch = branch.CreateLocal(context);
            }


            CmdData cmd = context.CreateCmdData(nameof(NameCmdLine));

            cmd.Add(nameof(NameCmdLine.Name), Name);

            // Update relevant model(s)
            if (context.Apply(cmd))
            {
                branch.SaveData(cmd);
            }
            else
            {
                ProcessorException pex = context.LastProcessingError;
                if (pex == null)
                {
                    Console.WriteLine("Handler failed");
                }
                else
                {
                    ShowError(pex);
                }
            }
        }
Beispiel #5
0
        protected override ICmdHandler GetCommandHandler(ExecutionContext context)
        {
            CmdData data = context.CreateCmdData(nameof(IMerge));

            data.Add(nameof(IMerge.FromId), FromId);
            return(new MergeHandler(data));
        }
Beispiel #6
0
        protected override ICmdHandler GetCommandHandler(ExecutionContext context)
        {
            var data = new CmdData(
                cmdName: nameof(ICloneStore),
                sequence: 0,
                createdAt: DateTime.UtcNow);

            data.Add(nameof(ICreateStore.StoreId), StoreId);
            data.Add(nameof(ICreateStore.Name), To);
            data.Add(nameof(ICloneStore.Origin), Origin);

            // For the time being, only clone to the same type as the origin (you should
            // really be allowed to clone from one type into another)
            StoreType type = StoreType.None;

            if (Directory.Exists(Origin))
            {
                type = StoreType.File;
            }
            else
            {
                string dbSpec = Path.HasExtension(Origin) ? Origin : Origin + ".ac-sqlite";
                if (File.Exists(dbSpec))
                {
                    type = StoreType.SQLite;
                }
            }

            if (type == StoreType.None)
            {
                throw new ArgumentException("Cannot determine store type for " + Origin);
            }

            data.Add(nameof(ICreateStore.Type), type);

            return(new CloneStoreHandler(data));
        }