コード例 #1
0
        public RequestContext(string inputMessage, List <string> list)
        {
            messagesList = list;
            var messageSplitLine = inputMessage.Split("\r\n");

            FirstLine = messageSplitLine[0];
            int rowCount = 2;

            GetAuthToken(messageSplitLine);
            int index = FindContentLength(messageSplitLine);

            content = messageSplitLine[index + rowCount];



            if (body == true)
            {
                while (content.Length != contentlength)
                {
                    rowCount++;
                    content += "\r\n";
                    content += messageSplitLine[index + rowCount];
                }
            }

            var messageSplit = FirstLine.Split(" ");

            Method   = messageSplit[0];
            endpoint = messageSplit[1];
            var messagePathSplit = endpoint.Split("/");
        }
コード例 #2
0
ファイル: RequestContext.cs プロジェクト: FlewRian/MTCG
        public RequestContext(string inputMessage, List <string> list)
        {
            messagesList = list;                                                        //Teilen des erhaltenen String
            var messageSplitLine = inputMessage.Split("\r\n");                          //bei wird \r\n geteilt und diese werden herausgefiltert

            FirstLine = messageSplitLine[0];
            int rowCount = 2;
            int index    = FindContentLength(messageSplitLine);

            FindAuthorization(messageSplitLine);
            Content = messageSplitLine[index + rowCount];



            if (BodyExists == true)
            {
                while (Content.Length != ContentLength)                                 //Bei mehr als einer Zeile in der Nachricht wird diese an den String Content angehängt
                {
                    rowCount++;
                    Content += "\r\n";
                    Content += messageSplitLine[index + rowCount];
                }
            }

            var messageSplit = FirstLine.Split(" ");                                    //Split bei " "

            HttpVerb    = messageSplit[0];
            MessagePath = messageSplit[1];
            var messagePathSplit = MessagePath.Split("/");                              //Split bei "/"
        }
コード例 #3
0
 //Get the host of the request
 public string GetHost()
 {
     if (HasHeader("Host"))
     {
         return(GetHeader("Host").Value);
     }
     return(FirstLine.Split(' ')[1]);
 }
コード例 #4
0
 public override int GetHashCode()
 {
     unchecked // Overflow is fine, just wrap
     {
         int hash = 17;
         // Suitable nullity checks etc, of course :)
         hash = hash * 486187739 + FirstLine.GetHashCode();
         hash = hash * 486187739 + Postcode.GetHashCode();
         return(hash);
     }
 }
コード例 #5
0
        public void FirstLine_ParseFirstLine_WhenAParagraphIsProvidedWithQuestionMarkAtTheEndOfTheFirstSentence_ThenFirstLineIsReturned()
        {
            // Arrange
            string input = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua? Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.";

            // Act
            string result = FirstLine.ParseFirstLine(input);

            // Assert
            result
            .Should()
            .Be("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua?");
        }
コード例 #6
0
        public void FirstLine_ParseFirstLine_WhenOneSentenceIsProvidedWithNoFullStop_ThenSameTextIsReturned()
        {
            // Arrange
            string input = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua";

            // Act
            string result = FirstLine.ParseFirstLine(input);

            // Assert
            result
            .Should()
            .Be("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua");
        }
コード例 #7
0
        //Check if the request is cacheable
        public bool IsCacheable()
        {
            // Check if it is a get request (these are not cachable)
            if (!FirstLine.Split(' ')[0].ToLower().Contains("get"))
            {
                return(false);
            }
            // If request has a 'Cache-Control: private' header, request is not cacheable.
            if (HasHeader("Cache-Control") && GetHeader("Cache-Control").Value == "private")
            {
                return(false);
            }

            return(true);
        }
コード例 #8
0
        public void OnSTL()
        {
            var str = "";

            if (stlTimeSlider >= swAddin.firstStlLineInCode)
            {
                FirstLine.BringToFront();
                ScrollCode.BringToFront();
                CodeWindow.Padding = new System.Windows.Forms.Padding(0, 12, 0, 0);
                var firstLineIndex = swAddin.model_code_xrefSTL[TimeMax.Value];
                var thisIndex      = firstLineIndex + stlCodeOffset;
                if (swAddin.stlCode.Count - 1 >= thisIndex && thisIndex > 0)
                {
                    FirstLine.Text = swAddin.stlCode[thisIndex];
                }
                for (int i = thisIndex + 1; i < thisIndex + max; i++)
                {
                    if (swAddin.stlCode.Count > i)
                    {
                        str += swAddin.stlCode[i];
                    }
                }
                CodeWindow.Text = str;
                var _swSurface = swAddin.stlSurfaces[stlTimeSlider];
                //var _p1 = _swLine.p1;
                //var _p2 = _swLine.p2;
                //p1xDisplay.Text = _p1.x.ToString("f5");
                //p1yDisplay.Text = _p1.y.ToString("f5");
                //p1zDisplay.Text = _p1.z.ToString("f5");
                //p2xDisplay.Text = _p2.x.ToString("f5");
                //p2yDisplay.Text = _p2.y.ToString("f5");
                //p2zDisplay.Text = _p2.z.ToString("f5");
                //var c = _swLine.ThisSketchLine.MakeInfinite();
            }
            else
            {
                for (int i = stlTimeSlider + stlCodeOffset; i < stlTimeSlider + stlCodeOffset + max; i++)
                {
                    if (swAddin.stlCode.Count > i)
                    {
                        str += swAddin.stlCode[i];
                    }
                }
                FirstLine.SendToBack();
                CodeWindow.Padding = new System.Windows.Forms.Padding(0, 0, 0, 0);
                CodeWindow.Text    = str;
            }
        }
