public CreateTemplateCode CreatePropertyConstraint(Guid constraintId, string name, string descrption,
                                                           PropertyConstraint constraintType, PropertyConstraintLevel level, Guid propertyTemplate)
        {
            var retValue   = CreateTemplateCode.Updated;
            var constraint = Db.PropertyTemplateConstraints.SingleOrDefault(p => p.ObjId == constraintId);

            bool isNewObject = false;

            if (constraint == null)
            {
                isNewObject      = true;
                constraint       = new PropertyTemplateConstraint();
                constraint.ObjId = constraintId;
                retValue         = CreateTemplateCode.Created;
            }

            constraint.Name                  = name;
            constraint.Description           = descrption;
            constraint.ConstraintType        = (long)constraintType;
            constraint.This2PropertyTemplate = propertyTemplate;
            constraint.ConstraintLevel       = (long)level;

            if (isNewObject)
            {
                Db.PropertyTemplateConstraints.Add(constraint);
            }
            else
            {
                Db.PropertyTemplateConstraints.Update(constraint);
            }
            return(retValue);
        }
Exemple #2
0
        public MyConstraintBuilder Property(String propertyName, Object propertyValue)
        {
            PropertyConstraint pc = new PropertyConstraint(propertyName, new MyEqualToConstraint(propertyValue));

            constraints.Push(pc);
            return(this);
        }
Exemple #3
0
        private void CreateNodeClick(object sender, RoutedEventArgs e)
        {
            if (tvUISTree.SelectedItem is TreeViewItem tvi &&
                tvi.Header is UISObject obj &&
                obj is UISList lst)
            {
                Type listType = lst.GetListType();
                if (listType == typeof(UISObject))
                {
                    AllowTag = new ObjectTag[] { ObjectTag.AnimationDefine, ObjectTag.Comment, ObjectTag.Predefined, ObjectTag.Functional, ObjectTag.Custom, ObjectTag.List };
                }
                else if (listType == typeof(UISProperty))
                {
                    AllowTag = Enum.GetValues(typeof(Property));
                }
                else if (listType == typeof(UISAnimation))
                {
                    AllowTag = Enum.GetValues(typeof(AnimationName));
                }
                else if (listType == typeof(UISFunctionalElement))
                {
                    AllowTag = Enum.GetValues(typeof(FunctionElementType));
                }
                else
                {
                    ObjectTag tag = PropertyConstraint.GetPropertyConstraint <ObjectTag>(lst.GetListType());
                    AllowTag = new ObjectTag[] { tag };
                }

                ShowModalDialog(true);
                this.PopupContent.LoadDialog(Dialog.CreateNode);
            }
        }
Exemple #4
0
        public void ApplyTo_returns_success_when_expected(CompositeType test)
        {
            var sut = new PropertyConstraint <CompositeType>(ct => ct.StringValue, Is.EqualTo(test.StringValue));

            var result = sut.ApplyTo(test);

            Assert.That(result.IsSuccess, Is.True);
        }
Exemple #5
0
        protected override void VisitProperty(PropertyConstraint node)
        {
            var op = ConvertOperator(node.Operator);

            var source = Query.From.FindTable(node.ConcreteType);
            var column = source.Column(node.Property);

            _whereResult = f.Constraint(column, op, node.Value);
        }
            private static string GetOverlappingForeignKeyDescription(IEnumerable <PropertyConstraint> constraints)
            {
                var builder = new StringBuilder();

                PropertyConstraint firstConstraint = constraints.First();

                builder.AppendFormat(CultureInfo.InvariantCulture, "Dependent {{EntitySet = {0}, Property = {1}}} <--- Contributing principals: ", firstConstraint.DependentEntitySet.Name, firstConstraint.DependentProperty.Name);

                string separator = string.Empty;

                foreach (PropertyConstraint constraint in constraints)
                {
                    builder.Append(separator);
                    builder.AppendFormat(CultureInfo.InvariantCulture, "{{EntitySet = {0}, Property = {1}}}", constraint.PrincipalEntitySet.Name, constraint.PrincipalProperty.Name);
                    separator = ", ";
                }

                builder.Append(".");

                return(builder.ToString());
            }
        /// <summary>
        /// Resolve a constraint that has been recognized by applying
        /// any pending operators and returning the resulting Constraint.
        /// </summary>
        /// <returns>A constraint that incorporates all pending operators</returns>
        private Constraint Resolve(Constraint constraint)
        {
            while (ops.Count > 0)
                switch ((Op)ops.Pop())
                {
                    case Op.Not:
                        constraint = new NotConstraint(constraint);
                        break;
                    case Op.All:
                        constraint = new AllItemsConstraint(constraint);
                        break;
                    case Op.Some:
                        constraint = new SomeItemsConstraint(constraint);
                        break;
                    case Op.None:
                        constraint = new NoItemConstraint(constraint);
                        break;
                    case Op.Prop:
                        constraint = new PropertyConstraint((string)opnds.Pop(), constraint);
                        break;
                }

            return constraint;
        }
