示例#1
0
        public string Scrub(string code, string[] scrubArray)
        {
            if (code == null)
                return null;

            var finalCode = code;

            if (scrubArray.Length > 1)
            {
                // Set a timeout for the regex so that we know when we have a problem with a specific object and regex
                var timeOut = new System.TimeSpan(0, 0, 30);

                scrubArray[1] = scrubArray[1].Replace("\\n", "\n");

                try
                {
                    finalCode = Regex.Replace(finalCode, string.Format(scrubArray[0], _traceCodeFormatter.StartHighlightMarkUp, _traceCodeFormatter.EndHighlightMarkUp), string.Format(scrubArray[1], _traceCodeFormatter.StartHighlightMarkUp, _traceCodeFormatter.EndHighlightMarkUp), RegexOptions.IgnoreCase, timeOut);
                }
                catch (RegexMatchTimeoutException ex)
                {
                    System.Console.WriteLine("Timeout occurred during regex scrubbing after {0} hr {1} min {2} secs.", timeOut.Hours, timeOut.Minutes, timeOut.Seconds);
                    System.Console.WriteLine("Error:  " + ex.Message);
                    System.Console.WriteLine("scrubArray[0] = " + scrubArray[0]);
                    System.Console.WriteLine("scrubArray[1] = " + scrubArray[1]);
                    System.Console.WriteLine("scrubArray[2] = " + scrubArray[2]);
                    throw;
                }
            }
            return finalCode;
        }
        public object GenerateIdentity()
        {
            System.DateTime baseDate = new System.DateTime(BASE_YEAR, BASE_MONTH, BASE_DAY);
            System.DateTime now = System.DateTime.Now;

            // Get the days and milliseconds which will be used to build the byte array
            System.TimeSpan days = new System.TimeSpan(now.Ticks - baseDate.Ticks);
            System.TimeSpan msecs = new System.TimeSpan(now.Ticks - (new System.DateTime(now.Year, now.Month, now.Day).Ticks));

            // Convert TimeSpans to a byte array
            byte[] daysArray = System.BitConverter.GetBytes(days.Days);
            byte[] msecsArray = System.BitConverter.GetBytes((long)(msecs.TotalMilliseconds / LIMITING_DIVISOR));

            // Reverse the bytes to match big-endian ordering
            // Used by certain DB engines (i.e. MS-SQL) for indexing
            System.Array.Reverse(daysArray);
            System.Array.Reverse(msecsArray);

            // Generate a real guid for the unique portion of sequential guid and put it in a byte array
            byte[] guidArray = System.Guid.NewGuid().ToByteArray();

            // Copy the bytes into the guid to make the sequential guid
            System.Array.Copy(daysArray, daysArray.Length - 2, guidArray, guidArray.Length - 6, 2);
            System.Array.Copy(msecsArray, msecsArray.Length - 4, guidArray, guidArray.Length - 4, 4);

            return new System.Guid(guidArray);
        }
示例#3
0
 public DateHeader(string name, System.DateTime dateTime, System.TimeSpan timeZoneOffset)
     : base(name, Header.GetHeaderId(name, true))
 {
     var type = Header.TypeFromHeaderId(this.HeaderId);
     if (this.HeaderId != HeaderId.Unknown && type != typeof (DateHeader))
         throw new System.ArgumentException(Resources.Strings.NameNotValidForThisHeaderType(name, "DateHeader", type.Name));
     this.SetRawValue(null, true);
     parsed = true;
     utcDateTime = dateTime.ToUniversalTime();
     this.timeZoneOffset = timeZoneOffset;
 }
		public void TestAverageNonZero()
		{
			var t1 = System.TimeSpan.FromHours(3);
			var t2 = System.TimeSpan.FromHours(1);
			var t3 = System.TimeSpan.FromMinutes(30);

			var total = System.TimeSpan.Zero;
			total += t1;
			total += t2;
			total += t3;

			var average = total.Average(3);

			var expectedResult = new System.TimeSpan(0, 1, 30, 0);

			Assert.AreEqual(expectedResult, average);
		}
示例#5
0
        protected override void Update(System.TimeSpan gameTime)
        {
            _totalTime += gameTime;
            if (_parent.Matched)
            {
                float decrease = 0.0015f;
                Transform.XScale -= decrease;
                Transform.YScale -= decrease;
                if (Transform.XScale <= 0 || Transform.YScale <= 0)
                {
                    _parent.Gone = true;
                    EntityManager.Remove(_parent);
                }
            }
            else if (_parent.Selected) {
                Transform.DrawOrder = 0;
                if (_growing)
                {
                    float increase = (_maxScale.X - _originalScale.X) * (float)_totalTime.TotalSeconds;

                    Transform.XScale = _originalScale.X + increase;
                    Transform.YScale = _originalScale.Y + increase;
                }
                else
                {
                    float decrease = (_maxScale.X - _originalScale.X) * (1 - (float)_totalTime.TotalSeconds);

                    Transform.XScale = _originalScale.X + decrease;
                    Transform.YScale = _originalScale.Y + decrease;
                }
                if (_totalTime > System.TimeSpan.FromSeconds(0.4))
                {

                    _growing = !_growing;
                    _totalTime = System.TimeSpan.FromSeconds(0);
                };
            }
            else
            {
                Transform.DrawOrder = 1;
                Transform.Scale = _originalScale;
            }
        }
示例#6
0
        public static string Start(System.Action action, int repeat, bool showTicksInfo = false)
        {
            var stopWatch = new System.Diagnostics.Stopwatch();
            stopWatch.Start();
            for (int i = 0; i < repeat; i++)
            {
                action();
            }
            stopWatch.Stop();
            System.TimeSpan total = stopWatch.Elapsed;
            System.TimeSpan average = new System.TimeSpan(stopWatch.Elapsed.Ticks / repeat);

            System.Text.StringBuilder perfResultsBuilder = new System.Text.StringBuilder();
            perfResultsBuilder.AppendLine("--------------------------------------------------------------");
            perfResultsBuilder.AppendFormat("  Total Time => {0}\r\nAverage Time => {1}", Align(total), Align(average));
            perfResultsBuilder.AppendLine();
            perfResultsBuilder.AppendLine("--------------------------------------------------------------");
            if (showTicksInfo)
                perfResultsBuilder.AppendLine(TicksInfo());
            return perfResultsBuilder.ToString();
        }
示例#7
0
        void CleanOldLog()
        {
            var dir = GetLogDirectory();
            var files = System.IO.Directory.GetFiles(dir, "*.log", System.IO.SearchOption.AllDirectories);
            var now = System.DateTime.Now;
            var expirationTime = new System.TimeSpan(24 * 3, 0, 0);
            
            foreach (var file in files)
            {
                var fileInfo = new System.IO.FileInfo(file);
                var subTime = now - fileInfo.LastWriteTime;
                if (subTime < expirationTime)
                    continue;

                try
                {
                    System.IO.File.Delete(file);
                }
                catch
                {
                }
            }
        }
