Example #1
0
        public void Parse(List <string> headerValues)
        {
            HeaderParser parser = new HeaderParser(headerValues[0]);
            HeaderValue  value;

            if (parser.TryGet("timeout", out value) && value.HasValue)
            {
                int intValue = 0;
                if (int.TryParse(value.Value, out intValue))
                {
                    this.TimeOut = TimeSpan.FromSeconds(intValue);
                }
                else
                {
                    this.TimeOut = TimeSpan.MaxValue;
                }
            }

            if (parser.TryGet("max", out value) && value.HasValue)
            {
                int intValue = 0;
                if (int.TryParse("max", out intValue))
                {
                    this.MaxRequests = intValue;
                }
                else
                {
                    this.MaxRequests = int.MaxValue;
                }
            }
        }
 internal HeaderInfo(string name, bool requestRestricted, bool responseRestricted, bool multi, HeaderParser p) {
     HeaderName = name;
     IsRequestRestricted = requestRestricted;
     IsResponseRestricted = responseRestricted;
     Parser = p;
     AllowMultiValues = multi;
 }
Example #3
0
        /// <summary>
        ///     Handle upgrade to websocket
        /// </summary>
        private async Task handleWebSocketUpgrade(SessionEventArgs args,
                                                  HttpClientStream clientStream, TcpServerConnection serverConnection,
                                                  CancellationTokenSource cancellationTokenSource, CancellationToken cancellationToken)
        {
            await serverConnection.Stream.WriteRequestAsync(args.HttpClient.Request, cancellationToken);

            var httpStatus = await serverConnection.Stream.ReadResponseStatus(cancellationToken);

            var response = args.HttpClient.Response;

            response.HttpVersion       = httpStatus.Version;
            response.StatusCode        = httpStatus.StatusCode;
            response.StatusDescription = httpStatus.Description;

            await HeaderParser.ReadHeaders(serverConnection.Stream, response.Headers,
                                           cancellationToken);

            if (!args.IsTransparent)
            {
                await clientStream.WriteResponseAsync(response, cancellationToken);
            }

            // If user requested call back then do it
            if (!args.HttpClient.Response.Locked)
            {
                await onBeforeResponse(args);
            }

            await TcpHelper.SendRaw(clientStream, serverConnection.Stream, BufferPool,
                                    args.OnDataSent, args.OnDataReceived, cancellationTokenSource, ExceptionFunc);
        }
 internal HeaderInfo(string name, bool restricted, bool multi, HeaderParser p)
 {
     HeaderName       = name;
     IsRestricted     = restricted;
     Parser           = p;
     AllowMultiValues = multi;
 }
        private List <string> GetAllReferences(string dacpacPath)
        {
            var parser = new HeaderParser(dacpacPath);

            var references = parser.GetCustomData()
                             .Where(p => p.Category == "Reference" && p.Type == "SqlSchema")
                             .ToList();

            if (references.Count == 0)
            {
                return(Enumerable.Empty <string>().ToList());
            }

            var fileNames = references
                            .SelectMany(r => r.Items)
                            .Where(i => i.Name == "FileName")
                            .Select(i => i.Value)
                            .ToList();

            if (fileNames.Count() == 0)
            {
                return(Enumerable.Empty <string>().ToList());
            }

            var additionalFiles = new List <string>();

            foreach (var fileName in fileNames)
            {
                additionalFiles.AddRange(GetAllReferences(fileName));
            }

            fileNames.AddRange(additionalFiles);

            return(fileNames.Distinct().ToList());
        }
Example #6
0
 internal HeaderInfo(string name, bool restricted, bool multivalue, HeaderParser parser)
 {
     _name = name;
     _restricted = restricted;
     _parser = parser;
     _multivalue = multivalue;
 }
