Exemple #1
0
        // When set up for an argument
        public override void SetupProperty(TypeHandlerAttribute attr, PropertyInfo arginfo)
        {
            base.SetupProperty(attr, arginfo);

            // Keep enum list reference
            list = arginfo.Enum;
        }
        // When set up for an argument
        public override void SetupProperty(TypeHandlerAttribute attr, PropertyInfo arginfo)
        {
            base.SetupProperty(attr, arginfo);

            // Keep enum list reference
            list = General.Map.Config.SectorEffectsList;
        }
Exemple #3
0
        // When set up for an argument
        public override void SetupProperty(TypeHandlerAttribute attr, PropertyInfo propinfo)
        {
            base.SetupProperty(attr, propinfo);

            // Sort in descending order
            List <int> lotagslist = new List <int>(GetLoTags());

            lotagslist.Sort((a, b) => - 1 * a.CompareTo(b));

            // Create enums list
            list = new EnumList();
            foreach (int i in lotagslist)
            {
                list.Add(new EnumItem(i.ToString(), i.ToString()));
            }
        }
        // This returns the type handler for the given argument
        public TypeHandler GetPropertyHandler(PropertyInfo propinfo)
        {
            Type t = typeof(NullHandler);
            TypeHandlerAttribute ta = null;

            // Do we have a handler type for this?
            if (handlertypes.ContainsKey(propinfo.Type))
            {
                ta = handlertypes[propinfo.Type];
                t  = ta.Type;
            }

            // Create instance
            TypeHandler th = (TypeHandler)General.ThisAssembly.CreateInstance(t.FullName);

            th.SetupProperty(ta, propinfo);
            return(th);
        }
Exemple #5
0
 // This sets up the handler for arguments
 public virtual void SetupProperty(TypeHandlerAttribute attr, PropertyInfo propinfo)
 {
     // Setup
     this.propinfo = propinfo;
     if (attr != null)
     {
         // Set attributes
         this.attribute    = attr;
         this.propertytype = attr.PropertyType;
         this.typename     = attr.Name;
     }
     else
     {
         // Indexless
         this.attribute    = null;
         this.propertytype = PropertyType.Integer;
         this.typename     = "Unknown";
     }
 }
        //internal Dictionary<string, PropertyType> KnownPropertyTypes { get { return knownpropertytypes; } }

        #endregion

        #region ================== Constructor / Disposer

        // Constructor
        public TypesManager()
        {
            // Initialize
            handlertypes = new Dictionary <PropertyType, TypeHandlerAttribute>();

            // Go for all types in this assembly
            Type[] types = General.ThisAssembly.GetTypes();
            foreach (Type tp in types)
            {
                // Check if this type is a class
                if (tp.IsClass && !tp.IsAbstract && !tp.IsArray)
                {
                    // Check if class has an TypeHandler attribute
                    if (Attribute.IsDefined(tp, typeof(TypeHandlerAttribute), false))
                    {
                        // Add the type to the list
                        object[]             attribs = tp.GetCustomAttributes(typeof(TypeHandlerAttribute), false);
                        TypeHandlerAttribute attr    = (attribs[0] as TypeHandlerAttribute);
                        attr.Type = tp;
                        handlertypes.Add(attr.PropertyType, attr);
                    }
                }
            }

            //mxd
            knownpropertytypes = new Dictionary <string, PropertyType>();
            string[] names  = Enum.GetNames(typeof(PropertyType));
            Array    values = Enum.GetValues(typeof(PropertyType));

            for (int i = 0; i < names.Length; i++)
            {
                knownpropertytypes[names[i]] = (PropertyType)values.GetValue(i);
            }

            // We have no destructor
            GC.SuppressFinalize(this);
        }