private T GetValue <T>(string name, RetrieveType retrieveValue) { string field = _aliaser.LookUpAlias(name); PropertyItem propStore = _propertyStore.FirstOrDefault(prop => prop.PropertyName == field); if (propStore == null) { return(default(T)); } Type type = typeof(T); object value = retrieveValue == RetrieveType.Current ? propStore.Current : propStore.Original; return(value == null || (value.GetType() != (Nullable.GetUnderlyingType(type) ?? type)) ? default(T) : (T)value); }
/// <summary> /// Gets the EOS Devices sorted by retType. /// </summary> /// <returns>The EOS Devices.</returns> /// <param name="comp">The Computer.</param> /// <param name="retType">Determines how to sort the devices.</param> public static Dictionary <string, Hacknet.Computer> GetEOSDevicesBy(this Hacknet.Computer comp, RetrieveType retType) { var res = new Dictionary <string, Hacknet.Computer>(); if (comp.attatchedDeviceIDs != null) { foreach (var id in comp.attatchedDeviceIDs.Split(new char[] { ' ', ',' }, StringSplitOptions.RemoveEmptyEntries)) { var c = comp.GetNetworkMap().GetComputerById(id); if (c != null) { switch (retType) { case RetrieveType.ID: res[id] = c; break; case RetrieveType.ADDRESS: res[c.ip] = c; break; case RetrieveType.NAME: res[c.name] = c; break; case RetrieveType.INDEX: res[c.GetNetworkMap().nodes.IndexOf(c).ToString()] = c; break; } } } } return(res); }
protected override void VisitRetrieveType(RetrieveType node, object data) { throw new NodeNotSupportedException(node); }
protected internal virtual void VisitRetrieveType(RetrieveType node, object data) { throw new NodeNotSupportedException(node); }
protected internal override void VisitRetrieveType(RetrieveType node, object data) { throw new VerifierException(); //not supported yet... }