示例#8
0
 // Summary:
 //     Adds a specified time interval to a DeltaSpace.DateTimeOffset object.
 //
 // Parameters:
 //   timeSpan:
 //     A System.TimeSpan object that represents a positive or a negative time interval.
 //
 // Returns:
 //     An object whose value is the sum of the date and time represented by the
 //     current DeltaSpace.DateTimeOffset object and the time interval represented by
 //     timeSpan.
 //
 // Exceptions:
 //   System.ArgumentOutOfRangeException:
 //     The resulting DeltaSpace.DateTimeOffset value is less than DeltaSpace.DateTimeOffset.MinValue.-or-
 //     The resulting DeltaSpace.DateTimeOffset value is greater than DeltaSpace.DateTimeOffset.MaxValue.
 public DateTimeOffset Add(TimeSpan timeSpan)
 {
     return new DateTimeOffset(this.value.Add(timeSpan));
 }
示例#9
0
        //public static bool operator == (MouseInfo left, MouseInfo right)
        //{
        //    return left.Console == right.Console && left.X == right.X && left.Y == right.Y;
        //}

        //public static bool operator !=(MouseInfo left, MouseInfo right)
        //{
        //    return left.Console != right.Console || left.X != right.X || left.Y != right.Y;
        //}

        /// <summary>
        /// Fills out the state of the mouse.
        /// </summary>
        /// <param name="gameTime"></param>
        public void ProcessMouse(Microsoft.Xna.Framework.GameTime gameTime)
        {
            Microsoft.Xna.Framework.Input.MouseState currentState = Microsoft.Xna.Framework.Input.Mouse.GetState();

            bool leftDown = currentState.LeftButton == Microsoft.Xna.Framework.Input.ButtonState.Pressed;
            bool rightDown = currentState.RightButton == Microsoft.Xna.Framework.Input.ButtonState.Pressed;

            bool newLeftClicked = LeftButtonDown && !leftDown;
            bool newRightClicked = RightButtonDown && !rightDown;

            if (!newLeftClicked)
                LeftDoubleClicked = false;
            if (!newRightClicked)
                RightDoubleClicked = false;

            if (LeftClicked && newLeftClicked && gameTime.ElapsedGameTime.TotalMilliseconds < 1000)
                LeftDoubleClicked = true;
            if (RightClicked && newRightClicked && gameTime.ElapsedGameTime.TotalMilliseconds < 1000)
                RightDoubleClicked = true;

            LeftClicked = newLeftClicked;
            RightClicked = newRightClicked;
            _leftLastClickedTime = gameTime.ElapsedGameTime;
            _rightLastClickedTime = gameTime.ElapsedGameTime;
            LeftButtonDown = leftDown;
            RightButtonDown = rightDown;

            ScrollWheelValueChange = ScrollWheelValue - currentState.ScrollWheelValue;
            ScrollWheelValue = currentState.ScrollWheelValue;

            ScreenLocation = new Point(currentState.X, currentState.Y);
        }
示例#10
0
        public override void Run()
        {
            if (!problemIsOn) return;

            else System.Diagnostics.Debug.WriteLine("----------------------------- " + this.problemName + " -----------------------------");

            // Map the set of clauses from parser to one set of intrinsic clauses.
            ConstructIntrinsicSet();

            // Create the analyzer
            StatisticsGenerator.HardCodedFigureAnalyzerMain analyzer = new StatisticsGenerator.HardCodedFigureAnalyzerMain(intrinsic, given, goals);

            // Perform and time the analysis
            figureStats = analyzer.AnalyzeFigure();

            //
            // If we know it's complete, keep that overridden completeness.
            // Otherwise, determine completeness through analysis of the nodes in the hypergraph.
            //
            if (!this.isComplete) this.isComplete = figureStats.isComplete;

            System.Diagnostics.Debug.WriteLine("Resultant Complete: " + this.isComplete +"\n");

            // Calculate the final numbers: counts of the k-G Strictly interesting problems.
            System.Text.StringBuilder str = new System.Text.StringBuilder();
            for (int k = 1; k <= StatisticsGenerator.FigureStatisticsAggregator.MAX_K; k++)
            {
                str.Append(figureStats.kGcardinalities[k] + "\t");
            }

            if (this.isComplete)
            {
                //using (System.IO.StreamWriter file = new System.IO.StreamWriter(@"C:\Users\ctalvin\Desktop\output\complete.txt", true))
                //{
                //    file.WriteLine(str);
                //}
                //using (System.IO.StreamWriter file = new System.IO.StreamWriter(@"C:\Users\ctalvin\Desktop\output\completeTime.txt", true))
                //{
                //    file.WriteLine(figureStats.stopwatch.Elapsed);
                //}
            }
            else
            {
                //using (System.IO.StreamWriter file = new System.IO.StreamWriter(@"C:\Users\ctalvin\Desktop\output\interesting.txt", true))
                //{
                //    file.WriteLine(str);
                //}
                //using (System.IO.StreamWriter file = new System.IO.StreamWriter(@"C:\Users\ctalvin\Desktop\output\interestingTime.txt", true))
                //{
                //    file.WriteLine(figureStats.stopwatch.Elapsed);
                //}
            }

            // Add to the cumulative statistics
            ActualProofProblem.TotalTime = ActualProofProblem.TotalTime.Add(figureStats.stopwatch.Elapsed);

            ActualProofProblem.TotalPoints += figureStats.numPoints;
            ActualProofProblem.TotalSegments += figureStats.numPoints;
            ActualProofProblem.TotalInMiddle += figureStats.numInMiddle;
            ActualProofProblem.TotalAngles += figureStats.numAngles;
            ActualProofProblem.TotalTriangles += figureStats.numTriangles;
            ActualProofProblem.TotalIntersections += figureStats.numIntersections;
            ActualProofProblem.TotalTotalProperties += figureStats.totalProperties;

            ActualProofProblem.TotalExplicitFacts += figureStats.totalExplicitFacts;

            ActualProofProblem.TotalGoals += goals.Count;
            ActualProofProblem.TotalProblemsGenerated += figureStats.totalProblemsGenerated;
            ActualProofProblem.TotalBackwardProblemsGenerated += figureStats.totalBackwardProblemsGenerated;

            // Query: Interesting Partitioning
            int numProblemsInPartition;
            List<int> upperBounds = GeometryTutorLib.ProblemAnalyzer.QueryFeatureVector.ConstructInterestingPartitionBounds();
            for (int i = 0; i < upperBounds.Count; i++)
            {
                ActualProofProblem.totalInteresting[i] += figureStats.interestingPartitionSummary.TryGetValue(upperBounds[i], out numProblemsInPartition) ? numProblemsInPartition : 0;
            }
            ActualProofProblem.totalInteresting[upperBounds.Count] += figureStats.interestingPartitionSummary.TryGetValue(int.MaxValue, out numProblemsInPartition) ? numProblemsInPartition : 0;

            upperBounds = GeometryTutorLib.ProblemAnalyzer.QueryFeatureVector.ConstructInterestingPartitionBounds();
            for (int i = 0; i < upperBounds.Count; i++)
            {
                ActualProofProblem.totalStrictInteresting[i] += figureStats.strictInterestingPartitionSummary.TryGetValue(upperBounds[i], out numProblemsInPartition) ? numProblemsInPartition : 0;
            }
            ActualProofProblem.totalStrictInteresting[upperBounds.Count] += figureStats.strictInterestingPartitionSummary.TryGetValue(int.MaxValue, out numProblemsInPartition) ? numProblemsInPartition : 0;

            // Rest of Cumulative Stats
            ActualProofProblem.TotalStrictInterestingProblems += figureStats.totalStrictInterestingProblems;
            ActualProofProblem.TotalInterestingProblems += figureStats.totalInterestingProblems;
            ActualProofProblem.TotalOriginalBookProblems += goals.Count;

            // Averages
            ActualProofProblem.TotalDeducedSteps += figureStats.averageProblemDeductiveSteps * figureStats.totalInterestingProblems;
            ActualProofProblem.TotalProblemLength += figureStats.averageProblemLength * figureStats.totalInterestingProblems;
            ActualProofProblem.TotalProblemWidth += figureStats.averageProblemWidth * figureStats.totalInterestingProblems;
            ActualProofProblem.TotalStrictDeducedSteps += figureStats.totalStrictInterestingProblems == 0 ? 0 : figureStats.strictAverageProblemDeductiveSteps * figureStats.totalStrictInterestingProblems;
            ActualProofProblem.TotalStrictProblemLength += figureStats.totalStrictInterestingProblems == 0 ? 0 : figureStats.strictAverageProblemLength * figureStats.totalStrictInterestingProblems;
            ActualProofProblem.TotalStrictProblemWidth += figureStats.totalStrictInterestingProblems == 0 ? 0 : figureStats.strictAverageProblemWidth * figureStats.totalStrictInterestingProblems;

            // Queries
            ActualProofProblem.TotalGoalPartitions += figureStats.goalPartitionSummary.Count;
            ActualProofProblem.TotalSourcePartitions += figureStats.sourcePartitionSummary.Count;

            // Query: Difficulty Partitioning
            upperBounds = GeometryTutorLib.ProblemAnalyzer.QueryFeatureVector.ConstructDifficultyPartitionBounds();
            for (int i = 0; i < upperBounds.Count; i++)
            {
                ActualProofProblem.totalDifficulty[i] += figureStats.difficultyPartitionSummary.TryGetValue(upperBounds[i], out numProblemsInPartition) ? numProblemsInPartition : 0;
            }
            ActualProofProblem.totalDifficulty[upperBounds.Count] += figureStats.difficultyPartitionSummary.TryGetValue(int.MaxValue, out numProblemsInPartition) ? numProblemsInPartition : 0;

            upperBounds = GeometryTutorLib.ProblemAnalyzer.QueryFeatureVector.ConstructDifficultyPartitionBounds();
            for (int i = 0; i < upperBounds.Count; i++)
            {
                ActualProofProblem.totalStrictDifficulty[i] += figureStats.strictDifficultyPartitionSummary.TryGetValue(upperBounds[i], out numProblemsInPartition) ? numProblemsInPartition : 0;
            }
            ActualProofProblem.totalStrictDifficulty[upperBounds.Count] += figureStats.strictDifficultyPartitionSummary.TryGetValue(int.MaxValue, out numProblemsInPartition) ? numProblemsInPartition : 0;
        }
