示例#1
0
        protected override IDictionary <string, IRoutingAttribute> ParserRoutings(string defaultTableName,
                                                                                  XmlNodeList routingNodes)
        {
            IDictionary <string, IRoutingAttribute> routings = new Dictionary <string, IRoutingAttribute>();

            if (null == routingNodes || 0 == routingNodes.Count)
            {
                //set the default value when the routingnodes is not exist

                IRoutingAttribute defaultRouting = new RoutingAttribute
                {
                    Name        = DefaultRoutingName,
                    Permission  = PermissionMode.WR,
                    StorageName = StorageParser.DefaultStorageName,
                    TableName   = defaultTableName,
                };
                routings.Add(DefaultRoutingName, defaultRouting);
                return(routings);
            }

            foreach (XmlNode node in routingNodes)
            {
                IRoutingAttribute routing = ParserRouting(defaultTableName, node);
                if (null != routing)
                {
                    routings.Add(routing.Name, routing);
                }
            }
            return(routings);
        }
示例#2
0
        protected override IRoutingAttribute ParserRouting(string defaultTableName, XmlNode routingNode)
        {
            if (null == routingNode)
            {
                throw new ArgumentNullException("routingNode");
            }
            object name;

            XmlFileParser.TryGetAttributeValue(routingNode, "Name", out name);
            if (null == name)
            {
                throw new Exception("the Name for the routing node is null.");
            }
            object storageName;

            XmlFileParser.TryGetAttributeValue(routingNode, "StorageName", out storageName);
            if (null == storageName)
            {
                throw new Exception("the StorageName for the routing node is null.");
            }
            object tableName;

            XmlFileParser.TryGetAttributeValue(routingNode, "TableName", out tableName);
            object owner;

            XmlFileParser.TryGetAttributeValue(routingNode, "Owner", out owner);
            object oPermission;

            XmlFileParser.TryGetAttributeValue(routingNode, "Permission", out oPermission);

            IRoutingAttribute rounting = new RoutingAttribute
            {
                Name        = name.ToString(),
                StorageName = storageName.ToString(),
                TableName   = null == tableName ? defaultTableName : tableName.ToString(),
                Permission  =
                    null == oPermission
                                                         ? PermissionMode.WR
                                                         : ConvertToPermissionMode.Convert(oPermission.ToString()),
            };

            if (null != owner)
            {
                rounting.Owner = owner.ToString();
            }
            return(rounting);
        }