예제 #1
0
 public static ContentCountDisplay GetContentCountDisplay(object extendedFolderFlagValue, StoreObjectId folderId)
 {
     if (folderId == null)
     {
         throw new ArgumentNullException("FolderID");
     }
     if (extendedFolderFlagValue != null && extendedFolderFlagValue is ExtendedFolderFlags)
     {
         ExtendedFolderFlags valueToTest = (ExtendedFolderFlags)extendedFolderFlagValue;
         if (Utilities.IsFlagSet((int)valueToTest, 2))
         {
             return(ContentCountDisplay.ItemCount);
         }
         if (Utilities.IsFlagSet((int)valueToTest, 1))
         {
             return(ContentCountDisplay.UnreadCount);
         }
     }
     return(FolderUtility.GetDefaultContentCountDisplay(folderId));
 }
예제 #2
0
 private static void RenderFolderList(FolderList folderList, string defaultText, string[] folderTypes, StoreObjectId selectedFolderId, IDictionary <string, string> dropdownAttributes, FolderDropdown.FolderFilterOptions folderFilterOptions, FolderDropdown.RenderingOptions renderingOptions, UserContext userContext, TextWriter writer, params FolderDropDownFilterDelegate[] filters)
 {
     if (folderList == null)
     {
         throw new ArgumentNullException("folderList");
     }
     writer.Write("<select");
     if (dropdownAttributes != null)
     {
         foreach (KeyValuePair <string, string> keyValuePair in dropdownAttributes)
         {
             writer.Write(" ");
             writer.Write(keyValuePair.Key);
             writer.Write("=\"");
             writer.Write(keyValuePair.Value);
             writer.Write("\"");
         }
     }
     writer.Write(">");
     if (!string.IsNullOrEmpty(defaultText))
     {
         writer.Write("<option value=\"\" class=dddt>");
         writer.Write(defaultText);
         writer.Write("</option>");
     }
     if ((renderingOptions & FolderDropdown.RenderingOptions.Root) != FolderDropdown.RenderingOptions.None)
     {
         writer.Write("<option value=\"");
         Utilities.HtmlEncode(userContext.GetRootFolderId(userContext.MailboxSession).ToBase64String(), writer);
         writer.Write("\"");
         if (Utilities.IsDefaultFolderId(userContext.MailboxSession, selectedFolderId, DefaultFolderType.Root))
         {
             writer.Write(" selected");
         }
         writer.Write(">");
         Utilities.HtmlEncode(userContext.ExchangePrincipal.MailboxInfo.DisplayName, writer);
         writer.Write("</option>");
     }
     for (int i = 0; i < folderList.Count; i++)
     {
         StoreObjectId objectId = ((VersionedId)folderList.GetPropertyValue(i, FolderSchema.Id)).ObjectId;
         if (((folderFilterOptions & FolderDropdown.FolderFilterOptions.SpecialFolders) != FolderDropdown.FolderFilterOptions.None || !Utilities.IsSpecialFolder(objectId, userContext)) && ((folderFilterOptions & FolderDropdown.FolderFilterOptions.DeletedItemsFolder) != FolderDropdown.FolderFilterOptions.None || !Utilities.IsDefaultFolderId(userContext.MailboxSession, objectId, DefaultFolderType.DeletedItems)) && ((folderFilterOptions & FolderDropdown.FolderFilterOptions.DeletedFolders) != FolderDropdown.FolderFilterOptions.None || !folderList.IsFolderDeleted(i)))
         {
             bool flag = false;
             for (int j = 0; j < filters.Length; j++)
             {
                 if (!filters[j](folderList, objectId))
                 {
                     flag = true;
                     break;
                 }
             }
             if (!flag)
             {
                 string text = folderList.GetPropertyValue(i, StoreObjectSchema.ContainerClass) as string;
                 if (!folderList.IsFolderDeleted(i))
                 {
                     if (text == null)
                     {
                         if ((folderFilterOptions & FolderDropdown.FolderFilterOptions.UnknownFolderType) == FolderDropdown.FolderFilterOptions.None)
                         {
                             goto IL_4A9;
                         }
                     }
                     else if (folderTypes == null)
                     {
                         if ((folderFilterOptions & FolderDropdown.FolderFilterOptions.FoldersAbleToViewInMailModule) != FolderDropdown.FolderFilterOptions.None)
                         {
                             if (ObjectClass.IsCalendarFolder(text))
                             {
                                 goto IL_4A9;
                             }
                             if (ObjectClass.IsContactsFolder(text))
                             {
                                 goto IL_4A9;
                             }
                         }
                     }
                     else
                     {
                         bool flag2 = false;
                         for (int k = 0; k < folderTypes.Length; k++)
                         {
                             if (ObjectClass.IsOfClass(text, folderTypes[k]))
                             {
                                 flag2 = true;
                                 break;
                             }
                         }
                         if (!flag2)
                         {
                             goto IL_4A9;
                         }
                     }
                 }
                 if (text == null || !Utilities.IsFolderSegmentedOut(text, userContext))
                 {
                     writer.Write("<option value=\"");
                     if ((renderingOptions & FolderDropdown.RenderingOptions.WholeLinkAsOptionValue) != FolderDropdown.RenderingOptions.None)
                     {
                         Utilities.HtmlEncode(Utilities.UrlEncode(text ?? "IPF.Note"), writer);
                         Utilities.HtmlEncode("&", writer);
                         writer.Write("id");
                         writer.Write("=");
                         Utilities.HtmlEncode(Utilities.UrlEncode(objectId.ToBase64String()), writer);
                         if (!FolderUtility.IsPrimaryMailFolder(objectId, userContext) && !folderList.IsFolderDeleted(i))
                         {
                             Utilities.HtmlEncode("&mru=1", writer);
                         }
                     }
                     else
                     {
                         Utilities.HtmlEncode(objectId.ToBase64String(), writer);
                     }
                     writer.Write("\"");
                     if ((renderingOptions & FolderDropdown.RenderingOptions.FolderDisplayNameAsTitle) != FolderDropdown.RenderingOptions.None)
                     {
                         writer.Write(" title=\"");
                         string text2 = folderList.GetPropertyValue(i, FolderSchema.DisplayName) as string;
                         if (text2 != null)
                         {
                             Utilities.HtmlEncode(text2, writer);
                         }
                         writer.Write("\"");
                     }
                     if (Utilities.IsSpecialFolder(objectId, userContext))
                     {
                         writer.Write(" class=sf ");
                     }
                     else if (folderList.IsFolderDeleted(i))
                     {
                         writer.Write(" class=df ");
                     }
                     if (objectId.Equals(selectedFolderId))
                     {
                         writer.Write(" selected");
                     }
                     writer.Write(">");
                     int num = 0;
                     if ((renderingOptions & FolderDropdown.RenderingOptions.Hierarchy) != FolderDropdown.RenderingOptions.None)
                     {
                         int num2 = (int)folderList.GetPropertyValue(i, FolderSchema.FolderHierarchyDepth);
                         num = (((renderingOptions & FolderDropdown.RenderingOptions.Root) != FolderDropdown.RenderingOptions.None) ? 1 : 0) + num2 - 1;
                         if (num * 2 > 24)
                         {
                             num = 12;
                         }
                         for (int l = 0; l < num; l++)
                         {
                             writer.Write(". ");
                         }
                     }
                     int num3 = 24 - num * 2;
                     if (num3 > 0)
                     {
                         Utilities.CropAndRenderText(writer, (string)folderList.GetPropertyValue(i, FolderSchema.DisplayName), num3);
                     }
                     if ((renderingOptions & FolderDropdown.RenderingOptions.ItemCount) != FolderDropdown.RenderingOptions.None)
                     {
                         object propertyValue = folderList.GetPropertyValue(i, FolderSchema.ExtendedFolderFlags);
                         ContentCountDisplay contentCountDisplay = FolderUtility.GetContentCountDisplay(propertyValue, objectId);
                         if (contentCountDisplay == ContentCountDisplay.ItemCount)
                         {
                             int num4 = (int)folderList.GetPropertyValue(i, FolderSchema.ItemCount);
                             if (num4 > 0)
                             {
                                 writer.Write(" [" + num4 + "]");
                             }
                         }
                         else if (contentCountDisplay == ContentCountDisplay.UnreadCount)
                         {
                             int num5 = (int)folderList.GetPropertyValue(i, FolderSchema.UnreadCount);
                             if (num5 > 0)
                             {
                                 writer.Write(" (" + num5 + ")");
                             }
                         }
                     }
                     writer.Write("</option>");
                 }
             }
         }
         IL_4A9 :;
     }
     writer.Write("</select>");
 }