diff options
author | E.Z. Hart <hartez@gmail.com> | 2016-03-24 10:33:32 -0600 |
---|---|---|
committer | E.Z. Hart <hartez@gmail.com> | 2016-03-24 10:48:21 -0600 |
commit | 1dcf5fef35c1c09e64f3c9e9ce6a31d2d0c3cd4a (patch) | |
tree | 2d3ae2fe8ef99ccca22306ecf530053d32d3bab1 /Xamarin.Forms.Controls | |
parent | a9e90a88ed401a8605b9798d4566d09a7192e280 (diff) | |
download | xamarin-forms-1dcf5fef35c1c09e64f3c9e9ce6a31d2d0c3cd4a.tar.gz xamarin-forms-1dcf5fef35c1c09e64f3c9e9ce6a31d2d0c3cd4a.tar.bz2 xamarin-forms-1dcf5fef35c1c09e64f3c9e9ce6a31d2d0c3cd4a.zip |
Move initialization of configuration files (if needed) to a pre-build task
Remove unneeded init scripts
Diffstat (limited to 'Xamarin.Forms.Controls')
-rw-r--r-- | Xamarin.Forms.Controls/App.cs | 34 | ||||
-rw-r--r-- | Xamarin.Forms.Controls/Xamarin.Forms.Controls.csproj | 10 | ||||
-rw-r--r-- | Xamarin.Forms.Controls/blank.config | 0 |
3 files changed, 31 insertions, 13 deletions
diff --git a/Xamarin.Forms.Controls/App.cs b/Xamarin.Forms.Controls/App.cs index 53424cce..975faf8c 100644 --- a/Xamarin.Forms.Controls/App.cs +++ b/Xamarin.Forms.Controls/App.cs @@ -72,7 +72,21 @@ namespace Xamarin.Forms.Controls public class App : Application { - public string InsightsApiKey = Secrets["InsightsApiKey"]; + static string s_insightsKey; + public static string InsightsApiKey + { + get + { + if (s_insightsKey == null) + { + var key = Config["InsightsApiKey"]; + s_insightsKey = string.IsNullOrEmpty(key) ? Insights.DebugModeKey : key; + } + + return s_insightsKey; + } + } + public const string AppName = "XamarinFormsControls"; public const string AppVersion = "1.4.3"; public static int IOSVersion = -1; @@ -153,11 +167,11 @@ namespace Xamarin.Forms.Controls return text; } - public static void InitSecrets () + public static void LoadConfig () { - secrets = new Dictionary<string, string> (); + s_config = new Dictionary<string, string> (); - string keyData = LoadResource ("secrets.txt").Result; + string keyData = LoadResource ("controlgallery.config").Result; string[] entries = keyData.Split ("\n\r".ToCharArray (), StringSplitOptions.RemoveEmptyEntries); foreach (string entry in entries) { string[] parts = entry.Split (':'); @@ -165,21 +179,21 @@ namespace Xamarin.Forms.Controls continue; } - secrets.Add (parts[0].Trim (), parts[1].Trim ()); + s_config.Add (parts[0].Trim (), parts[1].Trim ()); } } - private static Dictionary<string, string> secrets; + static Dictionary<string, string> s_config; - public static Dictionary<string, string> Secrets + public static Dictionary<string, string> Config { get { - if (secrets == null) { - InitSecrets (); + if (s_config == null) { + LoadConfig (); } - return secrets; + return s_config; } } } diff --git a/Xamarin.Forms.Controls/Xamarin.Forms.Controls.csproj b/Xamarin.Forms.Controls/Xamarin.Forms.Controls.csproj index c56b1436..fbccef9e 100644 --- a/Xamarin.Forms.Controls/Xamarin.Forms.Controls.csproj +++ b/Xamarin.Forms.Controls/Xamarin.Forms.Controls.csproj @@ -266,6 +266,7 @@ </ItemGroup> <ItemGroup> <None Include="app.config" /> + <EmbeddedResource Include="controlgallery.config" /> <None Include="packages.config" /> </ItemGroup> <ItemGroup> @@ -278,8 +279,11 @@ <SubType>Designer</SubType> </EmbeddedResource> </ItemGroup> - <ItemGroup> - <EmbeddedResource Include="secrets.txt" /> - </ItemGroup> <Import Project="..\packages\Xamarin.Insights.1.11.4\build\portable-win+net45+wp80+windows8+wpa+MonoAndroid10+MonoTouch10\Xamarin.Insights.targets" Condition="Exists('..\packages\Xamarin.Insights.1.11.4\build\portable-win+net45+wp80+windows8+wpa+MonoAndroid10+MonoTouch10\Xamarin.Insights.targets')" /> + <Target Name="BeforeBuild"> + <CreateItem Include="blank.config"> + <Output TaskParameter="Include" ItemName="ConfigFile" /> + </CreateItem> + <Copy SourceFiles="@(ConfigFile)" DestinationFiles="controlgallery.config" Condition="!Exists('controlgallery.config')" /> + </Target> </Project>
\ No newline at end of file diff --git a/Xamarin.Forms.Controls/blank.config b/Xamarin.Forms.Controls/blank.config new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/Xamarin.Forms.Controls/blank.config |