public static void GetDebugControlName(IFormChannelIdentifier channel, out string debugControlNamespace, out string debugControlName) { if (null == ConfigurationServices.ConfigurationSource) { throw new ConfigurationErrorsException("Missing configuration"); } UiControlFactorySettings settings = ConfigurationServices.ConfigurationSource.GetSection(UiControlFactorySettings.SectionName) as UiControlFactorySettings; if (null == settings) { throw new ConfigurationErrorsException(string.Format("The configuration section '{0}' was not found in the configuration", UiControlFactorySettings.SectionName)); } try { debugControlNamespace = settings.Channels[channel.ChannelName].DebugControlNamespace; debugControlName = settings.Channels[channel.ChannelName].DebugControlName; } catch (Exception e) { throw new ConfigurationErrorsException(string.Format("The channel {0} is missing from the configuration", channel.ChannelName), e); } }
public static IUiControl CreateControl(IFormChannelIdentifier channel, string namespaceName, string name) { string compositeName = string.Format("{0}->{1}->{2}", channel.ChannelName, namespaceName, name); if (false == _resourceLocker.Resources.FactoryCache.ContainsKey(compositeName)) { try { IUiControlFactory uiControlFactory = _resourceLocker.Resources.Factory.Create(compositeName); using (_resourceLocker.Locker) { if (_resourceLocker.Resources.FactoryCache.ContainsKey(compositeName) == false) { _resourceLocker.Resources.FactoryCache.Add(compositeName, uiControlFactory); } } } catch (ArgumentException ex) { HandleControlConfigurationError(ex, compositeName); } catch (ConfigurationErrorsException ex) { HandleControlConfigurationError(ex, compositeName); } } IUiControlFactory factory = _resourceLocker.Resources.FactoryCache[compositeName]; IUiControl control = factory.CreateControl(); control.UiControlChannel = channel; return(control); }
internal SchemaInfo(IFormChannelIdentifier channelIdentifier, XNamespace namespaceObj, XDocument schema) { this.ChannelIdentifier = channelIdentifier; this.Namespace = namespaceObj; this.Schema = schema; this.SchemaType = FormSchemaType.Uicontrols; }
/// <exclude /> public void Compile(XDocument doc, IFormChannelIdentifier channel, Dictionary <string, object> bindingObjects, bool withDebug, string customControlIdPrefix, Dictionary <string, List <ClientValidationRule> > bindingsValidationRules) { _bindingObjects = bindingObjects; _context = new CompileContext { BindingObjects = bindingObjects, BindingsValidationRules = bindingsValidationRules, CurrentChannel = channel, CustomControlIdPrefix = customControlIdPrefix }; _rootCompilerNode = BuildFromXmlPhase.BuildTree(doc); UpdateXmlInformationPhase updateInfo = new UpdateXmlInformationPhase(); updateInfo.UpdateInformation(_rootCompilerNode); CreateProducersPhase createProducers = new CreateProducersPhase(_context); createProducers.CreateProducers(_rootCompilerNode); EvaluatePropertiesPhase evaluateProperties = new EvaluatePropertiesPhase(_context, withDebug); evaluateProperties.Evaluate(_rootCompilerNode); ExtractUiArtifactsPhase extractUiArtifacts = new ExtractUiArtifactsPhase(); extractUiArtifacts.ExtractUiArtifacts(_rootCompilerNode, out _uiControl, out _label, out _tooltip, out _iconHandle); }
/// <exclude /> public void Compile(XDocument doc, IFormChannelIdentifier channel, Dictionary<string, object> bindingObjects, bool withDebug, string customControlIdPrefix, Dictionary<string, List<ClientValidationRule>> bindingsValidationRules) { _bindingObjects = bindingObjects; _context = new CompileContext { BindingObjects = bindingObjects, BindingsValidationRules = bindingsValidationRules, CurrentChannel = channel, CustomControlIdPrefix = customControlIdPrefix }; _rootCompilerNode = BuildFromXmlPhase.BuildTree(doc); UpdateXmlInformationPhase updateInfo = new UpdateXmlInformationPhase(); updateInfo.UpdateInformation(_rootCompilerNode); CreateProducersPhase createProducers = new CreateProducersPhase(_context); createProducers.CreateProducers(_rootCompilerNode); EvaluatePropertiesPhase evaluateProperties = new EvaluatePropertiesPhase(_context, withDebug); evaluateProperties.Evaluate(_rootCompilerNode); ExtractUiArtifactsPhase extractUiArtifacts = new ExtractUiArtifactsPhase(); extractUiArtifacts.ExtractUiArtifacts(_rootCompilerNode, out _uiControl, out _label, out _tooltip, out _iconHandle); }
public static IUiControl CreateControl(IFormChannelIdentifier channel, string namespaceName, string name) { string compositeName = string.Format("{0}->{1}->{2}", channel.ChannelName, namespaceName, name); if (false == _resourceLocker.Resources.FactoryCache.ContainsKey(compositeName)) { try { IUiControlFactory uiControlFactory = _resourceLocker.Resources.Factory.Create(compositeName); using (_resourceLocker.Locker) { if (_resourceLocker.Resources.FactoryCache.ContainsKey(compositeName) == false) { _resourceLocker.Resources.FactoryCache.Add(compositeName, uiControlFactory); } } } catch (ArgumentException ex) { HandleControlConfigurationError(ex, compositeName); } catch (ConfigurationErrorsException ex) { HandleControlConfigurationError(ex, compositeName); } } IUiControlFactory factory = _resourceLocker.Resources.FactoryCache[compositeName]; IUiControl control = factory.CreateControl(); control.UiControlChannel = channel; return control; }
public static IUiContainer CreateContainer(IFormChannelIdentifier channel, IFlowUiContainerType flowUiContainerType) { string compositeName = string.Format("{0}->{1}", channel.ChannelName, flowUiContainerType.ContainerName); IUiContainerFactory containerFactory; if (_resourceLocker.Resources.ContainerfactoryCache.TryGetValue(compositeName, out containerFactory) == false) { try { containerFactory = _resourceLocker.Resources.Factory.Create(compositeName); using (_resourceLocker.Locker) { if (_resourceLocker.Resources.ContainerfactoryCache.ContainsKey(compositeName) == false) _resourceLocker.Resources.ContainerfactoryCache.Add(compositeName, containerFactory); } } catch (ArgumentException ex) { HandleConfigurationError(ex); } catch (ConfigurationErrorsException ex) { HandleConfigurationError(ex); } } return containerFactory.CreateContainer(); }
public static IUiContainer CreateContainer(IFormChannelIdentifier channel, IFlowUiContainerType flowUiContainerType) { string compositeName = string.Format("{0}->{1}", channel.ChannelName, flowUiContainerType.ContainerName); IUiContainerFactory containerFactory; if (_resourceLocker.Resources.ContainerfactoryCache.TryGetValue(compositeName, out containerFactory) == false) { try { containerFactory = _resourceLocker.Resources.Factory.Create(compositeName); using (_resourceLocker.Locker) { if (_resourceLocker.Resources.ContainerfactoryCache.ContainsKey(compositeName) == false) { _resourceLocker.Resources.ContainerfactoryCache.Add(compositeName, containerFactory); } } } catch (ArgumentException ex) { HandleConfigurationError(ex); } catch (ConfigurationErrorsException ex) { HandleConfigurationError(ex); } } return(containerFactory.CreateContainer()); }
public IUiControl Render( IUiControl innerForm, IUiControl customToolbarItems, IFormChannelIdentifier channel, IDictionary <string, object> eventHandlerBindings, string containerLabel, string containerLabelField, ResourceHandle containerIcon) { if (string.IsNullOrEmpty(_templateFormVirtualPath) == false) { WebEmbeddedFormUiControl document = new WebEmbeddedFormUiControl(channel); document.FormPath = _templateFormVirtualPath; // "/Composite/Templates/Document.xml"; document.Bindings = new Dictionary <string, object>(eventHandlerBindings); document.Bindings.Add("Form", innerForm); if (customToolbarItems != null) { document.Bindings.Add("CustomToolbarItems", customToolbarItems); } _webDocument = new TemplatedExecutionContainer(document, _templateUserControlType, containerLabel, containerLabelField, containerIcon); } else { _webDocument = new TemplatedExecutionContainer((IWebUiControl)innerForm, _templateUserControlType, containerLabel, containerLabelField, containerIcon); } return(_webDocument); }
public IUiControl Render( IUiControl innerForm, IUiControl customToolbarItems, IFormChannelIdentifier channel, IDictionary<string, object> eventHandlerBindings, string containerLabel, string containerLabelField, ResourceHandle containerIcon) { if (string.IsNullOrEmpty(_templateFormVirtualPath) == false) { WebEmbeddedFormUiControl document = new WebEmbeddedFormUiControl(channel); document.FormPath = _templateFormVirtualPath; // "/Composite/Templates/Document.xml"; document.Bindings = new Dictionary<string, object>(eventHandlerBindings); document.Bindings.Add("Form", innerForm); if (customToolbarItems != null) { document.Bindings.Add("CustomToolbarItems", customToolbarItems); } _webDocument = new TemplatedExecutionContainer(document, _templateUserControlType, containerLabel, containerLabelField, containerIcon); } else { _webDocument = new TemplatedExecutionContainer((IWebUiControl)innerForm, _templateUserControlType, containerLabel, containerLabelField, containerIcon); } return _webDocument; }
internal static FormTreeCompiler Build(string formPath, IFormChannelIdentifier channel, Dictionary <string, object> bindings, bool debugMode) { string folderPath = Path.GetDirectoryName(formPath).ToLowerInvariant(); string fileName = Path.GetFileName(formPath).ToLowerInvariant(); List <IFormDefinitionFile> formFiles = (from file in DataFacade.GetData <IFormDefinitionFile>() where file.FolderPath.ToLowerInvariant() == folderPath && file.FileName.ToLowerInvariant() == fileName select file).ToList(); if (formFiles.Count == 0) { throw new ArgumentException(string.Format("No form definition with path '{0}' was found. Please use a virtual Form Path", formPath), "formPath"); } if (formFiles.Count > 1) { throw new ArgumentException(string.Format("Multiple form definitions with path '{0}' was found", formPath), "formPath"); } FormTreeCompiler compiler = new FormTreeCompiler(); using (XmlTextReader formMarkupReader = new XmlTextReader(formFiles[0].GetReadStream())) { compiler.Compile(formMarkupReader, channel, bindings, debugMode); return(compiler); } }
/// <exclude /> public void Compile(XmlReader reader, IFormChannelIdentifier channel, Dictionary<string, object> bindingObjects, bool withDebug, string customControlIdPrefix, Dictionary<string, List<ClientValidationRule>> bindingsValidationRules) { XDocument doc = XDocument.Load(reader); reader.Close(); Compile(doc, channel, bindingObjects, withDebug, customControlIdPrefix, bindingsValidationRules); }
/// <exclude /> public void Compile(XmlReader reader, IFormChannelIdentifier channel, Dictionary <string, object> bindingObjects, bool withDebug, string customControlIdPrefix, Dictionary <string, List <ClientValidationRule> > bindingsValidationRules) { XDocument doc = XDocument.Load(reader); reader.Close(); Compile(doc, channel, bindingObjects, withDebug, customControlIdPrefix, bindingsValidationRules); }
/// <exclude /> public static XDocument GenerateUiControlSchema(IFormChannelIdentifier channelIdentifier, XNamespace controlNamespace) { Dictionary <XNamespace, XDocument> schemas = new Dictionary <XNamespace, XDocument>(); ElementInformationExtractor worker = new ElementInformationExtractor(ConfigurationServices.FileConfigurationSourcePath); var elementDescriptors = from descriptor in worker.GetUiControlDescriptors() where descriptor.ChannelName == channelIdentifier.ChannelName && descriptor.NamespaceName == controlNamespace select descriptor; return(worker.GetXsd(elementDescriptors, controlNamespace)); }
public object CreateProducer(IFormChannelIdentifier channel, string namespaceName, string name) { switch (name) { case "function": return new FunctionProducer(); case "param": return new FunctionParameterProducer(); case "paramelement": return new FunctionParameterElementProducer(); default: throw new NotSupportedException("Not supported producer tag. Check whether the namespace or the tag name is correct. {{ {0} }} {1}".FormatWith(namespaceName, name)); } }
public object CreateProducer(IFormChannelIdentifier channel, string namespaceName, string name) { switch (name) { case "function": return(new FunctionProducer()); case "param": return(new FunctionParameterProducer()); case "paramelement": return(new FunctionParameterElementProducer()); default: throw new NotSupportedException("Not supported producer tag. Check whether the namespace or the tag name is correct. {{ {0} }} {1}".FormatWith(namespaceName, name)); } }
internal static FormTreeCompiler Build(string formPath, IFormChannelIdentifier channel, Dictionary<string, object> bindings, bool debugMode) { string folderPath = Path.GetDirectoryName(formPath).ToLowerInvariant(); string fileName = Path.GetFileName(formPath).ToLowerInvariant(); List<IFormDefinitionFile> formFiles = (from file in DataFacade.GetData<IFormDefinitionFile>() where file.FolderPath.ToLowerInvariant() == folderPath && file.FileName.ToLowerInvariant() == fileName select file).ToList(); if (formFiles.Count == 0) throw new ArgumentException(string.Format("No form definition with path '{0}' was found. Please use a virtual Form Path", formPath), "formPath"); if (formFiles.Count > 1) throw new ArgumentException(string.Format("Multiple form definitions with path '{0}' was found", formPath), "formPath"); FormTreeCompiler compiler = new FormTreeCompiler(); using (XmlTextReader formMarkupReader = new XmlTextReader(formFiles[0].GetReadStream())) { compiler.Compile(formMarkupReader, channel, bindings, debugMode); return compiler; } }
public object CreateProducer(IFormChannelIdentifier channel, string namespaceName, string name) { switch (name) { case "if": return new IfProducer(); case "ifCondition": return new IfConditionProducer(); case "ifWhenTrue": return new IfWhenTrueProducer(); case "ifWhenFalse": return new IfWhenFalseProducer(); case "read": return new ReadProducer(); case "bind": return new BindProducer(); case "binding": return new BindingProducer(); case "bindings": return new BindingsProducer(); case "layout": return new LayoutProducer(); case "evalfunc": return new EvalFuncProducer(); } throw new NotImplementedException(string.Format("Unknown buildin producer type {0}", name)); }
public object CreateProducer(IFormChannelIdentifier channel, string namespaceName, string name) { switch (name) { case "if": return(new IfProducer()); case "ifCondition": return(new IfConditionProducer()); case "ifWhenTrue": return(new IfWhenTrueProducer()); case "ifWhenFalse": return(new IfWhenFalseProducer()); case "read": return(new ReadProducer()); case "bind": return(new BindProducer()); case "binding": return(new BindingProducer()); case "bindings": return(new BindingsProducer()); case "layout": return(new LayoutProducer()); case "evalfunc": return(new EvalFuncProducer()); } throw new NotImplementedException(string.Format("Unknown buildin producer type {0}", name)); }
public static IUiControl Render( string consoleId, string elementProviderName, FlowToken flowToken, FormFlowUiDefinition formFlowUiCommand, IFormChannelIdentifier channel, bool debugMode, FlowControllerServicesContainer servicesContainer) { FlowControllerServicesContainer formServicesContainer = new FlowControllerServicesContainer(servicesContainer); formServicesContainer.AddService(new FormFlowRenderingService()); formServicesContainer.AddService(new FormFlowWebRenderingService()); IFormMarkupProvider formMarkupProvider = formFlowUiCommand.MarkupProvider; IFormMarkupProvider customToolbarItemsMarkupProvider = formFlowUiCommand.CustomToolbarItemsMarkupProvider; Dictionary<string, object> innerFormBindings = formFlowUiCommand.BindingsProvider.GetBindings(); Dictionary<IFormEventIdentifier, FormFlowEventHandler> eventHandlers = formFlowUiCommand.EventHandlers; Dictionary<string, List<ClientValidationRule>> bindingsValidationRules = formFlowUiCommand.BindingsValidationRules; FormTreeCompiler formCompiler = new FormTreeCompiler(); IUiContainer renderingContainer = GetRenderingContainer(channel, formFlowUiCommand.UiContainerType); // Setting state related objects so the delegate below can access them "fresh" CurrentFormTreeCompiler = formCompiler; CurrentInnerFormBindings = innerFormBindings; CurrentControlContainer = (IWebUiContainer)renderingContainer; Dictionary<string, object> containerEventHandlerStubs = new Dictionary<string, object>(); foreach (IFormEventIdentifier eventIdentifier in eventHandlers.Keys) { IFormEventIdentifier localScopeEventIdentifier = eventIdentifier; // See: Local variable usage with anonymous methods within loop control structures EventHandler handlerStub = delegate(object sender, EventArgs e) { try { BaseEventHandler(consoleId, elementProviderName, flowToken, formFlowUiCommand, servicesContainer, eventHandlers, localScopeEventIdentifier, formServicesContainer); } catch (Exception ex) { formServicesContainer.GetService<IManagementConsoleMessageService>().ShowLogEntry(typeof(FormFlowUiDefinitionRenderer), ex); throw; } }; containerEventHandlerStubs.Add(eventIdentifier.BindingName, handlerStub); if (innerFormBindings.ContainsKey(eventIdentifier.BindingName)) { innerFormBindings.Remove(eventIdentifier.BindingName); } innerFormBindings.Add(eventIdentifier.BindingName, handlerStub); } XDocument document; using (XmlReader formMarkupReader = formMarkupProvider.GetReader()) { document = XDocument.Load(formMarkupReader); formMarkupReader.Close(); } formCompiler.Compile(document, channel, innerFormBindings, debugMode, "", bindingsValidationRules); IUiControl innerForm = formCompiler.UiControl; IUiControl customToolbarItems = null; if (customToolbarItemsMarkupProvider != null) { FormTreeCompiler toolbarCompiler = new FormTreeCompiler(); using (XmlReader formMarkupReader = customToolbarItemsMarkupProvider.GetReader()) { toolbarCompiler.Compile(formMarkupReader, channel, innerFormBindings, debugMode, bindingsValidationRules); } customToolbarItems = toolbarCompiler.UiControl; } CurrentControlTreeRoot = (IWebUiControl)innerForm; string label = formCompiler.Label; if(label.IsNullOrEmpty()) { label = formFlowUiCommand.ContainerLabel ?? ""; } string labelField = GetFormLabelField(document); ResourceHandle containerIcon = formCompiler.Icon; return renderingContainer.Render(formCompiler.UiControl, customToolbarItems, channel, containerEventHandlerStubs, label, labelField, containerIcon); }
public object CreateProducer(IFormChannelIdentifier channel, string namespaceName, string name) { return(UiControlFactoryPluginFacade.CreateControl(channel, namespaceName, name)); }
public static object CreateProducer(IFormChannelIdentifier channel, string namespaceName, string name) { return(GetProducerMediator(namespaceName).CreateProducer(channel, namespaceName, name)); }
public static IUiControl CreateControl(IFormChannelIdentifier channel, string namespaceName, string name) { return(UiControlFactoryPluginFacade.CreateControl(channel, namespaceName, name)); }
public object CreateProducer(IFormChannelIdentifier channel, string namespaceName, string name) { return(FunctionFactoryPluginFacade.GetFunction(namespaceName, name)); }
/// <exclude /> public static FormTreeCompiler BuildWidgetForParameters(IEnumerable <ParameterProfile> parameterProfiles, Dictionary <string, object> bindings, string uniqueName, string panelLabel, IFormChannelIdentifier channelIdentifier) { XNamespace stdControlLibSpace = Namespaces.BindingFormsStdUiControls10; var bindingsDeclaration = new XElement(Namespaces.BindingForms10 + "bindings"); var widgetPlaceholder = new XElement(stdControlLibSpace + "FieldGroup", new XAttribute("Label", panelLabel)); var bindingsValidationRules = new Dictionary <string, List <ClientValidationRule> >(); foreach (ParameterProfile parameterProfile in parameterProfiles.Where(f => f.WidgetFunction != null)) { IWidgetFunction widgetFunction = parameterProfile.WidgetFunction; Type bindingType = widgetFunction != null && parameterProfile.Type.IsLazyGenericType() ? widgetFunction.ReturnType : parameterProfile.Type; bindingsDeclaration.Add( new XElement(Namespaces.BindingForms10 + "binding", new XAttribute("optional", true), new XAttribute("name", parameterProfile.Name), new XAttribute("type", bindingType.AssemblyQualifiedName))); var context = new FunctionContextContainer(); XElement uiMarkup = FunctionFacade.GetWidgetMarkup(widgetFunction, parameterProfile.Type, parameterProfile.WidgetFunctionParameters, parameterProfile.Label, parameterProfile.HelpDefinition, parameterProfile.Name, context); widgetPlaceholder.Add(uiMarkup); if (!bindings.ContainsKey(parameterProfile.Name)) { bindings.Add(parameterProfile.Name, ""); } if (parameterProfile.IsRequired) { bindingsValidationRules.Add(parameterProfile.Name, new List <ClientValidationRule> { new NotNullClientValidationRule() }); } } FormDefinition widgetFormDefinition = BuildFormDefinition(bindingsDeclaration, widgetPlaceholder, bindings); var compiler = new FormTreeCompiler(); using (XmlReader reader = widgetFormDefinition.FormMarkup) { compiler.Compile(reader, channelIdentifier, widgetFormDefinition.Bindings, false, "WidgetParameterSetters" + uniqueName, bindingsValidationRules); } return(compiler); }
/// <exclude /> public WebEmbeddedFormUiControl(IFormChannelIdentifier channel) { this.UiControlChannel = channel; }
public static object CreateProducer(IFormChannelIdentifier channel, string namespaceName, string name) { return GetProducerMediator(namespaceName).CreateProducer(channel, namespaceName, name); }
/// <exclude /> public void Compile(XmlReader reader, IFormChannelIdentifier channel, Dictionary <string, object> bindingObjects, bool withDebug, string customControlIdPrefix) { Compile(reader, channel, bindingObjects, withDebug, customControlIdPrefix, null); }
/// <exclude /> public void Compile(XmlReader reader, IFormChannelIdentifier channel, Dictionary<string, object> bindingObjects, bool withDebug, string customControlIdPrefix) { Compile(reader, channel, bindingObjects, withDebug, customControlIdPrefix, null); }
public object CreateProducer(IFormChannelIdentifier channel, string namespaceName, string name) { return FunctionFactoryPluginFacade.GetFunction(namespaceName, name); }
/// <exclude /> public void Compile(XmlReader reader, IFormChannelIdentifier channel, Dictionary<string, object> bindingObjects, bool withDebug) { Compile(reader, channel, bindingObjects, withDebug, "", null); }
/// <exclude /> public void Compile(XmlReader reader, IFormChannelIdentifier channel, Dictionary<string, object> bindingObjects) { Compile(reader, channel, bindingObjects, false, "", null); }
/// <exclude /> public void Compile(XmlReader reader, IFormChannelIdentifier channel, Dictionary <string, object> bindingObjects, bool withDebug, Dictionary <string, List <ClientValidationRule> > bindingsValidationRules) { Compile(reader, channel, bindingObjects, withDebug, "", bindingsValidationRules); }
public static IUiControl CreateControl(IFormChannelIdentifier channel, string namespaceName, string name) { return UiControlFactoryPluginFacade.CreateControl(channel, namespaceName, name); }
/// <exclude /> public void Compile(XmlReader reader, IFormChannelIdentifier channel, Dictionary <string, object> bindingObjects, bool withDebug) { Compile(reader, channel, bindingObjects, withDebug, "", null); }
/// <exclude /> public static FormTreeCompiler AttachAndCompileParameterWidgets(Control attachmentControl, IEnumerable <ParameterProfile> parameterProfiles, Dictionary <string, object> bindings, string uniqueName, string panelLabel, IFormChannelIdentifier channelIdentifier, bool reset) { FormTreeCompiler compiler = FunctionUiHelper.BuildWidgetForParameters(parameterProfiles, bindings, uniqueName, panelLabel, channelIdentifier); IWebUiControl webUiControl = (IWebUiControl)compiler.UiControl; Control form = webUiControl.BuildWebControl(); attachmentControl.Controls.Add(form); if (reset) { webUiControl.InitializeViewState(); } return(compiler); }
/// <exclude /> public void Compile(XmlReader reader, IFormChannelIdentifier channel, Dictionary <string, object> bindingObjects) { Compile(reader, channel, bindingObjects, false, "", null); }
public static IUiControl Render( string consoleId, string elementProviderName, FlowToken flowToken, FormFlowUiDefinition formFlowUiCommand, IFormChannelIdentifier channel, bool debugMode, FlowControllerServicesContainer servicesContainer) { FlowControllerServicesContainer formServicesContainer = new FlowControllerServicesContainer(servicesContainer); formServicesContainer.AddService(new FormFlowRenderingService()); formServicesContainer.AddService(new FormFlowWebRenderingService()); IFormMarkupProvider formMarkupProvider = formFlowUiCommand.MarkupProvider; IFormMarkupProvider customToolbarItemsMarkupProvider = formFlowUiCommand.CustomToolbarItemsMarkupProvider; Dictionary <string, object> innerFormBindings = formFlowUiCommand.BindingsProvider.GetBindings(); Dictionary <IFormEventIdentifier, FormFlowEventHandler> eventHandlers = formFlowUiCommand.EventHandlers; Dictionary <string, List <ClientValidationRule> > bindingsValidationRules = formFlowUiCommand.BindingsValidationRules; FormTreeCompiler formCompiler = new FormTreeCompiler(); IUiContainer renderingContainer = GetRenderingContainer(channel, formFlowUiCommand.UiContainerType); // Setting state related objects so the delegate below can access them "fresh" CurrentFormTreeCompiler = formCompiler; CurrentInnerFormBindings = innerFormBindings; CurrentControlContainer = (IWebUiContainer)renderingContainer; Dictionary <string, object> containerEventHandlerStubs = new Dictionary <string, object>(); foreach (IFormEventIdentifier eventIdentifier in eventHandlers.Keys) { IFormEventIdentifier localScopeEventIdentifier = eventIdentifier; // See: Local variable usage with anonymous methods within loop control structures EventHandler handlerStub = delegate(object sender, EventArgs e) { try { BaseEventHandler(consoleId, elementProviderName, flowToken, formFlowUiCommand, servicesContainer, eventHandlers, localScopeEventIdentifier, formServicesContainer); } catch (Exception ex) { formServicesContainer.GetService <IManagementConsoleMessageService>().ShowLogEntry(typeof(FormFlowUiDefinitionRenderer), ex); throw; } }; containerEventHandlerStubs.Add(eventIdentifier.BindingName, handlerStub); if (innerFormBindings.ContainsKey(eventIdentifier.BindingName)) { innerFormBindings.Remove(eventIdentifier.BindingName); } innerFormBindings.Add(eventIdentifier.BindingName, handlerStub); } XDocument document; using (XmlReader formMarkupReader = formMarkupProvider.GetReader()) { document = XDocument.Load(formMarkupReader); formMarkupReader.Close(); } formCompiler.Compile(document, channel, innerFormBindings, debugMode, "", bindingsValidationRules); IUiControl innerForm = formCompiler.UiControl; IUiControl customToolbarItems = null; if (customToolbarItemsMarkupProvider != null) { var toolbarCompiler = new FormTreeCompiler(); CurrentCustomToolbarFormTreeCompiler = toolbarCompiler; using (XmlReader formMarkupReader = customToolbarItemsMarkupProvider.GetReader()) { toolbarCompiler.Compile(formMarkupReader, channel, innerFormBindings, debugMode, bindingsValidationRules); } customToolbarItems = toolbarCompiler.UiControl; } CurrentControlTreeRoot = (IWebUiControl)innerForm; string label = formCompiler.Label; if (label.IsNullOrEmpty()) { label = formFlowUiCommand.ContainerLabel ?? ""; } string labelField = GetFormLabelField(document); ResourceHandle containerIcon = formCompiler.Icon; return(renderingContainer.Render(formCompiler.UiControl, customToolbarItems, channel, containerEventHandlerStubs, label, labelField, formCompiler.Tooltip, containerIcon)); }
public object CreateProducer(IFormChannelIdentifier channel, string namespaceName, string name) { return UiControlFactoryPluginFacade.CreateControl(channel, namespaceName, name); }
private static IUiContainer GetRenderingContainer(IFormChannelIdentifier channel, IFlowUiContainerType containerIdentifier) { return(UiContainerFactoryFactoryPluginFacade.CreateContainer(channel, containerIdentifier)); }
public static void InsertForm(Control control, ParameterList parameters) { Page currentPageHandler = HttpContext.Current.Handler as Page; if (currentPageHandler == null) { throw new InvalidOperationException("The Current HttpContext Handler must be a System.Web.Ui.Page"); } Type dataType = null; DataTypeDescriptor dataTypeDescriptor = null; string dataTypeName = parameters.GetParameter <string>("DataType"); dataType = TypeManager.GetType(dataTypeName); dataTypeDescriptor = DynamicTypeManager.GetDataTypeDescriptor(dataType); IFormChannelIdentifier channelIdentifier = FormsRendererChannel.Identifier; formHelper = new DataTypeDescriptorFormsHelper(dataTypeDescriptor); newData = DataFacade.BuildNew(dataType); GeneratedTypesHelper.SetNewIdFieldValue(newData); //Hide not editable fields, fox example - PageId GeneratedTypesHelper generatedTypesHelper = new GeneratedTypesHelper(dataTypeDescriptor); formHelper.AddReadOnlyFields(generatedTypesHelper.NotEditableDataFieldDescriptorNames); //If is Page Datatype if (PageFolderFacade.GetAllFolderTypes().Contains(dataType)) { IPage currentPage = PageRenderer.CurrentPage; if (currentPage.GetDefinedFolderTypes().Contains(dataType) == false) { currentPage.AddFolderDefinition(dataType.GetImmutableTypeId()); } PageFolderFacade.AssignFolderDataSpecificValues(newData, currentPage); } _compiler = new FormTreeCompiler(); //bindings = formHelper.GetBindings(newData); bindings = new Dictionary <string, object>(); formHelper.UpdateWithNewBindings(bindings); formHelper.ObjectToBindings(newData, bindings); using (XmlReader reader = XDocument.Parse(formHelper.GetForm()).CreateReader()) { try { _compiler.Compile(reader, channelIdentifier, bindings, formHelper.GetBindingsValidationRules(newData)); #region ClientValidationRules clientValidationRules = new Dictionary <string, List <ClientValidationRule> >(); foreach (var item in _compiler.GetField <object>("_context").GetProperty <IEnumerable>("Rebindings")) { var SourceProducer = item.GetProperty <object>("SourceProducer"); var uiControl = SourceProducer as IWebUiControl; if (uiControl != null) { clientValidationRules[uiControl.UiControlID] = uiControl.ClientValidationRules; } } #endregion } catch (ConfigurationErrorsException e) { if (e.Message.Contains("Failed to load the configuration for IUiControlFactory")) { throw new ConfigurationErrorsException("Composite.Forms.Renderer does not support widget. " + e.Message); } else { throw new ConfigurationErrorsException(e.Message); } } } webUiControl = (IWebUiControl)_compiler.UiControl; Control form = webUiControl.BuildWebControl(); control.Controls.Add(form); /*if (currentPageHandler.IsPostBack) * try * { * compiler.SaveControlProperties(); * } * catch { }*/ if (!currentPageHandler.IsPostBack) { webUiControl.InitializeViewState(); } return; }
private static IUiContainer GetRenderingContainer(IFormChannelIdentifier channel, IFlowUiContainerType containerIdentifier) { return UiContainerFactoryFactoryPluginFacade.CreateContainer(channel, containerIdentifier); }
/// <exclude /> public void Compile(XmlReader reader, IFormChannelIdentifier channel, Dictionary<string, object> bindingObjects, bool withDebug, Dictionary<string, List<ClientValidationRule>> bindingsValidationRules) { Compile(reader, channel, bindingObjects, withDebug, "", bindingsValidationRules); }
/// <exclude /> public static XDocument GenerateUiControlSchema(IFormChannelIdentifier channelIdentifier, XNamespace controlNamespace) { Dictionary<XNamespace, XDocument> schemas = new Dictionary<XNamespace, XDocument>(); ElementInformationExtractor worker = new ElementInformationExtractor(ConfigurationServices.FileConfigurationSourcePath); var elementDescriptors = from descriptor in worker.GetUiControlDescriptors() where descriptor.ChannelName == channelIdentifier.ChannelName && descriptor.NamespaceName == controlNamespace select descriptor; return worker.GetXsd(elementDescriptors, controlNamespace); }