Exemplo n.º 1
0
        public async Task WhenALoggerWritesToTheSinkItStoresTheCorrectTypesForStructure()
        {
            var storageAccount = CloudStorageAccount.DevelopmentStorageAccount;
            var tableClient    = storageAccount.CreateCloudTableClient();
            var table          = tableClient.GetTableReference("LogEventEntity");

            await table.DeleteIfExistsAsync();

            var logger = new LoggerConfiguration()
                         .WriteTo.AzureTableStorageWithProperties(storageAccount)
                         .CreateLogger();

            var struct1 = new Struct1
            {
                IntVal    = 10,
                StringVal = "ABCDE"
            };

            var struct2 = new Struct2
            {
                DateTimeVal = new DateTime(2014, 12, 3, 17, 37, 12),
                DoubleVal   = Math.PI
            };

            var struct0 = new Struct0
            {
                Struct1Val = struct1,
                Struct2Val = struct2
            };

            logger.Information("{@Struct0}", struct0);
            var result = (await TableQueryTakeDynamicAsync(table, takeCount: 1)).First();

            Assert.Equal("Struct0 { Struct1Val: Struct1 { IntVal: 10, StringVal: \"ABCDE\" }, Struct2Val: Struct2 { DateTimeVal: 12/03/2014 17:37:12, DoubleVal: 3.14159265358979 } }", result.Properties["Struct0"].StringValue);
        }
Exemplo n.º 2
0
 public void Struct0_AllExist()
 {
     Struct0 strout = new Struct0();
       strout.xi = 1234;
       strout.xb = true;
       strout.xd = 1234.567;
       strout.xdt = new DateTime(2006, 8, 9, 10, 11, 13);
     #if !FX1_0
       strout.nxi = 5678;
       strout.nxb = true;
       strout.nxd = 2345.678;
       strout.nxdt = new DateTime(2007, 9, 10, 11, 12, 14);
       strout.nxstr = new ChildStruct(567);
     #endif
       XmlDocument xdoc = Utils.Serialize("Struct0_AllExist",
     strout, Encoding.UTF8, MappingAction.Error);
       Type parsedType, parsedArrayType;
       object obj = Utils.Parse(xdoc, typeof(Struct0), MappingAction.Error,
     out parsedType, out parsedArrayType);
       Assert.IsInstanceOfType(typeof(Struct0), obj);
       Struct0 strin = (Struct0)obj;
       Assert.AreEqual(strout.xi, strin.xi);
       Assert.AreEqual(strout.xb, strin.xb);
       Assert.AreEqual(strout.xd, strin.xd);
       Assert.AreEqual(strout.xdt, strin.xdt);
     #if !FX1_0
       Assert.AreEqual(strout.nxi, strin.nxi);
       Assert.AreEqual(strout.nxb, strin.nxb);
       Assert.AreEqual(strout.nxd, strin.nxd);
       Assert.AreEqual(strout.nxdt, strin.nxdt);
       Assert.AreEqual(((ChildStruct)strout.nxstr).x, ((ChildStruct)strin.nxstr).x);
     #endif
 }
Exemplo n.º 3
0
        private void method_1()
        {
            Struct0[] structArray2 = this.struct0_0;
            int       length       = structArray2.Length;
            int       num3         = length * 2;

            if (num3 > 0)
            {
                Struct0[] structArray = new Struct0[num3];
                int       num4        = 0;
                for (int i = 0; i < length; i++)
                {
                    string str = structArray2[i].string_0;
                    if (str != null)
                    {
                        int num6  = structArray2[i].int_0;
                        int index = num6 & (num3 - 1);
                        while (structArray[index].string_0 != null)
                        {
                            index++;
                            if (index >= num3)
                            {
                                index = 0;
                            }
                        }
                        structArray[index].string_0 = str;
                        structArray[index].int_0    = num6;
                        num4++;
                    }
                }
                this.struct0_0 = structArray;
                this.int_0     = num4;
            }
        }
