Beispiel #1
0
        public override object Create(IConstructorPropertySource propertySource)
        {
            if (IsAbstract)
            {
                throw new PomonaSerializationException("Pomona was unable to instantiate type " + Name
                                                       + ", as it's an abstract type.");
            }

            if (Constructor == null)
            {
                throw new PomonaSerializationException("Pomona was unable to instantiate type " + Name
                                                       + ", Constructor property was null.");
            }

            if (this.createUsingPropertySourceFunc == null)
            {
                var param = Expression.Parameter(typeof(IConstructorPropertySource));
                var expr  =
                    Expression.Lambda(
                        Expression.Invoke(Constructor.InjectingConstructorExpression, param),
                        param);
                this.createUsingPropertySourceFunc = expr.Compile();
            }

            return(((Func <IConstructorPropertySource, object>) this.createUsingPropertySourceFunc)(propertySource));
        }
 public object CreateResource(TypeSpec type, IConstructorPropertySource args)
 {
     try
     {
         return(type.Create(args));
     }
     catch (ArgumentException argumentException)
     {
         PropertySpec propertySpec;
         if (type.TryGetPropertyByName(argumentException.ParamName, true, out propertySpec))
         {
             throw new ResourceValidationException(argumentException.Message,
                                                   propertySpec.Name,
                                                   propertySpec.ReflectedType.Name,
                                                   argumentException);
         }
         throw;
     }
 }
 public object CreateResource(TypeSpec type, IConstructorPropertySource args)
 {
     return(type.Create(args));
 }
Beispiel #4
0
 public virtual object Create(IConstructorPropertySource propertySource)
 {
     throw new NotSupportedException("Unable to instantiate type " + FullName);
 }
Beispiel #5
0
 public virtual object Create(IConstructorPropertySource propertySource)
 {
     throw new NotSupportedException("Unable to instantiate type " + FullName);
 }