コード例 #1
0
        public void UrlTest3()
        {
            bool ret = Xmtool.Regex().IsUrl("https://news.sina.com.cn");

            Assert.True(ret);
        }
コード例 #2
0
        public void EmailTest2()
        {
            bool ret = Xmtool.Regex().IsEmail("*****@*****.**");

            Assert.True(ret);
        }
コード例 #3
0
ファイル: ModelLoader.cs プロジェクト: softwaiter/netcoreORM
        private static ConnectionSetting ParseConnectionSetting(string connectionFilePath)
        {
            ConnectionSetting result = new ConnectionSetting();

            Xmtool.Xml().Iterate(connectionFilePath, (nodeInfo) => {
                if (!nodeInfo.IsEndNode)
                {
                    if (nodeInfo.Path == "/connection/dialect/@text")
                    {
                        result.Dialect = nodeInfo.Text.Trim().ToLower();
                    }
                    else if (nodeInfo.Path == "/connection/host/@text")
                    {
                        result.Host = nodeInfo.Text.Trim();
                    }
                    else if (nodeInfo.Path == "/connection/port/@text")
                    {
                        int port;
                        if (int.TryParse(nodeInfo.Text, out port))
                        {
                            result.Port = port;
                        }
                        else
                        {
                            throw new Exception("name属性不能为空。 " + connectionFilePath + " - Line " + nodeInfo.Line);
                        }
                    }
                    else if (nodeInfo.Path == "/connection/user/@text")
                    {
                        result.User = nodeInfo.Text.Trim();
                    }
                    else if (nodeInfo.Path == "/connection/password/@text")
                    {
                        result.Password = nodeInfo.Text.Trim();
                    }
                    else if (nodeInfo.Path == "/connection/database/@text")
                    {
                        result.Database = nodeInfo.Text.Trim();
                    }
                    else if (nodeInfo.Path == "/connection/charset/@text")
                    {
                        result.Charset = nodeInfo.Text.Trim();
                    }
                    else if (nodeInfo.Path == "/connection/encrypt/@text")
                    {
                        if (!reBool.IsMatch(nodeInfo.Text.Trim()))
                        {
                            throw new Exception("encrypt节点值必须是布尔型。 " + connectionFilePath + " - Line " + nodeInfo.Line);
                        }
                        result.Encrypt = bool.Parse(nodeInfo.Text.Trim());
                    }
                    else if (nodeInfo.Path == "/connection/pool")
                    {
                        string maxStr = nodeInfo.GetAttribute("max");
                        if (!Xmtool.Regex().IsPositiveInteger(maxStr))
                        {
                            throw new Exception("max属性必须是有效正整数。 " + connectionFilePath + " - Line " + nodeInfo.Line);
                        }
                        result.MaxPoolSize = int.Parse(maxStr);

                        string minStr = nodeInfo.GetAttribute("min");
                        if (!Xmtool.Regex().IsNaturalInteger(minStr))
                        {
                            throw new Exception("min属性必须是有效自然数。 " + connectionFilePath + " - Line " + nodeInfo.Line);
                        }
                        result.MinPoolSize = int.Parse(minStr);
                    }
                    else if (nodeInfo.Path == "/connection/pool/@text")
                    {
                        if (!reBool.IsMatch(nodeInfo.Text.Trim()))
                        {
                            throw new Exception("pool节点值必须是布尔型。 " + connectionFilePath + " - Line " + nodeInfo.Line);
                        }
                        result.Pooling = bool.Parse(nodeInfo.Text.Trim());
                    }
                }
                return(true);
            });
            return(result);
        }
コード例 #4
0
        public void DecimalTest2()
        {
            bool ret = Xmtool.Regex().IsDecimal("0.2");

            Assert.True(ret);
        }
コード例 #5
0
        public void DecimalTest9()
        {
            bool ret = Xmtool.Regex().IsDecimal("");

            Assert.False(ret);
        }
コード例 #6
0
        public void MobileTest4()
        {
            bool ret = Xmtool.Regex().IsMobile("1361234567");

            Assert.False(ret);
        }
