public void StepTrace(int currStep, int prev, MapCordinate point, List <MappedCordinate> trace) { try { int value = this.Map[point.y][point.x]; currStep++; if (value < prev) { trace.Add(new MappedCordinate(currStep, prev, value, point.y, point.x)); this.StepTrace(currStep, value, new MapCordinate(point.y - 1, point.x), new List <MappedCordinate>(trace)); this.StepTrace(currStep, value, new MapCordinate(point.y, point.x + 1), new List <MappedCordinate>(trace)); this.StepTrace(currStep, value, new MapCordinate(point.y + 1, point.x), new List <MappedCordinate>(trace)); this.StepTrace(currStep, value, new MapCordinate(point.y, point.x - 1), new List <MappedCordinate>(trace)); } else if (trace.Count >= _lastLength) { _lastLength = trace.Count; if (!Paths.Any(x => x.SequenceEqual(trace))) { Paths.Add(trace.ToArray()); } } } catch // Out of Bounds { // Trace End } }
public override Task Validate(ICollection <string> errorMessages) { if (IsNullOrEmpty(Protocols) || Protocols.Any(string.IsNullOrWhiteSpace)) { errorMessages.Add("Route Protocols cannot be null or contain null or empty values"); } if (IsNullOrEmpty(Hosts) && IsNullOrEmpty(Methods) && IsNullOrEmpty(Paths)) { errorMessages.Add("At least one of 'hosts', 'methods', or 'paths' must be set"); return(Task.CompletedTask); } if (Hosts?.Any(string.IsNullOrWhiteSpace) == true) { errorMessages.Add("Route Hosts cannot contain null or empty values"); } if (Methods?.Any(string.IsNullOrWhiteSpace) == true) { errorMessages.Add("Route Methods cannot contain null or empty values"); } if (Paths?.Any(string.IsNullOrWhiteSpace) == true) { errorMessages.Add("Route Paths cannot contain null or empty values"); } return(Task.CompletedTask); }
private void PathsChanged() { pathPanel.Controls.Clear(); if (Paths == null || !Paths.Any()) { Hide(); } else { foreach (string path in Paths) { var link = new LinkLabel(); link.Tag = path; link.Image = PathsAreFolders ? Properties.Resources.OpenFolder : Properties.Resources.scroll_view_16x16_plain; link.ImageAlign = ContentAlignment.MiddleLeft; link.TextAlign = ContentAlignment.MiddleLeft; link.Padding = new Padding(20, 0, 0, 0); link.LinkBehavior = LinkBehavior.HoverUnderline; link.BackColor = Color.Transparent; link.LinkColor = Color.Blue; link.AutoSize = true; link.Font = new Font(link.Font.FontFamily, 9.75f); link.MouseClick += new MouseEventHandler(link_MouseClick); pathPanel.Controls.Add(link); } SetLinkText(); Show(); } }
protected virtual bool TryParsePaths(out ImmutableArray <PathInfo> paths) { paths = ImmutableArray <PathInfo> .Empty; if (Path.Any() && !TryEnsureFullPath(Path, PathOrigin.Argument, out paths)) { return(false); } if (Paths.Any()) { if (!TryEnsureFullPath(Paths, PathOrigin.Option, out ImmutableArray <PathInfo> paths2)) { return(false); } paths = paths.AddRange(paths2); } ImmutableArray <PathInfo> pathsFromFile = ImmutableArray <PathInfo> .Empty; if (PathsFrom != null) { if (!FileSystemHelpers.TryReadAllText(PathsFrom, out string?content, ex => Logger.WriteError(ex))) { return(false); } IEnumerable <string> lines = TextHelpers.ReadLines(content).Where(f => !string.IsNullOrWhiteSpace(f)); if (!TryEnsureFullPath(lines, PathOrigin.File, out pathsFromFile)) { return(false); } paths = paths.AddRange(pathsFromFile); } if (Console.IsInputRedirected && PipeMode == PipeMode.Paths) { if (!TryEnsureFullPath( ConsoleHelpers.ReadRedirectedInputAsLines().Where(f => !string.IsNullOrEmpty(f)), PathOrigin.RedirectedInput, out ImmutableArray <PathInfo> pathsFromInput)) { return(false); } paths = paths.AddRange(pathsFromInput); } if (paths.IsEmpty) { paths = ImmutableArray.Create(new PathInfo(Environment.CurrentDirectory, PathOrigin.CurrentDirectory)); } return(true); }
public virtual async Task Validate(IReadOnlyCollection <string> availablePlugins, ICollection <string> errorMessages) { if (IsNullOrEmpty(Protocols) || Protocols.Any(x => !new[] { "http", "https" }.Contains(x))) { errorMessages.Add("Route Protocols is invalid (must contain one or both of 'http' or 'https')."); } if (IsNullOrEmpty(Hosts) && IsNullOrEmpty(Methods) && IsNullOrEmpty(Paths)) { errorMessages.Add("At least one of Route 'Hosts', 'Methods', or 'Paths' must be set."); } if (Hosts == null || Hosts.Any(x => string.IsNullOrWhiteSpace(x) || Uri.CheckHostName(x) == UriHostNameType.Unknown)) { errorMessages.Add("Route Hosts is invalid (cannot be null, or contain null, empty or invalid values)."); } if (Methods == null || Methods.Any(string.IsNullOrWhiteSpace)) { errorMessages.Add("Route Methods is invalid (cannot be null, or contain null or empty values)."); } if (Paths == null || Paths.Any(x => string.IsNullOrWhiteSpace(x) || !Uri.IsWellFormedUriString(x, UriKind.Relative))) { errorMessages.Add("Route Paths is invalid (cannot be null, or contain null, empty or invalid values)."); } await ValidatePlugins(availablePlugins, errorMessages); }
public void Serialize(JsonWriter writer) { writer.WriteStartObject(); writer.WritePropertyName("swagger"); writer.WriteValue(Swagger); if (Info != null) { writer.WritePropertyName("info"); Info.Serialize(writer); } if (Host != null) { writer.WritePropertyName("host"); writer.WriteValue(Host); } if (BasePath != null) { writer.WritePropertyName("basePath"); writer.WriteValue(BasePath); } if (Paths != null && Paths.Any()) { writer.WritePropertyName("paths"); WritePaths(writer); } if (Definitions != null && Definitions.Any()) { writer.WritePropertyName("definitions"); WriteDefinitions(writer); } writer.WriteEndObject(); }
public void Serialize(JsonWriter writer) { writer.WriteStartObject(); writer.WritePropertyName("swagger"); writer.WriteValue(Swagger); if (Info != null) { writer.WritePropertyName("info"); Info.Serialize(writer); } if (Host != null) { writer.WritePropertyName("host"); writer.WriteValue(Host); } if (BasePath != null) { writer.WritePropertyName("basePath"); writer.WriteValue(BasePath); } if (Schemes != null && Schemes.Any()) { writer.WritePropertyName("schemes"); writer.WriteStartArray(); foreach (string sch in Schemes) { writer.WriteValue(sch); } writer.WriteEndArray(); } if (Paths != null && Paths.Any()) { writer.WritePropertyName("paths"); WritePaths(writer); } if (Definitions != null && Definitions.Any()) { writer.WritePropertyName("definitions"); WriteDefinitions(writer); } if (SecurityDefinitions != null && SecurityDefinitions.Any()) { writer.WritePropertyName("securityDefinitions"); WriteSecurityDefinitions(writer); } if (Tags?.Count > 0) { writer.WritePropertyName("tags"); var tagsValue = JsonConvert.SerializeObject(Tags); writer.WriteRawValue(tagsValue); } writer.WriteEndObject(); }
void Paths_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) { ContentLeft = Paths.Min(p => p.MinX); ContentTop = Paths.Min(p => p.MinY); ContentWidth = Paths.Max(p => p.MaxX) - ContentLeft; ContentHeight = Paths.Max(p => p.MaxY) - ContentTop; SaveCommand.SetCanExecute(Paths.Any()); }
internal override IDictionary <string, object> ToDictionary() { return(DictionaryFromKvps( KvpOrNull(Context != 3, "context", Context), KvpOrNull(Paths?.Any() == true, "path", Paths), KvpOrNull(IgnoreWhitespace, "ignore_whitespace", "true"), KvpOrNull(!Binary, "binary", "false") )); }
protected override void Update() { // If addStateCache is invalid, means last path should be re-calculate if (!addStateCache.IsValid && Paths.Any()) { var updatePath = Paths.LastOrDefault(); MarkAsInvalid(updatePath); addStateCache.Validate(); } base.Update(); }
public bool InSelection(string path) { if (Paths.Any(x => string.Compare(x, path, IgnoreCase) == 0)) { return(SelectMatchedPath()); } if (Dirs.Any(x => path.StartsWith(x + "/", IgnoreCase, CultureInfo.InvariantCulture))) { return(SelectMatchedPath()); } return(!SelectMatchedPath()); }
/// <summary> /// Gets the paths. /// </summary> /// <returns> /// </returns> public IEnumerable <string> GetImagePaths() { try { return(Paths?.Any() == true ? Paths : default(IEnumerable <string>)); } catch (Exception ex) { Fail(ex); return(default(IEnumerable <string>)); } }
private static void ParsePaths(string[] args) { Paths = args.Where(a => !a.StartsWith("-")).ToList(); if (!Paths.Any()) { throw new CmdLnException("At least one path expected as a command line argument"); } foreach (var path in Paths) { if (!Directory.Exists(path)) { throw new CmdLnException($"Directory {path} does not exist."); } } }
private int AmountOfNewFoldersFor(string pathToAdd) { var aux = pathToAdd; var foldersInPath = pathToAdd.Count(x => x == '/'); var newFolders = 0; while (newFolders < foldersInPath) { if (Paths.Any(p => p.StartsWith(aux))) { break; } aux = aux.Substring(0, aux.LastIndexOf('/')); newFolders++; } return(newFolders); }
public override string ToString() { if (Type != null) { return(string.Format("Type:{0}", Type.FullName)); } if (Nuget != null) { return(string.Format("Nuget:{0}[{1}]", Nuget.Item1, Nuget.Item2)); } if (Paths.Any()) { return(string.Format("Path:{0}", string.Join(",", Paths))); } return("<Invalid>"); }
public virtual async Task Validate(IDictionary <string, AsyncLazy <KongPluginSchema> > availablePlugins, ICollection <string> errorMessages) { if (IsNullOrEmpty(Protocols) || Protocols.Any(x => !AllowedProtocols.Contains(x))) { errorMessages.Add("Route Protocols is invalid (must contain one or both of 'http' or 'https')."); } if (IsNullOrEmpty(Hosts) && IsNullOrEmpty(Methods) && IsNullOrEmpty(Paths)) { errorMessages.Add("At least one of Route 'Hosts', 'Methods', or 'Paths' must be set."); } if (Hosts?.Any(string.IsNullOrWhiteSpace) == true) { errorMessages.Add("Route Hosts is invalid (cannot contain null or empty values)."); } if (Hosts?.Any(x => !string.IsNullOrWhiteSpace(x) && x.StartsWith("*.") && x.EndsWith(".*")) == true) { errorMessages.Add("Route Hosts is invalid (values cannot begin and end with a wildcard, only one wildcard at the start or end is allowed)."); } if (Hosts?.Any(x => !string.IsNullOrWhiteSpace(x) && Uri.CheckHostName(RemoveWildcards(x)) == UriHostNameType.Unknown) == true) { errorMessages.Add("Route Hosts is invalid (values must be valid hostnames or IP addresses, with a single optional wildcard at the start or end)."); } if (Methods?.Any(string.IsNullOrWhiteSpace) == true) { errorMessages.Add("Route Methods is invalid (cannot contain null or empty values)."); } if (Paths?.Any(string.IsNullOrWhiteSpace) == true) { errorMessages.Add("Route Paths is invalid (cannot contain null or empty values)."); } if (Paths?.Any(x => !string.IsNullOrWhiteSpace(x) && !x.StartsWith('/')) == true) { errorMessages.Add("Route Paths is invalid (values must start with '/')."); } await ValidatePlugins(availablePlugins, errorMessages); }
private PathEntry TryGetDebugPath(string system, string type) { if (Paths.Any(p => p.IsSystem(system))) { // we have the system, but not the type. don't attempt to add an unknown type return(null); } // we don't have anything for the system in question. add a set of stock paths var systemPath = $"{system.RemoveInvalidFileSystemChars()}_INTERIM"; var systemDisp = $"{system} (INTERIM)"; Paths.AddRange(new[] { new PathEntry { System = system, SystemDisplayName = systemDisp, Type = "Base", Path = Path.Combine(".", systemPath), Ordinal = 0 }, new PathEntry { System = system, SystemDisplayName = systemDisp, Type = "ROM", Path = ".", Ordinal = 1 }, new PathEntry { System = system, SystemDisplayName = systemDisp, Type = "Savestates", Path = Path.Combine(".", "State"), Ordinal = 2 }, new PathEntry { System = system, SystemDisplayName = systemDisp, Type = "Save RAM", Path = Path.Combine(".", "SaveRAM"), Ordinal = 3 }, new PathEntry { System = system, SystemDisplayName = systemDisp, Type = "Screenshots", Path = Path.Combine(".", "Screenshots"), Ordinal = 4 }, new PathEntry { System = system, SystemDisplayName = systemDisp, Type = "Cheats", Path = Path.Combine(".", "Cheats"), Ordinal = 5 } }); return(this[system, type]); }
public bool IsMatch(string path) { return(Paths.Any(p => path.StartsWith(p.Path, StringComparison.OrdinalIgnoreCase))); }