Пример #1
0
        public void DoSample3()
        {
            string path = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
            var    pdf  = Sample3.GetSample(path);

            pdf.Output("sample3.pdf", OutputDevice.SaveToFile);
        }
Пример #2
0
        public FileStreamResult GetSample3()
        {
            var pdf = Sample3.GetSample(null, CurrentPath);

            pdf.Buffer.BaseStream.Seek(0, SeekOrigin.Begin);
            var result = new FileStreamResult(pdf.Buffer.BaseStream, "application/pdf");

            return(result);
        }
Пример #3
0
        public FileStreamResult GetSample3()
        {
            var          pdf    = Sample3.GetSample(Server.MapPath("../bin"));
            string       s      = pdf.Output("ap.pdf", OutputDevice.ReturnAsString);
            MemoryStream m      = new MemoryStream(FPdf.PrivateEncoding.GetBytes(s));
            var          result = new FileStreamResult(m, "application/pdf");

            return(result);
        }
Пример #4
0
        public FileStreamResult GetSample3()
        {
            var buffer = Sample3.GetSample(null, CurrentPath);

            buffer.Seek(0, SeekOrigin.Begin);
            var result = new FileStreamResult(buffer, "application/pdf");

            return(result);
        }
Пример #5
0
        static void Main(string[] args)
        {
            ISample sample1 = new Sample1();

            sample1.SayHello("小明");


            ISample sample2 = new Sample2();

            sample2.SayHello("Mike");


            ISample sample3 = new Sample3();

            sample3.SayHello("山本桑");


            Console.WriteLine("==== new 关键字 测试 ===");

            AbstractSample sample3a = new Sample3();

            sample3a.SayHello("山本桑");
            sample3a.SayEnd();

            Sample3 sample3b = new Sample3();

            sample3b.SayHello("山本桑");
            sample3b.SayEnd();



            Console.WriteLine("==== override 与 new 的区别 ===");


            Console.WriteLine("卡=普通卡!");
            Card card1 = new NormalCard();

            card1.LineUp();
            card1.TakeMoney();

            Console.WriteLine("卡=金卡!");
            Card card2 = new GoldCard();

            card2.LineUp();
            card2.TakeMoney();

            Console.WriteLine("金卡=金卡!");
            GoldCard card3 = new GoldCard();

            card3.LineUp();
            card3.TakeMoney();


            Console.ReadLine();
        }
Пример #6
0
        static void Main(string[] args)
        {
            var sample1 = new Sample1();
            var sample2 = new Sample2();
            var sample3 = new Sample3();

            var sp = new SamplePrint();

            sp.Print(sample1);
            sp.Print(sample2);
            sp.Print(sample3);
        }
 public ComplexSample(ISample2 sample2, Sample3 sample3)
 {
     Sample2 = sample2;
     Sample3 = sample3;
 }
Пример #8
0
 public static void Run2()
 {
     Console.WriteLine(Sample3.add4(1, 2, 3, 4));
 }
Пример #9
0
        public void TestNested()
        {
            var js = new JsonSerializer();
            js.Options.TagMode = TagMode.Names;

            var v = new Sample3 {
                S1 = new Sample1 { X = 345, Y = "test" },
                F = 222,
                S2 = new Sample2 { X = -346, Y = "test1" },
            };
            js.JsonOptions.Indent = "";

            var result = js.ToString(v);
            Assert.AreEqual(
                "{\n\"S1\":" +
                "{\n\"X\":345,\n\"Y\":\"test\"\n},\n" +
                "\"F\":222,\n" +
                "\"S2\":" +
                "{\n\"X\":-346,\n\"Y\":\"test1\"\n}\n" +
                "}",
                result);

            var jd = new JsonDeserializer();
            jd.Options.TagMode = TagMode.Names;
            var w = new Sample3();
            jd.FromString(w, result);
            Assert.AreEqual(v.S1.X, w.S1.X);
            Assert.AreEqual(v.S1.Y, w.S1.Y);
            Assert.AreEqual(v.F, w.F);
            Assert.AreEqual(v.S2.X, w.S2.X);
            Assert.AreEqual(v.S2.Y, w.S2.Y);
        }
Пример #10
0
        public void TestNested()
        {
            var bs = new BinarySerializer();
            bs.Options.TagMode = TagMode.Names;

            var v = new Sample3 {
                S1 = new Sample1 { X = 345, Y = "test" },
                F = 222,
                S2 = new Sample2 { X = -346, Y = "test1" },
            };

            var result = bs.ToBytes(v);
            Assert.AreEqual(
                "20 01 00 " + XS(typeof(Sample3)) + " 03 00 " +
                XS("S1", RoughType.Record, "F", RoughType.Int, "S2", RoughType.Record) +
                " 01 00 02 00 " + XS(typeof(Sample1)) +
                " 02 00 " + XS("X", RoughType.Int, "Y", RoughType.String) +
                " 01 00 59 01 00 00 02 00 " + XS("test") + " 00 00 " +
                "02 00 DE 00 00 00 " +
                "03 00 03 00 " + XS(typeof(Sample2)) +
                " 02 00 " + XS("X", RoughType.Int, "Y", RoughType.String) +
                " 01 00 A6 FE FF FF 02 00 " + XS("test1") + " 00 00 00 00",
                XS(result));

            var bd = new BinaryDeserializer();
            bd.Options.TagMode = TagMode.Names;
            var w = new Sample3();
            bd.FromBytes(w, result);
            Assert.AreEqual(v.S1.X, w.S1.X);
            Assert.AreEqual(v.S1.Y, w.S1.Y);
            Assert.AreEqual(v.F, w.F);
            Assert.AreEqual(v.S2.X, w.S2.X);
            Assert.AreEqual(v.S2.Y, w.S2.Y);
        }
Пример #11
0
    public static void ShowExample()
    {
        Sample3 wnd = GetWindow <Sample3>();

        wnd.titleContent = new GUIContent("Sample3");
    }
Пример #12
0
 static void Main(string[] args)
 {
     Console.WriteLine(Sample1.add(1, 2));
     Console.WriteLine(Sample2.multiply(3, 5));
     Console.WriteLine(Sample3.divied(10, 2));
 }
Пример #13
0
 public void DoSample3()
 {
     Sample3.GetSample("sample3.pdf", GetPath());
 }