mirror of
https://github.com/BepInEx/mono.git
synced 2026-11-17 01:41:17 -10:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
378032bf64 | ||
|
|
a19eb0760b | ||
|
|
5cfc62f415 | ||
|
|
1ed1c4bed1 | ||
|
|
616f648f0d | ||
|
|
4fccd4d599 | ||
|
|
bd4f80e803 | ||
|
|
9e9b3f913d | ||
|
|
a2a168e5f3 | ||
|
|
5f982b1908 | ||
|
|
f00202d3e3 | ||
|
|
b4d4033040 | ||
|
|
68deb6335e | ||
|
|
cb965a9d3a | ||
|
|
86262ef424 | ||
|
|
acfa4856b9 | ||
|
|
be8711a7e6 | ||
|
|
7e6a0ff51e | ||
|
|
c989e10293 | ||
|
|
b04d809478 | ||
|
|
219276c182 | ||
|
|
64ff652330 | ||
|
|
75e3ca80bc | ||
|
|
aa48b6f714 | ||
|
|
2603a2e4fd | ||
|
|
05550e7c66 | ||
|
|
99349445b1 | ||
|
|
d768dd0125 | ||
|
|
e376d9156b | ||
|
|
85349b801f | ||
|
|
41d1be9f34 | ||
|
|
ac19d5bfaf | ||
|
|
ae7d005dfc | ||
|
|
04427d962d | ||
|
|
57bc2f6ffb | ||
|
|
059a6a685b | ||
|
|
4ac77ca819 | ||
|
|
d703e86b4b | ||
|
|
6870a59952 | ||
|
|
721dadd34b | ||
|
|
b7061d3e57 | ||
|
|
2f4099863e | ||
|
|
96e0c59371 | ||
|
|
1e910229a8 | ||
|
|
c74031105a | ||
|
|
279678d726 | ||
|
|
46db32524d | ||
|
|
0563034987 | ||
|
|
0baf32151f | ||
|
|
8bd9eebf1f | ||
|
|
b9a5b85c16 | ||
|
|
c98be1ad12 | ||
|
|
67b1fcec06 | ||
|
|
4643f66d1a | ||
|
|
e3aa857b74 | ||
|
|
350fcbd003 | ||
|
|
c6799b1f41 | ||
|
|
f260ff4299 | ||
|
|
7122b78d60 | ||
|
|
52971cce4c | ||
|
|
5dc77749e7 | ||
|
|
472b3e6fca | ||
|
|
59b4c5bc3d | ||
|
|
f105c6d4e7 | ||
|
|
2e637c4cba | ||
|
|
8d44e61042 | ||
|
|
eac9866b2c | ||
|
|
7ada4aec7b | ||
|
|
dacb11a24c | ||
|
|
5c44041365 | ||
|
|
56b901df8f | ||
|
|
582bd35450 | ||
|
|
6057352d91 | ||
|
|
3b450189bb | ||
|
|
7878c22bbf | ||
|
|
674372dd15 | ||
|
|
af804a9305 | ||
|
|
7e2eff0be7 | ||
|
|
7de999655d | ||
|
|
1b84abfcab | ||
|
|
8286cbf198 | ||
|
|
db7d7c47cb | ||
|
|
9445d6e22c | ||
|
|
209c253e3f | ||
|
|
e449d41158 | ||
|
|
9b4a07a69e | ||
|
|
28766cfe96 | ||
|
|
a95adaf53d | ||
|
|
7ae2112edc | ||
|
|
79b99d358b | ||
|
|
12fedc8ee6 | ||
|
|
27589a4031 | ||
|
|
f12adef20c | ||
|
|
049efb2da8 | ||
|
|
d41b9d61c2 | ||
|
|
71b1f58d41 | ||
|
|
f983186526 | ||
|
|
c726c88f32 | ||
|
|
3cb9ce92bc | ||
|
|
2504797e50 | ||
|
|
67ebb6a498 | ||
|
|
d9e839c91b | ||
|
|
fd65ec9388 | ||
|
|
7a0052ae2f | ||
|
|
ec0e9d7771 | ||
|
|
4325b8151a | ||
|
|
482e406319 | ||
|
|
e421b10a3d | ||
|
|
55c4b01d95 | ||
|
|
a5610cbed1 | ||
|
|
fc9e1be0b3 | ||
|
|
9b9fef57d9 | ||
|
|
99b87f07af | ||
|
|
9a69207087 | ||
|
|
4cfb3889f8 | ||
|
|
0a7f80fb0a | ||
|
|
df66c40aaa | ||
|
|
9b3e4f9034 | ||
|
|
89dad63b0f | ||
|
|
9636231dda | ||
|
|
a2d896ec4e |
No files matched your search
+2
-2
@@ -57,11 +57,11 @@ function setup ()
|
||||
CROSS_DLL_DIR="$CROSS_DIR/bin"
|
||||
PATH=$CROSS_BIN_DIR:$PATH
|
||||
|
||||
MONO_VERSION=`grep AM_INIT_AUTOMAKE configure.in | cut -d ',' -f 2|tr -d '\)'`
|
||||
MONO_VERSION=`grep AM_INIT_AUTOMAKE configure.in | cut -d ',' -f 2|tr -d '\)'|tr -d '\('`
|
||||
|
||||
if [ -d ./.git ]; then
|
||||
MONO_GIT_COMMIT="`git log -1 --format=format:%t`"
|
||||
MONO_GIT_BRANCH="`git branch|grep '\*'|cut -d ' ' -f 2`"
|
||||
MONO_GIT_BRANCH="`git branch|grep '\*'|cut -d ' ' -f 2|tr -d '\)'|tr -d '\('`"
|
||||
MONO_RELEASE="$MONO_VERSION-$MONO_GIT_BRANCH-$MONO_GIT_COMMIT"
|
||||
else
|
||||
MONO_RELEASE="$MONO_VERSION"
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@ AC_CANONICAL_SYSTEM
|
||||
m4_ifdef([_A][M_PROG_TAR],[_A][M_SET_OPTION([tar-ustar])])
|
||||
|
||||
AM_CONFIG_HEADER(config.h)
|
||||
AM_INIT_AUTOMAKE(mono,2.10.3)
|
||||
AM_INIT_AUTOMAKE(mono,2.10.6)
|
||||
AM_MAINTAINER_MODE
|
||||
|
||||
API_VER=2.0
|
||||
|
||||
@@ -58,6 +58,7 @@ case $host in
|
||||
;;
|
||||
*-*-linux-android*)
|
||||
platform_android=yes
|
||||
AC_DEFINE(PLATFORM_ANDROID,1,[Targeting the Android platform])
|
||||
PATHSEP='/'
|
||||
SEARCHSEP=':'
|
||||
OS="UNIX"
|
||||
|
||||
@@ -114,7 +114,9 @@ typedef int32_t gboolean;
|
||||
|
||||
#define G_USEC_PER_SEC 1000000
|
||||
|
||||
#ifndef ABS
|
||||
#define ABS(a) ((a) > 0 ? (a) : -(a))
|
||||
#endif
|
||||
|
||||
#define G_STRUCT_OFFSET(p_type,field) offsetof(p_type,field)
|
||||
|
||||
|
||||
+8
-9
@@ -24,6 +24,7 @@
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
#include <config.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <glib.h>
|
||||
@@ -111,28 +112,26 @@ g_log_set_fatal_mask (const gchar *log_domain, GLogLevelFlags fatal_mask)
|
||||
void
|
||||
g_logv (const gchar *log_domain, GLogLevelFlags log_level, const gchar *format, va_list args)
|
||||
{
|
||||
#if PLATFORM_ANDROID
|
||||
__android_log_vprint (to_android_priority (log_level), log_domain, format, args);
|
||||
#else
|
||||
char *msg;
|
||||
|
||||
vasprintf (&msg, format, args);
|
||||
#if PLATFORM_ANDROID
|
||||
__android_log_print (to_android_priority (log_level),
|
||||
/* TODO: provide a proper app name */
|
||||
"mono", "%s%s%s",
|
||||
log_domain != NULL ? log_domain : "",
|
||||
log_domain != NULL ? ": " : "",
|
||||
msg);
|
||||
#else
|
||||
printf ("%s%s%s\n",
|
||||
log_domain != NULL ? log_domain : "",
|
||||
log_domain != NULL ? ": " : "",
|
||||
msg);
|
||||
#endif
|
||||
free (msg);
|
||||
if (log_level & fatal){
|
||||
fflush (stdout);
|
||||
fflush (stderr);
|
||||
abort ();
|
||||
}
|
||||
#endif
|
||||
if (log_level & fatal){
|
||||
abort ();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -371,6 +371,8 @@ void GC_print_callers GC_PROTO((struct callinfo info[NFRAMES]));
|
||||
# define GC_MACH_THREAD_STATE_FLAVOR PPC_THREAD_STATE
|
||||
# elif defined(I386)
|
||||
# define GC_MACH_THREAD_STATE_FLAVOR i386_THREAD_STATE
|
||||
# elif defined(X86_64)
|
||||
# define GC_MACH_THREAD_STATE_FLAVOR x86_THREAD_STATE64
|
||||
# else
|
||||
# define GC_MACH_THREAD_STATE_FLAVOR MACHINE_THREAD_STATE
|
||||
# endif
|
||||
|
||||
@@ -729,7 +729,7 @@ void nacl_shutdown_gc_thread()
|
||||
/* Caller holds allocation lock. */
|
||||
GC_thread GC_new_thread(pthread_t id)
|
||||
{
|
||||
int hv = ((word)id) % THREAD_TABLE_SZ;
|
||||
int hv = ((unsigned long)id) % THREAD_TABLE_SZ;
|
||||
GC_thread result;
|
||||
static GC_bool first_thread_used = FALSE;
|
||||
|
||||
@@ -760,7 +760,7 @@ GC_thread GC_new_thread(pthread_t id)
|
||||
/* Caller holds allocation lock. */
|
||||
void GC_delete_thread(pthread_t id)
|
||||
{
|
||||
int hv = ((word)id) % THREAD_TABLE_SZ;
|
||||
int hv = ((unsigned long)id) % THREAD_TABLE_SZ;
|
||||
register GC_thread p = GC_threads[hv];
|
||||
register GC_thread prev = 0;
|
||||
|
||||
@@ -796,7 +796,7 @@ void GC_delete_thread(pthread_t id)
|
||||
/* This is OK, but we need a way to delete a specific one. */
|
||||
void GC_delete_gc_thread(pthread_t id, GC_thread gc_id)
|
||||
{
|
||||
int hv = ((word)id) % THREAD_TABLE_SZ;
|
||||
int hv = ((unsigned long)id) % THREAD_TABLE_SZ;
|
||||
register GC_thread p = GC_threads[hv];
|
||||
register GC_thread prev = 0;
|
||||
|
||||
@@ -825,7 +825,7 @@ void GC_delete_gc_thread(pthread_t id, GC_thread gc_id)
|
||||
/* return the most recent one. */
|
||||
GC_thread GC_lookup_thread(pthread_t id)
|
||||
{
|
||||
int hv = ((word)id) % THREAD_TABLE_SZ;
|
||||
int hv = ((unsigned long)id) % THREAD_TABLE_SZ;
|
||||
register GC_thread p = GC_threads[hv];
|
||||
|
||||
while (p != 0 && !pthread_equal(p -> id, id)) p = p -> next;
|
||||
|
||||
@@ -26,6 +26,8 @@ PLATFORM_MAKE_CORLIB_CMP = yes
|
||||
PLATFORM_CHANGE_SEPARATOR_CMD=tr '/' '\\\\'
|
||||
PLATFORM_PATH_SEPARATOR = ;
|
||||
|
||||
override CURDIR:=$(shell cygpath -m $(CURDIR))
|
||||
|
||||
## not so simple :-)
|
||||
#PLATFORM_AOT_SUFFIX = .dll
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ EXTRA_DISTFILES = \
|
||||
$(RESOURCE_FILES)
|
||||
|
||||
Commons.Xml.Relaxng.Rnc/RncParser.cs: Commons.Xml.Relaxng.Rnc/RncParser.jay $(topdir)/jay/skeleton.cs
|
||||
$(topdir)/jay/jay -ctv < $(topdir)/jay/skeleton.cs Commons.Xml.Relaxng.Rnc/RncParser.jay > Commons.Xml.Relaxng.Rnc/RncParser.cs
|
||||
$(topdir)/jay/jay -ctv < $(topdir)/jay/skeleton.cs $(CURDIR)/Commons.Xml.Relaxng.Rnc/RncParser.jay > Commons.Xml.Relaxng.Rnc/RncParser.cs
|
||||
|
||||
BUILT_SOURCES = Commons.Xml.Relaxng.Rnc/RncParser.cs
|
||||
|
||||
|
||||
@@ -28,13 +28,13 @@ Mono.Xml.XPath2/XQueryParser.jay: Mono.Xml.XPath2/ParserBase.jay $(SKELETON)
|
||||
Mono.Xml.XPath2/XPath2Parser.cs: Mono.Xml.XPath2/XPath2Parser.jay
|
||||
echo "#define XPATH2_PARSER" > $@
|
||||
echo "#if NET_2_0" >> $@
|
||||
$(topdir)/jay/jay -ct < $(SKELETON) $< >>$@
|
||||
$(topdir)/jay/jay -ct < $(SKELETON) $(CURDIR)/$< >>$@
|
||||
echo "#endif" >> $@
|
||||
|
||||
Mono.Xml.XPath2/XQueryParser.cs: Mono.Xml.XPath2/XQueryParser.jay $(SKELETON)
|
||||
echo "#define XQUERY_PARSER" > $@
|
||||
echo "#if NET_2_0" >> $@
|
||||
$(topdir)/jay/jay -ct < $(SKELETON) $< >>$@
|
||||
$(topdir)/jay/jay -ct < $(SKELETON) $(CURDIR)/$< >>$@
|
||||
echo "#endif" >> $@
|
||||
|
||||
Mono.Xml.XPath2/XPath2Tokenizer.cs: Mono.Xml.XPath2/TokenizerBase.cs
|
||||
|
||||
@@ -329,6 +329,9 @@ namespace System
|
||||
#if MONODROID
|
||||
return ZoneInfoDB.GetTimeZone (id);
|
||||
#elif LIBC
|
||||
// Local requires special logic that already exists in the Local property (bug #326)
|
||||
if (id == "Local")
|
||||
return Local;
|
||||
string filepath = Path.Combine (TimeZoneDirectory, id);
|
||||
return FindSystemTimeZoneByFileName (id, filepath);
|
||||
#else
|
||||
|
||||
@@ -540,6 +540,20 @@ namespace MonoTests.System
|
||||
TimeZoneInfo vatican = TimeZoneInfo.FindSystemTimeZoneById ("Europe/Vatican");
|
||||
Assert.IsTrue (rome.HasSameRules (vatican));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void FindSystemTimeZoneById_Local_Roundtrip ()
|
||||
{
|
||||
Assert.AreEqual (TimeZoneInfo.Local.Id, TimeZoneInfo.FindSystemTimeZoneById (TimeZoneInfo.Local.Id).Id);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test326 ()
|
||||
{
|
||||
DateTime utc = DateTime.UtcNow;
|
||||
DateTime local = TimeZoneInfo.ConvertTime (utc, TimeZoneInfo.Utc, TimeZoneInfo.FindSystemTimeZoneById (TimeZoneInfo.Local.Id));
|
||||
Assert.AreEqual (local, utc + TimeZoneInfo.Local.GetUtcOffset (utc), "ConvertTime/Local");
|
||||
}
|
||||
|
||||
#if SLOW_TESTS
|
||||
[Test]
|
||||
|
||||
@@ -263,15 +263,10 @@ namespace System.Data.OracleClient.Oci {
|
||||
rsize = rsizep.ToUInt64 ();
|
||||
|
||||
//rsize = Encoding.UTF8.GetMaxByteCount (commandText.Length+1);
|
||||
Console.WriteLine ("OCIStatementHandle:Prepare: CmdText:{0}, rsize:{1} ",
|
||||
commandText, rsize);
|
||||
|
||||
// Fill buffer
|
||||
buffer = new byte[rsize];
|
||||
|
||||
Console.WriteLine ("OCIStatementHandle:Prepare: buffer.Length:{0}, this.columnCount:{1}",
|
||||
buffer.Length, this.ColumnCount);
|
||||
|
||||
OciCalls.OCIUnicodeToCharSet (Parent, buffer, commandText, ref rsizep);
|
||||
|
||||
// Execute statement
|
||||
|
||||
@@ -63,7 +63,7 @@ EXTRA_DISTFILES = \
|
||||
BUILT_SOURCES = Mono.Data.SqlExpressions/Parser.cs
|
||||
|
||||
Mono.Data.SqlExpressions/Parser.cs: Mono.Data.SqlExpressions/Parser.jay $(topdir)/jay/skeleton.cs
|
||||
$(topdir)/jay/jay -ct < $(topdir)/jay/skeleton.cs $< >$@
|
||||
$(topdir)/jay/jay -vct < $(topdir)/jay/skeleton.cs $(CURDIR)/$< >$@
|
||||
|
||||
include ../../build/library.make
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
// Juraj Skripsky ([email protected])
|
||||
//
|
||||
// (C) 2004 HotFeet GmbH (http://www.hotfeet.ch)
|
||||
// Copyright 2011 Xamarin Inc (http://www.xamarin.com)
|
||||
//
|
||||
|
||||
using System;
|
||||
@@ -190,6 +191,7 @@ LiteralValue
|
||||
| NumberLiteral { $$ = new Literal ($1); }
|
||||
| DateLiteral { $$ = new Literal ($1); }
|
||||
| BoolLiteral
|
||||
| NULL { $$ = new Literal (null); }
|
||||
;
|
||||
|
||||
BoolLiteral
|
||||
@@ -271,28 +273,20 @@ AggFunctionName
|
||||
;
|
||||
|
||||
StringExpr
|
||||
: PAROPEN StringExpr PARCLOSE
|
||||
{
|
||||
$$ = (IExpression)$2;
|
||||
}
|
||||
| SingleColumnValue
|
||||
: SingleColumnValue
|
||||
| StringLiteral { $$ = new Literal ($1); }
|
||||
| StringFunction
|
||||
| Function
|
||||
;
|
||||
|
||||
StringFunction
|
||||
: TRIM PAROPEN StringExpr PARCLOSE
|
||||
: TRIM PAROPEN ArithExpr PARCLOSE
|
||||
{
|
||||
$$ = new TrimFunction ((IExpression)$3);
|
||||
}
|
||||
| SUBSTRING PAROPEN StringExpr COMMA ArithExpr COMMA ArithExpr PARCLOSE
|
||||
| SUBSTRING PAROPEN ArithExpr COMMA ArithExpr COMMA ArithExpr PARCLOSE
|
||||
{
|
||||
$$ = new SubstringFunction ((IExpression)$3, (IExpression)$5, (IExpression)$7);
|
||||
}
|
||||
| StringExpr PLUS StringExpr
|
||||
{
|
||||
$$ = new ConcatFunction ((IExpression)$1, (IExpression)$3);
|
||||
}
|
||||
;
|
||||
|
||||
CalcFunction
|
||||
|
||||
@@ -55,42 +55,6 @@ namespace Mono.Data.SqlExpressions {
|
||||
}
|
||||
}
|
||||
|
||||
internal class ConcatFunction : StringFunction
|
||||
{
|
||||
readonly IExpression _add;
|
||||
public ConcatFunction (IExpression e, IExpression add)
|
||||
: base (e)
|
||||
{
|
||||
_add = add;
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (!base.Equals (obj))
|
||||
return false;
|
||||
|
||||
if (!(obj is ConcatFunction))
|
||||
return false;
|
||||
|
||||
ConcatFunction other = (ConcatFunction) obj;
|
||||
return _add.Equals (other._add);
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
int hashCode = base.GetHashCode ();
|
||||
hashCode ^= _add.GetHashCode ();
|
||||
return hashCode;
|
||||
}
|
||||
|
||||
override public object Eval (DataRow row) {
|
||||
string str = (string) base.Eval (row);
|
||||
string x = (string) _add.Eval (row);
|
||||
|
||||
return str + x;
|
||||
}
|
||||
}
|
||||
|
||||
internal class SubstringFunction : StringFunction {
|
||||
IExpression start;
|
||||
IExpression len;
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
|
||||
//
|
||||
// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
|
||||
// Copyright (C) 2011 Xamarin Inc (http://www.xamarin.com)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
@@ -475,43 +476,53 @@ namespace System.Data {
|
||||
if (value == null)
|
||||
value = String.Empty;
|
||||
|
||||
if (value != String.Empty) {
|
||||
if (AutoIncrement || Unique)
|
||||
throw new ArgumentException ("Cannot create an expression on a column that has AutoIncrement or Unique.");
|
||||
CompileExpression (value);
|
||||
_expression = value;
|
||||
}
|
||||
}
|
||||
|
||||
if (Table != null) {
|
||||
for (int i = 0; i < Table.Constraints.Count; i++) {
|
||||
if (Table.Constraints [i].IsColumnContained (this))
|
||||
throw new ArgumentException (
|
||||
String.Format (
|
||||
"Cannot set Expression property on column {0}, because it is a part of a constraint.",
|
||||
ColumnName));
|
||||
}
|
||||
}
|
||||
internal void CompileExpression ()
|
||||
{
|
||||
CompileExpression (_expression);
|
||||
}
|
||||
|
||||
Parser parser = new Parser ();
|
||||
IExpression compiledExpression = parser.Compile (value);
|
||||
internal void CompileExpression (string expression)
|
||||
{
|
||||
if (expression != String.Empty) {
|
||||
if (AutoIncrement || Unique)
|
||||
throw new ArgumentException ("Cannot create an expression on a column that has AutoIncrement or Unique.");
|
||||
|
||||
if (Table != null) {
|
||||
if (compiledExpression.DependsOn (this))
|
||||
throw new ArgumentException ("Cannot set Expression property due to circular reference in the expression.");
|
||||
// Check if expression is ok
|
||||
if (Table.Rows.Count == 0)
|
||||
compiledExpression.Eval (Table.NewRow ());
|
||||
else
|
||||
compiledExpression.Eval (Table.Rows [0]);
|
||||
}
|
||||
ReadOnly = true;
|
||||
_compiledExpression = compiledExpression;
|
||||
} else {
|
||||
_compiledExpression = null;
|
||||
if (Table != null) {
|
||||
int defaultValuesRowIndex = Table.DefaultValuesRowIndex;
|
||||
if (defaultValuesRowIndex != -1)
|
||||
DataContainer.FillValues (defaultValuesRowIndex);
|
||||
if (Table != null) {
|
||||
for (int i = 0; i < Table.Constraints.Count; i++) {
|
||||
if (Table.Constraints [i].IsColumnContained (this))
|
||||
throw new ArgumentException (
|
||||
String.Format (
|
||||
"Cannot set Expression property on column {0}, because it is a part of a constraint.",
|
||||
ColumnName));
|
||||
}
|
||||
}
|
||||
_expression = value;
|
||||
|
||||
Parser parser = new Parser ();
|
||||
IExpression compiledExpression = parser.Compile (expression);
|
||||
|
||||
if (Table != null) {
|
||||
if (compiledExpression.DependsOn (this))
|
||||
throw new ArgumentException ("Cannot set Expression property due to circular reference in the expression.");
|
||||
// Check if expression is ok
|
||||
if (Table.Rows.Count == 0)
|
||||
compiledExpression.Eval (Table.NewRow ());
|
||||
else
|
||||
compiledExpression.Eval (Table.Rows [0]);
|
||||
}
|
||||
ReadOnly = true;
|
||||
_compiledExpression = compiledExpression;
|
||||
} else {
|
||||
_compiledExpression = null;
|
||||
if (Table != null) {
|
||||
int defaultValuesRowIndex = Table.DefaultValuesRowIndex;
|
||||
if (defaultValuesRowIndex != -1)
|
||||
DataContainer.FillValues (defaultValuesRowIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -701,16 +712,12 @@ namespace System.Data {
|
||||
//Copy.Container
|
||||
copy.DataType = DataType;
|
||||
copy._defaultValue = _defaultValue;
|
||||
// Use the property to set the expression as it updates compiledExpression, if any.
|
||||
copy.Expression = _expression;
|
||||
// Do not use the Expression property to set the expression, the caller of Clone
|
||||
// must explicitly call CompileExpression on the returned DataColumn to update compiledExpression (if any).
|
||||
copy._expression = _expression;
|
||||
//Copy.ExtendedProperties
|
||||
if (_extendedProperties.Count > 0) {
|
||||
Array extPropArray = Array.CreateInstance (typeof (object), _extendedProperties.Count);
|
||||
_extendedProperties.CopyTo (extPropArray, 0);
|
||||
for (var i = 0; i < _extendedProperties.Count; i++)
|
||||
copy.ExtendedProperties.Add (extPropArray.GetValue(i),
|
||||
ExtendedProperties[extPropArray.GetValue(i)]);
|
||||
}
|
||||
foreach (object key in _extendedProperties.Keys)
|
||||
copy.ExtendedProperties.Add (key, ExtendedProperties[key]);
|
||||
copy._maxLength = _maxLength;
|
||||
copy._nameSpace = _nameSpace;
|
||||
copy._prefix = _prefix;
|
||||
|
||||
@@ -880,6 +880,8 @@ namespace System.Data {
|
||||
if (isEmpty || !Copy.Columns.Contains (column.ColumnName))
|
||||
Copy.Columns.Add (column.Clone ());
|
||||
}
|
||||
foreach (DataColumn column in Copy.Columns)
|
||||
column.CompileExpression ();
|
||||
|
||||
CopyConstraints (Copy);
|
||||
// add primary key to the copy
|
||||
|
||||
@@ -351,6 +351,7 @@ namespace System.Data {
|
||||
|
||||
DataTable GetTable (string name)
|
||||
{
|
||||
name = XmlConvert.DecodeName (name);
|
||||
if (DSet != null)
|
||||
return DSet.Tables [name];
|
||||
else if (name == table.TableName)
|
||||
|
||||
@@ -10,9 +10,10 @@
|
||||
// (C) Copyright 2002 Rodrigo Moya
|
||||
// (C) Copyright 2003 Daniel Morgan
|
||||
// (C) Copyright 2003 Martin Willemoes Hansen
|
||||
//
|
||||
// (C) Copyright 2011 Xamarin Inc
|
||||
|
||||
//
|
||||
// Copyright 2011 Xamarin Inc (http://www.xamarin.com)
|
||||
// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
@@ -913,5 +914,46 @@ namespace MonoTests.System.Data
|
||||
Assert.Fail ("SetOrdinalTest failed");
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Xamarin665 ()
|
||||
{
|
||||
var t = new DataTable() ;
|
||||
var c1 = t.Columns.Add ("c1");
|
||||
var c2 = t.Columns.Add ("c2");
|
||||
c2.Expression = "TRIM(ISNULL(c1,' '))";
|
||||
c2.Expression = "SUBSTRING(ISNULL(c1,' '), 1, 10)";
|
||||
}
|
||||
|
||||
DataColumn MakeColumn (string col, string test)
|
||||
{
|
||||
return new DataColumn () {
|
||||
ColumnName = col,
|
||||
Expression = test
|
||||
};
|
||||
}
|
||||
|
||||
#if false
|
||||
// Check Windows output for the row [0] value
|
||||
[Test]
|
||||
public void NullStrings ()
|
||||
{
|
||||
var a = MakeColumn ("nullbar", "null+'bar'");
|
||||
var b = MakeColumn ("barnull", "'bar'+null");
|
||||
var c = MakeColumn ("foobar", "'foo'+'bar'");
|
||||
|
||||
var table = new DataTable();
|
||||
|
||||
table.Columns.Add(a);
|
||||
table.Columns.Add(b);
|
||||
table.Columns.Add(c);
|
||||
|
||||
var row = table.NewRow();
|
||||
table.Rows.Add(row);
|
||||
Assert.AreEqual (row [0], DBNull.Value, "#1");
|
||||
Assert.AreEqual (row [1], DBNull.Value, "#2");
|
||||
Assert.AreEqual (row [2], "foobar", "#3");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -2563,6 +2563,30 @@ namespace MonoTests.System.Data
|
||||
Assert.AreEqual (2, dsLoad.Tables[2].Columns.Count, "T3-Columns");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ReadDiff ()
|
||||
{
|
||||
DataSet dsTest = new DataSet ("MonoTouchTest");
|
||||
var dt = new DataTable ("123");
|
||||
dt.Columns.Add (new DataColumn ("Value1"));
|
||||
dt.Columns.Add (new DataColumn ("Value2"));
|
||||
dsTest.Tables.Add (dt);
|
||||
dsTest.ReadXml (new StringReader (@"
|
||||
<diffgr:diffgram
|
||||
xmlns:msdata='urn:schemas-microsoft-com:xml-msdata'
|
||||
xmlns:diffgr='urn:schemas-microsoft-com:xml-diffgram-v1'>
|
||||
<MonoTouchTest>
|
||||
<_x0031_23 diffgr:id='1231' msdata:rowOrder='0'>
|
||||
<Value1>Row1Value1</Value1>
|
||||
<Value2>Row1Value2</Value2>
|
||||
</_x0031_23>
|
||||
</MonoTouchTest>
|
||||
</diffgr:diffgram>
|
||||
"));
|
||||
Assert.AreEqual ("123", dsTest.Tables [0].TableName, "#1");
|
||||
Assert.AreEqual (1, dsTest.Tables [0].Rows.Count, "#2");
|
||||
}
|
||||
|
||||
private void CompareTables (DataSet dsLoad) {
|
||||
Assert.AreEqual (ds.Tables.Count, dsLoad.Tables.Count, "NumTables");
|
||||
for (int tc = 0; tc < dsLoad.Tables.Count; tc++) {
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
|
||||
//
|
||||
// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
|
||||
// Copyright (C) 2011 Xamarin Inc. (http://www.xamarin.com)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
@@ -1043,6 +1044,43 @@ namespace MonoTests.System.Data
|
||||
Assert.AreEqual ("Table#1", copyTable.TableName, "#A30");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CloneExtendedProperties ()
|
||||
{
|
||||
// bug 668
|
||||
DataTable t1 = new DataTable ("t1");
|
||||
DataColumn c1 = t1.Columns.Add ("c1");
|
||||
c1.ExtendedProperties.Add ("Company", "Xamarin");
|
||||
|
||||
DataTable t2 = t1.Clone ();
|
||||
Assert.AreEqual ("Xamarin", t1.Columns["c1"].ExtendedProperties["Company"], "CEP1");
|
||||
Assert.AreEqual ("Xamarin", t2.Columns["c1"].ExtendedProperties["Company"], "CEP2");
|
||||
}
|
||||
|
||||
[Test]
|
||||
[ExpectedException (typeof (EvaluateException))]
|
||||
public void CloneExtendedProperties1 ()
|
||||
{
|
||||
// Xamarin bug 666
|
||||
DataTable table1 = new DataTable("Table1") ;
|
||||
|
||||
DataColumn c1 = table1.Columns.Add("c1", typeof(string), "'hello ' + c2") ; /* Should cause an exception */
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CloneExtendedProperties2 ()
|
||||
{
|
||||
// Xamarin bug 666
|
||||
DataTable table1 = new DataTable("Table1") ;
|
||||
|
||||
DataColumn c1 = table1.Columns.Add("c1") ;
|
||||
DataColumn c2 = table1.Columns.Add("c2") ;
|
||||
|
||||
c1.Expression = "'hello ' + c2";
|
||||
|
||||
DataTable t2 = table1.Clone(); // this should not cause an exception
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void LoadDataException ()
|
||||
{
|
||||
|
||||
+17
-2
@@ -54,9 +54,24 @@ namespace System.IdentityModel.Tokens
|
||||
#if TARGET_DOTNET
|
||||
throw new NotImplementedException ();
|
||||
#else
|
||||
return new BigInteger (FromBinHex (hexString)).ToString ();
|
||||
// http://tools.ietf.org/html/rfc5280#section-4.1.2.2
|
||||
// We SHOULD support negative numbers
|
||||
var bytes = FromBinHex (hexString);
|
||||
|
||||
var negative = bytes.Length > 0 && bytes [0] >= 0x80;
|
||||
if (negative) {
|
||||
for (int i = 0; i < bytes.Length; i++)
|
||||
bytes [i] = (byte) ~ bytes [i];
|
||||
}
|
||||
|
||||
var big = new BigInteger (bytes);
|
||||
if (negative) {
|
||||
big = big + 1;
|
||||
return "-" + big.ToString ();
|
||||
} else
|
||||
return big.ToString ();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
public X509IssuerSerialKeyIdentifierClause (X509Certificate2 certificate)
|
||||
: base (null)
|
||||
|
||||
Binary file not shown.
+10
@@ -40,6 +40,7 @@ namespace MonoTests.System.IdentityModel.Selectors
|
||||
{
|
||||
static readonly X509Certificate2 cert = new X509Certificate2 ("Test/Resources/test.pfx", "mono");
|
||||
static readonly X509Certificate2 cert2 = new X509Certificate2 ("Test/Resources/test2.pfx", "mono");
|
||||
static readonly X509Certificate2 cert3 = new X509Certificate2("Test/Resources/test_neg_serial.cer");
|
||||
|
||||
[Test]
|
||||
public void Properties ()
|
||||
@@ -50,5 +51,14 @@ namespace MonoTests.System.IdentityModel.Selectors
|
||||
Assert.AreEqual ("22491767666218099257720700881460366085", ic.IssuerSerialNumber, "#2");
|
||||
Assert.AreEqual (null, ic.ClauseType, "#3");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void NegativeSerialNumber ()
|
||||
{
|
||||
var clause = new X509IssuerSerialKeyIdentifierClause (cert3);
|
||||
Assert.AreEqual ("CN=test, OU=cert, O=test, [email protected]", clause.IssuerName, "#1");
|
||||
Assert.AreEqual ("-168428216848510272180165529369113665228", clause.IssuerSerialNumber, "#2");
|
||||
Assert.AreEqual (null, clause.ClauseType, "#3");
|
||||
}
|
||||
}
|
||||
}
|
||||
+48
-19
@@ -3,8 +3,10 @@
|
||||
//
|
||||
// Author:
|
||||
// Atsushi Enomoto <[email protected]>
|
||||
// Atsushi Enomoto <[email protected]>
|
||||
//
|
||||
// Copyright (C) 2008,2009 Novell, Inc (http://www.novell.com)
|
||||
// Copyright (C) 2011 Xamarin, Inc (http://xamarin.com)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
@@ -45,6 +47,24 @@ using XmlObjectSerializer = System.Object;
|
||||
|
||||
namespace System.ServiceModel.Dispatcher
|
||||
{
|
||||
// This set of classes is to work as message formatters for
|
||||
// WebHttpBehavior. There are couple of aspects to differentiate
|
||||
// implementations:
|
||||
// - request/reply and client/server
|
||||
// by WebMessageFormatter hierarchy
|
||||
// - WebClientMessageFormatter - for client
|
||||
// - RequestClientFormatter - for request
|
||||
// - ReplyClientFormatter - for response
|
||||
// - WebDispatchMessageFormatter - for server
|
||||
// - RequestDispatchFormatter - for request
|
||||
// - ReplyDispatchFormatter - for response
|
||||
//
|
||||
// FIXME: below items need more work
|
||||
// - HTTP method differences
|
||||
// - GET (WebGet)
|
||||
// - POST (other way)
|
||||
// - output format: Stream, JSON, XML ...
|
||||
|
||||
internal abstract class WebMessageFormatter
|
||||
{
|
||||
OperationDescription operation;
|
||||
@@ -182,6 +202,9 @@ namespace System.ServiceModel.Dispatcher
|
||||
|
||||
protected XmlObjectSerializer GetSerializer (WebContentFormat msgfmt, bool isWrapped, MessagePartDescription part)
|
||||
{
|
||||
if (part.Type == typeof (void))
|
||||
return null; // no serialization should be done.
|
||||
|
||||
switch (msgfmt) {
|
||||
case WebContentFormat.Xml:
|
||||
if (xml_serializer == null)
|
||||
@@ -208,6 +231,9 @@ namespace System.ServiceModel.Dispatcher
|
||||
// FIXME: handle ref/out parameters
|
||||
|
||||
var reader = message.GetReaderAtBodyContents ();
|
||||
reader.MoveToContent ();
|
||||
|
||||
bool wasEmptyElement = reader.IsEmptyElement;
|
||||
|
||||
if (isWrapped) {
|
||||
if (fmt == WebContentFormat.Json)
|
||||
@@ -216,9 +242,9 @@ namespace System.ServiceModel.Dispatcher
|
||||
reader.ReadStartElement (md.Body.WrapperName, md.Body.WrapperNamespace);
|
||||
}
|
||||
|
||||
var ret = ReadObjectBody (serializer, reader);
|
||||
var ret = (serializer == null) ? null : ReadObjectBody (serializer, reader);
|
||||
|
||||
if (isWrapped)
|
||||
if (isWrapped && !wasEmptyElement)
|
||||
reader.ReadEndElement ();
|
||||
|
||||
return ret;
|
||||
@@ -291,6 +317,8 @@ namespace System.ServiceModel.Dispatcher
|
||||
|
||||
internal abstract class WebClientMessageFormatter : WebMessageFormatter, IClientMessageFormatter
|
||||
{
|
||||
IClientMessageFormatter default_formatter;
|
||||
|
||||
protected WebClientMessageFormatter (OperationDescription operation, ServiceEndpoint endpoint, QueryStringConverter converter, WebHttpBehavior behavior)
|
||||
: base (operation, endpoint, converter, behavior)
|
||||
{
|
||||
@@ -306,11 +334,11 @@ namespace System.ServiceModel.Dispatcher
|
||||
|
||||
MessageDescription md = GetMessageDescription (MessageDirection.Input);
|
||||
|
||||
if (parameters.Length != md.Body.Parts.Count)
|
||||
throw new ArgumentException ("Parameter array length does not match the number of message body parts");
|
||||
|
||||
Message ret;
|
||||
Uri to;
|
||||
object msgpart = null;
|
||||
|
||||
|
||||
for (int i = 0; i < parameters.Length; i++) {
|
||||
var p = md.Body.Parts [i];
|
||||
string name = p.Name.ToUpper (CultureInfo.InvariantCulture);
|
||||
@@ -325,10 +353,9 @@ namespace System.ServiceModel.Dispatcher
|
||||
throw new NotImplementedException (String.Format ("More than one parameters including {0} that are not contained in the URI template {1} was found.", p.Name, UriTemplate));
|
||||
}
|
||||
}
|
||||
ret = Message.CreateMessage (messageVersion, (string) null, msgpart);
|
||||
|
||||
Uri to = UriTemplate.BindByName (Endpoint.Address.Uri, c);
|
||||
|
||||
Message ret = Message.CreateMessage (messageVersion, (string) null, msgpart);
|
||||
to = UriTemplate.BindByName (Endpoint.Address.Uri, c);
|
||||
ret.Headers.To = to;
|
||||
|
||||
var hp = new HttpRequestMessageProperty ();
|
||||
@@ -546,11 +573,8 @@ namespace System.ServiceModel.Dispatcher
|
||||
var fmt = wp != null ? wp.Format : WebContentFormat.Xml;
|
||||
|
||||
Uri to = message.Headers.To;
|
||||
UriTemplateMatch match = UriTemplate.Match (Endpoint.Address.Uri, to);
|
||||
if (match == null)
|
||||
// not sure if it could happen
|
||||
throw new SystemException (String.Format ("INTERNAL ERROR: UriTemplate does not match with the request: {0} / {1}", UriTemplate, to));
|
||||
if (iwc != null)
|
||||
UriTemplateMatch match = to == null ? null : UriTemplate.Match (Endpoint.Address.Uri, to);
|
||||
if (match != null && iwc != null)
|
||||
iwc.UriTemplateMatch = match;
|
||||
|
||||
MessageDescription md = GetMessageDescription (MessageDirection.Input);
|
||||
@@ -558,15 +582,20 @@ namespace System.ServiceModel.Dispatcher
|
||||
for (int i = 0; i < parameters.Length; i++) {
|
||||
var p = md.Body.Parts [i];
|
||||
string name = p.Name.ToUpperInvariant ();
|
||||
var str = match.BoundVariables [name];
|
||||
if (str != null)
|
||||
parameters [i] = Converter.ConvertStringToValue (str, p.Type);
|
||||
else if (fmt == WebContentFormat.Raw && p.Type == typeof (Stream)) {
|
||||
if (fmt == WebContentFormat.Raw && p.Type == typeof (Stream)) {
|
||||
var rmsg = (RawMessage) message;
|
||||
parameters [i] = rmsg.Stream;
|
||||
} else {
|
||||
var serializer = GetSerializer (fmt, IsRequestBodyWrapped, p);
|
||||
parameters [i] = DeserializeObject (serializer, message, md, IsRequestBodyWrapped, fmt);
|
||||
var str = match.BoundVariables [name];
|
||||
if (str != null)
|
||||
parameters [i] = Converter.ConvertStringToValue (str, p.Type);
|
||||
else {
|
||||
if (info.Method != "GET") {
|
||||
var serializer = GetSerializer (fmt, IsRequestBodyWrapped, p);
|
||||
parameters [i] = DeserializeObject (serializer, message, md, IsRequestBodyWrapped, fmt);
|
||||
}
|
||||
// for GET Uri template parameters, there is no <anyType xsi:nil='true' />. So just skip the member.
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -163,6 +163,15 @@ namespace System
|
||||
|
||||
void BindByName (ref int src, StringBuilder sb, ReadOnlyCollection<string> names, NameValueCollection nvc, IDictionary<string,string> dic, bool omitDefaults, bool query)
|
||||
{
|
||||
if (query) {
|
||||
int idx = template.IndexOf ('?', src);
|
||||
if (idx > 0) {
|
||||
sb.Append (template.Substring (src, idx - src));
|
||||
src = idx;
|
||||
// note that it doesn't append '?'. It is added only when there is actual parameter binding.
|
||||
}
|
||||
}
|
||||
|
||||
foreach (string name in names) {
|
||||
int s = template.IndexOf ('{', src);
|
||||
int e = template.IndexOf ('}', s + 1);
|
||||
@@ -173,18 +182,19 @@ namespace System
|
||||
#endif
|
||||
if (dic != null)
|
||||
dic.TryGetValue (name, out value);
|
||||
|
||||
if (query) {
|
||||
if (value != null || (!omitDefaults && Defaults.TryGetValue (name, out value))) {
|
||||
sb.Append (template.Substring (src, s - src));
|
||||
sb.Append (value);
|
||||
}
|
||||
} else
|
||||
if (value == null && (omitDefaults || !Defaults.TryGetValue(name, out value)))
|
||||
throw new ArgumentException(string.Format("The argument name value collection does not contain non-nul vaalue for '{0}'", name), "parameters");
|
||||
else {
|
||||
sb.Append (template.Substring (src, s - src));
|
||||
sb.Append (value);
|
||||
}
|
||||
} else {
|
||||
if (value == null && (omitDefaults || !Defaults.TryGetValue (name, out value)))
|
||||
throw new ArgumentException (string.Format("The argument name value collection does not contain non-null value for '{0}'", name), "parameters");
|
||||
|
||||
sb.Append (template.Substring (src, s - src));
|
||||
sb.Append (value);
|
||||
}
|
||||
src = e + 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,321 @@
|
||||
//
|
||||
// This code was partly auto-generated by slsvcutil, version 4.0.60310.0
|
||||
//
|
||||
namespace DHIWebService
|
||||
{
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
|
||||
[System.Diagnostics.DebuggerStepThroughAttribute()]
|
||||
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "4.0.0.0")]
|
||||
[System.Runtime.Serialization.DataContractAttribute(Name="ClientLoginData", Namespace="http://schemas.datacontract.org/2004/07/Domain.Models")]
|
||||
public partial class ClientLoginData : object
|
||||
{
|
||||
|
||||
private int CompanyNumberField;
|
||||
|
||||
private string InstitutionIdField;
|
||||
|
||||
private string PasswordField;
|
||||
|
||||
private string UserNameField;
|
||||
|
||||
[System.Runtime.Serialization.DataMemberAttribute()]
|
||||
public int CompanyNumber
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.CompanyNumberField;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.CompanyNumberField = value;
|
||||
}
|
||||
}
|
||||
|
||||
[System.Runtime.Serialization.DataMemberAttribute()]
|
||||
public string InstitutionId
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.InstitutionIdField;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.InstitutionIdField = value;
|
||||
}
|
||||
}
|
||||
|
||||
[System.Runtime.Serialization.DataMemberAttribute(IsRequired=true)]
|
||||
public string Password
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.PasswordField;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.PasswordField = value;
|
||||
}
|
||||
}
|
||||
|
||||
[System.Runtime.Serialization.DataMemberAttribute(IsRequired=true)]
|
||||
public string UserName
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.UserNameField;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.UserNameField = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[System.Diagnostics.DebuggerStepThroughAttribute()]
|
||||
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "4.0.0.0")]
|
||||
[System.Runtime.Serialization.DataContractAttribute(Name="Login", Namespace="http://schemas.datacontract.org/2004/07/Domain.Models")]
|
||||
public partial class Login : object
|
||||
{
|
||||
|
||||
private int CompanyNumberField;
|
||||
|
||||
private string InstitutionIdField;
|
||||
|
||||
private string PasswordField;
|
||||
|
||||
private string UserNameField;
|
||||
|
||||
[System.Runtime.Serialization.DataMemberAttribute()]
|
||||
public int CompanyNumber
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.CompanyNumberField;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.CompanyNumberField = value;
|
||||
}
|
||||
}
|
||||
|
||||
[System.Runtime.Serialization.DataMemberAttribute()]
|
||||
public string InstitutionId
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.InstitutionIdField;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.InstitutionIdField = value;
|
||||
}
|
||||
}
|
||||
|
||||
[System.Runtime.Serialization.DataMemberAttribute(IsRequired=true)]
|
||||
public string Password
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.PasswordField;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.PasswordField = value;
|
||||
}
|
||||
}
|
||||
|
||||
[System.Runtime.Serialization.DataMemberAttribute(IsRequired=true)]
|
||||
public string UserName
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.UserNameField;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.UserNameField = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
|
||||
[System.ServiceModel.ServiceContractAttribute(Namespace="IBEWebSvc", ConfigurationName="DHIWebService.IDHIService")]
|
||||
public interface IDHIService
|
||||
{
|
||||
|
||||
[System.ServiceModel.OperationContractAttribute(AsyncPattern=true, Action="IBEWebSvc/IDHIService/Login", ReplyAction="IBEWebSvc/IDHIService/LoginResponse")]
|
||||
// FIXME: uncommenting this results in cryptic error message. We should tell what could be wrong here.
|
||||
// [System.ServiceModel.Web.WebInvoke(BodyStyle=System.ServiceModel.Web.WebMessageBodyStyle.Wrapped)]
|
||||
System.IAsyncResult BeginLogin(DHIWebService.LoginRequest request, System.AsyncCallback callback, object asyncState);
|
||||
|
||||
DHIWebService.LoginResponse EndLogin(System.IAsyncResult result);
|
||||
|
||||
[System.ServiceModel.OperationContractAttribute(Action="IBEWebSvc/IDHIService/Login", ReplyAction="IBEWebSvc/IDHIService/LoginResponse")]
|
||||
[System.ServiceModel.Web.WebInvoke(BodyStyle=System.ServiceModel.Web.WebMessageBodyStyle.Wrapped)]
|
||||
DHIWebService.LoginResponse Login(DHIWebService.LoginRequest request);
|
||||
|
||||
|
||||
}
|
||||
|
||||
[System.Diagnostics.DebuggerStepThroughAttribute()]
|
||||
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
|
||||
[System.ServiceModel.MessageContractAttribute(WrapperName="Login", WrapperNamespace="IBEWebSvc", IsWrapped=true)]
|
||||
public partial class LoginRequest
|
||||
{
|
||||
|
||||
[System.ServiceModel.MessageBodyMemberAttribute(Namespace="IBEWebSvc", Order=0)]
|
||||
public DHIWebService.ClientLoginData clientLoginData;
|
||||
|
||||
[System.ServiceModel.MessageBodyMemberAttribute(Namespace="IBEWebSvc", Order=1)]
|
||||
public DHIWebService.Login credentials;
|
||||
|
||||
public LoginRequest()
|
||||
{
|
||||
}
|
||||
|
||||
public LoginRequest(DHIWebService.ClientLoginData clientLoginData, DHIWebService.Login credentials)
|
||||
{
|
||||
this.clientLoginData = clientLoginData;
|
||||
this.credentials = credentials;
|
||||
}
|
||||
}
|
||||
|
||||
[System.Diagnostics.DebuggerStepThroughAttribute()]
|
||||
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
|
||||
[System.ServiceModel.MessageContractAttribute(WrapperName="LoginResponse", WrapperNamespace="IBEWebSvc", IsWrapped=true)]
|
||||
public partial class LoginResponse
|
||||
{
|
||||
}
|
||||
|
||||
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
|
||||
public interface IDHIServiceChannel : DHIWebService.IDHIService, System.ServiceModel.IClientChannel
|
||||
{
|
||||
}
|
||||
|
||||
[System.Diagnostics.DebuggerStepThroughAttribute()]
|
||||
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
|
||||
public partial class LoginCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs
|
||||
{
|
||||
|
||||
private object[] results;
|
||||
|
||||
public LoginCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) :
|
||||
base(exception, cancelled, userState)
|
||||
{
|
||||
this.results = results;
|
||||
}
|
||||
|
||||
public DHIWebService.LoginResponse Result
|
||||
{
|
||||
get
|
||||
{
|
||||
base.RaiseExceptionIfNecessary();
|
||||
return ((DHIWebService.LoginResponse)(this.results[0]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[System.Diagnostics.DebuggerStepThroughAttribute()]
|
||||
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
|
||||
public partial class DHIServiceClient : System.ServiceModel.ClientBase<DHIWebService.IDHIService>, DHIWebService.IDHIService
|
||||
{
|
||||
|
||||
private BeginOperationDelegate onBeginLoginDelegate;
|
||||
|
||||
private EndOperationDelegate onEndLoginDelegate;
|
||||
|
||||
private System.Threading.SendOrPostCallback onLoginCompletedDelegate;
|
||||
|
||||
public DHIServiceClient()
|
||||
{
|
||||
}
|
||||
|
||||
public DHIServiceClient(string endpointConfigurationName) :
|
||||
base(endpointConfigurationName)
|
||||
{
|
||||
}
|
||||
|
||||
public DHIServiceClient(string endpointConfigurationName, string remoteAddress) :
|
||||
base(endpointConfigurationName, remoteAddress)
|
||||
{
|
||||
}
|
||||
|
||||
public DHIServiceClient(string endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress) :
|
||||
base(endpointConfigurationName, remoteAddress)
|
||||
{
|
||||
}
|
||||
|
||||
public DHIServiceClient(System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) :
|
||||
base(binding, remoteAddress)
|
||||
{
|
||||
}
|
||||
|
||||
public event System.EventHandler<LoginCompletedEventArgs> LoginCompleted;
|
||||
|
||||
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
System.IAsyncResult DHIWebService.IDHIService.BeginLogin(DHIWebService.LoginRequest request, System.AsyncCallback callback, object asyncState)
|
||||
{
|
||||
return base.Channel.BeginLogin(request, callback, asyncState);
|
||||
}
|
||||
|
||||
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
DHIWebService.LoginResponse DHIWebService.IDHIService.EndLogin(System.IAsyncResult result)
|
||||
{
|
||||
return base.Channel.EndLogin(result);
|
||||
}
|
||||
|
||||
private System.IAsyncResult OnBeginLogin(object[] inValues, System.AsyncCallback callback, object asyncState)
|
||||
{
|
||||
DHIWebService.LoginRequest request = ((DHIWebService.LoginRequest)(inValues[0]));
|
||||
return ((DHIWebService.IDHIService)(this)).BeginLogin(request, callback, asyncState);
|
||||
}
|
||||
|
||||
private object[] OnEndLogin(System.IAsyncResult result)
|
||||
{
|
||||
DHIWebService.LoginResponse retVal = ((DHIWebService.IDHIService)(this)).EndLogin(result);
|
||||
return new object[] {
|
||||
retVal};
|
||||
}
|
||||
|
||||
private void OnLoginCompleted(object state)
|
||||
{
|
||||
if ((this.LoginCompleted != null))
|
||||
{
|
||||
InvokeAsyncCompletedEventArgs e = ((InvokeAsyncCompletedEventArgs)(state));
|
||||
this.LoginCompleted(this, new LoginCompletedEventArgs(e.Results, e.Error, e.Cancelled, e.UserState));
|
||||
}
|
||||
}
|
||||
|
||||
public void LoginAsync(DHIWebService.LoginRequest request)
|
||||
{
|
||||
this.LoginAsync(request, null);
|
||||
}
|
||||
|
||||
public void LoginAsync(DHIWebService.LoginRequest request, object userState)
|
||||
{
|
||||
if ((this.onBeginLoginDelegate == null))
|
||||
{
|
||||
this.onBeginLoginDelegate = new BeginOperationDelegate(this.OnBeginLogin);
|
||||
}
|
||||
if ((this.onEndLoginDelegate == null))
|
||||
{
|
||||
this.onEndLoginDelegate = new EndOperationDelegate(this.OnEndLogin);
|
||||
}
|
||||
if ((this.onLoginCompletedDelegate == null))
|
||||
{
|
||||
this.onLoginCompletedDelegate = new System.Threading.SendOrPostCallback(this.OnLoginCompleted);
|
||||
}
|
||||
base.InvokeAsync(this.onBeginLoginDelegate, new object[] {
|
||||
request}, this.onEndLoginDelegate, this.onLoginCompletedDelegate, userState);
|
||||
}
|
||||
|
||||
|
||||
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
DHIWebService.LoginResponse DHIWebService.IDHIService.Login (DHIWebService.LoginRequest request)
|
||||
{
|
||||
return base.Channel.Login(request);
|
||||
}
|
||||
}
|
||||
}
|
||||
-1
@@ -241,7 +241,6 @@ namespace MonoTests.System.ServiceModel.Description
|
||||
var se = new ServiceEndpoint (cd, new WebHttpBinding (), new EndpointAddress ("http://localhost:8080/"));
|
||||
var wmebe = new WebMessageEncodingBindingElement ();
|
||||
var wme = wmebe.CreateMessageEncoderFactory ().Encoder;
|
||||
Console.WriteLine (wme.MediaType);
|
||||
var msg = wme.ReadMessage (ms, 100, null); // "application/xml" causes error.
|
||||
var formatter = new WebHttpBehaviorExt ().DoGetRequestDispatchFormatter (od, se);
|
||||
object [] pars = new object [1];
|
||||
|
||||
+1
@@ -256,6 +256,7 @@ namespace MonoTests.System.ServiceModel.Dispatcher
|
||||
{
|
||||
var host = new WebServiceHost (typeof (Hello));
|
||||
host.AddServiceEndpoint (typeof (IHello), new WebHttpBinding (), "http://localhost:37564/");
|
||||
host.Description.Behaviors.Find<ServiceDebugBehavior> ().IncludeExceptionDetailInFaults = true;
|
||||
host.Open ();
|
||||
try {
|
||||
// run client
|
||||
|
||||
@@ -228,6 +228,15 @@ namespace MonoTests.System
|
||||
Assert.AreEqual ("http://localhost/x/value2/value1", u.ToString ());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void BindByName3 ()
|
||||
{
|
||||
var t = new UriTemplate ("Login?clientLoginData={clientLoginData}&credentials={credentials}");
|
||||
var n = new NameValueCollection ();
|
||||
var u = t.BindByName (new Uri ("http://localhost"), n);
|
||||
Assert.AreEqual ("http://localhost/Login", u.ToString (), "#1");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void BindByNameManySlashes ()
|
||||
{
|
||||
|
||||
+6
-6
@@ -132,7 +132,7 @@ namespace System.ServiceModel.Channels.Security
|
||||
|
||||
// FIXME: use proper max buffer
|
||||
buf = source.CreateBufferedCopy (int.MaxValue);
|
||||
Console.WriteLine ("####### " + buf.CreateMessage ());
|
||||
//Console.WriteLine ("####### " + buf.CreateMessage ());
|
||||
|
||||
doc = new XmlDocument ();
|
||||
doc.PreserveWhitespace = true;
|
||||
@@ -162,10 +162,7 @@ Console.WriteLine ("####### " + buf.CreateMessage ());
|
||||
if (srcmsg.Version.Envelope == EnvelopeVersion.None)
|
||||
throw new ArgumentException ("The message to decrypt is not an expected SOAP envelope.");
|
||||
|
||||
string action = GetAction ();
|
||||
if (action == null)
|
||||
throw new ArgumentException ("SOAP action could not be retrieved from the message to decrypt.");
|
||||
|
||||
|
||||
XPathNavigator nav = doc.CreateNavigator ();
|
||||
using (XmlWriter writer = nav.AppendChild ()) {
|
||||
buf.CreateMessage ().WriteMessage (writer);
|
||||
@@ -348,6 +345,9 @@ doc.PreserveWhitespace = true;
|
||||
// and check if any of them can validate it.
|
||||
SupportingTokenParameters supp;
|
||||
string action = GetAction ();
|
||||
if (action == null)
|
||||
throw new ArgumentException ("SOAP action could not be retrieved from the message to decrypt.");
|
||||
|
||||
ValidateTokensByParameters (security.Element.EndpointSupportingTokenParameters, tokens, false);
|
||||
if (security.Element.OperationSupportingTokenParameters.TryGetValue (action, out supp))
|
||||
ValidateTokensByParameters (supp, tokens, false);
|
||||
@@ -441,7 +441,7 @@ doc.PreserveWhitespace = true;
|
||||
string ret = source_message.Headers.Action;
|
||||
if (ret == null) {
|
||||
HttpRequestMessageProperty reqprop =
|
||||
source_message.Properties ["Action"] as HttpRequestMessageProperty;
|
||||
source_message.Properties[HttpRequestMessageProperty.Name] as HttpRequestMessageProperty;
|
||||
if (reqprop != null)
|
||||
ret = reqprop.Headers ["Action"];
|
||||
}
|
||||
|
||||
+188
-142
@@ -233,8 +233,6 @@ namespace System.ServiceModel.Channels.Security
|
||||
security.SigningToken;
|
||||
MessageProtectionOrder protectionOrder =
|
||||
security.MessageProtectionOrder;
|
||||
SecurityTokenSerializer serializer =
|
||||
security.TokenSerializer;
|
||||
SecurityBindingElement element =
|
||||
security.Element;
|
||||
SecurityAlgorithmSuite suite = element.DefaultAlgorithmSuite;
|
||||
@@ -243,26 +241,19 @@ namespace System.ServiceModel.Channels.Security
|
||||
int identForMessageId = 1;
|
||||
XmlDocument doc = new XmlDocument ();
|
||||
doc.PreserveWhitespace = true;
|
||||
var action = msg.Headers.Action;
|
||||
|
||||
// FIXME: get correct ReplyTo value
|
||||
if (Direction == MessageDirection.Input)
|
||||
msg.Headers.ReplyTo = new EndpointAddress (Constants.WsaAnonymousUri);
|
||||
|
||||
if (MessageTo != null)
|
||||
msg.Headers.To = MessageTo.Uri;
|
||||
|
||||
if (msg.Version.Addressing != AddressingVersion.None) {
|
||||
AddAddressingToHeader (msg.Headers);
|
||||
}
|
||||
|
||||
// wss:Security
|
||||
WSSecurityMessageHeader header =
|
||||
new WSSecurityMessageHeader (serializer);
|
||||
new WSSecurityMessageHeader (security.TokenSerializer);
|
||||
msg.Headers.Add (header);
|
||||
// 1. [Timestamp]
|
||||
if (element.IncludeTimestamp) {
|
||||
WsuTimestamp timestamp = new WsuTimestamp ();
|
||||
timestamp.Id = messageId + "-" + identForMessageId++;
|
||||
timestamp.Created = DateTime.Now;
|
||||
// FIXME: on service side, use element.LocalServiceSettings.TimestampValidityDuration
|
||||
timestamp.Expires = timestamp.Created.Add (element.LocalClientSettings.TimestampValidityDuration);
|
||||
header.AddContent (timestamp);
|
||||
AddTimestampToHeader (header, messageId + "-" + identForMessageId++);
|
||||
}
|
||||
|
||||
XmlNamespaceManager nsmgr = new XmlNamespaceManager (doc.NameTable);
|
||||
@@ -272,13 +263,10 @@ namespace System.ServiceModel.Channels.Security
|
||||
nsmgr.AddNamespace ("o11", Constants.Wss11Namespace);
|
||||
|
||||
/*WrappedKey*/SecurityToken primaryToken = null;
|
||||
DerivedKeySecurityToken dkeyToken = null;
|
||||
SecurityToken actualToken = null;
|
||||
SecurityKeyIdentifierClause actualClause = null;
|
||||
Signature sig = null;
|
||||
|
||||
List<DerivedKeySecurityToken> derivedKeys =
|
||||
new List<DerivedKeySecurityToken> ();
|
||||
|
||||
|
||||
SymmetricAlgorithm masterKey = new RijndaelManaged ();
|
||||
masterKey.KeySize = suite.DefaultSymmetricKeyLength;
|
||||
@@ -303,7 +291,6 @@ namespace System.ServiceModel.Channels.Security
|
||||
SecurityKeyIdentifierClause encClause = ShouldOutputEncryptedKey ?
|
||||
CounterParameters.CallCreateKeyIdentifierClause (encToken, !ShouldOutputEncryptedKey ? SecurityTokenReferenceStyle.Internal : includeEncToken ? Parameters.ReferenceStyle : SecurityTokenReferenceStyle.External) : null;
|
||||
|
||||
MessagePartSpecification sigSpec = SignaturePart;
|
||||
MessagePartSpecification encSpec = EncryptionPart;
|
||||
|
||||
// encryption key (possibly also used for signing)
|
||||
@@ -341,27 +328,11 @@ else
|
||||
|
||||
// generate derived key if needed
|
||||
if (CounterParameters.RequireDerivedKeys) {
|
||||
RijndaelManaged deriv = new RijndaelManaged ();
|
||||
deriv.KeySize = suite.DefaultEncryptionKeyDerivationLength;
|
||||
deriv.Mode = CipherMode.CBC;
|
||||
deriv.Padding = PaddingMode.ISO10126;
|
||||
deriv.GenerateKey ();
|
||||
dkeyToken = new DerivedKeySecurityToken (
|
||||
GenerateId (doc),
|
||||
null, // algorithm
|
||||
actualClause,
|
||||
new InMemorySymmetricSecurityKey (actualKey.Key),
|
||||
null, // name
|
||||
null, // generation
|
||||
null, // offset
|
||||
deriv.Key.Length,
|
||||
null, // label
|
||||
deriv.Key);
|
||||
derivedKeys.Add (dkeyToken);
|
||||
actualToken = dkeyToken;
|
||||
actualKey.Key = ((SymmetricSecurityKey) dkeyToken.SecurityKeys [0]).GetSymmetricKey ();
|
||||
actualClause = new LocalIdKeyIdentifierClause (dkeyToken.Id);
|
||||
header.AddContent (dkeyToken);
|
||||
var dkeyToken = CreateDerivedKey (GenerateId (doc), actualClause, actualKey);
|
||||
actualToken = dkeyToken;
|
||||
actualKey.Key = ((SymmetricSecurityKey)dkeyToken.SecurityKeys [0]).GetSymmetricKey ();
|
||||
actualClause = new LocalIdKeyIdentifierClause (dkeyToken.Id);
|
||||
header.AddContent (dkeyToken);
|
||||
}
|
||||
|
||||
ReferenceList refList = new ReferenceList ();
|
||||
@@ -397,7 +368,6 @@ else
|
||||
|
||||
XmlElement body = doc.SelectSingleNode ("/s:Envelope/s:Body/*", nsmgr) as XmlElement;
|
||||
string bodyId = null;
|
||||
XmlElement secElem = null;
|
||||
Collection<WSSignedXml> endorsedSignatures =
|
||||
new Collection<WSSignedXml> ();
|
||||
bool signatureProtection = (protectionOrder == MessageProtectionOrder.SignBeforeEncryptAndEncryptSignature);
|
||||
@@ -413,110 +383,29 @@ else
|
||||
case MessageProtectionOrder.SignBeforeEncrypt:
|
||||
case MessageProtectionOrder.SignBeforeEncryptAndEncryptSignature:
|
||||
|
||||
// sign
|
||||
// see clause 8 of WS-SecurityPolicy C.2.2
|
||||
WSSignedXml sxml = new WSSignedXml (doc);
|
||||
SecurityTokenReferenceKeyInfo sigKeyInfo;
|
||||
|
||||
sig = sxml.Signature;
|
||||
sig.SignedInfo.CanonicalizationMethod =
|
||||
suite.DefaultCanonicalizationAlgorithm;
|
||||
foreach (XmlElement elem in doc.SelectNodes ("/s:Envelope/s:Header/o:Security/u:Timestamp", nsmgr))
|
||||
CreateReference (sig, elem, elem.GetAttribute ("Id", Constants.WsuNamespace));
|
||||
foreach (XmlElement elem in doc.SelectNodes ("/s:Envelope/s:Header/o:Security/o11:SignatureConfirmation", nsmgr))
|
||||
CreateReference (sig, elem, elem.GetAttribute ("Id", Constants.WsuNamespace));
|
||||
foreach (SupportingTokenInfo tinfo in tokenInfos)
|
||||
if (tinfo.Mode != SecurityTokenAttachmentMode.Endorsing) {
|
||||
XmlElement el = sxml.GetIdElement (doc, tinfo.Token.Id);
|
||||
CreateReference (sig, el, el.GetAttribute ("Id", Constants.WsuNamespace));
|
||||
}
|
||||
XmlNodeList nodes = doc.SelectNodes ("/s:Envelope/s:Header/*", nsmgr);
|
||||
for (int i = 0; i < msg.Headers.Count; i++) {
|
||||
MessageHeaderInfo h = msg.Headers [i];
|
||||
if (h.Name == "Security" && h.Namespace == Constants.WssNamespace)
|
||||
secElem = nodes [i] as XmlElement;
|
||||
else if (sigSpec.HeaderTypes.Count == 0 ||
|
||||
sigSpec.HeaderTypes.Contains (new XmlQualifiedName (h.Name, h.Namespace))) {
|
||||
string id = GenerateId (doc);
|
||||
h.Id = id;
|
||||
CreateReference (sig, nodes [i] as XmlElement, id);
|
||||
}
|
||||
}
|
||||
if (sigSpec.IsBodyIncluded) {
|
||||
bodyId = GenerateId (doc);
|
||||
CreateReference (sig, body.ParentNode as XmlElement, bodyId);
|
||||
}
|
||||
|
||||
if (security.DefaultSignatureAlgorithm == SignedXml.XmlDsigHMACSHA1Url) {
|
||||
// FIXME: use appropriate hash algorithm
|
||||
sxml.ComputeSignature (new HMACSHA1 (actualKey.Key));
|
||||
sigKeyInfo = new SecurityTokenReferenceKeyInfo (actualClause, serializer, doc);
|
||||
}
|
||||
else {
|
||||
SecurityKeyIdentifierClause signClause =
|
||||
CounterParameters.CallCreateKeyIdentifierClause (signToken, includeSigToken ? CounterParameters.ReferenceStyle : SecurityTokenReferenceStyle.External);
|
||||
AsymmetricSecurityKey signKey = (AsymmetricSecurityKey) signToken.ResolveKeyIdentifierClause (signClause);
|
||||
sxml.SigningKey = signKey.GetAsymmetricAlgorithm (security.DefaultSignatureAlgorithm, true);
|
||||
sxml.ComputeSignature ();
|
||||
sigKeyInfo = new SecurityTokenReferenceKeyInfo (signClause, serializer, doc);
|
||||
}
|
||||
|
||||
sxml.KeyInfo = new KeyInfo ();
|
||||
sxml.KeyInfo.AddClause (sigKeyInfo);
|
||||
|
||||
if (!signatureProtection)
|
||||
header.AddContent (sig);
|
||||
|
||||
// endorse the signature with (signed)endorsing
|
||||
// supporting tokens.
|
||||
|
||||
foreach (SupportingTokenInfo tinfo in tokenInfos) {
|
||||
switch (tinfo.Mode) {
|
||||
case SecurityTokenAttachmentMode.Endorsing:
|
||||
case SecurityTokenAttachmentMode.SignedEndorsing:
|
||||
if (sxml.Signature.Id == null) {
|
||||
sig.Id = GenerateId (doc);
|
||||
secElem.AppendChild (sxml.GetXml ());
|
||||
}
|
||||
WSSignedXml ssxml = new WSSignedXml (doc);
|
||||
ssxml.Signature.SignedInfo.CanonicalizationMethod = suite.DefaultCanonicalizationAlgorithm;
|
||||
CreateReference (ssxml.Signature, doc, sig.Id);
|
||||
SecurityToken sst = tinfo.Token;
|
||||
SecurityKey ssk = sst.SecurityKeys [0]; // FIXME: could be different?
|
||||
SecurityKeyIdentifierClause tclause = new LocalIdKeyIdentifierClause (sst.Id); // FIXME: could be different?
|
||||
if (ssk is SymmetricSecurityKey) {
|
||||
SymmetricSecurityKey signKey = (SymmetricSecurityKey) ssk;
|
||||
ssxml.ComputeSignature (signKey.GetKeyedHashAlgorithm (suite.DefaultSymmetricSignatureAlgorithm));
|
||||
} else {
|
||||
AsymmetricSecurityKey signKey = (AsymmetricSecurityKey) ssk;
|
||||
ssxml.SigningKey = signKey.GetAsymmetricAlgorithm (suite.DefaultAsymmetricSignatureAlgorithm, true);
|
||||
ssxml.ComputeSignature ();
|
||||
}
|
||||
ssxml.KeyInfo.AddClause (new SecurityTokenReferenceKeyInfo (tclause, serializer, doc));
|
||||
if (!signatureProtection)
|
||||
header.AddContent (ssxml.Signature);
|
||||
endorsedSignatures.Add (ssxml);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
var sig = CreateSignature (doc, body, nsmgr, tokenInfos,
|
||||
actualClause, actualKey, signToken, includeSigToken,
|
||||
signatureProtection, header, endorsedSignatures,
|
||||
ref bodyId);
|
||||
|
||||
|
||||
// encrypt
|
||||
|
||||
WSEncryptedXml exml = new WSEncryptedXml (doc);
|
||||
|
||||
EncryptedData edata = Encrypt (body, actualKey, actualToken.Id, refList, actualClause, exml, doc);
|
||||
EncryptedData edata = Encrypt (body, actualKey, actualToken.Id, refList, actualClause, exml, doc, EncryptedXml.XmlEncElementContentUrl);
|
||||
EncryptedXml.ReplaceElement (body, edata, false);
|
||||
|
||||
// encrypt signature
|
||||
if (signatureProtection) {
|
||||
XmlElement sigxml = sig.GetXml ();
|
||||
edata = Encrypt (sigxml, actualKey, actualToken.Id, refList, actualClause, exml, doc);
|
||||
edata = Encrypt (sigxml, actualKey, actualToken.Id, refList, actualClause, exml, doc, EncryptedXml.XmlEncElementUrl);
|
||||
header.AddContent (edata);
|
||||
|
||||
foreach (WSSignedXml ssxml in endorsedSignatures) {
|
||||
sigxml = ssxml.GetXml ();
|
||||
edata = Encrypt (sigxml, actualKey, actualToken.Id, refList, actualClause, exml, doc);
|
||||
edata = Encrypt (sigxml, actualKey, actualToken.Id, refList, actualClause, exml, doc, EncryptedXml.XmlEncElementUrl);
|
||||
header.AddContent (edata);
|
||||
}
|
||||
|
||||
@@ -524,7 +413,7 @@ else
|
||||
Collection<Wss11SignatureConfirmation> confs = header.FindAll<Wss11SignatureConfirmation> ();
|
||||
int count = 0;
|
||||
foreach (XmlElement elem in doc.SelectNodes ("/s:Envelope/s:Header/o:Security/o11:SignatureConfirmation", nsmgr)) {
|
||||
edata = Encrypt (elem, actualKey, confs [count].Id, refList, actualClause, exml, doc);
|
||||
edata = Encrypt (elem, actualKey, confs [count].Id, refList, actualClause, exml, doc, EncryptedXml.XmlEncElementUrl);
|
||||
EncryptedXml.ReplaceElement (elem, edata, false);
|
||||
header.Contents.Insert (header.Contents.IndexOf (confs [count]), edata);
|
||||
header.Contents.Remove (confs [count++]);
|
||||
@@ -532,11 +421,12 @@ else
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// encrypt Encrypted supporting tokens
|
||||
foreach (SupportingTokenInfo tinfo in tokenInfos) {
|
||||
if (tinfo.Mode == SecurityTokenAttachmentMode.SignedEncrypted) {
|
||||
XmlElement el = exml.GetIdElement (doc, tinfo.Token.Id);
|
||||
tinfo.Encrypted = Encrypt (el, actualKey, actualToken.Id, refList, actualClause, exml, doc);
|
||||
tinfo.Encrypted = Encrypt (el, actualKey, actualToken.Id, refList, actualClause, exml, doc, EncryptedXml.XmlEncElementUrl);
|
||||
EncryptedXml.ReplaceElement (el, tinfo.Encrypted, false);
|
||||
header.Contents.Insert (header.Contents.IndexOf (tinfo.Token), tinfo.Encrypted);
|
||||
header.Contents.Remove (tinfo.Token);
|
||||
@@ -545,7 +435,10 @@ else
|
||||
break;
|
||||
}
|
||||
|
||||
Message ret = new WSSecurityMessage (Message.CreateMessage (msg.Version, msg.Headers.Action, new XmlNodeReader (doc.SelectSingleNode ("/s:Envelope/s:Body/*", nsmgr) as XmlElement)), bodyId);
|
||||
|
||||
|
||||
|
||||
Message ret = new WSSecurityMessage (Message.CreateMessage (msg.Version, action, new XmlNodeReader (doc.SelectSingleNode ("/s:Envelope/s:Body/*", nsmgr) as XmlElement)), bodyId);
|
||||
ret.Properties.Security = (SecurityMessageProperty) secprop.CreateCopy ();
|
||||
ret.Properties.Security.EncryptionKey = masterKey.Key;
|
||||
|
||||
@@ -559,7 +452,7 @@ else
|
||||
|
||||
ret.Headers.Clear ();
|
||||
ret.Headers.CopyHeadersFrom (msg);
|
||||
|
||||
|
||||
// Header contents are:
|
||||
// - Timestamp
|
||||
// - SignatureConfirmation if required
|
||||
@@ -589,6 +482,157 @@ else
|
||||
return ret;
|
||||
}
|
||||
|
||||
Signature CreateSignature (XmlDocument doc, XmlElement body,
|
||||
XmlNamespaceManager nsmgr,
|
||||
SupportingTokenInfoCollection tokenInfos,
|
||||
SecurityKeyIdentifierClause actualClause,
|
||||
SymmetricAlgorithm actualKey,
|
||||
SecurityToken signToken,
|
||||
bool includeSigToken,
|
||||
bool signatureProtection,
|
||||
WSSecurityMessageHeader header,
|
||||
Collection<WSSignedXml> endorsedSignatures,
|
||||
ref string bodyId)
|
||||
{
|
||||
// sign
|
||||
// see clause 8 of WS-SecurityPolicy C.2.2
|
||||
WSSignedXml sxml = new WSSignedXml (doc);
|
||||
SecurityTokenReferenceKeyInfo sigKeyInfo;
|
||||
XmlElement secElem = null;
|
||||
var sigSpec = SignaturePart;
|
||||
var serializer = security.TokenSerializer;
|
||||
var suite = security.Element.DefaultAlgorithmSuite;
|
||||
|
||||
var sig = sxml.Signature;
|
||||
sig.SignedInfo.CanonicalizationMethod =
|
||||
suite.DefaultCanonicalizationAlgorithm;
|
||||
foreach (XmlElement elem in doc.SelectNodes ("/s:Envelope/s:Header/o:Security/u:Timestamp", nsmgr))
|
||||
CreateReference(sig, elem, elem.GetAttribute ("Id", Constants.WsuNamespace));
|
||||
foreach (XmlElement elem in doc.SelectNodes ("/s:Envelope/s:Header/o:Security/o11:SignatureConfirmation", nsmgr))
|
||||
CreateReference(sig, elem, elem.GetAttribute ("Id", Constants.WsuNamespace));
|
||||
foreach (SupportingTokenInfo tinfo in tokenInfos)
|
||||
if (tinfo.Mode != SecurityTokenAttachmentMode.Endorsing) {
|
||||
XmlElement el = sxml.GetIdElement (doc, tinfo.Token.Id);
|
||||
CreateReference (sig, el, el.GetAttribute ("Id", Constants.WsuNamespace));
|
||||
}
|
||||
XmlNodeList nodes = doc.SelectNodes ("/s:Envelope/s:Header/*", nsmgr);
|
||||
for (int i = 0; i < msg.Headers.Count; i++) {
|
||||
MessageHeaderInfo h = msg.Headers [i];
|
||||
if (h.Name == "Security" && h.Namespace == Constants.WssNamespace)
|
||||
secElem = nodes [i] as XmlElement;
|
||||
else if ((sigSpec.HeaderTypes.Count == 0 ||
|
||||
sigSpec.HeaderTypes.Contains (new XmlQualifiedName(h.Name, h.Namespace))) &&
|
||||
(msg.Version.Addressing != AddressingVersion.None ||
|
||||
!String.Equals (h.Name, "Action", StringComparison.Ordinal))) {
|
||||
string id = GenerateId (doc);
|
||||
h.Id = id;
|
||||
CreateReference (sig, nodes [i] as XmlElement, id);
|
||||
}
|
||||
}
|
||||
if (sigSpec.IsBodyIncluded) {
|
||||
bodyId = GenerateId (doc);
|
||||
CreateReference (sig, body.ParentNode as XmlElement, bodyId);
|
||||
}
|
||||
|
||||
|
||||
if (security.DefaultSignatureAlgorithm == SignedXml.XmlDsigHMACSHA1Url) {
|
||||
// FIXME: use appropriate hash algorithm
|
||||
sxml.ComputeSignature (new HMACSHA1(actualKey.Key));
|
||||
sigKeyInfo = new SecurityTokenReferenceKeyInfo (actualClause, serializer, doc);
|
||||
} else {
|
||||
SecurityKeyIdentifierClause signClause =
|
||||
CounterParameters.CallCreateKeyIdentifierClause (signToken, includeSigToken ? CounterParameters.ReferenceStyle : SecurityTokenReferenceStyle.External);
|
||||
AsymmetricSecurityKey signKey = (AsymmetricSecurityKey)signToken.ResolveKeyIdentifierClause (signClause);
|
||||
sxml.SigningKey = signKey.GetAsymmetricAlgorithm (security.DefaultSignatureAlgorithm, true);
|
||||
sxml.ComputeSignature ();
|
||||
sigKeyInfo = new SecurityTokenReferenceKeyInfo (signClause, serializer, doc);
|
||||
}
|
||||
|
||||
sxml.KeyInfo = new KeyInfo ();
|
||||
sxml.KeyInfo.AddClause (sigKeyInfo);
|
||||
|
||||
if (!signatureProtection)
|
||||
header.AddContent (sig);
|
||||
|
||||
// endorse the signature with (signed)endorsing
|
||||
// supporting tokens.
|
||||
|
||||
foreach (SupportingTokenInfo tinfo in tokenInfos) {
|
||||
switch (tinfo.Mode) {
|
||||
case SecurityTokenAttachmentMode.Endorsing:
|
||||
case SecurityTokenAttachmentMode.SignedEndorsing:
|
||||
if (sxml.Signature.Id == null) {
|
||||
sig.Id = GenerateId (doc);
|
||||
secElem.AppendChild (sxml.GetXml ());
|
||||
}
|
||||
WSSignedXml ssxml = new WSSignedXml (doc);
|
||||
ssxml.Signature.SignedInfo.CanonicalizationMethod = suite.DefaultCanonicalizationAlgorithm;
|
||||
CreateReference (ssxml.Signature, doc, sig.Id);
|
||||
SecurityToken sst = tinfo.Token;
|
||||
SecurityKey ssk = sst.SecurityKeys [0]; // FIXME: could be different?
|
||||
SecurityKeyIdentifierClause tclause = new LocalIdKeyIdentifierClause (sst.Id); // FIXME: could be different?
|
||||
if (ssk is SymmetricSecurityKey) {
|
||||
SymmetricSecurityKey signKey = (SymmetricSecurityKey)ssk;
|
||||
ssxml.ComputeSignature (signKey.GetKeyedHashAlgorithm(suite.DefaultSymmetricSignatureAlgorithm));
|
||||
} else {
|
||||
AsymmetricSecurityKey signKey = (AsymmetricSecurityKey)ssk;
|
||||
ssxml.SigningKey = signKey.GetAsymmetricAlgorithm (suite.DefaultAsymmetricSignatureAlgorithm, true);
|
||||
ssxml.ComputeSignature ();
|
||||
}
|
||||
ssxml.KeyInfo.AddClause (new SecurityTokenReferenceKeyInfo (tclause, serializer, doc));
|
||||
if (!signatureProtection)
|
||||
header.AddContent (ssxml.Signature);
|
||||
endorsedSignatures.Add (ssxml);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
return sig;
|
||||
}
|
||||
|
||||
void AddAddressingToHeader (MessageHeaders headers)
|
||||
{
|
||||
// FIXME: get correct ReplyTo value
|
||||
if (Direction == MessageDirection.Input)
|
||||
headers.ReplyTo = new EndpointAddress (Constants.WsaAnonymousUri);
|
||||
|
||||
if (MessageTo != null)
|
||||
headers.To = MessageTo.Uri;
|
||||
}
|
||||
|
||||
DerivedKeySecurityToken CreateDerivedKey (string id,
|
||||
SecurityKeyIdentifierClause actualClause,
|
||||
SymmetricAlgorithm actualKey)
|
||||
{
|
||||
RijndaelManaged deriv = new RijndaelManaged ();
|
||||
deriv.KeySize = security.Element.DefaultAlgorithmSuite.DefaultEncryptionKeyDerivationLength;
|
||||
deriv.Mode = CipherMode.CBC;
|
||||
deriv.Padding = PaddingMode.ISO10126;
|
||||
deriv.GenerateKey ();
|
||||
var dkeyToken = new DerivedKeySecurityToken (
|
||||
id,
|
||||
null, // algorithm
|
||||
actualClause,
|
||||
new InMemorySymmetricSecurityKey (actualKey.Key),
|
||||
null, // name
|
||||
null, // generation
|
||||
null, // offset
|
||||
deriv.Key.Length,
|
||||
null, // label
|
||||
deriv.Key);
|
||||
return dkeyToken;
|
||||
}
|
||||
|
||||
void AddTimestampToHeader (WSSecurityMessageHeader header, string id)
|
||||
{
|
||||
WsuTimestamp timestamp = new WsuTimestamp ();
|
||||
timestamp.Id = id;
|
||||
timestamp.Created = DateTime.Now;
|
||||
// FIXME: on service side, use element.LocalServiceSettings.TimestampValidityDuration
|
||||
timestamp.Expires = timestamp.Created.Add (security.Element.LocalClientSettings.TimestampValidityDuration);
|
||||
header.AddContent (timestamp);
|
||||
}
|
||||
|
||||
void CreateReference (Signature sig, XmlElement el, string id)
|
||||
{
|
||||
CreateReference (sig, el.OwnerDocument, id);
|
||||
@@ -626,7 +670,7 @@ else
|
||||
throw new Exception (String.Format ("INTERNAL ERROR: Invalid canonicalization URL: {0}", url));
|
||||
}
|
||||
|
||||
EncryptedData Encrypt (XmlElement target, SymmetricAlgorithm actualKey, string ekeyId, ReferenceList refList, SecurityKeyIdentifierClause encClause, EncryptedXml exml, XmlDocument doc)
|
||||
EncryptedData Encrypt (XmlElement target, SymmetricAlgorithm actualKey, string ekeyId, ReferenceList refList, SecurityKeyIdentifierClause encClause, EncryptedXml exml, XmlDocument doc, string elementType)
|
||||
{
|
||||
SecurityAlgorithmSuite suite = security.Element.DefaultAlgorithmSuite;
|
||||
SecurityTokenSerializer serializer = security.TokenSerializer;
|
||||
@@ -634,7 +678,7 @@ else
|
||||
byte [] encrypted = exml.EncryptData (target, actualKey, false);
|
||||
EncryptedData edata = new EncryptedData ();
|
||||
edata.Id = GenerateId (doc);
|
||||
edata.Type = EncryptedXml.XmlEncElementContentUrl;
|
||||
edata.Type = elementType;
|
||||
edata.EncryptionMethod = new EncryptionMethod (suite.DefaultEncryptionAlgorithm);
|
||||
// FIXME: here wsse:DigestMethod should be embedded
|
||||
// inside EncryptionMethod. Since it is not possible
|
||||
@@ -668,7 +712,7 @@ else
|
||||
string ret = msg.Headers.Action;
|
||||
if (ret == null) {
|
||||
HttpRequestMessageProperty reqprop =
|
||||
msg.Properties ["Action"] as HttpRequestMessageProperty;
|
||||
msg.Properties[HttpRequestMessageProperty.Name] as HttpRequestMessageProperty;
|
||||
if (reqprop != null)
|
||||
ret = reqprop.Headers ["Action"];
|
||||
}
|
||||
@@ -716,8 +760,10 @@ else
|
||||
{
|
||||
var dic = Constants.SoapDictionary;
|
||||
writer.WriteStartElement ("s", dic.Add ("Body"), dic.Add (Version.Envelope.Namespace));
|
||||
if (body_id != null)
|
||||
writer.WriteAttributeString ("Id", Constants.WsuNamespace, body_id);
|
||||
|
||||
if (body_id != null)
|
||||
writer.WriteAttributeString ("u", "Id", Constants.WsuNamespace, body_id);
|
||||
|
||||
}
|
||||
|
||||
protected override void OnWriteBodyContents (XmlDictionaryWriter w)
|
||||
|
||||
+38
-6
@@ -372,27 +372,59 @@ namespace System.ServiceModel.Channels
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
|
||||
[MonoTODO]
|
||||
public static SecurityBindingElement
|
||||
CreateMutualCertificateBindingElement ()
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
return CreateMutualCertificateBindingElement (MessageSecurityVersion.Default, false);
|
||||
}
|
||||
|
||||
[MonoTODO]
|
||||
public static SecurityBindingElement
|
||||
CreateMutualCertificateBindingElement (MessageSecurityVersion version)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
return CreateMutualCertificateBindingElement (version, false);
|
||||
}
|
||||
|
||||
[MonoTODO]
|
||||
[MonoTODO("Does not support allowSerializedSigningTokenOnReply.")]
|
||||
public static SecurityBindingElement
|
||||
CreateMutualCertificateBindingElement (
|
||||
MessageSecurityVersion version,
|
||||
bool allowSerializedSigningTokenOnReply)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
if (version == null)
|
||||
throw new ArgumentNullException ("version");
|
||||
|
||||
if (allowSerializedSigningTokenOnReply)
|
||||
throw new NotSupportedException ("allowSerializedSigningTokenOnReply is not supported");
|
||||
|
||||
if (version.SecurityVersion == SecurityVersion.WSSecurity10) {
|
||||
|
||||
var recipient = new X509SecurityTokenParameters (
|
||||
X509KeyIdentifierClauseType.Any,
|
||||
SecurityTokenInclusionMode.Never);
|
||||
recipient.RequireDerivedKeys = false;
|
||||
|
||||
var initiator = new X509SecurityTokenParameters (
|
||||
X509KeyIdentifierClauseType.Any,
|
||||
SecurityTokenInclusionMode.AlwaysToRecipient);
|
||||
initiator.RequireDerivedKeys = false;
|
||||
|
||||
return new AsymmetricSecurityBindingElement (recipient, initiator) {
|
||||
MessageSecurityVersion = version
|
||||
};
|
||||
} else {
|
||||
X509SecurityTokenParameters p =
|
||||
new X509SecurityTokenParameters (X509KeyIdentifierClauseType.Thumbprint);
|
||||
p.RequireDerivedKeys = false;
|
||||
|
||||
var sym = new SymmetricSecurityBindingElement () {
|
||||
MessageSecurityVersion = version,
|
||||
RequireSignatureConfirmation = true
|
||||
};
|
||||
|
||||
sym.EndpointSupportingTokenParameters.Endorsing.Add (p);
|
||||
return sym;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
[MonoTODO]
|
||||
|
||||
@@ -47,6 +47,13 @@ namespace System.ServiceModel.Description
|
||||
return att;
|
||||
return null;
|
||||
}
|
||||
|
||||
public static T GetCustomAttribute<T> (this ParameterInfo pi, bool inherit) where T : Attribute
|
||||
{
|
||||
foreach (T att in pi.GetCustomAttributes (typeof (T), inherit))
|
||||
return att;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public class ContractDescription
|
||||
|
||||
+39
-16
@@ -3,8 +3,10 @@
|
||||
//
|
||||
// Author:
|
||||
// Atsushi Enomoto <[email protected]>
|
||||
// Atsushi Enomoto <[email protected]>
|
||||
//
|
||||
// Copyright (C) 2005-2007 Novell, Inc. http://www.novell.com
|
||||
// Copyright (C) 2011 Xamarin, Inc. http://xamarin.com
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
@@ -294,8 +296,21 @@ namespace System.ServiceModel.Description
|
||||
od.Behaviors.Add (new DataContractSerializerOperationBehavior (od, dfa));
|
||||
|
||||
od.Messages.Add (GetMessage (od, mi, oca, true, isCallback, null));
|
||||
if (!od.IsOneWay)
|
||||
od.Messages.Add (GetMessage (od, mi, oca, false, isCallback, asyncReturnType));
|
||||
if (!od.IsOneWay) {
|
||||
var md = GetMessage (od, mi, oca, false, isCallback, asyncReturnType);
|
||||
od.Messages.Add (md);
|
||||
var mpa = mi.ReturnParameter.GetCustomAttribute<MessageParameterAttribute> (true);
|
||||
if (mpa != null) {
|
||||
var mpd = md.Body.Parts.FirstOrDefault (pd => pd.Name == mpa.Name);
|
||||
if (mpd != null) {
|
||||
md.Body.Parts.Remove (mpd);
|
||||
md.Body.ReturnValue = mpd;
|
||||
mpd.Name = mpa.Name;
|
||||
}
|
||||
else if (md.Body.ReturnValue == null)
|
||||
throw new InvalidOperationException (String.Format ("Specified message part '{0}' in MessageParameterAttribute on the return value, was not found", mpa.Name));
|
||||
}
|
||||
}
|
||||
var knownTypeAtts =
|
||||
cd.ContractType.GetCustomAttributes (typeof (ServiceKnownTypeAttribute), false).Union (
|
||||
mi.GetCustomAttributes (typeof (ServiceKnownTypeAttribute), false)).Union (
|
||||
@@ -400,9 +415,21 @@ namespace System.ServiceModel.Description
|
||||
cd.Namespace.Length == 0 ? "urn:" : cd.Namespace.EndsWith ("/") ? "" : "/", cd.Name, "/",
|
||||
od.Name, isRequest ? String.Empty : "Response");
|
||||
|
||||
MessageDescription md;
|
||||
if (mca != null)
|
||||
return CreateMessageDescription (messageType, cd.Namespace, action, isRequest, isCallback, mca);
|
||||
return CreateMessageDescription (oca, plist, od.Name, cd.Namespace, action, isRequest, isCallback, retType, mi.ReturnTypeCustomAttributes);
|
||||
md = CreateMessageDescription (messageType, cd.Namespace, action, isRequest, isCallback, mca);
|
||||
else
|
||||
md = CreateMessageDescription (oca, plist, od.Name, cd.Namespace, action, isRequest, isCallback, retType);
|
||||
|
||||
// ReturnValue
|
||||
if (!isRequest) {
|
||||
MessagePartDescription mp = CreatePartCore (GetMessageParameterAttribute (mi.ReturnTypeCustomAttributes), od.Name + "Result", md.Body.WrapperNamespace);
|
||||
mp.Index = 0;
|
||||
mp.Type = mca != null ? typeof (void) : retType;
|
||||
md.Body.ReturnValue = mp;
|
||||
}
|
||||
|
||||
return md;
|
||||
}
|
||||
|
||||
public static MessageDescription CreateMessageDescription (
|
||||
@@ -443,6 +470,13 @@ namespace System.ServiceModel.Description
|
||||
pd.MemberInfo = bmi;
|
||||
md.Headers.Add (pd);
|
||||
}
|
||||
var mpa = bmi.GetCustomAttribute<MessagePropertyAttribute> (false);
|
||||
if (mpa != null) {
|
||||
var pd = new MessagePropertyDescription (mpa.Name ?? mname);
|
||||
pd.Type = MessageFilterOutByRef (mtype);
|
||||
pd.MemberInfo = bmi;
|
||||
md.Properties.Add (pd);
|
||||
}
|
||||
var mba = GetMessageBodyMemberAttribute (bmi);
|
||||
if (mba != null) {
|
||||
var pd = CreatePartCore (mba, mname, defaultNamespace);
|
||||
@@ -454,12 +488,11 @@ namespace System.ServiceModel.Description
|
||||
}
|
||||
}
|
||||
|
||||
// FIXME: fill headers and properties.
|
||||
return md;
|
||||
}
|
||||
|
||||
public static MessageDescription CreateMessageDescription (
|
||||
OperationContractAttribute oca, ParameterInfo[] plist, string name, string defaultNamespace, string action, bool isRequest, bool isCallback, Type retType, ICustomAttributeProvider retTypeAttributes)
|
||||
OperationContractAttribute oca, ParameterInfo[] plist, string name, string defaultNamespace, string action, bool isRequest, bool isCallback, Type retType)
|
||||
{
|
||||
var dir = isRequest ^ isCallback ? MessageDirection.Input : MessageDirection.Output;
|
||||
MessageDescription md = new MessageDescription (action, dir) { IsRequest = isRequest };
|
||||
@@ -492,16 +525,6 @@ namespace System.ServiceModel.Description
|
||||
mb.Parts.Add (pd);
|
||||
}
|
||||
|
||||
// ReturnValue
|
||||
if (!isRequest) {
|
||||
MessagePartDescription mp = CreatePartCore (GetMessageParameterAttribute (retTypeAttributes), name + "Result", mb.WrapperNamespace);
|
||||
mp.Index = 0;
|
||||
mp.Type = retType;
|
||||
mb.ReturnValue = mp;
|
||||
}
|
||||
|
||||
// FIXME: fill properties.
|
||||
|
||||
return md;
|
||||
}
|
||||
|
||||
|
||||
+11
-1
@@ -27,6 +27,7 @@
|
||||
//
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Net.Security;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Reflection;
|
||||
@@ -35,6 +36,7 @@ using System.Xml.Serialization;
|
||||
|
||||
namespace System.ServiceModel.Description
|
||||
{
|
||||
[DebuggerDisplay ("Name={name}, Namespace={ns}, Type={Type}, Index={index}}")]
|
||||
public class MessagePartDescription
|
||||
{
|
||||
int index;
|
||||
@@ -50,8 +52,8 @@ namespace System.ServiceModel.Description
|
||||
|
||||
public MessagePartDescription (string name, string ns)
|
||||
{
|
||||
this.name = name;
|
||||
this.ns = ns;
|
||||
this.Name = name;
|
||||
}
|
||||
|
||||
public int Index {
|
||||
@@ -66,6 +68,10 @@ namespace System.ServiceModel.Description
|
||||
|
||||
public string Name {
|
||||
get { return name; }
|
||||
internal set {
|
||||
name = value;
|
||||
XmlName = new XmlName (value);
|
||||
}
|
||||
}
|
||||
|
||||
public string Namespace {
|
||||
@@ -102,6 +108,10 @@ namespace System.ServiceModel.Description
|
||||
|
||||
#region internals required for moonlight compatibility
|
||||
|
||||
internal XmlName XmlName {
|
||||
get; private set;
|
||||
}
|
||||
|
||||
ICustomAttributeProvider additional_att_provider;
|
||||
|
||||
internal ICustomAttributeProvider AdditionalAttributesProvider {
|
||||
|
||||
+10
-3
@@ -300,11 +300,15 @@ namespace System.ServiceModel.Dispatcher
|
||||
((PropertyInfo) mi).SetValue (msgObject, pair.Value, null);
|
||||
}
|
||||
|
||||
foreach (MessagePartDescription partDesc in md.Body.Parts)
|
||||
var l = new List<MessagePartDescription> (md.Body.Parts);
|
||||
if (md.Body.ReturnValue != null)
|
||||
l.Add (md.Body.ReturnValue);
|
||||
foreach (MessagePartDescription partDesc in l)
|
||||
if (partDesc.MemberInfo is FieldInfo)
|
||||
((FieldInfo) partDesc.MemberInfo).SetValue (msgObject, parts [partDesc.Index]);
|
||||
else
|
||||
else if (partDesc.MemberInfo is PropertyInfo)
|
||||
((PropertyInfo) partDesc.MemberInfo).SetValue (msgObject, parts [partDesc.Index], null);
|
||||
// otherwise, it could be null (in case of undefined return value in MessageContract)
|
||||
}
|
||||
|
||||
void MessageObjectToParts (MessageDescription md, object msgObject, Dictionary<MessageHeaderDescription,object> headers, object [] parts)
|
||||
@@ -317,7 +321,10 @@ namespace System.ServiceModel.Dispatcher
|
||||
headers [headDesc] = ((PropertyInfo) mi).GetValue (msgObject, null);
|
||||
}
|
||||
|
||||
foreach (MessagePartDescription partDesc in md.Body.Parts)
|
||||
var l = new List<MessagePartDescription> (md.Body.Parts);
|
||||
if (md.Body.ReturnValue != null)
|
||||
l.Add (md.Body.ReturnValue);
|
||||
foreach (MessagePartDescription partDesc in l)
|
||||
if (partDesc.MemberInfo is FieldInfo)
|
||||
parts [partDesc.Index] = ((FieldInfo) partDesc.MemberInfo).GetValue (msgObject);
|
||||
else
|
||||
|
||||
+6
-2
@@ -68,8 +68,12 @@ namespace System.ServiceModel.Dispatcher
|
||||
public override bool Match (Message message)
|
||||
{
|
||||
Uri to = message.Headers.To;
|
||||
bool path = ((CultureInfo.InvariantCulture.CompareInfo.IsPrefix (to.AbsolutePath, address.Uri.AbsolutePath, CompareOptions.Ordinal)) &&
|
||||
(to.Port == address.Uri.Port));
|
||||
if (to == null)
|
||||
return false;
|
||||
if (to.ToString () == Constants.WsaAnonymousUri || to.Equals (EndpointAddress.AnonymousUri) || to.Equals (EndpointAddress.NoneUri))
|
||||
return true;
|
||||
|
||||
bool path = CultureInfo.InvariantCulture.CompareInfo.IsPrefix (to.AbsolutePath, address.Uri.AbsolutePath, CompareOptions.Ordinal);
|
||||
bool host = IncludeHostNameInComparison
|
||||
? (String.CompareOrdinal (to.Host, address.Uri.Host) == 0)
|
||||
: true;
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
//
|
||||
// Copyright (C) 2005-2010 Novell, Inc. http://www.novell.com
|
||||
// Copyright (C) 2008 Mainsoft Co. http://www.mainsoft.com
|
||||
// Copyright (C) 2011 Xamarin Inc. http://www.xamarin.com
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
@@ -65,6 +66,7 @@ namespace System.ServiceModel.Dispatcher
|
||||
m.IsReturnValue = isReturnValue;
|
||||
m.MemberName = partDesc.Name;
|
||||
m.MemberType = partDesc.Type;
|
||||
m.XmlAttributes = partDesc.MemberInfo == null ? new XmlAttributes () : new XmlAttributes (partDesc.MemberInfo);
|
||||
return m;
|
||||
}
|
||||
|
||||
|
||||
@@ -181,23 +181,10 @@ namespace System.ServiceModel
|
||||
CreateBindingElements ()
|
||||
{
|
||||
var list = new List<BindingElement> ();
|
||||
switch (Security.Mode) {
|
||||
#if !NET_2_1
|
||||
case BasicHttpSecurityMode.Message:
|
||||
if (Security.Message.ClientCredentialType != BasicHttpMessageCredentialType.Certificate)
|
||||
throw new InvalidOperationException ("When Message security is enabled in a BasicHttpBinding, the message security credential type must be BasicHttpMessageCredentialType.Certificate.");
|
||||
goto case BasicHttpSecurityMode.TransportWithMessageCredential;
|
||||
case BasicHttpSecurityMode.TransportWithMessageCredential:
|
||||
SecurityBindingElement sec;
|
||||
if (Security.Message.ClientCredentialType != BasicHttpMessageCredentialType.Certificate)
|
||||
// FIXME: pass proper security token parameters.
|
||||
sec = SecurityBindingElement.CreateCertificateOverTransportBindingElement ();
|
||||
else
|
||||
sec = new AsymmetricSecurityBindingElement ();
|
||||
list.Add (sec);
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
|
||||
var security = CreateSecurityBindingElement ();
|
||||
if (security != null)
|
||||
list.Add (security);
|
||||
|
||||
#if NET_2_1
|
||||
if (EnableHttpCookieContainer)
|
||||
@@ -209,6 +196,37 @@ namespace System.ServiceModel
|
||||
|
||||
return new BindingElementCollection (list.ToArray ());
|
||||
}
|
||||
|
||||
SecurityBindingElement CreateSecurityBindingElement ()
|
||||
{
|
||||
SecurityBindingElement element;
|
||||
switch (Security.Mode) {
|
||||
#if !NET_2_1
|
||||
case BasicHttpSecurityMode.Message:
|
||||
if (Security.Message.ClientCredentialType != BasicHttpMessageCredentialType.Certificate)
|
||||
throw new InvalidOperationException ("When Message security is enabled in a BasicHttpBinding, the message security credential type must be BasicHttpMessageCredentialType.Certificate.");
|
||||
element = SecurityBindingElement.CreateMutualCertificateBindingElement (
|
||||
MessageSecurityVersion.WSSecurity10WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10);
|
||||
break;
|
||||
|
||||
case BasicHttpSecurityMode.TransportWithMessageCredential:
|
||||
if (Security.Message.ClientCredentialType != BasicHttpMessageCredentialType.Certificate)
|
||||
// FIXME: pass proper security token parameters.
|
||||
element = SecurityBindingElement.CreateCertificateOverTransportBindingElement ();
|
||||
else
|
||||
element = new AsymmetricSecurityBindingElement ();
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
|
||||
#if !NET_2_1
|
||||
element.SetKeyDerivation (false);
|
||||
element.SecurityHeaderLayout = SecurityHeaderLayout.Lax;
|
||||
#endif
|
||||
return element;
|
||||
}
|
||||
|
||||
MessageEncodingBindingElement BuildMessageEncodingBindingElement ()
|
||||
{
|
||||
@@ -255,43 +273,26 @@ namespace System.ServiceModel
|
||||
h.ExtendedProtectionPolicy = Security.Transport.ExtendedProtectionPolicy;
|
||||
#endif
|
||||
|
||||
#if !NET_2_1
|
||||
switch (Security.Mode) {
|
||||
case BasicHttpSecurityMode.Transport:
|
||||
switch (Security.Transport.ClientCredentialType) {
|
||||
case HttpClientCredentialType.Basic:
|
||||
h.AuthenticationScheme = AuthenticationSchemes.Basic;
|
||||
break;
|
||||
case HttpClientCredentialType.Ntlm:
|
||||
h.AuthenticationScheme = AuthenticationSchemes.Ntlm;
|
||||
break;
|
||||
case HttpClientCredentialType.Windows:
|
||||
h.AuthenticationScheme = AuthenticationSchemes.Negotiate;
|
||||
break;
|
||||
case HttpClientCredentialType.Digest:
|
||||
h.AuthenticationScheme = AuthenticationSchemes.Digest;
|
||||
break;
|
||||
case HttpClientCredentialType.Certificate:
|
||||
var https = (HttpsTransportBindingElement) h;
|
||||
https.RequireClientCertificate = true;
|
||||
break;
|
||||
}
|
||||
#if !NET_2_1 || MOBILE
|
||||
switch (Security.Transport.ClientCredentialType) {
|
||||
case HttpClientCredentialType.Basic:
|
||||
h.AuthenticationScheme = AuthenticationSchemes.Basic;
|
||||
break;
|
||||
case BasicHttpSecurityMode.TransportCredentialOnly:
|
||||
switch (Security.Transport.ClientCredentialType) {
|
||||
case HttpClientCredentialType.Basic:
|
||||
h.AuthenticationScheme = AuthenticationSchemes.Basic;
|
||||
case HttpClientCredentialType.Ntlm:
|
||||
h.AuthenticationScheme = AuthenticationSchemes.Ntlm;
|
||||
break;
|
||||
case HttpClientCredentialType.Windows:
|
||||
h.AuthenticationScheme = AuthenticationSchemes.Negotiate;
|
||||
break;
|
||||
case HttpClientCredentialType.Digest:
|
||||
h.AuthenticationScheme = AuthenticationSchemes.Digest;
|
||||
break;
|
||||
case HttpClientCredentialType.Certificate:
|
||||
switch (Security.Mode) {
|
||||
case BasicHttpSecurityMode.Transport:
|
||||
(h as HttpsTransportBindingElement).RequireClientCertificate = true;
|
||||
break;
|
||||
case HttpClientCredentialType.Ntlm:
|
||||
h.AuthenticationScheme = AuthenticationSchemes.Ntlm;
|
||||
break;
|
||||
case HttpClientCredentialType.Windows:
|
||||
h.AuthenticationScheme = AuthenticationSchemes.Negotiate;
|
||||
break;
|
||||
case HttpClientCredentialType.Digest:
|
||||
h.AuthenticationScheme = AuthenticationSchemes.Digest;
|
||||
break;
|
||||
case HttpClientCredentialType.Certificate:
|
||||
case BasicHttpSecurityMode.TransportCredentialOnly:
|
||||
throw new InvalidOperationException ("Certificate-based client authentication is not supported by 'TransportCredentialOnly' mode.");
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -25,6 +25,9 @@
|
||||
// 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;
|
||||
using System.Net.Security;
|
||||
using System.ServiceModel.Security;
|
||||
@@ -37,14 +40,16 @@ namespace System.ServiceModel
|
||||
internal BasicHttpMessageSecurity ()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
#if !MOBILE
|
||||
SecurityAlgorithmSuite alg = SecurityAlgorithmSuite.Default;
|
||||
BasicHttpMessageCredentialType ctype;
|
||||
|
||||
public SecurityAlgorithmSuite AlgorithmSuite {
|
||||
get { return alg; }
|
||||
set { alg = value; }
|
||||
}
|
||||
#endif
|
||||
BasicHttpMessageCredentialType ctype;
|
||||
|
||||
public BasicHttpMessageCredentialType ClientCredentialType {
|
||||
get { return ctype; }
|
||||
@@ -52,3 +57,5 @@ namespace System.ServiceModel
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -183,7 +183,9 @@ namespace System.ServiceModel
|
||||
xw.WriteEndAttribute ();
|
||||
xw.WriteAttributeString ("Source", log.Source.ToString ());
|
||||
xw.WriteAttributeString ("Type", log.Type.FullName);
|
||||
log.Message.CreateMessage ().WriteMessage (xw);
|
||||
var msg = log.Message.CreateMessage ();
|
||||
if (!msg.IsEmpty)
|
||||
msg.WriteMessage (xw);
|
||||
xw.WriteEndElement ();
|
||||
xw.Close ();
|
||||
|
||||
|
||||
@@ -103,6 +103,7 @@ System.ServiceModel.Configuration/StandardBindingElementCollectionTest.cs
|
||||
System.ServiceModel.Configuration/StandardBindingElementTest.cs
|
||||
System.ServiceModel.Configuration/StandardEndpointsSectionTest.cs
|
||||
System.ServiceModel.Configuration/UserBinding.cs
|
||||
System.ServiceModel.Description/BugX41.cs
|
||||
System.ServiceModel.Description/ClientCredentialsTest.cs
|
||||
System.ServiceModel.Description/ContractDescriptionTest.cs
|
||||
System.ServiceModel.Description/FaultDescriptionTest.cs
|
||||
|
||||
@@ -0,0 +1,288 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.235
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace Dealerinfo.wsvDealerinfo {
|
||||
|
||||
|
||||
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
|
||||
[System.ServiceModel.ServiceContractAttribute(Namespace="http://programcallbean.accentry.accell.nl", ConfigurationName="wsvDealerinfo.WSVDealerInfoServices")]
|
||||
public interface WSVDealerInfoServices {
|
||||
|
||||
// CODEGEN: Parameter 'wsvdealerinfo_XMLReturn' requires additional schema information that cannot be captured using the parameter mode. The specific attribute is 'System.Xml.Serialization.XmlElementAttribute'.
|
||||
[System.ServiceModel.OperationContractAttribute(Action="wsvdealerinfo_XML", ReplyAction="*")]
|
||||
[System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults=true)]
|
||||
[return: System.ServiceModel.MessageParameterAttribute(Name="wsvdealerinfo_XMLReturn")]
|
||||
Dealerinfo.wsvDealerinfo.wsvdealerinfo_XMLResponse wsvdealerinfo_XML(Dealerinfo.wsvDealerinfo.wsvdealerinfo_XMLRequest request);
|
||||
|
||||
// CODEGEN: Parameter 'wsvdealerinfoReturn' requires additional schema information that cannot be captured using the parameter mode. The specific attribute is 'System.Xml.Serialization.XmlElementAttribute'.
|
||||
[System.ServiceModel.OperationContractAttribute(Action="wsvdealerinfo", ReplyAction="*")]
|
||||
[System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults=true)]
|
||||
[return: System.ServiceModel.MessageParameterAttribute(Name="wsvdealerinfoReturn")]
|
||||
Dealerinfo.wsvDealerinfo.wsvdealerinfoResponse wsvdealerinfo(Dealerinfo.wsvDealerinfo.wsvdealerinfoRequest request);
|
||||
}
|
||||
|
||||
/// <remarks/>
|
||||
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.0.30319.1")]
|
||||
[System.SerializableAttribute()]
|
||||
[System.Diagnostics.DebuggerStepThroughAttribute()]
|
||||
[System.ComponentModel.DesignerCategoryAttribute("code")]
|
||||
[System.Xml.Serialization.XmlTypeAttribute(Namespace="http://programcallbean.accentry.accell.nl")]
|
||||
public partial class WSVDealerInfoInput : object, System.ComponentModel.INotifyPropertyChanged {
|
||||
|
||||
private string returncodeField;
|
||||
|
||||
private string wSVBedrijfscodeField;
|
||||
|
||||
private string wSVDealercodeField;
|
||||
|
||||
private string wSVWachtwoordField;
|
||||
|
||||
/// <remarks/>
|
||||
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, IsNullable=true, Order=0)]
|
||||
public string returncode {
|
||||
get {
|
||||
return this.returncodeField;
|
||||
}
|
||||
set {
|
||||
this.returncodeField = value;
|
||||
this.RaisePropertyChanged("returncode");
|
||||
}
|
||||
}
|
||||
|
||||
/// <remarks/>
|
||||
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, IsNullable=true, Order=1)]
|
||||
public string WSVBedrijfscode {
|
||||
get {
|
||||
return this.wSVBedrijfscodeField;
|
||||
}
|
||||
set {
|
||||
this.wSVBedrijfscodeField = value;
|
||||
this.RaisePropertyChanged("WSVBedrijfscode");
|
||||
}
|
||||
}
|
||||
|
||||
/// <remarks/>
|
||||
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, IsNullable=true, Order=2)]
|
||||
public string WSVDealercode {
|
||||
get {
|
||||
return this.wSVDealercodeField;
|
||||
}
|
||||
set {
|
||||
this.wSVDealercodeField = value;
|
||||
this.RaisePropertyChanged("WSVDealercode");
|
||||
}
|
||||
}
|
||||
|
||||
/// <remarks/>
|
||||
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, IsNullable=true, Order=3)]
|
||||
public string WSVWachtwoord {
|
||||
get {
|
||||
return this.wSVWachtwoordField;
|
||||
}
|
||||
set {
|
||||
this.wSVWachtwoordField = value;
|
||||
this.RaisePropertyChanged("WSVWachtwoord");
|
||||
}
|
||||
}
|
||||
|
||||
public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
protected void RaisePropertyChanged(string propertyName) {
|
||||
System.ComponentModel.PropertyChangedEventHandler propertyChanged = this.PropertyChanged;
|
||||
if ((propertyChanged != null)) {
|
||||
propertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <remarks/>
|
||||
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.0.30319.1")]
|
||||
[System.SerializableAttribute()]
|
||||
[System.Diagnostics.DebuggerStepThroughAttribute()]
|
||||
[System.ComponentModel.DesignerCategoryAttribute("code")]
|
||||
[System.Xml.Serialization.XmlTypeAttribute(Namespace="http://programcallbean.accentry.accell.nl")]
|
||||
public partial class WSVDealerInfoResult : object, System.ComponentModel.INotifyPropertyChanged {
|
||||
|
||||
private string returncodeField;
|
||||
|
||||
private string wSVFoutmeldingField;
|
||||
|
||||
private string wSVDealerinfoField;
|
||||
|
||||
/// <remarks/>
|
||||
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, IsNullable=true, Order=0)]
|
||||
public string returncode {
|
||||
get {
|
||||
return this.returncodeField;
|
||||
}
|
||||
set {
|
||||
this.returncodeField = value;
|
||||
this.RaisePropertyChanged("returncode");
|
||||
}
|
||||
}
|
||||
|
||||
/// <remarks/>
|
||||
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, IsNullable=true, Order=1)]
|
||||
public string WSVFoutmelding {
|
||||
get {
|
||||
return this.wSVFoutmeldingField;
|
||||
}
|
||||
set {
|
||||
this.wSVFoutmeldingField = value;
|
||||
this.RaisePropertyChanged("WSVFoutmelding");
|
||||
}
|
||||
}
|
||||
|
||||
/// <remarks/>
|
||||
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, IsNullable=true, Order=2)]
|
||||
public string WSVDealerinfo {
|
||||
get {
|
||||
return this.wSVDealerinfoField;
|
||||
}
|
||||
set {
|
||||
this.wSVDealerinfoField = value;
|
||||
this.RaisePropertyChanged("WSVDealerinfo");
|
||||
}
|
||||
}
|
||||
|
||||
public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
protected void RaisePropertyChanged(string propertyName) {
|
||||
System.ComponentModel.PropertyChangedEventHandler propertyChanged = this.PropertyChanged;
|
||||
if ((propertyChanged != null)) {
|
||||
propertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[System.Diagnostics.DebuggerStepThroughAttribute()]
|
||||
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
|
||||
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
[System.ServiceModel.MessageContractAttribute(WrapperName="wsvdealerinfo_XML", WrapperNamespace="http://programcallbean.accentry.accell.nl", IsWrapped=true)]
|
||||
public partial class wsvdealerinfo_XMLRequest {
|
||||
|
||||
[System.ServiceModel.MessageBodyMemberAttribute(Namespace="http://programcallbean.accentry.accell.nl", Order=0)]
|
||||
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, IsNullable=true)]
|
||||
public Dealerinfo.wsvDealerinfo.WSVDealerInfoInput inputData;
|
||||
|
||||
public wsvdealerinfo_XMLRequest() {
|
||||
}
|
||||
|
||||
public wsvdealerinfo_XMLRequest(Dealerinfo.wsvDealerinfo.WSVDealerInfoInput inputData) {
|
||||
this.inputData = inputData;
|
||||
}
|
||||
}
|
||||
|
||||
[System.Diagnostics.DebuggerStepThroughAttribute()]
|
||||
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
|
||||
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
[System.ServiceModel.MessageContractAttribute(WrapperName="wsvdealerinfo_XMLResponse", WrapperNamespace="http://programcallbean.accentry.accell.nl", IsWrapped=true)]
|
||||
public partial class wsvdealerinfo_XMLResponse {
|
||||
|
||||
[System.ServiceModel.MessageBodyMemberAttribute(Namespace="http://programcallbean.accentry.accell.nl", Order=0)]
|
||||
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, IsNullable=true)]
|
||||
public string wsvdealerinfo_XMLReturn;
|
||||
|
||||
public wsvdealerinfo_XMLResponse() {
|
||||
}
|
||||
|
||||
public wsvdealerinfo_XMLResponse(string wsvdealerinfo_XMLReturn) {
|
||||
this.wsvdealerinfo_XMLReturn = wsvdealerinfo_XMLReturn;
|
||||
}
|
||||
}
|
||||
|
||||
[System.Diagnostics.DebuggerStepThroughAttribute()]
|
||||
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
|
||||
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
[System.ServiceModel.MessageContractAttribute(WrapperName="wsvdealerinfo", WrapperNamespace="http://programcallbean.accentry.accell.nl", IsWrapped=true)]
|
||||
public partial class wsvdealerinfoRequest {
|
||||
|
||||
[System.ServiceModel.MessageBodyMemberAttribute(Namespace="http://programcallbean.accentry.accell.nl", Order=0)]
|
||||
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, IsNullable=true)]
|
||||
public Dealerinfo.wsvDealerinfo.WSVDealerInfoInput inputData;
|
||||
|
||||
public wsvdealerinfoRequest() {
|
||||
}
|
||||
|
||||
public wsvdealerinfoRequest(Dealerinfo.wsvDealerinfo.WSVDealerInfoInput inputData) {
|
||||
this.inputData = inputData;
|
||||
}
|
||||
}
|
||||
|
||||
[System.Diagnostics.DebuggerStepThroughAttribute()]
|
||||
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
|
||||
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
[System.ServiceModel.MessageContractAttribute(WrapperName="wsvdealerinfoResponse", WrapperNamespace="http://programcallbean.accentry.accell.nl", IsWrapped=true)]
|
||||
public partial class wsvdealerinfoResponse {
|
||||
|
||||
[System.ServiceModel.MessageBodyMemberAttribute(Namespace="http://programcallbean.accentry.accell.nl", Order=0)]
|
||||
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, IsNullable=true)]
|
||||
public Dealerinfo.wsvDealerinfo.WSVDealerInfoResult wsvdealerinfoReturn;
|
||||
|
||||
public wsvdealerinfoResponse() {
|
||||
}
|
||||
|
||||
public wsvdealerinfoResponse(Dealerinfo.wsvDealerinfo.WSVDealerInfoResult wsvdealerinfoReturn) {
|
||||
this.wsvdealerinfoReturn = wsvdealerinfoReturn;
|
||||
}
|
||||
}
|
||||
|
||||
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
|
||||
public interface WSVDealerInfoServicesChannel : Dealerinfo.wsvDealerinfo.WSVDealerInfoServices, System.ServiceModel.IClientChannel {
|
||||
}
|
||||
|
||||
[System.Diagnostics.DebuggerStepThroughAttribute()]
|
||||
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
|
||||
public partial class WSVDealerInfoServicesClient : System.ServiceModel.ClientBase<Dealerinfo.wsvDealerinfo.WSVDealerInfoServices>, Dealerinfo.wsvDealerinfo.WSVDealerInfoServices {
|
||||
|
||||
public WSVDealerInfoServicesClient() {
|
||||
}
|
||||
|
||||
public WSVDealerInfoServicesClient(string endpointConfigurationName) :
|
||||
base(endpointConfigurationName) {
|
||||
}
|
||||
|
||||
public WSVDealerInfoServicesClient(string endpointConfigurationName, string remoteAddress) :
|
||||
base(endpointConfigurationName, remoteAddress) {
|
||||
}
|
||||
|
||||
public WSVDealerInfoServicesClient(string endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress) :
|
||||
base(endpointConfigurationName, remoteAddress) {
|
||||
}
|
||||
|
||||
public WSVDealerInfoServicesClient(System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) :
|
||||
base(binding, remoteAddress) {
|
||||
}
|
||||
|
||||
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
Dealerinfo.wsvDealerinfo.wsvdealerinfo_XMLResponse Dealerinfo.wsvDealerinfo.WSVDealerInfoServices.wsvdealerinfo_XML(Dealerinfo.wsvDealerinfo.wsvdealerinfo_XMLRequest request) {
|
||||
return base.Channel.wsvdealerinfo_XML(request);
|
||||
}
|
||||
|
||||
public string wsvdealerinfo_XML(Dealerinfo.wsvDealerinfo.WSVDealerInfoInput inputData) {
|
||||
Dealerinfo.wsvDealerinfo.wsvdealerinfo_XMLRequest inValue = new Dealerinfo.wsvDealerinfo.wsvdealerinfo_XMLRequest();
|
||||
inValue.inputData = inputData;
|
||||
Dealerinfo.wsvDealerinfo.wsvdealerinfo_XMLResponse retVal = ((Dealerinfo.wsvDealerinfo.WSVDealerInfoServices)(this)).wsvdealerinfo_XML(inValue);
|
||||
return retVal.wsvdealerinfo_XMLReturn;
|
||||
}
|
||||
|
||||
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
Dealerinfo.wsvDealerinfo.wsvdealerinfoResponse Dealerinfo.wsvDealerinfo.WSVDealerInfoServices.wsvdealerinfo(Dealerinfo.wsvDealerinfo.wsvdealerinfoRequest request) {
|
||||
return base.Channel.wsvdealerinfo(request);
|
||||
}
|
||||
|
||||
public Dealerinfo.wsvDealerinfo.WSVDealerInfoResult wsvdealerinfo(Dealerinfo.wsvDealerinfo.WSVDealerInfoInput inputData) {
|
||||
Dealerinfo.wsvDealerinfo.wsvdealerinfoRequest inValue = new Dealerinfo.wsvDealerinfo.wsvdealerinfoRequest();
|
||||
inValue.inputData = inputData;
|
||||
Dealerinfo.wsvDealerinfo.wsvdealerinfoResponse retVal = ((Dealerinfo.wsvDealerinfo.WSVDealerInfoServices)(this)).wsvdealerinfo(inValue);
|
||||
return retVal.wsvdealerinfoReturn;
|
||||
}
|
||||
}
|
||||
}
|
||||
+43
@@ -5,6 +5,7 @@
|
||||
// Atsushi Enomoto <[email protected]>
|
||||
//
|
||||
// Copyright (C) 2005 Novell, Inc. http://www.novell.com
|
||||
// Copyright (C) 2011 Xamarin, Inc. http://xamarin.com
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
@@ -544,6 +545,35 @@ namespace MonoTests.System.ServiceModel.Description
|
||||
Assert.IsNotNull (xb, "#1");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void MessageParameterDescriptionInUse ()
|
||||
{
|
||||
// bug #41
|
||||
var cd = ContractDescription.GetContract (typeof (Dealerinfo.wsvDealerinfo.WSVDealerInfoServices));
|
||||
foreach (var od in cd.Operations)
|
||||
foreach (var md in od.Messages)
|
||||
if (md.Action == "*") // return
|
||||
Assert.IsNotNull (md.Body.ReturnValue, od.Name);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void BugX206Contract ()
|
||||
{
|
||||
var cd = ContractDescription.GetContract (typeof (BugX206Service));
|
||||
bool examined = false;
|
||||
foreach (var md in cd.Operations.First ().Messages) {
|
||||
if (md.Direction == MessageDirection.Input)
|
||||
continue;
|
||||
var pd = md.Body.ReturnValue;
|
||||
Assert.IsNotNull (pd, "#1");
|
||||
Assert.AreEqual ("DoWorkResult", pd.Name, "#2");
|
||||
Assert.IsNull (pd.MemberInfo, "#3");
|
||||
Assert.AreEqual (typeof (void), pd.Type, "#4");
|
||||
examined = true;
|
||||
}
|
||||
Assert.IsTrue (examined, "end");
|
||||
}
|
||||
|
||||
// It is for testing attribute search in interfaces.
|
||||
public class Foo : IFoo
|
||||
{
|
||||
@@ -905,5 +935,18 @@ namespace MonoTests.System.ServiceModel.Description
|
||||
[XmlSerializerFormat]
|
||||
string Echo (string input);
|
||||
}
|
||||
|
||||
[ServiceContract]
|
||||
public interface BugX206Service
|
||||
{
|
||||
[OperationContract]
|
||||
BugX206Response DoWork ();
|
||||
}
|
||||
|
||||
[MessageContract (IsWrapped = true)]
|
||||
public partial class BugX206Response
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
+73
@@ -34,7 +34,9 @@ using System.ServiceModel;
|
||||
using System.ServiceModel.Channels;
|
||||
using System.ServiceModel.Description;
|
||||
using System.ServiceModel.Dispatcher;
|
||||
using System.Text;
|
||||
using System.Xml;
|
||||
using System.Xml.Serialization;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace MonoTests.System.ServiceModel.Description
|
||||
@@ -119,6 +121,49 @@ namespace MonoTests.System.ServiceModel.Description
|
||||
Assert.AreEqual ("test", t2.echo.msg, "#01");
|
||||
Assert.AreEqual ("testtest", t2.body2, "#02");
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void XmlSerializerdWithXmlAttribute()
|
||||
{
|
||||
TypedMessageConverter c = TypedMessageConverter.Create (
|
||||
typeof (Test3), "http://tempuri.org/MyTest",
|
||||
new XmlSerializerFormatAttribute ());
|
||||
|
||||
|
||||
string xmlMessage = @"<s:Envelope xmlns:s='http://www.w3.org/2003/05/soap-envelope'
|
||||
xmlns:a='http://www.w3.org/2005/08/addressing'>
|
||||
<s:Header><a:Action s:mustUnderstand='1'>http://tempuri.org/MyTest</a:Action></s:Header>
|
||||
<s:Body xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema'>
|
||||
<test xmlns='urn:foo'>
|
||||
<Id>OneID</Id>
|
||||
<Element>
|
||||
<Prop1 xmlns='urn:bar'>foo</Prop1>
|
||||
<Prop2 xmlns='urn:bar'>2</Prop2>
|
||||
</Element>
|
||||
<Element>
|
||||
<Prop1 xmlns='urn:bar'>bar</Prop1>
|
||||
<Prop2 xmlns='urn:bar'>3</Prop2>
|
||||
</Element>
|
||||
</test>
|
||||
</s:Body>
|
||||
</s:Envelope>";
|
||||
|
||||
byte[] buffer = Encoding.UTF8.GetBytes(xmlMessage);
|
||||
using (XmlDictionaryReader reader = XmlDictionaryReader.CreateTextReader(buffer, XmlDictionaryReaderQuotas.Max))
|
||||
{
|
||||
Message messagedisk = Message.CreateMessage(reader, int.MaxValue, MessageVersion.Soap12);
|
||||
Test3 obj = c.FromMessage(messagedisk) as Test3;
|
||||
Assert.IsNotNull(obj);
|
||||
Assert.AreEqual("OneID", obj.Id);
|
||||
Assert.IsNotNull(obj.ArrayOfElement);
|
||||
Assert.AreEqual(2, obj.ArrayOfElement.Length);
|
||||
Assert.AreEqual("foo", obj.ArrayOfElement[0].Prop1);
|
||||
Assert.AreEqual(3, obj.ArrayOfElement[1].Prop2);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
[MessageContract (WrapperNamespace = "space", WrapperName = "MyName")]
|
||||
@@ -146,4 +191,32 @@ namespace MonoTests.System.ServiceModel.Description
|
||||
[MessageBodyMember (Name = "body", Namespace = "urn:foo")]
|
||||
public Echo Body { get; set; }
|
||||
}
|
||||
|
||||
[MessageContract(WrapperName = "test",
|
||||
WrapperNamespace = "urn:foo",
|
||||
IsWrapped = true)]
|
||||
public class Test3
|
||||
{
|
||||
|
||||
[MessageBodyMember()]
|
||||
[XmlElementAttribute()]
|
||||
public string Id;
|
||||
|
||||
[MessageBodyMember()]
|
||||
[XmlElement(Type = typeof(ElementType), ElementName = "Element")]
|
||||
public ElementType[] ArrayOfElement;
|
||||
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
[XmlType(Namespace = "urn:bar")]
|
||||
public class ElementType
|
||||
{
|
||||
[XmlElement(Order = 0)]
|
||||
public string Prop1 { get; set; }
|
||||
|
||||
[XmlElement(Order = 1)]
|
||||
public int Prop2 { get; set; }
|
||||
}
|
||||
|
||||
}
|
||||
-1
@@ -54,7 +54,6 @@ namespace MonoTests.System.ServiceModel.Dispatcher
|
||||
}
|
||||
|
||||
[Test]
|
||||
[Category ("NotWorking")]
|
||||
public void Match ()
|
||||
{
|
||||
PrefixEndpointAddressMessageFilter f =
|
||||
|
||||
@@ -173,7 +173,8 @@ System.ServiceModel.Security/UserNamePasswordClientCredential.cs
|
||||
System.ServiceModel/ActionNotSupportedException.cs
|
||||
System.ServiceModel/AllEnums.cs
|
||||
System.ServiceModel/BasicHttpBinding.cs
|
||||
System.ServiceModel/BasicHttpSecurity_2_1.cs
|
||||
System.ServiceModel/BasicHttpSecurity.cs
|
||||
System.ServiceModel/BasicHttpMessageSecurity.cs
|
||||
System.ServiceModel/ChannelFactory.cs
|
||||
System.ServiceModel/ChannelFactory_1.cs
|
||||
System.ServiceModel/ClientBase.cs
|
||||
@@ -200,6 +201,7 @@ System.ServiceModel/FaultException.cs
|
||||
System.ServiceModel/FaultException_1.cs
|
||||
System.ServiceModel/FaultReason.cs
|
||||
System.ServiceModel/FaultReasonText.cs
|
||||
System.ServiceModel/HttpTransportSecurity.cs
|
||||
System.ServiceModel/IClientChannel.cs
|
||||
System.ServiceModel/ICommunicationObject.cs
|
||||
System.ServiceModel/IContextChannel.cs
|
||||
|
||||
@@ -188,22 +188,22 @@ namespace System.Web.Routing
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool MatchConstraintRegex (string rx, string constraint)
|
||||
static bool MatchConstraintRegex (string value, string constraint)
|
||||
{
|
||||
int rxlen = rx.Length;
|
||||
if (rxlen > 0) {
|
||||
int len = constraint.Length;
|
||||
if (len > 0) {
|
||||
// Bug #651966 - regexp constraints must be treated
|
||||
// as absolute expressions
|
||||
if (rx [0] != '^') {
|
||||
rx = "^" + rx;
|
||||
rxlen++;
|
||||
if (constraint [0] != '^') {
|
||||
constraint = "^" + constraint;
|
||||
len++;
|
||||
}
|
||||
|
||||
if (rx [rxlen - 1] != '$')
|
||||
rx += "$";
|
||||
if (constraint [len - 1] != '$')
|
||||
constraint += "$";
|
||||
}
|
||||
|
||||
return Regex.Match (rx, constraint).Success;
|
||||
return Regex.Match (value, constraint).Success;
|
||||
}
|
||||
|
||||
protected virtual bool ProcessConstraint (HttpContextBase httpContext, object constraint, string parameterName, RouteValueDictionary values, RouteDirection routeDirection)
|
||||
|
||||
@@ -146,13 +146,15 @@ namespace System.Web.Compilation
|
||||
if (NeedsLoadFromBin && _compiler != null)
|
||||
return LoadTypeFromBin (_compiler, Parser);
|
||||
|
||||
// This is not called if compilation failed.
|
||||
// Returning null makes the caller throw an InvalidCastException
|
||||
Type type = null;
|
||||
Assembly assembly = results != null ? results.CompiledAssembly : null;
|
||||
if (assembly == null)
|
||||
return null;
|
||||
|
||||
return assembly.GetType (GetClassType (_compiler, Parser));
|
||||
if (assembly != null) {
|
||||
type = assembly.GetType (GetClassType (_compiler, Parser));
|
||||
}
|
||||
if (type == null) {
|
||||
throw new HttpException (500, String.Format ("Type {0} could not be loaded", GetClassType (_compiler, Parser)));
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
||||
// This is intended to be used by builders which may need to do special processing
|
||||
|
||||
@@ -77,14 +77,14 @@ EXTRA_DISTFILES = \
|
||||
$(nist_dom_files:%=Test/System.Xml/nist_dom/%)
|
||||
|
||||
System.Xml.XPath/Parser.cs: System.Xml.XPath/Parser.jay $(topdir)/jay/skeleton.cs
|
||||
$(topdir)/jay/jay -ct < $(topdir)/jay/skeleton.cs $< >$@
|
||||
$(topdir)/jay/jay -ct < $(topdir)/jay/skeleton.cs $(CURDIR)/$< >$@
|
||||
|
||||
Mono.Xml.Xsl/PatternParser.jay: System.Xml.XPath/Parser.jay $(topdir)/jay/skeleton.cs
|
||||
sed "s/\%start Expr/\%start Pattern/" $< >$@
|
||||
|
||||
Mono.Xml.Xsl/PatternParser.cs: Mono.Xml.Xsl/PatternParser.jay $(topdir)/jay/skeleton.cs
|
||||
echo "#define XSLT_PATTERN" > $@
|
||||
$(topdir)/jay/jay -ct $< < $(topdir)/jay/skeleton.cs >>$@
|
||||
$(topdir)/jay/jay -ct $(CURDIR)/$< < $(topdir)/jay/skeleton.cs >>$@
|
||||
|
||||
Mono.Xml.Xsl/PatternTokenizer.cs: System.Xml.XPath/Tokenizer.cs
|
||||
echo "#define XSLT_PATTERN" > $@
|
||||
|
||||
@@ -578,6 +578,10 @@ namespace Mono.Xml.XPath
|
||||
namespaces [nsIndex].Name = name;
|
||||
namespaces [nsIndex].Namespace = ns;
|
||||
namespaces [nsIndex].NextNamespace = nextNs;
|
||||
if (lineInfo != null && lineInfo.HasLineInfo ()) {
|
||||
namespaces [nsIndex].LineNumber = lineInfo.LineNumber;
|
||||
namespaces [nsIndex].LinePosition = lineInfo.LinePosition;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -118,14 +118,16 @@ namespace Mono.Xml.XPath
|
||||
int IXmlLineInfo.LineNumber {
|
||||
get {
|
||||
return currentIsAttr ? attributes [currentAttr].LineNumber :
|
||||
nodes [currentNode].LineNumber;
|
||||
currentIsNode ? nodes [currentNode].LineNumber :
|
||||
namespaces [currentNs].LineNumber;
|
||||
}
|
||||
}
|
||||
|
||||
int IXmlLineInfo.LinePosition {
|
||||
get {
|
||||
return currentIsAttr ? attributes [currentAttr].LinePosition :
|
||||
nodes [currentNode].LinePosition;
|
||||
currentIsNode ? nodes [currentNode].LinePosition :
|
||||
namespaces [currentNs].LinePosition;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -100,5 +100,7 @@ namespace Mono.Xml.XPath
|
||||
public int NextNamespace;
|
||||
public int Name;
|
||||
public int Namespace;
|
||||
public int LineNumber;
|
||||
public int LinePosition;
|
||||
}
|
||||
}
|
||||
@@ -444,7 +444,7 @@ namespace System.Xml.Serialization
|
||||
#if NET_2_0
|
||||
internal static Type GetGenericListItemType (Type type)
|
||||
{
|
||||
if (type.IsGenericType && type.GetGenericTypeDefinition () == typeof (IEnumerable<>)) {
|
||||
if (type.IsGenericType && typeof(IEnumerable).IsAssignableFrom(type.GetGenericTypeDefinition ())) {
|
||||
Type [] gatypes = type.GetGenericArguments ();
|
||||
if (type.GetMethod ("Add", gatypes) != null)
|
||||
return gatypes [0];
|
||||
|
||||
@@ -279,17 +279,21 @@ namespace System.Xml.Serialization
|
||||
sb.Append ("|");
|
||||
}
|
||||
|
||||
public int Order {
|
||||
internal int? Order {
|
||||
get {
|
||||
int order = -1;
|
||||
if (XmlElements != null)
|
||||
int? order = null;
|
||||
if (XmlElements.Count > 0)
|
||||
order = XmlElements.Order;
|
||||
if (order < 0 && XmlArray != null)
|
||||
else if (XmlArray != null)
|
||||
order = XmlArray.Order;
|
||||
if (order < 0 && XmlAnyElements != null)
|
||||
else if (XmlAnyElements.Count > 0)
|
||||
order = XmlAnyElements.Order;
|
||||
return order;
|
||||
}
|
||||
}
|
||||
|
||||
internal int SortableOrder {
|
||||
get { return Order != null ? (int) Order : int.MinValue; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -348,13 +348,17 @@ namespace System.Xml.Serialization {
|
||||
bool? isOrderExplicit = null;
|
||||
foreach (XmlReflectionMember rmember in members)
|
||||
{
|
||||
int? order = rmember.XmlAttributes.Order;
|
||||
if (isOrderExplicit == null)
|
||||
isOrderExplicit = rmember.XmlAttributes.Order >= 0;
|
||||
else if (isOrderExplicit != (rmember.XmlAttributes.Order >= 0))
|
||||
{
|
||||
if (order != null)
|
||||
isOrderExplicit = (int) order >= 0;
|
||||
}
|
||||
else if (order != null && isOrderExplicit != ((int) order >= 0))
|
||||
throw new InvalidOperationException ("Inconsistent XML sequence was detected. If there are XmlElement/XmlArray/XmlAnyElement attributes with explicit Order, then every other member must have an explicit order too.");
|
||||
}
|
||||
if (isOrderExplicit == true)
|
||||
members.Sort ((m1, m2) => m1.XmlAttributes.Order - m2.XmlAttributes.Order);
|
||||
members.Sort ((m1, m2) => (int) m1.XmlAttributes.SortableOrder - (int) m2.XmlAttributes.SortableOrder);
|
||||
|
||||
foreach (XmlReflectionMember rmember in members)
|
||||
{
|
||||
|
||||
@@ -111,13 +111,13 @@ namespace System.Xml
|
||||
|
||||
public XmlTextReader (string url, XmlNameTable nt)
|
||||
{
|
||||
string uriString;
|
||||
Stream stream = GetStreamFromUrl (url, out uriString);
|
||||
reader_uri = resolver.ResolveUri (null, url);
|
||||
string uriString = (reader_uri == null) ? String.Empty : reader_uri.ToString ();
|
||||
XmlParserContext ctx = new XmlParserContext (nt,
|
||||
new XmlNamespaceManager (nt),
|
||||
String.Empty,
|
||||
XmlSpace.None);
|
||||
this.InitializeContext (uriString, ctx, new XmlStreamReader (stream), XmlNodeType.Document);
|
||||
this.InitializeContext (uriString, ctx, null, XmlNodeType.Document);
|
||||
}
|
||||
|
||||
public XmlTextReader (TextReader input, XmlNameTable nt)
|
||||
@@ -138,6 +138,7 @@ namespace System.Xml
|
||||
}
|
||||
this.XmlResolver = resolver;
|
||||
string uriString;
|
||||
|
||||
Stream stream = GetStreamFromUrl (url, out uriString);
|
||||
this.InitializeContext (uriString, context, new XmlStreamReader (stream), fragType);
|
||||
}
|
||||
@@ -180,7 +181,12 @@ namespace System.Xml
|
||||
InitializeContext (url, context, fragment, fragType);
|
||||
}
|
||||
|
||||
private Stream GetStreamFromUrl (string url, out string absoluteUriString)
|
||||
Uri ResolveUri (string url)
|
||||
{
|
||||
return resolver.ResolveUri (null, url);
|
||||
}
|
||||
|
||||
Stream GetStreamFromUrl (string url, out string absoluteUriString)
|
||||
{
|
||||
#if NET_2_1
|
||||
if (url == null)
|
||||
@@ -188,7 +194,7 @@ namespace System.Xml
|
||||
if (url.Length == 0)
|
||||
throw new ArgumentException ("url");
|
||||
#endif
|
||||
Uri uri = resolver.ResolveUri (null, url);
|
||||
Uri uri = ResolveUri (url);
|
||||
absoluteUriString = uri != null ? uri.ToString () : String.Empty;
|
||||
return resolver.GetEntity (uri, null, typeof (Stream)) as Stream;
|
||||
}
|
||||
@@ -928,6 +934,7 @@ namespace System.Xml
|
||||
|
||||
private StringBuilder valueBuffer;
|
||||
|
||||
Uri reader_uri;
|
||||
private TextReader reader;
|
||||
private char [] peekChars;
|
||||
private int peekCharsIndex;
|
||||
@@ -1239,6 +1246,12 @@ namespace System.Xml
|
||||
|
||||
private bool ReadTextReader (int remained)
|
||||
{
|
||||
if (reader == null && reader_uri != null) {
|
||||
Uri uri = reader_uri;
|
||||
reader_uri = null;
|
||||
string uriString;
|
||||
reader = new XmlStreamReader (GetStreamFromUrl (uri.ToString (), out uriString));
|
||||
}
|
||||
if (peekCharsLength < 0) { // initialized buffer
|
||||
peekCharsLength = reader.Read (peekChars, 0, peekChars.Length);
|
||||
return peekCharsLength > 0;
|
||||
|
||||
@@ -1635,6 +1635,27 @@ namespace MonoTests.System.XmlSerialization
|
||||
var xs = new XmlSerializer (typeof (Bug704813Type));
|
||||
xs.Serialize (TextWriter.Null, new Bug704813Type ());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Bug708178Type()
|
||||
{
|
||||
XmlSerializer xmlSerializer = new XmlSerializer (typeof(Bug708178Type));
|
||||
Bug708178Type bugType = new Bug708178Type ();
|
||||
bugType.Foo.Add ("test");
|
||||
Assert.AreEqual (1, bugType.Foo.Count);
|
||||
|
||||
//xml Serialize
|
||||
TextWriter WriteFileStream = new StreamWriter (@"Bug708178Type.xml", false);
|
||||
xmlSerializer.Serialize (WriteFileStream, bugType);
|
||||
WriteFileStream.Close ();
|
||||
|
||||
//xml Deserialize
|
||||
FileStream ReadFileStream = new FileStream (@"Bug708178Type.xml", FileMode.Open, FileAccess.Read, FileShare.Read);
|
||||
Bug708178Type bugTypeReload = (Bug708178Type)xmlSerializer.Deserialize (ReadFileStream);
|
||||
|
||||
//should have deserialized the relationship
|
||||
Assert.AreEqual(1, bugTypeReload.Foo.Count);
|
||||
}
|
||||
#endif
|
||||
|
||||
public class Employee : IXmlSerializable
|
||||
|
||||
@@ -183,6 +183,22 @@ namespace MonoTests.System.XmlSerialization
|
||||
<child>Hello</child>
|
||||
<child>World</child>
|
||||
<child0>test</child0>
|
||||
</root>"));
|
||||
Assert.AreEqual ("Hello", result.Child1, "#1");
|
||||
Assert.AreEqual ("World", result.Child2, "#2");
|
||||
Assert.IsNull (result.Child0, "#3"); // not "test"
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ExplicitlyOrderedMembers4 ()
|
||||
{
|
||||
var xs = new XmlSerializer (typeof (ExplicitlyOrderedMembersType4));
|
||||
//Would result in an Inconsistent XML sequence error , see Bug 707434
|
||||
var result = (ExplicitlyOrderedMembersType4) xs.Deserialize(new StringReader (@"
|
||||
<root>
|
||||
<child>Hello</child>
|
||||
<child>World</child>
|
||||
<child0>test</child0>
|
||||
</root>"));
|
||||
Assert.AreEqual ("Hello", result.Child1, "#1");
|
||||
Assert.AreEqual ("World", result.Child2, "#2");
|
||||
|
||||
@@ -968,6 +968,16 @@ namespace MonoTests.System.Xml.TestClasses
|
||||
}
|
||||
}
|
||||
|
||||
public class Bug708178Type
|
||||
{
|
||||
List<string> foo = new List<string> ();
|
||||
|
||||
[XmlArray("Foo"), XmlArrayItem("Foo", typeof(string))]
|
||||
public List<string> Foo {
|
||||
get { return foo; }
|
||||
}
|
||||
}
|
||||
|
||||
[XmlRoot("root")]
|
||||
public class ExplicitlyOrderedMembersType1
|
||||
{
|
||||
@@ -1007,5 +1017,20 @@ namespace MonoTests.System.Xml.TestClasses
|
||||
public string Child2;
|
||||
}
|
||||
|
||||
[XmlRoot("root")]
|
||||
public class ExplicitlyOrderedMembersType4
|
||||
{
|
||||
[XmlElement("child0", Order = 1)] // it's between 0 and 2. After two "child" elements, child0 is not recognized as this member.
|
||||
public string Child0;
|
||||
|
||||
[XmlElement("child", Order = 0)]
|
||||
public string Child1;
|
||||
|
||||
[XmlElement("child", Order = 2)]
|
||||
public string Child2;
|
||||
|
||||
[XmlAttribute]
|
||||
public string Child3;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ using XPI = System.Xml.Linq.XProcessingInstruction;
|
||||
|
||||
namespace System.Xml.Linq
|
||||
{
|
||||
internal class XNodeReader : XmlReader
|
||||
internal class XNodeReader : XmlReader, IXmlLineInfo
|
||||
{
|
||||
ReadState state = ReadState.Initial;
|
||||
XNode node, start;
|
||||
@@ -46,6 +46,24 @@ namespace System.Xml.Linq
|
||||
start = node;
|
||||
}
|
||||
|
||||
int IXmlLineInfo.LineNumber {
|
||||
get {
|
||||
var o = (XObject) GetCurrentAttribute () ?? node;
|
||||
return o != null ? o.LineNumber : 0;
|
||||
}
|
||||
}
|
||||
int IXmlLineInfo.LinePosition {
|
||||
get {
|
||||
var o = (XObject) GetCurrentAttribute () ?? node;
|
||||
return o != null ? o.LinePosition : 0;
|
||||
}
|
||||
}
|
||||
bool IXmlLineInfo.HasLineInfo ()
|
||||
{
|
||||
var o = (XObject) GetCurrentAttribute () ?? node;
|
||||
return o != null ? ((IXmlLineInfo) o).HasLineInfo () : false;
|
||||
}
|
||||
|
||||
public override int AttributeCount {
|
||||
get {
|
||||
if (state != ReadState.Interactive || end_element)
|
||||
|
||||
@@ -182,9 +182,8 @@ namespace System.Collections.Generic
|
||||
|
||||
public void Clear ()
|
||||
{
|
||||
count = 0;
|
||||
first = null;
|
||||
version++;
|
||||
while (first != null)
|
||||
Remove (first);
|
||||
}
|
||||
|
||||
public bool Contains (T value)
|
||||
|
||||
@@ -214,8 +214,14 @@ namespace System.Net.Sockets
|
||||
throw new ArgumentOutOfRangeException("offset+size exceeds the size of buffer");
|
||||
}
|
||||
|
||||
Socket s = socket;
|
||||
|
||||
if (s == null) {
|
||||
throw new IOException("Connection closed");
|
||||
}
|
||||
|
||||
try {
|
||||
retval = socket.BeginReceive (buffer, offset, size, 0, callback, state);
|
||||
retval = s.BeginReceive (buffer, offset, size, 0, callback, state);
|
||||
} catch (Exception e) {
|
||||
throw new IOException ("BeginReceive failure", e);
|
||||
}
|
||||
@@ -240,8 +246,14 @@ namespace System.Net.Sockets
|
||||
throw new ArgumentOutOfRangeException("offset+size exceeds the size of buffer");
|
||||
}
|
||||
|
||||
Socket s = socket;
|
||||
|
||||
if (s == null) {
|
||||
throw new IOException("Connection closed");
|
||||
}
|
||||
|
||||
try {
|
||||
retval = socket.BeginSend (buffer, offset, size, 0, callback, state);
|
||||
retval = s.BeginSend (buffer, offset, size, 0, callback, state);
|
||||
} catch {
|
||||
throw new IOException ("BeginWrite failure");
|
||||
}
|
||||
@@ -316,8 +328,14 @@ namespace System.Net.Sockets
|
||||
if (ar == null)
|
||||
throw new ArgumentNullException ("async result is null");
|
||||
|
||||
Socket s = socket;
|
||||
|
||||
if (s == null) {
|
||||
throw new IOException("Connection closed");
|
||||
}
|
||||
|
||||
try {
|
||||
res = socket.EndReceive (ar);
|
||||
res = s.EndReceive (ar);
|
||||
} catch (Exception e) {
|
||||
throw new IOException ("EndRead failure", e);
|
||||
}
|
||||
@@ -330,8 +348,14 @@ namespace System.Net.Sockets
|
||||
if (ar == null)
|
||||
throw new ArgumentNullException ("async result is null");
|
||||
|
||||
Socket s = socket;
|
||||
|
||||
if (s == null) {
|
||||
throw new IOException("Connection closed");
|
||||
}
|
||||
|
||||
try {
|
||||
socket.EndSend (ar);
|
||||
s.EndSend (ar);
|
||||
} catch (Exception e) {
|
||||
throw new IOException ("EndWrite failure", e);
|
||||
}
|
||||
@@ -363,8 +387,14 @@ namespace System.Net.Sockets
|
||||
throw new ArgumentOutOfRangeException("offset+size exceeds the size of buffer");
|
||||
}
|
||||
|
||||
Socket s = socket;
|
||||
|
||||
if (s == null) {
|
||||
throw new IOException("Connection closed");
|
||||
}
|
||||
|
||||
try {
|
||||
res = socket.Receive (buffer, offset, size, 0);
|
||||
res = s.Receive (buffer, offset, size, 0);
|
||||
} catch (Exception e) {
|
||||
throw new IOException ("Read failure", e);
|
||||
}
|
||||
@@ -398,10 +428,16 @@ namespace System.Net.Sockets
|
||||
if (size < 0 || size > buffer.Length - offset)
|
||||
throw new ArgumentOutOfRangeException("offset+size exceeds the size of buffer");
|
||||
|
||||
Socket s = socket;
|
||||
|
||||
if (s == null) {
|
||||
throw new IOException("Connection closed");
|
||||
}
|
||||
|
||||
try {
|
||||
int count = 0;
|
||||
while (size - count > 0) {
|
||||
count += socket.Send (buffer, offset + count, size - count, 0);
|
||||
count += s.Send (buffer, offset + count, size - count, 0);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new IOException ("Write failure", e);
|
||||
|
||||
@@ -2,9 +2,10 @@
|
||||
//
|
||||
// Authors:
|
||||
// Marek Habersack ([email protected])
|
||||
// Gonzalo Paniagua Javier (gonzalo@novell.com)
|
||||
// Gonzalo Paniagua Javier (gonzalo@xamarin.com)
|
||||
//
|
||||
// Copyright (c) 2008,2010 Novell, Inc. (http://www.novell.com)
|
||||
// Copyright (c) 2011 Xamarin, Inc. (http://xamarin.com)
|
||||
//
|
||||
|
||||
//
|
||||
@@ -37,6 +38,8 @@ namespace System.Net.Sockets
|
||||
{
|
||||
public class SocketAsyncEventArgs : EventArgs, IDisposable
|
||||
{
|
||||
bool disposed;
|
||||
int in_progress;
|
||||
internal Socket.Worker Worker;
|
||||
EndPoint remote_ep;
|
||||
#if MOONLIGHT || NET_4_0
|
||||
@@ -147,7 +150,11 @@ namespace System.Net.Sockets
|
||||
|
||||
void Dispose (bool disposing)
|
||||
{
|
||||
disposed = true;
|
||||
|
||||
if (disposing) {
|
||||
if (disposed || Interlocked.CompareExchange (ref in_progress, 0, 0) != 0)
|
||||
return;
|
||||
if (Worker != null) {
|
||||
Worker.Dispose ();
|
||||
Worker = null;
|
||||
@@ -171,6 +178,10 @@ namespace System.Net.Sockets
|
||||
|
||||
internal void SetLastOperation (SocketAsyncOperation op)
|
||||
{
|
||||
if (disposed)
|
||||
throw new ObjectDisposedException ("System.Net.Sockets.SocketAsyncEventArgs");
|
||||
if (Interlocked.Exchange (ref in_progress, 1) != 0)
|
||||
throw new InvalidOperationException ("Operation already in progress");
|
||||
LastOperation = op;
|
||||
}
|
||||
|
||||
@@ -219,6 +230,8 @@ namespace System.Net.Sockets
|
||||
static void DispatcherCB (IAsyncResult ares)
|
||||
{
|
||||
SocketAsyncEventArgs args = (SocketAsyncEventArgs) ares.AsyncState;
|
||||
if (Interlocked.Exchange (ref args.in_progress, 0) != 1)
|
||||
throw new InvalidOperationException ("No operation in progress");
|
||||
SocketAsyncOperation op = args.LastOperation;
|
||||
// Notes;
|
||||
// -SocketOperation.AcceptReceive not used in SocketAsyncEventArgs
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
// Gonzalo Paniagua Javier ([email protected])
|
||||
//
|
||||
// (C) 2003 Ximian, Inc (http://www.ximian.com)
|
||||
// Copyright 2011 Xamarin, Inc (http://www.xamarin.com)
|
||||
//
|
||||
|
||||
//
|
||||
@@ -160,7 +161,7 @@ namespace System.Net
|
||||
if (rnd == null)
|
||||
rnd = new Random ();
|
||||
|
||||
int idx = (count > 1) ? rnd.Next (0, count - 1) : 0;
|
||||
int idx = (count > 1) ? rnd.Next (0, count) : 0;
|
||||
cncRef = (WeakReference) connections [idx];
|
||||
cnc = cncRef.Target as WebConnection;
|
||||
if (cnc == null) {
|
||||
|
||||
@@ -246,10 +246,10 @@ namespace System.Net
|
||||
[MonoTODO("Needs to respect Module, Proxy.AutoDetect, and Proxy.ScriptLocation config settings")]
|
||||
static IWebProxy GetDefaultWebProxy ()
|
||||
{
|
||||
WebProxy p = null;
|
||||
|
||||
#if CONFIGURATION_DEP
|
||||
DefaultProxySection sec = ConfigurationManager.GetSection ("system.net/defaultProxy") as DefaultProxySection;
|
||||
WebProxy p;
|
||||
|
||||
if (sec == null)
|
||||
return GetSystemWebProxy ();
|
||||
|
||||
@@ -265,8 +265,11 @@ namespace System.Net
|
||||
|
||||
if (pe.BypassOnLocal != ProxyElement.BypassOnLocalValues.Unspecified)
|
||||
p.BypassProxyOnLocal = (pe.BypassOnLocal == ProxyElement.BypassOnLocalValues.True);
|
||||
#endif
|
||||
|
||||
return p;
|
||||
#else
|
||||
return GetSystemWebProxy ();
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
//
|
||||
// (C) 2003 Motus Technologies Inc. (http://www.motus.com)
|
||||
// Copyright (C) 2004-2006 Novell Inc. (http://www.novell.com)
|
||||
// Copyright (C) 2011 Xamarin Inc. (http://www.xamarin.com)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
@@ -601,7 +602,7 @@ namespace System.Security.Cryptography.X509Certificates {
|
||||
// TODO 6.1.4.g-j
|
||||
|
||||
// 6.1.4.k - Verify that the certificate is a CA certificate
|
||||
X509BasicConstraintsExtension bce = (X509BasicConstraintsExtension) certificate.Extensions["2.5.29.19"];
|
||||
X509BasicConstraintsExtension bce = (certificate.Extensions["2.5.29.19"] as X509BasicConstraintsExtension);
|
||||
if (bce != null) {
|
||||
if (!bce.CertificateAuthority) {
|
||||
element.StatusFlags |= X509ChainStatusFlags.InvalidBasicConstraints;
|
||||
@@ -636,7 +637,7 @@ namespace System.Security.Cryptography.X509Certificates {
|
||||
}
|
||||
|
||||
// 6.1.4.n - if key usage extension is present...
|
||||
X509KeyUsageExtension kue = (X509KeyUsageExtension) certificate.Extensions["2.5.29.15"];
|
||||
X509KeyUsageExtension kue = (certificate.Extensions["2.5.29.15"] as X509KeyUsageExtension);
|
||||
if (kue != null) {
|
||||
// ... verify keyCertSign is set
|
||||
X509KeyUsageFlags success = X509KeyUsageFlags.KeyCertSign;
|
||||
@@ -703,7 +704,7 @@ namespace System.Security.Cryptography.X509Certificates {
|
||||
|
||||
private string GetSubjectKeyIdentifier (X509Certificate2 certificate)
|
||||
{
|
||||
X509SubjectKeyIdentifierExtension ski = (X509SubjectKeyIdentifierExtension) certificate.Extensions["2.5.29.14"];
|
||||
X509SubjectKeyIdentifierExtension ski = (certificate.Extensions["2.5.29.14"] as X509SubjectKeyIdentifierExtension);
|
||||
return (ski == null) ? String.Empty : ski.SubjectKeyIdentifier;
|
||||
}
|
||||
|
||||
@@ -816,7 +817,7 @@ namespace System.Security.Cryptography.X509Certificates {
|
||||
private X509ChainStatusFlags CheckRevocation (X509Certificate2 certificate, X509Certificate2 ca_cert, bool online)
|
||||
{
|
||||
// change this if/when we support OCSP
|
||||
X509KeyUsageExtension kue = (X509KeyUsageExtension) ca_cert.Extensions["2.5.29.15"];
|
||||
X509KeyUsageExtension kue = (ca_cert.Extensions["2.5.29.15"] as X509KeyUsageExtension);
|
||||
if (kue != null) {
|
||||
// ... verify CrlSign is set
|
||||
X509KeyUsageFlags success = X509KeyUsageFlags.CrlSign;
|
||||
@@ -834,7 +835,7 @@ namespace System.Security.Cryptography.X509Certificates {
|
||||
// crl = FindCrl (ca_cert, ref valid, ref out_of_date);
|
||||
|
||||
// We need to get the subjectAltName and an URI from there (or use OCSP)
|
||||
// X509KeyUsageExtension subjectAltName = (X509KeyUsageExtension) ca_cert.Extensions["2.5.29.17"];
|
||||
// X509KeyUsageExtension subjectAltName = (ca_cert.Extensions["2.5.29.17"] as X509KeyUsageExtension);
|
||||
}
|
||||
|
||||
if (crl != null) {
|
||||
|
||||
@@ -224,7 +224,7 @@ namespace System.Text.RegularExpressions {
|
||||
RegexOptions.IgnoreCase |
|
||||
RegexOptions.Multiline |
|
||||
RegexOptions.ExplicitCapture |
|
||||
#if !NET_2_1
|
||||
#if MOBILE || !NET_2_1
|
||||
RegexOptions.Compiled |
|
||||
#endif
|
||||
RegexOptions.Singleline |
|
||||
@@ -236,7 +236,7 @@ namespace System.Text.RegularExpressions {
|
||||
const RegexOptions ecmaopts =
|
||||
RegexOptions.IgnoreCase |
|
||||
RegexOptions.Multiline |
|
||||
#if !NET_2_1
|
||||
#if MOBILE || !NET_2_1
|
||||
RegexOptions.Compiled |
|
||||
#endif
|
||||
RegexOptions.ECMAScript;
|
||||
|
||||
@@ -35,7 +35,7 @@ namespace System.Text.RegularExpressions {
|
||||
IgnoreCase = 0x001,
|
||||
Multiline = 0x002,
|
||||
ExplicitCapture = 0x004,
|
||||
#if !NET_2_1
|
||||
#if MOBILE || !NET_2_1
|
||||
Compiled = 0x008,
|
||||
#endif
|
||||
Singleline = 0x010,
|
||||
|
||||
@@ -84,8 +84,13 @@ namespace MonoTests.System.Collections.Generic
|
||||
[Test]
|
||||
public void ClearTest ()
|
||||
{
|
||||
LinkedListNode <int> node = intlist.First;
|
||||
intlist.Clear ();
|
||||
|
||||
Assert.AreEqual (0, intlist.Count);
|
||||
Assert.AreEqual (2, node.Value);
|
||||
Assert.IsNull (node.Next);
|
||||
Assert.IsNull (node.Previous);
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
||||
@@ -17,15 +17,25 @@ namespace zipsharp
|
||||
AddInZip = 2
|
||||
}
|
||||
|
||||
[UnmanagedFunctionPointerAttribute (CallingConvention.Cdecl)]
|
||||
internal delegate IntPtr OpenFileFunc (IntPtr opaque, string filename, int mode);
|
||||
|
||||
[UnmanagedFunctionPointerAttribute (CallingConvention.Cdecl)]
|
||||
internal delegate /* ulong */ IntPtr ReadFileFunc (IntPtr opaque, IntPtr stream, IntPtr buffer, /* ulong */ IntPtr size);
|
||||
|
||||
[UnmanagedFunctionPointerAttribute (CallingConvention.Cdecl)]
|
||||
internal delegate /* ulong */ IntPtr WriteFileFunc (IntPtr opaque, IntPtr stream, IntPtr buffer, /* ulong */ IntPtr size);
|
||||
|
||||
[UnmanagedFunctionPointerAttribute (CallingConvention.Cdecl)]
|
||||
internal delegate /* long */ IntPtr TellFileFunc (IntPtr opaque, IntPtr stream);
|
||||
|
||||
[UnmanagedFunctionPointerAttribute (CallingConvention.Cdecl)]
|
||||
internal delegate /* long */ IntPtr SeekFileFunc (IntPtr opaque, IntPtr stream, /* ulong */ IntPtr offset, int origin);
|
||||
|
||||
[UnmanagedFunctionPointerAttribute (CallingConvention.Cdecl)]
|
||||
internal delegate int CloseFileFunc (IntPtr opaque, IntPtr stream);
|
||||
|
||||
[UnmanagedFunctionPointerAttribute (CallingConvention.Cdecl)]
|
||||
internal delegate int TestErrorFileFunc (IntPtr opaque, IntPtr stream);
|
||||
|
||||
[StructLayout (LayoutKind.Sequential)]
|
||||
@@ -38,6 +48,6 @@ namespace zipsharp
|
||||
[MarshalAs (UnmanagedType.FunctionPtr)] public SeekFileFunc zseek_file;
|
||||
[MarshalAs (UnmanagedType.FunctionPtr)] public CloseFileFunc zclose_file;
|
||||
[MarshalAs (UnmanagedType.FunctionPtr)] public TestErrorFileFunc zerror_file;
|
||||
[MarshalAs (UnmanagedType.FunctionPtr)] public IntPtr opaque;
|
||||
public IntPtr opaque;
|
||||
}
|
||||
}
|
||||
@@ -147,34 +147,34 @@ namespace zipsharp
|
||||
return unzReadCurrentFile (handle, b, (uint)count);
|
||||
}
|
||||
|
||||
[DllImport ("MonoPosixHelper")]
|
||||
[DllImport ("MonoPosixHelper", CallingConvention=CallingConvention.Cdecl)]
|
||||
static extern int unzCloseCurrentFile (UnzipHandle handle);
|
||||
|
||||
[DllImport ("MonoPosixHelper")]
|
||||
[DllImport ("MonoPosixHelper", CallingConvention=CallingConvention.Cdecl)]
|
||||
static extern IntPtr unztell (UnzipHandle handle);
|
||||
|
||||
[DllImport ("MonoPosixHelper")]
|
||||
[DllImport ("MonoPosixHelper", CallingConvention=CallingConvention.Cdecl)]
|
||||
static extern int unzGoToFirstFile (UnzipHandle handle);
|
||||
|
||||
[DllImport ("MonoPosixHelper")]
|
||||
[DllImport ("MonoPosixHelper", CallingConvention=CallingConvention.Cdecl)]
|
||||
static extern UnzipHandle unzOpen2 (string path,
|
||||
ref ZlibFileFuncDef pzlib_filefunc_def);
|
||||
|
||||
[DllImport ("MonoPosixHelper")]
|
||||
[DllImport ("MonoPosixHelper", CallingConvention=CallingConvention.Cdecl)]
|
||||
static extern int unzGoToNextFile (UnzipHandle handle);
|
||||
|
||||
[DllImport ("MonoPosixHelper")]
|
||||
[DllImport ("MonoPosixHelper", CallingConvention=CallingConvention.Cdecl)]
|
||||
static extern int unzLocateFile (UnzipHandle handle,
|
||||
string szFileName,
|
||||
int iCaseSensitivity);
|
||||
|
||||
[DllImport ("MonoPosixHelper")]
|
||||
[DllImport ("MonoPosixHelper", CallingConvention=CallingConvention.Cdecl)]
|
||||
static extern int unzOpenCurrentFile2 (UnzipHandle handle,
|
||||
out int method,
|
||||
out int level,
|
||||
int raw);
|
||||
|
||||
[DllImport ("MonoPosixHelper")]
|
||||
[DllImport ("MonoPosixHelper", CallingConvention=CallingConvention.Cdecl)]
|
||||
static extern int unzGetCurrentFileInfo (UnzipHandle handle,
|
||||
out UnzipFileInfo pfile_info,
|
||||
StringBuilder szFileName,
|
||||
@@ -184,15 +184,15 @@ namespace zipsharp
|
||||
StringBuilder szComment,
|
||||
IntPtr commentBufferSize); // uLong
|
||||
|
||||
[DllImport ("MonoPosixHelper")]
|
||||
[DllImport ("MonoPosixHelper", CallingConvention=CallingConvention.Cdecl)]
|
||||
static unsafe extern int unzReadCurrentFile (UnzipHandle handle,
|
||||
byte* buf, // voidp
|
||||
uint len);
|
||||
|
||||
//[DllImport ("MonoPosixHelper")]
|
||||
//[DllImport ("MonoPosixHelper", CallingConvention=CallingConvention.Cdecl)]
|
||||
//static extern int unzSetOffset (UnzipHandle handle, IntPtr pos); // uLong
|
||||
|
||||
[DllImport ("MonoPosixHelper")]
|
||||
[DllImport ("MonoPosixHelper", CallingConvention=CallingConvention.Cdecl)]
|
||||
static extern int unzClose (UnzipHandle handle);
|
||||
}
|
||||
}
|
||||
@@ -162,7 +162,7 @@ namespace System.Globalization {
|
||||
public string CultureName {
|
||||
get {
|
||||
if (customCultureName == null)
|
||||
customCultureName = ci.Name;
|
||||
customCultureName = ci == null ? String.Empty : ci.Name;
|
||||
return customCultureName;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -232,7 +232,6 @@ namespace System.IO {
|
||||
int i = 0;
|
||||
foreach (string s in drives) {
|
||||
infos [i++] = new DriveInfo (s, GetDriveFormat (s));
|
||||
Console.WriteLine (infos [i-1].path);
|
||||
}
|
||||
|
||||
return infos;
|
||||
|
||||
@@ -220,7 +220,7 @@ namespace System.IO
|
||||
}
|
||||
|
||||
if (access < FileAccess.Read || access > FileAccess.ReadWrite) {
|
||||
#if NET_2_1
|
||||
#if MOONLIGHT
|
||||
if (anonymous)
|
||||
throw new IsolatedStorageException ("Enum value for FileAccess was out of legal range.");
|
||||
else
|
||||
@@ -229,7 +229,7 @@ namespace System.IO
|
||||
}
|
||||
|
||||
if (share < FileShare.None || share > (FileShare.ReadWrite | FileShare.Delete)) {
|
||||
#if NET_2_1
|
||||
#if MOONLIGHT
|
||||
if (anonymous)
|
||||
throw new IsolatedStorageException ("Enum value for FileShare was out of legal range.");
|
||||
else
|
||||
@@ -275,7 +275,7 @@ namespace System.IO
|
||||
// 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 NET_2_1
|
||||
#if MOONLIGHT
|
||||
// don't use GetSecureFileName for the directory name
|
||||
throw new IsolatedStorageException (String.Format (msg, fname));
|
||||
#else
|
||||
@@ -289,7 +289,7 @@ namespace System.IO
|
||||
// don't leak the path information for isolated storage
|
||||
string msg = Locale.GetText ("Could not find file \"{0}\".");
|
||||
string fname = GetSecureFileName (path);
|
||||
#if NET_2_1
|
||||
#if MOONLIGHT
|
||||
throw new IsolatedStorageException (String.Format (msg, fname));
|
||||
#else
|
||||
throw new FileNotFoundException (String.Format (msg, fname), fname);
|
||||
|
||||
@@ -256,6 +256,11 @@ namespace System.IO {
|
||||
throw new ArgumentException ("An empty file name is not valid.");
|
||||
if (path.IndexOfAny (Path.InvalidPathChars) != -1)
|
||||
throw new ArgumentException ("Illegal characters in path.");
|
||||
if (Environment.IsRunningOnWindows) {
|
||||
int idx = path.IndexOf (':');
|
||||
if (idx >= 0 && idx != 1)
|
||||
throw new ArgumentException ("path");
|
||||
}
|
||||
}
|
||||
|
||||
internal MonoIOStat stat;
|
||||
|
||||
@@ -82,7 +82,7 @@ namespace System.IO
|
||||
// FIXME: add more exception mappings here
|
||||
case MonoIOError.ERROR_FILE_NOT_FOUND:
|
||||
message = String.Format ("Could not find file \"{0}\"", path);
|
||||
#if NET_2_1
|
||||
#if MOONLIGHT
|
||||
return new IsolatedStorageException (message);
|
||||
#else
|
||||
return new FileNotFoundException (message, path);
|
||||
@@ -93,7 +93,7 @@ namespace System.IO
|
||||
|
||||
case MonoIOError.ERROR_PATH_NOT_FOUND:
|
||||
message = String.Format ("Could not find a part of the path \"{0}\"", path);
|
||||
#if NET_2_1
|
||||
#if MOONLIGHT
|
||||
return new IsolatedStorageException (message);
|
||||
#else
|
||||
return new DirectoryNotFoundException (message);
|
||||
|
||||
@@ -841,6 +841,11 @@ namespace System.IO {
|
||||
throw new ArgumentException (Locale.GetText ("Path is empty"));
|
||||
if (path.IndexOfAny (Path.InvalidPathChars) != -1)
|
||||
throw new ArgumentException (Locale.GetText ("Path contains invalid chars"));
|
||||
if (Environment.IsRunningOnWindows) {
|
||||
int idx = path.IndexOf (':');
|
||||
if (idx >= 0 && idx != 1)
|
||||
throw new ArgumentException (parameterName);
|
||||
}
|
||||
#if MOONLIGHT
|
||||
// On Moonlight (SL4+) there are some limitations in "Elevated Trust"
|
||||
if (SecurityManager.HasElevatedPermissions) {
|
||||
|
||||
@@ -281,8 +281,13 @@ namespace System.Reflection {
|
||||
"name");
|
||||
|
||||
ManifestResourceInfo info = GetManifestResourceInfo (name);
|
||||
if (info == null)
|
||||
return null;
|
||||
if (info == null) {
|
||||
Assembly a = AppDomain.CurrentDomain.DoResourceResolve (name, this);
|
||||
if (a != null && a != this)
|
||||
return a.GetManifestResourceStream (name);
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
if (info.ReferencedAssembly != null)
|
||||
return info.ReferencedAssembly.GetManifestResourceStream (name);
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
// (C) 2002, 2003 Motus Technologies Inc. (http://www.motus.com)
|
||||
// Copyright (C) Tim Coleman, 2004
|
||||
// Copyright (C) 2004-2007,2011 Novell, Inc (http://www.novell.com)
|
||||
// Copyright (C) 2011 Xamarin Inc. http://www.xamarin.com
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
@@ -489,6 +490,8 @@ public partial class CryptoConfig {
|
||||
if (algo == null)
|
||||
algo = name;
|
||||
algoClass = Type.GetType (algo);
|
||||
if (algoClass == null)
|
||||
return null;
|
||||
// call the constructor for the type
|
||||
return Activator.CreateInstance (algoClass, args);
|
||||
}
|
||||
|
||||
@@ -33,9 +33,9 @@ using System.Text;
|
||||
|
||||
using Mono.Security.Cryptography;
|
||||
|
||||
namespace System.Security.Cryptography {
|
||||
namespace System.Security.Cryptography {
|
||||
|
||||
[ComVisible (true)]
|
||||
[ComVisible (true)]
|
||||
public class Rfc2898DeriveBytes : DeriveBytes {
|
||||
|
||||
private const int defaultIterations = 1000;
|
||||
@@ -155,6 +155,13 @@ namespace System.Security.Cryptography {
|
||||
Buffer.BlockCopy (_buffer, _pos, result, 0, count);
|
||||
if (count >= cb)
|
||||
return result;
|
||||
|
||||
// If we are going to go over the boundaries
|
||||
// of the result on our l-1 iteration, reduce
|
||||
// l to compensate.
|
||||
if (((l-1) * 20 + count) > result.Length)
|
||||
l--;
|
||||
|
||||
_pos = 0;
|
||||
rpos = count;
|
||||
}
|
||||
|
||||
@@ -94,6 +94,7 @@ namespace System.Text
|
||||
|
||||
public override void Reset ()
|
||||
{
|
||||
fallback_assigned = false;
|
||||
current = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,14 +31,15 @@ using System.Threading;
|
||||
|
||||
namespace System.Threading.Tasks
|
||||
{
|
||||
public class SynchronizationContextScheduler : TaskScheduler
|
||||
sealed class SynchronizationContextScheduler : TaskScheduler
|
||||
{
|
||||
readonly SynchronizationContext ctx;
|
||||
static readonly SendOrPostCallback callback = TaskLaunchWrapper;
|
||||
readonly SendOrPostCallback callback;
|
||||
|
||||
public SynchronizationContextScheduler (SynchronizationContext ctx)
|
||||
{
|
||||
this.ctx = ctx;
|
||||
this.callback = TaskLaunchWrapper;
|
||||
}
|
||||
|
||||
protected internal override void QueueTask (Task task)
|
||||
@@ -46,9 +47,9 @@ namespace System.Threading.Tasks
|
||||
ctx.Post (callback, task);
|
||||
}
|
||||
|
||||
static void TaskLaunchWrapper (object obj)
|
||||
void TaskLaunchWrapper (object obj)
|
||||
{
|
||||
((Task)obj).Execute (null);
|
||||
TryExecuteTask ((Task)obj);
|
||||
}
|
||||
|
||||
protected override System.Collections.Generic.IEnumerable<Task> GetScheduledTasks ()
|
||||
@@ -63,15 +64,8 @@ namespace System.Threading.Tasks
|
||||
|
||||
protected override bool TryExecuteTaskInline (Task task, bool taskWasPreviouslyQueued)
|
||||
{
|
||||
if (task.IsCompleted)
|
||||
return false;
|
||||
|
||||
if (task.Status == TaskStatus.WaitingToRun) {
|
||||
task.Execute (null);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
ctx.Send (callback, task);
|
||||
return true;
|
||||
}
|
||||
|
||||
public override int MaximumConcurrencyLevel {
|
||||
|
||||
@@ -30,8 +30,8 @@ using System.Collections.Concurrent;
|
||||
|
||||
namespace System.Threading.Tasks
|
||||
{
|
||||
[System.Diagnostics.DebuggerDisplay ("Id = {Id}, Status = {Status}, Method = {DebuggerDisplayMethodDescription}")]
|
||||
[System.Diagnostics.DebuggerTypeProxy ("System.Threading.Tasks.SystemThreadingTasks_TaskDebugView")]
|
||||
[System.Diagnostics.DebuggerDisplay ("Id = {Id}, Status = {Status}")]
|
||||
[System.Diagnostics.DebuggerTypeProxy (typeof (TaskDebuggerView))]
|
||||
public class Task : IDisposable, IAsyncResult
|
||||
{
|
||||
// With this attribute each thread has its own value so that it's correct for our Schedule code
|
||||
@@ -57,17 +57,22 @@ namespace System.Threading.Tasks
|
||||
|
||||
volatile AggregateException exception;
|
||||
volatile bool exceptionObserved;
|
||||
ConcurrentQueue<AggregateException> childExceptions;
|
||||
|
||||
TaskStatus status;
|
||||
|
||||
Action<object> action;
|
||||
Action simpleAction;
|
||||
object state;
|
||||
AtomicBooleanValue executing;
|
||||
|
||||
ConcurrentQueue<EventHandler> completed = new ConcurrentQueue<EventHandler> ();
|
||||
ConcurrentQueue<EventHandler> completed;
|
||||
|
||||
CancellationToken token;
|
||||
|
||||
const TaskCreationOptions MaxTaskCreationOptions =
|
||||
TaskCreationOptions.PreferFairness | TaskCreationOptions.LongRunning | TaskCreationOptions.AttachedToParent;
|
||||
|
||||
public Task (Action action) : this (action, TaskCreationOptions.None)
|
||||
{
|
||||
|
||||
@@ -84,8 +89,13 @@ namespace System.Threading.Tasks
|
||||
}
|
||||
|
||||
public Task (Action action, CancellationToken cancellationToken, TaskCreationOptions creationOptions)
|
||||
: this ((o) => { if (action != null) action (); }, null, cancellationToken, creationOptions)
|
||||
: this (null, null, cancellationToken, creationOptions, current)
|
||||
{
|
||||
if (action == null)
|
||||
throw new ArgumentNullException ("action");
|
||||
if (creationOptions > MaxTaskCreationOptions || creationOptions < TaskCreationOptions.None)
|
||||
throw new ArgumentOutOfRangeException ("creationOptions");
|
||||
this.simpleAction = action;
|
||||
}
|
||||
|
||||
public Task (Action<object> action, object state) : this (action, state, TaskCreationOptions.None)
|
||||
@@ -101,24 +111,35 @@ namespace System.Threading.Tasks
|
||||
: this (action, state, cancellationToken, TaskCreationOptions.None)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
public Task (Action<object> action, object state, CancellationToken cancellationToken, TaskCreationOptions creationOptions)
|
||||
: this (action, state, cancellationToken, creationOptions, current)
|
||||
{
|
||||
if (action == null)
|
||||
throw new ArgumentNullException ("action");
|
||||
if (creationOptions > MaxTaskCreationOptions || creationOptions < TaskCreationOptions.None)
|
||||
throw new ArgumentOutOfRangeException ("creationOptions");
|
||||
}
|
||||
|
||||
internal Task (Action<object> action,
|
||||
object state,
|
||||
CancellationToken cancellationToken,
|
||||
TaskCreationOptions creationOptions,
|
||||
Task parent)
|
||||
{
|
||||
this.taskCreationOptions = creationOptions;
|
||||
this.action = action == null ? EmptyFunc : action;
|
||||
this.action = action;
|
||||
this.state = state;
|
||||
this.taskId = Interlocked.Increment (ref id);
|
||||
this.status = TaskStatus.Created;
|
||||
this.status = cancellationToken.IsCancellationRequested ? TaskStatus.Canceled : TaskStatus.Created;
|
||||
this.token = cancellationToken;
|
||||
this.parent = parent;
|
||||
|
||||
// Process taskCreationOptions
|
||||
if (CheckTaskOptions (taskCreationOptions, TaskCreationOptions.AttachedToParent)) {
|
||||
parent = current;
|
||||
if (parent != null)
|
||||
parent.AddChild ();
|
||||
}
|
||||
if (CheckTaskOptions (taskCreationOptions, TaskCreationOptions.AttachedToParent) && parent != null)
|
||||
parent.AddChild ();
|
||||
}
|
||||
|
||||
|
||||
~Task ()
|
||||
{
|
||||
if (exception != null && !exceptionObserved)
|
||||
@@ -130,10 +151,6 @@ namespace System.Threading.Tasks
|
||||
return (opt & member) == member;
|
||||
}
|
||||
|
||||
static void EmptyFunc (object o)
|
||||
{
|
||||
}
|
||||
|
||||
#region Start
|
||||
public void Start ()
|
||||
{
|
||||
@@ -162,9 +179,24 @@ namespace System.Threading.Tasks
|
||||
|
||||
public void RunSynchronously (TaskScheduler scheduler)
|
||||
{
|
||||
if (scheduler.TryExecuteTask (this))
|
||||
return;
|
||||
if (scheduler == null)
|
||||
throw new ArgumentNullException ("scheduler");
|
||||
|
||||
if (Status > TaskStatus.WaitingForActivation)
|
||||
throw new InvalidOperationException ("The task is not in a valid state to be started");
|
||||
|
||||
SetupScheduler (scheduler);
|
||||
var saveStatus = status;
|
||||
status = TaskStatus.WaitingToRun;
|
||||
|
||||
try {
|
||||
if (scheduler.RunInline (this))
|
||||
return;
|
||||
} catch (Exception inner) {
|
||||
throw new TaskSchedulerException (inner);
|
||||
}
|
||||
|
||||
status = saveStatus;
|
||||
Start (scheduler);
|
||||
Wait ();
|
||||
}
|
||||
@@ -193,7 +225,11 @@ namespace System.Threading.Tasks
|
||||
|
||||
public Task ContinueWith (Action<Task> continuationAction, CancellationToken cancellationToken, TaskContinuationOptions continuationOptions, TaskScheduler scheduler)
|
||||
{
|
||||
Task continuation = new Task ((o) => continuationAction ((Task)o), this, cancellationToken, GetCreationOptions (continuationOptions));
|
||||
Task continuation = new Task ((o) => continuationAction ((Task)o),
|
||||
this,
|
||||
cancellationToken,
|
||||
GetCreationOptions (continuationOptions),
|
||||
this);
|
||||
ContinueWithCore (continuation, continuationOptions, scheduler);
|
||||
|
||||
return continuation;
|
||||
@@ -227,7 +263,11 @@ namespace System.Threading.Tasks
|
||||
if (scheduler == null)
|
||||
throw new ArgumentNullException ("scheduler");
|
||||
|
||||
Task<TResult> t = new Task<TResult> ((o) => continuationFunction ((Task)o), this, cancellationToken, GetCreationOptions (continuationOptions));
|
||||
Task<TResult> t = new Task<TResult> ((o) => continuationFunction ((Task)o),
|
||||
this,
|
||||
cancellationToken,
|
||||
GetCreationOptions (continuationOptions),
|
||||
this);
|
||||
|
||||
ContinueWithCore (t, continuationOptions, scheduler);
|
||||
|
||||
@@ -236,7 +276,7 @@ namespace System.Threading.Tasks
|
||||
|
||||
internal void ContinueWithCore (Task continuation, TaskContinuationOptions continuationOptions, TaskScheduler scheduler)
|
||||
{
|
||||
ContinueWithCore (continuation, continuationOptions, scheduler, () => true);
|
||||
ContinueWithCore (continuation, continuationOptions, scheduler, null);
|
||||
}
|
||||
|
||||
internal void ContinueWithCore (Task continuation, TaskContinuationOptions kind,
|
||||
@@ -249,8 +289,8 @@ namespace System.Threading.Tasks
|
||||
|
||||
AtomicBoolean launched = new AtomicBoolean ();
|
||||
EventHandler action = delegate (object sender, EventArgs e) {
|
||||
if (!launched.Value && launched.TrySet ()) {
|
||||
if (!predicate ())
|
||||
if (launched.TryRelaxedSet ()) {
|
||||
if (predicate != null && !predicate ())
|
||||
return;
|
||||
|
||||
if (!ContinuationStatusCheck (kind)) {
|
||||
@@ -269,6 +309,8 @@ namespace System.Threading.Tasks
|
||||
return;
|
||||
}
|
||||
|
||||
if (completed == null)
|
||||
Interlocked.CompareExchange (ref completed, new ConcurrentQueue<EventHandler> (), null);
|
||||
completed.Enqueue (action);
|
||||
|
||||
// Retry in case completion was achieved but event adding was too late
|
||||
@@ -321,7 +363,7 @@ namespace System.Threading.Tasks
|
||||
void CheckAndSchedule (Task continuation, TaskContinuationOptions options, TaskScheduler scheduler, bool fromCaller)
|
||||
{
|
||||
if ((options & TaskContinuationOptions.ExecuteSynchronously) > 0)
|
||||
continuation.ThreadStart ();
|
||||
continuation.RunSynchronously (scheduler);
|
||||
else
|
||||
continuation.Start (scheduler);
|
||||
}
|
||||
@@ -342,7 +384,7 @@ namespace System.Threading.Tasks
|
||||
|
||||
#region Internal and protected thingies
|
||||
internal void Schedule ()
|
||||
{
|
||||
{
|
||||
status = TaskStatus.WaitingToRun;
|
||||
|
||||
// If worker is null it means it is a local one, revert to the old behavior
|
||||
@@ -377,7 +419,7 @@ namespace System.Threading.Tasks
|
||||
try {
|
||||
InnerInvoke ();
|
||||
} catch (OperationCanceledException oce) {
|
||||
if (oce.CancellationToken == token)
|
||||
if (token != CancellationToken.None && oce.CancellationToken == token)
|
||||
CancelReal ();
|
||||
else
|
||||
HandleGenericException (oce);
|
||||
@@ -402,23 +444,31 @@ namespace System.Threading.Tasks
|
||||
childTasks.AddCount ();
|
||||
}
|
||||
|
||||
internal void ChildCompleted ()
|
||||
internal void ChildCompleted (AggregateException childEx)
|
||||
{
|
||||
childTasks.Signal ();
|
||||
if (childTasks.IsSet && status == TaskStatus.WaitingForChildrenToComplete) {
|
||||
if (childEx != null) {
|
||||
if (childExceptions == null)
|
||||
Interlocked.CompareExchange (ref childExceptions, new ConcurrentQueue<AggregateException> (), null);
|
||||
childExceptions.Enqueue (childEx);
|
||||
}
|
||||
|
||||
if (childTasks.Signal () && status == TaskStatus.WaitingForChildrenToComplete) {
|
||||
status = TaskStatus.RanToCompletion;
|
||||
|
||||
ProcessChildExceptions ();
|
||||
ProcessCompleteDelegates ();
|
||||
}
|
||||
}
|
||||
|
||||
internal virtual void InnerInvoke ()
|
||||
{
|
||||
if (action != null)
|
||||
if (action == null && simpleAction != null)
|
||||
simpleAction ();
|
||||
else if (action != null)
|
||||
action (state);
|
||||
// Set action to null so that the GC can collect the delegate and thus
|
||||
// any big object references that the user might have captured in an anonymous method
|
||||
action = null;
|
||||
simpleAction = null;
|
||||
state = null;
|
||||
}
|
||||
|
||||
@@ -443,17 +493,33 @@ namespace System.Threading.Tasks
|
||||
TaskScheduler.Current = null;
|
||||
|
||||
// Tell parent that we are finished
|
||||
if (CheckTaskOptions (taskCreationOptions, TaskCreationOptions.AttachedToParent) && parent != null){
|
||||
parent.ChildCompleted ();
|
||||
if (CheckTaskOptions (taskCreationOptions, TaskCreationOptions.AttachedToParent) && parent != null) {
|
||||
parent.ChildCompleted (this.Exception);
|
||||
}
|
||||
}
|
||||
|
||||
void ProcessCompleteDelegates ()
|
||||
{
|
||||
if (completed == null)
|
||||
return;
|
||||
|
||||
EventHandler handler;
|
||||
while (completed.TryDequeue (out handler))
|
||||
handler (this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
void ProcessChildExceptions ()
|
||||
{
|
||||
if (childExceptions == null)
|
||||
return;
|
||||
|
||||
if (exception == null)
|
||||
exception = new AggregateException ();
|
||||
|
||||
AggregateException childEx;
|
||||
while (childExceptions.TryDequeue (out childEx))
|
||||
exception.AddChildException (childEx);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Cancel and Wait related method
|
||||
@@ -471,6 +537,7 @@ namespace System.Threading.Tasks
|
||||
internal void HandleGenericException (AggregateException e)
|
||||
{
|
||||
exception = e;
|
||||
Thread.MemoryBarrier ();
|
||||
status = TaskStatus.Faulted;
|
||||
if (scheduler != null && scheduler.FireUnobservedEvent (exception).Observed)
|
||||
exceptionObserved = true;
|
||||
@@ -729,6 +796,9 @@ namespace System.Threading.Tasks
|
||||
|
||||
protected virtual void Dispose (bool disposing)
|
||||
{
|
||||
if (!IsCompleted)
|
||||
throw new InvalidOperationException ("A task may only be disposed if it is in a completion state");
|
||||
|
||||
// Set action to null so that the GC can collect the delegate and thus
|
||||
// any big object references that the user might have captured in a anonymous method
|
||||
if (disposing) {
|
||||
@@ -826,6 +896,14 @@ namespace System.Threading.Tasks
|
||||
return parent;
|
||||
}
|
||||
}
|
||||
|
||||
internal string DisplayActionMethod {
|
||||
get {
|
||||
Delegate d = simpleAction ?? (Delegate) action;
|
||||
return d == null ? "<none>" : d.Method.ToString ();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
//
|
||||
// TaskCompletionSource.cs
|
||||
//
|
||||
// Author:
|
||||
// Authors:
|
||||
// Jérémie "Garuma" Laval <[email protected]>
|
||||
// Marek Safar <[email protected]>
|
||||
//
|
||||
// Copyright (c) 2009 Jérémie "Garuma" Laval
|
||||
// Copyright 2011 Xamarin, Inc (http://www.xamarin.com)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -32,7 +34,8 @@ namespace System.Threading.Tasks
|
||||
{
|
||||
public class TaskCompletionSource<TResult>
|
||||
{
|
||||
Task<TResult> source;
|
||||
readonly Task<TResult> source;
|
||||
SpinLock opLock = new SpinLock (false);
|
||||
|
||||
public TaskCompletionSource ()
|
||||
{
|
||||
@@ -63,15 +66,18 @@ namespace System.Threading.Tasks
|
||||
if (!ApplyOperation (source.CancelReal))
|
||||
ThrowInvalidException ();
|
||||
}
|
||||
|
||||
|
||||
public void SetException (Exception exception)
|
||||
{
|
||||
if (exception == null)
|
||||
throw new ArgumentNullException ("exception");
|
||||
|
||||
SetException (new Exception[] { exception });
|
||||
}
|
||||
|
||||
|
||||
public void SetException (IEnumerable<Exception> exceptions)
|
||||
{
|
||||
if (!ApplyOperation (() => source.HandleGenericException (new AggregateException (exceptions))))
|
||||
if (!TrySetException (exceptions))
|
||||
ThrowInvalidException ();
|
||||
}
|
||||
|
||||
@@ -81,7 +87,7 @@ namespace System.Threading.Tasks
|
||||
ThrowInvalidException ();
|
||||
}
|
||||
|
||||
void ThrowInvalidException ()
|
||||
static void ThrowInvalidException ()
|
||||
{
|
||||
throw new InvalidOperationException ("The underlying Task is already in one of the three final states: RanToCompletion, Faulted, or Canceled.");
|
||||
}
|
||||
@@ -93,12 +99,22 @@ namespace System.Threading.Tasks
|
||||
|
||||
public bool TrySetException (Exception exception)
|
||||
{
|
||||
if (exception == null)
|
||||
throw new ArgumentNullException ("exception");
|
||||
|
||||
return TrySetException (new Exception[] { exception });
|
||||
}
|
||||
|
||||
public bool TrySetException (IEnumerable<Exception> exceptions)
|
||||
{
|
||||
return ApplyOperation (() => source.HandleGenericException (new AggregateException (exceptions)));
|
||||
if (exceptions == null)
|
||||
throw new ArgumentNullException ("exceptions");
|
||||
|
||||
var aggregate = new AggregateException (exceptions);
|
||||
if (aggregate.InnerExceptions.Count == 0)
|
||||
throw new ArgumentNullException ("exceptions");
|
||||
|
||||
return ApplyOperation (() => source.HandleGenericException (aggregate));
|
||||
}
|
||||
|
||||
public bool TrySetResult (TResult result)
|
||||
@@ -108,17 +124,24 @@ namespace System.Threading.Tasks
|
||||
|
||||
bool ApplyOperation (Action action)
|
||||
{
|
||||
if (CheckInvalidState ())
|
||||
return false;
|
||||
bool taken = false;
|
||||
try {
|
||||
opLock.Enter (ref taken);
|
||||
if (CheckInvalidState ())
|
||||
return false;
|
||||
|
||||
source.Status = TaskStatus.Running;
|
||||
source.Status = TaskStatus.Running;
|
||||
|
||||
if (action != null)
|
||||
action ();
|
||||
if (action != null)
|
||||
action ();
|
||||
|
||||
source.Finish ();
|
||||
source.Finish ();
|
||||
|
||||
return true;
|
||||
return true;
|
||||
} finally {
|
||||
if (taken)
|
||||
opLock.Exit ();
|
||||
}
|
||||
}
|
||||
|
||||
bool CheckInvalidState ()
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
//
|
||||
// TaskDebuggerView.cs
|
||||
//
|
||||
// Authors:
|
||||
// Marek Safar <[email protected]>
|
||||
//
|
||||
// Copyright 2011 Xamarin, Inc (http://www.xamarin.com)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
#if NET_4_0 || MOBILE
|
||||
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace System.Threading.Tasks
|
||||
{
|
||||
//
|
||||
// Custom debugger type proxy for tasks
|
||||
//
|
||||
sealed class TaskDebuggerView
|
||||
{
|
||||
readonly Task task;
|
||||
|
||||
public TaskDebuggerView (Task task)
|
||||
{
|
||||
this.task = task;
|
||||
}
|
||||
|
||||
public object AsyncState {
|
||||
get {
|
||||
return task.AsyncState;
|
||||
}
|
||||
}
|
||||
|
||||
public TaskCreationOptions CreationOptions {
|
||||
get {
|
||||
return task.CreationOptions;
|
||||
}
|
||||
}
|
||||
|
||||
public Exception Exception {
|
||||
get {
|
||||
return task.Exception;
|
||||
}
|
||||
}
|
||||
|
||||
public int Id {
|
||||
get {
|
||||
return task.Id;
|
||||
}
|
||||
}
|
||||
|
||||
public string Method {
|
||||
get {
|
||||
return task.DisplayActionMethod;
|
||||
}
|
||||
}
|
||||
|
||||
public TaskStatus Status {
|
||||
get {
|
||||
return task.Status;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,463 @@
|
||||
//
|
||||
// TaskFactory_T.cs
|
||||
//
|
||||
// Authors:
|
||||
// Jérémie "Garuma" Laval <[email protected]>
|
||||
// Marek Safar <[email protected]>
|
||||
//
|
||||
// Copyright (c) 2009 Jérémie "Garuma" Laval
|
||||
// Copyright 2011 Xamarin, Inc (http://www.xamarin.com)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
#if NET_4_0 || MOBILE
|
||||
|
||||
using System;
|
||||
using System.Threading;
|
||||
|
||||
namespace System.Threading.Tasks
|
||||
{
|
||||
public class TaskFactory<TResult>
|
||||
{
|
||||
readonly TaskScheduler scheduler;
|
||||
TaskCreationOptions creationOptions;
|
||||
TaskContinuationOptions continuationOptions;
|
||||
CancellationToken cancellationToken;
|
||||
|
||||
TaskFactory parent;
|
||||
|
||||
const TaskCreationOptions FromAsyncOptionsNotSupported = TaskCreationOptions.LongRunning | TaskCreationOptions.PreferFairness;
|
||||
|
||||
public TaskFactory ()
|
||||
: this (CancellationToken.None)
|
||||
{
|
||||
}
|
||||
|
||||
public TaskFactory (TaskScheduler scheduler)
|
||||
: this (CancellationToken.None, TaskCreationOptions.None, TaskContinuationOptions.None, scheduler)
|
||||
{
|
||||
}
|
||||
|
||||
public TaskFactory (CancellationToken cancellationToken)
|
||||
: this (cancellationToken, TaskCreationOptions.None, TaskContinuationOptions.None, null)
|
||||
{
|
||||
}
|
||||
|
||||
public TaskFactory (TaskCreationOptions creationOptions, TaskContinuationOptions continuationOptions)
|
||||
: this (CancellationToken.None, creationOptions, continuationOptions, null)
|
||||
{
|
||||
}
|
||||
|
||||
public TaskFactory (CancellationToken cancellationToken, TaskCreationOptions creationOptions, TaskContinuationOptions continuationOptions, TaskScheduler scheduler)
|
||||
{
|
||||
this.cancellationToken = cancellationToken;
|
||||
this.scheduler = scheduler;
|
||||
this.creationOptions = creationOptions;
|
||||
this.continuationOptions = continuationOptions;
|
||||
|
||||
TaskFactory.CheckContinuationOptions (continuationOptions);
|
||||
|
||||
this.parent = new TaskFactory (cancellationToken, creationOptions, continuationOptions, scheduler);
|
||||
}
|
||||
|
||||
public TaskScheduler Scheduler {
|
||||
get {
|
||||
return scheduler;
|
||||
}
|
||||
}
|
||||
|
||||
public TaskContinuationOptions ContinuationOptions {
|
||||
get {
|
||||
return continuationOptions;
|
||||
}
|
||||
}
|
||||
|
||||
public TaskCreationOptions CreationOptions {
|
||||
get {
|
||||
return creationOptions;
|
||||
}
|
||||
}
|
||||
|
||||
public CancellationToken CancellationToken {
|
||||
get {
|
||||
return cancellationToken;
|
||||
}
|
||||
}
|
||||
|
||||
#region StartNew for Task<TResult>
|
||||
public Task<TResult> StartNew (Func<TResult> function)
|
||||
{
|
||||
return StartNew (function, cancellationToken, creationOptions, GetScheduler ());
|
||||
}
|
||||
|
||||
public Task<TResult> StartNew (Func<TResult> function, TaskCreationOptions creationOptions)
|
||||
{
|
||||
return StartNew (function, cancellationToken, creationOptions, GetScheduler ());
|
||||
}
|
||||
|
||||
public Task<TResult> StartNew (Func<TResult> function, CancellationToken cancellationToken)
|
||||
{
|
||||
return StartNew (function, cancellationToken, creationOptions, GetScheduler ());
|
||||
}
|
||||
|
||||
public Task<TResult> StartNew (Func<TResult> function,
|
||||
CancellationToken cancellationToken,
|
||||
TaskCreationOptions creationOptions,
|
||||
TaskScheduler scheduler)
|
||||
{
|
||||
return StartNew ((o) => function (), null, cancellationToken, creationOptions, scheduler);
|
||||
}
|
||||
|
||||
public Task<TResult> StartNew (Func<object, TResult> function, object state)
|
||||
{
|
||||
return StartNew (function, state, cancellationToken, creationOptions, GetScheduler ());
|
||||
}
|
||||
|
||||
public Task<TResult> StartNew (Func<object, TResult> function, object state, TaskCreationOptions creationOptions)
|
||||
{
|
||||
return StartNew (function, state, cancellationToken, creationOptions, GetScheduler ());
|
||||
}
|
||||
|
||||
public Task<TResult> StartNew (Func<object, TResult> function, object state, CancellationToken cancellationToken)
|
||||
{
|
||||
return StartNew (function, state, cancellationToken, creationOptions, GetScheduler ());
|
||||
}
|
||||
|
||||
public Task<TResult> StartNew (Func<object, TResult> function, object state,
|
||||
CancellationToken cancellationToken,
|
||||
TaskCreationOptions creationOptions,
|
||||
TaskScheduler scheduler)
|
||||
{
|
||||
return parent.StartNew<TResult> (function, state, cancellationToken, creationOptions, scheduler);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Continue
|
||||
|
||||
public Task<TResult> ContinueWhenAny (Task[] tasks,
|
||||
Func<Task, TResult> continuationFunction)
|
||||
{
|
||||
return ContinueWhenAny (tasks, continuationFunction, cancellationToken, continuationOptions, GetScheduler ());
|
||||
}
|
||||
|
||||
public Task<TResult> ContinueWhenAny (Task[] tasks,
|
||||
Func<Task, TResult> continuationFunction,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
return ContinueWhenAny (tasks, continuationFunction, cancellationToken, continuationOptions, GetScheduler ());
|
||||
}
|
||||
|
||||
public Task<TResult> ContinueWhenAny (Task[] tasks,
|
||||
Func<Task, TResult> continuationFunction,
|
||||
TaskContinuationOptions continuationOptions)
|
||||
{
|
||||
return ContinueWhenAny (tasks, continuationFunction, cancellationToken, continuationOptions, GetScheduler ());
|
||||
}
|
||||
|
||||
public Task<TResult> ContinueWhenAny (Task[] tasks,
|
||||
Func<Task, TResult> continuationFunction,
|
||||
CancellationToken cancellationToken,
|
||||
TaskContinuationOptions continuationOptions,
|
||||
TaskScheduler scheduler)
|
||||
{
|
||||
return parent.ContinueWhenAny (tasks, continuationFunction, cancellationToken, continuationOptions, scheduler);
|
||||
}
|
||||
|
||||
public Task<TResult> ContinueWhenAny<TAntecedentResult> (Task<TAntecedentResult>[] tasks,
|
||||
Func<Task<TAntecedentResult>, TResult> continuationFunction)
|
||||
{
|
||||
return ContinueWhenAny (tasks, continuationFunction, cancellationToken, continuationOptions, GetScheduler ());
|
||||
}
|
||||
|
||||
public Task<TResult> ContinueWhenAny<TAntecedentResult> (Task<TAntecedentResult>[] tasks,
|
||||
Func<Task<TAntecedentResult>, TResult> continuationFunction,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
return ContinueWhenAny (tasks, continuationFunction, cancellationToken, continuationOptions, GetScheduler ());
|
||||
}
|
||||
|
||||
public Task<TResult> ContinueWhenAny<TAntecedentResult> (Task<TAntecedentResult>[] tasks,
|
||||
Func<Task<TAntecedentResult>, TResult> continuationFunction,
|
||||
TaskContinuationOptions continuationOptions)
|
||||
{
|
||||
return ContinueWhenAny (tasks, continuationFunction, cancellationToken, continuationOptions, GetScheduler ());
|
||||
}
|
||||
|
||||
public Task<TResult> ContinueWhenAny<TAntecedentResult> (Task<TAntecedentResult>[] tasks,
|
||||
Func<Task<TAntecedentResult>, TResult> continuationFunction,
|
||||
CancellationToken cancellationToken,
|
||||
TaskContinuationOptions continuationOptions,
|
||||
TaskScheduler scheduler)
|
||||
{
|
||||
return parent.ContinueWhenAny (tasks, continuationFunction, cancellationToken, continuationOptions, scheduler);
|
||||
}
|
||||
|
||||
public Task<TResult> ContinueWhenAll (Task[] tasks, Func<Task[], TResult> continuationFunction)
|
||||
{
|
||||
return ContinueWhenAll (tasks, continuationFunction, cancellationToken, continuationOptions, GetScheduler ());
|
||||
}
|
||||
|
||||
public Task<TResult> ContinueWhenAll (Task[] tasks,
|
||||
Func<Task[], TResult> continuationFunction,
|
||||
TaskContinuationOptions continuationOptions)
|
||||
{
|
||||
return ContinueWhenAll (tasks, continuationFunction, cancellationToken, continuationOptions, GetScheduler ());
|
||||
}
|
||||
|
||||
public Task<TResult> ContinueWhenAll (Task[] tasks,
|
||||
Func<Task[], TResult> continuationFunction,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
return ContinueWhenAll (tasks, continuationFunction, cancellationToken, continuationOptions, GetScheduler ());
|
||||
}
|
||||
|
||||
public Task<TResult> ContinueWhenAll (Task[] tasks,
|
||||
Func<Task[], TResult> continuationFunction,
|
||||
CancellationToken cancellationToken,
|
||||
TaskContinuationOptions continuationOptions, TaskScheduler scheduler)
|
||||
{
|
||||
return parent.ContinueWhenAll (tasks, continuationFunction, cancellationToken, continuationOptions, scheduler);
|
||||
}
|
||||
|
||||
public Task<TResult> ContinueWhenAll<TAntecedentResult> (Task<TAntecedentResult>[] tasks,
|
||||
Func<Task<TAntecedentResult>[], TResult> continuationFunction)
|
||||
{
|
||||
return ContinueWhenAll (tasks, continuationFunction, cancellationToken, continuationOptions, GetScheduler ());
|
||||
}
|
||||
|
||||
public Task<TResult> ContinueWhenAll<TAntecedentResult> (Task<TAntecedentResult>[] tasks,
|
||||
Func<Task<TAntecedentResult>[], TResult> continuationFunction,
|
||||
TaskContinuationOptions continuationOptions)
|
||||
{
|
||||
return ContinueWhenAll (tasks, continuationFunction, cancellationToken, continuationOptions, GetScheduler ());
|
||||
}
|
||||
|
||||
public Task<TResult> ContinueWhenAll<TAntecedentResult> (Task<TAntecedentResult>[] tasks,
|
||||
Func<Task<TAntecedentResult>[], TResult> continuationFunction,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
return ContinueWhenAll (tasks, continuationFunction, cancellationToken, continuationOptions, GetScheduler ());
|
||||
}
|
||||
|
||||
public Task<TResult> ContinueWhenAll<TAntecedentResult> (Task<TAntecedentResult>[] tasks,
|
||||
Func<Task<TAntecedentResult>[], TResult> continuationFunction,
|
||||
CancellationToken cancellationToken,
|
||||
TaskContinuationOptions continuationOptions, TaskScheduler scheduler)
|
||||
{
|
||||
return parent.ContinueWhenAll (tasks, continuationFunction, cancellationToken, continuationOptions, scheduler);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region FromAsync
|
||||
|
||||
public Task<TResult> FromAsync (IAsyncResult asyncResult, Func<IAsyncResult, TResult> endMethod)
|
||||
{
|
||||
return FromAsync (asyncResult, endMethod, creationOptions);
|
||||
}
|
||||
|
||||
public Task<TResult> FromAsync (IAsyncResult asyncResult, Func<IAsyncResult, TResult> endMethod, TaskCreationOptions creationOptions)
|
||||
{
|
||||
return FromAsync (asyncResult, endMethod, creationOptions, GetScheduler ());
|
||||
}
|
||||
|
||||
public Task<TResult> FromAsync (IAsyncResult asyncResult, Func<IAsyncResult, TResult> endMethod, TaskCreationOptions creationOptions, TaskScheduler scheduler)
|
||||
{
|
||||
return FromIAsyncResult (asyncResult, endMethod, creationOptions, scheduler);
|
||||
}
|
||||
|
||||
internal static Task<TResult> FromIAsyncResult (IAsyncResult asyncResult, Func<IAsyncResult, TResult> endMethod, TaskCreationOptions creationOptions, TaskScheduler scheduler)
|
||||
{
|
||||
if (asyncResult == null)
|
||||
throw new ArgumentNullException ("asyncResult");
|
||||
|
||||
if (endMethod == null)
|
||||
throw new ArgumentNullException ("endMethod");
|
||||
|
||||
if (scheduler == null)
|
||||
throw new ArgumentNullException ("scheduler");
|
||||
|
||||
if ((creationOptions & FromAsyncOptionsNotSupported) != 0)
|
||||
throw new ArgumentOutOfRangeException ("creationOptions");
|
||||
|
||||
var source = new CancellationTokenSource ();
|
||||
var task = new Task<TResult> (l => {
|
||||
try {
|
||||
return endMethod (asyncResult);
|
||||
} catch (OperationCanceledException) {
|
||||
source.Cancel ();
|
||||
source.Token.ThrowIfCancellationRequested ();
|
||||
}
|
||||
return default (TResult);
|
||||
}, null, source.Token, creationOptions);
|
||||
|
||||
// Take quick path for completed operations
|
||||
if (asyncResult.IsCompleted) {
|
||||
task.RunSynchronously (scheduler);
|
||||
} else {
|
||||
ThreadPool.RegisterWaitForSingleObject (asyncResult.AsyncWaitHandle,
|
||||
(s, t) => task.RunSynchronously (scheduler),
|
||||
null, Timeout.Infinite, true);
|
||||
}
|
||||
|
||||
return task;
|
||||
}
|
||||
|
||||
public Task<TResult> FromAsync (Func<AsyncCallback, object, IAsyncResult> beginMethod, Func<IAsyncResult, TResult> endMethod,
|
||||
object state)
|
||||
{
|
||||
return FromAsync (beginMethod, endMethod, state, creationOptions);
|
||||
}
|
||||
|
||||
public Task<TResult> FromAsync (Func<AsyncCallback, object, IAsyncResult> beginMethod, Func<IAsyncResult, TResult> endMethod,
|
||||
object state, TaskCreationOptions creationOptions)
|
||||
{
|
||||
return FromAsyncBeginEnd (beginMethod, endMethod, state, creationOptions);
|
||||
}
|
||||
|
||||
internal static Task<TResult> FromAsyncBeginEnd (Func<AsyncCallback, object, IAsyncResult> beginMethod, Func<IAsyncResult, TResult> endMethod,
|
||||
object state, TaskCreationOptions creationOptions)
|
||||
{
|
||||
if (beginMethod == null)
|
||||
throw new ArgumentNullException ("beginMethod");
|
||||
|
||||
if (endMethod == null)
|
||||
throw new ArgumentNullException ("endMethod");
|
||||
|
||||
if ((creationOptions & FromAsyncOptionsNotSupported) != 0)
|
||||
throw new ArgumentOutOfRangeException ("creationOptions");
|
||||
|
||||
var tcs = new TaskCompletionSource<TResult> (state, creationOptions);
|
||||
beginMethod (l => InnerInvoke (tcs, endMethod, l), state);
|
||||
|
||||
return tcs.Task;
|
||||
}
|
||||
|
||||
public Task<TResult> FromAsync<TArg1> (Func<TArg1, AsyncCallback, object, IAsyncResult> beginMethod, Func<IAsyncResult, TResult> endMethod,
|
||||
TArg1 arg1, object state)
|
||||
{
|
||||
return FromAsync (beginMethod, endMethod, arg1, state, creationOptions);
|
||||
}
|
||||
|
||||
public Task<TResult> FromAsync<TArg1> (Func<TArg1, AsyncCallback, object, IAsyncResult> beginMethod, Func<IAsyncResult, TResult> endMethod,
|
||||
TArg1 arg1, object state, TaskCreationOptions creationOptions)
|
||||
{
|
||||
return FromAsyncBeginEnd (beginMethod, endMethod, arg1, state, creationOptions);
|
||||
}
|
||||
|
||||
internal static Task<TResult> FromAsyncBeginEnd<TArg1> (Func<TArg1, AsyncCallback, object, IAsyncResult> beginMethod,
|
||||
Func<IAsyncResult, TResult> endMethod,
|
||||
TArg1 arg1, object state, TaskCreationOptions creationOptions)
|
||||
{
|
||||
if (beginMethod == null)
|
||||
throw new ArgumentNullException ("beginMethod");
|
||||
|
||||
if (endMethod == null)
|
||||
throw new ArgumentNullException ("endMethod");
|
||||
|
||||
if ((creationOptions & FromAsyncOptionsNotSupported) != 0)
|
||||
throw new ArgumentOutOfRangeException ("creationOptions");
|
||||
|
||||
var tcs = new TaskCompletionSource<TResult> (state, creationOptions);
|
||||
beginMethod (arg1, l => InnerInvoke (tcs, endMethod, l), state);
|
||||
|
||||
return tcs.Task;
|
||||
}
|
||||
|
||||
public Task<TResult> FromAsync<TArg1, TArg2> (Func<TArg1, TArg2, AsyncCallback, object, IAsyncResult> beginMethod, Func<IAsyncResult, TResult> endMethod,
|
||||
TArg1 arg1, TArg2 arg2, object state)
|
||||
{
|
||||
return FromAsync (beginMethod, endMethod, arg1, arg2, state, creationOptions);
|
||||
}
|
||||
|
||||
public Task<TResult> FromAsync<TArg1, TArg2> (Func<TArg1, TArg2, AsyncCallback, object, IAsyncResult> beginMethod, Func<IAsyncResult, TResult> endMethod,
|
||||
TArg1 arg1, TArg2 arg2, object state, TaskCreationOptions creationOptions)
|
||||
{
|
||||
return FromAsyncBeginEnd (beginMethod, endMethod, arg1, arg2, state, creationOptions);
|
||||
}
|
||||
|
||||
internal static Task<TResult> FromAsyncBeginEnd<TArg1, TArg2> (Func<TArg1, TArg2, AsyncCallback, object, IAsyncResult> beginMethod, Func<IAsyncResult, TResult> endMethod,
|
||||
TArg1 arg1, TArg2 arg2, object state, TaskCreationOptions creationOptions)
|
||||
{
|
||||
if (beginMethod == null)
|
||||
throw new ArgumentNullException ("beginMethod");
|
||||
|
||||
if (endMethod == null)
|
||||
throw new ArgumentNullException ("endMethod");
|
||||
|
||||
if ((creationOptions & FromAsyncOptionsNotSupported) != 0)
|
||||
throw new ArgumentOutOfRangeException ("creationOptions");
|
||||
|
||||
var tcs = new TaskCompletionSource<TResult> (state, creationOptions);
|
||||
beginMethod (arg1, arg2, l => InnerInvoke (tcs, endMethod, l), state);
|
||||
|
||||
return tcs.Task;
|
||||
}
|
||||
|
||||
public Task<TResult> FromAsync<TArg1, TArg2, TArg3> (Func<TArg1, TArg2, TArg3, AsyncCallback, object, IAsyncResult> beginMethod, Func<IAsyncResult, TResult> endMethod,
|
||||
TArg1 arg1, TArg2 arg2, TArg3 arg3, object state)
|
||||
{
|
||||
return FromAsync (beginMethod, endMethod, arg1, arg2, arg3, state, creationOptions);
|
||||
}
|
||||
|
||||
public Task<TResult> FromAsync<TArg1, TArg2, TArg3> (Func<TArg1, TArg2, TArg3, AsyncCallback, object, IAsyncResult> beginMethod, Func<IAsyncResult, TResult> endMethod,
|
||||
TArg1 arg1, TArg2 arg2, TArg3 arg3, object state,
|
||||
TaskCreationOptions creationOptions)
|
||||
{
|
||||
return FromAsyncBeginEnd (beginMethod, endMethod, arg1, arg2, arg3, state, creationOptions);
|
||||
}
|
||||
|
||||
internal static Task<TResult> FromAsyncBeginEnd<TArg1, TArg2, TArg3> (Func<TArg1, TArg2, TArg3, AsyncCallback, object, IAsyncResult> beginMethod, Func<IAsyncResult, TResult> endMethod,
|
||||
TArg1 arg1, TArg2 arg2, TArg3 arg3, object state, TaskCreationOptions creationOptions)
|
||||
{
|
||||
if (beginMethod == null)
|
||||
throw new ArgumentNullException ("beginMethod");
|
||||
|
||||
if (endMethod == null)
|
||||
throw new ArgumentNullException ("endMethod");
|
||||
|
||||
if ((creationOptions & FromAsyncOptionsNotSupported) != 0)
|
||||
throw new ArgumentOutOfRangeException ("creationOptions");
|
||||
|
||||
var tcs = new TaskCompletionSource<TResult> (state, creationOptions);
|
||||
beginMethod (arg1, arg2, arg3, l => InnerInvoke (tcs, endMethod, l), state);
|
||||
|
||||
return tcs.Task;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
TaskScheduler GetScheduler ()
|
||||
{
|
||||
return scheduler ?? TaskScheduler.Current;
|
||||
}
|
||||
|
||||
static void InnerInvoke (TaskCompletionSource<TResult> tcs, Func<IAsyncResult, TResult> endMethod, IAsyncResult l)
|
||||
{
|
||||
try {
|
||||
tcs.SetResult (endMethod (l));
|
||||
} catch (OperationCanceledException) {
|
||||
tcs.SetCanceled ();
|
||||
} catch (Exception e) {
|
||||
tcs.SetException (e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -35,8 +35,7 @@ namespace System.Threading.Tasks
|
||||
[System.Diagnostics.DebuggerTypeProxy ("System.Threading.Tasks.TaskScheduler+SystemThreadingTasks_TaskSchedulerDebugView")]
|
||||
public abstract class TaskScheduler
|
||||
{
|
||||
static TaskScheduler defaultScheduler =
|
||||
Environment.GetEnvironmentVariable ("USE_OLD_TASK_SCHED") != null ? (TaskScheduler)new Scheduler () : (TaskScheduler)new TpScheduler ();
|
||||
static TaskScheduler defaultScheduler = new TpScheduler ();
|
||||
SchedulerProxy proxy;
|
||||
|
||||
[ThreadStatic]
|
||||
@@ -53,6 +52,10 @@ namespace System.Threading.Tasks
|
||||
this.proxy = new SchedulerProxy (this);
|
||||
}
|
||||
|
||||
~TaskScheduler ()
|
||||
{
|
||||
}
|
||||
|
||||
public static TaskScheduler FromCurrentSynchronizationContext ()
|
||||
{
|
||||
var syncCtx = SynchronizationContext.Current;
|
||||
@@ -125,7 +128,17 @@ namespace System.Threading.Tasks
|
||||
}
|
||||
|
||||
protected abstract bool TryExecuteTaskInline (Task task, bool taskWasPreviouslyQueued);
|
||||
|
||||
|
||||
internal bool RunInline (Task task)
|
||||
{
|
||||
if (!TryExecuteTaskInline (task, false))
|
||||
return false;
|
||||
|
||||
if (!task.IsCompleted)
|
||||
throw new InvalidOperationException ("The TryExecuteTaskInline call to the underlying scheduler succeeded, but the task body was not invoked");
|
||||
return true;
|
||||
}
|
||||
|
||||
internal UnobservedTaskExceptionEventArgs FireUnobservedEvent (AggregateException e)
|
||||
{
|
||||
UnobservedTaskExceptionEventArgs args = new UnobservedTaskExceptionEventArgs (e);
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace System.Threading.Tasks
|
||||
{
|
||||
public class TaskSchedulerException : Exception
|
||||
{
|
||||
const string exceptionDefaultMessage = "TaskScheduler exception";
|
||||
const string exceptionDefaultMessage = "An exception was thrown by a TaskScheduler";
|
||||
|
||||
public TaskSchedulerException () : base (exceptionDefaultMessage)
|
||||
{
|
||||
|
||||
@@ -0,0 +1,212 @@
|
||||
//
|
||||
// Task_T.cs
|
||||
//
|
||||
// Copyright (c) 2008 Jérémie "Garuma" Laval
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
//
|
||||
//
|
||||
|
||||
#if NET_4_0 || MOBILE
|
||||
using System;
|
||||
|
||||
namespace System.Threading.Tasks
|
||||
{
|
||||
[System.Diagnostics.DebuggerDisplay ("Id = {Id}, Status = {Status}, Result = {ResultAsString}")]
|
||||
[System.Diagnostics.DebuggerTypeProxy (typeof (TaskDebuggerView))]
|
||||
public class Task<TResult>: Task
|
||||
{
|
||||
TResult value;
|
||||
static TaskFactory<TResult> factory = new TaskFactory<TResult> ();
|
||||
static readonly Action<object> emptyAction = delegate {};
|
||||
|
||||
internal Func<object, TResult> function;
|
||||
object state;
|
||||
|
||||
[System.Diagnostics.DebuggerBrowsable (System.Diagnostics.DebuggerBrowsableState.Never)]
|
||||
public TResult Result {
|
||||
get {
|
||||
if (function != null)
|
||||
Wait ();
|
||||
else if (Exception != null)
|
||||
throw Exception;
|
||||
return value;
|
||||
}
|
||||
internal set {
|
||||
this.value = value;
|
||||
}
|
||||
}
|
||||
|
||||
string ResultAsString {
|
||||
get {
|
||||
if ((Status & (TaskStatus.RanToCompletion)) != 0)
|
||||
return "" + value;
|
||||
|
||||
return "<value not available>";
|
||||
}
|
||||
}
|
||||
|
||||
public static new TaskFactory<TResult> Factory {
|
||||
get {
|
||||
return factory;
|
||||
}
|
||||
}
|
||||
|
||||
public Task (Func<TResult> function) : this (function, TaskCreationOptions.None)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public Task (Func<TResult> function, CancellationToken cancellationToken)
|
||||
: this (function == null ? (Func<object, TResult>)null : (o) => function(), null, cancellationToken, TaskCreationOptions.None)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public Task (Func<TResult> function, TaskCreationOptions creationOptions)
|
||||
: this (function == null ? (Func<object, TResult>)null : (o) => function(), null, CancellationToken.None, creationOptions)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public Task (Func<TResult> function, CancellationToken cancellationToken, TaskCreationOptions creationOptions)
|
||||
: this (function == null ? (Func<object, TResult>)null : (o) => function(), null, cancellationToken, creationOptions)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public Task (Func<object, TResult> function, object state) : this (function, state, TaskCreationOptions.None)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public Task (Func<object, TResult> function, object state, CancellationToken cancellationToken)
|
||||
: this (function, state, cancellationToken, TaskCreationOptions.None)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public Task (Func<object, TResult> function, object state, TaskCreationOptions creationOptions)
|
||||
: this (function, state, CancellationToken.None, creationOptions)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public Task (Func<object, TResult> function, object state, CancellationToken cancellationToken, TaskCreationOptions creationOptions)
|
||||
: base (emptyAction, state, cancellationToken, creationOptions)
|
||||
{
|
||||
this.function = function;
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
internal Task (Func<object, TResult> function,
|
||||
object state,
|
||||
CancellationToken cancellationToken,
|
||||
TaskCreationOptions creationOptions,
|
||||
Task parent)
|
||||
: base (null, state, cancellationToken, creationOptions, parent)
|
||||
{
|
||||
this.function = function;
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
internal override void InnerInvoke ()
|
||||
{
|
||||
if (function != null)
|
||||
value = function (state);
|
||||
|
||||
function = null;
|
||||
state = null;
|
||||
}
|
||||
|
||||
public Task ContinueWith (Action<Task<TResult>> continuationAction)
|
||||
{
|
||||
return ContinueWith (continuationAction, TaskContinuationOptions.None);
|
||||
}
|
||||
|
||||
public Task ContinueWith (Action<Task<TResult>> continuationAction, TaskContinuationOptions continuationOptions)
|
||||
{
|
||||
return ContinueWith (continuationAction, CancellationToken.None, continuationOptions, TaskScheduler.Current);
|
||||
}
|
||||
|
||||
public Task ContinueWith (Action<Task<TResult>> continuationAction, CancellationToken cancellationToken)
|
||||
{
|
||||
return ContinueWith (continuationAction, cancellationToken, TaskContinuationOptions.None, TaskScheduler.Current);
|
||||
}
|
||||
|
||||
public Task ContinueWith (Action<Task<TResult>> continuationAction, TaskScheduler scheduler)
|
||||
{
|
||||
return ContinueWith (continuationAction, CancellationToken.None, TaskContinuationOptions.None, scheduler);
|
||||
}
|
||||
|
||||
public Task ContinueWith (Action<Task<TResult>> continuationAction, CancellationToken cancellationToken,
|
||||
TaskContinuationOptions continuationOptions, TaskScheduler scheduler)
|
||||
{
|
||||
if (continuationAction == null)
|
||||
throw new ArgumentNullException ("continuationFunction");
|
||||
if (scheduler == null)
|
||||
throw new ArgumentNullException ("scheduler");
|
||||
|
||||
Task t = new Task ((o) => continuationAction ((Task<TResult>)o),
|
||||
this,
|
||||
cancellationToken,
|
||||
GetCreationOptions (continuationOptions),
|
||||
this);
|
||||
ContinueWithCore (t, continuationOptions, scheduler);
|
||||
|
||||
return t;
|
||||
}
|
||||
|
||||
public Task<TNewResult> ContinueWith<TNewResult> (Func<Task<TResult>, TNewResult> continuationFunction)
|
||||
{
|
||||
return ContinueWith<TNewResult> (continuationFunction, TaskContinuationOptions.None);
|
||||
}
|
||||
|
||||
public Task<TNewResult> ContinueWith<TNewResult> (Func<Task<TResult>, TNewResult> continuationFunction, CancellationToken cancellationToken)
|
||||
{
|
||||
return ContinueWith<TNewResult> (continuationFunction, cancellationToken, TaskContinuationOptions.None, TaskScheduler.Current);
|
||||
}
|
||||
|
||||
public Task<TNewResult> ContinueWith<TNewResult> (Func<Task<TResult>, TNewResult> continuationFunction, TaskContinuationOptions continuationOptions)
|
||||
{
|
||||
return ContinueWith<TNewResult> (continuationFunction, CancellationToken.None, continuationOptions, TaskScheduler.Current);
|
||||
}
|
||||
|
||||
public Task<TNewResult> ContinueWith<TNewResult> (Func<Task<TResult>, TNewResult> continuationFunction, TaskScheduler scheduler)
|
||||
{
|
||||
return ContinueWith<TNewResult> (continuationFunction, CancellationToken.None, TaskContinuationOptions.None, scheduler);
|
||||
}
|
||||
|
||||
public Task<TNewResult> ContinueWith<TNewResult> (Func<Task<TResult>, TNewResult> continuationFunction,
|
||||
CancellationToken cancellationToken,
|
||||
TaskContinuationOptions continuationOptions,
|
||||
TaskScheduler scheduler)
|
||||
{
|
||||
Task<TNewResult> t = new Task<TNewResult> ((o) => continuationFunction ((Task<TResult>)o),
|
||||
this,
|
||||
cancellationToken,
|
||||
GetCreationOptions (continuationOptions),
|
||||
this);
|
||||
ContinueWithCore (t, continuationOptions, scheduler);
|
||||
|
||||
return t;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -25,7 +25,7 @@
|
||||
*/
|
||||
|
||||
|
||||
#if NET_4_0
|
||||
#if NET_4_0 || MOBILE
|
||||
|
||||
using System;
|
||||
using System.Runtime.Serialization;
|
||||
@@ -34,7 +34,9 @@ using System.Runtime.CompilerServices;
|
||||
namespace System.Threading
|
||||
{
|
||||
[Serializable]
|
||||
#if !MOBILE
|
||||
[TypeForwardedFrom (Consts.AssemblySystemCore_3_5)]
|
||||
#endif
|
||||
public class LockRecursionException : Exception
|
||||
{
|
||||
public LockRecursionException ()
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
//
|
||||
//
|
||||
|
||||
#if NET_4_0
|
||||
#if NET_4_0 || MOBILE
|
||||
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
|
||||
@@ -121,6 +121,16 @@ namespace System
|
||||
return innerExceptions.AsReadOnly ();
|
||||
}
|
||||
}
|
||||
|
||||
internal void AddChildException (AggregateException childEx)
|
||||
{
|
||||
if (innerExceptions == null)
|
||||
innerExceptions = new List<Exception> ();
|
||||
if (childEx == null)
|
||||
return;
|
||||
|
||||
innerExceptions.Add (childEx);
|
||||
}
|
||||
|
||||
public override string ToString ()
|
||||
{
|
||||
|
||||
@@ -1316,6 +1316,25 @@ namespace System {
|
||||
}
|
||||
}
|
||||
|
||||
internal Assembly DoResourceResolve (string name, Assembly requesting) {
|
||||
if (ResourceResolve == null)
|
||||
return null;
|
||||
|
||||
Delegate[] invocation_list = ResourceResolve.GetInvocationList ();
|
||||
|
||||
foreach (Delegate eh in invocation_list) {
|
||||
ResolveEventHandler handler = (ResolveEventHandler) eh;
|
||||
#if NET_4_0
|
||||
Assembly assembly = handler (this, new ResolveEventArgs (name, requesting));
|
||||
#else
|
||||
Assembly assembly = handler (this, new ResolveEventArgs (name));
|
||||
#endif
|
||||
if (assembly != null)
|
||||
return assembly;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private void DoDomainUnload ()
|
||||
{
|
||||
if (DomainUnload != null)
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
#if NET_4_0
|
||||
#if NET_4_0 || MOBILE
|
||||
|
||||
namespace System
|
||||
{
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
#if NET_4_0
|
||||
#if NET_4_0 || MOBILE
|
||||
|
||||
namespace System
|
||||
{
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
//
|
||||
// (C) Ximian, Inc.
|
||||
// Copyright (C) 2004-2006 Novell, Inc (http://www.novell.com)
|
||||
// Copyright 2011 Xamarin Inc.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
@@ -54,6 +55,9 @@ namespace System
|
||||
// Fields
|
||||
static TimeZone currentTimeZone;
|
||||
|
||||
[NonSerialized]
|
||||
static long timezone_check;
|
||||
|
||||
// Constructor
|
||||
protected TimeZone ()
|
||||
{
|
||||
@@ -62,8 +66,13 @@ namespace System
|
||||
// Properties
|
||||
public static TimeZone CurrentTimeZone {
|
||||
get {
|
||||
if (currentTimeZone == null)
|
||||
currentTimeZone = new CurrentSystemTimeZone (DateTime.GetNow ());
|
||||
long now = DateTime.GetNow ();
|
||||
|
||||
if (currentTimeZone == null || (now - timezone_check) > TimeSpan.TicksPerMinute) {
|
||||
currentTimeZone = new CurrentSystemTimeZone (now);
|
||||
timezone_check = now;
|
||||
}
|
||||
|
||||
return currentTimeZone;
|
||||
}
|
||||
}
|
||||
|
||||
Loaded 100 of 231 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user