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);
        }
예제 #2
0
        /// <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);
        }
예제 #3
0
파일: State.cs 프로젝트: PlumpMath/cilpe-1
 protected override void VisitRetrieveType(RetrieveType node, object data)
 {
     throw new NodeNotSupportedException(node);
 }
예제 #4
0
 protected internal virtual void VisitRetrieveType(RetrieveType node, object data)
 {
     throw new NodeNotSupportedException(node);
 }
예제 #5
0
 protected internal override void VisitRetrieveType(RetrieveType node, object data)
 {
     throw new VerifierException();
     //not supported yet...
 }