private static Dictionary <string, string> CreateDictionary() { var fields = typeof(TemplateConstants) .GetFields(BindingFlags.Public | BindingFlags.Static | BindingFlags.FlattenHierarchy); var constants = fields.Where(f => f.IsLiteral && !f.IsInitOnly).ToList(); var result = new Dictionary <string, string>(); var instance = new TemplateConstants(); // Up to you if you want to filter the constants further to only include those // with string values. constants.ForEach(constant => result.Add(constant.Name, constant.GetValue(instance).ToString())); return(result); }
private static DeviceInstallation CreateDeviceInstallation(string pushPlatfrom, string registrationId, IList <string> pushTags = null) { InstallationId = registrationId; var pushChannel = registrationId; dynamic pushTemplates = new ExpandoObject(); switch (pushPlatfrom) { case PushPlatforms.ANDROID: pushTemplates = TemplateConstants.GetAndroidTemplates(); break; case PushPlatforms.IOS: InstallationId = ParseDeviceToken(registrationId); pushChannel = ParseDeviceToken(registrationId); pushTemplates = TemplateConstants.GetIosTemplates(); break; case PushPlatforms.WINDOWS: InstallationId = GetSha1Hash(registrationId); pushTemplates = TemplateConstants.GetWindowsTemplates(); break; default: break; } if (pushTags == null) { pushTags = new List <string>(); } pushTags.Add($"id:{InstallationId}"); return(new DeviceInstallation { templates = pushTemplates, installationId = InstallationId, platform = pushPlatfrom, pushChannel = pushChannel, tags = pushTags.ToArray() }); }
public void TestDictionary() { var dictionary = TemplateConstants.AsDictionary(); Assert.AreEqual(dictionary["Type"], TemplateConstants.Type); }