public Softwall.Rule[] GetRules() { DataRowCollection rows = softwallDataSet.Tables[0].Rows; List<Softwall.Rule> rules = new List<Softwall.Rule>(rows.Count); foreach (DataRow row in rows) { Softwall.Rule rule = new Softwall.Rule(); rule.Conditions = 0; object obj = row["ProcessName"]; if (!(obj is DBNull)) { rule.Conditions |= Softwall.CONDITION_PROCESS_NAME; rule.ProcessName = obj as string; } obj = row["FunctionName"]; if (!(obj is DBNull)) { rule.Conditions |= Softwall.CONDITION_FUNCTION_NAME; rule.FunctionName = obj as string; } obj = row["ReturnAddress"]; if (!(obj is DBNull)) { rule.Conditions |= Softwall.CONDITION_RETURN_ADDRESS; rule.ReturnAddress = (UInt32) obj; } obj = row["LocalAddress"]; if (!(obj is DBNull)) { rule.Conditions |= Softwall.CONDITION_LOCAL_ADDRESS; rule.LocalAddress = IPAddrFromStr(obj as string); } obj = row["LocalPort"]; if (!(obj is DBNull)) { rule.Conditions |= Softwall.CONDITION_LOCAL_PORT; rule.LocalPort = PortToBigEndian((UInt16) obj); } obj = row["RemoteAddress"]; if (!(obj is DBNull)) { rule.Conditions |= Softwall.CONDITION_PEER_ADDRESS; rule.RemoteAddress = IPAddrFromStr(obj as string); } obj = row["RemotePort"]; if (!(obj is DBNull)) { rule.Conditions |= Softwall.CONDITION_PEER_PORT; rule.RemotePort = PortToBigEndian((UInt16) obj); } rule.Retval = (Int32) row["ReturnValue"]; rule.LastError = (UInt32) row["LastError"]; rules.Add(rule); } return rules.ToArray(); }
public Softwall.Rule[] GetRules() { DataRowCollection rows = softwallDataSet.Tables[0].Rows; List <Softwall.Rule> rules = new List <Softwall.Rule>(rows.Count); foreach (DataRow row in rows) { Softwall.Rule rule = new Softwall.Rule(); rule.Conditions = 0; object obj = row["ProcessName"]; if (!(obj is DBNull)) { rule.Conditions |= Softwall.CONDITION_PROCESS_NAME; rule.ProcessName = obj as string; } obj = row["FunctionName"]; if (!(obj is DBNull)) { rule.Conditions |= Softwall.CONDITION_FUNCTION_NAME; rule.FunctionName = obj as string; } obj = row["ReturnAddress"]; if (!(obj is DBNull)) { rule.Conditions |= Softwall.CONDITION_RETURN_ADDRESS; rule.ReturnAddress = (UInt32)obj; } obj = row["LocalAddress"]; if (!(obj is DBNull)) { rule.Conditions |= Softwall.CONDITION_LOCAL_ADDRESS; rule.LocalAddress = IPAddrFromStr(obj as string); } obj = row["LocalPort"]; if (!(obj is DBNull)) { rule.Conditions |= Softwall.CONDITION_LOCAL_PORT; rule.LocalPort = PortToBigEndian((UInt16)obj); } obj = row["RemoteAddress"]; if (!(obj is DBNull)) { rule.Conditions |= Softwall.CONDITION_PEER_ADDRESS; rule.RemoteAddress = IPAddrFromStr(obj as string); } obj = row["RemotePort"]; if (!(obj is DBNull)) { rule.Conditions |= Softwall.CONDITION_PEER_PORT; rule.RemotePort = PortToBigEndian((UInt16)obj); } rule.Retval = (Int32)row["ReturnValue"]; rule.LastError = (UInt32)row["LastError"]; rules.Add(rule); } return(rules.ToArray()); }