コード例 #1
0
 private static StoreObjectId CreateStoreObjectIdFromString(string owaStoreObjectIdString, string itemPrefix, int indexOfLastSeparatorChar)
 {
     if (indexOfLastSeparatorChar == itemPrefix.Length)
     {
         throw new OwaInvalidIdFormatException(string.Format("There should be two separators \"{0}\" in the id of the public item. Invalid Id: {1}", ".", owaStoreObjectIdString));
     }
     return(OwaStoreObjectId.CreateStoreObjectId(owaStoreObjectIdString.Substring(itemPrefix.Length + 1, indexOfLastSeparatorChar - itemPrefix.Length - 1)));
 }
コード例 #2
0
        internal static OwaStoreObjectId CreateFromString(string owaStoreObjectIdString)
        {
            OwaStoreObjectIdType owaStoreObjectIdType = OwaStoreObjectIdType.MailBoxObject;

            if (owaStoreObjectIdString.StartsWith("PSF.", StringComparison.Ordinal))
            {
                owaStoreObjectIdType = OwaStoreObjectIdType.PublicStoreFolder;
            }
            else if (owaStoreObjectIdString.StartsWith("PSI.", StringComparison.Ordinal))
            {
                owaStoreObjectIdType = OwaStoreObjectIdType.PublicStoreItem;
            }
            else if (owaStoreObjectIdString.StartsWith("OUM.", StringComparison.Ordinal))
            {
                owaStoreObjectIdType = OwaStoreObjectIdType.OtherUserMailboxObject;
            }
            else if (owaStoreObjectIdString.StartsWith("CID.", StringComparison.Ordinal))
            {
                owaStoreObjectIdType = OwaStoreObjectIdType.Conversation;
            }
            else if (owaStoreObjectIdString.StartsWith("AMB.", StringComparison.Ordinal))
            {
                owaStoreObjectIdType = OwaStoreObjectIdType.ArchiveMailboxObject;
            }
            else if (owaStoreObjectIdString.StartsWith("ACI.", StringComparison.Ordinal))
            {
                owaStoreObjectIdType = OwaStoreObjectIdType.ArchiveConversation;
            }
            else if (owaStoreObjectIdString.StartsWith("GS.", StringComparison.Ordinal))
            {
                owaStoreObjectIdType = OwaStoreObjectIdType.GSCalendar;
            }
            StoreObjectId folderStoreObjectId  = null;
            StoreObjectId folderStoreObjectId2 = null;
            string        text = null;

            switch (owaStoreObjectIdType)
            {
            case OwaStoreObjectIdType.PublicStoreFolder:
                folderStoreObjectId = OwaStoreObjectId.CreateStoreObjectId(owaStoreObjectIdString.Substring("PSF".Length + 1));
                OwaStoreObjectId.ValidateFolderId(folderStoreObjectId);
                break;

            case OwaStoreObjectIdType.PublicStoreItem:
            {
                int num = owaStoreObjectIdString.LastIndexOf(".", StringComparison.Ordinal);
                if (num == "PSI".Length)
                {
                    throw new OwaInvalidIdFormatException(string.Format("There should be two separator \"{0}\" in the id of the public item. Invalid Id string: {1}", ".", owaStoreObjectIdString));
                }
                folderStoreObjectId2 = OwaStoreObjectId.CreateStoreObjectId(owaStoreObjectIdString.Substring("PSI".Length + 1, num - "PSI".Length - 1));
                folderStoreObjectId  = OwaStoreObjectId.CreateStoreObjectId(owaStoreObjectIdString.Substring(num + 1));
                OwaStoreObjectId.ValidateFolderId(folderStoreObjectId2);
                break;
            }

            case OwaStoreObjectIdType.Conversation:
            {
                string[] array = owaStoreObjectIdString.Split(new char[]
                    {
                        "."[0]
                    });
                OwaStoreObjectId result;
                if (array.Length == 4)
                {
                    result = new OwaStoreObjectId(ConversationId.Create(array[1]), string.IsNullOrEmpty(array[2]) ? null : OwaStoreObjectId.CreateStoreObjectId(array[2]), string.IsNullOrEmpty(array[3]) ? null : OwaStoreObjectId.CreateInstanceKey(array[3]));
                }
                else if (array.Length == 3)
                {
                    result = new OwaStoreObjectId(ConversationId.Create(array[1]), OwaStoreObjectId.CreateStoreObjectId(array[2]), null);
                }
                else
                {
                    if (array.Length != 2)
                    {
                        throw new OwaInvalidRequestException(string.Format("There should be one or two separator \"{0}\" in the id of the conversation item", "."));
                    }
                    result = new OwaStoreObjectId(ConversationId.Create(array[1]), null, null);
                }
                return(result);
            }

            case OwaStoreObjectIdType.OtherUserMailboxObject:
            {
                int num = owaStoreObjectIdString.LastIndexOf(".", StringComparison.Ordinal);
                folderStoreObjectId = OwaStoreObjectId.CreateStoreObjectIdFromString(owaStoreObjectIdString, "OUM", num);
                text = OwaStoreObjectId.ParseLegacyDnBase64String(owaStoreObjectIdString.Substring(num + 1));
                break;
            }

            case OwaStoreObjectIdType.ArchiveMailboxObject:
            {
                int num = owaStoreObjectIdString.LastIndexOf(".", StringComparison.Ordinal);
                folderStoreObjectId = OwaStoreObjectId.CreateStoreObjectIdFromString(owaStoreObjectIdString, "AMB", num);
                text = OwaStoreObjectId.ParseLegacyDnBase64String(owaStoreObjectIdString.Substring(num + 1));
                break;
            }

            case OwaStoreObjectIdType.ArchiveConversation:
            {
                string[] array = owaStoreObjectIdString.Split(new char[]
                    {
                        "."[0]
                    });
                OwaStoreObjectId result;
                if (array.Length == 5)
                {
                    text   = OwaStoreObjectId.ParseLegacyDnBase64String(array[3]);
                    result = new OwaStoreObjectId(ConversationId.Create(array[1]), string.IsNullOrEmpty(array[2]) ? null : OwaStoreObjectId.CreateStoreObjectId(array[2]), text, string.IsNullOrEmpty(array[4]) ? null : OwaStoreObjectId.CreateInstanceKey(array[4]));
                }
                else if (array.Length == 4)
                {
                    text   = OwaStoreObjectId.ParseLegacyDnBase64String(array[3]);
                    result = new OwaStoreObjectId(ConversationId.Create(array[1]), OwaStoreObjectId.CreateStoreObjectId(array[2]), text, null);
                }
                else
                {
                    if (array.Length != 3)
                    {
                        throw new OwaInvalidRequestException(string.Format("There should be two or three separator \"{0}\" in the id of the archive conversation item", "."));
                    }
                    text   = OwaStoreObjectId.ParseLegacyDnBase64String(array[2]);
                    result = new OwaStoreObjectId(ConversationId.Create(array[1]), null, text, null);
                }
                return(result);
            }

            case OwaStoreObjectIdType.GSCalendar:
            {
                string[] array = owaStoreObjectIdString.Split(new char[]
                    {
                        "."[0]
                    });
                if (array.Length != 2)
                {
                    throw new OwaInvalidRequestException(string.Format("There should be two separator \"{0}\" in the id of the GS calendar item", "."));
                }
                text = OwaStoreObjectId.ParseLegacyDnBase64String(array[1]);
                break;
            }

            default:
                return(OwaStoreObjectId.CreateFromStoreObjectId(OwaStoreObjectId.CreateStoreObjectId(owaStoreObjectIdString), null));
            }
            return(new OwaStoreObjectId(owaStoreObjectIdType, folderStoreObjectId, folderStoreObjectId2, text));
        }