コード例 #1
0
        protected private SPListCollection ExecuteSearch()
        {
            var final = new SPListCollection();

            if (!MyInvocation.BoundParameters.ContainsKey("InputObject"))
            {
                Web workingWeb            = this.GetWorkingWeb();
                IEnumerable <SPList> temp = MyInvocation.BoundParameters.ContainsKey("Identity") && this.TryFindList(this.Identity, workingWeb, out SPList spList)
                    ? (new SPList[1] {
                    spList
                })
                    : (IEnumerable <SPList>) this.GetAllLists(workingWeb);
                final.AddRange(temp);
            }
            else if (MyInvocation.BoundParameters.ContainsKey("InputObject"))
            {
                bool isAvail = ((Web)this.InputObject.ShowOriginal()).Lists.AreItemsAvailable;
                if (MyInvocation.BoundParameters.ContainsKey("Identity"))
                {
                    var outList = new SPList[1];
                    if (!this.Identity.IsGuid)
                    {
                        if (!isAvail)
                        {
                            var listCol = ((Web)this.InputObject.ShowOriginal()).Lists;
                            var list    = listCol.GetByTitle((string)this.Identity);
                            if (list != null)
                            {
                                outList[0] = (SPList)list;
                            }
                        }
                        else
                        {
                            outList[0] = this.InputObject.Lists.FindByName((string)this.Identity, StringComparison.CurrentCultureIgnoreCase);
                        }
                    }
                    else if (this.Identity.IsGuid)
                    {
                        if (!isAvail)
                        {
                            var listCol = ((Web)this.InputObject.ShowOriginal()).Lists;
                            var list    = listCol.GetById((Guid)this.Identity);
                            if (list != null)
                            {
                                outList[0] = (SPList)list;
                            }
                        }
                    }
                    final.AddRange(outList);
                }
                else
                {
                    if (!isAvail)
                    {
                        this.InputObject.LoadProperty("Lists");
                        final = this.InputObject.Lists;
                    }
                }
            }
            return(final);
        }