コード例 #1
0
 private void AddIdConstraint(WebHookAttribute attribute, SelectorModel selector)
 {
     if (attribute.Id != null)
     {
         var constraint = new WebHookIdConstraint(attribute.Id);
         selector.ActionConstraints.Add(constraint);
     }
 }
コード例 #2
0
 private void AddIdConstraint(WebHookAttribute attribute, IList <SelectorModel> selectors)
 {
     if (attribute.Id != null)
     {
         var constraint = new WebHookIdConstraint(attribute.Id);
         AddConstraint(constraint, selectors);
     }
 }
コード例 #3
0
        private void AddConstraints(WebHookAttribute attribute, IList <SelectorModel> selectors)
        {
            AddConstraint(_existsConstraint, selectors);

            if (attribute.ReceiverName != null)
            {
                var constraint = new WebHookReceiverNameConstraint(attribute.ReceiverName);
                AddConstraint(constraint, selectors);
            }

            if (attribute.Id != null)
            {
                var constraint = new WebHookIdConstraint(attribute.Id);
                AddConstraint(constraint, selectors);
            }
        }
コード例 #4
0
        // Set the template for given SelectorModel. Similar to WebHookActionAttributeBase implementing
        // IRouteTemplateProvider.
        private static void AddTemplate(WebHookAttribute attribute, string template, SelectorModel selector)
        {
            if (selector.AttributeRouteModel?.Template != null)
            {
                var message = string.Format(
                    CultureInfo.CurrentCulture,
                    Resources.RoutingProvider_MixedRouteWithWebHookAttribute,
                    attribute.GetType().Name,
                    selector.AttributeRouteModel.Attribute?.GetType().Name);
                throw new InvalidOperationException(message);
            }

            if (selector.AttributeRouteModel == null)
            {
                selector.AttributeRouteModel = new AttributeRouteModel();
            }

            selector.AttributeRouteModel.Template = template;
        }