Esempio n. 1
0
        /// <summary>
        /// Expanders' updater.
        /// </summary>
        /// <param name="expansionString">The expansion string.</param>
        /// <param name="expansionLabel">The expansion label.</param>
        /// <param name="expansionValue">The expansion value.</param>
        /// <param name="isMultiple">if set to <c>true</c> [is multiple].</param>
        /// <param name="delimiter">The delimiter.</param>
        public void ExpanderUpdater(string expansionString, string expansionLabel, int expansionValue, bool isMultiple = false, string delimiter = "")
        {
            IExpander expanderObject;

            if (ExpansionStringExists(expansionLabel))
            {
                expanderObject = GetExpanderObject(expansionLabel);
                expanderObject.ExpansionString = expansionString;
                expanderObject.ExpansionLabel  = expansionLabel;
                expanderObject.IsMultiple      = isMultiple;
                expanderObject.Delimiter       = delimiter;
            }
            else
            {
                expanderObject = new ExpanderObject
                {
                    ExpansionString = expansionString,
                    ExpansionLabel  = expansionLabel,
                    IsMultiple      = isMultiple,
                    Delimiter       = delimiter
                };
            }

            //var expander = new ExpanderObject
            //{
            //    ExpansionLabel = expansionLabel,
            //    ExpansionString = expansionString,
            //    ExpansionValue = expansionValue,
            //    IsMultiple = isMultiple,
            //    Delimiter = delimiter
            //};
            UpdateExpander(expanderObject);
        }
Esempio n. 2
0
        /// <summary>
        /// Updates the expander.
        /// </summary>
        /// <param name="expander">The expander.</param>
        public void UpdateExpander(IExpander expander)
        {
            var config = new MapperConfiguration(cfg => cfg.CreateMap <IExpander, IExpander>());
            var mapper = config.CreateMapper();

            var row = _expander
                      .Where((x => x.ExpansionLabel.Trim() == expander.ExpansionLabel))
                      .FirstOrDefault();

            if (row != null) //We have a matching item
            {
                var pos = _expander.IndexOf(row);

                row = mapper.Map <IExpander>(expander);
                row.UpdatedByNanite = true;
                _expander[pos]      = row;
            }
            else
            {
                IExpander expanderObject = new ExpanderObject
                {
                    ExpansionLabel  = expander.ExpansionLabel,
                    ExpansionString = expander.ExpansionString,
                    ExpansionValue  = expander.ExpansionValue,
                    IsMultiple      = expander.IsMultiple,
                    Delimiter       = expander.Delimiter,
                    UpdatedByNanite = true
                };
                //expanderObject = mapper.Map<IExpander>(expander);
                //expanderObject.UpdatedByNanite = true;

                _expander.Add(expanderObject);
            }
        }