Exemple #1
0
 public SPTime(ITimeSupplier ts)
 {
     if (ts == null)
     {
         throw new System.ArgumentNullException("ts");
     }
     _timeSupplierType = SPTime.GetDeltaType(ts);
     _timeSupplierName = SPTime.GetValidatedId(ts);
 }
Exemple #2
0
 public SPTime(DeltaTimeType etp)
 {
     if (etp == DeltaTimeType.Custom)
     {
         throw new System.ArgumentException("For custom time suppliers, you must specify it directly.");
     }
     _timeSupplierType = etp;
     _timeSupplierName = SPTime.GetTime(etp).Id;
 }
Exemple #3
0
 public bool Destroy()
 {
     if (SPTime.RemoveCustomTime(this))
     {
         _id = null;
         return(true);
     }
     else
     {
         return(false);
     }
 }
 public SPTime(ITimeSupplier ts)
 {
     if (ts == null)
     {
         throw new System.ArgumentNullException("ts");
     }
     _timeSupplierType = SPTime.GetDeltaType(ts);
     if (ts is CustomTimeSupplier)
     {
         _timeSupplierName = (ts as CustomTimeSupplier).Id;
     }
     else
     {
         _timeSupplierName = null;
     }
 }
Exemple #5
0
        /// <summary>
        /// Returns the Id of a time supplier as it is stored in the look up table. If the supplier is not managed, null is returned.
        /// </summary>
        /// <param name="supplier"></param>
        /// <returns></returns>
        public static string GetValidatedId(ITimeSupplier supplier)
        {
            if (supplier == null)
            {
                return(null);
            }

            string        id = supplier.Id;
            ITimeSupplier ts;

            if (supplier is SPTime)
            {
                var dtp = ((SPTime)supplier).TimeSupplierType;
                supplier = SPTime.GetTime(dtp, id);
                if (supplier == null)
                {
                    return(null);
                }
                else if (dtp != DeltaTimeType.Custom)
                {
                    return(supplier.Id);
                }
                else
                {
                    return(id);
                }
            }
            else if (_registeredTimeSuppliers.TryGetValue(id, out ts) && ts == supplier)
            {
                return(id);
            }

            var e = _registeredTimeSuppliers.GetEnumerator();

            while (e.MoveNext())
            {
                if (e.Current.Value == supplier || e.Current.Value.Id == id)
                {
                    return(e.Current.Key);
                }
            }
            return(null);
        }
Exemple #6
0
 public SPTime(DeltaTimeType etp, string timeSupplierName)
 {
     if (etp == DeltaTimeType.Custom)
     {
         if (SPTime.IsStandardTimeSupplier(timeSupplierName))
         {
             var ts = SPTime.GetTime(timeSupplierName);
             _timeSupplierType = GetDeltaType(ts);
             _timeSupplierName = ts.Id;
         }
         else
         {
             _timeSupplierType = DeltaTimeType.Custom;
             _timeSupplierName = timeSupplierName;
         }
     }
     else
     {
         _timeSupplierType = etp;
         _timeSupplierName = SPTime.GetTime(etp).Id;
     }
 }
 public SPTimePeriod(float seconds, ITimeSupplier supplier)
 {
     _seconds          = seconds;
     _timeSupplierType = SPTime.GetDeltaType(supplier);
     _timeSupplierName = SPTime.GetValidatedId(supplier);
 }
 public SPTimePeriod(float seconds, SPTime time)
 {
     _seconds          = seconds;
     _timeSupplierType = time.TimeSupplierType;
     _timeSupplierName = time.TimeSupplierName;
 }