Example #1
1
 public object WithRefsWithReturn(
     ref string param1,
     ref int param2,
     ref short param3,
     ref long param4,
     ref uint param5,
     ref ushort param6,
     ref ulong param7,
     ref bool param8,
     ref double param9,
     ref decimal param10,
     ref int? param11,
     ref object param12,
     ref char param13,
     ref DateTime param14,
     ref Single param15,
     ref IntPtr param16,
     ref UInt16 param17,
     ref UInt32 param18,
     ref UInt64 param19,
     ref UIntPtr param20
     )
 {
     throw new Exception("Foo");
 }
Example #2
0
 public Person(string firstName, string lastName, UInt16 age, Person bestFriend = null)
 {
   this.firstName = firstName;
   this.lastName = lastName;
   this.age = age;
   this.bestFriend = bestFriend;
 }
Example #3
0
        public bool SendMessage(UInt16 ip, byte code, string body = null)
        {
            if (!IsConnected())
                return false;

            var hasBody = !string.IsNullOrEmpty(body);

            var msg = new byte[hasBody ? 5 + body.Length : 3];

            var ipbs = BitConverter.GetBytes(ip);
            msg[0] = ipbs[0];
            msg[1] = ipbs[1];

            if (hasBody)
                code |= 1 << 7;
            msg[2] = (byte)code;

            if (hasBody)
            {
                var lbodybs = BitConverter.GetBytes(body.Length);
                msg[3] = lbodybs[0];
                msg[4] = lbodybs[1];

                var bodybs = System.Text.Encoding.ASCII.GetBytes(body);

                Array.Copy(bodybs, 0, msg, 5, body.Length);
            }

            return _device.Write(msg) > 0;
        }
Example #4
0
        /// <summary>
        /// Start the WebDAV interface using the given ip address, port and HTTPSecurity parameters.
        /// </summary>
        /// <param name="myIPAddress">The IPAddress for binding the interface at</param>
        /// <param name="myPort">The port for binding the interface at</param>
        /// <param name="myHttpWebSecurity">A HTTPSecurity class for checking security parameters like user credentials</param>
        public static Exceptional<HTTPServer<GraphDSWebDAV_Service>> StartWebDAV(this AGraphDSSharp myAGraphDSSharp, IPAddress myIPAddress, UInt16 myPort, HTTPSecurity myHttpWebSecurity = null)
        {
            try
            {
                // Initialize WebDAV service
                var _HttpWebServer = new HTTPServer<GraphDSWebDAV_Service>(
                    myIPAddress,
                    myPort,
                    new GraphDSWebDAV_Service(myAGraphDSSharp),
                    myAutoStart: true)
                {
                    HTTPSecurity = myHttpWebSecurity,
                };

                // Register the WebDAV service within the list of services
                // to stop before shutting down the GraphDSSharp instance
                myAGraphDSSharp.ShutdownEvent += new GraphDSSharp.ShutdownEventHandler((o, e) =>
                {
                    _HttpWebServer.StopAndWait();
                });

                return new Exceptional<HTTPServer<GraphDSWebDAV_Service>>(_HttpWebServer);

            }
            catch (Exception e)
            {
                return new Exceptional<HTTPServer<GraphDSWebDAV_Service>>(new GeneralError(e.Message, new System.Diagnostics.StackTrace(e)));
            }
        }