示例#11
0
 protected internal virtual bool TryCommand(System.Runtime.DurableInstancing.InstancePersistenceContext context, System.Runtime.DurableInstancing.InstancePersistenceCommand command, System.TimeSpan timeout)
 {
     throw null;
 }
            /// <summary>
            /// Retrieves the absolute duration, in whole number of days,
            /// of the given <see cref="System.TimeSpan"/> value as
            /// the number of milliseconds since
            /// <c>January 1, 1970, 00:00:00 GMT</c>.
            /// </summary>
            /// <param name="timeSpanValue">
            /// To convert to an <c>Int64</c> date in milliseconds value.
            /// </param>
            /// <returns>
            /// The corresponding <c>Int64</c> value.
            /// </returns>
            public static long ToDateInMillis(TimeSpan timeSpanValue)
            {
                timeSpanValue = timeSpanValue.Duration();

                JavaGregorianCalendar cal = HsqlConvert.GetJavaGregorianCalendar();

                cal.clear();
                cal.add(JavaCalendar.DAY_OF_YEAR, timeSpanValue.Days);

                return cal.getTimeInMillis();
            }
            /// <summary>
            /// Retrieves the number of milliseconds since 
            /// <c>January 1, 1970, 00:00:00 GMT</c> represented
            /// by the <c>Hours</c>, <c>Minutes</c> and <c>Seconds</c>
            /// portions of the given <see cref="TimeSpan"/>,
            /// interpreted as an absolute duration.
            /// </summary>
            /// <param name="value">
            /// For which to retrieve the <c>Int64</c> value.
            /// </param>
            /// <returns>
            /// The corresponding value.
            /// </returns>
            public static long ToTimeInMillis(TimeSpan value)
            {
                value = value.Duration();

                JavaCalendar cal = HsqlConvert.GetJavaGregorianCalendar();

                cal.clear();
                cal.set(JavaCalendar.HOUR_OF_DAY, value.Hours);
                cal.set(JavaCalendar.MINUTE, value.Minutes);
                cal.set(JavaCalendar.SECOND, value.Seconds);

                return cal.getTimeInMillis();
            }
示例#14
0
 public static bool Wait(object obj, System.TimeSpan timeout)
 {
     throw null;
 }
示例#15
0
 public static bool Wait(object obj, System.TimeSpan timeout, bool exitContext)
 {
     throw null;
 }
示例#16
0
 public static bool TryEnter(object obj, System.TimeSpan timeout)
 {
     throw null;
 }
示例#17
0
 public static void TryEnter(object obj, System.TimeSpan timeout, ref bool lockTaken)
 {
 }
示例#18
0
 public bool Wait(System.TimeSpan timeout)
 {
     throw null;
 }
示例#19
0
 public static bool SpinUntil(System.Func <bool> condition, System.TimeSpan timeout)
 {
     throw null;
 }
示例#20
0
 public void TryEnter(System.TimeSpan timeout, ref bool lockTaken)
 {
 }
示例#21
0
 //
 // Summary:
 //     Subtracts a specified time interval from the current DeltaSpace.DateTimeOffset
 //     object.
 //
 // Parameters:
 //   value:
 //     The time interval to subtract.
 //
 // Returns:
 //     An object that is equal to the date and time represented by the current DeltaSpace.DateTimeOffset
 //     object, minus the time interval represented by value.
 //
 // Exceptions:
 //   System.ArgumentOutOfRangeException:
 //     The resulting DeltaSpace.DateTimeOffset value is less than DeltaSpace.DateTimeOffset.MinValue.-or-
 //     The resulting DeltaSpace.DateTimeOffset value is greater than DeltaSpace.DateTimeOffset.MaxValue.
 public DateTimeOffset Subtract(TimeSpan value)
 {
     return new DateTimeOffset(this.value.Subtract(value));
 }
示例#22
0
 public void AcquireReaderLock(System.TimeSpan timeout)
 {
 }
