private object TryExecuteFunction(XElement functionNode)
        {
            try
            {
                var tree = FunctionFacade.BuildTree(functionNode);

                using (new FakeHttpContext())
                {
                    if (_page != null)
                    {
                        PageRenderer.CurrentPage = _page;
                        C1PageRoute.PageUrlData  = new PageUrlData(_page);
                    }
                    PageRenderer.RenderingReason = RenderingReason.BuildSearchIndex;

                    return(tree.GetValue(new FunctionContextContainer
                    {
                        SuppressXhtmlExceptions = false
                    }));
                }
            }
            catch (Exception)
            {
                return(null);
            }
        }
Esempio n. 2
0
        public static IEnumerable GetOptions(string optionsDescriptorSerialized)
        {
            XElement optionsDescriptor = XElement.Parse(optionsDescriptorSerialized);

            string              keyFieldName    = optionsDescriptor.Attribute("KeyFieldName").Value;
            string              labelFieldName  = optionsDescriptor.Attribute("LabelFieldName").Value;
            XElement            treeNodeElement = optionsDescriptor.Element("TreeNode").Elements().First();
            BaseRuntimeTreeNode runtimeTreeNode = FunctionFacade.BuildTree(treeNodeElement);

            IEnumerable optionsSource = runtimeTreeNode.GetValue <IEnumerable>();

            if (optionsSource is IEnumerable <XElement> )
            {
                IEnumerable <XElement> optionElements = (IEnumerable <XElement>)optionsSource;
                foreach (XElement optionElement in optionElements)
                {
                    yield return(new
                    {
                        Key = optionElement.Attribute(keyFieldName).Value,
                        Label = optionElement.Attribute(labelFieldName).Value
                    });
                }
            }
            else if (optionsSource is IDictionary)
            {
                IDictionary optionsDictionary = (IDictionary)optionsSource;
                foreach (var optionKey in optionsDictionary.Keys)
                {
                    yield return(new { Key = optionKey, Label = optionsDictionary[optionKey] });
                }
            }
            else if (string.IsNullOrEmpty(keyFieldName) == false || string.IsNullOrEmpty(labelFieldName))
            {
                foreach (object optionObject in optionsSource)
                {
                    if (optionObject != null)
                    {
                        Type objectType = optionObject.GetType();

                        string key = (string.IsNullOrEmpty(keyFieldName) ?
                                      optionObject.ToString() :
                                      objectType.GetProperty(keyFieldName).GetValue(optionObject, null).ToString());

                        string label = (string.IsNullOrEmpty(labelFieldName) ?
                                        optionObject.ToString() :
                                        objectType.GetProperty(labelFieldName).GetValue(optionObject, null).ToString());

                        yield return(new { Key = key, Label = label });
                    }
                }
            }
            else
            {
                foreach (var option in optionsSource)
                {
                    yield return(new { Key = option, Label = option });
                }
            }
        }
        public static void SetDefaultValues(IModelInstance instance)
        {
            var def = GetFormByName(instance.Name);

            foreach (var field in instance.Fields)
            {
                if (!def.DefaultValues.TryGetValue(field.Name, out var defaultValueSetter))
                {
                    continue;
                }

                var runtimeTree = FunctionFacade.BuildTree(defaultValueSetter);

                field.Value = runtimeTree.GetValue();
            }
        }
