Example #1
0
 /// <summary>
 /// Creates a new <see cref="HttpPartMessagePopulationSource" /> that will try to populate all
 /// non-owned properties with data from a given source.
 /// </summary>
 /// <param name="partName">A name used to identify this "part", being part of variable names created
 /// and therefore should be unique.</param>
 /// <param name="sourceCodeExpression">Delegate to get the property to load data from.</param>
 /// <param name="applies">Indicates whether this catch-all applies. If <c>false</c> is returned then
 /// NO code will be generated.</param>
 /// <param name="supportsMultiValues">Indicates whether the source of this part supports array-like values (i.e. ASP.NET parses
 /// and creates a <see cref="StringValues" /> representation).</param>
 /// <returns>A new <see cref="HttpPartMessagePopulationSource"/>.</returns>
 public static HttpPartMessagePopulationSource CatchAll(
     string partName,
     GetSourceVariable sourceCodeExpression,
     Func <MiddlewareBuilderContext, bool> applies,
     bool supportsMultiValues)
 {
     return(new HttpPartMessagePopulationSource(partName, sourceCodeExpression, applies, supportsMultiValues));
 }
Example #2
0
        private HttpPartMessagePopulationSource(Type partAttribute, GetSourceVariable sourceCodeExpression, bool supportsMultiValues)
        {
            this._partAttribute        = partAttribute;
            this._sourceCodeExpression = sourceCodeExpression;
            this._supportsMultiValues  = supportsMultiValues;
            this._isCatchAll           = false;

            this._variablePrefix = partAttribute.Name.Replace("Attribute", string.Empty).Camelize();
        }
Example #3
0
        private HttpPartMessagePopulationSource(
            string partName,
            GetSourceVariable sourceCodeExpression,
            Func <MiddlewareBuilderContext, bool> applies,
            bool supportsMultiValues)
        {
            this._sourceCodeExpression = sourceCodeExpression;
            this._supportsMultiValues  = supportsMultiValues;
            this._applies    = applies;
            this._isCatchAll = true;

            this._variablePrefix = partName;
        }
Example #4
0
 /// <summary>
 /// Creates a new <see cref="HttpPartMessagePopulationSource" /> that will look for properties
 /// that have an applied attribute.
 /// </summary>
 /// <param name="sourceCodeExpression">Delegate to get the property to load data from.</param>
 /// <param name="supportsMultiValues">Indicates whether the source of this part supports array-like values (i.e. ASP.NET parses
 /// and creates a <see cref="StringValues" /> representation).</param>
 /// <typeparam name="T">The attribute that is searched for.</typeparam>
 /// <returns>A new <see cref="HttpPartMessagePopulationSource"/>.</returns>
 public static HttpPartMessagePopulationSource Owned <T>(GetSourceVariable sourceCodeExpression, bool supportsMultiValues)
 {
     return(new HttpPartMessagePopulationSource(typeof(T), sourceCodeExpression, supportsMultiValues));
 }