Esempio n. 1
0
        public static IList<StateControl> FromCommon(StateModel stateModel)
        {
            List<StateControl> stateControls = new List<StateControl>();
            foreach (var state in stateModel.States)
            {
                var stateControl = new StateControl();
                stateControl.InitialPosition = new Point(state.X, state.Y);
                stateControl.DisplayName = state.Name;
                stateControl.StateId = state.StateID;
                stateControl.StartState = state.Default;
                stateControls.Add(stateControl);
            }

            foreach (var transition in stateModel.Transitions)
            {
                var sourceControl = (from sc in stateControls where sc.StateId == transition.SourceStateRef select sc).Single();
                var destControl = (from sc in stateControls where sc.StateId == transition.DestinationStateRef select sc).Single();
                if (sourceControl == null || destControl == null)
                {
                    throw new System.InvalidOperationException("cannot find states for transition");
                }
                var arrow = new Arrow();
                arrow.TailControl = sourceControl;
                arrow.HeadControl = destControl;
                sourceControl.AddArrow(arrow, StateControl.ArrowDirection.Out);
                destControl.AddArrow(arrow, StateControl.ArrowDirection.In);
            }
            return stateControls;
        }
Esempio n. 2
0
        public static StateModel ToCommon(IList<StateControl> stateControls, int modelId, string modelName)
        {
            var sm = new StateModel();
            sm.States = new List<State>();
            sm.Transitions = new List<Transition>();
            int i = 0;
            foreach (var control in stateControls)
            {
                var state = new State();
                state.Default = control.StartState;
                state.Name = control.DisplayName;
                state.StateID = i;
                Point position = Page1.GetPosition(control);
                state.X = (int) position.X;
                state.Y = (int) position.Y;
                control.StateId = i;
                i++;
                sm.States.Add(state);
            }

            foreach (var control in stateControls)
            {
                foreach (var arrow in control.ArrowsOut)
                {
                    var trans = new Transition();
                    trans.DestinationStateRef = arrow.HeadControl.StateId;
                    trans.SourceStateRef = arrow.TailControl.StateId;
                    sm.Transitions.Add(trans);
                }
            }
            sm.ModelID = modelId;
            sm.ModelName = modelName;
            return sm;
        }
Esempio n. 3
0
        private Derivative Evaluate( StateModel initial, double dt, Derivative d, double dampK, double dampB )
        {
            StateModel state;
              state.a = initial.a + (d.da * dt);
              state.v = initial.v + (d.dv * dt);

              Derivative output = new Derivative( );
              output.da = state.v;
              output.dv = Acceleration( state, dampK, dampB );
              return output;
        }
Esempio n. 4
0
 public void UpdateStatus(StateModel model, bool isMine)
 {
     if (isMine)
     {
         myMap.UpdateStatus(model);
     }
     else
     {
         otherMap.UpdateStatus(model);
     }
 }
    public StateModel State(string stateName)
    {
        var result = new StateModel(this)
        {
            Name = stateName
        };

        States.Add(stateName, result);

        return result;
    }
        public ActionResult State(string SearchValue, string sortOrder, int pid = 0, int cid = 0)
        {
            int        take  = 10;
            int        skip  = take * pid;
            StateModel model = new StateModel();

            model.PageID  = pid;
            model.Current = pid + 1;
            IEnumerable <StateModel> Courses = new List <StateModel>();

            CustomMethods.ValidateRoles("State");
            var Citieslist = new StateBLL {
            }.GetAllState(skip, take);

            if (cid != 0)
            {
                var sortedlist = new StateBLL {
                }.GetAllState(skip, take, cid);
                double count = Convert.ToDouble(sortedlist.Count);
                var    res   = count / take;
                model.Pagecount = (int)Math.Ceiling(res);
                model.StateList = sortedlist.Select(x => new StateModel
                {
                    CountryId   = x.CountryId,
                    CountryName = x.CountryName,
                    StateId     = x.StateId,
                    StateName   = x.StateName,
                    IsActive    = Convert.ToBoolean(x.IsActive)
                }).ToList();
            }
            else
            {
                if (Citieslist != null)
                {
                    double count = Convert.ToDouble(new StateBLL {
                    }.GetPageCount());
                    var res      = count / take;
                    model.Pagecount = (int)Math.Ceiling(res);
                    model.StateList = Citieslist.Select(x => new StateModel
                    {
                        CountryId   = x.CountryId,
                        CountryName = x.CountryName,
                        StateId     = x.StateId,
                        StateName   = x.StateName,
                        IsActive    = Convert.ToBoolean(x.IsActive)
                    }).ToList();
                }
            }

            return(View(model));
        }