Example #7
0
        public void Can_Read_Standard_Headers()
        {
            var parser    = new HeaderParser(".\\Test.dacpac");
            var ansiNulls = parser.GetCustomData().FirstOrDefault(p => p.Category == "AnsiNulls");

            Assert.AreEqual("True", ansiNulls.Items.FirstOrDefault(p => p.Name == "AnsiNulls").Value);
        }
        /// <summary>
        ///     Handle upgrade to websocket
        /// </summary>
        private async Task handleWebSocketUpgrade(string httpCmd,
                                                  SessionEventArgs args, Request request, Response response,
                                                  CustomBufferedStream clientStream, HttpResponseWriter clientStreamWriter,
                                                  TcpServerConnection serverConnection,
                                                  CancellationTokenSource cancellationTokenSource, CancellationToken cancellationToken)
        {
            // prepare the prefix content
            await serverConnection.StreamWriter.WriteLineAsync(httpCmd, cancellationToken);

            await serverConnection.StreamWriter.WriteHeadersAsync(request.Headers,
                                                                  cancellationToken : cancellationToken);

            string httpStatus;

            try
            {
                httpStatus = await serverConnection.Stream.ReadLineAsync(cancellationToken);

                if (httpStatus == null)
                {
                    throw new ServerConnectionException("Server connection was closed.");
                }
            }
            catch (Exception e) when(!(e is ServerConnectionException))
            {
                throw new ServerConnectionException("Server connection was closed.", e);
            }

            Version responseVersion;
            int     responseStatusCode;
            string  responseStatusDescription;

            Response.ParseResponseLine(httpStatus, out responseVersion,
                                       out responseStatusCode,
                                       out responseStatusDescription);
            response.HttpVersion       = responseVersion;
            response.StatusCode        = responseStatusCode;
            response.StatusDescription = responseStatusDescription;

            await HeaderParser.ReadHeaders(serverConnection.Stream, response.Headers,
                                           cancellationToken);

            if (!args.IsTransparent)
            {
                await clientStreamWriter.WriteResponseAsync(response,
                                                            cancellationToken : cancellationToken);
            }

            // If user requested call back then do it
            if (!args.WebSession.Response.Locked)
            {
                await invokeBeforeResponse(args);
            }

            await TcpHelper.SendRaw(clientStream, serverConnection.Stream, BufferPool, BufferSize,
                                    (buffer, offset, count) => { args.OnDataSent(buffer, offset, count); },
                                    (buffer, offset, count) => { args.OnDataReceived(buffer, offset, count); },
                                    cancellationTokenSource, ExceptionFunc);
        }
 /// <summary>
 ///     Initializes a new instance of the <see cref="HttpMessageDecoder" /> class.
 /// </summary>
 public HttpMessageDecoder()
 {
     _headerParser = new HeaderParser();
     _headerParser.HeaderParsed      = OnHeader;
     _headerParser.RequestLineParsed = OnRequestLine;
     _headerParser.Completed         = OnHeaderParsed;
     _messageReceived = delegate { };
 }
Example #10
0
        public void Parse()
        {
            var parser = new HeaderParser(CHeaderLexer.Lex(
                                              "/** Some function */\n" +
                                              "void frob_widgets(widget *widgets, int num_widgets);"));

            iDeclarations = parser.ParseHeader().ToArray();
        }
Example #11
0
        public void WhenParsingUnsignedInt_TheUnsignedQualifierIsApplied()
        {
            var parser = new HeaderParser(CHeaderLexer.Lex(
                                              "unsigned int foo;"));
            var declaration = parser.ParseHeader().Single();

            Assert.That(declaration.CType.Qualifiers, Is.EqualTo(new[] { "unsigned" }));
        }
 internal HeaderInfo(string name, bool requestRestricted, bool responseRestricted, bool multi, HeaderParser p)
 {
     this.HeaderName           = name;
     this.IsRequestRestricted  = requestRestricted;
     this.IsResponseRestricted = responseRestricted;
     this.Parser           = p;
     this.AllowMultiValues = multi;
 }
Example #13
0
        public void WhenParsingInt_TheUnsignedQualifierIsNotApplied()
        {
            var parser = new HeaderParser(CHeaderLexer.Lex(
                                              "int foo;"));
            var declaration = parser.ParseHeader().Single();

            Assert.That(declaration.CType.Qualifiers, Is.Empty);
        }
