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

Commit 26b4b03

Browse files
committed
Renamed DittoTypeConfig to DittoTypeInfo
As it contains information about the Type, it's not a "configuration".
1 parent 3a29898 commit 26b4b03

File tree

7 files changed

+38
-38
lines changed

7 files changed

+38
-38
lines changed

src/Our.Umbraco.Ditto/Common/DittoTypeConfig.cs renamed to src/Our.Umbraco.Ditto/Common/DittoTypeInfo.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@
66

77
namespace Our.Umbraco.Ditto
88
{
9-
internal sealed class DittoTypeConfig
9+
internal sealed class DittoTypeInfo
1010
{
11-
public static DittoTypeConfig Create<T>()
11+
public static DittoTypeInfo Create<T>()
1212
{
1313
return Create(typeof(T));
1414
}
1515

16-
public static DittoTypeConfig Create(Type type)
16+
public static DittoTypeInfo Create(Type type)
1717
{
18-
var config = new DittoTypeConfig
18+
var config = new DittoTypeInfo
1919
{
2020
TargetType = type
2121
};
@@ -70,9 +70,9 @@ public static DittoTypeConfig Create(Type type)
7070

7171
// properties (lazy & eager)
7272
//
73-
var lazyProperties = new List<DittoTypePropertyConfig>();
73+
var lazyProperties = new List<DittoTypePropertyInfo>();
7474
var lazyPropertyNames = new List<string>();
75-
var eagerProperties = new List<DittoTypePropertyConfig>();
75+
var eagerProperties = new List<DittoTypePropertyInfo>();
7676

7777
// Collect all the properties of the given type and loop through writable ones.
7878
foreach (var property in type.GetProperties(BindingFlags.Public | BindingFlags.Instance))
@@ -90,7 +90,7 @@ public static DittoTypeConfig Create(Type type)
9090

9191
var propertyType = property.PropertyType;
9292

93-
var propertyConfig = new DittoTypePropertyConfig
93+
var propertyConfig = new DittoTypePropertyInfo
9494
{
9595
CustomAttributes = attributes,
9696
PropertyInfo = property,
@@ -223,17 +223,17 @@ public static DittoTypeConfig Create(Type type)
223223
public IEnumerable<Attribute> CustomAttributes { get; set; }
224224

225225
public bool HasLazyProperties { get; set; }
226-
public IEnumerable<DittoTypePropertyConfig> LazyProperties { get; set; }
226+
public IEnumerable<DittoTypePropertyInfo> LazyProperties { get; set; }
227227
public IEnumerable<string> LazyPropertyNames { get; set; }
228228

229229
public bool HasEagerProperties { get; set; }
230-
public IEnumerable<DittoTypePropertyConfig> EagerProperties { get; set; }
230+
public IEnumerable<DittoTypePropertyInfo> EagerProperties { get; set; }
231231

232232
public IEnumerable<DittoConversionHandler> ConversionHandlers { get; set; }
233233
public IEnumerable<MethodInfo> ConvertingMethods { get; set; }
234234
public IEnumerable<MethodInfo> ConvertedMethods { get; set; }
235235

236-
internal sealed class DittoTypePropertyConfig
236+
internal sealed class DittoTypePropertyInfo
237237
{
238238
public bool IsCacheable { get; set; }
239239
public DittoCacheAttribute CacheInfo { get; set; }

src/Our.Umbraco.Ditto/Common/DittoTypeConfigCache.cs renamed to src/Our.Umbraco.Ditto/Common/DittoTypeInfoCache.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33

44
namespace Our.Umbraco.Ditto
55
{
6-
internal static class DittoTypeConfigCache
6+
internal static class DittoTypeInfoCache
77
{
8-
private static readonly ConcurrentDictionary<Type, DittoTypeConfig> _cache = new ConcurrentDictionary<Type, DittoTypeConfig>();
8+
private static readonly ConcurrentDictionary<Type, DittoTypeInfo> _cache = new ConcurrentDictionary<Type, DittoTypeInfo>();
99

1010
public static void Add<T>()
1111
{
@@ -14,7 +14,7 @@ public static void Add<T>()
1414

1515
public static void Add(Type type)
1616
{
17-
_cache.TryAdd(type, DittoTypeConfig.Create(type));
17+
_cache.TryAdd(type, DittoTypeInfo.Create(type));
1818
}
1919

2020
public static void Clear<T>()
@@ -24,19 +24,19 @@ public static void Clear<T>()
2424

2525
public static void Clear(Type type)
2626
{
27-
_cache.TryRemove(type, out DittoTypeConfig config);
27+
_cache.TryRemove(type, out DittoTypeInfo config);
2828
}
2929

30-
public static DittoTypeConfig GetOrAdd<T>()
30+
public static DittoTypeInfo GetOrAdd<T>()
3131
{
3232
return GetOrAdd(typeof(T));
3333
}
3434

35-
public static DittoTypeConfig GetOrAdd(Type type)
35+
public static DittoTypeInfo GetOrAdd(Type type)
3636
{
37-
if (_cache.TryGetValue(type, out DittoTypeConfig config) == false)
37+
if (_cache.TryGetValue(type, out DittoTypeInfo config) == false)
3838
{
39-
config = DittoTypeConfig.Create(type);
39+
config = DittoTypeInfo.Create(type);
4040
_cache.TryAdd(type, config);
4141
}
4242

src/Our.Umbraco.Ditto/Extensions/PublishedContentExtensions.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ public static object As(
138138
// Convert
139139
using (DittoDisposableTimer.DebugDuration(typeof(Ditto), $"As<{type.Name}>({content.DocumentTypeAlias} {content.Id})"))
140140
{
141-
var config = DittoTypeConfigCache.GetOrAdd(type);
141+
var config = DittoTypeInfoCache.GetOrAdd(type);
142142

143143
if (config.IsCacheable)
144144
{
@@ -164,7 +164,7 @@ public static object As(
164164
/// <exception cref="InvalidOperationException">Thrown if the given type has invalid constructors.</exception>
165165
private static object ConvertContent(
166166
IPublishedContent content,
167-
DittoTypeConfig config,
167+
DittoTypeInfo config,
168168
CultureInfo culture,
169169
object instance,
170170
Action<DittoConversionHandlerContext> onConverting,
@@ -254,8 +254,8 @@ private static object ConvertContent(
254254
private static object GetProcessedValue(
255255
IPublishedContent content,
256256
CultureInfo culture,
257-
DittoTypeConfig config,
258-
DittoTypeConfig.DittoTypePropertyConfig mappableProperty,
257+
DittoTypeInfo config,
258+
DittoTypeInfo.DittoTypePropertyInfo mappableProperty,
259259
object instance,
260260
DittoChainContext chainContext)
261261
{
@@ -291,7 +291,7 @@ private static object GetProcessedValue(
291291
/// <returns>Returns the processed value.</returns>
292292
private static object DoGetProcessedValue(
293293
IPublishedContent content,
294-
DittoTypeConfig.DittoTypePropertyConfig mappableProperty,
294+
DittoTypeInfo.DittoTypePropertyInfo mappableProperty,
295295
DittoProcessorContext baseProcessorContext,
296296
DittoChainContext chainContext)
297297
{
@@ -344,7 +344,7 @@ private static object DoGetProcessedValue(
344344
/// <param name="callback">The <see cref="Action{ConversionHandlerContext}"/> to fire when converting.</param>
345345
private static void OnConverting(
346346
IPublishedContent content,
347-
DittoTypeConfig config,
347+
DittoTypeInfo config,
348348
CultureInfo culture,
349349
object instance,
350350
Action<DittoConversionHandlerContext> callback)
@@ -366,7 +366,7 @@ private static void OnConverting(
366366
/// <param name="callback">The <see cref="Action{ConversionHandlerContext}"/> to fire when converted.</param>
367367
private static void OnConverted(
368368
IPublishedContent content,
369-
DittoTypeConfig config,
369+
DittoTypeInfo config,
370370
CultureInfo culture,
371371
object instance,
372372
Action<DittoConversionHandlerContext> callback)
@@ -391,7 +391,7 @@ private static void OnConverted(
391391
private static void OnConvert<TAttributeType>(
392392
DittoConversionHandlerType conversionType,
393393
IPublishedContent content,
394-
DittoTypeConfig config,
394+
DittoTypeInfo config,
395395
CultureInfo culture,
396396
object instance,
397397
Action<DittoConversionHandlerContext> callback)

src/Our.Umbraco.Ditto/Our.Umbraco.Ditto.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@
8181
<ItemGroup>
8282
<Compile Include="Bootstrapper.cs" />
8383
<Compile Include="Common\CachedInvocations.cs" />
84-
<Compile Include="Common\DittoTypeConfigCache.cs" />
85-
<Compile Include="Common\DittoTypeConfig.cs" />
84+
<Compile Include="Common\DittoTypeInfoCache.cs" />
85+
<Compile Include="Common\DittoTypeInfo.cs" />
8686
<Compile Include="Common\FastPropertyAccessor.cs" />
8787
<Compile Include="Common\DittoContextAccessor.cs" />
8888
<Compile Include="ComponentModel\Attributes\DittoDefaultProcessorAttribute.cs" />

tests/Our.Umbraco.Ditto.PerformanceTests/PublishedContentMapping.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public void Setup()
5050
Ditto.DeregisterPostProcessorType<TryConvertToAttribute>();
5151

5252
// pre-load the type config
53-
DittoTypeConfigCache.Add<BasicModel>();
53+
DittoTypeInfoCache.Add<BasicModel>();
5454
}
5555

5656
[Benchmark(Baseline = true)]

tests/Our.Umbraco.Ditto.Tests/DefaultProcessorTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public void Default_Processor_GlobalLevel_IsUsed()
7272
Ditto.RegisterDefaultProcessorType<UmbracoPropertyAttribute>();
7373

7474
// ...and clear the type-config cache
75-
DittoTypeConfigCache.Clear<MyModel>();
75+
DittoTypeInfoCache.Clear<MyModel>();
7676
}
7777
}
7878
}

tests/Our.Umbraco.Ditto.Tests/PropertySourceMappingTests.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,31 +52,31 @@ public void PropertySource_Properties_Map()
5252
};
5353

5454
Ditto.DefaultPropertySource = PropertySource.InstanceThenUmbracoProperties;
55-
DittoTypeConfigCache.Clear<BasicModelProperty>();
55+
DittoTypeInfoCache.Clear<BasicModelProperty>();
5656

5757
var model = content.As<BasicModelProperty>();
5858
Assert.AreEqual(instanceName, model.Name);
5959
Assert.AreEqual(instanceUrl, model.Url);
6060
Assert.AreEqual(customProp, model.Custom);
6161

6262
Ditto.DefaultPropertySource = PropertySource.UmbracoThenInstanceProperties;
63-
DittoTypeConfigCache.Clear<BasicModelProperty>();
63+
DittoTypeInfoCache.Clear<BasicModelProperty>();
6464

6565
model = content.As<BasicModelProperty>();
6666
Assert.AreEqual(customName, model.Name);
6767
Assert.AreEqual(instanceUrl, model.Url);
6868
Assert.AreEqual(customProp, model.Custom);
6969

7070
Ditto.DefaultPropertySource = PropertySource.InstanceProperties;
71-
DittoTypeConfigCache.Clear<BasicModelProperty>();
71+
DittoTypeInfoCache.Clear<BasicModelProperty>();
7272

7373
model = content.As<BasicModelProperty>();
7474
Assert.AreEqual(instanceName, model.Name);
7575
Assert.AreEqual(instanceUrl, model.Url);
7676
Assert.IsNull(model.Custom);
7777

7878
Ditto.DefaultPropertySource = PropertySource.UmbracoProperties;
79-
DittoTypeConfigCache.Clear<BasicModelProperty>();
79+
DittoTypeInfoCache.Clear<BasicModelProperty>();
8080

8181
model = content.As<BasicModelProperty>();
8282
Assert.AreEqual(customName, model.Name);
@@ -85,7 +85,7 @@ public void PropertySource_Properties_Map()
8585

8686
// Reset
8787
Ditto.DefaultPropertySource = PropertySource.InstanceThenUmbracoProperties;
88-
DittoTypeConfigCache.Clear<BasicModelProperty>();
88+
DittoTypeInfoCache.Clear<BasicModelProperty>();
8989
}
9090

9191
[Test]
@@ -152,7 +152,7 @@ public void PropertySource_Hidden_Properties_Warn()
152152

153153
// Check for hidden Umbraco properties
154154
Ditto.DefaultPropertySource = PropertySource.InstanceThenUmbracoProperties;
155-
DittoTypeConfigCache.Clear<BasicModelProperty>();
155+
DittoTypeInfoCache.Clear<BasicModelProperty>();
156156

157157
var model = content.As<BasicModelProperty>();
158158

@@ -165,7 +165,7 @@ public void PropertySource_Hidden_Properties_Warn()
165165
mockLogger.ClearLogMessages();
166166

167167
Ditto.DefaultPropertySource = PropertySource.UmbracoThenInstanceProperties;
168-
DittoTypeConfigCache.Clear<BasicModelProperty>();
168+
DittoTypeInfoCache.Clear<BasicModelProperty>();
169169

170170
model = content.As<BasicModelProperty>();
171171

@@ -176,7 +176,7 @@ public void PropertySource_Hidden_Properties_Warn()
176176

177177
// Reset
178178
Ditto.DefaultPropertySource = PropertySource.InstanceThenUmbracoProperties;
179-
DittoTypeConfigCache.Clear<BasicModelProperty>();
179+
DittoTypeInfoCache.Clear<BasicModelProperty>();
180180
}
181181
}
182182
}

0 commit comments

Comments
 (0)