public virtual object TryGetProperty(DocumentLibraryPropertyDefinition propertyDefinition) { if (this.schema.AllProperties.ContainsKey(propertyDefinition)) { return(UncDocumentLibraryItem.GetValueFromFileSystemInfo(propertyDefinition, this.fileSystemInfo)); } return(new PropertyError(propertyDefinition, PropertyErrorCode.NotFound)); }
internal static ITableView InternalGetView(QueryFilter query, SortBy[] sortBy, DocumentLibraryQueryOptions queryOptions, PropertyDefinition[] propsToReturn, UncSession session, DirectoryInfo directoryInfo, UncObjectId id) { if (propsToReturn == null) { throw new ArgumentNullException("propsToReturn"); } if (propsToReturn.Length == 0) { throw new ArgumentException("propsToReturn"); } DocumentLibraryPropertyDefinition[] propertyDefinitions = new DocumentLibraryPropertyDefinition[propsToReturn.Length]; for (int i = 0; i < propsToReturn.Length; i++) { propertyDefinitions[i] = (propsToReturn[i] as DocumentLibraryPropertyDefinition); if (propertyDefinitions[i] == null) { throw new ArgumentException("propsToReturn"); } } return(Utils.DoUncTask <ArrayTableView>(session.Identity, id, true, Utils.MethodType.GetView, delegate { FileSystemInfo[] array; switch (queryOptions) { case DocumentLibraryQueryOptions.Folders: array = directoryInfo.GetDirectories(); break; case DocumentLibraryQueryOptions.Files: array = directoryInfo.GetFiles(); break; case DocumentLibraryQueryOptions.FoldersAndFiles: array = directoryInfo.GetFileSystemInfos(); break; default: throw new ArgumentOutOfRangeException("queryOptions"); } List <object[]> list = new List <object[]>(); int num = 0; int num2 = Utils.GetViewMaxRows; while (num < array.Length && num2 > 0) { object[] array2 = new object[propertyDefinitions.Length]; for (int j = 0; j < propertyDefinitions.Length; j++) { array2[j] = UncDocumentLibraryItem.GetValueFromFileSystemInfo(propertyDefinitions[j], array[num]); } list.Add(array2); num2--; num++; } return new ArrayTableView(query, sortBy, propertyDefinitions, list); })); }
public override object TryGetProperty(PropertyDefinition propDef) { DocumentLibraryPropertyDefinition documentLibraryPropertyDefinition = propDef as DocumentLibraryPropertyDefinition; if (documentLibraryPropertyDefinition != null && documentLibraryPropertyDefinition.PropertyId == DocumentLibraryPropertyId.Uri) { return(this.Uri); } return(base.TryGetProperty(propDef)); }
protected GType GetValueOrDefault <GType>(PropertyDefinition propDef) { object obj = this.TryGetProperty(propDef); DocumentLibraryPropertyDefinition documentLibraryPropertyDefinition = propDef as DocumentLibraryPropertyDefinition; if (obj is PropertyError) { obj = documentLibraryPropertyDefinition.DefaultValue; } return((GType)((object)obj)); }
public virtual object TryGetProperty(PropertyDefinition propDef) { DocumentLibraryPropertyDefinition documentLibraryPropertyDefinition = propDef as DocumentLibraryPropertyDefinition; if (documentLibraryPropertyDefinition != null && documentLibraryPropertyDefinition.PropertyId == DocumentLibraryPropertyId.Id) { return(this.Id); } return(SharepointHelpers.GetValuesFromCAMLView(this.Schema, this.DataNode, this.CultureInfo, new PropertyDefinition[] { propDef })[0]); }
internal static object GetValueFromFileSystemInfo(DocumentLibraryPropertyDefinition propertyDefinition, FileSystemInfo fileSystemInfo) { FileInfo fileInfo = fileSystemInfo as FileInfo; switch (propertyDefinition.PropertyId) { case DocumentLibraryPropertyId.Uri: return(new Uri(fileSystemInfo.FullName)); case DocumentLibraryPropertyId.CreationTime: return(fileSystemInfo.CreationTimeUtc); case DocumentLibraryPropertyId.LastModifiedTime: return(fileSystemInfo.LastWriteTimeUtc); case DocumentLibraryPropertyId.IsFolder: return((fileSystemInfo.Attributes & FileAttributes.Directory) != (FileAttributes)0); case DocumentLibraryPropertyId.IsHidden: return((fileSystemInfo.Attributes & FileAttributes.Hidden) == FileAttributes.Hidden); case DocumentLibraryPropertyId.Id: return(new UncObjectId(new Uri(fileSystemInfo.FullName), ((fileSystemInfo.Attributes & FileAttributes.Directory) != (FileAttributes)0) ? UriFlags.UncFolder : UriFlags.UncDocument)); case DocumentLibraryPropertyId.Title: return(fileSystemInfo.Name); case DocumentLibraryPropertyId.FileSize: if (fileInfo != null) { return(fileInfo.Length); } return(new PropertyError(propertyDefinition, PropertyErrorCode.NotFound)); case DocumentLibraryPropertyId.FileType: if (fileInfo == null) { return(new PropertyError(propertyDefinition, PropertyErrorCode.NotFound)); } if (!string.IsNullOrEmpty(fileInfo.Extension)) { return(ExtensionToContentTypeMapper.Instance.GetContentTypeByExtension(fileInfo.Extension.Substring(1))); } return("application/octet-stream"); case DocumentLibraryPropertyId.BaseName: return(fileSystemInfo.Name); } throw PropertyErrorException.GetExceptionFromError(new PropertyError(propertyDefinition, PropertyErrorCode.NotSupported)); }
public object TryGetProperty(PropertyDefinition propertyDefinition) { if (propertyDefinition == null) { throw new ArgumentNullException("propertyDefinition"); } DocumentLibraryPropertyDefinition documentLibraryPropertyDefinition = propertyDefinition as DocumentLibraryPropertyDefinition; if (documentLibraryPropertyDefinition == null) { throw new ArgumentException("propertyDefinition"); } return(this.TryGetProperty(documentLibraryPropertyDefinition)); }
internal static SharepointPropertyDefinition PropertyDefinitionToSharepointPropertyDefinition(Schema schema, PropertyDefinition propDef) { SharepointPropertyDefinition sharepointPropertyDefinition = propDef as SharepointPropertyDefinition; DocumentLibraryPropertyDefinition documentLibraryPropertyDefinition = propDef as DocumentLibraryPropertyDefinition; if (documentLibraryPropertyDefinition == null) { throw new ArgumentException("propDefs"); } if (sharepointPropertyDefinition == null && schema.IdToPropertyMap.ContainsKey(documentLibraryPropertyDefinition.PropertyId)) { sharepointPropertyDefinition = (schema.IdToPropertyMap[documentLibraryPropertyDefinition.PropertyId] as SharepointPropertyDefinition); } return(sharepointPropertyDefinition); }
protected internal Schema() { this.allProperties = new Dictionary <PropertyDefinition, DocumentLibraryPropertyDefinition>(); BindingFlags bindingAttr = BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy; FieldInfo[] fields = base.GetType().GetFields(bindingAttr); foreach (FieldInfo fieldInfo in fields) { object value = fieldInfo.GetValue(null); DocumentLibraryPropertyDefinition documentLibraryPropertyDefinition = value as DocumentLibraryPropertyDefinition; if (documentLibraryPropertyDefinition != null) { if (documentLibraryPropertyDefinition.PropertyId != DocumentLibraryPropertyId.None) { this.idToPropertyMap.Add(documentLibraryPropertyDefinition.PropertyId, documentLibraryPropertyDefinition); } this.allProperties.Add(documentLibraryPropertyDefinition, documentLibraryPropertyDefinition); } } }
private object TryGetProperty(PropertyDefinition propertyDefinition) { DocumentLibraryPropertyId documentLibraryPropertyId = DocumentLibraryPropertyId.None; DocumentLibraryPropertyDefinition documentLibraryPropertyDefinition = propertyDefinition as DocumentLibraryPropertyDefinition; if (documentLibraryPropertyDefinition != null) { documentLibraryPropertyId = documentLibraryPropertyDefinition.PropertyId; } DocumentLibraryPropertyId documentLibraryPropertyId2 = documentLibraryPropertyId; switch (documentLibraryPropertyId2) { case DocumentLibraryPropertyId.None: return(new PropertyError(propertyDefinition, PropertyErrorCode.NotFound)); case DocumentLibraryPropertyId.Uri: return(this.id.Path); default: switch (documentLibraryPropertyId2) { case DocumentLibraryPropertyId.Id: return(this.id); case DocumentLibraryPropertyId.Title: return(this.shareName); default: if (documentLibraryPropertyId2 != DocumentLibraryPropertyId.Description) { return(UncDocumentLibraryItem.GetValueFromFileSystemInfo(documentLibraryPropertyDefinition, this.directoryInfo)); } return(this.description); } break; } }
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); }