예제 #1
0
        private void OnReadResponseHeader(PipeStream pipeStream)
        {
            if (Request.Server.EnableLog(BeetleX.EventArgs.LogType.Info))
            {
                Request.Server.Log(BeetleX.EventArgs.LogType.Info, $"Gateway {Request.ID} {Request.RemoteIPAddress} {Request.Method} {Request.Url} -> {Server.Host}:{Server.Port} response stream reading");
            }
            PipeStream agentStream = GetRequestStream();

            if (Status == RequestStatus.RespondingHeader)
            {
                mClientAgent.Status = TcpClientAgentStatus.ResponseReciveHeader;
                var indexof = pipeStream.IndexOf(HeaderTypeFactory.LINE_BYTES);
                while (indexof.End != null)
                {
                    pipeStream.Read(mBuffer, 0, indexof.Length);

                    if (indexof.Length == 2)
                    {
                        if (Request.VersionNumber == "1.0" && Request.KeepAlive)
                        {
                            agentStream.Write(Gateway.KEEP_ALIVE, 0, Gateway.KEEP_ALIVE.Length);
                        }
                        UrlRoute.Pluginer.HeaderWriting(Request, Response, mResponseHeader);
                        mResponseHeader.Write(agentStream);
                        if (Server.Gateway.OutputServerAddress)
                        {
                            agentStream.Write("Logic-Server: " + Server.ServerName + "\r\n");
                        }
                        agentStream.Write(mBuffer, 0, indexof.Length);
                        Status = RequestStatus.RespondingBody;
                        if (Request.Server.EnableLog(BeetleX.EventArgs.LogType.Info))
                        {
                            Request.Server.Log(BeetleX.EventArgs.LogType.Info, $"gateway {Request.ID} {Request.RemoteIPAddress} {Request.Method} {Request.Url} -> {Server.Host}:{Server.Port} response stream read header ");
                        }
                        return;
                    }
                    else
                    {
                        var header = HttpParse.AnalyzeHeader(new ReadOnlySpan <byte>(mBuffer, 0, indexof.Length - 2));
                        if (string.Compare(header.Item1, HeaderTypeFactory.TRANSFER_ENCODING, true) == 0 && string.Compare(header.Item2, "chunked", true) == 0)
                        {
                            mTransferEncoding = true;
                        }
                        if (string.Compare(header.Item1, HeaderTypeFactory.CONTENT_LENGTH, true) == 0)
                        {
                            mRequestLength = int.Parse(header.Item2);
                        }
                        if (string.Compare(header.Item1, HeaderTypeFactory.SERVER, true) == 0)
                        {
                            mResponseHeader.Add(HeaderTypeFactory.SERVER, "Bumblebee(BeetleX)");
                        }
                        else
                        {
                            mResponseHeader.Add(header.Item1, header.Item2);
                        }
                    }
                    indexof = pipeStream.IndexOf(HeaderTypeFactory.LINE_BYTES);
                }
            }
        }
예제 #2
0
        //0- Original File Name
        //1- Original File Size
        //2- First Part Name
        //3- Parts Number
        //4- {
        //   P% Name
        //   P% Size
        //   }
        private void GenerateSfx()
        {
            if (!includeSfx)
            {
                return;
            }

            Header hdr = new Header();

            //Self Joiner Signature
            hdr.Add(Path.GetFileName(fileName));
            hdr.Add(fileSize.ToString());
            hdr.Add(Path.GetFileName(files[0]));
            hdr.Add(files.Count.ToString());

            for (int i = 0; i < files.Count; i++)
            {
                hdr.Add(Path.GetFileName(files[i]));
                hdr.Add(pSizes[i].ToString());
            }

            if (Sfx.OutPath.Length > 0)
            {
                hdr.Add(Sfx.OutPath);
            }
            else
            {
                hdr.Add("\0");
            }

            if (Sfx.Comment.Length > 0)
            {
                hdr.Add(Sfx.Comment);
            }
            else
            {
                hdr.Add("\0");
            }

            string sfxPath = Path.Combine(outputFolder, "Q Join.exe");

            File.Copy(Path.Combine(Application.StartupPath, "qj.bin"), sfxPath, true);
            long sfxSize = IoTools.GetFileSize(sfxPath);

            FileStream   fs = new FileStream(sfxPath, FileMode.Append);
            BinaryWriter br = new BinaryWriter(fs);

            br.Seek(0, SeekOrigin.End);
            hdr.Write(br);

            fs.Close();
            br.Close();

            fs.Dispose();
        }