Exemplo n.º 4
0
 private int method_2(ref Struct0 logFont, ref Struct1 textMetric, uint fontType, int lParam)
 {
     if ((fontType & 4U) > 0U)
     {
         bool flag = logFont.class49_0.int_4 > 600;
         if (logFont.class49_0.byte_0 == (byte)0)
         {
             if (flag)
             {
                 this.fontStyles_0.BoldAvailable = true;
             }
             else
             {
                 this.fontStyles_0.RegularAvailable = true;
             }
         }
         else if (flag)
         {
             this.fontStyles_0.BoldItalicAvailable = true;
         }
         else
         {
             this.fontStyles_0.ItalicAvailable = true;
         }
     }
     return(1);
 }
Exemplo n.º 5
0
        public void Struct0_AllExist()
        {
            var strout = new Struct0();
            strout.xi = 1234;
            strout.xb = true;
            strout.xd = 1234.567;
            strout.xdt = new DateTime(2006, 8, 9, 10, 11, 13);
            strout.nxi = 5678;
            strout.nxb = true;
            strout.nxd = 2345.678;
            strout.nxdt = new DateTime(2007, 9, 10, 11, 12, 14);
            strout.nxstr = new ChildStruct(567);

            var xdoc = Utils.Serialize(
                "Struct0_AllExist",
                strout,
                Encoding.UTF8,
                new MappingActions { NullMappingAction = NullMappingAction.Error });

            Type parsedType, parsedArrayType;
            var obj = Utils.Parse(xdoc, typeof(Struct0), MappingAction.Error, out parsedType, out parsedArrayType);
            obj.ShouldBeOfType<Struct0>();
            var strin = (Struct0)obj;
            strout.xi.ShouldBe(strin.xi);
            strout.xb.ShouldBe(strin.xb);
            strout.xd.ShouldBe(strin.xd);
            strout.xdt.ShouldBe(strin.xdt);
            strout.nxi.ShouldBe(strin.nxi);
            strout.nxb.ShouldBe(strin.nxb);
            strout.nxd.ShouldBe(strin.nxd);
            strout.nxdt.ShouldBe(strin.nxdt);
            ((ChildStruct)strout.nxstr).x.ShouldBe(((ChildStruct)strin.nxstr).x);
        }
Exemplo n.º 6
0
    // Token: 0x0600094B RID: 2379 RVA: 0x00033128 File Offset: 0x00031328
    protected bool method_4(object object_0, JsonContract jsonContract_0, object object_1, IJsonLineInfo ijsonLineInfo_0, string string_0, Exception exception_0)
    {
        ErrorContext errorContext = this.method_2(object_0, object_1, string_0, exception_0);

        if (this.itraceWriter_0 != null && this.itraceWriter_0.LevelFilter >= TraceLevel.Error && !errorContext.method_0())
        {
            errorContext.method_1(true);
            string text = (base.GetType() == typeof(Class119)) ? "Error serializing" : "Error deserializing";
            if (jsonContract_0 != null)
            {
                text = text + " " + jsonContract_0.UnderlyingType;
            }
            text = text + ". " + exception_0.Message;
            if (!(exception_0 is JsonException))
            {
                text = Struct0.smethod_1(ijsonLineInfo_0, string_0, text);
            }
            this.itraceWriter_0.Trace(TraceLevel.Error, text, exception_0);
        }
        if (jsonContract_0 != null && object_0 != null)
        {
            jsonContract_0.method_4(object_0, this.jsonSerializer_0.Context, errorContext);
        }
        if (!errorContext.Handled)
        {
            this.jsonSerializer_0.method_6(new ErrorEventArgs(object_0, errorContext));
        }
        return(errorContext.Handled);
    }
Exemplo n.º 7
0
        public void Struct0_AllExist()
        {
            var strout = new Struct0();

            strout.xi  = 1234;
            strout.xb  = true;
            strout.xd  = 1234.567;
            strout.xdt = new DateTime(2006, 8, 9, 10, 11, 13);
#if !FX1_0
            strout.nxi   = 5678;
            strout.nxb   = true;
            strout.nxd   = 2345.678;
            strout.nxdt  = new DateTime(2007, 9, 10, 11, 12, 14);
            strout.nxstr = new ChildStruct(567);
#endif
            var xdoc = Utils.Serialize("Struct0_AllExist",
                                       strout, Encoding.UTF8, MappingAction.Error);
            Type parsedType, parsedArrayType;
            var  obj = Utils.Parse(xdoc, typeof(Struct0), MappingAction.Error,
                                   out parsedType, out parsedArrayType);
            Assert.IsInstanceOf <Struct0>(obj);
            var strin = (Struct0)obj;
            Assert.AreEqual(strout.xi, strin.xi);
            Assert.AreEqual(strout.xb, strin.xb);
            Assert.AreEqual(strout.xd, strin.xd);
            Assert.AreEqual(strout.xdt, strin.xdt);
#if !FX1_0
            Assert.AreEqual(strout.nxi, strin.nxi);
            Assert.AreEqual(strout.nxb, strin.nxb);
            Assert.AreEqual(strout.nxd, strin.nxd);
            Assert.AreEqual(strout.nxdt, strin.nxdt);
            Assert.AreEqual(((ChildStruct)strout.nxstr).x, ((ChildStruct)strin.nxstr).x);
#endif
        }
