Exemple #1
0
        public MathPresenter(IMathView view, Processor processor)
        {
            this.view = view;

            this.processor = processor;
            workspace = new MathWorkspace(Settings.Default.MaxCountOfExpressions);
        }
 static ImageLoader()
 {
     string baseDir = Path.Combine (Environment.GetFolderPath (Environment.SpecialFolder.Personal), "..");
     _cacheDir = Path.Combine (baseDir, "tmp/");
     _queue = new Processor<GetImageRequest>(Download);
     _requests = new Dictionary<GetImageRequest, Action<UpdateImage>>();
 }
Exemple #3
0
        public void Evaluate()
        {
            var processor = new Processor();

            var result = processor.Evaluate(@"//Nothing but a comment");
            Assert.IsNull(result.Result);
        }
Exemple #4
0
        public override bool Execute()
        {
            var referenceCopyLocalPaths = ReferenceCopyLocalPaths.Select(x => x.ItemSpec).ToList();
            var defineConstants = DefineConstants.GetConstants();
            processor = new Processor
            {
                Logger = new BuildLogger
                {
                    BuildEngine = BuildEngine,
                },
                AssemblyFilePath = AssemblyPath,
                IntermediateDirectory = IntermediateDir,
                KeyFilePath = KeyFilePath,
                SignAssembly = SignAssembly,
                ProjectDirectory = ProjectDirectory,
                References = References,
                SolutionDirectory = SolutionDir,
                ReferenceCopyLocalPaths = referenceCopyLocalPaths,
                DefineConstants = defineConstants,
                NuGetPackageRoot = NuGetPackageRoot
            };
            var success = processor.Execute();
            if (success)
            {
                var weavers = processor.Weavers.Select(x => x.AssemblyName);
                ExecutedWeavers = string.Join(";", weavers) + ";";
            }

            return success;
        }
Exemple #5
0
        public void ProcessorToString()
        {
            Processor p = new Processor(1, "Name", 0x1000, 0x40000, 0x3E000, 0x3FFFF);

            Console.WriteLine(p.ToString());
            Console.WriteLine(p.ToString("LOG", null));
        }
Exemple #6
0
    public void GenXML()
    {
        String sourceUri = Server.MapPath("5648.xml");
        String xqUri = Server.MapPath("graph.xq");

        using (FileStream sXml = File.OpenRead(sourceUri))
        {
            using (FileStream sXq = File.OpenRead(xqUri))
            {
                Processor processor = new Processor();
                XQueryCompiler compiler = processor.NewXQueryCompiler();
                compiler.BaseUri = sourceUri;
                XQueryExecutable exp = compiler.Compile(sXq);
                XQueryEvaluator eval = exp.Load();

                DocumentBuilder loader = processor.NewDocumentBuilder();
                loader.BaseUri = new Uri(sourceUri);
                XdmNode indoc = loader.Build(new FileStream(sourceUri, FileMode.Open, FileAccess.Read));

                eval.ContextItem = indoc;
                Serializer qout = new Serializer();
                qout.SetOutputProperty(Serializer.METHOD, "xml");
                qout.SetOutputProperty(Serializer.INDENT, "yes");
                qout.SetOutputProperty(Serializer.SAXON_INDENT_SPACES, "1");
                qout.SetOutputWriter(Response.Output);
                eval.Run(qout);
            }
        }
    }
Exemple #7
0
        // For viewing previous weeks processing
        public WeeklyProcessor(Processor ProcA, Processor ProcB)
        {
            FormType = 2;
            weeksProcessData = Global.Util.DeepClone<Processor>(ProcA);
            PreviousWeekProc = Global.Util.DeepClone<Processor>(ProcB);
            InitializeComponent();
            dataGridView_Previous.DataSource = PreviousWeekProc.Portfolio.Stocks;
            dataGridView_Current.DataSource = weeksProcessData.Portfolio.Stocks;

            dataGridView_Universe.AutoGenerateColumns = false;
            dataGridView_Universe.DataSource = weeksProcessData.Universe.TrendsUniverseContents;
            DataGridViewTextBoxColumn col = new DataGridViewTextBoxColumn();
            col.DataPropertyName = "Symbol";
            dataGridView_Universe.Columns.Add(col);

            textBox_StockPick.Text = weeksProcessData.StockPick;
            button_Finish.Text = "Return";

            foreach (Control ctrl in this.tableLayoutPanel1.Controls)
            {
                if (ctrl is Button)
                    ctrl.Enabled = false;
            }
            button_Finish.Enabled = true;
            RefreshLabels();
        }