Esempio n. 4
0
        private void initalizeStateCodeActivity_Initialize_ExecuteCode(object sender, EventArgs e)
        {
            List <NamedFunctionCall> namedFunctionCalls = new List <NamedFunctionCall>();

            if (Payload != "")
            {
                IFunction function = FunctionFacade.GetFunction(Payload);

                BaseRuntimeTreeNode baseRuntimeTreeNode = FunctionFacade.BuildTree(function, new Dictionary <string, object>());

                NamedFunctionCall namedFunctionCall = new NamedFunctionCall("", (BaseFunctionRuntimeTreeNode)baseRuntimeTreeNode);

                namedFunctionCalls.Add(namedFunctionCall);

                string layoutLabel = string.Format(StringResourceSystemFacade.GetString("Composite.Plugins.AllFunctionsElementProvider", "FunctionTesterWorkflow.Layout.Label"), function.Name);
                this.Bindings.Add("LayoutLabel", layoutLabel);
            }

            this.Bindings.Add("FunctionCalls", namedFunctionCalls);
            this.Bindings.Add("Parameters", new List <ManagedParameterDefinition>());
            this.Bindings.Add("PageId", PageManager.GetChildrenIDs(Guid.Empty).FirstOrDefault());

            if (UserSettings.ActiveLocaleCultureInfo != null)
            {
                List <KeyValuePair <string, string> > activeCulturesDictionary = UserSettings.ActiveLocaleCultureInfos.Select(f => new KeyValuePair <string, string>(f.Name, DataLocalizationFacade.GetCultureTitle(f))).ToList();
                this.Bindings.Add("ActiveCultureName", UserSettings.ActiveLocaleCultureInfo.Name);
                this.Bindings.Add("ActiveCulturesList", activeCulturesDictionary);
            }

            this.Bindings.Add("PageDataScopeName", DataScopeIdentifier.AdministratedName);
            this.Bindings.Add("PageDataScopeList", new Dictionary <string, string>
            {
                { DataScopeIdentifier.AdministratedName, StringResourceSystemFacade.GetString("Composite.Plugins.AllFunctionsElementProvider", "FunctionTesterWorkflow.AdminitrativeScope.Label") },
                { DataScopeIdentifier.PublicName, StringResourceSystemFacade.GetString("Composite.Plugins.AllFunctionsElementProvider", "FunctionTesterWorkflow.PublicScope.Label") }
            });


            Guid stateId = Guid.NewGuid();
            var  state   = new FunctionCallDesignerState {
                WorkflowId = WorkflowInstanceId, ConsoleIdInternal = GetCurrentConsoleId()
            };

            SessionStateManager.DefaultProvider.AddState <IFunctionCallEditorState>(stateId, state, DateTime.Now.AddDays(7.0));

            this.Bindings.Add("SessionStateProvider", SessionStateManager.DefaultProviderName);
            this.Bindings.Add("SessionStateId", stateId);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="targetType"></param>
        /// <returns></returns>
        /// <exclude />
        protected override Validator DoCreateValidator(Type targetType)
        {
            try
            {
                BaseRuntimeTreeNode node = FunctionFacade.BuildTree(XElement.Parse(FunctionMarkup));

                IPropertyValidatorBuilder propertyValidatorBuilder = node.GetValue <IPropertyValidatorBuilder>();

                ValidatorAttribute validatorAttribute = (ValidatorAttribute)propertyValidatorBuilder.GetAttribute();

                Validator validator = (Validator)DoCreateValidatorMethodInfo.Invoke(validatorAttribute, new object[] { targetType });

                return(validator);
            }
            catch (Exception ex)
            {
                string message = string.Format("Validator function markup parse / execution failed with the following error: '{0}'. The validator attribute is dropped.", ex.Message);
                Log.LogError("LazyFunctionProviedPropertyAttribute", message);
            }

            return(new LazyFunctionProviedPropertyValidator());
        }
Esempio n. 6
0
        protected string GetCurrentlySelectedDefaultValueText()
        {
            if (!String.IsNullOrEmpty(btnDefaultValueFunctionMarkup.Value))
            {
                try
                {
                    var functionElement = XElement.Parse(btnDefaultValueFunctionMarkup.Value);
                    if (functionElement.Name.Namespace != Namespaces.Function10)
                    {
                        functionElement = functionElement.Elements().First();
                    }

                    var widgetNode = (BaseFunctionRuntimeTreeNode)FunctionFacade.BuildTree(functionElement);

                    return(widgetNode.GetName());
                }
                catch (Exception ex)
                {
                    Log.LogError("TypeFieldDesigner", String.Format("Widget settings reset. Existing widget failed to validate with the following message: '{0}'", ex.Message));
                }
            }

            return("(no default value)");
        }
        private void editCodeActivity_Preview_ExecuteCode(object sender, EventArgs e)
        {
            IInlineFunction functionInfo       = this.GetBinding <IInlineFunction>("Function");
            string          code               = this.GetBinding <string>("FunctionCode");
            List <string>   selectedAssemblies = this.GetBinding <List <string> >("SelectedAssemblies");

            StringInlineFunctionCreateMethodErrorHandler handler = new StringInlineFunctionCreateMethodErrorHandler();

            MethodInfo methodInfo = InlineFunctionHelper.Create(functionInfo, code, handler, selectedAssemblies);

            FlowControllerServicesContainer serviceContainer            = WorkflowFacade.GetFlowControllerServicesContainer(WorkflowEnvironment.WorkflowInstanceId);
            IFormFlowWebRenderingService    formFlowWebRenderingService = serviceContainer.GetService <IFormFlowWebRenderingService>();

            if (handler.HasErrors)
            {
                StringBuilder sb = new StringBuilder();

                if (!string.IsNullOrWhiteSpace(handler.MissingContainerType))
                {
                    AddFormattedTextBlock(sb, handler.MissingContainerType);
                }

                if (!string.IsNullOrWhiteSpace(handler.NamespaceMismatch))
                {
                    AddFormattedTextBlock(sb, handler.NamespaceMismatch);
                }

                if (!string.IsNullOrWhiteSpace(handler.MissionMethod))
                {
                    AddFormattedTextBlock(sb, handler.MissionMethod);
                }

                if (handler.LoadingException != null)
                {
                    AddFormattedTextBlock(sb, handler.LoadingException.ToString());
                }

                foreach (Tuple <int, string, string> compileError in handler.CompileErrors)
                {
                    AddFormattedTextBlock(sb, "{0} : {1} : {2}".FormatWith(compileError.Item1, compileError.Item2, compileError.Item3));
                }

                formFlowWebRenderingService.SetNewPageOutput(new LiteralControl(sb.ToString()));

                return;
            }

            List <ManagedParameterDefinition> parameters = this.GetBinding <List <ManagedParameterDefinition> >("Parameters");

            List <object> parameterValues        = new List <object>();
            bool          parameterErrors        = false;
            StringBuilder parameterErrorMessages = new StringBuilder();

            foreach (ParameterInfo parameterInfo in methodInfo.GetParameters())
            {
                ManagedParameterDefinition parameter = parameters.FirstOrDefault(f => f.Name == parameterInfo.Name);
                if (parameter == null)
                {
                    string message = string.Format(GetText("CSharpInlineFunction.MissingParameterDefinition"), parameterInfo.Name);

                    parameterErrors = true;
                    AddFormattedTextBlock(parameterErrorMessages, message);
                }
                else if (parameter.Type != parameterInfo.ParameterType)
                {
                    string message = string.Format(GetText("CSharpInlineFunction.WrongParameterTestValueType"), parameterInfo.Name, parameterInfo.ParameterType, parameter.Type);

                    parameterErrors = true;
                    AddFormattedTextBlock(parameterErrorMessages, message);
                }
                else
                {
                    string previewValueFunctionMarkup = (string.IsNullOrEmpty(parameter.TestValueFunctionMarkup) ? parameter.DefaultValueFunctionMarkup : parameter.TestValueFunctionMarkup);

                    if (string.IsNullOrEmpty(previewValueFunctionMarkup))
                    {
                        string message = string.Format(GetText("CSharpInlineFunction.MissingParameterTestOrDefaultValue"), parameterInfo.Name, parameterInfo.ParameterType, parameter.Type);

                        parameterErrors = true;
                        AddFormattedTextBlock(parameterErrorMessages, message);
                    }
                    else
                    {
                        try
                        {
                            BaseRuntimeTreeNode treeNode = FunctionFacade.BuildTree(XElement.Parse(previewValueFunctionMarkup));
                            object value      = treeNode.GetValue();
                            object typedValue = ValueTypeConverter.Convert(value, parameter.Type);
                            parameterValues.Add(typedValue);
                        }
                        catch (Exception ex)
                        {
                            string message = string.Format("Error setting '{0}'. {1}", parameterInfo.Name, ex.Message);

                            parameterErrors = true;
                            AddFormattedTextBlock(parameterErrorMessages, message);
                        }
                    }
                }
            }

            if (parameterErrors)
            {
                formFlowWebRenderingService.SetNewPageOutput(new LiteralControl(parameterErrorMessages.ToString()));
                return;
            }

            CultureInfo oldCurrentCulture   = Thread.CurrentThread.CurrentCulture;
            CultureInfo oldCurrentUICulture = Thread.CurrentThread.CurrentUICulture;

            try
            {
                Guid pageId;
                if (this.GetBinding <object>("PageId") == null)
                {
                    pageId = Guid.Empty;
                }
                else
                {
                    pageId = this.GetBinding <Guid>("PageId");
                }
                string      dataScopeName = this.GetBinding <string>("PageDataScopeName");
                string      cultureName   = this.GetBinding <string>("ActiveCultureName");
                CultureInfo cultureInfo   = null;
                if (cultureName != null)
                {
                    cultureInfo = CultureInfo.CreateSpecificCulture(cultureName);
                }

                using (new DataScope(DataScopeIdentifier.Deserialize(dataScopeName), cultureInfo))
                {
                    Thread.CurrentThread.CurrentCulture = Thread.CurrentThread.CurrentUICulture = cultureInfo;

                    IPage page = DataFacade.GetData <IPage>(f => f.Id == pageId).FirstOrDefault();
                    if (page != null)
                    {
                        PageRenderer.CurrentPage = page;
                    }

                    object result = methodInfo.Invoke(null, parameterValues.ToArray());

                    string resultString;

                    try
                    {
                        resultString = PrettyPrinter.Print(result);
                    }
                    catch (Exception ex)
                    {
                        throw new TargetInvocationException(ex);
                    }

                    SetOutput(formFlowWebRenderingService, resultString);
                }
            }
            catch (TargetInvocationException ex)
            {
                SetOutput(formFlowWebRenderingService, ex.InnerException.ToString());
            }
            finally
            {
                Thread.CurrentThread.CurrentCulture   = oldCurrentCulture;
                Thread.CurrentThread.CurrentUICulture = oldCurrentUICulture;
            }
        }
        /// <summary>
        /// Execute the C1 Function defined for this attribute and return the result.
        /// </summary>
        /// <returns>Result of C1 Function call</returns>
        public override object GetValue()
        {
            BaseRuntimeTreeNode node = FunctionFacade.BuildTree(XElement.Parse(this.FunctionDescription));

            return(node.GetValue());
        }
Esempio n. 9
0
        private void editPreviewActivity_ExecuteCode(object sender, EventArgs e)
        {
            Stopwatch functionCallingStopwatch = null;
            long      millisecondsToken        = 0;

            CultureInfo oldCurrentCulture   = Thread.CurrentThread.CurrentCulture;
            CultureInfo oldCurrentUICulture = Thread.CurrentThread.CurrentUICulture;

            try
            {
                IXsltFunction xslt = this.GetBinding <IXsltFunction>("CurrentXslt");

                string xslTemplate = this.GetBinding <string>("XslTemplate");

                IFile persistemTemplateFile = IFileServices.TryGetFile <IXsltFile>(xslt.XslFilePath);
                if (persistemTemplateFile != null)
                {
                    string persistemTemplate = persistemTemplateFile.ReadAllText();

                    if (this.GetBinding <int>("XslTemplateLastSaveHash") != persistemTemplate.GetHashCode())
                    {
                        xslTemplate = persistemTemplate;
                        ConsoleMessageQueueFacade.Enqueue(new LogEntryMessageQueueItem {
                            Level = LogLevel.Fine, Message = "XSLT file on file system was used. It has been changed by another process.", Sender = this.GetType()
                        }, this.GetCurrentConsoleId());
                    }
                }

                List <NamedFunctionCall> namedFunctions = this.GetBinding <IEnumerable <NamedFunctionCall> >("FunctionCalls").ToList();

                // If preview is done multiple times in a row, with no postbacks an object reference to BaseFunctionRuntimeTreeNode may be held
                // If the function in the BaseFunctionRuntimeTreeNode have ben unloaded / reloaded, this preview will still run on the old instance
                // We force refresh by serializing / deserializing
                foreach (NamedFunctionCall namedFunction in namedFunctions)
                {
                    namedFunction.FunctionCall = (BaseFunctionRuntimeTreeNode)FunctionFacade.BuildTree(namedFunction.FunctionCall.Serialize());
                }


                List <ManagedParameterDefinition> parameterDefinitions = this.GetBinding <IEnumerable <ManagedParameterDefinition> >("Parameters").ToList();

                Guid        pageId        = this.GetBinding <Guid>("PageId");
                string      dataScopeName = this.GetBinding <string>("PageDataScopeName");
                string      cultureName   = this.GetBinding <string>("ActiveCultureName");
                CultureInfo cultureInfo   = null;
                if (cultureName != null)
                {
                    cultureInfo = CultureInfo.CreateSpecificCulture(cultureName);
                }

                IPage page;

                TransformationInputs transformationInput;
                using (new DataScope(DataScopeIdentifier.Deserialize(dataScopeName), cultureInfo))
                {
                    Thread.CurrentThread.CurrentCulture   = cultureInfo;
                    Thread.CurrentThread.CurrentUICulture = cultureInfo;

                    page = DataFacade.GetData <IPage>(f => f.Id == pageId).FirstOrDefault();
                    if (page != null)
                    {
                        PageRenderer.CurrentPage = page;
                    }

                    functionCallingStopwatch = Stopwatch.StartNew();
                    transformationInput      = RenderHelper.BuildInputDocument(namedFunctions, parameterDefinitions, true);
                    functionCallingStopwatch.Stop();

                    Thread.CurrentThread.CurrentCulture   = oldCurrentCulture;
                    Thread.CurrentThread.CurrentUICulture = oldCurrentUICulture;
                }


                string output = "";
                string error  = "";
                try
                {
                    Thread.CurrentThread.CurrentCulture   = cultureInfo;
                    Thread.CurrentThread.CurrentUICulture = cultureInfo;

                    var styleSheet = XElement.Parse(xslTemplate);

                    XsltBasedFunctionProvider.ResolveImportIncludePaths(styleSheet);

                    LocalizationParser.Parse(styleSheet);

                    XDocument transformationResult = new XDocument();
                    using (XmlWriter writer = new LimitedDepthXmlWriter(transformationResult.CreateWriter()))
                    {
                        XslCompiledTransform xslTransformer = new XslCompiledTransform();
                        xslTransformer.Load(styleSheet.CreateReader(), XsltSettings.TrustedXslt, new XmlUrlResolver());

                        XsltArgumentList transformArgs = new XsltArgumentList();
                        XslExtensionsManager.Register(transformArgs);

                        if (transformationInput.ExtensionDefinitions != null)
                        {
                            foreach (IXsltExtensionDefinition extensionDef in transformationInput.ExtensionDefinitions)
                            {
                                transformArgs.AddExtensionObject(extensionDef.ExtensionNamespace.ToString(),
                                                                 extensionDef.EntensionObjectAsObject);
                            }
                        }

                        Exception   exception   = null;
                        HttpContext httpContext = HttpContext.Current;

                        Thread thread = new Thread(delegate()
                        {
                            Thread.CurrentThread.CurrentCulture   = cultureInfo;
                            Thread.CurrentThread.CurrentUICulture = cultureInfo;

                            Stopwatch transformationStopwatch = Stopwatch.StartNew();

                            try
                            {
                                using (ThreadDataManager.Initialize())
                                    using (new DataScope(DataScopeIdentifier.Deserialize(dataScopeName), cultureInfo))
                                    {
                                        HttpContext.Current = httpContext;

                                        var reader = transformationInput.InputDocument.CreateReader();
                                        xslTransformer.Transform(reader, transformArgs, writer);
                                    }
                            }
                            catch (ThreadAbortException ex)
                            {
                                exception = ex;
                                Thread.ResetAbort();
                            }
                            catch (Exception ex)
                            {
                                exception = ex;
                            }

                            transformationStopwatch.Stop();

                            millisecondsToken = transformationStopwatch.ElapsedMilliseconds;
                        });

                        thread.Start();
                        bool res = thread.Join(1000);  // sadly, this needs to be low enough to prevent StackOverflowException from fireing.

                        if (res == false)
                        {
                            if (thread.ThreadState == System.Threading.ThreadState.Running)
                            {
                                thread.Abort();
                            }
                            throw new XslLoadException("Transformation took more than 1000 milliseconds to complete. This could be due to a never ending recursive call. Execution aborted to prevent fatal StackOverflowException.");
                        }

                        if (exception != null)
                        {
                            throw exception;
                        }
                    }

                    if (xslt.OutputXmlSubType == "XHTML")
                    {
                        XhtmlDocument xhtmlDocument = new XhtmlDocument(transformationResult);

                        output = xhtmlDocument.Root.ToString();
                    }
                    else
                    {
                        output = transformationResult.Root.ToString();
                    }
                }
                catch (Exception ex)
                {
                    output = "<error/>";
                    error  = string.Format("{0}\n{1}", ex.GetType().Name, ex.Message);

                    Exception inner = ex.InnerException;

                    string indent = "";

                    while (inner != null)
                    {
                        indent = indent + " - ";
                        error  = error + "\n" + indent + inner.Message;
                        inner  = inner.InnerException;
                    }
                }
                finally
                {
                    Thread.CurrentThread.CurrentCulture   = oldCurrentCulture;
                    Thread.CurrentThread.CurrentUICulture = oldCurrentUICulture;
                }

                Page currentPage = HttpContext.Current.Handler as Page;
                if (currentPage == null)
                {
                    throw new InvalidOperationException("The Current HttpContext Handler must be a System.Web.Ui.Page");
                }

                UserControl inOutControl = (UserControl)currentPage.LoadControl(UrlUtils.ResolveAdminUrl("controls/Misc/MarkupInOutView.ascx"));
                inOutControl.Attributes.Add("in", transformationInput.InputDocument.ToString());
                inOutControl.Attributes.Add("out", output);
                inOutControl.Attributes.Add("error", error);
                inOutControl.Attributes.Add("statusmessage", string.Format("Execution times: Total {0} ms. Functions: {1} ms. XSLT: {2} ms.",
                                                                           millisecondsToken + functionCallingStopwatch.ElapsedMilliseconds,
                                                                           functionCallingStopwatch.ElapsedMilliseconds,
                                                                           millisecondsToken));

                FlowControllerServicesContainer serviceContainer = WorkflowFacade.GetFlowControllerServicesContainer(WorkflowEnvironment.WorkflowInstanceId);
                var webRenderService = serviceContainer.GetService <IFormFlowWebRenderingService>();
                webRenderService.SetNewPageOutput(inOutControl);
            }
            catch (Exception ex)
            {
                FlowControllerServicesContainer serviceContainer = WorkflowFacade.GetFlowControllerServicesContainer(WorkflowEnvironment.WorkflowInstanceId);
                Control errOutput        = new LiteralControl("<pre>" + ex.ToString() + "</pre>");
                var     webRenderService = serviceContainer.GetService <IFormFlowWebRenderingService>();
                webRenderService.SetNewPageOutput(errOutput);
            }
        }
        private void ValidatePageTemplate(XDocument xDocument)
        {
            // check unique id's
            List <XAttribute> valueOrderedIdAttributes = xDocument.Descendants().Attributes("id").OrderBy(f => f.Value).ToList();

            XElement rootElement = xDocument.Root;

            if (rootElement.Name.LocalName.ToLowerInvariant() == "html")
            {
                if (rootElement.Name.Namespace != Namespaces.Xhtml)
                {
                    throw new InvalidOperationException(string.Format("Root element 'html' must belong to the namespace '{0}'. Change the \"<html>\" tag to \"<html xmlns='{0}'>\"", Namespaces.Xhtml));
                }

                if (rootElement.Name.LocalName != rootElement.Name.LocalName.ToLowerInvariant())
                {
                    throw new InvalidOperationException("Root element 'html' must be written in lower case.");
                }
            }

            for (int i = 0; i < valueOrderedIdAttributes.Count - 1; i++)
            {
                if (valueOrderedIdAttributes[i].Value == valueOrderedIdAttributes[i + 1].Value)
                {
                    throw new InvalidOperationException(string.Format("The id '{0}' is used on multiple elements ('{1}' and '{2}'). Element id values must be unique.", valueOrderedIdAttributes[i].Value, valueOrderedIdAttributes[i].Parent.Name.LocalName, valueOrderedIdAttributes[i + 1].Parent.Name.LocalName));
                }
            }

            foreach (XElement element in xDocument.Descendants().Where(f => f.Name.Namespace == Namespaces.AspNetControls))
            {
                switch (element.Name.LocalName)
                {
                case "form":
                case "placeholder":
                    break;

                default:
                    throw new InvalidOperationException(string.Format("Unknown element '{0}' in namespace '{1}'.", element.Name.LocalName, Namespaces.AspNetControls));
                }
            }

            foreach (XElement element in xDocument.Descendants().Where(f => f.Name.Namespace == Namespaces.Rendering10))
            {
                switch (element.Name.LocalName)
                {
                case "page.title":
                case "page.description":
                case "page.metatag.description":
                case "placeholder":
                    break;

                default:
                    throw new InvalidOperationException(string.Format("Unknown element '{0}' in namespace '{1}'.", element.Name.LocalName, Namespaces.Rendering10));
                }
            }

            if (1 < xDocument.Descendants(Namespaces.Rendering10 + "placeholder").Attributes("default").Where(f => f.Value == "true").Count())
            {
                throw new InvalidOperationException(string.Format("Multiple '{0}' elements are set to be default. Only one element may be default.", "placeholder"));
            }

            foreach (XElement element in xDocument.Descendants(Namespaces.Function10 + "function"))
            {
                FunctionFacade.BuildTree(element);
            }
        }