示例#1
0
        /// <summary>
        /// Add a new header.
        /// </summary>
        /// <param name="name"></param>
        /// <param name="value"></param>
        public void Add(string name, IHeader value)
        {
            string lowerName = name.ToLower();

            if (lowerName == "host")
            {
                var    header = (StringHeader)value;
                string method = HttpContext.Current.IsSecure ? "https://" : "http://";
                Uri = new Uri(method + header.Value + Uri.PathAndQuery);
                return;
            }
            if (lowerName == "content-length")
            {
                ContentLength = (NumericHeader)value;
            }
            if (lowerName == "content-type")
            {
                ContentType = (ContentTypeHeader)value;
                string charset = ContentType.Parameters["charset"];
                if (!string.IsNullOrEmpty(charset))
                {
                    Encoding = Encoding.GetEncoding(charset);
                }
            }
            if (lowerName == "cookie")
            {
                Cookies = ((CookieHeader)value).Cookies;
            }

            _headers.Add(name, value);
        }
        public static Output For(IHeader header)
        {
            ResponseContext context = new ResponseContext();
            context.AddHeader(header);

            return For(context);
        }
示例#3
0
 /// <summary>
 /// Get a response with header values "啊齄丂狛狜隣郎隣兀﨩"
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='scenario'>
 /// Send a post request with header values "scenario": "valid"
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task <HeaderResponseByteHeaders> ResponseByteAsync(this IHeader operations, string scenario, CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.ResponseByteWithHttpMessagesAsync(scenario, null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Headers);
     }
 }
示例#4
0
        private void listener_RequestReceived(object sender, RequestEventArgs e)
        {
            e.IsHandled       = true;
            e.Response.Reason = string.Empty;
            string  userAgent = string.Empty;
            IHeader uahead    =
                e.Request.Headers.Where(h => string.Equals("User-Agent", h.Name, StringComparison.OrdinalIgnoreCase)).
                FirstOrDefault();

            if (null != uahead)
            {
                userAgent = uahead.HeaderValue;
            }

            //Send to the correct handler
            if (userAgent.StartsWith("FAP"))
            {
                if (OnRequest(RequestType.FAP, e))
                {
                    return;
                }
            }
            if (OnRequest(RequestType.HTTP, e))
            {
                return;
            }
            e.Response.Reason = "Handler error";
            e.Response.Status = HttpStatusCode.InternalServerError;
            var generator = new ResponseWriter();

            generator.SendHeaders(e.Context, e.Response);
        }
示例#5
0
        public SWD(string path)
        {
            using (var reader = new EndianBinaryReader(new MemoryStream(File.ReadAllBytes(path))))
            {
                Type    = reader.ReadString(4);
                Unknown = reader.ReadBytes(4);
                Length  = reader.ReadUInt32();
                Version = reader.ReadUInt16();
                switch (Version)
                {
                case 0x402:
                {
                    Header_V402 header = reader.ReadObject <Header_V402>();
                    Header   = header;
                    Programs = ReadPrograms <ProgramInfo_V402>(reader, header.NumPRGISlots);
                    Samples  = ReadSamples <WavInfo_V402>(reader, header.NumWAVISlots);
                    break;
                }

                case 0x415:
                {
                    Header_V415 header = reader.ReadObject <Header_V415>();
                    Header   = header;
                    Programs = ReadPrograms <ProgramInfo_V415>(reader, header.NumPRGISlots);
                    if (header.PCMDLength != 0 && (header.PCMDLength & 0xFFFF0000) != 0xAAAA0000)
                    {
                        Samples = ReadSamples <WavInfo_V415>(reader, header.NumWAVISlots);
                    }
                    break;
                }

                default: throw new InvalidDataException();
                }
            }
        }
示例#6
0
        /// <summary>
        /// Assign a header
        /// </summary>
        /// <param name="name">Long name, in lower case.</param>
        /// <param name="header">Header to assign</param>
        internal virtual void Assign(string name, IHeader header)
        {
            switch (name)
            {
            case "to":
                To = ((ContactHeader)header).FirstContact;
                break;

            case "from":
                From = ((ContactHeader)header).FirstContact;
                break;

            case "cseq":
                CSeq = (CSeq)header;
                break;

            case "via":
                var via = (Via)header;
                if (Via != null && Via.Items.Count > 0)
                {
                    foreach (ViaEntry entry in via)
                    {
                        Via.Add(entry);
                    }
                }
                else
                {
                    Via = via;
                }
                break;
            }

            Headers.Add(name.ToLower(), header);
        }
        public static string PageHeader(IHeader pageDetails)
        {
            StringBuilder stringBuilder = new StringBuilder();

            stringBuilder.AppendLine("<!DOCTYPE html>");

            stringBuilder.AppendLine("<html lang='en' >");
            stringBuilder.AppendLine("<head>");
            stringBuilder.AppendLine("    <meta charset='UTF-8'>");
            stringBuilder.AppendLine($"    <title>{pageDetails.Title}</title>");
            stringBuilder.AppendLine("<meta http-equiv='Content -Type' content='text/html; charset=UTF-8'>");
            stringBuilder.AppendLine($"<meta name='description' content='{pageDetails.MetaDetails}'/>");
            stringBuilder.AppendLine($"<meta name='keywords' content='{string.Join(" ", pageDetails.Keywords)}'/>");
            stringBuilder.AppendLine($"<meta name='title' content='{pageDetails.Title}'/>");
            stringBuilder.AppendLine("<meta name='author' content='Electric Wolf'>");
            stringBuilder.AppendLine("    <meta name='viewport' content='width=device-width, initial-scale=1, shrink-to-fit=no'>");
            stringBuilder.AppendLine(@"    <link rel='stylesheet' href='Scripts/style.css'>");
            stringBuilder.AppendLine(@"    <link rel='stylesheet' href='https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css' integrity='sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T' crossorigin='anonymous'>");
            stringBuilder.AppendLine(@"    <script src='https://code.jquery.com/jquery-3.3.1.slim.min.js' integrity='sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo' crossorigin='anonymous'></script>");
            stringBuilder.AppendLine(@"    <script src='https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js' integrity='sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1' crossorigin='anonymous'></script>");
            stringBuilder.AppendLine(@"    <script src='https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js' integrity='sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM' crossorigin='anonymous'></script>");
            AddSiteTracker(stringBuilder);
            stringBuilder.AppendLine("</head>");

            return(stringBuilder.ToString());
        }
