internal ZhouyiHexagram(PatternsAndNumbers patterns, int index, string name, string text, string?applyNinesOrApplySixes, ZhouyiTrigram lowerTrigram, ZhouyiTrigram upperTrigram, string[] lines) { this.Patterns = patterns; this.Text = text; this.Index = index; this.Name = name; var trigram = lowerTrigram.GetPainting(); this.FirstLine = new Line(this, 1, trigram[0], lines[0]); this.SecondLine = new Line(this, 2, trigram[1], lines[1]); this.ThirdLine = new Line(this, 3, trigram[2], lines[2]); trigram = upperTrigram.GetPainting(); this.FourthLine = new Line(this, 4, trigram[0], lines[3]); this.FifthLine = new Line(this, 5, trigram[1], lines[4]); this.SixthLine = new Line(this, 6, trigram[2], lines[5]); this.LowerTrigram = lowerTrigram; this.UpperTrigram = upperTrigram; if (applyNinesOrApplySixes is not null) { this.ApplyNinesOrApplySixes = new Line(this, 0, trigram[0], applyNinesOrApplySixes); } }
/// <summary> /// 通过卦名获取经卦。 /// 如果有卦名重复,不保证顺序。 /// Get a trigram by its name. /// If some trigrams' names are duplicate, the order is not guaranteed. /// </summary> /// <param name="name"> /// 卦名。 /// The name. /// </param> /// <param name="result"> /// 结果。 /// The result. /// </param> /// <returns> /// 一个值,指示是否获取成功。 /// A value indicates whether the trigram has been found or not. /// </returns> /// <exception cref="ArgumentNullException"> /// <paramref name="name"/> 是 <c>null</c> 。 /// <paramref name="name"/> is <c>null</c>. /// </exception> public bool TryGetTrigram(string name, [MaybeNullWhen(false)] out ZhouyiTrigram result) { if (name is null) { throw new ArgumentNullException(nameof(name)); } return(this.trigramsAndHexagrams.TryGetTrigramByName(name, out result)); }