i18n.Domain.Concrete.FileNuggetFinder.AddNewTemplateItem C# (CSharp) Method

AddNewTemplateItem() private method

private AddNewTemplateItem ( string fileName, ReferenceContext referenceContext, Nugget nugget, TemplateItem>.ConcurrentDictionary templateItems ) : void
fileName string
referenceContext i18n.Domain.Entities.ReferenceContext
nugget i18n.Helpers.Nugget
templateItems TemplateItem>.ConcurrentDictionary
return void
        private void AddNewTemplateItem(
            string fileName,
            ReferenceContext referenceContext,
            Nugget nugget, 
            ConcurrentDictionary<string, TemplateItem> templateItems)
        {
            string msgid = nugget.MsgId.Replace("\r\n", "\n").Replace("\r", "\\n");
                // NB: In memory msgids are normalized so that LFs are converted to "\n" char sequence.
            string key = TemplateItem.KeyFromMsgidAndComment(msgid, nugget.Comment, _settings.MessageContextEnabledFromComment);
            List<string> tmpList;
               //
            templateItems.AddOrUpdate(
                key,
                // Add routine.
                k => {
                    TemplateItem item = new TemplateItem();
                    item.MsgKey = key;
                    item.MsgId = msgid;
                    item.FileName = fileName;

                    item.References = new List<ReferenceContext> {referenceContext};

                    if (nugget.Comment.IsSet()) {
                        tmpList = new List<string>();
                        tmpList.Add(nugget.Comment);
                        item.Comments = tmpList;
                    }

                    return item;
                },
                // Update routine.
                (k, v) =>
                {
                    if (!_settings.DisableReferences)
                    {
                        var newReferences = new List<ReferenceContext>(v.References.ToList());
                        newReferences.Add(referenceContext);
                        v.References = newReferences;
                    }

                    if (nugget.Comment.IsSet()) {
                        tmpList = v.Comments != null ? v.Comments.ToList() : new List<string>();
                        if (!_settings.DisableReferences || !tmpList.Contains(nugget.Comment))
                            tmpList.Add(nugget.Comment);
                        v.Comments = tmpList;
                    }

                    return v;
                });
        }