Exemple #8
0
 public TThreadPoolServer(Processor processor, ServerTransport serverTransport, LogDelegate logDelegate)
     : this(processor, serverTransport,
          new TransportFactory(), new TransportFactory(),
          new BinaryProtocol.Factory(), new BinaryProtocol.Factory(),
          DEFAULT_MIN_THREADS, DEFAULT_MAX_THREADS, logDelegate)
 {
 }
        public void FormatCollector(Dictionary<string, string> parameters, Dictionary<string, string> collectorDict, System.Xml.Linq.XElement collectorElement, Type collectorType, Processor processor)
        {
            CollectorHelpers.IsCollectorFormatterValid(collectorType, "NasuTek.Monitoring.Service.BuiltIn.Collectors.FileCollector");

            switch (collectorType.FullName)
            {
                case "NasuTek.Monitoring.Service.BuiltIn.Collectors.FileCollector":
                    {
                        string[] files = collectorDict["Files"].Split(',');
                        var dictRet = new Dictionary<string, Dictionary<string, string>>();

                        foreach (var file in files)
                        {
                            var xmlDoc = XDocument.Load(file);
                            foreach (var xmlRefVal in collectorElement.Elements("XmlRefToKeyValue"))
                            {
                                processor.AddDomain(xmlRefVal.Attribute("domain").Value, Path.GetFileName(file));

                                XElement ele = xmlDoc.XPathSelectElement(xmlRefVal.Attribute("name").Value);
                                if (ele != null)
                                    processor.GetDomain(xmlRefVal.Attribute("domain").Value, Path.GetFileName(file))[xmlRefVal.Attribute("domain_key").Value] = ele.Value;
                            }
                        }
                    }
                    break;
            }
        }
Exemple #10
0
        public ProcessorMT(Processor processor, int cThreads)
        {
            this.processor = processor;

            //(1) setting up threads to compute the best splits
            this.cThreads = (cThreads > MAX_THREADS) ? MAX_THREADS : cThreads;
            this.cThreads = (this.cThreads > processor.cJobs) ? processor.cJobs : this.cThreads;

            this.processorThreadObjs = new ProcessorThreadObj[this.cThreads];
            this.processorThreads = new Thread[this.cThreads];

            this.StartEvents = new ManualResetEvent[this.cThreads];
            this.DoneEvents = new ManualResetEvent[this.cThreads];

            for (int i = 0; i < this.cThreads; i++)
            {
                ProcessorThread processorThread = processor.CreatePerThread();

                this.StartEvents[i] = new ManualResetEvent(false);
                this.DoneEvents[i] = new ManualResetEvent(true);

                ProcessorThreadObj processorThreadObj = new ProcessorThreadObj(StartEvents[i], DoneEvents[i], processorThread);
                this.processorThreadObjs[i] = processorThreadObj;

                ThreadStart threadStart = new ThreadStart(processorThreadObj.Process);
                Thread thread = new Thread(threadStart);
                this.processorThreads[i] = thread;

                thread.Start();
            }
        }
