Beispiel #1
0
    private void ServerFixedUpdate()
    {
        //force a snapshot to happen
        //snapshots must be forced at some specific rate, since they are sent unreliable with no ack back
        //we can never be sure if it was recieved or not.

        networkObject.SetAllDirty();
        //these are always send for every player, since its just the players its probably ok
        //but for other objects it would be good to only send to players when nearby or visisble

        InputCommand input = new InputCommand();

        lock (_ServerInputQueue)
        {
            if (_ServerInputQueue.Count > 0)
            {
                input = _ServerInputQueue.Dequeue();
            }
        }

        if (input.Time > 0)
        {
            //Debug.LogFormat("SendInputs: {0} {1} {2} {3}", gameObject.name, timestep, vel.ToString("F4"), rot.eulerAngles);
            ProcessMovement(input.Time, input.Velocity, input.Rotation);
        }
    }
Beispiel #2
0
        public void Execute(LiteEngine engine, StringScanner s, Display display, InputCommand input, Env env)
        {
            var col   = this.ReadCollection(engine, s);
            var query = this.ReadQuery(s);

            display.WriteResult(engine.Count(col, query));
        }
        private InputCommand CreateInputCommand(CommandResolver resolver, IHostInterface host)
        {
            // instantiate input command

            if (resolver.CommandDefinition == null)
            {
                throw new InvalidOperationException("Cannot load input command because a command definition could not be resolved");
            }

            InputCommand cmd = host.CommandActivatorContainer.Get(resolver.CommandDefinition.InputCommandType);

            // initialize switches to false

            foreach (var item in resolver.CommandDefinition.Switches)
            {
                item.PropertyInfo.SetValue(cmd, new SwitchParameter()
                {
                    IsPresent = false
                });
            }

            // set node values

            foreach (var node in resolver.Nodes.Where(n => n.IsComplete))
            {
                node.SetValue(cmd);
            }

            return(cmd);
        }
Beispiel #4
0
        public override HandState HandleInput(InputCommand inputCommand, SpellCaster spellCaster, Hand hand)
        {
            switch (inputCommand)
            {
            case InputCommand.GripReleased:
                if (hand.Equals(Hand.Left))
                {
                    ((HonoviSpellCaster)spellCaster).ImpulseSpell();
                    spellCaster.GetComponent <Collider>().enabled = true;
                    return(new HonoviNormalState());
                }
                else
                {
                    return(this);
                }

            case InputCommand.TouchpadPressed:
                if (hand.Equals(Hand.Left))
                {
                    return(this);
                }
                else
                {
                    ((HonoviSpellCaster)spellCaster).DestroyCurrentSpell();
                    spellCaster.ShowSeal();
                    PlayerController.Instance.UpdateHandColliders(false);
                    return(new HonoviTeleportingState());
                }

            default:
                return(this);
            }
        }
        public static InputCommand DetermineCommand(string input)
        {
            // TODO: Implement
            input = SanitizeInput(input);

            var sa = input.Split();

            if (sa.Count() > 0)
            {
                string maincommand = sa[0];
                Console.WriteLine(maincommand);
                InputCommand n = (InputCommand)allowedCommands.IndexOf(maincommand);

                switch (n)
                {
                case InputCommand.Show:
                    break;

                case InputCommand.Details:
                    break;

                case InputCommand.Find:
                    break;

                default:
                    return(InputCommand.Unknown);
                }

                return(n);
            }

            return(InputCommand.Unknown);
        }
Beispiel #6
0
        public void Execute(LiteEngine engine, StringScanner s, Display display, InputCommand input, Env env)
        {
            var col   = this.ReadCollection(engine, s);
            var index = s.Scan(this.FieldPattern).Trim();

            display.WriteResult(engine.DropIndex(col, index));
        }
Beispiel #7
0
        public override void Execute(LiteShell shell, StringScanner s, Display display, InputCommand input)
        {
            if(s.Scan("false|off").Length > 0 && _writer != null)
            {
                display.TextWriters.Remove(_writer);
                input.OnWrite = null;
                _writer.Flush();
                _writer.Dispose();
                _writer = null;
            }
            else if(_writer == null)
            {
                if (shell.Database == null) throw LiteException.NoDatabase();

                var dbfilename = shell.Database.ConnectionString.Filename;
                var path = Path.Combine(Path.GetDirectoryName(dbfilename),
                    string.Format("{0}-spool-{1:yyyy-MM-dd-HH-mm}.txt", Path.GetFileNameWithoutExtension(dbfilename), DateTime.Now));

                _writer = File.CreateText(path);

                display.TextWriters.Add(_writer);

                input.OnWrite = (t) => _writer.Write(t);
            }
        }
