Ejemplo n.º 1
0
        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);
            }
        }
Ejemplo n.º 2
0
        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);
            }
        }