예제 #1
0
 public PreprocessingInputStream(TextReader reader, IPreprocessor preprocessor)
 {
     this.preprocessor = preprocessor;
     this.positions    = new Stack <PreprocessingInputStream.PrimitiveStream> ();
     this.unreadLines  = new LinkedArrayList <string> ();
     this.positions.Push(new PreprocessingInputStream.PrimitiveStream(reader));
 }
예제 #2
0
        public void TestGetIPreprocessor()
        {
            IPreprocessor preprocessor = _factory.GetIPreprocessor();

            Assert.IsNotNull(preprocessor);
            Assert.IsInstanceOfType(preprocessor, typeof(Preprocessor));
        }
예제 #3
0
        public static void Preprocess(string originalFile, string outputFile, string game, ILog messageLog)
        {
            EACodeLanguage eaCodeLanguage = Program.Languages [game];

            using (IPreprocessor preprocessor = (IPreprocessor) new Preprocessor(messageLog)) {
                preprocessor.AddReserved(eaCodeLanguage.GetCodeNames());
                preprocessor.AddDefined(new string[] { "_" + game + "_", "_EA_" });

                using (StreamReader streamReader = File.OpenText(originalFile)) {
                    using (IInputStream inputStream = (IInputStream) new PreprocessingInputStream((TextReader)streamReader, preprocessor)) {
                        StringWriter stringWriter = new StringWriter();

                        while (true)
                        {
                            string str = inputStream.ReadLine();

                            if (str != null)
                            {
                                stringWriter.WriteLine(str);
                            }
                            else
                            {
                                break;
                            }
                        }

                        messageLog.AddMessage("Processed code:\n" + stringWriter.ToString() + "\nEnd processed code");
                    }
                }
            }
        }
예제 #4
0
 public SinkGateway(
     IServiceProvider <TEntity> serviceProvider,
     IPreprocessor <TEntity> preprocessor)
 {
     this.serviceProvider = serviceProvider;
     this.preprocessor    = preprocessor;
 }
예제 #5
0
        private IEnumerable <IPreprocessor> GetDependentInstances(IPreprocessor target, IList <IPreprocessor> list)
        {
            var targetDeps = target.GetDependencies();

            return(list.Where(p => targetDeps
                              .Any(d => p.GetType().Equals(d))));
        }
 public PreprocessingInputStream(TextReader reader, IPreprocessor preprocessor)
 {
     this.preprocessor = preprocessor;
     this.positions = new Stack<PrimitiveStream>();
     this.unreadLines = new LinkedArrayList<string>();
     PrimitiveStream newData = new PrimitiveStream(reader);
     positions.Push(newData);
 }
예제 #7
0
 public SeriesVariable(double[] x, double[] y, string variableName = null, IPreprocessor preprocessor = null, double weight = 1)
 {
     _x            = x;
     _y            = y;
     _variableName = variableName;
     _preprocessor = preprocessor;
     _weight       = weight;
 }
예제 #8
0
 public SeriesVariable(double[] x, double[] y, string variableName = null, IPreprocessor preprocessor = null, double weight = 1)
 {
     _x = x;
     _y = y;
     _variableName = variableName;
     _preprocessor = preprocessor;
     _weight = weight;
 }
 protected ContentFactory(
     IPreprocessor preprocessor,
     string id,
     string configuration
     )
 {
     this.Preprocessor   = preprocessor;
     this._id            = id;
     this._configuration = configuration;
 }
예제 #10
0
		protected ContentFactory(
			IPreprocessor preprocessor,
			string        id,
			string        configuration
		)
		{
			this.Preprocessor   = preprocessor;
			this._id            = id;
			this._configuration = configuration;
		}
			public DataGridContentFactory(
				IPreprocessor preprocessor,
				string        id,
				string        configuration
			) : base(
					preprocessor,
					id,
					configuration
				)
			{
			}
예제 #12
0
 internal void AddPreprocessor(IPreprocessor instance)
 {
     if (Preprocessors.All(ipp => ipp.GetType() != instance.GetType()))
     {
         foreach (var extension in instance.Extensions)
         {
             AllowedExtensions.Add(extension);
         }
         Preprocessors.Add(instance);
     }
 }