示例#8
0
        public Description(IHeader header)
        {
            Header = header;

            Parameters      = Header.Parameters;
            OverloadHeaders = new List <IHeader>();
        }
        private void AssertHeader(IHeader header)
        {
            var headerObj = JsonObject.Parse(header.JsonString());
            var subs = headerObj.Object("sub");

            var firstNameSubstitutions = subs.Get<string[]>(FirstNamePlaceholder).ToList();
            CollectionAssert.AreEqual(new List<string> { Subscriber1FirstName, Subscriber2FirstName }, firstNameSubstitutions);

            var lastNameSubstitutions = subs.Get<string[]>(LastNamePlaceholder).ToList();
            CollectionAssert.AreEqual(new List<string> { "", Subscriber2LastName }, lastNameSubstitutions);

            var emailSubstitutions = subs.Get<string[]>(EmailPlaceholder).ToList();
            CollectionAssert.AreEqual(new List<string> { Subscriber1Email, Subscriber2Email }, emailSubstitutions);

            var resolveKeySubstitutions = subs.Get<string[]>(ResolveKeyPlaceholder).ToList();
            CollectionAssert.AreEqual(new List<string> { Subscriber1ResolveKey, Subscriber2ResolveKey }, resolveKeySubstitutions);

            var uniqueArgs = headerObj.Object("unique_args");

            var campaingId = uniqueArgs.Get(CampaignCustomHeaderKey);
            Assert.AreEqual(CampaignCustomHeaderValue, campaingId);

            var subscriberId = uniqueArgs.Get(SubscriberCustomHeaderKey);
            Assert.AreEqual(SubscriberCustomHeaderValue, subscriberId);
        }
示例#10
0
 /// <summary>
 /// Indicates whether the current object is equal to another object of the same type.
 /// </summary>
 /// <returns>
 /// true if the current object is equal to the <paramref name="other"/> parameter; otherwise, false.
 /// </returns>
 /// <param name="other">An object to compare with this object.
 ///                 </param>
 public bool Equals(IHeader other)
 {
     var header = other as StringHeader;
     if (header != null)
         return string.Compare(header.Value, Value, true) == 0;
     return false;
 }
示例#11
0
 public override PacketData GetBytes(IHeader header, PacketData packetData)
 {
     var ipHeader = (IPHeader)header;
     var currentData = new List<byte>();
     currentData.Add((byte)((ipHeader.VersionIHL << 4) | 5));
     currentData.Add(ipHeader.TypeOfService);
     //currentData.AddRange(GetBytes((UInt16)(packetData.Data.Count + 20)));
     currentData.AddRange(GetBytes(ipHeader.TotalLength));
     currentData.AddRange(GetBytes(ipHeader.Identification));
     //++ flags (3 bits-- left to right)
     //Bit 0: reserved, must be zero
     //Bit 1: (DF) 0 = May Fragment,  1 = Don't Fragment.
     //Bit 2: (MF) 0 = Last Fragment, 1 = More Fragments.
     //++ offset (13 bits)
     currentData.AddRange(GetBytes(ipHeader.FlagsFragmentOffset));
     currentData.Add(ipHeader.TTL);
     currentData.Add(ipHeader.Protocol);
     currentData.AddRange(new byte[]
                          {
                              0, 0
                          });
     currentData.AddRange(ipHeader.SourceAddress.GetBytes());
     currentData.AddRange(ipHeader.DestinationAddress.GetBytes());
     byte[] crc = GetCrc(currentData.ToArray());
     currentData[10] = crc[1];
     currentData[11] = crc[0];
     currentData.AddRange(packetData.Data);
     return packetData.UpdateData(currentData);
 }
示例#12
0
 public override PacketData GetBytes(IHeader header, PacketData packetData)
 {
     var udpHeader = (UdpHeader)header;
     var currentData = new List<byte>();
     currentData.AddRange(GetBytes(udpHeader.SourcePort));
     currentData.AddRange(GetBytes(udpHeader.DestinationPort));
     currentData.AddRange(GetBytes((ushort)(UdpHeaderProperty.Size + packetData.Data.Count)));
     currentData.AddRange(new byte[]
                          {
                              0, 0
                          });
     //+ crc
     List<byte> crcData = GetPseudoHeaderBytes(udpHeader, (uint)(packetData.Data.Count + UdpHeaderProperty.Size));
     crcData.AddRange(currentData);
     crcData.AddRange(packetData.Data);
     if (crcData.Count % 2 == 1)
     {
         crcData.Add(0);
     }
     byte[] crc = Checksum.GetCrc(crcData.ToArray());
     currentData[6] = crc[1];
     currentData[7] = crc[0];
     //+
     currentData.AddRange(packetData.Data);
     return packetData.UpdateData(currentData);
 }
 protected J1979Session(IHeader header, SessionChannel sessionChannel)
 {
     this.header             = header;
     this.sessionChannel     = sessionChannel;
     rxQueue                 = sessionChannel.RxQueue.GetConsumingEnumerable();
     rxQueue.BlockingTimeout = 250;
 }