Beispiel #8
0
        public void Execute(LiteEngine engine, StringScanner s, Display display, InputCommand input, Env env)
        {
            var col = this.ReadCollection(engine, s);
            var newName = s.Scan(@"[\w-]+").ThrowIfEmpty("Invalid new collection name");

            display.WriteResult(engine.RenameCollection(col, newName));
        }
 public CommandStep(int _index)
 {
     idIndex   = _index;
     followUps = new List <int>();
     command   = new InputCommand();
     myRect    = new Rect(50, 50, 200, 200);
 }
Beispiel #10
0
        public override InputCommand GetCommand()
        {
            if (Input.touchCount == 0)
            {
                if (prevInputCommand != InputCommand.None)
                {
                    Debug.Log("No touch detected");
                }
                prevInputCommand = InputCommand.None;
                return(InputCommand.None);
            }

            var touch = Input.GetTouch(0);

            switch (touch.phase)
            {
            case UnityEngine.TouchPhase.Began:
                return(CaptureTouchBegan(touch));

            case UnityEngine.TouchPhase.Moved:
                return(CaptureTouchMoving(touch));

            case UnityEngine.TouchPhase.Ended:
            case UnityEngine.TouchPhase.Canceled:
                return(CaptureTouchEnd(touch));

            default:
                return(InputCommand.None);
            }
        }
Beispiel #11
0
        public Response <List <UserInfo> > GetNextUserProcess([FromBody] InputCommand data)
        {
            try
            {
                List <UserInfo> dataReturn            = new List <UserInfo>();
                var             pi                    = WorkflowInit.Runtime.GetProcessInstanceAndFillProcessParameters(data.DocumentId);
                var             allCommandTransitions = pi.ProcessScheme.GetCommandTransitions(pi.CurrentActivity);
                var             yourTransition        = allCommandTransitions.FirstOrDefault(t => t.Trigger.Command.Name == data.CommandName);
                if (yourTransition == null)
                {
                    return(new Response <List <UserInfo> >(0, "Data null", null));
                }
                var  yourActivityName = yourTransition.To.Name;
                bool nextIsFinal      = yourTransition.To.IsFinal;

                var Nextactor = WorkflowInit.Runtime.GetAllActorsForAllCommandTransitions(data.DocumentId, false, yourActivityName);
                var dataList  = Nextactor.ToList();
                if (dataList != null && dataList.Count > 0)
                {
                    dataReturn = _employeeRepository.GetAllUserById(dataList);
                }
                return(new Response <List <UserInfo> >(1, "Success", dataReturn));
            }
            catch (Exception ex)
            {
                return(new Response <List <UserInfo> >(-1, ex.Message, null));
            }
        }
Beispiel #12
0
        public void Execute(LiteEngine engine, StringScanner s, Display display, InputCommand input, Env env)
        {
            var col = this.ReadCollection(engine, s);
            var doc = JsonSerializer.Deserialize(s.ToString()).AsDocument;

            display.WriteResult(engine.Update(col, doc));
        }
Beispiel #13
0
        public override void Execute(ref IShellEngine engine, StringScanner s, Display display, InputCommand input)
        {
            if (engine == null) throw ShellExpcetion.NoDatabase();

            var direction = s.Scan(@"[><]\s*").Trim();
            var filename = s.Scan(@".+").Trim();

            //dump import
            if(direction == "<")
            {
                using (var reader = new StreamReader(filename, Encoding.UTF8))
                {
                    string line;
                    while ((line = reader.ReadLine()) != null)
                    {
                        engine.Run(line, new Display()); // no output
                    }
                }
            }
            // dump export
            else
            {
                using (var writer = new StreamWriter(filename, false, Encoding.UTF8, 65536))
                {
                    writer.AutoFlush = true;
                    writer.WriteLine("-- LiteDB v{0}.{1}.{2} dump file @ {3}", 
                        engine.Version.Major, engine.Version.Minor, engine.Version.Build,
                        DateTime.Now);
                    engine.Dump(writer);
                    writer.Flush();
                }
            }
        }
