public void T1_TypeWasAdded() { using (var ms = new MemoryStream()) { var s1 = new SlimSerializer(); Assert.AreEqual(TypeRegistryMode.PerCall, s1.TypeMode); Assert.IsTrue( s1.IsThreadSafe ); Assert.IsFalse( s1.BatchTypesAdded ); s1.TypeMode = TypeRegistryMode.Batch; Assert.AreEqual(TypeRegistryMode.Batch, s1.TypeMode); Assert.IsFalse( s1.IsThreadSafe ); Assert.IsFalse( s1.BatchTypesAdded ); var o1 = new A1{ I1 = 12}; s1.Serialize(ms, o1); ms.Seek(0, SeekOrigin.Begin); var s2 = new SlimSerializer(); s2.TypeMode = TypeRegistryMode.Batch; var o2 = (A1)s2.Deserialize(ms); Assert.AreEqual( 12, o2.I1); Assert.IsTrue( s1.BatchTypesAdded ); Assert.IsTrue( s2.BatchTypesAdded ); } }
public void Test_ClassToStruct() { A1 a = new A1(); B1 b = new B1(); a = Context.objMan.GetMapper<B1, A1>().Map(b, a); Assert.AreEqual(a.fld1, 10); }
public void Test1() { A1 a = new A1(); B1 b = new B1(); var mapper = Context.objMan.GetMapper<B1, A1>(); //DynamicAssemblyManager.SaveAssembly(); mapper.Map(b, a); Assert.AreEqual(a.fld1, 15); Assert.AreEqual(a.fld2, "11"); }
static long BenchBLToolkit(int mappingsCount) { var s = new B1(); var d = new A1(); var sw = new Stopwatch(); sw.Start(); for (int i = 0; i < mappingsCount; ++i) { d = BLToolkit.Mapping.Map.ObjectToObject<A1>(s); } sw.Stop(); return sw.ElapsedMilliseconds; }
public void TestClone_InterClass_Protection() { A1 a = new A1 { M1 = 11, M2 = 22 }; using (B b = new B { M1 = 33, M2 = 44 }) { a.CloneProperties(b); Assert.AreEqual(b.M1, 11); Assert.AreEqual(b.M2, 22); } using (B b = new B { M1 = 33, M2 = 44 }) { a.CloneProperties(b, true); Assert.AreEqual(b.M1, 11); Assert.AreEqual(b.M2, 44); } }
void run() { director_basic_MyFoo a = new director_basic_MyFoo(); if (a.ping() != "director_basic_MyFoo::ping()") { throw new Exception ( "a.ping()" ); } if (a.pong() != "Foo::pong();director_basic_MyFoo::ping()") { throw new Exception ( "a.pong()" ); } Foo b = new Foo(); if (b.ping() != "Foo::ping()") { throw new Exception ( "b.ping()" ); } if (b.pong() != "Foo::pong();Foo::ping()") { throw new Exception ( "b.pong()" ); } A1 a1 = new A1(1, false); a1.Dispose(); { MyOverriddenClass my = new MyOverriddenClass(); my.expectNull = true; if (MyClass.call_pmethod(my, null) != null) throw new Exception("null pointer marshalling problem"); Bar myBar = new Bar(); my.expectNull = false; Bar myNewBar = MyClass.call_pmethod(my, myBar); if (myNewBar == null) throw new Exception("non-null pointer marshalling problem"); myNewBar.x = 10; } }
public void T1_ResetCallBatch() { using (var ms = new MemoryStream()) { var s1 = new SlimSerializer(); s1.TypeMode = TypeRegistryMode.Batch; Assert.AreEqual(TypeRegistryMode.Batch, s1.TypeMode); Assert.IsFalse( s1.IsThreadSafe ); Assert.IsFalse( s1.BatchTypesAdded ); var o1 = new A1{ I1 = 12}; s1.Serialize(ms, o1); Assert.IsTrue( s1.BatchTypesAdded ); s1.ResetCallBatch(); Assert.IsFalse( s1.BatchTypesAdded ); } }
public void T1_TypeWasNotAdded() { using (var ms = new MemoryStream()) { var s1 = new SlimSerializer( new Type[]{typeof(A1)});//put it in globals s1.TypeMode = TypeRegistryMode.Batch; Assert.IsFalse( s1.BatchTypesAdded ); var o1 = new A1{ I1 = 12}; s1.Serialize(ms, o1); ms.Seek(0, SeekOrigin.Begin); var s2 = new SlimSerializer(new Type[]{typeof(A1)}); s2.TypeMode = TypeRegistryMode.Batch; var o2 = (A1)s2.Deserialize(ms); Assert.AreEqual( 12, o2.I1); Assert.IsFalse( s1.BatchTypesAdded ); Assert.IsFalse( s2.BatchTypesAdded ); } }
private String SolveSteps(valuesStruct valueMC) { string calSteps = ""; //题干 int num = valueMC.number; int i, j; //for (i = 0; i < num - 1; i++) { calSteps += valueMC.values[0].ToString(); calSteps += "×"; } calSteps += valueMC.values[1].ToString(); //解题步骤 int A1, A2; int n = valueMC.baseNum; if (valueMC.posMul == 0) { A1 = decimal.ToInt32(valueMC.values[0]); A2 = decimal.ToInt32(valueMC.values[1]); } else { A2 = decimal.ToInt32(valueMC.values[0]); A1 = decimal.ToInt32(valueMC.values[1]); } int baseNum = 1000; int a1 = (A1 % baseNum) / 100; int b1 = ((A1 % baseNum) % 100) / 10; int c1 = ((A1 % baseNum) % 100) % 10; int a2 = (A2 % baseNum) / 100; int b2 = ((A2 % baseNum) % 100) / 10; int c2 = ((A2 % baseNum) % 100) % 10; int d1 = A1 / 1000; int d2 = A2 / 1000; n = A1 / 14; int a = A1 % 14; //第一步 calSteps += "="; calSteps += A1.ToString(); calSteps += "×10-"; calSteps += A1.ToString(); //第二步 int n100 = A1 * 10; int n2 = A1; calSteps += "="; calSteps += n100.ToString(); calSteps += "-"; calSteps += n2.ToString(); //第三步 decimal answer = 0; answer = n100 - n2; //第四步 if (answer != valueMC.answer) { calSteps += "Error!"; } calSteps += "="; calSteps += valueMC.answer.ToString(); calSteps += ",是正确答案。"; return(calSteps); }
static void Main() { A1 o1 = new A1(); System.Console.WriteLine(o1.v1); }
public TwoCtors(A1 a1, A2 a2) { CalledCtor = new[] { typeof(A1), typeof(A2) }; }
public B1(A1 a) { A = a; }
public void Test_WPFBrowserNavigator_Navition_Resolve_OnBaseType() { TestNavigation((wpfbuild, wpfnav, WindowTest) => { wpfnav.Should().NotBeNull(); wpfbuild.Register<A>("javascript\\navigation_1.html"); wpfbuild.Register<A1>("javascript\\navigation_2.html", "Special"); wpfnav.UseINavigable = true; var a1 = new A1(); var mre = new ManualResetEvent(false); WindowTest.RunOnUIThread( () => { wpfnav.NavigateAsync(a1).ContinueWith(t => mre.Set()); }); mre.WaitOne(); WindowTest.RunOnUIThread(() => { //a1.Navigation.Should().Be(wpfnav); a1.Navigation.Should().NotBeNull(); }); WindowTest.RunOnUIThread( () => wpfnav.Source.LocalPath.Should().EndWith("javascript\\navigation_1.html")); }); }
private PrivateConstructor(A1 a1) { A1 = a1; }
private String SolveSteps(valuesStruct valueMC) { string calSteps = ""; //题干 int num = valueMC.number; int i, j; //for (i = 0; i < num - 1; i++) { calSteps += valueMC.values[0].ToString(); calSteps += "÷"; } calSteps += valueMC.values[1].ToString(); //解题步骤 int A1, A2; int n = valueMC.baseNum; if (valueMC.posMul == 0) { A1 = decimal.ToInt32(valueMC.values[0]); A2 = decimal.ToInt32(valueMC.values[1]); } else { A2 = decimal.ToInt32(valueMC.values[0]); A1 = decimal.ToInt32(valueMC.values[1]); } int baseNum = 1000; int a1 = (A1 % baseNum) / 100; int b1 = ((A1 % baseNum) % 100) / 10; int c1 = ((A1 % baseNum) % 100) % 10; int a2 = (A2 % baseNum) / 100; int b2 = ((A2 % baseNum) % 100) / 10; int c2 = ((A2 % baseNum) % 100) % 10; int d1 = A1 / 1000; int d2 = A2 / 1000; int m = A2 / n; int a = A2 % 11; //第一步 calSteps += "="; calSteps += A1.ToString(); calSteps += "÷"; calSteps += m.ToString(); calSteps += "÷"; calSteps += n.ToString(); //calSteps += "×91"; //calSteps += "×"; //calSteps += A1.ToString(); ////calSteps += "×2"; //第二步 int n1000 = A1 / m; int A22 = A2 * 4; int a77 = a * 91; int n2 = n * 4; calSteps += "="; calSteps += n1000.ToString(); calSteps += "÷"; calSteps += n.ToString(); //第三步 decimal answer = 0; answer = n1000 / n; //第四步 if (answer != valueMC.answer) { calSteps += "Error!"; } calSteps += "="; calSteps += valueMC.answer.ToString(); calSteps += ",是正确答案。"; return calSteps; }
private void Test_HTMLWindow_WebCoreShutDown_Base(IWebSessionWatcher iWatcher) { var a = new A1(); TestNavigation((wpfbuild, wpfnav, WindowTest) => { wpfnav.WebSessionWatcher.Should().NotBeNull(); if (iWatcher != null) wpfnav.WebSessionWatcher = iWatcher; SetUpRoute(wpfbuild); wpfnav.UseINavigable = true; var mre = new ManualResetEvent(false); WindowTest.RunOnUIThread(() => wpfnav.IsHTMLLoaded.Should().BeFalse()); WindowTest.RunOnUIThread( () => { wpfnav.NavigateAsync(a).ContinueWith(t => mre.Set()); }); mre.WaitOne(); WindowTest.RunOnUIThread(() => { wpfnav.IsHTMLLoaded.Should().BeTrue(); a.Navigation.Should().NotBeNull(); }); WebCore.Shutdown(); Thread.Sleep(1500); }); }
private String SolveSteps(valuesStruct valueMC) { string calSteps = ""; //题干 int num = valueMC.number; int i, j; //for (i = 0; i < num - 1; i++) { calSteps += valueMC.values[0].ToString(); calSteps += "×"; } calSteps += valueMC.values[1].ToString(); //解题步骤 int A1, A2; int n = valueMC.baseNum; if (valueMC.posMul == 0) { A1 = decimal.ToInt32(valueMC.values[0]); A2 = decimal.ToInt32(valueMC.values[1]); } else { A2 = decimal.ToInt32(valueMC.values[0]); A1 = decimal.ToInt32(valueMC.values[1]); } int baseNum = 1000; int a1 = (A1 % baseNum) / 100; int b1 = ((A1 % baseNum) % 100) / 10; int c1 = ((A1 % baseNum) % 100) % 10; int a2 = (A2 % baseNum) / 100; int b2 = ((A2 % baseNum) % 100) / 10; int c2 = ((A2 % baseNum) % 100) % 10; int d1 = A1 / 1000; int d2 = A2 / 1000; int c21 = 10 - c2; int A21 = A2 + c21; //第一步 calSteps += "="; calSteps += A1.ToString(); calSteps += "×("; calSteps += A21.ToString(); calSteps += "-"; calSteps += c21.ToString(); calSteps += ")"; //第二步 calSteps += "="; calSteps += A1.ToString(); calSteps += "×"; calSteps += A21.ToString(); calSteps += "-"; calSteps += A1.ToString(); calSteps += "×"; calSteps += c21.ToString(); //第三步 calSteps += "="; int A1A21 = A1 * A21; int A1c21 = A1 * c21; calSteps += A1A21.ToString(); calSteps += "-"; calSteps += A1c21.ToString(); //calSteps += "="; //int b10b20 = b10 * b20; //int c1c2 = c1 * c2; //int bc10 = (b1 * c2 + b2 * c1) * 10; //calSteps += b10b20.ToString(); //calSteps += "+"; //calSteps += c1c2.ToString(); //calSteps += "+"; //calSteps += bc10.ToString(); decimal answer = 0; answer = A1A21 - A1c21; //第四步 if (answer != valueMC.answer) { calSteps += "Error!"; } calSteps += "="; calSteps += valueMC.answer.ToString(); calSteps += ",是正确答案。"; return(calSteps); }
void run() { director_basic_MyFoo a = new director_basic_MyFoo(); if (a.ping() != "director_basic_MyFoo::ping()") { throw new Exception("a.ping()"); } if (a.pong() != "Foo::pong();director_basic_MyFoo::ping()") { throw new Exception("a.pong()"); } Foo b = new Foo(); if (b.ping() != "Foo::ping()") { throw new Exception("b.ping()"); } if (b.pong() != "Foo::pong();Foo::ping()") { throw new Exception("b.pong()"); } A1 a1 = new A1(1, false); a1.Dispose(); { MyOverriddenClass my = new MyOverriddenClass(); my.expectNull = true; if (MyClass.call_pmethod(my, null) != null) { throw new Exception("null pointer marshalling problem"); } Bar myBar = new Bar(); my.expectNull = false; Bar myNewBar = MyClass.call_pmethod(my, myBar); if (myNewBar == null) { throw new Exception("non-null pointer marshalling problem"); } myNewBar.x = 10; // Low level implementation check // my.testalaqilDerivedClassHasMethod(); // These should not call the C# implementations as they are not overridden int v; v = MyClass.call_nonVirtual(my); if (v != 100) { throw new Exception("call_nonVirtual broken() " + v); } v = MyClass.call_nonOverride(my); if (v != 101) { throw new Exception("call_nonOverride broken() " + v); } // A mix of overridden and non-overridden MyClassEnd myend = new MyClassEnd(); MyClass mc = myend; v = mc.nonVirtual(); if (v != 202) { throw new Exception("mc.nonVirtual() broken " + v); } v = MyClass.call_nonVirtual(mc); if (v != 202) { throw new Exception("call_nonVirtual(mc) broken " + v); } v = MyClass.call_nonVirtual(myend); if (v != 202) { throw new Exception("call_nonVirtual(myend) broken" + v); } v = MyClass.call_nonOverride(mc); if (v != 101) { throw new Exception("call_nonOverride(mc) broken" + v); } v = MyClass.call_nonOverride(myend); if (v != 101) { throw new Exception("call_nonOverride(myend) broken" + v); } } }
private String SolveSteps(valuesStruct valueMC) { string calSteps = ""; //题干 int num = valueMC.number; int i, j; //for (i = 0; i < num - 1; i++) { calSteps += valueMC.values[0].ToString(); calSteps += "×"; } calSteps += valueMC.values[1].ToString(); //解题步骤 int A1, A2; if (valueMC.values[0] > 0)//valueMC.values[1]) { A1 = decimal.ToInt32(valueMC.values[0]); A2 = decimal.ToInt32(valueMC.values[1]); } else { A2 = decimal.ToInt32(valueMC.values[0]); A1 = decimal.ToInt32(valueMC.values[1]); } int baseNum = 1000; int a1 = (A1 % baseNum) / 100; int b1 = ((A1 % baseNum) % 100) / 10; int c1 = ((A1 % baseNum) % 100) % 10; int a2 = (A2 % baseNum) / 100; int b2 = ((A2 % baseNum) % 100) / 10; int c2 = ((A2 % baseNum) % 100) % 10; int d1 = A1 / 1000; int d2 = A2 / 1000; int baseNum2 = 100; int bs = 100 - A2; //第一步 int b1c1 = 10 * b1 + c1; calSteps += "=("; calSteps += A1.ToString(); calSteps += "×10+"; calSteps += b1.ToString(); calSteps += "×"; calSteps += c2.ToString(); calSteps += ")×10+"; calSteps += c1.ToString(); calSteps += "×"; calSteps += c2.ToString(); //第二步 int a1c200 = A1 * 10 + b1 * c2; int c1c2 = c1 * c2; calSteps += "="; calSteps += a1c200.ToString(); calSteps += "×10+"; calSteps += c1c2.ToString(); //第三步 decimal AA11 = a1c200 * 10; calSteps += "="; calSteps += AA11.ToString(); calSteps += "+"; calSteps += c1c2.ToString(); decimal answer = 0; answer = AA11 + c1c2; //第四步 if (answer != valueMC.answer) { calSteps += "Error!"; } calSteps += "="; calSteps += valueMC.answer.ToString(); calSteps += ",是正确答案。"; return(calSteps); }
get => new Vector4(A1, A2, A3, A4);
public void T3_Batch_CSUM_Mismatch() { using (var ms = new MemoryStream()) { var s1 = new SlimSerializer(new Type[]{typeof(A1)}); s1.TypeMode= TypeRegistryMode.Batch; var o1 = new A1{ I1 = 12}; s1.Serialize(ms, o1); ms.Seek(0, SeekOrigin.Begin); var s2 = new SlimSerializer(new Type[]{typeof(A2)}); s2.TypeMode= TypeRegistryMode.Batch; var o2 = (A1)s2.Deserialize(ms); } }
public static void Do12(this A1 parameter1, A2 parameter2, int arg) { _contract.Call(parameter1, parameter2, arg); }
private String SolveSteps(valuesStruct valueMC) { string calSteps = ""; int A1, A2; //题干 int num = valueMC.number; int i, j; if (valueMC.posMul == 0) { calSteps += valueMC.values[0].ToString(); calSteps += "×"; calSteps += valueMC.values[1].ToString(); calSteps += "+"; calSteps += valueMC.values[0].ToString(); A1 = decimal.ToInt32(valueMC.values[0]); A2 = decimal.ToInt32(valueMC.values[1]); } else { calSteps += valueMC.values[1].ToString(); calSteps += "×"; calSteps += valueMC.values[0].ToString(); calSteps += "-"; calSteps += valueMC.values[1].ToString(); A2 = decimal.ToInt32(valueMC.values[0]); A1 = decimal.ToInt32(valueMC.values[1]); } //解题步骤 int baseNum = 1000; int a1 = (A1 % baseNum) / 100; int b1 = ((A1 % baseNum) % 100) / 10; int c1 = ((A1 % baseNum) % 100) % 10; int a2 = (A2 % baseNum) / 100; int b2 = ((A2 % baseNum) % 100) / 10; int c2 = ((A2 % baseNum) % 100) % 10; int d1 = A1 / 1000; int d2 = A2 / 1000; int baseNum2 = 100; int bs = 100 - A2; //第一步 int A22 = 0; calSteps += "="; calSteps += A1.ToString(); calSteps += "×("; calSteps += A2.ToString(); if (valueMC.posMul == 0) { calSteps += "+1)"; A22 = A2 + 1; } else { calSteps += "-1)"; A22 = A2 - 1; } //第二步 calSteps += "="; calSteps += A1.ToString(); calSteps += "×"; calSteps += A22.ToString(); //第三步 //decimal AA11 = a1c200 * 10; //calSteps += "="; //calSteps += AA11.ToString(); //calSteps += "+"; //calSteps += c1c2.ToString(); decimal answer = 0; answer = A1 * A22; //第四步 if (answer != valueMC.answer) { calSteps += "Error!"; } calSteps += "="; calSteps += valueMC.answer.ToString(); calSteps += ",是正确答案。"; return(calSteps); }
public void Test_WPFBrowserNavigator_Navition_3_screens() { TestNavigation((wpfbuild, wpfnav, WindowTest) => { wpfnav.Should().NotBeNull(); SetUpRoute(wpfbuild); wpfbuild.Register<A1>("javascript\\navigation_3.html", "NewPath"); wpfnav.UseINavigable = true; var a1 = new A1(); var a2 = new A2(); var mre = new ManualResetEvent(false); WindowTest.RunOnUIThread( () => { wpfnav.NavigateAsync(a1).ContinueWith(t => mre.Set()); }); mre.WaitOne(); WindowTest.RunOnUIThread(() => { //a1.Navigation.Should().Be(wpfnav); a1.Navigation.Should().NotBeNull(); }); WindowTest.RunOnUIThread( () => wpfnav.Source.Should().EndWith(@"javascript\navigation_1.html")); mre = new ManualResetEvent(false); WindowTest.RunOnUIThread( () => { wpfnav.NavigateAsync(a2).ContinueWith(t => mre.Set()); }); mre.WaitOne(); WindowTest.RunOnUIThread(() => { a2.Navigation.Should().NotBeNull(); a1.Navigation.Should().BeNull(); }); WindowTest.RunOnUIThread(() => wpfnav.Source.Should().EndWith(@"javascript\navigation_2.html")); WindowTest.RunOnUIThread( () => { wpfnav.NavigateAsync(a1, "NewPath").ContinueWith ( t => { //a1.Navigation.Should().Be(wpfnav); a1.Navigation.Should().NotBeNull(); a2.Navigation.Should().BeNull(); mre.Set(); }); }); mre.WaitOne(); Thread.Sleep(2000); WindowTest.RunOnUIThread(() => wpfnav.Source.Should().EndWith(@"javascript\navigation_3.html")); }); }
public void Test_WPFBrowserNavigator_Navigation_ToNull() { TestNavigation((wpfbuild, wpfnav, WindowTest) => { wpfnav.Should().NotBeNull(); SetUpRoute(wpfbuild); wpfnav.UseINavigable = true; var a1 = new A1(); var mre = new ManualResetEvent(false); WindowTest.RunOnUIThread( () => { wpfnav.NavigateAsync(a1).ContinueWith(t => mre.Set()); }); mre.WaitOne(); WindowTest.RunOnUIThread(() => { //a1.Navigation.Should().Be(wpfnav); a1.Navigation.Should().NotBeNull(); }); WindowTest.RunOnUIThread( () => wpfnav.Source.LocalPath.Should().EndWith("javascript\\navigation_1.html")); WindowTest.RunOnUIThread( () => { wpfnav.NavigateAsync(null).ContinueWith(t => mre.Set()); }); mre.WaitOne(); WindowTest.RunOnUIThread(() => { a1.Navigation.Should().NotBeNull(); }); Thread.Sleep(200); WindowTest.RunOnUIThread(() => wpfnav.Source.LocalPath.Should().EndWith("javascript\\navigation_1.html")); }); }
public void T5_Batch_WriteReadMany() { using (var ms = new MemoryStream()) { var s1 = new SlimSerializer(); s1.TypeMode= TypeRegistryMode.Batch; var s2 = new SlimSerializer(); s2.TypeMode= TypeRegistryMode.Batch; var o1a = new A1{ I1 = 12}; var o1b = new A2{ I2 = 13}; var o1c = new A1{ I1 = 14}; var o1d = new A1{ I1 = 15}; var o1e = new A1{ I1 = 16}; s1.Serialize(ms, o1a); Assert.IsTrue( s1.BatchTypesAdded ); ms.Position = 0; var o2a = (A1)s2.Deserialize(ms); Assert.IsTrue( s2.BatchTypesAdded ); ms.Position = 0; s1.Serialize(ms, o1b); Assert.IsTrue( s1.BatchTypesAdded ); ms.Position = 0; var o2b = (A2)s2.Deserialize(ms); Assert.IsTrue( s2.BatchTypesAdded ); ms.Position = 0; s1.Serialize(ms, o1c); Assert.IsFalse( s1.BatchTypesAdded ); ms.Position = 0; var o2c = (A1)s2.Deserialize(ms); Assert.IsFalse( s2.BatchTypesAdded ); ms.Position = 0; s1.Serialize(ms, o1d); Assert.IsFalse( s1.BatchTypesAdded ); ms.Position = 0; var o2d = (A1)s2.Deserialize(ms); Assert.IsFalse( s2.BatchTypesAdded ); ms.Position = 0; s1.Serialize(ms, o1e); Assert.IsFalse( s1.BatchTypesAdded ); ms.Position = 0; var o2e = (A1)s2.Deserialize(ms); Assert.IsFalse( s2.BatchTypesAdded ); Assert.AreEqual(12, o2a.I1); Assert.AreEqual(13, o2b.I2); Assert.AreEqual(14, o2c.I1); Assert.AreEqual(15, o2d.I1); Assert.AreEqual(16, o2e.I1); } }
static void Main(string[] args) { //A1就是類別名稱,Happy就是類別的方法 //就像是我們裝好電腦之後,就可以做開機的動作,new就是裝好這台電腦 A1 _PC = new A1(); //然後我們就是做開機動作, string _Happy = _PC.Happy(); //----------------------------------------------- A2 _PC2 = new A2("龍魂GE60"); //可以在裝好電腦時,為他取名,這樣大家才會知道是哪台,當然建構式可以多個 string _strPC2 = _PC2.Happy(); //A3 方法重載 A2 _PC3 = new A2(); string _strPC3 = _PC3.Happy("自爽"); //-------------------------------------------------- //A4 屬性與修飾子 A4 _PC4 = new A4(); _PC4.ReStartNum = 5; Console.WriteLine(_PC4.ReStart()); //A5 封裝,剛才都是在使用封裝的 //假設現在A5是NB,他也一樣會有ReStart A5 _NB = new A5(); _NB.ReStartNum = 5; Console.WriteLine(_NB.ReStart()); //A9 介面 //抽象類別可以給初一些成員的實現,抽象類別的抽象成員可被子類別部分實現 //介面的成員需要實現類別完全實現,一個類別只能繼承一個抽象類別,但可以實現多個介面等 //第一類別是對物件的抽象;抽象類別是對類別的抽象;介面是對行為的抽象 //第二如果行為跨越不同類別的物件,可使用介面;對於一些相似的類別物件,用繼承抽象類別 //舉例 貓 狗都是動物,所以它們去繼承動物這抽象類別 //但悟空和超人都會飛,但是悟空會變身,神話的悟空也會變身,所以此時可以用介面來完成 //第三,抽象類別是從子類別中發現了公共的東西,泛化出父類別,然後子類別繼承父類別 //,而介面是根本不知子類別的存在,方法如何實現還不確認,預先定義 //例如在寫程式時候,是先寫了貓類別後,在寫出狗類別,最後發現有相同類似的,就泛化出動物類別, //不可能只有貓類別時候就想到動物類別 //而介面是一同思考,定義一些項目,但不知道會有什麼動物,要如何實現,能做的就是是先定義這些比賽項目的行為介面 //抽象類別是自底而上抽象類別的,而介面則是自頂而下設定的 //(從狗貓衍伸出動物)(從項目延伸出不知那些動物會來參加預先定義好項目) A9_Interface _A9 = new A9_Interface("測試介面"); IA9_Interface _A9_2 = new A9_Interface("測試介面2"); Console.WriteLine(_A9.ChangeThing("第一個")); Console.WriteLine(_A9_2.ChangeThing("第二個")); //A10 泛型 IList <Animal> arrayAnimal = new List <Animal>(); arrayAnimal.Add(new Cat_Extend("tt")); arrayAnimal.Add(new Dog_Extend("tt2")); arrayAnimal.Add(new Cat_Extend("tt3")); Console.WriteLine(arrayAnimal.Count.ToString()); //A11 泛型 cat_deleget _cat = new cat_deleget("T"); mouse_deleget _mo1 = new mouse_deleget("Ja"); mouse_deleget _mo2 = new mouse_deleget("Jb"); //表示將Mouse的Run方法透過實體化委託給CatShoutEventHandler登記到Cat的事件CatShout當中,+=是為了加進去add_CatShout的意思 _cat.CatShout += new cat_deleget.CatShoutEventHandler(_mo1.Run); _cat.CatShout += new cat_deleget.CatShoutEventHandler(_mo2.Run); _cat.Shout(); cat_deleget2 _cat2 = new cat_deleget2("T"); mouse_deleget2 _mo21 = new mouse_deleget2("Ja"); mouse_deleget2 _mo22 = new mouse_deleget2("Jb"); _cat2.CatShout += new cat_deleget2.CatShoutEventHandler(_mo21.Run); _cat2.CatShout += new cat_deleget2.CatShoutEventHandler(_mo22.Run); _cat2.Shout(); //A12-yieldreturn yieldreturn _yield = new yieldreturn(); var _return = _yield.returnACD(); string _strreturn = ""; foreach (var item in _return) { _strreturn += item; } Console.WriteLine(_strreturn); Console.Read(); }
public void M( A1 arg ) { }
public TwoCtors(A1 a1) { CalledCtor = new[] { typeof(A1) }; }
public void Test_WPFBrowserNavigator_Simple() { bool fl = false; EventHandler ea = null; TestNavigation((wpfbuild, wpfnav, WindowTest) => { ea = (o, e) => { fl = true; wpfnav.OnFirstLoad -= ea; }; wpfnav.OnFirstLoad+= ea; wpfnav.Should().NotBeNull(); SetUpRoute(wpfbuild); wpfnav.UseINavigable = true; var a = new A1(); var mre = new ManualResetEvent(false); WindowTest.RunOnUIThread(() => wpfnav.IsHTMLLoaded.Should().BeFalse()); WindowTest.RunOnUIThread( () => { wpfnav.NavigateAsync(a).ContinueWith(t => mre.Set()); }); mre.WaitOne(); fl.Should().BeTrue(); WindowTest.RunOnUIThread(() => { wpfnav.IsHTMLLoaded.Should().BeTrue(); //a1.Navigation.Should().Be(wpfnav); a.Navigation.Should().NotBeNull(); }); mre.WaitOne(); }); }
public ComplexObject() { A1 = new A1(); }
public void T4_CountMismatchResetBatch_WriteMany() { using (var ms = new MemoryStream()) { var s1 = new SlimSerializer(); s1.TypeMode= TypeRegistryMode.Batch; var o1a = new A1{ I1 = 12}; var o1b = new A2{ I2 = 13}; var o1c = new A1{ I1 = 14}; var o1d = new A1{ I1 = 15}; var o1e = new A1{ I1 = 16}; s1.Serialize(ms, o1a); Assert.IsTrue( s1.BatchTypesAdded ); s1.Serialize(ms, o1b); Assert.IsTrue( s1.BatchTypesAdded ); s1.Serialize(ms, o1c); Assert.IsFalse( s1.BatchTypesAdded ); s1.Serialize(ms, o1d); Assert.IsFalse( s1.BatchTypesAdded ); s1.Serialize(ms, o1e); Assert.IsFalse( s1.BatchTypesAdded ); ms.Seek(0, SeekOrigin.Begin); var buf = ms.GetBuffer(); Console.WriteLine( buf.ToDumpString(DumpFormat.Printable, 0,(int) ms.Length) ); var s2 = new SlimSerializer(); s2.TypeMode= TypeRegistryMode.Batch; var o2a = (A1)s2.Deserialize(ms); Assert.IsTrue( s2.BatchTypesAdded ); Assert.AreEqual(12, o2a.I1); s2.ResetCallBatch(); var o2b = (A2)s2.Deserialize(ms); //Exception } }
public CD1(A1 a, B1 b) { A = a; B = b; }
public void M(A1 arg) { }
private void Test_HTMLWindowRecovery_Capacity_Base(IWebSessionWatcher iWatcher) { bool fl = false; EventHandler ea = null; var a = new A1(); TestNavigation((wpfbuild, wpfnav, WindowTest) => { wpfnav.WebSessionWatcher.Should().NotBeNull(); if (iWatcher != null) wpfnav.WebSessionWatcher = iWatcher; ea = (o, e) => { fl = true; wpfnav.OnFirstLoad -= ea; }; wpfnav.OnFirstLoad += ea; wpfnav.Should().NotBeNull(); SetUpRoute(wpfbuild); wpfnav.UseINavigable = true; var mre = new ManualResetEvent(false); WindowTest.RunOnUIThread(() => wpfnav.IsHTMLLoaded.Should().BeFalse()); WindowTest.RunOnUIThread( () => { wpfnav.NavigateAsync(a).ContinueWith(t => mre.Set()); }); mre.WaitOne(); fl.Should().BeTrue(); WindowTest.RunOnUIThread(() => { wpfnav.IsHTMLLoaded.Should().BeTrue(); //a1.Navigation.Should().Be(wpfnav); a.Navigation.Should().NotBeNull(); }); mre.WaitOne(); var webv = (a.Navigation as IWebViewProvider).WebView; mre = new ManualResetEvent(false); Process p = null; WindowTest.RunOnUIThread(() => { p = webv.RenderProcess; p.Kill(); mre.Set(); }); mre.WaitOne(); Thread.Sleep(500); p.WaitForExit(); Process np = null; mre = new ManualResetEvent(false); WindowTest.RunOnUIThread(() => { np = webv.RenderProcess; mre.Set(); }); np.Should().NotBe(p); }); }
public void T2_PerCall_CSUM_Mismatch() { using (var ms = new MemoryStream()) { var s1 = new SlimSerializer(new Type[]{typeof(A1)}); var o1 = new A1{ I1 = 12}; s1.Serialize(ms, o1); ms.Seek(0, SeekOrigin.Begin); var s2 = new SlimSerializer(new Type[]{typeof(A2)}); var o2 = (A1)s2.Deserialize(ms); } }
public void Test_HTMLWindowRecovery_UnderClosure_Capacity_Base() { //bool fl = false; //EventHandler ea = null; var a = new A1(); IWebSessionWatcher watch = Substitute.For<IWebSessionWatcher>(); TestNavigation((wpfbuild, wpfnav, WindowTest) => { wpfnav.WebSessionWatcher.Should().NotBeNull(); wpfnav.WebSessionWatcher = watch; //ea = (o, e) => { fl = true; wpfnav.OnFirstLoad -= ea; }; //wpfnav.OnFirstLoad += ea; //wpfnav.Should().NotBeNull(); SetUpRoute(wpfbuild); wpfnav.UseINavigable = true; var mre = new ManualResetEvent(false); WindowTest.RunOnUIThread(() => wpfnav.IsHTMLLoaded.Should().BeFalse()); WindowTest.RunOnUIThread( () => { wpfnav.NavigateAsync(a).ContinueWith(t => mre.Set()); }); mre.WaitOne(); WindowTest.RunOnUIThread(() => { wpfnav.IsHTMLLoaded.Should().BeTrue(); //a1.Navigation.Should().Be(wpfnav); a.Navigation.Should().NotBeNull(); System.Windows.Application.Current.Shutdown(); var p = (a.Navigation as IWebViewProvider).WebView.RenderProcess; WebCore.Shutdown(); //p.Kill(); mre.Set(); }); mre.WaitOne(); Thread.Sleep(1000); watch.DidNotReceive().LogCritical("WebView crashed trying recover"); },false,false); }
private String SolveSteps(valuesStruct valueMC) { string calSteps = ""; //题干 int num = valueMC.number; int i, j; //for (i = 0; i < num - 1; i++) { calSteps += valueMC.values[0].ToString(); calSteps += "×"; } calSteps += valueMC.values[1].ToString(); //解题步骤 int A1, A2; if (valueMC.values[0] < valueMC.values[1]) { A1 = decimal.ToInt32(valueMC.values[0]); A2 = decimal.ToInt32(valueMC.values[1]); } else { A2 = decimal.ToInt32(valueMC.values[0]); A1 = decimal.ToInt32(valueMC.values[1]); } int baseNum = 1000; int a1 = (A1 % baseNum) / 100; int b1 = ((A1 % baseNum) % 100) / 10; int c1 = ((A1 % baseNum) % 100) % 10; int a2 = (A2 % baseNum) / 100; int b2 = ((A2 % baseNum) % 100) / 10; int c2 = ((A2 % baseNum) % 100) % 10; int d1 = A1 / 1000; int d2 = A2 / 1000; int baseNum2 = 100; int bs = 100 - A2; //第一步 int A21 = A2 - A1; calSteps += "="; calSteps += A1.ToString(); calSteps += "×"; calSteps += A1.ToString(); calSteps += "+("; calSteps += A2.ToString(); calSteps += "-"; calSteps += A1.ToString(); calSteps += ")×"; calSteps += A1.ToString(); //第二步 int A1A1 = A1 * A1; calSteps += "="; calSteps += A1A1.ToString(); calSteps += "+"; calSteps += A21.ToString(); calSteps += "×"; calSteps += A1.ToString(); //第三步 int A21A1 = A21 * A1; calSteps += "="; calSteps += A1A1.ToString(); calSteps += "+"; calSteps += A21A1.ToString(); decimal answer = 0; answer = A1A1 + A21A1; //第四步 if (answer != valueMC.answer) { calSteps += "Error!"; } calSteps += "="; calSteps += valueMC.answer.ToString(); calSteps += ",是正确答案。"; return(calSteps); }
protected A1(A1 copy) { this.X1 = copy.X1; }
public void Test_HTMLWindow_Path() { bool fl = false; EventHandler ea = null; var a = new A1(); string pn = Path.Combine(Path.GetTempPath(), "MVMMAWe"); TestNavigation((wpfbuild, wpfnav, WindowTest) => { wpfnav.SessionPath.Should().BeNull(); wpfnav.SessionPath = pn; ea = (o, e) => { fl = true; wpfnav.OnFirstLoad -= ea; }; wpfnav.OnFirstLoad += ea; wpfnav.Should().NotBeNull(); SetUpRoute(wpfbuild); wpfnav.UseINavigable = true; var mre = new ManualResetEvent(false); WindowTest.RunOnUIThread(() => wpfnav.IsHTMLLoaded.Should().BeFalse()); WindowTest.RunOnUIThread( () => { wpfnav.NavigateAsync(a).ContinueWith(t => mre.Set()); }); mre.WaitOne(); fl.Should().BeTrue(); }); Directory.Exists(pn).Should().BeTrue(); }
public Employee GetEmployee(string email) => A1.getEmployeeFromDatabase(_db, email);
public void Test_HTMLWindow_Event() { bool fl = false; EventHandler ea = null; var a = new A1(); string pn = Path.Combine(Path.GetTempPath(), "MVMMAWe"); bool fslr = false; NavigationEvent nea = null; TestNavigation((wpfbuild, wpfnav, WindowTest) => { wpfnav.OnFirstLoad += (o, e) => { fslr = true; }; wpfnav.OnNavigate += (o, e) => { nea = e; }; ea = (o, e) => { fl = true; wpfnav.OnFirstLoad -= ea; }; wpfnav.OnFirstLoad += ea; wpfnav.Should().NotBeNull(); SetUpRoute(wpfbuild); wpfnav.UseINavigable = true; var mre = new ManualResetEvent(false); WindowTest.RunOnUIThread(() => wpfnav.IsHTMLLoaded.Should().BeFalse()); WindowTest.RunOnUIThread( () => { wpfnav.NavigateAsync(a).ContinueWith(t => mre.Set()); }); mre.WaitOne(); fl.Should().BeTrue(); }); fslr.Should().BeTrue(); nea.Should().NotBeNull(); nea.OldViewModel.Should().BeNull(); nea.NewViewModel.Should().Be(a); }
static void Main(string[] args) { //A1就是類別名稱,Happy就是類別的方法 //就像是我們裝好電腦之後,就可以做開機的動作,new就是裝好這台電腦 A1 _PC = new A1(); //然後我們就是做開機動作, string _Happy=_PC.Happy(); //----------------------------------------------- A2 _PC2 = new A2("龍魂GE60"); //可以在裝好電腦時,為他取名,這樣大家才會知道是哪台,當然建構式可以多個 string _strPC2 = _PC2.Happy(); //A3 方法重載 A2 _PC3 = new A2(); string _strPC3 = _PC3.Happy("自爽"); //-------------------------------------------------- //A4 屬性與修飾子 A4 _PC4 = new A4(); _PC4.ReStartNum = 5; Console.WriteLine(_PC4.ReStart()); //A5 封裝,剛才都是在使用封裝的 //假設現在A5是NB,他也一樣會有ReStart A5 _NB = new A5(); _NB.ReStartNum = 5; Console.WriteLine(_NB.ReStart()); //A9 介面 //抽象類別可以給初一些成員的實現,抽象類別的抽象成員可被子類別部分實現 //介面的成員需要實現類別完全實現,一個類別只能繼承一個抽象類別,但可以實現多個介面等 //第一類別是對物件的抽象;抽象類別是對類別的抽象;介面是對行為的抽象 //第二如果行為跨越不同類別的物件,可使用介面;對於一些相似的類別物件,用繼承抽象類別 //舉例 貓 狗都是動物,所以它們去繼承動物這抽象類別 //但悟空和超人都會飛,但是悟空會變身,神話的悟空也會變身,所以此時可以用介面來完成 //第三,抽象類別是從子類別中發現了公共的東西,泛化出父類別,然後子類別繼承父類別 //,而介面是根本不知子類別的存在,方法如何實現還不確認,預先定義 //例如在寫程式時候,是先寫了貓類別後,在寫出狗類別,最後發現有相同類似的,就泛化出動物類別, //不可能只有貓類別時候就想到動物類別 //而介面是一同思考,定義一些項目,但不知道會有什麼動物,要如何實現,能做的就是是先定義這些比賽項目的行為介面 //抽象類別是自底而上抽象類別的,而介面則是自頂而下設定的 //(從狗貓衍伸出動物)(從項目延伸出不知那些動物會來參加預先定義好項目) A9_Interface _A9 = new A9_Interface("測試介面"); IA9_Interface _A9_2 = new A9_Interface("測試介面2"); Console.WriteLine(_A9.ChangeThing("第一個")); Console.WriteLine(_A9_2.ChangeThing("第二個")); //A10 泛型 IList<Animal> arrayAnimal = new List<Animal>(); arrayAnimal.Add(new Cat_Extend("tt")); arrayAnimal.Add(new Dog_Extend("tt2")); arrayAnimal.Add(new Cat_Extend("tt3")); Console.WriteLine(arrayAnimal.Count.ToString()); //A11 泛型 cat_deleget _cat = new cat_deleget("T"); mouse_deleget _mo1 = new mouse_deleget("Ja"); mouse_deleget _mo2 = new mouse_deleget("Jb"); //表示將Mouse的Run方法透過實體化委託給CatShoutEventHandler登記到Cat的事件CatShout當中,+=是為了加進去add_CatShout的意思 _cat.CatShout += new cat_deleget.CatShoutEventHandler(_mo1.Run); _cat.CatShout += new cat_deleget.CatShoutEventHandler(_mo2.Run); _cat.Shout(); cat_deleget2 _cat2 = new cat_deleget2("T"); mouse_deleget2 _mo21 = new mouse_deleget2("Ja"); mouse_deleget2 _mo22 = new mouse_deleget2("Jb"); _cat2.CatShout += new cat_deleget2.CatShoutEventHandler(_mo21.Run); _cat2.CatShout += new cat_deleget2.CatShoutEventHandler(_mo22.Run); _cat2.Shout(); //A12-yieldreturn yieldreturn _yield = new yieldreturn(); var _return = _yield.returnACD(); string _strreturn = ""; foreach (var item in _return) { _strreturn += item; } Console.WriteLine(_strreturn); Console.Read(); }