/// <summary> /// 初始化对象配置 /// </summary> /// <param name="xmlwr"></param> private void InitModelSetting(IO.XmlHelper xmlwr) { var modelnodes = xmlwr.GetNodeListByDelegate(delegate(XmlNode xn) { return xn.Name.Equals(ModelSettingNodeName, StringComparison.CurrentCultureIgnoreCase) && xn.ParentNode != null && xn.ParentNode.Name.Equals(ModelSettingParentNodeName, StringComparison.CurrentCultureIgnoreCase); }); if (modelnodes != null) { ModelSettings = new List<ModelSetting>(); foreach (var xn in modelnodes) { var model = new ModelSetting(); model.Contract = IO.XmlHelper.ReadAttributeValue(xn, "contract");//读取类型 model.TableName = IO.XmlHelper.ReadAttributeValue(xn, "TableName/value");//表名 model.PrimaryKey = IO.XmlHelper.ReadAttributeValue(xn, "PrimaryKey/value");//表的主健 //model.Fields = IO.XmlWR.ReadAttributeValue(xn, "Model/Fields/value");//字段 model.Mapping = IO.XmlHelper.ReadAttributeValue(xn, "Mapping/value");//获取映射 foreach (XmlNode cn in xn.ChildNodes) { if (cn.Name.Equals(SelectNodeName, StringComparison.OrdinalIgnoreCase))//查询字段 { model.Selects = GetCommandFromNode(cn); } else if (cn.Name.Equals(InsertNodeName, StringComparison.OrdinalIgnoreCase))//新增需要插入的字段 { model.InsertCommands = GetCommandFromNode(cn); } else if (cn.Name.Equals(UpdateNodeName, StringComparison.OrdinalIgnoreCase))//修改需要插入的字段 { model.UpdateCommands = GetCommandFromNode(cn); } } ModelSettings.Add(model); } } }
/// <summary> /// 初始化连接字符串 /// </summary> /// <param name="xmlwr"></param> private void InitConnectionSetting(IO.XmlHelper xmlwr) { var connodes = xmlwr.GetNodeListByDelegate(delegate(XmlNode xn) { return xn.Name.Equals(ConSettingNodeName, StringComparison.CurrentCultureIgnoreCase) && xn.ParentNode != null && xn.ParentNode.Name.Equals(ConSettingParentNodeName, StringComparison.CurrentCultureIgnoreCase); }); if (connodes != null) { ConSettings = new List<ConnSetting>(); foreach (var xn in connodes) { var con = new ConnSetting() { ConnectionString = IO.XmlHelper.ReadAttributeValue(xn, "connectionString"),//读取连接字符串 Name = IO.XmlHelper.ReadAttributeValue(xn, "name"),//读取配置名 ProviderName = IO.XmlHelper.ReadAttributeValue(xn, "providerName")//读取驱动 }; ConSettings.Add(con); } } }