Example #14
0
        public void TestRoundtrip()
        {
            // ARRANGE
            // =======
            // File
            FileInformation fi = new FileInformation();

            byte[] sourceFile = fi.FileContents;

            // Encryption and Decryption
            FormMain        mainForm = new FormMain(); // MainForm also holds user preferences in memory.
            PasswordHandler pwh      = new PasswordHandler("password", mainForm);
            AESencrypter    aesEnc   = new AESencrypter(fi.GenerateFileInfoHeader(), fi.FileContents, mainForm);
            AESdecrypter    aesDec   = new AESdecrypter(mainForm);

            byte[] encryptedFile;
            byte[] decryptedFile;

            // Bitmap Encoder and Decoder
            BitmapEncoder bmpEncoder = new BitmapEncoder();
            BitmapDecoder bmpDecoder = new BitmapDecoder(false);
            Bitmap        encodedBitmap;

            byte[] bytesFromImage;

            // Header Parser
            HeaderParser hp = new HeaderParser();

            byte[] parsedDecrypted;

            // ACT
            // ===
            Task.Run(async() => {
                // Encrypt the file.
                encryptedFile = aesEnc.EncryptBytes();

                // Encode the encrypted file into the bitmap.
                encodedBitmap = await bmpEncoder.EncodedBitmap(encryptedFile, aesEnc.InitializationVector);

                // Retrieve the encrypted bytes back out of the bitmap.
                bytesFromImage = await bmpDecoder.BytesFromImage(encodedBitmap);

                // Decrypt the bytes pulled from the image.
                decryptedFile = aesDec.DecryptedBytes(bytesFromImage, mainForm.EncryptionKey, aesEnc.InitializationVector);

                // Parse the header from the decrypted file.
                parsedDecrypted = hp.fileContentsWithoutHeader(decryptedFile);

                // ASSERT
                // ======
                for (int i = 0; i < fi.FileContents.Length; i++)
                {
                    // Assert that the bytes that went in are the same as the bytes that came out.
                    Assert.AreEqual(fi.FileContents[i], parsedDecrypted[i]);
                }
            }).GetAwaiter().GetResult();
        }
Example #15
0
        public void GetVisitDate_AdjustsYearToCurrentCenturyIfOlderThan1980()
        {
            var csvParser = new CsvParser("            DATE  ,01/03/1918");
            var parser    = new HeaderParser(csvParser);

            var visitDate = parser.GetVisitDate();

            Assert.That(visitDate.Year, Is.EqualTo(2018));
        }
Example #16
0
            static void ThrowTooLongFrameException(HeaderParser parser, int length)
            {
                throw GetTooLongFrameException();

                TooLongFrameException GetTooLongFrameException()
                {
                    return(new TooLongFrameException(parser.NewExceptionMessage(length)));
                }
            }
Example #17
0
        public UnpackResult Unpack(BinaryReader reader)
        {
            _reader = reader;

            UnpackResult result = null;

            try
            {
                byte[] identifier;
                byte[] header;
                byte[] actions;
                byte[] map;

                // unpack the identifier and header
                identifier = ZlibUnpack(IDENTIFIER_LENGTH);
                int identity = Common.ToInteger(identifier);
                if (identity != 1397908850 /*new patch replay */ && identity != 1397908851)
                {
                    throw
                        new Exception(
                            "Not a valid replay file!"); //if a file somehow makes it here before any of the other exceptions (typically would throw insufficient space in decode buffer first)
                }

                /*
                 * header = UnpackNextSection(HEADER_LENGTH);
                 * Console.WriteLine(_reader.BaseStream.Position.ToString("X"));
                 *
                 * int actionsSize = Common.ToInteger(UnpackNextSection(SECTION_SIZE_LENGTH));
                 * actions = UnpackNextSection(actionsSize);
                 *
                 * int mapSize = Common.ToInteger(UnpackNextSection(SECTION_SIZE_LENGTH));
                 * map = UnpackNextSection(mapSize);
                 */

                header = ZlibUnpack(HEADER_LENGTH, true);
                Header headerUnpacked = new HeaderParser(header).ParseHeader();
                //Console.WriteLine(headerUnpacked.GameCreator);


                // unpack the actions section
                int actionsSize = Common.ToInteger(ZlibUnpack(SECTION_SIZE_LENGTH));
                actions = ZlibUnpack(actionsSize);

                // unpack the map section
                int mapSize = Common.ToInteger(ZlibUnpack(SECTION_SIZE_LENGTH));
                map = ZlibUnpack(mapSize);


                result = new UnpackResult(identifier, header, actions, map);
            }
            finally
            {
                reader.Close();
            }

            return(result);
        }