示例#14
0
        /// <summary>
        /// Deserialize a single Export instance
        /// </summary>
        /// <param name="header">Header of the package.</param>
        /// <param name="cache">Decrypted bytes of a packagefile. Use Reader to decrypt</param>
        /// <param name="Offset">Ofset of a serialized Export object in cache</param>
        public Export(IHeader header, byte[] cache, int Offset)
        {
            HeaderExportOffset = header.ExportOffset;
            int ByteOffset = Offset + 28; // don't forget about 28 bytes of NcSoftHeader!!

            Class       = new Index(cache, HeaderExportOffset + ByteOffset);
            ByteOffset += Class.Size;

            Super       = new Index(cache, HeaderExportOffset + ByteOffset);
            ByteOffset += Super.Size;

            Group       = BitConverter.ToInt32(cache, HeaderExportOffset + ByteOffset);
            ByteOffset += 4;

            NameTableRef = new Index(cache, HeaderExportOffset + ByteOffset);
            ByteOffset  += NameTableRef.Size;

            ObjectFlags = BitConverter.ToInt32(cache, HeaderExportOffset + ByteOffset);
            ByteOffset += 4;

            SerialSize  = new Index(cache, HeaderExportOffset + ByteOffset);
            ByteOffset += SerialSize.Size;

            if (SerialSize.Value > 0)
            {
                SerialOffset = new Index(cache, HeaderExportOffset + ByteOffset);
                ByteOffset  += SerialOffset.Size;
            }
        }
示例#15
0
 /// <summary>
 /// Indicates whether the current object is equal to another object of the same type.
 /// </summary>
 /// <returns>
 /// true if the current object is equal to the <paramref name="other"/> parameter; otherwise, false.
 /// </returns>
 /// <param name="other">An object to compare with this object.
 ///                 </param>
 public virtual bool Equals(IHeader other)
 {
     var header = other as Event;
     if (header != null)
         return header.EventId == EventId && string.Compare(EventType, header.EventType) == 0;
     return false;
 }
示例#16
0
 public BaseMessage(IHeader header)
 {
     _header = header;
     _stream = new MemoryStream();
     _writer = new BinaryWriter(_stream);
     _count = 0;
 }
示例#17
0
 /// <summary>
 /// Indicates whether the current object is equal to another object of the same type.
 /// </summary>
 /// <returns>
 /// true if the current object is equal to the <paramref name="other"/> parameter; otherwise, false.
 /// </returns>
 /// <param name="other">An object to compare with this object.
 ///                 </param>
 public bool Equals(IHeader other)
 {
     var header = other as NumericHeader;
     if (header != null)
         return header.Value == Value;
     return false;
 }
        public static ISpanBuilder ObtainConsumerSpanBuilder(ITracer tracer, Headers headers, string spanName)
        {
            // See if we have a trace header
            IHeader traceHeader = null;

            // For whatever insane reason this linq query is not working ??
            //traceHeader = cr.Message.Headers.FirstOrDefault(p => p.Key == "tracing-id");
            foreach (var header in headers)
            {
                bool isKey = header.Key == "tracing-id";
                if (isKey)
                {
                    traceHeader = header;
                    break;
                }
            }

            ISpanBuilder spanBuilder;

            if (traceHeader != null)
            {
                var map = KafkaTracingContextHelper.Decode(traceHeader.GetValueBytes());
                var ctx = tracer.Extract(BuiltinFormats.TextMap, new TextMapExtractAdapter(map));
                spanBuilder = tracer.BuildSpan(spanName)
                              .WithTag(Tags.SpanKind.Key, Tags.SpanKindConsumer)
                              .AsChildOf(ctx);
            }
            else
            {
                spanBuilder = tracer.BuildSpan(spanName)
                              .WithTag(Tags.SpanKind.Key, Tags.SpanKindConsumer);
            }

            return(spanBuilder);
        }
示例#19
0
 /// <summary>
 /// Initializes client properties.
 /// </summary>
 private void Initialize()
 {
     this.Header           = new Header(this);
     this.BaseUri          = new System.Uri("http://localhost");
     SerializationSettings = new Newtonsoft.Json.JsonSerializerSettings
     {
         Formatting            = Newtonsoft.Json.Formatting.Indented,
         DateFormatHandling    = Newtonsoft.Json.DateFormatHandling.IsoDateFormat,
         DateTimeZoneHandling  = Newtonsoft.Json.DateTimeZoneHandling.Utc,
         NullValueHandling     = Newtonsoft.Json.NullValueHandling.Ignore,
         ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize,
         ContractResolver      = new Microsoft.Rest.Serialization.ReadOnlyJsonContractResolver(),
         Converters            = new  System.Collections.Generic.List <Newtonsoft.Json.JsonConverter>
         {
             new Microsoft.Rest.Serialization.Iso8601TimeSpanConverter()
         }
     };
     DeserializationSettings = new Newtonsoft.Json.JsonSerializerSettings
     {
         DateFormatHandling    = Newtonsoft.Json.DateFormatHandling.IsoDateFormat,
         DateTimeZoneHandling  = Newtonsoft.Json.DateTimeZoneHandling.Utc,
         NullValueHandling     = Newtonsoft.Json.NullValueHandling.Ignore,
         ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize,
         ContractResolver      = new Microsoft.Rest.Serialization.ReadOnlyJsonContractResolver(),
         Converters            = new System.Collections.Generic.List <Newtonsoft.Json.JsonConverter>
         {
             new Microsoft.Rest.Serialization.Iso8601TimeSpanConverter()
         }
     };
     CustomInitialize();
 }