예제 #3
0
        public void UpdateTabs()
        {
            var pages = Pages;

            _activePage = null;
            Header.Clear();

            Pages.ForEach(page =>
            {
                Header.Add(page.Button);

                if (page.IsActive && _activePage == null)
                {
                    _activePage = page;
                }
            });

            if (_activePage == null && Content.childCount > 0)
            {
                _activePage = Content[0] as TabPage;
            }

            Pages.ForEach(page =>
            {
                page.IsActive = page == _activePage;
                page.EnableInClassList(PageSelectedUssClassName, page.IsActive);
                page.Button.EnableInClassList(TabSelectedUssClassName, page.IsActive);
            });
        }
예제 #4
0
        internal MatchingRuleCollection(Dictionary <string, Matcher> matchingRules)
        {
            if (matchingRules == null)
            {
                throw new System.ArgumentNullException(nameof(matchingRules));
            }

            foreach (var rule in matchingRules.Where(m => m.Key.StartsWith("$.body")))
            {
                Body.Add(rule.Key.Replace(".body", ""), new MatcherList {
                    Matchers = new List <Matcher> {
                        rule.Value
                    }
                });
            }

            foreach (var rule in matchingRules.Where(m => m.Key.StartsWith("$.headers")))
            {
                Header.Add(rule.Key.Replace("$.headers.", ""), new MatcherList {
                    Matchers = new List <Matcher> {
                        rule.Value
                    }
                });
            }
        }
예제 #5
0
        public void Extract(string zapros = "2sf", string pathToXmlDocument = @"6000-ExtensionsBase.xml")
        {
            var document = new XmlDocument();

            document.Load(pathToXmlDocument);

            //// <ListOfExtension>
            XmlElement root = document.DocumentElement; //<?xml version="1.0"?>

            zapros = "RASHIRENIE" + zapros;
            XmlElement resultNode = null;
            int        ggg        = 0;

            foreach (XmlElement item in root)
            {
                ggg++;
                if (zapros == item.Name)
                {
                    resultNode = item;
                    break;
                }
            }
            //category = resultNode.Name;
            if (resultNode != null)
            {
                foreach (XmlElement item in resultNode)
                {
                    switch (item.Name)
                    {
                    case "Header":
                        Header.Add(item.GetAttribute("Value"));
                        break;

                    case "rusDescription":
                        RusDescription.Add(item.GetAttribute("Value"));
                        break;

                    case "engDescription":
                        EngDescription.Add(item.GetAttribute("Value"));
                        break;

                    case "typeFile":
                        TypeFile.Add(item.GetAttribute("Value"));
                        break;

                    case "WhatOpen":
                        WhatOpen.Add(item.GetAttribute("Value"));
                        break;

                    case "infoHeaderFile":
                        infoHeaderFile.Add(item.GetAttribute("Value"));
                        break;

                    case "detailedDescription":
                        detailedDescription.Add(item.GetAttribute("Value"));
                        break;
                    }
                }
            }
        }
