当前位置: 首页>>代码示例>>C#>>正文


C# Machine类代码示例

本文整理汇总了C#中Machine的典型用法代码示例。如果您正苦于以下问题:C# Machine类的具体用法?C# Machine怎么用?C# Machine使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Machine类属于命名空间,在下文中一共展示了Machine类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Main

        public static void Main(string[] args)
        {
            string thing =
            @"if 10 equals 10 then end";

            var compiler = new Compiler.Compiler(thing); // ew ew ew double compiler ew
            var machine = new Machine();

            System.Diagnostics.Stopwatch timer = new System.Diagnostics.Stopwatch();
            try
            {
                timer.Start();
                CompiledProgram program = compiler.Compile();
                Console.WriteLine(program.ToString());

                machine.Load(program);
                machine.Run();
            }
            catch (EnglangException exp)
            {
                Console.WriteLine(exp.Message);
            }

            timer.Stop();
            Console.WriteLine("Done. Time: {0}", timer.Elapsed.ToString("%m\\:ss\\.ffff"));
            Console.ReadLine();
        }
开发者ID:Spanfile,项目名称:Englang,代码行数:27,代码来源:Program.cs

示例2: AllocSquares

 private void AllocSquares(Machine machine)
 {
     int squaresNeeded = machine.Parts.Count - squares.Count;
     //Fetch needed squares
     for(int i = 0; i < squaresNeeded; i++)
     {
         GameObject square;
         if(squaresPool.Count == 0)
         {
             square = Object.Instantiate(SquarePrefab) as GameObject;
         }
         else
         {
             square = squaresPool.Dequeue();
             square.SetActive(true);
             square.hideFlags = HideFlags.None;
         }
         square.transform.SetParent (this.transform, false);
         squares.Add (square);
     }
     //Release unneeded squares
     for(int i = 0; i < -squaresNeeded; i++)
     {
         GameObject square = squares[squares.Count - 1 - i];
         squaresPool.Enqueue(square);
         square.SetActive(false);
         square.hideFlags = HideFlags.HideInHierarchy;
         square.transform.SetParent(null);
     }
     if(squaresNeeded < 0)
     {
         squares.RemoveRange (squares.Count + squaresNeeded, -squaresNeeded);
     }
 }
开发者ID:GabrielSibley,项目名称:games,代码行数:34,代码来源:MachineMiniLayoutDisplay.cs

示例3: GenerateVertices

        public static void GenerateVertices(Machine machine, double x, double y)
        {
            eachSide = new List<int>();
            vertices = new List<Vertex>();
            shapeList = new List<FrameworkElement>();
            edges = new List<Edge>();

            canvasHeight = y;
            canvasWidth = x;

            myMachine = machine;
            int i;
            int count = myMachine.States.Count;
            int rest = count - (count / 4) * 4; // остаток
            int onEachSide = count / 4;  // количество на каждой стороне

            for (i = 0; i < 4; i++)
            {
                eachSide.Add(onEachSide);
            }

            for (i = 0; i < rest; i++)
            {
                eachSide[i] += 1;
            }

            GenerateVertices();
            GenerateEdges();
            DrawVertices();
            DrawEdges();
        }
开发者ID:anhlehoang410,项目名称:Game-5,代码行数:31,代码来源:MachineDrawer.cs

示例4: Execute

        /// <summary>
        /// Parses given input and executes its opcodes.
        /// </summary>
        /// <param name="input">The user's input, as a string.</param>
        /// <param name="machine">The machine in which to execute the input.</param>
        public static Variable[] Execute(Machine machine, string input)
        {
            var resultsDictionary = new Dictionary<string, Variable>();
            var parser = new Parser( input, machine );

            try {
                // Execute opcodes
                foreach(Opcode opcode in parser.Parse()) {
                    Variable result = opcode.Execute();
                    if ( result != null
                      && !( resultsDictionary.ContainsKey( result.Name.Value ) ) )
                    {
                        resultsDictionary.Add( result.Name.Value, result );
                    }
                }
            }
            finally {
                machine.TDS.Collect();
            }

            // Return the vector of results
            var toret = new Variable[ resultsDictionary.Count ];
            resultsDictionary.Values.CopyTo( toret, 0 );
            return toret;
        }
开发者ID:Baltasarq,项目名称:CSim,代码行数:30,代码来源:ArchManager.cs