Esempio n. 7
0
        private async Task <StateModel> AssignValueToModel(State state)
        {
            return(await Task.Run(() =>
            {
                StateModel stateModel = new StateModel();
                stateModel.StateId = state.StateId;
                stateModel.StateName = state.StateName;
                stateModel.CountryId = Convert.ToInt32(state.CountryId);
                stateModel.CountryName = state.Country.CountryName;
                stateModel.PreparedByName = null != state.PreparedByUser ? state.PreparedByUser.UserName : null;

                return stateModel;
            }));
        }
        private void SetStateName(StateModel state)
        {
            if (!CanSetStateName(state))
            {
                return;
            }

            if (!IsNewCategory)
            {
                IsUpdated = true;
            }

            SaveChanges();
        }
        private async Task ApplyMessagesAsync(List <IMessage> requiredMessages)
        {
            foreach (var message in requiredMessages)
            {
                StateModel = StateModel.Apply(message) ?? StateModel;
            }

            if (requiredMessages.Count > 0)
            {
                await checkpointPersister.SaveCurrentCheckpointAsync(
                    projectorIdentifier,
                    requiredMessages[requiredMessages.Count - 1].CheckpointNumber);
            }
        }
Esempio n. 10
0
        public ActionResult Create_Get()
        {
            CityModel objCityModel = new CityModel();

            CountryModel objCountryModel = new CountryModel();

            objCityModel.countryList = objCountryModel.GetCountryList().ToList();

            StateModel objStateModel = new StateModel();

            objCityModel.stateList = objStateModel.GetStateList().ToList();

            return(View(objCityModel));
        }
Esempio n. 11
0
        // GET: Admin
        public ActionResult Index()
        {
            StateModel model = new StateModel();

            model.ExpectedOrderCount  = db.orders.Where(i => i.OrderState == OrderState.Expected).ToList().Count();
            model.CompletedOrderCount = db.orders.Where(i => i.OrderState == OrderState.Completed).ToList().Count();
            model.PackegedOrderCount  = db.orders.Where(i => i.OrderState == OrderState.Packaged).ToList().Count();
            model.ShippedOrderCount   = db.orders.Where(i => i.OrderState == OrderState.Shipped).ToList().Count();

            model.ProductCount = db.products.Count();
            model.OrdertCount  = db.orders.Count();

            return(View(model));
        }
Esempio n. 12
0
        public AddEditStateViewModel(StateModel p_State)
        {
            CancelCommand = new RelayCommand(OnCancel);
            SaveCommand   = new RelayCommand(OnSave, CanSave);

            if (p_State != null)
            {
                SetState(StatesRepository.Instance.RetrieveDetail(p_State.ID_STA));
            }
            else
            {
                SetState(null);
            }
        }
Esempio n. 13
0
        // GET: State/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            StateModel stateModel = db.States.Find(id);

            if (stateModel == null)
            {
                return(HttpNotFound());
            }
            return(View(stateModel));
        }
 public void WriteTo(StateModel state, Stream stream)
 {
     using (var sw = new StreamWriter(stream))
         using (var writer = new CsvWriter(sw))
         {
             for (int y = 0; y < 9; y++)
             {
                 for (int x = 0; x < 9; x++)
                 {
                     writer.WriteField <int?>(state.State[x, y]);
                 }
                 writer.NextRecord();
             }
         }
 }
    public IEnumerator GoToStateCoroutine(StateCode code)
    {
        var stateModel = GetState(code);

        if (!stateModel)
        {
            yield break;
        }

        yield return(CurrentState?.OnStateEnding());

        CurrentState = stateModel;

        yield return(stateModel.OnStateBeginning());
    }