예제 #6
0
        private static void AddMenu()
        {
            while (true)
            {
                Console.Clear();
                Header.Add();
                Console.WriteLine("\n*** Menu ***");
                Console.WriteLine("\n1. Blog");
                Console.WriteLine("2. Post");
                Console.WriteLine("0. Exit");
                Console.Write("\nOption: ");

                String selectedOperation = Console.ReadLine();

                if (selectedOperation.Equals("1"))
                {
                    AddMenuBlog();
                }
                else if (selectedOperation.Equals("2"))
                {
                    AddMenuPost();
                }
                else if (selectedOperation.Equals("0"))
                {
                    Exit();
                }
                else
                {
                    Console.WriteLine("Choose a valid option from menu!");
                    Console.ReadKey();
                }
            }
        }
        /// <summary>
        /// 添加请求头
        /// </summary>
        /// <param name="key">请求头的key</param>
        /// <param name="value">请求头的value</param>
        /// <returns></returns>
        public Dictionary <string, List <string> > AddHeader(string key, string value)
        {
            if (Header == null)
            {
                Header = new Dictionary <string, List <string> >();
            }
            List <string> headerValues = null;

            if (Header.ContainsKey(key))
            {
                headerValues = Header[key];
            }
            if (headerValues == null)
            {
                headerValues = new List <string>();
                headerValues.Add(value);
                Header.Add(key, headerValues);
            }
            else
            {
                headerValues.Add(value);
                Header[key] = headerValues;
            }
            return(Header);
        }
예제 #8
0
        /// <summary>
        /// Creates a new FITS image.
        /// </summary>
        /// <param name="File">File backing the image.</param>
        /// <param name="Width">Image width.</param>
        /// <param name="Height">Image height.</param>
        /// <param name="Transform">WCS transformation.</param>
        /// <param name="BitPix">BITPIX value.</param>
        /// <param name="ExtraProperties">Extra image properties to write in the header.</param>
        /// <param name="ReverseAxis">Reverses the order of the axis in the header.</param>
        public FitsImage(FitsFile File, uint Width, uint Height, WCSViaProjection Transform, int BitPix, List <ImageProperties> ExtraProperties = null, bool ReverseAxis = false) : this()
        {
            if (Width > MaxSize || Height > MaxSize)
            {
                throw new FITSFormatException("Image too large for Umbrella2.");
            }
            this.File      = File;
            this.Width     = Width;
            this.Height    = Height;
            this.Transform = Transform;
            BytesPerPixel  = (byte)Math.Abs(BitPix / 8);
            var RW = GetRW(BitPix);

            Reader  = RW.Item1;
            Writer  = RW.Item2;
            RAFirst = !ReverseAxis;
            Header  = GetHeader(BitPix);
            if (ExtraProperties != null)
            {
                foreach (ImageProperties prop in ExtraProperties)
                {
                    foreach (ElevatedRecord er in prop.GetRecords())
                    {
                        Header.Add(er.Name, er);
                    }
                }
            }
            File.SetPrimaryHeaders(Header);
        }
예제 #9
0
 public void AddHeader(ColumnRelevanceMapper column)
 {
     if (column != null)
     {
         Header.Add(column);
     }
 }
예제 #10
0
        private void CreateFrame()
        {
            SetLabel(Proxy.Label, Proxy.Tooltip);

            _addButton = AddHeaderButton(_addIcon.Texture, Proxy.AddTooltip, AddButtonUssClassName, AddItem);
            _addButton.SetEnabled(false);
            _removeButtons = Content.Query <IconButton>(className: RemoveButtonUssClassName).Build();

            _keyField = new TextField();
            _keyField.AddToClassList(HeaderKeyTextUssClassName);
            _keyField.RegisterValueChangedCallback(evt => AddKeyChanged(evt.newValue));
            _keyField.Q(TextField.textInputUssName).RegisterCallback <KeyDownEvent>(evt => KeyPressed(evt));

            var keyPlaceholder = new PlaceholderControl(Proxy.AddPlaceholder);

            keyPlaceholder.AddToField(_keyField);

            Header.Add(_keyField);
            _keyField.PlaceInFront(Label);

            var empty = new TextElement {
                text = Proxy.EmptyLabel, tooltip = Proxy.EmptyTooltip
            };

            empty.AddToClassList(EmptyLabelUssClassName);

            Content.Add(empty);

            _itemsContainer = new VisualElement();
            _itemsContainer.AddToClassList(ItemsUssClassName);

            Content.Add(_itemsContainer);
        }