예제 #13
0
 internal void AddPreprocessor(IPreprocessor instance)
 {
     if(!Preprocessors.Any(ipp => ipp.GetType() == instance.GetType()))
     {
         foreach(var extension in instance.Extensions)
         {
             AllowedExtensions.Add(extension);
         }
         Preprocessors.Add(instance);
     }
 }
예제 #14
0
 public GraphContentFactory(
     IPreprocessor preprocessor,
     string id,
     string configuration
     ) : base(
         preprocessor,
         id,
         configuration
         )
 {
 }
예제 #15
0
        private IPreprocessor GetNextInstance(IPreprocessor target, IList <IPreprocessor> list)
        {
            var deps = GetDependentInstances(target, list);

            foreach (var item in deps)
            {
                return(GetNextInstance(item, list));
            }

            return(target);
        }
예제 #16
0
 public void SetSettings(IFileReader reader,
                         ICloudLayouter layouter,
                         IPreprocessor preprocessor,
                         IImageSaver saver,
                         ICloudBuilder builder)
 {
     this.reader       = reader;
     this.layouter     = layouter;
     this.preprocessor = preprocessor;
     this.saver        = saver;
     this.cloudBuilder = builder;
 }
 public HtmlContentFactory(
     IPreprocessor preprocessor,
     string id,
     string configuration,
     string htmlPath
     ) : base(
         preprocessor,
         id,
         configuration
         )
 {
     this._htmlPath = htmlPath;
 }
			public HtmlContentFactory(
				IPreprocessor preprocessor,
				string        id,
				string        configuration,
				string        htmlPath
			) : base(
				preprocessor,
				id,
				configuration
			)
			{
				this._htmlPath = htmlPath;
			}
 public Middleware(
     IArenaLogic arenaLogic,
     IBotLogic botLogic,
     IPreprocessor preprocessor,
     IProcessor processor,
     IPostprocessor postprocessor)
 {
     _arenaLogic    = arenaLogic;
     _botLogic      = botLogic;
     _preprocessor  = preprocessor;
     _processor     = processor;
     _postprocessor = postprocessor;
 }
        /// <summary>
        /// Mockable Constructor
        /// </summary>
        public ImageApi(IPreprocessor preprocessor, IDataStore store)
        {
            if (null == preprocessor)
            {
                throw new ArgumentException("preprocessor");
            }
            if (null == store)
            {
                throw new ArgumentException("store");
            }

            this.preprocessor = preprocessor;
            this.store = store;
        }
예제 #21
0
        /// <summary>
        /// Mockable Constructor
        /// </summary>
        public ImageApi(IPreprocessor preprocessor, IDataStore store)
        {
            if (null == preprocessor)
            {
                throw new ArgumentException("preprocessor");
            }
            if (null == store)
            {
                throw new ArgumentException("store");
            }

            this.preprocessor = preprocessor;
            this.store        = store;
        }