Exemple #8
0
 public CreateTemplateCode CreatePropertyConstraint(Guid constraintId, string name, string descrption,
                                                    PropertyConstraint constraintType, Guid propertyTemplate)
 {
     throw new NotImplementedException();
 }
Exemple #9
0
 /// <summary>
 /// Read value by constrainted <see cref="Func{UISValue}"/>
 /// </summary>
 /// <returns></returns>
 private static UISValue Value()
 {
     return(PropertyConstraint.GetPropertyConstraint <Func <UISValue> >(CURRENT_PROPERTY)());
 }
Exemple #10
0
        private static UISAnimation Animation()
        {
            Word aniName;

            aniName = look as Word;
            ExpectGrammar(Tag.IDENTITY);
            if (aniName.Lexeme != "name")
            {
                ThrowError(new UISAnimationNameMissingException(aniName.Lexeme));
            }
            ExpectGrammar(Tag.Equal);
            aniName = look as Word;
            string animation_name = string.Empty;

            if (aniName.Lexeme.Length <= 2)
            {
                animation_name = PropertyConstraint.GetPropertyConstraint <string>(aniName.Lexeme);
            }
            else
            {
                animation_name = aniName.Lexeme;
            }
            ExpectGrammar(Tag.IDENTITY);

            Func <UISValue> readFunc;

            if (Enum.TryParse(animation_name, true, out AnimationName TargetAnimate))
            {
                readFunc = PropertyConstraint.GetPropertyConstraint <Func <UISValue> >(TargetAnimate);
            }
            else
            {
                readFunc = null;
                ThrowError(new UISUnsupportAnimationException(aniName.Lexeme));
            }

            ExpectGrammar(Tag.Split);

            Word         kw;
            UISAnimation ani = new UISAnimation(TargetAnimate);

            do
            {
                kw = look as Word;
                if (kw == null)
                {
                    break;
                }
                ExpectGrammar(Tag.IDENTITY);
                switch (kw.Lexeme.ToLower())
                {
                case "from":
                    ExpectGrammar(Tag.Equal);
                    ani.AddAnimationProperty(new UISAnimationProperty(AnimationType.FROM, readFunc() as UISLiteralValue));
                    Expect(Tag.Split);
                    break;

                case "to":
                    ExpectGrammar(Tag.Equal);
                    ani.AddAnimationProperty(new UISAnimationProperty(AnimationType.TO, readFunc() as UISLiteralValue));
                    Expect(Tag.Split);
                    break;

                case "time":
                    ExpectGrammar(Tag.Equal);
                    ani.AddAnimationProperty(new UISAnimationProperty(AnimationType.TIME, AnimationTime()));
                    Expect(Tag.Split);
                    break;

                case "atime":
                    ExpectGrammar(Tag.Equal);
                    ani.AddAnimationProperty(new UISAnimationProperty(AnimationType.ATIME, AnimationTime()));
                    Expect(Tag.Split);
                    break;

                case "repeat":
                    ExpectGrammar(Tag.Equal);
                    ani.AddAnimationProperty(new UISAnimationProperty(AnimationType.REPEAT, AnimationRepeat()));
                    Expect(Tag.Split);
                    break;

                case "trans":
                    ExpectGrammar(Tag.Equal);
                    ani.AddAnimationProperty(new UISAnimationProperty(AnimationType.TRANS, new UISAnimationCurve(ReadCurve())));
                    Expect(Tag.Split);
                    break;

                default:
                    ThrowError(new UISUnsupportAnimationControllerException(kw.Lexeme));
                    break;
                }
            } while (!Test(Tag.LINE_END));

            return(ani);
        }
