예제 #1
0
 /// <summary>
 /// 填充表
 /// </summary>
 /// <param name="info"></param>
 /// <param name="node"></param>
 protected virtual void FillOrmObjectBaseByXmlNode(OrmObjectInfo info, XmlNode node)
 {
     if (node.Attributes == null)
     {
         return;
     }
     info.ObjectName     = node.Attributes["ObjectName"] != null ? node.Attributes["ObjectName"].Value : null;
     info.Key            = node.Attributes["KeyName"] != null ? node.Attributes["KeyName"].Value : null;
     info.GetTableName   = node.Attributes["GetTableName"] != null ? node.Attributes["GetTableName"].Value.ToLower() : null;
     info.GetDataBase    = node.Attributes["GetDataBase"] != null ? node.Attributes["GetDataBase"].Value.ToLower() : null;
     info.NickObjectName = node.Attributes["NickObjectName"] != null ? node.Attributes["NickObjectName"].Value : null;
     info.SetTableName   = node.Attributes["SetTableName"] == null ? info.GetTableName : node.Attributes["SetTableName"].Value.ToLower();
     if (node.Attributes["CacheType"] != null)
     {
         info.CacheType = (CacheType)Enum.Parse(typeof(CacheType), node.Attributes["CacheType"].Value);
     }
     if (node.Attributes["IsCacheDependency"] != null)
     {
         info.IsCacheDependency = bool.Parse(node.Attributes["IsCacheDependency"].Value);
     }
     if (node.Attributes["CacheTime"] != null)
     {
         info.CacheTime = Convert.ToInt64(node.Attributes["CacheTime"].Value);
     }
     info.SetDataBase = node.Attributes["SetDataBase"] == null ? info.GetDataBase : node.Attributes["SetDataBase"].Value.ToLower();
     info.RouteName   = node.Attributes["RouteName"] == null ? "" : node.Attributes["RouteName"].Value.ToLower();
 }
예제 #2
0
 /// <summary>
 /// 填充map基本属性
 /// </summary>
 /// <param name="ormObject"></param>
 /// <param name="property"></param>
 /// <param name="node"></param>
 protected virtual void FillOrmPropertyMapKeyByXmlNode(OrmObjectInfo ormObject, OrmPropertyInfo property, XmlNode node)
 {
     if (node == null || node.Attributes == null)
     {
         return;
     }
     property.Map.ObjectProperty    = ormObject.GetPropertyInfo(node.Attributes["ObjectProperty"].Value);
     property.Map.MapObjectProperty = property.Map.GetMapObject().GetPropertyInfo(node.Attributes["MapObjectProperty"].Value);
 }
예제 #3
0
 /// <summary>
 /// 填充对象信息根据节点
 /// </summary>
 /// <param name="nodes"></param>
 protected virtual void FillOrmObjectByObjectXmlNodes(XmlNodeList nodes)
 {
     foreach (XmlNode node in nodes)
     {
         var info = new OrmObjectInfo();
         FillOrmObjectBaseByXmlNode(info, node);
         FillOrmObjectWhereByXmlNode(info, node);
         AddOrm(info);
     }
 }
예제 #4
0
 /// <summary>
 /// 根据property节点填充map
 /// </summary>
 /// <param name="info"></param>
 /// <param name="nodes"></param>
 protected virtual void FillOrmPropertyMapByPropertyXmlNodes(OrmObjectInfo info, XmlNodeList nodes)
 {
     foreach (XmlNode node in nodes)
     {
         OrmPropertyInfo pi = GetOrmPropertyByXmlNodeAndOrmObject(node, info);
         if (pi == null)
         {
             continue;
         }
         FillOrmPropertyMapByXmlNode(info, pi, node);
     }
 }
예제 #5
0
파일: Orm.cs 프로젝트: fangliu520/Beeant
 /// <summary>
 /// 添加对象
 /// </summary>
 /// <param name="info"></param>
 public virtual void AddOrm(OrmObjectInfo info)
 {
     Orms.Add(info.ObjectName, info);
     if (!Orms.ContainsKey(info.NickObjectName))
     {
         Orms.Add(info.NickObjectName, info);
     }
     if (!Orms.ContainsKey(info.ShortObjectName))
     {
         Orms.Add(info.ShortObjectName, info);
     }
 }