示例#23
0
 //
 // Summary:
 //     Initializes a new instance of the DeltaSpace.DateTimeOffset structure using the
 //     specified year, month, day, hour, minute, second, millisecond, and offset
 //     of a specified calendar.
 //
 // Parameters:
 //   year:
 //     The year.
 //
 //   month:
 //     The month (1 through 12).
 //
 //   day:
 //     The day (1 through the number of days in month).
 //
 //   hour:
 //     The hours (0 through 23).
 //
 //   minute:
 //     The minutes (0 through 59).
 //
 //   second:
 //     The seconds (0 through 59).
 //
 //   millisecond:
 //     The milliseconds (0 through 999).
 //
 //   calendar:
 //     The calendar that is used to interpret year, month, and day.
 //
 //   offset:
 //     The time's offset from Coordinated Universal Time (UTC).
 //
 // Exceptions:
 //   System.ArgumentException:
 //     offset does not represent whole minutes.
 //
 //   System.ArgumentNullException:
 //     calendar cannot be null.
 //
 //   System.ArgumentOutOfRangeException:
 //     year is less than the calendar parameter's MinSupportedDateTime.Year or greater
 //     than MaxSupportedDateTime.Year.-or-month is either less than or greater than
 //     the number of months in year in the calendar. -or-day is less than one or
 //     greater than the number of days in month.-or-hour is less than zero or greater
 //     than 23.-or-minute is less than 0 or greater than 59.-or-second is less than
 //     0 or greater than 59.-or-millisecond is less than 0 or greater than 999.-or-offset
 //     is less than -14 hours or greater than 14 hours.-or-The year, month, and
 //     day parameters cannot be represented as a date and time value.-or-The DeltaSpace.DateTimeOffset.UtcDateTime
 //     property is earlier than DeltaSpace.DateTimeOffset.MinValue or later than DeltaSpace.DateTimeOffset.MaxValue.
 public DateTimeOffset(
                                         int         year, 
                                         int         month, 
                                         int         day, 
                                         int         hour, 
                                         int         minute, 
                                         int         second, 
                                         int         millisecond, 
                                         Calendar    calendar, 
                                         TimeSpan    offset
                                     )
 {
     this.value = new SystemDateTimeOffset(year, month, day, hour, minute, second, millisecond, calendar, offset);
 }
示例#24
0
 public void AcquireWriterLock(System.TimeSpan timeout)
 {
 }
            /// <summary>
            /// Converts the <c>TotalMilliseconds</c> property of the
            /// given <see cref="System.TimeSpan"/> to an SQL
            /// date-time character sequence representing
            /// the number of milliseconds since
            /// <c>January 1, 1970, 00:00:00 GMT</c>.
            /// </summary>
            /// <param name="timeSpanValue">
            /// To convert to an SQL date-time character sequence.
            /// </param>
            /// <returns>
            /// The corresponding SQL date-time character sequence.
            /// </returns>
            public static string ToString(TimeSpan timeSpanValue)
            {
                JavaGregorianCalendar cal = HsqlConvert.GetJavaGregorianCalendar();

                double totalMillis = timeSpanValue.TotalMilliseconds;

                if (totalMillis < long.MinValue || totalMillis > long.MaxValue)
                {
                    throw HsqlConvert.NumericValueOutOfRange(totalMillis);
                }

                cal.setTimeInMillis(JavaMath.round(totalMillis));

                int year = cal.get(JavaCalendar.YEAR);
                int month = cal.get(JavaCalendar.MONTH) + 1;
                int day = cal.get(JavaCalendar.DAY_OF_MONTH);
                int hour = cal.get(JavaCalendar.HOUR_OF_DAY);
                int minute = cal.get(JavaCalendar.MINUTE);
                int second = cal.get(JavaCalendar.SECOND);
                int nanosecond = 1000 * cal.get(JavaCalendar.MILLISECOND);

                return ToDateTimeString(
                    year,
                    month,
                    day,
                    hour,
                    minute,
                    second,
                    nanosecond,
                    false);
            }
示例#26
0
 public System.Threading.LockCookie UpgradeToWriterLock(System.TimeSpan timeout)
 {
     throw null;
 }
            /// <summary>
            /// Converts the absolute duration represented by
            /// the given <see cref="System.TimeSpan"/>
            /// value to an <see cref="System.Int64"/> value
            /// representing the number of milliseconds since
            /// <c>January 1, 1970 00:00:00 GMT</c>.
            /// </summary>
            /// <param name="timeSpanValue">
            /// For which to retrieve the <c>Int64</c> value.
            /// </param>
            /// <returns>
            /// The corresponding value.
            /// </returns>
            public static long ToTimestampInMillis(TimeSpan timeSpanValue)
            {
                timeSpanValue = timeSpanValue.Duration();

                JavaGregorianCalendar cal = HsqlConvert.GetJavaGregorianCalendar();

                cal.clear();
                cal.add(JavaCalendar.DAY_OF_YEAR, timeSpanValue.Days);
                cal.add(JavaCalendar.HOUR_OF_DAY, timeSpanValue.Hours);
                cal.add(JavaCalendar.MINUTE, timeSpanValue.Minutes);
                cal.add(JavaCalendar.SECOND, timeSpanValue.Seconds);
                cal.add(JavaCalendar.MILLISECOND, timeSpanValue.Milliseconds);

                return cal.getTimeInMillis();
            }
示例#28
0
 public bool TryEnterUpgradeableReadLock(System.TimeSpan timeout)
 {
     throw null;
 }
示例#29
0
 public System.Collections.Generic.List <System.Runtime.DurableInstancing.InstancePersistenceEvent> WaitForEvents(System.Runtime.DurableInstancing.InstanceHandle handle, System.TimeSpan timeout)
 {
     throw null;
 }
示例#30
0
 public bool TryEnterWriteLock(System.TimeSpan timeout)
 {
     throw null;
 }
示例#31
0
 public System.Threading.Tasks.Task <bool> WaitAsync(System.TimeSpan timeout, System.Threading.CancellationToken cancellationToken)
 {
     throw null;
 }
 public static System.Threading.RegisteredWaitHandle RegisterWaitForSingleObject(System.Threading.WaitHandle waitObject, System.Threading.WaitOrTimerCallback callBack, object state, System.TimeSpan timeout, bool executeOnlyOnce)
 {
     throw null;
 }
 public TimeSpan(System.TimeSpan t)
 {
     if (t != null)
         timespan = t;
     else
         timespan = new System.TimeSpan();
 }
