static void RenderCleanups(List <string> cleanupBuilder, InjectionInfo info, string instanceName, int indent)
        {
            const string CLEANUP_REGISTRATION = "context.OnCleanUp.AddListener({0}.{1});";

            var cleanups = info.GetCalls <Cleanup>();

            if (cleanups != null && cleanups.Count > 0)
            {
                foreach (var cleanup in cleanups)
                {
                    AppendLine(cleanupBuilder, string.Format(CLEANUP_REGISTRATION, instanceName, cleanup.Name), indent);
                }
            }
        }
        static void RenderPostInjections(List <string> postInjectionBuilder, InjectionInfo info, string instanceName, int indent)
        {
            const string POST_INJECTION_CALL = "{0}.{1}();";

            var postInjections = info.GetCalls <PostInjection>();

            if (postInjections != null && postInjections.Count > 0)
            {
                foreach (var postInjection in postInjections)
                {
                    AppendLine(postInjectionBuilder, string.Format(POST_INJECTION_CALL, instanceName, postInjection.Name), indent);
                }
            }
        }
예제 #3
0
        private static void ParseMethodAttributes <T> (Type type, InjectionInfo info) where T : Attribute
        {
            var methods = type.GetMethods();

            for (var i = 0; i < methods.Length; i++)
            {
                var method     = methods[i];
                var attributes = method.GetCustomAttributes(typeof(T), true);

                if (attributes.Length > 0)
                {
                    info.GetCalls <T>(true).Add(method);
                }
            }
        }