Exemplo n.º 1
0
        private static void FillMenuItem(DTObject item, XmlNode node, string language)
        {
            string url = GetNodeValue(node, "url"), target = GetNodeValue(node, "target");
            var    codeDTO = DTObject.Create();

            if (!string.IsNullOrEmpty(url))
            {
                codeDTO.SetValue("url", url);
                if (!string.IsNullOrEmpty(target))
                {
                    codeDTO.SetValue("target", target);
                }
            }

            string name = GetNodeValue(node, "name");

            name = ParseName(name, language);
            string icon         = GetNodeValue(node, "icon");
            string iconFontSize = GetNodeValue(node, "iconFontSize");
            string tags         = GetNodeValue(node, "tags");
            string roles        = GetNodeValue(node, "roles");

            if (!string.IsNullOrEmpty(icon))
            {
                item.SetValue("icon", icon);
            }
            if (!string.IsNullOrEmpty(iconFontSize))
            {
                item.SetValue("iconFontSize", iconFontSize);
            }
            if (!string.IsNullOrEmpty(tags))
            {
                var temp = tags.Split(',');
                item.Push("tags", temp, (t, tag) =>
                {
                    t.SetValue(tag);
                });
            }
            if (!string.IsNullOrEmpty(roles))
            {
                var temp = roles.Split(',');
                item.Push("roles", temp, (t, role) =>
                {
                    t.SetValue(role);
                });
            }
            item.SetValue("name", name);
            item.SetObject("code", codeDTO);

            foreach (XmlNode childNode in node.ChildNodes)
            {
                if (childNode.NodeType != XmlNodeType.Element)
                {
                    continue;
                }
                var child = item.CreateAndPush("childs");
                FillMenuItem(child, childNode, language);
            }
        }
Exemplo n.º 2
0
        //internal bool ContainsItem(TextItem data)
        //{
        //    if (_list == null || data == null) return false;
        //    var datas = _list.ItemsSource as IEnumerable<TextItem>;
        //    if (datas == null) return false;
        //    return datas.FirstOrDefault((t) =>
        //    {
        //        return t.Value.Equals(data.Value);
        //    }) != null;
        //}

        #endregion



        public override void Write(DTObject data)
        {
            var result = this.Get();

            if (this.IsRadio)
            {
                var item = result.FirstOrDefault();
                if (item != null)
                {
                    DTObject d = DTObject.Create();
                    d["text"]  = item.Text;
                    d["value"] = item.Value;
                    data.SetObject(this.MemberName, d);
                }
            }
            else
            {
                data.Push(this.MemberName, result, (d, item) =>
                {
                    d["text"]  = item.Text;
                    d["value"] = item.Value;
                });
            }
        }
        public static DTObject Transform(DTObject arg)
        {
            //{component,action,argument:{elements:[{id,name,metadata}]}}
            DTObject result = DTObject.CreateReusable();
            DTObject sender = DTObject.CreateReusable();

            foreach (var p in arg.GetDictionary())
            {
                var name  = p.Key;
                var value = p.Value;
                switch (name)
                {
                case "pagination[page]":
                {
                    sender["metadata.page"] = value;
                    break;
                }

                case "pagination[pages]":
                {
                    sender["metadata.pages"] = value;
                    break;
                }

                case "pagination[perpage]":
                {
                    sender["metadata.perpage"] = value;
                    break;
                }

                case "pagination[total]":
                {
                    sender["metadata.total"] = value;
                    break;
                }

                case "sort[field]":
                {
                    sender["metadata.sort.field"] = value;
                    break;
                }

                case "sort[sort]":
                {
                    sender["metadata.sort.sort"] = value;
                    break;
                }

                case "info[component]":
                {
                    result["component"] = value;
                    break;
                }

                case "info[action]":
                {
                    result["action"] = value;
                    break;
                }

                case "info[senderId]":
                {
                    sender["id"] = value;
                    break;
                }

                case "info[senderName]":
                {
                    sender["name"] = value;
                    break;
                }

                case "info[dates]":
                {
                    sender["metadata.dates"] = GetArray(value);
                    break;
                }

                case "info[datetimes]":
                {
                    sender["metadata.datetimes"] = GetArray(value);
                    break;
                }

                default:
                {
                    FillQuery(sender, name, value);
                    break;
                }
                }
            }
            result.SetObject("argument.sender", sender);
            return(result);
        }