Exemplo n.º 1
0
        public IMetaData CreateObject(params object[] args)
        {
            IInputData input = ObjectUtil.ConfirmQueryObject <IInputData>(this, args);

            ITableSchemeEx scheme = CreateSourceScheme(input);

            switch (input.Style.Style)
            {
            case PageStyle.Insert:
            case PageStyle.Update:
            case PageStyle.Detail:
                return(new Tk5SingleNormalMetaData(scheme, input, this));

            case PageStyle.List:
                return(new Tk5ListMetaData(scheme, input, this));

            case PageStyle.Custom:
                InputDataProxy proxy;
                if (MetaDataUtil.StartsWith(input.Style, "DetailList"))
                {
                    proxy = new InputDataProxy(input, (PageStyleClass)PageStyle.List);
                    return(new Tk5ListMetaData(scheme, proxy, this));
                }
                else
                {
                    var metaData = SchemeUtil.CreateVueMetaData(input, scheme, this);
                    if (metaData != null)
                    {
                        return(metaData);
                    }
                }
                break;
            }
            return(null);
        }
Exemplo n.º 2
0
        internal TypeTableScheme(Type type)
        {
            TkDebug.AssertArgumentNull(type, "type", null);

            TableName = type.Name;
            DisplayNameAttribute dispAttr = Attribute.GetCustomAttribute(type,
                                                                         typeof(DisplayNameAttribute), false) as DisplayNameAttribute;

            if (dispAttr != null)
            {
                TableDesc = dispAttr.DisplayName;
            }
            else
            {
                TableDesc = TableName;
            }
            fList = new RegNameList <PropertyFieldInfo>();
            PropertyInfo[] props = type.GetProperties(BIND_ATTRIBUTE);
            if (props != null)
            {
                foreach (var prop in props)
                {
                    PropertyFieldInfo info = PropertyFieldInfo.Create(prop);
                    if (info != null)
                    {
                        fList.Add(info);
                    }
                }
            }

            NameField = MetaDataUtil.GetNameField(fList);
        }
Exemplo n.º 3
0
 public InternalTableSchemeEx(ITableScheme scheme, Func <IFieldInfo, IFieldInfoEx> converter)
 {
     fScheme = scheme;
     fFields = (from field in scheme.Fields
                select CreateFieldInfoEx(field, converter)).ToArray();
     NameField = MetaDataUtil.GetNameField(fFields);
 }
Exemplo n.º 4
0
        private PropertyFieldInfo(PropertyInfo property, FieldControlAttribute ctrlAttr)
        {
            NickName = property.Name;
            IsEmpty  = true;
            DisplayNameAttribute dispAttr = Attribute.GetCustomAttribute(property,
                                                                         typeof(DisplayNameAttribute), false) as DisplayNameAttribute;

            if (dispAttr == null)
            {
                DisplayName = NickName;
            }
            else
            {
                DisplayName = dispAttr.DisplayName;
            }
            DataType = MetaDataUtil.ConvertTypeToDataType(property.PropertyType);
            Control  = ctrlAttr;

            FieldLayoutAttribute layoutAttr = Attribute.GetCustomAttribute(property,
                                                                           typeof(FieldLayoutAttribute), false) as FieldLayoutAttribute;

            if (layoutAttr == null)
            {
                Layout = new FieldLayoutAttribute();
            }
            else
            {
                Layout = layoutAttr;
            }
            FieldDecoderAttribute decodeAttr = Attribute.GetCustomAttribute(property,
                                                                            typeof(FieldDecoderAttribute), false) as FieldDecoderAttribute;

            if (decodeAttr != null)
            {
                Decoder = decodeAttr;
            }
            else
            {
                Decoder = new FieldDecoderAttribute();
            }

            FieldInfoAttribute infoAttr = Attribute.GetCustomAttribute(property,
                                                                       typeof(FieldInfoAttribute), false) as FieldInfoAttribute;

            if (infoAttr != null)
            {
                IsKey        = infoAttr.IsKey;
                IsEmpty      = infoAttr.IsEmpty;
                Length       = infoAttr.Length;
                Hint         = infoAttr.Hint;
                HintPosition = infoAttr.HintPosition;
            }

            FieldUploadAttribute uploadAttr = Attribute.GetCustomAttribute(property,
                                                                           typeof(FieldUploadAttribute), false) as FieldUploadAttribute;

            Upload = uploadAttr;
        }
Exemplo n.º 5
0
        public override ITableSchemeEx CreateSourceScheme(IInputData input)
        {
            TypeTableScheme schema = MetaDataUtil.CreateTypeTableScheme(ClassRegName);

            TkDebug.AssertNotNull(schema, string.Format(ObjectUtil.SysCulture,
                                                        "没有找到标记了TypeTableSchemeAttribute的注册类{0}", ClassRegName), this);

            return(schema);
        }
Exemplo n.º 6
0
        public override bool Equals(object obj)
        {
            IPageStyle style1 = obj as IPageStyle;

            if (style1 == null)
            {
                return(false);
            }

            return(MetaDataUtil.Equals(this, style1));
        }
