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 HandleEmbeddedProperty(ElementCompileTreeNode element, List <PropertyCompileTreeNode> newProperties) { if (element.NamedProperties.Count > 0) { throw new FormCompileException("Attrbute not allow on embedded properties", element.XmlSourceNodeInformation); } string producerName; string propertyName; CompilerGlobals.GetSplittedPropertyNameFromCompositeName(element, out producerName, out propertyName); foreach (PropertyCompileTreeNode property in element.DefaultProperties) { var replacingProperty = new PropertyCompileTreeNode(propertyName, element.XmlSourceNodeInformation) { Value = property.Value, InclosingProducerName = producerName }; newProperties.Add(replacingProperty); } return(null); }
public ElementCompileTreeNode EvaluateElementCompileTreeNode(ElementCompileTreeNode element, List <PropertyCompileTreeNode> newProperties, string defaultOverloadPropertyName) { if (CompilerGlobals.IsElementEmbeddedProperty(element)) { return(HandleEmbeddedProperty(element, newProperties)); } if (element.Producer == null) { return(element); } if (element.Producer is IfProducer) { return(HandleIfProducerElement(element, newProperties)); } return(HandleProducerElement(element, newProperties, defaultOverloadPropertyName)); }
private ElementCompileTreeNode HandleIfProducerElement(ElementCompileTreeNode element, List <PropertyCompileTreeNode> newProperties) { ElementCompileTreeNode conditionElement = null; ElementCompileTreeNode whenTrueElement = null; ElementCompileTreeNode whenFalseElement = null; foreach (ElementCompileTreeNode child in element.Children) { if (CompilerGlobals.IsElementIfConditionTag(child)) { conditionElement = child; } if (CompilerGlobals.IsElementIfWhenTrueTag(child)) { whenTrueElement = child; } if (CompilerGlobals.IsElementIfWhenFalseTag(child)) { whenFalseElement = child; } } if (conditionElement == null) { throw new FormCompileException(string.Format("Missing condition tag ({0})", CompilerGlobals.IfCondition_TagName), element.XmlSourceNodeInformation); } if (whenTrueElement == null) { throw new FormCompileException(string.Format("Missing when true tag ({0})", CompilerGlobals.IfWhenTrue_TagName), element.XmlSourceNodeInformation); } var newConditionProperties = new List <PropertyCompileTreeNode>(); Evaluate(conditionElement, newConditionProperties); var conditionProducer = (IfConditionProducer)newConditionProperties[0].Value; object value; if (conditionProducer.Condition) { var newWhenTrueProperties = new List <PropertyCompileTreeNode>(); Evaluate(whenTrueElement, newWhenTrueProperties); var whenTrueProducer = (IfWhenTrueProducer)newWhenTrueProperties[0].Value; if (whenTrueProducer.Result.Count == 1) { value = whenTrueProducer.Result[0]; } else { value = whenTrueProducer.Result; } } else if (whenFalseElement != null) { var newWhenFalseProperties = new List <PropertyCompileTreeNode>(); Evaluate(whenFalseElement, newWhenFalseProperties); var whenFalseProducer = (IfWhenFalseProducer)newWhenFalseProperties[0].Value; if (whenFalseProducer.Result.Count == 1) { value = whenFalseProducer.Result[0]; } else { value = whenFalseProducer.Result; } } else { return(null); } var replacingProperty = new PropertyCompileTreeNode(CompilerGlobals.DefaultPropertyName, element.XmlSourceNodeInformation); replacingProperty.Value = value; newProperties.Add(replacingProperty); return(null); }