Exemple #11
0
 private void RunProcessor(API.Request request, Processor processor, string processorName)
 {
     API.Response response = null;
     try
     {
         // Threadpooling
         response = processor.process(request);
     }
     catch (Exception e)
     {
         Logger.Error("Failed to process message with processor " + processor.GetType() + " : " + e.Message, e);
         try
         {
             Type responseType = Type.GetType("Gwupe.Cloud.Messaging.Response." + processorName + "Rs");
             response = (API.Response) responseType.GetConstructor(Type.EmptyTypes).Invoke(new object[] {});
             response.error = "UNKNOWN_ERROR";
             response.errorMessage = e.Message;
         }
         catch (Exception exception)
         {
             Logger.Error("Failed to determine return type for " + processorName);
             response = new ErrorRs
                 {
                     errorMessage = "Failed to determine return type for " + processorName,
                     error = "INTERNAL_SERVER_ERROR"
                 };
         }
     }
     finally
     {
         SendResponse(response, request);
     }
 }
        public string Transform(string baseDir, string sourceXml, string releaseType, string version)
        {
            var sourceXsl = SchematronBuilder.CheckForNewerSchematron(baseDir, releaseType, version);

            // Create a Processor instance.
            var processor = new Processor();

            var result = new StringBuilder();

            var xmlDocumentBuilder = processor.NewDocumentBuilder();
            xmlDocumentBuilder.BaseUri = new Uri(baseDir);

            var xsltCompiler = processor.NewXsltCompiler();
            xsltCompiler.ErrorList = new ArrayList();
            var xmlToValidate = xmlDocumentBuilder.Build(new StringReader(sourceXml));
            var compiledXsl = xsltCompiler.Compile(new XmlTextReader(sourceXsl));
            var xmlValidator = compiledXsl.Load();

            // Set the root node of the source document to be the initial context node.
            xmlValidator.InitialContextNode = xmlToValidate;

            // BaseOutputUri is only necessary for xsl:result-document.
            xmlValidator.BaseOutputUri = new Uri(Path.Combine(baseDir, "output.xml"));

            var validationSerializer = new Serializer();

            using (var resultsWriter = new StringWriter(result))
            {
                validationSerializer.SetOutputWriter(resultsWriter);
                xmlValidator.Run(validationSerializer);
            }

            return result.ToString();
        }
        public void ToProcessors()
        {
            string xElementProcessors =
                "<processors>" + "\r\n  " +
                "<processor ID=\"0\" Name=\"ATMega128\">" + "\r\n    " +
                "<eepromSize>0x1000</eepromSize>" + "\r\n    " +
                "<flashSize>0x20000</flashSize>" + "\r\n    " +
                "<bootStartAddress>0x1E000</bootStartAddress>" + "\r\n    " +
                "<bootEndAddress>0x1FFFF</bootEndAddress>" + "\r\n  " +
                "</processor>" + "\r\n  " +
                "<processor ID=\"1\" Name=\"ATMega2560\">" + "\r\n    " +
                "<eepromSize>0x1000</eepromSize>" + "\r\n    " +
                "<flashSize>0x40000</flashSize>" + "\r\n    " +
                "<bootStartAddress>0x3E000</bootStartAddress>" + "\r\n    " +
                "<bootEndAddress>0x3FFFF</bootEndAddress>" + "\r\n  " +
                "</processor>" + "\r\n" +
                "</processors>";

            XElement xElement = XElement.Parse(xElementProcessors);
            var processors = xElement.ToProcessors(XNamespace.None).ToList();

            Assert.AreEqual(2, processors.Count);

            Processor expectedProcessor1 = new Processor(0, "ATMega128",
                0x1000, 0x20000, 0x1E000, 0x1FFFF);
            Processor expectedProcessor2 = new Processor(1, "ATMega2560",
                0x1000, 0x40000, 0x3E000, 0x3FFFF);

            Assert.IsTrue(expectedProcessor1.Equals(processors[0]));
            Assert.IsTrue(expectedProcessor2.Equals(processors[1]));
        }
        public string Format(string input, Dictionary<string, string> parameters, Processor processor)
        {
            var sizeUnconv = Convert.ToDouble(string.Join(null, System.Text.RegularExpressions.Regex.Split(input, "[^\\d]")));
            var oldSize = parameters.ContainsKey("OldFormat") ? parameters["OldFormat"] : "Bytes";
            var newSize = parameters.ContainsKey("NewFormat") ? parameters["NewFormat"] : "Bytes";
            var size = ByteConverter(oldSize, sizeUnconv);

            switch (newSize)
            {
                case "KB":
                    return (size / 1024).ToString("F2") + " KB";
                case "MB":
                    return (size / Math.Pow(1024, 2)).ToString("F2") + " MB";
                case "GB":
                    return (size / Math.Pow(1024, 3)).ToString("F2") + " GB";
                case "TB":
                    return (size / Math.Pow(1024, 4)).ToString("F2") + " TB";
                case "PB":
                    return (size / Math.Pow(1024, 5)).ToString("F2") + " PB";
                case "EB":
                    return (size / Math.Pow(1024, 6)).ToString("F2") + " EB";
                default:
                    return (size).ToString("F2") + " bytes";
            }
        }
Exemple #15
0
 public TThreadedServer(Processor processor, ServerTransport serverTransport)
     : this(processor, serverTransport,
          new TransportFactory(), new TransportFactory(),
          new BinaryProtocol.Factory(), new BinaryProtocol.Factory(),
          DEFAULT_MAX_THREADS, DefaultLogDelegate)
 {
 }
		protected override void OnStart(string[] args)
		{
			Core.Data.GainLogger.Write("Application started");

			_processor = new Processor();
			_processor.Start();
		}
 /// <summary>
 /// Image Processing
 /// </summary>
 /// <param name="image">image</param>
 public static void ImageProcessing([QueueTrigger("imaging")] string img)
 {
     var connectionString = CloudConfigurationManager.GetSetting("StorageAccount");
     var image = JsonConvert.DeserializeObject<ImageQueued>(img);
     var processor = new Processor(new DataStore(connectionString), versions.Images);
     processor.Process(image).Wait();
 }
