internal SharepointPropertyDefinition(string displayName, Type propType, DocumentLibraryPropertyId propertyId, string name, SharepointFieldType fieldType, SharepointPropertyDefinition.MarshalTypeToSharepoint clrToSharepoint, SharepointPropertyDefinition.MarshalTypeFromSharepoint sharepointToClr, object defaultValue) : base(displayName, propType, defaultValue, propertyId)
 {
     this.name            = name;
     this.fieldType       = fieldType;
     this.clrToSharepoint = clrToSharepoint;
     this.sharepointToClr = sharepointToClr;
 }
Example #2
0
        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;
            }
        }
 internal DocumentLibraryPropertyDefinition(string name, Type type, object defaultValue, DocumentLibraryPropertyId propertyId) : base(name, type)
 {
     this.defaultValue = defaultValue;
     this.propertyId   = propertyId;
     if (defaultValue != null && defaultValue.GetType() != type)
     {
         throw new ArgumentException();
     }
 }
Example #4
0
        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);
        }