Example #18
0
        public void Fields_TagList()
        {
            string       xml    = baseXml;
            HeaderParser parser = new HeaderParser(GetDoc(xml));

            Assert.Equal(2, parser.Header.Fields[0].Tags.Length);
            Assert.Equal("$ascii", parser.Header.Fields[0].Tags[0]);
            Assert.Equal("$text", parser.Header.Fields[0].Tags[1]);
        }
Example #19
0
        public void WhenParsingConstIntStarConst_TheConstQualifierIsAppliedToBoth()
        {
            var parser = new HeaderParser(CHeaderLexer.Lex(
                                              "const int * const foo;"));
            var declaration = parser.ParseHeader().Single();
            var ptrType     = (PointerCType)declaration.CType;

            Assert.That(ptrType.Qualifiers, Is.EqualTo(new[] { "const" }));
            Assert.That(ptrType.BaseType.Qualifiers, Is.EqualTo(new[] { "const" }));
        }
Example #20
0
 public void ParsesHeaderFields()
 {
     foreach (HeaderFieldTest test in HeaderFields)
     {
         string       xml         = baseXml;
         HeaderParser parser      = new HeaderParser(GetDoc(xml));
         object       actualValue = typeof(QvdHeader).GetProperty(test.PropertyName).GetValue(parser.Header);
         Assert.Equal(test.value, actualValue);
     }
 }
Example #21
0
        public void Fields_NumberFormat()
        {
            string       xml    = baseXml;
            HeaderParser parser = new HeaderParser(GetDoc(xml));
            NumberFormat format = parser.Header.Fields[0].NumberFormat;

            Assert.Equal("UNKNOWN", format.Type);
            Assert.Equal(0, (int)format.NDec);
            Assert.Null(format.Fmt);
        }
Example #22
0
    public IEnumerable <string> GetValues(string key)
    {
        StringValues values;

        if (Store.TryGetValue(key, out values))
        {
            return(HeaderParser.SplitValues(values));
        }
        return(HeaderParser.Empty);
    }
Example #23
0
        public void WhenParsingIntConstStar_TheConstQualifierIsAppliedToTheInt()
        {
            var parser = new HeaderParser(CHeaderLexer.Lex(
                                              "int const *foo;"));
            var declaration = parser.ParseHeader().Single();
            var ptrType     = (PointerCType)declaration.CType;

            Assert.That(ptrType.BaseType.Qualifiers, Is.EqualTo(new[] { "const" }));
            Assert.That(ptrType.Qualifiers, Is.Empty);
        }
Example #24
0
        public async Task <ActionResult> Index(int?page = 1)
        {
            var client = ExpenseTrackerHttpClient.GetClient();

            var model = new ExpenseGroupsViewModel();

            // Calling the GET method on API
            HttpResponseMessage egsResponse = await client.GetAsync("api/expensegroupstatusses");

            if (egsResponse.IsSuccessStatusCode)
            {
                string egsContent = await egsResponse.Content.ReadAsStringAsync();

                var lstExpenseGroupStatusses = JsonConvert
                                               .DeserializeObject <IEnumerable <ExpenseGroupStatus> >(egsContent);

                model.ExpenseGroupStatusses = lstExpenseGroupStatusses;
            }
            else
            {
                return(Content("An error occurred."));
            }

            // Without sorting
            //HttpResponseMessage response = await client.GetAsync("api/expensegroups");

            // With sorting. Expense groups will be sorted first by status code and then by title
            //HttpResponseMessage response = await client.GetAsync("api/expensegroups?sort=expensegroupstatusid,title");

            // With paging. We already have suport for paging in API but we need to add new support in the client.
            // I added PagingInfo.cs & HeaderParser.cs helper classes to implement paging on this MVC client.
            HttpResponseMessage response = await client.GetAsync("api/expensegroups?sort=expensegroupstatusid,title&page=" + page + "&pagesize=5");

            if (response.IsSuccessStatusCode)
            {
                string content = await response.Content.ReadAsStringAsync();

                var pagingInfo       = HeaderParser.FindAndParsePagingInfo(response.Headers); // Also, added NuGet package pagedlist.mvc to implement paging
                var lstExpenseGroups = JsonConvert.DeserializeObject <IEnumerable <ExpenseGroup> >(content);

                var pagedExpenseGroupsList = new StaticPagedList <ExpenseGroup>(lstExpenseGroups,
                                                                                pagingInfo.CurrentPage,
                                                                                pagingInfo.PageSize,
                                                                                pagingInfo.TotalCount);

                model.ExpenseGroups = pagedExpenseGroupsList;
                model.PagingInfo    = pagingInfo;
            }
            else
            {
                return(Content("An error occurred."));
            }

            return(View(model));
        }