Exemple #18
0
 public SocketServer(FitSocket socket, Processor<Cell> service, ProgressReporter reporter, bool suiteSetUpIsAnonymous)
 {
     this.service = service;
     this.reporter = reporter;
     this.socket = socket;
     IMaybeProcessingSuiteSetup = suiteSetUpIsAnonymous;
 }
        public async Task Process()
        {
            var bytes = File.ReadAllBytes(Environment.CurrentDirectory + @"\icon.png");

            var versions = this.Versions();
            var version = versions.Values.First();

            var queued = new ImageQueued
            {
                Identifier = Guid.NewGuid(),
                OriginalExtension = Naming.DefaultExtension,
                
            };
            queued.FileNameFormat = queued.Identifier.ToString() + "_{0}.{1}";

            await this.container.Save(string.Format("{0}_original.jpeg", queued.Identifier), bytes);

            var store = new DataStore(connectionString);

            var processor = new Processor(new DataStore(connectionString), versions);
            await processor.Process(queued);

            var data = await this.container.Get(string.Format("{0}_test.gif", queued.Identifier));
            Assert.IsNotNull(data);

            var entities = await this.table.QueryByRow<ImageEntity>("test");
            var entity = entities.FirstOrDefault();

            Assert.IsNotNull(entity);
            Assert.AreEqual(version.Format.MimeType, entity.MimeType);
            Assert.AreEqual(string.Format(Naming.PathFormat, this.container.Name, entity.FileName), entity.RelativePath);
        }
 public void Execute(Processor processor, params string[] parameters)
 {
     if (parameters.Length > 0)
     {
         if (parameters[0].Equals("start", StringComparison.InvariantCultureIgnoreCase))
         {
             if (parameters.Length > 1)
             {
                 processor.StartBeacon(parameters[1]);
             }
             else
             {
                 processor.StartBeacon();
             }
         }
         else if (parameters[0].Equals("stop", StringComparison.InvariantCultureIgnoreCase))
         {
             processor.StopBeacon();
         }
     }
     else
     {
         Console.WriteLine("Parameters: start/stop [friendly name]");
     }
 }
        /// <summary>
        /// Initializes a new instance of the 
        /// <see cref="SplitColorSpaceChannelsForm"/> class.
        /// </summary>
        /// <param name="processor">The SBIP processor.</param>
        public SplitColorSpaceChannelsForm(Processor processor)
        {
            InitializeComponent();

            Processor = processor;
            filter = new SplitColorSpaceChannels {ColorSpace = ColorSpaceEnum.HSB};
        }
    public void AddChangedFile()
    {
        var fileName = Path.GetTempFileName();
        try
        {
            var expected = File.GetLastWriteTimeUtc(fileName);
            var loggerMock = new Mock<BuildLogger>();
            loggerMock.Setup(x => x.LogDebug(It.IsAny<string>()));

            var processor = new Processor
                            {
                                Logger = loggerMock.Object,
                                ConfigFiles = new List<string>
                                              {
                                                  fileName
                                              }
                            };
            processor.CheckForWeaversXmlChanged();
            File.SetLastWriteTimeUtc(fileName, DateTime.Now.AddHours(1));
            processor.CheckForWeaversXmlChanged();

            loggerMock.Verify();

            Assert.AreEqual(expected, Processor.TimeStamps.First().Value);
        }
        finally
        {
            File.Delete(fileName);
            Processor.TimeStamps.Clear();
        }
    }