예제 #11
0
        public void OnEvaluate_ShouldFindResult()
        {
            var evaluator = new HeaderEvaluator();
            var header    = new Header();

            header.Add(new JsonString("key_str", "value"));
            header.Add(new JsonLong("key_int", 20));


            var actual = evaluator.Evaluate("${call1.response.header.key_str}", CreateTestResult("call1", header));

            Assert.AreEqual("value", actual);

            actual = evaluator.Evaluate("${call1.response.header.key_int}", CreateTestResult("call1", header));
            Assert.AreEqual(20, long.Parse(actual));
        }
예제 #12
0
 private void ResponseHeader(PipeStream pipeStream)
 {
     if (Status == RequestStatus.RespondingHeader)
     {
         var indexof = pipeStream.IndexOf(HeaderTypeFactory.LINE_BYTES);
         while (indexof.End != null)
         {
             pipeStream.Read(mBuffer, 0, indexof.Length);
             if (indexof.Length == 2)
             {
                 Status = RequestStatus.RespondingBody;
                 return;
             }
             else
             {
                 var header = HttpParse.AnalyzeHeader(new ReadOnlySpan <byte>(mBuffer, 0, indexof.Length - 2));
                 Header.Add(new Property {
                     Name = header.Item1, Value = header.Item2
                 });
                 if (string.Compare(header.Item1, HeaderTypeFactory.TRANSFER_ENCODING, true) == 0 && string.Compare(header.Item2, "chunked", true) == 0)
                 {
                     mTransferEncoding = true;
                 }
                 if (string.Compare(header.Item1, HeaderTypeFactory.CONTENT_LENGTH, true) == 0)
                 {
                     mRequestLength = int.Parse(header.Item2);
                 }
             }
             indexof = pipeStream.IndexOf(HeaderTypeFactory.LINE_BYTES);
         }
     }
 }
예제 #13
0
        public AudioSection()
        {
            Padding = new MarginPadding {
                Right = 100
            };
            SectionName = "AUDIO";
            Header.Add(new SpriteText
            {
                Text   = "SELECT AUDIO DEVICE",
                X      = 5,
                Anchor = Anchor.BottomRight,
                Font   = KanojoWorksFont.GetFont(size: 16, weight: FontWeight.Bold)
            });

            Children = new Drawable[]
            {
                new SpriteText
                {
                    Text = "Master Volume",
                    Font = KanojoWorksFont.GetFont(size: 30, weight: FontWeight.Light),
                },
                new SpriteText
                {
                    Text = "Music Volume",
                    Font = KanojoWorksFont.GetFont(size: 30, weight: FontWeight.Light)
                },
                new SpriteText
                {
                    Text = "SFX Volume",
                    Font = KanojoWorksFont.GetFont(size: 30, weight: FontWeight.Light)
                },
            };
        }
예제 #14
0
        public void Append(string name, object content)
        {
            if (name == "header")
            {
                throw new Exception($"header为保留关键字,不允许使用。");
            }
            if (Header.Where(item => item.Name == name).Count() > 0)
            {
                throw new Exception($"已存在同名的数据项{name}");
            }
            byte[] data = BinaryHelper.Serialize(content);
            if (Header.EnablePage)
            {
                if (currentPos + data.Length > Header.MaxSize * 1024 * 1024)
                {
                    fs.Close();
                    currentPage++;
                    fs = new FileStream(Path.Combine(WorkDirectory, $"{Header.FileName}._{currentPage}"), FileMode.CreateNew);
                    fileList.Add(fs.Name);
                    currentPos = fs.Position;
                }
            }

            Header.Add(new DataEntry
            {
                Name    = name,
                PageNum = currentPage,
                Offset  = currentPos,
                Length  = data.Length
            });

            fs.Write(data, 0, data.Length);
            currentPos = fs.Position;
        }
예제 #15
0
        public void ShouldAddHeader(ExtendableOptions options)
        {
            var header = Header.Add("key", "value");

            header.Apply(options);

            Assert.That(options.GetHeaders(), Contains.Item(new KeyValuePair <string, string>("key", "value")));
        }
