public virtual IEnumerable <PropertyAndField <TModel> > GetPropertyInfoes
            (BindingFlags bindFlags, PropertyFilterDelegate2 filter)
        {
            Type ModelType  = typeof(TModel);
            var  properties = ModelType.GetProperties(bindFlags);
            List <PropertyAndField <TModel> > list = new List <PropertyAndField <TModel> >();

            foreach (var p in properties)
            {
                if (filter != null)
                {
                    if (!filter(p))
                    {
                        continue;
                    }
                }
                PropertyAndField <TModel> pf = new PropertyAndField <TModel>();
                pf.DatabaseId   = GetDatabaseIdFromPropertyInfo(p);
                pf.DatabaseName = GetDatabaseNameFromPropertyInfo(p);
                pf.DatabaseType = GetDataTypeFromPropertyInfo(p);
                pf.AccessLevel  = GetAccessLevelFromPropertyInfo(p);
                pf.Property     = p;
                //pf.Getter
                //pf.Setter
                list.Add(pf);
            }

            return(list);
        }
Example #2
0
        //formname
        //entryid
        //Properties
        //              FieldId
        //              DataType
        //              Setter null|not null
        public T GetEntry(ModelMeteData <T> MetaData)
        {
            if (MetaData == null)
            {
                throw new ArgumentNullException("MetaData");
            }
            if (string.IsNullOrEmpty(MetaData.EntryId))
            {
                throw new ArgumentException("MetaData.EntryId must provider valid value.");
            }
            if (string.IsNullOrEmpty(MetaData.FormName))
            {
                throw new ArgumentException("MetaData.FormName must provider valid value.");
            }
            if (loginContext.LoginStatus != ARLoginStatus.Success || loginContext.ServerInstance == null)
            {
                throw new UnLoginException();
            }
            if (MetaData.Properties == null || MetaData.Properties.Count == 0)
            {
                throw new ArgumentException("MetaData.Properties must provider valid value.");
            }

            List <ARFieldValue> raw;
            Dictionary <uint, PropertyAndField <T> > mapps = new Dictionary <uint, PropertyAndField <T> >();

            List <uint> fil = new List <uint>();

            foreach (var prop in MetaData.Properties)
            {
                fil.Add(prop.DatabaseId);
                mapps.Add(prop.DatabaseId, prop);
            }
            raw = loginContext.ServerInstance.GetEntry(MetaData.FormName, MetaData.EntryId, fil);


            if (raw == null)
            {
                return(null);
            }

            T model = Activator.CreateInstance <T>();

            foreach (var arfv in raw)
            {
                PropertyAndField <T> t_p = mapps[arfv.FieldId];
                t_p.SetValueC(model, arfv.Value);
            }
            return(model);
        }
 public virtual PropertyAndField <TModel> GetEntryIdPropertyInfo()
 {
     foreach (PropertyInfo item in typeof(TModel).GetProperties())
     {
         var attributes = item.GetCustomAttributes(false);
         foreach (var attr in attributes)
         {
             if (attr is AREntryKeyAttribute)
             {
                 PropertyAndField <TModel> pf = new PropertyAndField <TModel>();
                 pf.DatabaseId   = GetDatabaseIdFromPropertyInfo(item);
                 pf.DatabaseName = GetDatabaseNameFromPropertyInfo(item);
                 pf.DatabaseType = GetDataTypeFromPropertyInfo(item);
                 pf.AccessLevel  = GetAccessLevelFromPropertyInfo(item);
                 pf.Property     = item;
                 //pf.Getter
                 //pf.Setter
                 return(pf);
             }
         }
     }
     return(null);
 }