예제 #1
0
 /// <summary>
 /// Resolves the dependencies needed for this instance to work.
 /// </summary>
 protected override void ResolveDependencies()
 {
     this.modelFactoryService = ModelFactoryService.Instance;
     this.playScene           = this.Scene as PlayScene;
     this.playerTransform     = this.playScene.Player.FindComponent <Transform3D>();
     this.playerCollider      = this.playScene.Player.FindComponent <BoxCollider>();
     this.playerBoundingBox   = new BoundingBox(this.playerTransform.Position - this.playerCollider.Size / 2, this.playerTransform.Position + this.playerCollider.Size / 2);
     this.tempBoundingBox     = new BoundingBox();
 }
예제 #2
0
 /// <summary>
 /// Gets the model factory that is capable of instantiating the specified model class type.
 /// </summary>
 /// <param name="type">The model class type that the model factory should instantiate.</param>
 /// <returns></returns>
 protected IModelFactory GetModelFactory(Type type)
 {
     return(ModelFactoryService.ResolveModelFactory(type));
 }
예제 #3
0
        /// <summary>
        /// Create a model class T instance and bind the specified item to the instance.
        /// </summary>
        /// <typeparam name="T">The model class that the item should be bound to.</typeparam>
        /// <param name="item">The item to bind.</param>
        /// <returns>A new instance of the model class T bound to the specified item.</returns>
        /// <exception cref="System.Exception">This method calls the model factory and the associated binding contract that may throw an error if the item does not comply with the binding contract or if the model class does not contain a constructor that accepts an item.</exception>
        public static T BindAs <T>(this Item item) where T : class
        {
            IModelFactory modelFactory = ModelFactoryService.ResolveModelFactory <T>();

            return(item.BindAs <T>(modelFactory));
        }
예제 #4
0
        /// <summary>
        /// Determines whether the selected item is bindable to the model class T.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="item">The item containing the field with the selected item to bind.</param>
        /// <param name="fieldId">The id of the field containing the selected item to test.</param>
        /// <returns><c>true</c> if the selected item is bindable to the model class T; otherwise <c>false</c></returns>
        public static Boolean IsSelectedItemBindable <T>(this Item item, ID fieldId) where T : class
        {
            IBindingContract bindingContract = ModelFactoryService.ResolveModelFactory <T>().BindingContract;

            return(item.IsSelectedItemBindable <T>(fieldId, bindingContract));
        }
예제 #5
0
        /// <summary>
        /// Creates a collection of model class T instances and bind the items in the specified collection to the instances.
        /// </summary>
        /// <typeparam name="T">The model class that the items in the collection should be bound to.</typeparam>
        /// <param name="items">The collection containing the items to bind.</param>
        /// <returns>A collection of model class T instances bound to the items in the specified collection.</returns>
        public static IEnumerable <T> BindItemsAs <T>(this IEnumerable <Item> items) where T : class
        {
            IModelFactory modelFactory = ModelFactoryService.ResolveModelFactory <T>();

            return(items.BindItemsAs <T>(modelFactory));
        }
예제 #6
0
        /// <summary>
        /// Determines whether the specified item is bindable to the model class T.
        /// </summary>
        /// <typeparam name="T">The model class that the item should be bindable to.</typeparam>
        /// <param name="item">The item to test.</param>
        /// <returns><c>true</c> if the item is bindable to the model class T; otherwise <c>false</c></returns>
        public static Boolean IsBindable <T>(this Item item) where T : class
        {
            IBindingContract bindingContract = ModelFactoryService.ResolveModelFactory <T>().BindingContract;

            return(item.IsBindable <T>(bindingContract));
        }
예제 #7
0
        /// <summary>
        /// Create a model class T instance and bind the selected item to the instance.
        /// </summary>
        /// <typeparam name="T">The model class that the selected item should be bound to.</typeparam>
        /// <param name="item">The item containing the field with the selected item to bind.</param>
        /// <param name="fieldId">The id of the field containing the selected item to bind.</param>
        /// <returns>A new instance of the model class T bound to the selected item.</returns>
        /// <exception cref="System.Exception">This method calls the model factory and the associated binding contract that may throw an error if the selected item does not comply with the binding contract or if the model class does not contain a constructor that accepts an item.</exception>
        public static T BindSelectedItemAs <T>(this Item item, ID fieldId) where T : class
        {
            IModelFactory modelFactory = ModelFactoryService.ResolveModelFactory <T>();

            return(BindSelectedItemAs <T>(item, fieldId, modelFactory));
        }
예제 #8
0
        /// <summary>
        /// Creates a collection of model class T instances and bind the specified item's children to the instances.
        /// </summary>
        /// <typeparam name="T">The model class that the item's children should be bound to.</typeparam>
        /// <param name="item">The parent item of the children to bind.</param>
        /// <returns>A collection of model class T instances bound to the specified item's children.</returns>
        public static IEnumerable <T> BindChildrenAs <T>(this Item item) where T : class
        {
            IModelFactory modelFactory = ModelFactoryService.ResolveModelFactory <T>();

            return(BindChildrenAs <T>(item, modelFactory));
        }