-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Pull request #1: Update latest code from github to stash
Merge in SST/vwo-dotnet-sdk-example from latestUpdate to master * commit 'e2c89002c75525dc40f4b73942c026ead0222c45': fix(update): Update latest code from github to stash
- Loading branch information
Showing
10 changed files
with
169 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -354,3 +354,4 @@ MigrationBackup/ | |
/VWOSdk.DemoApp/logs.txt | ||
|
||
.DS_STORE | ||
/VWOSdk.DemoApp/Resources/SettingsFile.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,47 @@ | ||
using System.IO; | ||
using System.Reflection; | ||
using System.Threading.Tasks; | ||
|
||
|
||
namespace VWOSdk.DemoApp.Controllers | ||
{ | ||
public class SettingsProvider | ||
{ | ||
public static Settings GetSettingsFile(long accountId, string sdkKey) | ||
{ | ||
if (accountId == 123456) | ||
return GetSettingsFile("DemoSettingsFile"); | ||
return VWO.GetSettingsFile(accountId, sdkKey); | ||
} | ||
|
||
private static Settings GetSettingsFile(string filename) | ||
{ | ||
string json = GetJsonText(filename); | ||
return Newtonsoft.Json.JsonConvert.DeserializeObject<Settings>(json); | ||
|
||
private static string _SettingsFilePath = Defaults.SettingsFilePath; | ||
public static Settings GetSettingsFile(long accountId, string sdkKey) | ||
{ | ||
if (File.Exists(_SettingsFilePath) == false) | ||
{ | ||
File.Create(_SettingsFilePath).Close(); | ||
} | ||
Settings SettingsFile = VWO.GetSettingsFile(accountId, sdkKey); | ||
_ = SaveAsync(SettingsFile); | ||
return SettingsFile; | ||
} | ||
|
||
private static string GetJsonText(string filename) | ||
public static async Task<Settings> GetAndUpdateSettingsFile(long accountId, string sdkKey) | ||
{ | ||
string path = null; | ||
|
||
foreach (var resource in Assembly.GetExecutingAssembly().GetManifestResourceNames()) | ||
if (File.Exists(_SettingsFilePath) == false) | ||
{ | ||
if (resource.Contains("." + filename + ".")) | ||
{ | ||
path = resource; | ||
break; | ||
} | ||
File.Create(_SettingsFilePath).Close(); | ||
} | ||
|
||
try | ||
Settings SettingsFile = VWO.GetAndUpdateSettingsFile(accountId, sdkKey); | ||
if (SettingsFile != null) | ||
{ | ||
var _assembly = Assembly.GetExecutingAssembly(); | ||
using (Stream resourceStream = _assembly.GetManifestResourceStream(path)) | ||
{ | ||
if (resourceStream == null) | ||
return null; | ||
|
||
using (StreamReader reader = new StreamReader(resourceStream)) | ||
{ | ||
return reader.ReadToEnd(); | ||
} | ||
} | ||
await File.WriteAllTextAsync(_SettingsFilePath, Newtonsoft.Json.JsonConvert.SerializeObject(SettingsFile, Newtonsoft.Json.Formatting.Indented)); | ||
} | ||
catch { } | ||
|
||
return null; | ||
return GetSettingsFile(); | ||
} | ||
public static async Task SaveAsync(Settings SettingsFile) | ||
{ | ||
await File.WriteAllTextAsync(_SettingsFilePath, Newtonsoft.Json.JsonConvert.SerializeObject(SettingsFile, Newtonsoft.Json.Formatting.Indented)); | ||
} | ||
private static Settings GetSettingsFile() | ||
{ | ||
string json = File.ReadAllText(_SettingsFilePath); | ||
return Newtonsoft.Json.JsonConvert.DeserializeObject<Settings>(json); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using Newtonsoft.Json; | ||
using System.Collections.Generic; | ||
|
||
namespace VWOSdk.DemoApp | ||
{ | ||
internal class FlushCallback : IFlushInterface | ||
{ | ||
public void onFlush(string error, object events) | ||
{ | ||
CustomLogger logger = new CustomLogger(); | ||
logger.WriteLog(LogLevel.DEBUG, "OnFlush call from SDK: " + events.ToString()); | ||
|
||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
using Newtonsoft.Json; | ||
using System.Collections.Generic; | ||
namespace VWOSdk.DemoApp | ||
{ | ||
internal class HookCallback : IntegrationEventListener | ||
{ | ||
public void onEvent(Dictionary<string, dynamic> properties) | ||
{ | ||
string payLoad = JsonConvert.SerializeObject(properties); | ||
CustomLogger logger = new CustomLogger(); | ||
logger.WriteLog(LogLevel.DEBUG, "onEvent call from SDK: " + payLoad); | ||
|
||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,15 @@ | ||
<Project Sdk="Microsoft.NET.Sdk.Web"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>netcoreapp2.0</TargetFramework> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<Content Remove="DemoSettingsFile.json" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.9" /> | ||
<PackageReference Include="Newtonsoft.Json" Version="12.0.2" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.4" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<EmbeddedResource Include="Resources\DemoSettingsFile.json" /> | ||
<ProjectReference Include="VWO.Sdk" Version="1.14.0" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="VWO.Sdk" Version="1.8.0" /> | ||
</ItemGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters