private Model.Field CreateField(SPField listField)
        {
            Model.Field field;

            switch (listField.Type)
            {
            case SPFieldType.Choice:
                field = new Model.FieldChoice
                {
                    Choices = ((SPFieldChoice)listField).Choices.Cast <string>().ToList()
                };
                break;

            case SPFieldType.MultiChoice:
                field = new Model.FieldChoice
                {
                    Choices = ((SPFieldMultiChoice)listField).Choices.Cast <string>().ToList()
                };
                break;

            case SPFieldType.DateTime:
                field = new Model.FieldDateTime {
                    DateOnly = ((SPFieldDateTime)listField).DisplayFormat == SPDateTimeFieldFormatType.DateOnly
                };
                break;

            case SPFieldType.Lookup:
                field = new Model.FieldLookup {
                    AllowMultivalue = ((SPFieldLookup)listField).AllowMultipleValues
                };
                break;

            default:
                field = new Model.Field();
                break;
            }

            field.Id           = listField.Id;
            field.IsHidden     = listField.Hidden;
            field.IsReadonly   = listField.ReadOnlyField;
            field.Title        = listField.Title;
            field.InternalName = listField.InternalName;
            field.Group        = listField.Group;
            field.Type         = (Model.FieldType)listField.Type;

            return(field);
        }
        private Model.Field CreateField(SPField listField)
        {
            Model.Field field;

            switch (listField.Type)
            {
                case SPFieldType.Choice:
                    field = new Model.FieldChoice
                    {
                        Choices = ((SPFieldChoice)listField).Choices.Cast<string>().ToList()
                    };
                    break;
                case SPFieldType.MultiChoice:
                    field = new Model.FieldChoice
                    {
                        Choices = ((SPFieldMultiChoice)listField).Choices.Cast<string>().ToList()
                    };
                    break;

                case SPFieldType.DateTime:
                    field = new Model.FieldDateTime { DateOnly = ((SPFieldDateTime)listField).DisplayFormat == SPDateTimeFieldFormatType.DateOnly };
                    break;

                case SPFieldType.Lookup:
                    field = new Model.FieldLookup {AllowMultivalue = ((SPFieldLookup)listField).AllowMultipleValues};
                    break;

                default:
                    field = new Model.Field();
                    break;
            }

            field.Id = listField.Id;
            field.IsHidden = listField.Hidden;
            field.IsReadonly = listField.ReadOnlyField;
            field.Title = listField.Title;
            field.InternalName = listField.InternalName;
            field.Group = listField.Group;
            field.Type = (Model.FieldType)listField.Type;

            return field;
        }
        private Model.Field CreateField(Field listField)
        {
            Model.Field field;

            switch (listField.FieldTypeKind)
            {
                case FieldType.Choice:
                    field = new Model.FieldChoice
                    {
                        Choices = ((Client.FieldChoice)listField).Choices
                    };
                    break;
                case FieldType.MultiChoice:
                    field = new Model.FieldChoice
                    {
                        Choices = ((Client.FieldMultiChoice)listField).Choices
                    };
                    break;

                case FieldType.DateTime:
                    field = new Model.FieldDateTime { DateOnly = ((Client.FieldDateTime)listField).DisplayFormat == DateTimeFieldFormatType.DateOnly };
                    break;

                case FieldType.Lookup:
                    field = new Model.FieldLookup { AllowMultivalue = ((Client.FieldLookup)listField).AllowMultipleValues };
                    break;

                case FieldType.User:
                    field = new Model.FieldLookup { AllowMultivalue = ((Client.FieldUser)listField).AllowMultipleValues };
                    break;

                case FieldType.Invalid:
                    switch (listField.TypeAsString)
                    {
                        case "TaxonomyFieldType":
                            field = new Model.FieldTaxonomy {AllowMultivalue = false, Type = Model.FieldType.Taxonomy, IsReadonly = true};
                            break;
                        case "TaxonomyFieldTypeMulti":
                            field = new Model.FieldTaxonomy { AllowMultivalue = true, Type = Model.FieldType.Taxonomy, IsReadonly = true};
                            break;
                        default:
                            field = new Model.Field();
                            break;
                    }
                    break;

                default:
                    field = new Model.Field();
                    break;
            }

            field.Id = listField.Id;
            field.IsHidden = listField.Hidden;
            field.IsReadonly |= listField.ReadOnlyField;
            field.Title = listField.Title;
            field.InternalName = listField.InternalName;
            field.Group = listField.Group;
            if( field.Type == 0 ) field.Type = (Model.FieldType)listField.FieldTypeKind;

            return field;
        }
Esempio n. 4
0
        private Model.Field CreateField(Field listField)
        {
            Model.Field field;

            switch (listField.FieldTypeKind)
            {
            case FieldType.Choice:
                field = new Model.FieldChoice
                {
                    Choices = ((Client.FieldChoice)listField).Choices
                };
                break;

            case FieldType.MultiChoice:
                field = new Model.FieldChoice
                {
                    Choices = ((Client.FieldMultiChoice)listField).Choices
                };
                break;

            case FieldType.DateTime:
                field = new Model.FieldDateTime {
                    DateOnly = ((Client.FieldDateTime)listField).DisplayFormat == DateTimeFieldFormatType.DateOnly
                };
                break;

            case FieldType.Lookup:
                field = new Model.FieldLookup {
                    AllowMultivalue = ((Client.FieldLookup)listField).AllowMultipleValues,
                    LookupField     = ((Client.FieldLookup)listField).LookupField,
                    LookupList      = ((Client.FieldLookup)listField).LookupList,
                    LookupWebId     = ((Client.FieldLookup)listField).LookupWebId
                };
                break;

            case FieldType.User:
                field = new Model.FieldLookup {
                    AllowMultivalue = ((Client.FieldUser)listField).AllowMultipleValues,
                    LookupField     = ((Client.FieldLookup)listField).LookupField,
                    LookupList      = ((Client.FieldUser)listField).LookupList,
                    LookupWebId     = ((Client.FieldUser)listField).LookupWebId
                };
                break;

            case FieldType.Invalid:
                switch (listField.TypeAsString)
                {
                case "TaxonomyFieldType":
                    field = new Model.FieldTaxonomy {
                        AllowMultivalue = false, Type = Model.FieldType.Taxonomy, IsReadonly = true
                    };
                    break;

                case "TaxonomyFieldTypeMulti":
                    field = new Model.FieldTaxonomy {
                        AllowMultivalue = true, Type = Model.FieldType.Taxonomy, IsReadonly = true
                    };
                    break;

                default:
                    field = new Model.Field();
                    break;
                }
                break;

            default:
                field = new Model.Field();
                break;
            }

            field.Id           = listField.Id;
            field.IsHidden     = listField.Hidden;
            field.IsReadonly  |= listField.ReadOnlyField;
            field.Title        = listField.Title;
            field.InternalName = listField.InternalName;
            field.Group        = listField.Group;
            if (field.Type == 0)
            {
                field.Type = (Model.FieldType)listField.FieldTypeKind;
            }

            return(field);
        }