Exemple #11
0
 public static string GetRelativeUri(Dialog dialog)
 {
     return($"pack://application:,,,/UISEditor;component/{PropertyConstraint.GetPropertyConstraint<string>(dialog)}");
 }
            private bool ResolveConstraintValue(EntitySetDataRow dependentRow, MemberProperty property, PropertyConstraint constraint, out object value)
            {
                value = null;

                List <AssociationSetDataRow> associationRows = this.data[constraint.AssociationSet].Rows.Where(
                    r => ReferenceEquals(r.GetRoleKey(constraint.DependentRoleName), dependentRow.Key)).ToList();

                if (associationRows.Count == 0)
                {
                    return(false);
                }

                if (associationRows.Count > 1)
                {
                    throw new TaupoInvalidOperationException(string.Format(
                                                                 CultureInfo.InvariantCulture,
                                                                 "Multiplicity constraint violated: the association set '{0}' has multiple rows with the same role key for the dependent role '{1}'.",
                                                                 constraint.AssociationSet.Name,
                                                                 constraint.DependentRoleName));
                }

                EntityDataKey principalKey = associationRows[0].GetRoleKey(constraint.PrincipalRoleName);

                EntitySetDataRow principalRow = this.data[constraint.PrincipalEntitySet].Rows.Where(r => ReferenceEquals(r.Key, principalKey)).SingleOrDefault();

                if (principalRow != null)
                {
                    List <PropertyConstraint> constraints;
                    if (this.TryGetConstraints(principalRow, constraint.PrincipalProperty, out constraints))
                    {
                        var item = new KeyValuePair <EntitySetDataRow, MemberProperty>(dependentRow, property);
                        this.visited.Add(item);
                        value = this.ResolvePropertyValue(principalRow, constraint.PrincipalProperty, constraints);
                        this.visited.Remove(item);
                    }
                    else
                    {
                        value = principalRow[constraint.PrincipalProperty.Name];
                    }
                }
                else if (constraint.PrincipalProperty.IsPrimaryKey)
                {
                    value = principalKey[constraint.PrincipalProperty.Name];
                }

                return(true);
            }
Exemple #13
0
 protected virtual void VisitProperty(PropertyConstraint node)
 {
 }
 /// <summary>
 /// Adds the constraint for the property.
 /// </summary>
 /// <param name="constraint">The constraint.</param>
 public void AddConstraint(PropertyConstraint constraint)
 {
     this.constraints.Add(constraint);
 }
Exemple #15
0
 private PropertyConstraint ConstrainProperty(PropertyComparisonExpression exp)
 {
     var constraint = new PropertyConstraint(exp)
     {
         Context = Context,
     };
     return constraint;
 }
        public CreateTemplateCode CreatePropertyConstraint(Guid constraintId, string name, string descrption, PropertyConstraint constraintType, PropertyConstraintLevel level, Guid propertyTemplate)
        {
            var constraint = new PropertyTemplateConstraint
            {
                ObjId                 = constraintId,
                Name                  = name,
                Description           = descrption,
                ConstraintType        = (long)constraintType,
                This2PropertyTemplate = propertyTemplate,
                ConstraintLevel       = (long)level
            };



            _propertyConstraintTemplates.Add(constraintId, constraint);

            return(CreateTemplateCode.Created);
        }
Exemple #17
0
        private void AddConstraint(PropertyCompareOperator op, object val)
        {
            if (_pending == null)
            {
                throw new InvalidOperationException("查询构造出错:你必须先调用方法 Constrain。");
            }

            //如果没有指定属性对应的实体类型,则使用当前仓库对应的实体来作为属性的拥有者。
            var propertyOwner = _pendingOwner;
            if (propertyOwner == null)
            {
                propertyOwner = _pending.OwnerType;
                if (_repo.EntityType.IsSubclassOf(propertyOwner))
                {
                    propertyOwner = _repo.EntityType;
                }
            }

            var constraint = new PropertyConstraint
            {
                Context = this,
                Property = _pending,
                ConcreteType = propertyOwner,
                Operator = op,
                Value = val
            };
            this.AddConstraint(constraint);

            _pending = null;
            _pendingOwner = null;
        }
 /// <summary>
 /// Adds the constraint for the property.
 /// </summary>
 /// <param name="constraint">The constraint.</param>
 public void AddConstraint(PropertyConstraint constraint)
 {
     this.constraints.Add(constraint);
 }
