public void NestedGenerics() { var input = new Nested1 <string> .Nested2 <int, bool> { Prop = Tuple.Create("1", 1, false) }; var script = CSScriptSerializer.Serialize(input); var output = CSScriptSerializer.Deserialize <Nested1 <string> .Nested2 <int, bool> >(script); Assert.Equal(input.Prop.Item1, output.Prop.Item1); Assert.Equal(input.Prop.Item2, output.Prop.Item2); Assert.Equal(input.Prop.Item3, output.Prop.Item3); }
public void NestedRecursiveGenerics() { var input = new Nested1 <string> .Nested3 { Parent = new Nested1 <string> { BaseProp = "base" } }; var script = CSScriptSerializer.Serialize(input); var output = CSScriptSerializer.Deserialize <Nested1 <string> .Nested3>(script); Assert.Equal(input.Parent.BaseProp, output.Parent.BaseProp); }
/// <summary> /// Gets sum of value1 and value2 /// by creating new thread ;) /// </summary> /// <param name="value1">First value to add</param> /// <param name="value2">Second value to add</param> /// <returns>Sum of value1 and value2</returns> public int GetSum(int value1, int value2) { Thread thread = new Thread(new ParameterizedThreadStart(Sum)); Nested1 nested1 = new Nested1 { nestedValue1 = value1, nestedValue2 = value2 }; thread.Start(nested1); Thread.Sleep(1000); return(nested1.sum); }
public void Read_properties_of_nested_types() { var model = new Nested1 { Zero = "zero", NestedModel1 = new Flat2 { First = 11, Second = "val-11" }, Third = "third", NestedModel2 = new Flat2 { First = 22, Second = "val-22" } }; var result = Read(model); result.Should().HaveCount(5); result[0].Attributes.Should().HaveCount(1); result[0].Attributes.ElementAt(0).Should().BeAssignableTo <RequiredAttribute>(); result[0].Value.Should().Be("zero"); result[0].Path.Should().BeEquivalentTo(new[] { "zero" }); result[1].Attributes.Should().HaveCount(1); result[1].Attributes.ElementAt(0).Should().BeAssignableTo <RequiredAttribute>(); result[1].Value.Should().Be(11); result[1].Path.Should().BeEquivalentTo(new[] { "nestedModel1", "first" }); result[2].Attributes.Should().HaveCount(1); result[2].Attributes.ElementAt(0).Should().BeAssignableTo <RequiredAttribute>(); result[2].Value.Should().Be("third"); result[2].Path.Should().BeEquivalentTo(new[] { "third" }); result[3].Attributes.Should().HaveCount(1); result[3].Attributes.ElementAt(0).Should().BeAssignableTo <RequiredAttribute>(); result[3].Value.Should().Be(model.NestedModel2); result[3].Path.Should().BeEquivalentTo(new[] { "nestedModel2" }); result[4].Attributes.Should().HaveCount(1); result[4].Attributes.ElementAt(0).Should().BeAssignableTo <RequiredAttribute>(); result[4].Value.Should().Be(22); result[4].Path.Should().BeEquivalentTo(new[] { "nestedModel2", "first" }); }
public Container(int nested_var) { Nested1 n1 = new Nested1(); n1.nestedVar = nested_var; }
public static void 启动() { Nested1 n1 = new Nested1(); 补语控制.执行_次(() => n1.CALL(), 3); }
static extern Nested1 EchoNested1(Nested1 value);
public bool Equals(Nested1 other) { return Field1.Equals(other.Field1) && Field2.Equals(other.Field2); }
static int Main() { var ok = true; SingleByte expectedSingleByte = SingleByte.Get(); SingleByte actualSingleByte = EchoSingleByte(expectedSingleByte); if (!expectedSingleByte.Equals(actualSingleByte)) { Console.WriteLine("EchoSingleByte failed"); ok = false; } SingleLong expectedSingleLong = SingleLong.Get(); SingleLong actualSingleLong = EchoSingleLong(expectedSingleLong); if (!expectedSingleLong.Equals(actualSingleLong)) { Console.WriteLine("EchoSingleLong failed"); ok = false; } SingleFloat expectedSingleFloat = SingleFloat.Get(); SingleFloat actualSingleFloat = EchoSingleFloat(expectedSingleFloat); if (!expectedSingleFloat.Equals(actualSingleFloat)) { Console.WriteLine("EchoSingleFloat failed"); ok = false; } SingleDouble expectedSingleDouble = SingleDouble.Get(); SingleDouble actualSingleDouble = EchoSingleDouble(expectedSingleDouble); if (!expectedSingleDouble.Equals(actualSingleDouble)) { Console.WriteLine("EchoSingleDouble failed"); ok = false; } ByteAndFloat expectedByteAndFloat = ByteAndFloat.Get(); ByteAndFloat actualByteAndFloat = EchoByteAndFloat(expectedByteAndFloat); if (!expectedByteAndFloat.Equals(actualByteAndFloat)) { Console.WriteLine("EchoByteAndFloat failed"); ok = false; } LongAndFloat expectedLongAndFloat = LongAndFloat.Get(); LongAndFloat actualLongAndFloat = EchoLongAndFloat(expectedLongAndFloat); if (!expectedLongAndFloat.Equals(actualLongAndFloat)) { Console.WriteLine("EchoLongAndFloat failed"); ok = false; } ByteAndDouble expectedByteAndDouble = ByteAndDouble.Get(); ByteAndDouble actualByteAndDouble = EchoByteAndDouble(expectedByteAndDouble); if (!expectedByteAndDouble.Equals(actualByteAndDouble)) { Console.WriteLine("EchoByteAndDouble failed"); ok = false; } DoubleAndByte expectedDoubleAndByte = DoubleAndByte.Get(); DoubleAndByte actualDoubleAndByte = EchoDoubleAndByte(expectedDoubleAndByte); if (!expectedDoubleAndByte.Equals(actualDoubleAndByte)) { Console.WriteLine("EchoDoubleAndByte failed"); ok = false; } PointerAndByte expectedPointerAndByte = PointerAndByte.Get(); PointerAndByte actualPointerAndByte = EchoPointerAndByte(expectedPointerAndByte); if (!expectedPointerAndByte.Equals(actualPointerAndByte)) { Console.WriteLine("EchoPointerAndByte failed"); ok = false; } ByteAndPointer expectedByteAndPointer = ByteAndPointer.Get(); ByteAndPointer actualByteAndPointer = EchoByteAndPointer(expectedByteAndPointer); if (!expectedByteAndPointer.Equals(actualByteAndPointer)) { Console.WriteLine("EchoByteAndPointer failed"); ok = false; } ByteFloatAndPointer expectedByteFloatAndPointer = ByteFloatAndPointer.Get(); ByteFloatAndPointer actualByteFloatAndPointer = EchoByteFloatAndPointer(expectedByteFloatAndPointer); if (!expectedByteFloatAndPointer.Equals(actualByteFloatAndPointer)) { Console.WriteLine("EchoByteFloatAndPointer failed"); ok = false; } PointerFloatAndByte expectedPointerFloatAndByte = PointerFloatAndByte.Get(); PointerFloatAndByte actualPointerFloatAndByte = EchoPointerFloatAndByte(expectedPointerFloatAndByte); if (!expectedPointerFloatAndByte.Equals(actualPointerFloatAndByte)) { Console.WriteLine("EchoPointerFloatAndByte failed"); ok = false; } TwoLongs expectedTwoLongs = TwoLongs.Get(); TwoLongs actualTwoLongs = EchoTwoLongs(expectedTwoLongs); if (!expectedTwoLongs.Equals(actualTwoLongs)) { Console.WriteLine("EchoTwoLongs failed"); ok = false; } TwoFloats expectedTwoFloats = TwoFloats.Get(); TwoFloats actualTwoFloats = EchoTwoFloats(expectedTwoFloats); if (!expectedTwoFloats.Equals(actualTwoFloats)) { Console.WriteLine("EchoTwoFloats failed"); ok = false; } TwoDoubles expectedTwoDoubles = TwoDoubles.Get(); TwoDoubles actualTwoDoubles = EchoTwoDoubles(expectedTwoDoubles); if (!expectedTwoDoubles.Equals(actualTwoDoubles)) { Console.WriteLine("EchoTwoDoubles failed"); ok = false; } FourLongs expectedFourLongs = FourLongs.Get(); FourLongs actualFourLongs = EchoFourLongs(expectedFourLongs); if (!expectedFourLongs.Equals(actualFourLongs)) { Console.WriteLine("EchoFourLongs failed"); ok = false; } FourDoubles expectedFourDoubles = FourDoubles.Get(); FourDoubles actualFourDoubles = EchoFourDoubles(expectedFourDoubles); if (!expectedFourDoubles.Equals(actualFourDoubles)) { Console.WriteLine("EchoFourDoubles failed"); ok = false; } InlineArray1 expectedInlineArray1 = InlineArray1.Get(); InlineArray1 actualInlineArray1 = EchoInlineArray1(expectedInlineArray1); if (!expectedInlineArray1.Equals(actualInlineArray1)) { Console.WriteLine("EchoInlineArray1 failed"); ok = false; } InlineArray2 expectedInlineArray2 = InlineArray2.Get(); InlineArray2 actualInlineArray2 = EchoInlineArray2(expectedInlineArray2); if (!expectedInlineArray2.Equals(actualInlineArray2)) { Console.WriteLine("EchoInlineArray2 failed"); ok = false; } InlineArray3 expectedInlineArray3 = InlineArray3.Get(); InlineArray3 actualInlineArray3 = EchoInlineArray3(expectedInlineArray3); if (!expectedInlineArray3.Equals(actualInlineArray3)) { Console.WriteLine("EchoInlineArray3 failed"); ok = false; } InlineArray4 expectedInlineArray4 = InlineArray4.Get(); InlineArray4 actualInlineArray4 = EchoInlineArray4(expectedInlineArray4); if (!expectedInlineArray4.Equals(actualInlineArray4)) { Console.WriteLine("EchoInlineArray4 failed"); ok = false; } InlineArray5 expectedInlineArray5 = InlineArray5.Get(); InlineArray5 actualInlineArray5 = EchoInlineArray5(expectedInlineArray5); if (!expectedInlineArray5.Equals(actualInlineArray5)) { Console.WriteLine("EchoInlineArray5 failed"); ok = false; } InlineArray6 expectedInlineArray6 = InlineArray6.Get(); InlineArray6 actualInlineArray6 = EchoInlineArray6(expectedInlineArray6); if (!expectedInlineArray6.Equals(actualInlineArray6)) { Console.WriteLine("EchoInlineArray6 failed"); ok = false; } Nested1 expectedNested1 = Nested1.Get(); Nested1 actualNested1 = EchoNested1(expectedNested1); if (!expectedNested1.Equals(actualNested1)) { Console.WriteLine("EchoNested1 failed"); ok = false; } Nested2 expectedNested2 = Nested2.Get(); Nested2 actualNested2 = EchoNested2(expectedNested2); if (!expectedNested2.Equals(actualNested2)) { Console.WriteLine("EchoNested2 failed"); ok = false; } Nested3 expectedNested3 = Nested3.Get(); Nested3 actualNested3 = EchoNested3(expectedNested3); if (!expectedNested3.Equals(actualNested3)) { Console.WriteLine("EchoNested3 failed"); ok = false; } Nested4 expectedNested4 = Nested4.Get(); Nested4 actualNested4 = EchoNested4(expectedNested4); if (!expectedNested4.Equals(actualNested4)) { Console.WriteLine("EchoNested4 failed"); ok = false; } Nested5 expectedNested5 = Nested5.Get(); Nested5 actualNested5 = EchoNested5(expectedNested5); if (!expectedNested5.Equals(actualNested5)) { Console.WriteLine("EchoNested5 failed"); ok = false; } Nested6 expectedNested6 = Nested6.Get(); Nested6 actualNested6 = EchoNested6(expectedNested6); if (!expectedNested6.Equals(actualNested6)) { Console.WriteLine("EchoNested6 failed"); ok = false; } Nested7 expectedNested7 = Nested7.Get(); Nested7 actualNested7 = EchoNested7(expectedNested7); if (!expectedNested7.Equals(actualNested7)) { Console.WriteLine("EchoNested7 failed"); ok = false; } Nested8 expectedNested8 = Nested8.Get(); Nested8 actualNested8 = EchoNested8(expectedNested8); if (!expectedNested8.Equals(actualNested8)) { Console.WriteLine("EchoNested8 failed"); ok = false; } Nested9 expectedNested9 = Nested9.Get(); Nested9 actualNested9 = EchoNested9(expectedNested9); if (!expectedNested9.Equals(actualNested9)) { Console.WriteLine("EchoNested9 failed"); ok = false; } TwoLongs expectedNotEnoughRegistersSysV1 = TwoLongs.Get(); TwoLongs actualNotEnoughRegistersSysV1 = NotEnoughRegistersSysV1(1, 2, 3, 4, 5, 6, expectedNotEnoughRegistersSysV1); if (!expectedNotEnoughRegistersSysV1.Equals(actualNotEnoughRegistersSysV1)) { Console.WriteLine("NotEnoughRegistersSysV1 failed"); ok = false; } TwoLongs expectedNotEnoughRegistersSysV2 = TwoLongs.Get(); TwoLongs actualNotEnoughRegistersSysV2 = NotEnoughRegistersSysV2(1, 2, 3, 4, 5, expectedNotEnoughRegistersSysV2); if (!expectedNotEnoughRegistersSysV2.Equals(actualNotEnoughRegistersSysV2)) { Console.WriteLine("NotEnoughRegistersSysV2 failed"); ok = false; } DoubleAndByte expectedNotEnoughRegistersSysV3 = DoubleAndByte.Get(); DoubleAndByte actualNotEnoughRegistersSysV3 = NotEnoughRegistersSysV3(1, 2, 3, 4, 5, 6, expectedNotEnoughRegistersSysV3); if (!expectedNotEnoughRegistersSysV3.Equals(actualNotEnoughRegistersSysV3)) { Console.WriteLine("NotEnoughRegistersSysV3 failed"); ok = false; } TwoDoubles expectedNotEnoughRegistersSysV4 = TwoDoubles.Get(); TwoDoubles actualNotEnoughRegistersSysV4 = NotEnoughRegistersSysV4(1.0d, 2.0d, 3.0d, 4.0d, 5.0d, 6.0d, 7.0d, 8.0d, expectedNotEnoughRegistersSysV4); if (!expectedNotEnoughRegistersSysV4.Equals(actualNotEnoughRegistersSysV4)) { Console.WriteLine("NotEnoughRegistersSysV4 failed"); ok = false; } TwoDoubles expectedNotEnoughRegistersSysV5 = TwoDoubles.Get(); TwoDoubles actualNotEnoughRegistersSysV5 = NotEnoughRegistersSysV5(1.0d, 2.0d, 3.0d, 4.0d, 5.0d, 6.0d, 7.0d, expectedNotEnoughRegistersSysV5); if (!expectedNotEnoughRegistersSysV5.Equals(actualNotEnoughRegistersSysV5)) { Console.WriteLine("NotEnoughRegistersSysV5 failed"); ok = false; } DoubleAndByte expectedNotEnoughRegistersSysV6 = DoubleAndByte.Get(); DoubleAndByte actualNotEnoughRegistersSysV6 = NotEnoughRegistersSysV6(1.0d, 2.0d, 3.0d, 4.0d, 5.0d, 6.0d, 7.0d, 8.0d, expectedNotEnoughRegistersSysV6); if (!expectedNotEnoughRegistersSysV6.Equals(actualNotEnoughRegistersSysV6)) { Console.WriteLine("NotEnoughRegistersSysV6 failed"); ok = false; } TwoDoubles expectedEnoughRegistersSysV1 = TwoDoubles.Get(); TwoDoubles actualEnoughRegistersSysV1 = EnoughRegistersSysV1(1, 2, 3, 4, 5, 6, expectedEnoughRegistersSysV1); if (!expectedEnoughRegistersSysV1.Equals(actualEnoughRegistersSysV1)) { Console.WriteLine("EnoughRegistersSysV1 failed"); ok = false; } DoubleAndByte expectedEnoughRegistersSysV2 = DoubleAndByte.Get(); DoubleAndByte actualEnoughRegistersSysV2 = EnoughRegistersSysV2(1, 2, 3, 4, 5, expectedEnoughRegistersSysV2); if (!expectedEnoughRegistersSysV2.Equals(actualEnoughRegistersSysV2)) { Console.WriteLine("EnoughRegistersSysV2 failed"); ok = false; } TwoLongs expectedEnoughRegistersSysV3 = TwoLongs.Get(); TwoLongs actualEnoughRegistersSysV3 = EnoughRegistersSysV3(1.0d, 2.0d, 3.0d, 4.0d, 5.0d, 6.0d, 7.0d, 8.0d, expectedEnoughRegistersSysV3); if (!expectedEnoughRegistersSysV3.Equals(actualEnoughRegistersSysV3)) { Console.WriteLine("EnoughRegistersSysV3 failed"); ok = false; } DoubleAndByte expectedEnoughRegistersSysV4 = DoubleAndByte.Get(); DoubleAndByte actualEnoughRegistersSysV4 = EnoughRegistersSysV4(1.0d, 2.0d, 3.0d, 4.0d, 5.0d, 6.0d, 7.0d, expectedEnoughRegistersSysV4); if (!expectedEnoughRegistersSysV4.Equals(actualEnoughRegistersSysV4)) { Console.WriteLine("EnoughRegistersSysV4 failed"); ok = false; } return(ok ? 100 : -1); }
static extern Nested1 EchoNested1(Nested1 value);
public bool Equals(Nested1 other) { return(Field1.Equals(other.Field1) && Field2.Equals(other.Field2)); }
//public int Property2 { get; init; } public ClassX(string ss) { Nested1 = new Nested1(); }
private void Sum(object obj) { Nested1 nested = obj as Nested1; nested.sum = nested.nestedValue1 + nested.nestedValue2; }
void SomeMethod() { Nested1 n1 = new Nested1(); Nested2 n2 = new Nested2(); }