Example #5
0
		public GroupFoundEventArgs (Byte connection, UInt16 start, UInt16 end, Byte[] uuid)
		{
			this.connection = connection;
			this.start = start;
			this.end = end;
			this.uuid = uuid;
		}
			public IndexBuffer(IDataStream stream, ulong vcn, FolderNTFS folder) {
				_folder = folder;
				_clusterStart = vcn * (ulong)(_folder._record.SectorsPerCluster * _folder._record.BytesPerSector);
				String magic = Util.GetASCIIString(stream, _clusterStart + 0x0, 4);

				if (!magic.Equals("INDX")) {
					throw new Exception("Magic INDX value not present");
				}

				_entriesStart = (ushort)(Util.GetUInt16(stream, _clusterStart + 0x18) + 0x18);
				_entriesEnd = (ushort)(Util.GetUInt16(stream, _clusterStart + 0x1c) + _entriesStart);

				ushort updateSequenceOffset = Util.GetUInt16(stream, _clusterStart + 0x04);
				ushort updateSequenceLength = Util.GetUInt16(stream, _clusterStart + 0x06);

				ushort updateSequenceNumber = Util.GetUInt16(stream, _clusterStart + updateSequenceOffset);
				ushort[] updateSequenceArray = new ushort[updateSequenceLength - 1];
				ushort read = 1;
				while (read < updateSequenceLength) {
					updateSequenceArray[read - 1] = Util.GetUInt16(stream, _clusterStart + updateSequenceOffset + (ushort)(read * 2));
					read++;
				}

				_stream = new FixupStream(stream, _clusterStart, _entriesEnd, updateSequenceNumber, updateSequenceArray, (ulong)folder.BytesPerSector);

				if (_entriesEnd == _entriesStart) {
					throw new Exception("Entry size was 0");
				}
			}
 public byte ReadRegister(UInt16 adr)
 {
     switch (adr)
     {
         case 0x00:
             return (byte)((pra | ~ddra) & 0x3f | IECLines & the_cpu_1541.IECLines);
         case 0x01: return (byte)(prb | ~ddrb);
         case 0x02: return ddra;
         case 0x03: return ddrb;
         case 0x04: return (byte)ta;
         case 0x05: return (byte)(ta >> 8);
         case 0x06: return (byte)tb;
         case 0x07: return (byte)(tb >> 8);
         case 0x08: tod_halt = false; return tod_10ths;
         case 0x09: return tod_sec;
         case 0x0a: return tod_min;
         case 0x0b: tod_halt = true; return tod_hr;
         case 0x0c: return sdr;
         case 0x0d:
             {
                 byte ret = icr; // Read and clear ICR
                 icr = 0;
                 the_cpu.ClearNMI();
                 return ret;
             }
         case 0x0e: return cra;
         case 0x0f: return crb;
     }
     return 0;	// Can't happen
 }
Example #8
0
    public bool DoPosTest(string testDesc, string id, UInt16 uintA, string format, String expectedValue, NumberFormatInfo _NFI)
    {
        bool retVal = true;
        string errorDesc;

        string actualValue;

        TestLibrary.TestFramework.BeginScenario(testDesc);
        try
        {
            actualValue = uintA.ToString(format, _NFI);

            if (actualValue != expectedValue)
            {
                errorDesc =
                    string.Format("The string representation of {0} is not the value {1} as expected: actual({2})",
                    uintA, expectedValue, actualValue);
                errorDesc += "\nThe format info is \"" + ((format == null) ? "null" : format) + "\" speicifed";
                TestLibrary.TestFramework.LogError(id + "_001", errorDesc);
                retVal = false;
            }
        }
        catch (Exception e)
        {
            errorDesc = "Unexpect exception:" + e;
            errorDesc += "\nThe UInt16 integer is " + uintA + ", format info is \"" + format + "\" speicifed.";
            TestLibrary.TestFramework.LogError(id + "_002", errorDesc);
            retVal = false;
        }
        return retVal;
    }
