예제 #1
0
        public SingleAsset <TAsset> GetSingle <TAsset>() where TAsset : Asset
        {
            var typeId = Typeof <TAsset> .Id;

            object singleAsset;

            using (Lock.Enter(_singleAssets))
            {
                // ReSharper disable once InvertIf
                if (!_singleAssets.TryGetValue(typeId, out singleAsset))
                {
                    singleAsset = new SingleAsset <TAsset>(_assets);
                    _singleAssets.Add(typeId, singleAsset);
                }
            }

            return((SingleAsset <TAsset>)singleAsset);
        }
예제 #2
0
 public SingleAssetShould()
 {
     _asset  = new TestAsset(1, Array.Empty <IComponent>());
     _single = new SingleAsset <TestAsset>(new Asset[] { _asset });
 }