当前位置: 首页>>代码示例>>C#>>正文


C# IConstraint类代码示例

本文整理汇总了C#中IConstraint的典型用法代码示例。如果您正苦于以下问题:C# IConstraint类的具体用法?C# IConstraint怎么用?C# IConstraint使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


IConstraint类属于命名空间,在下文中一共展示了IConstraint类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: And

 public virtual IConstraint And(IConstraint andWith)
 {
     lock (StreamLock())
     {
         return Join(andWith, true);
     }
 }
开发者ID:masroore,项目名称:db4o,代码行数:7,代码来源:QCon.cs

示例2: GetRandomValueCore

        protected override object GetRandomValueCore(Type type, IConstraint[] constraints)
        {
            var valueScaled = _random.NextDouble();

            if (type == typeof(float))
                return this.ApplyConstraints(
                    constraints, 0.0f, 1.0f,
                    (minValue, maxValue) => minValue + valueScaled * (maxValue - minValue)
                );

            if (type == typeof(double))
                return this.ApplyConstraints(
                    constraints, 0.0d, 1.0d,
                    (minValue, maxValue) => minValue + valueScaled * (maxValue - minValue)
                );

            if (type == typeof(decimal))
                return this.ApplyConstraints(
                    constraints, 0.0m, 1.0m,
                    (minValue, maxValue) => minValue + (decimal)valueScaled * (maxValue - minValue)
                );

            throw new InvalidOperationException(
                string.Format("{0} does not support generation of {1}", this.GetType(), type
            ));
        }
开发者ID:svn2github,项目名称:azonlibrary,代码行数:26,代码来源:FractionalValueGenerator.cs

示例3: VisitGroup

        protected override void VisitGroup(ConstraintGroup node)
        {
            IConstraint where = null;

            for (int i = 0, c = node.Items.Count; i < c; i++)
            {
                this.Visit(node.Items[i]);

                if (i == 0)
                {
                    where = _whereResult;
                }
                else
                {
                    string op = node.Operators[i - 1];
                    if (op == Constraint.AndOperator)
                    {
                        where = f.And(where, _whereResult);
                    }
                    else if (op == Constraint.OrOperator)
                    {
                        where = f.Or(where, _whereResult);
                    }
                }
            }

            _whereResult = where;
        }
开发者ID:569550384,项目名称:Rafy,代码行数:28,代码来源:ConstraintConverter.cs

示例4: FormatDescription

 /// <summary>
 /// Formats a prefix constraint's description.
 /// </summary>
 internal static string FormatDescription(string descriptionPrefix, IConstraint baseConstraint)
 {
     return string.Format(
         baseConstraint is EqualConstraint ? "{0} equal to {1}" : "{0} {1}",
         descriptionPrefix,
         baseConstraint.Description);
 }
开发者ID:nunit,项目名称:nunit,代码行数:10,代码来源:PrefixConstraint.cs

示例5: Visit

			public virtual void Visit(OrExpression expression)
			{
				expression.Left().Accept(this);
				IConstraint left = _constraint;
				expression.Right().Accept(this);
				left.Or(_constraint);
				_constraint = left;
			}
开发者ID:erdincay,项目名称:db4o,代码行数:8,代码来源:SODAQueryBuilder.cs

示例6: BinaryConstraint

        /// <summary>
        /// Construct a BinaryConstraint from two other constraints
        /// </summary>
        /// <param name="left">The first constraint</param>
        /// <param name="right">The second constraint</param>
        protected BinaryConstraint(IConstraint left, IConstraint right)
            : base(left, right)
        {
            Guard.ArgumentNotNull(left, "left");
            this.Left = left;

            Guard.ArgumentNotNull(right, "right");
            this.Right = right;
        }
开发者ID:alfeg,项目名称:nunit,代码行数:14,代码来源:BinaryConstraint.cs

示例7: BuildMessage

        /// <summary>
        /// Writes the difference between the constraint and the actual value into a message.
        /// </summary>
        /// <param name="constraint">The constraint.</param>
        public string BuildMessage(IConstraint constraint)
        {
            this.Message = string.Format("Expected: '{0}' But was : '{1}'"
                , constraint.Description
                , this.GetString(constraint.Actual));

            this.BuildHeader(this.Message, constraint);
            return this.Message;
        }
开发者ID:seniorOtaka,项目名称:ndoctor,代码行数:13,代码来源:TextMessageWriter.cs

