예제 #1
0
        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;
        }
예제 #2
0
파일: Utils.cs 프로젝트: zyonet/Pscx
        public static string GetShortPathName(string path)
        {
            PscxArgumentException.ThrowIfIsNull(path);
            FileSystemInfo info = GetFileOrDirectory(path);

            if (info == null)
            {
                throw new FileNotFoundException();
            }

            return(GetShortPathName(info));
        }
예제 #3
0
파일: Utils.cs 프로젝트: zyonet/Pscx
        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());
        }
예제 #4
0
파일: Utils.cs 프로젝트: zyonet/Pscx
        public static TEnum ParseEnumOrThrow <TEnum>(string value)
        {
            PscxArgumentException.ThrowIfIsNotDefined(typeof(TEnum), value);

            return((TEnum)(Enum.Parse(typeof(TEnum), value)));
        }