示例#1
0
        public void Import(IEnumerable <IAlarm> alarms, bool deleteExisting)
        {
            lock (this.cache)
                try
                {
                    this.pauseRepositoryUpdates = true;
                    if (deleteExisting)
                    {
                        foreach (var alarm in this.cache.Values.ToArray())
                        {
                            this.Remove(alarm);
                        }
                    }

                    this.RefreshRepository();
                    var equityComparer = new AlarmMetadataEqualityComparer();
                    foreach (var alarm in alarms)
                    {
                        if (!this.cache.Values.Contains(alarm, equityComparer))
                        {
                            this.Add(alarm);
                        }
                    }
                }
                finally
                {
                    this.pauseRepositoryUpdates = false;
                    this.UpdateRepository();
                }
        }
示例#2
0
        public void Import(IEnumerable<IAlarm> alarms, bool deleteExisting)
        {
            lock (this.cache)
            try
            {
                this.pauseRepositoryUpdates = true;
                if (deleteExisting)
                {
                    foreach (var alarm in this.cache.Values.ToArray())
                    {
                        this.Remove(alarm);
                    }
                }

                this.RefreshRepository();
                var equityComparer = new AlarmMetadataEqualityComparer();
                foreach(var alarm in alarms)
                {
                    if (!this.cache.Values.Contains(alarm, equityComparer))
                        this.Add(alarm);
                }
            }
            finally
            {
                this.pauseRepositoryUpdates = false;
                this.UpdateRepository();
            }
        }