Exemplo n.º 8
0
    private static bool smethod_2(int int_1, string string_0, out string string_1)
    {
        bool flag;

        string_1 = "";
        IntPtr zero = IntPtr.Zero;

        try
        {
            string  s       = "20110401";
            Enum2   sUCCESS = Enum2.SUCCESS;
            Struct1 struct2 = new Struct1();
            sUCCESS = (Enum2)SDog.LIV_get_software_info(ref struct2);
            sUCCESS = (Enum2)SDog.LIV_open(0, int_1, ref zero);
            if (sUCCESS != Enum2.SUCCESS)
            {
                throw new Exception("打开加密狗失败! " + sUCCESS.ToString());
            }
            Struct0 struct3 = new Struct0();
            sUCCESS = (Enum2)SDog.LIV_get_hardware_info(zero, ref struct3);
            if (sUCCESS != Enum2.SUCCESS)
            {
                throw new Exception("获取加密狗信息失败! " + sUCCESS.ToString());
            }
            if (SDog.LIV_passwd(zero, 1, Encoding.UTF8.GetBytes(s)) != 0)
            {
                throw new Exception("加密狗信息无法验证! ");
            }
            byte[] buffer = new byte[0x200];
            if (SDog.LIV_read(zero, 0, buffer) != 0)
            {
                throw new Exception("从加密狗读取数据失败! ");
            }
            string str2  = Encoding.UTF8.GetString(buffer);
            int    index = str2.IndexOf('\0');
            str2 = str2.Substring(0, index);
            if (string_0 != str2.Trim())
            {
                throw new Exception("加密狗授权验证失败! ");
            }
            flag = true;
        }
        catch (Exception exception)
        {
            string_1 = exception.Message;
            flag     = false;
        }
        finally
        {
            try
            {
                SDog.LIV_close(zero);
            }
            catch
            {
            }
        }
        return(flag);
    }
Exemplo n.º 9
0
 // Token: 0x06000996 RID: 2454 RVA: 0x0003723C File Offset: 0x0003543C
 private void method_18(JsonWriter jsonWriter_0, JsonContract jsonContract_0, object object_0)
 {
     if (this.itraceWriter_0 != null && this.itraceWriter_0.LevelFilter >= TraceLevel.Info)
     {
         this.itraceWriter_0.Trace(TraceLevel.Info, Struct0.smethod_1(null, jsonWriter_0.Path, "Finished serializing {0}".smethod_0(CultureInfo.InvariantCulture, jsonContract_0.UnderlyingType)), null);
     }
     jsonContract_0.method_1(object_0, this.jsonSerializer_0.streamingContext_0);
 }
Exemplo n.º 10
0
    // Token: 0x0600099C RID: 2460 RVA: 0x0003774C File Offset: 0x0003594C
    private void method_24(JsonWriter jsonWriter_0, Type type_1)
    {
        string text = Class90.smethod_4(type_1, this.jsonSerializer_0.typeNameAssemblyFormatHandling_0, this.jsonSerializer_0.ginterface2_0);

        if (this.itraceWriter_0 != null && this.itraceWriter_0.LevelFilter >= TraceLevel.Verbose)
        {
            this.itraceWriter_0.Trace(TraceLevel.Verbose, Struct0.smethod_1(null, jsonWriter_0.Path, "Writing type name '{0}' for {1}.".smethod_1(CultureInfo.InvariantCulture, text, type_1)), null);
        }
        jsonWriter_0.WritePropertyName("$type", false);
        jsonWriter_0.WriteValue(text);
    }