示例#34
0
        /// <summary>
        /// Put a positive duration value
        /// </summary>
        /// <param name='durationBody'>
        /// </param>
        /// <param name='customHeaders'>
        /// Headers that will be added to request.
        /// </param>
        /// <param name='cancellationToken'>
        /// The cancellation token.
        /// </param>
        /// <exception cref="ErrorException">
        /// Thrown when the operation returned an invalid status code
        /// </exception>
        /// <return>
        /// A response object containing the response body and response headers.
        /// </return>
        public async Task <AzureOperationResponse> PutPositiveDurationWithHttpMessagesAsync(System.TimeSpan durationBody, Dictionary <string, List <string> > customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
        {
            // Tracing
            bool   _shouldTrace  = ServiceClientTracing.IsEnabled;
            string _invocationId = null;

            if (_shouldTrace)
            {
                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
                Dictionary <string, object> tracingParameters = new Dictionary <string, object>();
                tracingParameters.Add("durationBody", durationBody);
                tracingParameters.Add("cancellationToken", cancellationToken);
                ServiceClientTracing.Enter(_invocationId, this, "PutPositiveDuration", tracingParameters);
            }
            // Construct URL
            var           _baseUrl         = Client.BaseUri.AbsoluteUri;
            var           _url             = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "duration/positiveduration").ToString();
            List <string> _queryParameters = new List <string>();

            if (_queryParameters.Count > 0)
            {
                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
            }
            // Create HTTP transport objects
            var _httpRequest = new HttpRequestMessage();
            HttpResponseMessage _httpResponse = null;

            _httpRequest.Method     = new HttpMethod("PUT");
            _httpRequest.RequestUri = new System.Uri(_url);
            // Set Headers
            if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
            {
                _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString());
            }
            if (Client.AcceptLanguage != null)
            {
                if (_httpRequest.Headers.Contains("accept-language"))
                {
                    _httpRequest.Headers.Remove("accept-language");
                }
                _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
            }


            if (customHeaders != null)
            {
                foreach (var _header in customHeaders)
                {
                    if (_httpRequest.Headers.Contains(_header.Key))
                    {
                        _httpRequest.Headers.Remove(_header.Key);
                    }
                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
                }
            }

            // Serialize Request
            string _requestContent = null;

            _requestContent      = Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(durationBody, Client.SerializationSettings);
            _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
            _httpRequest.Content.Headers.ContentType = System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8");
            // Set Credentials
            if (Client.Credentials != null)
            {
                cancellationToken.ThrowIfCancellationRequested();
                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
            }
            // Send Request
            if (_shouldTrace)
            {
                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
            }
            cancellationToken.ThrowIfCancellationRequested();
            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);

            if (_shouldTrace)
            {
                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
            }
            HttpStatusCode _statusCode = _httpResponse.StatusCode;

            cancellationToken.ThrowIfCancellationRequested();
            string _responseContent = null;

            if ((int)_statusCode != 200)
            {
                var ex = new ErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
                try
                {
                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);

                    Error _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject <Error>(_responseContent, Client.DeserializationSettings);
                    if (_errorBody != null)
                    {
                        ex.Body = _errorBody;
                    }
                }
                catch (JsonException)
                {
                    // Ignore the exception
                }
                ex.Request  = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
                if (_shouldTrace)
                {
                    ServiceClientTracing.Error(_invocationId, ex);
                }
                _httpRequest.Dispose();
                if (_httpResponse != null)
                {
                    _httpResponse.Dispose();
                }
                throw ex;
            }
            // Create Result
            var _result = new AzureOperationResponse();

            _result.Request  = _httpRequest;
            _result.Response = _httpResponse;
            if (_httpResponse.Headers.Contains("x-ms-request-id"))
            {
                _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
            }
            if (_shouldTrace)
            {
                ServiceClientTracing.Exit(_invocationId, _result);
            }
            return(_result);
        }
示例#35
0
 //
 // Summary:
 //     Initializes a new instance of the DeltaSpace.DateTimeOffset structure using the
 //     specified System.DateTime value and offset.
 //
 // Parameters:
 //   dateTime:
 //     A date and time.
 //
 //   offset:
 //     The time's offset from Coordinated Universal Time (UTC).
 //
 // Exceptions:
 //   System.ArgumentException:
 //     dateTime.Kind equals System.DateTimeKind.Utc and offset does not equal zero.-or-dateTime.Kind
 //     equals System.DateTimeKind.Local and offset does not equal the offset of
 //     the system's local time zone.-or-offset is not specified in whole minutes.
 //
 //   System.ArgumentOutOfRangeException:
 //     offset is less than -14 hours or greater than 14 hours.-or-DeltaSpace.DateTimeOffset.UtcDateTime
 //     is less than DeltaSpace.DateTimeOffset.MinValue or greater than DeltaSpace.DateTimeOffset.MaxValue.
 public DateTimeOffset(
                                         DateTime    dateTime,
                                         TimeSpan    offset
                                     )
 {
     this.value = new SystemDateTimeOffset(dateTime, offset);
 }
示例#36
0
 public static bool TryFormat(System.TimeSpan value, System.Span <byte> buffer, out int bytesWritten, System.Buffers.StandardFormat format = default(System.Buffers.StandardFormat))
 {
     throw null;
 }
示例#37
0
 //
 // Summary:
 //     Initializes a new instance of the DeltaSpace.DateTimeOffset structure using the
 //     specified number of ticks and offset.
 //
 // Parameters:
 //   ticks:
 //     A date and time expressed as the number of 100-nanosecond intervals that
 //     have elapsed since 12:00:00 midnight on January 1, 0001.
 //
 //   offset:
 //     The time's offset from Coordinated Universal Time (UTC).
 //
 // Exceptions:
 //   System.ArgumentException:
 //     offset is not specified in whole minutes.
 //
 //   System.ArgumentOutOfRangeException:
 //     The DeltaSpace.DateTimeOffset.UtcDateTime property is earlier than DeltaSpace.DateTimeOffset.MinValue
 //     or later than DeltaSpace.DateTimeOffset.MaxValue.-or-ticks is less than DateTimeOffset.MinValue.Ticks
 //     or greater than DateTimeOffset.MaxValue.Ticks.-or-Offset s less than -14
 //     hours or greater than 14 hours.
 public DateTimeOffset(
                                         long        ticks,
                                         TimeSpan    offset
                                     )
 {
     this.value = new SystemDateTimeOffset(ticks, offset);
 }
示例#38
0
 public static bool TryParse(System.ReadOnlySpan <byte> text, out System.TimeSpan value, out int bytesConsumed, char standardFormat = '\0')
 {
     throw null;
 }
示例#39
0
 //
 // Summary:
 //     Converts the value of the current DeltaSpace.DateTimeOffset object to the date
 //     and time specified by an offset value.
 //
 // Parameters:
 //   offset:
 //     The offset to convert the DeltaSpace.DateTimeOffset value to.
 //
 // Returns:
 //     An object that is equal to the original DeltaSpace.DateTimeOffset object (that
 //     is, their DeltaSpace.DateTimeOffset.ToUniversalTime() methods return identical
 //     points in time) but whose DeltaSpace.DateTimeOffset.Offset property is set to
 //     offset.
 //
 // Exceptions:
 //   System.ArgumentException:
 //     The resulting DeltaSpace.DateTimeOffset object has a DeltaSpace.DateTimeOffset.DateTime
 //     value earlier than DeltaSpace.DateTimeOffset.MinValue.-or-The resulting DeltaSpace.DateTimeOffset
 //     object has a DeltaSpace.DateTimeOffset.DateTime value later than DeltaSpace.DateTimeOffset.MaxValue.
 //
 //   System.ArgumentOutOfRangeException:
 //     offset is less than -14 hours.-or-offset is greater than 14 hours.
 public DateTimeOffset ToOffset(TimeSpan offset)
 {
     return new DateTimeOffset(this.value.ToOffset(offset));
 }
 public CancellationTokenSource(System.TimeSpan delay)
 {
 }
            public static java.sql.Date ToDate(TimeSpan timeSpanValue)
            {
                long millis = FromDotNet.ToDateInMillis(timeSpanValue);

                return new java.sql.Date(millis);
            }
 public void CancelAfter(System.TimeSpan delay)
 {
 }
 public static SqlObject ToOther(TimeSpan timeSpanValue)
 {
     return new SqlObject(ToTimestamp(timeSpanValue));
 }