예제 #6
0
        /// <summary>
        /// 同步缓存机制
        /// </summary>
        protected virtual void SetOrmObjectCacheTime(OrmObjectInfo orm)
        {
            var ormMaps =
                orm.Properties.Where(it => it.Map != null && !it.Map.IsGreedyLoad && it.Map.IsLazyLoad)
                .Select(it => it.Map);

            foreach (var ormMap in ormMaps)
            {
                ormMap.GetMapObject().CacheTime = orm.CacheTime;
                ormMap.GetMapObject().CacheType = orm.CacheType;
                SetOrmObjectCacheTime(ormMap.GetMapObject());
            }
        }
예제 #7
0
        /// <summary>
        /// 填充属性map
        /// </summary>
        /// <param name="ormObject"></param>
        /// <param name="property"></param>
        /// <param name="node"></param>
        protected virtual void FillOrmPropertyMapByXmlNode(OrmObjectInfo ormObject, OrmPropertyInfo property, XmlNode node)
        {
            XmlNode xnMap = node.SelectSingleNode("MapObject");

            if (xnMap != null)
            {
                property.Map = new OrmMapInfo {
                    Orms = Orms, MapObjectName = xnMap.Attributes["Name"].Value
                };
                FillOrmPropertyMapKeyByXmlNode(ormObject, property, xnMap);
                FillOrmPropertyMapOperateByXmlNode(property, xnMap);
            }
        }
예제 #8
0
 /// <summary>
 /// 根据property节点填充填充属性
 /// </summary>
 /// <param name="info"></param>
 /// <param name="nodes"></param>
 protected virtual void FillOrmPropertyByPropertyXmlNodes(OrmObjectInfo info, XmlNodeList nodes)
 {
     foreach (XmlNode nd in nodes)
     {
         var pi = new OrmPropertyInfo {
             ObjectName = info.ObjectName, Orms = Orms
         };
         info.Properties.Add(pi);
         FillOrmPropertyBaseByXmlNode(info, pi, nd);
         FillOrmPropertyDefaultByXmlNode(pi, nd);
         FillOrmPropertyOperatorModeByXmlNode(pi, nd);
     }
 }
예제 #9
0
 /// <summary>
 /// 根据objects节点填充map
 /// </summary>
 /// <param name="xnlObjects"></param>
 protected virtual void FillOrmPropertyMapByObjectXmlNodes(XmlNodeList xnlObjects)
 {
     foreach (XmlNode node in xnlObjects)
     {
         if (node.ChildNodes.Count == 0)
         {
             continue;
         }
         OrmObjectInfo info = GetOrmObjectByXmlNode(node);
         if (info == null)
         {
             continue;
         }
         XmlNodeList nodes = node.SelectNodes("Property");
         FillOrmPropertyMapByPropertyXmlNodes(info, nodes);
     }
 }
예제 #10
0
파일: XmlOrm.cs 프로젝트: fangliu520/Beeant
 /// <summary>
 /// 填充表
 /// </summary>
 /// <param name="info"></param>
 /// <param name="node"></param>
 protected virtual void FillOrmObjectBaseByXmlNode(OrmObjectInfo info, XmlNode node)
 {
     if (node.Attributes == null)
     {
         return;
     }
     info.ObjectName     = node.Attributes["ObjectName"] != null ? node.Attributes["ObjectName"].Value : null;
     info.Key            = node.Attributes["KeyName"] != null ? node.Attributes["KeyName"].Value : null;
     info.GetTableName   = node.Attributes["GetTableName"] != null ? node.Attributes["GetTableName"].Value.ToLower() : null;
     info.GetDataBase    = node.Attributes["GetDataBase"] != null ? node.Attributes["GetDataBase"].Value.ToLower() : null;
     info.NickObjectName = node.Attributes["NickObjectName"] != null ? node.Attributes["NickObjectName"].Value : null;
     info.SetTableName   = node.Attributes["SetTableName"] == null ? info.GetTableName : node.Attributes["SetTableName"].Value.ToLower();
     info.IsCache        = node.Attributes["IsCache"] != null && Convert.ToBoolean(node.Attributes["IsCache"].Value);
     info.CacheTime      = node.Attributes["CacheTime"] == null ?1200:Convert.ToInt64(node.Attributes["CacheTime"].Value);
     info.SetDataBase    = node.Attributes["SetDataBase"] == null ? info.GetDataBase : node.Attributes["SetDataBase"].Value.ToLower();
     info.RouteName      = node.Attributes["RouteName"] == null ? "" : node.Attributes["RouteName"].Value.ToLower();
 }