Exemple #23
0
        static void Main()
        {
            Components mcardVLC = new MotherBoard("VLC", (decimal)185.98);
            Components vcardRadeon = new GraphicsCard("Radeon", (decimal)102.34, "the best grafic card forever");
            Components vcardGeForce = new GraphicsCard("GeForce", (decimal)154.45, "is not worth");

            Components procIntel = new Processor("Intel", (decimal)346.563, "can be better");
            Components procAMD = new Processor("AMD", (decimal)405.239, "always the best");
            Components procMac = new Processor("IOS", 2000m, "It is okaaaay");

            Computer mac = new Computer("Mac", new List<Components>() { mcardVLC, vcardRadeon, vcardGeForce });
            Computer windows = new Computer("Windows");
            windows.Components.Add(procIntel);
            windows.Components.Add(procAMD);
            windows.Components.Add(procMac);
            //Console.WriteLine(windows);

            Computer linux = new Computer("Linux", new List<Components>() { mcardVLC, vcardGeForce, vcardRadeon, procAMD, procIntel, procMac });

            List<Computer> computers = new List<Computer>() { mac, windows, linux };

            computers.OrderBy(p => p.TotalPrice).ToList().ForEach(p => Console.WriteLine(p.ToString()));


            //or

            //computers.OrderBy(a => a.TotalPrice);

            //foreach (var computer in computers)
            //{
            //    Console.WriteLine(computer);
            //}
        }
        public void ExecuteReport(Dictionary<string, string> parameters, Processor processor)
        {
            foreach (var domain in processor.GetAllDomains())
            {
                Console.WriteLine("Domain: " + domain.Key);

                if (domain.Value.ContainsKey("Global"))
                {
                    foreach (var value in domain.Value["Global"])
                    {
                        Console.WriteLine("\tKey: " + value.Key);
                        Console.WriteLine("\t\tValue: " + value.Value);
                    }
                }

                foreach (var subdomain in domain.Value.Where(v => v.Key != "Global"))
                {
                    Console.WriteLine("\tSubdomain: " + subdomain.Key);
                    foreach (var value in subdomain.Value)
                    {
                        Console.WriteLine("\t\tKey: " + value.Key);
                        Console.WriteLine("\t\t\tValue: " + value.Value);
                    }
                }
            }
        }
 public void ApplyToEach(Processor proc)
 {
     foreach (int da in data)
     {
        proc(da);
     }
 }
 public MainWindow()
 {
     InitializeComponent();
     LoadWorkflow();
     frameworkProcessor = new Processor();
     isSoftStop = false;
 }
Exemple #27
0
 public void CanDisplayHelp()
 {
     const string text = "Supplies a value for tests.";
     var proc = new Processor(defaultArgument: "--test");
     proc.Handle("--test").Describe(text);
     Assert.That(proc.Help(), Is.StringContaining(text));
 }
Exemple #28
0
 protected override Tree<string> ExecuteOperation(Processor<string> processor, Tree<string> parameters)
 {
     processor.Store(new SavedInstance(
         parameters.Branches[2].Value,
         processor.Create(parameters.Branches[3].Value, ParameterTree(parameters, 4)).Value));
     return DefaultResult(parameters);
 }
Exemple #29
0
		public void Stack_Pointer_Initializes_To_Default_Value_After_Reset()
		{
			var processor = new Processor();
			processor.Reset();

			Assert.That(processor.StackPointer, Is.EqualTo(0xFD));
		}
Exemple #30
0
        public GraphsPresenter(IGraphsView view, Processor processor)
        {
            this.view = view;

            this.processor = processor;
            countOfGraphs = Settings.Default.MaxCountOfExpressions >= 20 ? 20 : Settings.Default.MaxCountOfExpressions;
            listOfGraphs = new List<GraphItemViewModel>(countOfGraphs);
        }
 public CommonTuneController()
 {
     _listener               = new Listener();
     _processor              = new Processor(_listener.Rate, _listener.BlockStream);
     _processor.ResultReady += ProcessTuneResult;
 }
 public void TearDown()
 {
     Processor.CommitTransaction();
     Processor.Dispose();
 }
Exemple #33
0
 public OrC(Processor processor) : base(processor, OPCODE, 0, 4, NAME)
 {
 }
 public override void executeOn(Processor processor)
 {
     processor.execute(this);
 }
 public override void CallingColumnExistsReturnsFalseIfColumnDoesNotExistWithSchema()
 {
     using (var table = new SqlServerCeTestTable(Processor, "id int"))
         Processor.ColumnExists("NOTUSED", table.Name, "DoesNotExist").ShouldBeFalse();
 }
Exemple #36
0
 public static void CompareDoublePop64(Processor p)
 {
     Fucom.Compare64(p, p.FPU.GetRegisterRef(1));
     p.FPU.Pop();
     p.FPU.Pop();
 }
