Ejemplo n.º 1
0
        /// <summary>
        /// Builds an instance from/with the data contained in the supplied build context.
        /// </summary>
        /// <param name="fabricContext">
        /// Specifies the build context of the current build operation.
        /// </param>
        /// <returns>
        /// The created instance.
        /// </returns>
        public object BuildFrom(IFabricContext fabricContext)
        {
            var collectionType = fabricContext.TypeToBuild;
            var itemType       = collectionType.GetGenericArguments().First();

            if (fabricContext.ContainerModel.HasImplementationsFor(itemType))
            {
                return(fabricContext.ResolveInstancesFromContainer(itemType));
            }

            var targetArray = Array.CreateInstance(itemType, 3);

            if (itemType.IsInterface)
            {
                targetArray.SetValue(fabricContext.ResolveByFabric(itemType), 0);
                targetArray.SetValue(fabricContext.ResolveByFabric(itemType), 1);
                targetArray.SetValue(fabricContext.ResolveByFabric(itemType), 2);

                foreach (var item in targetArray)
                {
                    fabricContext.InjectExistingInstanceIntoContainer(itemType, item);
                }
            }

            return(targetArray);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Builds an instance from/with the data contained in the supplied build context.
 /// </summary>
 /// <param name="fabricContext">
 /// Specifies the build context of the current build operation.
 /// </param>
 /// <returns>
 /// The created instance.
 /// </returns>
 public object BuildFrom(IFabricContext fabricContext)
 {
     return(fabricContext.CreateStub(fabricContext.TypeToBuild));
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Builds an instance from/with the data contained in the supplied build context.
 /// </summary>
 /// <param name="fabricContext">
 /// Specifies the build context of the current build operation.
 /// </param>
 /// <returns>
 /// The created instance.
 /// </returns>
 public object BuildFrom(IFabricContext fabricContext)
 {
     return fabricContext.CreateStub(fabricContext.TypeToBuild);
 }