コード例 #7
0
        public void NaturalIntTest2()
        {
            bool ret = Xmtool.Regex().IsNaturalInteger("10");

            Assert.True(ret);
        }
コード例 #8
0
        public void IPTest5()
        {
            bool ret = Xmtool.Regex().IsIP("255.255.255");

            Assert.False(ret);
        }
コード例 #9
0
        public void MobileTest2()
        {
            bool ret = Xmtool.Regex().IsMobile("13612345678");

            Assert.True(ret);
        }
コード例 #10
0
        public void IPTest()
        {
            bool ret = Xmtool.Regex().IsIP("192.168.1.1");

            Assert.True(ret);
        }
コード例 #11
0
        public void IPTest2()
        {
            bool ret = Xmtool.Regex().IsIP("255.255.255.255");

            Assert.True(ret);
        }
コード例 #12
0
        public void UrlTest7()
        {
            bool ret = Xmtool.Regex().IsUrl("");

            Assert.False(ret);
        }
コード例 #13
0
        public void UrlTest6()
        {
            bool ret = Xmtool.Regex().IsUrl("www.baidu");

            Assert.False(ret);
        }
コード例 #14
0
        public void UrlTest4()
        {
            bool ret = Xmtool.Regex().IsUrl("http://gjj.beijing.gov.cn");

            Assert.True(ret);
        }
コード例 #15
0
        public void IntTest6()
        {
            bool ret = Xmtool.Regex().IsInteger("abc");

            Assert.False(ret);
        }
コード例 #16
0
        public void IPTest6()
        {
            bool ret = Xmtool.Regex().IsIP("abc.abc.abc.abc");

            Assert.False(ret);
        }
コード例 #17
0
        public void PositiveIntTest2()
        {
            bool ret = Xmtool.Regex().IsPositiveInteger("2");

            Assert.True(ret);
        }
コード例 #18
0
        public void NumberTest()
        {
            bool ret = Xmtool.Regex().IsNumber("0");

            Assert.True(ret);
        }
コード例 #19
0
        public void PositiveIntTest7()
        {
            bool ret = Xmtool.Regex().IsPositiveInteger("");

            Assert.False(ret);
        }
コード例 #20
0
        public void NumberTest3()
        {
            bool ret = Xmtool.Regex().IsNumber(int.MinValue.ToString());

            Assert.True(ret);
        }
コード例 #21
0
        public void NaturalIntTest6()
        {
            bool ret = Xmtool.Regex().IsNaturalInteger("");

            Assert.False(ret);
        }
コード例 #22
0
        public void NumberTest5()
        {
            bool ret = Xmtool.Regex().IsNumber(double.MinValue.ToString("0"));

            Assert.True(ret);
        }
コード例 #23
0
        public void DecimalTest4()
        {
            bool ret = Xmtool.Regex().IsDecimal("-0.9");

            Assert.True(ret);
        }
コード例 #24
0
        public void NumberTest7()
        {
            bool ret = Xmtool.Regex().IsNumber("");

            Assert.False(ret);
        }
コード例 #25
0
        public void MobileTest6()
        {
            bool ret = Xmtool.Regex().IsMobile("");

            Assert.False(ret);
        }
コード例 #26
0
        public void IntTest3()
        {
            bool ret = Xmtool.Regex().IsInteger("-18");

            Assert.True(ret);
        }
