Ejemplo n.º 1
0
        private static TypedValue CreateWithParameters(Processor <T> processor, Tree <T> parameters, RuntimeType runtimeType)
        {
            RuntimeMember member = runtimeType.GetConstructor(parameters.Branches.Count);

            object[] parameterList = GetParameterList(processor, TypedValue.Void, parameters, member);
            try {
                return(member.Invoke(parameterList));
            }
            catch (Exception e) {
                throw new CreateException(runtimeType.Type, parameterList.Length, e);
            }
        }
Ejemplo n.º 2
0
    TypedValue CreateWithParameters(Tree <T> parameters, RuntimeType runtimeType)
    {
        RuntimeMember member = runtimeType.GetConstructor(parameters.Branches.Count);

        object[] parameterList = new ParameterList <T>(Processor).GetParameterList(TypedValue.Void, parameters, member);
        try {
            return(member.Invoke(parameterList));
        }
        catch (System.Exception e) {
            throw new CreateException(runtimeType.Type, parameterList.Length, e.InnerException ?? e);
        }
    }
 internal static bool TryGetConstructor(RuntimeType t, RuntimeType[] ctorParams, out RuntimeConstructorInfo ctorInfo)
 {
     ctorInfo = t.RemotingCache[CacheObjType.ConstructorInfo] as RuntimeConstructorInfo;
     if (ctorInfo != null)
     {
         return(true);
     }
     ctorInfo = t.GetConstructor(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance, null, CallingConventions.Any, ctorParams, null) as RuntimeConstructorInfo;
     if (ctorInfo != null)
     {
         t.RemotingCache[CacheObjType.ConstructorInfo] = ctorInfo;
         return(true);
     }
     return(false);
 }
Ejemplo n.º 4
0
        internal static RuntimeConstructorInfo GetConstructor(Type t, Type[] ctorParams)
        {
            RuntimeConstructorInfo info = (RuntimeConstructorInfo)t.Cache[CacheObjType.ConstructorInfo];

            if (info == null)
            {
                RuntimeType type = (RuntimeType)t;
                info = type.GetConstructor(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance, null, CallingConventions.Any, ctorParams, null) as RuntimeConstructorInfo;
                if (info == null)
                {
                    throw new SerializationException(string.Format(CultureInfo.CurrentCulture, Environment.GetResourceString("Serialization_ConstructorNotFound"), new object[] { t.FullName }));
                }
                t.Cache[CacheObjType.ConstructorInfo] = info;
            }
            return(info);
        }
Ejemplo n.º 5
0
 protected override ConstructorInfo GetConstructorImpl(BindingFlags bindingAttr, Binder binder, CallingConventions callConvention, Type[] types, ParameterModifier[] modifiers)
 {
     return(RewriteConstructor(RuntimeType.GetConstructor(bindingAttr, binder, callConvention, types, modifiers)));
 }