Exemplo n.º 1
0
        public void RegMHandle()
        {
            //var x = new Lazy<int>(() => 2);
            //var tt = x.GetType();
            //dynamic nn= Activator.CreateInstance(tt);

            //var vv = nn.Value;
            //Assert.AreEqual(vv, 2);

            using (var mmap = new MemMap())
            {
                RegDataMHandle._MemMap = mmap;
                var reg = new RegDataMHandle()
                {
                    _name = regroot
                };
                reg.Fillit();
                var mh  = mmap.AddData(reg);
                var ret = (RegDataMHandle)mmap.GetData(mh, reg.GetType());
                foreach (var m in ret._childNodes)
                {
                    var ch = mmap.GetData(m, reg.GetType());
                }
                Assert.IsTrue(reg.CompareTo(ret) == 0, "not eq cnt = {0}", RegDataMHandle._cnt);
            }
        }
Exemplo n.º 2
0
        public void DelegateTest()
        {
            var dummy = 0;
            var x     = new Action(() =>
            {
                dummy = 1;
            });



            using (var mfd = new MemMap())
            {
                var loc = mfd.AddData(x);
                var ret = (Action)mfd.GetData(loc, x.GetType());
                ret.Invoke();
                Assert.AreEqual(dummy, 1);


                //                Assert.IsTrue(ret.CompareTo(root) == 0, "not equal!");
            }
        }
Exemplo n.º 3
0
 public void Fillit(int nLevel = 0)
 {
     if (nLevel < 22)
     {
         using (var reg = Microsoft.Win32.Registry.CurrentUser.OpenSubKey(_name))
         {
             var subkeys = reg.GetSubKeyNames();
             if (subkeys.Length > 0)
             {
                 _childNodes = new List <MHandle>();
                 foreach (var key in reg.GetSubKeyNames())
                 {
                     var newName = _name + @"\" + key;
                     var newnode = new RegData()
                     {
                         _name = newName
                     };
                     _childNodes.Add(_MemMap.AddData(newnode));
                     newnode.Fillit(nLevel + 1);
                 }
             }
         }
     }
 }
Exemplo n.º 4
0
        public void Insert(int index, TValue item)
        {
            var loc = _MemMap.AddData(item, typeof(TValue));

            _listInternal.Insert(index, loc);
        }