示例#1
0
 /// <summary
 /// To json
 /// </summary>
 public JObject ToJson()
 {
     return(new JObject
     {
         ["groups"] = Groups.Select(u => u.ToJson()).ToArray(),
         ["supportedstandards"] = SupportedStandards.Select(u => new JString(u)).ToArray(),
         ["abi"] = Abi.ToJson(),
         ["permissions"] = Permissions.Select(p => p.ToJson()).ToArray(),
         ["trusts"] = Trusts.ToJson(),
         ["safemethods"] = SafeMethods.ToJson(),
         ["extra"] = Extra
     });
 }
示例#2
0
 /// <summary
 /// To json
 /// </summary>
 public JObject ToJson()
 {
     return(new JObject
     {
         ["groups"] = Groups.Select(u => u.ToJson()).ToArray(),
         ["features"] = new JObject
         {
             ["storage"] = Features.HasFlag(ContractFeatures.HasStorage),
             ["payable"] = Features.HasFlag(ContractFeatures.Payable)
         },
         ["supportedstandards"] = SupportedStandards.Select(u => new JString(u)).ToArray(),
         ["abi"] = Abi.ToJson(),
         ["permissions"] = Permissions.Select(p => p.ToJson()).ToArray(),
         ["trusts"] = Trusts.ToJson(),
         ["safemethods"] = SafeMethods.ToJson(),
         ["extra"] = Extra
     });
 }
示例#3
0
        /// <summary
        /// To json
        /// </summary>
        public JObject ToJson()
        {
            var feature = new JObject();

            feature["storage"] = Features.HasFlag(ContractFeatures.HasStorage);
            feature["payable"] = Features.HasFlag(ContractFeatures.Payable);

            var json = new JObject();

            json["groups"]      = new JArray(Groups.Select(u => u.ToJson()).ToArray());
            json["features"]    = feature;
            json["abi"]         = Abi.ToJson();
            json["permissions"] = Permissions.Select(p => p.ToJson()).ToArray();
            json["trusts"]      = Trusts.ToJson();
            json["safeMethods"] = SafeMethods.ToJson();
            json["extra"]       = Extra;

            return(json);
        }
        static void Main(string[] args)
        {
            Console.WriteLine("cs-hid-mouse");
            bool waitLocalHost = true;

            if (args.Length >= 1)
            {
                if (args[0] == "-w")
                {
                    waitLocalHost = false;
                }
            }

            int cxScreen = SafeMethods.GetSystemMetrics(SystemMetric.SM_CXVIRTUALSCREEN);
            int cyScreen = SafeMethods.GetSystemMetrics(SystemMetric.SM_CYVIRTUALSCREEN);

            Console.WriteLine($"CX: {cxScreen}");
            Console.WriteLine($"CY: {cyScreen}");

            // byte[] reportBuffer = MouseDescriptors.RelativeReport;
            // Usbip device = new Usbip(MouseDescriptors.Device, MouseDescriptors.RelativeHid, reportBuffer);

            // byte[] reportBuffer = MouseDescriptors.AbsoluteReport;
            // Usbip device = new Usbip(MouseDescriptors.Device, MouseDescriptors.AbsoluteHid, reportBuffer);

            byte[] reportBuffer = MouseDescriptors.AbsoluteAndRelativeReport;
            using (Usbip device = new Usbip(UsbDescriptors.Device, MouseDescriptors.AbsoluteAndRelativeHid, reportBuffer))
            {
                MouseDevice mouse = new MouseDevice(device, reportBuffer, cxScreen, cyScreen);

                device.Run();

                if (waitLocalHost == true)
                {
                    Thread usbipServer = new Thread(usbipServer_Run);
                    usbipServer.IsBackground = true;
                    usbipServer.Start();
                }

                MouseTest(mouse);
            }
        }