/// <summary> /// 通过卦名获取别卦。 /// 如果有卦名重复,不保证顺序。 /// Get a hexagram by its name. /// If some hexagrams' 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 hexagram 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 TryGetHexagram(string name, [MaybeNullWhen(false)] out ZhouyiHexagram result) { if (name is null) { throw new ArgumentNullException(nameof(name)); } var index = this.trigramsAndHexagrams.TryGetHexagram(name, out var t); if (index != -1) { Debug.Assert(t is not null); var tri = this.hexagramsTrigramsMap.GetTrigrams(index); result = new ZhouyiHexagram(this.patternsAndNumbers, index, t.Name, t.Text, t.ApplyNinesOrSixes, this.trigramsAndHexagrams.GetTrigram(tri.lower), this.trigramsAndHexagrams.GetTrigram(tri.upper), t.Lines); return(true); } result = null; return(false); }
internal Line(ZhouyiHexagram from, int index, Core.YinYang attribute, string text) { this.From = from; this.LineIndex = index; this.YinYang = attribute; this.LineText = text; }