コード例 #1
0
ファイル: SqlInterface.cs プロジェクト: melnx/Bermuda
        private void AddDatasourceMention(DatasourceMention datasourceMention)
        {
            if (datasourceMention.IsDisabled)
            {
                DatasourceMention dm;
                DatasourceMentions.TryRemove(datasourceMention.Id, out dm);
                ConcurrentDictionary <long, long> dml;
                if (MentionDatasourceLookup.TryRemove(datasourceMention.MentionId, out dml))
                {
                    long id;
                    dml.TryRemove(datasourceMention.DatasourceId, out id);
                }
                Mention m;
                if (Mentions.TryGetValue(datasourceMention.MentionId, out m))
                {
                    if (m.Datasources.Contains(datasourceMention.DatasourceId))
                    {
                        m.Datasources.Remove(datasourceMention.DatasourceId);
                    }
                }
            }
            else
            {
                if (!ReferenceEquals(DatasourceMentions.AddOrUpdate(datasourceMention.Id, datasourceMention, (x, y) => y), datasourceMention))
                {
                    return;
                }

                MentionDatasourceLookup.AddOrUpdate(datasourceMention.MentionId,
                                                    new ConcurrentDictionary <long, long>(new KeyValuePair <long, long>[] { new KeyValuePair <long, long>(datasourceMention.DatasourceId, datasourceMention.Id) }),
                                                    (x, y) => { y.AddOrUpdate(datasourceMention.DatasourceId, datasourceMention.Id, (j, k) => { return(k); }); return(y); });

                Mention mention;

                if (!Mentions.TryGetValue(datasourceMention.MentionId, out mention))
                {
                    return;
                }

                if (mention.Datasources == null || !mention.Datasources.Contains(datasourceMention.DatasourceId))
                {
                    if (mention.Datasources == null)
                    {
                        mention.Datasources = new List <long>();
                    }
                    mention.Datasources.Add(datasourceMention.DatasourceId);
                }
            }
        }
コード例 #2
0
ファイル: SqlInterface.cs プロジェクト: yonglehou/Bermuda
        private void AddDatasourceMention(DatasourceMention datasourceMention)
        {
            if (datasourceMention.IsDisabled)
            {
                DatasourceMention dm;
                DatasourceMentions.TryRemove(datasourceMention.Id, out dm);
                ConcurrentDictionary<long, long> dml;
                if (MentionDatasourceLookup.TryRemove(datasourceMention.MentionId, out dml))
                {
                    long id;
                    dml.TryRemove(datasourceMention.DatasourceId, out id);
                }
                Mention m;
                if (Mentions.TryGetValue(datasourceMention.MentionId, out m))
                {
                    if (m.Datasources.Contains(datasourceMention.DatasourceId))
                        m.Datasources.Remove(datasourceMention.DatasourceId);
                }
            }
            else
            {
                if (!ReferenceEquals(DatasourceMentions.AddOrUpdate(datasourceMention.Id, datasourceMention, (x, y) => y), datasourceMention))
                {
                    return;
                }

                MentionDatasourceLookup.AddOrUpdate(datasourceMention.MentionId,
                    new ConcurrentDictionary<long, long>(new KeyValuePair<long, long>[] { new KeyValuePair<long, long>(datasourceMention.DatasourceId, datasourceMention.Id) }),
                    (x, y) => { y.AddOrUpdate(datasourceMention.DatasourceId, datasourceMention.Id, (j, k) => { return k; }); return y; });

                Mention mention;

                if (!Mentions.TryGetValue(datasourceMention.MentionId, out mention))
                {
                    return;
                }

                if (mention.Datasources == null || !mention.Datasources.Contains(datasourceMention.DatasourceId))
                {
                    if (mention.Datasources == null) mention.Datasources = new List<long>();
                    mention.Datasources.Add(datasourceMention.DatasourceId);
                }
            }
        }