Example #25
0
        /// <summary>
        /// 抓取新闻
        /// </summary>
        /// <returns></returns>
        private NewsBody[] CrawleNews()
        {
            LogManager.WriteLine("Crawle news rss...");

            List <NewsHeader> headers = new List <NewsHeader>();

            for (int i = 0; i < ConfigManager.Config.Rss.Length; i++)
            {
                string xmlUrl = ConfigManager.Config.Rss[i][0];

                if (xmlUrl.StartsWith("#"))//使用#暂时屏蔽订阅
                {
                    continue;
                }

                string rssClass = ConfigManager.Config.Rss[i][1];
                try
                {
                    string xml = Client.GET(xmlUrl);
                    headers.AddRange(RssParser.Parse(xml, rssClass));
                }
                catch (Exception ex)
                {
                    LogManager.ShowException(ex, "Cannot get " + xmlUrl);
                }
            }


            LogManager.WriteLine("Crawle news body...");
            int count = 0;

            List <NewsBody> bodyList = new List <NewsBody>();

            foreach (NewsHeader header in headers)
            {
                count++;
                if (count % 5 == 0)//每爬去5个新闻提示一次
                {
                    LogManager.WriteLine(string.Format("<{0}> items done...", count));
                }
                try
                {
                    NewsBody body = HeaderParser.Parse(header);

                    bodyList.Add(body);
                }
                catch (Exception ex)
                {
                    LogManager.ShowException(ex);
                }
            }

            return(bodyList.ToArray());
        }
        // GET: ExpenseGroup

        public async Task <ActionResult> Index(int?page = 1)
        {
            var client = ExpenseTrackerHttpClient.GetClient();

            var model = new ExpenseGroupsViewModel();

            var egsResponse = await client.GetAsync("api/expensegroupstatusses");

            if (egsResponse.IsSuccessStatusCode)
            {
                string egsContent = await egsResponse.Content.ReadAsStringAsync();

                var lstExpenseGroupStatusses = JsonConvert
                                               .DeserializeObject <IEnumerable <ExpenseGroupStatus> >(egsContent);

                model.ExpenseGroupStatusses = lstExpenseGroupStatusses;
            }
            else
            {
                return(Content("An error occurred."));
            }


            // HttpResponseMessage response = await client.GetAsync("api/expensegroups?sort=expensegroupstatusid,title");

            HttpResponseMessage response =
                await client.GetAsync("api/expensegroups?sort=expensegroupstatusid,title&page=" + page + "&pagesize=5");

            if (response.IsSuccessStatusCode)
            {
                string content = await response.Content.ReadAsStringAsync();

                var pagingInfo = HeaderParser.FindAndParsePagingInfo(response.Headers);

                var lstExpenseGroups = JsonConvert.DeserializeObject <IEnumerable <ExpenseGroup> >(content);

                // model.ExpenseGroups = lstExpenseGroups;

                var pagedExpenseGroupsList = new StaticPagedList <ExpenseGroup>(lstExpenseGroups,
                                                                                pagingInfo.CurrentPage,
                                                                                pagingInfo.PageSize, pagingInfo.TotalCount);


                model.ExpenseGroups = pagedExpenseGroupsList;
                model.PagingInfo    = pagingInfo;
            }
            else
            {
                return(Content("An error occurred."));
            }


            return(View(model));
        }
Example #27
0
        private static IReplay ParseReplay(UnpackResult result)
        {
            HeaderParser headerParser = new HeaderParser(result.Header);
            Header       header       = headerParser.ParseHeader();

            ActionParser   actionsParser = new ActionParser(result.Actions, header.Players.ToList <IPlayer>());
            List <IAction> actions       = actionsParser.ParseActions();

            IReplay replay = new Replay(header, actions);

            return(replay);
        }
