示例#1
0
 public void ThrowArmor(float reachtime)
 {
     if (Life > 0)
     {
         string armorname = ReceiveDamage(1);
         _thrower.Throw(armorname, reachtime);
         _animator.SetTrigger("attack");
     }
     OnLootChange();
 }
        private Control CreateControl(string name, SerializableMap settings)
        {
            var context = new ControlContext
            {
                ioRunner = ior,
                uiRunner = uir
            };

            switch (name)
            {
            case "WritePointControl":
                return(new WritePointControl(context, settings));

            case "ReadPointControl":
                return(new ReadPointControl(context, settings));

            case "ReadRegisterControl":
                return(new ReadRegisterControl(context, settings));

            case "WriteRegisterControl":
                return(new WriteRegisterControl(context, settings));

            case "ReadFloatControl":
                return(new ReadFloatControl(context, settings));

            case "WriteFloatControl":
                return(new WriteFloatControl(context, settings));
            }
            Thrower.Throw("Unknown control name {0}", name);
            return(null);
        }
        public void StackTraceHelper_IncludesLineNumbersForFiles()
        {
            // Arrange
            Exception exception = null;

            try
            {
                // Throwing an exception in the current assembly always seems to populate the full stack
                // trace regardless of symbol type. Crossing assembly boundaries ensures PortablePdbReader gets used
                // on desktop.
                Thrower.Throw();
            }
            catch (Exception ex)
            {
                exception = ex;
            }

            // Act
            var stackFrames = StackTraceHelper.GetFrames(exception);

            // Assert
            Assert.Collection(stackFrames,
                              frame =>
            {
                Assert.Contains("Thrower.cs", frame.FilePath);
                Assert.Equal(17, frame.LineNumber);
            },
                              frame =>
            {
                Assert.Contains("StackTraceHelperTest.cs", frame.FilePath);
            });
        }
示例#4
0
        /// <summary>
        /// Parse of selected .sln file.
        /// </summary>
        /// <param name="sln">Solution file</param>
        /// <param name="type">Allowed type of operations.</param>
        /// <returns></returns>
        public ISlnResult Parse(string sln, SlnItems type)
        {
            if (string.IsNullOrWhiteSpace(sln))
            {
                Thrower.Throw(new ArgumentNullException(nameof(sln), MsgResource.ValueNoEmptyOrNull), sln);
                return(null);
            }

            using var reader = new StreamReader(sln, encoding);
            return(Parse(reader, type));
        }
示例#5
0
 public byte[] Read()
 {
     if (input.TryDequeue(out byte[] data))
     {
         if (data.Length == 0)
         {
             Thrower.Throw("Listener EOF");
         }
         return(data);
     }
     return(null);
 }
 public override void OnInspectorGUI()
 {
     base.OnInspectorGUI();
     if (Application.isPlaying)
     {
         if (GUILayout.Button("Throw"))
         {
             script.Throw();
         }
         if (GUILayout.Button("Reload"))
         {
             script.Reload();
         }
     }
 }
示例#7
0
        public void CheckException(byte[] response, int count)
        {
            if (count < 9)
            {
                Thrower.Throw("Partial exception packet got {0} expected >= {1}", count, 9);
            }
            var offset = 6;
            var code   = response[offset + 1];

            if ((code & 0x80) != 0)
            {
                Assert.Equal(response[offset + 0], Wrapped.Slave, "Slave mismatch got {0} expected {1}");
                Assert.Equal(code & 0x7F, Wrapped.Code, "Code mismatch got {0} expected {1}");
                throw new ModbusException(response[offset + 2]);
            }
        }
