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


C# Term.GetType方法代码示例

本文整理汇总了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());
 }
开发者ID:druzil,项目名称:nggp-base,代码行数:13,代码来源:GdlVisitors.cs

示例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;
        }
开发者ID:Mrding,项目名称:Ribbon,代码行数:36,代码来源:TimeBox.Validation.cs

示例3: NeedRelyOn

 public override bool NeedRelyOn(Term other)
 {
     return _typesOfRelyOn.Contains(other.GetType());
 }
开发者ID:Mrding,项目名称:Ribbon,代码行数:4,代码来源:OvertimeSubEvent.cs

示例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;
 }
开发者ID:Mrding,项目名称:Ribbon,代码行数:7,代码来源:AbstractBoxSwap.cs

示例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);
        }
开发者ID:druzil,项目名称:nggp-base,代码行数:32,代码来源:TermFunction.cs

示例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);
        }
开发者ID:druzil,项目名称:nggp-base,代码行数:14,代码来源:TermObject.cs

示例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));
        }
开发者ID:druzil,项目名称:nggp-base,代码行数:19,代码来源:SentenceFormsFinder.cs

示例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);
        }
开发者ID:Mrding,项目名称:Ribbon,代码行数:56,代码来源:TimeBox.Edit.cs

示例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);
        }
开发者ID:druzil,项目名称:nggp-base,代码行数:85,代码来源:TermVariable.cs

示例10: Repellent

 public override bool Repellent(Term other)
 {
     return base.Repellent(other) || !_typesOfRelyOn.Contains(other.GetType());
 }
开发者ID:Mrding,项目名称:Ribbon,代码行数:4,代码来源:AbsentEvent.cs


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