Exemplo n.º 11
0
    // Token: 0x0600099B RID: 2459 RVA: 0x000376E0 File Offset: 0x000358E0
    private void method_23(JsonWriter jsonWriter_0, Type type_1, object object_0)
    {
        string text = this.method_15(jsonWriter_0, object_0);

        if (this.itraceWriter_0 != null && this.itraceWriter_0.LevelFilter >= TraceLevel.Verbose)
        {
            this.itraceWriter_0.Trace(TraceLevel.Verbose, Struct0.smethod_1(null, jsonWriter_0.Path, "Writing object reference Id '{0}' for {1}.".smethod_1(CultureInfo.InvariantCulture, text, type_1)), null);
        }
        jsonWriter_0.WritePropertyName("$id", false);
        jsonWriter_0.WriteValue(text);
    }
Exemplo n.º 12
0
    // Token: 0x06000990 RID: 2448 RVA: 0x00036EF0 File Offset: 0x000350F0
    private bool method_13(JsonWriter jsonWriter_0, object object_0, JsonProperty jsonProperty_0, JsonContract jsonContract_0, JsonContainerContract jsonContainerContract_0, JsonProperty jsonProperty_1)
    {
        if (object_0 != null && jsonContract_0.enum8_0 != (Enum8)3)
        {
            if (jsonContract_0.enum8_0 != (Enum8)4)
            {
                ReferenceLoopHandling?referenceLoopHandling = null;
                if (jsonProperty_0 != null)
                {
                    referenceLoopHandling = jsonProperty_0.ReferenceLoopHandling;
                }
                if (referenceLoopHandling == null && jsonProperty_1 != null)
                {
                    referenceLoopHandling = jsonProperty_1.ItemReferenceLoopHandling;
                }
                if (referenceLoopHandling == null && jsonContainerContract_0 != null)
                {
                    referenceLoopHandling = jsonContainerContract_0.ItemReferenceLoopHandling;
                }
                if ((this.jsonSerializer_0.iequalityComparer_0 != null) ? this.list_0.smethod_10(object_0, this.jsonSerializer_0.iequalityComparer_0) : this.list_0.Contains(object_0))
                {
                    string text = "Self referencing loop detected";
                    if (jsonProperty_0 != null)
                    {
                        text += " for property '{0}'".smethod_0(CultureInfo.InvariantCulture, jsonProperty_0.PropertyName);
                    }
                    text += " with type '{0}'.".smethod_0(CultureInfo.InvariantCulture, object_0.GetType());
                    switch (referenceLoopHandling.GetValueOrDefault(this.jsonSerializer_0.referenceLoopHandling_0))
                    {
                    case ReferenceLoopHandling.Error:
                        throw JsonSerializationException.Create(null, jsonWriter_0.xEuXaafal7(), text, null);

                    case ReferenceLoopHandling.Ignore:
                        if (this.itraceWriter_0 != null && this.itraceWriter_0.LevelFilter >= TraceLevel.Verbose)
                        {
                            this.itraceWriter_0.Trace(TraceLevel.Verbose, Struct0.smethod_1(null, jsonWriter_0.Path, text + ". Skipping serializing self referenced value."), null);
                        }
                        return(false);

                    case ReferenceLoopHandling.Serialize:
                        if (this.itraceWriter_0 != null && this.itraceWriter_0.LevelFilter >= TraceLevel.Verbose)
                        {
                            this.itraceWriter_0.Trace(TraceLevel.Verbose, Struct0.smethod_1(null, jsonWriter_0.Path, text + ". Serializing self referenced value."), null);
                        }
                        return(true);
                    }
                }
                return(true);
            }
        }
        return(true);
    }
Exemplo n.º 13
0
    // Token: 0x06000991 RID: 2449 RVA: 0x00037088 File Offset: 0x00035288
    private void method_14(JsonWriter jsonWriter_0, object object_0)
    {
        string text = this.method_15(jsonWriter_0, object_0);

        if (this.itraceWriter_0 != null && this.itraceWriter_0.LevelFilter >= TraceLevel.Info)
        {
            this.itraceWriter_0.Trace(TraceLevel.Info, Struct0.smethod_1(null, jsonWriter_0.Path, "Writing object reference to Id '{0}' for {1}.".smethod_1(CultureInfo.InvariantCulture, text, object_0.GetType())), null);
        }
        jsonWriter_0.WriteStartObject();
        jsonWriter_0.WritePropertyName("$ref", false);
        jsonWriter_0.WriteValue(text);
        jsonWriter_0.WriteEndObject();
    }