Exemple #19
0
 public CreateTemplateCode CreatePropertyTemplate(Guid uid, string name, string description, string key,
                                                  PropertyTemplateType propertyType, Guid nodeTemplate, string groupd, bool isVisible, bool isReadonly, string meta,
                                                  object defaultValue, int groupOrder, int order, PropertyConstraint constraint,
                                                  PropertyConstraintLevel constraintLevel, string constraintMeta = "")
 {
     throw new NotImplementedException();
 }
Exemple #20
0
 public void SetUp()
 {
     theConstraint        = new PropertyConstraint("Length", new EqualConstraint(5));
     expectedDescription  = "property Length equal to 5";
     stringRepresentation = "<property Length <equal 5>>";
 }
            private bool ResolveConstraintValue(EntitySetDataRow dependentRow, MemberProperty property, PropertyConstraint constraint, out object value)
            {
                value = null;

                List<AssociationSetDataRow> associationRows = this.data[constraint.AssociationSet].Rows.Where(
                            r => ReferenceEquals(r.GetRoleKey(constraint.DependentRoleName), dependentRow.Key)).ToList();

                if (associationRows.Count == 0)
                {
                    return false;
                }

                if (associationRows.Count > 1)
                {
                    throw new TaupoInvalidOperationException(string.Format(
                     CultureInfo.InvariantCulture,
                     "Multiplicity constraint violated: the association set '{0}' has multiple rows with the same role key for the dependent role '{1}'.",
                     constraint.AssociationSet.Name,
                     constraint.DependentRoleName));
                }

                EntityDataKey principalKey = associationRows[0].GetRoleKey(constraint.PrincipalRoleName);

                EntitySetDataRow principalRow = this.data[constraint.PrincipalEntitySet].Rows.Where(r => ReferenceEquals(r.Key, principalKey)).SingleOrDefault();

                if (principalRow != null)
                {
                    List<PropertyConstraint> constraints;
                    if (this.TryGetConstraints(principalRow, constraint.PrincipalProperty, out constraints))
                    {
                        var item = new KeyValuePair<EntitySetDataRow, MemberProperty>(dependentRow, property);
                        this.visited.Add(item);
                        value = this.ResolvePropertyValue(principalRow, constraint.PrincipalProperty, constraints);
                        this.visited.Remove(item);
                    }
                    else
                    {
                        value = principalRow[constraint.PrincipalProperty.Name];
                    }
                }
                else if (constraint.PrincipalProperty.IsPrimaryKey)
                {
                    value = principalKey[constraint.PrincipalProperty.Name];
                }

                return true;
            }
 public void SetUp()
 {
     theConstraint = new PropertyConstraint("Length", new EqualConstraint(5));
     expectedDescription = "property Length equal to 5";
     stringRepresentation = "<property Length <equal 5>>";
 }
Exemple #23
0
        public void Assert_succeeds(CompositeType test)
        {
            var sut = new PropertyConstraint <CompositeType>(ct => ct.StringValue, Is.EqualTo(test.StringValue));

            Assert.That(test, sut);
        }
