protected virtual void SendPushRegistration(ReactorVirtualClient c) { EosPacket p = new EosPacket(); p.Sender = ReactorServer.Id; p.Type = EosPacketType.Registered; p.Data.Add(Encoding.Unicode.GetBytes(TimeToLive.ToString())); c.SendPacket(p.ToBytes()); }
public override string ToString() { List <string> slug = new List <string>(); slug.Add(@"--" + OPT_TIMETOLIVE + "=" + BaconArgs.Escape(TimeToLive.ToString())); slug.Add(@"--" + OPT_TIMECREATED + "=" + BaconArgs.Escape(DateTimeToTimestamp(TimeCreated).ToString())); slug.Add(@"--" + OPT_TYPE + "=" + BaconArgs.Escape(Type)); slug.Add(@"--" + OPT_SENDER + "=" + BaconArgs.Escape(Sender)); slug.Add(@"--"); slug.Add(Content); return(string.Join(" ", slug)); }
public XElement CreateHttpBody() { var payloadElement = new XElement("Payload"); if (Payload != null && Payload.Root != null) { payloadElement.Add(Payload.Root); } else { payloadElement.Value = "#WARNING: No payload"; } var binaryPayloadElement = new XElement("BinaryPayload"); if (BinaryPayload != null) { binaryPayloadElement.Value = Convert.ToBase64String(BinaryPayload); } else { binaryPayloadElement.Value = "#WARNING: No binary payload"; } return(new XElement("AMQPMessage", payloadElement, binaryPayloadElement, new XElement("ApplicationTimestamp", ApplicationTimestamp), new XElement("ContentType", ContentType), new XElement("CorrelationId", CorrelationId), new XElement("CpaId", CpaId), new XElement("EnqueuedTimeUtc", EnqueuedTimeUtc), new XElement("ScheduledEnqueueTimeUtc", ScheduledEnqueueTimeUtc), new XElement("TimeToLive", TimeToLive.ToString()), new XElement("To", To), new XElement("ToHerId", ToHerId), new XElement("FromHerId", FromHerId), new XElement("MessageFunction", MessageFunction), new XElement("MessageId", MessageId), new XElement("ReplyTo", ReplyTo) )); }
/// <summary> /// Creates a string representation of the IpPacket object. /// </summary> public override string ToString() { var s = new StringBuilder(); s.Append("IP version: "); s.AppendLine(IpVersion.ToString()); s.Append("Internet Header Length "); s.AppendLine(InternetHeaderLength.ToString()); s.Append("DSCP value "); s.AppendLine(DscpValue.ToString()); s.Append("ECN value "); s.AppendLine(ExplicitCongestionNotice.ToString()); s.Append("IP packet length "); s.AppendLine(IpPacketLength.ToString()); s.Append("ID/Fragment Group "); s.AppendLine(FragmentGroupId.ToString()); s.Append("IP header flags "); s.AppendLine(IpHeaderFlags.ToString()); s.Append("Fragment offset "); s.AppendLine(FragmentOffset.ToString()); s.Append("TTL "); s.AppendLine(TimeToLive.ToString()); s.Append("Protocol Number "); s.AppendLine(ProtocolNumber.ToString()); s.Append("Header Checksum "); s.AppendLine(PacketHeaderChecksum.ToString()); s.Append("Source IP "); s.AppendLine(SourceIpAddress.ToString()); s.Append("Destination IP "); s.AppendLine(DestinationIpAddress.ToString()); if (IpOptions != null) { s.Append("Length of IP options "); s.AppendLine(IpOptions.Length.ToString()); } s.Append("Packet Data Length "); s.AppendLine(PacketData.Length.ToString()); s.Append("Size of data buffer processed "); s.AppendLine(DataBuffer.Length.ToString()); return(s.ToString()); }
public override string ToString() { StringBuilder result = new StringBuilder(); result.Append("BEGIN:VCALENDAR"); result.Append(Constants.CrLf); result.Append("PRODID:"); result.Append(ProductId); result.Append(Constants.CrLf); //The following two lines seem to be required by Outlook to get the alarm settings (Version and Method) result.Append("VERSION:2.0"); result.Append(Constants.CrLf); result.Append("METHOD:PUBLISH"); result.Append(Constants.CrLf); result.Append("X-WR-CALNAME:"); result.Append(Name); result.Append(Constants.CrLf); result.Append("X-WR-CALDESC:"); result.Append(Description); result.Append(Constants.CrLf); result.Append("X-PUBLISHED-TTL:PT"); result.Append(TimeToLive.ToString()); result.Append("M"); result.Append(Constants.CrLf); foreach (var evnt in Events) { result.Append(evnt.ToString()); } result.Append("END:VCALENDAR"); return(result.ToString()); }
/// <summary cref="Packet.ToString(StringOutputType)" /> public override string ToString(StringOutputType outputFormat) { var buffer = new StringBuilder(); string color = ""; string colorEscape = ""; if (outputFormat == StringOutputType.Colored || outputFormat == StringOutputType.VerboseColored) { color = Color; colorEscape = AnsiEscapeSequences.Reset; } if (outputFormat == StringOutputType.Normal || outputFormat == StringOutputType.Colored) { // build the output string buffer.AppendFormat("{0}[IPv4Packet: SourceAddress={2}, DestinationAddress={3}, HeaderLength={4}, Protocol={5}, TimeToLive={6}]{1}", color, colorEscape, SourceAddress, DestinationAddress, HeaderLength, Protocol, TimeToLive); } if (outputFormat == StringOutputType.Verbose || outputFormat == StringOutputType.VerboseColored) { // collect the properties and their value Dictionary <string, string> properties = new Dictionary <string, string>(); properties.Add("version", Version.ToString()); // FIXME: Header length output is incorrect properties.Add("header length", HeaderLength + " bytes"); string diffServices = Convert.ToString(DifferentiatedServices, 2).PadLeft(8, '0').Insert(4, " "); properties.Add("differentiated services", "0x" + DifferentiatedServices.ToString("x").PadLeft(2, '0')); properties.Add("", diffServices.Substring(0, 7) + ".. = [" + (DifferentiatedServices >> 2) + "] code point"); properties.Add(" ", ".... .." + diffServices[6] + ". = [" + diffServices[6] + "] ECN"); properties.Add(" ", ".... ..." + diffServices[7] + " = [" + diffServices[7] + "] ECE"); properties.Add("total length", TotalLength.ToString()); properties.Add("identification", "0x" + Id.ToString("x") + " (" + Id + ")"); string flags = Convert.ToString(FragmentFlags, 2).PadLeft(8, '0').Substring(5, 3); properties.Add("flags", "0x" + FragmentFlags.ToString("x").PadLeft(2, '0')); properties.Add(" ", flags[0] + ".. = [" + flags[0] + "] reserved"); properties.Add(" ", "." + flags[1] + ". = [" + flags[1] + "] don't fragment"); properties.Add(" ", ".." + flags[2] + " = [" + flags[2] + "] more fragments"); properties.Add("fragment offset", FragmentOffset.ToString()); properties.Add("time to live", TimeToLive.ToString()); properties.Add("protocol", Protocol.ToString() + " (0x" + Protocol.ToString("x") + ")"); properties.Add("header checksum", "0x" + Checksum.ToString("x") + " [" + (ValidChecksum ? "valid" : "invalid") + "]"); properties.Add("source", SourceAddress.ToString()); properties.Add("destination", DestinationAddress.ToString()); // calculate the padding needed to right-justify the property names int padLength = Utils.RandomUtils.LongestStringLength(new List <string>(properties.Keys)); // build the output string buffer.AppendLine("IP: ******* IPv4 - \"Internet Protocol (Version 4)\" - offset=? length=" + TotalPacketLength); buffer.AppendLine("IP:"); foreach (var property in properties) { if (property.Key.Trim() != "") { buffer.AppendLine("IP: " + property.Key.PadLeft(padLength) + " = " + property.Value); } else { buffer.AppendLine("IP: " + property.Key.PadLeft(padLength) + " " + property.Value); } } buffer.AppendLine("IP:"); } // append the base class output buffer.Append(base.ToString(outputFormat)); return(buffer.ToString()); }
public override string ToString() { var a = new List <string>(); a.Add(@"--" + OPT_TIMETOLIVE + "=" + l.Escape(TimeToLive.ToString())); a.Add(@"--" + OPT_TIMECREATED + "=" + l.Escape(i(TimeCreated).ToString())); a.Add(@"--" + OPT_TYPE + "=" + l.Escape(Type)); a.Add(@"--" + OPT_SENDER + "=" + l.Escape(Sender)); a.Add(@"--"); a.Add(Content); return(string.Join(" ", a)); }
/// <summary> /// Liefert ein XDocument, welches die Daten des Feeds im RSS Format beinhaltet. /// </summary> /// <returns>Ein XDokument mit den Daten des Feeds im RSS Format.</returns> private XDocument GetDocumentFromData() { XDocument doc = new XDocument(); XElement root = doc.Root; XElement rss = new XElement("rss"); XElement channel = new XElement("channel"); if (Categories.Count > 0) { foreach (RSSFeedCategory cat in Categories) { XElement el = new XElement("category") { Value = cat.CategoryName, }; if (cat.Domain != "") { XAttribute at = new XAttribute("domain", cat.Domain); el.Add(at); } channel.Add(el); } } if (Copyrights != "") { channel.Add(new XElement("copyright") { Value = Copyrights, }); } if (Description != "") { channel.Add(new XElement("description") { Value = Description, }); } else { throw new ArgumentNullException("RSSFeed.Description", "A description is required in RSS documents."); } if (Docs != "") { channel.Add(new XElement("docs") { Value = Docs, }); } if (Generator != "") { channel.Add(new XElement("generator") { Value = Generator, }); } if (Image.Url != "") { if (Image.Link == "") { throw new ArgumentNullException("RSSFeed.ImageLink", "A link is required in RSS documents width image."); } if (Image.Title == "") { throw new ArgumentNullException("RSSFeed.ImageTitle", "A title is required in RSS documents width image."); } if (Image.Url == "") { throw new ArgumentNullException("RSSFeed.ImageUrl", "A url is required in RSS documents width image."); } XElement el = new XElement("image"); if (Image.Height != 31) { XAttribute imgHeight = new XAttribute("height", Image.Height.ToString()); el.Add(imgHeight); } if (Image.Width != 88) { XAttribute imgWidth = new XAttribute("width", Image.Width.ToString()); el.Add(imgWidth); } if (Description != "") { XAttribute imgDescription = new XAttribute("description", ImageDescription); el.Add(imgDescription); } XAttribute imgLink = new XAttribute("link", Image.Link); el.Add(imgLink); XAttribute imgTitle = new XAttribute("title", Image.Title); el.Add(imgTitle); XAttribute imgUrl = new XAttribute("url", Image.Url); el.Add(imgUrl); channel.Add(el); } if (Language != CultureInfo.InvariantCulture) { channel.Add(new XElement("language") { Value = Language.Name, }); } if (Updated != DateTime.MinValue) { channel.Add(new XElement("lastBuildDate") { Value = Updated.ToString("R"), }); } if (ArticleUrl != "") { channel.Add(new XElement("link") { Value = ArticleUrl, }); } else { throw new ArgumentNullException("RSSFeed.ArticleUrl", "A url to the articel is required in RSS documents."); } if (Author != "") { channel.Add(new XElement("managingEditor") { Value = Author, }); } if (Published != DateTime.MinValue) { channel.Add(new XElement("pubDate") { Value = Updated.ToString("R"), }); } if (SkipDays.Count > 0) { XElement e = new XElement("skipDays"); foreach (string s in SkipDays) { XElement el = new XElement("day") { Value = s, }; e.Add(el); } channel.Add(e); } if (SkipHours.Count > 0) { XElement e = new XElement("skipHours"); foreach (byte s in SkipHours) { XElement el = new XElement("hour") { Value = s.ToString(), }; e.Add(el); } channel.Add(e); } if (TextInput.Description != "") { if (TextInput.Description == "") { throw new ArgumentNullException("RSSFeed.TextInputDescription", "A description is required in RSS documents width TextInput field."); } if (TextInput.Link == "") { throw new ArgumentNullException("RSSFeed.TextInputLink", "A link is required in RSS documents width TextInput field."); } if (TextInput.Name == "") { throw new ArgumentNullException("RSSFeed.TextInputName", "A name is required in RSS documents width TextInput field."); } if (TextInput.Title == "") { throw new ArgumentNullException("RSSFeed.TextInputTitle", "A title is required in RSS documents width TextInput field."); } XElement el = new XElement("textinput"); XAttribute tifDescription = new XAttribute("description", TextInput.Description); el.Add(tifDescription); XAttribute tifLink = new XAttribute("link", TextInput.Link); el.Add(tifLink); XAttribute tifName = new XAttribute("name", TextInput.Name); el.Add(tifName); XAttribute tifTitle = new XAttribute("title", TextInput.Title); el.Add(tifTitle); channel.Add(el); } if (Title != "") { channel.Add(new XElement("title") { Value = Title, }); } else { throw new ArgumentNullException("RSSFeed.Title", "A title is required in RSS documents."); } if (TimeToLive != int.MinValue) { channel.Add(new XElement("ttl") { Value = TimeToLive.ToString(), }); } if (WebMaster != "") { channel.Add(new XElement("webMaster") { Value = WebMaster, }); } if (Articles.Count > 0) { foreach (RSSFeedArticle art in Articles) { XElement el = new XElement("item"); if (art.Author != "") { el.Add(new XElement("author") { Value = art.Author, }); } if (art.Comments != "") { el.Add(new XElement("comments") { Value = art.Comments, }); } if (art.Title != "") { el.Add(new XElement("title") { Value = art.Title, }); } else { throw new ArgumentNullException("RSSFeed.Item.Title", "A title is required in RSS articles."); } if (art.ArticleUrl != "") { el.Add(new XElement("link") { Value = art.ArticleUrl, }); } else { throw new ArgumentNullException("RSSFeed.Item.ArticleUrl", "A url to complete article is required in RSS articles."); } if (art.Content != "") { XElement e = new XElement("description"); e.Add(new XCData(art.Content)); el.Add(e); } else { throw new ArgumentNullException("RSSFeed.Item.Description", "A description is required in RSS articles."); } if (art.Published != DateTime.MinValue) { el.Add(new XElement("pubDate") { Value = art.Published.ToString("R"), }); } if (art.Author != "") { el.Add(new XElement("author") { Value = art.Author, }); } if (art.Source.Source != "") { XElement source = new XElement("source") { Value = art.Source.Source, }; source.Add(new XAttribute("url", art.Source.Uri)); el.Add(source); } if (art.Guid.Guid != "") { XElement guid = new XElement("guid") { Value = art.Guid.Guid, }; if (art.Guid.IsPermaLink == false) { guid.Add(new XAttribute("isPermaLink", art.Guid.IsPermaLink)); } el.Add(guid); } if (art.Enclosure.Url != "") { if (art.Enclosure.Length == 0) { throw new ArgumentNullException("RSSFeed.Item.Enclosure.Length", "The length of enclosure is required in RSS articles with enclosure."); } if (art.Enclosure.Type == "") { throw new ArgumentNullException("RSSFeed.Item.Enclosure.Type", "The type of enclosure is required in RSS articles with enclosure."); } XElement enclosure = new XElement("enclosure"); enclosure.Add(new XAttribute("url", art.Enclosure.Url)); enclosure.Add(new XAttribute("length", art.Enclosure.Length)); enclosure.Add(new XAttribute("type", art.Enclosure.Type)); el.Add(enclosure); } if (art.Categories.Count > 0) { foreach (RSSFeedCategory cat in art.Categories) { XElement e = new XElement("category") { Value = cat.CategoryName, }; if (cat.Domain != "") { XAttribute at = new XAttribute("domain", cat.Domain); e.Add(at); } channel.Add(el); } } channel.Add(el); } } rss.Add(new XAttribute("version", Version), channel); doc.Add(rss); return(doc); }