예제 #22
0
        public PredictionController(IConfiguration configuration)
        {
            _inputPreprocessor  = new InputPreprocessor();
            _outputPreprocessor = new OutputPreprocessor();

            // Initiate RabbitMQ connection
            _conn = new ConnectionFactory
            {
                UserName    = configuration["RABBITMQ_USERNAME"] ?? "guest",
                Password    = configuration["RABBITMQ_PASSWORD"] ?? "guest",
                VirtualHost = configuration["RABBITMQ_VIRTUALHOST"] ?? "/",
                HostName    = configuration["RABBITMQ_HOSTNAME"] ?? "localhost",
                Port        = int.TryParse(configuration["RABBITMQ_PORT"] ?? "5672", out var result) ? result : 5672
            }.CreateConnection();
예제 #23
0
        private void ValidatePreprocessor <T>(IPreprocessor instance)
        {
            if (Preprocessors.Any(p => p.GetType() == typeof(T)))
            {
                throw new InvalidOperationException(string.Format("Can't add multiple preprocessors of type: {0}", typeof(T).FullName));
            }

            foreach (var extension in instance.Extensions)
            {
                if (Enumerable.Contains(AllExtensions, extension))
                {
                    throw new InvalidOperationException(string.Format("Can't add multiple preprocessors for extension: {0}", extension));
                }
            }
        }
예제 #24
0
        public bool RunProcessor(IPreprocessor processor, String inputFile, String outputFile)
        {
            var reader = new GCodeReader(inputFile);
            var writer = new GCodeWriter(outputFile);

            try
            {
                return(processor.ProcessGCode(reader, writer, getPrinterDetails(), getJobDetails()));
            }
            finally
            {
                reader.Close();
                writer.Close();
            }
        }
예제 #25
0
 public TagCloudProgram(
     ITagCloudVisualization tagCloudVisualization,
     ITextParser parser,
     IFileReader fileReader,
     IPreprocessor wordsExcluder,
     IPreprocessor wordsStemer,
     Config config)
 {
     this.tagCloudVisualization = tagCloudVisualization;
     this.config        = config;
     this.wordsExcluder = wordsExcluder;
     this.wordsStemer   = wordsStemer;
     this.fileReader    = fileReader;
     this.parser        = parser;
 }
예제 #26
0
 public TagsCloudController(
     IConfiguration configuration,
     IDataReader reader,
     IPreprocessor preprocessor,
     IWordsCounter wordsCounter,
     ITagsGenerator tagsGenerator,
     IVisualizer visualizer,
     IImageWriter imageWriter)
 {
     this.configuration = configuration;
     this.reader        = reader;
     this.preprocessor  = preprocessor;
     this.wordsCounter  = wordsCounter;
     this.tagsGenerator = tagsGenerator;
     this.visualizer    = visualizer;
     this.imageWriter   = imageWriter;
 }
예제 #27
0
 public Middleware(
     IArenaLogic arenaLogic,
     IBotLogic botLogic,
     IMessageLogic messageLogic,
     IPreprocessor preprocessor,
     IProcessor processor,
     IPostprocessor postprocessor,
     ILogger <Middleware> logger)
 {
     _arenaLogic    = arenaLogic;
     _botLogic      = botLogic;
     _messageLogic  = messageLogic;
     _preprocessor  = preprocessor;
     _processor     = processor;
     _postprocessor = postprocessor;
     _logger        = logger;
 }
			public RDLContentFactory(
				IPreprocessor                                        preprocessor,
				string                                               id,
				string                                               configuration,
				List<Tuple<TemplateNodeQueryInfo, Int64, DataTable>> dataTablesInfoResult
			) : base(
					preprocessor,
					id,
					configuration
				)
			{
				this._dataTablesInfoResult = dataTablesInfoResult;

				this._rdlReport = CreateRdlReport(
					configuration,
					dataTablesInfoResult
				);
			}
예제 #29
0
            public RDLContentFactory(
                IPreprocessor preprocessor,
                string id,
                string configuration,
                List <Tuple <TemplateNodeQueryInfo, Int64, DataTable> > dataTablesInfoResult
                ) : base(
                    preprocessor,
                    id,
                    configuration
                    )
            {
                this._dataTablesInfoResult = dataTablesInfoResult;

                this._rdlReport = CreateRdlReport(
                    configuration,
                    dataTablesInfoResult
                    );
            }
예제 #30
0
        public static ConfigParserResult Parse(string code, IPreprocessor preprocessor)
        {
            ConfigParserResult result = new ConfigParserResult();
            List <string>      lines  = code.Replace("\r", "").Split(new[] { '\n' }, StringSplitOptions.None).ToList();

            // Find all directives
            for (int c = 0; c < lines.Count; c++)
            {
                if (lines[c].StartsWith("#"))
                {
                    int firstSpace = lines[c].IndexOf(' ');
                    if (firstSpace != -1)
                    {
                        string directive = lines[c].Substring(1, firstSpace - 1);
                        if (preprocessor.ContainsDirective(directive))
                        {
                            result.DirectiveValues.Add(new DirectiveValue(c + 1, directive, lines[c].Substring(firstSpace + 1).Trim()));
                            lines[c] = "//" + lines[c];  // Just comment out the directive so it still shows in exports
                        }
                    }
                }
            }

            // Get declarations
            int startLine       = 1;
            int declarationLine = lines.FindIndex(x =>
            {
                string trimmed = x.TrimEnd();
                return(trimmed.Length > 0 && trimmed.All(y => y == '-'));
            });

            if (declarationLine != -1)
            {
                List <string> declarationLines = lines.Take(declarationLine).ToList();
                result.Declarations = $"#line {startLine}{Environment.NewLine}{string.Join(Environment.NewLine, declarationLines)}";
                startLine          += declarationLines.Count + 1;
                lines.RemoveRange(0, declarationLine + 1);
            }

            // Get body
            result.Body = $"#line {startLine}{Environment.NewLine}{string.Join(Environment.NewLine, lines)}";

            return(result);
        }
예제 #31
0
 internal void AddPreprocessor(IPreprocessor instance)
 {
     if (Preprocessors.All(ipp => ipp.GetType() != instance.GetType()))
     {
         foreach (var extension in instance.Extensions)
         {
             AllowedExtensions.Add(extension);
         }
         Preprocessors.Add(instance);
     }
     if (instance.IgnoreExtensions.NullSafeAny())
     {
         foreach (var extension in instance.IgnoreExtensions)
         {
             AllowedExtensions.Add(extension);
         }
         Preprocessors.Add(new NullPreprocessor(instance.IgnoreExtensions));
     }
 }
예제 #32
0
 internal void AddPreprocessor(IPreprocessor instance)
 {
     if(Preprocessors.All(ipp => ipp.GetType() != instance.GetType()))
     {
         foreach(var extension in instance.Extensions)
         {
             AllowedExtensions.Add(extension);
         }
         Preprocessors.Add(instance);
     }
     if (instance.IgnoreExtensions.NullSafeAny())
     {
         foreach (var extension in instance.IgnoreExtensions)
         {
             AllowedExtensions.Add(extension);
         }
         Preprocessors.Add(new NullPreprocessor(instance.IgnoreExtensions));
     }
 }
예제 #33
0
        public static List <string> Preprocess(IEnumerable <string> files, IPreprocessor preprocessor)
        {
            var result = new List <string>();

            var tasks = new List <Task>();

            foreach (var file in files)
            {
                if (preprocessor.IsMatch(file))
                {
                    string taskFile = file;
                    tasks.Add(Task.Run(() => { preprocessor.Preprocess(result, taskFile); }));
                }
                else
                {
                    result.Add(file);
                }
            }

            Task.WaitAll(tasks.ToArray());
            return(result);
        }
예제 #34
0
 public Processor(
     IContext context,
     IOperationExecutive operationExecutive,
     ISafeMetadataProvider <TEntity> safeMetadataProvider,
     IServiceProvider <TEntity> serviceProvider,
     IMappingRepository <TEntity> mappingRepository,
     IPreprocessor <TEntity> preprocessor,
     IDeduplicator <TEntity> deduplicator,
     IHashingSerializer <TEntity> hashingSerializer,
     IGateway <TEntity> gateway,
     IEventHub <TEntity> eventHub)
 {
     this.context              = context;
     this.operationExecutive   = operationExecutive;
     this.safeMetadataProvider = safeMetadataProvider;
     this.serviceProvider      = serviceProvider;
     this.mappingRepository    = mappingRepository;
     this.preprocessor         = preprocessor;
     this.deduplicator         = deduplicator;
     this.hashingSerializer    = hashingSerializer;
     this.gateway              = gateway;
     this.eventHub             = eventHub;
 }
예제 #35
0
 public Searcher(IPreprocessor preprocessor, MatcherFactory matcherFactory)
 {
     _preprocessor   = preprocessor;
     _matcherFactory = matcherFactory;
 }
예제 #36
0
 public DirectiveParser(IPreprocessor preprocessor)
 {
     _preprocessor = preprocessor;
 }
        private void PreprocessElement(XmlDocument document, XmlElement element, ref List <PreprocessorAreaData> datas, PreprocessorAreaData parentArea = null)
        {
            List <XmlElement> nodes = element.ChildNodes.OfType <XmlElement>().ToList();

            foreach (XmlElement subElement in nodes)
            {
                if (subElement == null)
                {
                    continue;
                }

                switch (subElement.Name.ToLower())
                {
                case "mssqlauditorpreprocessor":
                {
                    string className = subElement.Attributes["preprocessor"].Value;

                    XmlAttribute idAttr        = subElement.Attributes["id"];
                    XmlAttribute nameAttr      = subElement.Attributes["name"];
                    XmlAttribute columnAttr    = subElement.Attributes["column"];
                    XmlAttribute rowAttr       = subElement.Attributes["row"];
                    XmlAttribute colSpanAttr   = subElement.Attributes["colspan"];
                    XmlAttribute rowSpanAttr   = subElement.Attributes["rowspan"];
                    XmlAttribute vertTestAlign = subElement.Attributes["text-vertical-align"];
                    XmlAttribute textAlign     = subElement.Attributes["text-align"];

                    string id          = "";
                    string preprocName = "unnamed";

                    if (nameAttr != null)
                    {
                        preprocName = nameAttr.Value;
                    }

                    if (idAttr != null)
                    {
                        id = idAttr.Value;
                    }

                    int col     = ParseIntAttribute(columnAttr, 1);
                    int row     = ParseIntAttribute(rowAttr, 1);
                    int colSpan = ParseIntAttribute(colSpanAttr, 1);
                    int rowSpan = ParseIntAttribute(rowSpanAttr, 1);

                    VerticalTextAlign?preprocVertTestAlign = null;

                    if (vertTestAlign != null)
                    {
                        VerticalTextAlign tempVertTestAlign;

                        if (Enum.TryParse(vertTestAlign.Value, out tempVertTestAlign))
                        {
                            preprocVertTestAlign = tempVertTestAlign;
                        }
                    }

                    TextAlign preprocTestAlign = TextAlign.Left;

                    if (textAlign != null)
                    {
                        if (!Enum.TryParse(textAlign.Value, out preprocTestAlign))
                        {
                            preprocTestAlign = TextAlign.Left;
                        }
                    }

                    IPreprocessor preprocessor =
                        (from proc in this._availablePreprocessors where proc.GetType().Name == className select proc)
                        .FirstOrDefault();

                    if (preprocessor != null)
                    {
                        string          configuration = subElement.InnerXml;
                        IContentFactory factory       = preprocessor.CreateContentFactory(id, configuration);

                        PreprocessorData data = new PreprocessorData
                        {
                            ContentFactory    = factory,
                            Name              = preprocName,
                            Column            = col,
                            Row               = row,
                            ColSpan           = colSpan,
                            RowSpan           = rowSpan,
                            VerticalTextAlign = preprocVertTestAlign,
                            TextAlign         = preprocTestAlign
                        };

                        XmlElement newSubElement = document.CreateElement("div");

                        newSubElement.SetAttribute("style", "margin:0; padding:0;");
                        newSubElement.InnerXml = string.Empty;

                        element.ReplaceChild(newSubElement, subElement);

                        if (parentArea != null)
                        {
                            parentArea.Preprocessors.Add(data);
                        }
                        else
                        {
                            log.ErrorFormat(
                                "Invalid configuration: <mssqlauditorpreprocessor> is not embedded in <mssqlauditorpreprocessors>. " +
                                "Are you using old style configuration file?" + Environment.NewLine +
                                "Silently ignoring '{0}' with id='{1}' and name='{2}'",
                                className,
                                id,
                                preprocName
                                );

                            throw new ArgumentOutOfRangeException(
                                      "document",
                                      "Invalid configuration: <mssqlauditorpreprocessor> is not embedded in <mssqlauditorpreprocessors>!"
                                      );
                        }
                        continue;
                    }
                    break;
                }

                case "mssqlauditorpreprocessors":
                {
                    XmlAttribute idAttr       = subElement.Attributes["id"];
                    XmlAttribute nameAttr     = subElement.Attributes["name"];
                    XmlAttribute rowsAttr     = subElement.Attributes["rows"];
                    XmlAttribute columnsAttr  = subElement.Attributes["columns"];
                    XmlAttribute splitterAttr = subElement.Attributes["splitter"];

                    string id       = "";
                    string name     = "unnamed";
                    string rows     = "";
                    string columns  = "";
                    string splitter = "";

                    if (nameAttr != null)
                    {
                        name = nameAttr.Value;
                    }
                    if (idAttr != null)
                    {
                        id = idAttr.Value;
                    }
                    if (columnsAttr != null)
                    {
                        columns = columnsAttr.Value;
                    }
                    if (rowsAttr != null)
                    {
                        rows = rowsAttr.Value;
                    }
                    if (splitterAttr != null)
                    {
                        splitter = splitterAttr.Value;
                    }

                    PreprocessorAreaData container = new PreprocessorAreaData(id, name, columns, rows);

                    if (string.Equals(splitter, "no", StringComparison.InvariantCultureIgnoreCase))
                    {
                        container.NoSplitter = true;
                    }

                    datas.Add(container);

                    PreprocessElement(document, subElement, ref datas, container);

                    container.CheckPreprocessors();

                    continue;
                }
                }

                PreprocessElement(document, subElement, ref datas);
            }
        }
예제 #38
0
 private void DefineMacrosAccordingToGameSettings(IPreprocessor preprocessor)
 {
     preprocessor.DefineMacro("AGS_NEW_STRINGS", "1");
     preprocessor.DefineMacro("AGS_SUPPORTS_IFVER", "1");
     if (_game.Settings.DebugMode)
     {
         preprocessor.DefineMacro("DEBUG", "1");
     }
     if (_game.Settings.EnforceObjectBasedScript)
     {
         preprocessor.DefineMacro("STRICT", "1");
     }
     if (_game.Settings.LeftToRightPrecedence)
     {
         preprocessor.DefineMacro("LRPRECEDENCE", "1");
     }
     if (_game.Settings.EnforceNewStrings)
     {
         preprocessor.DefineMacro("STRICT_STRINGS", "1");
     }
     if (_game.Settings.EnforceNewAudio)
     {
         preprocessor.DefineMacro("STRICT_AUDIO", "1");
     }
     if (!_game.Settings.UseOldCustomDialogOptionsAPI)
     {
         preprocessor.DefineMacro("NEW_DIALOGOPTS_API", "1");
     }
     // Define Script API level macros
     foreach (ScriptAPIVersion v in Enum.GetValues(typeof(ScriptAPIVersion)))
     {
         if (v > _game.Settings.ScriptAPIVersion)
             break;
         preprocessor.DefineMacro(_scriptAPIVersionMacros[(int)v], "1");
     }
     foreach (ScriptAPIVersion v in Enum.GetValues(typeof(ScriptAPIVersion)))
     {
         if (v < _game.Settings.ScriptCompatLevel)
             continue;
         preprocessor.DefineMacro(_scriptCompatLevelMacros[(int)v], "1");
     }
 }
 /// <summary>
 /// Mockable Constructor
 /// </summary>
 public ImageApi(string connectionString, IPreprocessor preprocessor, IStorageElements elements)
     : this(preprocessor, new DataStore(connectionString, elements))
 {
 }
예제 #40
0
 public Searcher(IPreprocessor preprocessor, MatcherFactory matcherFactory)
 {
     _preprocessor = preprocessor;
     _matcherFactory = matcherFactory;
 }
예제 #41
0
 private void DefineMacrosAccordingToGameSettings(IPreprocessor preprocessor)
 {
     preprocessor.DefineMacro("AGS_NEW_STRINGS", "1");
     preprocessor.DefineMacro("AGS_SUPPORTS_IFVER", "1");
     if (_game.Settings.DebugMode)
     {
         preprocessor.DefineMacro("DEBUG", "1");
     }
     if (_game.Settings.EnforceObjectBasedScript)
     {
         preprocessor.DefineMacro("STRICT", "1");
     }
     if (_game.Settings.LeftToRightPrecedence)
     {
         preprocessor.DefineMacro("LRPRECEDENCE", "1");
     }
     if (_game.Settings.EnforceNewStrings)
     {
         preprocessor.DefineMacro("STRICT_STRINGS", "1");
     }
     if (_game.Settings.EnforceNewAudio)
     {
         preprocessor.DefineMacro("STRICT_AUDIO", "1");
     }
 }
예제 #42
0
파일: LsfRunner.cs 프로젝트: pipe01/LICC
 public LsfRunner(IEnvironment environment, ICommandFinder commandFinder, IFileSystem fileSystem, ICommandExecutor commandExecutor)
 {
     this.Interpreter  = new Interpreter(environment, commandExecutor, commandFinder);
     this.Preprocessor = new Preprocessor(fileSystem);
     this.FileSystem   = fileSystem;
 }
예제 #43
0
 public DirectiveParser(IPreprocessor preprocessor)
 {
     _preprocessor = preprocessor;
 }
예제 #44
0
 public T WithPreprocessor(IPreprocessor instance)
 {
     bundleState.AddPreprocessor(instance);
     return((T)this);
 }