Exemplo n.º 1
0
        private SimSPListItemCollection GetItems()
        {
            var listItemCollection = new SimSPListItemCollection
            {
                List = this.Instance
            };

            foreach (SPListItem current in this.Items)
            {
                listItemCollection.Add(current);
            }

            return(listItemCollection);
        }
Exemplo n.º 2
0
        protected SimSPList(SPList instance)
            : base(instance)
        {
            this.contentTypes      = new SimSPContentTypeCollection();
            this.fields            = new SimSPFieldCollection();
            this.fieldIndexes      = new SimSPFieldIndexCollection();
            this.items             = new SimSPListItemCollection();
            this.views             = new SimSPViewCollection();
            this.contentTypes.List = this.Instance;
            this.fields.List       = this.Instance;
            this.fieldIndexes.List = this.Instance;
            this.items.List        = this.Instance;
            this.views.List        = this.Instance;
            this.GetOrCreateDefaultView();

            var shimSPList = new ShimSPList(instance);

            shimSPList.IDGet            = () => this.ID;
            shimSPList.HiddenGet        = () => this.Hidden;
            shimSPList.HiddenSetBoolean = (bool value) =>
            {
                this.Hidden = value;
            };
            shimSPList.EnableAttachmentsGet        = () => this.EnableAttachments;
            shimSPList.EnableAttachmentsSetBoolean = (bool value) =>
            {
                this.EnableAttachments = value;
            };
            shimSPList.TitleGet       = () => this.Title;
            shimSPList.TitleSetString = (string newTitle) =>
            {
                this.Title = newTitle;
            };
            shimSPList.RootFolderGet     = () => this.RootFolder;
            shimSPList.RootFolderUrlGet  = () => this.RootFolderUrl;
            shimSPList.DefaultViewGet    = () => this.GetOrCreateDefaultView().Instance;
            shimSPList.DefaultViewUrlGet = () =>
            {
                SimSPView orCreateDefaultView = this.GetOrCreateDefaultView();
                return(orCreateDefaultView.ServerRelativeUrl);
            };
            shimSPList.ParentWebGet     = () => this.ParentWeb;
            shimSPList.Delete           = new FakesDelegates.Action(this.Delete);
            shimSPList.ListsGet         = () => this.Lists;
            shimSPList.ItemsGet         = () => this.items.Instance;
            shimSPList.FieldsGet        = () => this.fields.Instance;
            shimSPList.FieldIndexesGet  = () => this.fieldIndexes.Instance;
            shimSPList.ContentTypesGet  = () => this.contentTypes.Instance;
            shimSPList.ViewsGet         = () => this.views.Instance;
            shimSPList.GetItemByIdInt32 = (int id) =>
            {
                foreach (SPListItem current in this.items)
                {
                    if (current.ID == id)
                    {
                        return(current);
                    }
                }
                throw new ArgumentException();
            };
            shimSPList.GetItemsSPView = (SPView view) => this.GetItems().Instance;
            shimSPList.ItemCountGet   = () => this.Items.Count;
            shimSPList.Update         = () =>
            {
                this.Updated = new bool?(false);
            };
            shimSPList.UpdateBoolean = (bool fromMigration) =>
            {
                this.Updated = new bool?(fromMigration);
            };
            shimSPList.AddItem = () => this.AddItem();
            shimSPList.ContentTypesEnabledGet        = () => this.ContentTypesEnabled;
            shimSPList.ContentTypesEnabledSetBoolean = (bool value) =>
            {
                this.ContentTypesEnabled = value;
            };
            this.Fake = shimSPList;
        }