Esempio n. 16
0
        public async Task <IActionResult> CreateState([FromBody] CreateStateRequest request)
        {
            try
            {
                var stateModel = new StateModel();
                stateModel.Name = request.StateName;
                var id = await _stateService.Create(stateModel);

                return(Ok(id));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
        /// <summary>
        /// Update State entity
        /// </summary>
        /// <param name="model"></param>
        /// <param name="theCountry"></param>
        /// <returns></returns>
        public static State Create(StateModel model, Country theCountry)
        {
            return(new State()
            {
                Id = model.Id,
                Code = model.Code,
                Name = model.Name,
                TheCountry = theCountry,

                IsApproved = model.IsApproved,
                IsRestricted = model.IsRestricted,
                ModifiedAt = DateTime.Now,
                RecordStatus = model.RecordStatus
            });
        }
Esempio n. 18
0
        private void RemoveState(StateModel state)
        {
            if (!IsNewCategory)
            {
                IsUpdated = true;
            }

            States.Remove(state);
            if (state.StateID != null)
            {
                DeletedStates.Add(state);
            }

            SaveChanges();
        }
Esempio n. 19
0
 public ActionResult NewState(StateModel model, int id)
 {
     model.StateCountryID = id;
     if (ModelState.IsValid)
     {
         State state = Mapper.Map <StateModel, State>(model);
         state.StateAddedBy   = Utils.CurrentUser;
         state.StateAddedDate = DateTime.Now;
         state.StateIsActive  = true;
         db.States.Add(state);
         db.SaveChanges();
         return(RedirectToAction("States"));
     }
     return(View("State/NewState", model));
 }
Esempio n. 20
0
        public async Task <int> CreateState(StateModel stateModel)
        {
            int stateId = 0;

            // assign values.
            State state = new State();

            state.StateName = stateModel.StateName;
            state.CountryId = stateModel.CountryId;
            await Create(state);

            stateId = state.StateId;

            return(stateId); // returns.
        }
Esempio n. 21
0
        // click, then focus on the canvas and remove the info-panel if existed
        protected override void OnMouseClick(MouseEventArgs e)
        {
            // focus on the current working-on canvas
            Select();

            // remove the info-panel
            ModelManager.removeInfoPanel();

            // left-click
            if (e.Button == MouseButtons.Left)
            {
                // on a certain link-view
                if (!(MouseManager.coveringLinkView is null))
                {
                    // simulating
                    if (SimulationManager.isSimulating())
                    {
                        StateModel currentStaying = SimulationManager.getCurrentStayingStateModel();

                        bool isActivatableLink =
                            !(currentStaying is null) &&
                            !(currentStaying.getConnectedLinks() is null) &&
                            currentStaying.getConnectedLinks().Exists(l => l.Id == MouseManager.coveringLinkView.Model.Id);

                        if (isActivatableLink)
                        {
                            SimulationManager.stepOnNextState(
                                MouseManager.coveringLinkView.Model,
                                MouseManager.coveringLinkView.Model.DstStateModel
                                );
                        }
                    }

                    // not simulating, show info-panel of this link
                    else
                    {
                        Program.form.selectExistedObject(MouseManager.coveringLinkView.Model);
                    }
                }
            }

            // cancel the link addition
            else if (e.Button == MouseButtons.Right)
            {
                MouseManager.AddingLinkView = null;
                Invalidate();
            }
        }
Esempio n. 22
0
        public IActionResult GetStates()
        {
            var        list = new List <StateModel>();
            StateModel item = new StateModel();

            item.Code = "UP";
            item.Name = "Uttar Pradesh";
            StateModel item2 = new StateModel();

            item2.Code = "DL";
            item2.Name = "New Delhi";

            list.Add(item);
            list.Add(item2);
            return(Ok(list));
        }
Esempio n. 23
0
        // delete a state-view
        public void deleteStateView(StateModel stateModel)
        {
            // search for the designated state-view by common id w/ corresponding state-model
            foreach (StateView stateView in mExistedStateViewList)
            {
                if (stateView.Id == stateModel.Id)
                {
                    mExistedStateViewList.Remove(stateView);
                    Controls.Remove(stateView);
                    break;
                }
            }

            // re-draw
            Invalidate();
        }
Esempio n. 24
0
        public ActionResult EditState(StateModel model, int id, int stateId)
        {
            if (ModelState.IsValid)
            {
                var state = db.States.Find(model.StateID);
                state.StateName = model.StateName;

                state.StateEditedBy   = Utils.CurrentUser;
                state.StateEditedDate = DateTime.Now;
                state.StateIsActive   = true;
                db.Entry(state).State = System.Data.Entity.EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("States"));
            }
            return(View("State/EditState", model));
        }
Esempio n. 25
0
        protected static List <StateModel> GetState4Country(int?Id)
        {
            StateModel objStateModel = new StateModel();

            if (Id != null && Id is int)
            {
                return(objStateModel.GetStateList(Convert.ToInt16(Id)));
            }
            return(objStateModel.stateList);

            //clsState objState = new clsState();
            //List<StateModel> stateList = objState.StateList.AsEnumerable().Where(c => c.RefCountryID == Id).ToList();
            //return stateList;
            //var state = stateList.Select(s => new { Value = s._StateID, Text = s._State });
            //return state;
        }
Esempio n. 26
0
        private bool CanSetStateName(StateModel state)
        {
            var name = state.StateName;

            if (name == "" || name == null)
            {
                return(false);
            }

            if (States.Count(x => x.StateName == name) > 1)
            {
                return(false);
            }

            return(true);
        }
Esempio n. 27
0
 /// <summary>
 /// Creates a state
 /// </summary>
 /// <param name="stateModel"></param>
 /// <returns></returns>
 public int Create(StateModel stateModel)
 {
     using (var scope = new TransactionScope())
     {
         var state = new StateLookup()
         {
             StateName         = stateModel.StateName,
             StateAbbreviation = stateModel.StateAbbreviation,
             Archived          = stateModel.Archived
         };
         _dbActions.StateRepository.Insert(state);
         _dbActions.Save();
         scope.Complete();
         return(state.Id);
     }
 }
        public ActionResult Index()
        {
            ViewBag.ListaTamPag             = new SelectList(new int[] { _quantMaxLinhasPorPagina, 10, 15, 20 }, _quantMaxLinhasPorPagina);
            ViewBag.QuantMaxLinhasPorPagina = _quantMaxLinhasPorPagina;
            ViewBag.PaginaAtual             = 1;

            var lista = StateModel.RecoverList(ViewBag.PaginaAtual, _quantMaxLinhasPorPagina);
            var quant = StateModel.RecoverQuantity();

            var difQuantPaginas = (quant % ViewBag.QuantMaxLinhasPorPagina) > 0 ? 1 : 0;

            ViewBag.QuantPaginas = (quant / ViewBag.QuantMaxLinhasPorPagina) + difQuantPaginas;
            ViewBag.Countrieses  = CountriesModel.RecoverList();

            return(View(lista));
        }
Esempio n. 29
0
        public StateModel Calculate(InputProcessModel inputModel)
        {
            //1 - initialize calculator
            SetupProcessElements(inputModel);
            ProcessState = new StateModel();

            //2 - get starting elements
            var startingElements = ProcessElements.Values.Where(x => x.PreviousElementIds.Count == 0);

            foreach (var startingElement in startingElements)
            {
                ExecuteElement(startingElement);
            }

            return(ProcessState);
        }
Esempio n. 30
0
        // --- without authentication

        public StateModel GetState()
        {
            var ret = new StateModel();

            lock (mutex)
            {
                var options = GetOptions();
                var timeout = options.GameOverTimeout;
                if (chessboard != null && chessboard.GameStarted && !chessboard.GameOver)
                {
                    timeout = options.SessionTimeout;
                }
                var now    = DateTime.Now;
                var nowUtc = DateTime.UtcNow;
                foreach (var pair in userTickets)
                {
                    var ctx  = pair.Value;
                    var diff = (int)(now - ctx.LastAccess).TotalSeconds;
                    if (diff > timeout * 60) // reset game after inactivity
                    {
                        chessboard = null;
                        if (IsComputerGame())
                        {
                            StopChessEngine();
                        }
                        userTickets.Clear();
                        stateChanged = nowUtc;
                        break;
                    }
                }
                if (chessboard != null)
                {
                    if (!chessboard.GameOver)
                    {
                        chessboard.UpdateClocks();
                        if (chessboard.GameOver)
                        {
                            stateChanged = DateTime.UtcNow;
                        }
                    }
                    ret.BlackClock = chessboard.BlackClock;
                    ret.WhiteClock = chessboard.WhiteClock;
                }
                ret.State = GetStateChanged();
                return(ret);
            }
        }
Esempio n. 31
0
 public IActionResult Index(StateModel stateModel)
 {
     if (stateModel.states == null)
     {
         stateModel.states = new SelectList(new List <SelectListItem>()
         {
             new SelectListItem()
             {
                 Text = "AAA", Value = "1"
             }, new SelectListItem()
             {
                 Text = "BBB", Value = "2"
             }
         }, "Value", "Text");
     }
     return(View(stateModel));
 }
        public StateModel GetStateById(StateModel _statemodal)
        {
            StateModel _objstate = new StateModel();

            using (newconecommerce dataContext = new newconecommerce())
            {
                _objstate = (from x in dataContext.tbl_States
                             where x.int_Id == _statemodal.intStateId
                             select new StateModel
                {
                    strStateName = x.v_State,
                    intCountryId = (int)x.int_CountryId
                }).FirstOrDefault();

                return(_objstate);
            }
        }
Esempio n. 33
0
        public IHttpActionResult Put(StateModel model)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }

                _stateService.Update(model);
                return(Ok(model));
            }
            catch (Exception ec)
            {
                return(BadRequest(ec.Message));
            }
        }
