예제 #1
0
 /// <summary>
 /// Validates a <see cref="string" /> that is a path.
 /// </summary>
 /// <param name="str">The <see cref="string" /> to be validated.</param>
 /// <returns>
 /// <see langword="true" />, if validation of <paramref name="str" /> succeeded;
 /// otherwise, <see langword="false" />.
 /// </returns>
 public static bool Path(string str)
 {
     return(str != null && CSharp.Try(() => new FileIOPermission(FileIOPermissionAccess.Read, new[] { str }).Demand()));
 }
예제 #2
0
 /// <summary>
 /// Validates a <see cref="string" /> that is a web URL with http or https scheme.
 /// </summary>
 /// <param name="str">The <see cref="string" /> to be validated.</param>
 /// <returns>
 /// <see langword="true" />, if validation of <paramref name="str" /> succeeded;
 /// otherwise, <see langword="false" />.
 /// </returns>
 public static bool Url(string str)
 {
     return(Uri.TryCreate(str, UriKind.Absolute, out Uri result) && CSharp.EqualsAny(result.Scheme, "http", "https"));
 }
예제 #3
0
 /// <summary>
 /// Validates a <see cref="string" /> that is a path.
 /// </summary>
 /// <param name="str">The <see cref="string" /> to be validated.</param>
 /// <returns>
 /// <see langword="true" />, if validation of <paramref name="str" /> succeeded;
 /// otherwise, <see langword="false" />.
 /// </returns>
 public static bool Path(string str)
 {
     return(str != null && CSharp.Try(() => new FileIOPermission(FileIOPermissionAccess.Read, SingletonCollection.Array(str)).Demand()));
 }