Beispiel #14
0
        public void Execute(LiteEngine engine, StringScanner s, Display display, InputCommand input, Env env)
        {
            var col = this.ReadCollection(engine, s);
            var index = s.Scan(this.FieldPattern).Trim();

            display.WriteResult(engine.Max(col, index.Length == 0 ? "_id" : index));
        }
Beispiel #15
0
    private void FixedUpdate()
    {
        InputCommand inp = TakeInput();

        switch (state)
        {
        case PlayerState.moving:
        case PlayerState.moveCarrying:
            if (inp.move)
            {
                rb2d.velocity = GetVectorDirection(inp.direction) * speed;
                if (direction != inp.direction)
                {
                    direction = inp.direction;
                    animator.Play(animations.GetName(state, direction));
                }
            }
            else
            {
                rb2d.velocity = Vector2.zero;
            }
            break;

        default:
            break;
        }
    }
Beispiel #16
0
        public void Execute(LiteEngine engine, StringScanner s, Display display, InputCommand input, Env env)
        {
            env.ConnectionString = new ConnectionString(s.Scan(@".+").TrimToNull());

            // if needs upgrade, do it now
            if (env.ConnectionString.Upgrade)
            {
                display.WriteLine("Upgrading datafile...");

                var result = LiteEngine.Upgrade(env.ConnectionString.Filename, env.ConnectionString.Password);

                if (result)
                {
                    display.WriteLine("Datafile upgraded to V7 format (LiteDB v.3.x)");
                }
                else
                {
                    throw new ShellException("File format do not support upgrade (" + env.ConnectionString.Filename + ")");
                }

                env.ConnectionString.Upgrade = false;
            }
            else
            {
                var isNew = File.Exists(env.ConnectionString.Filename);

                // open datafile just to test if it's ok (or to create new)
                using (var e = env.CreateEngine(isNew ? DataAccess.Write : DataAccess.Read))
                {
                }
            }
        }
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();
            CalendarToggle = GetTemplateChild(CalendarToggleButtonName) as ToggleButton;
            SekerPopup     = GetTemplateChild(SekerPopupName) as Popup;



            var dateSeker = new DateTimeSeker()
            {
                Background      = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#8B99B9")),
                CornerRadius    = new CornerRadius(5),
                BorderBrush     = new SolidColorBrush(Colors.Black),
                BorderThickness = new Thickness(1),
                FontSize        = 12
            };

            SekerPopup.Child = dateSeker;

            SekerDoneButtonCommand = new InputCommand((paramaters) =>
            {
                CalendarToggle.IsChecked = false;
                Text = dateSeker.SelectedDateTime.ToString();
            });

            dateSeker.DoneButtonCommand = SekerDoneButtonCommand;
        }
Beispiel #18
0
        static void Main(string[] args)
        {
            Console.WriteLine("Процесс начался...\n");

            try
            {
                //InputCommand input = new InputCommand
                //{
                //    CommandName = Constants.CompressCommand,
                //    SourceFile = "D:\\Marvel\\1.Iron.Man.2008_HDRip_[scarabey.org].avi",
                //    DestinationFile = "D:\\abc"
                //};
                //InputCommand input = new InputCommand
                //{
                //    CommandName = Constants.DecompressCommand,
                //    SourceFile = "D:\\abc.gz",
                //    DestinationFile = "D:\\abc1.avi"
                //};

                InputCommand input = ConvertArgsToInputCommand(args);
                GZipProgress.ProcessProgressedEvent += ProgressBar;
                GZipProgress.ProcessFinished        += Finished;
                GZipProcessor.Process(input);
            }
            catch (Exception e)
            {
                Console.BackgroundColor = ConsoleColor.Red;
                Console.ForegroundColor = ConsoleColor.White;
                Console.WriteLine(e.Message);
            }

            Console.ReadLine();
        }
Beispiel #19
0
        public void Execute(LiteEngine engine, StringScanner s, Display d, InputCommand input, Env env)
        {
            var sb      = new StringBuilder();
            var enabled = !(s.Scan(@"off\s*").Length > 0);

            env.Log.Level = enabled ? Logger.FULL : Logger.NONE;
        }
