/// <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 = prop.Value; } var macroControl = instance as Control; if (macroControl != null) { macroControl.ID = uniqueId; return(macroControl); } } return(null); }
private void InitializeForm(string macroAlias) { //Hold selected Alias in Viewstate SelectedMacroAlias = macroAlias; //Create new property collection List<PersistableMacroProperty> props = new List<PersistableMacroProperty>(); //Clear Old Control Collection _formTable.Controls.Clear(); //Is a Macro selected if (!string.IsNullOrEmpty(macroAlias)) { Macro formMacro = Macro.GetByAlias(macroAlias); ///Only render form when macro is found if (formMacro != null) { if (formMacro.Properties.Length > 0) { propertiesHeader.Visible = true; } foreach (MacroProperty macroProperty in formMacro.Properties) { var prop = new PersistableMacroProperty(); prop.Alias = macroProperty.Alias; prop.Name = macroProperty.Name; prop.AssemblyName = macroProperty.Type.Assembly; prop.TypeName = macroProperty.Type.Type; //Assign value if specified if (DataValues[macroProperty.Alias.ToLower()] != null) { prop.Value = DataValues[macroProperty.Alias.ToLower()].ToString(); } props.Add(prop); } } } //Hold selected properties in ViewState SelectedProperties = props; //Render the form RendeFormControls(); }