diff options
author | Dennis Kobert <d-kobert@web.de> | 2019-06-11 23:38:13 +0200 |
---|---|---|
committer | Dennis Kobert <d-kobert@web.de> | 2019-06-11 23:38:13 +0200 |
commit | 2fa4a0e50ebfc97059c8b84dbd17e79f9afc8a8d (patch) | |
tree | c3b34ccb2737e347a73768536895cbbaab13cc01 /dsa/FireBase/Query/AuthQuery.cs | |
parent | ec991104f56e90d7bb2878da2fe6ed4e585dfc46 (diff) | |
parent | af74efccf8d21e6151022b71f3cacd3fa83024ee (diff) |
Merge branch 'rework-backend'
Diffstat (limited to 'dsa/FireBase/Query/AuthQuery.cs')
-rw-r--r-- | dsa/FireBase/Query/AuthQuery.cs | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/dsa/FireBase/Query/AuthQuery.cs b/dsa/FireBase/Query/AuthQuery.cs new file mode 100644 index 0000000..2cfda3c --- /dev/null +++ b/dsa/FireBase/Query/AuthQuery.cs @@ -0,0 +1,34 @@ +using System; + +namespace Firebase.Database.Query +{ + /// <summary> + /// Represents an auth parameter in firebase query, e.g. "?auth=xyz". + /// </summary> + public class AuthQuery : ParameterQuery + { + private readonly Func<string> tokenFactory; + + /// <summary> + /// Initializes a new instance of the <see cref="AuthQuery" /> class. + /// </summary> + /// <param name="parent"> The parent. </param> + /// <param name="tokenFactory"> The authentication token factory. </param> + /// <param name="client"> The owner. </param> + public AuthQuery(FirebaseQuery parent, Func<string> tokenFactory, FirebaseClient client) : base(parent, + () => client.Options.AsAccessToken ? "access_token" : "auth", client) + { + this.tokenFactory = tokenFactory; + } + + /// <summary> + /// Build the url parameter value of this child. + /// </summary> + /// <param name="child"> The child of this child. </param> + /// <returns> The <see cref="string" />. </returns> + protected override string BuildUrlParameter(FirebaseQuery child) + { + return tokenFactory(); + } + } +}
\ No newline at end of file |