示例5: Main

        static void Main(string[] args)
        {
            var machine = new Machine(new StateInactive());
            var output = machine.Command("Input_Begin", Command.Begin);
            Console.WriteLine(Command.Begin.ToString() + "->  State: " + machine.Current);
            Console.WriteLine(output);
            Console.WriteLine("-------------------------------------------------");

            output = machine.Command("Input_Pause", Command.Pause);
            Console.WriteLine(Command.Pause.ToString() + "->  State: " + machine.Current);
            Console.WriteLine(output);
            Console.WriteLine("-------------------------------------------------");

            output = machine.Command("Input_End", Command.End);
            Console.WriteLine(Command.End.ToString() + "->  State: " + machine.Current);
            Console.WriteLine(output);
            Console.WriteLine("-------------------------------------------------");

            output = machine.Command("Input_Exit", Command.Exit);
            Console.WriteLine(Command.End.ToString() + "->  State: " + machine.Current);
            Console.WriteLine(output);
            Console.WriteLine("-------------------------------------------------");

            Console.WriteLine("");
            Console.WriteLine("Press any key to exit.");
            Console.ReadKey();
        }
开发者ID:thedom85,项目名称:CSharp_FiniteStateMachine,代码行数:27,代码来源:Program.cs

示例6: Main

static void Main()
{
Machine computer = new Machine("Intel");
showProcess proc = computer.Process;
proc = (showProcess)Delegate.Combine(proc, new showProcess(Process));
proc("pentium");
}
开发者ID:EdiCarlos,项目名称:MyPractices,代码行数:7,代码来源:example2.cs

示例7: Main

        private static void Main()
        {
            Console.SetWindowSize(Console.WindowWidth * 2, Console.WindowHeight * 2);
            bool correct = false;
            List<string> code = new List<string>();
            Machine machine = null;

            while (!correct)
            {
                Console.WriteLine("Please enter your LMC commands one line at a time. When the program is complete, enter a blank line.\n");

                //Code entering
                while (true)
                {
                    string line = Console.ReadLine();
                    if (line == string.Empty) { break; }
                    code.Add(line);
                }

                //If empty restart
                if (code.Count == 0) { Console.Clear(); continue; }

                Console.WriteLine("Is this program correct? Y/N");

                //Check for Y and N key presses
                bool cont = true;
                while (true)
                {
                    ConsoleKey key = Console.ReadKey().Key;
                    if (key == ConsoleKey.Y) { Console.WriteLine("\n"); break; }
                    if (key == ConsoleKey.N)
                    {
                        Console.Clear();
                        code = new List<string>();
                        cont = false;
                        break;
                    }
                    Console.Write("\b \b");
                }
                if (!cont) { continue; }

                //Verify if code is valid
                machine = new Machine(code);
                if (!machine.Compile())
                {
                    Console.WriteLine("Code is invalid, please reenter a valid LMC command code. Press nter to restart.");
                    Console.ReadLine();
                    Console.Clear();
                    code = new List<string>();
                }
                else
                {
                    Console.WriteLine("\nCode is verified and valid, proceeding.");
                    correct = true;
                }
            }

            //Run virtual machine
            machine.Run();
        }
开发者ID:StupidChris,项目名称:LMC-Emulator,代码行数:60,代码来源:Console.cs

示例8: ShutdownMethodTest

        public void ShutdownMethodTest() {
            _mockShutdownMethod.SetupSet(x => x.VirtualMachineProxy = _mockMachineProxy.Object).Verifiable();
            Machine m = new Machine(_mockMachineProxy.Object); // TODO: Passenden Wert initialisieren
            m.ShutdownMethod = _mockShutdownMethod.Object;

            _mockShutdownMethod.VerifyAll();
        }
开发者ID:shabbirh,项目名称:virtualboxservice,代码行数:7,代码来源:MachineTest.cs

示例9: InsertMachine

        /// <summary>
        /// InsertMachine
        /// </summary>
        /// <returns>Liste supports</returns>
        public int InsertMachine(Machine s)
        {
            int result = -1;
            CustomDataSource maDataSource = new CustomDataSource(Properties.Settings.Default.CHAINE_CONNEXION);

            try
            {
                maDataSource.StartGlobalTransaction();

                result = maDataSource.ExecuterDML(REQUETE_AJOUTER_MACHINE, true, s.Code, s.Nom, s.Historique, s.Caracteristiques, s.DateSortie);

                maDataSource.CommitGlobalTransaction();

            }
            catch (Exception ex)
            {
                maDataSource.RollBackGlobalTransaction();

                throw ex;
            }
            finally
            {
                
            }

            return result;
        }
