/// <summary> /// Возвращает коллекцию RuleElement запрашиваемого общего правила. /// </summary> /// <param name="request"></param> /// <returns></returns> public static IEnumerable <RuleElement> GetCommonRuleChildren(this TypiconEntity typicon, CommonRuleServiceRequest request) { if (request == null || request.RuleSerializer == null) { throw new ArgumentNullException("CommonRuleServiceRequest"); } CommonRule commonRule = typicon.GetCommonRule(c => c.Name == request.Key); if (commonRule == null) { throw new NullReferenceException("CommonRule"); } if (!commonRule.IsValid) { //if (request.Handler.Settings.ThrowExceptionIfInvalid) //{ // commonRule.ThrowExceptionIfInvalid(); //} //else //{ return(new List <RuleElement>()); //} } var container = commonRule.GetRule <ExecContainer>(request.RuleSerializer); return((container != null) ? container.ChildElements : new List <RuleElement>()); }
/// <summary> /// Возвращает строку из Правила, представляющего из себя коллекцию TextHolder, согласно индекса /// </summary> /// <param name="typicon"></param> /// <param name="request"></param> /// <param name="index">Номер TextHolder-ы в коллекции Правила</param> /// <returns></returns> public static string GetCommonRuleIndexedString(this TypiconEntity typicon, CommonRuleServiceRequest request, int index, string language) { string result = ""; if (GetCommonRuleChildren(typicon, request).ElementAtOrDefault(index) is TextHolder t && t.Paragraphs?.Count > 0) { result = t.Paragraphs[0]?[language]; } return(result); }
public TypiconEntity GetOwner() { TypiconEntity result = Owner; if ((result == null) && (Parent != null)) { return(Parent.GetOwner()); } return(result); }
/// <summary> /// Возвращает строку из системного правила, где определен только один элемент ItemText /// </summary> /// <param name="request"></param> /// <returns></returns> public static string GetCommonRuleTextValue(this TypiconEntity typicon, CommonRuleServiceRequest request, string language) { return(GetCommonRuleItemTextValue(typicon, request)[language]); }
/// <summary> /// Возвращает строку из системного правила, где определен только один элемент ItemText /// </summary> /// <param name="request"></param> /// <returns></returns> public static ItemText GetCommonRuleItemTextValue(this TypiconEntity typicon, CommonRuleServiceRequest request) { TextHolder textHolder = (TextHolder)GetCommonRuleChildren(typicon, request).FirstOrDefault(); return((textHolder?.Paragraphs.Count > 0) ? textHolder.Paragraphs[0] : new ItemText()); }