예제 #16
0
 public void AddHeader(string key, List <string> value)
 {
     if (Header == null)
     {
         Header = new Dictionary <string, List <string> >();
     }
     Header.Add(key, value);
 }
예제 #17
0
        public SheetHDR(ulong Id, string XmlSource, ExcelStream Excel, SharedStrings stringDictionary)
            : base(Id, Excel, stringDictionary)
        {
            var xd = new XmlDocument();
            xd.LoadXml(XmlSource);
            var rows = xd.GetElementsByTagName("row");
            // 遍历row标签
            var flag = false;
            Header = new Header();
            foreach (XmlNode x in rows)
            {
                var cols = x.ChildNodes;
                var objs = new Row(Header);
                // 遍历c标签
                foreach (XmlNode y in cols)
                {
                    string value = null;
                    // 如果是字符串类型,则需要从字典中查询
                    if (y.Attributes["t"]?.Value == "s")
                    {
                        var index = Convert.ToUInt64(y.FirstChild.InnerText);
                        value = StringDictionary[index];
                    }
                    else if (y.Attributes["t"]?.Value == "inlineStr")
                    {
                        value = y.FirstChild.FirstChild.InnerText;
                    }
                    // 否则其中的v标签值即为单元格内容
                    else
                    {
                        value = y.InnerText;
                    }

                    if (!flag)
                    {
                        Header.Add(value, y.Attributes["r"].Value);
                        continue;
                    }
                    objs.Add(value, y.Attributes["r"].Value);
                }
                if (!flag)
                {
                    while (Header.LastOrDefault() == null)
                        Header.RemoveAt(Header.Count - 1);
                    flag = true;
                    continue;
                }
                // 去掉末尾的null
                while (objs.LastOrDefault() == null)
                    objs.RemoveAt(objs.Count - 1);
                if (objs.Count > 0)
                    this.Add(objs);
            }
            while (this.Count > 0 && this.Last().Count == 0)
                this.RemoveAt(this.Count - 1);
            GC.Collect();
        }
예제 #18
0
    /// <summary>
    /// Initializes a new blank INI Streamer
    /// </summary>
    /// <param name="file"></param>
    public INIStreamer(string file)
    {
        m_File = file;

        Header.Clear();

        Header.Add("###########");
        Header.Add("Config File");
        Header.Add("Do not edit");
        Header.Add("###########");
    }
예제 #19
0
        public void ShouldBeVerifyable(ExtendableOptions options)
        {
            var header1 = Header.Add("key1", "value1");
            var header2 = Header.Add("key2", "value2");

            // only apply header1
            header1.Apply(options);

            Assert.IsTrue(header1.IsApplied(options));
            Assert.IsFalse(header2.IsApplied(options));
        }
예제 #20
0
        public void OnHeaderEquals_ShouldBeCaseInsensitive()
        {
            var header = new Header();

            header.Add("fullname", "Joel Miller");

            var anotherHeader = new Header();

            anotherHeader.Add("FullName", "Joel Miller");

            Assert.IsTrue(header.Equals(anotherHeader));
        }
예제 #21
0
        public void OnHeaderEquals_ValuesShouldCaseSensitive()
        {
            var header = new Header();

            header.Add("fullname", "Joel Miller");

            var anotherHeader = new Header();

            anotherHeader.Add("FullName", "joel miller");

            Assert.IsFalse(header.Equals(anotherHeader));
        }
예제 #22
0
        public void OnHeaderEquals_ShouldIgnoreSpecialWordNumber()
        {
            var header = new Header();

            header.Add("age", "35");

            var anotherHeader = new Header();

            anotherHeader.Add("age", "${NUMBER}");

            Assert.IsTrue(header.Equals(anotherHeader));
        }
예제 #23
0
        public void OnHeaderEquals_ShouldIgnoreSpecialWordANY()
        {
            var header = new Header();

            header.Add("fullname", "Joel Miller");

            var anotherHeader = new Header();

            anotherHeader.Add("FullName", "${ANY}");

            Assert.IsTrue(header.Equals(anotherHeader));
        }