Exemple #24
0
        private static void InitConstraint()
        {
            PropertyConstraint.AddPropertyConstraint <Func <UISValue> >(Property.TEX, Filename);
            for (int i = (int)Property.TEX2; i < (int)Property.TEX10; i++)
            {
                PropertyConstraint.AddPropertyConstraint <Func <UISValue> >((Property)i, Filename);
            }
            PropertyConstraint.AddPropertyConstraint <Func <UISValue> >(Property.FRAME, Framefile);
            for (int i = (int)Property.FRAME2; i < (int)Property.FRAME20; i++)
            {
                PropertyConstraint.AddPropertyConstraint <Func <UISValue> >((Property)i, Framefile);
            }
            PropertyConstraint.AddPropertyConstraint <Func <UISValue> >(Property.COLOR, Hexcolor);

            PropertyConstraint.AddPropertyConstraint <Func <UISValue> >(Property.SIZE, RelativeVector);
            PropertyConstraint.AddPropertyConstraint <Func <UISValue> >(Property.POS, RelativeVector);
            PropertyConstraint.AddPropertyConstraint <Func <UISValue> >(Property.SIZE2, RelativeVector);
            PropertyConstraint.AddPropertyConstraint <Func <UISValue> >(Property.POS2, RelativeVector);
            PropertyConstraint.AddPropertyConstraint <Func <UISValue> >(Property.PART, Vector);

            PropertyConstraint.AddPropertyConstraint <Func <UISValue> >(Property.ANCHOR, Term);
            PropertyConstraint.AddPropertyConstraint <Func <UISValue> >(Property.ROTATE, Term);
            PropertyConstraint.AddPropertyConstraint <Func <UISValue> >(Property.FLIP, Term);
            PropertyConstraint.AddPropertyConstraint <Func <UISValue> >(Property.OPACITY, Term);
            PropertyConstraint.AddPropertyConstraint <Func <UISValue> >(Property.ZINDEX, Term);
            PropertyConstraint.AddPropertyConstraint <Func <UISValue> >(Property.FSIZE, Term);
            PropertyConstraint.AddPropertyConstraint <Func <UISValue> >(Property.BLEND, Term);
            PropertyConstraint.AddPropertyConstraint <Func <UISValue> >(Property.TYPE, Term);
            PropertyConstraint.AddPropertyConstraint <Func <UISValue> >(Property.TYPE2, Term);
            PropertyConstraint.AddPropertyConstraint <Func <UISValue> >(Property.INTERVAL, Term);
            PropertyConstraint.AddPropertyConstraint <Func <UISValue> >(Property.MOTION, Motion);
            PropertyConstraint.AddPropertyConstraint <Func <UISValue> >(Property.ACTION1, Motion);
            PropertyConstraint.AddPropertyConstraint <Func <UISValue> >(Property.ACTION2, Motion);
            PropertyConstraint.AddPropertyConstraint <Func <UISValue> >(Property.HOVER, Motion);
            PropertyConstraint.AddPropertyConstraint <Func <UISValue> >(Property.LEAVE, Motion);
            PropertyConstraint.AddPropertyConstraint <Func <UISValue> >(Property.TEXT, Word);
            PropertyConstraint.AddPropertyConstraint <Func <UISValue> >(Property.PARENT, Word);
            PropertyConstraint.AddPropertyConstraint <Func <UISValue> >(Property.TAG, Term);
            PropertyConstraint.AddPropertyConstraint <Func <UISValue> >(Property.ETAG, Term);
            PropertyConstraint.AddPropertyConstraint <Func <UISValue> >(Property.LANG, Word);
            PropertyConstraint.AddPropertyConstraint <Func <UISValue> >(Property.UNSUPPOORT, Word);
            PropertyConstraint.AddPropertyConstraint <Func <UISValue> >(Property.TIP, Word);
            PropertyConstraint.AddPropertyConstraint <Func <UISValue> >(Property.SHOW, Term);

            PropertyConstraint.AddPropertyConstraint <Func <UISValue> >(AnimationName.MOVE, Vector);
            PropertyConstraint.AddPropertyConstraint <Func <UISValue> >(AnimationName.SCALE, Vector);
            PropertyConstraint.AddPropertyConstraint <Func <UISValue> >(AnimationName.SIZE, Vector);
            PropertyConstraint.AddPropertyConstraint <Func <UISValue> >(AnimationName.SKEW, Vector);

            PropertyConstraint.AddPropertyConstraint <Func <UISValue> >(AnimationName.WIDTH, Term);
            PropertyConstraint.AddPropertyConstraint <Func <UISValue> >(AnimationName.HEIGHT, Term);
            PropertyConstraint.AddPropertyConstraint <Func <UISValue> >(AnimationName.MOVEX, Term);
            PropertyConstraint.AddPropertyConstraint <Func <UISValue> >(AnimationName.MOVEY, Term);
            PropertyConstraint.AddPropertyConstraint <Func <UISValue> >(AnimationName.SCALEX, Term);
            PropertyConstraint.AddPropertyConstraint <Func <UISValue> >(AnimationName.SCALEY, Term);
            PropertyConstraint.AddPropertyConstraint <Func <UISValue> >(AnimationName.SKEWX, Term);
            PropertyConstraint.AddPropertyConstraint <Func <UISValue> >(AnimationName.SKEWY, Term);
            PropertyConstraint.AddPropertyConstraint <Func <UISValue> >(AnimationName.ROTATE, Term);
            PropertyConstraint.AddPropertyConstraint <Func <UISValue> >(AnimationName.FADE, Term);

            PropertyConstraint.AddPropertyConstraint <Func <UISValue> >(AnimationName.TINY, Hexcolor);

            PropertyConstraint.AddPropertyConstraint <Func <UISValue> >(AnimationName.SHOW, Nul);
            PropertyConstraint.AddPropertyConstraint <Func <UISValue> >(AnimationName.HIDE, Nul);

            for (int i = (int)Property.RECT; i < (int)Property.RECT10; i++)
            {
                PropertyConstraint.AddPropertyConstraint <Func <UISRect> >((Property)i, Rect);
            }
            PropertyConstraint.AddPropertyConstraint <Func <UISRect> >(Property.PADDING, Rect);

            PropertyConstraint.AddPropertyConstraint("m", "move");
            PropertyConstraint.AddPropertyConstraint("s", "scale");
            PropertyConstraint.AddPropertyConstraint("w", "width");
            PropertyConstraint.AddPropertyConstraint("h", "height");
            PropertyConstraint.AddPropertyConstraint("mx", "movex");
            PropertyConstraint.AddPropertyConstraint("my", "movey");
            PropertyConstraint.AddPropertyConstraint("sx", "scalex");
            PropertyConstraint.AddPropertyConstraint("sy", "scaley");
            PropertyConstraint.AddPropertyConstraint("r", "rotate");
            PropertyConstraint.AddPropertyConstraint("f", "fade");
        }