Example #9
0
 public wnd1(EndianBinaryReader er)
     : base(er)
 {
     long basepos = er.BaseStream.Position - 0x4C;
     InflationLeft = er.ReadUInt16() / 16f;
     InflationRight = er.ReadUInt16() / 16f;
     InflationTop = er.ReadUInt16() / 16f;
     InflationBottom = er.ReadUInt16() / 16f;
     FrameSizeLeft = er.ReadUInt16();
     FrameSizeRight = er.ReadUInt16();
     FrameSizeTop = er.ReadUInt16();
     FrameSizeBottom = er.ReadUInt16();
     NrFrames = er.ReadByte();
     byte tmp = er.ReadByte();
     UseLTMaterial = (tmp & 1) == 1;
     UseVtxColorForAllWindow = (tmp & 2) == 2;
     Kind = (WindowKind)((tmp >> 2) & 3);
     DontDrawContent = (tmp & 8) == 16;
     Padding = er.ReadUInt16();
     ContentOffset = er.ReadUInt32();
     FrameOffsetTableOffset = er.ReadUInt32();
     er.BaseStream.Position = basepos + ContentOffset;
     Content = new WindowContent(er);
     er.BaseStream.Position = basepos + FrameOffsetTableOffset;
     WindowFrameOffsets = er.ReadUInt32s(NrFrames);
     WindowFrames = new WindowFrame[NrFrames];
     for (int i = 0; i < NrFrames; i++)
     {
         er.BaseStream.Position = basepos + WindowFrameOffsets[i];
         WindowFrames[i] = new WindowFrame(er);
     }
     er.BaseStream.Position = basepos + SectionSize;
 }
Example #10
0
 public Item(Creature_item CItem)
 {
     _SlotId = CItem.SlotId;
     _ModelId = CItem.ModelId;
     _EffectId = CItem.EffectId;
     _Count = 1;
 }
Example #11
0
        public static byte[] CheckCRC(List<byte> listdata)
        {
            byte[] data = ASCIItoHEX(listdata);

            UInt16[] testPtr = new UInt16[data.Length];

            for (int i = 0; i < data.Length; i++)
            {
                testPtr[i] = (UInt16)data[i];
            }

            UInt16 index;
            UInt16 crc = 0xFFFF;

            for (int i = 0; i < testPtr.Length; i++)
            {
                index = (UInt16)((crc ^ testPtr[i]) & 0x00FF);
                crc = (UInt16)(((crc >> 8) & 0x00FF) ^ CRC_TABLE[index]);
            }

            if (testPtr.Length != 0)
            {
                crc = (UInt16)(((crc & 0x00FF) << 8) | ((crc & 0xFF00) >> 8));
            }

            if (crc != 0)
                return null;
            else
                return data.Take(data.Length - 2).ToArray();
        }
Example #12
0
        public static byte[] AddCRC(byte[] data)
        {
            UInt16[] testPtr = new UInt16[data.Length];

            for (int i = 0; i < testPtr.Length; i++)
            {
                testPtr[i] = (UInt16)data[i];
            }

            UInt16 index;
            UInt16 crc = 0xffff;

            for (int i = 0; i < testPtr.Length; i++)
            {
                index = (UInt16)((crc ^ testPtr[i]) & 0x00ff);
                crc = (UInt16)(((crc >> 8) & 0x00ff) ^ CRC_TABLE[index]);
            }

            if (testPtr.Length != 0)
            {
                crc = (UInt16)(((crc & 0x00ff) << 8) | ((crc & 0xff00) >> 8));
            }

            byte[] tmp = new byte[2];
            tmp[0] = (byte)(((crc) >> 8) & 0x00ff);
            tmp[1] = (byte)((crc) & 0x00ff);

            List<byte> newdata = new List<byte>();
            newdata.AddRange(data);
            newdata.AddRange(tmp);

            return HEXtoASCII(newdata.ToArray());
        }
