Exemple #1
0
        private static void LoadController(ControllerAttribute controller, Type type, FilterAttribute[] filters, OutputContractAttribute[] outputs)
        {
            string text = WebContext.Current.Request.ApplicationPath;

            if (!string.IsNullOrEmpty(controller.Path))
            {
                text += controller.Path;
            }
            Type[] nestedTypes = type.GetNestedTypes();
            for (int i = 0; i < nestedTypes.Length; i++)
            {
                Type type2 = nestedTypes[i];
                if (type2.GetInterface("Peanut.IView") != null)
                {
                    string     text2      = text + type2.Name;
                    ActionItem actionItem = new ActionItem(type2);
                    if (outputs.Length > 0)
                    {
                        actionItem.Output = outputs[0];
                    }
                    outputs = Functions.GetTypeAttributes <OutputContractAttribute>(type2, true);
                    if (outputs.Length > 0)
                    {
                        actionItem.Output = outputs[0];
                    }
                    for (int j = 0; j < filters.Length; j++)
                    {
                        FilterAttribute item = filters[j];
                        actionItem.Filters.Add(item);
                    }
                    FilterAttribute[] typeAttributes = Functions.GetTypeAttributes <FilterAttribute>(type2, true);
                    for (int j = 0; j < typeAttributes.Length; j++)
                    {
                        FilterAttribute item = typeAttributes[j];
                        actionItem.Filters.Add(item);
                    }
                    if (Utils.mActions.ContainsKey(text.ToLower()))
                    {
                        Utils.mActions[text2.ToLower()] = actionItem;
                    }
                    else
                    {
                        Utils.mActions.Add(text2.ToLower(), actionItem);
                    }
                    MatchUrlAttribute[] typeAttributes2 = Functions.GetTypeAttributes <MatchUrlAttribute>(type2, false);
                    if (typeAttributes2.Length > 0)
                    {
                        typeAttributes2[0].Item = actionItem;
                        Utils.mMatchUrls.Add(typeAttributes2[0]);
                    }
                }
            }
        }
Exemple #2
0
 private static void LoadController(ControllerAttribute controller, Type type, FilterAttribute[] filters, OutputContractAttribute[] outputs)
 {
     string text = WebContext.Current.Request.ApplicationPath;
     if (!string.IsNullOrEmpty(controller.Path))
     {
         text += controller.Path;
     }
     Type[] nestedTypes = type.GetNestedTypes();
     for (int i = 0; i < nestedTypes.Length; i++)
     {
         Type type2 = nestedTypes[i];
         if (type2.GetInterface("Peanut.IView") != null)
         {
             string text2 = text + type2.Name;
             ActionItem actionItem = new ActionItem(type2);
             if (outputs.Length > 0)
             {
                 actionItem.Output = outputs[0];
             }
             outputs = Functions.GetTypeAttributes<OutputContractAttribute>(type2, true);
             if (outputs.Length > 0)
             {
                 actionItem.Output = outputs[0];
             }
             for (int j = 0; j < filters.Length; j++)
             {
                 FilterAttribute item = filters[j];
                 actionItem.Filters.Add(item);
             }
             FilterAttribute[] typeAttributes = Functions.GetTypeAttributes<FilterAttribute>(type2, true);
             for (int j = 0; j < typeAttributes.Length; j++)
             {
                 FilterAttribute item = typeAttributes[j];
                 actionItem.Filters.Add(item);
             }
             if (Utils.mActions.ContainsKey(text.ToLower()))
             {
                 Utils.mActions[text2.ToLower()] = actionItem;
             }
             else
             {
                 Utils.mActions.Add(text2.ToLower(), actionItem);
             }
             MatchUrlAttribute[] typeAttributes2 = Functions.GetTypeAttributes<MatchUrlAttribute>(type2, false);
             if (typeAttributes2.Length > 0)
             {
                 typeAttributes2[0].Item = actionItem;
                 Utils.mMatchUrls.Add(typeAttributes2[0]);
             }
         }
     }
 }