Example #1
0
        internal static object CreateReflexForObject(ObjectIdentifier identifier, Type facadeType)
        {
            if (facadeType == null)
            {
                throw new ArgumentNullException(nameof(facadeType));
            }
            if (identifier == null)
            {
                throw new ArgumentNullException(nameof(identifier));
            }

            return(ProxyType.Create(facadeType, (info, args) => FacadeCallback(identifier, info, args)));
        }
Example #2
0
        public T CreateObject <T>(string assemblyLocation, string typeName)
        {
            var assembly = Assembly.LoadFrom(assemblyLocation);
            var type     = assembly.GetAssemblyTypes()
                           .FirstOrDefault(t => string.Equals(t.FullName,
                                                              typeName,
                                                              StringComparison.InvariantCultureIgnoreCase));

            if (type == null)
            {
                throw new TypeLoadException($"Could not find '{typeName}'");
            }
            var instance = Activator.CreateInstance(type);

            if (instance is T variable)
            {
                return(variable);
            }

            return(ProxyType.Create <T>((method, args) => type.GetSimilarMethod(method).Invoke(instance, args)));
        }