Esempio n. 1
0
        public IEnumerable <TEntity> GetEntities(IEntitySourceContext <TEntity> context)
        {
            var tokenizer = new JsonTokenizer(GetReader());

            tokenizer.Skip(JsonTokenType.ArrayStart);

            return(new Enumerator(_converters, _descriptions, tokenizer));
        }
Esempio n. 2
0
        public EntitySourceContextShould()
        {
            _source = new Mock <IEntitySource <Asset> >();
            _source
            .Setup(source => source.GetEntities(_context))
            .Returns(Array.Empty <Asset>());

            _sources = new[] { _source.Object };
            _context = new EntitySourceContext <Asset>();
        }
Esempio n. 3
0
        public ActorReferencesConverter(
            IActorContext actorContext,
            SourceDescriptions descriptions,
            IEntitySourceContext <Actor> sources,
            PropertyInfo property)
        {
            _actorContext = actorContext;
            _resolver     = ReferenceResolver <TOwner, TActor> .Build(property, descriptions, GetEntity);

            _sources = sources;
        }
Esempio n. 4
0
        public DelegateSourceShould()
        {
            _context = Mock.Of <IEntitySourceContext <Asset> >();

            _builder = new Mock <Func <IEntitySourceContext <Asset>, IEnumerable <Asset> > >();
            _builder
            .Setup(b => b.Invoke(_context))
            .Returns(Enumerable.Empty <Asset>());

            _source = new DelegateSource <Asset>(_builder.Object);
        }
Esempio n. 5
0
        public AssetReferencesConverter(
            SourceDescriptions descriptions,
            IServiceProvider provider,
            IEntitySourceContext <Asset> sources,
            PropertyInfo property)
        {
            _assetContext = new Lazy <IAssetContext>(provider.GetRequired <IAssetContext>);
            _resolver     = ReferenceResolver <TOwner, TAsset> .Build(property, descriptions, GetEntity);

            _sources = sources;
        }
Esempio n. 6
0
        public JsonStreamSourceShould()
        {
            var provider = new DependencyCollection()
                           .AddECS()
                           .BuildProvider();

            _assets = Many(10, i => CreateAsset(i));

            var serialized   = provider.GetRequired <JConverter>().Serialize(_assets);
            var memoryStream = new MemoryStream(Encoding.UTF8.GetBytes(serialized));

            _source        = provider.Activate <JsonStreamSource <Asset> >(new LocalList <object>(memoryStream));
            _sourceContext = Mock.Of <IEntitySourceContext <Asset> >();
        }
Esempio n. 7
0
        public JsonFileSourceShould()
        {
            var provider = new DependencyCollection()
                           .AddECS()
                           .BuildProvider();

            _assets = Many(10, i => CreateAsset(i));

            var serialized = provider.GetRequired <JConverter>().Serialize(_assets);

            var fileName = $"{nameof(JsonFileSourceShould)}.json";

            File.WriteAllText(fileName, serialized);

            _source        = provider.Activate <JsonFileSource <Asset> >(new LocalList <object>(fileName));
            _sourceContext = Mock.Of <IEntitySourceContext <Asset> >();
        }
Esempio n. 8
0
 public AssetContext(IEntitySource <Asset>[] sources, IEntitySourceContext <Asset> sourceContext)
     : this(sourceContext.GetEntities(sources))
 {
 }
Esempio n. 9
0
 public IEnumerable <TEntity> GetEntities(IEntitySourceContext <TEntity> context)
 {
     return(_builder(context));
 }