public async Task <T> GetAsync <T>() where T : class { var singleton = SingletonProvider.Get <T>(); if (singleton == null) { return(null); } return((T)await ContentGetter.GetAsync(singleton.ContentTypeId, singleton.KeyValues).ConfigureAwait(false)); }
public async Task <object> GetAsync(string contentTypeId) { var singleton = SingletonProvider.Get(contentTypeId); if (singleton == null) { return(null); } return(await ContentGetter.GetAsync(singleton.ContentTypeId, singleton.KeyValues).ConfigureAwait(false)); }
public T Get <T>(string language) where T : class { var singleton = SingletonProvider.Get <T>(); if (singleton == null) { return(null); } return(ContentGetter.Get <T>(singleton.Id, language)); }
public async Task InitializeAsync() { foreach (var singleton in SingletonProvider.GetAll()) { var content = await ContentGetter.GetAsync(singleton.ContentTypeId, singleton.KeyValues); var contentType = ContentTypeProvider.Get(singleton.ContentTypeId); if (content != null) { continue; } content = ContentInstanceCreator.Create(contentType); PrimaryKeySetter.Set(singleton.KeyValues, content); await ContentInserter.InsertAsync(content).ConfigureAwait(false); } }
public void Initialize() { foreach (var singleton in SingletonProvider.GetAll()) { var content = ContentGetter.Get <IContent>(singleton.Id, null); var contentType = ContentTypeProvider.Get(singleton.ContentTypeId); if (content != null) { if (content.ContentTypeId != contentType.Id) { throw new SingletonWithIdIsOfWrongType(singleton.Id, contentType, content.GetType(), content.ContentTypeId); } continue; } content = (IContent)Activator.CreateInstance(contentType.Type); content.Id = singleton.Id; ContentInserter.Insert(content); } }