示例8: GetRandomValueCore

        protected override object GetRandomValueCore(Type type, IConstraint[] constraints)
        {
            var randomNumber = _random.Next(Int32.MinValue, Int32.MaxValue);
            var valueScaled = (decimal)((long)randomNumber - Int32.MinValue) / ((long)Int32.MaxValue - Int32.MinValue);

            if (type == typeof(sbyte))
                return this.ApplyConstraints(
                    constraints, sbyte.MinValue, sbyte.MaxValue,
                    (minValue, maxValue) => minValue + valueScaled * (maxValue - minValue)
                );

            if (type == typeof(short))
                return this.ApplyConstraints(
                    constraints, short.MinValue, short.MaxValue,
                    (minValue, maxValue) => minValue + valueScaled * (maxValue - minValue)
                );

            if (type == typeof(int))
                return this.ApplyConstraints(
                    constraints, int.MinValue, int.MaxValue,
                    (minValue, maxValue) => minValue + valueScaled * ((long)maxValue - minValue)
                );

            if (type == typeof(long))
                return this.ApplyConstraints(
                    constraints, long.MinValue, long.MaxValue,
                    (minValue, maxValue) => this.ConstrictToRange(valueScaled, minValue, maxValue)
                );

            if (type == typeof(byte))
                return this.ApplyConstraints(
                    constraints, byte.MinValue, byte.MaxValue,
                    (minValue, maxValue) => minValue + valueScaled * (maxValue - minValue)
                );

            if (type == typeof(ushort))
                return this.ApplyConstraints(
                    constraints, ushort.MinValue, ushort.MaxValue,
                    (minValue, maxValue) => minValue + valueScaled * (maxValue - minValue)
                );

            if (type == typeof(uint))
                return this.ApplyConstraints(
                    constraints, uint.MinValue, uint.MaxValue,
                    (minValue, maxValue) => minValue + valueScaled * (maxValue - minValue)
                );

            if (type == typeof(ulong))
                return this.ApplyConstraints(
                    constraints, ulong.MinValue, ulong.MaxValue,
                    (minValue, maxValue) => minValue + valueScaled * (maxValue - minValue)
                );

            throw new InvalidOperationException(
                string.Format("{0} does not support generation of {1}", this.GetType(), type
            ));
        }
开发者ID:svn2github,项目名称:azonlibrary,代码行数:57,代码来源:NumericValueGenerator.cs

示例9: InstanceRegistration

        public InstanceRegistration(IConstraint constraint, ActionDescriptor actionDescriptor, ControllerDescriptor controllerDescriptor, FilterScope scope1)
            : base(actionDescriptor, controllerDescriptor, scope1)
        {
            if (constraint == null)
            {
                throw new ArgumentNullException("constraint", "Constraint instance can not be null.");
            }

            Constraint = constraint;
            ConstraintType = Constraint.GetType();
        }
开发者ID:Grinderofl,项目名称:FluentMvc,代码行数:11,代码来源:InstanceRegistration.cs

示例10: GetRandomValue

        public object GetRandomValue(Type type, IConstraint[] constraints)
        {
            Require.NotNull(type, "type");
            Require.That<InvalidOperationException>(
                this.IsTypeSupported(type),
                "{0} does not support generation of {1}.",
                this.GetType(), type
            );

            return this.GetRandomValueCore(type, constraints);
        }
开发者ID:svn2github,项目名称:azonlibrary,代码行数:11,代码来源:ValueGenerator.cs

示例11: Constraints

		public virtual IConstraints Constraints()
		{
			lock (_cluster)
			{
				IConstraint[] constraints = new IConstraint[_queries.Length];
				for (int i = 0; i < constraints.Length; i++)
				{
					constraints[i] = _queries[i].Constraints();
				}
				return new ClusterConstraints(_cluster, constraints);
			}
		}
开发者ID:Galigator,项目名称:db4o,代码行数:12,代码来源:ClusterQuery.cs

示例12: Constrain

 public virtual IConstraint Constrain(object constraint)
 {
     lock (_cluster)
     {
         var constraints = new IConstraint[_queries.Length];
         for (var i = 0; i < constraints.Length; i++)
         {
             constraints[i] = _queries[i].Constrain(constraint);
         }
         return new ClusterConstraint(_cluster, constraints);
     }
 }
开发者ID:masroore,项目名称:db4o,代码行数:12,代码来源:ClusterQuery.cs

示例13: Pendulum

        private Pendulum(Particle point_a_, Particle point_b_, Vector3f equilibrium_position_, Render callback_, params IConstraint[] constraints_)
        {
            point_a = point_a_;
            point_b = point_b_;
            callback = callback_;
            equilibrium_position = equilibrium_position_;

            constraints = new IConstraint[constraints_.Length];
            for(int i = 0; i < constraints_.Length; ++i)
            {
                constraints[i] = constraints_[i];
            }
        }
开发者ID:jonwa,项目名称:Pendulum-waves,代码行数:13,代码来源:Pendulum.cs

示例14: Join

		internal override IConstraint Join(IConstraint a_with, bool a_and)
		{
			lock (StreamLock())
			{
				if (!(a_with is QCon))
				{
					return null;
				}
				// resolving multiple constraints happens in QCon for
				// a_with, so we simply turn things around
				return ((QCon)a_with).Join1(this, a_and);
			}
		}
开发者ID:erdincay,项目名称:db4o,代码行数:13,代码来源:QConstraints.cs

示例15: PrefixConstraint

        /// <summary>
        /// Construct given a base constraint
        /// </summary>
        /// <param name="baseConstraint"></param>
        protected PrefixConstraint(IResolveConstraint baseConstraint)
            : base(baseConstraint)
        {
            Guard.ArgumentNotNull(baseConstraint, "baseConstraint");

            this.baseConstraint = baseConstraint.Resolve();
        }
开发者ID:alfeg,项目名称:nunit,代码行数:11,代码来源:PrefixConstraint.cs


注:本文中的IConstraint类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。