public static void SetValue(this MultiSelectCustomFieldRef field, object value)
        {
            if (field == null)
            {
                return;
            }

            if (value == null)
            {
                field.value = null;
            }
            else if (value is string)
            {
                field.value = new[] { new ListOrRecordRef()
                                      {
                                          internalId = value.ToString()
                                      } }
            }
            ;
            else if (value is RecordRef)
            {
                field.value = new[] { new ListOrRecordRef()
                                      {
                                          internalId = ((RecordRef)value).internalId
                                      } }
            }
            ;
            else if (value is ListOrRecordRef)
            {
                field.value = new[] { (ListOrRecordRef)value }
            }
            ;
            else if (value is ListOrRecordRef[])
            {
                field.value = (ListOrRecordRef[])value;
            }
            else if (value is RecordRef[])
            {
                var refs = (RecordRef[])value;
                field.value = new ListOrRecordRef[refs.Length];
                for (int i = 0; i < refs.Length; i++)
                {
                    field.value[i] = new ListOrRecordRef()
                    {
                        internalId = refs[i].internalId
                    };
                }
            }
        }
Exemplo n.º 2
0
        public static CustomFieldRef Create(string typeName)
        {
            CustomFieldRef fieldRef;

            switch (typeName)
            {
            case "StringCustomFieldRef":
                fieldRef = new StringCustomFieldRef();
                break;

            case "DoubleCustomFieldRef":
                fieldRef = new DoubleCustomFieldRef();
                break;

            case "MultiSelectCustomFieldRef":
                fieldRef = new MultiSelectCustomFieldRef();
                break;

            case "SelectCustomFieldRef":
                fieldRef = new SelectCustomFieldRef();
                break;

            case "DateCustomFieldRef":
                fieldRef = new DateCustomFieldRef();
                break;

            case "BooleanCustomFieldRef":
                fieldRef = new BooleanCustomFieldRef();
                break;

            case "LongCustomFieldRef":
                fieldRef = new LongCustomFieldRef();
                break;

            default:
                throw new ArgumentException(typeName + " is not a valid Custom Field type.");
            }
            return(fieldRef);
        }