public async Task <string> GetStatus() { try { using (var data = Context) return(RegistrationConverter.DataAccsessToDto(await(from item in data.Registration select item).FirstOrDefaultAsync()).Status); } catch (Exception) { return(null); } }
public void TestConversion1( ) { // takes IComponentLifetime _fixture.Container.Resolve <IRandom> ( ); var objIdProv = _fixture.Container.Resolve <IObjectIdProvider> ( ); var converter = new RegistrationConverter(_fixture.Container, objIdProv); var regs = _fixture.Container.ComponentRegistry.Registrations; var value = regs.Where( (registration, i) => registration.Services.Any( service => service is TypedService t && t.ServiceType == typeof(IRandom) ) ) .First( ); var result = converter.Convert( value , typeof(IEnumerable) , null , CultureInfo.CurrentCulture ); Assert.NotNull(result); var enumerable = ( IEnumerable )result; var collection = enumerable as object[] ?? enumerable.Cast <object> ( ).ToArray( ); Assert.NotEmpty(collection); foreach (var o in collection) { _output.WriteLine($"{o}"); } }
public void LazyLoadButton( ) { // takes IComponentLifetime var lazy = _fixture.Container.Resolve <Lazy <IRandom> > ( ); var objIdProv = _fixture.Container.Resolve <IObjectIdProvider> ( ); var instConv = new RegistrationConverter( _fixture.Container , objIdProv ); // TypeDescriptor.GetConverter ( typeof (IComponentRegistration) ) ; Assert.NotNull(instConv); _output.WriteLine($"{instConv}"); var converter = new InstanceRegistrationConverter( ); var regs = _fixture.Container.ComponentRegistry.Registrations; var regsAry = regs as IComponentRegistration[] ?? regs.ToArray( ); DumpRegistrations(regsAry); var serviceType = lazy.GetType( ); _output.WriteLine($"serviceType is {serviceType}"); var value = FindTypedService(regsAry, serviceType); if (value == null) { throw new ArgumentNullException( ); } _output.WriteLine($"typed service is ${value}"); var myVal = instConv.Convert( value , null , _fixture.Container , CultureInfo.CurrentCulture ); Assert.NotNull(myVal); Assert.IsAssignableFrom <IList <InstanceRegistration> > (myVal); var list = (IList <InstanceRegistration>)myVal; Assert.Single(list); Assert.Collection( list , info => { Assert.NotNull(info.Instance); } ); var instReg = list[0]; _output.WriteLine($"Passing {instReg} into {converter}"); var result = converter.Convert( instReg , typeof(IEnumerable) , null , CultureInfo.CurrentCulture ); Assert.NotNull(result); var enumerable = ( IEnumerable )result; var collection = enumerable.Cast <object> ( ).ToList( ); Assert.NotEmpty(collection); foreach (var o in collection) { _output.WriteLine($"{o}"); } }