OpenRA.MapField.MapField C# (CSharp) Method

MapField() public method

public MapField ( string key, string fieldName = null, bool required = true, string ignoreIfValue = null ) : System
key string
fieldName string
required bool
ignoreIfValue string
return System
        public MapField(string key, string fieldName = null, bool required = true, string ignoreIfValue = null)
        {
            this.key = key;
            this.fieldName = fieldName ?? key;
            this.required = required;
            this.ignoreIfValue = ignoreIfValue;

            field = typeof(Map).GetField(this.fieldName);
            property = typeof(Map).GetProperty(this.fieldName);
            if (field == null && property == null)
                throw new InvalidOperationException("Map does not have a field/property " + fieldName);

            var t = field != null ? field.FieldType : property.PropertyType;
            type = t == typeof(List<MiniYamlNode>) ? Type.NodeList :
                t == typeof(MiniYaml) ? Type.MiniYaml : Type.Normal;
        }