public IEnumerable <TEntity> GetEntities(IEntitySourceContext <TEntity> context) { var tokenizer = new JsonTokenizer(GetReader()); tokenizer.Skip(JsonTokenType.ArrayStart); return(new Enumerator(_converters, _descriptions, tokenizer)); }
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>(); }
public ActorReferencesConverter( IActorContext actorContext, SourceDescriptions descriptions, IEntitySourceContext <Actor> sources, PropertyInfo property) { _actorContext = actorContext; _resolver = ReferenceResolver <TOwner, TActor> .Build(property, descriptions, GetEntity); _sources = sources; }
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); }
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; }
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> >(); }
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> >(); }
public AssetContext(IEntitySource <Asset>[] sources, IEntitySourceContext <Asset> sourceContext) : this(sourceContext.GetEntities(sources)) { }
public IEnumerable <TEntity> GetEntities(IEntitySourceContext <TEntity> context) { return(_builder(context)); }