Beispiel #20
0
        public void Execute(LiteEngine engine, StringScanner s, Display d, InputCommand input, Env env)
        {
            var sb = new StringBuilder();
            var enabled = !(s.Scan(@"off\s*").Length > 0);

            env.Log.Level = enabled ? Logger.FULL : Logger.NONE;
        }
        public CommandModule Command(InputCommand input)
        {
            switch (input)
            {
            case InputCommand.Up:
                setRegion(currentRegionIndex - 1);
                break;

            case InputCommand.Down:
                setRegion(currentRegionIndex + 1);
                break;

            case InputCommand.Left:
            case InputCommand.Right:
                navigate(input);
                break;

            case InputCommand.Select:
                return(Select());

            case InputCommand.Unselect:
                return(Unselect());
            }
            return(this);
        }
        public CommandParameterAnalysis(InputCommand command)
        {
            // get defintion

            var definition = command.GetType().DescribeInputCommand();

            // get parameters in set - all parameters available for the active set

            ParametersInSet = definition.Parameters;
            if (!string.IsNullOrWhiteSpace(command.ActiveParameterSet))
            {
                ParametersInSet = ParametersInSet
                                  .Where(p => string.IsNullOrEmpty(p.ParameterSet) ||
                                         p.ParameterSet.Equals(command.ActiveParameterSet)).ToList();
            }

            // get missing required parameters in set - where a complete parameter node is missing for a required parameter in the current set

            MissingRequiredParameters = ParametersInSet.Where(p => p.IsRequired &&
                                                              p.PropertyInfo.GetValue(command) == null).ToList();

            // get superflous parameters - where at least a named parameter switch is defined for a parameter that is not included in the current set

            SuperflousParameters = definition.Parameters.Where(p => p.PropertyInfo.GetValue(command) != null &&
                                                               !ParametersInSet.Contains(p)).ToList();

            // get available parameters in set - all remaining parameters where at least a named parameter switch has not been defined for the current set

            AvailableParameters = definition.Parameters.Where(p => p.PropertyInfo.GetValue(command) == null &&
                                                              ParametersInSet.Contains(p)).ToList();

            // get available switches

            AvaliableSwitches = definition.Switches.Where(s => !((SwitchParameter)s.PropertyInfo.GetValue(command)).IsPresent).ToList();
        }
Beispiel #23
0
        public void Execute(LiteEngine engine, StringScanner s, Display display, InputCommand input, Env env)
        {
            var col = this.ReadCollection(engine, s);
            var doc = JsonSerializer.Deserialize(s.ToString()).AsDocument;

            display.WriteResult(engine.Update(col, doc));
        }
        public CommandModule Command(InputCommand input)
        {
            switch (input)
            {
            case InputCommand.Up:
            case InputCommand.Down:
                break;

            case InputCommand.Left:
            case InputCommand.Right:
                Navigate(input == InputCommand.Right);
                break;

            case InputCommand.Select:
                //TODO kiil urself
                MinionNavigator.HUGE_HACK = getMinionCount();

                click();
                if (parent is TargetingDummy)
                {
                    ((TargetingDummy)parent).setRegion(2);
                }
                return(parent);

            case InputCommand.Unselect:
                rightClick();

                if (parent is TargetingDummy)
                {
                    ((TargetingDummy)parent).setRegion(4);
                }
                return(parent);
            }
            return(this);
        }
Beispiel #25
0
        public void Execute(LiteEngine engine, StringScanner s, Display display, InputCommand input, Env env)
        {
            var fs = new LiteStorage(engine);
            var id = this.ReadId(s);

            display.WriteResult(fs.Delete(id));
        }
Beispiel #26
0
        public void Execute(LiteEngine engine, StringScanner s, Display display, InputCommand input, Env env)
        {
            var fs = new LiteStorage(engine);
            var id = this.ReadId(s);

            display.WriteResult(fs.Delete(id));
        }
Beispiel #27
0
        public override void Execute(ref LiteDatabase db, StringScanner s, Display d, InputCommand input)
        {
            var sb = new StringBuilder();
            var enabled = !(s.Scan(@"off\s*").Length > 0);

            db.Log.Level = enabled ? Logger.FULL : Logger.NONE;
        }