示例#20
0
        /// <summary>
        /// Initializes a new instance of the <see cref="GetSDMX_WSRest"/> class.
        /// </summary>
        /// <param name="config">
        /// The config
        /// </param>
        public GetSDMX_WSRest(EndpointSettings config)
        {
            if (config == null)
            {
                throw new ArgumentNullException("config");
            }

            if (string.IsNullOrEmpty(config.EndPoint))
            {
                throw new ArgumentException(Resources.ExceptionEndpointNotSet, "config");
            }

            // Getting nsiClientWs
            EndpointSettings V20Sett = (EndpointSettings)config.Clone();

            V20Sett.EndPointType = "V20";
            V20Sett.EndPoint     = V20Sett.EndPointV20;
            this._nsiClientWs    = new GetSDMX_WSV20(V20Sett);

            Logger.Info(Resources.InfoCreatingNsiClient);
            this._config = config;

            this._defaultHeader = new HeaderImpl("NSIClient", "NSIClient");
            Utils.PopulateHeaderFromSettings(this._defaultHeader);
        }
示例#21
0
 /// <summary>
 /// Initializes client properties.
 /// </summary>
 private void Initialize()
 {
     this.Header           = new Header(this);
     this.BaseUri          = new Uri("http://localhost");
     SerializationSettings = new JsonSerializerSettings
     {
         Formatting            = Formatting.Indented,
         DateFormatHandling    = DateFormatHandling.IsoDateFormat,
         DateTimeZoneHandling  = DateTimeZoneHandling.Utc,
         NullValueHandling     = NullValueHandling.Ignore,
         ReferenceLoopHandling = ReferenceLoopHandling.Serialize,
         ContractResolver      = new ReadOnlyJsonContractResolver(),
         Converters            = new List <JsonConverter>
         {
             new Iso8601TimeSpanConverter()
         }
     };
     DeserializationSettings = new JsonSerializerSettings
     {
         DateFormatHandling    = DateFormatHandling.IsoDateFormat,
         DateTimeZoneHandling  = DateTimeZoneHandling.Utc,
         NullValueHandling     = NullValueHandling.Ignore,
         ReferenceLoopHandling = ReferenceLoopHandling.Serialize,
         ContractResolver      = new ReadOnlyJsonContractResolver(),
         Converters            = new List <JsonConverter>
         {
             new Iso8601TimeSpanConverter()
         }
     };
     CustomInitialize();
 }
        private static HistogramBase Create(Type histogramType, IHeader header, long minBarForHighestTrackableValue)
        {
            var constructor = TypeHelper.GetConstructor(histogramType, HistogramClassConstructorArgsTypes);

            if (constructor == null)
            {
                throw new ArgumentException("The target type does not have a supported constructor", nameof(histogramType));
            }

            var highestTrackableValue = Math.Max(header.HighestTrackableValue, minBarForHighestTrackableValue);

            try
            {
                var histogram = (HistogramBase)constructor.Invoke(new object[]
                {
                    header.LowestTrackableUnitValue,
                    highestTrackableValue,
                    header.NumberOfSignificantValueDigits
                });

                //TODO: Java does this now. Need to follow this through -LC
                //histogram.IntegerToDoubleValueConversionRatio = header.IntegerToDoubleValueConversionRatio;
                //histogram.NormalizingIndexOffset = header.NormalizingIndexOffset;
                return(histogram);
            }
            catch (Exception ex)
            {
                //As we are calling an unknown method (the ctor) we cant be sure of what of what type of exceptions we need to catch -LC
                throw new ArgumentException("Unable to create histogram of Type " + histogramType.Name + ": " + ex.Message, ex);
            }
        }
示例#23
0
 public override void CustomPageHeader(IHeader header)
 {
     if (PageHeaderWriting != null)
     {
         PageHeaderWriting(this, new PageWritingEventArgs(header, GetExport(ExportId)));
     }
 }
示例#24
0
        public AbstractResponse(T response, ResponseHeader responseHeader)
        {
            this.response       = response;
            this.responseHeader = responseHeader;

            this.header = new HeaderImpl(this);
        }
示例#25
0
        /// <summary>
        /// Prints basic header fields
        /// </summary>
        /// <param name="header"></param>
        public void Print(IHeader header)
        {
            TCPHeader newHeader = header as TCPHeader;

            Console.WriteLine(string.Format("Window Size\tSource Port\tDestination Port\tUrgent Pointer"));
            Console.WriteLine(string.Format("    {0}\t{1}\t{2}\t{3}",
                                            newHeader.WindowSize, newHeader.SourcePort, newHeader.DestPort, newHeader.UrgentPointer));
        }
