-
Notifications
You must be signed in to change notification settings - Fork 129
Expand file tree
/
Copy pathExtension.cs
More file actions
91 lines (77 loc) · 2.57 KB
/
Extension.cs
File metadata and controls
91 lines (77 loc) · 2.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
namespace Microsoft.SCIM
{
using System;
using System.Net.Http;
public abstract class Extension : IExtension
{
private const string ArgumentNameController = "controller";
private const string ArgumentNameJsonDeserializingFactory = "jsonDeserializingFactory";
private const string ArgumentNamePath = "path";
private const string ArgumentNameSchemaIdentifier = "schemaIdentifier";
private const string ArgumentNameTypeName = "typeName";
protected Extension(
string schemaIdentifier,
string typeName,
string path,
Type controller,
JsonDeserializingFactory jsonDeserializingFactory)
{
if (string.IsNullOrWhiteSpace(schemaIdentifier))
{
throw new ArgumentNullException(Extension.ArgumentNameSchemaIdentifier);
}
if (string.IsNullOrWhiteSpace(typeName))
{
throw new ArgumentNullException(Extension.ArgumentNameTypeName);
}
if (string.IsNullOrWhiteSpace(path))
{
throw new ArgumentNullException(Extension.ArgumentNamePath);
}
this.SchemaIdentifier = schemaIdentifier;
this.TypeName = typeName;
this.Path = path;
this.Controller = controller ?? throw new ArgumentNullException(Extension.ArgumentNameController);
this.JsonDeserializingFactory = jsonDeserializingFactory ?? throw new ArgumentNullException(Extension.ArgumentNameJsonDeserializingFactory);
}
public Type Controller
{
get;
private set;
}
public JsonDeserializingFactory JsonDeserializingFactory
{
get;
private set;
}
public string Path
{
get;
private set;
}
public string SchemaIdentifier
{
get;
private set;
}
public string TypeName
{
get;
private set;
}
public virtual bool Supports(HttpRequestMessage request)
{
if (request == null)
{
throw new ArgumentNullException(nameof(request));
}
bool result =
request.RequestUri?.AbsolutePath?.EndsWith(
this.Path,
StringComparison.OrdinalIgnoreCase) == true;
return result;
}
}
}