Beispiel #28
0
    private InputCommand TakeInput()
    {
        InputCommand toReturn = new InputCommand();
        float        vInput   = Input.GetAxis("Vertical");
        float        hInput   = Input.GetAxis("Horizontal");

        toReturn.move = Mathf.Abs(vInput) > 0 || Mathf.Abs(hInput) > 0;
        if (Mathf.Abs(vInput) > Mathf.Abs(hInput))
        {
            if (vInput > 0)
            {
                toReturn.direction = Direction.up;
            }
            else
            {
                toReturn.direction = Direction.down;
            }
        }
        else
        {
            if (hInput > 0)
            {
                toReturn.direction = Direction.right;
            }
            else
            {
                toReturn.direction = Direction.left;
            }
        }
        toReturn.interact = Input.GetKeyDown(interactKey);
        toReturn.attack   = Input.GetKeyDown(attackKey);
        return(toReturn);
    }
Beispiel #29
0
        private void Game1_KeyPress(object sender, KeyPressEventArgs e)
        {
            string userKeyPress = e.KeyChar.ToString().ToUpper();

            InputCommand userCommand = inputManager.GetMoveCommand(userKeyPress);

            if (userCommand == InputCommand.MoveDown)
            {
                MessageBox.Show("Move down");
                // Add something when command is pressed
            }
            else if (userCommand == InputCommand.MoveUp)
            {
                MessageBox.Show("Move up");
                // Add something when command is pressed
            }
            else if (userCommand == InputCommand.MoveLeft)
            {
                MessageBox.Show("Move left");
                // Add something when command is pressed
            }
            else if (userCommand == InputCommand.MoveRight)
            {
                MessageBox.Show("Move right");
                // Add something when command is pressed
            }
            else
            {
                if (userCommand == InputCommand.Unknown)
                {
                    // This means that the user command is unknown.
                }
            }
        }
Beispiel #30
0
        public void Execute(LiteEngine engine, StringScanner s, Display display, InputCommand input, Env env)
        {
            if (s.Scan("false|off").Length > 0 && _writer != null)
            {
                display.TextWriters.Remove(_writer);
                input.OnWrite = null;
                _writer.Flush();
                _writer.Dispose();
                _writer = null;
            }
            else if (_writer == null)
            {
                if (engine == null)
                {
                    throw ShellExpcetion.NoDatabase();
                }

                var path = Path.GetFullPath(string.Format("LiteDB-spool-{0:yyyy-MM-dd-HH-mm}.txt", DateTime.Now));

                _writer = File.CreateText(path);

                display.TextWriters.Add(_writer);

                input.OnWrite = (t) => _writer.Write(t);
            }
        }
Beispiel #31
0
        public void Execute(LiteEngine engine, StringScanner s, Display display, InputCommand input, Env env)
        {
            var fs       = new LiteStorage(engine);
            var id       = this.ReadId(s);
            var metadata = JsonSerializer.Deserialize(s.ToString()).AsDocument;

            fs.SetMetadata(id, metadata);
        }
Beispiel #32
0
        public override void Execute(LiteShell shell, StringScanner s, Display display, InputCommand input)
        {
            if (shell.Database == null) throw LiteException.NoDatabase();

            shell.Database.Dispose();

            shell.Database = null;
        }
Beispiel #33
0
        private IEnumerator DoSetInputBuffer(InputCommand inputBuffer)
        {
            this.inputBuffer = inputBuffer;
            yield return(new WaitForSeconds(inputBufferDuration));

            this.inputBuffer        = InputCommand.None;
            inputBufferCleanRoutine = null;
        }
Beispiel #34
0
        public override void Execute(ref IShellEngine engine, StringScanner s, Display display, InputCommand input)
        {
            if (engine == null) throw ShellExpcetion.NoDatabase();

            engine.Dispose();

            engine = null;
        }
Beispiel #35
0
        public void Execute(LiteEngine engine, StringScanner s, Display display, InputCommand input, Env env)
        {
            var fs = new LiteStorage(engine);
            var id = this.ReadId(s);
            var metadata = JsonSerializer.Deserialize(s.ToString()).AsDocument;

            fs.SetMetadata(id, metadata);
        }
Beispiel #36
0
 public void Execute(LiteEngine engine, StringScanner s, Display display, InputCommand input, Env env)
 {
     if (engine != null)
     {
         engine.Dispose();
     }
     input.Running = false;
 }
Beispiel #37
0
        public override void Execute(ref LiteDatabase db, StringScanner s, Display display, InputCommand input)
        {
            if (db == null) throw LiteException.NoDatabase();

            db.Dispose();

            db = null;
        }
