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 ShouldReturnConvertedObjectWhenCanBeConverted()
        {
            var b = new B1(new A1());

            var a1 = b.Convert(o => o.A as A1);

            Assert.IsNotNull(a1);
        }
 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;
        }
Exemple #5
0
        public void ManageSubChannelsUsingClasses()
        {
            var a = new A();
            var b1 = new B1();
            var b2 = new B2();
            var c = new C();
            var bus = new EventStream(false);
            bus.Subscribe(TestActor, typeof(B2));
            bus.Publish(c);
            bus.Publish(b2);
            ExpectMsg(b2);
            bus.Subscribe(TestActor, typeof(A));
            bus.Publish(c);
            ExpectMsg(c);
            bus.Publish(b1);
            ExpectMsg(b1);

            bus.Unsubscribe(TestActor, typeof(B1));
            bus.Publish(c); //should not publish
            bus.Publish(b2); //should publish
            bus.Publish(a); //should publish
            ExpectMsg(b2);
            ExpectMsg(a);
            ExpectNoMsg(TimeSpan.FromSeconds(1));
        }
 public void TypeSwitch_ObjectB1_ParentTypeMatchedDefaultNotExecuted()
 {
     object item = new B1();
     bool referenceMatch = false;
     bool defaultExecuted = false;
     bool isOfTypeA = false;
     item.TypeSwitchOn()
         .Case<A>(x =>
         {
             referenceMatch = item == x;
             isOfTypeA = x is A;
         })
         .Default(x =>
         {
             defaultExecuted = true;
         });
     Assert.IsTrue(referenceMatch);
     Assert.IsTrue(isOfTypeA);
     Assert.IsFalse(defaultExecuted);
 }
 public void TypeSwitch_ObjectB1_ActualTypeMatchedAfterNonMatch()
 {
     object item = new B1();
     bool referenceMatch = false;
     bool defaultExecuted = false;
     bool isOfTypeA = false;
     bool isOfTypeB1 = false;
     bool isOfTypeB2 = false;
     item.TypeSwitchOn()
         .Case<B2>(x =>
         {
             isOfTypeB2 = x is B2;
         })
         .Case<B1>(x =>
         {
             referenceMatch = item == x;
             isOfTypeB1 = x is B1;
         })
         .Case<A>(x =>
         {
             isOfTypeA = x is A;
         })
         .Default(x =>
         {
             defaultExecuted = true;
         });
     Assert.IsTrue(referenceMatch);
     Assert.IsFalse(isOfTypeA);
     Assert.IsTrue(isOfTypeB1);
     Assert.IsFalse(isOfTypeB2);
     Assert.IsFalse(defaultExecuted);
 }
Exemple #8
0
 public void Test1()
 {
     B1 b = new B1();
    
     var a = Mapper.Map<B1,A1>(b);
     Assert.AreEqual(a.fld1, 15);
     Assert.AreEqual(a.fld2, "11");
 }
        public void ShouldReturnNullWhenCannotBeConverted()
        {
            var b1 = new B1(new A1());

            var a1 = b1.Convert(b => b.A as A2);

            Assert.IsNull(a1);
        }
Exemple #10
0
 public void Test_ClassToStruct()
 {
     B1 b = new B1();
     var a = Mapper.Map<B1, A1>(b);
     Assert.AreEqual(a.fld1, 10);
 }
Exemple #11
0
        public static void TestUseCase()
        {
            var a = new A();
            Assert.AreEqual(a, a, "Bridge692 A");

            var b1 = new B1();
            Assert.AreEqual(b1, b1, "Bridge692 B1");

            var b2 = new B1();
            Assert.AreEqual(b2, b2, "Bridge692 B2");

            var b3 = new B3();
            Assert.AreEqual(b3, b3, "Bridge692 B3");

            var c1 = new C1();
            Assert.AreNotStrictEqual(c1, c1, "Bridge692 C1");

            var c2 = new C2();
            Assert.AreNotStrictEqual(c2, c2, "Bridge692 C2");

            var c3 = new C3();
            Assert.AreNotStrictEqual(c3, c3, "Bridge692 C3");

            C3? c3_1 = new C3();
            Assert.AreNotStrictEqual(c3_1, c3_1, "Bridge692 C3_1");
        }
