コード例 #1
0
ファイル: TListUI.cs プロジェクト: muxiujh/timelineServer
        void field2UIMore(ref TFDictionary dict, PropertyInfo pro)
        {
            if (dict == null)
            {
                return;
            }

            var elementKey = (TE)dict[TF.element];
            // listElement
            TE listElement;

            switch (elementKey)
            {
            case TE.date:
            case TE.hidden:
                listElement = TE.text;
                break;

            case TE.select: {
                var    dataSource = G.Config[dict[TF.dataSource].ToString()];
                object valueShow  = null;
                try {
                    var value = dict[TF.value];
                    if (value != null)
                    {
                        valueShow = dataSource[value];
                    }
                }
                catch { }
                dict[TF.value] = valueShow;
            }
                listElement = TE.text;
                break;

            case TE.picture:
            case TE.pictureList:
                listElement = TE.picture;
                break;

            default:
                listElement = TE.textarea;
                break;
            }
            dict[TF.listElement] = listElement;
        }
コード例 #2
0
        protected TFDictionary field2UI(PropertyInfo pro, object value)
        {
            if (PropertyHelper.IsVirtual(pro))
            {
                return(null);
            }

            TFDictionary dict = pro.GetCustomAttributes <TField>()
                                .ToDictionary(p => p.Key, p => p.Value);

            // Reserved return
            if (dict.ContainsKey(TF.reserved))
            {
                return(null);
            }

            // begin fill dictionary
            PropertyHelper.FillTFDictionary(ref dict);

            // tsuper
            var super = dict[TF.super];

            if (super != null && m_super > (TS)super)
            {
                return(null);
            }

            // element
            TElement element = pro.GetCustomAttribute <TElement>();

            if (element == null)
            {
                TE te = PropertyHelper.IsKey(pro) ? TE.hidden : TE.text;
                element = new TElement(te);
            }
            dict[TF.element] = element.Key;

            // dataSource
            dict[TF.dataSource] = element.Value;

            // widget
            string widget;

            switch (element.Key)
            {
            case TE.text:
            case TE.password:
            case TE.url:
            case TE.tel:
                widget = TE.text.ToString();
                break;

            case TE.picture:
                widget = TE.hidden.ToString();
                break;

            default:
                widget = element.Key.ToString();
                break;
            }
            dict[TF.widget] = widget;

            // title
            dict[TF.title] = THelper.Lang(dict[TF.title] as string, pro.Name);

            // name
            dict[TF.name] = pro.Name;

            // value
            THelper.ConvertToUI(element.Key, ref value);
            dict[TF.value] = value;

            return(dict);
        }