public List <NumberObject> Get() { var JsonNumbers = Path.Combine(Directory.GetCurrentDirectory(), $".\\JsonFiles\\Numbers.json"); var Numbers = System.IO.File.ReadAllText(JsonNumbers); JObject NumbersArray = JObject.Parse(Numbers); List <NumberObject> result = new List <NumberObject>(); ListNumberObject ListNumber = JsonConvert.DeserializeObject <ListNumberObject>(Numbers); for (int i = 0; i < ListNumber.numbers.Count(); i++) { NumberObject n = new NumberObject(); n.number = Convert.ToInt32(ListNumber.numbers[i]); n.isMultiple = true; if (n.number % 11 == 0) { n.isMultiple = false; } result.Add(n); } return(result); }
public static void Main() { string json = @" { '01':'One', '02':'Two', '03':'Three', '04':'Four', '05':'Five', '06':'Six', '07':'Seven', '08':'Eight', '09':'Nine', '10':'Ten' }" ; JObject o = JObject.Parse(json); NumberObject zero = new NumberObject("00", "zero"); List <NumberObject> list = new List <NumberObject>(); foreach (JProperty p in o.Properties()) { NumberObject num = new NumberObject(p.Name, (string)p.Value); list.Add(num); } // now list can be used as your data source as it is of type List<NumberObject> }
public IActionResult About(int Id) { NumberObject.SetLimitNo(Id.ToString()); Product myProduct = new Product { GUID = "SettingNo", Name = Id.ToString() }; return(View(myProduct)); }
public IHttpActionResult Guess(NumberObject guess, int id) { if (guess == null) { return(this.BadRequest("Po seriozno!")); } if (!AreNumbersValid(guess.Number)) { return(this.BadRequest(string.Format("Numbers must be unique with length {0}!", GlobalConstants.NumberLength))); } Game game = this.gameService.GetGameDetails(id); var response = new HttpResponseMessage(); if (game == null) { response.StatusCode = HttpStatusCode.NotFound; response.Content = new StringContent(string.Format("Game with id {0} not found!", id)); return(this.ResponseMessage(response)); } var playerId = this.User.Identity.GetUserId(); if (!(game.BluePlayerId == playerId || game.RedPlayerId == playerId)) { response.StatusCode = HttpStatusCode.Forbidden; response.Content = new StringContent("You are not allowed to make guess in this game"); return(this.ResponseMessage(response)); } string currentPlayer = game.BluePlayerId == playerId ? "BluePlayerTurn" : "RedPlayerTurn"; if (currentPlayer != game.GameState.ToString()) { if (game.GameState == GameState.Finished) { response.StatusCode = HttpStatusCode.Forbidden; response.Content = new StringContent("Game Is Finished!"); return(this.ResponseMessage(response)); } response.StatusCode = HttpStatusCode.Forbidden; response.Content = new StringContent("It's not your turn!"); return(this.ResponseMessage(response)); } string numberToGuess = game.BluePlayerId == playerId ? game.RedPlayerGuessNumber : game.BluePlayerGuessNumber; Guess guessFromServer = this.guessService.MakeGuess(guess.Number, numberToGuess, playerId, game.Id); GuessResponseModel responseGuess = Mapper.Map <GuessResponseModel>(guessFromServer); return(this.Ok(responseGuess)); }
public IActionResult SqrtN([FromBody] NumberObject data) { if (ModelState.IsValid) { String result = Helper.convert(data.unsignedNumber); ResultObject resultObject = new ResultObject(result); return(Ok(resultObject)); } return(BadRequest(ModelState)); }
// Events #region Events private void OnResultChecked(bool correct, NumberObject selectedOption) { if (correct) // End round and show a new number { foreach (NumberObject opt in currOptions) { opt.Fade(false); } currOptions.Clear(); // Start again MainController.Instance.StartAgain(); } else // Check if it's the last incorrect answer to select { if (currOptions.Count > 2) { currOptions.Remove(selectedOption); selectedOption.Fade(false, () => { // Enable interaction again foreach (NumberObject opt in currOptions) { opt.SetInteraction(true); } }); } else { // 1. Mark the correct option with green foreach (NumberObject opt in currOptions) { if (opt.NumValue == MainController.Instance.CurrAnswer) { opt.UpdateColor(true); break; } } // 2. Fade out these 2 remaining options foreach (NumberObject opt in currOptions) { opt.Fade(false); } currOptions.Clear(); // 3. Start again MainController.Instance.StartAgain(); } } }
// Public #region Public public void AddOptions(List <int> options) { currOptions.Clear(); gameObject.SetActive(true); // For each value, create an option object to be shown foreach (var item in options) { NumberObject obj = Instantiate(Resources.Load(prefabPath) as GameObject, transform).GetComponent <NumberObject>(); obj.Init(item, () => { SelectOption(obj.NumValue, obj); }); currOptions.Add(obj); } }
public void SelectOption(int value, NumberObject selectedOption) { Debug.Log("Option Selected: " + value); bool answer = value == MainController.Instance.CurrAnswer; // Disable all interaction foreach (NumberObject button in currOptions) { button.SetInteraction(false); } selectedOption.CheckResult(answer); // Update score MainController.Instance.UpdateScore(answer); }
//int id public IActionResult Index(string Id) { // ViewData["Number"] = // return View(); // User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36 Edge/16.16299 //var ip = Request.Headers["X-Forwarded-For"].FirstOrDefault(); string ip = Request.Headers["User-Agent"].FirstOrDefault(); string iKey = Id != null && Id.Length > 0 ? Id : NumberObject.GenerateMD5(ip); Product myProduct = new Product { GUID = iKey, Name = NumberObject.PickNumber(iKey) }; return(View(myProduct)); }
public IHttpActionResult Put(NumberObject join, int id) { if (join == null) { return(this.BadRequest("Provide a 4 digit unique number to join in game!")); } if (!AreNumbersValid(join.Number)) { return(this.BadRequest(string.Format("Numbers must be unique with length {0}!", GlobalConstants.NumberLength))); } Game game = this.gameService.GetGameDetails(id); var response = new HttpResponseMessage(); if (game == null) { response.StatusCode = HttpStatusCode.NotFound; response.Content = new StringContent(string.Format("Game with id {0} not found!", id)); return(this.ResponseMessage(response)); } if (game.GameState != GameState.WaitingForOpponent) { response.StatusCode = HttpStatusCode.BadRequest; response.Content = new StringContent("This game is running or finished. You can't join!"); return(this.ResponseMessage(response)); } if (game.RedPlayerId == this.User.Identity.GetUserId()) { response.StatusCode = HttpStatusCode.BadRequest; response.Content = new StringContent("You already joined is this game!"); return(this.ResponseMessage(response)); } this.gameService.JoinGame(game, this.User.Identity.GetUserId(), join.Number, this.User.Identity.Name); return(this.Ok(string.Format("You joined game \"{0}\"", game.Name))); }
public static double op_Addition(None x, [NotNull] NumberObject y) { throw new NotImplementedException(); }
// Events #region Events public void CheckResultEnded(bool correct, NumberObject selOpt) { ResultChecked?.Invoke(correct, selOpt); }
public static bool op_GreaterThan([NotNull] NumberObject x, [NotNull] string y) { throw new NotImplementedException(); }
public static ConcatString op_Addition(ConcatString x, NumberObject y) { throw new NotImplementedException(); }
public static bool op_GreaterThanOrEqual([NotNull] NumberObject x, [NotNull] UnDefined y) { throw new NotImplementedException(); }
public static bool op_LessThan([NotNull] NumberObject x, [NotNull] UnDefined y) { throw new NotImplementedException(); }
public NumberValueEval(NumberObject numberObject) { NumberObject = numberObject; }
public static bool op_Inequality([NotNull] NumberObject x, [NotNull] string y) { throw new NotImplementedException(); }
public static bool op_LessThanOrEqual([NotNull] NumberObject x, [NotNull] string y) { throw new NotImplementedException(); }
public static double op_Addition([NotNull] NumberObject x, [NotNull] UnDefined y) { throw new NotImplementedException(); }
public static ConcatString op_Addition([NotNull] NumberObject x, [NotNull] string y) { throw new NotImplementedException(); }
public static bool op_Equality([NotNull] NumberObject x, double y) { throw new NotImplementedException(); }
public static double op_Addition(decimal x, NumberObject y) { throw new NotImplementedException(); }
public IAdaptingType read(JsonReader reader, ParseContext parseContext) { CacheableAdaptingTypeWrapper typeProxy = new CacheableAdaptingTypeWrapper(); IDictionary properties = new Hashtable(); Boolean referencedAdded = false; // skip '[' and move to next element reader.Read(); while (reader.TokenClass != JsonTokenClass.EndObject) { string name = reader.ReadMember(); if (!referencedAdded && !reservedKeyNames.Contains(name)) { referencedAdded = true; parseContext.addReference(typeProxy); } if (name.Equals(DATESMETA)) { parseContext.TurnOnIgnoreMode(); } properties.Add(name, RequestParser.Read(reader)); if (name.Equals(DATESMETA)) { parseContext.TurnOffIgnoreMode(); } if (properties.Count == 1) { if (properties.Contains(OBJECTREF)) { NumberObject objectRef = (NumberObject)properties[OBJECTREF]; properties.Remove(OBJECTREF); int refId = (int)objectRef.defaultAdapt(); reader.Read(); return(parseContext.getReference(refId)); } else if (properties.Contains(STRINGREF)) { NumberObject objectRef = (NumberObject)properties[STRINGREF]; properties.Remove(STRINGREF); int refId = (int)objectRef.defaultAdapt(); reader.Read(); return(new StringType(parseContext.getStringReference(refId >> 1))); } else if (properties.Contains(DATEREF)) { NumberObject objectRef = (NumberObject)properties[DATEREF]; properties.Remove(DATEREF); int refId = (int)objectRef.defaultAdapt(); reader.Read(); return(parseContext.getReference(refId)); } else if (properties.Contains(ARRAYREF)) { NumberObject objectRef = (NumberObject)properties[ARRAYREF]; properties.Remove(ARRAYREF); int refId = (int)objectRef.defaultAdapt(); reader.Read(); return(parseContext.getReference(refId)); } // if we got here, it is not a reference, but an object (anonymous or named) // so let's add it to reference cache //parseContext.addReference( typeProxy ); } } // if properties is empty, it might be an empty dictionary, which may have a pointer to it elsewhere if (properties.Count == 0) { parseContext.addReference(typeProxy); } // skip ']' reader.Read(); return(new AnonymousObject(properties)); }