Exemplo n.º 1
0
        public ExclusionGrid(IEnumerable <SkillVM> skills)
        {
            DoubleKeyComparer comparer = new DoubleKeyComparer(skills.Min(s => s.ID), skills.Max(s => s.ID));

            _grid = new Dictionary <DoubleKey, DoubleCheck>(comparer);

            foreach (SkillVM s1 in skills)
            {
                foreach (SkillVM s2 in skills)
                {
                    if (s1.ID != s2.ID)
                    {
                        DoubleKey key = new DoubleKey(s1.ID, s2.ID);
                        if (!_grid.ContainsKey(key))
                        {
                            bool        defaultChecked = GetDefaultChecked(s1, s2);
                            DoubleCheck value          = new DoubleCheck()
                            {
                                Skill1    = s1,
                                Skill2    = s2,
                                IsChecked = defaultChecked
                            };
                            _grid.Add(key, value);
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
        public static Func <IDataReader, object> GetFactory(this IDataReader reader, Type entityType)
        {
            if (reader == null)
            {
                throw new ArgumentNullException("reader");
            }
            if (entityType == null)
            {
                throw new ArgumentNullException("entityType");
            }
            Func <IDataReader, object> factory1 = null;
            DoubleKey <Type, string>   key      = new DoubleKey <Type, string>(entityType, reader.GetMetadataSummary());

            if (factoryCache.TryGetValue(key, out factory1))
            {
                return(factory1);
            }

            return(keyLocker.ExecuteSynchronized(key, k =>
            {
                Func <IDataReader, object> factory2;
                if (!factoryCache.TryGetValue(k, out factory2))
                {
                    var builder = new FromDataReaderFactoryBuilder(entityType, reader);
                    factory2 = builder.CreateFactory();
                    factoryCache[key] = factory2;
                }
                return factory2;
            }));
        }
Exemplo n.º 3
0
        public V Get(K key1, K key2)
        {
            DoubleKey key = new DoubleKey(key1, key2);

            if (map.ContainsKey(key))
            {
                return(map[key]);
            }
            throw new KeyNotFoundException();
        }
        public void PrimaryKeyExpression_2()
        {
            var record = new DoubleKey {
                StudentKey = 1, AdmissionNum = "123"
            };

            var exp = EntityFrameworkHelper.PrimaryKeyExpression <DoubleKey>();

            Assert.IsTrue(exp(record, new object[] { 1, "123" }));
            Assert.IsFalse(exp(record, new object[] { 2, string.Empty }));
        }
Exemplo n.º 5
0
        private static void UploadDataAsStreams(int UploadCount)
        {
            string directory = @"..\\..\\data\\meter-data";
            int    count     = 0;

            Dictionary <DateTime, double> ts_temperature = new Dictionary <DateTime, double>();
            StreamReader wfile = new System.IO.StreamReader(@"..\\..\\data\\weather.txt");
            string       wline;

            while ((wline = wfile.ReadLine()) != null)
            {
                string[] words = wline.Split('\t');
                DateTime date  = Convert.ToDateTime(words[4]);
                date = date.AddHours(Int32.Parse(words[5]));
                double temperature = Double.Parse(words[0]);
                ts_temperature[date] = temperature;
            }
            wfile.Close();


            foreach (string filePath in Directory.GetFiles(directory))
            {
                Console.WriteLine("file name:" + filePath);
                string line;
                System.IO.StreamReader file = new System.IO.StreamReader(filePath);

                LocationInfo li = new LocationInfo(AzureaccountName, AzureaccountKey, SynchronizerType.Azure);

                FqStreamID fq_sid = new FqStreamID("crrealhome" + count, "A", "TestBS");
                CallerInfo ci     = new CallerInfo(null, "A", "A", 1);

                StreamFactory sf = StreamFactory.Instance;
                sf.deleteStream(fq_sid, ci);
                IStream dfs_byte_val = sf.openValueDataStream <DoubleKey, ByteValue>(fq_sid, ci, li, StreamFactory.StreamSecurityType.Plain, CompressionType.None, StreamFactory.StreamOp.Write, mdserveraddress: mdServer, ChunkSizeForUpload: 4 * 1024 * 1024, ThreadPoolSize: 1, log: new Logger());


                while ((line = file.ReadLine()) != null)
                {
                    string[] words = line.Split('\t');
                    DateTime date  = Convert.ToDateTime(words[0]);
                    date = date.AddHours(int.Parse(words[1]) / 100);
                    DoubleKey key = new DoubleKey(((int)(ts_temperature[date])));
                    dfs_byte_val.Append(key, new ByteValue(BitConverter.GetBytes(Double.Parse(words[2]))), DateTimeToUnixTimestamp(date));
                    // Console.WriteLine(DateTimeToUnixTimestamp(date) + "," + words[2]);
                }

                dfs_byte_val.Close();
                count++;
                if (count == UploadCount)
                {
                    break;
                }
            }
        }
        public void FindExpression_2()
        {
            var record = new DoubleKey {
                StudentKey = 1, AdmissionNum = "123"
            };

            var exp1 = EntityFrameworkHelper.FindExpression <DoubleKey>(new object[] { 1, "123" }).Compile();
            var exp2 = EntityFrameworkHelper.FindExpression <DoubleKey>(new object[] { 2, string.Empty }).Compile();

            Assert.IsTrue(exp1(record));
            Assert.IsFalse(exp2(record));
        }
Exemplo n.º 7
0
    void LoadKeys()
    {
        keyMoveForward  = DoubleKey.FromPlayerPrefs("key_move_forward");
        keyMoveBackward = DoubleKey.FromPlayerPrefs("key_move_backward");
        keyMoveLeft     = DoubleKey.FromPlayerPrefs("key_move_left");
        keyMoveRight    = DoubleKey.FromPlayerPrefs("key_move_right");

        keyJump         = DoubleKey.FromPlayerPrefs("key_jump");
        keyCrouchToggle = DoubleKey.FromPlayerPrefs("key_crouch_toggle");
        keySprintToggle = DoubleKey.FromPlayerPrefs("key_sprint_toggle");
        keyCrouchHold   = DoubleKey.FromPlayerPrefs("key_crouch_hold");
        keySprintHold   = DoubleKey.FromPlayerPrefs("key_sprint_hold");
    }
Exemplo n.º 8
0
 public override bool Equals(object obj)
 {
     if (obj is DoubleKey)
     {
         DoubleKey other = obj as DoubleKey;
         if (Item1.Equals(other.Item1) && Item2.Equals(other.Item2) ||
             Item1.Equals(other.Item2) && Item2.Equals(other.Item1))
         {
             return(true);
         }
     }
     return(false);
 }
 public void ReadHourIntoStream()
 {
     long start = DateTime.Now.Ticks;
     Tuple<DateTime, double, double> tuple = timestamp_energy_temperature.ElementAt(count);
     DoubleKey key = new DoubleKey(Math.Round(tuple.Item3));
     dataStream.Append(key, new ByteValue(BitConverter.GetBytes(tuple.Item2)),(long)count);
     count++;
     long end = DateTime.Now.Ticks;
     Console.Write(count + "," + (end - start));
     
     using (results = File.AppendText(".\\result-width-" + width + ".txt"))
         results.Write(count + "," + (end - start));
 }
Exemplo n.º 10
0
        private static void UploadDataAsStreams(int UploadCount)
        {
            string directory = @"..\\..\\data\\meter-data";
            int count = 0;

            Dictionary<DateTime, double> ts_temperature = new Dictionary<DateTime, double>();
            StreamReader wfile = new System.IO.StreamReader(@"..\\..\\data\\weather.txt");
            string wline;
            while ((wline = wfile.ReadLine()) != null)
            {
                string[] words = wline.Split('\t');
                DateTime date = Convert.ToDateTime(words[4]);
                date = date.AddHours(Int32.Parse(words[5]));
                double temperature = Double.Parse(words[0]);
                ts_temperature[date] = temperature;
            }
            wfile.Close();


            foreach (string filePath in Directory.GetFiles(directory))
            {
                Console.WriteLine("file name:" + filePath);
                string line;
                System.IO.StreamReader file =   new System.IO.StreamReader(filePath);

                LocationInfo li = new LocationInfo(AzureaccountName, AzureaccountKey, SynchronizerType.Azure);

                FqStreamID fq_sid = new FqStreamID("crrealhome"+count, "A", "TestBS");
                CallerInfo ci = new CallerInfo(null, "A", "A", 1);

                StreamFactory sf = StreamFactory.Instance;
                sf.deleteStream(fq_sid, ci);
                IStream dfs_byte_val = sf.openValueDataStream<DoubleKey, ByteValue>(fq_sid, ci, li, StreamFactory.StreamSecurityType.Plain, CompressionType.None, StreamFactory.StreamOp.Write, mdserveraddress: mdServer, ChunkSizeForUpload: 4 * 1024 * 1024, ThreadPoolSize: 1, log: new Logger());

                
                while ((line = file.ReadLine()) != null)
                {
                    string[] words = line.Split('\t');
                    DateTime date = Convert.ToDateTime(words[0]);
                    date=date.AddHours(int.Parse(words[1])/100);
                    DoubleKey key = new DoubleKey(((int)(ts_temperature[date])));
                    dfs_byte_val.Append(key, new ByteValue(BitConverter.GetBytes(Double.Parse(words[2]))), DateTimeToUnixTimestamp(date));
                   // Console.WriteLine(DateTimeToUnixTimestamp(date) + "," + words[2]);
                }

                dfs_byte_val.Close();
                count++;
                if (count == UploadCount) 
                    break;
            }
        }
Exemplo n.º 11
0
    //utility

    void ManageToggleAndHoldInput(ref bool value, DoubleKey keyHold, DoubleKey keyToggle)
    {
        if (keyHold.GetKey())
        {
            value = true;
        }
        if (keyHold.GetKeyUp())
        {
            value = false;
        }
        if (keyToggle.GetKeyDown())
        {
            value = !value;
        }
    }
Exemplo n.º 12
0
        public void ReadHourIntoStream()
        {
            long start = DateTime.Now.Ticks;
            Tuple <DateTime, double, double> tuple = timestamp_energy_temperature.ElementAt(count);
            DoubleKey key = new DoubleKey(Math.Round(tuple.Item3));

            dataStream.Append(key, new ByteValue(BitConverter.GetBytes(tuple.Item2)), (long)count);
            count++;
            long end = DateTime.Now.Ticks;

            Console.Write(count + "," + (end - start));

            using (results = File.AppendText(".\\result-width-" + width + ".txt"))
                results.Write(count + "," + (end - start));
        }
Exemplo n.º 13
0
    void LoadKeys()
    {
        keyMoveForward  = DoubleKey.FromPlayerPrefs("key_move_forward");
        keyMoveBackward = DoubleKey.FromPlayerPrefs("key_move_backward");
        keyMoveLeft     = DoubleKey.FromPlayerPrefs("key_move_left");
        keyMoveRight    = DoubleKey.FromPlayerPrefs("key_move_right");

        keyJump         = DoubleKey.FromPlayerPrefs("key_jump");
        keyCrouchToggle = DoubleKey.FromPlayerPrefs("key_crouch_toggle");
        keySprintToggle = DoubleKey.FromPlayerPrefs("key_sprint_toggle");
        keyCrouchHold   = DoubleKey.FromPlayerPrefs("key_crouch_hold");
        keySprintHold   = DoubleKey.FromPlayerPrefs("key_sprint_hold");

        keyInteract    = DoubleKey.FromPlayerPrefs("key_interact");
        keyPrimaryFire = DoubleKey.FromPlayerPrefs("key_primary_fire");
        keyToggleGUI   = DoubleKey.FromPlayerPrefs("key_toggleGUI");
    }
Exemplo n.º 14
0
        private static void UploadDataAsStreams()
        {
            string directory = "D:\\data-hds\\data-hds";
            int count = 0;
            int UploadCount = 300;

            Dictionary<DateTime, double> ts_temperature = new Dictionary<DateTime, double>();
            StreamReader wfile = new System.IO.StreamReader(@"..\\..\\data\\weather.txt");
            string wline;
            while ((wline = wfile.ReadLine()) != null)
            {
                string[] words = wline.Split('\t');
                DateTime date = Convert.ToDateTime(words[4]);
                date = date.AddHours(Int32.Parse(words[5]));
                double temperature = Double.Parse(words[0]);
                ts_temperature[date] = temperature;
            }
            wfile.Close();

            foreach (string filePath in Directory.GetFiles(directory))
            {
                Console.WriteLine("file name:" + filePath);
                string line;
                System.IO.StreamReader file =   new System.IO.StreamReader(filePath);

                string AzureaccountName = "testdrive";
                string AzureaccountKey = "zRTT++dVryOWXJyAM7NM0TuQcu0Y23BgCQfkt7xh2f/Mm+r6c8/XtPTY0xxaF6tPSACJiuACsjotDeNIVyXM8Q==";
                LocationInfo li = new LocationInfo(AzureaccountName, AzureaccountKey, SynchronizerType.Azure);

                FqStreamID fq_sid = new FqStreamID("realhome"+count, "A", "TestBS");
                CallerInfo ci = new CallerInfo(null, "A", "A", 1);

                StreamFactory sf = StreamFactory.Instance;
                sf.deleteStream(fq_sid, ci);
                IStream dfs_byte_val = sf.openFileStream<DoubleKey, ByteValue>(fq_sid, ci, li,  StreamFactory.StreamSecurityType.Plain, CompressionType.None,StreamFactory.StreamOp.Write, mdServer, 4*1024*1024, 1, new Logger());

                while ((line = file.ReadLine()) != null)
                {
                    string[] words = line.Split('\t');
                    DateTime date = Convert.ToDateTime(words[0]);
                    date=date.AddHours(int.Parse(words[1])/100);
                    DoubleKey key = new DoubleKey(((int)(ts_temperature[date])));
                    dfs_byte_val.Append(key, new ByteValue(BitConverter.GetBytes(Double.Parse(words[2]))), DateTimeToUnixTimestamp(date));
                   // Console.WriteLine(DateTimeToUnixTimestamp(date) + "," + words[2]);
                }

                dfs_byte_val.Close();
                count++;
                if (count == UploadCount)
                    break;
            }
        }
Exemplo n.º 15
0
        public void Set(K key1, K key2, V val)
        {
            DoubleKey key = new DoubleKey(key1, key2);

            map[key] = val;
        }
Exemplo n.º 16
0
        public bool ContainsKey(K key1, K key2)
        {
            DoubleKey key = new DoubleKey(key1, key2);

            return(map.ContainsKey(key));
        }
Exemplo n.º 17
0
 private void LoadKeys()
 {
     keyInteract    = DoubleKey.FromPlayerPrefs("key_interact");
     keyPrimaryFire = DoubleKey.FromPlayerPrefs("key_primary_fire");
     keyToggleGUI   = DoubleKey.FromPlayerPrefs("key_toggleGUI");
 }
Exemplo n.º 18
0
 private void LoadKeys()
 {
     keyPrimaryFire      = DoubleKey.FromPlayerPrefs("key_primary_fire");
     keySecondaryFire    = DoubleKey.FromPlayerPrefs("key_secondary_fire");
     keyToggleFlashlight = DoubleKey.FromPlayerPrefs("key_toggle_flashlight");
 }
Exemplo n.º 19
0
 public PacketMouseMove(DoubleKey <float, float> percent)
 {
     PercentX = percent.X;
     PercentY = percent.Y;
 }