Exemple #37
0
 /// <summary>
 /// Recieves World information from the server and sends
 /// it to be processed. Begins receiving more information
 /// afterward.
 /// </summary>
 /// <param name="state"></param>
 private void ReceiveWorld(SocketState state)
 {
     Processor.ProcessData(theWorld, state);
     drawingPanel.Invalidate();
     Network.GetData(state);
 }
 public virtual DataSet Read(string template, params object[] args)
 {
     return(Processor.Read(template, args));
 }
 public virtual void Process(PerformDBOperationExpression expression)
 {
     Processor.Process(expression);
 }
 public virtual bool Exists(string template, params object[] args)
 {
     return(Processor.Exists(template, args));
 }
 public virtual DataSet ReadTableData(string tableName)
 {
     return(Processor.Read("SELECT * FROM [{0}]", tableName));
 }
 public virtual void Execute(string template, params object[] args)
 {
     Processor.Execute(template, args);
 }
Exemple #43
0
        /// <inheritdoc />
        /// <summary>
        /// On Service Start method
        /// </summary>
        /// <param name="args">Start arguments</param>
        public void OnStart(string[] args)
        {
            try
            {
                Core.Log.InfoBasic("Starting messaging service");
                _cTokenSource = new CancellationTokenSource();
                OnInit(args);
                QueueServer = GetQueueServer();
                if (QueueServer == null)
                {
                    throw new Exception("The queue server is null, please check the configuration file and ensure the Types assemblies are on the assembly folder.");
                }
                Processor = GetMessageProcessorAsync(QueueServer);
                if (Processor == null)
                {
                    throw new Exception("The message processor is null, please check your GetMessageProcessor method implementation.");
                }
                if (QueueServer.ResponseServer)
                {
                    QueueServer.ResponseReceived += async(s, e) =>
                    {
                        if (MessageReceived != null)
                        {
                            await MessageReceived.InvokeAsync(this, new RawMessageEventArgs(e.Message, e.CorrelationId)).ConfigureAwait(false);
                        }
                        await Processor.ProcessAsync(e, _cTokenSource.Token).ConfigureAwait(false);
                    };
                }
                else
                {
                    QueueServer.RequestReceived += async(s, e) =>
                    {
                        if (MessageReceived != null)
                        {
                            await MessageReceived.InvokeAsync(this, new RawMessageEventArgs(e.Request, e.CorrelationId)).ConfigureAwait(false);
                        }
                        var result = await Processor.ProcessAsync(e, _cTokenSource.Token).ConfigureAwait(false);

                        if (result != ResponseMessage.NoResponse && result != null)
                        {
                            e.Response = result as byte[] ?? (byte[])QueueServer.SenderSerializer.Serialize(result);
                        }
                    };
                    QueueServer.BeforeSendResponse += async(s, e) =>
                    {
                        if (BeforeSendMessage != null)
                        {
                            await BeforeSendMessage.InvokeAsync(this, new RawMessageEventArgs(e.Message, e.CorrelationId)).ConfigureAwait(false);
                        }
                    };
                    QueueServer.ResponseSent += async(s, e) =>
                    {
                        if (MessageSent != null)
                        {
                            await MessageSent.InvokeAsync(this, new RawMessageEventArgs(e.Message, e.CorrelationId)).ConfigureAwait(false);
                        }
                    };
                }

                Processor.Init();
                QueueServer.StartListeners();
                Core.Log.InfoBasic("Messaging service started.");

                Core.Status.Attach(collection =>
                {
                    Core.Status.AttachChild(Processor, this);
                    Core.Status.AttachChild(QueueServer, this);
                });
            }
            catch (Exception ex)
            {
                Core.Log.Write(ex);
                throw;
            }
        }
Exemple #44
0
 public static void RunTest(Processor p)
 {
     TestTools.RunLocalTest("A11", p.Process, p.TestDataName,
                            p.Verifier, VerifyResultWithoutOrder: p.VerifyResultWithoutOrder,
                            excludedTestCases: p.ExcludedTestCases);
 }