示例#26
0
    public IHeader imethod_7(IHeader interface21_0)
    {
        IHeader interface2 = (IHeader)interface21_0.Clone();

        interface2.UserID     = interface21_0.DestUserID;
        interface2.DestUserID = interface21_0.UserID;
        return(interface2);
    }
示例#27
0
 internal Mail(IHeader header)
 {
     _message = new MailMessage();
     Header = header;
     Headers = new Dictionary<string, string>();
     TextTransferEncoding = TransferEncoding.Base64;
     HtmlTransferEncoding = TransferEncoding.Base64;
 }
示例#28
0
 internal Mail(IHeader header)
 {
     _message             = new MailMessage();
     Header               = header;
     Headers              = new Dictionary <string, string>();
     TextTransferEncoding = TransferEncoding.Base64;
     HtmlTransferEncoding = TransferEncoding.Base64;
 }
示例#29
0
 public override PacketData GetBytes(IHeader header, PacketData packetData)
 {
     var imageHeader = (ImageHeader)header;
     var currentData = new List<byte>();
     currentData.Add(imageHeader.Operation);
     currentData.AddRange(imageHeader.Data);
     return packetData.UpdateData(currentData);
 }
示例#30
0
        public void Print(IHeader header)
        {
            IPHeader newIPHeader = header as IPHeader;

            Console.WriteLine(string.Format("Protocol\tSource IP\tDestination IP\tTotal Length"));
            Console.WriteLine(string.Format("  {0}\t{1}\t{2}\t{3}", newIPHeader.Protocol,
                                            newIPHeader.SourceIP, newIPHeader.DestIP, newIPHeader.TotalLength));
        }
示例#31
0
 public Section(IHeader header = null, ICourseLink parentCourse = null)
 {
     Header = header != null
         ? new Header(header.Name, header.Order, header.AnchorId, this)
         : new Header(parentSection: this);
     ParentCourse = parentCourse;
     Links        = new List <IDownloadableLink>();
 }
示例#32
0
        public void Print(IHeader header)
        {
            UDPHeader newHeader = header as UDPHeader;

            Console.WriteLine(string.Format("Soucre Port\tDestination Port\tLength"));
            Console.WriteLine(string.Format("    {0}\t{1}\t{2}",
                                            newHeader.SourcePort, newHeader.DestPort, newHeader.Length));
        }
示例#33
0
 public override PacketData GetBytes(IHeader header, PacketData packetData)
 {
     var icmpEchoHeader = (IcmpEchoHeader)header;
     var currentData = new List<byte>();
     currentData.AddRange(GetBytes(icmpEchoHeader.Identifier));
     currentData.AddRange(GetBytes(icmpEchoHeader.SequenceNumber));
     currentData.AddRange(icmpEchoHeader.Data);
     return packetData.UpdateData(currentData);
 }
示例#34
0
        public void SetHeader(IHeader header)
        {
            if (header == null)
            {
                return;
            }

            Headers[header.Name] = header;
        }
        public bool ContainsHeader(IHeader header)
        {
            if (!headers.ContainsKey(header.GetType()))
            {
                return false;
            }

            return headers[header.GetType()].Equals(header);
        }
示例#36
0
        private void PopulateValidLearners(IDataStoreCache cache, int ukprn, IHeader header, IReadOnlyCollection <ISourceFile> sourceFileCollection, IEnumerable <ILearner> learners, IEnumerable <ILearnerDestinationAndProgression> destinationAndProgressions)
        {
            var source = header.SourceEntity;
            int lLDDandHealthProblemID = 1;
            int learningDeliveryFamId  = 1;
            int appFinRecordId         = 1;

            cache.AddRange(BuildCollectionDetails(ukprn, header));
            cache.AddRange(BuildLearningProviders(ukprn));
            cache.AddRange(BuildSources(ukprn, source));
            cache.AddRange(BuildSourceFiles(ukprn, sourceFileCollection));

            learners.NullSafeForEach(learner =>
            {
                cache.Add(BuildValidLearner(ukprn, learner));

                learner.ContactPreferences.NullSafeForEach(contactPreference => cache.Add(BuildContactPreference(ukprn, learner, contactPreference)));
                learner.LearningDeliveries.NullSafeForEach(learningDelivery =>
                {
                    cache.Add(BuildLearningDelivery(ukprn, learner, learningDelivery));

                    if (learningDelivery.LearningDeliveryHEEntity != null)
                    {
                        cache.Add(BuildLearningDeliveryHERecord(ukprn, learner, learningDelivery));
                    }

                    learningDelivery.AppFinRecords.NullSafeForEach(appFinRecord => cache.Add(BuildLearningDeliveryAppFinRecord(ukprn, learner, learningDelivery, appFinRecord, appFinRecordId++)));
                    learningDelivery.LearningDeliveryFAMs.NullSafeForEach(famRecord => cache.Add(BuildLearningDeliveryFAMRecord(ukprn, learner, learningDelivery, famRecord, learningDeliveryFamId++)));
                    learningDelivery.LearningDeliveryWorkPlacements.NullSafeForEach(workPlacement => cache.Add(BuildLearningDeliveryWorkPlacement(ukprn, learner, learningDelivery, workPlacement)));
                    learningDelivery.ProviderSpecDeliveryMonitorings.NullSafeForEach(monitoring => cache.Add(BuildProviderSpecDeliveryMonitoring(ukprn, learner, learningDelivery, monitoring)));
                });

                learner.LearnerEmploymentStatuses.NullSafeForEach(employmentStatus =>
                {
                    cache.Add(BuildLearnerEmploymentStatus(ukprn, learner, employmentStatus));
                    employmentStatus.EmploymentStatusMonitorings.NullSafeForEach(monitoring => cache.Add(BuildEmploymentStatusMonitoring(ukprn, learner, employmentStatus, monitoring)));
                });

                learner.LearnerFAMs.NullSafeForEach(fam => cache.Add(BuildLearnerFAM(ukprn, learner, fam)));

                if (learner.LearnerHEEntity != null)
                {
                    cache.Add(BuildLearnerHE(ukprn, learner));
                    learner.LearnerHEEntity.LearnerHEFinancialSupports.NullSafeForEach(support => cache.Add(BuildLearnerHEFinancialSupport(ukprn, learner, support)));
                }

                learner.LLDDAndHealthProblems.NullSafeForEach(problem => cache.Add(BuildLLDDAndHealthProblem(ukprn, learner, problem, lLDDandHealthProblemID++)));

                learner.ProviderSpecLearnerMonitorings.NullSafeForEach(monitoring => cache.Add(BuildProviderSpecLearnerMonitoring(ukprn, learner, monitoring)));
            });

            destinationAndProgressions.NullSafeForEach(destinationAndProgression =>
            {
                cache.Add(BuildLearnerDestinationAndProgression(ukprn, destinationAndProgression));
                destinationAndProgression.DPOutcomes.NullSafeForEach(dpOutcome => cache.Add(BuildDPOutcome(ukprn, destinationAndProgression, dpOutcome)));
            });
        }
 /// <summary>
 /// Initializing func for Serializer.
 /// </summary>
 /// <param name="H">Header of the package</param>
 /// <param name="NT">NameTable of package.</param>
 /// <param name="ET">ExportTable of package.</param>
 /// <param name="IT">ImportTable of Package</param>
 /// <param name="body">Readed and decrypted bytes of package body. </param>
 /// <seealso cref="L2Package.PackageReader"/>
 public void Initialize(IHeader H, INameTable NT, IExportTable ET, IImportTable IT, byte[] body)
 {
     Header      = H;
     NameTable   = NT;
     ExportTable = ET;
     ImportTable = IT;
     Bytes       = body;
     Initialized = true;
 }