예제 #24
0
        public void OnHeaderEquals_ShouldCompareValues()
        {
            var header = new Header();

            header.Add("fullname", "Joel Miller");

            var anotherHeader = new Header();

            anotherHeader.Add("FullName", "Wrong Name");

            Assert.IsFalse(header.Equals(anotherHeader));
        }
예제 #25
0
        public void AddHeader(string key, string value)
        {
            string item = $"{key}: {value}{LineTerminator}";

            if (Header.Where(a => a?.StartsWith(key) ?? false).Any())
            {
                return;
            }
            else
            {
                Header.Add(item);
            }
        }
예제 #26
0
        private void Setup()
        {
            _icon = new Image();
            _icon.AddToClassList(IconUssClassName);
            _icon.style.width  = ExpandedIcon.Texture.width;
            _icon.style.height = ExpandedIcon.Texture.height;
            _icon.AddManipulator(new Clickable(() => IsExpanded = !IsExpanded));

            Header.Add(_icon);
            _icon.PlaceBehind(Label);

            Refresh();
        }
예제 #27
0
        private void CreateSecurityElement()
        {
            Header.Add(new XElement(wsse + "Security",
                                    new XAttribute(soapenv + "actor", "http://smev.gosuslugi.ru/actors/smev"),
                                    new XElement(wsse + "BinarySecurityToken",
                                                 new XAttribute("EncodingType",
                                                                "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary"),
                                                 new XAttribute("ValueType",
                                                                "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3"),
                                                 new XAttribute(wsu + "Id", "CertId")
                                                 ),
                                    new XElement(ds + "Signature",
                                                 new XElement(ds + "SignedInfo",
                                                              new XElement(ds + "CanonicalizationMethod",
                                                                           new XAttribute("Algorithm",
                                                                                          "http://www.w3.org/2001/10/xml-exc-c14n#")
                                                                           ),
                                                              new XElement(ds + "SignatureMethod",
                                                                           new XAttribute("Algorithm",
                                                                                          "http://www.w3.org/2001/04/xmldsig-more#gostr34102001-gostr3411")
                                                                           ),
                                                              new XElement(ds + "Reference",
                                                                           new XAttribute("URI", "#body"),
                                                                           new XElement(ds + "Transforms",
                                                                                        new XElement(ds + "Transform",
                                                                                                     new XAttribute(
                                                                                                         "Algorithm",
                                                                                                         "http://www.w3.org/2001/10/xml-exc-c14n#"))
                                                                                        ),
                                                                           new XElement(ds + "DigestMethod",
                                                                                        new XAttribute("Algorithm",
                                                                                                       "http://www.w3.org/2001/04/xmldsig-more#gostr3411")),
                                                                           new XElement(ds + "DigestValue")
                                                                           )

                                                              ),
                                                 new XElement(ds + "SignatureValue"),
                                                 new XElement(ds + "KeyInfo",
                                                              new XElement(wsse + "SecurityTokenReference",
                                                                           new XElement(wsse + "Reference",
                                                                                        new XAttribute("URI", "#CertId"),
                                                                                        new XAttribute("ValueType",
                                                                                                       "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3")
                                                                                        )
                                                                           )
                                                              )
                                                 )
                                    )
                       );
        }
예제 #28
0
        public void ShouldAddMultipleHeaders(ExtendableOptions options)
        {
            var header1 = Header.Add("key1", "value1");
            var header2 = Header.Add("key2", "value2");
            var header3 = Header.Add("key3", "value3");

            header1.Apply(options);
            header2.Apply(options);
            header3.Apply(options);

            Assert.That(options.GetHeaders(), Contains.Item(new KeyValuePair <string, string>("key1", "value1")));
            Assert.That(options.GetHeaders(), Contains.Item(new KeyValuePair <string, string>("key2", "value2")));
            Assert.That(options.GetHeaders(), Contains.Item(new KeyValuePair <string, string>("key3", "value3")));
        }