Exemplo n.º 14
0
 public void method_0(string string_0, string string_1)
 {
     this.struct0_0        = new Struct0();
     this.struct0_0.uint_0 = (uint)Marshal.SizeOf(this.struct0_0.GetType());
     if (FindWindow(string_0, string_1) == IntPtr.Zero)
     {
         throw new Exception("Failed to find an AppBar that matched the given criteria");
     }
     if (SHAppBarMessage(5, ref this.struct0_0) != 1)
     {
         throw new Exception("Failed to communicate with the given AppBar");
     }
 }
Exemplo n.º 15
0
        public static bool Write(IWriter writer, Struct0 val, string name = null)
        {
            if (!writer.StructBegin(Struct0.HASH_CODE, name))
            {
                return(false);
            }

            DoWrite(writer, val.s0a, "s0a", Write);
            DoWrite(writer, val.s0b, "s0b", Write);
            DoWrite(writer, val.s0c, "s0c", Write);

            return(writer.StructEnd());
        }
Exemplo n.º 16
0
        public static bool Read(IReader reader, ref Struct0 val, string name = null)
        {
            if (!reader.StructBegin(Struct0.HASH_CODE, name))
            {
                return(false);
            }

            DoRead(reader, ref val.s0a, "s0a", Read);
            DoRead(reader, ref val.s0b, "s0b", Read);
            DoRead(reader, ref val.s0c, "s0c", Read);

            return(reader.StructEnd());
        }
Exemplo n.º 17
0
    // Token: 0x060009AC RID: 2476 RVA: 0x00038470 File Offset: 0x00036670
    private bool ShouldSerialize(JsonWriter writer, JsonProperty property, object target)
    {
        if (property.ShouldSerialize == null)
        {
            return(true);
        }
        bool flag = property.ShouldSerialize(target);

        if (this.itraceWriter_0 != null && this.itraceWriter_0.LevelFilter >= TraceLevel.Verbose)
        {
            this.itraceWriter_0.Trace(TraceLevel.Verbose, Struct0.smethod_1(null, writer.Path, "ShouldSerialize result for property '{0}' on {1}: {2}".smethod_2(CultureInfo.InvariantCulture, property.PropertyName, property.DeclaringType, flag)), null);
        }
        return(flag);
    }
Exemplo n.º 18
0
    // Token: 0x060009AD RID: 2477 RVA: 0x000384E8 File Offset: 0x000366E8
    private bool method_40(JsonWriter jsonWriter_0, JsonProperty jsonProperty_0, object object_0)
    {
        if (jsonProperty_0.GetIsSpecified == null)
        {
            return(true);
        }
        bool flag = jsonProperty_0.GetIsSpecified(object_0);

        if (this.itraceWriter_0 != null && this.itraceWriter_0.LevelFilter >= TraceLevel.Verbose)
        {
            this.itraceWriter_0.Trace(TraceLevel.Verbose, Struct0.smethod_1(null, jsonWriter_0.Path, "IsSpecified result for property '{0}' on {1}: {2}".smethod_2(CultureInfo.InvariantCulture, jsonProperty_0.PropertyName, jsonProperty_0.DeclaringType, flag)), null);
        }
        return(flag);
    }