Esempio n. 34
0
        /// <summary>
        /// Fetches state details by id
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public StateModel GetById(int id)
        {
            var state = _dbActions.StateRepository.GetById(id);

            if (state != null)
            {
                StateModel stateEntity = new StateModel()
                {
                    Id                = state.Id,
                    StateName         = state.StateName,
                    StateAbbreviation = state.StateAbbreviation,
                    Archived          = state.Archived
                };
                return(stateEntity);
            }
            return(null);
        }
Esempio n. 35
0
        private static (decimal a, decimal b) TryParseOperands(string[] operands, StateModel state)
        {
            decimal a;
            decimal b;

            if (!decimal.TryParse(operands[0], out a)) //a is a reference!
            {
                a = state.GetVariable(operands[0]);
            }

            if (!decimal.TryParse(operands[1], out b)) //b is a reference!
            {
                b = state.GetVariable(operands[1]);
            }

            return(a : a, b : b);
        }
Esempio n. 36
0
        private bool ReadObject(StateModel state) {
            var ch = reader.Peek();
            var result = false;

            this.Position = readPos + 1; //peek のため
            this.Line = readLine;
            
            if (state.State == State.InObject) {
                if (!state.IsValue) {
                    if (ch == '}') {
                        if (state.BeforeComma && (relax & Relaxations.AllowLastComma) != Relaxations.AllowLastComma) {
                            throw CreateException(Resources.DisallowLastComma);
                        }
                        if (state.BeforeComma) {
                            HasLastComma = true;
                            IsStrict = false;
                        }
                        state.BeforeComma = false;
                        Next();
                        PopState();
                        PrepareTail(state);
                        this.Token = JsonToken.EndObject;
                        result = true;
                    } else {
                        state.BeforeComma = false;
                        result = ReadValue(state);
                        //文字列以外のプロパティは許可しない
                        if (this.Type != ValueType.String){
                            IsStrict = false;
                            if ((relax & Relaxations.AllowNonStringKeyName) != Relaxations.AllowNonStringKeyName) {
                                throw CreateException(Resources.DisallowNonStringKey);
                            }
                        }

                        //値以外はプロパティのキーにできない
                        if (this.Token != JsonToken.Value) {
                            throw CreateException(Resources.ErrorInvalidObjectKey);
                        }

                        PrepareTail(state);
                        this.Token = JsonToken.Key;
                        state.IsValue = true;
                    }
                } else {
                    state.BeforeComma = false;
                    result = ReadValue(state);
                    if (this.Token == JsonToken.Value) {
                        PrepareTail(state);
                        state.IsValue = false;
                    }
                }
            }

            return result;
        }
