Exemple #1
0
        /// <summary>
        /// The long hashcode is computed by using MD5 in order to prevent problems with poorly
        /// implemented predicate object hashcodes.
        /// </summary>
        /// <returns>The long hashcode of the predicate.</returns>
        public override long GetLongHashCode()
        {
            int hashCode = GetType().GetHashCode() ^ Value.GetHashCode();

            // bug #1086498, solved by mwherman2000
            byte[] dataArray = new byte[] { (byte)(hashCode & 0xFF),
                                            (byte)((hashCode >> 8) & 0xFF),
                                            (byte)((hashCode >> 16) & 0xFF),
                                            (byte)((hashCode >> 24) & 0xFF) };

            byte[] result = HA.ComputeHash(dataArray);

            long longHashCode = 0;

            for (int i = 0; i < 16; i += 8)
            {
                longHashCode ^= ((long)result[i] |
                                 ((long)result[i + 1] << 8) |
                                 ((long)result[i + 2] << 16) |
                                 ((long)result[i + 3] << 24) |
                                 ((long)result[i + 4] << 32) |
                                 ((long)result[i + 5] << 40) |
                                 ((long)result[i + 6] << 48) |
                                 ((long)result[i + 7] << 56));
            }

            return(longHashCode);
        }
Exemple #2
0
 protected void ResetInputs()
 {
     vehicule.Clear();
     dateDepart.Clear();
     HD.Clear();
     dateArivee.Clear();
     HA.Clear();
     trajet.Clear();
 }
Exemple #3
0
        public void TestHashtableArrayRepresentationWithDot()
        {
            var d = new HA {
                Id = 1, Data = new Hashtable {
                    { "a.b", 1 }
                }
            };
            var expected = "{ '_id' : 1, 'Data' : [['a.b', 1]] }".Replace("'", "\"");
            var json     = d.ToJson();

            Assert.AreEqual(expected, json);

            _collection.RemoveAll();
            _collection.Insert(d);
            var r = _collection.FindOne(Query.EQ("_id", d.Id));

            Assert.AreEqual(d.Id, r.Id);
            Assert.AreEqual(1, r.Data.Count);
            Assert.AreEqual(1, r.Data["a.b"]);
        }
        /// <summary>
        /// Sets the system mode.
        /// </summary>
        /// <param name="thermostatShortId"></param>
        /// <param name="state"></param>
        private void setAndValidateSystemMode(int thermostatShortId, HA.DeviceController.Common.ThermoSystemMode state)
        {
            // Get the device associated with the thermostat
            var thermostatDevice = getNodeByShortId(thermostatShortId) as Thermostat;
            if (thermostatDevice != null) {
                dm.setZWaveThermostatSystemState((byte)thermostatDevice.providerDeviceId, state);

                // Re-poll the device to get the new values
                dm.pollDevice(thermostatDevice.deviceId);

                // This is a delay to wait for the thermostat to respond back to the poll attempt
                System.Threading.Thread.Sleep(4000);

                // Grab a fresh copy of the device
                thermostatDevice = getNodeByShortId(thermostatShortId) as Thermostat;

                if (thermostatDevice.thermostatSystemState != state) {
                    setStatus("...failed!");
                } else {
                    setStatus("...success!");
                }
            }
        }
Exemple #5
0
        /*============================= DrwTxt ==============================*/
        public void DrwTxt(DrawingContext dc, string text = "", double x = 0,
                           double y = 0, double size = 16, HA ha = HA.Left,
                           VA va    = VA.Top)
        {
            FormattedText ft = new FormattedText(text, CultureInfo.CurrentCulture,
                                                 FlowDirection.LeftToRight, Default.Typeface,
                                                 size, Brushes.Black);
            double xOffset = 0;

            switch (ha)
            {
            case HA.Center:
                xOffset = -ft.Width / 2;
                break;

            case HA.Right:
                xOffset = -ft.Width;
                break;
            }

            double yOffset = 0;

            switch (va)
            {
            case VA.Center:
                yOffset = -ft.Height / 2;
                break;

            case VA.Bottom:
                yOffset = -ft.Height;
                break;
            }

            dc.DrawText(ft, new Point(Math.Round(x + xOffset),
                                      Math.Round(y + yOffset)));
        }
        public void TestHashtableArrayRepresentationWithDot()
        {
            var d = new HA { Id = 1, Data = new Hashtable { { "a.b", 1 } } };
            var expected = "{ '_id' : 1, 'Data' : [['a.b', 1]] }".Replace("'", "\"");
            var json = d.ToJson();
            Assert.AreEqual(expected, json);

            _collection.RemoveAll();
            _collection.Insert(d);
            var r = _collection.FindOne(Query.EQ("_id", d.Id));
            Assert.AreEqual(d.Id, r.Id);
            Assert.AreEqual(1, r.Data.Count);
            Assert.AreEqual(1, r.Data["a.b"]);
        }
Exemple #7
0
 public void ReceiveDataRequest(ESBDataRequest dataRequest)
 {
     HA.MarshallDataRequest(dataRequest);
 }
Exemple #8
0
 protected virtual byte[] GetKey(string key)
 {
     return(HA.ComputeHash(key.FromUTF8String()));
 }