Пример #1
0
        internal static RequirementClass RequirementScan(object obj)
        {
            Type RType = obj.GetType();

            RequirementClass[] rClasses = (RequirementClass[])RType.GetCustomAttributes(typeof(RequirementClass), false);

            if (rClasses.Length > 0)
            {
                RequirementClass rClass = rClasses[0];

                foreach (FieldInfo field in RType.GetFields(BindingFlags.NonPublic | BindingFlags.Instance))
                {
                    RequiredField[] requirements = (RequiredField[])field.GetCustomAttributes(typeof(RequiredField), false);

                    foreach (RequiredField r in requirements)
                    {
                        r.Target = field.GetValue(obj);
                        rClass.Add(r);
                    }
                }

                return(rClass);
            }

            return(null);
        }