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

Commit

Permalink
Add auto inferring PCL provider code to SS.Text PclExport as well
Browse files Browse the repository at this point in the history
  • Loading branch information
mythz committed Jan 16, 2014
1 parent 359dce1 commit 19ee97b
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/ServiceStack.Text/PclExport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,34 @@ static PclExport()
{
if (Instance != null)
return;

try
{
if (ConfigureProvider("ServiceStack.IosPclExportClient, ServiceStack.Pcl.iOS"))
return;
if (ConfigureProvider("ServiceStack.AndroidPclExportClient, ServiceStack.Pcl.Android"))
return;
if (ConfigureProvider("ServiceStack.WinStorePclExportClient, ServiceStack.Pcl.WinStore"))
return;
if (ConfigureProvider("ServiceStack.Net40PclExportClient, ServiceStack.Pcl.Net45"))
return;
}
catch (Exception /*ignore*/) {}
}

public static bool ConfigureProvider(string typeName)
{
var type = Type.GetType(typeName);
if (type == null)
return false;

var mi = type.GetMethod("Configure");
if (mi != null)
{
mi.Invoke(null, new object[0]);
}

return true;
}

public static void Configure(PclExport instance)
Expand Down

0 comments on commit 19ee97b

Please sign in to comment.