/// <summary> /// Gets the hash code /// </summary> /// <returns>Hash code</returns> public override int GetHashCode() { unchecked // Overflow is fine, just wrap { var hashCode = 41; // Suitable nullity checks etc, of course :) if (Name != null) { hashCode = hashCode * 59 + Name.GetHashCode(); } if (Version != null) { hashCode = hashCode * 59 + Version.GetHashCode(); } if (Status != null) { hashCode = hashCode * 59 + Status.GetHashCode(); } if (Who != null) { hashCode = hashCode * 59 + Who.GetHashCode(); } if (When != null) { hashCode = hashCode * 59 + When.GetHashCode(); } return(hashCode); } }
public void TransportMessage(Who recipient, Message msg) { Assert.IsNull(recipient); Assert.IsNull(xreply); xreply = msg; _baseObj.xreplyMon.Set(new Message(new XType("dummy"), new ValueFactoryTest1("none:"))); }
//Event handler for every time the rain timer ticks private void rain_Tick(object sender, EventArgs e) { for (int i = 0; i < rainAmount; i++) { int nextInt = Rand.Next(0, rainDokiesSelected); int nextSizeInt = Rand.Next(0, rainSizeCount); if (!justMonika) { if (nextInt == 0 && !rainSayori) { nextInt++; } if (nextInt == 1 && !rainNatsuki) { nextInt++; } if (nextInt == 2 && !rainYuri) { nextInt++; } } else { nextInt = (int)Who.wMonika; } if (nextSizeInt == 0 && !rainLarge) { nextSizeInt++; } if (nextSizeInt == 1 && !rainMedium) { nextSizeInt++; } Who next = (Who)nextInt; DokiSize nextSize = (DokiSize)nextSizeInt; Doki doki = null; switch (next) { case Who.wSayori: doki = GetSayori((int)nextSize, true); break; case Who.wNatsuki: doki = GetNatsuki((int)nextSize, true); break; case Who.wYuri: doki = GetYuri((int)nextSize, true); break; case Who.wMonika: doki = GetMonika((int)nextSize, true); break; } doki.Location = new Point(Rand.Next(0, doki.rWall), -doki.Height - 5); doki.Show(); } rain.Interval = Rand.Next(lowerRainInterval, higherRainInterval + 1); }
public void TransportPacket(Who recipient, FlexBuffer buf) { // Data-ize the packet // assert index is at the start of the header. int dataSize = buf.Avail(); if (dataSize < HEADER_SIZE) { throw new ArgumentException("dataSize < HEADER_SIZE"); } int pktSize = dataSize - HEADER_SIZE; if (maxPktSize > 0 && pktSize > maxPktSize) { throw new ArgumentException("maxPktSize > 0 && pktSize > maxPktSize"); } int index = buf.Index(); buf.PutInt(SIG); buf.PutInt(pktSize); buf.SetIndex(index); transport.TransportData(recipient, buf); }
public void SaveAndReadTest() { Who recipient = new Who(); recipient.Email = "*****@*****.**"; recipient.Rel = Who.RelType.MESSAGE_TO; entry.Recipient = recipient; StringBuilder sb = new StringBuilder(); XmlWriter writer = new XmlTextWriter(new StringWriter(sb)); entry.SaveToXml(writer); writer.Close(); XmlDocument document = new XmlDocument(); document.LoadXml(sb.ToString()); EmailListRecipientEntry newEntry = new EmailListRecipientEntry(); foreach (XmlNode node in document.FirstChild.ChildNodes) { ExtensionElementEventArgs args = new ExtensionElementEventArgs(); args.ExtensionElement = node; args.Base = newEntry; newEntry.Parse(args, new AtomFeedParser()); } Assert.AreEqual(recipient.Email, newEntry.Recipient.Email, "Parsed entry should have same recipient as original entry"); }
public void SetEmailListTest() { Who recipient = new Who(); entry.Recipient = recipient; Assert.AreEqual(recipient, entry.Recipient, "Recipient should be updated after setting"); }
private void WriteToFile(Direction direction, Who msgOrigin, String msg) { if (writer == null) { return; } try { lock (writer) { writer.Write(DateTime.Now.ToString("HH:mm:ss.fff", CultureInfo.CreateSpecificCulture("en-US"))); writer.Write(": "); writer.Write(ConvertDirToString(direction)); writer.Write(": "); if (msgOrigin != null) { writer.Write(msgOrigin.ToString()); writer.Write(": "); } writer.Write(msg); writer.WriteLine(); writer.Flush(); } } catch (Exception e) { writer.Close(); throw e; } }
public bool SessionMessage(Who sender, Message msg) { what = What.TESTMESSAGEHANDLERMESSAGE; this.xsender = sender; this.xmsg = msg; return(handled); }
public void SessionData(Who sender, FlexBuffer buf) { xsender = sender; xbuf = buf.GetAvailBytes(); what.WaitUntilEqAndSet(default(What), TIMEOUT, What.DATA); }
public override IDeepCopyable CopyTo(IDeepCopyable other) { var dest = other as AgentComponent; if (dest == null) { throw new ArgumentException("Can only copy to an object of the same type", "other"); } base.CopyTo(dest); if (Type != null) { dest.Type = (Hl7.Fhir.Model.CodeableConcept)Type.DeepCopy(); } if (Role != null) { dest.Role = new List <Hl7.Fhir.Model.CodeableConcept>(Role.DeepCopy()); } if (Who != null) { dest.Who = (Hl7.Fhir.Model.ResourceReference)Who.DeepCopy(); } if (OnBehalfOf != null) { dest.OnBehalfOf = (Hl7.Fhir.Model.ResourceReference)OnBehalfOf.DeepCopy(); } return(dest); }
public bool Message(Who sender, Message msg) { what = What.TESTMESSAGEHANDLERMESSAGE; this.xsender = sender; this.xmsg = msg; return(handled); /** * if (report) * Console.WriteLine( "message: "+msg ); * * if (msg.IsType( mt_add )) * { * int? x = (int?)( msg.Get( mf_x ) ); * int? y = ( int? ) ( msg.Get( mf_y ) ); * * Int32 r = ( int ) ( x + y ); * * Message rmsg = msg.Reply( mt_add_result ); * rmsg.Add( mf_result, r ); * * if (report) * Console.WriteLine( "replying with "+rmsg ); * * src.Message( sender, rmsg ); * } * * return true; * */ }
protected void Page_Load(object sender, EventArgs e) { _messageSender = (Person)Session["CurrentUser"]; if (!IsPostBack) { var toList = new List <string>(); if (_messageSender is Teacher) { toList.Add("ילד ספציפי"); toList.Add("כל ילדי הגן"); toList.Add("מפקחת"); } if (_messageSender is Supervisor) { toList.Add("גננת"); toList.Add("ילדי המחוז"); toList.Add("גננות המחוז"); } Who.DataSource = toList; Who.AutoPostBack = true; Who.DataBind(); if (_messageSender is Child) { Who.Visible = false; WhoLable.Visible = true; } } }
public static void HandleFinishedObjectInMachine(Object machine, Chest connectedChest) { var logMessage = $"Collecting a {machine.heldObject?.Name} from your {machine.Name}."; if (connectedChest.items.Count > ChestMaxItems) { Monitor.Log($"Your chest is already full. Cannot place item from {machine.Name} into it.", LogLevel.Error); return; } machine.checkForAction(Who); Who.items.ForEach(i => { if (i != null) { var result = connectedChest.addItem(i); if (result != null) { Game1.player.addItemToInventory(result); } } }); if (machine.heldObject != null && machine.minutesUntilReady > 0) { logMessage += $" The next {machine.heldObject.Name} will be ready in {machine.minutesUntilReady}"; } Who.ClearInventory(); Monitor.Log(logMessage, LogLevel.Info); }
public override int GetHashCode() { int hash = 1; if (buzz_ != null) { hash ^= Buzz.GetHashCode(); } if (Where.Length != 0) { hash ^= Where.GetHashCode(); } if (Who.Length != 0) { hash ^= Who.GetHashCode(); } if (How.Length != 0) { hash ^= How.GetHashCode(); } if (What.Length != 0) { hash ^= What.GetHashCode(); } if (Why.Length != 0) { hash ^= Why.GetHashCode(); } if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
public override String ToString() { String value = null; switch (What) { case LightingWhat.DimmerDown: case LightingWhat.DimmerUp: case LightingWhat.LightOFF: case LightingWhat.LightON: value = String.Format(CMD_BUS, Who.GetStringValue(), What.GetStringValue(), Where); break; case LightingWhat.DimmerStrenght: value = String.Format(CMD_BUS, Who.GetStringValue(), DimmerStrenght / 10, Where); break; case LightingWhat.LightOnAtSpeed: case LightingWhat.LightOffAtSpeed: value = String.Format(CMD_BUS, Who.GetStringValue(), String.Format(What.GetStringValue(), Speed), Where); break; case LightingWhat.GetStatus: value = String.Format(GET_STATE, Who.GetStringValue(), Where); break; } return(value); }
public bool SessionMessage(Who sender, Org.Apache.Etch.Bindings.Csharp.Msg.Message msg) { this.what = What.SESSION_MESSAGE; this.sender = sender; this.msg = msg; return(handled); }
public override IDeepCopyable CopyTo(IDeepCopyable other) { var dest = other as Signature; if (dest == null) { throw new ArgumentException("Can only copy to an object of the same type", "other"); } base.CopyTo(dest); if (Type != null) { dest.Type = new List <Hl7.Fhir.Model.Coding>(Type.DeepCopy()); } if (WhenElement != null) { dest.WhenElement = (Hl7.Fhir.Model.Instant)WhenElement.DeepCopy(); } if (Who != null) { dest.Who = (Hl7.Fhir.Model.DataType)Who.DeepCopy(); } if (ContentTypeElement != null) { dest.ContentTypeElement = (Hl7.Fhir.Model.Code)ContentTypeElement.DeepCopy(); } if (BlobElement != null) { dest.BlobElement = (Hl7.Fhir.Model.Base64Binary)BlobElement.DeepCopy(); } return(dest); }
public override string ToString() { String value = null; switch (What) { case AlarmWhat.GetZoneStatus: value = String.Format(GET_STATE, Who.GetStringValue(), String.Format(What.GetStringValue(), Zone)); break; case AlarmWhat.GetCentralUnitStatusFromWebServer: value = String.Format(GET_STATE_NO_WHERE, Who.GetStringValue()); break; case AlarmWhat.GetCentralUnitStatusFromCentralUnit: value = String.Format(GET_STATE, Who.GetStringValue(), What.GetStringValue()); break; case AlarmWhat.GetAuxiliaresStatusFromWebServer: value = String.Format(GET_STATE_NO_WHERE, WHO.Auxiliaries.GetStringValue()); break; } return(value); }
public void TransportPacket(Who recipient, FlexBuffer buf) { byte[] sendBytes = buf.GetAvailBytes(); if (listener != null) { IPEndPoint ipe = remoteIpEndPoint; if (recipient != null) { if (!(recipient is WhoSender)) { throw new Exception("unknown recipient"); } ipe = (recipient as WhoSender).sender; } if (ipe == null) { throw new Exception("unknown receiver"); } listener.Send(sendBytes, sendBytes.Length, ipe); } else { udpClient.Send(sendBytes, sendBytes.Length); } }
public bool SessionMessage(Who sender, Message msg) { long?msgid = msg.InReplyTo; if (msgid != null) { Mailbox mb; try { mb = GetMailbox(msgid.Value); } catch { mb = null; } if (mb != null) { try { return(mb.Message(sender, msg)); } catch (Exception) { // timeout or mailbox closed - fall through } } // no such mailbox - fall through return(false); } // no such mailbox or no msgid - fall through return(session.SessionMessage(sender, msg)); }
public Mailbox TransportCall(Who recipient, Message msg) { if (msg.MessageId != null) { throw new Exception(" message has already been sent"); } if (msg.InReplyTo != null) { throw new Exception(" message is marked as a reply"); } long mid = idGen.Next(); msg.MessageId = mid; Mailbox mb = new PlainMailbox(this, mid); Register(mb); try { transport.TransportMessage(recipient, msg); } catch (Exception e) { Unregister(mb); throw e; } return(mb); }
public override void Execute(IServerConnection serverConnection) { if (Done) { return; } if (!Who.IsOnline) { SetDone(); return; } switch (What) { case CalloutType.Message: Who.Message(Message); break; case CalloutType.Error: Who.Error(Message); break; default: break; } Done = true; }
/// <summary> /// Returns true if ContactLogInformation instances are equal /// </summary> /// <param name="other">Instance of ContactLogInformation to be compared</param> /// <returns>Boolean</returns> public bool Equals(ContactLogInformation other) { if (other is null) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return (( Type == other.Type || Type.Equals(other.Type) ) && ( When == other.When || When != null && When.Equals(other.When) ) && ( Who == other.Who || Who != null && other.Who != null && Who.SequenceEqual(other.Who) ) && ( Details == other.Details || Details != null && Details.Equals(other.Details) )); }
/// <inheritdoc /> public int CompareTo(OverlapAnnotation other) { if (ReferenceEquals(this, other)) { return(0); } if (other is null) { return(1); } var whereComparison = Where.CompareTo(other.Where); if (whereComparison != 0) { return(whereComparison); } var whatComparison = What.CompareTo(other.What); if (whatComparison != 0) { return(whatComparison); } var whoComparison = Who.CompareTo(other.Who); return(whoComparison != 0 ? whoComparison : Why.CompareTo(other.Why)); }
public bool SessionMessage(Who sender, Message msg) { what = What.MMGRMESSAGEHANDLERMESSAGE; xsender = sender; xmsg = msg; return(true); }
public void TestConstructorWithValidValues() { // ARRANGE const string paramControllerName = "ControllerName"; const string paramActionName = "ActionName"; const string paramPath = "/Home/Index"; const string paramQueryString = "?id=15"; const string paramClientIpAddress = "192.1.162.0"; const string paramUsername = "******"; // ACT IWho who = new Who( controllerName: paramControllerName, actionName: paramActionName, path: paramPath, queryString: paramQueryString, clientIpAddress: paramClientIpAddress, username: paramUsername); // ASSERT Assert.AreNotEqual(Guid.Empty, who.CorrelationId); Assert.AreEqual(paramControllerName, who.ControllerName); Assert.AreEqual(paramActionName, who.ActionName); Assert.AreEqual(paramPath, who.Path); Assert.AreEqual(paramQueryString, who.QueryString); Assert.AreEqual(paramClientIpAddress, who.ClientIpAddress); Assert.AreEqual(paramUsername, who.Username); }
private void sendPwAuthResp(Who recipient, Message msg, bool result, String status) { Message rmsg = msg.Reply(); rmsg.Add(mf_ok, result); rmsg.Add(mf_status, status); transport.TransportMessage(recipient, rmsg); }
/// <summary> /// 返回交易信息的哈希值。 /// </summary> /// <returns></returns> public override int GetHashCode() { var hash = 31 + Who.GetHashCode(); hash = 31 * hash + When.GetHashCode(); hash = 31 * hash + Amount.GetHashCode(); return(hash); }
static void Main() { Who.AmI(); var p = new Program(); var q = -p; var ignored = p.Foo; p.Bar += () => { }; }
public CustomerTicket CreateIndividualTicket(CustomerTicket ticket, Who who) { var entity = CastToCrmEntity(ticket, CustomerTicketSectorType.Individual, who); Guid ticketId = GlobalCode.Service.Create(entity); ticket.Id = ticketId.ToString(); return(ticket); }
// If mothership was killed - the player has ultimately lost. public void mothershipKilled(Who who) { if (who == Who.Enemy) { this.gameState = GameState.PlayerWon; } else if (who == Who.Player) { this.gameState = GameState.EnemyWon; } }
// Builds a unit in desired position and of desired type of unit. public bool buildUnit(Who who, UnitType typeOfUnit) { if ((who == Who.Player) || (who == Who.Enemy)) { if ((!isBuilded[(int) who]) && (players[(int) who].getCredits() >= unitCosts[(int) typeOfUnit])) { players[(int) who].setCredits(players[(int) who].getCredits() - unitCosts[(int) typeOfUnit]); // Set building to wanted unit and start counting down. timeToSpawn[(int) who] = 0.0f; isBuilded[(int) who] = true; builded[(int) who] = typeOfUnit; return true; } else { return false; } } return false; }
// This functions returns player's points public float getPlayerPoints(Who who) { return this.players[(int) who].getPoints(); }
// This functions returns player's credits public float getPlayerCredits(Who who) { return this.players[(int) who].getCredits(); }
// You can ask if a player is building a unit public bool isPlayerBuilding(Who who) { return isBuilded[(int) who]; }
public PieceId(bool black, Who who, int index) { Black = black; Who = who; Index = index; }
// You can get the unit he is building. public UnitType whatPlayerBuilds(Who who) { return builded[(int) who]; }
// You can get his time left to build. public float playerTimeLeftToBuild(Who who) { float res = buildTime[(int) builded[(int) who]] - timeToSpawn[(int) who]; if (res < 0.0f) { res = 0.0f; } return res; }
// You can get his time left to build. public float playerTimeLeftToBuild(Who who) { return buildTime[(int) builded[(int) who]] - timeToSpawn[(int) who]; }