Exemplo n.º 19
0
        private static HardDiskInfo smethod_1(byte byte_0)
        {
            Struct0 struct2 = new Struct0();
            Struct2 struct3 = new Struct2();
            Struct4 struct4 = new Struct4();
            uint    num     = 0;
            IntPtr  ptr     = CreateFile(@"\\.\Smartvsd", 0, 0, IntPtr.Zero, 1, 0, IntPtr.Zero);

            if (ptr == IntPtr.Zero)
            {
                throw new Exception("Open   smartvsd.vxd   failed.");
            }
            if (DeviceIoControl(ptr, 0x74080, IntPtr.Zero, 0, ref struct2, (uint)Marshal.SizeOf(struct2), ref num, IntPtr.Zero) == 0)
            {
                CloseHandle(ptr);
                throw new Exception("DeviceIoControl   failed:DFP_GET_VERSION");
            }
            if ((struct2.uint_0 & 1) == 0)
            {
                CloseHandle(ptr);
                throw new Exception("Error:   IDE   identify   command   not   supported.");
            }
            if ((byte_0 & 1) != 0)
            {
                struct3.struct1_0.byte_5 = 0xb0;
            }
            else
            {
                struct3.struct1_0.byte_5 = 160;
            }
            if ((struct2.uint_0 & (((int)0x10) >> byte_0)) != 0)
            {
                CloseHandle(ptr);
                throw new Exception($"Drive   {byte_0 + 1}   is   a   ATAPI   device,   we   don't   detect   it");
            }
            struct3.struct1_0.byte_6 = 0xec;
            struct3.byte_0           = byte_0;
            struct3.struct1_0.byte_1 = 1;
            struct3.struct1_0.byte_2 = 1;
            struct3.uint_0           = 0x200;
            if (DeviceIoControl_1(ptr, 0x7c088, ref struct3, (uint)Marshal.SizeOf(struct3), ref struct4, (uint)Marshal.SizeOf(struct4), ref num, IntPtr.Zero) == 0)
            {
                CloseHandle(ptr);
                throw new Exception("DeviceIoControl   failed:   DFP_RECEIVE_DRIVE_DATA");
            }
            CloseHandle(ptr);
            return(smethod_3(struct4.struct5_0));
        }
Exemplo n.º 20
0
        public void Struct0_AllExist()
        {
            var strout = new Struct0();

            strout.xi    = 1234;
            strout.xb    = true;
            strout.xd    = 1234.567;
            strout.xdt   = new DateTime(2006, 8, 9, 10, 11, 13);
            strout.nxi   = 5678;
            strout.nxb   = true;
            strout.nxd   = 2345.678;
            strout.nxdt  = new DateTime(2007, 9, 10, 11, 12, 14);
            strout.nxstr = new ChildStruct(567);

            var xdoc = Utils.Serialize(
                "Struct0_AllExist",
                strout,
                Encoding.UTF8,
                new MappingActions {
                NullMappingAction = NullMappingAction.Error
            });

            Type parsedType, parsedArrayType;
            var  obj = Utils.Parse(xdoc, typeof(Struct0), MappingAction.Error, out parsedType, out parsedArrayType);

            obj.ShouldBeOfType <Struct0>();
            var strin = (Struct0)obj;

            strout.xi.ShouldBe(strin.xi);
            strout.xb.ShouldBe(strin.xb);
            strout.xd.ShouldBe(strin.xd);
            strout.xdt.ShouldBe(strin.xdt);
            strout.nxi.ShouldBe(strin.nxi);
            strout.nxb.ShouldBe(strin.nxb);
            strout.nxd.ShouldBe(strin.nxd);
            strout.nxdt.ShouldBe(strin.nxdt);
            ((ChildStruct)strout.nxstr).x.ShouldBe(((ChildStruct)strin.nxstr).x);
        }
Exemplo n.º 21
0
 // Token: 0x060009A0 RID: 2464 RVA: 0x000377CC File Offset: 0x000359CC
 private void method_28(JsonWriter jsonWriter_0, JsonConverter jsonConverter_0, object object_0, JsonContract jsonContract_0, JsonContainerContract jsonContainerContract_0, JsonProperty jsonProperty_0)
 {
     if (this.method_11(object_0, null, jsonContract_0, jsonContainerContract_0, jsonProperty_0))
     {
         this.method_14(jsonWriter_0, object_0);
         return;
     }
     if (!this.method_13(jsonWriter_0, object_0, null, jsonContract_0, jsonContainerContract_0, jsonProperty_0))
     {
         return;
     }
     this.list_0.Add(object_0);
     if (this.itraceWriter_0 != null && this.itraceWriter_0.LevelFilter >= TraceLevel.Info)
     {
         this.itraceWriter_0.Trace(TraceLevel.Info, Struct0.smethod_1(null, jsonWriter_0.Path, "Started serializing {0} with converter {1}.".smethod_1(CultureInfo.InvariantCulture, object_0.GetType(), jsonConverter_0.GetType())), null);
     }
     jsonConverter_0.WriteJson(jsonWriter_0, object_0, this.method_6());
     if (this.itraceWriter_0 != null && this.itraceWriter_0.LevelFilter >= TraceLevel.Info)
     {
         this.itraceWriter_0.Trace(TraceLevel.Info, Struct0.smethod_1(null, jsonWriter_0.Path, "Finished serializing {0} with converter {1}.".smethod_1(CultureInfo.InvariantCulture, object_0.GetType(), jsonConverter_0.GetType())), null);
     }
     this.list_0.RemoveAt(this.list_0.Count - 1);
 }
