Example #1
0
        private static string GetScript(string culture)
        {
            var script = new StringBuilder();

            script.Append("var Resources = {");

            var resources = DbResources.GetLocalizationTable(culture);

            var resourceClassGroup = resources
                                     .GroupBy(r => r.ResourceClass)
                                     .Select(group => group.ToList())
                                     .ToList();

            foreach (var resourceClass in resourceClassGroup)
            {
                int i = 0;

                foreach (var resource in resourceClass)
                {
                    if (i == 0)
                    {
                        script.Append(resource.ResourceClass + ": {");
                    }

                    script.Append(resource.Key + ": function(){ return \"");
                    string localized = resource.Translated;

                    if (string.IsNullOrWhiteSpace(localized))
                    {
                        localized = resource.Original;
                    }

                    script.Append(HttpUtility.JavaScriptStringEncode(localized));

                    script.Append("\";");
                    script.Append("},");
                    i++;
                }

                script.Append("},");
            }


            script.Append("};");

            return(script.ToString());
        }
Example #2
0
        private IDataSource GetDataSource()
        {
            var sourceName = Request.GetDataSource();

            // TODO, get the DbResource based on the sourceName
            var dbResources = new DbResources
            {
                DbTables = new List <string>
                {
                    "Table1"
                }
            };

            var dataSource = new SqlDataSource(dbResources);

            return(dataSource);
        }
Example #3
0
        private static void InitializeResourcesAsync(string tenant)
        {
            IDictionary <string, string> resources = DbResources.GetLocalizedResources(tenant);

            CacheFactory.AddToDefaultCache("Resources", resources);
        }
Example #4
0
        private static async Task InitializeResourcesAsync(string tenant)
        {
            IDictionary <string, string> resources = await DbResources.GetLocalizedResourcesAsync(tenant).ConfigureAwait(false);

            CacheFactory.AddToDefaultCache("Resources", resources);
        }
Example #5
0
 public DebrisField()
 {
     Resources = new DbResources();
 }
Example #6
0
 public DbPlanet()
 {
     Resources = new DbResources();
 }