Example #13
0
 public OProg(byte[] data, byte[] footer, int id,int type)
 {
     this.type = type;
     this.data = data;
     this.footer = footer;
     this.id = id;
     return;
     u0=BinHelper.read_U16LE(footer, 0);
     exitsCnt=BinHelper.read_U16LE(footer, 2);
     if (type == 1)
     {
         entry=exitsCnt;
         exitsCnt = 0;
         unpack();
         return;
     }
     actorsCnt=BinHelper.read_U16LE(footer, 4);
     u6=BinHelper.read_U16LE(footer, 6);
     exits=BinHelper.read_U16LE(footer, 8);
     actors=BinHelper.read_U16LE(footer, 0x0A);
     sprites=BinHelper.read_U16LE(footer, 0x0C);
     entry=BinHelper.read_U16LE(footer, 0x0E);
     if (u0 != 0 || u6 != exits)
         throw new Exception("Unknown prog values");
     unpack();
 }
 public override byte[] GetBuffer()
 {
     crc = 0x0;
     byte[] buffer = base.GetBuffer();
     crc = CRC(buffer);
     return base.GetBuffer();
 }
 public override int HandleInterrupt()
 {
     switch (AttachedCPU.A) {
         case 0:
             mBuffer.Clear();
             break;
         case 1:
             lock (mBuffer) {
                 if (mBuffer.Count != 0)
                     AttachedCPU.C = mBuffer.Dequeue();
                 else
                     AttachedCPU.C = 0;
             }
             break;
         case 2:
             lock (mActiveKeys) {
                 if (mActiveKeys.Contains(AttachedCPU.B))
                     AttachedCPU.C = 1;
                 else
                     AttachedCPU.C = 0;
                 break;
             }
         case 3:
             mMessage = AttachedCPU.B;
             break;
     }
     return 0;
 }
Example #16
0
        /// <summary>  
        /// 图像信息读入(+2重载)
        /// </summary>  
        /// <param name="_fileName">文件名</param>  
        /// <param name="_width">图像的宽</param>  
        /// <param name="_height">图像的高</param> 
        /// <param name="_useless">无用字符消除</param>
        /// <param name="_front">首行缩进</param>  
        /// <param name="_behind">尾行缩进</param>  
        /// <param name="_needDecode">需要解码</param>
        /// <returns>得到的byte数组</returns>   
        public static byte[] Readin(String _fileName, UInt16 _width, UInt16 _height, UInt16 _useless, UInt16 _front, UInt16 _behind, Boolean _needDecode)
        {
            try
            {
                // Create an instance of StreamReader to read from a file.
                // The using statement also closes the StreamReader.
                using (StreamReader sr = new StreamReader(_fileName))
                {
                    String line, info = "";
                    // Read and display lines from the file until the end of
                    // the file is reached.
                    while ((line = sr.ReadLine()) != null)
                    {
                        if (_useless != 0)
                        {
                            _useless--;
                        }
                        else
                        {
                            info += UsefulReadout(line, _front, _behind) + " ";
                        }

                    }
                    return ConvertInfo(info, _width, _height, _needDecode);
                }
            }
            catch (Exception e)
            {
                // Let the user know what went wrong.
                MessageSender.e = e;
                return new byte[1];
            }
        }
        public TelemetryPacket(String telemetry)
        {
            isPayload = checkIfFromPayload(telemetry); // This should be done first before conversions

            temperature = getShortInt(telemetry.Substring(TEMPERATURE_IDX, 4)) * 0.1; // unvonverted temp is in 0.1 celsious
            altitude = getShortInt(telemetry.Substring(ALT_IDX, 4))*0.1; // Altitude expected is in 100m's
            missionTime = getUShortInt(telemetry.Substring(MISSION_TIME_IDx, 4));
            packetCount = getUShortInt(telemetry.Substring(PACKET_COUNT_IDX, 4));
            batVoltage = getShortInt(telemetry.Substring(SOURCE_VOLT_IDX,4));

            lux = getUnsignedShortInt(telemetry.Substring(LUM_IDX,4))*16;

            payloadDeployed = telemetry.Substring(PAYLOAD_DEPLOYED_IDX, 1) == "F";
            umbrellaDeployed = telemetry.Substring(UMBRELLA_DEPLOYED_IDX, 1) == "F";

            packetArray = new String[] {
                TEAM_ID,
                packetCount.ToString(),
                missionTime.ToString(),
                altitude.ToString("F1"),
                temperature.ToString("F1"),
                batVoltage.ToString("F1"),
                lux.ToString()
            };

            packetString = String.Join(",",packetArray);
        }
