Example #1
0
 /// <summary>
 /// Find the operation-controller by the type.
 /// </summary>
 /// <param name="type">The type used to find the operation-controller.</param>
 /// <returns>Returns the operation-controller registered for the <see cref="type" />.
 /// If corresponding operation-controller has not been registered - the <see cref="NullOperationController" /> is returned.</returns>
 protected T GetOperationControllerBy(Type type)
 {
     if (type == null)
     {
         return(NullOperationController);
     }
     return(RegisteredOperationControllers.FirstOrDefault(p => p.TypeKey.IsAssignableFrom(type)) ?? NullOperationController);
 }
Example #2
0
 /// <summary>
 /// Find the operation-controller by the type of the entity.
 /// </summary>
 /// <typeparam name="TEntity">The type used to find the operation-controller.</typeparam>
 /// <param name="entity">The entity which type is used to find the controller.</param>
 /// <returns>Returns the operation-controller registered for the <see cref="TEntity" />.
 /// If corresponding operation-controller has not been registered - the <see cref="NullOperationController" /> is returned.</returns>
 protected T GetOperationControllerFor <TEntity>(TEntity entity)
 {
     if (entity == null)
     {
         return(NullOperationController);
     }
     return(RegisteredOperationControllers.FirstOrDefault(p => p.TypeKey.IsInstanceOfType(entity)) ?? NullOperationController);
 }
Example #3
0
 /// <summary>
 /// Register the operation-controller.
 /// </summary>
 /// <param name="operationController">The type of the operation-controller.</param>
 protected void Register(T operationController)
 {
     RegisteredOperationControllers.Add(operationController);
 }