Exemple #12
0
 public static bool operator ==(BigInt B1, BigInt B2)
 {
     return(B1.Equals(B2));
 }
 protected B1(B1 copy) : base(copy)
 {
     this.Y1 = copy.Y1;
 }
Exemple #14
0
 public A1(V v, B1 b, C1 c)
 {
     B = b;
     C = c;
     V = v;
 }
Exemple #15
0
        private static void A(s1 s)
        {
            bool      flag = true;
            Rectangle rectangle2;
            bool      flag2;
            bool      flag3;

            using (a2 a = new a2())
            {
                Rectangle rectangle = s.G(flag);
                float     num       = 1.5f;
                a.A(new Size((int)((float)rectangle.Width * num), (int)((float)rectangle.Height * num)));
                a.A(false);
                if (a.ShowDialog() != DialogResult.OK)
                {
                    return;
                }
                rectangle2 = new Rectangle(0, 0, a.A().Width, a.A().Height);
                flag2      = a.A();
                flag3      = a.a();
            }
            object[][] array = new object[][]
            {
                new object[]
                {
                    ImageFormat.Png,
                    "Portable Network Graphics (*.png)",
                    "*.png"
                },
                new object[]
                {
                    ImageFormat.Bmp,
                    "Bitmap (*.bmp)",
                    "*.bmp"
                },
                new object[]
                {
                    ImageFormat.Tiff,
                    "Tag Image File (*.tif)",
                    "*.tif"
                },
                new object[]
                {
                    ImageFormat.Jpeg,
                    "Joint Photographic Experts Group (*.jpg)",
                    "*.jpg"
                }
            };
            if (flag2)
            {
                array = new object[][]
                {
                    array[0],
                    array[2]
                };
            }
            string text = "";

            object[][] array2 = array;
            for (int i = 0; i < array2.Length; i++)
            {
                object[] array3 = array2[i];
                if (text.Length > 0)
                {
                    text += "|";
                }
                object obj = text;
                text = string.Concat(new object[]
                {
                    obj,
                    "",
                    array3[1],
                    "|",
                    array3[2]
                });
            }
            int    num2  = 0;
            string text2 = y1.A(s.A().b(), 64);

            using (SaveFileDialog saveFileDialog = new SaveFileDialog())
            {
                saveFileDialog.Filter           = text;
                saveFileDialog.FilterIndex      = num2 + 1;
                saveFileDialog.RestoreDirectory = true;
                saveFileDialog.InitialDirectory = K1.A().A().RecentPicturePath;
                saveFileDialog.FileName         = text2;
                if (saveFileDialog.ShowDialog() == DialogResult.OK)
                {
                    num2  = saveFileDialog.FilterIndex - 1;
                    text2 = saveFileDialog.FileName;
                    K1.A().A().RecentPicturePath = Path.GetDirectoryName(saveFileDialog.FileName);
                }
            }
            Bitmap   bitmap   = new Bitmap(rectangle2.Width, rectangle2.Height);
            Color    white    = Color.White;
            Graphics graphics = Graphics.FromImage(bitmap);

            if (!flag2)
            {
                graphics.FillRectangle(new SolidBrush(white), graphics.ClipBounds);
            }
            B1 b = s.A().G(s, graphics, a1.Picture, flag2);

            s.H(rectangle2, 0f, b);
            bitmap.Save(text2, (ImageFormat)array[num2][0]);
            if (flag3)
            {
                try
                {
                    Process.Start(text2);
                }
                catch (Exception)
                {
                }
            }
        }