Esempio n. 37
0
    public void Update()
    {
        if (Current == null)
            return;

        if (Current.Id != (_old != null ? _old.Id : Guid.Empty))
        {
        #if DEBUG
        //            if (Verbose)
        //            {
        //                if (_old == null)
        //                    Debug.Log(Time.time + "s " + Name + ": Initial StateModel=" + Current.Name);
        //                else
        //                    Debug.Log(Time.time + "s " + Name + ": " + _old.Name + " -> " + Current.Name);
        //            }
        #endif

            Current.ExecEntry();
            _old = Current;
        }

        Current.ExecState();

        StateModel next;
        var trigger = Current.Update(out next);

        if (trigger)
        {
            Current.ExecExit();
            if (Current == next)
                Current.ExecEntry();
            else
                Current = next;
        }
    }
Esempio n. 38
0
        public bool Update(out StateModel state)
        {
            for (var index = 0; index < Conditions.Count; index++)
            {
                if (Conditions[index]())
                {
                    state = Parent.GetState(NextStates[index]);
                    return true;
                }
            }

            state = this;
            return false;
        }
 public ActionResult AddState(StateModel smodel)
 {
     try
     {
         HolidayPlanner.DAL.State st = new HolidayPlanner.DAL.State()
         {
             StateId = smodel.StateId,
             StateName = smodel.StateName,
             CountryId=smodel.CountryId
         };
         context.States.InsertOnSubmit(st);
         context.SubmitChanges();
         return RedirectToAction("Index");
     }
     catch
     {
         return View(smodel);
     }
 }
        private void PrepareCountry(StateModel model)
        {
            model.Countries = context.Countries.AsQueryable<HolidayPlanner.DAL.Country>().Select(x =>
                                                            new SelectListItem()
                                                            {
                                                                Text = x.CountryName,
                                                                Value = x.CountryId.ToString()
                                                            });

        }
