コード例 #1
0
ファイル: Duration.cs プロジェクト: zuohd/Composable
 /// <summary>The absolute value of the movement in time between first and second.</summary>
 public static IDuration Between(ITimePoint first, ITimePoint second)
 {
     if (first.IsAfterOrSameInstantAs(second))
     {
         return(FromTimeSpan(first.AsDateTime() - second.AsDateTime()));
     }
     return(FromTimeSpan(second.AsDateTime() - first.AsDateTime()));
 }
コード例 #2
0
            /// <summary>
            /// Removes the given item from the collection
            /// </summary>
            /// <returns>True, if the item was removed, otherwise False</returns>
            /// <param name="item">The item that should be removed</param>
            public override bool Remove(IModelElement item)
            {
                if ((this._parent.ScheduleInterval == item))
                {
                    this._parent.ScheduleInterval = null;
                    return(true);
                }
                ITimePoint timePointItem = item.As <ITimePoint>();

                if (((timePointItem != null) &&
                     this._parent.TimePoints.Remove(timePointItem)))
                {
                    return(true);
                }
                return(false);
            }
コード例 #3
0
            /// <summary>
            /// Adds the given element to the collection
            /// </summary>
            /// <param name="item">The item to add</param>
            public override void Add(IModelElement item)
            {
                if ((this._parent.ScheduleInterval == null))
                {
                    IDateTimeInterval scheduleIntervalCasted = item.As <IDateTimeInterval>();
                    if ((scheduleIntervalCasted != null))
                    {
                        this._parent.ScheduleInterval = scheduleIntervalCasted;
                        return;
                    }
                }
                ITimePoint timePointsCasted = item.As <ITimePoint>();

                if ((timePointsCasted != null))
                {
                    this._parent.TimePoints.Add(timePointsCasted);
                }
            }
コード例 #4
0
 public SimplePlaneTimePoint(IPlanePoint planePosition, ITimePoint timePosition) : base(planePosition)
 {
     _dateTimeValue = timePosition.AsDateTime();
 }
コード例 #5
0
 public ITimePoint ProjectAt(ITimePoint targetTime)
 {
     return(new SimplePlaneTimePoint(PlanePosition, targetTime));
 }
コード例 #6
0
 public SimplePlaneTimePoint(IPlanePoint planePosition, ITimePoint timePosition) : base(planePosition)
 {
     _dateTimeValue = timePosition.AsDateTime();
 }
コード例 #7
0
 /// <summary>Returns the <see cref="ITimePoint"/> resulting from offsetting <paramref name="me"/> by the smallest possible <see cref="ITimeMovement"/> forward in time.</summary>
 public static ITimePoint NextInstant(this ITimePoint me)
 {
     return(me.Offset(Duration.MinValue));
 }
コード例 #8
0
 public SimpleTimeInterval(ITimePoint timeCoordinate, IDuration duration)
 {
     TimePosition = timeCoordinate;
     TimeSpanValue = duration.AsTimeSpan();
 }
コード例 #9
0
 /// <summary>True if <see cref="LastInstantBefore"/> is before <paramref name="point"/> and <see cref="FirstInstantAfter"/> is after <paramref name="point"/></summary>
 public static bool Contains(this ITimeInterval me, ITimePoint point)
 {
     return(me.LastInstantBefore().IsBefore(point) && me.FirstInstantAfter().IsAfter(point));
 }
コード例 #10
0
 private static bool IsSameInstantAs(this ITimePoint me, ITimePoint other)
 {
     return(me.AsDateTime() == other.AsDateTime());
 }
コード例 #11
0
 public ITimePoint ProjectAt(ITimePoint targetTime)
 {
     return(new SimpleTimePoint(targetTime.AsDateTime()));
 }
コード例 #12
0
 /// <summary>True if <paramref name="me"/> is placed after or on the same point as <paramref name="other"/> on the timeline.</summary>
 public static bool IsAfterOrSameInstantAs(this ITimePoint me, ITimePoint other)
 {
     return(!me.IsBefore(other));
 }
コード例 #13
0
 /// <summary>True if <paramref name="me"/> is placed after <paramref name="other"/> on the timeline.</summary>
 public static bool IsAfter(this ITimePoint me, ITimePoint other)
 {
     return(me.AsDateTime() > other.AsDateTime());
 }
コード例 #14
0
 /// <summary>True if <paramref name="me"/> is placed before <paramref name="other"/> on the timeline.</summary>
 public static bool IsBefore(this ITimePoint me, ITimePoint other)
 {
     return(me.AsDateTime() < other.AsDateTime());
 }
コード例 #15
0
 public ITimePoint ProjectAt(ITimePoint targetTime)
 {
     return new SimplePlaneTimePoint(PlanePosition, targetTime);
 }
コード例 #16
0
 public SimpleTimeInterval(ITimePoint timeCoordinate, IDuration duration)
 {
     TimePosition  = timeCoordinate;
     TimeSpanValue = duration.AsTimeSpan();
 }
コード例 #17
0
 /// <summary>True if <see cref="LastInstantBefore"/> is before <paramref name="point"/> and <see cref="FirstInstantAfter"/> is after <paramref name="point"/></summary>
 public static bool Contains(this ITimeInterval me, ITimePoint point)
 {
     return me.LastInstantBefore().IsBefore(point) && me.FirstInstantAfter().IsAfter(point);
 }
コード例 #18
0
 private static SimpleTimeInterval NewTimeInterval(ITimePoint startingPoint, IDuration duration)
 {
     return(new SimpleTimeInterval(startingPoint, duration));
 }
コード例 #19
0
 private static SimpleTimeInterval NewTimeInterval(ITimePoint startingPoint, IDuration duration)
 {
     return new SimpleTimeInterval(startingPoint, duration);
 }
コード例 #20
0
 /// <summary>Returns the <see cref="ITimePoint"/> resulting from offsetting <paramref name="me"/> by the smallest possible <see cref="ITimeMovement"/> backward in time.</summary>
 public static ITimePoint PreviousInstant(this ITimePoint me)
 {
     return(me.Offset(Duration.MinValue.Negate()));
 }