static void Main(string[] args) { IGolpe megaPunch = new MegaPunch(); IGolpe flameThrower = new FlameThrower(); IGolpe bubbleBeam = new BubbleBeam(); IGolpe scratch = new Scratch(); IGolpe leechSeed = new LeechSeed(); Pokemon charmander = new TipoFogo("Charmander", 5); Pokemon bulbasaur = new TipoPlanta("Bulbasaur", 5); Pokemon squirtle = new TipoAgua("Squirtle", 5); Pokemon pikachu = new TipoEletrico("Pikachu", 5); Pokemon meowth = new TipoNormal("Meowth", 5); List <Pokemon> especies = new List <Pokemon>() { charmander, bulbasaur, squirtle, pikachu, meowth }; List <IGolpe> golpes = new List <IGolpe>() { megaPunch, flameThrower, bubbleBeam, scratch, leechSeed }; foreach (Pokemon pokemon in especies) { foreach (IGolpe golpe in golpes) { pokemon._golpe = golpe; Console.WriteLine("{0} no nível {1} utilizando {2} causa dano de {3}HP", pokemon._especie, pokemon._nivel, pokemon._golpe._nomeGolpe, pokemon.Ataque()); } } }
public async Task AddAsync(Scratch parameters) { await DbContextManager.BeginTransactionAsync(); var spParameters = new SqlParameter[4]; spParameters[0] = new SqlParameter() { ParameterName = "rewardAmount", Value = parameters.RewardAmount }; spParameters[1] = new SqlParameter() { ParameterName = "recieverId", Value = parameters.RecieverId }; spParameters[2] = new SqlParameter() { ParameterName = "sendDate", Value = parameters.sendDate }; spParameters[3] = new SqlParameter() { ParameterName = "rewardId", Value = parameters.RewardId }; await DbContextManager.StoreProc <StoreProcResult>("[dbo].spRewards ", spParameters); try { await DbContextManager.CommitAsync(); } catch (Exception e) { DbContextManager.RollbackTransaction(); } }
public void ShouldReturnAnOrderedListOfInstrutors() { //arrange Scratch scratch = new Scratch(); string[] expectedInstructors = new string[] { "Scott", "Keith", "Fritz", "Aaron" }; //act //IEnumerable<string> rawInstructors = from instructor in scratch.Instructors // where instructor.Length == 5 // orderby instructor descending // select instructor; List <string> instructors = scratch.Instructors .Where(i => i.Length == 5) .OrderByDescending(i => i).ToList(); //assert instructors.ShouldNotBeNull(); instructors.Count.ShouldBe(4); instructors.ShouldBe(expectedInstructors); }
public IHttpActionResult PostScratch(Scratch scratch) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _authorRepo.InsertAuthor(scratch); return(Ok(scratch)); }
public bool UpdateAuthor(int id, Scratch author) { int rowsAffected = this._db.Execute("UPDATE [Scratch] SET [FirstName] = @FirstName, [LastName]=@LastName, [IsActive]=@IsActive WHERE Id = " + author.Id, author); if (rowsAffected > 0) { return(true); } return(false); }
public IHttpActionResult GetScratch(int id) { Scratch scratch = _authorRepo.GetSingleAuthor(id); if (scratch == null) { return(NotFound()); } return(Ok(scratch)); }
public void TestIt() { var result = Scratch.findAdditions(new List <int> { 1 }, new List <int> { 1, 2, 3 }); Expect(result.Count, Is.EqualTo(2)); Expect(result.Contains(2), Is.True); }
public IHttpActionResult DeleteScratch(int id) { Scratch scratch = _authorRepo.GetSingleAuthor(id); if (scratch == null) { return(NotFound()); } _authorRepo.DeleteAuthor(id); return(Ok(scratch.FirstName + " Deleted")); }
void Start() { exeDirectory = new DirectoryInfo(Application.dataPath).Parent.FullName; poopTimer = PoopDelay * UnityEngine.Random.Range(0.8f, 1.2f); var texture = Resources.Load("Poop") as Texture2D; crunchedPoop = texture.EncodeToPNG(); audioSource = GetComponent<AudioSource>(); cooldog = GetComponent<Cooldog>(); textTyper = GetComponent<TextTyper>(); scratch = GetComponentInChildren<Scratch>(); }
public IHttpActionResult PutScratch(int id, Scratch scratch) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != scratch.Id) { return(BadRequest()); } _authorRepo.UpdateAuthor(id, scratch); return(StatusCode(HttpStatusCode.Accepted)); }
protected override void PageSwitchSetting(bool initalize) { base.PageSwitchSetting(initalize); //ページ初期化処理 if (m_Scratch == null) { m_Scratch = GetComponentInChildren <Scratch>(); m_Scratch.SetPositionAjustStatusBar(new Vector2(0, -67.5f), new Vector2(0, -135)); } // 看板イメージ(ATLAS未使用) setupScratch(); MainMenuManager.Instance.currentCategory = MAINMENU_CATEGORY.GACHA; }
public bool InsertAuthor(Scratch newAuthor) { int rowsAffected = this._db.Execute(@"INSERT Scratch([Id], [FirstName], [LastName], [IsActive]) values (@Id, @FirstName, @LastName, @IsActive)", new { Id = newAuthor.Id, FirstName = newAuthor.FirstName, LastName = newAuthor.LastName, IsActive = newAuthor.IsActive }); if (rowsAffected > 0) { return(true); } return(false); }
// Use this for initialization void Start() { // ページ切り替え用トグルの設定 Context.Toggle = GetComponent <Toggle>(); ToggleGroup toggleGroup = GetComponentInParent <ToggleGroup>(); if (toggleGroup != null) { Context.Toggle.group = toggleGroup; } Context.m_StepButton = m_StepButton; // コールバック設定 Scratch scratch = GetComponentInParent <Scratch>(); if (scratch != null) { Context.Toggle.onValueChanged.AddListener(scratch.OnChangedForm); } }
public Task DeleteAsync(Scratch parameters) { throw new NotImplementedException(); }
public HashSet <string> DeleteValidation(Scratch parameters) { return(ValidationMessages); }
public async Task UpdateAsync(Scratch entity) { await Uow.RegisterDirtyAsync(entity); await Uow.CommitAsync(); }
public HashSet <string> UpdateValidation(Scratch entity) { return(ValidationMessages); }
/// <summary> /// 报存抽奖记录 /// </summary> /// <param name="s"></param> /// <returns></returns> public int SaveScratch(Scratch s) { return(_set.SaveScratch(s)); }
public void ProcessRequest(HttpContext context) { if (GetQeuryString("para", context) == "jsapi") //获取js接口凭证 { try { ORG_INFO m = mss.GetWD(context.Session["ToUserName"].ToString()); if (m != null) { } } catch (Exception ex) { context.Response.Write(ex.Message + "," + ex.StackTrace); } } else if (GetQeuryString("para", context) == "SaveLocation") //保存地理位置 { try { ORG_INFO m = mss.GetWD(context.Session["ToUserName"].ToString()); if (m != null) { WD_Location l = new WD_Location(); l.accuracy = context.Request.Params["accuracy"]; l.Createdate = DateTime.Now; l.FromUserName = context.Session["FromUserName"].ToString(); l.latitude = context.Request.Params["latitude"]; l.longitude = context.Request.Params["longitude"]; l.speed = context.Request.Params["speed"]; l.ToUserName = context.Session["ToUserName"].ToString(); new WeiPage().GetBaiDuMap(ref l); mss.SaveLocation(l); context.Response.Write("0"); } } catch (Exception ex) { context.Response.Write(ex.Message + "," + ex.StackTrace); } } else if (GetQeuryString("para", context) == "GetScratch") //获取刮刮乐数据 { try { if ((context.Request.QueryString["FromUserName"] != null || context.Session["FromUserName"] != null) && (context.Request.QueryString["ToUserName"] != null || context.Session["ToUserName"] != null)) { string user = context.Request.QueryString["FromUserName"] == null ? context.Session["FromUserName"].ToString() : context.Request.QueryString["FromUserName"].ToString(); string user2 = context.Request.QueryString["ToUserName"] == null ? context.Session["ToUserName"].ToString() : context.Request.QueryString["ToUserName"].ToString(); CUST_INFO cust = op.GetCustinfoByFromusername(user); if (cust == null) { string url = "../../Member/Index.aspx?tousername=gh_60153a15d878&fromusername="******"{\"message\":\"你尚未绑定,请先绑定\",\"url\":\"" + url + "\",\"status\":\"" + 0 + "\"}"); } else if (cust.LAST_MODI_DATE != null && (cust.LAST_MODI_DATE < DateTime.Parse("2015-05-5") || cust.LAST_MODI_DATE > DateTime.Parse("2015-06-16"))) { //5月15至7月15 context.Response.Write("{\"message\":\"仅5.13-6.15期间绑定的会员方可参与此活动。\",\"url\":\"\",\"status\":\"" + 1 + "\"}"); } else { Scratch scr = mss.GetScratch(user); if (scr != null) { context.Response.Write("{\"message\":\"每人仅可参加一次此活动,感谢您的参与。\",\"url\":\"\",\"status\":\"" + 1 + "\"}"); } else { Random r = new Random(); int num = r.Next(0, 50); switch (num) { case 0: List <Scratch> slist = mss.GetScratchList("1", DateTime.Now.AddDays(-3)); //每三天只中一个 if (slist.Count > 0) { mss.SaveScratch(new Scratch { CreateDate = DateTime.Now, FromUserName = user, JP = "0", Code = -1 }); context.Response.Write("{\"message\":\"未中奖\",\"status\":\"" + -1 + "\"}"); } else { try { Hmj.WebApp.TicketService.VoucherWebServiceSoapClient d = new Hmj.WebApp.TicketService.VoucherWebServiceSoapClient(); string a = d.SendSignVoucherByFromUserName(user, 3924); server ser = JsonConvert.DeserializeObject <server>(a); //if (ser.Code == 0) //{ mss.SaveScratch(new Scratch { CreateDate = DateTime.Now, FromUserName = user, JP = "1", Code = ser.Code }); context.Response.Write("{\"message\":\"价值680元的护理免券1张\",\"status\":\"" + 3 + "\"}"); //} } catch (Exception) { mss.SaveScratch(new Scratch { CreateDate = DateTime.Now, FromUserName = user, JP = "0", Code = -1 }); context.Response.Write("{\"message\":\"未中奖\",\"status\":\"" + -1 + "\"}"); } } break; default: mss.SaveScratch(new Scratch { CreateDate = DateTime.Now, FromUserName = user, JP = "0", Code = -1 }); context.Response.Write("{\"message\":\"未中奖\",\"status\":\"" + -1 + "\"}"); break; } } } } } catch (Exception ex) { context.Response.Write(ex.Message + "," + ex.StackTrace); } } }
/// <summary> /// 报存抽奖记录 /// </summary> /// <param name="s"></param> /// <returns></returns> public int SaveScratch(Scratch s) { return((int)Insert(s)); }
public ScratchTests() { sut = new Scratch(); }
public void TestScratchMethod() { Scratch.Test(); }
public static void Run(string[] folders, int files, long size) { var scratch = new Scratch( new DiskFileSource(folders, files / folders.Length, size), CancellationToken.None); Console.WriteLine( "Found {0} values in existing files", scratch.Count); var pool = ArrayPool <int> .Create(); const int Length = 1 << 24; var i = 0; var sw = Stopwatch.StartNew(); Task.WaitAll(Enumerable.Range(0, 8).Select(_ => Task.Run(Act)).ToArray()); void Act() { var available = new List <Hash>(); var left = new int[Length]; var right = new int[Length]; var rand = new Random(100); void LoadRandomInto(int[] array) { while (true) { if (available.Count == 0) { for (var s = 0; s < Length; ++s) { array[s] = rand.Next(); } return; } var pos = rand.Next(available.Count); var hash = available[pos]; try { scratch.Read(1, hash, span => { if (!BlockHasher.ComputeHash(span).Equals(hash)) { Console.WriteLine("Bad hash!"); } MemoryMarshal.Cast <byte, int>(span).CopyTo(array); return(true); }); return; } catch (MissingBlockException) { Console.WriteLine("{0} Missing {1}", sw.Elapsed, hash); available[pos] = available[available.Count - 1]; available.RemoveAt(available.Count - 1); } } } int j = 0; while (j < 10000) { j = Interlocked.Increment(ref i); var result = pool.Rent(Length); LoadRandomInto(left); LoadRandomInto(right); for (var c = 0; c < Length; ++c) { result[c] = left[c] + right[c]; } var hash = BlockHasher.ComputeHash( MemoryMarshal.Cast <int, byte>(result.AsSpan(0, Length))); available.Add(hash); scratch.Write(1, hash, Length * sizeof(int), span => { MemoryMarshal.Cast <int, byte>(result.AsSpan(0, Length)).CopyTo(span); pool.Return(result); }); var total = j * sizeof(int) * (long)Length; Console.WriteLine( "i = {3} {0} Wrote {1} MB ({2:F2} MBps)", sw.Elapsed.TotalSeconds, total >> 20, total / sw.Elapsed.TotalSeconds / 1024 / 1024, j); } } }
public Task <object> GetBy(Scratch parameters) { throw new NotImplementedException(); }
internal Pipe(Loop loop, bool ipc) : base(loop, ipc) { this.scratch = new Scratch(); }
public void Start() { Scratch = GetComponent<Scratch>(); }