示例#38
0
        /// <summary>
        /// Indicates whether the current object is equal to another object of the same type.
        /// </summary>
        /// <returns>
        /// true if the current object is equal to the <paramref name="other"/> parameter; otherwise, false.
        /// </returns>
        /// <param name="other">An object to compare with this object.
        ///                 </param>
        public bool Equals(IHeader other)
        {
            var header = other as NumericHeader;

            if (header != null)
            {
                return(header.Value == Value);
            }
            return(false);
        }
示例#39
0
        internal static IEnumerable <string> GetHeaderItems(IHeader that)
        {
            var header = GetHeader(that);

            if (!string.IsNullOrWhiteSpace(header))
            {
                return(header.Split('\n').ToList());
            }
            return(new List <string>());
        }
示例#40
0
        /// <summary>
        /// Indicates whether the current object is equal to another object of the same type.
        /// </summary>
        /// <returns>
        /// true if the current object is equal to the <paramref name="other"/> parameter; otherwise, false.
        /// </returns>
        /// <param name="other">An object to compare with this object.
        ///                 </param>
        public virtual bool Equals(IHeader other)
        {
            var header = other as Event;

            if (header != null)
            {
                return(header.EventId == EventId && string.Compare(EventType, header.EventType) == 0);
            }
            return(false);
        }
示例#41
0
        /// <summary>
        /// Indicates whether the current object is equal to another object of the same type.
        /// </summary>
        /// <returns>
        /// true if the current object is equal to the <paramref name="other"/> parameter; otherwise, false.
        /// </returns>
        /// <param name="other">An object to compare with this object.
        ///                 </param>
        public bool Equals(IHeader other)
        {
            var header = other as StringHeader;

            if (header != null)
            {
                return(string.Compare(header.Value, Value, true) == 0);
            }
            return(false);
        }
示例#42
0
 public override PacketData GetBytes(IHeader header, PacketData packetData)
 {
     var ethernetHeader = (EthernetHeader)header;
     var currentData = new List<byte>();
     currentData.AddRange(ethernetHeader.Destination.GetBytes());
     currentData.AddRange(ethernetHeader.Source.GetBytes());
     currentData.AddRange(ethernetHeader.TypeOrLength.GetBytes());
     currentData.AddRange(packetData.Data);
     return packetData.UpdateData(currentData);
 }
示例#43
0
        /// <summary>
        /// Indicates whether the current object is equal to another object of the same type.
        /// </summary>
        /// <returns>
        /// true if the current object is equal to the <paramref name="other"/> parameter; otherwise, false.
        /// </returns>
        /// <param name="other">An object to compare with this object.
        ///                 </param>
        public bool Equals(IHeader other)
        {
            var ct = other as ContentType;

            if (ct == null)
            {
                return(false);
            }
            return(string.Compare(ct.Type, Type, true) == 0 && string.Compare(ct.SubType, SubType, true) == 0);
        }
示例#44
0
        public void Add(IHeader key, List<KartEntity> value)
        {
            if (map.ContainsKey(key))
            {
                map.Remove(key);
            }
            key.KayitSayisi = list.Count;

            this.map.Add(key, value);
        }
示例#45
0
		public SendGridMessage(MailAddress from, MailAddress[] to,
			String subject, String html, String text, IHeader header = null) : this()
		{
			From = from;
			To = to;

			_message.Subject = subject;

			Text = text;
			Html = html;
		}
