示例#1
0
        public static void FindAddIndexes(SqoTypeInfo ti, FieldSqoInfo fi)
        {
            bool found = false;

            if (fi.FInfo != null)
            {
                if (typeof(IList).IsAssignableFrom(fi.FInfo.FieldType))//ignore
                {
                    return;
                }
                object[] customAttStr = fi.FInfo.GetCustomAttributes(typeof(IndexAttribute), false);
                if (customAttStr.Length > 0)
                {
                    ti.IndexedFields.Add(fi);
                    found = true;
                }
                else
                {
                    PropertyInfo pi = MetaHelper.GetAutomaticProperty(fi.FInfo);
                    if (pi != null)
                    {
                        customAttStr = pi.GetCustomAttributes(typeof(IndexAttribute), false);
                        if (customAttStr.Length > 0)
                        {
                            ti.IndexedFields.Add(fi);
                            found = true;
                        }
                    }
                }
                if (!found)//look in configuration
                {
                    if (SiaqodbConfigurator.Indexes != null)
                    {
                        if (SiaqodbConfigurator.Indexes.ContainsKey(ti.Type))
                        {
                            if (SiaqodbConfigurator.Indexes[ti.Type].Contains(fi.Name))
                            {
                                ti.IndexedFields.Add(fi);
                            }
                        }
                    }
                }
            }
        }
示例#2
0
        public static void FindFields(ICollection <FieldInfo> fields, Dictionary <FieldInfo, PropertyInfo> automaticProperties, Type t)
        {
            var flags = BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Public | BindingFlags.Static;

            foreach (var field in t.GetFields(flags))
            {
                // Ignore inherited fields + OID
                if (field.DeclaringType == t && field.Name != "oid" && field.Name != "<OID>k__BackingField")
                {
                    //get automatic properties
                    PropertyInfo pi = MetaHelper.GetAutomaticProperty(field);
                    if (pi != null)
                    {
                        bool found = false;
                        foreach (FieldInfo fiAuto in automaticProperties.Keys)
                        {
                            if (fiAuto.Name == field.Name)
                            {
                                found = true;
                                break;
                            }
                        }
                        if (found)
                        {
                            continue;
                        }
                        automaticProperties[field] = pi;
                    }
                    fields.Add(field);
                }
            }

#if WinRT
            var baseType = t.GetBaseType();
#else
            var baseType = t.BaseType;
#endif
            if (baseType != null)
            {
                FindFields(fields, automaticProperties, baseType);
            }
        }
示例#3
0
        public static void FindAddConstraints(SqoTypeInfo ti, FieldSqoInfo fi)
        {
            bool found = false;

            if (fi.FInfo != null)//if is null can be from OLD schema version and now field is missing
            {
                object[] customAttStr = fi.FInfo.GetCustomAttributes(typeof(UniqueConstraint), false);
                if (customAttStr.Length > 0)
                {
                    ti.UniqueFields.Add(fi);
                    found = true;
                }
                else
                {
                    PropertyInfo pi = MetaHelper.GetAutomaticProperty(fi.FInfo);
                    if (pi != null)
                    {
                        customAttStr = pi.GetCustomAttributes(typeof(UniqueConstraint), false);
                        if (customAttStr.Length > 0)
                        {
                            ti.UniqueFields.Add(fi);
                            found = true;
                        }
                    }
                }
                if (!found)//look in configuration
                {
                    if (SiaqodbConfigurator.Constraints != null)
                    {
                        if (SiaqodbConfigurator.Constraints.ContainsKey(ti.Type))
                        {
                            if (SiaqodbConfigurator.Constraints[ti.Type].Contains(fi.Name))
                            {
                                ti.UniqueFields.Add(fi);
                            }
                        }
                    }
                }
            }
        }