コード例 #27
0
        private void _CheckProperyValue(string name, object value)
        {
            Property p = mModel.GetProperty(name);

            if (p.IsNotNull && value == null)
            {
                throw new Exception(string.Concat("属性值不能为空:", name));
            }

            if (value != null)
            {
                if (FieldUtils.IsNumeric(p.FieldType))
                {
                    if (!Xmtool.Regex().IsNumber(value.ToString()))
                    {
                        throw new Exception(string.Concat(p.Name, "属性值期待类型:", p.FieldType, ",实际类型为:", value.GetType()));
                    }
                }
                else if (p.FieldType == DbType.Boolean)
                {
                    Type _typ = value.GetType();
                    if (_typ != typeof(bool))
                    {
                        bool result;
                        if (!bool.TryParse(value.ToString(), out result))
                        {
                            throw new Exception(string.Concat(p.Name, "属性值期待类型:", p.FieldType, ",实际类型为:", _typ));
                        }
                    }
                }
                else if (p.FieldType == DbType.Date ||
                         p.FieldType == DbType.DateTime ||
                         p.FieldType == DbType.DateTime2)
                {
                    DateTime result;
                    if (!DateTime.TryParse(value.ToString(), out result))
                    {
                        throw new Exception(string.Concat(p.Name, "属性值期待类型:", p.FieldType, ",实际类型为:", value.GetType()));
                    }
                }

                if (p.RealType == typeof(string) && p.Length > 0)
                {
                    if (value.ToString().Length > p.Length)
                    {
                        throw new Exception(string.Concat(p.Name, "属性值最大长度不能超过", p.Length, ":", name));
                    }
                }
                else if (FieldUtils.IsNumeric(p.FieldType))
                {
                    double dValue = double.Parse(value.ToString());
                    if (p.MinValue != null)
                    {
                        if (dValue < p.MinValue)
                        {
                            throw new Exception(string.Concat(p.Name, "属性值取值限制范围:", p.MinValue, "-", p.MaxValue));
                        }
                    }
                    if (p.MaxValue != null)
                    {
                        if (dValue > p.MaxValue)
                        {
                            throw new Exception(string.Concat(p.Name, "属性值取值限制范围:", p.MinValue, "-", p.MaxValue));
                        }
                    }
                }
            }
        }
コード例 #28
0
        public void IntTest5()
        {
            bool ret = Xmtool.Regex().IsInteger("-9.6");

            Assert.False(ret);
        }