Exemplo n.º 22
0
        private PhysicalDisk method_4(string string_1)
        {
            PhysicalDisk disk = new PhysicalDisk {
                Extents      = new VOLUMEDISKEXTENTS(),
                Adapter      = new STORAGE_ADAPTER_DESCRIPTOR(),
                DeviceID     = new STORAGE_DEVICE_ID_DESCRIPTOR(),
                Device       = new STORAGE_DEVICE_DESCRIPTOR(),
                Version      = new GETVERSIONOUTPARAMS(),
                Params       = new SENDCMDOUTPARAMS(),
                SerialNumber = string.Empty,
                Firmware     = string.Empty,
                Model        = string.Empty
            };

            char[]         trimChars = new char[] { '\\' };
            SafeFileHandle handle    = Class1.CreateFileW(Class3.smethod_10(0) + Path.GetPathRoot(string_1).TrimEnd(trimChars), 0xc0000000, 3, IntPtr.Zero, 3, 0x80, IntPtr.Zero);

            try
            {
                uint    num     = 0;
                int     cb      = Marshal.SizeOf(disk.Extents);
                IntPtr  ptr     = Marshal.AllocHGlobal(cb);
                Struct0 struct2 = new Struct0();
                uint    num3    = this.method_0(0x56, 0, 0, 0);
                if (Class1.DeviceIoControl_1(handle, num3, IntPtr.Zero, 0, ptr, cb, ref num, 0))
                {
                    disk.Extents = (VOLUMEDISKEXTENTS)Marshal.PtrToStructure(ptr, typeof(VOLUMEDISKEXTENTS));
                    disk.Number  = Convert.ToByte(disk.Extents.diskNumber);
                }
                cb             = Marshal.SizeOf(disk.Adapter);
                ptr            = Marshal.AllocHGlobal(cb);
                struct2.uint_0 = 1;
                struct2.uint_1 = 0;
                if (Class1.DeviceIoControl(handle, 0x2d1400, struct2, Marshal.SizeOf(struct2), ptr, cb, ref num, 0))
                {
                    disk.Adapter = (STORAGE_ADAPTER_DESCRIPTOR)Marshal.PtrToStructure(ptr, typeof(STORAGE_ADAPTER_DESCRIPTOR));
                }
                cb             = Marshal.SizeOf(disk.DeviceID);
                ptr            = Marshal.AllocHGlobal(cb);
                struct2.uint_0 = 2;
                struct2.uint_1 = 0;
                if (Class1.DeviceIoControl(handle, 0x2d1400, struct2, Marshal.SizeOf(struct2), ptr, cb, ref num, 0))
                {
                    disk.DeviceID = (STORAGE_DEVICE_ID_DESCRIPTOR)Marshal.PtrToStructure(ptr, typeof(STORAGE_DEVICE_ID_DESCRIPTOR));
                }
                cb             = Marshal.SizeOf(disk.Device);
                ptr            = Marshal.AllocHGlobal(cb);
                struct2.uint_0 = 0;
                struct2.uint_1 = 0;
                if (Class1.DeviceIoControl(handle, 0x2d1400, struct2, Marshal.SizeOf(struct2), ptr, cb, ref num, 0))
                {
                    disk.Device = (STORAGE_DEVICE_DESCRIPTOR)Marshal.PtrToStructure(ptr, typeof(STORAGE_DEVICE_DESCRIPTOR));
                    string str2 = Encoding.ASCII.GetString(disk.Device.RawDeviceProperties);
                    int    num4 = Marshal.SizeOf(disk.Device) - disk.Device.RawDeviceProperties.Length;
                    if (disk.Device.ProductIdOffset > 0)
                    {
                        char[] chArray2 = new char[2];
                        chArray2[1] = ' ';
                        disk.Model  = str2.Substring(disk.Device.ProductIdOffset - num4, 20).Trim(chArray2);
                    }
                    if (disk.Device.ProductRevisionOffset > 0)
                    {
                        char[] chArray3 = new char[2];
                        chArray3[1]   = ' ';
                        disk.Firmware = str2.Substring(disk.Device.ProductRevisionOffset - num4, 8).Trim(chArray3);
                    }
                    if (disk.Device.SerialNumberOffset > 0)
                    {
                        char[] chArray4 = new char[2];
                        chArray4[1]       = ' ';
                        disk.SerialNumber = str2.Substring(disk.Device.SerialNumberOffset - num4, 40).Trim(chArray4);
                    }
                    if ((disk.SerialNumber != null) && (disk.SerialNumber.Length == 40))
                    {
                        disk.SerialNumber = this.method_3(disk.SerialNumber);
                    }
                    disk.RemovableMedia = Convert.ToBoolean(disk.Device.RemovableMedia);
                }
                cb  = Marshal.SizeOf(disk.Version);
                ptr = Marshal.AllocHGlobal(cb);
                if (Class1.DeviceIoControl_1(handle, 0x74080, IntPtr.Zero, 0, ptr, cb, ref num, 0))
                {
                    disk.Version = (GETVERSIONOUTPARAMS)Marshal.PtrToStructure(ptr, typeof(GETVERSIONOUTPARAMS));
                    if ((disk.Version.fCapabilities & 4L) > 0L)
                    {
                        SENDCMDINPARAMS sendcmdinparams = new SENDCMDINPARAMS();
                        sendcmdinparams.DriveRegs.Command = 0xec;
                        sendcmdinparams.DriveNumber       = disk.Number;
                        sendcmdinparams.BufferSize        = 0x200;
                        if (Class1.DeviceIoControl(handle, 0x7c088, sendcmdinparams, Marshal.SizeOf(sendcmdinparams), ptr, cb, ref num, 0))
                        {
                            disk.Params       = (SENDCMDOUTPARAMS)Marshal.PtrToStructure(ptr, typeof(SENDCMDOUTPARAMS));
                            disk.Model        = this.method_2(disk.Params.IDS.ModelNumber).Trim();
                            disk.Firmware     = this.method_2(disk.Params.IDS.FirmwareRevision).Trim();
                            disk.SerialNumber = this.method_2(disk.Params.IDS.SerialNumber).Trim();
                        }
                    }
                }
            }
            catch (Exception)
            {
            }
            finally
            {
                if (handle != null)
                {
                    handle.Dispose();
                }
            }
            return(disk);
        }