Example #28
0
        private static IReplay ParseReplay(UnpackResult result)
        {
            HeaderParser headerParser = new HeaderParser(result.Header);
            Header header = headerParser.ParseHeader();

            ActionParser actionsParser = new ActionParser(result.Actions, header.Players.ToList<IPlayer>());
            List<IAction> actions = actionsParser.ParseActions();

            IReplay replay = new Replay(header, actions);

            return replay;
        }
Example #29
0
        public void Can_Read_Reference()
        {
            var parser         = new HeaderParser(".\\Test.dacpac");
            var firstReference = parser.GetCustomData().FirstOrDefault(p => p.Category == "Reference" && p.Type == "SqlSchema");

            var fileName      = firstReference.Items.FirstOrDefault(p => p.Name == "FileName").Value;
            var logicalName   = firstReference.Items.FirstOrDefault(p => p.Name == "LogicalName").Value;
            var externalParts = firstReference.Items.FirstOrDefault(p => p.Name == "ExternalParts").Value;
            var suppressMissingDependenciesErrors = firstReference.Items.FirstOrDefault(p => p.Name == "SuppressMissingDependenciesErrors").Value;

            Console.WriteLine("DacPac Reference: {0}: {1}: {2}: {3}", fileName, logicalName, externalParts, suppressMissingDependenciesErrors);
        }
Example #30
0
        public string ConvertMarkdown(string markdown)
        {
            ParrentParser parrentParser = new HeaderParser();

            parrentParser.Succesor = new ParagraphParser();
            ChildrenParser childrenParser = new TextParser();

            childrenParser.Succesor = new MediaParser();
            INonTerminalExpression document = new MarkdownParser(parrentParser, childrenParser).Parse(markdown);

            return(document.Interpret());
        }
Example #31
0
        public async Task <ActionResult> Index(int?page = 1)
        {
            //calling get or post happen as async mode
            var client = ExpenseTrackerHttpClient.GetClient();

            var model = new ExpenseGroupsViewModel();
            // GET Expense Group Status
            var egsResponse = await client.GetAsync("api/expensegroupstatusses");

            if (egsResponse.IsSuccessStatusCode)
            {
                string egsContent = await egsResponse.Content.ReadAsStringAsync();

                //deserelized the response to get oreginal data
                var lstExpenseGroupStatusses =
                    JsonConvert.DeserializeObject <IEnumerable <ExpenseGroupStatus> >(egsContent);
                model.ExpenseGroupStatusses = lstExpenseGroupStatusses;
            }
            else
            {
                return(Content("An error occurred."));
            }

            // GET Expense Group

            HttpResponseMessage response =
                await client.GetAsync("api/expensegroups?sort=expensegroupstatusid,title&page=" + page + "&pagesize=5");     //done sorting

            if (response.IsSuccessStatusCode)
            {
                string content = await response.Content.ReadAsStringAsync();

                //paging
                var pagingInfo = HeaderParser.FindAndParsePagingInfo(response.Headers);
                //deserelized the response and get the data as IEnumerable

                var lstExpenseGroups =
                    JsonConvert.DeserializeObject <IEnumerable <ExpenseGroup> >(content);
                //then it convert to IPagedList inerface for pageing
                var pagedExpenseGroupsList = new StaticPagedList <ExpenseGroup>(lstExpenseGroups,
                                                                                pagingInfo.CurrentPage,
                                                                                pagingInfo.PageSize, pagingInfo.TotalCount);

                model.ExpenseGroups = pagedExpenseGroupsList;
                model.PagingInfo    = pagingInfo;
            }
            else
            {
                return(Content("An error occured."));
            }
            return(View(model));
        }
