本文整理汇总了C#中Constraint类的典型用法代码示例。如果您正苦于以下问题:C# Constraint类的具体用法?C# Constraint怎么用?C# Constraint使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Constraint类属于命名空间,在下文中一共展示了Constraint类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CSP
public CSP(ArrayList variables, Constraint constraints, Domain domains)
{
this.variables = variables;
//this.assignment = new Assignment(variables);
this.domains = domains;
this.constraints = constraints;
}
示例2: Visit
protected virtual void Visit(Constraint constraint)
{
switch (constraint.Type)
{
case ConstraintType.Empty:
this.VisitEmpty(constraint as EmptyConstraint);
break;
case ConstraintType.Property:
this.VisitProperty(constraint as PropertyConstraint);
break;
case ConstraintType.TwoPropertiesComparison:
this.VisitTwoPropertiesComparison(constraint as TwoPropertiesConstraint);
break;
case ConstraintType.Sql:
this.VisitSqlWhereConstraint(constraint as SqlWhereConstraint);
break;
case ConstraintType.AndOr:
this.VisitAndOrConstraint(constraint as AndOrConstraint);
break;
case ConstraintType.Group:
this.VisitGroup(constraint as ConstraintGroup);
break;
default:
break;
}
}
示例3: ConstraintToCatKind
public CatKind ConstraintToCatKind(Constraint c)
{
if (c is ScalarVar)
{
return new CatTypeVar(c.ToString());
}
else if (c is VectorVar)
{
return new CatStackVar(c.ToString());
}
else if (c is Vector)
{
return CatTypeVectorFromVec(c as Vector);
}
else if (c is Relation)
{
return CatFxnTypeFromRelation(c as Relation);
}
else if (c is RecursiveRelation)
{
return new CatRecursiveType();
}
else if (c is Constant)
{
// TODO: deal with CatCustomKinds
return new CatSimpleTypeKind(c.ToString());
}
else
{
throw new Exception("unhandled constraint " + c.ToString());
}
}
示例4: GeneratedFromXMLPosture
/// <summary>
/// Constructs a Posture Recognizer from a XML-File
/// </summary>
/// <param name="name">name of the given Posture (same as the XML-Source-File)</param>
/// <param name="XMLPath">full path of the XML-Source-File</param>
public GeneratedFromXMLPosture(String name, String xmlPath)
: base(name)
{
try
{
//Load the XML-Document in a new XmlDocument-Object
XmlDocument constraintsXML = new XmlDocument();
constraintsXML.Load(xmlPath);
//put Angle-Nodes from the XML to a XMLNodeList-Object
XmlNodeList xmlConstraintsList;
XmlNode root = constraintsXML.DocumentElement;
xmlConstraintsList = root.SelectNodes("//posture/constraints/angle");
//xmlConstraintsList -> constraints
foreach (XmlNode newConstraint in xmlConstraintsList)
{
Constraint newOne = new Constraint();
newOne.JointA = newConstraint.ChildNodes[0].InnerText;
newOne.JointB = newConstraint.ChildNodes[1].InnerText;
newOne.JointC = newConstraint.ChildNodes[2].InnerText;
newOne.min = Convert.ToInt16(newConstraint.ChildNodes[3].InnerText);
newOne.max = Convert.ToInt16(newConstraint.ChildNodes[4].InnerText);
constraints.Add(newOne);
}
}
catch (Exception e)
{
Console.WriteLine("Sorry, could not read " + xmlPath + ". StackTrace following." + e.StackTrace);
}
}
示例5: No_PrimaryKey
public void No_PrimaryKey()
{
var c = new Constraint("ix_testing", ContraintType.Index, "testing");
var test = new Table("test");
test.Constraints.Add(c);
Assert.Null(test.PrimaryKey);
}
示例6: Column
public Column(string name, DataType type, Constraint constraint, bool primaryKey)
{
Name = name;
Type = type;
Constraint = constraint;
PrimaryKey = primaryKey;
}
示例7: Set_PrimaryKey
public void Set_PrimaryKey()
{
var c = new Constraint("ix_testing", ContraintType.PrimaryKey, "testing");
var test = new Table("test");
test.Constraints.Add(c);
Assert.Equal(c, test.PrimaryKey);
}
示例8: Create
internal void Create(int numConstraints)
{
Vector = new Constraint[numConstraints];
// Initialize this to out of range.
firstActiveConstraintIndex = numConstraints;
}
示例9: GetSet_Unique
public void GetSet_Unique()
{
var test = new Constraint("test", ContraintType.Constraint, new List<string>());
var c = test.Unique;
test.Unique = !c;
Assert.Equal(!c, test.Unique);
}
示例10: CombineConstraint
public Constraint CombineConstraint(Constraint other, System.Linq.Expressions.ExpressionType op)
{
BooleanCombinationConstraint combinedConstraint = new BooleanCombinationConstraint(op);
combinedConstraint.AddConstraint(this);
combinedConstraint.AddConstraint(other);
return combinedConstraint;
}
示例11: AttributeConstraint
/// <summary>
/// Constructs an AttributeConstraint for a specified attriute
/// Type and base constraint.
/// </summary>
/// <param name="type"></param>
/// <param name="baseConstraint"></param>
public AttributeConstraint(Type type, Constraint baseConstraint)
: base(baseConstraint)
{
this.expectedType = type;
if (!typeof(Attribute).IsAssignableFrom(expectedType))
throw new ArgumentException(string.Format(
"Type {0} is not an attribute", expectedType), "type");
}
示例12: IsValid
public static void IsValid(
Constraint obj,
MethodReturnEventArgs<bool> e,
object constrainedObjectParam,
object constrainedValueParam)
{
// the base constraint accepts all values
e.Result = true;
}
示例13: ShowPopup
public void ShowPopup(View popupView, Constraint xConstraint, Constraint yConstraint, Constraint widthConstraint = null, Constraint heightConstraint = null)
{
DismissPopup();
_popup = popupView;
_content.InputTransparent = true;
Children.Add(_popup, xConstraint, yConstraint, widthConstraint, heightConstraint);
UpdateChildrenLayout();
}
示例14: Intersects
public override VersionRangePart Intersects(Constraint constraint)
{
#region Sanity checks
if (constraint == null) throw new ArgumentNullException("constraint");
#endregion
// If the exact version lies within the constraint, the exact version remains
if (constraint.NotBefore != null && _version < constraint.NotBefore) return null;
if (constraint.Before != null && _version >= constraint.Before) return null;
return this;
}
示例15: FromPoint
public static SubSpace FromPoint(params double[] coordinates)
{
//foreach coordinate, one constraint x[i]=coordinate[y], and the term??
Constraint[] constraints=new Constraint[coordinates.Length];
for (int i = 0; i < coordinates.Length; i++)
{
double[] constraintCoeffs=new double[coordinates.Length];
constraintCoeffs[i] = coordinates[i];
constraints[i] = new DefaultConstraint(constraintCoeffs);
}
return new SubSpace(constraints);
}