-
Notifications
You must be signed in to change notification settings - Fork 129
Expand file tree
/
Copy pathIReadOnlyCollectionExtensions.cs
More file actions
50 lines (45 loc) · 1.41 KB
/
IReadOnlyCollectionExtensions.cs
File metadata and controls
50 lines (45 loc) · 1.41 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
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
namespace Microsoft.SCIM
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
public static class IReadOnlyCollectionExtensions
{
public static IReadOnlyCollection<string> Encode(this IReadOnlyCollection<string> collection)
{
IReadOnlyCollection<string> result =
collection
.Select(
(string item) =>
HttpUtility.UrlEncode(item))
.ToArray();
return result;
}
public static bool TryGetPath(
this IReadOnlyCollection<IExtension> extensions,
string schemaIdentifier,
out string path)
{
if (string.IsNullOrWhiteSpace(schemaIdentifier))
{
throw new ArgumentNullException(nameof(schemaIdentifier));
}
path = null;
IExtension
extension =
extensions
.SingleOrDefault(
(IExtension item) =>
string.Equals(schemaIdentifier, item.SchemaIdentifier, StringComparison.OrdinalIgnoreCase));
if (null == extension)
{
return false;
}
path = extension.Path;
return true;
}
}
}