コード例 #1
0
        private Guid AddItem(SimSPField field)
        {
            var spField    = this.List.Fields[field.Id];
            var fieldIndex = this.SetNext();

            fieldIndex.Id     = field.Id;
            fieldIndex.Parent = base.Instance;
            spField.Indexed   = true;
            spField.Update();

            return(spField.Id);
        }
コード例 #2
0
 public SimSPFieldIndexCollection(SPFieldIndexCollection instance)
     : base(instance)
 {
     base.Fake.Bind(this);
     base.Fake.AddSPField = (SPField field) =>
     {
         if (field == null)
         {
             throw new ArgumentNullException("field");
         }
         if (base.Count >= SPFieldIndexCollection.Capacity)
         {
             throw new ArgumentOutOfRangeException();
         }
         return(this.AddItem(SimSPField.FromInstance(field)));
     };
     base.Fake.ItemGetGuid = (Guid id) =>
     {
         foreach (SPFieldIndex current in this)
         {
             if (current.Id == id)
             {
                 return(current);
             }
         }
         throw new ArgumentException("The field index could not be found.");
     };
     base.Fake.ItemGetInt32 = (int index) =>
     {
         if (index < 0)
         {
             throw new ArgumentOutOfRangeException();
         }
         if (index >= base.Count)
         {
             throw new ArgumentException();
         }
         return(base[index]);
     };
     base.Fake.DeleteGuid = (Guid id) =>
     {
         for (int i = 0; i < base.Count; i++)
         {
             SPFieldIndex sPFieldIndex = base[i];
             if (sPFieldIndex.Id == id)
             {
                 base.RemoveAt(i);
                 break;
             }
         }
     };
 }
コード例 #3
0
        public string Add(string title, SPFieldType type, bool required, bool compactName, StringCollection choices)
        {
            if (type <= SPFieldType.Computed)
            {
                if (type == SPFieldType.Computed)
                {
                    throw new InvalidOperationException();
                }
            }
            else
            {
                switch (type)
                {
                case SPFieldType.File:
                case SPFieldType.Attachments:
                case SPFieldType.Recurrence:
                case SPFieldType.CrossProjectLink:
                case SPFieldType.AllDayEvent:
                    throw new InvalidOperationException();

                case SPFieldType.User:
                default:
                    break;
                }
            }

            var simSPField = new SimSPField
            {
                Title           = title,
                Id              = Guid.NewGuid(),
                Type            = type,
                Required        = required,
                InternalName    = title,
                TypeDisplayName = "TypeDisplayName",
                Fields          = base.Instance
            };

            base.Add(simSPField.Instance);

            return(simSPField.InternalName);
        }