예제 #1
0
        public void XiangZhuanTest()
        {
            _ = new XiangZhuan("xiang.json");
            using var fileStream = new FileStream("xiang.json", FileMode.Open);
            var tuanzhuan = new XiangZhuan(fileStream);

            Zhouyi zhouyi = new Zhouyi();
            var    xiang  = tuanzhuan[zhouyi.GetHexagram(1)];

            Assert.AreEqual("天行健,君子以自强不息。", xiang);
            xiang = tuanzhuan[zhouyi.GetHexagram(64)];
            Assert.AreEqual("火在水上,未济。君子以慎辨物居方。", xiang);

            xiang = tuanzhuan[zhouyi.GetHexagram(2).ApplyNinesOrApplySixes];
            Assert.AreEqual("用六“永贞”,以大终也。", xiang);
            xiang = tuanzhuan[zhouyi.GetHexagram(1).SixthLine];
            Assert.AreEqual("“亢龙有悔”,盈不可久也。", xiang);
        }
        public void TuanzhuanTest()
        {
            _ = new Tuanzhuan("tuan.json");
            using var fileStream = new FileStream("tuan.json", FileMode.Open);
            var tuanzhuan = new Tuanzhuan(fileStream);

            Zhouyi zhouyi = new Zhouyi();
            var    tuan   = tuanzhuan[zhouyi.GetHexagram(1)];

            Assert.AreEqual("大哉乾元,万物资始,乃统天。" +
                            "云行雨施,品物流形。" +
                            "大明终始,六位时成。" +
                            "时乘六龙以御天。" +
                            "乾道变化,各正性命。" +
                            "保合大和,乃利贞。" +
                            "首出庶物,万国威宁。", tuan);
            tuan = tuanzhuan[zhouyi.GetHexagram(64)];
            Assert.AreEqual("“未济,亨”,柔得中也。" +
                            "“小狐汔济”,未出中也。" +
                            "“濡其尾,无攸利”,不续终也。" +
                            "虽不当位,刚柔应也。", tuan);
        }
        static void Main()
        {
            // Here we don't need a translation file for Zhouyi.
            Zhouyi zhouyi = new Zhouyi();

            // Here we use a combined translation file.
            XiangZhuan xiangZhuan = new XiangZhuan("zhuan.json");
            Tuanzhuan  tuanzhuan  = new Tuanzhuan("zhuan.json");

            var jian = zhouyi.GetHexagram(53);

            Console.WriteLine($"{tuanzhuan[jian]}---{xiangZhuan[jian]}---{xiangZhuan[jian.FirstLine]}");
            Console.WriteLine();
            // Output: 渐之进也,女归吉也。进得位,往有功也。进以正,可以正邦也。其位刚得中也。止而巽,动不穷也。---山上有木,渐。君子以居贤德 善俗。---“小子之厉”,义无咎也。
        }
        private static void Main(string[] args)
        {
            var zy = new Zhouyi("translation.json");
            List <ZhouyiHexagram> hexagrams = new List <ZhouyiHexagram>();

            for (int i = 0; i <= 0b111111; i++)
            {
                var str = Convert.ToString(i, 2).PadLeft(6, '0');
                _ = YiJingFramework.Core.Painting.TryParse(str, out var result);
                hexagrams.Add(zy.GetHexagram(result));
            }
            var linq = from hexagram in hexagrams
                       orderby hexagram.Index
                       select hexagram;

            foreach (var q in linq)
            {
                Console.Write(q.GetPainting().ToBytes()[0]);
                Console.Write(',');
            }
        }
예제 #5
0
        private static void Main()
        {
            // Here we read the translation from the resource.
            // You can also save the translation as a file and pass the it's path here.
            using var stream = new MemoryStream(Properties.Resources.translation);
            Zhouyi zhouyi = new Zhouyi(stream);

            _ = zhouyi.TryGetHexagram("同人", out var tongRen);
            Debug.Assert(tongRen is not null);
            Console.WriteLine(tongRen);
            Console.WriteLine(tongRen.SecondLine.YinYang);
            Console.WriteLine(tongRen.UpperTrigram.Nature);
            Console.WriteLine();
            // Outputs: 第十三卦 同人 天火同人 乾上离下
            // 同人于野,亨。利涉大川,利君子贞。
            // 初九:同人于门,无咎。
            // 六二:同人于宗,吝。
            // 九三:伏戎于莽,升其高陵,三岁不兴。
            // 九四:乘其墉,弗克攻,吉。
            // 九五:同人,先号啕而后笑。大师克相遇。
            // 上九:同人于郊,无悔。
            //
            // Yin
            // 天

            var tongRen2 = zhouyi.GetHexagram(new YiJingFramework.Core.Painting(
                                                  YiJingFramework.Core.YinYang.Yang,
                                                  YiJingFramework.Core.YinYang.Yin,
                                                  YiJingFramework.Core.YinYang.Yang,
                                                  YiJingFramework.Core.YinYang.Yang,
                                                  YiJingFramework.Core.YinYang.Yang,
                                                  YiJingFramework.Core.YinYang.Yang
                                                  ));

            Console.WriteLine(tongRen.Equals(tongRen2));
            Console.WriteLine();
            // Output: True
        }