Example #1
0
        // <file path="file|path|resource" [embedded="bool"] />
        private void ParseFile(XmlNode fileNode, string defaultNamespace, string defaultSchema, string defaultHint)
        {
            string path = this.GetValue(fileNode, "path");
            bool   embedded;           // Default embedded is False

            switch (this.GetValue(fileNode, "embedded", "FALSE").ToUpper())
            {
            case "TRUE": embedded = true; break;

            default: embedded = false; break;
            }

            XmlDocument mappings = new XmlDocument();

            if (!embedded)
            {
                // Try to Automatically Resolve Path of Mapping File
                string fullPath = Mappings.GetFullPath(path);
                mappings.Load(fullPath);
            }
            else
            {
                // Try to Automatically Load Embedded Mapping File
                using (Stream stream = Mappings.GetResourceStream(path)) {
                    mappings.Load(stream);
                }
            }
#if DEBUG_MAPPER
            Debug.WriteLine("----- File = " + path + " -----");
#endif
            this.ParseMappings(mappings, defaultNamespace, defaultSchema, defaultHint);
        }
Example #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);
        }