Exemple #1
0
 public static void OpenOffencesMenu(UIMenu callingMenu, List <Offence> SelectedOffences)
 {
     foreach (UIMenu men in OffenceCategoryMenus)
     {
         men.ParentMenu = callingMenu;
         foreach (UIMenuItem it in men.MenuItems)
         {
             if (it is UIMenuCheckboxItem)
             {
                 ((UIMenuCheckboxItem)it).Checked = SelectedOffences.Contains(CheckboxItems_Offences.FirstOrDefault(x => x.Item1 == it).Item2);
             }
         }
     }
     OffenceCategoryMenus[0].Visible = true;
 }
        public static T GetInstance(Type type, string key = null)
        {
            CheckType(type);

            // no key, return a new instance
            if (string.IsNullOrEmpty(key) == true)
            {
                return((T)Activator.CreateInstance(type));
            }

            // try to find an existing instance with that key
            var tuple = _instancesWithKey.FirstOrDefault(o => o.Item1 == type && o.Item2 == key);

            if (tuple != null)
            {
                return(tuple.Item3);
            }

            // create a new instance and register it
            T instance = (T)Activator.CreateInstance(type);

            _instancesWithKey.Add(type, key, instance);
            return(instance);
        }