Beispiel #1
0
        // Constructor for filter from configuration
        internal ThingsFilter(Configuration cfg, string path)
        {
            // Initialize
            requiredfields  = new List <string>();
            forbiddenfields = new List <string>();
            thingargs       = new int[Thing.NUM_ARGS];
            customfields    = new UniFields();

            // Read settings from config
            name         = cfg.ReadSetting(path + ".name", DEFAULT_NAME);
            categoryname = cfg.ReadSetting(path + ".category", "");
            invert       = cfg.ReadSetting(path + ".invert", false);                           //mxd
            displaymode  = (ThingsFilterDisplayMode)cfg.ReadSetting(path + ".displaymode", 0); //mxd
            thingtype    = cfg.ReadSetting(path + ".type", -1);
            thingangle   = cfg.ReadSetting(path + ".angle", -1);
            thingzheight = cfg.ReadSetting(path + ".zheight", int.MinValue);
            thingaction  = cfg.ReadSetting(path + ".action", -1);
            for (int i = 0; i < Thing.NUM_ARGS; i++)
            {
                thingargs[i] = cfg.ReadSetting(path + ".arg" + i.ToString(CultureInfo.InvariantCulture), -1);
            }
            thingtag = cfg.ReadSetting(path + ".tag", -1);

            // Read flags
            // key is string, value must be boolean which indicates if
            // its a required field (true) or forbidden field (false).
            IDictionary fields = cfg.ReadSetting(path + ".fields", new Hashtable());

            foreach (DictionaryEntry de in fields)
            {
                // Add to the corresponding list
                if ((bool)de.Value)
                {
                    requiredfields.Add(de.Key.ToString());
                }
                else
                {
                    forbiddenfields.Add(de.Key.ToString());
                }
            }

            // Custom fields
            IDictionary fieldvalues = cfg.ReadSetting(path + ".customfieldvalues", new Hashtable());

            foreach (DictionaryEntry fv in fieldvalues)
            {
                int ft = cfg.ReadSetting(path + ".customfieldtypes." + fv.Key, 0);
                customfields.Add(fv.Key.ToString(), new UniValue(ft, fv.Value));
            }

            AdjustForMapFormat();

            // We have no destructor
            GC.SuppressFinalize(this);
        }
Beispiel #2
0
        public const string DEFAULT_NAME = "Unnamed filter";         //mxd

        #endregion

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

        // Copy constructor
        internal ThingsFilter(ThingsFilter f)
        {
            // Copy
            name         = f.name;
            categoryname = f.categoryname;
            invert       = f.invert;       //mxd
            displaymode  = f.displaymode;  //mxd
            thingtype    = f.thingtype;
            thingzheight = f.thingzheight;
            thingangle   = f.thingangle;
            thingaction  = f.thingaction;
            thingargs    = new int[Thing.NUM_ARGS];
            Array.Copy(f.thingargs, thingargs, Thing.NUM_ARGS);
            thingtag        = f.thingtag;
            customfields    = new UniFields(f.customfields);
            requiredfields  = new List <string>(f.requiredfields);
            forbiddenfields = new List <string>(f.forbiddenfields);

            AdjustForMapFormat();

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