Inheritance: System.Attribute
        /// <summary>
        /// Initializes a new instance of the <see cref="RadioButtonEditorAttribute"/> class.
        /// </summary>
        /// <param name="enumOrLookupType">Type of the enum or lookup.</param>
        /// <exception cref="ArgumentNullException">enumOrLookupType</exception>
        /// <exception cref="ArgumentException">lookupType</exception>
        public RadioButtonEditorAttribute(Type enumOrLookupType)
            : base("RadioButton")
        {
            if (enumOrLookupType == null)
            {
                throw new ArgumentNullException("enumOrLookupType");
            }

            if (enumOrLookupType.IsEnum)
            {
                var ek = enumOrLookupType.GetCustomAttribute <EnumKeyAttribute>(false);
                if (ek == null)
                {
                    EnumKey = enumOrLookupType.FullName;
                }
                else
                {
                    EnumKey = ek.Value;
                }

                return;
            }

            var lk = enumOrLookupType.GetCustomAttribute <LookupScriptAttribute>(false);

            if (lk == null)
            {
                throw new ArgumentException(string.Format(
                                                "'{0}' type doesn't have a [LookupScript] attribute, so it can't " +
                                                "be used with a RadioButtonEditor!",
                                                enumOrLookupType.FullName), "lookupType");
            }

            LookupKey = lk.Key ?? LookupScriptAttribute.AutoLookupKeyFor(enumOrLookupType);
        }
        public LookupFilteringAttribute(Type lookupType)
            : base("Lookup")
        {
            var attr = lookupType.GetCustomAttribute <LookupScriptAttribute>(false);

            if (attr == null)
            {
                throw new ArgumentOutOfRangeException("lookupType");
            }

            SetOption("lookupKey", attr.Key ??
                      LookupScriptAttribute.AutoLookupKeyFor(lookupType));
        }
Exemplo n.º 3
0
        /// <summary>
        /// If you use this constructor, lookupKey will be determined by [LookupScript] attribute
        /// on specified lookup type. If this is a row type, make sure it has [LookupScript] attribute
        /// on it.
        /// </summary>
        public CheckLookupEditorAttribute(Type lookupType)
            : base("CheckLookup")
        {
            if (lookupType == null)
            {
                throw new ArgumentNullException("lookupType");
            }

            var attr = lookupType.GetCustomAttribute <LookupScriptAttribute>(false);

            if (attr == null)
            {
                throw new ArgumentException(string.Format(
                                                "'{0}' type doesn't have a [LookupScript] attribute, so it can't " +
                                                "be used with a CheckLookupEditor!",
                                                lookupType.FullName), "lookupType");
            }

            SetOption("lookupKey", attr.Key ??
                      LookupScriptAttribute.AutoLookupKeyFor(lookupType));
        }