Skip to content

Commit

Permalink
ApiSettings.Data
Browse files Browse the repository at this point in the history
- Can now create content parameter without name
- ApiSettings can now hold a Data-Dictionary available from the RequestTransformContext
  • Loading branch information
mattiasnordqvist committed Jun 13, 2018
1 parent e0ae719 commit 5d7fd6a
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 9 deletions.
6 changes: 3 additions & 3 deletions ProductAssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
[assembly: AssemblyCulture("")]

/* File versions are set by CI build */
[assembly: AssemblyVersion("6.2.1")]
[assembly: AssemblyFileVersion("6.2.1")]
[assembly: AssemblyInformationalVersion("6.2.1")]
[assembly: AssemblyVersion("6.2.2")]
[assembly: AssemblyFileVersion("6.2.2")]
[assembly: AssemblyInformationalVersion("6.2.2")]
4 changes: 3 additions & 1 deletion WebAnchor/DefaultApiSettings.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
using WebAnchor.RequestFactory;
using System.Collections.Generic;
using WebAnchor.RequestFactory;
using WebAnchor.ResponseParser;

namespace WebAnchor
{
public class DefaultApiSettings : IApiSettings
{
public Dictionary<string, object> Data { get; set; } = new Dictionary<string, object>();
public IApiRequestSettings Request { get; set; } = new DefaultApiRequestSettings();
public IApiResponeSettings Response { get; set; } = new DefaultApiResponseSettings();
}
Expand Down
4 changes: 3 additions & 1 deletion WebAnchor/IApiSettings.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
using WebAnchor.RequestFactory;
using System.Collections.Generic;
using WebAnchor.RequestFactory;
using WebAnchor.ResponseParser;

namespace WebAnchor
{
public interface IApiSettings
{
Dictionary<string, object> Data { get; set; }
IApiRequestSettings Request { get; set; }
IApiResponeSettings Response { get; set; }
}
Expand Down
16 changes: 15 additions & 1 deletion WebAnchor/RequestFactory/Parameter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ private Parameter()
public IEnumerable<object> Values { get; set; }

/// <summary>
/// value should be a single value, not a list or any other enumerable
/// value should be an object, not a list or any other enumerable though.
/// </summary>
/// <param name="name"></param>
/// <param name="value"></param>
Expand All @@ -58,6 +58,20 @@ public static Parameter CreateContentParameter(string name, object value)
};
}

/// <summary>
/// value should be an object, not a list or any other enumerable though.
/// </summary>
/// <param name="value"></param>
/// <returns></returns>
public static Parameter CreateContentParameter(object value)
{
return new Parameter()
{
Values = new object[] { value },
ParameterType = ParameterType.Content,
};
}

/// <summary>
/// value should be a single value, not a list or any other enumerable
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public class RequestTransformContext
public RequestTransformContext(ApiInvocation apiInvocation, IApiSettings settings)
{
ApiInvocation = apiInvocation;
Data = settings.Data;
ContentSerializer = settings.Request.ContentSerializer;
ParameterValueFormatter = settings.Request.ParameterValueFormatter;
InsertMissingSlashBetweenBaseLocationAndVerbAttributeUrl = settings.Request.InsertMissingSlashBetweenBaseLocationAndVerbAttributeUrl;
Expand All @@ -19,6 +20,7 @@ public RequestTransformContext(ApiInvocation apiInvocation, IApiSettings setting
}

public ApiInvocation ApiInvocation { get; private set; }
public IDictionary<string, object> Data { get; private set; }
public string UrlTemplate { get; internal set; }
public IContentSerializer ContentSerializer { get; set; }
public IParameterValueFormatter ParameterValueFormatter { get; set; }
Expand Down
6 changes: 3 additions & 3 deletions WebAnchor/WebAnchor.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
</PropertyGroup>
<PropertyGroup>
<PackageVersion>6.2.1</PackageVersion>
<PackageVersion>6.2.2</PackageVersion>
<PackageId>WebAnchor</PackageId>
<Title>WebAnchor</Title>
<Authors>mattiasnordqvist;carl_berg</Authors>
Expand All @@ -16,8 +16,8 @@
<RepositoryUrl>https://github.com/mattiasnordqvist/Web-Anchor.git</RepositoryUrl>
<PackageIconUrl>https://github.com/mattiasnordqvist/Web-Anchor/raw/master/logo.png</PackageIconUrl>
<PackageTags>REST HTTP API JSON</PackageTags>
<PackageReleaseNotes>AddHeader-attribute is now "AllowMultiple"
ParameterCreatorTransformer does not clear list of parameters.</PackageReleaseNotes>
<PackageReleaseNotes>Added Data-dictionary to ApiSettings
Can now create ContentParameter without name</PackageReleaseNotes>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
</PropertyGroup>
<ItemGroup>
Expand Down

0 comments on commit 5d7fd6a

Please sign in to comment.