예제 #1
0
        public static string LabelOf(this List <fieldObject> fields, string fieldId)
        {
            fieldObject field = fields.FirstOrDefault(x => x.id.Equals(fieldId, StringComparison.OrdinalIgnoreCase));

            if (field == null)
            {
                throw new ArgumentException("fieldId", string.Format("There is no field with the Id {0}", fieldId));
            }
            return(field.label);
        }
예제 #2
0
        public static string TypeOf(this List <fieldObject> fields, contactField field)
        {
            fieldObject f = fields.FirstOrDefault(x => x.id.Equals(field.fieldId, StringComparison.OrdinalIgnoreCase));

            if (f == null)
            {
                throw new ArgumentException("field", string.Format("There is no field with the Id {0}", field.fieldId));
            }
            return(f.type);
        }
예제 #3
0
        public static string IdOf(this List <fieldObject> fields, string fieldName)
        {
            fieldObject field = fields.FirstOrDefault(x => x.name.Equals(fieldName, StringComparison.OrdinalIgnoreCase) || x.label.Equals(fieldName, StringComparison.OrdinalIgnoreCase));

            if (field == null)
            {
                throw new ArgumentException("fieldName", string.Format("There is no field with the name or label {0}", fieldName));
            }
            return(field.id);
        }
예제 #4
0
        public static fieldOptionObject[] OptionsOf(this List <fieldObject> fields, string fieldName)
        {
            fieldObject field = fields.FirstOrDefault(x => x.name.Equals(fieldName, StringComparison.OrdinalIgnoreCase) || x.label.Equals(fieldName, StringComparison.OrdinalIgnoreCase));

            if (field == null)
            {
                throw new ArgumentException("fieldName", string.Format("There is no field with the name or label {0}", fieldName));
            }
            if (!field.type.Equals(FieldTypes.RadioButtons) || !field.type.Equals(FieldTypes.SelectList))
            {
                throw new ArgumentException("fieldId", string.Format("The field type is '{0}'. Must be either '{1}' or '{2}'", field.type, FieldTypes.RadioButtons, FieldTypes.SelectList));
            }
            return(field.options);
        }
예제 #5
0
        public static fieldOptionObject[] OptionsOf(this List <fieldObject> fields, contactField field)
        {
            fieldObject f = fields.FirstOrDefault(x => x.id.Equals(field.fieldId, StringComparison.OrdinalIgnoreCase));

            if (f == null)
            {
                throw new ArgumentException("field", string.Format("There is no field with the Id {0}", field.fieldId));
            }
            if (!f.type.Equals(FieldTypes.RadioButtons) || !f.type.Equals(FieldTypes.SelectList))
            {
                throw new ArgumentException("field", string.Format("The field type is '{0}'. Must be either '{1}' or '{2}'", f.type, FieldTypes.RadioButtons, FieldTypes.SelectList));
            }
            return(f.options);
        }