Пример #1
0
        private void WriteToPage(object page, XVar objectToWrite)
        {
            if (objectToWrite.IsArray())
            {
                if (objectToWrite.KeyExists("method"))
                {
                    XVar             parameters    = objectToWrite.KeyExists("params") ? objectToWrite["params"] : new XVar();
                    xtMethodDelegate invokedMethod = (xtMethodDelegate)objectToWrite["method"].Value;

                    MVCFunctions.ob_start();
                    var result    = invokedMethod.Invoke(parameters);
                    var resultStr = result as object == null ? "" : result.ToString();


                    MvcHtmlString textToWrite = MvcHtmlString.Create(MVCFunctions.ob_get_contents() + resultStr);
                    MVCFunctions.ob_end_clean();

                    page.GetType().GetMethod("Write", new Type[] { typeof(MvcHtmlString) }).Invoke(page, new object[] { textToWrite });
                }
            }
            else
            {
                page.GetType().GetMethod("Write", new Type[] { typeof(MvcHtmlString) }).Invoke(page, new object[] { MvcHtmlString.Create(objectToWrite.ToString()) });
            }
        }
Пример #2
0
        public System.Collections.IEnumerable GetSection(string sectionName, object page)
        {
            XVar     sectionValue = getVar(sectionName);
            XSection xSection     = new XSection();

            if (sectionValue != null)
            {
                if (sectionValue.Type == typeof(bool) && sectionValue)
                {
                    yield return(sectionName);
                }
                else if (sectionValue.IsArray())
                {
                    if (sectionValue.KeyExists("begin"))
                    {
                        WriteToPage(page, sectionValue["begin"]);
                    }
                    if (!sectionValue.KeyExists("data") ||
                        !sectionValue["data"].IsArray())
                    {
                        yield return(sectionName);
                    }
                    else
                    {
                        xSection.End = null;
                        foreach (var dataItem in sectionValue["data"].GetEnumerator())
                        {
                            if (dataItem.Value.IsArray())
                            {
                                xt_stack.Add(dataItem.Value);
                                if (dataItem.Value.KeyExists("begin"))
                                {
                                    WriteToPage(page, dataItem.Value["begin"]);
                                }
                            }
                            yield return(sectionName);

                            if (dataItem.Value.IsArray())
                            {
                                xt_stack.Remove(xt_stack.Count() - 1);
                                if (dataItem.Value.KeyExists("end"))
                                {
                                    WriteToPage(page, dataItem.Value["end"]);
                                }
                            }
                            xSection.Begin = null;
                        }
                    }
                    if (sectionValue.KeyExists("end"))
                    {
                        WriteToPage(page, sectionValue["end"]);
                    }
                }
                else if (sectionValue.Type != typeof(bool))
                {
                    yield return(sectionName);
                }
            }
        }
Пример #3
0
        /// <summary>
        /// changes php arrays into xml text recursively
        /// </summary>
        /// <param name="arg_arr_array">the array to be changed into XML</param>
        /// <param name="_arg_str_operation_name">the name of the main xml tag</param>
        /// <param name="arg_str_pad">the indentation pad text</param>
        /// <returns>xml text</returns>
        public XVar array_to_xml(XVar arg_arr_array, XVar _arg_str_operation_name = null, XVar arg_str_pad = null)
        {
            if (arg_arr_array as Object == null || !arg_arr_array.IsArray())
            {
                return(false);
            }
            XVar      arg_str_operation_name = _arg_str_operation_name ?? "report";
            XDocument xDoc = new XDocument();

            xDoc.Add(new XElement(arg_str_operation_name.ToString()));
            xDoc.Root.Add(this.prv_array_to_xml(arg_arr_array));
            return(xDoc.ToString());
        }
Пример #4
0
        public XVar call_func(XVar _param_var)
        {
            XVar var_var = _param_var.Clone();

            XVar var_out;

            if (!var_var.IsArray() || !var_var["func"].Length())
            {
                return("");
            }
            MVCFunctions.ob_start();

            XVar res = ((XTempl.xtFuncDelegate)var_var["func"].Value)(new XVar());

            var_out = MVCFunctions.ob_get_contents() + res.ToString();
            MVCFunctions.ob_end_clean();
            return(var_out);
        }