示例#46
0
        public override PacketData GetBytes(IHeader header, PacketData packetData)
        {
            return packetData;

            var ipv6_header = (IPv6Header)header;
            var currentData = new List<byte>();
            //++ more here
            currentData.AddRange(ipv6_header.SourceAddress.GetBytes());
            currentData.AddRange(ipv6_header.DestinationAddress.GetBytes());
            currentData.AddRange(packetData.Data);
            return packetData.UpdateData(currentData);
        }
        ///////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////BUILD FROM V2.1 SCHEMA                 //////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////////////
        #region Constructors and Destructors

        /// <summary>
        /// Initializes a new instance of the <see cref="MetadataObjectCore"/> class.
        /// </summary>
        /// <param name="metadata">
        /// The metadata. 
        /// </param>
        public MetadataObjectCore(GenericMetadata metadata)
            : base(SdmxStructureType.GetFromEnum(SdmxStructureEnumType.MetadataDocument), null)
        {
            this.metadataSets = new List<IMetadataSet>();

            this.header = new HeaderImpl(metadata.Content.Header);

            foreach (MetadataSetType metadataset in metadata.Content.DataSet)
            {
                this.metadataSets.Add(new MetadataSetObjectCore(this, metadataset));
            }
        }
        public IResponseContext AddHeader(IHeader header)
        {
            if (headers.ContainsKey(header.GetType()))
            {
                headers[header.GetType()] = header;
            }
            else
            {
                headers.Add(header.GetType(), header);
            }

            return this;
        }
示例#49
0
        internal SendGrid(MailAddress from, MailAddress[] to, MailAddress[] cc, MailAddress[] bcc, string subject, string html, string text, IHeader header = null)
            : this(header)
        {
            this.From = from;
            this.To = to;
            this.Cc = cc;
            this.Bcc = bcc;

            this.message.Subject = subject;

            this.Text = text;
            this.Html = html;
        }
示例#50
0
 public override PacketData GetBytes(IHeader header, PacketData packetData)
 {
     var icmpHeader = (IcmpHeader)header;
     var currentData = new List<byte>();
     currentData.AddRange(GetBytes(icmpHeader.Type));
     currentData.AddRange(GetBytes(icmpHeader.Code));
     currentData.AddRange(new byte[] { 0, 0 });
     currentData.AddRange(packetData.Data);
     byte[] crc = Checksum.GetCrc(currentData.ToArray());
     currentData[2] = crc[1];
     currentData[3] = crc[0];
     return packetData.UpdateData(currentData);
 }
        public FileBasedAtomDocument(string fileName, IChunkingStrategy chunkingStrategy)
        {
            fileInfo = new FileInfo(fileName);

            if (!fileInfo.Exists)
            {
                throw new NotFoundException(string.Format("File does not exist. File: [{0}].", fileInfo.FullName));
            }

            eTag = new ETag(string.Format(@"""{0}#{1}""", fileInfo.Name, fileInfo.LastWriteTimeUtc.Ticks));
            chunking = chunkingStrategy.CreateHeader(fileInfo.Length);
            lastModified = new LastModified(fileInfo.LastWriteTimeUtc);
        }
示例#52
0
        internal SendGrid(MailAddress from, MailAddress[] to, MailAddress[] cc, MailAddress[] bcc, 
            String subject, String html, String text, IHeader header = null )
            : this(header)
        {
            From = from;
            To = to;
            Cc = cc;
            Bcc = bcc;

            message.Subject = subject;

            Text = text;
            Html = html;
        }
 public override PacketData GetBytes(IHeader header, PacketData packetData)
 {
     if (!Collection.IsNullOrEmpty(packetData.Data))
     {
         //TODO: if this becomes iterative, this will have to change
         throw new InvalidOperationException("There should never be data after the TLV area of an OSPF LLS data block");
     }
     var ospfLlsDataBlockTlv = (OspfLlsDataBlockTlv)header;
     var currentData = new List<byte>();
     currentData.AddRange(GetBytes(ospfLlsDataBlockTlv.Type));
     currentData.AddRange(GetBytes(ospfLlsDataBlockTlv.Length));
     currentData.AddRange(ospfLlsDataBlockTlv.Value);
     return packetData.UpdateData(currentData);
 }
示例#54
0
        internal Mail(MailAddress from, MailAddress[] to, MailAddress[] cc, MailAddress[] bcc, 
            string subject, string html, string text, IHeader header = null )
            : this(header)
        {
            From = from;
            To = to;
            Cc = cc;
            Bcc = bcc;

            _message.Subject = subject;

            Text = text;
            Html = html;
            TextTransferEncoding = TransferEncoding.SevenBit;
            HtmlTransferEncoding = TransferEncoding.SevenBit;
        }
示例#55
0
 public override PacketData GetBytes(IHeader header, PacketData packetData)
 {
     var ripPreambleHeader = (RipPreambleHeader)header;
     var currentData = new List<byte>();
     currentData.Add(ripPreambleHeader.command);
     currentData.Add(ripPreambleHeader.Version);
     currentData.AddRange(GetBytes(ripPreambleHeader.Domain));
     foreach (var ripDataHeader in ripPreambleHeader.DataArray)
     {
         currentData.AddRange(GetBytes(ripDataHeader.AddressFamily));
         currentData.AddRange(GetBytes(ripDataHeader.RouteTag));
         currentData.AddRange(ripDataHeader.Network.GetBytes());
         currentData.AddRange(ripDataHeader.Mask.GetBytes());
         currentData.AddRange(ripDataHeader.NextHop.GetBytes());
         currentData.AddRange(GetBytes(ripDataHeader.Metric));
     }
     return packetData.UpdateData(currentData);
 }
