GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Proxy/src/NetCoreStack.Proxy/ProxyMetadataProvider.cs at master · NetCoreStack/Proxy

Expand file tree

/

ProxyMetadataProvider.cs

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
95 lines (77 loc) · 2.85 KB
/

ProxyMetadataProvider.cs

Copy path

File metadata and controls

95 lines (77 loc) · 2.85 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
92
93
94
95
using System;
using System.Collections.Concurrent;
using System.Reflection;
namespace NetCoreStack.Proxy
{
public class ProxyMetadataProvider
{
private readonly TypeCache _typeCache = new TypeCache();
private readonly Func<ProxyModelMetadataIdentity, ProxyModelMetadataCacheEntry> _cacheEntryFactory;
private readonly ProxyModelMetadataCacheEntry _metadataCacheEntryForObjectType;
public ProxyMetadataProvider()
{
_cacheEntryFactory = CreateCacheEntry;
_metadataCacheEntryForObjectType = GetMetadataCacheEntryForObjectType();
}
private ProxyModelMetadataCacheEntry GetMetadataCacheEntryForObjectType()
{
var key = ProxyModelMetadataIdentity.ForType(typeof(object));
var entry = CreateCacheEntry(key);
return entry;
}
private ProxyModelMetadataCacheEntry CreateCacheEntry(ProxyModelMetadataIdentity key)
{
var metadata = new ProxyModelMetadata(key);
return new ProxyModelMetadataCacheEntry(metadata);
}
private ProxyModelMetadataCacheEntry GetCacheEntry(Type modelType)
{
ProxyModelMetadataCacheEntry cacheEntry;
if (modelType == typeof(object))
{
cacheEntry = _metadataCacheEntryForObjectType;
}
else
{
var key = ProxyModelMetadataIdentity.ForType(modelType);
cacheEntry = _typeCache.GetOrAdd(key, _cacheEntryFactory);
}
return cacheEntry;
}
private ProxyModelMetadataCacheEntry GetCacheEntry(ParameterInfo parameter)
{
return _typeCache.GetOrAdd(
ProxyModelMetadataIdentity.ForParameter(parameter),
_cacheEntryFactory);
}
public ProxyModelMetadata GetMetadataForParameter(ParameterInfo parameter)
{
if (parameter == null)
{
throw new ArgumentNullException(nameof(parameter));
}
var cacheEntry = GetCacheEntry(parameter);
return cacheEntry.Metadata;
}
public ProxyModelMetadata GetMetadataForType(Type modelType)
{
if (modelType == null)
{
throw new ArgumentNullException(nameof(modelType));
}
var cacheEntry = GetCacheEntry(modelType);
return cacheEntry.Metadata;
}
private class TypeCache : ConcurrentDictionary<ProxyModelMetadataIdentity, ProxyModelMetadataCacheEntry>
{
}
private struct ProxyModelMetadataCacheEntry
{
public ProxyModelMetadataCacheEntry(ProxyModelMetadata metadata)
{
Metadata = metadata;
}
public ProxyModelMetadata Metadata { get; }
}
}
}
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.