public ValueOfSomeTypeExpression(ValueOfSomeTypeExpressionRoot root, Type type, TreeExpression path, Kind2 kind2) { Root = root; Type = type; Expression = path; Kind2 = kind2; }
private void Scan(ValueOfSomeTypeExpressionRoot root, XUnitTypeName x, Kind2 kind, ExpressionPath path = null) { if (!_resolver.TryGetValue(x.GetTypename(), out var type)) { throw new NotImplementedException(); } var info1 = new ValueOfSomeTypeExpression(root, type, new TreeExpression(path, null, kind), kind); _sink.Add(info1); if (kind != Kind2.Property) { return; } foreach (var propInfo in type.GetProperties()) { var attribute = propInfo.GetCustomAttribute <RelatedUnitSourceAttribute>(); if (attribute != null && attribute.Usage == RelatedUnitSourceUsage.DoNotUse) { continue; } var pt = propInfo.PropertyType; if (!pt.Implements <IUnit>()) { continue; } Scan(root, new XUnitTypeName(propInfo.PropertyType.Name), kind, path + propInfo.Name); } foreach (var methodInfo in type.GetMethods(BindingFlags.Instance | BindingFlags.Public)) { var at = methodInfo.GetCustomAttribute <RelatedUnitSourceAttribute>(); if (at is null || (at.Usage & RelatedUnitSourceUsage.ProvidesRelatedUnit) == 0) { continue; } var returnType = methodInfo.ReturnType; if (!returnType.Implements <IUnit>()) { throw new Exception("Should return IUnit"); } if (methodInfo.GetParameters().Length != 0) { throw new Exception("Should be parameterles"); } Scan(root, new XUnitTypeName(returnType.Name), Kind2.Method, path + $"{methodInfo.Name}"); } }
public TreeExpression(ExpressionPath path, IReadOnlyList <ExpressionPath> arguments, Kind2 kind) { Path = path; Kind = kind; Arguments = arguments ?? new ExpressionPath[0]; }
public override string ToString(bool shortVariant, Pullenti.Morph.MorphLang lang, int lev = 0) { StringBuilder res = new StringBuilder(); InstrumentKind ki = Kind; string str; str = Pullenti.Ner.Instrument.Internal.MetaInstrumentBlock.GlobalMeta.KindFeature.ConvertInnerValueToOuterValue(ki.ToString(), lang) as string; if (str != null) { res.Append(str); if (Kind2 != InstrumentKind.Undefined) { str = Pullenti.Ner.Instrument.Internal.MetaInstrumentBlock.GlobalMeta.KindFeature.ConvertInnerValueToOuterValue(Kind2.ToString(), lang) as string; if (str != null) { res.AppendFormat(" ({0})", str); } } } if (Number > 0) { if (ki == InstrumentKind.Table) { res.AppendFormat(" {0} строк, {1} столбцов", Children.Count, Number); } else { res.AppendFormat(" №{0}", Number); if (SubNumber > 0) { res.AppendFormat(".{0}", SubNumber); if (SubNumber2 > 0) { res.AppendFormat(".{0}", SubNumber2); if (SubNumber3 > 0) { res.AppendFormat(".{0}", SubNumber3); } } } if (MinNumber > 0) { for (int i = res.Length - 1; i >= 0; i--) { if (res[i] == ' ' || res[i] == '.') { res.Insert(i + 1, string.Format("{0}-", MinNumber)); break; } } } } } bool ignoreRef = false; if (IsExpired) { res.Append(" (утратить силу)"); ignoreRef = true; } else if (ki != InstrumentKind.Editions && ki != InstrumentKind.Approved && (Ref is Pullenti.Ner.Decree.DecreeReferent)) { res.Append(" (*)"); ignoreRef = true; } if ((((str = this.GetStringValue(ATTR_NAME)))) == null) { str = this.GetStringValue(ATTR_VALUE); } if (str != null) { if (str.Length > 100) { str = str.Substring(0, 100) + "..."; } res.AppendFormat(" \"{0}\"", str); } else if (!ignoreRef && (Ref is Pullenti.Ner.Referent) && (lev < 30)) { res.AppendFormat(" \"{0}\"", Ref.ToString(shortVariant, lang, lev + 1)); } return(res.ToString().Trim()); }