Esempio n. 41
0
 public ReportTopFileCount(StateModel.ReportRequest rq, uint limit)
 {
     _limit = limit;
     _rq = rq;
 }
Esempio n. 42
0
        private bool ReadValue(StateModel state) {

            var ch = Next();

            this.Position = readPos;
            this.Line = readLine;

            var result = false;
            if (ch == '{') {
                PushState(StateModel.InObject());
                this.Token = JsonToken.StartObject;
                result = true;
            } else if (ch == '[') {
                PushState(StateModel.InArray());
                this.Token = JsonToken.StartArray;
                result = true;
            } else if (ch == '"' || ch == '\'') {
                //単一引用符の文字列は許可しない
                if (ch == '\'' ){
                    IsStrict = false;
                    if ((relax & Relaxations.AllowSingleQuoteString) != Relaxations.AllowSingleQuoteString) {
                        throw CreateException(Resources.DisallowSingleQuoteString);
                    }
                }
                this.Quote = ch == '"' ? QuoteType.Double : QuoteType.Single;
                result = ReadString(state);
            } else {
                result = ReadUnquoted(state, ch);
            }

            return result;
        }
Esempio n. 43
0
 public void Reset(StateModel stateModel)
 {
     _old = null;
     Current = stateModel;
 }
Esempio n. 44
0
 public StateMachine(string name)
 {
     States = new Dictionary<string, StateModel>();
     _old = Current = null;
     Name = name;
 }
Esempio n. 45
0
        private bool ReadArray(StateModel state) {
            var ch = reader.Peek();
            var result = false;

            this.Position = readPos + 1; //peek のため
            this.Line = readLine;

            if (state.State == State.InArray) {
                if (ch == ']') {
                    if (state.BeforeComma && (relax & Relaxations.AllowLastComma) != Relaxations.AllowLastComma) {
                        throw CreateException(Resources.DisallowLastComma);
                    }
                    if (state.BeforeComma) {
                        HasLastComma = true;
                        IsStrict = false;
                    }
                    
                    state.BeforeComma = false;
                    Next();
                    PopState();
                    PrepareTail(state);
                    this.Token = JsonToken.EndArray;
                    result = true;
                } else {
                    state.BeforeComma = false;
                    result = ReadValue(state);
                    if (this.Token == JsonToken.Value) {
                        PrepareTail(state);
                    }
                }
            }
            return result;
        }