コード例 #29
0
ファイル: ModelLoader.cs プロジェクト: softwaiter/netcoreORM
        internal static Model ParseModel(string modelFilePath, string parent)
        {
            Model model = new Model();

            model.Path = parent.ToLower();

            Xmtool.Xml().Iterate(modelFilePath, (nodeInfo) =>
            {
                if (nodeInfo.Path == "/model")
                {
                    if (!nodeInfo.IsEndNode)
                    {
                        string name = nodeInfo.GetAttribute("name");
                        if (name == null)
                        {
                            throw new Exception("缺少name属性。 " + modelFilePath + " - Line " + nodeInfo.Line);
                        }
                        else if (string.IsNullOrWhiteSpace(name))
                        {
                            throw new Exception("name属性不能为空。 " + modelFilePath + " - Line " + nodeInfo.Line);
                        }
                        model.Name = name.Trim();

                        string table = nodeInfo.GetAttribute("table");
                        if (table != null)
                        {
                            if (string.IsNullOrWhiteSpace(table))
                            {
                                throw new Exception("table属性不能为空。 " + modelFilePath + " - Line " + nodeInfo.Line);
                            }
                            model.Table = table.Trim();
                        }
                        else
                        {
                            model.Table = model.Name;
                        }

                        string beforeSaveProcStr = nodeInfo.GetAttribute("beforeSave");
                        if (beforeSaveProcStr != null)
                        {
                            beforeSaveProcStr = beforeSaveProcStr.Trim();
                            if (beforeSaveProcStr.Length > 4 &&
                                beforeSaveProcStr.StartsWith("{{") &&
                                beforeSaveProcStr.EndsWith("}}"))
                            {
                                model.BeforeSaveProcessor = beforeSaveProcStr.Substring(2, beforeSaveProcStr.Length - 4);
                            }
                            else
                            {
                                throw new Exception("beforeSave属性必须是Processor。 " + modelFilePath + " - Line " + nodeInfo.Line);
                            }
                        }

                        string afterSaveProcStr = nodeInfo.GetAttribute("afterSave");
                        if (afterSaveProcStr != null)
                        {
                            afterSaveProcStr = afterSaveProcStr.Trim();
                            if (afterSaveProcStr.Length > 4 &&
                                afterSaveProcStr.StartsWith("{{") &&
                                afterSaveProcStr.EndsWith("}}"))
                            {
                                model.AfterSaveProcessor = afterSaveProcStr.Substring(2, afterSaveProcStr.Length - 4);
                            }
                            else
                            {
                                throw new Exception("afterSave属性必须是Processor。 " + modelFilePath + " - Line " + nodeInfo.Line);
                            }
                        }

                        string beforeDeleteProcStr = nodeInfo.GetAttribute("beforeDelete");
                        if (beforeDeleteProcStr != null)
                        {
                            beforeDeleteProcStr = beforeDeleteProcStr.Trim();
                            if (beforeDeleteProcStr.Length > 4 &&
                                beforeDeleteProcStr.StartsWith("{{") &&
                                beforeDeleteProcStr.EndsWith("}}"))
                            {
                                model.BeforeDeleteProcessor = beforeDeleteProcStr.Substring(2, beforeDeleteProcStr.Length - 4);
                            }
                            else
                            {
                                throw new Exception("beforeDelete属性必须是Processor。 " + modelFilePath + " - Line " + nodeInfo.Line);
                            }
                        }

                        string afterDeleteProcStr = nodeInfo.GetAttribute("afterDelete");
                        if (afterDeleteProcStr != null)
                        {
                            afterDeleteProcStr = afterDeleteProcStr.Trim();
                            if (afterDeleteProcStr.Length > 4 &&
                                afterDeleteProcStr.StartsWith("{{") &&
                                afterDeleteProcStr.EndsWith("}}"))
                            {
                                model.AfterDeleteProcessor = afterDeleteProcStr.Substring(2, afterDeleteProcStr.Length - 4);
                            }
                            else
                            {
                                throw new Exception("afterDelete属性必须是Processor。 " + modelFilePath + " - Line " + nodeInfo.Line);
                            }
                        }
                    }
                }
                else if (nodeInfo.Path == "/model/property")
                {
                    if (!nodeInfo.IsEndNode)
                    {
                        Property p = new Property();
                        DelayCheckPropertySetting dcps = null;

                        string name = nodeInfo.GetAttribute("name");
                        if (name == null)
                        {
                            throw new Exception("缺少name属性。 " + modelFilePath + " - Line " + nodeInfo.Line);
                        }
                        else if (string.IsNullOrWhiteSpace(name))
                        {
                            throw new Exception("name属性不能为空。 " + modelFilePath + " - Line " + nodeInfo.Line);
                        }
                        p.Name = name.Trim();

                        string field = nodeInfo.GetAttribute("field");
                        if (field != null)
                        {
                            if (string.IsNullOrWhiteSpace(field))
                            {
                                throw new Exception("field属性不能为空。 " + modelFilePath + " - Line " + nodeInfo.Line);
                            }
                            p.Field = field.Trim();
                        }
                        else
                        {
                            p.Field = string.Concat("f_", p.Name.ToLower());
                        }

                        Type type      = typeof(string);
                        string typeStr = nodeInfo.GetAttribute("type");
                        if (typeStr != null)
                        {
                            type = GetPropertyType(typeStr);
                            if (type == null)
                            {
                                throw new Exception("type属性非法。 " + modelFilePath + " - Line " + nodeInfo.Line);
                            }
                            else if (type == typeof(Model) ||
                                     type == typeof(DynamicObjectExt))
                            {
                                p.TypeValue = typeStr;

                                dcps          = new DelayCheckPropertySetting();
                                dcps.Position = modelFilePath + " - Line " + nodeInfo.Line;
                            }
                        }
                        else
                        {
                            string aiStr = nodeInfo.GetAttribute("autoIncrement");
                            if (aiStr != null)
                            {
                                if (!string.IsNullOrWhiteSpace(aiStr) &&
                                    reBool.IsMatch(aiStr))
                                {
                                    type = typeof(Int32);
                                }
                            }
                        }
                        p.Type     = type;
                        p.RealType = type;

                        string joinPropStr = nodeInfo.GetAttribute("joinProp");
                        if (joinPropStr != null)
                        {
                            if (p.Type == typeof(Model))
                            {
                                if (string.IsNullOrWhiteSpace(joinPropStr))
                                {
                                    throw new Exception("joinProp属性不能为空。" + modelFilePath + " - Line " + nodeInfo.Line);
                                }
                                p.JoinProp = joinPropStr.Trim();
                            }
                            else
                            {
                                throw new Exception("joinProp属性只在type属性为Model类型时有效。 " + modelFilePath + " - Line " + nodeInfo.Line);
                            }
                        }

                        string fieldTypeStr = nodeInfo.GetAttribute("fieldType");
                        if (fieldTypeStr != null)
                        {
                            if (type == typeof(DynamicObjectExt))
                            {
                                throw new Exception(typeStr + "类型的Property禁止设置fieldType。" + modelFilePath + " - Line " + nodeInfo.Line);
                            }

                            try
                            {
                                p.FieldType = Enum.Parse <DbType>(fieldTypeStr, true);
                                p.RealType  = DbType2Type(p.FieldType);
                            }
                            catch
                            {
                                throw new Exception("fieldType属性非法。 " + modelFilePath + " - Line " + nodeInfo.Line);
                            }
                        }
                        else
                        {
                            p.FieldType = Type2DbType(type);
                            if (p.Type == typeof(Model))
                            {
                                dcps.FieldTypeNotSet = true;
                            }
                        }

                        string lengthStr = nodeInfo.GetAttribute("length");
                        if (lengthStr != null)
                        {
                            if (string.IsNullOrWhiteSpace(lengthStr))
                            {
                                throw new Exception("length属性不能为空。 " + modelFilePath + " - Line " + nodeInfo.Line);
                            }

                            if (!Xmtool.Regex().IsPositiveInteger(lengthStr))
                            {
                                throw new Exception("length属性必须是有效正整数。 " + modelFilePath + " - Line " + nodeInfo.Line);
                            }

                            p.Length = int.Parse(lengthStr);
                        }
                        else
                        {
                            p.Length = FieldUtils.GetFieldLength(model, p.FieldType);
                            if (p.Type == typeof(DynamicObjectExt))
                            {
                                p.Length = 512;
                            }
                            else if (p.Type == typeof(Model))
                            {
                                dcps.LengthNotSet = true;
                            }
                        }

                        string minStr = nodeInfo.GetAttribute("min");
                        if (minStr != null)
                        {
                            if (FieldUtils.IsNumeric(p.FieldType))
                            {
                                if (string.IsNullOrWhiteSpace(minStr))
                                {
                                    throw new Exception("min属性不能为空。 " + modelFilePath + " - Line " + nodeInfo.Line);
                                }

                                if (!Xmtool.Regex().IsNumber(minStr))
                                {
                                    throw new Exception("min属性必须是有效数值。 " + modelFilePath + " - Line " + nodeInfo.Line);
                                }

                                p.MinValue = double.Parse(minStr);
                            }
                            else
                            {
                                throw new NotSupportedException(p.FieldType.ToString() + "类型不支持min设置。" + modelFilePath + " - Line " + nodeInfo.Line);
                            }
                        }

                        string maxStr = nodeInfo.GetAttribute("max");
                        if (maxStr != null)
                        {
                            if (FieldUtils.IsNumeric(p.FieldType))
                            {
                                if (string.IsNullOrWhiteSpace(maxStr))
                                {
                                    throw new Exception("max属性不能为空。 " + modelFilePath + " - Line " + nodeInfo.Line);
                                }

                                if (!Xmtool.Regex().IsNumber(maxStr))
                                {
                                    throw new Exception("max属性必须是有效数值。 " + modelFilePath + " - Line " + nodeInfo.Line);
                                }

                                p.MaxValue = double.Parse(maxStr);
                            }
                            else
                            {
                                throw new NotSupportedException(p.FieldType.ToString() + "类型不支持max设置。" + modelFilePath + " - Line " + nodeInfo.Line);
                            }
                        }

                        string precisionStr = nodeInfo.GetAttribute("precision");
                        if (precisionStr != null)
                        {
                            if (FieldUtils.IsFloat(p.FieldType))
                            {
                                if (string.IsNullOrWhiteSpace(precisionStr))
                                {
                                    throw new Exception("precision属性不能为空。 " + modelFilePath + " - Line " + nodeInfo.Line);
                                }

                                if (!Xmtool.Regex().IsNaturalInteger(precisionStr))
                                {
                                    throw new Exception("precision属性必须是有效自然数。 " + modelFilePath + " - Line " + nodeInfo.Line);
                                }

                                p.Precision = int.Parse(precisionStr);
                            }
                            else
                            {
                                throw new NotSupportedException(p.FieldType.ToString() + "类型不支持precision设置。" + modelFilePath + " - Line " + nodeInfo.Line);
                            }
                        }

                        string notNullStr = nodeInfo.GetAttribute("notNull");
                        if (notNullStr != null)
                        {
                            if (string.IsNullOrWhiteSpace(notNullStr))
                            {
                                throw new Exception("notNull属性不能为空。 " + modelFilePath + " - Line " + nodeInfo.Line);
                            }

                            if (!reBool.IsMatch(notNullStr))
                            {
                                throw new Exception("notNull属性必须是布尔型。 " + modelFilePath + " - Line " + nodeInfo.Line);
                            }

                            p.IsNotNull = bool.Parse(notNullStr);
                        }

                        string descStr = nodeInfo.GetAttribute("desc");
                        if (!string.IsNullOrEmpty(descStr))
                        {
                            p.Description = descStr;
                        }

                        string autoIncrStr = nodeInfo.GetAttribute("autoIncrement");
                        if (autoIncrStr != null)
                        {
                            if (FieldUtils.IsInteger(p.FieldType))
                            {
                                if (string.IsNullOrWhiteSpace(autoIncrStr))
                                {
                                    throw new Exception("autoIncrement属性不能为空。 " + modelFilePath + " - Line " + nodeInfo.Line);
                                }

                                if (!reBool.IsMatch(autoIncrStr))
                                {
                                    throw new Exception("autoIncrement属性必须是布尔型。 " + modelFilePath + " - Line " + nodeInfo.Line);
                                }

                                p.AutoIncrement = bool.Parse(autoIncrStr);
                            }
                            else
                            {
                                throw new NotSupportedException(p.FieldType.ToString() + "类型不支持autoIncrement设置。" + modelFilePath + " - Line " + nodeInfo.Line);
                            }
                        }

                        string unsignedStr = nodeInfo.GetAttribute("unsigned");
                        if (unsignedStr != null)
                        {
                            if (FieldUtils.IsNumeric(p.FieldType))
                            {
                                if (string.IsNullOrWhiteSpace(unsignedStr))
                                {
                                    throw new Exception("unsigned属性不能为空。 " + modelFilePath + " - Line " + nodeInfo.Line);
                                }

                                if (!reBool.IsMatch(unsignedStr))
                                {
                                    throw new Exception("unsigned属性必须是布尔型。 " + modelFilePath + " - Line " + nodeInfo.Line);
                                }

                                p.Unsigned = bool.Parse(unsignedStr);
                            }
                            else
                            {
                                throw new NotSupportedException(p.FieldType.ToString() + "类型不支持unsigned设置。" + modelFilePath + " - Line " + nodeInfo.Line);
                            }
                        }

                        string uniqueGroupStr = nodeInfo.GetAttribute("uniqueGroup");
                        if (uniqueGroupStr != null)
                        {
                            if (string.IsNullOrWhiteSpace(uniqueGroupStr))
                            {
                                throw new Exception("uniqueGroup属性不能为空。 " + modelFilePath + " - Line " + nodeInfo.Line);
                            }
                            p.UniqueGroup = uniqueGroupStr.Trim();
                        }

                        string indexGroupStr = nodeInfo.GetAttribute("indexGroup");
                        if (indexGroupStr != null)
                        {
                            if (string.IsNullOrWhiteSpace(indexGroupStr))
                            {
                                throw new Exception("indexGroup属性不能为空。 " + modelFilePath + " - Line " + nodeInfo.Line);
                            }
                            p.IndexGroup = indexGroupStr.Trim();
                        }

                        string primaryStr = nodeInfo.GetAttribute("primary");
                        if (primaryStr != null)
                        {
                            if (string.IsNullOrWhiteSpace(primaryStr))
                            {
                                throw new Exception("primary属性不能为空。 " + modelFilePath + " - Line " + nodeInfo.Line);
                            }

                            if (!reBool.IsMatch(primaryStr))
                            {
                                throw new Exception("primary属性必须是布尔型。 " + modelFilePath + " - Line " + nodeInfo.Line);
                            }

                            p.IsPrimaryKey = bool.Parse(primaryStr);
                        }

                        string defaultStr = nodeInfo.GetAttribute("defaultValue");
                        if (defaultStr != null)
                        {
                            p.DefaultValue = defaultStr.Trim();
                        }

                        string beforeProcStr = nodeInfo.GetAttribute("beforeSave");
                        if (beforeProcStr != null)
                        {
                            beforeProcStr = beforeProcStr.Trim();
                            if (beforeProcStr.Length > 4 &&
                                beforeProcStr.StartsWith("{{") &&
                                beforeProcStr.EndsWith("}}"))
                            {
                                p.BeforeSaveProcessor = beforeProcStr.Substring(2, beforeProcStr.Length - 4);
                            }
                            else
                            {
                                throw new Exception("beforeSave属性必须是Processor。 " + modelFilePath + " - Line " + nodeInfo.Line);
                            }
                        }

                        string afterProcStr = nodeInfo.GetAttribute("afterQuery");
                        if (afterProcStr != null)
                        {
                            afterProcStr = afterProcStr.Trim();
                            if (afterProcStr.Length > 4 &&
                                afterProcStr.StartsWith("{{") &&
                                afterProcStr.EndsWith("}}"))
                            {
                                p.AfterQueryProcessor = afterProcStr.Substring(2, afterProcStr.Length - 4);
                            }
                            else
                            {
                                throw new Exception("afterQuery属性必须是Processor。 " + modelFilePath + " - Line " + nodeInfo.Line);
                            }
                        }

                        string joinInsertStr = nodeInfo.GetAttribute("joinInsert");
                        if (joinInsertStr != null)
                        {
                            if (string.IsNullOrWhiteSpace(joinInsertStr))
                            {
                                throw new Exception("joinInsert属性不能为空。 " + modelFilePath + " - Line " + nodeInfo.Line);
                            }

                            if (!reBool.IsMatch(joinInsertStr))
                            {
                                throw new Exception("joinInsert属性必须是布尔型。 " + modelFilePath + " - Line " + nodeInfo.Line);
                            }

                            p.JoinInsert = bool.Parse(joinInsertStr);
                        }

                        string joinUpdateStr = nodeInfo.GetAttribute("joinUpdate");
                        if (joinUpdateStr != null)
                        {
                            if (string.IsNullOrWhiteSpace(joinUpdateStr))
                            {
                                throw new Exception("joinUpdate属性不能为空。 " + modelFilePath + " - Line " + nodeInfo.Line);
                            }

                            if (!reBool.IsMatch(joinUpdateStr))
                            {
                                throw new Exception("joinUpdate属性必须是布尔型。 " + modelFilePath + " - Line " + nodeInfo.Line);
                            }

                            p.JoinUpdate = bool.Parse(joinUpdateStr);
                        }

                        model.AddProperty(p);

                        if (dcps != null)
                        {
                            sDelayCheckProperties.TryAdd(p, dcps);
                        }
                    }
                }

                return(true);
            });
            return(model);
        }
コード例 #30
0
        public void UrlTest2()
        {
            bool ret = Xmtool.Regex().IsUrl("HTTP://WWW.QQ.COM");

            Assert.True(ret);
        }