public override void doAction(SVRow r) { string goal_str = r.row[field.address()]; double goal_dbl = Convert.ToDouble(goal_str); total += goal_dbl; }
}//Constructor // Process one row of the SnapView public override void doAction(SVRow r) { // Input the target element of the row string // If it exists in the Set, don't add it. Otherwise add it. // Get the Field address: int addr = field.address(); // Add value at address to the index set.Add(r.row[addr]); }
public void fillSnapViewTable(SnapView sv) { // LINQ query to return a list of rows var rowList = from row in xdoc.Descendants(config.xmlRootName).Descendants(config.xmlRowName) select new { fieldList = row.Descendants() }; // Loop over the rows foreach (var row in rowList) { // Have to iterate over row twice: once to find its size, so // the array can be created; second to fill the array. // This is because IEnumerable<T> doesn't provide a way of knowing // the number of elements in the collection without iterating over them all. int arr_size = 0; foreach (var field in row.fieldList) { arr_size++; }//foreach // Create the string array string[] row_array = new string[arr_size]; int arr_idx = 0; Console.WriteLine("Another row"); // Loop over the fields in the row foreach (var field in row.fieldList) { Console.WriteLine(" Another field: "); Console.WriteLine(field.Value.ToString()); // Add string to array row_array[arr_idx] = field.Value.ToString(); arr_idx++; }//foreach loop over fields in a row // Add row to the SnapView datastructure SVRow svr = new SVRow(); svr.row = row_array; sv.addRow(svr); }//foreach loop over rows }
public override void doAction(SVRow r) { // This class is incomplete (and unused at the moment) - doesn't have calculation code yet (hence the unused private data members) }
// Every Filter must be able to be "done" by the containing // snapview. Derived classes have the actual implementation. // Parameter is a "row" of the snapView. //abstract public bool try_filter(SVRow r); public override void doAction(SVRow r) { // Throw an exception as this doesn't do anything }
// Interface to the doAction method public void doAction(SVRow r) { action.doAction(r); }
public override void doAction(SVRow r) { decision = kBehaviour.keepIf(r.row[field.address()], new SingleCutVal(minimum)); }
public override void doAction(SVRow r) { decision = kBehaviour.keepIf(r.row[field.address()], new SingleCutVal(HA_arr[(int)value])); }
// name is Read-only (setter is private) //public string name { get; private set; } // Every action must be able to be "done" by the containing // snapview. Derived classes have the actual implementation. // Parameter is a "row" of the snapView. //public abstract void doAction(string[] r); public abstract void doAction(SVRow r);
}//Constructor // Uses polymorphism and strategy pattern to call the right // filter behaviour //public override bool try_filter(SVRow r) //{ // return kBehaviour.keepIf(r.row[field.address()], val); //} public override void doAction(SVRow r) { // This we know this is a single cut val filter because all Equals filters are decision = kBehaviour.keepIf(r.row[field.address()], new SingleCutVal(val)); }