Exemplo n.º 1
0
        /// <summary>
        /// Scans an object for Object to Object classes
        /// </summary>
        /// <param name="target"></param>
        /// <returns></returns>
        internal static ObjectToObjectClass OTOScan(object target)
        {
            Type targetType = target.GetType();

            ObjectToObjectClass[] otoClasses = (ObjectToObjectClass[])targetType.GetCustomAttributes(typeof(ObjectToObjectClass), false);
            Manager.Log("OTO Scanning requested ({0}): ", targetType.Name);
            ObjectToObjectClass otoClass = null;

            if (otoClasses.Length > 0)
            {
                Manager.Log("Started!\n", false);
                otoClass = otoClasses[0];

                foreach (FieldInfo field in targetType.GetFields(BindingFlags.NonPublic | BindingFlags.Instance))
                {
                    ObjectToObjectTarget[] otoTargets = (ObjectToObjectTarget[])field.GetCustomAttributes(typeof(ObjectToObjectTarget), false);

                    if (otoTargets.Length > 0)
                    {
                        Manager.Log("Found target: {0}\n", field.Name);
                        otoClass.ObjectTarget = field.GetValue(target);
                    }
                }

                foreach (FieldInfo field in targetType.GetFields(BindingFlags.NonPublic | BindingFlags.Instance))
                {
                    ObjectToObject[] otos = (ObjectToObject[])field.GetCustomAttributes(typeof(ObjectToObject), false);

                    foreach (ObjectToObject oto in otos)
                    {
                        Manager.Log("Found field {0}\n", field.Name);
                        oto.Owner = (Control)field.GetValue(target);
                        otoClass.Add(oto);
                    }
                }

                if (otoClass.ObjectTarget != null)
                {
                    Manager.Log("OTO Successfull scan\n");
                    return(otoClass);
                }
                else
                {
                    Manager.Log("OTO Unsuccessful scan\n");
                }
            }
            else
            {
                Manager.Log("Failed, not OTO class.\n", false);
            }

            return(null);
        }
Exemplo n.º 2
0
        private void Initialize()
        {
            foreach (DatabaseType dbType in Enum.GetValues(typeof(DatabaseType)))
            {
                i_accountSqlType.Items.Add(dbType);
                i_worldSqlType.Items.Add(dbType);
                i_characterSqlType.Items.Add(dbType);
            }

            m_otoClass = Manager.OTOScan(this);
            m_rClass   = Manager.RequirementScan(this);

            if (m_otoClass != null)
            {
                m_otoClass.GetValues();
            }
        }