Esempio n. 1
0
        public ListDictionary GetResourcesByCulture(string cultureName)
        {
            Debug.WriteLine(String.Format("StringResourcesLinq.GetResourceByCulture(culture:{0}) for resourceType:{1}", cultureName, this.resourceType));

            if (cultureName == null)
            {
                cultureName = "";
            }

            // create the dictionary
            ListDictionary resourceDictionary = new ListDictionary();

            // set up LINQ expression and get resource from database
            DBResourceDataClassesDataContext db  = getDataContext();
            IEnumerable <StringResource>     res = db.StringResources.Where(m => m.CultureCode.Equals(cultureName) && m.ResourceType.Equals(this.resourceType));

            foreach (StringResource r in res)
            {
                string k = r.ResourceKey;
                string v = r.ResourceValue;

                if (!resourceDictionary.Contains(k))
                {
                    resourceDictionary.Add(k, v);
                }
            }

            return(resourceDictionary);
        }
Esempio n. 2
0
        public ListDictionary GetResources()
        {
            Debug.WriteLine(String.Format("StringResourcesLinq.GetResources() for resourceType:{0}", this.resourceType));

            // create the dictionary
            ListDictionary resourceDictionary = new ListDictionary();

            // set up LINQ expression and get resource from database
            DBResourceDataClassesDataContext db  = getDataContext();
            IEnumerable <StringResource>     res = db.StringResources.Where(m => m.ResourceType.Equals(this.resourceType));

            foreach (StringResource r in res)
            {
                string culture = r.CultureCode;
                string k       = r.ResourceKey;
                string v       = r.ResourceValue;

                IDictionary resources = resourceDictionary[culture] as IDictionary;
                if (resources == null)
                {
                    resources = new ListDictionary();
                    resourceDictionary[culture] = resources;
                }

                if (!resources.Contains(k))
                {
                    resources.Add(k, v);
                }
            }

            return(resourceDictionary);
        }
Esempio n. 3
0
        private static DBResourceDataClassesDataContext getDataContext()
        {
            DBResourceDataClassesDataContext db = new DBResourceDataClassesDataContext();

            //db.Log = new DebuggerWriter();
            return(db);
        }