/// <summary>
        /// Creates a <see cref="IBehaviourRepository"/> based on the given <see cref="GladMonoBehaviour"/>
        /// instance provided and uses <see cref="IReflectionStrategy"/> for parsing the Type info.
        /// </summary>
        /// <param name="behaviour">Instance to parse.</param>
        /// <param name="strat">Strategy for parsing.</param>
        public BehaviourCollectionModelRepository(GladMonoBehaviour behaviour, IReflectionStrategy strat)
        {
            if (behaviour == null)
                throw new ArgumentNullException(nameof(behaviour), "Cannot deal with null " + nameof(MonoBehaviour) + ".");

            if (strat == null)
                throw new ArgumentNullException(nameof(strat), "Cannot handle serialization with a null " + nameof(IReflectionStrategy) + " strat.");

            dataBehaviour = behaviour;
            reflectionStrat = strat;
        }
Exemple #2
0
        /// <summary>
        /// Creates a <see cref="IBehaviourRepository"/> based on the given <see cref="GladMonoBehaviour"/>
        /// instance provided and uses <see cref="IReflectionStrategy"/> for parsing the Type info.
        /// </summary>
        /// <param name="behaviour">Instance to parse.</param>
        /// <param name="strat">Strategy for parsing.</param>
        public BehaviourCollectionModelRepository(GladMonoBehaviour behaviour, IReflectionStrategy strat)
        {
            if (behaviour == null)
            {
                throw new ArgumentNullException(nameof(behaviour), "Cannot deal with null " + nameof(MonoBehaviour) + ".");
            }

            if (strat == null)
            {
                throw new ArgumentNullException(nameof(strat), "Cannot handle serialization with a null " + nameof(IReflectionStrategy) + " strat.");
            }

            dataBehaviour   = behaviour;
            reflectionStrat = strat;
        }
        //Can't do this in constructor for some reason
        private void Init()
        {
            if (target == null)
                throw new ArgumentException(nameof(target), "Target is null for some reason.");

            reflectionStrat = new FasterflectReflectionStrategy();
            collectionRepo = new BehaviourCollectionModelRepository(target as GladMonoBehaviour, reflectionStrat);
            controller = new GladMonoBehaviourDataController();

            IEnumerable<IDataStoreModel> models = collectionRepo.BuildModels();

            List<IEditorDrawable> tempViewList = new List<IEditorDrawable>(models.Count() * 2);

            foreach (var dm in models)
                tempViewList.Add(controller.RegisterModel(dm));

            views = tempViewList;
        }
        //Can't do this in constructor for some reason
        private void Init()
        {
            if (target == null)
            {
                throw new ArgumentException(nameof(target), "Target is null for some reason.");
            }

            reflectionStrat = new FasterflectReflectionStrategy();
            collectionRepo  = new BehaviourCollectionModelRepository(target as GladMonoBehaviour, reflectionStrat);
            controller      = new GladMonoBehaviourDataController();

            IEnumerable <IDataStoreModel> models = collectionRepo.BuildModels();

            List <IEditorDrawable> tempViewList = new List <IEditorDrawable>(models.Count() * 2);

            foreach (var dm in models)
            {
                tempViewList.Add(controller.RegisterModel(dm));
            }

            views = tempViewList;
        }