示例#44
0
 public DateTimeRange(System.DateTimeOffset startTime, System.TimeSpan duration)
 {
     throw null;
 }
            public static JavaTime ToTime(TimeSpan value)
            {
                long millis = ToTimeInMillis(value);

                return new JavaTime(millis);
            }
示例#46
0
 public DateTimeRange(System.TimeSpan duration)
 {
     throw null;
 }
            public static JavaTimestamp ToTimestamp(TimeSpan timeSpanValue)
            {
                long millis = ToTimestampInMillis(timeSpanValue);

                return new JavaTimestamp(millis);
            }
示例#48
0
 internal void SetValue(System.DateTime value, System.TimeSpan timeZoneOffset)
 {
     this.SetRawValue(null, true);
     parsed = true;
     utcDateTime = value.ToUniversalTime();
     this.timeZoneOffset = timeZoneOffset;
 }
示例#49
0
文件: Game.cs 项目: Dani88/Zombies
        private void StartLoop()
        {
            var clock = new GameTime();

            RenderLoop.Run(RenderForm, () =>
            {
                Draw(clock);
                Update(clock);

                clock.EllapsedGameTime = clock.TotalGameTime - lastGameTimeUpdated;
                lastGameTimeUpdated = clock.TotalGameTime;
            });
        }
示例#50
0
 /// <summary>
 /// Initializes a new instance of the AggregateSeries class.
 /// </summary>
 /// <param name="timeSeriesId">A single Time Series ID value that
 /// uniquely identifies a single time series instance (e.g. a device).
 /// Note that a single Time Series ID can be composite if multiple
 /// properties are specified as Time Series ID at environment creation
 /// time. The position and type of values must match Time Series ID
 /// properties specified on the environment and returned by Get Model
 /// Setting API. Cannot be null.</param>
 /// <param name="searchSpan">The range of time on which the query is
 /// executed. Cannot be null.</param>
 /// <param name="interval">Interval size is specified in ISO-8601
 /// duration format. All intervals are the same size. One month is
 /// always converted to 30 days, and one year is always 365 days.
 /// Examples: 1 minute is "PT1M", 1 millisecond is "PT0.001S". For more
 /// information, see
 /// https://www.w3.org/TR/xmlschema-2/#duration</param>
 /// <param name="filter">Top-level filter over the events that
 /// restricts the number of events being considered for computation.
 /// This filter is AND'ed with filter in each variable. Example:
 /// "$event.Status.String='Good'". Optional.</param>
 /// <param name="projectedVariables">This allows the user to optionally
 /// select the variables that needs to be projected. When it is null or
 /// not set, all the variables from inlineVariables and model are
 /// returned. Can be null.</param>
 /// <param name="inlineVariables">This allows the user the optionally
 /// define inline-variables apart from the ones already defined in the
 /// model. When the inline variable names have the same name as the
 /// model, the inline variable definition takes precedence. Can be
 /// null.</param>
 public AggregateSeries(IList <object> timeSeriesId, DateTimeRange searchSpan, System.TimeSpan interval, Tsx filter = default(Tsx), IList <string> projectedVariables = default(IList <string>), IDictionary <string, Variable> inlineVariables = default(IDictionary <string, Variable>))
 {
     TimeSeriesId       = timeSeriesId;
     SearchSpan         = searchSpan;
     Filter             = filter;
     Interval           = interval;
     ProjectedVariables = projectedVariables;
     InlineVariables    = inlineVariables;
     CustomInit();
 }
示例#51
0
        //public static bool operator == (MouseInfo left, MouseInfo right)
        //{
        //    return left.Console == right.Console && left.X == right.X && left.Y == right.Y;
        //}
        //public static bool operator !=(MouseInfo left, MouseInfo right)
        //{
        //    return left.Console != right.Console || left.X != right.X || left.Y != right.Y;
        //}
        /// <summary>
        /// Fills out the state of the mouse.
        /// </summary>
        /// <param name="gameTime"></param>
        public void ProcessMouse(GameTime gameTime)
        {
            MouseState currentState = Mouse.GetState();

            bool leftDown = currentState.LeftButton == ButtonState.Pressed;
            bool rightDown = currentState.RightButton == ButtonState.Pressed;

            ScrollWheelValueChange = ScrollWheelValue - currentState.ScrollWheelValue;
            ScrollWheelValue = currentState.ScrollWheelValue;

            ScreenLocation = new Point((int)(currentState.X * Engine.RenderScale.X), (int)(currentState.Y * Engine.RenderScale.Y)) - new Point((int)(Engine.RenderRect.X * Engine.RenderScale.X), (int)(Engine.RenderRect.Y * Engine.RenderScale.Y));
            bool newLeftClicked = LeftButtonDown && !leftDown;
            bool newRightClicked = RightButtonDown && !rightDown;

            if (!newLeftClicked)
                LeftDoubleClicked = false;
            if (!newRightClicked)
                RightDoubleClicked = false;

            if (LeftClicked && newLeftClicked && gameTime.ElapsedGameTime.TotalMilliseconds < 1000)
                LeftDoubleClicked = true;
            if (RightClicked && newRightClicked && gameTime.ElapsedGameTime.TotalMilliseconds < 1000)
                RightDoubleClicked = true;

            LeftClicked = newLeftClicked;
            RightClicked = newRightClicked;
            _leftLastClickedTime = gameTime.ElapsedGameTime;
            _rightLastClickedTime = gameTime.ElapsedGameTime;
            LeftButtonDown = leftDown;
            RightButtonDown = rightDown;
        }
示例#52
0
 public System.Runtime.DurableInstancing.InstanceView Execute(System.Runtime.DurableInstancing.InstanceHandle handle, System.Runtime.DurableInstancing.InstancePersistenceCommand command, System.TimeSpan timeout)
 {
     throw null;
 }
