Example #1
0
        private static Type CreateFor(Type t)
        {
            if (NothingToDo.With(t))
            {
                throw new InvalidOperationException(
                          "Unable to create proxy type - base type must be public and have virtual properties.");
            }

            var compiledAssembly = MakeAssembly(cu => {
                foreach (var assembly in GetReferences(t))
                {
                    cu.ReferencedAssemblies.Add(assembly);
                }
                PrepareType(t, cu);
            });

            return(compiledAssembly.GetTypes()[0]);
        }
Example #2
0
 /// <summary>
 /// Returns true if we can generate a proxy subclass for the given type.
 /// It would be recommended not to use this when preparing types - try to
 /// prepare every type you think should be prepared. That way, if one of your
 /// types is not OK, you will get an exception at preparation time, rather
 /// than later, when some piece of code tries to use the factory to construct
 /// one of those types.
 /// </summary>
 public static bool CanGenerateProxy(Type t)
 {
     return(!NothingToDo.With(t));
 }