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);
        }