示例#53
0
		object GetValue (int i)
		{
			if (IsClosed)
				throw new InvalidOperationException ("The reader is closed.");
			if (currentRow == -1)
				throw new InvalidOperationException ("No data available.");
			if (i > cols.Length-1 || i < 0)
				throw new IndexOutOfRangeException ();

			OdbcReturn ret;
			int outsize = 0, bufsize;
			byte[] buffer;
			OdbcColumn col = GetColumn (i);
			object DataValue = null;
			ushort ColIndex = Convert.ToUInt16 (i + 1);

			// Check cached values
			if (col.Value == null) {
				// odbc help file
				// mk:@MSITStore:C:\program%20files\Microsoft%20Data%20Access%20SDK\Docs\odbc.chm::/htm/odbcc_data_types.htm
				switch (col.OdbcType) {
				case OdbcType.Bit:
					short bit_data = 0;
					ret = libodbc.SQLGetData (hstmt, ColIndex, col.SqlCType, ref bit_data, 0, ref outsize);
					if (outsize != (int) OdbcLengthIndicator.NullData)
						DataValue = bit_data == 0 ? "False" : "True";
					break;
				case OdbcType.Numeric:
				case OdbcType.Decimal:
					bufsize = 50;
					buffer = new byte [bufsize];  // According to sqlext.h, use SQL_CHAR for decimal.
					// FIXME : use Numeric.
					ret = libodbc.SQLGetData (hstmt, ColIndex, SQL_C_TYPE.CHAR, buffer, bufsize, ref outsize);
					if (outsize!=-1) {
						byte [] temp = new byte [outsize];
						for (int j = 0; j < outsize; j++)
							temp [j] = buffer [j];
						DataValue = Decimal.Parse (Encoding.Default.GetString (temp),
							CultureInfo.InvariantCulture);
					}
					break;
				case OdbcType.TinyInt:
					short short_data = 0;
					ret = libodbc.SQLGetData (hstmt, ColIndex, col.SqlCType, ref short_data, 0, ref outsize);
					DataValue = Convert.ToByte (short_data);
					break;
				case OdbcType.Int:
					int int_data = 0;
					ret = libodbc.SQLGetData (hstmt, ColIndex, col.SqlCType, ref int_data, 0, ref outsize);
					DataValue = int_data;
					break;

				case OdbcType.SmallInt:
					short sint_data = 0;
					ret = libodbc.SQLGetData (hstmt, ColIndex, col.SqlCType, ref sint_data, 0, ref outsize);
					DataValue = sint_data;
					break;

				case OdbcType.BigInt:
					long long_data = 0;
					ret = libodbc.SQLGetData (hstmt, ColIndex, col.SqlCType, ref long_data, 0, ref outsize);
					DataValue = long_data;
					break;
				case OdbcType.NChar:
					bufsize = 255;
					buffer = new byte [bufsize];
					ret = libodbc.SQLGetData (hstmt, ColIndex, SQL_C_TYPE.WCHAR, buffer, bufsize, ref outsize);
					if (outsize != (int) OdbcLengthIndicator.NullData)
						if (!(ret == OdbcReturn.SuccessWithInfo
						       && outsize == (int) OdbcLengthIndicator.NoTotal))
							DataValue = Encoding.Unicode.GetString (buffer, 0, outsize);
					break;
				case OdbcType.NText:
				case OdbcType.NVarChar:
					bufsize = (col.MaxLength < 127 ? (col.MaxLength*2+1) : 255);
					buffer = new byte[bufsize];  // According to sqlext.h, use SQL_CHAR for both char and varchar
					StringBuilder sb = new StringBuilder ();
					char[] charBuffer = new char[bufsize];
					Decoder unicodeDecoder = Encoding.Unicode.GetDecoder ();
					do {
						ret = libodbc.SQLGetData (hstmt, ColIndex, col.SqlCType, buffer, bufsize, ref outsize);
						if (ret == OdbcReturn.Error)
							break;
						// Fix for strance ODBC drivers (like psqlODBC)
						if (ret == OdbcReturn.Success && outsize==-1)
							ret = OdbcReturn.NoData;

						if (ret == OdbcReturn.Success || ret == OdbcReturn.SuccessWithInfo) {
							if (outsize >= bufsize || outsize == (int)OdbcLengthIndicator.NoTotal)
								outsize = bufsize;
							int charCount = unicodeDecoder.GetChars (buffer, 0, outsize, charBuffer, 0);
							string strValue = new String (charBuffer, 0, charCount);
							sb.Append (RemoveTrailingNullChar (strValue));
						}
					} while (ret != OdbcReturn.NoData);
					DataValue = sb.ToString ();
					charBuffer = null;
					break;
				case OdbcType.Text:
				case OdbcType.VarChar:
					bufsize = (col.MaxLength < 255 ? (col.MaxLength+1) : 255);
					buffer = new byte[bufsize];  // According to sqlext.h, use SQL_CHAR for both char and varchar
					StringBuilder sb1 = new StringBuilder ();
					charBuffer = new char[bufsize];
					Decoder defaultDecoder = Encoding.Default.GetDecoder();
					do { 
						ret = libodbc.SQLGetData (hstmt, ColIndex, col.SqlCType, buffer, bufsize, ref outsize);
						if (ret == OdbcReturn.Error)
							break;
						// Fix for strance ODBC drivers (like psqlODBC)
						if (ret == OdbcReturn.Success && outsize==-1)
							ret = OdbcReturn.NoData;
						if (ret == OdbcReturn.Success || ret == OdbcReturn.SuccessWithInfo) {
							if (outsize >= bufsize || outsize == (int)OdbcLengthIndicator.NoTotal)
								outsize = bufsize - 1;
							int charCount = defaultDecoder.GetChars(buffer, 0, outsize, charBuffer, 0);
							sb1.Append(charBuffer, 0, charCount);
						}
					} while (ret != OdbcReturn.NoData);
					DataValue = sb1.ToString ();
					break;
				case OdbcType.Real:
					float float_data = 0;
					ret = libodbc.SQLGetData (hstmt, ColIndex, col.SqlCType, ref float_data, 0, ref outsize);
					DataValue = float_data;
					break;
				case OdbcType.Double:
					double double_data = 0;
					ret = libodbc.SQLGetData (hstmt, ColIndex, col.SqlCType, ref double_data, 0, ref outsize);
					DataValue = double_data;
					break;
				case OdbcType.Timestamp:
				case OdbcType.DateTime:
				case OdbcType.Date:
				case OdbcType.Time:
					OdbcTimestamp ts_data = new OdbcTimestamp();
					ret = libodbc.SQLGetData (hstmt, ColIndex, col.SqlCType, ref ts_data, 0, ref outsize);
					if (outsize != -1) {// This means SQL_NULL_DATA
						if (col.OdbcType == OdbcType.Time) {
							// libodbc returns value in first three fields for OdbcType.Time 
							DataValue = new System.TimeSpan (ts_data.year, ts_data.month, ts_data.day);
						} else {
							DataValue = new DateTime(ts_data.year, ts_data.month,
							                         ts_data.day, ts_data.hour, ts_data.minute,
							                         ts_data.second);
							if (ts_data.fraction != 0)
								DataValue = ((DateTime) DataValue).AddTicks ((long)ts_data.fraction / 100);
						}
					}
					break;
				case OdbcType.VarBinary :
				case OdbcType.Image :
					bufsize = (col.MaxLength < 255 && col.MaxLength > 0 ? col.MaxLength : 255);
					buffer= new byte [bufsize];
					ArrayList al = new ArrayList ();
					//get the size of data to be returned.
					ret = libodbc.SQLGetData (hstmt, ColIndex, SQL_C_TYPE.BINARY, buffer, 0, ref outsize);
					if (outsize != (int) OdbcLengthIndicator.NullData) {
						do {
							ret = libodbc.SQLGetData (hstmt, ColIndex, SQL_C_TYPE.BINARY, buffer, bufsize, ref outsize);
							if (ret == OdbcReturn.Error)
								break;
							if (ret != OdbcReturn.NoData && outsize != -1) {
								if (outsize < bufsize) {
									byte [] tmparr = new byte [outsize];
									Array.Copy (buffer, 0, tmparr, 0, outsize);
									al.AddRange (tmparr);
								} else
									al.AddRange (buffer);
							} else {
								break;
							}
						} while (ret != OdbcReturn.NoData);
					}
					DataValue = al.ToArray (typeof (byte));
					break;
				case OdbcType.Binary :
					bufsize = col.MaxLength;
					buffer = new byte [bufsize];
					GetBytes (i, 0, buffer, 0, bufsize);
					ret = OdbcReturn.Success;
					DataValue = buffer;
					break;
				default:
					bufsize = 255;
					buffer = new byte[bufsize];
					ret = libodbc.SQLGetData (hstmt, ColIndex, SQL_C_TYPE.CHAR, buffer, bufsize, ref outsize);
					if (outsize != (int) OdbcLengthIndicator.NullData)
						if (! (ret == OdbcReturn.SuccessWithInfo
						       && outsize == (int) OdbcLengthIndicator.NoTotal))
							DataValue = Encoding.Default.GetString (buffer, 0, outsize);
					break;
				}

				if ((ret!=OdbcReturn.Success) && (ret!=OdbcReturn.SuccessWithInfo) && (ret!=OdbcReturn.NoData))
					throw Connection.CreateOdbcException (OdbcHandleType.Stmt, hstmt);

				if (outsize == -1) // This means SQL_NULL_DATA 
					col.Value = DBNull.Value;
				else
					col.Value = DataValue;
			}
			return col.Value;
		}
