예제 #1
0
        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);
            }
        }
예제 #2
0
        /// <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 void GetSplittedPropertyNameFromCompositeName(CompileTreeNode node, out string producerName, out string propertyName)
        {
            string[] split = node.XmlSourceNodeInformation.Name.Split('.');
            if (2 != split.Length)
            {
                throw new FormCompileException("Wrong tag format", node.XmlSourceNodeInformation);
            }

            producerName = split[0];
            propertyName = split[1];
        }
예제 #4
0
        public void ExtractUiArtifacts(CompileTreeNode node, out IUiControl uiControl, out string label, out string iconhandle)
        {
            foreach (PropertyCompileTreeNode n in node.DefaultProperties)
            {
                if (n.Value is LayoutProducer)
                {
                    LayoutProducer lp = (n.Value as LayoutProducer);
                    uiControl  = lp.UiControl;
                    label      = lp.label;
                    iconhandle = lp.iconhandle;

                    return;
                }
            }

            throw new FormCompileException("No layout defined in the source file", node.XmlSourceNodeInformation);
        }
        public static bool IsProducerTag(CompileTreeNode node)
        {
            ElementCompileTreeNode element = node as ElementCompileTreeNode;

            if (null == element)
            {
                return(false);
            }

            if (IsElementEmbeddedProperty(element))
            {
                return(false);
            }
            if (IsReadTag(element))
            {
                return(false);
            }
            if (IsBindTag(element))
            {
                return(false);
            }
            if (IsBindingTag(element))
            {
                return(false);
            }
            if (IsBindingsTag(element))
            {
                return(false);
            }
            if (IsLayoutTag(element))
            {
                return(false);
            }
            if (IsFormDefinitionTag(element))
            {
                return(false);
            }

            return(true);
        }
 public FormCompileException(string message, CompileTreeNode treeNode, CompileTreeNode propertyTreeNode)
     : this(message, treeNode.XmlSourceNodeInformation, propertyTreeNode.XmlSourceNodeInformation)
 {
 }
 public CompileTreeNode Evaluate(CompileTreeNode node)
 {
     return(Evaluate(node as ElementCompileTreeNode, null));
 }
예제 #8
0
 public void UpdateInformation(CompileTreeNode startNode)
 {
     UpdateInformation(startNode, "", null);
 }
예제 #9
0
        private void UpdateInformation(CompileTreeNode node, string currentXPath, int?childNumber)
        {
            if (childNumber.HasValue)
            {
                currentXPath = string.Format("{0}/{1}[{2}]", currentXPath, node.XmlSourceNodeInformation.TagName, childNumber.Value);
            }
            else
            {
                currentXPath = string.Format("{0}/{1}", currentXPath, node.XmlSourceNodeInformation.TagName);
            }

            node.XmlSourceNodeInformation.XPath = currentXPath;

            Dictionary <string, int> tagOccursCount = new Dictionary <string, int>();
            Dictionary <string, int> xPathCounter   = new Dictionary <string, int>();

            foreach (CompileTreeNode child in node.Children)
            {
                if (false == tagOccursCount.ContainsKey(child.XmlSourceNodeInformation.Name))
                {
                    tagOccursCount.Add(child.XmlSourceNodeInformation.Name, 0);
                }

                tagOccursCount[child.XmlSourceNodeInformation.Name]++;
            }

            foreach (CompileTreeNode child in node.Children)
            {
                if (tagOccursCount[child.XmlSourceNodeInformation.Name] > 1)
                {
                    if (false == xPathCounter.ContainsKey(child.XmlSourceNodeInformation.Name))
                    {
                        xPathCounter.Add(child.XmlSourceNodeInformation.Name, 1);
                    }

                    UpdateInformation(child, currentXPath, xPathCounter[child.XmlSourceNodeInformation.Name]++);
                }
                else
                {
                    UpdateInformation(child, currentXPath, null);
                }
            }

            foreach (PropertyCompileTreeNode nameProperty in node.AllNamedProperties)
            {
                nameProperty.XmlSourceNodeInformation.NamespaceURI = node.XmlSourceNodeInformation.NamespaceURI;

                UpdateInformation(nameProperty, currentXPath, null);
            }

            if (node.DefaultProperties.Count == 1)
            {
                node.DefaultProperties[0].XmlSourceNodeInformation.NamespaceURI = node.XmlSourceNodeInformation.NamespaceURI;

                UpdateInformation(node.DefaultProperties[0], currentXPath, null);
            }
            else if (node.DefaultProperties.Count > 1)
            {
                int counter = 1;
                foreach (CompileTreeNode defaultProperty in node.DefaultProperties)
                {
                    defaultProperty.XmlSourceNodeInformation.NamespaceURI = node.XmlSourceNodeInformation.NamespaceURI;

                    UpdateInformation(defaultProperty, currentXPath, counter++);
                }
            }
        }