public static ArgumentHasText ( string argument, string name ) : void | ||
argument | string | The string to check. |
name | string | The argument name. |
return | void |
/// <summary> /// Returns a key unique for the given type. /// </summary> /// <param name="type">The type the key shall be unique to</param> /// <param name="partialKey">The partial key to be made unique</param> /// <returns>A key formatted as <i>typename.partialkey</i></returns> public static string GetTypeScopedString(Type type, string partialKey) { AssertUtils.ArgumentNotNull(type, "type"); AssertUtils.ArgumentHasText(partialKey, "partialKey"); return(GetUniqueKey(type, null, partialKey)); }
/// <summary> /// Returns a key unique for the given instance. /// </summary> /// <param name="instance">The instance the key shall be unique to</param> /// <param name="partialKey">The partial key to be made unique</param> /// <returns>A key formatted as <i>typename[instance-id].partialkey</i></returns> public static string GetInstanceScopedString(object instance, string partialKey) { AssertUtils.ArgumentNotNull(instance, "instance"); AssertUtils.ArgumentHasText(partialKey, "partialKey"); if (instance is Type) { throw new ArgumentException( "please use GetUniqueKey(Type,string) for creating type specific keys", "instance"); } return(GetUniqueKey(instance.GetType(), instance, partialKey)); }
/// <summary> /// Extracts the bare ASPX page name without any extension from the /// supplied <paramref name="url"/>. /// </summary> /// <example> /// <p> /// Examples of what would be returned from this method given a url would be: /// </p> /// <p> /// <list type="bullet"> /// <item><description>'Login.aspx' => 'Login'</description></item> /// <item><description>'~/Login.aspx' => 'Login'</description></item> /// <item><description>'~/B2B/SignUp.aspx' => 'SignUp'</description></item> /// <item><description>'B2B/Foo/FooServices.aspx' => 'FooServices'</description></item> /// </list> /// </p> /// </example> /// <param name="url">The full URL to the ASPX page.</param> /// <returns> /// The bare ASPX page name without any extension. /// </returns> /// <exception cref="System.ArgumentNullException"> /// If the supplied <paramref name="url"/> is <see langword="null"/> or /// contains only whitespace character(s). /// </exception> public static string GetPageName(string url) { AssertUtils.ArgumentHasText(url, "url"); int lastSlash = url.LastIndexOf('/'); int lastDot = url.LastIndexOf('.'); if (lastDot < lastSlash) { lastDot = -1; } if (lastDot < 0) { int length = url.Length - lastSlash - 1; return(url.Substring(lastSlash + 1, length)); } return(url.Substring(lastSlash + 1, lastDot - lastSlash - 1)); }
public static void SaveAssembly(string assemblyName) { AssertUtils.ArgumentHasText(assemblyName, "assemblyName"); ModuleBuilder module = null; lock (s_moduleCache.SyncRoot) { module = (ModuleBuilder)s_moduleCache[assemblyName]; } if (module == null) { throw new ArgumentException(string.Format("'{0}' is not a valid dynamic assembly name", assemblyName), "assemblyName"); } AssemblyBuilder assembly = (AssemblyBuilder)module.Assembly; assembly.Save(assembly.GetName().Name + ".dll"); }
/// <summary> /// Combines a rooted base path with a relative path. /// </summary> /// <param name="rootPath">Must be a path starting with '/'</param> /// <param name="relativePath">the path to be combined. May start with basepath Placeholder '~'</param> /// <returns>the combined path</returns> /// <remarks> /// If relativePath starts with '~', rootPath is ignored and '~' resolves to the current AppDomain's application virtual path<br/> /// If relativePath start with '/', rootPath is ignored and relativePath is returned as-is. /// </remarks> public static string CombineVirtualPaths(string rootPath, string relativePath) { AssertUtils.ArgumentHasText(rootPath, "rootPath"); if (rootPath[0] != '/') { throw new ArgumentException("RootPath must start with '/'", "rootPath"); } string combinedPath = relativePath; if (combinedPath.StartsWith("~/")) { combinedPath = VirtualEnvironment.ApplicationVirtualPath.TrimEnd('/') + relativePath.Substring(1); } if (!combinedPath.StartsWith("/")) { combinedPath = GetVirtualDirectory(rootPath).TrimEnd('/') + '/' + relativePath; } // TODO: reduce contained directory upwalks here return(combinedPath); }
public void ArgumentHasText() { Assert.Throws <ArgumentNullException>(() => AssertUtils.ArgumentHasText(null, "foo")); }
public void ArgumentHasTextWithValidTextAndMessage() { AssertUtils.ArgumentHasText("... and no-one's getting fat 'cept Mama Cas!", "foo", "Bang!"); }
public void ArgumentHasTextWithMessage() { Assert.Throws <ArgumentNullException>(() => AssertUtils.ArgumentHasText(null, "foo", "Bang!")); }
public void ArgumentHasTextWithMessage() { AssertUtils.ArgumentHasText(null, "foo", "Bang!"); }
public void ArgumentHasText() { AssertUtils.ArgumentHasText(null, "foo"); }