Example #1
0
        /// <summary>Returns a theme feature object for internal use</summary>
        /// <returns>IThemeStandardFeatures implementation specific to the provided theme</returns>
        public static IThemeStandardFeatures GetStandardThemeFeatures()
        {
            try
            {
                var appEx = Current as ApplicationEx;
                if (appEx == null)
                {
                    return(null);
                }
                var key = appEx.Theme;

                if (!StandardThemeFeatures.ContainsKey(key))
                {
                    var implementationType     = appEx.TryFindResource("ThemeStandardFeaturesType").ToString();
                    var implementationAssembly = appEx.TryFindResource("ThemeStandardFeaturesAssembly").ToString();

                    var wrapper = new StandardThemeFeatureWrapper();
                    try
                    {
                        wrapper.StandardFeatures   = ObjectHelper.CreateObject(implementationType, implementationAssembly) as IThemeStandardFeatures;
                        wrapper.ThemeFeaturesFound = wrapper.StandardFeatures != null;
                    }
                    catch (Exception)
                    {
                        wrapper.ThemeFeaturesFound = false;
                    }
                    StandardThemeFeatures.Add(key, wrapper);
                }

                if (StandardThemeFeatures[key].ThemeFeaturesFound)
                {
                    return(StandardThemeFeatures[key].StandardFeatures);
                }
            }
            catch (Exception)
            {
                return(null);
            }
            return(null);
        }
Example #2
0
        /// <summary>Returns a theme feature object for internal use</summary>
        /// <returns>IThemeStandardFeatures implementation specific to the provided theme</returns>
        public static IThemeStandardFeatures GetStandardThemeFeatures()
        {
            try
            {
                var appex = Current as ApplicationEx;
                if (appex == null) return null;
                var key = appex.Theme;

                if (!StandardThemeFeatures.ContainsKey(key))
                {
                    var implementationType = appex.TryFindResource("ThemeStandardFeaturesType").ToString();
                    var implementationAssembly = appex.TryFindResource("ThemeStandardFeaturesAssembly").ToString();

                    var wrapper = new StandardThemeFeatureWrapper();
                    try
                    {
                        wrapper.StandardFeatures = ObjectHelper.CreateObject(implementationType, implementationAssembly) as IThemeStandardFeatures;
                        wrapper.ThemeFeaturesFound = wrapper.StandardFeatures != null;
                    }
                    catch (Exception)
                    {
                        wrapper.ThemeFeaturesFound = false;
                    }
                    StandardThemeFeatures.Add(key, wrapper);
                }

                if (StandardThemeFeatures[key].ThemeFeaturesFound)
                    return StandardThemeFeatures[key].StandardFeatures;
            }
            catch (Exception)
            {
                return null;
            }
            return null;
        }