public IEnumerable <EditItem> Parse(IEnumerable <string> tokens) { //defaults EditItem.Location location = EditItem.Location.Beginning; Hive hive = Hive.User; char[] charsToTrim = { '\'', '\"' }; foreach (var token in tokens) { string trimmed = token.Trim(charsToTrim); PathParser pathParser = new PathParser(trimmed); ParmParser parmParser = new ParmParser(trimmed); if (pathParser.IsPath) { var item = new EditItem(pathParser.Path, pathParser.Action, hive, location); editItemList.Add(item); } else if (parmParser.IsParm) { if (parmParser.HiveParm.HasValue) { hive = parmParser.HiveParm.Value; } if (parmParser.LocationParm.HasValue) { location = parmParser.LocationParm.Value; } } else { throw new Exception($"Bad parameter: {token}"); } } return(editItemList); }
private bool Equals(EditItem other) { return(string.Equals(pathString, other.pathString) && action == other.action && hive == other.hive && location == other.location); }