Exemple #25
0
        protected override void VisitProperty(PropertyConstraint node)
        {
            var op = ConvertOperator(node.Operator);

            var source = Query.From.FindTable(node.ConcreteType);
            var column = source.Column(node.Property);
            _whereResult = f.Constraint(column, op, node.Value);
        }
Exemple #26
0
        public void ApplyTo_throws_not_supported_if_test_is_not_same_as_type(object test)
        {
            var sut = new PropertyConstraint <CompositeType>(ct => ct.StringValue, Is.EqualTo("Hello world"));

            Assert.That(() => sut.ApplyTo(test), Throws.Exception.TypeOf <NotSupportedException>());
        }
 public CreateTemplateCode CreatePropertyConstraint(Guid constraintId, string name, string descrption,
                                                    PropertyConstraint constraintType, PropertyConstraintLevel level, Guid propertyTemplate)
 {
     return(CreateTemplateCode.Updated);
 }
Exemple #28
0
 static DialogResource()
 {
     PropertyConstraint.AddPropertyConstraint(Dialog.CreateNode, $"View/Dialog/CreateNode.xaml");
     PropertyConstraint.AddPropertyConstraint(Dialog.ResourceView, $"View/Dialog/ResourceViewer.xaml");
 }
        public void PropertyEqualToValueWithTolerance()
        {
            Constraint c = new EqualConstraint(105m).Within(0.1m);
            TextMessageWriter w = new TextMessageWriter();
            c.WriteDescriptionTo(w);
            Assert.That(w.ToString(), Is.EqualTo("105m +/- 0.1m"));

            c = new PropertyConstraint("D", new EqualConstraint(105m).Within(0.1m));
            w = new TextMessageWriter();
            c.WriteDescriptionTo(w);
            Assert.That(w.ToString(), Is.EqualTo("property D equal to 105m +/- 0.1m"));
        }
Exemple #30
0
 protected virtual void VisitProperty(PropertyConstraint node)
 {
 }