aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.DAL.Observables/LoadedObjectsService.cs
blob: dbd44b1e772a755a01b72e0980a98b5db8b67174 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Tango.DAL.Observables
{
    internal static class LoadedObjectsService
    {
        private static List<KeyValuePair<String, IObservableEntity>> LoadedObjects;

        public static Object Get(String guid)
        {
            return LoadedObjects.SingleOrDefault(x => x.Key == guid).Value;
        }

        public static void Add(String guid, IObservableEntity observable)
        {
            if (!LoadedObjects.Exists(x => x.Key == guid))
            {
                LoadedObjects.Add(new KeyValuePair<string, IObservableEntity>(guid, observable));
            }
        }

        public static bool Exists(String guid)
        {
            return LoadedObjects.Exists(x => x.Key == guid);
        }

        public static void Reset()
        {
            LoadedObjects.Clear();
        }

        static LoadedObjectsService()
        {
            LoadedObjects = new List<KeyValuePair<String, IObservableEntity>>();
        }
    }
}