コード例 #9
0
        private void ChooseFileButton_Click(object sender, EventArgs e)
        {
            string Text;
            int    Counter = 0;

            string[] ArrayLine    = null;
            string   ResultedText = "";
            string   FirstLine;

            string[] ArrayCluster = null;
            string[] Alphabet     = new string[] { "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "W", "X", "Z", "V", "Y" };
            if (OpenFileDialog.ShowDialog() == DialogResult.OK)
            {
                string FileName = OpenFileDialog.FileName;
                try
                {
                    using (var Stream = new StreamReader(FileName, Encoding.UTF8))
                    {
                        Text = Stream.ReadToEnd();
                        UnsortedTextbox.Text = "Your Filesystem:" + Environment.NewLine + Text + Environment.NewLine + "Your Files:" + Environment.NewLine;

                        FirstLine = File.ReadLines(FileName).Skip(0).First();
                        string[] ElemsOfFirstLine = FirstLine.Split(' ');

                        string SecondLine = File.ReadLines(FileName).Skip(1).First();
                        ArrayCluster = new string[(SecondLine.Length + 1) / 2];
                        ArrayCluster = SecondLine.Split(' ');
                        string[] ArrayClusterCopy = SecondLine.Split(' ');

                        Counter   = ElemsOfFirstLine.Length / 2 + 1;
                        ArrayLine = new string[Counter];
                        int i = 0;
                        for (int j = 0; j != ArrayLine.Length; j++)
                        {
                            if (i < ElemsOfFirstLine.Length)
                            {
                                ArrayLine[j] = ElemsOfFirstLine[i] + " " + ElemsOfFirstLine[i + 1];
                                int    StarterValue = Convert.ToInt32(ElemsOfFirstLine[i + 1]);
                                string NextValue    = ArrayCluster[StarterValue];
                                while (NextValue != "eof" && NextValue != "bad" && NextValue != "0")
                                {
                                    ArrayLine[j] += " " + NextValue;
                                    StarterValue  = Convert.ToInt32(ArrayCluster[StarterValue]);
                                    NextValue     = ArrayCluster[StarterValue];
                                }
                                if (NextValue == "eof")
                                {
                                    ArrayLine[j] += " eof";
                                }
                                if (NextValue == "bad")
                                {
                                    ArrayLine[j] += " bad";
                                }
                                i += 2;
                                UnsortedTextbox.Text += ArrayLine[j] + Environment.NewLine;
                            }
                        }

                        for (int j = 0; j != ElemsOfFirstLine.Length; j += 2)
                        {
                            int    FirstValue = Convert.ToInt32(ElemsOfFirstLine[j + 1]);
                            string NextValue  = ArrayClusterCopy[FirstValue];
                            while (NextValue != "eof" && NextValue != "bad" && NextValue != "0")
                            {
                                int IndexOfCopyArray = FirstValue;
                                FirstValue = Convert.ToInt32(NextValue);
                                NextValue  = ArrayClusterCopy[FirstValue];
                                ArrayClusterCopy[IndexOfCopyArray] = "0";
                            }
                            if (NextValue == "eof")
                            {
                                ArrayClusterCopy[FirstValue] = "0";
                            }
                            if (NextValue == "bad")
                            {
                                ArrayClusterCopy[FirstValue] = "0";
                            }
                        }

                        string OtherLine = "";
                        for (int j = 0; j != ArrayClusterCopy.Length; j++)
                        {
                            if (ArrayClusterCopy[j] != "0")
                            {
                                if (OtherLine == "")
                                {
                                    OtherLine = Convert.ToString(j);
                                    int    FirstValue = j;
                                    string NextValue  = ArrayClusterCopy[FirstValue];
                                    while (NextValue != "eof" && NextValue != "bad" && NextValue != "0")
                                    {
                                        int f = FirstValue;
                                        OtherLine          += " " + NextValue;
                                        FirstValue          = Convert.ToInt32(ArrayClusterCopy[FirstValue]);
                                        NextValue           = ArrayClusterCopy[FirstValue];
                                        ArrayClusterCopy[f] = "0";
                                    }
                                    if (NextValue == "eof")
                                    {
                                        OtherLine += " eof";
                                        ArrayClusterCopy[FirstValue] = "0";
                                    }
                                    if (NextValue == "bad")
                                    {
                                        OtherLine += " bad";
                                        ArrayClusterCopy[FirstValue] = "0";
                                    }
                                }
                                else
                                {
                                    int indexOfSubstring = OtherLine.IndexOf(ArrayClusterCopy[j]);
                                    OtherLine = OtherLine.Insert(indexOfSubstring, ArrayClusterCopy[j] + " ");
                                }
                            }
                        }
                        ArrayLine[ArrayLine.Length - 1] = OtherLine;
                        UnsortedTextbox.Text           += ArrayLine[ArrayLine.Length - 1] + Environment.NewLine;
                    }
                    int[] ArrayofEmptyClusters = new int[32];
                    for (int j = 0; j != ArrayofEmptyClusters.Length; j++)
                    {
                        ArrayofEmptyClusters[j] = 0;
                    }

                    bool FirstSign = false;
                    bool Overlay   = false;

                    for (int i = 0; i != ArrayLine.Length; i++)
                    {
                        if (ArrayLine[i] != null && ArrayLine[i] != "")
                        {
                            string   Line        = ArrayLine[i];
                            string[] ElemOfFiles = Line.Split(' ');
                            SortedTextbox.Text += Line;
                            bool Yes = false;
                            for (int j = 0; j != ElemOfFiles.Length; j++)
                            {
                                if (Yes == false)
                                {
                                    if (ElemOfFiles[0] == Alphabet[i])
                                    {
                                        ResultedText += ElemOfFiles[0];
                                    }
                                    else
                                    {
                                        ResultedText       += Alphabet[i];
                                        FirstLine          += " " + Alphabet[i] + " " + ElemOfFiles[0];
                                        SortedTextbox.Text += Environment.NewLine + "File was lost in your filesystem. It was added under name '" + Alphabet[i] + "'" + Environment.NewLine;
                                        FirstSign           = true;
                                    }
                                    Yes = true;
                                }
                                //////////
                                if (ElemOfFiles[j] != Alphabet[i] && ElemOfFiles[j] != "eof" && ElemOfFiles[j] != "bad")
                                {
                                    int k = Convert.ToInt32(ElemOfFiles[j]);
                                    if (ArrayofEmptyClusters[k] == 0)
                                    {
                                        ArrayofEmptyClusters[k] = k;
                                        ResultedText           += " " + ElemOfFiles[j];
                                    }
                                    else
                                    {
                                        Overlay             = true;
                                        SortedTextbox.Text += Environment.NewLine + "Crossing of adresses " + ElemOfFiles[j] + ". Duplicate elements will be rewritten to empty cells" + Environment.NewLine;
                                        bool Record = false;
                                        for (int a = 0; a != ArrayofEmptyClusters.Length; a++)
                                        {
                                            if (Record == false)
                                            {
                                                if (ArrayofEmptyClusters[a] == 0)
                                                {
                                                    Record = true;
                                                    ArrayofEmptyClusters[a] = k;
                                                    ResultedText           += " " + a;
                                                    ArrayCluster[Convert.ToInt32(ElemOfFiles[j - 1])] = Convert.ToString(a);
                                                    ArrayCluster[a] = "eof";
                                                    ElemOfFiles[j]  = Convert.ToString(a);
                                                }
                                            }
                                        }
                                        Record = false;
                                    }
                                }
                                else
                                {
                                    if (ElemOfFiles[j] == "eof")
                                    {
                                        if (FirstSign == false && Overlay == false)
                                        {
                                            SortedTextbox.Text += Environment.NewLine + "No errors found" + Environment.NewLine;
                                        }
                                        ResultedText += " " + "eof" + Environment.NewLine;
                                    }
                                    if (ElemOfFiles[j] == "bad")
                                    {
                                        SortedTextbox.Text += Environment.NewLine + "Found a badblock. Deleting this file" + Environment.NewLine;
                                        ResultedText       += " " + "eof" + Environment.NewLine;
                                        ArrayCluster[Convert.ToInt32(ElemOfFiles[j - 1])] = "eof";
                                    }
                                }
                                if (j == ElemOfFiles.Length - 1)
                                {
                                    if (ElemOfFiles[j] != "eof" && ElemOfFiles[j] != "bad")
                                    {
                                        SortedTextbox.Text += Environment.NewLine + "The end of the file was omitted. This error will be corrected by writing 'Eof' to the last cell." + Environment.NewLine;
                                        ResultedText       += " " + "eof" + Environment.NewLine;
                                        ArrayCluster[Convert.ToInt32(ElemOfFiles[j])] = "eof";
                                    }
                                }
                            }
                        }
                    }

                    SortedTextbox.Text += Environment.NewLine + "Fixed filesystem:" + Environment.NewLine + ResultedText + Environment.NewLine;
                }
                catch
                {
                    MessageBox.Show("Bad data from file");
                }
            }
            else
            {
                MessageBox.Show("Unable to read file");
            }
        }
コード例 #10
0
 //Filter a certain file type
 public bool HasContentToFilter()
 {
     string[] fileTypesToFilter = new string[] { ".png" };
     return(fileTypesToFilter.Any(fileType => FirstLine.Split(' ')[1].ToLower().Contains(fileType)));
 }
コード例 #11
0
ファイル: TBaseWorkShape.cs プロジェクト: atomaszz/gelios
 void PaintFirstFlag()
 {
     FirstLine.DrawFlagS = F_DrawFirstFlag;
     FirstLine.Prepare();
 }