本文整理汇总了C#中Term.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# Term.GetType方法的具体用法?C# Term.GetType怎么用?C# Term.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Term
的用法示例。
在下文中一共展示了Term.GetType方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: VisitTerm
public static void VisitTerm(Term term, GdlVisitor visitor)
{
visitor.VisitTerm(term);
var constant = term as TermObject;
if (constant != null)
visitor.VisitConstant(constant);
else if (term is TermVariable)
visitor.VisitVariable((TermVariable) term);
else if (term is TermFunction)
VisitFunction((TermFunction) term, visitor);
else
throw new Exception("Unexpected Term type " + term.GetType());
}
示例2: DependencyTermCreation
private static bool DependencyTermCreation(TimeBox sender, Term other, IOrderedEnumerable<Term> orderedTerms)
{
var newTermType = other.GetType();
var closestBottom = sender.GetClosestBottom(other);
var overlapping = false;
var canLandingOn = false;
foreach (var t in orderedTerms)
{
var insiede = other.IsInTheRange(t.Start, t.End);
overlapping = t.AnyOverlap(other) && !insiede; //oh! No~
if (overlapping)
{
other.Exception = new TermException(t, "AnyOverlap");
break;
}
canLandingOn = t.CanBeOverlap(newTermType);
if (!canLandingOn && insiede)
{
other.Exception = new TermException(t, "RelationIncorrect");
break;
}// find right position but no right relation
if (canLandingOn && insiede)
{
other.Bottom = closestBottom;
break;
}
}
return overlapping == false && canLandingOn;
}
示例3: NeedRelyOn
public override bool NeedRelyOn(Term other)
{
return _typesOfRelyOn.Contains(other.GetType());
}
示例4: CreateNewTerm
private static Term CreateNewTerm(Term term, DateTime start, DateTime end)
{
var newTerm = Term.CopyAsNew(start, term.GetType(), term, (int)(end - start).TotalMinutes);
newTerm.Seat = term.Seat;
newTerm.Tag = term.Tag;
return newTerm;
}
示例5: Mgu
public override bool Mgu(Term t, Substitution subsSoFar)
{
if (t is TermObject)// Cannot map functions to constants.
return false;
var variable = t as TermVariable;
if (variable != null)// Reverse the problem; the TermVariable class handles this
return variable.Mgu(this, subsSoFar);
var function = t as TermFunction;
if (function != null)
{
TermFunction f = function;
// Make sure that our function names are equal
if (FunctionName != f.FunctionName)
return false;
// Make sure arities are the same
if (Arity != f.Arity)
return false;
// Finally, make sure we can get the mgu of all arguments
for (int i = 0; i < Arity; i++)
if (Arguments[i].Mgu(f.Arguments[i], subsSoFar) == false)
return false;
// All good!
return true;
}
throw new Exception("TermFunction.mgu: Don't know how to handle term of type " + t.GetType().Name);
}
示例6: Mgu
public override bool Mgu(Term t, Substitution subsSoFar)
{
if (t is TermObject)
return Equals(t);
var variable = t as TermVariable;
if (variable != null) // Reverse the problem; the TermVariable class handles this
return variable.Mgu(this, subsSoFar);
if (t is TermFunction) // Can't unify a function and a constant.
return false;
throw new ApplicationException("TermObject.mgu: Don't know how to handle term of type " + t.GetType().Name);
}
示例7: AddTerm
public bool AddTerm(Term term, IDictionary<TermVariable, TermModel> varsToModelsMap)
{
var termObject = term as TermObject;
if (termObject != null)
return PossibleConstants.Add(termObject);
var function = term as TermFunction;
if (function != null)
{
var sentenceName = new NameAndArity(function);
bool changesMade = PossibleFunctions.CreateIfRequired(sentenceName);
return changesMade | AddBodyToModel(PossibleFunctions[sentenceName], function.Arguments.ToList(), varsToModelsMap);
}
var key = term as TermVariable;
if (key != null)
return MergeIn(varsToModelsMap[key]);
throw new Exception(String.Format("Unrecognized term type {0} for term {1}", term.GetType(), term));
}
示例8: Create
//public virtual void CreateOffWork(Term newTerm, Action<ITerm, bool> callback)
//{
// var foundTerms = TermSet.Retrieve<Term>(newTerm.Start, newTerm.End, o => o.Is<IIndependenceTerm>());
// var filteredTerms = foundTerms.Where(t => t.IsCoverd(newTerm.Start, newTerm.End)).OrderBy(o=> o.Start);
// var success = CreateValidations[newTerm.GetType()].Invoke(this, newTerm, filteredTerms);
// if (success)
// {
// _termSet.Add(newTerm);
// newTerm.UpdateLevel();
// newTerm.SetEmployeeId(Id);
// }
// callback(newTerm, success);
//}
public virtual void Create(Term newTerm, Action<ITerm, bool> callback, bool withRplaceDayOff)
{
//var success = false;
//var closestBottomTerm = GetOrderedBottoms(newTerm).FirstOrDefault();
//if (closestBottomTerm == null || !closestBottomTerm.Locked)
//{
//TODO: reconsider OrderBy clause
var foundTerms = TermSet.Retrieve<Term>(newTerm.Start, newTerm.End, o => o.IsNot<IImmutableTerm>());
var filteredTerms = foundTerms.Where(t => t.IsCoverd(newTerm.Start, newTerm.End)).OrderByDescending(o => o.Level);
var success = CreateValidations[newTerm.GetType()].Invoke(this, newTerm, filteredTerms);
//set up belongToPrev
//xnewTerm.RectifyAttribution(Boundary, newTerm.Start);
//temporary remark with IsOutOfBoundary limit
//if (success && newTerm.IsNot<IOffWork>())
//{
// var lowestTerm = newTerm.GetLowestTerm();
// success = !lowestTerm.IsOutOfBoundary(lowestTerm.Start, this);
//}
if (!success && newTerm.Exception != null && withRplaceDayOff && newTerm.Exception.CauseTarget is DayOff)
success = Delete(newTerm.Exception.CauseTarget, false);
if (success)
{
_termSet.Add(newTerm);
newTerm.UpdateLevel();
newTerm.SetEmployeeId(Id);
//xnewTerm.ForceAssignSeat(foundTerms, true);
Reporting(newTerm);
//xEmptySeatArrangment<AbsentEvent>(newTerm);
}
callback(newTerm, success);
}
示例9: Mgu
public override bool Mgu(Term t, Substitution subsSoFar)
{
if (t is TermObject)
{
Term replacement = subsSoFar.GetMapping(this);
if (replacement != null)
{
TermVariable termVariable = replacement as TermVariable;
if (termVariable != null)
{
subsSoFar.AddMapping(this, t);
subsSoFar.AddMapping(termVariable, t);
return true;
}
return replacement.Equals(t);
}
// There was no replacement:
// Add a mapping for the variable to this term-object
subsSoFar.AddMapping(this, t);
return true;
}
var variable = t as TermVariable;
if (variable != null)
{
TermVariable it = variable;
Term myReplacement = subsSoFar.GetMapping(this);
Term itsReplacement = subsSoFar.GetMapping(it);
if (itsReplacement == null)
{
// just map 'it' to me (or my replacement)
if (myReplacement == null)
{
if (!Equals(it))
subsSoFar.AddMapping(it, this);
}
else
{
if (!(myReplacement is TermVariable) || !myReplacement.Equals(it))
subsSoFar.AddMapping(it, myReplacement);
}
return true;
}
// At this point, 'it' has a replacement.
if (myReplacement == null)
{
// I don't have a replacement, so map me to it, or to its replacement
if (!(itsReplacement is TermVariable) || !itsReplacement.Equals(this))
subsSoFar.AddMapping(this, itsReplacement);
return true;
}
// At this point, both term variables have replacements.
// So make sure that they are the same!
return myReplacement.Equals(itsReplacement);
}
var func = t as TermFunction;
if (func != null)
{
Term myReplacement = subsSoFar.GetMapping(this);
// Case 1: I have a replacement
if (myReplacement != null)
// See if my replacement can be unified with the function
return myReplacement.Mgu(func, subsSoFar);
// Case 2: I have no replacement
TermFunction itsReplacement = subsSoFar.GetMapping(func);
if (itsReplacement.HasVariable(this))
return false;
// just set my replacement to the function
subsSoFar.AddMapping(this, itsReplacement);
return true;
}
throw new Exception("TermVariable.mgu: Don't know how to handle term of type " + t.GetType().Name);
}
示例10: Repellent
public override bool Repellent(Term other)
{
return base.Repellent(other) || !_typesOfRelyOn.Contains(other.GetType());
}