Ejemplo n.º 1
0
        /// <summary>
        /// Преобразовать внутреннее значение в строку указанного языка
        /// </summary>
        /// <param name="lang">язык</param>
        /// <return>значение</return>
        public string ConvertValueToString(Pullenti.Morph.MorphLang lang)
        {
            if (Value == null)
            {
                return(null);
            }
            Pullenti.Ner.Metadata.Feature attr = DefiningFeature;
            if (attr == null)
            {
                return(Value.ToString());
            }
            object v = (object)attr.ConvertInnerValueToOuterValue(Value.ToString(), lang);

            if (v == null)
            {
                return(null);
            }
            if (v is string)
            {
                return(v as string);
            }
            else
            {
                return(v.ToString());
            }
        }
Ejemplo n.º 2
0
        public string ToString(Pullenti.Morph.MorphLang lang)
        {
            StringBuilder res = new StringBuilder();

            Pullenti.Ner.Metadata.Feature attr = DefiningFeature;
            if (attr != null)
            {
                if (Count > 0)
                {
                    res.AppendFormat("{0} ({1}): ", attr.Caption, Count);
                }
                else
                {
                    res.AppendFormat("{0}: ", attr.Caption);
                }
            }
            else
            {
                res.AppendFormat("{0}: ", TypeName);
            }
            if (Value != null)
            {
                if (Value is Referent)
                {
                    res.Append((Value as Referent).ToString(false, lang, 0));
                }
                else if (attr == null)
                {
                    res.Append(Value.ToString());
                }
                else
                {
                    res.Append(attr.ConvertInnerValueToOuterValue(Value.ToString(), null));
                }
            }
            return(res.ToString());
        }