Exemplo n.º 1
0
        public static bool IsAutoupdate(libobj obj)
        {
            Type       type = obj.GetType();
            string     name = type.Name;
            table_info t;

            if (!_tables.ContainsKey(name))
            {
                AutoUpdateClassAttribute[] attr = (AutoUpdateClassAttribute[])
                                                  type.GetCustomAttributes(typeof(AutoUpdateClassAttribute), false);
                t = new table_info();

                if (attr.Length > 0) //class labeled as autoupde-able
                {
                    PropertyInfo[] props = type.GetProperties(BindingFlags.NonPublic |
                                                              BindingFlags.Public | BindingFlags.GetProperty | BindingFlags.Instance);
                    AutoUpdatePropAttribute[] attrs;
                    List <PropertyInfo>       updateable_props = new List <PropertyInfo>();

                    System.Array.ForEach <PropertyInfo>(props, (p) =>
                    {
                        attrs = (AutoUpdatePropAttribute[])p.GetCustomAttributes(
                            typeof(AutoUpdatePropAttribute), false);

                        if (attrs.Length > 0)
                        {
                            updateable_props.Add(p);
                        }
                    });

                    // if no property is labeled to be updated to a specific field (i.e. updateable_prop.count == 0)
                    // then there is nothing to update; thus only populate table_info if necc.
                    if (!(updateable_props.Count == 0))
                    {
                        t.ClassAttr     = attr[0];
                        t.PropertyInfos = updateable_props.ToArray();
                    }
                } //end if (attr.Length > 0) //class labeled as autoupde-able

                _tables.Add(name, t);
            }
            else //if (!_tables.ContainsKey(name))
            {
                _tables.TryGetValue(name, out t);
            } //end if (!_tables.ContainsKey(name))

            return(t.ClassAttr != null);
        }
Exemplo n.º 2
0
 private static table_info get_table_info(libobj obj)
 {
     return(get_table_info(obj.GetType().Name));
 }