예제 #11
0
 protected virtual void FillOrmObjectWhereByXmlNode(OrmObjectInfo info, XmlNode node)
 {
     if (node.Attributes != null && node.Attributes["SetDefaultWhere"] != null)
     {
         info.SetDefaultWhere = node.Attributes["SetDefaultWhere"].Value.Trim();
     }
     if (node.Attributes != null && node.Attributes["GetDefaultWhere"] != null)
     {
         info.GetDefaultWhere = node.Attributes["GetDefaultWhere"].Value.Trim();
     }
     if (node.Attributes != null && node.Attributes["RemoveMark"] != null)
     {
         info.RemoveMark = node.Attributes["RemoveMark"].Value.Trim();
     }
     if (node.Attributes != null && node.Attributes["RestoreMark"] != null)
     {
         info.RestoreMark = node.Attributes["RestoreMark"].Value.Trim();
     }
 }
예제 #12
0
 /// <summary>
 /// 填充属性基本信息
 /// </summary>
 /// <param name="ormObject"></param>
 /// <param name="property"></param>
 /// <param name="node"></param>
 protected virtual void FillOrmPropertyBaseByXmlNode(OrmObjectInfo ormObject, OrmPropertyInfo property, XmlNode node)
 {
     if (node.Attributes == null)
     {
         return;
     }
     property.PropertyName       = node.Attributes["PropertyName"].Value;
     property.NickPropertyName   = node.Attributes["NickPropertyName"] == null ? null : node.Attributes["NickPropertyName"].Value.Split(',');
     property.FieldName          = node.Attributes["FieldName"] == null ? property.PropertyName : node.Attributes["FieldName"].Value;
     property.FieldType          = node.Attributes["FieldType"] == null ? null : node.Attributes["FieldType"].Value;
     property.PropertyType       = node.Attributes["PropertyType"] == null ? null : Type.GetType(node.Attributes["PropertyType"].Value);
     property.Length             = node.Attributes["Length"] == null ? 0 : Convert.ToInt32(node.Attributes["Length"].Value);
     property.IsPrimaryKey       = node.Attributes["IsPrimaryKey"] != null && Convert.ToBoolean(node.Attributes["IsPrimaryKey"].Value);
     property.IsIdentityKey      = node.Attributes["IsIdentityKey"] != null && Convert.ToBoolean(node.Attributes["IsIdentityKey"].Value);
     property.IsCustom           = node.Attributes["IsCustom"] != null && Convert.ToBoolean(node.Attributes["IsCustom"].Value);
     property.IsOptimisticLocker = node.Attributes["IsOptimisticLocker"] != null && Convert.ToBoolean(node.Attributes["IsOptimisticLocker"].Value);
     property.IsVersion          = node.Attributes["IsVersion"] != null && Convert.ToBoolean(node.Attributes["IsVersion"].Value);
     ormObject.PrimaryProperty   = property.IsPrimaryKey ? property : ormObject.PrimaryProperty;
     ormObject.VersionProperty   = property.IsVersion ? property : ormObject.VersionProperty;
 }
예제 #13
0
 /// <summary>
 /// 返回属性
 /// </summary>
 /// <param name="node"></param>
 /// <param name="info"></param>
 /// <returns></returns>
 protected virtual OrmPropertyInfo GetOrmPropertyByXmlNodeAndOrmObject(XmlNode node, OrmObjectInfo info)
 {
     return(info.Properties.FirstOrDefault(p => node.Attributes != null && p.PropertyName.Equals(node.Attributes["PropertyName"].Value)));
 }
예제 #14
0
        /// <summary>
        /// 得到最近的一个属性
        /// </summary>
        /// <param name="chainProperties"></param>
        /// <param name="orm"></param>
        /// <param name="propertyName"></param>
        /// <returns></returns>
        protected virtual string AddNearProperty(IList <OrmPropertyInfo> chainProperties, OrmObjectInfo orm, string propertyName)
        {
            var p = orm.GetPropertyInfo(propertyName);

            if (p != null)
            {
                chainProperties.Add(p);
                return(null);
            }
            var index = propertyName.IndexOf('.');

            if (index == -1)
            {
                return(null);
            }
            p = orm.GetPropertyInfo(propertyName.Substring(0, index));
            if (p != null)
            {
                chainProperties.Add(p);
            }
            return(propertyName.Substring(index + 1, propertyName.Length - 1 - index));
        }