Esempio n. 46
0
        private void PrepareTail(StateModel beforeState) {
            var state = stateStack.Peek();
            if (state.State == State.InArray) {
                if (!Skip()) {
                    throw CreateException(Resources.ErrorArrayNotCompleted);
                }
                var ch = reader.Peek();
                if (ch != ',' && ch != ']') {
                    throw CreateException(Resources.ErrorArrayNotCompleted);
                }
                if (ch == ',') {
                    Next();
                    state.BeforeComma = true;
                }
                return;
            }
            if (state.State == State.InObject) {

                if (state.IsValue) {
                    if (!Skip()) {
                        throw CreateException(Resources.ErrorObjectNotCompleted);
                    }
                    var ch = reader.Peek();
                    if (ch != ',' && ch != '}') {
                        throw CreateException(Resources.ErrorObjectNotCompleted);
                    }
                    if (ch == ',') {
                        Next();
                        state.BeforeComma = true;
                    }
                } else {
                    if (!Skip()) {
                        throw CreateException(Resources.ErrorNotSetObjectValue);
                    }
                    if (Next() != ':') {
                        throw CreateException(Resources.ErrorInvalidCharacter);
                    }
                }
                if (state != beforeState && (beforeState.State == State.InObject || beforeState.State == State.InArray)) {
                    state.IsValue = false;
                }
                return;
            }
        }
Esempio n. 47
0
        private bool ReadString(StateModel state) {
            var isEscaped = false;
            var builder = new StringBuilder();

            while (reader.Peek() > 0) {
                var ch = Next();
                if (isEscaped) {
                    isEscaped = false;
                    builder.Append(ch);
                } else if (ch == (this.Quote == QuoteType.Double ? '"' : '\'')) {
                    this.Value = builder.ToString();
                    this.Type = ValueType.String;
                    this.Token = JsonToken.Value;
                    return true;
                } else if (ch == '\\') {
                    isEscaped = true;
                    builder.Append(ch);
                } else if (ch == '\r' || ch == '\n') {
                    throw CreateException(Resources.ErrorNotCompletedStringValue);
                } else {
                    builder.Append(ch);
                }
            }
            throw CreateException(Resources.ErrorNotCompletedStringValue);
        }
Esempio n. 48
0
 private Vector3d Acceleration( StateModel state, double dampK, double dampB )
 {
     return (-dampK * state.a) - (dampB * state.v);
 }
Esempio n. 49
0
        private bool ReadUnquoted(StateModel state, char first) {
            
            if (unquotedTailRegex.IsMatch(first.ToString())) {
                if (state.State == State.InObject && state.IsValue) {
                    throw CreateException(Resources.ErrorNotSetObjectValue);
                }
                if (state.State == State.InObject && !state.IsValue && first == ':') {
                    throw CreateException(Resources.ErrorNotSetObjectKey);
                }
                throw CreateException(Resources.ErrorInvalidCharacter);
            }
            var builder = new StringBuilder();

            builder.Append(first);
            while (reader.Peek() > 0) {
                var ch = (char)reader.Peek();
                if (unquotedTailRegex.IsMatch(ch.ToString())) {
                    break;
                }
                builder.Append(Next());
            }
            this.Value = builder.ToString();
            this.Type = JudgeUnquotedValue(this.Value);
            this.Token = JsonToken.Value;
            return true;
        }
Esempio n. 50
0
    public void UpdateStatus(StateModel model)
    {
        var hero = GetCharacter(model.heroIdx);
        if (hero == null)
            return;

        hero.UpdateStatus(model);
    }
Esempio n. 51
0
 private void PushState(StateModel newState) {
     stateStack.Push(newState);
 }
 public ActionResult AddState()
 {
     StateModel smodel = new StateModel();
     PrepareCountry(smodel);
     return View(smodel);
 }
Esempio n. 53
0
 public void UpdateStatus(StateModel model)
 {
     if (model.isRemove)
     {
         Hud.RemoveStatus(model.id);
     }
     else
     {
         Hud.UpdateStatus(model.id, model.type, model.duration);
     }
 }