Beispiel #38
0
        public void Execute(LiteEngine engine, StringScanner s, Display display, InputCommand input, Env env)
        {
            var cols = engine.GetCollectionNames().OrderBy(x => x).ToArray();

            if (cols.Length > 0)
            {
                display.WriteLine(ConsoleColor.Cyan, string.Join(Environment.NewLine, cols));
            }
        }
Beispiel #39
0
        public override void Execute(ref IShellEngine engine, StringScanner s, Display d, InputCommand input)
        {
            var sb = new StringBuilder();
            var enabled = !(s.Scan(@"off\s*").Length > 0);

            if(engine == null) throw ShellExpcetion.NoDatabase();

            engine.Debug(enabled);
        }
        public void SendInput(string conferenceId, MouseInput mouseInput)
        {
            Command command = new InputCommand(conferenceId)
            {
                MouseInput = mouseInput
            };

            SendCommand(command);
        }
Beispiel #41
0
 public AliasCommand(string command)
 {
     _inCmd      = new InputCommand(command);
     Description = $"Alias of _{command}_.";
     Action      = (repl, cmd, args) =>
     {
         repl.ProcessCommand((args.Length > 0) ? _inCmd.AppendArguments(args) : _inCmd);
     };
 }
Beispiel #42
0
        private void SendCommand(InputCommand input)
        {
            CommandModule result = this.currentModule.Command(input);

            if (result != null)
            {
                this.currentModule = result;
            }
        }
Beispiel #43
0
        public override void Execute(LiteShell shell, StringScanner s, Display display, InputCommand input)
        {
            var ver = typeof(LiteDatabase).Assembly.GetName().Version;

            display.WriteInfo(string.Format("v{0}.{1}.{2}",
                ver.Major,
                ver.Minor,
                ver.Build));
        }
Beispiel #44
0
 public static void ClearCommands()
 {
     ButtonUp      = null;
     ButtonDown    = null;
     ButtonLeft    = null;
     ButtonRight   = null;
     ButtonRestart = null;
     ButtonEnter   = null;
 }
Beispiel #45
0
        public override void Execute(LiteShell shell, StringScanner s, Display display, InputCommand input)
        {
            var filename = s.Scan(@".+").Trim();

            foreach (var line in File.ReadAllLines(filename))
            {
                input.Queue.Enqueue(line);
            }
        }
        bool Handle(InputCommand message)
        {
            // do something heavy: will block the Actor
            Thread.Sleep(2000);

            _writer.Tell(new CommandCompleted(message.Data));

            return(true);
        }
Beispiel #47
0
        public void Execute(LiteEngine engine, StringScanner s, Display display, InputCommand input, Env env)
        {
            var col = this.ReadCollection(engine, s);

            display.WriteResult(new BsonArray(engine.GetIndexes(col).Select(x => new BsonDocument
            {
                { "slot", x.Slot },
                { "field", x.Field },
                { "unique", x.Unique }
            })));
        }
        public static bool IsKeyPressed(InputCommand inputCommand)
        {
            if (_keyBindings == null) { _keyBindings = new ControlMapping().LoadKeyBindings(); } // This weird 'new' statement prevents the one-use method LoadKeyBindings from being held in memory.

            if(!_keyBindings.ContainsKey(inputCommand)) { throw new Exception("No key binding found for input command: " + inputCommand.ToString()); }
            foreach(Keys key in _keyBindings[inputCommand])
            {
                if (_input.Keyboard.IsKeyPressed(key)) { return true; }
            }
            return false;
        }
Beispiel #49
0
        public override void Execute(LiteShell shell, StringScanner s, Display display, InputCommand input)
        {
            var filename = s.Scan(@".+");

            if (shell.Database != null)
            {
                shell.Database.Dispose();
            }

            shell.Database = new LiteDatabase(filename);
        }
Beispiel #50
0
        public override void Execute(ref IShellEngine engine, StringScanner s, Display display, InputCommand input)
        {
            if (engine == null) throw ShellExpcetion.NoDatabase();

            var filename = s.Scan(@".+").Trim();

            foreach (var line in File.ReadAllLines(filename))
            {
                input.Queue.Enqueue(line);
            }
        }
Beispiel #51
0
        public override void Execute(ref LiteDatabase db, StringScanner s, Display display, InputCommand input)
        {
            var filename = s.Scan(@".+");

            if (db != null)
            {
                db.Dispose();
            }

            db = new LiteDatabase(filename);
        }