开发者ID:Jaymz2015,项目名称:MediaGestion,代码行数:31,代码来源:MachineDAO.cs

示例10: STM32LTDC

        public STM32LTDC(Machine machine) : base(machine)
        {
            Reconfigure(format: PixelFormat.RGBX8888);

            IRQ = new GPIO();

            this.machine = machine;
            internalLock = new object();

            var activeWidthConfigurationRegister = new DoubleWordRegister(this);
            accumulatedActiveHeightField = activeWidthConfigurationRegister.DefineValueField(0, 11, FieldMode.Read | FieldMode.Write, name: "AAH");
            accumulatedActiveWidthField = activeWidthConfigurationRegister.DefineValueField(16, 12, FieldMode.Read | FieldMode.Write, name: "AAW", writeCallback: (_, __) => HandleActiveDisplayChange());

            var backPorchConfigurationRegister = new DoubleWordRegister(this);
            accumulatedVerticalBackPorchField = backPorchConfigurationRegister.DefineValueField(0, 11, FieldMode.Read | FieldMode.Write, name: "AVBP");
            accumulatedHorizontalBackPorchField = backPorchConfigurationRegister.DefineValueField(16, 12, FieldMode.Read | FieldMode.Write, name: "AHBP", writeCallback: (_, __) => HandleActiveDisplayChange());

            var backgroundColorConfigurationRegister = new DoubleWordRegister(this);
            backgroundColorBlueChannelField = backgroundColorConfigurationRegister.DefineValueField(0, 8, FieldMode.Read | FieldMode.Write, name: "BCBLUE");
            backgroundColorGreenChannelField = backgroundColorConfigurationRegister.DefineValueField(8, 8, FieldMode.Read | FieldMode.Write, name: "BCGREEN");
            backgroundColorRedChannelField = backgroundColorConfigurationRegister.DefineValueField(16, 8, FieldMode.Read | FieldMode.Write, name: "BCRED", writeCallback: (_, __) => HandleBackgroundColorChange());

            var interruptEnableRegister = new DoubleWordRegister(this);
            lineInterruptEnableFlag = interruptEnableRegister.DefineFlagField(0, FieldMode.Read | FieldMode.Write, name: "LIE");

            var interruptClearRegister = new DoubleWordRegister(this);
            interruptClearRegister.DefineFlagField(0, FieldMode.Write, name: "CLIF", writeCallback: (old, @new) => { if(@new) IRQ.Unset(); });
            interruptClearRegister.DefineFlagField(3, FieldMode.Write, name: "CRRIF", writeCallback: (old, @new) => { if(@new) IRQ.Unset(); });

            lineInterruptPositionConfigurationRegister = new DoubleWordRegister(this).WithValueField(0, 11, FieldMode.Read | FieldMode.Write, name: "LIPOS");

            var registerMappings = new Dictionary<long, DoubleWordRegister>
            {
                { (long)Register.BackPorchConfigurationRegister, backPorchConfigurationRegister },
                { (long)Register.ActiveWidthConfigurationRegister, activeWidthConfigurationRegister },
                { (long)Register.BackgroundColorConfigurationRegister, backgroundColorConfigurationRegister },
                { (long)Register.InterruptEnableRegister, interruptEnableRegister },
                { (long)Register.InterruptClearRegister, interruptClearRegister },
                { (long)Register.LineInterruptPositionConfigurationRegister, lineInterruptPositionConfigurationRegister }
            };

            localLayerBuffer = new byte[2][];
            layer = new Layer[2];
            for(var i = 0; i < layer.Length; i++)
            {
                layer[i] = new Layer(this, i);

                var offset = 0x80 * i;
                registerMappings.Add(0x84 + offset, layer[i].ControlRegister);
                registerMappings.Add(0x88 + offset, layer[i].WindowHorizontalPositionConfigurationRegister);
                registerMappings.Add(0x8C + offset, layer[i].WindowVerticalPositionConfigurationRegister);
                registerMappings.Add(0x94 + offset, layer[i].PixelFormatConfigurationRegister);
                registerMappings.Add(0x98 + offset, layer[i].ConstantAlphaConfigurationRegister);
                registerMappings.Add(0xAC + offset, layer[i].ColorFrameBufferAddressRegister);
            }

            registers = new DoubleWordRegisterCollection(this, registerMappings);
            registers.Reset();
            HandlePixelFormatChange();
        }
