private ITableView InternalGetView(ListBaseType listBaseType, PredefinedListType predefinedListType, SortBy[] sortBy, params PropertyDefinition[] propsToReturn) { if (propsToReturn == null) { throw new ArgumentNullException("propsToReturn"); } if (propsToReturn.Length == 0) { throw new ArgumentException("propsToReturn"); } EnumValidator.ThrowIfInvalid <ListBaseType>(listBaseType, "listBaseType"); EnumValidator.ThrowIfInvalid <PredefinedListType>(predefinedListType, "listBaseType"); if (listBaseType != ListBaseType.Any && predefinedListType != PredefinedListType.Any) { throw new ArgumentException("listBaseType && predefinedListType"); } return(Utils.DoSharepointTask <ArrayTableView>(this.Identity, this.Id, (SharepointSiteId)this.Id, true, Utils.MethodType.GetView, delegate { List <object[]> list = new List <object[]>(); ArrayTableView result; using (Lists lists = new Lists(this.Uri.ToString())) { lists.Credentials = CredentialCache.DefaultCredentials; foreach (object obj in lists.GetListCollection().SelectNodes("/sp:List", SharepointHelpers.SharepointNamespaceManager)) { XmlNode xmlNode = (XmlNode)obj; object[] valuesFromCAMLView = SharepointHelpers.GetValuesFromCAMLView(SharepointListSchema.Instance, xmlNode, null, new PropertyDefinition[] { SharepointListSchema.ID, SharepointListSchema.ListType, SharepointListSchema.PredefinedListType, SharepointListSchema.IsHidden }); int num = 0; int num2 = num + 1; int num3 = num2 + 1; int num4 = num3 + 1; string text = valuesFromCAMLView[num] as string; if (text != null && valuesFromCAMLView[num2] is int && valuesFromCAMLView[num3] is int && valuesFromCAMLView[num4] is bool && !(bool)valuesFromCAMLView[num4]) { ListBaseType listBaseType2 = (ListBaseType)valuesFromCAMLView[num2]; PredefinedListType predefinedListType2 = (PredefinedListType)valuesFromCAMLView[num3]; if ((listBaseType == ListBaseType.Any || listBaseType == listBaseType2) && (predefinedListType == PredefinedListType.Any || predefinedListType == predefinedListType2)) { SharepointListId sharepointListId; if (listBaseType2 == ListBaseType.DocumentLibrary) { sharepointListId = new SharepointListId(text, this.Uri, null, UriFlags.SharepointDocumentLibrary); } else { sharepointListId = new SharepointListId(text, this.Uri, null, UriFlags.SharepointList); } sharepointListId.Cache = new KeyValuePair <string, XmlNode>?(new KeyValuePair <string, XmlNode>(this.Identity.Name, xmlNode)); object[] valuesFromCAMLView2 = SharepointHelpers.GetValuesFromCAMLView(SharepointListSchema.Instance, xmlNode, null, propsToReturn); for (int i = 0; i < propsToReturn.Length; i++) { DocumentLibraryPropertyDefinition documentLibraryPropertyDefinition = propsToReturn[i] as DocumentLibraryPropertyDefinition; if (documentLibraryPropertyDefinition != null) { if (documentLibraryPropertyDefinition.PropertyId == DocumentLibraryPropertyId.Id) { valuesFromCAMLView2[i] = sharepointListId; } else if (documentLibraryPropertyDefinition.PropertyId == DocumentLibraryPropertyId.Uri) { Uri uri = SharepointHelpers.GetValuesFromCAMLView(SharepointListSchema.Instance, xmlNode, null, new PropertyDefinition[] { SharepointListSchema.DefaultViewUri })[0] as Uri; if (uri != null) { valuesFromCAMLView2[i] = new UriBuilder(sharepointListId.SiteUri.Scheme, sharepointListId.SiteUri.Host, sharepointListId.SiteUri.Port, uri.ToString()).Uri; } } } } list.Add(valuesFromCAMLView2); } } } result = new ArrayTableView(null, sortBy, propsToReturn, list); } return result; })); }
public ITableView GetView(QueryFilter filter, SortBy[] sortBy, params PropertyDefinition[] propsToReturn) { WindowsImpersonationContext windowsImpersonationContext = Utils.ImpersonateUser(this.identity); ITableView result; try { IntPtr zero = IntPtr.Zero; try { int num = 0; int num3; int num4; int num2 = UncSession.NetShareEnum(this.id.Path.Host, 1, out zero, -1, out num3, out num4, ref num); if (num2 == 5) { throw new AccessDeniedException(this.Id, Strings.ExAccessDenied(this.id.Path.LocalPath)); } if (num2 == 2250 || num2 == 53) { throw new ObjectMovedOrDeletedException(this.Id, Strings.ExObjectMovedOrDeleted(this.id.Path.LocalPath)); } List <object[]> list = new List <object[]>(); if (num2 == 0 && num3 > 0) { int num5 = Marshal.SizeOf(typeof(UncSession.SHARE_INFO_1)); IntPtr ptr = zero; int num6 = 0; int num7 = Utils.GetViewMaxRows; while (num6 < num3 && num7 > 0) { UncSession.SHARE_INFO_1 share_INFO_ = (UncSession.SHARE_INFO_1)Marshal.PtrToStructure(ptr, typeof(UncSession.SHARE_INFO_1)); if (share_INFO_.ShareType == UncSession.ShareType.Disk) { UncObjectId uncObjectId = new UncObjectId(new Uri(Path.Combine("\\\\" + this.id.Path.Host, share_INFO_.NetName)), UriFlags.UncDocumentLibrary); object[] array = new object[propsToReturn.Length]; DirectoryInfo directoryInfo = null; bool flag = true; int i = 0; while (i < propsToReturn.Length) { DocumentLibraryPropertyId documentLibraryPropertyId = DocumentLibraryPropertyId.None; DocumentLibraryPropertyDefinition documentLibraryPropertyDefinition = propsToReturn[i] as DocumentLibraryPropertyDefinition; if (documentLibraryPropertyDefinition != null) { documentLibraryPropertyId = documentLibraryPropertyDefinition.PropertyId; } DocumentLibraryPropertyId documentLibraryPropertyId2 = documentLibraryPropertyId; switch (documentLibraryPropertyId2) { case DocumentLibraryPropertyId.None: array[i] = new PropertyError(propsToReturn[i], PropertyErrorCode.NotFound); break; case DocumentLibraryPropertyId.Uri: array[i] = uncObjectId.Path; break; case DocumentLibraryPropertyId.ContentLength: case DocumentLibraryPropertyId.CreationTime: case DocumentLibraryPropertyId.LastModifiedTime: case DocumentLibraryPropertyId.IsFolder: goto IL_1F2; case DocumentLibraryPropertyId.IsHidden: array[i] = share_INFO_.NetName.EndsWith("$"); break; case DocumentLibraryPropertyId.Id: array[i] = uncObjectId; break; case DocumentLibraryPropertyId.Title: array[i] = share_INFO_.NetName; break; default: if (documentLibraryPropertyId2 != DocumentLibraryPropertyId.Description) { goto IL_1F2; } array[i] = share_INFO_.Remark; break; } IL_248: i++; continue; IL_1F2: if (flag) { try { if (directoryInfo == null && flag) { directoryInfo = new DirectoryInfo(uncObjectId.Path.LocalPath); FileAttributes attributes = directoryInfo.Attributes; } } catch (UnauthorizedAccessException) { flag = false; } catch (IOException) { flag = false; } } if (flag) { array[i] = UncDocumentLibraryItem.GetValueFromFileSystemInfo(documentLibraryPropertyDefinition, directoryInfo); goto IL_248; } array[i] = new PropertyError(documentLibraryPropertyDefinition, PropertyErrorCode.NotFound); goto IL_248; } list.Add(array); num7--; } num6++; ptr = (IntPtr)(ptr.ToInt64() + (long)num5); } } result = new ArrayTableView(filter, sortBy, propsToReturn, list); } finally { if (IntPtr.Zero != zero) { UncSession.NetApiBufferFree(zero); } } } catch { Utils.UndoContext(ref windowsImpersonationContext); throw; } finally { Utils.UndoContext(ref windowsImpersonationContext); } return(result); }