示例#1
0
 // Helper method that loops through every type in AppDomain and
 // looks for an attribute of a given type and passes it into a delegate
 // submitted by the caller...
 private static void FindAllTypesWithAttribute <TAttrType>(TypeDelegate functor)
 {
     foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies())
     {
         // Consciously skipping Aall GAC assemblies since these are
         // expected to be .Net Framework assemblies...
         if (assembly.GlobalAssemblyCache)
         {
             continue;
         }
         try
         {
             foreach (Type type in assembly.GetTypes())
             {
                 TAttrType[] attributes = type.GetCustomAttributes(
                     typeof(TAttrType),
                     true) as TAttrType[];
                 if (attributes != null && attributes.Length > 0)
                 {
                     // Calling our given delegate with the type...
                     functor(type);
                 }
             }
         }
         catch
         {
             ;                     // do nothing
         }
     }
 }
示例#2
0
 public T Proxy <A, T>(TypeDelegate <T> @delegate, T instance) where T : StaticContextWrapper
 {
     instance.Parent     = Root;
     instance.Underlying = StaticGameContext.ProxyAccessor <A, TypeDelegate <T> >(@delegate, @delegate.ConstructorParams.ToArray());
     @delegate.Accessor  = instance;
     return(instance);
 }
 public static Type GetDrawerTypeForType(Type attributeType)
 {
     if (_GetDrawerTypeForType == null)
     {
         Type scriptAttributeUtilityType = Type.GetType("UnityEditor.ScriptAttributeUtility, UnityEditor");
         var  method = scriptAttributeUtilityType.GetMethod("GetDrawerTypeForType", BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public);
         _GetDrawerTypeForType = (TypeDelegate)method.CreateDelegate(typeof(TypeDelegate));
     }
     return(_GetDrawerTypeForType(attributeType));
 }
示例#4
0
        public T Proxy <A, T>(TypeDelegate <T> @delegate) where T : StaticContextWrapper
        {
            T instance = Activator.CreateInstance <T>();

            return(Proxy <A, T>(@delegate, instance));
        }