예제 #1
0
 /// <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);
     }
 }
예제 #2
0
 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:")));
 }
예제 #3
0
        //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);
        }
예제 #4
0
파일: Packetizer.cs 프로젝트: NeoTim/etch
        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);
        }
예제 #5
0
        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");
        }
예제 #6
0
        public void SetEmailListTest()
        {
            Who recipient = new Who();

            entry.Recipient = recipient;
            Assert.AreEqual(recipient, entry.Recipient, "Recipient should be updated after setting");
        }
예제 #7
0
파일: Logger.cs 프로젝트: NeoTim/etch
 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;
     }
 }
예제 #8
0
 public bool SessionMessage(Who sender, Message msg)
 {
     what         = What.TESTMESSAGEHANDLERMESSAGE;
     this.xsender = sender;
     this.xmsg    = msg;
     return(handled);
 }
예제 #9
0
            public void SessionData(Who sender, FlexBuffer buf)
            {
                xsender = sender;
                xbuf    = buf.GetAvailBytes();

                what.WaitUntilEqAndSet(default(What), TIMEOUT, What.DATA);
            }
예제 #10
0
            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);
            }
예제 #11
0
            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;
                 * */
            }
예제 #12
0
        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);
        }
예제 #14
0
파일: Play.cs 프로젝트: JaehoonHyun/tdd
        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);
        }
예제 #15
0
        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);
        }
예제 #16
0
 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);
 }
예제 #17
0
        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);
        }
예제 #18
0
        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);
        }
예제 #19
0
        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);
            }
        }
예제 #20
0
        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));
        }
예제 #21
0
        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);
        }
예제 #22
0
        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;
        }
예제 #23
0
        /// <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)
                 ));
        }
예제 #24
0
        /// <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));
        }
예제 #25
0
 public bool SessionMessage(Who sender, Message msg)
 {
     what    = What.MMGRMESSAGEHANDLERMESSAGE;
     xsender = sender;
     xmsg    = msg;
     return(true);
 }
예제 #26
0
        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);
        }
예제 #27
0
파일: PwAuth.cs 프로젝트: NeoTim/etch
        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);
    }
예제 #29
0
파일: Program.cs 프로젝트: weffer/C-
    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);
        }
예제 #31
0
 // 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;
     }
 }
예제 #32
0
 // 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;
 }
예제 #33
0
 // This functions returns player's points
 public float getPlayerPoints(Who who)
 {
     return this.players[(int) who].getPoints();
 }
예제 #34
0
 // This functions returns player's credits
 public float getPlayerCredits(Who who)
 {
     return this.players[(int) who].getCredits();
 }
예제 #35
0
 // You can ask if a player is building a unit
 public bool isPlayerBuilding(Who who)
 {
     return isBuilded[(int) who];
 }
예제 #36
0
파일: PieceId.cs 프로젝트: Aladewale/games
 public PieceId(bool black, Who who, int index)
 {
     Black = black;
     Who = who;
     Index = index;
 }
예제 #37
0
 // You can get the unit he is building.
 public UnitType whatPlayerBuilds(Who who)
 {
     return builded[(int) who];
 }
예제 #38
0
 // 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;
 }
예제 #39
0
 // You can get his time left to build.
 public float playerTimeLeftToBuild(Who who)
 {
     return buildTime[(int) builded[(int) who]] - timeToSpawn[(int) who];
 }