Esempio n. 1
0
        /// <summary>
        /// Create an instance of a Macro control and return it.
        /// Because the macro control uses inline client script whichs is not generated after postback
        /// That's why we use the Page Picker instead of the content picker of the macro.
        /// </summary>
        /// <remarks>
        /// This is legacy code migrated from umbraco.editorControls.macrocontainer.MacroControlFactory
        /// </remarks>
        internal Control GetMacroRenderControlByType(PersistableMacroProperty prop, string uniqueId)
        {
            var m        = MacroControlTypes.FindLast(macroGuiCcontrol => macroGuiCcontrol.ToString() == string.Format("{0}.{1}", prop.AssemblyName, prop.TypeName));
            var instance = ServiceProvider.GetService(m) as IMacroGuiRendering;

            if (instance != null)
            {
                if (string.IsNullOrEmpty(prop.Value) == false)
                {
                    instance.Value = HttpUtility.HtmlDecode(prop.Value);
                }
                var macroControl = instance as Control;
                if (macroControl != null)
                {
                    macroControl.ID = uniqueId;
                    return(macroControl);
                }
            }
            return(null);
        }
Esempio n. 2
0
        /// <summary>
        /// Create an instance of a Macro control and return it.
        /// Because the macro control uses inline client script whichs is not generated after postback
        /// That's why we use the Page Picker instead of the content picker of the macro.
        /// </summary>
        /// <remarks>
        /// This is legacy code migrated from umbraco.editorControls.macrocontainer.MacroControlFactory
        /// </remarks>
        internal Control GetMacroRenderControlByType(PersistableMacroProperty prop, string uniqueId)
        {
            var m        = MacroControlTypes.FindLast(macroGuiCcontrol => macroGuiCcontrol.ToString() == string.Format("{0}.{1}", prop.AssemblyName, prop.TypeName));
            var instance = PluginManager.Current.CreateInstance <IMacroGuiRendering>(m);

            if (instance != null)
            {
                if (!string.IsNullOrEmpty(prop.Value))
                {
                    instance.Value = HttpUtility.HtmlDecode(prop.Value);
                }
                var macroControl = instance as Control;
                if (macroControl != null)
                {
                    macroControl.ID = uniqueId;
                    return(macroControl);
                }
            }
            return(null);
        }