예제 #1
0
        public object Read(string xaml)
        {
            if (string.IsNullOrEmpty(xaml))
            {
                return(null);
            }
            var node = XamlUtil.GetNode(xaml);

            if (node == null)
            {
                return(null);
            }
            XmlnsDictionary.Collect(node);

            //创建元素
            var obj  = ComponentFactory.Create(node.OriginalName);
            var type = obj as Type;

            if (type != null)
            {
                //是基础类型
                return(DataUtil.ToValue(node.InnerHtml, type));
            }
            else
            {
                Load(obj, node);
            }
            return(obj);
        }
예제 #2
0
        /// <summary>
        /// 加载xaml文件中的信息到obj中
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="xaml"></param>
        /// <param name="connector"></param>
        public void Load(object obj, string xaml)
        {
            if (obj == null)
            {
                return;
            }
            var node = XamlUtil.GetNode(xaml);

            if (node == null)
            {
                return;
            }
            XmlnsDictionary.Collect(node);
            Load(obj, node);
        }