Imported Upstream version 3.6.0

Former-commit-id: da6be194a6b1221998fc28233f2503bd61dd9d14
This commit is contained in:
Jo Shields
2014-08-13 10:39:27 +01:00
commit a575963da9
50588 changed files with 8155799 additions and 0 deletions

View File

@@ -0,0 +1,72 @@
//
// Actions.cs
//
// Authors:
// Marek Safar <marek.safar@gmail.com>
//
// Copyright (C) 2007, 2010 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Runtime.CompilerServices;
#if NET_4_0
[assembly:TypeForwardedTo (typeof(Action<>))]
[assembly:TypeForwardedTo (typeof(Action<,>))]
[assembly:TypeForwardedTo (typeof(Action<,,>))]
[assembly:TypeForwardedTo (typeof(Action<,,,>))]
[assembly:TypeForwardedTo (typeof (Action))]
#endif
namespace System
{
#if NET_4_0
public delegate void Action<in T1, in T2, in T3, in T4, in T5, in T6, in T7, in T8, in T9> (
T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9);
public delegate void Action<in T1, in T2, in T3, in T4, in T5, in T6, in T7, in T8, in T9, in T10> (
T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9, T10 arg10);
public delegate void Action<in T1, in T2, in T3, in T4, in T5, in T6, in T7, in T8, in T9, in T10, in T11> (
T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9, T10 arg10, T11 arg11);
public delegate void Action<in T1, in T2, in T3, in T4, in T5, in T6, in T7, in T8, in T9, in T10, in T11, in T12> (
T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9, T10 arg10, T11 arg11, T12 arg12);
public delegate void Action<in T1, in T2, in T3, in T4, in T5, in T6, in T7, in T8, in T9, in T10, in T11, in T12, in T13> (
T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9, T10 arg10, T11 arg11, T12 arg12, T13 arg13);
public delegate void Action<in T1, in T2, in T3, in T4, in T5, in T6, in T7, in T8, in T9, in T10, in T11, in T12, in T13, in T14> (
T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9, T10 arg10, T11 arg11, T12 arg12, T13 arg13, T14 arg14);
public delegate void Action<in T1, in T2, in T3, in T4, in T5, in T6, in T7, in T8, in T9, in T10, in T11, in T12, in T13, in T14, in T15> (
T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9, T10 arg10, T11 arg11, T12 arg12, T13 arg13, T14 arg14, T15 arg15);
public delegate void Action<in T1, in T2, in T3, in T4, in T5, in T6, in T7, in T8, in T9, in T10, in T11, in T12, in T13, in T14, in T15, in T16> (
T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9, T10 arg10, T11 arg11, T12 arg12, T13 arg13, T14 arg14, T15 arg15, T16 arg16);
#else
public delegate void Action ();
public delegate void Action<T1, T2> (T1 arg1, T2 arg2);
public delegate void Action<T1, T2, T3> (T1 arg1, T2 arg2, T3 arg3);
public delegate void Action<T1, T2, T3, T4> (T1 arg1, T2 arg2, T3 arg3, T4 arg4);
#endif
}

View File

