public RelatedLinkAttribute(Type cmdletType) { CmdletAttribute attr = Utils.GetAttribute <CmdletAttribute>(cmdletType); PscxArgumentException.ThrowIfIsNull(attr, "The type {0} is not a cmdlet.", cmdletType); _text = attr.VerbName + '-' + attr.NounName; }
public static string GetShortPathName(string path) { PscxArgumentException.ThrowIfIsNull(path); FileSystemInfo info = GetFileOrDirectory(path); if (info == null) { throw new FileNotFoundException(); } return(GetShortPathName(info)); }
public static string GetShortPathName(FileSystemInfo info) { PscxArgumentException.ThrowIfIsNull(info); if (!info.Exists) { if (info is DirectoryInfo) { throw new DirectoryNotFoundException(); } throw new FileNotFoundException(); } StringBuilder buffer = new StringBuilder(MaxPath); bool result = NativeMethods.GetShortPathName(info.FullName, buffer, (uint)(buffer.Capacity)); if (!result) { throw new Win32Exception(); } return(buffer.ToString()); }
public static TEnum ParseEnumOrThrow <TEnum>(string value) { PscxArgumentException.ThrowIfIsNotDefined(typeof(TEnum), value); return((TEnum)(Enum.Parse(typeof(TEnum), value))); }