protected override object[] GetConstructorParameters(AbstractTypeConfiguration config)
        {
            var parameters = config.ConstructorMethods.Select(x => x.Key.GetParameters())
                        .OrderBy(x => x.Length)
                        .First();

            var resolved = parameters.Select(x => Container.GetInstance(x.ParameterType));
            return resolved.ToArray();
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="ObjectConstructionArgs"/> class.
 /// </summary>
 /// <param name="context">The context.</param>
 /// <param name="abstractTypeCreationContext">The abstract type creation context.</param>
 /// <param name="configuration">The configuration.</param>
 /// <param name="service">The service.</param>
 public ObjectConstructionArgs(
     Context context, 
     AbstractTypeCreationContext abstractTypeCreationContext, 
     AbstractTypeConfiguration configuration,
     IAbstractService service)
     : base(context)
 {
     AbstractTypeCreationContext = abstractTypeCreationContext;
     Configuration = configuration;
     Service = service;
 }
        /// <summary>
        /// Configures the specified type.
        /// </summary>
        /// <param name="type">The type.</param>
        /// <param name="config">The config.</param>
        /// <exception cref="ConfigurationException">Type configuration is not of type {0}.Formatted(typeof(UmbracoTypeConfiguration).FullName)</exception>
        public override void Configure(Type type, AbstractTypeConfiguration config)
        {
            var umbConfig = config as UmbracoTypeConfiguration;

            if (umbConfig == null)
                throw new ConfigurationException(
                    "Type configuration is not of type {0}".Formatted(typeof(UmbracoTypeConfiguration).FullName));

            umbConfig.ContentTypeAlias = ContentTypeAlias;
            umbConfig.CodeFirst = CodeFirst;
            umbConfig.ContentTypeName = ContentTypeName;

            base.Configure(type, config);
        }
Esempio n. 4
0
 protected abstract object[] GetConstructorParameters(AbstractTypeConfiguration config);
Esempio n. 5
0
 protected abstract object CreateConcreteInstance(AbstractTypeConfiguration config);
 public void Setup()
 {
     _configuration = new StubAbstractTypeConfiguration();
 }
 public void Import(AbstractTypeConfiguration typeConfig)
 {
     typeConfig.Properties
     .Where(x => this.Properties.All(y => y.PropertyInfo.Name != x.PropertyInfo.Name))
     .ForEach(x => this.AddProperty(x, false));
 }
Esempio n. 8
0
        public static void CheckProperty(AbstractTypeConfiguration config, string name, Type configType)
        {
            var pConfig = config.Properties.FirstOrDefault(x => x.PropertyInfo.Name == name);

            Assert.IsNotNull(pConfig, "Could not find property with name {0}".Formatted(name));
            Assert.AreEqual(configType,  pConfig.GetType(), "Property {0} is not of expected type".Formatted(name));
        }
 protected override object CreateConcreteInstance(AbstractTypeConfiguration config)
 {
     return Container.GetInstance(config.Type);
 }