Exemplo n.º 1
0
        // Constructors
        public ObjectDescription(Type type, ServiceAreaDescription declaringServiceArea)
        {
            this._innerType = this._type = type;
            // For ServiceResult, use the first type parameter as the type of object
            if (type.IsGenericType && type.Name.StartsWith("ServiceResult"))
            {
                this._innerType = this._type = type.GetGenericArguments()[0];
            }
            // If the type is an array, use the element type as the inner type
            if (this._type.IsArray)
            {
                this._innerType = this._type.GetElementType();
            }

            this._declaringServiceArea = declaringServiceArea;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Handle the action executing event and set the result to a view if documentation is requested.
        /// </summary>
        /// <param name="filterContext">The context of the event.</param>
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            base.OnActionExecuting(filterContext);

            ServiceAreaDescription serviceArea = new ServiceAreaDescription(filterContext.Controller.GetType().Assembly);
            if (filterContext.HttpContext.Request["mode"] == "help")
            {
                if (filterContext.Controller.GetType().Name == "HomeController")
                {
                    filterContext.Result = new ViewResult()
                    {
                        ViewName = "~/bin/Views/Shared/ServiceAreaHelp.aspx",
                        ViewData = new ViewDataDictionary<ServiceAreaDescription>(serviceArea),
                    };
                }
                else
                {
                    ObjectDescription type = new ObjectDescription(filterContext.Controller.GetType(), serviceArea);
                    if (filterContext.ActionDescriptor.ActionName.ToLower() == "index")
                    {
                        filterContext.Result = new ViewResult()
                        {
                            ViewName = "~/bin/Views/Shared/ObjectHelp.aspx",
                            ViewData = new ViewDataDictionary<ObjectDescription>(type),
                        };
                    }
                    else
                    {
                        ActionDescription action = type.Actions.First(a => a.Name.ToLower() == filterContext.ActionDescriptor.ActionName.ToLower());
                        filterContext.Result = new ViewResult()
                        {
                            ViewName = "~/bin/Views/Shared/ActionHelp.aspx",
                            ViewData = new ViewDataDictionary<ActionDescription>(action),
                        };
                    }
                }
            }
        }
Exemplo n.º 3
0
 // Methods
 /// <summary>
 /// Displays the homepage for this service area.
 /// </summary>
 /// <returns>A view for the homepage for this service area.</returns>
 public ActionResult Index()
 {
     ServiceAreaDescription serviceArea = new ServiceAreaDescription(Assembly.GetExecutingAssembly());
     return View(serviceArea);
 }