Exemple #45
0
 public GameBoyCpu(IMemoryMap memoryMap, Registers registers, Processor opcodeProcessor)
 {
     this.memoryMap = memoryMap;
     this.registers = registers;
     this.processor = opcodeProcessor;
 }
        public async Task Update(PerformContext c)
        {
            Ctx = c;
            Logger.LogDebug(LoggingEvents.Updater, "Starting Update job");

            var settings = await Settings.GetSettingsAsync();

            if (!settings.AutoUpdateEnabled)
            {
                Logger.LogDebug(LoggingEvents.Updater, "Auto update is not enabled");
                return;
            }

            var currentLocation = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);

            Logger.LogDebug(LoggingEvents.Updater, "Path: {0}", currentLocation);

            var productVersion = AssemblyHelper.GetRuntimeVersion();

            Logger.LogDebug(LoggingEvents.Updater, "Product Version {0}", productVersion);

            try
            {
                var productArray = GetVersion();
                var version      = productArray[0];
                Logger.LogDebug(LoggingEvents.Updater, "Version {0}", version);
                var branch = productArray[1];
                Logger.LogDebug(LoggingEvents.Updater, "Branch Version {0}", branch);

                Logger.LogDebug(LoggingEvents.Updater, "Version {0}", version);
                Logger.LogDebug(LoggingEvents.Updater, "Branch {0}", branch);

                Logger.LogDebug(LoggingEvents.Updater, "Looking for updates now");
                var updates = await Processor.Process(branch);

                Logger.LogDebug(LoggingEvents.Updater, "Updates: {0}", updates);
                var serverVersion = updates.UpdateVersionString;

                Logger.LogDebug(LoggingEvents.Updater, "Service Version {0}", updates.UpdateVersionString);

                if (!serverVersion.Equals(version, StringComparison.CurrentCultureIgnoreCase))
                {
                    // Let's download the correct zip
                    var desc  = RuntimeInformation.OSDescription;
                    var proce = RuntimeInformation.ProcessArchitecture;

                    Logger.LogDebug(LoggingEvents.Updater, "OS Information: {0} {1}", desc, proce);
                    Downloads download;
                    if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
                    {
                        Logger.LogDebug(LoggingEvents.Updater, "We are Windows");
                        download = updates.Downloads.FirstOrDefault(x => x.Name.Contains("windows.zip", CompareOptions.IgnoreCase));
                    }
                    else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
                    {
                        Logger.LogDebug(LoggingEvents.Updater, "We are OSX");
                        download = updates.Downloads.FirstOrDefault(x => x.Name.Contains("osx", CompareOptions.IgnoreCase));
                    }
                    else
                    {
                        Logger.LogDebug(LoggingEvents.Updater, "We are linux");
                        if (RuntimeInformation.OSDescription.Contains("arm", CompareOptions.IgnoreCase))
                        {
                            download = updates.Downloads.FirstOrDefault(x => x.Name.Contains("arm", CompareOptions.IgnoreCase));
                        }
                        else
                        {
                            download = updates.Downloads.FirstOrDefault(x => x.Name.Contains("linux", CompareOptions.IgnoreCase));
                        }
                    }
                    if (download == null)
                    {
                        Logger.LogDebug(LoggingEvents.Updater, "There were no downloads");
                        return;
                    }

                    Logger.LogDebug(LoggingEvents.Updater, "Found the download! {0}", download.Name);
                    Logger.LogDebug(LoggingEvents.Updater, "URL {0}", download.Url);

                    Logger.LogDebug(LoggingEvents.Updater, "Clearing out Temp Path");
                    var tempPath = Path.Combine(currentLocation, "TempUpdate");
                    if (Directory.Exists(tempPath))
                    {
                        DeleteDirectory(tempPath);
                    }

                    // Temp Path
                    Directory.CreateDirectory(tempPath);


                    if (settings.UseScript && !settings.WindowsService)
                    {
                        RunScript(settings, download.Url);
                        return;
                    }

                    // Download it
                    Logger.LogDebug(LoggingEvents.Updater, "Downloading the file {0} from {1}", download.Name, download.Url);
                    var extension = download.Name.Split('.').Last();
                    var zipDir    = Path.Combine(currentLocation, $"Ombi.{extension}");
                    Logger.LogDebug(LoggingEvents.Updater, "Zip Dir: {0}", zipDir);
                    try
                    {
                        if (File.Exists(zipDir))
                        {
                            File.Delete(zipDir);
                        }

                        Logger.LogDebug(LoggingEvents.Updater, "Starting Download");
                        await DownloadAsync(download.Url, zipDir, c);

                        Logger.LogDebug(LoggingEvents.Updater, "Finished Download");
                    }
                    catch (Exception e)
                    {
                        Logger.LogDebug(LoggingEvents.Updater, "Error when downloading");
                        Logger.LogDebug(LoggingEvents.Updater, e.Message);
                        Logger.LogError(LoggingEvents.Updater, e, "Error when downloading the zip");
                        throw;
                    }

                    // Extract it
                    Logger.LogDebug(LoggingEvents.Updater, "Extracting ZIP");
                    Extract(zipDir, tempPath);

                    Logger.LogDebug(LoggingEvents.Updater, "Finished Extracting files");
                    Logger.LogDebug(LoggingEvents.Updater, "Starting the Ombi.Updater process");
                    var updaterExtension = string.Empty;
                    if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
                    {
                        updaterExtension = ".exe";
                    }
                    var updaterFile = Path.Combine(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location),
                                                   "TempUpdate", $"Ombi.Updater{updaterExtension}");

                    // There must be an update
                    var start = new ProcessStartInfo
                    {
                        UseShellExecute  = false,
                        CreateNoWindow   = false,
                        FileName         = updaterFile,
                        Arguments        = GetArgs(settings),
                        WorkingDirectory = Path.Combine(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location), "TempUpdate"),
                    };
                    if (settings.Username.HasValue())
                    {
                        start.UserName = settings.Username;
                    }
                    if (settings.Password.HasValue())
                    {
                        start.Password = settings.Password.ToSecureString();
                    }
                    var proc = new Process {
                        StartInfo = start
                    };


                    proc.Start();

                    Logger.LogDebug(LoggingEvents.Updater, "Bye bye");
                }
            }
            catch (Exception e)
            {
                Logger.LogError(e, "Exception thrown in the OmbiUpdater, see previous messages");
                throw;
            }
        }