示例#56
0
        public override PacketData GetBytes(IHeader header, PacketData packetData)
        {
            var ospfDBDHeader = (OspfDbdHeader)header;

            if (ospfDBDHeader.LsaList != null)
            {
                foreach (var ospfLsaHeader in ospfDBDHeader.LsaList)
                {
                    packetData = Controller.GetSingletonHandler("OSPFLSA").GetBytes(ospfLsaHeader, packetData);
                }
            }
            var currentData = new List<byte>();
            currentData.AddRange(GetBytes(ospfDBDHeader.Mtu));
            currentData.AddRange(GetBytes(ospfDBDHeader.Options));
            currentData.AddRange(GetBytes(ospfDBDHeader.Flags));
            currentData.AddRange(GetBytes(ospfDBDHeader.SequenceNumber));
            currentData.AddRange(packetData.Data);
            return packetData.UpdateData(currentData);
        }
示例#57
0
        public override PacketData GetBytes(IHeader header, PacketData packetData)
        {
            var arpHeader = (ArpHeader)header;
            var currentData = new List<byte>();
            currentData.AddRange(GetBytes(arpHeader.HardwareType));
            currentData.AddRange(GetBytes(arpHeader.ProtocolType));

            currentData.Add(arpHeader.HardwareSize);
            currentData.Add(arpHeader.ProtocolSize);

            currentData.AddRange(GetBytes(arpHeader.Operation));

            currentData.AddRange(arpHeader.SourceMacAddress.GetBytes());
            currentData.AddRange(arpHeader.SourceIPAddress.GetBytes());
            currentData.AddRange(arpHeader.DestinationMacAddress.GetBytes());
            currentData.AddRange(arpHeader.DestinationIPAddress.GetBytes());

            currentData.AddRange(packetData.Data);
            return packetData.UpdateData(currentData);
        }
示例#58
0
        public override PacketData GetBytes(IHeader header, PacketData packetData)
        {
            ushort size = (ushort)packetData.Data.Count;

            var ospfLsaHeader = (OspfLsaHeader)header;
            var currentData = new List<byte>();
            currentData.AddRange(GetBytes(ospfLsaHeader.LSAge));
            currentData.AddRange(GetBytes(ospfLsaHeader.Options));
            currentData.AddRange(GetBytes(ospfLsaHeader.LSType));
            currentData.AddRange(ospfLsaHeader.LSID.GetBytes());
            currentData.AddRange(ospfLsaHeader.AdvertisingRouter.GetBytes());
            currentData.AddRange(GetBytes(ospfLsaHeader.SequenceNumber));
            currentData.AddRange(new byte[] { 0, 0 });
            currentData.AddRange(GetBytes((ushort)(20 + size)));
            byte[] crc = Nalarium.Checksum.GetCrc(currentData.ToArray());
            currentData[16] = crc[1];
            currentData[17] = crc[0];
            currentData.AddRange(packetData.Data);
            return packetData.UpdateData(currentData);
        }
示例#59
0
 public override PacketData GetBytes(IHeader header, PacketData packetData)
 {
     var ospfHelloHeader = (OspfHelloHeader)header;
     var currentData = new List<byte>();
     currentData.AddRange(GetNotReversedBytes(ospfHelloHeader.Mask));
     currentData.AddRange(GetBytes(ospfHelloHeader.Interval));
     currentData.Add(ospfHelloHeader.Options);
     currentData.Add(ospfHelloHeader.RouterPriority);
     currentData.AddRange(GetBytes(ospfHelloHeader.RouterDeadInterval));
     currentData.AddRange(ospfHelloHeader.Dr.GetBytes());
     currentData.AddRange(ospfHelloHeader.Bdr.GetBytes());
     if (ospfHelloHeader.Neighbor != null)
     {
         foreach (IPAddress neighbor in ospfHelloHeader.Neighbor)
         {
             currentData.AddRange(neighbor.GetBytes());
         }
     }
     currentData.AddRange(packetData.Data);
     return packetData.UpdateData(currentData);
 }
 public override PacketData GetBytes(IHeader header, PacketData packetData)
 {
     var ospfLlsDataBlockHeader = (OspfLlsDataBlockHeader)header;
     var currentData = new List<byte>();
     currentData.AddRange(new byte[]
                          {
                              0, 0
                          });
     var size = (ushort)(packetData.Data.Count + 4);
     packetData.AddProperty("OspfLlsDataBlockHeaderSize", size);
     currentData.AddRange(GetBytes((ushort)(size / 4)));
     byte[] crc = Checksum.GetCrc(currentData.ToArray());
     currentData[0] = 0xff;
     currentData[1] = 0xf6;
     //foreach (var ospfLlsDataBlockTlv in OspfLlsDataBlockHeader.OspfLlsDataBlockTlv)
     //{
     //    var subData = new List<byte>();
     //    Controller.GetSingletonHandler("OSPFLLSDATABLOCKTLV").GetBytes(ospfLlsDataBlockTlv, subData);
     //    currentData.AddRange(subData);
     //}
     currentData.AddRange(packetData.Data);
     return packetData.UpdateData(currentData);
 }