Exemple #1
0
        internal Context(Stream mappingStream, string connectString, CustomProvider customProvider,
                         int sessionMinutes, int cleanupMinutes)
        {
#if DEMO
            this.license = LicenseManager.Validate(this.GetType(), this);
#endif
            Mappings.LoadAssemblies();
            XmlDocument mappings = new XmlDocument();
            try {
                mappings.Load(mappingStream);
            }
            finally {
                if (mappingStream != null)
                {
                    mappingStream.Close();
                }
            }
            this.Init(mappings, connectString, customProvider, sessionMinutes, cleanupMinutes);
        }
Exemple #2
0
        internal Context(string mappingFile, string connectString, CustomProvider customProvider,
                         int sessionMinutes, int cleanupMinutes)
        {
#if DEMO
            this.license = LicenseManager.Validate(this.GetType(), this);
#endif
            Mappings.LoadAssemblies();
            XmlDocument mappings = new XmlDocument();
            if (mappingFile.IndexOf("/") > -1 || mappingFile.IndexOf("\\") > -1 || mappingFile.Split('.').Length <= 2)
            {
                // Try to Automatically Resolve Path of Mapping File
                string fullPath = Mappings.GetFullPath(mappingFile);
                mappings.Load(fullPath);
            }
            else
            {
                // Try to Automatically Load Embedded Mapping File
                using (Stream stream = Mappings.GetResourceStream(mappingFile)) {
                    mappings.Load(stream);
                }
            }
            this.Init(mappings, connectString, customProvider, sessionMinutes, cleanupMinutes);
        }