Exemplo n.º 1
0
        /// <summary>
        /// Called when authorization is required.
        /// </summary>
        /// <param name="filterContext">The filter context.</param>
        public void OnAuthorization(AuthorizationContext filterContext)
        {
            if (filterContext.Controller is EntityController)
                EntityBuilder = ((EntityController)filterContext.Controller).EntityBuilder;
            else
                return;
            if (filterContext.Controller.GetType().IsGenericType)
                Metadata = EntityAnalyzer.GetMetadata(filterContext.Controller.GetType().GetGenericArguments()[0]);
            RouteData = filterContext.RouteData;

            if (!Authorize(filterContext))
                filterContext.Result = new HttpStatusCodeResult(403);
        }
Exemplo n.º 2
0
 /// <summary>
 /// Initialize entity.
 /// </summary>
 public EntityBase()
 {
     _Metadata = EntityAnalyzer.GetMetadata(this.GetType());
 }