示例#54
0
 public uint GetUpTime()
 {
     System.TimeSpan dt = System.DateTime.UtcNow - Process.GetCurrentProcess().StartTime.ToUniversalTime();
     return((uint)dt.TotalMinutes);
 }
示例#55
0
 public DateTimeRange(System.TimeSpan duration, System.DateTimeOffset endTime)
 {
     throw null;
 }
示例#56
0
 public System.Threading.Tasks.Task <bool> WaitAsync(System.TimeSpan timeout)
 {
     throw null;
 }
示例#57
0
 private static void ParseValue(MimeStringList list, out System.DateTime utcDateTime, out System.TimeSpan timeZoneOffset)
 {
     var phrase = new MimeStringList();
     var valueParser = new ValueParser(list, false);
     var parseStage = ParseStage.DayOfWeek;
     var numArray = new int[8];
     byte num1 = 32;
     while (parseStage != ParseStage.Count) {
         valueParser.ParseCFWS(false, ref phrase, true);
         var ch = valueParser.ParseGet();
         if (ch != 0) {
             if (!MimeScan.IsToken(ch) || ch == 45 || ch == 43) {
                 num1 = ch;
                 valueParser.ParseCFWS(false, ref phrase, true);
             } else {
                 if (MimeScan.IsDigit(ch)) {
                     if (parseStage == ParseStage.DayOfWeek)
                         parseStage = ParseStage.DayOfMonth;
                     if (parseStage == ParseStage.Second && num1 != 58)
                         parseStage = ParseStage.Zone;
                     var num2 = 0;
                     do {
                         ++num2;
                         numArray[(int) parseStage] *= 10;
                         numArray[(int) parseStage] += ch - 48;
                         ch = valueParser.ParseGet();
                     } while (ch != 0 && MimeScan.IsDigit(ch));
                     if (ch != 0)
                         valueParser.ParseUnget();
                     if (parseStage == ParseStage.Year && num2 <= 2)
                         numArray[(int) parseStage] += numArray[(int) parseStage] < 30 ? 2000 : 1900;
                     if (parseStage == ParseStage.Zone && num2 <= 2)
                         numArray[(int) parseStage] *= 100;
                     if (parseStage == ParseStage.Zone && num1 == 45)
                         numArray[(int) parseStage] = -numArray[(int) parseStage];
                     ++parseStage;
                 } else if (MimeScan.IsAlpha(ch)) {
                     valueParser.ParseUnget();
                     var mimeString = valueParser.ParseToken(MimeScan.Token.Alpha);
                     if (parseStage == ParseStage.DayOfWeek)
                         parseStage = ParseStage.DayOfMonth;
                     else if (parseStage == ParseStage.Month) {
                         numArray[(int) parseStage] = DateHeader.MapMonthToInt(mimeString.Data, mimeString.Offset, mimeString.Length);
                         parseStage = ParseStage.Year;
                     } else if (parseStage >= ParseStage.Second) {
                         if (mimeString.Length == 2 && 65 == DateHeader.MakeUpper(mimeString[0]) && 77 == DateHeader.MakeUpper(mimeString[1])) {
                             if (numArray[4] == 12)
                                 numArray[4] = 0;
                             parseStage = ParseStage.Zone;
                         } else if (mimeString.Length == 2 && 80 == DateHeader.MakeUpper(mimeString[0]) && 77 == DateHeader.MakeUpper(mimeString[1])) {
                             if (numArray[4] < 12)
                                 numArray[4] += 12;
                             parseStage = ParseStage.Zone;
                         } else {
                             numArray[7] = (int) DateHeader.MapZoneToInt(mimeString.Data, mimeString.Offset, mimeString.Length);
                             parseStage = ParseStage.Count;
                         }
                     }
                 }
                 num1 = 32;
             }
         } else
             break;
     }
     if (parseStage > ParseStage.Year) {
         var year = numArray[3];
         var month = numArray[2];
         var day = numArray[1];
         var hour = numArray[4];
         var minute = numArray[5];
         var second = numArray[6];
         if (hour == 23 && minute == 59 && second == 60)
             second = 59;
         if (year >= 1900 && year <= 9999 && (month >= 1 && month <= 12) && (day >= 1 && day <= System.DateTime.DaysInMonth(year, month) && (hour >= 0 && hour < 24)) && (minute >= 0 && minute < 60 && second >= 0)) {
             if (second < 60) {
                 try {
                     utcDateTime = new System.DateTime(year, month, day, hour, minute, second, 0, System.DateTimeKind.Utc);
                     goto label_46;
                 } catch (System.ArgumentException ex) {
                     utcDateTime = minDateTime;
                     goto label_46;
                 }
             }
         }
         utcDateTime = minDateTime;
     } else
         utcDateTime = minDateTime;
     label_46:
     if (parseStage == ParseStage.Count && utcDateTime > minDateTime) {
         var hours = numArray[7]/100;
         var minutes = numArray[7]%100;
         if (hours > 99 || hours < -99) {
             hours = 0;
             minutes = 0;
         }
         if (minutes > 59 || minutes < -59)
             minutes = 0;
         timeZoneOffset = new System.TimeSpan(hours, minutes, 0);
         if (utcDateTime.Ticks >= timeZoneOffset.Ticks && System.DateTime.MaxValue.Ticks >= utcDateTime.Ticks - timeZoneOffset.Ticks)
             utcDateTime -= timeZoneOffset;
         else {
             utcDateTime = minDateTime;
             timeZoneOffset = System.TimeSpan.Zero;
         }
     } else
         timeZoneOffset = System.TimeSpan.Zero;
 }
示例#58
0
 public bool SignalAndWait(System.TimeSpan timeout)
 {
     throw null;
 }
示例#59
0
 private void Reset()
 {
     parsed = false;
     utcDateTime = minDateTime;
     timeZoneOffset = System.TimeSpan.Zero;
 }
示例#60
0
 public bool SignalAndWait(System.TimeSpan timeout, System.Threading.CancellationToken cancellationToken)
 {
     throw null;
 }