Profiles.ORNG.Utilities.OpenSocialManager.GetAllDBGadgets C# (CSharp) Method

GetAllDBGadgets() public static method

public static GetAllDBGadgets ( bool useCache ) : GadgetSpec>.Dictionary
useCache bool
return GadgetSpec>.Dictionary
        public static Dictionary<string, GadgetSpec> GetAllDBGadgets(bool useCache)
        {
            // check cache first
            Dictionary<string, GadgetSpec> dbApps = useCache ? (Dictionary<string, GadgetSpec>)Cache.FetchObject(ORNG_GADGET_SPEC_KEY) : null;
            if (dbApps == null)
            {
                dbApps = new Dictionary<string, GadgetSpec>();
                Profiles.ORNG.Utilities.DataIO data = new Profiles.ORNG.Utilities.DataIO();
                using (SqlDataReader dr = data.GetGadgets())
                {
                    while (dr.Read())
                    {
                        GadgetSpec spec = new GadgetSpec(Convert.ToInt32(dr[0]), dr[1].ToString(), dr[2].ToString(), Convert.ToBoolean(dr[3]));
                        dbApps.Add(spec.GetFileName(), spec);
                    }
                }

                // add to cache unless noCache is turned on
                if (useCache)
                {
                    // set it to not timeout
                    Cache.Set(ORNG_GADGET_SPEC_KEY, dbApps, -1, null);
                }
            }

            return dbApps;
        }