AdsInfoAccessor 1.0.0

dotnet add package AdsInfoAccessor --version 1.0.0
NuGet\Install-Package AdsInfoAccessor -Version 1.0.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="AdsInfoAccessor" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add AdsInfoAccessor --version 1.0.0
#r "nuget: AdsInfoAccessor, 1.0.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install AdsInfoAccessor as a Cake Addin
#addin nuget:?package=AdsInfoAccessor&version=1.0.0

// Install AdsInfoAccessor as a Cake Tool
#tool nuget:?package=AdsInfoAccessor&version=1.0.0

AdsInfoAccessor

AdsInfoAccessor is a library that provides single point to get common info in your application pipeline.

Features - Data providers

  1. Get data from configuration
  2. Get data from request headers
  3. Get data from bearer token.

Get It Started

Configuration

You can easy configure and use AdsInfoAccessor in you .NET Core & .NET applications.

If you're using .NET 5 & alter versions, you can put the following line of code in your Program.cs file.


using AdsInfoAccessor;

var builder = WebApplication.CreateBuilder(args);
builder.Services.AddAdsInfo();

...

app.Run();

If you're using .NET Core app, you can put the following line in your Startup.cs file ConfigureServices method.


using AdsPush.Extensions;
...

public override void ConfigureServices(IServiceCollection services)
{
    services.AddAdsPush<MyProvider>();
}  
...    

Usage

  • Create your info model.

using AdsInfoAccessor;

public class SampleInfo : IAdsInfo
{
    [InfoFromJwtClaim("sub")]
    public long UserId { get; set; }
    
    [InfoFromConfiguration("ASPNETCORE_ENVIRONMENT")]
    public Env CurrentEnv { get; set; }

    [InfoFromHeader("x-clientIp")]
    public string ClientIp { get; set; }

    [InfoFromHeader("x-deviceModel")]
    public string DeviceModel { get; set; }

    [InfoSubObject]
    public SampleSubInfo SubInfo { get; set; }
}

public class SampleSubInfo : IAdsInfo
{
    [InfoFromJwtClaim("sub")]
    public long AnOtherUserId { get; set; }
}

public enum Env
{
    Unknown,    
    Development,
    Production
}

  • Use IAdsInfoAccessor interface to get info instance.

app.MapGet("/", (
    IAdsInfoAccessor adsInfoAccessor) =>
{
    var info = adsInfoAccessor.GetInfo<SampleInfo>();
    return Results.Ok(info);
});

Now, you can test by making the following sample request.

curl --location 'http://localhost:5181' \
--header 'x-deviceModel: iPhone 12 Pro Max' \
--header 'x-clientIp: 52.52.52.52' \
--header 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJPbmxpbmUgSldUIEJ1aWxkZXIiLCJpYXQiOjE2Nzg2MjU4MDksImV4cCI6MTcxMDE2MTgwOSwiYXVkIjoid3d3LmV4YW1wbGUuY29tIiwic3ViIjoiMTIxMjEiLCJHaXZlbk5hbWUiOiJKb2hubnkiLCJTdXJuYW1lIjoiUm9ja2V0IiwiRW1haWwiOiJqcm9ja2V0QGV4YW1wbGUuY29tIiwiUm9sZSI6WyJNYW5hZ2VyIiwiUHJvamVjdCBBZG1pbmlzdHJhdG9yIl19.Urn9phKqdztKf7QI7CmAjCpWB9pBjZchGFTTH-Swdwo' \
--data ''

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.0 161 3/12/2023