Exemplo n.º 1
0
        public static PublicUrl Create(string externalUrl, SharingDataType dataType, SmtpAddress smtpAddress, string folderName, SharingAnonymousIdentityCollection sharingAnonymousIdentities)
        {
            Util.ThrowOnNullOrEmptyArgument(externalUrl, "externalUrl");
            Util.ThrowOnNullArgument(dataType, "dataType");
            Util.ThrowOnNullOrEmptyArgument(dataType.ExternalName, "dataType.ExternalName");
            Util.ThrowOnNullOrEmptyArgument(folderName, "folderName");
            string text = string.Join(string.Empty, folderName.Split(".*$&+,/:;=?@\"\\<>#%{}|\\^~[]`".ToCharArray()));

            if (string.IsNullOrEmpty(text))
            {
                text = "MyCalendar";
            }
            text = text.Replace(" ", "_");
            if (sharingAnonymousIdentities != null)
            {
                string text2 = text;
                int    num   = 0;
                for (;;)
                {
                    string urlId = PublicUrl.CalculateIdentity(dataType, text2);
                    if (!sharingAnonymousIdentities.Contains(urlId))
                    {
                        goto IL_CD;
                    }
                    if (++num > 50)
                    {
                        break;
                    }
                    ExTraceGlobals.SharingTracer.TraceDebug <string, int>(0L, "PublicUrl.Create(): {0} has been used in Sharing Anonymous Identities - Appending post fix: {1}.", text, num);
                    text2 = string.Format("{0}({1})", text, num);
                }
                throw new CannotShareFolderException(ServerStrings.ExTooManyObjects("PublicUrl", num, 50));
IL_CD:
                text = text2;
            }
            string uriString = string.Format("{0}/{1}/{2}/{3}/{1}", new object[]
            {
                externalUrl.TrimEnd(new char[]
                {
                    '/'
                }),
                dataType.ExternalName,
                smtpAddress.ToString(),
                text
            });
            PublicUrl publicUrl = new PublicUrl(new Uri(uriString, UriKind.Absolute), dataType, smtpAddress, text);

            ExTraceGlobals.SharingTracer.TraceDebug <PublicUrl, string>(0L, "PublicUrl.Create(): Created an instance of PublicUrl: {0} - {1}.", publicUrl, publicUrl.TraceInfo);
            return(publicUrl);
        }
Exemplo n.º 2
0
 private PublicUrl(Uri uri, SharingDataType dataType, SmtpAddress smtpAddress, string folderName) : base(uri, dataType, PublicUrl.CalculateIdentity(dataType, folderName))
 {
     this.smtpAddress = smtpAddress;
     this.folderName  = folderName;
 }