示例#8
0
        public static void Main(string[] args)
        {
            AppDomain.CurrentDomain.UnhandledException += UnhandledExceptionTrapper;

            if (args.Length > 0)
            {
                switch (args[0])
                {
                case "--list":
                    return;
                }
            }

            var config = Config.Parse(string.Join(" ", args));

            var socket = new TcpClient();
            var result = socket.BeginConnect(config.IP, config.Port, null, null);

            if (!result.AsyncWaitHandle.WaitOne(1000, true))
            {
                Thrower.Throw("Timeout connecting to {0}:{1}", config.IP, config.Port);
            }
            socket.EndConnect(result);

            var thread = new Thread(() => { ReadLoop(socket); })
            {
                IsBackground = true
            };

            thread.Start();

            var line = Console.ReadLine();

            while (line != null)
            {
                var bytes = Convert.FromBase64String(line);
                socket.GetStream().Write(bytes, 0, bytes.Length);
                line = Console.ReadLine();
            }

            throw new Exception("Stdin closed unexpectedly");
        }
示例#9
0
        public void CheckException(byte[] response, int count)
        {
            if (count < 5)
            {
                Thrower.Throw("Partial exception packet got {0} expected >= {1}", count, 5);
            }
            var offset = 0;
            var code   = response[offset + 1];

            if ((code & 0x80) != 0)
            {
                Assert.Equal(response[offset + 0], Wrapped.Slave, "Slave mismatch got {0} expected {1}");
                Assert.Equal(code & 0x7F, Wrapped.Code, "Code mismatch got {0} expected {1}");
                var crc1 = ModbusHelper.CRC16(response, offset, 3);
                //crc is little endian page 13 http://modbus.org/docs/Modbus_over_serial_line_V1_02.pdf
                var crc2 = ModbusHelper.GetUShortLittleEndian(response, offset + 3);
                Assert.Equal(crc2, crc1, "CRC mismatch got {0:X4} expected {1:X4}");
                throw new ModbusException(response[offset + 2]);
            }
        }
示例#10
0
        /// <summary>
        /// To parse data from used stream.
        /// </summary>
        /// <param name="reader"></param>
        /// <param name="type">Allowed type of operations.</param>
        /// <returns></returns>
        public ISlnResult Parse(StreamReader reader, SlnItems type)
        {
            if (reader == null)
            {
                Thrower.Throw(new ArgumentNullException(nameof(reader), MsgResource.ValueNoEmptyOrNull));
                return(null);
            }

            string sln = (reader.BaseStream is FileStream) ? ((FileStream)reader.BaseStream).Name : MEM_FILE;

            var data = new SlnResult()
            {
                SolutionDir = sln.GetDirectoryFromFile(),
                ResultType  = type,
            };

            Process(new Svc(reader, data));

            if (data.SolutionConfigs != null)
            {
                data.DefaultConfig = new ConfigItem(
                    ExtractDefaultConfiguration(data.SolutionConfigs),
                    ExtractDefaultPlatform(data.SolutionConfigs)
                    );
            }

            data.Properties = GlobalProperties(
                sln,
                data.DefaultConfig?.Configuration,
                data.DefaultConfig?.Platform
                );

            Aliases(data);

            if ((type & SlnItems.Env) == SlnItems.Env)
            {
                var Env = new IsolatedEnv(data, RawXmlProjects);
                Env.ShouldThrowErrorsInStrictMode = this.ShouldThrowErrorsInStrictMode;

                data.Env = Env;
                if ((type & SlnItems.EnvWithMinimalProjects) == SlnItems.EnvWithMinimalProjects)
                {
                    data.Env.LoadMinimalProjects();
                }
                if ((type & SlnItems.EnvWithProjects) == SlnItems.EnvWithProjects)
                {
                    data.Env.LoadProjects();
                }
            }

            if ((type & SlnItems.ProjectDependenciesXml) == SlnItems.ProjectDependenciesXml)
            {
                if (data.Env?.Projects != null)
                {
                    // The following class provides additional features for project references in ISlnPDManager manner,
                    // But we'll just activate references for existing ProjectDependencies (shallow copy)
                    // just to eliminate miscellaneous units between VS and msbuild world: https://github.com/3F/MvsSln/issues/25
                    new ProjectReferences(data.ProjectDependencies, data.Env.Projects);
                }
            }

            return(data);
        }
 public void Throw_Throws()
 {
     Assert.Throws <InvalidOperationException>(() => Thrower.Throw(new InvalidOperationException()));
 }