Ejemplo n.º 1
0
        public void Init(string filePath)
        {
            if (string.IsNullOrEmpty(filePath))
            {
                throw new ArgumentNullException("filePath");
            }
            try
            {
                XmlDocument doc   = XmlFileParser.LoadXml(filePath);
                XmlNodeList nodes = XmlFileParser.Analyze(doc, "AlbianObjects");
                if (1 != nodes.Count) //root node
                {
                    throw new Exception("Analyze the Objects node is error in the Persistence.config");
                }

                ParserObjects(nodes[0]);
            }
            catch (Exception exc)
            {
                throw exc;
            }
        }
Ejemplo n.º 2
0
        public void Init(string filePath)
        {
            if (string.IsNullOrEmpty(filePath))
            {
                throw new ArgumentNullException("filePath");
            }
            try
            {
                XmlDocument doc   = XmlFileParser.LoadXml(filePath);
                XmlNodeList nodes = XmlFileParser.Analyze(doc, "Storages");
                if (1 != nodes.Count) //root node
                {
                    throw new Exception("Analyze the Storages node is error in the Storage.config");
                }

                IDictionary <string, IStorageAttribute> dic = ParserStorages(nodes[0]);
                if (null == dic)
                {
                    if (null != Logger)
                    {
                        Logger.Error("no storage attribute in the config file.");
                    }
                    throw new Exception("no storage attribute in the config file.");
                }
                foreach (KeyValuePair <string, IStorageAttribute> kv in dic)
                {
                    if (kv.Value.Pooling)
                    {
                        DbConnectionPoolManager.CreatePool(kv.Value.Name, kv.Value.DatabaseStyle, kv.Value.MinPoolSize,
                                                           kv.Value.MaxPoolSize);
                    }
                }
            }
            catch (Exception exc)
            {
                throw exc;
            }
        }