示例#1
0
 /**
  * Read the "numericFields" string array from preferences, and activate numeric
  * sorting for all fields listed in the array. If an unknown field name is included,
  * add a field descriptor for the new field.
  */
 public static void setNumericFieldsFromPrefs()
 {
     string[] numFields = Globals.prefs.getStringArray("numericFields");
     if (numFields == null)
     return;
     // Build a Set of field names for the fields that should be sorted numerically:
     var nF = new Dictionary<string, bool>();
     for (int i = 0; i < numFields.Length; i++) {
     nF.Add(numFields[i], true);
     }
     // Look through all registered fields, and activate numeric sorting if necessary:
     foreach (var fieldName in runtime.fieldSet.Keys) {
     BibtexSingleField field = runtime.fieldSet[fieldName];
     if (!field.isNumeric() && nF.ContainsKey(fieldName)) {
         field.setNumeric(nF.ContainsKey(fieldName));
     }
     nF.Remove(fieldName); // remove, so we clear the set of all standard fields.
     }
     // If there are fields left in nF, these must be non-standard fields. Add descriptors for them:
     foreach (var fieldName in nF.Keys) {
     BibtexSingleField field = new BibtexSingleField(fieldName, false);
     field.setNumeric(true);
     runtime.fieldSet.Add(fieldName, field);
     }
 }