Exemplo n.º 1
0
 public ItemText(ItemText source)
 {
     foreach (KeyValuePair <string, string> entry in source._textDict)
     {
         AddElement(entry.Key, entry.Value);
     }
 }
        /// <summary>
        ///
        /// </summary>
        /// <param name="source"></param>
        /// <param name="symbol">Строковое значение для разделения элементов</param>
        /// <param name="values"></param>
        public static ItemText Merge(this ItemText source, string symbol, params ItemText[] values)
        {
            if (source == null || values == null || values.Count() == 0)
            {
                return(source);
            }

            foreach (var value in values)
            {
                foreach (ItemTextUnit item in value.Items)
                {
                    var found = source.Items.FirstOrDefault(c => c.Language == item.Language);
                    if (found != null)
                    {
                        found.Text += $"{symbol}{item.Text}";
                    }
                    else
                    {
                        source.AddOrUpdate(item.Language, item.Text);
                    }
                }
            }

            return(source);
        }
Exemplo n.º 3
0
        //protected override ItemText Deserialize(string exp) => Serializer.Deserialize<ItemTextNoted>(exp, RootName);

        //protected override string Serialize() => Serializer.Serialize(this, RootName);

        protected override void Build(ItemText source)
        {
            base.Build(source);

            if (source is ItemTextNoted s)
            {
                Note = s.Note;
            }
        }
        /// <summary>
        /// Заменяет для всех языков строковое значение на соответствующее переведенное целочисленное
        /// </summary>
        /// <param name="source"></param>
        /// <param name="oldValue"></param>
        /// <param name="integer"></param>
        public static void ReplaceForEach(this ItemText source, string oldValue, int integer)
        {
            foreach (var item in source.Items)
            {
                var newValue = LanguageSettingsFactory.Create(item.Language).IntConverter.ToString(integer);

                item.Text = item.Text.Replace(oldValue, newValue);
            }
        }
Exemplo n.º 5
0
        //protected override ItemText Deserialize(string exp) => Serializer.Deserialize<ItemTextHeader>(exp, RootName);

        //protected override string Serialize() => Serializer.Serialize(this, RootName);

        protected override void Build(ItemText source)
        {
            base.Build(source);

            if (source is ItemTextHeader s)
            {
                Header = s.Header;
            }
        }
Exemplo n.º 6
0
        //protected override ItemText Deserialize(string exp) => Serializer.Deserialize<ItemTextStyled>(exp, RootName);

        //protected override string Serialize() => Serializer.Serialize(this);//, RootName);

        protected override void Build(ItemText source)
        {
            base.Build(source);

            if (source is ItemTextStyled s)
            {
                IsBold   = s.IsBold;
                IsItalic = s.IsItalic;
                IsRed    = s.IsRed;
            }
        }
        /// <summary>
        /// Заменяет для каждого языка старое значение на новое, уникальное для языка
        /// </summary>
        /// <param name="source"></param>
        /// <param name="oldValue"></param>
        /// <param name="value"></param>
        public static void ReplaceForEach(this ItemText source, string oldValue, ItemText value)
        {
            if (source == null || value == null || value.IsEmpty)
            {
                return;
            }

            foreach (var item in source.Items)
            {
                var found = value.Items.FirstOrDefault(c => c.Language == item.Language);
                if (found != null)
                {
                    item.Text = item.Text.Replace(oldValue, found.Text);
                }
            }
        }
Exemplo n.º 8
0
        //public ItemTextNoted(ITypiconSerializer serializer) : base(serializer) { }

        //public ItemTextNoted(string exp) : base(exp) { }

        //public ItemTextNoted(string exp, string rootName) : base(exp, rootName) { }

        public ItemTextNoted(ItemText source) : base(source)
        {
        }
 /// <summary>
 /// Соединяет последовательно все значения по каждому языку
 /// </summary>
 /// <param name="source"></param>
 /// <param name="values"></param>
 public static ItemText Merge(this ItemText source, params ItemText[] values)
 {
     return(source.Merge(" ", values));
 }
Exemplo n.º 10
0
 public static void ReplaceValues(this ItemText item, ItemText replace)
 {
     item.Items.Clear();
     replace?.Items.ForEach(c => item.AddOrUpdate(c));
 }
Exemplo n.º 11
0
 /// <summary>
 /// Возвращает первое строковое значение Text.
 /// Используется в локализованных версиях
 /// </summary>
 /// <param name="item"></param>
 /// <returns></returns>
 public static string GetLocal(this ItemText item) => item.Items.FirstOrDefault()?.Text;
Exemplo n.º 12
0
        //public ItemTextHeader(ITypiconSerializer serializer) : base(serializer) { }

        //public ItemTextHeader(string exp) : base(exp) { }

        //public ItemTextHeader(string exp, string rootName) : base(exp, rootName) { }

        public ItemTextHeader(ItemText source) : base(source)
        {
        }
Exemplo n.º 13
0
 public ItemTextStyled(ItemText source) : base(source)
 {
 }