protected IOpenPlayerStrategy GetOpenPlayerStrategy()
        {
            ISettingsManager             settingsManager = ServiceRegistration.Get <ISettingsManager>();
            PlayerContextManagerSettings settings        = settingsManager.Load <PlayerContextManagerSettings>();
            string openPlayerStrategyTypeName            = settings.OpenPlayerStrategyTypeName;

            try
            {
                if (!string.IsNullOrEmpty(openPlayerStrategyTypeName))
                {
                    Type strategyType = Type.GetType(openPlayerStrategyTypeName);
                    if (strategyType == null)
                    {
                        return(new Default());
                    }
                    ConstructorInfo ci = strategyType.GetConstructor(new Type[] {});
                    return((IOpenPlayerStrategy)ci.Invoke(new object[] {}));
                }
            }
            catch (Exception e)
            {
                ServiceRegistration.Get <ILogger>().Warn("PlayerContextManager: Unable to load open player strategy type '{0}'", e, openPlayerStrategyTypeName);
            }
            return(new Default());
        }
Пример #2
0
        public override void Save()
        {
            base.Save();
            PlayerContextManagerSettings settings = SettingsManager.Load <PlayerContextManagerSettings>();
            int             selected     = Selected;
            IResourceString selectedItem = selected == -1 ? null : _items[selected];

            if (selectedItem != null)
            {
                settings.OpenPlayerStrategyTypeName = _piPOpenStrategyTypes[selectedItem].FullName;
                SettingsManager.Save(settings);
            }
        }
Пример #3
0
        public override void Load()
        {
            base.Load();
            Clear();
            PlayerContextManagerSettings settings = SettingsManager.Load <PlayerContextManagerSettings>();
            string settingTypeName = settings.OpenPlayerStrategyTypeName;
            int    currentIndex    = 0;

            foreach (Type openPlayerStrategyType in OPEN_PLAYER_STRATEGY_TYPES)
            {
                if (Add(openPlayerStrategyType) == settingTypeName)
                {
                    Selected = currentIndex;
                }
                currentIndex++;
            }
        }