Skip to content

Commit

Permalink
Merge pull request #111 from Sevitas/107_custom_type_provider_customi…
Browse files Browse the repository at this point in the history
…zation

fixes #107 -  Enable further customization of the CustomTypeProvider
  • Loading branch information
Sevitas authored Aug 12, 2021
2 parents 83a6202 + 770b3ed commit a8f1852
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,17 @@ namespace {_namespace}
{{
public class {CLASS_NAME} : ITypeProvider
{{
private static readonly Dictionary<Type, string> _codenames = new Dictionary<Type, string>
protected static readonly Dictionary<Type, string> _codenames = new Dictionary<Type, string>
{{
{CreateCodenameDictionaryValues()}
}};
public Type GetType(string contentType)
public virtual Type GetType(string contentType)
{{
return _codenames.Keys.FirstOrDefault(type => GetCodename(type).Equals(contentType));
}}
public string GetCodename(Type contentType)
public virtual string GetCodename(Type contentType)
{{
return _codenames.TryGetValue(contentType, out var codename) ? codename : null;
}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@ namespace KenticoKontentModels
{
public class CustomTypeProvider : ITypeProvider
{
private static readonly Dictionary<Type, string> _codenames = new Dictionary<Type, string>
protected static readonly Dictionary<Type, string> _codenames = new Dictionary<Type, string>
{
{typeof(Article), "article"},
{typeof(Office), "office"}
};

public Type GetType(string contentType)
public virtual Type GetType(string contentType)
{
return _codenames.Keys.FirstOrDefault(type => GetCodename(type).Equals(contentType));
}

public string GetCodename(Type contentType)
public virtual string GetCodename(Type contentType)
{
return _codenames.TryGetValue(contentType, out var codename) ? codename : null;
}
Expand Down

0 comments on commit a8f1852

Please sign in to comment.