Exemplo n.º 7
0
        public IMetaData CreateObject(params object[] args)
        {
            IInputData      input = ObjectUtil.ConfirmQueryObject <IInputData>(this, args);
            ITableSchemeEx  scheme;
            ISingleMetaData masterMeta;

            switch (input.Style.Style)
            {
            case PageStyle.Insert:
            case PageStyle.Update:
            case PageStyle.Detail:
                masterMeta = Master.CreateSingleMetaData();
                IEnumerable <ISingleMetaData> oneToOneMeta;
                if (OneToOneTables == null)
                {
                    oneToOneMeta = null;
                }
                else
                {
                    oneToOneMeta = (from item in OneToOneTables
                                    select item.CreateSingleMetaData());
                }
                var data = new Tk5MultipleMetaData(input,
                                                   EnumUtil.Convert(masterMeta, oneToOneMeta), OneToManyTables);
                return(data);

            case PageStyle.List:
                masterMeta = Master.CreateSingleMetaData();
                scheme     = masterMeta.CreateSourceScheme(input);
                return(new Tk5ListMetaData(scheme, input, masterMeta));

            case PageStyle.Custom:
                if (MetaDataUtil.StartsWith(input.Style, "DetailList"))
                {
                    int index = input.QueryString["Index"].Value <int>();
                    TkDebug.Assert(OneToManyTables != null && OneToManyTables.Count > index,
                                   string.Format(ObjectUtil.SysCulture, "第{0}项metaData配置不存在", index + 1), this);
                    var config         = OneToManyTables[index];
                    var detailMetaData = config.CreateSingleMetaData();
                    scheme = detailMetaData.CreateSourceScheme(input);
                    InputDataProxy  proxy = new InputDataProxy(input, (PageStyleClass)PageStyle.List);
                    Tk5ListMetaData meta  = new Tk5ListMetaData(scheme, proxy, detailMetaData,
                                                                config.TableOutput?.CreateObject());
                    return(meta);
                }
                break;
            }
            return(null);
        }
Exemplo n.º 8
0
        public IMetaData CreateObject(params object[] args)
        {
            IInputData input = ObjectUtil.ConfirmQueryObject <IInputData>(this, args);

            ITableSchemeEx  scheme;
            ISingleMetaData masterMeta;

            switch (input.Style.Style)
            {
            case PageStyle.Insert:
            case PageStyle.Update:
                masterMeta = Main.CreateSingleMetaData();
                scheme     = masterMeta.CreateSourceScheme(input);
                return(new Tk5SingleNormalMetaData(scheme, input, masterMeta));

            case PageStyle.List:
                masterMeta = Main.CreateSingleMetaData();
                scheme     = masterMeta.CreateSourceScheme(input);
                return(new Tk5ListMetaData(scheme, input, masterMeta));

            case PageStyle.Detail:
                masterMeta = Main.CreateSingleMetaData();
                return(new Tk5MultipleMetaData(input, EnumUtil.Convert(masterMeta),
                                               Details));

            case PageStyle.Custom:
                if (Details == null)
                {
                    return(null);
                }
                if (MetaDataUtil.StartsWith(input.Style, "DetailList"))
                {
                    int index = input.QueryString["Index"].Value <int>();
                    if (index < Details.Count)
                    {
                        var            detail = Details[index];
                        InputDataProxy proxy  = new InputDataProxy(input, (PageStyleClass)PageStyle.List);
                        masterMeta = detail.CreateSingleMetaData();
                        scheme     = masterMeta.CreateSourceScheme(input);
                        return(new Tk5ListMetaData(scheme, proxy, masterMeta,
                                                   detail.TableOutput?.CreateObject()));
                    }
                    return(null);
                }
                break;
            }
            return(null);
        }
Exemplo n.º 9
0
        internal static IMetaData CreateDetailListMeta(IInputData input, List <DetailSingleMetaDataConfig> detailItems,
                                                       out bool shouldReturn)
        {
            shouldReturn = false;

            if (MetaDataUtil.StartsWith(input.Style, "DetailList"))
            {
                int index = input.QueryString["Index"].Value <int>(0);
                if (index < detailItems.Count)
                {
                    var            detailMeta = detailItems[index].CreateSingleMetaData();
                    var            scheme     = detailMeta.CreateSourceScheme(input);
                    InputDataProxy proxy      = new InputDataProxy(input, (PageStyleClass)PageStyle.List);
                    shouldReturn = true;
                    return(new Tk5ListMetaData(scheme, proxy, detailMeta,
                                               detailItems[index].TableOutput?.CreateObject()));
                }
            }
            return(null);
        }
Exemplo n.º 10
0
 ITableSchemeEx IConfigCreator <ITableSchemeEx> .CreateObject(params object[] args)
 {
     return(MetaDataUtil.CreateTypeTableScheme(TypeRegName));
 }
Exemplo n.º 11
0
 public ITableScheme CreateObject(params object[] args)
 {
     return(MetaDataUtil.CreateTypeTableScheme(TypeRegName));
 }