Exemplo n.º 1
0
        public UserDefinedFormatFactory(UserDefinedFactoryParams createParams)
            : base(createParams)
        {
            var formatSpecificNode = createParams.FormatSpecificNode;

            ReadPatterns(formatSpecificNode, patterns);

            var boundsNodes = formatSpecificNode.Elements("bounds").Take(1);
            var beginFinder = BoundFinder.CreateBoundFinder(boundsNodes.Select(n => n.Element("begin")).FirstOrDefault());
            var endFinder   = BoundFinder.CreateBoundFinder(boundsNodes.Select(n => n.Element("end")).FirstOrDefault());

            this.tempFilesManager = createParams.TempFilesManager;

            formatInfo = new Lazy <JsonFormatInfo>(() =>
            {
                string transform = ReadParameter(formatSpecificNode, "transform");
                if (transform == null)
                {
                    throw new Exception("Wrong JSON format definition: transform is not defined");
                }

                LoadedRegex head = ReadRe(formatSpecificNode, "head-re", ReOptions.Multiline);
                LoadedRegex body = ReadRe(formatSpecificNode, "body-re", ReOptions.Singleline);
                string encoding  = ReadParameter(formatSpecificNode, "encoding");

                DejitteringParams?dejitteringParams = DejitteringParams.FromConfigNode(
                    formatSpecificNode.Element("dejitter"));

                TextStreamPositioningParams textStreamPositioningParams = TextStreamPositioningParams.FromConfigNode(
                    formatSpecificNode);

                return(new JsonFormatInfo(transform, head, body, beginFinder, endFinder,
                                          encoding, textStreamPositioningParams, dejitteringParams, viewOptions));
            });
        }
Exemplo n.º 2
0
        public UserDefinedFormatFactory(UserDefinedFactoryParams createParams)
            : base(createParams)
        {
            var formatSpecificNode = createParams.FormatSpecificNode;

            ReadPatterns(formatSpecificNode, patterns);
            var boundsNodes = formatSpecificNode.Elements("bounds").Take(1);
            var beginFinder = BoundFinder.CreateBoundFinder(boundsNodes.Select(n => n.Element("begin")).FirstOrDefault());
            var endFinder   = BoundFinder.CreateBoundFinder(boundsNodes.Select(n => n.Element("end")).FirstOrDefault());

            tempFilesManager       = createParams.TempFilesManager;
            fieldsProcessorFactory = createParams.FieldsProcessorFactory;
            regexFactory           = createParams.RegexFactory;
            traceSourceFactory     = createParams.TraceSourceFactory;
            fmtInfo = new Lazy <FormatInfo>(() =>
            {
                FieldsProcessor.IInitializationParams fieldsInitParams = fieldsProcessorFactory.CreateInitializationParams(
                    formatSpecificNode.Element("fields-config"), performChecks: true);
                MessagesReaderExtensions.XmlInitializationParams extensionsInitData = new MessagesReaderExtensions.XmlInitializationParams(
                    formatSpecificNode.Element("extensions"));
                DejitteringParams?dejitteringParams = DejitteringParams.FromConfigNode(
                    formatSpecificNode.Element("dejitter"));
                TextStreamPositioningParams textStreamPositioningParams = TextStreamPositioningParams.FromConfigNode(
                    formatSpecificNode);
                RotationParams rotationParams = RotationParams.FromConfigNode(
                    formatSpecificNode.Element("rotation"));
                FormatInfo.FormatFlags flags = FormatInfo.FormatFlags.None;
                if (formatSpecificNode.Element("plain-text-search-optimization").AttributeValue("allowed") == "yes")
                {
                    flags |= FormatInfo.FormatFlags.AllowPlainTextSearchOptimization;
                }
                return(new FormatInfo(
                           ReadRe(formatSpecificNode, "head-re", ReOptions.Multiline),
                           ReadRe(formatSpecificNode, "body-re", ReOptions.Singleline),
                           ReadParameter(formatSpecificNode, "encoding"),
                           fieldsInitParams,
                           extensionsInitData,
                           dejitteringParams,
                           textStreamPositioningParams,
                           flags,
                           rotationParams,
                           beginFinder,
                           endFinder
                           ));
            });
            uiKey = ReadParameter(formatSpecificNode, "ui-key");
        }