Beispiel #52
0
        public void Execute(LiteEngine engine, StringScanner s, Display display, InputCommand input, Env env)
        {
            var col = this.ReadCollection(engine, s);
            var filename = s.Scan(@".*");

            using (var sr = new StreamReader(filename, Encoding.UTF8))
            {
                var docs = JsonSerializer.DeserializeArray(sr);

                display.WriteResult(engine.Insert(col, docs.Select(x => x.AsDocument)));
            }
        }
Beispiel #53
0
        public void Execute(LiteEngine engine, StringScanner s, Display display, InputCommand input, Env env)
        {
            var ver = s.Scan(@"\d*");

            if (ver.Length > 0)
            {
                engine.UserVersion = Convert.ToUInt16(ver);
            }
            else
            {
                display.WriteLine(engine.UserVersion.ToString());
            }
        }
Beispiel #54
0
        public void Execute(LiteEngine engine, StringScanner s, Display display, InputCommand input, Env env)
        {
            var fs = new LiteStorage(engine);
            var id = this.ReadId(s);

            var filename = s.Scan(@"\s*.*").Trim();

            if (!File.Exists(filename)) throw new IOException("File " + filename + " not found");

            var file = fs.Upload(id, filename);

            display.WriteResult(file.AsDocument);
        }
Beispiel #55
0
        public void Execute(LiteEngine engine, StringScanner s, Display display, InputCommand input, Env env)
        {
            var fs = new LiteStorage(engine);
            var id = this.ReadId(s);
            var filename = s.Scan(@"\s*.*").Trim();

            var file = fs.FindById(id);

            if (file != null)
            {
                file.SaveAs(filename);

                display.WriteResult(file.AsDocument);
            }
        }
Beispiel #56
0
        public void Execute(LiteEngine engine, StringScanner s, Display display, InputCommand input, Env env)
        {
            var col = this.ReadCollection(engine, s);
            var value = JsonSerializer.Deserialize(s.ToString());

            if (value.IsArray)
            {
                display.WriteResult(engine.Insert(col, value.AsArray.RawValue.Select(x => x.AsDocument)));
            }
            else
            {
                engine.Insert(col, new BsonDocument[] { value.AsDocument });

                display.WriteResult(value.AsDocument["_id"]);
            }
        }
Beispiel #57
0
        public void Execute(LiteEngine engine, StringScanner s, Display display, InputCommand input, Env env)
        {
            var connectionString = new ConnectionString(s.Scan(@".+").TrimToNull());

            env.Filename = connectionString.Filename;
            env.Password = connectionString.Password;
            env.Journal = connectionString.Journal;

            // create file if not exits
            if(!File.Exists(env.Filename))
            {
                using (var e = env.CreateEngine(DataAccess.Write))
                {
                }
            }
        }
Beispiel #58
0
        public override void Execute(ref IShellEngine engine, StringScanner s, Display display, InputCommand input)
        {
            var connectionString = s.Scan(@".+");

            if (engine != null)
            {
                engine.Dispose();
            }

            // get filename, detect engine and open
            var filename = this.GetFilename(connectionString);
            engine = this.DetectEngine(filename);
            engine.Open(connectionString);

            // get engine version and display info
            var ver = engine.Version;
            display.WriteLine(ConsoleColor.DarkCyan, string.Format("open \"{0}\" (v{1}.{2}.{3})",
                Path.GetFileName(filename), ver.Major, ver.Minor, ver.Build));
        }
Beispiel #59
0
        public void Execute(LiteEngine engine, StringScanner s, Display display, InputCommand input, Env env)
        {
            var fs = new LiteStorage(engine);

            if (s.HasTerminated)
            {
                var files = fs.FindAll().Select(x => x.AsDocument);

                display.WriteResult(new BsonArray(files));
            }
            else
            {
                var id = this.ReadId(s);

                var files = fs.Find(id).Select(x => x.AsDocument);

                display.WriteResult(new BsonArray(files));
            }
        }
Beispiel #60
-12
        public void Execute(LiteEngine engine, StringScanner s, Display display, InputCommand input, Env env)
        {
            var col = this.ReadCollection(engine, s);
            var query = this.ReadQuery(s);

            display.WriteResult(engine.Delete(col, query));
        }