/// <summary>
 /// Restrict this route to the requests with the a Content-Type that matches.
 /// </summary>
 /// <param name="template"></param>
 /// <param name="model">Request model which has a ContentTypeAttribute</param>
 public ContentTypeRouteAttribute(string template, Type model)
     : base(template)
 {
     if (model != null)
     {
         object[] attributes = model.GetCustomAttributes(false);
         foreach (object attribute in attributes)
         {
             if (attribute is ContentTypeAttribute)
             {
                 ContentTypeAttribute contentType = (ContentTypeAttribute)attribute;
                 _constraint = new ContentTypeConstraint(contentType.ContentType);
                 break;
             }
         }
     }
     if (_constraint == null)
         throw new ArgumentException("Request model invalid or does not have ContentTypeAttribute", nameof(model));
 }
예제 #2
0
 /// <summary>
 /// Restrict this route to the requests with the a Content-Type that matches.
 /// </summary>
 /// <param name="template"></param>
 /// <param name="model">Request model which has a ContentTypeAttribute</param>
 public ContentTypeRouteAttribute(string template, Type model) :
     base(template)
 {
     if (model != null)
     {
         object[] attributes = model.GetCustomAttributes(false);
         foreach (object attribute in attributes)
         {
             if (attribute is ContentTypeAttribute)
             {
                 ContentTypeAttribute contentType = (ContentTypeAttribute)attribute;
                 _constraint = new ContentTypeConstraint(contentType.ContentType);
                 break;
             }
         }
     }
     if (_constraint == null)
     {
         throw new ArgumentException("Request model invalid or does not have ContentTypeAttribute", nameof(model));
     }
 }
예제 #3
0
 /// <summary>
 /// Restrict this route to the requests with the a Content-Type that matches.
 /// </summary>
 /// <param name="template">the url template we are applying the constraint</param>
 /// <param name="contentTypeBase">media type including sub-type but excluding the suffix (+)"</param>
 public ContentTypeRouteAttribute(string template, string contentTypeBase) :
     base(template)
 {
     _constraint = new ContentTypeConstraint(contentTypeBase);
 }
 /// <summary>
 /// Restrict this route to the requests with the a Content-Type that matches.
 /// </summary>
 /// <param name="template">the url template we are applying the constraint</param>
 /// <param name="contentTypeBase">media type including sub-type but excluding the suffix (+)"</param>
 public ContentTypeRouteAttribute(string template, string contentTypeBase)
     : base(template)
 {
     _constraint = new ContentTypeConstraint(contentTypeBase);
 }