@@ -0,0 +1,157 @@
Fri Jul 23 16:46:38 CEST 2010 Paolo Molaro <lupus@ximian.com>
* Funcs.cs: Fixed typo in Func`15.
2010-07-09 Gonzalo Paniagua Javier <gonzalo@novell.com>
* TimeZoneInfo.cs: avoid nullref when there are no adjustment rules.
Fixes bug #619811.
2010-06-09 Rodrigo Kumpera <rkumpera@novell.com>
* Actions.cs: Add missing v4 type forwarding.
2010-06-21 Jb Evain <jbevain@novell.com>
* TimeZoneInfo.cs: fix the moonlight and monotouch build.
2010-06-18 Vincent Povirk <madewokherd@gmail.com>
* TimeZoneInfo.cs: Applied patch from Vincent Povirk that adds
support for reading time zone information on windows.
This patch makes TimeZoneInfo.GetSystemTimeZones and
FindSystemTimeZoneById work based on the registry on non-Unix
platforms, if the appropriate registry key exists. Mono currently
reads from /usr/share/zoneinfo, which doesn't exist on Windows.
This should fix bug 606084.
It won't fix the Local property on Windows. I think that requires
a Windows API call to get the id of the local timezone.
This was modified from the previous version to not check the
registry on Unix platforms. (Sorry it took me so long to do
this. I have very little time to spend on Mono-related work.)
This patch is licensed under the MIT X11 license.
2010-04-16 Sebastien Pouliot <sebastien@ximian.com>
* Actions.cs: Forward Action() to mscorlib.dll and add the new
Action<...T16> delegates
* Funcs.cs: Add the new Func<...T16> delegates
* TimeZoneInfo.cs: Forward to mscorlib.dll
2010-03-30 Sebastien Pouliot <sebastien@ximian.com>
* InvalidTimeZoneException.cs
* TimeZoneInfo.AdjustmentRule.cs
* TimeZoneInfo.cs
* TimeZoneInfo.TransitionTime.cs
* TimeZoneNotFoundException.cs:
Fix Moonlight since these types now reside in mscorlib
for NET_4_0 and also for SL4
2010-03-30 Jb Evain <jbevain@novell.com>
* TimeZoneInfo.AdjustmentRule.cs
* TimeZoneInfo.TransitionTime.cs:
Add TypeForwarderFrom attributes.
2010-01-04 Jb Evain <jbevain@novell.com>
* TimeZoneInfo.AdjustmentRule.cs, TimeZoneInfo.TransitionTime.cs:
Do not include in both mscorlib and System.Core for a NET_2_1 profile.
2009-07-16 Sebastien Pouliot <sebastien@ximian.com>
* InvalidTimeZoneException.cs, TimeZoneInfo.AdjustmentRule.cs,
TimeZoneInfo.cs, TimeZoneInfo.TransitionTime.cs: Bring back those
inside NET_2_1 profile for Moonlight.
2009-06-10 Marek Safar <marek.safar@gmail.com>
* TimeZoneInfo.AdjustmentRule.cs, TimeZoneInfo.TransitionTime.cs,
Funcs.cs, InvalidTimeZoneException.cs, Actions.cs, TimeZoneInfo.cs,
TimeZoneNotFoundException.cs: Updated to 4.0 changes.
2009-06-03 Marek Safar <marek.safar@gmail.com>
* Func.cs: Add 4.0 forwarders.
2009-04-23 Sebastien Pouliot <sebastien@ximian.com>
* TimezoneInfo.cs: TimeZoneDirectory property should not be public
2008-10-31 Stephane Delcroix <sdelcroix@novell.com>
* TimezoneInfo.cs: Drop overlapping rules, fix the 3 dst changes in
Tunis in 1943
2008-10-31 Stephane Delcroix <sdelcroix@novell.com>
* TimezoneInfo.cs: fix for Argentina
2008-10-31 Stephane Delcroix <sdelcroix@novell.com>
* TimezoneInfo.cs: add indices for substrings.
2008-10-31 Stephane Delcroix <sdelcroix@novell.com>
* TimezoneInfo.cs: double the buffer size, as some tz files grew up
recently and failed to load.
2008-08-04 Jb Evain <jbevain@novell.com>
* TimeZoneInfo.cs: avoid using a SortedDictionary when not needed.
2008-06-25 Jb Evain <jbevain@novell.com>
* TimeZoneInfo.cs: remove the dependance to Mono.DataConverter
which is only used to read big endian int32.
2008-05-26 Stephane Delcroix <sdelcroix@novell.com>
* TimeZoneInfo.cs: workaround for weird transition dates, like for
America/Phoenix. Fixes bnc #391093.
2008-05-26 Stephane Delcroix <sdelcroix@novell.com>
* TimeZoneInfo.cs: nullity check in HasSameRules (). Fixes bnc #391011
2008-04-13 Jb Evain <jbevain@novell.com>
* Func.cs: remove old ugly 2.1 hack.
Merged from the Moonlight 2 branch.
2008-03-30 Jb Evain <jbevain@novell.com>
* TimeZoneInfo.cs: use generic collections instead of untyped
collections.
2008-02-01 Jb Evain <jbevain@novell.com>
* Funcs.cs: gross hack for SL 1.1a.
I hate myself, I hate myself.
2008-01-24 Stephane Delcroix <sdelcroix@novell.com>
* TimeZoneInfo.TransitionTime.cs: check for a whole number of
milliseconds instead of a whole number of seconds.
2008-01-21 Sebastien Pouliot <sebastien@ximian.com>
* TimeZoneInfo.TransitionTime.cs: Avoid NRE on bad cast if null is
provided to Equals(object). Found with Gendarme.
2008-01-08 Stephane Delcroix <sdelcroix@novell.com>
* TimeZoneInfo.TransitionTime.cs: fully qualify System.DayOfWeek in
casting operation.
2007-12-20 Stephane Delcroix <sdelcroix@novell.com>
* TimeZoneInfo.cs: adapting length check to parse TZif2 files
introduced by glibc 2.6.x.

View File

@@ -0,0 +1,72 @@
//
// System.Func.cs
//
// Authors:
// Alejandro Serrano "Serras" (trupill@yahoo.es)
// Marek Safar (marek.safar@gmail.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR TArg PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
//
#if NET_4_0
using System;
using System.Runtime.CompilerServices;
[assembly:TypeForwardedTo (typeof(Func<>))]
[assembly:TypeForwardedTo (typeof(Func<,>))]
[assembly:TypeForwardedTo (typeof(Func<,,>))]
[assembly:TypeForwardedTo (typeof(Func<,,,>))]
[assembly:TypeForwardedTo (typeof(Func<,,,,>))]
#endif
namespace System
{
#if NET_4_0
public delegate TResult Func<in T1, in T2, in T3, in T4, in T5, in T6, in T7, in T8, in T9, out TResult> (
T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9);
public delegate TResult Func<in T1, in T2, in T3, in T4, in T5, in T6, in T7, in T8, in T9, in T10, out TResult> (
T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9, T10 arg10);
public delegate TResult Func<in T1, in T2, in T3, in T4, in T5, in T6, in T7, in T8, in T9, in T10, in T11, out TResult> (
T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9, T10 arg10, T11 arg11);
public delegate TResult Func<in T1, in T2, in T3, in T4, in T5, in T6, in T7, in T8, in T9, in T10, in T11, in T12, out TResult> (
T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9, T10 arg10, T11 arg11, T12 arg12);
public delegate TResult Func<in T1, in T2, in T3, in T4, in T5, in T6, in T7, in T8, in T9, in T10, in T11, in T12, in T13, out TResult> (
T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9, T10 arg10, T11 arg11, T12 arg12, T13 arg13);
public delegate TResult Func<in T1, in T2, in T3, in T4, in T5, in T6, in T7, in T8, in T9, in T10, in T11, in T12, in T13, in T14, out TResult> (
T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9, T10 arg10, T11 arg11, T12 arg12, T13 arg13, T14 arg14);
public delegate TResult Func<in T1, in T2, in T3, in T4, in T5, in T6, in T7, in T8, in T9, in T10, in T11, in T12, in T13, in T14, in T15, out TResult> (
T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9, T10 arg10, T11 arg11, T12 arg12, T13 arg13, T14 arg14, T15 arg15);
public delegate TResult Func<in T1, in T2, in T3, in T4, in T5, in T6, in T7, in T8, in T9, in T10, in T11, in T12, in T13, in T14, in T15, in T16, out TResult> (
T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9, T10 arg10, T11 arg11, T12 arg12, T13 arg13, T14 arg14, T15 arg15, T16 arg16);
#else
public delegate TResult Func<TResult> ();
public delegate TResult Func<T, TResult> (T arg);
public delegate TResult Func<T1, T2, TResult> (T1 arg1, T2 arg2);
public delegate TResult Func<T1, T2, T3, TResult> (T1 arg1, T2 arg2, T3 arg3);
public delegate TResult Func<T1, T2, T3, T4, TResult> (T1 arg1, T2 arg2, T3 arg3, T4 arg4);
#endif
}

View File

@@ -0,0 +1,55 @@
/*
* System.InvalidTimeZoneException
*
* Author(s)
* Stephane Delcroix <stephane@delcroix.org>
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#if NET_4_0
using System;
using System.Runtime.CompilerServices;
[assembly:TypeForwardedTo (typeof(InvalidTimeZoneException))]
#else
namespace System
{
[Serializable]
public class InvalidTimeZoneException : Exception
{
public InvalidTimeZoneException () : base ()
{}
public InvalidTimeZoneException (string message) : base (message)
{}
public InvalidTimeZoneException (string message, Exception e) : base (message, e)
{}
protected InvalidTimeZoneException (Runtime.Serialization.SerializationInfo info, Runtime.Serialization.StreamingContext sc) : base (info, sc)
{}
}
}
#endif

View File

@@ -0,0 +1,195 @@
/*
* System.TimeZoneInfo.AdjustmentRule
*
* Author(s)
* Stephane Delcroix <stephane@delcroix.org>
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#if (INSIDE_CORLIB && NET_4_0) || (!INSIDE_CORLIB && (NET_3_5 && !NET_4_0 && !MOBILE))
using System.Runtime.CompilerServices;
using System.Runtime.Serialization;
namespace System
{
public sealed partial class TimeZoneInfo {
[SerializableAttribute]
#if MOBILE
[TypeForwardedFrom (Consts.AssemblySystem_Core)]
#elif NET_4_0
[TypeForwardedFrom (Consts.AssemblySystemCore_3_5)]
#endif
public sealed class AdjustmentRule : IEquatable<TimeZoneInfo.AdjustmentRule>, ISerializable, IDeserializationCallback
{
DateTime dateEnd;
public DateTime DateEnd {
get { return dateEnd; }
}
DateTime dateStart;
public DateTime DateStart {
get { return dateStart; }
}
TimeSpan daylightDelta;
public TimeSpan DaylightDelta {
get { return daylightDelta; }
}
TransitionTime daylightTransitionEnd;
public TransitionTime DaylightTransitionEnd {
get { return daylightTransitionEnd; }
}
TransitionTime daylightTransitionStart;
public TransitionTime DaylightTransitionStart {
get { return daylightTransitionStart; }
}
public static AdjustmentRule CreateAdjustmentRule (
DateTime dateStart,
DateTime dateEnd,
TimeSpan daylightDelta,
TransitionTime daylightTransitionStart,
TransitionTime daylightTransitionEnd)
{
return new AdjustmentRule (dateStart, dateEnd, daylightDelta, daylightTransitionStart, daylightTransitionEnd);
}
private AdjustmentRule (SerializationInfo info, StreamingContext context)
{
if (info == null)
throw new ArgumentNullException ("info");
dateStart = (DateTime) info.GetValue ("DateStart", typeof (DateTime));
dateEnd = (DateTime) info.GetValue ("DateEnd", typeof (DateTime));
daylightDelta = (TimeSpan) info.GetValue ("DaylightDelta", typeof (TimeSpan));
daylightTransitionStart = (TimeZoneInfo.TransitionTime) info.GetValue ("DaylightTransitionStart", typeof (TimeZoneInfo.TransitionTime));
daylightTransitionEnd = (TimeZoneInfo.TransitionTime) info.GetValue ("DaylightTransitionEnd", typeof (TimeZoneInfo.TransitionTime));
}
private AdjustmentRule (
DateTime dateStart,
DateTime dateEnd,
TimeSpan daylightDelta,
TransitionTime daylightTransitionStart,
TransitionTime daylightTransitionEnd)
{
if (dateStart.Kind != DateTimeKind.Unspecified || dateEnd.Kind != DateTimeKind.Unspecified)
throw new ArgumentException ("the Kind property of dateStart or dateEnd parameter does not equal DateTimeKind.Unspecified");
if (daylightTransitionStart == daylightTransitionEnd)
throw new ArgumentException ("daylightTransitionStart parameter cannot equal daylightTransitionEnd parameter");
if (dateStart.Ticks % TimeSpan.TicksPerDay != 0 || dateEnd.Ticks % TimeSpan.TicksPerDay != 0)
throw new ArgumentException ("dateStart or dateEnd parameter includes a time of day value");
if (dateEnd < dateStart)
throw new ArgumentOutOfRangeException ("dateEnd is earlier than dateStart");
if (daylightDelta > new TimeSpan (14, 0, 0) || daylightDelta < new TimeSpan (-14, 0, 0))
throw new ArgumentOutOfRangeException ("daylightDelta is less than -14 or greater than 14 hours");
if (daylightDelta.Ticks % TimeSpan.TicksPerSecond != 0)
throw new ArgumentOutOfRangeException ("daylightDelta parameter does not represent a whole number of seconds");
this.dateStart = dateStart;
this.dateEnd = dateEnd;
this.daylightDelta = daylightDelta;
this.daylightTransitionStart = daylightTransitionStart;
this.daylightTransitionEnd = daylightTransitionEnd;
}
public bool Equals (TimeZoneInfo.AdjustmentRule other)
{
return dateStart == other.dateStart &&
dateEnd == other.dateEnd &&
daylightDelta == other.daylightDelta &&
daylightTransitionStart == other.daylightTransitionStart &&
daylightTransitionEnd == other.daylightTransitionEnd;
}
public override int GetHashCode ()
{
return dateStart.GetHashCode () ^
dateEnd.GetHashCode () ^
daylightDelta.GetHashCode () ^
daylightTransitionStart.GetHashCode () ^
daylightTransitionEnd.GetHashCode ();
}
#if NET_4_0
void ISerializable.GetObjectData (SerializationInfo info, StreamingContext context)
#else
public void GetObjectData (SerializationInfo info, StreamingContext context)
#endif
{
if (info == null)
throw new ArgumentNullException ("info");
info.AddValue ("DateStart", DateStart);
info.AddValue ("DateEnd", DateEnd);
info.AddValue ("DaylightDelta", DaylightDelta);
info.AddValue ("DaylightTransitionStart", DaylightTransitionStart);
info.AddValue ("DaylightTransitionEnd", DaylightTransitionEnd);
}
#if NET_4_0
void IDeserializationCallback.OnDeserialization (object sender)
#else
public void OnDeserialization (object sender)
#endif
{
try {
TimeZoneInfo.AdjustmentRule.Validate (dateStart, dateEnd, daylightDelta,
daylightTransitionStart, daylightTransitionEnd);
} catch (ArgumentException ex) {
throw new SerializationException ("invalid serialization data", ex);
}
}
private static void Validate (
DateTime dateStart,
DateTime dateEnd,
TimeSpan daylightDelta,
TransitionTime daylightTransitionStart,
TransitionTime daylightTransitionEnd)
{
if (dateStart.Kind != DateTimeKind.Unspecified || dateEnd.Kind != DateTimeKind.Unspecified)
throw new ArgumentException ("the Kind property of dateStart or dateEnd parameter does not equal DateTimeKind.Unspecified");
if (daylightTransitionStart == daylightTransitionEnd)
throw new ArgumentException ("daylightTransitionStart parameter cannot equal daylightTransitionEnd parameter");
if (dateStart.Ticks % TimeSpan.TicksPerDay != 0 || dateEnd.Ticks % TimeSpan.TicksPerDay != 0)
throw new ArgumentException ("dateStart or dateEnd parameter includes a time of day value");
if (dateEnd < dateStart)
throw new ArgumentOutOfRangeException ("dateEnd is earlier than dateStart");
if (daylightDelta > new TimeSpan (14, 0, 0) || daylightDelta < new TimeSpan (-14, 0, 0))
throw new ArgumentOutOfRangeException ("daylightDelta is less than -14 or greater than 14 hours");
if (daylightDelta.Ticks % TimeSpan.TicksPerSecond != 0)
throw new ArgumentOutOfRangeException ("daylightDelta parameter does not represent a whole number of seconds");
}
}
}
}
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,85 @@
//
// System.TimeZoneInfo helper for MonoTouch
// because the devices cannot access the file system to read the data
//
// Authors:
// Sebastien Pouliot <sebastien@xamarin.com>
//
// Copyright 2011-2013 Xamarin Inc.
//
// The class can be either constructed from a string (from user code)
// or from a handle (from iphone-sharp.dll internal calls). This
// delays the creation of the actual managed string until actually
// required
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#if (INSIDE_CORLIB && MONOTOUCH)
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
using System.Runtime.InteropServices;
namespace System {
public partial class TimeZoneInfo {
[DllImport ("__Internal")]
extern static IntPtr monotouch_timezone_get_names (ref int count);
static ReadOnlyCollection<string> GetMonoTouchNames ()
{
int count = 0;
IntPtr array = monotouch_timezone_get_names (ref count);
string [] names = new string [count];
for (int i = 0, offset = 0; i < count; i++, offset += IntPtr.Size) {
IntPtr p = Marshal.ReadIntPtr (array, offset);
names [i] = Marshal.PtrToStringAnsi (p);
Marshal.FreeHGlobal (p);
}
Marshal.FreeHGlobal (array);
return new ReadOnlyCollection<string> (names);
}
[DllImport ("__Internal")]
extern static IntPtr monotouch_timezone_get_data (string name, ref int size);
static Stream GetMonoTouchData (string name)
{
int size = 0;
IntPtr data = monotouch_timezone_get_data (name, ref size);
if (size <= 0)
throw new TimeZoneNotFoundException ();
unsafe {
var s = new UnmanagedMemoryStream ((byte*) data, size);
s.Closed += delegate {
Marshal.FreeHGlobal (data);
};
return s;
}
}
}
}
#endif

View File

@@ -0,0 +1,301 @@
/*
* System.TimeZoneInfo.TransitionTime
*
* Author(s)
* Stephane Delcroix <stephane@delcroix.org>
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#if (INSIDE_CORLIB && NET_4_0) || (!INSIDE_CORLIB && (NET_3_5 && !NET_4_0 && !MOBILE))
using System.Runtime.CompilerServices;
using System.Runtime.Serialization;
namespace System
{
public sealed partial class TimeZoneInfo
{
[SerializableAttribute]
#if MOBILE
[TypeForwardedFrom (Consts.AssemblySystem_Core)]
#elif NET_4_0
[TypeForwardedFrom (Consts.AssemblySystemCore_3_5)]
#endif
public struct TransitionTime : IEquatable<TimeZoneInfo.TransitionTime>, ISerializable, IDeserializationCallback
{
DateTime timeOfDay;
public DateTime TimeOfDay {
get { return timeOfDay; }
}
int month;
public int Month {
get { return month; }
}
int day;
public int Day {
get {
#if STRICT
if (!isFixedDateRule)
throw new Exception ("Day property is not valid for floating date rules");
#endif
return day;
}
}
int week;
public int Week {
get {
#if STRICT
if (isFixedDateRule)
throw new Exception ("Week property is not valid for fixed date rules");
#endif
return week;
}
}
DayOfWeek dayOfWeek;
public DayOfWeek DayOfWeek {
get {
#if STRICT
if (isFixedDateRule)
throw new Exception ("DayOfWeek property is not valid for fixed date rules");
#endif
return dayOfWeek;
}
}
bool isFixedDateRule;
public bool IsFixedDateRule {
get { return isFixedDateRule; }
}
public static TransitionTime CreateFixedDateRule (
DateTime timeOfDay,
int month,
int day)
{
return new TransitionTime (timeOfDay, month, day);
}
public static TransitionTime CreateFloatingDateRule (
DateTime timeOfDay,
int month,
int week,
DayOfWeek dayOfWeek)
{
return new TransitionTime (timeOfDay, month, week, dayOfWeek);
}
private TransitionTime (SerializationInfo info, StreamingContext context)
{
if (info == null)
throw new ArgumentNullException ("info");
timeOfDay = (DateTime) info.GetValue ("TimeOfDay", typeof (DateTime));
month = (byte) info.GetValue ("Month", typeof (byte));
week = (byte) info.GetValue ("Week", typeof (byte));
day = (byte) info.GetValue ("Day", typeof (byte));
dayOfWeek = (DayOfWeek) info.GetValue ("DayOfWeek", typeof (DayOfWeek));
isFixedDateRule = (bool) info.GetValue ("IsFixedDateRule", typeof (bool));
if (isFixedDateRule)
{
week = -1;
dayOfWeek = (DayOfWeek) (-1);
}
if (!isFixedDateRule)
day = -1;
}
private TransitionTime (
DateTime timeOfDay,
int month,
int day) : this (timeOfDay, month)
{
if (day < 1 || day > 31)
throw new ArgumentOutOfRangeException ("day parameter is less than 1 or greater than 31");
this.day = day;
this.isFixedDateRule = true;
}
private TransitionTime (
DateTime timeOfDay,
int month,
int week,
DayOfWeek dayOfWeek) : this (timeOfDay, month)
{
if (week < 1 || week > 5)
throw new ArgumentOutOfRangeException ("week parameter is less than 1 or greater than 5");
if (dayOfWeek != DayOfWeek.Sunday &&
dayOfWeek != DayOfWeek.Monday &&
dayOfWeek != DayOfWeek.Tuesday &&
dayOfWeek != DayOfWeek.Wednesday &&
dayOfWeek != DayOfWeek.Thursday &&
dayOfWeek != DayOfWeek.Friday &&
dayOfWeek != DayOfWeek.Saturday)
throw new ArgumentOutOfRangeException ("dayOfWeek parameter is not a member od DayOfWeek enumeration");
this.week = week;
this.dayOfWeek = dayOfWeek;
this.isFixedDateRule = false;
}
private TransitionTime (
DateTime timeOfDay,
int month)
{
if (timeOfDay.Year != 1 || timeOfDay.Month != 1 || timeOfDay.Day != 1)
throw new ArgumentException ("timeOfDay parameter has a non-default date component");
if (timeOfDay.Kind != DateTimeKind.Unspecified)
throw new ArgumentException ("timeOfDay parameter Kind's property is not DateTimeKind.Unspecified");
if (timeOfDay.Ticks % TimeSpan.TicksPerMillisecond != 0)
throw new ArgumentException ("timeOfDay parameter does not represent a whole number of milliseconds");
if (month < 1 || month > 12)
throw new ArgumentOutOfRangeException ("month parameter is less than 1 or greater than 12");
this.timeOfDay = timeOfDay;
this.month = month;
this.week = -1;
this.dayOfWeek = (System.DayOfWeek)(-1);
this.day = -1;
this.isFixedDateRule = false;
}
public static bool operator == (TransitionTime t1, TransitionTime t2)
{
return ( t1.day == t2.day &&
t1.dayOfWeek == t2.dayOfWeek &&
t1.isFixedDateRule == t2.isFixedDateRule &&
t1.month == t2.month &&
t1.timeOfDay == t2.timeOfDay &&
t1.week == t2.week);
}
public static bool operator != (TransitionTime t1, TransitionTime t2)
{
return !(t1 == t2);
}
#if NET_4_0
void ISerializable.GetObjectData (SerializationInfo info, StreamingContext context)
#else
public void GetObjectData (SerializationInfo info, StreamingContext context)
#endif
{
if (info == null)
throw new ArgumentNullException ("info");
info.AddValue ("TimeOfDay", TimeOfDay);
info.AddValue ("Month", System.Convert.ToByte(Month));
if (week > -1)
info.AddValue ("Week", System.Convert.ToByte(week));
else
info.AddValue ("Week", (byte) 1);
if (day > -1)
info.AddValue ("Day", System.Convert.ToByte(day));
else
info.AddValue ("Day", (byte) 1);
if (dayOfWeek != ((System.DayOfWeek) (-1)))
info.AddValue ("DayOfWeek", dayOfWeek);
else
info.AddValue ("DayOfWeek", DayOfWeek.Sunday);
info.AddValue ("IsFixedDateRule", IsFixedDateRule);
}
public override bool Equals (object obj)
{
if (obj is TransitionTime)
return this == (TransitionTime) obj;
return false;
}
public bool Equals (TimeZoneInfo.TransitionTime other)
{
return this == other;
}
public override int GetHashCode ()
{
return (day ^ (int)dayOfWeek ^ month ^ (int)timeOfDay.Ticks ^ week);
}
#if NET_4_0
void IDeserializationCallback.OnDeserialization (object sender)
#else
public void OnDeserialization (object sender)
#endif
{
try {
TimeZoneInfo.TransitionTime.Validate (timeOfDay, month, week, day, dayOfWeek, isFixedDateRule);
} catch (ArgumentException ex) {
throw new SerializationException ("invalid serialization data", ex);
}
}
private static void Validate (DateTime timeOfDay, int month,int week, int day, DayOfWeek dayOfWeek, bool isFixedDateRule)
{
if (timeOfDay.Year != 1 || timeOfDay.Month != 1 || timeOfDay.Day != 1)
throw new ArgumentException ("timeOfDay parameter has a non-default date component");
if (timeOfDay.Kind != DateTimeKind.Unspecified)
throw new ArgumentException ("timeOfDay parameter Kind's property is not DateTimeKind.Unspecified");
if (timeOfDay.Ticks % TimeSpan.TicksPerMillisecond != 0)
throw new ArgumentException ("timeOfDay parameter does not represent a whole number of milliseconds");
if (day < 1 || day > 31) {
if (!(!isFixedDateRule && day == -1))
throw new ArgumentOutOfRangeException ("day parameter is less than 1 or greater than 31");
}
if (week < 1 || week > 5) {
if (!(isFixedDateRule && week == -1))
throw new ArgumentOutOfRangeException ("week parameter is less than 1 or greater than 5");
}
if (month < 1 || month > 12)
throw new ArgumentOutOfRangeException ("month parameter is less than 1 or greater than 12");
if (dayOfWeek != DayOfWeek.Sunday &&
dayOfWeek != DayOfWeek.Monday &&
dayOfWeek != DayOfWeek.Tuesday &&
dayOfWeek != DayOfWeek.Wednesday &&
dayOfWeek != DayOfWeek.Thursday &&
dayOfWeek != DayOfWeek.Friday &&
dayOfWeek != DayOfWeek.Saturday) {
if (!(isFixedDateRule && dayOfWeek == (DayOfWeek) (-1)))
throw new ArgumentOutOfRangeException ("dayOfWeek parameter is not a member od DayOfWeek enumeration");
}
}
}
}
}
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,55 @@
/*
* System.TimeZoneNotFoundException
*
* Author(s)
* Stephane Delcroix <stephane@delcroix.org>
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#if NET_4_0
using System;
using System.Runtime.CompilerServices;
[assembly:TypeForwardedTo (typeof(TimeZoneNotFoundException))]
#else
namespace System
{
[Serializable]
public class TimeZoneNotFoundException : Exception
{
public TimeZoneNotFoundException () : base ()
{}
public TimeZoneNotFoundException (string message) : base (message)
{}
public TimeZoneNotFoundException (string message, Exception e) : base (message, e)
{}
protected TimeZoneNotFoundException (Runtime.Serialization.SerializationInfo info, Runtime.Serialization.StreamingContext sc) : base (info, sc)
{}
}
}
#endif

View File

@@ -0,0 +1,13 @@
namespace System
{
internal static class MonoUtil
{
public readonly static bool IsUnix;
static MonoUtil ()
{
int platform = (int) Environment.OSVersion.Platform;
IsUnix = platform == 4 || platform == 128 || platform == 6;
}
}
}