public static void HasRoute(RouteCollection routes, string url, string body, BodyFormat bodyFormat, object expectations) { var propertyReader = new PropertyReader(); var expectedRouteValues = propertyReader.RouteValues(expectations); WebRouteAssert.HasRoute(routes, HttpMethod.Get, url, body, bodyFormat, expectedRouteValues); }
public void ForwardEvent(StoreId id, ForwardEventParameters parameters, Event updateToEvent = null, int?seriesSequenceNumber = null, string occurrencesViewPropertiesBlob = null, CommandContext commandContext = null) { using (ICalendarItemBase calendarItemBase = this.Bind(id)) { if (updateToEvent != null) { calendarItemBase.OpenAsReadWrite(); this.UpdateOnly(updateToEvent, calendarItemBase, base.GetSaveMode(updateToEvent.ChangeKey, commandContext)); } CalendarItemBase calendarItemBase2 = (CalendarItemBase)calendarItemBase; BodyFormat targetFormat = BodyFormat.TextPlain; if (parameters != null && parameters.Notes != null) { targetFormat = parameters.Notes.ContentType.ToStorageType(); } ReplyForwardConfiguration replyForwardParameters = new ReplyForwardConfiguration(targetFormat) { ShouldSuppressReadReceipt = false }; MailboxSession mailboxSession = base.Session as MailboxSession; using (MessageItem messageItem = calendarItemBase2.CreateForward(mailboxSession, CalendarItemBase.GetDraftsFolderIdOrThrow(mailboxSession), replyForwardParameters, seriesSequenceNumber, occurrencesViewPropertiesBlob)) { EventWorkflowParametersTranslator <ForwardEventParameters, ForwardEventParametersSchema> .Instance.SetPropertiesFromEntityOnStorageObject(parameters, messageItem); foreach (Recipient <RecipientSchema> recipient in parameters.Forwardees) { messageItem.Recipients.Add(new Participant(recipient.Name, recipient.EmailAddress, "SMTP")); } MeetingMessage.SendLocalOrRemote(messageItem, true, true); } } }
public VoculaPage GetPage(string site, string path, bool recursion, BodyFormat format) { path = this.Tools.NormalizePath(path); string pageFile = this.SiteDirectory + Path.DirectorySeparatorChar + site + path + $"page.{this.Lang}.md"; VoculaPage page = this.GetPage(pageFile); page.Path = path; page.Breadcrumb = this.GetBreadcrumb(site, path); page.Body = this.GetPageBody(site, path, pageFile, format); if (Directory.Exists(this.SiteDirectory + Path.DirectorySeparatorChar + site + path)) { page.Alternatives = this.Tools.GetAlternatives(Array.FindAll(Directory.GetFiles(this.SiteDirectory + Path.DirectorySeparatorChar + site + path, "*.md"), x => x.Like($"%{Path.DirectorySeparatorChar}page.%.md"))); } // Load subpages page.Children = new List <VoculaPage>(); string fullPath = this.SiteDirectory + Path.DirectorySeparatorChar + site + path; if (recursion) { if (Directory.Exists(@fullPath)) { string[] dirs = Directory.GetDirectories(@fullPath); foreach (string dir in dirs) { page.Children.Add(this.GetPage(site, dir.Replace(this.SiteDirectory + Path.DirectorySeparatorChar + site, "") + Path.DirectorySeparatorChar, recursion, BodyFormat.None)); } page.Children.Sort((x, y) => DateTime.Compare(x.Date, y.Date)); } } return(page); }
private void RestampItemCharset(Charset targetCharset, MemoryStream cachedHtml, Charset htmlCharsetDetectedFromMetaTag = null) { Charset charset = htmlCharsetDetectedFromMetaTag ?? ConvertUtils.GetItemMimeCharset(this.coreItem.PropertyBag); BodyFormat rawFormat = this.coreItem.Body.RawFormat; if (rawFormat == BodyFormat.TextHtml) { using (MemoryStream memoryStream = cachedHtml ?? this.LoadHtmlBodyInMemory()) { memoryStream.Position = 0L; using (Stream stream = this.coreItem.Body.InternalOpenBodyStream(InternalSchema.HtmlBody, PropertyOpenMode.Create)) { using (Stream stream2 = new ConverterStream(stream, new HtmlToHtml { InputEncoding = charset.GetEncoding(), OutputEncoding = targetCharset.GetEncoding(), DetectEncodingFromMetaTag = false }, ConverterStreamAccess.Write)) { Util.StreamHandler.CopyStreamData(memoryStream, stream2); } } } } this.SetItemCharset(targetCharset); }
protected override WorkState Do(WorkState currentWorkState) { this.CheckRequiredProperties(); WorkState result = new WorkState(this) { Status = Status.Succeeded, PreviousWorkState = currentWorkState }; object formatValues = new { JobName = Job.Name.Or("[JobName Not Set]"), WorkName = Job.CurrentWorkerName.Or("[WorkName Not Specified]"), Status = Job.CurrentWorkState.Status.ToString(), Message = Job.CurrentWorkState.Message.Or(" ") }; Email email = new Email(); email.Server(SmtpHost) .Port(int.Parse(Port)) .IsBodyHtml(_isBodyHtml) .From(From) .To(Recipients.DelimitSplit(",", ";")) .Subject(SubjectFormat.NamedFormat(formatValues)) .Body(BodyFormat.NamedFormat(formatValues)) .UserName(UserName) .Password(Password) .EnableSsl(_enableSsl) .Send(); return(result); }
protected static void CheckRtf(BodyFormat sourceFormat, BodyFormat targetFormat) { if (targetFormat == BodyFormat.ApplicationRtf && sourceFormat == BodyFormat.TextPlain) { throw new InvalidOperationException(ServerStrings.ExBodyFormatConversionNotSupported(sourceFormat.ToString() + "->" + targetFormat.ToString())); } }
private static BodyWriteConfiguration CreateBodyWriteConfiguration(BodyFormat bf) { BodyWriteConfiguration bodyWriteConfiguration = new BodyWriteConfiguration(bf, "utf-8"); bodyWriteConfiguration.SetTargetFormat(bf, "utf-8", BodyCharsetFlags.DisableCharsetDetection); return(bodyWriteConfiguration); }
private void WriteMessageBody() { this.limitsTracker.CountMessageBody(); BodyFormat rawFormat = this.item.Body.RawFormat; long bodySize = 0L; if (rawFormat == BodyFormat.TextHtml) { this.WriteMessageProperty(InternalSchema.HtmlBody, out bodySize); this.conversionResult.BodySize = bodySize; return; } this.WriteMessageProperty(InternalSchema.RtfSyncBodyCrc); this.WriteMessageProperty(InternalSchema.RtfSyncBodyCount); this.WriteMessageProperty(InternalSchema.RtfSyncBodyTag); this.WriteMessageProperty(InternalSchema.RtfInSync); this.WriteMessageProperty(InternalSchema.RtfSyncPrefixCount); this.WriteMessageProperty(InternalSchema.RtfSyncTrailingCount); if (rawFormat == BodyFormat.ApplicationRtf) { this.WriteMessageProperty(InternalSchema.RtfBody, out bodySize); this.conversionResult.BodySize = bodySize; return; } if (rawFormat == BodyFormat.TextPlain) { if (!this.item.Body.IsBodyDefined) { return; } using (Stream textStream = this.item.OpenPropertyStream(InternalSchema.TextBody, PropertyOpenMode.ReadOnly)) { if (this.tnefType == TnefType.SummaryTnef) { using (Stream stream = this.tnefWriter.StartStreamProperty(InternalSchema.TextBody)) { this.conversionResult.BodySize = Util.StreamHandler.CopyStreamData(textStream, stream); } textStream.Position = 0L; } using (Stream tnefStream = this.tnefWriter.StartStreamProperty(InternalSchema.RtfBody)) { int inCodePage = this.item.Body.RawCharset.CodePage; ConvertUtils.CallCts(ExTraceGlobals.CcOutboundTnefTracer, "ItemToTnefConverter::WriteMessageBody", ServerStrings.ConversionBodyConversionFailed, delegate { TextToRtf textToRtf = new TextToRtf(); textToRtf.InputEncoding = Charset.GetEncoding(inCodePage); using (Stream stream2 = new ConverterStream(textStream, textToRtf, ConverterStreamAccess.Read)) { using (ConverterStream converterStream = new ConverterStream(stream2, new RtfToRtfCompressed(), ConverterStreamAccess.Read)) { Util.StreamHandler.CopyStreamData(converterStream, tnefStream); } } }); } } } }
internal static HeaderFooterFormat GetSupportedPrefixFormat(BodyFormat format) { if (format != BodyFormat.TextPlain) { return(HeaderFooterFormat.Html); } return(HeaderFooterFormat.Text); }
// Token: 0x06001C01 RID: 7169 RVA: 0x0006D934 File Offset: 0x0006BB34 private static void SetItemBody(Item item, BodyFormat bodyFormat, string bodyContent) { BodyWriteConfiguration configuration = new BodyWriteConfiguration(bodyFormat); using (TextWriter textWriter = item.Body.OpenTextWriter(configuration)) { textWriter.Write(bodyContent); } }
private IList <RouteValue> ReadPropertiesFromBodyContent(BodyFormat bodyFormat) { var bodyTask = request.Content.ReadAsStringAsync(); var body = bodyTask.Result; var bodyReader = new BodyReader(); return(bodyReader.ReadBody(body, bodyFormat)); }
private void Init(string phoneNumber, TelcomProvider provider, BodyFormat bodyFormat = BodyFormat.Sms) { if (phoneNumber.Length != 10) { throw new Exception("phoneNumber must be length 10"); } PhoneNumber = phoneNumber; Provider = provider; BodyFormat = bodyFormat; }
public void SetTargetFormat(BodyFormat targetFormat, Charset targetCharset, BodyCharsetFlags flags) { EnumValidator.ThrowIfInvalid <BodyFormat>(targetFormat, "targetFormat"); if (targetCharset == null && (flags & BodyCharsetFlags.CharsetDetectionMask) == BodyCharsetFlags.DisableCharsetDetection) { throw new ArgumentNullException("targetCharset"); } this.targetCharset = targetCharset; this.targetFormat = targetFormat; this.targetCharsetFlags = flags; }
// Token: 0x06002EFA RID: 12026 RVA: 0x0010E534 File Offset: 0x0010C734 private void ProcessApprovalResponse(bool isEdit) { MessageItem requestItem; MessageItem messageItem = requestItem = base.GetRequestItem <MessageItem>(ReadMessageEventHandler.ApprovalPrefetchProperties); try { if (!Utilities.IsValidUndecidedApprovalRequest(messageItem)) { throw new OwaInvalidRequestException("The approval request was invalid or was already decided"); } string[] array = (string[])messageItem.VotingInfo.GetOptionsList(); string text = (string)base.GetParameter("Vt"); if (string.IsNullOrEmpty(text)) { throw new OwaInvalidRequestException("The approval vote was not supplied."); } if (array == null || Array.IndexOf <string>(array, text) == -1) { throw new OwaInvalidRequestException("The attempted approval vote was invalid for the approval request."); } BodyFormat replyForwardBodyFormat = ReplyForwardUtilities.GetReplyForwardBodyFormat(messageItem, base.UserContext); OwaStoreObjectId owaStoreObjectId = (OwaStoreObjectId)base.GetParameter("fId"); MessageItem messageItem3; MessageItem messageItem2 = messageItem3 = messageItem.CreateVotingResponse(string.Empty, replyForwardBodyFormat, base.UserContext.TryGetMyDefaultFolderId(DefaultFolderType.Drafts), text); try { messageItem2.Save(SaveMode.ResolveConflicts); messageItem2.Load(); if (!isEdit) { messageItem2.Send(); } else { base.WriteNewItemId(messageItem2); } } finally { if (messageItem3 != null) { ((IDisposable)messageItem3).Dispose(); } } } finally { if (requestItem != null) { ((IDisposable)requestItem).Dispose(); } } }
public void SetTargetFormat(BodyFormat targetFormat, string targetCharsetName, BodyCharsetFlags flags) { EnumValidator.ThrowIfInvalid <BodyFormat>(targetFormat, "targetFormat"); Charset charset = null; if (!string.IsNullOrEmpty(targetCharsetName)) { charset = ConvertUtils.GetCharsetFromCharsetName(targetCharsetName); } this.SetTargetFormat(targetFormat, charset, flags); }
internal ReplyForwardConfiguration(BodyFormat targetFormat, ForwardCreationFlags flags, CultureInfo culture) { EnumValidator.ThrowIfInvalid <BodyFormat>(targetFormat, "targetFormat"); EnumValidator.ThrowIfInvalid <ForwardCreationFlags>(flags, "flags"); this.targetFormat = targetFormat; this.forwardCreationFlags = flags; this.culture = culture; this.bodyPrefix = null; this.conversionCallbacks = null; this.subjectPrefix = null; }
/// <summary> /// Gets the hash code /// </summary> /// <returns>Returns HashCode</returns> public override int GetHashCode() { return(String.Format("{0}|{1}|{2}|{3}|{4}|{5}|", this.Parameters.Aggregate(0, (acc, next) => acc += next.GetHashCode()), Kind.GetHashCode(), Url?.GetHashCode() ?? 0, Method.GetHashCode(), BodyFormat.GetHashCode(), Async.GetHashCode() ).GetHashCode()); }
private AipHttpRequest() { Headers = new Dictionary <string, string>(); // 所有Url中附带aipSdk=CSharp参数 Querys = new Dictionary <string, string> { { "aipSdk", "CSharp" } }; Bodys = new Dictionary <string, object>(); Method = "GET"; BodyType = BodyFormat.Formed; ContentEncoding = Encoding.UTF8; }
public BodyReadConfiguration(BodyFormat targetFormat) { EnumValidator.ThrowIfInvalid <BodyFormat>(targetFormat, "targetFormat"); this.format = targetFormat; this.charset = null; this.injectPrefix = null; this.injectSuffix = null; this.injectFormat = BodyInjectionFormat.Text; this.conversionCallback = null; this.htmlFlags = HtmlStreamingFlags.None; this.styleSheetLimit = null; }
private AipHttpRequest() { Headers = new Dictionary <string, string>(); // 所有Url中附带aipSdk=CSharp参数 Querys = new Dictionary <string, string> { { "aipSdk", "CSharp" } }; Bodys = new Dictionary <string, object>(); Method = "GET"; BodyType = BodyFormat.Formed; ContentEncoding = Encoding.UTF8; System.Net.ServicePointManager.Expect100Continue = false; }
public BodyWriteConfiguration(BodyFormat sourceFormat, Charset sourceCharset) { EnumValidator.ThrowIfInvalid <BodyFormat>(sourceFormat, "sourceFormat"); this.sourceFormat = sourceFormat; this.sourceCharset = sourceCharset; this.targetFormat = this.sourceFormat; this.targetCharset = this.sourceCharset; this.targetCharsetFlags = BodyCharsetFlags.None; this.injectPrefix = null; this.injectSuffix = null; this.injectFormat = BodyInjectionFormat.Text; this.htmlFlags = HtmlStreamingFlags.None; }
public PreFormActionResponse Execute(OwaContext owaContext, out ApplicationElement applicationElement, out string type, out string state, out string action) { if (owaContext == null) { throw new ArgumentNullException("owaContext"); } applicationElement = ApplicationElement.Item; type = string.Empty; action = string.Empty; state = string.Empty; PreFormActionResponse preFormActionResponse = new PreFormActionResponse(); Item item = null; Item item2 = null; Item item3 = null; try { HttpContext httpContext = owaContext.HttpContext; UserContext userContext = owaContext.UserContext; string queryStringParameter = Utilities.GetQueryStringParameter(httpContext.Request, "fId", true); item = ReplyForwardUtilities.GetItemForRequest(owaContext, out item2); BodyFormat replyForwardBodyFormat = ReplyForwardUtilities.GetReplyForwardBodyFormat(item, userContext); item3 = ReplyForwardUtilities.CreatePostReplyItem(replyForwardBodyFormat, item as PostItem, userContext, Utilities.GetParentFolderId(item2, item)); item3.Save(SaveMode.ResolveConflicts); item3.Load(); preFormActionResponse.ApplicationElement = ApplicationElement.Item; preFormActionResponse.Type = "IPM.Post"; preFormActionResponse.Action = "PostReply"; preFormActionResponse.AddParameter("Id", OwaStoreObjectId.CreateFromStoreObject(item3).ToBase64String()); preFormActionResponse.AddParameter("fId", queryStringParameter); } finally { if (item != null) { item.Dispose(); item = null; } if (item2 != null) { item2.Dispose(); item2 = null; } if (item3 != null) { item3.Dispose(); item3 = null; } } return(preFormActionResponse); }
internal static ItemBody GetEntityBody(this IItem input, char[] buffer) { Body body; BodyType bodyType; try { body = IrmUtils.GetBody(input); BodyFormat format = body.Format; bodyType = format.ToEntityType(); } catch (PropertyErrorException ex) { ExTraceGlobals.CommonTracer.TraceDebug <string, string>(0L, "[BodyConverter::GetEntityBody] Encountered exception - Class: {0}; Message: {1}", ex.GetType().FullName, ex.Message); throw new CorruptDataException(Strings.ErrorItemCorrupt, ex); } catch (StoragePermanentException ex2) { if (ex2.InnerException is MapiExceptionNoSupport) { throw new CorruptDataException(Strings.ErrorItemCorrupt, ex2); } ExTraceGlobals.CommonTracer.TraceDebug(0L, "[BodyConverter::GetEntityBody] Encountered exception - Class: {0}, Message: {1} Inner exception was not MapiExceptionNoSupport but rather Class: {2}; Message: {3}", new object[] { ex2.GetType().FullName, ex2.Message, (ex2.InnerException == null) ? "<NULL>" : ex2.InnerException.GetType().FullName, (ex2.InnerException == null) ? "<NULL>" : ex2.InnerException.Message }); throw; } ItemBody itemBody = new ItemBody { ContentType = bodyType }; using (TextWriter textWriter = new StringWriter()) { if (bodyType == BodyType.Html) { BodyConverter.WriteHtmlContent(textWriter, input, buffer); } else { BodyConverter.WriteTextContent(textWriter, body, buffer); } itemBody.Content = textWriter.ToString(); } return(itemBody); }
internal static string GetItemBody(Item item, BodyFormat desiredFormat) { if (item == null) { throw new ArgumentNullException("item"); } string result; using (TextReader textReader = item.Body.OpenTextReader(desiredFormat)) { result = textReader.ReadToEnd(); } return(result); }
internal static BodyType ToEntityType(this BodyFormat input) { switch (input) { case BodyFormat.TextPlain: return(BodyType.Text); case BodyFormat.TextHtml: case BodyFormat.ApplicationRtf: return(BodyType.Html); default: throw new ArgumentOutOfRangeException("input"); } }
public static EmailMessage Create(BodyFormat bodyFormat, bool createAlternative, string charsetName) { if (bodyFormat != BodyFormat.Text && bodyFormat != BodyFormat.Html) { throw new ArgumentException(EmailMessageStrings.CannotCreateSpecifiedBodyFormat(bodyFormat.ToString())); } if (bodyFormat == BodyFormat.Text && createAlternative) { throw new ArgumentException(EmailMessageStrings.CannotCreateAlternativeBody); } Charset.GetCharset(charsetName); MimeTnefMessage mimeTnefMessage = new MimeTnefMessage(bodyFormat, createAlternative, charsetName); return(new EmailMessage(mimeTnefMessage)); }
private void SyncNotes(ContactItemType remoteItem, Contact localItem) { string text = string.Empty; BodyFormat bodyFormat = BodyFormat.TextPlain; if (remoteItem.Body != null) { text = remoteItem.Body.Value; bodyFormat = this.Convert(remoteItem.Body.BodyType1); ItemSynchronizer.Tracer.TraceDebug <ContactItemSynchronizer, string>((long)this.GetHashCode(), "{0}: Copying body: {1}", this, text); } using (TextWriter textWriter = localItem.Body.OpenTextWriter(bodyFormat)) { textWriter.Write(text); } }
internal static void HasRoute(RouteCollection routes, HttpMethod method, string url, string body, BodyFormat bodyFormat, RouteValues expectedProps) { var pathUrl = UrlHelpers.PrependTilde(url); var httpContext = HttpMockery.ContextForUrl(method, pathUrl, body); var routeData = GetRouteDataWithAttributeFilter(routes, httpContext); if (routeData == null) { var message = string.Format("Should have found the route to '{0}'", url); Asserts.Fail(message); } var webRouteReader = new Reader(); var actualProps = webRouteReader.GetRequestProperties(routeData, httpContext.Request, bodyFormat); var verifier = new Verifier(expectedProps, actualProps, url); verifier.VerifyExpectations(); }
internal static StorePropertyDefinition GetBodyProperty(BodyFormat bodyFormat) { switch (bodyFormat) { case BodyFormat.TextPlain: return(InternalSchema.TextBody); case BodyFormat.TextHtml: return(InternalSchema.HtmlBody); case BodyFormat.ApplicationRtf: return(InternalSchema.RtfBody); default: throw new ArgumentOutOfRangeException("bodyFormat", string.Format("Invalid body format: {0}.", bodyFormat)); } }
private static string CreatePostReplyForwardHeader(BodyFormat bodyFormat, Item item, UserContext userContext, string postToFolderName) { PostItem postItem = item as PostItem; if (postItem == null) { throw new ArgumentException("OWA logic error . CreatePostReplyForwardheader is called on a non-PostItem item."); } if (postToFolderName == null) { throw new ArgumentNullException("postToFolderName"); } if (string.Empty == postToFolderName) { throw new ArgumentException("postToFolderName should not be empty. "); } StringBuilder stringBuilder = new StringBuilder(); bool outputHtml = BodyFormat.TextHtml == bodyFormat; if (postItem.Sender != null) { if (Utilities.IsOnBehalfOf(postItem.Sender, postItem.From)) { stringBuilder.Append(string.Format(LocalizedStrings.GetHtmlEncoded(-1426120402), ReplyForwardUtilities.GetParticipantDisplayString(postItem.Sender, outputHtml), ReplyForwardUtilities.GetParticipantDisplayString(postItem.From, outputHtml))); } else { ReplyForwardUtilities.AppendParticipantDisplayString(postItem.Sender, stringBuilder, outputHtml); } } string fromLabel = string.Empty; switch (bodyFormat) { case BodyFormat.TextPlain: fromLabel = LocalizedStrings.GetNonEncoded(-1376223345); return(ReplyForwardUtilities.CreatePostTextReplyForwardHeader(postItem, userContext, fromLabel, stringBuilder.ToString(), postToFolderName)); case BodyFormat.TextHtml: fromLabel = LocalizedStrings.GetHtmlEncoded(-1376223345); return(ReplyForwardUtilities.CreatePostHtmlReplyForwardHeader(postItem, userContext, fromLabel, stringBuilder.ToString(), postToFolderName)); default: throw new ArgumentException("Unsupported body format"); } }
public static Item CreatePostReplyItem(BodyFormat bodyFormat, PostItem item, UserContext userContext, StoreObjectId parentFolderId) { PostItem postItem = null; bool flag = true; try { string bodyPrefix = ReplyForwardUtilities.CreateReplyForwardHeader(bodyFormat, item, userContext, parentFolderId); string legacyDN = null; OwaStoreObjectIdType owaStoreObjectIdType = Utilities.GetOwaStoreObjectIdType(userContext, item); if (owaStoreObjectIdType == OwaStoreObjectIdType.OtherUserMailboxObject) { legacyDN = Utilities.GetMailboxSessionLegacyDN(item); } OwaStoreObjectId destinationFolderId = OwaStoreObjectId.CreateFromFolderId(parentFolderId, owaStoreObjectIdType, legacyDN); OwaStoreObjectId scratchPadForImplicitDraft = Utilities.GetScratchPadForImplicitDraft(StoreObjectType.Post, destinationFolderId); try { ReplyForwardConfiguration replyForwardConfiguration = new ReplyForwardConfiguration(bodyFormat); replyForwardConfiguration.ConversionOptionsForSmime = Utilities.CreateInboundConversionOptions(userContext); replyForwardConfiguration.AddBodyPrefix(bodyPrefix); postItem = item.ReplyToFolder(scratchPadForImplicitDraft.GetSession(userContext), scratchPadForImplicitDraft.StoreObjectId, replyForwardConfiguration); } catch (StoragePermanentException ex) { if (ex.InnerException is MapiExceptionNoCreateRight) { throw new OwaAccessDeniedException(LocalizedStrings.GetNonEncoded(995407892), ex); } throw ex; } ReplyForwardUtilities.CopyMessageClassificationProperties(item, postItem, userContext); Utilities.SetPostSender(postItem, userContext, Utilities.IsPublic(item)); postItem.ConversationTopic = item.ConversationTopic; flag = false; } finally { if (flag && postItem != null) { postItem.Dispose(); postItem = null; } } return(postItem); }
public IList<RouteValue> ReadBody(string body, BodyFormat bodyFormat) { switch (bodyFormat) { case BodyFormat.FormUrl: var formUrlReader = new FormUrlBodyReader(); return formUrlReader.ReadBody(body); case BodyFormat.Json: var jsonReader = new JsonBodyReader(); return jsonReader.ReadBody(body); case BodyFormat.None: return new List<RouteValue>(); default: throw new ApplicationException("Unknown body format: " + bodyFormat); } }
public RouteValues GetRequestProperties(RouteData routeData, HttpRequestBase request, BodyFormat bodyFormat) { RouteValues result; if (routeData == null) { result = new RouteValues(); } else { result = new RouteValues(routeData.Values); } var requestParams = ReadRequestParams(request.Params); result.AddRange(requestParams); var bodyContent = ReadPropertiesFromBodyContent(request, bodyFormat); result.AddRange(bodyContent); result.Area = ReadAreaFromRouteData(routeData); return result; }
public MimeBody(BodyFormat format) { this._format = format; }
public static void HasApiRoute(HttpConfiguration config, string url, HttpMethod httpMethod, string body, BodyFormat bodyFormat, object expectations) { HasApiRoute(config, url, httpMethod, null, body, bodyFormat, expectations); }
public static IAsyncResult BeginQuickDirectSend(string from, string to, string subject, string body, BodyFormat bodyFormat, string attachmentPath, AsyncCallback callback) { SmtpClient._delegateQuickDirectSendAttach = SmtpClient.QuickDirectSend; return SmtpClient._delegateQuickDirectSendAttach.BeginInvoke(from, to, subject, body, bodyFormat, attachmentPath, callback, SmtpClient._delegateQuickDirectSendAttach); }
/// <summary> /// Creates the body template based on the specified content and format. /// </summary> /// <param name="content">The content.</param> /// <param name="format">The format to use.</param> public BodyTemplate(string content, BodyFormat format) { _content = content; _format = format; }
public static void HasRoute(RouteCollection routes, string url, HttpMethod httpMethod, string body, BodyFormat bodyFormat, IDictionary<string, string> expectedProps) { var expectedRouteValues = new RouteValues(expectedProps); WebRouteAssert.HasRoute(routes, httpMethod, url, body, bodyFormat, expectedRouteValues); }
public static void HasApiRoute(HttpConfiguration config, string url, HttpMethod httpMethod, string body, BodyFormat bodyFormat, IDictionary<string, string> expectedProps) { var expectedRouteValues = new RouteValues(expectedProps); ApiRouteAssert.HasRoute(config, url, httpMethod, body, bodyFormat, expectedRouteValues); }
public static void HasApiRoute(HttpConfiguration config, string url, HttpMethod httpMethod, string body, BodyFormat bodyFormat, object expectations) { var propertyReader = new PropertyReader(); var expectedProps = propertyReader.RouteValues(expectations); ApiRouteAssert.HasRoute(config, url, httpMethod, body, bodyFormat, expectedProps); }
private IList<RouteValue> ReadPropertiesFromBodyContent(HttpRequestBase request, BodyFormat bodyFormat) { var body = GetRequestBody(request); var bodyReader = new BodyReader(); return bodyReader.ReadBody(body, bodyFormat); }
/// <summary> /// This static method allows to send an email in 1 line of code. /// </summary> /// <param name="from">The email address of the person sending the message.</param> /// <param name="to">The email address of the message's recipient.</param> /// <param name="subject">The message's subject.</param> /// <param name="textBody">The text body of the message.</param> /// <param name="attachmentPath">The path to a file to be attached to the message.</param> /// <example> /// C# /// /// SmtpClient.QuickDirectSend("*****@*****.**","*****@*****.**","Test","Hello this is a test!",BodyFormat.Text,"C:\\My Documents\\file.doc"); /// /// VB.NET /// /// SmtpClient.QuickDirectSend("*****@*****.**","*****@*****.**","Test","Hello this is a test!",BodyFormat.Text,"C:\My Documents\file.doc") /// /// JScript.NET /// /// SmtpClient.QuickDirectSend("*****@*****.**","*****@*****.**","Test","Hello this is a test!",BodyFormat.Text,"C:\\My Documents\\file.doc"); /// </example> public static void QuickDirectSend(string from, string to, string subject, string body, BodyFormat bodyFormat, string attachmentPath) { ActiveUp.Net.Mail.SmtpClient.QuickSend(from, to, subject, body, bodyFormat, attachmentPath, string.Empty); /*ActiveUp.Net.Mail.Message message = new ActiveUp.Net.Mail.Message(); //message.From.Add(new ActiveUp.Net.Mail.Address(from)); message.From = new ActiveUp.Net.Mail.Address(from); message.To.Add(to); message.Subject = subject; if (bodyFormat == BodyFormat.Text) message.BodyText.Text = body; else message.BodyHtml.Text = body; if (!string.IsNullOrEmpty(attachmentPath)) message.Attachments.Add(attachmentPath, false); message.DirectSend();*/ }
/// <summary> /// Creates the body template based on the specified content. The default format is Text. /// </summary> /// <param name="content">The content.</param> public BodyTemplate(string content) { _content = content; _format = BodyFormat.Text; }
/// <summary> /// Add a templated body in the collection based on the specified content and body format. /// </summary> /// <param name="content">The content to use.</param> /// <param name="format">The message body format.</param> public void Add(string content, BodyFormat format) { List.Add(new BodyTemplate(content, format)); }
/// <summary> /// The default constructor. /// </summary> public BodyTemplate() { _content = string.Empty; _format = BodyFormat.Text; }
/// <summary> /// This static method allows to send an email in 1 line of code. /// </summary> /// <param name="from">The email address of the person sending the message.</param> /// <param name="to">The email address of the message's recipient.</param> /// <param name="subject">The message's subject.</param> /// <param name="textBody">The text body of the message.</param> /// <example> /// C# /// /// SmtpClient.QuickSend("*****@*****.**","*****@*****.**","Test","Hello this is a test!",BodyFormat.Text,"C:\\My Documents\\file.doc","mail.myhost.com"); /// /// VB.NET /// /// SmtpClient.QuickSend("*****@*****.**","*****@*****.**","Test","Hello this is a test!",BodyFormat.Text,"C:\My Documents\file.doc","mail.myhost.com") /// /// JScript.NET /// /// SmtpClient.QuickSend("*****@*****.**","*****@*****.**","Test","Hello this is a test!",BodyFormat.Text,"C:\\My Documents\\file.doc","mail.myhost.com"); /// </example> public static void QuickSend(string from, string to, string subject, string body, BodyFormat bodyFormat, string attachmentPath, string smtpServer) { ActiveUp.Net.Mail.SmtpMessage message = new ActiveUp.Net.Mail.SmtpMessage(); message.From = new ActiveUp.Net.Mail.Address(from); message.To.Add(to); message.Subject = subject; if (bodyFormat == BodyFormat.Text) message.BodyText.Text = body; else message.BodyHtml.Text = body; if (!string.IsNullOrEmpty(attachmentPath)) message.Attachments.Add(attachmentPath, false); if (!string.IsNullOrEmpty(smtpServer)) message.Send(smtpServer); else message.DirectSend(); }