Exemple #47
0
 public LdEA(Processor processor) : base(processor, OPCODE, 0, 4, NAME)
 {
 }
Exemple #48
0
 public Task <IResult <AddIpResult> > Execute()
 {
     return(Processor.Process <AddIpResult, IAddIpAddressCommand, AddIpAddressCommand>(this,
                                                                                       context => context.AddIpAddress(this)));
 }
Exemple #49
0
 public static void ComparePop64(Processor p, double value)
 {
     Fucom.Compare64(p, value);
     p.FPU.Pop();
 }
Exemple #50
0
 /// <summary>
 /// Tears down.
 /// </summary>
 public void TearDown()
 {
     Processor.Dispose();
 }
Exemple #51
0
 protected override void ProcessCore(CassetteSettings settings)
 {
     Processor.Process(this, settings);
 }
 public override void CallingColumnExistsReturnsFalseIfTableDoesNotExistWithSchema()
 {
     Processor.ColumnExists("TestSchema", "DoesNotExist", "DoesNotExist").ShouldBeFalse();
 }
Exemple #53
0
 public void writeResultFilePreamble(Processor processor, XdmNode catalog)
 {
     resultsDoc.writeResultFilePreamble(processor, catalog);
 }
 public override void CallingColumnExistsReturnsFalseIfTableDoesNotExist()
 {
     Processor.ColumnExists(null, "DoesNotExist", "DoesNotExist").ShouldBeFalse();
 }
 public override void CallingColumnExistsCanAcceptTableNameWithSingleQuote()
 {
     using (var table = new SqlServerCeTestTable("Test'Table", Processor, Quoter.QuoteColumnName("id") + " int"))
         Processor.ColumnExists("NOTUSED", table.Name, "id").ShouldBeTrue();
 }
 public override void CallingColumnExistsReturnsFalseIfColumnDoesNotExistWithSchema()
 {
     using (var table = new FirebirdTestTable(Processor, "TestSchema", "id int"))
         Processor.ColumnExists("TestSchema", table.Name, "DoesNotExist").ShouldBeFalse();
 }
 public override void CallingColumnExistsReturnsTrueIfColumnExistsWithSchema()
 {
     using (var table = new SqlServerCeTestTable(Processor, Quoter.QuoteColumnName("id") + " int"))
         Processor.ColumnExists("NOTUSED", table.Name, "id").ShouldBeTrue();
 }
 public override void CallingColumnExistsCanAcceptTableNameWithSingleQuote()
 {
     using (var table = new FirebirdTestTable("Test'Table", Processor, null, "id int"))
         Processor.ColumnExists(null, table.Name, "ID").ShouldBeTrue();
 }
Exemple #59
0
 public static void Abs(Processor p)
 {
     ref var st0 = ref p.FPU.ST0_Ref;
 public override void CallingColumnExistsReturnsTrueIfColumnExists()
 {
     using (var table = new FirebirdTestTable(Processor, null, "id int"))
         Processor.ColumnExists(null, table.Name, "ID").ShouldBeTrue();
 }