private NameRule GetNameRule(XmlNode node) { XmlAttribute attr = node.Attributes["type"]; string type = "is"; //default value if (attr != null && !String.IsNullOrEmpty(attr.Value)) { type = attr.Value; } NameRule result = NameRule.IS; if (type.ToLower() == "isnot") { result = NameRule.IS_NOT; } if (type.ToLower() == "contains") { result = NameRule.CONTAINS; } if (type.ToLower() == "notcontains") { result = NameRule.NOT_CONTAINS; } return(result); }
private void CreatCsF3DAL() { string procPrefix = this.txtProcPrefix.Text; string namepace = this.txtNameSpace.Text.Trim(); string namepace2 = this.txtNameSpace2.Text.Trim(); string modelname = this.txtClassName.Text; if (modelname == "") { modelname = tablename; } string bllname = modelname; string dalname = modelname; //命名规则处理 modelname = NameRule.GetModelClass(modelname, this.setting); bllname = NameRule.GetBLLClass(bllname, this.setting); dalname = NameRule.GetDALClass(dalname, this.setting); BuilderFrameF3 builderFrameS = new BuilderFrameF3(this.dbobj, this.dbname, this.tablename, this.cb.TableDescription, modelname, bllname, dalname, this.GetFieldlist(), this.GetKeyFields(), namepace, namepace2, setting.DbHelperName); string dALtype = GetDALType(); string strCode = builderFrameS.GetDALCode(dALtype, chk_CS_GetMaxID.Checked, chk_CS_Exists.Checked, chk_CS_Add.Checked, chk_CS_Update.Checked, chk_CS_Delete.Checked, chk_CS_GetModel.Checked, chk_CS_GetList.Checked, procPrefix); SettxtContent("CS", strCode); }
private void CreatePropertyCondition(XbimQueryBuilder qBuilder, XmlNode propGroupNode) { GroupRule pGrpRule = GetGroupRule(propGroupNode); //apply logical operators according to the "select" XmlNodeList pSets = ((XmlElement)propGroupNode).GetElementsByTagName("propertySet"); foreach (XmlNode pSet in pSets) { string pSetName = GetName(pSet); NameRule pSetNameRule = GetNameRule(pSet); XmlNode propNode = ((XmlElement)pSet).GetElementsByTagName("property").Item(0); string propName = GetName(propNode); NameRule propNameRule = GetNameRule(propNode); if (string.IsNullOrEmpty(propName)) { errLog.WriteLine("Name of the property must be specified. Property set: '" + pSetName + "', element: '" + eName + "'."); continue; } XmlNode valNode = (propNode as XmlElement).GetElementsByTagName("value").Item(0); string value = valNode.InnerText; ValueRule valRule = GetValueRule(valNode); if (string.IsNullOrEmpty(value)) { errLog.WriteLine("Value of the property '" + propName + "' must be specified. Property set: '" + pSetName + "', element: '" + eName + "."); continue; } qBuilder.AddPropertyCondition(pSetName, pSetNameRule, propName, propNameRule, value, valRule, pGrpRule); } }
public static bool IsValid(string name, string description) { var nameRule = new NameRule(); var descriptionRule = new DescriptionRule(); return(nameRule.ApplyRule(name) && descriptionRule.ApplyRule(description)); }
public Name(string name) { var validator = new NameRule(); if (!validator.IsValid(name)) { throw new InvalidEntityException(); } Value = name; }
public static bool EvaluatePropertyValue(IPersistIfcEntity element, string pSetName, NameRule pSetNameRule, string propertyName, NameRule propNameRule, string value, ValueRule valueRule) { Dictionary<IfcLabel, Dictionary<IfcIdentifier, IfcValue>> allProperties = null; if (string.IsNullOrEmpty(propertyName)) return false; //properties could be defined in IfcTypeObject as HasProperties IfcTypeObject typeObject = element as IfcTypeObject; if (typeObject != null) { allProperties = typeObject.GetAllPropertySingleValues(); } //or properties could be defined in IfcObject in IsDefinedBy IfcObject ifcObject = element as IfcObject; if (ifcObject != null) { allProperties = ifcObject.GetAllPropertySingleValues(); } //or properties could be defined for material as ExtendedMaterialProperties IfcMaterial material = element as IfcMaterial; if (material != null) { allProperties = material.GetAllPropertySingleValues(); } //getting properties is not supported otherwise if (allProperties != null) { foreach (var p in allProperties) { //if pSetName is null all property sets are inspected if (pSetName != null) { if (!IsRightName(pSetName, p.Key, pSetNameRule)) { continue; } } foreach (var prop in p.Value) { //if name is not specified all values are returned if (IsRightName(propertyName, prop.Key, propNameRule)) { Type t = ((ExpressType)(prop.Value)).UnderlyingSystemType; Expression right = XbimQueryFactory.PromoteToConstant(t, value); Expression left = XbimQueryFactory.PromoteToConstant(t, prop.Value.ToString()); //todo: this should be more sofisticated than 'ToString()' Expression eval = CreateValueExpression(left, right, valueRule); return Expression.Lambda<Func<bool>>(eval).Compile()(); } } } } return false; }
private void DefineToken(string name, Token token) { AssertIsNotLocked(); tokens.Add(name, token); Rule rule = new TokenRule(this, token); if (!ImplicitNames.Contains(name)) { rule = new NameRule(this, this, RuleName.Implicit).And(rule); } DefineRule(name, rule); }
private static bool IsRightName(string shouldBe, string isValue, NameRule rule) { switch (rule) { case NameRule.IS: return(shouldBe == isValue); case NameRule.IS_NOT: return(shouldBe != isValue); case NameRule.CONTAINS: return(isValue.Contains(shouldBe)); case NameRule.NOT_CONTAINS: return(!isValue.Contains(shouldBe)); default: throw new Exception("Unexpected enumeration member"); } }
private void CreatWeb() { string namepace = this.txtNameSpace.Text.Trim(); string folder = this.txtNameSpace2.Text.Trim(); string modelname = this.txtClassName.Text; if (modelname == "") { modelname = tablename; } string bllname = modelname; //命名规则处理 modelname = NameRule.GetModelClass(modelname, this.setting); bllname = NameRule.GetBLLClass(bllname, this.setting); //Maticsoft.BuilderWeb.BuilderWeb bw = new Maticsoft.BuilderWeb.BuilderWeb(); //bw.NameSpace = namepace; //bw.Fieldlist = GetFieldlist(); //bw.Keys = GetKeyFields(); //bw.ModelName = modelname; //bw.BLLName = bllname; //bw.Folder = folder; cb.BLLName = bllname; cb.NameSpace = namepace; cb.Fieldlist = GetFieldlist(); cb.Keys = GetKeyFields(); cb.ModelName = modelname; cb.Folder = folder; string webtype = GetWebType(); cb.CreatBuilderWeb(webtype); if (radbtn_Web_Aspx.Checked) { string strCode = cb.GetWebHtmlCode(chk_Web_HasKey.Checked, chk_Web_Add.Checked, chk_Web_Update.Checked, chk_Web_Show.Checked, true); SettxtContent("Aspx", strCode); } else { string strCode = cb.GetWebCode(chk_Web_HasKey.Checked, chk_Web_Add.Checked, chk_Web_Update.Checked, chk_Web_Show.Checked, true); SettxtContent("CS", strCode); } }
public void AddPropertyCondition(string pSetName, NameRule pSetNameRule, string propertyName, NameRule propNameRule, string value, ValueRule valueRule, GroupRule groupRule) { Expression psn = Expression.Constant(pSetName); Expression psnRl = Expression.Constant(pSetNameRule); Expression pn = Expression.Constant(propertyName); Expression pnRl = Expression.Constant(propNameRule); Expression valConst = Expression.Constant(value); Expression valRul = Expression.Constant(valueRule); MethodInfo getPropMeth = typeof(PropertyHelper).GetMethod("EvaluatePropertyValue"); if (getPropMeth == null) { throw new Exception("Wrong method definition."); } //public static IfcValue GetPropertyValue(IPersistIfcEntity element, string pSetName, NameRule pSetNameRule, string propertyName, NameRule propNameRule) Expression property = Expression.Call(getPropMeth, new Expression[] { input, psn, psnRl, pn, pnRl, valConst, valRul }); //bool result of the test AddToGroup(property, groupRule); }
private void CreatCsF3DALFactory() { string namepace = this.txtNameSpace.Text.Trim(); string namepace2 = this.txtNameSpace2.Text.Trim(); string modelname = this.txtClassName.Text; if (modelname == "") { modelname = tablename; } string bllname = modelname; string dalname = modelname; //命名规则处理 modelname = NameRule.GetModelClass(modelname, this.setting); bllname = NameRule.GetBLLClass(bllname, this.setting); dalname = NameRule.GetDALClass(dalname, this.setting); BuilderFrameF3 builderFrameS = new BuilderFrameF3(this.dbobj, this.dbname, this.tablename, this.cb.TableDescription, modelname, bllname, dalname, this.GetFieldlist(), this.GetKeyFields(), namepace, namepace2, setting.DbHelperName); string strCode = builderFrameS.GetDALFactoryCode(); SettxtContent("CS", strCode); }
private static bool IsRightName(string shouldBe, string isValue, NameRule rule) { switch (rule) { case NameRule.IS: return shouldBe == isValue; case NameRule.IS_NOT: return shouldBe != isValue; case NameRule.CONTAINS: return isValue.Contains(shouldBe); case NameRule.NOT_CONTAINS: return !isValue.Contains(shouldBe); default: throw new Exception("Unexpected enumeration member"); } }
public void AddPropertyCondition(string pSetName, NameRule pSetNameRule, string propertyName, NameRule propNameRule, string value, ValueRule valueRule, GroupRule groupRule) { Expression psn = Expression.Constant(pSetName); Expression psnRl = Expression.Constant(pSetNameRule); Expression pn = Expression.Constant(propertyName); Expression pnRl = Expression.Constant(propNameRule); Expression valConst = Expression.Constant(value); Expression valRul = Expression.Constant(valueRule); MethodInfo getPropMeth = typeof(PropertyHelper).GetMethod("EvaluatePropertyValue"); if (getPropMeth == null) throw new Exception("Wrong method definition."); //public static IfcValue GetPropertyValue(IPersistIfcEntity element, string pSetName, NameRule pSetNameRule, string propertyName, NameRule propNameRule) Expression property = Expression.Call(getPropMeth, new Expression[] {input ,psn, psnRl, pn, pnRl, valConst, valRul}); //bool result of the test AddToGroup(property, groupRule); }
public static bool EvaluatePropertyValue(IPersistIfcEntity element, string pSetName, NameRule pSetNameRule, string propertyName, NameRule propNameRule, string value, ValueRule valueRule) { Dictionary <IfcLabel, Dictionary <IfcIdentifier, IfcValue> > allProperties = null; if (string.IsNullOrEmpty(propertyName)) { return(false); } //properties could be defined in IfcTypeObject as HasProperties IfcTypeObject typeObject = element as IfcTypeObject; if (typeObject != null) { allProperties = typeObject.GetAllPropertySingleValues(); } //or properties could be defined in IfcObject in IsDefinedBy IfcObject ifcObject = element as IfcObject; if (ifcObject != null) { allProperties = ifcObject.GetAllPropertySingleValues(); } //or properties could be defined for material as ExtendedMaterialProperties IfcMaterial material = element as IfcMaterial; if (material != null) { allProperties = material.GetAllPropertySingleValues(); } //getting properties is not supported otherwise if (allProperties != null) { foreach (var p in allProperties) { //if pSetName is null all property sets are inspected if (pSetName != null) { if (!IsRightName(pSetName, p.Key, pSetNameRule)) { continue; } } foreach (var prop in p.Value) { //if name is not specified all values are returned if (IsRightName(propertyName, prop.Key, propNameRule)) { Type t = ((ExpressType)(prop.Value)).UnderlyingSystemType; Expression right = XbimQueryFactory.PromoteToConstant(t, value); Expression left = XbimQueryFactory.PromoteToConstant(t, prop.Value.ToString()); //todo: this should be more sofisticated than 'ToString()' Expression eval = CreateValueExpression(left, right, valueRule); return(Expression.Lambda <Func <bool> >(eval).Compile()()); } } } } return(false); }