Exemple #1
0
        public void SetCache(string sessionid, DCUser2 dcusr)
        {
            Guid gd = Guid.NewGuid();

            CacheMgr.Add <string>(CryptoUtils.DecryptTripleDES(sessionid), gd.ToString());
            CacheMgr.Add <DCUser2>(gd.ToString(), dcusr);
        }
Exemple #2
0
        public static void RunTest()
        {
            CacheMgr <int> cacheMgr = new CacheMgr <int>();

            cacheMgr.Add("Testing", getTestingValue, 18);
            while (Console.Read() != 'x')
            {
                Console.WriteLine(cacheMgr.Get("Testing"));
            }
        }
        /// <summary>
        /// This function is loading up the meta data information from the assembly about the entities, its storage name
        /// and its logical mapping information. This information is cached so that the subsequent queries do not need to
        /// lookup these meta data. The entity framework adds the following xml meta data resource files into the assembly of
        /// the context class:
        ///
        ///     .csdl   : Conceptual schema definition language
        ///     .ssdl   : Storage schema definition language
        ///     .msl    : Mapping specification language
        ///
        /// Respectively these files describes the conceptual model, storage model, and the mapping between these models
        ///
        /// </summary>
        /// <param name="contextAssembly">Assembly where the context code reside.</param>
        /// <returns></returns>
        private static Assembly LoadMetaDataFromAssembly(Assembly contextAssembly)
        {
            foreach (string ssdlResourceName in contextAssembly.GetManifestResourceNames().Where(
                         r => r.EndsWith(".ssdl", StringComparison.CurrentCultureIgnoreCase)))
            {
                XDocument ssdlDoc = XDocument.Load(contextAssembly.GetManifestResourceStream(ssdlResourceName));

                //Find correct way to do this.
                string    mslResourceName = ssdlResourceName.Replace(".ssdl", ".msl");
                XDocument mslDoc          = XDocument.Load(contextAssembly.GetManifestResourceStream(
                                                               mslResourceName));

                XNamespace ns = mslDoc.Elements().First().GetDefaultNamespace();

                //mapping for storage name to EntitySetName
                Dictionary <string, XElement> storageNameToMappingFragment =
                    mslDoc.Descendants(ns + "EntityTypeMapping").ToDictionary(
                        e => e.Element(ns + "MappingFragment").Attribute("StoreEntitySet").Value,
                        e => e);

                ns = ssdlDoc.Elements().First().GetDefaultNamespace();

                foreach (XElement set in ssdlDoc.Descendants(ns + "EntityContainer")
                         .First().Elements(ns + "EntitySet"))
                {
                    string name = set.Attribute("Name").Value;
                    // Sometime in the same SSDL XML - We have both "Schema" or one adorned with namespace
                    string schema = set.Attributes().First(attr => attr.Name.LocalName.ToLower() == "schema").Value;

                    string typeName = storageNameToMappingFragment[name].Attribute("TypeName").Value;


                    QualifiedEntity entity = new QualifiedEntity(schema, name);

                    foreach (XElement prop in storageNameToMappingFragment[name].Descendants().Where(e => e.Name.LocalName == "ScalarProperty"))
                    {
                        entity._propertyToColumnMap.Add(prop.Attribute("Name").Value, prop.Attribute("ColumnName").Value);
                    }

                    _storageMetaData.Add(typeName, entity);
                }
            }

            return(contextAssembly);
        }