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); } }
public TValue this[int index] { get { var mHandle = _listInternal[index]; TValue val = (TValue)_MemMap.GetData(mHandle, typeof(TValue)); return(val); } set { MHandle loc = _listInternal[index]; _MemMap.RemoveData(loc, typeof(TValue)); loc = _MemMap.AddData(value, typeof(TValue)); _listInternal[index] = loc; } }
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!"); } }