protected override Expression VisitParameter(ParameterExpression node) { if (node is null) { throw new ArgumentNullException(nameof(node)); } if (_replaceVars.Any() && _replaceVars.Single().ContainsKey(node)) { return(_replaceVars.Single()[node]); } return(base.VisitParameter(node)); }
public Optional <IServerPath> TryGetFile(IServerPath parentFolderServerPath, string fileName) { var fileServerPath = parentFolderServerPath.Subpath(fileName); Optional <Item> tfsItem = _tfsCache.FindFile(fileServerPath.AsString()); if (tfsItem.Any()) { return(Optional <IServerPath> .Some(fileServerPath)); } else { return(Optional <IServerPath> .None()); } }
public Constraint <T> FindConstraint <T>(string key, out bool mandatory, T defaultVal) { if (Mandatory.Any(c => c.Key == key)) { mandatory = true; var constraint = Mandatory.First(c => c.Key == key); return(constraint as Constraint <T> ?? new Constraint <T>(constraint)); } mandatory = false; if (Optional.Any(c => c.Key == key)) { var constraint = Optional.First(c => c.Key == key); return(constraint as Constraint <T> ?? new Constraint <T>(constraint)); } return(null); }
public static string Import(string fileName, string mapDescriptorFile, Optional <int> mapId, Optional <sbyte> mapSet, Optional <sbyte> zone, Optional <sbyte> order, Optional <bool> tutorial, IProgress <ProgressInfo> progress, CancellationToken ct) { var dir = Directory.GetParent(fileName).FullName; var lines = File.ReadAllLines(fileName).ToList(); var mapDescriptorRelativePath = Path.GetRelativePath(dir, mapDescriptorFile); if (!mapId.Any()) { var highestMapId = 0; sbyte highestMapSet = 0; sbyte highestZone = 0; sbyte highestOrder = 0; foreach (var line in lines) { string[] columns = line.Split(new[] { ',' }, 6); var mapIdConfig = int.Parse(columns[0].Trim()); if (mapIdConfig > highestMapId) { highestMapId = mapIdConfig; } } foreach (var line in lines) { string[] columns = line.Split(new[] { ',' }, 6); var mapSetConfig = sbyte.Parse(columns[1].Trim()); if (mapSetConfig > highestMapSet) { highestMapSet = mapSetConfig; } } foreach (var line in lines) { string[] columns = line.Split(new[] { ',' }, 6); var mapSetConfig = sbyte.Parse(columns[1].Trim()); if (mapSetConfig == highestMapSet) { var zoneConfig = sbyte.Parse(columns[2].Trim()); if (zoneConfig > highestZone) { highestZone = zoneConfig; } } } foreach (var line in lines) { string[] columns = line.Split(new[] { ',' }, 6); var mapSetConfig = sbyte.Parse(columns[1].Trim()); if (mapSetConfig == highestMapSet) { var zoneConfig = sbyte.Parse(columns[2].Trim()); if (zoneConfig == highestZone) { var orderConfig = sbyte.Parse(columns[3].Trim()); if (orderConfig > highestOrder) { highestOrder = orderConfig; } } } } var newLine = String.Format("{0,2},{1,2},{2,2},{3,2},{4,5},{5}", highestMapId + 1, mapSet.OrElse(highestMapSet), zone.OrElse(highestZone), order.OrElse((sbyte)(highestOrder + 1)), tutorial.OrElse(false), mapDescriptorRelativePath); lines.Add(newLine); File.WriteAllLines(fileName, lines); progress?.Report("Added new map: " + newLine); return(newLine); } else { for (int i = 0; i < lines.Count; i++) { string[] columns = lines[i].Split(new[] { ',' }, 6); var mapIdConfig = int.Parse(columns[0].Trim()); var mapSetConfig = mapSet.OrElse(sbyte.Parse(columns[1].Trim())); var zoneConfig = zone.OrElse(sbyte.Parse(columns[2].Trim())); var orderConfig = order.OrElse(sbyte.Parse(columns[3].Trim())); var isPracticeBoardConfig = tutorial.OrElse(bool.Parse(columns[4].Trim())); if (mapIdConfig == mapId.Single()) { var newLine = String.Format("{0,2},{1,2},{2,2},{3,2},{4,5},{5}", mapId.Single(), mapSetConfig, zoneConfig, orderConfig, isPracticeBoardConfig, mapDescriptorRelativePath); lines[i] = newLine; progress?.Report("Replaced map: " + newLine); return(newLine); } } throw new ArgumentException("Could not find map with id " + mapId.Single()); } }
public override bool CanExecute(object parameter) { return(!_mergeBuilder.Any(builder => builder.IsActive)); }
public override bool CanExecute(object parameter) { return(!_featureBranchBuilder.Any(builder => builder.IsActive)); }