Example #18
0
        public CalibratedThermalFrame ProcessFrame(ThermalFrame calibrationFrame)
        {
            UInt16[] output = new UInt16[Width * Height];

            for(int i=0;i<output.Length;i++)
            {
                int v = BitConverter.ToUInt16(RawData, i * 2);
                int c = BitConverter.ToUInt16(calibrationFrame.RawData, i * 2);

                if (v < 0x800)
                {
                    // Dead pixel, clamp it to zero.
                    v = 0;
                }
                else
                {
                    v = v - c + 0x8000;
                    if (v < 0) v = 0;
                    if (v > 0xFFFF) v = 0xFFFF;
                }
                output[i] = (UInt16)v;
           
            }
            return new CalibratedThermalFrame(output);
        }
Example #19
0
 public static UInt16 GetBigEndian(UInt16 value) {
     if (BitConverter.IsLittleEndian) {
         return swapByteOrder(value);
     } else {
         return value;
     }
 }
 public SensorInfo(RiftSharp.Win32Usb.HidCaps caps, UInt16 vendor, UInt16 product, string serial)
 {
     this.Capabilities = caps;
     this.VendorId = vendor;
     this.ProductId = product;
     this.SerialNumber = serial;
 }
Example #21
0
 /// <summary>
 /// See <see cref="INonIndexedPixel.SetColor"/> for more details.
 /// </summary>
 public void SetColor(Color color)
 {
     color = QuantizationHelper.ConvertAlpha(color);
     red = (UInt16) (color.R << 5);
     green = (UInt16) (color.G << 5);
     blue = (UInt16) (color.B << 5);
 }
Example #22
0
 private void button1_Click(object sender, EventArgs e)
 {
     listBox2.Visible = false;
     label6.Visible = false;
     label7.Visible = false;
     textBox2.Visible = false;
     try
     {
         vec = UInt16.Parse(vk.Text);
     }
     catch (Exception)
     {
         button2.Visible = false;
         label5.Visible = false;
         listBox1.Visible = false;
         MessageBox.Show("Некорректная длина вектора", "ErrorLength", MessageBoxButtons.OK, MessageBoxIcon.Error);
         vk.Focus();
         return;
     }
     button2.Visible = true;
     label5.Visible = true;
     listBox1.Visible = true;
     forming(ref A, vec);
     write_Vector(A, listBox1);
     button2.Focus();
 }
Example #23
0
        public Monitor(Int32[] arr, UInt16 ptr, UInt16 chars, UInt16 colPtr, UInt16 modePointer)
        {
            mem = arr;
            pointer = ptr;
            charSetPtr = chars;
            colors = new Color[16];
            modePtr = modePointer;
            for (int i = 0; i < 16; ++i) {
                colors[i] = new Color();
                colors[i].a = 1.0f;
            }
            colorPointer = colPtr;

            image = new Texture2D(256, 256, TextureFormat.ARGB32, false);
            windowPos = new Rect();
            if ((windowPos.x == 0) && (windowPos.y == 0))//windowPos is used to position the GUI window, lets set it in the center of the screen
            {
                windowPos = new Rect(Screen.width / 2, Screen.height / 2, 100, 100);
            }
            //Set all the pixels to black. If you don't do this the image contains random junk.
            for (int y = 0; y < image.height; y++) {
                for (int x = 0; x < image.width; x++) {
                    image.SetPixel(x, y, Color.black);
                }
            }
            image.Apply();
        }
