Ejemplo n.º 1
0
        protected async override void OnLoad(EventArgs e)
        {
            InstanceActivator instanceActivator = new InstanceActivator();

            var b = instanceActivator.InjectAndGetObject<GetImageUrlService>(typeof(GetImageUrlService)).Compile().Invoke();
            b.GeneratingUrlForImage(// ააქ უნდა გადავცეეე ფოტოს ID)
            


        }
Ejemplo n.º 2
0
        /// <summary>
        /// Create instance from cached activator
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="arguments"></param>
        /// <returns>Instance of object</returns>
        public static T InstanceOf <T>(params object[] arguments)
        {
            var ctor = typeof(T).GetConstructor(arguments.Select(x => x.GetType()).ToArray());

            if (Activators.ContainsKey(ctor))
            {
                return((T)Activators[ctor](arguments));
            }

            InstanceActivator <T> activator = GetActivator <T>(ctor);

            Activators.Add(ctor, args => activator);

            return(activator(arguments));
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="PropertyBagToTypeInstanceFactory"/> class.
        /// </summary>
        /// <param name="ctor">The constructor to use to construct an instance.</param>
        /// <param name="factory">A factory to create complex objects.</param>
        /// <remarks>
        /// TODO: strategy for selecting constructor
        /// TODO: strategy for determining ctr param => property name.
        /// </remarks>
        public PropertyBagToTypeInstanceFactory(ConstructorInfo ctor, IObjectFactory factory)
        {
            ConstructorInfo = ctor;
            _activator      = Instantiator.GetInstanceActivator(ctor);
            var parameters = ConstructorInfo.GetParameters();

            if (parameters.Length == 1 && parameters[0].ParameterType == typeof(PropertyBag))
            {
                _parameterAccessors.Add((pb) => pb);
            }
            else
            {
                parameters.ForEach(pi => _parameterAccessors.Add((pb) => pb.ConstructInstanceOfType(pi, factory)));
            }

            _factory = factory;
        }
        public void ActivatorShouldBeReturnedEvenIfNameDoesntMatchWhenRequestingDefaultService()
        {
            // Arrange
            var serviceType            = typeof(IFoo);
            var activatorGroup         = new DefaultActivatorGroup(serviceType);
            var defaultServiceIdentity = new ServiceIdentity(serviceType);
            var specialServiceIdentity = new ServiceIdentity(serviceType, "Special");
            var specialActivator       = new InstanceActivator(specialServiceIdentity, null);

            activatorGroup.Add(specialActivator);

            // Act
            var defaultActivator = activatorGroup.GetActivator(defaultServiceIdentity);

            // Assert
            Assert.AreSame(specialActivator, defaultActivator);
        }
Ejemplo n.º 5
0
 public PhoneContainer(PhoneBootstrapper bootstrapper)
 {
     this.bootstrapper = bootstrapper;
     Activator         = new InstanceActivator(bootstrapper, type => GetInstance(type, null));
 }
Ejemplo n.º 6
0
 public PhoneContainer(Bootstrapper bootStrapper)
 {
     Activator = new InstanceActivator(bootStrapper, type => GetInstance(type, null));
 }
 public InstanceActivatorDebuggerTypeProxy(InstanceActivator activator)
 {
     _activator = activator;
 }
 public PhoneContainer()
 {
     Activator = new InstanceActivator(type => this.GetInstance(type, null));
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="PhoneContainer"/> class.
 /// </summary>
 public PhoneContainer()
 {
     Activator = new InstanceActivator(type => GetInstance(type, null));
 }
Ejemplo n.º 10
0
		public PhoneContainer(Bootstrapper bootStrapper)
		{
			Activator = new InstanceActivator(bootStrapper, type => GetInstance(type, null));
		}