示例#1
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");
                    }
                }
            }
        }
 private void LogMessage(int Level, int Code, String strMessage)
 {
     if (m_ipLog != null)
     {
         m_ipLog.AddMessage(Level, Code, strMessage);
     }
 }
示例#3
0
 public void Start()
 {
     try
     {
         try
         {
             Task.Run(() => _host.Open()).Wait();
             Task.Run(() => _webAppHost.Open()).Wait();
         }
         catch (AggregateException ex)
         {
             throw ex.InnerExceptions.FirstOrDefault() ?? ex;
         }
         Task.Run(() => SessionManager.GarbageCollectorAsync(_gcCancellation.Token));
         StatusMonitor?.SetOnline();
         Log?.AddMessage("Service successfully started at {0}", ServiceUri);
     }
     catch (Exception ex)
     {
         Log?.AddMessage("Failed to start: {0}", ex);
         StatusMonitor?.SetError(ex.Message);
     }
 }
示例#4
0
        public static void Preprocess(string originalFile, string outputFile, string game, ILog messageLog)
        {
            EACodeLanguage language = languages[game];

            var predefined = new[]
            {
                "_" + game + "_",
                "_EA_"
            };

            using (var preprocessor = new Preprocessor(messageLog))
            {
                preprocessor.AddReserved(language.GetCodeNames());
                preprocessor.AddDefined(predefined);

                using (var reader = File.OpenText(originalFile))
                {
                    var stream = new PreprocessingInputStream(reader, preprocessor);

                    var writer = new StringWriter();
                    while (true)
                    {
                        string line = stream.ReadLine();
                        if (line == null)
                        {
                            break;
                        }
                        writer.WriteLine(line);
                    }
                    messageLog.AddMessage("Processed code:\n" + writer + "\nEnd processed code");
                    //File.WriteAllText(outputFile, writer.ToString());

                }
            }
        }