Skip to content

Commit 928a4ff

Browse files
committed
keep options.Transcoder working and support new style.
1 parent 8fe85ba commit 928a4ff

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

Enyim.Caching/Configuration/MemcachedClientConfiguration.cs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,26 @@ public MemcachedClientConfiguration(
133133
NodeLocator = options.Servers.Count > 1 ? typeof(DefaultNodeLocator) : typeof(SingleNodeLocator);
134134
}
135135

136-
if (transcoder != null)
136+
if (!string.IsNullOrEmpty(options.Transcoder))
137+
{
138+
try
139+
{
140+
if (options.Transcoder == "BinaryFormatterTranscoder")
141+
options.Transcoder = "Enyim.Caching.Memcached.Transcoders.BinaryFormatterTranscoder";
142+
143+
var transcoderType = Type.GetType(options.Transcoder);
144+
if (transcoderType != null)
145+
{
146+
Transcoder = Activator.CreateInstance(transcoderType) as ITranscoder;
147+
_logger.LogDebug($"Use '{options.Transcoder}'");
148+
}
149+
}
150+
catch (Exception ex)
151+
{
152+
_logger.LogError(new EventId(), ex, $"Unable to load '{options.Transcoder}'");
153+
}
154+
}
155+
else if (transcoder != null)
137156
{
138157
this._transcoder = transcoder;
139158
_logger.LogDebug($"Use Transcoder Type : '{transcoder.ToString()}'");

0 commit comments

Comments
 (0)