public void CreateProducers(CompileTreeNode node) { if (node is ElementCompileTreeNode) { ElementCompileTreeNode element = node as ElementCompileTreeNode; if ((CompilerGlobals.IsProducerTag(element)) || (CompilerGlobals.IsReadTag(element)) || (CompilerGlobals.IsBindTag(element)) || (CompilerGlobals.IsBindingTag(element)) || (CompilerGlobals.IsLayoutTag(element))) { element.Producer = ProducerMediatorPluginFacade.CreateProducer(_compileContext.CurrentChannel, element.XmlSourceNodeInformation.NamespaceURI, element.XmlSourceNodeInformation.Name); if (element.Producer is IUiControl) { (element.Producer as IUiControl).UiControlID = _compileContext.GetNextControlId(element.XmlSourceNodeInformation.Name); } } else if (CompilerGlobals.IsBindingsTag(element)) { if (null == _compileContext.BindingsProducer) { _compileContext.BindingsProducer = ProducerMediatorPluginFacade.CreateProducer(_compileContext.CurrentChannel, element.XmlSourceNodeInformation.NamespaceURI, element.XmlSourceNodeInformation.Name); } element.Producer = _compileContext.BindingsProducer; } } foreach (CompileTreeNode subNode in node.AllSubNodes) { CreateProducers(subNode); } }
private ElementCompileTreeNode HandleProducerElement(ElementCompileTreeNode element, List <PropertyCompileTreeNode> newProperties, string defaultOverloadPropertyName) { PropertyAssigner.AssignPropertiesToProducer(element, _compileContext); string replacingPropertyName = CompilerGlobals.DefaultPropertyName; if (defaultOverloadPropertyName != null) { replacingPropertyName = defaultOverloadPropertyName; } var replacingProperty = new PropertyCompileTreeNode(replacingPropertyName, element.XmlSourceNodeInformation); object result = ProducerMediatorPluginFacade.EvaluateProducer(element.XmlSourceNodeInformation.NamespaceURI, element.Producer); if (result is BindingProducer) { var bindingProducer = (BindingProducer)result; if (string.IsNullOrEmpty(bindingProducer.name)) { throw new FormCompileException("A binding declaraions is missing its name attribute", element.XmlSourceNodeInformation); } if (!_compileContext.RegistarBindingName(bindingProducer.name)) { throw new FormCompileException(string.Format("Name binding name {0} is used twice which is not allowed", bindingProducer.name), element.XmlSourceNodeInformation); } //if (_compileContext.GetBindingObject(bindingProducer.name) == null && !bindingProducer.optional) //{ // throw new FormCompileException(string.Format("The non optional binding {0} is missing its binding value", bindingProducer.name), element.XmlSourceNodeInformation); //} Type type = TypeManager.GetType(bindingProducer.type); _compileContext.SetBindingType(bindingProducer.name, type); } else if (_withDebug && result is IUiControl) { IUiControl uiControl = result as IUiControl; string debugControlNamespace; string debugControlName; UiControlFactoryPluginFacade.GetDebugControlName(_compileContext.CurrentChannel, out debugControlNamespace, out debugControlName); DebugUiControl debug = ProducerMediatorPluginFacade.CreateProducer(_compileContext.CurrentChannel, debugControlNamespace, debugControlName) as DebugUiControl; debug.UiControlID = _compileContext.GetNextDebugControlId; debug.UiControl = uiControl; result = debug; debug.UiControlID = uiControl.UiControlID; debug.TagName = element.XmlSourceNodeInformation.TagName; debug.SourceElementXPath = element.XmlSourceNodeInformation.XPath; foreach (CompileContext.IRebinding rd in _compileContext.Rebindings) { if (ReferenceEquals(uiControl, rd.SourceProducer)) { debug.Bindings.Add(new DebugUiControl.BindingInformation( rd.BindingObjectName, rd.DestinationObjectType, rd.PropertyName)); } } } replacingProperty.Value = result; newProperties.Add(replacingProperty); return(null); }