<commit_before>using UnityEngine;

namespace Unidux
{
    public static class MonoBehaviourExtension
    {
        public static void AddDisableTo<T>(
            this GameObject gameObject,
            Store<T> store,
            Render<T> render)
            where T : StateBase<T>
        {
            GetOrAddUniduxSubscriber<UniduxDisableSubscriber>(gameObject).AddRenderTo(store, render);
        }

        public static void AddDestroyTo<T>(
            this GameObject gameObject,
            Store<T> store,
            Render<T> render)
            where T : StateBase<T>
        {
            GetOrAddUniduxSubscriber<UniduxDestroySubscriber>(gameObject).AddRenderTo(store, render);
        }

        private static T GetOrAddUniduxSubscriber<T>(GameObject gameObject) where T : UniduxSubscriberBase
        {
            var component = gameObject.GetComponent<T>();
            if (component == null)
            {
                gameObject.AddComponent<T>();
                component = gameObject.GetComponent<T>();
            }
            return component;
        }
    }
}<commit_msg>issues/29 feat(Extension): MonoBehaviour extension for Add{Disable,Destroy}To<commit_after>using UnityEngine;

namespace Unidux
{
    public static class MonoBehaviourExtension
    {
        public static void AddDisableTo<T>(
            this MonoBehaviour behaviour,
            Store<T> store,
            Render<T> render)
            where T : StateBase<T>
        {
            GetOrAddUniduxSubscriber<UniduxDisableSubscriber>(behaviour.gameObject).AddRenderTo(store, render);
        }

        public static void AddDisableTo<T>(
            this GameObject gameObject,
            Store<T> store,
            Render<T> render)
            where T : StateBase<T>
        {
            GetOrAddUniduxSubscriber<UniduxDisableSubscriber>(gameObject).AddRenderTo(store, render);
        }

        public static void AddDestroyTo<T>(
            this MonoBehaviour behaviour,
            Store<T> store,
            Render<T> render)
            where T : StateBase<T>
        {
            GetOrAddUniduxSubscriber<UniduxDestroySubscriber>(behaviour.gameObject).AddRenderTo(store, render);
        }

        public static void AddDestroyTo<T>(
            this GameObject gameObject,
            Store<T> store,
            Render<T> render)
            where T : StateBase<T>
        {
            GetOrAddUniduxSubscriber<UniduxDestroySubscriber>(gameObject).AddRenderTo(store, render);
        }

        private static T GetOrAddUniduxSubscriber<T>(GameObject gameObject) where T : UniduxSubscriberBase
        {
            var component = gameObject.GetComponent<T>();
            if (component == null)
            {
                gameObject.AddComponent<T>();
                component = gameObject.GetComponent<T>();
            }
            return component;
        }
    }
}
{'fraction_non_alphanumeric': 0.08161157024793389, 'fraction_numerical': 0.0006887052341597796, 'mean_word_length': 1.9673135852911134, 'pattern_counts': {'":': 0, '<': 41, '<?xml version=': 0, '>': 41, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2634822', 'n_tokens_mistral': 775, 'n_tokens_neox': 757, 'n_words': 155}