// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-#if !MOONLIGHT
-
using System;
using System.IO;
using System.Security.Cryptography;
}
}
}
-
-#endif
-
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-#if !MOONLIGHT
-
using System;
using System.IO;
using System.Runtime.InteropServices;
}
}
}
-
-#endif
-
static RandomNumberGenerator Rng {
get {
-#if MOONLIGHT
- if (rng == null)
- rng = new RNGCryptoServiceProvider ();
-#else
if (rng == null)
rng = RandomNumberGenerator.Create ();
-#endif
return rng;
}
}
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-#if !MOONLIGHT
-
using System;
using System.Globalization;
using System.IO;
}
}
}
-
-#endif
-
private static byte[] emptySHA1 = { 0xda, 0x39, 0xa3, 0xee, 0x5e, 0x6b, 0x4b, 0x0d, 0x32, 0x55, 0xbf, 0xef, 0x95, 0x60, 0x18, 0x90, 0xaf, 0xd8, 0x07, 0x09 };
private static byte[] emptySHA256 = { 0xe3, 0xb0, 0xc4, 0x42, 0x98, 0xfc, 0x1c, 0x14, 0x9a, 0xfb, 0xf4, 0xc8, 0x99, 0x6f, 0xb9, 0x24, 0x27, 0xae, 0x41, 0xe4, 0x64, 0x9b, 0x93, 0x4c, 0xa4, 0x95, 0x99, 0x1b, 0x78, 0x52, 0xb8, 0x55 };
-#if !MOONLIGHT
private static byte[] emptySHA384 = { 0x38, 0xb0, 0x60, 0xa7, 0x51, 0xac, 0x96, 0x38, 0x4c, 0xd9, 0x32, 0x7e, 0xb1, 0xb1, 0xe3, 0x6a, 0x21, 0xfd, 0xb7, 0x11, 0x14, 0xbe, 0x07, 0x43, 0x4c, 0x0c, 0xc7, 0xbf, 0x63, 0xf6, 0xe1, 0xda, 0x27, 0x4e, 0xde, 0xbf, 0xe7, 0x6f, 0x65, 0xfb, 0xd5, 0x1a, 0xd2, 0xf1, 0x48, 0x98, 0xb9, 0x5b };
private static byte[] emptySHA512 = { 0xcf, 0x83, 0xe1, 0x35, 0x7e, 0xef, 0xb8, 0xbd, 0xf1, 0x54, 0x28, 0x50, 0xd6, 0x6d, 0x80, 0x07, 0xd6, 0x20, 0xe4, 0x05, 0x0b, 0x57, 0x15, 0xdc, 0x83, 0xf4, 0xa9, 0x21, 0xd3, 0x6c, 0xe9, 0xce, 0x47, 0xd0, 0xd1, 0x3c, 0x5d, 0x85, 0xf2, 0xb0, 0xff, 0x83, 0x18, 0xd2, 0x87, 0x7e, 0xec, 0x2f, 0x63, 0xb9, 0x31, 0xbd, 0x47, 0x41, 0x7a, 0x81, 0xa5, 0x38, 0x32, 0x7a, 0xf9, 0x27, 0xda, 0x3e };
-#endif
private static byte[] GetEmptyHash (HashAlgorithm hash)
{
return emptySHA1;
else if (hash is SHA256)
return emptySHA256;
-#if !MOONLIGHT
else if (hash is SHA384)
return emptySHA384;
else if (hash is SHA512)
return emptySHA512;
-#endif
else
return hash.ComputeHash ((byte[])null);
}
param.InverseQ = Normalize (privateKey [8].Value, keysize2);
param.P = Normalize (privateKey [4].Value, keysize2);
param.Q = Normalize (privateKey [5].Value, keysize2);
-#if MOONLIGHT
- RSA rsa = RSA.Create ();
- rsa.ImportParameters (param);
-#else
RSA rsa = null;
try {
rsa = RSA.Create ();
rsa = new RSACryptoServiceProvider (csp);
rsa.ImportParameters (param);
}
-#endif
return rsa;
}
private byte[] workBuff;
private byte[] workout;
protected PaddingMode padmode;
-#if !MOONLIGHT
// Silverlight 2.0 does not support any feedback mode
protected int FeedBackByte;
-#endif
private bool m_disposed = false;
protected bool lastBlock;
temp = new byte [BlockSizeByte];
Buffer.BlockCopy (rgbIV, 0, temp, 0, System.Math.Min (BlockSizeByte, rgbIV.Length));
temp2 = new byte [BlockSizeByte];
-#if !MOONLIGHT
FeedBackByte = (algo.FeedbackSize >> 3);
-#endif
// transform buffers
workBuff = new byte [BlockSizeByte];
workout = new byte [BlockSizeByte];
// i.e. Any padding must be done before calling this method
protected virtual void Transform (byte[] input, byte[] output)
{
-#if MOONLIGHT
- // Silverlight 2.0 only supports CBC
- CBC (input, output);
-#else
switch (algo.Mode) {
case CipherMode.ECB:
ECB (input, output);
default:
throw new NotImplementedException ("Unkown CipherMode" + algo.Mode.ToString ());
}
-#endif
}
// Electronic Code Book (ECB)
}
}
-#if !MOONLIGHT
// Cipher-FeedBack (CFB)
// this is how *CryptoServiceProvider implements CFB
// only AesCryptoServiceProvider support CFB > 8
{
throw new CryptographicException ("CTS isn't supported by the framework");
}
-#endif
private void CheckInput (byte[] inputBuffer, int inputOffset, int inputCount)
{
// ordered to avoid possible integer overflow
int len = outputBuffer.Length - inputCount - outputOffset;
-#if MOONLIGHT
- // only PKCS7 is supported Silverlight 2.0
- if (KeepLastBlock) {
-#else
if (!encrypt && (0 > len) && ((padmode == PaddingMode.None) || (padmode == PaddingMode.Zeros))) {
throw new CryptographicException ("outputBuffer", Locale.GetText ("Overflow"));
} else if (KeepLastBlock) {
-#endif
if (0 > len + BlockSizeByte) {
throw new CryptographicException ("outputBuffer", Locale.GetText ("Overflow"));
}
private bool KeepLastBlock {
get {
-#if MOONLIGHT
- // only PKCS7 is supported Silverlight 2.0
- return !encrypt;
-#else
return ((!encrypt) && (padmode != PaddingMode.None) && (padmode != PaddingMode.Zeros));
-#endif
}
}
return total;
}
-#if !MOONLIGHT
RandomNumberGenerator _rng;
private void Random (byte[] buffer, int start, int length)
msg += String.Format (Locale.GetText (" Error found at position {0}."), position);
throw new CryptographicException (msg);
}
-#endif
protected virtual byte[] FinalEncrypt (byte[] inputBuffer, int inputOffset, int inputCount)
{
int rem = inputCount - full;
int total = full;
-#if MOONLIGHT
- // only PKCS7 is supported Silverlight 2.0
- total += BlockSizeByte;
-#else
switch (padmode) {
case PaddingMode.ANSIX923:
case PaddingMode.ISO10126:
}
break;
}
-#endif // NET_2_1
byte[] res = new byte [total];
int outputOffset = 0;
// now we only have a single last block to encrypt
byte padding = (byte) (BlockSizeByte - rem);
-#if MOONLIGHT
- // only PKCS7 is supported Silverlight 2.0
- for (int i = res.Length; --i >= (res.Length - padding);)
- res [i] = padding;
- Buffer.BlockCopy (inputBuffer, inputOffset, res, full, rem);
- InternalTransformBlock (res, full, BlockSizeByte, res, full);
-#else
switch (padmode) {
case PaddingMode.ANSIX923:
// XX 00 00 00 00 00 00 07 (zero + padding length)
InternalTransformBlock (inputBuffer, inputOffset, BlockSizeByte, res, outputOffset);
break;
}
-#endif // NET_2_1
return res;
}
// total may be 0 (e.g. PaddingMode.None)
byte padding = ((total > 0) ? res [total - 1] : (byte) 0);
-#if MOONLIGHT
- // only PKCS7 is supported Silverlight 2.0
- if ((padding == 0) || (padding > BlockSizeByte))
- throw new CryptographicException (Locale.GetText ("Bad padding length."));
- for (int i = padding - 1; i > 0; i--) {
- if (res [total - 1 - i] != padding)
- throw new CryptographicException (Locale.GetText ("Bad padding at position {0}.", i));
- }
- total -= padding;
-#else
switch (padmode) {
case PaddingMode.ANSIX923:
if ((padding == 0) || (padding > BlockSizeByte))
case PaddingMode.Zeros: // nothing to do - user must unpad himself
break;
}
-#endif // NET_2_1
// return output without padding
if (total > 0) {
// b. ITU ASN.1 standards (free download)
// http://www.itu.int/ITU-T/studygroups/com17/languages/
-#if INSIDE_CORLIB && !MOONLIGHT
+#if INSIDE_CORLIB
internal class X509Certificate : ISerializable {
#else
public class X509Certificate : ISerializable {
// BUG: MS BCL 1.0 can't import a key which
// isn't the same size as the one present in
// the container.
-#if MOONLIGHT
- _dsa = new DSAManaged (dsaParams.Y.Length << 3);
-#else
_dsa = (DSA) new DSACryptoServiceProvider (dsaParams.Y.Length << 3);
_dsa.ImportParameters (dsaParams);
-#endif
}
return _dsa;
}
// isn't the same size as the one present in
// the container.
int keySize = (rsaParams.Modulus.Length << 3);
-#if MOONLIGHT
- _rsa = new RSAManaged (keySize);
-#else
_rsa = (RSA) new RSACryptoServiceProvider (keySize);
_rsa.ImportParameters (rsaParams);
-#endif
}
return _rsa;
}
public bool CheckSignature (byte[] hash, string hashAlgorithm, byte[] signature)
{
-#if MOONLIGHT
- string hashName = GetHashNameFromOID (hashAlgorithm);
- HashAlgorithm algo = HashAlgorithm.Create (hashName);
- return PKCS1.Verify_v15 (RSA, algo, hash, signature);
-#else
RSACryptoServiceProvider r = (RSACryptoServiceProvider) RSA;
return r.VerifyHash (hash, hashAlgorithm, signature);
-#endif
}
public bool IsSelfSigned {
namespace Mono.Security.X509 {
[Serializable]
-#if INSIDE_CORLIB && !MOONLIGHT
+#if INSIDE_CORLIB
internal
#else
public
* extnValue OCTET STRING
* }
*/
-#if INSIDE_CORLIB && !MOONLIGHT
+#if INSIDE_CORLIB
internal
#else
public
*
* Note: 1..MAX -> There shouldn't be 0 Extensions in the ASN1 structure
*/
-#if INSIDE_CORLIB && !MOONLIGHT
+#if INSIDE_CORLIB
internal
#else
public
// References:
// a. ITU ASN.1 standards (free download)
// http://www.itu.int/ITU-T/studygroups/com17/languages/
-
-#if INSIDE_CORLIB && !MOONLIGHT
+#if INSIDE_CORLIB
internal
#else
public
get {
if (rsa == null)
return false;
-#if INSIDE_CORLIB && !MOONLIGHT
+#if INSIDE_CORLIB
// the easy way
if (RSA is RSACryptoServiceProvider) {
// available as internal for corlib
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-#if MOONLIGHT || NET_4_0 || MOBILE
+#if NET_4_0 || MOBILE
using System;
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-#if MOONLIGHT || NET_4_0 || MOBILE
+#if NET_4_0 || MOBILE
using System;
#endif
public static class ContractHelper
{
-#if MOONLIGHT
- const string SystemWindowsBrowser = ", System.Windows.Browser, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e";
- const string HtmlPage = "System.Windows.Browser.HtmlPage" + SystemWindowsBrowser;
- const string HtmlWindow = "System.Windows.Browser.HtmlWindow" + SystemWindowsBrowser;
- static MethodInfo alert;
- static object window;
-
- static ContractHelper ()
- {
- Type htmlpage = Type.GetType (HtmlPage);
- MethodInfo get_window = htmlpage.GetMethod ("get_Window", BindingFlags.Static | BindingFlags.Public);
- window = get_window.Invoke (null, null);
- Type htmlwindow = Type.GetType (HtmlWindow);
- alert = htmlwindow.GetMethod ("Alert", BindingFlags.Instance | BindingFlags.Public);
- }
-#endif
-
[ReliabilityContract (Consistency.WillNotCorruptState, Cer.MayFail)]
[DebuggerNonUserCode]
public static string RaiseContractFailedEvent (ContractFailureKind failureKind, string userMessage, string conditionText, Exception innerException)
if (displayMessage != null) {
msg.Append (displayMessage);
}
-#if MOONLIGHT
- // Silverlight shows a dialog that let you Abort (kill process/browser), Retry or Ignore
- // Moonlight will simply warn and ignore (at least until FailFast is implemented)
- // using reflection into System.Windows.Browser to popup an browser alert
- alert.Invoke (window, new object [] { msg.ToString () });
-#else
if (Environment.UserInteractive) {
// FIXME: This should trigger an assertion.
// But code will never get here at the moment, as Environment.UserInteractive currently
// Note that FailFast() currently throws a NotImplementedException()
Environment.FailFast(msg.ToString()/*, new ExecutionEngineException()*/);
}
-#endif
}
}
string filename = "<filename unknown>";
if (fileName == null)
return filename;
-#if !MOONLIGHT
try {
filename = GetFileName ();
}
catch (SecurityException) {
// CAS check failure
}
-#else
- // Silverlight always return <filename unknown> but that's not very useful for debugging
- // OTOH we do not want to share any details about the original file system (even if they
- // are likely available in the debugging symbols files) from the browser's plugin (but
- // compiling stuff from smcs is fine since it's outside the sandbox)
- try {
- if (SecurityManager.SecurityEnabled)
- filename = Path.GetFileName (fileName);
- }
- catch (ArgumentException) {
- // e.g. invalid chars in filename
- }
-#endif
return filename;
}
[NonSerialized]
bool m_isReadOnly;
-#if !MOONLIGHT
[System.Runtime.InteropServices.ComVisible(false)]
public virtual CalendarAlgorithmType AlgorithmType {
get {
return CalendarAlgorithmType.Unknown;
}
}
-#endif
[System.Runtime.InteropServices.ComVisible(false)]
public virtual DateTime MaxSupportedDateTime {
{
[Serializable]
[StructLayout (LayoutKind.Sequential)]
-#if !MOONLIGHT
+
[ComVisible (true)]
public class CompareInfo : IDeserializationCallback {
CompareOptions options,
bool first);
-#else
- public class CompareInfo {
- internal static bool UseManagedCollation {
- get { return true; }
- }
-#endif
const CompareOptions ValidCompareOptions_NoStringSort =
CompareOptions.None | CompareOptions.IgnoreCase | CompareOptions.IgnoreNonSpace |
CompareOptions.IgnoreSymbols | CompareOptions.IgnoreKanaType | CompareOptions.IgnoreWidth |
}
} else {
/*
-#if !MOONLIGHT
this.icu_name = ci.IcuName;
this.construct_compareinfo (icu_name);
-#endif
*/
}
}
/*
~CompareInfo ()
{
-#if !MOONLIGHT
free_internal_collator ();
-#endif
}
*/
-#if !MOONLIGHT
private int internal_compare_managed (string str1, int offset1,
int length1, string str2,
int offset2, int length2,
internal_compare (str1, offset1, length1,
str2, offset2, length2, options);
}
-#else
- private int internal_compare_switch (string str1, int offset1,
- int length1, string str2,
- int offset2, int length2,
- CompareOptions options)
- {
- return collator.Compare (str1, offset1, length1,
- str2, offset2, length2, options);
- }
-#endif
+
public virtual int Compare (string string1, string string2)
{
return Compare (string1, string2, CompareOptions.None);
case CompareOptions.OrdinalIgnoreCase:
throw new ArgumentException ("Now allowed CompareOptions.", "options");
}
-#if !MOONLIGHT
if (UseManagedCollation)
return collator.GetSortKey (source, options);
SortKey key=new SortKey (culture, source, options);
assign_sortkey (key, source, options);
return(key);
-#else
- return collator.GetSortKey (source, options);
-#endif
}
public virtual int IndexOf (string source, char value)
CompareOptions.None));
}
-#if !MOONLIGHT
private int internal_index_managed (string s, int sindex,
int count, char c, CompareOptions opt,
bool first)
internal_index_managed (s, sindex, count, c, opt, first) :
internal_index (s, sindex, count, c, opt, first);
}
-#else
- private int internal_index_switch (string s, int sindex,
- int count, char c, CompareOptions opt,
- bool first)
- {
- return first ?
- collator.IndexOf (s, c, sindex, count, opt) :
- collator.LastIndexOf (s, c, sindex, count, opt);
- }
-#endif
public virtual int IndexOf (string source, char value,
int startIndex, int count,
}
}
-#if !MOONLIGHT
private int internal_index_managed (string s1, int sindex,
int count, string s2, CompareOptions opt,
bool first)
internal_index_managed (s1, sindex, count, s2, opt, first) :
internal_index (s1, sindex, count, s2, opt, first);
}
-#else
- private int internal_index_switch (string s1, int sindex,
- int count, string s2, CompareOptions opt,
- bool first)
- {
- return first ?
- collator.IndexOf (s1, s2, sindex, count, opt) :
- collator.LastIndexOf (s1, s2, sindex, count, opt);
- }
-#endif
public virtual int IndexOf (string source, string value,
int startIndex, int count,
public virtual string Name {
get {
-#if MOONLIGHT
- if (m_name == "zh-CHS")
- return "zh-Hans";
- if (m_name == "zh-CHT")
- return "zh-Hant";
-#endif
return(m_name);
}
}
return false;
}
-#if !MOONLIGHT
public static CultureInfo[] GetCultures(CultureTypes types)
{
bool neutral=((types & CultureTypes.NeutralCultures)!=0);
return infos;
}
-#endif
public override int GetHashCode ()
{
internal void CheckNeutral ()
{
-#if !MOONLIGHT && !NET_4_0
+#if !NET_4_0
if (IsNeutralCulture) {
throw new NotSupportedException ("Culture \"" + m_name + "\" is " +
"a neutral culture. It can not be used in formatting " +
// 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 || MOONLIGHT || MOBILE
+#if NET_4_0 || MOBILE
using System;
using System.Runtime.InteropServices;
// 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 || MOONLIGHT || MOBILE
+#if NET_4_0 || MOBILE
using System;
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-#if !MOONLIGHT
using System.Globalization;
using System.Reflection;
using System.Runtime.InteropServices;
#endif
}
}
-/* MOONLIGHT */
-#endif
// 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 !MOONLIGHT
using System.Collections;
using System.Reflection;
using System.Runtime.InteropServices;
#endif
}
}
-#endif
using System.Collections;
-#if !MOONLIGHT
-
namespace System.IO.IsolatedStorage {
internal class IsolatedStorageFileEnumerator : IEnumerator {
}
}
}
-#endif
// 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 !MOONLIGHT
using System.Diagnostics;
using System.Globalization;
using System.Reflection;
}
}
}
-#endif
None = 0,
User = 1,
-#if MOONLIGHT
- // Available in Silverlight
- Application = 32,
-#else
Domain = 2,
Assembly = 4,
Machine = 16,
Application = 32
-#endif
}
}
using System.Security.Permissions;
using System.Text;
using System.Runtime.InteropServices;
-
-#if !MOONLIGHT
using System.Security.AccessControl;
-#endif
namespace System.IO
{
return CreateDirectoriesInternal (path);
}
-#if !MOONLIGHT
[MonoLimitation ("DirectorySecurity not implemented")]
public static DirectoryInfo CreateDirectory (string path, DirectorySecurity directorySecurity)
{
return(CreateDirectory (path));
}
-#endif
static DirectoryInfo CreateDirectoriesInternal (string path)
{
return GetFileSystemEntries (path, searchPattern, FileAttributes.Directory, FileAttributes.Directory);
}
-#if !MOONLIGHT
public static string [] GetDirectories (string path, string searchPattern, SearchOption searchOption)
{
if (searchOption == SearchOption.TopDirectoryOnly)
foreach (string dir in GetDirectories (path))
GetDirectoriesRecurse (dir, searchPattern, all);
}
-#endif
public static string GetDirectoryRoot (string path)
{
return GetFileSystemEntries (path, searchPattern, FileAttributes.Directory, 0);
}
-#if !MOONLIGHT
public static string[] GetFiles (string path, string searchPattern, SearchOption searchOption)
{
if (searchOption == SearchOption.TopDirectoryOnly)
foreach (string dir in GetDirectories (path))
GetFilesRecurse (dir, searchPattern, all);
}
-#endif
public static string [] GetFileSystemEntries (string path)
{
throw MonoIO.GetException (error);
}
-#if !MOONLIGHT
public static void SetAccessControl (string path, DirectorySecurity directorySecurity)
{
if (null == directorySecurity)
directorySecurity.PersistModifications (path);
}
-#endif
public static void SetCreationTime (string path, DateTime creationTime)
{
return result;
}
-#if NET_4_0 || MOONLIGHT || MOBILE
+#if NET_4_0 || MOBILE
public static string[] GetFileSystemEntries (string path, string searchPattern, SearchOption searchOption)
{
// Take the simple way home:
#endif
-#if !MOONLIGHT
public static DirectorySecurity GetAccessControl (string path, AccessControlSections includeSections)
{
return new DirectorySecurity (path, includeSections);
AccessControlSections.Group |
AccessControlSections.Access);
}
-#endif
}
}
using System.Runtime.Serialization;
using System.Security;
using System.Text;
-#if !MOONLIGHT
using System.Security.AccessControl;
-#endif
namespace System.IO {
private string current;
private string parent;
-#if MOONLIGHT
- internal DirectoryInfo ()
- {
- }
-#endif
public DirectoryInfo (string path) : this (path, false)
{
}
return OriginalPath;
}
-#if !MOONLIGHT
public DirectoryInfo[] GetDirectories (string searchPattern, SearchOption searchOption)
{
//NULL-check of searchPattern is done in Directory.GetDirectories
{
Directory.SetAccessControl (FullPath, directorySecurity);
}
-#endif
-#if NET_4_0 || MOONLIGHT || MOBILE
+#if NET_4_0 || MOBILE
public IEnumerable<DirectoryInfo> EnumerateDirectories ()
{
throw new NotSupportedException (Locale.GetText ("File encryption isn't supported on any file system."));
}
-#if MOONLIGHT || NET_4_0 || MOBILE
+#if NET_4_0 || MOBILE
public static IEnumerable<string> ReadLines (string path)
{
return ReadLines (File.OpenText (path));
{
private bool exists;
-#if MOONLIGHT
- internal FileInfo ()
- {
- }
-#endif
public FileInfo (string fileName)
{
if (fileName == null)
this.access = access;
this.owner = ownsHandle;
this.async = isAsync;
-#if MOONLIGHT
- // default the browser to 'all' anonymous files and let other usage (like smcs) with 'normal'
- // (i.e. non-anonymous except for isolated storage) files and paths
- this.anonymous = SecurityManager.SecurityEnabled;
-#else
this.anonymous = false;
-#endif
if (canseek) {
buf_start = MonoIO.Seek (handle, 0, SeekOrigin.Current, out error);
if (error != MonoIOError.ERROR_SUCCESS) {
}
if (access < FileAccess.Read || access > FileAccess.ReadWrite) {
-#if MOONLIGHT
- if (anonymous)
- throw new IsolatedStorageException ("Enum value for FileAccess was out of legal range.");
- else
-#endif
throw new ArgumentOutOfRangeException ("access", "Enum value was out of legal range.");
}
if (share < FileShare.None || share > (FileShare.ReadWrite | FileShare.Delete)) {
-#if MOONLIGHT
- if (anonymous)
- throw new IsolatedStorageException ("Enum value for FileShare was out of legal range.");
- else
-#endif
throw new ArgumentOutOfRangeException ("share", "Enum value was out of legal range.");
}
// don't leak the path information for isolated storage
string msg = Locale.GetText ("Could not find a part of the path \"{0}\".");
string fname = (anonymous) ? dname : Path.GetFullPath (path);
-#if MOONLIGHT
- // don't use GetSecureFileName for the directory name
- throw new IsolatedStorageException (String.Format (msg, fname));
-#else
throw new DirectoryNotFoundException (String.Format (msg, fname));
-#endif
}
}
// don't leak the path information for isolated storage
string msg = Locale.GetText ("Could not find file \"{0}\".");
string fname = GetSecureFileName (path);
-#if MOONLIGHT
- throw new IsolatedStorageException (String.Format (msg, fname));
-#else
throw new FileNotFoundException (String.Format (msg, fname), fname);
-#endif
}
// IsolatedStorage needs to keep the Name property to the default "[Unknown]"
public string Name {
get {
-#if MOONLIGHT
- return SecurityManager.CheckElevatedPermissions () ? name : "[Unknown]";
-#else
return name;
-#endif
}
}
FlushBuffer ();
}
-#if NET_4_0 || MOONLIGHT || MOBILE
+#if NET_4_0 || MOBILE
public virtual void Flush (bool flushToDisk)
{
FlushBuffer ();
// FIXME: add more exception mappings here
case MonoIOError.ERROR_FILE_NOT_FOUND:
message = String.Format ("Could not find file \"{0}\"", path);
-#if MOONLIGHT
- return new IsolatedStorageException (message);
-#else
return new FileNotFoundException (message, path);
-#endif
case MonoIOError.ERROR_TOO_MANY_OPEN_FILES:
return new IOException ("Too many open files", unchecked((int)0x80070000) | (int)error);
case MonoIOError.ERROR_PATH_NOT_FOUND:
message = String.Format ("Could not find a part of the path \"{0}\"", path);
-#if MOONLIGHT
- return new IsolatedStorageException (message);
-#else
return new DirectoryNotFoundException (message);
-#endif
case MonoIOError.ERROR_ACCESS_DENIED:
message = String.Format ("Access to the path \"{0}\" is denied.", path);
return String.Compare (subset, slast, path, slast, subset.Length - slast) == 0;
}
-#if NET_4_0 || MOONLIGHT || MOBILE
+#if NET_4_0 || MOBILE
public
#else
internal
return ret.ToString ();
}
-#if NET_4_0 || MOONLIGHT || MOBILE
+#if NET_4_0 || MOBILE
public
#else
internal
return Combine (new string [] { path1, path2, path3 });
}
-#if NET_4_0 || MOONLIGHT || MOBILE
+#if NET_4_0 || MOBILE
public
#else
internal
if (idx >= 0 && idx != 1)
throw new ArgumentException (parameterName);
}
-#if MOONLIGHT
- // On Moonlight (SL4+) there are some limitations in "Elevated Trust"
- if (SecurityManager.HasElevatedPermissions) {
- }
-#endif
}
}
}
}
}
-#if MOONLIGHT || NET_4_0 || MOBILE
+#if NET_4_0 || MOBILE
public void CopyTo (Stream destination)
{
CopyTo (destination, 16*1024);
if ((access & COMPILER_ACCESS) != 0)
throw new NotImplementedException ("COMPILER_ACCESS is no longer supperted, use a newer mcs.");
-#if MOONLIGHT
- // only "Run" is supported by Silverlight
- // however SMCS requires more than this but runs outside the CoreCLR sandbox
- if (SecurityManager.SecurityEnabled && (access != AssemblyBuilderAccess.Run))
- throw new ArgumentException ("access");
-#endif
-
if (!Enum.IsDefined (typeof (AssemblyBuilderAccess), access))
throw new ArgumentException (string.Format (CultureInfo.InvariantCulture,
"Argument value {0} is not valid.", (int) access),
throw new NotImplementedException ();
}
-#if NET_4_0 || MOONLIGHT || MOBILE
+#if NET_4_0 || MOBILE
public override Type GetType (string name, bool throwOnError, bool ignoreCase)
{
if (name == null)
throw new NotImplementedException ();
}
-#if NET_4_0 || MOONLIGHT
+#if NET_4_0
public override ParameterInfo ReturnParameter {
get { return base.ReturnParameter; }
}
}
if (emitSymbolInfo) {
-#if MOONLIGHT
- symbolWriter = new Mono.CompilerServices.SymbolWriter.SymbolWriterImpl (this);
-#else
Assembly asm = Assembly.LoadWithPartialName ("Mono.CompilerServices.SymbolWriter");
if (asm == null)
throw new TypeLoadException ("The assembly for default symbol writer cannot be loaded");
Type t = asm.GetType ("Mono.CompilerServices.SymbolWriter.SymbolWriterImpl", true);
symbolWriter = (ISymbolWriter) Activator.CreateInstance (t, new object[] { this });
-#endif
string fileName = fqname;
if (assemblyb.AssemblyDir != null)
fileName = Path.Combine (assemblyb.AssemblyDir, fileName);
throw new NotImplementedException ();
}
-#if NET_4_0 || MOONLIGHT || MOBILE
+#if NET_4_0 || MOBILE
public override Assembly Assembly {
get { return assemblyb; }
}
[StructLayout (LayoutKind.Sequential)]
#if MOBILE
public partial class Assembly : ICustomAttributeProvider, _Assembly {
-#elif MOONLIGHT
- public abstract class Assembly : ICustomAttributeProvider, _Assembly {
#elif NET_4_0
public abstract class Assembly : ICustomAttributeProvider, _Assembly, IEvidenceFactory, ISerializable {
#else
private bool fromByteArray;
private string assemblyName;
-#if NET_4_0 || MOONLIGHT || MOBILE
+#if NET_4_0 || MOBILE
protected
#else
internal
[MethodImplAttribute (MethodImplOptions.InternalCall)]
get;
}
-#if !MOONLIGHT
+
public virtual Evidence Evidence {
[SecurityPermission (SecurityAction.Demand, ControlEvidence = true)]
get { return UnprotectedGetEvidence (); }
[MethodImplAttribute (MethodImplOptions.InternalCall)]
internal extern bool get_global_assembly_cache ();
-#endif
internal bool FromByteArray {
set { fromByteArray = value; }
}
string location = Path.GetDirectoryName (Location);
string filename = Path.Combine (location, info.FileName);
-#if MOONLIGHT
- // we don't control the content of 'info.FileName' so we want to make sure we keep to ourselves
- filename = Path.GetFullPath (filename);
- if (!filename.StartsWith (location))
- throw new SecurityException ("non-rooted access to manifest resource");
-#endif
return new FileStream (filename, FileMode.Open, FileAccess.Read);
}
// Try the assembly directory
string location = Path.GetDirectoryName (Location);
string fullName = Path.Combine (location, Path.Combine (culture.Name, aname.Name + ".dll"));
-#if MOONLIGHT
- // it's unlikely that culture.Name or aname.Name could contain stuff like ".." but...
- fullName = Path.GetFullPath (fullName);
- if (!fullName.StartsWith (location)) {
- if (throwOnError)
- throw new SecurityException ("non-rooted access to satellite assembly");
- return null;
- }
-#endif
if (!throwOnError && !File.Exists (fullName))
return null;
[MonoTODO ("Not implemented")]
public
-#if NET_4_0 || MOONLIGHT || MOBILE
+#if NET_4_0 || MOBILE
virtual
#endif
Module LoadModule (string moduleName, byte [] rawModule, byte [] rawSymbolStore)
}
public
-#if NET_4_0 || MOONLIGHT || MOBILE
+#if NET_4_0 || MOBILE
virtual
#endif
Object CreateInstance (String typeName, Boolean ignoreCase,
[MonoTODO ("Currently it always returns zero")]
[ComVisible (false)]
public
-#if NET_4_0 || MOONLIGHT || MOBILE
+#if NET_4_0 || MOBILE
virtual
#endif
long HostContext {
#endif
-#if NET_4_0 || MOONLIGHT || MOBILE
+#if NET_4_0 || MOBILE
static Exception CreateNIE ()
{
return new NotImplementedException ("Derived classes must implement it");
public abstract EventAttributes Attributes {get;}
public
-#if NET_4_0 || MOONLIGHT
+#if NET_4_0
virtual
#endif
Type EventHandlerType {
}
public
-#if NET_4_0 || MOONLIGHT
+#if NET_4_0
virtual
#endif
bool IsMulticast {get {return true;}}
[DebuggerHidden]
[DebuggerStepThrough]
public
-#if NET_4_0 || MOONLIGHT
+#if NET_4_0
virtual
#endif
void AddEventHandler (object target, Delegate handler)
[DebuggerHidden]
[DebuggerStepThrough]
public
-#if NET_4_0 || MOONLIGHT
+#if NET_4_0
virtual
#endif
void RemoveEventHandler (object target, Delegate handler)
return Type.EmptyTypes;
}
-#if !NET_4_0 && !MOONLIGHT
+#if !NET_4_0
public override bool IsGenericMethod {
get {
return false;
[Serializable]
[ClassInterfaceAttribute (ClassInterfaceType.None)]
[StructLayout (LayoutKind.Sequential)]
-#if NET_4_0 || MOONLIGHT || MOBILE
+#if NET_4_0 || MOBILE
public abstract class Module : ISerializable, ICustomAttributeProvider, _Module {
#else
public partial class Module : ISerializable, ICustomAttributeProvider, _Module {
const BindingFlags defaultBindingFlags =
BindingFlags.Public | BindingFlags.Static | BindingFlags.Instance;
-#if NET_4_0 || MOONLIGHT || MOBILE
+#if NET_4_0 || MOBILE
protected
#else
internal
#endif
-#if NET_4_0 || MOONLIGHT || MOBILE
+#if NET_4_0 || MOBILE
public virtual Assembly Assembly {
get { throw CreateNIE (); }
namespace System.Reflection {
-#if NET_4_0 || MOONLIGHT || MOBILE
+#if NET_4_0 || MOBILE
[ComVisible (true)]
[ComDefaultInterfaceAttribute (typeof (_Assembly))]
[Serializable]
public partial class Assembly {
#endif
public
-#if NET_4_0 || MOONLIGHT || MOBILE
+#if NET_4_0 || MOBILE
override
#endif
Type GetType (string name, bool throwOnError, bool ignoreCase)
throw new ArgumentException ("name", "Name cannot be empty");
res = InternalGetType (null, name, throwOnError, ignoreCase);
-#if !(NET_4_0 || MOONLIGHT || MOBILE) && !FULL_AOT_RUNTIME
+#if !(NET_4_0 || MOBILE) && !FULL_AOT_RUNTIME
if (res is TypeBuilder) {
if (throwOnError)
throw new TypeLoadException (string.Format ("Could not load type '{0}' from assembly '{1}'", name, this));
}
public
-#if NET_4_0 || MOONLIGHT || MOBILE
+#if NET_4_0 || MOBILE
override
#endif
Module GetModule (String name)
}
public
-#if NET_4_0 || MOONLIGHT || MOBILE
+#if NET_4_0 || MOBILE
override
#endif
AssemblyName[] GetReferencedAssemblies () {
}
public
-#if NET_4_0 || MOONLIGHT || MOBILE
+#if NET_4_0 || MOBILE
override
#endif
Module[] GetModules (bool getResourceModules) {
[MonoTODO ("Always returns the same as GetModules")]
public
-#if NET_4_0 || MOONLIGHT || MOBILE
+#if NET_4_0 || MOBILE
override
#endif
Module[] GetLoadedModules (bool getResourceModules)
}
public
-#if NET_4_0 || MOONLIGHT || MOBILE
+#if NET_4_0 || MOBILE
override
#endif
Assembly GetSatelliteAssembly (CultureInfo culture)
}
public
-#if NET_4_0 || MOONLIGHT || MOBILE
+#if NET_4_0 || MOBILE
override
#endif
Assembly GetSatelliteAssembly (CultureInfo culture, Version version)
//FIXME remove GetManifestModule under v4, it's a v2 artifact
[ComVisible (false)]
public
-#if NET_4_0 || MOONLIGHT || MOBILE
+#if NET_4_0 || MOBILE
override
#endif
Module ManifestModule {
}
}
-#if !MOONLIGHT
public
#if NET_4_0
override
return get_global_assembly_cache ();
}
}
-#endif
-
}
}
namespace System.Reflection {
-#if NET_4_0 || MOONLIGHT || MOBILE
+#if NET_4_0 || MOBILE
[ComVisible (true)]
[ComDefaultInterfaceAttribute (typeof (_Module))]
[Serializable]
#endif
public
-#if NET_4_0 || MOONLIGHT || MOBILE
+#if NET_4_0 || MOBILE
override
#endif
Assembly Assembly {
}
public
-#if NET_4_0 || MOONLIGHT || MOBILE
+#if NET_4_0 || MOBILE
override
#endif
// Note: we do not ask for PathDiscovery because no path is returned here.
}
public
-#if NET_4_0 || MOONLIGHT || MOBILE
+#if NET_4_0 || MOBILE
override
#endif
string ScopeName {
}
public
-#if NET_4_0 || MOONLIGHT || MOBILE
+#if NET_4_0 || MOBILE
override
#endif
int MDStreamVersion {
}
public
-#if NET_4_0 || MOONLIGHT || MOBILE
+#if NET_4_0 || MOBILE
override
#endif
Guid ModuleVersionId {
}
}
-#if NET_4_0 || MOONLIGHT || MOBILE
+#if NET_4_0 || MOBILE
public override
#else
public virtual
}
public
-#if NET_4_0 || MOONLIGHT || MOBILE
+#if NET_4_0 || MOBILE
override
#endif
bool IsResource()
return is_resource;
}
-#if NET_4_0 || MOONLIGHT || MOBILE
+#if NET_4_0 || MOBILE
public override
#else
public virtual
return filtered.ToArray ();
}
-#if NET_4_0 || MOONLIGHT || MOBILE
+#if NET_4_0 || MOBILE
public override
#else
public virtual
return MonoCustomAttrs.GetCustomAttributes (this, inherit);
}
-#if NET_4_0 || MOONLIGHT || MOBILE
+#if NET_4_0 || MOBILE
public override
#else
public virtual
return MonoCustomAttrs.GetCustomAttributes (this, attributeType, inherit);
}
-#if NET_4_0 || MOONLIGHT || MOBILE
+#if NET_4_0 || MOBILE
public override
#else
public virtual
return (globalType != null) ? globalType.GetField (name, bindingAttr) : null;
}
-#if NET_4_0 || MOONLIGHT || MOBILE
+#if NET_4_0 || MOBILE
public override
#else
public virtual
return (globalType != null) ? globalType.GetFields (bindingFlags) : new FieldInfo [0];
}
-#if NET_4_0 || MOONLIGHT || MOBILE
+#if NET_4_0 || MOBILE
public override
#else
public virtual
get { return get_MetadataToken (this); }
}
protected
-#if NET_4_0 || MOONLIGHT || MOBILE
+#if NET_4_0 || MOBILE
override
#else
virtual
}
public
-#if NET_4_0 || MOONLIGHT || MOBILE
+#if NET_4_0 || MOBILE
override
#endif
MethodInfo[] GetMethods (BindingFlags bindingFlags) {
return (globalType != null) ? globalType.GetMethods (bindingFlags) : new MethodInfo [0];
}
-#if NET_4_0 || MOONLIGHT || MOBILE
+#if NET_4_0 || MOBILE
public override
#else
public virtual
ModuleHandle.GetPEKind (out peKind, out machine);
}
-#if NET_4_0 || MOONLIGHT || MOBILE
+#if NET_4_0 || MOBILE
public override
#else
public virtual
return assembly.InternalGetType (this, className, throwOnError, ignoreCase);
}
-#if NET_4_0 || MOONLIGHT || MOBILE
+#if NET_4_0 || MOBILE
public override
#else
public virtual
}
public
-#if NET_4_0 || MOONLIGHT || MOBILE
+#if NET_4_0 || MOBILE
override
#endif
FieldInfo ResolveField (int metadataToken, Type [] genericTypeArguments, Type [] genericMethodArguments) {
}
public
-#if NET_4_0 || MOONLIGHT || MOBILE
+#if NET_4_0 || MOBILE
override
#endif
MemberInfo ResolveMember (int metadataToken, Type [] genericTypeArguments, Type [] genericMethodArguments) {
}
public
-#if NET_4_0 || MOONLIGHT || MOBILE
+#if NET_4_0 || MOBILE
override
#endif
MethodBase ResolveMethod (int metadataToken, Type [] genericTypeArguments, Type [] genericMethodArguments) {
}
public
-#if NET_4_0 || MOONLIGHT || MOBILE
+#if NET_4_0 || MOBILE
override
#endif
string ResolveString (int metadataToken) {
}
public
-#if NET_4_0 || MOONLIGHT || MOBILE
+#if NET_4_0 || MOBILE
override
#endif
Type ResolveType (int metadataToken, Type [] genericTypeArguments, Type [] genericMethodArguments) {
}
public
-#if NET_4_0 || MOONLIGHT || MOBILE
+#if NET_4_0 || MOBILE
override
#endif
byte[] ResolveSignature (int metadataToken) {
}
#endif
-#if NET_4_0 || MOONLIGHT || MOBILE
+#if NET_4_0 || MOBILE
public override
#else
public virtual
return InternalGetTypes ();
}
-#if NET_4_0 || MOONLIGHT || MOBILE
+#if NET_4_0 || MOBILE
public override IList<CustomAttributeData> GetCustomAttributesData () {
return CustomAttributeData.GetCustomAttributes (this);
}
extern int GetMetadataToken ();
public
-#if NET_4_0 || MOONLIGHT
+#if NET_4_0
virtual
#endif
int MetadataToken {
private string GetResourceFilePath (CultureInfo culture)
{
-#if !MOONLIGHT
if (resourceDir != null)
return Path.Combine (resourceDir, GetResourceFileName (culture));
else
-#endif
return GetResourceFileName (culture);
}
[ComVisible (true)]
public class ResourceSet : IDisposable, IEnumerable
{
-#if !MOONLIGHT
[NonSerialized]
-#endif
protected IResourceReader Reader;
protected Hashtable Table;
bool resources_read;
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-#if NET_4_0 || MOONLIGHT || MOBILE
+#if NET_4_0 || MOBILE
using System;
using System.Collections;
{
public static class ContractHelper
{
-#if MOONLIGHT
- const string SystemWindowsBrowser = ", System.Windows.Browser, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e";
- const string HtmlPage = "System.Windows.Browser.HtmlPage" + SystemWindowsBrowser;
- const string HtmlWindow = "System.Windows.Browser.HtmlWindow" + SystemWindowsBrowser;
- static MethodInfo alert;
- static object window;
-
- static ContractHelper ()
- {
- Type htmlpage = Type.GetType (HtmlPage);
- MethodInfo get_window = htmlpage.GetMethod ("get_Window", BindingFlags.Static | BindingFlags.Public);
- window = get_window.Invoke (null, null);
- Type htmlwindow = Type.GetType (HtmlWindow);
- alert = htmlwindow.GetMethod ("Alert", BindingFlags.Instance | BindingFlags.Public);
- }
-#endif
-
[ReliabilityContract (Consistency.WillNotCorruptState, Cer.MayFail)]
[DebuggerNonUserCode]
public static string RaiseContractFailedEvent (ContractFailureKind failureKind, string userMessage, string conditionText, Exception innerException)
if (displayMessage != null) {
msg.Append (displayMessage);
}
-#if MOONLIGHT
- // Silverlight shows a dialog that let you Abort (kill process/browser), Retry or Ignore
- // Moonlight will simply warn and ignore (at least until FailFast is implemented)
- // using reflection into System.Windows.Browser to popup an browser alert
- alert.Invoke (window, new object [] { msg.ToString () });
-#else
if (Environment.UserInteractive) {
// FIXME: This should trigger an assertion.
// But code will never get here at the moment, as Environment.UserInteractive currently
// Note that FailFast() currently throws a NotImplementedException()
Environment.FailFast(msg.ToString()/*, new ExecutionEngineException()*/);
}
-#endif
}
}
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-#if NET_4_0 || MOONLIGHT || MOBILE
+#if NET_4_0 || MOBILE
using System;
using System.Runtime.InteropServices;
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-#if NET_4_0 || MOONLIGHT || MOBILE
+#if NET_4_0 || MOBILE
namespace System.Runtime.CompilerServices
{
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-#if NET_4_0 || MOONLIGHT
+#if NET_4_0
namespace System.Runtime.ExceptionServices
{
using System.Threading;
using System.Runtime.ConstrainedExecution;
-#if !MOONLIGHT
#if !FULL_AOT_RUNTIME
using System.Runtime.InteropServices.ComTypes;
using Mono.Interop;
#endif
-#endif
namespace System.Runtime.InteropServices
{
throw new NotImplementedException ();
}
-#if !FULL_AOT_RUNTIME && !MOONLIGHT
+#if !FULL_AOT_RUNTIME
public static object CreateWrapperOfType (object o, Type t)
{
__ComObject co = o as __ComObject;
FreeHGlobal (s);
}
-#if !FULL_AOT_RUNTIME && !MOONLIGHT
+#if !FULL_AOT_RUNTIME
public static Guid GenerateGuidForType (Type type)
{
return type.GUID;
return m.GetHINSTANCE ();
}
-#endif // !MOONLIGHT
+#endif // !FULL_AOT_RUNTIME
#if !FULL_AOT_RUNTIME
[MonoTODO ("SetErrorInfo")]
{
throw new NotImplementedException ();
}
-#if !MOONLIGHT
+
[MethodImplAttribute (MethodImplOptions.InternalCall)]
private extern static IntPtr GetIDispatchForObjectInternal (object o);
{
throw new NotImplementedException ();
}
-#endif // !NET_2_1
#endif
[MethodImplAttribute(MethodImplOptions.InternalCall)]
}
#if !FULL_AOT_RUNTIME
-#if !MOONLIGHT
[MethodImplAttribute (MethodImplOptions.InternalCall)]
private extern static int ReleaseComObjectInternal (object co);
{
throw new NotSupportedException ("MSDN states user code should never need to call this method.");
}
-#endif // !NET_2_1
#endif
[ComVisible (true)]
[MethodImplAttribute(MethodImplOptions.InternalCall)]
public extern static IntPtr StringToHGlobalUni (string s);
-#if !MOONLIGHT
public static IntPtr SecureStringToBSTR (SecureString s)
{
if (s == null)
throw new ArgumentNullException ("s");
return SecureStringToCoTaskMemUnicode (s);
}
-#endif
[ReliabilityContractAttribute (Consistency.WillNotCorruptState, Cer.MayFail)]
[ComVisible (true)]
}
#if !FULL_AOT_RUNTIME
-#if !MOONLIGHT
public static int FinalReleaseComObject (object o)
{
while (ReleaseComObject (o) != 0);
return 0;
}
-#endif
#endif
[MethodImplAttribute(MethodImplOptions.InternalCall)]
private UnmanagedType utype;
public UnmanagedType ArraySubType;
-#if !MOONLIGHT
public VarEnum SafeArraySubType;
-#else
- private int SafeArraySubType;
-#endif
public int SizeConst;
public int IidParameterIndex;
public short SizeParamIndex;
return _constructionActivator;
}
}
-#if !MOONLIGHT
+
public static IMessage Activate (RemotingProxy proxy, ConstructionCall ctorCall)
{
IMessage response;
return response;
}
-#endif
+
public static IMessage RemoteActivate (IConstructionCallMessage ctorCall)
{
try
identity.AttachServerObject ((MarshalByRefObject) obj, Threading.Thread.CurrentContext);
ConstructionCall call = ctorCall as ConstructionCall;
-#if !MOONLIGHT
+
if (ctorCall.ActivationType.IsContextful && call != null && call.SourceProxy != null)
{
call.SourceProxy.AttachIdentity (identity);
RemotingServices.InternalExecuteMessage (target, ctorCall);
}
else
-#endif
ctorCall.MethodBase.Invoke (obj, ctorCall.Args);
return new ConstructionResponse (obj, null, ctorCall);
callback_object.DoCallBack (deleg);
}
-#if !MOONLIGHT
public static LocalDataStoreSlot AllocateDataSlot ()
{
return new LocalDataStoreSlot (false);
ctx.datastore [slot.slot] = data;
}
}
-#endif
}
class DynamicPropertyCollection
Type _activationType;
string _activationTypeName;
bool _isContextOk;
-#if !MOONLIGHT
[NonSerialized] RemotingProxy _sourceProxy;
-#endif
public ConstructionCall (IMessage m): base (m)
{
{
get { return base.Properties; }
}
-#if !MOONLIGHT
+
internal RemotingProxy SourceProxy
{
get { return _sourceProxy; }
set {_sourceProxy = value; }
}
-#endif
}
}
public virtual MarshalByRefObject CreateInstance (Type serverType)
{
-#if MOONLIGHT
- throw new NotImplementedException ();
-#else
RemotingProxy proxy = new RemotingProxy (serverType, ChannelServices.CrossContextUrl, null);
return (MarshalByRefObject) proxy.GetTransparentProxy();
-#endif
}
public virtual RealProxy CreateProxy (ObjRef objRef, Type serverType, object serverObject, Context serverContext)
MonoMethodMessage mMsg = (MonoMethodMessage) msg;
mMsg.LogicalCallContext = CallContext.CreateLogicalCallContext (true);
CallType call_type = mMsg.CallType;
-#if MOONLIGHT
- bool is_remproxy = false;
-#else
bool is_remproxy = (rp is RemotingProxy);
-#endif
out_args = null;
IMethodReturnMessage res_msg = null;
// Check for constructor msg
if (mMsg.MethodBase.IsConstructor)
{
-#if !MOONLIGHT
if (is_remproxy)
res_msg = (IMethodReturnMessage) (rp as RemotingProxy).ActivateRemoteObject ((IMethodMessage) msg);
else
-#endif
msg = new ConstructionCall (rp.GetProxiedType ());
}
internal static object CreateClientProxy (Type objectType, string url, object[] activationAttributes)
{
-#if MOONLIGHT
- throw new NotSupportedException ();
-#else
string activationUrl = url;
if (!activationUrl.EndsWith ("/"))
activationUrl += "/";
RemotingProxy proxy = new RemotingProxy (objectType, activationUrl, activationAttributes);
return proxy.GetTransparentProxy();
-#endif
}
internal static object CreateClientProxy (WellKnownClientTypeEntry entry)
if (att != null)
return att.CreateInstance (type);
}
-#if MOONLIGHT
- throw new NotSupportedException ();
-#else
RemotingProxy proxy = new RemotingProxy (type, ChannelServices.CrossContextUrl, activationAttributes);
return proxy.GetTransparentProxy();
-#endif
}
#if !NET_2_1
internal static object CreateClientProxyForComInterop (Type type)
// Registers the identity
uri_hash [uri] = identity;
-#if !MOONLIGHT
if (proxyType != null)
{
RemotingProxy proxy = new RemotingProxy (proxyType, identity);
clientProxy = proxy.GetTransparentProxy();
identity.ClientProxy = (MarshalByRefObject) clientProxy;
}
-#endif
return identity;
}
}
// TimeStamp does not have a TypeCode, so it is managed as a special
// case in GetTypeCode()
-#if !MOONLIGHT
// This environment variable is only for test and benchmarking purposes.
// By default, mono will always use IL generated class serializers.
string s = Environment.GetEnvironmentVariable("MONO_REFLECTION_SERIALIZER");
if (s == null) s = "no";
UseReflectionSerialization = (s != "no");
-#endif
}
public static bool IsPrimitive (Type type)
int IHashCodeProvider.GetHashCode (object o)
{
-#if !INSIDE_CORLIB && MOONLIGHT
- return o == null ? 0 : o .GetHashCode ();
-#else
return object.InternalGetHashCode (o);
-#endif
}
}
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-#if NET_4_0 || MOONLIGHT
+#if NET_4_0
namespace System.Runtime.Versioning
{
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-#if NET_4_0 || MOONLIGHT
+#if NET_4_0
namespace System.Runtime.Versioning
{
//
using System;
-#if NET_4_0 || MOONLIGHT || MOBILE
+#if NET_4_0 || MOBILE
namespace System.Runtime.Versioning
{
[AttributeUsageAttribute(AttributeTargets.Assembly, AllowMultiple = false, Inherited = false)]
using Mono.Security.X509;
using System.Runtime.Serialization;
-#if !MOONLIGHT
using Mono.Security.Authenticode;
-#endif
namespace System.Security.Cryptography.X509Certificates {
return new X509Certificate (data);
}
-#if !MOONLIGHT
[MonoTODO ("Incomplete - minimal validation in this version")]
public static X509Certificate CreateFromSignedFile (string filename)
{
throw new CryptographicException (Locale.GetText ("{0} isn't signed.", filename));
}
-#endif // NET_2_1
-
// constructors
// special constructor for Publisher (and related classes).
#endif
}
-#if !MOONLIGHT
[SecurityPermission (SecurityAction.Demand, UnmanagedCode = true)]
private void InitFromHandle (IntPtr handle)
{
}
// for 1.x IntPtr.Zero results in an "empty" certificate instance
}
-#endif
public X509Certificate (System.Security.Cryptography.X509Certificates.X509Certificate cert)
{
[ComVisible (true)]
[MonoTODO ("X509ContentType.SerializedCert isn't supported (anywhere in the class)")]
-#if MOONLIGHT
- public partial class X509Certificate {
-#else
public partial class X509Certificate : IDeserializationCallback, ISerializable {
-#endif
private string issuer_name;
private string subject_name;
Import (rawData, password, X509KeyStorageFlags.DefaultKeySet);
}
-#if !MOONLIGHT
[MonoTODO ("SecureString support is incomplete")]
public X509Certificate (byte[] rawData, SecureString password)
{
Import (rawData, password, X509KeyStorageFlags.DefaultKeySet);
}
-#endif
public X509Certificate (byte[] rawData, string password, X509KeyStorageFlags keyStorageFlags)
{
Import (rawData, password, keyStorageFlags);
}
-#if !MOONLIGHT
[MonoTODO ("SecureString support is incomplete")]
public X509Certificate (byte[] rawData, SecureString password, X509KeyStorageFlags keyStorageFlags)
{
Import (rawData, password, keyStorageFlags);
}
-#endif
public X509Certificate (string fileName)
{
Import (fileName, password, X509KeyStorageFlags.DefaultKeySet);
}
-#if !MOONLIGHT
[MonoTODO ("SecureString support is incomplete")]
public X509Certificate (string fileName, SecureString password)
{
Import (fileName, password, X509KeyStorageFlags.DefaultKeySet);
}
-#endif
public X509Certificate (string fileName, string password, X509KeyStorageFlags keyStorageFlags)
{
Import (fileName, password, keyStorageFlags);
}
-#if !MOONLIGHT
[MonoTODO ("SecureString support is incomplete")]
public X509Certificate (string fileName, SecureString password, X509KeyStorageFlags keyStorageFlags)
{
Import (fileName, password, keyStorageFlags);
}
-#endif
public X509Certificate (SerializationInfo info, StreamingContext context)
{
return Export (contentType, pwd);
}
-#if !MOONLIGHT
[MonoTODO ("X509ContentType.Pfx/Pkcs12 and SerializedCert are not supported. SecureString support is incomplete.")]
public virtual byte[] Export (X509ContentType contentType, SecureString password)
{
byte[] pwd = (password == null) ? null : password.GetBuffer ();
return Export (contentType, pwd);
}
-#endif
internal byte[] Export (X509ContentType contentType, byte[] password)
{
switch (contentType) {
case X509ContentType.Cert:
return x509.RawData;
-#if !MOONLIGHT
case X509ContentType.Pfx: // this includes Pkcs12
// TODO
throw new NotSupportedException ();
case X509ContentType.SerializedCert:
// TODO
throw new NotSupportedException ();
-#endif
default:
string msg = Locale.GetText ("This certificate format '{0}' cannot be exported.", contentType);
throw new CryptographicException (msg);
}
}
-#if !MOONLIGHT
[MonoTODO ("SecureString support is incomplete")]
public virtual void Import (byte[] rawData, SecureString password, X509KeyStorageFlags keyStorageFlags)
{
Import (rawData, (string)null, keyStorageFlags);
}
-#endif
[ComVisible (false)]
public virtual void Import (string fileName)
Import (rawData, password, keyStorageFlags);
}
-#if !MOONLIGHT
[MonoTODO ("SecureString support is incomplete, missing KeyStorageFlags support")]
public virtual void Import (string fileName, SecureString password, X509KeyStorageFlags keyStorageFlags)
{
byte[] rawData = Load (fileName);
Import (rawData, (string)null, keyStorageFlags);
}
-#endif
-#if !MOONLIGHT
void IDeserializationCallback.OnDeserialization (object sender)
{
}
// will throw a NRE if info is null (just like MS implementation)
info.AddValue ("RawData", x509.RawData);
}
-#endif
+
[ComVisible (false)]
public virtual void Reset ()
{
enum X509ContentType {
Unknown,
Cert,
-#if !MOONLIGHT
// not supported by Silverlight 2.0 (NET_2_1)
SerializedCert,
Pfx,
Pkcs7,
Authenticode,
Pkcs12 = Pfx
-#endif
}
}
[ComVisible (true)]
public enum X509KeyStorageFlags {
DefaultKeySet = 0,
-#if !MOONLIGHT
// not supported by Silverlight 2.0 (NET_2_1)
UserKeySet = 1,
MachineKeySet = 2,
Exportable = 4,
UserProtected = 8,
PersistKeySet = 16
-#endif
}
}
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-#if !MOONLIGHT && !FULL_AOT_RUNTIME
+#if !FULL_AOT_RUNTIME
using System.Collections;
using System.Collections.Generic;
}
return num;
}
-#if MOONLIGHT
- // we need SHA1 support to verify the codecs binary integrity
- public static string MapNameToOID (string name)
- {
- if ((name != null) && name.Contains ("SHA1"))
- return "1.3.14.3.2.26";
- return String.Empty;
- }
-
- private const string AES = "System.Security.Cryptography.AesManaged, System.Core, Version=2.0.5.0, Culture=neutral, PublicKeyToken=b77a5c561934e089";
-
- // non-configurable (versus machine.config) mappings for Moonlight (to avoid loading custom code)
- public static object CreateFromName (string name)
- {
- switch (name) {
- case "System.Security.Cryptography.HashAlgorithm":
- case "System.Security.Cryptography.SHA1":
- case "SHA1":
- return new SHA1Managed ();
- case "SHA256":
- return new SHA256Managed ();
- case "System.Security.Cryptography.MD5":
- case "MD5":
- return new MD5CryptoServiceProvider ();
- case "System.Security.Cryptography.RandomNumberGenerator":
- return new RNGCryptoServiceProvider ();
- case "System.Security.Cryptography.RSA":
- return new Mono.Security.Cryptography.RSAManaged ();
- case "AES":
- case AES:
- return (Aes) Activator.CreateInstance (Type.GetType (AES), null);
- default:
- throw new NotImplementedException (name);
- }
- }
-#endif
}
}
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-#if !MOONLIGHT
-
using System.IO;
using System.Globalization;
using System.Runtime.InteropServices;
}
}
}
-
-#endif
-
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-#if !MOONLIGHT
-
using System.Runtime.InteropServices;
using Mono.Security.Cryptography;
}
}
}
-
-#endif
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-#if !MOONLIGHT
-
using System.Runtime.InteropServices;
using Mono.Security.Cryptography;
}
}
}
-
-#endif
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-#if !MOONLIGHT
-
using System.Runtime.InteropServices;
using Mono.Security.Cryptography;
}
}
}
-
-#endif
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-#if !MOONLIGHT
-
using System.Runtime.InteropServices;
using Mono.Security.Cryptography;
}
}
}
-
-#endif
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-#if !MOONLIGHT
-
using System.Runtime.InteropServices;
using Mono.Security.Cryptography;
}
}
}
-
-#endif
-
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-#if !MOONLIGHT
-
using System.Runtime.InteropServices;
namespace System.Security.Cryptography {
}
}
}
-
-#endif
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-#if !MOONLIGHT
-
using System.Runtime.InteropServices;
namespace System.Security.Cryptography {
private const int BLOCK_SIZE_BYTES = 64;
}
}
-
-#endif
}
}
-#if NET_4_0 || MOONLIGHT
+#if NET_4_0
protected override void Dispose (bool disposing)
{
base.Dispose (disposing);
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-#if !MOONLIGHT
-
using System.IO;
using System.Runtime.InteropServices;
}
}
}
-
-#endif
-
#endif
-#if NET_4_0 || MOONLIGHT
+#if NET_4_0
public void Dispose ()
{
Dispose (true);
-//\r
-// System.Security.Cryptography.Rijndael.cs\r
-//\r
-// Authors: Dan Lewis (dihlewis@yahoo.co.uk)\r
-// Andrew Birkett (andy@nobugs.org)\r
-//\r
-// (C) 2002\r
+//
+// System.Security.Cryptography.Rijndael.cs
+//
+// Authors: Dan Lewis (dihlewis@yahoo.co.uk)
+// Andrew Birkett (andy@nobugs.org)
+//
+// (C) 2002
// Copyright (C) 2004-2006 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-#if !MOONLIGHT
-\r
using System.Runtime.InteropServices;
-\r
-namespace System.Security.Cryptography {\r
+
+namespace System.Security.Cryptography {
// References:
// a. FIPS PUB 197: Advanced Encryption Standard
// http://csrc.nist.gov/publications/fips/fips197/fips-197.pdf
-\r
+
[ComVisible (true)]
- public abstract class Rijndael : SymmetricAlgorithm {\r
-\r
- public static new Rijndael Create () \r
- {\r
+ public abstract class Rijndael : SymmetricAlgorithm {
+
+ public static new Rijndael Create ()
+ {
#if FULL_AOT_RUNTIME
return new System.Security.Cryptography.RijndaelManaged ();
#else
- return Create ("System.Security.Cryptography.Rijndael");\r
+ return Create ("System.Security.Cryptography.Rijndael");
#endif
- }\r
-\r
- public static new Rijndael Create (string algName) \r
- {\r
- return (Rijndael) CryptoConfig.CreateFromName (algName);\r
- }\r
+ }
+
+ public static new Rijndael Create (string algName)
+ {
+ return (Rijndael) CryptoConfig.CreateFromName (algName);
+ }
protected Rijndael ()
- {\r
- KeySizeValue = 256;\r
- BlockSizeValue = 128;\r
- FeedbackSizeValue = 128;\r
- \r
- LegalKeySizesValue = new KeySizes [1];\r
- LegalKeySizesValue [0] = new KeySizes (128, 256, 64);\r
-\r
- LegalBlockSizesValue = new KeySizes [1];\r
- LegalBlockSizesValue [0] = new KeySizes (128, 256, 64);\r
- }\r
- }\r
-}\r
-#endif
+ {
+ KeySizeValue = 256;
+ BlockSizeValue = 128;
+ FeedbackSizeValue = 128;
+
+ LegalKeySizesValue = new KeySizes [1];
+ LegalKeySizesValue [0] = new KeySizes (128, 256, 64);
+ LegalBlockSizesValue = new KeySizes [1];
+ LegalBlockSizesValue [0] = new KeySizes (128, 256, 64);
+ }
+ }
+}
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-#if !MOONLIGHT
-
using System.Runtime.InteropServices;
using Mono.Security.Cryptography;
}
}
}
-
-#endif
-
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-#if !MOONLIGHT
-
using Mono.Security.Cryptography;
using System.Runtime.InteropServices;
#endregion
}
}
-
-#endif
}
}
-#if !MOONLIGHT
-
[ComVisible (true)]
public sealed class SHA1CryptoServiceProvider : SHA1 {
sha.Initialize ();
}
}
-#endif // NET_2_1
}
-//\r
-// System.Security.Cryptography SHA384 Class implementation\r
-//\r
-// Authors:\r
-// Matthew S. Ford (Matthew.S.Ford@Rose-Hulman.Edu)\r
+//
+// System.Security.Cryptography SHA384 Class implementation
+//
+// Authors:
+// Matthew S. Ford (Matthew.S.Ford@Rose-Hulman.Edu)
// Sebastien Pouliot <sebastien@ximian.com>
-//\r
-// Copyright 2001 by Matthew S. Ford.\r
-// Portions (C) 2002 Motus Technologies Inc. (http://www.motus.com)\r
+//
+// Copyright 2001 by Matthew S. Ford.
+// Portions (C) 2002 Motus Technologies Inc. (http://www.motus.com)
// Copyright (C) 2004-2006 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-#if !MOONLIGHT
-
using System.Runtime.InteropServices;
-\r
-namespace System.Security.Cryptography {\r
+
+namespace System.Security.Cryptography {
[ComVisible (true)]
- public abstract class SHA384 : HashAlgorithm {\r
+ public abstract class SHA384 : HashAlgorithm {
protected SHA384 ()
- {\r
- HashSizeValue = 384;\r
- }\r
-\r
- public static new SHA384 Create () \r
- {\r
+ {
+ HashSizeValue = 384;
+ }
+
+ public static new SHA384 Create ()
+ {
#if FULL_AOT_RUNTIME
return new System.Security.Cryptography.SHA384Managed ();
#else
- return Create ("System.Security.Cryptography.SHA384");\r
+ return Create ("System.Security.Cryptography.SHA384");
#endif
- }\r
- \r
- public static new SHA384 Create (string hashName) \r
- {\r
- return (SHA384) CryptoConfig.CreateFromName (hashName);\r
- }\r
- }\r
-}\r
-#endif
-
+ }
+
+ public static new SHA384 Create (string hashName)
+ {
+ return (SHA384) CryptoConfig.CreateFromName (hashName);
+ }
+ }
+}
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-#if !MOONLIGHT
-
using System.Runtime.InteropServices;
namespace System.Security.Cryptography {
}
}
-
-#endif
-
-//\r
-// System.Security.Cryptography SHA512 Class implementation\r
-//\r
-// Authors:\r
-// Matthew S. Ford (Matthew.S.Ford@Rose-Hulman.Edu)\r
+//
+// System.Security.Cryptography SHA512 Class implementation
+//
+// Authors:
+// Matthew S. Ford (Matthew.S.Ford@Rose-Hulman.Edu)
// Sebastien Pouliot <sebastien@ximian.com>
-//\r
-// Copyright 2001 by Matthew S. Ford.\r
-// Portions (C) 2002 Motus Technologies Inc. (http://www.motus.com)\r
+//
+// Copyright 2001 by Matthew S. Ford.
+// Portions (C) 2002 Motus Technologies Inc. (http://www.motus.com)
// Copyright (C) 2004-2006 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-#if !MOONLIGHT
-
using System.Runtime.InteropServices;
-\r
-namespace System.Security.Cryptography {\r
+
+namespace System.Security.Cryptography {
[ComVisible (true)]
- public abstract class SHA512 : HashAlgorithm {\r
+ public abstract class SHA512 : HashAlgorithm {
protected SHA512 ()
- {\r
- HashSizeValue = 512;\r
- }\r
-\r
- public static new SHA512 Create () \r
- {\r
+ {
+ HashSizeValue = 512;
+ }
+
+ public static new SHA512 Create ()
+ {
#if FULL_AOT_RUNTIME
return new System.Security.Cryptography.SHA512Managed ();
#else
- return Create ("System.Security.Cryptography.SHA512");\r
+ return Create ("System.Security.Cryptography.SHA512");
#endif
- }\r
- \r
- public static new SHA512 Create (string hashName) \r
- {\r
- return (SHA512) CryptoConfig.CreateFromName (hashName);\r
- }\r
- }\r
-}\r
-#endif
-
+ }
+
+ public static new SHA512 Create (string hashName)
+ {
+ return (SHA512) CryptoConfig.CreateFromName (hashName);
+ }
+ }
+}
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-#if !MOONLIGHT
-
using System.Runtime.InteropServices;
namespace System.Security.Cryptography {
}
}
-
-#endif
-
protected byte[] KeyValue;
protected KeySizes[] LegalBlockSizesValue;
protected KeySizes[] LegalKeySizesValue;
-#if MOONLIGHT
- // Silverlight 2.0 only supports CBC
- internal int FeedbackSizeValue;
- internal CipherMode ModeValue;
- internal PaddingMode PaddingValue;
-#else
protected int FeedbackSizeValue;
protected CipherMode ModeValue;
protected PaddingMode PaddingValue;
-#endif
private bool m_disposed;
protected SymmetricAlgorithm ()
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-#if !MOONLIGHT
-
using System.Runtime.InteropServices;
using SSCX = System.Security.Cryptography.X509Certificates;
}
}
}
-
-#endif
-
public enum SecurityAction {
Demand = 2,
Assert = 3,
-#if NET_4_0 || MOONLIGHT
+#if NET_4_0
[Obsolete ("This requests should not be used")]
#endif
Deny = 4,
PermitOnly = 5,
LinkDemand = 6,
InheritanceDemand = 7,
-#if NET_4_0 || MOONLIGHT
+#if NET_4_0
[Obsolete ("This requests should not be used")]
#endif
RequestMinimum = 8,
-#if NET_4_0 || MOONLIGHT
+#if NET_4_0
[Obsolete ("This requests should not be used")]
#endif
RequestOptional = 9,
-#if NET_4_0 || MOONLIGHT
+#if NET_4_0
[Obsolete ("This requests should not be used")]
#endif
RequestRefuse = 10,
using System.Runtime.InteropServices;
using System.Security.Permissions;
using System.Security.Cryptography.X509Certificates;
-
-#if !MOONLIGHT
using Mono.Security.Authenticode;
-#endif
namespace System.Security.Policy {
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-#if !MOONLIGHT
-
using System.IO;
using System.Reflection;
using System.Runtime.InteropServices;
}
}
-
-#endif
-
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-#if !MOONLIGHT
-
using System.Collections;
using System.Globalization;
using System.Reflection;
}
}
}
-
-#endif
-
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-#if !MOONLIGHT
-
using System.Collections; // for IList
using System.Globalization;
using System.IO;
}
}
}
-
-#endif
-
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-#if !MOONLIGHT
-
using System.IO;
using System.Globalization;
using System.Security.Permissions;
}
}
}
-
-#endif
-
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-#if !MOONLIGHT
-
using System.Collections;
using System.Globalization;
using System.Runtime.InteropServices;
}
}
}
-
-#endif
-
namespace System.Security {
[ComVisible (true)]
-#if MOONLIGHT
- public interface IPermission {
-#else
public interface IPermission : ISecurityEncodable {
-#endif
IPermission Copy ();
void Demand ();
}
#pragma warning restore 649
-#if !MOONLIGHT
internal struct SecurityFrame {
private AppDomain _domain;
return al;
}
}
-#endif
}
return true; // always true outside Moonlight
}
- [Conditional ("MOONLIGHT")]
+ [Conditional ("ENABLE_SANDBOX")] //??
internal static void EnsureElevatedPermissions ()
{
// do nothing outside of Moonlight
namespace System.Security {
-#if !MOONLIGHT
[MonoTODO ("Only supported by the runtime when CoreCLR is enabled")]
-#endif
[AttributeUsage (AttributeTargets.Delegate | AttributeTargets.Interface | AttributeTargets.Field | AttributeTargets.Method |
AttributeTargets.Constructor | AttributeTargets.Enum | AttributeTargets.Struct | AttributeTargets.Class, AllowMultiple=false, Inherited=false)]
public sealed class SecuritySafeCriticalAttribute : Attribute {
namespace System.Security {
-#if MOONLIGHT
[MonoTODO ("Only supported by the runtime when CoreCLR is enabled")]
-#endif
[AttributeUsage (AttributeTargets.Assembly, AllowMultiple=false, Inherited=false)]
public sealed class SecurityTransparentAttribute : Attribute {
case UnicodeEncoding.BIG_UNICODE_CODE_PAGE:
return BigEndianUnicode;
-#if !MOONLIGHT
case Latin1Encoding.ISOLATIN_CODE_PAGE:
return ISOLatin1;
-#endif
default: break;
}
-#if !MOONLIGHT
// Try to obtain a code page handler from the I18N handler.
Encoding enc = (Encoding)(InvokeI18N ("GetEncoding", codepage));
if (enc != null) {
enc.is_readonly = true;
return enc;
}
-#endif // !NET_2_1
// We have no idea how to handle this code page.
throw new NotSupportedException
(String.Format ("CodePage {0} not supported", codepage.ToString ()));
return e;
}
-#if !MOONLIGHT
-
public static Encoding GetEncoding (int codepage,
EncoderFallback encoderFallback, DecoderFallback decoderFallback)
{
return e;
}
-#endif // !NET_2_1
-
static EncodingInfo [] encoding_infos;
// FIXME: As everyone would agree, this implementation is so *hacky*
return encoding_infos;
}
-#if !MOONLIGHT
[ComVisible (false)]
public bool IsAlwaysNormalized ()
{
// umm, ASCIIEncoding should have overriden this method, no?
return form == NormalizationForm.FormC && this is ASCIIEncoding;
}
-#endif // NET_2_1
// Get an encoding object for a specific web encoding name.
public static Encoding GetEncoding (string name)
case "utf_32be":
return GetEncoding (UTF32Encoding.BIG_UTF32_CODE_PAGE);
-#if !MOONLIGHT
case "iso_8859_1":
case "latin1":
return GetEncoding (Latin1Encoding.ISOLATIN_CODE_PAGE);
-#endif
}
-#if !MOONLIGHT
// Try to obtain a web encoding handler from the I18N handler.
Encoding enc = (Encoding)(InvokeI18N ("GetEncoding", name));
if (enc != null) {
if (type != null) {
return (Encoding)(Activator.CreateInstance (type));
}
-#endif
// We have no idea how to handle this encoding name.
throw new ArgumentException (String.Format ("Encoding name '{0}' not "
+ "supported", name), "name");
case 3: code_page = UTF8Encoding.UTF8_CODE_PAGE; break;
case 4: code_page = UnicodeEncoding.UNICODE_CODE_PAGE; break;
case 5: code_page = UnicodeEncoding.BIG_UNICODE_CODE_PAGE; break;
-#if !MOONLIGHT
case 6: code_page = Latin1Encoding.ISOLATIN_CODE_PAGE; break;
-#endif
}
defaultEncoding = GetEncoding (code_page);
}
} catch (NotSupportedException) {
-#if MOONLIGHT
- defaultEncoding = UTF8;
-#else
// code_page is not supported on underlying platform
defaultEncoding = UTF8Unmarked;
-#endif
} catch (ArgumentException) {
// code_page_name is not a valid code page, or is
// not supported by underlying OS
-#if MOONLIGHT
- defaultEncoding = UTF8;
-#else
defaultEncoding = UTF8Unmarked;
-#endif
}
defaultEncoding.is_readonly = true;
#endif
}
}
-#if !MOONLIGHT
// Get the ISO Latin1 encoding object.
private static Encoding ISOLatin1
}
}
-#endif
-
// Get the standard UTF-7 encoding object.
#if ECMA_COMPAT
private
return this;
}
-#if NET_4_0 || MOONLIGHT || MOBILE
+#if NET_4_0 || MOBILE
public StringBuilder Clear ()
{
Length = 0;
return this;
}
-#if MOONLIGHT
- internal
-#else
public
-#endif
StringBuilder AppendFormat (string format, object arg0)
{
return AppendFormat (null, format, new object [] { arg0 });
}
-#if MOONLIGHT
- internal
-#else
public
-#endif
StringBuilder AppendFormat (string format, object arg0, object arg1)
{
return AppendFormat (null, format, new object [] { arg0, arg1 });
}
-#if MOONLIGHT
- internal
-#else
public
-#endif
StringBuilder AppendFormat (string format, object arg0, object arg1, object arg2)
{
return AppendFormat (null, format, new object [] { arg0, arg1, arg2 });
, IDisposable
#endif
{
-#if !MOONLIGHT
private SecurityContext _sc;
-#endif
private LogicalCallContext _lcc;
private bool _suppressFlow;
private bool _capture;
internal ExecutionContext (ExecutionContext ec)
{
-#if !MOONLIGHT
if (ec._sc != null)
_sc = new SecurityContext (ec._sc);
-#endif
_suppressFlow = ec._suppressFlow;
_capture = true;
}
return null;
ExecutionContext capture = new ExecutionContext (ec);
-#if !MOONLIGHT
if (SecurityManager.SecurityEnabled)
capture.SecurityContext = SecurityContext.Capture ();
-#endif
#if !MONOTOUCH
capture.LogicalCallContext = CallContext.CreateLogicalCallContext (false);
#endif
}
}
-#if !MOONLIGHT
internal SecurityContext SecurityContext {
get {
if (_sc == null)
}
set { _sc = value; }
}
-#endif
internal bool FlowSuppressed {
get { return _suppressFlow; }
set { _suppressFlow = value; }
ec.FlowSuppressed = false;
}
-#if !MOONLIGHT
[MonoTODO ("only the SecurityContext is considered")]
[SecurityPermission (SecurityAction.LinkDemand, Infrastructure = true)]
public static void Run (ExecutionContext executionContext, ContextCallback callback, object state)
t.ExecutionContext.FlowSuppressed = true;
return new AsyncFlowControl (t, AsyncFlowControlType.Execution);
}
-#endif
}
}
\ No newline at end of file
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-#if NET_4_0 || MOONLIGHT || MOBILE
+#if NET_4_0 || MOBILE
using System;
}
}
-#if NET_4_0 || MOONLIGHT || MOBILE
+#if NET_4_0 || MOBILE
[MethodImplAttribute(MethodImplOptions.InternalCall)]
extern static void try_enter_with_atomic_var (object obj, int millisecondsTimeout, ref bool lockTaken);
{
[ComVisible (true)]
public sealed class RegisteredWaitHandle
-#if !MOONLIGHT
: MarshalByRefObject
-#endif
{
WaitHandle _waitObject;
WaitOrTimerCallback _callback;
[MethodImplAttribute(MethodImplOptions.InternalCall)]
private extern static byte[] ByteArrayToCurrentDomain (byte[] arr);
-#if !MOONLIGHT
static void DeserializePrincipal (Thread th)
{
MemoryStream ms = new MemoryStream (ByteArrayToCurrentDomain (th.Internal._serialized_principal));
th.principal = value;
}
}
-#endif
// Looks up the object associated with the current thread
// this is called by the JIT directly, too
}
}
-#if !MOONLIGHT
// Stores a hash keyed by strings of LocalDataStoreSlot objects
static Hashtable datastorehash;
private static object datastore_lock = new object ();
return(slot);
}
}
-#endif
public static AppDomain GetDomain() {
return AppDomain.CurrentDomain;
{
}
-#if !MOONLIGHT
[Obsolete ("Deprecated in favor of GetApartmentState, SetApartmentState and TrySetApartmentState.")]
public ApartmentState ApartmentState {
get {
TrySetApartmentState (value);
}
}
-#endif // !NET_2_1
//[MethodImplAttribute (MethodImplOptions.InternalCall)]
//private static extern int current_lcid ();
}
}
-#if !MOONLIGHT
public ThreadPriority Priority {
get {
return(ThreadPriority.Lowest);
// FIXME: Implement setter.
}
}
-#endif
public ThreadState ThreadState {
get {
Abort_internal (Internal, null);
}
-#if !MOONLIGHT
[SecurityPermission (SecurityAction.Demand, ControlThread=true)]
public void Abort (object stateInfo)
{
{
Interrupt_internal (Internal);
}
-#endif
// The current thread joins with 'this'. Set ms to 0 to block
// until this actually exits.
return Join_internal (Internal, millisecondsTimeout, Internal.system_thread_handle);
}
-#if !MOONLIGHT
public bool Join(TimeSpan timeout)
{
long ms = (long) timeout.TotalMilliseconds;
return Join_internal (Internal, (int) ms, Internal.system_thread_handle);
}
-#endif
[MethodImplAttribute(MethodImplOptions.InternalCall)]
public extern static void MemoryBarrier ();
-#if !MOONLIGHT
[MethodImplAttribute(MethodImplOptions.InternalCall)]
private extern void Resume_internal();
{
Resume_internal ();
}
-#endif // !NET_2_1
[MethodImplAttribute (MethodImplOptions.InternalCall)]
private extern static void SpinWait_nop ();
}
}
-#if MOONLIGHT
- private void StartInternal ()
- {
- current_thread = this;
-
- try {
- if (threadstart is ThreadStart) {
- ((ThreadStart) threadstart) ();
- } else {
- ((ParameterizedThreadStart) threadstart) (start_obj);
- }
- } catch (ThreadAbortException) {
- // do nothing
- } catch (Exception ex) {
- MoonlightUnhandledException (ex);
- }
- }
-
- static MethodInfo moonlight_unhandled_exception = null;
-
- static internal void MoonlightUnhandledException (Exception e)
- {
- try {
- if (moonlight_unhandled_exception == null) {
- var assembly = System.Reflection.Assembly.Load ("System.Windows, Version=2.0.5.0, Culture=Neutral, PublicKeyToken=7cec85d7bea7798e");
- var application = assembly.GetType ("System.Windows.Application");
- moonlight_unhandled_exception = application.GetMethod ("OnUnhandledException",
- System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static);
- }
- moonlight_unhandled_exception.Invoke (null, new object [] { null, e });
- }
- catch {
- try {
- Console.WriteLine ("Unexpected exception while trying to report unhandled application exception: {0}", e);
- } catch {
- }
- }
- }
-#elif MONOTOUCH
+#if MONOTOUCH
static ConstructorInfo nsautoreleasepool_ctor;
IDisposable GetNSAutoreleasePool ()
throw new SystemException ("Thread creation failed.");
}
-#if !MOONLIGHT
[MethodImplAttribute(MethodImplOptions.InternalCall)]
private extern static void Suspend_internal(InternalThread thread);
{
Suspend_internal (Internal);
}
-#endif // !NET_2_1
[MethodImplAttribute (MethodImplOptions.InternalCall)]
extern private static void SetState (InternalThread thread, ThreadState set);
// Managed and native threads are currently bound together.
}
-#if !MOONLIGHT
public ApartmentState GetApartmentState ()
{
return (ApartmentState)Internal.apartment_state;
return true;
}
-#endif // !NET_2_1
[ComVisible (false)]
public override int GetHashCode ()
Start ();
}
-#if !MOONLIGHT
// NOTE: This method doesn't show in the class library status page because
// it cannot be "found" with the StrongNameIdentityPermission for ECMA key.
// But it's there!
ExecutionContext.SecurityContext.CompressedStack = stack;
}
-#endif
-
void _Thread.GetIDsOfNames ([In] ref Guid riid, IntPtr rgszNames, uint cNames, uint lcid, IntPtr rgDispId)
{
throw new NotImplementedException ();
if (callBack == null)
throw new ArgumentNullException ("callBack");
-#if MOONLIGHT
- callBack = MoonlightHandler (callBack);
-#endif
if (callBack.IsTransparentProxy ()) {
IAsyncResult ar = callBack.BeginInvoke (state, null, null);
if (ar == null)
throw new NotImplementedException ();
}
-#endif
-
-#if MOONLIGHT
- static WaitCallback MoonlightHandler (WaitCallback callback)
- {
- return delegate (object o) {
- try {
- callback (o);
- }
- catch (Exception ex) {
- Thread.MoonlightUnhandledException (ex);
- }
- };
- }
#endif
}
}
{
[ComVisible (true)]
public sealed class Timer
-#if MOONLIGHT
- : IDisposable
-#else
: MarshalByRefObject, IDisposable
-#endif
{
static readonly Scheduler scheduler = Scheduler.Instance;
#region Timer instance fields
list.RemoveAt (i);
count--;
i--;
-#if MOONLIGHT
- ThreadPool.QueueUserWorkItem (TimerCaller, timer);
-#else
ThreadPool.UnsafeQueueUserWorkItem (TimerCaller, timer);
-#endif
long period = timer.period_ms;
long due_time = timer.due_time_ms;
bool no_more = (period == -1 || ((period == 0 || period == Timeout.Infinite) && due_time != Timeout.Infinite));
[ComVisible (true)]
[StructLayout (LayoutKind.Sequential)]
public abstract class WaitHandle
-#if MOONLIGHT
- : IDisposable
-#else
: MarshalByRefObject, IDisposable
-#endif
{
[MethodImplAttribute(MethodImplOptions.InternalCall)]
private static extern bool WaitAll_internal(WaitHandle[] handles, int ms, bool exitContext);
Dispose(true);
}
-#if NET_4_0 || MOBILE || MOONLIGHT
+#if NET_4_0 || MOBILE
public void Dispose ()
#else
void IDisposable.Dispose ()
public delegate void Action <in T1, in T2, in T3, in T4, in T5, in T6> (T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6);
public delegate void Action <in T1, in T2, in T3, in T4, in T5, in T6, in T7> (T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7);
public delegate void Action <in T1, in T2, in T3, in T4, in T5, in T6, in T7, in T8> (T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8);
-#elif MOONLIGHT
- [TypeForwardedFrom (Consts.AssemblySystem_Core)]
- public delegate void Action ();
-
- public delegate void Action <T> (T obj);
- public delegate void Action <T1, T2, T3, T4, T5> (T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5);
- public delegate void Action <T1, T2, T3, T4, T5, T6> (T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6);
- public delegate void Action <T1, T2, T3, T4, T5, T6, T7> (T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7);
- public delegate void Action <T1, T2, T3, T4, T5, T6, T7, T8> (T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8);
#else
public delegate void Action <T> (T obj);
using System.Security.Policy;
using System.Configuration.Assemblies;
using System.Text;
-#if !MOONLIGHT
using System.Runtime.Remoting;
using System.Runtime.Remoting.Activation;
-#endif
namespace System
{
{
}
-#if !MOONLIGHT
[MonoTODO ("No COM support")]
public static ObjectHandle CreateComInstanceFrom (string assemblyName, string typeName)
{
throw new ArgumentNullException ("domain");
return domain.CreateInstance (assemblyName, typeName, ignoreCase, bindingAttr, binder, args, culture, activationAttributes, securityAttributes);
}
-#endif // !NET_2_1
public static T CreateInstance <T> ()
{
}
CheckAbstractType (type);
-#if !MOONLIGHT
if (activationAttributes != null && activationAttributes.Length > 0) {
if (!type.IsMarshalByRef) {
string msg = Locale.GetText ("Type '{0}' doesn't derive from MarshalByRefObject.", type.FullName);
return newOb;
}
}
-#endif
return ctor.Invoke (bindingAttr, binder, args, culture);
}
}
}
-#if !MOONLIGHT
[SecurityPermission (SecurityAction.LinkDemand, RemotingConfiguration = true)]
public static object GetObject (Type type, string url)
{
return RemotingServices.Connect (type, url, state);
}
-#endif
+
[MethodImplAttribute (MethodImplOptions.InternalCall)]
internal static extern object CreateInstanceInternal (Type type);
namespace System {
[ComVisible (true)]
-#if !NET_2_1 || MOONLIGHT
+#if !NET_2_1
[ComDefaultInterface (typeof (_AppDomain))]
#endif
[ClassInterface(ClassInterfaceType.None)]
[StructLayout (LayoutKind.Sequential)]
-#if MOONLIGHT
- public sealed class AppDomain : _AppDomain {
-#elif NET_2_1
+#if NET_2_1
public sealed class AppDomain : MarshalByRefObject, _AppDomain {
#else
public sealed class AppDomain : MarshalByRefObject, _AppDomain, IEvidenceFactory {
[ThreadStatic]
static Hashtable assembly_resolve_in_progress_refonly;
-#if !MOONLIGHT
// CAS
private Evidence _evidence;
private PermissionSet _granted;
[ThreadStatic]
private static IPrincipal _principal;
-#endif
+
static AppDomain default_domain;
private AppDomain ()
get { throw new NotImplementedException (); }
}
#endif
-#if !MOONLIGHT
public string BaseDirectory {
get {
string path = SetupInformationNoCopy.ApplicationBase;
return (SetupInformationNoCopy.ShadowCopyFiles == "true");
}
}
-#endif
[MethodImplAttribute (MethodImplOptions.InternalCall)]
private extern string getFriendlyName ();
return getFriendlyName ();
}
}
-#if !MOONLIGHT
+
public Evidence Evidence {
get {
// if the host (runtime) hasn't provided it's own evidence...
internal PermissionSet GrantedPermissionSet {
get { return _granted; }
}
-#endif
#if NET_4_0
public PermissionSet PermissionSet {
}
}
-#if !MOONLIGHT
-
[Obsolete ("AppDomain.AppendPrivatePath has been deprecated. Please investigate the use of AppDomainSetup.PrivateBinPath instead.")]
[SecurityPermission (SecurityAction.LinkDemand, ControlAppDomain = true)]
public void AppendPrivatePath (string path)
{
return Activator.CreateComInstanceFrom (assemblyFile, typeName, hashValue ,hashAlgorithm);
}
-#endif
#endif
public ObjectHandle CreateInstance (string assemblyName, string typeName)
return base.GetType ();
}
-#if !MOONLIGHT
public override object InitializeLifetimeService ()
{
return null;
}
-#endif
[MethodImplAttribute (MethodImplOptions.InternalCall)]
internal extern Assembly LoadAssembly (string assemblyRef, Evidence securityEvidence, bool refOnly);
assembly.FromByteArray = true;
return assembly;
}
-#if !MOONLIGHT
#if NET_4_0
[Obsolete ("AppDomain policy levels are obsolete")]
#endif
_principal = principal;
}
-#endif
+
[MethodImplAttribute (MethodImplOptions.InternalCall)]
private static extern AppDomain InternalSetDomainByID (int domain_id);
return _process_guid;
}
-#if !MOONLIGHT
-
public static AppDomain CreateDomain (string friendlyName)
{
return CreateDomain (friendlyName, null, null);
return info;
}
-#endif // !NET_2_1
-
+
[MethodImplAttribute (MethodImplOptions.InternalCall)]
private static extern bool InternalIsFinalizingForUnload (int domain_id);
public override string ToString ()
{
-#if !MOONLIGHT
return getFriendlyName ();
-#else
- StringBuilder sb = new StringBuilder ("Name:");
- sb.AppendLine (FriendlyName);
- sb.AppendLine ("There are no context policies.");
- return sb.ToString ();
-#endif
}
private static void ValidateAssemblyName (string name)
get { return _domain_manager; }
}
-#if (!MOONLIGHT)
-
public event ResolveEventHandler ReflectionOnlyAssemblyResolve;
#pragma warning disable 649
return GetAssemblies (true);
}
-#else // MOONLIGHT
-
- public int ExecuteAssemblyByName (string assemblyName)
- {
- // critical code in SL that we're not calling in ML
- throw new NotImplementedException ();
- }
-#endif
-
#if !NET_2_1
void _AppDomain.GetIDsOfNames ([In] ref Guid riid, IntPtr rgszNames, uint cNames, uint lcid, IntPtr rgDispId)
{
}
#endif
-#if NET_4_0 || MOONLIGHT || MOBILE
+#if NET_4_0 || MOBILE
List<string> compatibility_switch;
public bool? IsCompatibilitySwitchSet (string value)
using System.Security;
using System.Runtime.Serialization.Formatters.Binary;
-#if(!MOONLIGHT)
using System.Runtime.Hosting;
using System.Security.Policy;
-#endif
namespace System
{
bool disallow_binding_redirects;
bool disallow_code_downloads;
-#if (!MOONLIGHT)
private ActivationArguments _activationArguments;
AppDomainInitializer domain_initializer;
[NonSerialized]
ApplicationTrust application_trust;
string [] domain_initializer_args;
-#else
- object _activationArguments;
- object domain_initializer; // always null
- [NonSerialized]
- object application_trust; // dummy, always null
- object domain_initializer_args;
-#endif
+
bool disallow_appbase_probe;
byte [] configuration_bytes;
configuration_bytes = setup.configuration_bytes;
}
-#if (!MOONLIGHT)
public AppDomainSetup (ActivationArguments activationArguments)
{
_activationArguments = activationArguments;
{
_activationArguments = new ActivationArguments (activationContext);
}
-#endif
static string GetAppBase (string appBase)
{
application_name = value;
}
}
-#if !MOONLIGHT
+
public string CachePath {
get {
return cache_path;
license_file = value;
}
}
-#endif
+
[MonoLimitation ("In Mono this is controlled by the --share-code flag")]
public LoaderOptimization LoaderOptimization {
get {
loader_optimization = value;
}
}
-#if !MOONLIGHT
+
public string PrivateBinPath {
get {
return private_bin_path;
serialized_non_primitives = ms.ToArray ();
}
-#endif // !NET_2_1
-#if NET_4_0 || MOONLIGHT || MOBILE
+
+#if NET_4_0 || MOBILE
[MonoTODO ("not implemented, does not throw because it's used in testing moonlight")]
public void SetCompatibilitySwitches (IEnumerable<string> switches)
{
[ComVisible (true)]
// FIXME: We are doing way to many double/triple exception checks for the overloaded functions"
public abstract class Array : ICloneable, ICollection, IList, IEnumerable
-#if NET_4_0 || MOONLIGHT || MOBILE
+#if NET_4_0 || MOBILE
, IStructuralComparable, IStructuralEquatable
#endif
{
return new SimpleEnumerator (this);
}
-#if NET_4_0 || MOONLIGHT || MOBILE
+#if NET_4_0 || MOBILE
int IStructuralComparable.CompareTo (object other, IComparer comparer)
{
if (other == null)
private static Stream Open (IntPtr handle, FileAccess access, int bufferSize)
{
-#if MOONLIGHT
- if (SecurityManager.SecurityEnabled && !Debugger.IsAttached && Environment.GetEnvironmentVariable ("MOONLIGHT_ENABLE_CONSOLE") == null)
- return new NullStream ();
-#endif
try {
return new FileStream (handle, access, false, bufferSize, false, bufferSize == 0);
} catch (IOException) {
/// <summary>
/// The ContextStatic attribute is used to flag fields as being unique
/// </summary>
-#if MOONLIGHT
- [Obsolete ("Not supported by the Silverlight runtime", true)]
-#endif
[AttributeUsage (AttributeTargets.Field, Inherited=false)]
[Serializable]
[ComVisible (true)]
return true;
}
-#if NET_4_0 || MOONLIGHT || MOBILE
+#if NET_4_0 || MOBILE
public static bool TryParse<TEnum> (string value, out TEnum result) where TEnum : struct
{
return TryParse (value, false, out result);
}
return retVal;
}
-#if NET_4_0 || MOONLIGHT || MOBILE
+#if NET_4_0 || MOBILE
public bool HasFlag (Enum flag)
{
var val = get_value ();
ProgramFiles = 0x26,
MyPictures = 0x27,
CommonProgramFiles = 0x2b,
-#if NET_4_0 || MOONLIGHT || MOBILE
+#if NET_4_0 || MOBILE
MyVideos = 0x0e,
#endif
#if NET_4_0
case SpecialFolder.Templates:
return ReadXdgUserDir (config, home, "XDG_TEMPLATES_DIR", "Templates");
-#if NET_4_0 || MOONLIGHT || MOBILE
+#if NET_4_0 || MOBILE
case SpecialFolder.MyVideos:
return ReadXdgUserDir (config, home, "XDG_VIDEOS_DIR", "Videos");
#endif
throw new NotImplementedException ();
}
-#if NET_4_0 || MOONLIGHT || MOBILE
+#if NET_4_0 || MOBILE
[SecurityCritical]
public static void FailFast (string message, Exception exception)
{
info.AddValue ("RemoteStackTraceString", _remoteStackTraceString);
info.AddValue ("RemoteStackIndex", remote_stack_index);
info.AddValue ("HResult", hresult);
-#if !MOONLIGHT
info.AddValue ("Source", Source);
-#else
- info.AddValue ("Source", null);
-#endif
info.AddValue ("ExceptionMethod", null);
info.AddValue ("Data", _data, typeof (IDictionary));
}
namespace System
{
-#if NET_4_0 || MOONLIGHT
+#if NET_4_0
[Obsolete]
#endif
[Serializable]
#else
// Used internally
delegate TResult Func<T1, T2, T3, TResult> (T1 arg1, T2 arg2, T3 arg3);
-#if MOONLIGHT
- public delegate TResult Func<T1, T2, T3, T4, TResult> (
- T1 arg1, T2 arg2, T3 arg3, T4 arg4);
-
- public delegate TResult Func<T1, T2, T3, T4, T5, TResult> (
- T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5);
-
- public delegate TResult Func<T1, T2, T3, T4, T5, T6, TResult> (
- T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6);
-
- public delegate TResult Func<T1, T2, T3, T4, T5, T6, T7, TResult> (
- T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7);
-
- public delegate TResult Func<T1, T2, T3, T4, T5, T6, T7, T8, TResult> (
- T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8);
-#endif
#endif
}
}
#endif
-#if NET_4_0 || MOONLIGHT || MOBILE
+#if NET_4_0 || MOBILE
[MethodImplAttribute (MethodImplOptions.InternalCall)]
internal extern static void register_ephemeron_array (Ephemeron[] array);
return !( a.Equals (b) );
}
-#if NET_4_0 || MOONLIGHT || MOBILE
+#if NET_4_0 || MOBILE
public static Guid Parse (string input)
{
if (input == null)
case 'P':
case 'p':
return Format.P;
-#if NET_4_0 || MOONLIGHT || MOBILE
+#if NET_4_0 || MOBILE
case 'X':
case 'x':
return Format.X;
}
throw new FormatException (
-#if NET_4_0 || MOONLIGHT || MOBILE
+#if NET_4_0 || MOBILE
"Format String can be only one of \"D\", \"d\", \"N\", \"n\", \"P\", \"p\", \"B\", \"b\", \"X\" or \"x\""
#else
"Format String can be only one of \"D\", \"d\", \"N\", \"n\", \"P\", \"p\", \"B\" or \"b\""
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
-#if NET_4_0 || MOONLIGHT || MOBILE
+#if NET_4_0 || MOBILE
using System.Runtime.CompilerServices;
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-#if NET_4_0 || MOONLIGHT || MOBILE
+#if NET_4_0 || MOBILE
using System;
using System.Runtime.Serialization;
namespace System
{
-#if MOONLIGHT
- [Obsolete ("STAThreadAttribute is not supported in this release. It has been left in so that legacy tools can be used with this release, but it cannot be used in your code.", true)]
-#endif
[AttributeUsage (AttributeTargets.Method)]
[ComVisible (true)]
public sealed class STAThreadAttribute : Attribute
}
// .NET 2.0 compatibility only
-#if !NET_4_0 && !MOONLIGHT && !MOBILE
+#if !NET_4_0 && !MOBILE
static readonly char[] WhiteChars = {
(char) 0x9, (char) 0xA, (char) 0xB, (char) 0xC, (char) 0xD,
(char) 0x85, (char) 0x1680, (char) 0x2028, (char) 0x2029,
unsafe string[] SplitByCharacters (char[] sep, int count, bool removeEmpty)
{
-#if !NET_4_0 && !MOONLIGHT && !MOBILE
+#if !NET_4_0 && !MOBILE
if (sep == null || sep.Length == 0)
sep = WhiteChars;
#endif
return (value == null) || (value.Length == 0);
}
-#if !MOONLIGHT
public string Normalize ()
{
return Normalization.Normalize (this, 0);
return Normalization.IsNormalized (this, 3);
}
}
-#endif
public string Remove (int startIndex)
{
return InternalIsInterned (str);
}
-#if NET_4_0 || MOONLIGHT || MOBILE
+#if NET_4_0 || MOBILE
public static string Join (string separator, params string [] value)
#else
public static string Join (string separator, string [] value)
}
}
-#if MOONLIGHT || MOBILE || NET_4_0
+#if MOBILE || NET_4_0
[ComVisible(false)]
public static string Concat (IEnumerable<string> values)
{
[Serializable]
[System.Runtime.InteropServices.ComVisible (true)]
public struct TimeSpan : IComparable, IComparable<TimeSpan>, IEquatable <TimeSpan>
-#if NET_4_0 || MOONLIGHT || MOBILE
+#if NET_4_0 || MOBILE
, IFormattable
#endif
{
return p.Execute (true, out result);
}
-#if NET_4_0 || MOONLIGHT || MOBILE
+#if NET_4_0 || MOBILE
public static TimeSpan Parse (string input, IFormatProvider formatProvider)
{
if (input == null)
return sb.ToString ();
}
-#if NET_4_0 || MOONLIGHT || MOBILE
+#if NET_4_0 || MOBILE
public string ToString (string format)
{
return ToString (format, null);
private int _cur = 0;
private int _length;
ParseError parse_error;
-#if NET_4_0 || MOONLIGHT || MOBILE
+#if NET_4_0 || MOBILE
bool parsed_ticks;
NumberFormatInfo number_format;
int parsed_numbers_count;
{
_src = src;
_length = _src.Length;
-#if NET_4_0 || MOONLIGHT || MOBILE
+#if NET_4_0 || MOBILE
number_format = GetNumberFormatInfo (null);
#endif
}
-#if NET_4_0 || MOONLIGHT || MOBILE
+#if NET_4_0 || MOBILE
// Reset state data, so we can execute another parse over the input.
void Reset ()
{
return res;
}
-#if NET_4_0 || MOONLIGHT || MOBILE
+#if NET_4_0 || MOBILE
// Used for custom formats parsing, where we may need to declare how
// many digits we expect, as well as the maximum allowed.
private int ParseIntExact (int digit_count, int max_digit_count)
if (!optional && (count == 0))
SetParseError (ParseError.Format);
-#if NET_4_0 || MOONLIGHT || MOBILE
+#if NET_4_0 || MOBILE
if (count > 0)
parsed_numbers_count++;
#endif
return (int)res;
}
-#if NET_4_0 || MOONLIGHT || MOBILE
+#if NET_4_0 || MOBILE
// This behaves pretty much like ParseOptDot, but we need to have it
// as a separated routine for both days and decimal separators.
private bool ParseOptDaysSeparator ()
if (!digitseen)
SetParseError (ParseError.Format);
-#if NET_4_0 || MOONLIGHT || MOBILE
+#if NET_4_0 || MOBILE
else if (!AtEnd && Char.IsDigit (_src, _cur))
SetParseError (ParseError.Overflow);
return res;
}
-#if NET_4_0 || MOONLIGHT || MOBILE
+#if NET_4_0 || MOBILE
// Used by custom formats parsing
// digits_count = 0 for digits up to max_digits_count (optional), and other value to
// force a precise number of digits.
parse_error = error;
}
-#if NET_4_0 || MOONLIGHT || MOBILE
+#if NET_4_0 || MOBILE
bool CheckParseSuccess (bool tryParse)
#else
bool CheckParseSuccess (int hours, int minutes, int seconds, bool tryParse)
{
// We always report the first error, but for 2.0 we need to give a higher
// precence to per-element overflow (as opposed to int32 overflow).
-#if NET_4_0 || MOONLIGHT || MOBILE
+#if NET_4_0 || MOBILE
if (parse_error == ParseError.Overflow) {
#else
if (parse_error == ParseError.Overflow || hours > 23 || minutes > 59 || seconds > 59) {
return true;
}
-#if NET_4_0 || MOONLIGHT || MOBILE
+#if NET_4_0 || MOBILE
// We are using a different parse approach in 4.0, due to some changes in the behaviour
// of the parse routines.
// The input string is documented as:
}
#endif
-#if NET_4_0 || MOONLIGHT || MOBILE
+#if NET_4_0 || MOBILE
public bool ExecuteWithFormat (string format, TimeSpanStyles style, bool tryParse, out TimeSpan result)
{
int days, hours, minutes, seconds;
}
#endif
}
-#if NET_4_0 || MOONLIGHT || MOBILE
+#if NET_4_0 || MOBILE
enum FormatElementType
{
Days,
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
-#if NET_4_0 || MOONLIGHT || MOBILE
+#if NET_4_0 || MOBILE
using System.Runtime.CompilerServices;
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-#if MOONLIGHT || NET_4_0 || MOBILE
+#if NET_4_0 || MOBILE
using System;
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-#if MOONLIGHT || NET_4_0 || MOBILE
+#if NET_4_0 || MOBILE
using System;
using System.Collections;
// 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 || MOONLIGHT || MOBILE
+#if NET_4_0 || MOBILE
using System.Runtime.Serialization;
using System.Runtime.InteropServices;
return v1.CompareTo (v2) <= 0;
}
-#if BOOSTRAP_NET_4_0 || NET_4_0 || MOONLIGHT || MOBILE
+#if BOOSTRAP_NET_4_0 || NET_4_0 || MOBILE
public static Version Parse (string input)
{
// Exactly the same as calling Version(string) .ctor
[Guid ("05F696DC-2B29-3663-AD8B-C4389CF2A713")]
public interface _AppDomain
{
-#if !MOONLIGHT
string BaseDirectory {get; }
string DynamicDirectory {get; }
Evidence Evidence {get; }
-#endif
string FriendlyName {get; }
-#if !MOONLIGHT
string RelativeSearchPath {get; }
bool ShadowCopyFiles {get; }
[SecurityPermission (SecurityAction.LinkDemand, ControlAppDomain = true)]
void ClearShadowCopyPath ();
-#endif
-#if !MOONLIGHT
ObjectHandle CreateInstance (string assemblyName, string typeName);
ObjectHandle CreateInstance (string assemblyName, string typeName, object[] activationAttributes);
ObjectHandle CreateInstance (string assemblyName, string typeName, bool ignoreCase,
ObjectHandle CreateInstanceFrom (string assemblyFile, string typeName, bool ignoreCase,
BindingFlags bindingAttr, Binder binder, object[] args, CultureInfo culture,
object[] activationAttributes, Evidence securityAttributes);
-#endif
#if !FULL_AOT_RUNTIME
AssemblyBuilder DefineDynamicAssembly (AssemblyName name, AssemblyBuilderAccess access);
#if !NET_4_0
[SecurityPermission (SecurityAction.LinkDemand, Infrastructure = true)]
#endif
-#if !MOONLIGHT
object GetLifetimeService ();
-#endif
Type GetType ();
-#if !MOONLIGHT
[SecurityPermission (SecurityAction.LinkDemand, Infrastructure = true)]
object InitializeLifetimeService ();
-#endif
Assembly Load (AssemblyName assemblyRef);
Assembly Load (byte[] rawAssembly);
Assembly Load (string assemblyString, Evidence assemblySecurity);
Assembly Load (byte[] rawAssembly, byte[] rawSymbolStore, Evidence securityEvidence);
-#if !MOONLIGHT
[SecurityPermission (SecurityAction.LinkDemand, ControlAppDomain = true)]
void SetAppDomainPolicy (PolicyLevel domainPolicy);
[SecurityPermission (SecurityAction.LinkDemand, ControlAppDomain = true)]
void SetCachePath (string s);
-#endif
[SecurityPermission (SecurityAction.LinkDemand, ControlAppDomain = true)]
void SetData (string name, object data);
-#if !MOONLIGHT
void SetPrincipalPolicy (PrincipalPolicy policy);
[SecurityPermission (SecurityAction.LinkDemand, ControlAppDomain = true)]
void SetShadowCopyPath (string s);
void SetThreadPrincipal (IPrincipal principal);
-#endif
string ToString ();
}
-#if NET_4_0 || MOONLIGHT || MOBILE
+#if NET_4_0 || MOBILE
[Test]
public void ClearMethod () {
StringBuilder sb = new StringBuilder ("Text");