开发者ID:rte-se,项目名称:emul8,代码行数:60,代码来源:STM32LTDC.cs

示例11: Add

        private static EnvironmentConfig Add(
            this EnvironmentConfig config,
            string applicationName,
            string logicalInstanceName,
            string machineName)
        {
            var app = config.Applications.SelectByName(applicationName);
            if (app == null)
            {
                app = new Application(applicationName);
                config.Applications.Add(app);
            }

            var logicalInstance = app.LogicalInstances.SelectByName(logicalInstanceName);
            if (logicalInstance == null)
            {
                logicalInstance = new LogicalInstance(logicalInstanceName);
                app.LogicalInstances.Add(logicalInstance);
            }

            var machine = logicalInstance.Machines.SelectByName(machineName);
            if (machine == null)
            {
                machine = new Machine(machineName);
                logicalInstance.Machines.Add(machine);
            }

            return config;
        }
开发者ID:paulkearney,项目名称:brnkly,代码行数:29,代码来源:EnvironmentConfigBuilderExtensions.cs

示例12: Compile

        public void Compile()
        {
            Machine machine = new Machine();
            IClass cls = machine.CreateClass("TestClass");
            cls.DefineInstanceVariable("x");
            cls.DefineClassVariable("count");

            Block block;

            block = new Method(cls, "x:");
            block.CompileArgument("newX");
            block.CompileGet("newX");
            block.CompileGet("count");
            block.CompileSet("x");

            Assert.AreEqual(1, block.Arity);
            Assert.AreEqual(0, block.NoLocals);
            Assert.IsNotNull(block.ByteCodes);
            Assert.IsTrue(block.ByteCodes.Length > 0);

            BlockDecompiler decompiler = new BlockDecompiler(block);
            var result = decompiler.Decompile();

            Assert.IsNotNull(result);
            Assert.AreEqual(3, result.Count);

            Assert.AreEqual("GetArgument newX", result[0]);
            Assert.AreEqual("GetClassVariable count", result[1]);
            Assert.AreEqual("SetInstanceVariable x", result[2]);
        }
开发者ID:ajlopez,项目名称:AjTalk,代码行数:30,代码来源:BlockTests.cs

示例13: AvoidDuplicatedInstanceVariable

 public void AvoidDuplicatedInstanceVariable()
 {
     Machine machine = new Machine();
     IClass cls = machine.CreateClass("TestClass");
     cls.DefineInstanceVariable("x");
     cls.DefineInstanceVariable("x");
 }
开发者ID:ajlopez,项目名称:AjTalk,代码行数:7,代码来源:ClassTests.cs

示例14: Clone

 public Machine Clone()
 {
     Machine insMachine = new Machine();
     insMachine.username = this.username;
     insMachine.domain = this.domain;
     insMachine.machine = this.machine;
     insMachine.password = this.password;
     insMachine.autoconnect = true;
     insMachine.connectionname = this.connectionname;
     insMachine.savepassword = true;
     insMachine.sharediskdrives = this.sharediskdrives;
     insMachine.shareprinters = this.shareprinters;
     insMachine.cachebitmaps = this.cachebitmaps;
     insMachine.colordepth = this.colordepth;
     insMachine.connected = false;
     insMachine.connecttoconsole = this.connecttoconsole;
     insMachine.displaythemes = this.displaythemes;
     insMachine.displaywallpaper = this.displaywallpaper;
     insMachine.fullscreen = false;
     insMachine.port = this.port;
     insMachine.protocol = this.protocol;
     insMachine.sharekeys = this.sharekeys;
     insMachine.shareports = this.shareports;
     insMachine.sharesmartcards = this.sharesmartcards;
     insMachine.sharesound = this.sharesound;
     insMachine.resolution = this.resolution;
     insMachine.inherit_settings = this.inherit_settings;
     insMachine.groupid = this.groupid;
     return insMachine;
 }
开发者ID:kisflying,项目名称:kion,代码行数:30,代码来源:Machine.cs

示例15: Remove

 public void Remove(Machine machine)
 {
     if (IdExists(machine))
     {
         lookupTable.Remove(MachineAt(IndexOf(machine)));
     }
 }
开发者ID:dvgamer,项目名称:Touno.Sentinel-II,代码行数:7,代码来源:MachineBanTable.cs


注:本文中的Machine类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。