コード例 #1
0
        private static void GetExposedExtensionMethods(Type type)
        {
            exposedExtensionMethods.Clear();
            typeToExposedMethods.Clear();

            MethodInfo[] methods = type.GetMethods(BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
            for (int i = 0; i < methods.Length; i++)
            {
                if (!methods[i].HasAttribute <RuntimeInspectorButtonAttribute>())
                {
                    continue;
                }

                ParameterInfo[] parameters = methods[i].GetParameters();
                if (parameters.Length != 1)
                {
                    continue;
                }

                RuntimeInspectorButtonAttribute attribute = methods[i].GetAttribute <RuntimeInspectorButtonAttribute>();
                Type parameterType = parameters[0].ParameterType;
                if (!attribute.IsInitializer || parameterType.IsAssignableFrom(methods[i].ReturnType))
                {
                    exposedExtensionMethods.Add(new ExposedExtensionMethodHolder(parameterType, methods[i], attribute));
                }
            }
        }
コード例 #2
0
        private static void GetExposedExtensionMethods(Type type)
        {
            exposedExtensionMethods.Clear();
            typeToExposedMethods.Clear();

            MethodInfo[] methods = type.GetMethods(BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
            for (int i = 0; i < methods.Length; i++)
            {
//				if( !Attribute.IsDefined( methods[i], typeof( RuntimeInspectorButtonAttribute ), true ) )
//					continue;

                ParameterInfo[] parameters = methods[i].GetParameters();
                if (parameters.Length != 1)
                {
                    continue;
                }

                Type parameterType = parameters[0].ParameterType;
                RuntimeInspectorButtonAttribute attribute = (RuntimeInspectorButtonAttribute)Attribute.GetCustomAttribute(methods[i], typeof(RuntimeInspectorButtonAttribute), true);
                XAttribute attribute1 = (XAttribute)Attribute.GetCustomAttribute(methods[i], typeof(XAttribute), true);
                if (attribute != null && !attribute.IsInitializer || parameterType.IsAssignableFrom(methods[i].ReturnType))
                {
                    exposedExtensionMethods.Add(new ExposedExtensionMethodHolder(parameterType, methods[i], attribute));
                }
                if (attribute1 != null)
                {
                    exposedExtensionMethods.Add(new ExposedExtensionMethodHolder(parameterType, methods[i], new RuntimeInspectorButtonAttribute(methods[i].Name, true, ButtonVisibility.InitializedObjects)));
                }
            }
        }
コード例 #3
0
        private static void GetExposedExtensionMethods(Type type)
        {
            exposedExtensionMethods.Clear();
            typeToExposedMethods.Clear();

            MethodInfo[] methods = type.GetMethods(BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
            for (int i = 0; i < methods.Length; i++)
            {
#if UNITY_EDITOR || !NETFX_CORE
                if (!Attribute.IsDefined(methods[i], typeof(RuntimeInspectorButtonAttribute), true))
#else
                if (!methods[i].IsDefined(typeof(RuntimeInspectorButtonAttribute), true))
#endif
                { continue; }

                ParameterInfo[] parameters = methods[i].GetParameters();
                if (parameters.Length != 1)
                {
                    continue;
                }

#if UNITY_EDITOR || !NETFX_CORE
                RuntimeInspectorButtonAttribute attribute = (RuntimeInspectorButtonAttribute)Attribute.GetCustomAttribute(methods[i], typeof(RuntimeInspectorButtonAttribute), true);
#else
                RuntimeInspectorButtonAttribute attribute = (RuntimeInspectorButtonAttribute)methods[i].GetCustomAttribute(typeof(RuntimeInspectorButtonAttribute), true);
#endif
                Type parameterType = parameters[0].ParameterType;
                if (!attribute.IsInitializer || parameterType.IsAssignableFrom(methods[i].ReturnType))
                {
                    exposedExtensionMethods.Add(new ExposedExtensionMethodHolder(parameterType, methods[i], attribute));
                }
            }
        }
コード例 #4
0
        public static ExposedMethod[] GetExposedMethods(this Type type)
        {
            ExposedMethod[] result;
            if (!typeToExposedMethods.TryGetValue(type, out result))
            {
                MethodInfo[]         methods        = type.GetMethods(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static);
                List <ExposedMethod> exposedMethods = new List <ExposedMethod>();

                for (int i = 0; i < methods.Length; i++)
                {
#if UNITY_EDITOR || !NETFX_CORE
                    if (!Attribute.IsDefined(methods[i], typeof(RuntimeInspectorButtonAttribute), true))
#else
                    if (!methods[i].IsDefined(typeof(RuntimeInspectorButtonAttribute), true))
#endif
                    { continue; }

                    if (methods[i].GetParameters().Length != 0)
                    {
                        continue;
                    }

#if UNITY_EDITOR || !NETFX_CORE
                    RuntimeInspectorButtonAttribute attribute = (RuntimeInspectorButtonAttribute)Attribute.GetCustomAttribute(methods[i], typeof(RuntimeInspectorButtonAttribute), true);
#else
                    RuntimeInspectorButtonAttribute attribute = (RuntimeInspectorButtonAttribute)methods[i].GetCustomAttribute(typeof(RuntimeInspectorButtonAttribute), true);
#endif
                    if (!attribute.IsInitializer || type.IsAssignableFrom(methods[i].ReturnType))
                    {
                        exposedMethods.Add(new ExposedMethod(methods[i], attribute, false));
                    }
                }

                for (int i = 0; i < exposedExtensionMethods.Count; i++)
                {
                    ExposedExtensionMethodHolder exposedExtensionMethod = exposedExtensionMethods[i];
                    if (exposedExtensionMethod.extendedType.IsAssignableFrom(type))
                    {
                        exposedMethods.Add(new ExposedMethod(exposedExtensionMethod.method, exposedExtensionMethod.properties, true));
                    }
                }

                if (exposedMethods.Count > 0)
                {
                    result = exposedMethods.ToArray();
                }
                else
                {
                    result = null;
                }

                typeToExposedMethods[type] = result;
            }

            return(result);
        }
コード例 #5
0
        public static ExposedMethod[] GetExposedMethods(this Type type)
        {
            ExposedMethod[] result;
            if (!typeToExposedMethods.TryGetValue(type, out result))
            {
                MethodInfo[]         methods        = type.GetMethods(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static);
                List <ExposedMethod> exposedMethods = new List <ExposedMethod>();

                for (int i = 0; i < methods.Length; i++)
                {
//					if( !Attribute.IsDefined( methods[i], typeof( RuntimeInspectorButtonAttribute ), true ) )
//						continue;

                    if (methods[i].GetParameters().Length != 0)
                    {
                        continue;
                    }

                    RuntimeInspectorButtonAttribute attribute = (RuntimeInspectorButtonAttribute)Attribute.GetCustomAttribute(methods[i], typeof(RuntimeInspectorButtonAttribute), true);
                    XAttribute attribute1 = (XAttribute)Attribute.GetCustomAttribute(methods[i], typeof(XAttribute), true);
                    if (attribute != null && !attribute.IsInitializer || type.IsAssignableFrom(methods[i].ReturnType))
                    {
                        exposedMethods.Add(new ExposedMethod(methods[i], attribute, false));
                    }
                    if (attribute1 != null)
                    {
                        exposedMethods.Add(new ExposedMethod(methods[i], new RuntimeInspectorButtonAttribute(methods[i].Name, true, ButtonVisibility.InitializedObjects), false));
                    }
                }

                for (int i = 0; i < exposedExtensionMethods.Count; i++)
                {
                    ExposedExtensionMethodHolder exposedExtensionMethod = exposedExtensionMethods[i];
                    if (exposedExtensionMethod.extendedType.IsAssignableFrom(type))
                    {
                        exposedMethods.Add(new ExposedMethod(exposedExtensionMethod.method, exposedExtensionMethod.properties, true));
                    }
                }

                if (exposedMethods.Count > 0)
                {
                    result = exposedMethods.ToArray();
                }
                else
                {
                    result = null;
                }

                typeToExposedMethods[type] = result;
            }

            return(result);
        }
コード例 #6
0
        public static ExposedMethod[] GetExposedMethods(this Type type)
        {
            ExposedMethod[] result;
            if (!typeToExposedMethods.TryGetValue(type, out result))
            {
                MethodInfo[] methods = type.GetMethods(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static);

                exposedMethodsList.Clear();
                for (int i = 0; i < methods.Length; i++)
                {
                    if (!methods[i].HasAttribute <RuntimeInspectorButtonAttribute>())
                    {
                        continue;
                    }

                    if (methods[i].GetParameters().Length != 0)
                    {
                        continue;
                    }

                    RuntimeInspectorButtonAttribute attribute = methods[i].GetAttribute <RuntimeInspectorButtonAttribute>();
                    if (!attribute.IsInitializer || type.IsAssignableFrom(methods[i].ReturnType))
                    {
                        exposedMethodsList.Add(new ExposedMethod(methods[i], attribute, false));
                    }
                }

                for (int i = 0; i < exposedExtensionMethods.Count; i++)
                {
                    ExposedExtensionMethodHolder exposedExtensionMethod = exposedExtensionMethods[i];
                    if (exposedExtensionMethod.extendedType.IsAssignableFrom(type))
                    {
                        exposedMethodsList.Add(new ExposedMethod(exposedExtensionMethod.method, exposedExtensionMethod.properties, true));
                    }
                }

                if (exposedMethodsList.Count > 0)
                {
                    result = exposedMethodsList.ToArray();
                }
                else
                {
                    result = null;
                }

                typeToExposedMethods[type] = result;
            }

            return(result);
        }
コード例 #7
0
 public ExposedExtensionMethodHolder(Type extendedType, MethodInfo method, RuntimeInspectorButtonAttribute properties)
 {
     this.extendedType = extendedType;
     this.method       = method;
     this.properties   = properties;
 }
コード例 #8
0
 public ExposedMethod(MethodInfo method, RuntimeInspectorButtonAttribute properties, bool isExtensionMethod)
 {
     this.method            = method;
     this.properties        = properties;
     this.isExtensionMethod = isExtensionMethod;
 }