Skip to content
This repository was archived by the owner on Dec 24, 2022. It is now read-only.

Commit 4df9d2f

Browse files
committed
Add GetAccessor API to TypeFields/TypeProperties
1 parent edeec9a commit 4df9d2f

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

src/ServiceStack.Text/TypeFields.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,13 @@ static TypeFields()
6565
}
6666
}
6767
}
68+
69+
public static TypeFieldInfo GetAccessor(string propertyName)
70+
{
71+
return Instance.FieldsMap.TryGetValue(propertyName, out TypeFieldInfo info)
72+
? info
73+
: null;
74+
}
6875
}
6976

7077
public abstract class TypeFields
@@ -96,6 +103,13 @@ public static TypeFields Get(Type type)
96103
return instance;
97104
}
98105

106+
public TypeFieldInfo GetAccessor(string propertyName)
107+
{
108+
return FieldsMap.TryGetValue(propertyName, out TypeFieldInfo info)
109+
? info
110+
: null;
111+
}
112+
99113
public Type Type { get; protected set; }
100114

101115
public readonly Dictionary<string, TypeFieldInfo> FieldsMap =

src/ServiceStack.Text/TypeProperties.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,13 @@ static TypeProperties()
5858
}
5959
}
6060
}
61+
62+
public static TypePropertyInfo GetAccessor(string propertyName)
63+
{
64+
return Instance.PropertyMap.TryGetValue(propertyName, out TypePropertyInfo info)
65+
? info
66+
: null;
67+
}
6168
}
6269

6370
public abstract class TypeProperties
@@ -89,6 +96,13 @@ public static TypeProperties Get(Type type)
8996
return instance;
9097
}
9198

99+
public TypePropertyInfo GetAccessor(string propertyName)
100+
{
101+
return PropertyMap.TryGetValue(propertyName, out TypePropertyInfo info)
102+
? info
103+
: null;
104+
}
105+
92106
public Type Type { get; protected set; }
93107

94108
public readonly Dictionary<string, TypePropertyInfo> PropertyMap =

0 commit comments

Comments
 (0)