Example #24
0
 public static string GetMemoryType(UInt16 t)
 {
     switch (t)
     {
         case 1:
             return "Other";
         case 2:
             return "Unknown";
         case 3:
             return "VRAM";
         case 4:
             return "DRAM";
         case 5:
             return "SRAM";
         case 6:
             return "WRAM";
         case 7:
             return "EDO RAM";
         case 8:
             return "Burst Synchronous DRAM";
         case 9:
             return "Pipelined Burst SRAM";
         case 10:
             return "CDRAM";
         case 11:
             return "3DRAM";
         case 12:
             return "SDRAM";
         case 13:
             return "SGRAM";
     }
     return "Unknown";
 }
Example #25
0
        public NetworkAddressKey(ImmutableArray<byte> IPv6Address, UInt16 Port)
        {
            this.IPv6Address = IPv6Address;
            this.Port = Port;

            this._hashCode = Port.GetHashCode() ^ new BigInteger(IPv6Address.ToArray()).GetHashCode();
        }
Example #26
0
	private void WorkOnInstanceAndLocal()
	{
		int localInt, i, j;
                for ( i = 0; i < 100; i++ )
                {
                   int index = randomNumGen.Next(0, ValueArraySize); 
		   instanceInt_1 = ValueArray[index];
                   Thread.Sleep(index);  
                   localInt = instanceInt_1; 
                   for ( j = 0; j < ValueArraySize; j++ )
                     if ( ValueArray[j] == localInt )
                          break;
                   if (j == ValueArraySize )
                     throw new Exception("WorkOnInstanceAndLocal: Atomicity of Read/Write violated - " + localInt);
                }	
		UInt16 localInt_1;
		localInt_1 = 1 + 1;
		if(localInt_1 != 2)
			throw new Exception("Loc_7453fg! Major Error here");
		localInt_1 = UInt16.MaxValue + UInt16.MinValue;
		if(localInt_1 != UInt16.MaxValue)
			throw new Exception("Loc_98745sg! Major Error here");
		localInt_1 = Int16.MaxValue * 2;
		if(localInt_1 != 65534)
			throw new Exception("Loc_3975sg! Major Error here, " + localInt_1);
		localInt_1 = UInt16.Parse("32");
		if(localInt_1 != 32)
			throw new Exception("Loc_975esg! Major Error here, " + localInt_1);
		localInt_1 = UInt16.MaxValue;
		if(localInt_1.GetHashCode() != 65535)
			throw new Exception("Loc_874325dg! Major Error here, " + localInt_1.GetHashCode());
		if(localInt_1.ToString() != "65535")
			throw new Exception("Loc_8754s! Major Error here, " + localInt_1.ToString());
	}
Example #27
0
        private static void DoNotify(NotifyEventProxy<EpoxyConnection> proxy, int requestNum, string payload, UInt16 delay)
        {
            var request = new PingRequest { Payload = payload, DelayMilliseconds = delay };
            proxy.NotifyAsync(request);

            Console.WriteLine($"P Event #{requestNum} Delay: {delay}");
        }
 public SFSDirectory(UInt16 Id)
 {
     DirectoryID = Id;
     IsRoot = false;
     SubDirectories = new List<SFSDirectory>();
     Files = new List<SFSFile>();
 }
Example #29
0
    static void test_v2(string host, UInt16 port)
    {
        var wait_response = true;

        KcpProject.v2.UdpSocket client = null;

        // 创建一个实例
        client = new KcpProject.v2.UdpSocket((byte[] buf) =>
        {
            wait_response = false;
            Console.WriteLine("recv message: {0}", System.Text.ASCIIEncoding.ASCII.GetString(buf));
        });

        // 绑定端口
        client.Connect(host, port);

        // 发送消息
        client.Send("Hello KCP.");

        // update.
        while (wait_response)
        {
            client.Update();
            System.Threading.Thread.Sleep(10);
        }
    }
Example #30
0
 public void decode()
 {
     MemoryStream stream = new MemoryStream(Data);
     BinaryReader reader = new BinaryReader(stream);
     this.NumStrings = reader.ReadUInt16();
     ReadStringOffset(reader);
 }