コード例 #1
0
 public MXRouteDescriptionSet(IMXRouteDescriptionGenerator patternGenerator,
                              IMXControllerConvention controllerConvention, IMXActionConvention actionConvention)
 {
     _patternGenerator     = patternGenerator;
     _controllerConvention = controllerConvention;
     _actionConvention     = actionConvention;
 }
コード例 #2
0
        private Dictionary <string, string> GenerateFullDefaultParameters(IMXControllerConvention controllerConvention,
                                                                          IMXActionConvention actionConvention,
                                                                          IEnumerable <IMXParameterConvention>
                                                                          defaultParametersList)
        {
            var toReturn = new Dictionary <string, string>();

            if (controllerConvention != null)
            {
                toReturn[MXConventionConstants.ControllerParameterKeyName] = controllerConvention.ConventionName;
            }

            if (actionConvention != null)
            {
                toReturn[MXConventionConstants.ActionParameterKeyName] = actionConvention.ConventionName;
            }

            if (defaultParametersList != null)
            {
                foreach (var p in defaultParametersList)
                {
                    toReturn[p.ConventionName] = p.DefaultValue == null ? null : p.DefaultValue.ToString();
                }
            }

            return(toReturn);
        }
コード例 #3
0
 private string GeneratePattern(IMXControllerConvention controllerConvention,
                                IMXActionConvention actionConvention,
                                IEnumerable<IMXParameterConvention> activeParametersList)
 {
     var patternParts = new List<string>() {controllerConvention.ConventionName};
     if (actionConvention != null)
         patternParts.Add(actionConvention.ConventionName);
     if (activeParametersList != null)
         patternParts.AddRange(activeParametersList.Select(x => "{" + x.ConventionName + "}"));
     var pattern = string.Join(MXConventionConstants.UrlPathSeparator, patternParts);
     return pattern;
 }
コード例 #4
0
 public MXRouteDescription Generate(IMXControllerConvention controllerConvention,
                                    IMXActionConvention actionConvention,
                                    IEnumerable <IMXParameterConvention> activeParametersList,
                                    IEnumerable <IMXParameterConvention> defaultParametersList)
 {
     return(new MXRouteDescription()
     {
         DefaultParameters =
             GenerateFullDefaultParameters(controllerConvention, actionConvention,
                                           defaultParametersList),
         Pattern = GeneratePattern(controllerConvention, actionConvention, activeParametersList)
     });
 }
コード例 #5
0
 public MXRouteDescription Generate(IMXControllerConvention controllerConvention,
                                    IMXActionConvention actionConvention,
                                    IEnumerable<IMXParameterConvention> activeParametersList,
                                    IEnumerable<IMXParameterConvention> defaultParametersList)
 {
     return new MXRouteDescription()
                {
                    DefaultParameters =
                        GenerateFullDefaultParameters(controllerConvention, actionConvention,
                                                      defaultParametersList),
                    Pattern = GeneratePattern(controllerConvention, actionConvention, activeParametersList)
                };
 }
コード例 #6
0
        private Dictionary<string, string> GenerateFullDefaultParameters(IMXControllerConvention controllerConvention,
                                                                         IMXActionConvention actionConvention,
                                                                         IEnumerable<IMXParameterConvention>
                                                                             defaultParametersList)
        {
            var toReturn = new Dictionary<string, string>();
            if (controllerConvention != null)
                toReturn[MXConventionConstants.ControllerParameterKeyName] = controllerConvention.ConventionName;

            if (actionConvention != null)
                toReturn[MXConventionConstants.ActionParameterKeyName] = actionConvention.ConventionName;

            if (defaultParametersList != null)
                foreach (var p in defaultParametersList)
                    toReturn[p.ConventionName] = p.DefaultValue == null ? null : p.DefaultValue.ToString();

            return toReturn;
        }
コード例 #7
0
        private string GeneratePattern(IMXControllerConvention controllerConvention,
                                       IMXActionConvention actionConvention,
                                       IEnumerable <IMXParameterConvention> activeParametersList)
        {
            var patternParts = new List <string>()
            {
                controllerConvention.ConventionName
            };

            if (actionConvention != null)
            {
                patternParts.Add(actionConvention.ConventionName);
            }
            if (activeParametersList != null)
            {
                patternParts.AddRange(activeParametersList.Select(x => "{" + x.ConventionName + "}"));
            }
            var pattern = string.Join(MXConventionConstants.UrlPathSeparator, patternParts);

            return(pattern);
        }
コード例 #8
0
 public MXRouteDescription Generate(IMXControllerConvention controllerConvention,
                                    IMXActionConvention actionConvention,
                                    IEnumerable <IMXParameterConvention> activeParametersList)
 {
     return(Generate(controllerConvention, actionConvention, activeParametersList, null));
 }
コード例 #9
0
 public MXRouteDescription Generate(IMXControllerConvention controllerConvention,
                                    IMXActionConvention actionConvention)
 {
     return(Generate(controllerConvention, actionConvention, null, null));
 }
コード例 #10
0
 public MXRouteDescription Generate(IMXControllerConvention controllerConvention,
                                    IMXActionConvention actionConvention,
                                    IEnumerable<IMXParameterConvention> activeParametersList)
 {
     return Generate(controllerConvention, actionConvention, activeParametersList, null);
 }
コード例 #11
0
 public MXRouteDescription Generate(IMXControllerConvention controllerConvention,
                                    IMXActionConvention actionConvention)
 {
     return Generate(controllerConvention, actionConvention, null, null);
 }