public NdfMap(MapValueHolder key, MapValueHolder value, NdfBinary mgr) : base(NdfType.Map, value) { Key = key; Manager = mgr; _typeSelection.AddRange(NdfTypeManager.GetTypeSelection()); }
public NdfMap(MapValueHolder key, MapValueHolder value, NdfBinary mgr) : base(NdfType.Map, value) { Key = key; Manager = mgr; _typeSelection.AddRange(NdfTypeManager.GetTypeSelection()); }
public NdfValueWrapper GetValueFromQuery(string query) { string rest = string.Empty; string next = NdfQueryReader.ParseNextStep(query, out rest); long index = -1; if (long.TryParse(next, out index)) // can be a list of map so we need to find a way to use "next" as a key and (even worst, sometimes a long is a key map) { NdfValueWrapper val = this.InnerList[(int)index].Value; switch (val.Type) { case NdfType.ObjectReference: NdfObjectReference reference = val as NdfObjectReference; return(reference.Instance.GetValueFromQuery(rest)); case NdfType.MapList: NdfMapList mapList = val as NdfMapList; return(mapList.GetValueFromQuery(rest)); case NdfType.List: NdfCollection list = val as NdfCollection; return(list.GetValueFromQuery(rest)); case NdfType.Map: NdfMap map = val as NdfMap; return((map.Value as MapValueHolder).Value); default: return(val); } } else { // do a list from the maps of the inner list List <CollectionItemValueHolder> maps = _innerList.FindAll(x => x.Value.Type == NdfType.Map); try { NdfValueWrapper selectedmap = maps.Find(x => (x.Value as NdfMap).Key.Value.ToString() == next).Value; // wat NdfMap mapVal = selectedmap as NdfMap; MapValueHolder valholder = mapVal.Value as MapValueHolder; return(valholder.Value); } catch { } } throw (new Exception("Something went wrong with this path: " + query != string.Empty ? query : "empty path")); }
private NdfObject GetUnit(NdfMap map) { MapValueHolder valueHolder = (MapValueHolder)map.Value; NdfObjectReference unitReference = (NdfObjectReference)valueHolder.Value; ObservableCollection <NdfObject> instances; if (unitReference.Class.Name == "TUniteAuSolDescriptor") { instances = tUniteAuSolDescriptor.Instances; } else { instances = tUniteDescriptor.Instances; } return(instances.Where(i => i.Id == unitReference.InstanceId).First()); }
private void GetValueForType(bool keyOrValue) { if (keyOrValue) { Key = new MapValueHolder( NdfTypeManager.GetValue(new byte[NdfTypeManager.SizeofType(KeyType)], KeyType, Manager), Manager); } else { Value = new MapValueHolder( NdfTypeManager.GetValue(new byte[NdfTypeManager.SizeofType(ValueType)], ValueType, Manager), Manager); } OnPropertyChanged("IsKeyNull"); OnPropertyChanged("IsValueNull"); }
public NdfMap(MapValueHolder key, MapValueHolder value, long offset) : base(NdfType.Map, value, offset) { Key = key; }
public MapChangeEntry(NdfPropertyValue affectedPropertyValue, MapValueHolder newKey, MapValueHolder newValue) : base(affectedPropertyValue) { NewKey = newKey; NewValue = newValue; }
public MapChangeEntry(NdfPropertyValue affectedPropertyValue, MapValueHolder newKey, MapValueHolder newValue) : base(affectedPropertyValue) { NewKey = newKey; NewValue = newValue; }
private void GetValueForType(bool keyOrValue) { if (keyOrValue) Key = new MapValueHolder( NdfTypeManager.GetValue(new byte[NdfTypeManager.SizeofType(KeyType)], KeyType, Manager), Manager); else Value = new MapValueHolder( NdfTypeManager.GetValue(new byte[NdfTypeManager.SizeofType(ValueType)], ValueType, Manager), Manager); OnPropertyChanged("IsKeyNull"); OnPropertyChanged("IsValueNull"); }
public bool TryGetValueFromQuery(string query, out NdfValueWrapper value) { string rest = string.Empty; string next = NdfQueryReader.ParseNextStep(query, out rest); // verify next is in the from "[ i ]" bool isIndex = false; string[] parts = next.Split(new string[] { "[", "]" }, StringSplitOptions.None); if (parts.Length == 3) { isIndex = true; } long index = -1; if (isIndex && long.TryParse(parts[1], out index)) { NdfValueWrapper val = null; try { val = this.InnerList[(int)index].Value; } catch { value = null; return(false); } switch (val.Type) { case NdfType.ObjectReference: NdfObjectReference reference = val as NdfObjectReference; return(reference.Instance.TryGetValueFromQuery(rest, out value)); case NdfType.MapList: NdfMapList mapList = val as NdfMapList; return(mapList.TryGetValueFromQuery(rest, out value)); case NdfType.List: NdfCollection list = val as NdfCollection; return(list.TryGetValueFromQuery(rest, out value)); case NdfType.Map: NdfMap map = val as NdfMap; return(map.TryGetValueFromQuery(rest, out value)); case Types.NdfType.Unknown: break; case Types.NdfType.Unset: break; default: value = val; return(true); } } else { // do a list from the maps of the inner list List <CollectionItemValueHolder> maps = _innerList.FindAll(x => x.Value.Type == NdfType.Map); try { NdfValueWrapper selectedmap = maps.Find(x => (x.Value as NdfMap).Key.Value.ToString() == next).Value; // wat NdfMap mapVal = selectedmap as NdfMap; MapValueHolder valholder = mapVal.Value as MapValueHolder; NdfValueWrapper val = valholder.Value; switch (val.Type) { case NdfType.ObjectReference: NdfObjectReference reference = val as NdfObjectReference; return(reference.Instance.TryGetValueFromQuery(rest, out value)); case NdfType.MapList: NdfMapList mapList = val as NdfMapList; return(mapList.TryGetValueFromQuery(rest, out value)); case NdfType.List: NdfCollection list = val as NdfCollection; return(list.TryGetValueFromQuery(rest, out value)); case NdfType.Map: NdfMap map = val as NdfMap; return(map.TryGetValueFromQuery(rest, out value)); case Types.NdfType.Unknown: break; case Types.NdfType.Unset: break; default: value = val; return(true); } } catch { value = null; return(false); } } value = null; return(false); //throw (new Exception("Something went wrong with this path: " + propertyPath != string.Empty ? propertyPath : "empty path")); }