internal LocalDescriptionAttribute(string description) : base(description)
 {
     this.description = string.Empty;
     this.description = SharedUtil.Trim(description);
     this.memberName  = string.Empty;
     this.type        = null;
 }
Beispiel #2
0
 private static string Extract(string value)
 {
     if (!SharedUtil.IsEmpty(value))
     {
         for (int i = 0; i < 20; i++)
         {
             value = value.Replace("%" + i, string.Empty);
         }
         value = value.Replace("\"\"", string.Empty).Trim();
         int index = value.ToLower().IndexOf(".exe");
         if (index > 0)
         {
             value = value.Substring(0, index + 4);
         }
         while (value.StartsWith("\"") || value.StartsWith("@"))
         {
             value = value.Substring(1);
         }
         while (value.EndsWith("\""))
         {
             value = value.Substring(0, value.Length - 1);
         }
     }
     return(SharedUtil.Trim(value));
 }
 internal LocalDescriptionAttribute(Type type, string memberName)
 {
     this.description = string.Empty;
     this.type        = type;
     if (this.type == null)
     {
         throw new ArgumentNullException("type");
     }
     this.memberName = SharedUtil.Trim(memberName);
 }
Beispiel #4
0
 internal ShellInfo(string filePath)
 {
     if (SharedUtil.IsEmpty(this.FilePath = SharedUtil.Trim(filePath)))
     {
         throw new ArgumentNullException("filePath");
     }
     this.DirectoryName    = Path.GetDirectoryName(this.FilePath);
     this.Extension        = Path.GetExtension(this.FilePath).ToLower();
     this.DotLessExtension = this.Extension.Replace(".", string.Empty);
     this.FileName         = Path.GetFileName(this.FilePath);
     this.Name             = Path.GetFileNameWithoutExtension(this.FilePath);
 }
Beispiel #5
0
 private static string AppDesc(ref string value)
 {
     try
     {
         RegistryKey key = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\ShellNoRoam\MUICache", false);
         if (key != null)
         {
             using (key)
             {
                 string[] strArray;
                 if (!SharedUtil.IsEmpty((ICollection)(strArray = key.GetValueNames())))
                 {
                     foreach (string str in strArray)
                     {
                         if (value.ToLower().IndexOf(str.ToLower()) >= 0)
                         {
                             return(SharedUtil.Trim(key.GetValue(str, value, RegistryValueOptions.None) as string));
                         }
                     }
                     foreach (string str2 in strArray)
                     {
                         if (str2.ToLower().IndexOf(value.ToLower()) >= 0)
                         {
                             value = str2;
                             return(SharedUtil.Trim(key.GetValue(str2, value, RegistryValueOptions.None) as string));
                         }
                     }
                 }
             }
         }
     }
     catch
     {
     }
     try
     {
         return("(" + Path.GetFileNameWithoutExtension(Extract(value)) + ")");
     }
     catch
     {
         return("(" + value + ")");
     }
 }
        protected override string GetLocalizedString(string value)
        {
            string category = this.category;

            if (!this.loaded)
            {
                try
                {
                    ResourceManager resourceManager = SharedUtil.GetResourceManager(this.type.Assembly);
                    string[]        resourceNames   = this.GetResourceNames();
                    for (int i = 0; i < resourceNames.Length; i++)
                    {
                        if (!SharedUtil.IsEmpty(category = SharedUtil.Trim(SharedUtil.GetString(resourceManager, resourceNames[i], new object[0]))))
                        {
                            break;
                        }
                    }
                    if ((SharedUtil.IsEmpty(category) && (this.type.BaseType != null)) && (this.type.BaseType != typeof(object)))
                    {
                        category = new LocalCategoryAttribute(this.type.BaseType, this.category).Category;
                    }
                }
                catch
                {
                }
                finally
                {
                    if (SharedUtil.IsEmpty(category))
                    {
                        category = this.category;
                    }
                    else
                    {
                        this.category = category;
                    }
                    this.loaded = true;
                }
            }
            return(category);
        }
 internal DisplayNameAttribute(string displayName)
 {
     this.displayName = SharedUtil.Trim(displayName);
     this.memberName  = string.Empty;
     this.type        = null;
 }
Beispiel #8
0
        internal static string[] GetUserLanguages(ref string languagePreference, params string[] supportedLanguages)
        {
            ArrayList list = null;
            int       index;
            string    str;
            bool      flag = true;
            string    str2 = languagePreference = SharedUtil.Trim(languagePreference).ToLower();

            if (!SharedUtil.IsEmpty((string)languagePreference) && ((index = languagePreference.IndexOf('-')) > 0))
            {
                str2 = languagePreference.Substring(0, index);
            }
            if (((HttpContext.Current == null) || (HttpContext.Current.Request == null)) || SharedUtil.IsEmpty((ICollection)HttpContext.Current.Request.UserLanguages))
            {
                if (!SharedUtil.IsEmpty((ICollection)supportedLanguages))
                {
                    list = new ArrayList(supportedLanguages);
                }
                else
                {
                    list = new ArrayList();
                }
            }
            else
            {
                list = new ArrayList(HttpContext.Current.Request.UserLanguages.Clone() as ICollection);
                while (flag && (list.Count > 0))
                {
                    flag = false;
                    for (int i = 0; i < list.Count; i++)
                    {
                        if (flag = (list[i] == null) || SharedUtil.IsEmpty(list[i] as string))
                        {
                            list.Remove(i);
                            continue;
                        }
                        if (flag = (index = ((string)list[i]).IndexOf(';')) >= 0)
                        {
                            list[i] = ((string)list[i]).Substring(0, index);
                            continue;
                        }
                        if (flag = (index = ((string)list[i]).IndexOf('-')) >= 0)
                        {
                            list[i] = ((string)list[i]).Substring(0, index);
                            continue;
                        }
                        list[i] = SharedUtil.Trim((string)list[i]).ToLower();
                    }
                }
                if (!SharedUtil.IsEmpty((ICollection)supportedLanguages))
                {
                    flag = true;
                    while (flag)
                    {
                        flag = false;
                        foreach (string str3 in list)
                        {
                            if (Array.IndexOf <string>(supportedLanguages, str3) < 0)
                            {
                                flag = true;
                                list.Remove(str3);
                                continue;
                            }
                        }
                    }
                }
            }
            if (SharedUtil.IsEmpty((ICollection)list))
            {
                list.AddRange(supportedLanguages);
            }
            if ((Array.IndexOf <string>(supportedLanguages, languagePreference) < 0) && (Array.IndexOf <string>(supportedLanguages, str2) >= 0))
            {
                languagePreference = str2;
            }
            languagePreference = str = SharedUtil.Trim(languagePreference).ToLower();
            if (!SharedUtil.IsEmpty(str) && (Array.IndexOf <string>(supportedLanguages, languagePreference) >= 0))
            {
                index = list.IndexOf(languagePreference);
                if (index >= 0)
                {
                    list.RemoveAt(index);
                }
                list.Insert(0, languagePreference);
            }
            else if ((list.Count > 0) && ((languagePreference = list[0] as string) == null))
            {
                languagePreference = string.Empty;
            }
            return(list.ToArray(typeof(string)) as string[]);
        }
 internal LocalCategoryAttribute(Type type, string category) : base(category)
 {
     this.category = string.Empty;
     this.category = SharedUtil.Trim(category);
     SharedUtil.ThrowIfNull(this.type = type, "type");
 }