Ejemplo n.º 1
0
 private void EnsureWidgetFunction()
 {
     lock (_lock)
     {
         if (_widgetFunction == null && _serializedWidgetFunction != null)
         {
             WidgetFunctionRuntimeTreeNode functionNode = (WidgetFunctionRuntimeTreeNode)FunctionFacade.BuildTree(_serializedWidgetFunction);
             _setParameters  = functionNode.GetSetParameters().ToList();
             _widgetFunction = functionNode.GetWidgetFunction();
         }
     }
 }
Ejemplo n.º 2
0
        //public static XElement GetWidgetMarkup(IWidgetFunction widgetFunction, Type targetType, IDictionary<string, object> parameters, string label, HelpDefinition helpDefinition, string bindingSourceName, FunctionContextContainer functionContextContainer)
        //{
        //    List<BaseParameterRuntimeTreeNode> parameterNodes = new List<BaseParameterRuntimeTreeNode>();

        //    if (parameters != null)
        //    {
        //        foreach (KeyValuePair<string, object> kvp in parameters)
        //        {
        //            parameterNodes.Add(new ConstantObjectParameterRuntimeTreeNode(kvp.Key, kvp.Value));
        //        }
        //    }

        //    BaseRuntimeTreeNode node = new WidgetFunctionRuntimeTreeNode(widgetFunction, label, helpDefinition, bindingSourceName, parameterNodes);

        //    return (XElement)node.GetValue(functionContextContainer);
        //}



        /// <exclude />
        public static XElement GetWidgetMarkup(IWidgetFunction widgetFunction, Type targetType, IEnumerable <BaseParameterRuntimeTreeNode> parameters, string label, HelpDefinition helpDefinition, string bindingSourceName, FunctionContextContainer functionContextContainer)
        {
            List <BaseParameterRuntimeTreeNode> parameterNodes = new List <BaseParameterRuntimeTreeNode>();

            if (parameters != null)
            {
                foreach (BaseParameterRuntimeTreeNode parameterNode in parameters)
                {
                    parameterNodes.Add(parameterNode);
                }
            }

            BaseRuntimeTreeNode node = new WidgetFunctionRuntimeTreeNode(widgetFunction, label, helpDefinition, bindingSourceName, parameterNodes);

            return((XElement)node.GetValue(functionContextContainer));
        }
Ejemplo n.º 3
0
    private void AddFunctionCall(string functionName, out IMetaFunction metaFunction)
    {
        BaseFunctionRuntimeTreeNode functionRuntime;

        if (_state.WidgetFunctionSelection)
        {
            IWidgetFunction widgetFunction = FunctionFacade.GetWidgetFunction(functionName);
            functionRuntime = new WidgetFunctionRuntimeTreeNode(widgetFunction);

            metaFunction = widgetFunction;
        }
        else
        {
            IFunction functionInfo = FunctionFacade.GetFunction(functionName);
            functionRuntime = new FunctionRuntimeTreeNode(functionInfo);

            metaFunction = functionInfo;
        }

        XElement function = functionRuntime.Serialize();

        if (!_state.WidgetFunctionSelection && _state.AllowLocalFunctionNameEditing)
        {
            string localName = functionName;
            int pointOffset = localName.LastIndexOf(".", StringComparison.Ordinal);
            if (pointOffset > 0 && pointOffset < localName.Length - 1)
            {
                localName = localName.Substring(pointOffset + 1);
            }
            string uniqueLocalName = localName;
            int retry = 1;
            while (FunctionMarkup.Descendants().Attributes("localname").Any(a => a.Value == uniqueLocalName))
            {
                uniqueLocalName = string.Format("{0}{1}", localName, ++retry);
            }

            function.Add(new XAttribute("localname", uniqueLocalName));
        }

        function.Add(new XAttribute("handle", Guid.NewGuid()));

        FunctionMarkup.Root.Add(function);
    }
    private void BtnAddFunctionCallClicked()
    {
        string selectedFunctionName = this.Request.Form["btnAddFunction"];

        BaseFunctionRuntimeTreeNode functionRuntime;
        if (_state.WidgetFunctionSelection)
        {
            functionRuntime = new WidgetFunctionRuntimeTreeNode(FunctionFacade.GetWidgetFunction(selectedFunctionName));
        }
        else
        {
            functionRuntime = new FunctionRuntimeTreeNode(FunctionFacade.GetFunction(selectedFunctionName));
        }

        XElement function = functionRuntime.Serialize();

        if (!_state.WidgetFunctionSelection && _state.AllowLocalFunctionNameEditing)
        {
            string localName = selectedFunctionName;
            int pointOffset = localName.LastIndexOf(".");
            if (pointOffset > 0 && pointOffset < localName.Length - 1)
            {
                localName = localName.Substring(pointOffset + 1);
            }
            string uniqueLocalName = localName;
            int retry = 1;
            while (FunctionMarkup.Descendants().Attributes("localname").Where(a => a.Value == uniqueLocalName).Any())
            {
                uniqueLocalName = string.Format("{0}{1}", localName, ++retry);
            }

            function.Add(new XAttribute("localname", uniqueLocalName));
        }

        function.Add(new XAttribute("handle", Guid.NewGuid()));

        FunctionMarkup.Root.Add(function);

        SaveChanges();
    }