Exemplo n.º 23
0
 internal static extern int LIV_get_hardware_info(IntPtr intptr_0, ref Struct0 struct0_0);
		public void WhenALoggerWritesToTheSinkItStoresTheCorrectTypesForStructure()
		{
			var storageAccount = CloudStorageAccount.DevelopmentStorageAccount;
			var tableClient = storageAccount.CreateCloudTableClient();
			var table = tableClient.GetTableReference("LogEventEntity");

			table.DeleteIfExists();

			var logger = new LoggerConfiguration()
				.WriteTo.AzureTableStorageWithProperties(storageAccount)
				.CreateLogger();

			var struct1 = new Struct1
			{
				IntVal = 10,
				StringVal = "ABCDE"
			};

			var struct2 = new Struct2
			{
				DateTimeVal = new DateTime(2014, 12, 3, 17, 37, 12),
				DoubleVal = Math.PI
			};

			var struct0 = new Struct0
			{
				Struct1Val = struct1,
				Struct2Val = struct2
			};

			logger.Information("{@Struct0}", struct0);
			var result = table.ExecuteQuery(new TableQuery().Take(1)).First();

			Assert.AreEqual("Struct0 { Struct1Val: Struct1 { IntVal: 10, StringVal: \"ABCDE\" }, Struct2Val: Struct2 { DateTimeVal: 12/03/2014 17:37:12, DoubleVal: 3.14159265358979 } }", result.Properties["Struct0"].StringValue);
		}
Exemplo n.º 25
0
 private static extern int DeviceIoControl(IntPtr intptr_0, uint uint_9, IntPtr intptr_1, uint uint_10, ref Struct0 struct0_0, uint uint_11, ref uint uint_12, [Out] IntPtr intptr_2);
Exemplo n.º 26
0
 private static extern uint SHAppBarMessage(uint uint_1, ref Struct0 struct0_1);