< Summary

Class:DCL.DataStore
Assembly:DataStore
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/DataStore/DataStore.cs
Covered lines:28
Uncovered lines:4
Coverable lines:32
Total lines:60
Line coverage:87.5% (28 of 32)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
DataStore()0%110100%
DataStore()0%110100%
Set[T](...)0%2.52050%
Get[T]()0%220100%
Clear()0%110100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/DataStore/DataStore.cs

#LineLine coverage
 1using System;
 2using System.Collections.Generic;
 3
 4namespace DCL
 5{
 6    public enum AppMode
 7    {
 8        DEFAULT,
 9        BUILDER_IN_WORLD_EDITION
 10    }
 11
 12    public class DataStore
 13    {
 114        private static DataStore instance = new DataStore();
 15
 256016        public static DataStore i { get => instance; }
 17
 89818        private Dictionary<Type, object> dataStores = new Dictionary<Type, object>();
 19
 20        public void Set<T>(T data) where T : class
 21        {
 710222            if (!dataStores.ContainsKey(typeof(T)))
 710223                dataStores.Add(typeof(T), data);
 24            else
 025                dataStores[typeof(T)] = data;
 026        }
 27
 28        public T Get<T>() where T : class, new()
 29        {
 13425730            if (!dataStores.ContainsKey(typeof(T)))
 710231                Set(new T());
 32
 13425733            return dataStores[typeof(T)] as T;
 34        }
 35
 86536        public static void Clear() => instance = new DataStore();
 37
 2093838        public DataStore_Common common => i.Get<DataStore_Common>();
 254439        public DataStore_Realm realm => i.Get<DataStore_Realm>();
 449740        public DebugConfig debugConfig => i.Get<DebugConfig>();
 74341        public DataStore_BuilderInWorld builderInWorld => i.Get<DataStore_BuilderInWorld>();
 84342        public DataStore_Quests Quests => i.Get<DataStore_Quests>();
 637243        public DataStore_HUDs HUDs => i.Get<DataStore_HUDs>();
 218644        public DataStore_Player player => i.Get<DataStore_Player>();
 5445        public DataStore_AvatarsLOD avatarsLOD => i.Get<DataStore_AvatarsLOD>();
 528846        public DataStore_VirtualAudioMixer virtualAudioMixer => i.Get<DataStore_VirtualAudioMixer>();
 817847        public DataStore_Screen screen => i.Get<DataStore_Screen>();
 048        public DataStore_WSCommunication wsCommunication => i.Get<DataStore_WSCommunication>();
 258649        public DataStore_WorldObjects sceneWorldObjects => i.Get<DataStore_WorldObjects>();
 6411050        public DataStore_ExploreV2 exploreV2 => i.Get<DataStore_ExploreV2>();
 152151        public DataStore_FeatureFlag featureFlags => i.Get<DataStore_FeatureFlag>();
 1093552        public DataStore_Camera camera => i.Get<DataStore_Camera>();
 73753        public DataStore_Settings settings => i.Get<DataStore_Settings>();
 5854        public DataStore_SkyboxConfig skyboxConfig => i.Get<DataStore_SkyboxConfig>();
 055        public ServerTime.WorldTimer worldTimer => i.Get<ServerTime.WorldTimer>();
 99556        public DataStore_Performance performance => i.Get<DataStore_Performance>();
 10257        public DataStore_ExperiencesViewer experiencesViewer => i.Get<DataStore_ExperiencesViewer>();
 130458        public DataStore_Emotes emotes => i.Get<DataStore_Emotes>();
 59    }
 60}