Example #32
0
        private List <string> GetAllReferences(string dacpacPath, bool isRootDacpac)
        {
            if (!isRootDacpac && !File.Exists(dacpacPath))
            {
                // When the root DACPAC has a reference with SuppressMissingDependenciesErrors = true,
                // second-level references of that first-level reference don't have to be referenced from the root project.
                // For that case, DACPACs not referenced directly by the root DACPAC are optional.
                return(Enumerable.Empty <string>().ToList());
            }

            var parser = new HeaderParser(dacpacPath);

            var references = parser.GetCustomData()
                             .Where(p => p.Category == "Reference" && p.Type == "SqlSchema")
                             .ToList();

            if (references.Count == 0)
            {
                return(Enumerable.Empty <string>().ToList());
            }

            var fileNames = references
                            .SelectMany(r => r.Items)
                            .Where(i => i.Name == "LogicalName")
                            .Where(i => !i.Value.Equals("master.dacpac", StringComparison.OrdinalIgnoreCase))
                            .Select(i => Path.GetFullPath(Path.Combine(Path.GetDirectoryName(dacpacPath), i.Value)))
                            .ToList();

            if (!isRootDacpac)
            {
                // If we're looking for references of a non-root DACPAC,
                // any reference is optional (see SuppressMissingDependenciesErrors = true).
                // Therefore this DACPACs won't be included, if they don't exist in the build output directory.
                fileNames = fileNames.Where(File.Exists).ToList();
            }

            if (fileNames.Count() == 0)
            {
                return(Enumerable.Empty <string>().ToList());
            }

            var additionalFiles = new List <string>();

            foreach (var fileName in fileNames)
            {
                additionalFiles.AddRange(GetAllReferences(fileName, false));
            }

            fileNames.AddRange(additionalFiles);

            return(fileNames.Distinct().ToList());
        }
Example #33
0
        public void HeaderParserHasNullSagaOnMessageNotInvolvingSaga()
        {
            //arrange
            var rawMessage   = MessageTestHelpers.GetErrorMessage();
            var headerParser = new HeaderParser();
            var doc          = new MessageDocument();

            //act
            headerParser.AddHeaderInformation(rawMessage, doc);

            //assert
            doc.SagaInfo.Should().BeNull();
        }
Example #34
0
 internal ParsedHeaderValue ParseValue()
 {
     var parser = new HeaderParser(Value);
     return parser.Parse();
 }
Example #35
0
        public void Load(Stream file)
        {
            CultureInfo currentCulture = Thread.CurrentThread.CurrentCulture;
            Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US");
            bool versionwarningsent = false;

            Dictionary<string, ISectionParser> sectionparsers = new Dictionary<string, ISectionParser>();

            sectionparsers["HEADER"] = new HeaderParser();
            sectionparsers["CLASSES"] = new ClassParser();
            sectionparsers["TABLES"] = new TableParser();
            sectionparsers["ENTITIES"] = new EntityParser();
            sectionparsers["BLOCKS"] = new BlockParser();
            ISectionParser currentParser = null;

            TextReader reader = new StreamReader(file);
            LoadState state = LoadState.OutsideSection;
            int? groupcode;
            string value;
            reader.ReadDXFEntry(out groupcode, out value);
            while (groupcode != null)
            {
                switch (state)
                {
                    case LoadState.OutsideSection:
                        if (groupcode == 0 && value.Trim() == "SECTION")
                        {
                            state = LoadState.InSection;
                            reader.ReadDXFEntry(out groupcode, out value);
                            if (groupcode != 2)
                                throw new Exception("Sektion gefunden aber keinen Namen zur Sektion");
                            value = value.Trim();
                            if (sectionparsers.ContainsKey(value))
                                currentParser = sectionparsers[value];
                        }
                        break;
                    case LoadState.InSection:
                        if (groupcode == 0 && value.Trim() == "ENDSEC")
                        {
                            state = LoadState.OutsideSection;
                            //after each section check wether the File Version is set
                            if (Header.AutoCADVersion != null &&
                                Header.AutoCADVersion != "AC1014")
                            {
                                if (!versionwarningsent)
                                {
                                    try
                                    {
                                        if (OnFileVersionIncompatible != null)
                                            OnFileVersionIncompatible(this, EventArgs.Empty);

                                    }
                                    catch (Exception)
                                    {

                                    }
                                    versionwarningsent = true;
                                }
                            }
                        }
                        else
                        {
                            if (currentParser != null)
                            {
                                currentParser.ParseGroupCode(this, (int)groupcode, value);
                            }
                        }
                        break;
                    default:
                        break;
                }
                reader.ReadDXFEntry(out groupcode, out value);
            }
            if (state == LoadState.InSection)
                throw new Exception("Dateiende erreicht aber immer noch offene Sektion vorhanden");
            Thread.CurrentThread.CurrentCulture = currentCulture;
        }