Esempio n. 1
0
 public override void Increment(int newTimeSlot)
 {
     object[] objArray = new object[2];
     objArray[0] = newTimeSlot;
     objArray[1] = 1;
     ExceptionHelpers.ThrowArgumentExceptionIf("newTimeSlot", newTimeSlot != 1, Resources.InvalidArgMessage, objArray);
     base.Increment(newTimeSlot);
 }
Esempio n. 2
0
        public static object ToList(this IEnumerable collection, Type listType)
        {
            ExceptionHelpers.ThrowArgumentExceptionIf("listType", !TypeSystem.ContainsInterface(listType, typeof(IList)), Resources.NotValidListType, new object[0]);
            IList lists = TypeSystem.CreateInstance(listType) as IList;

            foreach (object obj in collection)
            {
                lists.Add(obj);
            }
            return(lists);
        }
Esempio n. 3
0
        public static object ToQueue(this IEnumerable collection, Type queueType)
        {
            ExceptionHelpers.ThrowArgumentExceptionIf("queueType", !TypeSystem.IsQueueType(queueType), Resources.NotValidQueueType, new object[0]);
            object obj = TypeSystem.CreateInstance(queueType);

            foreach (object obj1 in collection)
            {
                object[] objArray = new object[1];
                objArray[0] = obj1;
                TypeSystem.InvokeMethod(obj, "Enqueue", objArray);
            }
            return(obj);
        }
Esempio n. 4
0
        public static object ToDictionary(this IEnumerable collection, Type dictionaryType)
        {
            ExceptionHelpers.ThrowArgumentExceptionIf("dictionaryType", !TypeSystem.ContainsInterface(dictionaryType, typeof(IDictionary)), Resources.NotValidDictionaryType, new object[0]);
            IDictionary dictionaries = TypeSystem.CreateInstance(dictionaryType) as IDictionary;

            foreach (object obj in collection)
            {
                object propertyValue  = TypeSystem.GetPropertyValue(obj, "Key", true);
                object propertyValue1 = TypeSystem.GetPropertyValue(obj, "Value", true);
                dictionaries.Add(propertyValue, propertyValue1);
            }
            return(dictionaries);
        }
Esempio n. 5
0
            public bool InsideWindow(DateTime other)
            {
                ExceptionHelpers.ThrowArgumentExceptionIf("other", other < this.BaseTime, Resources.TimeShouldBeGreater, new object[0]);
                TimeSpan timeSpan = other - this.BaseTime;

                if (timeSpan.TotalSeconds >= (double)this.TimeSlot.Value)
                {
                    return(false);
                }
                else
                {
                    return(true);
                }
            }
Esempio n. 6
0
 public void Set(DateTime newTime, int timeSlot)
 {
     ExceptionHelpers.ThrowArgumentExceptionIf("newTime", newTime < this.BaseTime, Resources.TimeShouldBeGreater, new object[0]);
     if (this.TimeSlot.Value == timeSlot)
     {
         TimeSpan timeSpan = newTime - this.BaseTime;
         int      num      = (int)Math.Floor(timeSpan.TotalSeconds / (double)timeSlot);
         DateTime baseTime = this.BaseTime;
         this.BaseTime = baseTime.AddSeconds((double)(num * timeSlot));
         return;
     }
     else
     {
         this.Reset(newTime, timeSlot);
         return;
     }
 }
Esempio n. 7
0
        public static object ToArray(this IEnumerable collection, Type arrayType)
        {
            ExceptionHelpers.ThrowArgumentExceptionIf("arrayType", !TypeSystem.IsArrayType(arrayType), Resources.NotValidArrayType, new object[0]);
            ArrayList arrayLists = new ArrayList();

            foreach (object obj in collection)
            {
                arrayLists.Add(obj);
            }
            Array arrays = Array.CreateInstance(arrayType.GetElementType(), arrayLists.Count);

            for (int i = 0; i < arrayLists.Count; i++)
            {
                arrays.SetValue(arrayLists[i], i);
            }
            return(arrays);
        }
Esempio n. 8
0
        public static object ToStack(this IEnumerable collection, Type stackType)
        {
            ExceptionHelpers.ThrowArgumentExceptionIf("stackType", !TypeSystem.IsStackType(stackType), Resources.NotValidStackType, new object[0]);
            IEnumerable enumerable = TypeSystem.CreateInstance(stackType) as IEnumerable;

            foreach (object obj in collection)
            {
                object[] objArray = new object[1];
                objArray[0] = obj;
                TypeSystem.InvokeMethod(enumerable, "Push", objArray);
            }
            object obj1 = TypeSystem.CreateInstance(stackType);

            foreach (object obj2 in enumerable)
            {
                object[] objArray1 = new object[1];
                objArray1[0] = obj2;
                TypeSystem.InvokeMethod(obj1, "Push", objArray1);
            }
            return(obj1);
        }