Exemplo n.º 3
0
        public UserDefinedFormatFactory(UserDefinedFactoryParams createParams)
            : base(createParams)
        {
            var formatSpecificNode = createParams.FormatSpecificNode;

            ReadPatterns(formatSpecificNode, patterns);

            var boundsNodes = formatSpecificNode.Elements("bounds").Take(1);
            var beginFinder = BoundFinder.CreateBoundFinder(boundsNodes.Select(n => n.Element("begin")).FirstOrDefault());
            var endFinder   = BoundFinder.CreateBoundFinder(boundsNodes.Select(n => n.Element("end")).FirstOrDefault());

            this.tempFilesManager   = createParams.TempFilesManager;
            this.regexFactory       = createParams.RegexFactory;
            this.traceSourceFactory = createParams.TraceSourceFactory;

            formatInfo = new Lazy <XmlFormatInfo>(() =>
            {
                XmlDocument tmpDoc = new XmlDocument();
                tmpDoc.LoadXml(formatSpecificNode.ToString());
                XmlElement xsl = tmpDoc.DocumentElement.SelectSingleNode("xsl:stylesheet", nsMgr) as XmlElement;
                if (xsl == null)
                {
                    throw new Exception("Wrong XML-based format definition: xsl:stylesheet is not defined");
                }

                LoadedRegex head = ReadRe(formatSpecificNode, "head-re", ReOptions.Multiline);
                LoadedRegex body = ReadRe(formatSpecificNode, "body-re", ReOptions.Singleline);
                string encoding  = ReadParameter(formatSpecificNode, "encoding");

                MessagesReaderExtensions.XmlInitializationParams extensionsInitData =
                    new MessagesReaderExtensions.XmlInitializationParams(formatSpecificNode.Element("extensions"));

                DejitteringParams?dejitteringParams = DejitteringParams.FromConfigNode(
                    formatSpecificNode.Element("dejitter"));

                TextStreamPositioningParams textStreamPositioningParams = TextStreamPositioningParams.FromConfigNode(
                    formatSpecificNode);

                return(new XmlFormatInfo(xsl, head, body, beginFinder, endFinder,
                                         encoding, extensionsInitData, textStreamPositioningParams, dejitteringParams, viewOptions));
            });
            uiKey = ReadParameter(formatSpecificNode, "ui-key");
        }
Exemplo n.º 4
0
        public UserDefinedFormatFactory(UserDefinedFactoryParams createParams)
            : base(createParams)
        {
            var formatSpecificNode = createParams.FormatSpecificNode;

            ReadPatterns(formatSpecificNode, patterns);
            tempFilesManager = createParams.TempFilesManager;
            fmtInfo          = new Lazy <FormatInfo>(() =>
            {
                Type precompiledUserCode = ReadPrecompiledUserCode(createParams.RootNode);
                FieldsProcessor.InitializationParams fieldsInitParams = new FieldsProcessor.InitializationParams(
                    formatSpecificNode.Element("fields-config"), true, precompiledUserCode);
                MessagesReaderExtensions.XmlInitializationParams extensionsInitData = new MessagesReaderExtensions.XmlInitializationParams(
                    formatSpecificNode.Element("extensions"));
                DejitteringParams?dejitteringParams = DejitteringParams.FromConfigNode(
                    formatSpecificNode.Element("dejitter"));
                TextStreamPositioningParams textStreamPositioningParams = TextStreamPositioningParams.FromConfigNode(
                    formatSpecificNode);
                RotationParams rotationParams = RotationParams.FromConfigNode(
                    formatSpecificNode.Element("rotation"));
                FormatInfo.FormatFlags flags = FormatInfo.FormatFlags.None;
                if (formatSpecificNode.Element("plain-text-search-optimization").AttributeValue("allowed") == "yes")
                {
                    flags |= FormatInfo.FormatFlags.AllowPlainTextSearchOptimization;
                }
                return(new FormatInfo(
                           ReadRe(formatSpecificNode, "head-re", ReOptions.Multiline),
                           ReadRe(formatSpecificNode, "body-re", ReOptions.Singleline),
                           ReadParameter(formatSpecificNode, "encoding"),
                           fieldsInitParams,
                           extensionsInitData,
                           dejitteringParams,
                           textStreamPositioningParams,
                           flags,
                           rotationParams
                           ));
            });
            uiKey = ReadParameter(formatSpecificNode, "ui-key");
        }