Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog33
-rw-r--r--Makefile.am4
-rw-r--r--acconfig.h1
-rw-r--r--configure.in22
-rw-r--r--data/config.in1
-rw-r--r--data/machine.config46
-rw-r--r--doc/Makefile.am6
-rw-r--r--doc/anoncvs5
-rw-r--r--doc/blogs4
-rw-r--r--doc/class-status.in12
-rw-r--r--doc/drawing43
-rw-r--r--doc/index28
-rw-r--r--doc/jit-debug30
-rw-r--r--doc/mono-roadmap.html2
-rwxr-xr-xdoc/plans2
-rw-r--r--doc/runtime2
-rwxr-xr-xdoc/sqlite2
-rw-r--r--doc/web/commands2
-rw-r--r--doc/web/infos/.cvsignore1
-rw-r--r--doc/web/makefile48
-rw-r--r--doc/web/masterinfos/.cvsignore1
-rw-r--r--doc/web/team.xml10
-rw-r--r--doc/web/team/jackson.pngbin4423 -> 4626 bytes
-rw-r--r--doc/winforms8
-rw-r--r--man/mono.113
-rwxr-xr-xmcs/README1
-rw-r--r--mcs/build/ChangeLog5
-rw-r--r--mcs/build/platforms/linux.make2
-rw-r--r--mcs/build/profiles/generics.make2
-rw-r--r--mcs/build/rules.make2
-rwxr-xr-xmcs/class/ByteFX.Data/AssemblyInfo.cs8
-rw-r--r--mcs/class/ByteFX.Data/ByteFX.Data.dll.sources1
-rwxr-xr-xmcs/class/ByteFX.Data/ChangeLog.txt36
-rw-r--r--mcs/class/ByteFX.Data/Common/DBConnectionString.cs8
-rw-r--r--mcs/class/ByteFX.Data/Common/DBParametersEditor.cs2
-rw-r--r--mcs/class/ByteFX.Data/Common/MultiHostStream.cs194
-rwxr-xr-xmcs/class/ByteFX.Data/Common/NamedPipeStream.cs2
-rw-r--r--mcs/class/ByteFX.Data/Common/Security.cs2
-rw-r--r--mcs/class/ByteFX.Data/Common/SqlCommandTextEditor.cs2
-rw-r--r--mcs/class/ByteFX.Data/Common/Version.cs2
-rwxr-xr-xmcs/class/ByteFX.Data/mysqlclient/CommandBuilder.cs15
-rwxr-xr-xmcs/class/ByteFX.Data/mysqlclient/Connection.cs22
-rw-r--r--mcs/class/ByteFX.Data/mysqlclient/ConnectionInternal.cs20
-rw-r--r--mcs/class/ByteFX.Data/mysqlclient/ConnectionString.cs2
-rwxr-xr-xmcs/class/ByteFX.Data/mysqlclient/Driver.cs117
-rwxr-xr-xmcs/class/ByteFX.Data/mysqlclient/Exception.cs17
-rwxr-xr-xmcs/class/ByteFX.Data/mysqlclient/Field.cs22
-rw-r--r--mcs/class/ByteFX.Data/mysqlclient/MySqlHelper.cs118
-rw-r--r--mcs/class/ByteFX.Data/mysqlclient/MySqlPool.cs93
-rw-r--r--mcs/class/ByteFX.Data/mysqlclient/MySqlPoolManager.cs4
-rw-r--r--mcs/class/ByteFX.Data/mysqlclient/MySqlStream.cs150
-rwxr-xr-xmcs/class/ByteFX.Data/mysqlclient/MysqlDefs.cs38
-rw-r--r--mcs/class/ByteFX.Data/mysqlclient/Packet.cs111
-rwxr-xr-xmcs/class/ByteFX.Data/mysqlclient/command.cs116
-rwxr-xr-xmcs/class/ByteFX.Data/mysqlclient/dataadapter.cs153
-rwxr-xr-xmcs/class/ByteFX.Data/mysqlclient/datareader.cs84
-rwxr-xr-xmcs/class/ByteFX.Data/mysqlclient/parameter.cs204
-rwxr-xr-xmcs/class/ByteFX.Data/mysqlclient/parameter_collection.cs107
-rwxr-xr-xmcs/class/ByteFX.Data/mysqlclient/transcaction.cs34
-rw-r--r--mcs/class/Makefile1
-rw-r--r--mcs/class/Microsoft.JScript/ChangeLog4
-rw-r--r--mcs/class/Microsoft.JScript/Microsoft.JScript.dll.sources1
-rw-r--r--mcs/class/Microsoft.JScript/Microsoft.JScript/ASTList.cs5
-rw-r--r--mcs/class/Microsoft.JScript/Microsoft.JScript/ArrayLiteral.cs5
-rw-r--r--mcs/class/Microsoft.JScript/Microsoft.JScript/BitwiseBinary.cs7
-rw-r--r--mcs/class/Microsoft.JScript/Microsoft.JScript/ChangeLog57
-rw-r--r--mcs/class/Microsoft.JScript/Microsoft.JScript/CodeGenerator.cs147
-rw-r--r--mcs/class/Microsoft.JScript/Microsoft.JScript/DebugBreak.cs5
-rw-r--r--mcs/class/Microsoft.JScript/Microsoft.JScript/Enum.cs5
-rw-r--r--mcs/class/Microsoft.JScript/Microsoft.JScript/Equality.cs5
-rw-r--r--mcs/class/Microsoft.JScript/Microsoft.JScript/Eval.cs5
-rw-r--r--mcs/class/Microsoft.JScript/Microsoft.JScript/ForIn.cs5
-rw-r--r--mcs/class/Microsoft.JScript/Microsoft.JScript/FormalParameterList.cs5
-rw-r--r--mcs/class/Microsoft.JScript/Microsoft.JScript/FunctionDeclaration.cs46
-rw-r--r--mcs/class/Microsoft.JScript/Microsoft.JScript/FunctionExpression.cs5
-rw-r--r--mcs/class/Microsoft.JScript/Microsoft.JScript/Import.cs5
-rw-r--r--mcs/class/Microsoft.JScript/Microsoft.JScript/InstanceOf.cs5
-rw-r--r--mcs/class/Microsoft.JScript/Microsoft.JScript/JScriptLexer.cs170
-rw-r--r--mcs/class/Microsoft.JScript/Microsoft.JScript/JScriptParser.cs688
-rw-r--r--mcs/class/Microsoft.JScript/Microsoft.JScript/JScriptParserTokenTypes.cs117
-rw-r--r--mcs/class/Microsoft.JScript/Microsoft.JScript/JScriptParserTokenTypes.txt117
-rw-r--r--mcs/class/Microsoft.JScript/Microsoft.JScript/Literal.cs25
-rw-r--r--mcs/class/Microsoft.JScript/Microsoft.JScript/NumericBinary.cs7
-rw-r--r--mcs/class/Microsoft.JScript/Microsoft.JScript/NumericUnary.cs5
-rw-r--r--mcs/class/Microsoft.JScript/Microsoft.JScript/Package.cs5
-rw-r--r--mcs/class/Microsoft.JScript/Microsoft.JScript/Plus.cs7
-rw-r--r--mcs/class/Microsoft.JScript/Microsoft.JScript/PostOrPrefixOperator.cs5
-rw-r--r--mcs/class/Microsoft.JScript/Microsoft.JScript/Print.cs5
-rw-r--r--mcs/class/Microsoft.JScript/Microsoft.JScript/Relational.cs5
-rw-r--r--mcs/class/Microsoft.JScript/Microsoft.JScript/Statement.cs19
-rw-r--r--mcs/class/Microsoft.JScript/Microsoft.JScript/StrictEquality.cs5
-rw-r--r--mcs/class/Microsoft.JScript/Microsoft.JScript/StringLiteral.cs8
-rw-r--r--mcs/class/Microsoft.JScript/Microsoft.JScript/Throw.cs5
-rw-r--r--mcs/class/Microsoft.JScript/Microsoft.JScript/Try.cs5
-rw-r--r--mcs/class/Microsoft.JScript/Microsoft.JScript/TypeOf.cs5
-rw-r--r--mcs/class/Microsoft.JScript/Microsoft.JScript/VariableDeclaration.cs19
-rw-r--r--mcs/class/Microsoft.JScript/Microsoft.JScript/Visitor.cs46
-rw-r--r--mcs/class/Microsoft.JScript/Microsoft.JScript/With.cs5
-rw-r--r--mcs/class/Microsoft.JScript/Microsoft.JScript/ast.cs11
-rwxr-xr-xmcs/class/Microsoft.JScript/Microsoft.JScript/expression.cs101
-rw-r--r--mcs/class/Microsoft.JScript/Microsoft.JScript/jscript-lexer-parser.g51
-rw-r--r--mcs/class/Microsoft.VisualBasic/Assembly/AssemblyInfo.cs39
-rw-r--r--mcs/class/Microsoft.VisualBasic/Assembly/ChangeLog5
-rw-r--r--mcs/class/Microsoft.VisualBasic/Assembly/Locale.cs24
-rw-r--r--mcs/class/Microsoft.VisualBasic/Changelog4
-rw-r--r--mcs/class/Microsoft.VisualBasic/Microsoft.VisualBasic.dll.sources2
-rw-r--r--mcs/class/Microsoft.VisualBasic/Test/StringsTest.csbin0 -> 71226 bytes
-rw-r--r--mcs/class/Microsoft.Web.Services/Makefile6
-rw-r--r--mcs/class/Mono.Cairo/ChangeLog17
-rw-r--r--mcs/class/Mono.Cairo/Mono.Cairo.dll.sources2
-rw-r--r--mcs/class/Mono.Cairo/Mono.Cairo/Cairo.cs5
-rw-r--r--mcs/class/Mono.Cairo/Mono.Cairo/Graphics.cs369
-rw-r--r--mcs/class/Mono.Cairo/Mono.Cairo/Object.cs72
-rw-r--r--mcs/class/Mono.Cairo/Mono.Cairo/Surface.cs66
-rwxr-xr-xmcs/class/Mono.Data.DB2Client/Mono.Data.Db2Client/DB2ClientParameter.cs2
-rw-r--r--mcs/class/Mono.Data.SqliteClient/Mono.Data.SqliteClient/SqliteDataReader.cs2
-rw-r--r--mcs/class/Mono.Data.SqliteClient/Mono.Data.SqliteClient/SqliteParameterCollection.cs2
-rw-r--r--mcs/class/Mono.Data.Tds/ChangeLog5
-rw-r--r--mcs/class/Mono.Data.Tds/Mono.Data.Tds/TdsMetaParameter.cs4
-rw-r--r--mcs/class/Mono.Posix/Mono.Posix/ChangeLog5
-rw-r--r--mcs/class/Mono.Posix/Mono.Posix/Syscall.cs12
-rw-r--r--mcs/class/Mono.Security/ChangeLog151
-rw-r--r--mcs/class/Mono.Security/Mono.Security.Cryptography/ChangeLog10
-rwxr-xr-xmcs/class/Mono.Security/Mono.Security.Cryptography/MD4.cs39
-rwxr-xr-xmcs/class/Mono.Security/Mono.Security.Cryptography/MD4Managed.cs264
-rw-r--r--mcs/class/Mono.Security/Mono.Security.Cryptography/MD5SHA1.cs127
-rwxr-xr-xmcs/class/Mono.Security/Mono.Security.Cryptography/PKCS8.cs351
-rw-r--r--mcs/class/Mono.Security/Mono.Security.Protocol.Tls.Alerts/TlsAlert.cs89
-rw-r--r--mcs/class/Mono.Security/Mono.Security.Protocol.Tls.Alerts/TlsCloseNotifyAlert.cs6
-rwxr-xr-xmcs/class/Mono.Security/Mono.Security.Protocol.Tls.Handshake.Client/ChangeLog122
-rw-r--r--mcs/class/Mono.Security/Mono.Security.Protocol.Tls.Handshake.Client/TlsClientCertificate.cs12
-rw-r--r--mcs/class/Mono.Security/Mono.Security.Protocol.Tls.Handshake.Client/TlsClientCertificateVerify.cs10
-rw-r--r--mcs/class/Mono.Security/Mono.Security.Protocol.Tls.Handshake.Client/TlsClientFinished.cs16
-rw-r--r--mcs/class/Mono.Security/Mono.Security.Protocol.Tls.Handshake.Client/TlsClientHello.cs28
-rw-r--r--mcs/class/Mono.Security/Mono.Security.Protocol.Tls.Handshake.Client/TlsClientKeyExchange.cs20
-rw-r--r--mcs/class/Mono.Security/Mono.Security.Protocol.Tls.Handshake.Client/TlsServerCertificate.cs62
-rw-r--r--mcs/class/Mono.Security/Mono.Security.Protocol.Tls.Handshake.Client/TlsServerCertificateRequest.cs10
-rw-r--r--mcs/class/Mono.Security/Mono.Security.Protocol.Tls.Handshake.Client/TlsServerFinished.cs20
-rw-r--r--mcs/class/Mono.Security/Mono.Security.Protocol.Tls.Handshake.Client/TlsServerHello.cs47
-rw-r--r--mcs/class/Mono.Security/Mono.Security.Protocol.Tls.Handshake.Client/TlsServerHelloDone.cs6
-rw-r--r--mcs/class/Mono.Security/Mono.Security.Protocol.Tls.Handshake.Client/TlsServerKeyExchange.cs20
-rwxr-xr-xmcs/class/Mono.Security/Mono.Security.Protocol.Tls.Handshake/ChangeLog122
-rw-r--r--mcs/class/Mono.Security/Mono.Security.Protocol.Tls.Handshake/TlsHandshakeMessage.cs39
-rw-r--r--mcs/class/Mono.Security/Mono.Security.Protocol.Tls/ChangeLog120
-rw-r--r--mcs/class/Mono.Security/Mono.Security.Protocol.Tls/CipherAlgorithmType.cs39
-rwxr-xr-xmcs/class/Mono.Security/Mono.Security.Protocol.Tls/CipherSuite.cs313
-rw-r--r--mcs/class/Mono.Security/Mono.Security.Protocol.Tls/ExchangeAlgorithmType.cs37
-rw-r--r--mcs/class/Mono.Security/Mono.Security.Protocol.Tls/HashAlgorithmType.cs35
-rw-r--r--mcs/class/Mono.Security/Mono.Security.Protocol.Tls/SecurityCompressionType.cs37
-rw-r--r--mcs/class/Mono.Security/Mono.Security.Protocol.Tls/SecurityProtocolType.cs35
-rw-r--r--mcs/class/Mono.Security/Mono.Security.Protocol.Tls/SslClientStream.cs1002
-rw-r--r--mcs/class/Mono.Security/Mono.Security.Protocol.Tls/TlsCipherSuite.cs16
-rw-r--r--mcs/class/Mono.Security/Mono.Security.Protocol.Tls/TlsCipherSuiteCollection.cs25
-rwxr-xr-xmcs/class/Mono.Security/Mono.Security.Protocol.Tls/TlsCipherSuiteFactory.cs183
-rw-r--r--mcs/class/Mono.Security/Mono.Security.Protocol.Tls/TlsClientSettings.cs81
-rw-r--r--mcs/class/Mono.Security/Mono.Security.Protocol.Tls/TlsContext.cs351
-rw-r--r--mcs/class/Mono.Security/Mono.Security.Protocol.Tls/TlsServerSettings.cs8
-rwxr-xr-xmcs/class/Mono.Security/Mono.Security.Protocol.Tls/TlsSslCipherSuite.cs29
-rw-r--r--mcs/class/Mono.Security/Mono.Security.dll.sources21
-rw-r--r--mcs/class/Mono.Security/Mono.Security_test.dll.sources3
-rw-r--r--mcs/class/Mono.Security/Test/Mono.Security.Cryptography/ChangeLog8
-rwxr-xr-xmcs/class/Mono.Security/Test/Mono.Security.Cryptography/MD4ManagedTest.cs27
-rwxr-xr-xmcs/class/Mono.Security/Test/Mono.Security.Cryptography/MD4Test.cs226
-rwxr-xr-xmcs/class/Mono.Security/Test/Mono.Security.Cryptography/PKCS8Test.cs92
-rw-r--r--mcs/class/Novell.Directory.Ldap/ChangeLog22
-rw-r--r--mcs/class/Novell.Directory.Ldap/Makefile13
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1Boolean.cs122
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1Choice.cs149
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1Decoder.cs194
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1Encoder.cs174
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1Enumerated.cs119
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1Identifier.cs327
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1Integer.cs123
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1Length.cs142
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1Null.cs89
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1Numeric.cs77
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1Object.cs123
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1OctetString.cs181
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1Sequence.cs124
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1SequenceOf.cs125
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1Set.cs106
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1SetOf.cs102
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1Structured.cs214
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1Tagged.cs172
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/LBERDecoder.cs277
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/LBEREncoder.cs305
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Controls/LdapEntryChangeControl.cs209
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Controls/LdapPersistSearchControl.cs284
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Controls/LdapSortControl.cs134
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Controls/LdapSortKey.cs171
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Controls/LdapSortResponse.cs145
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Controls/LdapVirtualListControl.cs527
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Controls/LdapVirtualListResponse.cs202
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/AbortPartitionOperationRequest.cs99
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/AddReplicaRequest.cs128
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/ChangeReplicaTypeRequest.cs130
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/GetBindDNRequest.cs71
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/GetBindDNResponse.cs110
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/GetEffectivePrivilegesRequest.cs111
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/GetEffectivePrivilegesResponse.cs123
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/GetReplicaInfoRequest.cs102
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/GetReplicaInfoResponse.cs306
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/GetReplicationFilterRequest.cs96
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/GetReplicationFilterResponse.cs165
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/ListReplicasRequest.cs91
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/ListReplicasResponse.cs125
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/MergePartitionsRequest.cs102
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/NamingContextConstants.cs367
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/PartitionEntryCountRequest.cs98
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/PartitionEntryCountResponse.cs107
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/PartitionSyncRequest.cs104
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/ReceiveAllUpdatesRequest.cs104
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/RefreshLdapServerRequest.cs64
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/RemoveOrphanPartitionRequest.cs98
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/RemoveReplicaRequest.cs108
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/ReplicationConstants.cs369
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/SchemaSyncRequest.cs95
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/SendAllUpdatesRequest.cs96
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/SetReplicationFilterRequest.cs155
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/SplitOrphanPartitionRequest.cs100
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/SplitPartitionRequest.cs101
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/TriggerBackgroundProcessRequest.cs120
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcAbandonRequest.cs82
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcAddRequest.cs119
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcAddResponse.cs89
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcAssertionValue.cs54
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcAttributeDescription.cs55
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcAttributeDescriptionList.cs84
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcAttributeList.cs57
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcAttributeTypeAndValues.cs61
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcAttributeValue.cs55
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcAttributeValueAssertion.cs90
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcAuthenticationChoice.cs72
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcBindRequest.cs166
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcBindResponse.cs141
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcCompareRequest.cs106
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcCompareResponse.cs89
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcControl.cs189
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcControls.cs102
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcDelRequest.cs98
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcDelResponse.cs89
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcExtendedRequest.cs120
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcExtendedResponse.cs156
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcFilter.cs1404
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcLdapDN.cs61
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcLdapMessage.cs342
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcLdapOID.cs54
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcLdapResult.cs211
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcLdapString.cs59
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcLdapURL.cs55
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcMatchingRuleAssertion.cs94
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcMatchingRuleId.cs51
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcMessageID.cs95
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcModifyDNRequest.cs108
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcModifyDNResponse.cs87
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcModifyRequest.cs118
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcModifyResponse.cs89
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcReferral.cs68
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcRelativeLdapDN.cs48
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcRequest.cs49
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcResponse.cs59
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcSaslCredentials.cs66
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcSearchRequest.cs139
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcSearchResultDone.cs88
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcSearchResultEntry.cs98
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcSearchResultReference.cs71
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcSubstringFilter.cs64
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcUnbindRequest.cs83
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Utilclass/ArrayEnumeration.cs89
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Utilclass/AttributeQualifier.cs93
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Utilclass/Base64.cs722
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Utilclass/BindProperties.cs134
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Utilclass/DN.cs743
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Utilclass/EnumeratedIterator.cs91
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Utilclass/ExceptionMessages.cs120
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Utilclass/ExtResponseFactory.cs117
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Utilclass/RDN.cs315
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Utilclass/ReferralInfo.cs104
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Utilclass/ResourcesHandler.cs214
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Utilclass/RespControlVector.cs124
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Utilclass/ResultCodeMessages.cs50
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.dll.sources160
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/AssemblyInfo.cs93
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/Connection.cs1387
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/InterThreadException.cs147
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapAbandonRequest.cs62
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapAddRequest.cs132
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapAttribute.cs1068
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapAttributeSet.cs426
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapAuthHandler.cs73
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapAuthProvider.cs101
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapBindHandler.cs90
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapBindRequest.cs101
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapCompareAttrNames.cs299
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapCompareRequest.cs115
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapConnection.cs3625
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapConstraints.cs465
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapControl.cs237
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapDN.cs262
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapDeleteRequest.cs84
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapEntry.cs207
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapException.cs1142
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapExtendedOperation.cs129
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapExtendedRequest.cs95
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapExtendedResponse.cs94
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapLocalException.cs163
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapMessage.cs676
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapMessageQueue.cs286
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapModification.cs173
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapModifyDNRequest.cs156
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapModifyRequest.cs183
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapReferralException.cs297
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapReferralHandler.cs50
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapResponse.cs482
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapResponseQueue.cs78
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapSearchConstraints.cs430
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapSearchQueue.cs82
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapSearchRequest.cs405
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapSearchResult.cs133
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapSearchResultReference.cs83
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapSearchResults.cs395
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapUnbindRequest.cs58
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapUnsolicitedNotificationListener.cs56
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapUrl.cs862
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/Message.cs605
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/MessageAgent.cs436
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/MessageVector.cs109
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/SupportClass.cs2090
-rw-r--r--mcs/class/Npgsql/ChangeLog39
-rwxr-xr-xmcs/class/Npgsql/Makefile2
-rwxr-xr-xmcs/class/Npgsql/Npgsql/HashAlgorithm.cs7
-rwxr-xr-xmcs/class/Npgsql/Npgsql/NpgsqlClosedState.cs88
-rwxr-xr-xmcs/class/Npgsql/Npgsql/NpgsqlCommand.cs23
-rwxr-xr-xmcs/class/Npgsql/Npgsql/NpgsqlConnectedState.cs5
-rwxr-xr-xmcs/class/Npgsql/Npgsql/NpgsqlConnection.cs184
-rwxr-xr-xmcs/class/Npgsql/Npgsql/NpgsqlDataAdapter.cs8
-rwxr-xr-xmcs/class/Npgsql/Npgsql/NpgsqlDataReader.cs4
-rwxr-xr-xmcs/class/Npgsql/Npgsql/NpgsqlReadyState.cs15
-rwxr-xr-xmcs/class/Npgsql/Npgsql/NpgsqlStartupState.cs2
-rwxr-xr-xmcs/class/Npgsql/Npgsql/NpgsqlState.cs5
-rw-r--r--mcs/class/Npgsql/NpgsqlTypes/.cvsignore1
-rw-r--r--mcs/class/PEAPI/ChangeLog9
-rw-r--r--mcs/class/PEAPI/PEAPI.cs71
-rw-r--r--mcs/class/README35
-rw-r--r--mcs/class/System.Data.Db2Client/Makefile23
-rw-r--r--mcs/class/System.Data.Db2Client/System.Data.Db2Client.dll.sources19
-rw-r--r--mcs/class/System.Data.Db2Client/System.Data.Db2Client/AssemblyInfo.cs19
-rw-r--r--mcs/class/System.Data.Db2Client/System.Data.Db2Client/BLOBWrapper.cs25
-rw-r--r--mcs/class/System.Data.Db2Client/System.Data.Db2Client/BLOBWrapperCollection.cs25
-rw-r--r--mcs/class/System.Data.Db2Client/System.Data.Db2Client/Db2CLIWrapper.cs92
-rw-r--r--mcs/class/System.Data.Db2Client/System.Data.Db2Client/Db2ClientUtils.cs29
-rw-r--r--mcs/class/System.Data.Db2Client/System.Data.Db2Client/Db2Command.cs360
-rw-r--r--mcs/class/System.Data.Db2Client/System.Data.Db2Client/Db2Connection.cs335
-rw-r--r--mcs/class/System.Data.Db2Client/System.Data.Db2Client/Db2Constants.cs140
-rw-r--r--mcs/class/System.Data.Db2Client/System.Data.Db2Client/Db2DataAdapter.cs163
-rw-r--r--mcs/class/System.Data.Db2Client/System.Data.Db2Client/Db2DataReader.cs763
-rw-r--r--mcs/class/System.Data.Db2Client/System.Data.Db2Client/Db2Exception.cs46
-rw-r--r--mcs/class/System.Data.Db2Client/System.Data.Db2Client/Db2LOBLocator.cs16
-rw-r--r--mcs/class/System.Data.Db2Client/System.Data.Db2Client/Db2Parameter.cs448
-rw-r--r--mcs/class/System.Data.Db2Client/System.Data.Db2Client/Db2ParameterCollection.cs103
-rw-r--r--mcs/class/System.Data.Db2Client/System.Data.Db2Client/Db2RowUpdatedEventArgs.cs17
-rw-r--r--mcs/class/System.Data.Db2Client/System.Data.Db2Client/Db2RowUpdatedEventHandler.cs5
-rw-r--r--mcs/class/System.Data.Db2Client/System.Data.Db2Client/Db2RowUpdatingEventArgs.cs19
-rw-r--r--mcs/class/System.Data.Db2Client/System.Data.Db2Client/Db2RowUpdatingEventHandler.cs5
-rw-r--r--mcs/class/System.Data.Db2Client/System.Data.Db2Client/Db2Transaction.cs93
-rw-r--r--mcs/class/System.Data.Db2Client/System.Data.Db2Client_test.dll.sources0
-rw-r--r--mcs/class/System.Data.ObjectSpaces/Assembly/AssemblyInfo.cs48
-rw-r--r--mcs/class/System.Data.ObjectSpaces/Assembly/ChangeLog4
-rw-r--r--mcs/class/System.Data.ObjectSpaces/Assembly/Locale.cs24
-rw-r--r--mcs/class/System.Data.ObjectSpaces/ChangeLog71
-rw-r--r--mcs/class/System.Data.ObjectSpaces/Makefile11
-rw-r--r--mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Query/ASTQueryParser.cs58
-rw-r--r--mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Query/Axis.cs67
-rw-r--r--mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Query/Binary.cs104
-rw-r--r--mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Query/ChangeLog4
-rw-r--r--mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Query/Conditional.cs62
-rw-r--r--mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Query/Context.cs38
-rw-r--r--mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Query/Delegates.cs16
-rw-r--r--mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Query/Empty.cs24
-rw-r--r--mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Query/Enumerations.cs113
-rw-r--r--mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Query/Expression.cs115
-rw-r--r--mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Query/Filter.cs30
-rw-r--r--mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Query/Function.cs30
-rw-r--r--mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Query/Literal.cs24
-rw-r--r--mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Query/OPath.cs25
-rw-r--r--mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Query/ObjectExpression.cs66
-rw-r--r--mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Query/ObjectSpaceNode.cs38
-rw-r--r--mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Query/OrderBy.cs30
-rw-r--r--mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Query/OrderByItem.cs24
-rw-r--r--mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Query/OrderByItemCollection.cs26
-rw-r--r--mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Query/Parameter.cs30
-rw-r--r--mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Query/Parent.cs24
-rw-r--r--mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Query/Property.cs30
-rw-r--r--mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Query/RelTraversal.cs36
-rw-r--r--mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Query/Span.cs30
-rw-r--r--mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Query/SpanProperty.cs30
-rw-r--r--mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Query/SpanPropertyCollection.cs26
-rw-r--r--mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Query/TypeCast.cs36
-rw-r--r--mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Query/TypeConversion.cs30
-rw-r--r--mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Query/TypeFilter.cs36
-rw-r--r--mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Query/Unary.cs30
-rw-r--r--mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Schema/ExtendedProperty.cs63
-rw-r--r--mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Schema/ExtendedPropertyCollection.cs126
-rw-r--r--mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Schema/ObjectRelationship.cs124
-rw-r--r--mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Schema/ObjectRelationshipCollection.cs86
-rw-r--r--mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Schema/ObjectRelationshipType.cs21
-rw-r--r--mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Schema/ObjectSchema.cs286
-rw-r--r--mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Schema/SchemaClass.cs91
-rw-r--r--mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Schema/SchemaClassCollection.cs78
-rw-r--r--mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Schema/SchemaMember.cs112
-rw-r--r--mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Schema/SchemaMemberCollection.cs78
-rw-r--r--mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.dll.sources80
-rwxr-xr-xmcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/ASTBaseParser.cs60
-rwxr-xr-xmcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/AstKeywords.cs51
-rwxr-xr-xmcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/CommonObjectContext.cs113
-rwxr-xr-xmcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/CompiledQuery.cs21
-rwxr-xr-xmcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/ContextException.cs45
-rwxr-xr-xmcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/DbObjectReader.cs65
-rwxr-xr-xmcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/Depth.cs21
-rwxr-xr-xmcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/DynamicAssembly.cs90
-rwxr-xr-xmcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/IObjectHelper.cs24
-rwxr-xr-xmcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/IObjectNotification.cs28
-rwxr-xr-xmcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/InitialState.cs21
-rwxr-xr-xmcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/KeyGenerator.cs34
-rwxr-xr-xmcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/ManyToManyRelationship.cs26
-rwxr-xr-xmcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/ManyToOneRelationship.cs25
-rwxr-xr-xmcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/ObjectContext.cs55
-rwxr-xr-xmcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/ObjectEngine.cs49
-rwxr-xr-xmcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/ObjectException.cs46
-rwxr-xr-xmcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/ObjectHolder.cs31
-rwxr-xr-xmcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/ObjectKey.cs40
-rwxr-xr-xmcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/ObjectKeyManager.cs31
-rwxr-xr-xmcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/ObjectList.cs108
-rwxr-xr-xmcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/ObjectQuery.cs76
-rwxr-xr-xmcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/ObjectReader.cs88
-rwxr-xr-xmcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/ObjectSet.cs132
-rwxr-xr-xmcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/ObjectSources.cs86
-rwxr-xr-xmcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/ObjectSpace.cs119
-rwxr-xr-xmcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/ObjectState.cs24
-rwxr-xr-xmcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/OneToManyRelationship.cs22
-rwxr-xr-xmcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/OneToOneRelationship.cs34
-rwxr-xr-xmcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/PersistenceError.cs36
-rwxr-xr-xmcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/PersistenceErrorBehavior.cs23
-rwxr-xr-xmcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/PersistenceErrorBehaviour.cs21
-rwxr-xr-xmcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/PersistenceErrorType.cs23
-rwxr-xr-xmcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/PersistenceException.cs76
-rwxr-xr-xmcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/PersistenceOptions.cs60
-rwxr-xr-xmcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/PersisteneceErrorType.cs23
-rwxr-xr-xmcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/UpdateErrorType.cs23
-rwxr-xr-xmcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/ValueRecord.cs50
-rwxr-xr-xmcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/ValueRecordMergeEventArgs.cs46
-rwxr-xr-xmcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/ValueRecordMergeEventHandler.cs17
-rw-r--r--mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces_test.dll.sources2
-rw-r--r--mcs/class/System.Data.ObjectSpaces/TODOAttribute.cs39
-rw-r--r--mcs/class/System.Data.ObjectSpaces/Test/ChangeLog10
-rw-r--r--mcs/class/System.Data.ObjectSpaces/Test/SupportFiles/osd.xml11
-rw-r--r--mcs/class/System.Data.ObjectSpaces/Test/SupportFiles/rsd.xml19
-rwxr-xr-xmcs/class/System.Data.ObjectSpaces/Test/System.Data.ObjectSpaces.Query/ObjectExpressionTests.cs49
-rwxr-xr-xmcs/class/System.Data.ObjectSpaces/Test/System.Data.ObjectSpaces/CommonObjectContextTests.cs77
-rwxr-xr-xmcs/class/System.Data.ObjectSpaces/Test/run_test.sh27
-rw-r--r--mcs/class/System.Data.SqlXml/ChangeLog8
-rw-r--r--mcs/class/System.Data.SqlXml/Makefile11
-rwxr-xr-xmcs/class/System.Data.SqlXml/System.Data.Mapping/Condition.cs58
-rwxr-xr-xmcs/class/System.Data.SqlXml/System.Data.Mapping/ConditionCollection.cs45
-rwxr-xr-xmcs/class/System.Data.SqlXml/System.Data.Mapping/DataSource.cs68
-rwxr-xr-xmcs/class/System.Data.SqlXml/System.Data.Mapping/DataSourceCollection.cs50
-rwxr-xr-xmcs/class/System.Data.SqlXml/System.Data.Mapping/Field.cs38
-rwxr-xr-xmcs/class/System.Data.SqlXml/System.Data.Mapping/FieldCollection.cs45
-rwxr-xr-xmcs/class/System.Data.SqlXml/System.Data.Mapping/FieldJoin.cs48
-rwxr-xr-xmcs/class/System.Data.SqlXml/System.Data.Mapping/FieldJoinCollection.cs45
-rwxr-xr-xmcs/class/System.Data.SqlXml/System.Data.Mapping/FieldMap.cs83
-rwxr-xr-xmcs/class/System.Data.SqlXml/System.Data.Mapping/FieldMapCollection.cs45
-rwxr-xr-xmcs/class/System.Data.SqlXml/System.Data.Mapping/IDomainConstraint.cs28
-rwxr-xr-xmcs/class/System.Data.SqlXml/System.Data.Mapping/IDomainField.cs24
-rwxr-xr-xmcs/class/System.Data.SqlXml/System.Data.Mapping/IDomainFieldJoin.cs24
-rwxr-xr-xmcs/class/System.Data.SqlXml/System.Data.Mapping/IDomainFieldJoinCollection.cs31
-rwxr-xr-xmcs/class/System.Data.SqlXml/System.Data.Mapping/IDomainSchema.cs50
-rwxr-xr-xmcs/class/System.Data.SqlXml/System.Data.Mapping/IDomainStructure.cs32
-rwxr-xr-xmcs/class/System.Data.SqlXml/System.Data.Mapping/Map.cs63
-rwxr-xr-xmcs/class/System.Data.SqlXml/System.Data.Mapping/MapCollection.cs45
-rwxr-xr-xmcs/class/System.Data.SqlXml/System.Data.Mapping/MappingAccess.cs21
-rwxr-xr-xmcs/class/System.Data.SqlXml/System.Data.Mapping/MappingArgumentType.cs23
-rwxr-xr-xmcs/class/System.Data.SqlXml/System.Data.Mapping/MappingConditionOperator.cs28
-rwxr-xr-xmcs/class/System.Data.SqlXml/System.Data.Mapping/MappingDataSourceType.cs21
-rwxr-xr-xmcs/class/System.Data.SqlXml/System.Data.Mapping/MappingDirection.cs20
-rwxr-xr-xmcs/class/System.Data.SqlXml/System.Data.Mapping/MappingParameter.cs49
-rwxr-xr-xmcs/class/System.Data.SqlXml/System.Data.Mapping/MappingParameterCollection.cs45
-rwxr-xr-xmcs/class/System.Data.SqlXml/System.Data.Mapping/MappingSchema.cs174
-rwxr-xr-xmcs/class/System.Data.SqlXml/System.Data.Mapping/Relationship.cs68
-rwxr-xr-xmcs/class/System.Data.SqlXml/System.Data.Mapping/RelationshipCollection.cs45
-rwxr-xr-xmcs/class/System.Data.SqlXml/System.Data.Mapping/RelationshipMap.cs43
-rwxr-xr-xmcs/class/System.Data.SqlXml/System.Data.Mapping/RelationshipMapCollection.cs45
-rwxr-xr-xmcs/class/System.Data.SqlXml/System.Data.Mapping/Variable.cs53
-rwxr-xr-xmcs/class/System.Data.SqlXml/System.Data.Mapping/VariableCollection.cs45
-rw-r--r--mcs/class/System.Data.SqlXml/System.Data.SqlXml.dll.sources52
-rwxr-xr-xmcs/class/System.Data.SqlXml/System.Data.SqlXml/DBObject.cs92
-rwxr-xr-xmcs/class/System.Data.SqlXml/System.Data.SqlXml/DBObjectException.cs63
-rwxr-xr-xmcs/class/System.Data.SqlXml/System.Data.SqlXml/FillStatus.cs21
-rwxr-xr-xmcs/class/System.Data.SqlXml/System.Data.SqlXml/RowFilledEventArgs.cs54
-rwxr-xr-xmcs/class/System.Data.SqlXml/System.Data.SqlXml/RowFillingEventArgs.cs54
-rwxr-xr-xmcs/class/System.Data.SqlXml/System.Data.SqlXml/XmlBulkLoad.cs101
-rwxr-xr-xmcs/class/System.Data.SqlXml/System.Data.SqlXml/XmlBulkLoadException.cs63
-rwxr-xr-xmcs/class/System.Data.SqlXml/System.Data.SqlXml/XmlRowsetAdapter.cs84
-rwxr-xr-xmcs/class/System.Data.SqlXml/System.Data.SqlXml/XmlRowsetAdapterException.cs63
-rwxr-xr-xmcs/class/System.Data.SqlXml/System.Xml.Query/SqlQueryOptions.cs43
-rwxr-xr-xmcs/class/System.Data.SqlXml/System.Xml.Query/SqlQueryPlan.cs21
-rwxr-xr-xmcs/class/System.Data.SqlXml/System.Xml.Query/XQueryProcessor.cs105
-rwxr-xr-xmcs/class/System.Data.SqlXml/System.Xml.Query/XmlCommand.cs26
-rwxr-xr-xmcs/class/System.Data.SqlXml/System.Xml.Query/XmlQueryArgumentList.cs97
-rwxr-xr-xmcs/class/System.Data.SqlXml/System.Xml.Query/XmlQueryCompileException.cs64
-rwxr-xr-xmcs/class/System.Data.SqlXml/System.Xml.Query/XmlQueryException.cs85
-rwxr-xr-xmcs/class/System.Data.SqlXml/System.Xml.Query/XmlViewSchema.cs35
-rwxr-xr-xmcs/class/System.Data.SqlXml/System.Xml.Query/XmlViewSchemaDictionary.cs170
-rwxr-xr-xmcs/class/System.Data.SqlXml/System.Xml.Query/XsltProcessor.cs72
-rw-r--r--mcs/class/System.Data.SqlXml/TODOAttribute.cs39
-rw-r--r--mcs/class/System.Data/ChangeLog8
-rwxr-xr-xmcs/class/System.Data/System.Data.Common/ChangeLog15
-rw-r--r--mcs/class/System.Data/System.Data.Common/DataColumnMappingCollection.cs6
-rw-r--r--mcs/class/System.Data/System.Data.Common/DbDataAdapter.cs31
-rw-r--r--mcs/class/System.Data/System.Data.Common/DbDataReader.cs89
-rwxr-xr-xmcs/class/System.Data/System.Data.SqlClient/ChangeLog14
-rw-r--r--mcs/class/System.Data/System.Data.SqlClient/SqlConnection.cs2
-rw-r--r--mcs/class/System.Data/System.Data.SqlClient/SqlParameterCollection.cs7
-rwxr-xr-xmcs/class/System.Data/System.Data.dll.sources23
-rw-r--r--mcs/class/System.Data/System.Data/AdapterMappingException.cs44
-rw-r--r--mcs/class/System.Data/System.Data/ChangeLog37
-rw-r--r--mcs/class/System.Data/System.Data/ConflictOptions.cs32
-rw-r--r--mcs/class/System.Data/System.Data/DBConcurrencyException.cs40
-rw-r--r--mcs/class/System.Data/System.Data/DataAdapterException.cs44
-rw-r--r--mcs/class/System.Data/System.Data/DataRelation.cs12
-rw-r--r--mcs/class/System.Data/System.Data/DataRow.cs377
-rw-r--r--mcs/class/System.Data/System.Data/DataSet.cs529
-rw-r--r--mcs/class/System.Data/System.Data/DataTable.cs166
-rw-r--r--mcs/class/System.Data/System.Data/DataTableCollection.cs16
-rw-r--r--mcs/class/System.Data/System.Data/DataTableReader.cs266
-rw-r--r--mcs/class/System.Data/System.Data/DataView.cs24
-rw-r--r--mcs/class/System.Data/System.Data/DbMetaData.cs64
-rw-r--r--mcs/class/System.Data/System.Data/FillOptions.cs22
-rw-r--r--mcs/class/System.Data/System.Data/ForeignKeyConstraint.cs8
-rw-r--r--mcs/class/System.Data/System.Data/IDataReader2.cs23
-rw-r--r--mcs/class/System.Data/System.Data/IDataRecord2.cs31
-rw-r--r--mcs/class/System.Data/System.Data/IDataSources.cs34
-rw-r--r--mcs/class/System.Data/System.Data/IDataUpdatableRecord.cs29
-rw-r--r--mcs/class/System.Data/System.Data/IDbAsyncCommand.cs26
-rw-r--r--mcs/class/System.Data/System.Data/IDbAsyncConnection.cs24
-rw-r--r--mcs/class/System.Data/System.Data/IDbExecutionContext.cs44
-rw-r--r--mcs/class/System.Data/System.Data/IGetTypedData.cs40
-rw-r--r--mcs/class/System.Data/System.Data/ISetTypedData.cs38
-rw-r--r--mcs/class/System.Data/System.Data/LoadOption.cs21
-rw-r--r--mcs/class/System.Data/System.Data/OperationAbortedException.cs44
-rw-r--r--mcs/class/System.Data/System.Data/ResultSetOptions.cs23
-rw-r--r--mcs/class/System.Data/System.Data/ResultSetSensitivity.cs21
-rw-r--r--mcs/class/System.Data/System.Data/StatementCompletedEventArgs.cs40
-rw-r--r--mcs/class/System.Data/System.Data/StatementCompletedEventHandler.cs16
-rw-r--r--mcs/class/System.Data/System.Data/UniqueConstraint.cs2
-rw-r--r--mcs/class/System.Data/System.Data/UpdateOptions.cs22
-rw-r--r--mcs/class/System.DirectoryServices/ChangeLog3
-rw-r--r--mcs/class/System.DirectoryServices/Makefile2
-rwxr-xr-xmcs/class/System.DirectoryServices/System.DirectoryServices.dll.sources12
-rw-r--r--mcs/class/System.DirectoryServices/System.DirectoryServices/AssemblyInfo.cs24
-rw-r--r--mcs/class/System.DirectoryServices/System.DirectoryServices/AuthenticationTypes.cs60
-rw-r--r--mcs/class/System.DirectoryServices/System.DirectoryServices/DirectoryEntries.cs303
-rw-r--r--mcs/class/System.DirectoryServices/System.DirectoryServices/DirectoryEntry.cs833
-rw-r--r--mcs/class/System.DirectoryServices/System.DirectoryServices/DirectorySearcher.cs499
-rw-r--r--mcs/class/System.DirectoryServices/System.DirectoryServices/PropertyCollection.cs174
-rw-r--r--mcs/class/System.DirectoryServices/System.DirectoryServices/PropertyValueCollection.cs193
-rw-r--r--mcs/class/System.DirectoryServices/System.DirectoryServices/ReferralChasingOption.cs64
-rw-r--r--mcs/class/System.DirectoryServices/System.DirectoryServices/ResultPropertyCollection.cs91
-rw-r--r--mcs/class/System.DirectoryServices/System.DirectoryServices/ResultPropertyValueCollection.cs81
-rw-r--r--mcs/class/System.DirectoryServices/System.DirectoryServices/SchemaNameCollection.cs147
-rw-r--r--mcs/class/System.DirectoryServices/System.DirectoryServices/SearchResult.cs102
-rw-r--r--mcs/class/System.DirectoryServices/System.DirectoryServices/SearchResultCollection.cs165
-rw-r--r--mcs/class/System.DirectoryServices/System.DirectoryServices/SearchScope.cs48
-rw-r--r--mcs/class/System.DirectoryServices/System.DirectoryServices/SortDirection.cs47
-rw-r--r--mcs/class/System.Drawing/Assembly/ChangeLog4
-rw-r--r--mcs/class/System.Drawing/Assembly/Consts.cs48
-rw-r--r--mcs/class/System.Drawing/ChangeLog4
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Drawing2D/Blend.cs2
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Drawing2D/ChangeLog28
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Drawing2D/ColorBlend.cs2
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Drawing2D/CustomLineCap.cs29
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Drawing2D/GraphicsContainer.cs9
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Drawing2D/InterpolationMode.cs2
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Drawing2D/LinearGradientBrush.cs40
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Drawing2D/Matrix.cs633
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Drawing2D/PathData.cs26
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Drawing2D/PathGradientBrush.cs15
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Drawing2D/QualityMode.cs2
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Drawing2D/RegionData.cs22
-rwxr-xr-xmcs/class/System.Drawing/System.Drawing.Imaging/BitmapData.cs19
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Imaging/ChangeLog19
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Imaging/ColorMap.cs28
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Imaging/ColorMatrix.cs291
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Imaging/EmfPlusRecordType.cs7
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Imaging/ImageAttributes.cs19
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Imaging/ImageCodecFlags.cs3
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Imaging/ImageCodecInfo.cs30
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Imaging/ImageFlags.cs3
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Imaging/ImageFormat.cs58
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Imaging/JPEGCodec.cs27
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Imaging/MetaHeader.cs61
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Imaging/PNGCodec.cs99
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Imaging/PropertyItem.cs38
-rwxr-xr-xmcs/class/System.Drawing/System.Drawing.dll.sources2
-rwxr-xr-xmcs/class/System.Drawing/System.Drawing/Bitmap.cs22
-rwxr-xr-xmcs/class/System.Drawing/System.Drawing/Brush.cs19
-rw-r--r--mcs/class/System.Drawing/System.Drawing/ChangeLog122
-rw-r--r--mcs/class/System.Drawing/System.Drawing/Color.cs3
-rw-r--r--mcs/class/System.Drawing/System.Drawing/ColorTranslator.cs7
-rw-r--r--mcs/class/System.Drawing/System.Drawing/ContentAlignment.cs3
-rw-r--r--mcs/class/System.Drawing/System.Drawing/Font.cs5
-rw-r--r--mcs/class/System.Drawing/System.Drawing/FontFamily.cs2
-rwxr-xr-xmcs/class/System.Drawing/System.Drawing/Graphics.cs204
-rw-r--r--mcs/class/System.Drawing/System.Drawing/Icon.cs5
-rw-r--r--mcs/class/System.Drawing/System.Drawing/IconConverter.cs17
-rw-r--r--mcs/class/System.Drawing/System.Drawing/Image.cs5
-rw-r--r--mcs/class/System.Drawing/System.Drawing/ImageAnimator.cs4
-rw-r--r--mcs/class/System.Drawing/System.Drawing/ImageConverter.cs11
-rw-r--r--mcs/class/System.Drawing/System.Drawing/ImageFormatConverter.cs10
-rwxr-xr-xmcs/class/System.Drawing/System.Drawing/Pen.cs300
-rw-r--r--mcs/class/System.Drawing/System.Drawing/Point.cs4
-rw-r--r--mcs/class/System.Drawing/System.Drawing/PointF.cs2
-rw-r--r--mcs/class/System.Drawing/System.Drawing/Rectangle.cs3
-rw-r--r--mcs/class/System.Drawing/System.Drawing/Region.cs459
-rw-r--r--mcs/class/System.Drawing/System.Drawing/Size.cs4
-rw-r--r--mcs/class/System.Drawing/System.Drawing/SizeConverter.cs58
-rw-r--r--mcs/class/System.Drawing/System.Drawing/SizeF.cs4
-rw-r--r--mcs/class/System.Drawing/System.Drawing/SolidBrush.cs12
-rw-r--r--mcs/class/System.Drawing/System.Drawing/StringFormat.cs23
-rw-r--r--mcs/class/System.Drawing/System.Drawing/SystemBrushes.cs20
-rw-r--r--mcs/class/System.Drawing/System.Drawing/SystemColors.cs7
-rw-r--r--mcs/class/System.Drawing/System.Drawing/SystemIcons.cs7
-rw-r--r--mcs/class/System.Drawing/System.Drawing/SystemPens.cs4
-rw-r--r--mcs/class/System.Drawing/System.Drawing/TextureBrush.cs13
-rw-r--r--mcs/class/System.Drawing/System.Drawing/gdipEnums.cs10
-rw-r--r--mcs/class/System.Drawing/System.Drawing/gdipFunctions.cs183
-rw-r--r--mcs/class/System.Drawing/System.Drawing/gdipStructs.cs21
-rw-r--r--mcs/class/System.Drawing/gdiplus/ChangeLog119
-rw-r--r--mcs/class/System.Drawing/gdiplus/Makefile5
-rw-r--r--mcs/class/System.Drawing/gdiplus/bitmap.c31
-rw-r--r--mcs/class/System.Drawing/gdiplus/brush.c46
-rwxr-xr-xmcs/class/System.Drawing/gdiplus/empty.c1
-rw-r--r--mcs/class/System.Drawing/gdiplus/gdip.h408
-rw-r--r--mcs/class/System.Drawing/gdiplus/gdip_defs.h162
-rw-r--r--mcs/class/System.Drawing/gdiplus/gdip_main.h144
-rw-r--r--mcs/class/System.Drawing/gdiplus/general.c14
-rw-r--r--mcs/class/System.Drawing/gdiplus/graphics.c116
-rw-r--r--mcs/class/System.Drawing/gdiplus/image.c2
-rw-r--r--mcs/class/System.Drawing/gdiplus/matrix.c257
-rw-r--r--mcs/class/System.Drawing/gdiplus/pen.c457
-rw-r--r--mcs/class/System.Drawing/gdiplus/solidbrush.c47
-rw-r--r--mcs/class/System.Runtime.Remoting/ChangeLog15
-rw-r--r--mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels.Http/ChangeLog30
-rw-r--r--mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels.Http/HttpChannel.cs115
-rw-r--r--mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels.Http/HttpClientChannel.cs63
-rw-r--r--mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels.Http/HttpHelper.cs24
-rw-r--r--mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels.Http/HttpRemotingHandler.cs64
-rw-r--r--mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels.Http/HttpRemotingHandlerFactory.cs55
-rw-r--r--mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels.Http/HttpServer.cs146
-rw-r--r--mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels.Http/HttpServerChannel.cs178
-rw-r--r--mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels.Http/HttpThread.cs38
-rw-r--r--mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels.Tcp/ChangeLog19
-rw-r--r--mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels.Tcp/TcpChannel.cs19
-rw-r--r--mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels.Tcp/TcpClientChannel.cs9
-rw-r--r--mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels.Tcp/TcpConnectionPool.cs3
-rw-r--r--mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels.Tcp/TcpServerChannel.cs39
-rw-r--r--mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels.Tcp/TcpServerTransportSink.cs2
-rw-r--r--mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels/BinaryClientFormatterSink.cs38
-rw-r--r--mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels/BinaryClientFormatterSinkProvider.cs16
-rw-r--r--mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels/BinaryCore.cs107
-rw-r--r--mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels/BinaryServerFormatterSink.cs27
-rw-r--r--mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels/BinaryServerFormatterSinkProvider.cs19
-rw-r--r--mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels/ChangeLog37
-rw-r--r--mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels/ChannelCore.cs47
-rw-r--r--mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels/SoapClientFormatterSink.cs25
-rw-r--r--mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels/SoapClientFormatterSinkProvider.cs19
-rw-r--r--mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels/SoapCore.cs112
-rw-r--r--mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels/SoapServerFormatterSink.cs25
-rw-r--r--mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels/SoapServerFormatterSinkProvider.cs35
-rw-r--r--mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.dll.sources4
-rw-r--r--mcs/class/System.Runtime.Remoting/System.Runtime.Remoting_test.dll.sources1
-rw-r--r--mcs/class/System.Runtime.Remoting/Test/BaseCalls.cs6
-rw-r--r--mcs/class/System.Runtime.Remoting/Test/CallSeq.cs2
-rw-r--r--mcs/class/System.Runtime.Remoting/Test/ChangeLog7
-rw-r--r--mcs/class/System.Runtime.Remoting/Test/ContextsTest.cs15
-rw-r--r--mcs/class/System.Runtime.Remoting/Test/CrossDomainCalls.cs153
-rw-r--r--mcs/class/System.Runtime.Serialization.Formatters.Soap/ChangeLog6
-rw-r--r--mcs/class/System.Runtime.Serialization.Formatters.Soap/System.Runtime.Serialization.Formatters.Soap/ChangeLog13
-rw-r--r--mcs/class/System.Runtime.Serialization.Formatters.Soap/System.Runtime.Serialization.Formatters.Soap/ObjectWriter.cs3
-rwxr-xr-xmcs/class/System.Runtime.Serialization.Formatters.Soap/System.Runtime.Serialization.Formatters.Soap/SoapFormatter.cs29
-rw-r--r--mcs/class/System.Runtime.Serialization.Formatters.Soap/System.Runtime.Serialization.Formatters.Soap/SoapParser.cs1
-rwxr-xr-xmcs/class/System.Runtime.Serialization.Formatters.Soap/System.Runtime.Serialization.Formatters.Soap/SoapReader.cs2
-rw-r--r--mcs/class/System.Web.Services/System.Web.Services.Description/ChangeLog5
-rw-r--r--mcs/class/System.Web.Services/System.Web.Services.Description/ServiceDescription.cs1
-rw-r--r--mcs/class/System.Web.Services/System.Web.Services.Description/SoapBinding.cs2
-rw-r--r--mcs/class/System.Web.Services/System.Web.Services.Description/SoapHeaderBinding.cs5
-rw-r--r--mcs/class/System.Web.Services/System.Web.Services.Description/SoapHeaderFaultBinding.cs4
-rwxr-xr-xmcs/class/System.Web.Services/System.Web.Services.Discovery/ChangeLog4
-rw-r--r--mcs/class/System.Web.Services/System.Web.Services.Discovery/DiscoveryDocumentSerializer.cs4
-rw-r--r--mcs/class/System.Web.Services/System.Web.Services.Protocols/ChangeLog35
-rwxr-xr-xmcs/class/System.Web.Services/System.Web.Services.Protocols/HttpSoapWebServiceHandler.cs7
-rw-r--r--mcs/class/System.Web.Services/System.Web.Services.Protocols/Methods.cs5
-rw-r--r--mcs/class/System.Web.Services/System.Web.Services.Protocols/SoapDocumentationHandler.cs4
-rw-r--r--mcs/class/System.Web.Services/System.Web.Services.Protocols/SoapHttpClientProtocol.cs42
-rw-r--r--mcs/class/System.Web.Services/System.Web.Services.Protocols/SoapMessage.cs3
-rw-r--r--mcs/class/System.Web.Services/System.Web.Services.Protocols/TypeStubManager.cs3
-rwxr-xr-xmcs/class/System.Web.Services/System.Web.Services.Protocols/WebServiceHelper.cs36
-rw-r--r--mcs/class/System.Web/Assembly/AssemblyInfo.cs1
-rw-r--r--mcs/class/System.Web/Assembly/ChangeLog4
-rw-r--r--mcs/class/System.Web/ChangeLog34
-rw-r--r--mcs/class/System.Web/System.Web.Caching/Cache.cs34
-rw-r--r--mcs/class/System.Web/System.Web.Caching/CachedRawResponse.cs79
-rw-r--r--mcs/class/System.Web/System.Web.Caching/CachedVaryBy.cs53
-rw-r--r--mcs/class/System.Web/System.Web.Caching/ChangeLog29
-rw-r--r--mcs/class/System.Web/System.Web.Caching/OutputCacheModule.cs135
-rw-r--r--mcs/class/System.Web/System.Web.Compilation/ChangeLog13
-rw-r--r--mcs/class/System.Web/System.Web.Compilation/PageCompiler.cs20
-rw-r--r--mcs/class/System.Web/System.Web.Compilation/TemplateControlCompiler.cs47
-rw-r--r--mcs/class/System.Web/System.Web.Configuration/ChangeLog12
-rw-r--r--mcs/class/System.Web/System.Web.Configuration/CompilationConfiguration.cs2
-rw-r--r--mcs/class/System.Web/System.Web.Configuration/CompilationConfigurationHandler.cs12
-rw-r--r--mcs/class/System.Web/System.Web.Configuration/HttpRuntimeConfig.cs75
-rw-r--r--mcs/class/System.Web/System.Web.Configuration/HttpRuntimeConfigurationHandler.cs87
-rw-r--r--mcs/class/System.Web/System.Web.Mail/ChangeLog6
-rw-r--r--mcs/class/System.Web/System.Web.Mail/MailMessageWrapper.cs2
-rw-r--r--mcs/class/System.Web/System.Web.Security/ADMembershipProvider.cs145
-rw-r--r--mcs/class/System.Web/System.Web.Security/AccessMembershipProvider.cs145
-rw-r--r--mcs/class/System.Web/System.Web.Security/AccessRoleProvider.cs96
-rw-r--r--mcs/class/System.Web/System.Web.Security/AnonymousIdentificationEventArgs.cs31
-rw-r--r--mcs/class/System.Web/System.Web.Security/AnonymousIdentificationEventHandler.cs15
-rw-r--r--mcs/class/System.Web/System.Web.Security/AnonymousIdentificationModule.cs40
-rw-r--r--mcs/class/System.Web/System.Web.Security/ChangeLog30
-rw-r--r--mcs/class/System.Web/System.Web.Security/CookieProtection.cs20
-rw-r--r--mcs/class/System.Web/System.Web.Security/IMembershipProvider.cs34
-rw-r--r--mcs/class/System.Web/System.Web.Security/IRoleProvider.cs28
-rw-r--r--mcs/class/System.Web/System.Web.Security/Membership.cs128
-rw-r--r--mcs/class/System.Web/System.Web.Security/MembershipCreateStatus.cs26
-rw-r--r--mcs/class/System.Web/System.Web.Security/MembershipCreateUserException.cs26
-rw-r--r--mcs/class/System.Web/System.Web.Security/MembershipOnlineStatus.cs19
-rw-r--r--mcs/class/System.Web/System.Web.Security/MembershipPasswordException.cs19
-rw-r--r--mcs/class/System.Web/System.Web.Security/MembershipPasswordFormat.cs19
-rw-r--r--mcs/class/System.Web/System.Web.Security/MembershipProviderCollection.cs29
-rw-r--r--mcs/class/System.Web/System.Web.Security/MembershipSortOptions.cs22
-rw-r--r--mcs/class/System.Web/System.Web.Security/MembershipUser.cs141
-rw-r--r--mcs/class/System.Web/System.Web.Security/MembershipUserCollection.cs88
-rw-r--r--mcs/class/System.Web/System.Web.Security/RoleManagerEventArgs.cs35
-rw-r--r--mcs/class/System.Web/System.Web.Security/RoleManagerEventHandler.cs15
-rw-r--r--mcs/class/System.Web/System.Web.Security/RoleManagerModule.cs33
-rw-r--r--mcs/class/System.Web/System.Web.Security/RolePrincipal.cs121
-rw-r--r--mcs/class/System.Web/System.Web.Security/RoleProviderCollection.cs29
-rw-r--r--mcs/class/System.Web/System.Web.Security/Roles.cs184
-rw-r--r--mcs/class/System.Web/System.Web.Security/SqlMembershipProvider.cs145
-rw-r--r--mcs/class/System.Web/System.Web.Security/SqlRoleProvider.cs96
-rw-r--r--mcs/class/System.Web/System.Web.SessionState/ChangeLog36
-rw-r--r--mcs/class/System.Web/System.Web.SessionState/RemoteStateServer.cs54
-rw-r--r--mcs/class/System.Web/System.Web.SessionState/SessionDictionary.cs178
-rw-r--r--mcs/class/System.Web/System.Web.SessionState/SessionInProcHandler.cs10
-rw-r--r--mcs/class/System.Web/System.Web.SessionState/SessionSQLServerHandler.cs57
-rw-r--r--mcs/class/System.Web/System.Web.SessionState/SessionStateModule.cs2
-rw-r--r--mcs/class/System.Web/System.Web.SessionState/SessionStateServerHandler.cs130
-rw-r--r--mcs/class/System.Web/System.Web.SessionState/StateServerItem.cs52
-rw-r--r--mcs/class/System.Web/System.Web.UI.HtmlControls/ChangeLog10
-rwxr-xr-xmcs/class/System.Web/System.Web.UI.HtmlControls/HtmlInputFile.cs17
-rwxr-xr-xmcs/class/System.Web/System.Web.UI.HtmlControls/HtmlInputRadioButton.cs2
-rwxr-xr-xmcs/class/System.Web/System.Web.UI.HtmlControls/HtmlSelect.cs2
-rwxr-xr-xmcs/class/System.Web/System.Web.UI.WebControls/BaseDataList.cs32
-rwxr-xr-xmcs/class/System.Web/System.Web.UI.WebControls/Calendar.cs8
-rw-r--r--mcs/class/System.Web/System.Web.UI.WebControls/ChangeLog110
-rw-r--r--mcs/class/System.Web/System.Web.UI.WebControls/ControlParameter.cs91
-rw-r--r--mcs/class/System.Web/System.Web.UI.WebControls/CookieParameter.cs74
-rw-r--r--mcs/class/System.Web/System.Web.UI.WebControls/DataGrid.cs152
-rw-r--r--mcs/class/System.Web/System.Web.UI.WebControls/DataGridColumn.cs7
-rw-r--r--mcs/class/System.Web/System.Web.UI.WebControls/DataGridColumnCollection.cs14
-rw-r--r--mcs/class/System.Web/System.Web.UI.WebControls/FormParameter.cs68
-rwxr-xr-xmcs/class/System.Web/System.Web.UI.WebControls/HyperLink.cs5
-rw-r--r--mcs/class/System.Web/System.Web.UI.WebControls/ListItem.cs25
-rw-r--r--mcs/class/System.Web/System.Web.UI.WebControls/Parameter.cs240
-rw-r--r--mcs/class/System.Web/System.Web.UI.WebControls/ParameterCollection.cs199
-rw-r--r--mcs/class/System.Web/System.Web.UI.WebControls/QueryStringParameter.cs69
-rw-r--r--mcs/class/System.Web/System.Web.UI.WebControls/RadioButton.cs2
-rw-r--r--mcs/class/System.Web/System.Web.UI.WebControls/SessionParameter.cs68
-rw-r--r--mcs/class/System.Web/System.Web.UI.WebControls/SqlDataSource.cs228
-rw-r--r--mcs/class/System.Web/System.Web.UI.WebControls/SqlDataSourceCommandEventArgs.cs32
-rw-r--r--mcs/class/System.Web/System.Web.UI.WebControls/SqlDataSourceCommandEventHandler.cs15
-rw-r--r--mcs/class/System.Web/System.Web.UI.WebControls/SqlDataSourceMode.cs22
-rw-r--r--mcs/class/System.Web/System.Web.UI.WebControls/SqlDataSourceStatusEventArgs.cs42
-rw-r--r--mcs/class/System.Web/System.Web.UI.WebControls/SqlDataSourceStatusEventHandler.cs15
-rw-r--r--mcs/class/System.Web/System.Web.UI.WebControls/SqlDataSourceView.cs411
-rw-r--r--mcs/class/System.Web/System.Web.UI.WebControls/Style.cs2
-rw-r--r--mcs/class/System.Web/System.Web.UI.WebControls/ValidationSummary.cs8
-rwxr-xr-xmcs/class/System.Web/System.Web.UI.WebControls/WebControl.cs25
-rw-r--r--mcs/class/System.Web/System.Web.UI.WebControls/Xml.cs3
-rw-r--r--mcs/class/System.Web/System.Web.UI.WebControls/XmlBuilder.cs37
-rw-r--r--mcs/class/System.Web/System.Web.UI/ChangeLog69
-rw-r--r--mcs/class/System.Web/System.Web.UI/Control.cs45
-rwxr-xr-xmcs/class/System.Web/System.Web.UI/DataBinder.cs25
-rw-r--r--mcs/class/System.Web/System.Web.UI/KeyedList.cs194
-rw-r--r--mcs/class/System.Web/System.Web.UI/KeyedListEnumerator.cs67
-rw-r--r--mcs/class/System.Web/System.Web.UI/ObjectStateFormatter.cs774
-rw-r--r--mcs/class/System.Web/System.Web.UI/OutputCacheLocation.cs5
-rwxr-xr-xmcs/class/System.Web/System.Web.UI/Page.cs102
-rwxr-xr-xmcs/class/System.Web/System.Web.UI/PersistChildrenAttribute.cs20
-rwxr-xr-xmcs/class/System.Web/System.Web.UI/PersistenceModeAttribute.cs31
-rw-r--r--mcs/class/System.Web/System.Web.UI/StateManagedCollection.cs289
-rw-r--r--mcs/class/System.Web/System.Web.UI/TemplateControlParser.cs26
-rwxr-xr-xmcs/class/System.Web/System.Web.UI/TemplateParser.cs78
-rw-r--r--mcs/class/System.Web/System.Web.Util/AltSerialization.cs162
-rw-r--r--mcs/class/System.Web/System.Web.Util/ChangeLog17
-rw-r--r--mcs/class/System.Web/System.Web.Util/TimeUtil.cs24
-rw-r--r--mcs/class/System.Web/System.Web.Util/UrlUtils.cs35
-rwxr-xr-xmcs/class/System.Web/System.Web.dll.sources58
-rw-r--r--mcs/class/System.Web/System.Web/ChangeLog59
-rw-r--r--mcs/class/System.Web/System.Web/HttpApplication.cs41
-rw-r--r--mcs/class/System.Web/System.Web/HttpCachePolicy.cs47
-rw-r--r--mcs/class/System.Web/System.Web/HttpCacheVaryByParams.cs34
-rw-r--r--mcs/class/System.Web/System.Web/HttpCacheability.cs2
-rw-r--r--mcs/class/System.Web/System.Web/HttpClientCertificate.cs2
-rw-r--r--mcs/class/System.Web/System.Web/HttpContext.cs46
-rw-r--r--mcs/class/System.Web/System.Web/HttpModuleCollection.cs2
-rw-r--r--mcs/class/System.Web/System.Web/HttpResponse.cs73
-rw-r--r--mcs/class/System.Web/System.Web/HttpRuntime.cs83
-rw-r--r--mcs/class/System.Web/System.Web/HttpStaticObjectsCollection.cs69
-rw-r--r--mcs/class/System.Web/System.Web/HttpWriter.cs11
-rw-r--r--mcs/class/System.Web/System.Web/QueueManager.cs82
-rw-r--r--mcs/class/System.Web/System.Web/TimeoutManager.cs106
-rw-r--r--mcs/class/System.Windows.Forms/Gtk/AccessibleEvents.cs59
-rw-r--r--mcs/class/System.Windows.Forms/Gtk/AccessibleNavigation.cs31
-rw-r--r--mcs/class/System.Windows.Forms/Gtk/AccessibleObject.cs303
-rw-r--r--mcs/class/System.Windows.Forms/Gtk/AccessibleRole.cs81
-rw-r--r--mcs/class/System.Windows.Forms/Gtk/AccessibleSelection.cs29
-rw-r--r--mcs/class/System.Windows.Forms/Gtk/AccessibleStates.cs59
-rw-r--r--mcs/class/System.Windows.Forms/Gtk/BaseCollection.cs73
-rw-r--r--mcs/class/System.Windows.Forms/Gtk/Binding.cs104
-rw-r--r--mcs/class/System.Windows.Forms/Gtk/BindingManagerBase.cs112
-rw-r--r--mcs/class/System.Windows.Forms/Gtk/BindingMemberInfo.cs138
-rw-r--r--mcs/class/System.Windows.Forms/Gtk/BindingsCollection.cs120
-rw-r--r--mcs/class/System.Windows.Forms/Gtk/BorderStyle.cs20
-rw-r--r--mcs/class/System.Windows.Forms/Gtk/ChangeLog44
-rw-r--r--mcs/class/System.Windows.Forms/Gtk/Control.cs98
-rw-r--r--mcs/class/System.Windows.Forms/Gtk/ConvertEventArgs.cs53
-rw-r--r--mcs/class/System.Windows.Forms/Gtk/ConvertEventHandler.cs16
-rw-r--r--mcs/class/System.Windows.Forms/Gtk/CurrencyManager.cs175
-rw-r--r--mcs/class/System.Windows.Forms/Gtk/DataGrid.cs1248
-rw-r--r--mcs/class/System.Windows.Forms/Gtk/DataGridBoolColumn.cs175
-rw-r--r--mcs/class/System.Windows.Forms/Gtk/DataGridCell.cs132
-rw-r--r--mcs/class/System.Windows.Forms/Gtk/DataGridColumnStyle.cs254
-rw-r--r--mcs/class/System.Windows.Forms/Gtk/DataGridLineStyle.cs19
-rw-r--r--mcs/class/System.Windows.Forms/Gtk/DataGridParentRowsLabelStyle.cs26
-rw-r--r--mcs/class/System.Windows.Forms/Gtk/DataGridPreferredColumnWidthTypeConverter.cs59
-rw-r--r--mcs/class/System.Windows.Forms/Gtk/DataGridTableStyle.cs485
-rw-r--r--mcs/class/System.Windows.Forms/Gtk/DataGridTextBox.cs78
-rw-r--r--mcs/class/System.Windows.Forms/Gtk/DataGridTextBoxColumn.cs202
-rw-r--r--mcs/class/System.Windows.Forms/Gtk/Demo3.cs96
-rw-r--r--mcs/class/System.Windows.Forms/Gtk/GridColumnStylesCollection.cs178
-rw-r--r--mcs/class/System.Windows.Forms/Gtk/GridTableStylesCollection.cs162
-rw-r--r--mcs/class/System.Windows.Forms/Gtk/IDataGridColumnStyleEditingNotificationService.cs17
-rw-r--r--mcs/class/System.Windows.Forms/Gtk/IDataGridEditingService.cs24
-rw-r--r--mcs/class/System.Windows.Forms/Gtk/ItemChangedEventArgs.cs36
-rw-r--r--mcs/class/System.Windows.Forms/Gtk/ItemChangedEventHandler.cs16
-rw-r--r--mcs/class/System.Windows.Forms/Gtk/KeyEventArgs.cs111
-rw-r--r--mcs/class/System.Windows.Forms/Gtk/KeyEventHandler.cs16
-rw-r--r--mcs/class/System.Windows.Forms/Gtk/KeyPressEventArgs.cs55
-rw-r--r--mcs/class/System.Windows.Forms/Gtk/KeyPressEventHandler.cs16
-rw-r--r--mcs/class/System.Windows.Forms/Gtk/Keys.cs202
-rw-r--r--mcs/class/System.Windows.Forms/Gtk/Makefile52
-rw-r--r--mcs/class/System.Windows.Forms/Gtk/NavigateEventArgs.cs48
-rw-r--r--mcs/class/System.Windows.Forms/Gtk/NavigateEventHandler.cs18
-rw-r--r--mcs/class/System.Windows.Forms/Gtk/PaintEventArgs.cs67
-rw-r--r--mcs/class/System.Windows.Forms/Gtk/PaintEventHandler.cs18
-rw-r--r--mcs/class/System.Windows.Forms/System.Windows.Forms.Test/FolderBrowserDialogTest.cs41
-rw-r--r--mcs/class/System.Windows.Forms/System.Windows.Forms/ButtonBase.cs41
-rw-r--r--mcs/class/System.Windows.Forms/System.Windows.Forms/ButtonState.cs6
-rw-r--r--mcs/class/System.Windows.Forms/System.Windows.Forms/ChangeLog11
-rw-r--r--mcs/class/System.Windows.Forms/System.Windows.Forms/CheckBox.cs343
-rw-r--r--mcs/class/System.Windows.Forms/System.Windows.Forms/Control.cs6
-rw-r--r--mcs/class/System.Windows.Forms/System.Windows.Forms/ControlPaint.cs1679
-rw-r--r--mcs/class/System.Windows.Forms/System.Windows.Forms/FolderBrowserDialog.cs194
-rw-r--r--mcs/class/System.Windows.Forms/System.Windows.Forms/Form.cs13
-rw-r--r--mcs/class/System.Windows.Forms/System.Windows.Forms/InputLanguageChangedEventArgs.cs2
-rw-r--r--mcs/class/System.Windows.Forms/System.Windows.Forms/LinkLabel.cs4
-rw-r--r--mcs/class/System.Windows.Forms/System.Windows.Forms/TabControl.cs2
-rw-r--r--mcs/class/System.Windows.Forms/System.Windows.Forms/TabDrawMode.cs4
-rw-r--r--mcs/class/System.Windows.Forms/System.Windows.Forms/win32Enums.cs114
-rw-r--r--mcs/class/System.Windows.Forms/System.Windows.Forms/win32Interfaces.cs2
-rw-r--r--mcs/class/System.Windows.Forms/System.Windows.Forms/win32Structs.cs21
-rw-r--r--mcs/class/System.Windows.Forms/System.Windows.Forms/win32functions.cs16
-rw-r--r--mcs/class/System.XML/ChangeLog16
-rw-r--r--mcs/class/System.XML/Mono.Xml.XPath/ChangeLog11
-rw-r--r--mcs/class/System.XML/Mono.Xml.XPath/IdPattern.cs15
-rw-r--r--mcs/class/System.XML/Mono.Xml.XPath/KeyPattern.cs27
-rw-r--r--mcs/class/System.XML/Mono.Xml.XPath/Pattern.cs14
-rw-r--r--mcs/class/System.XML/Mono.Xml.Xsl.Operations/ChangeLog20
-rw-r--r--mcs/class/System.XML/Mono.Xml.Xsl.Operations/XslAttribute.cs21
-rw-r--r--mcs/class/System.XML/Mono.Xml.Xsl.Operations/XslCopy.cs26
-rw-r--r--mcs/class/System.XML/Mono.Xml.Xsl.Operations/XslCopyOf.cs3
-rw-r--r--mcs/class/System.XML/Mono.Xml.Xsl.Operations/XslElement.cs26
-rw-r--r--mcs/class/System.XML/Mono.Xml.Xsl.Operations/XslLiteralElement.cs24
-rw-r--r--mcs/class/System.XML/Mono.Xml.Xsl.Operations/XslNumber.cs9
-rw-r--r--mcs/class/System.XML/Mono.Xml.Xsl/ChangeLog72
-rw-r--r--mcs/class/System.XML/Mono.Xml.Xsl/Compiler.cs62
-rw-r--r--mcs/class/System.XML/Mono.Xml.Xsl/Emitter.cs3
-rw-r--r--mcs/class/System.XML/Mono.Xml.Xsl/GenericOutputter.cs53
-rw-r--r--mcs/class/System.XML/Mono.Xml.Xsl/HtmlEmitter.cs320
-rw-r--r--mcs/class/System.XML/Mono.Xml.Xsl/MSXslScriptManager.cs23
-rw-r--r--mcs/class/System.XML/Mono.Xml.Xsl/Outputter.cs5
-rw-r--r--mcs/class/System.XML/Mono.Xml.Xsl/TextEmitter.cs4
-rw-r--r--mcs/class/System.XML/Mono.Xml.Xsl/TextOutputter.cs4
-rw-r--r--mcs/class/System.XML/Mono.Xml.Xsl/XmlWriterEmitter.cs5
-rw-r--r--mcs/class/System.XML/Mono.Xml.Xsl/XslDecimalFormat.cs33
-rw-r--r--mcs/class/System.XML/Mono.Xml.Xsl/XslOutput.cs16
-rw-r--r--mcs/class/System.XML/Mono.Xml.Xsl/XslStylesheet.cs308
-rw-r--r--mcs/class/System.XML/Mono.Xml.Xsl/XslTransformProcessor.cs77
-rw-r--r--mcs/class/System.XML/Mono.Xml.Xsl/XsltCompiledContext.cs80
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/ChangeLog5
-rw-r--r--mcs/class/System.XML/System.Xml.Schema/XmlSchemaBuiltInType.cs62
-rw-r--r--mcs/class/System.XML/System.Xml.Schema/XmlSchemaSet.cs120
-rwxr-xr-xmcs/class/System.XML/System.Xml.Serialization/ChangeLog22
-rw-r--r--mcs/class/System.XML/System.Xml.Serialization/XmlReflectionImporter.cs1
-rw-r--r--mcs/class/System.XML/System.Xml.Serialization/XmlSerializationReader.cs4
-rw-r--r--mcs/class/System.XML/System.Xml.Serialization/XmlSerializationWriter.cs4
-rw-r--r--mcs/class/System.XML/System.Xml.Serialization/XmlSerializationWriterInterpreter.cs3
-rw-r--r--mcs/class/System.XML/System.Xml.Serialization/XmlSerializer.cs1
-rw-r--r--mcs/class/System.XML/System.Xml.XPath/ChangeLog60
-rw-r--r--mcs/class/System.XML/System.Xml.XPath/DefaultContext.cs11
-rw-r--r--mcs/class/System.XML/System.Xml.XPath/Expression.cs43
-rw-r--r--mcs/class/System.XML/System.Xml.XPath/Iterator.cs367
-rw-r--r--mcs/class/System.XML/System.Xml.XPath/Parser.jay2
-rw-r--r--mcs/class/System.XML/System.Xml.XPath/XPathComparer.cs69
-rw-r--r--mcs/class/System.XML/System.Xml.XPath/XPathNavigator.cs5
-rw-r--r--mcs/class/System.XML/System.Xml.Xsl/ChangeLog10
-rw-r--r--mcs/class/System.XML/System.Xml.Xsl/ManagedXslTransform.cs14
-rwxr-xr-xmcs/class/System.XML/System.Xml.dll.sources31
-rw-r--r--mcs/class/System.XML/System.Xml/AsyncXmlTextWriter.cs42
-rw-r--r--mcs/class/System.XML/System.Xml/ChangeLog62
-rw-r--r--mcs/class/System.XML/System.Xml/DTDValidatingReader.cs2
-rw-r--r--mcs/class/System.XML/System.Xml/IXPathChangeNavigator.cs27
-rw-r--r--mcs/class/System.XML/System.Xml/IXPathEditor.cs28
-rw-r--r--mcs/class/System.XML/System.Xml/IXPathNavigator.cs61
-rw-r--r--mcs/class/System.XML/System.Xml/IXmlDataEvidence.cs20
-rw-r--r--mcs/class/System.XML/System.Xml/IXmlNamespaceResolver.cs32
-rw-r--r--mcs/class/System.XML/System.Xml/UpdateEventHandler.cs15
-rw-r--r--mcs/class/System.XML/System.Xml/XPathChangeNavigator.cs35
-rw-r--r--mcs/class/System.XML/System.Xml/XPathDocument2.cs205
-rw-r--r--mcs/class/System.XML/System.Xml/XPathDocument2ChangedEventAction.cs23
-rw-r--r--mcs/class/System.XML/System.Xml/XPathDocument2ChangedEventHandler.cs15
-rw-r--r--mcs/class/System.XML/System.Xml/XPathEditor.cs76
-rw-r--r--mcs/class/System.XML/System.Xml/XPathNavigator2.cs644
-rw-r--r--mcs/class/System.XML/System.Xml/XmlAttribute.cs2
-rw-r--r--mcs/class/System.XML/System.Xml/XmlChangeFilters.cs19
-rw-r--r--mcs/class/System.XML/System.Xml/XmlInfoItemType.cs23
-rw-r--r--mcs/class/System.XML/System.Xml/XmlNamespaceScope.cs21
-rw-r--r--mcs/class/System.XML/System.Xml/XmlNode.cs3
-rw-r--r--mcs/class/System.XML/System.Xml/XmlNodeChangeType.cs19
-rw-r--r--mcs/class/System.XML/System.Xml/XmlQualifiedNameTable.cs53
-rw-r--r--mcs/class/System.XML/System.Xml/XmlQueryDialect.cs17
-rw-r--r--mcs/class/System.XML/System.Xml/XmlTextReader.cs3
-rw-r--r--mcs/class/System.XML/System.Xml/XmlTextWriter.cs25
-rw-r--r--mcs/class/System.XML/System.Xml/XmlUpdateEventArgs.cs28
-rw-r--r--mcs/class/System.XML/System.Xml/XmlWriter.cs8
-rw-r--r--mcs/class/System.XML/Test/System.Xml/ChangeLog14
-rw-r--r--mcs/class/System.XML/Test/System.Xml/XmlAttributeTests.cs12
-rw-r--r--mcs/class/System.XML/Test/System.Xml/XmlElementTests.cs13
-rw-r--r--mcs/class/System.XML/Test/System.Xml/XmlNodeTests.cs79
-rw-r--r--mcs/class/System.XML/Test/System.Xml/XmlTextReaderTests.cs59
-rw-r--r--mcs/class/System.XML/Test/System.Xml/XmlTextWriterTests.cs55
-rw-r--r--mcs/class/System.XML/Test/System.Xml/XmlUrlResolverTests.cs14
-rw-r--r--mcs/class/System.XML/Test/System.Xml/XmlWriterTests.cs19
-rw-r--r--mcs/class/System/Assembly/AssemblyInfo.cs1
-rw-r--r--mcs/class/System/Assembly/ChangeLog4
-rw-r--r--mcs/class/System/ChangeLog8
-rw-r--r--mcs/class/System/Microsoft.CSharp/CSharpCodeCompiler.cs2
-rw-r--r--mcs/class/System/Microsoft.CSharp/ChangeLog5
-rw-r--r--mcs/class/System/Microsoft.VisualBasic/ChangeLog18
-rw-r--r--mcs/class/System/Microsoft.VisualBasic/VBCodeCompiler.cs485
-rw-r--r--mcs/class/System/Microsoft.VisualBasic/VBCodeGenerator.cs2394
-rw-r--r--mcs/class/System/Microsoft.Win32/ChangeLog62
-rw-r--r--mcs/class/System/Microsoft.Win32/TimerElapsedEventArgs.cs64
-rwxr-xr-xmcs/class/System/System.CodeDom.Compiler/ChangeLog8
-rwxr-xr-xmcs/class/System/System.CodeDom.Compiler/CodeGenerator.cs10
-rwxr-xr-xmcs/class/System/System.Collections.Specialized/ChangeLog4
-rw-r--r--mcs/class/System/System.Collections.Specialized/IOrderedDictionary.cs23
-rw-r--r--mcs/class/System/System.ComponentModel/ChangeLog14
-rw-r--r--mcs/class/System/System.ComponentModel/ComponentResourceManager.cs42
-rw-r--r--mcs/class/System/System.ComponentModel/IComponent.cs1
-rw-r--r--mcs/class/System/System.ComponentModel/PropertyDescriptorCollection.cs3
-rw-r--r--mcs/class/System/System.ComponentModel/PropertyTabAttribute.cs2
-rw-r--r--mcs/class/System/System.Configuration/ChangeLog7
-rw-r--r--mcs/class/System/System.Configuration/ConfigurationSettings.cs8
-rw-r--r--mcs/class/System/System.Diagnostics/ChangeLog67
-rw-r--r--mcs/class/System/System.Diagnostics/ICollectData.cs13
-rw-r--r--mcs/class/System/System.Net/ChangeLog34
-rw-r--r--mcs/class/System/System.Net/HttpWebRequest.cs10
-rw-r--r--mcs/class/System/System.Net/SecurityProtocolType.cs20
-rw-r--r--mcs/class/System/System.Net/WebConnection.cs87
-rw-r--r--mcs/class/System/System.Net/WebConnectionData.cs2
-rw-r--r--mcs/class/System/System.Net/WebConnectionGroup.cs23
-rw-r--r--mcs/class/System/System.Net/WebConnectionStream.cs61
-rwxr-xr-xmcs/class/System/System.Net/WebExceptionStatus.cs79
-rw-r--r--mcs/class/System/System.Text.RegularExpressions/ChangeLog20
-rw-r--r--mcs/class/System/System.Text.RegularExpressions/RegexTest.cs28
-rw-r--r--mcs/class/System/System.Text.RegularExpressions/interpreter.cs1
-rw-r--r--mcs/class/System/System.Text.RegularExpressions/quicksearch.cs25
-rw-r--r--mcs/class/System/System.Text.RegularExpressions/regex.cs9
-rw-r--r--mcs/class/System/System.Web/AspNetHostingPermission.cs82
-rw-r--r--mcs/class/System/System.Web/AspNetHostingPermissionAttribute.cs40
-rw-r--r--mcs/class/System/System.Web/AspNetHostingPermissionLevel.cs23
-rw-r--r--mcs/class/System/System.Web/ChangeLog14
-rwxr-xr-xmcs/class/System/System.dll.sources6
-rwxr-xr-xmcs/class/System/System/Uri.cs13
-rw-r--r--mcs/class/System/System_test.dll.sources2
-rw-r--r--mcs/class/System/Test/Microsoft.CSharp/ChangeLog5
-rw-r--r--mcs/class/System/Test/Microsoft.CSharp/CodeGeneratorFromCompileUnitTest.cs2
-rw-r--r--mcs/class/System/Test/System.Text.RegularExpressions/ChangeLog4
-rw-r--r--mcs/class/System/Test/System.Text.RegularExpressions/RegexBugs.cs67
-rw-r--r--mcs/class/System/Test/System.Text.RegularExpressions/RegexTest.cs28
-rw-r--r--mcs/class/System/Test/System/UriTest.cs1309
-rw-r--r--mcs/class/corlib/Assembly/AssemblyInfo.cs8
-rw-r--r--mcs/class/corlib/Assembly/ChangeLog4
-rw-r--r--mcs/class/corlib/ChangeLog59
-rw-r--r--mcs/class/corlib/Makefile3
-rw-r--r--mcs/class/corlib/Microsoft.Win32/RegistryKey.cs4
-rw-r--r--mcs/class/corlib/Mono.Math/BigInteger.cs4
-rw-r--r--mcs/class/corlib/Mono.Math/ChangeLog4
-rw-r--r--mcs/class/corlib/System.Collections.Generic/ICollection.cs4
-rw-r--r--mcs/class/corlib/System.Collections.Generic/IComparable.cs4
-rw-r--r--mcs/class/corlib/System.Collections.Generic/IComparer.cs4
-rw-r--r--mcs/class/corlib/System.Collections.Generic/IEnumerable.cs4
-rw-r--r--mcs/class/corlib/System.Collections.Generic/IEnumerator.cs4
-rw-r--r--mcs/class/corlib/System.Collections.Generic/IKeyComparer.cs4
-rw-r--r--mcs/class/corlib/System.Collections.Generic/IList.cs4
-rw-r--r--mcs/class/corlib/System.Collections.Generic/KeyValuePair.cs4
-rw-r--r--mcs/class/corlib/System.Collections/CaseInsensitiveComparer.cs22
-rw-r--r--mcs/class/corlib/System.Collections/ChangeLog8
-rw-r--r--mcs/class/corlib/System.Collections/IEnumerator.cs18
-rwxr-xr-xmcs/class/corlib/System.Configuration.Assemblies/ProcessorID.cs5
-rw-r--r--mcs/class/corlib/System.Diagnostics/StackFrame.cs5
-rw-r--r--mcs/class/corlib/System.Diagnostics/StackTrace.cs8
-rw-r--r--mcs/class/corlib/System.Globalization/CalendricalCalculations.cs4
-rw-r--r--mcs/class/corlib/System.Globalization/CultureInfo.cs12
-rw-r--r--mcs/class/corlib/System.Globalization/HebrewCalendar.cs14
-rw-r--r--mcs/class/corlib/System.Globalization/HijriCalendar.cs11
-rw-r--r--mcs/class/corlib/System.Globalization/JapaneseCalendar.cs6
-rw-r--r--mcs/class/corlib/System.Globalization/TaiwanCalendar.cs7
-rwxr-xr-xmcs/class/corlib/System.Globalization/TextInfo.cs2
-rw-r--r--mcs/class/corlib/System.IO/ChangeLog59
-rw-r--r--mcs/class/corlib/System.IO/CheckArgument.cs2
-rw-r--r--mcs/class/corlib/System.IO/Directory.cs74
-rw-r--r--mcs/class/corlib/System.IO/DirectoryInfo.cs2
-rw-r--r--mcs/class/corlib/System.IO/FileStream.cs2
-rw-r--r--mcs/class/corlib/System.IO/MemoryStream.cs6
-rw-r--r--mcs/class/corlib/System.IO/MonoIO.cs2
-rw-r--r--mcs/class/corlib/System.IO/Path.cs2
-rw-r--r--mcs/class/corlib/System.IO/SearchPattern.cs4
-rw-r--r--mcs/class/corlib/System.IO/StreamReader.cs6
-rw-r--r--mcs/class/corlib/System.IO/StreamWriter.cs2
-rw-r--r--mcs/class/corlib/System.IO/StringReader.cs67
-rw-r--r--mcs/class/corlib/System.IO/TextReader.cs3
-rwxr-xr-xmcs/class/corlib/System.Reflection.Emit/AssemblyBuilder.cs45
-rw-r--r--mcs/class/corlib/System.Reflection.Emit/AssemblyBuilderAccess.cs1
-rw-r--r--mcs/class/corlib/System.Reflection.Emit/ChangeLog51
-rw-r--r--mcs/class/corlib/System.Reflection.Emit/ConstructorBuilder.cs8
-rw-r--r--mcs/class/corlib/System.Reflection.Emit/DynamicMethod.cs315
-rwxr-xr-xmcs/class/corlib/System.Reflection.Emit/EnumBuilder.cs2
-rwxr-xr-xmcs/class/corlib/System.Reflection.Emit/FieldBuilder.cs6
-rw-r--r--mcs/class/corlib/System.Reflection.Emit/ILGenerator.cs45
-rwxr-xr-xmcs/class/corlib/System.Reflection.Emit/LocalBuilder.cs8
-rwxr-xr-xmcs/class/corlib/System.Reflection.Emit/MethodBuilder.cs18
-rw-r--r--mcs/class/corlib/System.Reflection.Emit/ModuleBuilder.cs33
-rwxr-xr-xmcs/class/corlib/System.Reflection.Emit/MonoArrayMethod.cs2
-rw-r--r--mcs/class/corlib/System.Reflection.Emit/OpCodes.cs17
-rw-r--r--mcs/class/corlib/System.Reflection.Emit/PackingSize.cs1
-rw-r--r--mcs/class/corlib/System.Reflection.Emit/StringToken.cs4
-rw-r--r--mcs/class/corlib/System.Reflection.Emit/TypeBuilder.cs110
-rw-r--r--mcs/class/corlib/System.Reflection/Assembly.cs20
-rwxr-xr-xmcs/class/corlib/System.Reflection/AssemblyName.cs17
-rwxr-xr-xmcs/class/corlib/System.Reflection/AssemblyNameFlags.cs4
-rw-r--r--mcs/class/corlib/System.Reflection/Binder.cs2
-rw-r--r--mcs/class/corlib/System.Reflection/ChangeLog49
-rw-r--r--mcs/class/corlib/System.Reflection/ConstructorInfo.cs3
-rwxr-xr-xmcs/class/corlib/System.Reflection/EventAttributes.cs1
-rwxr-xr-xmcs/class/corlib/System.Reflection/EventInfo.cs3
-rwxr-xr-xmcs/class/corlib/System.Reflection/FieldAttributes.cs1
-rwxr-xr-xmcs/class/corlib/System.Reflection/FieldInfo.cs5
-rwxr-xr-xmcs/class/corlib/System.Reflection/IReflect.cs3
-rwxr-xr-xmcs/class/corlib/System.Reflection/MemberInfo.cs5
-rwxr-xr-xmcs/class/corlib/System.Reflection/MemberTypes.cs1
-rwxr-xr-xmcs/class/corlib/System.Reflection/MethodAttributes.cs7
-rw-r--r--mcs/class/corlib/System.Reflection/MethodBase.cs5
-rwxr-xr-xmcs/class/corlib/System.Reflection/MethodImplAttributes.cs1
-rw-r--r--mcs/class/corlib/System.Reflection/MethodInfo.cs4
-rw-r--r--mcs/class/corlib/System.Reflection/MonoGenericInst.cs6
-rwxr-xr-xmcs/class/corlib/System.Reflection/MonoMethod.cs28
-rwxr-xr-xmcs/class/corlib/System.Reflection/PropertyInfo.cs2
-rwxr-xr-xmcs/class/corlib/System.Reflection/TypeDelegator.cs2
-rw-r--r--mcs/class/corlib/System.Reflection/common.src25
-rw-r--r--mcs/class/corlib/System.Resources/ChangeLog8
-rw-r--r--mcs/class/corlib/System.Resources/ResourceSet.cs27
-rw-r--r--mcs/class/corlib/System.Runtime.CompilerServices/ChangeLog7
-rw-r--r--mcs/class/corlib/System.Runtime.CompilerServices/MethodCodeType.cs2
-rw-r--r--mcs/class/corlib/System.Runtime.CompilerServices/MethodImplOptions.cs1
-rw-r--r--mcs/class/corlib/System.Runtime.CompilerServices/RuntimeHelpers.cs2
-rw-r--r--mcs/class/corlib/System.Runtime.InteropServices.Expando/Changelog4
-rw-r--r--mcs/class/corlib/System.Runtime.InteropServices.Expando/IExpando.cs2
-rw-r--r--mcs/class/corlib/System.Runtime.InteropServices/ArrayWithOffset.cs49
-rw-r--r--mcs/class/corlib/System.Runtime.InteropServices/BestFitMappingAttribute.cs31
-rw-r--r--mcs/class/corlib/System.Runtime.InteropServices/COMException.cs6
-rw-r--r--mcs/class/corlib/System.Runtime.InteropServices/ChangeLog45
-rw-r--r--mcs/class/corlib/System.Runtime.InteropServices/CurrencyWrapper.cs32
-rw-r--r--mcs/class/corlib/System.Runtime.InteropServices/DispatchWrapper.cs26
-rwxr-xr-xmcs/class/corlib/System.Runtime.InteropServices/DllImportAttribute.cs10
-rw-r--r--mcs/class/corlib/System.Runtime.InteropServices/ErrorWrapper.cs37
-rw-r--r--mcs/class/corlib/System.Runtime.InteropServices/ExtensibleClassFactory.cs22
-rwxr-xr-xmcs/class/corlib/System.Runtime.InteropServices/IRegistrationServices.cs2
-rw-r--r--mcs/class/corlib/System.Runtime.InteropServices/ITypeLibConverter.cs2
-rwxr-xr-xmcs/class/corlib/System.Runtime.InteropServices/ITypeLibExporterNameProvider.cs2
-rw-r--r--mcs/class/corlib/System.Runtime.InteropServices/ITypeLibExporterNotifySink.cs2
-rwxr-xr-xmcs/class/corlib/System.Runtime.InteropServices/ITypeLibImporterNotifySink.cs2
-rw-r--r--mcs/class/corlib/System.Runtime.InteropServices/Marshal.cs37
-rwxr-xr-xmcs/class/corlib/System.Runtime.InteropServices/MarshalAsAttribute.cs8
-rw-r--r--mcs/class/corlib/System.Runtime.InteropServices/ObjectCreationDelegate.cs14
-rw-r--r--mcs/class/corlib/System.Runtime.InteropServices/RegistrationServices.cs69
-rw-r--r--mcs/class/corlib/System.Runtime.InteropServices/TypeLibConverter.cs46
-rw-r--r--mcs/class/corlib/System.Runtime.InteropServices/UCOMIBindCtx.cs9
-rw-r--r--mcs/class/corlib/System.Runtime.InteropServices/UCOMIConnectionPoint.cs9
-rw-r--r--mcs/class/corlib/System.Runtime.InteropServices/UCOMIConnectionPointContainer.cs5
-rw-r--r--mcs/class/corlib/System.Runtime.InteropServices/UCOMIEnumConnectionPoints.cs5
-rw-r--r--mcs/class/corlib/System.Runtime.InteropServices/UCOMIEnumConnections.cs5
-rw-r--r--mcs/class/corlib/System.Runtime.InteropServices/UCOMIEnumMoniker.cs5
-rw-r--r--mcs/class/corlib/System.Runtime.InteropServices/UCOMIEnumString.cs5
-rw-r--r--mcs/class/corlib/System.Runtime.InteropServices/UCOMIEnumVARIANT.cs1
-rw-r--r--mcs/class/corlib/System.Runtime.InteropServices/UCOMIMoniker.cs31
-rw-r--r--mcs/class/corlib/System.Runtime.InteropServices/UCOMIPersistFile.cs5
-rw-r--r--mcs/class/corlib/System.Runtime.InteropServices/UCOMIRunningObjectTable.cs9
-rw-r--r--mcs/class/corlib/System.Runtime.InteropServices/UCOMIStream.cs8
-rw-r--r--mcs/class/corlib/System.Runtime.InteropServices/UCOMITypeComp.cs4
-rw-r--r--mcs/class/corlib/System.Runtime.InteropServices/UCOMITypeInfo.cs8
-rw-r--r--mcs/class/corlib/System.Runtime.InteropServices/UCOMITypeLib.cs7
-rw-r--r--mcs/class/corlib/System.Runtime.Remoting.Channels/AggregateDictionary.cs189
-rw-r--r--mcs/class/corlib/System.Runtime.Remoting.Channels/ChangeLog25
-rw-r--r--mcs/class/corlib/System.Runtime.Remoting.Channels/ChannelServices.cs304
-rw-r--r--mcs/class/corlib/System.Runtime.Remoting.Channels/ClientChannelSinkStack.cs7
-rwxr-xr-xmcs/class/corlib/System.Runtime.Remoting.Channels/CrossAppDomainChannel.cs25
-rw-r--r--mcs/class/corlib/System.Runtime.Remoting.Channels/ServerDispatchSink.cs7
-rw-r--r--mcs/class/corlib/System.Runtime.Remoting.Channels/ServerDispatchSinkProvider.cs7
-rw-r--r--mcs/class/corlib/System.Runtime.Remoting.Channels/SinkProviderData.cs13
-rw-r--r--mcs/class/corlib/System.Runtime.Remoting.Contexts/ChangeLog19
-rw-r--r--mcs/class/corlib/System.Runtime.Remoting.Contexts/Context.cs117
-rw-r--r--mcs/class/corlib/System.Runtime.Remoting.Contexts/ContextProperty.cs15
-rw-r--r--mcs/class/corlib/System.Runtime.Remoting.Contexts/SynchronizationAttribute.cs284
-rw-r--r--mcs/class/corlib/System.Runtime.Remoting.Messaging/ArgInfo.cs4
-rw-r--r--mcs/class/corlib/System.Runtime.Remoting.Messaging/AsyncResult.cs4
-rwxr-xr-xmcs/class/corlib/System.Runtime.Remoting.Messaging/CADMessages.cs28
-rw-r--r--mcs/class/corlib/System.Runtime.Remoting.Messaging/CallContext.cs4
-rw-r--r--mcs/class/corlib/System.Runtime.Remoting.Messaging/ChangeLog43
-rw-r--r--mcs/class/corlib/System.Runtime.Remoting.Messaging/ClientContextTerminatorSink.cs2
-rw-r--r--mcs/class/corlib/System.Runtime.Remoting.Messaging/ConstructionCall.cs8
-rw-r--r--mcs/class/corlib/System.Runtime.Remoting.Messaging/ConstructionResponse.cs15
-rwxr-xr-xmcs/class/corlib/System.Runtime.Remoting.Messaging/ErrorMessage.cs2
-rw-r--r--mcs/class/corlib/System.Runtime.Remoting.Messaging/ISerializationRootObject.cs19
-rw-r--r--mcs/class/corlib/System.Runtime.Remoting.Messaging/LogicalCallContext.cs5
-rw-r--r--mcs/class/corlib/System.Runtime.Remoting.Messaging/MethodCall.cs11
-rw-r--r--mcs/class/corlib/System.Runtime.Remoting.Messaging/MethodResponse.cs7
-rw-r--r--mcs/class/corlib/System.Runtime.Remoting.Messaging/MethodReturnMessageWrapper.cs18
-rw-r--r--mcs/class/corlib/System.Runtime.Remoting.Messaging/MonoMethodMessage.cs2
-rw-r--r--mcs/class/corlib/System.Runtime.Remoting.Messaging/ReturnMessage.cs5
-rw-r--r--mcs/class/corlib/System.Runtime.Remoting.Messaging/ServerContextTerminatorSink.cs2
-rw-r--r--mcs/class/corlib/System.Runtime.Remoting.Messaging/StackBuilderSink.cs20
-rw-r--r--mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/ChangeLog19
-rw-r--r--mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapAnyUri.cs39
-rw-r--r--mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapBase64Binary.cs39
-rw-r--r--mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapDate.cs72
-rw-r--r--mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapDateTime.cs48
-rw-r--r--mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapDay.cs49
-rw-r--r--mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapDuration.cs125
-rw-r--r--mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapEntities.cs39
-rw-r--r--mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapEntity.cs39
-rw-r--r--mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapHelper.cs27
-rw-r--r--mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapHexBinary.cs66
-rw-r--r--mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapId.cs37
-rw-r--r--mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapIdref.cs37
-rw-r--r--mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapIdrefs.cs37
-rw-r--r--mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapInteger.cs39
-rw-r--r--mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapLanguage.cs39
-rw-r--r--mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapMonth.cs47
-rw-r--r--mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapMonthDay.cs47
-rw-r--r--mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapName.cs39
-rw-r--r--mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapNcName.cs37
-rw-r--r--mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapNegativeInteger.cs40
-rw-r--r--mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapNmtoken.cs37
-rw-r--r--mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapNmtokens.cs37
-rw-r--r--mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapNonNegativeInteger.cs39
-rw-r--r--mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapNonPositiveInteger.cs39
-rw-r--r--mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapNormalizedString.cs37
-rw-r--r--mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapNotation.cs37
-rw-r--r--mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapPositiveInteger.cs37
-rw-r--r--mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapQName.cs76
-rw-r--r--mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapTime.cs70
-rw-r--r--mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapToken.cs41
-rw-r--r--mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapYear.cs74
-rw-r--r--mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapYearMonth.cs72
-rw-r--r--mcs/class/corlib/System.Runtime.Remoting.Metadata/ChangeLog11
-rw-r--r--mcs/class/corlib/System.Runtime.Remoting.Metadata/SoapAttribute.cs28
-rw-r--r--mcs/class/corlib/System.Runtime.Remoting.Metadata/SoapFieldAttribute.cs27
-rw-r--r--mcs/class/corlib/System.Runtime.Remoting.Metadata/SoapMethodAttribute.cs61
-rw-r--r--mcs/class/corlib/System.Runtime.Remoting.Metadata/SoapTypeAttribute.cs78
-rw-r--r--mcs/class/corlib/System.Runtime.Remoting.Proxies/ChangeLog15
-rw-r--r--mcs/class/corlib/System.Runtime.Remoting.Proxies/RealProxy.cs32
-rw-r--r--mcs/class/corlib/System.Runtime.Remoting.Proxies/RemotingProxy.cs13
-rw-r--r--mcs/class/corlib/System.Runtime.Remoting.Services/ChangeLog4
-rw-r--r--mcs/class/corlib/System.Runtime.Remoting.Services/EnterpriseServicesHelper.cs39
-rw-r--r--mcs/class/corlib/System.Runtime.Remoting/ActivatedClientTypeEntry.cs6
-rw-r--r--mcs/class/corlib/System.Runtime.Remoting/ActivatedServiceTypeEntry.cs3
-rwxr-xr-xmcs/class/corlib/System.Runtime.Remoting/ChangeLog65
-rw-r--r--mcs/class/corlib/System.Runtime.Remoting/IObjectHandle.cs4
-rw-r--r--mcs/class/corlib/System.Runtime.Remoting/IRemotingTypeInfo.cs45
-rw-r--r--mcs/class/corlib/System.Runtime.Remoting/InternalRemotingServices.cs95
-rw-r--r--mcs/class/corlib/System.Runtime.Remoting/ObjectHandle.cs2
-rw-r--r--mcs/class/corlib/System.Runtime.Remoting/RemotingConfiguration.cs676
-rw-r--r--mcs/class/corlib/System.Runtime.Remoting/RemotingServices.cs13
-rw-r--r--mcs/class/corlib/System.Runtime.Remoting/ServerIdentity.cs6
-rw-r--r--mcs/class/corlib/System.Runtime.Remoting/SoapServices.cs260
-rw-r--r--mcs/class/corlib/System.Runtime.Remoting/TypeInfo.cs4
-rw-r--r--mcs/class/corlib/System.Runtime.Remoting/WellKnownClientTypeEntry.cs3
-rw-r--r--mcs/class/corlib/System.Runtime.Remoting/WellKnownServiceTypeEntry.cs5
-rwxr-xr-xmcs/class/corlib/System.Runtime.Serialization.Formatters.Binary/BinaryFormatter.cs44
-rwxr-xr-xmcs/class/corlib/System.Runtime.Serialization.Formatters.Binary/ChangeLog20
-rw-r--r--mcs/class/corlib/System.Runtime.Serialization.Formatters.Binary/MessageFormatter.cs16
-rw-r--r--mcs/class/corlib/System.Runtime.Serialization.Formatters.Binary/ObjectReader.cs36
-rw-r--r--mcs/class/corlib/System.Runtime.Serialization.Formatters.Binary/ObjectWriter.cs15
-rw-r--r--mcs/class/corlib/System.Runtime.Serialization.Formatters/ChangeLog8
-rwxr-xr-xmcs/class/corlib/System.Runtime.Serialization.Formatters/FormatterTopObjectStyle.cs5
-rwxr-xr-xmcs/class/corlib/System.Runtime.Serialization.Formatters/InternalArrayTypeE.cs6
-rwxr-xr-xmcs/class/corlib/System.Runtime.Serialization.Formatters/InternalElementTypeE.cs5
-rwxr-xr-xmcs/class/corlib/System.Runtime.Serialization.Formatters/InternalMemberTypeE.cs4
-rwxr-xr-xmcs/class/corlib/System.Runtime.Serialization.Formatters/InternalMemberValueE.cs4
-rwxr-xr-xmcs/class/corlib/System.Runtime.Serialization.Formatters/InternalNameSpaceE.cs4
-rwxr-xr-xmcs/class/corlib/System.Runtime.Serialization.Formatters/InternalObjectPositionE.cs4
-rwxr-xr-xmcs/class/corlib/System.Runtime.Serialization.Formatters/InternalObjectTypeE.cs4
-rwxr-xr-xmcs/class/corlib/System.Runtime.Serialization.Formatters/InternalParseStateE.cs4
-rwxr-xr-xmcs/class/corlib/System.Runtime.Serialization.Formatters/InternalParseTypeE.cs5
-rwxr-xr-xmcs/class/corlib/System.Runtime.Serialization.Formatters/InternalPrimitiveTypeE.cs4
-rw-r--r--mcs/class/corlib/System.Runtime.Serialization.Formatters/InternalRM.cs19
-rw-r--r--mcs/class/corlib/System.Runtime.Serialization.Formatters/InternalST.cs19
-rwxr-xr-xmcs/class/corlib/System.Runtime.Serialization.Formatters/InternalSerializerTypeE.cs5
-rw-r--r--mcs/class/corlib/System.Runtime.Serialization.Formatters/ServerFault.cs6
-rw-r--r--mcs/class/corlib/System.Runtime.Serialization.Formatters/SoapFault.cs6
-rw-r--r--mcs/class/corlib/System.Runtime.Serialization.Formatters/TypeFilterLevel.cs21
-rw-r--r--mcs/class/corlib/System.Runtime.Serialization/ChangeLog14
-rwxr-xr-xmcs/class/corlib/System.Runtime.Serialization/Formatter.cs71
-rw-r--r--mcs/class/corlib/System.Runtime.Serialization/FormatterServices.cs38
-rw-r--r--mcs/class/corlib/System.Runtime.Serialization/ObjectManager.cs4
-rw-r--r--mcs/class/corlib/System.Security.Cryptography/ChangeLog12
-rwxr-xr-xmcs/class/corlib/System.Security.Cryptography/ProtectedData.cs19
-rwxr-xr-xmcs/class/corlib/System.Security.Cryptography/ProtectedMemory.cs18
-rwxr-xr-xmcs/class/corlib/System.Security.Cryptography/Rfc2898DeriveBytes.cs33
-rwxr-xr-xmcs/class/corlib/System.Security.Cryptography/SymmetricAlgorithm.cs8
-rw-r--r--mcs/class/corlib/System.Security.Permissions/IsolatedStoragePermissionAttribute.cs5
-rw-r--r--mcs/class/corlib/System.Security.Permissions/RegistryPermissionAttribute.cs1
-rwxr-xr-xmcs/class/corlib/System.Text/ASCIIEncoding.cs60
-rwxr-xr-xmcs/class/corlib/System.Text/ChangeLog15
-rwxr-xr-xmcs/class/corlib/System.Text/Encoding.cs33
-rw-r--r--mcs/class/corlib/System.Text/StringBuilder.cs20
-rwxr-xr-xmcs/class/corlib/System.Text/UTF7Encoding.cs73
-rwxr-xr-xmcs/class/corlib/System.Text/UTF8Encoding.cs89
-rwxr-xr-xmcs/class/corlib/System.Text/UnicodeEncoding.cs99
-rw-r--r--mcs/class/corlib/System.Threading/ChangeLog4
-rwxr-xr-xmcs/class/corlib/System.Threading/Thread.cs92
-rw-r--r--mcs/class/corlib/System/Activator.cs10
-rwxr-xr-xmcs/class/corlib/System/AppDomain.cs18
-rwxr-xr-xmcs/class/corlib/System/AppDomainSetup.cs29
-rw-r--r--mcs/class/corlib/System/Array.cs85
-rw-r--r--mcs/class/corlib/System/BadImageFormatException.cs5
-rw-r--r--mcs/class/corlib/System/Boolean.cs6
-rw-r--r--mcs/class/corlib/System/ChangeLog130
-rw-r--r--mcs/class/corlib/System/Console.cs26
-rw-r--r--mcs/class/corlib/System/DateTime.cs11
-rw-r--r--mcs/class/corlib/System/Decimal.cs82
-rw-r--r--mcs/class/corlib/System/Delegate.cs15
-rw-r--r--mcs/class/corlib/System/Double.cs3
-rw-r--r--mcs/class/corlib/System/Enum.cs8
-rw-r--r--mcs/class/corlib/System/Environment.cs12
-rw-r--r--mcs/class/corlib/System/Exception.cs11
-rw-r--r--mcs/class/corlib/System/FloatingPointFormatter.cs3
-rw-r--r--mcs/class/corlib/System/IAppDomainSetup.cs6
-rw-r--r--mcs/class/corlib/System/IServiceProvider.cs5
-rw-r--r--mcs/class/corlib/System/IntPtr.cs3
-rw-r--r--mcs/class/corlib/System/MonoType.cs34
-rw-r--r--mcs/class/corlib/System/MulticastDelegate.cs2
-rw-r--r--mcs/class/corlib/System/Object.cs2
-rw-r--r--mcs/class/corlib/System/OperatingSystem.cs30
-rw-r--r--mcs/class/corlib/System/PlatformID.cs15
-rwxr-xr-xmcs/class/corlib/System/RuntimeMethodHandle.cs2
-rw-r--r--mcs/class/corlib/System/String.cs28
-rw-r--r--mcs/class/corlib/System/Type.cs6
-rw-r--r--mcs/class/corlib/System/TypeInitializationException.cs6
-rw-r--r--mcs/class/corlib/System/ValueType.cs57
-rwxr-xr-xmcs/class/corlib/System/_AppDomain.cs3
-rw-r--r--mcs/class/corlib/Test/ChangeLog5
-rw-r--r--mcs/class/corlib/Test/System.IO/ChangeLog4
-rw-r--r--mcs/class/corlib/Test/System.IO/StringReaderTest.cs14
-rw-r--r--mcs/class/corlib/Test/System.Reflection.Emit/ChangeLog5
-rw-r--r--mcs/class/corlib/Test/System.Reflection.Emit/ConstructorBuilderTest.cs6
-rw-r--r--mcs/class/corlib/Test/System.Reflection/ChangeLog9
-rw-r--r--mcs/class/corlib/Test/System.Reflection/ModuleTest.cs14
-rw-r--r--mcs/class/corlib/Test/System.Runtime.Remoting/ChangeLog8
-rw-r--r--mcs/class/corlib/Test/System.Runtime.Remoting/ContextTest.cs112
-rw-r--r--mcs/class/corlib/Test/System.Runtime.Remoting/SoapServicesTest.cs230
-rwxr-xr-xmcs/class/corlib/Test/System.Runtime.Remoting/SynchronizationAttributeTest.cs308
-rw-r--r--mcs/class/corlib/Test/System.Security.Cryptography.X509Certificates/ChangeLog10
-rwxr-xr-xmcs/class/corlib/Test/System.Security.Cryptography.X509Certificates/X509SpcTest.cs1
-rw-r--r--mcs/class/corlib/Test/System.Security.Cryptography/ChangeLog10
-rwxr-xr-xmcs/class/corlib/Test/System.Security.Cryptography/ProtectedDataTest.cs109
-rwxr-xr-xmcs/class/corlib/Test/System.Security.Cryptography/ProtectedMemoryTest.cs112
-rwxr-xr-xmcs/class/corlib/Test/System.Security.Cryptography/Rfc2898DeriveBytesTest.cs45
-rw-r--r--mcs/class/corlib/Test/System/ArrayTest.cs6
-rw-r--r--mcs/class/corlib/Test/System/ChangeLog19
-rwxr-xr-xmcs/class/corlib/Test/System/DateTimeTest.cs20
-rw-r--r--mcs/class/corlib/Test/System/FloatingPointFormatterTest.cs6
-rw-r--r--mcs/class/corlib/Test/System/ValueTypeTest.cs71
-rw-r--r--mcs/class/corlib/Test/corlib_linux_test.args158
-rwxr-xr-xmcs/class/corlib/Test/corlib_test.args171
-rwxr-xr-xmcs/class/corlib/Unix/Errno.cs145
-rwxr-xr-xmcs/class/corlib/corlib.dll.sources22
-rwxr-xr-xmcs/class/corlib/corlib_test.dll.sources6
-rwxr-xr-xmcs/docs/compiler5
-rw-r--r--mcs/errors/ChangeLog4
-rw-r--r--mcs/errors/Makefile8
-rw-r--r--mcs/errors/cs0035.cs27
-rw-r--r--mcs/errors/cs0052.cs9
-rw-r--r--mcs/errors/cs0065.cs14
-rw-r--r--mcs/errors/cs0103.cs9
-rw-r--r--mcs/errors/cs0123.cs14
-rw-r--r--mcs/errors/cs0134.cs11
-rw-r--r--mcs/errors/cs0135.cs14
-rw-r--r--mcs/errors/cs0145.cs7
-rw-r--r--mcs/errors/cs0149.cs10
-rw-r--r--mcs/errors/cs0158.cs13
-rw-r--r--mcs/errors/cs0160.cs11
-rw-r--r--mcs/errors/cs0173.cs31
-rw-r--r--mcs/errors/cs0175-2.cs9
-rw-r--r--mcs/errors/cs0175.cs12
-rw-r--r--mcs/errors/cs0177.cs11
-rw-r--r--mcs/errors/cs0186.cs11
-rw-r--r--mcs/errors/cs0188.cs14
-rwxr-xr-xmcs/errors/cs0193.cs3
-rwxr-xr-xmcs/errors/cs0196.cs4
-rw-r--r--mcs/errors/cs0199.cs19
-rw-r--r--mcs/errors/cs0208-2.cs3
-rw-r--r--mcs/errors/cs0208.cs3
-rw-r--r--mcs/errors/cs0209.cs4
-rw-r--r--mcs/errors/cs0210.cs13
-rw-r--r--mcs/errors/cs0211.cs11
-rw-r--r--mcs/errors/cs0212.cs4
-rw-r--r--mcs/errors/cs0213.cs16
-rwxr-xr-xmcs/errors/cs0214-2.cs2
-rwxr-xr-xmcs/errors/cs0214-3.cs2
-rw-r--r--mcs/errors/cs0214.cs4
-rw-r--r--mcs/errors/cs0217.cs26
-rw-r--r--mcs/errors/cs0218.cs26
-rw-r--r--mcs/errors/cs0220.cs11
-rw-r--r--mcs/errors/cs0227.cs8
-rw-r--r--mcs/errors/cs0231.cs7
-rw-r--r--mcs/errors/cs0233.cs11
-rw-r--r--mcs/errors/cs0238.cs13
-rw-r--r--mcs/errors/cs0241.cs8
-rwxr-xr-xmcs/errors/cs0242.cs4
-rw-r--r--mcs/errors/cs0243.cs13
-rw-r--r--mcs/errors/cs0244.cs11
-rw-r--r--mcs/errors/cs0245.cs9
-rw-r--r--mcs/errors/cs0247.cs11
-rw-r--r--mcs/errors/cs0248.cs10
-rw-r--r--mcs/errors/cs0249.cs7
-rw-r--r--mcs/errors/cs0250.cs12
-rwxr-xr-xmcs/errors/cs0255.cs4
-rw-r--r--mcs/errors/cs0502.cs6
-rw-r--r--mcs/errors/cs0504.cs9
-rw-r--r--mcs/errors/cs0505.cs11
-rw-r--r--mcs/errors/cs0506.cs11
-rw-r--r--mcs/errors/cs0507.cs11
-rw-r--r--mcs/errors/cs0508.cs11
-rw-r--r--mcs/errors/cs0516.cs9
-rw-r--r--mcs/errors/cs0522.cs7
-rw-r--r--mcs/errors/cs0524.cs10
-rw-r--r--mcs/errors/cs0525.cs9
-rw-r--r--mcs/errors/cs0526.cs10
-rw-r--r--mcs/errors/cs0531.cs10
-rw-r--r--mcs/errors/cs0533.cs11
-rw-r--r--mcs/errors/cs0535.cs11
-rw-r--r--mcs/errors/cs0537.cs10
-rw-r--r--mcs/errors/cs0538.cs14
-rw-r--r--mcs/errors/cs0541.cs10
-rw-r--r--mcs/errors/cs0544.cs11
-rw-r--r--mcs/errors/cs0545.cs11
-rw-r--r--mcs/errors/cs0546.cs11
-rw-r--r--mcs/errors/cs0547.cs9
-rw-r--r--mcs/errors/cs0548.cs9
-rw-r--r--mcs/errors/cs0549.cs9
-rw-r--r--mcs/errors/cs0550.cs17
-rw-r--r--mcs/errors/cs0551.cs16
-rw-r--r--mcs/errors/cs0553.cs12
-rw-r--r--mcs/errors/cs0554.cs12
-rw-r--r--mcs/errors/cs0557.cs12
-rw-r--r--mcs/errors/cs0558.cs8
-rw-r--r--mcs/errors/cs0559.cs8
-rw-r--r--mcs/errors/cs0560.cs28
-rw-r--r--mcs/errors/cs0561.cs16
-rw-r--r--mcs/errors/cs0562.cs8
-rw-r--r--mcs/errors/cs0564.cs8
-rw-r--r--mcs/errors/cs0567.cs8
-rw-r--r--mcs/errors/cs0571.cs14
-rw-r--r--mcs/errors/cs0576.cs10
-rw-r--r--mcs/errors/cs0577.cs9
-rw-r--r--mcs/errors/cs0578.cs11
-rw-r--r--mcs/errors/cs0580.cs14
-rw-r--r--mcs/errors/cs0582.cs8
-rw-r--r--mcs/errors/cs0590.cs8
-rw-r--r--mcs/errors/cs0591.cs10
-rw-r--r--mcs/errors/cs0609.cs23
-rw-r--r--mcs/errors/cs0610-2.cs13
-rw-r--r--mcs/errors/cs0610.cs9
-rw-r--r--mcs/errors/cs0611-2.cs13
-rw-r--r--mcs/errors/cs0611.cs9
-rw-r--r--mcs/errors/cs0619.cs20
-rw-r--r--mcs/errors/cs0676-2.cs2
-rw-r--r--mcs/errors/cs0676.cs2
-rw-r--r--mcs/errors/cs1900.cs8
-rw-r--r--mcs/errors/cs1901.cs8
-rw-r--r--mcs/errors/cs1904.cs8
-rw-r--r--mcs/errors/cs2001.cs3
-rw-r--r--mcs/errors/cs2007.cs3
-rw-r--r--mcs/errors/cs2016.cs3
-rw-r--r--mcs/errors/cs2017.cs8
-rw-r--r--mcs/errors/cs2019.cs8
-rw-r--r--mcs/errors/cs8200.cs12
-rw-r--r--mcs/errors/cs8212.cs26
-rw-r--r--mcs/errors/cs8213.cs6
-rwxr-xr-xmcs/gmcs/ChangeLog41
-rwxr-xr-xmcs/gmcs/codegen.cs11
-rwxr-xr-xmcs/gmcs/decl.cs2
-rwxr-xr-xmcs/gmcs/ecore.cs9
-rwxr-xr-xmcs/gmcs/expression.cs8
-rw-r--r--mcs/gmcs/generic.cs25
-rwxr-xr-xmcs/gmcs/interface.cs10
-rwxr-xr-xmcs/gmcs/typemanager.cs43
-rw-r--r--mcs/ilasm/ChangeLog10
-rw-r--r--mcs/ilasm/Driver.cs7
-rw-r--r--mcs/ilasm/codegen/ChangeLog9
-rw-r--r--mcs/ilasm/codegen/LdstrInstr.cs13
-rw-r--r--mcs/ilasm/codegen/MethodDef.cs10
-rw-r--r--mcs/ilasm/parser/ChangeLog14
-rw-r--r--mcs/ilasm/parser/ILParser.jay34
-rw-r--r--mcs/mbas/AssemblyInfo.cs2
-rw-r--r--mcs/mbas/ChangeLog18
-rw-r--r--mcs/mbas/Makefile4
-rw-r--r--mcs/mbas/argument.cs4
-rw-r--r--mcs/mbas/assign.cs6
-rw-r--r--mcs/mbas/attribute.cs2
-rw-r--r--mcs/mbas/cfold.cs2
-rw-r--r--mcs/mbas/class.cs42
-rw-r--r--mcs/mbas/codegen.cs2
-rw-r--r--mcs/mbas/const.cs4
-rw-r--r--mcs/mbas/constant.cs4
-rw-r--r--mcs/mbas/decl.cs2
-rw-r--r--mcs/mbas/defaultparserattribute.cs3
-rw-r--r--mcs/mbas/delegate.cs10
-rw-r--r--mcs/mbas/driver.cs17
-rw-r--r--mcs/mbas/ecore.cs14
-rw-r--r--mcs/mbas/enum.cs12
-rw-r--r--mcs/mbas/expression.cs52
-rw-r--r--mcs/mbas/genericparser.cs2
-rw-r--r--mcs/mbas/interface.cs4
-rw-r--r--mcs/mbas/literal.cs14
-rw-r--r--mcs/mbas/location.cs5
-rw-r--r--mcs/mbas/mb-parser.jay36
-rw-r--r--mcs/mbas/mb-tokenizer.cs215
-rw-r--r--mcs/mbas/modifiers.cs2
-rw-r--r--mcs/mbas/module.cs6
-rw-r--r--mcs/mbas/namespace.cs2
-rw-r--r--mcs/mbas/parameter.cs5
-rw-r--r--mcs/mbas/pending.cs2
-rw-r--r--mcs/mbas/report.cs2
-rw-r--r--mcs/mbas/rootcontext.cs4
-rw-r--r--mcs/mbas/statement.cs10
-rw-r--r--mcs/mbas/statementCollection.cs2
-rw-r--r--mcs/mbas/support.cs6
-rw-r--r--mcs/mbas/testmbas/WriteOK.vb24
-rw-r--r--mcs/mbas/tree.cs2
-rw-r--r--mcs/mbas/typemanager.cs14
-rwxr-xr-xmcs/mcs/ChangeLog125
-rwxr-xr-xmcs/mcs/assign.cs2
-rw-r--r--mcs/mcs/attribute.cs17
-rwxr-xr-xmcs/mcs/cfold.cs27
-rwxr-xr-xmcs/mcs/class.cs8
-rwxr-xr-xmcs/mcs/codegen.cs10
-rw-r--r--mcs/mcs/convert.cs20
-rwxr-xr-xmcs/mcs/cs-parser.jay92
-rwxr-xr-xmcs/mcs/cs-tokenizer.cs20
-rwxr-xr-xmcs/mcs/decl.cs8
-rw-r--r--mcs/mcs/delegate.cs1
-rwxr-xr-xmcs/mcs/driver.cs76
-rwxr-xr-xmcs/mcs/ecore.cs2
-rwxr-xr-xmcs/mcs/expression.cs66
-rw-r--r--mcs/mcs/flowanalysis.cs5
-rwxr-xr-xmcs/mcs/gen-treedump.cs2
-rwxr-xr-xmcs/mcs/rootcontext.cs2
-rwxr-xr-xmcs/mcs/statement.cs58
-rwxr-xr-xmcs/mcs/support.cs6
-rwxr-xr-xmcs/mcs/typemanager.cs45
-rwxr-xr-xmcs/tests/ChangeLog4
-rw-r--r--mcs/tests/Makefile16
-rw-r--r--mcs/tests/README.tests10
-rwxr-xr-xmcs/tests/gen-30.cs32
-rw-r--r--mcs/tests/gen-31-dll.cs11
-rw-r--r--mcs/tests/gen-31-exe.cs11
-rw-r--r--mcs/tests/gen-32.cs21
-rw-r--r--mcs/tests/gen-33.cs21
-rw-r--r--mcs/tests/gen-34.cs14
-rwxr-xr-xmcs/tests/gen-test.pl4
-rw-r--r--mcs/tests/test-150.cs7
-rw-r--r--mcs/tests/test-219.cs27
-rw-r--r--mcs/tests/test-220.cs124
-rw-r--r--mcs/tests/verify-5.cs14
-rw-r--r--mcs/tests/verify-6.cs4
-rw-r--r--mcs/tools/SqlSharp/gui/gtk-sharp/ChangeLog7
-rwxr-xr-xmcs/tools/SqlSharp/gui/gtk-sharp/LoginDialog.cs4
-rwxr-xr-xmcs/tools/SqlSharp/gui/gtk-sharp/SqlEditorSharp.cs9
-rwxr-xr-xmcs/tools/SqlSharp/gui/gtk-sharp/sqlsharpgtk.cs1
-rw-r--r--mcs/tools/corcompare/ChangeLog71
-rw-r--r--mcs/tools/corcompare/CorCompare.exe.sources15
-rw-r--r--mcs/tools/corcompare/Makefile57
-rw-r--r--mcs/tools/corcompare/mono-api-diff.cs1220
-rw-r--r--mcs/tools/corcompare/mono-api-info.cs725
-rw-r--r--mcs/tools/corcompare/mono-api.xsl493
-rw-r--r--mcs/tools/gacutil/ChangeLog37
-rw-r--r--mcs/tools/gacutil/Makefile8
-rw-r--r--mcs/tools/gacutil/README9
-rw-r--r--mcs/tools/gacutil/TODO5
-rw-r--r--mcs/tools/gacutil/gacutil.cs403
-rw-r--r--mcs/tools/gacutil/gacutil.exe.sources1
-rw-r--r--mcs/tools/security/ChangeLog10
-rw-r--r--mcs/tools/security/sn.cs4
-rw-r--r--mono/arch/ChangeLog5
-rw-r--r--mono/arch/ppc/ppc-codegen.h59
-rw-r--r--mono/benchmark/Makefile.am3
-rw-r--r--mono/benchmark/valuetype-hash-equals.cs75
-rw-r--r--mono/dis/ChangeLog15
-rw-r--r--mono/dis/dump.c33
-rw-r--r--mono/dis/dump.h1
-rw-r--r--mono/dis/get.c6
-rw-r--r--mono/dis/main.c10
-rw-r--r--mono/dis/util.h1
-rw-r--r--mono/interpreter/ChangeLog4
-rw-r--r--mono/interpreter/interp.c14
-rw-r--r--mono/io-layer/ChangeLog11
-rw-r--r--mono/io-layer/io.c43
-rw-r--r--mono/metadata/ChangeLog295
-rw-r--r--mono/metadata/appdomain.c180
-rw-r--r--mono/metadata/appdomain.h14
-rw-r--r--mono/metadata/assembly.c101
-rw-r--r--mono/metadata/assembly.h6
-rw-r--r--mono/metadata/class.c75
-rw-r--r--mono/metadata/class.h4
-rw-r--r--mono/metadata/debug-helpers.c17
-rw-r--r--mono/metadata/debug-helpers.h2
-rw-r--r--mono/metadata/debug-mono-symfile.c1
-rw-r--r--mono/metadata/domain.c12
-rw-r--r--mono/metadata/exception.c16
-rw-r--r--mono/metadata/exception.h8
-rw-r--r--mono/metadata/gc.c15
-rw-r--r--mono/metadata/icall.c352
-rw-r--r--mono/metadata/image.c38
-rw-r--r--mono/metadata/image.h3
-rw-r--r--mono/metadata/loader.c10
-rw-r--r--mono/metadata/loader.h1
-rw-r--r--mono/metadata/locales.c10
-rw-r--r--mono/metadata/locales.h1
-rw-r--r--mono/metadata/metadata.c20
-rw-r--r--mono/metadata/mono-debug.c6
-rw-r--r--mono/metadata/object.c111
-rw-r--r--mono/metadata/object.h3
-rw-r--r--mono/metadata/reflection.c390
-rw-r--r--mono/metadata/reflection.h31
-rw-r--r--mono/metadata/threads.c246
-rw-r--r--mono/metadata/threads.h19
-rw-r--r--mono/metadata/verify.c1
-rw-r--r--mono/mini/ChangeLog144
-rw-r--r--mono/mini/aot.c14
-rw-r--r--mono/mini/arrays.cs2
-rw-r--r--mono/mini/cpu-g4.md57
-rw-r--r--mono/mini/exceptions-ppc.c12
-rw-r--r--mono/mini/exceptions-x86.c56
-rw-r--r--mono/mini/iltests.il69
-rw-r--r--mono/mini/inssel-float.brg4
-rw-r--r--mono/mini/inssel-long32.brg88
-rw-r--r--mono/mini/inssel-ppc.brg93
-rw-r--r--mono/mini/inssel-x86.brg10
-rw-r--r--mono/mini/inssel.brg48
-rw-r--r--mono/mini/jit-icalls.c52
-rw-r--r--mono/mini/mini-ops.h1
-rw-r--r--mono/mini/mini-ppc.c852
-rw-r--r--mono/mini/mini-ppc.h21
-rw-r--r--mono/mini/mini-sparc.c61
-rw-r--r--mono/mini/mini-x86.c66
-rw-r--r--mono/mini/mini-x86.h2
-rw-r--r--mono/mini/mini.c120
-rw-r--r--mono/mini/mini.h20
-rw-r--r--mono/mini/tramp-ppc.c31
-rw-r--r--mono/mini/tramp-x86.c33
-rw-r--r--mono/monoburg/monoburg.19
-rw-r--r--mono/monoburg/monoburg.c5
-rw-r--r--mono/monoburg/monoburg.h1
-rw-r--r--mono/monoburg/monoburg.y87
-rw-r--r--mono/monograph/ChangeLog4
-rw-r--r--mono/monograph/monograph.c2
-rw-r--r--mono/profiler/ChangeLog3
-rw-r--r--mono/profiler/mono-cov.c2
-rw-r--r--mono/tests/ChangeLog10
-rw-r--r--mono/tests/Makefile.am1
-rw-r--r--mono/tests/cattr-object.cs2
-rw-r--r--mono/tests/context-static.cs36
-rw-r--r--mono/utils/ChangeLog9
-rw-r--r--mono/utils/Makefile.am4
-rw-r--r--mono/utils/mono-math.c22
-rw-r--r--mono/utils/mono-math.h20
-rw-r--r--mono/utils/strenc.c21
-rw-r--r--runtime/Makefile.am7
-rw-r--r--scripts/.cvsignore4
-rw-r--r--web/Makefile.am6
-rw-r--r--web/anoncvs5
-rw-r--r--web/blogs4
-rw-r--r--web/class-status.in12
-rw-r--r--web/drawing43
-rw-r--r--web/index28
-rw-r--r--web/jit-debug30
-rw-r--r--web/mono-roadmap.html2
-rwxr-xr-xweb/plans2
-rw-r--r--web/runtime2
-rwxr-xr-xweb/sqlite2
-rw-r--r--web/web/commands2
-rw-r--r--web/web/infos/.cvsignore1
-rw-r--r--web/web/makefile48
-rw-r--r--web/web/masterinfos/.cvsignore1
-rw-r--r--web/web/team.xml10
-rw-r--r--web/web/team/jackson.pngbin4423 -> 4626 bytes
-rw-r--r--web/winforms8
1645 files changed, 100271 insertions, 12105 deletions
diff --git a/ChangeLog b/ChangeLog
index 264fedaa5d3..989e7ab8b6d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,36 @@
+2003-11-26 Zoltan Varga <vargaz@freemail.hu>
+
+ * configure.in: Add -fno-strict-aliasing to CFLAGS.
+
+ * configure.in: Applied patch from recht@netbsd.org. Avoid linking in
+ librt if not neccesary.
+
+2003-11-24 Zoltan Varga <vargaz@freemail.hu>
+
+ * configure.in: Fix signbit check. Fixes #51315.
+
+2003-11-20 Jackson Harper <jackson@ximian.com>
+
+ * data/machine.config: Add OutputCacheModule
+
+2003-11-19 Jackson Harper <jackson@ximian.com>
+
+ * doc/web/team.xml: New email address and job description
+ * doc/web/team/jackson.png: Picture of me debugging...seems appropriate
+
+2003-11-14 Jackson Harper <jackson@ximian.com>
+
+ * Makefile.am: delete mscorlib.dll
+
+2003-11-12 Jackson Harper <jackson@ximian.com>
+
+ * Makefile.am: corlib is now named mscorlib.dll
+
+2003-11-12 Zoltan Varga <vargaz@freemail.hu>
+
+ * configure.in acconfig.h: Add check for signbit, which is missing in
+ FreeBSD 4.x.
+
2003-11-07 Zoltan Varga <vargaz@freemail.hu>
* configure.in: Remove debugging junk accidently checked in.
diff --git a/Makefile.am b/Makefile.am
index 69a7952023b..cbf133b8338 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -22,7 +22,7 @@ mcs-tree-safe-build:
(cd ../mcs/jay; $(MAKE))
(cd ../mcs/mcs; $(MAKE) MCS=mcs)
(cd ../mcs/class/corlib; $(MAKE) MCS=mcs)
- cp ../mcs/class/lib/corlib.dll runtime
+ cp ../mcs/class/lib/mscorlib.dll runtime
cp ../mcs/mcs/mcs.exe runtime
xinstall-runtime:
@@ -33,7 +33,7 @@ mcs-rest:
(cd ../mcs/class; $(MAKE))
remove-binaries:
- rm ../mcs/class/lib/corlib.dll ../mcs/mcs/mcs.exe runtime/*dll runtime/*.exe >& /dev/null; echo
+ rm ../mcs/class/lib/mscorlib.dll ../mcs/mcs/mcs.exe runtime/*dll runtime/*.exe >& /dev/null; echo
win32getdeps:
diff --git a/acconfig.h b/acconfig.h
index 2ed16243b47..e54d4eeea44 100644
--- a/acconfig.h
+++ b/acconfig.h
@@ -29,3 +29,4 @@
#undef HAVE_GETHOSTBYNAME2_R
#undef HAVE_ICU
#undef HAVE_KW_THREAD
+#undef HAVE_SIGNBIT
diff --git a/configure.in b/configure.in
index 7c7cf2d18a3..b3dd0121f13 100644
--- a/configure.in
+++ b/configure.in
@@ -1,7 +1,7 @@
AC_INIT(README)
AC_CANONICAL_SYSTEM
AM_CONFIG_HEADER(config.h)
-AM_INIT_AUTOMAKE(mono,0.28.99)
+AM_INIT_AUTOMAKE(mono,0.29)
AM_MAINTAINER_MODE
dnl
@@ -162,6 +162,8 @@ AC_CHECK_SIZEOF(void *, 4)
WARN=''
if test x"$GCC" = xyes; then
WARN='-Wall -Wunused -Wmissing-prototypes -Wmissing-declarations -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Wpointer-arith -Wno-cast-qual -Wcast-align -Wwrite-strings'
+ # The runtime code does not respect ANSI C strict aliasing rules
+ CFLAGS="$CFLAGS -fno-strict-aliasing"
else
# The Sun Forte compiler complains about inline functions that access static variables
# so disable all inlining.
@@ -599,7 +601,10 @@ if test x$platform_win32 = xno; then
dnl ********************************
dnl *** Checks for semaphore lib ***
dnl ********************************
- AC_CHECK_LIB(rt, sem_init, LIBS="$LIBS -lrt")
+ # 'Real Time' functions on Solaris
+ # posix4 on Solaris 2.6
+ # pthread (first!) on Linux
+ AC_SEARCH_LIBS(sem_init, pthread rt posix4)
dnl ********************************
dnl *** Checks for timezone stuff **
@@ -647,6 +652,19 @@ if test x$platform_win32 = xno; then
dnl *** have it in the library (duh)) ***
dnl ****************************************************************
AC_CHECK_FUNCS(poll)
+
+ dnl *************************
+ dnl *** Check for signbit ***
+ dnl *************************
+ AC_MSG_CHECKING(for signbit)
+ AC_TRY_LINK([#include <math.h>], [
+ int s = signbit(1.0);
+ ], [
+ AC_MSG_RESULT(yes)
+ AC_DEFINE(HAVE_SIGNBIT)
+ ], [
+ AC_MSG_RESULT(no)
+ ])
else
AC_CHECK_LIB(ws2_32, main, LIBS="$LIBS -lws2_32", AC_ERROR(bad mingw install?))
AC_CHECK_LIB(psapi, main, LIBS="$LIBS -lpsapi", AC_ERROR(bad mingw install?))
diff --git a/data/config.in b/data/config.in
index 9d9887bc196..24c7ec91003 100644
--- a/data/config.in
+++ b/data/config.in
@@ -16,4 +16,5 @@
<dllmap dll="libglade-2.0-0.dll" target="libglade-2.0.so" />
<dllmap dll="oci" target="clntsh" />
<dllmap dll="gtkhtml-3.0" target="libgtkhtml-3.0.so.2" />
+ <dllmap dll="db2cli" target="libdb2_36.so"/>
</configuration>
diff --git a/data/machine.config b/data/machine.config
index 489190c85c7..3617d8051a1 100644
--- a/data/machine.config
+++ b/data/machine.config
@@ -3,9 +3,9 @@
<configuration>
<configSections>
- <section name="appSettings" type="System.Configuration.NameValueFileSectionHandler, System" />
-
+ <section name="appSettings" type="System.Configuration.NameValueFileSectionHandler, System" />
<section name="system.diagnostics" type="System.Diagnostics.DiagnosticsConfigurationHandler, System" />
+ <section name="system.runtime.remoting" type="System.Configuration.IgnoreSectionHandler, System" allowLocation="false"/>
<sectionGroup name="system.web">
<section name="httpHandlers"
type="System.Web.Configuration.HttpHandlersSectionHandler, System.Web" />
@@ -27,6 +27,8 @@
type="System.Web.Configuration.WebControlsSectionHandler, System.Web" />
<section name="compilation"
type="System.Web.Configuration.CompilationConfigurationHandler, System.Web" />
+ <section name="httpRuntime"
+ type="System.Web.Configuration.HttpRuntimeConfigurationHandler, System.Web" />
</sectionGroup>
<sectionGroup name="system.net">
<section name="settings"
@@ -40,7 +42,7 @@
<section name="webRequestModules"
type="System.Net.Configuration.WebRequestModuleHandler, System" />
</sectionGroup>
- <section name="system.drawing" type="System.Configuration.NameValueSectionHandler" />
+ <section name="system.drawing" type="System.Configuration.NameValueSectionHandler" />
</configSections>
<system.net>
<connectionManagement>
@@ -74,6 +76,8 @@
<add verb="*" path="*.ascx" type="System.Web.HttpForbiddenHandler, System.Web" />
<add verb="*" path="*.config" type="System.Web.HttpForbiddenHandler, System.Web" />
<add verb="*" path="*.cs" type="System.Web.HttpForbiddenHandler, System.Web" />
+ <add verb="*" path="*.rem" type="System.Runtime.Remoting.Channels.Http.HttpRemotingHandlerFactory, System.Runtime.Remoting" validate="false" />
+ <add verb="*" path="*.soap" type="System.Runtime.Remoting.Channels.Http.HttpRemotingHandlerFactory, System.Runtime.Remoting" validate="false" />
<add verb="GET,HEAD" path="*" type="System.Web.StaticFileHandler, System.Web" />
<add verb="*" path="*" type="System.Web.HttpMethodNotAllowedHandler, System.Web" />
</httpHandlers>
@@ -81,6 +85,7 @@
<add name="FormsAuthentication" type="System.Web.Security.FormsAuthenticationModule, System.Web" />
<add name="UrlAuthorization" type="System.Web.Security.UrlAuthorizationModule, System.Web" />
<add name="Session" type="System.Web.SessionState.SessionStateModule, System.Web" />
+ <add name="OutputCache" type="System.Web.Caching.OutputCacheModule, System.Web" />
</httpModules>
<authentication mode="Forms">
<forms name=".MONOAUTH" loginUrl="login.aspx" protection="All" timeout="30" path="/">
@@ -127,9 +132,42 @@
<add assembly="*" /> <!-- Add assemblies in bin directory -->
</assemblies>
</compilation>
-
+ <httpRuntime executionTimeout="90"
+ maxRequestLength="4096"
+ useFullyQualifiedRedirectUrl="false"
+ minFreeThreads="8"
+ minLocalRequestFreeThreads="4"
+ appRequestQueueLimit="100" />
</system.web>
+ <system.runtime.remoting>
+ <application>
+ <channels>
+ <channel ref="http client" displayName="http client (delay loaded)" delayLoadAsClientChannel="true" />
+ <channel ref="tcp client" displayName="tcp client (delay loaded)" delayLoadAsClientChannel="true" />
+ </channels>
+ </application>
+ <channels>
+ <channel id="http" type="System.Runtime.Remoting.Channels.Http.HttpChannel, System.Runtime.Remoting" />
+ <channel id="http client" type="System.Runtime.Remoting.Channels.Http.HttpClientChannel, System.Runtime.Remoting" />
+ <channel id="http server" type="System.Runtime.Remoting.Channels.Http.HttpServerChannel, System.Runtime.Remoting" />
+ <channel id="tcp" type="System.Runtime.Remoting.Channels.Tcp.TcpChannel, System.Runtime.Remoting" />
+ <channel id="tcp client" type="System.Runtime.Remoting.Channels.Tcp.TcpClientChannel, System.Runtime.Remoting" />
+ <channel id="tcp server" type="System.Runtime.Remoting.Channels.Tcp.TcpServerChannel, System.Runtime.Remoting" />
+ </channels>
+ <channelSinkProviders>
+ <clientProviders>
+ <formatter id="soap" type="System.Runtime.Remoting.Channels.SoapClientFormatterSinkProvider, System.Runtime.Remoting" />
+ <formatter id="binary" type="System.Runtime.Remoting.Channels.BinaryClientFormatterSinkProvider, System.Runtime.Remoting" />
+ </clientProviders>
+ <serverProviders>
+ <formatter id="soap" type="System.Runtime.Remoting.Channels.SoapServerFormatterSinkProvider, System.Runtime.Remoting" />
+ <formatter id="binary" type="System.Runtime.Remoting.Channels.BinaryServerFormatterSinkProvider, System.Runtime.Remoting" />
+ <provider id="wsdl" type="System.Runtime.Remoting.MetadataServices.SdlChannelSinkProvider, System.Runtime.Remoting" />
+ </serverProviders>
+ </channelSinkProviders>
+ </system.runtime.remoting>
+
<appSettings>
<!--<add key="yourkey" value="your value" /> -->
<!--<remove key="a key defined higher in the hierarchy" /> -->
diff --git a/doc/Makefile.am b/doc/Makefile.am
index cc45aa4aac2..68e822f30f7 100644
--- a/doc/Makefile.am
+++ b/doc/Makefile.am
@@ -8,7 +8,7 @@ WEB_FILES= \
tds-providers status testing thanks tools \
porting anoncvs monodoc-xml winforms
-OTHERS= pending resources-pending todo mono-build.sh mono-build-w32.sh
+OTHERS= pending resources-pending todo mono-build.sh mono-build-w32.sh print-stack
EXTRA_DIST = $(WEB_FILES) README $(OTHERS)
@@ -17,8 +17,8 @@ all-docs: $(WEB_FILES)
runtime documentation download faq contributing \
resources status > all-docs
-class-status: class-status.in pending-classes Makefile.am
- cat class-status.in pending-classes > class-status
+class-status: class-status.in Makefile.am
+ cat class-status.in > class-status
pending-classes:
diff --git a/doc/anoncvs b/doc/anoncvs
index 2e72173b458..c52d510fc53 100644
--- a/doc/anoncvs
+++ b/doc/anoncvs
@@ -2,7 +2,7 @@
Anonymous access to the Mono is available currently from three
servers (anoncvs-spain-1.go-mono.com,
- anoncvs-spain-2.go-mono.com and anoncvs-us-1.go-mono.com).
+ anoncvs-spain-2.go-mono.com and us-anoncvs.go-mono.com).
You can also use `anoncvs.go-mono.com', and that will pick a
server automatically for you.
@@ -43,6 +43,9 @@
Special thanks to Jesus Climent, Rodrigo Moya, Juantomás
García and Ismael Olea for making this happen.
+ Thanks to Matt Liotta of MontaraSoftware for hosting our
+ US-based AnonCVS server.
+
<a name="#mirror">
** Becoming an AnonCVS mirror
diff --git a/doc/blogs b/doc/blogs
index e1187bb52cc..4ed29e1010a 100644
--- a/doc/blogs
+++ b/doc/blogs
@@ -32,5 +32,7 @@
<br>
<a href="http://primates.ximian.com/~gonzalo/mono/blog/index.xml"><img align="center" src="images/xml.gif"></a>
<a href="http://primates.ximian.com/~gonzalo/mono/blog/">Gonzalo Paniagua</a>
-
+ <br>
+ <a href="http://codeblogs.ximian.com/blogs/ndrochak/index.rdf"><img align="center" src="images/xml.gif"></a>
+ <a href="http://codeblogs.ximian.com/blogs/ndrochak/">Nick Drochak</a>
diff --git a/doc/class-status.in b/doc/class-status.in
index 3a6af7b980f..9aa5311698d 100644
--- a/doc/class-status.in
+++ b/doc/class-status.in
@@ -5,36 +5,26 @@
Here is the status of the different assemblies:
<ul>
<li><a href="http://www.go-mono.com/class-status-corlib.html">corlib</a>: The core library.
- <li><a href="http://www.go-mono.com/class-status-System.html">System</a>.
+ <li><a href="http://www.go-mono.com/class-status-System.html">System</a>: Extra modules
<li><a href="http://www.go-mono.com/class-status-System.Xml.html">System.Xml</a>.
-
<li><a
href="http://www.go-mono.com/class-status-System.Data.html">System.Data</a>:
Database access functionality (also check the <a href="ado-net.html">Mono ADO.NET status</a> pages).
-
<li><a href="http://www.go-mono.com/class-status-System.Drawing.html">System.Drawing</a>.
-
<li><a
href="http://www.go-mono.com/class-status-System.Web.html">System.Web</a>:
ASP.NET classes, also check the <a href="asp-net.html">Mono ASP.NET status pages</a>
-
<li><a href="http://www.go-mono.com/class-status-System.Web.Services.html">System.Web.Services</a>.
-
<li><a
href="http://www.go-mono.com/class-status-Microsoft.VisualBasic.html">Microsoft.VisualBasic</a>:
Support runtime for Visual Basic applications
-
<li><a
href="http://www.go-mono.com/class-status-System.Windows.Forms.html">Windows.Forms</a>:
there is also a <a
href="http://lists.ximian.com/mailman/listinfo/mono-winforms-list">mailing
list available</a>
-
- <li><a href="http://www.go-mono.com/class-status-System.EnterpriseServices.html">EnterpriseServices</a>.
-
<li><a
href="http://www.go-mono.com/class-status-System.Runtime.Serialization.Formatters.Soap.html">System.Runtime.Serialization.Formatters.Soap</a>.
-
<li><a
href="http://www.go-mono.com/class-status-System.Security.html">System.Security</a>:
Xml Signature Security classes, also check the <a href="crypto.html">Cryptography status pages</a>
diff --git a/doc/drawing b/doc/drawing
new file mode 100644
index 00000000000..b8867f63d43
--- /dev/null
+++ b/doc/drawing
@@ -0,0 +1,43 @@
+* Drawing
+
+ Mono provides two mechanism to draw. The first exposes the
+ Microsoft System.Drawing API and the second exposes the <a
+ href="http://www.cairographics.org">Cairo</a> API.
+
+* System.Drawing
+
+ The System.Drawing implementation in Mono is designed to be
+ compatible with the Microsoft API. The imaging model is very
+ similar to the PDF 1.4 composition-based imaging model.
+
+ Our implementation is a C# wrapper around the GDI+ C API (also
+ called the "GDI+ Flat API").
+
+ <center>
+ <img src="images/system-drawing.png">
+ </center>
+
+ In Windows Mono uses the GDI+ library that is included
+ with the operating system, while in Unix we provide an
+ implementation of this API which uses Cairo to do the heavy
+ lifting.
+
+ The implementation of GDI+ lives in mcs/class/System.Drawing
+ in the gdiplus directory and requires <a
+ href="http://www.cairographics.org">Cairo</a> to be installed
+ to get the package built.
+
+ The C# code that implement System.Drawing is the same for
+ Windows and Unix builds.
+
+ Since this is an implementation of an existing Microsoft API
+ no architectural changes go here.
+
+* Mono.Cairo
+
+ The Mono.Cairo.dll assembly exposes the Cairo API to managed
+ applications. The mapping is a pretty straightforward one,
+ and the programming model is very close to the C API.
+
+ This API is still unstable due to the nature of the underlying
+ API being used and will be revisited as Cairo evolves.
diff --git a/doc/index b/doc/index
index 0b6e3482aab..0ddfb13b6ee 100644
--- a/doc/index
+++ b/doc/index
@@ -141,6 +141,34 @@
</tr>
</table>
+@item Nov 25th: Gtk# 0.14, System.DirectoryServices
+
+ Gtk# 0.14 has been released, and it is available from <a
+ href="http://gtk-sharp.sf.net">the Gtk# web site</a>.
+
+ Sunil has checked in the implementation of
+ System.DirectoryServices as well as the Novell.Directory.Ldap
+ code into Mono CVS.
+
+@item Nov 14th: Gtk# 0.13 released.
+
+ Mike Kestner has <a
+ href="http://lists.ximian.com/archives/public/mono-list/2003-November/016943.html">announced</a>
+ the release of the <a href="http://gtk-sharp.sf.net">Gtk#</a>
+ GUI toolkit for .NET and Mono.
+
+@item Nov 13th: Managed LDAP binding for Mono and .NET
+
+ Sunil Kumar at Novell has <a
+ href="http://lists.ximian.com/archives/public/mono-list/2003-November/016907.html">announced</a>
+ the availability of a fully managed implementation of LDAP for
+ Mono and the .NET Framework.
+
+ You can obtain the library from <a
+ href="http://forge.novell.com">Novell Forge's</a> <a
+ href="http://forge.novell.com/modules/xfmod/cvs/cvsbrowse.php/ldapcsharp/CsharpLDAP">CSharpLDAP</a>
+ module.
+
@item Nov 4th: Mono Roadmap announced.
The <a href="mono-roadmap.html">Mono Roadmap</a> and <a
diff --git a/doc/jit-debug b/doc/jit-debug
index 85f92906989..e33deb65579 100644
--- a/doc/jit-debug
+++ b/doc/jit-debug
@@ -13,6 +13,34 @@
Notice that the program will need to be compiled with the -g
flag and that running with --debug will slow down the execution.
+* Debugging with GDB
+
+ If you use GDB to debug your mono process, you can use the function
+ print_method_from_ip(void *address) to obtain the name of a method
+ given an address.
+
+ For example:
+
+ <pre>
+(gdb) where
+#0 ves_icall_System_String_GetHashCode (me=0x80795d0) at string-icalls.c:861
+#1 0x0817f490 in ?? ()
+#2 0x0817f42a in ?? ()
+#3 0x0817f266 in ?? ()
+#4 0x0817f1a5 in ?? ()
+</pre>
+
+ You can now use:
+
+<pre>
+(gdb) p print_method_from_ip (0x0817f490)
+IP 0x817f490 at offset 0x28 of method (wrapper managed-to-native) System.String:GetHashCode () (0x817f468 0x817f4a4)
+$1 = void
+(gdb) p print_method_from_ip (0x0817f42a)
+IP 0x817f42a at offset 0x52 of method System.Collections.Hashtable:GetHash (object) (0x817f3d8 0x817f43b)
+$2 = void
+</pre>
+
* Mono Debugger
The Mono debugger is written in C# and can debug both managed
@@ -38,4 +66,4 @@
- \ No newline at end of file
+
diff --git a/doc/mono-roadmap.html b/doc/mono-roadmap.html
index e35e9e1741b..8f4b8037333 100644
--- a/doc/mono-roadmap.html
+++ b/doc/mono-roadmap.html
@@ -212,7 +212,7 @@ vertical-align: top;
components.
</ul>
- <p>Release target: Q1/2004.
+ <p>Release target: Q2/2004.
<p>Bug fix releases would be done on a monthly basis.
diff --git a/doc/plans b/doc/plans
index db6f6dde7c8..f53aecd4e95 100755
--- a/doc/plans
+++ b/doc/plans
@@ -8,7 +8,7 @@
Currently you can read our plans for <a
href="ado-net.html">ADO.NET</a>, <a
- href="asp-net">ASP.NET</a>, <a href="java.html">Java</a> and
+ href="asp-net.html">ASP.NET</a>, <a href="java.html">Java</a> and
<a href="winforms.html">WinForms</a>.
diff --git a/doc/runtime b/doc/runtime
index f828bb13221..c2ecdf425a8 100644
--- a/doc/runtime
+++ b/doc/runtime
@@ -19,7 +19,7 @@
We are using the Boehm conservative garbage collector.
The Mono runtime can be used as a stand-alone process, or it
- can be <a href="embedded-api">embedded into applications</a> (see
+ can be <a href="embedded-api.html">embedded into applications</a> (see
the documentation in mono/samples/embed for more details).
Embedding the Mono runtime allows applications to be extended
diff --git a/doc/sqlite b/doc/sqlite
index 35ee3056896..6730477202c 100755
--- a/doc/sqlite
+++ b/doc/sqlite
@@ -82,7 +82,7 @@
{
string connectionString = "URI=file:SqliteTest.db";
IDbConnection dbcon;
- dbcon = new MySQLConnection(connectionString);
+ dbcon = new SqliteConnection(connectionString);
dbcon.Open();
IDbCommand dbcmd = dbcon.CreateCommand();
// requires a table to be created named employee
diff --git a/doc/web/commands b/doc/web/commands
index 64c8d24ff58..5eac2a24831 100644
--- a/doc/web/commands
+++ b/doc/web/commands
@@ -42,6 +42,7 @@
1,Debugging,jit-debug.html,jit-debug.src
0,Plans,plans.html,plans.src
1,ADO.NET,ado-net.html,ado-net.src
+1,Drawing,drawing.html,drawing.src
2,ProviderFactory,provider-factory.html,provider-factory.src
2,Firebird Interbase,firebird.html,firebird.src
2,IBM DB2,ibmdb2.html,ibmdb2.src
@@ -68,6 +69,7 @@
1,Web.Services,class-status-System.Web.Services.html,class-status-System.Web.Services.src,cm/cormissing.css,cm/cormissing.js
1,Microsoft.VisualBasic,class-status-Microsoft.VisualBasic.html,class-status-Microsoft.VisualBasic.src,cm/cormissing.css,cm/cormissing.js
1,Windows.Forms,class-status-System.Windows.Forms.html,class-status-System.Windows.Forms.src,cm/cormissing.css,cm/cormissing.js
+1,DirectoryServices,class-status-System.DirectoryServices.html,class-status-System.DirectoryServices.src,cm/cormissing.css,cm/cormissing.js
1,Formatters.Soap,class-status-System.Runtime.Serialization.Formatters.Soap.html,class-status-System.Runtime.Serialization.Formatters.Soap.src,cm/cormissing.css,cm/cormissing.js
1,Cscompmgd,class-status-Cscompmgd.html,class-status-Cscompmgd.src,cm/cormissing.css,cm/cormissing.js
1,System.Security,class-status-System.Security.html,class-status-System.Security.src,cm/cormissing.css,cm/cormissing.js
diff --git a/doc/web/infos/.cvsignore b/doc/web/infos/.cvsignore
new file mode 100644
index 00000000000..6722cd96e78
--- /dev/null
+++ b/doc/web/infos/.cvsignore
@@ -0,0 +1 @@
+*.xml
diff --git a/doc/web/makefile b/doc/web/makefile
index 91ac5b5129d..be86dab63fe 100644
--- a/doc/web/makefile
+++ b/doc/web/makefile
@@ -20,6 +20,7 @@ OBJECTS= \
deploy/ccvs.html \
deploy/documentation.html \
deploy/download.html \
+ deploy/drawing.html \
deploy/crypto.html \
deploy/embedded-api.html \
deploy/faq.html \
@@ -55,7 +56,6 @@ OBJECTS= \
deploy/provider-factory.html \
deploy/rationale.html \
deploy/resources.html \
- deploy/roadmap.html \
deploy/runtime.html \
deploy/screenshots.html \
deploy/sqlclient.html \
@@ -76,9 +76,11 @@ OBJECTS= \
deploy/class-status-System.Data.html \
deploy/class-status-System.Security.html \
deploy/class-status-System.Web.html \
+ deploy/class-status-System.Web.Services.html \
deploy/class-status-System.Drawing.html \
deploy/class-status-Microsoft.VisualBasic.html \
deploy/class-status-System.Windows.Forms.html \
+ deploy/class-status-System.DirectoryServices.html \
deploy/class-status-Cscompmgd.html \
deploy/class-status-System.Runtime.Serialization.Formatters.Soap.html
@@ -97,7 +99,7 @@ NON_HTML_SOURCES= \
all: $(OBJECTS) deploy/index.rss ../team
perl process.pl commands template.html.in deploy
cp $(HTML_SOURCES) deploy
- -mkdir deploy/team
+ test -d deploy/team || mkdir deploy/team
cp team/*png deploy/team
tutorial: mono-beginning.html.stamp mono-beginning.pdf
@@ -126,14 +128,16 @@ render-team-page.exe: render-team-page.cs
$(CSC) render-team-page.cs
clean:
- rm -f $(OBJECTS) $(patsubst deploy/%.html,src/%.src, $(OBJECTS)) src/*.xml src/*.html.in ../class-status-* ../class-status
+ rm -f $(OBJECTS) $(patsubst deploy/%.html,src/%.src, $(OBJECTS)) src/*.xml src/*.html.in ../class-status-* ../class-status infos/*
push:
cp -f $(NON_HTML_SOURCES) deploy
+ cp ../mono-roadmap.html deploy
#echo scp -P 2200 -r deploy/* www@www.go-mono.com:/web/cvsmodules/mono
#(cd deploy; rsync --verbose --recursive --checksum --update --rsh='ssh' . www@www.go-mono.com:/web/cvsmodules/mono )
(cd deploy; rsync --verbose --recursive --checksum --update --rsh='ssh' . mono-web@www.go-mono.com:/web/cvsmodules/mono )
+
push2:
scp -r deploy/* primates:public_html/xxx
@@ -155,21 +159,41 @@ src/%.src: ../% commands template.html.in makefile
.PRECIOUS: src/%.html.in
-src/%.html.in: src/%.xml transform.exe $(CORCOMPARE)/cormissing.xsl
- cscript $(CORCOMPARE)/transform.js $< $(CORCOMPARE)/cormissing.xsl > $@
- #$(RUN_MONO) ./transform.exe
+src/%.html.in: src/%.xml transform.exe $(CORCOMPARE)/mono-api.xsl
+ $(RUN_MONO) ./transform.exe $< $(CORCOMPARE)/mono-api.xsl > $@ || (rm -f $@ && exit 1)
+.PRECIOUS: infos/%.xml
+infos/%.xml: ../../../mcs/class/lib/%.dll $(CORCOMPARE)/mono-api-info.exe
+ $(RUN_MONO) $(CORCOMPARE)/mono-api-info.exe $< > $@ || (rm -f $@ && exit 1)
.PRECIOUS: src/%.xml
-src/%.xml: ../../../mcs/class/lib/%.dll $(CORCOMPARE)/CorCompare.exe
- $(RUN_MONO) $(CORCOMPARE)/CorCompare.exe -x $@ $<
+src/%.xml: infos/%.xml $(CORCOMPARE)/mono-api-diff.exe
+ $(RUN_MONO) $(CORCOMPARE)/mono-api-diff.exe masterinfos/$(notdir $<) $< > $@ || (rm -f $@ && exit 1)
+
+# corlib, corlib...
+infos/mscorlib.xml: ../../../mcs/class/lib/mscorlib.dll $(CORCOMPARE)/mono-api-info.exe
+ $(RUN_MONO) $(CORCOMPARE)/mono-api-info.exe $(notdir $(basename $<)) > $@ || (rm -f $@ && exit 1)
+
+src/corlib.xml: infos/mscorlib.xml $(CORCOMPARE)/mono-api-diff.exe
+ $(RUN_MONO) $(CORCOMPARE)/mono-api-diff.exe masterinfos/mscorlib.xml $< > $@ || (rm -f $@ && exit 1)
+
+# System
+infos/System.xml: ../../../mcs/class/lib/System.dll $(CORCOMPARE)/mono-api-info.exe
+ $(RUN_MONO) $(CORCOMPARE)/mono-api-info.exe $(notdir $(basename $<)) > $@ || (rm -f $@ && exit 1)
+
+src/System.xml: infos/System.xml $(CORCOMPARE)/mono-api-diff.exe
+ $(RUN_MONO) $(CORCOMPARE)/mono-api-diff.exe masterinfos/System.xml $< > $@ || (rm -f $@ && exit 1)
+
+# System.Xml
+infos/System.Xml.xml: ../../../mcs/class/lib/System.Xml.dll $(CORCOMPARE)/mono-api-info.exe
+ $(RUN_MONO) $(CORCOMPARE)/mono-api-info.exe $(notdir $(basename $<)) > $@ || (rm -f $@ && exit 1)
-src/corlib.xml: ../../../mcs/class/lib/corlib_cmp.dll $(CORCOMPARE)/CorCompare.exe
- $(RUN_MONO) $(CORCOMPARE)/CorCompare.exe -f corlib -ms mscorlib -x $@ $<
+src/System.Xml.xml: infos/System.Xml.xml $(CORCOMPARE)/mono-api-diff.exe
+ $(RUN_MONO) $(CORCOMPARE)/mono-api-diff.exe masterinfos/System.Xml.xml $< > $@ || (rm -f $@ && exit 1)
-src/System.Security.xml: ../../../mcs/class/lib/System.Security_cmp.dll $(CORCOMPARE)/CorCompare.exe
- $(RUN_MONO) $(CORCOMPARE)/CorCompare.exe -f System.Security -ms System.Security -x $@ $<
+src/System.DirectoryServices.xml: infos/System.DirectoryServices.xml $(CORCOMPARE)/mono-api-diff.exe
+ $(RUN_MONO) $(CORCOMPARE)/mono-api-diff.exe masterinfos/System.DirectoryServices.xml $< > $@ || (rm -f $@ && exit 1)
../class-status: ../class-status.in
cp -f $< $@
diff --git a/doc/web/masterinfos/.cvsignore b/doc/web/masterinfos/.cvsignore
new file mode 100644
index 00000000000..6722cd96e78
--- /dev/null
+++ b/doc/web/masterinfos/.cvsignore
@@ -0,0 +1 @@
+*.xml
diff --git a/doc/web/team.xml b/doc/web/team.xml
index 726757b1b90..cf5eeb63163 100644
--- a/doc/web/team.xml
+++ b/doc/web/team.xml
@@ -648,7 +648,7 @@
</name>
- <e-mail>jackson@latitudegeo.com</e-mail>
+ <e-mail>jackson@ximian.com</e-mail>
<image>jackson.png</image>
@@ -658,11 +658,11 @@
<tasks>
- <task>Misc Bug fixes</task>
+ <task>IL Assembler</task>
- <task>Cscompmgd</task>
+ <task>System.Web</task>
- <task>IL Assembler</task>
+ <task>Bug Fix0r</task>
</tasks>
@@ -678,7 +678,7 @@
</name>
- <e-mail>ndrochak AT gol.com</e-mail>
+ <e-mail>ndrochak AT ieee.org</e-mail>
<image>nickd.png</image>
diff --git a/doc/web/team/jackson.png b/doc/web/team/jackson.png
index fd99a69a1a7..2fb5545ee61 100644
--- a/doc/web/team/jackson.png
+++ b/doc/web/team/jackson.png
Binary files differ
diff --git a/doc/winforms b/doc/winforms
index e2b3ad59398..b98d0d3a561 100644
--- a/doc/winforms
+++ b/doc/winforms
@@ -90,9 +90,7 @@
* System.Drawing
- We currently have two code paths: the Wine-based
- System.Drawing and the Cairo-based one. We will eventually
- unify everything to use Cairo, but currently the effort can
- continue with the approach we have.
-
+ For details, see the <a
+ href="drawing.html">System.Drawing implementation notes</a>
+ section of the web site.
diff --git a/man/mono.1 b/man/mono.1
index 64bebdeeefc..b668b344a33 100644
--- a/man/mono.1
+++ b/man/mono.1
@@ -235,7 +235,6 @@ environment variable.
.TP
.I "MONO_DEBUG"
If set, enables some features of the runtime useful for debugging.
-
Currently it only makes the runtime display the stack traces for all the
threads running and exit. It may not exit cleanly. Use at your own risk.
.TP
@@ -245,12 +244,18 @@ turning externally-generated text (e.g. command-line arguments or
filenames) into unicode. The encoding names come from the list
provided by iconv, and the special case "default_locale" which refers
to the current locale's default encoding.
-
+.TP
When reading externally-generated text strings UTF-8 is tried first,
and then this list is tried in order with the first successful
conversion ending the search. When writing external text (e.g. new
filenames or arguments to new processes) the first item in this list
is used, or UTF-8 if the environment variable is not set.
+.TP
+.I "MONO_SHARED_DIR"
+If set its the directory where the ".wapi" handle state is stored.
+This is the directory where the Windows I/O Emulation layer stores its
+shared state data (files, events, mutexes, pipes). By default Mono
+will store the ".wapi" directory in the users's home directory.
.SH FILES
On Unix assemblies are loaded from the installation lib directory. If you set
`prefix' to /usr, the assemblies will be located in /usr/lib. On
@@ -266,6 +271,8 @@ Visit http://mail.ximian.com/mailman/mono-list for details.
.SH WEB SITE
Visit: http://www.go-mono.com for details
.SH SEE ALSO
-.BR mcs(1), mint(1), monodis(1), mono-config(5)
+.BR mcs(1), mint(1), monodis(1), mono-config(5).
+.PP
+For ASP.NET-related documentation, see the xsp(1) manual page
diff --git a/mcs/README b/mcs/README
index 40bbfc2f802..cea5f11930b 100755
--- a/mcs/README
+++ b/mcs/README
@@ -1,4 +1,3 @@
-
This contains the Mono C# compiler as well as the Mono runtime
library.
diff --git a/mcs/build/ChangeLog b/mcs/build/ChangeLog
index f5fddd1537c..939d6e7d4fd 100644
--- a/mcs/build/ChangeLog
+++ b/mcs/build/ChangeLog
@@ -1,3 +1,8 @@
+2003-11-12 Jackson Harper <jackson@ximian.com>
+
+ * rules.make:
+ * platforms/linux.make: corlib name is now mscorlib.
+
2003-11-09 Ben Maurer <bmaurer@users.sourceforge.net>
* profiles/generics.make: add the -2 flag.
diff --git a/mcs/build/platforms/linux.make b/mcs/build/platforms/linux.make
index 65e3f549436..4064cab530d 100644
--- a/mcs/build/platforms/linux.make
+++ b/mcs/build/platforms/linux.make
@@ -6,7 +6,7 @@
PLATFORM_DEBUG_FLAGS = -g
PLATFORM_MCS_FLAGS =
PLATFORM_RUNTIME = $(RUNTIME)
-PLATFORM_CORLIB = corlib.dll
+PLATFORM_CORLIB = mscorlib.dll
BOOTSTRAP_MCS = mcs
RESGEN = monoresgen
diff --git a/mcs/build/profiles/generics.make b/mcs/build/profiles/generics.make
index 0eb89b1d88f..bf4bbccfb47 100644
--- a/mcs/build/profiles/generics.make
+++ b/mcs/build/profiles/generics.make
@@ -25,4 +25,4 @@ endif
profile-check:
-PROFILE_MCS_FLAGS = -d:GENERICS -d:NET_1_1 -d:NET_1_2 -2
+PROFILE_MCS_FLAGS = -d:NET_1_1 -d:NET_1_2 -2
diff --git a/mcs/build/rules.make b/mcs/build/rules.make
index a31a49e87cf..e1b8eda83bf 100644
--- a/mcs/build/rules.make
+++ b/mcs/build/rules.make
@@ -25,7 +25,7 @@ INSTALL_BIN = $(INSTALL) -m 755
INSTALL_LIB = $(INSTALL_BIN)
MKINSTALLDIRS = $(SHELL) $(topdir)/mkinstalldirs
INTERNAL_MCS = $(RUNTIME) $(topdir)/mcs/mcs.exe
-corlib = corlib.dll
+corlib = mscorlib.dll
depsdir = $(topdir)/build/deps
distdir = $(dots)/$(package)/$(thisdir)
diff --git a/mcs/class/ByteFX.Data/AssemblyInfo.cs b/mcs/class/ByteFX.Data/AssemblyInfo.cs
index 39aab33df80..07e3da27400 100755
--- a/mcs/class/ByteFX.Data/AssemblyInfo.cs
+++ b/mcs/class/ByteFX.Data/AssemblyInfo.cs
@@ -26,7 +26,7 @@ using System.Runtime.CompilerServices;
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:
-[assembly: AssemblyVersion("0.7.2.*")]
+[assembly: AssemblyVersion("0.7.4.*")]
//
// In order to sign your assembly you must specify a key to use. Refer to the
@@ -53,6 +53,6 @@ using System.Runtime.CompilerServices;
// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework
// documentation for more information on this.
//
-//[assembly: AssemblyDelaySign(false)]
-//[assembly: AssemblyKeyFile("..\\..\\bytefx.snk")]
-//[assembly: AssemblyKeyName("")]
+[assembly: AssemblyDelaySign(false)]
+[assembly: AssemblyKeyFile("..\\..\\bytefx.snk")]
+[assembly: AssemblyKeyName("")]
diff --git a/mcs/class/ByteFX.Data/ByteFX.Data.dll.sources b/mcs/class/ByteFX.Data/ByteFX.Data.dll.sources
index 9d2af306d9c..305c1b42bad 100644
--- a/mcs/class/ByteFX.Data/ByteFX.Data.dll.sources
+++ b/mcs/class/ByteFX.Data/ByteFX.Data.dll.sources
@@ -10,6 +10,7 @@
./Common/SqlCommandTextEditor.cs
./Common/StringUtility.cs
./Common/Version.cs
+./Common/MultiHostStream.cs
./mysqlclient/CharSetMap.cs
./mysqlclient/CommandBuilder.cs
./mysqlclient/command.cs
diff --git a/mcs/class/ByteFX.Data/ChangeLog.txt b/mcs/class/ByteFX.Data/ChangeLog.txt
index acd157dbee2..3a805d686e1 100755
--- a/mcs/class/ByteFX.Data/ChangeLog.txt
+++ b/mcs/class/ByteFX.Data/ChangeLog.txt
@@ -1,3 +1,39 @@
+11/30/2003
+MySql - Fixed ConnectionSTring editor dialog (thanks marco p (pomarc))
+Common - UserId now supported in connection strings (thanks Jeff Neeley)
+MySql - Attempting to create a parameter that is not input throws an exception (thanks Ryan Gregg)
+
+11/29/2003
+MySql - Added much documentation
+
+11/26/2003
+MySql - checked in new MultiHostStream capability. Big thanks to Dan Guisinger for this. he originally submitted the code and idea of supporting multiple machines on the connect string.
+
+11/25/2003
+MySql - Added alot of documentation. Still alot to do.
+
+11/24/2003
+MySql - Fixed speed issue with 0.73
+
+11/14/2003
+MySql - changed to Thread.Sleep(0) in MySqlDataStream to help optimize the case where it doesn't need to wait (thanks Todd German)
+11/1/2003
+MySql - Prepopulating the idlepools to MinPoolSize
+
+10/31/2003
+MySql - Fixed MySqlPool deadlock condition as well as stupid bug where CreateNewPooledConnection
+ was not ever adding new connections to the pool.
+ Also fixed MySqlStream.ReadBytes and ReadByte to not use TicksPerSecond which does not appear
+ to always be right.
+ (thanks Matthew J. Peddlesden)
+MySql - Fix for precision and scale (thanks Matthew J. Peddlesden)
+
+10/28/2003
+MySql - Added Thread.Sleep(1) to stream reading methods to be more cpu friendly (thanks Sean McGinnis)
+
+10/24/2003
+MySql - Fixed problem where ExecuteReader would sometime return null (thanks Lloyd Dupont )
+
10/17/2003
MySql - Fixed major bug with null field handling (thanks Naucki)
diff --git a/mcs/class/ByteFX.Data/Common/DBConnectionString.cs b/mcs/class/ByteFX.Data/Common/DBConnectionString.cs
index 03943266449..2fe01655ad4 100644
--- a/mcs/class/ByteFX.Data/Common/DBConnectionString.cs
+++ b/mcs/class/ByteFX.Data/Common/DBConnectionString.cs
@@ -119,7 +119,10 @@ namespace ByteFX.Data.Common
!persistSecurityInfo) continue;
str.AppendFormat("{0}={1};", key, keyValues[key]);
}
- str.Remove( str.Length-1, 1 );
+
+ if (str.Length > 0)
+ str.Remove( str.Length-1, 1 );
+
return str.ToString();
}
@@ -138,6 +141,7 @@ namespace ByteFX.Data.Common
case "username":
case "user id":
case "user name":
+ case "userid":
username = value;
break;
@@ -216,6 +220,8 @@ namespace ByteFX.Data.Common
}
}
+ keyValues.Clear();
+
// now we run through our normalized key-values, splitting on equals
for (int y=0; y < x; y++)
{
diff --git a/mcs/class/ByteFX.Data/Common/DBParametersEditor.cs b/mcs/class/ByteFX.Data/Common/DBParametersEditor.cs
index 7e065fad4c7..0a555796100 100644
--- a/mcs/class/ByteFX.Data/Common/DBParametersEditor.cs
+++ b/mcs/class/ByteFX.Data/Common/DBParametersEditor.cs
@@ -24,7 +24,7 @@ namespace ByteFX.Data.Common
/// <summary>
/// Summary description for DBParametersEditor.
/// </summary>
- public class DBParametersEditor : CollectionEditor
+ internal class DBParametersEditor : CollectionEditor
{
public DBParametersEditor(Type t) : base(t)
{
diff --git a/mcs/class/ByteFX.Data/Common/MultiHostStream.cs b/mcs/class/ByteFX.Data/Common/MultiHostStream.cs
new file mode 100644
index 00000000000..56a2c8f9534
--- /dev/null
+++ b/mcs/class/ByteFX.Data/Common/MultiHostStream.cs
@@ -0,0 +1,194 @@
+using System;
+using System.Net;
+using System.IO;
+using System.Collections;
+using System.Threading;
+
+namespace ByteFX.Data.Common
+{
+ internal enum MultiHostStreamErrorType
+ {
+ Connecting,
+ Reading,
+ Writing
+ }
+
+ /// <summary>
+ /// Summary description for MultiHostStream.
+ /// </summary>
+ internal abstract class MultiHostStream : Stream
+ {
+ protected Stream stream;
+ protected int readTimeOut;
+ protected Exception baseException;
+
+ /// <summary>
+ /// Constructs a new MultiHostStream object with the given parameters
+ /// </summary>
+ /// <param name="hostList"></param>
+ /// <param name="port"></param>
+ /// <param name="readTimeOut"></param>
+ /// <param name="connectTimeOut"></param>
+ public MultiHostStream(string hostList, int port, int readTimeOut, int connectTimeOut)
+ {
+ this.readTimeOut = readTimeOut;
+ ProcessHosts( hostList, port, connectTimeOut );
+ }
+
+ protected abstract void TimeOut(MultiHostStreamErrorType error);
+ protected abstract void Error(string msg);
+ protected abstract bool CreateStream( IPAddress ip, string host, int port );
+ protected abstract bool DataAvailable
+ {
+ get;
+ }
+
+ private void ProcessHosts( string hostList, int port, int connectTimeOut )
+ {
+ int startTime = Environment.TickCount;
+
+ int toTicks = connectTimeOut * 1000;
+ //
+ // Host name can contain multiple hosts, seperated by &.
+ string [] dnsHosts = hostList.Split('&');
+ Hashtable ips = new Hashtable();
+
+ //
+ // Each host name specified may contain multiple IP addresses
+ // Lets look at the DNS entries for each host name
+ foreach(string h in dnsHosts)
+ {
+ IPHostEntry hostAddress = Dns.GetHostByName(h);
+ foreach (IPAddress addr in hostAddress.AddressList)
+ ips.Add( addr, hostAddress.HostName );
+ }
+ IPAddress[] keys = new IPAddress[ ips.Count ];
+ ips.Keys.CopyTo( keys, 0 );
+
+ if ((Environment.TickCount - startTime) > toTicks)
+ {
+ TimeOut(MultiHostStreamErrorType.Connecting);
+ return;
+ }
+
+ // make sure they gave us at least one host
+ if (ips.Count == 0)
+ {
+ Error("You must specify at least one host");
+ return;
+ }
+
+ int index = 0;
+ // now choose a random server if there are more than one
+ if (ips.Count > 1)
+ {
+ System.Random random = new Random((int)DateTime.Now.Ticks);
+ index = random.Next(ips.Count-1);
+ }
+
+ //
+ // Lets step through our hosts until we get a connection
+ for (int i=0; i < ips.Count; i++)
+ {
+ if ((Environment.TickCount - startTime) > toTicks)
+ {
+ TimeOut(MultiHostStreamErrorType.Connecting);
+ return;
+ }
+ if (CreateStream( (IPAddress)keys[i], (string)ips[keys[i]], port ))
+ return;
+ }
+ }
+
+ public override int ReadByte()
+ {
+ int start = Environment.TickCount;
+ int ticks = readTimeOut * 1000;
+
+ while ((Environment.TickCount - start) < ticks)
+ {
+ if (DataAvailable)
+ {
+ int b = stream.ReadByte();
+ return b;
+ }
+ else
+ Thread.Sleep(1);
+ }
+
+ TimeOut(MultiHostStreamErrorType.Reading);
+ return -1;
+ }
+
+ public override int Read(byte[] buffer, int offset, int count)
+ {
+ int numToRead = count;
+ int start = Environment.TickCount;
+ int ticks = readTimeOut * 1000;
+
+ while (numToRead > 0 && (Environment.TickCount - start) < ticks)
+ {
+ if (DataAvailable)
+ {
+ int bytes_read = stream.Read( buffer, offset, numToRead);
+ if (bytes_read == 0)
+ return (count - numToRead);
+ offset += bytes_read;
+ numToRead -= bytes_read;
+ }
+ Thread.Sleep(1);
+ }
+
+ if (numToRead > 0)
+ TimeOut(MultiHostStreamErrorType.Reading);
+ return count;
+ }
+
+ public override bool CanRead
+ {
+ get { return stream.CanRead; }
+ }
+
+ public override bool CanWrite
+ {
+ get { return stream.CanWrite; }
+ }
+
+ public override bool CanSeek
+ {
+ get { return stream.CanSeek; }
+ }
+
+ public override long Length
+ {
+ get { return stream.Length; }
+ }
+
+ public override long Position
+ {
+ get { return stream.Position; }
+ set { stream.Position = value; }
+ }
+
+ public override void Flush()
+ {
+ stream.Flush();
+ }
+
+ public override void SetLength(long length)
+ {
+ stream.SetLength( length );
+ }
+
+ public override void Write(byte[] buffer, int offset, int count)
+ {
+ stream.Write( buffer, offset, count );
+ }
+
+ public override long Seek( long offset, SeekOrigin origin )
+ {
+ return stream.Seek( offset, origin );
+ }
+
+ }
+}
diff --git a/mcs/class/ByteFX.Data/Common/NamedPipeStream.cs b/mcs/class/ByteFX.Data/Common/NamedPipeStream.cs
index 1d38c253ab5..5ebc5755cb8 100755
--- a/mcs/class/ByteFX.Data/Common/NamedPipeStream.cs
+++ b/mcs/class/ByteFX.Data/Common/NamedPipeStream.cs
@@ -25,7 +25,7 @@ namespace ByteFX.Data.Common
/// <summary>
/// Summary description for API.
/// </summary>
- public class NamedPipeStream : Stream
+ internal class NamedPipeStream : Stream
{
[DllImport("kernel32.dll", EntryPoint="CreateFile", SetLastError=true)]
private static extern IntPtr CreateFile(String lpFileName,
diff --git a/mcs/class/ByteFX.Data/Common/Security.cs b/mcs/class/ByteFX.Data/Common/Security.cs
index 811f16c3f70..0547e2e1a1b 100644
--- a/mcs/class/ByteFX.Data/Common/Security.cs
+++ b/mcs/class/ByteFX.Data/Common/Security.cs
@@ -5,7 +5,7 @@ namespace ByteFX.Data.Common
/// <summary>
/// Summary description for Security.
/// </summary>
- public class Security
+ internal class Security
{
public Security()
{
diff --git a/mcs/class/ByteFX.Data/Common/SqlCommandTextEditor.cs b/mcs/class/ByteFX.Data/Common/SqlCommandTextEditor.cs
index 530bf20be70..7dfa9743518 100644
--- a/mcs/class/ByteFX.Data/Common/SqlCommandTextEditor.cs
+++ b/mcs/class/ByteFX.Data/Common/SqlCommandTextEditor.cs
@@ -25,7 +25,7 @@ namespace ByteFX.Data.Common
/// <summary>
/// Summary description for MySqlConnectionDesign.
/// </summary>
- public class SqlCommandTextEditor : UITypeEditor
+ internal class SqlCommandTextEditor : UITypeEditor
{
public override System.Drawing.Design.UITypeEditorEditStyle GetEditStyle(System.ComponentModel.ITypeDescriptorContext context)
{
diff --git a/mcs/class/ByteFX.Data/Common/Version.cs b/mcs/class/ByteFX.Data/Common/Version.cs
index eba74166ff2..03b72a6a985 100644
--- a/mcs/class/ByteFX.Data/Common/Version.cs
+++ b/mcs/class/ByteFX.Data/Common/Version.cs
@@ -5,7 +5,7 @@ namespace ByteFX.Data.Common
/// <summary>
/// Summary description for Version.
/// </summary>
- public struct Version
+ internal struct Version
{
private int major;
private int minor;
diff --git a/mcs/class/ByteFX.Data/mysqlclient/CommandBuilder.cs b/mcs/class/ByteFX.Data/mysqlclient/CommandBuilder.cs
index 5befb5d7ba0..7572a398e4b 100755
--- a/mcs/class/ByteFX.Data/mysqlclient/CommandBuilder.cs
+++ b/mcs/class/ByteFX.Data/mysqlclient/CommandBuilder.cs
@@ -23,8 +23,9 @@ using System.Text;
namespace ByteFX.Data.MySqlClient
{
/// <summary>
- /// Summary description for CommandBuilder.
+ /// Automatically generates single-table commands used to reconcile changes made to a DataSet with the associated MySQL database. This class cannot be inherited.
/// </summary>
+ /// <include file='docs/MySqlCommandBuilder.xml' path='MyDocs/MyMembers[@name="Class"]/*'/>
[ToolboxItem(false)]
[System.ComponentModel.DesignerCategory("Code")]
public sealed class MySqlCommandBuilder : Component
@@ -40,10 +41,16 @@ namespace ByteFX.Data.MySqlClient
private MySqlCommand _deleteCmd;
#region Constructors
+ /// <summary>
+ /// Overloaded. Initializes a new instance of the SqlCommandBuilder class.
+ /// </summary>
public MySqlCommandBuilder()
{
}
+ /// <summary>
+ /// Overloaded. Initializes a new instance of the SqlCommandBuilder class.
+ /// </summary>
public MySqlCommandBuilder( MySqlDataAdapter adapter )
{
_adapter = adapter;
@@ -90,6 +97,12 @@ namespace ByteFX.Data.MySqlClient
#endregion
#region Public Methods
+ /// <summary>
+ /// Retrieves parameter information from the stored procedure specified in the MySqlCommand and populates the Parameters collection of the specified MySqlCommand object.
+ /// This method is not currently supported since stored procedures are not available in MySql.
+ /// </summary>
+ /// <param name="command">The MySqlCommand referencing the stored procedure from which the parameter information is to be derived. The derived parameters are added to the Parameters collection of the MySqlCommand.</param>
+ /// <exception cref="InvalidOperationException">The command text is not a valid stored procedure name.</exception>
public static void DeriveParameters(MySqlCommand command)
{
throw new MySqlException("DeriveParameters is not supported (due to MySql not supporting SP)");
diff --git a/mcs/class/ByteFX.Data/mysqlclient/Connection.cs b/mcs/class/ByteFX.Data/mysqlclient/Connection.cs
index 6a634886061..47895e40d6e 100755
--- a/mcs/class/ByteFX.Data/mysqlclient/Connection.cs
+++ b/mcs/class/ByteFX.Data/mysqlclient/Connection.cs
@@ -37,9 +37,12 @@ namespace ByteFX.Data.MySqlClient
internal ConnectionState state;
private MySqlInternalConnection internalConnection;
private MySqlDataReader dataReader;
- private NumberFormatInfo numberFormat;
- private MySqlConnectionString settings;
+ private NumberFormatInfo numberFormat;
+ private MySqlConnectionString settings;
+ /// <summary>
+ /// Occurs when the state of the connection changes.
+ /// </summary>
public event StateChangeEventHandler StateChange;
@@ -149,17 +152,17 @@ namespace ByteFX.Data.MySqlClient
[Browsable(false)]
public string ServerVersion
{
- get { return ""; } //internalConnection.GetServerVersion(); }
+ get { return internalConnection.Driver.Version; }
}
internal Encoding Encoding
{
get
{
-//TODO if (encoding == null)
+ if (internalConnection == null)
return System.Text.Encoding.Default;
-// else
-// return encoding;
+ else
+ return internalConnection.Driver.Encoding;
}
}
@@ -167,6 +170,7 @@ namespace ByteFX.Data.MySqlClient
/// <summary>
/// Gets or sets the string used to connect to a MySQL Server database.
/// </summary>
+ /// <include file='docs/MySqlConnection.xml' path='MyDocs/MyMembers[@name="ConnectionString"]/*'/>
#if WINDOWS
[Editor(typeof(Designers.ConnectionStringEditor), typeof(System.Drawing.Design.UITypeEditor))]
#endif
@@ -340,7 +344,11 @@ namespace ByteFX.Data.MySqlClient
}
#region ICloneable
- public object Clone()
+ /// <summary>
+ /// Creates a new MySqlConnection object with the exact same ConnectionString value
+ /// </summary>
+ /// <returns>A cloned MySqlConnection object</returns>
+ object ICloneable.Clone()
{
MySqlConnection clone = new MySqlConnection();
clone.ConnectionString = this.ConnectionString;
diff --git a/mcs/class/ByteFX.Data/mysqlclient/ConnectionInternal.cs b/mcs/class/ByteFX.Data/mysqlclient/ConnectionInternal.cs
index 52b23ce06c1..cb51b1f1ae8 100644
--- a/mcs/class/ByteFX.Data/mysqlclient/ConnectionInternal.cs
+++ b/mcs/class/ByteFX.Data/mysqlclient/ConnectionInternal.cs
@@ -40,12 +40,13 @@ namespace ByteFX.Data.MySqlClient
Packet packet;
try
{
- packet = driver.SendSql( "show status like 'uptime'" );
+ byte[] bytes = driver.Encoding.GetBytes("show status like 'uptime'");
+ packet = driver.SendSql( bytes );
// we have to read for two last packets since MySql sends
// us a last packet after schema and again after rows
// I will likely change this later to have the driver just
// return schema in one very large packet.
- while (packet.Type != PacketType.Last)
+ while (! packet.IsLastPacket())
packet = driver.ReadPacket();
}
catch
@@ -74,10 +75,13 @@ namespace ByteFX.Data.MySqlClient
if (serverVariablesSet) return;
// retrieve the encoding that should be used for character data
- MySqlCommand cmd = new MySqlCommand("select @@max_allowed_packet", connection);
+ MySqlCommand cmd = new MySqlCommand("show variables like 'max_allowed_packet'", connection);
try
{
- driver.MaxPacketSize = Convert.ToInt64(cmd.ExecuteScalar());
+ MySqlDataReader reader = cmd.ExecuteReader();
+ reader.Read();
+ driver.MaxPacketSize = reader.GetInt64( 1 );
+ reader.Close();
}
catch
{
@@ -94,7 +98,10 @@ namespace ByteFX.Data.MySqlClient
driver.Encoding = CharSetMap.GetEncoding( reader.GetString(1) );
reader.Close();
}
- catch { }
+ catch
+ {
+ throw new MySqlException("Failure to initialize connection");
+ }
serverVariablesSet = true;
}
@@ -102,8 +109,7 @@ namespace ByteFX.Data.MySqlClient
public void Open()
{
driver = new Driver();
- driver.Open( settings.Host, settings.Port, settings.Username, settings.Password,
- settings.UseCompression, settings.ConnectTimeout );
+ driver.Open( settings );
createTime = DateTime.Now;
}
diff --git a/mcs/class/ByteFX.Data/mysqlclient/ConnectionString.cs b/mcs/class/ByteFX.Data/mysqlclient/ConnectionString.cs
index ac5dac837fa..f3a9567d794 100644
--- a/mcs/class/ByteFX.Data/mysqlclient/ConnectionString.cs
+++ b/mcs/class/ByteFX.Data/mysqlclient/ConnectionString.cs
@@ -8,7 +8,7 @@ namespace ByteFX.Data.MySqlClient
/// </summary>
internal sealed class MySqlConnectionString : DBConnectionString
{
- private bool useCompression;
+ private bool useCompression = false;
public MySqlConnectionString()
{
diff --git a/mcs/class/ByteFX.Data/mysqlclient/Driver.cs b/mcs/class/ByteFX.Data/mysqlclient/Driver.cs
index 6aa5404c56e..fec7dfea8bc 100755
--- a/mcs/class/ByteFX.Data/mysqlclient/Driver.cs
+++ b/mcs/class/ByteFX.Data/mysqlclient/Driver.cs
@@ -37,11 +37,11 @@ namespace ByteFX.Data.MySqlClient
protected MySqlStream stream;
protected Encoding encoding;
protected byte packetSeq;
- protected int timeOut;
protected long maxPacketSize;
protected Packet peekedPacket = null;
protected ByteFX.Data.Common.Version serverVersion;
protected bool isOpen;
+ protected string versionString;
int protocol;
uint threadID;
@@ -69,41 +69,33 @@ namespace ByteFX.Data.MySqlClient
set { maxPacketSize = value; }
}
- /// <summary>
- ///
- /// </summary>
- /// <param name="host"></param>
- /// <param name="port"></param>
- /// <param name="userid"></param>
- /// <param name="password"></param>
- public void Open( String host, int port, String userid, String password,
- bool UseCompression, int connectTimeout )
+ public string Version
+ {
+ get { return versionString; }
+ }
+
+ public void Open( MySqlConnectionString settings )
{
- timeOut = connectTimeout;
- stream = new MySqlStream( host, port, timeOut );
+ stream = new MySqlStream( settings.Host, settings.Port, 30, settings.ConnectTimeout );
Packet packet = ReadPacket();
// read off the protocol version
protocol = packet.ReadByte();
- serverVersion = ByteFX.Data.Common.Version.Parse( packet.ReadString() );
+ versionString = packet.ReadString();
+ serverVersion = ByteFX.Data.Common.Version.Parse( versionString );
threadID = (uint)packet.ReadInteger(4);
encryptionSeed = packet.ReadString();
// read in Server capabilities if they are provided
serverCaps = 0;
- if (packet.CanRead)
+ if (packet.HasMoreData)
serverCaps = (int)packet.ReadInteger(2);
- Authenticate( userid, password, UseCompression );
+ Authenticate( settings.Username, settings.Password, settings.UseCompression );
isOpen = true;
}
- /// <summary>
- ///
- /// </summary>
- /// <param name="userid"></param>
- /// <param name="password"></param>
private void Authenticate( String userid, String password, bool UseCompression )
{
ClientParam clientParam = ClientParam.CLIENT_FOUND_ROWS | ClientParam.CLIENT_LONG_FLAG;
@@ -156,7 +148,8 @@ namespace ByteFX.Data.MySqlClient
/// <summary>
/// AuthenticateSecurity implements the new 4.1 authentication scheme
/// </summary>
- /// <param name="password"></param>
+ /// <param name="packet">The in-progress packet we use to complete the authentication</param>
+ /// <param name="password">The password of the user to use</param>
private void AuthenticateSecurely( Packet packet, string password )
{
packet.WriteString("xxxxxxxx", encoding );
@@ -169,7 +162,7 @@ namespace ByteFX.Data.MySqlClient
SHA1 sha = new SHA1CryptoServiceProvider();
byte[] firstPassBytes = sha.ComputeHash( System.Text.Encoding.Default.GetBytes(newPass));
- byte[] salt = packet.GetBytes();
+ byte[] salt = packet.GetBuffer();
byte[] input = new byte[ firstPassBytes.Length + 4 ];
salt.CopyTo( input, 0 );
firstPassBytes.CopyTo( input, 4 );
@@ -183,11 +176,10 @@ namespace ByteFX.Data.MySqlClient
// send the packet
packet = new Packet();
- packet.WriteBytes( firstPassBytes, 0, 20 );
+ packet.Write( firstPassBytes, 0, 20 );
SendPacket(packet);
}
-
/// <summary>
///
/// </summary>
@@ -272,35 +264,15 @@ namespace ByteFX.Data.MySqlClient
Packet packet = ReadRawPacket();
- if (packet.Type == PacketType.Error)
+ // if this is an error packet, then throw the exception
+ if (packet[0] == 0xff)
{
+ packet.ReadByte();
int errorCode = (int)packet.ReadInteger(2);
string msg = packet.ReadString();
throw new MySqlException( msg, errorCode );
}
- else if (packet.Type != PacketType.UpdateOrOk)
- packet.Position = 0;
-
- return packet;
- }
-
- /// <summary>
- ///
- /// </summary>
- /// <param name="packet"></param>
- private Packet LoadSchemaIntoPacket( Packet packet, int count )
- {
- for (int i=0; i < count; i++)
- {
- Packet colPacket = ReadRawPacket();
- packet.AppendPacket( colPacket );
- }
- Packet lastPacket = ReadRawPacket();
- if (lastPacket.Type != PacketType.Last)
- throw new MySqlException("Last packet not received when expected");
- packet.Type = PacketType.ResultSchema;
- packet.Position = 0;
return packet;
}
@@ -338,7 +310,7 @@ namespace ByteFX.Data.MySqlClient
byte[] compressed_buffer = new byte[packet.Length * 2];
Deflater deflater = new Deflater();
- deflater.SetInput( packet.GetBytes(), 0, packet.Length );
+ deflater.SetInput( packet.GetBuffer(), 0, packet.Length );
deflater.Finish();
int comp_len = deflater.Deflate( compressed_buffer, 0, compressed_buffer.Length );
if (comp_len > packet.Length) return null;
@@ -368,7 +340,7 @@ namespace ByteFX.Data.MySqlClient
header.WriteInteger( packet.Length + HEADER_LEN, 3 );
header.WriteByte( packetSeq );
header.WriteInteger( 0, 3 );
- buffer = packet.GetBytes();
+ buffer = packet.GetBuffer();
}
// now write the internal header
header.WriteInteger( packet.Length, 3 );
@@ -376,16 +348,14 @@ namespace ByteFX.Data.MySqlClient
}
else
{
- header = new Packet();
- header.WriteInteger( packet.Length, 3 );
- header.WriteByte( packetSeq );
- buffer = packet.GetBytes();
+ buffer = packet.GetBytes( packetSeq );
}
packetSeq++;
// send the data to eth server
- stream.Write( header.GetBytes(), 0, header.Length );
- stream.Write( buffer, 0, buffer.Length );
+ int start = 0;
+ if (! useCompression) start = 3;
+ stream.Write( buffer, start, packet.Length - start );
stream.Flush();
}
@@ -412,7 +382,7 @@ namespace ByteFX.Data.MySqlClient
SendPacket(packet);
packet = ReadPacket();
- if (packet.Type != PacketType.UpdateOrOk)
+ if (packet[0] != 0)
throw new MySqlException("SendCommand failed for command " + text );
}
@@ -423,42 +393,28 @@ namespace ByteFX.Data.MySqlClient
/// <returns>A packet containing the bytes returned by the server</returns>
public Packet SendQuery( byte[] sql )
{
+ string s = encoding.GetString(sql);
+
Packet packet = new Packet();
packetSeq = 0;
packet.WriteByte( (byte)DBCmd.QUERY );
- packet.WriteBytes( sql, 0, sql.Length );
+ packet.Write( sql, 0, sql.Length );
SendPacket( packet );
return ReadPacket();
}
- public Packet SendSql( string sql )
- {
- byte[] bytes = encoding.GetBytes(sql);
+
+ public Packet SendSql( byte[] bytes )
+ {
Packet packet = new Packet();
packetSeq = 0;
packet.WriteByte( (byte)DBCmd.QUERY );
- packet.WriteBytes( bytes, 0, bytes.Length );
+ packet.Write( bytes, 0, bytes.Length );
SendPacket( packet );
packet = ReadPacket();
-
- switch (packet.Type)
- {
- case PacketType.LoadDataLocal:
- SendFileToServer();
- return null;
-
- case PacketType.Other:
- packet.Position = 0;
- int count = (int)packet.ReadLenInteger();
- if (count > 0)
- return LoadSchemaIntoPacket( packet, count );
- else
- return packet;
- }
-
return packet;
}
@@ -472,10 +428,11 @@ namespace ByteFX.Data.MySqlClient
}
/// <summary>
- ///
+ /// Encrypts a password using the MySql encryption scheme
/// </summary>
- /// <param name="password"></param>
- /// <param name="seed"></param>
+ /// <param name="password">The password to encrypt</param>
+ /// <param name="message">The encryption seed the server gave us</param>
+ /// <param name="new_ver">Indicates if we should use the old or new encryption scheme</param>
/// <returns></returns>
public static String EncryptPassword(String password, String message, bool new_ver)
{
diff --git a/mcs/class/ByteFX.Data/mysqlclient/Exception.cs b/mcs/class/ByteFX.Data/mysqlclient/Exception.cs
index 9e4b315f617..2e8efbc8820 100755
--- a/mcs/class/ByteFX.Data/mysqlclient/Exception.cs
+++ b/mcs/class/ByteFX.Data/mysqlclient/Exception.cs
@@ -21,25 +21,30 @@ using System.Runtime.Serialization;
namespace ByteFX.Data.MySqlClient
{
/// <summary>
- /// Summary description for MySqlException.
+ /// The exception that is thrown when MySQL returns an error. This class cannot be inherited.
/// </summary>
+ /// <include file='docs/MySqlException.xml' path='MyDocs/MyMembers[@name="Class"]/*'/>
[Serializable]
- public sealed class MySqlException : Exception
+ public sealed class MySqlException : SystemException
{
- public MySqlException(string msg) : base(msg)
+ internal MySqlException(string msg) : base(msg)
+ {
+ }
+
+ internal MySqlException( string msg, Exception ex ) : base(msg, ex)
{
}
- public MySqlException()
+ internal MySqlException()
{
}
- public MySqlException(string msg, int errno) : base(msg)
+ internal MySqlException(string msg, int errno) : base(msg)
{
}
- public MySqlException(SerializationInfo info,
+ internal MySqlException(SerializationInfo info,
StreamingContext context) : base(info, context)
{
}
diff --git a/mcs/class/ByteFX.Data/mysqlclient/Field.cs b/mcs/class/ByteFX.Data/mysqlclient/Field.cs
index 4e81e6a54c6..4e30648224c 100755
--- a/mcs/class/ByteFX.Data/mysqlclient/Field.cs
+++ b/mcs/class/ByteFX.Data/mysqlclient/Field.cs
@@ -81,14 +81,14 @@ namespace ByteFX.Data.MySqlClient
public int NumericPrecision()
{
if (colType == MySqlDbType.Decimal)
- return ((SqlDecimal)value).Precision;
+ return colLen;
return -1;
}
public int NumericScale()
{
if (colType == MySqlDbType.Decimal)
- return ((SqlDecimal)value).Scale;
+ return colDecimals;
return -1;
}
@@ -143,7 +143,7 @@ namespace ByteFX.Data.MySqlClient
// read in the data
byte[] data = new byte[ len ];
- p.ReadBytes( data, 0, len );
+ p.Read( data, 0, len );
// if it is a blob and binary, then GetBytes is the way to go
if ( IsBlob() && IsBinary() )
@@ -172,7 +172,7 @@ namespace ByteFX.Data.MySqlClient
value = Int16.Parse( sValue );
break;
- case MySqlDbType.Long :
+ case MySqlDbType.Int :
case MySqlDbType.Int24:
if (IsUnsigned())
value = UInt32.Parse( sValue );
@@ -180,7 +180,7 @@ namespace ByteFX.Data.MySqlClient
value = Int32.Parse( sValue );
break;
- case MySqlDbType.LongLong:
+ case MySqlDbType.BigInt:
if (IsUnsigned())
value = UInt64.Parse( sValue );
else
@@ -264,12 +264,12 @@ namespace ByteFX.Data.MySqlClient
case MySqlDbType.Decimal: return "DECIMAL";
case MySqlDbType.Byte: return "TINY";
case MySqlDbType.Short: return "SHORT";
- case MySqlDbType.Long: return "LONG";
+ case MySqlDbType.Int: return "INTEGER";
case MySqlDbType.Float: return "FLOAT";
case MySqlDbType.Double: return "DOUBLE";
case MySqlDbType.Null: return "NULL";
case MySqlDbType.Timestamp: return "TIMESTAMP";
- case MySqlDbType.LongLong: return "LONGLONG";
+ case MySqlDbType.BigInt: return "BIGINT";
case MySqlDbType.Int24: return "INT24";
case MySqlDbType.Date: return "DATE";
case MySqlDbType.Time: return "TIME";
@@ -297,10 +297,10 @@ namespace ByteFX.Data.MySqlClient
case MySqlDbType.Short: return IsUnsigned() ? typeof(System.UInt16) : typeof(System.Int16);
- case MySqlDbType.Long:
+ case MySqlDbType.Int:
case MySqlDbType.Int24: return IsUnsigned() ? typeof(System.UInt32) : typeof(System.Int32);
- case MySqlDbType.LongLong: return IsUnsigned() ? typeof(System.UInt64) : typeof(System.Int64);
+ case MySqlDbType.BigInt: return IsUnsigned() ? typeof(System.UInt64) : typeof(System.Int64);
case MySqlDbType.Float: return typeof(System.Single);
case MySqlDbType.Double: return typeof(System.Double);
@@ -343,7 +343,7 @@ namespace ByteFX.Data.MySqlClient
else
return DbType.Int16;
- case MySqlDbType.Long:
+ case MySqlDbType.Int:
if (IsUnsigned())
return DbType.UInt32;
else
@@ -353,7 +353,7 @@ namespace ByteFX.Data.MySqlClient
case MySqlDbType.Double: return DbType.Double;
case MySqlDbType.Null: return DbType.Object;
- case MySqlDbType.LongLong:
+ case MySqlDbType.BigInt:
if (IsUnsigned())
return DbType.UInt64;
else
diff --git a/mcs/class/ByteFX.Data/mysqlclient/MySqlHelper.cs b/mcs/class/ByteFX.Data/mysqlclient/MySqlHelper.cs
index ad07b89875a..c2b710821a3 100644
--- a/mcs/class/ByteFX.Data/mysqlclient/MySqlHelper.cs
+++ b/mcs/class/ByteFX.Data/mysqlclient/MySqlHelper.cs
@@ -5,7 +5,7 @@ using ByteFX.Data.MySqlClient;
namespace ByteFX.Data.MySqlClient
{
/// <summary>
- /// Summary description for MySqlHelper.
+ /// Helper class that makes it easier to work with the provider.
/// </summary>
public sealed class MySqlHelper
{
@@ -15,6 +15,15 @@ namespace ByteFX.Data.MySqlClient
}
#region ExecuteNonQuery
+
+ /// <summary>
+ /// Executes a single command against a MySQL database. The <see cref="MySqlConnection"/> is assumed to be
+ /// open when the method is called and remains open after the method completes.
+ /// </summary>
+ /// <param name="connection"><see cref="MySqlConnection"/> object to use</param>
+ /// <param name="commandText">SQL command to be executed</param>
+ /// <param name="commandParameters">Array of <see cref="MySqlParameter"/> objects to use with the command.</param>
+ /// <returns></returns>
public static int ExecuteNonQuery( MySqlConnection connection, string commandText, params MySqlParameter[] commandParameters )
{
//create a command and prepare it for execution
@@ -33,6 +42,14 @@ namespace ByteFX.Data.MySqlClient
return result;
}
+ /// <summary>
+ /// Executes a single command against a MySQL database. A new <see cref="MySqlConnection"/> is created
+ /// using the <see cref="MySqlConnection.ConnectionString"/> given.
+ /// </summary>
+ /// <param name="connectionString"><see cref="MySqlConnection.ConnectionString"/> to use</param>
+ /// <param name="commandText">SQL command to be executed</param>
+ /// <param name="parms">Array of <see cref="MySqlParameter"/> objects to use with the command.</param>
+ /// <returns></returns>
public static int ExecuteNonQuery( string connectionString, string commandText, params MySqlParameter[] parms )
{
//create & open a SqlConnection, and dispose of it after we are done.
@@ -47,6 +64,15 @@ namespace ByteFX.Data.MySqlClient
#endregion
#region ExecuteDataSet
+
+ /// <summary>
+ /// Executes a single SQL command and returns the first row of the resultset. A new MySqlConnection object
+ /// is created, opened, and closed during this method.
+ /// </summary>
+ /// <param name="connectionString">Settings to be used for the connection</param>
+ /// <param name="commandText">Command to execute</param>
+ /// <param name="parms">Parameters to use for the command</param>
+ /// <returns>DataRow containing the first row of the resultset</returns>
public static DataRow ExecuteDatarow( string connectionString, string commandText, params MySqlParameter[] parms )
{
DataSet ds = ExecuteDataset( connectionString, commandText, parms );
@@ -56,12 +82,27 @@ namespace ByteFX.Data.MySqlClient
return ds.Tables[0].Rows[0];
}
+ /// <summary>
+ /// Executes a single SQL command and returns the resultset in a <see cref="DataSet"/>.
+ /// A new MySqlConnection object is created, opened, and closed during this method.
+ /// </summary>
+ /// <param name="connectionString">Settings to be used for the connection</param>
+ /// <param name="commandText">Command to execute</param>
+ /// <returns><see cref="DataSet"/> containing the resultset</returns>
public static DataSet ExecuteDataset(string connectionString, string commandText)
{
//pass through the call providing null for the set of SqlParameters
return ExecuteDataset(connectionString, commandText, (MySqlParameter[])null);
}
+ /// <summary>
+ /// Executes a single SQL command and returns the resultset in a <see cref="DataSet"/>.
+ /// A new MySqlConnection object is created, opened, and closed during this method.
+ /// </summary>
+ /// <param name="connectionString">Settings to be used for the connection</param>
+ /// <param name="commandText">Command to execute</param>
+ /// <param name="commandParameters">Parameters to use for the command</param>
+ /// <returns><see cref="DataSet"/> containing the resultset</returns>
public static DataSet ExecuteDataset(string connectionString, string commandText, params MySqlParameter[] commandParameters)
{
//create & open a SqlConnection, and dispose of it after we are done.
@@ -74,13 +115,29 @@ namespace ByteFX.Data.MySqlClient
}
}
+ /// <summary>
+ /// Executes a single SQL command and returns the resultset in a <see cref="DataSet"/>.
+ /// The state of the <see cref="MySqlConnection"/> object remains unchanged after execution
+ /// of this method.
+ /// </summary>
+ /// <param name="connection"><see cref="MySqlConnection"/> object to use</param>
+ /// <param name="commandText">Command to execute</param>
+ /// <returns><see cref="DataSet"/> containing the resultset</returns>
public static DataSet ExecuteDataset(MySqlConnection connection, string commandText)
{
//pass through the call providing null for the set of SqlParameters
return ExecuteDataset(connection, commandText, (MySqlParameter[])null);
}
-
+ /// <summary>
+ /// Executes a single SQL command and returns the resultset in a <see cref="DataSet"/>.
+ /// The state of the <see cref="MySqlConnection"/> object remains unchanged after execution
+ /// of this method.
+ /// </summary>
+ /// <param name="connection"><see cref="MySqlConnection"/> object to use</param>
+ /// <param name="commandText">Command to execute</param>
+ /// <param name="commandParameters">Parameters to use for the command</param>
+ /// <returns><see cref="DataSet"/> containing the resultset</returns>
public static DataSet ExecuteDataset(MySqlConnection connection, string commandText, params MySqlParameter[] commandParameters)
{
//create a command and prepare it for execution
@@ -107,6 +164,13 @@ namespace ByteFX.Data.MySqlClient
return ds;
}
+ /// <summary>
+ /// Updates the given table with data from the given <see cref="DataSet"/>
+ /// </summary>
+ /// <param name="connectionString">Settings to use for the update</param>
+ /// <param name="commandText">Command text to use for the update</param>
+ /// <param name="ds"><see cref="DataSet"/> containing the new data to use in the update</param>
+ /// <param name="tablename">Tablename in the dataset to update</param>
public static void UpdateDataSet( string connectionString, string commandText, DataSet ds, string tablename )
{
MySqlConnection cn = new MySqlConnection( connectionString );
@@ -120,6 +184,16 @@ namespace ByteFX.Data.MySqlClient
#endregion
#region ExecuteDataReader
+
+ /// <summary>
+ /// Executes a single command against a MySQL database, possibly inside an existing transaction.
+ /// </summary>
+ /// <param name="connection"><see cref="MySqlConnection"/> object to use for the command</param>
+ /// <param name="transaction"><see cref="MySqlTransaction"/> object to use for the command</param>
+ /// <param name="commandText">Command text to use</param>
+ /// <param name="commandParameters">Array of <see cref="MySqlParameter"/> objects to use with the command</param>
+ /// <param name="ExternalConn">True if the connection should be preserved, false if not</param>
+ /// <returns><see cref="MySqlDataReader"/> object ready to read the results of the command</returns>
private static MySqlDataReader ExecuteReader(MySqlConnection connection, MySqlTransaction transaction, string commandText, MySqlParameter[] commandParameters, bool ExternalConn )
{
//create a command and prepare it for execution
@@ -152,12 +226,25 @@ namespace ByteFX.Data.MySqlClient
return dr;
}
+ /// <summary>
+ /// Executes a single command against a MySQL database.
+ /// </summary>
+ /// <param name="connectionString">Settings to use for this command</param>
+ /// <param name="commandText">Command text to use</param>
+ /// <returns><see cref="MySqlDataReader"/> object ready to read the results of the command</returns>
public static MySqlDataReader ExecuteReader(string connectionString, string commandText)
{
//pass through the call providing null for the set of SqlParameters
return ExecuteReader(connectionString, commandText, (MySqlParameter[])null);
}
+ /// <summary>
+ /// Executes a single command against a MySQL database.
+ /// </summary>
+ /// <param name="connectionString">Settings to use for this command</param>
+ /// <param name="commandText">Command text to use</param>
+ /// <param name="commandParameters">Array of <see cref="MySqlParameter"/> objects to use with the command</param>
+ /// <returns><see cref="MySqlDataReader"/> object ready to read the results of the command</returns>
public static MySqlDataReader ExecuteReader(string connectionString, string commandText, params MySqlParameter[] commandParameters)
{
//create & open a SqlConnection
@@ -179,12 +266,26 @@ namespace ByteFX.Data.MySqlClient
#endregion
#region ExecuteScalar
+
+ /// <summary>
+ /// Execute a single command against a MySQL database.
+ /// </summary>
+ /// <param name="connectionString">Settings to use for the update</param>
+ /// <param name="commandText">Command text to use for the update</param>
+ /// <returns>The first column of the first row in the result set, or a null reference if the result set is empty.</returns>
public static object ExecuteScalar(string connectionString, string commandText)
{
//pass through the call providing null for the set of MySqlParameters
return ExecuteScalar(connectionString, commandText, (MySqlParameter[])null);
}
+ /// <summary>
+ /// Execute a single command against a MySQL database.
+ /// </summary>
+ /// <param name="connectionString">Settings to use for the command</param>
+ /// <param name="commandText">Command text to use for the command</param>
+ /// <param name="commandParameters">Parameters to use for the command</param>
+ /// <returns>The first column of the first row in the result set, or a null reference if the result set is empty.</returns>
public static object ExecuteScalar(string connectionString, string commandText, params MySqlParameter[] commandParameters)
{
//create & open a SqlConnection, and dispose of it after we are done.
@@ -197,12 +298,25 @@ namespace ByteFX.Data.MySqlClient
}
}
+ /// <summary>
+ /// Execute a single command against a MySQL database.
+ /// </summary>
+ /// <param name="connection"><see cref="MySqlConnection"/> object to use</param>
+ /// <param name="commandText">Command text to use for the command</param>
+ /// <returns>The first column of the first row in the result set, or a null reference if the result set is empty.</returns>
public static object ExecuteScalar(MySqlConnection connection, string commandText)
{
//pass through the call providing null for the set of MySqlParameters
return ExecuteScalar(connection, commandText, (MySqlParameter[])null);
}
+ /// <summary>
+ /// Execute a single command against a MySQL database.
+ /// </summary>
+ /// <param name="connection"><see cref="MySqlConnection"/> object to use</param>
+ /// <param name="commandText">Command text to use for the command</param>
+ /// <param name="commandParameters">Parameters to use for the command</param>
+ /// <returns>The first column of the first row in the result set, or a null reference if the result set is empty.</returns>
public static object ExecuteScalar(MySqlConnection connection, string commandText, params MySqlParameter[] commandParameters)
{
//create a command and prepare it for execution
diff --git a/mcs/class/ByteFX.Data/mysqlclient/MySqlPool.cs b/mcs/class/ByteFX.Data/mysqlclient/MySqlPool.cs
index 718fd53592e..bc4828c5e19 100644
--- a/mcs/class/ByteFX.Data/mysqlclient/MySqlPool.cs
+++ b/mcs/class/ByteFX.Data/mysqlclient/MySqlPool.cs
@@ -9,26 +9,43 @@ namespace ByteFX.Data.MySqlClient
/// </summary>
internal sealed class MySqlPool
{
- private ArrayList inUsePool;
- private ArrayList idlePool;
- private int minSize;
- private int maxSize;
+ private ArrayList inUsePool;
+ private ArrayList idlePool;
+ private MySqlConnectionString settings;
+ private int minSize;
+ private int maxSize;
- public MySqlPool(int minSize, int maxSize)
+ public MySqlPool(MySqlConnectionString settings)
+ {
+ minSize = settings.MinPoolSize;
+ maxSize = settings.MaxPoolSize;
+ this.settings = settings;
+ inUsePool =new ArrayList();
+ idlePool = new ArrayList( settings.MinPoolSize );
+
+ // prepopulate the idle pool to minSize
+ for (int i=0; i < minSize; i++)
+ CreateNewPooledConnection();
+ }
+
+ private void CheckOutConnection(MySqlInternalConnection conn)
{
- this.minSize = minSize;
- this.maxSize = maxSize;
- inUsePool =new ArrayList(minSize);
- idlePool = new ArrayList(minSize);
}
private MySqlInternalConnection GetPooledConnection()
{
+ MySqlInternalConnection conn = null;
+
+ // if there are no idle connections and the in use pool is full
+ // then return null to indicate that we cannot provide a connection
+ // at this time.
+ if (idlePool.Count == 0 && inUsePool.Count == maxSize) return null;
+
lock (idlePool.SyncRoot)
{
for (int i=idlePool.Count-1; i >=0; i--)
{
- MySqlInternalConnection conn = (idlePool[i] as MySqlInternalConnection);
+ conn = (idlePool[i] as MySqlInternalConnection);
if (conn.IsAlive())
{
lock (inUsePool)
@@ -45,20 +62,44 @@ namespace ByteFX.Data.MySqlClient
}
}
}
- return null;
+
+ // if we couldn't get a pooled connection and there is still room
+ // make a new one
+ if (conn == null && (idlePool.Count+inUsePool.Count) < maxSize)
+ {
+ conn = CreateNewPooledConnection();
+ if (conn == null) return null;
+
+ lock (idlePool.SyncRoot)
+ lock (inUsePool.SyncRoot)
+ {
+ idlePool.Remove( conn );
+ inUsePool.Add( conn );
+ }
+ }
+
+ return conn;
}
- private MySqlInternalConnection CreateNewPooledConnection( MySqlConnectionString settings )
+ private MySqlInternalConnection CreateNewPooledConnection()
{
- MySqlInternalConnection conn = new MySqlInternalConnection( settings );
- conn.Open();
- return conn;
+ lock(idlePool.SyncRoot)
+ lock (inUsePool.SyncRoot)
+ {
+ // first we check if we are allowed to create another
+ if ((inUsePool.Count + idlePool.Count) == maxSize) return null;
+
+ MySqlInternalConnection conn = new MySqlInternalConnection( settings );
+ conn.Open();
+ idlePool.Add( conn );
+ return conn;
+ }
}
public void ReleaseConnection( MySqlInternalConnection connection )
{
- lock (inUsePool.SyncRoot)
- lock (idlePool.SyncRoot)
+ lock (idlePool.SyncRoot)
+ lock (inUsePool.SyncRoot)
{
inUsePool.Remove( connection );
if (connection.Settings.ConnectionLifetime != 0 && connection.IsTooOld())
@@ -68,20 +109,16 @@ namespace ByteFX.Data.MySqlClient
}
}
- public MySqlInternalConnection GetConnection(MySqlConnectionString settings)
+ public MySqlInternalConnection GetConnection()
{
- MySqlInternalConnection conn;
+ MySqlInternalConnection conn = null;
- DateTime start = DateTime.Now;
- TimeSpan ts;
- do
- {
- conn = GetPooledConnection();
- if (conn == null)
- conn = CreateNewPooledConnection( settings );
- ts = DateTime.Now.Subtract( start );
- } while (conn == null && ts.Seconds < settings.ConnectTimeout );
+ int start = Environment.TickCount;
+ int ticks = settings.ConnectTimeout * 1000;
+ // wait timeOut seconds at most to get a connection
+ while (conn == null && (Environment.TickCount - start) < ticks)
+ conn = GetPooledConnection();
// if pool size is at maximum, then we must have reached our timeout so we simply
// throw our exception
diff --git a/mcs/class/ByteFX.Data/mysqlclient/MySqlPoolManager.cs b/mcs/class/ByteFX.Data/mysqlclient/MySqlPoolManager.cs
index acc6eba4d35..d1b418476ef 100644
--- a/mcs/class/ByteFX.Data/mysqlclient/MySqlPoolManager.cs
+++ b/mcs/class/ByteFX.Data/mysqlclient/MySqlPoolManager.cs
@@ -36,7 +36,7 @@ namespace ByteFX.Data.MySqlClient
MySqlPool pool;
if (!pools.Contains( text ))
{
- pool = new MySqlPool( settings.MinPoolSize, settings.MaxPoolSize );
+ pool = new MySqlPool( settings );
pools.Add( text, pool );
}
else
@@ -44,7 +44,7 @@ namespace ByteFX.Data.MySqlClient
pool = (pools[text] as MySqlPool);
}
- return pool.GetConnection( settings );
+ return pool.GetConnection();
}
}
diff --git a/mcs/class/ByteFX.Data/mysqlclient/MySqlStream.cs b/mcs/class/ByteFX.Data/mysqlclient/MySqlStream.cs
index a7d33ec9230..faa027765a6 100644
--- a/mcs/class/ByteFX.Data/mysqlclient/MySqlStream.cs
+++ b/mcs/class/ByteFX.Data/mysqlclient/MySqlStream.cs
@@ -20,124 +20,96 @@ using System.IO;
using System.Net;
using System.Net.Sockets;
using ByteFX.Data.Common;
+using System.Threading;
namespace ByteFX.Data.MySqlClient
{
/// <summary>
/// Summary description for API.
/// </summary>
- internal class MySqlStream : Stream
+ internal class MySqlStream : MultiHostStream
{
- Stream stream;
- Socket socket;
- int timeOut;
+ public MySqlStream( string hostList, int port, int readTimeOut, int connectTimeOut ) :
+ base( hostList, port, readTimeOut, connectTimeOut )
- public MySqlStream( string host, int port, int timeout )
{
- if (port == -1)
- Create( host );
- else
- Create( host, port );
- timeOut = timeout;
}
- private void Create( string host, int port )
+ protected override void Error(string msg)
{
- socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
- IPHostEntry he = Dns.GetHostByName( host );
- IPEndPoint serverAddr = new IPEndPoint(he.AddressList[0], port);
-
- socket.Connect(serverAddr);
- stream = new NetworkStream(socket, true);
+ throw new MySqlException( msg, baseException );
}
- private void Create( string host )
+ protected override void TimeOut(MultiHostStreamErrorType error)
{
- string pipeName;
-
- if (host.ToLower().Equals("localhost"))
- pipeName = @"\\.\pipe\MySql";
- else
- pipeName = String.Format(@"\\{0}\pipe\MySql", host);
-
- stream = new ByteFX.Data.Common.NamedPipeStream(pipeName, FileAccess.ReadWrite);
- }
-
- public bool DataAvailable
- {
- get
+ switch (error)
{
- if (stream is NetworkStream)
- return ((NetworkStream)stream).DataAvailable;
- else return (stream as NamedPipeStream).DataAvailable;
+ case MultiHostStreamErrorType.Connecting:
+ throw new MySqlException("Timed out creating a new MySqlConnection");
+ case MultiHostStreamErrorType.Reading:
+ throw new MySqlException("Timed out reading from MySql");
}
- }
-
- public override bool CanRead
- {
- get { return stream.CanRead; }
- }
-
- public override bool CanWrite
- {
- get { return stream.CanWrite; }
}
- public override bool CanSeek
+ protected override bool CreateStream( IPAddress ip, string hostname, int port )
{
- get { return stream.CanSeek; }
+ if (port == -1)
+ return CreatePipeStream(ip, hostname);
+ else
+ return CreateSocketStream(ip, port);
}
- public override long Length
+ private bool CreatePipeStream( IPAddress ip, string hostname )
{
- get { return stream.Length; }
- }
+ string pipeName;
- public override long Position
- {
- get { return stream.Position; }
- set { stream.Position = value; }
- }
+ if (hostname.ToLower().Equals("localhost"))
+ pipeName = @"\\.\pipe\MySql";
+ else
+ pipeName = String.Format(@"\\{0}\pipe\MySql", ip.ToString());
- public override void Flush()
- {
- stream.Flush();
+ try
+ {
+ stream = new NamedPipeStream(pipeName, FileAccess.ReadWrite);
+ return true;
+ }
+ catch (Exception ex)
+ {
+ baseException = ex;
+ return false;
+ }
}
- public override int ReadByte()
+ private bool CreateSocketStream( IPAddress ip, int port )
{
- long start = Environment.TickCount;
- long timeout_ticks = timeOut * TimeSpan.TicksPerSecond;
+ Socket socket = new Socket(AddressFamily.InterNetwork,
+ SocketType.Stream, ProtocolType.Tcp);
- while (((Environment.TickCount - start) < timeout_ticks))
+ try
{
- if (DataAvailable)
- {
- int b = stream.ReadByte();
- return b;
- }
+ //
+ // Lets try to connect
+ IPEndPoint endPoint = new IPEndPoint( ip, port);
+ socket.Connect(endPoint);
+ socket.SetSocketOption( SocketOptionLevel.Tcp, SocketOptionName.NoDelay, 1 );
+ stream = new NetworkStream( socket, true );
+ return true;
+ }
+ catch (Exception ex)
+ {
+ baseException = ex;
+ return false;
}
- throw new Exception("Timeout waiting for response from server");
}
- public override int Read(byte[] buffer, int offset, int count)
+ protected override bool DataAvailable
{
- long start = Environment.TickCount;
- int numToRead = count;
- long timeout_ticks = timeOut * TimeSpan.TicksPerSecond;
-
- while (numToRead > 0 && ((Environment.TickCount - start) < timeout_ticks))
+ get
{
- if (DataAvailable)
- {
- int bytes_read = stream.Read(buffer, offset, numToRead);
- offset += bytes_read;
- numToRead -= bytes_read;
- }
+ if (stream is NetworkStream)
+ return ((NetworkStream)stream).DataAvailable;
+ else return (stream as NamedPipeStream).DataAvailable;
}
- if (numToRead > 0)
- throw new Exception("Timeout waiting for response from server");
- return count;
}
public int ReadInt24()
@@ -152,20 +124,6 @@ namespace ByteFX.Data.MySqlClient
stream.Close();
}
- public override void SetLength(long length)
- {
- stream.SetLength( length );
- }
-
- public override void Write(byte[] buffer, int offset, int count)
- {
- stream.Write( buffer, offset, count );
- }
-
- public override long Seek( long offset, SeekOrigin origin )
- {
- return stream.Seek( offset, origin );
- }
}
}
diff --git a/mcs/class/ByteFX.Data/mysqlclient/MysqlDefs.cs b/mcs/class/ByteFX.Data/mysqlclient/MysqlDefs.cs
index eed7d80ad0d..570e48eeb8d 100755
--- a/mcs/class/ByteFX.Data/mysqlclient/MysqlDefs.cs
+++ b/mcs/class/ByteFX.Data/mysqlclient/MysqlDefs.cs
@@ -69,30 +69,62 @@ namespace ByteFX.Data.MySqlClient
CHANGE_USER = 17,
}
+ /// <summary>
+ /// Specifies MySQL specific data type of a field, property, for use in a <see cref="MySqlParameter"/>.
+ /// </summary>
public enum MySqlDbType
{
- Decimal = 0,
- Byte = 1,
+ /// <summary> <see cref="Decimal"/><para>A fixed precision and scale numeric value between -1038 -1 and 10 38 -1.</para></summary>
+ Decimal = 0,
+ /// <summary> <see cref="Byte"/><para>The signed range is -128 to 127. The unsigned range is 0 to 255.</para></summary>
+ Byte = 1,
+ /// <summary><see cref="Int16"/><para>A 16-bit signed or unsigned integer. The signed range is -32768 to 32767. The unsigned range is 0 to 65535</para></summary>
Short = 2,
+ /// <summary><see cref="Int32"/><para>A 32-bit signed or unsigned integer</para></summary>
+ Int = 3,
+ /// <summary><b>Obsolete</b> Please use Int for 32 bit values</summary>
+ [Obsolete("Long is no longer the correct way of specifying a 32 bit value. Use Int")]
Long = 3,
+ /// <summary><see cref="Single"/><para>A small (single-precision) floating-point number. Allowable values are -3.402823466E+38 to -1.175494351E-38, 0, and 1.175494351E-38 to 3.402823466E+38.</para></summary>
Float = 4,
+ /// <summary><see cref="Double"/><para>A normal-size (double-precision) floating-point number. Allowable values are -1.7976931348623157E+308 to -2.2250738585072014E-308, 0, and 2.2250738585072014E-308 to 1.7976931348623157E+308.</para></summary>
Double = 5,
+ /// <summary>Specifies a null value</summary>
Null = 6,
+ /// <summary>A timestamp. The range is '1970-01-01 00:00:00' to sometime in the year 2037</summary>
Timestamp = 7,
+ /// <summary><see cref="Int64"/><para>A 64-bit signed or unsigned integer.</para></summary>
+ BigInt = 8,
+ /// <summary><b>Obsolete</b> Please use BigInt for 64 bit values</summary>
+ [Obsolete("LongLong is no longer the correct way of specifying a 64 bit value. Use BigInt")]
LongLong = 8,
+ /// <summary>Specifies a 24 (3 byte) signed or unsigned value.</summary>
Int24 = 9,
+ ///<summary>Date The supported range is '1000-01-01' to '9999-12-31'.</summary>
Date = 10,
+ /// <summary> Time <para>The range is '-838:59:59' to '838:59:59'.</para></summary>
Time = 11,
- Datetime = 12,
+ ///<summary>DateTime The supported range is '1000-01-01 00:00:00' to '9999-12-31 23:59:59'.</summary>
+ Datetime = 12,
+ /// <summary>A year in 2- or 4-digit format (default is 4-digit). The allowable values are 1901 to 2155, 0000 in the 4-digit year format, and 1970-2069 if you use the 2-digit format (70-69)</summary>
Year = 13,
+ /// <summary><b>Obsolete</b> Use Datetime or Date type</summary>
Newdate = 14,
+ /// <summary>An enumeration. A string object that can have only one value, chosen from the list of values 'value1', 'value2', ..., NULL or the special "" error value. An ENUM can have a maximum of 65535 distinct values</summary>
Enum = 247,
+ /// <summary>A set. A string object that can have zero or more values, each of which must be chosen from the list of values 'value1', 'value2', ... A SET can have a maximum of 64 members.</summary>
Set = 248,
+ /// <summary>A BLOB or TEXT column with a maximum length of 255 (2^8 - 1) characters</summary>
TinyBlob = 249,
+ /// <summary>A BLOB or TEXT column with a maximum length of 16777215 (2^24 - 1) characters</summary>
MediumBlob = 250,
+ /// <summary>A BLOB or TEXT column with a maximum length of 4294967295 or 4G (2^32 - 1) characters</summary>
LongBlob = 251,
+ /// <summary>A BLOB or TEXT column with a maximum length of 65535 (2^16 - 1) characters</summary>
Blob = 252,
+ /// <summary>A variable-length string containing 0 to 255 characters</summary>
VarChar = 253,
+ /// <summary><b>Obsolete</b> Use VarChar type</summary>
String = 254
};
diff --git a/mcs/class/ByteFX.Data/mysqlclient/Packet.cs b/mcs/class/ByteFX.Data/mysqlclient/Packet.cs
index 25634989768..ca4685e93df 100644
--- a/mcs/class/ByteFX.Data/mysqlclient/Packet.cs
+++ b/mcs/class/ByteFX.Data/mysqlclient/Packet.cs
@@ -4,7 +4,7 @@ using System.Text;
namespace ByteFX.Data.MySqlClient
{
- internal enum PacketType
+/* internal enum PacketType
{
None,
UpdateOrOk,
@@ -14,32 +14,28 @@ namespace ByteFX.Data.MySqlClient
Error,
LoadDataLocal,
Other
- }
+ }*/
/// <summary>
/// Summary description for Packet.
/// </summary>
- internal class Packet
+ internal class Packet : MemoryStream
{
- MemoryStream data;
- PacketType type = PacketType.None;
Encoding encoding;
+ private static int HEADER_LEN = 7;
- public Packet()
+ public Packet() : base(256+HEADER_LEN)
{
- data = new MemoryStream();
+ Position = HEADER_LEN;
}
- public Packet(int len)
+ public Packet(int len) : base(len+HEADER_LEN)
{
- data = new MemoryStream(len);
+ Position = HEADER_LEN;
}
- public Packet(byte[] bytes)
+ public Packet(byte[] bytes) : base(bytes, 0, bytes.Length, true, true)
{
- data = new MemoryStream( bytes.Length );
- data.Write( bytes, 0, bytes.Length );
- data.Position = 0;
}
public Encoding Encoding
@@ -48,73 +44,30 @@ namespace ByteFX.Data.MySqlClient
get { return encoding; }
}
- public int Length
- {
- get { return (int)data.Length; }
- }
-
- public PacketType Type
- {
- get { if (type == PacketType.None) ParseType(); return type; }
- set { type = value; }
- }
-
- public long Position
- {
- get { return data.Position; }
- set { data.Position = value; }
- }
-
- public void AppendPacket( Packet newPacket )
- {
- data.Position = data.Length;
- byte[] bytes = newPacket.GetBytes();
- data.Write( bytes, 0, bytes.Length );
- }
-
- private PacketType ParseType()
- {
- byte b = ReadByte();
-
- // a 1 byte packet with byte 0xfe means last packet
- if ( data.Length == 1 && b == 0xfe)
- type = PacketType.Last;
-
- // a first byte of 0xff means the packet is an error message
- else if ( b == 0xff )
- type = PacketType.Error;
-
- // the first byte == 0 means an update packet or column count
- else if ( b == 0 )
- type = PacketType.UpdateOrOk;
- else
- type = PacketType.Other;
- return type;
- }
-
- public byte[] GetBytes()
- {
- return data.ToArray();
- }
-
- public void WriteByte( byte b )
+ public byte this[int index]
{
- data.WriteByte( b );
+ get { return GetBuffer()[index]; }
}
- public byte ReadByte()
+ public new int Length
{
- return (byte)data.ReadByte();
+ get { return (int)base.Length; }
}
- public void ReadBytes( byte[] buffer, int offset, int len )
+ public bool IsLastPacket()
{
- data.Read( buffer, offset, len );
+ if (Length == 1 && this[0] == 0xfe) return true;
+ return false;
}
- public void WriteBytes( byte[] bytes, int offset, int len )
+ public byte[] GetBytes( byte packetSeq )
{
- data.Write( bytes, offset, len );
+ long oldPos = Position;
+ Position = 3;
+ WriteInteger( Length-HEADER_LEN, 3 );
+ WriteByte( packetSeq );
+ Position = oldPos;
+ return GetBuffer();
}
public int ReadNBytes()
@@ -129,7 +82,7 @@ namespace ByteFX.Data.MySqlClient
int len = ReadLenInteger();
byte[] buffer = new Byte[len];
- ReadBytes(buffer, 0, len);
+ Read(buffer, 0, len);
return encoding.GetString( buffer, 0, len);
}
@@ -148,7 +101,7 @@ namespace ByteFX.Data.MySqlClient
for (int x=0; x < numbytes; x++)
{
- data.WriteByte( (byte)(val&0xff) );
+ WriteByte( (byte)(val&0xff) );
val >>= 8;
}
}
@@ -164,7 +117,7 @@ namespace ByteFX.Data.MySqlClient
int raise = 1;
for (int x=0; x < numbytes; x++)
{
- int b = data.ReadByte();
+ int b = ReadByte();
val += (b*raise);
raise *= 256;
}
@@ -189,9 +142,9 @@ namespace ByteFX.Data.MySqlClient
}
}
- public bool CanRead
+ public bool HasMoreData
{
- get { return data.Position < data.Length; }
+ get { return Position < Length; }
}
#region String Functions
@@ -199,9 +152,9 @@ namespace ByteFX.Data.MySqlClient
{
System.Text.StringBuilder sb = new System.Text.StringBuilder();
- while ( CanRead )
+ while ( HasMoreData )
{
- byte b = ReadByte();
+ byte b = (byte)ReadByte();
if (b == 0) break;
sb.Append( Convert.ToChar( b ));
}
@@ -212,13 +165,13 @@ namespace ByteFX.Data.MySqlClient
public void WriteString(string v, Encoding encoding)
{
WriteStringNoNull(v, encoding);
- data.WriteByte(0);
+ WriteByte(0);
}
public void WriteStringNoNull(string v, Encoding encoding)
{
byte[] bytes = encoding.GetBytes(v);
- data.Write(bytes, 0, bytes.Length);
+ Write(bytes, 0, bytes.Length);
}
#endregion
diff --git a/mcs/class/ByteFX.Data/mysqlclient/command.cs b/mcs/class/ByteFX.Data/mysqlclient/command.cs
index 0a1224afea1..1dd3a20e5f2 100755
--- a/mcs/class/ByteFX.Data/mysqlclient/command.cs
+++ b/mcs/class/ByteFX.Data/mysqlclient/command.cs
@@ -22,10 +22,13 @@ using System.Collections;
namespace ByteFX.Data.MySqlClient
{
+ /// <summary>
+ /// Represents a SQL statement to execute against a MySQL database. This class cannot be inherited.
+ /// </summary>
+ /// <include file='docs/MySqlCommand.xml' path='MyDocs/MyMembers[@name="Class"]/*'/>
#if WINDOWS
[System.Drawing.ToolboxBitmap( typeof(MySqlCommand), "Designers.command.bmp")]
#endif
-
[System.ComponentModel.DesignerCategory("Code")]
public sealed class MySqlCommand : Component, IDbCommand, ICloneable
{
@@ -44,31 +47,43 @@ namespace ByteFX.Data.MySqlClient
{
}
- // Implement other constructors here.
+ /// <summary>
+ /// Overloaded. Initializes a new instance of the MySqlCommand class.
+ /// </summary>
public MySqlCommand(string cmdText)
{
this.cmdText = cmdText;
}
+ /// <summary>
+ /// Overloaded. Initializes a new instance of the MySqlCommand class.
+ /// </summary>
public MySqlCommand(System.ComponentModel.IContainer container)
{
- /// <summary>
- /// Required for Windows.Forms Class Composition Designer support
- /// </summary>
+ // Required for Windows.Forms Class Composition Designer support
container.Add(this);
}
+ /// <summary>
+ /// Overloaded. Initializes a new instance of the MySqlCommand class.
+ /// </summary>
public MySqlCommand(string cmdText, MySqlConnection connection)
{
this.cmdText = cmdText;
this.connection = connection;
}
+ /// <summary>
+ /// Disposes of this instance of MySqlCommand
+ /// </summary>
public new void Dispose()
{
base.Dispose();
}
+ /// <summary>
+ /// Overloaded. Initializes a new instance of the MySqlCommand class.
+ /// </summary>
public MySqlCommand(string cmdText, MySqlConnection connection, MySqlTransaction txn)
{
this.cmdText = cmdText;
@@ -92,7 +107,7 @@ namespace ByteFX.Data.MySqlClient
set { cmdText = value; }
}
- public int UpdateCount
+ internal int UpdateCount
{
get { return updateCount; }
}
@@ -207,6 +222,10 @@ namespace ByteFX.Data.MySqlClient
#endregion
#region Methods
+ /// <summary>
+ /// Attempts to cancel the execution of a MySqlCommand. This operation is not supported.
+ /// </summary>
+ /// <exception cref="NotSupportedException">This operation is not supported.</exception>
public void Cancel()
{
throw new NotSupportedException();
@@ -229,7 +248,7 @@ namespace ByteFX.Data.MySqlClient
private ArrayList SplitSql(string sql)
{
ArrayList commands = new ArrayList();
- System.IO.MemoryStream ms = new System.IO.MemoryStream();
+ System.IO.MemoryStream ms = new System.IO.MemoryStream(sql.Length);
// first we tack on a semi-colon, if not already there, to make our
// sql processing code easier. Then we ask our encoder to give us
@@ -292,7 +311,7 @@ namespace ByteFX.Data.MySqlClient
if (cmdByte != ' ') { goodcmd = true; break; }
if (goodcmd)
- commands.Add( ms.ToArray() );
+ commands.Add( byteArray );
ms.SetLength(0);
}
else if (parm_start == -1)
@@ -306,6 +325,21 @@ namespace ByteFX.Data.MySqlClient
return commands;
}
+ private void ReadOffResultSet()
+ {
+ Driver driver = connection.InternalConnection.Driver;
+
+ // first read off the schema
+ Packet packet = driver.ReadPacket();
+ while (! packet.IsLastPacket())
+ packet = driver.ReadPacket();
+
+ // now read off the data
+ packet = driver.ReadPacket();
+ while (! packet.IsLastPacket())
+ packet = driver.ReadPacket();
+ }
+
/// <summary>
/// Internal function to execute the next command in an array of commands
/// </summary>
@@ -318,16 +352,20 @@ namespace ByteFX.Data.MySqlClient
byte[] sql = (byte[])arraySql[0];
arraySql.RemoveAt(0);
- string s = connection.Encoding.GetString(sql);
- Packet packet = driver.SendSql( s );
- if (packet.Type == PacketType.UpdateOrOk)
+ Packet packet = driver.SendSql( sql );
+ byte b = (byte)packet.ReadByte();
+ if (b == 0)
+ {
+ if (updateCount == -1) updateCount = 0;
updateCount += (int)packet.ReadLenInteger();
- else if (packet.Type == PacketType.ResultSchema && stopAtResultSet)
+ }
+ else if (stopAtResultSet)
+ {
+ packet.Position--;
return packet;
- else do
- {
- packet = driver.ReadPacket();
- } while (packet.Type != PacketType.Last);
+ }
+ else
+ ReadOffResultSet();
}
return null;
}
@@ -347,7 +385,7 @@ namespace ByteFX.Data.MySqlClient
throw new MySqlException("There is already an open DataReader associated with this Connection which must be closed first.");
// execute any commands left in the queue from before.
- ExecuteBatch(false);
+ //ExecuteBatch(false);
arraySql = SplitSql( cmdText );
updateCount = 0;
@@ -376,14 +414,13 @@ namespace ByteFX.Data.MySqlClient
return ExecuteReader(CommandBehavior.Default);
}
+
+ /// <summary>
+ /// Overloaded. Sends the CommandText to the Connection and builds a MySqlDataReader.
+ /// </summary>
+ /// <returns></returns>
public MySqlDataReader ExecuteReader(CommandBehavior behavior)
{
- /*
- * ExecuteReader should retrieve results from the data source
- * and return a DataReader that allows the user to process
- * the results.
- */
-
// There must be a valid and open connection.
if (connection == null || connection.State != ConnectionState.Open)
throw new InvalidOperationException("Connection must be valid and open");
@@ -415,27 +452,15 @@ namespace ByteFX.Data.MySqlClient
sql = String.Format("SET SQL_SELECT_LIMIT=1;{0};SET sql_select_limit=-1;", cmdText);
}
- // execute any commands left in the queue from before.
- ExecuteBatch(false);
-
arraySql = SplitSql( sql );
+ updateCount = -1;
MySqlDataReader reader = new MySqlDataReader(this, behavior);
- try
- {
- if (reader.NextResult())
- {
- connection.Reader = reader;
- return reader;
- }
- return null;
- }
- catch (Exception e)
- {
- System.Diagnostics.Trace.WriteLine("Exception in ExecuteReader: " + e.Message);
- throw e;
- }
+ // move to the first resultset
+ reader.NextResult();
+ connection.Reader = reader;
+ return reader;
}
/// <summary>
@@ -453,11 +478,9 @@ namespace ByteFX.Data.MySqlClient
if (connection.Reader != null)
throw new MySqlException("There is already an open DataReader associated with this Connection which must be closed first.");
- // execute any commands left in the queue from before.
- ExecuteBatch(false);
-
arraySql = SplitSql( cmdText );
+ updateCount = -1;
MySqlDataReader reader = new MySqlDataReader(this, 0);
reader.NextResult();
object val = null;
@@ -477,12 +500,17 @@ namespace ByteFX.Data.MySqlClient
#endregion
#region ICloneable
+ /// <summary>
+ /// Creates a clone of this MySqlCommand object. CommandText, Connection, and Transaction properties
+ /// are included as well as the entire parameter list.
+ /// </summary>
+ /// <returns>The cloned MySqlCommand object</returns>
public object Clone()
{
MySqlCommand clone = new MySqlCommand(cmdText, connection, curTransaction);
foreach (MySqlParameter p in parameters)
{
- clone.Parameters.Add(p.Clone());
+ clone.Parameters.Add((p as ICloneable).Clone());
}
return clone;
}
diff --git a/mcs/class/ByteFX.Data/mysqlclient/dataadapter.cs b/mcs/class/ByteFX.Data/mysqlclient/dataadapter.cs
index e6e288177c3..80637834834 100755
--- a/mcs/class/ByteFX.Data/mysqlclient/dataadapter.cs
+++ b/mcs/class/ByteFX.Data/mysqlclient/dataadapter.cs
@@ -21,6 +21,10 @@ using System.ComponentModel;
namespace ByteFX.Data.MySqlClient
{
+ /// <summary>
+ /// Represents a set of data commands and a database connection that are used to fill a dataset and update a MySQL database. This class cannot be inherited.
+ /// </summary>
+ /// <include file='docs/MySqlDataAdapter.xml' path='MyDocs/MyMembers[@name="Class"]/*'/>
[System.Drawing.ToolboxBitmap( typeof(MySqlDataAdapter), "Designers.dataadapter.bmp")]
[System.ComponentModel.DesignerCategory("Code")]
public sealed class MySqlDataAdapter : DbDataAdapter, IDbDataAdapter
@@ -40,41 +44,63 @@ namespace ByteFX.Data.MySqlClient
static private readonly object EventRowUpdating = new object();
+ /// <summary>
+ /// Initializes a new instance of the MySqlDataAdapter class.
+ /// </summary>
public MySqlDataAdapter()
{
}
+ /// <summary>
+ /// Initializes a new instance of the MySqlDataAdapter class with the specified MySqlCommand as the SelectCommand property.
+ /// </summary>
+ /// <param name="selectCommand"></param>
public MySqlDataAdapter( MySqlCommand selectCommand )
{
SelectCommand = selectCommand;
}
- public MySqlDataAdapter( string selectCommandText, string selectConnString)
+ /// <summary>
+ /// Initializes a new instance of the MySqlDataAdapter class with a SelectCommand and a MySqlConnection object.
+ /// </summary>
+ /// <param name="selectCommandText"></param>
+ /// <param name="conn"></param>
+ public MySqlDataAdapter( string selectCommandText, MySqlConnection conn)
{
- SelectCommand = new MySqlCommand( selectCommandText,
- new MySqlConnection(selectConnString) );
+ SelectCommand = new MySqlCommand( selectCommandText, conn );
}
- public MySqlDataAdapter( string selectCommandText, MySqlConnection conn)
+ /// <summary>
+ /// Initializes a new instance of the MySqlDataAdapter class with a SelectCommand and a connection string.
+ /// </summary>
+ /// <param name="selectCommandText"></param>
+ /// <param name="selectConnString"></param>
+ public MySqlDataAdapter( string selectCommandText, string selectConnString)
{
- SelectCommand = new MySqlCommand( selectCommandText, conn );
+ SelectCommand = new MySqlCommand( selectCommandText,
+ new MySqlConnection(selectConnString) );
}
#region Properties
- [DataSysDescription("Used during Fill/FillSchema")]
- [Category("Fill")]
- public MySqlCommand SelectCommand
+ /// <summary>
+ /// Gets or sets a SQL statement to delete records from the data set.
+ /// </summary>
+ [DataSysDescription("Used during Update for deleted rows in Dataset.")]
+ public MySqlCommand DeleteCommand
{
- get { return m_selectCommand; }
- set { m_selectCommand = value; }
+ get { return m_deleteCommand; }
+ set { m_deleteCommand = value; }
}
- IDbCommand IDbDataAdapter.SelectCommand
+ IDbCommand IDbDataAdapter.DeleteCommand
{
- get { return m_selectCommand; }
- set { m_selectCommand = (MySqlCommand)value; }
+ get { return m_deleteCommand; }
+ set { m_deleteCommand = (MySqlCommand)value; }
}
+ /// <summary>
+ /// Gets or sets a SQL statement to insert new records into the data source.
+ /// </summary>
[DataSysDescription("Used during Update for new rows in Dataset.")]
public MySqlCommand InsertCommand
{
@@ -88,6 +114,26 @@ namespace ByteFX.Data.MySqlClient
set { m_insertCommand = (MySqlCommand)value; }
}
+ /// <summary>
+ /// Gets or sets a SQL statement used to select records in the data source.
+ /// </summary>
+ [DataSysDescription("Used during Fill/FillSchema")]
+ [Category("Fill")]
+ public MySqlCommand SelectCommand
+ {
+ get { return m_selectCommand; }
+ set { m_selectCommand = value; }
+ }
+
+ IDbCommand IDbDataAdapter.SelectCommand
+ {
+ get { return m_selectCommand; }
+ set { m_selectCommand = (MySqlCommand)value; }
+ }
+
+ /// <summary>
+ /// Gets or sets a SQL statement used to update records in the data source.
+ /// </summary>
[DataSysDescription("Used during Update for modified rows in Dataset.")]
public MySqlCommand UpdateCommand
{
@@ -101,33 +147,41 @@ namespace ByteFX.Data.MySqlClient
set { m_updateCommand = (MySqlCommand)value; }
}
- [DataSysDescription("Used during Update for deleted rows in Dataset.")]
- public MySqlCommand DeleteCommand
- {
- get { return m_deleteCommand; }
- set { m_deleteCommand = value; }
- }
-
- IDbCommand IDbDataAdapter.DeleteCommand
- {
- get { return m_deleteCommand; }
- set { m_deleteCommand = (MySqlCommand)value; }
- }
#endregion
/*
* Implement abstract methods inherited from DbDataAdapter.
*/
+ /// <summary>
+ /// Overridden. See <see cref="DbDataAdapter.CreateRowUpdatedEvent"/>.
+ /// </summary>
+ /// <param name="dataRow"></param>
+ /// <param name="command"></param>
+ /// <param name="statementType"></param>
+ /// <param name="tableMapping"></param>
+ /// <returns></returns>
override protected RowUpdatedEventArgs CreateRowUpdatedEvent(DataRow dataRow, IDbCommand command, StatementType statementType, DataTableMapping tableMapping)
{
return new MySqlRowUpdatedEventArgs(dataRow, command, statementType, tableMapping);
}
+ /// <summary>
+ /// Overridden. See <see cref="DbDataAdapter.CreateRowUpdatingEvent"/>.
+ /// </summary>
+ /// <param name="dataRow"></param>
+ /// <param name="command"></param>
+ /// <param name="statementType"></param>
+ /// <param name="tableMapping"></param>
+ /// <returns></returns>
override protected RowUpdatingEventArgs CreateRowUpdatingEvent(DataRow dataRow, IDbCommand command, StatementType statementType, DataTableMapping tableMapping)
{
return new MySqlRowUpdatingEventArgs(dataRow, command, statementType, tableMapping);
}
+ /// <summary>
+ /// Overridden. Raises the RowUpdating event.
+ /// </summary>
+ /// <param name="value">A MySqlRowUpdatingEventArgs that contains the event data.</param>
override protected void OnRowUpdating(RowUpdatingEventArgs value)
{
MySqlRowUpdatingEventHandler handler = (MySqlRowUpdatingEventHandler) Events[EventRowUpdating];
@@ -137,6 +191,10 @@ namespace ByteFX.Data.MySqlClient
}
}
+ /// <summary>
+ /// Overridden. Raises the RowUpdated event.
+ /// </summary>
+ /// <param name="value">A MySqlRowUpdatedEventArgs that contains the event data. </param>
override protected void OnRowUpdated(RowUpdatedEventArgs value)
{
MySqlRowUpdatedEventHandler handler = (MySqlRowUpdatedEventHandler) Events[EventRowUpdated];
@@ -146,12 +204,18 @@ namespace ByteFX.Data.MySqlClient
}
}
+ /// <summary>
+ /// Occurs during Update before a command is executed against the data source. The attempt to update is made, so the event fires.
+ /// </summary>
public event MySqlRowUpdatingEventHandler RowUpdating
{
add { Events.AddHandler(EventRowUpdating, value); }
remove { Events.RemoveHandler(EventRowUpdating, value); }
}
+ /// <summary>
+ /// Occurs during Update after a command is executed against the data source. The attempt to update is made, so the event fires.
+ /// </summary>
public event MySqlRowUpdatedEventHandler RowUpdated
{
add { Events.AddHandler(EventRowUpdated, value); }
@@ -159,17 +223,36 @@ namespace ByteFX.Data.MySqlClient
}
}
+ /// <summary>
+ /// Represents the method that will handle the <see cref="MySqlDataAdapter.RowUpdating"/> event of a <see cref="MySqlDataAdapter"/>.
+ /// </summary>
public delegate void MySqlRowUpdatingEventHandler(object sender, MySqlRowUpdatingEventArgs e);
+
+ /// <summary>
+ /// Represents the method that will handle the <see cref="MySqlDataAdapter.RowUpdated"/> event of a <see cref="MySqlDataAdapter"/>.
+ /// </summary>
public delegate void MySqlRowUpdatedEventHandler(object sender, MySqlRowUpdatedEventArgs e);
- public class MySqlRowUpdatingEventArgs : RowUpdatingEventArgs
+ /// <summary>
+ /// Provides data for the RowUpdating event. This class cannot be inherited.
+ /// </summary>
+ public sealed class MySqlRowUpdatingEventArgs : RowUpdatingEventArgs
{
+ /// <summary>
+ /// Initializes a new instance of the MySqlRowUpdatingEventArgs class.
+ /// </summary>
+ /// <param name="row">The <see cref="DataRow"/> to <see cref="DbDataAdapter.Update"/>.</param>
+ /// <param name="command">The <see cref="IDbCommand"/> to execute during <see cref="DbDataAdapter.Update"/>.</param>
+ /// <param name="statementType">One of the <see cref="StatementType"/> values that specifies the type of query executed.</param>
+ /// <param name="tableMapping">The <see cref="DataTableMapping"/> sent through an <see cref="DbDataAdapter.Update"/>.</param>
public MySqlRowUpdatingEventArgs(DataRow row, IDbCommand command, StatementType statementType, DataTableMapping tableMapping)
: base(row, command, statementType, tableMapping)
{
}
- // Hide the inherited implementation of the command property.
+ /// <summary>
+ /// Gets or sets the MySqlCommand to execute when performing the Update.
+ /// </summary>
new public MySqlCommand Command
{
get { return (MySqlCommand)base.Command; }
@@ -177,14 +260,26 @@ namespace ByteFX.Data.MySqlClient
}
}
- public class MySqlRowUpdatedEventArgs : RowUpdatedEventArgs
+ /// <summary>
+ /// Provides data for the RowUpdated event. This class cannot be inherited.
+ /// </summary>
+ public sealed class MySqlRowUpdatedEventArgs : RowUpdatedEventArgs
{
+ /// <summary>
+ /// Initializes a new instance of the MySqlRowUpdatedEventArgs class.
+ /// </summary>
+ /// <param name="row">The <see cref="DataRow"/> sent through an <see cref="DbDataAdapter.Update"/>.</param>
+ /// <param name="command">The <see cref="IDbCommand"/> executed when <see cref="DbDataAdapter.Update"/> is called.</param>
+ /// <param name="statementType">One of the <see cref="StatementType"/> values that specifies the type of query executed.</param>
+ /// <param name="tableMapping">The <see cref="DataTableMapping"/> sent through an <see cref="DbDataAdapter.Update"/>.</param>
public MySqlRowUpdatedEventArgs(DataRow row, IDbCommand command, StatementType statementType, DataTableMapping tableMapping)
: base(row, command, statementType, tableMapping)
{
}
- // Hide the inherited implementation of the command property.
+ /// <summary>
+ /// Gets or sets the MySqlCommand executed when Update is called.
+ /// </summary>
new public MySqlCommand Command
{
get { return (MySqlCommand)base.Command; }
diff --git a/mcs/class/ByteFX.Data/mysqlclient/datareader.cs b/mcs/class/ByteFX.Data/mysqlclient/datareader.cs
index 1f4a3c6272d..bc166c53253 100755
--- a/mcs/class/ByteFX.Data/mysqlclient/datareader.cs
+++ b/mcs/class/ByteFX.Data/mysqlclient/datareader.cs
@@ -21,6 +21,10 @@ using System.Collections;
namespace ByteFX.Data.MySqlClient
{
+ /// <summary>
+ /// Provides a means of reading a forward-only stream of rows from a MySQL database. This class cannot be inherited.
+ /// </summary>
+ /// <include file='docs/MySqlDataReader.xml' path='MyDocs/MyMembers[@name="Class"]/*'/>
public sealed class MySqlDataReader : MarshalByRefObject, IEnumerable, IDataReader, IDisposable, IDataRecord
{
// The DataReader should always be open when returned to the user.
@@ -33,7 +37,6 @@ namespace ByteFX.Data.MySqlClient
private MySqlCommand command;
private bool canRead;
private bool hasRows;
-// private Packet rowPacket = null;
/*
* Keep track of the connection in order to implement the
@@ -54,14 +57,12 @@ namespace ByteFX.Data.MySqlClient
commandBehavior = behavior;
}
- /****
- * METHODS / PROPERTIES FROM IDataReader.
- ****/
+ /// <summary>
+ /// Gets a value indicating the depth of nesting for the current row. This method is not
+ /// supported currently and always returns 0.
+ /// </summary>
public int Depth
{
- /*
- * Always return a value of zero if nesting is not supported.
- */
get { return 0; }
}
@@ -73,7 +74,7 @@ namespace ByteFX.Data.MySqlClient
get { return ! isOpen; }
}
- public void Dispose()
+ void IDisposable.Dispose()
{
if (isOpen)
Close();
@@ -146,6 +147,10 @@ namespace ByteFX.Data.MySqlClient
}
}
+ /// <summary>
+ /// Gets the value of a column in its native format.
+ /// [C#] In C#, this property is the indexer for the MySqlDataReader class.
+ /// </summary>
public object this [ String name ]
{
// Look up the ordinal and return
@@ -183,13 +188,13 @@ namespace ByteFX.Data.MySqlClient
/// <summary>
/// Reads a stream of bytes from the specified column offset into the buffer an array starting at the given buffer offset.
/// </summary>
- /// <param name="i"></param>
- /// <param name="fieldOffset"></param>
- /// <param name="buffer"></param>
- /// <param name="bufferoffset"></param>
- /// <param name="length"></param>
- /// <returns></returns>
- public long GetBytes(int i, long fieldOffset, byte[] buffer, int bufferoffset, int length)
+ /// <param name="i">The zero-based column ordinal. </param>
+ /// <param name="dataIndex">The index within the field from which to begin the read operation. </param>
+ /// <param name="buffer">The buffer into which to read the stream of bytes. </param>
+ /// <param name="bufferIndex">The index for buffer to begin the read operation. </param>
+ /// <param name="length">The maximum length to copy into the buffer. </param>
+ /// <returns>The actual number of bytes read.</returns>
+ public long GetBytes(int i, long dataIndex, byte[] buffer, int bufferIndex, int length)
{
if (i >= _fields.Length)
throw new IndexOutOfRangeException();
@@ -199,15 +204,15 @@ namespace ByteFX.Data.MySqlClient
if (buffer == null)
return bytes.Length;
- /// adjust the length so we don't run off the end
- if (bytes.Length < (fieldOffset+length))
+ // adjust the length so we don't run off the end
+ if (bytes.Length < (dataIndex+length))
{
- length = (int)(bytes.Length - fieldOffset);
+ length = (int)(bytes.Length - dataIndex);
}
for (int x=0; x < length; x++)
{
- buffer[bufferoffset+x] = bytes[fieldOffset+x];
+ buffer[bufferIndex+x] = bytes[dataIndex+x];
}
return length;
@@ -247,7 +252,7 @@ namespace ByteFX.Data.MySqlClient
if (buffer == null)
return chars.Length;
- /// adjust the length so we don't run off the end
+ // adjust the length so we don't run off the end
if (chars.Length < (fieldOffset+length))
{
length = (int)(chars.Length - fieldOffset);
@@ -547,13 +552,8 @@ namespace ByteFX.Data.MySqlClient
#endregion
- public IDataReader GetData(int i)
+ IDataReader IDataRecord.GetData(int i)
{
- /*
- * The sample code does not support this method. Normally,
- * this would be used to expose nested tables and
- * other hierarchical data.
- */
throw new NotSupportedException("GetData not supported.");
}
@@ -578,13 +578,19 @@ namespace ByteFX.Data.MySqlClient
Driver driver = connection.InternalConnection.Driver;
+ // clear any rows that have not been read from the last rowset
ClearCurrentResult();
- // tell our command to execute the next sql batch
+ // tell our command to continue execution of the SQL batch until it its
+ // another resultset
Packet packet = command.ExecuteBatch(true);
- // if there was no more batches, then signal done
- if (packet == null) return false;
+ // if there was no more resultsets, then signal done
+ if (packet == null)
+ {
+ canRead = false;
+ return false;
+ }
// When executing query statements, the result byte that is returned
// from MySql is the column count. That is why we reference the LastResult
@@ -594,14 +600,20 @@ namespace ByteFX.Data.MySqlClient
_fields = new MySqlField[ packet.ReadLenInteger() ];
for (int x=0; x < _fields.Length; x++)
{
+ packet = driver.ReadPacket();
_fields[x] = new MySqlField();
_fields[x].ReadSchemaInfo( packet );
}
+ // read off the end of schema packet
+ packet = driver.ReadPacket();
+ if ( ! packet.IsLastPacket())
+ throw new MySqlException("Expected end of schema packet");
+
// now take a quick peek at the next packet to see if we have rows
//
packet = driver.PeekPacket();
- hasRows = packet.Type != PacketType.Last;
+ hasRows = ! packet.IsLastPacket();
canRead = hasRows;
connection.SetState( ConnectionState.Open );
@@ -625,7 +637,7 @@ namespace ByteFX.Data.MySqlClient
try
{
Packet rowPacket = driver.ReadPacket();
- if (rowPacket.Type == PacketType.Last)
+ if (rowPacket.IsLastPacket())
{
canRead = false;
return false;
@@ -665,16 +677,18 @@ namespace ByteFX.Data.MySqlClient
{
if (! canRead) return;
- Packet packet = connection.InternalConnection.Driver.ReadPacket();
+ Driver driver = connection.InternalConnection.Driver;
+
+ Packet packet = driver.ReadPacket();
// clean out any current resultset
- while (packet.Type != PacketType.Last)
- packet = connection.InternalConnection.Driver.ReadPacket();
+ while (! packet.IsLastPacket())
+ packet = driver.ReadPacket();
}
#endregion
#region IEnumerator
- public IEnumerator GetEnumerator()
+ IEnumerator IEnumerable.GetEnumerator()
{
return new System.Data.Common.DbEnumerator(this);
}
diff --git a/mcs/class/ByteFX.Data/mysqlclient/parameter.cs b/mcs/class/ByteFX.Data/mysqlclient/parameter.cs
index 7bcc2552801..8ce6aed3d24 100755
--- a/mcs/class/ByteFX.Data/mysqlclient/parameter.cs
+++ b/mcs/class/ByteFX.Data/mysqlclient/parameter.cs
@@ -24,25 +24,37 @@ using System.Reflection;
namespace ByteFX.Data.MySqlClient
{
+ /// <summary>
+ /// Represents a parameter to a <see cref="MySqlCommand"/>, and optionally, its mapping to <see cref="DataSet"/> columns. This class cannot be inherited.
+ /// </summary>
[TypeConverter(typeof(MySqlParameter.MySqlParameterConverter))]
public sealed class MySqlParameter : MarshalByRefObject, IDataParameter, IDbDataParameter, ICloneable
{
- MySqlDbType dbType = MySqlDbType.Null;
- DbType genericType;
- ParameterDirection direction = ParameterDirection.Input;
- bool isNullable = false;
- string paramName;
- string sourceColumn;
- DataRowVersion sourceVersion = DataRowVersion.Current;
- object paramValue = DBNull.Value;
- int size;
- byte precision=0, scale=0;
+ private MySqlDbType dbType = MySqlDbType.Null;
+ private DbType genericType;
+ private ParameterDirection direction = ParameterDirection.Input;
+ private bool isNullable = false;
+ private string paramName;
+ private string sourceColumn;
+ private DataRowVersion sourceVersion = DataRowVersion.Current;
+ private object paramValue = DBNull.Value;
+ private int size;
+ private byte precision=0, scale=0;
#region Constructors
+
+ /// <summary>
+ /// Initializes a new instance of the MySqlParameter class.
+ /// </summary>
public MySqlParameter()
{
}
+ /// <summary>
+ /// Initializes a new instance of the <see cref="MySqlParameter"/> class with the parameter name and a value of the new MySqlParameter.
+ /// </summary>
+ /// <param name="parameterName">The name of the parameter to map. </param>
+ /// <param name="value">An <see cref="Object"/> that is the value of the <see cref="MySqlParameter"/>. </param>
public MySqlParameter(string parameterName, object value)
{
ParameterName = parameterName;
@@ -51,34 +63,54 @@ namespace ByteFX.Data.MySqlClient
genericType = GetGenericType( paramValue.GetType() );
}
- public MySqlParameter( string parameterName, MySqlDbType type)
+ /// <summary>
+ /// Initializes a new instance of the <see cref="MySqlParameter"/> class with the parameter name and the data type.
+ /// </summary>
+ /// <param name="parameterName">The name of the parameter to map. </param>
+ /// <param name="dbType">One of the <see cref="MySqlDbType"/> values. </param>
+ public MySqlParameter( string parameterName, MySqlDbType dbType)
{
ParameterName = parameterName;
- dbType = type;
+ this.dbType = dbType;
}
- public MySqlParameter( string parameterName, MySqlDbType type, int size )
+ /// <summary>
+ /// Initializes a new instance of the <see cref="MySqlParameter"/> class with the parameter name, the <see cref="MySqlDbType"/>, and the size.
+ /// </summary>
+ /// <param name="parameterName">The name of the parameter to map. </param>
+ /// <param name="dbType">One of the <see cref="MySqlDbType"/> values. </param>
+ /// <param name="size">The length of the parameter. </param>
+ public MySqlParameter( string parameterName, MySqlDbType dbType, int size )
{
ParameterName = parameterName;
- dbType = type;
+ this.dbType = dbType;
this.size = size;
}
- public MySqlParameter( string name, MySqlDbType dbType, int size, string sourceCol )
+ /// <summary>
+ /// Initializes a new instance of the <see cref="MySqlParameter"/> class with the parameter name, the <see cref="MySqlDbType"/>, the size, and the source column name.
+ /// </summary>
+ /// <param name="parameterName">The name of the parameter to map. </param>
+ /// <param name="dbType">One of the <see cref="MySqlDbType"/> values. </param>
+ /// <param name="size">The length of the parameter. </param>
+ /// <param name="sourceColumn">The name of the source column. </param>
+ public MySqlParameter( string parameterName, MySqlDbType dbType, int size, string sourceColumn )
{
- ParameterName = name;
+ ParameterName = parameterName;
this.dbType = dbType;
this.size = size;
this.direction = ParameterDirection.Input;
this.precision = 0;
this.scale = 0;
- this.sourceColumn = sourceCol;
+ this.sourceColumn = sourceColumn;
this.sourceVersion = DataRowVersion.Current;
this.paramValue =null;
}
- public MySqlParameter(string name, MySqlDbType type, ParameterDirection dir, string col, DataRowVersion ver, object val)
+ internal MySqlParameter(string name, MySqlDbType type, ParameterDirection dir, string col, DataRowVersion ver, object val)
{
+ if (direction != ParameterDirection.Input)
+ throw new ArgumentException("Only input parameters are supported by MySql");
dbType = type;
direction = dir;
ParameterName = name;
@@ -87,10 +119,27 @@ namespace ByteFX.Data.MySqlClient
paramValue = val;
}
+ /// <summary>
+ /// Initializes a new instance of the <see cref="MySqlParameter"/> class with the parameter name, the type of the parameter, the size of the parameter, a <see cref="ParameterDirection"/>, the precision of the parameter, the scale of the parameter, the source column, a <see cref="DataRowVersion"/> to use, and the value of the parameter.
+ /// </summary>
+ /// <param name="parameterName">The name of the parameter to map. </param>
+ /// <param name="dbType">One of the <see cref="MySqlDbType"/> values. </param>
+ /// <param name="size">The length of the parameter. </param>
+ /// <param name="direction">One of the <see cref="ParameterDirection"/> values. </param>
+ /// <param name="isNullable">true if the value of the field can be null, otherwise false. </param>
+ /// <param name="precision">The total number of digits to the left and right of the decimal point to which <see cref="MySqlParameter.Value"/> is resolved.</param>
+ /// <param name="scale">The total number of decimal places to which <see cref="MySqlParameter.Value"/> is resolved. </param>
+ /// <param name="sourceColumn">The name of the source column. </param>
+ /// <param name="sourceVersion">One of the <see cref="DataRowVersion"/> values. </param>
+ /// <param name="value">An <see cref="Object"/> that is the value of the <see cref="MySqlParameter"/>. </param>
+ /// <exception cref="ArgumentException"/>
public MySqlParameter( string parameterName, MySqlDbType dbType, int size, ParameterDirection direction,
bool isNullable, byte precision, byte scale, string sourceColumn, DataRowVersion sourceVersion,
object value)
{
+ if (direction != ParameterDirection.Input)
+ throw new ArgumentException("Only input parameters are supported by MySql");
+
ParameterName = parameterName;
this.dbType = dbType;
this.size = size;
@@ -104,6 +153,10 @@ namespace ByteFX.Data.MySqlClient
#endregion
#region Properties
+
+ /// <summary>
+ /// Gets or sets the <see cref="DbType"/> of the parameter.
+ /// </summary>
public DbType DbType
{
get
@@ -133,11 +186,11 @@ namespace ByteFX.Data.MySqlClient
case DbType.Int32:
case DbType.UInt32:
- MySqlDbType = MySqlDbType.Long; break;
+ MySqlDbType = MySqlDbType.Int; break;
case DbType.Int64:
case DbType.UInt64:
- MySqlDbType = MySqlDbType.LongLong; break;
+ MySqlDbType = MySqlDbType.BigInt; break;
case DbType.DateTime:
MySqlDbType = MySqlDbType.Datetime; break;
@@ -165,19 +218,10 @@ namespace ByteFX.Data.MySqlClient
}
}
- [Category("Data")]
- public MySqlDbType MySqlDbType
- {
- get
- {
- return dbType;
- }
- set
- {
- dbType = value;
- }
- }
-
+ /// <summary>
+ /// Gets or sets a value indicating whether the parameter is input-only, output-only, bidirectional, or a stored procedure return value parameter.
+ /// As of MySql version 4.1 and earlier, input-only is the only valid choice.
+ /// </summary>
[Category("Data")]
public ParameterDirection Direction
{
@@ -185,12 +229,34 @@ namespace ByteFX.Data.MySqlClient
set { direction = value; }
}
+ /// <summary>
+ /// Gets or sets a value indicating whether the parameter accepts null values.
+ /// </summary>
[Browsable(false)]
public Boolean IsNullable
{
get { return isNullable; }
}
+ /// <summary>
+ /// Gets or sets the MySqlDbType of the parameter.
+ /// </summary>
+ [Category("Data")]
+ public MySqlDbType MySqlDbType
+ {
+ get
+ {
+ return dbType;
+ }
+ set
+ {
+ dbType = value;
+ }
+ }
+
+ /// <summary>
+ /// Gets or sets the name of the MySqlParameter.
+ /// </summary>
[Category("Misc")]
public String ParameterName
{
@@ -203,6 +269,39 @@ namespace ByteFX.Data.MySqlClient
}
}
+ /// <summary>
+ /// Gets or sets the maximum number of digits used to represent the <see cref="Value"/> property.
+ /// </summary>
+ [Category("Data")]
+ public byte Precision
+ {
+ get { return precision; }
+ set { precision = value; }
+ }
+
+ /// <summary>
+ /// Gets or sets the number of decimal places to which <see cref="Value"/> is resolved.
+ /// </summary>
+ [Category("Data")]
+ public byte Scale
+ {
+ get { return scale; }
+ set { scale = value; }
+ }
+
+ /// <summary>
+ /// Gets or sets the maximum size, in bytes, of the data within the column.
+ /// </summary>
+ [Category("Data")]
+ public int Size
+ {
+ get { return size; }
+ set { size = value; }
+ }
+
+ /// <summary>
+ /// Gets or sets the name of the source column that is mapped to the <see cref="DataSet"/> and used for loading or returning the <see cref="Value"/>.
+ /// </summary>
[Category("Data")]
public String SourceColumn
{
@@ -210,6 +309,9 @@ namespace ByteFX.Data.MySqlClient
set { sourceColumn = value; }
}
+ /// <summary>
+ /// Gets or sets the <see cref="DataRowVersion"/> to use when loading <see cref="Value"/>.
+ /// </summary>
[Category("Data")]
public DataRowVersion SourceVersion
{
@@ -217,6 +319,9 @@ namespace ByteFX.Data.MySqlClient
set { sourceVersion = value; }
}
+ /// <summary>
+ /// Gets or sets the value of the parameter.
+ /// </summary>
[TypeConverter(typeof(StringConverter))]
[Category("Data")]
public object Value
@@ -233,27 +338,6 @@ namespace ByteFX.Data.MySqlClient
}
}
- // implement methods of IDbDataParameter
- [Category("Data")]
- public byte Precision
- {
- get { return precision; }
- set { precision = value; }
- }
-
- [Category("Data")]
- public byte Scale
- {
- get { return scale; }
- set { scale = value; }
- }
-
- [Category("Data")]
- public int Size
- {
- get { return size; }
- set { size = value; }
- }
#endregion
private void EscapeByteArray( byte[] bytes, System.IO.MemoryStream s )
@@ -279,6 +363,10 @@ namespace ByteFX.Data.MySqlClient
s.Write( newbytes, 0, newx );
}
+ /// <summary>
+ /// Overridden. Gets a string containing the <see cref="ParameterName"/>.
+ /// </summary>
+ /// <returns></returns>
public override string ToString()
{
return paramName;
@@ -297,7 +385,7 @@ namespace ByteFX.Data.MySqlClient
return sb.ToString();
}
- public void SerializeToBytes( System.IO.MemoryStream s, MySqlConnection conn )
+ internal void SerializeToBytes( System.IO.MemoryStream s, MySqlConnection conn )
{
string parm_string = null;
byte[] bytes = null;
@@ -424,9 +512,9 @@ namespace ByteFX.Data.MySqlClient
case TypeCode.Int16:
case TypeCode.UInt16: return MySqlDbType.Int24;
case TypeCode.Int32:
- case TypeCode.UInt32: return MySqlDbType.Long;
+ case TypeCode.UInt32: return MySqlDbType.Int;
case TypeCode.Int64:
- case TypeCode.UInt64: return MySqlDbType.LongLong;
+ case TypeCode.UInt64: return MySqlDbType.BigInt;
case TypeCode.Single: return MySqlDbType.Float;
case TypeCode.Double: return MySqlDbType.Double;
case TypeCode.Decimal: return MySqlDbType.Decimal;
@@ -440,7 +528,7 @@ namespace ByteFX.Data.MySqlClient
#region ICloneable
- public object Clone()
+ object System.ICloneable.Clone()
{
MySqlParameter clone = new MySqlParameter( paramName, dbType, direction,
sourceColumn, sourceVersion, paramValue );
diff --git a/mcs/class/ByteFX.Data/mysqlclient/parameter_collection.cs b/mcs/class/ByteFX.Data/mysqlclient/parameter_collection.cs
index ecaadd0be26..84995140a4a 100755
--- a/mcs/class/ByteFX.Data/mysqlclient/parameter_collection.cs
+++ b/mcs/class/ByteFX.Data/mysqlclient/parameter_collection.cs
@@ -22,6 +22,10 @@ using System.ComponentModel;
namespace ByteFX.Data.MySqlClient
{
+ /// <summary>
+ /// Represents a collection of parameters relevant to a <see cref="MySqlCommand"/> as well as their respective mappings to columns in a <see cref="DataSet"/>. This class cannot be inherited.
+ /// </summary>
+ /// <include file='docs/MySqlParameterCollection.xml' path='MyDocs/MyMembers[@name="Class"]/*'/>
[Editor(typeof(ByteFX.Data.Common.DBParametersEditor), typeof(System.Drawing.Design.UITypeEditor))]
[ListBindable(true)]
public sealed class MySqlParameterCollection : MarshalByRefObject, IDataParameterCollection,
@@ -49,12 +53,12 @@ namespace ByteFX.Data.MySqlClient
_parms.CopyTo(array, index);
}
- public bool IsSynchronized
+ bool ICollection.IsSynchronized
{
get { return _parms.IsSynchronized; }
}
- public object SyncRoot
+ object ICollection.SyncRoot
{
get { return _parms.SyncRoot; }
}
@@ -70,11 +74,23 @@ namespace ByteFX.Data.MySqlClient
_parms.Clear();
}
+ /// <summary>
+ /// Gets a value indicating whether a MySqlParameter exists in the collection.
+ /// </summary>
+ /// <param name="value">The value of the <see cref="MySqlParameter"/> object to find. </param>
+ /// <returns>true if the collection contains the <see cref="MySqlParameter"/> object; otherwise, false.</returns>
+ /// <overloads>Gets a value indicating whether a <see cref="MySqlParameter"/> exists in the collection.</overloads>
public bool Contains(object value)
{
return _parms.Contains(value);
}
+ /// <summary>
+ /// Gets the location of a <see cref="MySqlParameter"/> in the collection.
+ /// </summary>
+ /// <param name="value">The <see cref="MySqlParameter"/> object to locate. </param>
+ /// <returns>The zero-based location of the <see cref="MySqlParameter"/> in the collection.</returns>
+ /// <overloads>Gets the location of a <see cref="MySqlParameter"/> in the collection.</overloads>
public int IndexOf(object value)
{
return _parms.IndexOf(value);
@@ -90,12 +106,12 @@ namespace ByteFX.Data.MySqlClient
_parms.Insert( index, value );
}
- public bool IsFixedSize
+ bool IList.IsFixedSize
{
get { return _parms.IsFixedSize; }
}
- public bool IsReadOnly
+ bool IList.IsReadOnly
{
get { return _parms.IsReadOnly; }
}
@@ -109,6 +125,11 @@ namespace ByteFX.Data.MySqlClient
_parms.Remove( value );
}
+ /// <summary>
+ /// Removes the specified <see cref="MySqlParameter"/> from the collection using a specific index.
+ /// </summary>
+ /// <param name="index">The zero-based index of the parameter. </param>
+ /// <overloads>Removes the specified <see cref="MySqlParameter"/> from the collection.</overloads>
public void RemoveAt( int index )
{
_parms.RemoveAt( index );
@@ -124,6 +145,11 @@ namespace ByteFX.Data.MySqlClient
}
}
+ /// <summary>
+ /// Adds the specified <see cref="MySqlParameter"/> object to the <see cref="MySqlParameterCollection"/>.
+ /// </summary>
+ /// <param name="value">The <see cref="MySqlParameter"/> to add to the collection.</param>
+ /// <returns>The index of the new <see cref="MySqlParameter"/> object.</returns>
public int Add( object value )
{
if (! (value is MySqlParameter)) throw new MySqlException("Only MySqlParameter objects may be stored");
@@ -139,6 +165,12 @@ namespace ByteFX.Data.MySqlClient
#endregion
#region IDataParameterCollection
+
+ /// <summary>
+ /// Gets a value indicating whether a <see cref="MySqlParameter"/> with the specified parameter name exists in the collection.
+ /// </summary>
+ /// <param name="name">The name of the <see cref="MySqlParameter"/> object to find.</param>
+ /// <returns>true if the collection contains the parameter; otherwise, false.</returns>
public bool Contains(string name)
{
if (name[0] == '@')
@@ -150,18 +182,27 @@ namespace ByteFX.Data.MySqlClient
return false;
}
- public int IndexOf( string name )
+ /// <summary>
+ /// Gets the location of the <see cref="MySqlParameter"/> in the collection with a specific parameter name.
+ /// </summary>
+ /// <param name="parameterName">The name of the <see cref="MySqlParameter"/> object to retrieve. </param>
+ /// <returns>The zero-based location of the <see cref="MySqlParameter"/> in the collection.</returns>
+ public int IndexOf( string parameterName )
{
- if (name[0] == '@')
- name = name.Substring(1, name.Length-1);
+ if (parameterName[0] == '@')
+ parameterName = parameterName.Substring(1, parameterName.Length-1);
for (int x=0; x < _parms.Count; x++)
{
MySqlParameter p = (MySqlParameter)_parms[x];
- if (p.ParameterName.ToLower().Equals( name.ToLower() )) return x;
+ if (p.ParameterName.ToLower().Equals( parameterName.ToLower() )) return x;
}
- throw new MySqlException("Parameter '" + name + "' not found in collection");
+ throw new MySqlException("Parameter '" + parameterName + "' not found in collection");
}
+ /// <summary>
+ /// Removes the specified <see cref="MySqlParameter"/> from the collection using the parameter name.
+ /// </summary>
+ /// <param name="name">The name of the <see cref="MySqlParameter"/> object to retrieve. </param>
public void RemoveAt( string name )
{
int index = IndexOf( name );
@@ -180,25 +221,40 @@ namespace ByteFX.Data.MySqlClient
#endregion
#region IEnumerable
- public IEnumerator GetEnumerator()
+ IEnumerator IEnumerable.GetEnumerator()
{
return ((IEnumerable)_parms).GetEnumerator();
}
#endregion
#region Public Methods
+
+ /// <summary>
+ /// Gets the <see cref="MySqlParameter"/> at the specified index.
+ /// </summary>
+ /// <overloads>Gets the <see cref="MySqlParameter"/> with a specified attribute.
+ /// [C#] In C#, this property is the indexer for the <see cref="MySqlParameterCollection"/> class.
+ /// </overloads>
public MySqlParameter this[int index]
{
get { return (MySqlParameter)_parms[index]; }
set { _parms[index] = value; }
}
+ /// <summary>
+ /// Gets the <see cref="MySqlParameter"/> with the specified name.
+ /// </summary>
public MySqlParameter this[string name]
{
get { return (MySqlParameter)_parms[ IndexOf( name ) ]; }
set { _parms[ IndexOf( name ) ] = value; }
}
+ /// <summary>
+ /// Adds the specified <see cref="MySqlParameter"/> object to the <see cref="MySqlParameterCollection"/>.
+ /// </summary>
+ /// <param name="value">The <see cref="MySqlParameter"/> to add to the collection.</param>
+ /// <returns>The index of the new <see cref="MySqlParameter"/> object.</returns>
public MySqlParameter Add(MySqlParameter value)
{
if ( value.ParameterName == null ) throw new ArgumentException("parameter must be named");
@@ -207,21 +263,48 @@ namespace ByteFX.Data.MySqlClient
return value;
}
+ /// <summary>
+ /// Adds a <see cref="MySqlParameter"/> to the <see cref="MySqlParameterCollection"/> given the specified parameter name and value.
+ /// </summary>
+ /// <param name="parameterName">The name of the parameter.</param>
+ /// <param name="value">The <see cref="MySqlParameter.Value"/> of the <see cref="MySqlParameter"/> to add to the collection.</param>
+ /// <returns>The index of the new <see cref="MySqlParameter"/> object.</returns>
public MySqlParameter Add( string parameterName, object value )
{
return Add( new MySqlParameter( parameterName, value ) );
}
- public MySqlParameter Add(string parameterName, MySqlDbType type)
+ /// <summary>
+ /// Adds a <see cref="MySqlParameter"/> to the <see cref="MySqlParameterCollection"/> given the parameter name and the data type.
+ /// </summary>
+ /// <param name="parameterName">The name of the parameter.</param>
+ /// <param name="dbType">One of the <see cref="MySqlDbType"/> values. </param>
+ /// <returns>The index of the new <see cref="MySqlParameter"/> object.</returns>
+ public MySqlParameter Add(string parameterName, MySqlDbType dbType)
{
- return Add(new MySqlParameter(parameterName, type));
+ return Add(new MySqlParameter(parameterName, dbType));
}
+ /// <summary>
+ /// Adds a <see cref="MySqlParameter"/> to the <see cref="MySqlParameterCollection"/> with the parameter name, the data type, and the column length.
+ /// </summary>
+ /// <param name="parameterName">The name of the parameter.</param>
+ /// <param name="dbType">One of the <see cref="MySqlDbType"/> values. </param>
+ /// <param name="size">The length of the column.</param>
+ /// <returns>The index of the new <see cref="MySqlParameter"/> object.</returns>
public MySqlParameter Add(string parameterName, MySqlDbType dbType, int size)
{
return Add(new MySqlParameter(parameterName, dbType, size ));
}
+ /// <summary>
+ /// Adds a <see cref="MySqlParameter"/> to the <see cref="MySqlParameterCollection"/> with the parameter name, the data type, the column length, and the source column name.
+ /// </summary>
+ /// <param name="parameterName">The name of the parameter.</param>
+ /// <param name="dbType">One of the <see cref="MySqlDbType"/> values. </param>
+ /// <param name="size">The length of the column.</param>
+ /// <param name="sourceColumn">The name of the source column.</param>
+ /// <returns>The index of the new <see cref="MySqlParameter"/> object.</returns>
public MySqlParameter Add(string parameterName, MySqlDbType dbType, int size, string sourceColumn)
{
return Add(new MySqlParameter(parameterName, dbType, size, sourceColumn));
diff --git a/mcs/class/ByteFX.Data/mysqlclient/transcaction.cs b/mcs/class/ByteFX.Data/mysqlclient/transcaction.cs
index f52a74c4620..213dac7818d 100755
--- a/mcs/class/ByteFX.Data/mysqlclient/transcaction.cs
+++ b/mcs/class/ByteFX.Data/mysqlclient/transcaction.cs
@@ -20,7 +20,11 @@ using System.Data;
namespace ByteFX.Data.MySqlClient
{
- public class MySqlTransaction : IDbTransaction
+ /// <summary>
+ /// Represents a SQL transaction to be made in a MySQL database. This class cannot be inherited.
+ /// </summary>
+ /// <include file='docs/MySqlTransaction.xml' path='MyDocs/MyMembers[@name="Class"]/*'/>
+ public sealed class MySqlTransaction : IDbTransaction
{
private IsolationLevel _level;
private MySqlConnection _conn;
@@ -31,22 +35,35 @@ namespace ByteFX.Data.MySqlClient
_open = true;
}
- public IsolationLevel IsolationLevel
- {
- get { return _level; }
- set { _level = value; }
- }
+ #region Properties
+ /// <summary>
+ /// Gets the <see cref="MySqlConnection"/> object associated with the transaction, or a null reference (Nothing in Visual Basic) if the transaction is no longer valid.
+ /// </summary>
public IDbConnection Connection
{
get { return _conn; }
set { _conn = (MySqlConnection)value; }
}
- public void Dispose()
+ /// <summary>
+ /// Specifies the <see cref="IsolationLevel"/> for this transaction.
+ /// </summary>
+ public IsolationLevel IsolationLevel
+ {
+ get { return _level; }
+ set { _level = value; }
+ }
+
+ #endregion
+
+ void System.IDisposable.Dispose()
{
}
+ /// <summary>
+ /// Commits the database transaction.
+ /// </summary>
public void Commit()
{
if (_conn == null || _conn.State != ConnectionState.Open)
@@ -65,6 +82,9 @@ namespace ByteFX.Data.MySqlClient
}
}
+ /// <summary>
+ /// Overloaded. Rolls back a transaction from a pending state.
+ /// </summary>
public void Rollback()
{
if (_conn == null || _conn.State != ConnectionState.Open)
diff --git a/mcs/class/Makefile b/mcs/class/Makefile
index 5b447555b69..2cc26b415eb 100644
--- a/mcs/class/Makefile
+++ b/mcs/class/Makefile
@@ -45,6 +45,7 @@ SUBDIRS = \
Commons.Xml.Relaxng \
Mono.Directory.LDAP \
Mono.Security.Win32 \
+ Novell.Directory.Ldap \
System.DirectoryServices \
System.Messaging \
System.ServiceProcess \
diff --git a/mcs/class/Microsoft.JScript/ChangeLog b/mcs/class/Microsoft.JScript/ChangeLog
index 30146169158..02660fe1853 100644
--- a/mcs/class/Microsoft.JScript/ChangeLog
+++ b/mcs/class/Microsoft.JScript/ChangeLog
@@ -1,3 +1,7 @@
+2003-11-10 <cesar@ciencias.unam.mx>
+
+ * Microsoft.JScript.dll.sources: don't build Visitor.cs.
+
2003-11-03 <cesar@ciencias.unam.mx>
* Microsoft.JScript.dll.sources: Added IdentificationTable.cs,
diff --git a/mcs/class/Microsoft.JScript/Microsoft.JScript.dll.sources b/mcs/class/Microsoft.JScript/Microsoft.JScript.dll.sources
index aed43ba17aa..22f609fb95f 100644
--- a/mcs/class/Microsoft.JScript/Microsoft.JScript.dll.sources
+++ b/mcs/class/Microsoft.JScript/Microsoft.JScript.dll.sources
@@ -156,7 +156,6 @@ Microsoft.JScript/VBArrayConstructor.cs
Microsoft.JScript/VBArrayObject.cs
Microsoft.JScript/VBArrayPrototype.cs
Microsoft.JScript/VersionableAttribute.cs
-Microsoft.JScript/Visitor.cs
Microsoft.JScript.Vsa/VsaEngine.cs
Microsoft.JScript/With.cs
Antlr.Runtime/antlr/ANTLRException.cs
diff --git a/mcs/class/Microsoft.JScript/Microsoft.JScript/ASTList.cs b/mcs/class/Microsoft.JScript/Microsoft.JScript/ASTList.cs
index 44629edb91d..98d38ffb4a1 100644
--- a/mcs/class/Microsoft.JScript/Microsoft.JScript/ASTList.cs
+++ b/mcs/class/Microsoft.JScript/Microsoft.JScript/ASTList.cs
@@ -43,5 +43,10 @@ namespace Microsoft.JScript.Tmp {
{
throw new NotImplementedException ();
}
+
+ internal override void Emit (EmitContext ec)
+ {
+ throw new NotImplementedException ();
+ }
}
}
diff --git a/mcs/class/Microsoft.JScript/Microsoft.JScript/ArrayLiteral.cs b/mcs/class/Microsoft.JScript/Microsoft.JScript/ArrayLiteral.cs
index fa35c7f3ec0..96145a56e22 100644
--- a/mcs/class/Microsoft.JScript/Microsoft.JScript/ArrayLiteral.cs
+++ b/mcs/class/Microsoft.JScript/Microsoft.JScript/ArrayLiteral.cs
@@ -24,5 +24,10 @@ namespace Microsoft.JScript.Tmp {
{
throw new NotImplementedException ();
}
+
+ internal override void Emit (EmitContext ec)
+ {
+ throw new NotImplementedException ();
+ }
}
}
diff --git a/mcs/class/Microsoft.JScript/Microsoft.JScript/BitwiseBinary.cs b/mcs/class/Microsoft.JScript/Microsoft.JScript/BitwiseBinary.cs
index 1f401903b77..3a5b246e2ac 100644
--- a/mcs/class/Microsoft.JScript/Microsoft.JScript/BitwiseBinary.cs
+++ b/mcs/class/Microsoft.JScript/Microsoft.JScript/BitwiseBinary.cs
@@ -9,7 +9,7 @@
using System;
-namespace Microsoft.JScript.Tmp {
+namespace Microsoft.JScript {
public sealed class BitwiseBinary : BinaryOp {
@@ -29,5 +29,10 @@ namespace Microsoft.JScript.Tmp {
{
throw new NotImplementedException ();
}
+
+ internal override void Emit (EmitContext ec)
+ {
+ throw new NotImplementedException ();
+ }
}
}
diff --git a/mcs/class/Microsoft.JScript/Microsoft.JScript/ChangeLog b/mcs/class/Microsoft.JScript/Microsoft.JScript/ChangeLog
index 5cbd9dbcc26..cad0fd09a7b 100644
--- a/mcs/class/Microsoft.JScript/Microsoft.JScript/ChangeLog
+++ b/mcs/class/Microsoft.JScript/Microsoft.JScript/ChangeLog
@@ -1,3 +1,60 @@
+2003-11-30 Cesar Lopez Nataren <cesar@ciencias.unam.mx>
+
+ * expression.cs: Added new field to Call class, so it can handle more arguments.
+
+ * StringLiteral.cs (Emit) : Load the string value.
+
+ * Literal.cs: BooleanLiteral, Resolve always return true. Emit the value and box it to Boolean.
+
+ * CodeGenerator.cs: Set parent if 'JScript 0' to GlobalScope. Set
+ custom attribute. Build default 'JScript 0' constructor. Emit
+ default initial/final code of 'Global Code'. Create default
+ 'JScript Main'.
+
+2003-11-29 Cesar Lopez Nataren <cesar@ciencias.unam.mx>
+
+ * jscript-lexer-grammar.g: define new rule 'arguments' instead of
+ repeating hand written rule all around. Change "." for DOT, dumb
+ mistake by myself. Added rule new_expr. Now we handle properly the
+ call_expr rule (as defined on the spec), and added a new
+ argument. Added subrule new_expr to left_hand_side_expr rule.
+
+2003-11-27 Cesar Lopez Nataren <cesar@ciencias.unam.mx>
+
+ * expression.cs (Expression): implemented Emit.
+
+ * expression.cs (Binary): Emit now creates a local for the
+ different kinds of binary expressions (initial code for this).
+
+ * ast.cs: Emit method now is abstract instead of virtual.
+
+ * CodeGenerator.cs: changed no_global_code_method to is_global_code_method.
+
+ * ASTList.cs, ArrayLiteral.cs, BitwiseBinary.cs, DebugBreak.cs,
+ Enum.cs, Equality.cs, Eval.cs, ForIn.cs, FormalParameterList.cs,
+ FunctionExpression.cs, Import.cs, InstanceOf.cs, Literal.cs,
+ NumericLiteral, NumericBinary.cs, NumericUnary.cs, Package.cs,
+ Plus.cs, PostOrPrefixOperator.cs, Print.cs, Relational.cs,
+ Continue, Break, Return, StrictEquality.cs, StringLiteral.cs,
+ Throw.cs, Try.cs, TypeOf.cs, VariableDeclaration.cs, With.cs,
+ Conditional, Call, Identifier, Args, Expression, :
+ added Emit method.
+
+ * FunctionDeclaration.cs: Check if values are not null first (at
+ Resolve). Ignore code generation is at 'Global Code'.
+
+ * VariableDeclaration.cs: Now I take care of IL generation when we
+ are at statements and expressions at global code, 'Global Code'
+ method is populated with that IL.
+
+ * CodeGenerator.cs: Added flag for 'Global Code' method
+ emittion. Now I call 'Emit' twice. The first for declarations the
+ follower for statements and expressions at global scope.
+
+2003-11-10 cesar lopez nataren <cesar@ciencias.unam.mx>
+
+ * Visitor.cs: Deleted.
+
2003-11-09 cesar lopez nataren <cesar@ciencias.unam.mx>
* FormalParameterList.cs: Now inherits from AST. Each of the
diff --git a/mcs/class/Microsoft.JScript/Microsoft.JScript/CodeGenerator.cs b/mcs/class/Microsoft.JScript/Microsoft.JScript/CodeGenerator.cs
index 6302842c4f6..396ec8af05b 100644
--- a/mcs/class/Microsoft.JScript/Microsoft.JScript/CodeGenerator.cs
+++ b/mcs/class/Microsoft.JScript/Microsoft.JScript/CodeGenerator.cs
@@ -11,6 +11,8 @@ using System;
using System.Reflection;
using System.Reflection.Emit;
using System.Threading;
+using Microsoft.JScript.Vsa;
+using System.Runtime.CompilerServices;
namespace Microsoft.JScript {
@@ -18,10 +20,12 @@ namespace Microsoft.JScript {
internal TypeBuilder type_builder;
internal ILGenerator ig;
+ internal bool is_global_code_method;
internal EmitContext (TypeBuilder type)
{
type_builder = type;
+ is_global_code_method = false;
}
}
@@ -76,20 +80,157 @@ namespace Microsoft.JScript {
TypeBuilder type_builder;
type_builder = module_builder.DefineType ("JScript 0");
+
+ type_builder.SetParent (typeof (GlobalScope));
+ type_builder.SetCustomAttribute (new CustomAttributeBuilder
+ (typeof (CompilerGlobalScopeAttribute).GetConstructor (new Type [] {}), new object [] {}));
+
EmitContext ec = new EmitContext (type_builder);
+ //
+ // Build the default constructor of the type
+ //
+ emit_default_script_constructor (ec);
+
+ // here we only emit code for declarations.
prog.Emit (ec);
+ //
+ // statements and expression at global scope are emitted
+ // inside 'Global Code' method.
+ //
+ type_builder = ec.type_builder;
+ MethodBuilder method = type_builder.DefineMethod ("Global Code",
+ MethodAttributes.Public,
+ typeof (System.Object),
+ new Type [] {});
+
+ ec.ig = method.GetILGenerator ();
+ ec.is_global_code_method = true;
+
+ emit_default_init_global_code (ec.ig);
+ prog.Emit (ec);
+ emit_default_end_global_code (ec.ig);
+
+ ec.type_builder.CreateType ();
+
+ //
+ // Build the default 'JScript Main' class
+ //
+ ec.type_builder = module_builder.DefineType ("JScript Main");
+ emit_jscript_main (ec.type_builder);
ec.type_builder.CreateType ();
}
+ internal static void emit_default_init_global_code (ILGenerator ig)
+ {
+ ig.Emit (OpCodes.Ldarg_0);
+ ig.Emit (OpCodes.Ldfld, typeof (ScriptObject).GetField ("engine"));
+ ig.Emit (OpCodes.Ldarg_0);
+ ig.Emit (OpCodes.Call,
+ typeof (VsaEngine).GetMethod ("PushScriptObject",
+ new Type [] { typeof (ScriptObject)}));
+ }
+
+ internal static void emit_default_end_global_code (ILGenerator ig)
+ {
+ ig.Emit (OpCodes.Ldarg_0);
+ ig.Emit (OpCodes.Ldfld, typeof (ScriptObject).GetField ("engine"));
+ ig.Emit (OpCodes.Call, typeof (VsaEngine).GetMethod ("PopScriptObject"));
+ ig.Emit (OpCodes.Pop);
+ ig.Emit (OpCodes.Ret);
+ }
+
+ internal static void emit_default_script_constructor (EmitContext ec)
+ {
+ ConstructorBuilder cons_builder;
+ TypeBuilder tb = ec.type_builder;
+ cons_builder = tb.DefineConstructor (MethodAttributes.Public,
+ CallingConventions.Standard,
+ new Type [] { typeof (GlobalScope) });
+
+ ILGenerator ig = cons_builder.GetILGenerator ();
+ ig.Emit (OpCodes.Ldarg_0);
+ ig.Emit (OpCodes.Ldarg_1);
+ ig.Emit (OpCodes.Dup);
+ ig.Emit (OpCodes.Ldfld,
+ typeof (ScriptObject).GetField ("engine"));
+
+ ig.Emit (OpCodes.Call,
+ typeof (GlobalScope).GetConstructor (new Type [] {typeof (GlobalScope),
+ typeof (VsaEngine)}));
+ ig.Emit (OpCodes.Ret);
+ }
+
+ internal static void emit_jscript_main (TypeBuilder tb)
+ {
+ emit_jscript_main_constructor (tb);
+ emit_jscript_main_entry_point (tb);
+ }
+
+ internal static void emit_jscript_main_constructor (TypeBuilder tb)
+ {
+ ConstructorBuilder cons = tb.DefineConstructor (MethodAttributes.Public,
+ CallingConventions.Standard,
+ new Type [] {});
+ ILGenerator ig = cons.GetILGenerator ();
+ ig.Emit (OpCodes.Ldarg_0);
+ ig.Emit (OpCodes.Call, typeof (Object).GetConstructor (new Type [] {}));
+ ig.Emit (OpCodes.Ret);
+ }
+
+ internal static void emit_jscript_main_entry_point (TypeBuilder tb)
+ {
+ MethodBuilder method;
+ method = tb.DefineMethod ("Main",
+ MethodAttributes.Public | MethodAttributes.Static,
+ typeof (void), new Type [] {typeof (String [])});
+
+ method.SetCustomAttribute (new CustomAttributeBuilder
+ (typeof (STAThreadAttribute).GetConstructor (
+ new Type [] {}),
+ new object [] {}));
+
+ ILGenerator ig = method.GetILGenerator ();
+
+ ig.DeclareLocal (typeof (GlobalScope));
+
+ ig.Emit (OpCodes.Ldc_I4_1);
+ ig.Emit (OpCodes.Ldc_I4_1);
+ ig.Emit (OpCodes.Newarr, typeof (string));
+ ig.Emit (OpCodes.Dup);
+ ig.Emit (OpCodes.Ldc_I4_0);
+
+ ig.Emit (OpCodes.Ldstr,
+ "mscorlib, Version=1.0.3300.0, Culture=neutral, Pub" +
+ "licKeyToken=b77a5c561934e089");
+
+ ig.Emit (OpCodes.Stelem_Ref);
+
+ ig.Emit (OpCodes.Call,
+ typeof (VsaEngine).GetMethod ("CreateEngineAndGetGlobalScope",
+ new Type [] {typeof (bool),
+ typeof (string [])}));
+ ig.Emit (OpCodes.Stloc_0);
+ ig.Emit (OpCodes.Ldloc_0);
+
+ ig.Emit (OpCodes.Newobj,
+ assembly_builder.GetType ("JScript 0").GetConstructor (
+ new Type [] {typeof (GlobalScope)}));
+ ig.Emit (OpCodes.Call,
+ assembly_builder.GetType ("JScript 0").GetMethod (
+ "Global Code", new Type [] {}));
+ ig.Emit (OpCodes.Pop);
+ ig.Emit (OpCodes.Ret);
+
+ assembly_builder.SetEntryPoint (method);
+ }
+
public static void Run (string file_name, AST prog)
{
CodeGenerator.Init (file_name);
CodeGenerator.Emit (prog);
-
- CodeGenerator.Save (trim_extension (file_name) +
- ".exe");
+ CodeGenerator.Save (trim_extension (file_name) + ".exe");
}
}
}
diff --git a/mcs/class/Microsoft.JScript/Microsoft.JScript/DebugBreak.cs b/mcs/class/Microsoft.JScript/Microsoft.JScript/DebugBreak.cs
index 0874bd2d6ed..9509dd51b83 100644
--- a/mcs/class/Microsoft.JScript/Microsoft.JScript/DebugBreak.cs
+++ b/mcs/class/Microsoft.JScript/Microsoft.JScript/DebugBreak.cs
@@ -16,5 +16,10 @@ namespace Microsoft.JScript.Tmp {
{
throw new NotImplementedException ();
}
+
+ internal override void Emit (EmitContext ec)
+ {
+ throw new NotImplementedException ();
+ }
}
}
diff --git a/mcs/class/Microsoft.JScript/Microsoft.JScript/Enum.cs b/mcs/class/Microsoft.JScript/Microsoft.JScript/Enum.cs
index 820beb7afcb..beebc5f4978 100644
--- a/mcs/class/Microsoft.JScript/Microsoft.JScript/Enum.cs
+++ b/mcs/class/Microsoft.JScript/Microsoft.JScript/Enum.cs
@@ -70,5 +70,10 @@ namespace Microsoft.JScript {
{
throw new NotImplementedException ();
}
+
+ internal override void Emit (EmitContext ec)
+ {
+ throw new NotImplementedException ();
+ }
}
}
diff --git a/mcs/class/Microsoft.JScript/Microsoft.JScript/Equality.cs b/mcs/class/Microsoft.JScript/Microsoft.JScript/Equality.cs
index 2a14347896b..d8205515c20 100644
--- a/mcs/class/Microsoft.JScript/Microsoft.JScript/Equality.cs
+++ b/mcs/class/Microsoft.JScript/Microsoft.JScript/Equality.cs
@@ -57,5 +57,10 @@ namespace Microsoft.JScript {
{
throw new NotImplementedException ();
}
+
+ internal override void Emit (EmitContext ec)
+ {
+ throw new NotImplementedException ();
+ }
}
}
diff --git a/mcs/class/Microsoft.JScript/Microsoft.JScript/Eval.cs b/mcs/class/Microsoft.JScript/Microsoft.JScript/Eval.cs
index fd36196a5ef..8d72f333682 100644
--- a/mcs/class/Microsoft.JScript/Microsoft.JScript/Eval.cs
+++ b/mcs/class/Microsoft.JScript/Microsoft.JScript/Eval.cs
@@ -22,5 +22,10 @@ namespace Microsoft.JScript.Tmp {
{
throw new NotImplementedException ();
}
+
+ internal override void Emit (EmitContext ec)
+ {
+ throw new NotImplementedException ();
+ }
}
}
diff --git a/mcs/class/Microsoft.JScript/Microsoft.JScript/ForIn.cs b/mcs/class/Microsoft.JScript/Microsoft.JScript/ForIn.cs
index 572dc56d33e..99c810ab8e0 100644
--- a/mcs/class/Microsoft.JScript/Microsoft.JScript/ForIn.cs
+++ b/mcs/class/Microsoft.JScript/Microsoft.JScript/ForIn.cs
@@ -23,5 +23,10 @@ namespace Microsoft.JScript.Tmp {
{
throw new NotImplementedException ();
}
+
+ internal override void Emit (EmitContext ec)
+ {
+ throw new NotImplementedException ();
+ }
}
}
diff --git a/mcs/class/Microsoft.JScript/Microsoft.JScript/FormalParameterList.cs b/mcs/class/Microsoft.JScript/Microsoft.JScript/FormalParameterList.cs
index 302eaac3357..a5da530ced1 100644
--- a/mcs/class/Microsoft.JScript/Microsoft.JScript/FormalParameterList.cs
+++ b/mcs/class/Microsoft.JScript/Microsoft.JScript/FormalParameterList.cs
@@ -73,5 +73,10 @@ namespace Microsoft.JScript {
return true;
}
+
+ internal override void Emit (EmitContext ec)
+ {
+ throw new NotImplementedException ();
+ }
}
}
diff --git a/mcs/class/Microsoft.JScript/Microsoft.JScript/FunctionDeclaration.cs b/mcs/class/Microsoft.JScript/Microsoft.JScript/FunctionDeclaration.cs
index da54716a349..f2ea4e5f40f 100644
--- a/mcs/class/Microsoft.JScript/Microsoft.JScript/FunctionDeclaration.cs
+++ b/mcs/class/Microsoft.JScript/Microsoft.JScript/FunctionDeclaration.cs
@@ -69,33 +69,41 @@ namespace Microsoft.JScript {
MethodBuilder method;
string name;
- if (Function.parent == null) {
- name = Function.name;
- type.DefineField (name, typeof (Microsoft.JScript.ScriptFunction),
- FieldAttributes.Public | FieldAttributes.Static);
-
- } else {
- name = get_composite_name ();
- ec.ig.DeclareLocal (typeof (Microsoft.JScript.ScriptFunction));
- }
-
- method = type.DefineMethod (name, Function.attr,
- Function.return_type,
- Function.params_types ());
+ if (!ec.is_global_code_method) {
+ if (Function.parent == null) {
+ name = Function.name;
+ type.DefineField (name,
+ typeof (Microsoft.JScript.ScriptFunction),
+ FieldAttributes.Public |
+ FieldAttributes.Static);
+ } else {
+ name = get_composite_name ();
+ ec.ig.DeclareLocal (typeof (Microsoft.JScript.ScriptFunction));
+ }
+ method = type.DefineMethod (name, Function.attr,
+ Function.return_type,
+ Function.params_types ());
+
+ ec.ig = method.GetILGenerator ();
- ec.ig = method.GetILGenerator ();
-
- Function.body.Emit (ec);
+ Function.body.Emit (ec);
+ }
}
internal override bool Resolve (IdentificationTable context)
{
context.Enter (Function.name, this);
-
context.OpenBlock ();
- Function.parameters.Resolve (context);
- Function.body.Resolve (context);
+ FormalParameterList p = Function.parameters;
+
+ if (p != null)
+ p.Resolve (context);
+
+ Block body = Function.body;
+
+ if (body != null)
+ body.Resolve (context);
context.CloseBlock ();
diff --git a/mcs/class/Microsoft.JScript/Microsoft.JScript/FunctionExpression.cs b/mcs/class/Microsoft.JScript/Microsoft.JScript/FunctionExpression.cs
index f26b5331337..863e1136f9d 100644
--- a/mcs/class/Microsoft.JScript/Microsoft.JScript/FunctionExpression.cs
+++ b/mcs/class/Microsoft.JScript/Microsoft.JScript/FunctionExpression.cs
@@ -39,5 +39,10 @@ namespace Microsoft.JScript {
{
throw new NotImplementedException ();
}
+
+ internal override void Emit (EmitContext ec)
+ {
+ throw new NotImplementedException ();
+ }
}
}
diff --git a/mcs/class/Microsoft.JScript/Microsoft.JScript/Import.cs b/mcs/class/Microsoft.JScript/Microsoft.JScript/Import.cs
index abaa113472f..fcfe10841d8 100644
--- a/mcs/class/Microsoft.JScript/Microsoft.JScript/Import.cs
+++ b/mcs/class/Microsoft.JScript/Microsoft.JScript/Import.cs
@@ -22,5 +22,10 @@ namespace Microsoft.JScript.Tmp {
{
throw new NotImplementedException ();
}
+
+ internal override void Emit (EmitContext ec)
+ {
+ throw new NotImplementedException ();
+ }
}
}
diff --git a/mcs/class/Microsoft.JScript/Microsoft.JScript/InstanceOf.cs b/mcs/class/Microsoft.JScript/Microsoft.JScript/InstanceOf.cs
index 5aa8319f7e7..5955bb82266 100644
--- a/mcs/class/Microsoft.JScript/Microsoft.JScript/InstanceOf.cs
+++ b/mcs/class/Microsoft.JScript/Microsoft.JScript/InstanceOf.cs
@@ -22,5 +22,10 @@ namespace Microsoft.JScript.Tmp {
{
throw new NotImplementedException ();
}
+
+ internal override void Emit (EmitContext ec)
+ {
+ throw new NotImplementedException ();
+ }
}
}
diff --git a/mcs/class/Microsoft.JScript/Microsoft.JScript/JScriptLexer.cs b/mcs/class/Microsoft.JScript/Microsoft.JScript/JScriptLexer.cs
index c0163cf09ff..6377b91011f 100644
--- a/mcs/class/Microsoft.JScript/Microsoft.JScript/JScriptLexer.cs
+++ b/mcs/class/Microsoft.JScript/Microsoft.JScript/JScriptLexer.cs
@@ -60,67 +60,66 @@ namespace Microsoft.JScript
public const int LITERAL_else = 30;
public const int ASSIGN = 31;
public const int LITERAL_new = 32;
- // "." = 33
+ public const int DOT = 33;
public const int OPEN_BRACKET = 34;
public const int CLOSE_BRACKET = 35;
- public const int DOT = 36;
- public const int INCREMENT = 37;
- public const int DECREMENT = 38;
- public const int LITERAL_delete = 39;
- public const int LITERAL_void = 40;
- public const int LITERAL_typeof = 41;
- public const int PLUS = 42;
- public const int MINUS = 43;
- public const int BITWISE_NOT = 44;
- public const int LOGICAL_NOT = 45;
- public const int MULT = 46;
- public const int DIVISION = 47;
- public const int MODULE = 48;
- public const int SHIFT_LEFT = 49;
- public const int SHIFT_RIGHT = 50;
- public const int UNSIGNED_SHIFT_RIGHT = 51;
- public const int LESS_THAN = 52;
- public const int GREATER_THAN = 53;
- public const int LESS_EQ = 54;
- public const int GREATER_EQ = 55;
- public const int LITERAL_instanceof = 56;
- public const int EQ = 57;
- public const int NEQ = 58;
- public const int STRICT_EQ = 59;
- public const int STRICT_NEQ = 60;
- public const int BITWISE_AND = 61;
- public const int BITWISE_XOR = 62;
- public const int BITWISE_OR = 63;
- public const int LOGICAL_AND = 64;
- public const int LOGICAL_OR = 65;
- public const int INTERR = 66;
- public const int MULT_ASSIGN = 67;
- public const int DIV_ASSIGN = 68;
- public const int MOD_ASSIGN = 69;
- public const int ADD_ASSIGN = 70;
- public const int SUB_ASSIGN = 71;
- public const int SHIFT_LEFT_ASSIGN = 72;
- public const int SHIFT_RIGHT_ASSIGN = 73;
- public const int AND_ASSIGN = 74;
- public const int XOR_ASSIGN = 75;
- public const int OR_ASSIGN = 76;
- public const int LITERAL_this = 77;
- public const int LITERAL_null = 78;
- public const int LITERAL_true = 79;
- public const int LITERAL_false = 80;
- public const int STRING_LITERAL = 81;
- public const int DECIMAL_LITERAL = 82;
- public const int HEX_INTEGER_LITERAL = 83;
- public const int LINE_FEED = 84;
- public const int CARRIAGE_RETURN = 85;
- public const int LINE_SEPARATOR = 86;
- public const int PARAGRAPH_SEPARATOR = 87;
- public const int TAB = 88;
- public const int VERTICAL_TAB = 89;
- public const int FORM_FEED = 90;
- public const int SPACE = 91;
- public const int NO_BREAK_SPACE = 92;
- public const int SL_COMMENT = 93;
+ public const int INCREMENT = 36;
+ public const int DECREMENT = 37;
+ public const int LITERAL_delete = 38;
+ public const int LITERAL_void = 39;
+ public const int LITERAL_typeof = 40;
+ public const int PLUS = 41;
+ public const int MINUS = 42;
+ public const int BITWISE_NOT = 43;
+ public const int LOGICAL_NOT = 44;
+ public const int MULT = 45;
+ public const int DIVISION = 46;
+ public const int MODULE = 47;
+ public const int SHIFT_LEFT = 48;
+ public const int SHIFT_RIGHT = 49;
+ public const int UNSIGNED_SHIFT_RIGHT = 50;
+ public const int LESS_THAN = 51;
+ public const int GREATER_THAN = 52;
+ public const int LESS_EQ = 53;
+ public const int GREATER_EQ = 54;
+ public const int LITERAL_instanceof = 55;
+ public const int EQ = 56;
+ public const int NEQ = 57;
+ public const int STRICT_EQ = 58;
+ public const int STRICT_NEQ = 59;
+ public const int BITWISE_AND = 60;
+ public const int BITWISE_XOR = 61;
+ public const int BITWISE_OR = 62;
+ public const int LOGICAL_AND = 63;
+ public const int LOGICAL_OR = 64;
+ public const int INTERR = 65;
+ public const int MULT_ASSIGN = 66;
+ public const int DIV_ASSIGN = 67;
+ public const int MOD_ASSIGN = 68;
+ public const int ADD_ASSIGN = 69;
+ public const int SUB_ASSIGN = 70;
+ public const int SHIFT_LEFT_ASSIGN = 71;
+ public const int SHIFT_RIGHT_ASSIGN = 72;
+ public const int AND_ASSIGN = 73;
+ public const int XOR_ASSIGN = 74;
+ public const int OR_ASSIGN = 75;
+ public const int LITERAL_this = 76;
+ public const int LITERAL_null = 77;
+ public const int LITERAL_true = 78;
+ public const int LITERAL_false = 79;
+ public const int STRING_LITERAL = 80;
+ public const int DECIMAL_LITERAL = 81;
+ public const int HEX_INTEGER_LITERAL = 82;
+ public const int LINE_FEED = 83;
+ public const int CARRIAGE_RETURN = 84;
+ public const int LINE_SEPARATOR = 85;
+ public const int PARAGRAPH_SEPARATOR = 86;
+ public const int TAB = 87;
+ public const int VERTICAL_TAB = 88;
+ public const int FORM_FEED = 89;
+ public const int SPACE = 90;
+ public const int NO_BREAK_SPACE = 91;
+ public const int SL_COMMENT = 92;
public JScriptLexer(Stream ins) : this(new ByteBuffer(ins))
{
@@ -145,30 +144,29 @@ namespace Microsoft.JScript
literals = new Hashtable();
literals.Add("switch", 17);
literals.Add("case", 19);
- literals.Add("this", 77);
+ literals.Add("this", 76);
literals.Add("for", 26);
literals.Add("catch", 14);
- literals.Add("true", 79);
+ literals.Add("true", 78);
literals.Add("default", 18);
literals.Add("try", 13);
- literals.Add(".", 33);
- literals.Add("void", 40);
+ literals.Add("void", 39);
literals.Add("break", 22);
literals.Add("while", 25);
literals.Add("continue", 23);
literals.Add("do", 24);
literals.Add("in", 28);
- literals.Add("null", 78);
+ literals.Add("null", 77);
literals.Add("function", 4);
literals.Add("throw", 16);
- literals.Add("instanceof", 56);
- literals.Add("typeof", 41);
+ literals.Add("instanceof", 55);
+ literals.Add("typeof", 40);
literals.Add("new", 32);
literals.Add("return", 21);
- literals.Add("delete", 39);
+ literals.Add("delete", 38);
literals.Add("if", 29);
literals.Add("finally", 15);
- literals.Add("false", 80);
+ literals.Add("false", 79);
literals.Add("else", 30);
literals.Add("var", 27);
literals.Add("with", 20);
@@ -548,11 +546,11 @@ tryAgain:
}
else
{
- goto _loop157_breakloop;
+ goto _loop159_breakloop;
}
}
-_loop157_breakloop: ;
+_loop159_breakloop: ;
} // ( ... )*
break;
}
@@ -575,11 +573,11 @@ _loop157_breakloop: ;
}
else
{
- goto _loop160_breakloop;
+ goto _loop162_breakloop;
}
}
-_loop160_breakloop: ;
+_loop162_breakloop: ;
} // ( ... )*
}
else {
@@ -635,7 +633,7 @@ _loop160_breakloop: ;
}
}
{ // ( ... )+
- int _cnt166=0;
+ int _cnt168=0;
for (;;)
{
if (((LA(1) >= '0' && LA(1) <= '9')))
@@ -644,12 +642,12 @@ _loop160_breakloop: ;
}
else
{
- if (_cnt166 >= 1) { goto _loop166_breakloop; } else { throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());; }
+ if (_cnt168 >= 1) { goto _loop168_breakloop; } else { throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());; }
}
- _cnt166++;
+ _cnt168++;
}
-_loop166_breakloop: ;
+_loop168_breakloop: ;
} // ( ... )+
}
}
@@ -705,7 +703,7 @@ _loop166_breakloop: ;
}
}
{ // ( ... )+
- int _cnt170=0;
+ int _cnt172=0;
for (;;)
{
switch ( LA(1) )
@@ -731,12 +729,12 @@ _loop166_breakloop: ;
}
default:
{
- if (_cnt170 >= 1) { goto _loop170_breakloop; } else { throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());; }
+ if (_cnt172 >= 1) { goto _loop172_breakloop; } else { throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());; }
}
break; }
- _cnt170++;
+ _cnt172++;
}
-_loop170_breakloop: ;
+_loop172_breakloop: ;
} // ( ... )+
if (_createToken && (null == _token) && (_ttype != Token.SKIP))
{
@@ -763,11 +761,11 @@ _loop170_breakloop: ;
}
else
{
- goto _loop174_breakloop;
+ goto _loop176_breakloop;
}
}
-_loop174_breakloop: ;
+_loop176_breakloop: ;
} // ( ... )*
match('"');
if (_createToken && (null == _token) && (_ttype != Token.SKIP))
@@ -850,11 +848,11 @@ _loop174_breakloop: ;
}
default:
{
- goto _loop178_breakloop;
+ goto _loop180_breakloop;
}
}
}
-_loop178_breakloop: ;
+_loop180_breakloop: ;
} // ( ... )*
_ttype = testLiteralsTable(_ttype);
if (_createToken && (null == _token) && (_ttype != Token.SKIP))
@@ -1526,11 +1524,11 @@ _loop178_breakloop: ;
}
else
{
- goto _loop229_breakloop;
+ goto _loop231_breakloop;
}
}
-_loop229_breakloop: ;
+_loop231_breakloop: ;
} // ( ... )*
_ttype = Token.SKIP;
if (_createToken && (null == _token) && (_ttype != Token.SKIP))
diff --git a/mcs/class/Microsoft.JScript/Microsoft.JScript/JScriptParser.cs b/mcs/class/Microsoft.JScript/Microsoft.JScript/JScriptParser.cs
index 641c8cd5ca0..7c92f91a733 100644
--- a/mcs/class/Microsoft.JScript/Microsoft.JScript/JScriptParser.cs
+++ b/mcs/class/Microsoft.JScript/Microsoft.JScript/JScriptParser.cs
@@ -52,67 +52,66 @@ namespace Microsoft.JScript
public const int LITERAL_else = 30;
public const int ASSIGN = 31;
public const int LITERAL_new = 32;
- // "." = 33
+ public const int DOT = 33;
public const int OPEN_BRACKET = 34;
public const int CLOSE_BRACKET = 35;
- public const int DOT = 36;
- public const int INCREMENT = 37;
- public const int DECREMENT = 38;
- public const int LITERAL_delete = 39;
- public const int LITERAL_void = 40;
- public const int LITERAL_typeof = 41;
- public const int PLUS = 42;
- public const int MINUS = 43;
- public const int BITWISE_NOT = 44;
- public const int LOGICAL_NOT = 45;
- public const int MULT = 46;
- public const int DIVISION = 47;
- public const int MODULE = 48;
- public const int SHIFT_LEFT = 49;
- public const int SHIFT_RIGHT = 50;
- public const int UNSIGNED_SHIFT_RIGHT = 51;
- public const int LESS_THAN = 52;
- public const int GREATER_THAN = 53;
- public const int LESS_EQ = 54;
- public const int GREATER_EQ = 55;
- public const int LITERAL_instanceof = 56;
- public const int EQ = 57;
- public const int NEQ = 58;
- public const int STRICT_EQ = 59;
- public const int STRICT_NEQ = 60;
- public const int BITWISE_AND = 61;
- public const int BITWISE_XOR = 62;
- public const int BITWISE_OR = 63;
- public const int LOGICAL_AND = 64;
- public const int LOGICAL_OR = 65;
- public const int INTERR = 66;
- public const int MULT_ASSIGN = 67;
- public const int DIV_ASSIGN = 68;
- public const int MOD_ASSIGN = 69;
- public const int ADD_ASSIGN = 70;
- public const int SUB_ASSIGN = 71;
- public const int SHIFT_LEFT_ASSIGN = 72;
- public const int SHIFT_RIGHT_ASSIGN = 73;
- public const int AND_ASSIGN = 74;
- public const int XOR_ASSIGN = 75;
- public const int OR_ASSIGN = 76;
- public const int LITERAL_this = 77;
- public const int LITERAL_null = 78;
- public const int LITERAL_true = 79;
- public const int LITERAL_false = 80;
- public const int STRING_LITERAL = 81;
- public const int DECIMAL_LITERAL = 82;
- public const int HEX_INTEGER_LITERAL = 83;
- public const int LINE_FEED = 84;
- public const int CARRIAGE_RETURN = 85;
- public const int LINE_SEPARATOR = 86;
- public const int PARAGRAPH_SEPARATOR = 87;
- public const int TAB = 88;
- public const int VERTICAL_TAB = 89;
- public const int FORM_FEED = 90;
- public const int SPACE = 91;
- public const int NO_BREAK_SPACE = 92;
- public const int SL_COMMENT = 93;
+ public const int INCREMENT = 36;
+ public const int DECREMENT = 37;
+ public const int LITERAL_delete = 38;
+ public const int LITERAL_void = 39;
+ public const int LITERAL_typeof = 40;
+ public const int PLUS = 41;
+ public const int MINUS = 42;
+ public const int BITWISE_NOT = 43;
+ public const int LOGICAL_NOT = 44;
+ public const int MULT = 45;
+ public const int DIVISION = 46;
+ public const int MODULE = 47;
+ public const int SHIFT_LEFT = 48;
+ public const int SHIFT_RIGHT = 49;
+ public const int UNSIGNED_SHIFT_RIGHT = 50;
+ public const int LESS_THAN = 51;
+ public const int GREATER_THAN = 52;
+ public const int LESS_EQ = 53;
+ public const int GREATER_EQ = 54;
+ public const int LITERAL_instanceof = 55;
+ public const int EQ = 56;
+ public const int NEQ = 57;
+ public const int STRICT_EQ = 58;
+ public const int STRICT_NEQ = 59;
+ public const int BITWISE_AND = 60;
+ public const int BITWISE_XOR = 61;
+ public const int BITWISE_OR = 62;
+ public const int LOGICAL_AND = 63;
+ public const int LOGICAL_OR = 64;
+ public const int INTERR = 65;
+ public const int MULT_ASSIGN = 66;
+ public const int DIV_ASSIGN = 67;
+ public const int MOD_ASSIGN = 68;
+ public const int ADD_ASSIGN = 69;
+ public const int SUB_ASSIGN = 70;
+ public const int SHIFT_LEFT_ASSIGN = 71;
+ public const int SHIFT_RIGHT_ASSIGN = 72;
+ public const int AND_ASSIGN = 73;
+ public const int XOR_ASSIGN = 74;
+ public const int OR_ASSIGN = 75;
+ public const int LITERAL_this = 76;
+ public const int LITERAL_null = 77;
+ public const int LITERAL_true = 78;
+ public const int LITERAL_false = 79;
+ public const int STRING_LITERAL = 80;
+ public const int DECIMAL_LITERAL = 81;
+ public const int HEX_INTEGER_LITERAL = 82;
+ public const int LINE_FEED = 83;
+ public const int CARRIAGE_RETURN = 84;
+ public const int LINE_SEPARATOR = 85;
+ public const int PARAGRAPH_SEPARATOR = 86;
+ public const int TAB = 87;
+ public const int VERTICAL_TAB = 88;
+ public const int FORM_FEED = 89;
+ public const int SPACE = 90;
+ public const int NO_BREAK_SPACE = 91;
+ public const int SL_COMMENT = 92;
protected void initialize()
@@ -1665,16 +1664,50 @@ _loop58_breakloop: ;
return assign_expr;
}
- public Call left_hand_side_expr() //throws RecognitionException, TokenStreamException
+ public AST left_hand_side_expr() //throws RecognitionException, TokenStreamException
{
- Call call;
+ AST lhe;
- call = null;
+ lhe = null;
+ Call call = null;
- call=call_expr();
- return call;
+ bool synPredMatched90 = false;
+ if (((tokenSet_3_.member(LA(1)))))
+ {
+ int _m90 = mark();
+ synPredMatched90 = true;
+ inputState.guessing++;
+ try {
+ {
+ call_expr();
+ }
+ }
+ catch (RecognitionException)
+ {
+ synPredMatched90 = false;
+ }
+ rewind(_m90);
+ inputState.guessing--;
+ }
+ if ( synPredMatched90 )
+ {
+ call=call_expr();
+ if (0==inputState.guessing)
+ {
+ lhe = call;
+ }
+ }
+ else if ((tokenSet_3_.member(LA(1)))) {
+ lhe=new_expr();
+ }
+ else
+ {
+ throw new NoViableAltException(LT(1), getFilename());
+ }
+
+ return lhe;
}
public JSToken assignment_op() //throws RecognitionException, TokenStreamException
@@ -1884,46 +1917,7 @@ _loop58_breakloop: ;
{
match(LITERAL_new);
member_expr();
- match(OPEN_PARENS);
- {
- switch ( LA(1) )
- {
- case IDENTIFIER:
- case OPEN_PARENS:
- case OPEN_BRACE:
- case LITERAL_new:
- case OPEN_BRACKET:
- case INCREMENT:
- case DECREMENT:
- case LITERAL_delete:
- case LITERAL_void:
- case LITERAL_typeof:
- case PLUS:
- case MINUS:
- case BITWISE_NOT:
- case LOGICAL_NOT:
- case LITERAL_this:
- case LITERAL_null:
- case LITERAL_true:
- case LITERAL_false:
- case STRING_LITERAL:
- case DECIMAL_LITERAL:
- case HEX_INTEGER_LITERAL:
- {
- arguments_list(null);
- break;
- }
- case CLOSE_PARENS:
- {
- break;
- }
- default:
- {
- throw new NoViableAltException(LT(1), getFilename());
- }
- }
- }
- match(CLOSE_PARENS);
+ arguments();
break;
}
default:
@@ -2019,194 +2013,24 @@ _loop58_breakloop: ;
{
- if ((LA(1)==33))
+ switch ( LA(1) )
{
- match(33);
+ case DOT:
+ {
+ match(DOT);
match(IDENTIFIER);
member_aux();
+ break;
}
- else {
- bool synPredMatched79 = false;
- if (((LA(1)==OPEN_BRACKET)))
- {
- int _m79 = mark();
- synPredMatched79 = true;
- inputState.guessing++;
- try {
- {
- match(OPEN_BRACKET);
- }
- }
- catch (RecognitionException)
- {
- synPredMatched79 = false;
- }
- rewind(_m79);
- inputState.guessing--;
- }
- if ( synPredMatched79 )
- {
- match(OPEN_BRACKET);
- expr();
- match(CLOSE_BRACKET);
- }
- else if ((tokenSet_5_.member(LA(1)))) {
- }
- else
- {
- throw new NoViableAltException(LT(1), getFilename());
- }
- }
- }
- }
-
- public void arguments_list(
- Args args
- ) //throws RecognitionException, TokenStreamException
-{
-
-
- AST a = null;
-
-
- a=assignment_expr();
- if (0==inputState.guessing)
- {
- args.Add (a);
- }
- { // ( ... )*
- for (;;)
- {
- if ((LA(1)==COMMA))
- {
- match(COMMA);
- a=assignment_expr();
- if (0==inputState.guessing)
- {
- args.Add (a);
- }
- }
- else
- {
- goto _loop87_breakloop;
- }
-
- }
-_loop87_breakloop: ;
- } // ( ... )*
- }
-
- public Call call_expr() //throws RecognitionException, TokenStreamException
-{
- Call func_call;
-
-
- func_call = null;
- AST member = null;
- AST args;
-
-
- member=member_expr();
- args=call_aux();
- if (0==inputState.guessing)
- {
-
- func_call = new Call (member, args);
-
- }
- return func_call;
- }
-
- public AST call_aux() //throws RecognitionException, TokenStreamException
-{
- AST args;
-
-
- Args tmp_args = new Args ();
- args = null;
-
-
- {
- switch ( LA(1) )
- {
- case OPEN_PARENS:
case OPEN_BRACKET:
- case DOT:
{
- {
- switch ( LA(1) )
- {
- case OPEN_PARENS:
- {
- match(OPEN_PARENS);
- {
- switch ( LA(1) )
- {
- case IDENTIFIER:
- case OPEN_PARENS:
- case OPEN_BRACE:
- case LITERAL_new:
- case OPEN_BRACKET:
- case INCREMENT:
- case DECREMENT:
- case LITERAL_delete:
- case LITERAL_void:
- case LITERAL_typeof:
- case PLUS:
- case MINUS:
- case BITWISE_NOT:
- case LOGICAL_NOT:
- case LITERAL_this:
- case LITERAL_null:
- case LITERAL_true:
- case LITERAL_false:
- case STRING_LITERAL:
- case DECIMAL_LITERAL:
- case HEX_INTEGER_LITERAL:
- {
- arguments_list(tmp_args);
- if (0==inputState.guessing)
- {
- args = tmp_args;
- }
- break;
- }
- case CLOSE_PARENS:
- {
- break;
- }
- default:
- {
- throw new NoViableAltException(LT(1), getFilename());
- }
- }
- }
- match(CLOSE_PARENS);
- break;
- }
- case OPEN_BRACKET:
- {
- match(OPEN_BRACKET);
- expr();
- match(CLOSE_BRACKET);
- break;
- }
- case DOT:
- {
- match(DOT);
- match(IDENTIFIER);
- break;
- }
- default:
- {
- throw new NoViableAltException(LT(1), getFilename());
- }
- }
- }
- call_aux();
+ match(OPEN_BRACKET);
+ expr();
+ match(CLOSE_BRACKET);
break;
}
case IDENTIFIER:
+ case OPEN_PARENS:
case CLOSE_PARENS:
case COLON:
case CLOSE_BRACE:
@@ -2262,9 +2086,242 @@ _loop87_breakloop: ;
}
}
}
+ }
+
+ public Args arguments() //throws RecognitionException, TokenStreamException
+{
+ Args args;
+
+
+ Args tmp = new Args ();
+ args = null;
+
+
+ match(OPEN_PARENS);
+ {
+ switch ( LA(1) )
+ {
+ case IDENTIFIER:
+ case OPEN_PARENS:
+ case OPEN_BRACE:
+ case LITERAL_new:
+ case OPEN_BRACKET:
+ case INCREMENT:
+ case DECREMENT:
+ case LITERAL_delete:
+ case LITERAL_void:
+ case LITERAL_typeof:
+ case PLUS:
+ case MINUS:
+ case BITWISE_NOT:
+ case LOGICAL_NOT:
+ case LITERAL_this:
+ case LITERAL_null:
+ case LITERAL_true:
+ case LITERAL_false:
+ case STRING_LITERAL:
+ case DECIMAL_LITERAL:
+ case HEX_INTEGER_LITERAL:
+ {
+ arguments_list(tmp);
+ if (0==inputState.guessing)
+ {
+ args = tmp;
+ }
+ break;
+ }
+ case CLOSE_PARENS:
+ {
+ break;
+ }
+ default:
+ {
+ throw new NoViableAltException(LT(1), getFilename());
+ }
+ }
+ }
+ match(CLOSE_PARENS);
return args;
}
+ public AST new_expr() //throws RecognitionException, TokenStreamException
+{
+ AST new_exp;
+
+
+ new_exp = null;
+ AST mem_exp = null;
+
+
+ mem_exp=member_expr();
+ if (0==inputState.guessing)
+ {
+ new_exp = mem_exp;
+ }
+ return new_exp;
+ }
+
+ public Call call_expr() //throws RecognitionException, TokenStreamException
+{
+ Call func_call;
+
+
+ func_call = null;
+ AST member = null;
+ AST args1 = null;
+ AST args2 = null;
+
+
+ member=member_expr();
+ args1=arguments();
+ args2=call_aux();
+ if (0==inputState.guessing)
+ {
+
+ func_call = new Call (member, args1, args2);
+
+ }
+ return func_call;
+ }
+
+ public AST call_aux() //throws RecognitionException, TokenStreamException
+{
+ AST args;
+
+
+ args = null;
+
+
+ switch ( LA(1) )
+ {
+ case OPEN_PARENS:
+ case DOT:
+ case OPEN_BRACKET:
+ {
+ {
+ switch ( LA(1) )
+ {
+ case OPEN_PARENS:
+ {
+ arguments();
+ break;
+ }
+ case OPEN_BRACKET:
+ {
+ match(OPEN_BRACKET);
+ expr();
+ match(CLOSE_BRACKET);
+ break;
+ }
+ case DOT:
+ {
+ match(DOT);
+ match(IDENTIFIER);
+ break;
+ }
+ default:
+ {
+ throw new NoViableAltException(LT(1), getFilename());
+ }
+ }
+ }
+ call_aux();
+ break;
+ }
+ case IDENTIFIER:
+ case CLOSE_PARENS:
+ case COLON:
+ case CLOSE_BRACE:
+ case COMMA:
+ case SEMI_COLON:
+ case LITERAL_in:
+ case ASSIGN:
+ case CLOSE_BRACKET:
+ case INCREMENT:
+ case DECREMENT:
+ case PLUS:
+ case MINUS:
+ case MULT:
+ case DIVISION:
+ case MODULE:
+ case SHIFT_LEFT:
+ case SHIFT_RIGHT:
+ case UNSIGNED_SHIFT_RIGHT:
+ case LESS_THAN:
+ case GREATER_THAN:
+ case LESS_EQ:
+ case GREATER_EQ:
+ case LITERAL_instanceof:
+ case EQ:
+ case NEQ:
+ case STRICT_EQ:
+ case STRICT_NEQ:
+ case BITWISE_AND:
+ case BITWISE_XOR:
+ case BITWISE_OR:
+ case LOGICAL_AND:
+ case LOGICAL_OR:
+ case INTERR:
+ case MULT_ASSIGN:
+ case DIV_ASSIGN:
+ case MOD_ASSIGN:
+ case ADD_ASSIGN:
+ case SUB_ASSIGN:
+ case SHIFT_LEFT_ASSIGN:
+ case SHIFT_RIGHT_ASSIGN:
+ case AND_ASSIGN:
+ case XOR_ASSIGN:
+ case OR_ASSIGN:
+ case STRING_LITERAL:
+ case DECIMAL_LITERAL:
+ case HEX_INTEGER_LITERAL:
+ {
+ break;
+ }
+ default:
+ {
+ throw new NoViableAltException(LT(1), getFilename());
+ }
+ }
+ return args;
+ }
+
+ public void arguments_list(
+ Args args
+ ) //throws RecognitionException, TokenStreamException
+{
+
+
+ AST a = null;
+
+
+ a=assignment_expr();
+ if (0==inputState.guessing)
+ {
+ args.Add (a);
+ }
+ { // ( ... )*
+ for (;;)
+ {
+ if ((LA(1)==COMMA))
+ {
+ match(COMMA);
+ a=assignment_expr();
+ if (0==inputState.guessing)
+ {
+ args.Add (a);
+ }
+ }
+ else
+ {
+ goto _loop87_breakloop;
+ }
+
+ }
+_loop87_breakloop: ;
+ } // ( ... )*
+ }
+
public Unary postfix_expr() //throws RecognitionException, TokenStreamException
{
Unary post_expr;
@@ -3597,11 +3654,11 @@ _loop87_breakloop: ;
match(OPEN_BRACE);
{
- bool synPredMatched135 = false;
+ bool synPredMatched137 = false;
if (((LA(1)==OPEN_BRACE)))
{
- int _m135 = mark();
- synPredMatched135 = true;
+ int _m137 = mark();
+ synPredMatched137 = true;
inputState.guessing++;
try {
{
@@ -3611,19 +3668,19 @@ _loop87_breakloop: ;
}
catch (RecognitionException)
{
- synPredMatched135 = false;
+ synPredMatched137 = false;
}
- rewind(_m135);
+ rewind(_m137);
inputState.guessing--;
}
- if ( synPredMatched135 )
+ if ( synPredMatched137 )
{
match(OPEN_BRACE);
{ // ( ... )+
- int _cnt137=0;
+ int _cnt139=0;
for (;;)
{
- if ((tokenSet_6_.member(LA(1))))
+ if ((tokenSet_5_.member(LA(1))))
{
property_name();
match(COLON);
@@ -3631,15 +3688,15 @@ _loop87_breakloop: ;
}
else
{
- if (_cnt137 >= 1) { goto _loop137_breakloop; } else { throw new NoViableAltException(LT(1), getFilename());; }
+ if (_cnt139 >= 1) { goto _loop139_breakloop; } else { throw new NoViableAltException(LT(1), getFilename());; }
}
- _cnt137++;
+ _cnt139++;
}
-_loop137_breakloop: ;
+_loop139_breakloop: ;
} // ( ... )+
}
- else if ((tokenSet_7_.member(LA(1)))) {
+ else if ((tokenSet_6_.member(LA(1)))) {
{ // ( ... )*
for (;;)
{
@@ -3649,11 +3706,11 @@ _loop137_breakloop: ;
}
else
{
- goto _loop139_breakloop;
+ goto _loop141_breakloop;
}
}
-_loop139_breakloop: ;
+_loop141_breakloop: ;
} // ( ... )*
}
else
@@ -3763,11 +3820,11 @@ _loop139_breakloop: ;
}
else
{
- goto _loop149_breakloop;
+ goto _loop151_breakloop;
}
}
-_loop149_breakloop: ;
+_loop151_breakloop: ;
} // ( ... )*
break;
}
@@ -3854,10 +3911,10 @@ _loop149_breakloop: ;
{ // ( ... )+
- int _cnt143=0;
+ int _cnt145=0;
for (;;)
{
- if ((tokenSet_6_.member(LA(1))))
+ if ((tokenSet_5_.member(LA(1))))
{
property_name();
match(COLON);
@@ -3865,12 +3922,12 @@ _loop149_breakloop: ;
}
else
{
- if (_cnt143 >= 1) { goto _loop143_breakloop; } else { throw new NoViableAltException(LT(1), getFilename());; }
+ if (_cnt145 >= 1) { goto _loop145_breakloop; } else { throw new NoViableAltException(LT(1), getFilename());; }
}
- _cnt143++;
+ _cnt145++;
}
-_loop143_breakloop: ;
+_loop145_breakloop: ;
} // ( ... )+
}
@@ -3983,10 +4040,9 @@ _loop143_breakloop: ;
@"""else""",
@"""ASSIGN""",
@"""new""",
- @""".""",
+ @"""DOT""",
@"""OPEN_BRACKET""",
@"""CLOSE_BRACKET""",
- @"""DOT""",
@"""INCREMENT""",
@"""DECREMENT""",
@"""delete""",
@@ -4048,52 +4104,46 @@ _loop143_breakloop: ;
private static long[] mk_tokenSet_0_()
{
- long[] data = { 70253584527984L, 1040384L, 0L, 0L};
+ long[] data = { 35137931915888L, 520192L, 0L, 0L};
return data;
}
public static readonly BitSet tokenSet_0_ = new BitSet(mk_tokenSet_0_());
private static long[] mk_tokenSet_1_()
{
- long[] data = { 70254659057266L, 1040384L, 0L, 0L};
+ long[] data = { 35139006445170L, 520192L, 0L, 0L};
return data;
}
public static readonly BitSet tokenSet_1_ = new BitSet(mk_tokenSet_1_());
private static long[] mk_tokenSet_2_()
{
- long[] data = { 70253584527968L, 1040384L, 0L, 0L};
+ long[] data = { 35137931915872L, 520192L, 0L, 0L};
return data;
}
public static readonly BitSet tokenSet_2_ = new BitSet(mk_tokenSet_2_());
private static long[] mk_tokenSet_3_()
{
- long[] data = { 21474837088L, 1040384L, 0L, 0L};
+ long[] data = { 21474837088L, 520192L, 0L, 0L};
return data;
}
public static readonly BitSet tokenSet_3_ = new BitSet(mk_tokenSet_3_());
private static long[] mk_tokenSet_4_()
{
- long[] data = { 70252780061280L, 1040384L, 0L, 0L};
+ long[] data = { 35137127449184L, 520192L, 0L, 0L};
return data;
}
public static readonly BitSet tokenSet_4_ = new BitSet(mk_tokenSet_4_());
private static long[] mk_tokenSet_5_()
{
- long[] data = { -56639612772896L, 925695L, 0L, 0L};
+ long[] data = { 32L, 458752L, 0L, 0L};
return data;
}
public static readonly BitSet tokenSet_5_ = new BitSet(mk_tokenSet_5_());
private static long[] mk_tokenSet_6_()
{
- long[] data = { 32L, 917504L, 0L, 0L};
+ long[] data = { 35137931916896L, 520192L, 0L, 0L};
return data;
}
public static readonly BitSet tokenSet_6_ = new BitSet(mk_tokenSet_6_());
- private static long[] mk_tokenSet_7_()
- {
- long[] data = { 70253584528992L, 1040384L, 0L, 0L};
- return data;
- }
- public static readonly BitSet tokenSet_7_ = new BitSet(mk_tokenSet_7_());
}
}
diff --git a/mcs/class/Microsoft.JScript/Microsoft.JScript/JScriptParserTokenTypes.cs b/mcs/class/Microsoft.JScript/Microsoft.JScript/JScriptParserTokenTypes.cs
index b5438331a44..7e4779a8519 100644
--- a/mcs/class/Microsoft.JScript/Microsoft.JScript/JScriptParserTokenTypes.cs
+++ b/mcs/class/Microsoft.JScript/Microsoft.JScript/JScriptParserTokenTypes.cs
@@ -35,67 +35,66 @@ namespace Microsoft.JScript
public const int LITERAL_else = 30;
public const int ASSIGN = 31;
public const int LITERAL_new = 32;
- // "." = 33
+ public const int DOT = 33;
public const int OPEN_BRACKET = 34;
public const int CLOSE_BRACKET = 35;
- public const int DOT = 36;
- public const int INCREMENT = 37;
- public const int DECREMENT = 38;
- public const int LITERAL_delete = 39;
- public const int LITERAL_void = 40;
- public const int LITERAL_typeof = 41;
- public const int PLUS = 42;
- public const int MINUS = 43;
- public const int BITWISE_NOT = 44;
- public const int LOGICAL_NOT = 45;
- public const int MULT = 46;
- public const int DIVISION = 47;
- public const int MODULE = 48;
- public const int SHIFT_LEFT = 49;
- public const int SHIFT_RIGHT = 50;
- public const int UNSIGNED_SHIFT_RIGHT = 51;
- public const int LESS_THAN = 52;
- public const int GREATER_THAN = 53;
- public const int LESS_EQ = 54;
- public const int GREATER_EQ = 55;
- public const int LITERAL_instanceof = 56;
- public const int EQ = 57;
- public const int NEQ = 58;
- public const int STRICT_EQ = 59;
- public const int STRICT_NEQ = 60;
- public const int BITWISE_AND = 61;
- public const int BITWISE_XOR = 62;
- public const int BITWISE_OR = 63;
- public const int LOGICAL_AND = 64;
- public const int LOGICAL_OR = 65;
- public const int INTERR = 66;
- public const int MULT_ASSIGN = 67;
- public const int DIV_ASSIGN = 68;
- public const int MOD_ASSIGN = 69;
- public const int ADD_ASSIGN = 70;
- public const int SUB_ASSIGN = 71;
- public const int SHIFT_LEFT_ASSIGN = 72;
- public const int SHIFT_RIGHT_ASSIGN = 73;
- public const int AND_ASSIGN = 74;
- public const int XOR_ASSIGN = 75;
- public const int OR_ASSIGN = 76;
- public const int LITERAL_this = 77;
- public const int LITERAL_null = 78;
- public const int LITERAL_true = 79;
- public const int LITERAL_false = 80;
- public const int STRING_LITERAL = 81;
- public const int DECIMAL_LITERAL = 82;
- public const int HEX_INTEGER_LITERAL = 83;
- public const int LINE_FEED = 84;
- public const int CARRIAGE_RETURN = 85;
- public const int LINE_SEPARATOR = 86;
- public const int PARAGRAPH_SEPARATOR = 87;
- public const int TAB = 88;
- public const int VERTICAL_TAB = 89;
- public const int FORM_FEED = 90;
- public const int SPACE = 91;
- public const int NO_BREAK_SPACE = 92;
- public const int SL_COMMENT = 93;
+ public const int INCREMENT = 36;
+ public const int DECREMENT = 37;
+ public const int LITERAL_delete = 38;
+ public const int LITERAL_void = 39;
+ public const int LITERAL_typeof = 40;
+ public const int PLUS = 41;
+ public const int MINUS = 42;
+ public const int BITWISE_NOT = 43;
+ public const int LOGICAL_NOT = 44;
+ public const int MULT = 45;
+ public const int DIVISION = 46;
+ public const int MODULE = 47;
+ public const int SHIFT_LEFT = 48;
+ public const int SHIFT_RIGHT = 49;
+ public const int UNSIGNED_SHIFT_RIGHT = 50;
+ public const int LESS_THAN = 51;
+ public const int GREATER_THAN = 52;
+ public const int LESS_EQ = 53;
+ public const int GREATER_EQ = 54;
+ public const int LITERAL_instanceof = 55;
+ public const int EQ = 56;
+ public const int NEQ = 57;
+ public const int STRICT_EQ = 58;
+ public const int STRICT_NEQ = 59;
+ public const int BITWISE_AND = 60;
+ public const int BITWISE_XOR = 61;
+ public const int BITWISE_OR = 62;
+ public const int LOGICAL_AND = 63;
+ public const int LOGICAL_OR = 64;
+ public const int INTERR = 65;
+ public const int MULT_ASSIGN = 66;
+ public const int DIV_ASSIGN = 67;
+ public const int MOD_ASSIGN = 68;
+ public const int ADD_ASSIGN = 69;
+ public const int SUB_ASSIGN = 70;
+ public const int SHIFT_LEFT_ASSIGN = 71;
+ public const int SHIFT_RIGHT_ASSIGN = 72;
+ public const int AND_ASSIGN = 73;
+ public const int XOR_ASSIGN = 74;
+ public const int OR_ASSIGN = 75;
+ public const int LITERAL_this = 76;
+ public const int LITERAL_null = 77;
+ public const int LITERAL_true = 78;
+ public const int LITERAL_false = 79;
+ public const int STRING_LITERAL = 80;
+ public const int DECIMAL_LITERAL = 81;
+ public const int HEX_INTEGER_LITERAL = 82;
+ public const int LINE_FEED = 83;
+ public const int CARRIAGE_RETURN = 84;
+ public const int LINE_SEPARATOR = 85;
+ public const int PARAGRAPH_SEPARATOR = 86;
+ public const int TAB = 87;
+ public const int VERTICAL_TAB = 88;
+ public const int FORM_FEED = 89;
+ public const int SPACE = 90;
+ public const int NO_BREAK_SPACE = 91;
+ public const int SL_COMMENT = 92;
}
}
diff --git a/mcs/class/Microsoft.JScript/Microsoft.JScript/JScriptParserTokenTypes.txt b/mcs/class/Microsoft.JScript/Microsoft.JScript/JScriptParserTokenTypes.txt
index c180659de36..84f89490b85 100644
--- a/mcs/class/Microsoft.JScript/Microsoft.JScript/JScriptParserTokenTypes.txt
+++ b/mcs/class/Microsoft.JScript/Microsoft.JScript/JScriptParserTokenTypes.txt
@@ -29,64 +29,63 @@ LITERAL_if="if"=29
LITERAL_else="else"=30
ASSIGN=31
LITERAL_new="new"=32
-"."=33
+DOT=33
OPEN_BRACKET=34
CLOSE_BRACKET=35
-DOT=36
-INCREMENT=37
-DECREMENT=38
-LITERAL_delete="delete"=39
-LITERAL_void="void"=40
-LITERAL_typeof="typeof"=41
-PLUS=42
-MINUS=43
-BITWISE_NOT=44
-LOGICAL_NOT=45
-MULT=46
-DIVISION=47
-MODULE=48
-SHIFT_LEFT=49
-SHIFT_RIGHT=50
-UNSIGNED_SHIFT_RIGHT=51
-LESS_THAN=52
-GREATER_THAN=53
-LESS_EQ=54
-GREATER_EQ=55
-LITERAL_instanceof="instanceof"=56
-EQ=57
-NEQ=58
-STRICT_EQ=59
-STRICT_NEQ=60
-BITWISE_AND=61
-BITWISE_XOR=62
-BITWISE_OR=63
-LOGICAL_AND=64
-LOGICAL_OR=65
-INTERR=66
-MULT_ASSIGN=67
-DIV_ASSIGN=68
-MOD_ASSIGN=69
-ADD_ASSIGN=70
-SUB_ASSIGN=71
-SHIFT_LEFT_ASSIGN=72
-SHIFT_RIGHT_ASSIGN=73
-AND_ASSIGN=74
-XOR_ASSIGN=75
-OR_ASSIGN=76
-LITERAL_this="this"=77
-LITERAL_null="null"=78
-LITERAL_true="true"=79
-LITERAL_false="false"=80
-STRING_LITERAL=81
-DECIMAL_LITERAL=82
-HEX_INTEGER_LITERAL=83
-LINE_FEED=84
-CARRIAGE_RETURN=85
-LINE_SEPARATOR=86
-PARAGRAPH_SEPARATOR=87
-TAB=88
-VERTICAL_TAB=89
-FORM_FEED=90
-SPACE=91
-NO_BREAK_SPACE=92
-SL_COMMENT=93
+INCREMENT=36
+DECREMENT=37
+LITERAL_delete="delete"=38
+LITERAL_void="void"=39
+LITERAL_typeof="typeof"=40
+PLUS=41
+MINUS=42
+BITWISE_NOT=43
+LOGICAL_NOT=44
+MULT=45
+DIVISION=46
+MODULE=47
+SHIFT_LEFT=48
+SHIFT_RIGHT=49
+UNSIGNED_SHIFT_RIGHT=50
+LESS_THAN=51
+GREATER_THAN=52
+LESS_EQ=53
+GREATER_EQ=54
+LITERAL_instanceof="instanceof"=55
+EQ=56
+NEQ=57
+STRICT_EQ=58
+STRICT_NEQ=59
+BITWISE_AND=60
+BITWISE_XOR=61
+BITWISE_OR=62
+LOGICAL_AND=63
+LOGICAL_OR=64
+INTERR=65
+MULT_ASSIGN=66
+DIV_ASSIGN=67
+MOD_ASSIGN=68
+ADD_ASSIGN=69
+SUB_ASSIGN=70
+SHIFT_LEFT_ASSIGN=71
+SHIFT_RIGHT_ASSIGN=72
+AND_ASSIGN=73
+XOR_ASSIGN=74
+OR_ASSIGN=75
+LITERAL_this="this"=76
+LITERAL_null="null"=77
+LITERAL_true="true"=78
+LITERAL_false="false"=79
+STRING_LITERAL=80
+DECIMAL_LITERAL=81
+HEX_INTEGER_LITERAL=82
+LINE_FEED=83
+CARRIAGE_RETURN=84
+LINE_SEPARATOR=85
+PARAGRAPH_SEPARATOR=86
+TAB=87
+VERTICAL_TAB=88
+FORM_FEED=89
+SPACE=90
+NO_BREAK_SPACE=91
+SL_COMMENT=92
diff --git a/mcs/class/Microsoft.JScript/Microsoft.JScript/Literal.cs b/mcs/class/Microsoft.JScript/Microsoft.JScript/Literal.cs
index eeaaea80505..2749c604f46 100644
--- a/mcs/class/Microsoft.JScript/Microsoft.JScript/Literal.cs
+++ b/mcs/class/Microsoft.JScript/Microsoft.JScript/Literal.cs
@@ -8,6 +8,7 @@
//
using System;
+using System.Reflection.Emit;
namespace Microsoft.JScript {
@@ -17,6 +18,11 @@ namespace Microsoft.JScript {
{
throw new NotImplementedException ();
}
+
+ internal override void Emit (EmitContext ec)
+ {
+ throw new NotImplementedException ();
+ }
}
internal class BooleanLiteral : AST {
@@ -35,7 +41,19 @@ namespace Microsoft.JScript {
internal override bool Resolve (IdentificationTable context)
{
- throw new NotImplementedException ();
+ return true;
+ }
+
+ internal override void Emit (EmitContext ec)
+ {
+ if (ec.is_global_code_method) {
+ if (val)
+ ec.ig.Emit (OpCodes.Ldc_I4_1);
+ else
+ ec.ig.Emit (OpCodes.Ldc_I4_0);
+
+ ec.ig.Emit (OpCodes.Box, typeof (System.Boolean));
+ }
}
}
@@ -57,5 +75,10 @@ namespace Microsoft.JScript {
{
return true;
}
+
+ internal override void Emit (EmitContext ec)
+ {
+ throw new NotImplementedException ();
+ }
}
}
diff --git a/mcs/class/Microsoft.JScript/Microsoft.JScript/NumericBinary.cs b/mcs/class/Microsoft.JScript/Microsoft.JScript/NumericBinary.cs
index ebe001452e5..7fbac05eed7 100644
--- a/mcs/class/Microsoft.JScript/Microsoft.JScript/NumericBinary.cs
+++ b/mcs/class/Microsoft.JScript/Microsoft.JScript/NumericBinary.cs
@@ -9,7 +9,7 @@
using System;
-namespace Microsoft.JScript.Tmp {
+namespace Microsoft.JScript {
public sealed class NumericBinary : BinaryOp {
@@ -34,5 +34,10 @@ namespace Microsoft.JScript.Tmp {
{
throw new NotImplementedException ();
}
+
+ internal override void Emit (EmitContext ec)
+ {
+ throw new NotImplementedException ();
+ }
}
}
diff --git a/mcs/class/Microsoft.JScript/Microsoft.JScript/NumericUnary.cs b/mcs/class/Microsoft.JScript/Microsoft.JScript/NumericUnary.cs
index 65ad6d49946..4bbf721d41e 100644
--- a/mcs/class/Microsoft.JScript/Microsoft.JScript/NumericUnary.cs
+++ b/mcs/class/Microsoft.JScript/Microsoft.JScript/NumericUnary.cs
@@ -28,5 +28,10 @@ namespace Microsoft.JScript.Tmp {
{
throw new NotImplementedException ();
}
+
+ internal override void Emit (EmitContext ec)
+ {
+ throw new NotImplementedException ();
+ }
}
}
diff --git a/mcs/class/Microsoft.JScript/Microsoft.JScript/Package.cs b/mcs/class/Microsoft.JScript/Microsoft.JScript/Package.cs
index d42890e1a4d..6e12bc5266a 100644
--- a/mcs/class/Microsoft.JScript/Microsoft.JScript/Package.cs
+++ b/mcs/class/Microsoft.JScript/Microsoft.JScript/Package.cs
@@ -24,5 +24,10 @@ namespace Microsoft.JScript {
{
throw new NotImplementedException ();
}
+
+ internal override void Emit (EmitContext ec)
+ {
+ throw new NotImplementedException ();
+ }
}
}
diff --git a/mcs/class/Microsoft.JScript/Microsoft.JScript/Plus.cs b/mcs/class/Microsoft.JScript/Microsoft.JScript/Plus.cs
index b774bdc345b..bce947c726e 100644
--- a/mcs/class/Microsoft.JScript/Microsoft.JScript/Plus.cs
+++ b/mcs/class/Microsoft.JScript/Microsoft.JScript/Plus.cs
@@ -9,7 +9,7 @@
using System;
-namespace Microsoft.JScript.Tmp {
+namespace Microsoft.JScript {
public sealed class Plus : BinaryOp {
@@ -34,5 +34,10 @@ namespace Microsoft.JScript.Tmp {
{
throw new NotImplementedException ();
}
+
+ internal override void Emit (EmitContext ec)
+ {
+ throw new NotImplementedException ();
+ }
}
}
diff --git a/mcs/class/Microsoft.JScript/Microsoft.JScript/PostOrPrefixOperator.cs b/mcs/class/Microsoft.JScript/Microsoft.JScript/PostOrPrefixOperator.cs
index b2b909a6b86..23304e1f12f 100644
--- a/mcs/class/Microsoft.JScript/Microsoft.JScript/PostOrPrefixOperator.cs
+++ b/mcs/class/Microsoft.JScript/Microsoft.JScript/PostOrPrefixOperator.cs
@@ -28,5 +28,10 @@ namespace Microsoft.JScript.Tmp {
{
throw new NotImplementedException ();
}
+
+ internal override void Emit (EmitContext ec)
+ {
+ throw new NotImplementedException ();
+ }
}
}
diff --git a/mcs/class/Microsoft.JScript/Microsoft.JScript/Print.cs b/mcs/class/Microsoft.JScript/Microsoft.JScript/Print.cs
index c881b471469..f605b017647 100644
--- a/mcs/class/Microsoft.JScript/Microsoft.JScript/Print.cs
+++ b/mcs/class/Microsoft.JScript/Microsoft.JScript/Print.cs
@@ -32,5 +32,10 @@ namespace Microsoft.JScript {
{
throw new NotImplementedException ();
}
+
+ internal override void Emit (EmitContext ec)
+ {
+ throw new NotImplementedException ();
+ }
}
}
diff --git a/mcs/class/Microsoft.JScript/Microsoft.JScript/Relational.cs b/mcs/class/Microsoft.JScript/Microsoft.JScript/Relational.cs
index d912212c55e..218fdf18348 100644
--- a/mcs/class/Microsoft.JScript/Microsoft.JScript/Relational.cs
+++ b/mcs/class/Microsoft.JScript/Microsoft.JScript/Relational.cs
@@ -62,5 +62,10 @@ namespace Microsoft.JScript {
return true;
}
+
+ internal override void Emit (EmitContext ec)
+ {
+ throw new NotImplementedException ();
+ }
}
}
diff --git a/mcs/class/Microsoft.JScript/Microsoft.JScript/Statement.cs b/mcs/class/Microsoft.JScript/Microsoft.JScript/Statement.cs
index c7abed9da49..e914ba9a188 100644
--- a/mcs/class/Microsoft.JScript/Microsoft.JScript/Statement.cs
+++ b/mcs/class/Microsoft.JScript/Microsoft.JScript/Statement.cs
@@ -46,6 +46,10 @@ namespace Microsoft.JScript {
return true;
}
+ internal override void Emit (EmitContext ec)
+ {
+ throw new NotImplementedException ();
+ }
}
internal class Continue : AST {
@@ -61,6 +65,11 @@ namespace Microsoft.JScript {
{
throw new NotImplementedException ();
}
+
+ internal override void Emit (EmitContext ec)
+ {
+ throw new NotImplementedException ();
+ }
}
internal class Break : AST {
@@ -76,6 +85,11 @@ namespace Microsoft.JScript {
{
throw new NotImplementedException ();
}
+
+ internal override void Emit (EmitContext ec)
+ {
+ throw new NotImplementedException ();
+ }
}
internal class Return : AST {
@@ -97,5 +111,10 @@ namespace Microsoft.JScript {
expression.Resolve (context);
return true;
}
+
+ internal override void Emit (EmitContext ec)
+ {
+ throw new NotImplementedException ();
+ }
}
}
diff --git a/mcs/class/Microsoft.JScript/Microsoft.JScript/StrictEquality.cs b/mcs/class/Microsoft.JScript/Microsoft.JScript/StrictEquality.cs
index 9de38c3e26a..c7c01116cb7 100644
--- a/mcs/class/Microsoft.JScript/Microsoft.JScript/StrictEquality.cs
+++ b/mcs/class/Microsoft.JScript/Microsoft.JScript/StrictEquality.cs
@@ -22,5 +22,10 @@ namespace Microsoft.JScript.Tmp {
{
throw new NotImplementedException ();
}
+
+ internal override void Emit (EmitContext ec)
+ {
+ throw new NotImplementedException ();
+ }
}
}
diff --git a/mcs/class/Microsoft.JScript/Microsoft.JScript/StringLiteral.cs b/mcs/class/Microsoft.JScript/Microsoft.JScript/StringLiteral.cs
index ceee426cb7a..bc2eeb9d617 100644
--- a/mcs/class/Microsoft.JScript/Microsoft.JScript/StringLiteral.cs
+++ b/mcs/class/Microsoft.JScript/Microsoft.JScript/StringLiteral.cs
@@ -8,6 +8,7 @@
//
using System;
+using System.Reflection.Emit;
namespace Microsoft.JScript {
@@ -34,6 +35,13 @@ namespace Microsoft.JScript {
{
return true;
}
+
+ internal override void Emit (EmitContext ec)
+ {
+ if (ec.is_global_code_method) {
+ ec.ig.Emit (OpCodes.Ldstr, str);
+ }
+ }
}
}
diff --git a/mcs/class/Microsoft.JScript/Microsoft.JScript/Throw.cs b/mcs/class/Microsoft.JScript/Microsoft.JScript/Throw.cs
index 2203ffba82c..da72b52f9b7 100644
--- a/mcs/class/Microsoft.JScript/Microsoft.JScript/Throw.cs
+++ b/mcs/class/Microsoft.JScript/Microsoft.JScript/Throw.cs
@@ -33,5 +33,10 @@ namespace Microsoft.JScript {
{
throw new NotImplementedException ();
}
+
+ internal override void Emit (EmitContext ec)
+ {
+ throw new NotImplementedException ();
+ }
}
}
diff --git a/mcs/class/Microsoft.JScript/Microsoft.JScript/Try.cs b/mcs/class/Microsoft.JScript/Microsoft.JScript/Try.cs
index 0e5d06b93e8..2a732c925cf 100644
--- a/mcs/class/Microsoft.JScript/Microsoft.JScript/Try.cs
+++ b/mcs/class/Microsoft.JScript/Microsoft.JScript/Try.cs
@@ -27,5 +27,10 @@ namespace Microsoft.JScript.Tmp {
{
throw new NotImplementedException ();
}
+
+ internal override void Emit (EmitContext ec)
+ {
+ throw new NotImplementedException ();
+ }
}
}
diff --git a/mcs/class/Microsoft.JScript/Microsoft.JScript/TypeOf.cs b/mcs/class/Microsoft.JScript/Microsoft.JScript/TypeOf.cs
index 2c177bf8e5d..e49c29c777a 100644
--- a/mcs/class/Microsoft.JScript/Microsoft.JScript/TypeOf.cs
+++ b/mcs/class/Microsoft.JScript/Microsoft.JScript/TypeOf.cs
@@ -22,5 +22,10 @@ namespace Microsoft.JScript.Tmp {
{
throw new NotImplementedException ();
}
+
+ internal override void Emit (EmitContext ec)
+ {
+ throw new NotImplementedException ();
+ }
}
}
diff --git a/mcs/class/Microsoft.JScript/Microsoft.JScript/VariableDeclaration.cs b/mcs/class/Microsoft.JScript/Microsoft.JScript/VariableDeclaration.cs
index 14d15a67992..f2227e6b9e1 100644
--- a/mcs/class/Microsoft.JScript/Microsoft.JScript/VariableDeclaration.cs
+++ b/mcs/class/Microsoft.JScript/Microsoft.JScript/VariableDeclaration.cs
@@ -70,15 +70,16 @@ namespace Microsoft.JScript {
internal override void Emit (EmitContext ec)
{
- if (parent == null) {
- FieldBuilder field;
- TypeBuilder type = ec.type_builder;
-
- field = type.DefineField (id, Type,
- FieldAttributes.Public |
- FieldAttributes.Static);
- } else
- ec.ig.DeclareLocal (Type);
+ if (!ec.is_global_code_method)
+ if (parent == null) {
+ FieldBuilder field;
+ TypeBuilder type = ec.type_builder;
+
+ field = type.DefineField (id, Type,
+ FieldAttributes.Public |
+ FieldAttributes.Static);
+ } else
+ ec.ig.DeclareLocal (Type);
}
internal override bool Resolve (IdentificationTable context)
diff --git a/mcs/class/Microsoft.JScript/Microsoft.JScript/Visitor.cs b/mcs/class/Microsoft.JScript/Microsoft.JScript/Visitor.cs
deleted file mode 100644
index 392c78953a3..00000000000
--- a/mcs/class/Microsoft.JScript/Microsoft.JScript/Visitor.cs
+++ /dev/null
@@ -1,46 +0,0 @@
-//
-// Visitor.cs: A interface for transversing the AST.
-//
-// Author:
-// Cesar Lopez Nataren
-//
-// (C) 2003, Cesar Lopez Nataren, <cesar@ciencias.unam.mx>
-//
-
-namespace Microsoft.JScript.Tmp
-{
- internal interface Visitor
- {
- object VisitASTList (ASTList prog, object obj);
-
- object VisitVariableDeclaration (VariableDeclaration decl, object args);
-
- object VisitFunctionDeclaration (FunctionDeclaration decl, object args);
-
- object VisitArrayLiteral (ArrayLiteral al, object args);
-
- object VisitBlock (Block b, object args);
-
- object VisitEval (Eval e, object args);
-
- object VisitForIn (ForIn fi, object args);
-
- object VisitFunctionExpression (FunctionExpression fe, object args);
-
- object VisitImport (Import imp, object args);
-
- object VisitPackage (Package imp, object args);
-
- object VisitScriptBlock (ScriptBlock sblock, object args);
-
- object VisitThrow (Throw t, object args);
-
- object VisitTry (Try t, object args);
-
- object VisitWith (With w, object args);
-
- object VisitPrint (Print p, object args);
-
- object VisitStringLiteral (StringLiteral sl, object args);
- }
-}
diff --git a/mcs/class/Microsoft.JScript/Microsoft.JScript/With.cs b/mcs/class/Microsoft.JScript/Microsoft.JScript/With.cs
index 8d95f354f05..7f188e30751 100644
--- a/mcs/class/Microsoft.JScript/Microsoft.JScript/With.cs
+++ b/mcs/class/Microsoft.JScript/Microsoft.JScript/With.cs
@@ -41,5 +41,10 @@ namespace Microsoft.JScript {
{
throw new NotImplementedException ();
}
+
+ internal override void Emit (EmitContext ec)
+ {
+ throw new NotImplementedException ();
+ }
}
}
diff --git a/mcs/class/Microsoft.JScript/Microsoft.JScript/ast.cs b/mcs/class/Microsoft.JScript/Microsoft.JScript/ast.cs
index 0710bbb245b..bf2056d6042 100644
--- a/mcs/class/Microsoft.JScript/Microsoft.JScript/ast.cs
+++ b/mcs/class/Microsoft.JScript/Microsoft.JScript/ast.cs
@@ -1,9 +1,10 @@
//
// ast.cs: Base class for the EcmaScript program tree representation.
//
-// Author: Cesar Octavio Lopez Nataren
+// Author:
+// Cesar Lopez Nataren (cesar@ciencias.unam.mx)
//
-// (C) 2003, Cesar Octavio Lopez Nataren, <cesar@ciencias.unam.mx>
+// (C) 2003, Cesar Lopez Nataren
//
namespace Microsoft.JScript {
@@ -11,11 +12,9 @@ namespace Microsoft.JScript {
public abstract class AST {
//
- // Here the actual IL code generation happens
+ // Here the actual IL code generation happens.
//
- internal virtual void Emit (EmitContext ec)
- {
- }
+ internal abstract void Emit (EmitContext ec);
//
// Perform type checks and associates expressions
diff --git a/mcs/class/Microsoft.JScript/Microsoft.JScript/expression.cs b/mcs/class/Microsoft.JScript/Microsoft.JScript/expression.cs
index b93de301bca..81d3e16616a 100755
--- a/mcs/class/Microsoft.JScript/Microsoft.JScript/expression.cs
+++ b/mcs/class/Microsoft.JScript/Microsoft.JScript/expression.cs
@@ -10,6 +10,7 @@
using System;
using System.Text;
using System.Collections;
+using System.Reflection.Emit;
namespace Microsoft.JScript {
@@ -28,16 +29,24 @@ namespace Microsoft.JScript {
if (oper != JSToken.None)
sb.Append (oper + " ");
- sb.Append (operand.ToString ());
+ if (operand != null)
+ sb.Append (operand.ToString ());
return sb.ToString ();
}
internal override bool Resolve (IdentificationTable context)
{
- operand.Resolve (context);
+ if (operand != null)
+ operand.Resolve (context);
return true;
+ }
+
+ internal override void Emit (EmitContext ec)
+ {
+ if (operand != null)
+ operand.Emit (ec);
}
}
@@ -76,6 +85,28 @@ namespace Microsoft.JScript {
return true;
}
+
+ internal override void Emit (EmitContext ec)
+ {
+ if (ec.is_global_code_method) {
+ ILGenerator ig = ec.ig;
+ emit_operator (ig);
+ }
+ }
+
+ internal void emit_operator (ILGenerator ig)
+ {
+ if (current_op == JSToken.Plus)
+ ig.DeclareLocal (typeof (Microsoft.JScript.Plus));
+ else if (current_op == JSToken.Minus || current_op == JSToken.Divide ||
+ current_op == JSToken.Modulo)
+ ig.DeclareLocal (typeof (Microsoft.JScript.NumericBinary));
+ else if (current_op == JSToken.BitwiseOr || current_op == JSToken.BitwiseXor ||
+ current_op == JSToken.BitwiseAnd)
+ ig.DeclareLocal (typeof (Microsoft.JScript.BitwiseBinary));
+ else if (current_op == JSToken.Equal || current_op == JSToken.NotEqual)
+ ig.DeclareLocal (typeof (Microsoft.JScript.Equality));
+ }
}
public class Conditional : AST {
@@ -107,41 +138,58 @@ namespace Microsoft.JScript {
{
throw new NotImplementedException ();
}
+
+ internal override void Emit (EmitContext ec)
+ {
+ throw new NotImplementedException ();
+ }
}
public class Call : AST {
- internal AST left;
- internal AST args;
+ internal AST member_exp;
+ internal AST args1;
+ internal AST args2;
- public Call (AST left, AST args)
+ public Call (AST member_exp, AST args1, AST args2)
{
- this.left = left;
- this.args = args;
+ this.member_exp = member_exp;
+ this.args1 = args1;
+ this.args2 = args2;
}
public override string ToString ()
{
StringBuilder sb = new StringBuilder ();
- if (left != null)
- sb.Append (left.ToString () + " ");
- if (args != null)
- sb.Append (args.ToString ());
+ if (member_exp != null)
+ sb.Append (member_exp.ToString () + " ");
+ if (args1 != null)
+ sb.Append (args1.ToString ());
+ if (args2 != null)
+ sb.Append (args2.ToString ());
return sb.ToString ();
}
internal override bool Resolve (IdentificationTable context)
{
- if (left != null)
- left.Resolve (context);
+ if (member_exp != null)
+ member_exp.Resolve (context);
+
+ if (args1 != null)
+ args1.Resolve (context);
- if (args != null)
- args.Resolve (context);
+ if (args2 != null)
+ args2.Resolve (context);
return true;
}
+
+ internal override void Emit (EmitContext ec)
+ {
+ throw new NotImplementedException ();
+ }
}
internal class Identifier : AST {
@@ -166,6 +214,11 @@ namespace Microsoft.JScript {
return true;
else throw new Exception ("variable not found: " + name);
}
+
+ internal override void Emit (EmitContext ec)
+ {
+ throw new NotImplementedException ();
+ }
}
public class Args : AST {
@@ -193,6 +246,11 @@ namespace Microsoft.JScript {
}
return true;
}
+
+ internal override void Emit (EmitContext ec)
+ {
+ throw new NotImplementedException ();
+ }
}
public class Expression : AST {
@@ -234,5 +292,18 @@ namespace Microsoft.JScript {
return true;
}
+
+ internal override void Emit (EmitContext ec)
+ {
+ int i, n = exprs.Count;
+ AST exp;
+
+ Console.WriteLine ("n = {0}", n);
+
+ for (i = 0; i < n; i++) {
+ exp = (AST) exprs [i];
+ exp.Emit (ec);
+ }
+ }
}
}
diff --git a/mcs/class/Microsoft.JScript/Microsoft.JScript/jscript-lexer-parser.g b/mcs/class/Microsoft.JScript/Microsoft.JScript/jscript-lexer-parser.g
index 0fe643e7c60..c5301db97b3 100644
--- a/mcs/class/Microsoft.JScript/Microsoft.JScript/jscript-lexer-parser.g
+++ b/mcs/class/Microsoft.JScript/Microsoft.JScript/jscript-lexer-parser.g
@@ -327,40 +327,55 @@ member_expr returns [AST mem_exp]
mem_exp = null;
}
: mem_exp = primary_expr member_aux
- | "new" member_expr OPEN_PARENS (arguments_list [null] | ) CLOSE_PARENS
+ | "new" member_expr arguments
;
member_aux
- : ( "." IDENTIFIER member_aux
+ : ( DOT IDENTIFIER member_aux
| (OPEN_BRACKET)=> OPEN_BRACKET expr CLOSE_BRACKET
- |
+ |
)
;
-
+new_expr returns [AST new_exp]
+{
+ new_exp = null;
+ AST mem_exp = null;
+}
+ : mem_exp = member_expr { new_exp = mem_exp; }
+ ;
+
call_expr returns [Call func_call]
{
func_call = null;
AST member = null;
- AST args;
+ AST args1 = null;
+ AST args2 = null;
}
- : member = member_expr args = call_aux
+ : member = member_expr args1 = arguments args2 = call_aux
{
- func_call = new Call (member, args);
+ func_call = new Call (member, args1, args2);
}
;
call_aux returns [AST args]
{
- Args tmp_args = new Args ();
args = null;
+}
+ :
+ ( arguments
+ | OPEN_BRACKET expr CLOSE_BRACKET
+ | DOT IDENTIFIER
+ ) call_aux
+ |
+ ;
+
+arguments returns [Args args]
+{
+ Args tmp = new Args ();
+ args = null;
}
- : ((OPEN_PARENS (arguments_list [tmp_args] { args = tmp_args; } | ) CLOSE_PARENS
- | OPEN_BRACKET expr CLOSE_BRACKET
- | DOT IDENTIFIER
- ) call_aux
- |
- )
+ : OPEN_PARENS (arguments_list [tmp] { args = tmp; } | ) CLOSE_PARENS
;
arguments_list [Args args]
@@ -371,11 +386,13 @@ arguments_list [Args args]
(COMMA a = assignment_expr { args.Add (a); })*
;
-left_hand_side_expr returns [Call call]
+left_hand_side_expr returns [AST lhe]
{
- call = null;
+ lhe = null;
+ Call call = null;
}
- : call = call_expr
+ : (call_expr)=> call = call_expr { lhe = call; }
+ | lhe = new_expr
;
postfix_expr returns [Unary post_expr]
diff --git a/mcs/class/Microsoft.VisualBasic/Assembly/AssemblyInfo.cs b/mcs/class/Microsoft.VisualBasic/Assembly/AssemblyInfo.cs
new file mode 100644
index 00000000000..4981cfb4f6c
--- /dev/null
+++ b/mcs/class/Microsoft.VisualBasic/Assembly/AssemblyInfo.cs
@@ -0,0 +1,39 @@
+//
+// AssemblyInfo.cs
+//
+// Author:
+// Andreas Nahr (ClassDevelopment@A-SoftTech.com)
+//
+// (C) 2003 Ximian, Inc. http://www.ximian.com
+//
+
+using System;
+using System.Reflection;
+using System.Resources;
+using System.Security;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about the Microsoft.VisualBasic assembly
+
+#if (NET_1_0)
+ [assembly: AssemblyVersion("7.0.3300.0")]
+ [assembly: SatelliteContractVersion("7.0.3300.0")]
+#endif
+#if (NET_1_1)
+ [assembly: AssemblyVersion("7.0.5000.0")]
+ [assembly: SatelliteContractVersion("7.0.5000.0")]
+ [assembly: ComCompatibleVersion(7, 0, 3300, 0)]
+ [assembly: TypeLibVersion(7, 1)]
+#endif
+
+[assembly: AssemblyTitle("Microsoft.VisualBasic.dll")]
+[assembly: AssemblyDescription("Microsoft.VisualBasic.dll")]
+[assembly: AssemblyCompany("MONO development team")]
+[assembly: AssemblyCopyright("(c) 2003 Various Authors")]
+
+[assembly: NeutralResourcesLanguage("en-US")]
+[assembly: AllowPartiallyTrustedCallers()]
+
+[assembly: AssemblyDelaySign(true)]
+//[assembly: AssemblyKeyFile("")] \ No newline at end of file
diff --git a/mcs/class/Microsoft.VisualBasic/Assembly/ChangeLog b/mcs/class/Microsoft.VisualBasic/Assembly/ChangeLog
new file mode 100644
index 00000000000..52ac3244a7e
--- /dev/null
+++ b/mcs/class/Microsoft.VisualBasic/Assembly/ChangeLog
@@ -0,0 +1,5 @@
+2003-11-13 Andreas Nahr <ClassDevelopment@A-SoftTech.com>
+
+ * AssemblyInfo.cs: Added
+ * ChangeLog: Added
+ * Locale.cs: Added \ No newline at end of file
diff --git a/mcs/class/Microsoft.VisualBasic/Assembly/Locale.cs b/mcs/class/Microsoft.VisualBasic/Assembly/Locale.cs
new file mode 100644
index 00000000000..a456449296f
--- /dev/null
+++ b/mcs/class/Microsoft.VisualBasic/Assembly/Locale.cs
@@ -0,0 +1,24 @@
+//
+// Locale.cs
+//
+// Author:
+// Miguel de Icaza (miguel@ximian.com)
+// Andreas Nahr (ClassDevelopment@A-SoftTech.com)
+//
+// (C) 2001 - 2003 Ximian, Inc (http://www.ximian.com)
+//
+
+internal sealed class Locale {
+
+ private Locale ()
+ {
+ }
+
+ /// <summary>
+ /// Returns the translated message for the current locale
+ /// </summary>
+ public static string GetText (string msg)
+ {
+ return msg;
+ }
+}
diff --git a/mcs/class/Microsoft.VisualBasic/Changelog b/mcs/class/Microsoft.VisualBasic/Changelog
index b7dd9b1420d..4bedee4f262 100644
--- a/mcs/class/Microsoft.VisualBasic/Changelog
+++ b/mcs/class/Microsoft.VisualBasic/Changelog
@@ -1,3 +1,7 @@
+2003-11-13 Andreas Nahr <ClassDevelopment@A-SoftTech.com>
+
+ * Microsoft.VisualBasic.dll.sources: Added Assembly files
+
2003-03-12 Martin Willemoes Hansen <mwh@sysrq.dk>
* Patched makefile.gnu to work with the new NUnit2 tests
diff --git a/mcs/class/Microsoft.VisualBasic/Microsoft.VisualBasic.dll.sources b/mcs/class/Microsoft.VisualBasic/Microsoft.VisualBasic.dll.sources
index 9763f5bced6..077b6db75d6 100644
--- a/mcs/class/Microsoft.VisualBasic/Microsoft.VisualBasic.dll.sources
+++ b/mcs/class/Microsoft.VisualBasic/Microsoft.VisualBasic.dll.sources
@@ -1,3 +1,5 @@
+Assembly/AssemblyInfo.cs
+Assembly/Locale.cs
Microsoft.VisualBasic/AppWinStyle.cs
Microsoft.VisualBasic/CallType.cs
Microsoft.VisualBasic/Collection.cs
diff --git a/mcs/class/Microsoft.VisualBasic/Test/StringsTest.cs b/mcs/class/Microsoft.VisualBasic/Test/StringsTest.cs
new file mode 100644
index 00000000000..a2291270e4c
--- /dev/null
+++ b/mcs/class/Microsoft.VisualBasic/Test/StringsTest.cs
Binary files differ
diff --git a/mcs/class/Microsoft.Web.Services/Makefile b/mcs/class/Microsoft.Web.Services/Makefile
index 39854cf2499..63770ad57ee 100644
--- a/mcs/class/Microsoft.Web.Services/Makefile
+++ b/mcs/class/Microsoft.Web.Services/Makefile
@@ -110,7 +110,8 @@ dist-local: dist-default
# Fun with dependency tracking
$(the_lib): $(makefrag) $(stampfile) $(response)
- $(CSCOMPILE) $(LIBRARY_FLAGS) $(LIB_MCS_FLAGS) /target:library /out:$@ @$(response)
+ $(CSCOMPILE) $(LIBRARY_FLAGS) $(LIB_MCS_FLAGS) /target:library /out:$(topdir)/class/lib/Microsoft.Web.Services.dll @$(response)
+ mv $(topdir)/class/lib/Microsoft.Web.Services.dll $(topdir)/class/lib/Microsoft.Web.Services.1.dll
$(makefrag): $(sourcefile)
@echo Creating $@ ...
@@ -135,7 +136,8 @@ $(stampfile):
endif
$(the_lib2): $(makefrag2) $(stampfile2) $(response2)
- $(CSCOMPILE) $(LIBRARY_FLAGS) $(LIB_MCS_FLAGS2) /target:library /out:$@ @$(response2)
+ $(CSCOMPILE) $(LIBRARY_FLAGS) $(LIB_MCS_FLAGS2) /target:library /out:$(topdir)/class/lib/Microsoft.Web.Services.dll @$(response2)
+ mv $(topdir)/class/lib/Microsoft.Web.Services.dll $(topdir)/class/lib/Microsoft.Web.Services.2.dll
$(makefrag2): $(sourcefile2)
@echo Creating $@ ...
diff --git a/mcs/class/Mono.Cairo/ChangeLog b/mcs/class/Mono.Cairo/ChangeLog
index a739a78f6ef..e06c8fcab0f 100644
--- a/mcs/class/Mono.Cairo/ChangeLog
+++ b/mcs/class/Mono.Cairo/ChangeLog
@@ -1,3 +1,20 @@
+2003-11-28 Miguel de Icaza <miguel@ximian.com>
+
+ * Mono.Cairo/Object.cs:
+
+ * Mono.Cairo/Surface.cs (LookupSurface): New method, it took me a
+ while to find out why Cairo applications would crash sometimes.
+ The problem was that Cairo.Object:TargetSurface get property would
+ create a Surface from an IntPtr, leading to having two managed
+ objects owning the same unmanaged Surface.
+
+ (Surface..ctor): Make private, so only this module can create
+ surfaces.
+
+ (Surface.Dispose): Add disposable pattern, finalizer.
+
+ * Mono.Cairo/Object.cs: Add disposable pattern, finalizer.
+
2003-10-11 Duncan Mak <duncan@ximian.com>
* Mono.Cairo/Cairo.cs (cairo_set_target_drawable): Not available anymore, removed.
diff --git a/mcs/class/Mono.Cairo/Mono.Cairo.dll.sources b/mcs/class/Mono.Cairo/Mono.Cairo.dll.sources
index 99096f53231..67a9efc7b06 100644
--- a/mcs/class/Mono.Cairo/Mono.Cairo.dll.sources
+++ b/mcs/class/Mono.Cairo/Mono.Cairo.dll.sources
@@ -1,4 +1,4 @@
./Mono.Cairo/Cairo.cs
./Mono.Cairo/Matrix.cs
-./Mono.Cairo/Object.cs
+./Mono.Cairo/Graphics.cs
./Mono.Cairo/Surface.cs
diff --git a/mcs/class/Mono.Cairo/Mono.Cairo/Cairo.cs b/mcs/class/Mono.Cairo/Mono.Cairo/Cairo.cs
index af5760f8722..68e6e4465f6 100644
--- a/mcs/class/Mono.Cairo/Mono.Cairo/Cairo.cs
+++ b/mcs/class/Mono.Cairo/Mono.Cairo/Cairo.cs
@@ -50,6 +50,10 @@ namespace Cairo {
public static extern void cairo_set_target_image (
IntPtr cr, string data, Cairo.Format format, int width, int height, int stride);
+ [DllImport (CairoImp)]
+ public static extern void cairo_set_target_drawable (
+ IntPtr ct, IntPtr display, IntPtr drawable);
+
[DllImport (CairoImp)]
public static extern void cairo_set_operator (IntPtr cr, Cairo.Operator op);
@@ -340,6 +344,7 @@ namespace Cairo {
[DllImport (CairoImp)]
public static extern Cairo.Status cairo_matrix_transform_point (
IntPtr matrix, ref double x, ref double y);
+
}
//
diff --git a/mcs/class/Mono.Cairo/Mono.Cairo/Graphics.cs b/mcs/class/Mono.Cairo/Mono.Cairo/Graphics.cs
new file mode 100644
index 00000000000..ab209cb1526
--- /dev/null
+++ b/mcs/class/Mono.Cairo/Mono.Cairo/Graphics.cs
@@ -0,0 +1,369 @@
+//
+// Mono.Cairo.Graphics.cs
+//
+// Author:
+// Duncan Mak (duncan@ximian.com)
+// Miguel de Icaza (miguel@novell.com)
+//
+// (C) Ximian Inc, 2003.
+// (C) Novell Inc, 2003.
+//
+// This is an OO wrapper API for the Cairo API.
+//
+
+using System;
+using System.Drawing;
+using System.Runtime.InteropServices;
+using Cairo;
+
+namespace Cairo {
+
+ public class Graphics : IDisposable
+ {
+ IntPtr state;
+
+ public Graphics ()
+ {
+ state = CairoAPI.cairo_create ();
+ }
+
+ private Graphics (IntPtr state)
+ {
+ this.state = state;
+ }
+
+ ~Graphics ()
+ {
+ Console.WriteLine ("Cairo not thread safe, you might want to call IDisposable.Dispose on Cairo.Surface");
+
+ }
+
+ void IDisposable.Dispose ()
+ {
+ Dispose (true);
+ GC.SuppressFinalize (this);
+ }
+
+ protected virtual void Dispose (bool disposing)
+ {
+ if (!disposing){
+ Console.WriteLine ("Cairo.Graphics: called from thread");
+ return;
+ }
+
+ if (state == (IntPtr) 0)
+ return;
+
+ CairoAPI.cairo_destroy (state);
+ state = (IntPtr) 0;
+ }
+
+ public Cairo.Graphics Copy ()
+ {
+ IntPtr dest;
+ CairoAPI.cairo_copy (out dest, state);
+ return new Cairo.Graphics (dest);
+ }
+
+ public void Save ()
+ {
+ CairoAPI.cairo_save (state);
+ }
+
+ public void Restore ()
+ {
+ CairoAPI.cairo_restore (state);
+ }
+
+ public Cairo.Status Status {
+ get {
+ return CairoAPI.cairo_status (state);
+ }
+ }
+
+ public string StatusString {
+ get {
+ return CairoAPI.cairo_status_string (state);
+ }
+ }
+
+ public IntPtr Handle {
+ get {
+ return state;
+ }
+ }
+
+ public Cairo.Operator Operator {
+ set {
+ CairoAPI.cairo_set_operator (state, value);
+ }
+
+ get {
+ return CairoAPI.cairo_current_operator (state);
+ }
+ }
+
+ public void SetRGBColor (double r, double g, double b)
+ {
+ CairoAPI.cairo_set_rgb_color (state, r, g, b);
+ }
+
+ public double Tolerance {
+ set {
+ CairoAPI.cairo_set_tolerance (state, value);
+ }
+
+ get {
+ return CairoAPI.cairo_current_tolerance (state);
+ }
+ }
+
+ public double Alpha {
+ set {
+ CairoAPI.cairo_set_alpha (state, value);
+ }
+
+ get {
+ return CairoAPI.cairo_current_alpha (state);
+ }
+ }
+
+ public Cairo.FillRule FillRule {
+ set {
+ CairoAPI.cairo_set_fill_rule (state, value);
+ }
+
+ get {
+ return CairoAPI.cairo_current_fill_rule (state);
+ }
+ }
+
+ public double LineWidth {
+ set {
+ CairoAPI.cairo_set_line_width (state, value);
+ }
+
+ get {
+ return CairoAPI.cairo_current_line_width (state);
+ }
+ }
+
+ public Cairo.LineCap LineCap {
+ set {
+ CairoAPI.cairo_set_line_cap (state, value);
+ }
+
+ get {
+ return CairoAPI.cairo_current_line_cap (state);
+ }
+ }
+
+ public Cairo.LineJoin LineJoin {
+ set {
+ CairoAPI.cairo_set_line_join (state, value);
+ }
+
+ get {
+ return CairoAPI.cairo_current_line_join (state);
+ }
+ }
+
+ public void SetDash (double [] dashes, int ndash, double offset)
+ {
+ CairoAPI.cairo_set_dash (state, dashes, ndash, offset);
+ }
+
+ public Cairo.Surface Pattern {
+ set {
+ CairoAPI.cairo_set_pattern (state, value.Handle);
+ }
+ }
+
+ public double MiterLimit {
+ set {
+ CairoAPI.cairo_set_miter_limit (state, value);
+ }
+
+ get {
+ return CairoAPI.cairo_current_miter_limit (state);
+ }
+ }
+
+ public void GetCurrentPoint (out double x, out double y)
+ {
+ CairoAPI.cairo_current_point (state, out x, out y);
+ }
+
+ public Point CurrentPoint {
+ get {
+ double x, y;
+ CairoAPI.cairo_current_point (state, out x, out y);
+ return new Point ((int) x, (int) y);
+ }
+ }
+
+ public Cairo.Surface TargetSurface {
+ set {
+ CairoAPI.cairo_set_target_surface (state, value.Handle);
+ }
+
+ get {
+ return Cairo.Surface.LookupExternalSurface (
+ CairoAPI.cairo_current_target_surface (state));
+ }
+ }
+
+#region Path methods
+
+ public void NewPath ()
+ {
+ CairoAPI.cairo_new_path (state);
+ }
+
+ public void MoveTo (double x, double y)
+ {
+ CairoAPI.cairo_move_to (state, x, y);
+ }
+
+ public void LineTo (double x, double y)
+ {
+ CairoAPI.cairo_line_to (state, x, y);
+ }
+
+ public void CurveTo (double x1, double y1, double x2, double y2, double x3, double y3)
+ {
+ CairoAPI.cairo_curve_to (state, x1, y1, x2, x2, x3, y3);
+ }
+
+ public void CurveTo (Point p1, Point p2, Point p3)
+ {
+ CairoAPI.cairo_curve_to (state, p1.X, p1.Y, p2.X, p2.Y, p3.X, p3.Y);
+ }
+
+ public void RelMoveTo (double dx, double dy)
+ {
+ CairoAPI.cairo_rel_move_to (state, dx, dy);
+ }
+
+ public void RelLineTo (double dx, double dy)
+ {
+ CairoAPI.cairo_rel_line_to (state, dx, dy);
+ }
+
+ public void RelCurveTo (double dx1, double dy1, double dx2, double dy2, double dx3, double dy3)
+ {
+ CairoAPI.cairo_rel_curve_to (state, dx1, dy1, dx2, dy2, dx3, dy3);
+ }
+
+ public void Arc (double xc, double yc, double radius, double angel1, double angel2)
+ {
+ CairoAPI.cairo_arc (state, xc, yc, radius, angel1, angel2);
+ }
+
+ public void ArcNegative (double xc, double yc, double radius, double angel1, double angel2)
+ {
+ CairoAPI.cairo_arc_negative (state, xc, yc, radius, angel1, angel2);
+ }
+
+ public void Rectangle (double x, double y, double width, double height)
+ {
+ CairoAPI.cairo_rectangle (state, x, y, width, height);
+ }
+
+ public void ClosePath ()
+ {
+ CairoAPI.cairo_close_path (state);
+ }
+#endregion
+
+#region Painting Methods
+
+ public void Stroke ()
+ {
+ CairoAPI.cairo_stroke (state);
+ }
+
+ public void Fill ()
+ {
+ CairoAPI.cairo_fill (state);
+ }
+
+#endregion
+
+ public void Clip ()
+ {
+ CairoAPI.cairo_clip (state);
+ }
+
+#region Modified state
+
+ public void SetTargetImage (
+ string data, Cairo.Format format, int width, int height, int stride)
+ {
+ CairoAPI.cairo_set_target_image (state, data, format, width, height, stride);
+ }
+
+ public void SetTargetDrawable (IntPtr dpy, IntPtr drawable)
+ {
+ CairoAPI.cairo_set_target_drawable (state, dpy, drawable);
+ }
+
+ public void SetPattern (Surface pattern)
+ {
+ CairoAPI.cairo_set_pattern (state, pattern.Handle);
+ }
+#endregion
+
+ public void Rotate (double angle)
+ {
+ CairoAPI.cairo_rotate (state, angle);
+ }
+
+ public void Scale (double sx, double sy)
+ {
+ CairoAPI.cairo_scale (state, sx, sy);
+ }
+
+ public void Translate (double tx, double ty)
+ {
+ CairoAPI.cairo_translate (state, tx, ty);
+ }
+
+ public void TransformPoint (ref double x, ref double y)
+ {
+ CairoAPI.cairo_transform_point (state, ref x, ref y);
+ }
+
+ public void TransformDistance (ref double dx, ref double dy)
+ {
+ CairoAPI.cairo_transform_distance (state, ref dx, ref dy);
+ }
+
+ public void InverseTransformPoint (ref double x, ref double y)
+ {
+ CairoAPI.cairo_inverse_transform_point (state, ref x, ref y);
+ }
+
+ public void InverseTransformDistance (ref double dx, ref double dy)
+ {
+ CairoAPI.cairo_inverse_transform_distance (state, ref dx, ref dy);
+ }
+
+ public void ConcatMatrix (Cairo.Matrix matrix)
+ {
+ CairoAPI.cairo_concat_matrix (state, matrix.Pointer);
+ }
+
+ public Cairo.Matrix Matrix {
+ set {
+ CairoAPI.cairo_set_matrix (state, value.Pointer);
+ }
+
+ get {
+ IntPtr p;
+ CairoAPI.cairo_current_matrix (state, out p);
+ return new Cairo.Matrix (p);
+ }
+ }
+ }
+}
diff --git a/mcs/class/Mono.Cairo/Mono.Cairo/Object.cs b/mcs/class/Mono.Cairo/Mono.Cairo/Object.cs
index afe4476f3ce..ab209cb1526 100644
--- a/mcs/class/Mono.Cairo/Mono.Cairo/Object.cs
+++ b/mcs/class/Mono.Cairo/Mono.Cairo/Object.cs
@@ -1,9 +1,12 @@
//
-// Mono.Cairo.Object.cs
+// Mono.Cairo.Graphics.cs
//
-// Author: Duncan Mak
+// Author:
+// Duncan Mak (duncan@ximian.com)
+// Miguel de Icaza (miguel@novell.com)
//
// (C) Ximian Inc, 2003.
+// (C) Novell Inc, 2003.
//
// This is an OO wrapper API for the Cairo API.
//
@@ -15,35 +18,51 @@ using Cairo;
namespace Cairo {
- public class Object
+ public class Graphics : IDisposable
{
IntPtr state;
- public Object ()
- : this (Create ())
+ public Graphics ()
{
+ state = CairoAPI.cairo_create ();
}
-
- internal Object (IntPtr ptr)
- {
- state = ptr;
- }
-
- public static IntPtr Create ()
- {
- return CairoAPI.cairo_create ();
- }
- public void Destroy ()
+ private Graphics (IntPtr state)
+ {
+ this.state = state;
+ }
+
+ ~Graphics ()
+ {
+ Console.WriteLine ("Cairo not thread safe, you might want to call IDisposable.Dispose on Cairo.Surface");
+
+ }
+
+ void IDisposable.Dispose ()
+ {
+ Dispose (true);
+ GC.SuppressFinalize (this);
+ }
+
+ protected virtual void Dispose (bool disposing)
{
+ if (!disposing){
+ Console.WriteLine ("Cairo.Graphics: called from thread");
+ return;
+ }
+
+ if (state == (IntPtr) 0)
+ return;
+
CairoAPI.cairo_destroy (state);
+ state = (IntPtr) 0;
}
- public Cairo.Object Copy ()
+ public Cairo.Graphics Copy ()
{
IntPtr dest;
CairoAPI.cairo_copy (out dest, state);
- return new Cairo.Object (dest);
+ return new Cairo.Graphics (dest);
}
public void Save ()
@@ -68,7 +87,7 @@ namespace Cairo {
}
}
- public IntPtr Pointer {
+ public IntPtr Handle {
get {
return state;
}
@@ -156,7 +175,7 @@ namespace Cairo {
public Cairo.Surface Pattern {
set {
- CairoAPI.cairo_set_pattern (state, value.Pointer);
+ CairoAPI.cairo_set_pattern (state, value.Handle);
}
}
@@ -185,11 +204,11 @@ namespace Cairo {
public Cairo.Surface TargetSurface {
set {
- CairoAPI.cairo_set_target_surface (state, value.Pointer);
+ CairoAPI.cairo_set_target_surface (state, value.Handle);
}
get {
- return new Cairo.Surface (
+ return Cairo.Surface.LookupExternalSurface (
CairoAPI.cairo_current_target_surface (state));
}
}
@@ -284,6 +303,15 @@ namespace Cairo {
CairoAPI.cairo_set_target_image (state, data, format, width, height, stride);
}
+ public void SetTargetDrawable (IntPtr dpy, IntPtr drawable)
+ {
+ CairoAPI.cairo_set_target_drawable (state, dpy, drawable);
+ }
+
+ public void SetPattern (Surface pattern)
+ {
+ CairoAPI.cairo_set_pattern (state, pattern.Handle);
+ }
#endregion
public void Rotate (double angle)
diff --git a/mcs/class/Mono.Cairo/Mono.Cairo/Surface.cs b/mcs/class/Mono.Cairo/Mono.Cairo/Surface.cs
index 920c375ea5b..16660b9b2df 100644
--- a/mcs/class/Mono.Cairo/Mono.Cairo/Surface.cs
+++ b/mcs/class/Mono.Cairo/Mono.Cairo/Surface.cs
@@ -1,9 +1,12 @@
//
// Mono.Cairo.CairoSurfaceObject.cs
//
-// Author: Duncan Mak
+// Authors:
+// Duncan Mak
+// Miguel de Icaza.
//
// (C) Ximian Inc, 2003.
+// (C) Novell, Inc. 2003.
//
// This is an OO wrapper API for the Cairo API
//
@@ -11,35 +14,53 @@
using System;
using System.Drawing;
using System.Runtime.InteropServices;
+using System.Collections;
using Cairo;
namespace Cairo {
- public class Surface
+ public class Surface : IDisposable
{
+ static Hashtable surfaces = new Hashtable ();
IntPtr surface;
- internal Surface (IntPtr ptr)
+ private Surface (IntPtr ptr, bool owns)
{
surface = ptr;
+ lock (typeof (Surface)){
+ surfaces [ptr] = this;
+ }
+ if (!owns)
+ CairoAPI.cairo_surface_reference (ptr);
}
+ static internal Surface LookupExternalSurface (IntPtr p)
+ {
+ lock (typeof (Surface)){
+ object o = surfaces [p];
+ if (o == null){
+ return new Surface (p, false);
+ }
+ return (Surface) o;
+ }
+ }
+
public static Cairo.Surface CreateForImage (
string data, Cairo.Format format, int width, int height, int stride)
{
IntPtr p = CairoAPI.cairo_surface_create_for_image (
data, format, width, height, stride);
- return new Cairo.Surface (p);
+ return new Cairo.Surface (p, true);
}
public static Cairo.Surface CreateSimilar (
Cairo.Surface surface, Cairo.Format format, int width, int height)
{
IntPtr p = CairoAPI.cairo_surface_create_similar (
- surface.Pointer, format, width, height);
+ surface.Handle, format, width, height);
- return new Cairo.Surface (p);
+ return new Cairo.Surface (p, true);
}
public static Cairo.Surface CreateSimilarSolid (
@@ -47,17 +68,34 @@ namespace Cairo {
int width, int height, double red, double green, double blue, double alpha)
{
IntPtr p = CairoAPI.cairo_surface_create_similar_solid (
- surface.Pointer, format, width, height, red, green, blue, alpha);
+ surface.Handle, format, width, height, red, green, blue, alpha);
- return new Cairo.Surface (p);
+ return new Cairo.Surface (p, true);
}
- public void Destroy ()
- {
- CairoAPI.cairo_surface_destroy (surface);
- }
-
- public IntPtr Pointer {
+ ~Surface ()
+ {
+ Dispose (false);
+ }
+
+ void IDisposable.Dispose ()
+ {
+ Dispose (true);
+ GC.SuppressFinalize (this);
+ }
+
+ protected virtual void Dispose (bool disposing)
+ {
+ if (surface == (IntPtr) 0)
+ return;
+ lock (typeof (Surface)){
+ surfaces.Remove (surface);
+ }
+ CairoAPI.cairo_surface_destroy (surface);
+ surface = (IntPtr) 0;
+ }
+
+ public IntPtr Handle {
get { return surface; }
}
diff --git a/mcs/class/Mono.Data.DB2Client/Mono.Data.Db2Client/DB2ClientParameter.cs b/mcs/class/Mono.Data.DB2Client/Mono.Data.Db2Client/DB2ClientParameter.cs
index bec76f91531..863c4efb535 100755
--- a/mcs/class/Mono.Data.DB2Client/Mono.Data.Db2Client/DB2ClientParameter.cs
+++ b/mcs/class/Mono.Data.DB2Client/Mono.Data.Db2Client/DB2ClientParameter.cs
@@ -203,7 +203,7 @@ namespace DB2ClientCS
{
get
{
- return Value;
+ return dataVal;
}
set
{
diff --git a/mcs/class/Mono.Data.SqliteClient/Mono.Data.SqliteClient/SqliteDataReader.cs b/mcs/class/Mono.Data.SqliteClient/Mono.Data.SqliteClient/SqliteDataReader.cs
index abaf08507f7..7cb09884610 100644
--- a/mcs/class/Mono.Data.SqliteClient/Mono.Data.SqliteClient/SqliteDataReader.cs
+++ b/mcs/class/Mono.Data.SqliteClient/Mono.Data.SqliteClient/SqliteDataReader.cs
@@ -195,7 +195,7 @@ namespace Mono.Data.SqliteClient
for (int i = 0; i < argc; i++) {
string col = new String (colnames[i]);
columns.Add (col);
- column_names[col.ToLower ()] = i++;
+ column_names[col.ToLower ()] = i;
}
}
diff --git a/mcs/class/Mono.Data.SqliteClient/Mono.Data.SqliteClient/SqliteParameterCollection.cs b/mcs/class/Mono.Data.SqliteClient/Mono.Data.SqliteClient/SqliteParameterCollection.cs
index 3e1893438ca..5b430740136 100644
--- a/mcs/class/Mono.Data.SqliteClient/Mono.Data.SqliteClient/SqliteParameterCollection.cs
+++ b/mcs/class/Mono.Data.SqliteClient/Mono.Data.SqliteClient/SqliteParameterCollection.cs
@@ -132,7 +132,7 @@ namespace Mono.Data.SqliteClient
public SqliteParameter Add (SqliteParameter param)
{
- Add (param);
+ Add ((object)param);
return param;
}
diff --git a/mcs/class/Mono.Data.Tds/ChangeLog b/mcs/class/Mono.Data.Tds/ChangeLog
index 54e830ce44b..b8f0703fd6d 100644
--- a/mcs/class/Mono.Data.Tds/ChangeLog
+++ b/mcs/class/Mono.Data.Tds/ChangeLog
@@ -1,3 +1,8 @@
+2003-11-20 Joerg Rosenkranz <joergr@voelcker.com>
+
+ * Mono.Data.Tds/TdsMetaParameter.cs: Fixed Prepare to allow string
+ and binary parameters with Length == 0
+
2002-12-22 Tim Coleman <tim@timcoleman.com>
* Mono.Data.Tds.Protocol/TdsComm.cs:
Change GetString to NOT explicitly add a NUL
diff --git a/mcs/class/Mono.Data.Tds/Mono.Data.Tds/TdsMetaParameter.cs b/mcs/class/Mono.Data.Tds/Mono.Data.Tds/TdsMetaParameter.cs
index 9c28363410c..11c4ee70ed8 100644
--- a/mcs/class/Mono.Data.Tds/Mono.Data.Tds/TdsMetaParameter.cs
+++ b/mcs/class/Mono.Data.Tds/Mono.Data.Tds/TdsMetaParameter.cs
@@ -111,13 +111,13 @@ namespace Mono.Data.Tds {
case "varchar":
case "nvarchar":
case "varbinary":
- result.Append (String.Format ("({0})", Size));
+ result.Append (String.Format ("({0})", Size > 0 ? Size : 1));
break;
case "char":
case "nchar":
case "binary":
if (isSizeSet && Size > 0)
- result.Append (String.Format ("({0})", Size));
+ result.Append (String.Format ("({0})", Size > 0 ? Size : 1));
break;
}
return result.ToString ();
diff --git a/mcs/class/Mono.Posix/Mono.Posix/ChangeLog b/mcs/class/Mono.Posix/Mono.Posix/ChangeLog
index bfb7b9528aa..910ac63db4e 100644
--- a/mcs/class/Mono.Posix/Mono.Posix/ChangeLog
+++ b/mcs/class/Mono.Posix/Mono.Posix/ChangeLog
@@ -1,3 +1,8 @@
+2003-11-11 Wojciech Polak <polak@gnu.org
+
+ * Syscall.cs: Applied patch from Wojciech Polak <polak@gnu.org> to
+ support IsAtty.
+
2003-05-16 Dick Porter <dick@ximian.com>
* UnixEndPoint.cs: New property to get and set the filename, like
diff --git a/mcs/class/Mono.Posix/Mono.Posix/Syscall.cs b/mcs/class/Mono.Posix/Mono.Posix/Syscall.cs
index 38e6615b746..274c792bf52 100644
--- a/mcs/class/Mono.Posix/Mono.Posix/Syscall.cs
+++ b/mcs/class/Mono.Posix/Mono.Posix/Syscall.cs
@@ -44,5 +44,17 @@ namespace Mono.Posix {
[DllImport ("libc")]
public static extern int chmod (string file, FileMode mode);
+
+ [DllImport ("libc", EntryPoint="isatty")]
+ static extern int syscall_isatty (int desc);
+
+ public static bool isatty (int desc)
+ {
+ int res = syscall_isatty (desc);
+ if (res == 1)
+ return true;
+ else
+ return false;
+ }
}
}
diff --git a/mcs/class/Mono.Security/ChangeLog b/mcs/class/Mono.Security/ChangeLog
index 20799c3502a..fbbf4e8f01d 100644
--- a/mcs/class/Mono.Security/ChangeLog
+++ b/mcs/class/Mono.Security/ChangeLog
@@ -1,3 +1,154 @@
+2003-11-27 Sebastien Pouliot <spouliot@videotron.ca>
+
+ * Mono.Security.dll.sources: Added MD4, MD4Managed and PKCS8 to build.
+ * Mono.Security_test.dll.sources: Added unit tests for MD4, MD4Managed
+ and PKCS8.
+
+2003-11-22 Carlos Guzman Alvarez <carlosga@telefonica.net>
+
+ * Changed line endings to unix format in SSL/TLS sources.
+
+ * Mono.Security.CryptographyoHMD5SHA1CryptoServiceProvider.cs:
+
+ - Removed file (now it's called MD5SHA1.cs)
+
+ * Mono.Security.Protocol.Tls/TlsCipherSuiteFactory.cs:
+
+ - Removed comments from AES ciphersuites.
+
+
+2003-11-17 Carlos Guzmán Álvarez <carlosga@telefonica.net>
+
+ * Mono.Security.Protocol.Tls/SslClientStream.cs:
+
+ Removed ReadByte method, use innerStream.ReadByte() method instead.
+
+2003-11-13 Carlos Guzmán Álvarez <carlosga@telefonica.net>
+
+ * Added implementation of an SslClientStream class similar to the MS .NET Framework 1.2 documentation.
+
+ The next files are no more needed:
+
+ - TlsSession.cs
+
+ - TlsNetworkStream.cs
+
+ - TlsSocket.cs
+
+ - TlsSessionState.cs
+
+ The next files are renamed:
+
+ - TlsSessionSettings.cs -> TlsClientSettings.cs
+
+ - TlsSessionContext.cs -> TlsContext.cs
+
+ The next files are new:
+
+ - SslClientStream.cs ( the name is non definitive yet )
+
+ The next files where changed to reflect the new canges:
+
+ - TlsHandshakeMessage.cs
+
+ - TlsClientCertificate.cs
+
+ - TlsClientCertificateVerify.cs
+
+ - TlsClientFinished.cs
+
+ - TlsClientHello.cs
+
+ - TlsClientKeyExchange.cs
+
+ - TlsServerCertificate.cs
+
+ - TlsServerCertificateRequest.cs
+
+ - TlsServerFinished.cs
+
+ - TlsServerHello.cs
+
+ - TlsServerHelloDone.cs
+
+ - TlsServerKeyExchange.cs
+
+ - TlsAlert.cs
+
+ - TlsCloseNotifyAlert.cs
+
+
+2003-11-12 Carlos Guzmán Álvarez <carlosga@telefonica.net>
+
+ * Mono.Security.Protocol.Tls.Alerts/TlsAlert.cs:
+
+ - Changes for give full error message only in debug mode ( Thanks to Sebastién Pouliot. )
+
+ * Mono.Security.Protocol.Tls/TlsProtocol.cs:
+
+ - Renamed to SecurityProtocolType.cs ( for match .NET 1.2 )
+
+ * Mono.Security.Cryptography/MD5SHA1CryptoServiceProvider.cs:
+
+ - Renamed to MD5SHA1.cs ( Thanks to Sebastién Pouliot. )
+
+ * Mono.Security.Cryptography/TlsCompressionMethod.cs:
+
+ - Renamed to SecurityCompressionType.
+
+ * Mono.Security.Protocol.Tls/CipherAlgorithmType.cs:
+ * Mono.Security.Protocol.Tls/HashAlgorithmType.cs:
+ * Mono.Security.Protocol.Tls/ExchangeAlgorithmType.cs:
+
+ - New enumerations that matches .NET 1.2 definitions with some minor differences.
+
+ * Mono.Security.Protocol.Tls/CipherSuite.cs:
+ * Mono.Security.Protocol.Tls/TlsCipherSuite.cs:
+ * Mono.Security.Protocol.Tls/TlsSslCipherSuite.cs:
+ * Mono.Security.Protocol.Tls/TlsSessionContext.cs:
+
+ - Added changes for make use of new enumerations.
+
+ * Mono.Security.Protocol.Tls/TlsClientStream.cs:
+
+ - Added new informative properties that matches .NET 1.2 SslClientStream
+ ( Not all the properties are implemented yet ).
+
+
+2003-11-10 Carlos Guzmán Álvarez <carlosga@telefonica.net>
+
+ * Mono.Security.Protocol.Tls.Alerts/TlsAlert.cs:
+
+ - Fixed invalid alert message.
+
+ * Mono.Security.Protocol.Tls/CipherSuite.cs:
+ * Mono.Security.Protocol.Tls/TlsSslCipherSuite.cs:
+ * Mono.Security.Cryptography/HMAC.cs:
+ * Mono.Security.Cryptography/MD5SHA1CryptoServiceProvider.cs:
+ * Mono.Security.Protocol.Tls.Handshake.Client/TlsClientCertificateVerify.cs:
+
+ - Changed ( Thanks to Sebastién Pouliot for his feedback )
+
+ SHA1CryptoServiceProvider sha = new SHA1CryptoServiceProvider();
+ MD5CryptoServiceProvider sha = new MD5CryptoServiceProvider();
+
+ to
+
+ HashAlgorithm sha = SHA1.Create();
+ HashAlgorithm md5 = MD5.Create();
+
+
+2003-11-04 Carlos Guzmán Álvarez <carlosga@telefonica.net>
+
+ * Mono.Security.Protocol.Tls.Handshake.Client/TlsServerCertificate.cs:
+
+ - Commented server certificate signature verification.
+
+ * Mono.Security.Protocol.Tls/TlsServerSettings.cs:
+
+ - Renamed ServerCertificates property to Certificates.
+
+
2003-11-04 Carlos Guzmán Álvarez (carlosga@telefonica.net)
* Updated SSL/TLS implementation files with unix like line endings.
diff --git a/mcs/class/Mono.Security/Mono.Security.Cryptography/ChangeLog b/mcs/class/Mono.Security/Mono.Security.Cryptography/ChangeLog
index 2b0fe9cc72c..918d23fa7fb 100644
--- a/mcs/class/Mono.Security/Mono.Security.Cryptography/ChangeLog
+++ b/mcs/class/Mono.Security/Mono.Security.Cryptography/ChangeLog
@@ -1,3 +1,13 @@
+2003-11-27 Sebastien Pouliot <spouliot@videotron.ca>
+
+ * MD4.cs: New. Asbtract class for all MD4 implementations. WARNING:
+ The MD4 algorithm is BROKEN (collisions) and SHOULDN'T be used in
+ NEW designs. However some higher level algorithms (like NTLM) requires
+ MD4 (and may even be secure using it). YOU'RE WARNED!
+ * MD4Managed.cs: New. Managed implementation of MD4 (RFC1320).
+ * PKCS8.cs: New. Added Private-Key Information Syntax Standard as a
+ building block for PKCS12.
+
2003-10-30 Sebastien Pouliot <spouliot@videotron.ca>
* CryptoConvert.cs: Fixed strongname generation for small exponents
diff --git a/mcs/class/Mono.Security/Mono.Security.Cryptography/MD4.cs b/mcs/class/Mono.Security/Mono.Security.Cryptography/MD4.cs
new file mode 100755
index 00000000000..d665ee35573
--- /dev/null
+++ b/mcs/class/Mono.Security/Mono.Security.Cryptography/MD4.cs
@@ -0,0 +1,39 @@
+//
+// MD4.cs - Message Digest 4 Abstract class
+//
+// Author:
+// Sebastien Pouliot (spouliot@motus.com)
+//
+// (C) 2003 Motus Technologies Inc. (http://www.motus.com)
+//
+
+using System;
+using System.Security.Cryptography;
+
+namespace Mono.Security.Cryptography {
+
+ public abstract class MD4 : HashAlgorithm {
+
+ protected MD4 ()
+ {
+ // MD4 hash length are 128 bits long
+ HashSizeValue = 128;
+ }
+
+ public static new MD4 Create ()
+ {
+ // for this to work we must register ourself with CryptoConfig
+ return Create ("MD4");
+ }
+
+ public static new MD4 Create (string hashName)
+ {
+ object o = CryptoConfig.CreateFromName (hashName);
+ // in case machine.config isn't configured to use any MD4 implementation
+ if (o == null) {
+ o = new MD4Managed ();
+ }
+ return (MD4) o;
+ }
+ }
+}
diff --git a/mcs/class/Mono.Security/Mono.Security.Cryptography/MD4Managed.cs b/mcs/class/Mono.Security/Mono.Security.Cryptography/MD4Managed.cs
new file mode 100755
index 00000000000..26ba30d0ce6
--- /dev/null
+++ b/mcs/class/Mono.Security/Mono.Security.Cryptography/MD4Managed.cs
@@ -0,0 +1,264 @@
+//
+// MD4Managed.cs - Message Digest 4 Managed Implementation
+//
+// Author:
+// Sebastien Pouliot (spouliot@motus.com)
+//
+// (C) 2003 Motus Technologies Inc. (http://www.motus.com)
+//
+
+using System;
+using System.Security.Cryptography;
+
+namespace Mono.Security.Cryptography {
+
+ // References:
+ // a. RFC1320: The MD4 Message-Digest Algorithm
+ // http://www.ietf.org/rfc/rfc1320.txt
+
+ public class MD4Managed : MD4 {
+
+ private uint[] state;
+ private byte[] buffer;
+ private uint[] count;
+ private uint[] x;
+
+ private const int S11 = 3;
+ private const int S12 = 7;
+ private const int S13 = 11;
+ private const int S14 = 19;
+ private const int S21 = 3;
+ private const int S22 = 5;
+ private const int S23 = 9;
+ private const int S24 = 13;
+ private const int S31 = 3;
+ private const int S32 = 9;
+ private const int S33 = 11;
+ private const int S34 = 15;
+
+ private byte[] digest;
+
+ //--- constructor -----------------------------------------------------------
+
+ public MD4Managed () : base ()
+ {
+ // we allocate the context memory
+ state = new uint [4];
+ count = new uint [2];
+ buffer = new byte [64];
+ digest = new byte [16];
+ // the initialize our context
+ Initialize ();
+ }
+
+ public override void Initialize ()
+ {
+ count [0] = 0;
+ count [1] = 0;
+ state [0] = 0x67452301;
+ state [1] = 0xefcdab89;
+ state [2] = 0x98badcfe;
+ state [3] = 0x10325476;
+ // temporary buffer in MD4Transform that we don't want to keep allocate on each iteration
+ x = new uint [16];
+ Array.Clear (buffer, 0, 64);
+ }
+
+ protected override void HashCore (byte[] array, int ibStart, int cbSize)
+ {
+ /* Compute number of bytes mod 64 */
+ int index = (int) ((count [0] >> 3) & 0x3F);
+ /* Update number of bits */
+ count [0] += (uint) (cbSize << 3);
+ if (count [0] < (cbSize << 3))
+ count [1]++;
+ count [1] += (uint) (cbSize >> 29);
+
+ int partLen = 64 - index;
+ int i = 0;
+ /* Transform as many times as possible. */
+ if (cbSize >= partLen) {
+ //MD4_memcpy((POINTER)&context->buffer[index], (POINTER)input, partLen);
+ Buffer.BlockCopy (array, ibStart, buffer, index, partLen);
+ MD4Transform (state, buffer, 0);
+
+ for (i = partLen; i + 63 < cbSize; i += 64) {
+ // MD4Transform (context->state, &input[i]);
+ MD4Transform (state, array, i);
+ }
+
+ index = 0;
+ }
+
+ /* Buffer remaining input */
+ //MD4_memcpy ((POINTER)&context->buffer[index], (POINTER)&input[i], inputLen-i);
+ Buffer.BlockCopy (array, ibStart + i, buffer, index, (cbSize-i));
+ }
+
+ protected override byte[] HashFinal ()
+ {
+ /* Save number of bits */
+ byte[] bits = new byte [8];
+ Encode (bits, count);
+
+ /* Pad out to 56 mod 64. */
+ uint index = ((count [0] >> 3) & 0x3f);
+ int padLen = (int) ((index < 56) ? (56 - index) : (120 - index));
+ HashCore (Padding (padLen), 0, padLen);
+
+ /* Append length (before padding) */
+ HashCore (bits, 0, 8);
+
+ /* Store state in digest */
+ Encode (digest, state);
+
+ // Zeroize sensitive information.
+ Initialize ();
+
+ return digest;
+ }
+
+ //--- private methods ---------------------------------------------------
+
+ private byte[] Padding (int nLength)
+ {
+ if (nLength > 0) {
+ byte[] padding = new byte [nLength];
+ padding [0] = 0x80;
+ return padding;
+ }
+ return null;
+ }
+
+ /* F, G and H are basic MD4 functions. */
+ private uint F (uint x, uint y, uint z)
+ {
+ return (uint) (((x) & (y)) | ((~x) & (z)));
+ }
+
+ private uint G (uint x, uint y, uint z)
+ {
+ return (uint) (((x) & (y)) | ((x) & (z)) | ((y) & (z)));
+ }
+
+ private uint H (uint x, uint y, uint z)
+ {
+ return (uint) ((x) ^ (y) ^ (z));
+ }
+
+ /* ROTATE_LEFT rotates x left n bits. */
+ private uint ROL (uint x, byte n)
+ {
+ return (uint) (((x) << (n)) | ((x) >> (32-(n))));
+ }
+
+ /* FF, GG and HH are transformations for rounds 1, 2 and 3 */
+ /* Rotation is separate from addition to prevent recomputation */
+ private void FF (ref uint a, uint b, uint c, uint d, uint x, byte s)
+ {
+ a += F (b, c, d) + x;
+ a = ROL (a, s);
+ }
+
+ private void GG (ref uint a, uint b, uint c, uint d, uint x, byte s)
+ {
+ a += G (b, c, d) + x + 0x5a827999;
+ a = ROL (a, s);
+ }
+
+ private void HH (ref uint a, uint b, uint c, uint d, uint x, byte s)
+ {
+ a += H (b, c, d) + x + 0x6ed9eba1;
+ a = ROL (a, s);
+ }
+
+ private void Encode (byte[] output, uint[] input)
+ {
+ for (int i = 0, j = 0; j < output.Length; i++, j += 4) {
+ output [j] = (byte)(input [i] & 0xff);
+ output [j+1] = (byte)((input [i] >> 8) & 0xff);
+ output [j+2] = (byte)((input [i] >> 16) & 0xff);
+ output [j+3] = (byte)(input [i] >> 24);
+ }
+ }
+
+ private void Decode (uint[] output, byte[] input, int index)
+ {
+ for (int i = 0, j = index; i < output.Length; i++, j += 4) {
+ output [i] = (uint) ((input [j]) | (input [j+1] << 8) | (input [j+2] << 16) | (input [j+3] << 24));
+ }
+ }
+
+ private void MD4Transform (uint[] state, byte[] block, int index)
+ {
+ uint a = state [0];
+ uint b = state [1];
+ uint c = state [2];
+ uint d = state [3];
+ uint[] x = new uint [16];
+
+ Decode (x, block, index);
+
+ /* Round 1 */
+ FF (ref a, b, c, d, x[ 0], S11); /* 1 */
+ FF (ref d, a, b, c, x[ 1], S12); /* 2 */
+ FF (ref c, d, a, b, x[ 2], S13); /* 3 */
+ FF (ref b, c, d, a, x[ 3], S14); /* 4 */
+ FF (ref a, b, c, d, x[ 4], S11); /* 5 */
+ FF (ref d, a, b, c, x[ 5], S12); /* 6 */
+ FF (ref c, d, a, b, x[ 6], S13); /* 7 */
+ FF (ref b, c, d, a, x[ 7], S14); /* 8 */
+ FF (ref a, b, c, d, x[ 8], S11); /* 9 */
+ FF (ref d, a, b, c, x[ 9], S12); /* 10 */
+ FF (ref c, d, a, b, x[10], S13); /* 11 */
+ FF (ref b, c, d, a, x[11], S14); /* 12 */
+ FF (ref a, b, c, d, x[12], S11); /* 13 */
+ FF (ref d, a, b, c, x[13], S12); /* 14 */
+ FF (ref c, d, a, b, x[14], S13); /* 15 */
+ FF (ref b, c, d, a, x[15], S14); /* 16 */
+
+ /* Round 2 */
+ GG (ref a, b, c, d, x[ 0], S21); /* 17 */
+ GG (ref d, a, b, c, x[ 4], S22); /* 18 */
+ GG (ref c, d, a, b, x[ 8], S23); /* 19 */
+ GG (ref b, c, d, a, x[12], S24); /* 20 */
+ GG (ref a, b, c, d, x[ 1], S21); /* 21 */
+ GG (ref d, a, b, c, x[ 5], S22); /* 22 */
+ GG (ref c, d, a, b, x[ 9], S23); /* 23 */
+ GG (ref b, c, d, a, x[13], S24); /* 24 */
+ GG (ref a, b, c, d, x[ 2], S21); /* 25 */
+ GG (ref d, a, b, c, x[ 6], S22); /* 26 */
+ GG (ref c, d, a, b, x[10], S23); /* 27 */
+ GG (ref b, c, d, a, x[14], S24); /* 28 */
+ GG (ref a, b, c, d, x[ 3], S21); /* 29 */
+ GG (ref d, a, b, c, x[ 7], S22); /* 30 */
+ GG (ref c, d, a, b, x[11], S23); /* 31 */
+ GG (ref b, c, d, a, x[15], S24); /* 32 */
+
+ HH (ref a, b, c, d, x[ 0], S31); /* 33 */
+ HH (ref d, a, b, c, x[ 8], S32); /* 34 */
+ HH (ref c, d, a, b, x[ 4], S33); /* 35 */
+ HH (ref b, c, d, a, x[12], S34); /* 36 */
+ HH (ref a, b, c, d, x[ 2], S31); /* 37 */
+ HH (ref d, a, b, c, x[10], S32); /* 38 */
+ HH (ref c, d, a, b, x[ 6], S33); /* 39 */
+ HH (ref b, c, d, a, x[14], S34); /* 40 */
+ HH (ref a, b, c, d, x[ 1], S31); /* 41 */
+ HH (ref d, a, b, c, x[ 9], S32); /* 42 */
+ HH (ref c, d, a, b, x[ 5], S33); /* 43 */
+ HH (ref b, c, d, a, x[13], S34); /* 44 */
+ HH (ref a, b, c, d, x[ 3], S31); /* 45 */
+ HH (ref d, a, b, c, x[11], S32); /* 46 */
+ HH (ref c, d, a, b, x[ 7], S33); /* 47 */
+ HH (ref b, c, d, a, x[15], S34); /* 48 */
+
+ state [0] += a;
+ state [1] += b;
+ state [2] += c;
+ state [3] += d;
+
+ /* Zeroize sensitive information. */
+ Array.Clear (x, 0, 16);
+ }
+ }
+}
diff --git a/mcs/class/Mono.Security/Mono.Security.Cryptography/MD5SHA1.cs b/mcs/class/Mono.Security/Mono.Security.Cryptography/MD5SHA1.cs
new file mode 100644
index 00000000000..4e52f252ed1
--- /dev/null
+++ b/mcs/class/Mono.Security/Mono.Security.Cryptography/MD5SHA1.cs
@@ -0,0 +1,127 @@
+/* Transport Security Layer (TLS)
+ * Copyright (c) 2003 Carlos Guzmán Álvarez
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+using System;
+using System.Security.Cryptography;
+
+namespace Mono.Security.Cryptography
+{
+ internal class MD5SHA1 : HashAlgorithm
+ {
+ #region FIELDS
+
+ private HashAlgorithm md5;
+ private HashAlgorithm sha;
+ private bool hashing;
+
+ #endregion
+
+ #region CONSTRUCTORS
+
+ public MD5SHA1()
+ {
+ this.md5 = MD5.Create();
+ this.sha = SHA1.Create();
+
+ // Set HashSizeValue
+ this.HashSizeValue = this.md5.HashSize + this.sha.HashSize;
+ }
+
+ #endregion
+
+ #region METHODS
+
+ public override void Initialize()
+ {
+ this.md5.Initialize();
+ this.sha.Initialize();
+ this.hashing = false;
+ }
+
+ protected override byte[] HashFinal()
+ {
+ if (!hashing)
+ {
+ this.hashing = true;
+ }
+ // Finalize the original hash
+ this.md5.TransformFinalBlock(new byte[0], 0, 0);
+ this.sha.TransformFinalBlock(new byte[0], 0, 0);
+
+ byte[] hash = new byte[36];
+
+ System.Array.Copy(this.md5.Hash, 0, hash, 0, 16);
+ System.Array.Copy(this.sha.Hash, 0, hash, 16, 20);
+
+ return hash;
+ }
+
+ protected override void HashCore(
+ byte[] array,
+ int ibStart,
+ int cbSize)
+ {
+ if (!hashing)
+ {
+ hashing = true;
+ }
+ this.md5.TransformBlock(array, ibStart, cbSize, array, ibStart);
+ this.sha.TransformBlock(array, ibStart, cbSize, array, ibStart);
+ }
+
+ public byte[] CreateSignature(RSA rsa)
+ {
+ if (rsa == null)
+ {
+ throw new CryptographicUnexpectedOperationException ("missing key");
+ }
+
+ #warning "MD5SHA1 hash is not supported by .NET"
+ RSAPKCS1SignatureFormatter f = new RSAPKCS1SignatureFormatter(rsa);
+ f.SetHashAlgorithm("MD5SHA1");
+
+ return f.CreateSignature(this.Hash);
+ }
+
+ public bool VerifySignature(RSA rsa, byte[] rgbSignature)
+ {
+ if (rsa == null)
+ {
+ throw new CryptographicUnexpectedOperationException ("missing key");
+ }
+ if (rgbSignature == null)
+ {
+ throw new ArgumentNullException ("rgbSignature");
+ }
+
+ #warning "MD5SHA1 hash is not supported by .NET"
+ RSAPKCS1SignatureDeformatter d = new RSAPKCS1SignatureDeformatter(rsa);
+ d.SetHashAlgorithm("MD5SHA1");
+
+ return d.VerifySignature(this.Hash, rgbSignature);
+ }
+
+ #endregion
+ }
+}
diff --git a/mcs/class/Mono.Security/Mono.Security.Cryptography/PKCS8.cs b/mcs/class/Mono.Security/Mono.Security.Cryptography/PKCS8.cs
new file mode 100755
index 00000000000..2f918aa9ed6
--- /dev/null
+++ b/mcs/class/Mono.Security/Mono.Security.Cryptography/PKCS8.cs
@@ -0,0 +1,351 @@
+//
+// PKCS8.cs: PKCS #8 - Private-Key Information Syntax Standard
+// ftp://ftp.rsasecurity.com/pub/pkcs/doc/pkcs-8.doc
+//
+// Author:
+// Sebastien Pouliot (spouliot@motus.com)
+//
+// (C) 2003 Motus Technologies Inc. (http://www.motus.com)
+//
+
+using System;
+using System.Collections;
+using System.Security.Cryptography;
+using System.Text;
+
+using Mono.Security.Cryptography;
+using Mono.Security.X509;
+
+namespace Mono.Security.Cryptography {
+
+ public class PKCS8 {
+
+ public enum KeyInfo {
+ PrivateKey,
+ EncryptedPrivateKey,
+ Unknown
+ }
+
+ static public KeyInfo GetType (byte[] data)
+ {
+ if (data == null)
+ throw new ArgumentNullException ("data");
+
+ KeyInfo ki = KeyInfo.Unknown;
+ try {
+ ASN1 top = new ASN1 (data);
+ if ((top.Tag == 0x30) && (top.Count > 0)) {
+ ASN1 firstLevel = top [0];
+ switch (firstLevel.Tag) {
+ case 0x02:
+ ki = KeyInfo.PrivateKey;
+ break;
+ case 0x30:
+ ki = KeyInfo.EncryptedPrivateKey;
+ break;
+ }
+ }
+ }
+ catch {
+ throw new CryptographicException ("invalid ASN.1 data");
+ }
+ return ki;
+ }
+
+ /*
+ * PrivateKeyInfo ::= SEQUENCE {
+ * version Version,
+ * privateKeyAlgorithm PrivateKeyAlgorithmIdentifier,
+ * privateKey PrivateKey,
+ * attributes [0] IMPLICIT Attributes OPTIONAL
+ * }
+ *
+ * Version ::= INTEGER
+ *
+ * PrivateKeyAlgorithmIdentifier ::= AlgorithmIdentifier
+ *
+ * PrivateKey ::= OCTET STRING
+ *
+ * Attributes ::= SET OF Attribute
+ */
+ public class PrivateKeyInfo {
+
+ private int _version;
+ private string _algorithm;
+ private byte[] _key;
+ private ArrayList _list;
+
+ public PrivateKeyInfo ()
+ {
+ _version = 0;
+ _list = new ArrayList ();
+ }
+
+ public PrivateKeyInfo (byte[] data) : this ()
+ {
+ Decode (data);
+ }
+
+ // properties
+
+ public string Algorithm {
+ get { return _algorithm; }
+ set { _algorithm = value; }
+ }
+
+ public ArrayList Attributes {
+ get { return _list; }
+ }
+
+ public byte[] PrivateKey {
+ get { return _key; }
+ set { _key = value; }
+ }
+
+ public int Version {
+ get { return _version; }
+ set {
+ if (_version < 0)
+ throw new ArgumentOutOfRangeException ("negative version");
+ _version = value;
+ }
+ }
+
+ // methods
+
+ private void Decode (byte[] data)
+ {
+ ASN1 privateKeyInfo = new ASN1 (data);
+ if (privateKeyInfo.Tag != 0x30)
+ throw new CryptographicException ("invalid PrivateKeyInfo");
+
+ ASN1 version = privateKeyInfo [0];
+ if (version.Tag != 0x02)
+ throw new CryptographicException ("invalid version");
+ _version = version.Value [0];
+
+ ASN1 privateKeyAlgorithm = privateKeyInfo [1];
+ if (privateKeyAlgorithm.Tag != 0x30)
+ throw new CryptographicException ("invalid algorithm");
+
+ ASN1 algorithm = privateKeyAlgorithm [0];
+ if (algorithm.Tag != 0x06)
+ throw new CryptographicException ("missing algorithm OID");
+ _algorithm = ASN1Convert.ToOID (algorithm);
+
+ ASN1 privateKey = privateKeyInfo [2];
+ _key = privateKey.Value;
+
+ // attributes [0] IMPLICIT Attributes OPTIONAL
+ if (privateKeyInfo.Count > 3) {
+ ASN1 attributes = privateKeyInfo [3];
+ for (int i=0; i < attributes.Count; i++) {
+ _list.Add (attributes [i]);
+ }
+ }
+ }
+
+ // TODO
+ public byte[] GetBytes ()
+ {
+ return null;
+ }
+
+ // static methods
+
+ static private byte[] RemoveLeadingZero (byte[] bigInt)
+ {
+ int start = 0;
+ int length = bigInt.Length;
+ if (bigInt [0] == 0x00) {
+ start = 1;
+ length--;
+ }
+ byte[] bi = new byte [length];
+ Buffer.BlockCopy (bigInt, start, bi, 0, length);
+ return bi;
+ }
+
+ static private byte[] Normalize (byte[] bigInt, int length)
+ {
+ if (bigInt.Length == length)
+ return bigInt;
+ else if (bigInt.Length > length)
+ return RemoveLeadingZero (bigInt);
+ else {
+ // pad with 0
+ byte[] bi = new byte [length];
+ Buffer.BlockCopy (bigInt, 0, bi, (length - bigInt.Length), bigInt.Length);
+ return bi;
+ }
+ }
+
+ /*
+ * RSAPrivateKey ::= SEQUENCE {
+ * version Version,
+ * modulus INTEGER, -- n
+ * publicExponent INTEGER, -- e
+ * privateExponent INTEGER, -- d
+ * prime1 INTEGER, -- p
+ * prime2 INTEGER, -- q
+ * exponent1 INTEGER, -- d mod (p-1)
+ * exponent2 INTEGER, -- d mod (q-1)
+ * coefficient INTEGER, -- (inverse of q) mod p
+ * otherPrimeInfos OtherPrimeInfos OPTIONAL
+ * }
+ */
+ static public RSA DecodeRSA (byte[] encryptedKeypair)
+ {
+ ASN1 privateKey = new ASN1 (encryptedKeypair);
+ if (privateKey.Tag != 0x30)
+ throw new CryptographicException ("invalid private key format");
+
+ ASN1 version = privateKey [0];
+ if (version.Tag != 0x02)
+ throw new CryptographicException ("missing version");
+
+ if (privateKey.Count < 9)
+ throw new CryptographicException ("not enough key parameters");
+
+ RSAParameters param = new RSAParameters ();
+ // note: MUST remove leading 0 - else MS wont import the key
+ param.Modulus = RemoveLeadingZero (privateKey [1].Value);
+ int keysize = param.Modulus.Length;
+ int keysize2 = (keysize >> 1); // half-size
+ // size must be normalized - else MS wont import the key
+ param.D = Normalize (privateKey [3].Value, keysize);
+ param.DP = Normalize (privateKey [6].Value, keysize2);
+ param.DQ = Normalize (privateKey [7].Value, keysize2);
+ param.Exponent = RemoveLeadingZero (privateKey [2].Value);
+ param.InverseQ = Normalize (privateKey [8].Value, keysize2);
+ param.P = Normalize (privateKey [4].Value, keysize2);
+ param.Q = Normalize (privateKey [5].Value, keysize2);
+
+ RSA rsa = RSA.Create ();
+ rsa.ImportParameters (param);
+ return rsa;
+ }
+
+ // DSA only encode it's X private key inside an ASN.1 INTEGER (Hint: Tag == 0x02)
+ // which isn't enough for rebuilding the keypair. The other parameters
+ // can be found (98% of the time) in the X.509 certificate associated
+ // with the private key or (2% of the time) the parameters are in it's
+ // issuer X.509 certificate (not supported in the .NET framework).
+ static public DSA DecodeDSA (byte[] encryptedPrivateKey, DSAParameters dsaParameters)
+ {
+ ASN1 privateKey = new ASN1 (encryptedPrivateKey);
+ if (privateKey.Tag != 0x02)
+ throw new CryptographicException ("invalid private key format");
+
+ // X is ALWAYS 20 bytes (no matter if the key length is 512 or 1024 bits)
+ dsaParameters.X = Normalize (encryptedPrivateKey, 20);
+ DSA dsa = DSA.Create ();
+ dsa.ImportParameters (dsaParameters);
+ return dsa;
+ }
+ }
+
+ /*
+ * EncryptedPrivateKeyInfo ::= SEQUENCE {
+ * encryptionAlgorithm EncryptionAlgorithmIdentifier,
+ * encryptedData EncryptedData
+ * }
+ *
+ * EncryptionAlgorithmIdentifier ::= AlgorithmIdentifier
+ *
+ * EncryptedData ::= OCTET STRING
+ *
+ * --
+ * AlgorithmIdentifier ::= SEQUENCE {
+ * algorithm OBJECT IDENTIFIER,
+ * parameters ANY DEFINED BY algorithm OPTIONAL
+ * }
+ *
+ * -- from PKCS#5
+ * PBEParameter ::= SEQUENCE {
+ * salt OCTET STRING SIZE(8),
+ * iterationCount INTEGER
+ * }
+ */
+ public class EncryptedPrivateKeyInfo {
+
+ private string _algorithm;
+ private byte[] _salt;
+ private int _iterations;
+ private byte[] _data;
+
+ public EncryptedPrivateKeyInfo () {}
+
+ public EncryptedPrivateKeyInfo (byte[] data) : this ()
+ {
+ Decode (data);
+ }
+
+ // properties
+
+ public string Algorithm {
+ get { return _algorithm; }
+ }
+
+ public byte[] EncryptedData {
+ get { return (byte[]) _data.Clone (); }
+ }
+
+ public byte[] Salt {
+ get { return (byte[]) _salt.Clone (); }
+ }
+
+ public int IterationCount {
+ get { return _iterations; }
+ }
+
+ // methods
+
+ private void Decode (byte[] data)
+ {
+ ASN1 encryptedPrivateKeyInfo = new ASN1 (data);
+ if (encryptedPrivateKeyInfo.Tag != 0x30)
+ throw new CryptographicException ("invalid EncryptedPrivateKeyInfo");
+
+ ASN1 encryptionAlgorithm = encryptedPrivateKeyInfo [0];
+ if (encryptionAlgorithm.Tag != 0x30)
+ throw new CryptographicException ("invalid encryptionAlgorithm");
+ ASN1 algorithm = encryptionAlgorithm [0];
+ if (algorithm.Tag != 0x06)
+ throw new CryptographicException ("invalid algorithm");
+ _algorithm = ASN1Convert.ToOID (algorithm);
+ // parameters ANY DEFINED BY algorithm OPTIONAL
+ if (encryptionAlgorithm.Count > 1) {
+ ASN1 parameters = encryptionAlgorithm [1];
+ if (parameters.Tag != 0x30)
+ throw new CryptographicException ("invalid parameters");
+
+ ASN1 salt = parameters [0];
+ if (salt.Tag != 0x04)
+ throw new CryptographicException ("invalid salt");
+ _salt = salt.Value;
+
+ ASN1 iterationCount = parameters [1];
+ if (iterationCount.Tag != 0x02)
+ throw new CryptographicException ("invalid iterationCount");
+ _iterations = ASN1Convert.ToInt32 (iterationCount);
+ }
+
+ ASN1 encryptedData = encryptedPrivateKeyInfo [1];
+ if (encryptedData.Tag != 0x04)
+ throw new CryptographicException ("invalid EncryptedData");
+ _data = encryptedData.Value;
+ }
+
+ // Note: PKCS#8 doesn't define how to generate the key required for encryption
+ // so you're on your own. Just don't try to copy the big guys too much ;)
+ // Netscape: http://www.cs.auckland.ac.nz/~pgut001/pubs/netscape.txt
+ // Microsoft: http://www.cs.auckland.ac.nz/~pgut001/pubs/breakms.txt
+ public byte[] GetBytes (byte[] encryptedPrivateKey)
+ {
+ // TODO
+ return null;
+ }
+ }
+ }
+}
diff --git a/mcs/class/Mono.Security/Mono.Security.Protocol.Tls.Alerts/TlsAlert.cs b/mcs/class/Mono.Security/Mono.Security.Protocol.Tls.Alerts/TlsAlert.cs
index 9a96aca52e7..fc6a2bd69d6 100644
--- a/mcs/class/Mono.Security/Mono.Security.Protocol.Tls.Alerts/TlsAlert.cs
+++ b/mcs/class/Mono.Security/Mono.Security.Protocol.Tls.Alerts/TlsAlert.cs
@@ -68,7 +68,7 @@ namespace Mono.Security.Protocol.Tls.Alerts
{
#region FIELDS
- private TlsSession session;
+ private TlsContext context;
private TlsAlertLevel level;
private TlsAlertDescription description;
@@ -76,20 +76,20 @@ namespace Mono.Security.Protocol.Tls.Alerts
#region PROPERTIES
- public TlsSession Session
+ public TlsContext Context
{
- get { return session; }
+ get { return this.context; }
}
#endregion
#region CONSTRUCTORS
- public TlsAlert(TlsSession session,
+ public TlsAlert(TlsContext context,
TlsAlertLevel level,
TlsAlertDescription description) : base()
{
- this.session = session;
+ this.context = context;
this.level = level;
this.description = description;
@@ -118,6 +118,7 @@ namespace Mono.Security.Protocol.Tls.Alerts
internal static string GetAlertMessage(TlsAlertDescription description)
{
+ #if (DEBUG)
switch (description)
{
case TlsAlertDescription.AccessDenied:
@@ -178,7 +179,7 @@ namespace Mono.Security.Protocol.Tls.Alerts
return "Invalid length on TLSCiphertext record or TLSCompressed record.";
case TlsAlertDescription.UnexpectedMessage:
- return "Invalid message receive.";
+ return "Invalid message received.";
case TlsAlertDescription.UnknownCA:
return "CA can't be identified as a trusted CA.";
@@ -192,6 +193,82 @@ namespace Mono.Security.Protocol.Tls.Alerts
default:
return "";
}
+ #else
+ switch (description)
+ {
+ case TlsAlertDescription.AccessDenied:
+ return "Invalid message.";
+
+ case TlsAlertDescription.BadCertificate:
+ return "Handshake failiure.";
+
+ case TlsAlertDescription.BadRecordMAC:
+ return "Cryptographic failiure.";
+
+ case TlsAlertDescription.CertificateExpired:
+ return "Handshake failiure.";
+
+ case TlsAlertDescription.CertificateRevoked:
+ return "Handshake failiure.";
+
+ case TlsAlertDescription.CertificateUnknown:
+ return "Handshake failiure.";
+
+ case TlsAlertDescription.CloseNotify:
+ return "Connection closed.";
+
+ case TlsAlertDescription.DecodeError:
+ return "Invalid message.";
+
+ case TlsAlertDescription.DecompressionFailiure:
+ return "Compression error.";
+
+ case TlsAlertDescription.DecryptError:
+ return "Cryptographic failiure.";
+
+ case TlsAlertDescription.DecryptionFailed:
+ return "Cryptographic failiure.";
+
+ case TlsAlertDescription.ExportRestriction:
+ return "Handshake failiure.";
+
+ case TlsAlertDescription.HandshakeFailiure:
+ return "Handshake failiure.";
+
+ case TlsAlertDescription.IlegalParameter:
+ return "Handshake failiure.";
+
+ case TlsAlertDescription.InsuficientSecurity:
+ return "Handshake failiure.";
+
+ case TlsAlertDescription.InternalError:
+ return "Fatal failiure.";
+
+ case TlsAlertDescription.NoRenegotiation:
+ return "Handshake failiure.";
+
+ case TlsAlertDescription.ProtocolVersion:
+ return "Handshake failiure.";
+
+ case TlsAlertDescription.RecordOverflow:
+ return "Incorrect message.";
+
+ case TlsAlertDescription.UnexpectedMessage:
+ return "Incorrect message.";
+
+ case TlsAlertDescription.UnknownCA:
+ return "Handshake failiure.";
+
+ case TlsAlertDescription.UnsupportedCertificate:
+ return "Handshake failiure.";
+
+ case TlsAlertDescription.UserCancelled:
+ return "Handshake cancelled by user.";
+
+ default:
+ return "";
+ }
+ #endif
}
#endregion
diff --git a/mcs/class/Mono.Security/Mono.Security.Protocol.Tls.Alerts/TlsCloseNotifyAlert.cs b/mcs/class/Mono.Security/Mono.Security.Protocol.Tls.Alerts/TlsCloseNotifyAlert.cs
index 2e573a2924a..fcf97515e74 100644
--- a/mcs/class/Mono.Security/Mono.Security.Protocol.Tls.Alerts/TlsCloseNotifyAlert.cs
+++ b/mcs/class/Mono.Security/Mono.Security.Protocol.Tls.Alerts/TlsCloseNotifyAlert.cs
@@ -29,8 +29,8 @@ namespace Mono.Security.Protocol.Tls.Alerts
{
internal class TlsCloseNotifyAlert : TlsAlert
{
- public TlsCloseNotifyAlert(TlsSession session)
- : base(session,
+ public TlsCloseNotifyAlert(TlsContext context)
+ : base(context,
TlsAlertLevel.Warning,
TlsAlertDescription.CloseNotify)
{
@@ -38,7 +38,7 @@ namespace Mono.Security.Protocol.Tls.Alerts
public override void UpdateSession()
{
- this.Session.Context.ConnectionEnd = true;
+ this.Context.ConnectionEnd = true;
}
}
}
diff --git a/mcs/class/Mono.Security/Mono.Security.Protocol.Tls.Handshake.Client/ChangeLog b/mcs/class/Mono.Security/Mono.Security.Protocol.Tls.Handshake.Client/ChangeLog
index 189c9c2dfae..1a83f868c15 100755
--- a/mcs/class/Mono.Security/Mono.Security.Protocol.Tls.Handshake.Client/ChangeLog
+++ b/mcs/class/Mono.Security/Mono.Security.Protocol.Tls.Handshake.Client/ChangeLog
@@ -1,3 +1,123 @@
+2003-11-17 Carlos Guzmán Álvarez <carlosga@telefonica.net>
+
+ * Mono.Security.Protocol.Tls/SslClientStream.cs:
+
+ Removed ReadByte method, use innerStream.ReadByte() method instead.
+
+2003-11-13 Carlos Guzmán Álvarez <carlosga@telefonica.net>
+
+ * Added implementation of an SslClientStream class similar to the MS .NET Framework 1.2 documentation.
+
+ The next files are no more needed:
+
+ - TlsSession.cs
+
+ - TlsNetworkStream.cs
+
+ - TlsSocket.cs
+
+ - TlsSessionState.cs
+
+ The next files are renamed:
+
+ - TlsSessionSettings.cs -> TlsClientSettings.cs
+
+ - TlsSessionContext.cs -> TlsContext.cs
+
+ The next files are new:
+
+ - SslClientStream.cs ( the name is non definitive yet )
+
+ The next files where changed to reflect the new canges:
+
+ - TlsHandshakeMessage.cs
+
+ - TlsClientCertificate.cs
+
+ - TlsClientCertificateVerify.cs
+
+ - TlsClientFinished.cs
+
+ - TlsClientHello.cs
+
+ - TlsClientKeyExchange.cs
+
+ - TlsServerCertificate.cs
+
+ - TlsServerCertificateRequest.cs
+
+ - TlsServerFinished.cs
+
+ - TlsServerHello.cs
+
+ - TlsServerHelloDone.cs
+
+ - TlsServerKeyExchange.cs
+
+ - TlsAlert.cs
+
+ - TlsCloseNotifyAlert.cs
+
+
+2003-11-12 Carlos Guzmán Álvarez <carlosga@telefonica.net>
+
+ * Mono.Security.Protocol.Tls.Alerts/TlsAlert.cs:
+
+ - Changes for give full error message only in debug mode ( Thanks to Sebastién Pouliot. )
+
+ * Mono.Security.Protocol.Tls/TlsProtocol.cs:
+
+ - Renamed to SecurityProtocolType.cs ( for match .NET 1.2 )
+
+ * Mono.Security.Cryptography/MD5SHA1CryptoServiceProvider.cs:
+
+ - Renamed to MD5SHA1.cs ( Thanks to Sebastién Pouliot. )
+
+ * Mono.Security.Cryptography/TlsCompressionMethod.cs:
+
+ - Renamed to SecurityCompressionType.
+
+ * Mono.Security.Protocol.Tls/CipherAlgorithmType.cs:
+ * Mono.Security.Protocol.Tls/HashAlgorithmType.cs:
+ * Mono.Security.Protocol.Tls/ExchangeAlgorithmType.cs:
+
+ - New enumerations that matches .NET 1.2 definitions with some minor differences.
+
+ * Mono.Security.Protocol.Tls/CipherSuite.cs:
+ * Mono.Security.Protocol.Tls/TlsCipherSuite.cs:
+ * Mono.Security.Protocol.Tls/TlsSslCipherSuite.cs:
+ * Mono.Security.Protocol.Tls/TlsSessionContext.cs:
+
+ - Added changes for make use of new enumerations.
+
+ * Mono.Security.Protocol.Tls/TlsClientStream.cs:
+
+ - Added new informative properties that matches .NET 1.2 SslClientStream
+ ( Not all the properties are implemented yet ).
+
+
+2003-11-10 Carlos Guzmán Álvarez <carlosga@telefonica.net>
+
+ * Mono.Security.Protocol.Tls.Alerts/TlsAlert.cs:
+
+ - Fixed invalid alert message.
+
+ * Mono.Security.Protocol.Tls/CipherSuite.cs:
+ * Mono.Security.Protocol.Tls/TlsSslCipherSuite.cs:
+ * Mono.Security.Cryptography/HMAC.cs:
+ * Mono.Security.Cryptography/MD5SHA1CryptoServiceProvider.cs:
+ * Mono.Security.Protocol.Tls.Handshake.Client/TlsClientCertificateVerify.cs:
+
+ - Changed ( Thanks to Sebastién Pouliot for his feedback )
+
+ SHA1CryptoServiceProvider sha = new SHA1CryptoServiceProvider();
+ MD5CryptoServiceProvider sha = new MD5CryptoServiceProvider();
+
+ to
+
+ HashAlgorithm sha = SHA1.Create();
+ HashAlgorithm md5 = MD5.Create();
+
2003-11-04 Carlos Guzmán Álvarez <carlosga@telefonica.net>
* Mono.Security.Protocol.Tls/CipherSuite.cs:
@@ -67,4 +187,4 @@
2003-10-23 Carlos Guzmán Álvarez <carlosga@telefonica.net>
- * Added partial implementation of SSL3 protocol ( not finished yet ). \ No newline at end of file
+ * Added partial implementation of SSL3 protocol ( not finished yet ).
diff --git a/mcs/class/Mono.Security/Mono.Security.Protocol.Tls.Handshake.Client/TlsClientCertificate.cs b/mcs/class/Mono.Security/Mono.Security.Protocol.Tls.Handshake.Client/TlsClientCertificate.cs
index 3ba44de72ff..0be0dd72040 100644
--- a/mcs/class/Mono.Security/Mono.Security.Protocol.Tls.Handshake.Client/TlsClientCertificate.cs
+++ b/mcs/class/Mono.Security/Mono.Security.Protocol.Tls.Handshake.Client/TlsClientCertificate.cs
@@ -32,8 +32,8 @@ namespace Mono.Security.Protocol.Tls.Handshake.Client
{
#region CONSTRUCTORS
- public TlsClientCertificate(TlsSession session)
- : base(session, TlsHandshakeType.Certificate, TlsContentType.Handshake)
+ public TlsClientCertificate(TlsContext context)
+ : base(context, TlsHandshakeType.Certificate, TlsContentType.Handshake)
{
}
@@ -58,15 +58,15 @@ namespace Mono.Security.Protocol.Tls.Handshake.Client
protected override void ProcessAsTls1()
{
- if (Session.Settings.Certificates == null ||
- Session.Settings.Certificates.Count == 0)
+ if (this.Context.ClientSettings.Certificates == null ||
+ this.Context.ClientSettings.Certificates.Count == 0)
{
- throw this.Session.CreateException("Client certificate requested by the server and no client certificate specified.");
+ throw this.Context.CreateException("Client certificate requested by the server and no client certificate specified.");
}
// Write client certificates information to a stream
TlsStream stream = new TlsStream();
- foreach (X509Certificate cert in Session.Settings.Certificates)
+ foreach (X509Certificate cert in this.Context.ClientSettings.Certificates)
{
stream.WriteInt24(cert.GetRawCertData().Length);
stream.Write(cert.GetRawCertData());
diff --git a/mcs/class/Mono.Security/Mono.Security.Protocol.Tls.Handshake.Client/TlsClientCertificateVerify.cs b/mcs/class/Mono.Security/Mono.Security.Protocol.Tls.Handshake.Client/TlsClientCertificateVerify.cs
index 4d986ffdbe4..9933bf070a4 100644
--- a/mcs/class/Mono.Security/Mono.Security.Protocol.Tls.Handshake.Client/TlsClientCertificateVerify.cs
+++ b/mcs/class/Mono.Security/Mono.Security.Protocol.Tls.Handshake.Client/TlsClientCertificateVerify.cs
@@ -34,8 +34,8 @@ namespace Mono.Security.Protocol.Tls.Handshake.Client
{
#region CONSTRUCTORS
- public TlsClientCertificateVerify(TlsSession session)
- : base(session, TlsHandshakeType.Finished, TlsContentType.Handshake)
+ public TlsClientCertificateVerify(TlsContext context)
+ : base(context, TlsHandshakeType.Finished, TlsContentType.Handshake)
{
}
@@ -60,15 +60,15 @@ namespace Mono.Security.Protocol.Tls.Handshake.Client
protected override void ProcessAsTls1()
{
- foreach (X509Certificate cert in Session.Settings.Certificates)
+ foreach (X509Certificate cert in this.Context.ClientSettings.Certificates)
{
- MD5SHA1CryptoServiceProvider hash = new MD5SHA1CryptoServiceProvider();
+ MD5SHA1 hash = new MD5SHA1();
X509.X509Certificate c = new X509.X509Certificate(cert.GetRawCertData());
RSA rsa = c.RSA;
RSAParameters p = rsa.ExportParameters(false);
TlsStream data = new TlsStream();
- data.Write(this.Session.Context.RandomCS);
+ data.Write(this.Context.RandomCS);
data.Write((short)p.Modulus.Length);
data.Write(p.Modulus);
data.Write((short)p.Exponent.Length);
diff --git a/mcs/class/Mono.Security/Mono.Security.Protocol.Tls.Handshake.Client/TlsClientFinished.cs b/mcs/class/Mono.Security/Mono.Security.Protocol.Tls.Handshake.Client/TlsClientFinished.cs
index 6e65064b739..8c69f75be57 100644
--- a/mcs/class/Mono.Security/Mono.Security.Protocol.Tls.Handshake.Client/TlsClientFinished.cs
+++ b/mcs/class/Mono.Security/Mono.Security.Protocol.Tls.Handshake.Client/TlsClientFinished.cs
@@ -33,8 +33,8 @@ namespace Mono.Security.Protocol.Tls.Handshake.Client
{
#region CONSTRUCTORS
- public TlsClientFinished(TlsSession session)
- : base(session, TlsHandshakeType.Finished, TlsContentType.Handshake)
+ public TlsClientFinished(TlsContext context)
+ : base(context, TlsHandshakeType.Finished, TlsContentType.Handshake)
{
}
@@ -55,10 +55,10 @@ namespace Mono.Security.Protocol.Tls.Handshake.Client
protected override void ProcessAsSsl3()
{
// Compute handshake messages hashes
- HashAlgorithm hash = new TlsSslHandshakeHash(this.Session.Context.MasterSecret);
+ HashAlgorithm hash = new TlsSslHandshakeHash(this.Context.MasterSecret);
TlsStream data = new TlsStream();
- data.Write(this.Session.Context.HandshakeMessages.ToArray());
+ data.Write(this.Context.HandshakeMessages.ToArray());
data.Write((int)0x434C4E54);
hash.TransformFinalBlock(data.ToArray(), 0, (int)data.Length);
@@ -71,14 +71,14 @@ namespace Mono.Security.Protocol.Tls.Handshake.Client
protected override void ProcessAsTls1()
{
// Compute handshake messages hash
- HashAlgorithm hash = new MD5SHA1CryptoServiceProvider();
+ HashAlgorithm hash = new MD5SHA1();
hash.ComputeHash(
- Session.Context.HandshakeMessages.ToArray(),
+ this.Context.HandshakeMessages.ToArray(),
0,
- (int)Session.Context.HandshakeMessages.Length);
+ (int)this.Context.HandshakeMessages.Length);
// Write message
- Write(Session.Context.Cipher.PRF(Session.Context.MasterSecret, "client finished", hash.Hash, 12));
+ Write(this.Context.Cipher.PRF(this.Context.MasterSecret, "client finished", hash.Hash, 12));
}
#endregion
diff --git a/mcs/class/Mono.Security/Mono.Security.Protocol.Tls.Handshake.Client/TlsClientHello.cs b/mcs/class/Mono.Security/Mono.Security.Protocol.Tls.Handshake.Client/TlsClientHello.cs
index 3148d9cfd2a..43bb2bb03f7 100644
--- a/mcs/class/Mono.Security/Mono.Security.Protocol.Tls.Handshake.Client/TlsClientHello.cs
+++ b/mcs/class/Mono.Security/Mono.Security.Protocol.Tls.Handshake.Client/TlsClientHello.cs
@@ -37,8 +37,8 @@ namespace Mono.Security.Protocol.Tls.Handshake.Client
#region CONSTRUCTORS
- public TlsClientHello(TlsSession session)
- : base(session, TlsHandshakeType.ClientHello, TlsContentType.Handshake)
+ public TlsClientHello(TlsContext context)
+ : base(context, TlsHandshakeType.ClientHello, TlsContentType.Handshake)
{
}
@@ -50,7 +50,7 @@ namespace Mono.Security.Protocol.Tls.Handshake.Client
{
base.UpdateSession();
- Session.Context.ClientRandom = random;
+ this.Context.ClientRandom = random;
random = null;
}
@@ -67,12 +67,12 @@ namespace Mono.Security.Protocol.Tls.Handshake.Client
protected override void ProcessAsTls1()
{
// Client Version
- this.Write((short)this.Session.Context.Protocol);
+ this.Write((short)this.Context.Protocol);
// Random bytes - Unix time + Radom bytes [28]
TlsStream clientRandom = new TlsStream();
- clientRandom.Write(this.Session.Context.GetUnixTime());
- clientRandom.Write(this.Session.Context.GetSecureRandomBytes(28));
+ clientRandom.Write(this.Context.GetUnixTime());
+ clientRandom.Write(this.Context.GetSecureRandomBytes(28));
this.random = clientRandom.ToArray();
clientRandom.Reset();
@@ -80,12 +80,12 @@ namespace Mono.Security.Protocol.Tls.Handshake.Client
// Session id
// Send the session ID empty
- if (this.Session.SessionId != null)
+ if (this.Context.SessionId != null)
{
- this.Write((byte)this.Session.SessionId.Length);
- if (this.Session.SessionId.Length > 0)
+ this.Write((byte)this.Context.SessionId.Length);
+ if (this.Context.SessionId.Length > 0)
{
- this.Write(this.Session.SessionId);
+ this.Write(this.Context.SessionId);
}
}
else
@@ -94,19 +94,19 @@ namespace Mono.Security.Protocol.Tls.Handshake.Client
}
// Write length of Cipher suites
- this.Write((short)(this.Session.Context.SupportedCiphers.Count*2));
+ this.Write((short)(this.Context.SupportedCiphers.Count*2));
// Write Supported Cipher suites
- for (int i = 0; i < this.Session.Context.SupportedCiphers.Count; i++)
+ for (int i = 0; i < this.Context.SupportedCiphers.Count; i++)
{
- this.Write((short)this.Session.Context.SupportedCiphers[i].Code);
+ this.Write((short)this.Context.SupportedCiphers[i].Code);
}
// Compression methods length
this.Write((byte)1);
// Compression methods ( 0 = none )
- this.Write((byte)this.Session.Context.CompressionMethod);
+ this.Write((byte)this.Context.CompressionMethod);
}
#endregion
diff --git a/mcs/class/Mono.Security/Mono.Security.Protocol.Tls.Handshake.Client/TlsClientKeyExchange.cs b/mcs/class/Mono.Security/Mono.Security.Protocol.Tls.Handshake.Client/TlsClientKeyExchange.cs
index 1357e733d9d..57e0479bdee 100644
--- a/mcs/class/Mono.Security/Mono.Security.Protocol.Tls.Handshake.Client/TlsClientKeyExchange.cs
+++ b/mcs/class/Mono.Security/Mono.Security.Protocol.Tls.Handshake.Client/TlsClientKeyExchange.cs
@@ -32,8 +32,8 @@ namespace Mono.Security.Protocol.Tls.Handshake.Client
{
#region CONSTRUCTORS
- public TlsClientKeyExchange (TlsSession session) :
- base(session,
+ public TlsClientKeyExchange (TlsContext context) :
+ base(context,
TlsHandshakeType.ClientKeyExchange,
TlsContentType.Handshake)
{
@@ -46,10 +46,10 @@ namespace Mono.Security.Protocol.Tls.Handshake.Client
protected override void ProcessAsSsl3()
{
// Compute pre master secret
- byte[] preMasterSecret = this.Session.Context.Cipher.CreatePremasterSecret();
+ byte[] preMasterSecret = this.Context.Cipher.CreatePremasterSecret();
// Create a new RSA key
- RSA rsa = this.Session.Context.Cipher.CreateRSA();
+ RSA rsa = this.Context.Cipher.CreateRSA();
// Encrypt premaster_sercret
RSAPKCS1KeyExchangeFormatter formatter = new RSAPKCS1KeyExchangeFormatter(rsa);
@@ -59,10 +59,10 @@ namespace Mono.Security.Protocol.Tls.Handshake.Client
this.Write(buffer);
// Create master secret
- this.Session.Context.Cipher.ComputeMasterSecret(preMasterSecret);
+ this.Context.Cipher.ComputeMasterSecret(preMasterSecret);
// Create keys
- this.Session.Context.Cipher.ComputeKeys();
+ this.Context.Cipher.ComputeKeys();
// Clear resources
rsa.Clear();
@@ -71,10 +71,10 @@ namespace Mono.Security.Protocol.Tls.Handshake.Client
protected override void ProcessAsTls1()
{
// Compute pre master secret
- byte[] preMasterSecret = this.Session.Context.Cipher.CreatePremasterSecret();
+ byte[] preMasterSecret = this.Context.Cipher.CreatePremasterSecret();
// Create a new RSA key
- RSA rsa = this.Session.Context.Cipher.CreateRSA();
+ RSA rsa = this.Context.Cipher.CreateRSA();
// Encrypt premaster_sercret
RSAPKCS1KeyExchangeFormatter formatter = new RSAPKCS1KeyExchangeFormatter(rsa);
@@ -85,10 +85,10 @@ namespace Mono.Security.Protocol.Tls.Handshake.Client
this.Write(buffer);
// Create master secret
- this.Session.Context.Cipher.ComputeMasterSecret(preMasterSecret);
+ this.Context.Cipher.ComputeMasterSecret(preMasterSecret);
// Create keys
- this.Session.Context.Cipher.ComputeKeys();
+ this.Context.Cipher.ComputeKeys();
// Clear resources
rsa.Clear();
diff --git a/mcs/class/Mono.Security/Mono.Security.Protocol.Tls.Handshake.Client/TlsServerCertificate.cs b/mcs/class/Mono.Security/Mono.Security.Protocol.Tls.Handshake.Client/TlsServerCertificate.cs
index 15618102c4f..a42b166a7b5 100644
--- a/mcs/class/Mono.Security/Mono.Security.Protocol.Tls.Handshake.Client/TlsServerCertificate.cs
+++ b/mcs/class/Mono.Security/Mono.Security.Protocol.Tls.Handshake.Client/TlsServerCertificate.cs
@@ -23,7 +23,10 @@
*/
using System;
+using System.Collections;
+using System.Text.RegularExpressions;
using System.Security.Cryptography;
+using X509Cert = System.Security.Cryptography.X509Certificates;
using Mono.Security.Protocol.Tls.Alerts;
using Mono.Security.X509;
@@ -34,23 +37,14 @@ namespace Mono.Security.Protocol.Tls.Handshake.Client
{
#region FIELDS
- private X509CertificateCollection certificates;
+ private X509CertificateCollection certificates;
#endregion
- #region PROPERTIES
-
- public X509CertificateCollection Certificates
- {
- get { return certificates; }
- }
-
- #endregion
-
#region CONSTRUCTORS
- public TlsServerCertificate(TlsSession session, byte[] buffer)
- : base(session, TlsHandshakeType.Certificate, buffer)
+ public TlsServerCertificate(TlsContext context, byte[] buffer)
+ : base(context, TlsHandshakeType.Certificate, buffer)
{
}
@@ -61,7 +55,7 @@ namespace Mono.Security.Protocol.Tls.Handshake.Client
public override void UpdateSession()
{
base.UpdateSession();
- this.Session.Context.ServerSettings.ServerCertificates = certificates;
+ this.Context.ServerSettings.Certificates = certificates;
}
#endregion
@@ -107,24 +101,60 @@ namespace Mono.Security.Protocol.Tls.Handshake.Client
private void validateCertificate(X509Certificate certificate)
{
- #warning "Check validity of certificates"
+ int[] certificateErrors = new int[0];
// 1 step : Validate dates
if (!certificate.IsCurrent)
{
- throw Session.CreateException("Certificate received from the server expired.");
+ #warning "Add error to the list"
}
// 2 step: Validate CA
// 3 step: Validate digital sign
+ /*
if (!certificate.VerifySignature(certificate.RSA))
{
- throw Session.CreateException("Certificate received from the server has invalid signature.");
+ throw this.Context.CreateException("Certificate received from the server has invalid signature.");
}
+ */
// 4 step: Validate domain name
+ if (!this.checkDomainName(certificate.SubjectName))
+ {
+ #warning "Add error to the list"
+ }
+
+ if (certificateErrors.Length > 0)
+ {
+ if (!this.Context.SslStream.RaiseServerCertificateValidation(
+ new X509Cert.X509Certificate(certificate.RawData),
+ new int[]{}))
+ {
+ throw this.Context.CreateException("Invalid certificate received form server.");
+ }
+ }
+ }
+
+ private bool checkDomainName(string subjectName)
+ {
+ string domainName = String.Empty;
+ Regex search = new Regex(@"([\w\s\d]*)\s*=\s*([^,]*)");
+
+ MatchCollection elements = search.Matches(subjectName);
+
+ foreach (Match element in elements)
+ {
+ switch (element.Groups[1].Value.Trim().ToUpper())
+ {
+ case "CN":
+ domainName = element.Groups[2].Value;
+ break;
+ }
+ }
+
+ return (this.Context.ClientSettings.TargetHost == domainName);
}
#endregion
diff --git a/mcs/class/Mono.Security/Mono.Security.Protocol.Tls.Handshake.Client/TlsServerCertificateRequest.cs b/mcs/class/Mono.Security/Mono.Security.Protocol.Tls.Handshake.Client/TlsServerCertificateRequest.cs
index 7250f0a86c4..e0a9150b0f9 100644
--- a/mcs/class/Mono.Security/Mono.Security.Protocol.Tls.Handshake.Client/TlsServerCertificateRequest.cs
+++ b/mcs/class/Mono.Security/Mono.Security.Protocol.Tls.Handshake.Client/TlsServerCertificateRequest.cs
@@ -39,8 +39,8 @@ namespace Mono.Security.Protocol.Tls.Handshake.Client
#region CONSTRUCTORS
- public TlsServerCertificateRequest(TlsSession session, byte[] buffer)
- : base(session, TlsHandshakeType.ServerHello, buffer)
+ public TlsServerCertificateRequest(TlsContext context, byte[] buffer)
+ : base(context, TlsHandshakeType.ServerHello, buffer)
{
}
@@ -52,9 +52,9 @@ namespace Mono.Security.Protocol.Tls.Handshake.Client
{
base.UpdateSession();
- this.Session.Context.ServerSettings.CertificateTypes = this.certificateTypes;
- this.Session.Context.ServerSettings.DistinguisedNames = this.distinguisedNames;
- this.Session.Context.ServerSettings.CertificateRequest = true;
+ this.Context.ServerSettings.CertificateTypes = this.certificateTypes;
+ this.Context.ServerSettings.DistinguisedNames = this.distinguisedNames;
+ this.Context.ServerSettings.CertificateRequest = true;
}
#endregion
diff --git a/mcs/class/Mono.Security/Mono.Security.Protocol.Tls.Handshake.Client/TlsServerFinished.cs b/mcs/class/Mono.Security/Mono.Security.Protocol.Tls.Handshake.Client/TlsServerFinished.cs
index 937d4df0661..f45a487d790 100644
--- a/mcs/class/Mono.Security/Mono.Security.Protocol.Tls.Handshake.Client/TlsServerFinished.cs
+++ b/mcs/class/Mono.Security/Mono.Security.Protocol.Tls.Handshake.Client/TlsServerFinished.cs
@@ -33,8 +33,8 @@ namespace Mono.Security.Protocol.Tls.Handshake.Client
{
#region CONSTRUCTORS
- public TlsServerFinished(TlsSession session, byte[] buffer)
- : base(session, TlsHandshakeType.ServerHello, buffer)
+ public TlsServerFinished(TlsContext context, byte[] buffer)
+ : base(context, TlsHandshakeType.ServerHello, buffer)
{
}
@@ -47,10 +47,10 @@ namespace Mono.Security.Protocol.Tls.Handshake.Client
base.UpdateSession();
// Reset Hahdshake messages information
- this.Session.Context.HandshakeMessages.Reset();
+ this.Context.HandshakeMessages.Reset();
// Hahdshake is finished
- this.Session.Context.HandshakeFinished = true;
+ this.Context.HandshakeFinished = true;
}
#endregion
@@ -60,10 +60,10 @@ namespace Mono.Security.Protocol.Tls.Handshake.Client
protected override void ProcessAsSsl3()
{
// Compute handshake messages hashes
- HashAlgorithm hash = new TlsSslHandshakeHash(this.Session.Context.MasterSecret);
+ HashAlgorithm hash = new TlsSslHandshakeHash(this.Context.MasterSecret);
TlsStream data = new TlsStream();
- data.Write(this.Session.Context.HandshakeMessages.ToArray());
+ data.Write(this.Context.HandshakeMessages.ToArray());
data.Write((int)0x53525652);
hash.TransformFinalBlock(data.ToArray(), 0, (int)data.Length);
@@ -90,14 +90,14 @@ namespace Mono.Security.Protocol.Tls.Handshake.Client
protected override void ProcessAsTls1()
{
byte[] serverPRF = this.ReadBytes((int)Length);
- HashAlgorithm hash = new MD5SHA1CryptoServiceProvider();
+ HashAlgorithm hash = new MD5SHA1();
hash.ComputeHash(
- Session.Context.HandshakeMessages.ToArray(),
+ this.Context.HandshakeMessages.ToArray(),
0,
- (int)Session.Context.HandshakeMessages.Length);
+ (int)this.Context.HandshakeMessages.Length);
- byte[] clientPRF = this.Session.Context.Cipher.PRF(this.Session.Context.MasterSecret, "server finished", hash.Hash, 12);
+ byte[] clientPRF = this.Context.Cipher.PRF(this.Context.MasterSecret, "server finished", hash.Hash, 12);
// Check server prf against client prf
if (clientPRF.Length != serverPRF.Length)
diff --git a/mcs/class/Mono.Security/Mono.Security.Protocol.Tls.Handshake.Client/TlsServerHello.cs b/mcs/class/Mono.Security/Mono.Security.Protocol.Tls.Handshake.Client/TlsServerHello.cs
index 7a8a8bb969e..ff207345b5f 100644
--- a/mcs/class/Mono.Security/Mono.Security.Protocol.Tls.Handshake.Client/TlsServerHello.cs
+++ b/mcs/class/Mono.Security/Mono.Security.Protocol.Tls.Handshake.Client/TlsServerHello.cs
@@ -30,8 +30,8 @@ namespace Mono.Security.Protocol.Tls.Handshake.Client
{
#region FIELDS
- private TlsProtocol protocol;
- private TlsCompressionMethod compressionMethod;
+ private SecurityProtocolType protocol;
+ private SecurityCompressionType compressionMethod;
private byte[] random;
private byte[] sessionId;
private CipherSuite cipherSuite;
@@ -40,8 +40,8 @@ namespace Mono.Security.Protocol.Tls.Handshake.Client
#region CONSTRUCTORS
- public TlsServerHello(TlsSession session, byte[] buffer)
- : base(session, TlsHandshakeType.ServerHello, buffer)
+ public TlsServerHello(TlsContext context, byte[] buffer)
+ : base(context, TlsHandshakeType.ServerHello, buffer)
{
}
@@ -53,24 +53,24 @@ namespace Mono.Security.Protocol.Tls.Handshake.Client
{
base.UpdateSession();
- this.Session.SetSessionId(this.sessionId);
- this.Session.Context.ServerRandom = this.random;
- this.Session.Context.Cipher = this.cipherSuite;
- this.Session.Context.CompressionMethod = this.compressionMethod;
- this.Session.Context.Cipher.Context = this.Session.Context;
+ this.Context.SessionId = this.sessionId;
+ this.Context.ServerRandom = this.random;
+ this.Context.Cipher = this.cipherSuite;
+ this.Context.CompressionMethod = this.compressionMethod;
+ this.Context.Cipher.Context = this.Context;
// Compute ClientRandom + ServerRandom
TlsStream random = new TlsStream();
- random.Write(this.Session.Context.ClientRandom);
- random.Write(this.Session.Context.ServerRandom);
- this.Session.Context.RandomCS = random.ToArray();
+ random.Write(this.Context.ClientRandom);
+ random.Write(this.Context.ServerRandom);
+ this.Context.RandomCS = random.ToArray();
// Server Random + Client Random
random.Reset();
- random.Write(this.Session.Context.ServerRandom);
- random.Write(this.Session.Context.ClientRandom);
+ random.Write(this.Context.ServerRandom);
+ random.Write(this.Context.ClientRandom);
- this.Session.Context.RandomSC = random.ToArray();
+ this.Context.RandomSC = random.ToArray();
random.Reset();
}
@@ -80,9 +80,8 @@ namespace Mono.Security.Protocol.Tls.Handshake.Client
protected override void ProcessAsSsl3()
{
- #warning "Check that the protocol sent by the server is supported"
// Read protocol version
- this.protocol = (TlsProtocol)this.ReadInt16();
+ this.protocol = (SecurityProtocolType)this.ReadInt16();
// Read random - Unix time + Random bytes
this.random = this.ReadBytes(32);
@@ -96,21 +95,21 @@ namespace Mono.Security.Protocol.Tls.Handshake.Client
// Read cipher suite
short cipherCode = this.ReadInt16();
- if (this.Session.Context.SupportedCiphers.IndexOf(cipherCode) == -1)
+ if (this.Context.SupportedCiphers.IndexOf(cipherCode) == -1)
{
// The server has sent an invalid ciphersuite
throw new TlsException("Invalid cipher suite received from server");
}
- this.cipherSuite = this.Session.Context.SupportedCiphers[cipherCode];
+ this.cipherSuite = this.Context.SupportedCiphers[cipherCode];
// Read compression methods ( always 0 )
- this.compressionMethod = (TlsCompressionMethod)this.ReadByte();
+ this.compressionMethod = (SecurityCompressionType)this.ReadByte();
}
protected override void ProcessAsTls1()
{
// Read protocol version
- this.protocol = (TlsProtocol)this.ReadInt16();
+ this.protocol = (SecurityProtocolType)this.ReadInt16();
// Read random - Unix time + Random bytes
this.random = this.ReadBytes(32);
@@ -124,15 +123,15 @@ namespace Mono.Security.Protocol.Tls.Handshake.Client
// Read cipher suite
short cipherCode = this.ReadInt16();
- if (this.Session.Context.SupportedCiphers.IndexOf(cipherCode) == -1)
+ if (this.Context.SupportedCiphers.IndexOf(cipherCode) == -1)
{
// The server has sent an invalid ciphersuite
throw new TlsException("Invalid cipher suite received from server");
}
- this.cipherSuite = this.Session.Context.SupportedCiphers[cipherCode];
+ this.cipherSuite = this.Context.SupportedCiphers[cipherCode];
// Read compression methods ( always 0 )
- this.compressionMethod = (TlsCompressionMethod)this.ReadByte();
+ this.compressionMethod = (SecurityCompressionType)this.ReadByte();
}
#endregion
diff --git a/mcs/class/Mono.Security/Mono.Security.Protocol.Tls.Handshake.Client/TlsServerHelloDone.cs b/mcs/class/Mono.Security/Mono.Security.Protocol.Tls.Handshake.Client/TlsServerHelloDone.cs
index 70b3bccf0ad..929f3cec063 100644
--- a/mcs/class/Mono.Security/Mono.Security.Protocol.Tls.Handshake.Client/TlsServerHelloDone.cs
+++ b/mcs/class/Mono.Security/Mono.Security.Protocol.Tls.Handshake.Client/TlsServerHelloDone.cs
@@ -30,8 +30,8 @@ namespace Mono.Security.Protocol.Tls.Handshake.Client
{
#region CONSTRUCTORS
- public TlsServerHelloDone(TlsSession session, byte[] buffer)
- : base(session, TlsHandshakeType.ServerHello, buffer)
+ public TlsServerHelloDone(TlsContext context, byte[] buffer)
+ : base(context, TlsHandshakeType.ServerHello, buffer)
{
}
@@ -43,7 +43,7 @@ namespace Mono.Security.Protocol.Tls.Handshake.Client
{
base.UpdateSession();
- this.Session.Context.HelloDone = true;
+ this.Context.HelloDone = true;
}
#endregion
diff --git a/mcs/class/Mono.Security/Mono.Security.Protocol.Tls.Handshake.Client/TlsServerKeyExchange.cs b/mcs/class/Mono.Security/Mono.Security.Protocol.Tls.Handshake.Client/TlsServerKeyExchange.cs
index dbd1a346ee7..511da18414a 100644
--- a/mcs/class/Mono.Security/Mono.Security.Protocol.Tls.Handshake.Client/TlsServerKeyExchange.cs
+++ b/mcs/class/Mono.Security/Mono.Security.Protocol.Tls.Handshake.Client/TlsServerKeyExchange.cs
@@ -41,8 +41,8 @@ namespace Mono.Security.Protocol.Tls.Handshake.Client
#region CONSTRUCTORS
- public TlsServerKeyExchange(TlsSession session, byte[] buffer)
- : base(session, TlsHandshakeType.ServerKeyExchange, buffer)
+ public TlsServerKeyExchange(TlsContext context, byte[] buffer)
+ : base(context, TlsHandshakeType.ServerKeyExchange, buffer)
{
this.verifySignature();
}
@@ -55,9 +55,9 @@ namespace Mono.Security.Protocol.Tls.Handshake.Client
{
base.UpdateSession();
- this.Session.Context.ServerSettings.ServerKeyExchange = true;
- this.Session.Context.ServerSettings.RsaParameters = this.rsaParams;
- this.Session.Context.ServerSettings.SignedParams = this.signedParams;
+ this.Context.ServerSettings.ServerKeyExchange = true;
+ this.Context.ServerSettings.RsaParameters = this.rsaParams;
+ this.Context.ServerSettings.SignedParams = this.signedParams;
}
#endregion
@@ -89,12 +89,12 @@ namespace Mono.Security.Protocol.Tls.Handshake.Client
private void verifySignature()
{
- MD5SHA1CryptoServiceProvider hash = new MD5SHA1CryptoServiceProvider();
+ MD5SHA1 hash = new MD5SHA1();
// Create server params array
TlsStream stream = new TlsStream();
- stream.Write(this.Session.Context.RandomCS);
+ stream.Write(this.Context.RandomCS);
stream.Write(rsaParams.Modulus.Length);
stream.Write(rsaParams.Modulus);
stream.Write(rsaParams.Exponent.Length);
@@ -105,9 +105,11 @@ namespace Mono.Security.Protocol.Tls.Handshake.Client
stream.Reset();
// Verify Signature
- X509Certificate certificate = this.Session.Context.ServerSettings.ServerCertificates[0];
+ X509Certificate certificate = this.Context.ServerSettings.Certificates[0];
- RSACryptoServiceProvider rsa = new RSACryptoServiceProvider(rsaParams.Modulus.Length << 3);
+ RSA rsa = RSA.Create();
+
+ rsa.KeySize = rsaParams.Modulus.Length << 3;
rsa.ImportParameters(rsaParams);
byte[] sign = hash.CreateSignature(rsa);
diff --git a/mcs/class/Mono.Security/Mono.Security.Protocol.Tls.Handshake/ChangeLog b/mcs/class/Mono.Security/Mono.Security.Protocol.Tls.Handshake/ChangeLog
index 189c9c2dfae..1a83f868c15 100755
--- a/mcs/class/Mono.Security/Mono.Security.Protocol.Tls.Handshake/ChangeLog
+++ b/mcs/class/Mono.Security/Mono.Security.Protocol.Tls.Handshake/ChangeLog
@@ -1,3 +1,123 @@
+2003-11-17 Carlos Guzmán Álvarez <carlosga@telefonica.net>
+
+ * Mono.Security.Protocol.Tls/SslClientStream.cs:
+
+ Removed ReadByte method, use innerStream.ReadByte() method instead.
+
+2003-11-13 Carlos Guzmán Álvarez <carlosga@telefonica.net>
+
+ * Added implementation of an SslClientStream class similar to the MS .NET Framework 1.2 documentation.
+
+ The next files are no more needed:
+
+ - TlsSession.cs
+
+ - TlsNetworkStream.cs
+
+ - TlsSocket.cs
+
+ - TlsSessionState.cs
+
+ The next files are renamed:
+
+ - TlsSessionSettings.cs -> TlsClientSettings.cs
+
+ - TlsSessionContext.cs -> TlsContext.cs
+
+ The next files are new:
+
+ - SslClientStream.cs ( the name is non definitive yet )
+
+ The next files where changed to reflect the new canges:
+
+ - TlsHandshakeMessage.cs
+
+ - TlsClientCertificate.cs
+
+ - TlsClientCertificateVerify.cs
+
+ - TlsClientFinished.cs
+
+ - TlsClientHello.cs
+
+ - TlsClientKeyExchange.cs
+
+ - TlsServerCertificate.cs
+
+ - TlsServerCertificateRequest.cs
+
+ - TlsServerFinished.cs
+
+ - TlsServerHello.cs
+
+ - TlsServerHelloDone.cs
+
+ - TlsServerKeyExchange.cs
+
+ - TlsAlert.cs
+
+ - TlsCloseNotifyAlert.cs
+
+
+2003-11-12 Carlos Guzmán Álvarez <carlosga@telefonica.net>
+
+ * Mono.Security.Protocol.Tls.Alerts/TlsAlert.cs:
+
+ - Changes for give full error message only in debug mode ( Thanks to Sebastién Pouliot. )
+
+ * Mono.Security.Protocol.Tls/TlsProtocol.cs:
+
+ - Renamed to SecurityProtocolType.cs ( for match .NET 1.2 )
+
+ * Mono.Security.Cryptography/MD5SHA1CryptoServiceProvider.cs:
+
+ - Renamed to MD5SHA1.cs ( Thanks to Sebastién Pouliot. )
+
+ * Mono.Security.Cryptography/TlsCompressionMethod.cs:
+
+ - Renamed to SecurityCompressionType.
+
+ * Mono.Security.Protocol.Tls/CipherAlgorithmType.cs:
+ * Mono.Security.Protocol.Tls/HashAlgorithmType.cs:
+ * Mono.Security.Protocol.Tls/ExchangeAlgorithmType.cs:
+
+ - New enumerations that matches .NET 1.2 definitions with some minor differences.
+
+ * Mono.Security.Protocol.Tls/CipherSuite.cs:
+ * Mono.Security.Protocol.Tls/TlsCipherSuite.cs:
+ * Mono.Security.Protocol.Tls/TlsSslCipherSuite.cs:
+ * Mono.Security.Protocol.Tls/TlsSessionContext.cs:
+
+ - Added changes for make use of new enumerations.
+
+ * Mono.Security.Protocol.Tls/TlsClientStream.cs:
+
+ - Added new informative properties that matches .NET 1.2 SslClientStream
+ ( Not all the properties are implemented yet ).
+
+
+2003-11-10 Carlos Guzmán Álvarez <carlosga@telefonica.net>
+
+ * Mono.Security.Protocol.Tls.Alerts/TlsAlert.cs:
+
+ - Fixed invalid alert message.
+
+ * Mono.Security.Protocol.Tls/CipherSuite.cs:
+ * Mono.Security.Protocol.Tls/TlsSslCipherSuite.cs:
+ * Mono.Security.Cryptography/HMAC.cs:
+ * Mono.Security.Cryptography/MD5SHA1CryptoServiceProvider.cs:
+ * Mono.Security.Protocol.Tls.Handshake.Client/TlsClientCertificateVerify.cs:
+
+ - Changed ( Thanks to Sebastién Pouliot for his feedback )
+
+ SHA1CryptoServiceProvider sha = new SHA1CryptoServiceProvider();
+ MD5CryptoServiceProvider sha = new MD5CryptoServiceProvider();
+
+ to
+
+ HashAlgorithm sha = SHA1.Create();
+ HashAlgorithm md5 = MD5.Create();
+
2003-11-04 Carlos Guzmán Álvarez <carlosga@telefonica.net>
* Mono.Security.Protocol.Tls/CipherSuite.cs:
@@ -67,4 +187,4 @@
2003-10-23 Carlos Guzmán Álvarez <carlosga@telefonica.net>
- * Added partial implementation of SSL3 protocol ( not finished yet ). \ No newline at end of file
+ * Added partial implementation of SSL3 protocol ( not finished yet ).
diff --git a/mcs/class/Mono.Security/Mono.Security.Protocol.Tls.Handshake/TlsHandshakeMessage.cs b/mcs/class/Mono.Security/Mono.Security.Protocol.Tls.Handshake/TlsHandshakeMessage.cs
index 5a5215779cf..dda98378636 100644
--- a/mcs/class/Mono.Security/Mono.Security.Protocol.Tls.Handshake/TlsHandshakeMessage.cs
+++ b/mcs/class/Mono.Security/Mono.Security.Protocol.Tls.Handshake/TlsHandshakeMessage.cs
@@ -31,7 +31,7 @@ namespace Mono.Security.Protocol.Tls.Handshake
{
#region FIELDS
- private TlsSession session;
+ private TlsContext context;
private TlsHandshakeType handshakeType;
private TlsContentType contentType;
@@ -39,30 +39,31 @@ namespace Mono.Security.Protocol.Tls.Handshake
#region PROPERTIES
- public TlsSession Session
+ public TlsContext Context
{
- get { return session; }
+ get { return this.context; }
}
public TlsHandshakeType HandshakeType
{
- get { return handshakeType; }
+ get { return this.handshakeType; }
}
public TlsContentType ContentType
{
- get { return contentType; }
+ get { return this.contentType; }
}
#endregion
#region CONSTRUCTORS
- public TlsHandshakeMessage(TlsSession session,
- TlsHandshakeType handshakeType,
- TlsContentType contentType) : base()
+ public TlsHandshakeMessage(
+ TlsContext context,
+ TlsHandshakeType handshakeType,
+ TlsContentType contentType) : base()
{
- this.session = session;
+ this.context = context;
this.handshakeType = handshakeType;
this.contentType = contentType;
@@ -70,10 +71,12 @@ namespace Mono.Security.Protocol.Tls.Handshake
this.process();
}
- public TlsHandshakeMessage(TlsSession session,
- TlsHandshakeType handshakeType, byte[] data) : base(data)
+ public TlsHandshakeMessage(
+ TlsContext context,
+ TlsHandshakeType handshakeType,
+ byte[] data) : base(data)
{
- this.session = session;
+ this.context = context;
this.handshakeType = handshakeType;
// Process message
@@ -94,14 +97,14 @@ namespace Mono.Security.Protocol.Tls.Handshake
private void process()
{
- switch (this.session.Context.Protocol)
+ switch (this.Context.Protocol)
{
- case TlsProtocol.Tls1:
- this.ProcessAsTls1();
+ case SecurityProtocolType.Ssl3:
+ this.ProcessAsSsl3();
break;
- case TlsProtocol.Ssl3:
- this.ProcessAsSsl3();
+ case SecurityProtocolType.Tls:
+ this.ProcessAsTls1();
break;
}
}
@@ -110,7 +113,7 @@ namespace Mono.Security.Protocol.Tls.Handshake
{
if (CanWrite)
{
- this.session.Context.HandshakeMessages.Write(this.EncodeMessage());
+ this.context.HandshakeMessages.Write(this.EncodeMessage());
this.Reset();
}
}
diff --git a/mcs/class/Mono.Security/Mono.Security.Protocol.Tls/ChangeLog b/mcs/class/Mono.Security/Mono.Security.Protocol.Tls/ChangeLog
index bb2ef99488a..f8dcd2a6bc7 100644
--- a/mcs/class/Mono.Security/Mono.Security.Protocol.Tls/ChangeLog
+++ b/mcs/class/Mono.Security/Mono.Security.Protocol.Tls/ChangeLog
@@ -1,3 +1,123 @@
+2003-11-17 Carlos Guzmán Álvarez <carlosga@telefonica.net>
+
+ * Mono.Security.Protocol.Tls/SslClientStream.cs:
+
+ Removed ReadByte method, use innerStream.ReadByte() method instead.
+
+2003-11-13 Carlos Guzmán Álvarez <carlosga@telefonica.net>
+
+ * Added implementation of an SslClientStream class similar to the MS .NET Framework 1.2 documentation.
+
+ The next files are no more needed:
+
+ - TlsSession.cs
+
+ - TlsNetworkStream.cs
+
+ - TlsSocket.cs
+
+ - TlsSessionState.cs
+
+ The next files are renamed:
+
+ - TlsSessionSettings.cs -> TlsClientSettings.cs
+
+ - TlsSessionContext.cs -> TlsContext.cs
+
+ The next files are new:
+
+ - SslClientStream.cs ( the name is non definitive yet )
+
+ The next files where changed to reflect the new canges:
+
+ - TlsHandshakeMessage.cs
+
+ - TlsClientCertificate.cs
+
+ - TlsClientCertificateVerify.cs
+
+ - TlsClientFinished.cs
+
+ - TlsClientHello.cs
+
+ - TlsClientKeyExchange.cs
+
+ - TlsServerCertificate.cs
+
+ - TlsServerCertificateRequest.cs
+
+ - TlsServerFinished.cs
+
+ - TlsServerHello.cs
+
+ - TlsServerHelloDone.cs
+
+ - TlsServerKeyExchange.cs
+
+ - TlsAlert.cs
+
+ - TlsCloseNotifyAlert.cs
+
+
+2003-11-12 Carlos Guzmán Álvarez <carlosga@telefonica.net>
+
+ * Mono.Security.Protocol.Tls.Alerts/TlsAlert.cs:
+
+ - Changes for give full error message only in debug mode ( Thanks to Sebastién Pouliot. )
+
+ * Mono.Security.Protocol.Tls/TlsProtocol.cs:
+
+ - Renamed to SecurityProtocolType.cs ( for match .NET 1.2 )
+
+ * Mono.Security.Cryptography/MD5SHA1CryptoServiceProvider.cs:
+
+ - Renamed to MD5SHA1.cs ( Thanks to Sebastién Pouliot. )
+
+ * Mono.Security.Cryptography/TlsCompressionMethod.cs:
+
+ - Renamed to SecurityCompressionType.
+
+ * Mono.Security.Protocol.Tls/CipherAlgorithmType.cs:
+ * Mono.Security.Protocol.Tls/HashAlgorithmType.cs:
+ * Mono.Security.Protocol.Tls/ExchangeAlgorithmType.cs:
+
+ - New enumerations that matches .NET 1.2 definitions with some minor differences.
+
+ * Mono.Security.Protocol.Tls/CipherSuite.cs:
+ * Mono.Security.Protocol.Tls/TlsCipherSuite.cs:
+ * Mono.Security.Protocol.Tls/TlsSslCipherSuite.cs:
+ * Mono.Security.Protocol.Tls/TlsSessionContext.cs:
+
+ - Added changes for make use of new enumerations.
+
+ * Mono.Security.Protocol.Tls/TlsClientStream.cs:
+
+ - Added new informative properties that matches .NET 1.2 SslClientStream
+ ( Not all the properties are implemented yet ).
+
+
+2003-11-10 Carlos Guzmán Álvarez <carlosga@telefonica.net>
+
+ * Mono.Security.Protocol.Tls.Alerts/TlsAlert.cs:
+
+ - Fixed invalid alert message.
+
+ * Mono.Security.Protocol.Tls/CipherSuite.cs:
+ * Mono.Security.Protocol.Tls/TlsSslCipherSuite.cs:
+ * Mono.Security.Cryptography/HMAC.cs:
+ * Mono.Security.Cryptography/MD5SHA1CryptoServiceProvider.cs:
+ * Mono.Security.Protocol.Tls.Handshake.Client/TlsClientCertificateVerify.cs:
+
+ - Changed ( Thanks to Sebastién Pouliot for his feedback )
+
+ SHA1CryptoServiceProvider sha = new SHA1CryptoServiceProvider();
+ MD5CryptoServiceProvider sha = new MD5CryptoServiceProvider();
+
+ to
+
+ HashAlgorithm sha = SHA1.Create();
+ HashAlgorithm md5 = MD5.Create();
+
2003-11-04 Carlos Guzmán Álvarez <carlosga@telefonica.net>
* Mono.Security.Protocol.Tls/CipherSuite.cs:
diff --git a/mcs/class/Mono.Security/Mono.Security.Protocol.Tls/CipherAlgorithmType.cs b/mcs/class/Mono.Security/Mono.Security.Protocol.Tls/CipherAlgorithmType.cs
new file mode 100644
index 00000000000..c1d6196c989
--- /dev/null
+++ b/mcs/class/Mono.Security/Mono.Security.Protocol.Tls/CipherAlgorithmType.cs
@@ -0,0 +1,39 @@
+/* Transport Security Layer (TLS)
+ * Copyright (c) 2003 Carlos Guzmán Álvarez
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+using System;
+
+namespace Mono.Security.Protocol.Tls
+{
+ public enum CipherAlgorithmType
+ {
+ Des,
+ None,
+ Rc2,
+ Rc4,
+ Rijndael,
+ SkipJack,
+ TripleDes
+ }
+}
diff --git a/mcs/class/Mono.Security/Mono.Security.Protocol.Tls/CipherSuite.cs b/mcs/class/Mono.Security/Mono.Security.Protocol.Tls/CipherSuite.cs
index b3926ee28db..99de84adb92 100755
--- a/mcs/class/Mono.Security/Mono.Security.Protocol.Tls/CipherSuite.cs
+++ b/mcs/class/Mono.Security/Mono.Security.Protocol.Tls/CipherSuite.cs
@@ -30,6 +30,7 @@ using System.Security.Cryptography;
using Mono.Security;
using Mono.Security.Cryptography;
using Mono.Security.X509;
+using M = Mono.Security.Cryptography;
namespace Mono.Security.Protocol.Tls
{
@@ -37,24 +38,26 @@ namespace Mono.Security.Protocol.Tls
{
#region FIELDS
- private short code;
- private string name;
- private string algName;
- private string hashName;
- private bool isExportable;
- private CipherMode cipherMode;
- private byte keyMaterialSize;
- private byte expandedKeyMaterialSize;
- private short effectiveKeyBits;
- private byte ivSize;
- private byte blockSize;
- private TlsSessionContext context;
- private SymmetricAlgorithm encryptionAlgorithm;
- private ICryptoTransform encryptionCipher;
- private SymmetricAlgorithm decryptionAlgorithm;
- private ICryptoTransform decryptionCipher;
- private KeyedHashAlgorithm clientHMAC;
- private KeyedHashAlgorithm serverHMAC;
+ private short code;
+ private string name;
+ private CipherAlgorithmType cipherAlgorithmType;
+ private HashAlgorithmType hashAlgorithmType;
+ private ExchangeAlgorithmType exchangeAlgorithmType;
+ private bool isExportable;
+ private CipherMode cipherMode;
+ private byte keyMaterialSize;
+ private int keyBlockSize;
+ private byte expandedKeyMaterialSize;
+ private short effectiveKeyBits;
+ private byte ivSize;
+ private byte blockSize;
+ private TlsContext context;
+ private SymmetricAlgorithm encryptionAlgorithm;
+ private ICryptoTransform encryptionCipher;
+ private SymmetricAlgorithm decryptionAlgorithm;
+ private ICryptoTransform decryptionCipher;
+ private KeyedHashAlgorithm clientHMAC;
+ private KeyedHashAlgorithm serverHMAC;
#endregion
@@ -62,117 +65,162 @@ namespace Mono.Security.Protocol.Tls
protected ICryptoTransform EncryptionCipher
{
- get { return encryptionCipher; }
+ get { return this.encryptionCipher; }
}
protected ICryptoTransform DecryptionCipher
{
- get { return decryptionCipher; }
+ get { return this.decryptionCipher; }
}
protected KeyedHashAlgorithm ClientHMAC
{
- get { return clientHMAC; }
+ get { return this.clientHMAC; }
}
protected KeyedHashAlgorithm ServerHMAC
{
- get { return serverHMAC; }
+ get { return this.serverHMAC; }
}
#endregion
#region PROPERTIES
- public short Code
+ public CipherAlgorithmType CipherAlgorithmType
{
- get { return code; }
+ get { return this.cipherAlgorithmType; }
}
- public string Name
+ public string HashAlgorithmName
{
- get { return name; }
+ get
+ {
+ switch (this.hashAlgorithmType)
+ {
+ case HashAlgorithmType.Md5:
+ return "MD5";
+
+ case HashAlgorithmType.Sha1:
+ return "SHA1";
+
+ default:
+ return "None";
+ }
+ }
}
- public bool IsExportable
+ public HashAlgorithmType HashAlgorithmType
{
- get { return isExportable; }
+ get { return this.hashAlgorithmType; }
+ }
+
+ public int HashSize
+ {
+ get
+ {
+ switch (this.hashAlgorithmType)
+ {
+ case HashAlgorithmType.Md5:
+ return 16;
+
+ case HashAlgorithmType.Sha1:
+ return 20;
+
+ default:
+ return 0;
+ }
+ }
+ }
+
+ public ExchangeAlgorithmType ExchangeAlgorithmType
+ {
+ get { return this.exchangeAlgorithmType; }
}
public CipherMode CipherMode
{
- get { return cipherMode; }
+ get { return this.cipherMode; }
}
- public int HashSize
+ public short Code
+ {
+ get { return this.code; }
+ }
+
+ public string Name
+ {
+ get { return this.name; }
+ }
+
+ public bool IsExportable
{
- get { return (int)(hashName == "MD5" ? 16 : 20); }
+ get { return this.isExportable; }
}
public byte KeyMaterialSize
{
- get { return keyMaterialSize; }
+ get { return this.keyMaterialSize; }
}
public int KeyBlockSize
{
- get
- {
- return keyMaterialSize*2 + HashSize*2 + ivSize*2;
- }
+ get { return this.keyBlockSize; }
}
public byte ExpandedKeyMaterialSize
{
- get { return expandedKeyMaterialSize; }
+ get { return this.expandedKeyMaterialSize; }
}
public byte EffectiveKeyBits
{
- get { return EffectiveKeyBits; }
+ get { return this.EffectiveKeyBits; }
}
public byte IvSize
{
- get { return ivSize; }
+ get { return this.ivSize; }
}
public byte BlockSize
{
- get { return blockSize; }
- }
-
- public string HashName
- {
- get { return hashName; }
+ get { return this.blockSize; }
}
- public TlsSessionContext Context
+ public TlsContext Context
{
- get { return context; }
- set { context = value; }
+ get { return this.context; }
+ set { this.context = value; }
}
#endregion
#region CONSTRUCTORS
- public CipherSuite(short code, string name, string algName, string hashName, bool exportable, bool blockMode, byte keyMaterialSize, byte expandedKeyMaterialSize, short effectiveKeyBytes, byte ivSize, byte blockSize)
+ public CipherSuite(
+ short code, string name, CipherAlgorithmType cipherAlgorithmType,
+ HashAlgorithmType hashAlgorithmType, ExchangeAlgorithmType exchangeAlgorithmType,
+ bool exportable, bool blockMode, byte keyMaterialSize,
+ byte expandedKeyMaterialSize, short effectiveKeyBytes,
+ byte ivSize, byte blockSize)
{
- this.code = code;
- this.name = name;
- this.algName = algName;
- this.hashName = hashName;
- this.isExportable = exportable;
+ this.code = code;
+ this.name = name;
+ this.cipherAlgorithmType = cipherAlgorithmType;
+ this.hashAlgorithmType = hashAlgorithmType;
+ this.exchangeAlgorithmType = exchangeAlgorithmType;
+ this.isExportable = exportable;
if (blockMode)
{
- this.cipherMode = CipherMode.CBC;
+ this.cipherMode = CipherMode.CBC;
}
- this.keyMaterialSize = keyMaterialSize;
- this.expandedKeyMaterialSize = expandedKeyMaterialSize;
- this.effectiveKeyBits = effectiveKeyBits;
- this.ivSize = ivSize;
- this.blockSize = blockSize;
+ this.keyMaterialSize = keyMaterialSize;
+ this.expandedKeyMaterialSize= expandedKeyMaterialSize;
+ this.effectiveKeyBits = effectiveKeyBits;
+ this.ivSize = ivSize;
+ this.blockSize = blockSize;
+ this.keyBlockSize = this.keyMaterialSize*2 + this.HashSize*2 + this.ivSize*2;
}
#endregion
@@ -181,8 +229,8 @@ namespace Mono.Security.Protocol.Tls
public void InitializeCipher()
{
- createEncryptionCipher();
- createDecryptionCipher();
+ this.createEncryptionCipher();
+ this.createDecryptionCipher();
}
public RSA CreateRSA()
@@ -190,50 +238,38 @@ namespace Mono.Security.Protocol.Tls
RSA rsa;
if (this.Context.ServerSettings.ServerKeyExchange)
{
- rsa = new RSACryptoServiceProvider();
+ rsa = RSA.Create();
rsa.ImportParameters(this.Context.ServerSettings.RsaParameters);
}
else
{
- rsa = this.Context.ServerSettings.ServerCertificates[0].RSA;
+ rsa = this.Context.ServerSettings.Certificates[0].RSA;
}
return rsa;
}
- public RSACryptoServiceProvider CreateRSA(RSAParameters rsaParams)
- {
- // BUG: MS BCL 1.0 can't import a key which
- // isn't the same size as the one present in
- // the container.
- int keySize = (rsaParams.Modulus.Length << 3);
- RSACryptoServiceProvider rsa = new RSACryptoServiceProvider(keySize);
- rsa.ImportParameters(rsaParams);
-
- return rsa;
- }
-
public void UpdateClientCipherIV(byte[] iv)
{
- if (cipherMode == CipherMode.CBC)
+ if (this.cipherMode == CipherMode.CBC)
{
// Set the new IV
- encryptionAlgorithm.IV = iv;
+ this.encryptionAlgorithm.IV = iv;
// Create encryption cipher with the new IV
- encryptionCipher = encryptionAlgorithm.CreateEncryptor();
+ this.encryptionCipher = this.encryptionAlgorithm.CreateEncryptor();
}
}
public void UpdateServerCipherIV(byte[] iv)
{
- if (cipherMode == CipherMode.CBC)
+ if (this.cipherMode == CipherMode.CBC)
{
// Set the new IV
- decryptionAlgorithm.IV = iv;
+ this.decryptionAlgorithm.IV = iv;
// Create encryption cipher with the new IV
- decryptionCipher = decryptionAlgorithm.CreateDecryptor();
+ this.decryptionCipher = this.decryptionAlgorithm.CreateDecryptor();
}
}
@@ -293,11 +329,11 @@ namespace Mono.Security.Protocol.Tls
}
*/
- fragmentSize = (buffer.Length - (paddingLength + 1)) - HashSize;
+ fragmentSize = (buffer.Length - (paddingLength + 1)) - this.HashSize;
}
else
{
- fragmentSize = buffer.Length - HashSize;
+ fragmentSize = buffer.Length - this.HashSize;
}
dcrFragment = new byte[fragmentSize];
@@ -342,8 +378,8 @@ namespace Mono.Security.Protocol.Tls
public byte[] PRF(byte[] secret, string label, byte[] data, int length)
{
- MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider();
- SHA1CryptoServiceProvider sha1 = new SHA1CryptoServiceProvider();
+ HashAlgorithm md5 = MD5.Create();
+ HashAlgorithm sha1 = SHA1.Create();
int secretLen = secret.Length / 2;
@@ -387,7 +423,7 @@ namespace Mono.Security.Protocol.Tls
iterations++;
}
- HMAC hmac = new HMAC(hashName, secret);
+ M.HMAC hmac = new M.HMAC(hashName, secret);
TlsStream resMacs = new TlsStream();
byte[][] hmacs = new byte[iterations + 1][];
@@ -417,93 +453,102 @@ namespace Mono.Security.Protocol.Tls
#region PRIVATE_METHODS
- // This code is from Mono.Security.X509Certificate class.
- private byte[] getUnsignedBigInteger(byte[] integer)
- {
- if (integer[0] == 0x00)
- {
- // this first byte is added so we're sure it's an unsigned integer
- // however we can't feed it into RSAParameters or DSAParameters
- int length = integer.Length - 1;
- byte[] uinteger = new byte[length];
- Array.Copy(integer, 1, uinteger, 0, length);
-
- return uinteger;
- }
- else
- {
- return integer;
- }
- }
-
private void createEncryptionCipher()
{
// Create and configure the symmetric algorithm
- switch (this.algName)
+ switch (this.cipherAlgorithmType)
{
- case "RC4":
- encryptionAlgorithm = new ARC4Managed();
+ case CipherAlgorithmType.Des:
+ this.encryptionAlgorithm = DES.Create();
+ break;
+
+ case CipherAlgorithmType.Rc2:
+ this.encryptionAlgorithm = RC2.Create();
+ break;
+
+ case CipherAlgorithmType.Rc4:
+ this.encryptionAlgorithm = new ARC4Managed();
break;
- default:
- encryptionAlgorithm = SymmetricAlgorithm.Create(algName);
+ case CipherAlgorithmType.TripleDes:
+ this.encryptionAlgorithm = TripleDES.Create();
+ break;
+
+ case CipherAlgorithmType.Rijndael:
+ this.encryptionAlgorithm = Rijndael.Create();
break;
}
// If it's a block cipher
- if (cipherMode == CipherMode.CBC)
+ if (this.cipherMode == CipherMode.CBC)
{
// Configure encrypt algorithm
- encryptionAlgorithm.Mode = this.cipherMode;
- encryptionAlgorithm.Padding = PaddingMode.None;
- encryptionAlgorithm.KeySize = this.keyMaterialSize * 8;
- encryptionAlgorithm.BlockSize = this.blockSize * 8;
+ this.encryptionAlgorithm.Mode = this.cipherMode;
+ this.encryptionAlgorithm.Padding = PaddingMode.None;
+ this.encryptionAlgorithm.KeySize = this.keyMaterialSize * 8;
+ this.encryptionAlgorithm.BlockSize = this.blockSize * 8;
}
// Set the key and IV for the algorithm
- encryptionAlgorithm.Key = context.ClientWriteKey;
- encryptionAlgorithm.IV = context.ClientWriteIV;
+ this.encryptionAlgorithm.Key = this.context.ClientWriteKey;
+ this.encryptionAlgorithm.IV = this.context.ClientWriteIV;
// Create encryption cipher
- encryptionCipher = encryptionAlgorithm.CreateEncryptor();
+ this.encryptionCipher = this.encryptionAlgorithm.CreateEncryptor();
// Create the HMAC algorithm for the client
- clientHMAC = new HMAC(hashName, context.ClientWriteMAC);
+ this.clientHMAC = new M.HMAC(
+ this.HashAlgorithmName,
+ this.context.ClientWriteMAC);
}
private void createDecryptionCipher()
{
// Create and configure the symmetric algorithm
- switch (this.algName)
+ switch (this.cipherAlgorithmType)
{
- case "RC4":
- decryptionAlgorithm = new ARC4Managed();
+ case CipherAlgorithmType.Des:
+ this.decryptionAlgorithm = DES.Create();
+ break;
+
+ case CipherAlgorithmType.Rc2:
+ this.decryptionAlgorithm = RC2.Create();
+ break;
+
+ case CipherAlgorithmType.Rc4:
+ this.decryptionAlgorithm = new ARC4Managed();
+ break;
+
+ case CipherAlgorithmType.TripleDes:
+ this.decryptionAlgorithm = TripleDES.Create();
break;
- default:
- decryptionAlgorithm = SymmetricAlgorithm.Create(algName);
+ case CipherAlgorithmType.Rijndael:
+ this.decryptionAlgorithm = Rijndael.Create();
break;
}
// If it's a block cipher
- if (cipherMode == CipherMode.CBC)
+ if (this.cipherMode == CipherMode.CBC)
{
// Configure encrypt algorithm
- decryptionAlgorithm.Mode = this.cipherMode;
- decryptionAlgorithm.Padding = PaddingMode.None;
- decryptionAlgorithm.KeySize = this.keyMaterialSize * 8;
- decryptionAlgorithm.BlockSize = this.blockSize * 8;
+ this.decryptionAlgorithm.Mode = this.cipherMode;
+ this.decryptionAlgorithm.Padding = PaddingMode.None;
+ this.decryptionAlgorithm.KeySize = this.keyMaterialSize * 8;
+ this.decryptionAlgorithm.BlockSize = this.blockSize * 8;
}
// Set the key and IV for the algorithm
- decryptionAlgorithm.Key = context.ServerWriteKey;
- decryptionAlgorithm.IV = context.ServerWriteIV;
+ this.decryptionAlgorithm.Key = this.context.ServerWriteKey;
+ this.decryptionAlgorithm.IV = this.context.ServerWriteIV;
// Create decryption cipher
- decryptionCipher = decryptionAlgorithm.CreateDecryptor();
+ this.decryptionCipher = this.decryptionAlgorithm.CreateDecryptor();
// Create the HMAC algorithm for the server
- serverHMAC = new HMAC(hashName, context.ServerWriteMAC);
+ this.serverHMAC = new M.HMAC(
+ this.HashAlgorithmName,
+ this.context.ServerWriteMAC);
}
#endregion
diff --git a/mcs/class/Mono.Security/Mono.Security.Protocol.Tls/ExchangeAlgorithmType.cs b/mcs/class/Mono.Security/Mono.Security.Protocol.Tls/ExchangeAlgorithmType.cs
new file mode 100644
index 00000000000..7a59d132dc0
--- /dev/null
+++ b/mcs/class/Mono.Security/Mono.Security.Protocol.Tls/ExchangeAlgorithmType.cs
@@ -0,0 +1,37 @@
+/* Transport Security Layer (TLS)
+ * Copyright (c) 2003 Carlos Guzmán Álvarez
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+using System;
+
+namespace Mono.Security.Protocol.Tls
+{
+ public enum ExchangeAlgorithmType
+ {
+ DiffieHellman,
+ Fortezza,
+ None,
+ RsaKeyX,
+ RsaSign
+ }
+}
diff --git a/mcs/class/Mono.Security/Mono.Security.Protocol.Tls/HashAlgorithmType.cs b/mcs/class/Mono.Security/Mono.Security.Protocol.Tls/HashAlgorithmType.cs
new file mode 100644
index 00000000000..21bf1c102cc
--- /dev/null
+++ b/mcs/class/Mono.Security/Mono.Security.Protocol.Tls/HashAlgorithmType.cs
@@ -0,0 +1,35 @@
+/* Transport Security Layer (TLS)
+ * Copyright (c) 2003 Carlos Guzmán Álvarez
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+using System;
+
+namespace Mono.Security.Protocol.Tls
+{
+ public enum HashAlgorithmType
+ {
+ Md5,
+ None,
+ Sha1
+ }
+}
diff --git a/mcs/class/Mono.Security/Mono.Security.Protocol.Tls/SecurityCompressionType.cs b/mcs/class/Mono.Security/Mono.Security.Protocol.Tls/SecurityCompressionType.cs
new file mode 100644
index 00000000000..5ef521cadfa
--- /dev/null
+++ b/mcs/class/Mono.Security/Mono.Security.Protocol.Tls/SecurityCompressionType.cs
@@ -0,0 +1,37 @@
+/* Transport Security Layer (TLS)
+ * Copyright (c) 2003 Carlos Guzmán Álvarez
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+using System;
+
+namespace Mono.Security.Protocol.Tls
+{
+ // Information about compression methods allowed by TLS
+ // can be found in:
+ // draft-ietf-tls-compression-05.txt (http://www.ietf.org/internet-drafts/draft-ietf-tls-compression-05.txt)
+ public enum SecurityCompressionType : byte
+ {
+ None = 0,
+ Zlib = 1
+ }
+}
diff --git a/mcs/class/Mono.Security/Mono.Security.Protocol.Tls/SecurityProtocolType.cs b/mcs/class/Mono.Security/Mono.Security.Protocol.Tls/SecurityProtocolType.cs
new file mode 100644
index 00000000000..fe7692c5d70
--- /dev/null
+++ b/mcs/class/Mono.Security/Mono.Security.Protocol.Tls/SecurityProtocolType.cs
@@ -0,0 +1,35 @@
+/* Transport Security Layer (TLS)
+ * Copyright (c) 2003 Carlos Guzmán Álvarez
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+using System;
+
+namespace Mono.Security.Protocol.Tls
+{
+ public enum SecurityProtocolType : short
+ {
+ Default = (0x03 << 8) | 0x01,
+ Ssl3 = (0x03 << 8) | 0x00,
+ Tls = (0x03 << 8) | 0x01
+ }
+} \ No newline at end of file
diff --git a/mcs/class/Mono.Security/Mono.Security.Protocol.Tls/SslClientStream.cs b/mcs/class/Mono.Security/Mono.Security.Protocol.Tls/SslClientStream.cs
new file mode 100644
index 00000000000..a06ac5dcbf3
--- /dev/null
+++ b/mcs/class/Mono.Security/Mono.Security.Protocol.Tls/SslClientStream.cs
@@ -0,0 +1,1002 @@
+/* Transport Security Layer (TLS)
+ * Copyright (c) 2003 Carlos Guzmán Álvarez
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+using System;
+using System.Collections;
+using System.IO;
+using System.Net;
+using System.Net.Sockets;
+using System.Security.Cryptography;
+using System.Security.Cryptography.X509Certificates;
+
+using Mono.Security.Protocol.Tls.Alerts;
+using Mono.Security.Protocol.Tls.Handshake;
+using Mono.Security.Protocol.Tls.Handshake.Client;
+
+namespace Mono.Security.Protocol.Tls
+{
+ public delegate bool CertificateValidationCallback(
+ X509Certificate certificate, int[] certificateErrors);
+
+ public delegate X509Certificate CertificateSelectionCallback(
+ X509CertificateCollection clientCertificates,
+ X509Certificate serverCertificate,
+ string targetHost,
+ X509CertificateCollection serverRequestedCertificates);
+
+ public class SslClientStream : Stream, IDisposable
+ {
+ #region EVENTS
+
+ public event TlsWarningAlertEventHandler WarningAlert;
+
+ #endregion
+
+ #region INTERNAL_EVENTS
+
+ internal event CertificateValidationCallback ServerCertValidation;
+ internal event CertificateSelectionCallback ClientCertSelection;
+
+ #endregion
+
+ #region FIELDS
+
+ private CertificateValidationCallback serverCertValidationDelegate;
+ private CertificateSelectionCallback clientCertSelectionDelegate;
+ private Stream innerStream;
+ private BufferedStream inputBuffer;
+ private TlsContext context;
+ private bool ownsStream;
+ private bool disposed;
+
+ #endregion
+
+ #region PROPERTIES
+
+ public override bool CanRead
+ {
+ get { return this.innerStream.CanRead; }
+ }
+
+ public override bool CanSeek
+ {
+ get { return false; }
+ }
+
+ public override bool CanWrite
+ {
+ get { return this.innerStream.CanWrite; }
+ }
+
+ public override long Length
+ {
+ get { throw new NotSupportedException(); }
+ }
+
+ public override long Position
+ {
+ get { throw new NotSupportedException(); }
+ set { throw new NotSupportedException(); }
+
+ }
+
+ #endregion
+
+ #region SECURITY_PROPERTIES
+
+ public bool CheckCertRevocationStatus
+ {
+ get { throw new NotImplementedException(); }
+ set { throw new NotImplementedException(); }
+ }
+
+ public CertificateValidationCallback ServerCertValidationDelegate
+ {
+ get { return this.serverCertValidationDelegate; }
+ set
+ {
+ if (this.ServerCertValidation != null)
+ {
+ this.ServerCertValidation -= this.serverCertValidationDelegate;
+ }
+ this.serverCertValidationDelegate = value;
+ this.ServerCertValidation += this.serverCertValidationDelegate;
+ }
+ }
+
+ public CertificateSelectionCallback ClientCertSelectionDelegate
+ {
+ get { return this.clientCertSelectionDelegate; }
+ set
+ {
+ if (this.ClientCertSelection != null)
+ {
+ this.ClientCertSelection -= this.clientCertSelectionDelegate;
+ }
+ this.clientCertSelectionDelegate = value;
+ this.ClientCertSelection += this.clientCertSelectionDelegate;
+ }
+ }
+
+ public CipherAlgorithmType CipherAlgorithm
+ {
+ get { return this.context.Cipher.CipherAlgorithmType;}
+ }
+
+ public int CipherStrength
+ {
+ get { return this.context.Cipher.EffectiveKeyBits;}
+ }
+
+ public X509CertificateCollection ClientCertificates
+ {
+ get { return this.context.ClientSettings.Certificates;}
+ }
+
+ public HashAlgorithmType HashAlgorithm
+ {
+ get { return this.context.Cipher.HashAlgorithmType; }
+ }
+
+ public int HashStrength
+ {
+ get { return this.context.Cipher.HashSize * 8; }
+ }
+
+ public int KeyExchangeStrength
+ {
+ get
+ {
+ return this.context.ServerSettings.Certificates[0].RSA.KeySize;
+ }
+ }
+
+ public ExchangeAlgorithmType KeyExchangeAlgorithm
+ {
+ get { return this.context.Cipher.ExchangeAlgorithmType; }
+ }
+
+ public SecurityProtocolType SecurityProtocol
+ {
+ get { return this.context.Protocol; }
+ }
+
+ public X509Certificate SelectedClientCertificate
+ {
+ get { throw new NotImplementedException(); }
+ }
+
+ public X509Certificate ServerCertificate
+ {
+ get { throw new NotImplementedException(); }
+ }
+
+ #endregion
+
+ #region DESTRUCTOR
+
+ ~SslClientStream()
+ {
+ this.Dispose(false);
+ }
+
+ #endregion
+
+ #region IDISPOSABLE
+
+ void IDisposable.Dispose()
+ {
+ this.Dispose(true);
+ GC.SuppressFinalize(this);
+ }
+
+ protected virtual void Dispose(bool disposing)
+ {
+ if (!disposed)
+ {
+ if (disposing)
+ {
+ if (this.innerStream != null)
+ {
+ // Write close notify
+ TlsCloseNotifyAlert alert = new TlsCloseNotifyAlert(this.context);
+ this.SendAlert(alert);
+
+ if (this.ownsStream)
+ {
+ // Close inner stream
+ this.innerStream.Close();
+ }
+ }
+ this.ownsStream = false;
+ this.innerStream = null;
+ if (this.ClientCertSelection != null)
+ {
+ this.ClientCertSelection -= this.clientCertSelectionDelegate;
+ }
+ if (this.ServerCertValidation != null)
+ {
+ this.ServerCertValidation -= this.serverCertValidationDelegate;
+ }
+ this.serverCertValidationDelegate = null;
+ this.clientCertSelectionDelegate = null;
+ }
+
+ disposed = true;
+ }
+ }
+
+ #endregion
+
+ #region CONSTRUCTORS
+
+ public SslClientStream(Stream stream, string targetHost, bool ownsStream) :
+ this(stream, targetHost,
+ ownsStream, SecurityProtocolType.Default, null)
+ {
+ }
+
+ public SslClientStream(
+ Stream stream, string targetHost, X509Certificate clientCertificate) :
+ this(
+ stream, targetHost,
+ false, SecurityProtocolType.Default,
+ new X509CertificateCollection(new X509Certificate[]{clientCertificate}))
+ {
+ }
+
+ public SslClientStream(
+ Stream stream,
+ string targetHost, X509CertificateCollection clientCertificates) :
+ this(stream, targetHost, false,
+ SecurityProtocolType.Default, clientCertificates)
+ {
+ }
+
+ public SslClientStream(
+ Stream stream,
+ string targetHost,
+ bool ownsStream,
+ SecurityProtocolType securityProtocolType) :
+ this(stream, targetHost, ownsStream, securityProtocolType,
+ new X509CertificateCollection())
+ {
+ }
+
+ public SslClientStream(
+ Stream stream,
+ string targetHost,
+ bool ownsStream,
+ SecurityProtocolType securityProtocolType,
+ X509CertificateCollection clientCertificates)
+ {
+ this.context = new TlsContext(
+ this,
+ securityProtocolType,
+ targetHost,
+ clientCertificates);
+ this.inputBuffer = new BufferedStream(new MemoryStream());
+ this.innerStream = stream;
+ this.ownsStream = ownsStream;
+ }
+
+ #endregion
+
+ #region METHODS
+
+ public override IAsyncResult BeginRead(
+ byte[] buffer,
+ int offset,
+ int count,
+ AsyncCallback callback,
+ object state)
+ {
+ throw new NotSupportedException();
+ }
+
+ public override IAsyncResult BeginWrite(
+ byte[] buffer,
+ int offset,
+ int count,
+ AsyncCallback callback,
+ object state)
+ {
+ throw new NotSupportedException();
+ }
+
+ public override int EndRead(IAsyncResult asyncResult)
+ {
+ throw new NotSupportedException();
+ }
+
+ public override void EndWrite(IAsyncResult asyncResult)
+ {
+ throw new NotSupportedException();
+ }
+
+ public override void Close()
+ {
+ ((IDisposable)this).Dispose();
+ }
+
+ public override void Flush()
+ {
+ if (this.disposed)
+ {
+ throw new ObjectDisposedException("The NetworkStream is closed.");
+ }
+
+ this.innerStream.Flush();
+ }
+
+ public int Read(byte[] buffer)
+ {
+ return this.Read(buffer, 0, buffer.Length);
+ }
+
+ public override int Read(byte[] buffer, int offset, int size)
+ {
+ if (!this.context.HandshakeFinished)
+ {
+ // Start handshake negotiation
+ this.doHandshake();
+ }
+
+ if (buffer == null)
+ {
+ throw new ArgumentNullException("buffer is a null reference.");
+ }
+ if (offset < 0)
+ {
+ throw new ArgumentOutOfRangeException("offset is less than 0.");
+ }
+ if (offset > buffer.Length)
+ {
+ throw new ArgumentOutOfRangeException("offset is greater than the length of buffer.");
+ }
+ if (size < 0)
+ {
+ throw new ArgumentOutOfRangeException("size is less than 0.");
+ }
+ if (size > (buffer.Length - offset))
+ {
+ throw new ArgumentOutOfRangeException("size is less than the length of buffer minus the value of the offset parameter.");
+ }
+ if (this.disposed)
+ {
+ throw new ObjectDisposedException("The NetworkStream is closed.");
+ }
+
+ try
+ {
+ // If actual buffer is full readed reset it
+ if (this.inputBuffer.Position == this.inputBuffer.Length &&
+ this.inputBuffer.Length > 0)
+ {
+ this.resetBuffer();
+ }
+
+ // Check if we have space in the middle buffer
+ // if not Read next TLS record and update the inputBuffer
+ while ((this.inputBuffer.Length - this.inputBuffer.Position) < size)
+ {
+ // Read next record and write it into the inputBuffer
+ long position = this.inputBuffer.Position;
+ byte[] record = this.receiveRecord();
+
+ if (record.Length > 0)
+ {
+ // Write new data to the inputBuffer
+ this.inputBuffer.Seek(0, SeekOrigin.End);
+ this.inputBuffer.Write(record, 0, record.Length);
+
+ // Restore buffer position
+ this.inputBuffer.Seek(position, SeekOrigin.Begin);
+ }
+
+ #warning "Think on how to solve this"
+ /*
+ if (base.Available == 0)
+ {
+ break;
+ }
+ */
+ }
+
+ return this.inputBuffer.Read(buffer, offset, size);
+ }
+ catch (TlsException ex)
+ {
+ throw ex;
+ }
+ catch (Exception ex)
+ {
+ throw new IOException("IO exception during read.", ex);
+ }
+ }
+
+ public override long Seek(long offset, SeekOrigin origin)
+ {
+ throw new NotSupportedException();
+ }
+
+ public override void SetLength(long value)
+ {
+ throw new NotSupportedException();
+ }
+
+ public void Write(byte[] buffer)
+ {
+ this.Write(buffer, 0, buffer.Length);
+ }
+
+ public override void Write(byte[] buffer, int offset, int size)
+ {
+ if (!this.context.HandshakeFinished)
+ {
+ // Start handshake negotiation
+ this.doHandshake();
+ }
+
+ if (buffer == null)
+ {
+ throw new ArgumentNullException("buffer is a null reference.");
+ }
+ if (offset < 0)
+ {
+ throw new ArgumentOutOfRangeException("offset is less than 0.");
+ }
+ if (offset > buffer.Length)
+ {
+ throw new ArgumentOutOfRangeException("offset is greater than the length of buffer.");
+ }
+ if (size < 0)
+ {
+ throw new ArgumentOutOfRangeException("size is less than 0.");
+ }
+ if (size > (buffer.Length - offset))
+ {
+ throw new ArgumentOutOfRangeException("size is less than the length of buffer minus the value of the offset parameter.");
+ }
+ if (disposed)
+ {
+ throw new ObjectDisposedException("The NetworkStream is closed.");
+ }
+
+ try
+ {
+ // Send the buffer as a TLS record
+ byte[] recordData = new byte[size];
+ System.Array.Copy(buffer, offset, recordData, 0, size);
+
+ this.sendRecord(TlsContentType.ApplicationData, recordData);
+ }
+ catch (TlsException ex)
+ {
+ throw ex;
+ }
+ catch (Exception ex)
+ {
+ throw new IOException("IO exception during Write.", ex);
+ }
+ }
+
+ #endregion
+
+ #region TLS_RECORD_METHODS
+
+ private byte[] receiveRecord()
+ {
+ if (this.context.ConnectionEnd)
+ {
+ throw this.context.CreateException("The session is finished and it's no longer valid.");
+ }
+
+ TlsContentType contentType = (TlsContentType)innerStream.ReadByte();
+ SecurityProtocolType protocol = (SecurityProtocolType)this.ReadShort();
+ short length = this.ReadShort();
+
+ // Read Record data
+ int received = 0;
+ byte[] buffer = new byte[length];
+ while (received != length)
+ {
+ received += this.innerStream.Read(
+ buffer, received, buffer.Length - received);
+ }
+
+ TlsStream message = new TlsStream(buffer);
+
+ // Check that the message has a valid protocol version
+ if (protocol != this.context.Protocol)
+ {
+ throw this.context.CreateException("Invalid protocol version on message received from server");
+ }
+
+ // Decrypt message contents if needed
+ if (contentType == TlsContentType.Alert && length == 2)
+ {
+ }
+ else
+ {
+ if (this.context.IsActual &&
+ contentType != TlsContentType.ChangeCipherSpec)
+ {
+ message = this.decryptRecordFragment(
+ contentType,
+ protocol,
+ message.ToArray());
+ }
+ }
+
+ byte[] result = message.ToArray();
+
+ // Process record
+ switch (contentType)
+ {
+ case TlsContentType.Alert:
+ this.processAlert((TlsAlertLevel)message.ReadByte(),
+ (TlsAlertDescription)message.ReadByte());
+ break;
+
+ case TlsContentType.ChangeCipherSpec:
+ // Reset sequence numbers
+ this.context.ReadSequenceNumber = 0;
+ break;
+
+ case TlsContentType.ApplicationData:
+ break;
+
+ case TlsContentType.Handshake:
+ while (!message.EOF)
+ {
+ this.processHandshakeMessage(message);
+ }
+ // Update handshakes of current messages
+ this.context.HandshakeMessages.Write(message.ToArray());
+ break;
+
+ default:
+ throw this.context.CreateException("Unknown record received from server.");
+ }
+
+ return result;
+ }
+
+ #endregion
+
+ #region TLS_SEND_METHODS
+
+ internal void SendAlert(TlsAlert alert)
+ {
+ // Write record
+ this.sendRecord(TlsContentType.Alert, alert.ToArray());
+
+ // Update session
+ alert.UpdateSession();
+
+ // Reset message contents
+ alert.Reset();
+ }
+
+ private void sendRecord(TlsHandshakeType type)
+ {
+ TlsHandshakeMessage msg = createClientHandshakeMessage(type);
+
+ // Write record
+ this.sendRecord(msg.ContentType, msg.EncodeMessage());
+
+ // Update session
+ msg.UpdateSession();
+
+ // Reset message contents
+ msg.Reset();
+ }
+
+ private void sendChangeCipherSpec()
+ {
+ // Send Change Cipher Spec message
+ this.sendRecord(TlsContentType.ChangeCipherSpec, new byte[] {1});
+
+ // Reset sequence numbers
+ this.context.WriteSequenceNumber = 0;
+
+ // Make the pending state to be the current state
+ this.context.IsActual = true;
+
+ // Send Finished message
+ this.sendRecord(TlsHandshakeType.Finished);
+ }
+
+ private void sendRecord(TlsContentType contentType, byte[] recordData)
+ {
+ if (this.context.ConnectionEnd)
+ {
+ throw this.context.CreateException("The session is finished and it's no longer valid.");
+ }
+
+ byte[][] fragments = this.fragmentData(recordData);
+ for (int i = 0; i < fragments.Length; i++)
+ {
+ byte[] fragment = fragments[i];
+
+ if (this.context.IsActual)
+ {
+ // Encrypt fragment
+ fragment = this.encryptRecordFragment(contentType, fragment);
+ }
+
+ // Write tls message
+ TlsStream record = new TlsStream();
+ record.Write((byte)contentType);
+ record.Write((short)this.context.Protocol);
+ record.Write((short)fragment.Length);
+ record.Write(fragment);
+
+ // Write record
+ this.innerStream.Write(record.ToArray(), 0, (int)record.Length);
+
+ // Reset record data
+ record.Reset();
+ }
+ }
+
+ private byte[][] fragmentData(byte[] messageData)
+ {
+ ArrayList d = new ArrayList();
+
+ int position = 0;
+
+ while (position < messageData.Length)
+ {
+ short fragmentLength = 0;
+ byte[] fragmentData;
+ if ((messageData.Length - position) > TlsContext.MAX_FRAGMENT_SIZE)
+ {
+ fragmentLength = TlsContext.MAX_FRAGMENT_SIZE;
+ }
+ else
+ {
+ fragmentLength = (short)(messageData.Length - position);
+ }
+ fragmentData = new byte[fragmentLength];
+
+ System.Array.Copy(messageData, position, fragmentData, 0, fragmentLength);
+
+ d.Add(fragmentData);
+
+ position += fragmentLength;
+ }
+
+ byte[][] result = new byte[d.Count][];
+ for (int i = 0; i < d.Count; i++)
+ {
+ result[i] = (byte[])d[i];
+ }
+
+ return result;
+ }
+
+ #endregion
+
+ #region TLS_CRYPTO_METHODS
+
+ private byte[] encryptRecordFragment(TlsContentType contentType, byte[] fragment)
+ {
+ // Calculate message MAC
+ byte[] mac = this.context.Cipher.ComputeClientRecordMAC(contentType, fragment);
+
+ // Encrypt the message
+ byte[] ecr = this.context.Cipher.EncryptRecord(fragment, mac);
+
+ // Set new IV
+ if (this.context.Cipher.CipherMode == CipherMode.CBC)
+ {
+ byte[] iv = new byte[this.context.Cipher.IvSize];
+ System.Array.Copy(ecr, ecr.Length - iv.Length, iv, 0, iv.Length);
+ this.context.Cipher.UpdateClientCipherIV(iv);
+ }
+
+ // Update sequence number
+ this.context.WriteSequenceNumber++;
+
+ return ecr;
+ }
+
+ private TlsStream decryptRecordFragment(TlsContentType contentType,
+ SecurityProtocolType protocol,
+ byte[] fragment)
+ {
+ byte[] dcrFragment = null;
+ byte[] dcrMAC = null;
+
+ // Decrypt message
+ this.context.Cipher.DecryptRecord(fragment, ref dcrFragment, ref dcrMAC);
+
+ // Set new IV
+ if (this.context.Cipher.CipherMode == CipherMode.CBC)
+ {
+ byte[] iv = new byte[this.context.Cipher.IvSize];
+ System.Array.Copy(fragment, fragment.Length - iv.Length, iv, 0, iv.Length);
+ this.context.Cipher.UpdateServerCipherIV(iv);
+ }
+
+ // Check MAC code
+ byte[] mac = this.context.Cipher.ComputeServerRecordMAC(contentType, dcrFragment);
+
+ // Check that the mac is correct
+ if (mac.Length != dcrMAC.Length)
+ {
+ throw new TlsException("Invalid MAC received from server.");
+ }
+ for (int i = 0; i < mac.Length; i++)
+ {
+ if (mac[i] != dcrMAC[i])
+ {
+ throw new TlsException("Invalid MAC received from server.");
+ }
+ }
+
+ // Update sequence number
+ this.context.ReadSequenceNumber++;
+
+ return new TlsStream(dcrFragment);
+ }
+
+ #endregion
+
+ #region MESSAGE_PROCESSING
+
+ private void processHandshakeMessage(TlsStream handMsg)
+ {
+ TlsHandshakeType handshakeType = (TlsHandshakeType)handMsg.ReadByte();
+ TlsHandshakeMessage message = null;
+
+ // Read message length
+ int length = handMsg.ReadInt24();
+
+ // Read message data
+ byte[] data = new byte[length];
+ handMsg.Read(data, 0, length);
+
+ // Create and process the server message
+ message = this.createServerHandshakeMessage(handshakeType, data);
+
+ // Update session
+ if (message != null)
+ {
+ message.UpdateSession();
+ }
+ }
+
+ private void processAlert(TlsAlertLevel alertLevel, TlsAlertDescription alertDesc)
+ {
+ switch (alertLevel)
+ {
+ case TlsAlertLevel.Fatal:
+ throw this.context.CreateException(alertLevel, alertDesc);
+
+ case TlsAlertLevel.Warning:
+ default:
+ switch (alertDesc)
+ {
+ case TlsAlertDescription.CloseNotify:
+ this.context.ConnectionEnd = true;
+ break;
+
+ default:
+ this.RaiseWarningAlert(alertLevel, alertDesc);
+ break;
+ }
+ break;
+ }
+ }
+
+ #endregion
+
+ #region MISC_METHODS
+
+ private void resetBuffer()
+ {
+ this.inputBuffer.SetLength(0);
+ this.inputBuffer.Position = 0;
+ }
+
+ private short ReadShort()
+ {
+ byte[] b = new byte[2];
+ this.innerStream.Read(b, 0, b.Length);
+
+ short val = BitConverter.ToInt16(b, 0);
+
+ return System.Net.IPAddress.HostToNetworkOrder(val);
+ }
+
+ #endregion
+
+ #region HANDSHAKE_METHODS
+
+ /*
+ Client Server
+
+ ClientHello -------->
+ ServerHello
+ Certificate*
+ ServerKeyExchange*
+ CertificateRequest*
+ <-------- ServerHelloDone
+ Certificate*
+ ClientKeyExchange
+ CertificateVerify*
+ [ChangeCipherSpec]
+ Finished -------->
+ [ChangeCipherSpec]
+ <-------- Finished
+ Application Data <-------> Application Data
+
+ Fig. 1 - Message flow for a full handshake
+ */
+
+ private void doHandshake()
+ {
+ // Obtain supported cipher suite collection
+ this.context.SupportedCiphers = TlsCipherSuiteFactory.GetSupportedCiphers(context.Protocol);
+
+ // Send client hello
+ this.sendRecord(TlsHandshakeType.ClientHello);
+
+ // Read server response
+ while (!this.context.HelloDone)
+ {
+ // Read next record
+ this.receiveRecord();
+ }
+
+ // Send client certificate if requested
+ if (this.context.ServerSettings.CertificateRequest)
+ {
+ this.sendRecord(TlsHandshakeType.Certificate);
+ }
+
+ // Send Client Key Exchange
+ this.sendRecord(TlsHandshakeType.ClientKeyExchange);
+
+ // Now initialize session cipher with the generated keys
+ this.context.Cipher.InitializeCipher();
+
+ // Send certificate verify if requested
+ if (this.context.ServerSettings.CertificateRequest)
+ {
+ this.sendRecord(TlsHandshakeType.CertificateVerify);
+ }
+
+ // Send Cipher Spec protocol
+ this.sendChangeCipherSpec();
+
+ // Read record until server finished is received
+ while (!this.context.HandshakeFinished)
+ {
+ // If all goes well this will process messages:
+ // Change Cipher Spec
+ // Server finished
+ this.receiveRecord();
+ }
+
+ // Clear Key Info
+ this.context.ClearKeyInfo();
+ }
+
+ private TlsHandshakeMessage createClientHandshakeMessage(TlsHandshakeType type)
+ {
+ switch (type)
+ {
+ case TlsHandshakeType.ClientHello:
+ return new TlsClientHello(this.context);
+
+ case TlsHandshakeType.Certificate:
+ return new TlsClientCertificate(this.context);
+
+ case TlsHandshakeType.ClientKeyExchange:
+ return new TlsClientKeyExchange(this.context);
+
+ case TlsHandshakeType.CertificateVerify:
+ return new TlsClientCertificateVerify(this.context);
+
+ case TlsHandshakeType.Finished:
+ return new TlsClientFinished(this.context);
+
+ default:
+ throw new InvalidOperationException("Unknown client handshake message type: " + type.ToString() );
+ }
+ }
+
+ private TlsHandshakeMessage createServerHandshakeMessage(TlsHandshakeType type, byte[] buffer)
+ {
+ switch (type)
+ {
+ case TlsHandshakeType.HelloRequest:
+ this.sendRecord(TlsHandshakeType.ClientHello);
+ return null;
+
+ case TlsHandshakeType.ServerHello:
+ return new TlsServerHello(this.context, buffer);
+
+ case TlsHandshakeType.Certificate:
+ return new TlsServerCertificate(this.context, buffer);
+
+ case TlsHandshakeType.ServerKeyExchange:
+ return new TlsServerKeyExchange(this.context, buffer);
+
+ case TlsHandshakeType.CertificateRequest:
+ return new TlsServerCertificateRequest(this.context, buffer);
+
+ case TlsHandshakeType.ServerHelloDone:
+ return new TlsServerHelloDone(this.context, buffer);
+
+ case TlsHandshakeType.Finished:
+ return new TlsServerFinished(this.context, buffer);
+
+ default:
+ throw this.context.CreateException("Unknown server handshake message received ({0})", type.ToString());
+ }
+ }
+
+ #endregion
+
+ #region EVENT_METHODS
+
+ internal void RaiseWarningAlert(TlsAlertLevel level, TlsAlertDescription description)
+ {
+ if (WarningAlert != null)
+ {
+ WarningAlert(this, new TlsWarningAlertEventArgs(level, description));
+ }
+ }
+
+ internal bool RaiseServerCertificateValidation(
+ X509Certificate certificate, int[] certificateErrors)
+ {
+ if (this.ServerCertValidation != null)
+ {
+ return this.ServerCertValidation(certificate, certificateErrors);
+ }
+
+ return false;
+ }
+
+ internal bool RaiseClientCertificateSelection(
+ X509CertificateCollection clientCertificates,
+ X509Certificate serverCertificate,
+ string targetHost,
+ X509CertificateCollection serverRequestedCertificates)
+ {
+ #warning "Add implementation"
+
+ return true;
+ }
+
+
+ #endregion
+ }
+}
diff --git a/mcs/class/Mono.Security/Mono.Security.Protocol.Tls/TlsCipherSuite.cs b/mcs/class/Mono.Security/Mono.Security.Protocol.Tls/TlsCipherSuite.cs
index 3f88b20aa87..82135585648 100644
--- a/mcs/class/Mono.Security/Mono.Security.Protocol.Tls/TlsCipherSuite.cs
+++ b/mcs/class/Mono.Security/Mono.Security.Protocol.Tls/TlsCipherSuite.cs
@@ -37,13 +37,15 @@ namespace Mono.Security.Protocol.Tls
{
#region CONSTRUCTORS
- public TlsCipherSuite(short code, string name, string algName,
- string hashName, bool exportable, bool blockMode,
- byte keyMaterialSize, byte expandedKeyMaterialSize,
- short effectiveKeyBytes, byte ivSize, byte blockSize)
- : base (code, name, algName, hashName, exportable, blockMode,
- keyMaterialSize, expandedKeyMaterialSize, effectiveKeyBytes,
- ivSize, blockSize)
+ public TlsCipherSuite(
+ short code, string name, CipherAlgorithmType cipherAlgorithmType,
+ HashAlgorithmType hashAlgorithmType, ExchangeAlgorithmType exchangeAlgorithmType,
+ bool exportable, bool blockMode, byte keyMaterialSize,
+ byte expandedKeyMaterialSize, short effectiveKeyBytes,
+ byte ivSize, byte blockSize) :
+ base(code, name, cipherAlgorithmType, hashAlgorithmType,
+ exchangeAlgorithmType, exportable, blockMode, keyMaterialSize,
+ expandedKeyMaterialSize, effectiveKeyBytes, ivSize, blockSize)
{
}
diff --git a/mcs/class/Mono.Security/Mono.Security.Protocol.Tls/TlsCipherSuiteCollection.cs b/mcs/class/Mono.Security/Mono.Security.Protocol.Tls/TlsCipherSuiteCollection.cs
index 9f721f96dad..7613288703b 100644
--- a/mcs/class/Mono.Security/Mono.Security.Protocol.Tls/TlsCipherSuiteCollection.cs
+++ b/mcs/class/Mono.Security/Mono.Security.Protocol.Tls/TlsCipherSuiteCollection.cs
@@ -33,7 +33,7 @@ namespace Mono.Security.Protocol.Tls
{
#region FIELDS
- private TlsProtocol protocol;
+ private SecurityProtocolType protocol;
#endregion
@@ -61,7 +61,7 @@ namespace Mono.Security.Protocol.Tls
#region CONSTRUCTORS
- public TlsCipherSuiteCollection(TlsProtocol protocol) : base()
+ public TlsCipherSuiteCollection(SecurityProtocolType protocol) : base()
{
this.protocol = protocol;
}
@@ -108,17 +108,28 @@ namespace Mono.Security.Protocol.Tls
RemoveAt(IndexOf(errorMessage));
}
- public CipherSuite Add(short code, string name, string algName, string hashName, bool exportable, bool blockMode, byte keyMaterialSize, byte expandedKeyMaterialSize, short effectiveKeyBytes, byte ivSize, byte blockSize)
+ public CipherSuite Add(
+ short code, string name, CipherAlgorithmType cipherType,
+ HashAlgorithmType hashType, ExchangeAlgorithmType exchangeType,
+ bool exportable, bool blockMode, byte keyMaterialSize,
+ byte expandedKeyMaterialSize, short effectiveKeyBytes,
+ byte ivSize, byte blockSize)
{
switch (this.protocol)
{
- case TlsProtocol.Tls1:
+ case SecurityProtocolType.Ssl3:
return this.add(
- new TlsCipherSuite(code, name, algName, hashName, exportable, blockMode, keyMaterialSize, expandedKeyMaterialSize, effectiveKeyBytes, ivSize, blockSize));
+ new TlsSslCipherSuite(
+ code, name, cipherType, hashType, exchangeType, exportable,
+ blockMode, keyMaterialSize, expandedKeyMaterialSize,
+ effectiveKeyBytes, ivSize, blockSize));
- case TlsProtocol.Ssl3:
+ case SecurityProtocolType.Tls:
return this.add(
- new TlsSslCipherSuite(code, name, algName, hashName, exportable, blockMode, keyMaterialSize, expandedKeyMaterialSize, effectiveKeyBytes, ivSize, blockSize));
+ new TlsCipherSuite(
+ code, name, cipherType, hashType, exchangeType, exportable,
+ blockMode, keyMaterialSize, expandedKeyMaterialSize,
+ effectiveKeyBytes, ivSize, blockSize));
default:
throw new NotSupportedException();
diff --git a/mcs/class/Mono.Security/Mono.Security.Protocol.Tls/TlsCipherSuiteFactory.cs b/mcs/class/Mono.Security/Mono.Security.Protocol.Tls/TlsCipherSuiteFactory.cs
index 2fa7313799e..c84aba02fbc 100755
--- a/mcs/class/Mono.Security/Mono.Security.Protocol.Tls/TlsCipherSuiteFactory.cs
+++ b/mcs/class/Mono.Security/Mono.Security.Protocol.Tls/TlsCipherSuiteFactory.cs
@@ -28,16 +28,16 @@ namespace Mono.Security.Protocol.Tls
{
internal class TlsCipherSuiteFactory
{
- public static TlsCipherSuiteCollection GetSupportedCiphers(TlsProtocol protocol)
+ public static TlsCipherSuiteCollection GetSupportedCiphers(SecurityProtocolType protocol)
{
switch (protocol)
{
- case TlsProtocol.Tls1:
- return TlsCipherSuiteFactory.GetTls1SupportedCiphers();
-
- case TlsProtocol.Ssl3:
+ case SecurityProtocolType.Ssl3:
return TlsCipherSuiteFactory.GetSsl3SupportedCiphers();
+ case SecurityProtocolType.Tls:
+ return TlsCipherSuiteFactory.GetTls1SupportedCiphers();
+
default:
throw new NotSupportedException();
}
@@ -47,123 +47,122 @@ namespace Mono.Security.Protocol.Tls
private static TlsCipherSuiteCollection GetTls1SupportedCiphers()
{
- TlsCipherSuiteCollection scs = new TlsCipherSuiteCollection(TlsProtocol.Tls1);
-
- // Supported ciphers
- // scs.Add((0x00 << 0x08) | 0x06, "TLS_RSA_EXPORT_WITH_RC2_CBC_40_MD5", "RC2", "MD5", true, true, 5, 16, 40, 8, 8);
- scs.Add((0x00 << 0x08) | 0x35, "TLS_RSA_WITH_AES_256_CBC_SHA", "Rijndael", "SHA1", false, true, 32, 32, 256, 16, 16);
- scs.Add((0x00 << 0x08) | 0x2F, "TLS_RSA_WITH_AES_128_CBC_SHA", "Rijndael", "SHA1", false, true, 16, 16, 128, 16, 16);
- scs.Add((0x00 << 0x08) | 0x0A, "TLS_RSA_WITH_3DES_EDE_CBC_SHA", "3DES", "SHA1", false, true, 24, 24, 168, 8, 8);
- scs.Add((0x00 << 0x08) | 0x09, "TLS_RSA_WITH_DES_CBC_SHA", "DES", "SHA1", false, true, 8, 8, 56, 8, 8);
- scs.Add((0x00 << 0x08) | 0x05, "TLS_RSA_WITH_RC4_128_SHA", "RC4", "SHA1", false, false, 16, 16, 128, 0, 0);
- scs.Add((0x00 << 0x08) | 0x04, "TLS_RSA_WITH_RC4_128_MD5", "RC4", "MD5", false, false, 16, 16, 128, 0, 0);
+ TlsCipherSuiteCollection scs = new TlsCipherSuiteCollection(SecurityProtocolType.Tls);
+
+ // Supported ciphers
+ scs.Add((0x00 << 0x08) | 0x35, "TLS_RSA_WITH_AES_256_CBC_SHA", CipherAlgorithmType.Rijndael, HashAlgorithmType.Sha1, ExchangeAlgorithmType.RsaSign, false, true, 32, 32, 256, 16, 16);
+ scs.Add((0x00 << 0x08) | 0x2F, "TLS_RSA_WITH_AES_128_CBC_SHA", CipherAlgorithmType.Rijndael, HashAlgorithmType.Sha1, ExchangeAlgorithmType.RsaSign, false, true, 16, 16, 128, 16, 16);
+ scs.Add((0x00 << 0x08) | 0x0A, "TLS_RSA_WITH_3DES_EDE_CBC_SHA", CipherAlgorithmType.TripleDes, HashAlgorithmType.Sha1, ExchangeAlgorithmType.RsaSign, false, true, 24, 24, 168, 8, 8);
+ scs.Add((0x00 << 0x08) | 0x09, "TLS_RSA_WITH_DES_CBC_SHA", CipherAlgorithmType.Des, HashAlgorithmType.Sha1, ExchangeAlgorithmType.RsaSign, false, true, 8, 8, 56, 8, 8);
+ scs.Add((0x00 << 0x08) | 0x05, "TLS_RSA_WITH_RC4_128_SHA", CipherAlgorithmType.Rc4, HashAlgorithmType.Sha1, ExchangeAlgorithmType.RsaSign, false, false, 16, 16, 128, 0, 0);
+ scs.Add((0x00 << 0x08) | 0x04, "TLS_RSA_WITH_RC4_128_MD5", CipherAlgorithmType.Rc4, HashAlgorithmType.Md5, ExchangeAlgorithmType.RsaSign, false, false, 16, 16, 128, 0, 0);
// Default CipherSuite
- // scs.Add(0, "TLS_NULL_WITH_NULL_NULL", "", "", true, false, 0, 0, 0, 0, 0);
+ // scs.Add(0, "TLS_NULL_WITH_NULL_NULL", CipherAlgorithmType.None, HashAlgorithmType.None, ExchangeAlgorithmType.None, true, false, 0, 0, 0, 0, 0);
// RSA Cipher Suites
- // scs.Add((0x00 << 0x08) | 0x01, "TLS_RSA_WITH_NULL_MD5", "", "MD5", true, false, 0, 0, 0, 0, 0);
- // scs.Add((0x00 << 0x08) | 0x02, "TLS_RSA_WITH_NULL_SHA", "", "SHA1", true, false, 0, 0, 0, 0, 0);
- // scs.Add((0x00 << 0x08) | 0x03, "TLS_RSA_EXPORT_WITH_RC4_40_MD5", "RC4", "MD5", true, false, 5, 16, 40, 0, 0);
- // scs.Add((0x00 << 0x08) | 0x05, "TLS_RSA_WITH_RC4_128_SHA", "RC4", "SHA1", false, false, 16, 16, 128, 0, 0);
- // scs.Add((0x00 << 0x08) | 0x04, "TLS_RSA_WITH_RC4_128_MD5", "RC4", "MD5", false, false, 16, 16, 128, 0, 0);
- // scs.Add((0x00 << 0x08) | 0x06, "TLS_RSA_EXPORT_WITH_RC2_CBC_40_MD5", "RC2", "MD5", true, true, 5, 16, 40, 8, 8);
- // scs.Add((0x00 << 0x08) | 0x07, "TLS_RSA_WITH_IDEA_CBC_SHA", "IDEA", "SHA1", false, true, 16, 16, 128, 8, 8);
- // scs.Add((0x00 << 0x08) | 0x08, "TLS_RSA_EXPORT_WITH_DES40_CBC_SHA", "DES", "SHA1", true, true, 5, 8, 40, 8, 8);
- // scs.Add((0x00 << 0x08) | 0x09, "TLS_RSA_WITH_DES_CBC_SHA", "DES", "SHA1", false, true, 8, 8, 56, 8, 8);
- // scs.Add((0x00 << 0x08) | 0x0A, "TLS_RSA_WITH_3DES_EDE_CBC_SHA", "3DES", "SHA1", false, true, 24, 24, 168, 8, 8);
-
+ // scs.Add((0x00 << 0x08) | 0x01, "TLS_RSA_WITH_NULL_MD5", CipherAlgorithmType.None, HashAlgorithmType.Md5, ExchangeAlgorithmType.None, true, false, 0, 0, 0, 0, 0);
+ // scs.Add((0x00 << 0x08) | 0x02, "TLS_RSA_WITH_NULL_SHA", CipherAlgorithmType.None, HashAlgorithmType.Sha1, ExchangeAlgorithmType.None, true, false, 0, 0, 0, 0, 0);
+ // scs.Add((0x00 << 0x08) | 0x03, "TLS_RSA_EXPORT_WITH_RC4_40_MD5", CipherAlgorithmType.Rc4, HashAlgorithmType.Md5, ExchangeAlgorithmType.RsaSignKeyX, true, false, 5, 16, 40, 0, 0);
+ // scs.Add((0x00 << 0x08) | 0x05, "TLS_RSA_WITH_RC4_128_SHA", CipherAlgorithmType.Rc4, HashAlgorithmType.Sha1, ExchangeAlgorithmType.RsaSign, false, false, 16, 16, 128, 0, 0);
+ // scs.Add((0x00 << 0x08) | 0x04, "TLS_RSA_WITH_RC4_128_MD5", CipherAlgorithmType.Rc4, HashAlgorithmType.Md5, ExchangeAlgorithmType.RsaSign, false, false, 16, 16, 128, 0, 0);
+ // scs.Add((0x00 << 0x08) | 0x06, "TLS_RSA_EXPORT_WITH_RC2_CBC_40_MD5", CipherAlgorithmType.Rc2, HashAlgorithmType.Md5, ExchangeAlgorithmType.RsaKeyX, true, true, 5, 16, 40, 8, 8);
+ // scs.Add((0x00 << 0x08) | 0x07, "TLS_RSA_WITH_IDEA_CBC_SHA", "IDEA", HashAlgorithmType.Sha1, ExchangeAlgorithmType.RsaSign, false, true, 16, 16, 128, 8, 8);
+ // scs.Add((0x00 << 0x08) | 0x08, "TLS_RSA_EXPORT_WITH_DES40_CBC_SHA", CipherAlgorithmType.Des, HashAlgorithmType.Sha1, ExchangeAlgorithmType.RsaKeyX, true, true, 5, 8, 40, 8, 8);
+ // scs.Add((0x00 << 0x08) | 0x09, "TLS_RSA_WITH_DES_CBC_SHA", CipherAlgorithmType.Des, HashAlgorithmType.Sha1, ExchangeAlgorithmType.RsaSign, false, true, 8, 8, 56, 8, 8);
+ // scs.Add((0x00 << 0x08) | 0x0A, "TLS_RSA_WITH_3DES_EDE_CBC_SHA", CipherAlgorithmType.TripleDes, HashAlgorithmType.Sha1, ExchangeAlgorithmType.RsaSign, false, true, 24, 24, 168, 8, 8);
+
// Diffie-Hellman Cipher Suites
- // scs.Add((0x00 << 0x08) | 0x0B, "TLS_DH_DSS_EXPORT_WITH_DES40_CBC_SHA", "DES", "SHA1", true, true, 5, 8, 40, 8, 8);
- // scs.Add((0x00 << 0x08) | 0x0C, "TLS_DH_DSS_WITH_DES_CBC_SHA", "DES", "SHA1", false, true, 8, 8, 56, 8, 8);
- // scs.Add((0x00 << 0x08) | 0x0D, "TLS_DH_DSS_WITH_3DES_EDE_CBC_SHA", "3DES", "SHA1", false, true, 24, 24, 168, 8, 8);
- // scs.Add((0x00 << 0x08) | 0x0E, "TLS_DH_RSA_EXPORT_WITH_DES40_CBC_SHA", "DES", "SHA1", true, true, 5, 8, 40, 8, 8);
- // scs.Add((0x00 << 0x08) | 0x0F, "TLS_DH_RSA_WITH_DES_CBC_SHA", "DES", "SHA1", false, true, 8, 8, 56, 8, 8);
- // scs.Add((0x00 << 0x08) | 0x10, "TLS_DH_RSA_WITH_3DES_EDE_CBC_SHA", "3DES", "SHA1", false, true, 24, 24, 168, 8, 8);
- // scs.Add((0x00 << 0x08) | 0x11, "TLS_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA", "DES", "SHA1", true, true, 5, 8, 40, 8, 8);
- // scs.Add((0x00 << 0x08) | 0x12, "TLS_DHE_DSS_WITH_DES_CBC_SHA", "DES", "SHA1", false, true, 8, 8, 56, 8, 8);
- // scs.Add((0x00 << 0x08) | 0x13, "TLS_DHE_DSS_WITH_3DES_EDE_CBC_SHA", "3DES", "SHA1", false, true, 24, 24, 168, 8, 8);
- // scs.Add((0x00 << 0x08) | 0x14, "TLS_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA", "DES", "SHA1", true, true, 5, 8, 40, 8, 8);
- // scs.Add((0x00 << 0x08) | 0x15, "TLS_DHE_RSA_WITH_DES_CBC_SHA", "SHA1", "DES", false, true, 8, 8, 56, 8, 8);
- // scs.Add((0x00 << 0x08) | 0x16, "TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA", "3DES", "SHA1", false, true, 24, 24, 168, 8, 8);
+ // scs.Add((0x00 << 0x08) | 0x0B, "TLS_DH_DSS_EXPORT_WITH_DES40_CBC_SHA", CipherAlgorithmType.Des, HashAlgorithmType.Sha1, ExchangeAlgorithmType.DiffieHellman, true, true, 5, 8, 40, 8, 8);
+ // scs.Add((0x00 << 0x08) | 0x0C, "TLS_DH_DSS_WITH_DES_CBC_SHA", CipherAlgorithmType.Des, HashAlgorithmType.Sha1, false, ExchangeAlgorithmType.DiffieHellman, true, 8, 8, 56, 8, 8);
+ // scs.Add((0x00 << 0x08) | 0x0D, "TLS_DH_DSS_WITH_3DES_EDE_CBC_SHA", CipherAlgorithmType.TripleDes, HashAlgorithmType.Sha1, ExchangeAlgorithmType.DiffieHellman, false, true, 24, 24, 168, 8, 8);
+ // scs.Add((0x00 << 0x08) | 0x0E, "TLS_DH_RSA_EXPORT_WITH_DES40_CBC_SHA", CipherAlgorithmType.Des, HashAlgorithmType.Sha1, ExchangeAlgorithmType.DiffieHellman, true, true, 5, 8, 40, 8, 8);
+ // scs.Add((0x00 << 0x08) | 0x0F, "TLS_DH_RSA_WITH_DES_CBC_SHA", CipherAlgorithmType.Des, HashAlgorithmType.Sha1, false, ExchangeAlgorithmType.DiffieHellman, true, 8, 8, 56, 8, 8);
+ // scs.Add((0x00 << 0x08) | 0x10, "TLS_DH_RSA_WITH_3DES_EDE_CBC_SHA", CipherAlgorithmType.TripleDes, HashAlgorithmType.Sha1, ExchangeAlgorithmType.DiffieHellman, false, true, 24, 24, 168, 8, 8);
+ // scs.Add((0x00 << 0x08) | 0x11, "TLS_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA", CipherAlgorithmType.Des, HashAlgorithmType.Sha1, ExchangeAlgorithmType.DiffieHellman, true, true, 5, 8, 40, 8, 8);
+ // scs.Add((0x00 << 0x08) | 0x12, "TLS_DHE_DSS_WITH_DES_CBC_SHA", CipherAlgorithmType.Des, HashAlgorithmType.Sha1, ExchangeAlgorithmType.DiffieHellman, false, true, 8, 8, 56, 8, 8);
+ // scs.Add((0x00 << 0x08) | 0x13, "TLS_DHE_DSS_WITH_3DES_EDE_CBC_SHA", CipherAlgorithmType.TripleDes, HashAlgorithmType.Sha1, ExchangeAlgorithmType.DiffieHellman, false, true, 24, 24, 168, 8, 8);
+ // scs.Add((0x00 << 0x08) | 0x14, "TLS_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA", CipherAlgorithmType.Des, HashAlgorithmType.Sha1, ExchangeAlgorithmType.DiffieHellman, true, true, 5, 8, 40, 8, 8);
+ // scs.Add((0x00 << 0x08) | 0x15, "TLS_DHE_RSA_WITH_DES_CBC_SHA", HashAlgorithmType.Sha1, CipherAlgorithmType.Des, false, ExchangeAlgorithmType.DiffieHellman, true, 8, 8, 56, 8, 8);
+ // scs.Add((0x00 << 0x08) | 0x16, "TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA", CipherAlgorithmType.TripleDes, HashAlgorithmType.Sha1, ExchangeAlgorithmType.DiffieHellman, false, true, 24, 24, 168, 8, 8);
// Anonymous Diffie-Hellman Cipher Suites
- // scs.Add((0x00 << 0x08) | 0x17, "TLS_DH_anon_EXPORT_WITH_RC4_40_MD5", "RC4", "MD5", true, false, 5, 16, 40, 0, 0);
- // scs.Add((0x00 << 0x08) | 0x18, "TLS_DH_anon_WITH_RC4_128_MD5", "RC4", "MD5", false, false, 16, 16, 128, 0, 0);
- // scs.Add((0x00 << 0x08) | 0x19, "TLS_DH_anon_EXPORT_WITH_DES40_CBC_SHA", "DES", "SHA1", false, true, 5, 8, 40, 8, 8);
- // scs.Add((0x00 << 0x08) | 0x1A, "TLS_DH_anon_WITH_DES_CBC_SHA", "DES4", "SHA1", false, true, 8, 8, 56, 8, 8);
- // scs.Add((0x00 << 0x08) | 0x1B, "TLS_DH_anon_WITH_3DES_EDE_CBC_SHA", "3DES", "SHA1", false, true, 24, 24, 168, 8, 8);
+ // scs.Add((0x00 << 0x08) | 0x17, "TLS_DH_anon_EXPORT_WITH_RC4_40_MD5", CipherAlgorithmType.Rc4, HashAlgorithmType.Md5, ExchangeAlgorithmType.DiffieHellman, true, false, 5, 16, 40, 0, 0);
+ // scs.Add((0x00 << 0x08) | 0x18, "TLS_DH_anon_WITH_RC4_128_MD5", CipherAlgorithmType.Rc4, HashAlgorithmType.Md5, false, ExchangeAlgorithmType.DiffieHellman, false, 16, 16, 128, 0, 0);
+ // scs.Add((0x00 << 0x08) | 0x19, "TLS_DH_anon_EXPORT_WITH_DES40_CBC_SHA", CipherAlgorithmType.Des, HashAlgorithmType.Sha1, ExchangeAlgorithmType.DiffieHellman, false, true, 5, 8, 40, 8, 8);
+ // scs.Add((0x00 << 0x08) | 0x1A, "TLS_DH_anon_WITH_DES_CBC_SHA", "DES4", HashAlgorithmType.Sha1, ExchangeAlgorithmType.DiffieHellman, false, true, 8, 8, 56, 8, 8);
+ // scs.Add((0x00 << 0x08) | 0x1B, "TLS_DH_anon_WITH_3DES_EDE_CBC_SHA", CipherAlgorithmType.TripleDes, HashAlgorithmType.Sha1, ExchangeAlgorithmType.DiffieHellman, false, true, 24, 24, 168, 8, 8);
// AES CipherSuites
//
// Ref: RFC3268 - (http://www.ietf.org/rfc/rfc3268.txt)
- // scs.Add((0x00 << 0x08) | 0x2F, "TLS_RSA_WITH_AES_128_CBC_SHA", "Rijndael", "SHA1", false, true, 16, 16, 128, 16, 16);
- // scs.Add((0x00 << 0x08) | 0x30, "TLS_DH_DSS_WITH_AES_128_CBC_SHA", "Rijndael", "SHA1", false, true, 16, 16, 128, 8, 8);
- // scs.Add((0x00 << 0x08) | 0x31, "TLS_DH_RSA_WITH_AES_128_CBC_SHA", "Rijndael", "SHA1", false, true, 16, 16, 128, 8, 8);
- // scs.Add((0x00 << 0x08) | 0x32, "TLS_DHE_DSS_WITH_AES_128_CBC_SHA", "Rijndael", "SHA1", false, true, 16, 16, 128, 8, 8);
- // scs.Add((0x00 << 0x08) | 0x33, "TLS_DHE_RSA_WITH_AES_128_CBC_SHA", "Rijndael", "SHA1", false, true, 16, 16, 128, 8, 8);
- // scs.Add((0x00 << 0x08) | 0x34, "TLS_DH_anon_WITH_AES_128_CBC_SHA", "Rijndael", "SHA1", false, true, 16, 16, 128, 8, 8);
-
- // scs.Add((0x00 << 0x08) | 0x35, "TLS_RSA_WITH_AES_256_CBC_SHA", "Rijndael", "SHA1", false, true, 32, 32, 256, 16, 16);
- // scs.Add((0x00 << 0x08) | 0x36, "TLS_DH_DSS_WITH_AES_256_CBC_SHA", "Rijndael", "SHA1", false, true, 32, 32, 256, 16, 16);
- // scs.Add((0x00 << 0x08) | 0x37, "TLS_DH_RSA_WITH_AES_256_CBC_SHA", "Rijndael", "SHA1", false, true, 32, 32, 256, 16, 16);
- // scs.Add((0x00 << 0x08) | 0x38, "TLS_DHE_DSS_WITH_AES_256_CBC_SHA", "Rijndael", "SHA1", false, true, 32, 32, 256, 16, 16);
- // scs.Add((0x00 << 0x08) | 0x39, "TLS_DHE_RSA_WITH_AES_256_CBC_SHA", "Rijndael", "SHA1", false, true, 32, 32, 256, 16, 16);
- // scs.Add((0x00 << 0x08) | 0x3A, "TLS_DH_anon_WITH_AES_256_CBC_SHA", "Rijndael", "SHA1", false, true, 32, 32, 256, 16, 16);
+ // scs.Add((0x00 << 0x08) | 0x2F, "TLS_RSA_WITH_AES_128_CBC_SHA", CipherAlgorithmType.Rijndael, HashAlgorithmType.Sha1, ExchangeAlgorithmType.RsaSign, false, true, 16, 16, 128, 16, 16);
+ // scs.Add((0x00 << 0x08) | 0x30, "TLS_DH_DSS_WITH_AES_128_CBC_SHA", CipherAlgorithmType.Rijndael, HashAlgorithmType.Sha1, ExchangeAlgorithmType.DiffieHellman, false, true, 16, 16, 128, 8, 8);
+ // scs.Add((0x00 << 0x08) | 0x31, "TLS_DH_RSA_WITH_AES_128_CBC_SHA", CipherAlgorithmType.Rijndael, HashAlgorithmType.Sha1, ExchangeAlgorithmType.DiffieHellman, false, true, 16, 16, 128, 8, 8);
+ // scs.Add((0x00 << 0x08) | 0x32, "TLS_DHE_DSS_WITH_AES_128_CBC_SHA", CipherAlgorithmType.Rijndael, HashAlgorithmType.Sha1, ExchangeAlgorithmType.DiffieHellman, false, true, 16, 16, 128, 8, 8);
+ // scs.Add((0x00 << 0x08) | 0x33, "TLS_DHE_RSA_WITH_AES_128_CBC_SHA", CipherAlgorithmType.Rijndael, HashAlgorithmType.Sha1, ExchangeAlgorithmType.DiffieHellman, false, true, 16, 16, 128, 8, 8);
+ // scs.Add((0x00 << 0x08) | 0x34, "TLS_DH_anon_WITH_AES_128_CBC_SHA", CipherAlgorithmType.Rijndael, HashAlgorithmType.Sha1, ExchangeAlgorithmType.DiffieHellman, false, true, 16, 16, 128, 8, 8);
+
+ // scs.Add((0x00 << 0x08) | 0x35, "TLS_RSA_WITH_AES_256_CBC_SHA", CipherAlgorithmType.Rijndael, HashAlgorithmType.Sha1, ExchangeAlgorithmType.RsaSign, false, true, 32, 32, 256, 16, 16);
+ // scs.Add((0x00 << 0x08) | 0x36, "TLS_DH_DSS_WITH_AES_256_CBC_SHA", CipherAlgorithmType.Rijndael, HashAlgorithmType.Sha1, ExchangeAlgorithmType.DiffieHellman, false, true, 32, 32, 256, 16, 16);
+ // scs.Add((0x00 << 0x08) | 0x37, "TLS_DH_RSA_WITH_AES_256_CBC_SHA", CipherAlgorithmType.Rijndael, HashAlgorithmType.Sha1, ExchangeAlgorithmType.DiffieHellman, false, true, 32, 32, 256, 16, 16);
+ // scs.Add((0x00 << 0x08) | 0x38, "TLS_DHE_DSS_WITH_AES_256_CBC_SHA", CipherAlgorithmType.Rijndael, HashAlgorithmType.Sha1, ExchangeAlgorithmType.DiffieHellman, false, true, 32, 32, 256, 16, 16);
+ // scs.Add((0x00 << 0x08) | 0x39, "TLS_DHE_RSA_WITH_AES_256_CBC_SHA", CipherAlgorithmType.Rijndael, HashAlgorithmType.Sha1, ExchangeAlgorithmType.DiffieHellman, false, true, 32, 32, 256, 16, 16);
+ // scs.Add((0x00 << 0x08) | 0x3A, "TLS_DH_anon_WITH_AES_256_CBC_SHA", CipherAlgorithmType.Rijndael, HashAlgorithmType.Sha1, ExchangeAlgorithmType.DiffieHellman, false, true, 32, 32, 256, 16, 16);
return scs;
}
private static TlsCipherSuiteCollection GetSsl3SupportedCiphers()
{
- TlsCipherSuiteCollection scs = new TlsCipherSuiteCollection(TlsProtocol.Ssl3);
+ TlsCipherSuiteCollection scs = new TlsCipherSuiteCollection(SecurityProtocolType.Ssl3);
// Supported ciphers
- scs.Add((0x00 << 0x08) | 0x0A, "SSL_RSA_WITH_3DES_EDE_CBC_SHA", "3DES", "SHA1", false, true, 24, 24, 168, 8, 8);
- scs.Add((0x00 << 0x08) | 0x09, "SSL_RSA_WITH_DES_CBC_SHA", "DES", "SHA1", false, true, 8, 8, 56, 8, 8);
- scs.Add((0x00 << 0x08) | 0x05, "SSL_RSA_WITH_RC4_128_SHA", "RC4", "SHA1", false, false, 16, 16, 128, 0, 0);
- scs.Add((0x00 << 0x08) | 0x04, "SSL_RSA_WITH_RC4_128_MD5", "RC4", "MD5", false, false, 16, 16, 128, 0, 0);
+ scs.Add((0x00 << 0x08) | 0x0A, "SSL_RSA_WITH_3DES_EDE_CBC_SHA", CipherAlgorithmType.TripleDes, HashAlgorithmType.Sha1, ExchangeAlgorithmType.RsaSign, false, true, 24, 24, 168, 8, 8);
+ scs.Add((0x00 << 0x08) | 0x09, "SSL_RSA_WITH_DES_CBC_SHA", CipherAlgorithmType.Des, HashAlgorithmType.Sha1, ExchangeAlgorithmType.RsaSign, false, true, 8, 8, 56, 8, 8);
+ scs.Add((0x00 << 0x08) | 0x05, "SSL_RSA_WITH_RC4_128_SHA", CipherAlgorithmType.Rc4, HashAlgorithmType.Sha1, ExchangeAlgorithmType.RsaSign, false, false, 16, 16, 128, 0, 0);
+ scs.Add((0x00 << 0x08) | 0x04, "SSL_RSA_WITH_RC4_128_MD5", CipherAlgorithmType.Rc4, HashAlgorithmType.Md5, ExchangeAlgorithmType.RsaSign, false, false, 16, 16, 128, 0, 0);
// Default CipherSuite
- // scs.Add(0, "SSL_NULL_WITH_NULL_NULL", "", "", true, false, 0, 0, 0, 0, 0);
+ // scs.Add(0, "SSL_NULL_WITH_NULL_NULL", CipherAlgorithmType.None, HashAlgorithmType.None, true, false, 0, 0, 0, 0, 0);
// RSA Cipher Suites
- // scs.Add((0x00 << 0x08) | 0x01, "SSL_RSA_WITH_NULL_MD5", "", "MD5", true, false, 0, 0, 0, 0, 0);
- // scs.Add((0x00 << 0x08) | 0x02, "SSL_RSA_WITH_NULL_SHA", "", "SHA1", true, false, 0, 0, 0, 0, 0);
- // scs.Add((0x00 << 0x08) | 0x03, "SSL_RSA_EXPORT_WITH_RC4_40_MD5", "RC4", "MD5", true, false, 5, 16, 40, 0, 0);
- // scs.Add((0x00 << 0x08) | 0x05, "SSL_RSA_WITH_RC4_128_SHA", "RC4", "SHA1", false, false, 16, 16, 128, 0, 0);
- // scs.Add((0x00 << 0x08) | 0x04, "SSL_RSA_WITH_RC4_128_MD5", "RC4", "MD5", false, false, 16, 16, 128, 0, 0);
- // scs.Add((0x00 << 0x08) | 0x06, "SSL_RSA_EXPORT_WITH_RC2_CBC_40_MD5", "RC2", "MD5", true, true, 5, 16, 40, 8, 8);
- // scs.Add((0x00 << 0x08) | 0x07, "SSL_RSA_WITH_IDEA_CBC_SHA", "IDEA", "SHA1", false, true, 16, 16, 128, 8, 8);
- // scs.Add((0x00 << 0x08) | 0x08, "SSL_RSA_EXPORT_WITH_DES40_CBC_SHA", "DES", "SHA1", true, true, 5, 8, 40, 8, 8);
- // scs.Add((0x00 << 0x08) | 0x09, "SSL_RSA_WITH_DES_CBC_SHA", "DES", "SHA1", false, true, 8, 8, 56, 8, 8);
- // scs.Add((0x00 << 0x08) | 0x0A, "SSL_RSA_WITH_3DES_EDE_CBC_SHA", "3DES", "SHA1", false, true, 24, 24, 168, 8, 8);
-
+ // scs.Add((0x00 << 0x08) | 0x01, "SSL_RSA_WITH_NULL_MD5", CipherAlgorithmType.None, HashAlgorithmType.Md5, ExchangeAlgorithmType.None, true, false, 0, 0, 0, 0, 0);
+ // scs.Add((0x00 << 0x08) | 0x02, "SSL_RSA_WITH_NULL_SHA", CipherAlgorithmType.None, HashAlgorithmType.Sha1, true, ExchangeAlgorithmType.None, false, 0, 0, 0, 0, 0);
+ // scs.Add((0x00 << 0x08) | 0x03, "SSL_RSA_EXPORT_WITH_RC4_40_MD5", CipherAlgorithmType.Rc4, HashAlgorithmType.Md5, ExchangeAlgorithmType.RsaKeyX, true, false, 5, 16, 40, 0, 0);
+ // scs.Add((0x00 << 0x08) | 0x05, "SSL_RSA_WITH_RC4_128_SHA", CipherAlgorithmType.Rc4, HashAlgorithmType.Sha1, ExchangeAlgorithmType.RsaSign, false, false, 16, 16, 128, 0, 0);
+ // scs.Add((0x00 << 0x08) | 0x04, "SSL_RSA_WITH_RC4_128_MD5", CipherAlgorithmType.Rc4, HashAlgorithmType.Md5, ExchangeAlgorithmType.RsaSign, false, false, 16, 16, 128, 0, 0);
+ // scs.Add((0x00 << 0x08) | 0x06, "SSL_RSA_EXPORT_WITH_RC2_CBC_40_MD5", CipherAlgorithmType.Rc2, HashAlgorithmType.Md5, ExchangeAlgorithmType.RsaKeyX, true, true, 5, 16, 40, 8, 8);
+ // scs.Add((0x00 << 0x08) | 0x07, "SSL_RSA_WITH_IDEA_CBC_SHA", "IDEA", HashAlgorithmType.Sha1, ExchangeAlgorithmType.RsaSign, false, true, 16, 16, 128, 8, 8);
+ // scs.Add((0x00 << 0x08) | 0x08, "SSL_RSA_EXPORT_WITH_DES40_CBC_SHA", CipherAlgorithmType.Des, HashAlgorithmType.Sha1, ExchangeAlgorithmType.RsaKeyEx, true, true, 5, 8, 40, 8, 8);
+ // scs.Add((0x00 << 0x08) | 0x09, "SSL_RSA_WITH_DES_CBC_SHA", CipherAlgorithmType.Des, HashAlgorithmType.Sha1, ExchangeAlgorithmType.RsaSign, false, true, 8, 8, 56, 8, 8);
+ // scs.Add((0x00 << 0x08) | 0x0A, "SSL_RSA_WITH_3DES_EDE_CBC_SHA", CipherAlgorithmType.TripleDes, HashAlgorithmType.Sha1, ExchangeAlgorithmType.RsaSign, false, true, 24, 24, 168, 8, 8);
+
// Diffie-Hellman Cipher Suites
- // scs.Add((0x00 << 0x08) | 0x0B, "SSL_DH_DSS_EXPORT_WITH_DES40_CBC_SHA", "DES", "SHA1", true, true, 5, 8, 40, 8, 8);
- // scs.Add((0x00 << 0x08) | 0x0C, "SSL_DH_DSS_WITH_DES_CBC_SHA", "DES", "SHA1", false, true, 8, 8, 56, 8, 8);
- // scs.Add((0x00 << 0x08) | 0x0D, "SSL_DH_DSS_WITH_3DES_EDE_CBC_SHA", "3DES", "SHA1", false, true, 24, 24, 168, 8, 8);
- // scs.Add((0x00 << 0x08) | 0x0E, "SSL_DH_RSA_EXPORT_WITH_DES40_CBC_SHA", "DES", "SHA1", true, true, 5, 8, 40, 8, 8);
- // scs.Add((0x00 << 0x08) | 0x0F, "SSL_DH_RSA_WITH_DES_CBC_SHA", "DES", "SHA1", false, true, 8, 8, 56, 8, 8);
- // scs.Add((0x00 << 0x08) | 0x10, "SSL_DH_RSA_WITH_3DES_EDE_CBC_SHA", "3DES", "SHA1", false, true, 24, 24, 168, 8, 8);
- // scs.Add((0x00 << 0x08) | 0x11, "SSL_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA", "DES", "SHA1", true, true, 5, 8, 40, 8, 8);
- // scs.Add((0x00 << 0x08) | 0x12, "SSL_DHE_DSS_WITH_DES_CBC_SHA", "DES", "SHA1", false, true, 8, 8, 56, 8, 8);
- // scs.Add((0x00 << 0x08) | 0x13, "SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA", "3DES", "SHA1", false, true, 24, 24, 168, 8, 8);
- // scs.Add((0x00 << 0x08) | 0x14, "SSL_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA", "DES", "SHA1", true, true, 5, 8, 40, 8, 8);
- // scs.Add((0x00 << 0x08) | 0x15, "SSL_DHE_RSA_WITH_DES_CBC_SHA", "SHA1", "DES", false, true, 8, 8, 56, 8, 8);
- // scs.Add((0x00 << 0x08) | 0x16, "SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA", "3DES", "SHA1", false, true, 24, 24, 168, 8, 8);
+ // scs.Add((0x00 << 0x08) | 0x0B, "SSL_DH_DSS_EXPORT_WITH_DES40_CBC_SHA", CipherAlgorithmType.Des, HashAlgorithmType.Sha1, ExchangeAlgorithmType.DiffieHellman, true, true, 5, 8, 40, 8, 8);
+ // scs.Add((0x00 << 0x08) | 0x0C, "SSL_DH_DSS_WITH_DES_CBC_SHA", CipherAlgorithmType.Des, HashAlgorithmType.Sha1, ExchangeAlgorithmType.DiffieHellman, false, true, 8, 8, 56, 8, 8);
+ // scs.Add((0x00 << 0x08) | 0x0D, "SSL_DH_DSS_WITH_3DES_EDE_CBC_SHA", CipherAlgorithmType.TripleDes, HashAlgorithmType.Sha1, ExchangeAlgorithmType.DiffieHellman, false, true, 24, 24, 168, 8, 8);
+ // scs.Add((0x00 << 0x08) | 0x0E, "SSL_DH_RSA_EXPORT_WITH_DES40_CBC_SHA", CipherAlgorithmType.Des, HashAlgorithmType.Sha1, ExchangeAlgorithmType.DiffieHellman, true, true, 5, 8, 40, 8, 8);
+ // scs.Add((0x00 << 0x08) | 0x0F, "SSL_DH_RSA_WITH_DES_CBC_SHA", CipherAlgorithmType.Des, HashAlgorithmType.Sha1, ExchangeAlgorithmType.DiffieHellman, false, true, 8, 8, 56, 8, 8);
+ // scs.Add((0x00 << 0x08) | 0x10, "SSL_DH_RSA_WITH_3DES_EDE_CBC_SHA", CipherAlgorithmType.TripleDes, HashAlgorithmType.Sha1, ExchangeAlgorithmType.DiffieHellman, false, true, 24, 24, 168, 8, 8);
+ // scs.Add((0x00 << 0x08) | 0x11, "SSL_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA", CipherAlgorithmType.Des, HashAlgorithmType.Sha1, ExchangeAlgorithmType.DiffieHellman, true, true, 5, 8, 40, 8, 8);
+ // scs.Add((0x00 << 0x08) | 0x12, "SSL_DHE_DSS_WITH_DES_CBC_SHA", CipherAlgorithmType.Des, HashAlgorithmType.Sha1, ExchangeAlgorithmType.DiffieHellman, false, true, 8, 8, 56, 8, 8);
+ // scs.Add((0x00 << 0x08) | 0x13, "SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA", CipherAlgorithmType.TripleDes, HashAlgorithmType.Sha1, ExchangeAlgorithmType.DiffieHellman, false, true, 24, 24, 168, 8, 8);
+ // scs.Add((0x00 << 0x08) | 0x14, "SSL_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA", CipherAlgorithmType.Des, HashAlgorithmType.Sha1, ExchangeAlgorithmType.DiffieHellman, true, true, 5, 8, 40, 8, 8);
+ // scs.Add((0x00 << 0x08) | 0x15, "SSL_DHE_RSA_WITH_DES_CBC_SHA", HashAlgorithmType.Sha1, CipherAlgorithmType.Des, ExchangeAlgorithmType.DiffieHellman, false, true, 8, 8, 56, 8, 8);
+ // scs.Add((0x00 << 0x08) | 0x16, "SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA", CipherAlgorithmType.TripleDes, HashAlgorithmType.Sha1, ExchangeAlgorithmType.DiffieHellman, false, true, 24, 24, 168, 8, 8);
// Anonymous Diffie-Hellman Cipher Suites
- // scs.Add((0x00 << 0x08) | 0x17, "SSL_DH_anon_EXPORT_WITH_RC4_40_MD5", "RC4", "MD5", true, false, 5, 16, 40, 0, 0);
- // scs.Add((0x00 << 0x08) | 0x18, "SSL_DH_anon_WITH_RC4_128_MD5", "RC4", "MD5", false, false, 16, 16, 128, 0, 0);
- // scs.Add((0x00 << 0x08) | 0x19, "SSL_DH_anon_EXPORT_WITH_DES40_CBC_SHA", "DES", "SHA1", false, true, 5, 8, 40, 8, 8);
- // scs.Add((0x00 << 0x08) | 0x1A, "SSL_DH_anon_WITH_DES_CBC_SHA", "DES4", "SHA1", false, true, 8, 8, 56, 8, 8);
- // scs.Add((0x00 << 0x08) | 0x1B, "SSL_DH_anon_WITH_3DES_EDE_CBC_SHA", "3DES", "SHA1", false, true, 24, 24, 168, 8, 8);
+ // scs.Add((0x00 << 0x08) | 0x17, "SSL_DH_anon_EXPORT_WITH_RC4_40_MD5", CipherAlgorithmType.Rc4, HashAlgorithmType.Md5, ExchangeAlgorithmType.DiffieHellman, true, false, 5, 16, 40, 0, 0);
+ // scs.Add((0x00 << 0x08) | 0x18, "SSL_DH_anon_WITH_RC4_128_MD5", CipherAlgorithmType.Rc4, HashAlgorithmType.Md5, false, ExchangeAlgorithmType.DiffieHellman, false, 16, 16, 128, 0, 0);
+ // scs.Add((0x00 << 0x08) | 0x19, "SSL_DH_anon_EXPORT_WITH_DES40_CBC_SHA", CipherAlgorithmType.Des, HashAlgorithmType.Sha1, ExchangeAlgorithmType.DiffieHellman, false, true, 5, 8, 40, 8, 8);
+ // scs.Add((0x00 << 0x08) | 0x1A, "SSL_DH_anon_WITH_DES_CBC_SHA", "DES4", HashAlgorithmType.Sha1, ExchangeAlgorithmType.DiffieHellman, false, true, 8, 8, 56, 8, 8);
+ // scs.Add((0x00 << 0x08) | 0x1B, "SSL_DH_anon_WITH_3DES_EDE_CBC_SHA", CipherAlgorithmType.TripleDes, HashAlgorithmType.Sha1, ExchangeAlgorithmType.DiffieHellman, false, true, 24, 24, 168, 8, 8);
return scs;
}
#endregion
}
-}
+} \ No newline at end of file
diff --git a/mcs/class/Mono.Security/Mono.Security.Protocol.Tls/TlsClientSettings.cs b/mcs/class/Mono.Security/Mono.Security.Protocol.Tls/TlsClientSettings.cs
new file mode 100644
index 00000000000..12248f3e620
--- /dev/null
+++ b/mcs/class/Mono.Security/Mono.Security.Protocol.Tls/TlsClientSettings.cs
@@ -0,0 +1,81 @@
+/* Transport Security Layer (TLS)
+ * Copyright (c) 2003 Carlos Guzmán Álvarez
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+using System;
+using System.Text;
+using System.Security.Cryptography.X509Certificates;
+
+namespace Mono.Security.Protocol.Tls
+{
+ internal sealed class TlsClientSettings
+ {
+ #region FIELDS
+
+ private string targetHost;
+ private X509CertificateCollection certificates;
+ private SecurityCompressionType compressionMethod;
+
+ #endregion
+
+ #region PROPERTIES
+
+ public string TargetHost
+ {
+ get { return this.targetHost; }
+ set { this.targetHost = value; }
+ }
+
+ public X509CertificateCollection Certificates
+ {
+ get { return this.certificates; }
+ set { this.certificates = value; }
+ }
+
+ public SecurityCompressionType CompressionMethod
+ {
+ get { return this.compressionMethod; }
+ set
+ {
+ if (value != SecurityCompressionType.None)
+ {
+ throw new NotSupportedException("Specified compression method is not supported");
+ }
+ this.compressionMethod = value;
+ }
+ }
+
+ #endregion
+
+ #region CONSTRUCTORS
+
+ public TlsClientSettings()
+ {
+ this.compressionMethod = SecurityCompressionType.None;
+ this.certificates = new X509CertificateCollection();
+ this.targetHost = String.Empty;
+ }
+
+ #endregion
+ }
+}
diff --git a/mcs/class/Mono.Security/Mono.Security.Protocol.Tls/TlsContext.cs b/mcs/class/Mono.Security/Mono.Security.Protocol.Tls/TlsContext.cs
new file mode 100644
index 00000000000..d93f2d55d44
--- /dev/null
+++ b/mcs/class/Mono.Security/Mono.Security.Protocol.Tls/TlsContext.cs
@@ -0,0 +1,351 @@
+/* Transport Security Layer (TLS)
+ * Copyright (c) 2003 Carlos Guzmán Álvarez
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+using System;
+using System.Text;
+using System.Collections;
+using System.Security.Cryptography;
+using System.Security.Cryptography.X509Certificates;
+
+using Mono.Security.Cryptography;
+using Mono.Security.Protocol.Tls.Alerts;
+using Mono.Security.Protocol.Tls.Handshake;
+
+namespace Mono.Security.Protocol.Tls
+{
+ internal class TlsContext
+ {
+ #region FIELDS
+
+ // SslClientStream that owns the context
+ private SslClientStream sslStream;
+
+ // Protocol version
+ private SecurityProtocolType protocol;
+
+ // Sesison ID
+ private byte[] sessionId;
+
+ // Compression method
+ private SecurityCompressionType compressionMethod;
+
+ // Information sent and request by the server in the Handshake protocol
+ private TlsServerSettings serverSettings;
+
+ // Client configuration
+ private TlsClientSettings clientSettings;
+
+ // Cipher suite information
+ private CipherSuite cipher;
+ private TlsCipherSuiteCollection supportedCiphers;
+
+ // Misc
+ private bool isActual;
+ private bool helloDone;
+ private bool handshakeFinished;
+ private bool connectionEnd;
+
+ // Sequence numbers
+ private long writeSequenceNumber;
+ private long readSequenceNumber;
+
+ // Random data
+ private byte[] clientRandom;
+ private byte[] serverRandom;
+ private byte[] randomCS;
+ private byte[] randomSC;
+
+ // Key information
+ private byte[] masterSecret;
+ private byte[] clientWriteMAC;
+ private byte[] serverWriteMAC;
+ private byte[] clientWriteKey;
+ private byte[] serverWriteKey;
+ private byte[] clientWriteIV;
+ private byte[] serverWriteIV;
+
+ // Handshake hashes
+ private TlsStream handshakeMessages;
+
+ #endregion
+
+ #region INTERNAL_CONSTANTS
+
+ internal const short MAX_FRAGMENT_SIZE = 16384; // 2^14
+
+ #endregion
+
+ #region PROPERTIES
+
+ public SslClientStream SslStream
+ {
+ get { return sslStream; }
+ }
+
+ public SecurityProtocolType Protocol
+ {
+ get { return this.protocol; }
+ set { this.protocol = value; }
+ }
+
+ public byte[] SessionId
+ {
+ get { return this.sessionId; }
+ set { this.sessionId = value; }
+ }
+
+ public SecurityCompressionType CompressionMethod
+ {
+ get { return this.compressionMethod; }
+ set { this.compressionMethod = value; }
+ }
+
+ public TlsServerSettings ServerSettings
+ {
+ get { return this.serverSettings; }
+ set { this.serverSettings = value; }
+ }
+
+ public TlsClientSettings ClientSettings
+ {
+ get { return this.clientSettings; }
+ set { this.clientSettings = value; }
+ }
+
+ public bool IsActual
+ {
+ get { return this.isActual; }
+ set { this.isActual = value; }
+ }
+
+ public bool HelloDone
+ {
+ get { return helloDone; }
+ set { helloDone = value; }
+ }
+
+ public bool HandshakeFinished
+ {
+ get { return handshakeFinished; }
+ set { handshakeFinished = value; }
+ }
+
+ public bool ConnectionEnd
+ {
+ get { return this.connectionEnd; }
+ set { this.connectionEnd = value; }
+ }
+
+ public CipherSuite Cipher
+ {
+ get { return this.cipher; }
+ set { this.cipher = value; }
+ }
+
+ public TlsCipherSuiteCollection SupportedCiphers
+ {
+ get { return supportedCiphers; }
+ set { supportedCiphers = value; }
+ }
+
+ public TlsStream HandshakeMessages
+ {
+ get { return this.handshakeMessages; }
+ }
+
+ public long WriteSequenceNumber
+ {
+ get { return this.writeSequenceNumber; }
+ set { this.writeSequenceNumber = value; }
+ }
+
+ public long ReadSequenceNumber
+ {
+ get { return this.readSequenceNumber; }
+ set { this.readSequenceNumber = value; }
+ }
+
+ public byte[] ClientRandom
+ {
+ get { return this.clientRandom; }
+ set { this.clientRandom = value; }
+ }
+
+ public byte[] ServerRandom
+ {
+ get { return this.serverRandom; }
+ set { this.serverRandom = value; }
+ }
+
+ public byte[] RandomCS
+ {
+ get { return this.randomCS; }
+ set { this.randomCS = value; }
+ }
+
+ public byte[] RandomSC
+ {
+ get { return this.randomSC; }
+ set { this.randomSC = value; }
+ }
+
+ public byte[] MasterSecret
+ {
+ get { return this.masterSecret; }
+ set { this.masterSecret = value; }
+ }
+
+ public byte[] ClientWriteMAC
+ {
+ get { return this.clientWriteMAC; }
+ set { this.clientWriteMAC = value; }
+ }
+
+ public byte[] ServerWriteMAC
+ {
+ get { return this.serverWriteMAC; }
+ set { this.serverWriteMAC = value; }
+ }
+
+ public byte[] ClientWriteKey
+ {
+ get { return this.clientWriteKey; }
+ set { this.clientWriteKey = value; }
+ }
+
+ public byte[] ServerWriteKey
+ {
+ get { return this.serverWriteKey; }
+ set { this.serverWriteKey = value; }
+ }
+
+ public byte[] ClientWriteIV
+ {
+ get { return this.clientWriteIV; }
+ set { this.clientWriteIV = value; }
+ }
+
+ public byte[] ServerWriteIV
+ {
+ get { return this.serverWriteIV; }
+ set { this.serverWriteIV = value; }
+ }
+
+ #endregion
+
+ #region CONSTRUCTORS
+
+ public TlsContext(
+ SslClientStream sslStream,
+ SecurityProtocolType securityProtocolType,
+ string targetHost,
+ X509CertificateCollection clientCertificates)
+ {
+ this.sslStream = sslStream;
+ this.protocol = securityProtocolType;
+ this.compressionMethod = SecurityCompressionType.None;
+ this.serverSettings = new TlsServerSettings();
+ this.clientSettings = new TlsClientSettings();
+ this.handshakeMessages = new TlsStream();
+ this.sessionId = null;
+
+ // Set client settings
+ this.ClientSettings.TargetHost = targetHost;
+ this.ClientSettings.Certificates = clientCertificates;
+ }
+
+ #endregion
+
+ #region METHODS
+
+ public int GetUnixTime()
+ {
+ DateTime now = DateTime.Now.ToUniversalTime();
+ TimeSpan unixTime = now.Subtract(new DateTime(1970, 1, 1));
+
+ return (int)unixTime.TotalSeconds;
+ }
+
+ public byte[] GetSecureRandomBytes(int count)
+ {
+ byte[] secureBytes = new byte[count];
+
+ RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider();
+ rng.GetNonZeroBytes(secureBytes);
+
+ return secureBytes;
+ }
+
+ public void ClearKeyInfo()
+ {
+ // Clear Master Secret
+ this.masterSecret = null;
+
+ // Clear client and server random
+ this.clientRandom = null;
+ this.serverRandom = null;
+ this.randomCS = null;
+ this.randomSC = null;
+
+ // Clear client keys
+ this.clientWriteKey = null;
+ this.clientWriteIV = null;
+
+ // Clear server keys
+ this.serverWriteKey = null;
+ this.serverWriteIV = null;
+
+ // Clear MAC keys if protocol is different than Ssl3
+ if (this.protocol != SecurityProtocolType.Ssl3)
+ {
+ this.clientWriteMAC = null;
+ this.serverWriteMAC = null;
+ }
+ }
+
+ #endregion
+
+ #region EXCEPTION_METHODS
+
+ internal TlsException CreateException(TlsAlertLevel alertLevel, TlsAlertDescription alertDesc)
+ {
+ return CreateException(TlsAlert.GetAlertMessage(alertDesc));
+ }
+
+ internal TlsException CreateException(string format, params object[] args)
+ {
+ StringBuilder message = new StringBuilder();
+ message.AppendFormat(format, args);
+
+ return CreateException(message.ToString());
+ }
+
+ internal TlsException CreateException(string message)
+ {
+ return new TlsException(message);
+ }
+
+ #endregion
+ }
+}
diff --git a/mcs/class/Mono.Security/Mono.Security.Protocol.Tls/TlsServerSettings.cs b/mcs/class/Mono.Security/Mono.Security.Protocol.Tls/TlsServerSettings.cs
index 737c990ed38..aae7af7150d 100644
--- a/mcs/class/Mono.Security/Mono.Security.Protocol.Tls/TlsServerSettings.cs
+++ b/mcs/class/Mono.Security/Mono.Security.Protocol.Tls/TlsServerSettings.cs
@@ -34,7 +34,7 @@ namespace Mono.Security.Protocol.Tls
{
#region FIELDS
- private X509CertificateCollection serverCertificates;
+ private X509CertificateCollection certificates;
private bool serverKeyExchange;
private bool certificateRequest;
private TlsClientCertificateType[] certificateTypes;
@@ -82,10 +82,10 @@ namespace Mono.Security.Protocol.Tls
set { distinguisedNames = value; }
}
- public X509CertificateCollection ServerCertificates
+ public X509CertificateCollection Certificates
{
- get { return serverCertificates; }
- set { serverCertificates = value; }
+ get { return certificates; }
+ set { certificates = value; }
}
#endregion
diff --git a/mcs/class/Mono.Security/Mono.Security.Protocol.Tls/TlsSslCipherSuite.cs b/mcs/class/Mono.Security/Mono.Security.Protocol.Tls/TlsSslCipherSuite.cs
index 46e8caa1573..52146e129fa 100755
--- a/mcs/class/Mono.Security/Mono.Security.Protocol.Tls/TlsSslCipherSuite.cs
+++ b/mcs/class/Mono.Security/Mono.Security.Protocol.Tls/TlsSslCipherSuite.cs
@@ -44,15 +44,18 @@ namespace Mono.Security.Protocol.Tls
#region CONSTRUCTORS
- public TlsSslCipherSuite(short code, string name, string algName,
- string hashName, bool exportable, bool blockMode,
- byte keyMaterialSize, byte expandedKeyMaterialSize,
- short effectiveKeyBytes, byte ivSize, byte blockSize)
- : base (code, name, algName, hashName, exportable, blockMode,
- keyMaterialSize, expandedKeyMaterialSize, effectiveKeyBytes,
- ivSize, blockSize)
+ public TlsSslCipherSuite(
+ short code, string name, CipherAlgorithmType cipherAlgorithmType,
+ HashAlgorithmType hashAlgorithmType, ExchangeAlgorithmType exchangeAlgorithmType,
+ bool exportable, bool blockMode, byte keyMaterialSize,
+ byte expandedKeyMaterialSize, short effectiveKeyBytes,
+ byte ivSize, byte blockSize) :
+ base(code, name, cipherAlgorithmType, hashAlgorithmType,
+ exchangeAlgorithmType, exportable, blockMode, keyMaterialSize,
+ expandedKeyMaterialSize, effectiveKeyBytes, ivSize, blockSize)
+
{
- int padLength = (hashName == "MD5") ? 48 : 40;
+ int padLength = (hashAlgorithmType == HashAlgorithmType.Md5) ? 48 : 40;
// Fill pad arrays
this.pad1 = new byte[padLength];
@@ -72,7 +75,7 @@ namespace Mono.Security.Protocol.Tls
public override byte[] ComputeServerRecordMAC(TlsContentType contentType, byte[] fragment)
{
- HashAlgorithm hash = HashAlgorithm.Create(this.HashName);
+ HashAlgorithm hash = HashAlgorithm.Create(this.HashAlgorithmName);
TlsStream block = new TlsStream();
block.Write(this.Context.ServerWriteMAC);
@@ -101,7 +104,7 @@ namespace Mono.Security.Protocol.Tls
public override byte[] ComputeClientRecordMAC(TlsContentType contentType, byte[] fragment)
{
- HashAlgorithm hash = HashAlgorithm.Create(this.HashName);
+ HashAlgorithm hash = HashAlgorithm.Create(this.HashAlgorithmName);
TlsStream block = new TlsStream();
block.Write(this.Context.ClientWriteMAC);
@@ -192,7 +195,7 @@ namespace Mono.Security.Protocol.Tls
}
else
{
- MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider();
+ HashAlgorithm md5 = MD5.Create();
// Generate final write keys
byte[] finalClientWriteKey = new byte[md5.HashSize];
@@ -222,8 +225,8 @@ namespace Mono.Security.Protocol.Tls
private byte[] prf(byte[] secret, string label, byte[] random)
{
- HashAlgorithm md5 = new MD5CryptoServiceProvider();
- SHA1CryptoServiceProvider sha = new SHA1CryptoServiceProvider();
+ HashAlgorithm md5 = MD5.Create();
+ HashAlgorithm sha = SHA1.Create();
// Compute SHA hash
TlsStream block = new TlsStream();
diff --git a/mcs/class/Mono.Security/Mono.Security.dll.sources b/mcs/class/Mono.Security/Mono.Security.dll.sources
index 431c1902119..cd84bd6f28a 100644
--- a/mcs/class/Mono.Security/Mono.Security.dll.sources
+++ b/mcs/class/Mono.Security/Mono.Security.dll.sources
@@ -11,6 +11,9 @@
./Mono.Security.Cryptography/CryptoConvert.cs
./Mono.Security.Cryptography/MD2.cs
./Mono.Security.Cryptography/MD2Managed.cs
+./Mono.Security.Cryptography/MD4.cs
+./Mono.Security.Cryptography/MD4Managed.cs
+./Mono.Security.Cryptography/PKCS8.cs
./Mono.Security.Cryptography/RC4.cs
./Mono.Security.X509/ITrustAnchors.cs
./Mono.Security.X509/TestAnchors.cs
@@ -32,22 +35,22 @@
./Mono.Security.X509.Stores/FileCertificateStore.cs
./Mono.Security.X509.Stores/ICertificateStore.cs
./Mono.Security.Cryptography/TlsHMAC.cs
-./Mono.Security.Cryptography/MD5SHA1CryptoServiceProvider.cs
+./Mono.Security.Cryptography/MD5SHA1.cs
./Mono.Security.Protocol.Tls/CipherSuite.cs
+./Mono.Security.Protocol.Tls/CipherAlgorithmType.cs
+./Mono.Security.Protocol.Tls/ExchangeAlgorithmType.cs
+./Mono.Security.Protocol.Tls/HashAlgorithmType.cs
+./Mono.Security.Protocol.Tls/SecurityCompressionType.cs
+./Mono.Security.Protocol.Tls/SecurityProtocolType.cs
./Mono.Security.Protocol.Tls/TlsCipherSuite.cs
./Mono.Security.Protocol.Tls/TlsCipherSuiteCollection.cs
./Mono.Security.Protocol.Tls/TlsCipherSuiteFactory.cs
-./Mono.Security.Protocol.Tls/TlsCompressionMethod.cs
./Mono.Security.Protocol.Tls/TlsContentType.cs
./Mono.Security.Protocol.Tls/TlsException.cs
-./Mono.Security.Protocol.Tls/TlsNetworkStream.cs
-./Mono.Security.Protocol.Tls/TlsProtocol.cs
./Mono.Security.Protocol.Tls/TlsServerSettings.cs
-./Mono.Security.Protocol.Tls/TlsSession.cs
-./Mono.Security.Protocol.Tls/TlsSessionContext.cs
-./Mono.Security.Protocol.Tls/TlsSessionSettings.cs
-./Mono.Security.Protocol.Tls/TlsSessionState.cs
-./Mono.Security.Protocol.Tls/TlsSocket.cs
+./Mono.Security.Protocol.Tls/TlsContext.cs
+./Mono.Security.Protocol.Tls/TlsClientSettings.cs
+./Mono.Security.Protocol.Tls/SslClientStream.cs
./Mono.Security.Protocol.Tls/TlsStream.cs
./Mono.Security.Protocol.Tls/TlsSslCipherSuite.cs
./Mono.Security.Protocol.Tls/TlsSslHandshakeHash.cs
diff --git a/mcs/class/Mono.Security/Mono.Security_test.dll.sources b/mcs/class/Mono.Security/Mono.Security_test.dll.sources
index 912b8e696fd..1acb339bb21 100644
--- a/mcs/class/Mono.Security/Mono.Security_test.dll.sources
+++ b/mcs/class/Mono.Security/Mono.Security_test.dll.sources
@@ -4,3 +4,6 @@ Mono.Security.Authenticode/SoftwarePublisherCertificateTest.cs
Mono.Security.Cryptography/ARC4ManagedTest.cs
Mono.Security.Cryptography/MD2ManagedTest.cs
Mono.Security.Cryptography/MD2Test.cs
+Mono.Security.Cryptography/MD4ManagedTest.cs
+Mono.Security.Cryptography/MD4Test.cs
+Mono.Security.Cryptography/PKCS8Test.cs
diff --git a/mcs/class/Mono.Security/Test/Mono.Security.Cryptography/ChangeLog b/mcs/class/Mono.Security/Test/Mono.Security.Cryptography/ChangeLog
index b52a1f7e4ce..5bda0e5e0d2 100644
--- a/mcs/class/Mono.Security/Test/Mono.Security.Cryptography/ChangeLog
+++ b/mcs/class/Mono.Security/Test/Mono.Security.Cryptography/ChangeLog
@@ -1,3 +1,11 @@
+2003-11-27 Sebastien Pouliot <spouliot@videotron.ca>
+
+ * MD4Test.cs: New. Contains all the test vectors provided in RFC1320
+ - but none are executed because MD4 is an abstract class.
+ * MD4ManagedTest.cs: New. Run the unit tests from MD4Test.cs using
+ the MD4Managed implementation of MD4.
+ * PKCS8Test.cs: New. Unit tests for PKCS8.
+
2003-03-07 Sebastien Pouliot <spouliot@videotron.ca>
* ARC4ManagedTest.cs: New. Test vectors for RC4(tm) taken from
diff --git a/mcs/class/Mono.Security/Test/Mono.Security.Cryptography/MD4ManagedTest.cs b/mcs/class/Mono.Security/Test/Mono.Security.Cryptography/MD4ManagedTest.cs
new file mode 100755
index 00000000000..0eb34b5c841
--- /dev/null
+++ b/mcs/class/Mono.Security/Test/Mono.Security.Cryptography/MD4ManagedTest.cs
@@ -0,0 +1,27 @@
+//
+// MD4ManagedTest.cs - NUnit Test Cases for MD4 (RFC1320)
+//
+// Author:
+// Sebastien Pouliot (spouliot@motus.com)
+//
+// (C) 2003 Motus Technologies Inc. (http://www.motus.com)
+//
+
+using System;
+using NUnit.Framework;
+using Mono.Security.Cryptography;
+
+namespace MonoTests.Mono.Security.Cryptography {
+
+ [TestFixture]
+ public class MD4ManagedTest : MD4Test {
+
+ [SetUp]
+ public void Setup ()
+ {
+ hash = new MD4Managed ();
+ }
+
+ // this will run ALL tests defined in MD4Test.cs with the MD4Managed implementation
+ }
+} \ No newline at end of file
diff --git a/mcs/class/Mono.Security/Test/Mono.Security.Cryptography/MD4Test.cs b/mcs/class/Mono.Security/Test/Mono.Security.Cryptography/MD4Test.cs
new file mode 100755
index 00000000000..4db2eb8d660
--- /dev/null
+++ b/mcs/class/Mono.Security/Test/Mono.Security.Cryptography/MD4Test.cs
@@ -0,0 +1,226 @@
+//
+// MD4Test.cs - NUnit Test Cases for MD4 (RFC1320)
+//
+// Author:
+// Sebastien Pouliot (spouliot@motus.com)
+//
+// (C) 2002, 2003 Motus Technologies Inc. (http://www.motus.com)
+//
+
+using NUnit.Framework;
+using System;
+using System.IO;
+using Mono.Security.Cryptography;
+using System.Text;
+
+namespace MonoTests.Mono.Security.Cryptography {
+
+ // References:
+ // a. The MD4 Message-Digest Algorithm
+ // http://www.ietf.org/rfc/RFC1320.txt
+
+ // MD4 is a abstract class - so ALL of the test included here wont be tested
+ // on the abstract class but should be tested in ALL its descendants.
+ public class MD4Test : Assertion {
+
+ protected MD4 hash;
+
+ // because most crypto stuff works with byte[] buffers
+ static public void AssertEquals (string msg, byte[] array1, byte[] array2)
+ {
+ if ((array1 == null) && (array2 == null))
+ return;
+ if (array1 == null)
+ Assertion.Fail (msg + " -> First array is NULL");
+ if (array2 == null)
+ Assertion.Fail (msg + " -> Second array is NULL");
+
+ bool a = (array1.Length == array2.Length);
+ if (a) {
+ for (int i = 0; i < array1.Length; i++) {
+ if (array1 [i] != array2 [i]) {
+ a = false;
+ break;
+ }
+ }
+ }
+ if (array1.Length > 0) {
+ msg += " -> Expected " + BitConverter.ToString (array1, 0);
+ msg += " is different than " + BitConverter.ToString (array2, 0);
+ }
+ Assertion.Assert (msg, a);
+ }
+
+ // MD4 ("") = 31d6cfe0d16ae931b73c59d7e0c089c0
+ [Test]
+ public void RFC1320_Test1 ()
+ {
+ string className = hash.ToString ();
+ byte[] result = { 0x31, 0xd6, 0xcf, 0xe0, 0xd1, 0x6a, 0xe9, 0x31, 0xb7, 0x3c, 0x59, 0xd7, 0xe0, 0xc0, 0x89, 0xc0 };
+ byte[] input = new byte [0];
+
+ string testName = className + " 1";
+ RFC1320_a (testName, hash, input, result);
+ RFC1320_b (testName, hash, input, result);
+ RFC1320_c (testName, hash, input, result);
+ RFC1320_d (testName, hash, input, result);
+ // N/A RFC1320_e (testName, hash, input, result);
+ }
+
+ // MD4 ("a") = bde52cb31de33e46245e05fbdbd6fb24
+ [Test]
+ public void RFC1320_Test2 ()
+ {
+ string className = hash.ToString ();
+ byte[] result = { 0xbd, 0xe5, 0x2c, 0xb3, 0x1d, 0xe3, 0x3e, 0x46, 0x24, 0x5e, 0x05, 0xfb, 0xdb, 0xd6, 0xfb, 0x24 };
+ byte[] input = Encoding.Default.GetBytes ("a");
+
+ string testName = className + " 2";
+ RFC1320_a (testName, hash, input, result);
+ RFC1320_b (testName, hash, input, result);
+ RFC1320_c (testName, hash, input, result);
+ RFC1320_d (testName, hash, input, result);
+ RFC1320_e (testName, hash, input, result);
+ }
+
+ // MD4 ("abc") = a448017aaf21d8525fc10ae87aa6729d
+ [Test]
+ public void RFC1320_Test3 ()
+ {
+ string className = hash.ToString ();
+ byte[] result = { 0xa4, 0x48, 0x01, 0x7a, 0xaf, 0x21, 0xd8, 0x52, 0x5f, 0xc1, 0x0a, 0xe8, 0x7a, 0xa6, 0x72, 0x9d };
+ byte[] input = Encoding.Default.GetBytes ("abc");
+
+ string testName = className + " 3";
+ RFC1320_a (testName, hash, input, result);
+ RFC1320_b (testName, hash, input, result);
+ RFC1320_c (testName, hash, input, result);
+ RFC1320_d (testName, hash, input, result);
+ RFC1320_e (testName, hash, input, result);
+ }
+
+ // MD4 ("message digest") = d9130a8164549fe818874806e1c7014b
+ [Test]
+ public void RFC1320_Test4 ()
+ {
+ string className = hash.ToString ();
+ byte[] result = { 0xd9, 0x13, 0x0a, 0x81, 0x64, 0x54, 0x9f, 0xe8, 0x18, 0x87, 0x48, 0x06, 0xe1, 0xc7, 0x01, 0x4b };
+ byte[] input = Encoding.Default.GetBytes ("message digest");
+
+ string testName = className + " 4";
+ RFC1320_a (testName, hash, input, result);
+ RFC1320_b (testName, hash, input, result);
+ RFC1320_c (testName, hash, input, result);
+ RFC1320_d (testName, hash, input, result);
+ RFC1320_e (testName, hash, input, result);
+ }
+
+ // MD4 ("abcdefghijklmnopqrstuvwxyz") = d79e1c308aa5bbcdeea8ed63df412da9
+ [Test]
+ public void RFC1320_Test5 ()
+ {
+ string className = hash.ToString ();
+ byte[] result = { 0xd7, 0x9e, 0x1c, 0x30, 0x8a, 0xa5, 0xbb, 0xcd, 0xee, 0xa8, 0xed, 0x63, 0xdf, 0x41, 0x2d, 0xa9 };
+ byte[] input = Encoding.Default.GetBytes ("abcdefghijklmnopqrstuvwxyz");
+
+ string testName = className + " 5";
+ RFC1320_a (testName, hash, input, result);
+ RFC1320_b (testName, hash, input, result);
+ RFC1320_c (testName, hash, input, result);
+ RFC1320_d (testName, hash, input, result);
+ RFC1320_e (testName, hash, input, result);
+ }
+
+ // MD4 ("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789") =
+ // 043f8582f241db351ce627e153e7f0e4
+ [Test]
+ public void RFC1320_Test6 ()
+ {
+ string className = hash.ToString ();
+ byte[] result = { 0x04, 0x3f, 0x85, 0x82, 0xf2, 0x41, 0xdb, 0x35, 0x1c, 0xe6, 0x27, 0xe1, 0x53, 0xe7, 0xf0, 0xe4 };
+ byte[] input = Encoding.Default.GetBytes ("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789");
+
+ string testName = className + " 6";
+ RFC1320_a (testName, hash, input, result);
+ RFC1320_b (testName, hash, input, result);
+ RFC1320_c (testName, hash, input, result);
+ RFC1320_d (testName, hash, input, result);
+ RFC1320_e (testName, hash, input, result);
+ }
+
+ // MD4 ("123456789012345678901234567890123456789012345678901234567890123456
+ // 78901234567890") = e33b4ddc9c38f2199c3e7b164fcc0536
+ [Test]
+ public void RFC1320_Test7 ()
+ {
+ string className = hash.ToString ();
+ byte[] result = { 0xe3, 0x3b, 0x4d, 0xdc, 0x9c, 0x38, 0xf2, 0x19, 0x9c, 0x3e, 0x7b, 0x16, 0x4f, 0xcc, 0x05, 0x36 };
+ byte[] input = Encoding.Default.GetBytes ("12345678901234567890123456789012345678901234567890123456789012345678901234567890");
+
+ string testName = className + " 7";
+ RFC1320_a (testName, hash, input, result);
+ RFC1320_b (testName, hash, input, result);
+ RFC1320_c (testName, hash, input, result);
+ RFC1320_d (testName, hash, input, result);
+ RFC1320_e (testName, hash, input, result);
+ }
+
+ public void RFC1320_a (string testName, MD4 hash, byte[] input, byte[] result)
+ {
+ byte[] output = hash.ComputeHash (input);
+ AssertEquals (testName + ".a.1", result, output);
+ AssertEquals (testName + ".a.2", result, hash.Hash);
+ // required or next operation will still return old hash
+ hash.Initialize ();
+ }
+
+ public void RFC1320_b (string testName, MD4 hash, byte[] input, byte[] result)
+ {
+ byte[] output = hash.ComputeHash (input, 0, input.Length);
+ AssertEquals (testName + ".b.1", result, output);
+ AssertEquals (testName + ".b.2", result, hash.Hash);
+ // required or next operation will still return old hash
+ hash.Initialize ();
+ }
+
+ public void RFC1320_c (string testName, MD4 hash, byte[] input, byte[] result)
+ {
+ MemoryStream ms = new MemoryStream (input);
+ byte[] output = hash.ComputeHash (ms);
+ AssertEquals (testName + ".c.1", result, output);
+ AssertEquals (testName + ".c.2", result, hash.Hash);
+ // required or next operation will still return old hash
+ hash.Initialize ();
+ }
+
+ public void RFC1320_d (string testName, MD4 hash, byte[] input, byte[] result)
+ {
+ byte[] output = hash.TransformFinalBlock (input, 0, input.Length);
+ AssertEquals (testName + ".d.1", input, output);
+ AssertEquals (testName + ".d.2", result, hash.Hash);
+ // required or next operation will still return old hash
+ hash.Initialize ();
+ }
+
+ public void RFC1320_e (string testName, MD4 hash, byte[] input, byte[] result)
+ {
+ byte[] copy = new byte [input.Length];
+ for (int i=0; i < input.Length - 1; i++)
+ hash.TransformBlock (input, i, 1, copy, i);
+ byte[] output = hash.TransformFinalBlock (input, input.Length - 1, 1);
+ TestCase.AssertEquals (testName + ".e.1", input [input.Length - 1], output [0]);
+ AssertEquals (testName + ".e.2", result, hash.Hash);
+ // required or next operation will still return old hash
+ hash.Initialize ();
+ }
+
+ // none of those values changes for any implementation of MD4
+ public virtual void StaticInfo ()
+ {
+ string className = hash.ToString ();
+ TestCase.AssertEquals (className + ".HashSize", 128, hash.HashSize);
+ TestCase.AssertEquals (className + ".InputBlockSize", 1, hash.InputBlockSize);
+ TestCase.AssertEquals (className + ".OutputBlockSize", 1, hash.OutputBlockSize);
+ }
+ }
+}
diff --git a/mcs/class/Mono.Security/Test/Mono.Security.Cryptography/PKCS8Test.cs b/mcs/class/Mono.Security/Test/Mono.Security.Cryptography/PKCS8Test.cs
new file mode 100755
index 00000000000..dd204519d67
--- /dev/null
+++ b/mcs/class/Mono.Security/Test/Mono.Security.Cryptography/PKCS8Test.cs
@@ -0,0 +1,92 @@
+//
+// PKCS8Test.cs - NUnit Test Cases for PKCS #8
+//
+// Author:
+// Sebastien Pouliot (spouliot@motus.com)
+//
+// (C) 2003 Motus Technologies Inc. (http://www.motus.com)
+//
+
+using System;
+using System.IO;
+using System.Security.Cryptography;
+using System.Text;
+
+using Mono.Security.Cryptography;
+using NUnit.Framework;
+
+namespace MonoTests.Mono.Security.Cryptography {
+
+ [TestFixture]
+ public class PKCS8Test : Assertion {
+
+ static public byte[] pkcs8_der = { 0x30, 0x82, 0x02, 0xB2, 0x30, 0x1C, 0x06, 0x0A, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x0C, 0x01, 0x03, 0x30, 0x0E, 0x04, 0x08, 0x86, 0x2A, 0xA9, 0x71, 0x6D, 0xA4, 0xB8, 0x2D, 0x02, 0x02, 0x07, 0xD0, 0x04, 0x82, 0x02, 0x90, 0x90, 0x14, 0xB5, 0xF0, 0xB6, 0x86, 0x56, 0xCB, 0xFA, 0x63, 0xAD, 0x9F, 0x5A, 0x59, 0x6C, 0xAD, 0x00, 0x3C, 0x37, 0x8A, 0xC3, 0x88, 0x58, 0x8B, 0xD7, 0x48, 0x53, 0x7A, 0xC8, 0x5B, 0x0D, 0x98, 0xDD, 0x8B, 0xB3, 0xEC, 0x4C, 0xAC, 0x61, 0x18, 0xE3, 0x5E, 0x47, 0xAD, 0xC7, 0x92, 0xBC, 0xD3, 0x00, 0x07, 0xFF, 0x1A, 0x68, 0x74, 0x45, 0x8E, 0xD8, 0x7C, 0x9F, 0x18, 0x7B, 0xD7, 0xC8,
+ 0x47, 0xBA, 0x6B, 0x19, 0xF2, 0xBF, 0x7E, 0x51, 0x0B, 0x4B, 0x43, 0xE8, 0xB9, 0x56, 0x7E, 0xD0, 0x74, 0xC7, 0xDE, 0x76, 0xDB, 0xFF, 0x5C, 0x6B, 0x53, 0xBE, 0x31, 0x06, 0xAE, 0x6C, 0x8F, 0xDC, 0x49, 0x04, 0x71, 0x74, 0xEE, 0xB8, 0x06, 0xCB, 0xAD, 0x86, 0xB4, 0x4E, 0xB9, 0x46, 0xA1, 0x03, 0x5E, 0x0E, 0xA7, 0xC7, 0x37, 0x6B, 0xB0, 0x8D, 0x2D, 0x81, 0x1F, 0xE3, 0xC2, 0x05, 0xDE, 0xEF, 0x51, 0x07, 0x70, 0x6E, 0x35, 0x9A, 0xAD, 0x19, 0x5E, 0xAF, 0xEB, 0x7F, 0xEF, 0xE4, 0xAB, 0x07, 0xF3, 0xF6, 0xEA, 0xFA, 0x0E, 0x83, 0x65, 0x06, 0x3C, 0xF3, 0xBD, 0x96, 0x08, 0x14, 0xC5, 0x34, 0x26, 0xED, 0xC0, 0x10,
+ 0xCC, 0xAE, 0x2D, 0x8F, 0xBE, 0xED, 0x98, 0x0D, 0x88, 0x1B, 0x1E, 0xC7, 0x37, 0xF0, 0xFC, 0xDB, 0x3C, 0xE3, 0x1B, 0x66, 0x52, 0x45, 0x6E, 0x05, 0xA6, 0xD9, 0x12, 0x23, 0x05, 0x5F, 0xE3, 0x9F, 0x7D, 0x21, 0x9B, 0x2E, 0x3E, 0x9E, 0x3C, 0xEE, 0xD1, 0x9B, 0x55, 0xDE, 0x57, 0x60, 0xA5, 0x24, 0x2D, 0xC7, 0x94, 0xEC, 0xFC, 0xB1, 0x6A, 0x65, 0xBD, 0x85, 0x02, 0x5C, 0x58, 0xAA, 0x5A, 0x6A, 0xF3, 0xAC, 0x6B, 0xDD, 0x0E, 0x63, 0xB2, 0x4B, 0x5B, 0x67, 0x3D, 0xC3, 0xBF, 0xE4, 0xC8, 0xEF, 0x3F, 0x89, 0x5A, 0xCD, 0x6D, 0xEF, 0x05, 0x22, 0x2B, 0x72, 0xFF, 0x80, 0x7A, 0xDD, 0xF1, 0x59, 0xA7, 0x6F, 0x00, 0xB1,
+ 0xBD, 0x4D, 0x88, 0xD6, 0xE4, 0x8A, 0xDD, 0xA9, 0xFC, 0xD9, 0x01, 0x0A, 0x65, 0x8E, 0x52, 0xF9, 0x7E, 0x20, 0x72, 0x67, 0x0D, 0x5B, 0xEE, 0x67, 0x5B, 0x46, 0x4A, 0x15, 0xA2, 0x6F, 0x15, 0x2B, 0x5B, 0x9A, 0x93, 0x12, 0x4F, 0xF4, 0xAD, 0x49, 0xD0, 0x11, 0xF1, 0x7E, 0x40, 0xDE, 0x32, 0x96, 0x2E, 0xB3, 0xE8, 0x71, 0x60, 0x27, 0x6E, 0xA2, 0x71, 0x83, 0xC7, 0xFE, 0x0E, 0x8B, 0x31, 0x06, 0x64, 0xE1, 0x19, 0x02, 0xB9, 0x44, 0x25, 0x0C, 0x94, 0x64, 0x7E, 0x5F, 0x89, 0x4D, 0x7E, 0x99, 0x0B, 0x91, 0xB8, 0x22, 0xA5, 0x33, 0x92, 0xD3, 0x49, 0x07, 0x1D, 0xC6, 0x25, 0x4A, 0xD7, 0x6D, 0xE2, 0x94, 0x3F, 0xFA,
+ 0x10, 0x72, 0x59, 0x62, 0xF5, 0xC6, 0xD4, 0x3A, 0xEE, 0x8F, 0xBC, 0x9C, 0xBC, 0xFC, 0xC7, 0x37, 0xBF, 0x7C, 0xA0, 0x67, 0xB0, 0xFF, 0x0F, 0x29, 0xA0, 0xA2, 0x71, 0x6B, 0x21, 0x00, 0xF4, 0x54, 0xD9, 0x3D, 0x1B, 0xCE, 0xF4, 0xFE, 0x6F, 0xF5, 0x21, 0xCB, 0x47, 0x58, 0x17, 0xF6, 0x45, 0x2F, 0xA0, 0x3B, 0x8B, 0xD9, 0xB8, 0x8A, 0x33, 0x3F, 0x16, 0xE0, 0xC7, 0x8A, 0xB8, 0x11, 0x2F, 0xA8, 0x7E, 0x7D, 0xA7, 0x7B, 0x65, 0x27, 0x89, 0x3C, 0x67, 0x4D, 0xD5, 0x70, 0x28, 0x76, 0x60, 0x96, 0x68, 0xBF, 0xFB, 0xCD, 0x49, 0xE0, 0x8A, 0x7C, 0x6F, 0x76, 0x06, 0x48, 0x6D, 0x63, 0x67, 0x8A, 0x47, 0x82, 0x5E, 0x7F,
+ 0x0E, 0xAC, 0x46, 0xB6, 0xBC, 0x0A, 0x6D, 0xE2, 0x1A, 0x3A, 0x20, 0xA5, 0xC7, 0x81, 0x71, 0x6E, 0x2B, 0x16, 0x97, 0xD4, 0xFA, 0xC0, 0xDD, 0x72, 0x5B, 0x9F, 0xA3, 0x43, 0xF4, 0x85, 0xB1, 0xC6, 0xA8, 0xE0, 0x62, 0x81, 0x5D, 0xA5, 0x07, 0x29, 0x6A, 0x6A, 0x2D, 0xE1, 0x1D, 0xBE, 0x12, 0x6D, 0x42, 0x58, 0x6F, 0x4E, 0x30, 0x3D, 0xBF, 0x32, 0x11, 0x38, 0xBC, 0x36, 0x76, 0x60, 0xFC, 0x57, 0x2F, 0xD3, 0x9E, 0xC4, 0x1A, 0x92, 0xEA, 0xDE, 0x85, 0xFD, 0xE7, 0xAA, 0x30, 0xA6, 0x97, 0x2C, 0x36, 0x3B, 0x3B, 0x0E, 0x92, 0x52, 0xFF, 0x42, 0xD7, 0x62, 0x6C, 0xC1, 0x3A, 0xE7, 0x1B, 0x4E, 0x13, 0x8C, 0x95, 0xB3,
+ 0x4B, 0xA7, 0x9E, 0x42, 0x75, 0xA8, 0xCA, 0x63, 0x76, 0xC4, 0x45, 0x74, 0x96, 0x43, 0xD8, 0x86, 0x82, 0xBE, 0x37, 0xFF, 0x9B, 0xEB, 0xB7, 0x18, 0xA1, 0x2F, 0xE3, 0x6C, 0x08, 0xE8, 0x11, 0x96, 0x8C, 0x5E, 0x9E, 0x2B, 0xE7, 0xDB, 0x7D, 0x54, 0xE1, 0xDB, 0x1E, 0xD3, 0x8F, 0xB5, 0x19, 0x4B, 0xB2, 0x16, 0xDB, 0xCF, 0xEC, 0x88, 0x0B, 0x6C, 0x3C, 0xE4, 0xF2, 0xC4, 0xFF, 0x4D, 0x3E, 0x53, 0x52, 0x3A, 0x81, 0x0B, 0x6E, 0xAC, 0x95, 0xEA, 0x5A, 0x6E, 0x4D, 0x83, 0x23, 0x82, 0xC9, 0x90, 0x02, 0x74, 0x10, 0x2A, 0x6C, 0xFB, 0x97, 0x4F, 0x5F, 0x70, 0x8E, 0xF0, 0xB9 };
+
+ [Test]
+ public void EncryptedPrivateKey_Farscape ()
+ {
+ AssertEquals ("PKCS8.GetType", PKCS8.KeyInfo.EncryptedPrivateKey, PKCS8.GetType (pkcs8_der));
+ PKCS8.EncryptedPrivateKeyInfo p8 = new PKCS8.EncryptedPrivateKeyInfo (pkcs8_der);
+ AssertEquals ("Algorithm", "1.2.840.113549.1.12.1.3", p8.Algorithm);
+ AssertEquals ("EncryptedData", "90-14-B5-F0-B6-86-56-CB-FA-63-AD-9F-5A-59-6C-AD-00-3C-37-8A-C3-88-58-8B-D7-48-53-7A-C8-5B-0D-98-DD-8B-B3-EC-4C-AC-61-18-E3-5E-47-AD-C7-92-BC-D3-00-07-FF-1A-68-74-45-8E-D8-7C-9F-18-7B-D7-C8-47-BA-6B-19-F2-BF-7E-51-0B-4B-43-E8-B9-56-7E-D0-74-C7-DE-76-DB-FF-5C-6B-53-BE-31-06-AE-6C-8F-DC-49-04-71-74-EE-B8-06-CB-AD-86-B4-4E-B9-46-A1-03-5E-0E-A7-C7-37-6B-B0-8D-2D-81-1F-E3-C2-05-DE-EF-51-07-70-6E-35-9A-AD-19-5E-AF-EB-7F-EF-E4-AB-07-F3-F6-EA-FA-0E-83-65-06-3C-F3-BD-96-08-14-C5-34-26-ED-C0-10-CC-AE-2D-8F-BE-ED-98-0D-88-1B-1E-C7-37-F0-FC-DB-3C-E3-1B-66-52-45-6E-05-A6-D9-12-23-05-5F-E3-9F-7D-21-9B-2E-3E-9E-3C-EE-D1-9B-55-DE-57-60-A5-24-2D-C7-94-EC-FC-B1-6A-65-BD-85-02-5C-58-AA-5A-6A-F3-AC-6B-DD-0E-63-B2-4B-5B-67-3D-C3-BF-E4-C8-EF-3F-89-5A-CD-6D-EF-05-22-2B-72-FF-80-7A-DD-F1-59-A7-6F-00-B1-BD-4D-88-D6-E4-8A-DD-A9-FC-D9-01-0A-65-8E-52-F9-7E-20-72-67-0D-5B-EE-67-5B-46-4A-15-A2-6F-15-2B-5B-9A-93-12-4F-F4-AD-49-D0-11-F1-7E-40-DE-32-96-2E-B3-E8-71-60-27-6E-A2-71-83-C7-FE-0E-8B-31-06-64-E1-19-02-B9-44-25-0C-94-64-7E-5F-89-4D-7E-99-0B-91-B8-22-A5-33-92-D3-49-07-1D-C6-25-4A-D7-6D-E2-94-3F-FA-10-72-59-62-F5-C6-D4-3A-EE-8F-BC-9C-BC-FC-C7-37-BF-7C-A0-67-B0-FF-0F-29-A0-A2-71-6B-21-00-F4-54-D9-3D-1B-CE-F4-FE-6F-F5-21-CB-47-58-17-F6-45-2F-A0-3B-8B-D9-B8-8A-33-3F-16-E0-C7-8A-B8-11-2F-A8-7E-7D-A7-7B-65-27-89-3C-67-4D-D5-70-28-76-60-96-68-BF-FB-CD-49-E0-8A-7C-6F-76-06-48-6D-63-67-8A-47-82-5E-7F-0E-AC-46-B6-BC-0A-6D-E2-1A-3A-20-A5-C7-81-71-6E-2B-16-97-D4-FA-C0-DD-72-5B-9F-A3-43-F4-85-B1-C6-A8-E0-62-81-5D-A5-07-29-6A-6A-2D-E1-1D-BE-12-6D-42-58-6F-4E-30-3D-BF-32-11-38-BC-36-76-60-FC-57-2F-D3-9E-C4-1A-92-EA-DE-85-FD-E7-AA-30-A6-97-2C-36-3B-3B-0E-92-52-FF-42-D7-62-6C-C1-3A-E7-1B-4E-13-8C-95-B3-4B-A7-9E-42-75-A8-CA-63-76-C4-45-74-96-43-D8-86-82-BE-37-FF-9B-EB-B7-18-A1-2F-E3-6C-08-E8-11-96-8C-5E-9E-2B-E7-DB-7D-54-E1-DB-1E-D3-8F-B5-19-4B-B2-16-DB-CF-EC-88-0B-6C-3C-E4-F2-C4-FF-4D-3E-53-52-3A-81-0B-6E-AC-95-EA-5A-6E-4D-83-23-82-C9-90-02-74-10-2A-6C-FB-97-4F-5F-70-8E-F0-B9",
+ BitConverter.ToString (p8.EncryptedData));
+ AssertEquals ("Salt", "86-2A-A9-71-6D-A4-B8-2D", BitConverter.ToString (p8.Salt));
+ AssertEquals ("IterationCount", 2000, p8.IterationCount);
+ }
+
+ static public byte[] End_Certificate_CP_01_01_crtx = { 0x30, 0x82, 0x02, 0x78, 0x02, 0x01, 0x00, 0x30, 0x0D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x01, 0x05, 0x00, 0x04, 0x82, 0x02, 0x62, 0x30, 0x82, 0x02, 0x5E, 0x02, 0x01, 0x00, 0x02, 0x81, 0x81, 0x00, 0xC6, 0x34, 0xEC, 0x6F, 0x0C, 0xE0, 0x59, 0x0E, 0xBC, 0x5F, 0xBA, 0x2E, 0x93, 0xBB, 0x04, 0xA7, 0x03, 0xB9, 0x70, 0x8A, 0xB9, 0xD7, 0xE5, 0xD7, 0xE6, 0xCA, 0x4A, 0x8C, 0x23, 0xD8, 0x60, 0xB3, 0x6B, 0xCB, 0x88, 0x88, 0xC7, 0xD8, 0x48, 0x7E, 0x64, 0xF9, 0xF6, 0x1B, 0xE3, 0x79, 0x46, 0x41, 0xE4, 0x61, 0xF7, 0x25, 0x47, 0x71, 0xF3, 0x50, 0x94, 0x4E, 0xF2, 0x7C, 0x6A, 0x37, 0xB6, 0x0C,
+ 0x46, 0xBF, 0x9C, 0x96, 0xA5, 0xE2, 0xAF, 0x0C, 0xCA, 0x8B, 0xF0, 0x8C, 0xBA, 0x43, 0x4A, 0x08, 0x8E, 0x6A, 0x87, 0xF3, 0x46, 0x4E, 0xCF, 0x6D, 0x5D, 0x52, 0x47, 0xAB, 0x99, 0xC7, 0x24, 0xCD, 0x31, 0x0E, 0x7D, 0xEF, 0xD1, 0xD9, 0xF3, 0x69, 0x24, 0xFB, 0xFC, 0x33, 0x6E, 0x29, 0xAB, 0x6F, 0x52, 0x75, 0x80, 0x2A, 0xBB, 0xE0, 0xA9, 0x2C, 0x31, 0xC5, 0xB7, 0x0B, 0x3D, 0x3B, 0xEA, 0xB5, 0x02, 0x03, 0x01, 0x00, 0x01, 0x02, 0x81, 0x81, 0x00, 0xBC, 0x98, 0x69, 0x0C, 0x75, 0xAD, 0x17, 0x30, 0x6D, 0x4F, 0x8C, 0xE1, 0x7A, 0xD2, 0x2D, 0xE8, 0x19, 0x24, 0x1F, 0x10, 0xF1, 0x2A, 0x9C, 0x59, 0xE6, 0x11, 0x40,
+ 0x03, 0xBE, 0xAB, 0xC9, 0xBF, 0x8F, 0x67, 0x38, 0x40, 0x26, 0x20, 0x07, 0x42, 0xB5, 0x24, 0x1E, 0xE8, 0x84, 0x76, 0xC5, 0xC2, 0x36, 0xE4, 0x7C, 0x7C, 0xAD, 0x51, 0xA0, 0xDA, 0x60, 0x74, 0x0A, 0x49, 0x15, 0xEC, 0x72, 0xBB, 0xE5, 0xE3, 0xE0, 0x3B, 0xF5, 0x51, 0x3B, 0x5D, 0xA4, 0xAD, 0xC6, 0x5D, 0x9F, 0x27, 0x69, 0xEA, 0x97, 0x29, 0x7E, 0x9C, 0xFC, 0x4F, 0x2D, 0xAF, 0xC5, 0xDC, 0xFC, 0xF4, 0xA5, 0x4A, 0x12, 0x18, 0x49, 0x28, 0x5F, 0x7F, 0x58, 0x7A, 0xC6, 0x3E, 0x79, 0xDF, 0xBA, 0x06, 0xAE, 0x6D, 0xCC, 0xB4, 0x71, 0x07, 0xD8, 0x18, 0xFB, 0x1E, 0x6D, 0x8D, 0x72, 0x85, 0xF7, 0xBD, 0x97, 0xA3, 0x85,
+ 0xF5, 0x02, 0x41, 0x00, 0xFE, 0x03, 0x77, 0x1A, 0x1B, 0x13, 0x48, 0x07, 0xE0, 0xD2, 0xEB, 0x84, 0x41, 0x39, 0x06, 0xB1, 0x13, 0xD0, 0xE9, 0xA5, 0xB8, 0xAC, 0x53, 0x33, 0x41, 0x5D, 0xB0, 0xF0, 0xCC, 0x61, 0x59, 0xA7, 0x10, 0x91, 0xCA, 0x60, 0x40, 0x17, 0x75, 0xFB, 0x98, 0x7B, 0x84, 0x4B, 0xC7, 0x2F, 0x1D, 0x15, 0xDE, 0x37, 0xC2, 0xA0, 0xE0, 0xBF, 0xA1, 0x67, 0x56, 0x8B, 0xF5, 0x08, 0xB9, 0x82, 0x99, 0x5B, 0x02, 0x41, 0x00, 0xC7, 0xC1, 0xBB, 0xB1, 0xD0, 0x5E, 0x72, 0x8C, 0x1A, 0x68, 0xCF, 0x95, 0xC7, 0x23, 0x70, 0xB9, 0xB1, 0x5F, 0x43, 0x54, 0x10, 0x84, 0x9A, 0x63, 0x77, 0xAA, 0xFE, 0x98, 0x25,
+ 0x0B, 0xCF, 0x0A, 0x0C, 0xCB, 0xAA, 0xE3, 0x36, 0xD3, 0xE3, 0xA1, 0xA9, 0x19, 0x26, 0xD4, 0x12, 0x88, 0xDC, 0x3B, 0xC4, 0x12, 0x27, 0x80, 0x07, 0xFC, 0x4C, 0x3D, 0xBB, 0x3A, 0x3D, 0xBE, 0x84, 0x7D, 0xB9, 0x2F, 0x02, 0x41, 0x00, 0xD3, 0x5F, 0xFE, 0xD4, 0x72, 0x83, 0x71, 0x05, 0x5D, 0x49, 0x27, 0x43, 0x3F, 0x23, 0x3D, 0x36, 0x4D, 0xCF, 0x23, 0x1F, 0x0C, 0xB6, 0x19, 0xE6, 0x25, 0x16, 0xDA, 0x0F, 0x07, 0x84, 0x5B, 0x1E, 0x72, 0xE3, 0x5F, 0x0D, 0x09, 0x48, 0x7C, 0x9D, 0x89, 0x1D, 0xFF, 0xD1, 0x2F, 0x47, 0x3D, 0x64, 0xDD, 0x2E, 0x79, 0x7F, 0x76, 0x87, 0x00, 0xC1, 0x05, 0x7C, 0x21, 0xC3, 0xC8, 0xDB,
+ 0xAC, 0xD1, 0x02, 0x40, 0x0B, 0xCD, 0x46, 0x69, 0x9B, 0x05, 0xF9, 0x7E, 0x8D, 0x90, 0xE3, 0xB2, 0xD5, 0xB1, 0x22, 0x57, 0xD6, 0x42, 0xEA, 0x97, 0x6C, 0xE2, 0x68, 0xBC, 0xB7, 0xB5, 0x42, 0x95, 0x7A, 0x9A, 0xD8, 0x00, 0xA0, 0x00, 0xE8, 0x77, 0xC4, 0x25, 0x80, 0xAD, 0x6C, 0x70, 0x2F, 0xFB, 0x17, 0x9D, 0x3E, 0x65, 0xC9, 0x8F, 0xC9, 0x05, 0xA7, 0x73, 0x20, 0x8E, 0x05, 0x21, 0xCB, 0xC4, 0x15, 0xCF, 0xD7, 0xC1, 0x02, 0x41, 0x00, 0xDE, 0x50, 0xE1, 0x6D, 0xF6, 0x32, 0x35, 0x5C, 0xCA, 0x5F, 0xB1, 0x9D, 0x84, 0x25, 0x17, 0x9E, 0x72, 0xBE, 0x00, 0xCE, 0x59, 0xD5, 0x53, 0xAE, 0xCC, 0x94, 0x89, 0x5C, 0xA1,
+ 0x8A, 0x29, 0x37, 0x2D, 0x47, 0xB6, 0x30, 0xE4, 0x04, 0x65, 0x51, 0xD5, 0xB1, 0x63, 0x85, 0x3B, 0x73, 0xD2, 0xF7, 0xA3, 0x2B, 0x19, 0x8F, 0xB2, 0xBC, 0x08, 0xFB, 0xE3, 0x0F, 0xDC, 0xDD, 0x6B, 0x44, 0x95, 0x84 };
+
+ static public byte[] End_Certificate_CP_01_02_crtx = { 0x30, 0x82, 0x02, 0x75, 0x02, 0x01, 0x00, 0x30, 0x0D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x01, 0x05, 0x00, 0x04, 0x82, 0x02, 0x5F, 0x30, 0x82, 0x02, 0x5B, 0x02, 0x01, 0x00, 0x02, 0x81, 0x81, 0x00, 0xD6, 0x39, 0x9E, 0x21, 0x93, 0xE2, 0xBA, 0x35, 0x7F, 0xE5, 0xF8, 0xE8, 0x87, 0x0B, 0x8A, 0x5F, 0x28, 0x25, 0x85, 0xB7, 0xE5, 0xCC, 0xDA, 0x7F, 0xD3, 0xC7, 0x09, 0x2A, 0x63, 0xE9, 0xAD, 0x8F, 0xD0, 0xA8, 0xEF, 0xBA, 0xCF, 0x3C, 0xFB, 0x55, 0x03, 0xB9, 0x83, 0x29, 0x4E, 0x0E, 0x89, 0x84, 0xFB, 0xE2, 0x62, 0x16, 0x1F, 0x9D, 0x87, 0x40, 0x16, 0x6B, 0xF8, 0xF4, 0x66, 0x38, 0x58, 0x74,
+ 0x67, 0xD4, 0xB5, 0xA1, 0x3A, 0x4B, 0x6F, 0x13, 0x4B, 0x08, 0x37, 0x3A, 0x3A, 0x64, 0x0A, 0x06, 0x8E, 0xA2, 0x7B, 0x14, 0x88, 0xB7, 0xF8, 0xCE, 0x6A, 0xD1, 0x45, 0x9B, 0x39, 0x93, 0x67, 0xBF, 0x0A, 0xAB, 0xDB, 0x37, 0x9D, 0xFA, 0xCE, 0x54, 0x0F, 0x37, 0x82, 0x09, 0x8F, 0x0D, 0x33, 0xE4, 0xB8, 0x6E, 0x46, 0xC1, 0xCC, 0x4F, 0x80, 0x5A, 0xB4, 0xBD, 0x19, 0x80, 0x27, 0x40, 0x84, 0x49, 0x02, 0x03, 0x01, 0x00, 0x01, 0x02, 0x81, 0x80, 0x14, 0x95, 0x5A, 0xAD, 0x4D, 0x41, 0x56, 0xB4, 0xF7, 0x42, 0x08, 0x85, 0x87, 0x1C, 0x43, 0xC2, 0x5A, 0xE0, 0x28, 0x16, 0x00, 0x5D, 0x8B, 0x8D, 0x06, 0xB3, 0x34, 0x1D,
+ 0x3F, 0x96, 0x5F, 0x57, 0xD7, 0x2B, 0xB4, 0x45, 0x15, 0xCE, 0x7D, 0x33, 0xB0, 0xF4, 0xED, 0x36, 0x55, 0xCA, 0xAD, 0xC9, 0xFA, 0x4D, 0xC9, 0x30, 0xE8, 0xFE, 0xC0, 0xD5, 0x16, 0x92, 0x6F, 0x4C, 0x44, 0x5A, 0x1B, 0x9D, 0x7E, 0xAE, 0xB8, 0x01, 0x6D, 0x38, 0x9D, 0xDC, 0x93, 0x68, 0xAB, 0x93, 0xD6, 0xC0, 0x8A, 0x8A, 0x63, 0xB4, 0xD6, 0xDA, 0x21, 0xC1, 0xA0, 0x28, 0x8C, 0x24, 0xC4, 0x27, 0xE1, 0x4B, 0x30, 0xD2, 0x2D, 0x87, 0x62, 0xF9, 0x17, 0x75, 0x21, 0x5E, 0xE1, 0x3C, 0xE2, 0x2D, 0x92, 0x03, 0xC6, 0xA1, 0x8D, 0x1D, 0xE9, 0x67, 0xF4, 0xCE, 0xFF, 0xAC, 0x52, 0x86, 0xD2, 0xF5, 0x0F, 0xEB, 0x03, 0x01,
+ 0x02, 0x41, 0x00, 0xED, 0x6A, 0xAE, 0xA7, 0x33, 0xB0, 0xB8, 0x86, 0x36, 0x91, 0xBA, 0xE7, 0xD2, 0xDD, 0x15, 0x3A, 0x97, 0xA2, 0x66, 0x31, 0x98, 0x24, 0xA6, 0x0D, 0xE7, 0x09, 0xE3, 0xBD, 0x36, 0x79, 0x91, 0xF2, 0x5E, 0x23, 0xAA, 0x21, 0xC9, 0x71, 0x43, 0x24, 0x10, 0xFA, 0xF0, 0xE6, 0xFC, 0xE4, 0xC6, 0x1F, 0x08, 0x45, 0xE8, 0x91, 0x74, 0x13, 0x69, 0x63, 0xA5, 0x40, 0x8F, 0x38, 0x44, 0x2B, 0x54, 0x69, 0x02, 0x41, 0x00, 0xE6, 0xFE, 0x39, 0x8B, 0x6F, 0xDB, 0x44, 0xCA, 0xE7, 0x72, 0xD3, 0xCA, 0x09, 0x5B, 0x3D, 0xB1, 0x53, 0x85, 0x29, 0x36, 0xFC, 0xF1, 0xB9, 0xD8, 0x1F, 0x64, 0x02, 0xD4, 0xF7, 0xF5,
+ 0x71, 0xE5, 0x9F, 0x17, 0xD7, 0xF3, 0x9F, 0x5A, 0x3A, 0xA6, 0xA3, 0x62, 0x46, 0xF6, 0x93, 0x3D, 0xD3, 0xCD, 0x18, 0xF2, 0x12, 0xBD, 0x68, 0x02, 0xAA, 0x91, 0x55, 0xDA, 0x64, 0x26, 0xD7, 0x16, 0x34, 0xE1, 0x02, 0x40, 0x60, 0x3F, 0xF4, 0xC8, 0x72, 0x4B, 0x3D, 0xB3, 0xA3, 0xA1, 0xD6, 0xFD, 0x2E, 0xDE, 0x54, 0x41, 0xE9, 0xC1, 0x7B, 0xDE, 0xB5, 0x48, 0x7E, 0x4D, 0x7A, 0x91, 0xE6, 0xD3, 0x09, 0xA7, 0xA5, 0x84, 0x75, 0xA7, 0xCD, 0xCC, 0x5E, 0xC7, 0x5D, 0x29, 0xDC, 0xFC, 0x6E, 0xF7, 0xA6, 0x24, 0xF5, 0x31, 0x15, 0x80, 0x89, 0xF5, 0x95, 0xF2, 0x5C, 0xB2, 0x7A, 0x07, 0x3F, 0x48, 0xD7, 0x52, 0x1D, 0xA9,
+ 0x02, 0x40, 0x40, 0x1B, 0xFC, 0xC2, 0x9B, 0x57, 0xE2, 0xDE, 0xE1, 0x9F, 0xB7, 0xF2, 0x11, 0xE8, 0xB5, 0xD5, 0x9A, 0x55, 0x91, 0xDB, 0xC6, 0x16, 0x1C, 0xBB, 0x43, 0xF3, 0x10, 0xEA, 0x24, 0xAB, 0x85, 0x61, 0xF2, 0x66, 0xBE, 0xB3, 0xC9, 0xDD, 0x53, 0xFB, 0xDD, 0xCA, 0xAF, 0xE1, 0x4D, 0x7A, 0x52, 0x67, 0x50, 0xEE, 0x16, 0x8F, 0x64, 0xE7, 0xA0, 0x89, 0x57, 0xA7, 0x96, 0x36, 0x45, 0x69, 0xCF, 0x61, 0x02, 0x40, 0x3D, 0x9E, 0xE3, 0x29, 0xD6, 0xBD, 0x59, 0xFF, 0xA5, 0xC3, 0xAC, 0x57, 0xCB, 0x74, 0xFE, 0xB0, 0xC3, 0x67, 0x34, 0xA8, 0x40, 0xEB, 0x04, 0x88, 0xC3, 0xC2, 0x74, 0x4F, 0x69, 0x77, 0x13, 0x48,
+ 0x8A, 0x97, 0x3C, 0xC2, 0x4B, 0xCD, 0xE8, 0xE0, 0x97, 0x98, 0xA2, 0x3F, 0xB6, 0xE2, 0x71, 0xD3, 0x65, 0x9F, 0x5A, 0xC6, 0xC8, 0xAE, 0xFE, 0xBA, 0xB1, 0xED, 0xDA, 0x08, 0x8A, 0x5B, 0x7B, 0x12 };
+
+ [Test]
+ public void PrivateKeyInfo_End_Certificate_CP_01_01 ()
+ {
+ AssertEquals ("PKCS8.GetType", PKCS8.KeyInfo.PrivateKey, PKCS8.GetType (End_Certificate_CP_01_01_crtx));
+ PKCS8.PrivateKeyInfo p8 = new PKCS8.PrivateKeyInfo (End_Certificate_CP_01_01_crtx);
+ AssertEquals ("Algorithm", "1.2.840.113549.1.1.1", p8.Algorithm);
+ AssertEquals ("Attributes", 0, p8.Attributes.Count);
+ AssertEquals ("PrivateKey", "30-82-02-5E-02-01-00-02-81-81-00-C6-34-EC-6F-0C-E0-59-0E-BC-5F-BA-2E-93-BB-04-A7-03-B9-70-8A-B9-D7-E5-D7-E6-CA-4A-8C-23-D8-60-B3-6B-CB-88-88-C7-D8-48-7E-64-F9-F6-1B-E3-79-46-41-E4-61-F7-25-47-71-F3-50-94-4E-F2-7C-6A-37-B6-0C-46-BF-9C-96-A5-E2-AF-0C-CA-8B-F0-8C-BA-43-4A-08-8E-6A-87-F3-46-4E-CF-6D-5D-52-47-AB-99-C7-24-CD-31-0E-7D-EF-D1-D9-F3-69-24-FB-FC-33-6E-29-AB-6F-52-75-80-2A-BB-E0-A9-2C-31-C5-B7-0B-3D-3B-EA-B5-02-03-01-00-01-02-81-81-00-BC-98-69-0C-75-AD-17-30-6D-4F-8C-E1-7A-D2-2D-E8-19-24-1F-10-F1-2A-9C-59-E6-11-40-03-BE-AB-C9-BF-8F-67-38-40-26-20-07-42-B5-24-1E-E8-84-76-C5-C2-36-E4-7C-7C-AD-51-A0-DA-60-74-0A-49-15-EC-72-BB-E5-E3-E0-3B-F5-51-3B-5D-A4-AD-C6-5D-9F-27-69-EA-97-29-7E-9C-FC-4F-2D-AF-C5-DC-FC-F4-A5-4A-12-18-49-28-5F-7F-58-7A-C6-3E-79-DF-BA-06-AE-6D-CC-B4-71-07-D8-18-FB-1E-6D-8D-72-85-F7-BD-97-A3-85-F5-02-41-00-FE-03-77-1A-1B-13-48-07-E0-D2-EB-84-41-39-06-B1-13-D0-E9-A5-B8-AC-53-33-41-5D-B0-F0-CC-61-59-A7-10-91-CA-60-40-17-75-FB-98-7B-84-4B-C7-2F-1D-15-DE-37-C2-A0-E0-BF-A1-67-56-8B-F5-08-B9-82-99-5B-02-41-00-C7-C1-BB-B1-D0-5E-72-8C-1A-68-CF-95-C7-23-70-B9-B1-5F-43-54-10-84-9A-63-77-AA-FE-98-25-0B-CF-0A-0C-CB-AA-E3-36-D3-E3-A1-A9-19-26-D4-12-88-DC-3B-C4-12-27-80-07-FC-4C-3D-BB-3A-3D-BE-84-7D-B9-2F-02-41-00-D3-5F-FE-D4-72-83-71-05-5D-49-27-43-3F-23-3D-36-4D-CF-23-1F-0C-B6-19-E6-25-16-DA-0F-07-84-5B-1E-72-E3-5F-0D-09-48-7C-9D-89-1D-FF-D1-2F-47-3D-64-DD-2E-79-7F-76-87-00-C1-05-7C-21-C3-C8-DB-AC-D1-02-40-0B-CD-46-69-9B-05-F9-7E-8D-90-E3-B2-D5-B1-22-57-D6-42-EA-97-6C-E2-68-BC-B7-B5-42-95-7A-9A-D8-00-A0-00-E8-77-C4-25-80-AD-6C-70-2F-FB-17-9D-3E-65-C9-8F-C9-05-A7-73-20-8E-05-21-CB-C4-15-CF-D7-C1-02-41-00-DE-50-E1-6D-F6-32-35-5C-CA-5F-B1-9D-84-25-17-9E-72-BE-00-CE-59-D5-53-AE-CC-94-89-5C-A1-8A-29-37-2D-47-B6-30-E4-04-65-51-D5-B1-63-85-3B-73-D2-F7-A3-2B-19-8F-B2-BC-08-FB-E3-0F-DC-DD-6B-44-95-84", BitConverter.ToString (p8.PrivateKey));
+ AssertEquals ("Version", 0, p8.Version);
+ }
+
+ [Test]
+ public void PrivateKeyInfo_End_Certificate_CP_01_02 ()
+ {
+ PKCS8.PrivateKeyInfo p8 = new PKCS8.PrivateKeyInfo (End_Certificate_CP_01_02_crtx);
+ AssertEquals ("Algorithm", "1.2.840.113549.1.1.1", p8.Algorithm);
+ AssertEquals ("Attributes", 0, p8.Attributes.Count);
+ AssertEquals ("PrivateKey", "30-82-02-5B-02-01-00-02-81-81-00-D6-39-9E-21-93-E2-BA-35-7F-E5-F8-E8-87-0B-8A-5F-28-25-85-B7-E5-CC-DA-7F-D3-C7-09-2A-63-E9-AD-8F-D0-A8-EF-BA-CF-3C-FB-55-03-B9-83-29-4E-0E-89-84-FB-E2-62-16-1F-9D-87-40-16-6B-F8-F4-66-38-58-74-67-D4-B5-A1-3A-4B-6F-13-4B-08-37-3A-3A-64-0A-06-8E-A2-7B-14-88-B7-F8-CE-6A-D1-45-9B-39-93-67-BF-0A-AB-DB-37-9D-FA-CE-54-0F-37-82-09-8F-0D-33-E4-B8-6E-46-C1-CC-4F-80-5A-B4-BD-19-80-27-40-84-49-02-03-01-00-01-02-81-80-14-95-5A-AD-4D-41-56-B4-F7-42-08-85-87-1C-43-C2-5A-E0-28-16-00-5D-8B-8D-06-B3-34-1D-3F-96-5F-57-D7-2B-B4-45-15-CE-7D-33-B0-F4-ED-36-55-CA-AD-C9-FA-4D-C9-30-E8-FE-C0-D5-16-92-6F-4C-44-5A-1B-9D-7E-AE-B8-01-6D-38-9D-DC-93-68-AB-93-D6-C0-8A-8A-63-B4-D6-DA-21-C1-A0-28-8C-24-C4-27-E1-4B-30-D2-2D-87-62-F9-17-75-21-5E-E1-3C-E2-2D-92-03-C6-A1-8D-1D-E9-67-F4-CE-FF-AC-52-86-D2-F5-0F-EB-03-01-02-41-00-ED-6A-AE-A7-33-B0-B8-86-36-91-BA-E7-D2-DD-15-3A-97-A2-66-31-98-24-A6-0D-E7-09-E3-BD-36-79-91-F2-5E-23-AA-21-C9-71-43-24-10-FA-F0-E6-FC-E4-C6-1F-08-45-E8-91-74-13-69-63-A5-40-8F-38-44-2B-54-69-02-41-00-E6-FE-39-8B-6F-DB-44-CA-E7-72-D3-CA-09-5B-3D-B1-53-85-29-36-FC-F1-B9-D8-1F-64-02-D4-F7-F5-71-E5-9F-17-D7-F3-9F-5A-3A-A6-A3-62-46-F6-93-3D-D3-CD-18-F2-12-BD-68-02-AA-91-55-DA-64-26-D7-16-34-E1-02-40-60-3F-F4-C8-72-4B-3D-B3-A3-A1-D6-FD-2E-DE-54-41-E9-C1-7B-DE-B5-48-7E-4D-7A-91-E6-D3-09-A7-A5-84-75-A7-CD-CC-5E-C7-5D-29-DC-FC-6E-F7-A6-24-F5-31-15-80-89-F5-95-F2-5C-B2-7A-07-3F-48-D7-52-1D-A9-02-40-40-1B-FC-C2-9B-57-E2-DE-E1-9F-B7-F2-11-E8-B5-D5-9A-55-91-DB-C6-16-1C-BB-43-F3-10-EA-24-AB-85-61-F2-66-BE-B3-C9-DD-53-FB-DD-CA-AF-E1-4D-7A-52-67-50-EE-16-8F-64-E7-A0-89-57-A7-96-36-45-69-CF-61-02-40-3D-9E-E3-29-D6-BD-59-FF-A5-C3-AC-57-CB-74-FE-B0-C3-67-34-A8-40-EB-04-88-C3-C2-74-4F-69-77-13-48-8A-97-3C-C2-4B-CD-E8-E0-97-98-A2-3F-B6-E2-71-D3-65-9F-5A-C6-C8-AE-FE-BA-B1-ED-DA-08-8A-5B-7B-12", BitConverter.ToString (p8.PrivateKey));
+ AssertEquals ("Version", 0, p8.Version);
+ // static
+ RSA rsa = PKCS8.PrivateKeyInfo.DecodeRSA (p8.PrivateKey);
+ AssertEquals ("DecodeRSA", "<RSAKeyValue><Modulus>1jmeIZPiujV/5fjohwuKXyglhbflzNp/08cJKmPprY/QqO+6zzz7VQO5gylODomE++JiFh+dh0AWa/j0ZjhYdGfUtaE6S28TSwg3OjpkCgaOonsUiLf4zmrRRZs5k2e/CqvbN536zlQPN4IJjw0z5LhuRsHMT4BatL0ZgCdAhEk=</Modulus><Exponent>AQAB</Exponent><P>7WqupzOwuIY2kbrn0t0VOpeiZjGYJKYN5wnjvTZ5kfJeI6ohyXFDJBD68Ob85MYfCEXokXQTaWOlQI84RCtUaQ==</P><Q>5v45i2/bRMrnctPKCVs9sVOFKTb88bnYH2QC1Pf1ceWfF9fzn1o6pqNiRvaTPdPNGPISvWgCqpFV2mQm1xY04Q==</Q><DP>YD/0yHJLPbOjodb9Lt5UQenBe961SH5NepHm0wmnpYR1p83MXsddKdz8bvemJPUxFYCJ9ZXyXLJ6Bz9I11IdqQ==</DP><DQ>QBv8wptX4t7hn7fyEei11ZpVkdvGFhy7Q/MQ6iSrhWHyZr6zyd1T+93Kr+FNelJnUO4Wj2TnoIlXp5Y2RWnPYQ==</DQ><InverseQ>PZ7jKda9Wf+lw6xXy3T+sMNnNKhA6wSIw8J0T2l3E0iKlzzCS83o4JeYoj+24nHTZZ9axsiu/rqx7doIilt7Eg==</InverseQ><D>FJVarU1BVrT3QgiFhxxDwlrgKBYAXYuNBrM0HT+WX1fXK7RFFc59M7D07TZVyq3J+k3JMOj+wNUWkm9MRFobnX6uuAFtOJ3ck2irk9bAiopjtNbaIcGgKIwkxCfhSzDSLYdi+Rd1IV7hPOItkgPGoY0d6Wf0zv+sUobS9Q/rAwE=</D></RSAKeyValue>", rsa.ToXmlString (true));
+ }
+
+ [Test]
+ [ExpectedException (typeof (CryptographicException))]
+ public void PrivateKeyInfo_NotDSA ()
+ {
+ PKCS8.PrivateKeyInfo p8 = new PKCS8.PrivateKeyInfo (End_Certificate_CP_01_02_crtx);
+ DSAParameters p = new DSAParameters ();
+ DSA dsa = PKCS8.PrivateKeyInfo.DecodeDSA (p8.PrivateKey, p);
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/ChangeLog b/mcs/class/Novell.Directory.Ldap/ChangeLog
new file mode 100644
index 00000000000..fd3b32fae40
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/ChangeLog
@@ -0,0 +1,22 @@
+2003-11-14 Sunil Kumar <sunilk@novell.com>
+
+ * Changed the Directory structure and Class file names as per the Microsoft Standards.
+
+ * Changed the build scripts accordingly
+
+2003-11-15 Sunil Kumar <sunilk@novell.com>
+
+ * Changed the LdapConnection public Method name as per MS naming convention
+
+ * Added the Authors description
+
+2003-11-16 Sunil Kumar <sunilk@novell.com>
+
+ * Added LDAP controls in Novell.Directory.Ldap.Controls
+
+ * Added Samples for LDAP controls
+
+2003-11-21 Sunil Kumar <sunilk@novell.com>
+
+ * Changed the linux build script to replace corlib.dll
+ with mscorlib.dll
diff --git a/mcs/class/Novell.Directory.Ldap/Makefile b/mcs/class/Novell.Directory.Ldap/Makefile
new file mode 100644
index 00000000000..ba179dc23aa
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Makefile
@@ -0,0 +1,13 @@
+thisdir = class/Novell.Directory.Ldap
+SUBDIRS =
+include ../../build/rules.make
+
+LIBRARY = Novell.Directory.Ldap.dll
+LIB_MCS_FLAGS = \
+ /nowarn:649 /nowarn:169 /nowarn:219 /nowarn:168 \
+ /r:$(corlib) \
+ /r:System.dll
+
+NO_TEST = yes
+
+include ../../build/library.make
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1Boolean.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1Boolean.cs
new file mode 100755
index 00000000000..32928bd898a
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1Boolean.cs
@@ -0,0 +1,122 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.Asn1.Asn1Boolean.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+
+namespace Novell.Directory.Ldap.Asn1
+{
+
+ /// <summary> This class encapsulates the ASN.1 BOOLEAN type.</summary>
+ [CLSCompliantAttribute(true)]
+ public class Asn1Boolean:Asn1Object
+ {
+
+ private bool content;
+
+ /// <summary> ASN.1 BOOLEAN tag definition.</summary>
+ public const int TAG = 0x01;
+
+ /// <summary> ID is added for Optimization.
+ ///
+ /// <p>ID needs only be one Value for every instance,
+ /// thus we create it only once.</p>
+ /// </summary>
+ public static readonly Asn1Identifier ID = new Asn1Identifier(Asn1Identifier.UNIVERSAL, false, TAG);
+ /* Constructors for Asn1Boolean
+ */
+
+ /// <summary> Call this constructor to construct an Asn1Boolean
+ /// object from a boolean value.
+ ///
+ /// </summary>
+ /// <param name="content">The boolean value to be contained in the
+ /// this Asn1Boolean object
+ /// </param>
+ public Asn1Boolean(bool content):base(ID)
+ {
+ this.content = content;
+ return ;
+ }
+
+ /// <summary> Constructs an Asn1Boolean object by decoding data from an
+ /// input stream.
+ ///
+ /// </summary>
+ /// <param name="dec">The decoder object to use when decoding the
+ /// input stream. Sometimes a developer might want to pass
+ /// in his/her own decoder object<br>
+ ///
+ /// </param>
+ /// <param name="in">A byte stream that contains the encoded ASN.1
+ ///
+ /// </param>
+ [CLSCompliantAttribute(false)]
+ public Asn1Boolean(Asn1Decoder dec, System.IO.Stream in_Renamed, int len):base(ID)
+ {
+ content = ((System.Boolean) dec.decodeBoolean(in_Renamed, len));
+ return ;
+ }
+
+ /* Asn1Object implementation
+ */
+
+ /// <summary> Encode the current instance into the
+ /// specified output stream using the specified encoder object.
+ ///
+ /// </summary>
+ /// <param name="enc">Encoder object to use when encoding self.<br>
+ ///
+ /// </param>
+ /// <param name="out">The output stream onto which the encoded byte
+ /// stream is written.
+ /// </param>
+ public override void encode(Asn1Encoder enc, System.IO.Stream out_Renamed)
+ {
+ enc.encode(this, out_Renamed);
+ return ;
+ }
+
+ /* Asn1Boolean specific methods
+ */
+
+ /// <summary> Returns the content of this Asn1Boolean as a boolean.</summary>
+ public bool booleanValue()
+ {
+ return content;
+ }
+
+ /// <summary> Returns a String representation of this Asn1Boolean object.</summary>
+ public override System.String ToString()
+ {
+ return base.ToString() + "BOOLEAN: " + content;
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1Choice.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1Choice.cs
new file mode 100755
index 00000000000..71cb109e35a
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1Choice.cs
@@ -0,0 +1,149 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.Asn1.Asn1Choice.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+
+namespace Novell.Directory.Ldap.Asn1
+{
+
+ /// <summary> The Asn1Choice object represents the choice of any Asn1Object. All
+ /// Asn1Object methods are delegated to the object this Asn1Choice contains.
+ /// </summary>
+ /* Can a CHOICE contain anything BUT a TAGGED Type?
+ */
+ [CLSCompliantAttribute(true)]
+ public class Asn1Choice:Asn1Object
+ {
+ /// <summary> Sets the CHOICE value stored in this Asn1Choice.
+ ///
+ /// </summary>
+ /// <param name="content">The Asn1Object that this Asn1Choice will
+ /// encode. Since all Asn1 objects are derived from Asn1Object
+ /// any basic type can be passed in.
+ /// </param>
+ [CLSCompliantAttribute(false)]
+ virtual protected internal Asn1Object ChoiceValue
+ {
+ set
+ {
+ this.content = value;
+ return ;
+ }
+
+ }
+
+ private Asn1Object content;
+
+ /* Constructors for Asn1Choice
+ */
+
+ /// <summary> Constructs an Asn1Choice object using an Asn1Object value.
+ ///
+ /// </summary>
+ /// <param name="content">The Asn1Object that this Asn1Choice will
+ /// encode. Since all Asn1 objects are derived from Asn1Object
+ /// any basic type can be passed in.
+ /// </param>
+ public Asn1Choice(Asn1Object content):base(null)
+ {
+ this.content = content;
+ return ;
+ }
+
+ /// <summary> No arg Constructor. This is used by Filter, who subsequently sets the
+ /// content after parsing the RFC 2254 Search Filter String.
+ /// </summary>
+ protected internal Asn1Choice():base(null)
+ {
+ this.content = null;
+ return ;
+ }
+
+ /* Asn1Object implementation
+ */
+
+
+ /// <summary> Call this method to encode the contents of this Asn1Choice
+ /// instance into the specified output stream using the
+ /// specified encoder object.
+ ///
+ /// </summary>
+ /// <param name="enc">Encoder object to use when encoding self.<br>
+ ///
+ /// </param>
+ /// <param name="out">The output stream onto which the encoded byte
+ /// stream is written.
+ /// </param>
+ public override void encode(Asn1Encoder enc, System.IO.Stream out_Renamed)
+ {
+ content.encode(enc, out_Renamed);
+ return ;
+ }
+
+ /* Asn1Choice specific methods
+ */
+
+ /// <summary> Returns the CHOICE value stored in this Asn1Choice
+ /// as an Asn1Object.
+ /// </summary>
+ public Asn1Object choiceValue()
+ {
+ return content;
+ }
+
+ /// <summary> This method will return the Asn1Identifier of the
+ /// encoded Asn1Object.We override the parent method
+ /// as the identifier of an Asn1Choice depends on the
+ /// type of the object encoded by this Asn1Choice.
+ /// </summary>
+ public override Asn1Identifier getIdentifier()
+ {
+ return content.getIdentifier();
+ }
+
+ /// <summary> Sets the identifier of the contained Asn1Object. We
+ /// override the parent method as the identifier of
+ /// an Asn1Choice depends on the type of the object
+ /// encoded by this Asn1Choice.
+ /// </summary>
+ public override void setIdentifier(Asn1Identifier id)
+ {
+ content.setIdentifier(id);
+ return ;
+ }
+
+ /// <summary> Return a String representation of this Asn1Object.</summary>
+ public override System.String ToString()
+ {
+ return content.ToString();
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1Decoder.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1Decoder.cs
new file mode 100755
index 00000000000..4136d056589
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1Decoder.cs
@@ -0,0 +1,194 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.Asn1.Asn1Decoder.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+
+namespace Novell.Directory.Ldap.Asn1
+{
+
+ /// <summary> This interface defines the methods for decoding each of the ASN.1 types.
+ ///
+ /// Decoders which implement this interface may be used to decode any of the
+ /// Asn1Object data types.
+ ///
+ /// <p>This package also provides the BERDecoder class that can be used to
+ /// BER decode ASN.1 classes. However an application might chose to use
+ /// its own decoder class.
+ ///
+ /// <p>This interface thus allows an application to use this package to
+ /// decode ASN.1 objects using other decoding rules if needed.
+ ///
+ /// <p>Note that Ldap packets are required to be BER encoded. Since this package
+ /// includes a BER decoder no application provided decoder is needed for
+ /// building Ldap packets.
+ /// </summary>
+ [CLSCompliantAttribute(false)]
+ public interface Asn1Decoder : System.Runtime.Serialization.ISerializable
+ {
+
+ /// <summary> Decode an encoded value into an Asn1Object from a byte array.
+ ///
+ /// </summary>
+ /// <param name="value">A byte array that points to the encoded Asn1 data
+ /// </param>
+ Asn1Object decode(sbyte[] value_Renamed);
+
+
+ /// <summary> Decode an encoded value into an Asn1Object from an InputStream.
+ ///
+ /// </summary>
+ /// <param name="in">An input stream containig the encoded ASN.1 data.
+ /// </param>
+ Asn1Object decode(System.IO.Stream in_Renamed);
+
+
+ /// <summary> Decode an encoded value into an Asn1Object from an InputStream.
+ ///
+ /// </summary>
+ /// <param name="length">The decoded components encoded length. This value is
+ /// handy when decoding structured types. It allows you to accumulate
+ /// the number of bytes decoded, so you know when the structured
+ /// type has decoded all of its components.<br>
+ ///
+ /// </param>
+ /// <param name="in">An input stream containig the encoded ASN.1 data.
+ /// </param>
+ Asn1Object decode(System.IO.Stream in_Renamed, int[] length);
+
+ /* Decoders for ASN.1 simple types
+ */
+
+ /// <summary> Decode a BOOLEAN directly from a stream. Call this method when you
+ /// know that the next ASN.1 encoded element is a BOOLEAN
+ ///
+ /// </summary>
+ /// <param name="in">An input stream containig the encoded ASN.1 data.<br>
+ ///
+ /// </param>
+ /// <param name="len">Length in bytes
+ /// </param>
+ System.Object decodeBoolean(System.IO.Stream in_Renamed, int len);
+
+ /// <summary> Decode a Numeric value directly from a stream. Call this method when you
+ /// know that the next ASN.1 encoded element is a Numeric
+ ///
+ /// <p>Can be used to decodes INTEGER and ENUMERATED types.
+ ///
+ /// </summary>
+ /// <param name="in">An input stream containig the encoded ASN.1 data.<br>
+ ///
+ /// </param>
+ /// <param name="len">Length in bytes
+ /// </param>
+ System.Object decodeNumeric(System.IO.Stream in_Renamed, int len);
+
+
+
+ /* Asn1 TYPE NOT YET SUPPORTED
+ * Decode a REAL directly from a stream.
+ * public Object decodeReal(InputStream in, int len)
+ * throws IOException;
+ */
+ /* Asn1 TYPE NOT YET SUPPORTED
+ * Decode a BIT_STRING directly from a stream.
+ * public Object decodeBitString(InputStream in, int len)
+ * throws IOException;
+ */
+
+
+
+ /// <summary> Decode an OCTET_STRING directly from a stream. Call this method when you
+ /// know that the next ASN.1 encoded element is a OCTET_STRING.
+ ///
+ /// </summary>
+ /// <param name="in">An input stream containig the encoded ASN.1 data.<br>
+ ///
+ /// </param>
+ /// <param name="len">Length in bytes
+ /// </param>
+ System.Object decodeOctetString(System.IO.Stream in_Renamed, int len);
+
+
+
+ /* Asn1 TYPE NOT YET SUPPORTED
+ * Decode an OBJECT_IDENTIFIER directly from a stream.
+ * public Object decodeObjectIdentifier(InputStream in, int len)
+ * throws IOException;
+ */
+
+
+
+ /// <summary> Decode a CharacterString directly from a stream.
+ ///
+ /// Decodes any of the specialized character strings.
+ ///
+ /// </summary>
+ /// <param name="in">An input stream containig the encoded ASN.1 data.
+ ///
+ /// </param>
+ /// <param name="len">Length in bytes
+ /// </param>
+ System.Object decodeCharacterString(System.IO.Stream in_Renamed, int len);
+
+ /* No Decoders for ASN.1 structured types. A structured type's value is a
+ * collection of other types.
+ */
+
+
+ /* Decoders for ASN.1 useful types
+ */
+
+ /* Asn1 TYPE NOT YET SUPPORTED
+ * Decode a GENERALIZED_TIME directly from a stream.
+ * public Object decodeGeneralizedTime(InputStream in, int len)
+ * throws IOException;
+ */
+
+ /* Asn1 TYPE NOT YET SUPPORTED
+ * Decode a UNIVERSAL_TIME directly from a stream.
+ * public Object decodeUniversalTime(InputStream in, int len)
+ * throws IOException;
+ */
+
+ /* Asn1 TYPE NOT YET SUPPORTED
+ * Decode an EXTERNAL directly from a stream.
+ * public Object decodeExternal(InputStream in, int len)
+ * throws IOException;
+ */
+
+
+ /* Asn1 TYPE NOT YET SUPPORTED
+ * Decode an OBJECT_DESCRIPTOR directly from a stream.
+ * public Object decodeObjectDescriptor(InputStream in, int len)
+ * throws IOException;
+ */
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1Encoder.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1Encoder.cs
new file mode 100755
index 00000000000..f587bf10eca
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1Encoder.cs
@@ -0,0 +1,174 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.Asn1.Asn1Encoder.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+
+namespace Novell.Directory.Ldap.Asn1
+{
+
+ /// <summary> This interface defines the methods for encoding each of the ASN.1 types.
+ ///
+ /// Encoders which implement this interface may be used to encode any of the
+ /// Asn1Object data types.
+ ///
+ /// <p>This package also provides the BEREncoder class that can be used to
+ /// BER encode ASN.1 classes. However an application might chose to use
+ /// its own encoder class.
+ ///
+ /// <p>This interface thus allows an application to use this package to
+ /// encode ASN.1 objects using other encoding rules if needed.
+ ///
+ /// <p>Note that Ldap packets are required to be BER encoded. Since this package
+ /// includes a BER encoder no application provided encoder is needed for
+ /// building Ldap packets.
+ /// </summary>
+ [CLSCompliantAttribute(true)]
+ public interface Asn1Encoder : System.Runtime.Serialization.ISerializable
+ {
+
+ /* Encoders for ASN.1 simple types */
+
+ /// <summary> Encode an Asn1Boolean directly into the provided output stream.
+ ///
+ /// </summary>
+ /// <param name="b">The Asn1Boolean object to encode<br>
+ ///
+ /// </param>
+ /// <param name="out">The output stream onto which the ASN.1 object is
+ /// to be encoded<br>
+ /// </param>
+ void encode(Asn1Boolean b, System.IO.Stream out_Renamed);
+
+ /// <summary> Encode an Asn1Numeric directly to a stream.
+ ///
+ /// <p>Use a two's complement representation in the fewest number of octets
+ /// possible.
+ ///
+ /// Can be used to encode both INTEGER and ENUMERATED values.<br>
+ ///
+ /// </summary>
+ /// <param name="n">The Asn1Numeric object to encode<br>
+ ///
+ /// </param>
+ /// <param name="out">The output stream onto which the ASN.1 object is
+ /// to be encoded<br>
+ /// </param>
+ void encode(Asn1Numeric n, System.IO.Stream out_Renamed);
+
+ /* Asn1 TYPE NOT YET SUPPORTED
+ * Encode an Asn1Real directly to a stream.
+ * public void encode(Asn1Real r, OutputStream out)
+ * throws IOException;
+ */
+
+ /// <summary> Encode an Asn1Null directly to a stream.
+ ///
+ /// </summary>
+ /// <param name="n">The Asn1Null object to encode<br>
+ ///
+ /// </param>
+ /// <param name="out">The output stream onto which the ASN.1 object is
+ /// to be encoded<br>
+ /// </param>
+ void encode(Asn1Null n, System.IO.Stream out_Renamed);
+
+ /* Asn1 TYPE NOT YET SUPPORTED
+ * Encode an Asn1BitString directly to a stream.
+ * public void encode(Asn1BitString bs, OutputStream out)
+ * throws IOException;
+ */
+
+ /// <summary> Encode an Asn1OctetString directly to a stream.
+ ///
+ /// </summary>
+ /// <param name="os">The Asn1OctetString object to encode<br>
+ ///
+ /// </param>
+ /// <param name="out">The output stream onto which the ASN.1 object is
+ /// to be encoded<br>
+ /// </param>
+ void encode(Asn1OctetString os, System.IO.Stream out_Renamed);
+
+ /* Asn1 TYPE NOT YET SUPPORTED
+ * Encode an Asn1ObjectIdentifier directly to a stream.
+ * public void encode(Asn1ObjectIdentifier oi, OutputStream out)
+ * throws IOException;
+ */
+
+ /* Asn1 TYPE NOT YET SUPPORTED
+ * Encode an Asn1CharacterString directly to a stream.
+ * public void encode(Asn1CharacterString cs, OutputStream out)
+ * throws IOException;
+ */
+
+ /* Encoder for ASN.1 structured types
+ */
+
+ /// <summary> Encode an Asn1Structured directly to a stream.
+ ///
+ /// </summary>
+ /// <param name="c">The Asn1Structured object to encode<br>
+ ///
+ /// </param>
+ /// <param name="out">The output stream onto which the ASN.1 object is
+ /// to be encoded<br>
+ /// </param>
+ void encode(Asn1Structured c, System.IO.Stream out_Renamed);
+
+ /// <summary> Encode an Asn1Tagged directly to a stream.
+ ///
+ /// </summary>
+ /// <param name="t">The Asn1Tagged object to encode<br>
+ ///
+ /// </param>
+ /// <param name="out">The output stream onto which the ASN.1 object is
+ /// to be encoded<br>
+ /// </param>
+ void encode(Asn1Tagged t, System.IO.Stream out_Renamed);
+
+ /* Encoders for ASN.1 useful types
+ */
+
+ /* Encoder for ASN.1 Identifier
+ */
+
+ /// <summary> Encode an Asn1Identifier directly to a stream.
+ ///
+ /// </summary>
+ /// <param name="id">The Asn1Identifier object to encode<br>
+ ///
+ /// </param>
+ /// <param name="out">The output stream onto which the ASN.1 object is
+ /// to be encoded<br>
+ /// </param>
+ void encode(Asn1Identifier id, System.IO.Stream out_Renamed);
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1Enumerated.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1Enumerated.cs
new file mode 100755
index 00000000000..febe0a298a1
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1Enumerated.cs
@@ -0,0 +1,119 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.Asn1.Asn1Enumerated.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+
+namespace Novell.Directory.Ldap.Asn1
+{
+
+ /// <summary> This class encapsulates the ASN.1 ENUMERATED type.</summary>
+ [CLSCompliantAttribute(true)]
+ public class Asn1Enumerated:Asn1Numeric
+ {
+
+ /// <summary> ASN.1 tag definition for ENUMERATED</summary>
+ public const int TAG = 0x0a;
+
+ /// <summary> ID is added for Optimization.
+ ///
+ /// <p>ID needs only be one Value for every instance,
+ /// thus we create it only once.</p>
+ /// </summary>
+ public static readonly Asn1Identifier ID = new Asn1Identifier(Asn1Identifier.UNIVERSAL, false, TAG);
+ /* Constructors for Asn1Enumerated
+ */
+
+ /// <summary> Call this constructor to construct an Asn1Enumerated
+ /// object from an integer value.
+ ///
+ /// </summary>
+ /// <param name="content">The integer value to be contained in the
+ /// this Asn1Enumerated object
+ /// </param>
+ public Asn1Enumerated(int content):base(ID, content)
+ {
+ return ;
+ }
+
+ /// <summary> Call this constructor to construct an Asn1Enumerated
+ /// object from a long value.
+ ///
+ /// </summary>
+ /// <param name="content">The long value to be contained in the
+ /// this Asn1Enumerated object
+ /// </param>
+ public Asn1Enumerated(long content):base(ID, content)
+ {
+ return ;
+ }
+
+ /// <summary> Constructs an Asn1Enumerated object by decoding data from an
+ /// input stream.
+ ///
+ /// </summary>
+ /// <param name="dec">The decoder object to use when decoding the
+ /// input stream. Sometimes a developer might want to pass
+ /// in his/her own decoder object<br>
+ ///
+ /// </param>
+ /// <param name="in">A byte stream that contains the encoded ASN.1
+ ///
+ /// </param>
+ [CLSCompliantAttribute(false)]
+ public Asn1Enumerated(Asn1Decoder dec, System.IO.Stream in_Renamed, int len):base(ID, (System.Int64) dec.decodeNumeric(in_Renamed, len))
+ {
+ return ;
+ }
+
+
+ /// <summary> Call this method to encode the current instance into the
+ /// specified output stream using the specified encoder object.
+ ///
+ /// </summary>
+ /// <param name="enc">Encoder object to use when encoding self.<br>
+ ///
+ /// </param>
+ /// <param name="out">The output stream onto which the encoded byte
+ /// stream is written.
+ /// </param>
+ public override void encode(Asn1Encoder enc, System.IO.Stream out_Renamed)
+ {
+ enc.encode(this, out_Renamed);
+ return ;
+ }
+
+ /// <summary> Return a String representation of this Asn1Enumerated.</summary>
+ public override System.String ToString()
+ {
+ return base.ToString() + "ENUMERATED: " + longValue();
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1Identifier.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1Identifier.cs
new file mode 100755
index 00000000000..7e31802f1f8
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1Identifier.cs
@@ -0,0 +1,327 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.Asn1.Asn1Identifier.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+
+namespace Novell.Directory.Ldap.Asn1
+{
+
+ /// <summary> This class is used to encapsulate an ASN.1 Identifier.
+ ///
+ /// <p>An Asn1Identifier is composed of three parts:
+ /// <li> a class type,
+ /// <li> a form, and
+ /// <li> a tag.</p>
+ ///
+ /// <p>The class type is defined as:</p>
+ /// <pre>
+ /// bit 8 7 TAG CLASS
+ /// ------- -----------
+ /// 0 0 UNIVERSAL
+ /// 0 1 APPLICATION
+ /// 1 0 CONTEXT
+ /// 1 1 PRIVATE
+ /// </pre>
+ /// <p> The form is defined as:</p>
+ /// <pre>
+ /// bit 6 FORM
+ /// ----- --------
+ /// 0 PRIMITIVE
+ /// 1 CONSTRUCTED
+ /// </pre>
+ ///
+ /// <p> Note: CONSTRUCTED types are made up of other CONSTRUCTED or PRIMITIVE
+ /// types.</p>
+ ///
+ /// <p> The tag is defined as:</p>
+ /// <pre>
+ /// bit 5 4 3 2 1 TAG
+ /// ------------- ---------------------------------------------
+ /// 0 0 0 0 0
+ /// . . . . .
+ /// 1 1 1 1 0 (0-30) single octet tag
+ ///
+ /// 1 1 1 1 1 (> 30) multiple octet tag, more octets follow
+ /// </pre>
+ /// </summary>
+ [CLSCompliantAttribute(true)]
+ public class Asn1Identifier:System.Object, System.ICloneable
+ {
+ /// <summary> Returns the CLASS of this Asn1Identifier as an int value.
+ ///
+ /// </summary>
+ /// <seealso cref="#UNIVERSAL">
+ /// </seealso>
+ /// <seealso cref="#APPLICATION">
+ /// </seealso>
+ /// <seealso cref="#CONTEXT">
+ /// </seealso>
+ /// <seealso cref="#PRIVATE">
+ /// </seealso>
+ virtual public int Asn1Class
+ {
+ get
+ {
+ return tagClass;
+ }
+
+ }
+ /// <summary> Return a boolean indicating if the constructed bit is set.
+ ///
+ /// </summary>
+ /// <returns> true if constructed and false if primitive.
+ /// </returns>
+ virtual public bool Constructed
+ {
+ get
+ {
+ return constructed;
+ }
+
+ }
+ /// <summary> Returns the TAG of this Asn1Identifier.</summary>
+ virtual public int Tag
+ {
+ get
+ {
+ return tag;
+ }
+
+ }
+ /// <summary> Returns the encoded length of this Asn1Identifier.</summary>
+ virtual public int EncodedLength
+ {
+ get
+ {
+ return encodedLength;
+ }
+
+ }
+ /// <summary> Returns a boolean value indicating whether or not this Asn1Identifier
+ /// has a TAG CLASS of UNIVERSAL.
+ ///
+ /// </summary>
+ /// <seealso cref="#UNIVERSAL">
+ /// </seealso>
+ [CLSCompliantAttribute(false)]
+ virtual public bool Universal
+ {
+ get
+ {
+ return tagClass == UNIVERSAL;
+ }
+
+ }
+ /// <summary> Returns a boolean value indicating whether or not this Asn1Identifier
+ /// has a TAG CLASS of APPLICATION.
+ ///
+ /// </summary>
+ /// <seealso cref="#APPLICATION">
+ /// </seealso>
+ [CLSCompliantAttribute(false)]
+ virtual public bool Application
+ {
+ get
+ {
+ return tagClass == APPLICATION;
+ }
+
+ }
+ /// <summary> Returns a boolean value indicating whether or not this Asn1Identifier
+ /// has a TAG CLASS of CONTEXT-SPECIFIC.
+ ///
+ /// </summary>
+ /// <seealso cref="#CONTEXT">
+ /// </seealso>
+ [CLSCompliantAttribute(false)]
+ virtual public bool Context
+ {
+ get
+ {
+ return tagClass == CONTEXT;
+ }
+
+ }
+ /// <summary> Returns a boolean value indicating whether or not this Asn1Identifier
+ /// has a TAG CLASS of PRIVATE.
+ ///
+ /// </summary>
+ /// <seealso cref="#PRIVATE">
+ [CLSCompliantAttribute(false)]
+ virtual public bool Private
+ {
+ get
+ {
+ return tagClass == PRIVATE;
+ }
+
+ }
+
+ /// <summary> Universal tag class.
+ ///
+ /// <p> UNIVERSAL = 0 </p>
+ /// </summary>
+ public const int UNIVERSAL = 0;
+
+ /// <summary> Application-wide tag class.
+ ///
+ /// <p> APPLICATION = 1 </p>
+ /// </summary>
+ public const int APPLICATION = 1;
+
+ /// <summary> Context-specific tag class.
+ ///
+ /// <p> CONTEXT = 2 </p>
+ /// </summary>
+ public const int CONTEXT = 2;
+
+ /// <summary> Private-use tag class.
+ ///
+ /// <p> PRIVATE = 3 </p>
+ /// </summary>
+ public const int PRIVATE = 3;
+
+
+ /* Private variables
+ */
+
+ private int tagClass;
+ private bool constructed;
+ private int tag;
+ private int encodedLength;
+
+ /* Constructors for Asn1Identifier
+ */
+
+ /// <summary> Constructs an Asn1Identifier using the classtype, form and tag.
+ ///
+ /// </summary>
+ /// <param name="tagClass">As defined above.
+ ///
+ /// </param>
+ /// <param name="constructed">Set to true if constructed and false if primitive.
+ ///
+ /// </param>
+ /// <param name="tag">The tag of this identifier
+ /// </param>
+ public Asn1Identifier(int tagClass, bool constructed, int tag)
+ {
+ this.tagClass = tagClass;
+ this.constructed = constructed;
+ this.tag = tag;
+ }
+
+ /// <summary> Decode an Asn1Identifier directly from an InputStream and
+ /// save the encoded length of the Asn1Identifier.
+ ///
+ /// </summary>
+ /// <param name="in">The input stream to decode from.
+ /// </param>
+ public Asn1Identifier(System.IO.Stream in_Renamed)
+ {
+ int r = in_Renamed.ReadByte();
+ encodedLength++;
+ if (r < 0)
+ throw new System.IO.EndOfStreamException("BERDecoder: decode: EOF in Identifier");
+ tagClass = r >> 6;
+ constructed = (r & 0x20) != 0;
+ tag = r & 0x1F; // if tag < 30 then its a single octet identifier.
+ if (tag == 0x1F)
+ // if true, its a multiple octet identifier.
+ tag = decodeTagNumber(in_Renamed);
+ return ;
+ }
+
+ public Asn1Identifier()
+ {
+ return ;
+ }
+
+ /// <summary> Decode an Asn1Identifier directly from an InputStream and
+ /// save the encoded length of the Asn1Identifier, but reuse the object.
+ ///
+ /// </summary>
+ /// <param name="in">The input stream to decode from.
+ /// </param>
+ public void reset(System.IO.Stream in_Renamed)
+ {
+ encodedLength = 0;
+ int r = in_Renamed.ReadByte();
+ encodedLength++;
+ if (r < 0)
+ throw new System.IO.EndOfStreamException("BERDecoder: decode: EOF in Identifier");
+ tagClass = r >> 6;
+ constructed = (r & 0x20) != 0;
+ tag = r & 0x1F; // if tag < 30 then its a single octet identifier.
+ if (tag == 0x1F)
+ // if true, its a multiple octet identifier.
+ tag = decodeTagNumber(in_Renamed);
+ }
+
+ /// <summary> In the case that we have a tag number that is greater than 30, we need
+ /// to decode a multiple octet tag number.
+ /// </summary>
+ private int decodeTagNumber(System.IO.Stream in_Renamed)
+ {
+ int n = 0;
+ while (true)
+ {
+ int r = in_Renamed.ReadByte();
+ encodedLength++;
+ if (r < 0)
+ throw new System.IO.EndOfStreamException("BERDecoder: decode: EOF in tag number");
+ n = (n << 7) + (r & 0x7F);
+ if ((r & 0x80) == 0)
+ break;
+ }
+ return n;
+ }
+
+ /* Convenience methods
+ */
+
+ /// <summary> Creates a duplicate, not a true clone, of this object and returns
+ /// a reference to the duplicate.
+ ///
+ /// </summary>
+ public System.Object Clone()
+ {
+ try
+ {
+ return base.MemberwiseClone();
+ }
+ catch (System.Exception ce)
+ {
+ throw new System.SystemException("Internal error, cannot create clone");
+ }
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1Integer.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1Integer.cs
new file mode 100755
index 00000000000..4b581664add
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1Integer.cs
@@ -0,0 +1,123 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.Asn1.Asn1Integer.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+
+namespace Novell.Directory.Ldap.Asn1
+{
+
+ /// <summary> This class encapsulates the ASN.1 INTEGER type.</summary>
+ [CLSCompliantAttribute(true)]
+ public class Asn1Integer:Asn1Numeric
+ {
+
+ /// <summary> ASN.1 INTEGER tag definition.</summary>
+ public const int TAG = 0x02;
+
+ /// <summary> ID is added for Optimization.</summary>
+ /// <summary> <p>ID needs only be one Value for every instance,
+ /// thus we create it only once.</p>
+ /// </summary>
+ public static readonly Asn1Identifier ID = new Asn1Identifier(Asn1Identifier.UNIVERSAL, false, TAG);
+ /* Constructors for Asn1Integer
+ */
+
+ /// <summary> Call this constructor to construct an Asn1Integer
+ /// object from an integer value.
+ ///
+ /// </summary>
+ /// <param name="content">The integer value to be contained in the
+ /// this Asn1Integer object
+ /// </param>
+ public Asn1Integer(int content):base(ID, content)
+ {
+ return ;
+ }
+
+ /// <summary> Call this constructor to construct an Asn1Integer
+ /// object from a long value.
+ ///
+ /// </summary>
+ /// <param name="content">The long value to be contained in the
+ /// this Asn1Integer object
+ /// </param>
+ public Asn1Integer(long content):base(ID, content)
+ {
+ return ;
+ }
+
+ /// <summary> Constructs an Asn1Integer object by decoding data from an
+ /// input stream.
+ ///
+ /// </summary>
+ /// <param name="dec">The decoder object to use when decoding the
+ /// input stream. Sometimes a developer might want to pass
+ /// in his/her own decoder object<br>
+ ///
+ /// </param>
+ /// <param name="in">A byte stream that contains the encoded ASN.1
+ ///
+ /// </param>
+ [CLSCompliantAttribute(false)]
+ public Asn1Integer(Asn1Decoder dec, System.IO.Stream in_Renamed, int len):base(ID, (System.Int64) dec.decodeNumeric(in_Renamed, len))
+ {
+ return ;
+ }
+
+ /* Asn1Object implementation
+ */
+
+ /// <summary> Call this method to encode the current instance into the
+ /// specified output stream using the specified encoder object.
+ ///
+ /// </summary>
+ /// <param name="enc">Encoder object to use when encoding self.<br>
+ ///
+ /// </param>
+ /// <param name="out">The output stream onto which the encoded byte
+ /// stream is written.
+ /// </param>
+ public override void encode(Asn1Encoder enc, System.IO.Stream out_Renamed)
+ {
+ enc.encode(this, out_Renamed);
+ return ;
+ }
+
+ /* Asn1Integer specific methods
+ */
+
+ /// <summary> Returns a String representation of this Asn1Integer object.</summary>
+ public override System.String ToString()
+ {
+ return base.ToString() + "INTEGER: " + longValue();
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1Length.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1Length.cs
new file mode 100755
index 00000000000..0951ea907ea
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1Length.cs
@@ -0,0 +1,142 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.Asn1.Asn1Length.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+
+namespace Novell.Directory.Ldap.Asn1
+{
+
+ /// <summary> This class provides a means to manipulate ASN.1 Length's. It will
+ /// be used by Asn1Encoder's and Asn1Decoder's by composition.
+ /// </summary>
+ [CLSCompliantAttribute(true)]
+ public class Asn1Length
+ {
+ /// <summary> Returns the length of this Asn1Length.</summary>
+ virtual public int Length
+ {
+ get
+ {
+ return length;
+ }
+
+ }
+ /// <summary> Returns the encoded length of this Asn1Length.</summary>
+ virtual public int EncodedLength
+ {
+ get
+ {
+ return encodedLength;
+ }
+
+ }
+
+ /* Private variables
+ */
+
+ private int length;
+ private int encodedLength;
+
+ /* Constructors for Asn1Length
+ */
+
+ /// <summary> Constructs an empty Asn1Length. Values are added by calling reset</summary>
+ public Asn1Length()
+ {
+ }
+ /// <summary> Constructs an Asn1Length</summary>
+ public Asn1Length(int length)
+ {
+ this.length = length;
+ }
+
+ /// <summary> Constructs an Asn1Length object by decoding data from an
+ /// input stream.
+ ///
+ /// </summary>
+ /// <param name="in">A byte stream that contains the encoded ASN.1
+ ///
+ /// </param>
+ public Asn1Length(System.IO.Stream in_Renamed)
+ {
+ int r = in_Renamed.ReadByte();
+ encodedLength++;
+ if (r == 0x80)
+ length = - 1;
+ else if (r < 0x80)
+ length = r;
+ else
+ {
+ length = 0;
+ for (r = r & 0x7F; r > 0; r--)
+ {
+ int part = in_Renamed.ReadByte();
+ encodedLength++;
+ if (part < 0)
+ throw new System.IO.EndOfStreamException("BERDecoder: decode: EOF in Asn1Length");
+ length = (length << 8) + part;
+ }
+ }
+ }
+
+ /// <summary> Resets an Asn1Length object by decoding data from an
+ /// input stream.
+ ///
+ /// Note: this was added for optimization of Asn1.LBERdecoder.decode()
+ ///
+ /// </summary>
+ /// <param name="in">A byte stream that contains the encoded ASN.1
+ ///
+ /// </param>
+ public void reset(System.IO.Stream in_Renamed)
+ {
+ encodedLength = 0;
+ int r = in_Renamed.ReadByte();
+ encodedLength++;
+ if (r == 0x80)
+ length = - 1;
+ else if (r < 0x80)
+ length = r;
+ else
+ {
+ length = 0;
+ for (r = r & 0x7F; r > 0; r--)
+ {
+ int part = in_Renamed.ReadByte();
+ encodedLength++;
+ if (part < 0)
+ throw new System.IO.EndOfStreamException("BERDecoder: decode: EOF in Asn1Length");
+ length = (length << 8) + part;
+ }
+ }
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1Null.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1Null.cs
new file mode 100755
index 00000000000..bea0649d4f2
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1Null.cs
@@ -0,0 +1,89 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.Asn1.Asn1Null.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+
+namespace Novell.Directory.Ldap.Asn1
+{
+
+ /// <summary> This class represents the ASN.1 NULL type.</summary>
+ [CLSCompliantAttribute(true)]
+ public class Asn1Null:Asn1Object
+ {
+
+ /// <summary> ASN.1 NULL tag definition.</summary>
+ public const int TAG = 0x05;
+
+ /// <summary> ID is added for Optimization.</summary>
+ /// <summary> <p>ID needs only be one Value for every instance,
+ /// thus we create it only once.</p>
+ /// </summary>
+ public static readonly Asn1Identifier ID = new Asn1Identifier(Asn1Identifier.UNIVERSAL, false, TAG);
+ /* Constructor for Asn1Null
+ */
+
+ /// <summary> Call this constructor to construct a new Asn1Null
+ /// object.
+ /// </summary>
+ public Asn1Null():base(ID)
+ {
+ return ;
+ }
+
+ /* Asn1Object implementation
+ */
+
+ /// <summary> Call this method to encode the current instance into the
+ /// specified output stream using the specified encoder object.
+ ///
+ /// </summary>
+ /// <param name="enc">Encoder object to use when encoding self.<br>
+ ///
+ /// </param>
+ /// <param name="out">The output stream onto which the encoded byte
+ /// stream is written.
+ /// </param>
+ public override void encode(Asn1Encoder enc, System.IO.Stream out_Renamed)
+ {
+ enc.encode(this, out_Renamed);
+ return ;
+ }
+
+ /* Asn1Null specific methods
+ */
+
+ /// <summary> Return a String representation of this Asn1Null object.</summary>
+ public override System.String ToString()
+ {
+ return base.ToString() + "NULL: \"\"";
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1Numeric.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1Numeric.cs
new file mode 100755
index 00000000000..468a3e2f9e8
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1Numeric.cs
@@ -0,0 +1,77 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.Asn1.Asn1Numeric.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+
+namespace Novell.Directory.Ldap.Asn1
+{
+
+ /// <summary> This abstract class is the base class
+ /// for all Asn1 numeric (integral) types. These include
+ /// Asn1Integer and Asn1Enumerated.
+ /// </summary>
+ [CLSCompliantAttribute(true)]
+ public abstract class Asn1Numeric:Asn1Object
+ {
+
+ private System.Int64 content;
+
+ internal Asn1Numeric(Asn1Identifier id, int value_Renamed):base(id)
+ {
+ content = (System.Int64) value_Renamed;
+ return ;
+ }
+
+ internal Asn1Numeric(Asn1Identifier id, long value_Renamed):base(id)
+ {
+ content = (System.Int64) value_Renamed;
+ return ;
+ }
+
+/* internal Asn1Numeric(Asn1Identifier id, System.Int64 value_Renamed):base(id)
+ {
+ content = value_Renamed;
+ return ;
+ }
+*/
+ /// <summary> Returns the content of this Asn1Numeric object as an int.</summary>
+ public int intValue()
+ {
+ return (int) content;
+ }
+
+ /// <summary> Returns the content of this Asn1Numeric object as a long.</summary>
+ public long longValue()
+ {
+ return (long) content;
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1Object.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1Object.cs
new file mode 100755
index 00000000000..323f95ccefe
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1Object.cs
@@ -0,0 +1,123 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.Asn1.Asn1Object.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+
+namespace Novell.Directory.Ldap.Asn1
+{
+
+ /// <summary> This is the base class for all other Asn1 types.</summary>
+ [CLSCompliantAttribute(true)]
+ [Serializable]
+ public abstract class Asn1Object : System.Runtime.Serialization.ISerializable
+ {
+
+ private Asn1Identifier id;
+
+ public Asn1Object(Asn1Identifier id)
+ {
+ this.id = id;
+ return ;
+ }
+
+ public void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context)
+ {
+ }
+
+ /// <summary> Abstract method that must be implemented by each child
+ /// class to encode itself ( an Asn1Object) directly intto
+ /// a output stream.
+ ///
+ /// </summary>
+ /// <param name="out">The output stream onto which the encoded
+ /// Asn1Object will be placed.
+ /// </param>
+ abstract public void encode(Asn1Encoder enc, System.IO.Stream out_Renamed);
+
+ /// <summary> Returns the identifier for this Asn1Object as an Asn1Identifier.
+ /// This Asn1Identifier object will include the CLASS, FORM and TAG
+ /// for this Asn1Object.
+ /// </summary>
+ public virtual Asn1Identifier getIdentifier()
+ {
+ return id;
+ }
+
+ /// <summary> Sets the identifier for this Asn1Object. This is helpful when
+ /// creating implicit Asn1Tagged types.
+ ///
+ /// </summary>
+ /// <param name="id">An Asn1Identifier object representing the CLASS,
+ /// FORM and TAG)
+ /// </param>
+ public virtual void setIdentifier(Asn1Identifier id)
+ {
+ this.id = id;
+ return ;
+ }
+
+ /// <summary> This method returns a byte array representing the encoded
+ /// Asn1Object. It in turn calls the encode method that is
+ /// defined in Asn1Object but will usually be implemented
+ /// in the child Asn1 classses.
+ /// </summary>
+ [CLSCompliantAttribute(false)]
+ public sbyte[] getEncoding(Asn1Encoder enc)
+ {
+ System.IO.MemoryStream out_Renamed = new System.IO.MemoryStream();
+ try
+ {
+ encode(enc, out_Renamed);
+ }
+ catch (System.IO.IOException e)
+ {
+ // Should never happen - the current Asn1Object does not have
+ // a encode method.
+ throw new System.SystemException("IOException while encoding to byte array: " + e.ToString());
+ }
+ return SupportClass.ToSByteArray(out_Renamed.ToArray());
+ }
+
+ /// <summary> Return a String representation of this Asn1Object.</summary>
+ [CLSCompliantAttribute(false)]
+ public override System.String ToString()
+ {
+ System.String[] classTypes = new System.String[]{"[UNIVERSAL ", "[APPLICATION ", "[", "[PRIVATE "};
+
+ System.Text.StringBuilder sb = new System.Text.StringBuilder();
+ Asn1Identifier id = getIdentifier(); // could be overridden.
+
+ sb.Append(classTypes[id.Asn1Class]).Append(id.Tag).Append("] ");
+
+ return sb.ToString();
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1OctetString.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1OctetString.cs
new file mode 100755
index 00000000000..e3a70b530ba
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1OctetString.cs
@@ -0,0 +1,181 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.Asn1.Asn1OctetString.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+
+namespace Novell.Directory.Ldap.Asn1
+{
+
+ /// <summary> This class encapsulates the OCTET STRING type.</summary>
+ [CLSCompliantAttribute(true)]
+ public class Asn1OctetString:Asn1Object
+ {
+
+ private sbyte[] content;
+
+ /// <summary> ASN.1 OCTET STRING tag definition.</summary>
+ public const int TAG = 0x04;
+
+ /// <summary> ID is added for Optimization.
+ /// <p>Id needs only be one Value for every instance,
+ /// thus we create it only once.</p>
+ /// </summary>
+ protected internal static readonly Asn1Identifier ID = new Asn1Identifier(Asn1Identifier.UNIVERSAL, false, TAG);
+ /* Constructors for Asn1OctetString
+ */
+
+ /// <summary> Call this constructor to construct an Asn1OctetString
+ /// object from a byte array.
+ ///
+ /// </summary>
+ /// <param name="content">A byte array representing the string that
+ /// will be contained in the this Asn1OctetString object
+ /// </param>
+ [CLSCompliantAttribute(false)]
+ public Asn1OctetString(sbyte[] content):base(ID)
+ {
+ this.content = content;
+ return ;
+ }
+
+
+ /// <summary> Call this constructor to construct an Asn1OctetString
+ /// object from a String object.
+ ///
+ /// </summary>
+ /// <param name="content">A string value that will be contained
+ /// in the this Asn1OctetString object
+ /// </param>
+ public Asn1OctetString(System.String content):base(ID)
+ {
+ try
+ {
+/* System.Text.UTF8Encoding utf8 = new System.Text.UTF8Encoding();
+ byte[] bytes = utf8.GetBytes (content);
+ sbyte[] sbytes = new sbyte[bytes.Length+1]; //signed bytes
+ sbytes[0] = 0; //set sign byte to zero.
+ for(int i=1; i<sbytes.Length; i++)
+ sbytes[i] = (sbyte) bytes[i-1]; //cast byte-->sbyte
+*/
+ System.Text.Encoding encoder = System.Text.Encoding.GetEncoding("utf-8");
+ byte[] ibytes = encoder.GetBytes(content);
+ sbyte[] sbytes=SupportClass.ToSByteArray(ibytes);
+
+ this.content = sbytes;
+// this.content = content.getBytes("UTF8");
+ }
+ catch (System.IO.IOException uee)
+ {
+ throw new System.SystemException(uee.ToString());
+ }
+ return ;
+ }
+
+
+ /// <summary> Constructs an Asn1OctetString object by decoding data from an
+ /// input stream.
+ ///
+ /// </summary>
+ /// <param name="dec">The decoder object to use when decoding the
+ /// input stream. Sometimes a developer might want to pass
+ /// in his/her own decoder object<br>
+ ///
+ /// </param>
+ /// <param name="in">A byte stream that contains the encoded ASN.1
+ ///
+ /// </param>
+ [CLSCompliantAttribute(false)]
+ public Asn1OctetString(Asn1Decoder dec, System.IO.Stream in_Renamed, int len):base(ID)
+ {
+ content = (len > 0)?(sbyte[]) dec.decodeOctetString(in_Renamed, len):new sbyte[0];
+ return ;
+ }
+
+
+ /* Asn1Object implementation
+ */
+
+ /// <summary> Call this method to encode the current instance into the
+ /// specified output stream using the specified encoder object.
+ ///
+ /// </summary>
+ /// <param name="enc">Encoder object to use when encoding self.<br>
+ ///
+ /// </param>
+ /// <param name="out">The output stream onto which the encoded byte
+ /// stream is written.
+ /// </param>
+ public override void encode(Asn1Encoder enc, System.IO.Stream out_Renamed)
+ {
+ enc.encode(this, out_Renamed);
+ return ;
+ }
+
+
+ /*Asn1OctetString specific methods
+ */
+
+ /// <summary> Returns the content of this Asn1OctetString as a byte array.</summary>
+ [CLSCompliantAttribute(false)]
+ public sbyte[] byteValue()
+ {
+ return content;
+ }
+
+
+ /// <summary> Returns the content of this Asn1OctetString as a String.</summary>
+ public System.String stringValue()
+ {
+ System.String s = null;
+ try
+ {
+ System.Text.Encoding encoder = System.Text.Encoding.GetEncoding("utf-8");
+ char[] dchar = encoder.GetChars(SupportClass.ToByteArray(content));
+ s = new String(dchar);
+// sbyte *sb=content;
+// s = new String(sb,0,content.Length, new System.Text.UTF8Encoding());
+ }
+ catch (System.IO.IOException uee)
+ {
+ throw new System.SystemException(uee.ToString());
+ }
+
+ return s;
+ }
+
+
+ /// <summary> Return a String representation of this Asn1Object.</summary>
+ public override System.String ToString()
+ {
+ return base.ToString() + "OCTET STRING: " + stringValue();
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1Sequence.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1Sequence.cs
new file mode 100755
index 00000000000..152ba64e537
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1Sequence.cs
@@ -0,0 +1,124 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.Asn1.Asn1Sequence.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+
+namespace Novell.Directory.Ldap.Asn1
+{
+
+ /// <summary> The Asn1Sequence class can hold an ordered collection of components with
+ /// distinct type.
+ ///
+ /// This class inherits from the Asn1Structured class which
+ /// provides functionality to hold multiple Asn1 components.
+ /// </summary>
+ [CLSCompliantAttribute(true)]
+ public class Asn1Sequence:Asn1Structured
+ {
+
+ /// <summary> ASN.1 SEQUENCE tag definition.</summary>
+ public const int TAG = 0x10;
+
+ /// <summary> ID is added for Optimization.
+ ///
+ /// id needs only be one Value for every instance Thus we create it only once.
+ /// </summary>
+ private static readonly Asn1Identifier ID = new Asn1Identifier(Asn1Identifier.UNIVERSAL, true, TAG);
+ /* Constructors for Asn1Sequence
+ */
+
+ /// <summary> Constructs an Asn1Sequence object with no actual Asn1Objects in it.
+ ///
+ /// Assumes a default size of 10 elements.
+ /// </summary>
+ public Asn1Sequence():base(ID, 10)
+ {
+ return ;
+ }
+
+ /// <summary> Constructs an Asn1Sequence object with the specified
+ /// number of placeholders for Asn1Objects.
+ ///
+ /// It should be noted there are no actual Asn1Objects in this
+ /// SequenceOf object.
+ ///
+ /// </summary>
+ /// <param name="size">Specifies the initial size of the collection.
+ /// </param>
+ public Asn1Sequence(int size):base(ID, size)
+ {
+ return ;
+ }
+
+ /// <summary> Constructs an Asn1Sequence object with an array representing an
+ /// Asn1 sequence.
+ ///
+ /// </summary>
+ /// <param name="newContent">the array containing the Asn1 data for the sequence
+ ///
+ /// </param>
+ /// <param name="size">Specifies the number of items in the array
+ /// </param>
+ public Asn1Sequence(Asn1Object[] newContent, int size):base(ID, newContent, size)
+ {
+ return ;
+ }
+
+ /// <summary> Constructs an Asn1Sequence object by decoding data from an
+ /// input stream.
+ ///
+ /// </summary>
+ /// <param name="dec">The decoder object to use when decoding the
+ /// input stream. Sometimes a developer might want to pass
+ /// in his/her own decoder object<br>
+ ///
+ /// </param>
+ /// <param name="in">A byte stream that contains the encoded ASN.1
+ ///
+ /// </param>
+ [CLSCompliantAttribute(false)]
+ public Asn1Sequence(Asn1Decoder dec, System.IO.Stream in_Renamed, int len):base(ID)
+ {
+ decodeStructured(dec, in_Renamed, len);
+ return ;
+ }
+
+ /* Asn1Sequence specific methods
+ */
+
+ /// <summary> Return a String representation of this Asn1Sequence.</summary>
+ [CLSCompliantAttribute(false)]
+ public override System.String ToString()
+ {
+ return base.toString("SEQUENCE: { ");
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1SequenceOf.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1SequenceOf.cs
new file mode 100755
index 00000000000..a3ecd9e7850
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1SequenceOf.cs
@@ -0,0 +1,125 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.Asn1.Asn1SequenceOf.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+namespace Novell.Directory.Ldap.Asn1
+{
+
+ /// <summary> The Asn1SequenceOf class is used to hold an ordered collection
+ /// of components with identical type. This class inherits
+ /// from the Asn1Structured class which already provides
+ /// functionality to hold multiple Asn1 components.
+ /// </summary>
+ [CLSCompliantAttribute(true)]
+ public class Asn1SequenceOf:Asn1Structured
+ {
+
+ /// <summary> ASN.1 SEQUENCE OF tag definition.</summary>
+ public const int TAG = 0x10;
+
+ /// <summary> ID is added for Optimization.
+ ///
+ /// <p>ID needs only be one Value for every instance,
+ /// thus we create it only once.</p>
+ /// </summary>
+ public static readonly Asn1Identifier ID = new Asn1Identifier(Asn1Identifier.UNIVERSAL, true, TAG);
+
+ /* Constructors for Asn1SequenceOf
+ */
+
+ /// <summary> Constructs an Asn1SequenceOf object with no actual
+ /// Asn1Objects in it. Assumes a default size of 5 elements.
+ /// </summary>
+ public Asn1SequenceOf():base(ID)
+ {
+ return ;
+ }
+
+
+ /// <summary> Constructs an Asn1SequenceOf object with the specified
+ /// number of placeholders for Asn1Objects. However there
+ /// are no actual Asn1Objects in this SequenceOf object.
+ ///
+ /// </summary>
+ /// <param name="size">Specifies the initial size of the collection.
+ /// </param>
+ public Asn1SequenceOf(int size):base(ID, size)
+ {
+ return ;
+ }
+
+
+ /// <summary> A copy constructor which creates an Asn1SequenceOf from an
+ /// instance of Asn1Sequence.
+ ///
+ /// Since SEQUENCE and SEQUENCE_OF have the same identifier, the decoder
+ /// will always return a SEQUENCE object when it detects that identifier.
+ /// In order to take advantage of the Asn1SequenceOf type, we need to be
+ /// able to construct this object when knowingly receiving an
+ /// Asn1Sequence.
+ /// </summary>
+ public Asn1SequenceOf(Asn1Sequence sequence):base(ID, sequence.toArray(), sequence.size())
+ {
+ return ;
+ }
+
+
+ /// <summary> Constructs an Asn1SequenceOf object by decoding data from an
+ /// input stream.
+ ///
+ /// </summary>
+ /// <param name="dec">The decoder object to use when decoding the
+ /// input stream. Sometimes a developer might want to pass
+ /// in his/her own decoder object<br>
+ ///
+ /// </param>
+ /// <param name="in">A byte stream that contains the encoded ASN.1
+ ///
+ /// </param>
+ [CLSCompliantAttribute(false)]
+ public Asn1SequenceOf(Asn1Decoder dec, System.IO.Stream in_Renamed, int len):base(ID)
+ {
+ decodeStructured(dec, in_Renamed, len);
+ return ;
+ }
+
+
+ /* Asn1SequenceOf specific methods
+ */
+
+ /// <summary> Returns a String representation of this Asn1SequenceOf object</summary>
+ [CLSCompliantAttribute(false)]
+ public override System.String ToString()
+ {
+ return base.toString("SEQUENCE OF: { ");
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1Set.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1Set.cs
new file mode 100755
index 00000000000..0e18172be74
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1Set.cs
@@ -0,0 +1,106 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.Asn1.Asn1Set.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+
+namespace Novell.Directory.Ldap.Asn1
+{
+
+ /// <summary> The Asn1Set class can hold an unordered collection of components with
+ /// distinct type. This class inherits from the Asn1Structured class
+ /// which already provides functionality to hold multiple Asn1 components.
+ /// </summary>
+ [CLSCompliantAttribute(true)]
+ public class Asn1Set:Asn1Structured
+ {
+
+ /// <summary> ASN.1 SET tag definition.</summary>
+ public const int TAG = 0x11;
+
+ /// <summary> ID is added for Optimization.</summary>
+ /// <summary> <p>ID needs only be one Value for every instance,
+ /// thus we create it only once.</p>
+ /// </summary>
+ public static readonly Asn1Identifier ID = new Asn1Identifier(Asn1Identifier.UNIVERSAL, true, TAG);
+ /* Constructors for Asn1Set
+ */
+
+ /// <summary> Constructs an Asn1Set object with no actual
+ /// Asn1Objects in it. Assumes a default size of 5 elements.
+ /// </summary>
+ public Asn1Set():base(ID)
+ {
+ return ;
+ }
+
+
+ /// <summary> Constructs an Asn1Set object with the specified
+ /// number of placeholders for Asn1Objects. However there
+ /// are no actual Asn1Objects in this SequenceOf object.
+ ///
+ /// </summary>
+ /// <param name="size">Specifies the initial size of the collection.
+ /// </param>
+ public Asn1Set(int size):base(ID, size)
+ {
+ return ;
+ }
+
+ /// <summary> Constructs an Asn1Set object by decoding data from an
+ /// input stream.
+ ///
+ /// </summary>
+ /// <param name="dec">The decoder object to use when decoding the
+ /// input stream. Sometimes a developer might want to pass
+ /// in his/her own decoder object<br>
+ ///
+ /// </param>
+ /// <param name="in">A byte stream that contains the encoded ASN.1
+ ///
+ /// </param>
+ [CLSCompliantAttribute(false)]
+ public Asn1Set(Asn1Decoder dec, System.IO.Stream in_Renamed, int len):base(ID)
+ {
+ decodeStructured(dec, in_Renamed, len);
+ return ;
+ }
+
+ /* Asn1Set specific methods
+ */
+
+ /// <summary> Returns a String representation of this Asn1Set.</summary>
+ [CLSCompliantAttribute(false)]
+ public override System.String ToString()
+ {
+ return base.toString("SET: { ");
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1SetOf.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1SetOf.cs
new file mode 100755
index 00000000000..a31fcc08cf2
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1SetOf.cs
@@ -0,0 +1,102 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.Asn1.Asn1SetOf.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+
+namespace Novell.Directory.Ldap.Asn1
+{
+
+ /// <summary> The Asn1Set class can hold an unordered collection of components with
+ /// identical type. This class inherits from the Asn1Structured class
+ /// which already provides functionality to hold multiple Asn1 components.
+ /// </summary>
+ [CLSCompliantAttribute(true)]
+ public class Asn1SetOf:Asn1Structured
+ {
+
+ /// <summary> ASN.1 SET OF tag definition.</summary>
+ public const int TAG = 0x11;
+
+ /// <summary> ID is added for Optimization.
+ ///
+ /// <p>Id needs only be one Value for every instance,
+ /// thus we create it only once.</p>
+ /// </summary>
+ public static readonly Asn1Identifier ID = new Asn1Identifier(Asn1Identifier.UNIVERSAL, true, TAG);
+ /* Constructors for Asn1SetOf
+ */
+
+ /// <summary> Constructs an Asn1SetOf object with no actual
+ /// Asn1Objects in it. Assumes a default size of 5 elements.
+ /// </summary>
+ public Asn1SetOf():base(ID)
+ {
+ return ;
+ }
+
+
+ /// <summary> Constructs an Asn1SetOf object with the specified
+ /// number of placeholders for Asn1Objects. However there
+ /// are no actual Asn1Objects in this SequenceOf object.
+ ///
+ /// </summary>
+ /// <param name="size">Specifies the initial size of the collection.
+ /// </param>
+ public Asn1SetOf(int size):base(ID, size)
+ {
+ return ;
+ }
+
+
+ /// <summary> A copy constructor that creates an Asn1SetOf from an instance of Asn1Set.
+ ///
+ /// <p>Since SET and SET_OF have the same identifier, the decoder
+ /// will always return a SET object when it detects that identifier.
+ /// In order to take advantage of the Asn1SetOf type, we need to be
+ /// able to construct this object when knowingly receiving an
+ /// Asn1Set.</p>
+ /// </summary>
+ public Asn1SetOf(Asn1Set set_Renamed):base(ID, set_Renamed.toArray(), set_Renamed.size())
+ {
+ return ;
+ }
+
+ /* Asn1SetOf specific methods
+ */
+
+ /// <summary> Return a String representation of this Asn1SetOf.</summary>
+ [CLSCompliantAttribute(false)]
+ public override System.String ToString()
+ {
+ return base.toString("SET OF: { ");
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1Structured.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1Structured.cs
new file mode 100755
index 00000000000..f6dadd4d050
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1Structured.cs
@@ -0,0 +1,214 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.Asn1.Asn1Structured.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+
+namespace Novell.Directory.Ldap.Asn1
+{
+
+ /// <summary> This class serves as the base type for all ASN.1
+ /// structured types.
+ /// </summary>
+ [CLSCompliantAttribute(true)]
+ public abstract class Asn1Structured:Asn1Object
+ {
+ private Asn1Object[] content;
+
+ private int contentIndex = 0;
+
+ /*
+ * Create a an Asn1 structured type with default size of 10
+ *
+ * @param the Asn1Identifier containing the tag for this structured type
+ */
+ protected internal Asn1Structured(Asn1Identifier id):this(id, 10)
+ {
+ return ;
+ }
+
+ /*
+ * Create a an Asn1 structured type with the designated size
+ *
+ * @param id the Asn1Identifier containing the tag for this structured type
+ *
+ * @param size the size to allocate
+ */
+ protected internal Asn1Structured(Asn1Identifier id, int size):base(id)
+ {
+ content = new Asn1Object[size];
+ return ;
+ }
+
+ /*
+ * Create a an Asn1 structured type with default size of 10
+ *
+ * @param id the Asn1Identifier containing the tag for this structured type
+ *
+ * @param content an array containing the content
+ *
+ * @param size the number of items of content in the array
+ */
+ protected internal Asn1Structured(Asn1Identifier id, Asn1Object[] newContent, int size):base(id)
+ {
+ content = newContent;
+ contentIndex = size;
+ return ;
+ }
+
+ /// <summary> Encodes the contents of this Asn1Structured directly to an output
+ /// stream.
+ /// </summary>
+ public override void encode(Asn1Encoder enc, System.IO.Stream out_Renamed)
+ {
+ enc.encode(this, out_Renamed);
+ return ;
+ }
+
+ /// <summary> Decode an Asn1Structured type from an InputStream.</summary>
+ [CLSCompliantAttribute(false)]
+ protected internal void decodeStructured(Asn1Decoder dec, System.IO.Stream in_Renamed, int len)
+ {
+ int[] componentLen = new int[1]; // collects length of component
+
+ while (len > 0)
+ {
+ add(dec.decode(in_Renamed, componentLen));
+ len -= componentLen[0];
+ }
+ return ;
+ }
+
+ /// <summary> Returns an array containing the individual ASN.1 elements
+ /// of this Asn1Structed object.
+ ///
+ /// </summary>
+ /// <returns> an array of Asn1Objects
+ /// </returns>
+ public Asn1Object[] toArray()
+ {
+ Asn1Object[] cloneArray = new Asn1Object[contentIndex];
+ Array.Copy((System.Array) content, 0, (System.Array) cloneArray, 0, contentIndex);
+ return cloneArray;
+ }
+
+ /// <summary> Adds a new Asn1Object to the end of this Asn1Structured
+ /// object.
+ ///
+ /// </summary>
+ /// <param name="value">The Asn1Object to add to this Asn1Structured
+ /// object.
+ /// </param>
+ public void add(Asn1Object value_Renamed)
+ {
+ if (contentIndex == content.Length)
+ {
+ // Array too small, need to expand it, double length
+ int newSize = contentIndex + contentIndex;
+ Asn1Object[] newArray = new Asn1Object[newSize];
+ Array.Copy((System.Array) content, 0, (System.Array) newArray, 0, contentIndex);
+ content = newArray;
+ }
+ content[contentIndex++] = value_Renamed;
+ return ;
+ }
+
+ /// <summary> Replaces the Asn1Object in the specified index position of
+ /// this Asn1Structured object.
+ ///
+ /// </summary>
+ /// <param name="index">The index into the Asn1Structured object where
+ /// this new ANS1Object will be placed.
+ ///
+ /// </param>
+ /// <param name="value">The Asn1Object to set in this Asn1Structured
+ /// object.
+ /// </param>
+ public void set_Renamed(int index, Asn1Object value_Renamed)
+ {
+ if ((index >= contentIndex) || (index < 0))
+ {
+ throw new System.IndexOutOfRangeException("Asn1Structured: get: index " + index + ", size " + contentIndex);
+ }
+ content[index] = value_Renamed;
+ return ;
+ }
+
+ /// <summary> Gets a specific Asn1Object in this structred object.
+ ///
+ /// </summary>
+ /// <param name="index">The index of the Asn1Object to get from
+ /// this Asn1Structured object.
+ /// </param>
+ public Asn1Object get_Renamed(int index)
+ {
+ if ((index >= contentIndex) || (index < 0))
+ {
+ throw new System.IndexOutOfRangeException("Asn1Structured: set: index " + index + ", size " + contentIndex);
+ }
+ return content[index];
+ }
+
+ /// <summary> Returns the number of Asn1Obejcts that have been encoded
+ /// into this Asn1Structured class.
+ /// </summary>
+ public int size()
+ {
+ return contentIndex;
+ }
+
+ /// <summary> Creates a String representation of this Asn1Structured.
+ /// object.
+ ///
+ /// </summary>
+ /// <param name="type">the Type to put in the String representing this structured object
+ ///
+ /// </param>
+ /// <returns> the String representation of this object.
+ /// </returns>
+ [CLSCompliantAttribute(false)]
+ public virtual System.String toString(System.String type)
+ {
+ System.Text.StringBuilder sb = new System.Text.StringBuilder();
+
+ sb.Append(type);
+
+ for (int i = 0; i < contentIndex; i++)
+ {
+ sb.Append(content[i]);
+ if (i != contentIndex - 1)
+ sb.Append(", ");
+ }
+ sb.Append(" }");
+
+ return base.ToString() + sb.ToString();
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1Tagged.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1Tagged.cs
new file mode 100755
index 00000000000..e638727ed04
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1Tagged.cs
@@ -0,0 +1,172 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.Asn1.Asn1Tagged.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+
+namespace Novell.Directory.Ldap.Asn1
+{
+
+ /// <summary> The Asn1Tagged class can hold a base Asn1Object with a distinctive tag
+ /// describing the type of that base object. It also maintains a boolean value
+ /// indicating whether the value should be encoded by EXPLICIT or IMPLICIT
+ /// means. (Explicit is true by default.)
+ ///
+ /// If the type is encoded IMPLICITLY, the base types form, length and content
+ /// will be encoded as usual along with the class type and tag specified in
+ /// the constructor of this Asn1Tagged class.
+ ///
+ /// If the type is to be encoded EXPLICITLY, the base type will be encoded as
+ /// usual after the Asn1Tagged identifier has been encoded.
+ /// </summary>
+ [CLSCompliantAttribute(true)]
+ public class Asn1Tagged:Asn1Object
+ {
+ /// <summary> Sets the Asn1Object tagged value</summary>
+ [CLSCompliantAttribute(false)]
+ virtual public Asn1Object TaggedValue
+ {
+ set
+ {
+ this.content = value;
+ if (!explicit_Renamed && value != null)
+ {
+ // replace object's id with new tag.
+ value.setIdentifier(this.getIdentifier());
+ }
+ }
+
+ }
+ /// <summary> Returns a boolean value indicating if this object uses
+ /// EXPLICIT tagging.
+ /// </summary>
+ virtual public bool Explicit
+ {
+ get
+ {
+ return explicit_Renamed;
+ }
+
+ }
+
+ private bool explicit_Renamed;
+ private Asn1Object content;
+
+ /* Constructors for Asn1Tagged
+ */
+
+ /// <summary> Constructs an Asn1Tagged object using the provided
+ /// AN1Identifier and the Asn1Object.
+ ///
+ /// The explicit flag defaults to true as per the spec.
+ /// </summary>
+ public Asn1Tagged(Asn1Identifier identifier, Asn1Object object_Renamed):this(identifier, object_Renamed, true)
+ {
+ return ;
+ }
+
+ /// <summary> Constructs an Asn1Tagged object.</summary>
+ public Asn1Tagged(Asn1Identifier identifier, Asn1Object object_Renamed, bool explicit_Renamed):base(identifier)
+ {
+ this.content = object_Renamed;
+ this.explicit_Renamed = explicit_Renamed;
+
+ if (!explicit_Renamed && content != null)
+ {
+ // replace object's id with new tag.
+ content.setIdentifier(identifier);
+ }
+ return ;
+ }
+
+ /// <summary> Constructs an Asn1Tagged object by decoding data from an
+ /// input stream.
+ ///
+ /// </summary>
+ /// <param name="dec">The decoder object to use when decoding the
+ /// input stream. Sometimes a developer might want to pass
+ /// in his/her own decoder object<br>
+ ///
+ /// </param>
+ /// <param name="in">A byte stream that contains the encoded ASN.1
+ ///
+ /// </param>
+ [CLSCompliantAttribute(false)]
+ public Asn1Tagged(Asn1Decoder dec, System.IO.Stream in_Renamed, int len, Asn1Identifier identifier):base(identifier)
+ {
+
+ // If we are decoding an implicit tag, there is no way to know at this
+ // low level what the base type really is. We can place the content
+ // into an Asn1OctetString type and pass it back to the application who
+ // will be able to create the appropriate ASN.1 type for this tag.
+ content = new Asn1OctetString(dec, in_Renamed, len);
+ return ;
+ }
+
+ /* Asn1Object implementation
+ */
+
+ /// <summary> Call this method to encode the current instance into the
+ /// specified output stream using the specified encoder object.
+ ///
+ /// </summary>
+ /// <param name="enc">Encoder object to use when encoding self.<br>
+ ///
+ /// </param>
+ /// <param name="out">The output stream onto which the encoded byte
+ /// stream is written.
+ /// </param>
+ public override void encode(Asn1Encoder enc, System.IO.Stream out_Renamed)
+ {
+ enc.encode(this, out_Renamed);
+ return ;
+ }
+
+ /* Asn1Tagged specific methods
+ */
+
+ /// <summary> Returns the Asn1Object stored in this Asn1Tagged object</summary>
+ public Asn1Object taggedValue()
+ {
+ return content;
+ }
+
+ /// <summary> Return a String representation of this Asn1Object.</summary>
+ public override System.String ToString()
+ {
+ if (explicit_Renamed)
+ {
+ return base.ToString() + content.ToString();
+ }
+ // implicit tagging
+ return content.ToString();
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/LBERDecoder.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/LBERDecoder.cs
new file mode 100755
index 00000000000..0cf4847a7d3
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/LBERDecoder.cs
@@ -0,0 +1,277 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.Asn1.LBERDecoder.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+
+namespace Novell.Directory.Ldap.Asn1
+{
+
+ /// <summary> This class provides LBER decoding routines for ASN.1 Types. LBER is a
+ /// subset of BER as described in the following taken from 5.1 of RFC 2251:
+ ///
+ /// <p>5.1. Mapping Onto BER-based Transport Services
+ ///
+ /// The protocol elements of Ldap are encoded for exchange using the
+ /// Basic Encoding Rules (BER) [11] of ASN.1 [3]. However, due to the
+ /// high overhead involved in using certain elements of the BER, the
+ /// following additional restrictions are placed on BER-encodings of Ldap
+ /// protocol elements:
+ ///
+ /// <li>(1) Only the definite form of length encoding will be used.
+ ///
+ /// <li>(2) OCTET STRING values will be encoded in the primitive form only.
+ ///
+ /// <li>(3) If the value of a BOOLEAN type is true, the encoding MUST have
+ /// its contents octets set to hex "FF".
+ ///
+ /// <li>(4) If a value of a type is its default value, it MUST be absent.
+ /// Only some BOOLEAN and INTEGER types have default values in this
+ /// protocol definition.
+ ///
+ /// <p>These restrictions do not apply to ASN.1 types encapsulated inside of
+ /// OCTET STRING values, such as attribute values, unless otherwise
+ /// noted.
+ ///
+ /// <p>[3] ITU-T Rec. X.680, "Abstract Syntax Notation One (ASN.1) -
+ /// Specification of Basic Notation", 1994.
+ ///
+ /// <p>[11] ITU-T Rec. X.690, "Specification of ASN.1 encoding rules: Basic,
+ /// Canonical, and Distinguished Encoding Rules", 1994.
+ ///
+ /// </summary>
+ [CLSCompliantAttribute(true)]
+ public class LBERDecoder : Asn1Decoder
+ {
+ public LBERDecoder()
+ {
+ InitBlock();
+ }
+ public void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context)
+ {
+ }
+
+ private void InitBlock()
+ {
+ asn1ID = new Asn1Identifier();
+ asn1Len = new Asn1Length();
+ }
+ //used to speed up decode, so it doesn't need to recreate an identifier every time
+ //instead just reset is called CANNOT be static for multiple connections
+ private Asn1Identifier asn1ID;
+ private Asn1Length asn1Len;
+
+
+ /* Generic decode routines
+ */
+
+ /// <summary> Decode an LBER encoded value into an Asn1Type from a byte array.</summary>
+ [CLSCompliantAttribute(false)]
+ public virtual Asn1Object decode(sbyte[] value_Renamed)
+ {
+ Asn1Object asn1 = null;
+
+ System.IO.MemoryStream in_Renamed = new System.IO.MemoryStream(SupportClass.ToByteArray(value_Renamed));
+ try
+ {
+ asn1 = decode(in_Renamed);
+ }
+ catch (System.IO.IOException ioe)
+ {
+ }
+ return asn1;
+ }
+
+ /// <summary> Decode an LBER encoded value into an Asn1Type from an InputStream.</summary>
+ public virtual Asn1Object decode(System.IO.Stream in_Renamed)
+ {
+ int[] len = new int[1];
+ return decode(in_Renamed, len);
+ }
+
+ /// <summary> Decode an LBER encoded value into an Asn1Object from an InputStream.
+ ///
+ /// <p> This method also returns the total length of this encoded
+ /// Asn1Object (length of type + length of length + length of content)
+ /// in the parameter len. This information is helpful when decoding
+ /// structured types.
+ /// </summary>
+ public virtual Asn1Object decode(System.IO.Stream in_Renamed, int[] len)
+ {
+ asn1ID.reset(in_Renamed);
+ asn1Len.reset(in_Renamed);
+
+ int length = asn1Len.Length;
+ len[0] = asn1ID.EncodedLength + asn1Len.EncodedLength + length;
+
+ if (asn1ID.Universal)
+ {
+ switch (asn1ID.Tag)
+ {
+
+ case Asn1Sequence.TAG:
+ return new Asn1Sequence(this, in_Renamed, length);
+
+ case Asn1Set.TAG:
+ return new Asn1Set(this, in_Renamed, length);
+
+ case Asn1Boolean.TAG:
+ return new Asn1Boolean(this, in_Renamed, length);
+
+ case Asn1Integer.TAG:
+ return new Asn1Integer(this, in_Renamed, length);
+
+ case Asn1OctetString.TAG:
+ return new Asn1OctetString(this, in_Renamed, length);
+
+ case Asn1Enumerated.TAG:
+ return new Asn1Enumerated(this, in_Renamed, length);
+
+ case Asn1Null.TAG:
+ return new Asn1Null(); // has no content to decode.
+ /* Asn1 TYPE NOT YET SUPPORTED
+ case Asn1BitString.TAG:
+ return new Asn1BitString(this, in, length);
+ case Asn1ObjectIdentifier.TAG:
+ return new Asn1ObjectIdentifier(this, in, length);
+ case Asn1Real.TAG:
+ return new Asn1Real(this, in, length);
+ case Asn1NumericString.TAG:
+ return new Asn1NumericString(this, in, length);
+ case Asn1PrintableString.TAG:
+ return new Asn1PrintableString(this, in, length);
+ case Asn1TeletexString.TAG:
+ return new Asn1TeletexString(this, in, length);
+ case Asn1VideotexString.TAG:
+ return new Asn1VideotexString(this, in, length);
+ case Asn1IA5String.TAG:
+ return new Asn1IA5String(this, in, length);
+ case Asn1GraphicString.TAG:
+ return new Asn1GraphicString(this, in, length);
+ case Asn1VisibleString.TAG:
+ return new Asn1VisibleString(this, in, length);
+ case Asn1GeneralString.TAG:
+ return new Asn1GeneralString(this, in, length);
+ */
+
+
+ default:
+ throw new System.IO.EndOfStreamException("Unknown tag"); // !!! need a better exception
+
+ }
+ }
+ else
+ {
+ // APPLICATION or CONTEXT-SPECIFIC tag
+ return new Asn1Tagged(this, in_Renamed, length, (Asn1Identifier) asn1ID.Clone());
+ }
+ }
+
+ /* Decoders for ASN.1 simple type Contents
+ */
+
+ /// <summary> Decode a boolean directly from a stream.</summary>
+ public System.Object decodeBoolean(System.IO.Stream in_Renamed, int len)
+ {
+ sbyte[] lber = new sbyte[len];
+
+ int i = SupportClass.ReadInput(in_Renamed, ref lber, 0, lber.Length);
+
+ if (i != len)
+ throw new System.IO.EndOfStreamException("LBER: BOOLEAN: decode error: EOF");
+
+ return (lber[0] == 0x00)?false:true;
+ }
+
+ /// <summary> Decode a Numeric type directly from a stream. Decodes INTEGER
+ /// and ENUMERATED types.
+ /// </summary>
+ public System.Object decodeNumeric(System.IO.Stream in_Renamed, int len)
+ {
+ long l = 0;
+ int r = in_Renamed.ReadByte();
+
+ if (r < 0)
+ throw new System.IO.EndOfStreamException("LBER: NUMERIC: decode error: EOF");
+
+ if ((r & 0x80) != 0)
+ {
+ // check for negative number
+ l = - 1;
+ }
+
+ l = (l << 8) | r;
+
+ for (int i = 1; i < len; i++)
+ {
+ r = in_Renamed.ReadByte();
+ if (r < 0)
+ throw new System.IO.EndOfStreamException("LBER: NUMERIC: decode error: EOF");
+ l = (l << 8) | r;
+ }
+ return (System.Int64) l;
+ }
+
+ /// <summary> Decode an OctetString directly from a stream.</summary>
+ public System.Object decodeOctetString(System.IO.Stream in_Renamed, int len)
+ {
+ sbyte[] octets = new sbyte[len];
+ int totalLen = 0;
+
+ while (totalLen < len)
+ {
+ // Make sure we have read all the data
+ int inLen = SupportClass.ReadInput(in_Renamed, ref octets, totalLen, len - totalLen);
+ totalLen += inLen;
+ }
+
+ return octets;
+ }
+
+ /// <summary> Decode a CharacterString directly from a stream.</summary>
+ public System.Object decodeCharacterString(System.IO.Stream in_Renamed, int len)
+ {
+ sbyte[] octets = new sbyte[len];
+
+ for (int i = 0; i < len; i++)
+ {
+ int ret = in_Renamed.ReadByte(); // blocks
+ if (ret == - 1)
+ throw new System.IO.EndOfStreamException("LBER: CHARACTER STRING: decode error: EOF");
+ octets[i] = (sbyte) ret;
+ }
+ System.Text.Encoding encoder = System.Text.Encoding.GetEncoding("utf-8");
+ char[] dchar = encoder.GetChars(SupportClass.ToByteArray(octets));
+ string rval = new String(dchar);
+
+ return rval;//new String( "UTF8");
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/LBEREncoder.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/LBEREncoder.cs
new file mode 100755
index 00000000000..ad265efe10b
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/LBEREncoder.cs
@@ -0,0 +1,305 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.Asn1.LBEREncoder.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+
+namespace Novell.Directory.Ldap.Asn1
+{
+
+ /// <summary> This class provides LBER encoding routines for ASN.1 Types. LBER is a
+ /// subset of BER as described in the following taken from 5.1 of RFC 2251:
+ ///
+ /// <p>5.1. Mapping Onto BER-based Transport Services
+ ///
+ /// The protocol elements of Ldap are encoded for exchange using the
+ /// Basic Encoding Rules (BER) [11] of ASN.1 [3]. However, due to the
+ /// high overhead involved in using certain elements of the BER, the
+ /// following additional restrictions are placed on BER-encodings of Ldap
+ /// protocol elements:
+ ///
+ /// <li>(1) Only the definite form of length encoding will be used.
+ ///
+ /// <li>(2) OCTET STRING values will be encoded in the primitive form only.
+ ///
+ /// <li>(3) If the value of a BOOLEAN type is true, the encoding MUST have
+ /// its contents octets set to hex "FF".
+ ///
+ /// <li>(4) If a value of a type is its default value, it MUST be absent.
+ /// Only some BOOLEAN and INTEGER types have default values in this
+ /// protocol definition.
+ ///
+ /// <p>These restrictions do not apply to ASN.1 types encapsulated inside of
+ /// OCTET STRING values, such as attribute values, unless otherwise
+ /// noted.
+ ///
+ /// <p>[3] ITU-T Rec. X.680, "Abstract Syntax Notation One (ASN.1) -
+ /// Specification of Basic Notation", 1994.
+ ///
+ /// <p>[11] ITU-T Rec. X.690, "Specification of ASN.1 encoding rules: Basic,
+ /// Canonical, and Distinguished Encoding Rules", 1994.
+ ///
+ /// </summary>
+ [CLSCompliantAttribute(true)]
+ public class LBEREncoder : Asn1Encoder
+ {
+
+ /* Encoders for ASN.1 simple type Contents
+ */
+ public void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context)
+ {
+ }
+ /// <summary> BER Encode an Asn1Boolean directly into the specified output stream.</summary>
+ public virtual void encode(Asn1Boolean b, System.IO.Stream out_Renamed)
+ {
+ /* Encode the id */
+ encode(b.getIdentifier(), out_Renamed);
+
+ /* Encode the length */
+ out_Renamed.WriteByte((System.Byte) 0x01);
+
+ /* Encode the boolean content*/
+ out_Renamed.WriteByte((byte) (b.booleanValue()?(sbyte) SupportClass.Identity(0xff):(sbyte) 0x00));
+
+ return ;
+ }
+
+ /// <summary> Encode an Asn1Numeric directly into the specified outputstream.
+ ///
+ /// <p>Use a two's complement representation in the fewest number of octets
+ /// possible.
+ ///
+ /// <p>Can be used to encode INTEGER and ENUMERATED values.
+ /// </summary>
+ public void encode(Asn1Numeric n, System.IO.Stream out_Renamed)
+ {
+ sbyte[] octets = new sbyte[8];
+ sbyte len;
+ long value_Renamed = n.longValue();
+ long endValue = (value_Renamed < 0)?- 1:0;
+ long endSign = endValue & 0x80;
+
+ for (len = 0; len == 0 || value_Renamed != endValue || (octets[len - 1] & 0x80) != endSign; len++)
+ {
+ octets[len] = (sbyte) (value_Renamed & 0xFF);
+ value_Renamed >>= 8;
+ }
+
+ encode(n.getIdentifier(), out_Renamed);
+ out_Renamed.WriteByte((byte) len); // Length
+ for (int i = len - 1; i >= 0; i--)
+ // Content
+ out_Renamed.WriteByte((byte) octets[i]);
+ return ;
+ }
+
+ /* Asn1 TYPE NOT YET SUPPORTED
+ * Encode an Asn1Real directly to a stream.
+ public void encode(Asn1Real r, OutputStream out)
+ throws IOException
+ {
+ throw new IOException("LBEREncoder: Encode to a stream not implemented");
+ }
+ */
+
+ /// <summary> Encode an Asn1Null directly into the specified outputstream.</summary>
+ public void encode(Asn1Null n, System.IO.Stream out_Renamed)
+ {
+ encode(n.getIdentifier(), out_Renamed);
+ out_Renamed.WriteByte((System.Byte) 0x00); // Length (with no Content)
+ return ;
+ }
+
+ /* Asn1 TYPE NOT YET SUPPORTED
+ * Encode an Asn1BitString directly to a stream.
+ public void encode(Asn1BitString bs, OutputStream out)
+ throws IOException
+ {
+ throw new IOException("LBEREncoder: Encode to a stream not implemented");
+ }
+ */
+
+ /// <summary> Encode an Asn1OctetString directly into the specified outputstream.</summary>
+ public void encode(Asn1OctetString os, System.IO.Stream out_Renamed)
+ {
+ encode(os.getIdentifier(), out_Renamed);
+ encodeLength(os.byteValue().Length, out_Renamed);
+ sbyte[] temp_sbyteArray;
+ temp_sbyteArray = os.byteValue();
+ out_Renamed.Write(SupportClass.ToByteArray(temp_sbyteArray), 0, temp_sbyteArray.Length);;;
+ return ;
+ }
+
+ /* Asn1 TYPE NOT YET SUPPORTED
+ * Encode an Asn1ObjectIdentifier directly to a stream.
+ * public void encode(Asn1ObjectIdentifier oi, OutputStream out)
+ * throws IOException
+ * {
+ * throw new IOException("LBEREncoder: Encode to a stream not implemented");
+ * }
+ */
+
+ /* Asn1 TYPE NOT YET SUPPORTED
+ * Encode an Asn1CharacterString directly to a stream.
+ * public void encode(Asn1CharacterString cs, OutputStream out)
+ * throws IOException
+ * {
+ * throw new IOException("LBEREncoder: Encode to a stream not implemented");
+ * }
+ */
+
+ /* Encoders for ASN.1 structured types
+ */
+
+ /// <summary> Encode an Asn1Structured into the specified outputstream. This method
+ /// can be used to encode SET, SET_OF, SEQUENCE, SEQUENCE_OF
+ /// </summary>
+ public void encode(Asn1Structured c, System.IO.Stream out_Renamed)
+ {
+ encode(c.getIdentifier(), out_Renamed);
+
+ Asn1Object[] value_Renamed = c.toArray();
+
+ System.IO.MemoryStream output = new System.IO.MemoryStream();
+
+ /* Cycle through each element encoding each element */
+ for (int i = 0; i < value_Renamed.Length; i++)
+ {
+ (value_Renamed[i]).encode(this, output);
+ }
+
+ /* Encode the length */
+ encodeLength((int)output.Length, out_Renamed);
+
+ /* Add each encoded element into the output stream */
+ sbyte[] temp_sbyteArray;
+ temp_sbyteArray = SupportClass.ToSByteArray(output.ToArray());
+ out_Renamed.Write(SupportClass.ToByteArray(temp_sbyteArray), 0, temp_sbyteArray.Length);;;
+ return ;
+ }
+
+ /// <summary> Encode an Asn1Tagged directly into the specified outputstream.</summary>
+ public void encode(Asn1Tagged t, System.IO.Stream out_Renamed)
+ {
+ if (t.Explicit)
+ {
+ encode(t.getIdentifier(), out_Renamed);
+
+ /* determine the encoded length of the base type. */
+ System.IO.MemoryStream encodedContent = new System.IO.MemoryStream();
+ t.taggedValue().encode(this, encodedContent);
+
+ encodeLength((int)encodedContent.Length, out_Renamed);
+ sbyte[] temp_sbyteArray;
+ temp_sbyteArray = SupportClass.ToSByteArray(encodedContent.ToArray());
+ out_Renamed.Write(SupportClass.ToByteArray(temp_sbyteArray), 0, temp_sbyteArray.Length);;;;
+ }
+ else
+ {
+ t.taggedValue().encode(this, out_Renamed);
+ }
+ return ;
+ }
+
+ /* Encoders for ASN.1 useful types
+ */
+ /* Encoder for ASN.1 Identifier
+ */
+
+ /// <summary> Encode an Asn1Identifier directly into the specified outputstream.</summary>
+ public void encode(Asn1Identifier id, System.IO.Stream out_Renamed)
+ {
+ int c = id.Asn1Class;
+ int t = id.Tag;
+ sbyte ccf = (sbyte) ((c << 6) | (id.Constructed?0x20:0));
+
+ if (t < 30)
+ {
+ /* single octet */
+ out_Renamed.WriteByte((System.Byte) (ccf | t));
+ }
+ else
+ {
+ /* multiple octet */
+ out_Renamed.WriteByte((System.Byte) (ccf | 0x1F));
+ encodeTagInteger(t, out_Renamed);
+ }
+ return ;
+ }
+
+ /* Private helper methods
+ */
+
+ /*
+ * Encodes the specified length into the the outputstream
+ */
+ private void encodeLength(int length, System.IO.Stream out_Renamed)
+ {
+ if (length < 0x80)
+ {
+ out_Renamed.WriteByte((System.Byte) length);
+ }
+ else
+ {
+ sbyte[] octets = new sbyte[4]; // 4 bytes sufficient for 32 bit int.
+ sbyte n;
+ for (n = 0; length != 0; n++)
+ {
+ octets[n] = (sbyte) (length & 0xFF);
+ length >>= 8;
+ }
+
+ out_Renamed.WriteByte((System.Byte) (0x80 | n));
+
+ for (int i = n - 1; i >= 0; i--)
+ out_Renamed.WriteByte((byte) octets[i]);
+ }
+ return ;
+ }
+
+ /// <summary> Encodes the provided tag into the outputstream.</summary>
+ private void encodeTagInteger(int value_Renamed, System.IO.Stream out_Renamed)
+ {
+ sbyte[] octets = new sbyte[5];
+ int n;
+ for (n = 0; value_Renamed != 0; n++)
+ {
+ octets[n] = (sbyte) (value_Renamed & 0x7F);
+ value_Renamed = value_Renamed >> 7;
+ }
+ for (int i = n - 1; i > 0; i--)
+ {
+ out_Renamed.WriteByte((System.Byte) (octets[i] | 0x80));
+ }
+ out_Renamed.WriteByte((byte) octets[0]);
+ return ;
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Controls/LdapEntryChangeControl.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Controls/LdapEntryChangeControl.cs
new file mode 100755
index 00000000000..0bdcba595c5
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Controls/LdapEntryChangeControl.cs
@@ -0,0 +1,209 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.Controls.LdapEntryChangeControl.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+using Novell.Directory.Ldap;
+using Novell.Directory.Ldap.Asn1;
+
+namespace Novell.Directory.Ldap.Controls
+{
+
+ /// <summary> LdapEntryChangeControl is a Server Control returned at the request
+ /// of the client in response to a persistent search request. It
+ /// contains additional information about a change such as what type of
+ /// change occurred.
+ ///
+ /// <p>Sample Code: <a href="http://developer.novell.com/ndk/doc/samplecode/
+ /// jldap_sample/controls/SearchPersist.java.html">SearchPersist.java</p>
+ /// </summary>
+ public class LdapEntryChangeControl:LdapControl
+ {
+ /// <summary> returns the record number of the change in the servers change log.
+ ///
+ /// </summary>
+ /// <returns> the record number of the change in the server's change log.
+ /// The server may not return a change number. In this case the return
+ /// value is -1
+ /// </returns>
+ virtual public bool HasChangeNumber
+ {
+
+
+ get
+ {
+ return m_hasChangeNumber;
+ }
+
+ }
+ /// <summary> returns the record number of the change in the servers change log.
+ ///
+ /// </summary>
+ /// <returns> the record number of the change in the server's change log.
+ /// The server may not return a change number. In this case the return
+ /// value is -1
+ /// </returns>
+ virtual public int ChangeNumber
+ {
+
+
+ get
+ {
+ return m_changeNumber;
+ }
+
+ }
+ /// <summary> Returns the type of change that occured
+ ///
+ /// </summary>
+ /// <returns> returns one of the following values indicating the type of
+ /// change that occurred:
+ /// LdapPersistSearchControl.ADD
+ /// LdapPersistSearchControl.DELETE
+ /// LdapPersistSearchControl.MODIFY
+ /// LdapPersistSearchControl.MODDN.
+ /// </returns>
+ virtual public int ChangeType
+ {
+ get
+ {
+ return m_changeType;
+ }
+
+ }
+ /// <summary> Returns the previous DN of the entry, if it was renamed.
+ ///
+ /// </summary>
+ /// <returns> the previous DN of the entry if the entry was renamed (ie. if the
+ /// change type is LdapersistSearchControl.MODDN.
+ /// </returns>
+ virtual public System.String PreviousDN
+ {
+ get
+ {
+ return m_previousDN;
+ }
+
+ }
+ private int m_changeType;
+ private System.String m_previousDN;
+ private bool m_hasChangeNumber;
+ private int m_changeNumber;
+
+ /// <summary> This constructor is called by the SDK to create an
+ /// LdapEntryChangeControl. This constructor should NOT be called by
+ /// application developers. It must be public since it resides in a
+ /// different package than the classes that call it.</P>
+ /// <p>The Entry Change Control is defined as follows:</p>
+ /// <p>EntryChangeNotification ::= SEQUENCE {
+ /// <p>changeType ENUMERATED {</p>
+ /// <p>add (1),</p>
+ /// <p>delete (2),</p>
+ /// <p>modify (4),</p>
+ /// <p>modDN (8)</p>
+ /// <p>},</p>
+ /// <p>previousDN LdapDN OPTIONAL, -- modifyDN ops. only</p>
+ /// <p>changeNumber INTEGER OPTIONAL -- if supported</p>
+ /// <p>}</p>
+ ///
+ /// </summary>
+ /// <param name="oid"> The OID of the control, as a dotted string.
+ /// <br><br>
+ /// </param>
+ /// <param name="critical"> True if the Ldap operation should be discarded if
+ /// the control is not supported. False if
+ /// the operation can be processed without the control.
+ /// <br><br>
+ /// </param>
+ /// <param name="value"> The control-specific data.
+ /// </param>
+ [CLSCompliantAttribute(false)]
+ public LdapEntryChangeControl(System.String oid, bool critical, sbyte[] value_Renamed):base(oid, critical, value_Renamed)
+ {
+
+ // Create a decoder objet
+ LBERDecoder decoder = new LBERDecoder();
+ if (decoder == null)
+ throw new System.IO.IOException("Decoding error.");
+
+ // We should get a sequence initially
+ Asn1Object asnObj = decoder.decode(value_Renamed);
+
+ if ((asnObj == null) || (!(asnObj is Asn1Sequence)))
+ throw new System.IO.IOException("Decoding error.");
+
+ Asn1Sequence sequence = (Asn1Sequence) asnObj;
+
+
+ // The first element in the sequence should be an enumerated type
+ Asn1Object asn1Obj = sequence.get_Renamed(0);
+ if ((asn1Obj == null) || (!(asn1Obj is Asn1Enumerated)))
+ throw new System.IO.IOException("Decoding error.");
+
+ m_changeType = ((Asn1Enumerated) asn1Obj).intValue();
+
+ //check for optional elements
+ if ((sequence.size() > 1) && (m_changeType == 8))
+ //8 means modifyDN
+ {
+ // get the previous DN - it is encoded as an octet string
+ asn1Obj = sequence.get_Renamed(1);
+ if ((asn1Obj == null) || (!(asn1Obj is Asn1OctetString)))
+ throw new System.IO.IOException("Decoding error get previous DN");
+
+ m_previousDN = ((Asn1OctetString) asn1Obj).stringValue();
+ }
+ else
+ {
+ m_previousDN = "";
+ }
+
+ //check for change number
+ if (sequence.size() == 3)
+ {
+ asn1Obj = sequence.get_Renamed(2);
+ if ((asn1Obj == null) || (!(asn1Obj is Asn1Integer)))
+ throw new System.IO.IOException("Decoding error getting change number");
+
+ m_changeNumber = ((Asn1Integer) asn1Obj).intValue();
+ m_hasChangeNumber = true;
+ }
+ else
+ m_hasChangeNumber = false;
+ return ;
+ }
+
+ /// <summary> Returns a string representation of the control for debugging.</summary>
+ public override System.String ToString()
+ {
+ return base.ToString();
+ }
+ } //end class LdapEntryChangeControl
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Controls/LdapPersistSearchControl.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Controls/LdapPersistSearchControl.cs
new file mode 100755
index 00000000000..de6d67c85c2
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Controls/LdapPersistSearchControl.cs
@@ -0,0 +1,284 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.Controls.LdapPersistSearchControl.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+using Novell.Directory.Ldap;
+using Novell.Directory.Ldap.Asn1;
+
+namespace Novell.Directory.Ldap.Controls
+{
+
+
+ /// <summary> LdapPersistSearchControl is a Server Control that allows a client
+ /// to receive notifications from the server of changes to entries within
+ /// the searches result set. The client can be notified when an entry is
+ /// added to the result set, when an entry is deleted from the result set,
+ /// when a DN has been changed or when and attribute value has been changed.
+ ///
+ /// <p>Sample Code: <a href="http://developer.novell.com/ndk/doc/samplecode/
+ /// jldap_sample/controls/SearchPersist.java.html">SearchPersist.java</p>
+ /// </summary>
+ public class LdapPersistSearchControl:LdapControl
+ {
+ /// <summary> Returns the change types to be monitored as a logical OR of any or
+ /// all of these values: ADD, DELETE, MODIFY, and/or MODDN.
+ ///
+ /// </summary>
+ /// <returns> the change types to be monitored. The logical or of any of
+ /// the following values: ADD, DELETE, MODIFY, and/or MODDN.
+ /// </returns>
+ /// <summary> Sets the change types to be monitored.
+ ///
+ /// types The change types to be monitored as a logical OR of any or all
+ /// of these types: ADD, DELETE, MODIFY, and/or MODDN. Can also be set
+ /// to the value ANY which is defined as the logical OR of all of the
+ /// preceding values.
+ /// </summary>
+ virtual public int ChangeTypes
+ {
+ get
+ {
+ return m_changeTypes;
+ }
+
+ set
+ {
+ m_changeTypes = value;
+ m_sequence.set_Renamed(CHANGETYPES_INDEX, new Asn1Integer(m_changeTypes));
+ setValue();
+ return ;
+ }
+
+ }
+ /// <summary> Returns true if entry change controls are to be returned with the
+ /// search results.
+ ///
+ /// </summary>
+ /// <returns> true if entry change controls are to be returned with the
+ /// search results. Otherwise, false is returned
+ /// </returns>
+ /// <summary> When set to true, requests that entry change controls be returned with
+ /// the search results.
+ ///
+ /// </summary>
+ /// <param name="returnControls"> true to return entry change controls.
+ /// </param>
+ virtual public bool ReturnControls
+ {
+ get
+ {
+ return m_returnControls;
+ }
+
+ set
+ {
+ m_returnControls = value;
+ m_sequence.set_Renamed(RETURNCONTROLS_INDEX, new Asn1Boolean(m_returnControls));
+ setValue();
+ return ;
+ }
+
+ }
+ /// <summary> getChangesOnly returns true if only changes are to be returned.
+ /// Results from the initial search are not returned.
+ ///
+ /// </summary>
+ /// <returns> true of only changes are to be returned
+ /// </returns>
+ /// <summary> When set to true, requests that only changes be returned, results from
+ /// the initial search are not returned.
+ /// </summary>
+ /// <param name="changesOnly"> true to skip results for the initial search
+ /// </param>
+ virtual public bool ChangesOnly
+ {
+ get
+ {
+ return m_changesOnly;
+ }
+
+ set
+ {
+ m_changesOnly = value;
+ m_sequence.set_Renamed(CHANGESONLY_INDEX, new Asn1Boolean(m_changesOnly));
+ setValue();
+ return ;
+ }
+
+ }
+ /* private data members */
+ private static int SEQUENCE_SIZE = 3;
+
+ private static int CHANGETYPES_INDEX = 0;
+ private static int CHANGESONLY_INDEX = 1;
+ private static int RETURNCONTROLS_INDEX = 2;
+
+ private static LBEREncoder s_encoder;
+
+ private int m_changeTypes;
+ private bool m_changesOnly;
+ private bool m_returnControls;
+ private Asn1Sequence m_sequence;
+
+ /// <summary> The requestOID of the persistent search control</summary>
+ private static System.String requestOID = "2.16.840.1.113730.3.4.3";
+
+ /// <summary> The responseOID of the psersistent search - entry change control</summary>
+ private static System.String responseOID = "2.16.840.1.113730.3.4.7";
+
+ /// <summary> Change type specifying that you want to track additions of new entries
+ /// to the directory.
+ /// </summary>
+ public const int ADD = 1;
+
+ /// <summary> Change type specifying that you want to track removals of entries from
+ /// the directory.
+ /// </summary>
+ public const int DELETE = 2;
+
+ /// <summary> Change type specifying that you want to track modifications of entries
+ /// in the directory.
+ /// </summary>
+ public const int MODIFY = 4;
+
+ /// <summary> Change type specifying that you want to track modifications of the DNs
+ /// of entries in the directory.
+ /// </summary>
+ public const int MODDN = 8;
+
+ /// <summary> Change type specifying that you want to track any of the above
+ /// modifications.
+ /// </summary>
+ public static readonly int ANY = ADD | DELETE | MODIFY | MODDN;
+
+ /* public constructors */
+
+ /// <summary> The default constructor. A control with changes equal to ANY,
+ /// isCritical equal to true, changesOnly equal to true, and
+ /// returnControls equal to true
+ /// </summary>
+ public LdapPersistSearchControl():this(ANY, true, true, true)
+ {
+ return ;
+ }
+
+ /// <summary> <p>Constructs an LdapPersistSearchControl object according to the
+ /// supplied parameters. The resulting control is used to specify a
+ /// persistent search.</p>
+ ///
+ /// </summary>
+ /// <param name="changeTypes"> the change types to monitor. The bitwise OR of any
+ /// of the following values:
+ /// <li> LdapPersistSearchControl.ADD</li>
+ /// <li> LdapPersistSearchControl.DELETE</li>
+ /// <li> LdapPersistSearchControl.MODIFY</li>
+ /// <li> LdapPersistSearchControl.MODDN</li>
+ /// To track all changes the value can be set to:
+ /// <li> LdapPersistSearchControl.ANY</li>
+ /// <br>
+ /// </param>
+ /// <param name="changesOnly"> true if you do not want the server to return
+ /// all existing entries in the directory that match the search
+ /// criteria. (Use this if you just want the changed entries to be
+ /// returned.)
+ /// <br><br>
+ /// </param>
+ /// <param name="returnControls"> true if you want the server to return entry
+ /// change controls with each entry in the search results. You need to
+ /// return entry change controls to discover what type of change
+ /// and other additional information about the change.
+ /// <br><br>
+ /// </param>
+ /// <param name="isCritical"> true if this control is critical to the search
+ /// operation. If true and the server does not support this control,
+ /// the server will not perform the search at all.
+ /// </param>
+ public LdapPersistSearchControl(int changeTypes, bool changesOnly, bool returnControls, bool isCritical):base(requestOID, isCritical, null)
+ {
+
+ m_changeTypes = changeTypes;
+ m_changesOnly = changesOnly;
+ m_returnControls = returnControls;
+
+ m_sequence = new Asn1Sequence(SEQUENCE_SIZE);
+
+ m_sequence.add(new Asn1Integer(m_changeTypes));
+ m_sequence.add(new Asn1Boolean(m_changesOnly));
+ m_sequence.add(new Asn1Boolean(m_returnControls));
+
+ setValue();
+ return ;
+ }
+
+ public override System.String ToString()
+ {
+ sbyte[] data = m_sequence.getEncoding(s_encoder);
+
+ System.Text.StringBuilder buf = new System.Text.StringBuilder(data.Length);
+
+ for (int i = 0; i < data.Length; i++)
+ {
+ buf.Append(data[i].ToString());
+ if (i < data.Length - 1)
+ buf.Append(",");
+ }
+
+ return buf.ToString();
+ }
+
+ /// <summary> Sets the encoded value of the LdapControlClass</summary>
+ private void setValue()
+ {
+ base.setValue(m_sequence.getEncoding(s_encoder));
+ return ;
+ }
+ static LdapPersistSearchControl()
+ {
+ s_encoder = new LBEREncoder();
+ /*
+ * This is where we register the control response
+ */
+ {
+ /* Register the Entry Change control class which is returned by the
+ * server in response to a persistent search request
+ */
+ try
+ {
+ // Register LdapEntryChangeControl
+ LdapControl.register(responseOID, System.Type.GetType("Novell.Directory.Ldap.Controls.LdapEntryChangeControl"));
+ }
+ catch (System.Exception e)
+ {
+ }
+ }
+ }
+ } // end class LdapPersistentSearchControl
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Controls/LdapSortControl.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Controls/LdapSortControl.cs
new file mode 100755
index 00000000000..5fe00cfe23a
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Controls/LdapSortControl.cs
@@ -0,0 +1,134 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.Controls.LdapSortControl.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+using Novell.Directory.Ldap;
+using Novell.Directory.Ldap.Asn1;
+
+namespace Novell.Directory.Ldap.Controls
+{
+
+ /// <summary> LdapSortControl is a Server Control to specify how search results are
+ /// to be sorted by the server. If a server does not support
+ /// sorting in general or for a particular query, the results will be
+ /// returned unsorted, along with a control indicating why they were not
+ /// sorted (or that sort controls are not supported). If the control was
+ /// marked "critical", the whole search operation will fail if the sort
+ /// control is not supported.
+ ///
+ /// <p>Sample Code: <a href="http://developer.novell.com/ndk/doc/samplecode/
+ /// jldap_sample/controls/AsyncSortControl.java.html">AsyncSortControl.java</p>
+ /// </summary>
+ public class LdapSortControl:LdapControl
+ {
+
+ private static int ORDERING_RULE = 0;
+ private static int REVERSE_ORDER = 1;
+ /// <summary> The requestOID of the sort control</summary>
+ private static System.String requestOID = "1.2.840.113556.1.4.473";
+
+ /// <summary> The responseOID of the sort control</summary>
+ private static System.String responseOID = "1.2.840.113556.1.4.474";
+ /// <summary> Constructs a sort control with a single key.
+ ///
+ /// </summary>
+ /// <param name="key"> A sort key object, which specifies attribute,
+ /// order, and optional matching rule.
+ ///
+ /// </param>
+ /// <param name="critical True">if the search operation is to fail if the
+ /// server does not support this control.
+ /// </param>
+ public LdapSortControl(LdapSortKey key, bool critical):this(new LdapSortKey[]{key}, critical)
+ {
+ return ;
+ }
+
+ /// <summary> Constructs a sort control with multiple sort keys.
+ ///
+ /// </summary>
+ /// <param name="keys An">array of sort key objects, to be processed in
+ /// order.
+ ///
+ /// </param>
+ /// <param name="critical True">if the search operation is to fail if the
+ /// server does not support this control.
+ /// </param>
+ public LdapSortControl(LdapSortKey[] keys, bool critical):base(requestOID, critical, null)
+ {
+
+ Asn1SequenceOf sortKeyList = new Asn1SequenceOf();
+
+ for (int i = 0; i < keys.Length; i++)
+ {
+
+ Asn1Sequence key = new Asn1Sequence();
+
+ key.add(new Asn1OctetString(keys[i].Key));
+
+ if ((System.Object) keys[i].MatchRule != null)
+ {
+ key.add(new Asn1Tagged(new Asn1Identifier(Asn1Identifier.CONTEXT, false, ORDERING_RULE), new Asn1OctetString(keys[i].MatchRule), false));
+ }
+
+ if (keys[i].Reverse == true)
+ {
+ // only add if true
+ key.add(new Asn1Tagged(new Asn1Identifier(Asn1Identifier.CONTEXT, false, REVERSE_ORDER), new Asn1Boolean(true), false));
+ }
+
+ sortKeyList.add(key);
+ }
+
+ setValue(sortKeyList.getEncoding(new LBEREncoder()));
+ return ;
+ }
+ static LdapSortControl()
+ {
+ /*
+ * This is where we register the control responses
+ */
+ {
+ /*
+ * Register the Server Sort Control class which is returned by the
+ * server in response to a Sort Request
+ */
+ try
+ {
+ LdapControl.register(responseOID, System.Type.GetType("Novell.Directory.Ldap.Controls.LdapSortResponse"));
+ }
+ catch (System.Exception e)
+ {
+ }
+ }
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Controls/LdapSortKey.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Controls/LdapSortKey.cs
new file mode 100755
index 00000000000..64972f0ae0c
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Controls/LdapSortKey.cs
@@ -0,0 +1,171 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.Controls.LdapSortKey.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+namespace Novell.Directory.Ldap.Controls
+{
+
+ /// <summary> Encapsulates parameters for sorting search results.
+ ///
+ /// <p>Sample Code: <a href="http://developer.novell.com/ndk/doc/samplecode/
+ /// jldap_sample/controls/AsyncSortControl.java.html">AsyncSortControl.java</p>
+ /// </summary>
+ public class LdapSortKey
+ {
+ /// <summary> Returns the attribute to used for sorting.
+ ///
+ /// </summary>
+ /// <returns> The name of the attribute used for sorting.
+ /// </returns>
+ virtual public System.String Key
+ {
+ get
+ {
+ return key;
+ }
+
+ }
+ /// <summary> Returns the sorting order, ascending or descending.
+ ///
+ /// </summary>
+ /// <returns> True if the sorting is done is descending order; false, if the
+ /// sorting is done is ascending order.
+ /// </returns>
+ virtual public bool Reverse
+ {
+ get
+ {
+ return reverse;
+ }
+
+ }
+ /// <summary> Returns the OID to be used as a matching rule.
+ ///
+ /// </summary>
+ /// <returns> The OID to be used as matching rule, or null if none is to be
+ /// used.
+ /// </returns>
+ virtual public System.String MatchRule
+ {
+ get
+ {
+ return matchRule;
+ }
+
+ }
+
+ private System.String key;
+ private bool reverse;
+ private System.String matchRule;
+
+ // Constructors
+
+ /// <summary> Constructs a new LdapSortKey object using an attribute as the sort key.
+ ///
+ /// </summary>
+ /// <param name="keyDescription">The single attribute to use for sorting. If the
+ /// name is preceded by a minus sign (-), the sorting
+ /// is done in reverse (descending) order.
+ /// An OID for a matching rule may be appended
+ /// following a ":".
+ /// <br>
+ /// Examples:
+ /// <ul>
+ /// <li> "cn" (sorts in ascending order by the cn attribute)</li>
+ /// <li> "-cn" (sorts in descending order by the cn attribute) </li>
+ /// <li> "cn:1.2.3.4.5" (sorts in ascending order by the cn attribute
+ /// using the matching rule 1.2.3.4.5) </li>
+ /// </ul>
+ /// </param>
+ public LdapSortKey(System.String keyDescription)
+ {
+ matchRule = null;
+ reverse = false;
+ System.String myKey = keyDescription;
+ if (myKey[0] == '-')
+ {
+ myKey = myKey.Substring(1);
+ this.reverse = true;
+ }
+ int pos = myKey.IndexOf(":");
+ if (pos != - 1)
+ {
+ this.key = myKey.Substring(0, (pos) - (0));
+ this.matchRule = myKey.Substring(pos + 1);
+ }
+ else
+ {
+ this.key = myKey;
+ }
+ return ;
+ }
+
+ /// <summary> Constructs a new LdapSortKey object with the specified attribute name
+ /// and sort order.
+ ///
+ /// </summary>
+ /// <param name="key"> The single attribute to use for sorting.
+ /// <br><br>
+ /// </param>
+ /// <param name="reverse">If true, sorting is done in descending order. If false,
+ /// sorting is done in ascending order.
+ /// </param>
+ public LdapSortKey(System.String key, bool reverse):this(key, reverse, null)
+ {
+ return ;
+ }
+
+ /// <summary> Constructs a new LdapSortKey object with the specified attribute name,
+ /// sort order, and a matching rule.
+ ///
+ /// </summary>
+ /// <param name="key"> The attribute name (for example, "cn") to use for sorting.
+ /// <br><br>
+ /// </param>
+ /// <param name="reverse"> If true, sorting is done in descending order. If false,
+ /// sorting is done in ascending order.
+ /// <br><br>
+ /// </param>
+ /// <param name="matchRule"> The object ID (OID) of a matching rule used for
+ /// collation. If the object will be used to request
+ /// server-side sorting of search results, it should
+ /// be the OID of a matching rule known to be
+ /// supported by that server.
+ /// </param>
+ public LdapSortKey(System.String key, bool reverse, System.String matchRule)
+ {
+ this.key = key;
+ this.reverse = reverse;
+ this.matchRule = matchRule;
+ return ;
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Controls/LdapSortResponse.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Controls/LdapSortResponse.cs
new file mode 100755
index 00000000000..9ece01515f4
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Controls/LdapSortResponse.cs
@@ -0,0 +1,145 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.Controls.LdapSortResponse.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+using Novell.Directory.Ldap;
+using Novell.Directory.Ldap.Asn1;
+
+namespace Novell.Directory.Ldap.Controls
+{
+
+ /// <summary> LdapSortResponse - will be added in newer version of Ldap
+ /// Controls draft-- add descritption from draft here.
+ /// </summary>
+ public class LdapSortResponse:LdapControl
+ {
+ /// <summary> If not null, this returns the attribute that caused the sort
+ /// operation to fail.
+ /// </summary>
+ virtual public System.String FailedAttribute
+ {
+ get
+ {
+ return failedAttribute;
+ }
+
+ }
+ /// <summary> Returns the result code from the sort</summary>
+ virtual public int ResultCode
+ {
+ get
+ {
+ return resultCode;
+ }
+
+ }
+
+ private System.String failedAttribute;
+ private int resultCode;
+
+ /// <summary> This constructor is usually called by the SDK to instantiate an
+ /// a LdapControl corresponding to the Server response to a Ldap
+ /// Sort Control request. Application programmers should not have
+ /// any reason to call the constructor. This constructor besides
+ /// constructing a LdapControl object parses the contents of the response
+ /// control.
+ /// <br>
+ /// RFC 2891 defines this response control as follows:
+ ///
+ /// The controlValue is an OCTET STRING, whose
+ /// value is the BER encoding of a value of the following SEQUENCE:
+ /// SortResult ::= SEQUENCE {
+ /// sortResult ENUMERATED {
+ /// success (0), -- results are sorted
+ /// operationsError (1), -- server internal failure
+ /// timeLimitExceeded (3), -- timelimit reached before
+ /// -- sorting was completed
+ /// strongAuthRequired (8), -- refused to return sorted
+ /// -- results via insecure
+ /// -- protocol
+ /// adminLimitExceeded (11), -- too many matching entries
+ /// -- for the server to sort
+ /// noSuchAttribute (16), -- unrecognized attribute
+ /// -- type in sort key
+ /// inappropriateMatching (18), -- unrecognized or
+ /// -- inappropriate matching
+ /// -- rule in sort key
+ /// insufficientAccessRights (50), -- refused to return sorted
+ /// -- results to this client
+ /// busy (51), -- too busy to process
+ /// unwillingToPerform (53), -- unable to sort
+ /// other (80)
+ /// },
+ /// attributeType [0] AttributeDescription OPTIONAL }
+ ///
+ ///
+ /// </summary>
+ /// <param name="oid"> The OID of the control, as a dotted string.
+ /// <br><br>
+ /// </param>
+ /// <param name="critical"> True if the Ldap operation should be discarded if
+ /// the control is not supported. False if
+ /// the operation can be processed without the control.
+ /// <br><br>
+ /// </param>
+ /// <param name="values"> The control-specific data.
+ /// </param>
+ [CLSCompliantAttribute(false)]
+ public LdapSortResponse(System.String oid, bool critical, sbyte[] values):base(oid, critical, values)
+ {
+
+ // Create a decoder object
+ LBERDecoder decoder = new LBERDecoder();
+ if (decoder == null)
+ throw new System.IO.IOException("Decoding error");
+
+ // We should get back an enumerated type
+ Asn1Object asnObj = decoder.decode(values);
+
+ if ((asnObj == null) || (!(asnObj is Asn1Sequence)))
+ throw new System.IO.IOException("Decoding error");
+
+
+ Asn1Object asn1Enum = ((Asn1Sequence) asnObj).get_Renamed(0);
+ if ((asn1Enum != null) && (asn1Enum is Asn1Enumerated))
+ resultCode = ((Asn1Enumerated) asn1Enum).intValue();
+
+ // Second element is the attributeType
+ if (((Asn1Sequence) asnObj).size() > 1)
+ {
+ Asn1Object asn1String = ((Asn1Sequence) asnObj).get_Renamed(1);
+ if ((asn1String != null) && (asn1String is Asn1OctetString))
+ failedAttribute = ((Asn1OctetString) asn1String).stringValue();
+ }
+ return ;
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Controls/LdapVirtualListControl.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Controls/LdapVirtualListControl.cs
new file mode 100755
index 00000000000..88ce879b728
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Controls/LdapVirtualListControl.cs
@@ -0,0 +1,527 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.Controls.LdapVirtualListControl.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+using Novell.Directory.Ldap;
+using Novell.Directory.Ldap.Asn1;
+
+namespace Novell.Directory.Ldap.Controls
+{
+
+ /* The following is the ASN.1 of the VLV Request packet:<br>
+ *
+ * VirtualListViewRequest ::= SEQUENCE {
+ * beforeCount INTEGER (0..maxInt),
+ * afterCount INTEGER (0..maxInt),
+ * CHOICE {
+ * byoffset [0] SEQUENCE {
+ * offset INTEGER (0 .. maxInt),
+ * contentCount INTEGER (0 .. maxInt) },
+ * greaterThanOrEqual [1] AssertionValue },
+ * contextID OCTET STRING OPTIONAL }
+ *
+ */
+
+ /// <summary> LdapVirtualListControl is a Server Control used to specify
+ /// that results from a search are to be returned in pages - which are
+ /// subsets of the entire virtual result set.
+ ///
+ /// <p>On success, an updated LdapVirtualListResponse object is
+ /// returned as a response Control, containing information on the virtual
+ /// list size and the actual first index. This object can then be used
+ /// by the client with a new requested position or length and sent to the
+ /// server to obtain a different segment of the virtual list.</p>
+ ///
+ /// <p>Sample Code: <a href="http://developer.novell.com/ndk/doc/samplecode/
+ /// jldap_sample/controls/VLVControl.java.html">VLVControl.java</p>
+ /// </summary>
+ public class LdapVirtualListControl:LdapControl
+ {
+ /// <summary> Returns the number of entries after the top/center one to return per
+ /// page of results.
+ /// </summary>
+ virtual public int AfterCount
+ {
+ get
+ {
+ return m_afterCount;
+ }
+
+ }
+ /// <summary> Returns the number of entries before the top/center one to return per
+ /// page of results.
+ /// </summary>
+ virtual public int BeforeCount
+ {
+ get
+ {
+ return m_beforeCount;
+ }
+
+ }
+ /// <summary> Returns the size of the virtual search results list. For a newly
+ /// constructed control - one which is not the result of parseResponse on
+ /// a control returned by a server - the method returns -1.
+ /// </summary>
+ /// <summary> Sets the assumed size of the virtual search results list. This will
+ /// typically be a number returned on a previous virtual list request in
+ /// an LdapVirtualListResponse.
+ /// </summary>
+ virtual public int ListSize
+ {
+ get
+ {
+ return m_contentCount;
+ }
+
+ set
+ {
+ m_contentCount = value;
+
+ /* since we just changed a field we need to rebuild the ber
+ * encoded control
+ */
+ BuildIndexedVLVRequest();
+
+ /* Set the request data field in the in the parent LdapControl to
+ * the ASN.1 encoded value of this control. This encoding will be
+ * appended to the search request when the control is sent.
+ */
+ setValue(m_vlvRequest.getEncoding(new LBEREncoder()));
+ }
+
+ }
+ /// <summary> Returns the cookie used by some servers to optimize the processing of
+ /// virtual list requests.
+ /// </summary>
+ /// <summary> Sets the cookie used by some servers to optimize the processing of
+ /// virtual list requests. It should be the context field returned in a
+ /// virtual list response control for the same search.
+ /// </summary>
+ virtual public System.String Context
+ {
+ get
+ {
+ return m_context;
+ }
+
+ set
+ {
+ /* Index of the context field if one exists in the ber
+ */
+ int CONTEXTIDINDEX = 3;
+
+ /* Save off the new value in private variable
+ */
+ m_context = value;
+
+ /* Is there a context field that is already in the ber
+ */
+ if (m_vlvRequest.size() == 4)
+ {
+ /* If YES then replace it */
+ m_vlvRequest.set_Renamed(CONTEXTIDINDEX, new Asn1OctetString(m_context));
+ }
+ else if (m_vlvRequest.size() == 3)
+ {
+ /* If no then add a new one */
+ m_vlvRequest.add(new Asn1OctetString(m_context));
+ }
+
+ /* Set the request data field in the in the parent LdapControl to
+ * the ASN.1 encoded value of this control. This encoding will be
+ * appended to the search request when the control is sent.
+ */
+ setValue(m_vlvRequest.getEncoding(new LBEREncoder()));
+ }
+
+ }
+
+ /* The ASN.1 for the VLV Request has CHOICE field. These private
+ * variables represent differnt ids for these different options
+ */
+ private static int BYOFFSET = 0;
+ private static int GREATERTHANOREQUAL = 1;
+
+
+ /// <summary> The Request OID for a VLV Request</summary>
+ private static System.String requestOID = "2.16.840.1.113730.3.4.9";
+
+ /*
+ * The Response stOID for a VLV Response
+ */
+ private static System.String responseOID = "2.16.840.1.113730.3.4.10";
+
+ /*
+ * The encoded ASN.1 VLV Control is stored in this variable
+ */
+ private Asn1Sequence m_vlvRequest;
+
+
+ /* Private instance variables go here.
+ * These variables are used to store copies of various fields
+ * that can be set in a VLV control. One could have managed
+ * without really defining these private variables by reverse
+ * engineering each field from the ASN.1 encoded control.
+ * However that would have complicated and slowed down the code.
+ */
+ private int m_beforeCount;
+ private int m_afterCount;
+ private System.String m_jumpTo;
+ private System.String m_context = null;
+ private int m_startIndex = 0;
+ private int m_contentCount = - 1;
+
+ /// <summary> Constructs a virtual list control using the specified filter
+ /// expression.
+ ///
+ /// <p>The expression specifies the first entry to be used for the
+ /// virtual search results. The other two paramers are the number of
+ /// entries before and after a located index to be returned.</p>
+ ///
+ /// </summary>
+ /// <param name="jumpTo"> A search expression that defines the first
+ /// element to be returned in the virtual search results. The filter
+ /// expression in the search operation itself may be, for example,
+ /// "objectclass=person" and the jumpTo expression in the virtual
+ /// list control may be "cn=m*", to retrieve a subset of entries
+ /// starting at or centered around those with a common name beginning
+ /// with the letter "M". <br><br>
+ ///
+ /// </param>
+ /// <param name="beforeCount"> The number of entries before startIndex (the
+ /// reference entry) to be returned. <br><br>
+ ///
+ /// </param>
+ /// <param name="afterCount"> The number of entries after startIndex to be
+ /// returned. <br><br>
+ /// </param>
+ public LdapVirtualListControl(System.String jumpTo, int beforeCount, int afterCount):this(jumpTo, beforeCount, afterCount, null)
+ {
+ return ;
+ }
+
+
+
+ /// <summary> Constructs a virtual list control using the specified filter
+ /// expression along with an optional server context.
+ ///
+ /// <p>The expression specifies the first entry to be used for the
+ /// virtual search results. The other two paramers are the number of
+ /// entries before and after a located index to be returned.</p>
+ ///
+ /// </summary>
+ /// <param name="jumpTo"> A search expression that defines the first
+ /// element to be returned in the virtual search results. The filter
+ /// expression in the search operation itself may be, for example,
+ /// "objectclass=person" and the jumpTo expression in the virtual
+ /// list control may be "cn=m*", to retrieve a subset of entries
+ /// starting at or centered around those with a common name beginning
+ /// with the letter "M".<br><br>
+ ///
+ /// </param>
+ /// <param name="beforeCount">The number of entries before startIndex (the
+ /// reference entry) to be returned. <br><br>
+ ///
+ /// </param>
+ /// <param name="afterCount">The number of entries after startIndex to be
+ /// returned. <br><br>
+ ///
+ /// </param>
+ /// <param name="context">Used by some implementations to process requests
+ /// more efficiently. The context should be null on the first search,
+ /// and thereafter it should be whatever was returned by the server in the
+ /// virtual list response control.
+ /// </param>
+ public LdapVirtualListControl(System.String jumpTo, int beforeCount, int afterCount, System.String context):base(requestOID, true, null)
+ {
+
+ /* Save off the fields in local variables
+ */
+ m_beforeCount = beforeCount;
+ m_afterCount = afterCount;
+ m_jumpTo = jumpTo;
+ m_context = context;
+
+ /* Call private method to build the ASN.1 encoded request packet.
+ */
+ BuildTypedVLVRequest();
+
+ /* Set the request data field in the in the parent LdapControl to
+ * the ASN.1 encoded value of this control. This encoding will be
+ * appended to the search request when the control is sent.
+ */
+ setValue(m_vlvRequest.getEncoding(new LBEREncoder()));
+ return ;
+ }
+
+ /// <summary>Private method used to construct the ber encoded control
+ /// Used only when using the typed mode of VLV Control.
+ /// </summary>
+ private void BuildTypedVLVRequest()
+ {
+ /* Create a new Asn1Sequence object */
+ m_vlvRequest = new Asn1Sequence(4);
+
+ /* Add the beforeCount and afterCount fields to the sequence */
+ m_vlvRequest.add(new Asn1Integer(m_beforeCount));
+ m_vlvRequest.add(new Asn1Integer(m_afterCount));
+
+ /* The next field is dependent on the type of indexing being used.
+ * A "typed" VLV request uses a ASN.1 OCTET STRING to index to the
+ * correct object in the list. Encode the ASN.1 CHOICE corresponding
+ * to this option (as indicated by the greaterthanOrEqual field)
+ * in the ASN.1.
+ */
+ m_vlvRequest.add(new Asn1Tagged(new Asn1Identifier(Asn1Identifier.CONTEXT, false, GREATERTHANOREQUAL), new Asn1OctetString(m_jumpTo), false));
+
+ /* Add the optional context string if one is available.
+ */
+ if ((System.Object) m_context != null)
+ m_vlvRequest.add(new Asn1OctetString(m_context));
+
+ return ;
+ }
+
+ /// <summary> Use this constructor to fetch a subset when the size of the
+ /// virtual list is known,
+ ///
+ /// <br><br>
+ /// </summary>
+ /// <param name="beforeCount">The number of entries before startIndex (the
+ /// reference entry) to be returned. <br><br>
+ ///
+ /// </param>
+ /// <param name="afterCount"> The number of entries after startIndex to be
+ /// returned.<br><br>
+ ///
+ /// </param>
+ /// <param name="startIndex">The index of the reference entry to be returned.<br><br>
+ ///
+ /// </param>
+ /// <param name="contentCount">The total number of entries assumed to be in the
+ /// list. This is a number returned on a previous search, in the
+ /// LdapVirtualListResponse. The server may use this number to adjust
+ /// the returned subset offset.
+ /// </param>
+ public LdapVirtualListControl(int startIndex, int beforeCount, int afterCount, int contentCount):this(startIndex, beforeCount, afterCount, contentCount, null)
+ {
+ return ;
+ }
+
+
+
+ /// <summary> Use this constructor to fetch a subset when the size of the
+ /// virtual list is known,
+ ///
+ /// <br><br>
+ /// </summary>
+ /// <param name="beforeCount"> The number of entries before startIndex (the
+ /// reference entry) to be returned.<br><br>
+ ///
+ /// </param>
+ /// <param name="afterCount"> The number of entries after startIndex to be
+ /// returned.<br><br>
+ ///
+ /// </param>
+ /// <param name="startIndex"> The index of the reference entry to be
+ /// returned.<br><br>
+ ///
+ /// </param>
+ /// <param name="contentCount"> The total number of entries assumed to be in the
+ /// list. This is a number returned on a previous search, in the
+ /// LdapVirtualListResponse. The server may use this number to adjust
+ /// the returned subset offset.<br><br>
+ ///
+ /// </param>
+ /// <param name="context"> Used by some implementations to process requests
+ /// more efficiently. The context should be null on the first search,
+ /// and thereafter it should be whatever was returned by the server in the
+ /// virtual list response control.
+ /// </param>
+ public LdapVirtualListControl(int startIndex, int beforeCount, int afterCount, int contentCount, System.String context):base(requestOID, true, null)
+ {
+
+
+ /* Save off the fields in local variables
+ */
+ m_beforeCount = beforeCount;
+ m_afterCount = afterCount;
+ m_startIndex = startIndex;
+ m_contentCount = contentCount;
+ m_context = context;
+
+ /* Call private method to build the ASN.1 encoded request packet.
+ */
+ BuildIndexedVLVRequest();
+
+ /* Set the request data field in the in the parent LdapControl to
+ * the ASN.1 encoded value of this control. This encoding will be
+ * appended to the search request when the control is sent.
+ */
+ setValue(m_vlvRequest.getEncoding(new LBEREncoder()));
+ return ;
+ }
+
+ /// <summary>Private method used to construct the ber encoded control
+ /// Used only when using the Indexed mode of VLV Control
+ /// </summary>
+ private void BuildIndexedVLVRequest()
+ {
+ /* Create a new Asn1Sequence object */
+ m_vlvRequest = new Asn1Sequence(4);
+
+ /* Add the beforeCount and afterCount fields to the sequence */
+ m_vlvRequest.add(new Asn1Integer(m_beforeCount));
+ m_vlvRequest.add(new Asn1Integer(m_afterCount));
+
+ /* The next field is dependent on the type of indexing being used.
+ * An "indexed" VLV request uses a ASN.1 SEQUENCE to index to the
+ * correct object in the list. Encode the ASN.1 CHOICE corresponding
+ * to this option (as indicated by the byoffset fieldin the ASN.1.
+ */
+ Asn1Sequence byoffset = new Asn1Sequence(2);
+ byoffset.add(new Asn1Integer(m_startIndex));
+ byoffset.add(new Asn1Integer(m_contentCount)); ;
+
+ /* Add the ASN.1 sequence to the encoded data
+ */
+ m_vlvRequest.add(new Asn1Tagged(new Asn1Identifier(Asn1Identifier.CONTEXT, true, BYOFFSET), byoffset, false));
+
+ /* Add the optional context string if one is available.
+ */
+ if ((System.Object) m_context != null)
+ m_vlvRequest.add(new Asn1OctetString(m_context));
+
+ return ;
+ }
+
+
+
+ /// <summary> Sets the center or starting list index to return, and the number of
+ /// results before and after.
+ ///
+ /// <br><br>
+ /// </summary>
+ /// <param name="listIndex"> The center or starting list index to be
+ /// returned. <br><br>
+ ///
+ /// </param>
+ /// <param name="beforeCount"> The number of entries before "listIndex" to be
+ /// returned. <br><br>
+ ///
+ /// </param>
+ /// <param name="afterCount"> The number of entries after "listIndex" to be
+ /// returned. <br><br>
+ /// </param>
+ public virtual void setRange(int listIndex, int beforeCount, int afterCount)
+ {
+
+ /* Save off the fields in local variables
+ */
+ m_beforeCount = beforeCount;
+ m_afterCount = afterCount;
+ m_startIndex = listIndex;
+
+ /* since we just changed a field we need to rebuild the ber
+ * encoded control
+ */
+ BuildIndexedVLVRequest();
+
+ /* Set the request data field in the in the parent LdapControl to
+ * the ASN.1 encoded value of this control. This encoding will be
+ * appended to the search request when the control is sent.
+ */
+ setValue(m_vlvRequest.getEncoding(new LBEREncoder()));
+ }
+
+ // PROPOSED ADDITION TO NEXT VERSION OF DRAFT (v7)
+ /// <summary> Sets the center or starting list index to return, and the number of
+ /// results before and after.
+ ///
+ /// <br><br>
+ /// </summary>
+ /// <param name="jumpTo">A search expression that defines the first
+ /// element to be returned in the virtual search results. The filter
+ /// expression in the search operation itself may be, for example,
+ /// "objectclass=person" and the jumpTo expression in the virtual
+ /// list control may be "cn=m*", to retrieve a subset of entries
+ /// starting at or centered around those with a common name
+ /// beginning with the letter "M".<br><br>
+ ///
+ /// </param>
+ /// <param name="beforeCount"> The number of entries before "listIndex" to be
+ /// returned.<br><br>
+ ///
+ /// </param>
+ /// <param name="afterCount">The number of entries after "listIndex" to be
+ /// returned.<br><br>
+ /// </param>
+
+ public virtual void setRange(System.String jumpTo, int beforeCount, int afterCount)
+ {
+ /* Save off the fields in local variables
+ */
+ m_beforeCount = beforeCount;
+ m_afterCount = afterCount;
+ m_jumpTo = jumpTo;
+
+ /* since we just changed a field we need to rebuild the ber
+ * encoded control
+ */
+ BuildTypedVLVRequest();
+
+ /* Set the request data field in the in the parent LdapControl to
+ * the ASN.1 encoded value of this control. This encoding will be
+ * appended to the search request when the control is sent.
+ */
+ setValue(m_vlvRequest.getEncoding(new LBEREncoder()));
+ }
+ static LdapVirtualListControl()
+ {
+ /*
+ * This is where we register the control responses
+ */
+ {
+ /* Register the VLV Sort Control class which is returned by the server
+ * in response to a VLV Sort Request
+ */
+ try
+ {
+ LdapControl.register(responseOID, System.Type.GetType("Novell.Directory.Ldap.Controls.LdapVirtualListResponse"));
+ }
+ catch (System.Exception e)
+ {
+ }
+ }
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Controls/LdapVirtualListResponse.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Controls/LdapVirtualListResponse.cs
new file mode 100755
index 00000000000..8969c933247
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Controls/LdapVirtualListResponse.cs
@@ -0,0 +1,202 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.Controls.LdapVirtualListResponse.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+using Novell.Directory.Ldap;
+using Novell.Directory.Ldap.Asn1;
+
+namespace Novell.Directory.Ldap.Controls
+{
+
+ /// <summary>
+ /// LdapVirtualListResponse is a Server Control returned by the server in
+ /// response to a virtual list search request.
+ /// </summary>
+ /// <summary> <br><br>
+ /// <p>In response to a VLV Search request the server returns an error code
+ /// and if the search was successful returns the following information:<br>
+ /// <li> an index into the search results from where the returned list begins
+ /// <li> an estimate of the total number of elements in the search result
+ /// <li> an optional context field to be returned to the server with
+ /// subsequent VLV request.
+ ///
+ /// <p>Sample Code: <a href="http://developer.novell.com/ndk/doc/samplecode/
+ /// jldap_sample/controls/VLVControl.java.html">VLVControl.java</p>
+ /// </summary>
+ public class LdapVirtualListResponse:LdapControl
+ {
+ /// <summary> Returns the size of the virtual search results list. This integer as
+ /// the servers current estimate of what the search result size.
+ /// </summary>
+ virtual public int ContentCount
+ {
+ get
+ {
+ return m_ContentCount;
+ }
+
+ }
+ /// <summary> Returns the index of the first entry in the returned list. The server uses
+ /// the clients request information in conjunction with its current search result
+ /// list to estimate what list of entries the client is requesting. This integer
+ /// is the index into the search results that is returned to the client.
+ /// </summary>
+ virtual public int FirstPosition
+ {
+ get
+ {
+ return m_firstPosition;
+ }
+
+ }
+ /// <summary> Returns the result code for the virtual list search request.</summary>
+ virtual public int ResultCode
+ {
+ get
+ {
+ return m_resultCode;
+ }
+
+ }
+ /// <summary> Returns the cookie used by some servers to optimize the processing of
+ /// virtual list requests. Subsequent VLV requests to the same server
+ /// should return this String to the server.
+ /// </summary>
+ virtual public System.String Context
+ {
+ get
+ {
+ return m_context;
+ }
+
+ }
+ /* The parsed fields are stored in these private variables */
+ private int m_firstPosition;
+ private int m_ContentCount;
+ private int m_resultCode;
+
+ /* The context field if one was returned by the server */
+ private System.String m_context = null;
+
+ /// <summary> This constructor is usually called by the SDK to instantiate an
+ /// a LdapControl corresponding to the Server response to a Ldap
+ /// VLV Control request. Application programmers should not have
+ /// any reason to call the constructor. This constructor besides
+ /// constructing a LdapVirtualListResponse control object also
+ /// parses the contents of the response into local variables.
+ ///
+ /// <p>RFC 2891 defines this response control as follows:
+ ///
+ /// The controlValue is an OCTET STRING, whose value is the BER
+ /// encoding of a value of the following ASN.1:<br><br>
+ ///
+ /// VirtualListViewResponse ::= SEQUENCE {
+ /// targetPosition INTEGER (0 .. maxInt),
+ /// contentCount INTEGER (0 .. maxInt),
+ /// virtualListViewResult ENUMERATED {
+ /// success (0),
+ /// operationsError (1),
+ /// unwillingToPerform (53),
+ /// insufficientAccessRights (50),
+ /// busy (51),
+ /// timeLimitExceeded (3),
+ /// adminLimitExceeded (11),
+ /// sortControlMissing (60),
+ /// offsetRangeError (61),
+ /// other (80) },
+ /// contextID OCTET STRING OPTIONAL }
+ ///
+ ///
+ /// </summary>
+ /// <param name="oid"> The OID of the control, as a dotted string.
+ /// <br><br>
+ /// </param>
+ /// <param name="critical"> True if the Ldap operation should be discarded if
+ /// the control is not supported. False if
+ /// the operation can be processed without the control.
+ /// <br><br>
+ /// </param>
+ /// <param name="values"> The control-specific data.
+ /// </param>
+ [CLSCompliantAttribute(false)]
+ public LdapVirtualListResponse(System.String oid, bool critical, sbyte[] values):base(oid, critical, values)
+ {
+
+ /* Create a decoder object */
+ LBERDecoder decoder = new LBERDecoder();
+ if (decoder == null)
+ throw new System.IO.IOException("Decoding error");
+
+ /* We should get back an ASN.1 Sequence object */
+ Asn1Object asnObj = decoder.decode(values);
+ if ((asnObj == null) || (!(asnObj is Asn1Sequence)))
+ throw new System.IO.IOException("Decoding error");
+
+ /* Else we got back a ASN.1 sequence - print it if running debug code */
+
+ /* Get the 1st element which should be an integer containing the
+ * targetPosition (firstPosition)
+ */
+ Asn1Object asn1firstPosition = ((Asn1Sequence) asnObj).get_Renamed(0);
+ if ((asn1firstPosition != null) && (asn1firstPosition is Asn1Integer))
+ m_firstPosition = ((Asn1Integer) asn1firstPosition).intValue();
+ else
+ throw new System.IO.IOException("Decoding error");
+
+ /* Get the 2nd element which should be an integer containing the
+ * current estimate of the contentCount
+ */
+ Asn1Object asn1ContentCount = ((Asn1Sequence) asnObj).get_Renamed(1);
+ if ((asn1ContentCount != null) && (asn1ContentCount is Asn1Integer))
+ m_ContentCount = ((Asn1Integer) asn1ContentCount).intValue();
+ else
+ throw new System.IO.IOException("Decoding error");
+
+ /* The 3rd element is an enum containing the errorcode */
+ Asn1Object asn1Enum = ((Asn1Sequence) asnObj).get_Renamed(2);
+ if ((asn1Enum != null) && (asn1Enum is Asn1Enumerated))
+ m_resultCode = ((Asn1Enumerated) asn1Enum).intValue();
+ else
+ throw new System.IO.IOException("Decoding error");
+
+ /* Optional 4th element could be the context string that the server
+ * wants the client to send back with each subsequent VLV request
+ */
+ if (((Asn1Sequence) asnObj).size() > 3)
+ {
+ Asn1Object asn1String = ((Asn1Sequence) asnObj).get_Renamed(3);
+ if ((asn1String != null) && (asn1String is Asn1OctetString))
+ m_context = ((Asn1OctetString) asn1String).stringValue();
+ }
+ return ;
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/AbortPartitionOperationRequest.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/AbortPartitionOperationRequest.cs
new file mode 100755
index 00000000000..0e3ca8a5b78
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/AbortPartitionOperationRequest.cs
@@ -0,0 +1,99 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.Extensions.AbortPartitionOperationRequest.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+using Novell.Directory.Ldap;
+using Novell.Directory.Ldap.Asn1;
+using Novell.Directory.Ldap.Utilclass;
+
+namespace Novell.Directory.Ldap.Extensions
+{
+
+ /// <summary>
+ /// Aborts the last partition operation that was requested on the
+ /// specified partition if the operation is still pending.
+ ///
+ /// <p>The AbortPartitionRequest extension uses the following OID:<br>
+ /// &nbsp;&nbsp;&nbsp;2.16.840.1.113719.1.27.100.29</p>
+ ///
+ /// <p>The requestValue has the following format:<br>
+ ///
+ /// requestValue ::= <br>
+ /// &nbsp;&nbsp;&nbsp;&nbsp; flags&nbsp;&nbsp;&nbsp;&nbsp; INTEGER<br>
+ /// &nbsp;&nbsp;&nbsp;&nbsp; partitionDN&nbsp;&nbsp;&nbsp;&nbsp; LdapDN </p>
+ /// </summary>
+ public class AbortPartitionOperationRequest:LdapExtendedOperation
+ {
+
+ /// <summary> Constructs an extended operation object for aborting a partition operation.
+ ///
+ /// </summary>
+ /// <param name="partitionDN">The distinguished name of the replica's
+ /// partition root.<br><br>
+ ///
+ /// </param>
+ /// <param name="flags">Determines whether all servers in the replica ring must
+ /// be up before proceeding. When set to zero, the status of the
+ /// servers is not checked. When set to Ldap_ENSURE_SERVERS_UP,
+ /// all servers must be up for the operation to proceed.
+ ///
+ /// </param>
+ /// <exception cref=""> LdapException A general exception which includes an error message
+ /// and an Ldap error code.
+ /// </exception>
+ public AbortPartitionOperationRequest(System.String partitionDN, int flags):base(ReplicationConstants.ABORT_NAMING_CONTEXT_OP_REQ, null)
+ {
+
+ try
+ {
+
+ if ((System.Object) partitionDN == null)
+ throw new System.ArgumentException(ExceptionMessages.PARAM_ERROR);
+
+ System.IO.MemoryStream encodedData = new System.IO.MemoryStream();
+ LBEREncoder encoder = new LBEREncoder();
+
+
+ Asn1Integer asn1_flags = new Asn1Integer(flags);
+ Asn1OctetString asn1_partitionDN = new Asn1OctetString(partitionDN);
+
+ asn1_flags.encode(encoder, encodedData);
+ asn1_partitionDN.encode(encoder, encodedData);
+
+ setValue(SupportClass.ToSByteArray(encodedData.ToArray()));
+ }
+ catch (System.IO.IOException ioe)
+ {
+ throw new LdapException(ExceptionMessages.ENCODING_ERROR, LdapException.ENCODING_ERROR, (System.String) null);
+ }
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/AddReplicaRequest.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/AddReplicaRequest.cs
new file mode 100755
index 00000000000..9f7c62514e5
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/AddReplicaRequest.cs
@@ -0,0 +1,128 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.Extensions.AddReplicaRequest.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+using Novell.Directory.Ldap;
+using Novell.Directory.Ldap.Asn1;
+using Novell.Directory.Ldap.Utilclass;
+
+namespace Novell.Directory.Ldap.Extensions
+{
+
+ /// <summary>
+ /// Adds a replica to the specified directory server.
+ ///
+ /// <p>To add a replica to a particular server, you must create an instance of
+ /// this class and then call the extendedOperation method with this
+ /// object as the required LdapExtendedOperation parameter.</p>
+ ///
+ /// <p>The addReplicaRequest extension uses the following OID:<br>
+ /// &nbsp;&nbsp;&nbsp;2.16.840.1.113719.1.27.100.7</p>
+ ///
+ /// <p>The requestValue has the following format:<br>
+ ///
+ /// requestValue ::=<br>
+ /// &nbsp;&nbsp;&nbsp;&nbsp; flags&nbsp;&nbsp;&nbsp;&nbsp; INTEGER<br>
+ /// &nbsp;&nbsp;&nbsp;&nbsp; replicaType&nbsp;&nbsp;&nbsp;&nbsp; INTEGER<br>
+ /// &nbsp;&nbsp;&nbsp;&nbsp; serverName&nbsp;&nbsp;&nbsp;&nbsp; LdapDN<br>
+ /// &nbsp;&nbsp;&nbsp;&nbsp; dn &nbsp;&nbsp;&nbsp;&nbsp; LdapDN</p>
+ /// </summary>
+ public class AddReplicaRequest:LdapExtendedOperation
+ {
+
+ /// <summary>
+ /// Constructs a new extended operation object for adding a replica to the
+ /// specified server.
+ ///
+ /// </summary>
+ /// <param name="dn">The distinguished name of the replica's partition root.<br><br>
+ ///
+ /// </param>
+ /// <param name="serverDN">The server on which the new replica will be added.<br><br>
+ ///
+ /// </param>
+ /// <param name="replicaType">The type of replica to add. The replica
+ /// types are defined in the ReplicationConstants class.<br><br>
+ ///
+ /// </param>
+ /// <param name="flags">Specifies whether all servers in the replica ring must be up
+ /// before proceeding. When set to zero, the status of the servers is not
+ /// checked. When set to Ldap_ENSURE_SERVERS_UP, all servers must be up for the
+ /// operation to proceed.
+ ///
+ /// </param>
+ /// <exception cref=""> LdapException A general exception which includes an error message
+ /// and an Ldap error code.
+ ///
+ /// </exception>
+ /// <seealso cref="ReplicationConstants#Ldap_RT_MASTER">
+ /// </seealso>
+ /// <seealso cref="ReplicationConstants#Ldap_RT_SECONDARY">
+ /// </seealso>
+ /// <seealso cref="ReplicationConstants#Ldap_RT_READONLY">
+ /// </seealso>
+ /// <seealso cref="ReplicationConstants#Ldap_RT_SUBREF">
+ /// </seealso>
+ /// <seealso cref="ReplicationConstants#Ldap_RT_SPARSE_WRITE">
+ /// </seealso>
+ /// <seealso cref="ReplicationConstants#Ldap_RT_SPARSE_READ">
+ /// </seealso>
+ public AddReplicaRequest(System.String dn, System.String serverDN, int replicaType, int flags):base(ReplicationConstants.ADD_REPLICA_REQ, null)
+ {
+
+ try
+ {
+
+ if (((System.Object) dn == null) || ((System.Object) serverDN == null))
+ throw new System.ArgumentException(ExceptionMessages.PARAM_ERROR);
+
+ System.IO.MemoryStream encodedData = new System.IO.MemoryStream();
+ LBEREncoder encoder = new LBEREncoder();
+
+ Asn1Integer asn1_flags = new Asn1Integer(flags);
+ Asn1Integer asn1_replicaType = new Asn1Integer(replicaType);
+ Asn1OctetString asn1_serverDN = new Asn1OctetString(serverDN);
+ Asn1OctetString asn1_dn = new Asn1OctetString(dn);
+
+ asn1_flags.encode(encoder, encodedData);
+ asn1_replicaType.encode(encoder, encodedData);
+ asn1_serverDN.encode(encoder, encodedData);
+ asn1_dn.encode(encoder, encodedData);
+
+ setValue(SupportClass.ToSByteArray(encodedData.ToArray()));
+ }
+ catch (System.IO.IOException ioe)
+ {
+ throw new LdapException(ExceptionMessages.ENCODING_ERROR, LdapException.ENCODING_ERROR, (System.String) null);
+ }
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/ChangeReplicaTypeRequest.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/ChangeReplicaTypeRequest.cs
new file mode 100755
index 00000000000..790dbbb10de
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/ChangeReplicaTypeRequest.cs
@@ -0,0 +1,130 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.Extensions.ChangeReplicaTypeRequest.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+using Novell.Directory.Ldap;
+using Novell.Directory.Ldap.Asn1;
+using Novell.Directory.Ldap.Utilclass;
+
+namespace Novell.Directory.Ldap.Extensions
+{
+
+ /// <summary>
+ /// Changes the type of the replica that resides
+ /// on the specified directory server.
+ ///
+ /// <p>To change a replica's type, you must create an instance of this class and
+ /// then call the extendedOperation method with this object as the required
+ /// LdapExtendedOperation parameter.</p>
+ ///
+ /// <p>The changeReplicaTypeRequest extension uses the following OID:<br>
+ /// &nbsp;&nbsp;&nbsp;2.16.840.1.113719.1.27.100.15</p>
+ ///
+ /// <p>The requestValue has the following format:<br>
+ ///
+ /// requestValue ::=<br>
+ /// &nbsp;&nbsp;&nbsp;&nbsp; flags &nbsp;&nbsp;&nbsp;&nbsp; INTEGER<br>
+ /// &nbsp;&nbsp;&nbsp;&nbsp; replicaType&nbsp;&nbsp;&nbsp;&nbsp; INTEGER<br>
+ /// &nbsp;&nbsp;&nbsp;&nbsp; serverName&nbsp;&nbsp;&nbsp;&nbsp; LdapDN<br>
+ /// &nbsp;&nbsp;&nbsp;&nbsp; dn&nbsp;&nbsp;&nbsp;&nbsp; LdapDN</p>
+ /// </summary>
+ public class ChangeReplicaTypeRequest:LdapExtendedOperation
+ {
+
+ /// <summary>
+ /// Constructs a new extended operation object for changing a replica's type.
+ ///
+ /// </summary>
+ /// <param name="dn"> The distinguished name of the replica's
+ /// partition root.
+ /// <br><br>
+ /// </param>
+ /// <param name="serverDN"> The server on which the replica resides.
+ /// <br><br>
+ ///
+ /// </param>
+ /// <param name="replicaType"> The new replica type. The replica types are defined
+ /// in the ReplicationConstants class.
+ /// <br><br>
+ /// </param>
+ /// <param name="flags"> Specifies whether all servers in the replica ring must be up
+ /// before proceeding. When set to zero, the status of the servers is
+ /// not checked. When set to Ldap_ENSURE_SERVERS_UP, all servers must be
+ /// up for the operation to proceed.
+ ///
+ /// </param>
+ /// <exception cref=""> LdapException A general exception which includes an error message
+ /// and an Ldap error code.
+ ///
+ /// </exception>
+ /// <seealso cref="ReplicationConstants#Ldap_RT_MASTER">
+ /// </seealso>
+ /// <seealso cref="ReplicationConstants#Ldap_RT_SECONDARY">
+ /// </seealso>
+ /// <seealso cref="ReplicationConstants#Ldap_RT_READONLY">
+ /// </seealso>
+ /// <seealso cref="ReplicationConstants#Ldap_RT_SUBREF">
+ /// </seealso>
+ /// <seealso cref="ReplicationConstants#Ldap_RT_SPARSE_WRITE">
+ /// </seealso>
+ /// <seealso cref="ReplicationConstants#Ldap_RT_SPARSE_READ">
+ /// </seealso>
+ public ChangeReplicaTypeRequest(System.String dn, System.String serverDN, int replicaType, int flags):base(ReplicationConstants.CHANGE_REPLICA_TYPE_REQ, null)
+ {
+
+ try
+ {
+
+ if (((System.Object) dn == null) || ((System.Object) serverDN == null))
+ throw new System.ArgumentException(ExceptionMessages.PARAM_ERROR);
+
+ System.IO.MemoryStream encodedData = new System.IO.MemoryStream();
+ LBEREncoder encoder = new LBEREncoder();
+
+ Asn1Integer asn1_flags = new Asn1Integer(flags);
+ Asn1Integer asn1_replicaType = new Asn1Integer(replicaType);
+ Asn1OctetString asn1_serverDN = new Asn1OctetString(serverDN);
+ Asn1OctetString asn1_dn = new Asn1OctetString(dn);
+
+ asn1_flags.encode(encoder, encodedData);
+ asn1_replicaType.encode(encoder, encodedData);
+ asn1_serverDN.encode(encoder, encodedData);
+ asn1_dn.encode(encoder, encodedData);
+
+ setValue(SupportClass.ToSByteArray(encodedData.ToArray()));
+ }
+ catch (System.IO.IOException ioe)
+ {
+ throw new LdapException(ExceptionMessages.ENCODING_ERROR, LdapException.ENCODING_ERROR, (System.String) null);
+ }
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/GetBindDNRequest.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/GetBindDNRequest.cs
new file mode 100755
index 00000000000..c67d8705152
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/GetBindDNRequest.cs
@@ -0,0 +1,71 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.Extensions.GetBindDNRequest.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+using Novell.Directory.Ldap;
+using Novell.Directory.Ldap.Asn1;
+using Novell.Directory.Ldap.Utilclass;
+
+namespace Novell.Directory.Ldap.Extensions
+{
+
+ /// <summary> Returns the distingusihed name of the object your are logged in as.
+ ///
+ /// <p>To use this class, you must create an instance of the
+ /// class and then call the extendedOperation method with this
+ /// object as the required LdapExtendedOperation parameter.</p>
+ ///
+ /// <p>The returned LdapExtendedResponse object can then be converted to
+ /// a GetBindDNResponse object with the ExtendedREsponseFactory
+ /// class. This object contains methods for retrieving the distinguished
+ /// name.</p>
+ ///
+ /// <p>The GetBindDNRequest extension uses the following OID:<br>
+ /// &nbsp;&nbsp;&nbsp;2.16.840.1.113719.1.27.100.31</p>
+ ///
+ /// <p>The request value has a value of null.</p>
+ ///
+ /// </summary>
+ public class GetBindDNRequest:LdapExtendedOperation
+ {
+
+ /// <summary> Constructs an extended operation object for retrieving the bind dn.
+ ///
+ /// </summary>
+ /// <exception cref=""> LdapException A general exception which includes an error
+ /// message and an Ldap error code.
+ /// </exception>
+
+ public GetBindDNRequest():base(ReplicationConstants.GET_IDENTITY_NAME_REQ, null)
+ {
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/GetBindDNResponse.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/GetBindDNResponse.cs
new file mode 100755
index 00000000000..2da6321b94b
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/GetBindDNResponse.cs
@@ -0,0 +1,110 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.Extensions.GetBindDNResponse.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+using Novell.Directory.Ldap;
+using Novell.Directory.Ldap.Asn1;
+using Novell.Directory.Ldap.Utilclass;
+using Novell.Directory.Ldap.Rfc2251;
+
+namespace Novell.Directory.Ldap.Extensions
+{
+
+ /// <summary> Retrieves the identity from an GetBindDNResponse object.
+ ///
+ /// <p>An object in this class is generated from an LdapExtendedResponse object
+ /// using the ExtendedResponseFactory class.</p>
+ ///
+ /// <p>The GetBindDNResponse extension uses the following OID:<br>
+ /// &nbsp;&nbsp;&nbsp;2.16.840.1.113719.1.27.100.32 </p>
+ ///
+ /// </summary>
+ public class GetBindDNResponse:LdapExtendedResponse
+ {
+ /// <summary> Returns the identity of the object.
+ ///
+ /// </summary>
+ /// <returns> A string value specifying the bind dn returned by the server.
+ /// </returns>
+ virtual public System.String Identity
+ {
+ get
+ {
+ return identity;
+ }
+
+ }
+
+ // Identity returned by the server
+ private System.String identity;
+
+ /// <summary> Constructs an object from the responseValue which contains the bind dn.
+ ///
+ /// <p>The constructor parses the responseValue which has the following
+ /// format:<br>
+ /// responseValue ::=<br>
+ /// &nbsp;&nbsp;&nbsp;&nbsp;identity &nbsp;&nbsp;&nbsp; OCTET STRING</p>
+ ///
+ /// </summary>
+ /// <exception cref=""> IOException The return value could not be decoded.
+ /// </exception>
+ public GetBindDNResponse(RfcLdapMessage rfcMessage):base(rfcMessage)
+ {
+
+ if (ResultCode == LdapException.SUCCESS)
+ {
+ // parse the contents of the reply
+ sbyte[] returnedValue = this.Value;
+ if (returnedValue == null)
+ throw new System.IO.IOException("No returned value");
+
+ // Create a decoder object
+ LBERDecoder decoder = new LBERDecoder();
+ if (decoder == null)
+ throw new System.IO.IOException("Decoding error");
+
+ // The only parameter returned should be an octet string
+ Asn1OctetString asn1_identity = (Asn1OctetString) decoder.decode(returnedValue);
+ if (asn1_identity == null)
+ throw new System.IO.IOException("Decoding error");
+
+ // Convert to normal string object
+ identity = asn1_identity.stringValue();
+ if ((System.Object) identity == null)
+ throw new System.IO.IOException("Decoding error");
+ }
+ else
+ {
+ identity = "";
+ }
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/GetEffectivePrivilegesRequest.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/GetEffectivePrivilegesRequest.cs
new file mode 100755
index 00000000000..c1e07177899
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/GetEffectivePrivilegesRequest.cs
@@ -0,0 +1,111 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.Extensions.GetEffectivePrivilegesRequest.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+using Novell.Directory.Ldap;
+using Novell.Directory.Ldap.Asn1;
+using Novell.Directory.Ldap.Utilclass;
+
+namespace Novell.Directory.Ldap.Extensions
+{
+
+ /// <summary>
+ /// Returns the effective rights of one object to an attribute of another object.
+ ///
+ /// <p>To use this class, you must instantiate an object of this class and then
+ /// call the extendedOperation method with this object as the required
+ /// LdapExtendedOperation parameter.</p>
+ ///
+ /// <p>The returned LdapExtendedResponse object can then be converted to
+ /// a GetEffectivePrivilegesResponse object with the ExtendedResponseFactory class.
+ /// The GetEffectivePrivilegesResponse class contains methods for
+ /// retrieving the effective rights.</p>
+ ///
+ /// <p>The getEffectivePrivilegesRequest extension uses the following OID:<br>
+ /// &nbsp;&nbsp;&nbsp;2.16.840.1.113719.1.27.100.33</p>
+ ///
+ /// <p>The requestValue has the following format:<br>
+ ///
+ /// requestValue ::=<br>
+ /// &nbsp;&nbsp;&nbsp;&nbsp; dn &nbsp;&nbsp;&nbsp; LdapDN<br>
+ /// &nbsp;&nbsp;&nbsp;&nbsp; trusteeDN&nbsp;&nbsp;&nbsp; LdapDN<br>
+ /// &nbsp;&nbsp;&nbsp;&nbsp; attrName &nbsp;&nbsp;&nbsp; LdapDN </p>
+ /// </summary>
+ public class GetEffectivePrivilegesRequest:LdapExtendedOperation
+ {
+
+ /// <summary> Constructs an extended operation object for checking effective rights.
+ ///
+ /// </summary>
+ /// <param name="dn"> The distinguished name of the entry whose attribute is
+ /// being checked.
+ /// <br><br>
+ /// </param>
+ /// <param name="trusteeDN">The distinguished name of the entry whose trustee rights
+ /// are being returned
+ /// <br><br>
+ /// </param>
+ /// <param name="attrName"> The Ldap attribute name.
+ ///
+ /// </param>
+ /// <exception cref=""> LdapException A general exception which includes an error
+ /// message and an Ldap error code.
+ /// </exception>
+
+ public GetEffectivePrivilegesRequest(System.String dn, System.String trusteeDN, System.String attrName):base(ReplicationConstants.GET_EFFECTIVE_PRIVILEGES_REQ, null)
+ {
+
+ try
+ {
+
+ if (((System.Object) dn == null))
+ throw new System.ArgumentException(ExceptionMessages.PARAM_ERROR);
+
+ System.IO.MemoryStream encodedData = new System.IO.MemoryStream();
+ LBEREncoder encoder = new LBEREncoder();
+
+ Asn1OctetString asn1_dn = new Asn1OctetString(dn);
+ Asn1OctetString asn1_trusteeDN = new Asn1OctetString(trusteeDN);
+ Asn1OctetString asn1_attrName = new Asn1OctetString(attrName);
+
+ asn1_dn.encode(encoder, encodedData);
+ asn1_trusteeDN.encode(encoder, encodedData);
+ asn1_attrName.encode(encoder, encodedData);
+
+ setValue(SupportClass.ToSByteArray(encodedData.ToArray()));
+ }
+ catch (System.IO.IOException ioe)
+ {
+ throw new LdapException(ExceptionMessages.ENCODING_ERROR, LdapException.ENCODING_ERROR, (System.String) null);
+ }
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/GetEffectivePrivilegesResponse.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/GetEffectivePrivilegesResponse.cs
new file mode 100755
index 00000000000..4550f54b47f
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/GetEffectivePrivilegesResponse.cs
@@ -0,0 +1,123 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.Extensions.GetEffectivePrivilegesResponse.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+using Novell.Directory.Ldap;
+using Novell.Directory.Ldap.Asn1;
+using Novell.Directory.Ldap.Utilclass;
+using Novell.Directory.Ldap.Rfc2251;
+
+namespace Novell.Directory.Ldap.Extensions
+{
+
+ /// <summary> Retrieves the effective rights from an GetEffectivePrivilegesResponse object.
+ ///
+ /// <p>An object in this class is generated from an ExtendedResponse object
+ /// using the ExtendedResponseFactory class.</p>
+ ///
+ /// <p>The getEffectivePrivilegesResponse extension uses the following OID:<br>
+ /// &nbsp;&nbsp;&nbsp;2.16.840.1.113719.1.27.100.34</p>
+ ///
+ /// </summary>
+ public class GetEffectivePrivilegesResponse:LdapExtendedResponse
+ {
+ /// <summary> Returns the effective privileges.
+ ///
+ /// <p>See the ReplicationConstants class for the privilege flags.
+ ///
+ /// </summary>
+ /// <returns> A flag which is a combination of zero or more privilege flags as
+ /// returned by the server.
+ ///
+ /// </returns>
+ /// <seealso cref="LdapDSConstants#Ldap_DS_ATTR_COMPARE">
+ /// </seealso>
+ /// <seealso cref="LdapDSConstants#Ldap_DS_ATTR_READ">
+ /// </seealso>
+ /// <seealso cref="LdapDSConstants#Ldap_DS_ATTR_WRITE">
+ /// </seealso>
+ /// <seealso cref="LdapDSConstants#Ldap_DS_ATTR_SELF">
+ /// </seealso>
+ /// <seealso cref="LdapDSConstants#Ldap_DS_ATTR_SUPERVISOR">
+ /// </seealso>
+ /// <seealso cref="LdapDSConstants#Ldap_DS_ATTR_INHERIT_CTL">
+ /// </seealso>
+ virtual public int Privileges
+ {
+ get
+ {
+ return privileges;
+ }
+
+ }
+
+ // Identity returned by the server
+ private int privileges;
+
+ /// <summary> Constructs an object from the responseValue which contains the effective
+ /// privileges.
+ ///
+ /// <p>The constructor parses the responseValue which has the following
+ /// format:<br>
+ /// responseValue ::=<br>
+ /// &nbsp;&nbsp;&nbsp;&nbsp; privileges&nbsp;&nbsp;&nbsp; INTEGER</p>
+ ///
+ /// </summary>
+ /// <exception cref=""> IOException The responseValue could not be decoded.
+ /// </exception>
+ public GetEffectivePrivilegesResponse(RfcLdapMessage rfcMessage):base(rfcMessage)
+ {
+
+ if (ResultCode == LdapException.SUCCESS)
+ {
+ // parse the contents of the reply
+ sbyte[] returnedValue = this.Value;
+ if (returnedValue == null)
+ throw new System.IO.IOException("No returned value");
+
+ // Create a decoder object
+ LBERDecoder decoder = new LBERDecoder();
+ if (decoder == null)
+ throw new System.IO.IOException("Decoding error");
+
+ Asn1Integer asn1_privileges = (Asn1Integer) decoder.decode(returnedValue);
+ if (asn1_privileges == null)
+ throw new System.IO.IOException("Decoding error");
+
+ privileges = asn1_privileges.intValue();
+ }
+ else
+ {
+ privileges = 0;
+ }
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/GetReplicaInfoRequest.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/GetReplicaInfoRequest.cs
new file mode 100755
index 00000000000..0a65d197b87
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/GetReplicaInfoRequest.cs
@@ -0,0 +1,102 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.Extensions.GetReplicaInfoRequest.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+using Novell.Directory.Ldap;
+using Novell.Directory.Ldap.Asn1;
+using Novell.Directory.Ldap.Utilclass;
+
+namespace Novell.Directory.Ldap.Extensions
+{
+
+ /// <summary>
+ /// Reads information about a replica.
+ ///
+ /// <p>The information available includes such items as replicas state, last
+ /// modification time, and replica type. </p>
+ ///
+ /// <p>To read other information about a replica, you must
+ /// create an instance of this class and then call the
+ /// extendedOperation method with this object as the required
+ /// LdapExtendedOperation parameter.</p>
+ ///
+ /// <p>The getReplicaInfoRequest extension uses the following OID:<br>
+ /// &nbsp;&nbsp;&nbsp;2.16.840.1.113719.1.27.100.17</p>
+ ///
+ /// <p>The requestValue has the following format:<br>
+ ///
+ /// requestValue ::=<br>
+ /// &nbsp;&nbsp;&nbsp;&nbsp; serverDN&nbsp;&nbsp;&nbsp; LdapDN<br>
+ /// &nbsp;&nbsp;&nbsp;&nbsp; partitionDN&nbsp;&nbsp;&nbsp; LdapDN</p>
+ /// </summary>
+ public class GetReplicaInfoRequest:LdapExtendedOperation
+ {
+
+ /// <summary>
+ /// Constructs an extended operations object for reading replica information.
+ ///
+ /// </summary>
+ /// <param name="serverDN">The server on which the replica resides.
+ /// <br><br>
+ /// </param>
+ /// <param name="partitionDN">The distinguished name of the replica to be read.
+ ///
+ /// </param>
+ /// <exception cref=""> LdapException A general exception which includes an error
+ /// message and an Ldap error code.
+ /// </exception>
+ public GetReplicaInfoRequest(System.String serverDN, System.String partitionDN):base(ReplicationConstants.GET_REPLICA_INFO_REQ, null)
+ {
+
+ try
+ {
+
+ if (((System.Object) serverDN == null) || ((System.Object) partitionDN == null))
+ throw new System.ArgumentException(ExceptionMessages.PARAM_ERROR);
+
+ System.IO.MemoryStream encodedData = new System.IO.MemoryStream();
+ LBEREncoder encoder = new LBEREncoder();
+
+ Asn1OctetString asn1_serverDN = new Asn1OctetString(serverDN);
+ Asn1OctetString asn1_partitionDN = new Asn1OctetString(partitionDN);
+
+ asn1_serverDN.encode(encoder, encodedData);
+ asn1_partitionDN.encode(encoder, encodedData);
+
+ setValue(SupportClass.ToSByteArray(encodedData.ToArray()));
+ }
+ catch (System.IO.IOException ioe)
+ {
+ throw new LdapException(ExceptionMessages.ENCODING_ERROR, LdapException.ENCODING_ERROR, (System.String) null);
+ }
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/GetReplicaInfoResponse.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/GetReplicaInfoResponse.cs
new file mode 100755
index 00000000000..3e58e198eea
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/GetReplicaInfoResponse.cs
@@ -0,0 +1,306 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.Extensions.GetReplicaInfoResponse.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+using Novell.Directory.Ldap;
+using Novell.Directory.Ldap.Asn1;
+using Novell.Directory.Ldap.Utilclass;
+using Novell.Directory.Ldap.Rfc2251;
+
+namespace Novell.Directory.Ldap.Extensions
+{
+
+ /// <summary> Retrieves the replica information from a GetReplicaInfoResponse object.
+ ///
+ /// <p>An object in this class is generated from an ExtendedResponse using the
+ /// ExtendedResponseFactory class.</p>
+ ///
+ /// <p>The getReplicaInfoResponse extension uses the following OID:<br>
+ /// &nbsp;&nbsp;&nbsp;2.16.840.1.113719.1.27.100.18</p>
+ ///
+ /// </summary>
+ public class GetReplicaInfoResponse:LdapExtendedResponse
+ {
+
+ // Other info as returned by the server
+ private int partitionID;
+ private int replicaState;
+ private int modificationTime;
+ private int purgeTime;
+ private int localPartitionID;
+ private System.String partitionDN;
+ private int replicaType;
+ private int flags;
+
+ /// <summary> Constructs an object from the responseValue which contains the
+ /// replica information.
+ ///
+ /// <p>The constructor parses the responseValue which has the following
+ /// format:<br>
+ /// responseValue ::=<br>
+ /// &nbsp;&nbsp;&nbsp;&nbsp; partitionID &nbsp;&nbsp;&nbsp; INTEGER<br>
+ /// &nbsp;&nbsp;&nbsp;&nbsp; replicaState &nbsp;&nbsp;&nbsp; INTEGER<br>
+ /// &nbsp;&nbsp;&nbsp;&nbsp; modificationTime &nbsp;&nbsp;&nbsp; INTEGER<br>
+ /// &nbsp;&nbsp;&nbsp;&nbsp; purgeTime &nbsp;&nbsp;&nbsp; INTEGER<br>
+ /// &nbsp;&nbsp;&nbsp;&nbsp; localPartitionID &nbsp;&nbsp;&nbsp; INTEGER<br>
+ /// &nbsp;&nbsp;&nbsp;&nbsp; partitionDN &nbsp;&nbsp;&nbsp; OCTET STRING<br>
+ /// &nbsp;&nbsp;&nbsp;&nbsp; replicaType &nbsp;&nbsp;&nbsp; INTEGER<br>
+ /// &nbsp;&nbsp;&nbsp;&nbsp; flags &nbsp;&nbsp;&nbsp; INTEGER</p>
+ ///
+ /// </summary>
+ /// <exception cref=""> IOException The response value could not be decoded.
+ /// </exception>
+ public GetReplicaInfoResponse(RfcLdapMessage rfcMessage):base(rfcMessage)
+ {
+
+ if (ResultCode == LdapException.SUCCESS)
+ {
+ // parse the contents of the reply
+ sbyte[] returnedValue = this.Value;
+ if (returnedValue == null)
+ throw new System.IO.IOException("No returned value");
+
+ // Create a decoder object
+ LBERDecoder decoder = new LBERDecoder();
+ if (decoder == null)
+ throw new System.IO.IOException("Decoding error");
+
+ // Parse the parameters in the order
+
+ System.IO.MemoryStream currentPtr = new System.IO.MemoryStream(SupportClass.ToByteArray(returnedValue));
+
+ // Parse partitionID
+ Asn1Integer asn1_partitionID = (Asn1Integer) decoder.decode(currentPtr);
+ if (asn1_partitionID == null)
+ throw new System.IO.IOException("Decoding error");
+
+ partitionID = asn1_partitionID.intValue();
+
+
+ // Parse replicaState
+ Asn1Integer asn1_replicaState = (Asn1Integer) decoder.decode(currentPtr);
+ if (asn1_replicaState == null)
+ throw new System.IO.IOException("Decoding error");
+
+ replicaState = asn1_replicaState.intValue();
+
+ // Parse modificationTime
+ Asn1Integer asn1_modificationTime = (Asn1Integer) decoder.decode(currentPtr);
+ if (asn1_modificationTime == null)
+ throw new System.IO.IOException("Decoding error");
+
+ modificationTime = asn1_modificationTime.intValue();
+
+ // Parse purgeTime
+ Asn1Integer asn1_purgeTime = (Asn1Integer) decoder.decode(currentPtr);
+ if (asn1_purgeTime == null)
+ throw new System.IO.IOException("Decoding error");
+
+ purgeTime = asn1_purgeTime.intValue();
+
+ // Parse localPartitionID
+ Asn1Integer asn1_localPartitionID = (Asn1Integer) decoder.decode(currentPtr);
+ if (asn1_localPartitionID == null)
+ throw new System.IO.IOException("Decoding error");
+
+ localPartitionID = asn1_localPartitionID.intValue();
+
+ // Parse partitionDN
+ Asn1OctetString asn1_partitionDN = (Asn1OctetString) decoder.decode(currentPtr);
+ if (asn1_partitionDN == null)
+ throw new System.IO.IOException("Decoding error");
+
+ partitionDN = asn1_partitionDN.stringValue();
+ if ((System.Object) partitionDN == null)
+ throw new System.IO.IOException("Decoding error");
+
+
+ // Parse replicaType
+ Asn1Integer asn1_replicaType = (Asn1Integer) decoder.decode(currentPtr);
+ if (asn1_replicaType == null)
+ throw new System.IO.IOException("Decoding error");
+
+ replicaType = asn1_replicaType.intValue();
+
+
+ // Parse flags
+ Asn1Integer asn1_flags = (Asn1Integer) decoder.decode(currentPtr);
+ if (asn1_flags == null)
+ throw new System.IO.IOException("Decoding error");
+
+ flags = asn1_flags.intValue();
+ }
+ else
+ {
+ partitionID = 0;
+ replicaState = 0;
+ modificationTime = 0;
+ purgeTime = 0;
+ localPartitionID = 0;
+ partitionDN = "";
+ replicaType = 0;
+ flags = 0;
+ }
+ }
+
+
+ /// <summary> Returns the numeric identifier for the partition.
+ ///
+ /// </summary>
+ /// <returns> Integer value specifying the partition ID.
+ /// </returns>
+ public virtual int getpartitionID()
+ {
+ return partitionID;
+ }
+
+ /// <summary> Returns the current state of the replica.
+ ///
+ /// </summary>
+ /// <returns> Integer value specifying the current state of the replica. See
+ /// ReplicationConstants class for possible values for this field.
+ ///
+ /// </returns>
+ /// <seealso cref="ReplicationConstants#Ldap_RS_BEGIN_ADD">
+ /// </seealso>
+ /// <seealso cref="ReplicationConstants#Ldap_RS_DEAD_REPLICA">
+ /// </seealso>
+ /// <seealso cref="ReplicationConstants#Ldap_RS_DYING_REPLICA">
+ /// </seealso>
+ /// <seealso cref="ReplicationConstants#Ldap_RS_JS_0">
+ /// </seealso>
+ /// <seealso cref="ReplicationConstants#Ldap_RS_JS_1">
+ /// </seealso>
+ /// <seealso cref="ReplicationConstants#Ldap_RS_JS_2">
+ /// </seealso>
+ /// <seealso cref="ReplicationConstants#Ldap_RS_LOCKED">
+ /// </seealso>
+ /// <seealso cref="ReplicationConstants#Ldap_RS_MASTER_DONE">
+ /// </seealso>
+ /// <seealso cref="ReplicationConstants#Ldap_RS_MASTER_START">
+ /// </seealso>
+ /// <seealso cref="ReplicationConstants#Ldap_RS_SS_0">
+ /// </seealso>
+ /// <seealso cref="ReplicationConstants#Ldap_RS_TRANSITION_ON">
+ /// </seealso>
+ public virtual int getreplicaState()
+ {
+ return replicaState;
+ }
+
+
+
+ /// <summary> Returns the time of the most recent modification.
+ ///
+ /// </summary>
+ /// <returns> Integer value specifying the last modification time.
+ /// </returns>
+ public virtual int getmodificationTime()
+ {
+ return modificationTime;
+ }
+
+
+ /// <summary> Returns the most recent time in which all data has been synchronized.
+ ///
+ /// </summary>
+ /// <returns> Integer value specifying the last purge time.
+ /// </returns>
+ public virtual int getpurgeTime()
+ {
+ return purgeTime;
+ }
+
+ /// <summary> Returns the local numeric identifier for the replica.
+ ///
+ /// </summary>
+ /// <returns> Integer value specifying the local ID of the partition.
+ /// </returns>
+ public virtual int getlocalPartitionID()
+ {
+ return localPartitionID;
+ }
+
+ /// <summary> Returns the distinguished name of the partition.
+ ///
+ /// </summary>
+ /// <returns> String value specifying the name of the partition read.
+ /// </returns>
+ public virtual System.String getpartitionDN()
+ {
+ return partitionDN;
+ }
+
+ /// <summary> Returns the replica type.
+ ///
+ /// <p>See the ReplicationConstants class for possible values for
+ /// this field.</p>
+ ///
+ /// </summary>
+ /// <returns> Integer identifying the type of the replica.
+ ///
+ /// </returns>
+ /// <seealso cref="ReplicationConstants#Ldap_RT_MASTER">
+ /// </seealso>
+ /// <seealso cref="ReplicationConstants#Ldap_RT_SECONDARY">
+ /// </seealso>
+ /// <seealso cref="ReplicationConstants#Ldap_RT_READONLY">
+ /// </seealso>
+ /// <seealso cref="ReplicationConstants#Ldap_RT_SUBREF">
+ /// </seealso>
+ /// <seealso cref="ReplicationConstants#Ldap_RT_SPARSE_WRITE">
+ /// </seealso>
+ /// <seealso cref="ReplicationConstants#Ldap_RT_SPARSE_READ">
+ /// </seealso>
+ public virtual int getreplicaType()
+ {
+ return replicaType;
+ }
+
+ /// <summary> Returns flags that specify whether the replica is busy or is a boundary.
+ ///
+ /// <p>See the ReplicationConstants class for possible values for
+ /// this field.</p>
+ ///
+ /// </summary>
+ /// <returns> Integer value specifying the flags for the replica.
+ ///
+ /// </returns>
+ /// <seealso cref="ReplicationConstants#Ldap_DS_FLAG_BUSY">
+ /// </seealso>
+ /// <seealso cref="ReplicationConstants#Ldap_DS_FLAG_BOUNDARY">
+ /// </seealso>
+ public virtual int getflags()
+ {
+ return flags;
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/GetReplicationFilterRequest.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/GetReplicationFilterRequest.cs
new file mode 100755
index 00000000000..4183e83c999
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/GetReplicationFilterRequest.cs
@@ -0,0 +1,96 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.Extensions.GetReplicationFilterRequest.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+using Novell.Directory.Ldap;
+using Novell.Directory.Ldap.Asn1;
+using Novell.Directory.Ldap.Utilclass;
+
+namespace Novell.Directory.Ldap.Extensions
+{
+
+ /// <summary>
+ /// Gets the Replication filter for all replicas on the server.
+ ///
+ /// <p>The filter is returned as an array of classnames-attribute names pairs. </p>
+ ///
+ /// <p>To get the filter for all replicas on a specific server, you must
+ /// create an instance of this class and then call the
+ /// extendedOperation method with this object as the required
+ /// LdapExtendedOperation parameter.</p>
+ ///
+ /// <p>The GetReplicationFilterRequest extension uses the following OID:<br>
+ /// &nbsp;&nbsp;&nbsp;2.16.840.1.113719.1.27.100.37</p>
+ ///
+ /// <p>The requestValue has the following format:<br>
+ ///
+ /// requestValue ::=<br>
+ /// &nbsp;&nbsp;&nbsp;&nbsp; serverName&nbsp;&nbsp;&nbsp; LdapDN</p>
+ /// </summary>
+ public class GetReplicationFilterRequest:LdapExtendedOperation
+ {
+
+ /// <summary>
+ /// Constructs an extended operations object which contains the ber encoded
+ /// replication filter.
+ ///
+ /// </summary>
+ /// <param name="serverDN">The server whose replication filter needs to be read
+ /// <br><br>
+ /// </param>
+ /// <exception cref=""> LdapException A general exception which includes an error
+ /// message and an Ldap error code.
+ /// </exception>
+ public GetReplicationFilterRequest(System.String serverDN):base(ReplicationConstants.GET_REPLICATION_FILTER_REQ, null)
+ {
+
+ try
+ {
+
+ if ((System.Object) serverDN == null)
+ throw new System.ArgumentException(ExceptionMessages.PARAM_ERROR);
+
+ System.IO.MemoryStream encodedData = new System.IO.MemoryStream();
+ LBEREncoder encoder = new LBEREncoder();
+
+ Asn1OctetString asn1_serverDN = new Asn1OctetString(serverDN);
+
+ // Add the serverDN to encoded data
+ asn1_serverDN.encode(encoder, encodedData);
+ setValue(SupportClass.ToSByteArray(encodedData.ToArray()));
+ }
+ catch (System.IO.IOException ioe)
+ {
+ throw new LdapException(ExceptionMessages.ENCODING_ERROR, LdapException.ENCODING_ERROR, (System.String) null);
+ }
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/GetReplicationFilterResponse.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/GetReplicationFilterResponse.cs
new file mode 100755
index 00000000000..b947a826945
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/GetReplicationFilterResponse.cs
@@ -0,0 +1,165 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.Extensions.GetReplicationFilterResponse.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+using Novell.Directory.Ldap;
+using Novell.Directory.Ldap.Asn1;
+using Novell.Directory.Ldap.Utilclass;
+using Novell.Directory.Ldap.Rfc2251;
+
+namespace Novell.Directory.Ldap.Extensions
+{
+
+ /// <summary> This object represent the filter returned fom a GetReplicationFilterRequest.
+ ///
+ /// <p>An object in this class is generated from an ExtendedResponse object
+ /// using the ExtendedResponseFactory class.</p>
+ ///
+ /// <p>The GetReplicationFilterResponse extension uses the following OID:<br>
+ /// &nbsp;&nbsp;&nbsp;2.16.840.1.113719.1.27.100.38</p>
+ ///
+ /// </summary>
+ public class GetReplicationFilterResponse:LdapExtendedResponse
+ {
+ /// <summary> Returns the replicationFilter as an array of classname-attribute name pairs
+ ///
+ /// </summary>
+ /// <returns> String array contining a two dimensional array of strings. The first
+ /// element of each array is the class name the others are the attribute names
+ /// </returns>
+ virtual public System.String[][] ReplicationFilter
+ {
+ get
+ {
+ return returnedFilter;
+ }
+
+ }
+
+
+
+ // Replication filter returned by the server goes here
+ internal System.String[][] returnedFilter;
+
+ /// <summary> Constructs an object from the responseValue which contains the replication
+ /// filter.
+ ///
+ /// <p>The constructor parses the responseValue which has the following
+ /// format:<br>
+ /// responseValue ::=<br>
+ /// &nbsp;&nbsp;&nbsp;&nbsp; SEQUENCE of SEQUENCE {</p>
+ /// &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; classname&nbsp;&nbsp;&nbsp; OCTET STRING</p>
+ /// &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SEQUENCE of ATTRIBUTES</p>
+ /// &nbsp;&nbsp;&nbsp;&nbsp;}</p>
+ /// &nbsp;&nbsp;&nbsp;&nbsp;where</p>
+ /// &nbsp;&nbsp;&nbsp;&nbsp;ATTRIBUTES:: OCTET STRING</p>
+ ///
+ /// </summary>
+ /// <exception cref=""> IOException The responseValue could not be decoded.
+ /// </exception>
+ public GetReplicationFilterResponse(RfcLdapMessage rfcMessage):base(rfcMessage)
+ {
+
+ if (ResultCode != LdapException.SUCCESS)
+ {
+ returnedFilter = new System.String[0][];
+ for (int i = 0; i < 0; i++)
+ {
+ returnedFilter[i] = new System.String[0];
+ }
+ }
+ else
+ {
+ // parse the contents of the reply
+ sbyte[] returnedValue = this.Value;
+ if (returnedValue == null)
+ throw new System.IO.IOException("No returned value");
+
+ // Create a decoder object
+ LBERDecoder decoder = new LBERDecoder();
+ if (decoder == null)
+ throw new System.IO.IOException("Decoding error");
+
+ // We should get back a sequence
+ Asn1Sequence returnedSequence = (Asn1Sequence) decoder.decode(returnedValue);
+
+ if (returnedSequence == null)
+ throw new System.IO.IOException("Decoding error");
+
+ // How many sequences in this list
+ int numberOfSequences = returnedSequence.size();
+ returnedFilter = new System.String[numberOfSequences][];
+
+ // Parse each returned sequence object
+ for (int classNumber = 0; classNumber < numberOfSequences; classNumber++)
+ {
+
+ // Get the next Asn1Sequence
+ Asn1Sequence asn1_innerSequence = (Asn1Sequence) returnedSequence.get_Renamed(classNumber);
+ if (asn1_innerSequence == null)
+ throw new System.IO.IOException("Decoding error");
+
+ // Get the asn1 encoded classname
+ Asn1OctetString asn1_className = (Asn1OctetString) asn1_innerSequence.get_Renamed(0);
+ if (asn1_className == null)
+ return ;
+
+ // Get the attribute List
+ Asn1Sequence asn1_attributeList = (Asn1Sequence) asn1_innerSequence.get_Renamed(1);
+ if (asn1_attributeList == null)
+ throw new System.IO.IOException("Decoding error");
+
+ int numberOfAttributes = asn1_attributeList.size();
+ returnedFilter[classNumber] = new System.String[numberOfAttributes + 1];
+
+ // Get the classname
+ returnedFilter[classNumber][0] = asn1_className.stringValue();
+ if ((System.Object) returnedFilter[classNumber][0] == null)
+ throw new System.IO.IOException("Decoding error");
+
+ for (int attributeNumber = 0; attributeNumber < numberOfAttributes; attributeNumber++)
+ {
+
+ // Get the asn1 encoded attribute name
+ Asn1OctetString asn1_attributeName = (Asn1OctetString) asn1_attributeList.get_Renamed(attributeNumber);
+ if (asn1_attributeName == null)
+ throw new System.IO.IOException("Decoding error");
+
+ // Get attributename string
+ returnedFilter[classNumber][attributeNumber + 1] = asn1_attributeName.stringValue();
+ if ((System.Object) returnedFilter[classNumber][attributeNumber + 1] == null)
+ throw new System.IO.IOException("Decoding error");
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/ListReplicasRequest.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/ListReplicasRequest.cs
new file mode 100755
index 00000000000..06f5a4735ac
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/ListReplicasRequest.cs
@@ -0,0 +1,91 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.Extensions.ListReplicasRequest.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+using Novell.Directory.Ldap;
+using Novell.Directory.Ldap.Asn1;
+using Novell.Directory.Ldap.Utilclass;
+
+namespace Novell.Directory.Ldap.Extensions
+{
+
+ /// <summary>
+ /// Lists all the replicas that reside on the the specified directory server.
+ ///
+ /// <p>To list replicas, you must create an instance
+ /// of this class and then call the extendedOperation method with this
+ /// object as the required LdapExtendedOperation parameter.</p>
+ ///
+ /// <p>The listReplicaRequest extension uses the following OID:<br>
+ /// &nbsp;&nbsp;&nbsp;2.16.840.1.113719.1.27.100.19</p>
+ ///
+ /// <p>The requestValue has the following format:<br>
+ ///
+ /// requestValue ::=<br>
+ /// &nbsp;&nbsp;&nbsp;&nbsp; serverName &nbsp;&nbsp;&nbsp; LdapDN</p>
+ /// </summary>
+ public class ListReplicasRequest:LdapExtendedOperation
+ {
+
+ /// <summary> Constructs an extended operation object for listing replicas.
+ ///
+ /// </summary>
+ /// <param name="serverName">The server which contains replicas.
+ ///
+ /// </param>
+ /// <exception cref=""> LdapException A general exception which includes an error
+ /// message and an Ldap error code.
+ /// </exception>
+ public ListReplicasRequest(System.String serverName):base(ReplicationConstants.LIST_REPLICAS_REQ, null)
+ {
+
+ try
+ {
+
+ if ((System.Object) serverName == null)
+ throw new System.ArgumentException(ExceptionMessages.PARAM_ERROR);
+
+ System.IO.MemoryStream encodedData = new System.IO.MemoryStream();
+ LBEREncoder encoder = new LBEREncoder();
+
+ Asn1OctetString asn1_serverName = new Asn1OctetString(serverName);
+
+ asn1_serverName.encode(encoder, encodedData);
+
+ setValue(SupportClass.ToSByteArray(encodedData.ToArray()));
+ }
+ catch (System.IO.IOException ioe)
+ {
+ throw new LdapException(ExceptionMessages.ENCODING_ERROR, LdapException.ENCODING_ERROR, (System.String) null);
+ }
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/ListReplicasResponse.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/ListReplicasResponse.cs
new file mode 100755
index 00000000000..c391918d7d2
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/ListReplicasResponse.cs
@@ -0,0 +1,125 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.Extensions.ListReplicasResponse.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+using Novell.Directory.Ldap;
+using Novell.Directory.Ldap.Asn1;
+using Novell.Directory.Ldap.Utilclass;
+using Novell.Directory.Ldap.Rfc2251;
+
+namespace Novell.Directory.Ldap.Extensions
+{
+
+ /// <summary> Retrieves the list of replicas from the specified server.
+ ///
+ /// <p>An object in this class is generated from an ExtendedResponse object
+ /// using the ExtendedResponseFactory class.</p>
+ ///
+ /// <p>The listReplicaResponse extension uses the following OID:<br>
+ /// &nbsp;&nbsp;&nbsp;2.16.840.1.113719.1.27.20</p>
+ ///
+ /// </summary>
+ public class ListReplicasResponse:LdapExtendedResponse
+ {
+ /// <summary> Returns a list of distinguished names for the replicas on the server.
+ ///
+ /// </summary>
+ /// <returns> String value specifying the identity returned by the server
+ /// </returns>
+ virtual public System.String[] ReplicaList
+ {
+ get
+ {
+ return replicaList;
+ }
+
+ }
+
+ // Identity returned by the server
+ private System.String[] replicaList;
+
+ /// <summary> Constructs an object from the responseValue which contains the list
+ /// of replicas.
+ ///
+ /// <p>The constructor parses the responseValue which has the following
+ /// format:<br>
+ /// responseValue ::=<br>
+ /// &nbsp;&nbsp;&nbsp;&nbsp; replicaList&nbsp;&nbsp;&nbsp;
+ /// SEQUENCE OF OCTET STRINGS
+ ///
+ /// </summary>
+ /// <exception cref=""> IOException The responseValue could not be decoded.
+ /// </exception>
+ public ListReplicasResponse(RfcLdapMessage rfcMessage):base(rfcMessage)
+ {
+
+ if (ResultCode != LdapException.SUCCESS)
+ {
+ replicaList = new System.String[0];
+ }
+ else
+ {
+ // parse the contents of the reply
+ sbyte[] returnedValue = this.Value;
+ if (returnedValue == null)
+ throw new System.IO.IOException("No returned value");
+
+ // Create a decoder object
+ LBERDecoder decoder = new LBERDecoder();
+ if (decoder == null)
+ throw new System.IO.IOException("Decoding error");
+
+ // We should get back a sequence
+ Asn1Sequence returnedSequence = (Asn1Sequence) decoder.decode(returnedValue);
+ if (returnedSequence == null)
+ throw new System.IO.IOException("Decoding error");
+
+ // How many replicas were returned
+ int len = returnedSequence.size();
+ replicaList = new System.String[len];
+
+ // Copy each one into our String array
+ for (int i = 0; i < len; i++)
+ {
+ // Get the next Asn1Octet String in the sequence
+ Asn1OctetString asn1_nextReplica = (Asn1OctetString) returnedSequence.get_Renamed(i);
+ if (asn1_nextReplica == null)
+ throw new System.IO.IOException("Decoding error");
+
+ // Convert to a string
+ replicaList[i] = asn1_nextReplica.stringValue();
+ if ((System.Object) replicaList[i] == null)
+ throw new System.IO.IOException("Decoding error");
+ }
+ }
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/MergePartitionsRequest.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/MergePartitionsRequest.cs
new file mode 100755
index 00000000000..5f2a5ab7aa3
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/MergePartitionsRequest.cs
@@ -0,0 +1,102 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.Extensions.MergePartitionsRequest.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+using Novell.Directory.Ldap;
+using Novell.Directory.Ldap.Asn1;
+using Novell.Directory.Ldap.Utilclass;
+
+namespace Novell.Directory.Ldap.Extensions
+{
+
+ /// <summary>
+ /// Merges a child partition with its parent partition.
+ ///
+ /// <p>To merge a child partition with its parent, you must create an
+ /// instance of this class and then call the extendedOperation method
+ /// with this object as the required LdapExtendedOperation parameter.</p>
+ ///
+ /// <p>The mergePartitionsRequest extension uses the following OID:<br>
+ /// &nbsp;&nbsp;&nbsp;2.16.840.1.113719.1.27.100.5</p>
+ ///
+ /// <p>The requestValue has the following format:<br>
+ ///
+ /// requestValue ::=<br>
+ /// &nbsp;&nbsp;&nbsp;&nbsp; flags &nbsp;&nbsp;&nbsp; INTEGER<br>
+ /// &nbsp;&nbsp;&nbsp;&nbsp; dn &nbsp;&nbsp;&nbsp; LdapDN</p>
+ /// </summary>
+ public class MergePartitionsRequest:LdapExtendedOperation
+ {
+
+ /// <summary> Constructs an extended operation object for merging partitions.
+ ///
+ /// </summary>
+ /// <param name="dn"> The distinguished name of the child partition's root.
+ /// <br><br>
+ /// </param>
+ /// <param name="flags"> Determines whether all servers in the replica ring must
+ /// be up before proceeding. When set to zero, the status of
+ /// the servers is not checked. When set to
+ /// Ldap_ENSURE_SERVERS_UP, all servers must be up for the
+ /// operation to proceed.
+ ///
+ /// </param>
+ /// <exception cref=""> LdapException A general exception which includes an error
+ /// message and an Ldap error code.
+ /// </exception>
+
+ public MergePartitionsRequest(System.String dn, int flags):base(ReplicationConstants.MERGE_NAMING_CONTEXT_REQ, null)
+ {
+
+ try
+ {
+
+ if ((System.Object) dn == null)
+ throw new System.ArgumentException(ExceptionMessages.PARAM_ERROR);
+
+ System.IO.MemoryStream encodedData = new System.IO.MemoryStream();
+ LBEREncoder encoder = new LBEREncoder();
+
+ Asn1Integer asn1_flags = new Asn1Integer(flags);
+ Asn1OctetString asn1_dn = new Asn1OctetString(dn);
+
+ asn1_flags.encode(encoder, encodedData);
+ asn1_dn.encode(encoder, encodedData);
+
+ setValue(SupportClass.ToSByteArray(encodedData.ToArray()));
+ }
+ catch (System.IO.IOException ioe)
+ {
+ throw new LdapException(ExceptionMessages.ENCODING_ERROR, LdapException.ENCODING_ERROR, (System.String) null);
+ }
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/NamingContextConstants.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/NamingContextConstants.cs
new file mode 100755
index 00000000000..47c9c09d13e
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/NamingContextConstants.cs
@@ -0,0 +1,367 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.Extensions.NamingContextConstants.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+
+namespace Novell.Directory.Ldap.Extensions
+{
+
+ /*
+ * public class NamingContextConstants
+ */
+
+ /// <summary> Contains a collection of constants used by the Novell Ldap extensions.</summary>
+ public class NamingContextConstants
+ {
+
+ /// <summary> A constant for the createNamingContextRequest OID.</summary>
+ public const System.String CREATE_NAMING_CONTEXT_REQ = "2.16.840.1.113719.1.27.100.3";
+
+ /// <summary> A constant for the createNamingContextResponse OID.</summary>
+ public const System.String CREATE_NAMING_CONTEXT_RES = "2.16.840.1.113719.1.27.100.4";
+
+ /// <summary> A constant for the mergeNamingContextRequest OID.</summary>
+ public const System.String MERGE_NAMING_CONTEXT_REQ = "2.16.840.1.113719.1.27.100.5";
+
+ /// <summary> A constant for the mergeNamingContextResponse OID.</summary>
+ public const System.String MERGE_NAMING_CONTEXT_RES = "2.16.840.1.113719.1.27.100.6";
+
+ /// <summary> A constant for the addReplicaRequest OID.</summary>
+ public const System.String ADD_REPLICA_REQ = "2.16.840.1.113719.1.27.100.7";
+
+ /// <summary> A constant for the addReplicaResponse OID.</summary>
+ public const System.String ADD_REPLICA_RES = "2.16.840.1.113719.1.27.100.8";
+
+ /// <summary> A constant for the refreshServerRequest OID.</summary>
+ public const System.String REFRESH_SERVER_REQ = "2.16.840.1.113719.1.27.100.9";
+
+ /// <summary> A constant for the refreshServerResponse OID.</summary>
+ public const System.String REFRESH_SERVER_RES = "2.16.840.1.113719.1.27.100.10";
+
+ /// <summary> A constant for the removeReplicaRequest OID.</summary>
+ public const System.String DELETE_REPLICA_REQ = "2.16.840.1.113719.1.27.100.11";
+
+ /// <summary> A constant for the removeReplicaResponse OID.</summary>
+ public const System.String DELETE_REPLICA_RES = "2.16.840.1.113719.1.27.100.12";
+
+ /// <summary> A constant for the namingContextEntryCountRequest OID.</summary>
+ public const System.String NAMING_CONTEXT_COUNT_REQ = "2.16.840.1.113719.1.27.100.13";
+
+ /// <summary> A constant for the namingContextEntryCountResponse OID.</summary>
+ public const System.String NAMING_CONTEXT_COUNT_RES = "2.16.840.1.113719.1.27.100.14";
+
+ /// <summary> A constant for the changeReplicaTypeRequest OID.</summary>
+ public const System.String CHANGE_REPLICA_TYPE_REQ = "2.16.840.1.113719.1.27.100.15";
+
+ /// <summary> A constant for the changeReplicaTypeResponse OID.</summary>
+ public const System.String CHANGE_REPLICA_TYPE_RES = "2.16.840.1.113719.1.27.100.16";
+
+ /// <summary> A constant for the getReplicaInfoRequest OID.</summary>
+ public const System.String GET_REPLICA_INFO_REQ = "2.16.840.1.113719.1.27.100.17";
+
+ /// <summary> A constant for the getReplicaInfoResponse OID.</summary>
+ public const System.String GET_REPLICA_INFO_RES = "2.16.840.1.113719.1.27.100.18";
+
+ /// <summary> A constant for the listReplicaRequest OID.</summary>
+ public const System.String LIST_REPLICAS_REQ = "2.16.840.1.113719.1.27.100.19";
+
+ /// <summary> A constant for the listReplicaResponse OID.</summary>
+ public const System.String LIST_REPLICAS_RES = "2.16.840.1.113719.1.27.100.20";
+
+ /// <summary> A constant for the receiveAllUpdatesRequest OID.</summary>
+ public const System.String RECEIVE_ALL_UPDATES_REQ = "2.16.840.1.113719.1.27.100.21";
+
+ /// <summary> A constant for the receiveAllUpdatesResponse OID.</summary>
+ public const System.String RECEIVE_ALL_UPDATES_RES = "2.16.840.1.113719.1.27.100.22";
+
+ /// <summary> A constant for the sendAllUpdatesRequest OID.</summary>
+ public const System.String SEND_ALL_UPDATES_REQ = "2.16.840.1.113719.1.27.100.23";
+
+ /// <summary> A constant for the sendAllUpdatesResponse OID.</summary>
+ public const System.String SEND_ALL_UPDATES_RES = "2.16.840.1.113719.1.27.100.24";
+
+ /// <summary> A constant for the requestNamingContextSyncRequest OID.</summary>
+ public const System.String NAMING_CONTEXT_SYNC_REQ = "2.16.840.1.113719.1.27.100.25";
+
+ /// <summary> A constant for the requestNamingContextSyncResponse OID.</summary>
+ public const System.String NAMING_CONTEXT_SYNC_RES = "2.16.840.1.113719.1.27.100.26";
+
+ /// <summary> A constant for the requestSchemaSyncRequest OID.</summary>
+ public const System.String SCHEMA_SYNC_REQ = "2.16.840.1.113719.1.27.100.27";
+
+ /// <summary> A constant for the requestSchemaSyncResponse OID.</summary>
+ public const System.String SCHEMA_SYNC_RES = "2.16.840.1.113719.1.27.100.28";
+
+ /// <summary> A constant for the abortNamingContextOperationRequest OID.</summary>
+ public const System.String ABORT_NAMING_CONTEXT_OP_REQ = "2.16.840.1.113719.1.27.100.29";
+
+ /// <summary> A constant for the abortNamingContextOperationResponse OID.</summary>
+ public const System.String ABORT_NAMING_CONTEXT_OP_RES = "2.16.840.1.113719.1.27.100.30";
+
+ /// <summary> A constant for the getContextIdentityNameRequest OID.</summary>
+ public const System.String GET_IDENTITY_NAME_REQ = "2.16.840.1.113719.1.27.100.31";
+
+ /// <summary> A constant for the getContextIdentityNameResponse OID.</summary>
+ public const System.String GET_IDENTITY_NAME_RES = "2.16.840.1.113719.1.27.100.32";
+
+ /// <summary> A constant for the getEffectivePrivilegesRequest OID.</summary>
+ public const System.String GET_EFFECTIVE_PRIVILEGES_REQ = "2.16.840.1.113719.1.27.100.33";
+
+ /// <summary> A constant for the getEffectivePrivilegesResponse OID.</summary>
+ public const System.String GET_EFFECTIVE_PRIVILEGES_RES = "2.16.840.1.113719.1.27.100.34";
+
+ /// <summary> A constant for the setReplicationFilterRequest OID.</summary>
+ public const System.String SET_REPLICATION_FILTER_REQ = "2.16.840.1.113719.1.27.100.35";
+
+ /// <summary> A constant for the setReplicationFilterResponse OID.</summary>
+ public const System.String SET_REPLICATION_FILTER_RES = "2.16.840.1.113719.1.27.100.36";
+
+ /// <summary> A constant for the getReplicationFilterRequest OID.</summary>
+ public const System.String GET_REPLICATION_FILTER_REQ = "2.16.840.1.113719.1.27.100.37";
+
+ /// <summary> A constant for the getReplicationFilterResponse OID.</summary>
+ public const System.String GET_REPLICATION_FILTER_RES = "2.16.840.1.113719.1.27.100.38";
+
+ /// <summary> A constant for the createOrphanNamingContextRequest OID.</summary>
+ public const System.String CREATE_ORPHAN_NAMING_CONTEXT_REQ = "2.16.840.1.113719.1.27.100.39";
+
+ /// <summary> A constant for the createOrphanNamingContextResponse OID.</summary>
+ public const System.String CREATE_ORPHAN_NAMING_CONTEXT_RES = "2.16.840.1.113719.1.27.100.40";
+
+ /// <summary> A constant for the removeOrphanNamingContextRequest OID.</summary>
+ public const System.String REMOVE_ORPHAN_NAMING_CONTEXT_REQ = "2.16.840.1.113719.1.27.100.41";
+
+ /// <summary> A constant for the removeOrphanNamingContextResponse OID.</summary>
+ public const System.String REMOVE_ORPHAN_NAMING_CONTEXT_RES = "2.16.840.1.113719.1.27.100.42";
+
+ /// <summary> A constant for the triggerBackLinkerRequest OID.</summary>
+ public const System.String TRIGGER_BKLINKER_REQ = "2.16.840.1.113719.1.27.100.43";
+
+ /// <summary> A constant for the triggerBackLinkerResponse OID.</summary>
+ public const System.String TRIGGER_BKLINKER_RES = "2.16.840.1.113719.1.27.100.44";
+
+ /// <summary> A constant for the triggerJanitorRequest OID.</summary>
+ public const System.String TRIGGER_JANITOR_REQ = "2.16.840.1.113719.1.27.100.47";
+
+ /// <summary> A constant for the triggerJanitorResponse OID.</summary>
+ public const System.String TRIGGER_JANITOR_RES = "2.16.840.1.113719.1.27.100.48";
+
+ /// <summary> A constant for the triggerLimberRequest OID.</summary>
+ public const System.String TRIGGER_LIMBER_REQ = "2.16.840.1.113719.1.27.100.49";
+
+ /// <summary> A constant for the triggerLimberResponse OID.</summary>
+ public const System.String TRIGGER_LIMBER_RES = "2.16.840.1.113719.1.27.100.50";
+
+ /// <summary> A constant for the triggerSkulkerRequest OID.</summary>
+ public const System.String TRIGGER_SKULKER_REQ = "2.16.840.1.113719.1.27.100.51";
+
+ /// <summary> A constant for the triggerSkulkerResponse OID.</summary>
+ public const System.String TRIGGER_SKULKER_RES = "2.16.840.1.113719.1.27.100.52";
+
+ /// <summary> A constant for the triggerSchemaSyncRequest OID.</summary>
+ public const System.String TRIGGER_SCHEMA_SYNC_REQ = "2.16.840.1.113719.1.27.100.53";
+
+ /// <summary> A constant for the triggerSchemaSyncResponse OID.</summary>
+ public const System.String TRIGGER_SCHEMA_SYNC_RES = "2.16.840.1.113719.1.27.100.54";
+
+ /// <summary> A constant for the triggerPartitionPurgeRequest OID.</summary>
+ public const System.String TRIGGER_PART_PURGE_REQ = "2.16.840.1.113719.1.27.100.55";
+
+ /// <summary> A constant for the triggerPartitionPurgeResponse OID.</summary>
+ public const System.String TRIGGER_PART_PURGE_RES = "2.16.840.1.113719.1.27.100.56";
+
+
+ /// <summary> A constant that specifies that all servers in a replica ring must be
+ /// running for a naming context operation to proceed.
+ /// </summary>
+ public const int Ldap_ENSURE_SERVERS_UP = 1;
+
+
+ /// <summary> Identifies this replica as the master replica of the naming context.
+ ///
+ /// <p>On this type of replica, entries can be modified, and naming context
+ /// operations can be performed.</p>
+ /// </summary>
+ public const int Ldap_RT_MASTER = 0;
+
+ /// <summary> Identifies this replica as a secondary replica of the naming context.
+ ///
+ /// <p>On this type of replica, read and write operations can be performed,
+ /// and entries can be modified.</p>
+ /// </summary>
+ public const int Ldap_RT_SECONDARY = 1;
+
+ /// <summary> Identifies this replica as a read-only replica of the naming context.
+ ///
+ /// <p>Only Novell eDirectory synchronization processes can modifie
+ /// entries on this replica.</p>
+ /// </summary>
+ public const int Ldap_RT_READONLY = 2;
+
+ /// <summary> Identifies this replica as a subordinate reference replica of the
+ /// naming context.
+ ///
+ /// <p>Novell eDirectory automatically adds these replicas to a server
+ /// when the server does not contain replicas of all child naming contexts.
+ /// Only eDirectory can modify information on these types of replicas. </p>
+ /// </summary>
+ public const int Ldap_RT_SUBREF = 3;
+
+ /// <summary> Identifies this replica as a read/write replica of the naming context,
+ /// but the replica contains sparse data.
+ ///
+ /// <p>The replica has been configured to contain only specified object types
+ /// and attributes. On this type of replica, only the attributes and objects
+ /// contained in the sparse data can be modified.</p>
+ /// </summary>
+ public const int Ldap_RT_SPARSE_WRITE = 4;
+
+ /// <summary> Identifies this replica as a read-only replica of the naming context,
+ /// but the replica contains sparse data.
+ ///
+ /// <p>The replica has been configured to contain only specified object types
+ /// and attributes. On this type of replica, only Novell eDirectory
+ /// synchronization processes can modify the sparse data.</p>
+ /// </summary>
+ public const int Ldap_RT_SPARSE_READ = 5;
+
+ //Replica States
+
+ /// <summary> Indicates that the replica is fully functioning and capable of responding
+ /// to requests.
+ /// </summary>
+ public const int Ldap_RS_ON = 0;
+
+ /// <summary> Indicates that a new replica has been added but has not received a full
+ /// download of information from the replica ring.
+ /// </summary>
+ public const int Ldap_RS_NEW_REPLICA = 1;
+
+ /// <summary> Indicates that the replica is being deleted and that the request has
+ /// been received.
+ /// </summary>
+ public const int Ldap_RS_DYING_REPLICA = 2;
+
+ /// <summary> Indicates that the replica is locked. The move operation uses this state
+ /// to lock the parent naming context of the child naming context that is moving.
+ /// </summary>
+ public const int Ldap_RS_LOCKED = 3;
+
+ /// <summary> Indicates that a new replica has finished receiving its download from the
+ /// master replica and is now receiving synchronization updates from other
+ /// replicas.
+ /// </summary>
+ public const int Ldap_RS_TRANSITION_ON = 6;
+
+
+ /// <summary> Indicates that the dying replica needs to synchronize with another replica
+ /// before being converted either to an external reference, if a root replica,
+ /// or to a subordinate reference, if a non-root replica.
+ /// </summary>
+ public const int Ldap_RS_DEAD_REPLICA = 7;
+
+ /// <summary> Indicates that the subordinate references of the new replica are being
+ /// added.
+ /// </summary>
+ public const int Ldap_RS_BEGIN_ADD = 8;
+
+ /// <summary> Indicates that a naming context is receiving a new master replica.
+ ///
+ /// <p>The replica that will be the new master replica is set to this state.</p>
+ /// </summary>
+ public const int Ldap_RS_MASTER_START = 11;
+
+ /// <summary> Indicates that a naming context has a new master replica.
+ ///
+ /// <p>When the new master is set to this state, Novell eDirectory knows
+ /// that the replica is now the master and changes its replica type to
+ /// master and the old master to read/write.</p>
+ /// </summary>
+ public const int Ldap_RS_MASTER_DONE = 12;
+
+ /// <summary> Indicates that the naming context is going to split into two naming contexts.
+ ///
+ /// <p>In this state, other replicas of the naming context are informed of the
+ /// pending split.</p>
+ /// </summary>
+ public const int Ldap_RS_SS_0 = 48; // Replica splitting 0
+
+ /// <summary> Indicates that that the split naming context operation has started.
+ ///
+ /// <p>When the split is finished, the state will change to RS_ON.</p>
+ /// </summary>
+ public const int Ldap_RS_SS_1 = 49; // Replica splitting 1
+
+ /// <summary> Indicates that that two naming contexts are in the process of joining
+ /// into one naming context.
+ ///
+ /// <p>In this state, the replicas that are affected are informed of the join
+ /// operation. The master replica of the parent and child naming contexts are
+ /// first set to this state and then all the replicas of the parent and child.
+ /// New replicas are added where needed.</p>
+ /// </summary>
+ public const int Ldap_RS_JS_0 = 64; // Replica joining 0
+
+ /// <summary> Indicates that that two naming contexts are in the process of joining
+ /// into one naming context.
+ ///
+ /// <p>This state indicates that the join operation is waiting for the new
+ /// replicas to synchronize and move to the RS_ON state.</p>
+ /// </summary>
+ public const int Ldap_RS_JS_1 = 65; // Replica joining 1
+
+ /// <summary> Indicates that that two naming contexts are in the process of joining
+ /// into one naming context.
+ ///
+ /// <p>This state indicates that all the new replicas are in the RS_ON state
+ /// and that the rest of the work can be completed.</p>
+ /// </summary>
+ public const int Ldap_RS_JS_2 = 66; // Replica joining 2
+
+
+ // Values for flags used in the replica info class structure
+
+ /// <summary> Indicates that the replica is involved with a partition operation,
+ /// for example, merging a tree or moving a subtree.
+ /// </summary>
+ public const int Ldap_DS_FLAG_BUSY = 0x0001;
+
+ /// <summary> Indicates that this naming context is on the DNS federation boundary.
+ /// This flag is only set on DNS trees.
+ /// </summary>
+ public const int Ldap_DS_FLAG_BOUNDARY = 0x0002;
+
+
+ public NamingContextConstants()
+ {
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/PartitionEntryCountRequest.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/PartitionEntryCountRequest.cs
new file mode 100755
index 00000000000..715ed90b679
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/PartitionEntryCountRequest.cs
@@ -0,0 +1,98 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.Extensions.PartitionEntryCountRequest.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+using Novell.Directory.Ldap;
+using Novell.Directory.Ldap.Asn1;
+using Novell.Directory.Ldap.Utilclass;
+
+namespace Novell.Directory.Ldap.Extensions
+{
+
+ /// <summary> Returns a count of the number of entries (objects) in the
+ /// specified partition.
+ ///
+ /// <p>To obtain the count of entries, you must create an instance of this
+ /// class and then call the extendedOperation method with this
+ /// object as the required LdapExtendedOperation parameter.</p>
+ ///
+ /// <p>The returned LdapExtendedResponse object can then be converted to
+ /// a PartitionEntryCountResponse object. This class contains
+ /// methods for retrieving the returned count.</p>
+ ///
+ /// <p>The PartitionEntryCountRequest extension uses the following
+ /// OID:<br>
+ /// &nbsp;&nbsp;&nbsp;2.16.840.1.113719.1.27.100.13</p>
+ ///
+ /// <p>The requestValue has the following format:<br>
+ ///
+ /// requestValue ::=<br><br>
+ /// &nbsp;&nbsp;&nbsp;&nbsp; dn &nbsp;&nbsp;&nbsp; LdapDN
+ /// </summary>
+ public class PartitionEntryCountRequest:LdapExtendedOperation
+ {
+
+ /// <summary> Constructs an extended operation object for counting entries
+ /// in a naming context.
+ ///
+ /// </summary>
+ /// <param name="dn"> The distinguished name of the partition.
+ ///
+ /// </param>
+ /// <exception cref=""> LdapException A general exception which includes an
+ /// error message and an Ldap error code.
+ /// </exception>
+
+ public PartitionEntryCountRequest(System.String dn):base(ReplicationConstants.NAMING_CONTEXT_COUNT_REQ, null)
+ {
+
+ try
+ {
+
+ if (((System.Object) dn == null))
+ throw new System.ArgumentException(ExceptionMessages.PARAM_ERROR);
+
+ System.IO.MemoryStream encodedData = new System.IO.MemoryStream();
+ LBEREncoder encoder = new LBEREncoder();
+
+ Asn1OctetString asn1_dn = new Asn1OctetString(dn);
+
+ asn1_dn.encode(encoder, encodedData);
+
+ setValue(SupportClass.ToSByteArray(encodedData.ToArray()));
+ }
+ catch (System.IO.IOException ioe)
+ {
+ throw new LdapException(ExceptionMessages.ENCODING_ERROR, LdapException.ENCODING_ERROR, (System.String) null);
+ }
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/PartitionEntryCountResponse.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/PartitionEntryCountResponse.cs
new file mode 100755
index 00000000000..a261685f094
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/PartitionEntryCountResponse.cs
@@ -0,0 +1,107 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.Extensions.PartitionEntryCountResponse.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+using Novell.Directory.Ldap;
+using Novell.Directory.Ldap.Asn1;
+using Novell.Directory.Ldap.Utilclass;
+using Novell.Directory.Ldap.Rfc2251;
+namespace Novell.Directory.Ldap.Extensions
+{
+
+ /// <summary> Returns the number of entries in the partition.
+ ///
+ /// <p>An object in this class is generated from an ExtendedResponse object
+ /// using the ExtendedResponseFactory class.</p>
+ ///
+ /// <p>The PartitionEntryCountResponse extension uses the following
+ /// OID:<br>
+ /// &nbsp;&nbsp;&nbsp;2.16.840.1.113719.1.27.100.14</p>
+ ///
+ /// </summary>
+ public class PartitionEntryCountResponse:LdapExtendedResponse
+ {
+ /// <summary> Returns the number of entries in the naming context.
+ ///
+ /// </summary>
+ /// <returns> The count of the number of objects returned.
+ /// </returns>
+ virtual public int Count
+ {
+ get
+ {
+ return count;
+ }
+
+ }
+
+ //The count of the objects returned by the server is saved here
+ private int count;
+
+ /// <summary> Constructs an object from the responseValue which contains the
+ /// entry count.
+ ///
+ /// <p>The constructor parses the responseValue which has the following
+ /// format:<br>
+ /// responseValue ::=<br>
+ /// &nbsp;&nbsp;&nbsp;&nbsp; count &nbsp;&nbsp;&nbsp INTEGER</p>
+ ///
+ /// </summary>
+ /// <exception cref=""> IOException The response value could not be decoded.
+ /// </exception>
+ public PartitionEntryCountResponse(RfcLdapMessage rfcMessage):base(rfcMessage)
+ {
+
+ if (ResultCode == LdapException.SUCCESS)
+ {
+ // parse the contents of the reply
+ sbyte[] returnedValue = this.Value;
+ if (returnedValue == null)
+ throw new System.IO.IOException("No returned value");
+
+ // Create a decoder object
+ LBERDecoder decoder = new LBERDecoder();
+ if (decoder == null)
+ throw new System.IO.IOException("Decoding error");
+
+ Asn1Integer asn1_count = (Asn1Integer) decoder.decode(returnedValue);
+ if (asn1_count == null)
+ throw new System.IO.IOException("Decoding error");
+
+ count = asn1_count.intValue();
+ }
+ else
+ {
+ count = - 1;
+ }
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/PartitionSyncRequest.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/PartitionSyncRequest.cs
new file mode 100755
index 00000000000..7cf3e9db870
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/PartitionSyncRequest.cs
@@ -0,0 +1,104 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.Extensions.PartitionSyncRequest.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+using Novell.Directory.Ldap;
+using Novell.Directory.Ldap.Asn1;
+using Novell.Directory.Ldap.Utilclass;
+
+namespace Novell.Directory.Ldap.Extensions
+{
+
+ /// <summary>
+ /// Synchronizes all replicas of a naming context.
+ ///
+ /// <p>The PartitionSyncRequest extension uses the following OID:<br>
+ /// &nbsp;&nbsp;&nbsp;2.16.840.1.113719.1.27.100.25</p>
+ ///
+ /// <p>The requestValue has the following format:<br>
+ ///
+ /// requestValue ::=<br>
+ /// &nbsp;&nbsp;&nbsp;&nbsp; serverName&nbsp;&nbsp;&nbsp; LdapDN<br>
+ /// &nbsp;&nbsp;&nbsp;&nbsp; partitionRoot&nbsp;&nbsp;&nbsp; LdapDN<br>
+ /// &nbsp;&nbsp;&nbsp;&nbsp; delay&nbsp;&nbsp;&nbsp; INTEGER</p>
+ /// </summary>
+ public class PartitionSyncRequest:LdapExtendedOperation
+ {
+
+ /// <summary>
+ /// Constructs an extended operation object for synchronizing the replicas
+ /// of a partition.
+ ///
+ /// </summary>
+ /// <param name="serverName"> The distinquished name of server containing the
+ /// naming context.
+ /// <br><br>
+ /// </param>
+ /// <param name="partitionRoot"> The distinguished name of the naming context
+ /// to synchronize.
+ /// <br><br>
+ /// </param>
+ /// <param name="delay"> The time, in seconds, to delay before the synchronization
+ /// should start.
+ ///
+ /// </param>
+ /// <exception cref=""> LdapException A general exception which includes an error message
+ /// and an Ldap error code.
+ /// </exception>
+ public PartitionSyncRequest(System.String serverName, System.String partitionRoot, int delay):base(ReplicationConstants.NAMING_CONTEXT_SYNC_REQ, null)
+ {
+
+ try
+ {
+
+ if (((System.Object) serverName == null) || ((System.Object) partitionRoot == null))
+ throw new System.ArgumentException(ExceptionMessages.PARAM_ERROR);
+
+ System.IO.MemoryStream encodedData = new System.IO.MemoryStream();
+ LBEREncoder encoder = new LBEREncoder();
+
+ Asn1OctetString asn1_serverName = new Asn1OctetString(serverName);
+ Asn1OctetString asn1_partitionRoot = new Asn1OctetString(partitionRoot);
+ Asn1Integer asn1_delay = new Asn1Integer(delay);
+
+ asn1_serverName.encode(encoder, encodedData);
+ asn1_partitionRoot.encode(encoder, encodedData);
+ asn1_delay.encode(encoder, encodedData);
+
+ setValue(SupportClass.ToSByteArray(encodedData.ToArray()));
+ }
+ catch (System.IO.IOException ioe)
+ {
+ throw new LdapException(ExceptionMessages.ENCODING_ERROR, LdapException.ENCODING_ERROR, (System.String) null);
+ }
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/ReceiveAllUpdatesRequest.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/ReceiveAllUpdatesRequest.cs
new file mode 100755
index 00000000000..149f9f0eb25
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/ReceiveAllUpdatesRequest.cs
@@ -0,0 +1,104 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.Extensions.ReceiveAllUpdatesRequest.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+using Novell.Directory.Ldap;
+using Novell.Directory.Ldap.Asn1;
+using Novell.Directory.Ldap.Utilclass;
+
+namespace Novell.Directory.Ldap.Extensions
+{
+
+ /// <summary> Schedules a specified directory server to receive updates from another
+ /// directory server for a specific replica.
+ ///
+ /// <p>The receiveAllUpdatesRequest extension uses the following OID:<br>
+ /// &nbsp;&nbsp;&nbsp;2.16.840.1.113719.1.27.100.21</p>
+ ///
+ /// <p>The requestValue has the following format:<br>
+ ///
+ /// requestValue ::=<br>
+ /// &nbsp;&nbsp;&nbsp;&nbsp; partitionRoot &nbsp;&nbsp;&nbsp; LdapDN<br>
+ /// &nbsp;&nbsp;&nbsp;&nbsp; toServerDN &nbsp;&nbsp;&nbsp; LdapDN<br>
+ /// &nbsp;&nbsp;&nbsp;&nbsp; fromServerDN &nbsp;&nbsp;&nbsp; LdapDN</p>
+ /// </summary>
+ public class ReceiveAllUpdatesRequest:LdapExtendedOperation
+ {
+
+ /// <summary>
+ /// Constructs an extended operation object for receiving all updates from
+ /// another directory server for a specific replica.
+ ///
+ /// </summary>
+ /// <param name="partitionRoot"> The distinguished name of the replica
+ /// that will be updated.
+ /// <br><br>
+ /// </param>
+ /// <param name="toServerDN"> The distinguished name of the server holding the
+ /// replica to be updated.
+ /// <br><br>
+ /// </param>
+ /// <param name="fromServerDN"> The distinguished name of the server from which
+ /// updates are sent.
+ ///
+ /// </param>
+ /// <exception cref=""> LdapException A general exception which includes an error message
+ /// and an Ldap error code.
+ /// </exception>
+ public ReceiveAllUpdatesRequest(System.String partitionRoot, System.String toServerDN, System.String fromServerDN):base(ReplicationConstants.RECEIVE_ALL_UPDATES_REQ, null)
+ {
+
+ try
+ {
+
+ if (((System.Object) partitionRoot == null) || ((System.Object) toServerDN == null) || ((System.Object) fromServerDN == null))
+ throw new System.ArgumentException(ExceptionMessages.PARAM_ERROR);
+
+ System.IO.MemoryStream encodedData = new System.IO.MemoryStream();
+ LBEREncoder encoder = new LBEREncoder();
+
+ Asn1OctetString asn1_partitionRoot = new Asn1OctetString(partitionRoot);
+ Asn1OctetString asn1_toServerDN = new Asn1OctetString(toServerDN);
+ Asn1OctetString asn1_fromServerDN = new Asn1OctetString(fromServerDN);
+
+ asn1_partitionRoot.encode(encoder, encodedData);
+ asn1_toServerDN.encode(encoder, encodedData);
+ asn1_fromServerDN.encode(encoder, encodedData);
+
+ setValue(SupportClass.ToSByteArray(encodedData.ToArray()));
+ }
+ catch (System.IO.IOException ioe)
+ {
+ throw new LdapException(ExceptionMessages.ENCODING_ERROR, LdapException.ENCODING_ERROR, (System.String) null);
+ }
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/RefreshLdapServerRequest.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/RefreshLdapServerRequest.cs
new file mode 100755
index 00000000000..aaf2230eed2
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/RefreshLdapServerRequest.cs
@@ -0,0 +1,64 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.Extensions.RefreshLdapServerRequest.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+using Novell.Directory.Ldap;
+using Novell.Directory.Ldap.Asn1;
+using Novell.Directory.Ldap.Utilclass;
+
+namespace Novell.Directory.Ldap.Extensions
+{
+
+ /// <summary>
+ /// Reloads the Ldap server.
+ ///
+ /// <p>The refreshLdapServerRequest extension uses the following OID:<br>
+ /// &nbsp;&nbsp;&nbsp;2.16.840.1.113719.1.27.100.9</p>
+ ///
+ /// <p>The requestValue is set to null.</p>
+ /// </summary>
+ public class RefreshLdapServerRequest:LdapExtendedOperation
+ {
+
+ /// <summary>
+ /// Constructs an extended operation object for reloading the Ldap server.
+ ///
+ /// <p>The constructor sets the OID.</p>
+ ///
+ /// </summary>
+ /// <exception cref=""> LdapException A general exception which includes an error
+ /// message and an Ldap error code.
+ /// </exception>
+ public RefreshLdapServerRequest():base(ReplicationConstants.REFRESH_SERVER_REQ, null)
+ {
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/RemoveOrphanPartitionRequest.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/RemoveOrphanPartitionRequest.cs
new file mode 100755
index 00000000000..ce6c25003d2
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/RemoveOrphanPartitionRequest.cs
@@ -0,0 +1,98 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.Extensions.RemoveOrphanPartitionRequest.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+using Novell.Directory.Ldap;
+using Novell.Directory.Ldap.Asn1;
+using Novell.Directory.Ldap.Utilclass;
+
+namespace Novell.Directory.Ldap.Extensions
+{
+
+ /// <summary> Deletes an orphan partition.
+ ///
+ /// <p>To delete an orphan partition, you must create an instance of this
+ /// class and then call the extendedOperation method with this
+ /// object as the required LdapExtendedOperation parameter.</p>
+ ///
+ /// <p>The RemoveOrphanPartitionRequest extension uses the following OID:<br>
+ /// &nbsp;&nbsp;&nbsp;2.16.840.1.113719.1.27.100.41</p>
+ ///
+ /// <p>The requestValue has the following format:<br>
+ ///
+ /// requestValue ::=<br>
+ /// &nbsp;&nbsp;&nbsp;&nbsp; serverDN &nbsp;&nbsp;&nbsp; LdapDN<br>
+ /// &nbsp;&nbsp;&nbsp;&nbsp; contextName &nbsp;&nbsp;&nbsp; LdapDN</p>
+ /// </summary>
+ public class RemoveOrphanPartitionRequest:LdapExtendedOperation
+ {
+
+ /// <summary> Constructs an extended operation object for deleting an orphan partition.
+ ///
+ /// </summary>
+ /// <param name="serverDN"> The distinguished name of the server
+ /// on which the orphan partition resides.
+ /// <br><br>
+ /// </param>
+ /// <param name="contextName"> The distinguished name of the orphan
+ /// partition to delete.
+ ///
+ /// </param>
+ /// <exception cref=""> LdapException A general exception which includes an error message
+ /// and an Ldap error code.
+ /// </exception>
+ public RemoveOrphanPartitionRequest(System.String serverDN, System.String contextName):base(ReplicationConstants.REMOVE_ORPHAN_NAMING_CONTEXT_REQ, null)
+ {
+
+ try
+ {
+
+ if (((System.Object) serverDN == null) || ((System.Object) contextName == null))
+ throw new System.ArgumentException(ExceptionMessages.PARAM_ERROR);
+
+ System.IO.MemoryStream encodedData = new System.IO.MemoryStream();
+ LBEREncoder encoder = new LBEREncoder();
+
+ Asn1OctetString asn1_serverDN = new Asn1OctetString(serverDN);
+ Asn1OctetString asn1_contextName = new Asn1OctetString(contextName);
+
+ asn1_serverDN.encode(encoder, encodedData);
+ asn1_contextName.encode(encoder, encodedData);
+
+ setValue(SupportClass.ToSByteArray(encodedData.ToArray()));
+ }
+ catch (System.IO.IOException ioe)
+ {
+ throw new LdapException(ExceptionMessages.ENCODING_ERROR, LdapException.ENCODING_ERROR, (System.String) null);
+ }
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/RemoveReplicaRequest.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/RemoveReplicaRequest.cs
new file mode 100755
index 00000000000..0282aadd8f7
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/RemoveReplicaRequest.cs
@@ -0,0 +1,108 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.Extensions.RemoveReplicaRequest.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+using Novell.Directory.Ldap;
+using Novell.Directory.Ldap.Asn1;
+using Novell.Directory.Ldap.Utilclass;
+
+namespace Novell.Directory.Ldap.Extensions
+{
+
+ /// <summary>
+ /// Removes a replica from the specified directory server.
+ ///
+ /// <p>To remove a replica from a particular server, you must create an instance
+ /// of this class and then call the extendedOperation method with this
+ /// object as the required LdapExtendedOperation parameter.</p>
+ ///
+ /// <p>The removeReplicaRequest extension uses the following OID:<br>
+ /// &nbsp;&nbsp;&nbsp;2.16.840.1.113719.1.27.100.11</p>
+ ///
+ /// <p>The requestValue has the following format:<br>
+ ///
+ /// requestValue ::=<br>
+ /// &nbsp;&nbsp;&nbsp;&nbsp; flags &nbsp;&nbsp;&nbsp; INTEGER<br>
+ /// &nbsp;&nbsp;&nbsp;&nbsp; serverName &nbsp;&nbsp;&nbsp; LdapDN<br>
+ /// &nbsp;&nbsp;&nbsp;&nbsp; dn &nbsp;&nbsp;&nbsp; LdapDN</p>
+ /// </summary>
+ public class RemoveReplicaRequest:LdapExtendedOperation
+ {
+
+ /// <summary> Constructs an extended operation object for removing a replica.
+ ///
+ /// </summary>
+ /// <param name="dn"> The distinguished name of the replica's
+ /// partition root.
+ /// <br><br>
+ /// </param>
+ /// <param name="serverDN"> The distinguished name of server from which the replica
+ /// will be removed.
+ /// <br><br>
+ /// </param>
+ /// <param name="flags"> Determines whether all servers in the replica ring must
+ /// be up before proceeding. When set to zero, the status of the
+ /// servers is not checked. When set to Ldap_ENSURE_SERVERS_UP,
+ /// all servers must be up for the operation to proceed.
+ ///
+ /// </param>
+ /// <exception cref=""> LdapException A general exception which includes an error message
+ /// and an Ldap error code.
+ /// </exception>
+ public RemoveReplicaRequest(System.String dn, System.String serverDN, int flags):base(ReplicationConstants.DELETE_REPLICA_REQ, null)
+ {
+
+ try
+ {
+
+ if (((System.Object) dn == null) || ((System.Object) serverDN == null))
+ throw new System.ArgumentException(ExceptionMessages.PARAM_ERROR);
+
+ System.IO.MemoryStream encodedData = new System.IO.MemoryStream();
+ LBEREncoder encoder = new LBEREncoder();
+
+ Asn1Integer asn1_flags = new Asn1Integer(flags);
+ Asn1OctetString asn1_serverDN = new Asn1OctetString(serverDN);
+ Asn1OctetString asn1_dn = new Asn1OctetString(dn);
+
+ asn1_flags.encode(encoder, encodedData);
+ asn1_serverDN.encode(encoder, encodedData);
+ asn1_dn.encode(encoder, encodedData);
+
+ setValue(SupportClass.ToSByteArray(encodedData.ToArray()));
+ }
+ catch (System.IO.IOException ioe)
+ {
+ throw new LdapException(ExceptionMessages.ENCODING_ERROR, LdapException.ENCODING_ERROR, (System.String) null);
+ }
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/ReplicationConstants.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/ReplicationConstants.cs
new file mode 100755
index 00000000000..72e06d9bb84
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/ReplicationConstants.cs
@@ -0,0 +1,369 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.Extensions.ReplicationConstants.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+
+namespace Novell.Directory.Ldap.Extensions
+{
+
+ /*
+ * public class ReplicationConstants
+ */
+
+ /// <summary> Contains a collection of constants used by the replication management
+ /// in Novell Ldap extensions.
+ /// </summary>
+ public class ReplicationConstants
+ {
+
+ /// <summary> A constant for the SplitPartitionRequest OID.</summary>
+ public const System.String CREATE_NAMING_CONTEXT_REQ = "2.16.840.1.113719.1.27.100.3";
+
+ /// <summary> A constant for the SplitPartitionResponse OID.</summary>
+ public const System.String CREATE_NAMING_CONTEXT_RES = "2.16.840.1.113719.1.27.100.4";
+
+ /// <summary> A constant for the mergePartitionRequest OID.</summary>
+ public const System.String MERGE_NAMING_CONTEXT_REQ = "2.16.840.1.113719.1.27.100.5";
+
+ /// <summary> A constant for the mergePartitionResponse OID.</summary>
+ public const System.String MERGE_NAMING_CONTEXT_RES = "2.16.840.1.113719.1.27.100.6";
+
+ /// <summary> A constant for the addReplicaRequest OID.</summary>
+ public const System.String ADD_REPLICA_REQ = "2.16.840.1.113719.1.27.100.7";
+
+ /// <summary> A constant for the addReplicaResponse OID.</summary>
+ public const System.String ADD_REPLICA_RES = "2.16.840.1.113719.1.27.100.8";
+
+ /// <summary> A constant for the refreshServerRequest OID.</summary>
+ public const System.String REFRESH_SERVER_REQ = "2.16.840.1.113719.1.27.100.9";
+
+ /// <summary> A constant for the refreshServerResponse OID.</summary>
+ public const System.String REFRESH_SERVER_RES = "2.16.840.1.113719.1.27.100.10";
+
+ /// <summary> A constant for the removeReplicaRequest OID.</summary>
+ public const System.String DELETE_REPLICA_REQ = "2.16.840.1.113719.1.27.100.11";
+
+ /// <summary> A constant for the removeReplicaResponse OID.</summary>
+ public const System.String DELETE_REPLICA_RES = "2.16.840.1.113719.1.27.100.12";
+
+ /// <summary> A constant for the partitionEntryCountRequest OID.</summary>
+ public const System.String NAMING_CONTEXT_COUNT_REQ = "2.16.840.1.113719.1.27.100.13";
+
+ /// <summary> A constant for the partitionEntryCountResponse OID.</summary>
+ public const System.String NAMING_CONTEXT_COUNT_RES = "2.16.840.1.113719.1.27.100.14";
+
+ /// <summary> A constant for the changeReplicaTypeRequest OID.</summary>
+ public const System.String CHANGE_REPLICA_TYPE_REQ = "2.16.840.1.113719.1.27.100.15";
+
+ /// <summary> A constant for the changeReplicaTypeResponse OID.</summary>
+ public const System.String CHANGE_REPLICA_TYPE_RES = "2.16.840.1.113719.1.27.100.16";
+
+ /// <summary> A constant for the getReplicaInfoRequest OID.</summary>
+ public const System.String GET_REPLICA_INFO_REQ = "2.16.840.1.113719.1.27.100.17";
+
+ /// <summary> A constant for the getReplicaInfoResponse OID.</summary>
+ public const System.String GET_REPLICA_INFO_RES = "2.16.840.1.113719.1.27.100.18";
+
+ /// <summary> A constant for the listReplicaRequest OID.</summary>
+ public const System.String LIST_REPLICAS_REQ = "2.16.840.1.113719.1.27.100.19";
+
+ /// <summary> A constant for the listReplicaResponse OID.</summary>
+ public const System.String LIST_REPLICAS_RES = "2.16.840.1.113719.1.27.100.20";
+
+ /// <summary> A constant for the receiveAllUpdatesRequest OID.</summary>
+ public const System.String RECEIVE_ALL_UPDATES_REQ = "2.16.840.1.113719.1.27.100.21";
+
+ /// <summary> A constant for the receiveAllUpdatesResponse OID.</summary>
+ public const System.String RECEIVE_ALL_UPDATES_RES = "2.16.840.1.113719.1.27.100.22";
+
+ /// <summary> A constant for the sendAllUpdatesRequest OID.</summary>
+ public const System.String SEND_ALL_UPDATES_REQ = "2.16.840.1.113719.1.27.100.23";
+
+ /// <summary> A constant for the sendAllUpdatesResponse OID.</summary>
+ public const System.String SEND_ALL_UPDATES_RES = "2.16.840.1.113719.1.27.100.24";
+
+ /// <summary> A constant for the requestPartitionSyncRequest OID.</summary>
+ public const System.String NAMING_CONTEXT_SYNC_REQ = "2.16.840.1.113719.1.27.100.25";
+
+ /// <summary> A constant for the requestPartitionSyncResponse OID.</summary>
+ public const System.String NAMING_CONTEXT_SYNC_RES = "2.16.840.1.113719.1.27.100.26";
+
+ /// <summary> A constant for the requestSchemaSyncRequest OID.</summary>
+ public const System.String SCHEMA_SYNC_REQ = "2.16.840.1.113719.1.27.100.27";
+
+ /// <summary> A constant for the requestSchemaSyncResponse OID.</summary>
+ public const System.String SCHEMA_SYNC_RES = "2.16.840.1.113719.1.27.100.28";
+
+ /// <summary> A constant for the abortPartitionOperationRequest OID.</summary>
+ public const System.String ABORT_NAMING_CONTEXT_OP_REQ = "2.16.840.1.113719.1.27.100.29";
+
+ /// <summary> A constant for the abortPartitionOperationResponse OID.</summary>
+ public const System.String ABORT_NAMING_CONTEXT_OP_RES = "2.16.840.1.113719.1.27.100.30";
+
+ /// <summary> A constant for the getContextIdentityNameRequest OID.</summary>
+ public const System.String GET_IDENTITY_NAME_REQ = "2.16.840.1.113719.1.27.100.31";
+
+ /// <summary> A constant for the getContextIdentityNameResponse OID.</summary>
+ public const System.String GET_IDENTITY_NAME_RES = "2.16.840.1.113719.1.27.100.32";
+
+ /// <summary> A constant for the getEffectivePrivilegesRequest OID.</summary>
+ public const System.String GET_EFFECTIVE_PRIVILEGES_REQ = "2.16.840.1.113719.1.27.100.33";
+
+ /// <summary> A constant for the getEffectivePrivilegesResponse OID.</summary>
+ public const System.String GET_EFFECTIVE_PRIVILEGES_RES = "2.16.840.1.113719.1.27.100.34";
+
+ /// <summary> A constant for the setReplicationFilterRequest OID.</summary>
+ public const System.String SET_REPLICATION_FILTER_REQ = "2.16.840.1.113719.1.27.100.35";
+
+ /// <summary> A constant for the setReplicationFilterResponse OID.</summary>
+ public const System.String SET_REPLICATION_FILTER_RES = "2.16.840.1.113719.1.27.100.36";
+
+ /// <summary> A constant for the getReplicationFilterRequest OID.</summary>
+ public const System.String GET_REPLICATION_FILTER_REQ = "2.16.840.1.113719.1.27.100.37";
+
+ /// <summary> A constant for the getReplicationFilterResponse OID.</summary>
+ public const System.String GET_REPLICATION_FILTER_RES = "2.16.840.1.113719.1.27.100.38";
+
+ /// <summary> A constant for the splitOrphanPartitionRequest OID.</summary>
+ public const System.String CREATE_ORPHAN_NAMING_CONTEXT_REQ = "2.16.840.1.113719.1.27.100.39";
+
+ /// <summary> A constant for the splitOrphanPartitionResponse OID.</summary>
+ public const System.String CREATE_ORPHAN_NAMING_CONTEXT_RES = "2.16.840.1.113719.1.27.100.40";
+
+ /// <summary> A constant for the removeOrphanPartitionRequest OID.</summary>
+ public const System.String REMOVE_ORPHAN_NAMING_CONTEXT_REQ = "2.16.840.1.113719.1.27.100.41";
+
+ /// <summary> A constant for the removeOrphanPartitionResponse OID.</summary>
+ public const System.String REMOVE_ORPHAN_NAMING_CONTEXT_RES = "2.16.840.1.113719.1.27.100.42";
+
+ /// <summary> A constant for the triggerBackLinkerRequest OID.</summary>
+ public const System.String TRIGGER_BKLINKER_REQ = "2.16.840.1.113719.1.27.100.43";
+
+ /// <summary> A constant for the triggerBackLinkerResponse OID.</summary>
+ public const System.String TRIGGER_BKLINKER_RES = "2.16.840.1.113719.1.27.100.44";
+
+ /// <summary> A constant for the triggerJanitorRequest OID.</summary>
+ public const System.String TRIGGER_JANITOR_REQ = "2.16.840.1.113719.1.27.100.47";
+
+ /// <summary> A constant for the triggerJanitorResponse OID.</summary>
+ public const System.String TRIGGER_JANITOR_RES = "2.16.840.1.113719.1.27.100.48";
+
+ /// <summary> A constant for the triggerLimberRequest OID.</summary>
+ public const System.String TRIGGER_LIMBER_REQ = "2.16.840.1.113719.1.27.100.49";
+
+ /// <summary> A constant for the triggerLimberResponse OID.</summary>
+ public const System.String TRIGGER_LIMBER_RES = "2.16.840.1.113719.1.27.100.50";
+
+ /// <summary> A constant for the triggerSkulkerRequest OID.</summary>
+ public const System.String TRIGGER_SKULKER_REQ = "2.16.840.1.113719.1.27.100.51";
+
+ /// <summary> A constant for the triggerSkulkerResponse OID.</summary>
+ public const System.String TRIGGER_SKULKER_RES = "2.16.840.1.113719.1.27.100.52";
+
+ /// <summary> A constant for the triggerSchemaSyncRequest OID.</summary>
+ public const System.String TRIGGER_SCHEMA_SYNC_REQ = "2.16.840.1.113719.1.27.100.53";
+
+ /// <summary> A constant for the triggerSchemaSyncResponse OID.</summary>
+ public const System.String TRIGGER_SCHEMA_SYNC_RES = "2.16.840.1.113719.1.27.100.54";
+
+ /// <summary> A constant for the triggerPartitionPurgeRequest OID.</summary>
+ public const System.String TRIGGER_PART_PURGE_REQ = "2.16.840.1.113719.1.27.100.55";
+
+ /// <summary> A constant for the triggerPartitionPurgeResponse OID.</summary>
+ public const System.String TRIGGER_PART_PURGE_RES = "2.16.840.1.113719.1.27.100.56";
+
+
+ /// <summary> A constant that specifies that all servers in a replica ring must be
+ /// running for a partition operation to proceed.
+ /// </summary>
+ public const int Ldap_ENSURE_SERVERS_UP = 1;
+
+
+ /// <summary> Identifies this replica as the master replica of the partition.
+ ///
+ /// <p>On this type of replica, entries can be modified, and partition
+ /// operations can be performed.</p>
+ /// </summary>
+ public const int Ldap_RT_MASTER = 0;
+
+ /// <summary> Identifies this replica as a secondary replica of the partition.
+ ///
+ /// <p>On this type of replica, read and write operations can be performed,
+ /// and entries can be modified.</p>
+ /// </summary>
+ public const int Ldap_RT_SECONDARY = 1;
+
+ /// <summary> Identifies this replica as a read-only replica of the partition.
+ ///
+ /// <p>Only Novell eDirectory synchronization processes can modified
+ /// entries on this replica.</p>
+ /// </summary>
+ public const int Ldap_RT_READONLY = 2;
+
+ /// <summary> Identifies this replica as a subordinate reference replica of the
+ /// partition.
+ ///
+ /// <p>NOvell eDirectory automatically adds these replicas to a server
+ /// when the server does not contain replicas of all child partitions.
+ /// Only eDirectory can modify information on these types of replicas.</p>
+ /// </summary>
+ public const int Ldap_RT_SUBREF = 3;
+
+ /// <summary> Identifies this replica as a read/write replica of the partition,
+ /// but the replica contains sparse data.
+ ///
+ /// <p>The replica has been configured to contain only specified object types
+ /// and attributes. On this type of replica, only the attributes and objects
+ /// contained in the sparse data can be modified.</p>
+ /// </summary>
+ public const int Ldap_RT_SPARSE_WRITE = 4;
+
+ /// <summary> Identifies this replica as a read-only replica of the partition,
+ /// but the replica contains sparse data.
+ ///
+ /// <p>The replica has been configured to contain only specified object types
+ /// and attributes. On this type of replica, only Novell eDirectory
+ /// synchronization processes can modify the sparse data.</p>
+ /// </summary>
+ public const int Ldap_RT_SPARSE_READ = 5;
+
+ //Replica States
+
+ /// <summary> Indicates that the replica is fully functioning and capable of responding
+ /// to requests.
+ /// </summary>
+ public const int Ldap_RS_ON = 0;
+
+ /// <summary> Indicates that a new replica has been added but has not received a full
+ /// download of information from the replica ring.
+ /// </summary>
+ public const int Ldap_RS_NEW_REPLICA = 1;
+
+ /// <summary> Indicates that the replica is being deleted and that the request has
+ /// been received.
+ /// </summary>
+ public const int Ldap_RS_DYING_REPLICA = 2;
+
+ /// <summary> Indicates that the replica is locked. The move operation uses this state
+ /// to lock the parent partition of the child partition that is moving.
+ /// </summary>
+ public const int Ldap_RS_LOCKED = 3;
+
+ /// <summary> Indicates that a new replica has finished receiving its download from the
+ /// master replica and is now receiving synchronization updates from other
+ /// replicas.
+ /// </summary>
+ public const int Ldap_RS_TRANSITION_ON = 6;
+
+
+ /// <summary> Indicates that the dying replica needs to synchronize with another replica
+ /// before being converted either to an external reference, if a root replica,
+ /// or to a subordinate reference, if a non-root replica.
+ /// </summary>
+ public const int Ldap_RS_DEAD_REPLICA = 7;
+
+ /// <summary> Indicates that the subordinate references of the new replica are being
+ /// added.
+ /// </summary>
+ public const int Ldap_RS_BEGIN_ADD = 8;
+
+ /// <summary> Indicates that a partition is receiving a new master replica.
+ ///
+ /// <p>The replica that will be the new master replica is set to this state.</p>
+ /// </summary>
+ public const int Ldap_RS_MASTER_START = 11;
+
+ /// <summary> Indicates that a partition has a new master replica.
+ ///
+ /// <p>When the new master is set to this state, Novell eDirectory knows
+ /// that the replica is now the master and changes its replica type to
+ /// master and the old master to read/write.</p>
+ /// </summary>
+ public const int Ldap_RS_MASTER_DONE = 12;
+
+ /// <summary> Indicates that the partition is going to split into two partitions.
+ ///
+ /// <p>In this state, other replicas of the partition are informed of the
+ /// pending split.</p>
+ /// </summary>
+ public const int Ldap_RS_SS_0 = 48; // Replica splitting 0
+
+ /// <summary> Indicates that that the split partition operation has started.
+ ///
+ /// <p>When the split is finished, the state will change to RS_ON.</p>
+ /// </summary>
+ public const int Ldap_RS_SS_1 = 49; // Replica splitting 1
+
+ /// <summary> Indicates that that two partitions are in the process of joining
+ /// into one partition.
+ ///
+ /// <p>In this state, the replicas that are affected are informed of the join
+ /// operation. The master replica of the parent and child partitions are
+ /// first set to this state and then all the replicas of the parent and child.
+ /// New replicas are added where needed.</p>
+ /// </summary>
+ public const int Ldap_RS_JS_0 = 64; // Replica joining 0
+
+ /// <summary> Indicates that that two partitions are in the process of joining
+ /// into one partition.
+ ///
+ /// <p>This state indicates that the join operation is waiting for the new
+ /// replicas to synchronize and move to the RS_ON state.</p>
+ /// </summary>
+ public const int Ldap_RS_JS_1 = 65; // Replica joining 1
+
+ /// <summary> Indicates that that two partitions are in the process of joining
+ /// into one partition.
+ ///
+ /// <p>This state indicates that all the new replicas are in the RS_ON state
+ /// and that the rest of the work can be completed.</p>
+ /// </summary>
+ public const int Ldap_RS_JS_2 = 66; // Replica joining 2
+
+
+ // Values for flags used in the replica info class structure
+
+ /// <summary> Indicates that the replica is involved with a partition operation,
+ /// for example, merging a tree or moving a subtree.
+ /// </summary>
+ public const int Ldap_DS_FLAG_BUSY = 0x0001;
+
+ /// <summary> Indicates that this partition is on the DNS federation boundary.
+ /// This flag is only set on DNS trees.
+ /// </summary>
+ public const int Ldap_DS_FLAG_BOUNDARY = 0x0002;
+
+
+ public ReplicationConstants()
+ {
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/SchemaSyncRequest.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/SchemaSyncRequest.cs
new file mode 100755
index 00000000000..9fd3156cc98
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/SchemaSyncRequest.cs
@@ -0,0 +1,95 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.Extensions.SchemaSyncRequest.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+using Novell.Directory.Ldap;
+using Novell.Directory.Ldap.Asn1;
+using Novell.Directory.Ldap.Utilclass;
+
+namespace Novell.Directory.Ldap.Extensions
+{
+
+ /// <summary>
+ /// Synchronizes the schema.
+ ///
+ /// <p>The requestSchemaSyncRequest extension uses the following OID: <br>
+ /// &nbsp;&nbsp;&nbsp;2.16.840.1.113719.1.27.100.27</p>
+ ///
+ /// <p>The requestValue has the following format:<br>
+ ///
+ /// requestValue ::=<br>
+ /// &nbsp;&nbsp;&nbsp;&nbsp; serverName &nbsp;&nbsp;&nbsp; LdapDN<br>
+ /// &nbsp;&nbsp;&nbsp;&nbsp; delay &nbsp;&nbsp;&nbsp; INTEGER</p>
+ /// </summary>
+ public class SchemaSyncRequest:LdapExtendedOperation
+ {
+
+ /// <summary> Constructs an extended operation object for synchronizing the schema.
+ ///
+ /// </summary>
+ /// <param name="serverName"> The distinguished name of the server which will start
+ /// the synchronization.
+ /// <br><br>
+ /// </param>
+ /// <param name="delay"> The time, in seconds, to delay before the synchronization
+ /// should start.
+ ///
+ /// </param>
+ /// <exception cref=""> LdapException A general exception which includes an error message
+ /// and an Ldap error code.
+ /// </exception>
+ public SchemaSyncRequest(System.String serverName, int delay):base(ReplicationConstants.SCHEMA_SYNC_REQ, null)
+ {
+
+ try
+ {
+
+ if ((System.Object) serverName == null)
+ throw new System.ArgumentException(ExceptionMessages.PARAM_ERROR);
+
+ System.IO.MemoryStream encodedData = new System.IO.MemoryStream();
+ LBEREncoder encoder = new LBEREncoder();
+
+ Asn1OctetString asn1_serverName = new Asn1OctetString(serverName);
+ Asn1Integer asn1_delay = new Asn1Integer(delay);
+
+ asn1_serverName.encode(encoder, encodedData);
+ asn1_delay.encode(encoder, encodedData);
+
+ setValue(SupportClass.ToSByteArray(encodedData.ToArray()));
+ }
+ catch (System.IO.IOException ioe)
+ {
+ throw new LdapException(ExceptionMessages.ENCODING_ERROR, LdapException.ENCODING_ERROR, (System.String) null);
+ }
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/SendAllUpdatesRequest.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/SendAllUpdatesRequest.cs
new file mode 100755
index 00000000000..50895564cf3
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/SendAllUpdatesRequest.cs
@@ -0,0 +1,96 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.Extensions.SendAllUpdatesRequest.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+using Novell.Directory.Ldap;
+using Novell.Directory.Ldap.Asn1;
+using Novell.Directory.Ldap.Utilclass;
+
+namespace Novell.Directory.Ldap.Extensions
+{
+
+ /// <summary>
+ /// Schedules an updated request to be sent to all directory servers in a
+ /// replica ring.
+ ///
+ /// <p>The sendAllUpdatesRequest extension uses the following OID:<br>
+ /// &nbsp;&nbsp;&nbsp;2.16.840.1.113719.1.27.100.23</p>
+ ///
+ /// <p>The requestValue has the following format:<br>
+ ///
+ /// requestValue ::=<br>
+ /// &nbsp;&nbsp;&nbsp;&nbsp; partitionRoot&nbsp;&nbsp;&nbsp; LdapDN<br>
+ /// &nbsp;&nbsp;&nbsp;&nbsp; origServerDN&nbsp;&nbsp;&nbsp; LdapDN</p>
+ /// </summary>
+ public class SendAllUpdatesRequest:LdapExtendedOperation
+ {
+
+ /// <summary>
+ /// Constructs an extended operation object for sending updates to a replica ring.
+ ///
+ /// </summary>
+ /// <param name="partitionRoot">The distinguished name of the replica
+ /// that will be updated.
+ /// <br><br>
+ /// </param>
+ /// <param name="origServerDN"> The distinguished name of the server that sends the
+ /// updates to the replica ring.
+ ///
+ /// </param>
+ /// <exception cref=""> LdapException A general exception which includes an error message
+ /// and an Ldap error code.
+ /// </exception>
+ public SendAllUpdatesRequest(System.String partitionRoot, System.String origServerDN):base(ReplicationConstants.SEND_ALL_UPDATES_REQ, null)
+ {
+
+ try
+ {
+
+ if (((System.Object) partitionRoot == null) || ((System.Object) origServerDN == null))
+ throw new System.ArgumentException(ExceptionMessages.PARAM_ERROR);
+ System.IO.MemoryStream encodedData = new System.IO.MemoryStream();
+ LBEREncoder encoder = new LBEREncoder();
+
+ Asn1OctetString asn1_partitionRoot = new Asn1OctetString(partitionRoot);
+ Asn1OctetString asn1_origServerDN = new Asn1OctetString(origServerDN);
+
+ asn1_partitionRoot.encode(encoder, encodedData);
+ asn1_origServerDN.encode(encoder, encodedData);
+
+ setValue(SupportClass.ToSByteArray(encodedData.ToArray()));
+ }
+ catch (System.IO.IOException ioe)
+ {
+ throw new LdapException(ExceptionMessages.ENCODING_ERROR, LdapException.ENCODING_ERROR, (System.String) null);
+ }
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/SetReplicationFilterRequest.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/SetReplicationFilterRequest.cs
new file mode 100755
index 00000000000..4a86595eadf
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/SetReplicationFilterRequest.cs
@@ -0,0 +1,155 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.Extensions.SetReplicationFilterRequest.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+using Novell.Directory.Ldap;
+using Novell.Directory.Ldap.Asn1;
+using Novell.Directory.Ldap.Utilclass;
+
+namespace Novell.Directory.Ldap.Extensions
+{
+
+ /// <summary>
+ /// Sets the Replication filter for all replicas on the server.
+ ///
+ /// <p>The filter specified is a an array of classnames-attribute names pairs. </p>
+ ///
+ /// <p>To set the filter for all replicas on the connected server, you must
+ /// create an instance of this class and then call the
+ /// extendedOperation method with this object as the required
+ /// LdapExtendedOperation parameter.</p>
+ ///
+ /// <p>The SetReplicationFilterRequest extension uses the following OID:<br>
+ /// &nbsp;&nbsp;&nbsp;2.16.840.1.113719.1.27.100.35</p>
+ ///
+ /// <p>The requestValue has the following format:<br>
+ ///
+ /// requestValue ::=<br>
+ /// &nbsp;&nbsp;&nbsp;&nbsp; serverName&nbsp;&nbsp;&nbsp; LdapDN</p>
+ /// &nbsp;&nbsp;&nbsp;&nbsp; SEQUENCE of SEQUENCE {</p>
+ /// &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; classname&nbsp;&nbsp;&nbsp; OCTET STRING</p>
+ /// &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SEQUENCE of ATTRIBUTES</p>
+ /// &nbsp;&nbsp;&nbsp;&nbsp;}</p>
+ /// &nbsp;&nbsp;&nbsp;&nbsp;where</p>
+ /// &nbsp;&nbsp;&nbsp;&nbsp;ATTRIBUTES:: OCTET STRING</p>
+ /// </summary>
+ public class SetReplicationFilterRequest:LdapExtendedOperation
+ {
+
+ /// <summary>
+ /// Constructs an extended operations object which contains the ber encoded
+ /// replication filter.
+ ///
+ /// </summary>
+ /// <param name="serverDN">The server on which the replication filter needs to be set
+ /// <br><br>
+ /// </param>
+ /// <param name="replicationFilter">An array of String Arrays. Each array starting with
+ /// a class name followed by the attribute names for that class that should comprise
+ /// the replication filter.
+ /// <br><br>
+ /// </param>
+ /// <exception cref=""> LdapException A general exception which includes an error
+ /// message and an Ldap error code.
+ /// </exception>
+ public SetReplicationFilterRequest(System.String serverDN, System.String[][] replicationFilter):base(ReplicationConstants.SET_REPLICATION_FILTER_REQ, null)
+ {
+
+ try
+ {
+
+ if ((System.Object) serverDN == null)
+ throw new System.ArgumentException(ExceptionMessages.PARAM_ERROR);
+
+ System.IO.MemoryStream encodedData = new System.IO.MemoryStream();
+ LBEREncoder encoder = new LBEREncoder();
+
+ Asn1OctetString asn1_serverDN = new Asn1OctetString(serverDN);
+
+ // Add the serverDN to encoded data
+ asn1_serverDN.encode(encoder, encodedData);
+
+ // The toplevel sequenceOF
+ Asn1SequenceOf asn1_replicationFilter = new Asn1SequenceOf();
+
+ if (replicationFilter == null)
+ {
+ asn1_replicationFilter.encode(encoder, encodedData);
+ setValue(SupportClass.ToSByteArray(encodedData.ToArray()));
+ return ;
+ }
+
+ int i = 0;
+ // for every element in the array
+ while ((i < replicationFilter.Length) && (replicationFilter[i] != null))
+ {
+
+
+ // The following additional Sequence is not needed
+ // as defined by the Asn1. But the server and the
+ // C client are encoding it. Remove this when server
+ // and C client are fixed to conform to the published Asn1.
+ Asn1Sequence buginAsn1Representation = new Asn1Sequence();
+
+ // Add the classname to the sequence -
+ buginAsn1Representation.add(new Asn1OctetString(replicationFilter[i][0]));
+
+ // Start a sequenceOF for attributes
+ Asn1SequenceOf asn1_attributeList = new Asn1SequenceOf();
+
+ // For every attribute in the array - remember attributes start after
+ // the first element
+ int j = 1;
+ while ((j < replicationFilter[i].Length) && ((System.Object) replicationFilter[i][j] != null))
+ {
+
+ // Add the attribute name to the inner SequenceOf
+ asn1_attributeList.add(new Asn1OctetString(replicationFilter[i][j]));
+ j++;
+ }
+
+
+ // Add the attributeList to the sequence - extra add due to bug
+ buginAsn1Representation.add(asn1_attributeList);
+ asn1_replicationFilter.add(buginAsn1Representation);
+ i++;
+ }
+
+ asn1_replicationFilter.encode(encoder, encodedData);
+ setValue(SupportClass.ToSByteArray(encodedData.ToArray()));
+ }
+ catch (System.IO.IOException ioe)
+ {
+ throw new LdapException(ExceptionMessages.ENCODING_ERROR, LdapException.ENCODING_ERROR, (System.String) null);
+ }
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/SplitOrphanPartitionRequest.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/SplitOrphanPartitionRequest.cs
new file mode 100755
index 00000000000..74c83722e01
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/SplitOrphanPartitionRequest.cs
@@ -0,0 +1,100 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.Extensions.SplitOrphanPartitionRequest.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+using Novell.Directory.Ldap;
+using Novell.Directory.Ldap.Asn1;
+using Novell.Directory.Ldap.Utilclass;
+
+namespace Novell.Directory.Ldap.Extensions
+{
+
+ /// <summary> Splits a new orphan partitiont.
+ ///
+ /// <p>To split a new orphan partition, you must create an instance of
+ /// this class and then call the extendedOperation method with this object
+ /// as the required LdapExtendedOperation parameter.</p>
+ ///
+ /// <p>The SplitOrphanPartitionRequest extension uses the following OID:<br>
+ /// &nbsp;&nbsp;&nbsp;2.16.840.1.113719.1.27.100.39</p>
+ ///
+ /// <p>The requestValue has the following format:<br>
+ ///
+ /// requestValue ::=<br>
+ /// &nbsp;&nbsp;&nbsp;&nbsp; serverDN&nbsp;&nbsp;&nbsp;&nbsp; LdapDN<br>
+ /// &nbsp;&nbsp;&nbsp;&nbsp; contextName&nbsp;&nbsp;&nbsp;&nbsp; LdapDN</p>
+ /// </summary>
+ public class SplitOrphanPartitionRequest:LdapExtendedOperation
+ {
+
+ /// <summary>
+ /// Constructs an extended operation object for creating an orphan partition.
+ ///
+ ///
+ /// </summary>
+ /// <param name="serverDN"> The distinguished name of the server on which
+ /// the new orphan partition will reside.
+ /// <br><br>
+ /// </param>
+ /// <param name="contextName">The distinguished name of the
+ /// new orphan partition.
+ ///
+ /// </param>
+ /// <exception cref=""> LdapException A general exception which includes an error message
+ /// and an Ldap error code.
+ /// </exception>
+ public SplitOrphanPartitionRequest(System.String serverDN, System.String contextName):base(ReplicationConstants.CREATE_ORPHAN_NAMING_CONTEXT_REQ, null)
+ {
+
+ try
+ {
+
+ if (((System.Object) serverDN == null) || ((System.Object) contextName == null))
+ throw new System.ArgumentException(ExceptionMessages.PARAM_ERROR);
+
+ System.IO.MemoryStream encodedData = new System.IO.MemoryStream();
+ LBEREncoder encoder = new LBEREncoder();
+
+ Asn1OctetString asn1_serverDN = new Asn1OctetString(serverDN);
+ Asn1OctetString asn1_contextName = new Asn1OctetString(contextName);
+
+ asn1_serverDN.encode(encoder, encodedData);
+ asn1_contextName.encode(encoder, encodedData);
+
+ setValue(SupportClass.ToSByteArray(encodedData.ToArray()));
+ }
+ catch (System.IO.IOException ioe)
+ {
+ throw new LdapException(ExceptionMessages.ENCODING_ERROR, LdapException.ENCODING_ERROR, (System.String) null);
+ }
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/SplitPartitionRequest.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/SplitPartitionRequest.cs
new file mode 100755
index 00000000000..bce66be71ad
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/SplitPartitionRequest.cs
@@ -0,0 +1,101 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.Extensions.SplitPartitionRequest.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+using Novell.Directory.Ldap;
+using Novell.Directory.Ldap.Asn1;
+using Novell.Directory.Ldap.Utilclass;
+
+namespace Novell.Directory.Ldap.Extensions
+{
+
+ /// <summary> Creates a new partition.
+ ///
+ /// <p>To split a new partition, you must create an instance of this
+ /// class and then call the extendedOperation method with this
+ /// object as the required LdapExtendedOperation parameter.</p>
+ ///
+ /// <p>The SplitPartitionRequest extension uses the following OID:<br>
+ /// &nbsp;&nbsp;&nbsp;2.16.840.1.113719.1.27.100.3</p>
+ ///
+ /// <p>The requestValue has the following format:<br>
+ ///
+ /// requestValue ::=<br>
+ /// &nbsp;&nbsp;&nbsp;&nbsp; flags &nbsp;&nbsp;&nbsp;&nbsp; INTEGER<br>
+ /// &nbsp;&nbsp;&nbsp;&nbsp; dn &nbsp;&nbsp;&nbsp;&nbsp; LdapDN</p>
+ /// </summary>
+ public class SplitPartitionRequest:LdapExtendedOperation
+ {
+
+ /// <summary>
+ /// Constructs an extended operation object for splitting partition.
+ ///
+ /// </summary>
+ /// <param name="dn"> The distinguished name of the container where the new
+ /// partition root should be located.
+ /// <br><br>
+ /// </param>
+ /// <param name="flags">Specifies whether all servers in the replica ring must be up before
+ /// proceeding. When set to zero, the status of the servers is not
+ /// checked. When set to Ldap_ENSURE_SERVERS_UP, all servers must be up
+ /// for the operation to proceed.
+ ///
+ /// </param>
+ /// <exception cref=""> LdapException A general exception which includes an error message
+ /// and an Ldap error code.
+ /// </exception>
+ public SplitPartitionRequest(System.String dn, int flags):base(ReplicationConstants.CREATE_NAMING_CONTEXT_REQ, null)
+ {
+
+ try
+ {
+
+ if ((System.Object) dn == null)
+ throw new System.ArgumentException(ExceptionMessages.PARAM_ERROR);
+
+ System.IO.MemoryStream encodedData = new System.IO.MemoryStream();
+ LBEREncoder encoder = new LBEREncoder();
+
+ Asn1Integer asn1_flags = new Asn1Integer(flags);
+ Asn1OctetString asn1_dn = new Asn1OctetString(dn);
+
+ asn1_flags.encode(encoder, encodedData);
+ asn1_dn.encode(encoder, encodedData);
+
+ setValue(SupportClass.ToSByteArray(encodedData.ToArray()));
+ }
+ catch (System.IO.IOException ioe)
+ {
+ throw new LdapException(ExceptionMessages.ENCODING_ERROR, LdapException.ENCODING_ERROR, (System.String) null);
+ }
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/TriggerBackgroundProcessRequest.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/TriggerBackgroundProcessRequest.cs
new file mode 100755
index 00000000000..6e594efcc8d
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/TriggerBackgroundProcessRequest.cs
@@ -0,0 +1,120 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.Extensions.TriggerBackgroundProcessRequest.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+using Novell.Directory.Ldap;
+using Novell.Directory.Ldap.Asn1;
+using Novell.Directory.Ldap.Utilclass;
+
+namespace Novell.Directory.Ldap.Extensions
+{
+
+ /// <summary> This API is used to trigger the specified background process on the
+ /// Novell eDirectory server.
+ ///
+ /// <p>The TriggerBackgroundProcessRequest uses tone of the following OID's
+ /// depending on the process being triggered:<br>
+ /// &nbsp;&nbsp;&nbsp;2.16.840.1.113719.1.27.100.43</p>
+ /// &nbsp;&nbsp;&nbsp;2.16.840.1.113719.1.27.100.47</p>
+ /// &nbsp;&nbsp;&nbsp;2.16.840.1.113719.1.27.100.49</p>
+ /// &nbsp;&nbsp;&nbsp;2.16.840.1.113719.1.27.100.51</p>
+ /// &nbsp;&nbsp;&nbsp;2.16.840.1.113719.1.27.100.53</p>
+ /// &nbsp;&nbsp;&nbsp;2.16.840.1.113719.1.27.100.55</p>
+ ///
+ /// <p>The requestValue has the following format:<br>
+ ///
+ /// requestValue ::=<br>
+ /// &nbsp;&nbsp;&nbsp;&nbsp; NULL
+ /// </p>
+ /// </summary>
+
+ public class TriggerBackgroundProcessRequest:LdapExtendedOperation
+ {
+
+ /// <summary> Constants used to refer to different Novell eDirectory
+ /// background processes
+ /// </summary>
+ public const int Ldap_BK_PROCESS_BKLINKER = 1;
+ public const int Ldap_BK_PROCESS_JANITOR = 2;
+ public const int Ldap_BK_PROCESS_LIMBER = 3;
+ public const int Ldap_BK_PROCESS_SKULKER = 4;
+ public const int Ldap_BK_PROCESS_SCHEMA_SYNC = 5;
+ public const int Ldap_BK_PROCESS_PART_PURGE = 6;
+
+ /// <summary>
+ /// Based on the process ID specified this constructer cosntructs an
+ /// LdapExtendedOperation object with the apppropriate OID.
+ ///
+ /// </summary>
+ /// <param name="processID"> This id identifies the background process to be triggerd.
+ ///
+ /// </param>
+ /// <exception cref=""> LdapException A general exception which includes an error message
+ /// and an Ldap error code.
+ /// </exception>
+ public TriggerBackgroundProcessRequest(int processID):base(null, null)
+ {
+
+ switch (processID)
+ {
+
+
+ case Ldap_BK_PROCESS_BKLINKER:
+ setID(ReplicationConstants.TRIGGER_BKLINKER_REQ);
+ break;
+
+ case Ldap_BK_PROCESS_JANITOR:
+ setID(ReplicationConstants.TRIGGER_JANITOR_REQ);
+ break;
+
+ case Ldap_BK_PROCESS_LIMBER:
+ setID(ReplicationConstants.TRIGGER_LIMBER_REQ);
+ break;
+
+ case Ldap_BK_PROCESS_SKULKER:
+ setID(ReplicationConstants.TRIGGER_SKULKER_REQ);
+ break;
+
+ case Ldap_BK_PROCESS_SCHEMA_SYNC:
+ setID(ReplicationConstants.TRIGGER_SCHEMA_SYNC_REQ);
+ break;
+
+ case Ldap_BK_PROCESS_PART_PURGE:
+ setID(ReplicationConstants.TRIGGER_PART_PURGE_REQ);
+ break;
+
+ default:
+ throw new System.ArgumentException(ExceptionMessages.PARAM_ERROR);
+
+ }
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcAbandonRequest.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcAbandonRequest.cs
new file mode 100755
index 00000000000..ad5ddb06e24
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcAbandonRequest.cs
@@ -0,0 +1,82 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.Rfc2251.RfcAbandonRequest.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+using Novell.Directory.Ldap.Asn1;
+using Novell.Directory.Ldap;
+using Novell.Directory.Ldap.Utilclass;
+
+namespace Novell.Directory.Ldap.Rfc2251
+{
+
+ /// <summary> Represents the Ldap Abandon Request.
+ ///
+ /// <pre>
+ /// AbandonRequest ::= [APPLICATION 16] MessageID
+ /// </pre>
+ /// </summary>
+ class RfcAbandonRequest:RfcMessageID, RfcRequest
+ {
+
+ //*************************************************************************
+ // Constructor for AbandonRequest
+ //*************************************************************************
+
+ /// <summary> Constructs an RfcAbandonRequest</summary>
+ public RfcAbandonRequest(int msgId):base(msgId)
+ {
+ return ;
+ }
+
+ //*************************************************************************
+ // Accessors
+ //*************************************************************************
+
+ /// <summary> Override getIdentifier to return an application-wide id.
+ /// <pre>
+ /// ID = CLASS: APPLICATION, FORM: CONSTRUCTED, TAG: 16. (0x50)
+ /// </pre>
+ /// </summary>
+ public override Asn1Identifier getIdentifier()
+ {
+ return new Asn1Identifier(Asn1Identifier.APPLICATION, false, LdapMessage.ABANDON_REQUEST);
+ }
+
+ public RfcRequest dupRequest(System.String base_Renamed, System.String filter, bool reference)
+ {
+ throw new LdapException(ExceptionMessages.NO_DUP_REQUEST, new System.Object[]{"Abandon"}, LdapException.Ldap_NOT_SUPPORTED, (System.String) null);
+ }
+ public System.String getRequestDN()
+ {
+ return null;
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcAddRequest.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcAddRequest.cs
new file mode 100755
index 00000000000..d59be903fe1
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcAddRequest.cs
@@ -0,0 +1,119 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.Rfc2251.RfcAddRequest.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+using Novell.Directory.Ldap.Asn1;
+using Novell.Directory.Ldap;
+
+namespace Novell.Directory.Ldap.Rfc2251
+{
+
+ /// <summary> Represents the Ldap Add Request.
+ ///
+ /// <pre>
+ /// AddRequest ::= [APPLICATION 8] SEQUENCE {
+ /// entry LdapDN,
+ /// attributes AttributeList }
+ /// </pre>
+ /// </summary>
+ public class RfcAddRequest:Asn1Sequence, RfcRequest
+ {
+ /// <summary> Gets the attributes of the entry</summary>
+ virtual public RfcAttributeList Attributes
+ {
+ get
+ {
+ return (RfcAttributeList) get_Renamed(1);
+ }
+
+ }
+
+ //*************************************************************************
+ // Constructors for AddRequest
+ //*************************************************************************
+
+ /// <summary> Constructs an RFCAddRequest
+ ///
+ /// </summary>
+ /// <param name="entry">the entry
+ ///
+ /// </param>
+ /// <param name="attributes">the Attributes making up the Entry
+ /// </param>
+ public RfcAddRequest(RfcLdapDN entry, RfcAttributeList attributes):base(2)
+ {
+ add(entry);
+ add(attributes);
+ return ;
+ }
+
+ /// <summary> Constructs a new Add Request using data from an existing request.
+ ///
+ /// </summary>
+ /// <param name="origRequest">the original request data
+ ///
+ /// </param>
+ /// <param name="base">if not null, replaces the dn of the original request
+ /// </param>
+ /* package */
+ internal RfcAddRequest(Asn1Object[] origRequest, System.String base_Renamed):base(origRequest, origRequest.Length)
+ {
+ // Replace the base if specified, otherwise keep original base
+ if ((System.Object) base_Renamed != null)
+ {
+ set_Renamed(0, new RfcLdapDN(base_Renamed));
+ }
+ return ;
+ }
+ //*************************************************************************
+ // Accessors
+ //*************************************************************************
+
+ /// <summary> Override getIdentifier to return an application-wide id.
+ /// <pre>
+ /// ID = CLASS: APPLICATION, FORM: CONSTRUCTED, TAG: 8. (0x68)
+ /// </pre>
+ /// </summary>
+ public override Asn1Identifier getIdentifier()
+ {
+ return new Asn1Identifier(Asn1Identifier.APPLICATION, true, LdapMessage.ADD_REQUEST);
+ }
+
+ public RfcRequest dupRequest(System.String base_Renamed, System.String filter, bool request)
+ {
+ return new RfcAddRequest(toArray(), base_Renamed);
+ }
+ public System.String getRequestDN()
+ {
+ return ((RfcLdapDN) get_Renamed(0)).stringValue();
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcAddResponse.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcAddResponse.cs
new file mode 100755
index 00000000000..dd181aa57f9
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcAddResponse.cs
@@ -0,0 +1,89 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.Rfc2251.RfcAddResponse.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+using Novell.Directory.Ldap;
+using Novell.Directory.Ldap.Asn1;
+
+namespace Novell.Directory.Ldap.Rfc2251
+{
+
+ /// <summary> Represents the Ldap Add Response.
+ ///
+ /// <pre>
+ /// AddResponse ::= [APPLICATION 9] LdapResult
+ /// </pre>
+ /// </summary>
+ public class RfcAddResponse:RfcLdapResult
+ {
+
+ //*************************************************************************
+ // Constructors for AddResponse
+ //*************************************************************************
+
+ /// <summary> The only time a client will create a AddResponse is when it is
+ /// decoding it from an InputStream
+ /// </summary>
+ [CLSCompliantAttribute(false)]
+ public RfcAddResponse(Asn1Decoder dec, System.IO.Stream in_Renamed, int len):base(dec, in_Renamed, len)
+ {
+ }
+
+ /// <summary> Constructs an RfcAddResponse from parameters.
+ ///
+ /// </summary>
+ /// <param name="resultCode">the result code of the operation
+ ///
+ /// </param>
+ /// <param name="matchedDN">the matched DN returned from the server
+ ///
+ /// </param>
+ /// <param name="errorMessage">the diagnostic message returned from the server
+ ///
+ /// </param>
+ /// <param name="referral">the referral(s) returned by the server
+ /// </param>
+ public RfcAddResponse(Asn1Enumerated resultCode, RfcLdapDN matchedDN, RfcLdapString errorMessage, RfcReferral referral):base(resultCode, matchedDN, errorMessage, referral)
+ {
+ return ;
+ }
+
+ //*************************************************************************
+ // Accessors
+ //*************************************************************************
+
+ /// <summary> Override getIdentifier to return an application-wide id.</summary>
+ public override Asn1Identifier getIdentifier()
+ {
+ return new Asn1Identifier(Asn1Identifier.APPLICATION, true, LdapMessage.ADD_RESPONSE);
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcAssertionValue.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcAssertionValue.cs
new file mode 100755
index 00000000000..6fb142c3e12
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcAssertionValue.cs
@@ -0,0 +1,54 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.Rfc2251.RfcAssertionValue.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+
+using System;
+using Novell.Directory.Ldap.Asn1;
+
+namespace Novell.Directory.Ldap.Rfc2251
+{
+
+ /// <summary> Represents the Ldap Assertion Value.
+ ///
+ /// <pre>
+ /// AssertionValue ::= OCTET STRING
+ /// </pre>
+ /// </summary>
+ public class RfcAssertionValue:Asn1OctetString
+ {
+
+ /// <summary> </summary>
+ [CLSCompliantAttribute(false)]
+ public RfcAssertionValue(sbyte[] value_Renamed):base(value_Renamed)
+ {
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcAttributeDescription.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcAttributeDescription.cs
new file mode 100755
index 00000000000..974c7874e32
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcAttributeDescription.cs
@@ -0,0 +1,55 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.Rfc2251.RfcAttributeDescription.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+using Novell.Directory.Ldap.Asn1;
+
+namespace Novell.Directory.Ldap.Rfc2251
+{
+
+ /*
+ * Represents the Ldap Attribute Description.
+ */
+ public class RfcAttributeDescription:RfcLdapString
+ {
+
+ /// <summary> </summary>
+ public RfcAttributeDescription(System.String s):base(s)
+ {
+ }
+
+ /// <summary> </summary>
+ [CLSCompliantAttribute(false)]
+ public RfcAttributeDescription(Asn1Decoder dec, System.IO.Stream in_Renamed, int len):base(dec, in_Renamed, len)
+ {
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcAttributeDescriptionList.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcAttributeDescriptionList.cs
new file mode 100755
index 00000000000..31bd72bef1d
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcAttributeDescriptionList.cs
@@ -0,0 +1,84 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.Rfc2251.RfcAttributeDescriptionList.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+using Novell.Directory.Ldap.Asn1;
+
+namespace Novell.Directory.Ldap.Rfc2251
+{
+
+ /// <summary><pre>
+ /// The AttributeDescriptionList is used to list attributes to be returned in
+ /// a search request.
+ ///
+ /// <pre>
+ /// AttributeDescriptionList ::= SEQUENCE OF
+ /// AttributeDescription
+ /// </pre>
+ ///
+ /// </summary>
+ /// <seealso cref="RfcAttributeDescription">
+ /// </seealso>
+ /// <seealso cref="Asn1SequenceOf">
+ /// </seealso>
+ /// <seealso cref="RfcSearchRequest">
+ /// </seealso>
+ public class RfcAttributeDescriptionList:Asn1SequenceOf
+ {
+ /// <summary> </summary>
+ public RfcAttributeDescriptionList(int size):base(size)
+ {
+ return ;
+ }
+
+ /// <summary> Convenience constructor. This constructor will construct an
+ /// AttributeDescriptionList using the supplied array of Strings.
+ /// </summary>
+ public RfcAttributeDescriptionList(System.String[] attrs):base(attrs == null?0:attrs.Length)
+ {
+
+ if (attrs != null)
+ {
+ for (int i = 0; i < attrs.Length; i++)
+ {
+ add(new RfcAttributeDescription(attrs[i]));
+ }
+ }
+ return ;
+ }
+
+ /*
+ * Override add() to only accept types of AttributeDescription
+ *
+ * @exception Asn1InvalidTypeException
+ */
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcAttributeList.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcAttributeList.cs
new file mode 100755
index 00000000000..218974d7345
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcAttributeList.cs
@@ -0,0 +1,57 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.Rfc2251.RfcAttributeList.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+using Novell.Directory.Ldap.Asn1;
+
+namespace Novell.Directory.Ldap.Rfc2251
+{
+
+ /// <summary> Represents an Ldap Attribute List.
+ ///
+ /// <pre>
+ /// AttributeList ::= SEQUENCE OF SEQUENCE {
+ /// type AttributeDescription,
+ /// vals SET OF AttributeValue }
+ /// </pre>
+ /// </summary>
+ public class RfcAttributeList:Asn1SequenceOf
+ {
+
+ //*************************************************************************
+ // Constructor for AttributeList
+ //*************************************************************************
+ public RfcAttributeList(int size):base(size)
+ {
+ return ;
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcAttributeTypeAndValues.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcAttributeTypeAndValues.cs
new file mode 100755
index 00000000000..ee2a94223d7
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcAttributeTypeAndValues.cs
@@ -0,0 +1,61 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.Rfc2251.RfcAttributeTypeAndValues.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+using Novell.Directory.Ldap.Asn1;
+
+namespace Novell.Directory.Ldap.Rfc2251
+{
+
+ /// <summary> Represents and Ldap Attribute Type and Values.
+ ///
+ /// <pre>
+ /// AttributeTypeAndValues ::= SEQUENCE {
+ /// type AttributeDescription,
+ /// vals SET OF AttributeValue }
+ /// </pre>
+ /// </summary>
+ public class RfcAttributeTypeAndValues:Asn1Sequence
+ {
+
+ //*************************************************************************
+ // Constructor for AttributeTypeAndValues
+ //*************************************************************************
+
+ /// <summary> </summary>
+ public RfcAttributeTypeAndValues(RfcAttributeDescription type, Asn1SetOf vals):base(2)
+ {
+ add(type);
+ add(vals);
+ return ;
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcAttributeValue.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcAttributeValue.cs
new file mode 100755
index 00000000000..d3a4101e562
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcAttributeValue.cs
@@ -0,0 +1,55 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.Rfc2251.RfcAttributeValue.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+using Novell.Directory.Ldap.Asn1;
+
+namespace Novell.Directory.Ldap.Rfc2251
+{
+
+ /*
+ * Represents an Ldap Attribute Value.
+ */
+ public class RfcAttributeValue:Asn1OctetString
+ {
+
+ /// <summary> </summary>
+ public RfcAttributeValue(System.String value_Renamed):base(value_Renamed)
+ {
+ }
+
+ /// <summary> </summary>
+ [CLSCompliantAttribute(false)]
+ public RfcAttributeValue(sbyte[] value_Renamed):base(value_Renamed)
+ {
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcAttributeValueAssertion.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcAttributeValueAssertion.cs
new file mode 100755
index 00000000000..dccffd2fb80
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcAttributeValueAssertion.cs
@@ -0,0 +1,90 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.Rfc2251.RfcAttributeValueAssertion.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+using Novell.Directory.Ldap.Asn1;
+
+namespace Novell.Directory.Ldap.Rfc2251
+{
+
+ /// <summary> Represents an Ldap Attribute Value Assertion.
+ ///
+ /// <pre>
+ /// AttributeValueAssertion ::= SEQUENCE {
+ /// attributeDesc AttributeDescription,
+ /// assertionValue AssertionValue }
+ /// </pre>
+ /// </summary>
+ public class RfcAttributeValueAssertion:Asn1Sequence
+ {
+ /// <summary> Returns the attribute description.
+ ///
+ /// </summary>
+ /// <returns> the attribute description
+ /// </returns>
+ virtual public System.String AttributeDescription
+ {
+ get
+ {
+ return ((RfcAttributeDescription) get_Renamed(0)).stringValue();
+ }
+
+ }
+ /// <summary> Returns the assertion value.
+ ///
+ /// </summary>
+ /// <returns> the assertion value.
+ /// </returns>
+ [CLSCompliantAttribute(false)]
+ virtual public sbyte[] AssertionValue
+ {
+ get
+ {
+ return ((RfcAssertionValue) get_Renamed(1)).byteValue();
+ }
+
+ }
+
+ /// <summary> Creates an Attribute Value Assertion.
+ ///
+ /// </summary>
+ /// <param name="ad">The assertion description
+ ///
+ /// </param>
+ /// <param name="av">The assertion value
+ /// </param>
+ public RfcAttributeValueAssertion(RfcAttributeDescription ad, RfcAssertionValue av):base(2)
+ {
+ add(ad);
+ add(av);
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcAuthenticationChoice.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcAuthenticationChoice.cs
new file mode 100755
index 00000000000..ece178f53e7
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcAuthenticationChoice.cs
@@ -0,0 +1,72 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.Rfc2251.RfcAuthenticationChoice.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+using Novell.Directory.Ldap.Asn1;
+
+namespace Novell.Directory.Ldap.Rfc2251
+{
+
+ /// <summary> Represents an Ldap Authentication Choice.
+ ///
+ /// <pre>
+ /// AuthenticationChoice ::= CHOICE {
+ /// simple [0] OCTET STRING,
+ /// -- 1 and 2 reserved
+ /// sasl [3] SaslCredentials }
+ /// </pre>
+ /// </summary>
+ public class RfcAuthenticationChoice:Asn1Choice
+ {
+
+ //*************************************************************************
+ // Constructors for AuthenticationChoice
+ //*************************************************************************
+
+ /// <summary> </summary>
+ public RfcAuthenticationChoice(Asn1Tagged choice):base(choice)
+ {
+ }
+
+ [CLSCompliantAttribute(false)]
+ public RfcAuthenticationChoice(System.String mechanism, sbyte[] credentials):base(new Asn1Tagged(new Asn1Identifier(Asn1Identifier.CONTEXT, true, 3), new RfcSaslCredentials(new RfcLdapString(mechanism), credentials != null?new Asn1OctetString(credentials):null), false))
+ { // implicit tagging
+ }
+
+ //*************************************************************************
+ // Mutators
+ //*************************************************************************
+
+ //*************************************************************************
+ // Accessors
+ //*************************************************************************
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcBindRequest.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcBindRequest.cs
new file mode 100755
index 00000000000..84372c66d10
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcBindRequest.cs
@@ -0,0 +1,166 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.Rfc2251.RfcBindRequest.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+using Novell.Directory.Ldap.Asn1;
+using Novell.Directory.Ldap;
+
+namespace Novell.Directory.Ldap.Rfc2251
+{
+
+ /// <summary> Represents and Ldap Bind Request.
+ /// <pre>
+ /// BindRequest ::= [APPLICATION 0] SEQUENCE {
+ /// version INTEGER (1 .. 127),
+ /// name LdapDN,
+ /// authentication AuthenticationChoice }
+ /// </pre>
+ /// </summary>
+ public class RfcBindRequest:Asn1Sequence, RfcRequest
+ {
+ /// <summary> </summary>
+ /// <summary> Sets the protocol version</summary>
+ virtual public Asn1Integer Version
+ {
+ get
+ {
+ return (Asn1Integer) get_Renamed(0);
+ }
+
+ set
+ {
+ set_Renamed(0, value);
+ return ;
+ }
+
+ }
+ /// <summary> </summary>
+ /// <summary> </summary>
+ virtual public RfcLdapDN Name
+ {
+ get
+ {
+ return (RfcLdapDN) get_Renamed(1);
+ }
+
+ set
+ {
+ set_Renamed(1, value);
+ return ;
+ }
+
+ }
+ /// <summary> </summary>
+ /// <summary> </summary>
+ virtual public RfcAuthenticationChoice AuthenticationChoice
+ {
+ get
+ {
+ return (RfcAuthenticationChoice) get_Renamed(2);
+ }
+
+ set
+ {
+ set_Renamed(2, value);
+ return ;
+ }
+
+ }
+
+ /// <summary> ID is added for Optimization.
+ ///
+ /// <p>ID needs only be one Value for every instance,
+ /// thus we create it only once.<p>
+ /// </summary>
+ new private static readonly Asn1Identifier ID = new Asn1Identifier(Asn1Identifier.APPLICATION, true, LdapMessage.BIND_REQUEST);
+
+
+ //*************************************************************************
+ // Constructors for BindRequest
+ //*************************************************************************
+
+ /// <summary> </summary>
+ public RfcBindRequest(Asn1Integer version, RfcLdapDN name, RfcAuthenticationChoice auth):base(3)
+ {
+ add(version);
+ add(name);
+ add(auth);
+ return ;
+ }
+
+ [CLSCompliantAttribute(false)]
+ public RfcBindRequest(int version, System.String dn, System.String mechanism, sbyte[] credentials):this(new Asn1Integer(version), new RfcLdapDN(dn), new RfcAuthenticationChoice(mechanism, credentials))
+ {
+ }
+
+ /// <summary> Constructs a new Bind Request copying the original data from
+ /// an existing request.
+ /// </summary>
+ /* package */
+ internal RfcBindRequest(Asn1Object[] origRequest, System.String base_Renamed):base(origRequest, origRequest.Length)
+ {
+ // Replace the dn if specified, otherwise keep original base
+ if ((System.Object) base_Renamed != null)
+ {
+ set_Renamed(1, new RfcLdapDN(base_Renamed));
+ }
+ return ;
+ }
+
+ //*************************************************************************
+ // Mutators
+ //*************************************************************************
+
+ //*************************************************************************
+ // Accessors
+ //*************************************************************************
+
+ /// <summary> Override getIdentifier to return an application-wide id.
+ ///
+ /// <pre>
+ /// ID = CLASS: APPLICATION, FORM: CONSTRUCTED, TAG: 0. (0x60)
+ /// </pre>
+ /// </summary>
+ public override Asn1Identifier getIdentifier()
+ {
+ return ID;
+ }
+
+ public RfcRequest dupRequest(System.String base_Renamed, System.String filter, bool request)
+ {
+ return new RfcBindRequest(toArray(), base_Renamed);
+ }
+ public System.String getRequestDN()
+ {
+ return ((RfcLdapDN) get_Renamed(1)).stringValue();
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcBindResponse.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcBindResponse.cs
new file mode 100755
index 00000000000..37c7684ddfb
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcBindResponse.cs
@@ -0,0 +1,141 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.Rfc2251.RfcBindResponse.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+using Novell.Directory.Ldap;
+using Novell.Directory.Ldap.Asn1;
+
+namespace Novell.Directory.Ldap.Rfc2251
+{
+
+ /// <summary> Represents and Ldap Bind Response.
+ ///
+ /// <pre>
+ /// BindResponse ::= [APPLICATION 1] SEQUENCE {
+ ///
+ /// COMPONENTS OF LdapResult,
+ /// serverSaslCreds [7] OCTET STRING OPTIONAL }
+ /// </pre>
+ /// </summary>
+ public class RfcBindResponse:Asn1Sequence, RfcResponse
+ {
+ /// <summary> Returns the OPTIONAL serverSaslCreds of a BindResponse if it exists
+ /// otherwise null.
+ /// </summary>
+ virtual public Asn1OctetString ServerSaslCreds
+ {
+ get
+ {
+ if (size() == 5)
+ return (Asn1OctetString) ((Asn1Tagged) get_Renamed(4)).taggedValue();
+
+ if (size() == 4)
+ {
+ // could be referral or serverSaslCreds
+ Asn1Object obj = get_Renamed(3);
+ if (obj is Asn1Tagged)
+ return (Asn1OctetString) ((Asn1Tagged) obj).taggedValue();
+ }
+
+ return null;
+ }
+
+ }
+
+ //*************************************************************************
+ // Constructors for BindResponse
+ //*************************************************************************
+
+ /// <summary> The only time a client will create a BindResponse is when it is
+ /// decoding it from an InputStream
+ ///
+ /// Note: If serverSaslCreds is included in the BindResponse, it does not
+ /// need to be decoded since it is already an OCTET STRING.
+ /// </summary>
+ [CLSCompliantAttribute(false)]
+ public RfcBindResponse(Asn1Decoder dec, System.IO.Stream in_Renamed, int len):base(dec, in_Renamed, len)
+ {
+
+ // Decode optional referral from Asn1OctetString to Referral.
+ if (size() > 3)
+ {
+ Asn1Tagged obj = (Asn1Tagged) get_Renamed(3);
+ Asn1Identifier id = obj.getIdentifier();
+ if (id.Tag == RfcLdapResult.REFERRAL)
+ {
+ sbyte[] content = ((Asn1OctetString) obj.taggedValue()).byteValue();
+ System.IO.MemoryStream bais = new System.IO.MemoryStream(SupportClass.ToByteArray(content));
+ set_Renamed(3, new RfcReferral(dec, bais, content.Length));
+ }
+ }
+ }
+
+ //*************************************************************************
+ // Accessors
+ //*************************************************************************
+
+ /// <summary> </summary>
+ public Asn1Enumerated getResultCode()
+ {
+ return (Asn1Enumerated) get_Renamed(0);
+ }
+
+ /// <summary> </summary>
+ public RfcLdapDN getMatchedDN()
+ {
+ return new RfcLdapDN(((Asn1OctetString) get_Renamed(1)).byteValue());
+ }
+
+ /// <summary> </summary>
+ public RfcLdapString getErrorMessage()
+ {
+ return new RfcLdapString(((Asn1OctetString) get_Renamed(2)).byteValue());
+ }
+
+ /// <summary> </summary>
+ public RfcReferral getReferral()
+ {
+ if (size() > 3)
+ {
+ Asn1Object obj = get_Renamed(3);
+ if (obj is RfcReferral)
+ return (RfcReferral) obj;
+ }
+ return null;
+ }
+
+ /// <summary> Override getIdentifier to return an application-wide id.</summary>
+ public override Asn1Identifier getIdentifier()
+ {
+ return new Asn1Identifier(Asn1Identifier.APPLICATION, true, LdapMessage.BIND_RESPONSE);
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcCompareRequest.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcCompareRequest.cs
new file mode 100755
index 00000000000..ae66a37697f
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcCompareRequest.cs
@@ -0,0 +1,106 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.Rfc2251.RfcCompareRequest.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+using Novell.Directory.Ldap.Asn1;
+using Novell.Directory.Ldap;
+
+namespace Novell.Directory.Ldap.Rfc2251
+{
+
+ /// <summary> Represents and Ldap Compare Request.
+ ///
+ /// <pre>
+ /// CompareRequest ::= [APPLICATION 14] SEQUENCE {
+ /// entry LdapDN,
+ /// ava AttributeValueAssertion }
+ /// </pre>
+ /// </summary>
+ public class RfcCompareRequest:Asn1Sequence, RfcRequest
+ {
+ virtual public RfcAttributeValueAssertion AttributeValueAssertion
+ {
+ get
+ {
+ return ((RfcAttributeValueAssertion) get_Renamed(1));
+ }
+
+ }
+
+ //*************************************************************************
+ // Constructor for CompareRequest
+ //*************************************************************************
+
+ /// <summary> </summary>
+ public RfcCompareRequest(RfcLdapDN entry, RfcAttributeValueAssertion ava):base(2)
+ {
+ add(entry);
+ add(ava);
+ if (ava.AssertionValue == null)
+ {
+ throw new System.ArgumentException("compare: Attribute must have an assertion value");
+ }
+ return ;
+ }
+
+ /// <summary> Constructs a new Compare Request copying from the data of
+ /// an existing request.
+ /// </summary>
+ /* package */
+ internal RfcCompareRequest(Asn1Object[] origRequest, System.String base_Renamed):base(origRequest, origRequest.Length)
+ {
+ // Replace the base if specified, otherwise keep original base
+ if ((System.Object) base_Renamed != null)
+ {
+ set_Renamed(0, new RfcLdapDN(base_Renamed));
+ }
+ return ;
+ }
+ //*************************************************************************
+ // Accessors
+ //*************************************************************************
+
+ /// <summary> Override getIdentifier to return an application-wide id.</summary>
+ public override Asn1Identifier getIdentifier()
+ {
+ return new Asn1Identifier(Asn1Identifier.APPLICATION, true, LdapMessage.COMPARE_REQUEST);
+ }
+
+ public RfcRequest dupRequest(System.String base_Renamed, System.String filter, bool request)
+ {
+ return new RfcCompareRequest(toArray(), base_Renamed);
+ }
+ public System.String getRequestDN()
+ {
+ return ((RfcLdapDN) get_Renamed(0)).stringValue();
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcCompareResponse.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcCompareResponse.cs
new file mode 100755
index 00000000000..0292a90c6d7
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcCompareResponse.cs
@@ -0,0 +1,89 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.Rfc2251.RfcCompareResponse.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+using Novell.Directory.Ldap;
+using Novell.Directory.Ldap.Asn1;
+
+namespace Novell.Directory.Ldap.Rfc2251
+{
+
+ /// <summary> Represents and Ldap Compare Response.
+ ///
+ /// <pre>
+ /// CompareResponse ::= [APPLICATION 15] LdapResult
+ /// </pre>
+ /// </summary>
+ public class RfcCompareResponse:RfcLdapResult
+ {
+
+ //*************************************************************************
+ // Constructor for CompareResponse
+ //*************************************************************************
+
+ /// <summary> The only time a client will create a CompareResponse is when it is
+ /// decoding it from an InputStream
+ /// </summary>
+ [CLSCompliantAttribute(false)]
+ public RfcCompareResponse(Asn1Decoder dec, System.IO.Stream in_Renamed, int len):base(dec, in_Renamed, len)
+ {
+ }
+
+ /// <summary> Constructs an RfcCompareResponse from parameters.
+ ///
+ /// </summary>
+ /// <param name="resultCode">the result code of the operation
+ ///
+ /// </param>
+ /// <param name="matchedDN">the matched DN returned from the server
+ ///
+ /// </param>
+ /// <param name="errorMessage">the diagnostic message returned from the server
+ ///
+ /// </param>
+ /// <param name="referral">the referral(s) returned by the server
+ /// </param>
+ public RfcCompareResponse(Asn1Enumerated resultCode, RfcLdapDN matchedDN, RfcLdapString errorMessage, RfcReferral referral):base(resultCode, matchedDN, errorMessage, referral)
+ {
+ return ;
+ }
+
+ //*************************************************************************
+ // Accessors
+ //*************************************************************************
+
+ /// <summary> Override getIdentifier to return an application-wide id.</summary>
+ public override Asn1Identifier getIdentifier()
+ {
+ return new Asn1Identifier(Asn1Identifier.APPLICATION, true, LdapMessage.COMPARE_RESPONSE);
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcControl.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcControl.cs
new file mode 100755
index 00000000000..ba7366dbfba
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcControl.cs
@@ -0,0 +1,189 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.Rfc2251.RfcControl.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+using Novell.Directory.Ldap.Asn1;
+
+
+namespace Novell.Directory.Ldap.Rfc2251
+{
+
+ /// <summary> Represents an Ldap Control.
+ ///
+ /// <pre>
+ /// Control ::= SEQUENCE {
+ /// controlType LdapOID,
+ /// criticality BOOLEAN DEFAULT FALSE,
+ /// controlValue OCTET STRING OPTIONAL }
+ /// </pre>
+ /// </summary>
+ public class RfcControl:Asn1Sequence
+ {
+ /// <summary> </summary>
+ virtual public Asn1OctetString ControlType
+ {
+ get
+ {
+ return (Asn1OctetString) get_Renamed(0);
+ }
+
+ }
+ /// <summary> Returns criticality.
+ ///
+ /// If no value present, return the default value of FALSE.
+ /// </summary>
+ virtual public Asn1Boolean Criticality
+ {
+ get
+ {
+ if (size() > 1)
+ {
+ // MAY be a criticality
+ Asn1Object obj = get_Renamed(1);
+ if (obj is Asn1Boolean)
+ return (Asn1Boolean) obj;
+ }
+
+ return new Asn1Boolean(false);
+ }
+
+ }
+ /// <summary> Since controlValue is an OPTIONAL component, we need to check
+ /// to see if one is available. Remember that if criticality is of default
+ /// value, it will not be present.
+ /// </summary>
+ /// <summary> Called to set/replace the ControlValue. Will normally be called by
+ /// the child classes after the parent has been instantiated.
+ /// </summary>
+ virtual public Asn1OctetString ControlValue
+ {
+ get
+ {
+ if (size() > 2)
+ {
+ // MUST be a control value
+ return (Asn1OctetString) get_Renamed(2);
+ }
+ else if (size() > 1)
+ {
+ // MAY be a control value
+ Asn1Object obj = get_Renamed(1);
+ if (obj is Asn1OctetString)
+ return (Asn1OctetString) obj;
+ }
+ return null;
+ }
+
+ set
+ {
+
+ if (value == null)
+ return ;
+
+ if (size() == 3)
+ {
+ // We already have a control value, replace it
+ set_Renamed(2, value);
+ return ;
+ }
+
+ if (size() == 2)
+ {
+
+ // Get the second element
+ Asn1Object obj = get_Renamed(1);
+
+ // Is this a control value
+ if (obj is Asn1OctetString)
+ {
+
+ // replace this one
+ set_Renamed(1, value);
+ return ;
+ }
+ else
+ {
+ // add a new one at the end
+ add(value);
+ return ;
+ }
+ }
+ }
+
+ }
+
+ //*************************************************************************
+ // Constructors for Control
+ //*************************************************************************
+
+ /// <summary> </summary>
+ public RfcControl(RfcLdapOID controlType):this(controlType, new Asn1Boolean(false), null)
+ {
+ }
+
+ /// <summary> </summary>
+ public RfcControl(RfcLdapOID controlType, Asn1Boolean criticality):this(controlType, criticality, null)
+ {
+ }
+
+ /// <summary>
+ /// Note: criticality is only added if true, as per RFC 2251 sec 5.1 part
+ /// (4): If a value of a type is its default value, it MUST be
+ /// absent.
+ /// </summary>
+ public RfcControl(RfcLdapOID controlType, Asn1Boolean criticality, Asn1OctetString controlValue):base(3)
+ {
+ add(controlType);
+ if (criticality.booleanValue() == true)
+ add(criticality);
+ if (controlValue != null)
+ add(controlValue);
+ }
+
+ /// <summary> Constructs a Control object by decoding it from an InputStream.</summary>
+ [CLSCompliantAttribute(false)]
+ public RfcControl(Asn1Decoder dec, System.IO.Stream in_Renamed, int len):base(dec, in_Renamed, len)
+ {
+ }
+
+ /// <summary> Constructs a Control object by decoding from an Asn1Sequence</summary>
+ public RfcControl(Asn1Sequence seqObj):base(3)
+ {
+ int len = seqObj.size();
+ for (int i = 0; i < len; i++)
+ add(seqObj.get_Renamed(i));
+ }
+
+ //*************************************************************************
+ // Accessors
+ //*************************************************************************
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcControls.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcControls.cs
new file mode 100755
index 00000000000..38b74059a02
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcControls.cs
@@ -0,0 +1,102 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.Rfc2251.RfcControls.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+using Novell.Directory.Ldap.Asn1;
+using Novell.Directory.Ldap.Rfc2251;
+
+namespace Novell.Directory.Ldap.Rfc2251
+{
+
+ /// <summary> Represents Ldap Contreols.
+ ///
+ /// </pre>
+ /// Controls ::= SEQUENCE OF Control
+ /// <pre>
+ /// </summary>
+ public class RfcControls:Asn1SequenceOf
+ {
+
+ /// <summary> Controls context specific tag</summary>
+ public const int CONTROLS = 0;
+
+ //*************************************************************************
+ // Constructors for Controls
+ //*************************************************************************
+
+ /// <summary> Constructs a Controls object. This constructor is used in combination
+ /// with the add() method to construct a set of Controls to send to the
+ /// server.
+ /// </summary>
+ public RfcControls():base(5)
+ {
+ }
+
+ /// <summary> Constructs a Controls object by decoding it from an InputStream.</summary>
+ [CLSCompliantAttribute(false)]
+ public RfcControls(Asn1Decoder dec, System.IO.Stream in_Renamed, int len):base(dec, in_Renamed, len)
+ {
+
+ // Convert each SEQUENCE element to a Control
+ for (int i = 0; i < size(); i++)
+ {
+ RfcControl tempControl = new RfcControl((Asn1Sequence) get_Renamed(i));
+ set_Renamed(i, tempControl);
+ }
+ }
+
+ //*************************************************************************
+ // Mutators
+ //*************************************************************************
+
+ /// <summary> Override add() of Asn1SequenceOf to only accept a Control type.</summary>
+ public void add(RfcControl control)
+ {
+ base.add(control);
+ }
+
+ /// <summary> Override set() of Asn1SequenceOf to only accept a Control type.</summary>
+ public void set_Renamed(int index, RfcControl control)
+ {
+ base.set_Renamed(index, control);
+ }
+
+ //*************************************************************************
+ // Accessors
+ //*************************************************************************
+
+ /// <summary> Override getIdentifier to return a context specific id.</summary>
+ public override Asn1Identifier getIdentifier()
+ {
+ return new Asn1Identifier(Asn1Identifier.CONTEXT, true, CONTROLS);
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcDelRequest.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcDelRequest.cs
new file mode 100755
index 00000000000..f016eb18a02
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcDelRequest.cs
@@ -0,0 +1,98 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.Rfc2251.RfcDelRequest.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+using Novell.Directory.Ldap.Asn1;
+using Novell.Directory.Ldap;
+
+namespace Novell.Directory.Ldap.Rfc2251
+{
+
+ /// <summary> Represents an Ldap Delete Request.
+ ///
+ /// <pre>
+ /// DelRequest ::= [APPLICATION 10] LdapDN
+ /// </pre>
+ /// </summary>
+ public class RfcDelRequest:RfcLdapDN, RfcRequest
+ {
+
+ //*************************************************************************
+ // Constructor for DelRequest
+ //*************************************************************************
+
+ /// <summary> Constructs an Ldapv3 delete request protocol operation.
+ ///
+ /// </summary>
+ /// <param name="dn">The Distinguished Name of the entry to delete.
+ /// </param>
+ public RfcDelRequest(System.String dn):base(dn)
+ {
+ }
+
+ /// <summary> Constructs an Ldapv3 delete request protocol operation.
+ ///
+ /// </summary>
+ /// <param name="dn">The Distinguished Name of the entry to delete.
+ /// </param>
+ [CLSCompliantAttribute(false)]
+ public RfcDelRequest(sbyte[] dn):base(dn)
+ {
+ }
+
+ /// <summary> Override getIdentifier() to return the appropriate application-wide id
+ /// representing this delete request. The getIdentifier() method is called
+ /// when this object is encoded.
+ ///
+ /// Identifier = CLASS: APPLICATION, FORM: CONSTRUCTED, TAG: 10
+ /// </summary>
+ public override Asn1Identifier getIdentifier()
+ {
+ return new Asn1Identifier(Asn1Identifier.APPLICATION, false, LdapMessage.DEL_REQUEST);
+ }
+
+ public RfcRequest dupRequest(System.String base_Renamed, System.String filter, bool request)
+ {
+ if ((System.Object) base_Renamed == null)
+ {
+ return new RfcDelRequest(byteValue());
+ }
+ else
+ {
+ return new RfcDelRequest(base_Renamed);
+ }
+ }
+ public System.String getRequestDN()
+ {
+ return base.stringValue();
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcDelResponse.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcDelResponse.cs
new file mode 100755
index 00000000000..28225bd7cc0
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcDelResponse.cs
@@ -0,0 +1,89 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.Rfc2251.RfcDelResponse.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+using Novell.Directory.Ldap;
+using Novell.Directory.Ldap.Asn1;
+
+namespace Novell.Directory.Ldap.Rfc2251
+{
+
+ /// <summary> Represents and Ldap Delete Response.
+ ///
+ /// <pre>
+ /// DelResponse ::= [APPLICATION 11] LdapResult
+ /// </pre>
+ /// </summary>
+ public class RfcDelResponse:RfcLdapResult
+ {
+
+ //*************************************************************************
+ // Constructors for DelResponse
+ //*************************************************************************
+
+ /// <summary> The only time a client will create a DelResponse is when it is
+ /// decoding it from an InputStream
+ /// </summary>
+ [CLSCompliantAttribute(false)]
+ public RfcDelResponse(Asn1Decoder dec, System.IO.Stream in_Renamed, int len):base(dec, in_Renamed, len)
+ {
+ }
+
+ /// <summary> Constructs an RfcDelResponse from parameters.
+ ///
+ /// </summary>
+ /// <param name="resultCode">the result code of the operation
+ ///
+ /// </param>
+ /// <param name="matchedDN">the matched DN returned from the server
+ ///
+ /// </param>
+ /// <param name="errorMessage">the diagnostic message returned from the server
+ ///
+ /// </param>
+ /// <param name="referral">the referral(s) returned by the server
+ /// </param>
+ public RfcDelResponse(Asn1Enumerated resultCode, RfcLdapDN matchedDN, RfcLdapString errorMessage, RfcReferral referral):base(resultCode, matchedDN, errorMessage, referral)
+ {
+ return ;
+ }
+
+ //*************************************************************************
+ // Accessors
+ //*************************************************************************
+
+ /// <summary> Override getIdentifier to return an application-wide id.</summary>
+ public override Asn1Identifier getIdentifier()
+ {
+ return new Asn1Identifier(Asn1Identifier.APPLICATION, true, LdapMessage.DEL_RESPONSE);
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcExtendedRequest.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcExtendedRequest.cs
new file mode 100755
index 00000000000..09ce21433ef
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcExtendedRequest.cs
@@ -0,0 +1,120 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.Rfc2251.RfcExtendedRequest.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+using Novell.Directory.Ldap.Asn1;
+using Novell.Directory.Ldap;
+
+namespace Novell.Directory.Ldap.Rfc2251
+{
+
+ /// <summary> Represents an Ldap Extended Request.
+ ///
+ /// <pre>
+ /// ExtendedRequest ::= [APPLICATION 23] SEQUENCE {
+ /// requestName [0] LdapOID,
+ /// requestValue [1] OCTET STRING OPTIONAL }
+ /// </pre>
+ /// </summary>
+ public class RfcExtendedRequest:Asn1Sequence, RfcRequest
+ {
+
+ /// <summary> Context-specific TAG for optional requestName.</summary>
+ public const int REQUEST_NAME = 0;
+ /// <summary> Context-specific TAG for optional requestValue.</summary>
+ public const int REQUEST_VALUE = 1;
+
+ //*************************************************************************
+ // Constructors for ExtendedRequest
+ //*************************************************************************
+
+ /// <summary> Constructs an extended request.
+ ///
+ /// </summary>
+ /// <param name="requestName">The OID for this extended operation.
+ /// </param>
+ public RfcExtendedRequest(RfcLdapOID requestName):this(requestName, null)
+ {
+ return ;
+ }
+
+ /// <summary> Constructs an extended request.
+ ///
+ /// </summary>
+ /// <param name="requestName">The OID for this extended operation.
+ /// </param>
+ /// <param name="requestValue">An optional request value.
+ /// </param>
+ public RfcExtendedRequest(RfcLdapOID requestName, Asn1OctetString requestValue):base(2)
+ {
+ add(new Asn1Tagged(new Asn1Identifier(Asn1Identifier.CONTEXT, false, REQUEST_NAME), requestName, false));
+ if (requestValue != null)
+ add(new Asn1Tagged(new Asn1Identifier(Asn1Identifier.CONTEXT, false, REQUEST_VALUE), requestValue, false));
+ return ;
+ }
+
+
+ /// <summary> Constructs an extended request from an existing request.
+ ///
+ /// </summary>
+ /// <param name="origRequest">Asn1Object of existing request
+ /// </param>
+ /* package */
+ public RfcExtendedRequest(Asn1Object[] origRequest):base(origRequest, origRequest.Length)
+ {
+ return ;
+ }
+ //*************************************************************************
+ // Accessors
+ //*************************************************************************
+
+ /// <summary> Override getIdentifier to return an application-wide id.
+ ///
+ /// <pre>
+ /// ID = CLASS: APPLICATION, FORM: CONSTRUCTED, TAG: 23.
+ /// </pre>
+ /// </summary>
+ public override Asn1Identifier getIdentifier()
+ {
+ return new Asn1Identifier(Asn1Identifier.APPLICATION, true, LdapMessage.EXTENDED_REQUEST);
+ }
+
+ public RfcRequest dupRequest(System.String base_Renamed, System.String filter, bool request)
+ {
+ // Just dup the original request
+ return new RfcExtendedRequest(toArray());
+ }
+ public System.String getRequestDN()
+ {
+ return null;
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcExtendedResponse.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcExtendedResponse.cs
new file mode 100755
index 00000000000..683932dd274
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcExtendedResponse.cs
@@ -0,0 +1,156 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.Rfc2251.RfcExtendedResponse.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+using Novell.Directory.Ldap.Asn1;
+using Novell.Directory.Ldap;
+
+namespace Novell.Directory.Ldap.Rfc2251
+{
+
+ /// <summary> Represents an Ldap Extended Response.
+ ///
+ /// <pre>
+ /// ExtendedResponse ::= [APPLICATION 24] SEQUENCE {
+ /// COMPONENTS OF LdapResult,
+ /// responseName [10] LdapOID OPTIONAL,
+ /// response [11] OCTET STRING OPTIONAL }
+ /// </pre>
+ /// </summary>
+ public class RfcExtendedResponse:Asn1Sequence, RfcResponse
+ {
+ /// <summary> </summary>
+ virtual public RfcLdapOID ResponseName
+ {
+ get
+ {
+ return (responseNameIndex != 0)?(RfcLdapOID) get_Renamed(responseNameIndex):null;
+ }
+
+ }
+ /// <summary> </summary>
+ [CLSCompliantAttribute(false)]
+ virtual public Asn1OctetString Response
+ {
+ get
+ {
+ return (responseIndex != 0)?(Asn1OctetString) get_Renamed(responseIndex):null;
+ }
+
+ }
+
+ /// <summary> Context-specific TAG for optional responseName.</summary>
+ public const int RESPONSE_NAME = 10;
+ /// <summary> Context-specific TAG for optional response.</summary>
+ public const int RESPONSE = 11;
+
+ private int referralIndex;
+ private int responseNameIndex;
+ private int responseIndex;
+
+ //*************************************************************************
+ // Constructors for ExtendedResponse
+ //*************************************************************************
+
+ /// <summary> The only time a client will create a ExtendedResponse is when it is
+ /// decoding it from an InputStream
+ /// </summary>
+ [CLSCompliantAttribute(false)]
+ public RfcExtendedResponse(Asn1Decoder dec, System.IO.Stream in_Renamed, int len):base(dec, in_Renamed, len)
+ {
+
+
+ // decode optional tagged elements
+ if (size() > 3)
+ {
+ for (int i = 3; i < size(); i++)
+ {
+ Asn1Tagged obj = (Asn1Tagged) get_Renamed(i);
+ Asn1Identifier id = obj.getIdentifier();
+ switch (id.Tag)
+ {
+
+ case RfcLdapResult.REFERRAL:
+ sbyte[] content = ((Asn1OctetString) obj.taggedValue()).byteValue();
+ System.IO.MemoryStream bais = new System.IO.MemoryStream(SupportClass.ToByteArray(content));
+ set_Renamed(i, new RfcReferral(dec, bais, content.Length));
+ referralIndex = i;
+ break;
+
+ case RESPONSE_NAME:
+ set_Renamed(i, new RfcLdapOID(((Asn1OctetString) obj.taggedValue()).byteValue()));
+ responseNameIndex = i;
+ break;
+
+ case RESPONSE:
+ set_Renamed(i, obj.taggedValue());
+ responseIndex = i;
+ break;
+ }
+ }
+ }
+ }
+
+ //*************************************************************************
+ // Accessors
+ //*************************************************************************
+
+ /// <summary> </summary>
+ public Asn1Enumerated getResultCode()
+ {
+ return (Asn1Enumerated) get_Renamed(0);
+ }
+
+ /// <summary> </summary>
+ public RfcLdapDN getMatchedDN()
+ {
+ return new RfcLdapDN(((Asn1OctetString) get_Renamed(1)).byteValue());
+ }
+
+ /// <summary> </summary>
+ public RfcLdapString getErrorMessage()
+ {
+ return new RfcLdapString(((Asn1OctetString) get_Renamed(2)).byteValue());
+ }
+
+ /// <summary> </summary>
+ public RfcReferral getReferral()
+ {
+ return (referralIndex != 0)?(RfcReferral) get_Renamed(referralIndex):null;
+ }
+
+ /// <summary> Override getIdentifier to return an application-wide id.</summary>
+ public override Asn1Identifier getIdentifier()
+ {
+ return new Asn1Identifier(Asn1Identifier.APPLICATION, true, LdapMessage.EXTENDED_RESPONSE);
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcFilter.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcFilter.cs
new file mode 100755
index 00000000000..230880fb163
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcFilter.cs
@@ -0,0 +1,1404 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.Rfc2251.RfcFilter.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+using Novell.Directory.Ldap.Asn1;
+using LdapException = Novell.Directory.Ldap.LdapException;
+using LdapLocalException = Novell.Directory.Ldap.LdapLocalException;
+using LdapSearchRequest = Novell.Directory.Ldap.LdapSearchRequest;
+using Novell.Directory.Ldap.Utilclass;
+
+namespace Novell.Directory.Ldap.Rfc2251
+{
+
+ /// <summary> Represents an Ldap Filter.
+ ///
+ /// <p>This filter object can be created from a String or can be built up
+ /// programatically by adding filter components one at a time. Existing filter
+ /// components can be iterated though.</p>
+ ///
+ /// <p>Each filter component has an integer identifier defined in this class.
+ /// The following are basic filter components: {@link #EQUALITY_MATCH},
+ /// {@link #GREATER_OR_EQUAL}, {@link #LESS_OR_EQUAL}, {@link #SUBSTRINGS},
+ /// {@link #PRESENT}, {@link #APPROX_MATCH}, {@link #EXTENSIBLE_MATCH}.</p>
+ ///
+ /// <p>More filters can be nested together into more complex filters with the
+ /// following filter components: {@link #AND}, {@link #OR}, {@link #NOT} </p>
+ ///
+ /// <p>Substrings can have three components:
+ /// <pre>
+ /// Filter ::= CHOICE {
+ /// and [0] SET OF Filter,
+ /// or [1] SET OF Filter,
+ /// not [2] Filter,
+ /// equalityMatch [3] AttributeValueAssertion,
+ /// substrings [4] SubstringFilter,
+ /// greaterOrEqual [5] AttributeValueAssertion,
+ /// lessOrEqual [6] AttributeValueAssertion,
+ /// present [7] AttributeDescription,
+ /// approxMatch [8] AttributeValueAssertion,
+ /// extensibleMatch [9] MatchingRuleAssertion }
+ /// </pre>
+ /// </summary>
+ public class RfcFilter:Asn1Choice
+ {
+ //*************************************************************************
+ // Public variables for Filter
+ //*************************************************************************
+
+ /// <summary> Identifier for AND component.</summary>
+ public const int AND = LdapSearchRequest.AND;
+ /// <summary> Identifier for OR component.</summary>
+ public const int OR = LdapSearchRequest.OR;
+ /// <summary> Identifier for NOT component.</summary>
+ public const int NOT = LdapSearchRequest.NOT;
+ /// <summary> Identifier for EQUALITY_MATCH component.</summary>
+ public const int EQUALITY_MATCH = LdapSearchRequest.EQUALITY_MATCH;
+ /// <summary> Identifier for SUBSTRINGS component.</summary>
+ public const int SUBSTRINGS = LdapSearchRequest.SUBSTRINGS;
+ /// <summary> Identifier for GREATER_OR_EQUAL component.</summary>
+ public const int GREATER_OR_EQUAL = LdapSearchRequest.GREATER_OR_EQUAL;
+ /// <summary> Identifier for LESS_OR_EQUAL component.</summary>
+ public const int LESS_OR_EQUAL = LdapSearchRequest.LESS_OR_EQUAL;
+ /// <summary> Identifier for PRESENT component.</summary>
+ public const int PRESENT = LdapSearchRequest.PRESENT;
+ /// <summary> Identifier for APPROX_MATCH component.</summary>
+ public const int APPROX_MATCH = LdapSearchRequest.APPROX_MATCH;
+ /// <summary> Identifier for EXTENSIBLE_MATCH component.</summary>
+ public const int EXTENSIBLE_MATCH = LdapSearchRequest.EXTENSIBLE_MATCH;
+
+ /// <summary> Identifier for INITIAL component.</summary>
+ public const int INITIAL = LdapSearchRequest.INITIAL;
+ /// <summary> Identifier for ANY component.</summary>
+ public const int ANY = LdapSearchRequest.ANY;
+ /// <summary> Identifier for FINAL component.</summary>
+ public const int FINAL = LdapSearchRequest.FINAL;
+
+ //*************************************************************************
+ // Private variables for Filter
+ //*************************************************************************
+
+ private FilterTokenizer ft;
+ private System.Collections.Stack filterStack;
+ private bool finalFound;
+
+ //*************************************************************************
+ // Constructor for Filter
+ //*************************************************************************
+
+ /// <summary> Constructs a Filter object by parsing an RFC 2254 Search Filter String.</summary>
+ public RfcFilter(System.String filter):base(null)
+ {
+ ChoiceValue = parse(filter);
+ return ;
+ }
+
+ /// <summary> Constructs a Filter object that will be built up piece by piece. </summary>
+ public RfcFilter():base(null)
+ {
+ filterStack = new System.Collections.Stack();
+ //The choice value must be set later: setChoiceValue(rootFilterTag)
+ return ;
+ }
+
+ //*************************************************************************
+ // Helper methods for RFC 2254 Search Filter parsing.
+ //*************************************************************************
+
+ /// <summary> Parses an RFC 2251 filter string into an ASN.1 Ldap Filter object.</summary>
+ private Asn1Tagged parse(System.String filterExpr)
+ {
+
+ if ((System.Object) filterExpr == null || filterExpr.Equals(""))
+ {
+ filterExpr = new System.Text.StringBuilder("(objectclass=*)").ToString();
+ }
+
+ int idx;
+ if ((idx = filterExpr.IndexOf((System.Char) '\\')) != - 1)
+ {
+ System.Text.StringBuilder sb = new System.Text.StringBuilder(filterExpr);
+ int i = idx;
+ while (i < (sb.Length - 1))
+ {
+ char c = sb[i++];
+ if (c == '\\')
+ {
+ // found '\' (backslash)
+ // If V2 escape, turn to a V3 escape
+ c = sb[i];
+ if (c == '*' || c == '(' || c == ')' || c == '\\')
+ {
+ // Ldap v2 filter, convert them into hex chars
+ sb.Remove(i, i + 1 - i);
+ sb.Insert(i, System.Convert.ToString((int) c, 16));
+ i += 2;
+ }
+ }
+ }
+ filterExpr = sb.ToString();
+ }
+
+ // missing opening and closing parentheses, must be V2, add parentheses
+ if ((filterExpr[0] != '(') && (filterExpr[filterExpr.Length - 1] != ')'))
+ {
+ filterExpr = "(" + filterExpr + ")";
+ }
+
+ char ch = filterExpr[0];
+ int len = filterExpr.Length;
+
+ // missing opening parenthesis ?
+ if (ch != '(')
+ {
+ throw new LdapLocalException(ExceptionMessages.MISSING_LEFT_PAREN, LdapException.FILTER_ERROR);
+ }
+
+ // missing closing parenthesis ?
+ if (filterExpr[len - 1] != ')')
+ {
+ throw new LdapLocalException(ExceptionMessages.MISSING_RIGHT_PAREN, LdapException.FILTER_ERROR);
+ }
+
+ // unmatched parentheses ?
+ int parenCount = 0;
+ for (int i = 0; i < len; i++)
+ {
+ if (filterExpr[i] == '(')
+ {
+ parenCount++;
+ }
+
+ if (filterExpr[i] == ')')
+ {
+ parenCount--;
+ }
+ }
+
+ if (parenCount > 0)
+ {
+ throw new LdapLocalException(ExceptionMessages.MISSING_RIGHT_PAREN, LdapException.FILTER_ERROR);
+ }
+
+ if (parenCount < 0)
+ {
+ throw new LdapLocalException(ExceptionMessages.MISSING_LEFT_PAREN, LdapException.FILTER_ERROR);
+ }
+ ft = new FilterTokenizer(this, filterExpr);
+
+ return parseFilter();
+ }
+
+ /// <summary> Parses an RFC 2254 filter</summary>
+ private Asn1Tagged parseFilter()
+ {
+ ft.getLeftParen();
+
+ Asn1Tagged filter = parseFilterComp();
+
+ ft.getRightParen();
+
+ return filter;
+ }
+
+ /// <summary> RFC 2254 filter helper method. Will Parse a filter component.</summary>
+ private Asn1Tagged parseFilterComp()
+ {
+ Asn1Tagged tag = null;
+ int filterComp = ft.OpOrAttr;
+
+ switch (filterComp)
+ {
+
+ case AND:
+ case OR:
+ tag = new Asn1Tagged(new Asn1Identifier(Asn1Identifier.CONTEXT, true, filterComp), parseFilterList(), false);
+ break;
+
+ case NOT:
+ tag = new Asn1Tagged(new Asn1Identifier(Asn1Identifier.CONTEXT, true, filterComp), parseFilter(), true);
+ break;
+
+ default:
+ int filterType = ft.FilterType;
+ System.String value_Renamed = ft.Value;
+
+ switch (filterType)
+ {
+
+ case GREATER_OR_EQUAL:
+ case LESS_OR_EQUAL:
+ case APPROX_MATCH:
+ tag = new Asn1Tagged(new Asn1Identifier(Asn1Identifier.CONTEXT, true, filterType), new RfcAttributeValueAssertion(new RfcAttributeDescription(ft.Attr), new RfcAssertionValue(unescapeString(value_Renamed))), false);
+ break;
+
+ case EQUALITY_MATCH:
+ if (value_Renamed.Equals("*"))
+ {
+ // present
+ tag = new Asn1Tagged(new Asn1Identifier(Asn1Identifier.CONTEXT, false, PRESENT), new RfcAttributeDescription(ft.Attr), false);
+ }
+ else if (value_Renamed.IndexOf((System.Char) '*') != - 1)
+ {
+ // substrings parse:
+ // [initial], *any*, [final] into an Asn1SequenceOf
+// SupportClass.Tokenizer sub = new StringTokenizer(value_Renamed, "*", true);
+ SupportClass.Tokenizer sub = new SupportClass.Tokenizer(value_Renamed, "*");//, true);
+ Asn1SequenceOf seq = new Asn1SequenceOf(5);
+ int tokCnt = sub.Count;
+ int cnt = 0;
+
+ System.String lastTok = new System.Text.StringBuilder("").ToString();
+
+ while (sub.HasMoreTokens())
+ {
+ System.String subTok = sub.NextToken();
+ cnt++;
+ if (subTok.Equals("*"))
+ {
+ // if previous token was '*', and since the current
+ // token is a '*', we need to insert 'any'
+ if (lastTok.Equals(subTok))
+ {
+ // '**'
+ seq.add(new Asn1Tagged(new Asn1Identifier(Asn1Identifier.CONTEXT, false, ANY), new RfcLdapString(unescapeString("")), false));
+ }
+ }
+ else
+ {
+ // value (RfcLdapString)
+ if (cnt == 1)
+ {
+ // initial
+ seq.add(new Asn1Tagged(new Asn1Identifier(Asn1Identifier.CONTEXT, false, INITIAL), new RfcLdapString(unescapeString(subTok)), false));
+ }
+ else if (cnt < tokCnt)
+ {
+ // any
+ seq.add(new Asn1Tagged(new Asn1Identifier(Asn1Identifier.CONTEXT, false, ANY), new RfcLdapString(unescapeString(subTok)), false));
+ }
+ else
+ {
+ // final
+ seq.add(new Asn1Tagged(new Asn1Identifier(Asn1Identifier.CONTEXT, false, FINAL), new RfcLdapString(unescapeString(subTok)), false));
+ }
+ }
+ lastTok = subTok;
+ }
+
+ tag = new Asn1Tagged(new Asn1Identifier(Asn1Identifier.CONTEXT, true, SUBSTRINGS), new RfcSubstringFilter(new RfcAttributeDescription(ft.Attr), seq), false);
+ }
+ else
+ {
+ // simple
+ tag = new Asn1Tagged(new Asn1Identifier(Asn1Identifier.CONTEXT, true, EQUALITY_MATCH), new RfcAttributeValueAssertion(new RfcAttributeDescription(ft.Attr), new RfcAssertionValue(unescapeString(value_Renamed))), false);
+ }
+ break;
+
+ case EXTENSIBLE_MATCH:
+ System.String type = null, matchingRule = null;
+ bool dnAttributes = false;
+// SupportClass.Tokenizer st = new StringTokenizer(ft.Attr, ":", true);
+ SupportClass.Tokenizer st = new SupportClass.Tokenizer(ft.Attr, ":");//, true);
+
+ bool first = true;
+ while (st.HasMoreTokens())
+ {
+ System.String s = st.NextToken().Trim();
+ if (first && !s.Equals(":"))
+ {
+ type = s;
+ }
+ // dn must be lower case to be considered dn of the Entry.
+ else if (s.Equals("dn"))
+ {
+ dnAttributes = true;
+ }
+ else if (!s.Equals(":"))
+ {
+ matchingRule = s;
+ }
+ first = false;
+ }
+
+ tag = new Asn1Tagged(new Asn1Identifier(Asn1Identifier.CONTEXT, true, EXTENSIBLE_MATCH), new RfcMatchingRuleAssertion(((System.Object) matchingRule == null)?null:new RfcMatchingRuleId(matchingRule), ((System.Object) type == null)?null:new RfcAttributeDescription(type), new RfcAssertionValue(unescapeString(value_Renamed)), (dnAttributes == false)?null:new Asn1Boolean(true)), false);
+ break;
+ }
+ break;
+
+ }
+ return tag;
+ }
+
+ /// <summary> Must have 1 or more Filters</summary>
+ private Asn1SetOf parseFilterList()
+ {
+ Asn1SetOf set_Renamed = new Asn1SetOf();
+
+ set_Renamed.add(parseFilter()); // must have at least 1 filter
+
+ while (ft.peekChar() == '(')
+ {
+ // check for more filters
+ set_Renamed.add(parseFilter());
+ }
+ return set_Renamed;
+ }
+
+ /// <summary> Convert hex character to an integer. Return -1 if char is something
+ /// other than a hex char.
+ /// </summary>
+ internal static int hex2int(char c)
+ {
+ return (c >= '0' && c <= '9')?c - '0':(c >= 'A' && c <= 'F')?c - 'A' + 10:(c >= 'a' && c <= 'f')?c - 'a' + 10:- 1;
+ }
+
+ /// <summary> Replace escaped hex digits with the equivalent binary representation.
+ /// Assume either V2 or V3 escape mechanisms:
+ /// V2: \*, \(, \), \\.
+ /// V3: \2A, \28, \29, \5C, \00.
+ ///
+ /// </summary>
+ /// <param name="string"> A part of the input filter string to be converted.
+ ///
+ /// </param>
+ /// <returns> octet-string encoding of the specified string.
+ /// </returns>
+ private sbyte[] unescapeString(System.String string_Renamed)
+ {
+ // give octets enough space to grow
+ sbyte[] octets = new sbyte[string_Renamed.Length * 3];
+ // index for string and octets
+ int iString, iOctets;
+ // escape==true means we are in an escape sequence.
+ bool escape = false;
+ // escStart==true means we are reading the first character of an escape.
+ bool escStart = false;
+
+ int ival, length = string_Renamed.Length;
+ sbyte[] utf8Bytes;
+ char ch; // Character we are adding to the octet string
+ char[] ca = new char[1]; // used while converting multibyte UTF-8 char
+ char temp = (char) (0); // holds the value of the escaped sequence
+
+ // loop through each character of the string and copy them into octets
+ // converting escaped sequences when needed
+ for (iString = 0, iOctets = 0; iString < length; iString++)
+ {
+ ch = string_Renamed[iString];
+ if (escape)
+ {
+ if ((ival = hex2int(ch)) < 0)
+ {
+ // Invalid escape value(not a hex character)
+ throw new LdapLocalException(ExceptionMessages.INVALID_ESCAPE, new System.Object[]{ch}, LdapException.FILTER_ERROR);
+ }
+ else
+ {
+ // V3 escaped: \\**
+ if (escStart)
+ {
+ temp = (char) (ival << 4); // high bits of escaped char
+ escStart = false;
+ }
+ else
+ {
+ temp |= (char) (ival); // all bits of escaped char
+ octets[iOctets++] = (sbyte) temp;
+ escStart = escape = false;
+ }
+ }
+ }
+ else if (ch == '\\')
+ {
+ escStart = escape = true;
+ }
+ else
+ {
+ try
+ {
+ // place the character into octets.
+ if ((ch >= 0x01 && ch <= 0x27) || (ch >= 0x2B && ch <= 0x5B) || (ch >= 0x5D))
+ {
+ // found valid char
+ if (ch <= 0x7f)
+ {
+ // char = %x01-27 / %x2b-5b / %x5d-7f
+ octets[iOctets++] = (sbyte) ch;
+ }
+ else
+ {
+ // char > 0x7f, could be encoded in 2 or 3 bytes
+ ca[0] = ch;
+ System.Text.Encoding encoder = System.Text.Encoding.GetEncoding("utf-8");
+ byte[] ibytes = encoder.GetBytes(new System.String(ca));
+ utf8Bytes=SupportClass.ToSByteArray(ibytes);
+
+// utf8Bytes = new System.String(ca).getBytes("UTF-8");
+ // copy utf8 encoded character into octets
+ Array.Copy((System.Array) SupportClass.ToByteArray(utf8Bytes), 0, (System.Array)SupportClass.ToByteArray( octets), iOctets, utf8Bytes.Length);
+ iOctets = iOctets + utf8Bytes.Length;
+ }
+ escape = false;
+ }
+ else
+ {
+ // found invalid character
+ System.String escString = "";
+ ca[0] = ch;
+ System.Text.Encoding encoder = System.Text.Encoding.GetEncoding("utf-8");
+ byte[] ibytes = encoder.GetBytes(new System.String(ca));
+ utf8Bytes=SupportClass.ToSByteArray(ibytes);
+
+// utf8Bytes = new System.String(ca).getBytes("UTF-8");
+ for (int i = 0; i < utf8Bytes.Length; i++)
+ {
+ sbyte u = utf8Bytes[i];
+ if ((u >= 0) && (u < 0x10))
+ {
+ escString = escString + "\\0" + System.Convert.ToString(u & 0xff, 16);
+ }
+ else
+ {
+ escString = escString + "\\" + System.Convert.ToString(u & 0xff, 16);
+ }
+ }
+ throw new LdapLocalException(ExceptionMessages.INVALID_CHAR_IN_FILTER, new System.Object[]{ch, escString}, LdapException.FILTER_ERROR);
+ }
+ }
+ catch (System.IO.IOException ue)
+ {
+ throw new System.SystemException("UTF-8 String encoding not supported by JVM");
+ }
+ }
+ }
+
+ // Verify that any escape sequence completed
+ if (escStart || escape)
+ {
+ throw new LdapLocalException(ExceptionMessages.SHORT_ESCAPE, LdapException.FILTER_ERROR);
+ }
+
+ sbyte[] toReturn = new sbyte[iOctets];
+// Array.Copy((System.Array)SupportClass.ToByteArray(octets), 0, (System.Array)SupportClass.ToByteArray(toReturn), 0, iOctets);
+ Array.Copy((System.Array)octets, 0, (System.Array)toReturn, 0, iOctets);
+
+ octets = null;
+ return toReturn;
+ }
+
+ /* **********************************************************************
+ * The following methods aid in building filters sequentially,
+ * and is used by DSMLHandler:
+ ***********************************************************************/
+
+ /// <summary> Called by sequential filter building methods to add to a filter
+ /// component.
+ ///
+ /// <p>Verifies that the specified Asn1Object can be added, then adds the
+ /// object to the filter.</p>
+ /// </summary>
+ /// <param name="current"> Filter component to be added to the filter
+ /// @throws LdapLocalException Occurs when an invalid component is added, or
+ /// when the component is out of sequence.
+ /// </param>
+ private void addObject(Asn1Object current)
+ {
+ if (filterStack == null)
+ {
+ filterStack = new System.Collections.Stack();
+ }
+ if (choiceValue() == null)
+ {
+ //ChoiceValue is the root Asn1 node
+ ChoiceValue = current;
+ }
+ else
+ {
+ Asn1Tagged topOfStack = (Asn1Tagged) filterStack.Peek();
+ Asn1Object value_Renamed = topOfStack.taggedValue();
+ if (value_Renamed == null)
+ {
+ topOfStack.TaggedValue = current;
+ filterStack.Push(current);
+// filterStack.Add(current);
+ }
+ else if (value_Renamed is Asn1SetOf)
+ {
+ ((Asn1SetOf) value_Renamed).add(current);
+ //don't add this to the stack:
+ }
+ else if (value_Renamed is Asn1Set)
+ {
+ ((Asn1Set) value_Renamed).add(current);
+ //don't add this to the stack:
+ }
+ else if (value_Renamed.getIdentifier().Tag == LdapSearchRequest.NOT)
+ {
+ throw new LdapLocalException("Attemp to create more than one 'not' sub-filter", LdapException.FILTER_ERROR);
+ }
+ }
+ int type = current.getIdentifier().Tag;
+ if (type == AND || type == OR || type == NOT)
+ {
+// filterStack.Add(current);
+ filterStack.Push(current);
+ }
+ return ;
+ }
+
+ /// <summary> Creates and addes a substrings filter component.
+ ///
+ /// <p>startSubstrings must be immediatly followed by at least one
+ /// {@link #addSubstring} method and one {@link #endSubstrings} method</p>
+ /// @throws com.novell.ldap.LdapLocalException
+ /// Occurs when this component is created out of sequence.
+ /// </summary>
+ public virtual void startSubstrings(System.String attrName)
+ {
+ finalFound = false;
+ Asn1SequenceOf seq = new Asn1SequenceOf(5);
+ Asn1Object current = new Asn1Tagged(new Asn1Identifier(Asn1Identifier.CONTEXT, true, SUBSTRINGS), new RfcSubstringFilter(new RfcAttributeDescription(attrName), seq), false);
+ addObject(current);
+ SupportClass.StackPush(filterStack, seq);
+ return ;
+ }
+
+ /// <summary> Adds a Substring component of initial, any or final substring matching.
+ ///
+ /// <p>This method can be invoked only if startSubString was the last filter-
+ /// building method called. A substring is not required to have an 'INITIAL'
+ /// substring. However, when a filter contains an 'INITIAL' substring only
+ /// one can be added, and it must be the first substring added. Any number of
+ /// 'ANY' substrings can be added. A substring is not required to have a
+ /// 'FINAL' substrings either. However, when a filter does contain a 'FINAL'
+ /// substring only one can be added, and it must be the last substring added.
+ /// </p>
+ /// </summary>
+ /// <param name="type">Substring type: INITIAL | ANY | FINAL]
+ /// </param>
+ /// <param name="value">Value to use for matching
+ /// @throws LdapLocalException Occurs if this method is called out of
+ /// sequence or the type added is out of sequence.
+ /// </param>
+ [CLSCompliantAttribute(false)]
+ public virtual void addSubstring(int type, sbyte[] value_Renamed)
+ {
+ try
+ {
+ Asn1SequenceOf substringSeq = (Asn1SequenceOf) filterStack.Peek();
+ if (type != INITIAL && type != ANY && type != FINAL)
+ {
+ throw new LdapLocalException("Attempt to add an invalid " + "substring type", LdapException.FILTER_ERROR);
+ }
+
+ if (type == INITIAL && substringSeq.size() != 0)
+ {
+ throw new LdapLocalException("Attempt to add an initial " + "substring match after the first substring", LdapException.FILTER_ERROR);
+ }
+ if (finalFound)
+ {
+ throw new LdapLocalException("Attempt to add a substring " + "match after a final substring match", LdapException.FILTER_ERROR);
+ }
+ if (type == FINAL)
+ {
+ finalFound = true;
+ }
+ substringSeq.add(new Asn1Tagged(new Asn1Identifier(Asn1Identifier.CONTEXT, false, type), new RfcLdapString(value_Renamed), false));
+ }
+ catch (System.InvalidCastException e)
+ {
+ throw new LdapLocalException("A call to addSubstring occured " + "without calling startSubstring", LdapException.FILTER_ERROR);
+ }
+ return ;
+ }
+
+ /// <summary> Completes a SubString filter component.
+ ///
+ /// @throws LdapLocalException Occurs when this is called out of sequence,
+ /// or the substrings filter is empty.
+ /// </summary>
+ public virtual void endSubstrings()
+ {
+ try
+ {
+ finalFound = false;
+ Asn1SequenceOf substringSeq = (Asn1SequenceOf) filterStack.Peek();
+ if (substringSeq.size() == 0)
+ {
+ throw new LdapLocalException("Empty substring filter", LdapException.FILTER_ERROR);
+ }
+ }
+ catch (System.InvalidCastException e)
+ {
+ throw new LdapLocalException("Missmatched ending of substrings", LdapException.FILTER_ERROR);
+ }
+ filterStack.Pop();
+ return ;
+ }
+
+ /// <summary> Creates and adds an AttributeValueAssertion to the filter.
+ ///
+ /// </summary>
+ /// <param name="rfcType">Filter type: EQUALITY_MATCH | GREATER_OR_EQUAL
+ /// | LESS_OR_EQUAL | APPROX_MATCH ]
+ /// </param>
+ /// <param name="attrName">Name of the attribute to be asserted
+ /// </param>
+ /// <param name="value">Value of the attribute to be asserted
+ /// @throws LdapLocalException
+ /// Occurs when the filter type is not a valid attribute assertion.
+ /// </param>
+ [CLSCompliantAttribute(false)]
+ public virtual void addAttributeValueAssertion(int rfcType, System.String attrName, sbyte[] value_Renamed)
+ {
+ if (filterStack != null && !(filterStack.Count == 0) && filterStack.Peek() is Asn1SequenceOf)
+ {
+ //If a sequenceof is on the stack then substring is left on the stack
+ throw new LdapLocalException("Cannot insert an attribute assertion in a substring", LdapException.FILTER_ERROR);
+ }
+ if ((rfcType != EQUALITY_MATCH) && (rfcType != GREATER_OR_EQUAL) && (rfcType != LESS_OR_EQUAL) && (rfcType != APPROX_MATCH))
+ {
+ throw new LdapLocalException("Invalid filter type for AttributeValueAssertion", LdapException.FILTER_ERROR);
+ }
+ Asn1Object current = new Asn1Tagged(new Asn1Identifier(Asn1Identifier.CONTEXT, true, rfcType), new RfcAttributeValueAssertion(new RfcAttributeDescription(attrName), new RfcAssertionValue(value_Renamed)), false);
+ addObject(current);
+ return ;
+ }
+
+ /// <summary> Creates and adds a present matching to the filter.
+ ///
+ /// </summary>
+ /// <param name="attrName">Name of the attribute to check for presence.
+ /// @throws LdapLocalException
+ /// Occurs if addPresent is called out of sequence.
+ /// </param>
+ public virtual void addPresent(System.String attrName)
+ {
+ Asn1Object current = new Asn1Tagged(new Asn1Identifier(Asn1Identifier.CONTEXT, false, PRESENT), new RfcAttributeDescription(attrName), false);
+ addObject(current);
+ return ;
+ }
+
+ /// <summary> Adds an extensible match to the filter.
+ ///
+ /// </summary>
+ /// <param name="">matchingRule
+ /// OID or name of the matching rule to use for comparison
+ /// </param>
+ /// <param name="attrName"> Name of the attribute to match.
+ /// </param>
+ /// <param name="value"> Value of the attribute to match against.
+ /// </param>
+ /// <param name="useDNMatching">Indicates whether DN matching should be used.
+ /// @throws LdapLocalException
+ /// Occurs when addExtensibleMatch is called out of sequence.
+ /// </param>
+ [CLSCompliantAttribute(false)]
+ public virtual void addExtensibleMatch(System.String matchingRule, System.String attrName, sbyte[] value_Renamed, bool useDNMatching)
+ {
+ Asn1Object current = new Asn1Tagged(new Asn1Identifier(Asn1Identifier.CONTEXT, true, EXTENSIBLE_MATCH), new RfcMatchingRuleAssertion(((System.Object) matchingRule == null)?null:new RfcMatchingRuleId(matchingRule), ((System.Object) attrName == null)?null:new RfcAttributeDescription(attrName), new RfcAssertionValue(value_Renamed), (useDNMatching == false)?null:new Asn1Boolean(true)), false);
+ addObject(current);
+ return ;
+ }
+
+ /// <summary> Creates and adds the Asn1Tagged value for a nestedFilter: AND, OR, or
+ /// NOT.
+ ///
+ /// <p>Note that a Not nested filter can only have one filter, where AND
+ /// and OR do not</p>
+ ///
+ /// </summary>
+ /// <param name="rfcType">Filter type:
+ /// [AND | OR | NOT]
+ /// @throws com.novell.ldap.LdapLocalException
+ /// </param>
+ public virtual void startNestedFilter(int rfcType)
+ {
+ Asn1Object current;
+ if (rfcType == AND || rfcType == OR)
+ {
+ current = new Asn1Tagged(new Asn1Identifier(Asn1Identifier.CONTEXT, true, rfcType), new Asn1SetOf(), false);
+ }
+ else if (rfcType == NOT)
+ {
+ current = new Asn1Tagged(new Asn1Identifier(Asn1Identifier.CONTEXT, true, rfcType), null, true);
+ }
+ else
+ {
+ throw new LdapLocalException("Attempt to create a nested filter other than AND, OR or NOT", LdapException.FILTER_ERROR);
+ }
+ addObject(current);
+ return ;
+ }
+
+ /// <summary> Completes a nested filter and checks for the valid filter type.</summary>
+ /// <param name="rfcType"> Type of filter to complete.
+ /// @throws com.novell.ldap.LdapLocalException Occurs when the specified
+ /// type differs from the current filter component.
+ /// </param>
+ public virtual void endNestedFilter(int rfcType)
+ {
+ if (rfcType == NOT)
+ {
+ //if this is a Not than Not should be the second thing on the stack
+ filterStack.Pop();
+ }
+ int topOfStackType = ((Asn1Object) filterStack.Peek()).getIdentifier().Tag;
+ if (topOfStackType != rfcType)
+ {
+ throw new LdapLocalException("Missmatched ending of nested filter", LdapException.FILTER_ERROR);
+ }
+ filterStack.Pop();
+ return ;
+ }
+
+ /// <summary> Creates an iterator over the preparsed segments of a filter.
+ ///
+ /// <p>The first object returned by an iterator is an integer indicating the
+ /// type of filter components. Subseqence values are returned. If a
+ /// component is of type 'AND' or 'OR' or 'NOT' then the value
+ /// returned is another iterator. This iterator is used by toString.</p>
+ ///
+ /// </summary>
+ /// <returns> Iterator over filter segments
+ /// </returns>
+ public virtual System.Collections.IEnumerator getFilterIterator()
+ {
+ return new FilterIterator(this, (Asn1Tagged) this.choiceValue());
+ }
+
+ /// <summary> Creates and returns a String representation of this filter.</summary>
+ public virtual System.String filterToString()
+ {
+ System.Text.StringBuilder filter = new System.Text.StringBuilder();
+ stringFilter(this.getFilterIterator(), filter);
+ return filter.ToString();
+ }
+
+ /// <summary> Uses a filterIterator to create a string representation of a filter.
+ ///
+ /// </summary>
+ /// <param name="itr">Iterator of filter components
+ /// </param>
+ /// <param name="filter">Buffer to place a string representation of the filter
+ /// </param>
+ /// <seealso cref="#getFilterIterator">
+ /// </seealso>
+ private static void stringFilter(System.Collections.IEnumerator itr, System.Text.StringBuilder filter)
+ {
+ int op = - 1;
+ filter.Append('(');
+ while (itr.MoveNext())
+ {
+ System.Object filterpart = itr.Current;
+ if (filterpart is System.Int32)
+ {
+ op = ((System.Int32) filterpart);
+ switch (op)
+ {
+
+ case AND:
+ filter.Append('&');
+ break;
+
+ case OR:
+ filter.Append('|');
+ break;
+
+ case NOT:
+ filter.Append('!');
+ break;
+
+ case EQUALITY_MATCH: {
+ filter.Append((System.String) itr.Current);
+ filter.Append('=');
+ sbyte[] value_Renamed = (sbyte[]) itr.Current;
+ filter.Append(byteString(value_Renamed));
+ break;
+ }
+
+ case GREATER_OR_EQUAL: {
+ filter.Append((System.String) itr.Current);
+ filter.Append(">=");
+ sbyte[] value_Renamed = (sbyte[]) itr.Current;
+ filter.Append(byteString(value_Renamed));
+ break;
+ }
+
+ case LESS_OR_EQUAL: {
+ filter.Append((System.String) itr.Current);
+ filter.Append("<=");
+ sbyte[] value_Renamed = (sbyte[]) itr.Current;
+ filter.Append(byteString(value_Renamed));
+ break;
+ }
+
+ case PRESENT:
+ filter.Append((System.String) itr.Current);
+ filter.Append("=*");
+ break;
+
+ case APPROX_MATCH:
+ filter.Append((System.String) itr.Current);
+ filter.Append("~=");
+ sbyte[] value_Renamed2 = (sbyte[]) itr.Current;
+ filter.Append(byteString(value_Renamed2));
+ break;
+
+ case EXTENSIBLE_MATCH:
+ System.String oid = (System.String) itr.Current;
+
+ filter.Append((System.String) itr.Current);
+ filter.Append(':');
+ filter.Append(oid);
+ filter.Append(":=");
+ filter.Append((System.String) itr.Current);
+ break;
+
+ case SUBSTRINGS: {
+ filter.Append((System.String) itr.Current);
+ filter.Append('=');
+ bool noStarLast = false;
+ while (itr.MoveNext())
+ {
+ op = ((System.Int32) itr.Current);
+ switch (op)
+ {
+
+ case INITIAL:
+ filter.Append((System.String) itr.Current);
+ filter.Append('*');
+ noStarLast = false;
+ break;
+
+ case ANY:
+ if (noStarLast)
+ filter.Append('*');
+ filter.Append((System.String) itr.Current);
+ filter.Append('*');
+ noStarLast = false;
+ break;
+
+ case FINAL:
+ if (noStarLast)
+ filter.Append('*');
+ filter.Append((System.String) itr.Current);
+ break;
+ }
+ }
+ break;
+ }
+ }
+ }
+ else if (filterpart is System.Collections.IEnumerator)
+ {
+ stringFilter((System.Collections.IEnumerator) filterpart, filter);
+ }
+ }
+ filter.Append(')');
+ }
+
+ /// <summary> Convert a UTF8 encoded string, or binary data, into a String encoded for
+ /// a string filter.
+ /// </summary>
+ private static System.String byteString(sbyte[] value_Renamed)
+ {
+ System.String toReturn = null;
+ if (Novell.Directory.Ldap.Utilclass.Base64.isValidUTF8(value_Renamed, true))
+ {
+ try
+ {
+ System.Text.Encoding encoder = System.Text.Encoding.GetEncoding("utf-8");
+ char[] dchar = encoder.GetChars(SupportClass.ToByteArray(value_Renamed));
+ toReturn = new String(dchar);
+
+// toReturn = new String(value_Renamed, "UTF-8");
+ }
+ catch (System.IO.IOException e)
+ {
+ throw new System.SystemException("Default JVM does not support UTF-8 encoding" + e);
+ }
+ }
+ else
+ {
+ System.Text.StringBuilder binary = new System.Text.StringBuilder();
+ for (int i = 0; i < value_Renamed.Length; i++)
+ {
+ //TODO repair binary output
+ //Every octet needs to be escaped
+ if (value_Renamed[i] >= 0)
+ {
+ //one character hex string
+ binary.Append("\\0");
+ binary.Append(System.Convert.ToString(value_Renamed[i], 16));
+ }
+ else
+ {
+ //negative (eight character) hex string
+ binary.Append("\\" + System.Convert.ToString(value_Renamed[i], 16).Substring(6));
+ }
+ }
+ toReturn = binary.ToString();
+ }
+ return toReturn;
+ }
+
+ /// <summary> This inner class wrappers the Search Filter with an iterator.
+ /// This iterator will give access to all the individual components
+ /// preparsed. The first call to next will return an Integer identifying
+ /// the type of filter component. Then the component values will be returned
+ /// AND, NOT, and OR components values will be returned as Iterators.
+ /// </summary>
+ private class FilterIterator : System.Collections.IEnumerator
+ {
+ public void Reset(){}
+ private void InitBlock(RfcFilter enclosingInstance)
+ {
+ this.enclosingInstance = enclosingInstance;
+ }
+ private RfcFilter enclosingInstance;
+ /// <summary> Returns filter identifiers and components of a filter.
+ ///
+ /// The first object returned is an Integer identifying
+ /// its type.
+ /// </summary>
+ public virtual System.Object Current
+ {
+ get
+ {
+ System.Object toReturn = null;
+ if (!tagReturned)
+ {
+ tagReturned = true;
+ toReturn = root.getIdentifier().Tag;
+ }
+ else
+ {
+ Asn1Object asn1 = root.taggedValue();
+
+ if (asn1 is RfcLdapString)
+ {
+ //one value to iterate
+ hasMore = false;
+ toReturn = ((RfcLdapString) asn1).stringValue();
+ }
+ else if (asn1 is RfcSubstringFilter)
+ {
+
+ RfcSubstringFilter sub = (RfcSubstringFilter) asn1;
+ if (index == - 1)
+ {
+ //return attribute name
+ index = 0;
+ RfcAttributeDescription attr = (RfcAttributeDescription) sub.get_Renamed(0);
+ toReturn = attr.stringValue();
+ }
+ else if (index % 2 == 0)
+ {
+ //return substring identifier
+ Asn1SequenceOf substrs = (Asn1SequenceOf) sub.get_Renamed(1);
+ toReturn = ((Asn1Tagged) substrs.get_Renamed(index / 2)).getIdentifier().Tag;
+ index++;
+ }
+ else
+ {
+ //return substring value
+ Asn1SequenceOf substrs = (Asn1SequenceOf) sub.get_Renamed(1);
+ Asn1Tagged tag = (Asn1Tagged) substrs.get_Renamed(index / 2);
+ RfcLdapString value_Renamed = (RfcLdapString) tag.taggedValue();
+ toReturn = value_Renamed.stringValue();
+ index++;
+ }
+ if (index / 2 >= ((Asn1SequenceOf) sub.get_Renamed(1)).size())
+ {
+ hasMore = false;
+ }
+ }
+ else if (asn1 is RfcAttributeValueAssertion)
+ {
+ // components: =,>=,<=,~=
+ RfcAttributeValueAssertion assertion = (RfcAttributeValueAssertion) asn1;
+
+ if (index == - 1)
+ {
+ toReturn = assertion.AttributeDescription;
+ index = 1;
+ }
+ else if (index == 1)
+ {
+ toReturn = assertion.AssertionValue;
+ index = 2;
+ hasMore = false;
+ }
+ }
+ else if (asn1 is RfcMatchingRuleAssertion)
+ {
+ //Extensible match
+ RfcMatchingRuleAssertion exMatch = (RfcMatchingRuleAssertion) asn1;
+ if (index == - 1)
+ {
+ index = 0;
+ }
+ toReturn = ((Asn1OctetString) ((Asn1Tagged) exMatch.get_Renamed(index++)).taggedValue()).stringValue();
+ if (index > 2)
+ {
+ hasMore = false;
+ }
+ }
+ else if (asn1 is Asn1SetOf)
+ {
+ //AND and OR nested components
+ Asn1SetOf set_Renamed = (Asn1SetOf) asn1;
+ if (index == - 1)
+ {
+ index = 0;
+ }
+ toReturn = new FilterIterator(enclosingInstance,(Asn1Tagged) set_Renamed.get_Renamed(index++));
+ if (index >= set_Renamed.size())
+ {
+ this.hasMore = false;
+ }
+ }
+ else if (asn1 is Asn1Tagged)
+ {
+ //NOT nested component.
+ toReturn = new FilterIterator(enclosingInstance,(Asn1Tagged) asn1);
+ this.hasMore = false;
+ }
+ }
+ return toReturn;
+ }
+
+ }
+ public RfcFilter Enclosing_Instance
+ {
+ get
+ {
+ return enclosingInstance;
+ }
+
+ }
+ internal Asn1Tagged root;
+ /// <summary>indicates if the identifier for a component has been returned yet </summary>
+ internal bool tagReturned = false;
+ /// <summary>indexes the several parts a component may have </summary>
+ internal int index = - 1;
+ private bool hasMore = true;
+
+ public FilterIterator(RfcFilter enclosingInstance, Asn1Tagged root)
+ {
+ InitBlock(enclosingInstance);
+ this.root = root;
+ }
+ public virtual bool MoveNext()
+ {
+ return hasMore;
+ }
+
+ public void remove()
+ {
+ throw new System.NotSupportedException("Remove is not supported on a filter iterator");
+ }
+ }
+
+ /// <summary> This inner class will tokenize the components of an RFC 2254 search filter.</summary>
+ internal class FilterTokenizer
+ {
+ private void InitBlock(RfcFilter enclosingInstance)
+ {
+ this.enclosingInstance = enclosingInstance;
+ }
+ private RfcFilter enclosingInstance;
+ /// <summary> Reads either an operator, or an attribute, whichever is
+ /// next in the filter string.
+ ///
+ /// <p>Operators are &, |, or !.<p>
+ ///
+ /// <p>If the next component is an attribute, it is read and stored in the
+ /// attr field of this class which may be retrieved with getAttr()
+ /// and a -1 is returned. Otherwise, the int value of the operator read is
+ /// returned.</p>
+ /// </summary>
+ virtual public int OpOrAttr
+ {
+ get
+ {
+ int index;
+
+ if (offset >= filterLength)
+ {
+ //"Unexpected end of filter",
+ throw new LdapLocalException(ExceptionMessages.UNEXPECTED_END, LdapException.FILTER_ERROR);
+ }
+ int ret;
+ int testChar = filter[offset];
+ if (testChar == '&')
+ {
+ offset++;
+ ret = Novell.Directory.Ldap.Rfc2251.RfcFilter.AND;
+ }
+ else if (testChar == '|')
+ {
+ offset++;
+ ret = Novell.Directory.Ldap.Rfc2251.RfcFilter.OR;
+ }
+ else if (testChar == '!')
+ {
+ offset++;
+ ret = Novell.Directory.Ldap.Rfc2251.RfcFilter.NOT;
+ }
+ else
+ {
+ if (filter.Substring(offset).StartsWith(":=") == true)
+ {
+ throw new LdapLocalException(ExceptionMessages.NO_MATCHING_RULE, LdapException.FILTER_ERROR);
+ }
+
+ if (filter.Substring(offset).StartsWith("::=") == true || filter.Substring(offset).StartsWith(":::=") == true)
+ {
+ throw new LdapLocalException(ExceptionMessages.NO_DN_NOR_MATCHING_RULE, LdapException.FILTER_ERROR);
+ }
+
+
+ // get first component of 'item' (attr or :dn or :matchingrule)
+ System.String delims = "=~<>()";
+ System.Text.StringBuilder sb = new System.Text.StringBuilder();
+
+ while (delims.IndexOf((System.Char) filter[offset]) == - 1 && filter.Substring(offset).StartsWith(":=") == false)
+ {
+ sb.Append(filter[offset++]);
+ }
+
+ attr = sb.ToString().Trim();
+
+ // is there an attribute name specified in the filter ?
+ if (attr.Length == 0 || attr[0] == ';')
+ {
+ throw new LdapLocalException(ExceptionMessages.NO_ATTRIBUTE_NAME, LdapException.FILTER_ERROR);
+ }
+
+ for (index = 0; index < attr.Length; index++)
+ {
+ char atIndex = attr[index];
+ if (!(System.Char.IsLetterOrDigit(atIndex) || atIndex == '-' || atIndex == '.' || atIndex == ';' || atIndex == ':'))
+ {
+
+ if (atIndex == '\\')
+ {
+ throw new LdapLocalException(ExceptionMessages.INVALID_ESC_IN_DESCR, LdapException.FILTER_ERROR);
+ }
+ else
+ {
+ throw new LdapLocalException(ExceptionMessages.INVALID_CHAR_IN_DESCR, new System.Object[]{atIndex}, LdapException.FILTER_ERROR);
+ }
+ }
+ }
+
+ // is there an option specified in the filter ?
+ index = attr.IndexOf((System.Char) ';');
+ if (index != - 1 && index == attr.Length - 1)
+ {
+ throw new LdapLocalException(ExceptionMessages.NO_OPTION, LdapException.FILTER_ERROR);
+ }
+ ret = - 1;
+ }
+ return ret;
+ }
+
+ }
+ /// <summary> Reads an RFC 2251 filter type from the filter string and returns its
+ /// int value.
+ /// </summary>
+ virtual public int FilterType
+ {
+ get
+ {
+ if (offset >= filterLength)
+ {
+ //"Unexpected end of filter",
+ throw new LdapLocalException(ExceptionMessages.UNEXPECTED_END, LdapException.FILTER_ERROR);
+ }
+ int ret;
+ if (filter.Substring(offset).StartsWith(">="))
+ {
+ offset += 2;
+ ret = Novell.Directory.Ldap.Rfc2251.RfcFilter.GREATER_OR_EQUAL;
+ }
+ else if (filter.Substring(offset).StartsWith("<="))
+ {
+ offset += 2;
+ ret = Novell.Directory.Ldap.Rfc2251.RfcFilter.LESS_OR_EQUAL;
+ }
+ else if (filter.Substring(offset).StartsWith("~="))
+ {
+ offset += 2;
+ ret = Novell.Directory.Ldap.Rfc2251.RfcFilter.APPROX_MATCH;
+ }
+ else if (filter.Substring(offset).StartsWith(":="))
+ {
+ offset += 2;
+ ret = Novell.Directory.Ldap.Rfc2251.RfcFilter.EXTENSIBLE_MATCH;
+ }
+ else if (filter[offset] == '=')
+ {
+ offset++;
+ ret = Novell.Directory.Ldap.Rfc2251.RfcFilter.EQUALITY_MATCH;
+ }
+ else
+ {
+ //"Invalid comparison operator",
+ throw new LdapLocalException(ExceptionMessages.INVALID_FILTER_COMPARISON, LdapException.FILTER_ERROR);
+ }
+ return ret;
+ }
+
+ }
+ /// <summary> Reads a value from a filter string.</summary>
+ virtual public System.String Value
+ {
+ get
+ {
+ if (offset >= filterLength)
+ {
+ //"Unexpected end of filter",
+ throw new LdapLocalException(ExceptionMessages.UNEXPECTED_END, LdapException.FILTER_ERROR);
+ }
+
+ int idx = filter.IndexOf((System.Char) ')', offset);
+ if (idx == - 1)
+ {
+ idx = filterLength;
+ }
+ System.String ret = filter.Substring(offset, (idx) - (offset));
+ offset = idx;
+
+ return ret;
+ }
+
+ }
+ /// <summary> Returns the current attribute identifier.</summary>
+ virtual public System.String Attr
+ {
+ get
+ {
+ return attr;
+ }
+
+ }
+ public RfcFilter Enclosing_Instance
+ {
+ get
+ {
+ return enclosingInstance;
+ }
+
+ }
+
+ //*************************************************************************
+ // Private variables
+ //*************************************************************************
+
+ private System.String filter; // The filter string to parse
+ private System.String attr; // Name of the attribute just parsed
+ private int offset; // Offset pointer into the filter string
+ private int filterLength; // Length of the filter string to parse
+
+ //*************************************************************************
+ // Constructor
+ //*************************************************************************
+
+ /// <summary> Constructs a FilterTokenizer for a filter.</summary>
+ public FilterTokenizer(RfcFilter enclosingInstance, System.String filter)
+ {
+ InitBlock(enclosingInstance);
+ this.filter = filter;
+ this.offset = 0;
+ this.filterLength = filter.Length;
+ return ;
+ }
+
+ //*************************************************************************
+ // Tokenizer methods
+ //*************************************************************************
+
+ /// <summary> Reads the current char and throws an Exception if it is not a left
+ /// parenthesis.
+ /// </summary>
+ public void getLeftParen()
+ {
+ if (offset >= filterLength)
+ {
+ //"Unexpected end of filter",
+ throw new LdapLocalException(ExceptionMessages.UNEXPECTED_END, LdapException.FILTER_ERROR);
+ }
+ if (filter[offset++] != '(')
+ {
+ //"Missing left paren",
+ throw new LdapLocalException(ExceptionMessages.EXPECTING_LEFT_PAREN, new System.Object[]{filter[offset -= 1]}, LdapException.FILTER_ERROR);
+ }
+ return ;
+ }
+
+ /// <summary> Reads the current char and throws an Exception if it is not a right
+ /// parenthesis.
+ /// </summary>
+ public void getRightParen()
+ {
+ if (offset >= filterLength)
+ {
+ //"Unexpected end of filter",
+ throw new LdapLocalException(ExceptionMessages.UNEXPECTED_END, LdapException.FILTER_ERROR);
+ }
+ if (filter[offset++] != ')')
+ {
+ //"Missing right paren",
+ throw new LdapLocalException(ExceptionMessages.EXPECTING_RIGHT_PAREN, new System.Object[]{filter[offset - 1]}, LdapException.FILTER_ERROR);
+ }
+ return ;
+ }
+
+ /// <summary> Return the current char without advancing the offset pointer. This is
+ /// used by ParseFilterList when determining if there are any more
+ /// Filters in the list.
+ /// </summary>
+ public char peekChar()
+ {
+ if (offset >= filterLength)
+ {
+ //"Unexpected end of filter",
+ throw new LdapLocalException(ExceptionMessages.UNEXPECTED_END, LdapException.FILTER_ERROR);
+ }
+ return filter[offset];
+ }
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcLdapDN.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcLdapDN.cs
new file mode 100755
index 00000000000..76b7b796f41
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcLdapDN.cs
@@ -0,0 +1,61 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.Rfc2251.RfcLdapDN.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+
+namespace Novell.Directory.Ldap.Rfc2251
+{
+
+ /// <summary> Represents an Ldap DN.
+ ///
+ /// <pre>
+ /// LdapDN ::= LdapString
+ /// </pre>
+ /// </summary>
+ public class RfcLdapDN:RfcLdapString
+ {
+
+ //*************************************************************************
+ // Constructors for RfcLdapDN
+ //*************************************************************************
+
+ /// <summary> </summary>
+ public RfcLdapDN(System.String s):base(s)
+ {
+ }
+
+ /// <summary> </summary>
+ [CLSCompliantAttribute(false)]
+ public RfcLdapDN(sbyte[] s):base(s)
+ {
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcLdapMessage.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcLdapMessage.cs
new file mode 100755
index 00000000000..b9f391242e7
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcLdapMessage.cs
@@ -0,0 +1,342 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.Rfc2251.RfcLdapMessage.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+using LdapException = Novell.Directory.Ldap.LdapException;
+using LdapMessage = Novell.Directory.Ldap.LdapMessage;
+using Novell.Directory.Ldap.Asn1;
+
+namespace Novell.Directory.Ldap.Rfc2251
+{
+
+ /// <summary> Represents an Ldap Message.
+ ///
+ /// <pre>
+ /// LdapMessage ::= SEQUENCE {
+ /// messageID MessageID,
+ /// protocolOp CHOICE {
+ /// bindRequest BindRequest,
+ /// bindResponse BindResponse,
+ /// unbindRequest UnbindRequest,
+ /// searchRequest SearchRequest,
+ /// searchResEntry SearchResultEntry,
+ /// searchResDone SearchResultDone,
+ /// searchResRef SearchResultReference,
+ /// modifyRequest ModifyRequest,
+ /// modifyResponse ModifyResponse,
+ /// addRequest AddRequest,
+ /// addResponse AddResponse,
+ /// delRequest DelRequest,
+ /// delResponse DelResponse,
+ /// modDNRequest ModifyDNRequest,
+ /// modDNResponse ModifyDNResponse,
+ /// compareRequest CompareRequest,
+ /// compareResponse CompareResponse,
+ /// abandonRequest AbandonRequest,
+ /// extendedReq ExtendedRequest,
+ /// extendedResp ExtendedResponse },
+ /// controls [0] Controls OPTIONAL }
+ /// </pre>
+ ///
+ /// <br><br>
+ /// Note: The creation of a MessageID should be hidden within the creation of
+ /// an RfcLdapMessage. The MessageID needs to be in sequence, and has an
+ /// upper and lower limit. There is never a case when a user should be
+ /// able to specify the MessageID for an RfcLdapMessage. The MessageID()
+ /// constructor should be package protected. (So the MessageID value
+ /// isn't arbitrarily run up.)
+ /// </summary>
+ public class RfcLdapMessage:Asn1Sequence
+ {
+ /// <summary> Returns this RfcLdapMessage's messageID as an int.</summary>
+ virtual public int MessageID
+ {
+ get
+ {
+ return ((Asn1Integer) get_Renamed(0)).intValue();
+ }
+
+ }
+ /// <summary> Returns this RfcLdapMessage's message type</summary>
+ virtual public int Type
+ {
+ get
+ {
+ return get_Renamed(1).getIdentifier().Tag;
+ }
+
+ }
+ /// <summary> Returns the response associated with this RfcLdapMessage.
+ /// Can be one of RfcLdapResult, RfcBindResponse, RfcExtendedResponse
+ /// all which extend RfcResponse. It can also be
+ /// RfcSearchResultEntry, or RfcSearchResultReference
+ /// </summary>
+ virtual public Asn1Object Response
+ {
+ get
+ {
+ return get_Renamed(1);
+ }
+
+ }
+ /// <summary> Returns the optional Controls for this RfcLdapMessage.</summary>
+ virtual public RfcControls Controls
+ {
+ get
+ {
+ if (size() > 2)
+ return (RfcControls) get_Renamed(2);
+ return null;
+ }
+
+ }
+ /// <summary> Returns the dn of the request, may be null</summary>
+ virtual public System.String RequestDN
+ {
+ get
+ {
+ return ((RfcRequest) op).getRequestDN();
+ }
+
+ }
+ /// <summary> returns the original request in this message
+ ///
+ /// </summary>
+ /// <returns> the original msg request for this response
+ /// </returns>
+ /// <summary> sets the original request in this message
+ ///
+ /// </summary>
+ /// <param name="msg">the original request for this response
+ /// </param>
+ virtual public LdapMessage RequestingMessage
+ {
+ get
+ {
+ return requestMessage;
+ }
+
+ set
+ {
+ requestMessage = value;
+ return ;
+ }
+
+ }
+
+ private Asn1Object op;
+ private RfcControls controls;
+ private LdapMessage requestMessage = null;
+
+ /// <summary> Create an RfcLdapMessage by copying the content array
+ ///
+ /// </summary>
+ /// <param name="origContent">the array list to copy
+ /// </param>
+ /* package */
+ internal RfcLdapMessage(Asn1Object[] origContent, RfcRequest origRequest, System.String dn, System.String filter, bool reference):base(origContent, origContent.Length)
+ {
+
+ set_Renamed(0, new RfcMessageID()); // MessageID has static counter
+
+ RfcRequest req = (RfcRequest) origContent[1];
+ RfcRequest newreq = req.dupRequest(dn, filter, reference);
+ op = (Asn1Object) newreq;
+ set_Renamed(1, (Asn1Object) newreq);
+
+ return ;
+ }
+
+ /// <summary> Create an RfcLdapMessage using the specified Ldap Request.</summary>
+ public RfcLdapMessage(RfcRequest op):this(op, null)
+ {
+ return ;
+ }
+
+ /// <summary> Create an RfcLdapMessage request from input parameters.</summary>
+ public RfcLdapMessage(RfcRequest op, RfcControls controls):base(3)
+ {
+
+ this.op = (Asn1Object) op;
+ this.controls = controls;
+
+ add(new RfcMessageID()); // MessageID has static counter
+ add((Asn1Object) op);
+ if (controls != null)
+ {
+ add(controls);
+ }
+ return ;
+ }
+
+ /// <summary> Create an RfcLdapMessage using the specified Ldap Response.</summary>
+ public RfcLdapMessage(Asn1Sequence op):this(op, null)
+ {
+ return ;
+ }
+
+ /// <summary> Create an RfcLdapMessage response from input parameters.</summary>
+ public RfcLdapMessage(Asn1Sequence op, RfcControls controls):base(3)
+ {
+
+ this.op = op;
+ this.controls = controls;
+
+ add(new RfcMessageID()); // MessageID has static counter
+ add(op);
+ if (controls != null)
+ {
+ add(controls);
+ }
+ return ;
+ }
+
+ /// <summary> Will decode an RfcLdapMessage directly from an InputStream.</summary>
+ [CLSCompliantAttribute(false)]
+ public RfcLdapMessage(Asn1Decoder dec, System.IO.Stream in_Renamed, int len):base(dec, in_Renamed, len)
+ {
+
+ sbyte[] content;
+ System.IO.MemoryStream bais;
+
+ // Decode implicitly tagged protocol operation from an Asn1Tagged type
+ // to its appropriate application type.
+ Asn1Tagged protocolOp = (Asn1Tagged) get_Renamed(1);
+ Asn1Identifier protocolOpId = protocolOp.getIdentifier();
+ content = ((Asn1OctetString) protocolOp.taggedValue()).byteValue();
+ bais = new System.IO.MemoryStream(SupportClass.ToByteArray(content));
+
+ switch (protocolOpId.Tag)
+ {
+
+ case LdapMessage.SEARCH_RESPONSE:
+ set_Renamed(1, new RfcSearchResultEntry(dec, bais, content.Length));
+ break;
+
+ case LdapMessage.SEARCH_RESULT:
+ set_Renamed(1, new RfcSearchResultDone(dec, bais, content.Length));
+ break;
+
+ case LdapMessage.SEARCH_RESULT_REFERENCE:
+ set_Renamed(1, new RfcSearchResultReference(dec, bais, content.Length));
+ break;
+
+ case LdapMessage.ADD_RESPONSE:
+ set_Renamed(1, new RfcAddResponse(dec, bais, content.Length));
+ break;
+
+ case LdapMessage.BIND_RESPONSE:
+ set_Renamed(1, new RfcBindResponse(dec, bais, content.Length));
+ break;
+
+ case LdapMessage.COMPARE_RESPONSE:
+ set_Renamed(1, new RfcCompareResponse(dec, bais, content.Length));
+ break;
+
+ case LdapMessage.DEL_RESPONSE:
+ set_Renamed(1, new RfcDelResponse(dec, bais, content.Length));
+ break;
+
+ case LdapMessage.EXTENDED_RESPONSE:
+ set_Renamed(1, new RfcExtendedResponse(dec, bais, content.Length));
+ break;
+
+ case LdapMessage.MODIFY_RESPONSE:
+ set_Renamed(1, new RfcModifyResponse(dec, bais, content.Length));
+ break;
+
+ case LdapMessage.MODIFY_RDN_RESPONSE:
+ set_Renamed(1, new RfcModifyDNResponse(dec, bais, content.Length));
+ break;
+
+ default:
+ throw new System.SystemException("RfcLdapMessage: Invalid tag: " + protocolOpId.Tag);
+
+ }
+
+ // decode optional implicitly tagged controls from Asn1Tagged type to
+ // to RFC 2251 types.
+ if (size() > 2)
+ {
+ Asn1Tagged controls = (Asn1Tagged) get_Renamed(2);
+ // Asn1Identifier controlsId = protocolOp.getIdentifier();
+ // we could check to make sure we have controls here....
+
+ content = ((Asn1OctetString) controls.taggedValue()).byteValue();
+ bais = new System.IO.MemoryStream(SupportClass.ToByteArray(content));
+ set_Renamed(2, new RfcControls(dec, bais, content.Length));
+ }
+ return ;
+ }
+
+ //*************************************************************************
+ // Accessors
+ //*************************************************************************
+
+ /// <summary> Returns the request associated with this RfcLdapMessage.
+ /// Throws a class cast exception if the RfcLdapMessage is not a request.
+ /// </summary>
+ public RfcRequest getRequest()
+ {
+ return (RfcRequest) get_Renamed(1);
+ }
+
+ public virtual bool isRequest()
+ {
+ return get_Renamed(1) is RfcRequest;
+ }
+
+ /// <summary> Duplicate this message, replacing base dn, filter, and scope if supplied
+ ///
+ /// </summary>
+ /// <param name="dn">the base dn
+ /// <br><br>
+ /// </param>
+ /// <param name="filter">the filter
+ /// <br><br>
+ /// </param>
+ /// <param name="reference">true if a search reference
+ ///
+ /// </param>
+ /// <returns> the object representing the new message
+ /// </returns>
+ public System.Object dupMessage(System.String dn, System.String filter, bool reference)
+ {
+ if ((op == null))
+ {
+ throw new LdapException("DUP_ERROR", LdapException.LOCAL_ERROR, (System.String) null);
+ }
+
+ RfcLdapMessage newMsg = new RfcLdapMessage(toArray(), (RfcRequest) get_Renamed(1), dn, filter, reference);
+ return newMsg;
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcLdapOID.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcLdapOID.cs
new file mode 100755
index 00000000000..9430894cc4d
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcLdapOID.cs
@@ -0,0 +1,54 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.Rfc2251.RfcLdapOID.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+using Novell.Directory.Ldap.Asn1;
+
+namespace Novell.Directory.Ldap.Rfc2251
+{
+
+ /*
+ * Represents an LdapOID.
+ */
+ public class RfcLdapOID:Asn1OctetString
+ {
+ /// <summary> </summary>
+ public RfcLdapOID(System.String s):base(s)
+ {
+ }
+
+ /// <summary> </summary>
+ [CLSCompliantAttribute(false)]
+ public RfcLdapOID(sbyte[] s):base(s)
+ {
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcLdapResult.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcLdapResult.cs
new file mode 100755
index 00000000000..c842049c0d8
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcLdapResult.cs
@@ -0,0 +1,211 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.Rfc2251.RfcLdapResult.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+using Novell.Directory.Ldap.Asn1;
+
+namespace Novell.Directory.Ldap.Rfc2251
+{
+
+ /// <summary> Represents an LdapResult.
+ ///
+ /// <pre>
+ /// LdapResult ::= SEQUENCE {
+ /// resultCode ENUMERATED {
+ /// success (0),
+ /// operationsError (1),
+ /// protocolError (2),
+ /// timeLimitExceeded (3),
+ /// sizeLimitExceeded (4),
+ /// compareFalse (5),
+ /// compareTrue (6),
+ /// authMethodNotSupported (7),
+ /// strongAuthRequired (8),
+ /// -- 9 reserved --
+ /// referral (10), -- new
+ /// adminLimitExceeded (11), -- new
+ /// unavailableCriticalExtension (12), -- new
+ /// confidentialityRequired (13), -- new
+ /// saslBindInProgress (14), -- new
+ /// noSuchAttribute (16),
+ /// undefinedAttributeType (17),
+ /// inappropriateMatching (18),
+ /// constraintViolation (19),
+ /// attributeOrValueExists (20),
+ /// invalidAttributeSyntax (21),
+ /// -- 22-31 unused --
+ /// noSuchObject (32),
+ /// aliasProblem (33),
+ /// invalidDNSyntax (34),
+ /// -- 35 reserved for undefined isLeaf --
+ /// aliasDereferencingProblem (36),
+ /// -- 37-47 unused --
+ /// inappropriateAuthentication (48),
+ ///
+ /// invalidCredentials (49),
+ /// insufficientAccessRights (50),
+ /// busy (51),
+ /// unavailable (52),
+ /// unwillingToPerform (53),
+ /// loopDetect (54),
+ /// -- 55-63 unused --
+ /// namingViolation (64),
+ /// objectClassViolation (65),
+ /// notAllowedOnNonLeaf (66),
+ /// notAllowedOnRDN (67),
+ /// entryAlreadyExists (68),
+ /// objectClassModsProhibited (69),
+ /// -- 70 reserved for CLdap --
+ /// affectsMultipleDSAs (71), -- new
+ /// -- 72-79 unused --
+ /// other (80) },
+ /// -- 81-90 reserved for APIs --
+ /// matchedDN LdapDN,
+ /// errorMessage LdapString,
+ /// referral [3] Referral OPTIONAL }
+ /// </pre>
+ ///
+ /// </summary>
+ public class RfcLdapResult:Asn1Sequence, RfcResponse
+ {
+
+ /// <summary> Context-specific TAG for optional Referral.</summary>
+ public const int REFERRAL = 3;
+
+ //*************************************************************************
+ // Constructors for RfcLdapResult
+ //*************************************************************************
+
+ /// <summary> Constructs an RfcLdapResult from parameters
+ ///
+ /// </summary>
+ /// <param name="resultCode">the result code of the operation
+ ///
+ /// </param>
+ /// <param name="matchedDN">the matched DN returned from the server
+ ///
+ /// </param>
+ /// <param name="errorMessage">the diagnostic message returned from the server
+ /// </param>
+ public RfcLdapResult(Asn1Enumerated resultCode, RfcLdapDN matchedDN, RfcLdapString errorMessage):this(resultCode, matchedDN, errorMessage, null)
+ {
+ return ;
+ }
+
+ /// <summary> Constructs an RfcLdapResult from parameters
+ ///
+ /// </summary>
+ /// <param name="resultCode">the result code of the operation
+ ///
+ /// </param>
+ /// <param name="matchedDN">the matched DN returned from the server
+ ///
+ /// </param>
+ /// <param name="errorMessage">the diagnostic message returned from the server
+ ///
+ /// </param>
+ /// <param name="referral">the referral(s) returned by the server
+ /// </param>
+ public RfcLdapResult(Asn1Enumerated resultCode, RfcLdapDN matchedDN, RfcLdapString errorMessage, RfcReferral referral):base(4)
+ {
+ add(resultCode);
+ add(matchedDN);
+ add(errorMessage);
+ if (referral != null)
+ add(referral);
+ return ;
+ }
+
+ /// <summary> Constructs an RfcLdapResult from the inputstream</summary>
+ [CLSCompliantAttribute(false)]
+ public RfcLdapResult(Asn1Decoder dec, System.IO.Stream in_Renamed, int len):base(dec, in_Renamed, len)
+ {
+
+ // Decode optional referral from Asn1OctetString to Referral.
+ if (size() > 3)
+ {
+ Asn1Tagged obj = (Asn1Tagged) get_Renamed(3);
+ Asn1Identifier id = obj.getIdentifier();
+ if (id.Tag == RfcLdapResult.REFERRAL)
+ {
+ sbyte[] content = ((Asn1OctetString) obj.taggedValue()).byteValue();
+ System.IO.MemoryStream bais = new System.IO.MemoryStream(SupportClass.ToByteArray(content));
+ set_Renamed(3, new RfcReferral(dec, bais, content.Length));
+ }
+ }
+ return ;
+ }
+
+ //*************************************************************************
+ // Accessors
+ //*************************************************************************
+
+ /// <summary> Returns the result code from the server
+ ///
+ /// </summary>
+ /// <returns> the result code
+ /// </returns>
+ public Asn1Enumerated getResultCode()
+ {
+ return (Asn1Enumerated) get_Renamed(0);
+ }
+
+ /// <summary> Returns the matched DN from the server
+ ///
+ /// </summary>
+ /// <returns> the matched DN
+ /// </returns>
+ public RfcLdapDN getMatchedDN()
+ {
+ return new RfcLdapDN(((Asn1OctetString) get_Renamed(1)).byteValue());
+ }
+
+ /// <summary> Returns the error message from the server
+ ///
+ /// </summary>
+ /// <returns> the server error message
+ /// </returns>
+ public RfcLdapString getErrorMessage()
+ {
+ return new RfcLdapString(((Asn1OctetString) get_Renamed(2)).byteValue());
+ }
+
+ /// <summary> Returns the referral(s) from the server
+ ///
+ /// </summary>
+ /// <returns> the referral(s)
+ /// </returns>
+ public RfcReferral getReferral()
+ {
+ return (size() > 3)?(RfcReferral) get_Renamed(3):null;
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcLdapString.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcLdapString.cs
new file mode 100755
index 00000000000..aecb61fa80c
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcLdapString.cs
@@ -0,0 +1,59 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.Rfc2251.RfcLdapString.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+using Novell.Directory.Ldap.Asn1;
+
+namespace Novell.Directory.Ldap.Rfc2251
+{
+
+ /// <summary> Represnts an Ldap String.</summary>
+ public class RfcLdapString:Asn1OctetString
+ {
+
+ /// <summary> </summary>
+ public RfcLdapString(System.String s):base(s)
+ {
+ }
+
+ /// <summary> </summary>
+ [CLSCompliantAttribute(false)]
+ public RfcLdapString(sbyte[] ba):base(ba)
+ {
+ }
+
+ /// <summary> </summary>
+ [CLSCompliantAttribute(false)]
+ public RfcLdapString(Asn1Decoder dec, System.IO.Stream in_Renamed, int len):base(dec, in_Renamed, len)
+ {
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcLdapURL.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcLdapURL.cs
new file mode 100755
index 00000000000..235a6994553
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcLdapURL.cs
@@ -0,0 +1,55 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.Rfc2251.RfcLdapURL.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+
+namespace Novell.Directory.Ldap.Rfc2251
+{
+
+ /// <summary> Represents an Ldap URL.
+ ///
+ /// <pre>
+ /// LdapURL ::= LdapString -- limited to characters permitted in URLs
+ /// </pre>
+ /// </summary>
+ public class RfcLdapURL:RfcLdapString
+ {
+
+ //*************************************************************************
+ // Constructor for RfcLdapURL
+ //*************************************************************************
+
+ /// <summary> </summary>
+ public RfcLdapURL(System.String s):base(s)
+ {
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcMatchingRuleAssertion.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcMatchingRuleAssertion.cs
new file mode 100755
index 00000000000..9f4b19525dd
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcMatchingRuleAssertion.cs
@@ -0,0 +1,94 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.Rfc2251.RfcMatchingRuleAssertion.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+using Novell.Directory.Ldap.Asn1;
+
+namespace Novell.Directory.Ldap.Rfc2251
+{
+
+ /// <summary> Represents an Ldap Matching Rule Assertion.
+ ///
+ /// <pre>
+ /// MatchingRuleAssertion ::= SEQUENCE {
+ /// matchingRule [1] MatchingRuleId OPTIONAL,
+ /// type [2] AttributeDescription OPTIONAL,
+ /// matchValue [3] AssertionValue,
+ /// dnAttributes [4] BOOLEAN DEFAULT FALSE }
+ /// </pre>
+ /// </summary>
+ public class RfcMatchingRuleAssertion:Asn1Sequence
+ {
+
+ //*************************************************************************
+ // Constructors for MatchingRuleAssertion
+ //*************************************************************************
+
+ /// <summary> Creates a MatchingRuleAssertion with the only required parameter.
+ ///
+ /// </summary>
+ /// <param name="matchValue">The assertion value.
+ /// </param>
+ public RfcMatchingRuleAssertion(RfcAssertionValue matchValue):this(null, null, matchValue, null)
+ {
+ }
+
+ /// <summary> Creates a MatchingRuleAssertion.
+ ///
+ /// The value null may be passed for an optional value that is not used.
+ ///
+ /// </summary>
+ /// <param name="matchValue">The assertion value.
+ /// </param>
+ /// <param name="matchingRule">Optional matching rule.
+ /// </param>
+ /// <param name="type">Optional attribute description.
+ /// </param>
+ /// <param name="dnAttributes">Asn1Boolean value. (default false)
+ /// </param>
+ public RfcMatchingRuleAssertion(RfcMatchingRuleId matchingRule, RfcAttributeDescription type, RfcAssertionValue matchValue, Asn1Boolean dnAttributes):base(4)
+ {
+ if (matchingRule != null)
+ add(new Asn1Tagged(new Asn1Identifier(Asn1Identifier.CONTEXT, false, 1), matchingRule, false));
+
+ if (type != null)
+ add(new Asn1Tagged(new Asn1Identifier(Asn1Identifier.CONTEXT, false, 2), type, false));
+
+ add(new Asn1Tagged(new Asn1Identifier(Asn1Identifier.CONTEXT, false, 3), matchValue, false));
+
+ // if dnAttributes if false, that is the default value and we must not
+ // encode it. (See RFC 2251 5.1 number 4)
+ if (dnAttributes != null && dnAttributes.booleanValue())
+ add(new Asn1Tagged(new Asn1Identifier(Asn1Identifier.CONTEXT, false, 4), dnAttributes, false));
+ return ;
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcMatchingRuleId.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcMatchingRuleId.cs
new file mode 100755
index 00000000000..575538cb7e6
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcMatchingRuleId.cs
@@ -0,0 +1,51 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.Rfc2251.RfcMatchingRuleId.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+
+namespace Novell.Directory.Ldap.Rfc2251
+{
+
+ /// <summary> Represents an Ldap Matching Rule ID.
+ ///
+ /// <pre>
+ /// MatchingRuleId ::= LdapString
+ /// </pre>
+ /// </summary>
+ public class RfcMatchingRuleId:RfcLdapString
+ {
+
+ /// <summary> Constructs a MatchingRuleId from a String.</summary>
+ public RfcMatchingRuleId(System.String s):base(s)
+ {
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcMessageID.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcMessageID.cs
new file mode 100755
index 00000000000..d64b9902e24
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcMessageID.cs
@@ -0,0 +1,95 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.Rfc2251.RfcMessageID.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+using Novell.Directory.Ldap.Asn1;
+
+namespace Novell.Directory.Ldap.Rfc2251
+{
+
+ /// <summary> Represents an Ldap Message ID.
+ ///
+ /// <pre>
+ /// MessageID ::= INTEGER (0 .. maxInt)
+ ///
+ /// maxInt INTEGER ::= 2147483647 -- (2^^31 - 1) --
+ ///
+ /// Note: The creation of a MessageID should be hidden within the creation of
+ /// an RfcLdapMessage. The MessageID needs to be in sequence, and has an
+ /// upper and lower limit. There is never a case when a user should be
+ /// able to specify the MessageID for an RfcLdapMessage. The MessageID()
+ /// class should be package protected. (So the MessageID value isn't
+ /// arbitrarily run up.)
+ /// </pre>
+ /// </summary>
+ class RfcMessageID:Asn1Integer
+ {
+ /// <summary> Increments the message number atomically
+ ///
+ /// </summary>
+ /// <returns> the new message number
+ /// </returns>
+ private static int MessageID
+ {
+ get
+ {
+ lock (lock_Renamed)
+ {
+ return (messageID < System.Int32.MaxValue)?++messageID:(messageID = 1);
+ }
+ }
+
+ }
+
+ private static int messageID = 0;
+ private static System.Object lock_Renamed;
+
+ /// <summary> Creates a MessageID with an auto incremented Asn1Integer value.
+ ///
+ /// Bounds: (0 .. 2,147,483,647) (2^^31 - 1 or Integer.MAX_VALUE)
+ ///
+ /// MessageID zero is never used in this implementation. Always
+ /// start the messages with one.
+ /// </summary>
+ protected internal RfcMessageID():base(MessageID)
+ {
+ }
+
+ /// <summary> Creates a MessageID with a specified int value.</summary>
+ protected internal RfcMessageID(int i):base(i)
+ {
+ }
+ static RfcMessageID()
+ {
+ lock_Renamed = new System.Object();
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcModifyDNRequest.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcModifyDNRequest.cs
new file mode 100755
index 00000000000..11646e47670
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcModifyDNRequest.cs
@@ -0,0 +1,108 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.Rfc2251.RfcModifyDNRequest.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+using Novell.Directory.Ldap.Asn1;
+using Novell.Directory.Ldap;
+
+namespace Novell.Directory.Ldap.Rfc2251
+{
+
+ /// <summary> Represents an LDAM MOdify DN Request.
+ ///
+ /// <pre>
+ /// ModifyDNRequest ::= [APPLICATION 12] SEQUENCE {
+ /// entry LdapDN,
+ /// newrdn RelativeLdapDN,
+ /// deleteoldrdn BOOLEAN,
+ /// newSuperior [0] LdapDN OPTIONAL }
+ /// </pre>
+ /// </summary>
+ public class RfcModifyDNRequest:Asn1Sequence, RfcRequest
+ {
+
+ //*************************************************************************
+ // Constructors for ModifyDNRequest
+ //*************************************************************************
+
+ /// <summary> </summary>
+ public RfcModifyDNRequest(RfcLdapDN entry, RfcRelativeLdapDN newrdn, Asn1Boolean deleteoldrdn):this(entry, newrdn, deleteoldrdn, null)
+ {
+ }
+
+ /// <summary> </summary>
+ public RfcModifyDNRequest(RfcLdapDN entry, RfcRelativeLdapDN newrdn, Asn1Boolean deleteoldrdn, RfcLdapDN newSuperior):base(4)
+ {
+ add(entry);
+ add(newrdn);
+ add(deleteoldrdn);
+ if (newSuperior != null)
+ add(newSuperior);
+ }
+
+ /// <summary> Constructs a new Delete Request copying from the ArrayList of
+ /// an existing request.
+ /// </summary>
+ /* package */
+ internal RfcModifyDNRequest(Asn1Object[] origRequest, System.String base_Renamed):base(origRequest, origRequest.Length)
+ {
+ // Replace the base if specified, otherwise keep original base
+ if ((System.Object) base_Renamed != null)
+ {
+ set_Renamed(0, new RfcLdapDN(base_Renamed));
+ }
+ return ;
+ }
+ //*************************************************************************
+ // Accessors
+ //*************************************************************************
+
+ /// <summary> Override getIdentifier to return an application-wide id.
+ ///
+ /// <pre>
+ /// ID = CLASS: APPLICATION, FORM: CONSTRUCTED, TAG: 12.
+ /// </pre>
+ /// </summary>
+ public override Asn1Identifier getIdentifier()
+ {
+ return new Asn1Identifier(Asn1Identifier.APPLICATION, true, LdapMessage.MODIFY_RDN_REQUEST);
+ }
+
+ public RfcRequest dupRequest(System.String base_Renamed, System.String filter, bool request)
+ {
+ return new RfcModifyDNRequest(toArray(), base_Renamed);
+ }
+ public System.String getRequestDN()
+ {
+ return ((RfcLdapDN) get_Renamed(0)).stringValue();
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcModifyDNResponse.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcModifyDNResponse.cs
new file mode 100755
index 00000000000..daccc9a9227
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcModifyDNResponse.cs
@@ -0,0 +1,87 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.Rfc2251.RfcModifyDNResponse.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+using Novell.Directory.Ldap.Asn1;
+using Novell.Directory.Ldap;
+
+namespace Novell.Directory.Ldap.Rfc2251
+{
+
+ /// <summary> Represents an Ldap Modify DN Request.
+ ///
+ /// <pre>
+ /// ModifyDNResponse ::= [APPLICATION 13] LdapResult
+ /// </pre>
+ /// </summary>
+ public class RfcModifyDNResponse:RfcLdapResult
+ {
+
+ //*************************************************************************
+ // Constructor for ModifyDNResponse
+ //*************************************************************************
+
+ /// <summary> Create a ModifyDNResponse by decoding it from an InputStream</summary>
+ [CLSCompliantAttribute(false)]
+ public RfcModifyDNResponse(Asn1Decoder dec, System.IO.Stream in_Renamed, int len):base(dec, in_Renamed, len)
+ {
+ }
+
+ /// <summary> Constructs an RfcModifyDNResponse from parameters.
+ ///
+ /// </summary>
+ /// <param name="resultCode">the result code of the operation
+ ///
+ /// </param>
+ /// <param name="matchedDN">the matched DN returned from the server
+ ///
+ /// </param>
+ /// <param name="errorMessage">the diagnostic message returned from the server
+ ///
+ /// </param>
+ /// <param name="referral">the referral(s) returned by the server
+ /// </param>
+ public RfcModifyDNResponse(Asn1Enumerated resultCode, RfcLdapDN matchedDN, RfcLdapString errorMessage, RfcReferral referral):base(resultCode, matchedDN, errorMessage, referral)
+ {
+ return ;
+ }
+
+ //*************************************************************************
+ // Accessors
+ //*************************************************************************
+
+ /// <summary> Override getIdentifier to return an application-wide id.</summary>
+ public override Asn1Identifier getIdentifier()
+ {
+ return new Asn1Identifier(Asn1Identifier.APPLICATION, true, LdapMessage.MODIFY_RDN_RESPONSE);
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcModifyRequest.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcModifyRequest.cs
new file mode 100755
index 00000000000..85667f0e076
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcModifyRequest.cs
@@ -0,0 +1,118 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.Rfc2251.RfcModifyRequest.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+using Novell.Directory.Ldap.Asn1;
+using Novell.Directory.Ldap;
+
+namespace Novell.Directory.Ldap.Rfc2251
+{
+
+ /// <summary> Represents an Ldap Modify Request.
+ ///
+ /// <pre>
+ /// ModifyRequest ::= [APPLICATION 6] SEQUENCE {
+ /// object LdapDN,
+ /// modification SEQUENCE OF SEQUENCE {
+ /// operation ENUMERATED {
+ /// add (0),
+ /// delete (1),
+ /// replace (2) },
+ /// modification AttributeTypeAndValues } }
+ /// </pre>
+ /// </summary>
+ public class RfcModifyRequest:Asn1Sequence, RfcRequest
+ {
+ /// <summary> Return the Modifications for this request
+ ///
+ /// </summary>
+ /// <returns> the modifications for this request.
+ /// </returns>
+ virtual public Asn1SequenceOf Modifications
+ {
+ get
+ {
+ return (Asn1SequenceOf) get_Renamed(1);
+ }
+
+ }
+
+ //*************************************************************************
+ // Constructor for ModifyRequest
+ //*************************************************************************
+
+ /// <summary> </summary>
+ public RfcModifyRequest(RfcLdapDN object_Renamed, Asn1SequenceOf modification):base(2)
+ {
+ add(object_Renamed);
+ add(modification);
+ return ;
+ }
+
+ /// <summary> Constructs a new Modify Request copying from the ArrayList of
+ /// an existing request.
+ /// </summary>
+ /* package */
+ internal RfcModifyRequest(Asn1Object[] origRequest, System.String base_Renamed):base(origRequest, origRequest.Length)
+ {
+ // Replace the base if specified, otherwise keep original base
+ if ((System.Object) base_Renamed != null)
+ {
+ set_Renamed(0, new RfcLdapDN(base_Renamed));
+ }
+ return ;
+ }
+ //*************************************************************************
+ // Accessors
+ //*************************************************************************
+
+ /// <summary> Override getIdentifier to return an application-wide id.</summary>
+ public override Asn1Identifier getIdentifier()
+ {
+ return new Asn1Identifier(Asn1Identifier.APPLICATION, true, LdapMessage.MODIFY_REQUEST);
+ }
+
+ public RfcRequest dupRequest(System.String base_Renamed, System.String filter, bool request)
+ {
+ return new RfcModifyRequest(toArray(), base_Renamed);
+ }
+
+ /// <summary> Return the String value of the DN associated with this request
+ ///
+ /// </summary>
+ /// <returns> the DN for this request.
+ /// </returns>
+ public System.String getRequestDN()
+ {
+ return ((RfcLdapDN) get_Renamed(0)).stringValue();
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcModifyResponse.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcModifyResponse.cs
new file mode 100755
index 00000000000..3a9516d9709
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcModifyResponse.cs
@@ -0,0 +1,89 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.Rfc2251.RfcModifyResponse.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+using Novell.Directory.Ldap.Asn1;
+using Novell.Directory.Ldap;
+
+namespace Novell.Directory.Ldap.Rfc2251
+{
+
+ /// <summary> Represents an Ldap Modify Response.
+ ///
+ /// <pre>
+ /// ModifyResponse ::= [APPLICATION 7] LdapResult
+ /// </pre>
+ /// </summary>
+ public class RfcModifyResponse:RfcLdapResult
+ {
+
+ //*************************************************************************
+ // Constructor for ModifyResponse
+ //*************************************************************************
+
+ /// <summary> The only time a client will create a ModifyResponse is when it is
+ /// decoding it from an InputStream
+ /// </summary>
+ [CLSCompliantAttribute(false)]
+ public RfcModifyResponse(Asn1Decoder dec, System.IO.Stream in_Renamed, int len):base(dec, in_Renamed, len)
+ {
+ }
+
+ /// <summary> Constructs an RfcModifyResponse from parameters.
+ ///
+ /// </summary>
+ /// <param name="resultCode">the result code of the operation
+ ///
+ /// </param>
+ /// <param name="matchedDN">the matched DN returned from the server
+ ///
+ /// </param>
+ /// <param name="errorMessage">the diagnostic message returned from the server
+ ///
+ /// </param>
+ /// <param name="referral">the referral(s) returned by the server
+ /// </param>
+ public RfcModifyResponse(Asn1Enumerated resultCode, RfcLdapDN matchedDN, RfcLdapString errorMessage, RfcReferral referral):base(resultCode, matchedDN, errorMessage, referral)
+ {
+ return ;
+ }
+
+ //*************************************************************************
+ // Accessors
+ //*************************************************************************
+
+ /// <summary> Override getIdentifier to return an application-wide id.</summary>
+ public override Asn1Identifier getIdentifier()
+ {
+ return new Asn1Identifier(Asn1Identifier.APPLICATION, true, LdapMessage.MODIFY_RESPONSE);
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcReferral.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcReferral.cs
new file mode 100755
index 00000000000..6ac7e56288a
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcReferral.cs
@@ -0,0 +1,68 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.Rfc2251.RfcReferral.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+using Novell.Directory.Ldap.Asn1;
+
+namespace Novell.Directory.Ldap.Rfc2251
+{
+
+ /// <summary> Represents an Ldap Referral.
+ ///
+ /// <pre>
+ /// Referral ::= SEQUENCE OF LdapURL
+ /// </pre>
+ /// </summary>
+ public class RfcReferral:Asn1SequenceOf
+ {
+
+ //*************************************************************************
+ // Constructor for Referral
+ //*************************************************************************
+
+ /// <summary> The only time a Referral object is constructed, is when we are
+ /// decoding an RfcLdapResult or COMPONENTS OF RfcLdapResult.
+ /// </summary>
+ [CLSCompliantAttribute(false)]
+ public RfcReferral(Asn1Decoder dec, System.IO.Stream in_Renamed, int len):base(dec, in_Renamed, len)
+ {
+
+ //convert from Asn1OctetString to RfcLdapURL here (then look at
+ // LdapResponse.getReferrals())
+ }
+
+ //*************************************************************************
+ // Accessors
+ //*************************************************************************
+
+ // inherited from SequenceOf
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcRelativeLdapDN.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcRelativeLdapDN.cs
new file mode 100755
index 00000000000..fb17d95e960
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcRelativeLdapDN.cs
@@ -0,0 +1,48 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.Rfc2251.RfcRelativeLdapDN.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+
+namespace Novell.Directory.Ldap.Rfc2251
+{
+
+ /*
+ * Represents an Ldap Relative DN.
+ */
+ public class RfcRelativeLdapDN:RfcLdapString
+ {
+
+ /// <summary> </summary>
+ public RfcRelativeLdapDN(System.String s):base(s)
+ {
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcRequest.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcRequest.cs
new file mode 100755
index 00000000000..86efd5057bd
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcRequest.cs
@@ -0,0 +1,49 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.Rfc2251.RfcRequest.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+
+
+namespace Novell.Directory.Ldap.Rfc2251
+{
+
+ /// <summary> This interface represents Protocol Operations that are requests from a
+ /// client.
+ /// </summary>
+ public interface RfcRequest
+ {
+ /// <summary> Builds a new request using the data from the this object.</summary>
+ RfcRequest dupRequest(System.String base_Renamed, System.String filter, bool reference);
+
+ /// <summary> Builds a new request using the data from the this object.</summary>
+ System.String getRequestDN();
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcResponse.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcResponse.cs
new file mode 100755
index 00000000000..4e1d69c628d
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcResponse.cs
@@ -0,0 +1,59 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.Rfc2251.RfcResponse.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+using Novell.Directory.Ldap.Asn1;
+
+namespace Novell.Directory.Ldap.Rfc2251
+{
+
+ /// <summary> This interface represents RfcLdapMessages that contain a response from a
+ /// server.
+ ///
+ /// <p>If the protocol operation of the RfcLdapMessage is of this type,
+ /// it contains at least an RfcLdapResult.</p>
+ /// </summary>
+ public interface RfcResponse
+ {
+
+ /// <summary> </summary>
+ Asn1Enumerated getResultCode();
+
+ /// <summary> </summary>
+ RfcLdapDN getMatchedDN();
+
+ /// <summary> </summary>
+ RfcLdapString getErrorMessage();
+
+ /// <summary> </summary>
+ RfcReferral getReferral();
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcSaslCredentials.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcSaslCredentials.cs
new file mode 100755
index 00000000000..c2507cdaeaa
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcSaslCredentials.cs
@@ -0,0 +1,66 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.Rfc2251.RfcSaslCredentials.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+using Novell.Directory.Ldap.Asn1;
+
+namespace Novell.Directory.Ldap.Rfc2251
+{
+
+ /// <summary> Represents Ldap Sasl Credentials.
+ ///
+ /// <pre>
+ /// SaslCredentials ::= SEQUENCE {
+ /// mechanism LdapString,
+ /// credentials OCTET STRING OPTIONAL }
+ /// </pre>
+ /// </summary>
+ public class RfcSaslCredentials:Asn1Sequence
+ {
+
+ //*************************************************************************
+ // Constructors for SaslCredentials
+ //*************************************************************************
+
+ /// <summary> </summary>
+ public RfcSaslCredentials(RfcLdapString mechanism):this(mechanism, null)
+ {
+ }
+
+ /// <summary> </summary>
+ public RfcSaslCredentials(RfcLdapString mechanism, Asn1OctetString credentials):base(2)
+ {
+ add(mechanism);
+ if (credentials != null)
+ add(credentials);
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcSearchRequest.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcSearchRequest.cs
new file mode 100755
index 00000000000..b67be6f75e3
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcSearchRequest.cs
@@ -0,0 +1,139 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.Rfc2251.RfcSearchRequest.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+using LdapException = Novell.Directory.Ldap.LdapException;
+using Novell.Directory.Ldap;
+using Novell.Directory.Ldap.Asn1;
+
+namespace Novell.Directory.Ldap.Rfc2251
+{
+
+ /// <summary> Represents an Ldap Search Request.
+ ///
+ /// <pre>
+ /// SearchRequest ::= [APPLICATION 3] SEQUENCE {
+ /// baseObject LdapDN,
+ /// scope ENUMERATED {
+ /// baseObject (0),
+ /// singleLevel (1),
+ /// wholeSubtree (2) },
+ /// derefAliases ENUMERATED {
+ /// neverDerefAliases (0),
+ /// derefInSearching (1),
+ /// derefFindingBaseObj (2),
+ /// derefAlways (3) },
+ /// sizeLimit INTEGER (0 .. maxInt),
+ /// timeLimit INTEGER (0 .. maxInt),
+ /// typesOnly BOOLEAN,
+ /// filter Filter,
+ /// attributes AttributeDescriptionList }
+ /// </pre>
+ /// </summary>
+ public class RfcSearchRequest:Asn1Sequence, RfcRequest
+ {
+
+ //*************************************************************************
+ // Constructors for SearchRequest
+ //*************************************************************************
+
+ /*
+ *
+ */
+ public RfcSearchRequest(RfcLdapDN baseObject, Asn1Enumerated scope, Asn1Enumerated derefAliases, Asn1Integer sizeLimit, Asn1Integer timeLimit, Asn1Boolean typesOnly, RfcFilter filter, RfcAttributeDescriptionList attributes):base(8)
+ {
+ add(baseObject);
+ add(scope);
+ add(derefAliases);
+ add(sizeLimit);
+ add(timeLimit);
+ add(typesOnly);
+ add(filter);
+ add(attributes);
+ return ;
+ }
+
+ /// <summary> Constructs a new Search Request copying from an existing request.</summary>
+ /* package */
+ internal RfcSearchRequest(Asn1Object[] origRequest, System.String base_Renamed, System.String filter, bool request):base(origRequest, origRequest.Length)
+ {
+
+ // Replace the base if specified, otherwise keep original base
+ if ((System.Object) base_Renamed != null)
+ {
+ set_Renamed(0, new RfcLdapDN(base_Renamed));
+ }
+
+ // If this is a reencode of a search continuation reference
+ // and if original scope was one-level, we need to change the scope to
+ // base so we don't return objects a level deeper than requested
+ if (request)
+ {
+ int scope = ((Asn1Enumerated) origRequest[1]).intValue();
+ if (scope == LdapConnection.SCOPE_ONE)
+ {
+ set_Renamed(1, new Asn1Enumerated(LdapConnection.SCOPE_BASE));
+ }
+ }
+ // Replace the filter if specified, otherwise keep original filter
+ if ((System.Object) filter != null)
+ {
+ set_Renamed(6, new RfcFilter(filter));
+ }
+ return ;
+ }
+
+ //*************************************************************************
+ // Accessors
+ //*************************************************************************
+
+ /// <summary> Override getIdentifier to return an application-wide id.
+ ///
+ /// <pre>
+ /// ID = CLASS: APPLICATION, FORM: CONSTRUCTED, TAG: 3. (0x63)
+ /// </pre>
+ /// </summary>
+ public override Asn1Identifier getIdentifier()
+ {
+ return new Asn1Identifier(Asn1Identifier.APPLICATION, true, LdapMessage.SEARCH_REQUEST);
+ }
+
+ public RfcRequest dupRequest(System.String base_Renamed, System.String filter, bool request)
+ {
+ return new RfcSearchRequest(toArray(), base_Renamed, filter, request);
+ }
+
+ public System.String getRequestDN()
+ {
+ return ((RfcLdapDN) get_Renamed(0)).stringValue();
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcSearchResultDone.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcSearchResultDone.cs
new file mode 100755
index 00000000000..b7f2314cb47
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcSearchResultDone.cs
@@ -0,0 +1,88 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.Rfc2251.RfcSearchResultDone.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+using Novell.Directory.Ldap;
+using Novell.Directory.Ldap.Asn1;
+
+namespace Novell.Directory.Ldap.Rfc2251
+{
+
+ /// <summary> Represents an Ldap Search Result Done Response.
+ ///
+ /// <pre>
+ /// SearchResultDone ::= [APPLICATION 5] LdapResult
+ /// </pre>
+ /// </summary>
+ public class RfcSearchResultDone:RfcLdapResult
+ {
+
+ //*************************************************************************
+ // Constructors for SearchResultDone
+ //*************************************************************************
+
+ /// <summary> Decode a search result done from the input stream.</summary>
+ [CLSCompliantAttribute(false)]
+ public RfcSearchResultDone(Asn1Decoder dec, System.IO.Stream in_Renamed, int len):base(dec, in_Renamed, len)
+ {
+ return ;
+ }
+
+ /// <summary> Constructs an RfcSearchResultDone from parameters.
+ ///
+ /// </summary>
+ /// <param name="resultCode">the result code of the operation
+ ///
+ /// </param>
+ /// <param name="matchedDN">the matched DN returned from the server
+ ///
+ /// </param>
+ /// <param name="errorMessage">the diagnostic message returned from the server
+ ///
+ /// </param>
+ /// <param name="referral">the referral(s) returned by the server
+ /// </param>
+ public RfcSearchResultDone(Asn1Enumerated resultCode, RfcLdapDN matchedDN, RfcLdapString errorMessage, RfcReferral referral):base(resultCode, matchedDN, errorMessage, referral)
+ {
+ return ;
+ }
+
+ //*************************************************************************
+ // Accessors
+ //*************************************************************************
+
+ /// <summary> Override getIdentifier to return an application-wide id.</summary>
+ public override Asn1Identifier getIdentifier()
+ {
+ return new Asn1Identifier(Asn1Identifier.APPLICATION, true, LdapMessage.SEARCH_RESULT);
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcSearchResultEntry.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcSearchResultEntry.cs
new file mode 100755
index 00000000000..9a127c916ab
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcSearchResultEntry.cs
@@ -0,0 +1,98 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.Rfc2251.RfcSearchResultEntry.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+using Novell.Directory.Ldap;
+using Novell.Directory.Ldap.Asn1;
+
+namespace Novell.Directory.Ldap.Rfc2251
+{
+
+ /// <summary> Represents an Ldap Search Result Entry.
+ ///
+ /// <pre>
+ /// SearchResultEntry ::= [APPLICATION 4] SEQUENCE {
+ /// objectName LdapDN,
+ /// attributes PartialAttributeList }
+ /// </pre>
+ /// </summary>
+ public class RfcSearchResultEntry:Asn1Sequence
+ {
+ /// <summary> </summary>
+ virtual public Asn1OctetString ObjectName
+ {
+ get
+ {
+ return (Asn1OctetString) get_Renamed(0);
+ }
+
+ }
+ /// <summary> </summary>
+ virtual public Asn1Sequence Attributes
+ {
+ get
+ {
+ return (Asn1Sequence) get_Renamed(1);
+ }
+
+ }
+
+ //*************************************************************************
+ // Constructors for SearchResultEntry
+ //*************************************************************************
+
+ /// <summary> The only time a client will create a SearchResultEntry is when it is
+ /// decoding it from an InputStream
+ /// </summary>
+ [CLSCompliantAttribute(false)]
+ public RfcSearchResultEntry(Asn1Decoder dec, System.IO.Stream in_Renamed, int len):base(dec, in_Renamed, len)
+ {
+
+ // Decode objectName
+ // set(0, new RfcLdapDN(((Asn1OctetString)get(0)).stringValue()));
+
+ // Create PartitalAttributeList. This does not need to be decoded, only
+ // typecast.
+ // set(1, new PartitalAttributeList());
+ return ;
+ }
+
+ //*************************************************************************
+ // Accessors
+ //*************************************************************************
+
+ /// <summary> Override getIdentifier to return an application-wide id.</summary>
+ public override Asn1Identifier getIdentifier()
+ {
+ return new Asn1Identifier(Asn1Identifier.APPLICATION, true, LdapMessage.SEARCH_RESPONSE);
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcSearchResultReference.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcSearchResultReference.cs
new file mode 100755
index 00000000000..e17d4e2dd3b
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcSearchResultReference.cs
@@ -0,0 +1,71 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.Rfc2251.RfcSearchResultReference.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+using Novell.Directory.Ldap;
+using Novell.Directory.Ldap.Asn1;
+
+namespace Novell.Directory.Ldap.Rfc2251
+{
+
+ /// <summary> Represents an Ldap Search Result Reference.
+ ///
+ /// <pre>
+ /// SearchResultReference ::= [APPLICATION 19] SEQUENCE OF LdapURL
+ /// </pre>
+ /// </summary>
+ public class RfcSearchResultReference:Asn1SequenceOf
+ {
+
+ //*************************************************************************
+ // Constructors for SearchResultReference
+ //*************************************************************************
+
+ /// <summary> The only time a client will create a SearchResultReference is when it is
+ /// decoding it from an InputStream
+ /// </summary>
+ [CLSCompliantAttribute(false)]
+ public RfcSearchResultReference(Asn1Decoder dec, System.IO.Stream in_Renamed, int len):base(dec, in_Renamed, len)
+ {
+ return ;
+ }
+
+ //*************************************************************************
+ // Accessors
+ //*************************************************************************
+
+ /// <summary> Override getIdentifier to return an application-wide id.</summary>
+ public override Asn1Identifier getIdentifier()
+ {
+ return new Asn1Identifier(Asn1Identifier.APPLICATION, true, LdapMessage.SEARCH_RESULT_REFERENCE);
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcSubstringFilter.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcSubstringFilter.cs
new file mode 100755
index 00000000000..fb8e6338b78
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcSubstringFilter.cs
@@ -0,0 +1,64 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.Rfc2251.RfcSubstringFilter.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+using Novell.Directory.Ldap.Asn1;
+
+namespace Novell.Directory.Ldap.Rfc2251
+{
+
+ /// <summary> Represents an Ldap Substring Filter.
+ ///
+ /// <pre>
+ /// SubstringFilter ::= SEQUENCE {
+ /// type AttributeDescription,
+ /// -- at least one must be present
+ /// substrings SEQUENCE OF CHOICE {
+ /// initial [0] LdapString,
+ /// any [1] LdapString,
+ /// final [2] LdapString } }
+ /// </pre>
+ /// </summary>
+ public class RfcSubstringFilter:Asn1Sequence
+ {
+
+ //*************************************************************************
+ // Constructors for SubstringFilter
+ //*************************************************************************
+
+ /// <summary> </summary>
+ public RfcSubstringFilter(RfcAttributeDescription type, Asn1SequenceOf substrings):base(2)
+ {
+ add(type);
+ add(substrings);
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcUnbindRequest.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcUnbindRequest.cs
new file mode 100755
index 00000000000..9a7ff6f08e1
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcUnbindRequest.cs
@@ -0,0 +1,83 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.Rfc2251.RfcUnbindRequest.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+using Novell.Directory.Ldap.Asn1;
+using Novell.Directory.Ldap;
+using Novell.Directory.Ldap.Utilclass;
+
+namespace Novell.Directory.Ldap.Rfc2251
+{
+
+ /// <summary> Represents the Ldap Unbind request.
+ ///
+ /// <pre>
+ /// UnbindRequest ::= [APPLICATION 2] NULL
+ /// </pre>
+ /// </summary>
+ public class RfcUnbindRequest:Asn1Null, RfcRequest
+ {
+
+ //*************************************************************************
+ // Constructor for UnbindRequest
+ //*************************************************************************
+
+ /// <summary> Construct an RfCUnbind Request</summary>
+ public RfcUnbindRequest():base()
+ {
+ return ;
+ }
+
+ //*************************************************************************
+ // Accessors
+ //*************************************************************************
+
+ /// <summary> Override getIdentifier to return an application-wide id.
+ /// <pre>
+ /// ID = CLASS: APPLICATION, FORM: PRIMITIVE, TAG: 2. (0x42)
+ /// </pre>
+ /// </summary>
+ public override Asn1Identifier getIdentifier()
+ {
+ return new Asn1Identifier(Asn1Identifier.APPLICATION, false, LdapMessage.UNBIND_REQUEST);
+ }
+
+ public RfcRequest dupRequest(System.String base_Renamed, System.String filter, bool request)
+ {
+ throw new LdapException(ExceptionMessages.NO_DUP_REQUEST, new System.Object[]{"unbind"}, LdapException.Ldap_NOT_SUPPORTED, (System.String) null);
+ }
+
+ public System.String getRequestDN()
+ {
+ return null;
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Utilclass/ArrayEnumeration.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Utilclass/ArrayEnumeration.cs
new file mode 100755
index 00000000000..95fee05560c
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Utilclass/ArrayEnumeration.cs
@@ -0,0 +1,89 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.Utilclass.ArrayEnumeration.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+
+namespace Novell.Directory.Ldap.Utilclass
+{
+
+ public class ArrayEnumeration : System.Collections.IEnumerator
+ {
+ private System.Object tempAuxObj;
+ public virtual bool MoveNext()
+ {
+ bool result = hasMoreElements();
+ if (result)
+ {
+ tempAuxObj = nextElement();
+ }
+ return result;
+ }
+ public virtual void Reset()
+ {
+ tempAuxObj = null;
+ }
+ public virtual System.Object Current
+ {
+ get
+ {
+ return tempAuxObj;
+ }
+
+ }
+ private System.Object[] eArray;
+ private int index = 0;
+ /// <summary> Constructor to create the Enumeration
+ ///
+ /// </summary>
+ /// <param name="eArray">the array to use for the Enumeration
+ /// </param>
+ public ArrayEnumeration(System.Object[] eArray)
+ {
+ this.eArray = eArray;
+ }
+
+ public bool hasMoreElements()
+ {
+ if (eArray == null)
+ return false;
+ return (index < eArray.Length);
+ }
+
+ public System.Object nextElement()
+ {
+ if ((eArray == null) || (index >= eArray.Length))
+ {
+ throw new System.ArgumentOutOfRangeException();
+ }
+ return eArray[index++];
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Utilclass/AttributeQualifier.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Utilclass/AttributeQualifier.cs
new file mode 100755
index 00000000000..d111009e88d
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Utilclass/AttributeQualifier.cs
@@ -0,0 +1,93 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.Utilclass.AttributeQualifier.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+
+namespace Novell.Directory.Ldap.Utilclass
+{
+
+ /// <summary> Encapsulates a qualifier in a Schema definition. Definitions that are not
+ /// in rfc2252. Begins with 'X-'
+ /// </summary>
+ public class AttributeQualifier
+ {
+ virtual public System.String Name
+ {
+ /*
+ public void addValue( String value )
+ {
+ values.add( value );
+ return;
+ }
+ */
+
+ get
+ {
+ return name;
+ }
+
+ }
+ virtual public System.String[] Values
+ {
+ get
+ {
+ System.String[] strValues = null;
+ if (values.Count > 0)
+ {
+ strValues = new System.String[values.Count];
+ for (int i = 0; i < values.Count; i++)
+ {
+ strValues[i] = ((System.String) values[i]);
+ }
+ }
+ return strValues;
+ }
+
+ }
+ internal System.String name;
+ internal System.Collections.ArrayList values;
+
+ public AttributeQualifier(System.String name, System.String[] value_Renamed)
+ {
+ if ((System.Object) name == null || value_Renamed == null)
+ {
+ throw new System.ArgumentException("A null name or value " + "was passed in for a schema definition qualifier");
+ }
+ this.name = name;
+ values = new System.Collections.ArrayList(5);
+ for (int i = 0; i < value_Renamed.Length; i++)
+ {
+ values.Add(value_Renamed[i]);
+ }
+ return ;
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Utilclass/Base64.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Utilclass/Base64.cs
new file mode 100755
index 00000000000..0d648fb88b9
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Utilclass/Base64.cs
@@ -0,0 +1,722 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.Utilclass.Base64.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+
+namespace Novell.Directory.Ldap.Utilclass
+{
+
+ /// <summary> The Base64 utility class performs base64 encoding and decoding.
+ ///
+ /// The Base64 Content-Transfer-Encoding is designed to represent
+ /// arbitrary sequences of octets in a form that need not be humanly
+ /// readable. The encoding and decoding algorithms are simple, but the
+ /// encoded data are consistently only about 33 percent larger than the
+ /// unencoded data. The base64 encoding algorithm is defined by
+ /// RFC 2045.
+ /// </summary>
+ public class Base64
+ {
+ /// <summary>Conversion table for encoding to base64.
+ ///
+ /// emap is a six-bit value to base64 (8-bit) converstion table.
+ /// For example, the value of the 6-bit value 15
+ /// is mapped to 0x50 which is the ASCII letter 'P', i.e. the letter P
+ /// is the base64 encoded character that represents the 6-bit value 15.
+ /// </summary>
+ /*
+ * 8-bit base64 encoded character base64 6-bit
+ * encoded original
+ * character binary value
+ */
+ private static readonly char[] emap = new char[]{'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '/'}; // 4-9, + /; 56-63
+
+ /// <summary>conversion table for decoding from base64.
+ ///
+ /// dmap is a base64 (8-bit) to six-bit value converstion table.
+ /// For example the ASCII character 'P' has a value of 80.
+ /// The value in the 80th position of the table is 0x0f or 15.
+ /// 15 is the original 6-bit value that the letter 'P' represents.
+ /// </summary>
+ /*
+ * 6-bit decoded value base64 base64
+ * encoded character
+ * value
+ *
+ * Note: about half of the values in the table are only place holders
+ */
+ private static readonly sbyte[] dmap = new sbyte[]{(sbyte) (0x00), (sbyte) (0x00), (sbyte) (0x00), (sbyte) (0x00), (sbyte) (0x00), (sbyte) (0x00), (sbyte) (0x00), (sbyte) (0x00), (sbyte) (0x00), (sbyte) (0x00), (sbyte) (0x00), (sbyte) (0x00), (sbyte) (0x00), (sbyte) (0x00), (sbyte) (0x00), (sbyte) (0x00), (sbyte) (0x00), (sbyte) (0x00), (sbyte) (0x00), (sbyte) (0x00), (sbyte) (0x00), (sbyte) (0x00), (sbyte) (0x00), (sbyte) (0x00), (sbyte) (0x00), (sbyte) (0x00), (sbyte) (0x00), (sbyte) (0x00), (sbyte) (0x00), (sbyte) (0x00), (sbyte) (0x00), (sbyte) (0x00), (sbyte) (0x00), (sbyte) (0x00), (sbyte) (0x00), (sbyte) (0x00), (sbyte) (0x00), (sbyte) (0x00), (sbyte) (0x00), (sbyte) (0x00), (sbyte) (0x00), (sbyte) (0x00), (sbyte) (0x00), (sbyte) (0x3e), (sbyte) (0x00), (sbyte) (0x00), (sbyte) (0x00), (sbyte) (0x3f), (sbyte) (0x34), (sbyte) (0x35), (sbyte) (0x36), (sbyte) (0x37), (sbyte) (0x38), (sbyte) (0x39), (sbyte) (0x3a), (sbyte) (0x3b), (sbyte) (0x3c), (sbyte) (0x3d), (sbyte) (0x00), (sbyte) (0x00), (sbyte) (0x00), (sbyte) (0x00), (sbyte) (0x00), (sbyte) (0x00), (sbyte) (0x00), (sbyte) (0x00), (sbyte) (0x01), (sbyte) (0x02), (sbyte) (0x03), (sbyte) (0x04), (sbyte) (0x05), (sbyte) (0x06), (sbyte) (0x07), (sbyte) (0x08), (sbyte) (0x09), (sbyte) (0x0a), (sbyte) (0x0b), (sbyte) (0x0c), (sbyte) (0x0d), (sbyte) (0x0e), (sbyte) (0x0f), (sbyte) (0x10), (sbyte) (0x11), (sbyte) (0x12), (sbyte) (0x13), (sbyte) (0x14), (sbyte) (0x15), (sbyte) (0x16), (sbyte) (0x17), (sbyte) (0x18), (sbyte) (0x19), (sbyte) (0x00), (sbyte) (0x00), (sbyte) (0x00), (sbyte) (0x00), (sbyte) (0x00), (sbyte) (0x00), (sbyte) (0x1a), (sbyte) (0x1b), (sbyte) (0x1c), (sbyte) (0x1d), (sbyte) (0x1e), (sbyte) (0x1f), (sbyte) (0x20), (sbyte) (0x21), (sbyte) (0x22), (sbyte) (0x23), (sbyte) (0x24), (sbyte) (0x25), (sbyte) (0x26), (sbyte) (0x27), (sbyte) (0x28), (sbyte) (0x29), (sbyte) (0x2a), (sbyte) (0x2b), (sbyte) (0x2c), (sbyte) (0x2d), (sbyte) (0x2e), (sbyte) (0x2f), (sbyte) (0x30), (sbyte) (0x31), (sbyte) (0x32), (sbyte) (0x33), (sbyte) (0x00), (
+ sbyte) (0x00), (sbyte) (0x00), (sbyte) (0x00), (sbyte) (0x00)}; // 120-127 'xyz '
+
+ /// <summary> Default constructor, don't allow instances of the
+ /// utility class to be created.
+ /// </summary>
+ private Base64()
+ {
+ return ;
+ }
+
+
+ /// <summary> Encodes the specified String into a base64 encoded String object.
+ ///
+ /// </summary>
+ /// <param name="inputString"> The String object to be encoded.
+ ///
+ /// </param>
+ /// <returns> a String containing the encoded value of the input.
+ /// </returns>
+ public static System.String encode(System.String inputString)
+ {
+ try
+ {
+ System.Text.Encoding encoder = System.Text.Encoding.GetEncoding("utf-8");
+ byte[] ibytes = encoder.GetBytes(inputString);
+ sbyte[] sbytes=SupportClass.ToSByteArray(ibytes);
+ return encode(sbytes);
+ }
+ catch (System.IO.IOException ue)
+ {
+ throw new System.SystemException("US-ASCII String encoding not supported by JVM");
+ }
+ }
+
+ /// <summary> Encodes the specified bytes into a base64 array of bytes.
+ /// Each byte in the return array represents a base64 character.
+ ///
+ /// </summary>
+ /// <param name="inputBytes"> the byte array to be encoded.
+ ///
+ /// </param>
+ /// <returns> a String containing the base64 encoded data
+ /// </returns>
+ [CLSCompliantAttribute(false)]
+ public static System.String encode(sbyte[] inputBytes)
+ {
+ int i, j, k;
+ int t, t1, t2;
+ int ntb; // number of three-bytes in inputBytes
+ bool onePadding = false, twoPaddings = false;
+ char[] encodedChars; // base64 encoded chars
+ int len = inputBytes.Length;
+
+ if (len == 0)
+ {
+ // No data, return no data.
+ return new System.Text.StringBuilder("").ToString();
+ }
+
+ // every three bytes will be encoded into four bytes
+ if (len % 3 == 0)
+ {
+ ntb = len / 3;
+ }
+ // the last one or two bytes will be encoded into
+ // four bytes with one or two paddings
+ else
+ {
+ ntb = len / 3 + 1;
+ }
+
+ // need two paddings
+ if ((len % 3) == 1)
+ {
+ twoPaddings = true;
+ }
+ // need one padding
+ else if ((len % 3) == 2)
+ {
+ onePadding = true;
+ }
+
+ encodedChars = new char[ntb * 4];
+
+ // map of decoded and encoded bits
+ // bits in 3 decoded bytes: 765432 107654 321076 543210
+ // bits in 4 encoded bytes: 76543210765432107654321076543210
+ // plain "AAA": 010000 010100 000101 000001
+ // base64 encoded "QUFB": 00010000000101000000010100000001
+ // one padding:
+ // bits in 2 decoded bytes: 765432 10 7654 3210
+ // bits in 4 encoded bytes: 765432107654 321076543210 '='
+ // plain "AA": 010000 010100 0001
+ // base64 encoded "QUE=": 00010000000101000000010000111101
+ // two paddings:
+ // bits in 1 decoded bytes: 765432 10
+ // bits in 4 encoded bytes: 7654321076543210 '=' '='
+ // plain "A": 010000 01
+ // base64 encoded "QQ==": 00010000000100000011110100111101
+ //
+ // note: the encoded bits which have no corresponding decoded bits
+ // are filled with zeros; '=' = 00111101.
+ for (i = 0, j = 0, k = 1; i < len; i += 3, j += 4, k++)
+ {
+
+ // build encodedChars[j]
+ t = 0x00ff & inputBytes[i];
+ encodedChars[j] = emap[t >> 2];
+
+ // build encodedChars[j+1]
+ if ((k == ntb) && twoPaddings)
+ {
+ encodedChars[j + 1] = emap[(t & 0x03) << 4];
+ encodedChars[j + 2] = '=';
+ encodedChars[j + 3] = '=';
+ break;
+ }
+ else
+ {
+ t1 = 0x00ff & inputBytes[i + 1];
+ encodedChars[j + 1] = emap[((t & 0x03) << 4) + ((t1 & 0xf0) >> 4)];
+ }
+
+ // build encodedChars[j+2]
+ if ((k == ntb) && onePadding)
+ {
+ encodedChars[j + 2] = emap[(t1 & 0x0f) << 2];
+ encodedChars[j + 3] = '=';
+ break;
+ }
+ else
+ {
+ t2 = 0x00ff & inputBytes[i + 2];
+ encodedChars[j + 2] = (emap[(t1 & 0x0f) << 2 | (t2 & 0xc0) >> 6]);
+ }
+
+ // build encodedChars[j+3]
+ encodedChars[j + 3] = (emap[(t2 & 0x3f)]);
+ }
+ return new System.String(encodedChars);
+ }
+
+
+ /// <summary> Decodes the input base64 encoded String.
+ /// The resulting binary data is returned as an array of bytes.
+ ///
+ /// </summary>
+ /// <param name="encodedString">The base64 encoded String object.
+ ///
+ /// </param>
+ /// <returns> The decoded byte array.
+ /// </returns>
+ [CLSCompliantAttribute(false)]
+ public static sbyte[] decode(System.String encodedString)
+ {
+ char[] c = new char[encodedString.Length];
+ SupportClass.GetCharsFromString(encodedString, 0, encodedString.Length, ref c, 0);
+ return decode(c);
+ }
+
+ /// <summary> Decodes the input base64 encoded array of characters.
+ /// The resulting binary data is returned as an array of bytes.
+ ///
+ /// </summary>
+ /// <param name="encodedChars">The character array containing the base64 encoded data.
+ ///
+ /// </param>
+ /// <returns> A byte array object containing decoded bytes.
+ /// </returns>
+ [CLSCompliantAttribute(false)]
+ public static sbyte[] decode(char[] encodedChars)
+ {
+ int i, j, k;
+ int ecLen = encodedChars.Length; // length of encodedChars
+ int gn = ecLen / 4; // number of four-byte groups in encodedChars
+ int dByteLen; // length of decoded bytes, default is '0'
+ bool onePad = false, twoPads = false;
+ sbyte[] decodedBytes; // decoded bytes
+
+ if (encodedChars.Length == 0)
+ {
+ return new sbyte[0];
+ }
+ // the number of encoded bytes should be multiple of 4
+ if ((ecLen % 4) != 0)
+ {
+ throw new System.SystemException("com.novell.ldap.ldif_dsml." + "Base64Decoder: decode: mal-formatted encode value");
+ }
+
+ // every four-bytes in encodedString, except the last one if it in the
+ // form of '**==' or '***=' ( can't be '*===' or '===='), will be
+ // decoded into three bytes.
+ if ((encodedChars[ecLen - 1] == (int) '=') && (encodedChars[ecLen - 2] == (int) '='))
+ {
+ // the last four bytes of encodedChars is in the form of '**=='
+ twoPads = true;
+ // the first two bytes of the last four-bytes of encodedChars will
+ // be decoded into one byte.
+ dByteLen = gn * 3 - 2;
+ decodedBytes = new sbyte[dByteLen];
+ }
+ else if (encodedChars[ecLen - 1] == '=')
+ {
+ // the last four bytes of encodedChars is in the form of '***='
+ onePad = true;
+ // the first two bytes of the last four-bytes of encodedChars will
+ // be decoded into two bytes.
+ dByteLen = gn * 3 - 1;
+ decodedBytes = new sbyte[dByteLen];
+ }
+ else
+ {
+ // the last four bytes of encodedChars is in the form of '****',
+ // e.g. no pad.
+ dByteLen = gn * 3;
+ decodedBytes = new sbyte[dByteLen];
+ }
+
+ // map of encoded and decoded bits
+ // no padding:
+ // bits in 4 encoded bytes: 76543210 76543210 76543210 76543210
+ // bits in 3 decoded bytes: 765432 107654 321076 543210
+ // base64 string "QUFB":00010000 00010100 000001010 0000001
+ // plain string "AAA": 010000 010100 000101 000001
+ // one padding:
+ // bits in 4 encoded bytes: 76543210 76543210 76543210 76543210
+ // bits in 2 decoded bytes: 765432 107654 3210
+ // base64 string "QUE=": 00010000 000101000 0000100 00111101
+ // plain string "AA": 010000 010100 0001
+ // two paddings:
+ // bits in 4 encoded bytes: 76543210 76543210 76543210 76543210
+ // bits in 1 decoded bytes: 765432 10
+ // base64 string "QQ==": 00010000 00010000 00111101 00111101
+ // plain string "A": 010000 01
+ for (i = 0, j = 0, k = 1; i < ecLen; i += 4, j += 3, k++)
+ {
+ // build decodedBytes[j].
+ decodedBytes[j] = (sbyte) (dmap[encodedChars[i]] << 2 | (dmap[encodedChars[i + 1]] & 0x30) >> 4);
+
+ // build decodedBytes[j+1]
+ if ((k == gn) && twoPads)
+ {
+ break;
+ }
+ else
+ {
+ decodedBytes[j + 1] = (sbyte) ((dmap[encodedChars[i + 1]] & 0x0f) << 4 | (dmap[encodedChars[i + 2]] & 0x3c) >> 2);
+ }
+
+ // build decodedBytes[j+2]
+ if ((k == gn) && onePad)
+ {
+ break;
+ }
+ else
+ {
+ decodedBytes[j + 2] = (sbyte) ((dmap[encodedChars[i + 2]] & 0x03) << 6 | dmap[encodedChars[i + 3]] & 0x3f);
+ }
+ }
+ return decodedBytes;
+ }
+
+ /// <summary> Decodes a base64 encoded StringBuffer.
+ /// Decodes all or part of the input base64 encoded StringBuffer, each
+ /// Character value representing a base64 character. The resulting
+ /// binary data is returned as an array of bytes.
+ ///
+ /// </summary>
+ /// <param name="encodedSBuf">The StringBuffer object that contains base64
+ /// encoded data.
+ /// </param>
+ /// <param name="start"> The start index of the base64 encoded data.
+ /// </param>
+ /// <param name="end"> The end index + 1 of the base64 encoded data.
+ ///
+ /// </param>
+ /// <returns> The decoded byte array
+ /// </returns>
+ [CLSCompliantAttribute(false)]
+ public static sbyte[] decode(System.Text.StringBuilder encodedSBuf, int start, int end)
+ {
+ int i, j, k;
+ int esbLen = end - start; // length of the encoded part
+ int gn = esbLen / 4; // number of four-bytes group in ebs
+ int dByteLen; // length of dbs, default is '0'
+ bool onePad = false, twoPads = false;
+ sbyte[] decodedBytes; // decoded bytes
+
+ if (encodedSBuf.Length == 0)
+ {
+ return new sbyte[0];
+ }
+ // the number of encoded bytes should be multiple of number 4
+ if ((esbLen % 4) != 0)
+ {
+ throw new System.SystemException("com.novell.ldap.ldif_dsml." + "Base64Decoder: decode error: mal-formatted encode value");
+ }
+
+ // every four-bytes in ebs, except the last one if it in the form of
+ // '**==' or '***=' ( can't be '*===' or '===='), will be decoded into
+ // three bytes.
+ if ((encodedSBuf[end - 1] == (int) '=') && (encodedSBuf[end - 2] == (int) '='))
+ {
+ // the last four bytes of ebs is in the form of '**=='
+ twoPads = true;
+ // the first two bytes of the last four-bytes of ebs will be
+ // decoded into one byte.
+ dByteLen = gn * 3 - 2;
+ decodedBytes = new sbyte[dByteLen];
+ }
+ else if (encodedSBuf[end - 1] == (int) '=')
+ {
+ // the last four bytes of ebs is in the form of '***='
+ onePad = true;
+ // the first two bytes of the last four-bytes of ebs will be
+ // decoded into two bytes.
+ dByteLen = gn * 3 - 1;
+ decodedBytes = new sbyte[dByteLen];
+ }
+ else
+ {
+ // the last four bytes of ebs is in the form of '****', eg. no pad.
+ dByteLen = gn * 3;
+ decodedBytes = new sbyte[dByteLen];
+ }
+
+ // map of encoded and decoded bits
+ // no padding:
+ // bits in 4 encoded bytes: 76543210 76543210 76543210 76543210
+ // bits in 3 decoded bytes: 765432 107654 321076 543210
+ // base64 string "QUFB":00010000 00010100 000001010 0000001
+ // plain string "AAA": 010000 010100 000101 000001
+ // one padding:
+ // bits in 4 encoded bytes: 76543210 76543210 76543210 76543210
+ // bits in 2 decoded bytes: 765432 107654 3210
+ // base64 string "QUE=": 00010000 000101000 0000100 00111101
+ // plain string "AA": 010000 010100 0001
+ // two paddings:
+ // bits in 4 encoded bytes: 76543210 76543210 76543210 76543210
+ // bits in 1 decoded bytes: 765432 10
+ // base64 string "QQ==": 00010000 00010000 00111101 00111101
+ // plain string "A": 010000 01
+ for (i = 0, j = 0, k = 1; i < esbLen; i += 4, j += 3, k++)
+ {
+ // build decodedBytes[j].
+ decodedBytes[j] = (sbyte) (dmap[encodedSBuf[start + i]] << 2 | (dmap[encodedSBuf[start + i + 1]] & 0x30) >> 4);
+
+ // build decodedBytes[j+1]
+ if ((k == gn) && twoPads)
+ {
+ break;
+ }
+ else
+ {
+ decodedBytes[j + 1] = (sbyte) ((dmap[encodedSBuf[start + i + 1]] & 0x0f) << 4 | (dmap[encodedSBuf[start + i + 2]] & 0x3c) >> 2);
+ }
+
+ // build decodedBytes[j+2]
+ if ((k == gn) && onePad)
+ {
+ break;
+ }
+ else
+ {
+ decodedBytes[j + 2] = (sbyte) ((dmap[encodedSBuf[start + i + 2]] & 0x03) << 6 | dmap[encodedSBuf[start + i + 3]] & 0x3f);
+ }
+ }
+ return decodedBytes;
+ }
+
+ /// <summary> Checks if the input byte array contains only safe values, that is,
+ /// the data does not need to be encoded for use with LDIF.
+ /// The rules for checking safety are based on the rules for LDIF
+ /// (Ldap Data Interchange Format) per RFC 2849. The data does
+ /// not need to be encoded if all the following are true:
+ /// <br>
+ /// <p>The data cannot start with the following byte values:</p>
+ /// <pre>
+ /// 00 (NUL)
+ /// 10 (LF)
+ /// 13 (CR)
+ /// 32 (SPACE)
+ /// 58 (:)
+ /// 60 (<)
+ /// Any character with value greater than 127
+ /// (Negative for a byte value)
+ /// </pre>
+ /// <p>The data cannot contain any of the following byte values:</p>
+ /// <pre>
+ /// 00 (NUL)
+ /// 10 (LF)
+ /// 13 (CR)
+ /// Any character with value greater than 127
+ /// (Negative for a byte value)
+ /// </pre>
+ /// <p>The data cannot end with a space.</p>
+ ///
+ /// </summary>
+ /// <param name="bytes">the bytes to be checked.
+ ///
+ /// </param>
+ /// <returns> true if encoding not required for LDIF
+ /// </returns>
+ [CLSCompliantAttribute(false)]
+ public static bool isLDIFSafe(sbyte[] bytes)
+ {
+ int len = bytes.Length;
+ if (len > 0)
+ {
+ int testChar = bytes[0];
+ // unsafe if first character is a NON-SAFE-INIT-CHAR
+ if ((testChar == 0x00) || (testChar == 0x0A) || (testChar == 0x0D) || (testChar == 0x20) || (testChar == 0x3A) || (testChar == 0x3C) || (testChar < 0))
+ {
+ // non ascii (>127 is negative)
+ return false;
+ }
+ // unsafe if last character is a space
+ if (bytes[len - 1] == ' ')
+ {
+ return false;
+ }
+ // unsafe if contains any non safe character
+ if (len > 1)
+ {
+ for (int i = 1; i < bytes.Length; i++)
+ {
+ testChar = bytes[i];
+ if ((testChar == 0x00) || (testChar == 0x0A) || (testChar == 0x0D) || (testChar < 0))
+ {
+ // non ascii (>127 is negative)
+ return false;
+ }
+ }
+ }
+ }
+ return true;
+ }
+ /// <summary> Checks if the input String contains only safe values, that is,
+ /// the data does not need to be encoded for use with LDIF.
+ /// The rules for checking safety are based on the rules for LDIF
+ /// (Ldap Data Interchange Format) per RFC 2849. The data does
+ /// not need to be encoded if all the following are true:
+ /// <br>
+ /// <p>The data cannot start with the following char values:</p>
+ /// <pre>
+ /// 00 (NUL)
+ /// 10 (LF)
+ /// 13 (CR)
+ /// 32 (SPACE)
+ /// 58 (:)
+ /// 60 (<)
+ /// Any character with value greater than 127
+ /// </pre>
+ /// <p>The data cannot contain any of the following char values:</p>
+ /// <pre>
+ /// 00 (NUL)
+ /// 10 (LF)
+ /// 13 (CR)
+ /// Any character with value greater than 127
+ /// </pre>
+ /// <p>The data cannot end with a space.</p>
+ ///
+ /// </summary>
+ /// <param name="str">the String to be checked.
+ ///
+ /// </param>
+ /// <returns> true if encoding not required for LDIF
+ /// </returns>
+ public static bool isLDIFSafe(System.String str)
+ {
+ try
+ {
+ System.Text.Encoding encoder = System.Text.Encoding.GetEncoding("utf-8");
+ byte[] ibytes = encoder.GetBytes(str);
+ sbyte[] sbytes=SupportClass.ToSByteArray(ibytes); return (isLDIFSafe(sbytes));
+ }
+ catch (System.IO.IOException ue)
+ {
+ throw new System.SystemException("UTF-8 String encoding not supported by JVM");
+ }
+ }
+
+ /* **************UTF-8 Validation methods and members*******************
+ * The following text is taken from draft-yergeau-rfc2279bis-02 and explains
+ * UTF-8 encoding:
+ *
+ *<p>In UTF-8, characters are encoded using sequences of 1 to 6 octets.
+ * If the range of character numbers is restricted to U+0000..U+10FFFF
+ * (the UTF-16 accessible range), then only sequences of one to four
+ * octets will occur. The only octet of a "sequence" of one has the
+ * higher-order bit set to 0, the remaining 7 bits being used to encode
+ * the character number. In a sequence of n octets, n>1, the initial
+ * octet has the n higher-order bits set to 1, followed by a bit set to
+ * 0. The remaining bit(s) of that octet contain bits from the number
+ * of the character to be encoded. The following octet(s) all have the
+ * higher-order bit set to 1 and the following bit set to 0, leaving 6
+ * bits in each to contain bits from the character to be encoded.</p>
+ *
+ * <p>The table below summarizes the format of these different octet types.
+ * The letter x indicates bits available for encoding bits of the
+ * character number.</p>
+ *
+ * <pre>
+ * Char. number range | UTF-8 octet sequence
+ * (hexadecimal) | (binary)
+ * --------------------+---------------------------------------------
+ * 0000 0000-0000 007F | 0xxxxxxx
+ * 0000 0080-0000 07FF | 110xxxxx 10xxxxxx
+ * 0000 0800-0000 FFFF | 1110xxxx 10xxxxxx 10xxxxxx
+ * 0001 0000-001F FFFF | 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
+ * 0020 0000-03FF FFFF | 111110xx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx
+ * 0400 0000-7FFF FFFF | 1111110x 10xxxxxx ... 10xxxxxx
+ * </pre>
+ */
+
+ /// <summary> Given the first byte in a sequence, getByteCount returns the number of
+ /// additional bytes in a UTF-8 character sequence (not including the first
+ /// byte).
+ ///
+ /// </summary>
+ /// <param name="b"> The first byte in a UTF-8 character sequence.
+ ///
+ /// </param>
+ /// <returns> the number of additional bytes in a UTF-8 character sequence.
+ /// </returns>
+ private static int getByteCount(sbyte b)
+ {
+ if (b > 0)
+ return 0;
+ if ((b & 0xE0) == 0xC0)
+ {
+ return 1; //one additional byte (2 bytes total)
+ }
+ if ((b & 0xF0) == 0xE0)
+ {
+ return 2; //two additional bytes (3 bytes total)
+ }
+ if ((b & 0xF8) == 0xF0)
+ {
+ return 3; //three additional bytes (4 bytes total)
+ }
+ if ((b & 0xFC) == 0xF8)
+ {
+ return 4; //four additional bytes (5 bytes total)
+ }
+ if ((b & 0xFF) == 0xFC)
+ {
+ return 5; //five additional bytes (6 bytes total)
+ }
+ return - 1;
+ }
+
+ /// <summary> Bit masks used to determine if a the value of UTF-8 byte sequence
+ /// is less than the minimum value.
+ ///
+ /// <p>If the value of a byte sequence is less than the minimum value then
+ /// the number should be encoded in fewer bytes and is invalid. For example
+ /// If the first byte indicates that a sequence has three bytes in a
+ /// sequence. Then the top five bits cannot be zero. Notice the index into
+ /// the array is one less than the number of bytes in a sequence.
+ /// A validity test for this could be:
+ /// <pre>
+ /// if ((lowerBoundMask[1][0] & byte[0] != 0) ||
+ /// (lowerBoundMask[1][1] & byte[1] != 0)) {
+ /// then the value is above the minimum and is valid.
+ /// }
+ /// </pre>
+ /// </summary>
+ private static readonly sbyte[][] lowerBoundMask = {new sbyte[]{0, 0}, new sbyte[]{(sbyte) (0x1E), (sbyte) (0x00)}, new sbyte[]{(sbyte) (0x0F), (sbyte) (0x20)}, new sbyte[]{(sbyte) (0x07), (sbyte) (0x30)}, new sbyte[]{(sbyte) (0x02), (sbyte) (0x38)}, new sbyte[]{(sbyte) (0x01), (sbyte) (0x3C)}};
+
+ /// <summary>mask to AND with a continuation byte: should equal continuationResult </summary>
+ private static sbyte continuationMask = (sbyte) SupportClass.Identity(0xC0);
+
+ /// <summary>expected result of ANDing a continuation byte with continuationMask </summary>
+ private static sbyte continuationResult = (sbyte) SupportClass.Identity(0x80);
+
+ /// <summary> Determines if an array of bytes contains only valid UTF-8 characters.
+ /// <p>
+ /// UTF-8 is the standard encoding for Ldap strings. If a value contains
+ /// data that is not valid UTF-8 then data is lost converting the
+ /// value to a Java String.
+ /// </p>
+ ///
+ /// <p>In addition, Java Strings currently use UCS2 (Unicode Code Standard
+ /// 2-byte characters). UTF-8 can be encoded as USC2 and UCS4 (4-byte
+ /// characters). Some valid UTF-8 characters cannot be represented as UCS2
+ /// characters. To determine if all UTF-8 sequences can be encoded into
+ /// UCS2 characters (a Java String), specify the <code>isUCS2Only</code>
+ /// parameter as <code>true</code>.<p>
+ ///
+ /// </summary>
+ /// <param name="array"> An array of bytes that are to be tested for valid UTF-8
+ /// encoding.
+ /// <br><br>
+ /// </param>
+ /// <param name="isUCS2Only">true if the UTF-8 values must be restricted to fit
+ /// within UCS2 encoding (2 bytes)
+ /// </param>
+ /// <returns> true if all values in the byte array are valid UTF-8
+ /// sequences. If <code>isUCS2Only</code> is
+ /// <code>true</code>, the method returns false if a UTF-8
+ /// sequence generates any character that cannot be
+ /// represented as a UCS2 character (Java String)
+ /// </returns>
+ [CLSCompliantAttribute(false)]
+ public static bool isValidUTF8(sbyte[] array, bool isUCS2Only)
+ {
+ int index = 0;
+ while (index < array.Length)
+ {
+ int count = getByteCount(array[index]);
+ if (count == 0)
+ {
+ //anything that qualifies as count=0 is valid UTF-8
+ index++;
+ continue;
+ }
+
+ if (count == - 1 || index + count >= array.Length || (isUCS2Only && count >= 3))
+ {
+ /* Any count that puts us out of bounds for the index is
+ * invalid. Valid UCS2 characters can only have 2 additional
+ * bytes. (three total) */
+ return false;
+ }
+
+ /* Tests if the first and second byte are below the minimum bound */
+ if ((lowerBoundMask[count][0] & array[index]) == 0 && (lowerBoundMask[count][1] & array[index + 1]) == 0)
+ {
+ return false;
+ }
+
+ /* testing continuation on the second and following bytes */
+ for (int i = 1; i <= count; i++)
+ {
+ if ((array[index + i] & continuationMask) != continuationResult)
+ {
+ return false;
+ }
+ }
+ index += count + 1;
+ }
+ return true;
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Utilclass/BindProperties.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Utilclass/BindProperties.cs
new file mode 100755
index 00000000000..3d255532c09
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Utilclass/BindProperties.cs
@@ -0,0 +1,134 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.Utilclass.BindProperties.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+
+namespace Novell.Directory.Ldap.Utilclass
+{
+
+ /// <summary> Encapsulates an Ldap Bind properties</summary>
+ public class BindProperties
+ {
+ /// <summary> gets the protocol version</summary>
+ virtual public int ProtocolVersion
+ {
+ get
+ {
+ return version;
+ }
+
+ }
+ /// <summary> Gets the authentication dn
+ ///
+ /// </summary>
+ /// <returns> the authentication dn for this connection
+ /// </returns>
+ virtual public System.String AuthenticationDN
+ {
+ get
+ {
+ return dn;
+ }
+
+ }
+ /// <summary> Gets the authentication method
+ ///
+ /// </summary>
+ /// <returns> the authentication method for this connection
+ /// </returns>
+ virtual public System.String AuthenticationMethod
+ {
+ get
+ {
+ return method;
+ }
+
+ }
+ /// <summary> Gets the SASL Bind properties
+ ///
+ /// </summary>
+ /// <returns> the sasl bind properties for this connection
+ /// </returns>
+ virtual public System.Collections.Hashtable SaslBindProperties
+ {
+ get
+ {
+ return bindProperties;
+ }
+
+ }
+
+ /// <summary> Gets the SASL callback handler
+ ///
+ /// </summary>
+ /// <returns> the sasl callback handler for this connection
+ /// </returns>
+ virtual public System.Object SaslCallbackHandler
+ {
+ get
+ {
+ return bindCallbackHandler;
+ }
+
+ }
+
+ /// <summary> Indicates whether or not the bind properties specify an anonymous bind
+ ///
+ /// </summary>
+ /// <returns> true if the bind properties specify an anonymous bind
+ /// </returns>
+ virtual public bool Anonymous
+ {
+ get
+ {
+ return anonymous;
+ }
+
+ }
+
+ private int version = 3;
+ private System.String dn = null;
+ private System.String method = null;
+ private bool anonymous;
+ private System.Collections.Hashtable bindProperties = null;
+ private System.Object bindCallbackHandler = null;
+
+ public BindProperties(int version, System.String dn, System.String method, bool anonymous, System.Collections.Hashtable bindProperties, System.Object bindCallbackHandler)
+ {
+ this.version = version;
+ this.dn = dn;
+ this.method = method;
+ this.anonymous = anonymous;
+ this.bindProperties = bindProperties;
+ this.bindCallbackHandler = bindCallbackHandler;
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Utilclass/DN.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Utilclass/DN.cs
new file mode 100755
index 00000000000..6db86f7033f
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Utilclass/DN.cs
@@ -0,0 +1,743 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.Utilclass.DN.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+
+namespace Novell.Directory.Ldap.Utilclass
+{
+
+ /// <summary> <P>A DN encapsulates a Distinguished Name (an ldap name with context). A DN
+ /// does not need to be fully distinguished, or extend to the Root of a
+ /// directory. It provides methods to get information about the DN and to
+ /// manipulate the DN. </P>
+ ///
+ /// <P> The following are examples of valid DN:
+ /// <ul>
+ /// <li>cn=admin,ou=marketing,o=corporation</li>
+ /// <li>cn=admin,ou=marketing</li>
+ /// <li>2.5.4.3=admin,ou=marketing</li>
+ /// <li>oid.2.5.4.3=admin,ou=marketing</li>
+ /// </ul>
+ ///
+ /// <P>Note: Multivalued attributes are all considered to be one
+ /// component and are represented in one RDN (see RDN)
+ /// </P>
+ ///
+ /// </summary>
+ /// <seealso cref="RDN">
+ /// </seealso>
+
+ public class DN : System.Object
+ {
+ private void InitBlock()
+ {
+ rdnList = new System.Collections.ArrayList();
+ }
+ /// <summary> Retrieves a list of RDN Objects, or individual names of the DN</summary>
+ /// <returns> list of RDNs
+ /// </returns>
+ virtual public System.Collections.ArrayList RDNs
+ {
+ get
+ {
+ int size = rdnList.Count;
+ System.Collections.ArrayList v = new System.Collections.ArrayList(size);
+ for (int i = 0; i < size; i++)
+ {
+ v.Add(rdnList[i]);
+ }
+ return v;
+ }
+
+ }
+ /// <summary> Returns the Parent of this DN</summary>
+ /// <returns> Parent DN
+ /// </returns>
+ virtual public DN Parent
+ {
+ get
+ {
+ DN parent = new DN();
+ parent.rdnList = (System.Collections.ArrayList) this.rdnList.Clone();
+ if (parent.rdnList.Count >= 1)
+ parent.rdnList.Remove(rdnList[0]); //remove first object
+ return parent;
+ }
+
+ }
+
+ //parser state identifiers.
+ private const int LOOK_FOR_RDN_ATTR_TYPE = 1;
+ private const int ALPHA_ATTR_TYPE = 2;
+ private const int OID_ATTR_TYPE = 3;
+ private const int LOOK_FOR_RDN_VALUE = 4;
+ private const int QUOTED_RDN_VALUE = 5;
+ private const int HEX_RDN_VALUE = 6;
+ private const int UNQUOTED_RDN_VALUE = 7;
+
+ /* State transition table: Parsing starts in state 1.
+
+ State COMMA DIGIT "Oid." ALPHA EQUAL QUOTE SHARP HEX
+ --------------------------------------------------------------------
+ 1 Err 3 3 2 Err Err Err Err
+ 2 Err Err Err 2 4 Err Err Err
+ 3 Err 3 Err Err 4 Err Err Err
+ 4 Err 7 Err 7 Err 5 6 7
+ 5 1 5 Err 5 Err 1 Err 7
+ 6 1 6 Err Err Err Err Err 6
+ 7 1 7 Err 7 Err Err Err 7
+
+ */
+
+
+ private System.Collections.ArrayList rdnList;
+
+ public DN()
+ {
+ InitBlock();
+ return ;
+ }
+ /// <summary> Constructs a new DN based on the specified string representation of a
+ /// distinguished name. The syntax of the DN must conform to that specified
+ /// in RFC 2253.
+ ///
+ /// </summary>
+ /// <param name="dnString">a string representation of the distinguished name
+ /// </param>
+ /// <exception cref=""> IllegalArgumentException if the the value of the dnString
+ /// parameter does not adhere to the syntax described in
+ /// RFC 2253
+ /// </exception>
+ public DN(System.String dnString)
+ {
+ InitBlock();
+ /* the empty string is a valid DN */
+ if (dnString.Length == 0)
+ return ;
+
+ char currChar;
+ char nextChar;
+ int currIndex;
+ char[] tokenBuf = new char[dnString.Length];
+ int tokenIndex;
+ int lastIndex;
+ int valueStart;
+ int state;
+ int trailingSpaceCount = 0;
+ System.String attrType = "";
+ System.String attrValue = "";
+ System.String rawValue = "";
+ int hexDigitCount = 0;
+ RDN currRDN = new RDN();
+
+ //indicates whether an OID number has a first digit of ZERO
+ bool firstDigitZero = false;
+
+ tokenIndex = 0;
+ currIndex = 0;
+ valueStart = 0;
+ state = LOOK_FOR_RDN_ATTR_TYPE;
+ lastIndex = dnString.Length - 1;
+ while (currIndex <= lastIndex)
+ {
+ currChar = dnString[currIndex];
+ switch (state)
+ {
+
+ case LOOK_FOR_RDN_ATTR_TYPE:
+ while (currChar == ' ' && (currIndex < lastIndex))
+ currChar = dnString[++currIndex];
+ if (isAlpha(currChar))
+ {
+ if (dnString.Substring(currIndex).StartsWith("oid.") || dnString.Substring(currIndex).StartsWith("OID."))
+ {
+ //form is "oid.###.##.###... or OID.###.##.###...
+ currIndex += 4; //skip oid. prefix and get to actual oid
+ if (currIndex > lastIndex)
+ throw new System.ArgumentException(dnString);
+ currChar = dnString[currIndex];
+ if (isDigit(currChar))
+ {
+ tokenBuf[tokenIndex++] = currChar;
+ state = OID_ATTR_TYPE;
+ }
+ else
+ throw new System.ArgumentException(dnString);
+ }
+ else
+ {
+ tokenBuf[tokenIndex++] = currChar;
+ state = ALPHA_ATTR_TYPE;
+ }
+ }
+ else if (isDigit(currChar))
+ {
+ --currIndex;
+ state = OID_ATTR_TYPE;
+ }
+ else if (!(System.Char.GetUnicodeCategory(currChar) == System.Globalization.UnicodeCategory.SpaceSeparator))
+ throw new System.ArgumentException(dnString);
+ break;
+
+
+ case ALPHA_ATTR_TYPE:
+ if (isAlpha(currChar) || isDigit(currChar) || (currChar == '-'))
+ tokenBuf[tokenIndex++] = currChar;
+ else
+ {
+ //skip any spaces
+ while ((currChar == ' ') && (currIndex < lastIndex))
+ currChar = dnString[++currIndex];
+ if (currChar == '=')
+ {
+ attrType = new System.String(tokenBuf, 0, tokenIndex);
+ tokenIndex = 0;
+ state = LOOK_FOR_RDN_VALUE;
+ }
+ else
+ throw new System.ArgumentException(dnString);
+ }
+ break;
+
+
+ case OID_ATTR_TYPE:
+ if (!isDigit(currChar))
+ throw new System.ArgumentException(dnString);
+ firstDigitZero = (currChar == '0')?true:false;
+ tokenBuf[tokenIndex++] = currChar;
+ currChar = dnString[++currIndex];
+
+ if ((isDigit(currChar) && firstDigitZero) || (currChar == '.' && firstDigitZero))
+ {
+ throw new System.ArgumentException(dnString);
+ }
+
+ //consume all numbers.
+ while (isDigit(currChar) && (currIndex < lastIndex))
+ {
+ tokenBuf[tokenIndex++] = currChar;
+ currChar = dnString[++currIndex];
+ }
+ if (currChar == '.')
+ {
+ tokenBuf[tokenIndex++] = currChar;
+ //The state remains at OID_ATTR_TYPE
+ }
+ else
+ {
+ //skip any spaces
+ while (currChar == ' ' && (currIndex < lastIndex))
+ currChar = dnString[++currIndex];
+ if (currChar == '=')
+ {
+ attrType = new System.String(tokenBuf, 0, tokenIndex);
+ tokenIndex = 0;
+ state = LOOK_FOR_RDN_VALUE;
+ }
+ else
+ throw new System.ArgumentException(dnString);
+ }
+ break;
+
+
+ case LOOK_FOR_RDN_VALUE:
+ while (currChar == ' ')
+ {
+ if (currIndex < lastIndex)
+ currChar = dnString[++currIndex];
+ else
+ throw new System.ArgumentException(dnString);
+ }
+ if (currChar == '"')
+ {
+ state = QUOTED_RDN_VALUE;
+ valueStart = currIndex;
+ }
+ else if (currChar == '#')
+ {
+ hexDigitCount = 0;
+ tokenBuf[tokenIndex++] = currChar;
+ valueStart = currIndex;
+ state = HEX_RDN_VALUE;
+ }
+ else
+ {
+ valueStart = currIndex;
+ //check this character again in the UNQUOTED_RDN_VALUE state
+ currIndex--;
+ state = UNQUOTED_RDN_VALUE;
+ }
+ break;
+
+
+ case UNQUOTED_RDN_VALUE:
+ if (currChar == '\\')
+ {
+ if (!(currIndex < lastIndex))
+ throw new System.ArgumentException(dnString);
+ currChar = dnString[++currIndex];
+ if (isHexDigit(currChar))
+ {
+ if (!(currIndex < lastIndex))
+ throw new System.ArgumentException(dnString);
+ nextChar = dnString[++currIndex];
+ if (isHexDigit(nextChar))
+ {
+ tokenBuf[tokenIndex++] = hexToChar(currChar, nextChar);
+ trailingSpaceCount = 0;
+ }
+ else
+ throw new System.ArgumentException(dnString);
+ }
+ else if (needsEscape(currChar) || currChar == '#' || currChar == '=' || currChar == ' ')
+ {
+ tokenBuf[tokenIndex++] = currChar;
+ trailingSpaceCount = 0;
+ }
+ else
+ throw new System.ArgumentException(dnString);
+ }
+ else if (currChar == ' ')
+ {
+ trailingSpaceCount++;
+ tokenBuf[tokenIndex++] = currChar;
+ }
+ else if ((currChar == ',') || (currChar == ';') || (currChar == '+'))
+ {
+ attrValue = new System.String(tokenBuf, 0, tokenIndex - trailingSpaceCount);
+ rawValue = dnString.Substring(valueStart, (currIndex - trailingSpaceCount) - (valueStart));
+
+ currRDN.add(attrType, attrValue, rawValue);
+ if (currChar != '+')
+ {
+ rdnList.Add(currRDN);
+ currRDN = new RDN();
+ }
+
+ trailingSpaceCount = 0;
+ tokenIndex = 0;
+ state = LOOK_FOR_RDN_ATTR_TYPE;
+ }
+ else if (needsEscape(currChar))
+ {
+ throw new System.ArgumentException(dnString);
+ }
+ else
+ {
+ trailingSpaceCount = 0;
+ tokenBuf[tokenIndex++] = currChar;
+ }
+ break; //end UNQUOTED RDN VALUE
+
+
+ case QUOTED_RDN_VALUE:
+ if (currChar == '"')
+ {
+ rawValue = dnString.Substring(valueStart, (currIndex + 1) - (valueStart));
+ if (currIndex < lastIndex)
+ currChar = dnString[++currIndex];
+ //skip any spaces
+ while ((currChar == ' ') && (currIndex < lastIndex))
+ currChar = dnString[++currIndex];
+ if ((currChar == ',') || (currChar == ';') || (currChar == '+') || (currIndex == lastIndex))
+ {
+ attrValue = new System.String(tokenBuf, 0, tokenIndex);
+
+ currRDN.add(attrType, attrValue, rawValue);
+ if (currChar != '+')
+ {
+ rdnList.Add(currRDN);
+ currRDN = new RDN();
+ }
+ trailingSpaceCount = 0;
+ tokenIndex = 0;
+ state = LOOK_FOR_RDN_ATTR_TYPE;
+ }
+ else
+ throw new System.ArgumentException(dnString);
+ }
+ else if (currChar == '\\')
+ {
+ currChar = dnString[++currIndex];
+ if (isHexDigit(currChar))
+ {
+ nextChar = dnString[++currIndex];
+ if (isHexDigit(nextChar))
+ {
+ tokenBuf[tokenIndex++] = hexToChar(currChar, nextChar);
+ trailingSpaceCount = 0;
+ }
+ else
+ throw new System.ArgumentException(dnString);
+ }
+ else if (needsEscape(currChar) || currChar == '#' || currChar == '=' || currChar == ' ')
+ {
+ tokenBuf[tokenIndex++] = currChar;
+ trailingSpaceCount = 0;
+ }
+ else
+ throw new System.ArgumentException(dnString);
+ }
+ else
+ tokenBuf[tokenIndex++] = currChar;
+ break; //end QUOTED RDN VALUE
+
+
+ case HEX_RDN_VALUE:
+ if ((!isHexDigit(currChar)) || (currIndex > lastIndex))
+ {
+ //check for odd number of hex digits
+ if ((hexDigitCount % 2) != 0 || hexDigitCount == 0)
+ throw new System.ArgumentException(dnString);
+ else
+ {
+ rawValue = dnString.Substring(valueStart, (currIndex) - (valueStart));
+ //skip any spaces
+ while ((currChar == ' ') && (currIndex < lastIndex))
+ currChar = dnString[++currIndex];
+ if ((currChar == ',') || (currChar == ';') || (currChar == '+') || (currIndex == lastIndex))
+ {
+ attrValue = new System.String(tokenBuf, 0, tokenIndex);
+
+ //added by cameron
+ currRDN.add(attrType, attrValue, rawValue);
+ if (currChar != '+')
+ {
+ rdnList.Add(currRDN);
+ currRDN = new RDN();
+ }
+ tokenIndex = 0;
+ state = LOOK_FOR_RDN_ATTR_TYPE;
+ }
+ else
+ {
+ throw new System.ArgumentException(dnString);
+ }
+ }
+ }
+ else
+ {
+ tokenBuf[tokenIndex++] = currChar;
+ hexDigitCount++;
+ }
+ break; //end HEX RDN VALUE
+ } //end switch
+ currIndex++;
+ } //end while
+
+ //check ending state
+ if (state == UNQUOTED_RDN_VALUE || (state == HEX_RDN_VALUE && (hexDigitCount % 2) == 0) && hexDigitCount != 0)
+ {
+ attrValue = new System.String(tokenBuf, 0, tokenIndex - trailingSpaceCount);
+ rawValue = dnString.Substring(valueStart, (currIndex - trailingSpaceCount) - (valueStart));
+ currRDN.add(attrType, attrValue, rawValue);
+ rdnList.Add(currRDN);
+ }
+ else if (state == LOOK_FOR_RDN_VALUE)
+ {
+ //empty value is valid
+ attrValue = "";
+ rawValue = dnString.Substring(valueStart);
+ currRDN.add(attrType, attrValue, rawValue);
+ rdnList.Add(currRDN);
+ }
+ else
+ {
+ throw new System.ArgumentException(dnString);
+ }
+ } //end DN constructor (string dn)
+
+
+ /// <summary> Checks a character to see if it is an ascii alphabetic character in
+ /// ranges 65-90 or 97-122.
+ ///
+ /// </summary>
+ /// <param name="ch">the character to be tested.
+ /// </param>
+ /// <returns> <code>true</code> if the character is an ascii alphabetic
+ /// character
+ /// </returns>
+ private bool isAlpha(char ch)
+ {
+ if (((ch < 91) && (ch > 64)) || ((ch < 123) && (ch > 96)))
+ //ASCII A-Z
+ return true;
+ else
+ return false;
+ }
+
+
+ /// <summary> Checks a character to see if it is an ascii digit (0-9) character in
+ /// the ascii value range 48-57.
+ ///
+ /// </summary>
+ /// <param name="ch">the character to be tested.
+ /// </param>
+ /// <returns> <code>true</code> if the character is an ascii alphabetic
+ /// character
+ /// </returns>
+ private bool isDigit(char ch)
+ {
+ if ((ch < 58) && (ch > 47))
+ //ASCII 0-9
+ return true;
+ else
+ return false;
+ }
+
+ /// <summary> Checks a character to see if it is valid hex digit 0-9, a-f, or
+ /// A-F (ASCII value ranges 48-47, 65-70, 97-102).
+ ///
+ /// </summary>
+ /// <param name="ch">the character to be tested.
+ /// </param>
+ /// <returns> <code>true</code> if the character is a valid hex digit
+ /// </returns>
+
+ private static bool isHexDigit(char ch)
+ {
+ if (((ch < 58) && (ch > 47)) || ((ch < 71) && (ch > 64)) || ((ch < 103) && (ch > 96)))
+ //ASCII A-F
+ return true;
+ else
+ return false;
+ }
+
+ /// <summary> Checks a character to see if it must always be escaped in the
+ /// string representation of a DN. We must tests for space, sharp, and
+ /// equals individually.
+ ///
+ /// </summary>
+ /// <param name="ch">the character to be tested.
+ /// </param>
+ /// <returns> <code>true</code> if the character needs to be escaped in at
+ /// least some instances.
+ /// </returns>
+ private bool needsEscape(char ch)
+ {
+ if ((ch == ',') || (ch == '+') || (ch == '\"') || (ch == ';') || (ch == '<') || (ch == '>') || (ch == '\\'))
+ return true;
+ else
+ return false;
+ }
+
+ /// <summary> Converts two valid hex digit characters that form the string
+ /// representation of an ascii character value to the actual ascii
+ /// character.
+ ///
+ /// </summary>
+ /// <param name="hex1">the hex digit for the high order byte.
+ /// </param>
+ /// <param name="hex0">the hex digit for the low order byte.
+ /// </param>
+ /// <returns> the character whose value is represented by the parameters.
+ /// </returns>
+
+ private static char hexToChar(char hex1, char hex0)
+ {
+ int result;
+
+ if ((hex1 < 58) && (hex1 > 47))
+ //ASCII 0-9
+ result = (hex1 - 48) * 16;
+ else if ((hex1 < 71) && (hex1 > 64))
+ //ASCII a-f
+ result = (hex1 - 55) * 16;
+ else if ((hex1 < 103) && (hex1 > 96))
+ //ASCII A-F
+ result = (hex1 - 87) * 16;
+ else
+ throw new System.ArgumentException("Not hex digit");
+
+ if ((hex0 < 58) && (hex0 > 47))
+ //ASCII 0-9
+ result += (hex0 - 48);
+ else if ((hex0 < 71) && (hex0 > 64))
+ //ASCII a-f
+ result += (hex0 - 55);
+ else if ((hex0 < 103) && (hex0 > 96))
+ //ASCII A-F
+ result += (hex0 - 87);
+ else
+ throw new System.ArgumentException("Not hex digit");
+
+ return (char) result;
+ }
+
+ /// <summary> Creates and returns a string that represents this DN. The string
+ /// follows RFC 2253, which describes String representation of DN's and
+ /// RDN's
+ ///
+ /// </summary>
+ /// <returns> A DN string.
+ /// </returns>
+ public override System.String ToString()
+ {
+ int length = rdnList.Count;
+ System.String dn = "";
+ if (length < 1)
+ return null;
+ dn = rdnList[0].ToString();
+ for (int i = 1; i < length; i++)
+ {
+ dn += ("," + rdnList[i].ToString());
+ }
+ return dn;
+ }
+
+
+ /// <summary> Compares this DN to the specified DN to determine if they are equal.
+ ///
+ /// </summary>
+ /// <param name="toDN">the DN to compare to
+ /// </param>
+ /// <returns> <code>true</code> if the DNs are equal; otherwise
+ /// <code>false</code>
+ /// </returns>
+
+ public System.Collections.ArrayList getrdnList()
+ {
+ return this.rdnList;
+ }
+ public override bool Equals(System.Object toDN)
+ {
+ return Equals((DN) toDN);
+ }
+ public bool Equals(DN toDN)
+ {
+ System.Collections.ArrayList aList=toDN.getrdnList();
+ int length = aList.Count;
+
+ if (this.rdnList.Count != length)
+ return false;
+
+ for (int i = 0; i < length; i++)
+ {
+ if (!((RDN) rdnList[i]).equals((RDN) toDN.getrdnList()[i]))
+ return false;
+ }
+ return true;
+ }
+
+ /// <summary> return a string array of the individual RDNs contained in the DN
+ ///
+ /// </summary>
+ /// <param name="noTypes"> If true, returns only the values of the
+ /// components, and not the names, e.g. "Babs
+ /// Jensen", "Accounting", "Acme", "us" - instead of
+ /// "cn=Babs Jensen", "ou=Accounting", "o=Acme", and
+ /// "c=us".
+ /// </param>
+ /// <returns> <code>String[]</code> containing the rdns in the DN with
+ /// the leftmost rdn in the first element of the array
+ ///
+ /// </returns>
+ public virtual System.String[] explodeDN(bool noTypes)
+ {
+ int length = rdnList.Count;
+ System.String[] rdns = new System.String[length];
+ for (int i = 0; i < length; i++)
+ rdns[i] = ((RDN) rdnList[i]).toString(noTypes);
+ return rdns;
+ }
+
+ /// <summary> Retrieves the count of RDNs, or individule names, in the Distinguished name</summary>
+ /// <returns> the count of RDN
+ /// </returns>
+ public virtual int countRDNs()
+ {
+ return rdnList.Count;
+ }
+
+ /// <summary>Determines if this DN is <I>contained</I> by the DN passed in. For
+ /// example: "cn=admin, ou=marketing, o=corporation" is contained by
+ /// "o=corporation", "ou=marketing, o=corporation", and "ou=marketing"
+ /// but <B>not</B> by "cn=admin" or "cn=admin,ou=marketing,o=corporation"
+ /// Note: For users of Netscape's SDK this method is comparable to contains
+ ///
+ /// </summary>
+ /// <param name="containerDN">of a container
+ /// </param>
+ /// <returns> true if containerDN contains this DN
+ /// </returns>
+ public virtual bool isDescendantOf(DN containerDN)
+ {
+ int i = containerDN.rdnList.Count - 1; //index to an RDN of the ContainerDN
+ int j = this.rdnList.Count - 1; //index to an RDN of the ContainedDN
+ //Search from the end of the DN for an RDN that matches the end RDN of
+ //containerDN.
+ while (!((RDN) this.rdnList[j--]).equals((RDN) containerDN.rdnList[i]))
+ {
+ if (j <= 0)
+ return false;
+ //if the end RDN of containerDN does not have any equal
+ //RDN in rdnList, then containerDN does not contain this DN
+ }
+ i--; //avoid a redundant compare
+ j--;
+ //step backwards to verify that all RDNs in containerDN exist in this DN
+ for (; i >= 0 && j >= 0; i--, j--)
+ {
+ if (!((RDN) this.rdnList[j]).equals((RDN) containerDN.rdnList[i]))
+ return false;
+ }
+ if (j == 0 && i == 0)
+ //the DNs are identical and thus not contained
+ return false;
+
+ return true;
+ }
+
+ /// <summary> Adds the RDN to the beginning of the current DN.</summary>
+ /// <param name="rdn">an RDN to be added
+ /// </param>
+ public virtual void addRDN(RDN rdn)
+ {
+ rdnList.Insert(0, rdn);
+ }
+
+ /// <summary> Adds the RDN to the beginning of the current DN.</summary>
+ /// <param name="rdn">an RDN to be added
+ /// </param>
+ public virtual void addRDNToFront(RDN rdn)
+ {
+ rdnList.Insert(0, rdn);
+ }
+
+ /// <summary> Adds the RDN to the end of the current DN</summary>
+ /// <param name="rdn">an RDN to be added
+ /// </param>
+ public virtual void addRDNToBack(RDN rdn)
+ {
+ rdnList.Add(rdn);
+ }
+ } //end class DN
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Utilclass/EnumeratedIterator.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Utilclass/EnumeratedIterator.cs
new file mode 100755
index 00000000000..beecaf4f58c
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Utilclass/EnumeratedIterator.cs
@@ -0,0 +1,91 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.Utilclass.EnumeratedIterator.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+
+namespace Novell.Directory.Ldap.Utilclass
+{
+ /// <summary> wrappers a class of type Iterator and makes it act as an Enumerator. This
+ /// is used when the API requires enumerations be used but we may be using
+ /// JDK1.2 collections, which return iterators instead of enumerators. Used by
+ /// LdapSchema and LdapSchemaElement
+ ///
+ /// </summary>
+ /// <seealso cref="com.novell.ldap.LdapSchema#getAttributeSchemas">
+ /// </seealso>
+ /// <seealso cref="com.novell.ldap.LdapSchemaElement#getQualifierNames">
+ /// </seealso>
+
+ public class EnumeratedIterator : System.Collections.IEnumerator
+ {
+ private System.Object tempAuxObj;
+ public virtual bool MoveNext()
+ {
+ bool result = hasMoreElements();
+ if (result)
+ {
+ tempAuxObj = nextElement();
+ }
+ return result;
+ }
+ public virtual void Reset()
+ {
+ tempAuxObj = null;
+ }
+ public virtual System.Object Current
+ {
+ get
+ {
+ return tempAuxObj;
+ }
+
+ }
+ private System.Collections.IEnumerator i;
+
+ public EnumeratedIterator(System.Collections.IEnumerator iterator)
+ {
+ i = iterator;
+ return ;
+ }
+
+ /// <summary> Enumeration method that maps to Iterator.hasNext()</summary>
+ public bool hasMoreElements()
+ {
+ return i.MoveNext();
+ }
+
+ /// <summary> Enumeration method that maps to Iterator.next()</summary>
+ public System.Object nextElement()
+ {
+ return i.Current;
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Utilclass/ExceptionMessages.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Utilclass/ExceptionMessages.cs
new file mode 100755
index 00000000000..ace778e240d
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Utilclass/ExceptionMessages.cs
@@ -0,0 +1,120 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.Utilclass.ExceptionMessages.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+
+namespace Novell.Directory.Ldap.Utilclass
+{
+
+ /// <summary> This class contains strings that may be associated with Exceptions generated
+ /// by the Ldap API libraries.
+ /// Two entries are made for each message, a String identifier, and the
+ /// actual error string. Parameters are identified as {0}, {1}, etc.
+ /// </summary>
+ public class ExceptionMessages:System.Resources.ResourceManager
+ {
+ public System.Object[][] getContents()
+ {
+ return contents;
+ }
+ //static strings to aide lookup and guarantee accuracy:
+ //DO NOT include these strings in other Locales
+ [CLSCompliantAttribute(false)]
+ public const System.String TOSTRING = "TOSTRING";
+ public const System.String SERVER_MSG = "SERVER_MSG";
+ public const System.String MATCHED_DN = "MATCHED_DN";
+ public const System.String FAILED_REFERRAL = "FAILED_REFERRAL";
+ public const System.String REFERRAL_ITEM = "REFERRAL_ITEM";
+ public const System.String CONNECTION_ERROR = "CONNECTION_ERROR";
+ public const System.String CONNECTION_IMPOSSIBLE = "CONNECTION_IMPOSSIBLE";
+ public const System.String CONNECTION_WAIT = "CONNECTION_WAIT";
+ public const System.String CONNECTION_FINALIZED = "CONNECTION_FINALIZED";
+ public const System.String CONNECTION_CLOSED = "CONNECTION_CLOSED";
+ public const System.String CONNECTION_READER = "CONNECTION_READER";
+ public const System.String DUP_ERROR = "DUP_ERROR";
+ public const System.String REFERRAL_ERROR = "REFERRAL_ERROR";
+ public const System.String REFERRAL_LOCAL = "REFERRAL_LOCAL";
+ public const System.String REFERENCE_ERROR = "REFERENCE_ERROR";
+ public const System.String REFERRAL_SEND = "REFERRAL_SEND";
+ public const System.String REFERENCE_NOFOLLOW = "REFERENCE_NOFOLLOW";
+ public const System.String REFERRAL_BIND = "REFERRAL_BIND";
+ public const System.String REFERRAL_BIND_MATCH = "REFERRAL_BIND_MATCH";
+ public const System.String NO_DUP_REQUEST = "NO_DUP_REQUEST";
+ public const System.String SERVER_CONNECT_ERROR = "SERVER_CONNECT_ERROR";
+ public const System.String NO_SUP_PROPERTY = "NO_SUP_PROPERTY";
+ public const System.String ENTRY_PARAM_ERROR = "ENTRY_PARAM_ERROR";
+ public const System.String DN_PARAM_ERROR = "DN_PARAM_ERROR";
+ public const System.String RDN_PARAM_ERROR = "RDN_PARAM_ERROR";
+ public const System.String OP_PARAM_ERROR = "OP_PARAM_ERROR";
+ public const System.String PARAM_ERROR = "PARAM_ERROR";
+ public const System.String DECODING_ERROR = "DECODING_ERROR";
+ public const System.String ENCODING_ERROR = "ENCODING_ERROR";
+ public const System.String IO_EXCEPTION = "IO_EXCEPTION";
+ public const System.String INVALID_ESCAPE = "INVALID_ESCAPE";
+ public const System.String SHORT_ESCAPE = "SHORT_ESCAPE";
+ public const System.String INVALID_CHAR_IN_FILTER = "INVALID_CHAR_IN_FILTER";
+ public const System.String INVALID_CHAR_IN_DESCR = "INVALID_CHAR_IN_DESCR";
+ public const System.String INVALID_ESC_IN_DESCR = "INVALID_ESC_IN_DESCR";
+ public const System.String UNEXPECTED_END = "UNEXPECTED_END";
+ public const System.String MISSING_LEFT_PAREN = "MISSING_LEFT_PAREN";
+ public const System.String MISSING_RIGHT_PAREN = "MISSING_RIGHT_PAREN";
+ public const System.String EXPECTING_RIGHT_PAREN = "EXPECTING_RIGHT_PAREN";
+ public const System.String EXPECTING_LEFT_PAREN = "EXPECTING_LEFT_PAREN";
+ public const System.String NO_OPTION = "NO_OPTION";
+ public const System.String INVALID_FILTER_COMPARISON = "INVALID_FILTER_COMPARISON";
+ public const System.String NO_MATCHING_RULE = "NO_MATCHING_RULE";
+ public const System.String NO_ATTRIBUTE_NAME = "NO_ATTRIBUTE_NAME";
+ public const System.String NO_DN_NOR_MATCHING_RULE = "NO_DN_NOR_MATCHING_RULE";
+ public const System.String NOT_AN_ATTRIBUTE = "NOT_AN_ATTRIBUTE";
+ public const System.String UNEQUAL_LENGTHS = "UNEQUAL_LENGTHS";
+ public const System.String IMPROPER_REFERRAL = "IMPROPER_REFERRAL";
+ public const System.String NOT_IMPLEMENTED = "NOT_IMPLEMENTED";
+ public const System.String NO_MEMORY = "NO_MEMORY";
+ public const System.String SERVER_SHUTDOWN_REQ = "SERVER_SHUTDOWN_REQ";
+ public const System.String INVALID_ADDRESS = "INVALID_ADDRESS";
+ public const System.String UNKNOWN_RESULT = "UNKNOWN_RESULT";
+ public const System.String OUTSTANDING_OPERATIONS = "OUTSTANDING_OPERATIONS";
+ public const System.String WRONG_FACTORY = "WRONG_FACTORY";
+ public const System.String NO_TLS_FACTORY = "NO_TLS_FACTORY";
+ public const System.String NO_STARTTLS = "NO_STARTTLS";
+ public const System.String STOPTLS_ERROR = "STOPTLS_ERROR";
+ public const System.String MULTIPLE_SCHEMA = "MULTIPLE_SCHEMA";
+ public const System.String NO_SCHEMA = "NO_SCHEMA";
+ public const System.String READ_MULTIPLE = "READ_MULTIPLE";
+ public const System.String CANNOT_BIND = "CANNOT_BIND";
+
+ //End constants
+
+ internal static readonly System.Object[][] contents = {new System.Object[]{"TOSTRING", "{0}: {1} ({2}) {3}"}, new System.Object[]{"SERVER_MSG", "{0}: Server Message: {1}"}, new System.Object[]{"MATCHED_DN", "{0}: Matched DN: {1}"}, new System.Object[]{"FAILED_REFERRAL", "{0}: Failed Referral: {1}"}, new System.Object[]{"REFERRAL_ITEM", "{0}: Referral: {1}"}, new System.Object[]{"CONNECTION_ERROR", "Unable to connect to server {0}:{1}"}, new System.Object[]{"CONNECTION_IMPOSSIBLE", "Unable to reconnect to server, application has never called connect()"}, new System.Object[]{"CONNECTION_WAIT", "Connection lost waiting for results from {0}:{1}"}, new System.Object[]{"CONNECTION_FINALIZED", "Connection closed by the application finalizing the object"}, new System.Object[]{"CONNECTION_CLOSED", "Connection closed by the application disconnecting"}, new System.Object[]{"CONNECTION_READER", "Reader thread terminated"}, new System.Object[]{"DUP_ERROR", "RfcLdapMessage: Cannot duplicate message built from the input stream"}, new System.Object[]{"REFERENCE_ERROR", "Error attempting to follow a search continuation reference"}, new System.Object[]{"REFERRAL_ERROR", "Error attempting to follow a referral"}, new System.Object[]{"REFERRAL_LOCAL", "LdapSearchResults.{0}(): No entry found & request is not complete"}, new System.Object[]{"REFERRAL_SEND", "Error sending request to referred server"}, new System.Object[]{"REFERENCE_NOFOLLOW", "Search result reference received, and referral following is off"}, new System.Object[]{"REFERRAL_BIND", "LdapBind.bind() function returned null"}, new System.Object[]{"REFERRAL_BIND_MATCH", "Could not match LdapBind.bind() connection with Server Referral URL list"}, new System.Object[]{"NO_DUP_REQUEST", "Cannot duplicate message to follow referral for {0} request, not allowed"}, new System.Object[]{"SERVER_CONNECT_ERROR", "Error connecting to server {0} while attempting to follow a referral"}, new System.Object[]{"NO_SUP_PROPERTY", "Requested property is not supported."}, new
+ System.Object[]{"ENTRY_PARAM_ERROR", "Invalid Entry parameter"}, new System.Object[]{"DN_PARAM_ERROR", "Invalid DN parameter"}, new System.Object[]{"RDN_PARAM_ERROR", "Invalid DN or RDN parameter"}, new System.Object[]{"OP_PARAM_ERROR", "Invalid extended operation parameter, no OID specified"}, new System.Object[]{"PARAM_ERROR", "Invalid parameter"}, new System.Object[]{"DECODING_ERROR", "Error Decoding responseValue"}, new System.Object[]{"ENCODING_ERROR", "Encoding Error"}, new System.Object[]{"IO_EXCEPTION", "I/O Exception on host {0}, port {1}"}, new System.Object[]{"INVALID_ESCAPE", "Invalid value in escape sequence \"{0}\""}, new System.Object[]{"SHORT_ESCAPE", "Incomplete escape sequence"}, new System.Object[]{"UNEXPECTED_END", "Unexpected end of filter"}, new System.Object[]{"MISSING_LEFT_PAREN", "Unmatched parentheses, left parenthesis missing"}, new System.Object[]{"NO_OPTION", "Semicolon present, but no option specified"}, new System.Object[]{"MISSING_RIGHT_PAREN", "Unmatched parentheses, right parenthesis missing"}, new System.Object[]{"EXPECTING_RIGHT_PAREN", "Expecting right parenthesis, found \"{0}\""}, new System.Object[]{"EXPECTING_LEFT_PAREN", "Expecting left parenthesis, found \"{0}\""}, new System.Object[]{"NO_ATTRIBUTE_NAME", "Missing attribute description"}, new System.Object[]{"NO_DN_NOR_MATCHING_RULE", "DN and matching rule not specified"}, new System.Object[]{"NO_MATCHING_RULE", "Missing matching rule"}, new System.Object[]{"INVALID_FILTER_COMPARISON", "Invalid comparison operator"}, new System.Object[]{"INVALID_CHAR_IN_FILTER", "The invalid character \"{0}\" needs to be escaped as \"{1}\""}, new System.Object[]{"INVALID_ESC_IN_DESCR", "Escape sequence not allowed in attribute description"}, new System.Object[]{"INVALID_CHAR_IN_DESCR", "Invalid character \"{0}\" in attribute description"}, new System.Object[]{"NOT_AN_ATTRIBUTE", "Schema element is not an LdapAttributeSchema object"}, new System.Object[]{"UNEQUAL_LENGTHS",
+ "Length of attribute Name array does not equal length of Flags array"}, new System.Object[]{"IMPROPER_REFERRAL", "Referral not supported for command {0}"}, new System.Object[]{"NOT_IMPLEMENTED", "Method LdapConnection.startTLS not implemented"}, new System.Object[]{"NO_MEMORY", "All results could not be stored in memory, sort failed"}, new System.Object[]{"SERVER_SHUTDOWN_REQ", "Received unsolicited notification from server {0}:{1} to shutdown"}, new System.Object[]{"INVALID_ADDRESS", "Invalid syntax for address with port; {0}"}, new System.Object[]{"UNKNOWN_RESULT", "Unknown Ldap result code {0}"}, new System.Object[]{"OUTSTANDING_OPERATIONS", "Cannot start or stop TLS because outstanding Ldap operations exist on this connection"}, new System.Object[]{"WRONG_FACTORY", "StartTLS cannot use the set socket factory because it does not implement LdapTLSSocketFactory"}, new System.Object[]{"NO_TLS_FACTORY", "StartTLS failed because no LdapTLSSocketFactory has been set for this Connection"}, new System.Object[]{"NO_STARTTLS", "An attempt to stopTLS on a connection where startTLS had not been called"}, new System.Object[]{"STOPTLS_ERROR", "Error stopping TLS: Error getting input & output streams from the original socket"}, new System.Object[]{"MULTIPLE_SCHEMA", "Multiple schema found when reading the subschemaSubentry for {0}"}, new System.Object[]{"NO_SCHEMA", "No schema found when reading the subschemaSubentry for {0}"}, new System.Object[]{"READ_MULTIPLE", "Read response is ambiguous, multiple entries returned"}, new System.Object[]{"CANNOT_BIND", "Cannot bind. Use PoolManager.getBoundConnection()"}};
+ } //End ExceptionMessages
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Utilclass/ExtResponseFactory.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Utilclass/ExtResponseFactory.cs
new file mode 100755
index 00000000000..dfd668d6e91
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Utilclass/ExtResponseFactory.cs
@@ -0,0 +1,117 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.Utilclass.ExtResponseFactory.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+using Novell.Directory.Ldap;
+using Novell.Directory.Ldap.Extensions;
+using Novell.Directory.Ldap.Rfc2251;
+
+namespace Novell.Directory.Ldap.Utilclass
+{
+ /// <summary>
+ /// Takes an LdapExtendedResponse and returns an object
+ /// (that implements the base class ParsedExtendedResponse)
+ /// based on the OID.
+ ///
+ /// <p>You can then call methods defined in the child
+ /// class to parse the contents of the response. The methods available
+ /// depend on the child class. All child classes inherit from the
+ /// ParsedExtendedResponse.
+ ///
+ /// </summary>
+ public class ExtResponseFactory
+ {
+
+ /// <summary> Used to Convert an RfcLdapMessage object to the appropriate
+ /// LdapExtendedResponse object depending on the operation being performed.
+ ///
+ /// </summary>
+ /// <param name="inResponse"> The LdapExtendedReponse object as returned by the
+ /// extendedOperation method in the LdapConnection object.
+ /// <br><br>
+ /// </param>
+ /// <returns> An object of base class LdapExtendedResponse. The actual child
+ /// class of this returned object depends on the operation being
+ /// performed.
+ ///
+ /// </returns>
+ /// <exception cref=""> LdapException A general exception which includes an error message
+ /// and an Ldap error code.
+ /// </exception>
+
+ static public LdapExtendedResponse convertToExtendedResponse(RfcLdapMessage inResponse)
+ {
+
+ LdapExtendedResponse tempResponse = new LdapExtendedResponse(inResponse);
+
+ // Get the oid stored in the Extended response
+ System.String inOID = tempResponse.ID;
+
+ if ((System.Object) inOID == null)
+ return tempResponse;
+ // Is this an OID we support, if yes then build the
+ // detailed LdapExtendedResponse object
+ try
+ {
+ if (inOID.Equals(ReplicationConstants.NAMING_CONTEXT_COUNT_RES))
+ {
+ return new PartitionEntryCountResponse(inResponse);
+ }
+ if (inOID.Equals(ReplicationConstants.GET_IDENTITY_NAME_RES))
+ {
+ return new GetBindDNResponse(inResponse);
+ }
+ if (inOID.Equals(ReplicationConstants.GET_EFFECTIVE_PRIVILEGES_RES))
+ {
+ return new GetEffectivePrivilegesResponse(inResponse);
+ }
+ if (inOID.Equals(ReplicationConstants.GET_REPLICA_INFO_RES))
+ {
+ return new GetReplicaInfoResponse(inResponse);
+ }
+ if (inOID.Equals(ReplicationConstants.LIST_REPLICAS_RES))
+ {
+ return new ListReplicasResponse(inResponse);
+ }
+ if (inOID.Equals(ReplicationConstants.GET_REPLICATION_FILTER_RES))
+ {
+ return new GetReplicationFilterResponse(inResponse);
+ }
+ else
+ return tempResponse;
+ }
+ catch (System.IO.IOException ioe)
+ {
+ throw new LdapException(ExceptionMessages.DECODING_ERROR, LdapException.DECODING_ERROR, (System.String) null);
+ }
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Utilclass/RDN.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Utilclass/RDN.cs
new file mode 100755
index 00000000000..b3e780f9422
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Utilclass/RDN.cs
@@ -0,0 +1,315 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.Utilclass.RDN.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+
+namespace Novell.Directory.Ldap.Utilclass
+{
+
+ /// <summary> <P>A RDN encapsulates a single object's name of a Distinguished Name(DN).
+ /// The object name represented by this class contains no context. Thus a
+ /// Relative Distinguished Name (RDN) could be relative to anywhere in the
+ /// Directories tree.</P>
+ ///
+ /// <P>For example, of following DN, 'cn=admin, ou=marketing, o=corporation', all
+ /// possible RDNs are 'cn=admin', 'ou=marketing', and 'o=corporation'.</P>
+ ///
+ /// <P>Multivalued attributes are encapsulated in this class. For example the
+ /// following could be represented by an RDN: 'cn=john + l=US', or
+ /// 'cn=juan + l=ES' </P>
+ ///
+ /// </summary>
+ /// <seealso cref="DN">
+ /// </seealso>
+
+
+ public class RDN:System.Object
+ {
+ /// <summary> Returns the actually Raw String before Normalization
+ ///
+ /// </summary>
+ /// <returns> The raw string
+ /// </returns>
+ virtual protected internal System.String RawValue
+ {
+ get
+ {
+ return rawValue;
+ }
+
+ }
+ /// <summary> Returns the type of this RDN. This method assumes that only one value
+ /// is used, If multivalues attributes are used only the first Type is
+ /// returned. Use GetTypes.
+ /// </summary>
+ /// <returns> Type of attribute
+ /// </returns>
+ virtual public System.String Type
+ {
+ get
+ {
+ return (System.String) types[0];
+ }
+
+ }
+ /// <summary> Returns all the types for this RDN.</summary>
+ /// <returns> list of types
+ /// </returns>
+ virtual public System.String[] Types
+ {
+ get
+ {
+ System.String[] toReturn = new System.String[types.Count];
+ for (int i = 0; i < types.Count; i++)
+ toReturn[i] = ((System.String) types[i]);
+ return toReturn;
+ }
+
+ }
+ /// <summary> Returns the values of this RDN. If multivalues attributes are used only
+ /// the first Type is returned. Use GetTypes.
+ ///
+ /// </summary>
+ /// <returns> Type of attribute
+ /// </returns>
+ virtual public System.String Value
+ {
+ get
+ {
+ return (System.String) values[0];
+ }
+
+ }
+ /// <summary> Returns all the types for this RDN.</summary>
+ /// <returns> list of types
+ /// </returns>
+ virtual public System.String[] Values
+ {
+ get
+ {
+ System.String[] toReturn = new System.String[values.Count];
+ for (int i = 0; i < values.Count; i++)
+ toReturn[i] = ((System.String) values[i]);
+ return toReturn;
+ }
+
+ }
+ /// <summary> Determines if this RDN is multivalued or not</summary>
+ /// <returns> true if this RDN is multivalued
+ /// </returns>
+ virtual public bool Multivalued
+ {
+ get
+ {
+ return (values.Count > 1)?true:false;
+ }
+
+ }
+ private System.Collections.ArrayList types; //list of Type strings
+ private System.Collections.ArrayList values; //list of Value strings
+ private System.String rawValue; //the unnormalized value
+
+ /// <summary> Creates an RDN object from the DN component specified in the string RDN
+ ///
+ /// </summary>
+ /// <param name="rdn">the DN component
+ /// </param>
+ public RDN(System.String rdn)
+ {
+ rawValue = rdn;
+ DN dn = new DN(rdn);
+ System.Collections.ArrayList rdns = dn.RDNs;
+ //there should only be one rdn
+ if (rdns.Count != 1)
+ throw new System.ArgumentException("Invalid RDN: see API " + "documentation");
+ RDN thisRDN = (RDN) (rdns[0]);
+ this.types = thisRDN.types;
+ this.values = thisRDN.values;
+ this.rawValue = thisRDN.rawValue;
+ return ;
+ }
+
+ public RDN()
+ {
+ types = new System.Collections.ArrayList();
+ values = new System.Collections.ArrayList();
+ rawValue = "";
+ return ;
+ }
+
+ /// <summary> Compares the RDN to the rdn passed. Note: If an there exist any
+ /// mulivalues in one RDN they must all be present in the other.
+ ///
+ /// </summary>
+ /// <param name="rdn">the RDN to compare to
+ ///
+ /// @throws IllegalArgumentException if the application compares a name
+ /// with an OID.
+ /// </param>
+ [CLSCompliantAttribute(false)]
+ public virtual bool equals(RDN rdn)
+ {
+ if (this.values.Count != rdn.values.Count)
+ {
+ return false;
+ }
+ int j, i;
+ for (i = 0; i < this.values.Count; i++)
+ {
+ //verify that the current value and type exists in the other list
+ j = 0;
+ //May need a more intellegent compare
+ while (j < values.Count && (!((System.String) this.values[i]).ToUpper().Equals(((System.String) rdn.values[j]).ToUpper()) || !equalAttrType((System.String) this.types[i], (System.String) rdn.types[j])))
+ {
+ j++;
+ }
+ if (j >= rdn.values.Count)
+ //couldn't find first value
+ return false;
+ }
+ return true;
+ }
+
+ /// <summary> Internal function used by equal to compare Attribute types. Because
+ /// attribute types could either be an OID or a name. There needs to be a
+ /// Translation mechanism. This function will absract this functionality.
+ ///
+ /// Currently if types differ (Oid and number) then UnsupportedOperation is
+ /// thrown, either one or the other must used. In the future an OID to name
+ /// translation can be used.
+ ///
+ ///
+ /// </summary>
+ private bool equalAttrType(System.String attr1, System.String attr2)
+ {
+ if (System.Char.IsDigit(attr1[0]) ^ System.Char.IsDigit(attr2[0]))
+ //isDigit tests if it is an OID
+ throw new System.ArgumentException("OID numbers are not " + "currently compared to attribute names");
+
+ return attr1.ToUpper().Equals(attr2.ToUpper());
+ }
+
+ /// <summary> Adds another value to the RDN. Only one attribute type is allowed for
+ /// the RDN.
+ /// </summary>
+ /// <param name="attrType">Attribute type, could be an OID or String
+ /// </param>
+ /// <param name="attrValue">Attribute Value, must be normalized and escaped
+ /// </param>
+ /// <param name="rawValue">or text before normalization, can be Null
+ /// </param>
+ public virtual void add(System.String attrType, System.String attrValue, System.String rawValue)
+ {
+ types.Add(attrType);
+ values.Add(attrValue);
+ this.rawValue += rawValue;
+ }
+
+ /// <summary> Creates a string that represents this RDN, according to RFC 2253
+ ///
+ /// </summary>
+ /// <returns> An RDN string
+ /// </returns>
+ public override System.String ToString()
+ {
+ return toString(false);
+ }
+
+ /// <summary> Creates a string that represents this RDN.
+ ///
+ /// If noTypes is true then Atribute types will be ommited.
+ ///
+ /// </summary>
+ /// <param name="noTypes">true if attribute types will be omitted.
+ ///
+ /// </param>
+ /// <returns> An RDN string
+ /// </returns>
+ [CLSCompliantAttribute(false)]
+ public virtual System.String toString(bool noTypes)
+ {
+ int length = types.Count;
+ System.String toReturn = "";
+ if (length < 1)
+ return null;
+ if (!noTypes)
+ {
+ toReturn = types[0] + "=";
+ }
+ toReturn += values[0];
+
+ for (int i = 1; i < length; i++)
+ {
+ toReturn += "+";
+ if (!noTypes)
+ {
+ toReturn += (types[i] + "=");
+ }
+ toReturn += values[i];
+ }
+ return toReturn;
+ }
+
+ /// <summary> Returns each multivalued name in the current RDN as an array of Strings.
+ ///
+ /// </summary>
+ /// <param name="noTypes">Specifies whether Attribute types are included. The attribute
+ /// type names will be ommitted if the parameter noTypes is true.
+ ///
+ /// </param>
+ /// <returns> List of multivalued Attributes
+ /// </returns>
+ public virtual System.String[] explodeRDN(bool noTypes)
+ {
+ int length = types.Count;
+ if (length < 1)
+ return null;
+ System.String[] toReturn = new System.String[types.Count];
+
+ if (!noTypes)
+ {
+ toReturn[0] = types[0] + "=";
+ }
+ toReturn[0] += values[0];
+
+ for (int i = 1; i < length; i++)
+ {
+ if (!noTypes)
+ {
+ toReturn[i] += (types[i] + "=");
+ }
+ toReturn[i] += values[i];
+ }
+
+ return toReturn;
+ }
+ } //end class RDN
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Utilclass/ReferralInfo.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Utilclass/ReferralInfo.cs
new file mode 100755
index 00000000000..4cf83a69e46
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Utilclass/ReferralInfo.cs
@@ -0,0 +1,104 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.Utilclass.ReferralInfo.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+using Novell.Directory.Ldap;
+using LdapUrl = Novell.Directory.Ldap.LdapUrl;
+
+namespace Novell.Directory.Ldap.Utilclass
+{
+
+ /// <summary> This class encapsulates the combination of LdapReferral URL and
+ /// the connection opened to service this URL
+ /// </summary>
+ public class ReferralInfo
+ {
+ /// <summary>Returns the referral URL
+ ///
+ /// </summary>
+ /// <returns> the Referral URL
+ /// </returns>
+ virtual public LdapUrl ReferralUrl
+ {
+ get
+ {
+ return referralUrl;
+ }
+
+ }
+ /// <summary>Returns the referral Connection
+ ///
+ /// </summary>
+ /// <returns> the Referral Connection
+ /// </returns>
+ virtual public LdapConnection ReferralConnection
+ {
+ get
+ {
+ return conn;
+ }
+
+ }
+ /// <summary>Returns the referral list
+ ///
+ /// </summary>
+ /// <returns> the Referral list
+ /// </returns>
+ virtual public System.String[] ReferralList
+ {
+ get
+ {
+ return referralList;
+ }
+
+ }
+// private DirectoryEntry conn;
+ private LdapConnection conn;
+ private LdapUrl referralUrl;
+ private System.String[] referralList;
+
+ /// <summary> Construct the ReferralInfo class
+ ///
+ /// </summary>
+ /// <param name="lc">The DirectoryEntry opened to process this referral
+ ///
+ /// </param>
+ /// <param name="refUrl">The URL string associated with this connection
+ /// </param>
+ public ReferralInfo(LdapConnection lc, System.String[] refList, LdapUrl refUrl)
+ {
+ conn = lc;
+ referralUrl = refUrl;
+ referralList = refList;
+ return ;
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Utilclass/ResourcesHandler.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Utilclass/ResourcesHandler.cs
new file mode 100755
index 00000000000..45a5496ffb8
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Utilclass/ResourcesHandler.cs
@@ -0,0 +1,214 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.Utilclass.ResourcesHandler.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+
+namespace Novell.Directory.Ldap.Utilclass
+{
+
+ /// <summary> A utility class to get strings from the ExceptionMessages and
+ /// ResultCodeMessages resources.
+ /// </summary>
+ public class ResourcesHandler
+ {
+ // Cannot create an instance of this class
+ private ResourcesHandler()
+ {
+ return ;
+ }
+
+ /*
+ * Initialized when the first result string is requested
+ */
+ private static System.Resources.ResourceManager defaultResultCodes = null;
+
+ /// <summary> Initialized when the first Exception message string is requested</summary>
+ private static System.Resources.ResourceManager defaultMessages = null;
+
+
+ /// <summary> Package where resources are found</summary>
+ private static System.String pkg = "Novell.Directory.Ldap.Utilclass.";
+
+ /// <summary> The default Locale</summary>
+ private static System.Globalization.CultureInfo defaultLocale;
+
+ /// <summary> Returns a string using the MessageOrKey as a key into
+ /// ExceptionMessages or, if the Key does not exist, returns the
+ /// string messageOrKey. In addition it formats the arguments into the message
+ /// according to MessageFormat.
+ ///
+ /// </summary>
+ /// <param name="messageOrKey"> Key string for the resource.
+ /// <br><br>
+ /// </param>
+ /// <param name="">arguments
+ ///
+ /// </param>
+ /// <returns> the text for the message specified by the MessageKey or the Key
+ /// if it there is no message for that key.
+ /// </returns>
+ public static System.String getMessage(System.String messageOrKey, System.Object[] arguments)
+ {
+ return getMessage(messageOrKey, arguments, null);
+ }
+
+ /// <summary> Returns the message stored in the ExceptionMessages resource for the
+ /// specified locale using messageOrKey and argments passed into the
+ /// constructor. If no string exists in the resource then this returns
+ /// the string stored in message. (This method is identical to
+ /// getLdapErrorMessage(Locale locale).)
+ ///
+ /// </summary>
+ /// <param name="messageOrKey"> Key string for the resource.
+ /// <br><br>
+ /// </param>
+ /// <param name="">arguments
+ /// <br><br>
+ /// </param>
+ /// <param name="locale"> The Locale that should be used to pull message
+ /// strings out of ExceptionMessages.
+ ///
+ /// </param>
+ /// <returns> the text for the message specified by the MessageKey or the Key
+ /// if it there is no message for that key.
+ /// </returns>
+ public static System.String getMessage(System.String messageOrKey, System.Object[] arguments, System.Globalization.CultureInfo locale)
+ {
+ System.String pattern;
+ System.Resources.ResourceManager messages = null;
+
+ if ((System.Object) messageOrKey == null)
+ {
+ messageOrKey = "";
+ }
+
+ try
+ {
+ if ((locale == null) || defaultLocale.Equals(locale))
+ {
+ locale = defaultLocale;
+ // Default Locale
+ if (defaultMessages == null)
+ {
+ System.Threading.Thread.CurrentThread.CurrentUICulture = defaultLocale;
+ defaultMessages = System.Resources.ResourceManager.CreateFileBasedResourceManager(pkg + "ExceptionMessages", "", null);
+ }
+ messages = defaultMessages;
+ }
+ else
+ {
+ System.Threading.Thread.CurrentThread.CurrentUICulture = locale;
+ messages = System.Resources.ResourceManager.CreateFileBasedResourceManager(pkg + "ExceptionMessages", "", null);
+ }
+ pattern = messages.GetString(messageOrKey);
+ }
+ catch (System.Resources.MissingManifestResourceException mre)
+ {
+ pattern = messageOrKey;
+ }
+
+ // Format the message if arguments were passed
+ if (arguments != null)
+ {
+// MessageFormat mf = new MessageFormat(pattern);
+ pattern=System.String.Format(locale,pattern,arguments);
+// mf.setLocale(locale);
+ //this needs to be reset with the new local - i18n defect in java
+// mf.applyPattern(pattern);
+// pattern = mf.format(arguments);
+ }
+ return pattern;
+ }
+
+ /// <summary> Returns a string representing the Ldap result code from the
+ /// default ResultCodeMessages resource.
+ ///
+ /// </summary>
+ /// <param name="code"> the result code
+ /// <br><br>
+ /// </param>
+ /// <returns> the String representing the result code.
+ /// </returns>
+ public static System.String getResultString(int code)
+ {
+ return getResultString(code, null);
+ }
+
+ /// <summary> Returns a string representing the Ldap result code. The message
+ /// is obtained from the locale specific ResultCodeMessage resource.
+ ///
+ /// </summary>
+ /// <param name="code"> the result code
+ /// <br><br>
+ /// </param>
+ /// <param name="locale"> The Locale that should be used to pull message
+ /// strings out of ResultMessages.
+ ///
+ /// </param>
+ /// <returns> the String representing the result code.
+ /// </returns>
+ public static System.String getResultString(int code, System.Globalization.CultureInfo locale)
+ {
+ System.Resources.ResourceManager messages;
+ System.String result;
+ try
+ {
+ if ((locale == null) || defaultLocale.Equals(locale))
+ {
+ locale = defaultLocale;
+ // Default Locale
+ if (defaultResultCodes == null)
+ {
+// System.Threading.Thread.CurrentThread.CurrentUICulture = defaultLocale;
+ defaultResultCodes = System.Resources.ResourceManager.CreateFileBasedResourceManager(pkg + "ResultCodeMessages", "", null);
+ }
+ messages = defaultResultCodes;
+ }
+ else
+ {
+ System.Threading.Thread.CurrentThread.CurrentUICulture = locale;
+ messages = System.Resources.ResourceManager.CreateFileBasedResourceManager(pkg + "ResultCodeMessages", "", null);
+ }
+// result = messages.GetString(System.Convert.ToString(code));
+ result = Convert.ToString(code);
+ }
+ catch (System.Resources.MissingManifestResourceException mre)
+ {
+ result = getMessage(ExceptionMessages.UNKNOWN_RESULT, new System.Object[]{code}, locale);
+ }
+ return result;
+ }
+ static ResourcesHandler()
+ {
+// defaultLocale = System.Globalization.CultureInfo.CurrentCulture;
+ }
+ } //end class ResourcesHandler
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Utilclass/RespControlVector.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Utilclass/RespControlVector.cs
new file mode 100755
index 00000000000..1732bd46d38
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Utilclass/RespControlVector.cs
@@ -0,0 +1,124 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.Utilclass.RespControlVector.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+
+namespace Novell.Directory.Ldap.Utilclass
+{
+
+ /// <summary> The <code>MessageVector</code> class implements extends the
+ /// existing Vector class so that it can be used to maintain a
+ /// list of currently registered control responses.
+ /// </summary>
+ public class RespControlVector:System.Collections.ArrayList
+ {
+ public RespControlVector(int cap, int incr):base(cap)
+ {
+ return ;
+ }
+
+ /// <summary>Inner class defined to create a temporary object to encapsulate
+ /// all registration information about a response control. This class
+ /// cannot be used outside this class
+ /// </summary>
+ private class RegisteredControl
+ {
+ private void InitBlock(RespControlVector enclosingInstance)
+ {
+ this.enclosingInstance = enclosingInstance;
+ }
+ private RespControlVector enclosingInstance;
+ public RespControlVector Enclosing_Instance
+ {
+ get
+ {
+ return enclosingInstance;
+ }
+
+ }
+ public System.String myOID;
+ public System.Type myClass;
+
+ public RegisteredControl(RespControlVector enclosingInstance, System.String oid, System.Type controlClass)
+ {
+ InitBlock(enclosingInstance);
+ myOID = oid;
+ myClass = controlClass;
+ }
+ }
+
+ /* Adds a control to the current list of registered response controls.
+ *
+ */
+ public void registerResponseControl(System.String oid, System.Type controlClass)
+ {
+ lock (this)
+ {
+
+ Add(new RegisteredControl(this, oid, controlClass));
+ }
+ }
+
+ /* Searches the list of registered controls for a mathcing control. We
+ * search using the OID string. If a match is found we return the
+ * Class name that was provided to us on registration.
+ */
+ public System.Type findResponseControl(System.String searchOID)
+ {
+ lock (this)
+ {
+ RegisteredControl ctl = null;
+
+ /* loop through the contents of the vector */
+ for (int i = 0; i < Count; i++)
+ {
+
+ /* Get next registered control */
+ if ((ctl = (RegisteredControl) ToArray()[i]) == null)
+ {
+ throw new System.FieldAccessException();
+ }
+
+ /* Does the stored OID match with whate we are looking for */
+ if (ctl.myOID.CompareTo(searchOID) == 0)
+ {
+
+
+ /* Return the class name if we have match */
+ return ctl.myClass;
+ }
+ }
+ /* The requested control does not have a registered response class */
+ return null;
+ }
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Utilclass/ResultCodeMessages.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Utilclass/ResultCodeMessages.cs
new file mode 100755
index 00000000000..0db59a4a24a
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Utilclass/ResultCodeMessages.cs
@@ -0,0 +1,50 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.Utilclass.ResultCodeMessages.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+
+namespace Novell.Directory.Ldap.Utilclass
+{
+
+ /// <summary> This class contains strings corresponding to Ldap Result Codes.
+ /// The resources are accessed by the String representation of the result code.
+ /// </summary>
+
+ public class ResultCodeMessages:System.Resources.ResourceManager
+ {
+ public System.Object[][] getContents()
+ {
+ return contents;
+ }
+ internal static readonly System.Object[][] contents = {new System.Object[]{"0", "Success"}, new System.Object[]{"1", "Operations Error"}, new System.Object[]{"2", "Protocol Error"}, new System.Object[]{"3", "Timelimit Exceeded"}, new System.Object[]{"4", "Sizelimit Exceeded"}, new System.Object[]{"5", "Compare False"}, new System.Object[]{"6", "Compare True"}, new System.Object[]{"7", "Authentication Method Not Supported"}, new System.Object[]{"8", "Strong Authentication Required"}, new System.Object[]{"9", "Partial Results"}, new System.Object[]{"10", "Referral"}, new System.Object[]{"11", "Administrative Limit Exceeded"}, new System.Object[]{"12", "Unavailable Critical Extension"}, new System.Object[]{"13", "Confidentiality Required"}, new System.Object[]{"14", "SASL Bind In Progress"}, new System.Object[]{"16", "No Such Attribute"}, new System.Object[]{"17", "Undefined Attribute Type"}, new System.Object[]{"18", "Inappropriate Matching"}, new System.Object[]{"19", "Constraint Violation"}, new System.Object[]{"20", "Attribute Or Value Exists"}, new System.Object[]{"21", "Invalid Attribute Syntax"}, new System.Object[]{"32", "No Such Object"}, new System.Object[]{"33", "Alias Problem"}, new System.Object[]{"34", "Invalid DN Syntax"}, new System.Object[]{"35", "Is Leaf"}, new System.Object[]{"36", "Alias Dereferencing Problem"}, new System.Object[]{"48", "Inappropriate Authentication"}, new System.Object[]{"49", "Invalid Credentials"}, new System.Object[]{"50", "Insufficient Access Rights"}, new System.Object[]{"51", "Busy"}, new System.Object[]{"52", "Unavailable"}, new System.Object[]{"53", "Unwilling To Perform"}, new System.Object[]{"54", "Loop Detect"}, new System.Object[]{"64", "Naming Violation"}, new System.Object[]{"65", "Object Class Violation"}, new System.Object[]{"66", "Not Allowed On Non-leaf"}, new System.Object[]{"67", "Not Allowed On RDN"}, new System.Object[]{"68", "Entry Already Exists"}, new System.Object[]{"69", "Object Class Modifications Prohibited"}, new System.Object[]{"71",
+ "Affects Multiple DSAs"}, new System.Object[]{"80", "Other"}, new System.Object[]{"81", "Server Down"}, new System.Object[]{"82", "Local Error"}, new System.Object[]{"83", "Encoding Error"}, new System.Object[]{"84", "Decoding Error"}, new System.Object[]{"85", "Ldap Timeout"}, new System.Object[]{"86", "Authentication Unknown"}, new System.Object[]{"87", "Filter Error"}, new System.Object[]{"88", "User Cancelled"}, new System.Object[]{"89", "Parameter Error"}, new System.Object[]{"90", "No Memory"}, new System.Object[]{"91", "Connect Error"}, new System.Object[]{"92", "Ldap Not Supported"}, new System.Object[]{"93", "Control Not Found"}, new System.Object[]{"94", "No Results Returned"}, new System.Object[]{"95", "More Results To Return"}, new System.Object[]{"96", "Client Loop"}, new System.Object[]{"97", "Referral Limit Exceeded"}, new System.Object[]{"112", "TLS not supported"}};
+ } //End ResultCodeMessages
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.dll.sources b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.dll.sources
new file mode 100755
index 00000000000..6da691aa54c
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.dll.sources
@@ -0,0 +1,160 @@
+Novell.Directory.Ldap/AssemblyInfo.cs
+Novell.Directory.Ldap.Utilclass/Base64.cs
+Novell.Directory.Ldap.Utilclass/DN.cs
+Novell.Directory.Ldap.Utilclass/RDN.cs
+Novell.Directory.Ldap.Utilclass/BindProperties.cs
+Novell.Directory.Ldap.Utilclass/ReferralInfo.cs
+Novell.Directory.Ldap.Utilclass/ArrayEnumeration.cs
+Novell.Directory.Ldap.Utilclass/AttributeQualifier.cs
+Novell.Directory.Ldap.Utilclass/EnumeratedIterator.cs
+Novell.Directory.Ldap.Utilclass/ResultCodeMessages.cs
+Novell.Directory.Ldap.Utilclass/ResourcesHandler.cs
+Novell.Directory.Ldap.Utilclass/ExceptionMessages.cs
+Novell.Directory.Ldap.Utilclass/RespControlVector.cs
+Novell.Directory.Ldap.Utilclass/ExtResponseFactory.cs
+Novell.Directory.Ldap.Asn1/Asn1Boolean.cs
+Novell.Directory.Ldap.Asn1/Asn1Choice.cs
+Novell.Directory.Ldap.Asn1/Asn1Encoder.cs
+Novell.Directory.Ldap.Asn1/Asn1Decoder.cs
+Novell.Directory.Ldap.Asn1/Asn1Enumerated.cs
+Novell.Directory.Ldap.Asn1/Asn1Identifier.cs
+Novell.Directory.Ldap.Asn1/Asn1Integer.cs
+Novell.Directory.Ldap.Asn1/Asn1Null.cs
+Novell.Directory.Ldap.Asn1/Asn1Length.cs
+Novell.Directory.Ldap.Asn1/Asn1Sequence.cs
+Novell.Directory.Ldap.Asn1/Asn1Set.cs
+Novell.Directory.Ldap.Asn1/Asn1SequenceOf.cs
+Novell.Directory.Ldap.Asn1/Asn1SetOf.cs
+Novell.Directory.Ldap.Asn1/Asn1Structured.cs
+Novell.Directory.Ldap.Asn1/Asn1Tagged.cs
+Novell.Directory.Ldap.Asn1/Asn1Numeric.cs
+Novell.Directory.Ldap.Asn1/Asn1Object.cs
+Novell.Directory.Ldap.Asn1/Asn1OctetString.cs
+Novell.Directory.Ldap.Asn1/LBERDecoder.cs
+Novell.Directory.Ldap.Asn1/LBEREncoder.cs
+Novell.Directory.Ldap.Rfc2251/RfcRelativeLdapDN.cs
+Novell.Directory.Ldap.Rfc2251/RfcModifyDNRequest.cs
+Novell.Directory.Ldap.Rfc2251/RfcModifyDNResponse.cs
+Novell.Directory.Ldap.Rfc2251/RfcModifyResponse.cs
+Novell.Directory.Ldap.Rfc2251/RfcModifyRequest.cs
+Novell.Directory.Ldap.Rfc2251/RfcCompareRequest.cs
+Novell.Directory.Ldap.Rfc2251/RfcCompareResponse.cs
+Novell.Directory.Ldap.Rfc2251/RfcAddRequest.cs
+Novell.Directory.Ldap.Rfc2251/RfcAddResponse.cs
+Novell.Directory.Ldap.Rfc2251/RfcAttributeDescriptionList.cs
+Novell.Directory.Ldap.Rfc2251/RfcAttributeValue.cs
+Novell.Directory.Ldap.Rfc2251/RfcAttributeTypeAndValues.cs
+Novell.Directory.Ldap.Rfc2251/RfcAttributeList.cs
+Novell.Directory.Ldap.Rfc2251/RfcMatchingRuleId.cs
+Novell.Directory.Ldap.Rfc2251/RfcDelRequest.cs
+Novell.Directory.Ldap.Rfc2251/RfcDelResponse.cs
+Novell.Directory.Ldap.Rfc2251/RfcMatchingRuleAssertion.cs
+Novell.Directory.Ldap.Rfc2251/RfcSubstringFilter.cs
+Novell.Directory.Ldap.Rfc2251/RfcAttributeDescription.cs
+Novell.Directory.Ldap.Rfc2251/RfcAttributeValueAssertion.cs
+Novell.Directory.Ldap.Rfc2251/RfcAssertionValue.cs
+Novell.Directory.Ldap.Rfc2251/RfcSaslCredentials.cs
+Novell.Directory.Ldap.Rfc2251/RfcAbandonRequest.cs
+Novell.Directory.Ldap.Rfc2251/RfcAuthenticationChoice.cs
+Novell.Directory.Ldap.Rfc2251/RfcFilter.cs
+Novell.Directory.Ldap.Rfc2251/RfcLdapString.cs
+Novell.Directory.Ldap.Rfc2251/RfcLdapOID.cs
+Novell.Directory.Ldap.Rfc2251/RfcLdapDN.cs
+Novell.Directory.Ldap.Rfc2251/RfcMessageID.cs
+Novell.Directory.Ldap.Rfc2251/RfcRequest.cs
+Novell.Directory.Ldap.Rfc2251/RfcSearchRequest.cs
+Novell.Directory.Ldap.Rfc2251/RfcReferral.cs
+Novell.Directory.Ldap.Rfc2251/RfcLdapResult.cs
+Novell.Directory.Ldap.Rfc2251/RfcResponse.cs
+Novell.Directory.Ldap.Rfc2251/RfcSearchResultEntry.cs
+Novell.Directory.Ldap.Rfc2251/RfcSearchResultDone.cs
+Novell.Directory.Ldap.Rfc2251/RfcSearchResultReference.cs
+Novell.Directory.Ldap.Rfc2251/RfcBindRequest.cs
+Novell.Directory.Ldap.Rfc2251/RfcBindResponse.cs
+Novell.Directory.Ldap.Rfc2251/RfcControl.cs
+Novell.Directory.Ldap.Rfc2251/RfcControls.cs
+Novell.Directory.Ldap.Rfc2251/RfcLdapMessage.cs
+Novell.Directory.Ldap.Rfc2251/RfcUnbindRequest.cs
+Novell.Directory.Ldap.Rfc2251/RfcExtendedRequest.cs
+Novell.Directory.Ldap.Rfc2251/RfcExtendedResponse.cs
+Novell.Directory.Ldap/SupportClass.cs
+Novell.Directory.Ldap/LdapConnection.cs
+Novell.Directory.Ldap/LdapAuthHandler.cs
+Novell.Directory.Ldap/LdapBindHandler.cs
+Novell.Directory.Ldap/LdapAuthProvider.cs
+Novell.Directory.Ldap/LdapModifyRequest.cs
+Novell.Directory.Ldap/LdapModifyDNRequest.cs
+Novell.Directory.Ldap/LdapCompareAttrNames.cs
+Novell.Directory.Ldap/LdapCompareRequest.cs
+Novell.Directory.Ldap/LdapModification.cs
+Novell.Directory.Ldap/LdapAddRequest.cs
+Novell.Directory.Ldap/LdapResponseQueue.cs
+Novell.Directory.Ldap/LdapDeleteRequest.cs
+Novell.Directory.Ldap/LdapLocalException.cs
+Novell.Directory.Ldap/LdapSearchRequest.cs
+Novell.Directory.Ldap/LdapSearchQueue.cs
+Novell.Directory.Ldap/LdapAbandonRequest.cs
+Novell.Directory.Ldap/LdapBindRequest.cs
+Novell.Directory.Ldap/LdapSearchConstraints.cs
+Novell.Directory.Ldap/LdapReferralHandler.cs
+Novell.Directory.Ldap/LdapReferralException.cs
+Novell.Directory.Ldap/LdapUnsolicitedNotificationListener.cs
+Novell.Directory.Ldap/LdapConstraints.cs
+Novell.Directory.Ldap/LdapExtendedOperation.cs
+Novell.Directory.Ldap/LdapExtendedRequest.cs
+Novell.Directory.Ldap/LdapExtendedResponse.cs
+Novell.Directory.Ldap/InterThreadException.cs
+Novell.Directory.Ldap/MessageVector.cs
+Novell.Directory.Ldap/LdapResponse.cs
+Novell.Directory.Ldap/LdapUnbindRequest.cs
+Novell.Directory.Ldap/Connection.cs
+Novell.Directory.Ldap/Message.cs
+Novell.Directory.Ldap/LdapDN.cs
+Novell.Directory.Ldap/LdapEntry.cs
+Novell.Directory.Ldap/LdapAttribute.cs
+Novell.Directory.Ldap/LdapAttributeSet.cs
+Novell.Directory.Ldap/LdapSearchResult.cs
+Novell.Directory.Ldap/LdapSearchResults.cs
+Novell.Directory.Ldap/LdapSearchResultReference.cs
+Novell.Directory.Ldap/LdapMessageQueue.cs
+Novell.Directory.Ldap/MessageAgent.cs
+Novell.Directory.Ldap/LdapUrl.cs
+Novell.Directory.Ldap/LdapControl.cs
+Novell.Directory.Ldap/LdapException.cs
+Novell.Directory.Ldap/LdapMessage.cs
+Novell.Directory.Ldap.Extensions/AbortPartitionOperationRequest.cs
+Novell.Directory.Ldap.Extensions/AddReplicaRequest.cs
+Novell.Directory.Ldap.Extensions/PartitionEntryCountRequest.cs
+Novell.Directory.Ldap.Extensions/ChangeReplicaTypeRequest.cs
+Novell.Directory.Ldap.Extensions/PartitionEntryCountResponse.cs
+Novell.Directory.Ldap.Extensions/GetBindDNRequest.cs
+Novell.Directory.Ldap.Extensions/PartitionSyncRequest.cs
+Novell.Directory.Ldap.Extensions/GetBindDNResponse.cs
+Novell.Directory.Ldap.Extensions/ReceiveAllUpdatesRequest.cs
+Novell.Directory.Ldap.Extensions/GetEffectivePrivilegesRequest.cs
+Novell.Directory.Ldap.Extensions/RefreshLdapServerRequest.cs
+Novell.Directory.Ldap.Extensions/GetEffectivePrivilegesResponse.cs
+Novell.Directory.Ldap.Extensions/RemoveOrphanPartitionRequest.cs
+Novell.Directory.Ldap.Extensions/GetReplicaInfoRequest.cs
+Novell.Directory.Ldap.Extensions/RemoveReplicaRequest.cs
+Novell.Directory.Ldap.Extensions/GetReplicaInfoResponse.cs
+Novell.Directory.Ldap.Extensions/ReplicationConstants.cs
+Novell.Directory.Ldap.Extensions/GetReplicationFilterRequest.cs
+Novell.Directory.Ldap.Extensions/SchemaSyncRequest.cs
+Novell.Directory.Ldap.Extensions/GetReplicationFilterResponse.cs
+Novell.Directory.Ldap.Extensions/SendAllUpdatesRequest.cs
+Novell.Directory.Ldap.Extensions/ListReplicasRequest.cs
+Novell.Directory.Ldap.Extensions/SetReplicationFilterRequest.cs
+Novell.Directory.Ldap.Extensions/ListReplicasResponse.cs
+Novell.Directory.Ldap.Extensions/SplitOrphanPartitionRequest.cs
+Novell.Directory.Ldap.Extensions/MergePartitionsRequest.cs
+Novell.Directory.Ldap.Extensions/SplitPartitionRequest.cs
+Novell.Directory.Ldap.Extensions/NamingContextConstants.cs
+Novell.Directory.Ldap.Extensions/TriggerBackgroundProcessRequest.cs
+Novell.Directory.Ldap.Controls/LdapEntryChangeControl.cs
+Novell.Directory.Ldap.Controls/LdapPersistSearchControl.cs
+Novell.Directory.Ldap.Controls/LdapSortControl.cs
+Novell.Directory.Ldap.Controls/LdapSortKey.cs
+Novell.Directory.Ldap.Controls/LdapSortResponse.cs
+Novell.Directory.Ldap.Controls/LdapVirtualListControl.cs
+Novell.Directory.Ldap.Controls/LdapVirtualListResponse.cs
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/AssemblyInfo.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/AssemblyInfo.cs
new file mode 100755
index 00000000000..032715ce066
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/AssemblyInfo.cs
@@ -0,0 +1,93 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.AssemblyInfo.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+using System;
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Resources;
+using System.Security;
+using System.Runtime.InteropServices;
+
+//
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+//
+[assembly: AssemblyTitle("C# LDAP")]
+[assembly: AssemblyDescription("Novell.Directory.Ldap")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("Novell, Inc")]
+[assembly: AssemblyProduct("")]
+[assembly: AssemblyCopyright(" (C) 2003 Novell, Inc")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+[assembly: CLSCompliant(true)]
+
+//
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Revision and Build Numbers
+// by using the '*' as shown below:
+
+[assembly: AssemblyVersion("1.0.0")]
+
+//
+// In order to sign your assembly you must specify a key to use. Refer to the
+// Microsoft .NET Framework documentation for more information on assembly signing.
+//
+// Use the attributes below to control which key is used for signing.
+//
+// Notes:
+// (*) If no key is specified, the assembly is not signed.
+// (*) KeyName refers to a key that has been installed in the Crypto Service
+// Provider (CSP) on your machine. KeyFile refers to a file which contains
+// a key.
+// (*) If the KeyFile and the KeyName values are both specified, the
+// following processing occurs:
+// (1) If the KeyName can be found in the CSP, that key is used.
+// (2) If the KeyName does not exist and the KeyFile does exist, the key
+// in the KeyFile is installed into the CSP and used.
+// (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility.
+// When specifying the KeyFile, the location of the KeyFile should be
+// relative to the project output directory which is
+// %Project Directory%\obj\<configuration>. For example, if your KeyFile is
+// located in the project directory, you would specify the AssemblyKeyFile
+// attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")]
+// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework
+// documentation for more information on this.
+//
+[assembly: AssemblyDelaySign(false)]
+//[assembly: AssemblyKeyFile("")]
+//[assembly: AssemblyKeyName("")]
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/Connection.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/Connection.cs
new file mode 100755
index 00000000000..97e5f4198c0
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/Connection.cs
@@ -0,0 +1,1387 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.Connection.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+using System.Threading;
+using Novell.Directory.Ldap.Asn1;
+using Novell.Directory.Ldap.Rfc2251;
+using Novell.Directory.Ldap.Utilclass;
+
+namespace Novell.Directory.Ldap
+{
+
+ /// <summary> The class that creates a connection to the Ldap server. After the
+ /// connection is made, a thread is created that reads data from the
+ /// connection.
+ /// <p>
+ /// The application's thread sends a request to the MessageAgent class, which
+ /// creates a Message class. The Message class calls the writeMessage method
+ /// of this class to send the request to the server. The application thread
+ /// will then query the MessageAgent class for a response.
+ /// <p>
+ /// The reader thread multiplexes response messages received from the
+ /// server to the appropriate Message class. Each Message class
+ /// has its own message queue.
+ /// <p>
+ /// Unsolicited messages are process separately, and if the application
+ /// has registered a handler, a separate thread is created for that
+ /// application's handler to process the message.
+ /// <p>
+ /// Note: the reader thread must not be a "selfish" thread, since some
+ /// operating systems do not time slice.
+ ///
+ /// </summary>
+ /*package*/
+ sealed class Connection
+ {
+ private void InitBlock()
+ {
+ writeSemaphore = new System.Object();
+ encoder = new LBEREncoder();
+ decoder = new LBERDecoder();
+ stopReaderMessageID = CONTINUE_READING;
+ messages = new MessageVector(5, 5);
+ unsolicitedListeners = new System.Collections.ArrayList(3);
+ }
+ /// <summary> Indicates whether clones exist for LdapConnection
+ ///
+ /// </summary>
+ /// <returns> true if clones exist, false otherwise.
+ /// </returns>
+ internal bool Cloned
+ {
+ /* package */
+
+ get
+ {
+ return (cloneCount > 0);
+ }
+
+ }
+ /// <summary> gets the host used for this connection</summary>
+ internal System.String Host
+ {
+ /* package */
+
+ get
+ {
+ return host;
+ }
+
+ }
+ /// <summary> gets the port used for this connection</summary>
+ internal int Port
+ {
+ /* package */
+
+ get
+ {
+ return port;
+ }
+
+ }
+ /// <summary> gets the writeSemaphore id used for active bind operation</summary>
+ /// <summary> sets the writeSemaphore id used for active bind operation</summary>
+ internal int BindSemId
+ {
+ /* package */
+
+ get
+ {
+ return bindSemaphoreId;
+ }
+
+ /* package */
+
+ set
+ {
+ bindSemaphoreId = value;
+ return ;
+ }
+
+ }
+ /// <summary> checks if the writeSemaphore id used for active bind operation is clear</summary>
+ internal bool BindSemIdClear
+ {
+ /* package */
+
+ get
+ {
+ if (bindSemaphoreId == 0)
+ {
+ return true;
+ }
+ return false;
+ }
+
+ }
+ /// <summary> Return whether the application is bound to this connection.
+ /// Note: an anonymous bind returns false - not bound
+ /// </summary>
+ internal bool Bound
+ {
+ /* package */
+
+ get
+ {
+ if (bindProperties != null)
+ {
+ // Bound if not anonymous
+ return (!bindProperties.Anonymous);
+ }
+ return false;
+ }
+
+ }
+ /// <summary> Return whether a connection has been made</summary>
+ internal bool Connected
+ {
+ /* package */
+
+ get
+ {
+ return (in_Renamed != null);
+ }
+
+ }
+ /// <summary>
+ /// Sets the authentication credentials in the object
+ /// and set flag indicating successful bind.
+ ///
+ ///
+ /// <br><br>
+ /// </summary>
+ /// <returns> The BindProperties object for this connection.
+ /// </returns>
+ /// <summary>
+ /// Sets the authentication credentials in the object
+ /// and set flag indicating successful bind.
+ ///
+ ///
+ /// <br><br>
+ /// </summary>
+ /// <param name="bindProps"> The BindProperties object to set.
+ /// </param>
+ internal BindProperties BindProperties
+ {
+ /* package */
+
+ get
+ {
+ return bindProperties;
+ }
+
+ /* package */
+
+ set
+ {
+ bindProperties = value;
+ return ;
+ }
+
+ }
+ /// <summary> Gets the current referral active on this connection if created to
+ /// follow referrals.
+ ///
+ /// </summary>
+ /// <returns> the active referral url
+ /// </returns>
+ /// <summary> Sets the current referral active on this connection if created to
+ /// follow referrals.
+ /// </summary>
+ internal ReferralInfo ActiveReferral
+ {
+
+
+ get
+ {
+ return activeReferral;
+ }
+
+
+
+ set
+ {
+ activeReferral = value;
+ return ;
+ }
+
+ }
+
+ /// <summary> Returns the name of this Connection, used for debug only
+ ///
+ /// </summary>
+ /// <returns> the name of this connection
+ /// </returns>
+ internal System.String ConnectionName
+ {
+ /*package*/
+
+ get
+ {
+ return name;
+ }
+
+ }
+
+ private System.Object writeSemaphore;
+ private int writeSemaphoreOwner = 0;
+ private int writeSemaphoreCount = 0;
+
+ // We need a message number for disconnect to grab the semaphore,
+ // but may not have one, so we invent a unique one.
+ private int ephemeralId = - 1;
+ private BindProperties bindProperties = null;
+ private int bindSemaphoreId = 0; // 0 is never used by to lock a semaphore
+
+ private SupportClass.ThreadClass reader = null; // New thread that reads data from the server.
+ private SupportClass.ThreadClass deadReader = null; // Identity of last reader thread
+ private System.IO.IOException deadReaderException = null; // Last exception of reader
+
+ private LBEREncoder encoder;
+ private LBERDecoder decoder;
+
+ /*
+ * socket is the current socket being used.
+ * nonTLSBackup is the backup socket if startTLS is called.
+ * if nonTLSBackup is null then startTLS has not been called,
+ * or stopTLS has been called to end TLS protection
+ */
+ private System.Net.Sockets.TcpClient socket = null;
+ private System.Net.Sockets.TcpClient nonTLSBackup = null;
+
+ private System.IO.Stream in_Renamed = null;
+ private System.IO.Stream out_Renamed = null;
+ // When set to true the client connection is up and running
+ private bool clientActive = true;
+
+ // Indicates we have received a server shutdown unsolicited notification
+ private bool unsolSvrShutDnNotification = false;
+
+ // Ldap message IDs are all positive numbers so we can use negative
+ // numbers as flags. This are flags assigned to stopReaderMessageID
+ // to tell the reader what state we are in.
+ private const int CONTINUE_READING = - 99;
+ private const int STOP_READING = - 98;
+
+ // Stops the reader thread when a Message with the passed-in ID is read.
+ // This parameter is set by stopReaderOnReply and stopTLS
+ private int stopReaderMessageID;
+
+
+ // Place to save message information classes
+ private MessageVector messages;
+
+ // Connection created to follow referral
+ private ReferralInfo activeReferral = null;
+
+ // Place to save unsolicited message listeners
+ private System.Collections.ArrayList unsolicitedListeners;
+
+ // The LdapSocketFactory to be used as the default to create new connections
+// private static LdapSocketFactory socketFactory = null;
+ // The LdapSocketFactory used for this connection
+// private LdapSocketFactory mySocketFactory;
+ private System.String host = null;
+ private int port = 0;
+ // Number of clones in addition to original LdapConnection using this
+ // connection.
+ private int cloneCount = 0;
+ // Connection number & name used only for debug
+ private System.String name = "";
+ private static System.Object nameLock; // protect connNum
+ private static int connNum = 0;
+
+ // These attributes can be retreived using the getProperty
+ // method in LdapConnection. Future releases might require
+ // these to be local variables that can be modified using
+ // the setProperty method.
+ /* package */
+ internal static System.String sdk;
+ /* package */
+ internal static System.Int32 protocol;
+ /* package */
+ internal static System.String security = "simple";
+
+ /// <summary> Create a new Connection object
+ ///
+ /// </summary>
+ /// <param name="factory">specifies the factory to use to produce SSL sockets.
+ /// </param>
+ /* package */
+// internal Connection(LdapSocketFactory factory)
+ internal Connection()
+ {
+ InitBlock();
+ return ;
+ }
+
+ /// <summary> Copy this Connection object.
+ ///
+ /// <p>This is not a true clone, but creates a new object encapsulating
+ /// part of the connection information from the original object.
+ /// The new object will have the same default socket factory,
+ /// designated socket factory, host, port, and protocol version
+ /// as the original object.
+ /// The new object is NOT be connected to the host.</p>
+ ///
+ /// </summary>
+ /// <returns> a shallow copy of this object
+ /// </returns>
+ /* package */
+ internal System.Object copy()
+ {
+ Connection c = new Connection();
+ c.host = this.host;
+ c.port = this.port;
+ Novell.Directory.Ldap.Connection.protocol = Connection.protocol;
+ return c;
+ }
+
+ /// <summary> Acquire a simple counting semaphore that synchronizes state affecting
+ /// bind. This method generates an ephemeral message id (negative number).
+ ///
+ /// We bind using the message ID because a different thread may unlock
+ /// the semaphore than the one that set it. It is cleared when the
+ /// response to the bind is processed, or when the bind operation times out.
+ ///
+ /// Returns when the semaphore is acquired
+ ///
+ /// </summary>
+ /// <returns> the ephemeral message id that identifies semaphore's owner
+ /// </returns>
+ /* package */
+ internal int acquireWriteSemaphore()
+ {
+ return acquireWriteSemaphore(0);
+ }
+
+ /// <summary> Acquire a simple counting semaphore that synchronizes state affecting
+ /// bind. The semaphore is held by setting a value in writeSemaphoreOwner.
+ ///
+ /// We bind using the message ID because a different thread may unlock
+ /// the semaphore than the one that set it. It is cleared when the
+ /// response to the bind is processed, or when the bind operation times out.
+ /// Returns when the semaphore is acquired.
+ ///
+ /// </summary>
+ /// <param name="msgId">a value that identifies the owner of this semaphore. A
+ /// value of zero means assign a unique semaphore value.
+ ///
+ /// </param>
+ /// <returns> the semaphore value used to acquire the lock
+ /// </returns>
+ /* package */
+ internal int acquireWriteSemaphore(int msgId)
+ {
+ int id = msgId;
+ lock (writeSemaphore)
+ {
+ if (id == 0)
+ {
+ ephemeralId = ((ephemeralId == System.Int32.MinValue)?(ephemeralId = - 1):--ephemeralId);
+ id = ephemeralId;
+ }
+ while (true)
+ {
+ if (writeSemaphoreOwner == 0)
+ {
+ // we have acquired the semahpore
+ writeSemaphoreOwner = id;
+ break;
+ }
+ else
+ {
+ if (writeSemaphoreOwner == id)
+ {
+ // we already own the semahpore
+ break;
+ }
+ try
+ {
+ // Keep trying for the lock
+ System.Threading.Monitor.Wait(writeSemaphore);
+ continue;
+ }
+ catch (System.Threading.ThreadInterruptedException ex)
+ {
+ // Keep trying for the lock
+ continue;
+ }
+ }
+ }
+ writeSemaphoreCount++;
+ }
+ return id;
+ }
+
+ /// <summary> Release a simple counting semaphore that synchronizes state affecting
+ /// bind. Frees the semaphore when number of acquires and frees for this
+ /// thread match.
+ ///
+ /// </summary>
+ /// <param name="msgId">a value that identifies the owner of this semaphore
+ /// </param>
+ /* package */
+ internal void freeWriteSemaphore(int msgId)
+ {
+ lock (writeSemaphore)
+ {
+ if (writeSemaphoreOwner == 0)
+ {
+ throw new System.SystemException("Connection.freeWriteSemaphore(" + msgId + "): semaphore not owned by any thread");
+ }
+ else if (writeSemaphoreOwner != msgId)
+ {
+ throw new System.SystemException("Connection.freeWriteSemaphore(" + msgId + "): thread does not own the semaphore, owned by " + writeSemaphoreOwner);
+ }
+ // if all instances of this semaphore for this thread are released,
+ // wake up all threads waiting.
+ if (--writeSemaphoreCount == 0)
+ {
+ writeSemaphoreOwner = 0;
+ System.Threading.Monitor.Pulse(writeSemaphore);
+ }
+ }
+ return ;
+ }
+
+ /*
+ * Wait until the reader thread ID matches the specified parameter.
+ * Null = wait for the reader to terminate
+ * Non Null = wait for the reader to start
+ * Returns when the ID matches, i.e. reader stopped, or reader started.
+ *
+ * @param the thread id to match
+ */
+ private void waitForReader(SupportClass.ThreadClass thread)
+ {
+ // wait for previous reader thread to terminate
+ System.Threading.Thread rInst;
+ System.Threading.Thread tInst;
+ if(reader!=null)
+ {
+ rInst=reader.Instance;
+ }
+ else
+ {
+ rInst=null;
+ }
+
+ if(thread!=null)
+ {
+ tInst=thread.Instance;
+ }
+ else
+ {
+ tInst=null;
+ }
+// while (reader != thread)
+ while (!Object.Equals(rInst,tInst))
+ {
+ // Don't initialize connection while previous reader thread still
+ // active.
+ try
+ {
+ /*
+ * The reader thread may start and immediately terminate.
+ * To prevent the waitForReader from waiting forever
+ * for the dead to rise, we leave traces of the deceased.
+ * If the thread is already gone, we throw an exception.
+ */
+ if (thread == deadReader)
+ {
+ if (thread == null)
+ /* then we wanted a shutdown */
+ return ;
+ System.IO.IOException lex = deadReaderException;
+ deadReaderException = null;
+ deadReader = null;
+ // Reader thread terminated
+ throw new LdapException(ExceptionMessages.CONNECTION_READER, LdapException.CONNECT_ERROR, null, lex);
+ }
+ lock (this)
+ {
+ System.Threading.Monitor.Wait(this, TimeSpan.FromMilliseconds(5));
+ }
+ }
+ catch (System.Threading.ThreadInterruptedException ex)
+ {
+ ;
+ }
+ if(reader!=null)
+ {
+ rInst=reader.Instance;
+ }
+ else
+ {
+ rInst=null;
+ }
+
+ if(thread!=null)
+ {
+ tInst=thread.Instance;
+ }
+ else
+ {
+ tInst=null;
+ }
+
+ }
+ deadReaderException = null;
+ deadReader = null;
+ return ;
+ }
+
+ /// <summary> Constructs a TCP/IP connection to a server specified in host and port.
+ ///
+ /// </summary>
+ /// <param name="host">The host to connect to.
+ /// <br><br>
+ /// </param>
+ /// <param name="port">The port on the host to connect to.
+ /// </param>
+ /* package */
+ internal void connect(System.String host, int port)
+ {
+ connect(host, port, 0);
+ return ;
+ }
+
+ /// <summary> Constructs a TCP/IP connection to a server specified in host and port.
+ /// Starts the reader thread.
+ ///
+ /// </summary>
+ /// <param name="host">The host to connect to.
+ /// <br><br>
+ /// </param>
+ /// <param name="port">The port on the host to connect to.
+ /// <br><br>
+ /// </param>
+ /// <param name="semaphoreId">The write semaphore ID to use for the connect
+ /// </param>
+ private void connect(System.String host, int port, int semaphoreId)
+ {
+ /* Synchronized so all variables are in a consistant state and
+ * so that another thread isn't doing a connect, disconnect, or clone
+ * at the same time.
+ */
+ // Wait for active reader to terminate
+ waitForReader(null);
+
+ // Clear the server shutdown notification flag. This should already
+ // be false unless of course we are reusing the same Connection object
+ // after a server shutdown notification
+ unsolSvrShutDnNotification = false;
+
+ int semId = acquireWriteSemaphore(semaphoreId);
+
+ // Make socket connection to specified host and port
+ if (port == 0)
+ {
+ port = 389;//LdapConnection.DEFAULT_PORT;
+ }
+
+ try
+ {
+ if ((in_Renamed == null) || (out_Renamed == null))
+ {
+ socket = new System.Net.Sockets.TcpClient(host, port);
+
+ in_Renamed = (System.IO.Stream) socket.GetStream();
+ out_Renamed = (System.IO.Stream) socket.GetStream();
+ }
+ else
+ {
+ Console.WriteLine( "connect input/out Stream specified");
+
+ }
+ }
+ catch (System.IO.IOException ioe)
+ {
+ // Unable to connect to server host:port
+// freeWriteSemaphore(semId);
+ throw new LdapException(ExceptionMessages.CONNECTION_ERROR, new System.Object[]{host, port}, LdapException.CONNECT_ERROR, null, ioe);
+ }
+ // Set host and port
+ this.host = host;
+ this.port = port;
+ // start the reader thread
+ this.startReader();
+ freeWriteSemaphore(semId);
+ clientActive = true; // Client is up
+ return ;
+ }
+
+ /// <summary> Increments the count of cloned connections</summary>
+ /* package */
+ internal void incrCloneCount()
+ {
+ lock (this)
+ {
+ cloneCount++;
+ return ;
+ }
+ }
+
+ /// <summary> Destroys a clone of <code>LdapConnection</code>.
+ ///
+ /// <p>This method first determines if only one <code>LdapConnection</code>
+ /// object is associated with this connection, i.e. if no clone exists.</p>
+ ///
+ /// <p>If no clone exists, the socket is closed, and the current
+ /// <code>Connection</code> object is returned.</p>
+ ///
+ /// <p>If multiple <code>LdapConnection</code> objects are associated
+ /// with this connection, i.e. clones exist, a {@link #copy} of the
+ /// this object is made, but is not connected to any host. This
+ /// disassociates that clone from the original connection. The new
+ /// <code>Connection</code> object is returned.
+ ///
+ /// <p>Only one destroyClone instance is allowed to run at any one time.</p>
+ ///
+ /// <p>If the connection is closed, any threads waiting for operations
+ /// on that connection will wake with an LdapException indicating
+ /// the connection is closed.</p>
+ ///
+ /// </summary>
+ /// <param name="apiCall"><code>true</code> indicates the application is closing the
+ /// connection or or creating a new one by calling either the
+ /// <code>connect</code> or <code>disconnect</code> methods
+ /// of <code>LdapConnection</code>. <code>false</code>
+ /// indicates that <code>LdapConnection</code> is being finalized.
+ ///
+ /// </param>
+ /// <returns> a Connection object or null if finalizing.
+ /// </returns>
+ /* package */
+ internal Connection destroyClone(bool apiCall)
+ {
+ lock (this)
+ {
+ Connection conn = this;
+
+ if (cloneCount > 0)
+ {
+ cloneCount--;
+ // This is a clone, set a new connection object.
+ if (apiCall)
+ {
+ conn = (Connection) this.copy();
+ }
+ else
+ {
+ conn = null;
+ }
+ }
+ else
+ {
+ if (in_Renamed != null)
+ {
+ // Not a clone and connected
+ /*
+ * Either the application has called disconnect or connect
+ * resulting in the current connection being closed. If the
+ * application has any queues waiting on messages, we
+ * need wake these up so the application does not hang.
+ * The boolean flag indicates whether the close came
+ * from an API call or from the object being finalized.
+ */
+ InterThreadException notify = new InterThreadException((apiCall?ExceptionMessages.CONNECTION_CLOSED:ExceptionMessages.CONNECTION_FINALIZED), null, LdapException.CONNECT_ERROR, null, null);
+ // Destroy old connection
+ shutdown("destroy clone", 0, notify);
+ }
+ }
+ return conn;
+ }
+ }
+
+ /// <summary> sets the default socket factory
+ ///
+ /// </summary>
+ /// <param name="factory">the default factory to set
+ /// </param>
+ /* package */
+ /// <summary> gets the socket factory used for this connection
+ ///
+ /// </summary>
+ /// <returns> the default factory for this connection
+ /// </returns>
+ /* package */
+
+ /// <summary> clears the writeSemaphore id used for active bind operation</summary>
+ /* package */
+ internal void clearBindSemId()
+ {
+ bindSemaphoreId = 0;
+ return ;
+ }
+
+ /// <summary> Writes an LdapMessage to the Ldap server over a socket.
+ ///
+ /// </summary>
+ /// <param name="info">the Message containing the message to write.
+ /// </param>
+ /* package */
+ internal void writeMessage(Message info)
+ {
+ messages.Add(info);
+ // For bind requests, if not connected, attempt to reconnect
+ if (info.BindRequest && (Connected == false) && ((System.Object) host != null))
+ {
+ connect(host, port, info.MessageID);
+ }
+ LdapMessage msg = info.Request;
+ writeMessage(msg);
+ return ;
+ }
+
+
+ /// <summary> Writes an LdapMessage to the Ldap server over a socket.
+ ///
+ /// </summary>
+ /// <param name="msg">the message to write.
+ /// </param>
+ /* package */
+ internal void writeMessage(LdapMessage msg)
+ {
+ int id;
+ // Get the correct semaphore id for bind operations
+ if (bindSemaphoreId == 0)
+ {
+ // Semaphore id for normal operations
+ id = msg.MessageID;
+ }
+ else
+ {
+ // Semaphore id for sasl bind operations
+ id = bindSemaphoreId;
+ }
+ System.IO.Stream myOut = out_Renamed;
+
+ acquireWriteSemaphore(id);
+ try
+ {
+ if (myOut == null)
+ {
+ throw new System.IO.IOException("Output stream not initialized");
+ }
+ sbyte[] ber = msg.Asn1Object.getEncoding(encoder);
+ myOut.Write(SupportClass.ToByteArray(ber), 0, ber.Length);
+ myOut.Flush();
+ }
+ catch (System.IO.IOException ioe)
+ {
+
+ /*
+ * IOException could be due to a server shutdown notification which
+ * caused our Connection to quit. If so we send back a slightly
+ * different error message. We could have checked this a little
+ * earlier in the method but that would be an expensive check each
+ * time we send out a message. Since this shutdown request is
+ * going to be an infrequent occurence we check for it only when
+ * we get an IOException. shutdown() will do the cleanup.
+ */
+ if (clientActive)
+ {
+ // We beliefe the connection was alive
+ if (unsolSvrShutDnNotification)
+ {
+ // got server shutdown
+ throw new LdapException(ExceptionMessages.SERVER_SHUTDOWN_REQ, new System.Object[]{host, port}, LdapException.CONNECT_ERROR, null, ioe);
+ }
+
+ // Other I/O Exceptions on host:port are reported as is
+ throw new LdapException(ExceptionMessages.IO_EXCEPTION, new System.Object[]{host, port}, LdapException.CONNECT_ERROR, null, ioe);
+ }
+ }
+ finally
+ {
+ freeWriteSemaphore(id);
+ }
+ return ;
+ }
+
+ /// <summary> Returns the message agent for this msg ID</summary>
+ /* package */
+ internal MessageAgent getMessageAgent(int msgId)
+ {
+ Message info = messages.findMessageById(msgId);
+ return info.MessageAgent;
+ }
+
+ /// <summary> Removes a Message class from the Connection's list
+ ///
+ /// </summary>
+ /// <param name="info">the Message class to remove from the list
+ /// </param>
+ /* package */
+ internal void removeMessage(Message info)
+ {
+ bool done = SupportClass.VectorRemoveElement(messages, info);
+ return ;
+ }
+
+ /// <summary> Cleans up resources associated with this connection.</summary>
+ ~Connection()
+ {
+ shutdown("Finalize", 0, null);
+ return ;
+ }
+ /// <summary> Cleans up resources associated with this connection.
+ /// This method may be called by finalize() for the connection, or it may
+ /// be called by LdapConnection.disconnect().
+ /// Should not have a writeSemaphore lock in place, as deadlock can occur
+ /// while abandoning connections.
+ /// </summary>
+ private void shutdown(System.String reason, int semaphoreId, InterThreadException notifyUser)
+ {
+ Message info = null;
+ if (!clientActive)
+ {
+ return ;
+ }
+ clientActive = false;
+ while (true)
+ {
+ // remove messages from connection list and send abandon
+ try
+ {
+ System.Object temp_object;
+ temp_object = messages[0];
+ messages.RemoveAt(0);
+ info = (Message) temp_object;
+ }
+ catch (ArgumentOutOfRangeException ex)
+ {
+ // No more messages
+ break;
+ }
+ info.Abandon(null, notifyUser); // also notifies the application
+ }
+
+ int semId = acquireWriteSemaphore(semaphoreId);
+ // Now send unbind if socket not closed
+ if ((bindProperties != null) && (out_Renamed != null) && (!bindProperties.Anonymous))
+ {
+ try
+ {
+ LdapMessage msg = new LdapUnbindRequest(null);
+ sbyte[] ber = msg.Asn1Object.getEncoding(encoder);
+ out_Renamed.Write(SupportClass.ToByteArray(ber), 0, ber.Length);
+ out_Renamed.Flush();
+ }
+ catch (System.Exception ex)
+ {
+ ; // don't worry about error
+ }
+ }
+ bindProperties = null;
+
+ in_Renamed = null;
+ out_Renamed = null;
+ if (socket != null)
+ {
+ // Close the socket
+ try
+ {
+ socket.Close();
+ }
+ catch (System.IO.IOException ie)
+ {
+ // ignore problem closing socket
+ }
+ socket = null;
+ }
+ freeWriteSemaphore(semId);
+ return ;
+ }
+
+ /// <summary> This tests to see if there are any outstanding messages. If no messages
+ /// are in the queue it returns true. Each message will be tested to
+ /// verify that it is complete.
+ /// <I>The writeSemaphore must be set for this method to be reliable!</I>
+ ///
+ /// </summary>
+ /// <returns> true if no outstanding messages
+ /// </returns>
+ /* package */
+ internal bool areMessagesComplete()
+ {
+ System.Object[] messages = this.messages.ObjectArray;
+ int length = messages.Length;
+
+ // Check if SASL bind in progress
+ if (bindSemaphoreId != 0)
+ {
+ return false;
+ }
+
+ // Check if any messages queued
+ if (length == 0)
+ {
+ return true;
+ }
+
+ for (int i = 0; i < length; i++)
+ {
+ if (((Message) messages[i]).Complete == false)
+ return false;
+ }
+ return true;
+ }
+
+ /// <summary> The reader thread will stop when a reply is read with an ID equal
+ /// to the messageID passed in to this method. This is used by
+ /// LdapConnection.StartTLS.
+ /// </summary>
+ /* package */
+ internal void stopReaderOnReply(int messageID)
+ {
+
+ this.stopReaderMessageID = messageID;
+ return ;
+ }
+
+ /// <summary>startReader
+ /// startReader should be called when socket and io streams have been
+ /// set or changed. In particular after client.Connection.startTLS()
+ /// It assumes the reader thread is not running.
+ /// </summary>
+ /* package */
+ internal void startReader()
+ {
+ // Start Reader Thread
+ SupportClass.ThreadClass r =new SupportClass.ThreadClass(new System.Threading.ThreadStart(new ReaderThread(this).Run));
+// Thread r = new Thread(new ThreadStart(new ReaderThread(this).Run));
+ r.IsBackground = true; // If the last thread running, allow exit.
+ r.Start();
+ waitForReader(r);
+ return ;
+ }
+
+ /// <summary> StartsTLS, in this package, assumes the caller has:
+ /// 1) Acquired the writeSemaphore
+ /// 2) Stopped the reader thread
+ /// 3) checked that no messages are outstanding on this connection.
+ ///
+ /// After calling this method upper layers should start the reader
+ /// by calling startReader()
+ ///
+ /// In the client.Connection, StartTLS assumes Ldap.LdapConnection will
+ /// stop and start the reader thread. Connection.StopTLS will stop
+ /// and start the reader thread.
+ /// </summary>
+ /* package */
+/* internal void startTLS()
+ {
+ if (this.mySocketFactory == null)
+ {
+ throw new LdapException(ExceptionMessages.NO_TLS_FACTORY, LdapException.TLS_NOT_SUPPORTED, null);
+ }
+ else if (!(this.mySocketFactory is LdapTLSSocketFactory))
+ {
+ throw new LdapException(ExceptionMessages.WRONG_FACTORY, LdapException.TLS_NOT_SUPPORTED, null);
+ }
+
+ try
+ {
+ waitForReader(null);
+ this.nonTLSBackup = this.socket;
+ this.socket = ((LdapTLSSocketFactory) this.mySocketFactory).createSocket(this.socket);
+ this.in_Renamed = (System.IO.Stream) socket.GetStream();
+ this.out_Renamed = (System.IO.Stream) socket.GetStream();
+
+ if (Debug.Ldap_DEBUG)
+ {
+ Debug.trace(Debug.TLS, "connection.startTLS, nonTLSBackup:" + nonTLSBackup + ", TLSSocket:" + socket + ", input:" + in_Renamed + "," + "output:" + out_Renamed);
+ }
+ }
+ catch (System.Exception uhe)
+ {
+ this.nonTLSBackup = null;
+ throw new LdapException("The host is unknown", LdapException.CONNECT_ERROR, null, uhe);
+ }
+ catch (System.IO.IOException ioe)
+ {
+ this.nonTLSBackup = null;
+ throw new LdapException("Could not negotiate a secure connection", LdapException.CONNECT_ERROR, null, ioe);
+ }
+ return ;
+ }
+*/
+ /*
+ * Stops TLS.
+ *
+ * StopTLS, in this package, assumes the caller has:
+ * 1) blocked writing (acquireWriteSemaphore).
+ * 2) checked that no messages are outstanding.
+ *
+ * StopTLS Needs to do the following:
+ * 1) close the current socket
+ * - This stops the reader thread
+ * - set STOP_READING flag on stopReaderMessageID so that
+ * the reader knows that the IOException is planned.
+ * 2) replace the current socket with nonTLSBackup,
+ * 3) and set nonTLSBackup to null;
+ * 4) reset input and outputstreams
+ * 5) start the reader thread by calling startReader
+ *
+ * Note: Sun's JSSE doesn't allow the nonTLSBackup socket to be
+ * used any more, even though autoclose was false: you get an IOException.
+ * IBM's JSSE hangs when you close the JSSE socket.
+ */
+ /* package */
+/* internal void stopTLS()
+ {
+ try
+ {
+ this.stopReaderMessageID = Connection.STOP_READING;
+ this.socket.Close();
+ waitForReader(null);
+ this.socket = this.nonTLSBackup;
+ this.in_Renamed = (System.IO.Stream) this.socket.GetStream();
+ this.out_Renamed = (System.IO.Stream) this.socket.GetStream();
+ if (Debug.Ldap_DEBUG)
+ {
+ Debug.trace(Debug.TLS, "connection.stopTLS, nonTLSBackup:" + nonTLSBackup + ", TLSSocket:" + socket + ", input:" + in_Renamed + "," + "output:" + out_Renamed);
+ }
+ // Allow the new reader to start
+ this.stopReaderMessageID = Connection.CONTINUE_READING;
+ }
+ catch (System.IO.IOException ioe)
+ {
+ throw new LdapException(ExceptionMessages.STOPTLS_ERROR, LdapException.CONNECT_ERROR, null, ioe);
+ }
+ finally
+ {
+ this.nonTLSBackup = null;
+ startReader();
+ }
+ return ;
+ }
+*///TLS not supported in first release
+
+ public class ReaderThread
+ {
+ private void InitBlock(Connection enclosingInstance)
+ {
+ this.enclosingInstance = enclosingInstance;
+ }
+ private Connection enclosingInstance;
+ public Connection Enclosing_Instance
+ {
+ get
+ {
+ return enclosingInstance;
+ }
+
+ }
+ public ReaderThread(Connection enclosingInstance)
+ {
+ InitBlock(enclosingInstance);
+ return ;
+ }
+
+ /// <summary> This thread decodes and processes RfcLdapMessage's from the server.
+ ///
+ /// Note: This thread needs a graceful shutdown implementation.
+ /// </summary>
+ public virtual void Run()
+ {
+
+ System.String reason = "reader: thread stopping";
+ InterThreadException notify = null;
+ Message info = null;
+ System.IO.IOException ioex = null;
+ this.enclosingInstance.reader = SupportClass.ThreadClass.Current();
+// Enclosing_Instance.reader = SupportClass.ThreadClass.Current();
+// Console.WriteLine("Inside run:" + this.enclosingInstance.reader.Name);
+ try
+ {
+ for (; ; )
+ {
+ // -------------------------------------------------------
+ // Decode an RfcLdapMessage directly from the socket.
+ // -------------------------------------------------------
+ Asn1Identifier asn1ID;
+ System.IO.Stream myIn;
+ /* get current value of in, keep value consistant
+ * though the loop, i.e. even during shutdown
+ */
+ myIn = this.enclosingInstance.in_Renamed;
+ if (myIn == null)
+ {
+ break;
+ }
+ asn1ID = new Asn1Identifier(myIn);
+ int tag = asn1ID.Tag;
+ if (asn1ID.Tag != Asn1Sequence.TAG)
+ {
+ continue; // loop looking for an RfcLdapMessage identifier
+ }
+
+ // Turn the message into an RfcMessage class
+ Asn1Length asn1Len = new Asn1Length(myIn);
+
+ RfcLdapMessage msg = new RfcLdapMessage(this.enclosingInstance.decoder, myIn, asn1Len.Length);
+
+ // ------------------------------------------------------------
+ // Process the decoded RfcLdapMessage.
+ // ------------------------------------------------------------
+ int msgId = msg.MessageID;
+
+ // Find the message which requested this response.
+ // It is possible to receive a response for a request which
+ // has been abandoned. If abandoned, throw it away
+ try
+ {
+ info = this.enclosingInstance.messages.findMessageById(msgId);
+ info.putReply(msg); // queue & wake up waiting thread
+ }
+ catch (System.FieldAccessException ex)
+ {
+
+ /*
+ * We get the NoSuchFieldException when we could not find
+ * a matching message id. First check to see if this is
+ * an unsolicited notification (msgID == 0). If it is not
+ * we throw it away. If it is we call any unsolicited
+ * listeners that might have been registered to listen for these
+ * messages.
+ */
+
+
+ /* Note the location of this code. We could have required
+ * that message ID 0 be just like other message ID's but
+ * since message ID 0 has to be treated specially we have
+ * a separate check for message ID 0. Also note that
+ * this test is after the regular message list has been
+ * checked for. We could have always checked the list
+ * of messages after checking if this is an unsolicited
+ * notification but that would have inefficient as
+ * message ID 0 is a rare event (as of this time).
+ */
+ if (msgId == 0)
+ {
+
+
+ // Notify any listeners that might have been registered
+ this.enclosingInstance.notifyAllUnsolicitedListeners(msg);
+
+ /*
+ * Was this a server shutdown unsolicited notification.
+ * IF so we quit. Actually calling the return will
+ * first transfer control to the finally clause which
+ * will do the necessary clean up.
+ */
+ if (this.enclosingInstance.unsolSvrShutDnNotification)
+ {
+ notify = new InterThreadException(ExceptionMessages.SERVER_SHUTDOWN_REQ, new System.Object[]{this.enclosingInstance.host, this.enclosingInstance.port}, LdapException.CONNECT_ERROR, null, null);
+
+ return ;
+ }
+ }
+ else
+ {
+
+ }
+ }
+ if ((this.enclosingInstance.stopReaderMessageID == msgId) || (this.enclosingInstance.stopReaderMessageID == Novell.Directory.Ldap.Connection.STOP_READING))
+ {
+ // Stop the reader Thread.
+ return ;
+ }
+ }
+ }
+ catch (System.IO.IOException ioe)
+ {
+
+ ioex = ioe;
+ if ((this.enclosingInstance.stopReaderMessageID != Novell.Directory.Ldap.Connection.STOP_READING) && this.enclosingInstance.clientActive)
+ {
+ // Connection lost waiting for results from host:port
+ notify = new InterThreadException(ExceptionMessages.CONNECTION_WAIT, new System.Object[]{this.enclosingInstance.host, this.enclosingInstance.port}, LdapException.CONNECT_ERROR, ioe, info);
+ }
+ // The connection is no good, don't use it any more
+ this.enclosingInstance.in_Renamed = null;
+ this.enclosingInstance.out_Renamed = null;
+ }
+ finally
+ {
+ /*
+ * There can be four states that the reader can be in at this point:
+ * 1) We are starting TLS and will be restarting the reader
+ * after we have negotiated TLS.
+ * - Indicated by whether stopReaderMessageID does not
+ * equal CONTINUE_READING.
+ * - Don't call Shutdown.
+ * 2) We are stoping TLS and will be restarting after TLS is
+ * stopped.
+ * - Indicated by an IOException AND stopReaderMessageID equals
+ * STOP_READING - in which case notify will be null.
+ * - Don't call Shutdown
+ * 3) We receive a Server Shutdown notification.
+ * - Indicated by messageID equal to 0.
+ * - call Shutdown.
+ * 4) Another error occured
+ * - Indicated by an IOException AND notify is not NULL
+ * - call Shutdown.
+ */
+ if ((!this.enclosingInstance.clientActive) || (notify != null))
+ {
+ //#3 & 4
+ this.enclosingInstance.shutdown(reason, 0, notify);
+ }
+ else
+ {
+ this.enclosingInstance.stopReaderMessageID = Novell.Directory.Ldap.Connection.CONTINUE_READING;
+ }
+ }
+ this.enclosingInstance.deadReaderException = ioex;
+ this.enclosingInstance.deadReader = this.enclosingInstance.reader;
+ this.enclosingInstance.reader = null;
+ return ;
+ }
+ } // End class ReaderThread
+
+ /// <summary>Add the specific object to the list of listeners that want to be
+ /// notified when an unsolicited notification is received.
+ /// </summary>
+ /* package */
+ internal void AddUnsolicitedNotificationListener(LdapUnsolicitedNotificationListener listener)
+ {
+ unsolicitedListeners.Add(listener);
+ return ;
+ }
+
+ /// <summary>Remove the specific object from current list of listeners</summary>
+ /* package */
+ internal void RemoveUnsolicitedNotificationListener(LdapUnsolicitedNotificationListener listener)
+ {
+ SupportClass.VectorRemoveElement(unsolicitedListeners, listener);
+ return ;
+ }
+
+ /// <summary>Inner class defined so that we can spawn off each unsolicited
+ /// listener as a seperate thread. We did not want to call the
+ /// unsolicited listener method directly as this would have tied up our
+ /// deamon listener thread in the applications unsolicited listener method.
+ /// Since we do not know what the application unsolicited listener
+ /// might be doing and how long it will take to process the uncoslicited
+ /// notification. We use this class to spawn off the unsolicited
+ /// notification as a separate thread
+ /// </summary>
+ private class UnsolicitedListenerThread:SupportClass.ThreadClass
+ {
+ private void InitBlock(Connection enclosingInstance)
+ {
+ this.enclosingInstance = enclosingInstance;
+ }
+ private Connection enclosingInstance;
+ public Connection Enclosing_Instance
+ {
+ get
+ {
+ return enclosingInstance;
+ }
+
+ }
+ private LdapUnsolicitedNotificationListener listenerObj;
+ private LdapExtendedResponse unsolicitedMsg;
+
+ /* package */
+ internal UnsolicitedListenerThread(Connection enclosingInstance, LdapUnsolicitedNotificationListener l, LdapExtendedResponse m)
+ {
+ InitBlock(enclosingInstance);
+ this.listenerObj = l;
+ this.unsolicitedMsg = m;
+ return ;
+ }
+
+ public override void Run()
+ {
+ listenerObj.messageReceived(unsolicitedMsg);
+ return ;
+ }
+ }
+
+ private void notifyAllUnsolicitedListeners(RfcLdapMessage message)
+ {
+
+
+ // MISSING: If this is a shutdown notification from the server
+ // set a flag in the Connection class so that we can throw an
+ // appropriate LdapException to the application
+ LdapMessage extendedLdapMessage = new LdapExtendedResponse(message);
+ System.String notificationOID = ((LdapExtendedResponse) extendedLdapMessage).ID;
+ if (notificationOID.Equals(LdapConnection.SERVER_SHUTDOWN_OID))
+ {
+
+
+ unsolSvrShutDnNotification = true;
+ }
+
+ int numOfListeners = unsolicitedListeners.Count;
+
+ // Cycle through all the listeners
+ for (int i = 0; i < numOfListeners; i++)
+ {
+
+ // Get next listener
+ LdapUnsolicitedNotificationListener listener = (LdapUnsolicitedNotificationListener) unsolicitedListeners[i];
+
+
+ // Create a new ExtendedResponse each time as we do not want each listener
+ // to have its own copy of the message
+ LdapExtendedResponse tempLdapMessage = new LdapExtendedResponse(message);
+
+ // Spawn a new thread for each listener to go process the message
+ // The reason we create a new thread rather than just call the
+ // the messageReceived method directly is beacuse we do not know
+ // what kind of processing the notification listener class will
+ // do. We do not want our deamon thread to block waiting for
+ // the notification listener method to return.
+ UnsolicitedListenerThread u = new UnsolicitedListenerThread(this, listener, tempLdapMessage);
+ u.Start();
+ }
+
+
+ return ;
+ }
+ static Connection()
+ {
+ nameLock = new System.Object();
+ sdk = new System.Text.StringBuilder("3.0").ToString();
+ protocol = 3;
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/InterThreadException.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/InterThreadException.cs
new file mode 100755
index 00000000000..f7c77626124
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/InterThreadException.cs
@@ -0,0 +1,147 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.InterThreadException.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+
+namespace Novell.Directory.Ldap
+{
+
+ /* package */
+ public class InterThreadException:LdapException
+ {
+ /// <summary> Returns the message ID of this message request.
+ ///
+ /// </summary>
+ /// <returns> the message ID. Returns -1 if no message
+ /// is associated with this exception.
+ /// </returns>
+ virtual internal int MessageID
+ {
+ /* package */
+
+ get
+ {
+ if (request == null)
+ {
+ return - 1;
+ }
+ return request.MessageID;
+ }
+
+ }
+ /// <summary> Returns the message type expected as a reply to
+ /// the message associated with this message's request type.
+ ///
+ /// </summary>
+ /// <returns> the message type of the expected reply. Returns -1
+ /// if no reply expected.
+ /// </returns>
+ virtual internal int ReplyType
+ {
+ /* package */
+
+ get
+ {
+ if (request == null)
+ {
+ return - 1;
+ }
+ int reqType = request.MessageType;
+ int responseType = - 1;
+ switch (reqType)
+ {
+
+ case LdapMessage.BIND_REQUEST:
+ responseType = LdapMessage.BIND_RESPONSE;
+ break;
+
+ case LdapMessage.UNBIND_REQUEST:
+ responseType = - 1;
+ break;
+
+ case LdapMessage.SEARCH_REQUEST:
+ responseType = LdapMessage.SEARCH_RESULT;
+ break;
+
+ case LdapMessage.MODIFY_REQUEST:
+ responseType = LdapMessage.MODIFY_RESPONSE;
+ break;
+
+ case LdapMessage.ADD_REQUEST:
+ responseType = LdapMessage.ADD_RESPONSE;
+ break;
+
+ case LdapMessage.DEL_REQUEST:
+ responseType = LdapMessage.DEL_RESPONSE;
+ break;
+
+ case LdapMessage.MODIFY_RDN_REQUEST:
+ responseType = LdapMessage.MODIFY_RDN_RESPONSE;
+ break;
+
+ case LdapMessage.COMPARE_REQUEST:
+ responseType = LdapMessage.COMPARE_RESPONSE;
+ break;
+
+ case LdapMessage.ABANDON_REQUEST:
+ responseType = - 1;
+ break;
+
+ case LdapMessage.EXTENDED_REQUEST:
+ responseType = LdapMessage.EXTENDED_RESPONSE;
+ break;
+
+ }
+ return responseType;
+ }
+
+ }
+ private Message request;
+
+ /// <summary> Constructs a InterThreadException with its associated message.
+ ///
+ /// </summary>
+ /// <param name="message"> The text providign additional error information.
+ /// <br><br>
+ /// </param>
+ /// <param name="resultCode"> The error result code.
+ /// <br><br>
+ /// </param>
+ /// <param name="request"> The Message class associated with this exception.
+ /// </param>
+ /* package */
+ internal InterThreadException(System.String message, System.Object[] arguments, int resultCode, System.Exception rootException, Message request):base(message, arguments, resultCode, (System.String) null, rootException)
+ {
+ this.request = request;
+ return ;
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapAbandonRequest.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapAbandonRequest.cs
new file mode 100755
index 00000000000..f56da7e3bb0
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapAbandonRequest.cs
@@ -0,0 +1,62 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.LdapAbandonRequest.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+using Novell.Directory.Ldap.Rfc2251;
+
+namespace Novell.Directory.Ldap
+{
+
+ /// <summary> Represents an Ldap Abandon Request
+ ///
+ /// </summary>
+ /// <seealso cref="LdapConnection#sendRequest">
+ /// </seealso>
+ /*
+ * AbandonRequest ::= [APPLICATION 16] MessageID
+ */
+ public class LdapAbandonRequest:LdapMessage
+ {
+ /// <summary> Construct an Ldap Abandon Request.
+ /// <br><br>
+ /// </summary>
+ /// <param name="id">The ID of the operation to abandon.
+ /// <br><br>
+ /// </param>
+ /// <param name="cont">Any controls that apply to the abandon request
+ /// or null if none.
+ /// </param>
+ public LdapAbandonRequest(int id, LdapControl[] cont):base(LdapMessage.ABANDON_REQUEST, new RfcAbandonRequest(id), cont)
+ {
+ return ;
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapAddRequest.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapAddRequest.cs
new file mode 100755
index 00000000000..1ce0a487a04
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapAddRequest.cs
@@ -0,0 +1,132 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.LdapAddRequest.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+using Novell.Directory.Ldap.Asn1;
+using Novell.Directory.Ldap.Rfc2251;
+namespace Novell.Directory.Ldap
+{
+
+ /// <summary> Represents an Ldap Add Request.
+ ///
+ /// </summary>
+ /// <seealso cref="LdapConnection#sendRequest">
+ /// </seealso>
+ /*
+ * AddRequest ::= [APPLICATION 8] SEQUENCE {
+ * entry LdapDN,
+ * attributes AttributeList }
+ */
+ public class LdapAddRequest:LdapMessage
+ {
+ /// <summary> Constructs an LdapEntry that represents the add request
+ ///
+ /// </summary>
+ /// <returns> an LdapEntry that represents the add request.
+ /// </returns>
+ virtual public LdapEntry Entry
+ {
+ get
+ {
+ RfcAddRequest addreq = (RfcAddRequest) Asn1Object.getRequest();
+
+ LdapAttributeSet attrs = new LdapAttributeSet();
+
+ // Build the list of attributes
+ Asn1Object[] seqArray = addreq.Attributes.toArray();
+ for (int i = 0; i < seqArray.Length; i++)
+ {
+ RfcAttributeTypeAndValues seq = (RfcAttributeTypeAndValues) seqArray[i];
+ LdapAttribute attr = new LdapAttribute(((Asn1OctetString) seq.get_Renamed(0)).stringValue());
+
+ // Add the values to the attribute
+ Asn1SetOf set_Renamed = (Asn1SetOf) seq.get_Renamed(1);
+ System.Object[] setArray = set_Renamed.toArray();
+ for (int j = 0; j < setArray.Length; j++)
+ {
+ attr.addValue(((Asn1OctetString) setArray[j]).byteValue());
+ }
+ attrs.Add(attr);
+ }
+
+ return new LdapEntry(Asn1Object.RequestDN, attrs);
+ }
+
+ }
+ /// <summary> Constructs a request to add an entry to the directory.
+ ///
+ /// </summary>
+ /// <param name="entry">The LdapEntry to add to the directory.
+ ///
+ /// </param>
+ /// <param name="cont">Any controls that apply to the add request,
+ /// or null if none.
+ /// </param>
+ public LdapAddRequest(LdapEntry entry, LdapControl[] cont):base(LdapMessage.ADD_REQUEST, new RfcAddRequest(new RfcLdapDN(entry.DN), makeRfcAttrList(entry)), cont)
+ {
+ return ;
+ }
+
+ /// <summary> Build the attribuite list from an LdapEntry.
+ ///
+ /// </summary>
+ /// <param name="entry">The LdapEntry associated with this add request.
+ /// </param>
+ private static RfcAttributeList makeRfcAttrList(LdapEntry entry)
+ {
+ // convert Java-API LdapEntry to RFC2251 AttributeList
+ LdapAttributeSet attrSet = entry.getAttributeSet();
+ RfcAttributeList attrList = new RfcAttributeList(attrSet.Count);
+ System.Collections.IEnumerator itr = attrSet.GetEnumerator();
+ while (itr.MoveNext())
+ {
+ LdapAttribute attr = (LdapAttribute) itr.Current;
+ Asn1SetOf vals = new Asn1SetOf(attr.size());
+ System.Collections.IEnumerator attrEnum = attr.ByteValues;
+ while (attrEnum.MoveNext())
+ {
+ vals.add(new RfcAttributeValue((sbyte[]) attrEnum.Current));
+ }
+ attrList.add(new RfcAttributeTypeAndValues(new RfcAttributeDescription(attr.Name), vals));
+ }
+ return attrList;
+ }
+
+ /// <summary> Return an Asn1 representation of this add request.
+ ///
+ /// #return an Asn1 representation of this object.
+ /// </summary>
+ public override System.String ToString()
+ {
+ return Asn1Object.ToString();
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapAttribute.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapAttribute.cs
new file mode 100755
index 00000000000..77afb4fce91
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapAttribute.cs
@@ -0,0 +1,1068 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.LdapAttribute.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+using ArrayEnumeration = Novell.Directory.Ldap.Utilclass.ArrayEnumeration;
+using Base64 = Novell.Directory.Ldap.Utilclass.Base64;
+
+namespace Novell.Directory.Ldap
+{
+ /// <summary> The name and values of one attribute of a directory entry.
+ ///
+ /// <p>LdapAttribute objects are used when searching for, adding,
+ /// modifying, and deleting attributes from the directory.
+ /// LdapAttributes are often used in conjunction with an
+ /// {@link LdapAttributeSet} when retrieving or adding multiple
+ /// attributes to an entry.
+ ///
+ ///
+ ///
+ /// </summary>
+ /// <seealso cref="LdapEntry">
+ /// </seealso>
+ /// <seealso cref="LdapAttributeSet">
+ /// </seealso>
+ /// <seealso cref="LdapModification">
+ /// </seealso>
+
+ public class LdapAttribute : System.ICloneable, System.IComparable
+ {
+ class URLData
+ {
+ private void InitBlock(LdapAttribute enclosingInstance)
+ {
+ this.enclosingInstance = enclosingInstance;
+ }
+ private LdapAttribute enclosingInstance;
+ public LdapAttribute Enclosing_Instance
+ {
+ get
+ {
+ return enclosingInstance;
+ }
+
+ }
+ private int length;
+ private sbyte[] data;
+ public URLData(LdapAttribute enclosingInstance, sbyte[] data, int length)
+ {
+ InitBlock(enclosingInstance);
+ this.length = length;
+ this.data = data;
+ return ;
+ }
+ public int getLength()
+ {
+ return length;
+ }
+ public sbyte[] getData()
+ {
+ return data;
+ }
+ }
+ /// <summary> Returns an enumerator for the values of the attribute in byte format.
+ ///
+ /// </summary>
+ /// <returns> The values of the attribute in byte format.
+ /// <P> Note: All string values will be UTF-8 encoded. To decode use the
+ /// String constructor. Example: new String( byteArray, "UTF-8" );
+ /// </returns>
+ virtual public System.Collections.IEnumerator ByteValues
+ {
+ get
+ {
+ return new ArrayEnumeration(ByteValueArray);
+ }
+
+ }
+ /// <summary> Returns an enumerator for the string values of an attribute.
+ ///
+ /// </summary>
+ /// <returns> The string values of an attribute.
+ /// </returns>
+ virtual public System.Collections.IEnumerator StringValues
+ {
+ get
+ {
+ return new ArrayEnumeration(StringValueArray);
+ }
+
+ }
+ /// <summary> Returns the values of the attribute as an array of bytes.
+ ///
+ /// </summary>
+ /// <returns> The values as an array of bytes or an empty array if there are
+ /// no values.
+ /// </returns>
+ [CLSCompliantAttribute(false)]
+ virtual public sbyte[][] ByteValueArray
+ {
+ get
+ {
+ if (null == this.values)
+ return new sbyte[0][];
+ int size = this.values.Length;
+ sbyte[][] bva = new sbyte[size][];
+ // Deep copy so application cannot change values
+ for (int i = 0, u = size; i < u; i++)
+ {
+ bva[i] = new sbyte[((sbyte[]) values[i]).Length];
+ Array.Copy((System.Array) this.values[i], 0, (System.Array) bva[i], 0, bva[i].Length);
+ }
+ return bva;
+ }
+
+ }
+ /// <summary> Returns the values of the attribute as an array of strings.
+ ///
+ /// </summary>
+ /// <returns> The values as an array of strings or an empty array if there are
+ /// no values
+ /// </returns>
+ virtual public System.String[] StringValueArray
+ {
+ get
+ {
+ if (null == this.values)
+ return new System.String[0];
+ int size = values.Length;
+ System.String[] sva = new System.String[size];
+ for (int j = 0; j < size; j++)
+ {
+ try
+ {
+ System.Text.Encoding encoder = System.Text.Encoding.GetEncoding("utf-8");
+ char[] dchar = encoder.GetChars(SupportClass.ToByteArray((sbyte[])values[j]));
+// char[] dchar = encoder.GetChars((byte[])values[j]);
+ sva[j] = new String(dchar);
+// sva[j] = new String((sbyte[]) values[j], "UTF-8");
+ }
+ catch (System.IO.IOException uee)
+ {
+ // Exception should NEVER get thrown but just in case it does ...
+ throw new System.SystemException(uee.ToString());
+ }
+ }
+ return sva;
+ }
+
+ }
+ /// <summary> Returns the the first value of the attribute as a <code>String</code>.
+ ///
+ /// </summary>
+ /// <returns> The UTF-8 encoded<code>String</code> value of the attribute's
+ /// value. If the value wasn't a UTF-8 encoded <code>String</code>
+ /// to begin with the value of the returned <code>String</code> is
+ /// non deterministic.
+ ///
+ /// <p>If <code>this</code> attribute has more than one value the
+ /// first value is converted to a UTF-8 encoded <code>String</code>
+ /// and returned. It should be noted, that the directory may
+ /// return attribute values in any order, so that the first
+ /// value may vary from one call to another.
+ ///
+ /// <p>If the attribute has no values <code>null</code> is returned
+ /// </returns>
+ virtual public System.String StringValue
+ {
+ get
+ {
+ System.String rval = null;
+ if (this.values != null)
+ {
+ try
+ {
+ System.Text.Encoding encoder = System.Text.Encoding.GetEncoding("utf-8");
+ char[] dchar = encoder.GetChars(SupportClass.ToByteArray((sbyte[])this.values[0]));
+// char[] dchar = encoder.GetChars((byte[]) this.values[0]);
+ rval = new String(dchar);
+ }
+ catch (System.IO.IOException use)
+ {
+ throw new System.SystemException(use.ToString());
+ }
+ }
+ return rval;
+ }
+
+ }
+ /// <summary> Returns the the first value of the attribute as a byte array.
+ ///
+ /// </summary>
+ /// <returns> The binary value of <code>this</code> attribute or
+ /// <code>null</code> if <code>this</code> attribute doesn't have a value.
+ ///
+ /// <p>If the attribute has no values <code>null</code> is returned
+ /// </returns>
+ [CLSCompliantAttribute(false)]
+ virtual public sbyte[] ByteValue
+ {
+ get
+ {
+ sbyte[] bva = null;
+ if (this.values != null)
+ {
+ // Deep copy so app can't change the value
+ bva = new sbyte[((sbyte[]) values[0]).Length];
+ Array.Copy((System.Array) this.values[0], 0, (System.Array) bva, 0, bva.Length);
+ }
+ return bva;
+ }
+
+ }
+ /// <summary> Returns the language subtype of the attribute, if any.
+ ///
+ /// <p>For example, if the attribute name is cn;lang-ja;phonetic,
+ /// this method returns the string, lang-ja.</p>
+ ///
+ /// </summary>
+ /// <returns> The language subtype of the attribute or null if the attribute
+ /// has none.
+ /// </returns>
+ virtual public System.String LangSubtype
+ {
+ get
+ {
+ if (subTypes != null)
+ {
+ for (int i = 0; i < subTypes.Length; i++)
+ {
+ if (subTypes[i].StartsWith("lang-"))
+ {
+ return subTypes[i];
+ }
+ }
+ }
+ return null;
+ }
+
+ }
+ /// <summary> Returns the name of the attribute.
+ ///
+ /// </summary>
+ /// <returns> The name of the attribute.
+ /// </returns>
+ virtual public System.String Name
+ {
+ get
+ {
+ return name;
+ }
+
+ }
+ /// <summary> Replaces all values with the specified value. This protected method is
+ /// used by sub-classes of LdapSchemaElement because the value cannot be set
+ /// with a contructor.
+ /// </summary>
+ virtual protected internal System.String Value
+ {
+ set
+ {
+ values = null;
+ try
+ {
+ System.Text.Encoding encoder = System.Text.Encoding.GetEncoding("utf-8");
+ byte[] ibytes = encoder.GetBytes(value);
+ sbyte[] sbytes=SupportClass.ToSByteArray(ibytes);
+
+ this.add(sbytes);
+ }
+ catch (System.IO.IOException ue)
+ {
+ throw new System.SystemException(ue.ToString());
+ }
+ return ;
+ }
+
+ }
+ private System.String name; // full attribute name
+ private System.String baseName; // cn of cn;lang-ja;phonetic
+ private System.String[] subTypes = null; // lang-ja of cn;lang-ja
+ private System.Object[] values = null; // Array of byte[] attribute values
+
+ /// <summary> Constructs an attribute with copies of all values of the input
+ /// attribute.
+ ///
+ /// </summary>
+ /// <param name="attr"> An LdapAttribute to use as a template.
+ ///
+ /// @throws IllegalArgumentException if attr is null
+ /// </param>
+ public LdapAttribute(LdapAttribute attr)
+ {
+ if (attr == null)
+ {
+ throw new System.ArgumentException("LdapAttribute class cannot be null");
+ }
+ // Do a deep copy of the LdapAttribute template
+ this.name = attr.name;
+ this.baseName = attr.baseName;
+ if (null != attr.subTypes)
+ {
+ this.subTypes = new System.String[attr.subTypes.Length];
+ Array.Copy((System.Array) attr.subTypes, 0, (System.Array) this.subTypes, 0, this.subTypes.Length);
+ }
+ // OK to just copy attributes, as the app only sees a deep copy of them
+ if (null != attr.values)
+ {
+ this.values = new System.Object[attr.values.Length];
+ Array.Copy((System.Array) attr.values, 0, (System.Array) this.values, 0, this.values.Length);
+ }
+ return ;
+ }
+
+ /// <summary> Constructs an attribute with no values.
+ ///
+ /// </summary>
+ /// <param name="attrName">Name of the attribute.
+ ///
+ /// @throws IllegalArgumentException if attrName is null
+ /// </param>
+ public LdapAttribute(System.String attrName)
+ {
+ if ((System.Object) attrName == null)
+ {
+ throw new System.ArgumentException("Attribute name cannot be null");
+ }
+ this.name = attrName;
+ this.baseName = LdapAttribute.getBaseName(attrName);
+ this.subTypes = LdapAttribute.getSubtypes(attrName);
+ return ;
+ }
+
+ /// <summary> Constructs an attribute with a byte-formatted value.
+ ///
+ /// </summary>
+ /// <param name="attrName">Name of the attribute.<br><br>
+ /// </param>
+ /// <param name="attrBytes">Value of the attribute as raw bytes.
+ ///
+ /// <P> Note: If attrBytes represents a string it should be UTF-8 encoded.
+ ///
+ /// @throws IllegalArgumentException if attrName or attrBytes is null
+ /// </param>
+ [CLSCompliantAttribute(false)]
+ public LdapAttribute(System.String attrName, sbyte[] attrBytes):this(attrName)
+ {
+ if (attrBytes == null)
+ {
+ throw new System.ArgumentException("Attribute value cannot be null");
+ }
+ // Make our own copy of the byte array to prevent app from changing it
+ sbyte[] tmp = new sbyte[attrBytes.Length];
+ Array.Copy((System.Array) attrBytes, 0, (System.Array)tmp, 0, attrBytes.Length);
+ this.add(tmp);
+ return ;
+ }
+
+ /// <summary> Constructs an attribute with a single string value.
+ ///
+ /// </summary>
+ /// <param name="attrName">Name of the attribute.<br><br>
+ /// </param>
+ /// <param name="attrString">Value of the attribute as a string.
+ ///
+ /// @throws IllegalArgumentException if attrName or attrString is null
+ /// </param>
+ public LdapAttribute(System.String attrName, System.String attrString):this(attrName)
+ {
+ if ((System.Object) attrString == null)
+ {
+ throw new System.ArgumentException("Attribute value cannot be null");
+ }
+ try
+ {
+ System.Text.Encoding encoder = System.Text.Encoding.GetEncoding("utf-8");
+ byte[] ibytes = encoder.GetBytes(attrString);
+ sbyte[] sbytes=SupportClass.ToSByteArray(ibytes);
+
+ this.add(sbytes);
+ }
+ catch (System.IO.IOException e)
+ {
+ throw new System.SystemException(e.ToString());
+ }
+ return ;
+ }
+
+ /// <summary> Constructs an attribute with an array of string values.
+ ///
+ /// </summary>
+ /// <param name="attrName">Name of the attribute.<br><br>
+ /// </param>
+ /// <param name="attrStrings">Array of values as strings.
+ ///
+ /// @throws IllegalArgumentException if attrName, attrStrings, or a member
+ /// of attrStrings is null
+ /// </param>
+ public LdapAttribute(System.String attrName, System.String[] attrStrings):this(attrName)
+ {
+ if (attrStrings == null)
+ {
+ throw new System.ArgumentException("Attribute values array cannot be null");
+ }
+ for (int i = 0, u = attrStrings.Length; i < u; i++)
+ {
+ try
+ {
+ if ((System.Object) attrStrings[i] == null)
+ {
+ throw new System.ArgumentException("Attribute value " + "at array index " + i + " cannot be null");
+ }
+ System.Text.Encoding encoder = System.Text.Encoding.GetEncoding("utf-8");
+ byte[] ibytes = encoder.GetBytes(attrStrings[i]);
+ sbyte[] sbytes=SupportClass.ToSByteArray(ibytes);
+ this.add(sbytes);
+// this.add(attrStrings[i].getBytes("UTF-8"));
+ }
+ catch (System.IO.IOException e)
+ {
+ throw new System.SystemException(e.ToString());
+ }
+ }
+ return ;
+ }
+
+ /// <summary> Returns a clone of this LdapAttribute.
+ ///
+ /// </summary>
+ /// <returns> clone of this LdapAttribute.
+ /// </returns>
+ public System.Object Clone()
+ {
+ try
+ {
+ System.Object newObj = base.MemberwiseClone();
+ if (values != null)
+ {
+ Array.Copy((System.Array) this.values, 0, (System.Array) ((LdapAttribute) newObj).values, 0, this.values.Length);
+ }
+ return newObj;
+ }
+ catch (System.Exception ce)
+ {
+ throw new System.SystemException("Internal error, cannot create clone");
+ }
+ }
+
+ /// <summary> Adds a string value to the attribute.
+ ///
+ /// </summary>
+ /// <param name="attrString">Value of the attribute as a String.
+ ///
+ /// @throws IllegalArgumentException if attrString is null
+ /// </param>
+ public virtual void addValue(System.String attrString)
+ {
+ if ((System.Object) attrString == null)
+ {
+ throw new System.ArgumentException("Attribute value cannot be null");
+ }
+ try
+ {
+ System.Text.Encoding encoder = System.Text.Encoding.GetEncoding("utf-8");
+ byte[] ibytes = encoder.GetBytes(attrString);
+ sbyte[] sbytes=SupportClass.ToSByteArray(ibytes);
+ this.add(sbytes);
+// this.add(attrString.getBytes("UTF-8"));
+ }
+ catch (System.IO.IOException ue)
+ {
+ throw new System.SystemException(ue.ToString());
+ }
+ return ;
+ }
+
+ /// <summary> Adds a byte-formatted value to the attribute.
+ ///
+ /// </summary>
+ /// <param name="attrBytes">Value of the attribute as raw bytes.
+ ///
+ /// <P> Note: If attrBytes represents a string it should be UTF-8 encoded.
+ ///
+ /// @throws IllegalArgumentException if attrBytes is null
+ /// </param>
+ [CLSCompliantAttribute(false)]
+ public virtual void addValue(sbyte[] attrBytes)
+ {
+ if (attrBytes == null)
+ {
+ throw new System.ArgumentException("Attribute value cannot be null");
+ }
+ this.add(attrBytes);
+ return ;
+ }
+
+ /// <summary> Adds a base64 encoded value to the attribute.
+ /// The value will be decoded and stored as bytes. String
+ /// data encoded as a base64 value must be UTF-8 characters.
+ ///
+ /// </summary>
+ /// <param name="attrString">The base64 value of the attribute as a String.
+ ///
+ /// @throws IllegalArgumentException if attrString is null
+ /// </param>
+ public virtual void addBase64Value(System.String attrString)
+ {
+ if ((System.Object) attrString == null)
+ {
+ throw new System.ArgumentException("Attribute value cannot be null");
+ }
+
+ this.add(Base64.decode(attrString));
+ return ;
+ }
+
+ /// <summary> Adds a base64 encoded value to the attribute.
+ /// The value will be decoded and stored as bytes. Character
+ /// data encoded as a base64 value must be UTF-8 characters.
+ ///
+ /// </summary>
+ /// <param name="attrString">The base64 value of the attribute as a StringBuffer.
+ /// </param>
+ /// <param name="start"> The start index of base64 encoded part, inclusive.
+ /// </param>
+ /// <param name="end"> The end index of base encoded part, exclusive.
+ ///
+ /// @throws IllegalArgumentException if attrString is null
+ /// </param>
+ public virtual void addBase64Value(System.Text.StringBuilder attrString, int start, int end)
+ {
+ if (attrString == null)
+ {
+ throw new System.ArgumentException("Attribute value cannot be null");
+ }
+
+ this.add(Base64.decode(attrString, start, end));
+
+ return ;
+ }
+
+ /// <summary> Adds a base64 encoded value to the attribute.
+ /// The value will be decoded and stored as bytes. Character
+ /// data encoded as a base64 value must be UTF-8 characters.
+ ///
+ /// </summary>
+ /// <param name="attrChars">The base64 value of the attribute as an array of
+ /// characters.
+ ///
+ /// @throws IllegalArgumentException if attrString is null
+ /// </param>
+ public virtual void addBase64Value(char[] attrChars)
+ {
+ if (attrChars == null)
+ {
+ throw new System.ArgumentException("Attribute value cannot be null");
+ }
+
+ this.add(Base64.decode(attrChars));
+ return ;
+ }
+
+ /// <summary> Adds a URL, indicating a file or other resource that contains
+ /// the value of the attribute.
+ ///
+ /// </summary>
+ /// <param name="url">String value of a URL pointing to the resource containing
+ /// the value of the attribute.
+ ///
+ /// @throws IllegalArgumentException if url is null
+ /// </param>
+ public virtual void addURLValue(System.String url)
+ {
+ if ((System.Object) url == null)
+ {
+ throw new System.ArgumentException("Attribute URL cannot be null");
+ }
+ addURLValue(new System.Uri(url));
+ return ;
+ }
+
+ /// <summary> Adds a URL, indicating a file or other resource that contains
+ /// the value of the attribute.
+ ///
+ /// </summary>
+ /// <param name="url">A URL class pointing to the resource containing the value
+ /// of the attribute.
+ ///
+ /// @throws IllegalArgumentException if url is null
+ /// </param>
+ public virtual void addURLValue(System.Uri url)
+ {
+ // Class to encapsulate the data bytes and the length
+ if (url == null)
+ {
+ throw new System.ArgumentException("Attribute URL cannot be null");
+ }
+ try
+ {
+ // Get InputStream from the URL
+ System.IO.Stream in_Renamed = System.Net.WebRequest.Create(url).GetResponse().GetResponseStream();
+ // Read the bytes into buffers and store the them in an arraylist
+ System.Collections.ArrayList bufs = new System.Collections.ArrayList();
+ sbyte[] buf = new sbyte[4096];
+ int len, totalLength = 0;
+ while ((len = SupportClass.ReadInput(in_Renamed, ref buf, 0, 4096)) != - 1)
+ {
+ bufs.Add(new URLData(this, buf, len));
+ buf = new sbyte[4096];
+ totalLength += len;
+ }
+ /*
+ * Now that the length is known, allocate an array to hold all
+ * the bytes of data and copy the data to that array, store
+ * it in this LdapAttribute
+ */
+ sbyte[] data = new sbyte[totalLength];
+ int offset = 0; //
+ for (int i = 0; i < bufs.Count; i++)
+ {
+ URLData b = (URLData) bufs[i];
+ len = b.getLength();
+ Array.Copy((System.Array) b.getData(), 0, (System.Array) data, offset, len);
+ offset += len;
+ }
+ this.add(data);
+ }
+ catch (System.IO.IOException ue)
+ {
+ throw new System.SystemException(ue.ToString());
+ }
+ return ;
+ }
+
+ /// <summary> Returns the base name of the attribute.
+ ///
+ /// <p>For example, if the attribute name is cn;lang-ja;phonetic,
+ /// this method returns cn.</p>
+ ///
+ /// </summary>
+ /// <returns> The base name of the attribute.
+ /// </returns>
+ public virtual System.String getBaseName()
+ {
+ return baseName;
+ }
+
+ /// <summary> Returns the base name of the specified attribute name.
+ ///
+ /// <p>For example, if the attribute name is cn;lang-ja;phonetic,
+ /// this method returns cn.</p>
+ ///
+ /// </summary>
+ /// <param name="attrName">Name of the attribute from which to extract the
+ /// base name.
+ ///
+ /// </param>
+ /// <returns> The base name of the attribute.
+ ///
+ /// @throws IllegalArgumentException if attrName is null
+ /// </returns>
+ public static System.String getBaseName(System.String attrName)
+ {
+ if ((System.Object) attrName == null)
+ {
+ throw new System.ArgumentException("Attribute name cannot be null");
+ }
+ int idx = attrName.IndexOf((System.Char) ';');
+ if (- 1 == idx)
+ {
+ return attrName;
+ }
+ return attrName.Substring(0, (idx) - (0));
+ }
+
+ /// <summary> Extracts the subtypes from the attribute name.
+ ///
+ /// <p>For example, if the attribute name is cn;lang-ja;phonetic,
+ /// this method returns an array containing lang-ja and phonetic.
+ ///
+ /// </summary>
+ /// <returns> An array subtypes or null if the attribute has none.
+ /// </returns>
+ public virtual System.String[] getSubtypes()
+ {
+ return subTypes;
+ }
+
+ /// <summary> Extracts the subtypes from the specified attribute name.
+ ///
+ /// <p>For example, if the attribute name is cn;lang-ja;phonetic,
+ /// this method returns an array containing lang-ja and phonetic.</p>
+ ///
+ /// </summary>
+ /// <param name="attrName"> Name of the attribute from which to extract
+ /// the subtypes.
+ ///
+ /// </param>
+ /// <returns> An array subtypes or null if the attribute has none.
+ ///
+ /// @throws IllegalArgumentException if attrName is null
+ /// </returns>
+ public static System.String[] getSubtypes(System.String attrName)
+ {
+ if ((System.Object) attrName == null)
+ {
+ throw new System.ArgumentException("Attribute name cannot be null");
+ }
+ SupportClass.Tokenizer st = new SupportClass.Tokenizer(attrName, ";");
+ System.String[] subTypes = null;
+ int cnt = st.Count;
+ if (cnt > 0)
+ {
+ st.NextToken(); // skip over basename
+ subTypes = new System.String[cnt - 1];
+ int i = 0;
+ while (st.HasMoreTokens())
+ {
+ subTypes[i++] = st.NextToken();
+ }
+ }
+ return subTypes;
+ }
+
+ /// <summary> Reports if the attribute name contains the specified subtype.
+ ///
+ /// <p>For example, if you check for the subtype lang-en and the
+ /// attribute name is cn;lang-en, this method returns true.</p>
+ ///
+ /// </summary>
+ /// <param name="subtype"> The single subtype to check for.
+ ///
+ /// </param>
+ /// <returns> True, if the attribute has the specified subtype;
+ /// false, if it doesn't.
+ ///
+ /// @throws IllegalArgumentException if subtype is null
+ /// </returns>
+ public virtual bool hasSubtype(System.String subtype)
+ {
+ if ((System.Object) subtype == null)
+ {
+ throw new System.ArgumentException("subtype cannot be null");
+ }
+ if (null != this.subTypes)
+ {
+ for (int i = 0; i < subTypes.Length; i++)
+ {
+ if (subTypes[i].ToUpper().Equals(subtype.ToUpper()))
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /// <summary> Reports if the attribute name contains all the specified subtypes.
+ ///
+ /// <p> For example, if you check for the subtypes lang-en and phonetic
+ /// and if the attribute name is cn;lang-en;phonetic, this method
+ /// returns true. If the attribute name is cn;phonetic or cn;lang-en,
+ /// this method returns false.</p>
+ ///
+ /// </summary>
+ /// <param name="subtypes"> An array of subtypes to check for.
+ ///
+ /// </param>
+ /// <returns> True, if the attribute has all the specified subtypes;
+ /// false, if it doesn't have all the subtypes.
+ ///
+ /// @throws IllegalArgumentException if subtypes is null or if array member
+ /// is null.
+ /// </returns>
+ public virtual bool hasSubtypes(System.String[] subtypes)
+ {
+ if (subtypes == null)
+ {
+ throw new System.ArgumentException("subtypes cannot be null");
+ }
+ for (int i = 0; i < subtypes.Length; i++)
+ {
+ for (int j = 0; j < subTypes.Length; j++)
+ {
+ if ((System.Object) subTypes[j] == null)
+ {
+ throw new System.ArgumentException("subtype " + "at array index " + i + " cannot be null");
+ }
+ if (subTypes[j].ToUpper().Equals(subtypes[i].ToUpper()))
+ {
+ goto gotSubType;
+ }
+ }
+ return false;
+gotSubType: ;
+ }
+ return true;
+ }
+
+ /// <summary> Removes a string value from the attribute.
+ ///
+ /// </summary>
+ /// <param name="attrString"> Value of the attribute as a string.
+ ///
+ /// <p>Note: Removing a value which is not present in the attribute has
+ /// no effect.</p>
+ ///
+ /// @throws IllegalArgumentException if attrString is null
+ /// </param>
+ public virtual void removeValue(System.String attrString)
+ {
+ if (null == (System.Object) attrString)
+ {
+ throw new System.ArgumentException("Attribute value cannot be null");
+ }
+ try
+ {
+ System.Text.Encoding encoder = System.Text.Encoding.GetEncoding("utf-8");
+ byte[] ibytes = encoder.GetBytes(attrString);
+ sbyte[] sbytes=SupportClass.ToSByteArray(ibytes);
+ this.removeValue(sbytes);
+// this.removeValue(attrString.getBytes("UTF-8"));
+ }
+ catch (System.IO.IOException uee)
+ {
+ // This should NEVER happen but just in case ...
+ throw new System.SystemException(uee.ToString());
+ }
+ return ;
+ }
+
+ /// <summary> Removes a byte-formatted value from the attribute.
+ ///
+ /// </summary>
+ /// <param name="attrBytes"> Value of the attribute as raw bytes.
+ /// <P> Note: If attrBytes represents a string it should be UTF-8 encoded.
+ /// Example: <code>String.getBytes("UTF-8");</code></P>
+ ///
+ /// <p>Note: Removing a value which is not present in the attribute has
+ /// no effect.</p>
+ ///
+ /// @throws IllegalArgumentException if attrBytes is null
+ /// </param>
+ [CLSCompliantAttribute(false)]
+ public virtual void removeValue(sbyte[] attrBytes)
+ {
+ if (null == attrBytes)
+ {
+ throw new System.ArgumentException("Attribute value cannot be null");
+ }
+ for (int i = 0; i < this.values.Length; i++)
+ {
+ if (equals(attrBytes, (sbyte[]) this.values[i]))
+ {
+ if (0 == i && 1 == this.values.Length)
+ {
+ // Optimize if first element of a single valued attr
+ this.values = null;
+ return ;
+ }
+ if (this.values.Length == 1)
+ {
+ this.values = null;
+ }
+ else
+ {
+ int moved = this.values.Length - i - 1;
+ System.Object[] tmp = new System.Object[this.values.Length - 1];
+ if (i != 0)
+ {
+ Array.Copy((System.Array) values, 0, (System.Array) tmp, 0, i);
+ }
+ if (moved != 0)
+ {
+ Array.Copy((System.Array) values, i + 1, (System.Array) tmp, i, moved);
+ }
+ this.values = tmp;
+ tmp = null;
+ }
+ break;
+ }
+ }
+ return ;
+ }
+
+ /// <summary> Returns the number of values in the attribute.
+ ///
+ /// </summary>
+ /// <returns> The number of values in the attribute.
+ /// </returns>
+ public virtual int size()
+ {
+ return null == this.values?0:this.values.Length;
+ }
+
+ /// <summary> Compares this object with the specified object for order.
+ ///
+ /// <p> Ordering is determined by comparing attribute names (see
+ /// {@link #getName() }) using the method compareTo() of the String class.
+ /// </p>
+ ///
+ /// </summary>
+ /// <param name="attribute"> The LdapAttribute to be compared to this object.
+ ///
+ /// </param>
+ /// <returns> Returns a negative integer, zero, or a positive
+ /// integer as this object is less than, equal to, or greater than the
+ /// specified object.
+ /// </returns>
+ public virtual int CompareTo(System.Object attribute)
+ {
+
+ return name.CompareTo(((LdapAttribute) attribute).name);
+ }
+
+ /// <summary> Adds an object to <code>this</code> object's list of attribute values
+ ///
+ /// </summary>
+ /// <param name="bytes"> Ultimately all of this attribute's values are treated
+ /// as binary data so we simplify the process by requiring
+ /// that all data added to our list is in binary form.
+ ///
+ /// <P> Note: If attrBytes represents a string it should be UTF-8 encoded.
+ /// </param>
+ private void add(sbyte[] bytes)
+ {
+ if (null == this.values)
+ {
+ this.values = new System.Object[]{bytes};
+ }
+ else
+ {
+ // Duplicate attribute values not allowed
+ for (int i = 0; i < this.values.Length; i++)
+ {
+ if (equals(bytes, (sbyte[]) this.values[i]))
+ {
+ return ; // Duplicate, don't add
+ }
+ }
+ System.Object[] tmp = new System.Object[this.values.Length + 1];
+ Array.Copy((System.Array) this.values, 0, (System.Array) tmp, 0, this.values.Length);
+ tmp[this.values.Length] = bytes;
+ this.values = tmp;
+ tmp = null;
+ }
+ return ;
+ }
+
+ /// <summary> Returns true if the two specified arrays of bytes are equal to each
+ /// another. Matches the logic of Arrays.equals which is not available
+ /// in jdk 1.1.x.
+ ///
+ /// </summary>
+ /// <param name="e1">the first array to be tested
+ /// </param>
+ /// <param name="e2">the second array to be tested
+ /// </param>
+ /// <returns> true if the two arrays are equal
+ /// </returns>
+ private bool equals(sbyte[] e1, sbyte[] e2)
+ {
+ // If same object, they compare true
+ if (e1 == e2)
+ return true;
+
+ // If either but not both are null, they compare false
+ if (e1 == null || e2 == null)
+ return false;
+
+ // If arrays have different length, they compare false
+ int length = e1.Length;
+ if (e2.Length != length)
+ return false;
+
+ // If any of the bytes are different, they compare false
+ for (int i = 0; i < length; i++)
+ {
+ if (e1[i] != e2[i])
+ return false;
+ }
+
+ return true;
+ }
+
+ /// <summary> Returns a string representation of this LdapAttribute
+ ///
+ /// </summary>
+ /// <returns> a string representation of this LdapAttribute
+ /// </returns>
+ public override System.String ToString()
+ {
+ System.Text.StringBuilder result = new System.Text.StringBuilder("LdapAttribute: ");
+ try
+ {
+ result.Append("{type='" + name + "'");
+ if (values != null)
+ {
+ result.Append(", ");
+ if (values.Length == 1)
+ {
+ result.Append("value='");
+ }
+ else
+ {
+ result.Append("values='");
+ }
+ for (int i = 0; i < values.Length; i++)
+ {
+ if (i != 0)
+ {
+ result.Append("','");
+ }
+ if (((sbyte[]) values[i]).Length == 0)
+ {
+ continue;
+ }
+ System.Text.Encoding encoder = System.Text.Encoding.GetEncoding("utf-8");
+// char[] dchar = encoder.GetChars((byte[]) values[i]);
+ char[] dchar = encoder.GetChars(SupportClass.ToByteArray((sbyte[])values[i]));
+ System.String sval = new String(dchar);
+
+// System.String sval = new String((sbyte[]) values[i], "UTF-8");
+ if (sval.Length == 0)
+ {
+ // didn't decode well, must be binary
+ result.Append("<binary value, length:" + sval.Length);
+ continue;
+ }
+ result.Append(sval);
+ }
+ result.Append("'");
+ }
+ result.Append("}");
+ }
+ catch (System.Exception e)
+ {
+ throw new System.SystemException(e.ToString());
+ }
+ return result.ToString();
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapAttributeSet.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapAttributeSet.cs
new file mode 100755
index 00000000000..2a14da25744
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapAttributeSet.cs
@@ -0,0 +1,426 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.LdapAttributeSet.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+
+
+namespace Novell.Directory.Ldap
+{
+
+ /// <summary>
+ /// A set of {@link LdapAttribute} objects.
+ ///
+ /// <p>An <code>LdapAttributeSet</code> is a collection of <code>LdapAttribute</code>
+ /// classes as returned from an <code>LdapEntry</code> on a search or read
+ /// operation. <code>LdapAttributeSet</code> may be also used to contruct an entry
+ /// to be added to a directory. If the <code>add()</code> or <code>addAll()</code>
+ /// methods are called and one or more of the objects to be added is not
+ /// an <code>LdapAttribute, ClassCastException</code> is thrown (as discussed in the
+ /// documentation for <code>java.util.Collection</code>).
+ ///
+ ///
+ /// </summary>
+ /// <seealso cref="LdapAttribute">
+ /// </seealso>
+ /// <seealso cref="LdapEntry">
+ /// </seealso>
+ public class LdapAttributeSet:SupportClass.AbstractSetSupport, System.ICloneable//, SupportClass.SetSupport
+ {
+ /// <summary> Returns the number of attributes in this set.
+ ///
+ /// </summary>
+ /// <returns> number of attributes in this set.
+ /// </returns>
+ public override int Count
+ {
+ get
+ {
+ return this.map.Count;
+ }
+
+ }
+
+ /// <summary> This is the underlying data structure for this set.
+ /// <p>HashSet is similar to the functionality of this set. The difference
+ /// is we use the name of an attribute as keys in the Map and LdapAttributes
+ /// as the values. We also do not declare the map as transient, making the
+ /// map serializable.</p>
+ /// </summary>
+ private System.Collections.Hashtable map;
+
+ /// <summary> Constructs an empty set of attributes.</summary>
+ public LdapAttributeSet():base()
+ {
+ map = new System.Collections.Hashtable();
+ }
+
+ // --- methods not defined in Set ---
+
+ /// <summary> Returns a deep copy of this attribute set.
+ ///
+ /// </summary>
+ /// <returns> A deep copy of this attribute set.
+ /// </returns>
+ public override System.Object Clone()
+ {
+ try
+ {
+ System.Object newObj = base.MemberwiseClone();
+ System.Collections.IEnumerator i = this.GetEnumerator();
+ while (i.MoveNext())
+ {
+ ((LdapAttributeSet) newObj).Add(((LdapAttribute) i.Current).Clone());
+ }
+ return newObj;
+ }
+ catch (System.Exception ce)
+ {
+ throw new System.SystemException("Internal error, cannot create clone");
+ }
+ }
+
+ /// <summary> Returns the attribute matching the specified attrName.
+ ///
+ /// <p>For example:</p>
+ /// <ul>
+ /// <li><code>getAttribute("cn")</code> returns only the "cn" attribute</li>
+ /// <li><code>getAttribute("cn;lang-en")</code> returns only the "cn;lang-en"
+ /// attribute.</li>
+ /// </ul>
+ /// <p>In both cases, <code>null</code> is returned if there is no exact match to
+ /// the specified attrName.</p>
+ ///
+ /// <p>Note: Novell eDirectory does not currently support language subtypes.
+ /// It does support the "binary" subtype.</p>
+ ///
+ /// </summary>
+ /// <param name="attrName"> The name of an attribute to retrieve, with or without
+ /// subtype specifications. For example, "cn", "cn;phonetic", and
+ /// "cn;binary" are valid attribute names.
+ ///
+ /// </param>
+ /// <returns> The attribute matching the specified attrName, or <code>null</code>
+ /// if there is no exact match.
+ /// </returns>
+ public virtual LdapAttribute getAttribute(System.String attrName)
+ {
+ return (LdapAttribute) map[attrName.ToUpper()];
+ }
+
+ /// <summary> Returns a single best-match attribute, or <code>null</code> if no match is
+ /// available in the entry.
+ ///
+ /// <p>Ldap version 3 allows adding a subtype specification to an attribute
+ /// name. For example, "cn;lang-ja" indicates a Japanese language
+ /// subtype of the "cn" attribute and "cn;lang-ja-JP-kanji" may be a subtype
+ /// of "cn;lang-ja". This feature may be used to provide multiple
+ /// localizations in the same directory. For attributes which do not vary
+ /// among localizations, only the base attribute may be stored, whereas
+ /// for others there may be varying degrees of specialization.</p>
+ ///
+ /// <p>For example, <code>getAttribute(attrName,lang)</code> returns the
+ /// <code>LdapAttribute</code> that exactly matches attrName and that
+ /// best matches lang.</p>
+ ///
+ /// <p>If there are subtypes other than "lang" subtypes included
+ /// in attrName, for example, "cn;binary", only attributes with all of
+ /// those subtypes are returned. If lang is <code>null</code> or empty, the
+ /// method behaves as getAttribute(attrName). If there are no matching
+ /// attributes, <code>null</code> is returned. </p>
+ ///
+ ///
+ /// <p>Assume the entry contains only the following attributes:</p>
+ ///
+ /// <ul>
+ /// <li>cn;lang-en</li>
+ /// <li>cn;lang-ja-JP-kanji</li>
+ /// <li>sn</li>
+ /// </ul>
+ ///
+ /// <p>Examples:</p>
+ /// <ul>
+ /// <li><code>getAttribute( "cn" )</code> returns <code>null</code>.</li>
+ /// <li><code>getAttribute( "sn" )</code> returns the "sn" attribute.</li>
+ /// <li><code>getAttribute( "cn", "lang-en-us" )</code>
+ /// returns the "cn;lang-en" attribute.</li>
+ /// <li><code>getAttribute( "cn", "lang-en" )</code>
+ /// returns the "cn;lang-en" attribute.</li>
+ /// <li><code>getAttribute( "cn", "lang-ja" )</code>
+ /// returns <code>null</code>.</li>
+ /// <li><code>getAttribute( "sn", "lang-en" )</code>
+ /// returns the "sn" attribute.</li>
+ /// </ul>
+ ///
+ /// <p>Note: Novell eDirectory does not currently support language subtypes.
+ /// It does support the "binary" subtype.</p>
+ ///
+ /// </summary>
+ /// <param name="attrName"> The name of an attribute to retrieve, with or without
+ /// subtype specifications. For example, "cn", "cn;phonetic", and
+ /// cn;binary" are valid attribute names.
+ /// <br><br>
+ /// </param>
+ /// <param name="lang"> A language specification with optional subtypes
+ /// appended using "-" as separator. For example, "lang-en", "lang-en-us",
+ /// "lang-ja", and "lang-ja-JP-kanji" are valid language specification.
+ ///
+ /// </param>
+ /// <returns> A single best-match <code>LdapAttribute</code>, or <code>null</code>
+ /// if no match is found in the entry.
+ ///
+ /// </returns>
+ public virtual LdapAttribute getAttribute(System.String attrName, System.String lang)
+ {
+ System.String key = attrName + ";" + lang;
+ return (LdapAttribute) map[key.ToUpper()];
+ }
+
+ /// <summary> Creates a new attribute set containing only the attributes that have
+ /// the specified subtypes.
+ ///
+ /// <p>For example, suppose an attribute set contains the following
+ /// attributes:</p>
+ ///
+ /// <ul>
+ /// <li> cn</li>
+ /// <li> cn;lang-ja</li>
+ /// <li> sn;phonetic;lang-ja</li>
+ /// <li> sn;lang-us</li>
+ /// </ul>
+ ///
+ /// <p>Calling the <code>getSubset</code> method and passing lang-ja as the
+ /// argument, the method returns an attribute set containing the following
+ /// attributes:</p>
+ ///
+ /// <ul>
+ /// <li>cn;lang-ja</li>
+ /// <li>sn;phonetic;lang-ja</li>
+ /// </ul>
+ ///
+ /// </summary>
+ /// <param name="subtype"> Semi-colon delimited list of subtypes to include. For
+ /// example:
+ /// <ul>
+ /// <li> "lang-ja" specifies only Japanese language subtypes</li>
+ /// <li> "binary" specifies only binary subtypes</li>
+ /// <li> "binary;lang-ja" specifies only Japanese language subtypes
+ /// which also are binary</li>
+ /// </ul>
+ ///
+ /// <p>Note: Novell eDirectory does not currently support language subtypes.
+ /// It does support the "binary" subtype.</p>
+ ///
+ /// </param>
+ /// <returns> An attribute set containing the attributes that match the
+ /// specified subtype.
+ /// </returns>
+ public virtual LdapAttributeSet getSubset(System.String subtype)
+ {
+
+ // Create a new tempAttributeSet
+ LdapAttributeSet tempAttributeSet = new LdapAttributeSet();
+ System.Collections.IEnumerator i = this.GetEnumerator();
+
+ // Cycle throught this.attributeSet
+ while (i.MoveNext())
+ {
+ LdapAttribute attr = (LdapAttribute) i.Current;
+
+ // Does this attribute have the subtype we are looking for. If
+ // yes then add it to our AttributeSet, else next attribute
+ if (attr.hasSubtype(subtype))
+ tempAttributeSet.Add(attr.Clone());
+ }
+ return tempAttributeSet;
+ }
+
+ // --- methods defined in set ---
+
+ /// <summary> Returns an iterator over the attributes in this set. The attributes
+ /// returned from this iterator are not in any particular order.
+ ///
+ /// </summary>
+ /// <returns> iterator over the attributes in this set
+ /// </returns>
+ public override System.Collections.IEnumerator GetEnumerator()
+ {
+ return this.map.Values.GetEnumerator();
+ }
+
+ /// <summary> Returns <code>true</code> if this set contains no elements
+ ///
+ /// </summary>
+ /// <returns> <code>true</code> if this set contains no elements
+ /// </returns>
+ public override bool IsEmpty()
+ {
+ return (this.map.Count == 0);
+ }
+
+ /// <summary> Returns <code>true</code> if this set contains an attribute of the same name
+ /// as the specified attribute.
+ ///
+ /// </summary>
+ /// <param name="attr"> Object of type <code>LdapAttribute</code>
+ ///
+ /// </param>
+ /// <returns> true if this set contains the specified attribute
+ ///
+ /// @throws ClassCastException occurs the specified Object
+ /// is not of type LdapAttribute.
+ /// </returns>
+ public override bool Contains(object attr)
+ {
+ LdapAttribute attribute = (LdapAttribute) attr;
+ return this.map.ContainsKey(attribute.Name.ToUpper());
+ }
+
+ /// <summary> Adds the specified attribute to this set if it is not already present.
+ /// <p>If an attribute with the same name already exists in the set then the
+ /// specified attribute will not be added.</p>
+ ///
+ /// </summary>
+ /// <param name="attr"> Object of type <code>LdapAttribute</code>
+ ///
+ /// </param>
+ /// <returns> true if the attribute was added.
+ ///
+ /// @throws ClassCastException occurs the specified Object
+ /// is not of type <code>LdapAttribute</code>.
+ /// </returns>
+ public override bool Add(object attr)
+ {
+ //We must enforce that attr is an LdapAttribute
+ LdapAttribute attribute = (LdapAttribute) attr;
+ System.String name = attribute.Name.ToUpper();
+ if (this.map.ContainsKey(name))
+ return false;
+ else
+ {
+ SupportClass.PutElement(this.map, name, attribute);
+ return true;
+ }
+ }
+
+ /// <summary> Removes the specified object from this set if it is present.
+ ///
+ /// <p>If the specified object is of type <code>LdapAttribute</code>, the
+ /// specified attribute will be removed. If the specified object is of type
+ /// <code>String</code>, the attribute with a name that matches the string will
+ /// be removed.</p>
+ ///
+ /// </summary>
+ /// <param name="object">LdapAttribute to be removed or <code>String</code> naming
+ /// the attribute to be removed.
+ ///
+ /// </param>
+ /// <returns> true if the object was removed.
+ ///
+ /// @throws ClassCastException occurs the specified Object
+ /// is not of type <code>LdapAttribute</code> or of type <code>String</code>.
+ /// </returns>
+ public override bool Remove(object object_Renamed)
+ {
+ System.String attributeName; //the name is the key to object in the HashMap
+ if (object_Renamed is System.String)
+ {
+ attributeName = ((System.String) object_Renamed);
+ }
+ else
+ {
+ attributeName = ((LdapAttribute) object_Renamed).Name;
+ }
+ if ((System.Object) attributeName == null)
+ {
+ return false;
+ }
+ return (SupportClass.HashtableRemove(this.map, attributeName.ToUpper()) != null);
+ }
+
+ /// <summary> Removes all of the elements from this set.</summary>
+ public override void Clear()
+ {
+ this.map.Clear();
+ }
+
+ /// <summary> Adds all <code>LdapAttribute</code> objects in the specified collection to
+ /// this collection.
+ ///
+ /// </summary>
+ /// <param name="c"> Collection of <code>LdapAttribute</code> objects.
+ ///
+ /// @throws ClassCastException occurs when an element in the
+ /// collection is not of type <code>LdapAttribute</code>.
+ ///
+ /// </param>
+ /// <returns> true if this set changed as a result of the call.
+ /// </returns>
+ public override bool AddAll(System.Collections.ICollection c)
+ {
+ bool setChanged = false;
+ System.Collections.IEnumerator i = c.GetEnumerator();
+
+ while (i.MoveNext())
+ {
+ // we must enforce that everything in c is an LdapAttribute
+ // add will return true if the attribute was added
+ if (this.Add(i.Current))
+ {
+ setChanged = true;
+ }
+ }
+ return setChanged;
+ }
+
+ /// <summary> Returns a string representation of this LdapAttributeSet
+ ///
+ /// </summary>
+ /// <returns> a string representation of this LdapAttributeSet
+ /// </returns>
+ public override System.String ToString()
+ {
+ System.Text.StringBuilder retValue = new System.Text.StringBuilder("LdapAttributeSet: ");
+ System.Collections.IEnumerator attrs = GetEnumerator();
+ bool first = true;
+ while (attrs.MoveNext())
+ {
+ if (!first)
+ {
+ retValue.Append(" ");
+ }
+ first = false;
+ LdapAttribute attr = (LdapAttribute) attrs.Current;
+ retValue.Append(attr.ToString());
+ }
+ return retValue.ToString();
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapAuthHandler.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapAuthHandler.cs
new file mode 100755
index 00000000000..ea5480d974c
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapAuthHandler.cs
@@ -0,0 +1,73 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.LdapAuthHandler.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+namespace Novell.Directory.Ldap
+{
+
+ /// <summary>
+ /// Used to provide credentials for authentication when processing a
+ /// referral.
+ ///
+ /// <p>A programmer desiring to supply authentication credentials
+ /// to the API when automatically following referrals MUST
+ /// implement this interface. If LdapAuthHandler or LdapBindHandler are not
+ /// implemented, automatically followed referrals will use anonymous
+ /// authentication. Referral URLs of any type other than Ldap (i.e. a
+ /// referral URL other than ldap://something) are not chased automatically
+ /// by the API on automatic following.</p>
+ ///
+ ///
+ /// </summary>
+ /// <seealso cref="LdapBindHandler">
+ /// </seealso>
+ /// <seealso cref="LdapConstraints#setReferralFollowing(boolean)">
+ /// </seealso>
+ public interface LdapAuthHandler : LdapReferralHandler
+ {
+
+ /// <summary> Returns an object which can provide credentials for authenticating to
+ /// a server at the specified host and port.
+ ///
+ /// </summary>
+ /// <param name="host"> Contains a host name or the IP address (in dotted string
+ /// format) of a host running an Ldap server.
+ /// <br><br>
+ /// </param>
+ /// <param name="port"> Contains the TCP or UDP port number of the host.
+ ///
+ /// </param>
+ /// <returns> An object with authentication credentials to the specified
+ /// host and port.
+ /// </returns>
+ LdapAuthProvider getAuthProvider(System.String host, int port);
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapAuthProvider.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapAuthProvider.cs
new file mode 100755
index 00000000000..2973b22e8d1
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapAuthProvider.cs
@@ -0,0 +1,101 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.LdapAuthProvider.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+namespace Novell.Directory.Ldap
+{
+
+ /// <summary> An implementation of LdapAuthHandler must be able to provide an
+ /// LdapAuthProvider object at the time of a referral. The class
+ /// encapsulates information that is used by the client for authentication
+ /// when following referrals automatically.
+ ///
+ /// </summary>
+ /// <seealso cref="LdapAuthHandler">
+ /// </seealso>
+ /// <seealso cref="LdapBindHandler">
+ /// </seealso>
+ /// <seealso cref="LdapConstraints#setReferralFollowing(boolean)">
+ /// </seealso>
+ public class LdapAuthProvider
+ {
+ /// <summary> Returns the distinguished name to be used for authentication on
+ /// automatic referral following.
+ ///
+ /// </summary>
+ /// <returns> The distinguished name from the object.
+ /// </returns>
+ virtual public System.String DN
+ {
+ get
+ {
+ return dn;
+ }
+
+ }
+ /// <summary> Returns the password to be used for authentication on automatic
+ /// referral following.
+ ///
+ /// </summary>
+ /// <returns> The byte[] value (UTF-8) of the password from the object.
+ /// </returns>
+ [CLSCompliantAttribute(false)]
+ virtual public sbyte[] Password
+ {
+ get
+ {
+ return password;
+ }
+
+ }
+
+ private System.String dn;
+ private sbyte[] password;
+
+ /// <summary> Constructs information that is used by the client for authentication
+ /// when following referrals automatically.
+ ///
+ /// </summary>
+ /// <param name="dn"> The distinguished name to use when authenticating to
+ /// a server.
+ /// <br><br>
+ /// </param>
+ /// <param name="password"> The password to use when authenticating to a server.
+ /// </param>
+ [CLSCompliantAttribute(false)]
+ public LdapAuthProvider(System.String dn, sbyte[] password)
+ {
+ this.dn = dn;
+ this.password = password;
+ return ;
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapBindHandler.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapBindHandler.cs
new file mode 100755
index 00000000000..e2c15bf7150
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapBindHandler.cs
@@ -0,0 +1,90 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.LdapBindHandler.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+namespace Novell.Directory.Ldap
+{
+
+ /// <summary>
+ /// Used to do explicit bind processing on a referral.
+ ///
+ /// <p>This interface allows a programmer to override the default
+ /// authentication and reauthentication behavior when automatically
+ /// following referrals and search references. It is used to control the
+ /// authentication mechanism used on automatic referral following.</p>
+ ///
+ /// <p>A client can specify an instance of this class to be used
+ /// on a single operation (through the LdapConstraints object)
+ /// or for all operations (through the LdapContraints object
+ /// associated with the connection).
+ ///
+ ///
+ /// </summary>
+ /// <seealso cref="LdapAuthHandler">
+ /// </seealso>
+ /// <seealso cref="LdapConstraints#setReferralFollowing(boolean)">
+ /// </seealso>
+ public interface LdapBindHandler : LdapReferralHandler
+ {
+
+ /// <summary> Called by LdapConnection when a referral is received.
+ ///
+ /// <p>This method has the responsibility to bind to one of the
+ /// hosts in the list specified by the ldaprul parameter which corresponds
+ /// exactly to the list of hosts returned in a single referral response.
+ /// An implementation may access the host, port, credentials, and other
+ /// information in the original LdapConnection object to decide on an
+ /// appropriate authentication mechanism, and/or interact with a user or
+ /// external module. The object implementing LdapBind creates a new
+ /// LdapConnection object to perform its connect and bind calls. It
+ /// returns the new connection when both the connect and bind operations
+ /// succeed on one host from the list. The LdapConnection object referral
+ /// following code uses the new LdapConnection object when it resends the
+ /// search request, updated with the new search base and possible search
+ /// filter. An LdapException is thrown on failure, as in the
+ /// LdapConnection.bind method. </p>
+ ///
+ /// </summary>
+ /// <param name="ldapurl">The list of servers contained in a referral response.
+ /// </param>
+ /// <param name="conn"> An established connection to an Ldap server.
+ ///
+ /// </param>
+ /// <returns> An established connection to one of the ldap servers
+ /// in the referral list.
+ ///
+ /// </returns>
+ /// <exception cref=""> LdapReferralException An LdapreferralException is thrown
+ /// with appropriate fields set to give the reason for the failure.
+ /// </exception>
+ LdapConnection Bind(System.String[] ldapurl, LdapConnection conn);
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapBindRequest.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapBindRequest.cs
new file mode 100755
index 00000000000..cee5fa4d41f
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapBindRequest.cs
@@ -0,0 +1,101 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.LdapBindRequest.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+using Novell.Directory.Ldap.Asn1;
+using Novell.Directory.Ldap.Rfc2251;
+namespace Novell.Directory.Ldap
+{
+
+ /// <summary> Represents a simple bind request.
+ ///
+ /// </summary>
+ /// <seealso cref="LdapConnection#sendRequest">
+ /// </seealso>
+ /*
+ * BindRequest ::= [APPLICATION 0] SEQUENCE {
+ * version INTEGER (1 .. 127),
+ * name LdapDN,
+ * authentication AuthenticationChoice }
+ */
+ public class LdapBindRequest:LdapMessage
+ {
+ /// <summary> Retrieves the Authentication DN for a bind request.
+ ///
+ /// </summary>
+ /// <returns> the Authentication DN for a bind request
+ /// </returns>
+ virtual public System.String AuthenticationDN
+ {
+ get
+ {
+ return Asn1Object.RequestDN;
+ }
+
+ }
+ /// <summary> Constructs a simple bind request.
+ ///
+ /// </summary>
+ /// <param name="version"> The Ldap protocol version, use Ldap_V3.
+ /// Ldap_V2 is not supported.
+ /// <br><br>
+ /// </param>
+ /// <param name="dn"> If non-null and non-empty, specifies that the
+ /// connection and all operations through it should
+ /// be authenticated with dn as the distinguished
+ /// name.
+ /// <br><br>
+ /// </param>
+ /// <param name="passwd"> If non-null and non-empty, specifies that the
+ /// connection and all operations through it should
+ /// be authenticated with dn as the distinguished
+ /// name and passwd as password.
+ ///
+ /// </param>
+ /// <param name="cont">Any controls that apply to the simple bind request,
+ /// or null if none.
+ /// </param>
+ [CLSCompliantAttribute(false)]
+ public LdapBindRequest(int version, System.String dn, sbyte[] passwd, LdapControl[] cont):base(LdapMessage.BIND_REQUEST, new RfcBindRequest(new Asn1Integer(version), new RfcLdapDN(dn), new RfcAuthenticationChoice(new Asn1Tagged(new Asn1Identifier(Asn1Identifier.CONTEXT, false, 0), new Asn1OctetString(passwd), false))), cont)
+ {
+ return ;
+ }
+
+ /// <summary> Return an Asn1 representation of this add request.
+ ///
+ /// #return an Asn1 representation of this object.
+ /// </summary>
+ public override System.String ToString()
+ {
+ return Asn1Object.ToString();
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapCompareAttrNames.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapCompareAttrNames.cs
new file mode 100755
index 00000000000..f46a49f04f9
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapCompareAttrNames.cs
@@ -0,0 +1,299 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.LdapCompareAttrNames.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+using Novell.Directory.Ldap.Utilclass;
+
+namespace Novell.Directory.Ldap
+{
+
+
+ /// <summary> Compares Ldap entries based on attribute name.
+ ///
+ /// <p>An object of this class defines ordering when sorting LdapEntries,
+ /// usually from search results. When using this Comparator, LdapEntry objects
+ /// are sorted by the attribute names(s) passed in on the
+ /// constructor, in ascending or descending order. The object is typically
+ /// supplied to an implementation of the collection interfaces such as
+ /// java.util.TreeSet which performs sorting. </p>
+ ///
+ /// <p>Comparison is performed via locale-sensitive Java String comparison,
+ /// which may not correspond to the Ldap ordering rules by which an Ldap server
+ /// would sort them.
+ ///
+ /// </summary>
+ public class LdapCompareAttrNames : System.Collections.IComparer
+ {
+ private void InitBlock()
+ {
+// location = Locale.getDefault();
+ location=System.Globalization.CultureInfo.CurrentCulture;
+ collator = System.Globalization.CultureInfo.CurrentCulture.CompareInfo;
+ }
+ /// <summary> Returns the locale to be used for sorting, if a locale has been
+ /// specified.
+ ///
+ /// <p>If locale is null, a basic String.compareTo method is used for
+ /// collation. If non-null, a locale-specific collation is used. </p>
+ ///
+ /// </summary>
+ /// <returns> The locale if one has been specified
+ /// </returns>
+ /// <summary> Sets the locale to be used for sorting.
+ ///
+ /// </summary>
+ /// <param name="locale"> The locale to be used for sorting.
+ /// </param>
+ virtual public System.Globalization.CultureInfo Locale
+ {
+ get
+ {
+ //currently supports only English local.
+ return location;
+ }
+
+ set
+ {
+ collator = value.CompareInfo;
+ location = value;
+ }
+
+ }
+ private System.String[] sortByNames; //names to to sort by.
+ private bool[] sortAscending; //true if sorting ascending
+ private System.Globalization.CultureInfo location;
+ private System.Globalization.CompareInfo collator;
+
+ /// <summary> Constructs an object that sorts results by a single attribute, in
+ /// ascending order.
+ ///
+ /// </summary>
+ /// <param name="attrName"> Name of an attribute by which to sort.
+ ///
+ /// </param>
+ public LdapCompareAttrNames(System.String attrName)
+ {
+ InitBlock();
+ sortByNames = new System.String[1];
+ sortByNames[0] = attrName;
+ sortAscending = new bool[1];
+ sortAscending[0] = true;
+ }
+
+ /// <summary> Constructs an object that sorts results by a single attribute, in
+ /// either ascending or descending order.
+ ///
+ /// </summary>
+ /// <param name="attrName"> Name of an attribute to sort by.
+ /// <br><br>
+ /// </param>
+ /// <param name="ascendingFlag"> True specifies ascending order; false specifies
+ /// descending order.
+ /// </param>
+ public LdapCompareAttrNames(System.String attrName, bool ascendingFlag)
+ {
+ InitBlock();
+ sortByNames = new System.String[1];
+ sortByNames[0] = attrName;
+ sortAscending = new bool[1];
+ sortAscending[0] = ascendingFlag;
+ }
+
+
+ /// <summary> Constructs an object that sorts by one or more attributes, in the
+ /// order provided, in ascending order.
+ ///
+ /// <p>Note: Novell eDirectory allows sorting by one attribute only. The
+ /// direcctory server must also be configured to index the specified
+ /// attribute.</p>
+ ///
+ /// </summary>
+ /// <param name="attrNames"> Array of names of attributes to sort by.
+ ///
+ /// </param>
+ public LdapCompareAttrNames(System.String[] attrNames)
+ {
+ InitBlock();
+ sortByNames = new System.String[attrNames.Length];
+ sortAscending = new bool[attrNames.Length];
+ for (int i = 0; i < attrNames.Length; i++)
+ {
+ sortByNames[i] = attrNames[i];
+ sortAscending[i] = true;
+ }
+ }
+
+ /// <summary> Constructs an object that sorts by one or more attributes, in the
+ /// order provided, in either ascending or descending order for each
+ /// attribute.
+ ///
+ /// <p>Note: Novell eDirectory supports only ascending sort order (A,B,C ...)
+ /// and allows sorting only by one attribute. The directory server must be
+ /// configured to index this attribute.</p>
+ ///
+ /// </summary>
+ /// <param name="attrNames"> Array of names of attributes to sort by.
+ /// <br><br>
+ /// </param>
+ /// <param name="ascendingFlags"> Array of flags, one for each attrName, where
+ /// true specifies ascending order and false specifies
+ /// descending order. An LdapException is thrown if
+ /// the length of ascendingFlags is not greater than
+ /// or equal to the length of attrNames.
+ ///
+ /// </param>
+ /// <exception cref=""> LdapException A general exception which includes an error
+ /// message and an Ldap error code.
+ ///
+ /// </exception>
+ public LdapCompareAttrNames(System.String[] attrNames, bool[] ascendingFlags)
+ {
+ InitBlock();
+ if (attrNames.Length != ascendingFlags.Length)
+ {
+ throw new LdapException(ExceptionMessages.UNEQUAL_LENGTHS, LdapException.INAPPROPRIATE_MATCHING, (System.String) null);
+ //"Length of attribute Name array does not equal length of Flags array"
+ }
+ sortByNames = new System.String[attrNames.Length];
+ sortAscending = new bool[ascendingFlags.Length];
+ for (int i = 0; i < attrNames.Length; i++)
+ {
+ sortByNames[i] = attrNames[i];
+ sortAscending[i] = ascendingFlags[i];
+ }
+ }
+
+ /// <summary> Compares the the attributes of the first LdapEntry to the second.
+ /// <p>Only the values of the attributes named at the construction of this
+ /// object will be compared. Multi-valued attributes compare on the first
+ /// value only. </p>
+ ///
+ /// </summary>
+ /// <param name="object1"> Target entry for comparison.
+ ///
+ /// </param>
+ /// <param name="object2"> Entry to be compared to.
+ ///
+ /// </param>
+ /// <returns> Negative value if the first entry is less than the second and
+ /// positive if the first is greater than the second. Zero is returned if all
+ /// attributes to be compared are the same.
+ /// </returns>
+ public virtual int Compare(System.Object object1, System.Object object2)
+ {
+ LdapEntry entry1 = (LdapEntry) object1;
+ LdapEntry entry2 = (LdapEntry) object2;
+ LdapAttribute one, two;
+ System.String[] first; //multivalued attributes are ignored.
+ System.String[] second; //we just use the first element
+ int compare, i = 0;
+ if (collator == null)
+ {
+ //using default locale
+ collator = System.Globalization.CultureInfo.CurrentCulture.CompareInfo;
+ }
+
+ do
+ {
+ //while first and second are equal
+ one = entry1.getAttribute(sortByNames[i]);
+ two = entry2.getAttribute(sortByNames[i]);
+ if ((one != null) && (two != null))
+ {
+ first = one.StringValueArray;
+ second = two.StringValueArray;
+ compare = collator.Compare(first[0], second[0]);
+ }
+ //We could also use the other multivalued attributes to break ties.
+ //one of the entries was null
+ else
+ {
+ if (one != null)
+ compare = - 1;
+ //one is greater than two
+ else if (two != null)
+ compare = 1;
+ //one is lesser than two
+ else
+ compare = 0; //tie - break it with the next attribute name
+ }
+
+ i++;
+ }
+ while ((compare == 0) && (i < sortByNames.Length));
+
+ if (sortAscending[i - 1])
+ {
+ // return the normal ascending comparison.
+ return compare;
+ }
+ else
+ {
+ // negate the comparison for a descending comparison.
+ return - compare;
+ }
+ }
+
+ /// <summary> Determines if this comparator is equal to the comparator passed in.
+ ///
+ /// <p> This will return true if the comparator is an instance of
+ /// LdapCompareAttrNames and compares the same attributes names in the same
+ /// order.</p>
+ ///
+ /// </summary>
+ /// <returns> true the comparators are equal
+ /// </returns>
+ public override bool Equals(System.Object comparator)
+ {
+ if (!(comparator is LdapCompareAttrNames))
+ {
+ return false;
+ }
+ LdapCompareAttrNames comp = (LdapCompareAttrNames) comparator;
+
+ // Test to see if the attribute to compare are the same length
+ if ((comp.sortByNames.Length != this.sortByNames.Length) || (comp.sortAscending.Length != this.sortAscending.Length))
+ {
+ return false;
+ }
+
+ // Test to see if the attribute names and sorting orders are the same.
+ for (int i = 0; i < this.sortByNames.Length; i++)
+ {
+ if (comp.sortAscending[i] != this.sortAscending[i])
+ return false;
+ if (!comp.sortByNames[i].ToUpper().Equals(this.sortByNames[i].ToUpper()))
+ return false;
+ }
+ return true;
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapCompareRequest.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapCompareRequest.cs
new file mode 100755
index 00000000000..d7b7d52dbe7
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapCompareRequest.cs
@@ -0,0 +1,115 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.LdapCompareRequest.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+using Novell.Directory.Ldap.Rfc2251;
+
+namespace Novell.Directory.Ldap
+{
+
+ /// <summary> Represents an Ldap Compare Request.
+ ///
+ /// </summary>
+ /// <seealso cref="LdapConnection#sendRequest">
+ /// </seealso>
+ /*
+ * CompareRequest ::= [APPLICATION 14] SEQUENCE {
+ * entry LdapDN,
+ * ava AttributeValueAssertion }
+ */
+ public class LdapCompareRequest:LdapMessage
+ {
+ /// <summary> Returns the LdapAttribute associated with this request.
+ ///
+ /// </summary>
+ /// <returns> the LdapAttribute
+ /// </returns>
+ virtual public System.String AttributeDescription
+ {
+ get
+ {
+ RfcCompareRequest req = (RfcCompareRequest) Asn1Object.getRequest();
+ return req.AttributeValueAssertion.AttributeDescription;
+ }
+
+ }
+ /// <summary> Returns the LdapAttribute associated with this request.
+ ///
+ /// </summary>
+ /// <returns> the LdapAttribute
+ /// </returns>
+ [CLSCompliantAttribute(false)]
+ virtual public sbyte[] AssertionValue
+ {
+ get
+ {
+ RfcCompareRequest req = (RfcCompareRequest) Asn1Object.getRequest();
+ return req.AttributeValueAssertion.AssertionValue;
+ }
+
+ }
+ /// <summary> Returns of the dn of the entry to compare in the directory
+ ///
+ /// </summary>
+ /// <returns> the dn of the entry to compare
+ /// </returns>
+ virtual public System.String DN
+ {
+ get
+ {
+ return Asn1Object.RequestDN;
+ }
+
+ }
+ /// <summary> Constructs an LdapCompareRequest Object.
+ /// <br><br>
+ /// </summary>
+ /// <param name="dn"> The distinguished name of the entry containing an
+ /// attribute to compare.
+ /// <br><br>
+ /// </param>
+ /// <param name="name"> The name of the attribute to compare.
+ /// <br><br>
+ /// </param>
+ /// <param name="value"> The value of the attribute to compare.
+ ///
+ /// <br><br>
+ /// </param>
+ /// <param name="cont">Any controls that apply to the compare request,
+ /// or null if none.
+ /// </param>
+ [CLSCompliantAttribute(false)]
+ public LdapCompareRequest(System.String dn, System.String name, sbyte[] value_Renamed, LdapControl[] cont):base(LdapMessage.COMPARE_REQUEST, new RfcCompareRequest(new RfcLdapDN(dn), new RfcAttributeValueAssertion(new RfcAttributeDescription(name), new RfcAssertionValue(value_Renamed))), cont)
+ {
+ return ;
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapConnection.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapConnection.cs
new file mode 100755
index 00000000000..b296d1e6f22
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapConnection.cs
@@ -0,0 +1,3625 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.LdapConnection.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+using Novell.Directory.Ldap;
+using Novell.Directory.Ldap.Asn1;
+using Novell.Directory.Ldap.Rfc2251;
+using Novell.Directory.Ldap.Utilclass;
+
+namespace Novell.Directory.Ldap
+{
+
+ /// <summary> The central class that encapsulates the connection
+ /// to a directory server through the Ldap protocol.
+ /// LdapConnection objects are used to perform common Ldap
+ /// operations such as search, modify and add.
+ ///
+ /// <p>In addition, LdapConnection objects allow you to bind to an
+ /// Ldap server, set connection and search constraints, and perform
+ /// several other tasks.
+ ///
+ /// <p>An LdapConnection object is not connected on
+ /// construction and can only be connected to one server at one
+ /// port. Multiple threads may share this single connection, typically
+ /// by cloning the connection object, one for each thread. An
+ /// application may have more than one LdapConnection object, connected
+ /// to the same or different directory servers.</p>
+ ///
+ ///
+ /// </summary>
+ public class LdapConnection : System.ICloneable
+ {
+ private void InitBlock()
+ {
+ defSearchCons = new LdapSearchConstraints();
+ responseCtlSemaphore = new System.Object();
+ }
+ /// <summary> Returns the protocol version uses to authenticate.
+ ///
+ /// <p> 0 is returned if no authentication has been performed.</p>
+ ///
+ /// </summary>
+ /// <returns> The protol version used for authentication or 0
+ /// not authenticated.
+ ///
+ /// </returns>
+ /// <seealso cref="int, String, String)">
+ /// </seealso>
+ virtual public int ProtocolVersion
+ {
+ get
+ {
+ BindProperties prop = conn.BindProperties;
+ if (prop == null)
+ {
+ return Ldap_V3;
+ }
+ return prop.ProtocolVersion;
+ }
+
+ }
+ /// <summary> Returns the distinguished name (DN) used for as the bind name during
+ /// the last successful bind operation. <code>null</code> is returned
+ /// if no authentication has been performed or if the bind resulted in
+ /// an aonymous connection.
+ ///
+ /// </summary>
+ /// <returns> The distinguished name if authenticated; otherwise, null.
+ ///
+ /// </returns>
+ /// <seealso cref="String, String)">
+ /// </seealso>
+ /// <seealso cref="#isBound()">
+ /// </seealso>
+ virtual public System.String AuthenticationDN
+ {
+ get
+ {
+ BindProperties prop = conn.BindProperties;
+ if (prop == null)
+ {
+ return null;
+ }
+ if (prop.Anonymous)
+ {
+ return null;
+ }
+ return prop.AuthenticationDN;
+ }
+
+ }
+ /// <summary> Returns the method used to authenticate the connection. The return
+ /// value is one of the following:
+ ///
+ /// <ul>
+ /// <li>"none" indicates the connection is not authenticated.</li>
+ ///
+ ///
+ /// <li>"simple" indicates simple authentication was used or that a null
+ /// or empty authentication DN was specified.</li>
+ ///
+ /// <li>"sasl" indicates that a SASL mechanism was used to authenticate</li>
+ /// </ul>
+ ///
+ /// </summary>
+ /// <returns> The method used to authenticate the connection.
+ /// </returns>
+ virtual public System.String AuthenticationMethod
+ {
+ get
+ {
+ BindProperties prop = conn.BindProperties;
+ if (prop == null)
+ {
+ return "simple";
+ }
+ return conn.BindProperties.AuthenticationMethod;
+ }
+
+ }
+ /// <summary> Returns the properties if any specified on binding with a
+ /// SASL mechanism.
+ ///
+ /// <p> Null is returned if no authentication has been performed
+ /// or no authentication Map is present.</p>
+ ///
+ /// </summary>
+ /// <returns> The bind properties Map Object used for SASL bind or null if
+ /// the connection is not present or not authenticated.
+ ///
+ /// </returns>
+ /// <seealso cref="String, String, String[], Map, Object )">
+ /// </seealso>
+ virtual public System.Collections.IDictionary SaslBindProperties
+ {
+ get
+ {
+ BindProperties prop = conn.BindProperties;
+ if (prop == null)
+ {
+ return null;
+ }
+ return conn.BindProperties.SaslBindProperties;
+ }
+
+ }
+ /// <summary> Returns the call back handler if any specified on binding with a
+ /// SASL mechanism.
+ ///
+ /// <p> Null is returned if no authentication has been performed
+ /// or no authentication call back handler is present.</p>
+ ///
+ /// </summary>
+ /// <returns> The call back handler used for SASL bind or null if the
+ /// object is not present or not authenticated.
+ ///
+ /// </returns>
+ /// <seealso cref="String, String, String[], Map, Object )">
+ /// </seealso>
+ virtual public System.Object SaslBindCallbackHandler
+ {
+ get
+ {
+ BindProperties prop = conn.BindProperties;
+ if (prop == null)
+ {
+ return null;
+ }
+ return conn.BindProperties.SaslCallbackHandler;
+ }
+
+ }
+ /// <summary> Returns a copy of the set of constraints associated with this
+ /// connection. These constraints apply to all operations performed
+ /// through this connection (unless a different set of constraints is
+ /// specified when calling an operation method).
+ ///
+ /// </summary>
+ /// <returns> The set of default contraints that apply to this connection.
+ ///
+ /// </returns>
+ /// <seealso cref="#setConstraints(LdapConstraints)">
+ /// </seealso>
+ /// <summary> Sets the constraints that apply to all operations performed through
+ /// this connection (unless a different set of constraints is specified
+ /// when calling an operation method). An LdapSearchConstraints object
+ /// which is passed to this method sets all constraints, while an
+ /// LdapConstraints object passed to this method sets only base constraints.
+ ///
+ /// </summary>
+ /// <param name="cons"> An LdapConstraints or LdapSearchConstraints Object
+ /// containing the contstraint values to set.
+ ///
+ /// </param>
+ /// <seealso cref="#getConstraints()">
+ /// </seealso>
+ /// <seealso cref="#getSearchConstraints()">
+ /// </seealso>
+ virtual public LdapConstraints Constraints
+ {
+ get
+ {
+ return (LdapConstraints) (this.defSearchCons).Clone();
+ }
+
+ set
+ {
+ // Set all constraints, replace the object with a new one
+ if (value is LdapSearchConstraints)
+ {
+ defSearchCons = (LdapSearchConstraints) value.Clone();
+ return ;
+ }
+
+ // We set the constraints this way, so a thread doesn't get an
+ // conconsistant view of the referrals.
+ LdapSearchConstraints newCons = (LdapSearchConstraints) defSearchCons.Clone();
+ newCons.HopLimit = value.HopLimit;
+ newCons.TimeLimit = value.TimeLimit;
+ newCons.setReferralHandler(value.getReferralHandler());
+ newCons.ReferralFollowing = value.ReferralFollowing;
+ LdapControl[] lsc = value.getControls();
+ if (lsc != null)
+ {
+ newCons.setControls(lsc);
+ }
+ System.Collections.Hashtable lp = newCons.Properties;
+ if (lp != null)
+ {
+ newCons.Properties = lp;
+ }
+ defSearchCons = newCons;
+ return ;
+ }
+
+ }
+ /// <summary> Returns the host name of the Ldap server to which the object is or
+ /// was last connected, in the format originally specified.
+ ///
+ /// </summary>
+ /// <returns> The host name of the Ldap server to which the object last
+ /// connected or null if the object has never connected.
+ ///
+ /// </returns>
+ /// <seealso cref="String, int)">
+ /// </seealso>
+ virtual public System.String Host
+ {
+ get
+ {
+ return conn.Host;
+ }
+
+ }
+ /// <summary> Returns the port number of the Ldap server to which the object is or
+ /// was last connected.
+ ///
+ /// </summary>
+ /// <returns> The port number of the Ldap server to which the object last
+ /// connected or -1 if the object has never connected.
+ ///
+ /// </returns>
+ /// <seealso cref="String, int)">
+ /// </seealso>
+ virtual public int Port
+ {
+ get
+ {
+ return conn.Port;
+ }
+
+ }
+ /// <summary> Returns a copy of the set of search constraints associated with this
+ /// connection. These constraints apply to search operations performed
+ /// through this connection (unless a different set of
+ /// constraints is specified when calling the search operation method).
+ ///
+ /// </summary>
+ /// <returns> The set of default search contraints that apply to
+ /// this connection.
+ ///
+ /// </returns>
+ /// <seealso cref="#setConstraints">
+ /// </seealso>
+ /// <seealso cref="String, int, String, String[], boolean, LdapSearchConstraints)">
+ /// </seealso>
+ virtual public LdapSearchConstraints SearchConstraints
+ {
+ get
+ {
+ return (LdapSearchConstraints) this.defSearchCons.Clone();
+ }
+
+ }
+ /// <summary> Indicates whether the object has authenticated to the connected Ldap
+ /// server.
+ ///
+ /// </summary>
+ /// <returns> True if the object has authenticated; false if it has not
+ /// authenticated.
+ ///
+ /// </returns>
+ /// <seealso cref="String, String)">
+ /// </seealso>
+ virtual public bool Bound
+ {
+ get
+ {
+ return conn.Bound;
+ }
+
+ }
+ /// <summary> Indicates whether the connection represented by this object is open
+ /// at this time.
+ ///
+ /// </summary>
+ /// <returns> True if connection is open; false if the connection is closed.
+ /// </returns>
+ virtual public bool Connected
+ {
+ get
+ {
+ return conn.Connected;
+ }
+
+ }
+ /// <summary> Returns the Server Controls associated with the most recent response
+ /// to a synchronous request on this connection object, or null
+ /// if the latest response contained no Server Controls. The method
+ /// always returns null for asynchronous requests. For asynchronous
+ /// requests, the response controls are available in LdapMessage.
+ ///
+ /// </summary>
+ /// <returns> The server controls associated with the most recent response
+ /// to a synchronous request or null if the response contains no server
+ /// controls.
+ ///
+ /// </returns>
+ /// <seealso cref="LdapMessage#getControls()">
+ /// </seealso>
+ virtual public LdapControl[] ResponseControls
+ {
+ get
+ {
+ if (responseCtls == null)
+ {
+ return null;
+ }
+
+
+ // We have to clone the control just in case
+ // we have two client threads that end up retreiving the
+ // same control.
+ LdapControl[] clonedControl = new LdapControl[responseCtls.Length];
+
+ // Also note we synchronize access to the local response
+ // control object just in case another message containing controls
+ // comes in from the server while we are busy duplicating
+ // this one.
+ lock (responseCtlSemaphore)
+ {
+ for (int i = 0; i < responseCtls.Length; i++)
+ {
+ clonedControl[i] = (LdapControl) (responseCtls[i]).Clone();
+ }
+ }
+
+ // Return the cloned copy. Note we have still left the
+ // control in the local responseCtls variable just in case
+ // somebody requests it again.
+ return clonedControl;
+ }
+
+ }
+ /// <summary> Return the Connection object associated with this LdapConnection
+ ///
+ /// </summary>
+ /// <returns> the Connection object
+ /// </returns>
+ virtual internal Connection Connection
+ {
+ /* package */
+
+ get
+ {
+ return conn;
+ }
+
+ }
+ /// <summary> Return the Connection object name associated with this LdapConnection
+ ///
+ /// </summary>
+ /// <returns> the Connection object name
+ /// </returns>
+ virtual internal System.String ConnectionName
+ {
+ /* package */
+
+ get
+ {
+ return name;
+ }
+
+ }
+ private LdapSearchConstraints defSearchCons;
+ private LdapControl[] responseCtls = null;
+
+ // Synchronization Object used to synchronize access to responseCtls
+ private System.Object responseCtlSemaphore;
+
+ private Connection conn = null;
+
+ private static System.Object nameLock; // protect agentNum
+ private static int lConnNum = 0; // Debug, LdapConnection number
+ private System.String name; // String name for debug
+
+ /// <summary> Used with search to specify that the scope of entrys to search is to
+ /// search only the base obect.
+ ///
+ /// <p>SCOPE_BASE = 0</p>
+ /// </summary>
+ public const int SCOPE_BASE = 0;
+
+ /// <summary> Used with search to specify that the scope of entrys to search is to
+ /// search only the immediate subordinates of the base obect.
+ ///
+ /// <p>SCOPE_ONE = 1</p>
+ /// </summary>
+ public const int SCOPE_ONE = 1;
+
+ /// <summary> Used with search to specify that the scope of entrys to search is to
+ /// search the base object and all entries within its subtree.
+ ///
+ /// <p>SCOPE_ONE = 2</p>
+ /// </summary>
+ public const int SCOPE_SUB = 2;
+
+ /// <summary> Used with search instead of an attribute list to indicate that no
+ /// attributes are to be returned.
+ ///
+ /// <p>NO_ATTRS = "1.1"</p>
+ /// </summary>
+ public const System.String NO_ATTRS = "1.1";
+
+ /// <summary> Used with search instead of an attribute list to indicate that all
+ /// attributes are to be returned.
+ ///
+ /// <p>ALL_USER_ATTRS = "*"</p>
+ /// </summary>
+ public const System.String ALL_USER_ATTRS = "*";
+
+ /// <summary> Specifies the Ldapv3 protocol version when performing a bind operation.
+ ///
+ /// <p>Specifies Ldap version V3 of the protocol, and is specified
+ /// when performing bind operations.
+ /// <p>You can use this identifier in the version parameter
+ /// of the bind method to specify an Ldapv3 bind.
+ /// Ldap_V3 is the default protocol version</p>
+ ///
+ /// <p>Ldap_V3 = 3</p>
+ ///
+ /// </summary>
+ /// <seealso cref="String, byte[])">
+ /// </seealso>
+ /// <seealso cref="String, byte[], LdapConstraints)">
+ /// </seealso>
+ /// <seealso cref="String, byte[], LdapResponseQueue)">
+ /// </seealso>
+ /// <seealso cref="String, byte[], LdapResponseQueue, LdapConstraints)">
+ /// </seealso>
+ public const int Ldap_V3 = 3;
+
+ /// <summary> The default port number for Ldap servers.
+ ///
+ /// <p>You can use this identifier to specify the port when establishing
+ /// a clear text connection to a server. This the default port.</p>
+ ///
+ /// <p>DEFAULT_PORT = 389</p>
+ ///
+ /// </summary>
+ /// <seealso cref="int)">
+ /// </seealso>
+ public const int DEFAULT_PORT = 389;
+
+
+ /// <summary> The default SSL port number for Ldap servers.
+ ///
+ /// <p>DEFAULT_SSL_PORT = 636</p>
+ ///
+ /// <p>You can use this identifier to specify the port when establishing
+ /// a an SSL connection to a server.</p>.
+ /// </summary>
+ public const int DEFAULT_SSL_PORT = 636;
+
+ /// <summary> A string that can be passed in to the getProperty method.
+ ///
+ /// <p>Ldap_PROPERTY_SDK = "version.sdk"</p>
+ ///
+ /// <p>You can use this string to request the version of the SDK</p>.
+ /// </summary>
+ public const System.String Ldap_PROPERTY_SDK = "version.sdk";
+
+ /// <summary> A string that can be passed in to the getProperty method.
+ ///
+ /// <p>Ldap_PROPERTY_PROTOCOL = "version.protocol"</p>
+ ///
+ /// <p>You can use this string to request the version of the
+ /// Ldap protocol</p>.
+ /// </summary>
+ public const System.String Ldap_PROPERTY_PROTOCOL = "version.protocol";
+
+ /// <summary> A string that can be passed in to the getProperty method.
+ ///
+ /// <p>Ldap_PROPERTY_SECURITY = "version.security"</p>
+ ///
+ /// <p>You can use this string to request the type of security
+ /// being used</p>.
+ /// </summary>
+ public const System.String Ldap_PROPERTY_SECURITY = "version.security";
+
+ /// <summary> A string that corresponds to the server shutdown notification OID.
+ /// This notification may be used by the server to advise the client that
+ /// the server is about to close the connection due to an error
+ /// condition.
+ ///
+ /// <p>SERVER_SHUTDOWN_OID = "1.3.6.1.4.1.1466.20036"
+ /// </summary>
+ public const System.String SERVER_SHUTDOWN_OID = "1.3.6.1.4.1.1466.20036";
+
+ /// <summary> The OID string that identifies a StartTLS request and response.</summary>
+ private const System.String START_TLS_OID = "1.3.6.1.4.1.1466.20037";
+
+ /*
+ * Constructors
+ */
+
+
+ /// <summary> Constructs a new LdapConnection object, which will use the supplied
+ /// class factory to construct a socket connection during
+ /// LdapConnection.connect method.
+ ///
+ /// </summary>
+ /// <param name="factory"> An object capable of producing a Socket.
+ ///
+ /// </param>
+ /// <seealso cref="int)">
+ /// </seealso>
+ /// <seealso cref="#getSocketFactory()">
+ /// </seealso>
+ /// <seealso cref="LdapSocketFactory)">
+ /// </seealso>
+ public LdapConnection()
+ {
+ InitBlock();
+ // Get a unique connection name for debug
+ conn = new Connection();
+ return ;
+ }
+
+ /*
+ * The following are methods that affect the operation of
+ * LdapConnection, but are not Ldap requests.
+ */
+
+ /// <summary> Returns a copy of the object with a private context, but sharing the
+ /// network connection if there is one.
+ ///
+ /// <p>The network connection remains open until all clones have
+ /// disconnected or gone out of scope. Any connection opened after
+ /// cloning is private to the object making the connection.</p>
+ ///
+ /// <p>The clone can issue requests and freely modify options and search
+ /// constraints, and , without affecting the source object or other clones.
+ /// If the clone disconnects or reconnects, it is completely dissociated
+ /// from the source object and other clones. Reauthenticating in a clone,
+ /// however, is a global operation which will affect the source object
+ /// and all associated clones, because it applies to the single shared
+ /// physical connection. Any request by an associated object after one
+ /// has reauthenticated will carry the new identity.</p>
+ ///
+ /// </summary>
+ /// <returns> A of the object.
+ /// </returns>
+ public System.Object Clone()
+ {
+ LdapConnection newClone;
+ System.Object newObj;
+ try
+ {
+ newObj = base.MemberwiseClone();
+ newClone = (LdapConnection) newObj;
+ }
+ catch (System.Exception ce)
+ {
+ throw new System.SystemException("Internal error, cannot create clone");
+ }
+ newClone.conn = conn; // same underlying connection
+
+ //now just duplicate the defSearchCons and responseCtls
+ if (defSearchCons != null)
+ {
+ newClone.defSearchCons = (LdapSearchConstraints) defSearchCons.Clone();
+ }
+ else
+ {
+ newClone.defSearchCons = null;
+ }
+ if (responseCtls != null)
+ {
+ newClone.responseCtls = new LdapControl[responseCtls.Length];
+ for (int i = 0; i < responseCtls.Length; i++)
+ {
+ newClone.responseCtls[i] = (LdapControl) responseCtls[i].Clone();
+ }
+ }
+ else
+ {
+ newClone.responseCtls = null;
+ }
+ conn.incrCloneCount(); // Increment the count of clones
+ return newObj;
+ }
+
+ /// <summary> Closes the connection, if open, and releases any other resources held
+ /// by the object.
+ ///
+ /// </summary>
+ /// <exception cref=""> LdapException A general exception which includes an error
+ /// message and an Ldap error code.
+ ///
+ /// </exception>
+ /// <seealso cref="#disconnect">
+ /// </seealso>
+ ~LdapConnection()
+ {
+ // Disconnect did not come from user API call
+ Disconnect(defSearchCons, false);
+ return ;
+ }
+
+ /// <summary> Returns a property of a connection object.
+ ///
+ /// </summary>
+ /// <param name="name"> Name of the property to be returned.
+ ///
+ /// <p>The following read-only properties are available
+ /// for any given connection:</p>
+ /// <ul>
+ /// <li>Ldap_PROPERTY_SDK returns the version of this SDK,
+ /// as a Float data type.</li>
+ ///
+ /// <li>Ldap_PROPERTY_PROTOCOL returns the highest supported version of
+ /// the Ldap protocol, as a Float data type.</li>
+ ///
+ /// <li>Ldap_PROPERTY_SECURITY returns a comma-separated list of the
+ /// types of authentication supported, as a
+ /// string.
+ /// </ul>
+ ///
+ /// <p>A deep copy of the property is provided where applicable; a
+ /// client does not need to clone the object received.</p>
+ ///
+ /// </param>
+ /// <returns> The object associated with the requested property,
+ /// or null if the property is not defined.
+ ///
+ /// </returns>
+ /// <seealso cref="LdapConstraints#getProperty(String)">
+ /// </seealso>
+ /// <seealso cref="Object)">
+ /// </seealso>
+ public virtual System.Object getProperty(System.String name)
+ {
+ if (name.ToUpper().Equals(Ldap_PROPERTY_SDK.ToUpper()))
+ return Connection.sdk;
+ else if (name.ToUpper().Equals(Ldap_PROPERTY_PROTOCOL.ToUpper()))
+ return Connection.protocol;
+ else if (name.ToUpper().Equals(Ldap_PROPERTY_SECURITY.ToUpper()))
+ return Connection.security;
+ else
+ {
+ return null;
+ }
+ }
+
+ /// <summary> Registers an object to be notified on arrival of an unsolicited
+ /// message from a server.
+ ///
+ /// <p>An unsolicited message has the ID 0. A new thread is created and
+ /// the method "messageReceived" in each registered object is called in
+ /// turn.</p>
+ ///
+ /// </summary>
+ /// <param name="listener"> An object to be notified on arrival of an
+ /// unsolicited message from a server. This object must
+ /// implement the LdapUnsolicitedNotificationListener interface.
+ ///
+ /// </param>
+ public virtual void AddUnsolicitedNotificationListener(LdapUnsolicitedNotificationListener listener)
+ {
+ if (listener != null)
+ conn.AddUnsolicitedNotificationListener(listener);
+ }
+
+
+
+ /// <summary> Deregisters an object so that it will no longer be notified on
+ /// arrival of an unsolicited message from a server. If the object is
+ /// null or was not previously registered for unsolicited notifications,
+ /// the method does nothing.
+ ///
+ ///
+ /// </summary>
+ /// <param name="listener"> An object to no longer be notified on arrival of
+ /// an unsolicited message from a server.
+ ///
+ /// </param>
+ public virtual void RemoveUnsolicitedNotificationListener(LdapUnsolicitedNotificationListener listener)
+ {
+
+ if (listener != null)
+ conn.RemoveUnsolicitedNotificationListener(listener);
+ }
+
+ /// <summary> Starts Transport Layer Security (TLS) protocol on this connection
+ /// to enable session privacy.
+ ///
+ /// <p>This affects the LdapConnection object and all cloned objects. A
+ /// socket factory that implements LdapTLSSocketFactory must be set on the
+ /// connection.</p>
+ ///
+ /// </summary>
+ /// <exception cref=""> LdapException Thrown if TLS cannot be started. If a
+ /// SocketFactory has been specified that does not implement
+ /// LdapTLSSocketFactory an LdapException is thrown.
+ ///
+ /// </exception>
+ /// <seealso cref="#isTLS">
+ /// </seealso>
+ /// <seealso cref="#stopTLS">
+ /// </seealso>
+ /// <seealso cref="#setSocketFactory">
+ /// </seealso>
+ //*************************************************************************
+ // Below are all of the Ldap protocol operation methods
+ //*************************************************************************
+
+ //*************************************************************************
+ // abandon methods
+ //*************************************************************************
+
+ /// <summary>
+ ///
+ /// Notifies the server not to send additional results associated with
+ /// this LdapSearchResults object, and discards any results already
+ /// received.
+ ///
+ /// </summary>
+ /// <param name="results"> An object returned from a search.
+ ///
+ /// </param>
+ /// <exception cref=""> LdapException A general exception which includes an error
+ /// message and an Ldap error code.
+ /// </exception>
+ public virtual void Abandon(LdapSearchResults results)
+ {
+ Abandon(results, defSearchCons);
+ return ;
+ }
+
+ /// <summary>
+ ///
+ /// Notifies the server not to send additional results associated with
+ /// this LdapSearchResults object, and discards any results already
+ /// received.
+ ///
+ /// </summary>
+ /// <param name="results"> An object returned from a search.
+ /// <br><br>
+ /// </param>
+ /// <param name="cons"> The contraints specific to the operation.
+ ///
+ /// </param>
+ /// <exception cref=""> LdapException A general exception which includes an error
+ /// message and an Ldap error code.
+ /// </exception>
+ public virtual void Abandon(LdapSearchResults results, LdapConstraints cons)
+ {
+ results.Abandon();
+ return ;
+ }
+
+ /// <summary>
+ /// Abandons an asynchronous operation.
+ ///
+ /// </summary>
+ /// <param name="id"> The ID of the asynchronous operation to abandon. The ID
+ /// can be obtained from the response queue for the
+ /// operation.
+ ///
+ /// </param>
+ /// <exception cref=""> LdapException A general exception which includes an error
+ /// message and an Ldap error code.
+ /// </exception>
+ public virtual void Abandon(int id)
+ {
+ Abandon(id, defSearchCons);
+ return ;
+ }
+
+ /// <summary> Abandons an asynchronous operation, using the specified
+ /// constraints.
+ ///
+ /// </summary>
+ /// <param name="id">The ID of the asynchronous operation to abandon.
+ /// The ID can be obtained from the search
+ /// queue for the operation.
+ /// <br><br>
+ /// </param>
+ /// <param name="cons">The contraints specific to the operation.
+ ///
+ /// </param>
+ /// <exception cref=""> LdapException A general exception which includes an error
+ /// message and an Ldap error code.
+ /// </exception>
+ public virtual void Abandon(int id, LdapConstraints cons)
+ {
+ // We need to inform the Message Agent which owns this messageID to
+ // remove it from the queue.
+ try
+ {
+ MessageAgent agent = conn.getMessageAgent(id);
+ agent.Abandon(id, cons);
+ return ;
+ }
+ catch (System.FieldAccessException ex)
+ {
+ return ; // Ignore error
+ }
+ }
+
+ /// <summary> Abandons all outstanding operations managed by the queue.
+ ///
+ /// <p>All operations in progress, which are managed by the specified queue,
+ /// are abandoned.</p>
+ ///
+ /// </summary>
+ /// <param name="queue"> The queue returned from an asynchronous request.
+ /// All outstanding operations managed by the queue
+ /// are abandoned, and the queue is emptied.
+ ///
+ /// </param>
+ /// <exception cref=""> LdapException A general exception which includes an error
+ /// message and an Ldap error code.
+ /// </exception>
+ public virtual void Abandon(LdapMessageQueue queue)
+ {
+ Abandon(queue, defSearchCons);
+ return ;
+ }
+
+ /// <summary> Abandons all outstanding operations managed by the queue.
+ ///
+ /// <p>All operations in progress, which are managed by the specified
+ /// queue, are abandoned.</p>
+ ///
+ /// </summary>
+ /// <param name="queue"> The queue returned from an asynchronous request.
+ /// All outstanding operations managed by the queue
+ /// are abandoned, and the queue is emptied.
+ /// <br><br>
+ /// </param>
+ /// <param name="cons"> The contraints specific to the operation.
+ ///
+ /// </param>
+ /// <exception cref=""> LdapException A general exception which includes an error
+ /// message and an Ldap error code.
+ /// </exception>
+ public virtual void Abandon(LdapMessageQueue queue, LdapConstraints cons)
+ {
+ if (queue != null)
+ {
+ MessageAgent agent;
+ if (queue is LdapSearchQueue)
+ {
+ agent = queue.MessageAgent;
+ }
+ else
+ {
+ agent = queue.MessageAgent;
+ }
+ int[] msgIds = agent.MessageIDs;
+ for (int i = 0; i < msgIds.Length; i++)
+ {
+ agent.Abandon(msgIds[i], cons);
+ }
+ }
+ return ;
+ }
+
+ //*************************************************************************
+ // add methods
+ //*************************************************************************
+
+ /// <summary> Synchronously adds an entry to the directory.
+ ///
+ /// </summary>
+ /// <param name="entry"> LdapEntry object specifying the distinguished
+ /// name and attributes of the new entry.
+ ///
+ /// </param>
+ /// <exception cref=""> LdapException A general exception which includes an error
+ /// message and an Ldap error code.
+ /// </exception>
+ public virtual void Add(LdapEntry entry)
+ {
+ Add(entry, defSearchCons);
+ return ;
+ }
+
+ /// <summary>
+ /// Synchronously adds an entry to the directory, using the specified
+ /// constraints.
+ ///
+ /// </summary>
+ /// <param name="entry"> LdapEntry object specifying the distinguished
+ /// name and attributes of the new entry.
+ /// <br><br>
+ /// </param>
+ /// <param name="cons"> Constraints specific to the operation.
+ ///
+ /// </param>
+ /// <exception cref=""> LdapException A general exception which includes an error
+ /// message and an Ldap error code.
+ /// </exception>
+
+ public virtual void Add(LdapEntry entry, LdapConstraints cons)
+ {
+ LdapResponseQueue queue = Add(entry, null, cons);
+
+ // Get a handle to the add response
+ LdapResponse addResponse = (LdapResponse) (queue.getResponse());
+
+ // Set local copy of responseControls synchronously if there were any
+ lock (responseCtlSemaphore)
+ {
+ responseCtls = addResponse.Controls;
+ }
+ chkResultCode(queue, cons, addResponse);
+ return ;
+ }
+
+ /// <summary> Asynchronously adds an entry to the directory.
+ ///
+ /// </summary>
+ /// <param name="entry"> LdapEntry object specifying the distinguished
+ /// name and attributes of the new entry.
+ /// <br><br>
+ /// </param>
+ /// <param name="queue"> Handler for messages returned from a server in
+ /// response to this request. If it is null, a
+ /// queue object is created internally.
+ ///
+ /// </param>
+ /// <exception cref=""> LdapException A general exception which includes an error
+ /// message and an Ldap error code.
+ /// </exception>
+ public virtual LdapResponseQueue Add(LdapEntry entry, LdapResponseQueue queue)
+ {
+ return Add(entry, queue, defSearchCons);
+ }
+
+ /// <summary> Asynchronously adds an entry to the directory, using the specified
+ /// constraints.
+ ///
+ /// </summary>
+ /// <param name="entry"> LdapEntry object specifying the distinguished
+ /// name and attributes of the new entry.
+ /// <br><br>
+ /// </param>
+ /// <param name="queue"> Handler for messages returned from a server in
+ /// response to this request. If it is null, a
+ /// queue object is created internally.
+ /// <br><br>
+ /// </param>
+ /// <param name="cons"> Constraints specific to the operation.
+ ///
+ /// </param>
+ /// <exception cref=""> LdapException A general exception which includes an error
+ /// message and an Ldap error code.
+ /// </exception>
+ public virtual LdapResponseQueue Add(LdapEntry entry, LdapResponseQueue queue, LdapConstraints cons)
+ {
+ if (cons == null)
+ cons = defSearchCons;
+
+ // error check the parameters
+ if (entry == null)
+ {
+ throw new System.ArgumentException("The LdapEntry parameter" + " cannot be null");
+ }
+ if ((System.Object) entry.DN == null)
+ {
+ throw new System.ArgumentException("The DN value must be present" + " in the LdapEntry object");
+ }
+
+ LdapMessage msg = new LdapAddRequest(entry, cons.getControls());
+
+ return SendRequestToServer(msg, cons.TimeLimit, queue, null);
+ }
+
+ //*************************************************************************
+ // bind methods
+ //*************************************************************************
+
+ /// <summary> Synchronously authenticates to the Ldap server (that the object is
+ /// currently connected to) as an Ldapv3 bind, using the specified name and
+ /// password.
+ ///
+ /// <p>If the object has been disconnected from an Ldap server,
+ /// this method attempts to reconnect to the server. If the object
+ /// has already authenticated, the old authentication is discarded.</p>
+ ///
+ /// </summary>
+ /// <param name="dn"> If non-null and non-empty, specifies that the
+ /// connection and all operations through it should
+ /// be authenticated with dn as the distinguished
+ /// name.
+ /// <br><br>
+ /// </param>
+ /// <param name="passwd"> If non-null and non-empty, specifies that the
+ /// connection and all operations through it should
+ /// be authenticated with dn as the distinguished
+ /// name and passwd as password.
+ /// <br><br>
+ /// Note: the application should use care in the use
+ /// of String password objects. These are long lived
+ /// objects, and may expose a security risk, especially
+ /// in objects that are serialized. The LdapConnection
+ /// keeps no long lived instances of these objects.
+ ///
+ /// </param>
+ /// <exception cref=""> LdapException A general exception which includes an error
+ /// message and an Ldap error code.
+ ///
+ /// </exception>
+ /// <deprecated> replaced by {@link #bind(int, String, byte[])}
+ /// </deprecated>
+ public virtual void Bind(System.String dn, System.String passwd)
+ {
+ Bind(Ldap_V3, dn, passwd, defSearchCons);
+ return ;
+ }
+
+ /// <summary> Synchronously authenticates to the Ldap server (that the object is
+ /// currently connected to) using the specified name, password,
+ /// and Ldap version.
+ ///
+ /// <p>If the object has been disconnected from an Ldap server,
+ /// this method attempts to reconnect to the server. If the object
+ /// has already authenticated, the old authentication is discarded.</p>
+ ///
+ /// </summary>
+ /// <param name="version"> The Ldap protocol version, use Ldap_V3.
+ /// Ldap_V2 is not supported.
+ /// <br><br>
+ /// </param>
+ /// <param name="dn"> If non-null and non-empty, specifies that the
+ /// connection and all operations through it should
+ /// be authenticated with dn as the distinguished
+ /// name.
+ /// <br><br>
+ /// </param>
+ /// <param name="passwd"> If non-null and non-empty, specifies that the
+ /// connection and all operations through it should
+ /// be authenticated with dn as the distinguished
+ /// name and passwd as password.
+ /// <br><br>
+ /// Note: the application should use care in the use
+ /// of String password objects. These are long lived
+ /// objects, and may expose a security risk, especially
+ /// in objects that are serialized. The LdapConnection
+ /// keeps no long lived instances of these objects.
+ ///
+ /// </param>
+ /// <exception cref=""> LdapException A general exception which includes an error
+ /// message and an Ldap error code.
+ ///
+ /// </exception>
+ /// <deprecated> replaced by {@link #bind(int, String, byte[])}
+ /// </deprecated>
+ public virtual void Bind(int version, System.String dn, System.String passwd)
+ {
+ Bind(version, dn, passwd, defSearchCons);
+ return ;
+ }
+
+ /// <summary> Synchronously authenticates to the Ldap server (that the object is
+ /// currently connected to) as an Ldapv3 bind, using the specified name,
+ /// password, and constraints.
+ ///
+ /// <p>If the object has been disconnected from an Ldap server,
+ /// this method attempts to reconnect to the server. If the object
+ /// has already authenticated, the old authentication is discarded.</p>
+ ///
+ /// </summary>
+ /// <param name="dn"> If non-null and non-empty, specifies that the
+ /// connection and all operations through it should
+ /// be authenticated with dn as the distinguished
+ /// name.
+ /// <br><br>
+ /// </param>
+ /// <param name="passwd"> If non-null and non-empty, specifies that the
+ /// connection and all operations through it should
+ /// be authenticated with dn as the distinguished
+ /// name and passwd as password.
+ /// Note: the application should use care in the use
+ /// of String password objects. These are long lived
+ /// objects, and may expose a security risk, especially
+ /// in objects that are serialized. The LdapConnection
+ /// keeps no long lived instances of these objects.
+ /// <br><br>
+ /// </param>
+ /// <param name="cons"> Constraints specific to the operation.
+ ///
+ /// </param>
+ /// <exception cref=""> LdapException A general exception which includes an error
+ /// message and an Ldap error code.
+ ///
+ /// </exception>
+ /// <deprecated> replaced by {@link #bind(int, String, byte[], LdapConstraints)}
+ /// </deprecated>
+ public virtual void Bind(System.String dn, System.String passwd, LdapConstraints cons)
+ {
+ Bind(Ldap_V3, dn, passwd, cons);
+ return ;
+ }
+
+ /// <summary> Synchronously authenticates to the Ldap server (that the object is
+ /// currently connected to) using the specified name, password, Ldap version,
+ /// and constraints.
+ ///
+ /// <p>If the object has been disconnected from an Ldap server,
+ /// this method attempts to reconnect to the server. If the object
+ /// has already authenticated, the old authentication is discarded.</p>
+ ///
+ /// </summary>
+ /// <param name="version"> The Ldap protocol version, use Ldap_V3.
+ /// Ldap_V2 is not supported.
+ /// <br><br>
+ /// </param>
+ /// <param name="dn"> If non-null and non-empty, specifies that the
+ /// connection and all operations through it should
+ /// be authenticated with dn as the distinguished
+ /// name.
+ /// <br><br>
+ /// </param>
+ /// <param name="passwd"> If non-null and non-empty, specifies that the
+ /// connection and all operations through it should
+ /// be authenticated with dn as the distinguished
+ /// name and passwd as password.
+ /// <br><br>
+ /// Note: the application should use care in the use
+ /// of String password objects. These are long lived
+ /// objects, and may expose a security risk, especially
+ /// in objects that are serialized. The LdapConnection
+ /// keeps no long lived instances of these objects.
+ /// <br><br>
+ /// </param>
+ /// <param name="cons"> The constraints specific to the operation.
+ ///
+ /// </param>
+ /// <exception cref=""> LdapException A general exception which includes an error
+ /// message and an Ldap error code.
+ ///
+ /// </exception>
+ /// <deprecated> replaced by
+ /// {@link #bind(int, String, byte[], LdapConstraints)}
+ /// </deprecated>
+ public virtual void Bind(int version, System.String dn, System.String passwd, LdapConstraints cons)
+ {
+ sbyte[] pw = null;
+ if ((System.Object) passwd != null)
+ {
+ try
+ {
+ System.Text.Encoding encoder = System.Text.Encoding.GetEncoding("utf-8");
+ byte[] ibytes = encoder.GetBytes(passwd);
+ pw=SupportClass.ToSByteArray(ibytes);
+
+ // pw = passwd.getBytes("UTF8");
+ passwd = null; // Keep no reference to String object
+ }
+ catch (System.IO.IOException ex)
+ {
+ passwd = null; // Keep no reference to String object
+ throw new System.SystemException(ex.ToString());
+ }
+ }
+ Bind(version, dn, pw, cons);
+ return ;
+ }
+
+ /// <summary> Synchronously authenticates to the Ldap server (that the object is
+ /// currently connected to) using the specified name, password,
+ /// and Ldap version.
+ ///
+ /// <p>If the object has been disconnected from an Ldap server,
+ /// this method attempts to reconnect to the server. If the object
+ /// has already authenticated, the old authentication is discarded.</p>
+ ///
+ /// </summary>
+ /// <param name="version"> The version of the Ldap protocol to use
+ /// in the bind, use Ldap_V3. Ldap_V2 is not supported.
+ /// <br><br>
+ /// </param>
+ /// <param name="dn"> If non-null and non-empty, specifies that the
+ /// connection and all operations through it should
+ /// be authenticated with dn as the distinguished
+ /// name.
+ /// <br><br>
+ /// </param>
+ /// <param name="passwd"> If non-null and non-empty, specifies that the
+ /// connection and all operations through it should
+ /// be authenticated with dn as the distinguished
+ /// name and passwd as password.
+ ///
+ /// </param>
+ /// <exception cref=""> LdapException A general exception which includes an error
+ /// message and an Ldap error code.
+ /// </exception>
+ [CLSCompliantAttribute(false)]
+ public virtual void Bind(int version, System.String dn, sbyte[] passwd)
+ {
+ Bind(version, dn, passwd, defSearchCons);
+ return ;
+ }
+
+ /// <summary>
+ /// Synchronously authenticates to the Ldap server (that the object is
+ /// currently connected to) using the specified name, password, Ldap version,
+ /// and constraints.
+ ///
+ /// <p>If the object has been disconnected from an Ldap server,
+ /// this method attempts to reconnect to the server. If the object
+ /// has already authenticated, the old authentication is discarded.</p>
+ ///
+ /// </summary>
+ /// <param name="version"> The Ldap protocol version, use Ldap_V3.
+ /// Ldap_V2 is not supported.
+ /// <br><br>
+ /// </param>
+ /// <param name="dn"> If non-null and non-empty, specifies that the
+ /// connection and all operations through it should
+ /// be authenticated with dn as the distinguished
+ /// name.
+ /// <br><br>
+ /// </param>
+ /// <param name="passwd"> If non-null and non-empty, specifies that the
+ /// connection and all operations through it should
+ /// be authenticated with dn as the distinguished
+ /// name and passwd as password.
+ /// <br><br>
+ /// </param>
+ /// <param name="cons"> The constraints specific to the operation.
+ ///
+ /// </param>
+ /// <exception cref=""> LdapException A general exception which includes an error
+ /// message and an Ldap error code.
+ /// </exception>
+ [CLSCompliantAttribute(false)]
+ public virtual void Bind(int version, System.String dn, sbyte[] passwd, LdapConstraints cons)
+ {
+ LdapResponseQueue queue = Bind(version, dn, passwd, null, cons);
+ LdapResponse res = (LdapResponse) queue.getResponse();
+ if (res != null)
+ {
+ // Set local copy of responseControls synchronously if any
+ lock (responseCtlSemaphore)
+ {
+ responseCtls = res.Controls;
+ }
+
+ chkResultCode(queue, cons, res);
+ }
+ return ;
+ }
+
+ /// <summary> Asynchronously authenticates to the Ldap server (that the object is
+ /// currently connected to) using the specified name, password, Ldap
+ /// version, and queue.
+ ///
+ /// <p>If the object has been disconnected from an Ldap server,
+ /// this method attempts to reconnect to the server. If the object
+ /// has already authenticated, the old authentication is discarded.</p>
+ ///
+ ///
+ /// </summary>
+ /// <param name="version"> The Ldap protocol version, use Ldap_V3.
+ /// Ldap_V2 is not supported.
+ /// <br><br>
+ /// </param>
+ /// <param name="dn"> If non-null and non-empty, specifies that the
+ /// connection and all operations through it should
+ /// be authenticated with dn as the distinguished
+ /// name.
+ /// <br><br>
+ /// </param>
+ /// <param name="passwd"> If non-null and non-empty, specifies that the
+ /// connection and all operations through it should
+ /// be authenticated with dn as the distinguished
+ /// name and passwd as password.
+ /// <br><br>
+ /// </param>
+ /// <param name="queue"> Handler for messages returned from a server in
+ /// response to this request. If it is null, a
+ /// queue object is created internally.
+ ///
+ /// </param>
+ /// <exception cref=""> LdapException A general exception which includes an error
+ /// message and an Ldap error code.
+ /// </exception>
+ [CLSCompliantAttribute(false)]
+ public virtual LdapResponseQueue Bind(int version, System.String dn, sbyte[] passwd, LdapResponseQueue queue)
+ {
+ return Bind(version, dn, passwd, queue, defSearchCons);
+ }
+
+ /// <summary> Asynchronously authenticates to the Ldap server (that the object is
+ /// currently connected to) using the specified name, password, Ldap
+ /// version, queue, and constraints.
+ ///
+ /// <p>If the object has been disconnected from an Ldap server,
+ /// this method attempts to reconnect to the server. If the object
+ /// had already authenticated, the old authentication is discarded.</p>
+ ///
+ /// </summary>
+ /// <param name="version"> The Ldap protocol version, use Ldap_V3.
+ /// Ldap_V2 is not supported.
+ /// <br><br>
+ /// </param>
+ /// <param name="dn"> If non-null and non-empty, specifies that the
+ /// connection and all operations through it should
+ /// be authenticated with dn as the distinguished
+ /// name.
+ /// <br><br>
+ /// </param>
+ /// <param name="passwd"> If non-null and non-empty, specifies that the
+ /// connection and all operations through it should
+ /// be authenticated with dn as the distinguished
+ /// name and passwd as password.
+ /// <br><br>
+ /// </param>
+ /// <param name="queue"> Handler for messages returned from a server in
+ /// response to this request. If it is null, a
+ /// queue object is created internally.
+ /// <br><br>
+ /// </param>
+ /// <param name="cons"> Constraints specific to the operation.
+ ///
+ /// </param>
+ /// <exception cref=""> LdapException A general exception which includes an error
+ /// message and an Ldap error code.
+ /// </exception>
+ [CLSCompliantAttribute(false)]
+ public virtual LdapResponseQueue Bind(int version, System.String dn, sbyte[] passwd, LdapResponseQueue queue, LdapConstraints cons)
+ {
+ int msgId;
+ BindProperties bindProps;
+ if (cons == null)
+ cons = defSearchCons;
+
+ if ((System.Object) dn == null)
+ {
+ dn = "";
+ }
+ else
+ {
+ dn = dn.Trim();
+ }
+
+ if (passwd == null)
+ passwd = new sbyte[]{};
+
+ bool anonymous = false;
+ if (passwd.Length == 0)
+ {
+ anonymous = true; // anonymous, passwd length zero with simple bind
+ dn = ""; // set to null if anonymous
+ }
+
+ LdapMessage msg = new LdapBindRequest(version, dn, passwd, cons.getControls());
+
+ msgId = msg.MessageID;
+ bindProps = new BindProperties(version, dn, "simple", anonymous, null, null);
+
+ // For bind requests, if not connected, attempt to reconnect
+ if (!conn.Connected)
+ {
+ if ((System.Object) conn.Host != null)
+ {
+ conn.connect(conn.Host, conn.Port);
+ }
+ else
+ {
+ throw new LdapException(ExceptionMessages.CONNECTION_IMPOSSIBLE, LdapException.CONNECT_ERROR, null);
+ }
+ }
+
+ // The semaphore is released when the bind response is queued.
+ conn.acquireWriteSemaphore(msgId);
+
+ return SendRequestToServer(msg, cons.TimeLimit, queue, bindProps);
+ }
+
+ //*************************************************************************
+ // compare methods
+ //*************************************************************************
+
+ /// <summary>
+ /// Synchronously checks to see if an entry contains an attribute
+ /// with a specified value.
+ ///
+ /// </summary>
+ /// <param name="dn"> The distinguished name of the entry to use in the
+ /// comparison.
+ /// <br><br>
+ /// </param>
+ /// <param name="attr"> The attribute to compare against the entry. The
+ /// method checks to see if the entry has an
+ /// attribute with the same name and value as this
+ /// attribute.
+ ///
+ /// </param>
+ /// <returns> True if the entry has the value,
+ /// and false if the entry does not
+ /// have the value or the attribute.
+ ///
+ /// </returns>
+ /// <exception cref=""> LdapException A general exception which includes an error
+ /// message and an Ldap error code.
+ /// </exception>
+ public virtual bool Compare(System.String dn, LdapAttribute attr)
+ {
+ return Compare(dn, attr, defSearchCons);
+ }
+
+ /// <summary>
+ /// Synchronously checks to see if an entry contains an attribute with a
+ /// specified value, using the specified constraints.
+ ///
+ /// </summary>
+ /// <param name="dn"> The distinguished name of the entry to use in the
+ /// comparison.
+ /// <br><br>
+ /// </param>
+ /// <param name="attr"> The attribute to compare against the entry. The
+ /// method checks to see if the entry has an
+ /// attribute with the same name and value as this
+ /// attribute.
+ /// <br><br>
+ /// </param>
+ /// <param name="cons"> Constraints specific to the operation.
+ ///
+ /// </param>
+ /// <returns> True if the entry has the value,
+ /// and false if the entry does not
+ /// have the value or the attribute.
+ ///
+ /// </returns>
+ /// <exception cref=""> LdapException A general exception which includes an error
+ /// message and an Ldap error code.
+ /// </exception>
+ public virtual bool Compare(System.String dn, LdapAttribute attr, LdapConstraints cons)
+ {
+ bool ret = false;
+
+ LdapResponseQueue queue = Compare(dn, attr, null, cons);
+
+ LdapResponse res = (LdapResponse) queue.getResponse();
+
+ // Set local copy of responseControls synchronously - if there were any
+ lock (responseCtlSemaphore)
+ {
+ responseCtls = res.Controls;
+ }
+
+ if (res.ResultCode == LdapException.COMPARE_TRUE)
+ {
+ ret = true;
+ }
+ else if (res.ResultCode == LdapException.COMPARE_FALSE)
+ {
+ ret = false;
+ }
+ else
+ {
+ chkResultCode(queue, cons, res);
+ }
+ return ret;
+ }
+
+ /// <summary> Asynchronously compares an attribute value with one in the directory,
+ /// using the specified queue.
+ /// <p>
+ /// Please note that a successful completion of this command results in
+ /// one of two status codes: LdapException.COMPARE_TRUE if the entry
+ /// has the value, and LdapException.COMPARE_FALSE if the entry
+ /// does not have the value or the attribute.
+ /// <br><br>
+ /// </summary>
+ /// <param name="dn"> The distinguished name of the entry containing an
+ /// attribute to compare.
+ /// <br><br>
+ /// </param>
+ /// <param name="attr"> An attribute to compare.
+ /// <br><br>
+ /// </param>
+ /// <param name="queue"> The queue for messages returned from a server in
+ /// response to this request. If it is null, a
+ /// queue object is created internally.
+ ///
+ /// </param>
+ /// <exception cref=""> LdapException A general exception which includes an error
+ /// message and an Ldap error code.
+ ///
+ /// </exception>
+ /// <seealso cref="LdapException#COMPARE_TRUE">
+ /// </seealso>
+ /// <seealso cref="LdapException#COMPARE_FALSE">
+ /// </seealso>
+ public virtual LdapResponseQueue Compare(System.String dn, LdapAttribute attr, LdapResponseQueue queue)
+ {
+ return Compare(dn, attr, queue, defSearchCons);
+ }
+
+ /// <summary> Asynchronously compares an attribute value with one in the directory,
+ /// using the specified queue and contraints.
+ /// <p>
+ /// Please note that a successful completion of this command results in
+ /// one of two status codes: LdapException.COMPARE_TRUE if the entry
+ /// has the value, and LdapException.COMPARE_FALSE if the entry
+ /// does not have the value or the attribute.
+ /// <br><br>
+ /// </summary>
+ /// <param name="dn"> The distinguished name of the entry containing an
+ /// attribute to compare.
+ /// <br><br>
+ /// </param>
+ /// <param name="attr"> An attribute to compare.
+ /// <br><br>
+ /// </param>
+ /// <param name="queue"> Handler for messages returned from a server in
+ /// response to this request. If it is null, a
+ /// queue object is created internally.
+ /// <br><br>
+ /// </param>
+ /// <param name="cons"> Constraints specific to the operation.
+ ///
+ /// </param>
+ /// <exception cref=""> LdapException A general exception which includes an error
+ /// message and an Ldap error code.
+ ///
+ /// </exception>
+ /// <seealso cref="LdapException#COMPARE_TRUE">
+ /// </seealso>
+ /// <seealso cref="LdapException#COMPARE_FALSE">
+ /// </seealso>
+ public virtual LdapResponseQueue Compare(System.String dn, LdapAttribute attr, LdapResponseQueue queue, LdapConstraints cons)
+ {
+ if (attr.size() != 1)
+ {
+ throw new System.ArgumentException("compare: Exactly one value " + "must be present in the LdapAttribute");
+ }
+
+ if ((System.Object) dn == null)
+ {
+ // Invalid parameter
+ throw new System.ArgumentException("compare: DN cannot be null");
+ }
+
+ if (cons == null)
+ cons = defSearchCons;
+
+ LdapMessage msg = new LdapCompareRequest(dn, attr.Name, attr.ByteValue, cons.getControls());
+
+ return SendRequestToServer(msg, cons.TimeLimit, queue, null);
+ }
+
+ //*************************************************************************
+ // connect methods
+ //*************************************************************************
+
+ /// <summary>
+ /// Connects to the specified host and port.
+ ///
+ /// <p>If this LdapConnection object represents an open connection, the
+ /// connection is closed first before the new connection is opened.
+ /// At this point, there is no authentication, and any operations are
+ /// conducted as an anonymous client.</p>
+ ///
+ /// <p> When more than one host name is specified, each host is contacted
+ /// in turn until a connection can be established.</p>
+ ///
+ /// </summary>
+ /// <param name="host">A host name or a dotted string representing the IP address
+ /// of a host running an Ldap server. It may also
+ /// contain a list of host names, space-delimited. Each host
+ /// name can include a trailing colon and port number.
+ /// <br><br>
+ /// </param>
+ /// <param name="port">The TCP or UDP port number to connect to or contact.
+ /// The default Ldap port is 389. The port parameter is
+ /// ignored for any host hame which includes a colon and
+ /// port number.
+ /// <br><br>
+ /// </param>
+ /// <exception cref=""> LdapException A general exception which includes an error
+ /// message and an Ldap error code.
+ ///
+ /// </exception>
+ public virtual void Connect(System.String host, int port)
+ {
+ // connect doesn't affect other clones
+ // If not a clone, destroys old connection.
+ // Step through the space-delimited list
+ SupportClass.Tokenizer hostList = new SupportClass.Tokenizer(host, " ");
+ System.String address = null;
+
+ int specifiedPort;
+ int colonIndex; //after the colon is the port
+ while (hostList.HasMoreTokens())
+ {
+ try
+ {
+ specifiedPort = port;
+ address = hostList.NextToken();
+ colonIndex = address.IndexOf((System.Char) ':');
+ if (colonIndex != - 1 && colonIndex + 1 != address.Length)
+ {
+ //parse Port out of address
+ try
+ {
+ specifiedPort = System.Int32.Parse(address.Substring(colonIndex + 1));
+ address = address.Substring(0, (colonIndex) - (0));
+ }
+ catch (System.Exception e)
+ {
+ throw new System.ArgumentException(ExceptionMessages.INVALID_ADDRESS);
+ }
+ }
+ // This may return a different conn object
+ // Disassociate this clone with the underlying connection.
+ conn = conn.destroyClone(true);
+ conn.connect(address, specifiedPort);
+ break;
+ }
+ catch (LdapException LE)
+ {
+ if (!hostList.HasMoreTokens())
+ throw LE;
+ }
+ }
+ return ;
+ }
+
+ //*************************************************************************
+ // delete methods
+ //*************************************************************************
+
+ /// <summary>
+ /// Synchronously deletes the entry with the specified distinguished name
+ /// from the directory.
+ ///
+ /// <p>Note: A Delete operation will not remove an entry that contains
+ /// subordinate entries, nor will it dereference alias entries. </p>
+ ///
+ /// </summary>
+ /// <param name="dn"> The distinguished name of the entry to delete.
+ ///
+ /// </param>
+ /// <exception cref=""> LdapException A general exception which includes an error
+ /// message and an Ldap error code.
+ /// </exception>
+ public virtual void Delete(System.String dn)
+ {
+ Delete(dn, defSearchCons);
+ return ;
+ }
+
+
+ /// <summary> Synchronously deletes the entry with the specified distinguished name
+ /// from the directory, using the specified constraints.
+ ///
+ /// <p>Note: A Delete operation will not remove an entry that contains
+ /// subordinate entries, nor will it dereference alias entries. </p>
+ ///
+ /// </summary>
+ /// <param name="dn"> The distinguished name of the entry to delete.
+ /// <br><br>
+ /// </param>
+ /// <param name="cons"> Constraints specific to the operation.
+ ///
+ /// </param>
+ /// <exception cref=""> LdapException A general exception which includes an error
+ /// message and an Ldap error code.
+ /// </exception>
+ public virtual void Delete(System.String dn, LdapConstraints cons)
+ {
+ LdapResponseQueue queue = Delete(dn, null, cons);
+
+ // Get a handle to the delete response
+ LdapResponse deleteResponse = (LdapResponse) (queue.getResponse());
+
+ // Set local copy of responseControls synchronously - if there were any
+ lock (responseCtlSemaphore)
+ {
+ responseCtls = deleteResponse.Controls;
+ }
+ chkResultCode(queue, cons, deleteResponse);
+ return ;
+ }
+
+ /// <summary> Asynchronously deletes the entry with the specified distinguished name
+ /// from the directory and returns the results to the specified queue.
+ ///
+ /// <p>Note: A Delete operation will not remove an entry that contains
+ /// subordinate entries, nor will it dereference alias entries. </p>
+ ///
+ /// </summary>
+ /// <param name="dn"> The distinguished name of the entry to modify.
+ /// <br><br>
+ /// </param>
+ /// <param name="queue"> The queue for messages returned from a server in
+ /// response to this request. If it is null, a
+ /// queue object is created internally.
+ ///
+ /// </param>
+ /// <exception cref=""> LdapException A general exception which includes an error
+ /// message and an Ldap error code.
+ ///
+ /// </exception>
+ public virtual LdapResponseQueue Delete(System.String dn, LdapResponseQueue queue)
+ {
+ return Delete(dn, queue, defSearchCons);
+ }
+
+ /// <summary> Asynchronously deletes the entry with the specified distinguished name
+ /// from the directory, using the specified contraints and queue.
+ ///
+ /// <p>Note: A Delete operation will not remove an entry that contains
+ /// subordinate entries, nor will it dereference alias entries. </p>
+ ///
+ /// </summary>
+ /// <param name="dn"> The distinguished name of the entry to delete.
+ /// <br><br>
+ /// </param>
+ /// <param name="queue"> The queue for messages returned from a server in
+ /// response to this request. If it is null, a
+ /// queue object is created internally.
+ /// <br><br>
+ /// </param>
+ /// <param name="cons"> The constraints specific to the operation.
+ ///
+ /// </param>
+ /// <exception cref=""> LdapException A general exception which includes an error
+ /// message and an Ldap error code.
+ ///
+ /// </exception>
+ public virtual LdapResponseQueue Delete(System.String dn, LdapResponseQueue queue, LdapConstraints cons)
+ {
+ if ((System.Object) dn == null)
+ {
+ // Invalid DN parameter
+ throw new System.ArgumentException(ExceptionMessages.DN_PARAM_ERROR);
+ }
+
+ if (cons == null)
+ cons = defSearchCons;
+
+ LdapMessage msg = new LdapDeleteRequest(dn, cons.getControls());
+
+ return SendRequestToServer(msg, cons.TimeLimit, queue, null);
+ }
+
+ //*************************************************************************
+ // disconnect method
+ //*************************************************************************
+
+ /// <summary>
+ /// Synchronously disconnects from the Ldap server.
+ ///
+ /// <p>Before the object can perform Ldap operations again, it must
+ /// reconnect to the server by calling connect.</p>
+ ///
+ /// <p>The disconnect method abandons any outstanding requests, issues an
+ /// unbind request to the server, and then closes the socket.</p>
+ ///
+ /// </summary>
+ /// <exception cref=""> LdapException A general exception which includes an error
+ /// message and an Ldap error code.
+ ///
+ /// </exception>
+ public virtual void Disconnect()
+ {
+ // disconnect from API call
+ Disconnect(defSearchCons, true);
+ return ;
+ }
+
+ /// <summary> Synchronously disconnects from the Ldap server.
+ ///
+ /// <p>Before the object can perform Ldap operations again, it must
+ /// reconnect to the server by calling connect.</p>
+ ///
+ /// <p>The disconnect method abandons any outstanding requests, issues an
+ /// unbind request to the server, and then closes the socket.</p>
+ ///
+ /// </summary>
+ /// <param name="cons">LDPConstraints to be set with the unbind request
+ ///
+ /// </param>
+ /// <exception cref=""> LdapException A general exception which includes an error
+ /// message and an Ldap error code.
+ /// </exception>
+ public virtual void Disconnect(LdapConstraints cons)
+ {
+ // disconnect from API call
+ Disconnect(cons, true);
+ return ;
+ }
+
+ /// <summary> Synchronously disconnect from the server
+ ///
+ /// </summary>
+ /// <param name="how">true if application call disconnect API, false if finalize.
+ /// </param>
+ private void Disconnect(LdapConstraints cons, bool how)
+ {
+ // disconnect doesn't affect other clones
+ // If not a clone, distroys connection
+ conn = conn.destroyClone(how);
+ return ;
+ }
+
+ //*************************************************************************
+ // extendedOperation methods
+ //*************************************************************************
+
+ /// <summary> Provides a synchronous means to access extended, non-mandatory
+ /// operations offered by a particular Ldapv3 compliant server.
+ ///
+ /// </summary>
+ /// <param name="op"> The object which contains (1) an identifier of an extended
+ /// operation which should be recognized by the particular Ldap
+ /// server this client is connected to and (2)
+ /// an operation-specific sequence of octet strings
+ /// or BER-encoded values.
+ ///
+ /// </param>
+ /// <returns> An operation-specific object, containing an ID and either an octet
+ /// string or BER-encoded values.
+ ///
+ /// </returns>
+ /// <exception cref=""> LdapException A general exception which includes an error
+ /// message and an Ldap error code.
+ /// </exception>
+ public virtual LdapExtendedResponse ExtendedOperation(LdapExtendedOperation op)
+ {
+ return ExtendedOperation(op, defSearchCons);
+ }
+
+ /*
+ * Synchronous Ldap extended request with SearchConstraints
+ */
+
+ /// <summary>
+ /// Provides a synchronous means to access extended, non-mandatory
+ /// operations offered by a particular Ldapv3 compliant server.
+ ///
+ /// </summary>
+ /// <param name="op"> The object which contains (1) an identifier of an extended
+ /// operation which should be recognized by the particular Ldap
+ /// server this client is connected to and (2) an
+ /// operation-specific sequence of octet strings
+ /// or BER-encoded values.
+ /// <br><br>
+ /// </param>
+ /// <param name="cons">The constraints specific to the operation.
+ ///
+ /// </param>
+ /// <returns> An operation-specific object, containing an ID and either an
+ /// octet string or BER-encoded values.
+ ///
+ /// </returns>
+ /// <exception cref=""> LdapException A general exception which includes an error
+ /// message and an Ldap error code.
+ /// </exception>
+
+ public virtual LdapExtendedResponse ExtendedOperation(LdapExtendedOperation op, LdapConstraints cons)
+ {
+
+ // Call asynchronous API and get back handler to reponse queue
+ LdapResponseQueue queue = ExtendedOperation(op, cons, null);
+ LdapExtendedResponse response = (LdapExtendedResponse) queue.getResponse();
+
+ // Set local copy of responseControls synchronously - if there were any
+ lock (responseCtlSemaphore)
+ {
+ responseCtls = response.Controls;
+ }
+
+ chkResultCode(queue, cons, response);
+ return response;
+ }
+
+
+ /*
+ * Asynchronous Ldap extended request
+ */
+
+ /// <summary> Provides an asynchronous means to access extended, non-mandatory
+ /// operations offered by a particular Ldapv3 compliant server.
+ ///
+ /// </summary>
+ /// <param name="op"> The object which contains (1) an identifier of an extended
+ /// operation which should be recognized by the particular Ldap
+ /// server this client is connected to and (2) an
+ /// operation-specific sequence of octet strings
+ /// or BER-encoded values.
+ /// <br><br>
+ /// </param>
+ /// <param name="queue"> The queue for messages returned from a server in
+ /// response to this request. If it is null, a queue
+ /// object is created internally.
+ ///
+ /// </param>
+ /// <returns> An operation-specific object, containing an ID and either an octet
+ /// string or BER-encoded values.
+ ///
+ /// </returns>
+ /// <exception cref=""> LdapException A general exception which includes an error
+ /// message and an Ldap error code.
+ /// </exception>
+
+ public virtual LdapResponseQueue ExtendedOperation(LdapExtendedOperation op, LdapResponseQueue queue)
+ {
+
+ return ExtendedOperation(op, defSearchCons, queue);
+ }
+
+
+ /*
+ * Asynchronous Ldap extended request with SearchConstraints
+ */
+
+ /// <summary> Provides an asynchronous means to access extended, non-mandatory
+ /// operations offered by a particular Ldapv3 compliant server.
+ ///
+ /// </summary>
+ /// <param name="op"> The object which contains (1) an identifier of an extended
+ /// operation which should be recognized by the particular Ldap
+ /// server this client is connected to and (2) an operation-
+ /// specific sequence of octet strings or BER-encoded values.
+ /// <br><br>
+ /// </param>
+ /// <param name="queue"> The queue for messages returned from a server in
+ /// response to this request. If it is null, a queue
+ /// object is created internally.
+ /// <br><br>
+ /// </param>
+ /// <param name="cons"> The constraints specific to this operation.
+ ///
+ /// </param>
+ /// <returns> An operation-specific object, containing an ID and either an
+ /// octet string or BER-encoded values.
+ ///
+ /// </returns>
+ /// <exception cref=""> LdapException A general exception which includes an error
+ /// message and an Ldap error code.
+ /// </exception>
+
+ public virtual LdapResponseQueue ExtendedOperation(LdapExtendedOperation op, LdapConstraints cons, LdapResponseQueue queue)
+ {
+ // Use default constraints if none-specified
+ if (cons == null)
+ cons = defSearchCons;
+ LdapMessage msg = MakeExtendedOperation(op, cons);
+ return SendRequestToServer(msg, cons.TimeLimit, queue, null);
+ }
+
+ /// <summary> Formulates the extended operation, constraints into an
+ /// LdapMessage and returns the LdapMessage. This is used by
+ /// extendedOperation and startTLS which needs the LdapMessage to
+ /// get the MessageID.
+ /// </summary>
+ protected internal virtual LdapMessage MakeExtendedOperation(LdapExtendedOperation op, LdapConstraints cons)
+ {
+ // Use default constraints if none-specified
+ if (cons == null)
+ cons = defSearchCons;
+
+ // error check the parameters
+ if ((System.Object) op.getID() == null)
+ {
+ // Invalid extended operation parameter, no OID specified
+ throw new System.ArgumentException(ExceptionMessages.OP_PARAM_ERROR);
+ }
+
+ return new LdapExtendedRequest(op, cons.getControls());
+ }
+
+ //*************************************************************************
+ // getResponseControls method
+ //*************************************************************************
+
+ //*************************************************************************
+ // modify methods
+ //*************************************************************************
+
+ /// <summary> Synchronously makes a single change to an existing entry in the
+ /// directory.
+ ///
+ /// <p>For example, this modify method changes the value of an attribute,
+ /// adds a new attribute value, or removes an existing attribute value. </p>
+ ///
+ /// <p>The LdapModification object specifies both the change to be made and
+ /// the LdapAttribute value to be changed.</p>
+ ///
+ /// <p>If the request fails with {@link LdapException#CONNECT_ERROR},
+ /// it is indeterminate whether or not the server made the modification.</p>
+ ///
+ /// </summary>
+ /// <param name="dn"> The distinguished name of the entry to modify.
+ /// <br><br>
+ /// </param>
+ /// <param name="mod"> A single change to be made to the entry.
+ ///
+ /// </param>
+ /// <exception cref=""> LdapException A general exception which includes an error
+ /// message and an Ldap error code.
+ /// </exception>
+ public virtual void Modify(System.String dn, LdapModification mod)
+ {
+ Modify(dn, mod, defSearchCons);
+ return ;
+ }
+
+ /// <summary>
+ /// Synchronously makes a single change to an existing entry in the
+ /// directory, using the specified constraints.
+ ///
+ /// <p>For example, this modify method changes the value of an attribute,
+ /// adds a new attribute value, or removes an existing attribute value.</p>
+ ///
+ /// <p>The LdapModification object specifies both the change to be
+ /// made and the LdapAttribute value to be changed.</p>
+ ///
+ /// <p>If the request fails with {@link LdapException#CONNECT_ERROR},
+ /// it is indeterminate whether or not the server made the modification.</p>
+ ///
+ /// </summary>
+ /// <param name="dn"> The distinguished name of the entry to modify.
+ /// <br><br>
+ /// </param>
+ /// <param name="mod"> A single change to be made to the entry.
+ /// <br><br>
+ /// </param>
+ /// <param name="cons"> The constraints specific to the operation.
+ ///
+ /// </param>
+ /// <exception cref=""> LdapException A general exception which includes an error
+ /// message and an Ldap error code.
+ /// </exception>
+ public virtual void Modify(System.String dn, LdapModification mod, LdapConstraints cons)
+ {
+ LdapModification[] mods = new LdapModification[1];
+ mods[0] = mod;
+ Modify(dn, mods, cons);
+ return ;
+ }
+
+ /// <summary>
+ /// Synchronously makes a set of changes to an existing entry in the
+ /// directory.
+ ///
+ /// <p>For example, this modify method changes attribute values, adds
+ /// new attribute values, or removes existing attribute values.</p>
+ ///
+ /// <p>Because the server applies all changes in an LdapModification array
+ /// atomically, the application can expect that no changes
+ /// have been performed if an error is returned.
+ /// If the request fails with {@link LdapException#CONNECT_ERROR},
+ /// it is indeterminate whether or not the server made the modifications.</p>
+ ///
+ /// </summary>
+ /// <param name="dn"> Distinguished name of the entry to modify.
+ /// <br><br>
+ /// </param>
+ /// <param name="mods"> The changes to be made to the entry.
+ ///
+ /// </param>
+ /// <exception cref=""> LdapException A general exception which includes an error
+ /// message and an Ldap error code.
+ /// </exception>
+ public virtual void Modify(System.String dn, LdapModification[] mods)
+ {
+ Modify(dn, mods, defSearchCons);
+ return ;
+ }
+
+ /// <summary> Synchronously makes a set of changes to an existing entry in the
+ /// directory, using the specified constraints.
+ ///
+ /// <p>For example, this modify method changes attribute values, adds new
+ /// attribute values, or removes existing attribute values.</p>
+ ///
+ /// <p>Because the server applies all changes in an LdapModification array
+ /// atomically, the application can expect that no changes
+ /// have been performed if an error is returned.
+ /// If the request fails with {@link LdapException#CONNECT_ERROR},
+ /// it is indeterminate whether or not the server made the modifications.</p>
+ ///
+ /// </summary>
+ /// <param name="dn"> The distinguished name of the entry to modify.
+ /// <br><br>
+ /// </param>
+ /// <param name="mods"> The changes to be made to the entry.
+ /// <br><br>
+ /// </param>
+ /// <param name="cons"> The constraints specific to the operation.
+ ///
+ /// </param>
+ /// <exception cref=""> LdapException A general exception which includes an
+ /// error message and an Ldap error code.
+ /// </exception>
+ public virtual void Modify(System.String dn, LdapModification[] mods, LdapConstraints cons)
+ {
+ LdapResponseQueue queue = Modify(dn, mods, null, cons);
+
+ // Get a handle to the modify response
+ LdapResponse modifyResponse = (LdapResponse) (queue.getResponse());
+
+ // Set local copy of responseControls synchronously - if there were any
+ lock (responseCtlSemaphore)
+ {
+ responseCtls = modifyResponse.Controls;
+ }
+
+ chkResultCode(queue, cons, modifyResponse);
+
+ return ;
+ }
+
+ /// <summary> Asynchronously makes a single change to an existing entry in the
+ /// directory.
+ ///
+ /// <p>For example, this modify method can change the value of an attribute,
+ /// add a new attribute value, or remove an existing attribute value.</p>
+ ///
+ /// <p>The LdapModification object specifies both the change to be made and
+ /// the LdapAttribute value to be changed.</p>
+ ///
+ /// <p>If the request fails with {@link LdapException#CONNECT_ERROR},
+ /// it is indeterminate whether or not the server made the modification.</p>
+ ///
+ /// </summary>
+ /// <param name="dn"> Distinguished name of the entry to modify.
+ /// <br><br>
+ /// </param>
+ /// <param name="mod"> A single change to be made to the entry.
+ /// <br><br>
+ /// </param>
+ /// <param name="queue"> Handler for messages returned from a server in
+ /// response to this request. If it is null, a
+ /// queue object is created internally.
+ ///
+ /// </param>
+ /// <exception cref=""> LdapException A general exception which includes an error
+ /// message and an Ldap error code.
+ /// </exception>
+ public virtual LdapResponseQueue Modify(System.String dn, LdapModification mod, LdapResponseQueue queue)
+ {
+ return Modify(dn, mod, queue, defSearchCons);
+ }
+
+ /// <summary> Asynchronously makes a single change to an existing entry in the
+ /// directory, using the specified constraints and queue.
+ ///
+ /// <p>For example, this modify method can change the value of an attribute,
+ /// add a new attribute value, or remove an existing attribute value.</p>
+ ///
+ /// <p>The LdapModification object specifies both the change to be made
+ /// and the LdapAttribute value to be changed.</p>
+ ///
+ /// <p>If the request fails with {@link LdapException#CONNECT_ERROR},
+ /// it is indeterminate whether or not the server made the modification.</p>
+ ///
+ /// </summary>
+ /// <param name="dn"> Distinguished name of the entry to modify.
+ /// <br><br>
+ /// </param>
+ /// <param name="mod"> A single change to be made to the entry.
+ /// <br><br>
+ /// </param>
+ /// <param name="queue"> Handler for messages returned from a server in
+ /// response to this request. If it is null, a
+ /// queue object is created internally.
+ /// <br><br>
+ /// </param>
+ /// <param name="cons"> Constraints specific to the operation.
+ ///
+ /// </param>
+ /// <exception cref=""> LdapException A general exception which includes an error
+ /// message and an Ldap error code.
+ /// </exception>
+ public virtual LdapResponseQueue Modify(System.String dn, LdapModification mod, LdapResponseQueue queue, LdapConstraints cons)
+ {
+ LdapModification[] mods = new LdapModification[1];
+ mods[0] = mod;
+ return Modify(dn, mods, queue, cons);
+ }
+
+ /// <summary> Asynchronously makes a set of changes to an existing entry in the
+ /// directory.
+ ///
+ /// <p>For example, this modify method can change attribute values, add new
+ /// attribute values, or remove existing attribute values.</p>
+ ///
+ /// <p>Because the server applies all changes in an LdapModification array
+ /// atomically, the application can expect that no changes
+ /// have been performed if an error is returned.
+ /// If the request fails with {@link LdapException#CONNECT_ERROR},
+ /// it is indeterminate whether or not the server made the modifications.</p>
+ ///
+ /// </summary>
+ /// <param name="dn"> The distinguished name of the entry to modify.
+ /// <br><br>
+ /// </param>
+ /// <param name="mods"> The changes to be made to the entry.
+ /// <br><br>
+ /// </param>
+ /// <param name="queue"> The queue for messages returned from a server in
+ /// response to this request. If it is null, a
+ /// queue object is created internally.
+ ///
+ /// </param>
+ /// <exception cref=""> LdapException A general exception which includes an error
+ /// message and an Ldap error code.
+ /// </exception>
+ public virtual LdapResponseQueue Modify(System.String dn, LdapModification[] mods, LdapResponseQueue queue)
+ {
+ return Modify(dn, mods, queue, defSearchCons);
+ }
+
+ /// <summary> Asynchronously makes a set of changes to an existing entry in the
+ /// directory, using the specified constraints and queue.
+ ///
+ /// <p>For example, this modify method can change attribute values, add new
+ /// attribute values, or remove existing attribute values.</p>
+ ///
+ /// <p>Because the server applies all changes in an LdapModification array
+ /// atomically, the application can expect that no changes
+ /// have been performed if an error is returned.
+ /// If the request fails with {@link LdapException#CONNECT_ERROR},
+ /// it is indeterminate whether or not the server made the modifications.</p>
+ ///
+ /// </summary>
+ /// <param name="dn"> The distinguished name of the entry to modify.
+ /// <br><br>
+ /// </param>
+ /// <param name="mods"> The changes to be made to the entry.
+ /// <br><br>
+ /// </param>
+ /// <param name="queue"> The queue for messages returned from a server in
+ /// response to this request. If it is null, a
+ /// queue object is created internally.
+ /// <br><br>
+ /// </param>
+ /// <param name="cons"> Constraints specific to the operation.
+ ///
+ /// </param>
+ /// <exception cref=""> LdapException A general exception which includes an error
+ /// message and an Ldap error code.
+ /// </exception>
+ public virtual LdapResponseQueue Modify(System.String dn, LdapModification[] mods, LdapResponseQueue queue, LdapConstraints cons)
+ {
+ if ((System.Object) dn == null)
+ {
+ // Invalid DN parameter
+ throw new System.ArgumentException(ExceptionMessages.DN_PARAM_ERROR);
+ }
+
+ if (cons == null)
+ cons = defSearchCons;
+
+ LdapMessage msg = new LdapModifyRequest(dn, mods, cons.getControls());
+
+ return SendRequestToServer(msg, cons.TimeLimit, queue, null);
+ }
+
+ //*************************************************************************
+ // read methods
+ //*************************************************************************
+
+ /// <summary> Synchronously reads the entry for the specified distiguished name (DN)
+ /// and retrieves all attributes for the entry.
+ ///
+ /// </summary>
+ /// <param name="dn"> The distinguished name of the entry to retrieve.
+ ///
+ /// </param>
+ /// <returns> the LdapEntry read from the server.
+ ///
+ /// </returns>
+ /// <exception cref=""> LdapException if the object was not found
+ /// </exception>
+ public virtual LdapEntry Read(System.String dn)
+ {
+ return Read(dn, defSearchCons);
+ }
+
+
+ /// <summary>
+ /// Synchronously reads the entry for the specified distiguished name (DN),
+ /// using the specified constraints, and retrieves all attributes for the
+ /// entry.
+ ///
+ /// </summary>
+ /// <param name="dn"> The distinguished name of the entry to retrieve.
+ /// <br><br>
+ /// </param>
+ /// <param name="cons"> The constraints specific to the operation.
+ ///
+ /// </param>
+ /// <returns> the LdapEntry read from the server
+ ///
+ /// </returns>
+ /// <exception cref=""> LdapException if the object was not found
+ /// </exception>
+ public virtual LdapEntry Read(System.String dn, LdapSearchConstraints cons)
+ {
+ return Read(dn, null, cons);
+ }
+
+ /// <summary>
+ /// Synchronously reads the entry for the specified distinguished name (DN)
+ /// and retrieves only the specified attributes from the entry.
+ ///
+ /// </summary>
+ /// <param name="dn"> The distinguished name of the entry to retrieve.
+ /// <br><br>
+ /// </param>
+ /// <param name="attrs"> The names of the attributes to retrieve.
+ ///
+ /// </param>
+ /// <returns> the LdapEntry read from the server
+ ///
+ /// </returns>
+ /// <exception cref=""> LdapException if the object was not found
+ /// </exception>
+ public virtual LdapEntry Read(System.String dn, System.String[] attrs)
+ {
+ return Read(dn, attrs, defSearchCons);
+ }
+
+ /// <summary> Synchronously reads the entry for the specified distinguished name (DN),
+ /// using the specified constraints, and retrieves only the specified
+ /// attributes from the entry.
+ ///
+ /// </summary>
+ /// <param name="dn"> The distinguished name of the entry to retrieve.
+ /// <br><br>
+ /// </param>
+ /// <param name="attrs"> The names of the attributes to retrieve.
+ /// <br><br>
+ /// </param>
+ /// <param name="cons"> The constraints specific to the operation.
+ ///
+ /// </param>
+ /// <returns> the LdapEntry read from the server
+ ///
+ /// </returns>
+ /// <exception cref=""> LdapException if the object was not found
+ /// </exception>
+ public virtual LdapEntry Read(System.String dn, System.String[] attrs, LdapSearchConstraints cons)
+ {
+ LdapSearchResults sr = Search(dn, SCOPE_BASE, null, attrs, false, cons);
+
+ LdapEntry ret = null;
+ if (sr.hasMore())
+ {
+ ret = sr.next();
+ if (sr.hasMore())
+ {
+ // "Read response is ambiguous, multiple entries returned"
+ throw new LdapLocalException(ExceptionMessages.READ_MULTIPLE, LdapException.AMBIGUOUS_RESPONSE);
+ }
+ }
+ return ret;
+ }
+
+ /// <summary> Synchronously reads the entry specified by the Ldap URL.
+ ///
+ /// <p>When this read method is called, a new connection is created
+ /// automatically, using the host and port specified in the URL. After
+ /// finding the entry, the method closes the connection (in other words,
+ /// it disconnects from the Ldap server).</p>
+ ///
+ /// <p>If the URL specifies a filter and scope, they are not used. Of the
+ /// information specified in the URL, this method only uses the Ldap host
+ /// name and port number, the base distinguished name (DN), and the list
+ /// of attributes to return.</p>
+ ///
+ /// </summary>
+ /// <param name="toGet"> Ldap URL specifying the entry to read.
+ ///
+ /// </param>
+ /// <returns> The entry specified by the base DN.
+ ///
+ /// </returns>
+ /// <exception cref=""> LdapException if the object was not found
+ /// </exception>
+ public static LdapEntry Read(LdapUrl toGet)
+ {
+ LdapConnection lconn = new LdapConnection();
+ lconn.Connect(toGet.Host, toGet.Port);
+ LdapEntry toReturn = lconn.Read(toGet.getDN(), toGet.AttributeArray);
+ lconn.Disconnect();
+ return toReturn;
+ }
+
+ /// <summary> Synchronously reads the entry specified by the Ldap URL, using the
+ /// specified constraints.
+ ///
+ /// <p>When this method is called, a new connection is created
+ /// automatically, using the host and port specified in the URL. After
+ /// finding the entry, the method closes the connection (in other words,
+ /// it disconnects from the Ldap server).</p>
+ ///
+ /// <p>If the URL specifies a filter and scope, they are not used. Of the
+ /// information specified in the URL, this method only uses the Ldap host
+ /// name and port number, the base distinguished name (DN), and the list
+ /// of attributes to return.</p>
+ ///
+ /// </summary>
+ /// <returns> The entry specified by the base DN.
+ ///
+ /// </returns>
+ /// <param name="toGet"> Ldap URL specifying the entry to read.
+ /// <br><br>
+ /// </param>
+ /// <param name="cons"> Constraints specific to the operation.
+ ///
+ /// </param>
+ /// <exception cref=""> LdapException if the object was not found
+ /// </exception>
+ public static LdapEntry Read(LdapUrl toGet, LdapSearchConstraints cons)
+ {
+ LdapConnection lconn = new LdapConnection();
+ lconn.Connect(toGet.Host, toGet.Port);
+ LdapEntry toReturn = lconn.Read(toGet.getDN(), toGet.AttributeArray, cons);
+ lconn.Disconnect();
+ return toReturn;
+ }
+
+ //*************************************************************************
+ // rename methods
+ //*************************************************************************
+
+ /// <summary>
+ /// Synchronously renames an existing entry in the directory.
+ ///
+ /// </summary>
+ /// <param name="dn"> The current distinguished name of the entry.
+ /// <br><br>
+ /// </param>
+ /// <param name="newRdn"> The new relative distinguished name for the entry.
+ /// <br><br>
+ /// </param>
+ /// <param name="deleteOldRdn"> If true, the old name is not retained as an
+ /// attribute value. If false, the old name is
+ /// retained as an attribute value.
+ ///
+ /// </param>
+ /// <exception cref=""> LdapException A general exception which includes an error
+ /// message and an Ldap error code.
+ /// </exception>
+ public virtual void Rename(System.String dn, System.String newRdn, bool deleteOldRdn)
+ {
+ Rename(dn, newRdn, deleteOldRdn, defSearchCons);
+ return ;
+ }
+
+ /// <summary>
+ /// Synchronously renames an existing entry in the directory, using the
+ /// specified constraints.
+ ///
+ /// </summary>
+ /// <param name="dn"> The current distinguished name of the entry.
+ /// <br><br>
+ /// </param>
+ /// <param name="newRdn"> The new relative distinguished name for the entry.
+ /// <br><br>
+ /// </param>
+ /// <param name="deleteOldRdn"> If true, the old name is not retained as an
+ /// attribute value. If false, the old name is
+ /// retained as an attribute value.
+ /// <br><br>
+ /// </param>
+ /// <param name="cons"> The constraints specific to the operation.
+ ///
+ /// </param>
+ /// <exception cref=""> LdapException A general exception which includes an error
+ /// message and an Ldap error code.
+ /// </exception>
+ public virtual void Rename(System.String dn, System.String newRdn, bool deleteOldRdn, LdapConstraints cons)
+ {
+ // null for newParentdn means that this is originating as an Ldapv2 call
+ Rename(dn, newRdn, null, deleteOldRdn, cons);
+ return ;
+ }
+
+ /// <summary> Synchronously renames an existing entry in the directory, possibly
+ /// repositioning the entry in the directory tree.
+ ///
+ /// </summary>
+ /// <param name="dn"> The current distinguished name of the entry.
+ /// <br><br>
+ /// </param>
+ /// <param name="newRdn"> The new relative distinguished name for the entry.
+ /// <br><br>
+ /// </param>
+ /// <param name="newParentdn"> The distinguished name of an existing entry which
+ /// is to be the new parent of the entry.
+ /// <br><br>
+ /// </param>
+ /// <param name="deleteOldRdn"> If true, the old name is not retained as an
+ /// attribute value. If false, the old name is
+ /// retained as an attribute value.
+ ///
+ /// </param>
+ /// <exception cref=""> LdapException A general exception which includes an error
+ /// message and an Ldap error code.
+ /// </exception>
+ public virtual void Rename(System.String dn, System.String newRdn, System.String newParentdn, bool deleteOldRdn)
+ {
+ Rename(dn, newRdn, newParentdn, deleteOldRdn, defSearchCons);
+ return ;
+ }
+
+ /// <summary>
+ /// Synchronously renames an existing entry in the directory, using the
+ /// specified constraints and possibly repositioning the entry in the
+ /// directory tree.
+ ///
+ /// </summary>
+ /// <param name="dn"> The current distinguished name of the entry.
+ /// <br><br>
+ /// </param>
+ /// <param name="newRdn"> The new relative distinguished name for the entry.
+ /// <br><br>
+ /// </param>
+ /// <param name="newParentdn"> The distinguished name of an existing entry which
+ /// is to be the new parent of the entry.
+ /// <br><br>
+ /// </param>
+ /// <param name="deleteOldRdn"> If true, the old name is not retained as an
+ /// attribute value. If false, the old name is
+ /// retained as an attribute value.
+ /// <br><br>
+ /// </param>
+ /// <param name="cons"> The constraints specific to the operation.
+ ///
+ /// </param>
+ /// <exception cref=""> LdapException A general exception which includes an error
+ /// message and an Ldap error code.
+ /// </exception>
+ public virtual void Rename(System.String dn, System.String newRdn, System.String newParentdn, bool deleteOldRdn, LdapConstraints cons)
+ {
+ LdapResponseQueue queue = Rename(dn, newRdn, newParentdn, deleteOldRdn, null, cons);
+
+ // Get a handle to the rename response
+ LdapResponse renameResponse = (LdapResponse) (queue.getResponse());
+
+ // Set local copy of responseControls synchronously - if there were any
+ lock (responseCtlSemaphore)
+ {
+ responseCtls = renameResponse.Controls;
+ }
+
+ chkResultCode(queue, cons, renameResponse);
+ return ;
+ }
+
+ /*
+ * rename
+ */
+
+ /// <summary> Asynchronously renames an existing entry in the directory.
+ ///
+ /// </summary>
+ /// <param name="dn"> The current distinguished name of the entry.
+ /// <br><br>
+ /// </param>
+ /// <param name="newRdn"> The new relative distinguished name for the entry.
+ /// <br><br>
+ /// </param>
+ /// <param name="deleteOldRdn"> If true, the old name is not retained as an
+ /// attribute value. If false, the old name is
+ /// retained as an attribute value.
+ /// <br><br>
+ /// </param>
+ /// <param name="queue"> The queue for messages returned from a server in
+ /// response to this request. If it is null, a
+ /// queue object is created internally.
+ ///
+ /// </param>
+ /// <exception cref=""> LdapException A general exception which includes an error
+ /// message and an Ldap error code.
+ /// </exception>
+ public virtual LdapResponseQueue Rename(System.String dn, System.String newRdn, bool deleteOldRdn, LdapResponseQueue queue)
+ {
+ return Rename(dn, newRdn, deleteOldRdn, queue, defSearchCons);
+ }
+
+ /// <summary> Asynchronously renames an existing entry in the directory, using the
+ /// specified constraints.
+ ///
+ /// </summary>
+ /// <param name="dn"> The current distinguished name of the entry.
+ /// <br><br>
+ /// </param>
+ /// <param name="newRdn"> The new relative distinguished name for the entry.
+ /// <br><br>
+ /// </param>
+ /// <param name="deleteOldRdn"> If true, the old name is not retained as an
+ /// attribute value. If false, the old name is
+ /// retained as an attribute value.
+ /// <br><br>
+ /// </param>
+ /// <param name="queue"> The queue for messages returned from a server in
+ /// response to this request. If it is null, a
+ /// queue object is created internally.
+ /// <br><br>
+ /// </param>
+ /// <param name="cons"> The constraints specific to the operation.
+ ///
+ /// </param>
+ /// <exception cref=""> LdapException A general exception which includes an error
+ /// message and an Ldap error code.
+ /// </exception>
+ public virtual LdapResponseQueue Rename(System.String dn, System.String newRdn, bool deleteOldRdn, LdapResponseQueue queue, LdapConstraints cons)
+ {
+ return Rename(dn, newRdn, null, deleteOldRdn, queue, cons);
+ }
+
+ /// <summary> Asynchronously renames an existing entry in the directory, possibly
+ /// repositioning the entry in the directory.
+ ///
+ /// </summary>
+ /// <param name="dn"> The current distinguished name of the entry.
+ /// <br><br>
+ /// </param>
+ /// <param name="newRdn"> The new relative distinguished name for the entry.
+ /// <br><br>
+ /// </param>
+ /// <param name="newParentdn"> The distinguished name of an existing entry which
+ /// is to be the new parent of the entry.
+ /// <br><br>
+ /// </param>
+ /// <param name="deleteOldRdn"> If true, the old name is not retained as an
+ /// attribute value. If false, the old name is
+ /// retained as an attribute value.
+ /// <br><br>
+ /// </param>
+ /// <param name="queue"> The queue for messages returned from a server in
+ /// response to this request. If it is null, a
+ /// queue object is created internally.
+ ///
+ /// </param>
+ /// <exception cref=""> LdapException A general exception which includes an error
+ /// message and an Ldap error code.
+ /// </exception>
+ public virtual LdapResponseQueue Rename(System.String dn, System.String newRdn, System.String newParentdn, bool deleteOldRdn, LdapResponseQueue queue)
+ {
+ return Rename(dn, newRdn, newParentdn, deleteOldRdn, queue, defSearchCons);
+ }
+
+ /// <summary> Asynchronously renames an existing entry in the directory, using the
+ /// specified constraints and possibily repositioning the entry in the
+ /// directory.
+ ///
+ /// </summary>
+ /// <param name="dn"> The current distinguished name of the entry.
+ /// <br><br>
+ /// </param>
+ /// <param name="newRdn"> The new relative distinguished name for the entry.
+ /// <br><br>
+ /// </param>
+ /// <param name="newParentdn"> The distinguished name of an existing entry which
+ /// is to be the new parent of the entry.
+ /// <br><br>
+ /// </param>
+ /// <param name="deleteOldRdn"> If true, the old name is not retained as an
+ /// attribute value. If false, the old name is
+ /// retained as an attribute value.
+ /// <br><br>
+ /// </param>
+ /// <param name="queue"> The queue for messages returned from a server in
+ /// response to this request. If it is null, a
+ /// queue object is created internally.
+ /// <br><br>
+ /// </param>
+ /// <param name="cons"> The constraints specific to the operation.
+ ///
+ /// </param>
+ /// <exception cref=""> LdapException A general exception which includes an error
+ /// message and an Ldap error code.
+ /// </exception>
+ public virtual LdapResponseQueue Rename(System.String dn, System.String newRdn, System.String newParentdn, bool deleteOldRdn, LdapResponseQueue queue, LdapConstraints cons)
+ {
+ if ((System.Object) dn == null || (System.Object) newRdn == null)
+ {
+ // Invalid DN or RDN parameter
+ throw new System.ArgumentException(ExceptionMessages.RDN_PARAM_ERROR);
+ }
+
+ if (cons == null)
+ cons = defSearchCons;
+
+ LdapMessage msg = new LdapModifyDNRequest(dn, newRdn, newParentdn, deleteOldRdn, cons.getControls());
+
+ return SendRequestToServer(msg, cons.TimeLimit, queue, null);
+ }
+
+ //*************************************************************************
+ // search methods
+ //*************************************************************************
+
+ /// <summary>
+ /// Synchronously performs the search specified by the parameters.
+ ///
+ /// </summary>
+ /// <param name="base"> The base distinguished name to search from.
+ /// <br><br>
+ /// </param>
+ /// <param name="scope"> The scope of the entries to search. The following
+ /// are the valid options:
+ /// <ul>
+ /// <li>SCOPE_BASE - searches only the base DN
+ ///
+ /// <li>SCOPE_ONE - searches only entries under the base DN
+ ///
+ /// <li>SCOPE_SUB - searches the base DN and all entries
+ /// within its subtree
+ /// </ul><br><br>
+ /// </param>
+ /// <param name="filter"> Search filter specifying the search criteria.
+ /// <br><br>
+ /// </param>
+ /// <param name="attrs"> Names of attributes to retrieve.
+ /// <br><br>
+ /// </param>
+ /// <param name="typesOnly"> If true, returns the names but not the values of
+ /// the attributes found. If false, returns the
+ /// names and values for attributes found.
+ ///
+ /// </param>
+ /// <exception cref=""> LdapException A general exception which includes an error
+ /// message and an Ldap error code.
+ /// </exception>
+ public virtual LdapSearchResults Search(System.String base_Renamed, int scope, System.String filter, System.String[] attrs, bool typesOnly)
+ {
+ return Search(base_Renamed, scope, filter, attrs, typesOnly, defSearchCons);
+ }
+
+ /// <summary>
+ /// Synchronously performs the search specified by the parameters,
+ /// using the specified search constraints (such as the
+ /// maximum number of entries to find or the maximum time to wait for
+ /// search results).
+ ///
+ /// <p>As part of the search constraints, the method allows specifying
+ /// whether or not the results are to be delivered all at once or in
+ /// smaller batches. If specified that the results are to be delivered in
+ /// smaller batches, each iteration blocks only until the next batch of
+ /// results is returned.</p>
+ ///
+ /// </summary>
+ /// <param name="base"> The base distinguished name to search from.
+ /// <br><br>
+ /// </param>
+ /// <param name="scope"> The scope of the entries to search. The following
+ /// are the valid options:
+ /// <ul>
+ /// <li>SCOPE_BASE - searches only the base DN
+ ///
+ /// <li>SCOPE_ONE - searches only entries under the base DN
+ ///
+ /// <li>SCOPE_SUB - searches the base DN and all entries
+ /// within its subtree
+ /// </ul><br><br>
+ /// </param>
+ /// <param name="filter"> The search filter specifying the search criteria.
+ /// <br><br>
+ /// </param>
+ /// <param name="attrs"> The names of attributes to retrieve.
+ /// <br><br>
+ /// </param>
+ /// <param name="typesOnly"> If true, returns the names but not the values of
+ /// the attributes found. If false, returns the
+ /// names and values for attributes found.
+ /// <br><br>
+ /// </param>
+ /// <param name="cons"> The constraints specific to the search.
+ ///
+ /// </param>
+ /// <exception cref=""> LdapException A general exception which includes an error
+ /// message and an Ldap error code.
+ /// </exception>
+ public virtual LdapSearchResults Search(System.String base_Renamed, int scope, System.String filter, System.String[] attrs, bool typesOnly, LdapSearchConstraints cons)
+ {
+ LdapSearchQueue queue = Search(base_Renamed, scope, filter, attrs, typesOnly, null, cons);
+
+ if (cons == null)
+ cons = defSearchCons;
+ return new LdapSearchResults(this, queue, cons);
+ }
+
+ /// <summary> Asynchronously performs the search specified by the parameters.
+ ///
+ /// </summary>
+ /// <param name="base"> The base distinguished name to search from.
+ /// <br><br>
+ /// </param>
+ /// <param name="scope"> The scope of the entries to search. The following
+ /// are the valid options:
+ /// <ul>
+ /// <li>SCOPE_BASE - searches only the base DN
+ ///
+ /// <li>SCOPE_ONE - searches only entries under the base DN
+ ///
+ /// <li>SCOPE_SUB - searches the base DN and all entries
+ /// within its subtree
+ /// </ul><br><br>
+ /// </param>
+ /// <param name="filter"> Search filter specifying the search criteria.
+ /// <br><br>
+ /// </param>
+ /// <param name="attrs"> Names of attributes to retrieve.
+ /// <br><br>
+ /// </param>
+ /// <param name="typesOnly"> If true, returns the names but not the values of
+ /// the attributes found. If false, returns the
+ /// names and values for attributes found.
+ /// <br><br>
+ /// </param>
+ /// <param name="queue"> Handler for messages returned from a server in
+ /// response to this request. If it is null, a
+ /// queue object is created internally.
+ ///
+ /// </param>
+ /// <exception cref=""> LdapException A general exception which includes an error
+ /// message and an Ldap error code.
+ /// </exception>
+ public virtual LdapSearchQueue Search(System.String base_Renamed, int scope, System.String filter, System.String[] attrs, bool typesOnly, LdapSearchQueue queue)
+ {
+ return Search(base_Renamed, scope, filter, attrs, typesOnly, queue, defSearchCons);
+ }
+
+ /// <summary> Asynchronously performs the search specified by the parameters,
+ /// also allowing specification of constraints for the search (such
+ /// as the maximum number of entries to find or the maximum time to
+ /// wait for search results).
+ ///
+ /// </summary>
+ /// <param name="base"> The base distinguished name to search from.
+ /// <br><br>
+ /// </param>
+ /// <param name="scope"> The scope of the entries to search. The following
+ /// are the valid options:
+ /// <ul>
+ /// <li>SCOPE_BASE - searches only the base DN
+ ///
+ /// <li>SCOPE_ONE - searches only entries under the base DN
+ ///
+ /// <li>SCOPE_SUB - searches the base DN and all entries
+ /// within its subtree
+ /// </ul><br><br>
+ /// </param>
+ /// <param name="filter"> The search filter specifying the search criteria.
+ /// <br><br>
+ /// </param>
+ /// <param name="attrs"> The names of attributes to retrieve.
+ /// <br><br>
+ /// </param>
+ /// <param name="typesOnly"> If true, returns the names but not the values of
+ /// the attributes found. If false, returns the
+ /// names and values for attributes found.
+ /// <br><br>
+ /// </param>
+ /// <param name="queue"> The queue for messages returned from a server in
+ /// response to this request. If it is null, a
+ /// queue object is created internally.
+ /// <br><br>
+ /// </param>
+ /// <param name="cons"> The constraints specific to the search.
+ ///
+ /// </param>
+ /// <exception cref=""> LdapException A general exception which includes an error
+ /// message and an Ldap error code.
+ /// </exception>
+ public virtual LdapSearchQueue Search(System.String base_Renamed, int scope, System.String filter, System.String[] attrs, bool typesOnly, LdapSearchQueue queue, LdapSearchConstraints cons)
+ {
+ if ((System.Object) filter == null)
+ {
+ filter = "objectclass=*";
+ }
+ if (cons == null)
+ cons = defSearchCons;
+
+ LdapMessage msg = new LdapSearchRequest(base_Renamed, scope, filter, attrs, cons.Dereference, cons.MaxResults, cons.ServerTimeLimit, typesOnly, cons.getControls());
+ MessageAgent agent;
+ LdapSearchQueue myqueue = queue;
+ if (myqueue == null)
+ {
+ agent = new MessageAgent();
+ myqueue = new LdapSearchQueue(agent);
+ }
+ else
+ {
+ agent = queue.MessageAgent;
+ }
+
+ try
+ {
+ agent.sendMessage(conn, msg, cons.TimeLimit, myqueue, null);
+ }
+ catch (LdapException lex)
+ {
+ throw lex;
+ }
+ return myqueue;
+ }
+
+ /*
+ * Ldap URL search
+ */
+
+ /// <summary> Synchronously performs the search specified by the Ldap URL, returning
+ /// an enumerable LdapSearchResults object.
+ ///
+ /// </summary>
+ /// <param name="toGet">The Ldap URL specifying the entry to read.
+ ///
+ /// </param>
+ /// <exception cref=""> LdapException A general exception which includes an error
+ /// message and an Ldap error code.
+ /// </exception>
+ public static LdapSearchResults Search(LdapUrl toGet)
+ {
+ // Get a clone of default search constraints, method alters batchSize
+ return Search(toGet, null);
+ }
+
+ /*
+ * Ldap URL search
+ */
+
+ /// <summary> Synchronously perfoms the search specified by the Ldap URL, using
+ /// the specified search constraints (such as the maximum number of
+ /// entries to find or the maximum time to wait for search results).
+ ///
+ /// <p>When this method is called, a new connection is created
+ /// automatically, using the host and port specified in the URL. After
+ /// all search results have been received from the server, the method
+ /// closes the connection (in other words, it disconnects from the Ldap
+ /// server).</p>
+ ///
+ /// <p>As part of the search constraints, a choice can be made as to whether
+ /// to have the results delivered all at once or in smaller batches. If
+ /// the results are to be delivered in smaller batches, each iteration
+ /// blocks only until the next batch of results is returned.</p>
+ ///
+ ///
+ /// </summary>
+ /// <param name="toGet"> Ldap URL specifying the entry to read.
+ /// <br><br>
+ /// </param>
+ /// <param name="cons"> The constraints specific to the search.
+ ///
+ /// </param>
+ /// <exception cref=""> LdapException A general exception which includes an error
+ /// message and an Ldap error code.
+ /// </exception>
+ public static LdapSearchResults Search(LdapUrl toGet, LdapSearchConstraints cons)
+ {
+ LdapConnection lconn = new LdapConnection();
+ lconn.Connect(toGet.Host, toGet.Port);
+ if (cons == null)
+ {
+ // This is a clone, so we already have our own copy
+ cons = lconn.SearchConstraints;
+ }
+ else
+ {
+ // get our own copy of user's constraints because we modify it
+ cons = (LdapSearchConstraints) cons.Clone();
+ }
+ cons.BatchSize = 0; // Must wait until all results arrive
+ LdapSearchResults toReturn = lconn.Search(toGet.getDN(), toGet.Scope, toGet.Filter, toGet.AttributeArray, false, cons);
+ lconn.Disconnect();
+ return toReturn;
+ }
+
+ /// <summary> Sends an Ldap request to a directory server.
+ ///
+ /// <p>The specified the Ldap request is sent to the directory server
+ /// associated with this connection using default constraints. An Ldap
+ /// request object is a subclass {@link LdapMessage} with the operation
+ /// type set to one of the request types. You can build a request by using
+ /// the request classes found in this package</p>
+ ///
+ /// <p>You should note that, since Ldap requests sent to the server
+ /// using sendRequest are asynchronous, automatic referral following
+ /// does not apply to these requests.</p>
+ ///
+ /// </summary>
+ /// <param name="request">The Ldap request to send to the directory server.
+ /// </param>
+ /// <param name="queue"> The queue for messages returned from a server in
+ /// response to this request. If it is null, a
+ /// queue object is created internally.
+ /// </param>
+ /// <exception cref=""> LdapException A general exception which includes an error
+ /// message and an Ldap error code.
+ ///
+ /// </exception>
+ /// <seealso cref="LdapMessage#getType()">
+ /// </seealso>
+ /// <seealso cref="LdapMessage#isRequest()">
+ /// </seealso>
+ public virtual LdapMessageQueue SendRequest(LdapMessage request, LdapMessageQueue queue)
+ {
+ return SendRequest(request, queue, null);
+ }
+
+ /// <summary> Sends an Ldap request to a directory server.
+ ///
+ /// <p>The specified the Ldap request is sent to the directory server
+ /// associated with this connection. An Ldap request object is an
+ /// {@link LdapMessage} with the operation type set to one of the request
+ /// types. You can build a request by using the request classes found in this
+ /// package</p>
+ ///
+ /// <p>You should note that, since Ldap requests sent to the server
+ /// using sendRequest are asynchronous, automatic referral following
+ /// does not apply to these requests.</p>
+ ///
+ /// </summary>
+ /// <param name="request">The Ldap request to send to the directory server.
+ /// </param>
+ /// <param name="queue"> The queue for messages returned from a server in
+ /// response to this request. If it is null, a
+ /// queue object is created internally.
+ /// </param>
+ /// <param name="cons"> The constraints that apply to this request
+ /// </param>
+ /// <exception cref=""> LdapException A general exception which includes an error
+ /// message and an Ldap error code.
+ ///
+ /// </exception>
+ /// <seealso cref="LdapMessage#getType()">
+ /// </seealso>
+ /// <seealso cref="LdapMessage#isRequest()">
+ /// </seealso>
+ public virtual LdapMessageQueue SendRequest(LdapMessage request, LdapMessageQueue queue, LdapConstraints cons)
+ {
+
+
+ if (!request.Request)
+ {
+ throw new System.SystemException("Object is not a request message");
+ }
+
+ if (cons == null)
+ {
+ cons = defSearchCons;
+ }
+
+ // Get the correct queue for a search request
+ MessageAgent agent;
+ LdapMessageQueue myqueue = queue;
+ if (myqueue == null)
+ {
+ agent = new MessageAgent();
+ if (request.Type == LdapMessage.SEARCH_REQUEST)
+ {
+ myqueue = new LdapSearchQueue(agent);
+ }
+ else
+ {
+ myqueue = new LdapResponseQueue(agent);
+ }
+ }
+ else
+ {
+ if (request.Type == LdapMessage.SEARCH_REQUEST)
+ {
+ agent = queue.MessageAgent;
+ }
+ else
+ {
+ agent = queue.MessageAgent;
+ }
+ }
+
+ try
+ {
+ agent.sendMessage(conn, request, cons.TimeLimit, myqueue, null);
+ }
+ catch (LdapException lex)
+ {
+ throw lex;
+ }
+ return myqueue;
+ }
+
+ //*************************************************************************
+ // helper methods
+ //*************************************************************************
+
+ /// <summary> Locates the appropriate message agent and sends
+ /// the Ldap request to a directory server.
+ ///
+ /// </summary>
+ /// <param name="msg">the message to send
+ /// <br><br>
+ /// </param>
+ /// <param name="timeout">the timeout value
+ /// <br><br>
+ /// </param>
+ /// <param name="queue">the response queue or null
+ ///
+ /// </param>
+ /// <returns> the LdapResponseQueue for this request
+ ///
+ /// </returns>
+ /// <exception cref=""> LdapException A general exception which includes an error
+ /// message and an Ldap error code.
+ /// </exception>
+ private LdapResponseQueue SendRequestToServer(LdapMessage msg, int timeout, LdapResponseQueue queue, BindProperties bindProps)
+ {
+ MessageAgent agent;
+ if (queue == null)
+ {
+ agent = new MessageAgent();
+ queue = new LdapResponseQueue(agent);
+ }
+ else
+ {
+ agent = queue.MessageAgent;
+ }
+
+ agent.sendMessage(conn, msg, timeout, queue, bindProps);
+ return queue;
+ }
+
+ /// <summary> get an LdapConnection object so that we can follow a referral.
+ /// This function is never called if cons.getReferralFollowing() returns
+ /// false.
+ ///
+ /// </summary>
+ /// <param name="referrals">the array of referral strings
+ /// <br><br>
+ ///
+ /// </param>
+ /// <returns> The referralInfo object
+ ///
+ /// </returns>
+ /// <exception cref=""> LdapReferralException A general exception which includes
+ /// an error message and an Ldap error code.
+ /// </exception>
+ private ReferralInfo getReferralConnection(System.String[] referrals)
+ {
+ ReferralInfo refInfo = null;
+ System.Exception ex = null;
+ LdapConnection rconn = null;
+ LdapReferralHandler rh = defSearchCons.getReferralHandler();
+ int i = 0;
+ // Check if we use LdapRebind to get authentication credentials
+ if ((rh == null) || (rh is LdapAuthHandler))
+ {
+ for (i = 0; i < referrals.Length; i++)
+ {
+ // dn, pw are null in the default case (anonymous bind)
+ System.String dn = null;
+ sbyte[] pw = null;
+ try
+ {
+ rconn = new LdapConnection();
+ rconn.Constraints = defSearchCons;
+ LdapUrl url = new LdapUrl(referrals[i]);
+ rconn.Connect(url.Host, url.Port);
+ if (rh != null)
+ {
+ if (rh is LdapAuthHandler)
+ {
+ // Get application supplied dn and pw
+ LdapAuthProvider ap = ((LdapAuthHandler) rh).getAuthProvider(url.Host, url.Port);
+ dn = ap.DN;
+ pw = ap.Password;
+ }
+ }
+ rconn.Bind(Ldap_V3, dn, pw);
+ ex = null;
+ refInfo = new ReferralInfo(rconn, referrals, url);
+ // Indicate this connection created to follow referral
+ rconn.Connection.ActiveReferral = refInfo;
+ break;
+ }
+ catch (System.Exception lex)
+ {
+ if (rconn != null)
+ {
+ try
+ {
+ rconn.Disconnect();
+ rconn = null;
+ ex = lex;
+ }
+ catch (LdapException e)
+ {
+ ; // ignore
+ }
+ }
+ }
+ }
+ }
+ // Check if application gets connection and does bind
+ else
+ {
+ // rh instanceof LdapBind
+ try
+ {
+ rconn = ((LdapBindHandler) rh).Bind(referrals, this);
+ if (rconn == null)
+ {
+ LdapReferralException rex = new LdapReferralException(ExceptionMessages.REFERRAL_ERROR);
+ rex.setReferrals(referrals);
+ throw rex;
+ }
+ // Figure out which Url belongs to the connection
+ for (int idx = 0; idx < referrals.Length; idx++)
+ {
+ try
+ {
+ LdapUrl url = new LdapUrl(referrals[idx]);
+ if (url.Host.ToUpper().Equals(rconn.Host.ToUpper()) && (url.Port == rconn.Port))
+ {
+ refInfo = new ReferralInfo(rconn, referrals, url);
+ break;
+ }
+ }
+ catch (System.Exception e)
+ {
+ ; // ignore
+ }
+ }
+ if (refInfo == null)
+ {
+ // Could not match LdapBind.bind() connecction with URL list
+ ex = new LdapLocalException(ExceptionMessages.REFERRAL_BIND_MATCH, LdapException.CONNECT_ERROR);
+ }
+ }
+ catch (System.Exception lex)
+ {
+ rconn = null;
+ ex = lex;
+ }
+ }
+ if (ex != null)
+ {
+ // Could not connect to any server, throw an exception
+ LdapException ldapex;
+ if (ex is LdapReferralException)
+ {
+ throw (LdapReferralException) ex;
+ }
+ else if (ex is LdapException)
+ {
+ ldapex = (LdapException) ex;
+ }
+ else
+ {
+ ldapex = new LdapLocalException(ExceptionMessages.SERVER_CONNECT_ERROR, new System.Object[]{conn.Host}, LdapException.CONNECT_ERROR, ex);
+ }
+ // Error attempting to follow a referral
+ LdapReferralException rex = new LdapReferralException(ExceptionMessages.REFERRAL_ERROR, ldapex);
+ rex.setReferrals(referrals);
+ // Use last URL string for the failed referral
+ rex.FailedReferral = referrals[referrals.Length - 1];
+ throw rex;
+ }
+
+ // We now have an authenticated connection
+ // to be used to follow the referral.
+ return refInfo;
+ }
+
+ /// <summary> Check the result code and throw an exception if needed.
+ ///
+ /// <p>If referral following is enabled, checks if we need to
+ /// follow a referral</p>
+ ///
+ /// </summary>
+ /// <param name="queue">- the message queue of the current response
+ ///
+ /// </param>
+ /// <param name="cons">- the constraints that apply to the request
+ ///
+ /// </param>
+ /// <param name="response">- the LdapResponse to check
+ /// </param>
+ private void chkResultCode(LdapMessageQueue queue, LdapConstraints cons, LdapResponse response)
+ {
+ if ((response.ResultCode == LdapException.REFERRAL) && cons.ReferralFollowing)
+ {
+ // Perform referral following and return
+ System.Collections.ArrayList refConn = null;
+ try
+ {
+ chaseReferral(queue, cons, response, response.Referrals, 0, false, null);
+ }
+ finally
+ {
+ releaseReferralConnections(refConn);
+ }
+ }
+ else
+ {
+ // Throws exception for non success result
+ response.chkResultCode();
+ }
+ return ;
+ }
+
+ /// <summary> Follow referrals if necessary referral following enabled.
+ /// This function is called only by synchronous requests.
+ /// Search responses come here only if referral following is
+ /// enabled and if we are processing a SearchResultReference
+ /// or a Response with a status of REFERRAL, i.e. we are
+ /// going to follow a referral.
+ ///
+ /// This functions recursively follows a referral until a result
+ /// is returned or until the hop limit is reached.
+ ///
+ /// </summary>
+ /// <param name="queue">The LdapResponseQueue for this request
+ /// <br><br>
+ /// </param>
+ /// <param name="cons">The constraints that apply to the request
+ /// <br><br>
+ /// </param>
+ /// <param name="msg">The referral or search reference response message
+ /// <br><br>
+ /// </param>
+ /// <param name="initialReferrals">The referral array returned from the
+ /// initial request.
+ /// <br><br>
+ /// </param>
+ /// <param name="hopCount">the number of hops already used while
+ /// following this referral
+ /// <br><br>
+ /// </param>
+ /// <param name="searchReference">true if the message is a search reference
+ /// <br><br>
+ /// </param>
+ /// <param name="connectionList">An optional array list used to store
+ /// the LdapConnection objects used in following the referral.
+ ///
+ /// </param>
+ /// <returns> The array list used to store the all LdapConnection objects
+ /// used in following the referral. The list will be empty
+ /// if there were none.
+ ///
+ /// </returns>
+ /// <exception cref=""> LdapException A general exception which includes an error
+ /// message and an Ldap error code.
+ /// </exception>
+ /* package */
+ internal virtual System.Collections.ArrayList chaseReferral(LdapMessageQueue queue, LdapConstraints cons, LdapMessage msg, System.String[] initialReferrals, int hopCount, bool searchReference, System.Collections.ArrayList connectionList)
+ {
+ System.Collections.ArrayList connList = connectionList;
+ LdapConnection rconn = null; // new conn for following referral
+ ReferralInfo rinfo = null; // referral info
+ LdapMessage origMsg;
+
+ // Get a place to store new connections
+ if (connList == null)
+ {
+ connList = new System.Collections.ArrayList(cons.HopLimit);
+ }
+ // Following referrals or search reference
+ System.String[] refs; // referral list
+ if (initialReferrals != null)
+ {
+ // Search continuation reference from a search request
+ refs = initialReferrals;
+ origMsg = msg.RequestingMessage;
+ }
+ else
+ {
+ // Not a search request
+ LdapResponse resp = (LdapResponse) queue.getResponse();
+ if (resp.ResultCode != LdapException.REFERRAL)
+ {
+ // Not referral result,throw Exception if nonzero result
+ resp.chkResultCode();
+ return connList;
+ }
+ // We have a referral response
+ refs = resp.Referrals;
+ origMsg = resp.RequestingMessage;
+ }
+ LdapUrl refUrl; // referral represented as URL
+ try
+ {
+ // increment hop count, check max hops
+ if (hopCount++ > cons.HopLimit)
+ {
+ throw new LdapLocalException("Max hops exceeded", LdapException.REFERRAL_LIMIT_EXCEEDED);
+ }
+ // Get a connection to follow the referral
+ rinfo = getReferralConnection(refs);
+ rconn = rinfo.ReferralConnection;
+ refUrl = rinfo.ReferralUrl;
+ connList.Add(rconn);
+
+
+ // rebuild msg into new msg changing msgID,dn,scope,filter
+ LdapMessage newMsg = rebuildRequest(origMsg, refUrl, searchReference);
+
+
+ // Send new message on new connection
+ try
+ {
+ MessageAgent agent;
+ if (queue is LdapResponseQueue)
+ {
+ agent = queue.MessageAgent;
+ }
+ else
+ {
+ agent = queue.MessageAgent;
+ }
+ agent.sendMessage(rconn.Connection, newMsg, defSearchCons.TimeLimit, queue, null);
+ }
+ catch (InterThreadException ex)
+ {
+ // Error ending request to referred server
+ LdapReferralException rex = new LdapReferralException(ExceptionMessages.REFERRAL_SEND, LdapException.CONNECT_ERROR, null, ex);
+ rex.setReferrals(initialReferrals);
+ ReferralInfo ref_Renamed = rconn.Connection.ActiveReferral;
+ rex.FailedReferral = ref_Renamed.ReferralUrl.ToString();
+ throw rex;
+ }
+
+ if (initialReferrals == null)
+ {
+ // For operation results, when all responses are complete,
+ // the stack unwinds back to the original and returns
+ // to the application.
+ // An exception is thrown for an error
+ connList = chaseReferral(queue, cons, null, null, hopCount, false, connList);
+ }
+ else
+ {
+ // For search, just return to LdapSearchResults object
+ return connList;
+ }
+ }
+ catch (System.Exception ex)
+ {
+
+ if (ex is LdapReferralException)
+ {
+ throw (LdapReferralException) ex;
+ }
+ else
+ {
+
+ // Set referral list and failed referral
+ LdapReferralException rex = new LdapReferralException(ExceptionMessages.REFERRAL_ERROR, ex);
+ rex.setReferrals(refs);
+ if (rinfo != null)
+ {
+ rex.FailedReferral = rinfo.ReferralUrl.ToString();
+ }
+ else
+ {
+ rex.FailedReferral = refs[refs.Length - 1];
+ }
+ throw rex;
+ }
+ }
+ return connList;
+ }
+
+ /// <summary> Builds a new request replacing dn, scope, and filter where approprate
+ ///
+ /// </summary>
+ /// <param name="msg">the original LdapMessage to build the new request from
+ /// <br><br>
+ /// </param>
+ /// <param name="url">the referral url
+ ///
+ /// </param>
+ /// <returns> a new LdapMessage with appropriate information replaced
+ ///
+ /// </returns>
+ /// <exception cref=""> LdapException A general exception which includes an error
+ /// message and an Ldap error code.
+ /// </exception>
+ private LdapMessage rebuildRequest(LdapMessage msg, LdapUrl url, bool reference)
+ {
+
+ System.String dn = url.getDN(); // new base
+ System.String filter = null;
+
+ switch (msg.Type)
+ {
+
+ case LdapMessage.SEARCH_REQUEST:
+ if (reference)
+ {
+ filter = url.Filter;
+ }
+ break;
+ // We are allowed to get a referral for the following
+
+ case LdapMessage.ADD_REQUEST:
+ case LdapMessage.BIND_REQUEST:
+ case LdapMessage.COMPARE_REQUEST:
+ case LdapMessage.DEL_REQUEST:
+ case LdapMessage.EXTENDED_REQUEST:
+ case LdapMessage.MODIFY_RDN_REQUEST:
+ case LdapMessage.MODIFY_REQUEST:
+ break;
+ // The following return no response
+
+ case LdapMessage.ABANDON_REQUEST:
+ case LdapMessage.UNBIND_REQUEST:
+ default:
+ throw new LdapLocalException(ExceptionMessages.IMPROPER_REFERRAL, new System.Object[]{msg.Type}, LdapException.LOCAL_ERROR);
+ }
+
+ return msg.Clone(dn, filter, reference);
+ }
+
+ /*
+ * Release connections acquired by following referrals
+ *
+ * @param list the list of the connections
+ */
+ /* package */
+ internal virtual void releaseReferralConnections(System.Collections.ArrayList list)
+ {
+ if (list == null)
+ {
+ return ;
+ }
+ // Release referral connections
+ for (int i = list.Count - 1; i >= 0; i--)
+ {
+ LdapConnection rconn = null;
+ try
+ {
+ rconn=(LdapConnection)list[i];
+ list.RemoveAt(i);
+// rconn = (LdapConnection) list.RemoveAt(i);
+ rconn.Disconnect();
+ }
+ catch (System.IndexOutOfRangeException ex)
+ {
+ continue;
+ }
+ catch (LdapException lex)
+ {
+ continue;
+ }
+ }
+ return ;
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapConstraints.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapConstraints.cs
new file mode 100755
index 00000000000..aa65fd31f17
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapConstraints.cs
@@ -0,0 +1,465 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.LdapConstraints.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+
+namespace Novell.Directory.Ldap
+{
+
+ /// <summary> Defines options controlling Ldap operations on the directory.
+ ///
+ /// <p>An LdapConstraints object is always associated with an LdapConnection
+ /// object; its values can be changed with LdapConnection.setConstraints, or
+ /// overridden by passing an LdapConstraints object to an operation.</p>
+ ///
+ /// </summary>
+ /// <seealso cref="LdapConnection#setConstraints(LdapConstraints)">
+ /// </seealso>
+ public class LdapConstraints : System.ICloneable
+ {
+ /// <summary> Returns the maximum number of referrals to follow during automatic
+ /// referral following. The operation will be abandoned and terminated by
+ /// the API with a result code of LdapException.REFERRAL_LIMIT_EXCEEDED
+ /// if the number of referrals in a sequence exceeds the limit.
+ /// It is ignored for asynchronous operations.
+ ///
+ /// </summary>
+ /// <returns> The maximum number of referrals to follow in sequence
+ ///
+ /// </returns>
+ /// <seealso cref="#setHopLimit(int)">
+ /// </seealso>
+ /// <seealso cref="LdapException#REFERRAL_LIMIT_EXCEEDED">
+ /// </seealso>
+ /// <summary> Sets the maximum number of referrals to follow in sequence during
+ /// automatic referral following.
+ ///
+ /// </summary>
+ /// <param name="hop_limit">The maximum number of referrals to follow in a
+ /// sequence during automatic referral following.
+ /// The default value is 10. A value of 0 means no limit.
+ /// The operation will be abandoned and terminated by the
+ /// API with a result code of
+ /// LdapException.REFERRAL_LIMIT_EXCEEDED if the
+ /// number of referrals in a sequence exceeds the limit.
+ /// It is ignored for asynchronous operations.
+ ///
+ /// </param>
+ /// <seealso cref="LdapException#REFERRAL_LIMIT_EXCEEDED">
+ /// </seealso>
+ virtual public int HopLimit
+ {
+ get
+ {
+ return hopLimit;
+ }
+
+ set
+ {
+ this.hopLimit = value;
+ return ;
+ }
+
+ }
+ /// <summary> Gets all the properties of the constraints object which has been
+ /// assigned with {@link #setProperty(String, Object)}.
+ /// A value of <code>null</code> is returned if no properties are defined.
+ ///
+ /// </summary>
+ /// <seealso cref="Object)">
+ /// </seealso>
+ /// <seealso cref="LdapConnection#getProperty(String)">
+ /// </seealso>
+ /// <summary> Sets all the properties of the constraints object.
+ ///
+ /// </summary>
+ /// <param name="props">the properties represented by the Hashtable object to set.
+ /// </param>
+ virtual internal System.Collections.Hashtable Properties
+ {
+ /* package */
+
+ get
+ {
+ return properties;
+ }
+
+ /* package */
+
+ set
+ {
+ properties = (System.Collections.Hashtable) value.Clone();
+ return ;
+ }
+
+ }
+ /// <summary> Specified whether or not referrals are followed automatically.
+ ///
+ /// </summary>
+ /// <returns> True if referrals are followed automatically, or
+ /// false if referrals throw an LdapReferralException.</p>
+ /// </returns>
+ /// <summary> Specifies whether referrals are followed automatically or if
+ /// referrals throw an LdapReferralException.
+ ///
+ /// <p>Referrals of any type other than to an Ldap server (for example, a
+ /// referral URL other than ldap://something) are ignored on automatic
+ /// referral following. </p>
+ ///
+ /// <p> The default is false.</p>
+ ///
+ /// </summary>
+ /// <param name="doReferrals"> True to follow referrals automatically.
+ /// False to throw an LdapReferralException if
+ /// the server returns a referral.
+ /// </param>
+ virtual public bool ReferralFollowing
+ {
+ get
+ {
+ return doReferrals;
+ }
+
+ set
+ {
+ this.doReferrals = value;
+ return ;
+ }
+
+ }
+ /// <summary> Returns the maximum number of milliseconds to wait for any operation
+ /// under these constraints.
+ ///
+ /// <p>If the value is 0, there is no maximum time limit on waiting
+ /// for operation results. The actual granularity of the timeout depends
+ /// platform. This limit is enforced the the API on an
+ /// operation, not by the server.
+ /// The operation will be abandoned and terminated by the
+ /// API with a result code of LdapException.Ldap_TIMEOUT if the
+ /// operation exceeds the time limit.</p>
+ ///
+ /// </summary>
+ /// <returns> The maximum number of milliseconds to wait for the operation.
+ ///
+ /// </returns>
+ /// <seealso cref="LdapException#Ldap_TIMEOUT">
+ /// </seealso>
+ /// <summary> Sets the maximum number of milliseconds the client waits for
+ /// any operation under these constraints to complete.
+ ///
+ /// <p>If the value is 0, there is no maximum time limit enforced by the
+ /// API on waiting for the operation results. The actual granularity of
+ /// the timeout depends on the platform.
+ /// The operation will be abandoned and terminated by the
+ /// API with a result code of LdapException.Ldap_TIMEOUT if the
+ /// operation exceeds the time limit.</p>
+ ///
+ /// </summary>
+ /// <param name="msLimit"> The maximum milliseconds to wait.
+ ///
+ /// </param>
+ /// <seealso cref="LdapException#Ldap_TIMEOUT">
+ /// </seealso>
+ virtual public int TimeLimit
+ {
+ get
+ {
+ return msLimit;
+ }
+
+ set
+ {
+ this.msLimit = value;
+ return ;
+ }
+
+ }
+
+ private int msLimit = 0;
+ private int hopLimit = 10;
+ private bool doReferrals = false;
+ private LdapReferralHandler refHandler = null;
+ private LdapControl[] controls = null;
+ private static System.Object nameLock; // protect agentNum
+ private static int lConsNum = 0; // Debug, LdapConstraints num
+ private System.String name; // String name for debug
+ private System.Collections.Hashtable properties = null; // Properties
+
+ /// <summary> Constructs a new LdapConstraints object that specifies the default
+ /// set of constraints.
+ /// </summary>
+ public LdapConstraints()
+ {
+ // Get a unique constraints name for debug
+ return ;
+ }
+
+ /// <summary> Constructs a new LdapConstraints object specifying constraints that
+ /// control wait time, and referral handling.
+ ///
+ /// </summary>
+ /// <param name="msLimit"> The maximum time in milliseconds to wait for results.
+ /// The default is 0, which means that there is no
+ /// maximum time limit. This limit is enforced for an
+ /// operation by the API, not by the server.
+ /// The operation will be abandoned and terminated by the
+ /// API with a result code of LdapException.Ldap_TIMEOUT
+ /// if the operation exceeds the time limit.
+ /// <br><br>
+ /// </param>
+ /// <param name="doReferrals">Determines whether to automatically follow
+ /// referrals or not. Specify true to follow
+ /// referrals automatically, and false to throw
+ /// an LdapReferralException if the server responds
+ /// with a referral. False is the default value.
+ /// The way referrals are followed automatically is
+ /// determined by the setting of the handler parameter.
+ /// It is ignored for asynchronous operations.
+ /// <br><br>
+ /// </param>
+ /// <param name="handler"> The custom authentication handler called when
+ /// LdapConnection needs to authenticate, typically on
+ /// following a referral. A null may be specified to
+ /// indicate default authentication processing, i.e.
+ /// referrals are followed with anonymous authentication.
+ /// The handler object may be an implemention of either the
+ /// LdapBindHandler or LdapAuthHandler interface.
+ /// The implementation of these interfaces determines how
+ /// authentication is performed when following referrals.
+ /// It is ignored for asynchronous operations.
+ /// <br><br>
+ /// </param>
+ /// <param name="hop_limit">The maximum number of referrals to follow in a
+ /// sequence during automatic referral following.
+ /// The default value is 10. A value of 0 means no limit.
+ /// The operation will be abandoned and terminated by the
+ /// API with a result code of
+ /// LdapException.REFERRAL_LIMIT_EXCEEDED if the
+ /// number of referrals in a sequence exceeds the limit.
+ /// It is ignored for asynchronous operations.
+ ///
+ /// </param>
+ /// <seealso cref="LdapException#Ldap_TIMEOUT">
+ /// </seealso>
+ /// <seealso cref="LdapException#REFERRAL_LIMIT_EXCEEDED">
+ /// </seealso>
+ /// <seealso cref="LdapException#REFERRAL">
+ /// </seealso>
+ /// <seealso cref="LdapReferralException">
+ /// </seealso>
+ /// <seealso cref="LdapBindHandler">
+ /// </seealso>
+ /// <seealso cref="LdapAuthHandler">
+ /// </seealso>
+ public LdapConstraints(int msLimit, bool doReferrals, LdapReferralHandler handler, int hop_limit)
+ {
+ this.msLimit = msLimit;
+ this.doReferrals = doReferrals;
+ this.refHandler = handler;
+ this.hopLimit = hop_limit;
+ // Get a unique constraints name for debug
+ return ;
+ }
+
+ /// <summary> Returns the controls to be sent to the server.
+ ///
+ /// </summary>
+ /// <returns> The controls to be sent to the server, or null if none.
+ ///
+ /// </returns>
+ /// <seealso cref="#setControls(LdapControl)">
+ /// </seealso>
+ /// <seealso cref="#setControls(LdapControl[])">
+ /// </seealso>
+ public virtual LdapControl[] getControls()
+ {
+ return controls;
+ }
+
+ /// <summary> Gets a property of the constraints object which has been
+ /// assigned with {@link #setProperty(String, Object)}.
+ ///
+ /// </summary>
+ /// <param name="name"> Name of the property to be returned.
+ ///
+ /// </param>
+ /// <returns> the object associated with the property,
+ /// or <code>null</code> if the property is not set.
+ ///
+ /// </returns>
+ /// <seealso cref="Object)">
+ /// </seealso>
+ /// <seealso cref="LdapConnection#getProperty(String)">
+ /// </seealso>
+ public virtual System.Object getProperty(System.String name)
+ {
+ if (properties == null)
+ {
+ return null; // Requested property not available.
+ }
+ return properties[name];
+ }
+
+ /// <summary> Returns an object that can process authentication for automatic
+ /// referral handling.
+ ///
+ /// <p>It may be null.</p>
+ ///
+ /// </summary>
+ /// <returns> An LdapReferralHandler object that can process authentication.
+ /// </returns>
+ /*package*/
+ internal virtual LdapReferralHandler getReferralHandler()
+ {
+ return refHandler;
+ }
+
+ /// <summary> Sets a single control to be sent to the server.
+ ///
+ /// </summary>
+ /// <param name="control"> A single control to be sent to the server or
+ /// null if none.
+ /// </param>
+ public virtual void setControls(LdapControl control)
+ {
+ if (control == null)
+ {
+ this.controls = null;
+ return ;
+ }
+ this.controls = new LdapControl[1];
+ this.controls[0] = (LdapControl) control.Clone();
+ return ;
+ }
+
+ /// <summary> Sets controls to be sent to the server.
+ ///
+ /// </summary>
+ /// <param name="controls"> An array of controls to be sent to the server or
+ /// null if none.
+ /// </param>
+ public virtual void setControls(LdapControl[] controls)
+ {
+ if ((controls == null) || (controls.Length == 0))
+ {
+ this.controls = null;
+ return ;
+ }
+ this.controls = new LdapControl[controls.Length];
+ for (int i = 0; i < controls.Length; i++)
+ {
+ this.controls[i] = (LdapControl) controls[i].Clone();
+ }
+ return ;
+ }
+
+ /// <summary> Sets a property of the constraints object.
+ ///
+ /// <p>No property names have been defined at this time, but the
+ /// mechanism is in place in order to support revisional as well as
+ /// dynamic and proprietary extensions to operation modifiers.</p>
+ ///
+ /// </summary>
+ /// <param name="name"> Name of the property to set.
+ /// <br><br>
+ /// </param>
+ /// <param name="value"> Value to assign to the property.
+ /// property is not supported.
+ ///
+ /// @throws NullPointerException if name or value are null
+ ///
+ /// </param>
+ /// <seealso cref=")">
+ /// </seealso>
+ /// <seealso cref="LdapConnection#getProperty(String)">
+ /// </seealso>
+ public virtual void setProperty(System.String name, System.Object value_Renamed)
+ {
+ if (properties == null)
+ {
+ properties = new System.Collections.Hashtable();
+ }
+ SupportClass.PutElement(properties, name, value_Renamed);
+ return ;
+ }
+
+ /// <summary> Specifies the object that will process authentication requests
+ /// during automatic referral following.
+ ///
+ /// <p>The default is null.</p>
+ ///
+ /// </summary>
+ /// <param name="handler"> An object that implements LdapBindHandler or
+ /// LdapAuthHandler
+ ///
+ /// </param>
+ /// <seealso cref="LdapAuthHandler">
+ /// </seealso>
+ /// <seealso cref="LdapBindHandler">
+ /// </seealso>
+ public virtual void setReferralHandler(LdapReferralHandler handler)
+ {
+ refHandler = handler;
+ return ;
+ }
+
+ /// <summary> Clones an LdapConstraints object.
+ ///
+ /// </summary>
+ /// <returns> An LdapConstraints object.
+ /// </returns>
+ public System.Object Clone()
+ {
+ try
+ {
+ System.Object newObj = base.MemberwiseClone();
+ if (controls != null)
+ {
+ ((LdapConstraints) newObj).controls = new LdapControl[controls.Length];
+ controls.CopyTo(((LdapConstraints) newObj).controls, 0);
+ }
+ if (properties != null)
+ {
+ ((LdapConstraints) newObj).properties = (System.Collections.Hashtable) properties.Clone();
+ }
+ return newObj;
+ }
+ catch (System.Exception ce)
+ {
+ throw new System.SystemException("Internal error, cannot create clone");
+ }
+ }
+ static LdapConstraints()
+ {
+ nameLock = new System.Object();
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapControl.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapControl.cs
new file mode 100755
index 00000000000..62dfa189a16
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapControl.cs
@@ -0,0 +1,237 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.LdapControl.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+using Novell.Directory.Ldap.Utilclass;
+using Novell.Directory.Ldap.Asn1;
+using Novell.Directory.Ldap.Rfc2251;
+
+namespace Novell.Directory.Ldap
+{
+
+ /// <summary> Encapsulates optional additional parameters or constraints to be applied to
+ /// an Ldap operation.
+ ///
+ /// <p>When included with LdapConstraints or LdapSearchConstraints
+ /// on an LdapConnection or with a specific operation request, it is
+ /// sent to the server along with operation requests.</p>
+ ///
+ /// </summary>
+ /// <seealso cref="LdapConnection#getResponseControls">
+ /// </seealso>
+ /// <seealso cref="LdapSearchConstraints#getControls">
+ /// </seealso>
+ /// <seealso cref="LdapSearchConstraints#setControls">
+ /// </seealso>
+ public class LdapControl : System.ICloneable
+ {
+ /// <summary> Returns the identifier of the control.
+ ///
+ /// </summary>
+ /// <returns> The object ID of the control.
+ /// </returns>
+ virtual public System.String ID
+ {
+ get
+ {
+ return new System.Text.StringBuilder(control.ControlType.stringValue()).ToString();
+ }
+
+ }
+ /// <summary> Returns whether the control is critical for the operation.
+ ///
+ /// </summary>
+ /// <returns> Returns true if the control must be supported for an associated
+ /// operation to be executed, and false if the control is not required for
+ /// the operation.
+ /// </returns>
+ virtual public bool Critical
+ {
+ get
+ {
+ return control.Criticality.booleanValue();
+ }
+
+ }
+ internal static RespControlVector RegisteredControls
+ {
+ /* package */
+
+ get
+ {
+ return registeredControls;
+ }
+
+ }
+ /// <summary> Returns the RFC 2251 Control object.
+ ///
+ /// </summary>
+ /// <returns> An ASN.1 RFC 2251 Control.
+ /// </returns>
+ virtual internal RfcControl Asn1Object
+ {
+ /*package*/
+
+ get
+ {
+ return control;
+ }
+
+ }
+
+ private static RespControlVector registeredControls;
+
+ private RfcControl control; // An RFC 2251 Control
+
+ /// <summary> Constructs a new LdapControl object using the specified values.
+ ///
+ /// </summary>
+ /// <param name="oid"> The OID of the control, as a dotted string.
+ /// <br><br>
+ /// </param>
+ /// <param name="critical"> True if the Ldap operation should be discarded if
+ /// the control is not supported. False if
+ /// the operation can be processed without the control.
+ /// <br><br>
+ /// </param>
+ /// <param name="values"> The control-specific data.
+ /// </param>
+ [CLSCompliantAttribute(false)]
+ public LdapControl(System.String oid, bool critical, sbyte[] values)
+ {
+ if ((System.Object) oid == null)
+ {
+ throw new System.ArgumentException("An OID must be specified");
+ }
+ if (values == null)
+ {
+ control = new RfcControl(new RfcLdapOID(oid), new Asn1Boolean(critical));
+ }
+ else
+ {
+ control = new RfcControl(new RfcLdapOID(oid), new Asn1Boolean(critical), new Asn1OctetString(values));
+ }
+ return ;
+ }
+
+ /// <summary> Create an LdapControl from an existing control.</summary>
+ protected internal LdapControl(RfcControl control)
+ {
+ this.control = control;
+ return ;
+ }
+
+ /// <summary> Returns a copy of the current LdapControl object.
+ ///
+ /// </summary>
+ /// <returns> A copy of the current LdapControl object.
+ /// </returns>
+ public System.Object Clone()
+ {
+ LdapControl cont;
+ try
+ {
+ cont = (LdapControl) base.MemberwiseClone();
+ }
+ catch (System.Exception ce)
+ {
+ throw new System.SystemException("Internal error, cannot create clone");
+ }
+ sbyte[] vals = this.getValue();
+ sbyte[] twin = null;
+ if (vals != null)
+ {
+ //is this necessary?
+ // Yes even though the contructor above allocates a
+ // new Asn1OctetString, vals in that constuctor
+ // is only copied by reference
+ twin = new sbyte[vals.Length];
+ for (int i = 0; i < vals.Length; i++)
+ {
+ twin[i] = vals[i];
+ }
+ cont.control = new RfcControl(new RfcLdapOID(ID), new Asn1Boolean(Critical), new Asn1OctetString(twin));
+ }
+ return cont;
+ }
+
+ /// <summary> Returns the control-specific data of the object.
+ ///
+ /// </summary>
+ /// <returns> The control-specific data of the object as a byte array,
+ /// or null if the control has no data.
+ /// </returns>
+ [CLSCompliantAttribute(false)]
+ public virtual sbyte[] getValue()
+ {
+ sbyte[] result = null;
+ Asn1OctetString val = control.ControlValue;
+ if (val != null)
+ {
+ result = val.byteValue();
+ }
+ return result;
+ }
+
+
+ /// <summary> Sets the control-specific data of the object. This method is for
+ /// use by an extension of LdapControl.
+ /// </summary>
+ [CLSCompliantAttribute(false)]
+ protected internal virtual void setValue(sbyte[] controlValue)
+ {
+ control.ControlValue = new Asn1OctetString(controlValue);
+ return ;
+ }
+
+ /// <summary> Registers a class to be instantiated on receipt of a control with the
+ /// given OID.
+ ///
+ /// <p>Any previous registration for the OID is overridden. The
+ /// controlClass must be an extension of LdapControl.</p>
+ ///
+ /// </summary>
+ /// <param name="oid"> The object identifier of the control.
+ /// <br><br>
+ /// </param>
+ /// <param name="controlClass"> A class which can instantiate an LdapControl.
+ /// </param>
+ public static void register(System.String oid, System.Type controlClass)
+ {
+ registeredControls.registerResponseControl(oid, controlClass);
+ return ;
+ }
+ static LdapControl()
+ {
+ registeredControls = new RespControlVector(5, 5);
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapDN.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapDN.cs
new file mode 100755
index 00000000000..ad194917a5a
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapDN.cs
@@ -0,0 +1,262 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.LdapDN.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+using Novell.Directory.Ldap.Utilclass;
+
+namespace Novell.Directory.Ldap
+{
+
+ /// <summary> A utility class to facilitate composition and deomposition
+ /// of distinguished names (DNs).
+ ///
+ /// <p>Specifies methods for manipulating a distinguished name (DN)
+ /// and a relative distinguished name (RDN).</p>
+ /// </summary>
+ public class LdapDN
+ {
+ /// <summary> Compares the two strings per the distinguishedNameMatch equality matching
+ /// (using case-ignore matching). IllegalArgumentException is thrown if one
+ /// or both DNs are invalid. UnsupportedOpersationException is thrown if the
+ /// API implementation is not able to detemine if the DNs match or not.
+ ///
+ /// </summary>
+ /// <param name="dn1"> String form of the first DN to compare.
+ /// <br><br>
+ /// </param>
+ /// <param name="dn2"> String form of the second DN to compare.
+ ///
+ /// </param>
+ /// <returns> Returns true if the two strings correspond to the same DN; false
+ /// if the DNs are different.
+ /// </returns>
+ [CLSCompliantAttribute(false)]
+ public static bool equals(System.String dn1, System.String dn2)
+ {
+ DN dnA = new DN(dn1);
+ DN dnB = new DN(dn2);
+ return dnA.Equals(dnB);
+ }
+
+ /// <summary> Returns the RDN after escaping the characters requiring escaping.
+ ///
+ /// <p>For example, for the rdn "cn=Acme, Inc", the escapeRDN method
+ /// returns "cn=Acme\, Inc".</p>
+ ///
+ /// <p>escapeRDN escapes the AttributeValue by inserting '\' before the
+ /// following chars: * ',' '+' '"' '\' '<' '>' ';' <BR>
+ /// '#' if it comes at the beginning of the string, and <BR>
+ /// ' ' (space) if it comes at the beginning or the end of a string.
+ /// Note that single-valued attributes can be used because of ambiguity. See
+ /// RFC 2253 </p>
+ ///
+ /// </summary>
+ /// <param name="rdn"> The RDN to escape.
+ ///
+ /// </param>
+ /// <returns> The RDN with escaping characters.
+ /// </returns>
+ public static System.String escapeRDN(System.String rdn)
+ {
+ System.Text.StringBuilder escapedS = new System.Text.StringBuilder(rdn);
+ int i = 0;
+
+ while (i < escapedS.Length && escapedS[i] != '=')
+ {
+ i++; //advance until we find the separator =
+ }
+ if (i == escapedS.Length)
+ {
+ throw new System.ArgumentException("Could not parse RDN: Attribute " + "type and name must be separated by an equal symbol, '='");
+ }
+
+ i++;
+ //check for a space or # at the beginning of a string.
+ if ((escapedS[i] == ' ') || (escapedS[i] == '#'))
+ {
+ escapedS.Insert(i++, '\\');
+ }
+
+ //loop from second char to the second to last
+ for (; i < escapedS.Length; i++)
+ {
+ if ((escapedS[i] == ',') || (escapedS[i] == '+') || (escapedS[i] == '"') || (escapedS[i] == '\\') || (escapedS[i] == '<') || (escapedS[i] == '>') || (escapedS[i] == ';'))
+ {
+ escapedS.Insert(i++, '\\');
+ }
+ }
+
+ //check last char for a space
+ if (escapedS[escapedS.Length - 1] == ' ')
+ {
+ escapedS.Insert(escapedS.Length - 1, '\\');
+ }
+ return escapedS.ToString();
+ }
+
+
+
+ /// <summary> Returns the individual components of a distinguished name (DN).
+ ///
+ /// </summary>
+ /// <param name="dn"> The distinguished name, for example, "cn=Babs
+ /// Jensen,ou=Accounting,o=Acme,c=US"
+ /// <br><br>
+ /// </param>
+ /// <param name="noTypes"> If true, returns only the values of the
+ /// components and not the names. For example, "Babs
+ /// Jensen", "Accounting", "Acme", "US" instead of
+ /// "cn=Babs Jensen", "ou=Accounting", "o=Acme", and
+ /// "c=US".
+ ///
+ /// </param>
+ /// <returns> An array of strings representing the individual components
+ /// of a DN, or null if the DN is not valid.
+ /// </returns>
+ public static System.String[] explodeDN(System.String dn, bool noTypes)
+ {
+ DN dnToExplode = new DN(dn);
+ return dnToExplode.explodeDN(noTypes);
+ }
+
+ /// <summary> Returns the individual components of a relative distinguished name
+ /// (RDN), normalized.
+ ///
+ /// </summary>
+ /// <param name="rdn"> The relative distinguished name, or in other words,
+ /// the left-most component of a distinguished name.
+ /// <br><br>
+ /// </param>
+ /// <param name="noTypes"> If true, returns only the values of the
+ /// components, and not the names of the component, for
+ /// example "Babs Jensen" instead of "cn=Babs Jensen".
+ ///
+ /// </param>
+ /// <returns> An array of strings representing the individual components
+ /// of an RDN, or null if the RDN is not a valid RDN.
+ /// </returns>
+ public static System.String[] explodeRDN(System.String rdn, bool noTypes)
+ {
+ RDN rdnToExplode = new RDN(rdn);
+ return rdnToExplode.explodeRDN(noTypes);
+ }
+
+ /// <summary> Returns true if the string conforms to distinguished name syntax.</summary>
+ /// <param name="dn"> String to evaluate fo distinguished name syntax.
+ /// </param>
+ /// <returns> true if the dn is valid.
+ /// </returns>
+ public static bool isValid(System.String dn)
+ {
+ try
+ {
+ new DN(dn);
+ }
+ catch (System.ArgumentException iae)
+ {
+ return false;
+ }
+ return true;
+ }
+
+ /// <summary> Returns the DN normalized by removal of non-significant space characters
+ /// as per RFC 2253, section4.
+ ///
+ /// </summary>
+ /// <returns> a normalized string
+ /// </returns>
+ public static System.String normalize(System.String dn)
+ {
+ DN testDN = new DN(dn);
+ return testDN.ToString();
+ }
+
+
+ /// <summary> Returns the RDN after unescaping the characters requiring escaping.
+ ///
+ /// <p>For example, for the rdn "cn=Acme\, Inc", the unescapeRDN method
+ /// returns "cn=Acme, Inc".</p>
+ /// unescapeRDN unescapes the AttributeValue by
+ /// removing the '\' when the next character fits the following:<BR>
+ /// ',' '+' '"' '\' '<' '>' ';'<BR>
+ /// '#' if it comes at the beginning of the Attribute Name
+ /// (without the '\').<BR>
+ /// ' ' (space) if it comes at the beginning or the end of the Attribute Name
+ /// </p>
+ /// </summary>
+ /// <param name="rdn"> The RDN to unescape.
+ ///
+ /// </param>
+ /// <returns> The RDN with the escaping characters removed.
+ /// </returns>
+ public static System.String unescapeRDN(System.String rdn)
+ {
+ System.Text.StringBuilder unescaped = new System.Text.StringBuilder();
+ int i = 0;
+
+ while (i < rdn.Length && rdn[i] != '=')
+ {
+ i++; //advance until we find the separator =
+ }
+ if (i == rdn.Length)
+ {
+ throw new System.ArgumentException("Could not parse rdn: Attribute " + "type and name must be separated by an equal symbol, '='");
+ }
+ i++;
+ //check if the first two chars are "\ " (slash space) or "\#"
+ if ((rdn[i] == '\\') && (i + 1 < rdn.Length - 1) && ((rdn[i + 1] == ' ') || (rdn[i + 1] == '#')))
+ {
+ i++;
+ }
+ for (; i < rdn.Length; i++)
+ {
+ //if the current char is a slash, not the end char, and is followed
+ // by a special char then...
+ if ((rdn[i] == '\\') && (i != rdn.Length - 1))
+ {
+ if ((rdn[i + 1] == ',') || (rdn[i + 1] == '+') || (rdn[i + 1] == '"') || (rdn[i + 1] == '\\') || (rdn[i + 1] == '<') || (rdn[i + 1] == '>') || (rdn[i + 1] == ';'))
+ {
+ //I'm not sure if I have to check for these special chars
+ continue;
+ }
+ //check if the last two chars are "\ "
+ else if ((rdn[i + 1] == ' ') && (i + 2 == rdn.Length))
+ {
+ //if the last char is a space
+ continue;
+ }
+ }
+ unescaped.Append(rdn[i]);
+ }
+ return unescaped.ToString();
+ }
+ } //end class LdapDN
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapDeleteRequest.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapDeleteRequest.cs
new file mode 100755
index 00000000000..f7bdd1a6ebc
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapDeleteRequest.cs
@@ -0,0 +1,84 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.LdapDeleteRequest.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+using Novell.Directory.Ldap.Rfc2251;
+
+namespace Novell.Directory.Ldap
+{
+
+ /// <summary> Represents a request to delete an entry.
+ ///
+ /// </summary>
+ /// <seealso cref="LdapConnection#sendRequest">
+ /// </seealso>
+ /*
+ * DelRequest ::= [APPLICATION 10] LdapDN
+ */
+ public class LdapDeleteRequest:LdapMessage
+ {
+ /// <summary> Returns of the dn of the entry to delete from the directory
+ ///
+ /// </summary>
+ /// <returns> the dn of the entry to delete
+ /// </returns>
+ virtual public System.String DN
+ {
+ get
+ {
+ return Asn1Object.RequestDN;
+ }
+
+ }
+ /// <summary> Constructs a request to delete an entry from the directory
+ ///
+ /// </summary>
+ /// <param name="dn">the dn of the entry to delete.
+ ///
+ /// </param>
+ /// <param name="cont">Any controls that apply to the abandon request
+ /// or null if none.
+ /// </param>
+ public LdapDeleteRequest(System.String dn, LdapControl[] cont):base(LdapMessage.DEL_REQUEST, new RfcDelRequest(dn), cont)
+ {
+ return ;
+ }
+
+ /// <summary> Return an Asn1 representation of this delete request
+ ///
+ /// #return an Asn1 representation of this object
+ /// </summary>
+ public override System.String ToString()
+ {
+ return Asn1Object.ToString();
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapEntry.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapEntry.cs
new file mode 100755
index 00000000000..970e0782c9f
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapEntry.cs
@@ -0,0 +1,207 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.LdapEntry.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+
+namespace Novell.Directory.Ldap
+{
+
+ /// <summary> Represents a single entry in a directory, consisting of
+ /// a distinguished name (DN) and zero or more attributes.
+ ///
+ /// <p>An instance of
+ /// LdapEntry is created in order to add an entry to a directory, and
+ /// instances of LdapEntry are returned on a search by enumerating an
+ /// LdapSearchResults.
+ ///
+ /// </summary>
+ /// <seealso cref="LdapAttribute">
+ /// </seealso>
+ /// <seealso cref="LdapAttributeSet">
+ /// </seealso>
+ public class LdapEntry : System.IComparable
+ {
+ /// <summary> Returns the distinguished name of the entry.
+ ///
+ /// </summary>
+ /// <returns> The distinguished name of the entry.
+ /// </returns>
+ [CLSCompliantAttribute(false)]
+ virtual public System.String DN
+ {
+ get
+ {
+ return dn;
+ }
+
+ }
+ protected internal System.String dn;
+ protected internal LdapAttributeSet attrs;
+
+ /// <summary> Constructs an empty entry.</summary>
+ public LdapEntry():this(null, null)
+ {
+ }
+
+ /// <summary> Constructs a new entry with the specified distinguished name and with
+ /// an empty attribute set.
+ ///
+ /// </summary>
+ /// <param name="dn"> The distinguished name of the entry. The
+ /// value is not validated. An invalid distinguished
+ /// name will cause operations using this entry to fail.
+ ///
+ /// </param>
+ public LdapEntry(System.String dn):this(dn, null)
+ {
+ }
+
+ /// <summary> Constructs a new entry with the specified distinguished name and set
+ /// of attributes.
+ ///
+ /// </summary>
+ /// <param name="dn"> The distinguished name of the new entry. The
+ /// value is not validated. An invalid distinguished
+ /// name will cause operations using this entry to fail.
+ /// <br><br>
+ /// </param>
+ /// <param name="attrs"> The initial set of attributes assigned to the
+ /// entry.
+ /// </param>
+ public LdapEntry(System.String dn, LdapAttributeSet attrs)
+ {
+ if ((System.Object) dn == null)
+ {
+ dn = "";
+ }
+ if (attrs == null)
+ {
+ attrs = new LdapAttributeSet();
+ }
+ this.dn = dn;
+ this.attrs = attrs;
+ return ;
+ }
+
+ /// <summary> Returns the attributes matching the specified attrName.
+ ///
+ /// </summary>
+ /// <param name="attrName">The name of the attribute or attributes to return.
+ /// <br><br>
+ /// </param>
+ /// <returns> An array of LdapAttribute objects.
+ /// </returns>
+ public virtual LdapAttribute getAttribute(System.String attrName)
+ {
+ return attrs.getAttribute(attrName);
+ }
+
+ /// <summary> Returns the attribute set of the entry.
+ ///
+ /// <p>All base and subtype variants of all attributes are
+ /// returned. The LdapAttributeSet returned may be
+ /// empty if there are no attributes in the entry. </p>
+ ///
+ /// </summary>
+ /// <returns> The attribute set of the entry.
+ /// </returns>
+ public virtual LdapAttributeSet getAttributeSet()
+ {
+ return attrs;
+ }
+
+
+ /// <summary> Returns an attribute set from the entry, consisting of only those
+ /// attributes matching the specified subtypes.
+ ///
+ /// <p>The getAttributeSet method can be used to extract only
+ /// a particular language variant subtype of each attribute,
+ /// if it exists. The "subtype" may be, for example, "lang-ja", "binary",
+ /// or "lang-ja;phonetic". If more than one subtype is specified, separated
+ /// with a semicolon, only those attributes with all of the named
+ /// subtypes will be returned. The LdapAttributeSet returned may be
+ /// empty if there are no matching attributes in the entry. </p>
+ ///
+ /// </summary>
+ /// <param name="subtype"> One or more subtype specification(s), separated
+ /// with semicolons. The "lang-ja" and
+ /// "lang-en;phonetic" are valid subtype
+ /// specifications.
+ ///
+ /// </param>
+ /// <returns> An attribute set from the entry with the attributes that
+ /// match the specified subtypes or an empty set if no attributes
+ /// match.
+ /// </returns>
+ public virtual LdapAttributeSet getAttributeSet(System.String subtype)
+ {
+ return attrs.getSubset(subtype);
+ }
+
+ /// <summary> Compares this object with the specified object for order.
+ ///
+ /// <p>Ordering is determined by comparing normalized DN values
+ /// (see {@link LdapEntry#getDN() } and
+ /// {@link LdapDN#normalize(java.lang.String)}) using the
+ /// compareTo method of the String class. </p>
+ ///
+ /// </summary>
+ /// <param name="entry"> Entry to compare to
+ ///
+ /// </param>
+ /// <returns> A negative integer, zero, or a positive integer as this
+ /// object is less than, equal to, or greater than the specified object.
+ /// </returns>
+ public virtual int CompareTo(System.Object entry)
+ {
+ return LdapDN.normalize(this.dn).CompareTo(LdapDN.normalize(((LdapEntry) entry).dn));
+ }
+
+ /// <summary> Returns a string representation of this LdapEntry
+ ///
+ /// </summary>
+ /// <returns> a string representation of this LdapEntry
+ /// </returns>
+ public override System.String ToString()
+ {
+ System.Text.StringBuilder result = new System.Text.StringBuilder("LdapEntry: ");
+ if ((System.Object) dn != null)
+ {
+ result.Append(dn + "; ");
+ }
+ if (attrs != null)
+ {
+ result.Append(attrs.ToString());
+ }
+ return result.ToString();
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapException.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapException.cs
new file mode 100755
index 00000000000..37d346c8ce6
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapException.cs
@@ -0,0 +1,1142 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.LdapException.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+using Novell.Directory.Ldap.Utilclass;
+
+namespace Novell.Directory.Ldap
+{
+
+ /// <summary> Thrown to indicate that an Ldap exception has occurred. This is a general
+ /// exception which includes a message and an Ldap result code.
+ ///
+ /// <p>An LdapException can result from physical problems (such as
+ /// network errors) as well as problems with Ldap operations detected
+ /// by the server. For example, if an Ldap add operation fails because of a
+ /// duplicate entry, the server returns a result code.</p>
+ ///
+ /// <p>Five possible sources of information are available from LdapException:
+ /// <dl>
+ /// <dt>Result Code:</dt>
+ /// <dd>The <code>getResultCode</code> method returns a result code,
+ /// which can be compared against standard Ldap result codes. </dd>
+ /// <dt>Message:</dt>
+ /// <dd>The <code>getMessage</code> method returns a localized message
+ /// from the message resource that corresponds to the result code.
+ /// </dd>
+ /// <dt>Ldap server Message:</dt>
+ /// <dd>The <code>getLdapErrorMessage</code> method returns any error
+ /// message received from the Ldap server.</dd>
+ /// <dt>Matched DN:</dt>
+ /// <dd>The <code>getMatchedDN</code> method retrieves the part of a
+ /// submitted distinguished name which could be matched by the server</dd>
+ /// <dt>Root Cause:</dt>
+ /// <dd>The <code>getCause</code> method returns the a nested exception
+ /// that was the original cause for the error. </dd>
+ /// </dl></p>
+ ///
+ /// <p>The <code>toString</code> method returns a string containing all
+ /// the above sources of information, if they have a value.</p>
+ ///
+ /// <p>Exceptions generated by the API, i.e. that are not a result
+ /// of a server response, can be identified as <tt>instanceof
+ /// {@link LdapLocalException}</tt>
+ ///
+ /// <p>The following table lists the standard Ldap result codes.
+ /// See RFC2251 for a discussion of the meanings of the result codes.
+ /// The corresponding ASN.1 definition from RFC2251 is provided in parentheses.</p>
+ /// <table>
+ /// <tr>
+ /// <td><b>Value</b>
+ /// <td><b>Result Code</b>
+ /// </tr>
+ /// <tr><td> 0</td><td>{@link #SUCCESS} (success) </td></tr>
+ /// <tr><td> 1</td><td>{@link #OPERATIONS_ERROR} (operationsError) </td></tr>
+ /// <tr><td> 2</td><td>{@link #PROTOCOL_ERROR} (protocolError) </td></tr>
+ /// <tr><td> 3</td><td>{@link #TIME_LIMIT_EXCEEDED} (timeLimitExceeded) </td></tr>
+ /// <tr><td> 4</td><td>{@link #SIZE_LIMIT_EXCEEDED} (sizeLimitExceeded) </td></tr>
+ /// <tr><td> 5</td><td>{@link #COMPARE_FALSE} (compareFalse) </td></tr>
+ /// <tr><td> 6</td><td>{@link #COMPARE_TRUE} (compareTrue) </td></tr>
+ /// <tr><td> 7</td><td>{@link #AUTH_METHOD_NOT_SUPPORTED} (authMethodNotSupported) </td></tr>
+ /// <tr><td> 8</td><td>{@link #STRONG_AUTH_REQUIRED} (strongAuthRequired) </td></tr>
+ /// <tr><td> 10</td><td>{@link #REFERRAL} (referral) </td></tr>
+ /// <tr><td> 11</td><td>{@link #ADMIN_LIMIT_EXCEEDED} (adminLimitExceeded) </td></tr>
+ /// <tr><td> 12</td><td>{@link #UNAVAILABLE_CRITICAL_EXTENSION} (unavailableCriticalExtension) </td></tr>
+ /// <tr><td> 13</td><td>{@link #CONFIDENTIALITY_REQUIRED} (confidentialityRequired) </td></tr>
+ /// <tr><td> 14</td><td>{@link #SASL_BIND_IN_PROGRESS} (saslBindInProgress) </td></tr>
+ /// <tr><td> 16</td><td>{@link #NO_SUCH_ATTRIBUTE} (noSuchAttribute) </td></tr>
+ /// <tr><td> 17</td><td>{@link #UNDEFINED_ATTRIBUTE_TYPE} (undefinedAttributeType) </td></tr>
+ /// <tr><td> 18</td><td>{@link #INAPPROPRIATE_MATCHING} (inappropriateMatching) </td></tr>
+ /// <tr><td> 19</td><td>{@link #CONSTRAINT_VIOLATION} (constraintViolation) </td></tr>
+ /// <tr><td> 20</td><td>{@link #ATTRIBUTE_OR_VALUE_EXISTS} (AttributeOrValueExists) </td></tr>
+ /// <tr><td> 21</td><td>{@link #INVALID_ATTRIBUTE_SYNTAX} (invalidAttributeSyntax) </td></tr>
+ /// <tr><td> 32</td><td>{@link #NO_SUCH_OBJECT} (noSuchObject) </td></tr>
+ /// <tr><td> 33</td><td>{@link #ALIAS_PROBLEM} (aliasProblem) </td></tr>
+ /// <tr><td> 34</td><td>{@link #INVALID_DN_SYNTAX} (invalidDNSyntax) </td></tr>
+ /// <tr><td> 35</td><td>{@link #IS_LEAF} (isLeaf) </td></tr>
+ /// <tr><td> 36</td><td>{@link #ALIAS_DEREFERENCING_PROBLEM} (aliasDereferencingProblem) </td></tr>
+ /// <tr><td> 48</td><td>{@link #INAPPROPRIATE_AUTHENTICATION} (inappropriateAuthentication) </td></tr>
+ /// <tr><td> 49</td><td>{@link #INVALID_CREDENTIALS} (invalidCredentials) </td></tr>
+ /// <tr><td> 50</td><td>{@link #INSUFFICIENT_ACCESS_RIGHTS} (insufficientAccessRights) </td></tr>
+ /// <tr><td> 51</td><td>{@link #BUSY} (busy) </td></tr>
+ /// <tr><td> 52</td><td>{@link #UNAVAILABLE} (unavailable) </td></tr>
+ /// <tr><td> 53</td><td>{@link #UNWILLING_TO_PERFORM} (unwillingToPerform) </td></tr>
+ /// <tr><td> 54</td><td>{@link #LOOP_DETECT} (loopDetect) </td></tr>
+ /// <tr><td> 64</td><td>{@link #NAMING_VIOLATION} (namingViolation) </td></tr>
+ /// <tr><td> 65</td><td>{@link #OBJECT_CLASS_VIOLATION} (objectClassViolation) </td></tr>
+ /// <tr><td> 66</td><td>{@link #NOT_ALLOWED_ON_NONLEAF} (notAllowedOnNonLeaf) </td></tr>
+ /// <tr><td> 67</td><td>{@link #NOT_ALLOWED_ON_RDN} (notAllowedOnRDN) </td></tr>
+ /// <tr><td> 68</td><td>{@link #ENTRY_ALREADY_EXISTS} (entryAlreadyExists) </td></tr>
+ /// <tr><td> 69</td><td>{@link #OBJECT_CLASS_MODS_PROHIBITED} (objectClassModsProhibited) </td></tr>
+ /// <tr><td> 71</td><td>{@link #AFFECTS_MULTIPLE_DSAS} (affectsMultipleDSAs </td></tr>
+ /// <tr><td> 80</td><td>{@link #OTHER} (other) </td></tr>
+ /// </table>
+ ///
+ /// <p>Local errors, resulting from actions other than an operation on a
+ /// server.</p>
+ ///
+ /// <table>
+ /// <tr>
+ /// <td><b>Value</b>
+ /// <td><b>Result Code</b>
+ /// </tr>
+ /// <tr><td>81</td><td>{@link #SERVER_DOWN}</td></tr>
+ /// <tr><td>82</td><td>{@link #LOCAL_ERROR}</td></tr>
+ /// <tr><td>83</td><td>{@link #ENCODING_ERROR}</td></tr>
+ /// <tr><td>84</td><td>{@link #DECODING_ERROR}</td></tr>
+ /// <tr><td>85</td><td>{@link #Ldap_TIMEOUT}</td></tr>
+ /// <tr><td>86</td><td>{@link #AUTH_UNKNOWN}</td></tr>
+ /// <tr><td>87</td><td>{@link #FILTER_ERROR}</td></tr>
+ /// <tr><td>88</td><td>{@link #USER_CANCELLED}</td></tr>
+ /// <tr><td>90</td><td>{@link #NO_MEMORY}</td></tr>
+ /// <tr><td>91</td><td>{@link #CONNECT_ERROR}</td></tr>
+ /// <tr><td>92</td><td>{@link #Ldap_NOT_SUPPORTED}</td></tr>
+ /// <tr><td>93</td><td>{@link #CONTROL_NOT_FOUND}</td></tr>
+ /// <tr><td>94</td><td>{@link #NO_RESULTS_RETURNED}</td></tr>
+ /// <tr><td>95</td><td>{@link #MORE_RESULTS_TO_RETURN}</td></tr>
+ /// <tr><td>96</td><td>{@link #CLIENT_LOOP}</td></tr>
+ /// <tr><td>97</td><td>{@link #REFERRAL_LIMIT_EXCEEDED}</td></tr>
+ /// <tr><td>100</td><td>{@link #INVALID_RESPONSE}</td></tr>
+ /// <tr><td>101</td><td>{@link #AMBIGUOUS_RESPONSE}</td></tr>
+ /// <tr><td>112</td><td>{@link #TLS_NOT_SUPPORTED}</td></tr>
+ /// </table>
+ /// </summary>
+
+ public class LdapException:System.Exception
+ {
+ /// <summary> Returns the error message from the Ldap server, if this message is
+ /// available (that is, if this message was set). If the message was not set,
+ /// this method returns null.
+ ///
+ /// </summary>
+ /// <returns> The error message or null if the message was not set.
+ ///
+ /// </returns>
+ virtual public System.String LdapErrorMessage
+ {
+ get
+ {
+ if (((System.Object) serverMessage != null) && (serverMessage.Length == 0))
+ {
+ return null;
+ }
+ return serverMessage;
+ }
+
+ }
+ /// <summary> Returns the lower level Exception which caused the failure, if any.
+ /// For example, an IOException with additional information may be returned
+ /// on a CONNECT_ERROR failure.
+ /// </summary>
+ virtual public System.Exception Cause
+ {
+ get
+ {
+ return rootException;
+ }
+
+ }
+ /// <summary> Returns the result code from the exception.
+ ///
+ /// <p>The codes are defined as <code>public final static int</code> members
+ /// of the Ldap Exception class. If the exception is a
+ /// result of error information returned from a directory operation, the
+ /// code will be one of those defined for the class. Otherwise, a local error
+ /// code is returned. </p>
+ /// </summary>
+ virtual public int ResultCode
+ {
+ get
+ {
+ return resultCode;
+ }
+
+ }
+ /// <summary> Returns the part of a submitted distinguished name which could be
+ /// matched by the server.
+ ///
+ /// </p>If the exception was caused by a local error, such as no server
+ /// available, the return value is null. If the exception resulted from
+ /// an operation being executed on a server, the value is an empty string
+ /// except when the result of the operation was one of the following:</p>
+ /// <ul>
+ /// <li>NO_SUCH_OBJECT</li>
+ /// <li>ALIAS_PROBLEM</li>
+ /// <li>INVALID_DN_SYNTAX</li>
+ /// <li>ALIAS_DEREFERENCING_PROBLEM</li>
+ /// </ul>
+ ///
+ /// </summary>
+ /// <returns> The part of a submitted distinguished name which could be
+ /// matched by the server or null if the error is a local error.
+ /// </returns>
+ virtual public System.String MatchedDN
+ {
+ get
+ {
+ return matchedDN;
+ }
+
+ }
+ public override System.String Message
+ {
+ get
+ {
+ return resultCodeToString();
+ }
+
+ }
+ /* public override System.String Message
+ {
+ get
+ {
+ return resultCodeToString();
+ }
+
+ }
+ */
+ // The Result Code
+ private int resultCode = 0;
+ // The localized message
+ private System.String messageOrKey = null;
+ // The arguments associated with the localized message
+ private System.Object[] arguments = null;
+ // The Matched DN
+ private System.String matchedDN = null;
+ // The Root Cause
+ private System.Exception rootException = null;
+ // A message from the server
+ private System.String serverMessage = null;
+
+ /// <summary>Indicates the requested client operation completed successfully.
+ ///
+ /// <p>SUCCESS = 0<p/>
+ /// </summary>
+ public const int SUCCESS = 0;
+
+ /// <summary> Indicates an internal error.
+ ///
+ /// <p>The server is unable to respond with a more specific error and is
+ /// also unable to properly respond to a request. It does not indicate
+ /// that the client has sent an erroneous message.</p>
+ ///
+ /// <p>OPERATIONS_ERROR = 1</p>
+ /// </summary>
+ public const int OPERATIONS_ERROR = 1;
+
+ /// <summary> Indicates that the server has received an invalid or malformed request
+ /// from the client.
+ ///
+ /// <p>PROTOCOL_ERROR = 2</p>
+ /// </summary>
+ public const int PROTOCOL_ERROR = 2;
+
+ /// <summary> Indicates that the operation's time limit specified by either the
+ /// client or the server has been exceeded.
+ ///
+ /// <p>On search operations, incomplete results are returned.</p>
+ ///
+ /// <p>TIME_LIMIT_EXCEEDED = 3</p>
+ /// </summary>
+ public const int TIME_LIMIT_EXCEEDED = 3;
+
+ /// <summary> Indicates that in a search operation, the size limit specified by
+ /// the client or the server has been exceeded. Incomplete results are
+ /// returned.
+ ///
+ /// <p>SIZE_LIMIT_EXCEEDED = 4</p>
+ /// </summary>
+ public const int SIZE_LIMIT_EXCEEDED = 4;
+
+ /// <summary> Does not indicate an error condition. Indicates that the results of
+ /// a compare operation are false.
+ ///
+ /// <p>COMPARE_FALSE = 5</p>
+ /// </summary>
+ public const int COMPARE_FALSE = 5;
+
+ /// <summary> Does not indicate an error condition. Indicates that the results of a
+ /// compare operation are true.
+ ///
+ /// <p>COMPARE_TRUE = 6</p>
+ /// </summary>
+ public const int COMPARE_TRUE = 6;
+
+ /// <summary> Indicates that during a bind operation the client requested an
+ /// authentication method not supported by the Ldap server.
+ ///
+ /// <p>AUTH_METHOD_NOT_SUPPORTED = 7</p>
+ /// </summary>
+ public const int AUTH_METHOD_NOT_SUPPORTED = 7;
+
+ /// <summary>Indicates a problem with the level of authentication.
+ ///
+ /// <p>One of the following has occurred:
+ /// <ul>
+ /// <li>In bind requests, the Ldap server accepts only strong
+ /// authentication.</li>
+ /// <li>In a client request, the client requested an operation such as delete
+ /// that requires strong authentication.</li>
+ /// <li>In an unsolicited notice of disconnection, the Ldap server discovers
+ /// the security protecting the communication between the client and
+ /// server has unexpectedly failed or been compromised.</li>
+ /// </ul>
+ /// <p>STRONG_AUTH_REQUIRED = 8</p>
+ /// </summary>
+ public const int STRONG_AUTH_REQUIRED = 8;
+
+ /// <summary> Returned by some Ldap servers to Ldapv2 clients to indicate that a referral
+ /// has been returned in the error string.
+ ///
+ /// <p>Ldap_PARTIAL_RESULTS = 9</p>
+ /// </summary>
+ public const int Ldap_PARTIAL_RESULTS = 9;
+
+ /// <summary> Does not indicate an error condition. In Ldapv3, indicates that the server
+ /// does not hold the target entry of the request, but that the servers in the
+ /// referral field may.
+ ///
+ /// <p>REFERRAL = 10</p>
+ /// </summary>
+ public const int REFERRAL = 10;
+
+ /// <summary> Indicates that an Ldap server limit set by an administrative authority
+ /// has been exceeded.
+ ///
+ /// <p>ADMIN_LIMIT_EXCEEDED = 11</p>
+ /// </summary>
+ public const int ADMIN_LIMIT_EXCEEDED = 11;
+
+ /// <summary> Indicates that the Ldap server was unable to satisfy a request because
+ /// one or more critical extensions were not available.
+ ///
+ /// <p>Either the server does not support the control or the control is not
+ /// appropriate for the operation type.</p>
+ ///
+ /// <p>UNAVAILABLE_CRITICAL_EXTENSION = 12</p>
+ /// </summary>
+ public const int UNAVAILABLE_CRITICAL_EXTENSION = 12;
+
+ /// <summary> Indicates that the session is not protected by a protocol such as
+ /// Transport Layer Security (TLS), which provides session confidentiality.
+ ///
+ /// <p>CONFIDENTIALITY_REQUIRED = 13</p>
+ /// </summary>
+ public const int CONFIDENTIALITY_REQUIRED = 13;
+
+ /// <summary> Does not indicate an error condition, but indicates that the server is
+ /// ready for the next step in the process. The client must send the server
+ /// the same SASL mechanism to continue the process.
+ ///
+ /// <p>SASL_BIND_IN_PROGRESS = 14</p>
+ /// </summary>
+ public const int SASL_BIND_IN_PROGRESS = 14;
+
+ /// <summary> Indicates that the attribute specified in the modify or compare
+ /// operation does not exist in the entry.
+ ///
+ /// <p>NO_SUCH_ATTRIBUTE = 16</p>
+ /// </summary>
+ public const int NO_SUCH_ATTRIBUTE = 16;
+
+ /// <summary> Indicates that the attribute specified in the modify or add operation
+ /// does not exist in the Ldap server's schema.
+ ///
+ /// <p>UNDEFINED_ATTRIBUTE_TYPE = 17</p>
+ /// </summary>
+ public const int UNDEFINED_ATTRIBUTE_TYPE = 17;
+
+ /// <summary> Indicates that the matching rule specified in the search filter does
+ /// not match a rule defined for the attribute's syntax.
+ ///
+ /// <p>INAPPROPRIATE_MATCHING = 18</p>
+ /// </summary>
+ public const int INAPPROPRIATE_MATCHING = 18;
+
+ /// <summary> Indicates that the attribute value specified in a modify, add, or
+ /// modify DN operation violates constraints placed on the attribute. The
+ /// constraint can be one of size or content (for example, string only,
+ /// no binary data).
+ ///
+ /// <p>CONSTRAINT_VIOLATION = 19</p>
+ /// </summary>
+ public const int CONSTRAINT_VIOLATION = 19;
+
+ /// <summary> Indicates that the attribute value specified in a modify or add
+ /// operation already exists as a value for that attribute.
+ ///
+ /// <p>ATTRIBUTE_OR_VALUE_EXISTS = 20</p>
+ /// </summary>
+ public const int ATTRIBUTE_OR_VALUE_EXISTS = 20;
+
+ /// <summary> Indicates that the attribute value specified in an add, compare, or
+ /// modify operation is an unrecognized or invalid syntax for the attribute.
+ ///
+ /// <p>INVALID_ATTRIBUTE_SYNTAX = 21</p>
+ /// </summary>
+ public const int INVALID_ATTRIBUTE_SYNTAX = 21;
+
+ /// <summary> Indicates the target object cannot be found.
+ ///
+ /// <p>This code is not returned on the following operations:</p>
+ /// <ul>
+ /// <li>Search operations that find the search base but cannot find any
+ /// entries that match the search filter.</li>
+ /// <li>Bind operations.</li>
+ /// </ul>
+ /// <p>NO_SUCH_OBJECT = 32</p>
+ /// </summary>
+ public const int NO_SUCH_OBJECT = 32;
+
+ /// <summary> Indicates that an error occurred when an alias was dereferenced.
+ ///
+ /// <p>ALIAS_PROBLEM = 33</p>
+ /// </summary>
+ public const int ALIAS_PROBLEM = 33;
+
+ /// <summary> Indicates that the syntax of the DN is incorrect.
+ ///
+ /// <p>If the DN syntax is correct, but the Ldap server's structure
+ /// rules do not permit the operation, the server returns
+ /// Ldap_UNWILLING_TO_PERFORM. </p>
+ ///
+ /// <p>INVALID_DN_SYNTAX = 34</p>
+ /// </summary>
+ public const int INVALID_DN_SYNTAX = 34;
+
+ /// <summary> Indicates that the specified operation cannot be performed on a
+ /// leaf entry.
+ ///
+ /// <p>This code is not currently in the Ldap specifications, but is
+ /// reserved for this constant.</p>
+ ///
+ /// <p>IS_LEAF = 35</p>
+ /// </summary>
+ public const int IS_LEAF = 35;
+
+ /// <summary> Indicates that during a search operation, either the client does not
+ /// have access rights to read the aliased object's name or dereferencing
+ /// is not allowed.
+ ///
+ /// <p>ALIAS_DEREFERENCING_PROBLEM = 36</p>
+ /// </summary>
+ public const int ALIAS_DEREFERENCING_PROBLEM = 36;
+
+ /// <summary> Indicates that during a bind operation, the client is attempting to use
+ /// an authentication method that the client cannot use correctly.
+ ///
+ /// <p> For example, either of the following cause this error:</p>
+ /// <ul>
+ /// <li>The client returns simple credentials when strong credentials are
+ /// required.
+ /// <li>The client returns a DN and a password for a simple bind when the
+ /// entry does not have a password defined.
+ /// </ul>
+ /// <p>INAPPROPRIATE_AUTHENTICATION = 48</p>
+ /// </summary>
+ public const int INAPPROPRIATE_AUTHENTICATION = 48;
+
+ /// <summary> Indicates that invalid information was passed during a bind operation.
+ ///
+ /// <p>One of the following occurred:
+ /// <ul>
+ /// <li> The client passed either an incorrect DN or password.</li>
+ /// <li> The password is incorrect because it has expired, intruder detection
+ /// has locked the account, or some other similar reason.</li>
+ /// </ul>
+ /// <p>INVALID_CREDENTIALS = 49</p>
+ /// </summary>
+ public const int INVALID_CREDENTIALS = 49;
+
+ /// <summary> Indicates that the caller does not have sufficient rights to perform
+ /// the requested operation.
+ ///
+ /// <p>INSUFFICIENT_ACCESS_RIGHTS = 50</p>
+ /// </summary>
+ public const int INSUFFICIENT_ACCESS_RIGHTS = 50;
+
+ /// <summary> Indicates that the Ldap server is too busy to process the client request
+ /// at this time, but if the client waits and resubmits the request, the
+ /// server may be able to process it then.
+ ///
+ /// <p>BUSY = 51</p>
+ /// </summary>
+ public const int BUSY = 51;
+
+ /// <summary> Indicates that the Ldap server cannot process the client's bind
+ /// request, usually because it is shutting down.
+ ///
+ /// <p>UNAVAILABLE = 52</p>
+ /// </summary>
+ public const int UNAVAILABLE = 52;
+
+ /// <summary> Indicates that the Ldap server cannot process the request because of
+ /// server-defined restrictions.
+ ///
+ /// <p>This error is returned for the following reasons:</p>
+ /// <ul>
+ /// <li>The add entry request violates the server's structure rules.</li>
+ /// <li>The modify attribute request specifies attributes that users
+ /// cannot modify.</li>
+ /// </ul>
+ /// <p>UNWILLING_TO_PERFORM = 53</p>
+ /// </summary>
+ public const int UNWILLING_TO_PERFORM = 53;
+
+ /// <summary> Indicates that the client discovered an alias or referral loop,
+ /// and is thus unable to complete this request.
+ ///
+ /// <p>LOOP_DETECT = 54</p>
+ /// </summary>
+ public const int LOOP_DETECT = 54;
+
+ /// <summary> Indicates that the add or modify DN operation violates the schema's
+ /// structure rules.
+ ///
+ /// <p>For example,</p>
+ /// <ul>
+ /// <li>The request places the entry subordinate to an alias.</li>
+ /// <li>The request places the entry subordinate to a container that
+ /// is forbidden by the containment rules.</li>
+ /// <li>The RDN for the entry uses a forbidden attribute type.</li>
+ ///
+ /// <p>NAMING_VIOLATION = 64</p>
+ /// </summary>
+ public const int NAMING_VIOLATION = 64;
+
+ /// <summary> Indicates that the add, modify, or modify DN operation violates the
+ /// object class rules for the entry.
+ ///
+ /// <p>For example, the following types of request return this error:</p>
+ /// <ul>
+ /// <li>The add or modify operation tries to add an entry without a value
+ /// for a required attribute.</li>
+ /// <li>The add or modify operation tries to add an entry with a value for
+ /// an attribute which the class definition does not contain.</li>
+ /// <li>The modify operation tries to remove a required attribute without
+ /// removing the auxiliary class that defines the attribute as required.</li>
+ /// </ul>
+ /// <p>OBJECT_CLASS_VIOLATION = 65</p>
+ /// </summary>
+ public const int OBJECT_CLASS_VIOLATION = 65;
+
+ /// <summary> Indicates that the requested operation is permitted only on leaf entries.
+ ///
+ /// <p>For example, the following types of requests return this error:</p>
+ /// <ul>
+ /// <li>The client requests a delete operation on a parent entry.</li>
+ /// <li> The client request a modify DN operation on a parent entry.</li>
+ /// </ul>
+ /// <p>NOT_ALLOWED_ON_NONLEAF = 66</p>
+ /// </summary>
+ public const int NOT_ALLOWED_ON_NONLEAF = 66;
+
+ /// <summary> Indicates that the modify operation attempted to remove an attribute
+ /// value that forms the entry's relative distinguished name.
+ ///
+ /// <p>NOT_ALLOWED_ON_RDN = 67</p>
+ /// </summary>
+ public const int NOT_ALLOWED_ON_RDN = 67;
+
+ /// <summary> Indicates that the add operation attempted to add an entry that already
+ /// exists, or that the modify operation attempted to rename an entry to the
+ /// name of an entry that already exists.
+ ///
+ /// <p>ENTRY_ALREADY_EXISTS = 68</p>
+ /// </summary>
+ public const int ENTRY_ALREADY_EXISTS = 68;
+
+ /// <summary> Indicates that the modify operation attempted to modify the structure
+ /// rules of an object class.
+ ///
+ /// <p>OBJECT_CLASS_MODS_PROHIBITED = 69</p>
+ /// </summary>
+ public const int OBJECT_CLASS_MODS_PROHIBITED = 69;
+
+ /// <summary> Indicates that the modify DN operation moves the entry from one Ldap
+ /// server to another and thus requires more than one Ldap server.
+ ///
+ /// <p>AFFECTS_MULTIPLE_DSAS = 71</p>
+ /// </summary>
+ public const int AFFECTS_MULTIPLE_DSAS = 71;
+
+ /// <summary> Indicates an unknown error condition.
+ ///
+ /// <p>OTHER = 80</p>
+ /// </summary>
+ public const int OTHER = 80;
+
+ /////////////////////////////////////////////////////////////////////////////
+ // Local Errors, resulting from actions other than an operation on a server
+ /////////////////////////////////////////////////////////////////////////////
+
+ /// <summary> Indicates that the Ldap libraries cannot establish an initial connection
+ /// with the Ldap server. Either the Ldap server is down or the specified
+ /// host name or port number is incorrect.
+ ///
+ /// <p>SERVER_DOWN = 81</p>
+ /// </summary>
+ public const int SERVER_DOWN = 81;
+
+ /// <summary> Indicates that the Ldap client has an error. This is usually a failed
+ /// dynamic memory allocation error.
+ ///
+ /// <p>LOCAL_ERROR = 82</p>
+ /// </summary>
+ public const int LOCAL_ERROR = 82;
+
+ /// <summary> Indicates that the Ldap client encountered errors when encoding an
+ /// Ldap request intended for the Ldap server.
+ ///
+ /// <p>ENCODING_ERROR = 83</p>
+ /// </summary>
+ public const int ENCODING_ERROR = 83;
+
+ /// <summary> Indicates that the Ldap client encountered errors when decoding an
+ /// Ldap response from the Ldap server.
+ ///
+ /// <p>DECODING_ERROR = 84</p>
+ /// </summary>
+ public const int DECODING_ERROR = 84;
+
+ /// <summary> Indicates that the time limit of the Ldap client was exceeded while
+ /// waiting for a result.
+ ///
+ /// <p>Ldap_TIMEOUT = 85</p>
+ /// </summary>
+ public const int Ldap_TIMEOUT = 85;
+
+ /// <summary> Indicates that a bind method was called with an unknown
+ /// authentication method.
+ ///
+ /// <p>AUTH_UNKNOWN = 86</p>
+ /// </summary>
+ public const int AUTH_UNKNOWN = 86;
+
+ /// <summary> Indicates that the search method was called with an invalid
+ /// search filter.
+ ///
+ /// <p>FILTER_ERROR = 87</p>
+ /// </summary>
+ public const int FILTER_ERROR = 87;
+
+ /// <summary> Indicates that the user cancelled the Ldap operation.
+ ///
+ /// <p>USER_CANCELLED = 88</p>
+ /// </summary>
+ public const int USER_CANCELLED = 88;
+
+
+ /// <summary> Indicates that a dynamic memory allocation method failed when calling
+ /// an Ldap method.
+ ///
+ /// <p>NO_MEMORY = 90</p>
+ /// </summary>
+ public const int NO_MEMORY = 90;
+
+ /// <summary> Indicates that the Ldap client has lost either its connection or
+ /// cannot establish a connection to the Ldap server.
+ ///
+ /// <p>CONNECT_ERROR = 91</p>
+ /// </summary>
+ public const int CONNECT_ERROR = 91;
+
+ /// <summary> Indicates that the requested functionality is not supported by the
+ /// client. For example, if the Ldap client is established as an Ldapv2
+ /// client, the libraries set this error code when the client requests
+ /// Ldapv3 functionality.
+ ///
+ /// <p>Ldap_NOT_SUPPORTED = 92</p>
+ /// </summary>
+ public const int Ldap_NOT_SUPPORTED = 92;
+
+ /// <summary> Indicates that the client requested a control that the libraries
+ /// cannot find in the list of supported controls sent by the Ldap server.
+ ///
+ /// <p>CONTROL_NOT_FOUND = 93</p>
+ /// </summary>
+ public const int CONTROL_NOT_FOUND = 93;
+
+ /// <summary> Indicates that the Ldap server sent no results.
+ ///
+ /// <p>NO_RESULTS_RETURNED = 94</p>
+ /// </summary>
+ public const int NO_RESULTS_RETURNED = 94;
+
+ /// <summary> Indicates that more results are chained in the result message.
+ ///
+ /// <p>MORE_RESULTS_TO_RETURN = 95</p>
+ /// </summary>
+ public const int MORE_RESULTS_TO_RETURN = 95;
+
+ /// <summary> Indicates the Ldap libraries detected a loop. Usually this happens
+ /// when following referrals.
+ ///
+ /// <p>CLIENT_LOOP = 96</p>
+ /// </summary>
+ public const int CLIENT_LOOP = 96;
+
+ /// <summary> Indicates that the referral exceeds the hop limit. The default hop
+ /// limit is ten.
+ ///
+ /// <p>The hop limit determines how many servers the client can hop through
+ /// to retrieve data. For example, suppose the following conditions:</p>
+ /// <ul>
+ /// <li>Suppose the hop limit is two.</li>
+ /// <li> If the referral is to server D which can be contacted only through
+ /// server B (1 hop) which contacts server C (2 hops) which contacts
+ /// server D (3 hops).</li>
+ /// </ul>
+ /// <p> With these conditions, the hop limit is exceeded and the Ldap
+ /// libraries set this code.</p>
+ ///
+ /// <p>REFERRAL_LIMIT_EXCEEDED = 97</p>
+ /// </summary>
+ public const int REFERRAL_LIMIT_EXCEEDED = 97;
+
+ /// <summary> Indicates that the server response to a request is invalid.
+ ///
+ /// <p>INVALID_RESPONSE = 100</p>
+ /// </summary>
+ public const int INVALID_RESPONSE = 100;
+
+ /// <summary> Indicates that the server response to a request is ambiguous.
+ ///
+ /// <p>AMBIGUOUS_RESPONSE = 101</p>
+ /// </summary>
+ public const int AMBIGUOUS_RESPONSE = 101;
+
+ /// <summary> Indicates that TLS is not supported on the server.
+ ///
+ /// <p>TLS_NOT_SUPPORTED = 112</p>
+ /// </summary>
+ public const int TLS_NOT_SUPPORTED = 112;
+
+ /*
+ * Note: Error strings have been pulled out into
+ * ResultCodeMessages.properties
+ */
+
+ /// <summary> Constructs a default exception with no specific error information.</summary>
+ public LdapException():base()
+ {
+ return ;
+ }
+
+ /// <summary> <p>Constructs an exception with a detailed message obtained from the
+ /// specified <code>MessageOrKey</code> String, the result code,
+ /// and a server meessage.</p>
+ ///
+ /// <p>The String is used either as a message key to obtain a localized
+ /// messsage from ExceptionMessages, or if there is no key in the
+ /// resource matching the text, it is used as the detailed message itself.</p>
+ ///
+ /// </summary>
+ /// <param name="messageOrKey"> Key to addition result information, a key into
+ /// ExceptionMessages, or the information
+ /// itself if the key doesn't exist.
+ /// <br><br>
+ /// </param>
+ /// <param name="resultCode"> The result code returned.
+ /// <br><br>
+ /// </param>
+ /// <param name="serverMsg"> Error message specifying additional information
+ /// from the server
+ /// </param>
+ public LdapException(System.String messageOrKey, int resultCode, System.String serverMsg):this(messageOrKey, null, resultCode, serverMsg, null, null)
+ {
+ return ;
+ }
+
+ /// <summary> <p>Constructs an exception with a detailed message obtained from the
+ /// specified <code>MessageOrKey</code> String and modifying arguments.
+ /// Additional parameters specify the result code and server message.</p>
+ ///
+ /// <p>The String is used either as a message key to obtain a localized
+ /// messsage from ExceptionMessages, or if there is no key in the
+ /// resource matching the text, it is used as the detailed message itself.</p>
+ ///
+ /// <p>The message in the default locale is built with the supplied arguments,
+ /// which are saved to be used for building messages for other locales.</p>
+ ///
+ /// </summary>
+ /// <param name="messageOrKey"> Key to addition result information, a key into
+ /// ExceptionMessages, or the information
+ /// itself if the key doesn't exist.
+ /// <br><br>
+ /// </param>
+ /// <param name="arguments"> The modifying arguments to be included in the
+ /// message string.
+ /// <br><br>
+ /// </param>
+ /// <param name="serverMsg"> Error message specifying additional information
+ /// from the server
+ /// <br><br>
+ /// </param>
+ /// <param name="resultCode"> The result code returned.
+ /// </param>
+ public LdapException(System.String messageOrKey, System.Object[] arguments, int resultCode, System.String serverMsg):this(messageOrKey, arguments, resultCode, serverMsg, null, null)
+ {
+ return ;
+ }
+
+ /// <summary> <p>Constructs an exception with a detailed message obtained from the
+ /// specified <code>MessageOrKey</code> String.
+ /// Additional parameters specify the result code, the server message, and a
+ /// rootException which is the underlying cause of an error on the client.<p>
+ ///
+ /// <p>The String is used either as a message key to obtain a localized
+ /// messsage from ExceptionMessages, or if there is no key in the
+ /// resource matching the text, it is used as the detailed message itself.</p>
+ ///
+ /// </summary>
+ /// <param name="messageOrKey"> Key to addition result information, a key into
+ /// ExceptionMessages, or the information
+ /// itself if the key doesn't exist.
+ /// <br><br>
+ /// </param>
+ /// <param name="resultCode"> The result code returned.
+ /// <br><br>
+ /// </param>
+ /// <param name="serverMsg"> Error message specifying additional information
+ /// from the server
+ /// <br><br>
+ /// </param>
+ /// <param name="rootException"> A throwable which is the underlying cause
+ /// of the LdapException.
+ /// </param>
+ public LdapException(System.String messageOrKey, int resultCode, System.String serverMsg, System.Exception rootException):this(messageOrKey, null, resultCode, serverMsg, null, rootException)
+ {
+ return ;
+ }
+
+ /// <summary> <p>Constructs an exception with a detailed message obtained from the
+ /// specified <code>MessageOrKey</code> String and modifying arguments.
+ /// Additional parameters specify the result code, the server message,
+ /// and a rootException which is the underlying cause of an error
+ /// on the client.</p>
+ ///
+ /// <p>The String is used either as a message key to obtain a localized
+ /// messsage from ExceptionMessages, or if there is no key in the
+ /// resource matching the text, it is used as the detailed message itself.</p>
+ ///
+ /// <p>The message in the default locale is built with the supplied arguments,
+ /// which are saved to be used for building messages for other locales.</p>
+ ///
+ /// </summary>
+ /// <param name="messageOrKey"> Key to addition result information, a key into
+ /// ExceptionMessages, or the information
+ /// itself if the key doesn't exist.
+ /// <br><br>
+ /// </param>
+ /// <param name="arguments"> The modifying arguments to be included in the
+ /// message string.
+ /// <br><br>
+ /// </param>
+ /// <param name="resultCode"> The result code returned.
+ /// <br><br>
+ /// </param>
+ /// <param name="serverMsg"> Error message specifying additional information
+ /// from the server
+ /// <br><br>
+ /// </param>
+ /// <param name="rootException"> A throwable which is the underlying cause
+ /// of the LdapException.
+ /// </param>
+ public LdapException(System.String messageOrKey, System.Object[] arguments, int resultCode, System.String serverMsg, System.Exception rootException):this(messageOrKey, arguments, resultCode, serverMsg, null, rootException)
+ {
+ return ;
+ }
+
+ /// <summary> <p>Constructs an exception with a detailed message obtained from the
+ /// specified <code>MessageOrKey</code> String.
+ /// Additional parameters specify the result code, the message returned
+ /// from the server, and a matchedDN returned from the server.</p>
+ ///
+ /// <p>The String is used either as a message key to obtain a localized
+ /// messsage from ExceptionMessages, or if there is no key in the
+ /// resource matching the text, it is used as the detailed message itself.</p>
+ ///
+ /// </summary>
+ /// <param name="messageOrKey"> Key to addition result information, a key into
+ /// ExceptionMessages, or the information
+ /// itself if the key doesn't exist.
+ /// <br><br>
+ /// </param>
+ /// <param name="resultCode"> The result code returned.
+ /// <br><br>
+ /// </param>
+ /// <param name="serverMsg"> Error message specifying additional information
+ /// from the server
+ /// <br><br>
+ /// </param>
+ /// <param name="matchedDN"> The maximal subset of a specified DN which could
+ /// be matched by the server on a search operation.
+ /// </param>
+ public LdapException(System.String messageOrKey, int resultCode, System.String serverMsg, System.String matchedDN):this(messageOrKey, null, resultCode, serverMsg, matchedDN, null)
+ {
+ return ;
+ }
+
+ /// <summary> <p>Constructs an exception with a detailed message obtained from the
+ /// specified <code>MessageOrKey</code> String and modifying arguments.
+ /// Additional parameters specify the result code, a message returned from
+ /// the server, and a matchedDN returned from the server.</p>
+ ///
+ /// <p>The String is used either as a message key to obtain a localized
+ /// messsage from ExceptionMessages, or if there is no key in the
+ /// resource matching the text, it is used as the detailed message itself.</p>
+ ///
+ /// <p>The message in the default locale is built with the supplied arguments,
+ /// which are saved to be used for building messages for other locales.</p>
+ ///
+ /// </summary>
+ /// <param name="messageOrKey"> Key to addition result information, a key into
+ /// ExceptionMessages, or the information
+ /// itself if the key doesn't exist.
+ /// <br><br>
+ /// </param>
+ /// <param name="arguments"> The modifying arguments to be included in the
+ /// message string.
+ /// <br><br>
+ /// </param>
+ /// <param name="resultCode"> The result code returned.
+ /// <br><br>
+ /// </param>
+ /// <param name="serverMsg"> Error message specifying additional information
+ /// from the server
+ /// <br><br>
+ /// </param>
+ /// <param name="matchedDN"> The maximal subset of a specified DN which could
+ /// be matched by the server on a search operation.
+ /// </param>
+ public LdapException(System.String messageOrKey, System.Object[] arguments, int resultCode, System.String serverMsg, System.String matchedDN):this(messageOrKey, arguments, resultCode, serverMsg, matchedDN, null)
+ {
+ return ;
+ }
+
+ /// <summary> <p>Constructs an exception with a detailed message obtained from the
+ /// specified <code>MessageOrKey</code> String and modifying arguments.
+ /// Additional parameters specify the result code, a message returned
+ /// from the server, a matchedDN returned from
+ /// the server, and a rootException which is the underlying cause of an error
+ /// on the client.</p>
+ ///
+ /// <p>The String is used either as a message key to obtain a localized
+ /// messsage from ExceptionMessages, or if there is no key in the
+ /// resource matching the text, it is used as the detailed message itself.</p>
+ ///
+ /// <p>The message in the default locale is built with the supplied arguments,
+ /// which are saved to be used for building messages for other locales.</p>
+ ///
+ /// </summary>
+ /// <param name="messageOrKey"> Key to addition result information, a key into
+ /// ExceptionMessages, or the information
+ /// itself if the key doesn't exist.
+ /// <br><br>
+ /// </param>
+ /// <param name="arguments"> The modifying arguments to be included in the
+ /// message string.
+ /// <br><br>
+ /// </param>
+ /// <param name="resultCode"> The result code returned.
+ /// <br><br>
+ /// </param>
+ /// <param name="serverMsg"> Error message specifying additional information
+ /// from the server
+ /// <br><br>
+ /// </param>
+ /// <param name="rootException"> A throwable which is the underlying cause
+ /// of the LdapException.
+ /// <br><br>
+ /// </param>
+ /// <param name="matchedDN"> The maximal subset of a specified DN which could
+ /// be matched by the server on a search operation.
+ /// </param>
+ /* package */
+ internal LdapException(System.String messageOrKey, System.Object[] arguments, int resultCode, System.String serverMsg, System.String matchedDN, System.Exception rootException)
+ //:base(Novell.Directory.Ldap.Utilclass.ResourcesHandler.getMessage(messageOrKey, arguments))
+ //Once resorcehandler starts working properly need to uncomment
+ {
+ this.messageOrKey = messageOrKey;
+ this.arguments = arguments;
+ this.resultCode = resultCode;
+ this.rootException = rootException;
+ this.matchedDN = matchedDN;
+ this.serverMessage = serverMsg;
+ return ;
+ }
+
+ /// <summary> Returns a string representing the result code in the default
+ /// locale.
+ ///
+ /// </summary>
+ /// <returns> The message for the result code in the LdapException object.
+ /// </returns>
+ public virtual System.String resultCodeToString()
+ {
+ return ResourcesHandler.getResultString(resultCode);
+ }
+
+ /// <summary> Returns a string representing the specified result code in the default
+ /// locale.
+ ///
+ /// </summary>
+ /// <param name="code"> The result code for which a message is to be returned.
+ ///
+ /// </param>
+ /// <returns> The message corresponding to the specified result code, or
+ /// or null if the message is not available for the default locale.
+ /// </returns>
+ public static System.String resultCodeToString(int code)
+ {
+ return ResourcesHandler.getResultString(code);
+ }
+
+ /// <summary> Returns a string representing the result code in the
+ /// specified locale.
+ ///
+ /// </summary>
+ /// <param name="locale">The locale in which to render the error message.
+ ///
+ /// </param>
+ /// <returns> A message corresponding to the result code in the
+ /// specified locale, or null if the message is not available
+ /// for the requested locale.
+ /// </returns>
+ public virtual System.String resultCodeToString(System.Globalization.CultureInfo locale)
+ {
+ return ResourcesHandler.getResultString(resultCode, locale);
+ }
+
+ /// <summary> Returns a string representing the specified error code in the
+ /// specified locale.
+ ///
+ /// </summary>
+ /// <param name="code"> The result code for which a message is to be
+ /// returned.
+ /// <br><br>
+ /// </param>
+ /// <param name="locale"> The locale in which to render the message.
+ ///
+ /// </param>
+ /// <returns> A message corresponding to the result code in the
+ /// specified locale, or null if the message is not available
+ /// for the requested locale.
+ /// </returns>
+ public static System.String resultCodeToString(int code, System.Globalization.CultureInfo locale)
+ {
+ return ResourcesHandler.getResultString(code, locale);
+ }
+
+ /// <summary> returns a string of information about the exception and the
+ /// the nested exceptions, if any.
+ /// </summary>
+ public override System.String ToString()
+ {
+ return getExceptionString("LdapException");
+ }
+
+ /// <summary> builds a string of information about the exception and the
+ /// the nested exceptions, if any.
+ ///
+ /// </summary>
+ /// <param name="exception">The name of the exception class
+ /// </param>
+ /* package */
+ internal virtual System.String getExceptionString(System.String exception)
+ {
+ System.String tmsg;
+
+ // Format the basic exception information
+
+ // Craft a string from the resouce file
+ System.String msg = ResourcesHandler.getMessage("TOSTRING", new System.Object[]{exception, base.Message, resultCode, resultCodeToString()});
+ // If found no string from resource file, use a default string
+ if (msg.ToUpper().Equals("TOSTRING".ToUpper()))
+ {
+ msg = exception + ": (" + resultCode + ") " + resultCodeToString();
+ }
+
+ // Add server message
+ if (((System.Object) serverMessage != null) && (serverMessage.Length != 0))
+ {
+ tmsg = ResourcesHandler.getMessage("SERVER_MSG", new System.Object[]{exception, serverMessage});
+ // If found no string from resource file, use a default string
+ if (tmsg.ToUpper().Equals("SERVER_MSG".ToUpper()))
+ {
+ tmsg = exception + ": Server Message: " + serverMessage;
+ }
+
+ msg = msg + '\n' + tmsg;
+ }
+
+ // Add Matched DN message
+ if ((System.Object) matchedDN != null)
+ {
+ tmsg = ResourcesHandler.getMessage("MATCHED_DN", new System.Object[]{exception, matchedDN});
+ // If found no string from resource file, use a default string
+ if (tmsg.ToUpper().Equals("MATCHED_DN".ToUpper()))
+ {
+ tmsg = exception + ": Matched DN: " + matchedDN;
+ }
+
+ msg = msg + '\n' + tmsg;
+ }
+
+ if (rootException != null)
+ {
+ msg = msg + '\n' + rootException.ToString();
+ }
+ return msg;
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapExtendedOperation.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapExtendedOperation.cs
new file mode 100755
index 00000000000..cae68f01d62
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapExtendedOperation.cs
@@ -0,0 +1,129 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.LdapExtendedOperation.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+
+namespace Novell.Directory.Ldap
+{
+
+ /// <summary> Encapsulates an ID which uniquely identifies a particular extended
+ /// operation, known to a particular server, and the data associated
+ /// with that extended operation.
+ ///
+ /// </summary>
+ /// <seealso cref="LdapConnection#extendedOperation">
+ /// </seealso>
+ public class LdapExtendedOperation : System.ICloneable
+ {
+
+ private System.String oid;
+ private sbyte[] vals;
+
+ /// <summary> Constructs a new object with the specified object ID and data.
+ ///
+ /// </summary>
+ /// <param name="oid"> The unique identifier of the operation.
+ ///
+ /// </param>
+ /// <param name="vals"> The operation-specific data of the operation.
+ /// </param>
+ [CLSCompliantAttribute(false)]
+ public LdapExtendedOperation(System.String oid, sbyte[] vals)
+ {
+ this.oid = oid;
+ this.vals = vals;
+ }
+
+ /// <summary> Returns a clone of this object.
+ ///
+ /// </summary>
+ /// <returns> clone of this object.
+ /// </returns>
+ public System.Object Clone()
+ {
+ try
+ {
+ System.Object newObj = base.MemberwiseClone();
+// Array.Copy((System.Array)SupportClass.ToByteArray( this.vals), 0, (System.Array)SupportClass.ToByteArray( ((LdapExtendedOperation) newObj).vals), 0, this.vals.Length);
+ Array.Copy((System.Array)this.vals, 0, (System.Array)((LdapExtendedOperation) newObj).vals, 0, this.vals.Length);
+ return newObj;
+ }
+ catch (System.Exception ce)
+ {
+ throw new System.SystemException("Internal error, cannot create clone");
+ }
+ }
+
+ /// <summary> Returns the unique identifier of the operation.
+ ///
+ /// </summary>
+ /// <returns> The OID (object ID) of the operation.
+ /// </returns>
+ public virtual System.String getID()
+ {
+ return oid;
+ }
+
+ /// <summary> Returns a reference to the operation-specific data.
+ ///
+ /// </summary>
+ /// <returns> The operation-specific data.
+ /// </returns>
+ [CLSCompliantAttribute(false)]
+ public virtual sbyte[] getValue()
+ {
+ return vals;
+ }
+
+ /// <summary> Sets the value for the operation-specific data.
+ ///
+ /// </summary>
+ /// <param name="newVals"> The byte array of operation-specific data.
+ /// </param>
+ [CLSCompliantAttribute(false)]
+ protected internal virtual void setValue(sbyte[] newVals)
+ {
+ this.vals = newVals;
+ return ;
+ }
+
+ /// <summary> Resets the OID for the operation to a new value
+ ///
+ /// </summary>
+ /// <param name="newoid"> The new OID for the operation
+ /// </param>
+ protected internal virtual void setID(System.String newoid)
+ {
+ this.oid = newoid;
+ return ;
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapExtendedRequest.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapExtendedRequest.cs
new file mode 100755
index 00000000000..9e5ce01f785
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapExtendedRequest.cs
@@ -0,0 +1,95 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.LdapExtendedRequest.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+using Asn1OctetString = Novell.Directory.Ldap.Asn1.Asn1OctetString;
+using Asn1Tagged = Novell.Directory.Ldap.Asn1.Asn1Tagged;
+using RfcExtendedRequest = Novell.Directory.Ldap.Rfc2251.RfcExtendedRequest;
+using RfcLdapOID = Novell.Directory.Ldap.Rfc2251.RfcLdapOID;
+
+namespace Novell.Directory.Ldap
+{
+
+ /// <summary> Represents an Ldap Extended Request.
+ ///
+ /// </summary>
+ /// <seealso cref="LdapConnection#sendRequest">
+ /// </seealso>
+ /*
+ * ExtendedRequest ::= [APPLICATION 23] SEQUENCE {
+ * requestName [0] LdapOID,
+ * requestValue [1] OCTET STRING OPTIONAL }
+ */
+ public class LdapExtendedRequest:LdapMessage
+ {
+ /// <summary> Retrieves an extended operation from this request</summary>
+ /// <returns> extended operation represented in this request.
+ /// </returns>
+ virtual public LdapExtendedOperation ExtendedOperation
+ {
+ get
+ {
+ RfcExtendedRequest xreq = (RfcExtendedRequest) this.Asn1Object.get_Renamed(1);
+
+ //Zeroth element is the OID, element one is the value
+ Asn1Tagged tag = (Asn1Tagged) xreq.get_Renamed(0);
+ RfcLdapOID oid = (RfcLdapOID) tag.taggedValue();
+ System.String requestID = oid.stringValue();
+
+ sbyte[] requestValue = null;
+ if (xreq.size() >= 2)
+ {
+ tag = (Asn1Tagged) xreq.get_Renamed(1);
+ Asn1OctetString value_Renamed = (Asn1OctetString) tag.taggedValue();
+ requestValue = value_Renamed.byteValue();
+ }
+ return new LdapExtendedOperation(requestID, requestValue);
+ }
+
+ }
+ /// <summary> Constructs an LdapExtendedRequest.
+ /// <br><br>
+ /// </summary>
+ /// <param name="op"> The object which contains (1) an identifier of an extended
+ /// operation which should be recognized by the particular Ldap
+ /// server this client is connected to, and (2) an operation-
+ /// specific sequence of octet strings or BER-encoded values.
+ /// <br><br>
+ /// </param>
+ /// <param name="cont">Any controls that apply to the extended request
+ /// or null if none.
+ /// </param>
+ public LdapExtendedRequest(LdapExtendedOperation op, LdapControl[] cont):base(LdapMessage.EXTENDED_REQUEST, new RfcExtendedRequest(new RfcLdapOID(op.getID()), (op.getValue() != null)?new Asn1OctetString(op.getValue()):null), cont)
+ {
+ return ;
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapExtendedResponse.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapExtendedResponse.cs
new file mode 100755
index 00000000000..a69d2eef172
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapExtendedResponse.cs
@@ -0,0 +1,94 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.LdapExtendedResponse.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+using Novell.Directory.Ldap.Rfc2251;
+using Novell.Directory.Ldap.Asn1;
+
+namespace Novell.Directory.Ldap
+{
+
+ /// <summary>
+ /// Encapsulates the response returned by an Ldap server on an
+ /// asynchronous extended operation request. It extends LdapResponse.
+ ///
+ /// The response can contain the OID of the extension, an octet string
+ /// with the operation's data, both, or neither.
+ /// </summary>
+ public class LdapExtendedResponse:LdapResponse
+ {
+ /// <summary> Returns the message identifier of the response.
+ ///
+ /// </summary>
+ /// <returns> OID of the response.
+ /// </returns>
+ virtual public System.String ID
+ {
+ get
+ {
+ RfcLdapOID respOID = ((RfcExtendedResponse) message.Response).ResponseName;
+ if (respOID == null)
+ return null;
+ return respOID.stringValue();
+ }
+
+ }
+ /// <summary> Returns the value part of the response in raw bytes.
+ ///
+ /// </summary>
+ /// <returns> The value of the response.
+ /// </returns>
+ [CLSCompliantAttribute(false)]
+ virtual public sbyte[] Value
+ {
+ get
+ {
+ Asn1OctetString tempString = ((RfcExtendedResponse) message.Response).Response;
+ if (tempString == null)
+ return null;
+ else
+ return (tempString.byteValue());
+ }
+
+ }
+
+ /// <summary> Creates an LdapExtendedResponse object which encapsulates
+ /// a server response to an asynchronous extended operation request.
+ ///
+ /// </summary>
+ /// <param name="message"> The RfcLdapMessage to convert to an
+ /// LdapExtendedResponse object.
+ /// </param>
+ public LdapExtendedResponse(RfcLdapMessage message):base(message)
+ {
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapLocalException.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapLocalException.cs
new file mode 100755
index 00000000000..f4c0da3fb3a
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapLocalException.cs
@@ -0,0 +1,163 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.LdapLocalException.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+
+namespace Novell.Directory.Ldap
+{
+
+ /// <summary> Represents an Ldap exception that is not a result of a server response.</summary>
+ public class LdapLocalException:LdapException
+ {
+ /// <summary> Constructs a default exception with no specific error information.</summary>
+ public LdapLocalException():base()
+ {
+ return ;
+ }
+
+ /// <summary> Constructs a local exception with a detailed message obtained from the
+ /// specified <code>MessageOrKey</code> String and the result code.
+ /// <br>
+ /// The String is used either as a message key to obtain a localized
+ /// messsage from ExceptionMessages, or if there is no key in the
+ /// resource matching the text, it is used as the detailed message itself.
+ ///
+ /// </summary>
+ /// <param name="messageOrKey"> Key to addition result information, a key into
+ /// ExceptionMessages, or the information
+ /// itself if the key doesn't exist.
+ /// <br><br>
+ /// </param>
+ /// <param name="resultCode"> The result code returned.
+ /// </param>
+ public LdapLocalException(System.String messageOrKey, int resultCode):base(messageOrKey, resultCode, (System.String) null)
+ {
+ return ;
+ }
+
+ /// <summary> Constructs a local exception with a detailed message obtained from the
+ /// specified <code>MessageOrKey</code> String and modifying arguments.
+ /// Additional parameters specify the result code.
+ /// <br>
+ /// The String is used either as a message key to obtain a localized
+ /// messsage from ExceptionMessages, or if there is no key in the
+ /// resource matching the text, it is used as the detailed message itself.
+ /// <br>
+ /// The message in the default locale is built with the supplied arguments,
+ /// which are saved to be used for building messages for other locales.
+ ///
+ /// </summary>
+ /// <param name="messageOrKey"> Key to addition result information, a key into
+ /// ExceptionMessages, or the information
+ /// itself if the key doesn't exist.
+ /// <br><br>
+ /// </param>
+ /// <param name="arguments"> The modifying arguments to be included in the
+ /// message string.
+ /// <br><br>
+ /// </param>
+ /// <param name="resultCode"> The result code returned.
+ /// </param>
+ public LdapLocalException(System.String messageOrKey, System.Object[] arguments, int resultCode):base(messageOrKey, arguments, resultCode, (System.String) null)
+ {
+ return ;
+ }
+
+ /// <summary> Constructs a local exception with a detailed message obtained from the
+ /// specified <code>MessageOrKey</code> String.
+ /// Additional parameters specify the result code and a rootException which
+ /// is the underlying cause of an error on the client.
+ /// <br>
+ /// The String is used either as a message key to obtain a localized
+ /// messsage from ExceptionMessages, or if there is no key in the
+ /// resource matching the text, it is used as the detailed message itself.
+ ///
+ /// </summary>
+ /// <param name="messageOrKey"> Key to addition result information, a key into
+ /// ExceptionMessages, or the information
+ /// itself if the key doesn't exist.
+ /// <br><br>
+ /// </param>
+ /// <param name="resultCode"> The result code returned.
+ /// <br><br>
+ /// </param>
+ /// <param name="rootException"> A throwable which is the underlying cause
+ /// of the LdapException.
+ /// </param>
+ public LdapLocalException(System.String messageOrKey, int resultCode, System.Exception rootException):base(messageOrKey, resultCode, null, rootException)
+ {
+ return ;
+ }
+
+ /// <summary> Constructs a local exception with a detailed message obtained from the
+ /// specified <code>MessageOrKey</code> String and modifying arguments.
+ /// Additional parameters specify the result code
+ /// and a rootException which is the underlying cause of an error
+ /// on the client.
+ /// <br>
+ /// The String is used either as a message key to obtain a localized
+ /// messsage from ExceptionMessages, or if there is no key in the
+ /// resource matching the text, it is used as the detailed message itself.
+ /// <br>
+ /// The message in the default locale is built with the supplied arguments,
+ /// which are saved to be used for building messages for other locales.
+ ///
+ /// </summary>
+ /// <param name="messageOrKey"> Key to addition result information, a key into
+ /// ExceptionMessages, or the information
+ /// itself if the key doesn't exist.
+ /// <br><br>
+ /// </param>
+ /// <param name="arguments"> The modifying arguments to be included in the
+ /// message string.
+ /// <br><br>
+ /// </param>
+ /// <param name="resultCode"> The result code returned.
+ /// <br><br>
+ /// </param>
+ /// <param name="rootException"> A throwable which is the underlying cause
+ /// of the LdapException.
+ /// </param>
+ public LdapLocalException(System.String messageOrKey, System.Object[] arguments, int resultCode, System.Exception rootException):base(messageOrKey, arguments, resultCode, null, rootException)
+ {
+ return ;
+ }
+
+ /// <summary> returns a string of information about the exception and the
+ /// the nested exceptions, if any.
+ /// </summary>
+ public override System.String ToString()
+ {
+ // Format the basic exception information
+ return getExceptionString("LdapLocalException");
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapMessage.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapMessage.cs
new file mode 100755
index 00000000000..50c2aac3055
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapMessage.cs
@@ -0,0 +1,676 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.LdapMessage.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+using Novell.Directory.Ldap.Rfc2251;
+using Novell.Directory.Ldap.Asn1;
+using Novell.Directory.Ldap.Utilclass;
+
+namespace Novell.Directory.Ldap
+{
+
+ /// <summary> The base class for Ldap request and response messages.
+ ///
+ /// <p>Subclassed by response messages used in asynchronous operations.
+ ///
+ ///
+ /// </summary>
+ public class LdapMessage
+ {
+ /// <summary> Returns the LdapMessage request associated with this response</summary>
+ virtual internal LdapMessage RequestingMessage
+ {
+ /* package */
+
+ get
+ {
+ return message.RequestingMessage;
+ }
+
+ }
+ /// <summary> Returns any controls in the message.</summary>
+ virtual public LdapControl[] Controls
+ {
+ get
+ {
+
+/* LdapControl[] controls = null;
+ RfcControls asn1Ctrls = message.Controls;
+
+ if (asn1Ctrls != null)
+ {
+ controls = new LdapControl[asn1Ctrls.size()];
+ for (int i = 0; i < asn1Ctrls.size(); i++)
+ {
+ RfcControl rfcCtl = (RfcControl) asn1Ctrls.get_Renamed(i);
+ System.String oid = rfcCtl.ControlType.stringValue();
+ sbyte[] value_Renamed = rfcCtl.ControlValue.byteValue();
+ bool critical = rfcCtl.Criticality.booleanValue();
+
+ controls[i] = controlFactory(oid, critical, value_Renamed);
+ }
+ }
+
+ return controls;
+*/
+ LdapControl[] controls = null;
+ RfcControls asn1Ctrls = message.Controls;
+
+ // convert from RFC 2251 Controls to LDAPControl[].
+ if (asn1Ctrls != null)
+ {
+ controls = new LdapControl[asn1Ctrls.size()];
+ for (int i = 0; i < asn1Ctrls.size(); i++)
+ {
+
+ /*
+ * At this point we have an RfcControl which needs to be
+ * converted to the appropriate Response Control. This requires
+ * calling the constructor of a class that extends LDAPControl.
+ * The controlFactory method searches the list of registered
+ * controls and if a match is found calls the constructor
+ * for that child LDAPControl. Otherwise, it returns a regular
+ * LDAPControl object.
+ *
+ * Question: Why did we not call the controlFactory method when
+ * we were parsing the control. Answer: By the time the
+ * code realizes that we have a control it is already too late.
+ */
+ RfcControl rfcCtl = (RfcControl) asn1Ctrls.get_Renamed(i);
+ System.String oid = rfcCtl.ControlType.stringValue();
+ sbyte[] value_Renamed = rfcCtl.ControlValue.byteValue();
+ bool critical = rfcCtl.Criticality.booleanValue();
+
+ /* Return from this call should return either an LDAPControl
+ * or a class extending LDAPControl that implements the
+ * appropriate registered response control
+ */
+ controls[i] = controlFactory(oid, critical, value_Renamed);
+ }
+ }
+ return controls;
+
+ }
+
+ }
+
+ /// <summary> Returns the message ID. The message ID is an integer value
+ /// identifying the Ldap request and its response.
+ /// </summary>
+ virtual public int MessageID
+ {
+ get
+ {
+ if (imsgNum == - 1)
+ {
+ imsgNum = message.MessageID;
+ }
+ return imsgNum;
+ }
+
+ }
+ /// <summary> Returns the Ldap operation type of the message.
+ ///
+ /// <p>The type is one of the following:</p>
+ /// <ul>
+ /// <li>BIND_REQUEST = 0;</li>
+ /// <li>BIND_RESPONSE = 1;</li>
+ /// <li>UNBIND_REQUEST = 2;</li>
+ /// <li>SEARCH_REQUEST = 3;</li>
+ /// <li>SEARCH_RESPONSE = 4;</li>
+ /// <li>SEARCH_RESULT = 5;</li>
+ /// <li>MODIFY_REQUEST = 6;</li>
+ /// <li>MODIFY_RESPONSE = 7;</li>
+ /// <li>ADD_REQUEST = 8;</li>
+ /// <li>ADD_RESPONSE = 9;</li>
+ /// <li>DEL_REQUEST = 10;</li>
+ /// <li>DEL_RESPONSE = 11;</li>
+ /// <li>MODIFY_RDN_REQUEST = 12;</li>
+ /// <li>MODIFY_RDN_RESPONSE = 13;</li>
+ /// <li>COMPARE_REQUEST = 14;</li>
+ /// <li>COMPARE_RESPONSE = 15;</li>
+ /// <li>ABANDON_REQUEST = 16;</li>
+ /// <li>SEARCH_RESULT_REFERENCE = 19;</li>
+ /// <li>EXTENDED_REQUEST = 23;</li>
+ /// <li>EXTENDED_RESPONSE = 24;</li>
+ /// </ul>
+ ///
+ /// </summary>
+ /// <returns> The operation type of the message.
+ /// </returns>
+ virtual public int Type
+ {
+ get
+ {
+ if (messageType == - 1)
+ {
+ messageType = message.Type;
+ }
+ return messageType;
+ }
+
+ }
+ /// <summary> Indicates whether the message is a request or a response
+ ///
+ /// </summary>
+ /// <returns> true if the message is a request, false if it is a response,
+ /// a search result, or a search result reference.
+ /// </returns>
+ virtual public bool Request
+ {
+ get
+ {
+ return message.isRequest();
+ }
+
+ }
+ /// <summary> Returns the RFC 2251 LdapMessage composed in this object.</summary>
+ virtual internal RfcLdapMessage Asn1Object
+ {
+ /* package */
+
+ get
+ {
+ return message;
+ }
+
+ }
+ private System.String Name
+ {
+ get
+ {
+ System.String name;
+ switch (Type)
+ {
+
+ case SEARCH_RESPONSE:
+ name = "LdapSearchResponse";
+ break;
+
+ case SEARCH_RESULT:
+ name = "LdapSearchResult";
+ break;
+
+ case SEARCH_REQUEST:
+ name = "LdapSearchRequest";
+ break;
+
+ case MODIFY_REQUEST:
+ name = "LdapModifyRequest";
+ break;
+
+ case MODIFY_RESPONSE:
+ name = "LdapModifyResponse";
+ break;
+
+ case ADD_REQUEST:
+ name = "LdapAddRequest";
+ break;
+
+ case ADD_RESPONSE:
+ name = "LdapAddResponse";
+ break;
+
+ case DEL_REQUEST:
+ name = "LdapDelRequest";
+ break;
+
+ case DEL_RESPONSE:
+ name = "LdapDelResponse";
+ break;
+
+ case MODIFY_RDN_REQUEST:
+ name = "LdapModifyRDNRequest";
+ break;
+
+ case MODIFY_RDN_RESPONSE:
+ name = "LdapModifyRDNResponse";
+ break;
+
+ case COMPARE_REQUEST:
+ name = "LdapCompareRequest";
+ break;
+
+ case COMPARE_RESPONSE:
+ name = "LdapCompareResponse";
+ break;
+
+ case BIND_REQUEST:
+ name = "LdapBindRequest";
+ break;
+
+ case BIND_RESPONSE:
+ name = "LdapBindResponse";
+ break;
+
+ case UNBIND_REQUEST:
+ name = "LdapUnbindRequest";
+ break;
+
+ case ABANDON_REQUEST:
+ name = "LdapAbandonRequest";
+ break;
+
+ case SEARCH_RESULT_REFERENCE:
+ name = "LdapSearchResultReference";
+ break;
+
+ case EXTENDED_REQUEST:
+ name = "LdapExtendedRequest";
+ break;
+
+ case EXTENDED_RESPONSE:
+ name = "LdapExtendedResponse";
+ break;
+
+ default:
+ throw new System.SystemException("LdapMessage: Unknown Type " + Type);
+
+ }
+ return name;
+ }
+
+ }
+ /// <summary> Retrieves the identifier tag for this message.
+ ///
+ /// <p>An identifier can be associated with a message with the
+ /// <code>setTag</code> method.
+ /// Tags are set by the application and not by the API or the server.
+ /// If a server response <code>isRequest() == false</code> has no tag,
+ /// the tag associated with the corresponding server request is used.</p>
+ ///
+ /// </summary>
+ /// <returns> the identifier associated with this message or <code>null</code>
+ /// if none.
+ ///
+ /// </returns>
+ /// <seealso cref="#setTag">
+ /// </seealso>
+ /// <seealso cref="#isRequest">
+ /// </seealso>
+ /// <summary> Sets a string identifier tag for this message.
+ ///
+ /// <p>This method allows an API to set a tag and later identify messages
+ /// by retrieving the tag associated with the message.
+ /// Tags are set by the application and not by the API or the server.
+ /// Message tags are not included with any message sent to or received
+ /// from the server.</p>
+ ///
+ /// <p>Tags set on a request to the server
+ /// are automatically associated with the response messages when they are
+ /// received by the API and transferred to the application.
+ /// The application can explicitly set a different value in a
+ /// response message.</p>
+ ///
+ /// <p>To set a value in a server request, for example an
+ /// {@link LdapSearchRequest}, you must create the object,
+ /// set the tag, and use the
+ /// {@link LdapConnection#sendRequest LdapConnection.sendRequest()}
+ /// method to send it to the server.</p>
+ ///
+ /// </summary>
+ /// <param name="stringTag"> the String assigned to identify this message.
+ ///
+ /// </param>
+ /// <seealso cref="#getTag">
+ /// </seealso>
+ /// <seealso cref="#isRequest">
+ /// </seealso>
+ virtual public System.String Tag
+ {
+ get
+ {
+ if ((System.Object) this.stringTag != null)
+ {
+ return this.stringTag;
+ }
+ if (Request)
+ {
+ return null;
+ }
+ LdapMessage m = this.RequestingMessage;
+ if (m == null)
+ {
+ return null;
+ }
+ return m.stringTag;
+ }
+
+ set
+ {
+ this.stringTag = value;
+ return ;
+ }
+
+ }
+
+ /// <summary> A bind request operation.
+ ///
+ /// <p>BIND_REQUEST = 0</p>
+ /// </summary>
+ public const int BIND_REQUEST = 0;
+
+ /// <summary> A bind response operation.
+ ///
+ /// <p>BIND_RESPONSE = 1</p>
+ /// </summary>
+ public const int BIND_RESPONSE = 1;
+
+ /// <summary> An unbind request operation.
+ ///
+ /// <p>UNBIND_REQUEST = 2</p>
+ /// </summary>
+ public const int UNBIND_REQUEST = 2;
+
+ /// <summary> A search request operation.
+ ///
+ /// <p>SEARCH_REQUEST = 3</p>
+ /// </summary>
+ public const int SEARCH_REQUEST = 3;
+
+ /// <summary> A search response containing data.
+ ///
+ /// <p>SEARCH_RESPONSE = 4</p>
+ /// </summary>
+ public const int SEARCH_RESPONSE = 4;
+
+ /// <summary> A search result message - contains search status.
+ ///
+ /// <p>SEARCH_RESULT = 5</p>
+ /// </summary>
+ public const int SEARCH_RESULT = 5;
+
+ /// <summary> A modify request operation.
+ ///
+ /// <p>MODIFY_REQUEST = 6</p>
+ /// </summary>
+ public const int MODIFY_REQUEST = 6;
+
+ /// <summary> A modify response operation.
+ ///
+ /// <p>MODIFY_RESPONSE = 7</p>
+ /// </summary>
+ public const int MODIFY_RESPONSE = 7;
+
+ /// <summary> An add request operation.
+ ///
+ /// <p>ADD_REQUEST = 8</p>
+ /// </summary>
+ public const int ADD_REQUEST = 8;
+
+ /// <summary> An add response operation.
+ ///
+ /// <p>ADD_RESONSE = 9</p>
+ /// </summary>
+ public const int ADD_RESPONSE = 9;
+
+ /// <summary> A delete request operation.
+ ///
+ /// <p>DEL_REQUEST = 10</p>
+ /// </summary>
+ public const int DEL_REQUEST = 10;
+
+ /// <summary> A delete response operation.
+ ///
+ /// <p>DEL_RESONSE = 11</p>
+ /// </summary>
+ public const int DEL_RESPONSE = 11;
+
+ /// <summary> A modify RDN request operation.
+ ///
+ /// <p>MODIFY_RDN_REQUEST = 12</p>
+ /// </summary>
+ public const int MODIFY_RDN_REQUEST = 12;
+
+ /// <summary> A modify RDN response operation.
+ ///
+ /// <p>MODIFY_RDN_RESPONSE = 13</p>
+ /// </summary>
+ public const int MODIFY_RDN_RESPONSE = 13;
+
+ /// <summary> A compare result operation.
+ ///
+ /// <p>COMPARE_REQUEST = 14</p>
+ /// </summary>
+ public const int COMPARE_REQUEST = 14;
+
+ /// <summary> A compare response operation.
+ ///
+ /// <p>COMPARE_RESPONSE = 15</p>
+ /// </summary>
+ public const int COMPARE_RESPONSE = 15;
+
+ /// <summary> An abandon request operation.
+ ///
+ /// <p>ABANDON_REQUEST = 16</p>
+ /// </summary>
+ public const int ABANDON_REQUEST = 16;
+
+
+ /// <summary> A search result reference operation.
+ ///
+ /// <p>SEARCH_RESULT_REFERENCE = 19</p>
+ /// </summary>
+ public const int SEARCH_RESULT_REFERENCE = 19;
+
+ /// <summary> An extended request operation.
+ ///
+ /// <p>EXTENDED_REQUEST = 23</p>
+ /// </summary>
+ public const int EXTENDED_REQUEST = 23;
+
+ /// <summary> An extended response operation.
+ ///
+ /// <p>EXTENDED_RESONSE = 24</p>
+ /// </summary>
+ public const int EXTENDED_RESPONSE = 24;
+
+ /// <summary> A request or response message for an asynchronous Ldap operation.</summary>
+ protected internal RfcLdapMessage message;
+
+ /// <summary> Lock object to protect counter for message numbers</summary>
+ /*
+ private static Object msgLock = new Object();
+ */
+
+ /// <summary> Counters used to construct request message #'s, unique for each request
+ /// Will be enabled after ASN.1 conversion
+ /// </summary>
+ /*
+ private static int msgNum = 0; // Ldap Request counter
+ */
+ private int imsgNum = - 1; // This instance LdapMessage number
+
+ private int messageType = - 1;
+
+ /* application defined tag to identify this message */
+ private System.String stringTag = null;
+
+ /// <summary> Dummy constuctor</summary>
+ /* package */
+ internal LdapMessage()
+ {
+ return ;
+ }
+
+ /// <summary> Creates an LdapMessage when sending a protocol operation and sends
+ /// some optional controls with the message.
+ ///
+ /// </summary>
+ /// <param name="op">The operation type of message.
+ /// <br><br>
+ /// </param>
+ /// <param name="controls">The controls to use with the operation.
+ ///
+ /// </param>
+ /// <seealso cref="#getType">
+ /// </seealso>
+ /*package*/
+ internal LdapMessage(int type, RfcRequest op, LdapControl[] controls)
+ {
+
+ // Get a unique number for this request message
+
+ messageType = type;
+ RfcControls asn1Ctrls = null;
+ if (controls != null)
+ {
+ // Move LdapControls into an RFC 2251 Controls object.
+ asn1Ctrls = new RfcControls();
+ for (int i = 0; i < controls.Length; i++)
+ {
+// asn1Ctrls.add(null);
+ asn1Ctrls.add(controls[i].Asn1Object);
+ }
+ }
+
+ // create RFC 2251 LdapMessage
+ message = new RfcLdapMessage(op, asn1Ctrls);
+ return ;
+ }
+
+ /// <summary> Creates an Rfc 2251 LdapMessage when the libraries receive a response
+ /// from a command.
+ ///
+ /// </summary>
+ /// <param name="message">A response message.
+ /// </param>
+ protected internal LdapMessage(RfcLdapMessage message)
+ {
+ this.message = message;
+ return ;
+ }
+
+ /// <summary> Returns a mutated clone of this LdapMessage,
+ /// replacing base dn, filter.
+ ///
+ /// </summary>
+ /// <param name="dn">the base dn
+ /// <br><br>
+ /// </param>
+ /// <param name="filter">the filter
+ /// <br><br>
+ /// </param>
+ /// <param name="reference">true if a search reference
+ ///
+ /// </param>
+ /// <returns> the object representing the new message
+ /// </returns>
+ /* package */
+ internal LdapMessage Clone(System.String dn, System.String filter, bool reference)
+ {
+ return new LdapMessage((RfcLdapMessage) message.dupMessage(dn, filter, reference));
+ }
+
+ /// <summary> Instantiates an LdapControl. We search through our list of
+ /// registered controls. If we find a matchiing OID we instantiate
+ /// that control by calling its contructor. Otherwise we default to
+ /// returning a regular LdapControl object
+ ///
+ /// </summary>
+ private LdapControl controlFactory(System.String oid, bool critical, sbyte[] value_Renamed)
+ {
+// throw new NotImplementedException();
+ RespControlVector regControls = LdapControl.RegisteredControls;
+ try
+ {
+ /*
+ * search through the registered extension list to find the
+ * response control class
+ */
+ System.Type respCtlClass = regControls.findResponseControl(oid);
+
+ // Did not find a match so return default LDAPControl
+ if (respCtlClass == null)
+ return new LdapControl(oid, critical, value_Renamed);
+
+ /* If found, get LDAPControl constructor */
+ System.Type[] argsClass = new System.Type[]{typeof(System.String), typeof(bool), typeof(sbyte[])};
+ System.Object[] args = new System.Object[]{oid, critical, value_Renamed};
+ System.Exception ex = null;
+ try
+ {
+ System.Reflection.ConstructorInfo ctlConstructor = respCtlClass.GetConstructor(argsClass);
+
+ try
+ {
+ /* Call the control constructor for a registered Class*/
+ System.Object ctl = null;
+// ctl = ctlConstructor.newInstance(args);
+ ctl = ctlConstructor.Invoke(args);
+ return (LdapControl) ctl;
+ }
+ catch (System.UnauthorizedAccessException e)
+ {
+ ex = e;
+ }
+ catch (System.Reflection.TargetInvocationException e)
+ {
+ ex = e;
+ }
+ catch (System.Exception e)
+ {
+ // Could not create the ResponseControl object
+ // All possible exceptions are ignored. We fall through
+ // and create a default LDAPControl object
+ ex = e;
+ }
+
+ }
+ catch (System.MethodAccessException e)
+ {
+ // bad class was specified, fall through and return a
+ // default LDAPControl object
+ ex = e;
+ }
+ }
+ catch (System.FieldAccessException e)
+ {
+ // No match with the OID
+ // Do nothing. Fall through and construct a default LDAPControl object.
+ }
+ // If we get here we did not have a registered response control
+ // for this oid. Return a default LDAPControl object.
+ return new LdapControl(oid, critical, value_Renamed);
+
+ }
+
+ /// <summary> Creates a String representation of this object
+ ///
+ /// </summary>
+ /// <returns> a String representation for this LdapMessage
+ /// </returns>
+ public override System.String ToString()
+ {
+ return Name + "(" + MessageID + "): " + message.ToString();
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapMessageQueue.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapMessageQueue.cs
new file mode 100755
index 00000000000..b709270fc01
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapMessageQueue.cs
@@ -0,0 +1,286 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.LdapMessageQueue.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+using RfcLdapMessage = Novell.Directory.Ldap.Rfc2251.RfcLdapMessage;
+using ExtResponseFactory = Novell.Directory.Ldap.Utilclass.ExtResponseFactory;
+
+namespace Novell.Directory.Ldap
+{
+
+ /// <summary> Represents a queue of incoming asynchronous messages from the server.
+ /// It is the common interface for {@link LdapResponseQueue} and
+ /// {@link LdapSearchQueue}.
+ /// </summary>
+ public abstract class LdapMessageQueue
+ {
+ /// <summary> Returns the name used for debug
+ ///
+ /// </summary>
+ /// <returns> name of object instance used for debug
+ /// </returns>
+ virtual internal System.String DebugName
+ {
+ /* package */
+
+ get
+ {
+ return name;
+ }
+
+ }
+ /// <summary> Returns the internal client message agent
+ ///
+ /// </summary>
+ /// <returns> The internal client message agent
+ /// </returns>
+ virtual internal MessageAgent MessageAgent
+ {
+ /* package */
+
+ get
+ {
+ return agent;
+ }
+
+ }
+ /// <summary> Returns the message IDs for all outstanding requests. These are requests
+ /// for which a response has not been received from the server or which
+ /// still have messages to be retrieved with getResponse.
+ ///
+ /// <p>The last ID in the array is the messageID of the last submitted
+ /// request.</p>
+ ///
+ /// </summary>
+ /// <returns> The message IDs for all outstanding requests.
+ /// </returns>
+ virtual public int[] MessageIDs
+ {
+ get
+ {
+ return agent.MessageIDs;
+ }
+
+ }
+ /// <summary> The message agent object associated with this queue</summary>
+ /* package */
+ internal MessageAgent agent;
+
+ // Queue name used only for debug
+ /* package */
+ internal System.String name = "";
+
+ // nameLock used to protect queueNum during increment
+ /* package */
+ internal static System.Object nameLock;
+
+ // Queue number used only for debug
+ /* package */
+ internal static int queueNum = 0;
+
+ /// <summary> Constructs a response queue using the specified message agent
+ ///
+ /// </summary>
+ /// <param name="agent">The message agent to associate with this conneciton
+ /// </param>
+ /* package */
+ internal LdapMessageQueue(System.String myname, MessageAgent agent)
+ {
+ // Get a unique connection name for debug
+ this.agent = agent;
+ return ;
+ }
+
+ /// <summary> Returns the response from an Ldap request.
+ ///
+ /// <p>The getResponse method blocks until a response is available, or until
+ /// all operations associated with the object have completed or been
+ /// canceled, and then returns the response.</p>
+ ///
+ /// <p>The application is responsible to determine the type of message
+ /// returned.</p>
+ ///
+ /// </summary>
+ /// <returns> The response.
+ ///
+ /// </returns>
+ /// <seealso cref="LdapResponse">
+ /// </seealso>
+ /// <seealso cref="LdapSearchResult">
+ /// </seealso>
+ /// <seealso cref="LdapSearchResultReference">
+ ///
+ /// </seealso>
+ /// <exception cref=""> LdapException A general exception which includes an error
+ /// message and an Ldap error code.
+ /// </exception>
+ public virtual LdapMessage getResponse()
+ {
+ return getResponse(null);
+ }
+
+ /// <summary> Returns the response from an Ldap request for a particular message ID.
+ ///
+ /// <p>The getResponse method blocks until a response is available
+ /// for a particular message ID, or until all operations associated
+ /// with the object have completed or been canceled, and
+ /// then returns the response. If there is no outstanding operation for
+ /// the message ID (or if it is zero or a negative number),
+ /// IllegalArgumentException is thrown.
+ ///
+ /// <p>The application is responsible to determine the type of message
+ /// returned.</p>
+ ///
+ /// </summary>
+ /// <param name="msgid">query for responses for a specific message request
+ ///
+ /// </param>
+ /// <returns> The response from the server.
+ ///
+ /// </returns>
+ /// <seealso cref="LdapResponse">
+ /// </seealso>
+ /// <seealso cref="LdapSearchResult">
+ /// </seealso>
+ /// <seealso cref="LdapSearchResultReference">
+ ///
+ /// </seealso>
+ /// <exception cref=""> LdapException A general exception which includes an error
+ /// message and an Ldap error code.
+ /// </exception>
+ public virtual LdapMessage getResponse(System.Int32 msgid)
+ {
+ return getResponse(new Integer32(msgid));
+ }
+
+ /// <summary> Private implementation of getResponse.
+ /// Has an Integer object as a parameter so we can distinguish
+ /// the null and the message number case
+ /// </summary>
+// private LdapMessage getResponse(System.Int32 msgid)
+ private LdapMessage getResponse(Integer32 msgid)
+ {
+ System.Object resp;
+ RfcLdapMessage message;
+ LdapMessage response;
+ if ((resp = agent.getLdapMessage(msgid)) == null)
+ {
+ // blocks
+ return null; // no messages from this agent
+ }
+ // Local error occurred, contains a LocalException
+ if (resp is LdapResponse)
+ {
+ return (LdapMessage) resp;
+ }
+ // Normal message handling
+ message = (RfcLdapMessage) resp;
+ switch (message.Type)
+ {
+
+ case LdapMessage.SEARCH_RESPONSE:
+ response = new LdapSearchResult(message);
+ break;
+
+ case LdapMessage.SEARCH_RESULT_REFERENCE:
+ response = new LdapSearchResultReference(message);
+ break;
+
+ case LdapMessage.EXTENDED_RESPONSE:
+ ExtResponseFactory fac = new ExtResponseFactory();
+ response = ExtResponseFactory.convertToExtendedResponse(message);
+ break;
+
+ default:
+ response = new LdapResponse(message);
+ break;
+
+ }
+ return response;
+ }
+
+ /// <summary> Reports true if any response has been received from the server and not
+ /// yet retrieved with getResponse. If getResponse has been used to
+ /// retrieve all messages received to this point, then isResponseReceived
+ /// returns false.
+ ///
+ /// </summary>
+ /// <returns> true if a response is available to be retrieved via getResponse,
+ /// otherwise false.
+ ///
+ /// </returns>
+ /// <seealso cref="#getResponse()">
+ /// </seealso>
+ public virtual bool isResponseReceived()
+ {
+ return agent.isResponseReceived();
+ }
+
+ /// <summary> Reports true if a response has been received from the server for
+ /// a particular message ID but not yet retrieved with getResponse. If
+ /// there is no outstanding operation for the message ID (or if it is
+ /// zero or a negative number), IllegalArgumentException is thrown.
+ ///
+ /// </summary>
+ /// <param name="msgid"> A particular message ID to query for available responses.
+ ///
+ /// </param>
+ /// <returns> true if a response is available to be retrieved via getResponse
+ /// for the specified message ID, otherwise false.
+ ///
+ /// </returns>
+ /// <seealso cref="#getResponse(int)">
+ /// </seealso>
+ public virtual bool isResponseReceived(int msgid)
+ {
+ return agent.isResponseReceived(msgid);
+ }
+
+ /// <summary> Reports true if all results have been received for a particular
+ /// message id.
+ ///
+ /// <p>If the search result done has been received from the server for the
+ /// message id, it reports true. There may still be messages waiting to be
+ /// retrieved by the applcation with getResponse.<p>
+ ///
+ /// @throws IllegalArgumentException if there is no outstanding operation
+ /// for the message ID,
+ /// </summary>
+ public virtual bool isComplete(int msgid)
+ {
+ return agent.isComplete(msgid);
+ }
+ static LdapMessageQueue()
+ {
+ nameLock = new System.Object();
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapModification.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapModification.cs
new file mode 100755
index 00000000000..dde7fa2912f
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapModification.cs
@@ -0,0 +1,173 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.LdapModification.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+
+namespace Novell.Directory.Ldap
+{
+
+ /// <summary> A single add, delete, or replace operation to an LdapAttribute.
+ ///
+ /// <p>An LdapModification contains information on the type of modification
+ /// being performed, the name of the attribute to be replaced, and the new
+ /// value. Multiple modifications are expressed as an array of modifications,
+ /// i.e., <code>LdapModification[]</code>.</p>
+ ///
+ /// <p>An LdapModification or an LdapModification array enable you to modify
+ /// an attribute of an Ldap entry. The entire array of modifications must
+ /// be performed by the server as a single atomic operation in the order they
+ /// are listed. No changes are made to the directory unless all the operations
+ /// succeed. If all succeed, a success result is returned to the application.
+ /// It should be noted that if the connection fails during a modification,
+ /// it is indeterminate whether the modification occurred or not.</p>
+ ///
+ /// <p>There are three types of modification operations: Add, Delete,
+ /// and Replace.</p>
+ ///
+ /// <p><b>Add: </b>Creates the attribute if it doesn't exist, and adds
+ /// the specified values. This operation must contain at least one value, and
+ /// all values of the attribute must be unique.</p>
+ ///
+ /// <p><b>Delete: </b>Deletes specified values from the attribute. If no
+ /// values are specified, or if all existing values of the attribute are
+ /// specified, the attribute is removed. Mandatory attributes cannot be
+ /// removed.</p>
+ ///
+ /// <p><b>Replace: </b>Creates the attribute if necessary, and replaces
+ /// all existing values of the attribute with the specified values.
+ /// If you wish to keep any existing values of a multi-valued attribute,
+ /// you must include these values in the replace operation.
+ /// A replace operation with no value will remove the entire attribute if it
+ /// exists, and is ignored if the attribute does not exist.</p>
+ ///
+ /// <p>Additional information on Ldap modifications is available in section 4.6
+ /// of <a href="http://www.ietf.org/rfc/rfc2251.txt">rfc2251.txt</a></p>
+ ///
+ ///
+ /// </summary>
+ /// <seealso cref="LdapConnection#modify">
+ /// </seealso>
+ /// <seealso cref="LdapAttribute">
+ /// </seealso>
+ public class LdapModification
+ {
+ /// <summary> Returns the attribute to modify, with any existing values.
+ ///
+ /// </summary>
+ /// <returns> The attribute to modify.
+ /// </returns>
+ virtual public LdapAttribute Attribute
+ {
+ get
+ {
+ return attr;
+ }
+
+ }
+ /// <summary> Returns the type of modification specified by this object.
+ ///
+ /// <p>The type is one of the following:</p>
+ /// <ul>
+ /// <li>LdapModification.ADD</li>
+ /// <li>LdapModification.DELETE</li>
+ /// <li>LdapModification.REPLACE</li>
+ /// </ul>
+ ///
+ /// </summary>
+ /// <returns> The type of modification specified by this object.
+ /// </returns>
+ virtual public int Op
+ {
+ get
+ {
+ return op;
+ }
+
+ }
+
+ private int op;
+ private LdapAttribute attr;
+
+ /// <summary> Adds the listed values to the given attribute, creating
+ /// the attribute if it does not already exist.
+ ///
+ /// <p>ADD = 0</p>
+ /// </summary>
+ public const int ADD = 0;
+
+ /// <summary> Deletes the listed values from the given attribute,
+ /// removing the entire attribute (1) if no values are listed or
+ /// (2) if all current values of the attribute are listed for
+ /// deletion.
+ ///
+ /// <p>DELETE = 1</p>
+ /// </summary>
+ public const int DELETE = 1;
+
+ /// <summary> Replaces all existing values of the given attribute
+ /// with the new values listed, creating the attribute if it
+ /// does not already exist.
+ ///
+ /// <p> A replace with no value deletes the entire attribute if it
+ /// exists, and is ignored if the attribute does not exist. </p>
+ ///
+ /// <p>REPLACE = 2</p>
+ /// </summary>
+ public const int REPLACE = 2;
+
+ /// <summary> Specifies a modification to be made to an attribute.
+ ///
+ /// </summary>
+ /// <param name="op"> The type of modification to make, which can be
+ /// one of the following:
+ /// <ul>
+ /// <li>LdapModification.ADD - The value should be added to
+ /// the attribute</li>
+ ///
+ /// <li>LdapModification.DELETE - The value should be removed
+ /// from the attribute </li>
+ ///
+ /// <li>LdapModification.REPLACE - The value should replace all
+ /// existing values of the
+ /// attribute </li>
+ /// </ul><br>
+ /// </param>
+ /// <param name="attr"> The attribute to modify.
+ ///
+ /// </param>
+ public LdapModification(int op, LdapAttribute attr)
+ {
+ this.op = op;
+ this.attr = attr;
+ return ;
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapModifyDNRequest.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapModifyDNRequest.cs
new file mode 100755
index 00000000000..d8421904316
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapModifyDNRequest.cs
@@ -0,0 +1,156 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.LdapModifyDNRequest.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+using Novell.Directory.Ldap.Asn1;
+using Novell.Directory.Ldap.Rfc2251;
+
+namespace Novell.Directory.Ldap
+{
+
+ /// <summary> Represents an Ldap ModifyDN request
+ ///
+ /// </summary>
+ /// <seealso cref="LdapConnection#sendRequest">
+ /// </seealso>
+ /*
+ * ModifyDNRequest ::= [APPLICATION 12] SEQUENCE {
+ * entry LdapDN,
+ * newrdn RelativeLdapDN,
+ * deleteoldrdn BOOLEAN,
+ * newSuperior [0] LdapDN OPTIONAL }
+ */
+ public class LdapModifyDNRequest:LdapMessage
+ {
+ /// <summary> Returns the dn of the entry to rename or move in the directory
+ ///
+ /// </summary>
+ /// <returns> the dn of the entry to rename or move
+ /// </returns>
+ virtual public System.String DN
+ {
+ get
+ {
+ return Asn1Object.RequestDN;
+ }
+
+ }
+ /// <summary> Returns the newRDN of the entry to rename or move in the directory
+ ///
+ /// </summary>
+ /// <returns> the newRDN of the entry to rename or move
+ /// </returns>
+ virtual public System.String NewRDN
+ {
+ get
+ {
+ // Get the RFC request object for this request
+ RfcModifyDNRequest req = (RfcModifyDNRequest) Asn1Object.getRequest();
+ RfcRelativeLdapDN relDN = (RfcRelativeLdapDN) req.toArray()[1];
+ return relDN.stringValue();
+ }
+
+ }
+ /// <summary> Returns the DeleteOldRDN flag that applies to the entry to rename or
+ /// move in the directory
+ ///
+ /// </summary>
+ /// <returns> the DeleteOldRDN flag for the entry to rename or move
+ /// </returns>
+ virtual public bool DeleteOldRDN
+ {
+ get
+ {
+ // Get the RFC request object for this request
+ RfcModifyDNRequest req = (RfcModifyDNRequest) Asn1Object.getRequest();
+ Asn1Boolean delOld = (Asn1Boolean) req.toArray()[2];
+ return delOld.booleanValue();
+ }
+
+ }
+ /// <summary> Returns the ParentDN for the entry move in the directory
+ ///
+ /// </summary>
+ /// <returns> the ParentDN for the entry to move, or <dd>null</dd>
+ /// if the request is not a move.
+ /// </returns>
+ virtual public System.String ParentDN
+ {
+ get
+ {
+ // Get the RFC request object for this request
+ RfcModifyDNRequest req = (RfcModifyDNRequest) Asn1Object.getRequest();
+ Asn1Object[] seq = req.toArray();
+ if ((seq.Length < 4) || (seq[3] == null))
+ {
+ return null;
+ }
+ RfcLdapDN parentDN = (RfcLdapDN) req.toArray()[3];
+ return parentDN.stringValue();
+ }
+
+ }
+ /// <summary> Constructs a ModifyDN (rename) Request.
+ ///
+ /// </summary>
+ /// <param name="dn"> The current distinguished name of the entry.
+ /// <br><br>
+ /// </param>
+ /// <param name="newRdn"> The new relative distinguished name for the entry.
+ /// <br><br>
+ /// </param>
+ /// <param name="newParentdn"> The distinguished name of an existing entry which
+ /// is to be the new parent of the entry.
+ /// <br><br>
+ /// </param>
+ /// <param name="deleteOldRdn"> If true, the old name is not retained as an
+ /// attribute value. If false, the old name is
+ /// retained as an attribute value.
+ /// <br><br>
+ /// </param>
+ /// <param name="cont"> Any controls that apply to the modifyDN request,
+ /// or null if none.
+ /// </param>
+ public LdapModifyDNRequest(System.String dn, System.String newRdn, System.String newParentdn, bool deleteOldRdn, LdapControl[] cont):base(LdapMessage.MODIFY_RDN_REQUEST, new RfcModifyDNRequest(new RfcLdapDN(dn), new RfcRelativeLdapDN(newRdn), new Asn1Boolean(deleteOldRdn), ((System.Object) newParentdn != null)?new RfcLdapDN(newParentdn):null), cont)
+ {
+ return ;
+ }
+
+ /// <summary> Return an Asn1 representation of this mod DN request
+ ///
+ /// #return an Asn1 representation of this object
+ /// </summary>
+ public override System.String ToString()
+ {
+ return Asn1Object.ToString();
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapModifyRequest.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapModifyRequest.cs
new file mode 100755
index 00000000000..9d63e3b6f33
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapModifyRequest.cs
@@ -0,0 +1,183 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.LdapModifyRequest.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+using Novell.Directory.Ldap.Asn1;
+using Novell.Directory.Ldap.Rfc2251;
+
+namespace Novell.Directory.Ldap
+{
+
+ /// <summary> Modification Request.
+ ///
+ /// </summary>
+ /// <seealso cref="LdapConnection#sendRequest">
+ /// </seealso>
+ /*
+ * ModifyRequest ::= [APPLICATION 6] SEQUENCE {
+ * object LdapDN,
+ * modification SEQUENCE OF SEQUENCE {
+ * operation ENUMERATED {
+ * add (0),
+ * delete (1),
+ * replace (2) },
+ * modification AttributeTypeAndValues } }
+ */
+ public class LdapModifyRequest:LdapMessage
+ {
+ /// <summary> Returns of the dn of the entry to modify in the directory
+ ///
+ /// </summary>
+ /// <returns> the dn of the entry to modify
+ /// </returns>
+ virtual public System.String DN
+ {
+ get
+ {
+ return Asn1Object.RequestDN;
+ }
+
+ }
+ /// <summary> Constructs the modifications associated with this request
+ ///
+ /// </summary>
+ /// <returns> an array of LdapModification objects
+ /// </returns>
+ virtual public LdapModification[] Modifications
+ {
+ get
+ {
+ // Get the RFC request object for this request
+ RfcModifyRequest req = (RfcModifyRequest) Asn1Object.getRequest();
+ // get beginning sequenceOf modifications
+ Asn1SequenceOf seqof = req.Modifications;
+ Asn1Object[] mods = seqof.toArray();
+ LdapModification[] modifications = new LdapModification[mods.Length];
+ // Process each modification
+ for (int m = 0; m < mods.Length; m++)
+ {
+ // Each modification consists of a mod type and a sequence
+ // containing the attr name and a set of values
+ Asn1Sequence opSeq = (Asn1Sequence) mods[m];
+ if (opSeq.size() != 2)
+ {
+ throw new System.SystemException("LdapModifyRequest: modification " + m + " is wrong size: " + opSeq.size());
+ }
+ // Contains operation and sequence for the attribute
+ Asn1Object[] opArray = opSeq.toArray();
+ Asn1Enumerated asn1op = (Asn1Enumerated) opArray[0];
+ // get the operation
+ int op = asn1op.intValue();
+ Asn1Sequence attrSeq = (Asn1Sequence) opArray[1];
+ Asn1Object[] attrArray = attrSeq.toArray();
+ RfcAttributeDescription aname = (RfcAttributeDescription) attrArray[0];
+ System.String name = aname.stringValue();
+ Asn1SetOf avalue = (Asn1SetOf) attrArray[1];
+ Asn1Object[] valueArray = avalue.toArray();
+ LdapAttribute attr = new LdapAttribute(name);
+
+ for (int v = 0; v < valueArray.Length; v++)
+ {
+ RfcAttributeValue rfcV = (RfcAttributeValue) valueArray[v];
+ attr.addValue(rfcV.byteValue());
+ }
+
+ modifications[m] = new LdapModification(op, attr);
+ }
+ return modifications;
+ }
+
+ }
+ /// <summary> Constructs an Ldap Modify request.
+ ///
+ /// </summary>
+ /// <param name="dn"> The distinguished name of the entry to modify.
+ /// <br><br>
+ /// </param>
+ /// <param name="mods"> The changes to be made to the entry.
+ /// <br><br>
+ /// </param>
+ /// <param name="cont"> Any controls that apply to the modify request,
+ /// or null if none.
+ /// </param>
+ public LdapModifyRequest(System.String dn, LdapModification[] mods, LdapControl[] cont):base(LdapMessage.MODIFY_REQUEST, new RfcModifyRequest(new RfcLdapDN(dn), encodeModifications(mods)), cont)
+ {
+ return ;
+ }
+
+ /// <summary> Encode an array of LdapModifications to ASN.1.
+ ///
+ /// </summary>
+ /// <param name="mods">an array of LdapModification objects
+ ///
+ /// </param>
+ /// <returns> an Asn1SequenceOf object containing the modifications.
+ /// </returns>
+ static private Asn1SequenceOf encodeModifications(LdapModification[] mods)
+ {
+ // Convert Java-API LdapModification[] to RFC2251 SEQUENCE OF SEQUENCE
+ Asn1SequenceOf rfcMods = new Asn1SequenceOf(mods.Length);
+ for (int i = 0; i < mods.Length; i++)
+ {
+ LdapAttribute attr = mods[i].Attribute;
+
+ // place modification attribute values in Asn1SetOf
+ Asn1SetOf vals = new Asn1SetOf(attr.size());
+ if (attr.size() > 0)
+ {
+ System.Collections.IEnumerator attrEnum = attr.ByteValues;
+ while (attrEnum.MoveNext())
+ {
+ vals.add(new RfcAttributeValue((sbyte[]) attrEnum.Current));
+ }
+ }
+
+ // create SEQUENCE containing mod operation and attr type and vals
+ Asn1Sequence rfcMod = new Asn1Sequence(2);
+ rfcMod.add(new Asn1Enumerated(mods[i].Op));
+ rfcMod.add(new RfcAttributeTypeAndValues(new RfcAttributeDescription(attr.Name), vals));
+
+ // place SEQUENCE into SEQUENCE OF
+ rfcMods.add(rfcMod);
+ }
+ return rfcMods;
+ }
+
+ /// <summary> Return an Asn1 representation of this modify request
+ ///
+ /// #return an Asn1 representation of this object
+ /// </summary>
+ public override System.String ToString()
+ {
+ return Asn1Object.ToString();
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapReferralException.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapReferralException.cs
new file mode 100755
index 00000000000..6824a1add8c
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapReferralException.cs
@@ -0,0 +1,297 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.LdapReferralException.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+using Novell.Directory.Ldap.Utilclass;
+
+namespace Novell.Directory.Ldap
+{
+
+ /// <summary> Thrown when a server returns a referral and when a referral has not
+ /// been followed. It contains a list of URL strings corresponding
+ /// to the referrals or search continuation references received on an Ldap
+ /// operation.
+ /// </summary>
+ public class LdapReferralException:LdapException
+ {
+ /// <summary> Sets a referral that could not be processed
+ ///
+ /// </summary>
+ /// <param name="url">The referral URL that could not be processed.
+ /// </param>
+ virtual public System.String FailedReferral
+ {
+ /* Gets the referral that could not be processed. If multiple referrals
+ * could not be processed, the method returns one of them.
+ *
+ * @return the referral that could not be followed.
+ */
+
+ get
+ {
+ return failedReferral;
+ }
+
+ set
+ {
+ failedReferral = value;
+ return ;
+ }
+
+ }
+
+ private System.String failedReferral = null;
+ private System.String[] referrals = null;
+
+ /// <summary> Constructs a default exception with no specific error information.</summary>
+ public LdapReferralException():base()
+ {
+ return ;
+ }
+
+ /// <summary> Constructs a default exception with a specified string as additional
+ /// information.
+ ///
+ /// <p>This form is used for lower-level errors.</p>
+ ///
+ /// </summary>
+ /// <param name="message">The additional error information.
+ /// </param>
+ public LdapReferralException(System.String message):base(message, LdapException.REFERRAL, (System.String) null)
+ {
+ return ;
+ }
+
+ /// <summary> Constructs a default exception with a specified string as additional
+ /// information.
+ ///
+ /// <p>This form is used for lower-level errors.</p>
+ ///
+ /// <br><br>
+ /// </summary>
+ /// <param name="arguments"> The modifying arguments to be included in the
+ /// message string.
+ ///
+ /// </param>
+ /// <param name="message">The additional error information.
+ /// </param>
+ public LdapReferralException(System.String message, System.Object[] arguments):base(message, arguments, LdapException.REFERRAL, (System.String) null)
+ {
+ return ;
+ }
+ /// <summary> Constructs a default exception with a specified string as additional
+ /// information and an exception that indicates a failure to follow a
+ /// referral. This excepiton applies only to synchronous operations and
+ /// is thrown only on receipt of a referral when the referral was not
+ /// followed.
+ ///
+ /// </summary>
+ /// <param name="message">The additional error information.
+ ///
+ /// <br><br>
+ /// </param>
+ /// <param name="rootException">An exception which caused referral following to fail.
+ /// </param>
+ public LdapReferralException(System.String message, System.Exception rootException):base(message, LdapException.REFERRAL, null, rootException)
+ {
+ return ;
+ }
+
+ /// <summary> Constructs a default exception with a specified string as additional
+ /// information and an exception that indicates a failure to follow a
+ /// referral. This excepiton applies only to synchronous operations and
+ /// is thrown only on receipt of a referral when the referral was not
+ /// followed.
+ ///
+ /// </summary>
+ /// <param name="message">The additional error information.
+ ///
+ /// <br><br>
+ /// </param>
+ /// <param name="arguments"> The modifying arguments to be included in the
+ /// message string.
+ /// <br><br>
+ /// </param>
+ /// <param name="rootException">An exception which caused referral following to fail.
+ /// </param>
+ public LdapReferralException(System.String message, System.Object[] arguments, System.Exception rootException):base(message, arguments, LdapException.REFERRAL, null, rootException)
+ {
+ return ;
+ }
+
+ /// <summary> Constructs an exception with a specified error string, result code, and
+ /// an error message from the server.
+ ///
+ /// </summary>
+ /// <param name="message"> The additional error information.
+ /// <br><br>
+ /// </param>
+ /// <param name="resultCode"> The result code returned.
+ /// <br><br>
+ /// </param>
+ /// <param name="serverMessage"> Error message specifying additional information
+ /// from the server.
+ /// </param>
+ public LdapReferralException(System.String message, int resultCode, System.String serverMessage):base(message, resultCode, serverMessage)
+ {
+ return ;
+ }
+
+ /// <summary> Constructs an exception with a specified error string, result code, and
+ /// an error message from the server.
+ ///
+ /// </summary>
+ /// <param name="message"> The additional error information.
+ /// <br><br>
+ /// </param>
+ /// <param name="arguments"> The modifying arguments to be included in the
+ /// message string.
+ /// <br><br>
+ /// </param>
+ /// <param name="resultCode"> The result code returned.
+ /// <br><br>
+ /// </param>
+ /// <param name="serverMessage"> Error message specifying additional information
+ /// from the server.
+ /// </param>
+ public LdapReferralException(System.String message, System.Object[] arguments, int resultCode, System.String serverMessage):base(message, arguments, resultCode, serverMessage)
+ {
+ return ;
+ }
+
+ /// <summary> Constructs an exception with a specified error string, result code,
+ /// an error message from the server, and an exception that indicates
+ /// a failure to follow a referral.
+ ///
+ /// </summary>
+ /// <param name="message"> The additional error information.
+ /// <br><br>
+ /// </param>
+ /// <param name="resultCode"> The result code returned.
+ /// <br><br>
+ /// </param>
+ /// <param name="serverMessage"> Error message specifying additional information
+ /// from the server.
+ /// </param>
+ public LdapReferralException(System.String message, int resultCode, System.String serverMessage, System.Exception rootException):base(message, resultCode, serverMessage, rootException)
+ {
+ return ;
+ }
+ /// <summary> Constructs an exception with a specified error string, result code,
+ /// an error message from the server, and an exception that indicates
+ /// a failure to follow a referral.
+ ///
+ /// </summary>
+ /// <param name="message"> The additional error information.
+ /// <br><br>
+ /// </param>
+ /// <param name="arguments"> The modifying arguments to be included in the
+ /// message string.
+ /// <br><br>
+ /// </param>
+ /// <param name="resultCode"> The result code returned.
+ /// <br><br>
+ /// </param>
+ /// <param name="serverMessage"> Error message specifying additional information
+ /// from the server.
+ /// </param>
+ public LdapReferralException(System.String message, System.Object[] arguments, int resultCode, System.String serverMessage, System.Exception rootException):base(message, arguments, resultCode, serverMessage, rootException)
+ {
+ return ;
+ }
+
+ /// <summary> Gets the list of referral URLs (Ldap URLs to other servers) returned by
+ /// the Ldap server.
+ ///
+ /// The referral list may include URLs of a type other than ones for an Ldap
+ /// server (for example, a referral URL other than ldap://something).</p>
+ ///
+ /// </summary>
+ /// <returns> The list of URLs that comprise this referral
+ /// </returns>
+ public virtual System.String[] getReferrals()
+ {
+ return referrals;
+ }
+
+ /// <summary> Sets the list of referrals
+ ///
+ /// </summary>
+ /// <param name="urls">the list of referrals returned by the Ldap server in a
+ /// single response.
+ /// </param>
+ /* package */
+ internal virtual void setReferrals(System.String[] urls)
+ {
+ referrals = urls;
+ return ;
+ }
+
+ /// <summary> returns a string of information about the exception and the
+ /// the nested exceptions, if any.
+ /// </summary>
+ public override System.String ToString()
+ {
+ System.String msg, tmsg;
+
+ // Format the basic exception information
+ msg = getExceptionString("LdapReferralException");
+
+ // Add failed referral information
+ if ((System.Object) failedReferral != null)
+ {
+ tmsg = ResourcesHandler.getMessage("FAILED_REFERRAL", new System.Object[]{"LdapReferralException", failedReferral});
+ // If found no string from resource file, use a default string
+ if (tmsg.ToUpper().Equals("SERVER_MSG".ToUpper()))
+ {
+ tmsg = "LdapReferralException: Failed Referral: " + failedReferral;
+ }
+ msg = msg + '\n' + tmsg;
+ }
+
+ // Add referral information, display all the referrals in the list
+ if (referrals != null)
+ {
+ for (int i = 0; i < referrals.Length; i++)
+ {
+ tmsg = ResourcesHandler.getMessage("REFERRAL_ITEM", new System.Object[]{"LdapReferralException", referrals[i]});
+ // If found no string from resource file, use a default string
+ if (tmsg.ToUpper().Equals("SERVER_MSG".ToUpper()))
+ {
+ tmsg = "LdapReferralException: Referral: " + referrals[i];
+ }
+ msg = msg + '\n' + tmsg;
+ }
+ }
+ return msg;
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapReferralHandler.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapReferralHandler.cs
new file mode 100755
index 00000000000..9e01520c0a0
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapReferralHandler.cs
@@ -0,0 +1,50 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.LdapReferralHandler.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+
+namespace Novell.Directory.Ldap
+{
+
+ /// <summary>
+ /// Shared ancestor to the two types of referral objects - LdapBindHandler and
+ /// LdapAuthHandler.
+ ///
+ /// </summary>
+ /// <seealso cref="LdapBindHandler">
+ /// </seealso>
+ /// <seealso cref="LdapAuthHandler">
+ ///
+ /// </seealso>
+ public interface LdapReferralHandler
+ {
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapResponse.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapResponse.cs
new file mode 100755
index 00000000000..59c2cd1a343
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapResponse.cs
@@ -0,0 +1,482 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.LdapResponse.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+using Novell.Directory.Ldap.Asn1;
+using Novell.Directory.Ldap.Rfc2251;
+using Novell.Directory.Ldap.Utilclass;
+
+namespace Novell.Directory.Ldap
+{
+
+ /// <summary> A message received from an LdapServer
+ /// in response to an asynchronous request.
+ ///
+ /// </summary>
+ /// <seealso cref="LdapConnection#search">
+ /// </seealso>
+
+ /*
+ * Note: Exceptions generated by the reader thread are returned
+ * to the application as an exception in an LdapResponse. Thus
+ * if <code>exception</code> has a value, it is not a server response,
+ * but instad an exception returned to the application from the API.
+ */
+ public class LdapResponse:LdapMessage
+ {
+ /// <summary> Returns any error message in the response.
+ ///
+ /// </summary>
+ /// <returns> Any error message in the response.
+ /// </returns>
+ virtual public System.String ErrorMessage
+ {
+ get
+ {
+ if (exception != null)
+ {
+ return exception.LdapErrorMessage;
+ }
+
+/* RfcResponse resp=(RfcResponse)( message.Response);
+ if(resp == null)
+ Console.WriteLine(" Response is null");
+ else
+ Console.WriteLine(" Response is non null");
+ string str=resp.getErrorMessage().stringValue();
+ if( str==null)
+ Console.WriteLine("str is null..");
+ Console.WriteLine(" Response is non null" + str);
+ return str;
+*/
+ return ((RfcResponse) message.Response).getErrorMessage().stringValue();
+ }
+
+ }
+ /// <summary> Returns the partially matched DN field from the server response,
+ /// if the response contains one.
+ ///
+ /// </summary>
+ /// <returns> The partially matched DN field, if the response contains one.
+ ///
+ /// </returns>
+ virtual public System.String MatchedDN
+ {
+ get
+ {
+ if (exception != null)
+ {
+ return exception.MatchedDN;
+ }
+ return ((RfcResponse) message.Response).getMatchedDN().stringValue();
+ }
+
+ }
+ /// <summary> Returns all referrals in a server response, if the response contains any.
+ ///
+ /// </summary>
+ /// <returns> All the referrals in the server response.
+ /// </returns>
+ virtual public System.String[] Referrals
+ {
+ get
+ {
+ System.String[] referrals = null;
+ RfcReferral ref_Renamed = ((RfcResponse) message.Response).getReferral();
+
+ if (ref_Renamed == null)
+ {
+ referrals = new System.String[0];
+ }
+ else
+ {
+ // convert RFC 2251 Referral to String[]
+ int size = ref_Renamed.size();
+ referrals = new System.String[size];
+ for (int i = 0; i < size; i++)
+ {
+ System.String aRef = ((Asn1OctetString) ref_Renamed.get_Renamed(i)).stringValue();
+ try
+ {
+ // get the referral URL
+ LdapUrl urlRef = new LdapUrl(aRef);
+ if ((System.Object) urlRef.getDN() == null)
+ {
+ RfcLdapMessage origMsg = base.Asn1Object.RequestingMessage.Asn1Object;
+ System.String dn;
+ if ((System.Object) (dn = origMsg.RequestDN) != null)
+ {
+ urlRef.setDN(dn);
+ aRef = urlRef.ToString();
+ }
+ }
+ }
+ catch (System.UriFormatException mex)
+ {
+ ;
+ }
+ finally
+ {
+ referrals[i] = aRef;
+ }
+ }
+ }
+ return referrals;
+ }
+
+ }
+ /// <summary> Returns the result code in a server response.
+ ///
+ /// <p> For a list of result codes, see the LdapException class. </p>
+ ///
+ /// </summary>
+ /// <returns> The result code.
+ /// </returns>
+ virtual public int ResultCode
+ {
+ get
+ {
+ if (exception != null)
+ {
+ return exception.ResultCode;
+ }
+ return ((RfcResponse) message.Response).getResultCode().intValue();
+ }
+
+ }
+ /// <summary> Checks the resultCode and generates the appropriate exception or
+ /// null if success.
+ /// </summary>
+ virtual internal LdapException ResultException
+ {
+ /* package */
+
+ get
+ {
+ LdapException ex = null;
+ switch (ResultCode)
+ {
+
+ case LdapException.SUCCESS:
+ case LdapException.COMPARE_TRUE:
+ case LdapException.COMPARE_FALSE:
+ break;
+
+ case LdapException.REFERRAL:
+ System.String[] refs = Referrals;
+ ex = new LdapReferralException("Automatic referral following not enabled", LdapException.REFERRAL, ErrorMessage);
+ ((LdapReferralException) ex).setReferrals(refs);
+ break;
+
+ default:
+ ex = new LdapException(LdapException.resultCodeToString(ResultCode), ResultCode, ErrorMessage, MatchedDN);
+// ex = new LdapException("49", 49, "hello error", "hi error..");
+ break;
+
+ }
+ return ex;
+ }
+
+ }
+ /// <summary> Returns any controls in the message.
+ ///
+ /// </summary>
+ /// <seealso cref="com.novell.ldap.LdapMessage#getControls()">
+ /// </seealso>
+ override public LdapControl[] Controls
+ {
+ get
+ {
+ if (exception != null)
+ {
+ return null;
+ }
+ return base.Controls;
+ }
+
+ }
+ /// <summary> Returns the message ID.
+ ///
+ /// </summary>
+ /// <seealso cref="com.novell.ldap.LdapMessage#getMessageID()">
+ /// </seealso>
+ override public int MessageID
+ {
+ get
+ {
+ if (exception != null)
+ {
+ return exception.MessageID;
+ }
+ return base.MessageID;
+ }
+
+ }
+ /// <summary> Returns the Ldap operation type of the message.
+ ///
+ /// </summary>
+ /// <returns> The operation type of the message.
+ ///
+ /// </returns>
+ /// <seealso cref="com.novell.ldap.LdapMessage#getType()">
+ /// </seealso>
+ override public int Type
+ {
+ get
+ {
+ if (exception != null)
+ {
+ return exception.ReplyType;
+ }
+ return base.Type;
+ }
+
+ }
+ /// <summary> Returns an embedded exception response
+ ///
+ /// </summary>
+ /// <returns> an embedded exception if any
+ /// </returns>
+ virtual internal LdapException Exception
+ {
+ /*package*/
+
+ get
+ {
+ return exception;
+ }
+
+ }
+ /// <summary> Indicates the referral instance being followed if the
+ /// connection created to follow referrals.
+ ///
+ /// </summary>
+ /// <returns> the referral being followed
+ /// </returns>
+ virtual internal ReferralInfo ActiveReferral
+ {
+ /*package*/
+
+ get
+ {
+ return activeReferral;
+ }
+
+ }
+ private InterThreadException exception = null;
+ private ReferralInfo activeReferral;
+
+ /// <summary> Creates an LdapResponse using an LdapException.
+ /// Used to wake up the user following an abandon.
+ /// Note: The abandon doesn't have to be user initiated
+ /// but may be the result of error conditions.
+ /// <br>
+ /// Referral information is available if this connection created solely
+ /// to follow a referral.
+ ///
+ /// </summary>
+ /// <param name="ex"> The exception
+ /// <br><br>
+ /// </param>
+ /// <param name="activeReferral"> The referral actually used to create the
+ /// connection
+ /// </param>
+ public LdapResponse(InterThreadException ex, ReferralInfo activeReferral)
+ {
+ exception = ex;
+ this.activeReferral = activeReferral;
+
+ return ;
+ }
+
+ /// <summary> Creates a response LdapMessage when receiving an asynchronous
+ /// response from a server.
+ ///
+ /// </summary>
+ /// <param name="message"> The RfcLdapMessage from a server.
+ /// </param>
+ /*package*/
+ internal LdapResponse(RfcLdapMessage message):base(message)
+ {
+ return ;
+ }
+
+ /// <summary> Creates a SUCCESS response LdapMessage. Typically the response
+ /// comes from a source other than a BER encoded Ldap message,
+ /// such as from DSML. Other values which are allowed in a response
+ /// are set to their empty values.
+ ///
+ /// </summary>
+ /// <param name="type"> The message type as defined in LdapMessage.
+ ///
+ /// </param>
+ /// <seealso cref="LdapMessage">
+ /// </seealso>
+ public LdapResponse(int type):this(type, LdapException.SUCCESS, null, null, null, null)
+ {
+ return ;
+ }
+
+ /// <summary> Creates a response LdapMessage from parameters. Typically the data
+ /// comes from a source other than a BER encoded Ldap message,
+ /// such as from DSML.
+ ///
+ /// </summary>
+ /// <param name="type"> The message type as defined in LdapMessage.
+ ///
+ /// </param>
+ /// <param name="resultCode"> The result code as defined in LdapException.
+ ///
+ /// </param>
+ /// <param name="matchedDN"> The name of the lowest entry that was matched
+ /// for some error result codes, an empty string
+ /// or <code>null</code> if none.
+ ///
+ /// </param>
+ /// <param name="serverMessage"> A diagnostic message returned by the server,
+ /// an empty string or <code>null</code> if none.
+ ///
+ /// </param>
+ /// <param name="referrals"> The referral URLs returned for a REFERRAL result
+ /// code or <code>null</code> if none.
+ ///
+ /// </param>
+ /// <param name="controls"> Any controls returned by the server or
+ /// <code>null</code> if none.
+ ///
+ /// </param>
+ /// <seealso cref="LdapMessage">
+ /// </seealso>
+ /// <seealso cref="LdapException">
+ /// </seealso>
+ public LdapResponse(int type, int resultCode, System.String matchedDN, System.String serverMessage, System.String[] referrals, LdapControl[] controls):base(new RfcLdapMessage(RfcResultFactory(type, resultCode, matchedDN, serverMessage, referrals)))
+ {
+
+ return ;
+ }
+
+ private static Asn1Sequence RfcResultFactory(int type, int resultCode, System.String matchedDN, System.String serverMessage, System.String[] referrals)
+ {
+ Asn1Sequence ret;
+
+ if ((System.Object) matchedDN == null)
+ matchedDN = "";
+ if ((System.Object) serverMessage == null)
+ serverMessage = "";
+
+ switch (type)
+ {
+
+ case SEARCH_RESULT:
+ ret = new RfcSearchResultDone(new Asn1Enumerated(resultCode), new RfcLdapDN(matchedDN), new RfcLdapString(serverMessage), null);
+ break;
+
+ case BIND_RESPONSE:
+ ret = null; // Not yet implemented
+ break;
+
+ case SEARCH_RESPONSE:
+ ret = null; // Not yet implemented
+ break;
+
+ case MODIFY_RESPONSE:
+ ret = new RfcModifyResponse(new Asn1Enumerated(resultCode), new RfcLdapDN(matchedDN), new RfcLdapString(serverMessage), null);
+ break;
+
+ case ADD_RESPONSE:
+ ret = new RfcAddResponse(new Asn1Enumerated(resultCode), new RfcLdapDN(matchedDN), new RfcLdapString(serverMessage), null);
+ break;
+
+ case DEL_RESPONSE:
+ ret = new RfcDelResponse(new Asn1Enumerated(resultCode), new RfcLdapDN(matchedDN), new RfcLdapString(serverMessage), null);
+ break;
+
+ case MODIFY_RDN_RESPONSE:
+ ret = new RfcModifyDNResponse(new Asn1Enumerated(resultCode), new RfcLdapDN(matchedDN), new RfcLdapString(serverMessage), null);
+ break;
+
+ case COMPARE_RESPONSE:
+ ret = new RfcCompareResponse(new Asn1Enumerated(resultCode), new RfcLdapDN(matchedDN), new RfcLdapString(serverMessage), null);
+ break;
+
+ case SEARCH_RESULT_REFERENCE:
+ ret = null; // Not yet implemented
+ break;
+
+ case EXTENDED_RESPONSE:
+ ret = null; // Not yet implemented
+ break;
+
+ default:
+ throw new System.SystemException("Type " + type + " Not Supported");
+
+ }
+ return ret;
+ }
+
+ /// <summary> Checks the resultCode and throws the appropriate exception.
+ ///
+ /// </summary>
+ /// <exception cref=""> LdapException A general exception which includes an error
+ /// message and an Ldap error code.
+ /// </exception>
+ /* package */
+ internal virtual void chkResultCode()
+ {
+ if (exception != null)
+ {
+ throw exception;
+ }
+ else
+ {
+ LdapException ex = ResultException;
+ if (ex != null)
+ {
+ throw ex;
+ }
+ return ;
+ }
+ }
+
+ /* Methods from LdapMessage */
+
+ /// <summary> Indicates if this response is an embedded exception response
+ ///
+ /// </summary>
+ /// <returns> true if contains an embedded Ldapexception
+ /// </returns>
+ /*package*/
+ internal virtual bool hasException()
+ {
+ return (exception != null);
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapResponseQueue.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapResponseQueue.cs
new file mode 100755
index 00000000000..a6eeaa288a7
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapResponseQueue.cs
@@ -0,0 +1,78 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.LdapResponseQueue.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+
+namespace Novell.Directory.Ldap
+{
+
+ /// <summary> A mechanism for processing asynchronous messages received from a server.
+ /// It represents the message queue associated with a particular asynchronous
+ /// Ldap operation or operations.
+ /// </summary>
+ public class LdapResponseQueue:LdapMessageQueue
+ {
+ /// <summary> Constructs a response queue using the specified message agent
+ ///
+ /// </summary>
+ /// <param name="agent">The message agent to associate with this queue
+ /// </param>
+ /* package */
+ internal LdapResponseQueue(MessageAgent agent):base("LdapResponseQueue", agent)
+ {
+ return ;
+ }
+
+ /// <summary> Merges two message queues. It appends the current and
+ /// future contents from another queue to this one.
+ ///
+ /// <p>After the operation, queue2.getMessageIDs()
+ /// returns an empty array, and its outstanding responses
+ /// have been removed and appended to this queue</p>.
+ ///
+ /// </summary>
+ /// <param name="queue2"> The queue that is merged from. Following
+ /// the merge, this queue object will no
+ /// longer receive any data, and calls made
+ /// to its methods will fail with a RuntimeException.
+ /// The queue can be reactivated by using it in an
+ /// Ldap request, after which it will receive responses
+ /// for that request..
+ /// </param>
+ public virtual void merge(LdapMessageQueue queue2)
+ {
+ LdapResponseQueue q = (LdapResponseQueue) queue2;
+ agent.merge(q.MessageAgent);
+
+ return ;
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapSearchConstraints.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapSearchConstraints.cs
new file mode 100755
index 00000000000..8e0f135d3f8
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapSearchConstraints.cs
@@ -0,0 +1,430 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.LdapSearchConstraints.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+
+namespace Novell.Directory.Ldap
+{
+
+ /// <summary>
+ /// Defines the options controlling search operations.
+ ///
+ /// <p>An LdapSearchConstraints object is always associated with an
+ /// LdapConnection object; its values can be changed with the
+ /// LdapConnection.setConstraints method, or overridden by passing
+ /// an LdapSearchConstraints object to the search operation.</p>
+ ///
+ /// </summary>
+ /// <seealso cref="LdapConstraints">
+ /// </seealso>
+ /// <seealso cref="LdapConnection#setConstraints(LdapConstraints)">
+ /// </seealso>
+ public class LdapSearchConstraints:LdapConstraints
+ {
+ private void InitBlock()
+ {
+ dereference = DEREF_NEVER;
+ }
+ /// <summary> Returns the number of results to block on during receipt of search
+ /// results.
+ ///
+ /// </p>This should be 0 if intermediate reults are not needed,
+ /// and 1 if results are to be processed as they come in. A value of
+ /// indicates block until all results are received. Default: </p>
+ ///
+ /// </summary>
+ /// <returns> The the number of results to block on.
+ ///
+ /// </returns>
+ /// <seealso cref="#setBatchSize(int)">
+ /// </seealso>
+ /// <summary> Specifies the number of results to return in a batch.
+ /// <p>Specifying 0 means to block until all results are received.
+ /// Specifying 1 means to return results one result at a time. Default: 1
+ /// </p>
+ ///
+ /// <p>This should be 0 if intermediate results are not needed,
+ /// and 1 if results are to be processed as they come in. The
+ /// default is 1.
+ ///
+ /// </summary>
+ /// <param name="batchSize"> The number of results to block on.
+ ///
+ /// </param>
+ /// <seealso cref="#getBatchSize()">
+ /// </seealso>
+ virtual public int BatchSize
+ {
+ get
+ {
+ return batchSize;
+ }
+
+ set
+ {
+ this.batchSize = value;
+ return ;
+ }
+
+ }
+ /// <summary> Specifies when aliases should be dereferenced.
+ ///
+ /// <p>Returns one of the following:
+ /// <ul>
+ /// <li>DEREF_NEVER</li>
+ /// <li>DEREF_FINDING</li>
+ /// <li>DEREF_SEARCHING</li>
+ /// <li>DEREF_ALWAYS</li>
+ /// </ul>
+ ///
+ /// </summary>
+ /// <returns> The setting for dereferencing aliases.
+ ///
+ /// </returns>
+ /// <seealso cref="#setDereference(int)">
+ /// </seealso>
+ /// <summary> Sets a preference indicating whether or not aliases should be
+ /// dereferenced, and if so, when.
+ ///
+ ///
+ /// </summary>
+ /// <param name="dereference"> Specifies how aliases are dereference and can be set
+ /// to one of the following:
+ /// <ul>
+ /// <li>DEREF_NEVER - do not dereference aliases</li>
+ /// <li>DEREF_FINDING - dereference aliases when finding
+ /// the base object to start the search</li>
+ /// <li>DEREF_SEARCHING - dereference aliases when
+ /// searching but not when finding the base
+ /// object to start the search</li>
+ /// <li>DEREF_ALWAYS - dereference aliases when finding
+ /// the base object and when searching</li>
+ /// </ul>
+ ///
+ /// </param>
+ /// <seealso cref="#getDereference()">
+ /// </seealso>
+ virtual public int Dereference
+ {
+ get
+ {
+ return dereference;
+ }
+
+ set
+ {
+ this.dereference = value;
+ return ;
+ }
+
+ }
+ /// <summary> Returns the maximum number of search results to be returned for
+ /// a search operation. A value of 0 means no limit. Default: 1000
+ /// The search operation will be terminated with an
+ /// LdapException.SIZE_LIMIT_EXCEEDED if the number of results
+ /// exceed the maximum.
+ ///
+ /// </summary>
+ /// <returns> The value for the maximum number of results to return.
+ ///
+ /// </returns>
+ /// <seealso cref="#setMaxResults(int)">
+ /// </seealso>
+ /// <seealso cref="LdapException#SIZE_LIMIT_EXCEEDED">
+ /// </seealso>
+ /// <summary> Sets the maximum number of search results to be returned from a
+ /// search operation. The value 0 means no limit. The default is 1000.
+ /// The search operation will be terminated with an
+ /// LdapException.SIZE_LIMIT_EXCEEDED if the number of results
+ /// exceed the maximum.
+ ///
+ /// </summary>
+ /// <param name="maxResults"> Maximum number of search results to return.
+ ///
+ /// </param>
+ /// <seealso cref="#getMaxResults()">
+ /// </seealso>
+ /// <seealso cref="LdapException#SIZE_LIMIT_EXCEEDED">
+ /// </seealso>
+ virtual public int MaxResults
+ {
+ get
+ {
+ return maxResults;
+ }
+
+ set
+ {
+ this.maxResults = value;
+ return ;
+ }
+
+ }
+ /// <summary> Returns the maximum number of seconds that the server waits when
+ /// returning search results.
+ /// The search operation will be terminated with an
+ /// LdapException.TIME_LIMIT_EXCEEDED if the operation exceeds the time
+ /// limit.
+ ///
+ /// </summary>
+ /// <returns> The maximum number of seconds the server waits for search'
+ /// results.
+ ///
+ /// </returns>
+ /// <seealso cref="#setServerTimeLimit(int)">
+ /// </seealso>
+ /// <seealso cref="LdapException#TIME_LIMIT_EXCEEDED">
+ /// </seealso>
+ /// <summary> Sets the maximum number of seconds that the server is to wait when
+ /// returning search results.
+ /// The search operation will be terminated with an
+ /// LdapException.TIME_LIMIT_EXCEEDED if the operation exceeds the time
+ /// limit.
+ ///
+ /// <p>The parameter is only recognized on search operations. </p>
+ ///
+ /// </summary>
+ /// <param name="seconds">The number of seconds to wait for search results.
+ ///
+ /// </param>
+ /// <seealso cref="#getServerTimeLimit()">
+ /// </seealso>
+ /// <seealso cref="LdapException#TIME_LIMIT_EXCEEDED">
+ /// </seealso>
+ virtual public int ServerTimeLimit
+ {
+ get
+ {
+ return serverTimeLimit;
+ }
+
+ set
+ {
+ this.serverTimeLimit = value;
+ return ;
+ }
+
+ }
+
+ private int dereference;
+ private int serverTimeLimit = 0;
+ private int maxResults = 1000;
+ private int batchSize = 1;
+ new private static System.Object nameLock; // protect agentNum
+ private static int lSConsNum = 0; // Debug, LdapConnection number
+ new private System.String name; // String name for debug
+
+ /// <summary> Indicates that aliases are never dereferenced.
+ ///
+ /// <p> DEREF_NEVER = 0 </p>
+ ///
+ /// </summary>
+ /// <seealso cref="#getDereference()">
+ /// </seealso>
+ /// <seealso cref="#setDereference(int)">
+ /// </seealso>
+ public const int DEREF_NEVER = 0;
+
+ /// <summary> Indicates that aliases are are derefrenced when
+ /// searching the entries beneath the starting point of the search,
+ /// but not when finding the starting entry.
+ ///
+ /// <p> DEREF_SEARCHING = 1 </p>
+ ///
+ /// </summary>
+ /// <seealso cref="#getDereference()">
+ /// </seealso>
+ /// <seealso cref="#setDereference(int)">
+ /// </seealso>
+ public const int DEREF_SEARCHING = 1;
+
+ /// <summary> Indicates that aliases are dereferenced when
+ /// finding the starting point for the search,
+ /// but not when searching under that starting entry.
+ ///
+ /// <p> DEREF_FINDING = 2 </p>
+ ///
+ /// </summary>
+ /// <seealso cref="#getDereference()">
+ /// </seealso>
+ /// <seealso cref="#setDereference(int)">
+ /// </seealso>
+ public const int DEREF_FINDING = 2;
+
+ /// <summary> Indicates that aliases are always dereferenced, both when
+ /// finding the starting point for the search, and also when
+ /// searching the entries beneath the starting entry.
+ ///
+ /// <p> DEREF_ALWAYS = 3 </p>
+ ///
+ /// </summary>
+ /// <seealso cref="#getDereference()">
+ /// </seealso>
+ /// <seealso cref="#setDereference(int)">
+ /// </seealso>
+ public const int DEREF_ALWAYS = 3;
+
+ /// <summary> Constructs an LdapSearchConstraints object with a default set
+ /// of search constraints.
+ /// </summary>
+ public LdapSearchConstraints():base()
+ {
+ InitBlock();
+ // Get a unique connection name for debug
+ }
+
+ /// <summary> Constructs an LdapSearchConstraints object initialized with values
+ /// from an existing constraints object (LdapConstraints
+ /// or LdapSearchConstraints).
+ /// </summary>
+ public LdapSearchConstraints(LdapConstraints cons):base(cons.TimeLimit, cons.ReferralFollowing, cons.getReferralHandler(), cons.HopLimit)
+ {
+ InitBlock();
+ LdapControl[] lsc = cons.getControls();
+ if (lsc != null)
+ {
+ LdapControl[] generated_var = new LdapControl[lsc.Length];
+ lsc.CopyTo(generated_var, 0);
+ base.setControls(generated_var);
+ }
+ System.Collections.Hashtable lp = cons.Properties;
+ if (lp != null)
+ {
+ base.Properties = (System.Collections.Hashtable) lp.Clone();
+ }
+
+ if (cons is LdapSearchConstraints)
+ {
+ LdapSearchConstraints scons = (LdapSearchConstraints) cons;
+ this.serverTimeLimit = scons.ServerTimeLimit;
+ this.dereference = scons.Dereference;
+ this.maxResults = scons.MaxResults;
+ this.batchSize = scons.BatchSize;
+ }
+ // Get a unique connection name for debug
+ return ;
+ }
+
+ /// <summary> Constructs a new LdapSearchConstraints object and allows the
+ /// specification operational constraints in that object.
+ ///
+ /// </summary>
+ /// <param name="msLimit"> The maximum time in milliseconds to wait for results.
+ /// The default is 0, which means that there is no
+ /// maximum time limit. This limit is enforced for an
+ /// operation by the API, not by the server.
+ /// The operation will be abandoned and terminated by the
+ /// API with an LdapException.Ldap_TIMEOUT if the
+ /// operation exceeds the time limit.
+ /// <br><br>
+ /// </param>
+ /// <param name="serverTimeLimit">The maximum time in seconds that the server
+ /// should spend returning search results. This is a
+ /// server-enforced limit. The default of 0 means
+ /// no time limit.
+ /// The operation will be terminated by the server with an
+ /// LdapException.TIME_LIMIT_EXCEEDED if the search
+ /// operation exceeds the time limit.
+ /// <br><br>
+ /// </param>
+ /// <param name="dereference">Specifies when aliases should be dereferenced.
+ /// Must be either DEREF_NEVER, DEREF_FINDING,
+ /// DEREF_SEARCHING, or DEREF_ALWAYS from this class.
+ /// Default: DEREF_NEVER
+ /// <br><br>
+ /// </param>
+ /// <param name="maxResults">The maximum number of search results to return
+ /// for a search request.
+ /// The search operation will be terminated by the server
+ /// with an LdapException.SIZE_LIMIT_EXCEEDED if the
+ /// number of results exceed the maximum.
+ /// Default: 1000
+ /// <br><br>
+ /// </param>
+ /// <param name="doReferrals">Determines whether to automatically follow
+ /// referrals or not. Specify true to follow
+ /// referrals automatically, and false to throw
+ /// an LdapException.REFERRAL if the server responds
+ /// with a referral.
+ /// It is ignored for asynchronous operations.
+ /// Default: false
+ /// <br><br>
+ /// </param>
+ /// <param name="batchSize">The number of results to return in a batch. Specifying
+ /// 0 means to block until all results are received.
+ /// Specifying 1 means to return results one result at a
+ /// time. Default: 1
+ ///
+ /// <br><br>
+ /// </param>
+ /// <param name="handler"> The custom authentication handler called when
+ /// LdapConnection needs to authenticate, typically on
+ /// following a referral. A null may be specified to
+ /// indicate default authentication processing, i.e.
+ /// referrals are followed with anonymous authentication.
+ /// ThE object may be an implemention of either the
+ /// the LdapBindHandler or LdapAuthHandler interface.
+ /// It is ignored for asynchronous operations.
+ /// <br><br>
+ /// </param>
+ /// <param name="hop_limit">The maximum number of referrals to follow in a
+ /// sequence during automatic referral following.
+ /// The default value is 10. A value of 0 means no limit.
+ /// It is ignored for asynchronous operations.
+ /// The operation will be abandoned and terminated by the
+ /// API with an LdapException.REFERRAL_LIMIT_EXCEEDED if the
+ /// number of referrals in a sequence exceeds the limit.
+ ///
+ /// </param>
+ /// <seealso cref="LdapException#Ldap_TIMEOUT">
+ /// </seealso>
+ /// <seealso cref="LdapException#REFERRAL">
+ /// </seealso>
+ /// <seealso cref="LdapException#SIZE_LIMIT_EXCEEDED">
+ /// </seealso>
+ /// <seealso cref="LdapException#TIME_LIMIT_EXCEEDED">
+ /// </seealso>
+ public LdapSearchConstraints(int msLimit, int serverTimeLimit, int dereference, int maxResults, bool doReferrals, int batchSize, LdapReferralHandler handler, int hop_limit):base(msLimit, doReferrals, handler, hop_limit)
+ {
+ InitBlock();
+ this.serverTimeLimit = serverTimeLimit;
+ this.dereference = dereference;
+ this.maxResults = maxResults;
+ this.batchSize = batchSize;
+ // Get a unique connection name for debug
+ return ;
+ }
+ static LdapSearchConstraints()
+ {
+ nameLock = new System.Object();
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapSearchQueue.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapSearchQueue.cs
new file mode 100755
index 00000000000..2dc1e9924cf
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapSearchQueue.cs
@@ -0,0 +1,82 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.LdapSearchQueue.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+
+namespace Novell.Directory.Ldap
+{
+
+ /// <summary> A mechanism for queuing asynchronous search results
+ /// received from a server.
+ ///
+ /// </summary>
+ /// <seealso cref="LdapConnection#search">
+ /// </seealso>
+ /// <seealso cref="LdapResponseQueue">
+ /// </seealso>
+ public class LdapSearchQueue:LdapMessageQueue
+ {
+ /// <summary> Constructs a response queue using a specific client queue
+ ///
+ /// </summary>
+ /// <param name="agent">The message agent to associate with this queue
+ /// </param>
+ /* package */
+ internal LdapSearchQueue(MessageAgent agent):base("LdapSearchQueue", agent)
+ {
+ return ;
+ }
+ /// <summary> Merges two message queues. It appends the current and
+ /// future contents from another queue to this one.
+ ///
+ /// <p>After the operation, queue2.getMessageIDs()
+ /// returns an empty array, and its outstanding responses
+ /// have been removed and appended to this queue</p>.
+ ///
+ /// </summary>
+ /// <param name="queue2"> The queue that is merged from. Following
+ /// the merge, this queue object will no
+ /// longer receive any data, and calls made
+ /// to its methods will fail with a RuntimeException.
+ /// The queue can be reactivated by using it in an
+ /// Ldap request, after which it will receive responses
+ /// for that request..
+ /// </param>
+ public virtual void merge(LdapMessageQueue queue2)
+ {
+
+ LdapSearchQueue q = (LdapSearchQueue) queue2;
+ agent.merge(q.MessageAgent);
+
+ return ;
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapSearchRequest.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapSearchRequest.cs
new file mode 100755
index 00000000000..f8ebdcd71c3
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapSearchRequest.cs
@@ -0,0 +1,405 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.LdapSearchRequest.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+using Novell.Directory.Ldap.Asn1;
+using Novell.Directory.Ldap.Rfc2251;
+
+namespace Novell.Directory.Ldap
+{
+
+ /// <summary> Represents an Ldap Search request.
+ ///
+ /// </summary>
+ /// <seealso cref="LdapConnection#sendRequest">
+ /// </seealso>
+ /*
+ * SearchRequest ::= [APPLICATION 3] SEQUENCE {
+ * baseObject LdapDN,
+ * scope ENUMERATED {
+ * baseObject (0),
+ * singleLevel (1),
+ * wholeSubtree (2) },
+ * derefAliases ENUMERATED {
+ * neverDerefAliases (0),
+ * derefInSearching (1),
+ * derefFindingBaseObj (2),
+ * derefAlways (3) },
+ * sizeLimit INTEGER (0 .. maxInt),
+ * timeLimit INTEGER (0 .. maxInt),
+ * typesOnly BOOLEAN,
+ * filter Filter,
+ * attributes AttributeDescriptionList }
+ */
+ public class LdapSearchRequest:LdapMessage
+ {
+ /// <summary> Retrieves the Base DN for a search request.
+ ///
+ /// </summary>
+ /// <returns> the base DN for a search request
+ /// </returns>
+ virtual public System.String DN
+ {
+ get
+ {
+ return Asn1Object.RequestDN;
+ }
+
+ }
+ /// <summary> Retrieves the scope of a search request.</summary>
+ /// <returns> scope of a search request
+ ///
+ /// </returns>
+ /// <seealso cref="com.novell.ldap.LdapConnection#SCOPE_BASE">
+ /// </seealso>
+ /// <seealso cref="com.novell.ldap.LdapConnection#SCOPE_ONE">
+ /// </seealso>
+ /// <seealso cref="com.novell.ldap.LdapConnection#SCOPE_SUB">
+ /// </seealso>
+ virtual public int Scope
+ {
+ get
+ {
+ //element number one stores the scope
+ return ((Asn1Enumerated) ((RfcSearchRequest) (this.Asn1Object).get_Renamed(1)).get_Renamed(1)).intValue();
+ }
+
+ }
+ /// <summary> Retrieves the behaviour of dereferencing aliases on a search request.</summary>
+ /// <returns> integer representing how to dereference aliases
+ ///
+ /// </returns>
+ /// <seealso cref="com.novell.ldap.LdapSearchConstraints#DEREF_ALWAYS">
+ /// </seealso>
+ /// <seealso cref="com.novell.ldap.LdapSearchConstraints#DEREF_FINDING">
+ /// </seealso>
+ /// <seealso cref="com.novell.ldap.LdapSearchConstraints#DEREF_NEVER">
+ /// </seealso>
+ /// <seealso cref="com.novell.ldap.LdapSearchConstraints#DEREF_SEARCHING">
+ /// </seealso>
+ virtual public int Dereference
+ {
+ get
+ {
+ //element number two stores the dereference
+ return ((Asn1Enumerated) ((RfcSearchRequest) (this.Asn1Object).get_Renamed(1)).get_Renamed(2)).intValue();
+ }
+
+ }
+ /// <summary> Retrieves the maximum number of entries to be returned on a search.
+ ///
+ /// </summary>
+ /// <returns> Maximum number of search entries.
+ /// </returns>
+ virtual public int MaxResults
+ {
+ get
+ {
+ //element number three stores the max results
+ return ((Asn1Integer) ((RfcSearchRequest) (this.Asn1Object).get_Renamed(1)).get_Renamed(3)).intValue();
+ }
+
+ }
+ /// <summary> Retrieves the server time limit for a search request.
+ ///
+ /// </summary>
+ /// <returns> server time limit in nanoseconds.
+ /// </returns>
+ virtual public int ServerTimeLimit
+ {
+ get
+ {
+ //element number four stores the server time limit
+ return ((Asn1Integer) ((RfcSearchRequest) (this.Asn1Object).get_Renamed(1)).get_Renamed(4)).intValue();
+ }
+
+ }
+ /// <summary> Retrieves whether attribute values or only attribute types(names) should
+ /// be returned in a search request.
+ /// </summary>
+ /// <returns> true if only attribute types (names) are returned, false if
+ /// attributes types and values are to be returned.
+ /// </returns>
+ virtual public bool TypesOnly
+ {
+ get
+ {
+ //element number five stores types value
+ return ((Asn1Boolean) ((RfcSearchRequest) (this.Asn1Object).get_Renamed(1)).get_Renamed(5)).booleanValue();
+ }
+
+ }
+ /// <summary> Retrieves an array of attribute names to request for in a search.</summary>
+ /// <returns> Attribute names to be searched
+ /// </returns>
+ virtual public System.String[] Attributes
+ {
+ get
+ {
+ RfcAttributeDescriptionList attrs = (RfcAttributeDescriptionList) ((RfcSearchRequest) (this.Asn1Object).get_Renamed(1)).get_Renamed(7);
+
+ System.String[] rAttrs = new System.String[attrs.size()];
+ for (int i = 0; i < rAttrs.Length; i++)
+ {
+ rAttrs[i] = ((RfcAttributeDescription) attrs.get_Renamed(i)).stringValue();
+ }
+ return rAttrs;
+ }
+
+ }
+ /// <summary> Creates a string representation of the filter in this search request.</summary>
+ /// <returns> filter string for this search request
+ /// </returns>
+ virtual public System.String StringFilter
+ {
+ get
+ {
+ return this.RfcFilter.filterToString();
+ }
+
+ }
+ /// <summary> Retrieves an SearchFilter object representing a filter for a search request</summary>
+ /// <returns> filter object for a search request.
+ /// </returns>
+ private RfcFilter RfcFilter
+ {
+ get
+ {
+ return (RfcFilter) ((RfcSearchRequest) (this.Asn1Object).get_Renamed(1)).get_Renamed(6);
+ }
+
+ }
+ /// <summary> Retrieves an Iterator object representing the parsed filter for
+ /// this search request.
+ ///
+ /// <p>The first object returned from the Iterator is an Integer indicating
+ /// the type of filter component. One or more values follow the component
+ /// type as subsequent items in the Iterator. The pattern of Integer
+ /// component type followed by values continues until the end of the
+ /// filter.</p>
+ ///
+ /// <p>Values returned as a byte array may represent UTF-8 characters or may
+ /// be binary values. The possible Integer components of a search filter
+ /// and the associated values that follow are:
+ /// <ul>
+ /// <li>AND - followed by an Iterator value</li>
+ /// <li>OR - followed by an Iterator value</li>
+ /// <li>NOT - followed by an Iterator value</li>
+ /// <li>EQUALITY_MATCH - followed by the attribute name represented as a
+ /// String, and by the attribute value represented as a byte array</li>
+ /// <li>GREATER_OR_EQUAL - followed by the attribute name represented as a
+ /// String, and by the attribute value represented as a byte array</li>
+ /// <li>LESS_OR_EQUAL - followed by the attribute name represented as a
+ /// String, and by the attribute value represented as a byte array</li>
+ /// <li>APPROX_MATCH - followed by the attribute name represented as a
+ /// String, and by the attribute value represented as a byte array</li>
+ /// <li>PRESENT - followed by a attribute name respresented as a String</li>
+ /// <li>EXTENSIBLE_MATCH - followed by the name of the matching rule
+ /// represented as a String, by the attribute name represented
+ /// as a String, and by the attribute value represented as a
+ /// byte array.
+ /// <li>SUBSTRINGS - followed by the attribute name represented as a
+ /// String, by one or more SUBSTRING components (INITIAL, ANY,
+ /// or FINAL) followed by the SUBSTRING value.
+ /// </ul></p>
+ ///
+ /// </summary>
+ /// <returns> Iterator representing filter components
+ /// </returns>
+ virtual public System.Collections.IEnumerator SearchFilter
+ {
+ get
+ {
+ return RfcFilter.getFilterIterator();
+ }
+
+ }
+ //*************************************************************************
+ // Public variables for Filter
+ //*************************************************************************
+
+ /// <summary> Search Filter Identifier for an AND component.</summary>
+ public const int AND = 0;
+ /// <summary> Search Filter Identifier for an OR component.</summary>
+ public const int OR = 1;
+ /// <summary> Search Filter Identifier for a NOT component.</summary>
+ public const int NOT = 2;
+ /// <summary> Search Filter Identifier for an EQUALITY_MATCH component.</summary>
+ public const int EQUALITY_MATCH = 3;
+ /// <summary> Search Filter Identifier for a SUBSTRINGS component.</summary>
+ public const int SUBSTRINGS = 4;
+ /// <summary> Search Filter Identifier for a GREATER_OR_EQUAL component.</summary>
+ public const int GREATER_OR_EQUAL = 5;
+ /// <summary> Search Filter Identifier for a LESS_OR_EQUAL component.</summary>
+ public const int LESS_OR_EQUAL = 6;
+ /// <summary> Search Filter Identifier for a PRESENT component.</summary>
+ public const int PRESENT = 7;
+ /// <summary> Search Filter Identifier for an APPROX_MATCH component.</summary>
+ public const int APPROX_MATCH = 8;
+ /// <summary> Search Filter Identifier for an EXTENSIBLE_MATCH component.</summary>
+ public const int EXTENSIBLE_MATCH = 9;
+
+ /// <summary> Search Filter Identifier for an INITIAL component of a SUBSTRING.
+ /// Note: An initial SUBSTRING is represented as "<value>*".
+ /// </summary>
+ public const int INITIAL = 0;
+ /// <summary> Search Filter Identifier for an ANY component of a SUBSTRING.
+ /// Note: An ANY SUBSTRING is represented as "*<value>*".
+ /// </summary>
+ public const int ANY = 1;
+ /// <summary> Search Filter Identifier for a FINAL component of a SUBSTRING.
+ /// Note: A FINAL SUBSTRING is represented as "*<value>".
+ /// </summary>
+ public const int FINAL = 2;
+
+ /// <summary> Constructs an Ldap Search Request.
+ ///
+ /// </summary>
+ /// <param name="base"> The base distinguished name to search from.
+ /// <br><br>
+ /// </param>
+ /// <param name="scope"> The scope of the entries to search. The following
+ /// are the valid options:
+ /// <ul>
+ /// <li>SCOPE_BASE - searches only the base DN
+ ///
+ /// <li>SCOPE_ONE - searches only entries under the base DN
+ ///
+ /// <li>SCOPE_SUB - searches the base DN and all entries
+ /// within its subtree
+ /// </ul><br><br>
+ /// </param>
+ /// <param name="filter"> The search filter specifying the search criteria.
+ /// <br><br>
+ /// </param>
+ /// <param name="attrs"> The names of attributes to retrieve.
+ /// operation exceeds the time limit.
+ /// <br><br>
+ /// </param>
+ /// <param name="dereference">Specifies when aliases should be dereferenced.
+ /// Must be one of the constants defined in
+ /// LdapConstraints, which are DEREF_NEVER,
+ /// DEREF_FINDING, DEREF_SEARCHING, or DEREF_ALWAYS.
+ /// <br><br>
+ /// </param>
+ /// <param name="maxResults">The maximum number of search results to return
+ /// for a search request.
+ /// The search operation will be terminated by the server
+ /// with an LdapException.SIZE_LIMIT_EXCEEDED if the
+ /// number of results exceed the maximum.
+ /// <br><br>
+ /// </param>
+ /// <param name="serverTimeLimit">The maximum time in seconds that the server
+ /// should spend returning search results. This is a
+ /// server-enforced limit. A value of 0 means
+ /// no time limit.
+ /// <br><br>
+ /// </param>
+ /// <param name="typesOnly"> If true, returns the names but not the values of
+ /// the attributes found. If false, returns the
+ /// names and values for attributes found.
+ /// <br><br>
+ /// </param>
+ /// <param name="cont"> Any controls that apply to the search request.
+ /// or null if none.
+ ///
+ /// </param>
+ /// <seealso cref="com.novell.ldap.LdapConnection#search">
+ /// </seealso>
+ /// <seealso cref="com.novell.ldap.LdapSearchConstraints">
+ /// </seealso>
+ public LdapSearchRequest(System.String base_Renamed, int scope, System.String filter, System.String[] attrs, int dereference, int maxResults, int serverTimeLimit, bool typesOnly, LdapControl[] cont):base(LdapMessage.SEARCH_REQUEST, new RfcSearchRequest(new RfcLdapDN(base_Renamed), new Asn1Enumerated(scope), new Asn1Enumerated(dereference), new Asn1Integer(maxResults), new Asn1Integer(serverTimeLimit), new Asn1Boolean(typesOnly), new RfcFilter(filter), new RfcAttributeDescriptionList(attrs)), cont)
+ {
+ return ;
+ }
+
+ /// <summary> Constructs an Ldap Search Request with a filter in Asn1 format.
+ ///
+ /// </summary>
+ /// <param name="base"> The base distinguished name to search from.
+ /// <br><br>
+ /// </param>
+ /// <param name="scope"> The scope of the entries to search. The following
+ /// are the valid options:
+ /// <ul>
+ /// <li>SCOPE_BASE - searches only the base DN
+ ///
+ /// <li>SCOPE_ONE - searches only entries under the base DN
+ ///
+ /// <li>SCOPE_SUB - searches the base DN and all entries
+ /// within its subtree
+ /// </ul><br><br>
+ /// </param>
+ /// <param name="filter"> The search filter specifying the search criteria.
+ /// <br><br>
+ /// </param>
+ /// <param name="attrs"> The names of attributes to retrieve.
+ /// operation exceeds the time limit.
+ /// <br><br>
+ /// </param>
+ /// <param name="dereference">Specifies when aliases should be dereferenced.
+ /// Must be either one of the constants defined in
+ /// LdapConstraints, which are DEREF_NEVER,
+ /// DEREF_FINDING, DEREF_SEARCHING, or DEREF_ALWAYS.
+ /// <br><br>
+ /// </param>
+ /// <param name="maxResults">The maximum number of search results to return
+ /// for a search request.
+ /// The search operation will be terminated by the server
+ /// with an LdapException.SIZE_LIMIT_EXCEEDED if the
+ /// number of results exceed the maximum.
+ /// <br><br>
+ /// </param>
+ /// <param name="serverTimeLimit">The maximum time in seconds that the server
+ /// should spend returning search results. This is a
+ /// server-enforced limit. A value of 0 means
+ /// no time limit.
+ /// <br><br>
+ /// </param>
+ /// <param name="typesOnly"> If true, returns the names but not the values of
+ /// the attributes found. If false, returns the
+ /// names and values for attributes found.
+ /// <br><br>
+ /// </param>
+ /// <param name="cont"> Any controls that apply to the search request.
+ /// or null if none.
+ ///
+ /// </param>
+ /// <seealso cref="com.novell.ldap.LdapConnection#search">
+ /// </seealso>
+ /// <seealso cref="com.novell.ldap.LdapSearchConstraints">
+ /// </seealso>
+ public LdapSearchRequest(System.String base_Renamed, int scope, RfcFilter filter, System.String[] attrs, int dereference, int maxResults, int serverTimeLimit, bool typesOnly, LdapControl[] cont):base(LdapMessage.SEARCH_REQUEST, new RfcSearchRequest(new RfcLdapDN(base_Renamed), new Asn1Enumerated(scope), new Asn1Enumerated(dereference), new Asn1Integer(maxResults), new Asn1Integer(serverTimeLimit), new Asn1Boolean(typesOnly), filter, new RfcAttributeDescriptionList(attrs)), cont)
+ {
+ return ;
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapSearchResult.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapSearchResult.cs
new file mode 100755
index 00000000000..71553fbe84f
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapSearchResult.cs
@@ -0,0 +1,133 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.LdapSearchResult.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+using Novell.Directory.Ldap.Asn1;
+using Novell.Directory.Ldap.Rfc2251;
+
+namespace Novell.Directory.Ldap
+{
+
+ /// <summary> Encapsulates a single search result that is in response to an asynchronous
+ /// search operation.
+ /// </summary>
+ /// <seealso cref="LdapConnection#search">
+ /// </seealso>
+ public class LdapSearchResult:LdapMessage
+ {
+ /// <summary> Returns the entry of a server's search response.
+ ///
+ /// </summary>
+ /// <returns> The LdapEntry associated with this LdapSearchResult
+ /// </returns>
+ virtual public LdapEntry Entry
+ {
+ get
+ {
+ if (entry == null)
+ {
+ LdapAttributeSet attrs = new LdapAttributeSet();
+
+ Asn1Sequence attrList = ((RfcSearchResultEntry) message.Response).Attributes;
+
+ Asn1Object[] seqArray = attrList.toArray();
+ for (int i = 0; i < seqArray.Length; i++)
+ {
+ Asn1Sequence seq = (Asn1Sequence) seqArray[i];
+ LdapAttribute attr = new LdapAttribute(((Asn1OctetString) seq.get_Renamed(0)).stringValue());
+
+ Asn1Set set_Renamed = (Asn1Set) seq.get_Renamed(1);
+ System.Object[] setArray = set_Renamed.toArray();
+ for (int j = 0; j < setArray.Length; j++)
+ {
+ attr.addValue(((Asn1OctetString) setArray[j]).byteValue());
+ }
+ attrs.Add(attr);
+ }
+
+ entry = new LdapEntry(((RfcSearchResultEntry) message.Response).ObjectName.stringValue(), attrs);
+ }
+ return entry;
+ }
+
+ }
+
+ private LdapEntry entry = null;
+
+ /// <summary> Constructs an LdapSearchResult object.
+ ///
+ /// </summary>
+ /// <param name="message">The RfcLdapMessage with a search result.
+ /// </param>
+ /*package*/
+ internal LdapSearchResult(RfcLdapMessage message):base(message)
+ {
+ return ;
+ }
+
+ /// <summary> Constructs an LdapSearchResult object from an LdapEntry.
+ ///
+ /// </summary>
+ /// <param name="entry">the LdapEntry represented by this search result.
+ /// <br><br>
+ /// </param>
+ /// <param name="cont">controls associated with the search result
+ /// </param>
+ public LdapSearchResult(LdapEntry entry, LdapControl[] cont):base()
+ {
+ if (entry == null)
+ {
+ throw new System.ArgumentException("Argument \"entry\" cannot be null");
+ }
+ this.entry = entry;
+ return ;
+ }
+
+ /// <summary> Return a String representation of this object.
+ ///
+ /// </summary>
+ /// <returns> a String representing this object.
+ /// </returns>
+ public override System.String ToString()
+ {
+ System.String str;
+ if (entry == null)
+ {
+ str = base.ToString();
+ }
+ else
+ {
+ str = entry.ToString();
+ }
+ return str;
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapSearchResultReference.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapSearchResultReference.cs
new file mode 100755
index 00000000000..75112875c78
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapSearchResultReference.cs
@@ -0,0 +1,83 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.LdapSearchResultReference.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+using Novell.Directory.Ldap.Rfc2251;
+using Novell.Directory.Ldap.Asn1;
+
+namespace Novell.Directory.Ldap
+{
+
+ /// <summary>
+ /// Encapsulates a continuation reference from an asynchronous search operation.
+ ///
+ /// </summary>
+ public class LdapSearchResultReference:LdapMessage
+ {
+ /// <summary> Returns any URLs in the object.
+ ///
+ /// </summary>
+ /// <returns> The URLs.
+ /// </returns>
+ virtual public System.String[] Referrals
+ {
+ get
+ {
+ Asn1Object[] references = ((RfcSearchResultReference) message.Response).toArray();
+ srefs = new System.String[references.Length];
+ for (int i = 0; i < references.Length; i++)
+ {
+ srefs[i] = ((Asn1OctetString) (references[i])).stringValue();
+ }
+ return (srefs);
+ }
+
+ }
+
+ private System.String[] srefs;
+ private static System.Object nameLock; // protect agentNum
+ private static int refNum = 0; // Debug, LdapConnection number
+ private System.String name; // String name for debug
+ /*package*/ /// <summary> Constructs an LdapSearchResultReference object.
+ ///
+ /// </summary>
+ /// <param name="message">The LdapMessage with a search reference.
+ /// </param>
+ internal LdapSearchResultReference(RfcLdapMessage message):base(message)
+ {
+ return ;
+ }
+ static LdapSearchResultReference()
+ {
+ nameLock = new System.Object();
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapSearchResults.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapSearchResults.cs
new file mode 100755
index 00000000000..70fa5eb1260
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapSearchResults.cs
@@ -0,0 +1,395 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.LdapSearchResults.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+using Novell.Directory.Ldap.Utilclass;
+
+namespace Novell.Directory.Ldap
+{
+
+ /// <summary> <p>An LdapSearchResults object is returned from a synchronous search
+ /// operation. It provides access to all results received during the
+ /// operation (entries and exceptions).</p>
+ ///
+ /// </summary>
+ /// <seealso cref="LdapConnection#search">
+ /// </seealso>
+ public class LdapSearchResults
+ {
+ /// <summary> Returns a count of the items in the search result.
+ ///
+ /// <p>Returns a count of the entries and exceptions remaining in the object.
+ /// If the search was submitted with a batch size greater than zero,
+ /// getCount reports the number of results received so far but not enumerated
+ /// with next(). If batch size equals zero, getCount reports the number of
+ /// items received, since the application thread blocks until all results are
+ /// received.</p>
+ ///
+ /// </summary>
+ /// <returns> The number of items received but not retrieved by the application
+ /// </returns>
+ virtual public int Count
+ {
+ get
+ {
+ int qCount = queue.MessageAgent.Count;
+ return entryCount - entryIndex + referenceCount - referenceIndex + qCount;
+ }
+
+ }
+ /// <summary> Returns the latest server controls returned by the server
+ /// in the context of this search request, or null
+ /// if no server controls were returned.
+ ///
+ /// </summary>
+ /// <returns> The server controls returned with the search request, or null
+ /// if none were returned.
+ /// </returns>
+ virtual public LdapControl[] ResponseControls
+ {
+ get
+ {
+ return controls;
+ }
+
+ }
+ /// <summary> Collects batchSize elements from an LdapSearchQueue message
+ /// queue and places them in a Vector.
+ ///
+ /// <p>If the last message from the server,
+ /// the result message, contains an error, it will be stored in the Vector
+ /// for nextElement to process. (although it does not increment the search
+ /// result count) All search result entries will be placed in the Vector.
+ /// If a null is returned from getResponse(), it is likely that the search
+ /// was abandoned.</p>
+ ///
+ /// </summary>
+ /// <returns> true if all search results have been placed in the vector.
+ /// </returns>
+ private bool BatchOfResults
+ {
+ get
+ {
+ LdapMessage msg;
+
+ // <=batchSize so that we can pick up the result-done message
+ for (int i = 0; i < batchSize; )
+ {
+ try
+ {
+ if ((msg = queue.getResponse()) != null)
+ {
+ // Only save controls if there are some
+ LdapControl[] ctls = msg.Controls;
+ if (ctls != null)
+ {
+
+ controls = ctls;
+ }
+
+ if (msg is LdapSearchResult)
+ {
+ // Search Entry
+ System.Object entry = ((LdapSearchResult) msg).Entry;
+ entries.Add(entry);
+ i++;
+ entryCount++;
+ }
+ else if (msg is LdapSearchResultReference)
+ {
+ // Search Ref
+ System.String[] refs = ((LdapSearchResultReference) msg).Referrals;
+
+ if (cons.ReferralFollowing)
+ {
+// referralConn = conn.chaseReferral(queue, cons, msg, refs, 0, true, referralConn);
+ }
+ else
+ {
+ references.Add(refs);
+ referenceCount++;
+ }
+ }
+ else
+ {
+ // LdapResponse
+ LdapResponse resp = (LdapResponse) msg;
+ int resultCode = resp.ResultCode;
+ // Check for an embedded exception
+ if (resp.hasException())
+ {
+ // Fake it, results in an exception when msg read
+ resultCode = LdapException.CONNECT_ERROR;
+ }
+
+ if ((resultCode == LdapException.REFERRAL) && cons.ReferralFollowing)
+ {
+ // Following referrals
+// referralConn = conn.chaseReferral(queue, cons, resp, resp.Referrals, 0, false, referralConn);
+ }
+ else if (resultCode != LdapException.SUCCESS)
+ {
+ // Results in an exception when message read
+ entries.Add(resp);
+ entryCount++;
+ }
+ // We are done only when we have read all messages
+ // including those received from following referrals
+ int[] msgIDs = queue.MessageIDs;
+ if (msgIDs.Length == 0)
+ {
+ // Release referral exceptions
+// conn.releaseReferralConnections(referralConn);
+ return true; // search completed
+ }
+ else
+ {
+ }
+ continue;
+ }
+ }
+ else
+ {
+ // We get here if the connection timed out
+ // we have no responses, no message IDs and no exceptions
+ LdapException e = new LdapException(null, LdapException.Ldap_TIMEOUT, (System.String) null);
+ entries.Add(e);
+ break;
+ }
+ }
+ catch (LdapException e)
+ {
+ // Hand exception off to user
+ entries.Add(e);
+ }
+ continue;
+ }
+ return false; // search not completed
+ }
+
+ }
+
+ private System.Collections.ArrayList entries; // Search entries
+ private int entryCount; // # Search entries in vector
+ private int entryIndex; // Current position in vector
+ private System.Collections.ArrayList references; // Search Result References
+ private int referenceCount; // # Search Result Reference in vector
+ private int referenceIndex; // Current position in vector
+ private int batchSize; // Application specified batch size
+ private bool completed = false; // All entries received
+ private LdapControl[] controls = null; // Last set of controls
+ private LdapSearchQueue queue;
+ private static System.Object nameLock; // protect resultsNum
+ private static int resultsNum = 0; // used for debug
+ private System.String name; // used for debug
+ private LdapConnection conn; // LdapConnection which started search
+ private LdapSearchConstraints cons; // LdapSearchConstraints for search
+ private System.Collections.ArrayList referralConn = null; // Referral Connections
+
+ /// <summary> Constructs a queue object for search results.
+ ///
+ /// </summary>
+ /// <param name="conn">The LdapConnection which initiated the search
+ /// <br><br>
+ /// </param>
+ /// <param name="queue">The queue for the search results.
+ /// <br><br>
+ /// </param>
+ /// <param name="cons">The LdapSearchConstraints associated with this search
+ /// </param>
+ /* package */
+ internal LdapSearchResults(LdapConnection conn, LdapSearchQueue queue, LdapSearchConstraints cons)
+ {
+ // setup entry Vector
+ this.conn = conn;
+ this.cons = cons;
+ int batchSize = cons.BatchSize;
+ int vectorIncr = (batchSize == 0)?64:0;
+ entries = new System.Collections.ArrayList((batchSize == 0)?64:batchSize);
+ entryCount = 0;
+ entryIndex = 0;
+
+ // setup search reference Vector
+ references = new System.Collections.ArrayList(5);
+ referenceCount = 0;
+ referenceIndex = 0;
+
+ this.queue = queue;
+ this.batchSize = (batchSize == 0)?System.Int32.MaxValue:batchSize;
+
+ return ;
+ }
+
+ /// <summary> Reports if there are more search results.
+ ///
+ /// </summary>
+ /// <returns> true if there are more search results.
+ /// </returns>
+ public virtual bool hasMore()
+ {
+ bool ret = false;
+ if ((entryIndex < entryCount) || (referenceIndex < referenceCount))
+ {
+ // we have data
+ ret = true;
+ }
+ else if (completed == false)
+ {
+ // reload the Vector by getting more results
+ resetVectors();
+ ret = (entryIndex < entryCount) || (referenceIndex < referenceCount);
+ }
+ return ret;
+ }
+
+ /*
+ * If both of the vectors are empty, get more data for them.
+ */
+ private void resetVectors()
+ {
+ // If we're done, no further checking needed
+ if (completed)
+ {
+ return ;
+ }
+ // Checks if we have run out of references
+ if ((referenceIndex != 0) && (referenceIndex >= referenceCount))
+ {
+ SupportClass.SetSize(references, 0);
+ referenceCount = 0;
+ referenceIndex = 0;
+ }
+ // Checks if we have run out of entries
+ if ((entryIndex != 0) && (entryIndex >= entryCount))
+ {
+ SupportClass.SetSize(entries, 0);
+ entryCount = 0;
+ entryIndex = 0;
+ }
+ // If no data at all, must reload enumeration
+ if ((referenceIndex == 0) && (referenceCount == 0) && (entryIndex == 0) && (entryCount == 0))
+ {
+ completed = BatchOfResults;
+ }
+ return ;
+ }
+ /// <summary> Returns the next result as an LdapEntry.
+ ///
+ /// <p>If automatic referral following is disabled or if a referral
+ /// was not followed, next() will throw an LdapReferralException
+ /// when the referral is received.</p>
+ ///
+ /// </summary>
+ /// <returns> The next search result as an LdapEntry.
+ ///
+ /// </returns>
+ /// <exception cref=""> LdapException A general exception which includes an error
+ /// message and an Ldap error code.
+ /// </exception>
+ /// <exception cref=""> LdapReferralException A referral was received and not
+ /// followed.
+ /// </exception>
+ public virtual LdapEntry next()
+ {
+ if (completed && (entryIndex >= entryCount) && (referenceIndex >= referenceCount))
+ {
+ throw new System.ArgumentOutOfRangeException("LdapSearchResults.next() no more results");
+ }
+ // Check if the enumeration is empty and must be reloaded
+ resetVectors();
+
+ System.Object element = null;
+ // Check for Search References & deliver to app as they come in
+ // We only get here if not following referrals/references
+ if (referenceIndex < referenceCount)
+ {
+ System.String[] refs = (System.String[]) (references[referenceIndex++]);
+ LdapReferralException rex = new LdapReferralException(ExceptionMessages.REFERENCE_NOFOLLOW);
+ rex.setReferrals(refs);
+ throw rex;
+ }
+ else if (entryIndex < entryCount)
+ {
+ // Check for Search Entries and the Search Result
+ element = entries[entryIndex++];
+ if (element is LdapResponse)
+ {
+ // Search done w/bad status
+ if (((LdapResponse) element).hasException())
+ {
+
+ LdapResponse lr = (LdapResponse) element;
+ ReferralInfo ri = lr.ActiveReferral;
+
+ if (ri != null)
+ {
+ // Error attempting to follow a search continuation reference
+ LdapReferralException rex = new LdapReferralException(ExceptionMessages.REFERENCE_ERROR, lr.Exception);
+ rex.setReferrals(ri.ReferralList);
+ rex.FailedReferral = ri.ReferralUrl.ToString();
+ throw rex;
+ }
+ }
+ // Throw an exception if not success
+ ((LdapResponse) element).chkResultCode();
+ }
+ else if (element is LdapException)
+ {
+ throw (LdapException) element;
+ }
+ }
+ else
+ {
+ // If not a Search Entry, Search Result, or search continuation
+ // we are very confused.
+ // LdapSearchResults.next(): No entry found & request is not complete
+ throw new LdapException(ExceptionMessages.REFERRAL_LOCAL, new System.Object[]{"next"}, LdapException.LOCAL_ERROR, (System.String) null);
+ }
+ return (LdapEntry) element;
+ }
+
+ /// <summary> Cancels the search request and clears the message and enumeration.</summary>
+ /*package*/
+ internal virtual void Abandon()
+ {
+ // first, remove message ID and timer and any responses in the queue
+ queue.MessageAgent.AbandonAll();
+
+ // next, clear out enumeration
+ resetVectors();
+ completed = true;
+ }
+ static LdapSearchResults()
+ {
+ nameLock = new System.Object();
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapUnbindRequest.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapUnbindRequest.cs
new file mode 100755
index 00000000000..a6a752b5f62
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapUnbindRequest.cs
@@ -0,0 +1,58 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.LdapUnbindRequest.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+using Novell.Directory.Ldap.Rfc2251;
+
+namespace Novell.Directory.Ldap
+{
+
+ /// <summary> Represents an Ldap Unbind Request.
+ ///
+ /// </summary>
+ /// <seealso cref="LdapConnection#sendRequest">
+ /// </seealso>
+ /*
+ * UnbindRequest ::= [APPLICATION 2] NULL
+ */
+ public class LdapUnbindRequest:LdapMessage
+ {
+ /// <summary> Constructs an Ldap Unbind Request.
+ ///
+ /// </summary>
+ /// <param name="cont">Any controls that apply to the unbind request
+ /// </param>
+ public LdapUnbindRequest(LdapControl[] cont):base(LdapMessage.UNBIND_REQUEST, new RfcUnbindRequest(), cont)
+ {
+ return ;
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapUnsolicitedNotificationListener.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapUnsolicitedNotificationListener.cs
new file mode 100755
index 00000000000..9168396305e
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapUnsolicitedNotificationListener.cs
@@ -0,0 +1,56 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.LdapUnsolicitedNotificationListener.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+
+namespace Novell.Directory.Ldap
+{
+
+ /// <summary>
+ /// An object that implements this interface can be notified when
+ /// unsolicited messages arrive from the server. A client registers the
+ /// object with LdapConnection.AddUnsolicitedNotificationListener. </p>
+ ///
+ /// </summary>
+ public interface LdapUnsolicitedNotificationListener
+ {
+
+ /// <summary> The method is called when an unsolicited message arrives from a
+ /// server, if the object has registered with LdapCo
+ /// LdapConnection.AddUnsolicitedNotificationListener.
+ ///
+ /// </summary>
+ /// <param name="msg"> An unsolicited message received from the server.
+ /// <br><br>
+ /// </param>
+ void messageReceived(LdapExtendedResponse msg);
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapUrl.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapUrl.cs
new file mode 100755
index 00000000000..52a2c3de9cd
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapUrl.cs
@@ -0,0 +1,862 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.LdapUrl.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+using ArrayEnumeration = Novell.Directory.Ldap.Utilclass.ArrayEnumeration;
+
+namespace Novell.Directory.Ldap
+{
+
+ /// <summary>
+ /// Encapsulates parameters of an Ldap URL query as defined in RFC2255.
+ ///
+ /// An LdapUrl object can be passed to LdapConnection.search to retrieve
+ /// search results.
+ ///
+ /// </summary>
+ /// <seealso cref="LdapConnection#search">
+ /// </seealso>
+ public class LdapUrl : System.ICloneable
+ {
+ private void InitBlock()
+ {
+ scope = DEFAULT_SCOPE;
+ }
+ /// <summary> Returns an array of attribute names specified in the URL.
+ ///
+ /// </summary>
+ /// <returns> An array of attribute names in the URL.
+ /// </returns>
+ virtual public System.String[] AttributeArray
+ {
+ get
+ {
+ return attrs;
+ }
+
+ }
+ /// <summary> Returns an enumerator for the attribute names specified in the URL.
+ ///
+ /// </summary>
+ /// <returns> An enumeration of attribute names.
+ /// </returns>
+ virtual public System.Collections.IEnumerator Attributes
+ {
+ get
+ {
+ return new ArrayEnumeration(attrs);
+ }
+
+ }
+ /// <summary> Returns any Ldap URL extensions specified, or null if none are
+ /// specified. Each extension is a type=value expression. The =value part
+ /// MAY be omitted. The expression MAY be prefixed with '!' if it is
+ /// mandatory for evaluation of the URL.
+ ///
+ /// </summary>
+ /// <returns> string array of extensions.
+ /// </returns>
+ virtual public System.String[] Extensions
+ {
+ get
+ {
+ return extensions;
+ }
+
+ }
+ /// <summary> Returns the search filter or <code>null</code> if none was specified.
+ ///
+ /// </summary>
+ /// <returns> The search filter.
+ /// </returns>
+ virtual public System.String Filter
+ {
+ get
+ {
+ return filter;
+ }
+
+ }
+ /// <summary> Returns the name of the Ldap server in the URL.
+ ///
+ /// </summary>
+ /// <returns> The host name specified in the URL.
+ /// </returns>
+ virtual public System.String Host
+ {
+ get
+ {
+ return host;
+ }
+
+ }
+ /// <summary> Returns the port number of the Ldap server in the URL.
+ ///
+ /// </summary>
+ /// <returns> The port number in the URL.
+ /// </returns>
+ virtual public int Port
+ {
+ get
+ {
+ if (port == 0)
+ {
+ return LdapConnection.DEFAULT_PORT;
+ }
+ return port;
+ }
+
+ }
+ /// <summary> Returns the depth of search. It returns one of the following from
+ /// LdapConnection: SCOPE_BASE, SCOPE_ONE, or SCOPE_SUB.
+ ///
+ /// </summary>
+ /// <returns> The search scope.
+ /// </returns>
+ virtual public int Scope
+ {
+ get
+ {
+ return scope;
+ }
+
+ }
+ /// <summary> Returns true if the URL is of the type ldaps (Ldap over SSL, a predecessor
+ /// to startTls)
+ ///
+ /// </summary>
+ /// <returns> whether this is a secure Ldap url or not.
+ /// </returns>
+ virtual public bool Secure
+ {
+ get
+ {
+ return secure;
+ }
+
+ }
+ private static readonly int DEFAULT_SCOPE = LdapConnection.SCOPE_BASE;
+
+ // Broken out parts of the URL
+ private bool secure = false; // URL scheme ldap/ldaps
+ private bool ipV6 = false; // TCP/IP V6
+ private System.String host = null; // Host
+ private int port = 0; // Port
+ private System.String dn = null; // Base DN
+ private System.String[] attrs = null; // Attributes
+ private System.String filter = null; // Filter
+ private int scope; // Scope
+ private System.String[] extensions = null; // Extensions
+
+ /// <summary> Constructs a URL object with the specified string as the URL.
+ ///
+ /// </summary>
+ /// <param name="url"> An Ldap URL string, e.g.
+ /// "ldap://ldap.example.com:80/dc=example,dc=com?cn,
+ /// sn?sub?(objectclass=inetOrgPerson)".
+ ///
+ /// </param>
+ /// <exception cref=""> MalformedURLException The specified URL cannot be parsed.
+ /// </exception>
+ public LdapUrl(System.String url)
+ {
+ InitBlock();
+ parseURL(url);
+ return ;
+ }
+
+
+ /// <summary> Constructs a URL object with the specified host, port, and DN.
+ ///
+ /// <p>This form is used to create URL references to a particular object
+ /// in the directory.</p>
+ ///
+ /// </summary>
+ /// <param name="host"> Host identifier of Ldap server, or null for
+ /// "localhost".
+ /// <br><br>
+ /// </param>
+ /// <param name="port"> The port number for Ldap server (use
+ /// LdapConnection.DEFAULT_PORT for default port).
+ /// <br><br>
+ /// </param>
+ /// <param name="dn"> Distinguished name of the base object of the search.
+ ///
+ /// </param>
+ public LdapUrl(System.String host, int port, System.String dn)
+ {
+ InitBlock();
+ this.host = host;
+ this.port = port;
+ this.dn = dn;
+ return ;
+ }
+
+ /// <summary> Constructs an Ldap URL with all fields explicitly assigned, to
+ /// specify an Ldap search operation.
+ ///
+ /// </summary>
+ /// <param name="host"> Host identifier of Ldap server, or null for
+ /// "localhost".
+ /// <br><br>
+ /// </param>
+ /// <param name="port"> The port number for Ldap server (use
+ /// LdapConnection.DEFAULT_PORT for default port).
+ /// <br><br>
+ /// </param>
+ /// <param name="dn"> Distinguished name of the base object of the search.
+ ///
+ /// <br><br>
+ /// </param>
+ /// <param name="attrNames">Names or OIDs of attributes to retrieve. Passing a
+ /// null array signifies that all user attributes are to be
+ /// retrieved. Passing a value of "*" allows you to specify
+ /// that all user attributes as well as any specified
+ /// operational attributes are to be retrieved.
+ /// <br><br>
+ ///
+ /// </param>
+ /// <param name="scope"> Depth of search (in DN namespace). Use one of
+ /// SCOPE_BASE, SCOPE_ONE, SCOPE_SUB from LdapConnection.
+ /// <br><br>
+ ///
+ /// </param>
+ /// <param name="filter"> The search filter specifying the search criteria.
+ /// <br><br>
+ ///
+ /// </param>
+ /// <param name="extensions"> Extensions provide a mechanism to extend the
+ /// functionality of Ldap URLs. Currently no
+ /// Ldap URL extensions are defined. Each extension
+ /// specification is a type=value expression, and may
+ /// be <code>null</code> or empty. The =value part may be
+ /// omitted. The expression may be prefixed with '!' if it
+ /// is mandatory for the evaluation of the URL.
+ /// </param>
+ public LdapUrl(System.String host, int port, System.String dn, System.String[] attrNames, int scope, System.String filter, System.String[] extensions)
+ {
+ InitBlock();
+ this.host = host;
+ this.port = port;
+ this.dn = dn;
+ this.attrs = new System.String[attrNames.Length];
+ attrNames.CopyTo(this.attrs, 0);
+ this.scope = scope;
+ this.filter = filter;
+ this.extensions = new System.String[extensions.Length];
+ extensions.CopyTo(this.extensions, 0);
+ return ;
+ }
+
+ /// <summary> Constructs an Ldap URL with all fields explicitly assigned, including
+ /// isSecure, to specify an Ldap search operation.
+ ///
+ /// </summary>
+ /// <param name="host"> Host identifier of Ldap server, or null for
+ /// "localhost".
+ /// <br><br>
+ ///
+ /// </param>
+ /// <param name="port"> The port number for Ldap server (use
+ /// LdapConnection.DEFAULT_PORT for default port).
+ /// <br><br>
+ ///
+ /// </param>
+ /// <param name="dn"> Distinguished name of the base object of the search.
+ /// <br><br>
+ ///
+ /// </param>
+ /// <param name="attrNames">Names or OIDs of attributes to retrieve. Passing a
+ /// null array signifies that all user attributes are to be
+ /// retrieved. Passing a value of "*" allows you to specify
+ /// that all user attributes as well as any specified
+ /// operational attributes are to be retrieved.
+ /// <br><br>
+ ///
+ /// </param>
+ /// <param name="scope"> Depth of search (in DN namespace). Use one of
+ /// SCOPE_BASE, SCOPE_ONE, SCOPE_SUB from LdapConnection.
+ /// <br><br>
+ ///
+ /// </param>
+ /// <param name="filter"> The search filter specifying the search criteria.
+ /// from LdapConnection: SCOPE_BASE, SCOPE_ONE, SCOPE_SUB.
+ /// <br><br>
+ ///
+ /// </param>
+ /// <param name="extensions"> Extensions provide a mechanism to extend the
+ /// functionality of Ldap URLs. Currently no
+ /// Ldap URL extensions are defined. Each extension
+ /// specification is a type=value expression, and may
+ /// be <code>null</code> or empty. The =value part may be
+ /// omitted. The expression may be prefixed with '!' if it
+ /// is mandatory for the evaluation of the URL.
+ /// <br><br>
+ ///
+ /// </param>
+ /// <param name="secure"> If true creates an Ldap URL of the ldaps type
+ /// </param>
+ public LdapUrl(System.String host, int port, System.String dn, System.String[] attrNames, int scope, System.String filter, System.String[] extensions, bool secure)
+ {
+ InitBlock();
+ this.host = host;
+ this.port = port;
+ this.dn = dn;
+ this.attrs = attrNames;
+ this.scope = scope;
+ this.filter = filter;
+ this.extensions = new System.String[extensions.Length];
+ extensions.CopyTo(this.extensions, 0);
+ this.secure = secure;
+ return ;
+ }
+
+ /// <summary> Returns a clone of this URL object.
+ ///
+ /// </summary>
+ /// <returns> clone of this URL object.
+ /// </returns>
+ public System.Object Clone()
+ {
+ try
+ {
+ return base.MemberwiseClone();
+ }
+ catch (System.Exception ce)
+ {
+ throw new System.SystemException("Internal error, cannot create clone");
+ }
+ }
+
+ /// <summary> Decodes a URL-encoded string.
+ ///
+ /// <p>Any occurences of %HH are decoded to the hex value represented.
+ /// However, this method does NOT decode "+" into " ".
+ ///
+ /// </summary>
+ /// <param name="URLEncoded"> String to decode.
+ ///
+ /// </param>
+ /// <returns> The decoded string.
+ ///
+ /// </returns>
+ /// <exception cref=""> MalformedURLException The URL could not be parsed.
+ /// </exception>
+ public static System.String decode(System.String URLEncoded)
+ {
+
+
+ int searchStart = 0;
+ int fieldStart;
+
+ fieldStart = URLEncoded.IndexOf("%", searchStart);
+ // Return now if no encoded data
+ if (fieldStart < 0)
+ {
+ return URLEncoded;
+ }
+
+ // Decode the %HH value and copy to new string buffer
+ int fieldEnd = 0; // end of previous field
+ int dataLen = URLEncoded.Length;
+
+ System.Text.StringBuilder decoded = new System.Text.StringBuilder(dataLen);
+
+ while (true)
+ {
+ if (fieldStart > (dataLen - 3))
+ {
+ throw new System.UriFormatException("LdapUrl.decode: must be two hex characters following escape character '%'");
+ }
+ if (fieldStart < 0)
+ fieldStart = dataLen;
+ // Copy to string buffer from end of last field to start of next
+ decoded.Append(URLEncoded.Substring(fieldEnd, (fieldStart) - (fieldEnd)));
+ fieldStart += 1;
+ if (fieldStart >= dataLen)
+ break;
+ fieldEnd = fieldStart + 2;
+ try
+ {
+ decoded.Append((char) System.Convert.ToInt32(URLEncoded.Substring(fieldStart, (fieldEnd) - (fieldStart)), 16));
+ }
+ catch (System.FormatException ex)
+ {
+ throw new System.UriFormatException("LdapUrl.decode: error converting hex characters to integer \"" + ex.Message + "\"");
+ }
+ searchStart = fieldEnd;
+ if (searchStart == dataLen)
+ break;
+ fieldStart = URLEncoded.IndexOf("%", searchStart);
+ }
+
+ return (decoded.ToString());
+ }
+
+ /// <summary> Encodes an arbitrary string using the URL encoding rules.
+ ///
+ /// <p> Any illegal characters are encoded as %HH. </p>
+ ///
+ /// </summary>
+ /// <param name="toEncode"> The string to encode.
+ ///
+ /// </param>
+ /// <returns> The URL-encoded string.
+ ///
+ /// Comment: An illegal character consists of any non graphical US-ASCII character, Unsafe, or reserved characters.
+ /// </returns>
+ public static System.String encode(System.String toEncode)
+ {
+ System.Text.StringBuilder buffer = new System.Text.StringBuilder(toEncode.Length); //empty but initial capicity of 'length'
+ System.String temp;
+ char currChar;
+ for (int i = 0; i < toEncode.Length; i++)
+ {
+ currChar = toEncode[i];
+ if ((((int) currChar <= 0x1F) || ((int) currChar == 0x7F) || (((int) currChar >= 0x80) && ((int) currChar <= 0xFF))) || ((currChar == '<') || (currChar == '>') || (currChar == '\"') || (currChar == '#') || (currChar == '%') || (currChar == '{') || (currChar == '}') || (currChar == '|') || (currChar == '\\') || (currChar == '^') || (currChar == '~') || (currChar == '[') || (currChar == '\'')) || ((currChar == ';') || (currChar == '/') || (currChar == '?') || (currChar == ':') || (currChar == '@') || (currChar == '=') || (currChar == '&')))
+ {
+ temp = System.Convert.ToString(currChar, 16);
+ if (temp.Length == 1)
+ buffer.Append("%0" + temp);
+ //if(temp.length()==2) this can only be two or one digit long.
+ else
+ buffer.Append("%" + System.Convert.ToString(currChar, 16));
+ }
+ else
+ buffer.Append(currChar);
+ }
+ return buffer.ToString();
+ }
+
+ /// <summary> Returns the base distinguished name encapsulated in the URL.
+ ///
+ /// </summary>
+ /// <returns> The base distinguished name specified in the URL, or null if none.
+ /// </returns>
+ public virtual System.String getDN()
+ {
+ return dn;
+ }
+
+ /// <summary> Sets the base distinguished name encapsulated in the URL.</summary>
+ /* package */
+ internal virtual void setDN(System.String dn)
+ {
+ this.dn = dn;
+ return ;
+ }
+
+ /// <summary> Returns a valid string representation of this Ldap URL.
+ ///
+ /// </summary>
+ /// <returns> The string representation of the Ldap URL.
+ /// </returns>
+ public override System.String ToString()
+ {
+ System.Text.StringBuilder url = new System.Text.StringBuilder(256);
+ // Scheme
+ if (secure)
+ {
+ url.Append("ldaps://");
+ }
+ else
+ {
+ url.Append("ldap://");
+ }
+ // Host:port/dn
+ if (ipV6)
+ {
+ url.Append("[" + host + "]");
+ }
+ else
+ {
+ url.Append(host);
+ }
+
+ // Port not specified
+ if (port != 0)
+ {
+ url.Append(":" + port);
+ }
+
+ if (((System.Object) dn == null) && (attrs == null) && (scope == DEFAULT_SCOPE) && ((System.Object) filter == null) && (extensions == null))
+ {
+ return url.ToString();
+ }
+
+ url.Append("/");
+
+ if ((System.Object) dn != null)
+ {
+ url.Append(dn);
+ }
+
+ if ((attrs == null) && (scope == DEFAULT_SCOPE) && ((System.Object) filter == null) && (extensions == null))
+ {
+ return url.ToString();
+ }
+
+ // attributes
+ url.Append("?");
+ if (attrs != null)
+ {
+ //should we check also for attrs != "*"
+ for (int i = 0; i < attrs.Length; i++)
+ {
+ url.Append(attrs[i]);
+ if (i < (attrs.Length - 1))
+ {
+ url.Append(",");
+ }
+ }
+ }
+
+ if ((scope == DEFAULT_SCOPE) && ((System.Object) filter == null) && (extensions == null))
+ {
+ return url.ToString();
+ }
+
+ // scope
+ url.Append("?");
+ if (scope != DEFAULT_SCOPE)
+ {
+ if (scope == LdapConnection.SCOPE_ONE)
+ {
+ url.Append("one");
+ }
+ else
+ {
+ url.Append("sub");
+ }
+ }
+
+ if (((System.Object) filter == null) && (extensions == null))
+ {
+ return url.ToString();
+ }
+
+ // filter
+ if ((System.Object) filter == null)
+ {
+ url.Append("?");
+ }
+ else
+ {
+ url.Append("?" + Filter);
+ }
+
+ if (extensions == null)
+ {
+ return url.ToString();
+ }
+
+ // extensions
+ url.Append("?");
+ if (extensions != null)
+ {
+ for (int i = 0; i < extensions.Length; i++)
+ {
+ url.Append(extensions[i]);
+ if (i < (extensions.Length - 1))
+ {
+ url.Append(",");
+ }
+ }
+ }
+ return url.ToString();
+ }
+
+ private System.String[] parseList(System.String listStr, char delimiter, int listStart, int listEnd)
+ // end of list + 1
+ {
+ System.String[] list;
+ // Check for and empty string
+ if ((listEnd - listStart) < 1)
+ {
+ return null;
+ }
+ // First count how many items are specified
+ int itemStart = listStart;
+ int itemEnd;
+ int itemCount = 0;
+ while (itemStart > 0)
+ {
+ // itemStart == 0 if no delimiter found
+ itemCount += 1;
+ itemEnd = listStr.IndexOf((System.Char) delimiter, itemStart);
+ if ((itemEnd > 0) && (itemEnd < listEnd))
+ {
+ itemStart = itemEnd + 1;
+ }
+ else
+ {
+ break;
+ }
+ }
+ // Now fill in the array with the attributes
+ itemStart = listStart;
+ list = new System.String[itemCount];
+ itemCount = 0;
+ while (itemStart > 0)
+ {
+ itemEnd = listStr.IndexOf((System.Char) delimiter, itemStart);
+ if (itemStart <= listEnd)
+ {
+ if (itemEnd < 0)
+ itemEnd = listEnd;
+ if (itemEnd > listEnd)
+ itemEnd = listEnd;
+ list[itemCount] = listStr.Substring(itemStart, (itemEnd) - (itemStart));
+ itemStart = itemEnd + 1;
+ itemCount += 1;
+ }
+ else
+ {
+ break;
+ }
+ }
+ return list;
+ }
+
+
+ private void parseURL(System.String url)
+ {
+ int scanStart = 0;
+ int scanEnd = url.Length;
+
+ if ((System.Object) url == null)
+ throw new System.UriFormatException("LdapUrl: URL cannot be null");
+
+ // Check if URL is enclosed by < & >
+ if (url[scanStart] == '<')
+ {
+ if (url[scanEnd - 1] != '>')
+ throw new System.UriFormatException("LdapUrl: URL bad enclosure");
+ scanStart += 1;
+ scanEnd -= 1;
+ }
+
+ // Determine the URL scheme and set appropriate default port
+ if (url.Substring(scanStart, (scanStart + 4) - (scanStart)).ToUpper().Equals("URL:".ToUpper()))
+ {
+ scanStart += 4;
+ }
+ if (url.Substring(scanStart, (scanStart + 7) - (scanStart)).ToUpper().Equals("ldap://".ToUpper()))
+ {
+ scanStart += 7;
+ port = LdapConnection.DEFAULT_PORT;
+ }
+ else if (url.Substring(scanStart, (scanStart + 8) - (scanStart)).ToUpper().Equals("ldaps://".ToUpper()))
+ {
+ secure = true;
+ scanStart += 8;
+ port = LdapConnection.DEFAULT_SSL_PORT;
+ }
+ else
+ {
+ throw new System.UriFormatException("LdapUrl: URL scheme is not ldap");
+ }
+
+ // Find where host:port ends and dn begins
+ int dnStart = url.IndexOf("/", scanStart);
+ int hostPortEnd = scanEnd;
+ bool novell = false;
+ if (dnStart < 0)
+ {
+ /*
+ * Kludge. check for ldap://111.222.333.444:389??cn=abc,o=company
+ *
+ * Check for broken Novell referral format. The dn is in
+ * the scope position, but the required slash is missing.
+ * This is illegal syntax but we need to account for it.
+ * Fortunately it can't be confused with anything real.
+ */
+ dnStart = url.IndexOf("?", scanStart);
+ if (dnStart > 0)
+ {
+ if (url[dnStart + 1] == '?')
+ {
+ hostPortEnd = dnStart;
+ dnStart += 1;
+ novell = true;
+ }
+ else
+ {
+ dnStart = - 1;
+ }
+ }
+ }
+ else
+ {
+ hostPortEnd = dnStart;
+ }
+ // Check for IPV6 "[ipaddress]:port"
+ int portStart;
+ int hostEnd = hostPortEnd;
+ if (url[scanStart] == '[')
+ {
+ hostEnd = url.IndexOf((System.Char) ']', scanStart + 1);
+ if ((hostEnd >= hostPortEnd) || (hostEnd == - 1))
+ {
+ throw new System.UriFormatException("LdapUrl: \"]\" is missing on IPV6 host name");
+ }
+ // Get host w/o the [ & ]
+ host = url.Substring(scanStart + 1, (hostEnd) - (scanStart + 1));
+ portStart = url.IndexOf(":", hostEnd);
+ if ((portStart < hostPortEnd) && (portStart != - 1))
+ {
+ // port is specified
+ port = System.Int32.Parse(url.Substring(portStart + 1, (hostPortEnd) - (portStart + 1)));
+ }
+ else
+ {
+ }
+ }
+ else
+ {
+ portStart = url.IndexOf(":", scanStart);
+ // Isolate the host and port
+ if ((portStart < 0) || (portStart > hostPortEnd))
+ {
+ // no port is specified, we keep the default
+ host = url.Substring(scanStart, (hostPortEnd) - (scanStart));
+ }
+ else
+ {
+ // port specified in URL
+ host = url.Substring(scanStart, (portStart) - (scanStart));
+ port = System.Int32.Parse(url.Substring(portStart + 1, (hostPortEnd) - (portStart + 1)));
+ }
+ }
+
+ scanStart = hostPortEnd + 1;
+ if ((scanStart >= scanEnd) || (dnStart < 0))
+ return ;
+
+ // Parse out the base dn
+ scanStart = dnStart + 1;
+
+ int attrsStart = url.IndexOf((System.Char) '?', scanStart);
+ if (attrsStart < 0)
+ {
+ dn = url.Substring(scanStart, (scanEnd) - (scanStart));
+ }
+ else
+ {
+ dn = url.Substring(scanStart, (attrsStart) - (scanStart));
+ }
+
+ scanStart = attrsStart + 1;
+ // Wierd novell syntax can have nothing beyond the dn
+ if ((scanStart >= scanEnd) || (attrsStart < 0) || novell)
+ return ;
+
+ // Parse out the attributes
+ int scopeStart = url.IndexOf((System.Char) '?', scanStart);
+ if (scopeStart < 0)
+ scopeStart = scanEnd - 1;
+ attrs = parseList(url, ',', attrsStart + 1, scopeStart);
+
+ scanStart = scopeStart + 1;
+ if (scanStart >= scanEnd)
+ return ;
+
+ // Parse out the scope
+ int filterStart = url.IndexOf((System.Char) '?', scanStart);
+ System.String scopeStr;
+ if (filterStart < 0)
+ {
+ scopeStr = url.Substring(scanStart, (scanEnd) - (scanStart));
+ }
+ else
+ {
+ scopeStr = url.Substring(scanStart, (filterStart) - (scanStart));
+ }
+ if (scopeStr.ToUpper().Equals("".ToUpper()))
+ {
+ scope = LdapConnection.SCOPE_BASE;
+ }
+ else if (scopeStr.ToUpper().Equals("base".ToUpper()))
+ {
+ scope = LdapConnection.SCOPE_BASE;
+ }
+ else if (scopeStr.ToUpper().Equals("one".ToUpper()))
+ {
+ scope = LdapConnection.SCOPE_ONE;
+ }
+ else if (scopeStr.ToUpper().Equals("sub".ToUpper()))
+ {
+ scope = LdapConnection.SCOPE_SUB;
+ }
+ else
+ {
+ throw new System.UriFormatException("LdapUrl: URL invalid scope");
+ }
+
+
+ scanStart = filterStart + 1;
+ if ((scanStart >= scanEnd) || (filterStart < 0))
+ return ;
+
+ // Parse out the filter
+ scanStart = filterStart + 1;
+
+ System.String filterStr;
+ int extStart = url.IndexOf((System.Char) '?', scanStart);
+ if (extStart < 0)
+ {
+ filterStr = url.Substring(scanStart, (scanEnd) - (scanStart));
+ }
+ else
+ {
+ filterStr = url.Substring(scanStart, (extStart) - (scanStart));
+ }
+
+ if (!filterStr.Equals(""))
+ {
+ filter = filterStr; // Only modify if not the default filter
+ }
+
+
+ scanStart = extStart + 1;
+ if ((scanStart >= scanEnd) || (extStart < 0))
+ return ;
+
+ // Parse out the extensions
+ int end = url.IndexOf((System.Char) '?', scanStart);
+ if (end > 0)
+ throw new System.UriFormatException("LdapUrl: URL has too many ? fields");
+ extensions = parseList(url, ',', scanStart, scanEnd);
+
+ return ;
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/Message.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/Message.cs
new file mode 100755
index 00000000000..48c97400f2a
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/Message.cs
@@ -0,0 +1,605 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.Message.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+using Novell.Directory.Ldap.Rfc2251;
+using Novell.Directory.Ldap.Utilclass;
+
+namespace Novell.Directory.Ldap
+{
+
+ /// <summary> Encapsulates an Ldap message, its state, and its replies.</summary>
+ /* package */
+ class Message
+ {
+ private void InitBlock()
+ {
+ replies = new MessageVector(5, 5);
+ }
+ /// <summary> Get number of messages queued.
+ /// Don't count the last message containing result code.
+ /// </summary>
+ virtual internal int Count
+ {
+ /* package */
+
+ get
+ {
+ int size = replies.Count;
+ if (complete)
+ {
+ return (size > 0?(size - 1):size);
+ }
+ else
+ {
+ return size;
+ }
+ }
+
+ }
+
+ /// <summary> sets the agent for this message</summary>
+ virtual internal MessageAgent Agent
+ {
+ /* package */
+
+ set
+ {
+ this.agent = value;
+ return ;
+ }
+
+ }
+
+ /// <summary> Returns true if replies are queued
+ ///
+ /// </summary>
+ /// <returns> false if no replies are queued, otherwise true
+ /// </returns>
+ /* package */
+ internal virtual bool hasReplies()
+ {
+ if (replies == null)
+ {
+ // abandoned request
+ return false;
+ }
+ return (replies.Count > 0);
+ }
+
+ virtual internal int MessageType
+ {
+ /* package */
+
+ get
+ {
+ if (msg == null)
+ {
+ return - 1;
+ }
+ return msg.Type;
+ }
+
+ }
+
+ virtual internal int MessageID
+ {
+ /* package */
+
+ get
+ {
+ return msgId;
+ }
+
+ }
+
+ /// <summary> gets the operation complete status for this message
+ ///
+ /// </summary>
+ /// <returns> the true if the operation is complete, i.e.
+ /// the LdapResult has been received.
+ /// </returns>
+ virtual internal bool Complete
+ {
+ /* package */
+
+ get
+ {
+ return complete;
+ }
+
+ }
+
+ /// <summary> Gets the next reply from the reply queue or waits until one is there
+ ///
+ /// </summary>
+ /// <returns> the next reply message on the reply queue or null
+ /// </returns>
+ /* package */
+ internal virtual System.Object waitForReply()
+ {
+ if (replies == null)
+ {
+ return null;
+ }
+ // sync on message so don't confuse with timer thread
+ lock (replies)
+ {
+ System.Object msg = null;
+ while (waitForReply_Renamed_Field)
+ {
+ if ((replies.Count == 0))
+ {
+ try
+ {
+ System.Threading.Monitor.Wait(replies);
+ }
+ catch (System.Threading.ThreadInterruptedException ir)
+ {
+ ; // do nothing
+ }
+ if (waitForReply_Renamed_Field)
+ {
+ continue;
+ }
+ else
+ {
+ break;
+ }
+ }
+ else
+ {
+ System.Object temp_object;
+ temp_object = replies[0];
+ replies.RemoveAt(0);
+ msg = temp_object; // Atomic get and remove
+ }
+ if ((complete || !acceptReplies) && (replies.Count == 0))
+ {
+ // Remove msg from connection queue when last reply read
+ conn.removeMessage(this);
+ }
+ else
+ {
+ }
+ return msg;
+ }
+ return null;
+ }
+ }
+
+
+ /// <summary> Gets the next reply from the reply queue if one exists
+ ///
+ /// </summary>
+ /// <returns> the next reply message on the reply queue or null if none
+ /// </returns>
+ virtual internal System.Object Reply
+ {
+ /* package */
+
+ get
+ {
+ System.Object msg;
+ if (replies == null)
+ {
+ return null;
+ }
+ lock (replies)
+ {
+ // Test and remove must be atomic
+ if ((replies.Count == 0))
+ {
+ return null; // No data
+ }
+ System.Object temp_object;
+ temp_object = replies[0];
+ replies.RemoveAt(0);
+ msg = temp_object; // Atomic get and remove
+ }
+ if ((conn != null) && (complete || !acceptReplies) && (replies.Count == 0))
+ {
+ // Remove msg from connection queue when last reply read
+ conn.removeMessage(this);
+ }
+ return msg;
+ }
+
+ }
+
+ /// <summary> Returns true if replies are accepted for this request.
+ ///
+ /// </summary>
+ /// <returns> false if replies are no longer accepted for this request
+ /// </returns>
+ /* package */
+ internal virtual bool acceptsReplies()
+ {
+ return acceptReplies;
+ }
+
+ /// <summary> gets the LdapMessage request associated with this message
+ ///
+ /// </summary>
+ /// <returns> the LdapMessage request associated with this message
+ /// </returns>
+ virtual internal LdapMessage Request
+ {
+ /*package*/
+
+ get
+ {
+ return msg;
+ }
+
+ }
+
+
+ virtual internal bool BindRequest
+ {
+ /* package */
+
+ get
+ {
+ return (bindprops != null);
+ }
+
+ }
+
+
+ /// <summary> gets the MessageAgent associated with this message
+ ///
+ /// </summary>
+ /// <returns> the MessageAgent associated with this message
+ /// </returns>
+ virtual internal MessageAgent MessageAgent
+ {
+ /* package */
+
+ get
+ {
+ return agent;
+ }
+
+ }
+
+ private LdapMessage msg; // msg request sent to server
+ private Connection conn; // Connection object where msg sent
+ private MessageAgent agent; // MessageAgent handling this request
+ private LdapMessageQueue queue; // Application message queue
+ private int mslimit; // client time limit in milliseconds
+ private SupportClass.ThreadClass timer = null; // Timeout thread
+ // Note: MessageVector is synchronized
+ private MessageVector replies; // place to store replies
+ private int msgId; // message ID of this request
+ private bool acceptReplies = true; // false if no longer accepting replies
+ private bool waitForReply_Renamed_Field = true; // true if wait for reply
+ private bool complete = false; // true LdapResult received
+ private System.String name; // String name used for Debug
+ private BindProperties bindprops; // Bind properties if a bind request
+
+ internal Message(LdapMessage msg, int mslimit, Connection conn, MessageAgent agent, LdapMessageQueue queue, BindProperties bindprops)
+ {
+ InitBlock();
+ this.msg = msg;
+ this.conn = conn;
+ this.agent = agent;
+ this.queue = queue;
+ this.mslimit = mslimit;
+ this.msgId = msg.MessageID;
+ this.bindprops = bindprops;
+ return ;
+ }
+
+ internal void sendMessage()
+ {
+ conn.writeMessage(this);
+ // Start the timer thread
+ if (mslimit != 0)
+ {
+ // Don't start the timer thread for abandon or Unbind
+ switch (msg.Type)
+ {
+
+ case LdapMessage.ABANDON_REQUEST:
+ case LdapMessage.UNBIND_REQUEST:
+ mslimit = 0;
+ break;
+
+ default:
+ timer = new Timeout(this, mslimit, this);
+ timer.IsBackground = true; // If this is the last thread running, allow exit.
+ timer.Start();
+ break;
+
+ }
+ }
+ return ;
+ }
+
+ internal virtual void Abandon(LdapConstraints cons, InterThreadException informUserEx)
+ {
+ if (!waitForReply_Renamed_Field)
+ {
+ return ;
+ }
+ acceptReplies = false; // don't listen to anyone
+ waitForReply_Renamed_Field = false; // don't let sleeping threads lie
+ if (!complete)
+ {
+ try
+ {
+ // If a bind, release bind semaphore & wake up waiting threads
+ // Must do before writing abandon message, otherwise deadlock
+ if (bindprops != null)
+ {
+ int id;
+ if (conn.BindSemIdClear)
+ {
+ // Semaphore id for normal operations
+ id = msgId;
+ }
+ else
+ {
+ // Semaphore id for sasl bind
+ id = conn.BindSemId;
+ conn.clearBindSemId();
+ }
+ conn.freeWriteSemaphore(id);
+ }
+
+ // Create the abandon message, but don't track it.
+ LdapControl[] cont = null;
+ if (cons != null)
+ {
+ cont = cons.getControls();
+ }
+ LdapMessage msg = new LdapAbandonRequest(msgId, cont);
+ // Send abandon message to server
+ conn.writeMessage(msg);
+ }
+ catch (LdapException ex)
+ {
+ ; // do nothing
+ }
+ // If not informing user, remove message from agent
+ if (informUserEx == null)
+ {
+ agent.Abandon(msgId, null);
+ }
+ conn.removeMessage(this);
+ }
+ // Get rid of all replies queued
+ if (informUserEx != null)
+ {
+ replies.Add(new LdapResponse(informUserEx, conn.ActiveReferral));
+ stopTimer();
+ // wake up waiting threads to receive exception
+ sleepersAwake();
+ // Message will get cleaned up when last response removed from queue
+ }
+ else
+ {
+ // Wake up any waiting threads, so they can terminate.
+ // If informing the user, we wake sleepers after
+ // caller queues dummy response with error status
+ sleepersAwake();
+ cleanup();
+ }
+ return ;
+ }
+
+ private void cleanup()
+ {
+ stopTimer(); // Make sure timer stopped
+ try
+ {
+ acceptReplies = false;
+ if (conn != null)
+ {
+ conn.removeMessage(this);
+ }
+ // Empty out any accumuluated replies
+ if (replies != null)
+ {
+ while (!(replies.Count == 0))
+ {
+ System.Object temp_object;
+ temp_object = replies[0];
+ replies.RemoveAt(0);
+ System.Object generatedAux = temp_object;
+ }
+ }
+ }
+ catch (System.Exception ex)
+ {
+ // nothing
+ }
+ // Let GC clean up this stuff, leave name in case finalized is called
+ conn = null;
+ msg = null;
+ // agent = null; // leave this reference
+ queue = null;
+ //replies = null; //leave this since we use it as a semaphore
+ bindprops = null;
+ return ;
+ }
+
+ ~Message()
+ {
+ cleanup();
+ return ;
+ }
+
+
+ internal virtual void putReply(RfcLdapMessage message)
+ {
+ if (!acceptReplies)
+ {
+ return ;
+ }
+ replies.Add(message);
+ message.RequestingMessage = msg; // Save request message info
+ switch (message.Type)
+ {
+
+ case LdapMessage.SEARCH_RESPONSE:
+ case LdapMessage.SEARCH_RESULT_REFERENCE:
+ break;
+
+ default:
+ int res;
+ stopTimer();
+ // Accept no more results for this message
+ // Leave on connection queue so we can abandon if necessary
+ acceptReplies = false;
+ complete = true;
+ if (bindprops != null)
+ {
+ res = ((RfcResponse) message.Response).getResultCode().intValue();
+ if (res == LdapException.SASL_BIND_IN_PROGRESS)
+ {
+ }
+ else
+ {
+ // We either have success or failure on the bind
+ if (res == LdapException.SUCCESS)
+ {
+ // Set bind properties into connection object
+ conn.BindProperties = bindprops;
+ }
+ else
+ {
+ }
+ // If not a sasl bind in-progress, release the bind
+ // semaphore and wake up all waiting threads
+ int id;
+ if (conn.BindSemIdClear)
+ {
+ // Semaphore id for normal operations
+ id = msgId;
+ }
+ else
+ {
+ // Semaphore id for sasl bind
+ id = conn.BindSemId;
+ conn.clearBindSemId();
+ }
+ conn.freeWriteSemaphore(id);
+ }
+ }
+ break;
+
+ }
+ // wake up waiting threads
+ sleepersAwake();
+ return ;
+ }
+
+ /// <summary> stops the timeout timer from running</summary>
+ /* package */
+ internal virtual void stopTimer()
+ {
+ // If timer thread started, stop it
+ if (timer != null)
+ {
+ timer.Interrupt();
+ }
+ return ;
+ }
+
+ /// <summary> Notifies all waiting threads</summary>
+ private void sleepersAwake()
+ {
+ // Notify any thread waiting for this message id
+ lock (replies)
+ {
+ System.Threading.Monitor.Pulse(replies);
+ }
+ // Notify a thread waiting for any message id
+ agent.sleepersAwake(false);
+ return ;
+ }
+
+ /// <summary> Timer class to provide timing for messages. Only called
+ /// if time to wait is non zero.
+ /// </summary>
+ private sealed class Timeout:SupportClass.ThreadClass
+ {
+ private void InitBlock(Message enclosingInstance)
+ {
+ this.enclosingInstance = enclosingInstance;
+ }
+ private Message enclosingInstance;
+ public Message Enclosing_Instance
+ {
+ get
+ {
+ return enclosingInstance;
+ }
+
+ }
+ private int timeToWait = 0;
+ private Message message;
+
+ /* package */
+ internal Timeout(Message enclosingInstance, int interval, Message msg):base()
+ {
+ InitBlock(enclosingInstance);
+ timeToWait = interval;
+ message = msg;
+ return ;
+ }
+
+ /// <summary> The timeout thread. If it wakes from the sleep, future input
+ /// is stopped and the request is timed out.
+ /// </summary>
+ override public void Run()
+ {
+ try
+ {
+ System.Threading.Thread.Sleep(new System.TimeSpan(10000 * timeToWait));
+ message.acceptReplies = false;
+ // Note: Abandon clears the bind semaphore after failed bind.
+ message.Abandon(null, new InterThreadException("Client request timed out", null, LdapException.Ldap_TIMEOUT, null, message));
+ }
+ catch (System.Threading.ThreadInterruptedException ie)
+ {
+ // the timer was stopped, do nothing
+ }
+ return ;
+ }
+ }
+
+ /// <summary> sets the agent for this message</summary>
+
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/MessageAgent.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/MessageAgent.cs
new file mode 100755
index 00000000000..48731f24d32
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/MessageAgent.cs
@@ -0,0 +1,436 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.MessageAgent.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+using Novell.Directory.Ldap.Utilclass;
+
+namespace Novell.Directory.Ldap
+{
+
+ /* package */
+ class MessageAgent
+ {
+ private void InitBlock()
+ {
+ messages = new MessageVector(5, 5);
+ }
+ /// <summary> empty and return all messages owned by this agent
+ ///
+ ///
+ /// </summary>
+ virtual internal System.Object[] MessageArray
+ {
+ /* package */
+
+ get
+ {
+ return messages.ObjectArray;
+ }
+
+ }
+ /// <summary> Get a list of message ids controlled by this agent
+ ///
+ /// </summary>
+ /// <returns> an array of integers representing the message ids
+ /// </returns>
+ virtual internal int[] MessageIDs
+ {
+ /* package */
+
+ get
+ {
+ int size = messages.Count;
+ int[] ids = new int[size];
+ Message info;
+
+ for (int i = 0; i < size; i++)
+ {
+ info = (Message) messages[i];
+ ids[i] = info.MessageID;
+ }
+ return ids;
+ }
+
+ }
+ /// <summary> Get the maessage agent number for debugging
+ ///
+ /// </summary>
+ /// <returns> the agent number
+ /// </returns>
+ virtual internal System.String AgentName
+ {
+ /*packge*/
+
+ get
+ {
+ return name;
+ }
+
+ }
+ /// <summary> Get a count of all messages queued</summary>
+ virtual internal int Count
+ {
+ /* package */
+
+ get
+ {
+ int count = 0;
+ System.Object[] msgs = messages.ToArray();
+ for (int i = 0; i < msgs.Length; i++)
+ {
+ Message m = (Message) msgs[i];
+ count += m.Count;
+ }
+ return count;
+ }
+
+ }
+ private MessageVector messages;
+ private int indexLastRead = 0;
+ private static System.Object nameLock; // protect agentNum
+ private static int agentNum = 0; // Debug, agent number
+ private System.String name; // String name for debug
+
+ /* package */
+ internal MessageAgent()
+ {
+ InitBlock();
+ // Get a unique agent id for debug
+ }
+
+ /// <summary> merges two message agents
+ ///
+ /// </summary>
+ /// <param name="fromAgent">the agent to be merged into this one
+ /// </param>
+ /* package */
+ internal void merge(MessageAgent fromAgent)
+ {
+ System.Object[] msgs = fromAgent.MessageArray;
+ for (int i = 0; i < msgs.Length; i++)
+ {
+ messages.Add(msgs[i]);
+ ((Message) (msgs[i])).Agent = this;
+ }
+ lock (messages)
+ {
+ if (msgs.Length > 1)
+ {
+ System.Threading.Monitor.PulseAll(messages); // wake all threads waiting for messages
+ }
+ else if (msgs.Length == 1)
+ {
+ System.Threading.Monitor.Pulse(messages); // only wake one thread
+ }
+ }
+ return ;
+ }
+
+
+ /// <summary> Wakes up any threads waiting for messages in the message agent
+ ///
+ /// </summary>
+ /* package */
+ internal void sleepersAwake(bool all)
+ {
+ lock (messages)
+ {
+ if (all)
+ System.Threading.Monitor.PulseAll(messages);
+ else
+ System.Threading.Monitor.Pulse(messages);
+ }
+ return ;
+ }
+
+ /// <summary> Returns true if any responses are queued for any of the agent's messages
+ ///
+ /// return false if no responses are queued, otherwise true
+ /// </summary>
+ /* package */
+ internal bool isResponseReceived()
+ {
+ int size = messages.Count;
+ int next = indexLastRead + 1;
+ Message info;
+ for (int i = 0; i < size; i++)
+ {
+ if (next == size)
+ {
+ next = 0;
+ }
+ info = (Message) messages[next];
+ if (info.hasReplies())
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /// <summary> Returns true if any responses are queued for the specified msgId
+ ///
+ /// return false if no responses are queued, otherwise true
+ /// </summary>
+ /* package */
+ internal bool isResponseReceived(int msgId)
+ {
+ try
+ {
+ Message info = messages.findMessageById(msgId);
+ return info.hasReplies();
+ }
+ catch (System.FieldAccessException ex)
+ {
+ return false;
+ }
+ }
+
+ /// <summary> Abandon the request associated with MsgId
+ ///
+ /// </summary>
+ /// <param name="msgId">the message id to abandon
+ /// <br><br>
+ /// </param>
+ /// <param name="cons">constraints associated with this request
+ /// </param>
+ /* package */
+ internal void Abandon(int msgId, LdapConstraints cons)
+ //, boolean informUser)
+ {
+ Message info = null;
+ try
+ {
+ // Send abandon request and remove from connection list
+ info = messages.findMessageById(msgId);
+ SupportClass.VectorRemoveElement(messages, info); // This message is now dead
+ info.Abandon(cons, null);
+
+ return ;
+ }
+ catch (System.FieldAccessException ex)
+ {
+ }
+ return ;
+ }
+
+ /// <summary> Abandon all requests on this MessageAgent</summary>
+ /* package */
+ internal void AbandonAll()
+ {
+ int size = messages.Count;
+ Message info;
+
+ for (int i = 0; i < size; i++)
+ {
+ info = (Message) messages[i];
+ // Message complete and no more replies, remove from id list
+ SupportClass.VectorRemoveElement(messages, info);
+ info.Abandon(null, null);
+ }
+ return ;
+ }
+
+ /// <summary> Indicates whether a specific operation is complete
+ ///
+ /// </summary>
+ /// <returns> true if a specific operation is complete
+ /// </returns>
+ /* package */
+ internal bool isComplete(int msgid)
+ {
+ try
+ {
+ Message info = messages.findMessageById(msgid);
+ if (!info.Complete)
+ {
+ return false;
+ }
+ }
+ catch (System.FieldAccessException ex)
+ {
+ ; // return true, if no message, it must be complete
+ }
+ return true;
+ }
+
+ /// <summary> Returns the Message object for a given messageID
+ ///
+ /// </summary>
+ /// <param name="msgid">the message ID.
+ /// </param>
+ /* package */
+ internal Message getMessage(int msgid)
+ {
+ return messages.findMessageById(msgid);
+ }
+
+ /// <summary> Send a request to the server. A Message class is created
+ /// for the specified request which causes the message to be sent.
+ /// The request is added to the list of messages being managed by
+ /// this agent.
+ ///
+ /// </summary>
+ /// <param name="conn">the connection that identifies the server.
+ /// <br><br>
+ /// </param>
+ /// <param name="msg">the LdapMessage to send
+ /// <br><br>
+ /// </param>
+ /// <param name="timeOut">the interval to wait for the message to complete or
+ /// <code>null</code> if infinite.
+ /// </param>
+ /// <param name="queue">the LdapMessageQueue associated with this request.
+ /// </param>
+ /* package */
+ internal void sendMessage(Connection conn, LdapMessage msg, int timeOut, LdapMessageQueue queue, BindProperties bindProps)
+ {
+ // creating a messageInfo causes the message to be sent
+ // and a timer to be started if needed.
+ Message message = new Message(msg, timeOut, conn, this, queue, bindProps);
+ messages.Add(message);
+ message.sendMessage(); // Now send message to server
+ return ;
+ }
+
+ /// <summary> Returns a response queued, or waits if none queued
+ ///
+ /// </summary>
+ /* package */
+// internal System.Object getLdapMessage(System.Int32 msgId)
+ internal System.Object getLdapMessage(System.Int32 msgId)
+ {
+ return (getLdapMessage(new Integer32(msgId)));
+ }
+
+ internal System.Object getLdapMessage(Integer32 msgId)
+ {
+ System.Object rfcMsg;
+ // If no messages for this agent, just return null
+ if (messages.Count == 0)
+ {
+ return null;
+ }
+ if ( msgId != null)
+ {
+ // Request messages for a specific ID
+ try
+ {
+ // Get message for this ID
+// Message info = messages.findMessageById(msgId);
+ Message info = messages.findMessageById(msgId.intValue);
+ rfcMsg = info.waitForReply(); // blocks for a response
+ if (!info.acceptsReplies() && !info.hasReplies())
+ {
+ // Message complete and no more replies, remove from id list
+ SupportClass.VectorRemoveElement(messages, info);
+ info.Abandon(null, null); // Get rid of resources
+ }
+ else
+ {
+ }
+ return rfcMsg;
+ }
+ catch (System.FieldAccessException ex)
+ {
+ // no such message id
+ return null;
+ }
+ }
+ else
+ {
+ // A msgId was NOT specified, any message will do
+ lock (messages)
+ {
+ while (true)
+ {
+ int next = indexLastRead + 1;
+ Message info;
+ for (int i = 0; i < messages.Count; i++)
+ {
+ if (next >= messages.Count)
+ {
+ next = 0;
+ }
+ info = (Message) messages[next];
+ indexLastRead = next++;
+ rfcMsg = info.Reply;
+ // Check this request is complete
+ if (!info.acceptsReplies() && !info.hasReplies())
+ {
+ // Message complete & no more replies, remove from id list
+ SupportClass.VectorRemoveElement(messages, info); // remove from list
+ info.Abandon(null, null); // Get rid of resources
+ // Start loop at next message that is now moved
+ // to the current position in the Vector.
+ i -= 1;
+ }
+ if (rfcMsg != null)
+ {
+ // We got a reply
+ return rfcMsg;
+ }
+ else
+ {
+ // We found no reply here
+ }
+ } // end for loop */
+ // Messages can be removed in this loop, we we must
+ // check if any messages left for this agent
+ if (messages.Count == 0)
+ {
+ return null;
+ }
+
+ // No data, wait for something to come in.
+ try
+ {
+ System.Threading.Monitor.Wait(messages);
+ }
+ catch (System.Threading.ThreadInterruptedException ex)
+ {
+ }
+ } /* end while */
+ } /* end synchronized */
+ }
+ }
+
+ /// <summary> Debug code to print messages in message vector</summary>
+ private void debugDisplayMessages()
+ {
+ return ;
+ }
+ static MessageAgent()
+ {
+ nameLock = new System.Object();
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/MessageVector.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/MessageVector.cs
new file mode 100755
index 00000000000..cdbdb8ac427
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/MessageVector.cs
@@ -0,0 +1,109 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.MessageVector.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+
+namespace Novell.Directory.Ldap
+{
+
+ /// <summary> The <code>MessageVector</code> class implements additional semantics
+ /// to Vector needed for handling messages.
+ /// </summary>
+ /* package */
+ class MessageVector:System.Collections.ArrayList
+ {
+ /// <summary>Returns an array containing all of the elements in this MessageVector.
+ /// The elements returned are in the same order in the array as in the
+ /// Vector. The contents of the vector are cleared.
+ ///
+ /// </summary>
+ /// <returns> the array containing all of the elements.
+ /// </returns>
+ virtual internal System.Object[] ObjectArray
+ {
+ /* package */
+
+ get
+ {
+ lock (this)
+ {
+ System.Object[] results = new System.Object[Count];
+ Array.Copy((System.Array) ToArray(), 0, (System.Array) results, 0, Count);
+ for (int i = 0; i < Count; i++)
+ {
+ ToArray()[i] = null;
+ }
+// Count = 0;
+ return results;
+ }
+ }
+
+ }
+ /* package */
+ internal MessageVector(int cap, int incr):base(cap)
+ {
+ return ;
+ }
+
+ /// <summary> Finds the Message object with the given MsgID, and returns the Message
+ /// object. It finds the object and returns it in an atomic operation.
+ ///
+ /// </summary>
+ /// <param name="msgId">The msgId of the Message object to return
+ ///
+ /// </param>
+ /// <returns> The Message object corresponding to this MsgId.
+ ///
+ /// @throws NoSuchFieldException when no object with the corresponding
+ /// value for the MsgId field can be found.
+ /// </returns>
+ /* package */
+ internal Message findMessageById(int msgId)
+ {
+ lock (this)
+ {
+ Message msg = null;
+ for (int i = 0; i < Count; i++)
+ {
+ if ((msg = (Message) ToArray()[i]) == null)
+ {
+ throw new System.FieldAccessException();
+ }
+ if (msg.MessageID == msgId)
+ {
+ return msg;
+ }
+ }
+ throw new System.FieldAccessException();
+ }
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/SupportClass.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/SupportClass.cs
new file mode 100755
index 00000000000..3bbd8f90ce4
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/SupportClass.cs
@@ -0,0 +1,2090 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.SupportClass.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+// Support classes replicate the functionality of the original code, but in some cases they are
+// substantially different architecturally. Although every effort is made to preserve the
+// original architecture of the application in the converted project, the user should be aware that
+// the primary goal of these support classes is to replicate functionality, and that at times
+// the architecture of the resulting solution may differ somewhat.
+//
+
+using System;
+
+ /// <summary>
+ /// This interface should be implemented by any class whose instances are intended
+ /// to be executed by a thread.
+ /// </summary>
+ public interface IThreadRunnable
+ {
+ /// <summary>
+ /// This method has to be implemented in order that starting of the thread causes the object's
+ /// run method to be called in that separately executing thread.
+ /// </summary>
+ void Run();
+ }
+
+
+ public class Integer32 : System.Object
+ {
+ private System.Int32 _wintv;
+
+ public Integer32(System.Int32 ival)
+ {
+ _wintv=ival;
+ }
+
+ public System.Int32 intValue
+ {
+ get
+ {
+ return _wintv;
+ }
+ set
+ {
+ _wintv=value;
+ }
+ }
+ }
+
+ /// <summary>
+ /// Contains conversion support elements such as classes, interfaces and static methods.
+ /// </summary>
+ public class SupportClass
+ {
+ /// <summary>
+ /// Receives a byte array and returns it transformed in an sbyte array
+ /// </summary>
+ /// <param name="byteArray">Byte array to process</param>
+ /// <returns>The transformed array</returns>
+ [CLSCompliantAttribute(false)]
+ public static sbyte[] ToSByteArray(byte[] byteArray)
+ {
+ sbyte[] sbyteArray = new sbyte[byteArray.Length];
+ for(int index=0; index < byteArray.Length; index++)
+ sbyteArray[index] = (sbyte) byteArray[index];
+ return sbyteArray;
+ }
+ /*******************************/
+ /// <summary>
+ /// Converts an array of sbytes to an array of bytes
+ /// </summary>
+ /// <param name="sbyteArray">The array of sbytes to be converted</param>
+ /// <returns>The new array of bytes</returns>
+ [CLSCompliantAttribute(false)]
+ public static byte[] ToByteArray(sbyte[] sbyteArray)
+ {
+ byte[] byteArray = new byte[sbyteArray.Length];
+ for(int index=0; index < sbyteArray.Length; index++)
+ byteArray[index] = (byte) sbyteArray[index];
+ return byteArray;
+ }
+
+ /// <summary>
+ /// Converts a string to an array of bytes
+ /// </summary>
+ /// <param name="sourceString">The string to be converted</param>
+ /// <returns>The new array of bytes</returns>
+ public static byte[] ToByteArray(string sourceString)
+ {
+ byte[] byteArray = new byte[sourceString.Length];
+ for (int index=0; index < sourceString.Length; index++)
+ byteArray[index] = (byte) sourceString[index];
+ return byteArray;
+ }
+
+ /// <summary>
+ /// Converts a array of object-type instances to a byte-type array.
+ /// </summary>
+ /// <param name="tempObjectArray">Array to convert.</param>
+ /// <returns>An array of byte type elements.</returns>
+ public static byte[] ToByteArray(object[] tempObjectArray)
+ {
+ byte[] byteArray = new byte[tempObjectArray.Length];
+ for (int index = 0; index < tempObjectArray.Length; index++)
+ byteArray[index] = (byte)tempObjectArray[index];
+ return byteArray;
+ }
+
+
+ /*******************************/
+ /// <summary>Reads a number of characters from the current source Stream and writes the data to the target array at the specified index.</summary>
+ /// <param name="sourceStream">The source Stream to read from.</param>
+ /// <param name="target">Contains the array of characteres read from the source Stream.</param>
+ /// <param name="start">The starting index of the target array.</param>
+ /// <param name="count">The maximum number of characters to read from the source Stream.</param>
+ /// <returns>The number of characters read. The number will be less than or equal to count depending on the data available in the source Stream. Returns -1 if the end of the stream is reached.</returns>
+ [CLSCompliantAttribute(false)]
+ public static System.Int32 ReadInput(System.IO.Stream sourceStream, ref sbyte[] target, int start, int count)
+ {
+ // Returns 0 bytes if not enough space in target
+ if (target.Length == 0)
+ return 0;
+
+ byte[] receiver = new byte[target.Length];
+ int bytesRead = sourceStream.Read(receiver, start, count);
+
+ // Returns -1 if EOF
+ if (bytesRead == 0)
+ return -1;
+
+ for(int i = start; i < start + bytesRead; i++)
+ target[i] = (sbyte)receiver[i];
+
+ return bytesRead;
+ }
+
+ /// <summary>Reads a number of characters from the current source TextReader and writes the data to the target array at the specified index.</summary>
+ /// <param name="sourceTextReader">The source TextReader to read from</param>
+ /// <param name="target">Contains the array of characteres read from the source TextReader.</param>
+ /// <param name="start">The starting index of the target array.</param>
+ /// <param name="count">The maximum number of characters to read from the source TextReader.</param>
+ /// <returns>The number of characters read. The number will be less than or equal to count depending on the data available in the source TextReader. Returns -1 if the end of the stream is reached.</returns>
+ [CLSCompliantAttribute(false)]
+ public static System.Int32 ReadInput(System.IO.TextReader sourceTextReader, ref sbyte[] target, int start, int count)
+ {
+ // Returns 0 bytes if not enough space in target
+ if (target.Length == 0) return 0;
+
+ char[] charArray = new char[target.Length];
+ int bytesRead = sourceTextReader.Read(charArray, start, count);
+
+ // Returns -1 if EOF
+ if (bytesRead == 0) return -1;
+
+ for(int index=start; index<start+bytesRead; index++)
+ target[index] = (sbyte)charArray[index];
+
+ return bytesRead;
+ }
+
+ /*******************************/
+ /// <summary>
+ /// This method returns the literal value received
+ /// </summary>
+ /// <param name="literal">The literal to return</param>
+ /// <returns>The received value</returns>
+ public static long Identity(long literal)
+ {
+ return literal;
+ }
+
+ /// <summary>
+ /// This method returns the literal value received
+ /// </summary>
+ /// <param name="literal">The literal to return</param>
+ /// <returns>The received value</returns>
+ [CLSCompliantAttribute(false)]
+ public static ulong Identity(ulong literal)
+ {
+ return literal;
+ }
+
+ /// <summary>
+ /// This method returns the literal value received
+ /// </summary>
+ /// <param name="literal">The literal to return</param>
+ /// <returns>The received value</returns>
+ public static float Identity(float literal)
+ {
+ return literal;
+ }
+
+ /// <summary>
+ /// This method returns the literal value received
+ /// </summary>
+ /// <param name="literal">The literal to return</param>
+ /// <returns>The received value</returns>
+ public static double Identity(double literal)
+ {
+ return literal;
+ }
+
+ /*******************************/
+ /// <summary>
+ /// The class performs token processing from strings
+ /// </summary>
+ public class Tokenizer
+ {
+ //Element list identified
+ private System.Collections.ArrayList elements;
+ //Source string to use
+ private string source;
+ //The tokenizer uses the default delimiter set: the space character, the tab character, the newline character, and the carriage-return character
+ private string delimiters = " \t\n\r";
+
+ /// <summary>
+ /// Initializes a new class instance with a specified string to process
+ /// </summary>
+ /// <param name="source">String to tokenize</param>
+ public Tokenizer(string source)
+ {
+ this.elements = new System.Collections.ArrayList();
+ this.elements.AddRange(source.Split(this.delimiters.ToCharArray()));
+ this.RemoveEmptyStrings();
+ this.source = source;
+ }
+
+ /// <summary>
+ /// Initializes a new class instance with a specified string to process
+ /// and the specified token delimiters to use
+ /// </summary>
+ /// <param name="source">String to tokenize</param>
+ /// <param name="delimiters">String containing the delimiters</param>
+ public Tokenizer(string source, string delimiters)
+ {
+ this.elements = new System.Collections.ArrayList();
+ this.delimiters = delimiters;
+ this.elements.AddRange(source.Split(this.delimiters.ToCharArray()));
+ this.RemoveEmptyStrings();
+ this.source = source;
+ }
+
+ /// <summary>
+ /// Current token count for the source string
+ /// </summary>
+ public int Count
+ {
+ get
+ {
+ return (this.elements.Count);
+ }
+ }
+
+ /// <summary>
+ /// Determines if there are more tokens to return from the source string
+ /// </summary>
+ /// <returns>True or false, depending if there are more tokens</returns>
+ public bool HasMoreTokens()
+ {
+ return (this.elements.Count > 0);
+ }
+
+ /// <summary>
+ /// Returns the next token from the token list
+ /// </summary>
+ /// <returns>The string value of the token</returns>
+ public string NextToken()
+ {
+ string result;
+ if (source == "") throw new System.Exception();
+ else
+ {
+ this.elements = new System.Collections.ArrayList();
+ this.elements.AddRange(this.source.Split(delimiters.ToCharArray()));
+ RemoveEmptyStrings();
+ result = (string) this.elements[0];
+ this.elements.RemoveAt(0);
+ this.source = this.source.Remove(this.source.IndexOf(result),result.Length);
+ this.source = this.source.TrimStart(this.delimiters.ToCharArray());
+ return result;
+ }
+ }
+
+ /// <summary>
+ /// Returns the next token from the source string, using the provided
+ /// token delimiters
+ /// </summary>
+ /// <param name="delimiters">String containing the delimiters to use</param>
+ /// <returns>The string value of the token</returns>
+ public string NextToken(string delimiters)
+ {
+ this.delimiters = delimiters;
+ return NextToken();
+ }
+
+ /// <summary>
+ /// Removes all empty strings from the token list
+ /// </summary>
+ private void RemoveEmptyStrings()
+ {
+ for (int index=0; index < this.elements.Count; index++)
+ if ((string)this.elements[index]== "")
+ {
+ this.elements.RemoveAt(index);
+ index--;
+ }
+ }
+ }
+
+ /*******************************/
+ /// <summary>
+ /// Provides support for DateFormat
+ /// </summary>
+ public class DateTimeFormatManager
+ {
+ static public DateTimeFormatHashTable manager = new DateTimeFormatHashTable();
+
+ /// <summary>
+ /// Hashtable class to provide functionality for dateformat properties
+ /// </summary>
+ public class DateTimeFormatHashTable :System.Collections.Hashtable
+ {
+ /// <summary>
+ /// Sets the format for datetime.
+ /// </summary>
+ /// <param name="format">DateTimeFormat instance to set the pattern</param>
+ /// <param name="newPattern">A string with the pattern format</param>
+ public void SetDateFormatPattern(System.Globalization.DateTimeFormatInfo format, System.String newPattern)
+ {
+ if (this[format] != null)
+ ((DateTimeFormatProperties) this[format]).DateFormatPattern = newPattern;
+ else
+ {
+ DateTimeFormatProperties tempProps = new DateTimeFormatProperties();
+ tempProps.DateFormatPattern = newPattern;
+ Add(format, tempProps);
+ }
+ }
+
+ /// <summary>
+ /// Gets the current format pattern of the DateTimeFormat instance
+ /// </summary>
+ /// <param name="format">The DateTimeFormat instance which the value will be obtained</param>
+ /// <returns>The string representing the current datetimeformat pattern</returns>
+ public string GetDateFormatPattern(System.Globalization.DateTimeFormatInfo format)
+ {
+ if (this[format] == null)
+ return "d-MMM-yy";
+ else
+ return ((DateTimeFormatProperties) this[format]).DateFormatPattern;
+ }
+
+ /// <summary>
+ /// Sets the datetimeformat pattern to the giving format
+ /// </summary>
+ /// <param name="format">The datetimeformat instance to set</param>
+ /// <param name="newPattern">The new datetimeformat pattern</param>
+ public void SetTimeFormatPattern(System.Globalization.DateTimeFormatInfo format, System.String newPattern)
+ {
+ if (this[format] != null)
+ ((DateTimeFormatProperties) this[format]).TimeFormatPattern = newPattern;
+ else
+ {
+ DateTimeFormatProperties tempProps = new DateTimeFormatProperties();
+ tempProps.TimeFormatPattern = newPattern;
+ Add(format, tempProps);
+ }
+ }
+
+ /// <summary>
+ /// Gets the current format pattern of the DateTimeFormat instance
+ /// </summary>
+ /// <param name="format">The DateTimeFormat instance which the value will be obtained</param>
+ /// <returns>The string representing the current datetimeformat pattern</returns>
+ public string GetTimeFormatPattern(System.Globalization.DateTimeFormatInfo format)
+ {
+ if (this[format] == null)
+ return "h:mm:ss tt";
+ else
+ return ((DateTimeFormatProperties) this[format]).TimeFormatPattern;
+ }
+
+ /// <summary>
+ /// Internal class to provides the DateFormat and TimeFormat pattern properties on .NET
+ /// </summary>
+ class DateTimeFormatProperties
+ {
+ public string DateFormatPattern = "d-MMM-yy";
+ public string TimeFormatPattern = "h:mm:ss tt";
+ }
+ }
+ }
+ /*******************************/
+ /// <summary>
+ /// Gets the DateTimeFormat instance and date instance to obtain the date with the format passed
+ /// </summary>
+ /// <param name="format">The DateTimeFormat to obtain the time and date pattern</param>
+ /// <param name="date">The date instance used to get the date</param>
+ /// <returns>A string representing the date with the time and date patterns</returns>
+ public static string FormatDateTime(System.Globalization.DateTimeFormatInfo format, System.DateTime date)
+ {
+ string timePattern = DateTimeFormatManager.manager.GetTimeFormatPattern(format);
+ string datePattern = DateTimeFormatManager.manager.GetDateFormatPattern(format);
+ return date.ToString(datePattern + " " + timePattern, format);
+ }
+
+ /*******************************/
+ /// <summary>
+ /// Adds a new key-and-value pair into the hash table
+ /// </summary>
+ /// <param name="collection">The collection to work with</param>
+ /// <param name="key">Key used to obtain the value</param>
+ /// <param name="newValue">Value asociated with the key</param>
+ /// <returns>The old element associated with the key</returns>
+ public static System.Object PutElement(System.Collections.IDictionary collection, System.Object key, System.Object newValue)
+ {
+ System.Object element = collection[key];
+ collection[key] = newValue;
+ return element;
+ }
+
+ /*******************************/
+ /// <summary>
+ /// This class contains static methods to manage arrays.
+ /// </summary>
+ public class ArrayListSupport
+ {
+ /// <summary>
+ /// Obtains an array containing all the elements of the collection.
+ /// </summary>
+ /// <param name="collection">The collection from wich to obtain the elements.</param>
+ /// <param name="objects">The array containing all the elements of the collection.</param>
+ /// <returns>The array containing all the elements of the collection.</returns>
+ public static System.Object[] ToArray(System.Collections.ArrayList collection, System.Object[] objects)
+ {
+ int index = 0;
+ System.Collections.IEnumerator tempEnumerator = collection.GetEnumerator();
+ while (tempEnumerator.MoveNext())
+ objects[index++] = tempEnumerator.Current;
+ return objects;
+ }
+ }
+
+
+ /*******************************/
+ /// <summary>
+ /// Removes the first occurrence of an specific object from an ArrayList instance.
+ /// </summary>
+ /// <param name="arrayList">The ArrayList instance</param>
+ /// <param name="element">The element to remove</param>
+ /// <returns>True if item is found in the ArrayList; otherwise, false</returns>
+ public static System.Boolean VectorRemoveElement(System.Collections.ArrayList arrayList, System.Object element)
+ {
+ System.Boolean containsItem = arrayList.Contains(element);
+ arrayList.Remove(element);
+ return containsItem;
+ }
+
+ /*******************************/
+ /// <summary>
+ /// Support class used to handle threads
+ /// </summary>
+ public class ThreadClass : IThreadRunnable
+ {
+ /// <summary>
+ /// The instance of System.Threading.Thread
+ /// </summary>
+ private System.Threading.Thread threadField;
+
+ /// <summary>
+ /// Initializes a new instance of the ThreadClass class
+ /// </summary>
+ public ThreadClass()
+ {
+ threadField = new System.Threading.Thread(new System.Threading.ThreadStart(Run));
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the Thread class.
+ /// </summary>
+ /// <param name="Name">The name of the thread</param>
+ public ThreadClass(string Name)
+ {
+ threadField = new System.Threading.Thread(new System.Threading.ThreadStart(Run));
+ this.Name = Name;
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the Thread class.
+ /// </summary>
+ /// <param name="Start">A ThreadStart delegate that references the methods to be invoked when this thread begins executing</param>
+ public ThreadClass(System.Threading.ThreadStart Start)
+ {
+ threadField = new System.Threading.Thread(Start);
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the Thread class.
+ /// </summary>
+ /// <param name="Start">A ThreadStart delegate that references the methods to be invoked when this thread begins executing</param>
+ /// <param name="Name">The name of the thread</param>
+ public ThreadClass(System.Threading.ThreadStart Start, string Name)
+ {
+ threadField = new System.Threading.Thread(Start);
+ this.Name = Name;
+ }
+
+ /// <summary>
+ /// This method has no functionality unless the method is overridden
+ /// </summary>
+ public virtual void Run()
+ {
+ }
+
+ /// <summary>
+ /// Causes the operating system to change the state of the current thread instance to ThreadState.Running
+ /// </summary>
+ public virtual void Start()
+ {
+ threadField.Start();
+ }
+
+ /// <summary>
+ /// Interrupts a thread that is in the WaitSleepJoin thread state
+ /// </summary>
+ public virtual void Interrupt()
+ {
+ threadField.Interrupt();
+ }
+
+ /// <summary>
+ /// Gets the current thread instance
+ /// </summary>
+ public System.Threading.Thread Instance
+ {
+ get
+ {
+ return threadField;
+ }
+ set
+ {
+ threadField = value;
+ }
+ }
+
+ /// <summary>
+ /// Gets or sets the name of the thread
+ /// </summary>
+ public System.String Name
+ {
+ get
+ {
+ return threadField.Name;
+ }
+ set
+ {
+ if (threadField.Name == null)
+ threadField.Name = value;
+ }
+ }
+
+ /// <summary>
+ /// Gets or sets a value indicating the scheduling priority of a thread
+ /// </summary>
+ public System.Threading.ThreadPriority Priority
+ {
+ get
+ {
+ return threadField.Priority;
+ }
+ set
+ {
+ threadField.Priority = value;
+ }
+ }
+
+ /// <summary>
+ /// Gets a value indicating the execution status of the current thread
+ /// </summary>
+ public bool IsAlive
+ {
+ get
+ {
+ return threadField.IsAlive;
+ }
+ }
+
+ /// <summary>
+ /// Gets or sets a value indicating whether or not a thread is a background thread.
+ /// </summary>
+ public bool IsBackground
+ {
+ get
+ {
+ return threadField.IsBackground;
+ }
+ set
+ {
+ threadField.IsBackground = value;
+ }
+ }
+
+ /// <summary>
+ /// Blocks the calling thread until a thread terminates
+ /// </summary>
+ public void Join()
+ {
+ threadField.Join();
+ }
+
+ /// <summary>
+ /// Blocks the calling thread until a thread terminates or the specified time elapses
+ /// </summary>
+ /// <param name="MiliSeconds">Time of wait in milliseconds</param>
+ public void Join(long MiliSeconds)
+ {
+ lock(this)
+ {
+ threadField.Join(new System.TimeSpan(MiliSeconds * 10000));
+ }
+ }
+
+ /// <summary>
+ /// Blocks the calling thread until a thread terminates or the specified time elapses
+ /// </summary>
+ /// <param name="MiliSeconds">Time of wait in milliseconds</param>
+ /// <param name="NanoSeconds">Time of wait in nanoseconds</param>
+ public void Join(long MiliSeconds, int NanoSeconds)
+ {
+ lock(this)
+ {
+ threadField.Join(new System.TimeSpan(MiliSeconds * 10000 + NanoSeconds * 100));
+ }
+ }
+
+ /// <summary>
+ /// Resumes a thread that has been suspended
+ /// </summary>
+ public void Resume()
+ {
+ threadField.Resume();
+ }
+
+ /// <summary>
+ /// Raises a ThreadAbortException in the thread on which it is invoked,
+ /// to begin the process of terminating the thread. Calling this method
+ /// usually terminates the thread
+ /// </summary>
+ public void Abort()
+ {
+ threadField.Abort();
+ }
+
+ /// <summary>
+ /// Raises a ThreadAbortException in the thread on which it is invoked,
+ /// to begin the process of terminating the thread while also providing
+ /// exception information about the thread termination.
+ /// Calling this method usually terminates the thread.
+ /// </summary>
+ /// <param name="stateInfo">An object that contains application-specific information, such as state, which can be used by the thread being aborted</param>
+ public void Abort(System.Object stateInfo)
+ {
+ lock(this)
+ {
+ threadField.Abort(stateInfo);
+ }
+ }
+
+ /// <summary>
+ /// Suspends the thread, if the thread is already suspended it has no effect
+ /// </summary>
+ public void Suspend()
+ {
+ threadField.Suspend();
+ }
+
+ /// <summary>
+ /// Obtain a String that represents the current Object
+ /// </summary>
+ /// <returns>A String that represents the current Object</returns>
+ public override System.String ToString()
+ {
+ return "Thread[" + Name + "," + Priority.ToString() + "," + "" + "]";
+ }
+
+ /// <summary>
+ /// Gets the currently running thread
+ /// </summary>
+ /// <returns>The currently running thread</returns>
+ public static ThreadClass Current()
+ {
+ ThreadClass CurrentThread = new ThreadClass();
+ CurrentThread.Instance = System.Threading.Thread.CurrentThread;
+ return CurrentThread;
+ }
+ }
+
+
+ /*******************************/
+ /// <summary>
+ /// This class contains different methods to manage Collections.
+ /// </summary>
+ public class CollectionSupport : System.Collections.CollectionBase
+ {
+ /// <summary>
+ /// Creates an instance of the Collection by using an inherited constructor.
+ /// </summary>
+ public CollectionSupport() : base()
+ {
+ }
+
+ /// <summary>
+ /// Adds an specified element to the collection.
+ /// </summary>
+ /// <param name="element">The element to be added.</param>
+ /// <returns>Returns true if the element was successfuly added. Otherwise returns false.</returns>
+ public virtual bool Add(System.Object element)
+ {
+ return (this.List.Add(element) != -1);
+ }
+
+ /// <summary>
+ /// Adds all the elements contained in the specified collection.
+ /// </summary>
+ /// <param name="collection">The collection used to extract the elements that will be added.</param>
+ /// <returns>Returns true if all the elements were successfuly added. Otherwise returns false.</returns>
+ public virtual bool AddAll(System.Collections.ICollection collection)
+ {
+ bool result = false;
+ if (collection!=null)
+ {
+ System.Collections.IEnumerator tempEnumerator = new System.Collections.ArrayList(collection).GetEnumerator();
+ while (tempEnumerator.MoveNext())
+ {
+ if (tempEnumerator.Current != null)
+ result = this.Add(tempEnumerator.Current);
+ }
+ }
+ return result;
+ }
+
+
+ /// <summary>
+ /// Adds all the elements contained in the specified support class collection.
+ /// </summary>
+ /// <param name="collection">The collection used to extract the elements that will be added.</param>
+ /// <returns>Returns true if all the elements were successfuly added. Otherwise returns false.</returns>
+ public virtual bool AddAll(CollectionSupport collection)
+ {
+ return this.AddAll((System.Collections.ICollection)collection);
+ }
+
+ /// <summary>
+ /// Verifies if the specified element is contained into the collection.
+ /// </summary>
+ /// <param name="element"> The element that will be verified.</param>
+ /// <returns>Returns true if the element is contained in the collection. Otherwise returns false.</returns>
+ public virtual bool Contains(System.Object element)
+ {
+ return this.List.Contains(element);
+ }
+
+ /// <summary>
+ /// Verifies if all the elements of the specified collection are contained into the current collection.
+ /// </summary>
+ /// <param name="collection">The collection used to extract the elements that will be verified.</param>
+ /// <returns>Returns true if all the elements are contained in the collection. Otherwise returns false.</returns>
+ public virtual bool ContainsAll(System.Collections.ICollection collection)
+ {
+ bool result = false;
+ System.Collections.IEnumerator tempEnumerator = new System.Collections.ArrayList(collection).GetEnumerator();
+ while (tempEnumerator.MoveNext())
+ if (!(result = this.Contains(tempEnumerator.Current)))
+ break;
+ return result;
+ }
+
+ /// <summary>
+ /// Verifies if all the elements of the specified collection are contained into the current collection.
+ /// </summary>
+ /// <param name="collection">The collection used to extract the elements that will be verified.</param>
+ /// <returns>Returns true if all the elements are contained in the collection. Otherwise returns false.</returns>
+ public virtual bool ContainsAll(CollectionSupport collection)
+ {
+ return this.ContainsAll((System.Collections.ICollection) collection);
+ }
+
+ /// <summary>
+ /// Verifies if the collection is empty.
+ /// </summary>
+ /// <returns>Returns true if the collection is empty. Otherwise returns false.</returns>
+ public virtual bool IsEmpty()
+ {
+ return (this.Count == 0);
+ }
+
+ /// <summary>
+ /// Removes an specified element from the collection.
+ /// </summary>
+ /// <param name="element">The element to be removed.</param>
+ /// <returns>Returns true if the element was successfuly removed. Otherwise returns false.</returns>
+ public virtual bool Remove(System.Object element)
+ {
+ bool result = false;
+ if (this.Contains(element))
+ {
+ this.List.Remove(element);
+ result = true;
+ }
+ return result;
+ }
+
+ /// <summary>
+ /// Removes all the elements contained into the specified collection.
+ /// </summary>
+ /// <param name="collection">The collection used to extract the elements that will be removed.</param>
+ /// <returns>Returns true if all the elements were successfuly removed. Otherwise returns false.</returns>
+ public virtual bool RemoveAll(System.Collections.ICollection collection)
+ {
+ bool result = false;
+ System.Collections.IEnumerator tempEnumerator = new System.Collections.ArrayList(collection).GetEnumerator();
+ while (tempEnumerator.MoveNext())
+ {
+ if (this.Contains(tempEnumerator.Current))
+ result = this.Remove(tempEnumerator.Current);
+ }
+ return result;
+ }
+
+ /// <summary>
+ /// Removes all the elements contained into the specified collection.
+ /// </summary>
+ /// <param name="collection">The collection used to extract the elements that will be removed.</param>
+ /// <returns>Returns true if all the elements were successfuly removed. Otherwise returns false.</returns>
+ public virtual bool RemoveAll(CollectionSupport collection)
+ {
+ return this.RemoveAll((System.Collections.ICollection) collection);
+ }
+
+ /// <summary>
+ /// Removes all the elements that aren't contained into the specified collection.
+ /// </summary>
+ /// <param name="collection">The collection used to verify the elements that will be retained.</param>
+ /// <returns>Returns true if all the elements were successfully removed. Otherwise returns false.</returns>
+ public virtual bool RetainAll(System.Collections.ICollection collection)
+ {
+ bool result = false;
+ System.Collections.IEnumerator tempEnumerator = this.GetEnumerator();
+ CollectionSupport tempCollection = new CollectionSupport();
+ tempCollection.AddAll(collection);
+ while (tempEnumerator.MoveNext())
+ if (!tempCollection.Contains(tempEnumerator.Current))
+ {
+ result = this.Remove(tempEnumerator.Current);
+
+ if (result == true)
+ {
+ tempEnumerator = this.GetEnumerator();
+ }
+ }
+ return result;
+ }
+
+ /// <summary>
+ /// Removes all the elements that aren't contained into the specified collection.
+ /// </summary>
+ /// <param name="collection">The collection used to verify the elements that will be retained.</param>
+ /// <returns>Returns true if all the elements were successfully removed. Otherwise returns false.</returns>
+ public virtual bool RetainAll(CollectionSupport collection)
+ {
+ return this.RetainAll((System.Collections.ICollection) collection);
+ }
+
+ /// <summary>
+ /// Obtains an array containing all the elements of the collection.
+ /// </summary>
+ /// <returns>The array containing all the elements of the collection</returns>
+ public virtual System.Object[] ToArray()
+ {
+ int index = 0;
+ System.Object[] objects = new System.Object[this.Count];
+ System.Collections.IEnumerator tempEnumerator = this.GetEnumerator();
+ while (tempEnumerator.MoveNext())
+ objects[index++] = tempEnumerator.Current;
+ return objects;
+ }
+
+ /// <summary>
+ /// Obtains an array containing all the elements of the collection.
+ /// </summary>
+ /// <param name="objects">The array into which the elements of the collection will be stored.</param>
+ /// <returns>The array containing all the elements of the collection.</returns>
+ public virtual System.Object[] ToArray(System.Object[] objects)
+ {
+ int index = 0;
+ System.Collections.IEnumerator tempEnumerator = this.GetEnumerator();
+ while (tempEnumerator.MoveNext())
+ objects[index++] = tempEnumerator.Current;
+ return objects;
+ }
+
+ /// <summary>
+ /// Creates a CollectionSupport object with the contents specified in array.
+ /// </summary>
+ /// <param name="array">The array containing the elements used to populate the new CollectionSupport object.</param>
+ /// <returns>A CollectionSupport object populated with the contents of array.</returns>
+ public static CollectionSupport ToCollectionSupport(System.Object[] array)
+ {
+ CollectionSupport tempCollectionSupport = new CollectionSupport();
+ tempCollectionSupport.AddAll(array);
+ return tempCollectionSupport;
+ }
+ }
+
+ /*******************************/
+ /// <summary>
+ /// This class contains different methods to manage list collections.
+ /// </summary>
+ public class ListCollectionSupport : System.Collections.ArrayList
+ {
+ /// <summary>
+ /// Creates a new instance of the class ListCollectionSupport.
+ /// </summary>
+ public ListCollectionSupport() : base()
+ {
+ }
+
+ /// <summary>
+ /// Creates a new instance of the class ListCollectionSupport.
+ /// </summary>
+ /// <param name="collection">The collection to insert into the new object.</param>
+ public ListCollectionSupport(System.Collections.ICollection collection) : base(collection)
+ {
+ }
+
+ /// <summary>
+ /// Creates a new instance of the class ListCollectionSupport with the specified capacity.
+ /// </summary>
+ /// <param name="capacity">The capacity of the new array.</param>
+ public ListCollectionSupport(int capacity) : base(capacity)
+ {
+ }
+
+ /// <summary>
+ /// Adds an object to the end of the List.
+ /// </summary>
+ /// <param name="valueToInsert">The value to insert in the array list.</param>
+ /// <returns>Returns true after adding the value.</returns>
+ public virtual bool Add(System.Object valueToInsert)
+ {
+ base.Insert(this.Count, valueToInsert);
+ return true;
+ }
+
+ /// <summary>
+ /// Adds all the elements contained into the specified collection, starting at the specified position.
+ /// </summary>
+ /// <param name="index">Position at which to add the first element from the specified collection.</param>
+ /// <param name="list">The list used to extract the elements that will be added.</param>
+ /// <returns>Returns true if all the elements were successfuly added. Otherwise returns false.</returns>
+ public virtual bool AddAll(int index, System.Collections.IList list)
+ {
+ bool result = false;
+ if (list!=null)
+ {
+ System.Collections.IEnumerator tempEnumerator = new System.Collections.ArrayList(list).GetEnumerator();
+ int tempIndex = index;
+ while (tempEnumerator.MoveNext())
+ {
+ base.Insert(tempIndex++, tempEnumerator.Current);
+ result = true;
+ }
+ }
+ return result;
+ }
+
+ /// <summary>
+ /// Adds all the elements contained in the specified collection.
+ /// </summary>
+ /// <param name="collection">The collection used to extract the elements that will be added.</param>
+ /// <returns>Returns true if all the elements were successfuly added. Otherwise returns false.</returns>
+ public virtual bool AddAll(System.Collections.IList collection)
+ {
+ return this.AddAll(this.Count,collection);
+ }
+
+ /// <summary>
+ /// Adds all the elements contained in the specified support class collection.
+ /// </summary>
+ /// <param name="collection">The collection used to extract the elements that will be added.</param>
+ /// <returns>Returns true if all the elements were successfuly added. Otherwise returns false.</returns>
+ public virtual bool AddAll(CollectionSupport collection)
+ {
+ return this.AddAll(this.Count,collection);
+ }
+
+ /// <summary>
+ /// Adds all the elements contained into the specified support class collection, starting at the specified position.
+ /// </summary>
+ /// <param name="index">Position at which to add the first element from the specified collection.</param>
+ /// <param name="list">The list used to extract the elements that will be added.</param>
+ /// <returns>Returns true if all the elements were successfuly added. Otherwise returns false.</returns>
+ public virtual bool AddAll(int index, CollectionSupport collection)
+ {
+ return this.AddAll(index,(System.Collections.IList)collection);
+ }
+
+ /// <summary>
+ /// Creates a copy of the ListCollectionSupport.
+ /// </summary>
+ /// <returns> A copy of the ListCollectionSupport.</returns>
+ public virtual System.Object ListCollectionClone()
+ {
+ return MemberwiseClone();
+ }
+
+
+ /// <summary>
+ /// Returns an iterator of the collection.
+ /// </summary>
+ /// <returns>An IEnumerator.</returns>
+ public virtual System.Collections.IEnumerator ListIterator()
+ {
+ return base.GetEnumerator();
+ }
+
+ /// <summary>
+ /// Removes all the elements contained into the specified collection.
+ /// </summary>
+ /// <param name="collection">The collection used to extract the elements that will be removed.</param>
+ /// <returns>Returns true if all the elements were successfuly removed. Otherwise returns false.</returns>
+ public virtual bool RemoveAll(System.Collections.ICollection collection)
+ {
+ bool result = false;
+ System.Collections.IEnumerator tempEnumerator = new System.Collections.ArrayList(collection).GetEnumerator();
+ while (tempEnumerator.MoveNext())
+ {
+ result = true;
+ if (base.Contains(tempEnumerator.Current))
+ base.Remove(tempEnumerator.Current);
+ }
+ return result;
+ }
+
+ /// <summary>
+ /// Removes all the elements contained into the specified collection.
+ /// </summary>
+ /// <param name="collection">The collection used to extract the elements that will be removed.</param>
+ /// <returns>Returns true if all the elements were successfuly removed. Otherwise returns false.</returns>
+ public virtual bool RemoveAll(CollectionSupport collection)
+ {
+ return this.RemoveAll((System.Collections.ICollection) collection);
+ }
+
+ /// <summary>
+ /// Removes the value in the specified index from the list.
+ /// </summary>
+ /// <param name="index">The index of the value to remove.</param>
+ /// <returns>Returns the value removed.</returns>
+ public virtual System.Object RemoveElement(int index)
+ {
+ System.Object objectRemoved = this[index];
+ this.RemoveAt(index);
+ return objectRemoved;
+ }
+
+ /// <summary>
+ /// Removes an specified element from the collection.
+ /// </summary>
+ /// <param name="element">The element to be removed.</param>
+ /// <returns>Returns true if the element was successfuly removed. Otherwise returns false.</returns>
+ public virtual bool RemoveElement(System.Object element)
+ {
+
+ bool result = false;
+ if (this.Contains(element))
+ {
+ base.Remove(element);
+ result = true;
+ }
+ return result;
+ }
+
+ /// <summary>
+ /// Removes the first value from an array list.
+ /// </summary>
+ /// <returns>Returns the value removed.</returns>
+ public virtual System.Object RemoveFirst()
+ {
+ System.Object objectRemoved = this[0];
+ this.RemoveAt(0);
+ return objectRemoved;
+ }
+
+ /// <summary>
+ /// Removes the last value from an array list.
+ /// </summary>
+ /// <returns>Returns the value removed.</returns>
+ public virtual System.Object RemoveLast()
+ {
+ System.Object objectRemoved = this[this.Count-1];
+ base.RemoveAt(this.Count-1);
+ return objectRemoved;
+ }
+
+ /// <summary>
+ /// Removes all the elements that aren't contained into the specified collection.
+ /// </summary>
+ /// <param name="collection">The collection used to verify the elements that will be retained.</param>
+ /// <returns>Returns true if all the elements were successfully removed. Otherwise returns false.</returns>
+ public virtual bool RetainAll(System.Collections.ICollection collection)
+ {
+ bool result = false;
+ System.Collections.IEnumerator tempEnumerator = this.GetEnumerator();
+ ListCollectionSupport tempCollection = new ListCollectionSupport(collection);
+ while (tempEnumerator.MoveNext())
+ if (!tempCollection.Contains(tempEnumerator.Current))
+ {
+ result = this.RemoveElement(tempEnumerator.Current);
+
+ if (result == true)
+ {
+ tempEnumerator = this.GetEnumerator();
+ }
+ }
+ return result;
+ }
+
+ /// <summary>
+ /// Removes all the elements that aren't contained into the specified collection.
+ /// </summary>
+ /// <param name="collection">The collection used to verify the elements that will be retained.</param>
+ /// <returns>Returns true if all the elements were successfully removed. Otherwise returns false.</returns>
+ public virtual bool RetainAll(CollectionSupport collection)
+ {
+ return this.RetainAll((System.Collections.ICollection) collection);
+ }
+
+ /// <summary>
+ /// Verifies if all the elements of the specified collection are contained into the current collection.
+ /// </summary>
+ /// <param name="collection">The collection used to extract the elements that will be verified.</param>
+ /// <returns>Returns true if all the elements are contained in the collection. Otherwise returns false.</returns>
+ public virtual bool ContainsAll(System.Collections.ICollection collection)
+ {
+ bool result = false;
+ System.Collections.IEnumerator tempEnumerator = new System.Collections.ArrayList(collection).GetEnumerator();
+ while (tempEnumerator.MoveNext())
+ if(!(result = this.Contains(tempEnumerator.Current)))
+ break;
+ return result;
+ }
+
+ /// <summary>
+ /// Verifies if all the elements of the specified collection are contained into the current collection.
+ /// </summary>
+ /// <param name="collection">The collection used to extract the elements that will be verified.</param>
+ /// <returns>Returns true if all the elements are contained in the collection. Otherwise returns false.</returns>
+ public virtual bool ContainsAll(CollectionSupport collection)
+ {
+ return this.ContainsAll((System.Collections.ICollection) collection);
+ }
+
+ /// <summary>
+ /// Returns a new list containing a portion of the current list between a specified range.
+ /// </summary>
+ /// <param name="startIndex">The start index of the range.</param>
+ /// <param name="endIndex">The end index of the range.</param>
+ /// <returns>A ListCollectionSupport instance containing the specified elements.</returns>
+ public virtual ListCollectionSupport SubList(int startIndex, int endIndex)
+ {
+ int index = 0;
+ System.Collections.IEnumerator tempEnumerator = this.GetEnumerator();
+ ListCollectionSupport result = new ListCollectionSupport();
+ for(index = startIndex; index < endIndex; index++)
+ result.Add(this[index]);
+ return (ListCollectionSupport)result;
+ }
+
+ /// <summary>
+ /// Obtains an array containing all the elements of the collection.
+ /// </summary>
+ /// <param name="objects">The array into which the elements of the collection will be stored.</param>
+ /// <returns>The array containing all the elements of the collection.</returns>
+ public virtual System.Object[] ToArray(System.Object[] objects)
+ {
+ if (objects.Length < this.Count)
+ objects = new System.Object[this.Count];
+ int index = 0;
+ System.Collections.IEnumerator tempEnumerator = this.GetEnumerator();
+ while (tempEnumerator.MoveNext())
+ objects[index++] = tempEnumerator.Current;
+ return objects;
+ }
+
+ /// <summary>
+ /// Returns an iterator of the collection starting at the specified position.
+ /// </summary>
+ /// <param name="index">The position to set the iterator.</param>
+ /// <returns>An IEnumerator at the specified position.</returns>
+ public virtual System.Collections.IEnumerator ListIterator(int index)
+ {
+ if ((index < 0) || (index > this.Count)) throw new System.IndexOutOfRangeException();
+ System.Collections.IEnumerator tempEnumerator= this.GetEnumerator();
+ if (index > 0)
+ {
+ int i=0;
+ while ((tempEnumerator.MoveNext()) && (i < index - 1))
+ i++;
+ }
+ return tempEnumerator;
+ }
+
+ /// <summary>
+ /// Gets the last value from a list.
+ /// </summary>
+ /// <returns>Returns the last element of the list.</returns>
+ public virtual System.Object GetLast()
+ {
+ if (this.Count == 0) throw new System.ArgumentOutOfRangeException();
+ else
+ {
+ return this[this.Count - 1];
+ }
+ }
+
+ /// <summary>
+ /// Return whether this list is empty.
+ /// </summary>
+ /// <returns>True if the list is empty, false if it isn't.</returns>
+ public virtual bool IsEmpty()
+ {
+ return (this.Count == 0);
+ }
+
+ /// <summary>
+ /// Replaces the element at the specified position in this list with the specified element.
+ /// </summary>
+ /// <param name="index">Index of element to replace.</param>
+ /// <param name="element">Element to be stored at the specified position.</param>
+ /// <returns>The element previously at the specified position.</returns>
+ public virtual System.Object Set(int index, System.Object element)
+ {
+ System.Object result = this[index];
+ this[index] = element;
+ return result;
+ }
+
+ /// <summary>
+ /// Returns the element at the specified position in the list.
+ /// </summary>
+ /// <param name="index">Index of element to return.</param>
+ /// <param name="element">Element to be stored at the specified position.</param>
+ /// <returns>The element at the specified position in the list.</returns>
+ public virtual System.Object Get(int index)
+ {
+ return this[index];
+ }
+ }
+
+ /*******************************/
+ /// <summary>
+ /// This class manages array operations.
+ /// </summary>
+ public class ArraysSupport
+ {
+ /// <summary>
+ /// Compares the entire members of one array whith the other one.
+ /// </summary>
+ /// <param name="array1">The array to be compared.</param>
+ /// <param name="array2">The array to be compared with.</param>
+ /// <returns>True if both arrays are equals otherwise it returns false.</returns>
+ /// <remarks>Two arrays are equal if they contains the same elements in the same order.</remarks>
+ public static bool IsArrayEqual(System.Array array1, System.Array array2)
+ {
+ if (array1.Length != array2.Length)
+ return false;
+ for (int i = 0; i < array1.Length; i++)
+ if (!(array1.GetValue(i).Equals(array2.GetValue(i))))
+ return false;
+ return true;
+ }
+
+ /// <summary>
+ /// Fills the array with an specific value from an specific index to an specific index.
+ /// </summary>
+ /// <param name="array">The array to be filled.</param>
+ /// <param name="fromindex">The first index to be filled.</param>
+ /// <param name="toindex">The last index to be filled.</param>
+ /// <param name="val">The value to fill the array with.</param>
+ public static void FillArray(System.Array array, System.Int32 fromindex,System.Int32 toindex, System.Object val)
+ {
+ System.Object Temp_Object = val;
+ System.Type elementtype = array.GetType().GetElementType();
+ if (elementtype != val.GetType())
+ Temp_Object = System.Convert.ChangeType(val, elementtype);
+ if (array.Length == 0)
+ throw (new System.NullReferenceException());
+ if (fromindex > toindex)
+ throw (new System.ArgumentException());
+ if ((fromindex < 0) || ((System.Array)array).Length < toindex)
+ throw (new System.IndexOutOfRangeException());
+ for (int index = (fromindex > 0) ? fromindex-- : fromindex; index < toindex; index++)
+ array.SetValue(Temp_Object, index);
+ }
+
+ /// <summary>
+ /// Fills the array with an specific value.
+ /// </summary>
+ /// <param name="array">The array to be filled.</param>
+ /// <param name="val">The value to fill the array with.</param>
+ public static void FillArray(System.Array array, System.Object val)
+ {
+ FillArray(array, 0, array.Length, val);
+ }
+ }
+
+
+ /*******************************/
+ /// <summary>
+ /// This class manages a set of elements.
+ /// </summary>
+ public class SetSupport : System.Collections.ArrayList
+ {
+ /// <summary>
+ /// Creates a new set.
+ /// </summary>
+ public SetSupport(): base()
+ {
+ }
+
+ /// <summary>
+ /// Creates a new set initialized with System.Collections.ICollection object
+ /// </summary>
+ /// <param name="collection">System.Collections.ICollection object to initialize the set object</param>
+ public SetSupport(System.Collections.ICollection collection): base(collection)
+ {
+ }
+
+ /// <summary>
+ /// Creates a new set initialized with a specific capacity.
+ /// </summary>
+ /// <param name="capacity">value to set the capacity of the set object</param>
+ public SetSupport(int capacity): base(capacity)
+ {
+ }
+
+ /// <summary>
+ /// Adds an element to the set.
+ /// </summary>
+ /// <param name="objectToAdd">The object to be added.</param>
+ /// <returns>True if the object was added, false otherwise.</returns>
+ public new virtual bool Add(object objectToAdd)
+ {
+ if (this.Contains(objectToAdd))
+ return false;
+ else
+ {
+ base.Add(objectToAdd);
+ return true;
+ }
+ }
+
+ /// <summary>
+ /// Adds all the elements contained in the specified collection.
+ /// </summary>
+ /// <param name="collection">The collection used to extract the elements that will be added.</param>
+ /// <returns>Returns true if all the elements were successfuly added. Otherwise returns false.</returns>
+ public virtual bool AddAll(System.Collections.ICollection collection)
+ {
+ bool result = false;
+ if (collection!=null)
+ {
+ System.Collections.IEnumerator tempEnumerator = new System.Collections.ArrayList(collection).GetEnumerator();
+ while (tempEnumerator.MoveNext())
+ {
+ if (tempEnumerator.Current != null)
+ result = this.Add(tempEnumerator.Current);
+ }
+ }
+ return result;
+ }
+
+ /// <summary>
+ /// Adds all the elements contained in the specified support class collection.
+ /// </summary>
+ /// <param name="collection">The collection used to extract the elements that will be added.</param>
+ /// <returns>Returns true if all the elements were successfuly added. Otherwise returns false.</returns>
+ public virtual bool AddAll(CollectionSupport collection)
+ {
+ return this.AddAll((System.Collections.ICollection)collection);
+ }
+
+ /// <summary>
+ /// Verifies that all the elements of the specified collection are contained into the current collection.
+ /// </summary>
+ /// <param name="collection">The collection used to extract the elements that will be verified.</param>
+ /// <returns>True if the collection contains all the given elements.</returns>
+ public virtual bool ContainsAll(System.Collections.ICollection collection)
+ {
+ bool result = false;
+ System.Collections.IEnumerator tempEnumerator = collection.GetEnumerator();
+ while (tempEnumerator.MoveNext())
+ if (!(result = this.Contains(tempEnumerator.Current)))
+ break;
+ return result;
+ }
+
+ /// <summary>
+ /// Verifies if all the elements of the specified collection are contained into the current collection.
+ /// </summary>
+ /// <param name="collection">The collection used to extract the elements that will be verified.</param>
+ /// <returns>Returns true if all the elements are contained in the collection. Otherwise returns false.</returns>
+ public virtual bool ContainsAll(CollectionSupport collection)
+ {
+ return this.ContainsAll((System.Collections.ICollection) collection);
+ }
+
+ /// <summary>
+ /// Verifies if the collection is empty.
+ /// </summary>
+ /// <returns>True if the collection is empty, false otherwise.</returns>
+ public virtual bool IsEmpty()
+ {
+ return (this.Count == 0);
+ }
+
+ /// <summary>
+ /// Removes an element from the set.
+ /// </summary>
+ /// <param name="elementToRemove">The element to be removed.</param>
+ /// <returns>True if the element was removed.</returns>
+ public new virtual bool Remove(object elementToRemove)
+ {
+ bool result = false;
+ if (this.Contains(elementToRemove))
+ result = true;
+ base.Remove(elementToRemove);
+ return result;
+ }
+
+ /// <summary>
+ /// Removes all the elements contained in the specified collection.
+ /// </summary>
+ /// <param name="collection">The collection used to extract the elements that will be removed.</param>
+ /// <returns>True if all the elements were successfuly removed, false otherwise.</returns>
+ public virtual bool RemoveAll(System.Collections.ICollection collection)
+ {
+ bool result = false;
+ System.Collections.IEnumerator tempEnumerator = collection.GetEnumerator();
+ while (tempEnumerator.MoveNext())
+ {
+ if ((result == false) && (this.Contains(tempEnumerator.Current)))
+ result = true;
+ this.Remove(tempEnumerator.Current);
+ }
+ return result;
+ }
+
+ /// <summary>
+ /// Removes all the elements contained into the specified collection.
+ /// </summary>
+ /// <param name="collection">The collection used to extract the elements that will be removed.</param>
+ /// <returns>Returns true if all the elements were successfuly removed. Otherwise returns false.</returns>
+ public virtual bool RemoveAll(CollectionSupport collection)
+ {
+ return this.RemoveAll((System.Collections.ICollection) collection);
+ }
+
+ /// <summary>
+ /// Removes all the elements that aren't contained in the specified collection.
+ /// </summary>
+ /// <param name="collection">The collection used to verify the elements that will be retained.</param>
+ /// <returns>True if all the elements were successfully removed, false otherwise.</returns>
+ public virtual bool RetainAll(System.Collections.ICollection collection)
+ {
+ bool result = false;
+ System.Collections.IEnumerator tempEnumerator = collection.GetEnumerator();
+ SetSupport tempSet = (SetSupport)collection;
+ while (tempEnumerator.MoveNext())
+ if (!tempSet.Contains(tempEnumerator.Current))
+ {
+ result = this.Remove(tempEnumerator.Current);
+ tempEnumerator = this.GetEnumerator();
+ }
+ return result;
+ }
+
+ /// <summary>
+ /// Removes all the elements that aren't contained into the specified collection.
+ /// </summary>
+ /// <param name="collection">The collection used to verify the elements that will be retained.</param>
+ /// <returns>Returns true if all the elements were successfully removed. Otherwise returns false.</returns>
+ public virtual bool RetainAll(CollectionSupport collection)
+ {
+ return this.RetainAll((System.Collections.ICollection) collection);
+ }
+
+ /// <summary>
+ /// Obtains an array containing all the elements of the collection.
+ /// </summary>
+ /// <returns>The array containing all the elements of the collection.</returns>
+ public new virtual object[] ToArray()
+ {
+ int index = 0;
+ object[] tempObject= new object[this.Count];
+ System.Collections.IEnumerator tempEnumerator = this.GetEnumerator();
+ while (tempEnumerator.MoveNext())
+ tempObject[index++] = tempEnumerator.Current;
+ return tempObject;
+ }
+
+ /// <summary>
+ /// Obtains an array containing all the elements in the collection.
+ /// </summary>
+ /// <param name="objects">The array into which the elements of the collection will be stored.</param>
+ /// <returns>The array containing all the elements of the collection.</returns>
+ public virtual object[] ToArray(object[] objects)
+ {
+ int index = 0;
+ System.Collections.IEnumerator tempEnumerator = this.GetEnumerator();
+ while (tempEnumerator.MoveNext())
+ objects[index++] = tempEnumerator.Current;
+ return objects;
+ }
+ }
+ /*******************************/
+ /// <summary>
+ /// This class manages different operation with collections.
+ /// </summary>
+ public class AbstractSetSupport : SetSupport
+ {
+ /// <summary>
+ /// The constructor with no parameters to create an abstract set.
+ /// </summary>
+ public AbstractSetSupport()
+ {
+ }
+ }
+
+
+ /*******************************/
+ /// <summary>
+ /// Removes the element with the specified key from a Hashtable instance.
+ /// </summary>
+ /// <param name="hashtable">The Hashtable instance</param>
+ /// <param name="key">The key of the element to remove</param>
+ /// <returns>The element removed</returns>
+ public static System.Object HashtableRemove(System.Collections.Hashtable hashtable, System.Object key)
+ {
+ System.Object element = hashtable[key];
+ hashtable.Remove(key);
+ return element;
+ }
+
+ /*******************************/
+ /// <summary>
+ /// Sets the size of the ArrayList. If the new size is greater than the current capacity, then new null items are added to the end of the ArrayList. If the new size is lower than the current size, then all elements after the new size are discarded
+ /// </summary>
+ /// <param name="arrayList">The ArrayList to be changed</param>
+ /// <param name="newSize">The new ArrayList size</param>
+ public static void SetSize(System.Collections.ArrayList arrayList, int newSize)
+ {
+ if (newSize < 0) throw new System.ArgumentException();
+ else
+ {
+ if (newSize < arrayList.Count)
+ arrayList.RemoveRange(newSize,(arrayList.Count-newSize));
+ else
+ while(newSize > arrayList.Count)
+ arrayList.Add(null);
+ }
+ }
+
+ /*******************************/
+ /// <summary>
+ /// Adds an element to the top end of a Stack instance.
+ /// </summary>
+ /// <param name="stack">The Stack instance</param>
+ /// <param name="element">The element to add</param>
+ /// <returns>The element added</returns>
+ public static System.Object StackPush(System.Collections.Stack stack, System.Object element)
+ {
+ stack.Push(element);
+ return element;
+ }
+
+ /*******************************/
+ /// <summary>
+ /// Copies an array of chars obtained from a String into a specified array of chars
+ /// </summary>
+ /// <param name="sourceString">The String to get the chars from</param>
+ /// <param name="sourceStart">Position of the String to start getting the chars</param>
+ /// <param name="sourceEnd">Position of the String to end getting the chars</param>
+ /// <param name="destinationArray">Array to return the chars</param>
+ /// <param name="destinationStart">Position of the destination array of chars to start storing the chars</param>
+ /// <returns>An array of chars</returns>
+ public static void GetCharsFromString(string sourceString, int sourceStart, int sourceEnd, ref char[] destinationArray, int destinationStart)
+ {
+ int sourceCounter;
+ int destinationCounter;
+ sourceCounter = sourceStart;
+ destinationCounter = destinationStart;
+ while (sourceCounter < sourceEnd)
+ {
+ destinationArray[destinationCounter] = (char) sourceString[sourceCounter];
+ sourceCounter++;
+ destinationCounter++;
+ }
+ }
+
+ /*******************************/
+ /// <summary>
+ /// Creates an output file stream to write to the file with the specified name.
+ /// </summary>
+ /// <param name="FileName">Name of the file to write.</param>
+ /// <param name="Append">True in order to write to the end of the file, false otherwise.</param>
+ /// <returns>New instance of FileStream with the proper file mode.</returns>
+ public static System.IO.FileStream GetFileStream(string FileName, bool Append)
+ {
+ if (Append)
+ return new System.IO.FileStream(FileName, System.IO.FileMode.Append);
+ else
+ return new System.IO.FileStream(FileName, System.IO.FileMode.Create);
+ }
+
+
+ /*******************************/
+ /// <summary>
+ /// Converts an array of sbytes to an array of chars
+ /// </summary>
+ /// <param name="sByteArray">The array of sbytes to convert</param>
+ /// <returns>The new array of chars</returns>
+ [CLSCompliantAttribute(false)]
+ public static char[] ToCharArray(sbyte[] sByteArray)
+ {
+ char[] charArray = new char[sByteArray.Length];
+ sByteArray.CopyTo(charArray, 0);
+ return charArray;
+ }
+
+ /// <summary>
+ /// Converts an array of bytes to an array of chars
+ /// </summary>
+ /// <param name="byteArray">The array of bytes to convert</param>
+ /// <returns>The new array of chars</returns>
+ public static char[] ToCharArray(byte[] byteArray)
+ {
+ char[] charArray = new char[byteArray.Length];
+ byteArray.CopyTo(charArray, 0);
+ return charArray;
+ }
+
+ /*******************************/
+ /// <summary>
+ /// Encapsulates the functionality of message digest algorithms such as SHA-1 or MD5.
+ /// </summary>
+ public class MessageDigestSupport
+ {
+ private System.Security.Cryptography.HashAlgorithm algorithm;
+ private byte[] data;
+ private int position;
+ private string algorithmName;
+
+ /// <summary>
+ /// The HashAlgorithm instance that provide the cryptographic hash algorithm
+ /// </summary>
+ public System.Security.Cryptography.HashAlgorithm Algorithm
+ {
+ get
+ {
+ return this.algorithm;
+ }
+ set
+ {
+ this.algorithm = value;
+ }
+ }
+
+ /// <summary>
+ /// The digest data
+ /// </summary>
+ public byte[] Data
+ {
+ get
+ {
+ return this.data;
+ }
+ set
+ {
+ this.data = value;
+ }
+ }
+
+ /// <summary>
+ /// The name of the cryptographic hash algorithm used in the instance
+ /// </summary>
+ public string AlgorithmName
+ {
+ get
+ {
+ return this.algorithmName;
+ }
+ }
+
+ /// <summary>
+ /// Creates a message digest using the specified name to set Algorithm property.
+ /// </summary>
+ /// <param name="algorithm">The name of the algorithm to use</param>
+ public MessageDigestSupport(System.String algorithm)
+ {
+ if (algorithm.Equals("SHA-1"))
+ {
+ this.algorithmName = "SHA";
+ }
+ else
+ {
+ this.algorithmName = algorithm;
+ }
+ this.Algorithm = (System.Security.Cryptography.HashAlgorithm) System.Security.Cryptography.CryptoConfig.CreateFromName(this.algorithmName);
+ this.position = 0;
+ }
+
+ /// <summary>
+ /// Computes the hash value for the internal data digest.
+ /// </summary>
+ /// <returns>The array of signed bytes with the resulting hash value</returns>
+ [CLSCompliantAttribute(false)]
+ public sbyte[] DigestData()
+ {
+ sbyte[] result = ToSByteArray(this.Algorithm.ComputeHash(this.data));
+ this.Reset();
+ return result;
+ }
+
+ /// <summary>
+ /// Performs and update on the digest with the specified array and then completes the digest
+ /// computation.
+ /// </summary>
+ /// <param name="newData">The array of bytes for final update to the digest</param>
+ /// <returns>An array of signed bytes with the resulting hash value</returns>
+ [CLSCompliantAttribute(false)]
+ public sbyte[] DigestData(byte[] newData)
+ {
+ this.Update(newData);
+ return this.DigestData();
+ }
+
+ /// <summary>
+ /// Updates the digest data with the specified array of bytes by making an append
+ /// operation in the internal array of data.
+ /// </summary>
+ /// <param name="newData">The array of bytes for the update operation</param>
+ public void Update(byte[] newData)
+ {
+ if (position == 0)
+ {
+ this.Data = newData;
+ this.position = this.Data.Length - 1;
+ }
+ else
+ {
+ byte[] oldData = this.Data;
+ this.Data = new byte[newData.Length + position + 1];
+ oldData.CopyTo(this.Data, 0);
+ newData.CopyTo(this.Data, oldData.Length);
+
+ this.position = this.Data.Length - 1;
+ }
+ }
+
+ /// <summary>
+ /// Updates the digest data with the input byte by calling the method Update with an array.
+ /// </summary>
+ /// <param name="newData">The input byte for the update</param>
+ public void Update(byte newData)
+ {
+ byte[] newDataArray = new byte[1];
+ newDataArray[0] = newData;
+ this.Update(newDataArray);
+ }
+
+ /// <summary>
+ /// Updates the specified count of bytes with the input array of bytes starting at the
+ /// input offset.
+ /// </summary>
+ /// <param name="newData">The array of bytes for the update operation</param>
+ /// <param name="offset">The initial position to start from in the array of bytes</param>
+ /// <param name="count">The number of bytes fot the update</param>
+ public void Update(byte[] newData, int offset, int count)
+ {
+ byte[] newDataArray = new byte[count];
+ System.Array.Copy(newData, offset, newDataArray, 0, count);
+ this.Update(newDataArray);
+ }
+
+ /// <summary>
+ /// Resets the digest data to the initial state.
+ /// </summary>
+ public void Reset()
+ {
+ this.data = null;
+ this.position = 0;
+ }
+
+ /// <summary>
+ /// Returns a string representation of the Message Digest
+ /// </summary>
+ /// <returns>A string representation of the object</returns>
+ public override string ToString()
+ {
+ return this.Algorithm.ToString();
+ }
+
+ /// <summary>
+ /// Generates a new instance of the MessageDigestSupport class using the specified algorithm
+ /// </summary>
+ /// <param name="algorithm">The name of the algorithm to use</param>
+ /// <returns>A new instance of the MessageDigestSupport class</returns>
+ public static MessageDigestSupport GetInstance(System.String algorithm)
+ {
+ return new MessageDigestSupport(algorithm);
+ }
+
+ /// <summary>
+ /// Compares two arrays of signed bytes evaluating equivalence in digest data
+ /// </summary>
+ /// <param name="firstDigest">An array of signed bytes for comparison</param>
+ /// <param name="secondDigest">An array of signed bytes for comparison</param>
+ /// <returns>True if the input digest arrays are equal</returns>
+ [CLSCompliantAttribute(false)]
+ public static bool EquivalentDigest(System.SByte[] firstDigest, System.SByte[] secondDigest)
+ {
+ bool result = false;
+ if (firstDigest.Length == secondDigest.Length)
+ {
+ int index = 0;
+ result = true;
+ while(result && index < firstDigest.Length)
+ {
+ result = firstDigest[index] == secondDigest[index];
+ index++;
+ }
+ }
+
+ return result;
+ }
+ }
+
+ /*******************************/
+ /// <summary>
+ /// This class uses a cryptographic Random Number Generator to provide support for
+ /// strong pseudo-random number generation.
+ /// </summary>
+ public class SecureRandomSupport
+ {
+ private System.Security.Cryptography.RNGCryptoServiceProvider generator;
+
+ /// <summary>
+ /// Initializes a new instance of the random number generator.
+ /// </summary>
+ public SecureRandomSupport()
+ {
+ this.generator = new System.Security.Cryptography.RNGCryptoServiceProvider();
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the random number generator with the given seed.
+ /// </summary>
+ /// <param name="seed">The initial seed for the generator</param>
+ public SecureRandomSupport(byte[] seed)
+ {
+ this.generator = new System.Security.Cryptography.RNGCryptoServiceProvider(seed);
+ }
+
+ /// <summary>
+ /// Returns an array of bytes with a sequence of cryptographically strong random values
+ /// </summary>
+ /// <param name="randomnumbersarray">The array of bytes to fill</param>
+ [CLSCompliantAttribute(false)]
+ public sbyte[] NextBytes(byte[] randomnumbersarray)
+ {
+ this.generator.GetBytes(randomnumbersarray);
+ return ToSByteArray(randomnumbersarray);
+ }
+
+ /// <summary>
+ /// Returns the given number of seed bytes generated for the first running of a new instance
+ /// of the random number generator
+ /// </summary>
+ /// <param name="numberOfBytes">Number of seed bytes to generate</param>
+ /// <returns>Seed bytes generated</returns>
+ public static byte[] GetSeed(int numberOfBytes)
+ {
+ System.Security.Cryptography.RNGCryptoServiceProvider generatedSeed = new System.Security.Cryptography.RNGCryptoServiceProvider();
+ byte[] seeds = new byte[numberOfBytes];
+ generatedSeed.GetBytes(seeds);
+ return seeds;
+ }
+
+ /// <summary>
+ /// Creates a new instance of the random number generator with the seed provided by the user
+ /// </summary>
+ /// <param name="newSeed">Seed to create a new random number generator</param>
+ public void SetSeed(byte[] newSeed)
+ {
+ this.generator = new System.Security.Cryptography.RNGCryptoServiceProvider(newSeed);
+ }
+
+ /// <summary>
+ /// Creates a new instance of the random number generator with the seed provided by the user
+ /// </summary>
+ /// <param name="newSeed">Seed to create a new random number generator</param>
+ public void SetSeed(long newSeed)
+ {
+ byte[] bytes = new byte[8];
+ for (int index= 7; index > 0 ; index--)
+ {
+ bytes[index] = (byte)(newSeed - (long)((newSeed >> 8) << 8));
+ newSeed = (long)(newSeed >> 8);
+ }
+ SetSeed(bytes);
+ }
+ }
+
+ /*******************************/
+ /// <summary>
+ /// Interface used by classes which must be single threaded.
+ /// </summary>
+ public interface SingleThreadModel
+ {
+ }
+
+
+ /*******************************/
+ /// <summary>
+ /// Creates an instance of a received Type.
+ /// </summary>
+ /// <param name="classType">The Type of the new class instance to return.</param>
+ /// <returns>An Object containing the new instance.</returns>
+ public static System.Object CreateNewInstance(System.Type classType)
+ {
+ System.Object instance = null;
+ System.Type[] constructor = new System.Type[]{};
+ System.Reflection.ConstructorInfo[] constructors = null;
+
+ constructors = classType.GetConstructors();
+
+ if (constructors.Length == 0)
+ throw new System.UnauthorizedAccessException();
+ else
+ {
+ for(int i = 0; i < constructors.Length; i++)
+ {
+ System.Reflection.ParameterInfo[] parameters = constructors[i].GetParameters();
+
+ if (parameters.Length == 0)
+ {
+ instance = classType.GetConstructor(constructor).Invoke(new System.Object[]{});
+ break;
+ }
+ else if (i == constructors.Length -1)
+ throw new System.MethodAccessException();
+ }
+ }
+ return instance;
+ }
+
+
+ /*******************************/
+ /// <summary>
+ /// Writes the exception stack trace to the received stream
+ /// </summary>
+ /// <param name="throwable">Exception to obtain information from</param>
+ /// <param name="stream">Output sream used to write to</param>
+ public static void WriteStackTrace(System.Exception throwable, System.IO.TextWriter stream)
+ {
+ stream.Write(throwable.StackTrace);
+ stream.Flush();
+ }
+
+ /*******************************/
+ /// <summary>
+ /// Determines whether two Collections instances are equals.
+ /// </summary>
+ /// <param name="source">The first Collections to compare. </param>
+ /// <param name="target">The second Collections to compare. </param>
+ /// <returns>Return true if the first collection is the same instance as the second collection, otherwise return false.</returns>
+ public static bool EqualsSupport(System.Collections.ICollection source, System.Collections.ICollection target )
+ {
+ System.Collections.IEnumerator sourceEnumerator = ReverseStack(source);
+ System.Collections.IEnumerator targetEnumerator = ReverseStack(target);
+
+ if (source.Count != target.Count)
+ return false;
+ while(sourceEnumerator.MoveNext() && targetEnumerator.MoveNext())
+ if (!sourceEnumerator.Current.Equals(targetEnumerator.Current))
+ return false;
+ return true;
+ }
+
+ /// <summary>
+ /// Determines if a Collection is equal to the Object.
+ /// </summary>
+ /// <param name="source">The first Collections to compare.</param>
+ /// <param name="target">The Object to compare.</param>
+ /// <returns>Return true if the first collection contains the same values of the second Object, otherwise return false.</returns>
+ public static bool EqualsSupport(System.Collections.ICollection source, System.Object target)
+ {
+ if((target.GetType())!= (typeof(System.Collections.ICollection)))
+ return false;
+ else
+ return EqualsSupport(source,(System.Collections.ICollection)target);
+ }
+
+ /// <summary>
+ /// Determines if a IDictionaryEnumerator is equal to the Object.
+ /// </summary>
+ /// <param name="source">The first IDictionaryEnumerator to compare.</param>
+ /// <param name="target">The second Object to compare.</param>
+ /// <returns>Return true if the first IDictionaryEnumerator contains the same values of the second Object, otherwise return false.</returns>
+ public static bool EqualsSupport(System.Collections.IDictionaryEnumerator source, System.Object target)
+ {
+ if((target.GetType())!= (typeof(System.Collections.IDictionaryEnumerator)))
+ return false;
+ else
+ return EqualsSupport(source,(System.Collections.IDictionaryEnumerator)target);
+ }
+
+ /// <summary>
+ /// Determines whether two IDictionaryEnumerator instances are equals.
+ /// </summary>
+ /// <param name="source">The first IDictionaryEnumerator to compare.</param>
+ /// <param name="target">The second IDictionaryEnumerator to compare.</param>
+ /// <returns>Return true if the first IDictionaryEnumerator contains the same values as the second IDictionaryEnumerator, otherwise return false.</returns>
+ public static bool EqualsSupport(System.Collections.IDictionaryEnumerator source, System.Collections.IDictionaryEnumerator target )
+ {
+ while(source.MoveNext() && target.MoveNext())
+ if (source.Key.Equals(target.Key))
+ if(source.Value.Equals(target.Value))
+ return true;
+ return false;
+ }
+
+ /// <summary>
+ /// Reverses the Stack Collection received.
+ /// </summary>
+ /// <param name="collection">The collection to reverse.</param>
+ /// <returns>The collection received in reverse order if it was a System.Collections.Stack type, otherwise it does
+ /// nothing to the collection.</returns>
+ public static System.Collections.IEnumerator ReverseStack(System.Collections.ICollection collection)
+ {
+ if((collection.GetType()) == (typeof(System.Collections.Stack)))
+ {
+ System.Collections.ArrayList collectionStack = new System.Collections.ArrayList(collection);
+ collectionStack.Reverse();
+ return collectionStack.GetEnumerator();
+ }
+ else
+ return collection.GetEnumerator();
+ }
+
+ }
diff --git a/mcs/class/Npgsql/ChangeLog b/mcs/class/Npgsql/ChangeLog
index 6630181432c..35a658bfa61 100644
--- a/mcs/class/Npgsql/ChangeLog
+++ b/mcs/class/Npgsql/ChangeLog
@@ -1,3 +1,42 @@
+2003-11-23 Pedro Martínez Juliá <yoros@wanadoo.es>
+
+ * Npgsql/HashAlgorithm.cs:
+ * Npgsql/NpgsqlClosedState.cs:
+ * Npgsql/NpgsqlCommand.cs:
+ * Npgsql/NpgsqlConnectedState.cs:
+ * Npgsql/NpgsqlConnection.cs:
+ * Npgsql/NpgsqlReadyState.cs:
+ * Npgsql/NpgsqlStartupState.cs:
+ * Npgsql/NpgsqlState.cs: Apply Disposable pattern, when using
+ ADO.NET we need to call Dispose after using any Component like
+ NpgsqlDataAdapter, NpgsqlConnection, etc... Change a few internal
+ methods to Properties.
+
+2003-11-22 Pedro Martínez Juliá <yoros@wanadoo.es>
+
+ * Npgsql/NpgsqlClosedState.cs:
+ * Npgsql/NpgsqlConnectedState.cs:
+ * Npgsql/NpgsqlConnection.cs:
+ * Npgsql/NpgsqlReadyState.cs:
+ * Npgsql/NpgsqlState.cs: Changes related to the last update of SSL
+ implementation. Now we're using TcpClient for the connection and
+ Stream for the abstraction layer to SslClientStream.
+
+2003-11-11 Pedro Martínez Juliá <yoros@wanadoo.es>
+
+ * Npgsql/NpgsqlDataReader.cs: GetSchemaTable has nothing to do with
+ CanRead because the schema can be readed with or without result
+ rows.
+
+2003-11-10 Pedro Martínez Juliá <yoros@wanadoo.es>
+
+ * Npgsql/NpgsqlDataAdapter.cs: Best use "if" instead of try-catch.
+
+2003-11-10 Pedro Martínez Juliá <yoros@wanadoo.es>
+
+ * Npgsql/NpgsqlDataAdapter.cs: Catch the exception thrown by MS.NET
+ when a mapping is not in the collection.
+
2003-11-09 Pedro Martínez Juliá <yoros@wanadoo.es>
* Npgsql/NpgsqlDataAdapter.cs: Do not assing the result of the
diff --git a/mcs/class/Npgsql/Makefile b/mcs/class/Npgsql/Makefile
index ace777ebc7d..4adaf701cbf 100755
--- a/mcs/class/Npgsql/Makefile
+++ b/mcs/class/Npgsql/Makefile
@@ -62,3 +62,5 @@ install: install-recursive install-local
uninstall: uninstall-recursive uninstall-local
+test:
+
diff --git a/mcs/class/Npgsql/Npgsql/HashAlgorithm.cs b/mcs/class/Npgsql/Npgsql/HashAlgorithm.cs
index 8fd97c81b81..84f6d4ac5d8 100755
--- a/mcs/class/Npgsql/Npgsql/HashAlgorithm.cs
+++ b/mcs/class/Npgsql/Npgsql/HashAlgorithm.cs
@@ -37,6 +37,13 @@ namespace Npgsql
{
disposed = false;
}
+
+ /// <summary>
+ /// Finalizer for HashAlgorithm
+ /// </summary>
+ ~HashAlgorithm () {
+ Dispose(false);
+ }
/// <summary>
/// Get whether or not the hash can transform multiple blocks at a time.
diff --git a/mcs/class/Npgsql/Npgsql/NpgsqlClosedState.cs b/mcs/class/Npgsql/Npgsql/NpgsqlClosedState.cs
index 62beebd572f..6ab6472c0ea 100755
--- a/mcs/class/Npgsql/Npgsql/NpgsqlClosedState.cs
+++ b/mcs/class/Npgsql/Npgsql/NpgsqlClosedState.cs
@@ -28,32 +28,26 @@ using System.Net.Sockets;
using System.Resources;
using Mono.Security.Protocol.Tls;
-namespace Npgsql
-{
+namespace Npgsql {
-
- internal sealed class NpgsqlClosedState : NpgsqlState
- {
+ internal sealed class NpgsqlClosedState : NpgsqlState {
+
private static NpgsqlClosedState _instance = null;
-
private static readonly String CLASSNAME = "NpgsqlClosedState";
-
+
private NpgsqlClosedState() : base() { }
- public static NpgsqlClosedState Instance
- {
- get
- {
- NpgsqlEventLog.LogPropertyGet(LogLevel.Debug, CLASSNAME, "Instance");
- if ( _instance == null )
- {
+ public static NpgsqlClosedState Instance {
+ get {
+ NpgsqlEventLog.LogPropertyGet(LogLevel.Debug, CLASSNAME, "Instance");
+ if (_instance == null) {
_instance = new NpgsqlClosedState();
}
- return _instance;
+ return _instance;
}
}
- public override void Open(NpgsqlConnection context)
- {
+
+ public override void Open(NpgsqlConnection context) {
NpgsqlEventLog.LogMethodEnter(LogLevel.Debug, CLASSNAME, "Open");
IPEndPoint serverEndPoint;
@@ -63,61 +57,41 @@ namespace Npgsql
// (i.e.:192.168.0.1), there may be a long delay trying
// resolve it when it is not necessary.
// So, try first connect as if it was a dotted ip address.
- try
- {
+ try {
IPAddress ipserver = IPAddress.Parse(context.ServerName);
serverEndPoint = new IPEndPoint(ipserver, Int32.Parse(context.ServerPort));
}
- catch(FormatException) // The exception isn't used.
- {
+ catch(FormatException) { // The exception isn't used.
// Server isn't in dotted decimal format. Just connect using DNS resolves.
IPHostEntry serverHostEntry = Dns.GetHostByName(context.ServerName);
serverEndPoint = new IPEndPoint(serverHostEntry.AddressList[0], Int32.Parse(context.ServerPort));
}
-
- // Connect to the server.
- TlsSessionSettings tlsSettings = new TlsSessionSettings();
-
- tlsSettings.Protocol = TlsProtocol.Tls1;
- tlsSettings.ServerName = context.ServerName;
- tlsSettings.ServerPort = Int32.Parse(context.ServerPort);
// Create a new TLS Session
- try
- {
- context.TlsSession = new TlsSession(tlsSettings);
- BufferedStream stream = new BufferedStream(context.TlsSession.NetworkStream);
- context.setNormalStream(context.TlsSession.NetworkStream);
- context.setStream(stream);
- BinaryReader receive = new BinaryReader(context.TlsSession.NetworkStream);
- BinaryWriter send = new BinaryWriter(context.TlsSession.NetworkStream);
-
- // If the PostgreSQL server has SSL connections enabled Open TLS context.TlsSession if (response == 'S') {
- if (context.SSL=="yes")
- {
- PGUtil.WriteInt32(context.TlsSession.NetworkStream, 8);
- PGUtil.WriteInt32(context.TlsSession.NetworkStream,80877103);
+ try {
+ TcpClient tcpc = new TcpClient(context.ServerName, Int32.Parse(context.ServerPort));
+ Stream stream = tcpc.GetStream();
+ // If the PostgreSQL server has SSL connections enabled Open SslClientStream if (response == 'S') {
+ if (context.SSL == "yes") {
+ PGUtil.WriteInt32(stream, 8);
+ PGUtil.WriteInt32(stream,80877103);
// Receive response
- Char response = (Char)context.TlsSession.NetworkStream.ReadByte();
-
- if (response == 'S')
- {
- context.TlsSession.Open(); // open TLS context.TlsSession
+ Char response = (Char)stream.ReadByte();
+ if (response == 'S') {
+ stream = new SslClientStream(tcpc.GetStream(), context.ServerName, true, Mono.Security.Protocol.Tls.SecurityProtocolType.Default);
}
-
- }
-
+ }
+ context.NormalStream = stream;
+ context.BufferedStream = new BufferedStream(stream);
}
- catch (TlsException e)
- {
+ catch (TlsException e) {
throw new NpgsqlException(e.ToString());
}
- // Create objects for read & write
- // context.TcpClient.Connect(serverEndPoint);
- NpgsqlEventLog.LogMsg(resman, "Log_ConnectedTo", LogLevel.Normal, serverEndPoint.Address, serverEndPoint.Port);
-
- ChangeState( context, NpgsqlConnectedState.Instance );
+ NpgsqlEventLog.LogMsg(resman, "Log_ConnectedTo", LogLevel.Normal, serverEndPoint.Address, serverEndPoint.Port);
+ ChangeState(context, NpgsqlConnectedState.Instance);
context.Startup();
}
+
}
+
}
diff --git a/mcs/class/Npgsql/Npgsql/NpgsqlCommand.cs b/mcs/class/Npgsql/Npgsql/NpgsqlCommand.cs
index 93ccd4c47e0..f4a62bbcb63 100755
--- a/mcs/class/Npgsql/Npgsql/NpgsqlCommand.cs
+++ b/mcs/class/Npgsql/Npgsql/NpgsqlCommand.cs
@@ -94,6 +94,13 @@ namespace Npgsql {
type = CommandType.Text;
this.Transaction = transaction;
}
+
+ /// <summary>
+ /// Finalizer for <see cref="Npgsql.NpgsqlCommand">NpgsqlCommand</see>.
+ /// </summary>
+ ~NpgsqlCommand () {
+ Dispose(false);
+ }
// Public properties.
/// <summary>
@@ -581,8 +588,14 @@ namespace Npgsql {
/// <summary>
/// Releases the resources used by the <see cref="Npgsql.NpgsqlCommand">NpgsqlCommand</see>.
/// </summary>
- public new void Dispose() {
- NpgsqlEventLog.LogMethodEnter(LogLevel.Debug, CLASSNAME, "Dispose");
+ protected override void Dispose (bool disposing) {
+ if (disposing) {
+ if (connection != null) {
+ connection.Dispose();
+ }
+ base.Dispose(disposing);
+ NpgsqlEventLog.LogMethodEnter(LogLevel.Debug, CLASSNAME, "Dispose");
+ }
}
///<summary>
@@ -736,8 +749,10 @@ namespace Npgsql {
for (i = 0; i < parameters.Count; i++) {
//result = result.Replace(":" + parameterName, parameters[i].Value.ToString());
parameterName = parameters[i].ParameterName;
- //textCommand = textCommand.Replace(':' + parameterName, "$" + (i+1));
- textCommand = ReplaceParameterValue(textCommand, parameterName, "$" + (i+1));
+ // The space in front of '$' fixes a parsing problem in 7.3 server
+ // which gives errors of operator when finding the caracters '=$' in
+ // prepare text
+ textCommand = ReplaceParameterValue(textCommand, parameterName, " $" + (i+1));
}
diff --git a/mcs/class/Npgsql/Npgsql/NpgsqlConnectedState.cs b/mcs/class/Npgsql/Npgsql/NpgsqlConnectedState.cs
index c48a6c5acfe..05dc371958f 100755
--- a/mcs/class/Npgsql/Npgsql/NpgsqlConnectedState.cs
+++ b/mcs/class/Npgsql/Npgsql/NpgsqlConnectedState.cs
@@ -24,7 +24,6 @@
using System;
using System.IO;
-using Mono.Security.Protocol.Tls;
namespace Npgsql
@@ -62,7 +61,7 @@ namespace Npgsql
"",
"");
- startupPacket.WriteToStream( context.getStream(), context.Encoding );
+ startupPacket.WriteToStream( context.BufferedStream, context.Encoding );
ProcessBackendResponses( context );
}
else if (context.BackendProtocolVersion == ProtocolVersion.Version2)
@@ -77,7 +76,7 @@ namespace Npgsql
"",
"");
- startupPacket.WriteToStream( new BufferedStream(context.TlsSession.NetworkStream), context.Encoding );
+ startupPacket.WriteToStream( new BufferedStream(context.NormalStream), context.Encoding );
ProcessBackendResponses( context );
diff --git a/mcs/class/Npgsql/Npgsql/NpgsqlConnection.cs b/mcs/class/Npgsql/Npgsql/NpgsqlConnection.cs
index 9516b011d38..b8fba3b2298 100755
--- a/mcs/class/Npgsql/Npgsql/NpgsqlConnection.cs
+++ b/mcs/class/Npgsql/Npgsql/NpgsqlConnection.cs
@@ -34,7 +34,6 @@ using System.Collections;
using System.Collections.Specialized;
using NpgsqlTypes;
using Npgsql.Design;
-using Mono.Security.Protocol.Tls;
namespace Npgsql {
@@ -69,14 +68,14 @@ namespace Npgsql {
// as I didn't want to add another interface for internal access
// --brar
// In the connection string
- internal readonly Char CONN_DELIM = ';'; // Delimeter
- internal readonly Char CONN_ASSIGN = '=';
+ internal readonly Char CONN_DELIM = ';'; // Delimeter
+ internal readonly Char CONN_ASSIGN = '=';
internal readonly String CONN_SERVER = "SERVER";
internal readonly String CONN_USERID = "USER ID";
- internal readonly String CONN_PASSWORD = "PASSWORD";
- internal readonly String CONN_DATABASE = "DATABASE";
- internal readonly String CONN_PORT = "PORT";
- internal readonly String SSL_ENABLED = "SSL";
+ internal readonly String CONN_PASSWORD = "PASSWORD";
+ internal readonly String CONN_DATABASE = "DATABASE";
+ internal readonly String CONN_PORT = "PORT";
+ internal readonly String SSL_ENABLED = "SSL";
// Postgres default port
internal readonly String PG_PORT = "5432";
@@ -96,9 +95,8 @@ namespace Npgsql {
// Logging related values
private readonly String CLASSNAME = "NpgsqlConnection";
- private TlsSession session;
- private TlsNetworkStream secstream;
- private BufferedStream stream;
+ private Stream stream;
+ private BufferedStream bstream;
private Encoding connection_encoding;
@@ -144,6 +142,13 @@ namespace Npgsql {
}
/// <summary>
+ /// Finalizer for NpgsqlConnection
+ /// </summary>
+ ~NpgsqlConnection () {
+ Dispose(false);
+ }
+
+ /// <summary>
/// Gets or sets the string used to open a SQL Server database.
/// </summary>
/// <value>The connection string that includes the server name,
@@ -438,8 +443,8 @@ namespace Npgsql {
}
finally {
// Even if an exception occurs, let object in a consistent state.
- if (TlsSession != null)
- TlsSession.Close();
+ if (stream != null)
+ stream.Close();
connection_state = ConnectionState.Closed;
}
}
@@ -535,33 +540,34 @@ namespace Npgsql {
/// This method is required to set all the version dependent features flags.
/// SupportsPrepare means the server can use prepared query plans (7.3+)
/// </summary>
- private void ProcessServerVersion() {
+ private void ProcessServerVersion () {
NpgsqlEventLog.LogMethodEnter(LogLevel.Debug, CLASSNAME, "ProcessServerVersion");
-
-
- if (BackendProtocolVersion == ProtocolVersion.Version2)
+
+ if (BackendProtocolVersion == ProtocolVersion.Version2) {
SupportsPrepare = (_serverVersion.IndexOf("PostgreSQL 7.3") != -1);
- else
- // 3.0+ version is set by ParameterStatus message.
- SupportsPrepare = (_serverVersion.IndexOf("7.4") != -1);
-
- }
-
- internal BufferedStream getStream()
- {
- return stream;
- }
- internal void setStream(BufferedStream bs)
- {
- stream=bs;
+ }
+ else {
+ // 3.0+ version is set by ParameterStatus message.
+ SupportsPrepare = (_serverVersion.IndexOf("7.4") != -1);
+ }
}
- internal TlsNetworkStream getNormalStream()
- {
- return secstream;
+
+ internal BufferedStream BufferedStream {
+ get {
+ return bstream;
+ }
+ set {
+ bstream = value;
+ }
}
- internal void setNormalStream(TlsNetworkStream tns)
- {
- secstream=tns;
+
+ internal Stream NormalStream {
+ get {
+ return stream;
+ }
+ set {
+ stream = value;
+ }
}
/*
@@ -575,41 +581,38 @@ namespace Npgsql {
*/
// State
- internal void Query( NpgsqlCommand queryCommand ) {
- CurrentState.Query( this, queryCommand );
+ internal void Query (NpgsqlCommand queryCommand) {
+ CurrentState.Query(this, queryCommand );
}
- internal void Authenticate(string password) {
- CurrentState.Authenticate( this, password );
+
+ internal void Authenticate (string password) {
+ CurrentState.Authenticate(this, password );
}
- internal void Startup() {
- CurrentState.Startup( this );
+
+ internal void Startup () {
+ CurrentState.Startup(this);
}
-
- internal void Parse(NpgsqlParse parse)
- {
- CurrentState.Parse(this, parse);
+
+ internal void Parse (NpgsqlParse parse) {
+ CurrentState.Parse(this, parse);
}
-
- internal void Flush()
- {
- CurrentState.Flush(this);
+
+ internal void Flush () {
+ CurrentState.Flush(this);
}
-
- internal void Sync()
- {
- CurrentState.Sync(this);
+
+ internal void Sync () {
+ CurrentState.Sync(this);
}
-
- internal void Bind(NpgsqlBind bind)
- {
- CurrentState.Bind(this, bind);
+
+ internal void Bind (NpgsqlBind bind) {
+ CurrentState.Bind(this, bind);
}
-
- internal void Execute(NpgsqlExecute execute)
- {
- CurrentState.Execute(this, execute);
+
+ internal void Execute (NpgsqlExecute execute) {
+ CurrentState.Execute(this, execute);
}
-
+
internal NpgsqlState CurrentState {
get {
return state;
@@ -618,7 +621,6 @@ namespace Npgsql {
state = value;
}
}
- // Internal properties
internal NpgsqlBackEndKeyData BackEndKeyData {
get {
@@ -634,52 +636,37 @@ namespace Npgsql {
return (String)connection_string_values[CONN_SERVER];
}
}
+
internal String ServerPort {
get {
return (String)connection_string_values[CONN_PORT];
}
}
+
internal String DatabaseName {
get {
return (String)connection_string_values[CONN_DATABASE];
}
}
+
internal String UserName {
get {
return (String)connection_string_values[CONN_USERID];
}
}
+
internal String ServerPassword {
get {
return (String)connection_string_values[CONN_PASSWORD];
}
}
- internal String SSL
- {
- get
- {
- return (String)connection_string_values[SSL_ENABLED];
- }
-
- }
- internal TlsSession TlsSession {
+ internal String SSL {
get {
- return session;
- }
- set {
- session = value;
- }
- }
-
- internal TlsNetworkStream SecuredStream
- {
- get
- {
- return SecuredStream;
+ return (String)connection_string_values[SSL_ENABLED];
}
}
-
+
internal Encoding Encoding {
get {
return connection_encoding;
@@ -696,7 +683,6 @@ namespace Npgsql {
get {
return _inTransaction;
}
-
set {
_inTransaction = value;
}
@@ -706,7 +692,6 @@ namespace Npgsql {
get {
return _supportsPrepare;
}
-
set {
_supportsPrepare = value;
}
@@ -716,8 +701,7 @@ namespace Npgsql {
get {
return _serverVersion;
}
- set
- {
+ set {
_serverVersion = value;
}
}
@@ -726,23 +710,21 @@ namespace Npgsql {
get {
return _oidToNameMapping;
}
-
set {
_oidToNameMapping = value;
}
}
- internal Int32 BackendProtocolVersion
- {
- get
- {
- return _backendProtocolVersion;
- }
-
- set
- {
- _backendProtocolVersion = value;
- }
+
+ internal Int32 BackendProtocolVersion {
+ get {
+ return _backendProtocolVersion;
+ }
+ set {
+ _backendProtocolVersion = value;
+ }
}
+
}
+
}
diff --git a/mcs/class/Npgsql/Npgsql/NpgsqlDataAdapter.cs b/mcs/class/Npgsql/Npgsql/NpgsqlDataAdapter.cs
index 38cefbc6cbd..2e671fd23c6 100755
--- a/mcs/class/Npgsql/Npgsql/NpgsqlDataAdapter.cs
+++ b/mcs/class/Npgsql/Npgsql/NpgsqlDataAdapter.cs
@@ -112,8 +112,12 @@ namespace Npgsql
foreach (IDataParameter parameter in value.Command.Parameters) {
string dsColumnName = parameter.SourceColumn;
- DataColumnMapping mapping = columnMappings [parameter.SourceColumn];
- if (mapping != null) dsColumnName = mapping.DataSetColumn;
+ if (columnMappings.Contains(parameter.SourceColumn)) {
+ DataColumnMapping mapping = columnMappings[parameter.SourceColumn];
+ if (mapping != null) {
+ dsColumnName = mapping.DataSetColumn;
+ }
+ }
DataRowVersion rowVersion = DataRowVersion.Default;
if (value.StatementType == StatementType.Update) rowVersion = parameter.SourceVersion;
if (value.StatementType == StatementType.Delete) rowVersion = DataRowVersion.Original;
diff --git a/mcs/class/Npgsql/Npgsql/NpgsqlDataReader.cs b/mcs/class/Npgsql/Npgsql/NpgsqlDataReader.cs
index 05faed2f08c..5b631828214 100755
--- a/mcs/class/Npgsql/Npgsql/NpgsqlDataReader.cs
+++ b/mcs/class/Npgsql/Npgsql/NpgsqlDataReader.cs
@@ -163,10 +163,6 @@ namespace Npgsql
public DataTable GetSchemaTable()
{
NpgsqlEventLog.LogMethodEnter(LogLevel.Debug, CLASSNAME, "GetSchemaTable");
- //throw new NotImplementedException();
-
- if (!CanRead())
- return null; //[FIXME] Should we return null or throw an exception??
if(_currentResultsetSchema == null)
_currentResultsetSchema = GetResultsetSchema();
diff --git a/mcs/class/Npgsql/Npgsql/NpgsqlReadyState.cs b/mcs/class/Npgsql/Npgsql/NpgsqlReadyState.cs
index 3833c7e8146..7dff28dba4e 100755
--- a/mcs/class/Npgsql/Npgsql/NpgsqlReadyState.cs
+++ b/mcs/class/Npgsql/Npgsql/NpgsqlReadyState.cs
@@ -27,7 +27,6 @@ using System.IO;
using System.Net;
using System.Net.Sockets;
using System.Resources;
-using Mono.Security.Protocol.Tls;
namespace Npgsql
{
@@ -72,7 +71,7 @@ namespace Npgsql
// Send the query request to backend.
NpgsqlQuery query = new NpgsqlQuery(commandText, context.BackendProtocolVersion);
- BufferedStream stream = context.getStream();
+ BufferedStream stream = context.BufferedStream;
query.WriteToStream(stream, context.Encoding);
stream.Flush();
@@ -83,7 +82,7 @@ namespace Npgsql
public override void Parse(NpgsqlConnection context, NpgsqlParse parse)
{
NpgsqlEventLog.LogMethodEnter(LogLevel.Debug, CLASSNAME, "Parse");
- BufferedStream stream = context.getStream();
+ BufferedStream stream = context.BufferedStream;
parse.WriteToStream(stream, context.Encoding);
stream.Flush();
@@ -94,21 +93,21 @@ namespace Npgsql
public override void Sync(NpgsqlConnection context)
{
NpgsqlEventLog.LogMethodEnter(LogLevel.Debug, CLASSNAME, "Sync");
- _syncMessage.WriteToStream(context.getNormalStream(), context.Encoding);
+ _syncMessage.WriteToStream(context.NormalStream, context.Encoding);
ProcessBackendResponses(context);
}
public override void Flush(NpgsqlConnection context)
{
NpgsqlEventLog.LogMethodEnter(LogLevel.Debug, CLASSNAME, "Flush");
- _flushMessage.WriteToStream(context.getNormalStream(), context.Encoding);
+ _flushMessage.WriteToStream(context.NormalStream, context.Encoding);
ProcessBackendResponses(context);
}
public override void Bind(NpgsqlConnection context, NpgsqlBind bind)
{
NpgsqlEventLog.LogMethodEnter(LogLevel.Debug, CLASSNAME, "Bind");
- BufferedStream stream = context.getStream();
+ BufferedStream stream = context.BufferedStream;
bind.WriteToStream(stream, context.Encoding);
stream.Flush();
@@ -119,8 +118,8 @@ namespace Npgsql
NpgsqlEventLog.LogMethodEnter(LogLevel.Debug, CLASSNAME, "Execute");
NpgsqlDescribe describe = new NpgsqlDescribe('P', execute.PortalName);
- describe.WriteToStream(context.getNormalStream(), context.Encoding);
- execute.WriteToStream(context.getNormalStream(), context.Encoding);
+ describe.WriteToStream(context.NormalStream, context.Encoding);
+ execute.WriteToStream(context.NormalStream, context.Encoding);
Sync(context);
}
diff --git a/mcs/class/Npgsql/Npgsql/NpgsqlStartupState.cs b/mcs/class/Npgsql/Npgsql/NpgsqlStartupState.cs
index 6c6cc4a3dc3..1a4d7109e9e 100755
--- a/mcs/class/Npgsql/Npgsql/NpgsqlStartupState.cs
+++ b/mcs/class/Npgsql/Npgsql/NpgsqlStartupState.cs
@@ -54,7 +54,7 @@ namespace Npgsql
{
NpgsqlEventLog.LogMethodEnter(LogLevel.Debug, CLASSNAME, "Authenticate");
NpgsqlPasswordPacket pwpck = new NpgsqlPasswordPacket(password, context.BackendProtocolVersion);
- BufferedStream stream = context.getStream();
+ BufferedStream stream = context.BufferedStream;
pwpck.WriteToStream(stream, context.Encoding);
stream.Flush();
diff --git a/mcs/class/Npgsql/Npgsql/NpgsqlState.cs b/mcs/class/Npgsql/Npgsql/NpgsqlState.cs
index 78e636fc54c..29cbe93c0cc 100755
--- a/mcs/class/Npgsql/Npgsql/NpgsqlState.cs
+++ b/mcs/class/Npgsql/Npgsql/NpgsqlState.cs
@@ -32,7 +32,6 @@ using System.Net.Sockets;
using System.Collections;
using System.Text;
using System.Resources;
-using Mono.Security.Protocol.Tls;
namespace Npgsql
{
@@ -68,7 +67,7 @@ namespace Npgsql
NpgsqlEventLog.LogMethodEnter(LogLevel.Debug, CLASSNAME, "Close");
if ( context.State == ConnectionState.Open )
{
- TlsNetworkStream stream = context.getNormalStream();
+ Stream stream = context.NormalStream;
if ( stream.CanWrite )
{
stream.WriteByte((Byte)'X');
@@ -102,7 +101,7 @@ namespace Npgsql
{
NpgsqlEventLog.LogMethodEnter(LogLevel.Debug, CLASSNAME, "ProcessBackendResponses");
- BufferedStream stream = context.getStream();
+ BufferedStream stream = context.BufferedStream;
Int32 authType;
Boolean readyForQuery = false;
diff --git a/mcs/class/Npgsql/NpgsqlTypes/.cvsignore b/mcs/class/Npgsql/NpgsqlTypes/.cvsignore
new file mode 100644
index 00000000000..270df4cda87
--- /dev/null
+++ b/mcs/class/Npgsql/NpgsqlTypes/.cvsignore
@@ -0,0 +1 @@
+*.resources
diff --git a/mcs/class/PEAPI/ChangeLog b/mcs/class/PEAPI/ChangeLog
index f68aa25a86f..178102708f8 100644
--- a/mcs/class/PEAPI/ChangeLog
+++ b/mcs/class/PEAPI/ChangeLog
@@ -1,3 +1,12 @@
+2003-11-18 Jackson Harper <jackson@ximian.com>
+
+ * PEAPI.cs: If the data length for a methods seh section is
+ greater then 255 use fat format headers.
+
+2003-11-17 Jackson Harper <jackson@ximian.com>
+
+ * PEAPI.cs: Allow strings to be loaded as bytearrays.
+
2003-10-19 Jackson Harper <jackson@ximian.com>
* PEAPI.cs: Use bytes not bits for constant sizes.
diff --git a/mcs/class/PEAPI/PEAPI.cs b/mcs/class/PEAPI/PEAPI.cs
index 9b02c20ce8d..8626abc8af1 100644
--- a/mcs/class/PEAPI/PEAPI.cs
+++ b/mcs/class/PEAPI/PEAPI.cs
@@ -1000,8 +1000,15 @@ namespace PEAPI
/// <param name="str">the string value</param>
public void ldstr(string str) {
AddToBuffer(new StringInstr(0x72,str));
- }
-
+ }
+
+ /// <summary>
+ /// Add the load string instruction
+ /// </summary>
+ public void ldstr (byte[] str) {
+ AddToBuffer (new StringInstr (0x72, str));
+ }
+
/// <summary>
/// Add the calli instruction
/// </summary>
@@ -1338,6 +1345,13 @@ namespace PEAPI
numExceptClauses += (uint)tryBlock.NumHandlers();
if (tryBlock.isFat()) fatExceptionFormat = true;
}
+
+ uint data_size = ExHeaderSize + numExceptClauses *
+ (fatExceptionFormat ? FatExClauseSize : SmlExClauseSize);
+
+ if (data_size > 256)
+ fatExceptionFormat = true;
+
// Console.WriteLine("numexceptclauses = " + numExceptClauses);
if (fatExceptionFormat) {
// Console.WriteLine("Fat exception format");
@@ -3843,16 +3857,25 @@ if (rsrc != null)
}
internal class StringInstr : Instr {
- string val;
+ string val;
+ byte[] bval;
uint strIndex;
internal StringInstr(int inst, string str) : base(inst) {
val = str;
size += 4;
- }
-
- internal sealed override bool Check(MetaData md) {
- strIndex = md.AddToUSHeap(val);
+ }
+
+ internal StringInstr (int inst, byte[] str) : base (inst) {
+ bval = str;
+ size += 4;
+ }
+
+ internal sealed override bool Check(MetaData md) {
+ if (val != null)
+ strIndex = md.AddToUSHeap(val);
+ else
+ strIndex = md.AddToUSHeap (bval);
return false;
}
@@ -4405,8 +4428,13 @@ if (rsrc != null)
internal uint AddToUSHeap(string str) {
if (str == null) return 0;
return us.Add(str,true);
- }
-
+ }
+
+ internal uint AddToUSHeap(byte[] str) {
+ if (str == null) return 0;
+ return us.Add (str, true);
+ }
+
internal uint AddToStringsHeap(string str) {
if ((str == null) || (str.CompareTo("") == 0)) return 0;
return strings.Add(str,false);
@@ -4865,8 +4893,9 @@ if (rsrc != null)
bool largeIx = false;
uint sizeOfHeader;
char[] name;
- Hashtable htable = new Hashtable();
-
+ Hashtable htable = new Hashtable();
+ Hashtable btable = new Hashtable ();
+
internal MetaDataStream(char[] name, bool addInitByte) : base(new MemoryStream()) {
if (addInitByte) { Write((byte)0); size = 1; }
this.name = name;
@@ -4924,8 +4953,24 @@ if (rsrc != null)
index = (uint)val;
}
return index;
- }
-
+ }
+ internal uint Add (byte[] str, bool prependSize) {
+ Object val = btable [str];
+ uint index = 0;
+ if (val == null) {
+ index = size;
+ btable [str] = index;
+ if (prependSize) CompressNum ((uint) str.Length+1);
+ Write (str);
+ Write ((byte) 0);
+ size = (uint) Seek (0, SeekOrigin.Current);
+ } else {
+ index = (uint) val;
+ }
+ return index;
+ }
+
+
internal uint Add(Guid guid) {
Write(guid.ToByteArray());
size =(uint)Seek(0,SeekOrigin.Current);
diff --git a/mcs/class/README b/mcs/class/README
index fa83397fdf4..bf82cecee7f 100644
--- a/mcs/class/README
+++ b/mcs/class/README
@@ -6,24 +6,12 @@ divide the code based on the namespace they implement.
In addition, each assembly directory contains a Test directory that holds the
NUnit tests for that assembly.
-The nant build file for an assembly creates two versions of the dll for that
-assembly. One version is a "full" dll. The full dll contains (almost) all
-of the classes, regardless of how complete the classes are. The name of this
-dll is the normal name you would expect, like "corlib.dll" or "System.dll".
-These full dll's are created in the /mcs/class/lib directory.
-
-The other dll which is built is a "restricted" dll. The restricted dll
-omits incomplete classes that would prevent the NUnit testrunner from actually
-running the tests. These restricted dll's are created in the Test directory
-of their respective assembly and named with a "_res" suffix. So, for example,
-the NUnit-testable dll for corlib is /mcs/class/corlib/Test/corlib_res.dll.
-
-The final dll which is built is the one which houses the actual NUnit tests.
-This dll is built from all of the classes in the Test directory and below, and
-is named with a "_test" suffix. So, for example, the NUnit tests for corlib
-are in /mcs/class/corlib/Test/corlib_test.dll. This dll is also linked with
-the restricted dll found in the same directory.
+We use a new build system which is described by various README files
+in mcs/build
+The build process typically builds an assembly, but in some cases it
+also builds special versions of the assemblies intended to be used for
+testing.
* Missing implementation bits
@@ -37,11 +25,14 @@ the restricted dll found in the same directory.
throw new NotImplementedException ();
}
-* Supporting both .NET 1.1 and .NET 1.0 builds
+* Supporting .NET 1.2, .NET 1.1 and .NET 1.0 builds
- Use #ifdef NET_1_1 for code that should only be included for
- a .NET 1.1 build, and NET_1_0 for code that should only be included
- for a 1.0 build.
+ The defines NET_1_1 and NET_1_2 are used to include
+ features. When NET_1_2 is defined, it also implies that the
+ NET_1_1 is defined.
+
+ To have code which is only available in an old version, use ONLY_1_0,
+ ONLY_1_1
* Tagging buggy code
@@ -280,4 +271,4 @@ class X : Y {
}
}
}
- \ No newline at end of file
+
diff --git a/mcs/class/System.Data.Db2Client/Makefile b/mcs/class/System.Data.Db2Client/Makefile
new file mode 100644
index 00000000000..cd5ab5ce220
--- /dev/null
+++ b/mcs/class/System.Data.Db2Client/Makefile
@@ -0,0 +1,23 @@
+thisdir = class/System.Data.Db2Client
+SUBDIRS =
+include ../../build/rules.make
+
+# I have *no idea* why I need to do this.
+
+ifeq ($(PROFILE),atomic)
+system = System.dll
+else
+system = $(topdir)/class/lib/System.dll
+endif
+
+LIBRARY = System.Data.Db2Client.dll
+LIB_MCS_FLAGS = \
+ /unsafe /nowarn:649 /nowarn:169 /nowarn:219 /nowarn:168 \
+ /r:$(corlib) \
+ /r:$(system) \
+ /r:System.Xml.dll \
+ /r:System.Data.dll
+
+TEST_MCS_FLAGS = $(LIB_MCS_FLAGS)
+
+include ../../build/library.make
diff --git a/mcs/class/System.Data.Db2Client/System.Data.Db2Client.dll.sources b/mcs/class/System.Data.Db2Client/System.Data.Db2Client.dll.sources
new file mode 100644
index 00000000000..587e6c2ee6c
--- /dev/null
+++ b/mcs/class/System.Data.Db2Client/System.Data.Db2Client.dll.sources
@@ -0,0 +1,19 @@
+System.Data.Db2Client/AssemblyInfo.cs
+System.Data.Db2Client/BLOBWrapperCollection.cs
+System.Data.Db2Client/BLOBWrapper.cs
+System.Data.Db2Client/Db2ClientUtils.cs
+System.Data.Db2Client/Db2CLIWrapper.cs
+System.Data.Db2Client/Db2Command.cs
+System.Data.Db2Client/Db2Connection.cs
+System.Data.Db2Client/Db2Constants.cs
+System.Data.Db2Client/Db2DataAdapter.cs
+System.Data.Db2Client/Db2DataReader.cs
+System.Data.Db2Client/Db2Exception.cs
+System.Data.Db2Client/Db2LOBLocator.cs
+System.Data.Db2Client/Db2ParameterCollection.cs
+System.Data.Db2Client/Db2Parameter.cs
+System.Data.Db2Client/Db2RowUpdatedEventArgs.cs
+System.Data.Db2Client/Db2RowUpdatedEventHandler.cs
+System.Data.Db2Client/Db2RowUpdatingEventArgs.cs
+System.Data.Db2Client/Db2RowUpdatingEventHandler.cs
+System.Data.Db2Client/Db2Transaction.cs
diff --git a/mcs/class/System.Data.Db2Client/System.Data.Db2Client/AssemblyInfo.cs b/mcs/class/System.Data.Db2Client/System.Data.Db2Client/AssemblyInfo.cs
new file mode 100644
index 00000000000..52914e77b91
--- /dev/null
+++ b/mcs/class/System.Data.Db2Client/System.Data.Db2Client/AssemblyInfo.cs
@@ -0,0 +1,19 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+
+[assembly: AssemblyTitle("")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("")]
+[assembly: AssemblyCopyright("")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+
+[assembly: AssemblyVersion("1.0.*")]
+
+
+[assembly: AssemblyDelaySign(false)]
+[assembly: AssemblyKeyFile("")]
+[assembly: AssemblyKeyName("")]
diff --git a/mcs/class/System.Data.Db2Client/System.Data.Db2Client/BLOBWrapper.cs b/mcs/class/System.Data.Db2Client/System.Data.Db2Client/BLOBWrapper.cs
new file mode 100644
index 00000000000..436831d7289
--- /dev/null
+++ b/mcs/class/System.Data.Db2Client/System.Data.Db2Client/BLOBWrapper.cs
@@ -0,0 +1,25 @@
+using System;
+
+namespace System.Data.Db2Client{
+ public class BLOBWrapper{
+ byte[] _blob;
+ int _length;
+
+
+ public byte[] ByteArray{
+ set{
+ _length = ((byte[])value).Length;
+ _blob = new byte[_length];
+ System.Array.Copy((byte[])value, 0, _blob, 0, _length);
+ }
+ }
+
+ public long GetBytes(long fieldOffset, byte[] buffer, int bufferOffset, int length){
+ long start = fieldOffset * length;
+ if (_length <= start){return 0;}
+ int actuallength = (int)(((length+start)>_length)?(_length - start):length);
+ System.Array.Copy(_blob, (int)start, buffer, (int)bufferOffset, actuallength);
+ return (long)(((length+start)>_length)?(_length - start):length);
+ }
+ }
+}
diff --git a/mcs/class/System.Data.Db2Client/System.Data.Db2Client/BLOBWrapperCollection.cs b/mcs/class/System.Data.Db2Client/System.Data.Db2Client/BLOBWrapperCollection.cs
new file mode 100644
index 00000000000..b777e0a37c1
--- /dev/null
+++ b/mcs/class/System.Data.Db2Client/System.Data.Db2Client/BLOBWrapperCollection.cs
@@ -0,0 +1,25 @@
+using System;
+using System.Collections;
+
+namespace System.Data.Db2Client{
+ public class BLOBWrapperCollection{
+
+ private Hashtable _blobs = new Hashtable();
+
+ public void Add(int ColumnNumber){
+ BLOBWrapper _blob = new BLOBWrapper();
+ _blobs.Add(ColumnNumber, _blob);
+ }
+
+ public BLOBWrapper this[int index]{
+ get{
+ return (BLOBWrapper)_blobs[index];
+ }
+ }
+
+ public long GetBytes(int col, long fieldOffset, byte[] buffer, int bufferOffset, int length){
+ BLOBWrapper _blob = (BLOBWrapper)_blobs[col];
+ return _blob.GetBytes(fieldOffset, buffer, bufferOffset, length);
+ }
+ }
+}
diff --git a/mcs/class/System.Data.Db2Client/System.Data.Db2Client/Db2CLIWrapper.cs b/mcs/class/System.Data.Db2Client/System.Data.Db2Client/Db2CLIWrapper.cs
new file mode 100644
index 00000000000..5a38be313e4
--- /dev/null
+++ b/mcs/class/System.Data.Db2Client/System.Data.Db2Client/Db2CLIWrapper.cs
@@ -0,0 +1,92 @@
+using System;
+using System.Data;
+using System.Runtime.InteropServices;
+using System.Text;
+
+namespace System.Data.Db2Client
+{
+ /// <summary>
+ /// db2Prototypes class is a wrapper for the db2.lib, IBM's Call Level Interface to Db2
+ /// </summary>
+ internal class Db2CLIWrapper
+ {
+ private const string libname = "db2cli";
+
+ [DllImport(libname, EntryPoint = "SQLAllocHandle")]
+ internal static extern short SQLAllocHandle(short handleType, IntPtr inputHandle, ref IntPtr outputHandle);
+ [DllImport(libname, EntryPoint = "SQLConnect")]
+ internal static extern short SQLConnect(IntPtr sqlHdbc, string serverName, short serverNameLength, string userName, short userNameLength, string authentication, short authenticationLength);
+ [DllImport(libname, EntryPoint = "SQLColAttribute")]
+ internal static extern short SQLColAttribute(IntPtr StatementHandle, short ColumnNumber, short FieldIdentifier, IntPtr CharacterAttribute, short BufferLength, ref short StringLength, ref int NumericAttribute);
+ [DllImport(libname, EntryPoint = "SQLGetData")]
+ internal static extern short SQLGetData(IntPtr StatementHandle, short ColumnNumber, short TargetType, IntPtr TargetPtr, IntPtr BufferLength, ref IntPtr StrLen_or_Ind);
+ [DllImport(libname, EntryPoint="SQLMoreResults")]
+ internal static extern short SQLMoreResults(IntPtr StatementHandle);
+
+ [DllImport(libname, EntryPoint = "SQLGetData")]
+ internal static extern short SQLGetData(IntPtr StatementHandle, short ColumnNumber, short TargetType, byte[] TargetPtr, IntPtr BufferLength, ref IntPtr StrLen_or_Ind);
+
+ [DllImport(libname, CharSet = CharSet.Auto, EntryPoint = "SQLDisconnect")]
+ internal static extern short SQLDisconnect(IntPtr sqlHdbc);
+ [DllImport(libname, EntryPoint = "SQLGetDiagRec")]
+ internal static extern short SQLGetDiagRec( short handleType, IntPtr handle, short recNum, [Out] StringBuilder sqlState, ref IntPtr nativeErrorPtr, [Out] StringBuilder errorMessage, short bufferLength, ref IntPtr shortTextLengthPtr);
+ [DllImport(libname, EntryPoint = "SQLSetConnectAttr")]
+ internal static extern short SQLSetConnectAttr(IntPtr sqlHdbc, long sqlAttr, [In] IntPtr sqlValuePtr, long sqlValueLength);
+ [DllImport(libname, EntryPoint = "SQLEndTran")]
+ internal static extern short SQLEndTran (short handleType, IntPtr handle, short fType);
+ [DllImport(libname, EntryPoint = "SQLCancel")]
+ internal static extern short SQLCancel(IntPtr handle);
+ [DllImport(libname, EntryPoint = "SQLNumResultCols")]
+ internal static extern short SQLNumResultCols(IntPtr handle, ref int numCols);
+ [DllImport(libname, EntryPoint = "SQLFetch")]
+ internal static extern short SQLFetch(IntPtr handle);
+ [DllImport(libname, EntryPoint = "SQLRowCount")]
+ internal static extern short SQLRowCount(IntPtr stmtHandle, ref int numRows);
+ [DllImport(libname, EntryPoint = "SQLExecute")]
+ internal static extern short SQLExecute(IntPtr handle);
+ [DllImport (libname, EntryPoint = "SQLExecDirect")]
+ internal static extern short SQLExecDirect(IntPtr stmtHandle, string stmt, int length);
+ [DllImport(libname, EntryPoint = "SQLDescribeCol")]
+ internal static extern short SQLDescribeCol(IntPtr stmtHandle, ushort colNum, StringBuilder colName, short colNameMaxLength, IntPtr colNameLength, ref IntPtr dataType, ref IntPtr colSizePtr, ref IntPtr scalePtr, ref IntPtr nullablePtr );
+ [DllImport(libname, EntryPoint = "SQLBindCol")]
+ internal static extern short SQLBindCol(IntPtr StatementHandle, short ColumnNumber, short TargetType, IntPtr TargetValue, IntPtr BufferLength, ref IntPtr StrLen_or_Ind);
+ [DllImport(libname, EntryPoint = "SQLDriverConnect")]
+ internal static extern short SQLDriverConnect(IntPtr hdbc, int centered, [In] string inConnectStr, [In] int inStrLength, [Out] StringBuilder outConnectStr, [Out] int outStrCapacity, [Out] IntPtr outStrLengthReturned, [In] int completion);
+ [DllImport(libname, EntryPoint = "SQLPrepare")]
+ internal static extern short SQLPrepare(IntPtr stmtHandle, string stmt, int length);
+ [DllImport(libname, EntryPoint = "SQLDescribeParam")]
+ internal static extern short SQLDescribeParam(IntPtr stmtHandle, short paramNumber,ref IntPtr dataType, ref IntPtr paramSize, ref IntPtr decimalDigits, ref IntPtr nullable);
+ [DllImport(libname, EntryPoint = "SQLNumParams")]
+ internal static extern short SQLNumParams(IntPtr stmtHandle, ref IntPtr numParams);
+ [DllImport(libname)]
+ internal static extern short SQLBindParameter(IntPtr stmtHandle, ushort paramNumber,
+ short dataType, short valueType, short paramType, uint colSize, short decDigits,
+ IntPtr dataBufferPtr, int dataBufferLength, IntPtr StrLen_or_IndPtr);
+
+ [DllImport(libname)]
+ internal static extern short SQLBindParameter(IntPtr stmtHandle, ushort paramNumber,
+ short dataType, short valueType, short paramType, uint colSize, short decDigits,
+ byte[] dataBufferPtr, int dataBufferLength, IntPtr StrLen_or_IndPtr);
+
+ [DllImport(libname, EntryPoint = "SQLBindParameter")]
+ internal static extern short SQLBindParameter(IntPtr stmtHandle, ushort paramNumber,
+ short dataType, short valueType, short paramType, uint colSize, short decDigits,
+ ref int dataBufferPtr, int dataBufferLength, int StrLen_or_IndPtr);
+
+ [DllImport(libname, EntryPoint = "SQLDescribeParam")]
+ internal static extern short SQLDescribeParam(IntPtr stmtHandle, short ParameterNumber, IntPtr DataTypePtr, IntPtr ParameterSizePtr, IntPtr DecimalDigitsPtr, IntPtr NullablePtr);
+
+ [DllImport(libname, EntryPoint = "SQLGetLength")]
+ internal static extern short SQLGetLength( IntPtr stmtHandle, short locatorCType, int Locator,
+ IntPtr stringLength, IntPtr indicatorValue);
+ [DllImport(libname, EntryPoint = "SQLGetPosition")]
+ internal static extern short SQLGetPosition(IntPtr stmtHandle, short locatorCType, int sourceLocator, int searchLocator,
+ string searchLiteral, int searchLiteralLength, uint fromPosition, IntPtr locatedAt, IntPtr indicatorValue);
+ [DllImport(libname, EntryPoint = "SQLGetPosition")]
+ internal static extern short SQLBindFileToCol (IntPtr stmtHandle, ushort colNum, string fileName, IntPtr fileNameLength,
+ IntPtr fileOptions, short maxFileNameLength, IntPtr stringLength, IntPtr indicatorValue);
+ [DllImport(libname, EntryPoint = "SQLGetPosition")]
+ internal static extern short SQLBindFileToParam (IntPtr stmtHandle, ushort targetType, short dataType, string fileName,
+ IntPtr fileNameLength, short maxFileNameLength, IntPtr indicatorValue);
+ }
+}
diff --git a/mcs/class/System.Data.Db2Client/System.Data.Db2Client/Db2ClientUtils.cs b/mcs/class/System.Data.Db2Client/System.Data.Db2Client/Db2ClientUtils.cs
new file mode 100644
index 00000000000..2c627d63da0
--- /dev/null
+++ b/mcs/class/System.Data.Db2Client/System.Data.Db2Client/Db2ClientUtils.cs
@@ -0,0 +1,29 @@
+using System;
+
+namespace System.Data.Db2Client
+{
+
+ public class Db2ClientUtils
+ {
+ public Db2ClientUtils()
+ {
+
+ }
+ #region Db2CheckReturn
+
+ public static int Db2CheckReturn(short sqlRet, short handleType, IntPtr handle, string message)
+ {
+ switch ((long)sqlRet)
+ {
+ case Db2Constants.SQL_ERROR:
+ if (handleType != 0)
+ throw new Db2Exception(handleType, handle, message);
+ else
+ throw new Db2Exception(message);
+ default:
+ return 0;
+ }
+ }
+ #endregion
+ }
+}
diff --git a/mcs/class/System.Data.Db2Client/System.Data.Db2Client/Db2Command.cs b/mcs/class/System.Data.Db2Client/System.Data.Db2Client/Db2Command.cs
new file mode 100644
index 00000000000..d855b19907a
--- /dev/null
+++ b/mcs/class/System.Data.Db2Client/System.Data.Db2Client/Db2Command.cs
@@ -0,0 +1,360 @@
+using System;
+using System.Data;
+using System.Runtime.InteropServices;
+
+
+namespace System.Data.Db2Client
+{
+
+ public class Db2Command : IDbCommand
+ {
+ #region Private data members
+
+
+ private string commandText;
+ private CommandType commandType = CommandType.Text;
+ private Db2Connection db2Conn;
+ private Db2Transaction db2Trans;
+ private int commandTimeout;
+ private bool prepared = false;
+ private IntPtr hwndStmt = IntPtr.Zero; //Our statement handle
+ private Db2ParameterCollection parameters = new Db2ParameterCollection();
+
+ #endregion
+
+ #region Constructors
+
+ public Db2Command()
+ {
+ hwndStmt = IntPtr.Zero;
+ }
+ public Db2Command(string commandStr)
+ {
+ commandText = commandStr;
+ hwndStmt = IntPtr.Zero;
+
+ }
+ public Db2Command(string commandStr, Db2Connection con) : this()
+ {
+ commandText = commandStr;
+ db2Conn = con;
+ AllocateStatement("Constructor 3");
+ }
+ public Db2Command (string commandStr, Db2Connection con, Db2Transaction trans)
+ {
+ commandText = commandStr;
+ db2Conn = con;
+ db2Trans = trans;
+ AllocateStatement("Constructor 4");
+ }
+ ///Db2 Specific constructors
+ ///
+ public Db2Command (IntPtr hwndSt)
+ {
+ hwndStmt = hwndSt;
+ }
+ public void Dispose()
+ {
+ }
+ #endregion
+ #region SelfDescribe property
+ ///
+ /// Property dictates whether or not any paramter markers will get their describe info
+ /// from the database, or if the user will supply the information
+ ///
+ bool selfDescribe = false;
+ public bool SelfDescribe
+ {
+ get
+ {
+ return selfDescribe;
+ }
+ set
+ {
+ selfDescribe = value;
+ }
+ }
+ #endregion
+ #region CommandText property
+ ///
+ ///The query; If it gets set, reset the prepared property
+ ///
+ public string CommandText
+ {
+ get
+ {
+ return commandText;
+ }
+ set
+ {
+ prepared = false;
+ commandText = value;
+ }
+ }
+ #endregion
+ #region CommandTimeout property
+ ///
+ /// The Timeout property states how long we wait for results to return
+ ///
+ public int CommandTimeout
+ {
+ get
+ {
+ return commandTimeout;
+ }
+ set
+ {
+ commandTimeout = value;
+ }
+ }
+ #endregion
+
+ #region CommandType property
+
+ public CommandType CommandType
+ {
+ get
+ {
+ return commandType;
+ }
+ set
+ {
+ commandType = value;
+ }
+ }
+ #endregion
+
+ #region Connection property
+ ///
+ /// The connection we'll be executing on.
+ ///
+ IDbConnection IDbCommand.Connection
+ {
+ get
+ {
+ return db2Conn;
+ }
+ set
+ {
+ db2Conn = (Db2Connection)value;
+ AllocateStatement("Connection property set");
+ }
+ }
+
+ public Db2Connection Connection
+ {
+ get
+ {
+ return db2Conn;
+ }
+ set
+ {
+ db2Conn = value;
+ AllocateStatement("Connection property set");
+ }
+ }
+ #endregion
+ #region Parameters property
+ ///
+ /// Parameter list, Not yet implemented
+ ///
+ public Db2ParameterCollection Parameters
+ {
+ get
+ {
+ return parameters;
+ }
+ }
+ IDataParameterCollection IDbCommand.Parameters
+ {
+ get
+ {
+ return parameters;
+ }
+ }
+ #endregion
+
+ #region Transaction property
+ ///
+ /// The transaction this command is associated with
+ ///
+ public IDbTransaction Transaction
+ {
+ get
+ {
+ return db2Trans;
+ }
+ set
+ {
+ db2Trans = (Db2Transaction)value;
+ }
+ }
+ #endregion
+
+ #region UpdatedRowSource property
+ ///
+ /// Need to see how this works with Db2...
+ ///
+ public UpdateRowSource UpdatedRowSource
+ {
+ get
+ {
+ throw new Db2Exception ("TBD");
+ }
+ set
+ {
+ throw new Db2Exception ("TBD");
+ }
+ }
+ #endregion
+
+ #region Statement Handle
+ ///
+ /// returns the Db2Client statement handle
+ ///
+ public IntPtr statementHandle
+ {
+ get
+ {
+ return hwndStmt;
+ }
+ }
+ #endregion
+
+ #region AllocateStatement function
+ ///
+ /// Allocate a statement handle, internal. Pass in the name of the caller for exception info.
+ /// I think I'll make the handle a property and add a constructor with the handle argument so that
+ /// statements can be executed on the same handle if need be, though you could accomplish the same by
+ /// just keeping the command object open.
+ ///
+ internal void AllocateStatement(string location)
+ {
+ short sqlRet;
+ sqlRet = Db2CLIWrapper.SQLAllocHandle(Db2Constants.SQL_HANDLE_STMT, db2Conn.DBHandle , ref hwndStmt);
+ if ((sqlRet != Db2Constants.SQL_SUCCESS) && (sqlRet != Db2Constants.SQL_SUCCESS_WITH_INFO))
+ throw new Db2Exception(Db2Constants.SQL_HANDLE_DBC, db2Conn.DBHandle, location +": Unable to allocate statement handle.");
+ parameters.HwndStmt = hwndStmt;
+ }
+ #endregion
+
+ #region Cancel
+ /// <summary>
+ /// Attempt to cancel an executing command
+ /// </summary>
+ public void Cancel()
+ {
+ Db2CLIWrapper.SQLCancel(hwndStmt);
+ }
+ #endregion
+
+ #region CreateParameter
+ ///
+ ///Returns a parameter
+ ///
+ public IDbDataParameter CreateParameter()
+ {
+ throw new Db2Exception("TBD");
+ }
+ #endregion
+
+ #region ExecuteNonQuery
+
+ public int ExecuteNonQuery()
+ {
+ if ((commandText == null) ||(commandText.Length == 0))
+ throw new Db2Exception("Command string is empty");
+
+ if(CommandType.StoredProcedure == commandType && !commandText.StartsWith("CALL "))
+ commandText = "CALL " + commandText;
+
+ Prepare();
+
+ short sqlRet;
+ if (prepared)
+ sqlRet = Db2CLIWrapper.SQLExecute(hwndStmt);
+ else
+ sqlRet = Db2CLIWrapper.SQLExecDirect(hwndStmt, commandText, commandText.Length);
+
+ int numRows = 0;
+ sqlRet = Db2CLIWrapper.SQLRowCount(hwndStmt, ref numRows); //How many rows affected. numRows will be -1 if we aren't dealing with an Insert, Delete or Update, or if the statement did not execute successfully
+
+ parameters.GetOutValues();
+ ///At this point, I think we need to save any results, but not return them
+ ///For now, we will go execute and return the number of rows affected
+ return numRows;
+ }
+ #endregion
+
+ #region ExecuteReader calls
+ ///
+ ///ExecuteReader
+ ///
+ IDataReader IDbCommand.ExecuteReader()
+ {
+ return ExecuteReader();
+ }
+
+ public Db2DataReader ExecuteReader()
+ {
+ Db2DataReader reader;
+
+
+ if (!prepared)
+ {
+ ExecuteNonQuery();
+ reader = new Db2DataReader(db2Conn, this);
+ }
+ else
+ reader = new Db2DataReader(db2Conn, this, true);
+
+ return reader;
+ }
+
+ public IDataReader ExecuteReader(CommandBehavior behavior)
+ {
+ //throw new Db2Exception("TBD");
+ return ExecuteReader();
+ }
+ #endregion
+
+ #region ExecuteScalar
+ ///
+ /// ExecuteScalar
+ ///
+ public object ExecuteScalar()
+ {
+ throw new Db2Exception("TBD");
+ }
+ #endregion
+
+ #region Prepare ()
+ ///
+ /// Prepare a statement against the database
+ ///
+ public void Prepare ()
+ {
+
+ short sqlRet = 0;
+
+ IntPtr numParams = IntPtr.Zero;
+ sqlRet = Db2CLIWrapper.SQLPrepare(hwndStmt, commandText, commandText.Length);
+ Db2ClientUtils.Db2CheckReturn(sqlRet, Db2Constants.SQL_HANDLE_STMT, hwndStmt, "SQLPrepare error.");
+ short i=1;
+ foreach ( Db2Parameter param in parameters)
+ {
+
+ if (selfDescribe)
+ {
+ sqlRet = param.Describe(this.hwndStmt, i);
+ Db2ClientUtils.Db2CheckReturn(sqlRet, Db2Constants.SQL_HANDLE_STMT, hwndStmt, "Error binding parameter in Db2Command: ");
+ }
+ sqlRet = param.Bind(this.hwndStmt, i);
+ Db2ClientUtils.Db2CheckReturn(sqlRet, Db2Constants.SQL_HANDLE_STMT, hwndStmt, "Error binding parameter in Db2Command: ");
+ i++;
+ }
+ prepared=true;
+ }
+ #endregion
+ }
+}
diff --git a/mcs/class/System.Data.Db2Client/System.Data.Db2Client/Db2Connection.cs b/mcs/class/System.Data.Db2Client/System.Data.Db2Client/Db2Connection.cs
new file mode 100644
index 00000000000..292489fea0a
--- /dev/null
+++ b/mcs/class/System.Data.Db2Client/System.Data.Db2Client/Db2Connection.cs
@@ -0,0 +1,335 @@
+using System;
+using System.Collections;
+using System.Collections.Specialized;
+using System.Data;
+using System.Runtime.InteropServices;
+using System.Text;
+
+namespace System.Data.Db2Client
+{
+
+
+ public class Db2Connection : IDbConnection
+ {
+ private WeakReference refTransaction;
+
+ private string connectionString = null;
+ private StringBuilder outConnectStr;
+ private string dbName = null;
+ private int connectionTimeout;
+
+ private IntPtr penvHandle=IntPtr.Zero;
+ private IntPtr dbHandle = IntPtr.Zero;
+
+ private bool disposed = false;
+
+ string serverName, userName, authentication, dsn;
+
+ public Db2Connection()
+ {
+ //
+ // TODO: Add constructor logic here
+ //
+ }
+ public Db2Connection(string conString)
+ {
+ SetConnectionString(conString);
+ }
+ #region ConnectionString property
+ ///
+ ///Accessor for the connectionString property
+ public string ConnectionString
+ {
+ get
+ {
+ return connectionString;
+ }
+ set
+ {
+ SetConnectionString(value);
+ }
+ }
+ #endregion
+
+
+ #region ConnectionTimeout property
+ public int ConnectionTimeout
+ {
+ get
+ {
+ return connectionTimeout;
+ }
+ set
+ {
+ connectionTimeout = value;
+ }
+ }
+ #endregion
+
+ #region Database property
+ public string Database
+ {
+ get
+ {
+ return dbName;
+ }
+ set
+ {
+ dbName = value;
+ }
+ }
+ #endregion
+
+ #region State property
+ /// <summary>
+ /// The Connection State property, open or closed.
+ /// NOTE: IBM's docs on SqlFreeHandle do not state what is done when a handle is freed
+ /// i.e. if the handle is set to SQL_NULL_HANDLE.
+ /// </summary>
+
+ unsafe public ConnectionState State
+ {
+ get
+ {
+ if ((long)dbHandle.ToPointer() == Db2Constants.SQL_NULL_HANDLE)
+ return ConnectionState.Closed;
+ else
+ return ConnectionState.Open;
+ }
+ }
+ #endregion
+
+ #region DBHandle
+ ///
+ /// Handle Returns an IntPtr of the dbm handle
+ ///
+ public IntPtr DBHandle
+ {
+ get
+ {
+ return dbHandle;
+ }
+ }
+ #endregion
+
+ #region BeginTransaction Method
+ /// <summary>
+ /// Opens a transaction against the database at the default isolation level, which will be
+ /// that which the packages were bound at, unless overriden in the connection string, and if nothing was specified at that point
+ /// then I believe the default level is Cursor Stability (don't quote me on that, I haven't
+ /// found the appropriate reference yet), ODBC equivalent is SQL_TXN_READ_COMMITTED
+ /// </summary>
+ /// <returns></returns>
+ IDbTransaction IDbConnection.BeginTransaction()
+ {
+ return BeginTransaction();
+ }
+
+ IDbTransaction IDbConnection.BeginTransaction(IsolationLevel isolationL)
+ {
+ return BeginTransaction(isolationL);
+ }
+
+ public Db2Transaction BeginTransaction()
+ {
+ CheckOldTransaction();
+
+ Db2Transaction tran = new Db2Transaction(this, IsolationLevel.ReadCommitted);
+ refTransaction = new WeakReference(tran);
+ return tran;
+ }
+
+ public Db2Transaction BeginTransaction(IsolationLevel isolationL)
+ {
+ CheckOldTransaction();
+
+ Db2Transaction tran = new Db2Transaction(this, isolationL);
+ refTransaction = new WeakReference(tran);
+ return tran;
+ }
+
+ private void CheckOldTransaction()
+ {
+ if((refTransaction != null) && (!refTransaction.IsAlive))
+ {
+ try
+ {
+ Db2CLIWrapper.SQLEndTran(Db2Constants.SQL_HANDLE_DBC, this.dbHandle, Db2Constants.SQL_ROLLBACK);
+ }
+ finally
+ {
+ refTransaction = null;
+ }
+ }
+
+ if ((refTransaction != null) && (refTransaction.IsAlive))
+ {
+ throw new Db2Exception("Cannot open another transaction");
+ }
+ }
+ #endregion
+
+ #region ChangeDatabase
+ public void ChangeDatabase(string newDBName)
+ {
+ short sqlRet;
+ this.Close();
+
+ sqlRet = Db2CLIWrapper.SQLAllocHandle(Db2Constants.SQL_HANDLE_DBC, penvHandle, ref dbHandle);
+ Db2ClientUtils.Db2CheckReturn(sqlRet, Db2Constants.SQL_HANDLE_ENV, penvHandle, "Unable to allocate database handle in Db2Connection.");
+
+ this.serverName = newDBName;
+ this.dbName = newDBName;
+ sqlRet = Db2CLIWrapper.SQLConnect(dbHandle,serverName, (short)serverName.Length, userName, (short)userName.Length, authentication, (short)authentication.Length);
+ Db2ClientUtils.Db2CheckReturn(sqlRet, Db2Constants.SQL_HANDLE_ENV, penvHandle, "Unable to connect to the database.");
+
+ }
+ #endregion
+
+ #region Close
+ ///Close, per MSDN documentation
+ ///
+ public void Close()
+ {
+ short sqlRet = 0;
+// Db2ClientUtils util = new Db2ClientUtils();
+
+ sqlRet = Db2CLIWrapper.SQLDisconnect(dbHandle);
+// util.Db2CheckReturn(sqlRet, Db2Constants.SQL_HANDLE_DBC, dbHandle, "Error in Connection->Close: ");
+ dbHandle = new IntPtr(Db2Constants.SQL_NULL_HANDLE);
+ }
+ #endregion
+
+ #region CreateCommand
+ /// <summary>
+ /// CreateCommand per MSDN
+ /// </summary>
+ /// <returns></returns>
+ IDbCommand IDbConnection.CreateCommand()
+ {
+ return CreateCommand();
+ }
+
+ public Db2Command CreateCommand()
+ {
+ CheckState();
+ return new Db2Command();
+ }
+ #endregion
+
+ #region Open
+ /// <summary>
+ /// Open, per MSDN
+ /// </summary>
+ public void Open()
+ {
+ outConnectStr = new StringBuilder(60); //Set some initial size, we know we're gettig a chunk of data back
+ IntPtr numOutCharsReturned = IntPtr.Zero;
+ short sqlRet=0;
+
+ if (this.State == ConnectionState.Open || this.State == ConnectionState.Connecting || this.State == ConnectionState.Executing || this.State == ConnectionState.Fetching)
+ {
+ throw new Db2Exception("Connection already open");
+ }
+
+ try
+ {
+ string[] parts = connectionString.Split(new char[]{';'});
+ foreach(string part in parts)
+ {
+ string[] pairs = part.Split(new char[]{'='});
+ switch(pairs[0])
+ {
+ case "database":
+ serverName = pairs[1];
+ break;
+ case "uid":
+ userName = pairs[1];
+ break;
+ case "pwd":
+ authentication = pairs[1];
+ break;
+ case "dsn":
+ dsn = pairs[1];
+ break;
+ default:
+ break;
+ }
+ }
+ }
+ catch(Exception)
+ {
+ throw new Db2Exception("Bad connection string");
+ }
+
+ try
+ {
+ sqlRet = Db2CLIWrapper.SQLAllocHandle(Db2Constants.SQL_HANDLE_ENV, IntPtr.Zero, ref penvHandle);
+ Db2ClientUtils.Db2CheckReturn(sqlRet, 0, IntPtr.Zero, "Unable to allocate Environment handle in Db2Connection.");
+
+ sqlRet = Db2CLIWrapper.SQLAllocHandle(Db2Constants.SQL_HANDLE_DBC, penvHandle, ref dbHandle);
+ Db2ClientUtils.Db2CheckReturn(sqlRet, Db2Constants.SQL_HANDLE_ENV, penvHandle, "Unable to allocate database handle in Db2Connection.");
+
+ if(dsn != null)
+ {
+ sqlRet = Db2CLIWrapper.SQLDriverConnect(dbHandle, 0, connectionString,
+ connectionString.Length, outConnectStr, 100, numOutCharsReturned,
+ Db2Constants.SQL_DRIVER_COMPLETE);
+ }
+ else
+ {
+ sqlRet = Db2CLIWrapper.SQLConnect(dbHandle,serverName, (short)serverName.Length, userName, (short)userName.Length, authentication, (short)authentication.Length);
+ Db2ClientUtils.Db2CheckReturn(sqlRet, Db2Constants.SQL_HANDLE_ENV, penvHandle, "Unable to connect to the database.");
+ }
+ }
+ catch (Db2Exception Db2E)
+ {
+ Console.WriteLine(Db2E.Message);
+ Dispose();
+ throw Db2E;
+ }
+ }
+ #endregion
+
+ #region Dispose
+ /// <summary>
+ /// Dispose
+ /// </summary>
+ public void Dispose()
+ {
+ if(!disposed)
+ {
+ this.Close();
+ disposed = true;
+ } else
+ return;
+ }
+
+ #endregion
+
+ private void CheckState()
+ {
+ if (ConnectionState.Closed == State)
+ throw new Db2Exception ("Connection is currently closed.");
+ }
+
+ void SetConnectionString (string connectionString)
+ {
+ this.connectionString = connectionString;
+ }
+
+ internal WeakReference WeakRefTransaction
+ {
+ get
+ {
+ return refTransaction;
+ }
+ set
+ {
+ refTransaction = value;
+ }
+ }
+
+ }
+}
+
diff --git a/mcs/class/System.Data.Db2Client/System.Data.Db2Client/Db2Constants.cs b/mcs/class/System.Data.Db2Client/System.Data.Db2Client/Db2Constants.cs
new file mode 100644
index 00000000000..ccdca156a7e
--- /dev/null
+++ b/mcs/class/System.Data.Db2Client/System.Data.Db2Client/Db2Constants.cs
@@ -0,0 +1,140 @@
+using System;
+
+namespace System.Data.Db2Client
+{
+ /// <summary>
+ /// Summary description for Db2Constants.
+ /// </summary>
+ public class Db2Constants
+ {
+ public Db2Constants()
+ {
+
+
+ }
+ public const short SQL_HANDLE_ENV = 1;
+ public const short SQL_HANDLE_DBC = 2;
+ public const short SQL_HANDLE_STMT = 3;
+ public const short SQL_HANDLE_DESC = 4;
+
+ /* RETCODE values */
+ public const short SQL_SUCCESS = 0;
+ public const short SQL_SUCCESS_WITH_INFO = 1;
+ public const short SQL_NEED_DATA = 99;
+ public const short SQL_NO_DATA = 100;
+ public const short SQL_STILL_EXECUTING = 2;
+ public const short SQL_ERROR = -1;
+ public const short SQL_INVALID_HANDLE = -2;
+
+ public const int SQL_NTS = -3;
+ public const long SQL_NULL_HANDLE = 0L;
+ public const short SQL_COMMIT = 0;
+ public const short SQL_ROLLBACK = 1;
+ public const short SQL_NO_DATA_FOUND = 100;
+
+ /* Isolation levels */
+ public const long SQL_TXN_READ_UNCOMMITTED = 0x00000001L;
+ public const long SQL_TXN_READ_COMMITTED = 0x00000002L;
+ public const long SQL_TXN_REPEATABLE_READ = 0x00000004L;
+ public const long SQL_TXN_SERIALIZABLE_READ = 0x00000008L;
+ public const long SQL_TXN_NOCOMMIT = 0x00000020L;
+
+ /* Connect options */
+ public const long SQL_TXN_ISOLATION = 108;
+ public const long SQL_AUTOCOMMIT = 102;
+
+ public const long SQL_AUTOCOMMIT_OFF = 0L;
+ public const long SQL_AUTOCOMMIT_ON = 1L;
+
+ /* Data Types */
+ public const int SQL_UNKNOWN_TYPE = 0;
+ public const int SQL_CHAR = 1;
+ public const int SQL_NUMERIC = 2;
+ public const int SQL_DECIMAL = 3;
+ public const int SQL_INTEGER = 4;
+ public const int SQL_SMALLINT = 5;
+ public const int SQL_FLOAT = 6;
+ public const int SQL_REAL = 7;
+ public const int SQL_DOUBLE = 8;
+ public const int SQL_DATETIME = 9;
+ public const int SQL_VARCHAR = 12;
+ public const int SQL_WCHAR = (-8);
+ public const int SQL_WVARCHAR = (-9);
+ public const int SQL_WLONGVARCHAR = (-10);
+ public const int SQL_TYPE_DATE = 91;
+ public const int SQL_TYPE_TIME = 92;
+ public const int SQL_TYPE_TIMESTAMP = 93;
+ public const int SQL_TYPE_BINARY = -2;
+ public const int SQL_TYPE_BLOB = -98;
+
+ public const int SQL_C_CHAR = SQL_CHAR;
+ public const int SQL_C_SLONG = -16;
+ public const int SQL_C_SSHORT = -15;
+ public const int SQL_C_TYPE_BINARY = -2;
+ public const int SQL_C_DOUBLE = 8;
+ public const int SQL_C_DECIMAL_IBM = 3;
+ public const int SQL_C_DECIMAL_OLEDB = 2514;
+ public const int SQL_C_DEFAULT = 99;
+ public const int SQL_C_TYPE_DATE = 91;
+ public const int SQL_C_TYPE_TIME = 92;
+ public const int SQL_C_TYPE_TIMESTAMP = 93;
+ public const int SQL_C_TYPE_NUMERIC = 2;
+ public const int SQL_C_TYPE_REAL = 7;
+
+ public const int SQL_BLOB_LOCATOR = 31;
+ public const int SQL_CLOB_LOCATOR = 41;
+ public const int SQL_DBCLOB_LOCATOR = -351;
+
+ public const int SQL_C_BLOB_LOCATOR = SQL_BLOB_LOCATOR;
+ public const int SQL_C_CLOB_LOCATOR = SQL_CLOB_LOCATOR;
+ public const int SQL_C_DBCLOB_LOCATOR = SQL_DBCLOB_LOCATOR;
+
+ public const int SQL_USER_DEFINED_TYPE = (-450);
+
+ /* SQLDriverConnect Options */
+ public const int SQL_DRIVER_NOPROMPT = 0;
+ public const int SQL_DRIVER_COMPLETE = 1;
+ public const int SQL_DRIVER_PROMPT = 2;
+ public const int SQL_DRIVER_COMPLETE_REQUIRED = 3;
+
+ /* Null settings */
+ public const int SQL_NO_NULLS = 0;
+ public const int SQL_NULLABLE = 1;
+ public const int SQL_NULLABLE_UNKNOWN = 2;
+
+ /* Defines for SQLBindParameter and SQLProcedureColumns */
+ public const int SQL_PARAM_TYPE_UNKNOWN = 0;
+ public const int SQL_PARAM_INPUT = 1;
+ public const int SQL_PARAM_INPUT_OUTPUT = 2;
+ public const int SQL_RESULT_COL = 3;
+ public const int SQL_PARAM_OUTPUT = 4;
+ public const int SQL_RETURN_VALUE = 5;
+
+ /*Defines for SQLColAttributeW*/
+ public const int SQL_DESC_ALLOC_TYPE = 1099;
+ public const int SQL_DESC_AUTO_UNIQUE_VALUE = 11;
+ public const int SQL_DESC_BASE_COLUMN_NAME = 22;
+ public const int SQL_DESC_BASE_TABLE_NAME = 23;
+ public const int SQL_DESC_COLUMN_CATALOG_NAME = 17;
+ public const int SQL_DESC_COLUMN_NAME = 1;
+ public const int SQL_DESC_COLUMN_OWNER_NAME = 16;
+ public const int SQL_DESC_COLUMN_TABLE_NAME = 15;
+ public const int SQL_DESC_CONCISE_TYPE = 2;
+ public const int SQL_DESC_COUNT = 1001;
+ public const int SQL_DESC_DATA_PTR = 1010;
+ public const int SQL_DESC_DATETIME_INTERVAL_CODE = 1007;
+ public const int SQL_DESC_INDICATOR_PTR = 1009;
+ public const int SQL_DESC_LENGTH = 1003;
+ public const int SQL_DESC_NAME = 1011;
+ public const int SQL_DESC_NULLABLE = 1008;
+ public const int SQL_DESC_OCTET_NULLABLE = 1013;
+ public const int SQL_DESC_OCTET_LENGTH_PTR = 1004;
+ public const int SQL_DESC_PRECISION = 1005;
+ public const int SQL_DESC_SCALE = 1006;
+ public const int SQL_DESC_TYPE = 1002;
+ public const int SQL_DESC_TYPE_NAME = 14;
+ public const int SQL_DESC_UNNAMED = 1012;
+ public const int SQL_DESC_UNSIGNED = 8;
+ public const int SQL_DESC_UPDATABLE = 10;
+ }
+}
diff --git a/mcs/class/System.Data.Db2Client/System.Data.Db2Client/Db2DataAdapter.cs b/mcs/class/System.Data.Db2Client/System.Data.Db2Client/Db2DataAdapter.cs
new file mode 100644
index 00000000000..a1d737ee735
--- /dev/null
+++ b/mcs/class/System.Data.Db2Client/System.Data.Db2Client/Db2DataAdapter.cs
@@ -0,0 +1,163 @@
+using System;
+using System.ComponentModel;
+using System.Data;
+using System.Data.Common;
+
+namespace System.Data.Db2Client {
+
+ public sealed class Db2DataAdapter : DbDataAdapter, IDbDataAdapter
+ {
+ #region Fields
+
+ bool disposed = false;
+ Db2Command deleteCommand;
+ Db2Command insertCommand;
+ Db2Command selectCommand;
+ Db2Command updateCommand;
+
+ #endregion
+
+ #region Constructors
+
+ public Db2DataAdapter ()
+ : this (new Db2Command ())
+ {
+ }
+
+ public Db2DataAdapter (Db2Command selectCommand)
+ {
+ DeleteCommand = null;
+ InsertCommand = null;
+ SelectCommand = selectCommand;
+ UpdateCommand = null;
+ }
+
+ public Db2DataAdapter (string selectCommandText, Db2Connection selectConnection)
+ : this (new Db2Command (selectCommandText, selectConnection))
+ {
+ }
+
+ public Db2DataAdapter (string selectCommandText, string selectConnectionString)
+ : this (selectCommandText, new Db2Connection (selectConnectionString))
+ {
+ }
+
+ #endregion
+
+ #region Properties
+
+
+ public Db2Command DeleteCommand {
+ get { return deleteCommand; }
+ set { deleteCommand = value; }
+ }
+
+
+ public Db2Command InsertCommand {
+ get { return insertCommand; }
+ set { insertCommand = value; }
+ }
+
+
+ public Db2Command SelectCommand {
+ get { return selectCommand; }
+ set { selectCommand = value; }
+ }
+
+
+ public Db2Command UpdateCommand {
+ get { return updateCommand; }
+ set { updateCommand = value; }
+ }
+
+ IDbCommand IDbDataAdapter.DeleteCommand {
+ get { return DeleteCommand; }
+ set {
+ if (!(value is Db2Command))
+ throw new ArgumentException ();
+ DeleteCommand = (Db2Command)value;
+ }
+ }
+
+ IDbCommand IDbDataAdapter.InsertCommand {
+ get { return InsertCommand; }
+ set {
+ if (!(value is Db2Command))
+ throw new ArgumentException ();
+ InsertCommand = (Db2Command)value;
+ }
+ }
+
+ IDbCommand IDbDataAdapter.SelectCommand {
+ get { return SelectCommand; }
+ set {
+ if (!(value is Db2Command))
+ throw new ArgumentException ();
+ SelectCommand = (Db2Command)value;
+ }
+ }
+
+ IDbCommand IDbDataAdapter.UpdateCommand {
+ get { return UpdateCommand; }
+ set {
+ if (!(value is Db2Command))
+ throw new ArgumentException ();
+ UpdateCommand = (Db2Command)value;
+ }
+ }
+
+
+ ITableMappingCollection IDataAdapter.TableMappings {
+ get { return TableMappings; }
+ }
+
+ #endregion
+
+ #region Methods
+
+ protected override RowUpdatedEventArgs CreateRowUpdatedEvent (DataRow dataRow, IDbCommand command, StatementType statementType, DataTableMapping tableMapping)
+ {
+ return new Db2RowUpdatedEventArgs (dataRow, command, statementType, tableMapping);
+ }
+
+
+ protected override RowUpdatingEventArgs CreateRowUpdatingEvent (DataRow dataRow, IDbCommand command, StatementType statementType, DataTableMapping tableMapping)
+ {
+ return new Db2RowUpdatingEventArgs (dataRow, command, statementType, tableMapping);
+ }
+
+ protected override void Dispose (bool disposing)
+ {
+ if (!disposed) {
+ if (disposing) {
+
+ }
+
+ disposed = true;
+ }
+ }
+
+ protected override void OnRowUpdated (RowUpdatedEventArgs value)
+ {
+ if (RowUpdated != null)
+ RowUpdated (this, (Db2RowUpdatedEventArgs) value);
+ }
+
+ protected override void OnRowUpdating (RowUpdatingEventArgs value)
+ {
+ if (RowUpdating != null)
+ RowUpdating (this, (Db2RowUpdatingEventArgs) value);
+ }
+
+ #endregion
+
+ #region Events and Delegates
+
+ public event Db2RowUpdatedEventHandler RowUpdated;
+
+ public event Db2RowUpdatingEventHandler RowUpdating;
+
+ #endregion
+
+ }
+}
diff --git a/mcs/class/System.Data.Db2Client/System.Data.Db2Client/Db2DataReader.cs b/mcs/class/System.Data.Db2Client/System.Data.Db2Client/Db2DataReader.cs
new file mode 100644
index 00000000000..017285063c0
--- /dev/null
+++ b/mcs/class/System.Data.Db2Client/System.Data.Db2Client/Db2DataReader.cs
@@ -0,0 +1,763 @@
+using System;
+using System.Data;
+using System.Runtime.InteropServices;
+using System.Globalization;
+using System.Text;
+
+namespace System.Data.Db2Client
+{
+ /// <summary>
+ /// Summary description for Db2ClientDataReader.
+ /// Db2ClientDataReader.
+ /// </summary>
+ public class Db2DataReader : MarshalByRefObject, IDataReader
+ {
+ internal DataTable _resultSet;
+ internal Db2Connection db2Conn;
+ internal IntPtr hwndStmt;
+ private int row=-1;
+ private int numCols=0;
+
+ internal IntPtr Ptr = IntPtr.Zero;
+ BLOBWrapperCollection _blobs = new BLOBWrapperCollection();
+
+ private DataTable _schemaTable ;
+ private DataTable _resultInfo;
+
+ IntPtr intPtr = IntPtr.Zero;
+ IntPtr[] ipTarget;
+
+ #region Constructors and destructors
+ /// <summary>
+ ///
+ /// </summary>
+ /// <param name="con"></Connection object to Db2>
+ /// <param name="com"></Command object>
+ internal Db2DataReader(Db2Connection con, Db2Command com)
+ {
+ _schemaTable = BuildNewSchemaTable();
+ db2Conn = con;
+ hwndStmt = com.statementHandle; //We have access to the results through the statement handle
+
+ short sqlRet;
+
+ _resultSet = new DataTable();
+
+ sqlRet = Db2CLIWrapper.SQLNumResultCols(hwndStmt, ref numCols);
+ Db2ClientUtils.Db2CheckReturn(sqlRet, Db2Constants.SQL_HANDLE_STMT, hwndStmt, "Db2ClientDataReader - SQLNumResultCols");
+
+ //IntPtr[] sqlLen_or_IndPtr = new IntPtr[numCols];
+ //ipTarget = new IntPtr[numCols];
+
+ _schemaTable = BuildNewSchemaTable();
+
+ PrepareResults(/*sqlLen_or_IndPtr*/);
+ //FetchResults(sqlLen_or_IndPtr, _resultSet);
+ isClosed = false;
+ }
+ /// <summary>
+ /// Constructor for use with prepared statements
+ /// </summary>
+ ///
+ internal Db2DataReader(Db2Connection con, Db2Command com, bool prepared)
+ {
+ db2Conn = con;
+ hwndStmt = com.statementHandle; //We have access to the results through the statement handle
+
+ short sqlRet;
+
+ sqlRet = Db2CLIWrapper.SQLNumResultCols(hwndStmt, ref numCols);
+ Db2ClientUtils.Db2CheckReturn(sqlRet, Db2Constants.SQL_HANDLE_STMT, hwndStmt, "Db2ClientDataReader - SQLNumResultCols");
+
+
+ //IntPtr[] sqlLen_or_IndPtr = new IntPtr[numCols];
+ //ipTarget = new IntPtr[numCols];
+
+ PrepareResults(/*sqlLen_or_IndPtr*/);
+ isClosed = false;
+ }
+
+ public void Dispose()
+ {
+ Close();
+ }
+ #endregion
+
+ #region Properties
+ #region Depth property
+ ///
+ ///Depth of nesting for the current row, need to figure out what this translates into
+ ///with Db2.
+ ///
+ private int depth = 0;
+ public int Depth
+ {
+ get
+ {
+ return depth;
+ }
+ }
+ #endregion
+ #region IsClosed property
+ /// <summary>
+ /// True if the reader is closed.
+ /// </summary>
+ private bool isClosed = true;
+ public bool IsClosed
+ {
+ get
+ {
+ return isClosed;
+ }
+ }
+ #endregion
+ #region RecordsAffected property
+ ///
+ /// Number of records affected by this operation. Will be zero until we close the
+ /// reader
+ ///
+ private int recordsAffected = 0;
+ public int RecordsAffected
+ {
+ get
+ {
+ return recordsAffected;
+ }
+ }
+ #endregion
+ #endregion
+
+ #region Methods
+
+ #region Close method
+ ///
+ ///
+ public void Close()
+ {
+ if (_resultSet != null)
+ {
+ recordsAffected = _resultSet.Rows.Count;
+ _resultSet.Dispose();
+ _resultSet = null;
+ isClosed=true;
+ }
+ }
+ #endregion
+
+ #region GetSchemaTable
+
+ public DataTable GetSchemaTable()
+ {
+ if (null ==_schemaTable)
+ {
+ _schemaTable = BuildNewSchemaTable();
+ }
+
+ return _schemaTable;
+ }
+ #endregion
+
+ #region NextResult
+
+ public bool NextResult()
+ {
+
+ //throw new Db2Exception("To be done");
+ short result = Db2CLIWrapper.SQLMoreResults(this.hwndStmt);
+ Db2ClientUtils.Db2CheckReturn(result, Db2Constants.SQL_HANDLE_STMT, hwndStmt, "Db2ClientDataReader - SQLMoreResults");
+
+
+ if (Db2Constants.SQL_SUCCESS == result){
+ result = Db2CLIWrapper.SQLNumResultCols(hwndStmt, ref numCols);
+ Db2ClientUtils.Db2CheckReturn(result, Db2Constants.SQL_HANDLE_STMT, hwndStmt, "Db2ClientDataReader - SQLNumResultCols");
+
+ row=-1;
+ _schemaTable = new DataTable();
+ _schemaTable = BuildNewSchemaTable();
+ _resultSet = new DataTable();
+ _blobs = new BLOBWrapperCollection();
+
+ PrepareResults();
+ return true;
+ }
+ return false;
+
+ //Deferring the meat of this until the batch stuff is implemented
+ }
+ #endregion
+
+ #region Read
+ ///
+ /// Apparently, this function does nothing other than tell you if you can move to the
+ /// next row in the resultset. I have to move the fetching stuff elswhere...
+ ///
+ public bool Read()
+ {
+ if (isClosed) return false;
+ row++;
+ if (FetchResults(_resultSet)) return true; else return false;
+
+ }
+ #endregion
+
+ #region Describe/Bind/Fetch functions
+ ///
+ ///Broke these out so that we can use different paths for Immediate executions and Prepared executions
+ /// <summary>
+ /// Does the describe and bind steps for the query result set. Called for both immediate and prepared queries.
+ /// </summary>
+ private void PrepareResults(/*IntPtr[] sqlLen_or_IndPtr*/)
+ {
+
+
+ short sqlRet;
+ IntPtr ptrCharacterAttribute = IntPtr.Zero;
+ InitMem(20, ref ptrCharacterAttribute);
+ short buflen = 18;
+ short strlen = 18;
+ int numericattr = 0;
+ int colsize;
+ string colname;
+ int sqltype;
+ int precision;
+ int scale;
+ int nullable;
+ int updatable;
+ int isautoincrement;
+ string baseschemaname;
+ string basecatalogname;
+ string basetablename;
+ string basecolumnname;
+
+
+ for (short i=1; i<=numCols; i++)
+ {
+
+ sqlRet = Db2CLIWrapper.SQLColAttribute(hwndStmt, (short)i, (short)Db2Constants.SQL_DESC_BASE_COLUMN_NAME, ptrCharacterAttribute, buflen, ref strlen, ref numericattr);
+ colname = Marshal.PtrToStringAnsi(ptrCharacterAttribute);
+
+ sqlRet = Db2CLIWrapper.SQLColAttribute(hwndStmt, (short)i, (short)Db2Constants.SQL_DESC_CONCISE_TYPE, ptrCharacterAttribute, buflen, ref strlen, ref numericattr);
+ sqltype = numericattr;
+
+ sqlRet = Db2CLIWrapper.SQLColAttribute(hwndStmt, (short)i, (short)Db2Constants.SQL_DESC_LENGTH, ptrCharacterAttribute, buflen, ref strlen, ref numericattr);
+ colsize = numericattr;
+
+ sqlRet = Db2CLIWrapper.SQLColAttribute(hwndStmt, (short)i, (short)Db2Constants.SQL_DESC_PRECISION, ptrCharacterAttribute, buflen, ref strlen, ref numericattr);
+ precision = numericattr;
+
+ sqlRet = Db2CLIWrapper.SQLColAttribute(hwndStmt, (short)i, (short)Db2Constants.SQL_DESC_SCALE, ptrCharacterAttribute, buflen, ref strlen, ref numericattr);
+ scale = numericattr;
+
+ sqlRet = Db2CLIWrapper.SQLColAttribute(hwndStmt, (short)i, (short)Db2Constants.SQL_DESC_NULLABLE, ptrCharacterAttribute, buflen, ref strlen, ref numericattr);
+ nullable = numericattr;
+
+ sqlRet = Db2CLIWrapper.SQLColAttribute(hwndStmt, (short)i, (short)Db2Constants.SQL_DESC_UPDATABLE, ptrCharacterAttribute, buflen, ref strlen, ref numericattr);
+ updatable = numericattr;
+
+
+ sqlRet = Db2CLIWrapper.SQLColAttribute(hwndStmt, (short)i, (short)Db2Constants.SQL_DESC_AUTO_UNIQUE_VALUE, ptrCharacterAttribute, buflen, ref strlen, ref numericattr);
+ isautoincrement = numericattr;
+
+ sqlRet = Db2CLIWrapper.SQLColAttribute(hwndStmt, (short)i, (short)Db2Constants.SQL_DESC_BASE_COLUMN_NAME, ptrCharacterAttribute, buflen, ref strlen, ref numericattr);
+ basecolumnname = Marshal.PtrToStringAnsi(ptrCharacterAttribute);
+
+ sqlRet = Db2CLIWrapper.SQLColAttribute(hwndStmt, (short)i, (short)Db2Constants.SQL_DESC_BASE_TABLE_NAME, ptrCharacterAttribute, buflen, ref strlen, ref numericattr);
+ basetablename = Marshal.PtrToStringAnsi(ptrCharacterAttribute);
+
+ _resultSet.Columns.Add(colname);
+
+ DataRow r = _schemaTable.NewRow();
+
+ switch((int)sqltype){
+ case Db2Constants.SQL_TYPE_BLOB:
+ case Db2Constants.SQL_TYPE_BINARY:
+ _blobs.Add(i);
+
+ break;
+ }
+
+ r["ColumnName"] = colname;
+ r["ColumnOrdinal"] = i;
+ r["ColumnSize"] = colsize;
+ r["NumericPrecision"] = precision;
+ r["NumericScale"] = scale;
+ r["DataType"] = GetManagedType((short)sqltype);
+ r["ProviderType"] = sqltype;
+ r["IsLong"] = IsLong((short)sqltype);
+ r["AllowDBNull"] = (nullable==0)?true:false;
+ r["IsReadOnly"] = false;
+ r["IsRowVersion"] = false;
+ r["IsKey"] = false;
+ r["IsAutoIncrement"] = (isautoincrement==0)?true:false;
+ r["BaseColumnName"] = basecolumnname;
+ r["BaseTableName"] = basetablename;
+ r["BaseCatalogName"] = "";
+ r["BaseSchemaName"] = "";
+
+ _schemaTable.Rows.Add(r);
+ }
+ }
+/// <summary>
+/// FetchResults does what it says.
+/// </summary>
+/// <param name="dbVals"></param>
+/// <param name="sqlLen_or_IndPtr"></param>
+/// <param name="_resultSet"></param>
+ private bool FetchResults(/*IntPtr[] sqlLen_or_IndPtr, */DataTable _resultSet)
+ {
+ short sqlRet = 0;
+ string str = String.Empty;
+
+ sqlRet = Db2CLIWrapper.SQLFetch(hwndStmt);
+
+ Db2ClientUtils.Db2CheckReturn(sqlRet, Db2Constants.SQL_HANDLE_STMT, hwndStmt, "Db2ClientDataReader - SQLFetch 1");
+
+ if(Db2Constants.SQL_NO_DATA_FOUND == sqlRet) return false;
+ //while(sqlRet != Db2Constants.SQL_NO_DATA_FOUND)
+ //{
+ DataRow newRow = _resultSet.NewRow();
+
+ for (short y=1;y<=numCols;y++)
+ {
+ newRow[y-1] = GetDataObject(y);
+ }
+ _resultSet.Rows.Add(newRow);
+ return true;
+ //sqlRet = Db2CLIWrapper.SQLFetch(hwndStmt);
+ //Db2ClientUtils.Db2CheckReturn(sqlRet, Db2Constants.SQL_HANDLE_STMT, hwndStmt, "Db2ClientDataReader - SQLFetch 2");
+ //}
+ }
+
+ private object GetDataObject(int i){
+ int len = (int)_schemaTable.Rows[i-1][2] + 2;
+ short sqlRet;
+ IntPtr StrLen_or_IndStr = IntPtr.Zero;
+
+ switch((int)_schemaTable.Rows[i-1][6]){
+ case Db2Constants.SQL_INTEGER:
+ InitMem(len, ref Ptr);
+ sqlRet = Db2CLIWrapper.SQLGetData(this.hwndStmt, (short)(i), (short)Db2Constants.SQL_C_SLONG, Ptr, new IntPtr(len), ref StrLen_or_IndStr);
+ return (int) Marshal.PtrToStructure(Ptr, typeof(int));
+ break;
+
+ case Db2Constants.SQL_SMALLINT:
+ InitMem(len, ref Ptr);
+ sqlRet = Db2CLIWrapper.SQLGetData(this.hwndStmt, (short)(i), (short)Db2Constants.SQL_C_SSHORT, Ptr, new IntPtr(len), ref StrLen_or_IndStr);
+ return (short) Marshal.PtrToStructure(Ptr, typeof(short));
+ break;
+
+ case Db2Constants.SQL_DOUBLE:
+ InitMem(len, ref Ptr);
+ sqlRet = Db2CLIWrapper.SQLGetData(this.hwndStmt, (short)(i), (short)Db2Constants.SQL_C_DOUBLE, Ptr, new IntPtr(len), ref StrLen_or_IndStr);
+ return (double)Marshal.PtrToStructure(Ptr, typeof(double));
+ break;
+
+ case Db2Constants.SQL_DECIMAL:
+ InitMem(len, ref Ptr);
+ sqlRet = Db2CLIWrapper.SQLGetData(this.hwndStmt, (short)(i), (short)Db2Constants.SQL_C_DECIMAL_OLEDB, Ptr, new IntPtr(len), ref StrLen_or_IndStr);
+ return (decimal)Marshal.PtrToStructure(Ptr, typeof(decimal));
+ break;
+
+ case Db2Constants.SQL_DATETIME:
+ case Db2Constants.SQL_TYPE_DATE:
+ InitMem(len, ref Ptr);
+ sqlRet = Db2CLIWrapper.SQLGetData(this.hwndStmt, (short)(i), (short)Db2Constants.SQL_C_TYPE_DATE, Ptr, new IntPtr(len), ref StrLen_or_IndStr);
+ short year = Marshal.ReadInt16(Ptr, 0);
+ short month = Marshal.ReadInt16(Ptr, 2);
+ short day = Marshal.ReadInt16(Ptr, 4);
+ return new DateTime(year, month, day);
+ break;
+
+ case Db2Constants.SQL_CHAR:
+ case Db2Constants.SQL_VARCHAR:
+ InitMem(len, ref Ptr);
+ sqlRet = Db2CLIWrapper.SQLGetData(this.hwndStmt, (short)(i), (short)Db2Constants.SQL_C_CHAR, Ptr, new IntPtr(len), ref StrLen_or_IndStr);
+ return Marshal.PtrToStringAnsi(Ptr);
+ break;
+
+ case Db2Constants.SQL_TYPE_BLOB:
+ case Db2Constants.SQL_TYPE_BINARY:
+ BLOBWrapper _blob = _blobs[i];
+ _blob.ByteArray = GetBlobData(i);
+ //Console.WriteLine(len.ToString());
+ return null;
+ break;
+ default:
+ Console.WriteLine(_schemaTable.Rows[i-1][6].ToString());
+ throw new Db2Exception("Unsuported data type");
+ }
+ return null;
+ }
+ #endregion
+
+ #region IDataRecord Interface
+ ///Code for the IDataRecord interface
+ ///
+ #region FieldCount
+ ///
+ ///
+ private int fieldCount = -1;
+ public int FieldCount
+ {
+ get
+ {
+ if (IsClosed)
+ fieldCount = 0;
+ else
+ fieldCount = _resultSet.Columns.Count;
+ return fieldCount;
+ }
+ }
+ #endregion
+
+ #region Item accessors
+ public object this[string name]
+ {
+ get
+ {
+ return _resultSet.Rows[row][name];
+ }
+ }
+ public object this[int col]
+ {
+ get
+ {
+ return _resultSet.Rows[row][col];
+ }
+ }
+ #endregion
+
+ #region GetBoolean method
+ ///
+ ///Use the Convert class for all of these returns
+ ///
+ public bool GetBoolean(int col)
+ {
+ return Convert.ToBoolean(this[col]);
+ }
+ #endregion
+
+ #region GetByte
+ ///
+ ///GetByte
+ ///
+ public byte GetByte(int col)
+ {
+ return Convert.ToByte(this[col]);
+ }
+ #endregion
+
+ #region GetBytes
+ ///
+ /// GetBytes, return a stream of bytes
+ ///
+ public long GetBytes(int col, long fieldOffset, byte[] buffer, int bufferOffset, int length)
+ {
+ return _blobs.GetBytes(col, fieldOffset, buffer, bufferOffset, length);
+ //return 0;
+ }
+ #endregion
+
+ #region GetChar
+ ///
+ ///GetChar, return column as a char
+ ///
+ public char GetChar(int col)
+ {
+ return Convert.ToChar(this[col]);
+ }
+ #endregion
+
+ #region GetChars
+ ///
+ ///GetChars, returns char array
+ ///
+ public long GetChars(int col, long fieldOffset, char[] buffer, int bufferOffset, int length)
+ {
+ //Again, not sure how I'll deal with this just yet
+ return 0;
+ }
+ #endregion
+
+ #region GetData
+ ///
+ /// GetData method
+ ///
+ public IDataReader GetData(int col)
+ {
+ //Have to research this one, not quite sure what the docs mean
+ //Db2 does have some structured data types, is that what this is for?
+ throw new Db2Exception("Not yet supported.");
+ }
+ #endregion
+
+ #region GetDataTypeName
+ ///
+ ///GetDataTypeName return the type of data
+ ///
+ public string GetDataTypeName(int col)
+ {
+ //I could check the meta data as a starting point for this one, but until I implement
+ //returning the result sets, I'm not exactly sure what info I'll have, so this function
+ //waits until then...
+ throw new Db2Exception("Not yet implemented");
+ }
+ #endregion
+
+ #region GetDateTime
+ ///
+ /// GetDateTime method
+ ///
+ public string NewGetDateTime(int col)
+ {
+ return Convert.ToString(this[col]);
+ }
+ public DateTime GetDateTime(int col)
+ {
+ return Convert.ToDateTime(this[col]);
+ }
+ #endregion
+
+ #region GetDecimal
+ ///
+ ///GetDecimal method
+ ///
+ public decimal GetDecimal(int col)
+ {
+ return Convert.ToDecimal(this[col]);
+ }
+ #endregion
+
+ #region GetDouble
+ ///
+ /// GetDouble
+ ///
+ public double GetDouble(int col)
+ {
+ return Convert.ToDouble(this[col]);
+ }
+ #endregion
+
+ #region GetFieldType
+ ///
+ /// Type GetFieldType
+ ///
+ public Type GetFieldType(int col)
+ {
+ //Again need more research here
+ return typeof(int);
+ }
+ #endregion
+
+ #region GetFloat
+ ///
+ /// GetFloat
+ ///
+ public float GetFloat(int col)
+ {
+ return (float) Convert.ToDouble(this[col].ToString(),new CultureInfo("en-US").NumberFormat);
+ }
+ #endregion
+
+ #region GetGuid
+ ///
+ /// GetGuid
+ ///
+ public Guid GetGuid(int col)
+ {
+ // a Guid is a 128 bit unique value. Could be like a GENERATE UNIQUE in Db2
+ // as usual, need more research
+ throw new Db2Exception("TBD");
+ }
+ #endregion
+
+ #region The GetInt?? series
+ ///
+ ///GetInt16
+ ///
+ public short GetInt16(int col)
+ {
+ return Convert.ToInt16(this[col]);
+ }
+ ///
+ ///GetInt32
+ ///
+ public int GetInt32(int col)
+ {
+ return Convert.ToInt32(this[col]);
+ }
+ ///
+ ///GetInt64
+ ///
+ public long GetInt64(int col)
+ {
+ return Convert.ToInt64(this[col]);
+ }
+ #endregion
+
+ #region GetName
+ ///
+ ///GetName, returns the name of the field
+ ///
+ public string GetName(int col)
+ {
+ return (_resultSet.Columns[col].ColumnName);
+ }
+ #endregion
+
+ #region GetOrdinal
+ ///
+ /// GetOrdinal, return the index of the named column
+ ///
+ public int GetOrdinal(string name)
+ {
+ return _resultSet.Columns[name].Ordinal;
+ }
+ #endregion
+
+ #region GetString
+ ///
+ /// GetString returns a string
+ ///
+ public string GetString(int col)
+ {
+ return Convert.ToString(this[col]);
+ }
+ #endregion
+
+ #region GetLobLocator
+ ///
+ ///Returns a LOB Locator class
+ ///
+ //Db2ClientLOBLocator GetLobLocator(int col)
+ //{
+
+ #endregion
+
+ #region GetValue
+ ///
+ /// GetVCalue, returns an object
+ ///
+ public object GetValue(int col)
+ {
+ return this[col];
+ }
+ #endregion
+
+ #region GetValues
+ ///
+ /// GetValues returns all columns in the row through the argument, and the number of columns in the return value
+ ///
+ public int GetValues(object[] values)
+ {
+
+ if (values.Length<numCols)
+ throw new Db2Exception("GetValues argument too small for number of columns in row.");
+ for (int i = 0; i<numCols; i++){
+ values[i] = this[i];
+
+ }
+
+ return numCols;
+ }
+ #endregion
+
+ #region IsDBNull
+ ///
+ /// IsDBNull Is the column null
+ ///
+ public bool IsDBNull(int col)
+ {
+ //Proper implementation once I get the SQLDescribe/SQLBind/SQLFetch stuff in place
+ return false;
+ }
+ #endregion
+
+ #endregion ///For IDataRecord
+
+ #region private methods
+
+ private DataTable BuildNewSchemaTable()
+ {
+ DataTable schemaTable = new DataTable("SchemaTable");
+
+ schemaTable.Columns.Add(new DataColumn("ColumnName", typeof(string)));
+ schemaTable.Columns.Add(new DataColumn("ColumnOrdinal", typeof(int)));
+ schemaTable.Columns.Add(new DataColumn("ColumnSize", typeof(int)));
+ schemaTable.Columns.Add(new DataColumn("NumericPrecision", typeof(short)));
+ schemaTable.Columns.Add(new DataColumn("NumericScale", typeof(short)));
+ schemaTable.Columns.Add(new DataColumn("DataType", typeof(System.Type)));
+ schemaTable.Columns.Add(new DataColumn("ProviderType", typeof(int)));
+ schemaTable.Columns.Add(new DataColumn("IsLong", typeof(bool)));
+ schemaTable.Columns.Add(new DataColumn("AllowDBNull", typeof(bool)));
+ schemaTable.Columns.Add(new DataColumn("IsReadOnly", typeof(bool)));
+ schemaTable.Columns.Add(new DataColumn("IsRowVersion", typeof(bool)));
+ schemaTable.Columns.Add(new DataColumn("IsUnique", typeof(bool)));
+ schemaTable.Columns.Add(new DataColumn("IsKey", typeof(bool)));
+ schemaTable.Columns.Add(new DataColumn("IsAutoIncrement", typeof(bool)));
+ schemaTable.Columns.Add(new DataColumn("BaseSchemaName", typeof(string)));
+ schemaTable.Columns.Add(new DataColumn("BaseCatalogName", typeof(string)));
+ schemaTable.Columns.Add(new DataColumn("BaseTableName", typeof(string)));
+ schemaTable.Columns.Add(new DataColumn("BaseColumnName", typeof(string)));
+
+ return schemaTable;
+ }
+ #endregion
+
+ private void InitMem(int memSize, ref IntPtr ptr){
+ if (ptr.ToInt32() == 0){
+ unsafe{
+ fixed(byte* arr = new byte[memSize]){
+ ptr = new IntPtr(arr);
+ }
+ }
+ }
+ }
+
+ private Type GetManagedType(short sql_type){
+ switch(sql_type){
+ case Db2Constants.SQL_INTEGER:
+ return typeof(int);
+ case Db2Constants.SQL_SMALLINT:
+ return typeof(short);
+ case Db2Constants.SQL_DOUBLE:
+ return typeof(double);
+ case Db2Constants.SQL_DECIMAL:
+ return typeof(decimal);
+ case Db2Constants.SQL_DATETIME:
+ case Db2Constants.SQL_TYPE_DATE:
+ return typeof(DateTime);
+ case Db2Constants.SQL_CHAR:
+ case Db2Constants.SQL_VARCHAR:
+ return typeof(string);
+ case Db2Constants.SQL_TYPE_BLOB:
+ case Db2Constants.SQL_TYPE_BINARY:
+ return typeof(IntPtr);
+ }
+ return null;
+ }
+
+ private bool IsLong(short sql_type){
+ switch(sql_type){
+ default:
+ return false;
+ }
+ }
+ private byte[] GetBlobData(int column){
+ IntPtr StrLen_or_IndStr = new IntPtr(0);
+ long sqlRet = 0;
+ int length;
+ byte[] result = new byte[0];
+
+ sqlRet = Db2CLIWrapper.SQLGetData(this.hwndStmt, (short)column, Db2Constants.SQL_C_TYPE_BINARY, result, new IntPtr(0), ref StrLen_or_IndStr);
+ length = StrLen_or_IndStr.ToInt32();
+ result = new byte[length];
+
+ sqlRet = Db2CLIWrapper.SQLGetData(this.hwndStmt, (short)column, Db2Constants.SQL_C_TYPE_BINARY, result, new IntPtr(length), ref StrLen_or_IndStr);
+
+ return result;
+ }
+ }
+
+}
+#endregion
diff --git a/mcs/class/System.Data.Db2Client/System.Data.Db2Client/Db2Exception.cs b/mcs/class/System.Data.Db2Client/System.Data.Db2Client/Db2Exception.cs
new file mode 100644
index 00000000000..9ae51a76cba
--- /dev/null
+++ b/mcs/class/System.Data.Db2Client/System.Data.Db2Client/Db2Exception.cs
@@ -0,0 +1,46 @@
+using System;
+using System.Runtime.InteropServices;
+using System.Text;
+
+namespace System.Data.Db2Client
+{
+
+ public class Db2Exception : Exception
+ {
+ internal string message;
+ public Db2Exception(string Message)
+ {
+ this.message = Message;
+ }
+ public Db2Exception(short sqlHandleType, IntPtr sqlHandle, string Message)
+ {
+ StringBuilder sqlState = new StringBuilder(50);
+ StringBuilder errorMessage = new StringBuilder(1025);
+
+ int sqlReturn;
+ short recNum=1;
+ short bufLength = 1025;
+
+ IntPtr textLengthPtr = IntPtr.Zero;
+ IntPtr nativeErrorPtr = IntPtr.Zero;
+
+ sqlReturn = Db2CLIWrapper.SQLGetDiagRec(sqlHandleType, sqlHandle, recNum, sqlState, ref nativeErrorPtr, errorMessage, bufLength, ref textLengthPtr);
+ this.message = Message + "\n" + sqlState.ToString() + " " + errorMessage.ToString()+"\n";
+ //See if there are more errors to retrieve and get them.
+ while (sqlReturn != Db2Constants.SQL_NO_DATA && sqlReturn > 0)
+ {
+ recNum++;
+ sqlReturn = Db2CLIWrapper.SQLGetDiagRec(sqlHandleType, sqlHandle, recNum, sqlState, ref nativeErrorPtr, errorMessage, bufLength, ref textLengthPtr);
+ this.message += "\n" + sqlState.ToString() + " " + errorMessage.ToString()+"\n";
+ }
+
+ }
+ public override string Message
+ {
+ get
+ {
+ return this.message;
+ }
+ }
+ }
+}
diff --git a/mcs/class/System.Data.Db2Client/System.Data.Db2Client/Db2LOBLocator.cs b/mcs/class/System.Data.Db2Client/System.Data.Db2Client/Db2LOBLocator.cs
new file mode 100644
index 00000000000..cf55159cc31
--- /dev/null
+++ b/mcs/class/System.Data.Db2Client/System.Data.Db2Client/Db2LOBLocator.cs
@@ -0,0 +1,16 @@
+using System;
+using System.Data;
+
+namespace Db2DriverCS
+{
+
+ public class Db2ClientLOB
+ {
+ internal IntPtr hwndStmt;
+
+ public Db2ClientLOB()
+ {
+
+ }
+ }
+}
diff --git a/mcs/class/System.Data.Db2Client/System.Data.Db2Client/Db2Parameter.cs b/mcs/class/System.Data.Db2Client/System.Data.Db2Client/Db2Parameter.cs
new file mode 100644
index 00000000000..2c19d777239
--- /dev/null
+++ b/mcs/class/System.Data.Db2Client/System.Data.Db2Client/Db2Parameter.cs
@@ -0,0 +1,448 @@
+using System;
+using System.Data;
+using System.Runtime.InteropServices;
+
+namespace System.Data.Db2Client
+{
+
+ public sealed class Db2Parameter : MarshalByRefObject, IDbDataParameter, IDataParameter, ICloneable
+ {
+ private DbType dbType;
+ private IntPtr db2DataType;
+ private ParameterDirection direction;
+ private bool nullable;
+ private string parameterName;
+ private string sourceColumn;
+ private IntPtr paramSize;
+ private IntPtr decimalDigits;
+ private DataRowVersion sourceVersion;
+ object dataVal;
+ IntPtr DataValPtr = IntPtr.Zero;
+ byte[] bDataVal;
+ private int iDataVal;
+ private byte scale, precision;
+ private int size;
+ bool selfDescribe = false;
+
+ #region Contructors and destructors
+ public Db2Parameter()
+ {
+ }
+ public Db2Parameter (string name)
+ {
+ parameterName = name;
+ }
+
+ public Db2Parameter(string name, DbType type)
+ {
+ parameterName = name;
+ dbType = type;
+ }
+ public Db2Parameter(string name, object data)
+ {
+ parameterName = name;
+ this.Value = data;
+ }
+ public Db2Parameter(string name, DbType type, string columnName)
+ {
+ parameterName = name;
+ dbType = type;
+ sourceColumn = columnName;
+ }
+ public Db2Parameter(string name, int db2Type)
+ {
+ parameterName = name;
+ dbType = inferTypeFromDb2Type(db2Type);
+ db2DataType = new IntPtr(db2Type);
+ }
+ #endregion
+ #region Properties
+ #region DbType Property
+ ///
+ /// Parameter data type
+ ///
+ public DbType DbType
+ {
+ get
+ {
+ return dbType;
+ }
+ set
+ {
+ dbType = value;
+ }
+ }
+ #endregion
+ #region Direction
+ ///
+ /// In or out parameter, or both
+ ///
+ public ParameterDirection Direction
+ {
+ get
+ {
+ return direction;
+ }
+ set
+ {
+ direction = value;
+ }
+ }
+ #endregion
+ #region IsNullable
+ ///
+ /// Does this parameter support a null value
+ ///
+ public bool IsNullable
+ {
+ get
+ {
+ return nullable;
+ }
+ set
+ {
+ nullable = value;
+ }
+ }
+ #endregion
+ #region ParameterName
+ public string ParameterName
+ {
+ get
+ {
+ return parameterName;
+ }
+ set
+ {
+ parameterName = value;
+ }
+ }
+ #endregion
+ #region SourceColumn
+ ///
+ /// Gets or sets the name of the source column that is mapped to the DataSet
+ ///
+ public string SourceColumn
+ {
+ get
+ {
+ return sourceColumn;
+ }
+ set
+ {
+ sourceColumn = value;
+ }
+ }
+ #endregion
+ #region SourceVersion
+ ///
+ /// DataRowVersion property
+ ///
+ public DataRowVersion SourceVersion
+ {
+ get
+ {
+ return sourceVersion;
+ }
+ set
+ {
+ sourceVersion = value;
+ }
+ }
+ #endregion
+ #region IDbDataParameter properties
+ public byte Precision
+ {
+ get
+ {
+ return precision;
+ }
+ set
+ {
+ precision = value;
+ }
+ }
+
+ public byte Scale
+ {
+ get
+ {
+ return scale;
+ }
+ set
+ {
+ scale = value;
+ }
+ }
+
+ public int Size
+ {
+ get
+ {
+ return size;
+ }
+ set
+ {
+ size = value;
+ }
+ }
+ #endregion
+ #region Value
+ ///
+ /// The actual parameter data
+ ///
+ public object Value
+ {
+ get
+ {
+ return dataVal;
+ }
+ set
+ {
+ this.dataVal = value;
+ DbType = inferType(dataVal);
+ if (dbType==DbType.Int32)
+ iDataVal=(int) value;
+ else
+ {
+ if (bDataVal==null || bDataVal.Length< (((int)paramSize>20)?(int)paramSize:20) )
+ bDataVal=new byte[((int)paramSize>20)?(int)paramSize:20];
+ else
+ bDataVal.Initialize();
+ byte[] strValueBuffer=System.Text.Encoding.ASCII.GetBytes(dataVal.ToString());
+
+ strValueBuffer.CopyTo(bDataVal,0);
+ }
+ }
+ }
+ #endregion
+ #endregion
+ #region inferType Method
+ /// <summary>
+ /// Determine the data type based on the value
+ /// </summary>
+ private DbType inferType (object Data)
+ {
+ switch (Type.GetTypeCode(Data.GetType()))
+ {
+ case TypeCode.Empty:
+ throw new SystemException("Invalid data type");
+
+ case TypeCode.Object:
+ return DbType.Object;
+
+ case TypeCode.DBNull:
+ case TypeCode.Char:
+ case TypeCode.SByte:
+ case TypeCode.UInt16:
+ case TypeCode.UInt32:
+ case TypeCode.UInt64:
+ // Throw a SystemException for unsupported data types.
+ throw new SystemException("Invalid data type");
+
+ case TypeCode.Boolean:
+ return DbType.Boolean;
+
+ case TypeCode.Byte:
+ return DbType.Byte;
+
+ case TypeCode.Int16:
+ return DbType.Int16;
+
+ case TypeCode.Int32:
+ return DbType.Int32;
+
+ case TypeCode.Int64:
+ return DbType.Int64;
+
+ case TypeCode.Single:
+ return DbType.Single;
+
+ case TypeCode.Double:
+ return DbType.Double;
+
+ case TypeCode.Decimal:
+ return DbType.Decimal;
+
+ case TypeCode.DateTime:
+ return DbType.DateTime;
+
+ case TypeCode.String:
+ return DbType.String;
+
+ default:
+ throw new SystemException("Value is of unknown data type");
+ }
+ }
+ #endregion
+ #region inferTypeFromDb2Type
+ ///
+ /// Determine the DbType from the SQL type returned by SQLDescribeParam
+ ///
+ private DbType inferTypeFromDb2Type(int db2Type)
+ {
+ switch (db2Type)
+ {
+ case Db2Constants.SQL_CHAR:
+ return DbType.AnsiString;
+ case Db2Constants.SQL_NUMERIC:
+ case Db2Constants.SQL_DECIMAL:
+ return DbType.Decimal;
+ case Db2Constants.SQL_DATETIME:
+ return DbType.DateTime;
+ case Db2Constants.SQL_FLOAT:
+ case Db2Constants.SQL_DOUBLE:
+ return DbType.Double;
+ case Db2Constants.SQL_INTEGER:
+ return DbType.Int32;
+ case Db2Constants.SQL_SMALLINT:
+ return DbType.Int16;
+ case Db2Constants.SQL_VARCHAR:
+ return DbType.String;
+ case Db2Constants.SQL_USER_DEFINED_TYPE:
+ return DbType.Object;
+ default:
+ throw new SystemException("Db2 Data type is unknown.");
+ }
+ }
+ #endregion
+ #region Describe
+ ///
+ /// Describe the parameter. Use at the caller's discretion
+ ///
+ public short Describe(IntPtr hwndStmt, short paramNum)
+ {
+ IntPtr nullable = IntPtr.Zero;
+ paramSize = IntPtr.Zero;
+ decimalDigits = IntPtr.Zero;
+ short sqlRet = 0;
+
+ sqlRet = Db2CLIWrapper.SQLDescribeParam(hwndStmt, paramNum, ref db2DataType, ref paramSize, ref decimalDigits, ref nullable);
+ return sqlRet;
+ }
+ #endregion
+ #region Bind
+ ///
+ /// Bind this parameter
+ ///
+ public short Bind(IntPtr hwndStmt, short paramNum)
+ {
+ short sqlRet = 0;
+ IntPtr StrLen_or_IndPtr = IntPtr.Zero;
+ if(IntPtr.Zero == DataValPtr){
+ InitMem(20, ref DataValPtr);
+ }
+
+ IntPtr DataTypePtr = IntPtr.Zero;
+ InitMem(4, ref DataTypePtr);
+
+ IntPtr ParameterSizePtr = IntPtr.Zero;
+ InitMem(4, ref ParameterSizePtr);
+
+ IntPtr DecimalDigitsPtr = IntPtr.Zero;
+ InitMem(4, ref DecimalDigitsPtr);
+
+
+ IntPtr NullablePtr = IntPtr.Zero;
+ InitMem(4, ref NullablePtr);
+
+
+
+ sqlRet = Db2CLIWrapper.SQLDescribeParam(hwndStmt, paramNum, DataTypePtr, ParameterSizePtr, DecimalDigitsPtr, NullablePtr);
+
+ int _dataType = (int)Marshal.PtrToStructure(DataTypePtr, typeof(int));
+ int _parameterSize = (int)Marshal.PtrToStructure(ParameterSizePtr, typeof(int));
+ int _decimalDigits = (int)Marshal.PtrToStructure(DecimalDigitsPtr, typeof(int));
+ int _nullable = (int)Marshal.PtrToStructure(NullablePtr, typeof(int));
+
+ switch ((int)db2DataType)
+ {
+ //These types are treated as SQL_C_CHAR for binding purposes
+ case Db2Constants.SQL_TYPE_DATE:
+ case Db2Constants.SQL_TYPE_TIME:
+ case Db2Constants.SQL_TYPE_TIMESTAMP:
+ case Db2Constants.SQL_VARCHAR:
+ case Db2Constants.SQL_CHAR:
+ paramSize = new IntPtr(_parameterSize);
+ if(ParameterDirection.Output == direction){
+ sqlRet = Db2CLIWrapper.SQLBindParameter(hwndStmt, (ushort)paramNum,
+ ConvertParameterDirection(direction), Db2Constants.SQL_C_DEFAULT,
+ (short)db2DataType, Convert.ToUInt32((int)paramSize) ,
+ (short) _decimalDigits, DataValPtr, _parameterSize, StrLen_or_IndPtr);
+ }
+ else{
+ sqlRet = Db2CLIWrapper.SQLBindParameter(hwndStmt, (ushort)paramNum,
+ ConvertParameterDirection(direction), Db2Constants.SQL_C_DEFAULT,
+ (short)db2DataType, Convert.ToUInt32((int)paramSize) ,
+ (short) _decimalDigits, bDataVal, _parameterSize, StrLen_or_IndPtr);
+ }
+ break;
+ case Db2Constants.SQL_DECIMAL:
+ if(ParameterDirection.Output == direction){
+ sqlRet = Db2CLIWrapper.SQLBindParameter(hwndStmt, (ushort)paramNum,
+ ConvertParameterDirection(direction), Db2Constants.SQL_C_DEFAULT,
+ (short)db2DataType, Convert.ToUInt32((int)paramSize + _decimalDigits) ,
+ (short) _decimalDigits, DataValPtr, _parameterSize, StrLen_or_IndPtr);
+ }
+ else{
+ sqlRet = Db2CLIWrapper.SQLBindParameter(hwndStmt, (ushort)paramNum,
+ ConvertParameterDirection(direction), Db2Constants.SQL_C_DEFAULT,
+ (short)db2DataType, Convert.ToUInt32((int)paramSize + _decimalDigits) ,
+ (short) _decimalDigits, bDataVal, _parameterSize, StrLen_or_IndPtr);
+ }
+ break;
+
+
+ default:
+ sqlRet = Db2CLIWrapper.SQLBindParameter(hwndStmt, (ushort)paramNum, ConvertParameterDirection(direction), Db2Constants.SQL_C_DEFAULT, (short)db2DataType, Convert.ToUInt32((int)paramSize) , 0, ref iDataVal, 0, 0);
+ break;
+ }
+ return sqlRet;
+ }
+ #endregion
+ object ICloneable.Clone ()
+ {
+ throw new NotImplementedException ();
+ }
+
+ public short ConvertParameterDirection(ParameterDirection direction){
+ switch(direction){
+ case(ParameterDirection.Input):
+ return Db2Constants.SQL_PARAM_INPUT;
+ case(ParameterDirection.Output):
+ return Db2Constants.SQL_PARAM_OUTPUT;
+ default:
+ return Db2Constants.SQL_PARAM_INPUT;
+ }
+ }
+
+ private void InitMem(int memSize, ref IntPtr ptr){
+ if (ptr.ToInt32() == 0){
+ unsafe{
+ fixed(byte* arr = new byte[memSize]){
+ ptr = new IntPtr(arr);
+ }
+ }
+ }
+ }
+ internal void GetOutValue(){
+ switch ((int)db2DataType)
+ {
+ case Db2Constants.SQL_INTEGER:
+ dataVal = Marshal.PtrToStructure(DataValPtr, typeof(int));
+ break;
+ case Db2Constants.SQL_VARCHAR:
+
+ dataVal = Marshal.PtrToStringAnsi(DataValPtr);
+ break;
+ case Db2Constants.SQL_DECIMAL:
+ //dataVal = Marshal.PtrToStructure(bDataVal, typeof(decimal));
+ dataVal = Marshal.PtrToStringAnsi(DataValPtr);
+
+ break;
+ default:
+ throw new Db2Exception("Unknown data type");
+ }
+ }
+ }
+}
diff --git a/mcs/class/System.Data.Db2Client/System.Data.Db2Client/Db2ParameterCollection.cs b/mcs/class/System.Data.Db2Client/System.Data.Db2Client/Db2ParameterCollection.cs
new file mode 100644
index 00000000000..52385740dc0
--- /dev/null
+++ b/mcs/class/System.Data.Db2Client/System.Data.Db2Client/Db2ParameterCollection.cs
@@ -0,0 +1,103 @@
+using System;
+using System.Data;
+using System.Collections;
+using System.Globalization;
+
+
+namespace System.Data.Db2Client
+{
+
+ public class Db2ParameterCollection : ArrayList, IDataParameterCollection
+ {
+ IntPtr hwndStmt = IntPtr.Zero;
+
+ internal IntPtr HwndStmt{
+ set{
+ hwndStmt = value;
+ }
+ }
+ public object this[string index]
+ {
+ get
+ {
+ return this[IndexOf(index)];
+ }
+ set
+ {
+ this[IndexOf(index)] = value;
+ }
+ }
+ public bool Contains(string paramName)
+ {
+ return(-1 != IndexOf(paramName));
+ }
+
+ public int IndexOf(string paramName)
+ {
+ int index = 0;
+ foreach(Db2Parameter item in this)
+ {
+ if (0 == _cultureAwareCompare(item.ParameterName, paramName))
+ {
+ return index;
+ }
+ index++;
+ }
+ return -1;
+ }
+
+ public void RemoveAt(string paramName)
+ {
+ RemoveAt(IndexOf(paramName));
+ }
+
+ public override int Add(object value)
+ {
+ return Add((Db2Parameter)value);
+ }
+
+ public int Add(Db2Parameter value)
+ {
+ if (((Db2Parameter)value).ParameterName != null)
+ {
+
+ int result = base.Add(value);
+ //value.Bind(hwndStmt, (short)this.Count);
+ //Console.WriteLine("{0}", this.Count.ToString());
+ return result;
+ }
+ else
+ throw new ArgumentException("parameter must be named");
+ }
+
+ public int Add(string paramName, DbType type)
+ {
+ return Add(new Db2Parameter(paramName, type));
+ }
+
+ public int Add(string paramName, object value)
+ {
+ return Add(new Db2Parameter(paramName, value));
+ }
+
+ public int Add(string paramName, DbType dbType, string sourceColumn)
+ {
+ return Add(new Db2Parameter(paramName, dbType, sourceColumn));
+ }
+
+ private int _cultureAwareCompare(string strA, string strB)
+ {
+ return CultureInfo.CurrentCulture.CompareInfo.Compare(strA, strB, CompareOptions.IgnoreKanaType | CompareOptions.IgnoreWidth | CompareOptions.IgnoreCase);
+ }
+
+ internal void GetOutValues(){
+ foreach(Db2Parameter param in this){
+ if(ParameterDirection.Output == param.Direction){
+ param.GetOutValue();
+ //Console.WriteLine(param.ParameterName);
+ }
+ }
+ }
+ }
+}
+
diff --git a/mcs/class/System.Data.Db2Client/System.Data.Db2Client/Db2RowUpdatedEventArgs.cs b/mcs/class/System.Data.Db2Client/System.Data.Db2Client/Db2RowUpdatedEventArgs.cs
new file mode 100644
index 00000000000..998ad398492
--- /dev/null
+++ b/mcs/class/System.Data.Db2Client/System.Data.Db2Client/Db2RowUpdatedEventArgs.cs
@@ -0,0 +1,17 @@
+using System;
+using System.Data;
+using System.Data.Common;
+
+namespace System.Data.Db2Client {
+ public sealed class Db2RowUpdatedEventArgs : RowUpdatedEventArgs
+ {
+ public Db2RowUpdatedEventArgs (DataRow row, IDbCommand command, StatementType statementType, DataTableMapping tableMapping)
+ : base (row, command, statementType, tableMapping)
+ {
+ }
+
+ public new Db2Command Command {
+ get { return (Db2Command) base.Command; }
+ }
+ }
+} \ No newline at end of file
diff --git a/mcs/class/System.Data.Db2Client/System.Data.Db2Client/Db2RowUpdatedEventHandler.cs b/mcs/class/System.Data.Db2Client/System.Data.Db2Client/Db2RowUpdatedEventHandler.cs
new file mode 100644
index 00000000000..7972645df8c
--- /dev/null
+++ b/mcs/class/System.Data.Db2Client/System.Data.Db2Client/Db2RowUpdatedEventHandler.cs
@@ -0,0 +1,5 @@
+using System;
+
+namespace System.Data.Db2Client {
+ public delegate void Db2RowUpdatedEventHandler (object sender, Db2RowUpdatedEventArgs e);
+} \ No newline at end of file
diff --git a/mcs/class/System.Data.Db2Client/System.Data.Db2Client/Db2RowUpdatingEventArgs.cs b/mcs/class/System.Data.Db2Client/System.Data.Db2Client/Db2RowUpdatingEventArgs.cs
new file mode 100644
index 00000000000..1f075f019e2
--- /dev/null
+++ b/mcs/class/System.Data.Db2Client/System.Data.Db2Client/Db2RowUpdatingEventArgs.cs
@@ -0,0 +1,19 @@
+using System;
+using System.Data;
+using System.Data.Common;
+
+namespace System.Data.Db2Client {
+ public sealed class Db2RowUpdatingEventArgs : RowUpdatingEventArgs
+ {
+ public Db2RowUpdatingEventArgs (DataRow row, IDbCommand command, StatementType statementType, DataTableMapping tableMapping)
+ : base (row, command, statementType, tableMapping)
+ {
+ }
+
+ public new Db2Command Command {
+ get { return (Db2Command) base.Command; }
+ set { base.Command = value; }
+ }
+
+ }
+} \ No newline at end of file
diff --git a/mcs/class/System.Data.Db2Client/System.Data.Db2Client/Db2RowUpdatingEventHandler.cs b/mcs/class/System.Data.Db2Client/System.Data.Db2Client/Db2RowUpdatingEventHandler.cs
new file mode 100644
index 00000000000..a274b1f5615
--- /dev/null
+++ b/mcs/class/System.Data.Db2Client/System.Data.Db2Client/Db2RowUpdatingEventHandler.cs
@@ -0,0 +1,5 @@
+using System;
+
+namespace System.Data.Db2Client {
+ public delegate void Db2RowUpdatingEventHandler(object sender, Db2RowUpdatingEventArgs e);
+} \ No newline at end of file
diff --git a/mcs/class/System.Data.Db2Client/System.Data.Db2Client/Db2Transaction.cs b/mcs/class/System.Data.Db2Client/System.Data.Db2Client/Db2Transaction.cs
new file mode 100644
index 00000000000..613da892f7c
--- /dev/null
+++ b/mcs/class/System.Data.Db2Client/System.Data.Db2Client/Db2Transaction.cs
@@ -0,0 +1,93 @@
+using System;
+using System.Data;
+using System.Runtime.InteropServices;
+
+namespace System.Data.Db2Client
+{
+ public class Db2Transaction : IDbTransaction
+ {
+ IsolationLevel IL = IsolationLevel.Unspecified;
+ Db2Connection db2Conn;
+ public Db2Transaction(Db2Connection con, IsolationLevel isoL)
+ {
+ long db2IsoL = Db2Constants.SQL_TXN_READ_COMMITTED;
+ db2Conn = con;
+ short sqlRet;
+
+ switch (isoL)
+ {
+ case System.Data.IsolationLevel.Chaos: //No Db2equivalent, default to SQL_TXN_READ_COMMITTED
+ break;
+ case System.Data.IsolationLevel.ReadCommitted: //SQL_TXN_READ_COMMITTED
+ db2IsoL = Db2Constants.SQL_TXN_READ_COMMITTED;
+ break;
+ case System.Data.IsolationLevel.ReadUncommitted: //SQL_TXN_READ_UNCOMMITTED
+ db2IsoL = Db2Constants.SQL_TXN_READ_UNCOMMITTED;
+ break;
+ case System.Data.IsolationLevel.RepeatableRead: //SQL_TXN_REPEATABLE_READ
+ db2IsoL = Db2Constants.SQL_TXN_REPEATABLE_READ;
+ break;
+ case System.Data.IsolationLevel.Serializable: //SQL_TXN_SERIALIZABLE_READ
+ db2IsoL = Db2Constants.SQL_TXN_SERIALIZABLE_READ;
+ break;
+ }
+
+ IL = isoL;
+ IntPtr iso = new IntPtr(db2IsoL);
+ IntPtr attr = new IntPtr(Db2Constants.SQL_AUTOCOMMIT_OFF);
+ sqlRet = Db2CLIWrapper.SQLSetConnectAttr(db2Conn.DBHandle, Db2Constants.SQL_AUTOCOMMIT, attr, 0);
+ Db2ClientUtils.Db2CheckReturn(sqlRet, Db2Constants.SQL_HANDLE_DBC, db2Conn.DBHandle, "Error setting AUTOCOMMIT OFF in transaction CTOR.");
+//
+
+ }
+
+ /// <summary>
+ /// Db2Connection associated with this transaction
+ /// </summary>
+ public IDbConnection Connection
+ {
+ get
+ {
+ return db2Conn;
+ }
+ }
+ /// <summary>
+ /// IsolationLevel property
+ /// </summary>
+ ///
+ public IsolationLevel IsolationLevel
+ {
+ get
+ {
+ return IL;
+ }
+ }
+
+ public void Commit() {
+ Db2CLIWrapper.SQLEndTran(Db2Constants.SQL_HANDLE_DBC, db2Conn.DBHandle, Db2Constants.SQL_COMMIT);
+ this.db2Conn.WeakRefTransaction = null;
+ this.db2Conn = null;
+ }
+
+ public void Rollback()
+ {
+ Db2CLIWrapper.SQLEndTran(Db2Constants.SQL_HANDLE_DBC, db2Conn.DBHandle, Db2Constants.SQL_ROLLBACK);
+ this.db2Conn.WeakRefTransaction = null;
+ this.db2Conn = null;
+ }
+
+ /// <summary>
+ /// Dispose method.
+ /// </summary>
+ private bool Done = false;
+ public void Dispose()
+ {
+ if (Done)
+ return;
+ Rollback();
+ IL = IsolationLevel.Unspecified;
+ db2Conn = null;
+ Done = true;
+ }
+ }
+}
diff --git a/mcs/class/System.Data.Db2Client/System.Data.Db2Client_test.dll.sources b/mcs/class/System.Data.Db2Client/System.Data.Db2Client_test.dll.sources
new file mode 100644
index 00000000000..e69de29bb2d
--- /dev/null
+++ b/mcs/class/System.Data.Db2Client/System.Data.Db2Client_test.dll.sources
diff --git a/mcs/class/System.Data.ObjectSpaces/Assembly/AssemblyInfo.cs b/mcs/class/System.Data.ObjectSpaces/Assembly/AssemblyInfo.cs
new file mode 100644
index 00000000000..93d88135e04
--- /dev/null
+++ b/mcs/class/System.Data.ObjectSpaces/Assembly/AssemblyInfo.cs
@@ -0,0 +1,48 @@
+//
+// AssemblyInfo.cs
+//
+// Author:
+// Andreas Nahr (ClassDevelopment@A-SoftTech.com)
+//
+// (C) 2003 Ximian, Inc. http://www.ximian.com
+//
+
+using System;
+using System.Reflection;
+using System.Resources;
+using System.Security;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about the system assembly
+
+#if (NET_1_0)
+ [assembly: AssemblyVersion("1.0.3300.0")]
+ [assembly: SatelliteContractVersion("1.0.3300.0")]
+#endif
+#if (NET_1_1)
+ [assembly: AssemblyVersion("1.0.5000.0")]
+ [assembly: SatelliteContractVersion("1.0.5000.0")]
+ [assembly: ComCompatibleVersion(1, 0, 3300, 0)]
+ [assembly: TypeLibVersion(1, 10)]
+#endif
+
+[assembly: AssemblyTitle("System.Data.ObjectSpaces.dll")]
+[assembly: AssemblyDescription("System.Data.ObjectSpaces.dll")]
+[assembly: AssemblyConfiguration("Development version")]
+[assembly: AssemblyCompany("MONO development team")]
+[assembly: AssemblyProduct("MONO CLI")]
+[assembly: AssemblyCopyright("(c) 2003 Various Authors")]
+[assembly: AssemblyTrademark("")]
+
+// FIXME Add once compliance is reached
+//[assembly: CLSCompliant(true)]
+[assembly: AssemblyDefaultAlias("System.Data.ObjectSpaces.dll")]
+[assembly: AssemblyInformationalVersion("0.0.0.1")]
+[assembly: NeutralResourcesLanguage("en-US")]
+
+[assembly: ComVisible(false)]
+[assembly: AllowPartiallyTrustedCallers]
+
+//[assembly: AssemblyDelaySign(false)]
+//[assembly: AssemblyKeyFile("")]
diff --git a/mcs/class/System.Data.ObjectSpaces/Assembly/ChangeLog b/mcs/class/System.Data.ObjectSpaces/Assembly/ChangeLog
new file mode 100644
index 00000000000..017e946b62f
--- /dev/null
+++ b/mcs/class/System.Data.ObjectSpaces/Assembly/ChangeLog
@@ -0,0 +1,4 @@
+2003-11-26 Tim Coleman <tim@timcoleman.com>
+ * AssemblyInfo.cs: Added
+ * ChangeLog: Added
+ * Locale.cs: Added
diff --git a/mcs/class/System.Data.ObjectSpaces/Assembly/Locale.cs b/mcs/class/System.Data.ObjectSpaces/Assembly/Locale.cs
new file mode 100644
index 00000000000..a456449296f
--- /dev/null
+++ b/mcs/class/System.Data.ObjectSpaces/Assembly/Locale.cs
@@ -0,0 +1,24 @@
+//
+// Locale.cs
+//
+// Author:
+// Miguel de Icaza (miguel@ximian.com)
+// Andreas Nahr (ClassDevelopment@A-SoftTech.com)
+//
+// (C) 2001 - 2003 Ximian, Inc (http://www.ximian.com)
+//
+
+internal sealed class Locale {
+
+ private Locale ()
+ {
+ }
+
+ /// <summary>
+ /// Returns the translated message for the current locale
+ /// </summary>
+ public static string GetText (string msg)
+ {
+ return msg;
+ }
+}
diff --git a/mcs/class/System.Data.ObjectSpaces/ChangeLog b/mcs/class/System.Data.ObjectSpaces/ChangeLog
new file mode 100644
index 00000000000..f6aee7bab00
--- /dev/null
+++ b/mcs/class/System.Data.ObjectSpaces/ChangeLog
@@ -0,0 +1,71 @@
+2003-11-27 Tim Coleman <tim@timcoleman.com>
+ * System.Data.ObjectSpaces.Query/ObjectExpression.cs:
+ * System.Data.ObjectSpaces.Query/ObjectSpaceNode.cs:
+ * System.Data.ObjectSpaces_test.dll.sources:
+ Various updates for completion
+
+2003-11-26 Tim Coleman <tim@timcoleman.com>
+ * System.Data.ObjectSpaces_test.dll.sources:
+ * Makefile:
+ Add stuff for tests
+ * System.Data.ObjectSpaces/PersistenceError.cs:
+ * System.Data.ObjectSpaces/PersistenceException.cs:
+ * System.Data.ObjectSpaces.Schema/ExtendedProperty.cs:
+ * System.Data.ObjectSpaces.Schema/ExtendedPropertyCollection.cs:
+ * System.Data.ObjectSpaces.Schema/ObjectRelationship.cs:
+ * System.Data.ObjectSpaces.Schema/ObjectRelationshipCollection.cs:
+ * System.Data.ObjectSpaces.Schema/ObjectRelationshipType.cs:
+ * System.Data.ObjectSpaces.Schema/SchemaClass.cs:
+ * System.Data.ObjectSpaces.Schema/SchemaClassCollection.cs:
+ * System.Data.ObjectSpaces.Schema/SchemaMember.cs:
+ * System.Data.ObjectSpaces.Schema/SchemaMemberCollection.cs:
+ * System.Data.ObjectSpaces.dll.sources:
+ New class stubs added
+ * System.Data.ObjectSpaces/CommonObjectContext.cs:
+ * System.Data.ObjectSpaces/ContextException.cs:
+ * System.Data.ObjectSpaces/DbObjectReader.cs:
+ * System.Data.ObjectSpaces/ObjectContext.cs:
+ * System.Data.ObjectSpaces/ObjectException.cs:
+ * System.Data.ObjectSpaces/ObjectKeyManager.cs:
+ * System.Data.ObjectSpaces/ObjectList.cs:
+ * System.Data.ObjectSpaces/OneToManyRelationship.cs:
+ * System.Data.ObjectSpaces/OneToOneRelationship.cs:
+ * System.Data.ObjectSpaces.Schema/ObjectSchema.cs:
+ Updates to make more correct
+
+2003-11-25 Tim Coleman <tim@timcoleman.com>
+ * System.Data.ObjectSpaces/PersistenceErrorBehaviour.cs:
+ * System.Data.ObjectSpaces/PersisteneceErrorType.cs:
+ Remove misnamed class files
+ * System.Data.ObjectSpaces/ObjectException.cs:
+ * System.Data.ObjectSpaces/ObjectQuery.cs:
+ * System.Data.ObjectSpaces/ObjectSet.cs:
+ * System.Data.ObjectSpaces/ObjectSources.cs:
+ * System.Data.ObjectSpaces/PersistenceErrorBehavior.cs:
+ * System.Data.ObjectSpaces/PersistenceErrorType.cs:
+ * System.Data.ObjectSpaces/PersistenceOptions.cs:
+ New stubs created to get things to compile
+ * Makefile:
+ Add new dependencies
+ * System.Data.ObjectSpaces/ASTBaseParser.cs:
+ * System.Data.ObjectSpaces/CommonObjectContext.cs:
+ * System.Data.ObjectSpaces/DbObjectReader.cs:
+ * System.Data.ObjectSpaces/DynamicAssembly.cs:
+ * System.Data.ObjectSpaces/IObjectHelper.cs:
+ * System.Data.ObjectSpaces/IObjectNotification.cs:
+ * System.Data.ObjectSpaces/KeyGenerator.cs:
+ * System.Data.ObjectSpaces/ObjectContext.cs:
+ * System.Data.ObjectSpaces/ObjectEngine.cs:
+ * System.Data.ObjectSpaces/ObjectKeyManager.cs:
+ * System.Data.ObjectSpaces/ObjectList.cs:
+ * System.Data.ObjectSpaces/ObjectReader.cs:
+ * System.Data.ObjectSpaces/ObjectSpace.cs:
+ * System.Data.ObjectSpaces/ValueRecord.cs:
+ * System.Data.ObjectSpaces.Query/Axis.cs:
+ Changes to get things to compile
+
+2003-11-15 Richard Thombs <stony@stony.org>
+
+ * Added initial System.Data.ObjectSpaces.Query stubs
+ * Added Makefile et al
+
diff --git a/mcs/class/System.Data.ObjectSpaces/Makefile b/mcs/class/System.Data.ObjectSpaces/Makefile
new file mode 100644
index 00000000000..9962da22a7b
--- /dev/null
+++ b/mcs/class/System.Data.ObjectSpaces/Makefile
@@ -0,0 +1,11 @@
+thisdir = class/System.Data.ObjectSpaces
+SUBDIRS =
+include ../../build/rules.make
+
+LIBRARY = System.Data.ObjectSpaces.dll
+LIB_MCS_FLAGS = /r:$(corlib),System.dll,System.Data.dll,System.Xml.dll,System.Data.SqlXml.dll
+TEST_MCS_FLAGS = $(LIB_MCS_FLAGS)
+
+EXTRA_DISTFILES =
+
+include ../../build/library.make
diff --git a/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Query/ASTQueryParser.cs b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Query/ASTQueryParser.cs
new file mode 100644
index 00000000000..2fc234d02e6
--- /dev/null
+++ b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Query/ASTQueryParser.cs
@@ -0,0 +1,58 @@
+//
+// System.Data.ObjectSpaces.Query.ASTQueryParser
+//
+//
+// Author:
+// Richard Thombs (stony@stony.org)
+//
+
+#if NET_1_2
+
+namespace System.Data.ObjectSpaces.Query
+{
+ [MonoTODO()]
+ public class ASTQueryParser : ASTBaseParser
+ {
+ public static Int16 AND;
+ public static Int16 ASCEND;
+ public static Int16 CAST;
+ public static Int16 CONST;
+ public static Int16 DESCEND;
+ public static Int16 FN_FILENAME;
+ public static Int16 FN_FILEPATH;
+ public static Int16 FN_ISNULL;
+ public static Int16 FN_LEN;
+ public static Int16 FN_SUBS;
+ public static Int16 FN_TRIM;
+ public static Int16 IDENT;
+ public static Int16 NEG;
+ public static Int16 NOT;
+ public static Int16 OP_EQ;
+ public static Int16 OP_GR;
+ public static Int16 OP_GT;
+ public static Int16 OP_IIF;
+ public static Int16 OP_IN;
+ public static Int16 OP_LE;
+ public static Int16 OP_LIKE;
+ public static Int16 OP_LT;
+ public static Int16 OP_NE;
+ public static Int16 OR;
+ public static Int16 PARAM;
+ public static Int16 PARENT;
+ public static Int16 REL;
+ public static Int16 YYERRCODE;
+
+ [MonoTODO()]
+ public ASTQueryParser() : base()
+ {
+ }
+
+ // Create an internal parse tree from the query string.
+ [MonoTODO()]
+ public override void Parse(string query)
+ {
+ }
+ }
+}
+
+#endif
diff --git a/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Query/Axis.cs b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Query/Axis.cs
new file mode 100644
index 00000000000..1c3c56c1a26
--- /dev/null
+++ b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Query/Axis.cs
@@ -0,0 +1,67 @@
+//
+// System.Data.ObjectSpaces.Query.Axis
+//
+//
+// Authors:
+// Richard Thombs (stony@stony.org)
+// Tim Coleman (tim@timcoleman.com)
+//
+
+#if NET_1_2
+
+using System.Xml;
+
+namespace System.Data.ObjectSpaces.Query
+{
+ [MonoTODO()]
+ public class Axis : Filter
+ {
+ [MonoTODO()]
+ public Axis(Expression source,Expression constraint) : base(source,constraint)
+ {
+ throw new NotImplementedException();
+ }
+
+ [MonoTODO()]
+ public override bool IsConst {
+ get { throw new NotImplementedException(); }
+ }
+
+ [MonoTODO()]
+ public override NodeType NodeType {
+ get { throw new NotImplementedException(); }
+ }
+
+ [MonoTODO()]
+ public override object Clone()
+ {
+ throw new NotImplementedException();
+ }
+
+ [MonoTODO()]
+ public override bool IsArithmetic()
+ {
+ throw new NotImplementedException();
+ }
+
+ [MonoTODO()]
+ public override bool IsBoolean()
+ {
+ throw new NotImplementedException();
+ }
+
+ [MonoTODO()]
+ public override bool IsFilter()
+ {
+ throw new NotImplementedException();
+ }
+
+ [MonoTODO()]
+ public override void WriteXml(XmlWriter xmlw)
+ {
+ throw new NotImplementedException();
+ }
+ }
+}
+
+#endif
diff --git a/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Query/Binary.cs b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Query/Binary.cs
new file mode 100644
index 00000000000..25de772d90d
--- /dev/null
+++ b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Query/Binary.cs
@@ -0,0 +1,104 @@
+//
+// System.Data.ObjectSpaces.Query.Binary
+//
+//
+// Author:
+// Richard Thombs (stony@stony.org)
+//
+
+#if NET_1_2
+
+using System.Xml;
+
+namespace System.Data.ObjectSpaces.Query
+{
+ [MonoTODO()]
+ public class Binary : Expression
+ {
+ [MonoTODO()]
+ public Binary(Expression left,Expression right,BinaryOperator _operator) : base()
+ {
+ throw new NotImplementedException();
+ }
+
+ [MonoTODO()]
+ public override object Clone()
+ {
+ throw new NotImplementedException();
+ }
+
+ [MonoTODO()]
+ public static Int64 Compare(object vLeft,object vRight,Type type,BinaryOperator op)
+ {
+ throw new NotImplementedException();
+ }
+
+ [MonoTODO()]
+ public static object EvaluateConstant(Literal left,BinaryOperator op,Literal right)
+ {
+ throw new NotImplementedException();
+ }
+
+ [MonoTODO()]
+ public static bool IsInteger(Type type)
+ {
+ throw new NotImplementedException();
+ }
+
+ [MonoTODO()]
+ public static bool IsOperatorArithmetic(BinaryOperator op)
+ {
+ throw new NotImplementedException();
+ }
+
+ [MonoTODO()]
+ public static bool IsOperatorBoolean(BinaryOperator op)
+ {
+ throw new NotImplementedException();
+ }
+
+ [MonoTODO()]
+ public static bool IsOperatorLogical(BinaryOperator op)
+ {
+ throw new NotImplementedException();
+ }
+
+ [MonoTODO()]
+ public static bool IsOperatorRelational(BinaryOperator op)
+ {
+ throw new NotImplementedException();
+ }
+
+ [MonoTODO()]
+ public override void WriteXml(XmlWriter xmlw)
+ {
+ throw new NotImplementedException();
+ }
+
+ // Gets/sets the left operand of this binary expression
+ [MonoTODO()]
+ public Expression Left
+ {
+ get { throw new NotImplementedException(); }
+ set { throw new NotImplementedException(); }
+ }
+
+ // Gets/sets the operator used by this binary expression
+ [MonoTODO()]
+ public Expression Operator
+ {
+ get { throw new NotImplementedException(); }
+ set { throw new NotImplementedException(); }
+ }
+
+ // Gets/sets the right operand of this binary expression
+ [MonoTODO()]
+ public Expression Right
+ {
+ get { throw new NotImplementedException(); }
+ set { throw new NotImplementedException(); }
+ }
+ }
+}
+
+#endif
diff --git a/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Query/ChangeLog b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Query/ChangeLog
new file mode 100644
index 00000000000..84e4ad31bff
--- /dev/null
+++ b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Query/ChangeLog
@@ -0,0 +1,4 @@
+2003-11-15 Richard Thombs <stony@stony.org>
+
+ * Added class and constructor stubs for all classes
+
diff --git a/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Query/Conditional.cs b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Query/Conditional.cs
new file mode 100644
index 00000000000..a943b804825
--- /dev/null
+++ b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Query/Conditional.cs
@@ -0,0 +1,62 @@
+//
+// System.Data.ObjectSpaces.Query.Conditional
+//
+//
+// Author:
+// Richard Thombs (stony@stony.org)
+//
+
+#if NET_1_2
+
+using System.Xml;
+
+namespace System.Data.ObjectSpaces.Query
+{
+ [MonoTODO()]
+ public class Conditional : Expression
+ {
+ [MonoTODO()]
+ public Conditional(Expression condition,Expression tBranch,Expression fBranch) : base()
+ {
+ throw new NotImplementedException();
+ }
+
+ [MonoTODO()]
+ public override object Clone()
+ {
+ throw new NotImplementedException();
+ }
+
+ [MonoTODO()]
+ public override void WriteXml(XmlWriter xmlw)
+ {
+ throw new NotImplementedException();
+ }
+
+ // Gets/sets the condition expression
+ [MonoTODO()]
+ public Expression Condition
+ {
+ get { throw new NotImplementedException(); }
+ set { throw new NotImplementedException(); }
+ }
+
+ // Gets/sets the true branch expression
+ [MonoTODO()]
+ public Expression TBranch
+ {
+ get { throw new NotImplementedException(); }
+ set { throw new NotImplementedException(); }
+ }
+
+ // Gets/sets the false branch expression
+ [MonoTODO()]
+ public Expression FBranch
+ {
+ get { throw new NotImplementedException(); }
+ set { throw new NotImplementedException(); }
+ }
+ }
+}
+
+#endif
diff --git a/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Query/Context.cs b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Query/Context.cs
new file mode 100644
index 00000000000..8d68604b24f
--- /dev/null
+++ b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Query/Context.cs
@@ -0,0 +1,38 @@
+//
+// System.Data.ObjectSpaces.Query.Context
+//
+//
+// Author:
+// Richard Thombs (stony@stony.org)
+//
+
+#if NET_1_2
+
+using System.Xml;
+
+namespace System.Data.ObjectSpaces.Query
+{
+ [MonoTODO()]
+ public class Context : Expression
+ {
+ [MonoTODO()]
+ public Context() : base()
+ {
+ throw new NotImplementedException();
+ }
+
+ [MonoTODO()]
+ public override object Clone()
+ {
+ throw new NotImplementedException();
+ }
+
+ [MonoTODO()]
+ public override void WriteXml(XmlWriter xmlw)
+ {
+ throw new NotImplementedException();
+ }
+ }
+}
+
+#endif
diff --git a/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Query/Delegates.cs b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Query/Delegates.cs
new file mode 100644
index 00000000000..b941727caee
--- /dev/null
+++ b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Query/Delegates.cs
@@ -0,0 +1,16 @@
+//
+// System.Data.ObjectSpaces.Query delegates
+//
+//
+// Author:
+// Richard Thombs (stony@stony.org)
+//
+
+#if NET_1_2
+
+namespace System.Data.ObjectSpaces.Query
+{
+ public delegate void EnumNodesCallBack(Expression node,object[] opParams);
+}
+
+#endif
diff --git a/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Query/Empty.cs b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Query/Empty.cs
new file mode 100644
index 00000000000..fad48394528
--- /dev/null
+++ b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Query/Empty.cs
@@ -0,0 +1,24 @@
+//
+// System.Data.ObjectSpaces.Query.Empty
+//
+//
+// Author:
+// Richard Thombs (stony@stony.org)
+//
+
+#if NET_1_2
+
+namespace System.Data.ObjectSpaces.Query
+{
+ [MonoTODO()]
+ public class Empty : Expression
+ {
+ [MonoTODO()]
+ public override object Clone()
+ {
+ throw new NotImplementedException();
+ }
+ }
+}
+
+#endif
diff --git a/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Query/Enumerations.cs b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Query/Enumerations.cs
new file mode 100644
index 00000000000..c48acee8de9
--- /dev/null
+++ b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Query/Enumerations.cs
@@ -0,0 +1,113 @@
+//
+// System.Data.ObjectSpaces.Query enumerations
+//
+//
+// Author:
+// Richard Thombs (stony@stony.org)
+//
+
+#if NET_1_2
+
+namespace System.Data.ObjectSpaces.Query
+{
+ public enum AnnotationType
+ {
+ QilAnnotation,
+ ParseAnnotation,
+ AxisNode,
+ DebugInfo,
+ UserInterface
+ }
+
+ public enum BinaryOperator
+ {
+ LogicalAnd,
+ LogicalOr,
+ Equality,
+ Inequality,
+ LessThan,
+ LessEqual,
+ GreaterThan,
+ GreaterEqual,
+ Addition,
+ Subtraction,
+ Multiplication,
+ Division,
+ Modulus,
+ Concatenation
+ }
+
+ public enum FunctionOperator
+ {
+ Trim,
+ Len,
+ Like,
+ Substring
+ }
+
+ public enum LiteralType
+ {
+ String,
+ SByte,
+ Byte,
+ Int16,
+ Int32,
+ Int64,
+ UInt16,
+ UInt32,
+ UInt64,
+ Char,
+ Single,
+ Double,
+ Boolean,
+ Decimal,
+ Guid,
+ DateTime,
+ TimeSpan
+ }
+
+ public enum NodeType
+ {
+ Aggregate,
+ Axis,
+ Binary,
+ Conditional,
+ Context,
+ Distinct,
+ Empty,
+ Expression,
+ Filter,
+ Function,
+ Join,
+ InOperator,
+ Literal,
+ ObjectSpaceNode,
+ OrderBy,
+ Parameter,
+ Parent,
+ Projection,
+ Property,
+ RelTraversal,
+ Span,
+ Reference,
+ TypeCast,
+ TypeConversion,
+ Unary
+ }
+
+ public enum RelTraversalDirection
+ {
+ ToTarget,
+ ToSource
+ }
+
+ public enum UnaryOperator
+ {
+ Negation,
+ LogicalNot,
+ IsNull,
+ Exists
+ }
+}
+
+#endif
diff --git a/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Query/Expression.cs b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Query/Expression.cs
new file mode 100644
index 00000000000..f0c849a2dd6
--- /dev/null
+++ b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Query/Expression.cs
@@ -0,0 +1,115 @@
+//
+// System.Data.ObjectSpaces.Query.Expression
+//
+//
+// Author:
+// Richard Thombs (stony@stony.org)
+//
+
+#if NET_1_2
+
+using System.Xml;
+
+namespace System.Data.ObjectSpaces.Query
+{
+ [MonoTODO()]
+ public abstract class Expression : ICloneable
+ {
+ public Expression parent;
+
+ [MonoTODO()]
+ protected Expression()
+ {
+ throw new NotImplementedException();
+ }
+
+ public abstract object Clone();
+
+ [MonoTODO()]
+ public static void EnumNodes(Expression root,EnumNodesCallBack callback)
+ {
+ throw new NotImplementedException();
+ }
+
+ [MonoTODO()]
+ public static void EnumNodes(Expression root,EnumNodesCallBack callback,object[] oParams)
+ {
+ throw new NotImplementedException();
+ }
+
+ [MonoTODO()]
+ public object GetAnnotation(AnnotationType annotationType)
+ {
+ throw new NotImplementedException();
+ }
+
+ [MonoTODO()]
+ public virtual bool IsArithmetic()
+ {
+ throw new NotImplementedException();
+ }
+
+ [MonoTODO()]
+ public virtual bool IsBoolean()
+ {
+ throw new NotImplementedException();
+ }
+
+ [MonoTODO()]
+ public virtual bool IsFilter()
+ {
+ throw new NotImplementedException();
+ }
+
+ [MonoTODO()]
+ public static void Replace(Expression oldNode,Expression newNode)
+ {
+ throw new NotImplementedException();
+ }
+
+ [MonoTODO()]
+ public void SetAnnotation(AnnotationType annotationType,object o)
+ {
+ throw new NotImplementedException();
+ }
+
+ [MonoTODO()]
+ public string ToXmlString()
+ {
+ throw new NotImplementedException();
+ }
+
+ [MonoTODO()]
+ public virtual void WriteXml(XmlWriter xmlw)
+ {
+ throw new NotImplementedException();
+ }
+
+ [MonoTODO()]
+ public virtual bool IsConst
+ {
+ get { throw new NotImplementedException(); }
+ }
+
+ [MonoTODO()]
+ public virtual NodeType NodeType
+ {
+ get { throw new NotImplementedException(); }
+ }
+
+ [MonoTODO()]
+ public Expression Owner
+ {
+ get { throw new NotImplementedException(); }
+ }
+
+ [MonoTODO()]
+ public virtual Type ValueType
+ {
+ get { throw new NotImplementedException(); }
+ }
+
+ }
+}
+
+#endif
diff --git a/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Query/Filter.cs b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Query/Filter.cs
new file mode 100644
index 00000000000..0a72d85e6a5
--- /dev/null
+++ b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Query/Filter.cs
@@ -0,0 +1,30 @@
+//
+// System.Data.ObjectSpaces.Query.Filter
+//
+//
+// Author:
+// Richard Thombs (stony@stony.org)
+//
+
+#if NET_1_2
+
+namespace System.Data.ObjectSpaces.Query
+{
+ [MonoTODO()]
+ public class Filter : Expression
+ {
+ [MonoTODO()]
+ public Filter(Expression source,Expression constraint) : base()
+ {
+ throw new NotImplementedException();
+ }
+
+ [MonoTODO()]
+ public override object Clone()
+ {
+ throw new NotImplementedException();
+ }
+ }
+}
+
+#endif
diff --git a/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Query/Function.cs b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Query/Function.cs
new file mode 100644
index 00000000000..1bb222f41b5
--- /dev/null
+++ b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Query/Function.cs
@@ -0,0 +1,30 @@
+//
+// System.Data.ObjectSpaces.Query.Function
+//
+//
+// Author:
+// Richard Thombs (stony@stony.org)
+//
+
+#if NET_1_2
+
+namespace System.Data.ObjectSpaces.Query
+{
+ [MonoTODO()]
+ public class Function : Expression
+ {
+ [MonoTODO()]
+ public Function(FunctionOperator _operator,Expression[] _params) : base()
+ {
+ throw new NotImplementedException();
+ }
+
+ [MonoTODO()]
+ public override object Clone()
+ {
+ throw new NotImplementedException();
+ }
+ }
+}
+
+#endif
diff --git a/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Query/Literal.cs b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Query/Literal.cs
new file mode 100644
index 00000000000..c142a6dbeeb
--- /dev/null
+++ b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Query/Literal.cs
@@ -0,0 +1,24 @@
+//
+// System.Data.ObjectSpaces.Query.Literal
+//
+//
+// Author:
+// Richard Thombs (stony@stony.org)
+//
+
+#if NET_1_2
+
+namespace System.Data.ObjectSpaces.Query
+{
+ [MonoTODO()]
+ public class Literal : Expression
+ {
+ [MonoTODO()]
+ public override object Clone()
+ {
+ throw new NotImplementedException();
+ }
+ }
+}
+
+#endif
diff --git a/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Query/OPath.cs b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Query/OPath.cs
new file mode 100644
index 00000000000..23b03a5891d
--- /dev/null
+++ b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Query/OPath.cs
@@ -0,0 +1,25 @@
+//
+// System.Data.ObjectSpaces.Query.OPath
+//
+//
+// Author:
+// Richard Thombs (stony@stony.org)
+//
+
+#if NET_1_2
+
+using System.Data.ObjectSpaces.Schema;
+
+namespace System.Data.ObjectSpaces.Query
+{
+ [MonoTODO()]
+ public class OPath
+ {
+ public static ObjectExpression Parse(ObjectQuery oq,ObjectSchema objectSchema)
+ {
+ throw new NotImplementedException();
+ }
+ }
+}
+
+#endif
diff --git a/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Query/ObjectExpression.cs b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Query/ObjectExpression.cs
new file mode 100644
index 00000000000..6392ef2c30a
--- /dev/null
+++ b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Query/ObjectExpression.cs
@@ -0,0 +1,66 @@
+//
+// System.Data.ObjectSpaces.Query.ObjectExpression
+//
+//
+// Author:
+// Richard Thombs (stony@stony.org)
+// Tim Coleman (tim@timcoleman.com)
+//
+// Copyright (C) Tim Coleman, 2003
+//
+
+#if NET_1_2
+
+using System.Data.ObjectSpaces;
+
+namespace System.Data.ObjectSpaces.Query {
+ public class ObjectExpression
+ {
+ #region Fields
+
+ Expression expression;
+ ObjectSchema objectSchema;
+
+ #endregion // Fields
+
+ #region Constructors
+
+ [MonoTODO]
+ public ObjectExpression (Expression expression, ObjectSchema objectSchama)
+ {
+ this.expression = expression;
+ this.objectSchema = objectSchema;
+ }
+
+ #endregion // Constructors
+
+ #region Properties
+
+ public Expression Expression {
+ get { return expression; }
+ }
+
+ public ObjectSchema ObjectSchema {
+ get { return objectSchema; }
+ }
+
+ [MonoTODO]
+ public Type ObjectType {
+ get { throw new NotImplementedException (); }
+ }
+
+ #endregion // Properties
+
+ #region Methods
+
+ [MonoTODO]
+ public CompiledQuery Compile (MappingSchema map)
+ {
+ throw new NotImplementedException ();
+ }
+
+ #endregion // Methods
+ }
+}
+
+#endif
diff --git a/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Query/ObjectSpaceNode.cs b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Query/ObjectSpaceNode.cs
new file mode 100644
index 00000000000..f92c649a4cd
--- /dev/null
+++ b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Query/ObjectSpaceNode.cs
@@ -0,0 +1,38 @@
+//
+// System.Data.ObjectSpaces.Query.ObjectSpaceNode
+//
+//
+// Author:
+// Richard Thombs (stony@stony.org)
+// Tim Coleman (tim@timcoleman.com)
+//
+// Copyright (C) Tim Coleman, 2003
+//
+
+#if NET_1_2
+
+namespace System.Data.ObjectSpaces.Query {
+ public class ObjectSpaceNode : Expression
+ {
+ #region Constructors
+
+ public ObjectSpaceNode ()
+ : base ()
+ {
+ }
+
+ #endregion
+
+ #region Methods
+
+ [MonoTODO()]
+ public override object Clone()
+ {
+ throw new NotImplementedException();
+ }
+
+ #endregion // Methods
+ }
+}
+
+#endif
diff --git a/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Query/OrderBy.cs b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Query/OrderBy.cs
new file mode 100644
index 00000000000..5f8191dc21a
--- /dev/null
+++ b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Query/OrderBy.cs
@@ -0,0 +1,30 @@
+//
+// System.Data.ObjectSpaces.Query.OrderBy
+//
+//
+// Author:
+// Richard Thombs (stony@stony.org)
+//
+
+#if NET_1_2
+
+namespace System.Data.ObjectSpaces.Query
+{
+ [MonoTODO()]
+ public class OrderBy : Expression
+ {
+ [MonoTODO()]
+ public OrderBy(Expression source,OrderByItemCollection orderByItems)
+ {
+ throw new NotImplementedException();
+ }
+
+ [MonoTODO()]
+ public override object Clone()
+ {
+ throw new NotImplementedException();
+ }
+ }
+}
+
+#endif
diff --git a/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Query/OrderByItem.cs b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Query/OrderByItem.cs
new file mode 100644
index 00000000000..63ed39d8d11
--- /dev/null
+++ b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Query/OrderByItem.cs
@@ -0,0 +1,24 @@
+//
+// System.Data.ObjectSpaces.Query.OrderByItem
+//
+//
+// Author:
+// Richard Thombs (stony@stony.org)
+//
+
+#if NET_1_2
+
+namespace System.Data.ObjectSpaces.Query
+{
+ [MonoTODO()]
+ public class OrderByItem
+ {
+ [MonoTODO()]
+ public OrderByItem(string item,bool ascendent)
+ {
+ throw new NotImplementedException();
+ }
+ }
+}
+
+#endif
diff --git a/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Query/OrderByItemCollection.cs b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Query/OrderByItemCollection.cs
new file mode 100644
index 00000000000..c74ac201172
--- /dev/null
+++ b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Query/OrderByItemCollection.cs
@@ -0,0 +1,26 @@
+//
+// System.Data.ObjectSpaces.Query.OrderByItemCollection
+//
+//
+// Author:
+// Richard Thombs (stony@stony.org)
+//
+
+#if NET_1_2
+
+using System.Collections;
+
+namespace System.Data.ObjectSpaces.Query
+{
+ [MonoTODO()]
+ public class OrderByItemCollection : CollectionBase
+ {
+ [MonoTODO()]
+ public OrderByItemCollection() : base()
+ {
+ throw new NotImplementedException();
+ }
+ }
+}
+
+#endif
diff --git a/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Query/Parameter.cs b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Query/Parameter.cs
new file mode 100644
index 00000000000..a26391a6922
--- /dev/null
+++ b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Query/Parameter.cs
@@ -0,0 +1,30 @@
+//
+// System.Data.ObjectSpaces.Query.Parameter
+//
+//
+// Author:
+// Richard Thombs (stony@stony.org)
+//
+
+#if NET_1_2
+
+namespace System.Data.ObjectSpaces.Query
+{
+ [MonoTODO()]
+ public class Parameter : Expression
+ {
+ [MonoTODO()]
+ public Parameter(int ordinal)
+ {
+ throw new NotImplementedException();
+ }
+
+ [MonoTODO()]
+ public override object Clone()
+ {
+ throw new NotImplementedException();
+ }
+ }
+}
+
+#endif
diff --git a/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Query/Parent.cs b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Query/Parent.cs
new file mode 100644
index 00000000000..0db4b1f77e3
--- /dev/null
+++ b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Query/Parent.cs
@@ -0,0 +1,24 @@
+//
+// System.Data.ObjectSpaces.Query.Parent
+//
+//
+// Author:
+// Richard Thombs (stony@stony.org)
+//
+
+#if NET_1_2
+
+namespace System.Data.ObjectSpaces.Query
+{
+ [MonoTODO()]
+ public class Parent : Context
+ {
+ [MonoTODO()]
+ public Parent(Context sContext) : base()
+ {
+ throw new NotImplementedException();
+ }
+ }
+}
+
+#endif
diff --git a/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Query/Property.cs b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Query/Property.cs
new file mode 100644
index 00000000000..c49320b8bde
--- /dev/null
+++ b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Query/Property.cs
@@ -0,0 +1,30 @@
+//
+// System.Data.ObjectSpaces.Query.Property
+//
+//
+// Author:
+// Richard Thombs (stony@stony.org)
+//
+
+#if NET_1_2
+
+namespace System.Data.ObjectSpaces.Query
+{
+ [MonoTODO()]
+ public class Property : Expression
+ {
+ [MonoTODO()]
+ public Property(Expression source,string name) : base()
+ {
+ throw new NotImplementedException();
+ }
+
+ [MonoTODO()]
+ public override object Clone()
+ {
+ throw new NotImplementedException();
+ }
+ }
+}
+
+#endif
diff --git a/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Query/RelTraversal.cs b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Query/RelTraversal.cs
new file mode 100644
index 00000000000..97f7f500b0e
--- /dev/null
+++ b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Query/RelTraversal.cs
@@ -0,0 +1,36 @@
+//
+// System.Data.ObjectSpaces.Query.RelTraversal
+//
+//
+// Author:
+// Richard Thombs (stony@stony.org)
+//
+
+#if NET_1_2
+
+namespace System.Data.ObjectSpaces.Query
+{
+ [MonoTODO()]
+ public class RelTraversal : Expression
+ {
+ [MonoTODO()]
+ public RelTraversal(RelTraversalDirection direction) : base()
+ {
+ throw new NotImplementedException();
+ }
+
+ [MonoTODO()]
+ public RelTraversal(string relName,RelTraversalDirection direction) : base()
+ {
+ throw new NotImplementedException();
+ }
+
+ [MonoTODO()]
+ public override object Clone()
+ {
+ throw new NotImplementedException();
+ }
+ }
+}
+
+#endif
diff --git a/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Query/Span.cs b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Query/Span.cs
new file mode 100644
index 00000000000..4308b26acc9
--- /dev/null
+++ b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Query/Span.cs
@@ -0,0 +1,30 @@
+//
+// System.Data.ObjectSpaces.Query.Span
+//
+//
+// Author:
+// Richard Thombs (stony@stony.org)
+//
+
+#if NET_1_2
+
+namespace System.Data.ObjectSpaces.Query
+{
+ [MonoTODO()]
+ public class Span : Expression
+ {
+ [MonoTODO()]
+ public Span(Expression source,SpanPropertyCollection spanProperties) : base()
+ {
+ throw new NotImplementedException();
+ }
+
+ [MonoTODO()]
+ public override object Clone()
+ {
+ throw new NotImplementedException();
+ }
+ }
+}
+
+#endif
diff --git a/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Query/SpanProperty.cs b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Query/SpanProperty.cs
new file mode 100644
index 00000000000..a521cc44761
--- /dev/null
+++ b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Query/SpanProperty.cs
@@ -0,0 +1,30 @@
+//
+// System.Data.ObjectSpaces.Query.SpanProperty
+//
+//
+// Author:
+// Richard Thombs (stony@stony.org)
+//
+
+#if NET_1_2
+
+namespace System.Data.ObjectSpaces.Query
+{
+ [MonoTODO()]
+ public class SpanProperty
+ {
+ [MonoTODO()]
+ public SpanProperty(string name)
+ {
+ throw new NotImplementedException();
+ }
+
+ [MonoTODO()]
+ public SpanProperty(string name,SpanPropertyCollection subSpan)
+ {
+ throw new NotImplementedException();
+ }
+ }
+}
+
+#endif
diff --git a/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Query/SpanPropertyCollection.cs b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Query/SpanPropertyCollection.cs
new file mode 100644
index 00000000000..8739ee65ff3
--- /dev/null
+++ b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Query/SpanPropertyCollection.cs
@@ -0,0 +1,26 @@
+//
+// System.Data.ObjectSpaces.Query.SpanPropertyCollection
+//
+//
+// Author:
+// Richard Thombs (stony@stony.org)
+//
+
+#if NET_1_2
+
+using System.Collections;
+
+namespace System.Data.ObjectSpaces.Query
+{
+ [MonoTODO()]
+ public class SpanPropertyCollection : CollectionBase
+ {
+ [MonoTODO()]
+ public SpanPropertyCollection() : base()
+ {
+ throw new NotImplementedException();
+ }
+ }
+}
+
+#endif
diff --git a/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Query/TypeCast.cs b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Query/TypeCast.cs
new file mode 100644
index 00000000000..5495046bc32
--- /dev/null
+++ b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Query/TypeCast.cs
@@ -0,0 +1,36 @@
+//
+// System.Data.ObjectSpaces.Query.TypeCast
+//
+//
+// Author:
+// Richard Thombs (stony@stony.org)
+//
+
+#if NET_1_2
+
+namespace System.Data.ObjectSpaces.Query
+{
+ [MonoTODO()]
+ public class TypeCast : Expression
+ {
+ [MonoTODO()]
+ public TypeCast() : base()
+ {
+ throw new NotImplementedException();
+ }
+
+ [MonoTODO()]
+ public TypeCast(string typeName) : base()
+ {
+ throw new NotImplementedException();
+ }
+
+ [MonoTODO()]
+ public override object Clone()
+ {
+ throw new NotImplementedException();
+ }
+ }
+}
+
+#endif
diff --git a/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Query/TypeConversion.cs b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Query/TypeConversion.cs
new file mode 100644
index 00000000000..ee65ccb053e
--- /dev/null
+++ b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Query/TypeConversion.cs
@@ -0,0 +1,30 @@
+//
+// System.Data.ObjectSpaces.Query.TypeConversion
+//
+//
+// Author:
+// Richard Thombs (stony@stony.org)
+//
+
+#if NET_1_2
+
+namespace System.Data.ObjectSpaces.Query
+{
+ [MonoTODO()]
+ public class TypeConversion : Expression
+ {
+ [MonoTODO()]
+ public TypeConversion(Expression source,Type type)
+ {
+ throw new NotImplementedException();
+ }
+
+ [MonoTODO()]
+ public override object Clone()
+ {
+ throw new NotImplementedException();
+ }
+ }
+}
+
+#endif
diff --git a/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Query/TypeFilter.cs b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Query/TypeFilter.cs
new file mode 100644
index 00000000000..8b81fd4bcb9
--- /dev/null
+++ b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Query/TypeFilter.cs
@@ -0,0 +1,36 @@
+//
+// System.Data.ObjectSpaces.Query.TypeFilter
+//
+//
+// Author:
+// Richard Thombs (stony@stony.org)
+//
+
+#if NET_1_2
+
+namespace System.Data.ObjectSpaces.Query
+{
+ [MonoTODO()]
+ public class TypeFilter : Expression
+ {
+ [MonoTODO()]
+ public TypeFilter(Expression source,Type type) : base()
+ {
+ throw new NotImplementedException();
+ }
+
+ [MonoTODO()]
+ public TypeFilter(Expression source,Type type,bool baseTypeOnly) : base()
+ {
+ throw new NotImplementedException();
+ }
+
+ [MonoTODO()]
+ public override object Clone()
+ {
+ throw new NotImplementedException();
+ }
+ }
+}
+
+#endif
diff --git a/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Query/Unary.cs b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Query/Unary.cs
new file mode 100644
index 00000000000..7eb964054fd
--- /dev/null
+++ b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Query/Unary.cs
@@ -0,0 +1,30 @@
+//
+// System.Data.ObjectSpaces.Query.Unary
+//
+//
+// Author:
+// Richard Thombs (stony@stony.org)
+//
+
+#if NET_1_2
+
+namespace System.Data.ObjectSpaces.Query
+{
+ [MonoTODO()]
+ public class Unary : Expression
+ {
+ [MonoTODO()]
+ public Unary(Expression operand,UnaryOperator _operator)
+ {
+ throw new NotImplementedException();
+ }
+
+ [MonoTODO()]
+ public override object Clone()
+ {
+ throw new NotImplementedException();
+ }
+ }
+}
+
+#endif
diff --git a/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Schema/ExtendedProperty.cs b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Schema/ExtendedProperty.cs
new file mode 100644
index 00000000000..a182019c982
--- /dev/null
+++ b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Schema/ExtendedProperty.cs
@@ -0,0 +1,63 @@
+//
+// System.Data.ObjectSpaces.Schema.ExtendedProperty.cs
+//
+// Author:
+// Tim Coleman (tim@timcoleman.com)
+//
+// Copyright (C) Tim Coleman, 2003
+//
+
+#if NET_1_2
+
+using System.Xml;
+
+namespace System.Data.ObjectSpaces.Schema {
+ public class ExtendedProperty
+ {
+ #region Fields
+
+ XmlQualifiedName qname;
+ object propertyValue;
+ string prefix;
+
+ #endregion // Fields
+
+ #region Constructors
+
+ [MonoTODO]
+ public ExtendedProperty (XmlQualifiedName qualifiedName, object propertyValue)
+ {
+ QualifiedName = qualifiedName;
+ PropertyValue = propertyValue;
+ }
+
+ public ExtendedProperty (XmlQualifiedName qualifiedName, object propertyValue, string prefix)
+ : this (qualifiedName, propertyValue)
+ {
+ Prefix = prefix;
+ }
+
+ #endregion // Constructors
+
+ #region Properties
+
+ public string Prefix {
+ get { return prefix; }
+ set { prefix = value; }
+ }
+
+ public object PropertyValue {
+ get { return propertyValue; }
+ set { propertyValue = value; }
+ }
+
+ public XmlQualifiedName QualifiedName {
+ get { return qname; }
+ set { qname = value; }
+ }
+
+ #endregion // Properties
+ }
+}
+
+#endif // NET_1_2
diff --git a/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Schema/ExtendedPropertyCollection.cs b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Schema/ExtendedPropertyCollection.cs
new file mode 100644
index 00000000000..5584b2be979
--- /dev/null
+++ b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Schema/ExtendedPropertyCollection.cs
@@ -0,0 +1,126 @@
+//
+// System.Data.ObjectSpaces.Schema.ExtendedPropertyCollection.cs
+//
+// Author:
+// Tim Coleman (tim@timcoleman.com)
+//
+// Copyright (C) Tim Coleman, 2003
+//
+
+#if NET_1_2
+
+using System.Collections;
+using System.Xml;
+
+namespace System.Data.ObjectSpaces.Schema {
+ public class ExtendedPropertyCollection : CollectionBase
+ {
+ #region Fields
+
+ ArrayList qnames;
+
+ #endregion
+
+ #region Constructors
+
+ public ExtendedPropertyCollection ()
+ {
+ qnames = new ArrayList();
+ }
+
+ public ExtendedPropertyCollection (ExtendedProperty[] value)
+ : this ()
+ {
+ AddRange (value);
+ }
+
+ public ExtendedPropertyCollection (ExtendedPropertyCollection value)
+ : this ()
+ {
+ AddRange (value);
+ }
+
+ #endregion // Constructors
+
+ #region Properties
+
+ public ExtendedProperty this [int obj] {
+ get { return (ExtendedProperty) List [obj]; }
+ set {
+ List [obj] = value;
+ qnames [obj] = value.QualifiedName;
+ }
+ }
+
+ [MonoTODO]
+ public ExtendedProperty this [XmlQualifiedName type] {
+ get { return (ExtendedProperty) List [qnames.IndexOf (type)]; }
+ set { List [qnames.IndexOf (type)] = value; }
+ }
+
+ #endregion // Properties
+
+ #region Methods
+
+ public void Add (ExtendedProperty value)
+ {
+ Insert (Count, value);
+ }
+
+ public void AddRange (ExtendedProperty[] value)
+ {
+ foreach (ExtendedProperty p in value)
+ Add (p);
+ }
+
+ public void AddRange (ExtendedPropertyCollection value)
+ {
+ foreach (ExtendedProperty p in value)
+ Add (p);
+ }
+
+ public bool Contains (ExtendedProperty value)
+ {
+ return List.Contains (value);
+ }
+
+ public void CopyTo (ExtendedProperty[] array, int index)
+ {
+ List.CopyTo (array, index);
+ }
+
+ public int IndexOf (ExtendedProperty value)
+ {
+ return List.IndexOf (value);
+ }
+
+ [MonoTODO]
+ public void Insert (int index, ExtendedProperty value)
+ {
+ List.Insert (index, value);
+ qnames [index] = value.QualifiedName;
+ }
+
+ [MonoTODO]
+ protected override void OnInsert (int index, object value)
+ {
+ }
+
+ [MonoTODO]
+ protected override void OnRemove (int index, object value)
+ {
+ }
+
+ [MonoTODO]
+ public void Remove (ExtendedProperty value)
+ {
+ int index = IndexOf (value);
+ List.Remove (value);
+ qnames.RemoveAt (index);
+ }
+
+ #endregion // Methods
+ }
+}
+
+#endif // NET_1_2
diff --git a/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Schema/ObjectRelationship.cs b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Schema/ObjectRelationship.cs
new file mode 100644
index 00000000000..32d56a7446f
--- /dev/null
+++ b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Schema/ObjectRelationship.cs
@@ -0,0 +1,124 @@
+//
+// System.Data.ObjectSpaces.Schema.ObjectRelationship.cs
+//
+// Author:
+// Tim Coleman (tim@timcoleman.com)
+//
+// Copyright (C) Tim Coleman, 2003
+//
+
+#if NET_1_2
+
+using System.Data.Mapping;
+
+namespace System.Data.ObjectSpaces.Schema {
+ public sealed class ObjectRelationship : IDomainConstraint
+ {
+ #region Fields
+
+ string name;
+ SchemaClass childClass;
+ SchemaMember childMember;
+ SchemaClass parentClass;
+ SchemaMember parentMember;
+ ObjectRelationshipType type;
+ bool isCascadeDelete;
+
+ #endregion // Fields
+
+ #region Constructors
+
+ [MonoTODO]
+ public ObjectRelationship (string name, SchemaClass parentClass, SchemaMember parentMember, SchemaClass childClass, SchemaMember childMember, ObjectRelationshipType type)
+ {
+ Name = name;
+ Type = type;
+
+ this.parentClass = parentClass;
+ this.parentMember = parentMember;
+ this.childClass = childClass;
+ this.childMember = childMember;
+ }
+
+ [MonoTODO]
+ public ObjectRelationship (string name, SchemaClass parentClass, SchemaMember parentMember, SchemaClass childClass, SchemaMember childMember, ObjectRelationshipType type, bool isCascadeDelete)
+ : this (name, parentClass, parentMember, childClass, childMember, type)
+ {
+ IsCascadeDelete = isCascadeDelete;
+ }
+
+ #endregion // Constructors
+
+ #region Properties
+
+ public SchemaClass ChildClass {
+ get { return childClass; }
+ }
+
+ public SchemaMember ChildMember {
+ get { return childMember; }
+ }
+
+ [MonoTODO]
+ public ObjectSchema DeclaringObjectSchema {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public ExtendedPropertyCollection ExtendedProperties {
+ get { throw new NotImplementedException (); }
+ }
+
+ private bool IDomainConstraint.CascadeDelete {
+ get { return IsCascadeDelete; }
+ }
+
+ [MonoTODO]
+ private IDomainSchema IDomainConstraint.DomainSchema {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ private IDomainFieldJoinCollection IDomainConstraint.FieldJoins {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ private IDomainStructure IDomainConstraint.FromDomainStructure {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ private IDomainStructure IDomainConstraint.ToDomainStructure {
+ get { throw new NotImplementedException (); }
+ }
+
+ public bool IsCascadeDelete {
+ get { return isCascadeDelete; }
+ set { isCascadeDelete = value; }
+ }
+
+ public string Name {
+ get { return name; }
+ set { name = value; }
+ }
+
+
+ public SchemaClass ParentClass {
+ get { return parentClass; }
+ }
+
+ public SchemaMember ParentMember {
+ get { return parentMember; }
+ }
+
+ public ObjectRelationshipType Type {
+ get { return type; }
+ set { type = value; }
+ }
+
+ #endregion // Properties
+ }
+}
+
+#endif // NET_1_2
diff --git a/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Schema/ObjectRelationshipCollection.cs b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Schema/ObjectRelationshipCollection.cs
new file mode 100644
index 00000000000..f1921d27e01
--- /dev/null
+++ b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Schema/ObjectRelationshipCollection.cs
@@ -0,0 +1,86 @@
+//
+// System.Data.ObjectSpaces.Schema.ObjectRelationshipCollection.cs
+//
+// Author:
+// Tim Coleman (tim@timcoleman.com)
+//
+// Copyright (C) Tim Coleman, 2003
+//
+
+#if NET_1_2
+
+using System.Collections;
+
+namespace System.Data.ObjectSpaces.Schema {
+ public class ObjectRelationshipCollection : CollectionBase
+ {
+ #region Properties
+
+ [MonoTODO]
+ public ObjectRelationship this [string name] {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public ObjectRelationship this [int index] {
+ get { return (ObjectRelationship) List [index]; }
+ }
+
+ #endregion // Properties
+
+ #region Methods
+
+ public void Add (ObjectRelationship relationship)
+ {
+ Insert (Count, relationship);
+ }
+
+ public bool Contains (ObjectRelationship relationship)
+ {
+ return List.Contains (relationship);
+ }
+
+ [MonoTODO]
+ public ObjectRelationship[] GetChildRelationships (Type type)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public ObjectRelationship[] GetParentRelationships (Type type)
+ {
+ throw new NotImplementedException ();
+ }
+
+ public int IndexOf (ObjectRelationship relationship)
+ {
+ return List.IndexOf (relationship);
+ }
+
+ public void Insert (int index, ObjectRelationship relationship)
+ {
+ List.Insert (index, relationship);
+ }
+
+ [MonoTODO]
+ protected override void OnInsert (int index, object value)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ protected override void OnRemove (int index, object value)
+ {
+ throw new NotImplementedException ();
+ }
+
+ public void Remove (ObjectRelationship relation)
+ {
+ List.Remove (relation);
+ }
+
+ #endregion // Methods
+ }
+}
+
+#endif // NET_1_2
diff --git a/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Schema/ObjectRelationshipType.cs b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Schema/ObjectRelationshipType.cs
new file mode 100644
index 00000000000..2de3e47f1e3
--- /dev/null
+++ b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Schema/ObjectRelationshipType.cs
@@ -0,0 +1,21 @@
+//
+// System.Data.ObjectSpaces.Schema.ObjectRelationshipType.cs
+//
+// Author:
+// Tim Coleman (tim@timcoleman.com)
+//
+// Copyright (C) Tim Coleman, 2003
+//
+
+#if NET_1_2
+
+namespace System.Data.ObjectSpaces.Schema {
+ public enum ObjectRelationshipType
+ {
+ OneToMany,
+ OneToOne,
+ ManyToMany
+ }
+}
+
+#endif // NET_1_2
diff --git a/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Schema/ObjectSchema.cs b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Schema/ObjectSchema.cs
new file mode 100644
index 00000000000..29589556731
--- /dev/null
+++ b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Schema/ObjectSchema.cs
@@ -0,0 +1,286 @@
+//
+// System.Data.ObjectSpaces.Schema.ObjectSchema.cs
+//
+// Author:
+// Mark Easton (mark.easton@blinksoftware.co.uk)
+// Tim Coleman (tim@timcoleman.com)
+//
+// (C) BLiNK Software Ltd. http://www.blinksoftware.co.uk
+// Copyright (C) Tim Coleman, 2003
+//
+
+#if NET_1_2
+
+using System.Data.Mapping;
+using System.IO;
+using System.Xml;
+using System.Xml.Schema;
+
+namespace System.Data.ObjectSpaces.Schema {
+ public class ObjectSchema : ICloneable, IDomainSchema
+ {
+ #region Fields
+
+ string name;
+
+ #endregion // Fields
+
+ #region Constructors
+
+ [MonoTODO]
+ public ObjectSchema ()
+ {
+ }
+
+ [MonoTODO]
+ public ObjectSchema (string url)
+ {
+ }
+
+ #endregion // Constructors
+
+ #region Properties
+
+ [MonoTODO]
+ public SchemaClassCollection Classes {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public ExtendedPropertyCollection ExtendedProperties {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ private MappingDataSourceType IDomainSchema.DomainType {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO ("Verify")]
+ public string Name {
+ get { return name; }
+ set { name = value; }
+ }
+
+ [MonoTODO]
+ public string Namespace {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public ObjectRelationshipCollection Relationships {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public string SourceUri {
+ get { throw new NotImplementedException (); }
+ }
+
+ #endregion // Properties
+
+ #region Methods
+
+ [MonoTODO]
+ public Object Clone ()
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public string GetSchemaXml ()
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ private IDomainConstraint IDomainSchema.GetDomainConstraint (string select, IXmlNamespaceResolver namespaces)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ private IDomainStructure IDomainSchema.GetDomainStructure (string select, IXmlNamespaceResolver namespaces)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ private void IDomainSchema.Read (string url)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ private void IDomainSchema.Read (string url, ValidationEventHandler validationEventHandler)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ private void IDomainSchema.Read (XmlReader reader)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ private void IDomainSchema.Read (XmlReader reader, ValidationEventHandler validationEventHandler)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ private void IDomainSchema.ReadExtensions (XmlReader reader)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ private void IDomainSchema.ReadExtensions (XmlReader reader, ValidationEventHandler validationEventHandler)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ private void IDomainSchema.Write (string schemaLocation)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ private void IDomainSchema.Write (string schemaLocation, IXmlNamespaceResolver namespaceResolver)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ private void IDomainSchema.Write (XmlWriter writer)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ private void IDomainSchema.Write (XmlWriter writer, IXmlNamespaceResolver namespaceResolver)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ private void IDomainSchema.Write (Stream stream)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ private void IDomainSchema.Write (Stream stream, IXmlNamespaceResolver namespaceResolver)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ private void IDomainSchema.Write (TextWriter writer)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ private void IDomainSchema.Write (TextWriter writer, IXmlNamespaceResolver namespaceResolver)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ private void IDomainSchema.WriteExtensions (XmlWriter reader)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ private void IDomainSchema.WriteExtensions (XmlWriter reader, IXmlNamespaceResolver namespaceResolver)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void Read (string url)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void Read (string url, ValidationEventHandler validationEventHandler)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void Read (XmlReader reader)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void Read (XmlReader reader, ValidationEventHandler validationEventHandler)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void Reset ()
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void Write (string schemaLocation)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void Write (string schemaLocation, IXmlNamespaceResolver namespaceResolver)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void Write (XmlWriter writer)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void Write (XmlWriter writer, IXmlNamespaceResolver namespaceResolver)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void Write (Stream stream)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void Write (Stream stream, IXmlNamespaceResolver namespaceResolver)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void Write (TextWriter writer)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void Write (TextWriter writer, IXmlNamespaceResolver namespaceResolver)
+ {
+ throw new NotImplementedException ();
+ }
+
+ #endregion // Methods
+ }
+}
+
+#endif // NET_1_2
diff --git a/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Schema/SchemaClass.cs b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Schema/SchemaClass.cs
new file mode 100644
index 00000000000..4900af4d1eb
--- /dev/null
+++ b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Schema/SchemaClass.cs
@@ -0,0 +1,91 @@
+//
+// System.Data.ObjectSpaces.Schema.SchemaClass.cs
+//
+// Author:
+// Tim Coleman (tim@timcoleman.com)
+//
+// Copyright (C) Tim Coleman, 2003
+//
+
+#if NET_1_2
+
+using System.Data.Mapping;
+using System.Xml;
+
+namespace System.Data.ObjectSpaces.Schema {
+ public sealed class SchemaClass : IDomainStructure
+ {
+ #region Fields
+
+ bool canInherit;
+ Type classType;
+
+ #endregion // Fields
+
+ #region Constructors
+
+ [MonoTODO]
+ public SchemaClass ()
+ {
+ }
+
+ [MonoTODO]
+ public SchemaClass (Type classType)
+ {
+ ClassType = classType;
+ }
+
+ #endregion // Constructors
+
+ #region Properties
+
+ public bool CanInherit {
+ get { return canInherit; }
+ set { canInherit = value; }
+ }
+
+ public Type ClassType {
+ get { return classType; }
+ set { classType = value; }
+ }
+
+ [MonoTODO]
+ public ObjectSchema DeclaringObjectSchema {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public ExtendedPropertyCollection ExtendedProperties {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ private IDomainSchema IDomainStructure.DomainSchema {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ private string IDomainStructure.Select {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public SchemaMemberCollection SchemaMembers {
+ get { throw new NotImplementedException (); }
+ }
+
+ #endregion // Properties
+
+ #region Methods
+
+ [MonoTODO]
+ private IDomainField IDomainStructure.GetDomainField (string select, IXmlNamespaceResolver namespaces)
+ {
+ throw new NotImplementedException ();
+ }
+
+ #endregion // Methods
+ }
+}
+
+#endif // NET_1_2
diff --git a/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Schema/SchemaClassCollection.cs b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Schema/SchemaClassCollection.cs
new file mode 100644
index 00000000000..14410404048
--- /dev/null
+++ b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Schema/SchemaClassCollection.cs
@@ -0,0 +1,78 @@
+//
+// System.Data.ObjectSpaces.Schema.SchemaClassCollection.cs
+//
+// Author:
+// Tim Coleman (tim@timcoleman.com)
+//
+// Copyright (C) Tim Coleman, 2003
+//
+
+#if NET_1_2
+
+using System.Collections;
+
+namespace System.Data.ObjectSpaces.Schema {
+ public class SchemaClassCollection : CollectionBase
+ {
+ #region Properties
+
+ public SchemaClass this [int index] {
+ get { return (SchemaClass) List [index]; }
+ }
+
+ [MonoTODO]
+ public SchemaClass this [string typeName] {
+ get { throw new NotImplementedException (); }
+ }
+
+ #endregion // Properties
+
+ #region Methods
+
+ public void Add (SchemaClass schemaClass)
+ {
+ Insert (Count, schemaClass);
+ }
+
+ public bool Contains (SchemaClass schemaClass)
+ {
+ return List.Contains (schemaClass);
+ }
+
+ public void CopyTo (SchemaClass[] array, int index)
+ {
+ List.CopyTo (array, index);
+ }
+
+ public int IndexOf (SchemaClass schemaClass)
+ {
+ return List.IndexOf (schemaClass);
+ }
+
+ public void Insert (int index, SchemaClass schemaClass)
+ {
+ List.Insert (index, schemaClass);
+ }
+
+ [MonoTODO]
+ protected override void OnInsert (int index, object value)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ protected override void OnRemove (int index, object value)
+ {
+ throw new NotImplementedException ();
+ }
+
+ public void Remove (SchemaClass schemaClass)
+ {
+ List.Remove (schemaClass);
+ }
+
+ #endregion // Methods
+ }
+}
+
+#endif // NET_1_2
diff --git a/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Schema/SchemaMember.cs b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Schema/SchemaMember.cs
new file mode 100644
index 00000000000..32b14e2fcb3
--- /dev/null
+++ b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Schema/SchemaMember.cs
@@ -0,0 +1,112 @@
+//
+// System.Data.ObjectSpaces.Schema.SchemaMember.cs
+//
+// Author:
+// Tim Coleman (tim@timcoleman.com)
+//
+// Copyright (C) Tim Coleman, 2003
+//
+
+#if NET_1_2
+
+using System.Data.Mapping;
+using System.Reflection;
+
+namespace System.Data.ObjectSpaces.Schema {
+ public class SchemaMember : IDomainField
+ {
+ #region Fields
+
+ string alias;
+ bool isHidden;
+ bool isKey;
+ bool isLazyLoad;
+ KeyGenerator keyGenerator;
+ string name;
+
+ #endregion // Fields
+
+ #region Constructors
+
+ [MonoTODO]
+ public SchemaMember ()
+ {
+ }
+
+ [MonoTODO]
+ public SchemaMember (string name)
+ {
+ Name = name;
+ }
+
+ [MonoTODO]
+ public SchemaMember (string name, bool key)
+ : this (name)
+ {
+ IsKey = key;
+ }
+
+ #endregion // Constructors
+
+ #region Properties
+
+ public string Alias {
+ get { return alias; }
+ set { alias = value; }
+ }
+
+ [MonoTODO]
+ public SchemaClass DeclaringSchemaClass {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public ExtendedPropertyCollection ExtendedProperties {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ private IDomainStructure IDomainField.DomainStructure {
+ get { throw new NotImplementedException (); }
+ }
+
+ public bool IsHidden {
+ get { return isHidden; }
+ set { isHidden = value; }
+ }
+
+ public bool IsKey {
+ get { return isKey; }
+ set { isKey = value; }
+ }
+
+ public bool IsLazyLoad {
+ get { return isLazyLoad; }
+ set { isLazyLoad = value; }
+ }
+
+ public KeyGenerator KeyGenerator {
+ get { return keyGenerator; }
+ set { keyGenerator = value; }
+ }
+
+ [MonoTODO]
+ public MemberInfo MemberInfo {
+ get { throw new NotImplementedException (); }
+ }
+
+ public string Name {
+ get { return name; }
+ set { name = value; }
+ }
+
+ [MonoTODO]
+ public ObjectRelationship ObjectRelationship {
+ get { throw new NotImplementedException (); }
+ }
+
+ #endregion // Properties
+ }
+}
+
+#endif // NET_1_2
diff --git a/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Schema/SchemaMemberCollection.cs b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Schema/SchemaMemberCollection.cs
new file mode 100644
index 00000000000..5f78c8574f2
--- /dev/null
+++ b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.Schema/SchemaMemberCollection.cs
@@ -0,0 +1,78 @@
+//
+// System.Data.ObjectSpaces.Schema.SchemaMemberCollection.cs
+//
+// Author:
+// Tim Coleman (tim@timcoleman.com)
+//
+// Copyright (C) Tim Coleman, 2003
+//
+
+#if NET_1_2
+
+using System.Collections;
+
+namespace System.Data.ObjectSpaces.Schema {
+ public class SchemaMemberCollection : CollectionBase
+ {
+ #region Properties
+
+ public SchemaMember this [int index] {
+ get { return (SchemaMember) List [index]; }
+ }
+
+ [MonoTODO]
+ public SchemaMember this [string typeName] {
+ get { throw new NotImplementedException (); }
+ }
+
+ #endregion // Properties
+
+ #region Methods
+
+ public void Add (SchemaMember member)
+ {
+ Insert (Count, member);
+ }
+
+ public bool Contains (SchemaMember member)
+ {
+ return List.Contains (member);
+ }
+
+ public void CopyTo (SchemaMember[] array, int index)
+ {
+ List.CopyTo (array, index);
+ }
+
+ public int IndexOf (SchemaMember member)
+ {
+ return List.IndexOf (member);
+ }
+
+ public void Insert (int index, SchemaMember member)
+ {
+ List.Insert (index, member);
+ }
+
+ [MonoTODO]
+ protected override void OnInsert (int index, object value)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ protected override void OnRemove (int index, object value)
+ {
+ throw new NotImplementedException ();
+ }
+
+ public void Remove (SchemaMember member)
+ {
+ List.Remove (member);
+ }
+
+ #endregion // Methods
+ }
+}
+
+#endif // NET_1_2
diff --git a/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.dll.sources b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.dll.sources
new file mode 100644
index 00000000000..4288ac463d6
--- /dev/null
+++ b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces.dll.sources
@@ -0,0 +1,80 @@
+TODOAttribute.cs
+Assembly/AssemblyInfo.cs
+Assembly/Locale.cs
+System.Data.ObjectSpaces/ASTBaseParser.cs
+System.Data.ObjectSpaces/AstKeywords.cs
+System.Data.ObjectSpaces/CommonObjectContext.cs
+System.Data.ObjectSpaces/CompiledQuery.cs
+System.Data.ObjectSpaces/ContextException.cs
+System.Data.ObjectSpaces/DbObjectReader.cs
+System.Data.ObjectSpaces/Depth.cs
+System.Data.ObjectSpaces/DynamicAssembly.cs
+System.Data.ObjectSpaces/InitialState.cs
+System.Data.ObjectSpaces/IObjectHelper.cs
+System.Data.ObjectSpaces/IObjectNotification.cs
+System.Data.ObjectSpaces/KeyGenerator.cs
+System.Data.ObjectSpaces/ManyToManyRelationship.cs
+System.Data.ObjectSpaces/ManyToOneRelationship.cs
+System.Data.ObjectSpaces/ObjectContext.cs
+System.Data.ObjectSpaces/ObjectEngine.cs
+System.Data.ObjectSpaces/ObjectException.cs
+System.Data.ObjectSpaces/ObjectHolder.cs
+System.Data.ObjectSpaces/ObjectKey.cs
+System.Data.ObjectSpaces/ObjectKeyManager.cs
+System.Data.ObjectSpaces/ObjectList.cs
+System.Data.ObjectSpaces/ObjectQuery.cs
+System.Data.ObjectSpaces/ObjectReader.cs
+System.Data.ObjectSpaces/ObjectSet.cs
+System.Data.ObjectSpaces/ObjectSources.cs
+System.Data.ObjectSpaces/ObjectSpace.cs
+System.Data.ObjectSpaces/ObjectState.cs
+System.Data.ObjectSpaces/OneToManyRelationship.cs
+System.Data.ObjectSpaces/OneToOneRelationship.cs
+System.Data.ObjectSpaces/PersistenceError.cs
+System.Data.ObjectSpaces/PersistenceErrorBehavior.cs
+System.Data.ObjectSpaces/PersistenceErrorType.cs
+System.Data.ObjectSpaces/PersistenceException.cs
+System.Data.ObjectSpaces/PersistenceOptions.cs
+System.Data.ObjectSpaces/UpdateErrorType.cs
+System.Data.ObjectSpaces/ValueRecord.cs
+System.Data.ObjectSpaces/ValueRecordMergeEventArgs.cs
+System.Data.ObjectSpaces/ValueRecordMergeEventHandler.cs
+System.Data.ObjectSpaces.Query/ASTQueryParser.cs
+System.Data.ObjectSpaces.Query/Axis.cs
+System.Data.ObjectSpaces.Query/Binary.cs
+System.Data.ObjectSpaces.Query/Conditional.cs
+System.Data.ObjectSpaces.Query/Context.cs
+System.Data.ObjectSpaces.Query/Delegates.cs
+System.Data.ObjectSpaces.Query/Empty.cs
+System.Data.ObjectSpaces.Query/Enumerations.cs
+System.Data.ObjectSpaces.Query/Expression.cs
+System.Data.ObjectSpaces.Query/Filter.cs
+System.Data.ObjectSpaces.Query/Function.cs
+System.Data.ObjectSpaces.Query/Literal.cs
+System.Data.ObjectSpaces.Query/ObjectExpression.cs
+System.Data.ObjectSpaces.Query/ObjectSpaceNode.cs
+System.Data.ObjectSpaces.Query/OPath.cs
+System.Data.ObjectSpaces.Query/OrderBy.cs
+System.Data.ObjectSpaces.Query/OrderByItemCollection.cs
+System.Data.ObjectSpaces.Query/OrderByItem.cs
+System.Data.ObjectSpaces.Query/Parameter.cs
+System.Data.ObjectSpaces.Query/Parent.cs
+System.Data.ObjectSpaces.Query/Property.cs
+System.Data.ObjectSpaces.Query/RelTraversal.cs
+System.Data.ObjectSpaces.Query/Span.cs
+System.Data.ObjectSpaces.Query/SpanPropertyCollection.cs
+System.Data.ObjectSpaces.Query/SpanProperty.cs
+System.Data.ObjectSpaces.Query/TypeCast.cs
+System.Data.ObjectSpaces.Query/TypeConversion.cs
+System.Data.ObjectSpaces.Query/TypeFilter.cs
+System.Data.ObjectSpaces.Query/Unary.cs
+System.Data.ObjectSpaces.Schema/SchemaClass.cs
+System.Data.ObjectSpaces.Schema/ObjectRelationship.cs
+System.Data.ObjectSpaces.Schema/ObjectRelationshipCollection.cs
+System.Data.ObjectSpaces.Schema/ObjectRelationshipType.cs
+System.Data.ObjectSpaces.Schema/ObjectSchema.cs
+System.Data.ObjectSpaces.Schema/SchemaMemberCollection.cs
+System.Data.ObjectSpaces.Schema/SchemaMember.cs
+System.Data.ObjectSpaces.Schema/SchemaClassCollection.cs
+System.Data.ObjectSpaces.Schema/ExtendedProperty.cs
+System.Data.ObjectSpaces.Schema/ExtendedPropertyCollection.cs
diff --git a/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/ASTBaseParser.cs b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/ASTBaseParser.cs
new file mode 100755
index 00000000000..514647d0f71
--- /dev/null
+++ b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/ASTBaseParser.cs
@@ -0,0 +1,60 @@
+//
+// System.Data.ObjectSpaces.ASTBaseParser.cs - Implements a base Abstract Syntax Tree parser
+//
+// Author:
+// Mark Easton (mark.easton@blinksoftware.co.uk)
+//
+// (C) BLiNK Software Ltd. http://www.blinksoftware.co.uk
+//
+
+#if NET_1_2
+
+using System.Data.ObjectSpaces.Query;
+
+namespace System.Data.ObjectSpaces
+{
+ public class ASTBaseParser
+ {
+ public int lexerPos; //The current position in the lexical analyser
+ public int parCount; //The parse number
+ public Expression parseTree; //The parse tree
+
+ [MonoTODO]
+ public ASTBaseParser () {}
+
+
+
+ [MonoTODO]
+ protected Expression BuildBinaryNode (Expression left, Expression right, BinaryOperator op)
+ {
+ return null;
+ }
+
+ [MonoTODO]
+ protected Expression BuildConditionalNode (Expression condition, Expression trueBranch, Expression falseBranch)
+ {
+ return null;
+ }
+
+ [MonoTODO]
+ protected Expression BuildUnaryNode (Expression node, UnaryOperator op)
+ {
+ return null;
+ }
+
+ [MonoTODO]
+ protected Expression GetConstraint (Axis filter)
+ {
+ return null;
+ }
+
+ [MonoTODO]
+ public virtual void Parse (string opath) {}
+
+ [MonoTODO]
+ public virtual void ParseObjectQuery (Type type, string opath, bool baseTypeOnly) {}
+
+ }
+}
+
+#endif
diff --git a/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/AstKeywords.cs b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/AstKeywords.cs
new file mode 100755
index 00000000000..36b88163638
--- /dev/null
+++ b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/AstKeywords.cs
@@ -0,0 +1,51 @@
+//
+// System.Data.ObjectSpaces.AstKeywords.cs : The recognised keywords for Abstract Syntax Trees
+//
+// Author:
+// Mark Easton (mark.easton@blinksoftware.co.uk)
+//
+// (C) BLiNK Software Ltd. http://www.blinksoftware.co.uk
+//
+
+#if NET_1_2
+
+namespace System.Data.ObjectSpaces
+{
+ public class AstKeywords
+ {
+ public static string arithmetic;
+ public static string axisQueries;
+ public static string boolean;
+ public static string condition;
+ public static string conditional;
+ public static string constraint;
+ public static string falseBranch;
+ public static string filter;
+ public static string first;
+ public static string left;
+ public static string len;
+ public static string like;
+ public static string name;
+ public static string objectSchema;
+ public static string operand;
+ public static string @operator;
+ public static string orderByItem;
+ public static string @params;
+ public static string right;
+ public static string second;
+ public static string source;
+ public static string spanProperties;
+ public static string spanProperty;
+ public static string substring;
+ public static string trim;
+ public static string trueBranch;
+ public static string type;
+ public static string value;
+
+ [MonoTODO]
+ public AstKeywords () {}
+
+ }
+}
+
+#endif \ No newline at end of file
diff --git a/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/CommonObjectContext.cs b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/CommonObjectContext.cs
new file mode 100755
index 00000000000..ed85f9d12fc
--- /dev/null
+++ b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/CommonObjectContext.cs
@@ -0,0 +1,113 @@
+//
+// System.Data.ObjectSpaces.CommonObjectContext.cs : A basic ObjectContext for handling persistent object identity and state.
+//
+// Author:
+// Mark Easton (mark.easton@blinksoftware.co.uk)
+// Tim Coleman (tim@timcoleman.com)
+//
+// (C) BLiNK Software Ltd. http://www.blinksoftware.co.uk
+// Copyright (C) Tim Coleman, 2003
+//
+
+#if NET_1_2
+
+using System;
+using System.Data.ObjectSpaces.Schema;
+using System.Globalization;
+
+namespace System.Data.ObjectSpaces
+{
+ public class CommonObjectContext : ObjectContext
+ {
+ #region Fields
+
+ ObjectSchema objectSchema;
+
+ #endregion // Fields
+
+ #region Constructors
+
+ public CommonObjectContext (ObjectSchema objectSchema)
+ {
+ if (objectSchema == null)
+ throw new ArgumentNullException ("objectSchema", Locale.GetText ("'objectSchema' argument cannot be null."));
+ this.objectSchema = objectSchema;
+ }
+
+ #endregion // Constructors
+
+ #region Methods
+
+ [MonoTODO]
+ public override void Add (object obj, ObjectState state)
+ {
+ if (obj == null)
+ throw new ContextException (Locale.GetText ("Cannot add null object into any object context."));
+ if (!Enum.IsDefined (typeof (ObjectState), state))
+ throw new NullReferenceException ();
+ if (state == ObjectState.Unknown)
+ throw new ContextException (Locale.GetText ("Cannot add any object into an object context as an Unknown object."));
+ }
+
+ [MonoTODO]
+ public override void Delete (object obj)
+ {
+ if (obj == null)
+ throw new ArgumentNullException ("obj", Locale.GetText ("'obj' argument cannot be null."));
+ }
+
+ [MonoTODO]
+ public override ValueRecord GetCurrentValueRecord (object obj)
+ {
+ if (obj == null)
+ throw new ArgumentNullException ("obj", Locale.GetText ("'obj' argument cannot be null."));
+
+ return null;
+ }
+
+ [MonoTODO]
+ public override ObjectState GetObjectState (object obj)
+ {
+ if (obj == null)
+ throw new ArgumentNullException ("obj", Locale.GetText ("'obj' argument cannot be null."));
+
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public override ValueRecord GetOriginalValueRecord (object obj)
+ {
+ if (obj == null)
+ throw new ArgumentNullException ("obj", Locale.GetText ("'obj' argument cannot be null."));
+
+ return null;
+ }
+
+ [MonoTODO]
+ public override void Import (ObjectContext context)
+ {
+ if (context == null)
+ throw new ArgumentNullException ("context", Locale.GetText ("'context' argument cannot be null."));
+ }
+
+ [MonoTODO]
+ public override void Import (ObjectContext context, object obj)
+ {
+ if (obj == null)
+ throw new ArgumentNullException ("obj", Locale.GetText ("'obj' argument cannot be null."));
+ if (context == null)
+ throw new ArgumentNullException ("context", Locale.GetText ("'context' argument cannot be null."));
+ }
+
+ [MonoTODO]
+ public override void Remove (object obj)
+ {
+ if (obj == null)
+ throw new ArgumentNullException ("obj", Locale.GetText ("'obj' argument cannot be null."));
+ }
+
+ #endregion // Methods
+ }
+}
+
+#endif
diff --git a/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/CompiledQuery.cs b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/CompiledQuery.cs
new file mode 100755
index 00000000000..5fc64072482
--- /dev/null
+++ b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/CompiledQuery.cs
@@ -0,0 +1,21 @@
+//
+// System.Data.ObjectSpaces.CompiledQuery.cs : A pre-compiled OPath query
+//
+// Author:
+// Mark Easton (mark.easton@blinksoftware.co.uk)
+//
+// (C) BLiNK Software Ltd. http://www.blinksoftware.co.uk
+//
+
+#if NET_1_2
+
+namespace System.Data.ObjectSpaces
+{
+ public class CompiledQuery
+ {
+ [MonoTODO]
+ private CompiledQuery () {}
+ }
+}
+
+#endif \ No newline at end of file
diff --git a/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/ContextException.cs b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/ContextException.cs
new file mode 100755
index 00000000000..16d595af61f
--- /dev/null
+++ b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/ContextException.cs
@@ -0,0 +1,45 @@
+//
+// System.Data.ObjectSpaces.ContextException.cs : The exception thrown when an ObjectContext encounters an error
+//
+// Author:
+// Mark Easton (mark.easton@blinksoftware.co.uk)
+//
+// (C) BLiNK Software Ltd. http://www.blinksoftware.co.uk
+//
+
+#if NET_1_2
+
+using System.Globalization;
+using System.Runtime.Serialization;
+
+namespace System.Data.ObjectSpaces
+{
+ public class ContextException : ObjectException
+ {
+ [MonoTODO]
+ public ContextException ()
+ : base (Locale.GetText ("A Context Exception has occurred."))
+ {
+ }
+
+ [MonoTODO]
+ protected ContextException (SerializationInfo info, StreamingContext context)
+ : base (info, context)
+ {
+ }
+
+ [MonoTODO]
+ public ContextException (string message)
+ : base (message)
+ {
+ }
+
+ [MonoTODO]
+ public ContextException (string message, Exception innerException)
+ : base (message, innerException)
+ {
+ }
+ }
+}
+
+#endif
diff --git a/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/DbObjectReader.cs b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/DbObjectReader.cs
new file mode 100755
index 00000000000..d4567ffafcf
--- /dev/null
+++ b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/DbObjectReader.cs
@@ -0,0 +1,65 @@
+//
+// System.Data.ObjectSpaces.DbObjectReader.cs
+//
+// Author:
+// Mark Easton (mark.easton@blinksoftware.co.uk)
+//
+// (C) BLiNK Software Ltd. http://www.blinksoftware.co.uk
+//
+
+#if NET_1_2
+
+using System.Data;
+using System.Data.Mapping;
+
+namespace System.Data.ObjectSpaces
+{
+ public class DbObjectReader : ObjectReader
+ {
+ [MonoTODO]
+ public DbObjectReader (IDataReader dataReader, Type type, MappingSchema map)
+ {
+ if (dataReader == null || type == null || map == null)
+ throw new ObjectException ();
+
+ }
+
+ [MonoTODO]
+ public DbObjectReader (IDataReader dataReader, Type type, MappingSchema map, ObjectContext context)
+ {
+ if (dataReader == null || type == null || map == null || context == null)
+ throw new ObjectException ();
+ }
+
+ [MonoTODO]
+ public override bool HasObjects {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public bool NextResult (Type type, MappingSchema map)
+ {
+ return false;
+ }
+
+ [MonoTODO]
+ public bool NextResult (Type type, MappingSchema map, ObjectContext context)
+ {
+ return false;
+ }
+
+ [MonoTODO]
+ public override void Close ()
+ {
+ base.Close();
+ }
+
+ [MonoTODO]
+ public override bool Read()
+ {
+ return false;
+ }
+ }
+}
+
+#endif
diff --git a/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/Depth.cs b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/Depth.cs
new file mode 100755
index 00000000000..89a9b7f064d
--- /dev/null
+++ b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/Depth.cs
@@ -0,0 +1,21 @@
+//
+// System.Data.ObjectSpaces.Depth.cs - Specifies the shallowness of object changing operations
+//
+// Author:
+// Mark Easton (mark.easton@blinksoftware.co.uk)
+//
+// (C) BLiNK Software Ltd. http://www.blinksoftware.co.uk
+//
+
+#if NET_1_2
+
+namespace System.Data.ObjectSpaces
+{
+ public enum Depth
+ {
+ SingleObject,
+ ObjectGraph
+ }
+}
+
+#endif
diff --git a/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/DynamicAssembly.cs b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/DynamicAssembly.cs
new file mode 100755
index 00000000000..3c0209d3566
--- /dev/null
+++ b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/DynamicAssembly.cs
@@ -0,0 +1,90 @@
+//
+// System.Data.ObjectSpaces.DynamicAssembly.cs
+//
+// Author:
+// Mark Easton (mark.easton@blinksoftware.co.uk)
+//
+// (C) BLiNK Software Ltd. http://www.blinksoftware.co.uk
+//
+
+#if NET_1_2
+
+using System.Data.Mapping;
+using System.Reflection;
+
+namespace System.Data.ObjectSpaces
+{
+ [MonoTODO]
+ public class DynamicAssembly
+ {
+ private Type type; //The underlying type
+
+ protected FieldInfo fInfo;
+ protected PropertyInfo pInfo;
+
+ [MonoTODO]
+ protected DynamicAssembly (Type type)
+ {
+ this.type = type;
+ }
+
+ public Type UnderLyingType {
+ get { return this.type; }
+ }
+
+
+ [MonoTODO]
+ public virtual object CreateObject (ObjectEngine engine,
+ ObjectContext context,
+ MappingSchema map,
+ ObjectSources sources)
+ {
+ return null;
+ }
+
+ [MonoTODO]
+ public FieldInfo[] GetFields()
+ {
+ return null;
+ }
+
+ [MonoTODO]
+ public PropertyInfo[] GetProperties ()
+ {
+ return null;
+ }
+
+
+
+ [MonoTODO]
+ public virtual object GetValue (object obj, PropertyInfo propertyInfo)
+ {
+ return null;
+ }
+
+ [MonoTODO]
+ public virtual object GetValue (object obj, FieldInfo fieldInfo)
+ {
+ return null;
+ }
+
+ [MonoTODO]
+ public virtual object GetValue (object obj, MemberInfo memberInfo, string memberPath)
+ {
+ return null;
+ }
+
+
+
+ [MonoTODO]
+ public virtual void SetValue (object obj, PropertyInfo propertyInfo, object value) {}
+
+ [MonoTODO]
+ public virtual void SetValue (object obj, FieldInfo fieldInfo, object value) {}
+
+ [MonoTODO]
+ public virtual void SetValue (object obj, MemberInfo memberInfo, string memberPath, object value) {}
+ }
+}
+
+#endif
diff --git a/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/IObjectHelper.cs b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/IObjectHelper.cs
new file mode 100755
index 00000000000..facddcaabef
--- /dev/null
+++ b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/IObjectHelper.cs
@@ -0,0 +1,24 @@
+//
+// System.Data.ObjectSpaces.IObjectHelper.cs - Helps out a bit...
+//
+// Author:
+// Mark Easton (mark.easton@blinksoftware.co.uk)
+//
+// (C) BLiNK Software Ltd. http://www.blinksoftware.co.uk
+//
+
+#if NET_1_2
+
+namespace System.Data.ObjectSpaces
+{
+ public interface IObjectHelper
+ {
+ object this [string name] {
+ get;
+ set;
+ }
+
+ }
+}
+
+#endif
diff --git a/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/IObjectNotification.cs b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/IObjectNotification.cs
new file mode 100755
index 00000000000..71e2d7279f3
--- /dev/null
+++ b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/IObjectNotification.cs
@@ -0,0 +1,28 @@
+//
+// System.Data.ObjectSpaces.IObjectNotification.cs - Provides notification of events during a persisted objects lifetime
+//
+// Author:
+// Mark Easton (mark.easton@blinksoftware.co.uk)
+//
+// (C) BLiNK Software Ltd. http://www.blinksoftware.co.uk
+//
+
+#if NET_1_2
+
+namespace System.Data.ObjectSpaces
+{
+ public interface IObjectNotification
+ {
+ void OnCreated ();
+ void OnCreating ();
+ void OnDeleted ();
+ void OnDeleting ();
+ void OnMaterialized ();
+ void OnPersistError ();
+ void OnUpdated ();
+ void OnUpdating ();
+
+ }
+}
+
+#endif
diff --git a/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/InitialState.cs b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/InitialState.cs
new file mode 100755
index 00000000000..7deda4ec91d
--- /dev/null
+++ b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/InitialState.cs
@@ -0,0 +1,21 @@
+//
+// System.Data.ObjectSpaces.InitialState.cs - The initial ObjectState for new objects
+//
+// Author:
+// Mark Easton (mark.easton@blinksoftware.co.uk)
+//
+// (C) BLiNK Software Ltd. http://www.blinksoftware.co.uk
+//
+
+#if NET_1_2
+
+namespace System.Data.ObjectSpaces
+{
+ public enum InitialState
+ {
+ Inserted,
+ Changed
+ }
+}
+
+#endif \ No newline at end of file
diff --git a/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/KeyGenerator.cs b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/KeyGenerator.cs
new file mode 100755
index 00000000000..f5dbb194365
--- /dev/null
+++ b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/KeyGenerator.cs
@@ -0,0 +1,34 @@
+//
+// System.Data.ObjectSpaces.KeyGenerator.cs
+//
+// Author:
+// Mark Easton (mark.easton@blinksoftware.co.uk)
+//
+// (C) BLiNK Software Ltd. http://www.blinksoftware.co.uk
+//
+
+#if NET_1_2
+
+namespace System.Data.ObjectSpaces
+{
+ [MonoTODO]
+ public abstract class KeyGenerator
+ {
+ [MonoTODO]
+ protected KeyGenerator ()
+ {
+ }
+
+ public abstract Type OwnerType { get; }
+
+ public abstract string UserParameter { get; }
+
+ public abstract Type GetKeyType ();
+
+ public abstract void Initialize (Type type, string userParameter);
+
+ public abstract object NextKey ();
+ }
+}
+
+#endif
diff --git a/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/ManyToManyRelationship.cs b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/ManyToManyRelationship.cs
new file mode 100755
index 00000000000..7e9df59656a
--- /dev/null
+++ b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/ManyToManyRelationship.cs
@@ -0,0 +1,26 @@
+//
+// System.Data.ObjectSpaces.ManyToManyRelationship.cs
+//
+// Author:
+// Mark Easton (mark.easton@blinksoftware.co.uk)
+//
+// (C) BLiNK Software Ltd. http://www.blinksoftware.co.uk
+//
+
+#if NET_1_2
+
+using System.Collections;
+
+namespace System.Data.ObjectSpaces
+{
+ [MonoTODO]
+ public class ManyToManyRelationship : ObjectKeyManager
+ {
+ [MonoTODO]
+ public ArrayList ObjectKeys {
+ get { return null; }
+ }
+ }
+}
+
+#endif \ No newline at end of file
diff --git a/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/ManyToOneRelationship.cs b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/ManyToOneRelationship.cs
new file mode 100755
index 00000000000..9773a45a669
--- /dev/null
+++ b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/ManyToOneRelationship.cs
@@ -0,0 +1,25 @@
+//
+// System.Data.ObjectSpaces.ManyToOneRelationship.cs
+//
+// Author:
+// Mark Easton (mark.easton@blinksoftware.co.uk)
+//
+// (C) BLiNK Software Ltd. http://www.blinksoftware.co.uk
+//
+
+#if NET_1_2
+
+namespace System.Data.ObjectSpaces
+{
+ [MonoTODO]
+ public class ManyToOneRelationship : ObjectKeyManager
+ {
+ [MonoTODO]
+ public ObjectKey ForeignKey {
+ get { return null; }
+ set {}
+ }
+ }
+}
+
+#endif \ No newline at end of file
diff --git a/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/ObjectContext.cs b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/ObjectContext.cs
new file mode 100755
index 00000000000..3a914b6ab71
--- /dev/null
+++ b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/ObjectContext.cs
@@ -0,0 +1,55 @@
+//
+// System.Data.ObjectSpaces.ObjectContext.cs : Handles identity and state for persistent objects.
+//
+// Author:
+// Mark Easton (mark.easton@blinksoftware.co.uk)
+//
+// (C) BLiNK Software Ltd. http://www.blinksoftware.co.uk
+//
+
+#if NET_1_2
+
+namespace System.Data.ObjectSpaces
+{
+ public abstract class ObjectContext
+ {
+ [MonoTODO]
+ protected ObjectContext ()
+ {
+ }
+
+ public virtual void Add (object obj)
+ {
+ Add (obj, (ObjectState) (-1));
+ }
+
+ [MonoTODO]
+ public virtual void Add (object obj, ObjectState state)
+ {
+ }
+
+ public abstract void Delete (object obj);
+ public abstract ValueRecord GetCurrentValueRecord (object obj);
+
+ [MonoTODO]
+ public static ObjectContext GetInternalContext (ObjectSpace objectSpace)
+ {
+ return null;
+ }
+
+ [MonoTODO]
+ public static ObjectContext GetInternalContext (ObjectSet objectSet)
+ {
+ return null;
+ }
+
+ public abstract ObjectState GetObjectState (object obj);
+ public abstract ValueRecord GetOriginalValueRecord (object obj);
+ public abstract void Import (ObjectContext context);
+ public abstract void Import (ObjectContext context, object obj);
+ public abstract void Remove (object obj);
+
+ }
+}
+
+#endif
diff --git a/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/ObjectEngine.cs b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/ObjectEngine.cs
new file mode 100755
index 00000000000..51478172b78
--- /dev/null
+++ b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/ObjectEngine.cs
@@ -0,0 +1,49 @@
+//
+// System.Data.ObjectSpaces.ObjectEngine.cs : Handles low-level object persistence operations with data sources.
+//
+// Author:
+// Mark Easton (mark.easton@blinksoftware.co.uk)
+//
+// (C) BLiNK Software Ltd. http://www.blinksoftware.co.uk
+//
+
+#if NET_1_2
+
+using System.Collections;
+using System.Data.Mapping;
+using System.Reflection;
+
+namespace System.Data.ObjectSpaces
+{
+ [MonoTODO]
+ public class ObjectEngine
+ {
+ [MonoTODO]
+ public static void Fetch (MappingSchema map, ObjectSources sources, ObjectContext context,
+ object obj, string propertyName) {}
+
+ [MonoTODO]
+ public static ObjectReader GetObjectReader (ObjectSources sources, ObjectContext context,
+ CompiledQuery compiledQuery, object[] parameters)
+ {
+ return null;
+ }
+
+ [MonoTODO]
+ public static ValueRecord GetPersistentValueRecord (MappingSchema map, ObjectSources sources, object obj)
+ {
+ return null;
+ }
+
+ [MonoTODO]
+ public static void PersistChanges(MappingSchema map, ObjectSources sources,
+ ObjectContext context, ICollection objs, PersistenceOptions options) {}
+
+ [MonoTODO]
+ public static void Resync (MappingSchema map, ObjectSources sources,
+ ObjectContext context, ICollection objs, Depth depth) {}
+
+ }
+}
+
+#endif
diff --git a/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/ObjectException.cs b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/ObjectException.cs
new file mode 100755
index 00000000000..47a6bf62e32
--- /dev/null
+++ b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/ObjectException.cs
@@ -0,0 +1,46 @@
+//
+// System.Data.ObjectSpaces.ObjectException.cs
+//
+// Author:
+// Tim Coleman (tim@timcoleman.com)
+//
+// Copyright (C) Tim Coleman, 2003
+//
+
+#if NET_1_2
+
+using System;
+using System.Globalization;
+using System.Runtime.Serialization;
+
+namespace System.Data.ObjectSpaces
+{
+ public class ObjectException : SystemException
+ {
+ [MonoTODO()]
+ protected ObjectException (SerializationInfo info, StreamingContext context)
+ : base (info, context)
+ {
+ }
+
+ [MonoTODO()]
+ public ObjectException ()
+ : base (Locale.GetText ("An object exception has occurred."))
+ {
+ }
+
+ [MonoTODO()]
+ public ObjectException (String s)
+ : base (s)
+ {
+ }
+
+ [MonoTODO()]
+ public ObjectException (String s, Exception innerException)
+ : base (s, innerException)
+ {
+ }
+ }
+}
+
+#endif
diff --git a/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/ObjectHolder.cs b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/ObjectHolder.cs
new file mode 100755
index 00000000000..9f5521095fc
--- /dev/null
+++ b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/ObjectHolder.cs
@@ -0,0 +1,31 @@
+//
+// System.Data.ObjectSpaces.ObjectHolder.cs - An object wrapper to facilitate delayed loading
+//
+// Author:
+// Mark Easton (mark.easton@blinksoftware.co.uk)
+//
+// (C) BLiNK Software Ltd. http://www.blinksoftware.co.uk
+//
+
+#if NET_1_2
+
+namespace System.Data.ObjectSpaces
+{
+ [MonoTODO]
+ public class ObjectHolder
+ {
+ private object innerObject; //The wrapped object
+
+ [MonoTODO]
+ public ObjectHolder () {}
+
+ [MonoTODO]
+ public object InnerObject {
+ get { return this.innerObject; }
+ set { this.innerObject = value; }
+ }
+
+ }
+}
+
+#endif \ No newline at end of file
diff --git a/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/ObjectKey.cs b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/ObjectKey.cs
new file mode 100755
index 00000000000..1164e2f42eb
--- /dev/null
+++ b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/ObjectKey.cs
@@ -0,0 +1,40 @@
+//
+// System.Data.ObjectSpaces.ObjectKey.cs : Provides a unique identifer for persistable objects
+//
+// Author:
+// Mark Easton (mark.easton@blinksoftware.co.uk)
+//
+// (C) BLiNK Software Ltd. http://www.blinksoftware.co.uk
+//
+
+#if NET_1_2
+
+namespace System.Data.ObjectSpaces
+{
+ public class ObjectKey
+ {
+
+ [MonoTODO]
+ public ObjectKey (Type type, object[] values) {}
+
+ [MonoTODO]
+ public ObjectKey (Type type, string key) {}
+
+ [MonoTODO]
+ public string KeyText {
+ get{ return String.Empty; }
+ }
+
+ [MonoTODO]
+ public Type Type {
+ get{ return typeof(object); }
+ }
+
+ [MonoTODO]
+ public object[] Values {
+ get{ return null; }
+ }
+ }
+}
+
+#endif \ No newline at end of file
diff --git a/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/ObjectKeyManager.cs b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/ObjectKeyManager.cs
new file mode 100755
index 00000000000..ebde85c0b00
--- /dev/null
+++ b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/ObjectKeyManager.cs
@@ -0,0 +1,31 @@
+//
+// System.Data.ObjectSpaces.ObjectKeyManager.cs
+//
+// Author:
+// Mark Easton (mark.easton@blinksoftware.co.uk)
+// Tim Coleman (tim@timcoleman.com)
+//
+// (C) BLiNK Software Ltd. http://www.blinksoftware.co.uk
+// Copyright (C) Tim Coleman, 2003
+//
+
+#if NET_1_2
+
+namespace System.Data.ObjectSpaces {
+ public abstract class ObjectKeyManager
+ {
+ [MonoTODO]
+ public override bool Equals (object obj)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public override int GetHashCode ()
+ {
+ throw new NotImplementedException ();
+ }
+ }
+}
+
+#endif
diff --git a/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/ObjectList.cs b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/ObjectList.cs
new file mode 100755
index 00000000000..5fbe8e5cb54
--- /dev/null
+++ b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/ObjectList.cs
@@ -0,0 +1,108 @@
+//
+// System.Data.ObjectSpaces.ObjectList.cs
+//
+// Author:
+// Mark Easton (mark.easton@blinksoftware.co.uk)
+//
+// (C) BLiNK Software Ltd. http://www.blinksoftware.co.uk
+//
+
+#if NET_1_2
+
+using System.Collections;
+
+namespace System.Data.ObjectSpaces
+{
+ [MonoTODO]
+ public class ObjectList : ICollection, IEnumerable, IList
+ {
+
+ [MonoTODO]
+ public ObjectList () : this (typeof (ArrayList), null) {}
+
+ [MonoTODO]
+ public ObjectList (Type type, object[] parameters)
+ {
+ if (type == null || !(type is IList))
+ throw new ObjectException ();
+ }
+
+ [MonoTODO]
+ public int Count {
+ get { return 0; }
+ }
+
+ [MonoTODO]
+ private bool ICollection.IsSynchronized {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ private object ICollection.SyncRoot {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public IList InnerList {
+ get { return null; }
+ }
+
+ [MonoTODO]
+ public bool IsFixedSize {
+ get { return false; }
+ }
+
+ [MonoTODO]
+ public bool IsReadOnly {
+ get { return false; }
+ }
+
+ [MonoTODO]
+ public object this[int index] {
+ get { throw new NotImplementedException (); }
+ set { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public int Add (object value)
+ {
+ return 0;
+ }
+
+ [MonoTODO]
+ public void Clear () {}
+
+ [MonoTODO]
+ public bool Contains (object value)
+ {
+ return false;
+ }
+
+ [MonoTODO]
+ public void CopyTo (Array array, int index) {}
+
+
+ [MonoTODO]
+ public IEnumerator GetEnumerator ()
+ {
+ return null;
+ }
+
+ [MonoTODO]
+ public int IndexOf (object value)
+ {
+ return 0;
+ }
+
+ [MonoTODO]
+ public void Insert (int index, object value) {}
+
+ [MonoTODO]
+ public void Remove (object value) {}
+
+ [MonoTODO]
+ public void RemoveAt (int index) {}
+ }
+}
+
+#endif
diff --git a/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/ObjectQuery.cs b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/ObjectQuery.cs
new file mode 100755
index 00000000000..66b34718adc
--- /dev/null
+++ b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/ObjectQuery.cs
@@ -0,0 +1,76 @@
+//
+// System.Data.ObjectSpaces.ObjectQuery.cs
+//
+// Author:
+// Tim Coleman (tim@timcoleman.com)
+//
+// Copyright (C) Tim Coleman, 2003
+//
+
+#if NET_1_2
+
+namespace System.Data.ObjectSpaces
+{
+ public class ObjectQuery
+ {
+ bool baseTypeOnly;
+ Type objectType;
+ string query;
+ string sort;
+ string span;
+
+ [MonoTODO()]
+ public ObjectQuery (Type type, string query)
+ : this (type, query, null)
+ {
+ }
+
+ [MonoTODO()]
+ public ObjectQuery (Type type, string query, string span)
+ {
+ SetObjectType (type);
+ SetQuery (query);
+
+ this.baseTypeOnly = false;
+ this.sort = null;
+ this.span = span;
+ }
+
+ [MonoTODO("Error handling")]
+ public bool BaseTypeOnly {
+ get { return baseTypeOnly; }
+ set { baseTypeOnly = value; }
+ }
+
+ public Type ObjectType {
+ get { return objectType; }
+ }
+
+ public string Query {
+ get { return query; }
+ }
+
+ public string Sort {
+ get { return sort; }
+ set { sort = value; }
+ }
+
+ public string Span {
+ get { return span; }
+ }
+
+ [MonoTODO()]
+ private void SetObjectType (Type type)
+ {
+ objectType = type;
+ }
+
+ [MonoTODO()]
+ private void SetQuery (string query)
+ {
+ this.query = query;
+ }
+ }
+}
+
+#endif
diff --git a/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/ObjectReader.cs b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/ObjectReader.cs
new file mode 100755
index 00000000000..d0f8abaf585
--- /dev/null
+++ b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/ObjectReader.cs
@@ -0,0 +1,88 @@
+//
+// System.Data.ObjectSpaces.ObjectReader.cs
+//
+// Author:
+// Mark Easton (mark.easton@blinksoftware.co.uk)
+//
+// (C) BLiNK Software Ltd. http://www.blinksoftware.co.uk
+//
+
+#if NET_1_2
+
+using System.Collections;
+
+namespace System.Data.ObjectSpaces
+{
+ public abstract class ObjectReader : IDisposable, IEnumerable
+ {
+ //Inform listeners when a ValueRecord is being merged
+ public event ValueRecordMergeEventHandler ValueMerging;
+
+ private bool isClosed = true; //Is the reader closed
+
+
+ [MonoTODO]
+ public object Current {
+ get { return null; }
+ }
+
+ public abstract bool HasObjects { get; }
+
+ [MonoTODO]
+ public virtual bool IsClosed {
+ get { return this.isClosed; }
+ }
+
+
+ [MonoTODO]
+ public ObjectContext ObjectContext {
+ get { return null; }
+ }
+
+
+ [MonoTODO]
+ public Type ObjectType {
+ get { return null; }
+ }
+
+
+ [MonoTODO]
+ public virtual void Close ()
+ {
+ this.isClosed = true;
+ }
+
+
+ [MonoTODO]
+ protected virtual void Dispose (bool disposing) {}
+
+
+
+ [MonoTODO]
+ public IEnumerator GetEnumerator ()
+ {
+ return null;
+ }
+
+ [MonoTODO]
+ private void IDisposable.Dispose ()
+ {
+ }
+
+ [MonoTODO]
+ protected virtual void OnValueMerging (ValueRecordMergeEventArgs e)
+ {
+ if (this.ValueMerging != null)
+ this.ValueMerging (this, e);
+ }
+
+
+ [MonoTODO]
+ public virtual bool Read()
+ {
+ return false;
+ }
+ }
+}
+
+#endif
diff --git a/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/ObjectSet.cs b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/ObjectSet.cs
new file mode 100755
index 00000000000..3006bdd4609
--- /dev/null
+++ b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/ObjectSet.cs
@@ -0,0 +1,132 @@
+//
+// System.Data.ObjectSpaces.ObjectSet.cs
+//
+// Author:
+// Tim Coleman (tim@timcoleman.com)
+//
+// Copyright (C) Tim Coleman, 2003
+//
+
+#if NET_1_2
+
+using System.Collections;
+using System.ComponentModel;
+using System.Data.ObjectSpaces.Schema;
+using System.Xml;
+using System.Xml.Schema;
+using System.Xml.Serialization;
+
+namespace System.Data.ObjectSpaces
+{
+ public class ObjectSet : CollectionBase, IListSource, IXmlSerializable
+ {
+ #region Constructors
+
+ [MonoTODO]
+ public ObjectSet (Type t, ObjectSchema oschema)
+ {
+ throw new NotImplementedException();
+ }
+
+ [MonoTODO]
+ public ObjectSet ()
+ {
+ throw new NotImplementedException ();
+ }
+
+ #endregion // Constructors
+
+ #region Properties
+
+ [MonoTODO]
+ public object this [int i] {
+ get { throw new NotImplementedException(); }
+ set { throw new NotImplementedException(); }
+ }
+
+ [MonoTODO]
+ private bool IListSource.ContainsListCollection {
+ get { throw new NotImplementedException(); }
+ }
+
+ #endregion // Properties
+
+ #region Methods
+
+ [MonoTODO]
+ public void Add (object o)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void Add (ICollection c)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void Add (object o, ObjectState state)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void GetRemotingDiffGram (XmlWriter writer)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ private IList IListSource.GetList ()
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ private XmlSchema IXmlSerializable.GetSchema()
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ private void IXmlSerializable.ReadXml (XmlReader reader)
+ {
+ throw new NotImplementedException();
+ }
+
+ [MonoTODO]
+ private void IXmlSerializable.WriteXml (XmlWriter writer)
+ {
+ throw new NotImplementedException();
+ }
+
+ [MonoTODO]
+ protected override void OnInsertComplete (int index, object value)
+ {
+ throw new NotImplementedException();
+ }
+
+ [MonoTODO]
+ protected override void OnRemoveComplete (int index, object value)
+ {
+ throw new NotImplementedException();
+ }
+
+ [MonoTODO]
+ protected override void OnSetComplete (int index, object oldValue, object newValue)
+ {
+ throw new NotImplementedException();
+ }
+
+ [MonoTODO]
+ public void StartTracking (Object o, InitialState state)
+ {
+ throw new NotImplementedException();
+ }
+
+ #endregion // Methods
+ }
+}
+
+#endif // NET_1_2
diff --git a/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/ObjectSources.cs b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/ObjectSources.cs
new file mode 100755
index 00000000000..12aced52e24
--- /dev/null
+++ b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/ObjectSources.cs
@@ -0,0 +1,86 @@
+//
+// System.Data.ObjectSpaces.ObjectSources.cs
+//
+// Author:
+// Tim Coleman (tim@timcoleman.com)
+//
+// Copyright (C) Tim Coleman, 2003
+//
+
+#if NET_1_2
+
+using System.Collections;
+
+namespace System.Data.ObjectSpaces {
+ public class ObjectSources : IDataSources, IEnumerable
+ {
+ #region Constructors
+
+ public ObjectSources ()
+ {
+ }
+
+ #endregion // Constructors
+
+ #region Properties
+
+ [MonoTODO]
+ public int Count {
+ get { throw new NotImplementedException (); }
+ }
+
+ public object this [string name] {
+ get { throw new NotImplementedException (); }
+ }
+
+ #endregion // Properties
+
+ #region Methods
+
+ [MonoTODO]
+ public void Add (string name, IDbConnection connection)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void Add (string name, IDbTransaction transaction)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void Clear ()
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public bool Contains (string name)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void Remove (string name)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public virtual IDictionaryEnumerator GetEnumerator ()
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ private IEnumerator IEnumerable.GetEnumerator ()
+ {
+ throw new NotImplementedException ();
+ }
+
+ #endregion // Methods
+ }
+}
+
+#endif
diff --git a/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/ObjectSpace.cs b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/ObjectSpace.cs
new file mode 100755
index 00000000000..b450723a5a7
--- /dev/null
+++ b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/ObjectSpace.cs
@@ -0,0 +1,119 @@
+//
+// System.Data.ObjectSpaces.ObjectSpace.cs : Handles high-level object persistence interactions with a data source.
+//
+// Author:
+// Mark Easton (mark.easton@blinksoftware.co.uk)
+//
+// (C) BLiNK Software Ltd. http://www.blinksoftware.co.uk
+//
+
+#if NET_1_2
+
+using System.Collections;
+using System.Data;
+using System.Data.Mapping;
+
+namespace System.Data.ObjectSpaces
+{
+ public class ObjectSpace
+ {
+ [MonoTODO]
+ public ObjectSpace (MappingSchema map, ObjectSources sources) {}
+
+ [MonoTODO]
+ public ObjectSpace (string mapFile, IDbConnection conn) {}
+
+ [MonoTODO]
+ public ObjectSpace (string mapFile, ObjectSources sources) {}
+
+ [MonoTODO]
+ public ObjectSpace (MappingSchema map, IDbConnection conn) {}
+
+ [MonoTODO]
+ public object GetObject (ObjectQuery query, object[] parameters)
+ {
+ return null;
+ }
+
+ [MonoTODO]
+ public object GetObject (Type type, string queryString)
+ {
+ return null;
+ }
+
+ [MonoTODO]
+ public object GetObject (Type type, string queryString, string relatedSpan)
+ {
+ return null;
+ }
+
+ [MonoTODO]
+ public ObjectReader GetObjectReader (ObjectQuery query, object[] parameters)
+ {
+ return null;
+ }
+
+ [MonoTODO]
+ public ObjectReader GetObjectReader (Type type, string queryString)
+ {
+ return null;
+ }
+
+ [MonoTODO]
+ public ObjectReader GetObjectReader (Type type, string queryString, string relatedSpan)
+ {
+ return null;
+ }
+
+ [MonoTODO]
+ public ObjectSet GetObjectSet (ObjectQuery query, object[] parameters)
+ {
+ return null;
+ }
+
+ [MonoTODO]
+ public ObjectSet GetObjectSet (Type type, string queryString)
+ {
+ return null;
+ }
+
+ [MonoTODO]
+ public ObjectSet GetObjectSet (Type type, string queryString, string relatedSpan)
+ {
+ return null;
+ }
+
+ [MonoTODO]
+ public void MarkForDeletion (object obj) {}
+
+ [MonoTODO]
+ public void MarkForDeletion (ICollection objs) {}
+
+ [MonoTODO]
+ public void PersistChanges (object obj) {}
+
+ [MonoTODO]
+ public void PersistChanges (object obj, PersistenceOptions options) {}
+
+ [MonoTODO]
+ public void PersistChanges (ICollection objs) {}
+
+ [MonoTODO]
+ public void PersistChanges (ICollection objs, PersistenceOptions options) {}
+
+ [MonoTODO]
+ public void Resync (object obj, Depth depth) {}
+
+ [MonoTODO]
+ public void Resync (ICollection objs, Depth depth) {}
+
+ [MonoTODO]
+ public void StartTracking (object obj, InitialState state) {}
+
+ [MonoTODO]
+ public void StartTracking (ICollection objs, InitialState state) {}
+
+ }
+}
+
+#endif
diff --git a/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/ObjectState.cs b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/ObjectState.cs
new file mode 100755
index 00000000000..d5b0d598093
--- /dev/null
+++ b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/ObjectState.cs
@@ -0,0 +1,24 @@
+//
+// System.Data.ObjectSpaces.ObjectState.cs - The modification state of a persitent object
+//
+// Author:
+// Mark Easton (mark.easton@blinksoftware.co.uk)
+//
+// (C) BLiNK Software Ltd. http://www.blinksoftware.co.uk
+//
+
+#if NET_1_2
+
+namespace System.Data.ObjectSpaces
+{
+ public enum ObjectState
+ {
+ Unknown,
+ Unchanged,
+ Inserted,
+ Updated,
+ Deleted
+ }
+}
+
+#endif \ No newline at end of file
diff --git a/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/OneToManyRelationship.cs b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/OneToManyRelationship.cs
new file mode 100755
index 00000000000..06ea05c2079
--- /dev/null
+++ b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/OneToManyRelationship.cs
@@ -0,0 +1,22 @@
+//
+// System.Data.ObjectSpaces.OneToManyRelationship.cs
+//
+// Author:
+// Mark Easton (mark.easton@blinksoftware.co.uk)
+//
+// (C) BLiNK Software Ltd. http://www.blinksoftware.co.uk
+//
+
+#if NET_1_2
+
+namespace System.Data.ObjectSpaces
+{
+ [MonoTODO]
+ public class OneToManyRelationship : ObjectKeyManager
+ {
+
+
+ }
+}
+
+#endif
diff --git a/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/OneToOneRelationship.cs b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/OneToOneRelationship.cs
new file mode 100755
index 00000000000..754490bfac2
--- /dev/null
+++ b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/OneToOneRelationship.cs
@@ -0,0 +1,34 @@
+//
+// System.Data.ObjectSpaces.OneToOneRelationship.cs
+//
+// Author:
+// Mark Easton (mark.easton@blinksoftware.co.uk)
+// Tim Coleman (tim@timcoleman.com)
+//
+// (C) BLiNK Software Ltd. http://www.blinksoftware.co.uk
+// Copyright (C) Tim Coleman, 2003
+//
+
+#if NET_1_2
+
+namespace System.Data.ObjectSpaces {
+ public class OneToOneRelationship : ObjectKeyManager
+ {
+ #region Fields
+
+ ObjectKey foreignKey;
+
+ #endregion // Fields
+
+ #region Properties
+
+ public ObjectKey ForeignKey {
+ get { return foreignKey; }
+ set { foreignKey = value; }
+ }
+
+ #endregion // Properties
+ }
+}
+
+#endif
diff --git a/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/PersistenceError.cs b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/PersistenceError.cs
new file mode 100755
index 00000000000..9988d189004
--- /dev/null
+++ b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/PersistenceError.cs
@@ -0,0 +1,36 @@
+//
+// System.Data.ObjectSpaces.PersistenceError
+//
+// Author:
+// Tim Coleman (tim@timcoleman.com)
+//
+// Copyright (C) Tim Coleman, 2003
+//
+
+#if NET_1_2
+
+namespace System.Data.ObjectSpaces {
+ public class PersistenceError
+ {
+ #region Properties
+
+ [MonoTODO]
+ public object ErrorObject {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public PersistenceErrorType ErrorType {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public Exception InnerException {
+ get { throw new NotImplementedException (); }
+ }
+
+ #endregion // Properties
+ }
+}
+
+#endif
diff --git a/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/PersistenceErrorBehavior.cs b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/PersistenceErrorBehavior.cs
new file mode 100755
index 00000000000..255201c9752
--- /dev/null
+++ b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/PersistenceErrorBehavior.cs
@@ -0,0 +1,23 @@
+//
+// System.Data.ObjectSpaces.PersistenceErrorBehavior.cs - The behaviour to follow when a persistence error occurs
+//
+// Author:
+// Mark Easton (mark.easton@blinksoftware.co.uk)
+// Tim Coleman (tim@timcoleman.com)
+//
+// (C) BLiNK Software Ltd. http://www.blinksoftware.co.uk
+// Copyright (C) Tim Coleman, 2003
+//
+
+#if NET_1_2
+
+namespace System.Data.ObjectSpaces
+{
+ public enum PersistenceErrorBehavior
+ {
+ ThrowAtFirstError,
+ ThrowAfterCompletion
+ }
+}
+
+#endif
diff --git a/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/PersistenceErrorBehaviour.cs b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/PersistenceErrorBehaviour.cs
new file mode 100755
index 00000000000..7f24e7c36f4
--- /dev/null
+++ b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/PersistenceErrorBehaviour.cs
@@ -0,0 +1,21 @@
+//
+// System.Data.ObjectSpaces.PersistenceErrorBehaviour.cs - The behaviour to follow when a persistence error occurs
+//
+// Author:
+// Mark Easton (mark.easton@blinksoftware.co.uk)
+//
+// (C) BLiNK Software Ltd. http://www.blinksoftware.co.uk
+//
+
+#if NET_1_2
+
+namespace System.Data.ObjectSpaces
+{
+ public enum PersistenceErrorBehaviour
+ {
+ ThrowAtFirstError,
+ ThrowAfterCompletion
+ }
+}
+
+#endif \ No newline at end of file
diff --git a/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/PersistenceErrorType.cs b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/PersistenceErrorType.cs
new file mode 100755
index 00000000000..d87e7a5bc0a
--- /dev/null
+++ b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/PersistenceErrorType.cs
@@ -0,0 +1,23 @@
+//
+// System.Data.ObjectSpaces.PersistenceErrorType.cs - The type of persistence error
+//
+// Author:
+// Mark Easton (mark.easton@blinksoftware.co.uk)
+//
+// (C) BLiNK Software Ltd. http://www.blinksoftware.co.uk
+//
+
+#if NET_1_2
+
+namespace System.Data.ObjectSpaces
+{
+ public enum PersistenceErrorType
+ {
+ Inserting,
+ Deleting,
+ Updating,
+ Unknown
+ }
+}
+
+#endif \ No newline at end of file
diff --git a/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/PersistenceException.cs b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/PersistenceException.cs
new file mode 100755
index 00000000000..faf48b97508
--- /dev/null
+++ b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/PersistenceException.cs
@@ -0,0 +1,76 @@
+//
+// System.Data.ObjectSpaces.PersistenceException
+//
+// Author:
+// Tim Coleman (tim@timcoleman.com)
+//
+// Copyright (C) Tim Coleman, 2003
+//
+
+#if NET_1_2
+
+using System.Collections;
+using System.Runtime.Serialization;
+
+namespace System.Data.ObjectSpaces {
+ public class PersistenceException : ObjectException
+ {
+ #region Fields
+
+ ArrayList errors;
+
+ #endregion // Fields
+
+ #region Constructors
+
+ [MonoTODO]
+ public PersistenceException (SerializationInfo info, StreamingContext context)
+ : base (info, context)
+ {
+ this.errors = new ArrayList ();
+ }
+
+ [MonoTODO]
+ public PersistenceException ()
+ : base ("A PersistenceException has occurred.")
+ {
+ this.errors = new ArrayList ();
+ }
+
+ [MonoTODO]
+ public PersistenceException (PersistenceError[] errors, string s)
+ : base (s)
+ {
+ this.errors = new ArrayList (errors);
+ }
+
+ [MonoTODO]
+ public PersistenceException (PersistenceError[] errors, string s, Exception innerException)
+ : base (s, innerException)
+ {
+ this.errors = new ArrayList (errors);
+ }
+
+ #endregion // Constructors
+
+ #region Properties
+
+ public ArrayList Errors {
+ get { return errors; }
+ }
+
+ #endregion // Properties
+
+ #region Methods
+
+ [MonoTODO]
+ public override void GetObjectData (SerializationInfo info, StreamingContext context)
+ {
+ throw new NotImplementedException ();
+ }
+
+ #endregion Methods
+ }
+}
+
+#endif
diff --git a/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/PersistenceOptions.cs b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/PersistenceOptions.cs
new file mode 100755
index 00000000000..b8350c2f817
--- /dev/null
+++ b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/PersistenceOptions.cs
@@ -0,0 +1,60 @@
+//
+// System.Data.ObjectSpaces.PersistenceOptions.cs
+//
+// Author:
+// Tim Coleman (tim@timcoleman.com)
+//
+// Copyright (C) Tim Coleman, 2003
+//
+
+#if NET_1_2
+
+namespace System.Data.ObjectSpaces {
+ public class PersistenceOptions
+ {
+ #region Constructors
+
+ [MonoTODO]
+ public PersistenceOptions (Depth depth, PersistenceErrorBehavior errorBehavior)
+ {
+ }
+
+ [MonoTODO]
+ public PersistenceOptions (PersistenceErrorBehavior errorBehavior)
+ {
+ }
+
+ [MonoTODO]
+ public PersistenceOptions (Depth depth)
+ {
+ }
+
+ [MonoTODO]
+ public PersistenceOptions ()
+ {
+ }
+
+ #endregion // Constructors
+
+ #region Properties
+
+ [MonoTODO]
+ public static PersistenceOptions Default {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public Depth Depth {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public PersistenceErrorBehavior ErrorBehavior {
+ get { throw new NotImplementedException (); }
+ }
+
+ #endregion // Properties
+ }
+}
+
+#endif
diff --git a/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/PersisteneceErrorType.cs b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/PersisteneceErrorType.cs
new file mode 100755
index 00000000000..d87e7a5bc0a
--- /dev/null
+++ b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/PersisteneceErrorType.cs
@@ -0,0 +1,23 @@
+//
+// System.Data.ObjectSpaces.PersistenceErrorType.cs - The type of persistence error
+//
+// Author:
+// Mark Easton (mark.easton@blinksoftware.co.uk)
+//
+// (C) BLiNK Software Ltd. http://www.blinksoftware.co.uk
+//
+
+#if NET_1_2
+
+namespace System.Data.ObjectSpaces
+{
+ public enum PersistenceErrorType
+ {
+ Inserting,
+ Deleting,
+ Updating,
+ Unknown
+ }
+}
+
+#endif \ No newline at end of file
diff --git a/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/UpdateErrorType.cs b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/UpdateErrorType.cs
new file mode 100755
index 00000000000..50ef4a0a449
--- /dev/null
+++ b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/UpdateErrorType.cs
@@ -0,0 +1,23 @@
+//
+// System.Data.ObjectSpaces.UpdateErrorType.cs - The type of an update error
+//
+// Author:
+// Mark Easton (mark.easton@blinksoftware.co.uk)
+//
+// (C) BLiNK Software Ltd. http://www.blinksoftware.co.uk
+//
+
+#if NET_1_2
+
+namespace System.Data.ObjectSpaces
+{
+ public enum UpdateErrorType
+ {
+ Inserting,
+ Deleting,
+ Updating,
+ Unknown
+ }
+}
+
+#endif \ No newline at end of file
diff --git a/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/ValueRecord.cs b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/ValueRecord.cs
new file mode 100755
index 00000000000..b860d8d4c9f
--- /dev/null
+++ b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/ValueRecord.cs
@@ -0,0 +1,50 @@
+//
+// System.Data.ObjectSpaces.ValueRecord.cs
+//
+// Author:
+// Mark Easton (mark.easton@blinksoftware.co.uk)
+//
+// (C) BLiNK Software Ltd. http://www.blinksoftware.co.uk
+//
+#if NET_1_2
+
+using System.Collections;
+
+namespace System.Data.ObjectSpaces
+{
+ [MonoTODO]
+ public class ValueRecord : IEnumerable
+ {
+
+ [MonoTODO]
+ public Type ObjectType {
+ get { return null; }
+ }
+
+ [MonoTODO]
+ public object this[string propertyName] {
+ get { return null; }
+ set {}
+ }
+
+ [MonoTODO]
+ public IEnumerator GetEnumerator ()
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public override int GetHashCode ()
+ {
+ return 0;
+ }
+
+ [MonoTODO]
+ public override bool Equals (object value)
+ {
+ return false;
+ }
+ }
+}
+
+#endif
diff --git a/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/ValueRecordMergeEventArgs.cs b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/ValueRecordMergeEventArgs.cs
new file mode 100755
index 00000000000..77969a40387
--- /dev/null
+++ b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/ValueRecordMergeEventArgs.cs
@@ -0,0 +1,46 @@
+//
+// System.Data.ObjectSpaces.ValueRecordMergeEventArgs.cs : The argument passed when a ValueRecord's merge event occurs
+//
+// Author:
+// Mark Easton (mark.easton@blinksoftware.co.uk)
+//
+// (C) BLiNK Software Ltd. http://www.blinksoftware.co.uk
+//
+
+#if NET_1_2
+
+namespace System.Data.ObjectSpaces
+{
+ public class ValueRecordMergeEventArgs
+ {
+ private ValueRecord currentRecord; //The current value record
+ private ValueRecord originalRecord; //The original value record
+ private ValueRecord persistentRecord; //The persistent value record
+
+
+ //Simple constructors are ideal to code on Monday afternoons
+ public ValueRecordMergeEventArgs (ValueRecord currentRecord,
+ ValueRecord originalRecord, ValueRecord persistentRecord)
+ {
+ this.currentRecord = currentRecord;
+ this.originalRecord = originalRecord;
+ this.persistentRecord = persistentRecord;
+ }
+
+
+ //Properties
+ public ValueRecord CurrentValueRecord {
+ get{ return currentRecord; }
+ }
+
+ public ValueRecord OriginalValueRecord {
+ get{ return originalRecord; }
+ }
+
+ public ValueRecord PersistentValueRecord {
+ get{ return persistentRecord; }
+ }
+ }
+}
+
+#endif \ No newline at end of file
diff --git a/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/ValueRecordMergeEventHandler.cs b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/ValueRecordMergeEventHandler.cs
new file mode 100755
index 00000000000..37a3c595b97
--- /dev/null
+++ b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces/ValueRecordMergeEventHandler.cs
@@ -0,0 +1,17 @@
+//
+// System.Data.ObjectSpaces.ValueRecordMergeEventHandler.cs : The delegate for handling ValueRecord's merge events
+//
+// Author:
+// Mark Easton (mark.easton@blinksoftware.co.uk)
+//
+// (C) BLiNK Software Ltd. http://www.blinksoftware.co.uk
+//
+
+#if NET_1_2
+
+namespace System.Data.ObjectSpaces
+{
+ public delegate void ValueRecordMergeEventHandler (object sender, ValueRecordMergeEventArgs e);
+}
+
+#endif \ No newline at end of file
diff --git a/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces_test.dll.sources b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces_test.dll.sources
new file mode 100644
index 00000000000..4821987d749
--- /dev/null
+++ b/mcs/class/System.Data.ObjectSpaces/System.Data.ObjectSpaces_test.dll.sources
@@ -0,0 +1,2 @@
+System.Data.ObjectSpaces/CommonObjectContextTests.cs
+System.Data.ObjectSpaces.Query/ObjectExpressionTests.cs
diff --git a/mcs/class/System.Data.ObjectSpaces/TODOAttribute.cs b/mcs/class/System.Data.ObjectSpaces/TODOAttribute.cs
new file mode 100644
index 00000000000..ff341fefd84
--- /dev/null
+++ b/mcs/class/System.Data.ObjectSpaces/TODOAttribute.cs
@@ -0,0 +1,39 @@
+//
+// TODOAttribute.cs
+//
+// Author:
+// Ravi Pratap (ravi@ximian.com)
+//
+// (C) Ximian, Inc. http://www.ximian.com
+//
+
+using System;
+
+namespace System.Data.ObjectSpaces {
+
+ /// <summary>
+ /// The TODO attribute is used to flag all incomplete bits in our class libraries
+ /// </summary>
+ ///
+ /// <remarks>
+ /// Use this to decorate any element which you think is not complete
+ /// </remarks>
+ [AttributeUsage (AttributeTargets.All, AllowMultiple=true)]
+ internal class MonoTODOAttribute : Attribute {
+
+ private string comment;
+
+ public MonoTODOAttribute ()
+ {}
+
+ public MonoTODOAttribute (string comment)
+ {
+ this.comment = comment;
+ }
+
+ public string Comment
+ {
+ get { return comment; }
+ }
+ }
+}
diff --git a/mcs/class/System.Data.ObjectSpaces/Test/ChangeLog b/mcs/class/System.Data.ObjectSpaces/Test/ChangeLog
new file mode 100644
index 00000000000..dda79c86678
--- /dev/null
+++ b/mcs/class/System.Data.ObjectSpaces/Test/ChangeLog
@@ -0,0 +1,10 @@
+2003-11-27 Tim Coleman <tim@timcoleman.com>
+ * System.Data.ObjectSpaces.Query/ObjectExpressionTests.cs:
+ * SupportFiles/osd.xml:
+ * SupportFiles/rsd.xml:
+ New classes added for test
+
+2003-11-26 Tim Coleman <tim@timcoleman.com>
+ * ChangeLog run_test.sh
+ * System.Data.ObjectSpaces/CommonObjectContextTests.cs:
+ New classes added for test
diff --git a/mcs/class/System.Data.ObjectSpaces/Test/SupportFiles/osd.xml b/mcs/class/System.Data.ObjectSpaces/Test/SupportFiles/osd.xml
new file mode 100644
index 00000000000..168bfab0d03
--- /dev/null
+++ b/mcs/class/System.Data.ObjectSpaces/Test/SupportFiles/osd.xml
@@ -0,0 +1,11 @@
+<osd:ExtendedObjectSchema Name="DataTypesOSD" xmlns:osd="http://schemas.microsoft.com/data/2002/09/20/persistenceschema">
+ <osd:Classes>
+ <osd:Class Name="Customer">
+ <osd:Member Name="Id" Key="true" />
+ <osd:Member Name="Company" />
+ <osd:Member Name="Name" />
+ <osd:Member Name="Phone" />
+ </osd:Class>
+ </osd:Classes>
+</osd:ExtendedObjectSchema>
+
diff --git a/mcs/class/System.Data.ObjectSpaces/Test/SupportFiles/rsd.xml b/mcs/class/System.Data.ObjectSpaces/Test/SupportFiles/rsd.xml
new file mode 100644
index 00000000000..e0714c96fb6
--- /dev/null
+++ b/mcs/class/System.Data.ObjectSpaces/Test/SupportFiles/rsd.xml
@@ -0,0 +1,19 @@
+<rsd:Database Name="Northwind" Owner="sa" xmlns:rsd="http://schemas.microsoft.com/data/2002/09/28/rsd">
+ <r:Schema Name="dbo" xmlns:r="http://schemas.microsoft.com/data/2002/09/28/rsd">
+ <rsd:Tables>
+ <rsd:Table Name="Customers">
+ <rsd:Columns>
+ <rsd:Column Name="CustomerID" SqlType="nchar" Precision="5" />
+ <rsd:Column Name="CompanyName" SqlType="nvarchar" Precision="40" />
+ <rsd:Column AllowDbNull="true" Name="ContactName" SqlType="nvarchar" Precision="30" />
+ <rsd:Column AllowDbNull="true" Name="Phone" SqlType="nvarchar" Precision="24" />
+ </rsd:Columns>
+ <rsd:Constraints>
+ <rsd:PrimaryKey Name="PK_Customers">
+ <rsd:ColumnRef Name="CustomerID" />
+ </rsd:PrimaryKey>
+ </rsd:Constraints>
+ </rsd:Table>
+ </rsd:Tables>
+ </r:Schema>
+</rsd:Database>
diff --git a/mcs/class/System.Data.ObjectSpaces/Test/System.Data.ObjectSpaces.Query/ObjectExpressionTests.cs b/mcs/class/System.Data.ObjectSpaces/Test/System.Data.ObjectSpaces.Query/ObjectExpressionTests.cs
new file mode 100755
index 00000000000..3e2ddc52090
--- /dev/null
+++ b/mcs/class/System.Data.ObjectSpaces/Test/System.Data.ObjectSpaces.Query/ObjectExpressionTests.cs
@@ -0,0 +1,49 @@
+//
+// System.Data.ObjectSpaces.Query.ObjectExpressionTests.cs
+//
+// Author:
+// Tim Coleman (tim@timcoleman.com)
+//
+// Copyright (C) Tim Coleman, 2003
+//
+
+#if NET_1_2
+
+using System;
+using System.Data.ObjectSpaces;
+using System.Data.ObjectSpaces.Query;
+using System.Data.ObjectSpaces.Schema;
+using NUnit.Framework;
+
+namespace MonoTests.System.Data.ObjectSpaces.Query
+{
+ [TestFixture]
+ public class ObjectExpressionTests : Assertion
+ {
+ ObjectExpression objectExpression;
+ Expression expression;
+ ObjectSchema objectSchema;
+
+ [SetUp]
+ public void GetReady ()
+ {
+ expression = new Parameter (1);
+ objectSchema = new ObjectSchema ();
+ objectExpression = new ObjectExpression (expression, objectSchema);
+ }
+
+ [Test]
+ public void Expression
+ {
+ AssertEquals ("#A01", expression, ObjectExpression.Expression);
+ }
+
+ [Test]
+ public void Expression ()
+ {
+ AssertEquals ("#A01", objectSchema, ObjectExpression.ObjectSchema);
+ }
+ }
+}
+
+#endif
diff --git a/mcs/class/System.Data.ObjectSpaces/Test/System.Data.ObjectSpaces/CommonObjectContextTests.cs b/mcs/class/System.Data.ObjectSpaces/Test/System.Data.ObjectSpaces/CommonObjectContextTests.cs
new file mode 100755
index 00000000000..880e88e208a
--- /dev/null
+++ b/mcs/class/System.Data.ObjectSpaces/Test/System.Data.ObjectSpaces/CommonObjectContextTests.cs
@@ -0,0 +1,77 @@
+//
+// System.Data.ObjectSpaces.CommonObjectContextTests.cs
+//
+// Author:
+// Tim Coleman (tim@timcoleman.com)
+//
+// Copyright (C) Tim Coleman, 2003
+//
+
+#if NET_1_2
+
+using System;
+using System.Data.ObjectSpaces;
+using System.Data.ObjectSpaces.Schema;
+using NUnit.Framework;
+
+namespace MonoTests.System.Data.ObjectSpaces
+{
+ [TestFixture]
+ public class CommonObjectContextTests : Assertion
+ {
+ CommonObjectContext context;
+
+ [SetUp]
+ public void GetReady ()
+ {
+ ObjectSchema schema = new ObjectSchema ();
+ context = new CommonObjectContext (schema);
+ }
+
+ [Test]
+ public void Add1 ()
+ {
+ try {
+ context.Add (null);
+ Fail ("Expected a ContextException to be thrown.");
+ } catch (ContextException) {}
+
+ try {
+ context.Add ("add1");
+ Fail ("Expected a NullReferenceException to be thrown.");
+ } catch (NullReferenceException) {}
+ }
+
+ [Test]
+ public void Add2 ()
+ {
+ try {
+ context.Add (null, ObjectState.Unknown);
+ Fail ("Expected a ContextException to be thrown.");
+ } catch (ContextException) {}
+
+ try {
+ context.Add ("add2", (ObjectState) (-1));
+ Fail ("Expected a NullReferenceException to be thrown.");
+ } catch (NullReferenceException) {}
+
+ try {
+ context.Add ("add2", ObjectState.Unknown);
+ Fail ("Expected a ContextException to be thrown.");
+ } catch (ContextException) {}
+
+ context.Add ("add2", ObjectState.Inserted);
+ }
+
+ [Test]
+ public void Delete ()
+ {
+ try {
+ context.Delete (null);
+ Fail ("Expected an ArgumentNullException to be thrown.");
+ } catch (ArgumentNullException) {}
+ }
+ }
+}
+
+#endif
diff --git a/mcs/class/System.Data.ObjectSpaces/Test/run_test.sh b/mcs/class/System.Data.ObjectSpaces/Test/run_test.sh
new file mode 100755
index 00000000000..1bdd9dfaaba
--- /dev/null
+++ b/mcs/class/System.Data.ObjectSpaces/Test/run_test.sh
@@ -0,0 +1,27 @@
+#!/bin/sh
+
+if [ $# -eq 0 ]; then
+ echo "You should give a list of test names such as: "
+ echo "$0 System.IO.FileTest System.Text.StringBuilderTest"
+ echo "or"
+ echo "$0 System.AllTests"
+ echo "or"
+ echo "$0 all"
+ echo "and so on..."
+ exit 1
+fi
+
+topdir=../../..
+NUNITCONSOLE=$topdir/class/lib/nunit-console.exe
+MONO_PATH=$topdir/nunit20:$topdir/class/lib:.
+
+for i in $@; do
+ if [ "$i" = "all" ]; then
+ fixture=""
+ else
+ fixture="/fixture:MonoTests.${i}"
+ fi
+ MONO_PATH=$MONO_PATH \
+ mono --debug ${NUNITCONSOLE} System.Data.ObjectSpaces_test.dll $fixture
+done
+
diff --git a/mcs/class/System.Data.SqlXml/ChangeLog b/mcs/class/System.Data.SqlXml/ChangeLog
new file mode 100644
index 00000000000..82ecc718bbf
--- /dev/null
+++ b/mcs/class/System.Data.SqlXml/ChangeLog
@@ -0,0 +1,8 @@
+2003-11-25 Tim Coleman <tim@timcoleman.com>
+ * Makefile:
+ * System.Data.Mapping/*.cs:
+ * System.Data.SqlXml/*.cs:
+ * System.Data.SqlXml.dll.sources:
+ * System.Xml.Query/*.cs:
+ * TODOAttribute.cs:
+ Create initial stubs for System.Data.SqlXml
diff --git a/mcs/class/System.Data.SqlXml/Makefile b/mcs/class/System.Data.SqlXml/Makefile
new file mode 100644
index 00000000000..5de085f8098
--- /dev/null
+++ b/mcs/class/System.Data.SqlXml/Makefile
@@ -0,0 +1,11 @@
+thisdir = class/System.Data.SqlXml
+SUBDIRS =
+include ../../build/rules.make
+
+LIBRARY = System.Data.SqlXml.dll
+LIB_MCS_FLAGS = /r:$(corlib),System.Data.dll,System.Xml.dll
+NO_TEST = yes
+
+EXTRA_DISTFILES =
+
+include ../../build/library.make
diff --git a/mcs/class/System.Data.SqlXml/System.Data.Mapping/Condition.cs b/mcs/class/System.Data.SqlXml/System.Data.Mapping/Condition.cs
new file mode 100755
index 00000000000..ad1bdf595e7
--- /dev/null
+++ b/mcs/class/System.Data.SqlXml/System.Data.Mapping/Condition.cs
@@ -0,0 +1,58 @@
+//
+// System.Data.Mapping.Condition
+//
+// Author:
+// Tim Coleman (tim@timcoleman.com)
+//
+// Copyright (C) Tim Coleman, 2003
+//
+
+#if NET_1_2
+
+using System.Data.SqlXml;
+
+namespace System.Data.Mapping {
+ public class Condition
+ {
+ #region Properties
+
+ [MonoTODO]
+ public Field LeftField {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public MappingConditionOperator Operator {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public Variable OwnerVariable {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public string RightConstant {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public Field RightField {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public MappingArgumentType RightOperandType {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public MappingParameter RightParameter {
+ get { throw new NotImplementedException (); }
+ }
+
+ #endregion // Properties
+ }
+}
+
+#endif // NET_1_2
diff --git a/mcs/class/System.Data.SqlXml/System.Data.Mapping/ConditionCollection.cs b/mcs/class/System.Data.SqlXml/System.Data.Mapping/ConditionCollection.cs
new file mode 100755
index 00000000000..cb36ce9a111
--- /dev/null
+++ b/mcs/class/System.Data.SqlXml/System.Data.Mapping/ConditionCollection.cs
@@ -0,0 +1,45 @@
+//
+// System.Data.Mapping.ConditionCollection
+//
+// Author:
+// Tim Coleman (tim@timcoleman.com)
+//
+// Copyright (C) Tim Coleman, 2003
+//
+
+#if NET_1_2
+
+using System.Data.SqlXml;
+using System.Collections;
+
+namespace System.Data.Mapping {
+ public class ConditionCollection : ReadOnlyCollectionBase
+ {
+ #region Properties
+
+ [MonoTODO]
+ public Condition this [int index] {
+ get { throw new NotImplementedException (); }
+ }
+
+ #endregion // Properties
+
+ #region Methods
+
+ [MonoTODO]
+ public bool Contains (Condition dataSource)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void CopyTo (Condition[] array, int index)
+ {
+ throw new NotImplementedException ();
+ }
+
+ #endregion // Methods
+ }
+}
+
+#endif // NET_1_2
diff --git a/mcs/class/System.Data.SqlXml/System.Data.Mapping/DataSource.cs b/mcs/class/System.Data.SqlXml/System.Data.Mapping/DataSource.cs
new file mode 100755
index 00000000000..97715934b5c
--- /dev/null
+++ b/mcs/class/System.Data.SqlXml/System.Data.Mapping/DataSource.cs
@@ -0,0 +1,68 @@
+//
+// System.Data.Mapping.DataSource
+//
+// Author:
+// Tim Coleman (tim@timcoleman.com)
+//
+// Copyright (C) Tim Coleman, 2003
+//
+
+#if NET_1_2
+
+using System.Data.SqlXml;
+
+namespace System.Data.Mapping {
+ public class DataSource
+ {
+ #region Properties
+
+ [MonoTODO]
+ public MappingDirection Direction {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public string name {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public MappingSchema OwnerMappingSchema {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public RelationshipCollection Relationships {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public IDomainSchema Schema {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public string SourceUri {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public MappingDataSourceType Type {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public VariableCollection Variables {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public bool WriteInline {
+ get { throw new NotImplementedException (); }
+ }
+
+ #endregion // Properties
+ }
+}
+
+#endif // NET_1_2
diff --git a/mcs/class/System.Data.SqlXml/System.Data.Mapping/DataSourceCollection.cs b/mcs/class/System.Data.SqlXml/System.Data.Mapping/DataSourceCollection.cs
new file mode 100755
index 00000000000..68dbda291fa
--- /dev/null
+++ b/mcs/class/System.Data.SqlXml/System.Data.Mapping/DataSourceCollection.cs
@@ -0,0 +1,50 @@
+//
+// System.Data.Mapping.DataSourceCollection
+//
+// Author:
+// Tim Coleman (tim@timcoleman.com)
+//
+// Copyright (C) Tim Coleman, 2003
+//
+
+#if NET_1_2
+
+using System.Collections;
+using System.Data.SqlXml;
+
+namespace System.Data.Mapping {
+ public class DataSourceCollection : ReadOnlyCollectionBase
+ {
+ #region Properties
+
+ [MonoTODO]
+ public DataSource this [int index] {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public DataSource this [string name] {
+ get { throw new NotImplementedException (); }
+ }
+
+ #endregion // Properties
+
+ #region Methods
+
+ [MonoTODO]
+ public bool Contains (DataSource dataSource)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void CopyTo (DataSource[] array, int index)
+ {
+ throw new NotImplementedException ();
+ }
+
+ #endregion // Methods
+ }
+}
+
+#endif // NET_1_2
diff --git a/mcs/class/System.Data.SqlXml/System.Data.Mapping/Field.cs b/mcs/class/System.Data.SqlXml/System.Data.Mapping/Field.cs
new file mode 100755
index 00000000000..5fe03398d20
--- /dev/null
+++ b/mcs/class/System.Data.SqlXml/System.Data.Mapping/Field.cs
@@ -0,0 +1,38 @@
+//
+// System.Data.Mapping.Field
+//
+// Author:
+// Tim Coleman (tim@timcoleman.com)
+//
+// Copyright (C) Tim Coleman, 2003
+//
+
+#if NET_1_2
+
+using System.Data.SqlXml;
+
+namespace System.Data.Mapping {
+ public class Field
+ {
+ #region Properties
+
+ [MonoTODO]
+ public IDomainField DomainField {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public string Name {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public Variable OwnerVariable {
+ get { throw new NotImplementedException (); }
+ }
+
+ #endregion // Properties
+ }
+}
+
+#endif // NET_1_2
diff --git a/mcs/class/System.Data.SqlXml/System.Data.Mapping/FieldCollection.cs b/mcs/class/System.Data.SqlXml/System.Data.Mapping/FieldCollection.cs
new file mode 100755
index 00000000000..c1e72a2694f
--- /dev/null
+++ b/mcs/class/System.Data.SqlXml/System.Data.Mapping/FieldCollection.cs
@@ -0,0 +1,45 @@
+//
+// System.Data.Mapping.FieldCollection
+//
+// Author:
+// Tim Coleman (tim@timcoleman.com)
+//
+// Copyright (C) Tim Coleman, 2003
+//
+
+#if NET_1_2
+
+using System.Data.SqlXml;
+using System.Collections;
+
+namespace System.Data.Mapping {
+ public class FieldCollection : ReadOnlyCollectionBase
+ {
+ #region Properties
+
+ [MonoTODO]
+ public Field this [int index] {
+ get { throw new NotImplementedException (); }
+ }
+
+ #endregion // Properties
+
+ #region Methods
+
+ [MonoTODO]
+ public bool Contains (Field dataSource)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void CopyTo (Field[] array, int index)
+ {
+ throw new NotImplementedException ();
+ }
+
+ #endregion // Methods
+ }
+}
+
+#endif // NET_1_2
diff --git a/mcs/class/System.Data.SqlXml/System.Data.Mapping/FieldJoin.cs b/mcs/class/System.Data.SqlXml/System.Data.Mapping/FieldJoin.cs
new file mode 100755
index 00000000000..bf10c132aa7
--- /dev/null
+++ b/mcs/class/System.Data.SqlXml/System.Data.Mapping/FieldJoin.cs
@@ -0,0 +1,48 @@
+//
+// System.Data.Mapping.FieldJoin
+//
+// Author:
+// Tim Coleman (tim@timcoleman.com)
+//
+// Copyright (C) Tim Coleman, 2003
+//
+
+#if NET_1_2
+
+using System.Data.SqlXml;
+
+namespace System.Data.Mapping {
+ public class FieldJoin
+ {
+ #region Properties
+
+ [MonoTODO]
+ public Field FromField {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public string FromFieldName {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public Relationship OwnerRelationship {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public Field ToField {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public string ToFieldName {
+ get { throw new NotImplementedException (); }
+ }
+
+ #endregion // Properties
+ }
+}
+
+#endif // NET_1_2
diff --git a/mcs/class/System.Data.SqlXml/System.Data.Mapping/FieldJoinCollection.cs b/mcs/class/System.Data.SqlXml/System.Data.Mapping/FieldJoinCollection.cs
new file mode 100755
index 00000000000..3feb404d742
--- /dev/null
+++ b/mcs/class/System.Data.SqlXml/System.Data.Mapping/FieldJoinCollection.cs
@@ -0,0 +1,45 @@
+//
+// System.Data.Mapping.FieldJoinCollection
+//
+// Author:
+// Tim Coleman (tim@timcoleman.com)
+//
+// Copyright (C) Tim Coleman, 2003
+//
+
+#if NET_1_2
+
+using System.Data.SqlXml;
+using System.Collections;
+
+namespace System.Data.Mapping {
+ public class FieldJoinCollection : ReadOnlyCollectionBase
+ {
+ #region Properties
+
+ [MonoTODO]
+ public FieldJoin this [int index] {
+ get { throw new NotImplementedException (); }
+ }
+
+ #endregion // Properties
+
+ #region Methods
+
+ [MonoTODO]
+ public bool Contains (FieldJoin dataSource)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void CopyTo (FieldJoin[] array, int index)
+ {
+ throw new NotImplementedException ();
+ }
+
+ #endregion // Methods
+ }
+}
+
+#endif // NET_1_2
diff --git a/mcs/class/System.Data.SqlXml/System.Data.Mapping/FieldMap.cs b/mcs/class/System.Data.SqlXml/System.Data.Mapping/FieldMap.cs
new file mode 100755
index 00000000000..1e19db9fddf
--- /dev/null
+++ b/mcs/class/System.Data.SqlXml/System.Data.Mapping/FieldMap.cs
@@ -0,0 +1,83 @@
+//
+// System.Data.Mapping.FieldMap
+//
+// Author:
+// Tim Coleman (tim@timcoleman.com)
+//
+// Copyright (C) Tim Coleman, 2003
+//
+
+#if NET_1_2
+
+using System.Data.SqlXml;
+
+namespace System.Data.Mapping {
+ public class FieldMap
+ {
+ #region Properties
+
+ [MonoTODO]
+ public string NullValue {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public Map OwnerMap {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public string SourceConstant {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public Field SourceField {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public MappingParameter SourceParameter {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public MappingArgumentType SourceType {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public string TargetConstant {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public IDomainField TargetDomainField {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public MappingParameter TargetParameter {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public MappingArgumentType TargetType {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public bool UseForConcurrency {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public MappingAccess UseNull {
+ get { throw new NotImplementedException (); }
+ }
+
+ #endregion // Properties
+ }
+}
+
+#endif // NET_1_2
diff --git a/mcs/class/System.Data.SqlXml/System.Data.Mapping/FieldMapCollection.cs b/mcs/class/System.Data.SqlXml/System.Data.Mapping/FieldMapCollection.cs
new file mode 100755
index 00000000000..e3eecc361b0
--- /dev/null
+++ b/mcs/class/System.Data.SqlXml/System.Data.Mapping/FieldMapCollection.cs
@@ -0,0 +1,45 @@
+//
+// System.Data.Mapping.FieldMapCollection
+//
+// Author:
+// Tim Coleman (tim@timcoleman.com)
+//
+// Copyright (C) Tim Coleman, 2003
+//
+
+#if NET_1_2
+
+using System.Data.SqlXml;
+using System.Collections;
+
+namespace System.Data.Mapping {
+ public class FieldMapCollection : ReadOnlyCollectionBase
+ {
+ #region Properties
+
+ [MonoTODO]
+ public FieldMap this [int index] {
+ get { throw new NotImplementedException (); }
+ }
+
+ #endregion // Properties
+
+ #region Methods
+
+ [MonoTODO]
+ public bool Contains (FieldMap dataSource)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void CopyTo (FieldMap[] array, int index)
+ {
+ throw new NotImplementedException ();
+ }
+
+ #endregion // Methods
+ }
+}
+
+#endif // NET_1_2
diff --git a/mcs/class/System.Data.SqlXml/System.Data.Mapping/IDomainConstraint.cs b/mcs/class/System.Data.SqlXml/System.Data.Mapping/IDomainConstraint.cs
new file mode 100755
index 00000000000..37935ef8112
--- /dev/null
+++ b/mcs/class/System.Data.SqlXml/System.Data.Mapping/IDomainConstraint.cs
@@ -0,0 +1,28 @@
+//
+// System.Data.Mapping.IDomainConstraint
+//
+// Author:
+// Tim Coleman (tim@timcoleman.com)
+//
+// Copyright (C) Tim Coleman, 2003
+//
+
+#if NET_1_2
+
+namespace System.Data.Mapping {
+ public interface IDomainConstraint
+ {
+ #region Properties
+
+ bool CascadeDelete { get; }
+ IDomainSchema DomainSchema { get; }
+ IDomainFieldJoinCollection FieldJoins { get; }
+ IDomainStructure FromDomainStructure { get; }
+ string Name { get; }
+ IDomainStructure ToDomainStructure { get; }
+
+ #endregion // Properties
+ }
+}
+
+#endif // NET_1_2
diff --git a/mcs/class/System.Data.SqlXml/System.Data.Mapping/IDomainField.cs b/mcs/class/System.Data.SqlXml/System.Data.Mapping/IDomainField.cs
new file mode 100755
index 00000000000..7830bf14bc4
--- /dev/null
+++ b/mcs/class/System.Data.SqlXml/System.Data.Mapping/IDomainField.cs
@@ -0,0 +1,24 @@
+//
+// System.Data.Mapping.IDomainField
+//
+// Author:
+// Tim Coleman (tim@timcoleman.com)
+//
+// Copyright (C) Tim Coleman, 2003
+//
+
+#if NET_1_2
+
+namespace System.Data.Mapping {
+ public interface IDomainField
+ {
+ #region Properties
+
+ IDomainStructure DomainStructure { get; }
+ string Name { get; }
+
+ #endregion // Properties
+ }
+}
+
+#endif // NET_1_2
diff --git a/mcs/class/System.Data.SqlXml/System.Data.Mapping/IDomainFieldJoin.cs b/mcs/class/System.Data.SqlXml/System.Data.Mapping/IDomainFieldJoin.cs
new file mode 100755
index 00000000000..b744925461d
--- /dev/null
+++ b/mcs/class/System.Data.SqlXml/System.Data.Mapping/IDomainFieldJoin.cs
@@ -0,0 +1,24 @@
+//
+// System.Data.Mapping.IDomainFieldJoin
+//
+// Author:
+// Tim Coleman (tim@timcoleman.com)
+//
+// Copyright (C) Tim Coleman, 2003
+//
+
+#if NET_1_2
+
+namespace System.Data.Mapping {
+ public interface IDomainFieldJoin
+ {
+ #region Properties
+
+ IDomainField FromDomainField { get; }
+ IDomainField ToDomainField { get; }
+
+ #endregion // Properties
+ }
+}
+
+#endif // NET_1_2
diff --git a/mcs/class/System.Data.SqlXml/System.Data.Mapping/IDomainFieldJoinCollection.cs b/mcs/class/System.Data.SqlXml/System.Data.Mapping/IDomainFieldJoinCollection.cs
new file mode 100755
index 00000000000..3dbd02f88ea
--- /dev/null
+++ b/mcs/class/System.Data.SqlXml/System.Data.Mapping/IDomainFieldJoinCollection.cs
@@ -0,0 +1,31 @@
+//
+// System.Data.Mapping.IDomainFieldJoinCollection
+//
+// Author:
+// Tim Coleman (tim@timcoleman.com)
+//
+// Copyright (C) Tim Coleman, 2003
+//
+
+#if NET_1_2
+
+namespace System.Data.Mapping {
+ public interface IDomainFieldJoinCollection
+ {
+ #region Properties
+
+ IDomainFieldJoin this [int index] { get; }
+
+ #endregion // Properties
+
+ #region Methods
+
+ bool Contains (IDomainFieldJoin fieldJoin);
+ void CopyTo (IDomainFieldJoin[] fieldJoins, int index);
+ int IndexOf (IDomainFieldJoin fieldJoin);
+
+ #endregion // Methods
+ }
+}
+
+#endif // NET_1_2
diff --git a/mcs/class/System.Data.SqlXml/System.Data.Mapping/IDomainSchema.cs b/mcs/class/System.Data.SqlXml/System.Data.Mapping/IDomainSchema.cs
new file mode 100755
index 00000000000..10e294323ff
--- /dev/null
+++ b/mcs/class/System.Data.SqlXml/System.Data.Mapping/IDomainSchema.cs
@@ -0,0 +1,50 @@
+//
+// System.Data.Mapping.IDomainSchema
+//
+// Author:
+// Tim Coleman (tim@timcoleman.com)
+//
+// Copyright (C) Tim Coleman, 2003
+//
+
+#if NET_1_2
+
+using System.IO;
+using System.Xml;
+using System.Xml.Schema;
+
+namespace System.Data.Mapping {
+ public interface IDomainSchema
+ {
+ #region Properties
+
+ MappingDataSourceType DomainType { get; }
+
+ #endregion // Properties
+
+ #region Methods
+
+ IDomainConstraint GetDomainConstraint (string name, IXmlNamespaceResolver namespaces);
+ IDomainStructure GetDomainStructure (string select, IXmlNamespaceResolver namespaces);
+ void Read (string url, ValidationEventHandler validationEventHandler);
+ void Read (string url);
+ void Read (XmlReader reader, ValidationEventHandler validationEventHandler);
+ void Read (XmlReader reader);
+ void ReadExtensions (XmlReader reader, ValidationEventHandler validationEventHandler);
+ void ReadExtensions (XmlReader reader);
+ void Write (string url, IXmlNamespaceResolver namespaceResolver);
+ void Write (string url);
+ void Write (XmlWriter writer, IXmlNamespaceResolver namespaceResolver);
+ void Write (XmlWriter writer);
+ void Write (Stream stream, IXmlNamespaceResolver namespaceResolver);
+ void Write (Stream stream);
+ void Write (TextWriter writer, IXmlNamespaceResolver namespaceResolver);
+ void Write (TextWriter writer);
+ void WriteExtensions (XmlWriter writer, IXmlNamespaceResolver namespaceResolver);
+ void WriteExtensions (XmlWriter writer);
+
+ #endregion // Methods
+ }
+}
+
+#endif // NET_1_2
diff --git a/mcs/class/System.Data.SqlXml/System.Data.Mapping/IDomainStructure.cs b/mcs/class/System.Data.SqlXml/System.Data.Mapping/IDomainStructure.cs
new file mode 100755
index 00000000000..2145baf4757
--- /dev/null
+++ b/mcs/class/System.Data.SqlXml/System.Data.Mapping/IDomainStructure.cs
@@ -0,0 +1,32 @@
+//
+// System.Data.Mapping.IDomainStructure
+//
+// Author:
+// Tim Coleman (tim@timcoleman.com)
+//
+// Copyright (C) Tim Coleman, 2003
+//
+
+#if NET_1_2
+
+using System.Xml;
+
+namespace System.Data.Mapping {
+ public interface IDomainStructure
+ {
+ #region Properties
+
+ IDomainSchema DomainSchema { get; }
+ string Select { get; }
+
+ #endregion // Properties
+
+ #region Methods
+
+ IDomainField GetDomainField (string fieldName, IXmlNamespaceResolver namespaces);
+
+ #endregion // Methods
+ }
+}
+
+#endif // NET_1_2
diff --git a/mcs/class/System.Data.SqlXml/System.Data.Mapping/Map.cs b/mcs/class/System.Data.SqlXml/System.Data.Mapping/Map.cs
new file mode 100755
index 00000000000..da184e17ce8
--- /dev/null
+++ b/mcs/class/System.Data.SqlXml/System.Data.Mapping/Map.cs
@@ -0,0 +1,63 @@
+//
+// System.Data.Mapping.Map
+//
+// Author:
+// Tim Coleman (tim@timcoleman.com)
+//
+// Copyright (C) Tim Coleman, 2003
+//
+
+#if NET_1_2
+
+using System.Data.SqlXml;
+
+namespace System.Data.Mapping {
+ public class Map
+ {
+ #region Properties
+
+ [MonoTODO]
+ public MappingAccess Access {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public Field ContentsMap {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public FieldMapCollection FieldMaps {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public Field OverflowMap {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public MappingSchema OwnerMappingSchema {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public Variable SourceVariable {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public string TargetSelect {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public IDomainStructure TargetStructure {
+ get { throw new NotImplementedException (); }
+ }
+
+ #endregion // Properties
+ }
+}
+
+#endif // NET_1_2
diff --git a/mcs/class/System.Data.SqlXml/System.Data.Mapping/MapCollection.cs b/mcs/class/System.Data.SqlXml/System.Data.Mapping/MapCollection.cs
new file mode 100755
index 00000000000..9a7166a2e6d
--- /dev/null
+++ b/mcs/class/System.Data.SqlXml/System.Data.Mapping/MapCollection.cs
@@ -0,0 +1,45 @@
+//
+// System.Data.Mapping.MapCollection
+//
+// Author:
+// Tim Coleman (tim@timcoleman.com)
+//
+// Copyright (C) Tim Coleman, 2003
+//
+
+#if NET_1_2
+
+using System.Data.SqlXml;
+using System.Collections;
+
+namespace System.Data.Mapping {
+ public class MapCollection : ReadOnlyCollectionBase
+ {
+ #region Properties
+
+ [MonoTODO]
+ public Map this [int index] {
+ get { throw new NotImplementedException (); }
+ }
+
+ #endregion // Properties
+
+ #region Methods
+
+ [MonoTODO]
+ public bool Contains (Map dataSource)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void CopyTo (Map[] array, int index)
+ {
+ throw new NotImplementedException ();
+ }
+
+ #endregion // Methods
+ }
+}
+
+#endif // NET_1_2
diff --git a/mcs/class/System.Data.SqlXml/System.Data.Mapping/MappingAccess.cs b/mcs/class/System.Data.SqlXml/System.Data.Mapping/MappingAccess.cs
new file mode 100755
index 00000000000..5810fba7047
--- /dev/null
+++ b/mcs/class/System.Data.SqlXml/System.Data.Mapping/MappingAccess.cs
@@ -0,0 +1,21 @@
+//
+// System.Data.Mapping.MappingAccess
+//
+// Author:
+// Tim Coleman (tim@timcoleman.com)
+//
+// Copyright (C) Tim Coleman, 2003
+//
+
+#if NET_1_2
+
+namespace System.Data.Mapping {
+ public enum MappingAccess
+ {
+ Read,
+ ReadWrite,
+ Write
+ }
+}
+
+#endif // NET_1_2
diff --git a/mcs/class/System.Data.SqlXml/System.Data.Mapping/MappingArgumentType.cs b/mcs/class/System.Data.SqlXml/System.Data.Mapping/MappingArgumentType.cs
new file mode 100755
index 00000000000..f14fa055cd1
--- /dev/null
+++ b/mcs/class/System.Data.SqlXml/System.Data.Mapping/MappingArgumentType.cs
@@ -0,0 +1,23 @@
+//
+// System.Data.Mapping.MappingArgumentType
+//
+// Author:
+// Tim Coleman (tim@timcoleman.com)
+//
+// Copyright (C) Tim Coleman, 2003
+//
+
+#if NET_1_2
+
+namespace System.Data.Mapping {
+ public enum MappingArgumentType
+ {
+ NotRequired,
+ Field,
+ DomainField,
+ Constant,
+ MappingParameter
+ }
+}
+
+#endif // NET_1_2
diff --git a/mcs/class/System.Data.SqlXml/System.Data.Mapping/MappingConditionOperator.cs b/mcs/class/System.Data.SqlXml/System.Data.Mapping/MappingConditionOperator.cs
new file mode 100755
index 00000000000..916df9e3f0f
--- /dev/null
+++ b/mcs/class/System.Data.SqlXml/System.Data.Mapping/MappingConditionOperator.cs
@@ -0,0 +1,28 @@
+//
+// System.Data.Mapping.MappingConditionOperator
+//
+// Author:
+// Tim Coleman (tim@timcoleman.com)
+//
+// Copyright (C) Tim Coleman, 2003
+//
+
+#if NET_1_2
+
+namespace System.Data.Mapping {
+ public enum MappingConditionOperator
+ {
+ LessThen,
+ GreaterThen,
+ LessThenOrEqual,
+ GreaterThenOrEqual,
+ Equal,
+ NotEqual,
+ Like,
+ NotLike,
+ IsNull,
+ IsNotNull
+ }
+}
+
+#endif // NET_1_2
diff --git a/mcs/class/System.Data.SqlXml/System.Data.Mapping/MappingDataSourceType.cs b/mcs/class/System.Data.SqlXml/System.Data.Mapping/MappingDataSourceType.cs
new file mode 100755
index 00000000000..c26a18a75a2
--- /dev/null
+++ b/mcs/class/System.Data.SqlXml/System.Data.Mapping/MappingDataSourceType.cs
@@ -0,0 +1,21 @@
+//
+// System.Data.Mapping.MappingDataSourceType
+//
+// Author:
+// Tim Coleman (tim@timcoleman.com)
+//
+// Copyright (C) Tim Coleman, 2003
+//
+
+#if NET_1_2
+
+namespace System.Data.Mapping {
+ public enum MappingDataSourceType
+ {
+ SQLServer,
+ Xml,
+ Object
+ }
+}
+
+#endif // NET_1_2
diff --git a/mcs/class/System.Data.SqlXml/System.Data.Mapping/MappingDirection.cs b/mcs/class/System.Data.SqlXml/System.Data.Mapping/MappingDirection.cs
new file mode 100755
index 00000000000..042c4e8c75a
--- /dev/null
+++ b/mcs/class/System.Data.SqlXml/System.Data.Mapping/MappingDirection.cs
@@ -0,0 +1,20 @@
+//
+// System.Data.Mapping.MappingDirection
+//
+// Author:
+// Tim Coleman (tim@timcoleman.com)
+//
+// Copyright (C) Tim Coleman, 2003
+//
+
+#if NET_1_2
+
+namespace System.Data.Mapping {
+ public enum MappingDirection
+ {
+ Source,
+ Target
+ }
+}
+
+#endif // NET_1_2
diff --git a/mcs/class/System.Data.SqlXml/System.Data.Mapping/MappingParameter.cs b/mcs/class/System.Data.SqlXml/System.Data.Mapping/MappingParameter.cs
new file mode 100755
index 00000000000..4cbfa41a168
--- /dev/null
+++ b/mcs/class/System.Data.SqlXml/System.Data.Mapping/MappingParameter.cs
@@ -0,0 +1,49 @@
+//
+// System.Data.Mapping.MappingParameter
+//
+// Author:
+// Tim Coleman (tim@timcoleman.com)
+//
+// Copyright (C) Tim Coleman, 2003
+//
+
+#if NET_1_2
+
+using System.Data.SqlXml;
+using System.Xml.Schema;
+
+namespace System.Data.Mapping {
+ public class MappingParameter
+ {
+ #region Properties
+
+ [MonoTODO]
+ public XmlSchemaBuiltInType DataType {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public string Default {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public string Name {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public string NullValue {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public MappingSchema OwnerMappingSchema {
+ get { throw new NotImplementedException (); }
+ }
+
+ #endregion // Properties
+ }
+}
+
+#endif // NET_1_2
diff --git a/mcs/class/System.Data.SqlXml/System.Data.Mapping/MappingParameterCollection.cs b/mcs/class/System.Data.SqlXml/System.Data.Mapping/MappingParameterCollection.cs
new file mode 100755
index 00000000000..f86f35b9da5
--- /dev/null
+++ b/mcs/class/System.Data.SqlXml/System.Data.Mapping/MappingParameterCollection.cs
@@ -0,0 +1,45 @@
+//
+// System.Data.Mapping.MappingParameterCollection
+//
+// Author:
+// Tim Coleman (tim@timcoleman.com)
+//
+// Copyright (C) Tim Coleman, 2003
+//
+
+#if NET_1_2
+
+using System.Data.SqlXml;
+using System.Collections;
+
+namespace System.Data.Mapping {
+ public class MappingParameterCollection : ReadOnlyCollectionBase
+ {
+ #region Properties
+
+ [MonoTODO]
+ public MappingParameter this [int index] {
+ get { throw new NotImplementedException (); }
+ }
+
+ #endregion // Properties
+
+ #region Methods
+
+ [MonoTODO]
+ public bool Contains (MappingParameter dataSource)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void CopyTo (MappingParameter[] array, int index)
+ {
+ throw new NotImplementedException ();
+ }
+
+ #endregion // Methods
+ }
+}
+
+#endif // NET_1_2
diff --git a/mcs/class/System.Data.SqlXml/System.Data.Mapping/MappingSchema.cs b/mcs/class/System.Data.SqlXml/System.Data.Mapping/MappingSchema.cs
new file mode 100755
index 00000000000..faae23b12e1
--- /dev/null
+++ b/mcs/class/System.Data.SqlXml/System.Data.Mapping/MappingSchema.cs
@@ -0,0 +1,174 @@
+//
+// System.Data.Mapping.MappingSchema
+//
+// Author:
+// Tim Coleman (tim@timcoleman.com)
+//
+// Copyright (C) Tim Coleman, 2003
+//
+
+#if NET_1_2
+
+using System.Data.SqlXml;
+using System.IO;
+using System.Xml;
+using System.Xml.Schema;
+
+namespace System.Data.Mapping {
+ public class MappingSchema
+ {
+ #region Constructors
+
+ [MonoTODO]
+ public MappingSchema ()
+ {
+ }
+
+ [MonoTODO]
+ public MappingSchema (string url, ValidationEventHandler validationEventHandler)
+ {
+ }
+
+ [MonoTODO]
+ public MappingSchema (string url)
+ {
+ }
+
+ [MonoTODO]
+ public MappingSchema (XmlReader reader, ValidationEventHandler validationEventHandler)
+ {
+ }
+
+ [MonoTODO]
+ public MappingSchema (XmlReader reader)
+ {
+ }
+
+ #endregion // Constructors
+
+ #region Properties
+
+ [MonoTODO]
+ public DataSourceCollection DataSources {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public MappingParameterCollection MappingParameters {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public MapCollection Maps {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public RelationshipMapCollection RelationshipMaps {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public string SourceUri {
+ get { throw new NotImplementedException (); }
+ }
+
+ #endregion // Properties
+
+ #region Methods
+
+ [MonoTODO]
+ public Relationship Find (string fromVariableName, string toVariableName)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public RelationshipCollection Find (string variableName)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public string GetXml ()
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void Read (string url, ValidationEventHandler validationEventHandler)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void Read (string url)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void Read (XmlReader reader, ValidationEventHandler validationEventHandler)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void Read (XmlReader reader)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void Write (string url, IXmlNamespaceResolver namespaceResolver)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void Write (string url)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void Write (XmlWriter writer, IXmlNamespaceResolver namespaceResolver)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void Write (XmlWriter writer)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void Write (Stream stream, IXmlNamespaceResolver namespaceResolver)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void Write (Stream stream)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void Write (TextWriter writer, IXmlNamespaceResolver namespaceResolver)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void Write (TextWriter writer)
+ {
+ throw new NotImplementedException ();
+ }
+
+ #endregion // Methods
+ }
+}
+
+#endif // NET_1_2
diff --git a/mcs/class/System.Data.SqlXml/System.Data.Mapping/Relationship.cs b/mcs/class/System.Data.SqlXml/System.Data.Mapping/Relationship.cs
new file mode 100755
index 00000000000..d4670c935f0
--- /dev/null
+++ b/mcs/class/System.Data.SqlXml/System.Data.Mapping/Relationship.cs
@@ -0,0 +1,68 @@
+//
+// System.Data.Mapping.Relationship
+//
+// Author:
+// Tim Coleman (tim@timcoleman.com)
+//
+// Copyright (C) Tim Coleman, 2003
+//
+
+#if NET_1_2
+
+using System.Data.SqlXml;
+
+namespace System.Data.Mapping {
+ public class Relationship
+ {
+ #region Properties
+
+ [MonoTODO]
+ public bool CascadeDelete {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public string ConstraintName {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public IDomainConstraint DomainConstraint {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public FieldJoinCollection FieldJoins {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public Variable FromVariable {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public string Name {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public RelationshipCollection NestedRelationships {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public DataSource OwnerDataSource {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public Variable ToVariable {
+ get { throw new NotImplementedException (); }
+ }
+
+ #endregion // Properties
+ }
+}
+
+#endif // NET_1_2
diff --git a/mcs/class/System.Data.SqlXml/System.Data.Mapping/RelationshipCollection.cs b/mcs/class/System.Data.SqlXml/System.Data.Mapping/RelationshipCollection.cs
new file mode 100755
index 00000000000..72a50e2aec3
--- /dev/null
+++ b/mcs/class/System.Data.SqlXml/System.Data.Mapping/RelationshipCollection.cs
@@ -0,0 +1,45 @@
+//
+// System.Data.Mapping.RelationshipCollection
+//
+// Author:
+// Tim Coleman (tim@timcoleman.com)
+//
+// Copyright (C) Tim Coleman, 2003
+//
+
+#if NET_1_2
+
+using System.Data.SqlXml;
+using System.Collections;
+
+namespace System.Data.Mapping {
+ public class RelationshipCollection : ReadOnlyCollectionBase
+ {
+ #region Properties
+
+ [MonoTODO]
+ public Relationship this [int index] {
+ get { throw new NotImplementedException (); }
+ }
+
+ #endregion // Properties
+
+ #region Methods
+
+ [MonoTODO]
+ public bool Contains (Relationship dataSource)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void CopyTo (Relationship[] array, int index)
+ {
+ throw new NotImplementedException ();
+ }
+
+ #endregion // Methods
+ }
+}
+
+#endif // NET_1_2
diff --git a/mcs/class/System.Data.SqlXml/System.Data.Mapping/RelationshipMap.cs b/mcs/class/System.Data.SqlXml/System.Data.Mapping/RelationshipMap.cs
new file mode 100755
index 00000000000..4f1029f8a25
--- /dev/null
+++ b/mcs/class/System.Data.SqlXml/System.Data.Mapping/RelationshipMap.cs
@@ -0,0 +1,43 @@
+//
+// System.Data.Mapping.RelationshipMap
+//
+// Author:
+// Tim Coleman (tim@timcoleman.com)
+//
+// Copyright (C) Tim Coleman, 2003
+//
+
+#if NET_1_2
+
+using System.Data.SqlXml;
+
+namespace System.Data.Mapping {
+ public class RelationshipMap
+ {
+ #region Properties
+
+ [MonoTODO]
+ public MappingSchema OwnerMappingSchema {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public Relationship SourceRelationship {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public IDomainConstraint TargetConstraint {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public string TargetConstraintName {
+ get { throw new NotImplementedException (); }
+ }
+
+ #endregion // Properties
+ }
+}
+
+#endif // NET_1_2
diff --git a/mcs/class/System.Data.SqlXml/System.Data.Mapping/RelationshipMapCollection.cs b/mcs/class/System.Data.SqlXml/System.Data.Mapping/RelationshipMapCollection.cs
new file mode 100755
index 00000000000..2d73b17d612
--- /dev/null
+++ b/mcs/class/System.Data.SqlXml/System.Data.Mapping/RelationshipMapCollection.cs
@@ -0,0 +1,45 @@
+//
+// System.Data.Mapping.RelationshipMapCollection
+//
+// Author:
+// Tim Coleman (tim@timcoleman.com)
+//
+// Copyright (C) Tim Coleman, 2003
+//
+
+#if NET_1_2
+
+using System.Data.SqlXml;
+using System.Collections;
+
+namespace System.Data.Mapping {
+ public class RelationshipMapCollection : ReadOnlyCollectionBase
+ {
+ #region Properties
+
+ [MonoTODO]
+ public RelationshipMap this [int index] {
+ get { throw new NotImplementedException (); }
+ }
+
+ #endregion // Properties
+
+ #region Methods
+
+ [MonoTODO]
+ public bool Contains (RelationshipMap dataSource)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void CopyTo (RelationshipMap[] array, int index)
+ {
+ throw new NotImplementedException ();
+ }
+
+ #endregion // Methods
+ }
+}
+
+#endif // NET_1_2
diff --git a/mcs/class/System.Data.SqlXml/System.Data.Mapping/Variable.cs b/mcs/class/System.Data.SqlXml/System.Data.Mapping/Variable.cs
new file mode 100755
index 00000000000..e577b46877e
--- /dev/null
+++ b/mcs/class/System.Data.SqlXml/System.Data.Mapping/Variable.cs
@@ -0,0 +1,53 @@
+//
+// System.Data.Mapping.Variable
+//
+// Author:
+// Tim Coleman (tim@timcoleman.com)
+//
+// Copyright (C) Tim Coleman, 2003
+//
+
+#if NET_1_2
+
+using System.Data.SqlXml;
+
+namespace System.Data.Mapping {
+ public class Variable
+ {
+ #region Properties
+
+ [MonoTODO]
+ public ConditionCollection Conditions {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public IDomainStructure DomainStructure {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public FieldCollection Fields {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public string Name {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public DataSource OwnerDataSource {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public string Select {
+ get { throw new NotImplementedException (); }
+ }
+
+ #endregion // Properties
+ }
+}
+
+#endif // NET_1_2
diff --git a/mcs/class/System.Data.SqlXml/System.Data.Mapping/VariableCollection.cs b/mcs/class/System.Data.SqlXml/System.Data.Mapping/VariableCollection.cs
new file mode 100755
index 00000000000..4af7089a4c1
--- /dev/null
+++ b/mcs/class/System.Data.SqlXml/System.Data.Mapping/VariableCollection.cs
@@ -0,0 +1,45 @@
+//
+// System.Data.Mapping.VariableCollection
+//
+// Author:
+// Tim Coleman (tim@timcoleman.com)
+//
+// Copyright (C) Tim Coleman, 2003
+//
+
+#if NET_1_2
+
+using System.Data.SqlXml;
+using System.Collections;
+
+namespace System.Data.Mapping {
+ public class VariableCollection : ReadOnlyCollectionBase
+ {
+ #region Properties
+
+ [MonoTODO]
+ public Variable this [int index] {
+ get { throw new NotImplementedException (); }
+ }
+
+ #endregion // Properties
+
+ #region Methods
+
+ [MonoTODO]
+ public bool Contains (Variable dataSource)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void CopyTo (Variable[] array, int index)
+ {
+ throw new NotImplementedException ();
+ }
+
+ #endregion // Methods
+ }
+}
+
+#endif // NET_1_2
diff --git a/mcs/class/System.Data.SqlXml/System.Data.SqlXml.dll.sources b/mcs/class/System.Data.SqlXml/System.Data.SqlXml.dll.sources
new file mode 100644
index 00000000000..2678112523b
--- /dev/null
+++ b/mcs/class/System.Data.SqlXml/System.Data.SqlXml.dll.sources
@@ -0,0 +1,52 @@
+TODOAttribute.cs
+System.Data.SqlXml/DBObject.cs
+System.Data.SqlXml/DBObjectException.cs
+System.Data.SqlXml/RowFilledEventArgs.cs
+System.Data.SqlXml/RowFillingEventArgs.cs
+System.Data.SqlXml/XmlBulkLoad.cs
+System.Data.SqlXml/XmlBulkLoadException.cs
+System.Data.SqlXml/XmlRowsetAdapter.cs
+System.Data.SqlXml/XmlRowsetAdapterException.cs
+System.Data.SqlXml/FillStatus.cs
+System.Xml.Query/SqlQueryOptions.cs
+System.Xml.Query/SqlQueryPlan.cs
+System.Xml.Query/XmlCommand.cs
+System.Xml.Query/XmlQueryArgumentList.cs
+System.Xml.Query/XmlQueryCompileException.cs
+System.Xml.Query/XmlQueryException.cs
+System.Xml.Query/XmlViewSchema.cs
+System.Xml.Query/XmlViewSchemaDictionary.cs
+System.Xml.Query/XQueryProcessor.cs
+System.Xml.Query/XsltProcessor.cs
+System.Data.Mapping/ConditionCollection.cs
+System.Data.Mapping/Condition.cs
+System.Data.Mapping/DataSourceCollection.cs
+System.Data.Mapping/DataSource.cs
+System.Data.Mapping/FieldCollection.cs
+System.Data.Mapping/Field.cs
+System.Data.Mapping/FieldJoinCollection.cs
+System.Data.Mapping/FieldJoin.cs
+System.Data.Mapping/FieldMapCollection.cs
+System.Data.Mapping/FieldMap.cs
+System.Data.Mapping/IDomainConstraint.cs
+System.Data.Mapping/IDomainField.cs
+System.Data.Mapping/IDomainFieldJoinCollection.cs
+System.Data.Mapping/IDomainFieldJoin.cs
+System.Data.Mapping/IDomainSchema.cs
+System.Data.Mapping/IDomainStructure.cs
+System.Data.Mapping/MapCollection.cs
+System.Data.Mapping/Map.cs
+System.Data.Mapping/MappingAccess.cs
+System.Data.Mapping/MappingArgumentType.cs
+System.Data.Mapping/MappingConditionOperator.cs
+System.Data.Mapping/MappingDataSourceType.cs
+System.Data.Mapping/MappingDirection.cs
+System.Data.Mapping/MappingParameterCollection.cs
+System.Data.Mapping/MappingParameter.cs
+System.Data.Mapping/MappingSchema.cs
+System.Data.Mapping/RelationshipCollection.cs
+System.Data.Mapping/Relationship.cs
+System.Data.Mapping/RelationshipMapCollection.cs
+System.Data.Mapping/RelationshipMap.cs
+System.Data.Mapping/VariableCollection.cs
+System.Data.Mapping/Variable.cs
diff --git a/mcs/class/System.Data.SqlXml/System.Data.SqlXml/DBObject.cs b/mcs/class/System.Data.SqlXml/System.Data.SqlXml/DBObject.cs
new file mode 100755
index 00000000000..ca7921a9d91
--- /dev/null
+++ b/mcs/class/System.Data.SqlXml/System.Data.SqlXml/DBObject.cs
@@ -0,0 +1,92 @@
+//
+// System.Data.SqlXml.DBObject
+//
+// Author:
+// Tim Coleman (tim@timcoleman.com)
+//
+// Copyright (C) Tim Coleman, 2003
+//
+
+#if NET_1_2
+
+using System.Data;
+using System.IO;
+using System.Xml.Query;
+
+namespace System.Data.SqlXml {
+ public class DBObject
+ {
+ #region Constructors
+
+ [MonoTODO]
+ public DBObject ()
+ {
+ }
+
+ #endregion // Constructors
+
+ #region Properties
+
+ [MonoTODO]
+ public string Path {
+ get { throw new NotImplementedException(); }
+ set { throw new NotImplementedException(); }
+ }
+
+ #endregion // Properties
+
+ #region Methods
+
+ [MonoTODO]
+ public void Retrieve (Stream stream, IDbConnection connection)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void Retrieve (Stream stream, XmlQueryArgumentList argumentList, IDbConnection connection)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public IDataReader Retrieve (IDbConnection connection)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public IDataReader Retrieve (XmlQueryArgumentList argumentList, IDbConnection connection)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void Update (Stream insertStream, IDbConnection connection)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void Update (Stream insertStream, XmlQueryArgumentList argumentList, IDbConnection connection)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void Update (byte[] inputBytes, IDbConnection connection)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void Update (byte[] inputBytes, XmlQueryArgumentList argumentList, IDbConnection connection)
+ {
+ throw new NotImplementedException ();
+ }
+
+ #endregion // Methods
+ }
+}
+
+#endif // NET_1_2
diff --git a/mcs/class/System.Data.SqlXml/System.Data.SqlXml/DBObjectException.cs b/mcs/class/System.Data.SqlXml/System.Data.SqlXml/DBObjectException.cs
new file mode 100755
index 00000000000..34a88197657
--- /dev/null
+++ b/mcs/class/System.Data.SqlXml/System.Data.SqlXml/DBObjectException.cs
@@ -0,0 +1,63 @@
+//
+// System.Data.SqlXml.DBObjectException
+//
+// Author:
+// Tim Coleman (tim@timcoleman.com)
+//
+// Copyright (C) Tim Coleman, 2003
+//
+
+#if NET_1_2
+
+using System;
+using System.Runtime.Serialization;
+
+namespace System.Data.SqlXml {
+ public class DBObjectException : Exception
+ {
+ #region Constructors
+
+ public DBObjectException (SerializationInfo info, StreamingContext context)
+ : base (info, context)
+ {
+ }
+
+ public DBObjectException ()
+ : base ("A Database Object Exception has occurred.")
+ {
+ }
+
+ public DBObjectException (string res)
+ : base (res)
+ {
+ }
+
+ public DBObjectException (string resource, Exception exception)
+ : base (resource, exception)
+ {
+ }
+
+ #endregion // Constructors
+
+ #region Properties
+
+ [MonoTODO]
+ public override string Message {
+ get { throw new NotImplementedException(); }
+ }
+
+ #endregion // Properties
+
+ #region Methods
+
+ [MonoTODO]
+ public override void GetObjectData (SerializationInfo info, StreamingContext context)
+ {
+ throw new NotImplementedException();
+ }
+
+ #endregion // Methods
+ }
+}
+
+#endif // NET_1_2
diff --git a/mcs/class/System.Data.SqlXml/System.Data.SqlXml/FillStatus.cs b/mcs/class/System.Data.SqlXml/System.Data.SqlXml/FillStatus.cs
new file mode 100755
index 00000000000..4736b24cd80
--- /dev/null
+++ b/mcs/class/System.Data.SqlXml/System.Data.SqlXml/FillStatus.cs
@@ -0,0 +1,21 @@
+//
+// System.Data.SqlXml.FillStatus
+//
+// Author:
+// Tim Coleman (tim@timcoleman.com)
+//
+// Copyright (C) Tim Coleman, 2003
+//
+
+#if NET_1_2
+
+namespace System.Data.SqlXml {
+ public enum FillStatus
+ {
+ Continue,
+ ErrorsOccurred,
+ SkipCurrentRow
+ }
+}
+
+#endif // NET_1_2
diff --git a/mcs/class/System.Data.SqlXml/System.Data.SqlXml/RowFilledEventArgs.cs b/mcs/class/System.Data.SqlXml/System.Data.SqlXml/RowFilledEventArgs.cs
new file mode 100755
index 00000000000..39fc1d89da1
--- /dev/null
+++ b/mcs/class/System.Data.SqlXml/System.Data.SqlXml/RowFilledEventArgs.cs
@@ -0,0 +1,54 @@
+//
+// System.Data.SqlXml.RowFilledEventArgs
+//
+// Author:
+// Tim Coleman (tim@timcoleman.com)
+//
+// Copyright (C) Tim Coleman, 2003
+//
+
+#if NET_1_2
+
+using System;
+
+namespace System.Data.SqlXml {
+ public class RowFilledEventArgs : EventArgs
+ {
+ #region Fields
+
+ Exception errors;
+ DataRow row;
+ FillStatus status;
+
+ #endregion // Fields
+
+ #region Constructors
+
+ public RowFilledEventArgs (DataRow row)
+ {
+ this.row = row;
+ }
+
+ #endregion // Constructors
+
+ #region Properties
+
+ public Exception Errors {
+ get { return errors; }
+ set { errors = value; }
+ }
+
+ public DataRow Row {
+ get { return row; }
+ }
+
+ public FillStatus Status {
+ get { return status; }
+ set { status = value; }
+ }
+
+ #endregion // Properties
+ }
+}
+
+#endif // NET_1_2
diff --git a/mcs/class/System.Data.SqlXml/System.Data.SqlXml/RowFillingEventArgs.cs b/mcs/class/System.Data.SqlXml/System.Data.SqlXml/RowFillingEventArgs.cs
new file mode 100755
index 00000000000..b4f07a19f04
--- /dev/null
+++ b/mcs/class/System.Data.SqlXml/System.Data.SqlXml/RowFillingEventArgs.cs
@@ -0,0 +1,54 @@
+//
+// System.Data.SqlXml.RowFillingEventArgs
+//
+// Author:
+// Tim Coleman (tim@timcoleman.com)
+//
+// Copyright (C) Tim Coleman, 2003
+//
+
+#if NET_1_2
+
+using System;
+
+namespace System.Data.SqlXml {
+ public class RowFillingEventArgs : EventArgs
+ {
+ #region Fields
+
+ Exception errors;
+ DataRow row;
+ FillStatus status;
+
+ #endregion // Fields
+
+ #region Constructors
+
+ public RowFillingEventArgs (DataRow row)
+ {
+ this.row = row;
+ }
+
+ #endregion // Constructors
+
+ #region Properties
+
+ public Exception Errors {
+ get { return errors; }
+ set { errors = value; }
+ }
+
+ public DataRow Row {
+ get { return row; }
+ }
+
+ public FillStatus Status {
+ get { return status; }
+ set { status = value; }
+ }
+
+ #endregion // Properties
+ }
+}
+
+#endif // NET_1_2
diff --git a/mcs/class/System.Data.SqlXml/System.Data.SqlXml/XmlBulkLoad.cs b/mcs/class/System.Data.SqlXml/System.Data.SqlXml/XmlBulkLoad.cs
new file mode 100755
index 00000000000..639907634b0
--- /dev/null
+++ b/mcs/class/System.Data.SqlXml/System.Data.SqlXml/XmlBulkLoad.cs
@@ -0,0 +1,101 @@
+//
+// System.Data.SqlXml.XmlBulkLoad
+//
+// Author:
+// Tim Coleman (tim@timcoleman.com)
+//
+// Copyright (C) Tim Coleman, 2003
+//
+
+#if NET_1_2
+
+using System.Data;
+using System.Data.Mapping;
+
+namespace System.Data.SqlXml {
+ public class XmlBulkLoad
+ {
+ #region Fields
+
+ bool checkConstraints;
+ int clientBufferSize;
+ string errorLogFile;
+ bool forceTableLock;
+ bool keepIdentity;
+ bool keepNulls;
+ MappingSchema mapping;
+ int serverTransactionSize;
+
+ #endregion // Fields
+
+ #region Constructors
+
+ [MonoTODO]
+ public XmlBulkLoad ()
+ {
+ }
+
+ #endregion // Constructors
+
+ #region Properties
+
+ public bool CheckConstraints {
+ get { return checkConstraints; }
+ set { checkConstraints = value; }
+ }
+
+ public int ClientBufferSize {
+ get { return clientBufferSize; }
+ }
+
+ public string ErrorLogFile {
+ get { return errorLogFile; }
+ set { errorLogFile = value; }
+ }
+
+ public bool ForceTableLock {
+ get { return forceTableLock; }
+ set { forceTableLock = value; }
+ }
+
+ public bool KeepIdentity {
+ get { return keepIdentity; }
+ set { keepIdentity = value; }
+ }
+
+ public bool KeepNulls {
+ get { return keepNulls; }
+ set { keepNulls = value; }
+ }
+
+ public MappingSchema Mapping {
+ get { return mapping; }
+ set { mapping = value; }
+ }
+
+ public int ServerTransactionSize {
+ get { return serverTransactionSize; }
+ }
+
+ #endregion // Properties
+
+ #region Methods
+
+ [MonoTODO]
+ public void Execute (string xmlFileName, IDbConnection connection)
+ {
+ throw new NotImplementedException();
+ }
+
+ [MonoTODO]
+ public void SetBufferingSizes (int clientBufferSize, int serverTransactionSize)
+ {
+ this.clientBufferSize = clientBufferSize;
+ throw new NotImplementedException();
+ }
+
+ #endregion // Methods
+ }
+}
+
+#endif // NET_1_2
diff --git a/mcs/class/System.Data.SqlXml/System.Data.SqlXml/XmlBulkLoadException.cs b/mcs/class/System.Data.SqlXml/System.Data.SqlXml/XmlBulkLoadException.cs
new file mode 100755
index 00000000000..a1e4158be3d
--- /dev/null
+++ b/mcs/class/System.Data.SqlXml/System.Data.SqlXml/XmlBulkLoadException.cs
@@ -0,0 +1,63 @@
+//
+// System.Data.SqlXml.XmlBulkLoadException
+//
+// Author:
+// Tim Coleman (tim@timcoleman.com)
+//
+// Copyright (C) Tim Coleman, 2003
+//
+
+#if NET_1_2
+
+using System;
+using System.Runtime.Serialization;
+
+namespace System.Data.SqlXml {
+ public class XmlBulkLoadException : Exception
+ {
+ #region Constructors
+
+ public XmlBulkLoadException (SerializationInfo info, StreamingContext context)
+ : base (info, context)
+ {
+ }
+
+ public XmlBulkLoadException ()
+ : base ("An XML Bulk Load Exception has occurred.")
+ {
+ }
+
+ public XmlBulkLoadException (string res)
+ : base (res)
+ {
+ }
+
+ public XmlBulkLoadException (string resource, Exception exception)
+ : base (resource, exception)
+ {
+ }
+
+ #endregion // Constructors
+
+ #region Properties
+
+ [MonoTODO]
+ public override string Message {
+ get { throw new NotImplementedException(); }
+ }
+
+ #endregion // Properties
+
+ #region Methods
+
+ [MonoTODO]
+ public override void GetObjectData (SerializationInfo info, StreamingContext context)
+ {
+ throw new NotImplementedException();
+ }
+
+ #endregion // Methods
+ }
+}
+
+#endif // NET_1_2
diff --git a/mcs/class/System.Data.SqlXml/System.Data.SqlXml/XmlRowsetAdapter.cs b/mcs/class/System.Data.SqlXml/System.Data.SqlXml/XmlRowsetAdapter.cs
new file mode 100755
index 00000000000..325f03bf9ac
--- /dev/null
+++ b/mcs/class/System.Data.SqlXml/System.Data.SqlXml/XmlRowsetAdapter.cs
@@ -0,0 +1,84 @@
+//
+// System.Data.SqlXml.XmlRowsetAdapter
+//
+// Author:
+// Tim Coleman (tim@timcoleman.com)
+//
+// Copyright (C) Tim Coleman, 2003
+//
+
+#if NET_1_2
+
+using System.Data.Mapping;
+using System.Xml;
+
+namespace System.Data.SqlXml {
+ public class XmlRowsetAdapter
+ {
+ #region Fields
+
+ MappingSchema mapping;
+
+ #endregion // Fields
+
+ #region Constructors
+
+ [MonoTODO]
+ public XmlRowsetAdapter ()
+ {
+ }
+
+ #endregion // Constructors
+
+ #region Properties
+
+ public MappingSchema Mapping {
+ get { return mapping; }
+ set { mapping = value; }
+ }
+
+ #endregion // Properties
+
+ #region Methods
+
+ [MonoTODO]
+ public void Fill (DataSet dataSet, string filename)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void Fill (DataSet dataSet, string filename, XmlResolver resolver)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void Fill (DataSet dataSet, XmlReader reader)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void FillSchema (DataSet dataSet)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public virtual void OnRowFilled (RowFilledEventArgs e)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public virtual void OnRowFilling (RowFillingEventArgs e)
+ {
+ throw new NotImplementedException ();
+ }
+
+ #endregion // Methods
+ }
+}
+
+#endif // NET_1_2
diff --git a/mcs/class/System.Data.SqlXml/System.Data.SqlXml/XmlRowsetAdapterException.cs b/mcs/class/System.Data.SqlXml/System.Data.SqlXml/XmlRowsetAdapterException.cs
new file mode 100755
index 00000000000..bfc6ac8c77f
--- /dev/null
+++ b/mcs/class/System.Data.SqlXml/System.Data.SqlXml/XmlRowsetAdapterException.cs
@@ -0,0 +1,63 @@
+//
+// System.Data.SqlXml.XmlRowsetAdapterException
+//
+// Author:
+// Tim Coleman (tim@timcoleman.com)
+//
+// Copyright (C) Tim Coleman, 2003
+//
+
+#if NET_1_2
+
+using System;
+using System.Runtime.Serialization;
+
+namespace System.Data.SqlXml {
+ public class XmlRowsetAdapterException : Exception
+ {
+ #region Constructors
+
+ public XmlRowsetAdapterException (SerializationInfo info, StreamingContext context)
+ : base (info, context)
+ {
+ }
+
+ public XmlRowsetAdapterException ()
+ : base ("An XML Rowset Adapter Exception has occurred.")
+ {
+ }
+
+ public XmlRowsetAdapterException (string res)
+ : base (res)
+ {
+ }
+
+ public XmlRowsetAdapterException (string resource, Exception exception)
+ : base (resource, exception)
+ {
+ }
+
+ #endregion // Constructors
+
+ #region Properties
+
+ [MonoTODO]
+ public override string Message {
+ get { throw new NotImplementedException(); }
+ }
+
+ #endregion // Properties
+
+ #region Methods
+
+ [MonoTODO]
+ public override void GetObjectData (SerializationInfo info, StreamingContext context)
+ {
+ throw new NotImplementedException();
+ }
+
+ #endregion // Methods
+ }
+}
+
+#endif // NET_1_2
diff --git a/mcs/class/System.Data.SqlXml/System.Xml.Query/SqlQueryOptions.cs b/mcs/class/System.Data.SqlXml/System.Xml.Query/SqlQueryOptions.cs
new file mode 100755
index 00000000000..6405844d725
--- /dev/null
+++ b/mcs/class/System.Data.SqlXml/System.Xml.Query/SqlQueryOptions.cs
@@ -0,0 +1,43 @@
+//
+// System.Xml.Query.SqlQueryOptions
+//
+// Author:
+// Tim Coleman (tim@timcoleman.com)
+//
+// Copyright (C) Tim Coleman, 2003
+//
+
+#if NET_1_2
+
+using System.Data.SqlXml;
+
+namespace System.Xml.Query {
+ public class SqlQueryOptions
+ {
+ #region Fields
+
+ SqlQueryPlan sqlQueryPlan;
+
+ #endregion // Fields
+
+ #region Constructors
+
+ [MonoTODO]
+ public SqlQueryOptions ()
+ {
+ }
+
+ #endregion // Constructors
+
+ #region Properties
+
+ public SqlQueryPlan SqlQueryPlan {
+ get { return sqlQueryPlan; }
+ set { sqlQueryPlan = value; }
+ }
+
+ #endregion // Properties
+ }
+}
+
+#endif // NET_1_2
diff --git a/mcs/class/System.Data.SqlXml/System.Xml.Query/SqlQueryPlan.cs b/mcs/class/System.Data.SqlXml/System.Xml.Query/SqlQueryPlan.cs
new file mode 100755
index 00000000000..2f030ca9efa
--- /dev/null
+++ b/mcs/class/System.Data.SqlXml/System.Xml.Query/SqlQueryPlan.cs
@@ -0,0 +1,21 @@
+//
+// System.Xml.Query.SqlQueryPlan
+//
+// Author:
+// Tim Coleman (tim@timcoleman.com)
+//
+// Copyright (C) Tim Coleman, 2003
+//
+
+#if NET_1_2
+
+namespace System.Xml.Query {
+ public enum SqlQueryPlan
+ {
+ Serialized,
+ Mars,
+ UnionAll
+ }
+}
+
+#endif // NET_1_2
diff --git a/mcs/class/System.Data.SqlXml/System.Xml.Query/XQueryProcessor.cs b/mcs/class/System.Data.SqlXml/System.Xml.Query/XQueryProcessor.cs
new file mode 100755
index 00000000000..5ec1615377f
--- /dev/null
+++ b/mcs/class/System.Data.SqlXml/System.Xml.Query/XQueryProcessor.cs
@@ -0,0 +1,105 @@
+//
+// System.Xml.Query.XQueryProcessor
+//
+// Author:
+// Tim Coleman (tim@timcoleman.com)
+//
+// Copyright (C) Tim Coleman, 2003
+//
+
+#if NET_1_2
+
+using System.Data;
+using System.Data.SqlXml;
+using System.IO;
+
+namespace System.Xml.Query {
+ public class XQueryProcessor
+ {
+ #region Fields
+
+ XmlCommand xmlCommand;
+
+ #endregion // Fields
+
+ #region Constructors
+
+ [MonoTODO]
+ public XQueryProcessor ()
+ {
+ }
+
+ #endregion // Constructors
+
+ #region Properties
+
+ [MonoTODO]
+ public SqlQueryOptions SqlQueryOptions {
+ get { throw new NotImplementedException (); }
+ set { throw new NotImplementedException (); }
+ }
+
+ public XmlCommand XmlCommand {
+ get { return xmlCommand; }
+ }
+
+ [MonoTODO]
+ public XmlViewSchemaDictionary XmlViewSchemaDictionary {
+ get { throw new NotImplementedException (); }
+ set { throw new NotImplementedException (); }
+ }
+
+ #endregion // Properties
+
+ #region Methods
+
+ [MonoTODO]
+ public void Compile (string query)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void Compile (TextReader query)
+ {
+ // Should generate an XmlCommand
+
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void CompileView (string query, string mappingLocation)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void CompileView (TextReader query, string mappingLocation)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void Execute (string contextDocumentUri, XmlResolver dataSources, TextWriter results)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void Execute (XmlResolver dataSources, TextWriter results)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void ExecuteView (IDbConnection connection, TextWriter results)
+ {
+ throw new NotImplementedException ();
+ }
+
+
+ #endregion // Methods
+ }
+}
+
+#endif // NET_1_2
diff --git a/mcs/class/System.Data.SqlXml/System.Xml.Query/XmlCommand.cs b/mcs/class/System.Data.SqlXml/System.Xml.Query/XmlCommand.cs
new file mode 100755
index 00000000000..b0e0bab8538
--- /dev/null
+++ b/mcs/class/System.Data.SqlXml/System.Xml.Query/XmlCommand.cs
@@ -0,0 +1,26 @@
+//
+// System.Xml.Query.XmlCommand
+//
+// Author:
+// Tim Coleman (tim@timcoleman.com)
+//
+// Copyright (C) Tim Coleman, 2003
+//
+
+#if NET_1_2
+
+using System.IO;
+
+namespace System.Xml.Query {
+ public abstract class XmlCommand
+ {
+ #region Methods
+
+ public abstract void Execute (string contextDocumentUri, XmlResolver dataSources, XmlQueryArgumentList argList, TextWriter results);
+ public abstract void Execute (string contextDocumentUri, XmlResolver dataSources, XmlQueryArgumentList argList, Stream results);
+
+ #endregion // Methods
+ }
+}
+
+#endif // NET_1_2
diff --git a/mcs/class/System.Data.SqlXml/System.Xml.Query/XmlQueryArgumentList.cs b/mcs/class/System.Data.SqlXml/System.Xml.Query/XmlQueryArgumentList.cs
new file mode 100755
index 00000000000..afe9c7bb567
--- /dev/null
+++ b/mcs/class/System.Data.SqlXml/System.Xml.Query/XmlQueryArgumentList.cs
@@ -0,0 +1,97 @@
+//
+// System.Xml.Query.XmlQueryArgumentList
+//
+// Author:
+// Tim Coleman (tim@timcoleman.com)
+//
+// Copyright (C) Tim Coleman, 2003
+//
+
+#if NET_1_2
+
+using System.Collections;
+using System.Data.SqlXml;
+using System.Xml;
+
+namespace System.Xml.Query {
+ public class XmlQueryArgumentList
+ {
+ #region Fields
+
+ Hashtable extensionObjects;
+ Hashtable parameters;
+
+ #endregion // Fields
+
+ #region Constructors
+
+ [MonoTODO]
+ public XmlQueryArgumentList ()
+ {
+ extensionObjects = new Hashtable ();
+ parameters = new Hashtable ();
+ }
+
+ #endregion // Constructors
+
+ #region Methods
+
+ [MonoTODO]
+ public void AddExtensionObject (string namespaceUri, object value)
+ {
+ extensionObjects [namespaceUri] = value;
+ }
+
+ [MonoTODO]
+ public void AddParam (string localName, string namespaceUri, object value)
+ {
+ AddParam (new XmlQualifiedName (localName, namespaceUri), value);
+ }
+
+ [MonoTODO]
+ private void AddParam (XmlQualifiedName qname, object value)
+ {
+ parameters [qname] = value;
+ }
+
+ [MonoTODO]
+ public object GetExtensionObject (string namespaceUri)
+ {
+ return extensionObjects [namespaceUri];
+ }
+
+ [MonoTODO]
+ public object GetParam (string localName, string namespaceUri)
+ {
+ return GetParam (new XmlQualifiedName (localName, namespaceUri));
+ }
+
+ [MonoTODO]
+ private object GetParam (XmlQualifiedName qname)
+ {
+ return parameters [qname];
+ }
+
+ [MonoTODO]
+ public void RemoveExtensionObject (string namespaceUri)
+ {
+ extensionObjects.Remove (namespaceUri);
+ }
+
+ [MonoTODO]
+ public void RemoveParam (string localName, string namespaceUri)
+ {
+ RemoveParam (new XmlQualifiedName (localName, namespaceUri));
+ }
+
+ [MonoTODO]
+ private void RemoveParam (XmlQualifiedName qname)
+ {
+ parameters.Remove (qname);
+ }
+
+ #endregion // Methods
+ }
+}
+
+#endif // NET_1_2
diff --git a/mcs/class/System.Data.SqlXml/System.Xml.Query/XmlQueryCompileException.cs b/mcs/class/System.Data.SqlXml/System.Xml.Query/XmlQueryCompileException.cs
new file mode 100755
index 00000000000..2b09b12f66e
--- /dev/null
+++ b/mcs/class/System.Data.SqlXml/System.Xml.Query/XmlQueryCompileException.cs
@@ -0,0 +1,64 @@
+//
+// System.Xml.Query.XmlQueryCompileException
+//
+// Author:
+// Tim Coleman (tim@timcoleman.com)
+//
+// Copyright (C) Tim Coleman, 2003
+//
+
+#if NET_1_2
+
+using System;
+using System.Data.SqlXml;
+using System.Runtime.Serialization;
+
+namespace System.Xml.Query {
+ public class XmlQueryCompileException : XmlQueryException
+ {
+ #region Constructors
+
+ public XmlQueryCompileException (SerializationInfo info, StreamingContext context)
+ : base (info, context)
+ {
+ }
+
+ public XmlQueryCompileException ()
+ : base ("An XML Query Compile Exception has occurred.")
+ {
+ }
+
+ public XmlQueryCompileException (string res)
+ : base (res)
+ {
+ }
+
+ public XmlQueryCompileException (string resource, Exception exception)
+ : base (resource, exception)
+ {
+ }
+
+ #endregion // Constructors
+
+ #region Properties
+
+ [MonoTODO]
+ public override string Message {
+ get { throw new NotImplementedException(); }
+ }
+
+ #endregion // Properties
+
+ #region Methods
+
+ [MonoTODO]
+ public override void GetObjectData (SerializationInfo info, StreamingContext context)
+ {
+ throw new NotImplementedException();
+ }
+
+ #endregion // Methods
+ }
+}
+
+#endif // NET_1_2
diff --git a/mcs/class/System.Data.SqlXml/System.Xml.Query/XmlQueryException.cs b/mcs/class/System.Data.SqlXml/System.Xml.Query/XmlQueryException.cs
new file mode 100755
index 00000000000..988466402d5
--- /dev/null
+++ b/mcs/class/System.Data.SqlXml/System.Xml.Query/XmlQueryException.cs
@@ -0,0 +1,85 @@
+//
+// System.Xml.Query.XmlQueryException
+//
+// Author:
+// Tim Coleman (tim@timcoleman.com)
+//
+// Copyright (C) Tim Coleman, 2003
+//
+
+#if NET_1_2
+
+using System;
+using System.Data.SqlXml;
+using System.Runtime.Serialization;
+
+namespace System.Xml.Query {
+ public class XmlQueryException : SystemException
+ {
+ #region Constructors
+
+ public XmlQueryException (SerializationInfo info, StreamingContext context)
+ : base (info, context)
+ {
+ }
+
+ public XmlQueryException ()
+ : base ("An XML Query Exception has occurred.")
+ {
+ }
+
+ public XmlQueryException (string res)
+ : base (res)
+ {
+ }
+
+ public XmlQueryException (string resource, Exception exception)
+ : base (resource, exception)
+ {
+ }
+
+ #endregion // Constructors
+
+ #region Properties
+
+ [MonoTODO]
+ public int LineNumber {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public int LinePosition {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public override string Message {
+ get { throw new NotImplementedException(); }
+ }
+
+ [MonoTODO]
+ public string SourceUri {
+ get { throw new NotImplementedException(); }
+ }
+
+ #endregion // Properties
+
+ #region Methods
+
+ [MonoTODO]
+ public override void GetObjectData (SerializationInfo info, StreamingContext context)
+ {
+ throw new NotImplementedException();
+ }
+
+ [MonoTODO]
+ public void SetMessage (string message, bool addLineInfo)
+ {
+ throw new NotImplementedException ();
+ }
+
+ #endregion // Methods
+ }
+}
+
+#endif // NET_1_2
diff --git a/mcs/class/System.Data.SqlXml/System.Xml.Query/XmlViewSchema.cs b/mcs/class/System.Data.SqlXml/System.Xml.Query/XmlViewSchema.cs
new file mode 100755
index 00000000000..aca3ec754c8
--- /dev/null
+++ b/mcs/class/System.Data.SqlXml/System.Xml.Query/XmlViewSchema.cs
@@ -0,0 +1,35 @@
+//
+// System.Xml.Query.XmlViewSchema
+//
+// Author:
+// Tim Coleman (tim@timcoleman.com)
+//
+// Copyright (C) Tim Coleman, 2003
+//
+
+#if NET_1_2
+
+using System.Collections;
+using System.Data.SqlXml;
+using System.Xml.Schema;
+
+namespace System.Xml.Query {
+ public abstract class XmlViewSchema
+ {
+ #region Properties
+
+ [MonoTODO]
+ public XmlSchema ResultsSchema {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public IEnumerator SourceDataNames {
+ get { throw new NotImplementedException (); }
+ }
+
+ #endregion // Properties
+ }
+}
+
+#endif // NET_1_2
diff --git a/mcs/class/System.Data.SqlXml/System.Xml.Query/XmlViewSchemaDictionary.cs b/mcs/class/System.Data.SqlXml/System.Xml.Query/XmlViewSchemaDictionary.cs
new file mode 100755
index 00000000000..25a70fc5034
--- /dev/null
+++ b/mcs/class/System.Data.SqlXml/System.Xml.Query/XmlViewSchemaDictionary.cs
@@ -0,0 +1,170 @@
+//
+// System.Xml.Query.XmlViewSchemaDictionary
+//
+// Author:
+// Tim Coleman (tim@timcoleman.com)
+//
+// Copyright (C) Tim Coleman, 2003
+//
+
+#if NET_1_2
+
+using System.Collections;
+using System.Data.Mapping;
+using System.Data.SqlXml;
+
+namespace System.Xml.Query {
+ public class XmlViewSchemaDictionary : ICollection, IDictionary, IEnumerable
+ {
+ #region Constructors
+
+ [MonoTODO]
+ public XmlViewSchemaDictionary ()
+ {
+ }
+
+ #endregion // Constructors
+
+ #region Properties
+
+ [MonoTODO]
+ public int Count {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ private bool ICollection.IsSynchronized {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ private object ICollection.SyncRoot {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ private bool IDictionary.IsFixedSize {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ private bool IDictionary.IsReadOnly {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ private ICollection IDictionary.Keys {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ private ICollection IDictionary.Values {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ private object IDictionary.this [object key] {
+ get { throw new NotImplementedException (); }
+ set { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public XmlViewSchema this [string name] {
+ get { throw new NotImplementedException (); }
+ set { throw new NotImplementedException (); }
+ }
+
+ #endregion // Properties
+
+ #region Methods
+
+ [MonoTODO]
+ public void Add (string name, XmlViewSchema mapping)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void Add (string name, MappingSchema mapping)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void Add (string name, string mappingUrl)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void Add (string name, XmlReader reader)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void Add (XmlViewSchemaDictionary externalCollection)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void Clear ()
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public bool Contains (string name)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public IDictionaryEnumerator GetEnumerator ()
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ private void ICollection.CopyTo (Array array, int index)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ private void IDictionary.Add (object key, object value)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ private bool IDictionary.Contains (object key)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ private void IDictionary.Remove (object key)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ private IEnumerator IEnumerable.GetEnumerator ()
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void Remove (string name)
+ {
+ throw new NotImplementedException ();
+ }
+
+
+ #endregion // Methods
+ }
+}
+
+#endif // NET_1_2
diff --git a/mcs/class/System.Data.SqlXml/System.Xml.Query/XsltProcessor.cs b/mcs/class/System.Data.SqlXml/System.Xml.Query/XsltProcessor.cs
new file mode 100755
index 00000000000..47187bfad94
--- /dev/null
+++ b/mcs/class/System.Data.SqlXml/System.Xml.Query/XsltProcessor.cs
@@ -0,0 +1,72 @@
+//
+// System.Xml.Query.XsltProcessor
+//
+// Author:
+// Tim Coleman (tim@timcoleman.com)
+//
+// Copyright (C) Tim Coleman, 2003
+//
+
+#if NET_1_2
+
+using System.Data.SqlXml;
+using System.IO;
+
+namespace System.Xml.Query {
+ public class XsltProcessor
+ {
+ #region Constructors
+
+ [MonoTODO]
+ public XsltProcessor ()
+ {
+ }
+
+ #endregion // Constructors
+
+ #region Properties
+
+ [MonoTODO]
+ public XmlCommand XmlCommand {
+ get { throw new NotImplementedException (); }
+ }
+
+ #endregion // Properties
+
+ #region Methods
+
+ [MonoTODO]
+ public void Compile (string stylesheetUri, XmlResolver resolver)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void Compile (string stylesheetUri)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void Execute (string contextDocumentUri, XmlResolver dataSources, XmlQueryArgumentList argList, TextWriter results)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void Execute (string contextDocumentUri, XmlResolver dataSources, XmlQueryArgumentList argList, Stream results)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void Execute (string contextDocumentUri, string resultDocumentUri)
+ {
+ throw new NotImplementedException ();
+ }
+
+ #endregion // Methods
+ }
+}
+
+#endif // NET_1_2
diff --git a/mcs/class/System.Data.SqlXml/TODOAttribute.cs b/mcs/class/System.Data.SqlXml/TODOAttribute.cs
new file mode 100644
index 00000000000..7446fb75913
--- /dev/null
+++ b/mcs/class/System.Data.SqlXml/TODOAttribute.cs
@@ -0,0 +1,39 @@
+//
+// TODOAttribute.cs
+//
+// Author:
+// Ravi Pratap (ravi@ximian.com)
+//
+// (C) Ximian, Inc. http://www.ximian.com
+//
+
+using System;
+
+namespace System.Data.SqlXml {
+
+ /// <summary>
+ /// The TODO attribute is used to flag all incomplete bits in our class libraries
+ /// </summary>
+ ///
+ /// <remarks>
+ /// Use this to decorate any element which you think is not complete
+ /// </remarks>
+ [AttributeUsage (AttributeTargets.All, AllowMultiple=true)]
+ internal class MonoTODOAttribute : Attribute {
+
+ private string comment;
+
+ public MonoTODOAttribute ()
+ {}
+
+ public MonoTODOAttribute (string comment)
+ {
+ this.comment = comment;
+ }
+
+ public string Comment
+ {
+ get { return comment; }
+ }
+ }
+}
diff --git a/mcs/class/System.Data/ChangeLog b/mcs/class/System.Data/ChangeLog
index 4d76c1670aa..c6a6f64bbdb 100644
--- a/mcs/class/System.Data/ChangeLog
+++ b/mcs/class/System.Data/ChangeLog
@@ -1,3 +1,11 @@
+2003-11-26 Tim Coleman <tim@timcoleman.com>
+ * System.Data.dll.sources:
+ Add many new System.Data classes for NET_1_2 build.
+
+2003-11-25 Tim Coleman <tim@timcoleman.com>
+ * System.Data.dll.sources:
+ Add System.Data/IDataSources.cs to build
+
2003-07-18 Andreas Nahr <ClassDevelopment@A-SoftTech.com>
* System.Data.dll.sources: Assembly/Locale.cs added, Assembly/AssemblyInfo.cs added
diff --git a/mcs/class/System.Data/System.Data.Common/ChangeLog b/mcs/class/System.Data/System.Data.Common/ChangeLog
index 8ceaa04c663..0a8d64da2d2 100755
--- a/mcs/class/System.Data/System.Data.Common/ChangeLog
+++ b/mcs/class/System.Data/System.Data.Common/ChangeLog
@@ -1,3 +1,18 @@
+2003-11-26 Tim Coleman <tim@timcoleman.com>
+ * DbDataReader.cs: Add new stub class
+
+2003-11-23 Pedro Martínez Juliá <yoros@wanadoo.es>
+
+ * DbDataAdapter.cs: Call command dispose in self dispose method. We
+ need to dispose the connections and other stuff stored in the
+ commands.
+
+2003-11-10 Pedro Martínez Juliá <yoros@wanadoo.es>
+
+ * DataColumnMappingCollection.cs: Fix a missing exception when the
+ required mapping is not in the collection. MS.NET throws an
+ exception there.
+
2003-10-22 Eran Domb <erand@miansoft.com>
* DbDataAdapter.cs (Fill): add only the mapped column to the dataTable (not all columns of dataReader).
diff --git a/mcs/class/System.Data/System.Data.Common/DataColumnMappingCollection.cs b/mcs/class/System.Data/System.Data.Common/DataColumnMappingCollection.cs
index 83dfdefc6e4..0fac2bc4f47 100644
--- a/mcs/class/System.Data/System.Data.Common/DataColumnMappingCollection.cs
+++ b/mcs/class/System.Data/System.Data.Common/DataColumnMappingCollection.cs
@@ -58,7 +58,11 @@ namespace System.Data.Common {
}
public DataColumnMapping this [string sourceColumn] {
- get { return (DataColumnMapping) sourceColumns[sourceColumn]; }
+ get {
+ if (!Contains(sourceColumn)) {
+ throw new IndexOutOfRangeException("DataColumnMappingCollection doesn't contains DataColumnMapping with SourceColumn 'field_int2'.");
+ }
+ return (DataColumnMapping) sourceColumns[sourceColumn]; }
set { this [list.IndexOf (sourceColumns[sourceColumn])] = value; }
}
diff --git a/mcs/class/System.Data/System.Data.Common/DbDataAdapter.cs b/mcs/class/System.Data/System.Data.Common/DbDataAdapter.cs
index 1b5de338d06..7db1b6ba83c 100644
--- a/mcs/class/System.Data/System.Data.Common/DbDataAdapter.cs
+++ b/mcs/class/System.Data/System.Data.Common/DbDataAdapter.cs
@@ -77,17 +77,30 @@ namespace System.Data.Common {
protected override void Dispose (bool disposing)
{
if (disposing) {
- ((IDbDataAdapter) this).SelectCommand = null;
- ((IDbDataAdapter) this).InsertCommand = null;
- ((IDbDataAdapter) this).UpdateCommand = null;
- ((IDbDataAdapter) this).DeleteCommand = null;
+ IDbDataAdapter da = (IDbDataAdapter) this;
+ if (da.SelectCommand != null) {
+ da.SelectCommand.Dispose();
+ da.SelectCommand = null;
+ }
+ if (da.InsertCommand != null) {
+ da.InsertCommand.Dispose();
+ da.InsertCommand = null;
+ }
+ if (da.UpdateCommand != null) {
+ da.UpdateCommand.Dispose();
+ da.UpdateCommand = null;
+ }
+ if (da.DeleteCommand != null) {
+ da.DeleteCommand.Dispose();
+ da.DeleteCommand = null;
+ }
}
}
- public override int Fill (DataSet dataSet)
- {
+ public override int Fill (DataSet dataSet)
+ {
return Fill (dataSet, 0, 0, DefaultSourceTableName, SelectCommand, CommandBehavior.Default);
- }
+ }
public int Fill (DataTable dataTable)
{
@@ -569,8 +582,8 @@ namespace System.Data.Common {
foreach (IDataParameter parameter in command.Parameters) {
string dsColumnName = parameter.SourceColumn;
- DataColumnMapping mapping = columnMappings [parameter.SourceColumn];
- if (mapping != null) dsColumnName = mapping.DataSetColumn;
+ if (columnMappings.Contains(parameter.SourceColumn))
+ dsColumnName = columnMappings [parameter.SourceColumn].DataSetColumn;
DataRowVersion rowVersion = DataRowVersion.Default;
// Parameter version is ignored for non-update commands
diff --git a/mcs/class/System.Data/System.Data.Common/DbDataReader.cs b/mcs/class/System.Data/System.Data.Common/DbDataReader.cs
new file mode 100644
index 00000000000..cf8fded17ed
--- /dev/null
+++ b/mcs/class/System.Data/System.Data.Common/DbDataReader.cs
@@ -0,0 +1,89 @@
+//
+// System.Data.Common.DbDataReader.cs
+//
+// Author:
+// Tim Coleman (tim@timcoleman.com)
+//
+// Copyright (C) Tim Coleman, 2003
+//
+
+#if NET_1_2
+
+using System.Collections;
+using System.Data;
+
+namespace System.Data.Common {
+ public abstract class DbDataReader : MarshalByRefObject, IDataReader, IDataReader2, IDataRecord, IDataRecord2, IDisposable, IEnumerable
+ {
+ #region Constructors
+
+ protected DbDataReader ()
+ {
+ }
+
+ #endregion // Constructors
+
+ #region Properties
+
+ public abstract int Depth { get; }
+ public abstract int FieldCount { get; }
+ public abstract bool HasRows { get; }
+ public abstract bool IsClosed { get; }
+ public abstract object this [int index] { get; }
+ public abstract object this [string name] { get; }
+ public abstract int RecordsAffected { get; }
+ public abstract int VisibleFieldCount { get; }
+
+ #endregion // Properties
+
+ #region Methods
+
+ public abstract void Close ();
+ public abstract void Dispose ();
+ public abstract bool GetBoolean (int i);
+ public abstract byte GetByte (int i);
+ public abstract long GetBytes (int i, long fieldOffset, byte[] buffer, int bufferOffset, int length);
+ public abstract char GetChar (int i);
+ public abstract long GetChars (int i, long dataIndex, char[] buffer, int bufferIndex, int length);
+
+ [MonoTODO]
+ public DbDataReader GetData (int i)
+ {
+ throw new NotImplementedException ();
+ }
+
+ public abstract string GetDataTypeName (int i);
+ public abstract DateTime GetDateTime (int i);
+ public abstract decimal GetDecimal (int i);
+ public abstract double GetDouble (int i);
+ public abstract IEnumerator GetEnumerator ();
+ public abstract Type GetFieldProviderSpecificType (int i);
+ public abstract Type GetFieldType (int i);
+ public abstract float GetFloat (int i);
+ public abstract Guid GetGuid (int i);
+ public abstract short GetInt16 (int i);
+ public abstract int GetInt32 (int i);
+ public abstract long GetInt64 (int i);
+ public abstract string GetName (int i);
+ public abstract int GetOrdinal (string name);
+ public abstract object GetProviderSpecificValue (int i);
+ public abstract int GetProviderSpecificValues (object[] values);
+ public abstract DataTable GetSchemaTable ();
+ public abstract string GetString (int i);
+ public abstract object GetValue (int i);
+ public abstract int GetValues (object[] values);
+
+ IDataReader IDataRecord.GetData (int i)
+ {
+ return ((IDataReader) this).GetData (i);
+ }
+
+ public abstract bool IsDBNull (int i);
+ public abstract bool NextResult ();
+ public abstract bool Read ();
+
+ #endregion // Methods
+ }
+}
+
+#endif // NET_1_2
diff --git a/mcs/class/System.Data/System.Data.SqlClient/ChangeLog b/mcs/class/System.Data/System.Data.SqlClient/ChangeLog
index 8216cfa0f5c..b7cd25553a8 100755
--- a/mcs/class/System.Data/System.Data.SqlClient/ChangeLog
+++ b/mcs/class/System.Data/System.Data.SqlClient/ChangeLog
@@ -1,3 +1,17 @@
+2003-11-20 Joerg Rosenkranz <JoergR@voelcker.com>
+
+ * SqlConnection (SetDefaultConnectionParameters):
+ Changed default value of WORKSTATION ID to reflect real
+ host name instead of "localhost".
+
+2003-11-16 Ben Maurer <bmaurer@users.sourceforge.net>
+
+ * SqlParameterCollection.cs (Clear): Clear needs to take
+ the parameter out of the collection so that it can be used
+ again.
+ (Remove):
+ (RemoveAt): Ditto.
+
2003-10-03 Diego Caravana <diego@toth.it>
* SqlCommand.cs: no change.
diff --git a/mcs/class/System.Data/System.Data.SqlClient/SqlConnection.cs b/mcs/class/System.Data/System.Data.SqlClient/SqlConnection.cs
index f552b33affe..0baadaafc09 100644
--- a/mcs/class/System.Data/System.Data.SqlClient/SqlConnection.cs
+++ b/mcs/class/System.Data/System.Data.SqlClient/SqlConnection.cs
@@ -509,7 +509,7 @@ namespace System.Data.SqlClient {
if (null == parameters.Get ("POOLING"))
parameters["POOLING"] = "true";
if (null == parameters.Get ("WORKSTATION ID"))
- parameters["WORKSTATION ID"] = Dns.GetHostByName ("localhost").HostName;
+ parameters["WORKSTATION ID"] = Dns.GetHostName();
}
private void SetProperties (NameValueCollection parameters)
diff --git a/mcs/class/System.Data/System.Data.SqlClient/SqlParameterCollection.cs b/mcs/class/System.Data/System.Data.SqlClient/SqlParameterCollection.cs
index 5973f74f809..9a9dd37e52a 100644
--- a/mcs/class/System.Data/System.Data.SqlClient/SqlParameterCollection.cs
+++ b/mcs/class/System.Data/System.Data.SqlClient/SqlParameterCollection.cs
@@ -151,6 +151,10 @@ namespace System.Data.SqlClient {
public void Clear()
{
metaParameters.Clear ();
+
+ foreach (SqlParameter p in list)
+ p.Container = null;
+
list.Clear ();
}
@@ -204,12 +208,15 @@ namespace System.Data.SqlClient {
public void Remove (object value)
{
+ ((SqlParameter) value).Container = null;
+
metaParameters.Remove (((SqlParameter) value).MetaParameter);
list.Remove (value);
}
public void RemoveAt (int index)
{
+ this [index].Container = null;
metaParameters.RemoveAt (index);
list.RemoveAt (index);
}
diff --git a/mcs/class/System.Data/System.Data.dll.sources b/mcs/class/System.Data/System.Data.dll.sources
index 4d56d73e0e7..1c5f56ef3c8 100755
--- a/mcs/class/System.Data/System.Data.dll.sources
+++ b/mcs/class/System.Data/System.Data.dll.sources
@@ -1,12 +1,15 @@
Assembly/AssemblyInfo.cs
Assembly/Locale.cs
System.Data/AcceptRejectRule.cs
+System.Data/AdapterMappingException.cs
System.Data/CommandBehavior.cs
System.Data/CommandType.cs
System.Data/ConnectionState.cs
+System.Data/ConflictOptions.cs
System.Data/Constraint.cs
System.Data/ConstraintCollection.cs
System.Data/ConstraintException.cs
+System.Data/DataAdapterException.cs
System.Data/DataCategoryAttribute.cs
System.Data/DataColumn.cs
System.Data/DataColumnChangeEventArgs.cs
@@ -30,6 +33,7 @@ System.Data/DataSysDescriptionAttribute.cs
System.Data/DataTable.cs
System.Data/DataTableCollection.cs
System.Data/DataTablePropertyDescriptor.cs
+System.Data/DataTableReader.cs
System.Data/DataView.cs
System.Data/DataViewManager.cs
System.Data/DataViewManagerListItemTypeDescriptor.cs
@@ -37,12 +41,14 @@ System.Data/DataViewRowState.cs
System.Data/DataViewSetting.cs
System.Data/DataViewSettingCollection.cs
System.Data/DBConcurrencyException.cs
+System.Data/DbMetaData.cs
System.Data/DbType.cs
System.Data/DeletedRowInaccessibleException.cs
System.Data/DuplicateNameException.cs
System.Data/EvaluateException.cs
System.Data/FillErrorEventArgs.cs
System.Data/FillErrorEventHandler.cs
+System.Data/FillOptions.cs
System.Data/ForeignKeyConstraint.cs
System.Data/IColumnMapping.cs
System.Data/IColumnMappingCollection.cs
@@ -50,19 +56,29 @@ System.Data/IDataAdapter.cs
System.Data/IDataParameter.cs
System.Data/IDataParameterCollection.cs
System.Data/IDataReader.cs
+System.Data/IDataReader2.cs
System.Data/IDataRecord.cs
+System.Data/IDataRecord2.cs
+System.Data/IDataSources.cs
+System.Data/IDataUpdatableRecord.cs
+System.Data/IDbAsyncCommand.cs
+System.Data/IDbAsyncConnection.cs
System.Data/IDbCommand.cs
System.Data/IDbConnection.cs
System.Data/IDbDataAdapter.cs
System.Data/IDbDataParameter.cs
+System.Data/IDbExecutionContext.cs
System.Data/IDbTransaction.cs
+System.Data/IGetTypedData.cs
System.Data/InRowChangingEventException.cs
System.Data/InternalDataCollectionBase.cs
System.Data/InvalidConstraintException.cs
System.Data/InvalidExpressionException.cs
+System.Data/ISetTypedData.cs
System.Data/IsolationLevel.cs
System.Data/ITableMapping.cs
System.Data/ITableMappingCollection.cs
+System.Data/LoadOption.cs
System.Data/MappingType.cs
System.Data/MergeFailedEventArgs.cs
System.Data/MergeFailedEventHandler.cs
@@ -71,23 +87,29 @@ System.Data/MissingMappingAction.cs
System.Data/MissingPrimaryKeyException.cs
System.Data/MissingSchemaAction.cs
System.Data/NoNullAllowedException.cs
+System.Data/OperationAbortedException.cs
System.Data/ParameterDirection.cs
System.Data/PropertyAttributes.cs
System.Data/PropertyCollection.cs
System.Data/ReadOnlyException.cs
System.Data/ResDescriptionAttribute.cs
+System.Data/ResultSetOptions.cs
+System.Data/ResultSetSensitivity.cs
System.Data/RowNotInTableException.cs
System.Data/Rule.cs
System.Data/SchemaType.cs
System.Data/SqlDbType.cs
System.Data/StateChangeEventArgs.cs
System.Data/StateChangeEventHandler.cs
+System.Data/StatementCompletedEventArgs.cs
+System.Data/StatementCompletedEventHandler.cs
System.Data/StatementType.cs
System.Data/StrongTypingException.cs
System.Data/SyntaxErrorException.cs
System.Data/TODOAttribute.cs
System.Data/TypeDataSetGeneratorException.cs
System.Data/UniqueConstraint.cs
+System.Data/UpdateOptions.cs
System.Data/UpdateRowSource.cs
System.Data/UpdateStatus.cs
System.Data/VersionNotFoundException.cs
@@ -104,6 +126,7 @@ System.Data.Common/DataTableMappingCollection.cs
System.Data.Common/DbDataAdapter.cs
System.Data.Common/DbDataPermission.cs
System.Data.Common/DbDataPermissionAttribute.cs
+System.Data.Common/DbDataReader.cs
System.Data.Common/DbDataRecord.cs
System.Data.Common/DbEnumerator.cs
System.Data.Common/FieldNameLookup.cs
diff --git a/mcs/class/System.Data/System.Data/AdapterMappingException.cs b/mcs/class/System.Data/System.Data/AdapterMappingException.cs
new file mode 100644
index 00000000000..73d7781d3f7
--- /dev/null
+++ b/mcs/class/System.Data/System.Data/AdapterMappingException.cs
@@ -0,0 +1,44 @@
+//
+// System.Data.AdapterMappingException.cs
+//
+// Author:
+// Tim Coleman (tim@timcoleman.com)
+//
+// Copyright (C) Tim Coleman, 2003
+//
+
+#if NET_1_2
+
+using System.Globalization;
+using System.Runtime.Serialization;
+
+namespace System.Data {
+ public class AdapterMappingException : InvalidOperationException
+ {
+ #region Constructors
+
+ public AdapterMappingException ()
+ : base (Locale.GetText ("An AdapterMappingException has occurred."))
+ {
+ }
+
+ public AdapterMappingException (string s)
+ : base (s)
+ {
+ }
+
+ public AdapterMappingException (string s, Exception innerException)
+ : base (s, innerException)
+ {
+ }
+
+ public AdapterMappingException (SerializationInfo info, StreamingContext context)
+ : base (info, context)
+ {
+ }
+
+ #endregion // Constructors
+ }
+}
+
+#endif // NET_1_2
diff --git a/mcs/class/System.Data/System.Data/ChangeLog b/mcs/class/System.Data/System.Data/ChangeLog
index bd0d0fee1b6..85075f06491 100644
--- a/mcs/class/System.Data/System.Data/ChangeLog
+++ b/mcs/class/System.Data/System.Data/ChangeLog
@@ -1,3 +1,40 @@
+2003-11-26 Miguel de Icaza <miguel@ximian.com>
+
+ * DataSet.cs: Add a few more missing methods, code style updated
+ to Mono style.
+
+2003-11-26 Tim Coleman <tim@timcoleman.com>
+
+ * ConflictOptions.cs DataAdapterException.cs DataTableReader.cs
+ * DbMetaData.cs FillOptions.cs IDataReader2.cs IDataRecord2.cs
+ * IDataUpdatableRecord.cs IDbAsyncCommand.cs IDbAsyncConnection.cs
+ * IDbExecutionContext.cs IGetTypedData.cs ISetTypedData.cs
+ * LoadOption.cs OperationAbortedException.cs ResultSetOptions.cs
+ * ResultSetSensitivity.cs StatementCompletedEventArgs.cs
+ * StatementCompletedEventHandler.cs UpdateOptions.cs:
+ New classes added for NET_1_2
+ * DBConcurrencyException.cs DataRelation.cs DataSet.cs DataTable.cs
+ * DataTableCollection.cs DataView.cs ForeignKeyConstraint.cs:
+ Modifications to add new NET_1_2 functions
+
+2003-11-25 Tim Coleman <tim@timcoleman.com>
+ * IDataSources.cs:
+ New 1.2 class added
+
+2003-11-21 Pedro Martínez Juliá <yoros@wanadoo.es>
+
+ * DataRow.cs: Detached row can be accesible (new rows from data
+ table are detached). Closes but #51263.
+
+2003-11-19 Eran Domb <erand@mainsoft.com>
+ * DataRow.cs : Throw exceptions if Row is Detached.
+ (EndEdit) : Check that we are not in middle of ChangeEvent.
+ (AcceptChanges) : Detach the row.
+
+ * DataRelation.cs : throw correct exception.
+ *UniqueConstraint.cs : throw correct exception.
+
+
2003-11-09 Pedro Martínez Juliá <yoros@wanadoo.es>
* DataRow.cs: Use RemoveInternal instead of Remove because the last
diff --git a/mcs/class/System.Data/System.Data/ConflictOptions.cs b/mcs/class/System.Data/System.Data/ConflictOptions.cs
new file mode 100644
index 00000000000..79628d8f3bf
--- /dev/null
+++ b/mcs/class/System.Data/System.Data/ConflictOptions.cs
@@ -0,0 +1,32 @@
+//
+// System.Data.ConflictOptions.cs
+//
+// Author:
+// Tim Coleman (tim@timcoleman.com)
+//
+// Copyright (C) Tim Coleman, 2003
+//
+
+#if NET_1_2
+
+namespace System.Data {
+ public enum ConflictOptions
+ {
+ Optimistic,
+ SetAllValues,
+ CompareRowVersion,
+ CompareRowVersionUpdate,
+ CompareRowVersionDelete,
+ CompareAllValues,
+ CompareAllValuesUpdate,
+ CompareAllValuesDelete,
+ CompareChangedValues,
+ CompareChangedValuesUpdate,
+ CompareChangedValuesDelete,
+ OverwriteChanges,
+ OverwriteChangesUpdate,
+ OverwriteChangesDelete
+ }
+}
+
+#endif // NET_1_2
diff --git a/mcs/class/System.Data/System.Data/DBConcurrencyException.cs b/mcs/class/System.Data/System.Data/DBConcurrencyException.cs
index 22dc144e58c..553fe86af9d 100644
--- a/mcs/class/System.Data/System.Data/DBConcurrencyException.cs
+++ b/mcs/class/System.Data/System.Data/DBConcurrencyException.cs
@@ -13,7 +13,9 @@ namespace System.Data {
[Serializable]
public sealed class DBConcurrencyException : SystemException
{
+ DataRow row;
+ #region Constructors
#if NET_1_1
public DBConcurrencyException ()
: base ()
@@ -30,17 +32,53 @@ namespace System.Data {
{
}
- DataRow row;
+#if NET_1_2
+ public DBConcurrencyException (DataRow[] dataRows, string message, Exception inner)
+ : base (message, inner)
+ {
+ }
+#endif
+ #endregion // Constructors
+
+ #region Properties
public DataRow Row {
get { return row; }
set { row = value;} // setting the row has no effect
}
+#if NET_1_2
+ [MonoTODO]
+ public int RowCount {
+ get { throw new NotImplementedException (); }
+ }
+#endif
+
+ #endregion // Properties
+
+ #region Methods
+
+#if NET_1_2
+ [MonoTODO]
+ public void CopyToRows (DataRow[] array)
+ {
+ throw new NotImplementedException ();
+ }
+#endif
+
+#if NET_1_2
+ [MonoTODO]
+ public void CopyToRows (DataRow[] array, int ArrayIndex)
+ {
+ throw new NotImplementedException ();
+ }
+#endif
[MonoTODO]
public override void GetObjectData (SerializationInfo info, StreamingContext context)
{
base.GetObjectData (info, context);
}
+
+ #endregion // Methods
}
}
diff --git a/mcs/class/System.Data/System.Data/DataAdapterException.cs b/mcs/class/System.Data/System.Data/DataAdapterException.cs
new file mode 100644
index 00000000000..13ebb8516aa
--- /dev/null
+++ b/mcs/class/System.Data/System.Data/DataAdapterException.cs
@@ -0,0 +1,44 @@
+//
+// System.Data.DataAdapterException.cs
+//
+// Author:
+// Tim Coleman (tim@timcoleman.com)
+//
+// Copyright (C) Tim Coleman, 2003
+//
+
+#if NET_1_2
+
+using System.Globalization;
+using System.Runtime.Serialization;
+
+namespace System.Data {
+ public class DataAdapterException : InvalidOperationException
+ {
+ #region Constructors
+
+ public DataAdapterException ()
+ : base (Locale.GetText ("A DataAdapterException has occurred."))
+ {
+ }
+
+ public DataAdapterException (string s)
+ : base (s)
+ {
+ }
+
+ public DataAdapterException (string s, Exception innerException)
+ : base (s, innerException)
+ {
+ }
+
+ public DataAdapterException (SerializationInfo info, StreamingContext context)
+ : base (info, context)
+ {
+ }
+
+ #endregion // Constructors
+ }
+}
+
+#endif // NET_1_2
diff --git a/mcs/class/System.Data/System.Data/DataRelation.cs b/mcs/class/System.Data/System.Data/DataRelation.cs
index c676ffc97f0..f41537297bd 100644
--- a/mcs/class/System.Data/System.Data/DataRelation.cs
+++ b/mcs/class/System.Data/System.Data/DataRelation.cs
@@ -4,9 +4,11 @@
// Author:
// Daniel Morgan <danmorg@sc.rr.com>
// Alan Tam Siu Lung <Tam@SiuLung.com>
+// Tim Coleman <tim@timcoleman.com>
//
// (C) 2002 Daniel Morgan
// (C) 2002 Ximian, Inc.
+// Copyright (C) Tim Coleman, 2003
//
using System;
@@ -62,7 +64,7 @@ namespace System.Data
this.childColumns = childColumns;
this.createConstraints = createConstraints;
if (parentColumns.Length != childColumns.Length)
- throw new InvalidConstraintException ();
+ throw new ArgumentException ("ParentColumns and ChildColumns should be the same length");
DataTable parentTable = parentColumns[0].Table;
DataTable childTable = childColumns[0].Table;
if (parentTable.DataSet != childTable.DataSet)
@@ -82,6 +84,14 @@ namespace System.Data
throw new NotImplementedException ();
}
+#if NET_1_2
+ [MonoTODO]
+ public DataRelation (string relationName, string parentTableName, string parentTableNamespace, string childTableName, string childTableNamespace, string[] parentColumnNames, string[] childColumnNames, bool nested)
+ {
+ throw new NotImplementedException ();
+ }
+#endif
+
#endregion // Constructors
#region Properties
diff --git a/mcs/class/System.Data/System.Data/DataRow.cs b/mcs/class/System.Data/System.Data/DataRow.cs
index 55c41b9c97d..bbba60656c4 100644
--- a/mcs/class/System.Data/System.Data/DataRow.cs
+++ b/mcs/class/System.Data/System.Data/DataRow.cs
@@ -40,6 +40,7 @@ namespace System.Data {
private string _nullConstraintMessage;
private bool editing = false;
private bool _hasParentCollection;
+ private bool _inChangingEvent;
#endregion
@@ -185,8 +186,11 @@ namespace System.Data {
// Accessing deleted rows
if (rowState == DataRowState.Deleted && version != DataRowVersion.Original)
throw new DeletedRowInaccessibleException ("Deleted row information cannot be accessed through the row.");
+ // Row not in table
+ //if (rowState == DataRowState.Detached && version == DataRowVersion.Default)
+ // throw new RowNotInTableException("This row has been removed from a table and does not have any data. BeginEdit() will allow creation of new data in this row.");
// Non-existent version
- if (rowState == DataRowState.Detached && version == DataRowVersion.Current || !HasVersion (version))
+ if (!HasVersion (version))
throw new VersionNotFoundException (Locale.GetText ("There is no " + version.ToString () + " data to access."));
switch (version) {
case DataRowVersion.Default:
@@ -211,9 +215,12 @@ namespace System.Data {
[MonoTODO]
public object[] ItemArray {
get {
- // Accessing deleted rows
- if (rowState == DataRowState.Deleted)
- throw new DeletedRowInaccessibleException ("Deleted row information cannot be accessed through the row.");
+ // row not in table
+ if (rowState == DataRowState.Detached)
+ throw new RowNotInTableException("This row has been removed from a table and does not have any data. BeginEdit() will allow creation of new data in this row.");
+ // Accessing deleted rows
+ if (rowState == DataRowState.Deleted)
+ throw new DeletedRowInaccessibleException ("Deleted row information cannot be accessed through the row.");
return current;
}
@@ -243,132 +250,131 @@ namespace System.Data {
}
}
- private object SetColumnValue (object v, int index)
- {
- object newval = null;
- DataColumn col = _table.Columns[index];
-
- if (_hasParentCollection && col.ReadOnly && v != this[index])
- throw new ReadOnlyException ();
-
- if (v == null)
- {
- if(col.DefaultValue != DBNull.Value)
- {
- newval = col.DefaultValue;
- }
- else if(col.AutoIncrement == true)
- {
- newval = this [index];
- }
- else
- {
- if (!col.AllowDBNull)
- {
- //Constraint violations during data load is raise in DataTable EndLoad
- this._nullConstraintViolation = true;
- _nullConstraintMessage = "Column '" + col.ColumnName + "' does not allow nulls.";
- }
-
- newval = DBNull.Value;
- }
- }
- else if (v == DBNull.Value)
- {
-
- if (!col.AllowDBNull)
- {
- //Constraint violations during data load is raise in DataTable EndLoad
- this._nullConstraintViolation = true;
- _nullConstraintMessage = "Column '" + col.ColumnName + "' does not allow nulls.";
- }
-
- newval = DBNull.Value;
- }
- else
- {
- Type vType = v.GetType(); // data type of value
- Type cType = col.DataType; // column data type
- if (cType != vType)
- {
- TypeCode typeCode = Type.GetTypeCode(cType);
- switch(typeCode) {
- case TypeCode.Boolean :
- v = Convert.ToBoolean (v);
- break;
- case TypeCode.Byte :
- v = Convert.ToByte (v);
- break;
- case TypeCode.Char :
- v = Convert.ToChar (v);
- break;
- case TypeCode.DateTime :
- v = Convert.ToDateTime (v);
- break;
- case TypeCode.Decimal :
- v = Convert.ToDecimal (v);
- break;
- case TypeCode.Double :
- v = Convert.ToDouble (v);
- break;
- case TypeCode.Int16 :
- v = Convert.ToInt16 (v);
- break;
- case TypeCode.Int32 :
- v = Convert.ToInt32 (v);
- break;
- case TypeCode.Int64 :
- v = Convert.ToInt64 (v);
- break;
- case TypeCode.SByte :
- v = Convert.ToSByte (v);
- break;
- case TypeCode.Single :
- v = Convert.ToSingle (v);
- break;
- case TypeCode.String :
- v = Convert.ToString (v);
- break;
- case TypeCode.UInt16 :
- v = Convert.ToUInt16 (v);
- break;
- case TypeCode.UInt32 :
- v = Convert.ToUInt32 (v);
- break;
- case TypeCode.UInt64 :
- v = Convert.ToUInt64 (v);
- break;
- default :
-
- switch(cType.ToString()) {
- case "System.TimeSpan" :
- v = (System.TimeSpan) v;
- break;
- case "System.Type" :
- v = (System.Type) v;
- break;
- case "System.Object" :
- //v = (System.Object) v;
- break;
- default:
- if (!cType.IsArray)
- throw new InvalidCastException("Type not supported.");
- break;
- }
- break;
- }
- vType = v.GetType();
- }
- newval = v;
- if(col.AutoIncrement == true) {
- long inc = Convert.ToInt64(v);
- col.UpdateAutoIncrementValue (inc);
- }
- }
- col.DataHasBeenSet = true;
- return newval;
- }
+ private object SetColumnValue (object v, int index)
+ {
+ object newval = null;
+ DataColumn col = _table.Columns[index];
+
+ if (_hasParentCollection && col.ReadOnly && v != this[index])
+ throw new ReadOnlyException ();
+
+ if (v == null)
+ {
+ if(col.DefaultValue != DBNull.Value)
+ {
+ newval = col.DefaultValue;
+ }
+ else if(col.AutoIncrement == true)
+ {
+ newval = this [index];
+ }
+ else
+ {
+ if (!col.AllowDBNull)
+ {
+ //Constraint violations during data load is raise in DataTable EndLoad
+ this._nullConstraintViolation = true;
+ _nullConstraintMessage = "Column '" + col.ColumnName + "' does not allow nulls.";
+ }
+ newval = DBNull.Value;
+ }
+ }
+ else if (v == DBNull.Value)
+ {
+
+ if (!col.AllowDBNull)
+ {
+ //Constraint violations during data load is raise in DataTable EndLoad
+ this._nullConstraintViolation = true;
+ _nullConstraintMessage = "Column '" + col.ColumnName + "' does not allow nulls.";
+ }
+
+ newval = DBNull.Value;
+ }
+ else
+ {
+ Type vType = v.GetType(); // data type of value
+ Type cType = col.DataType; // column data type
+ if (cType != vType)
+ {
+ TypeCode typeCode = Type.GetTypeCode(cType);
+ switch(typeCode) {
+ case TypeCode.Boolean :
+ v = Convert.ToBoolean (v);
+ break;
+ case TypeCode.Byte :
+ v = Convert.ToByte (v);
+ break;
+ case TypeCode.Char :
+ v = Convert.ToChar (v);
+ break;
+ case TypeCode.DateTime :
+ v = Convert.ToDateTime (v);
+ break;
+ case TypeCode.Decimal :
+ v = Convert.ToDecimal (v);
+ break;
+ case TypeCode.Double :
+ v = Convert.ToDouble (v);
+ break;
+ case TypeCode.Int16 :
+ v = Convert.ToInt16 (v);
+ break;
+ case TypeCode.Int32 :
+ v = Convert.ToInt32 (v);
+ break;
+ case TypeCode.Int64 :
+ v = Convert.ToInt64 (v);
+ break;
+ case TypeCode.SByte :
+ v = Convert.ToSByte (v);
+ break;
+ case TypeCode.Single :
+ v = Convert.ToSingle (v);
+ break;
+ case TypeCode.String :
+ v = Convert.ToString (v);
+ break;
+ case TypeCode.UInt16 :
+ v = Convert.ToUInt16 (v);
+ break;
+ case TypeCode.UInt32 :
+ v = Convert.ToUInt32 (v);
+ break;
+ case TypeCode.UInt64 :
+ v = Convert.ToUInt64 (v);
+ break;
+ default :
+
+ switch(cType.ToString()) {
+ case "System.TimeSpan" :
+ v = (System.TimeSpan) v;
+ break;
+ case "System.Type" :
+ v = (System.Type) v;
+ break;
+ case "System.Object" :
+ //v = (System.Object) v;
+ break;
+ default:
+ if (!cType.IsArray)
+ throw new InvalidCastException("Type not supported.");
+ break;
+ }
+ break;
+ }
+ vType = v.GetType();
+ }
+ newval = v;
+ if(col.AutoIncrement == true) {
+ long inc = Convert.ToInt64(v);
+ col.UpdateAutoIncrementValue (inc);
+ }
+ }
+ col.DataHasBeenSet = true;
+ return newval;
+ }
/// <summary>
/// Gets or sets the custom error description for a row.
@@ -436,6 +442,7 @@ namespace System.Data {
break;
case DataRowState.Deleted:
_table.Rows.RemoveInternal (this);
+ DetachRow();
break;
case DataRowState.Detached:
throw new RowNotInTableException("Cannot perform this operation on a row not in the table.");
@@ -499,14 +506,14 @@ namespace System.Data {
Table.Rows.RemoveInternal (this);
break;
case DataRowState.Deleted:
- throw new DeletedRowInaccessibleException ();
+ break;
default:
// check what to do with child rows
CheckChildRows(DataRowAction.Delete);
rowState = DataRowState.Deleted;
break;
}
- _table.DeletedDataRow(this, DataRowAction.Delete);
+ _table.DeletedDataRow(this, DataRowAction.Delete);
}
// check the child rows of this row before deleting the row.
@@ -633,37 +640,47 @@ namespace System.Data {
[MonoTODO]
public void EndEdit ()
{
- if (rowState == DataRowState.Detached)
- {
- editing = false;
- return;
- }
-
- if (HasVersion (DataRowVersion.Proposed))
- {
- _table.ChangingDataRow(this, DataRowAction.Change);
- if (rowState == DataRowState.Unchanged)
- rowState = DataRowState.Modified;
-
- //Calling next method validates UniqueConstraints
- //and ForeignKeys.
- try
- {
- if ((_table.DataSet == null || _table.DataSet.EnforceConstraints) && !_table._duringDataLoad)
- _table.Rows.ValidateDataRowInternal(this);
- }
- catch (Exception e)
- {
- editing = false;
- proposed = null;
- throw e;
- }
- // check all child rows.
- CheckChildRows(DataRowAction.Change);
- current = proposed;
- proposed = null;
- editing = false;
- _table.ChangedDataRow(this, DataRowAction.Change);
+ if (_inChangingEvent)
+ throw new InRowChangingEventException("Cannot call EndEdit inside an OnRowChanging event.");
+ if (rowState == DataRowState.Detached)
+ {
+ editing = false;
+ return;
+ }
+
+ if (HasVersion (DataRowVersion.Proposed))
+ {
+ _inChangingEvent = true;
+ try
+ {
+ _table.ChangingDataRow(this, DataRowAction.Change);
+ }
+ finally
+ {
+ _inChangingEvent = false;
+ }
+ if (rowState == DataRowState.Unchanged)
+ rowState = DataRowState.Modified;
+
+ //Calling next method validates UniqueConstraints
+ //and ForeignKeys.
+ try
+ {
+ if ((_table.DataSet == null || _table.DataSet.EnforceConstraints) && !_table._duringDataLoad)
+ _table.Rows.ValidateDataRowInternal(this);
+ }
+ catch (Exception e)
+ {
+ editing = false;
+ proposed = null;
+ throw e;
+ }
+ // check all child rows.
+ CheckChildRows(DataRowAction.Change);
+ current = proposed;
+ proposed = null;
+ editing = false;
+ _table.ChangedDataRow(this, DataRowAction.Change);
}
}
@@ -693,8 +710,8 @@ namespace System.Data {
if (relation == null)
return new DataRow[0];
- if (this.Table == null)
- throw new RowNotInTableException();
+ if (this.Table == null || RowState == DataRowState.Detached)
+ throw new RowNotInTableException("This row has been removed from a table and does not have any data. BeginEdit() will allow creation of new data in this row.");
if (relation.DataSet != this.Table.DataSet)
throw new ArgumentException();
@@ -847,8 +864,8 @@ namespace System.Data {
if (relation == null)
return new DataRow[0];
- if (this.Table == null)
- throw new RowNotInTableException();
+ if (this.Table == null || RowState == DataRowState.Detached)
+ throw new RowNotInTableException("This row has been removed from a table and does not have any data. BeginEdit() will allow creation of new data in this row.");
if (relation.DataSet != this.Table.DataSet)
throw new ArgumentException();
@@ -962,6 +979,8 @@ namespace System.Data {
/// </summary>
public void RejectChanges ()
{
+ if (RowState == DataRowState.Detached)
+ throw new RowNotInTableException("This row has been removed from a table and does not have any data. BeginEdit() will allow creation of new data in this row.");
// If original is null, then nothing has happened since AcceptChanges
// was last called. We have no "original" to go back to.
if (original != null)
@@ -1045,8 +1064,8 @@ namespace System.Data {
[MonoTODO]
public void SetParentRow (DataRow parentRow, DataRelation relation)
{
- if (_table == null || parentRow.Table == null)
- throw new RowNotInTableException();
+ if (_table == null || parentRow.Table == null || RowState == DataRowState.Detached)
+ throw new RowNotInTableException("This row has been removed from a table and does not have any data. BeginEdit() will allow creation of new data in this row.");
if (parentRow != null && _table.DataSet != parentRow.Table.DataSet)
throw new ArgumentException();
@@ -1202,17 +1221,17 @@ namespace System.Data {
}
}
- internal void CheckNullConstraints()
- {
- if (_nullConstraintViolation)
- {
- for (int i = 0; i < proposed.Length; i++)
- {
- if (this[i] == DBNull.Value && !_table.Columns[i].AllowDBNull)
- throw new NoNullAllowedException(_nullConstraintMessage);
- }
- _nullConstraintViolation = false;
- }
+ internal void CheckNullConstraints()
+ {
+ if (_nullConstraintViolation)
+ {
+ for (int i = 0; i < proposed.Length; i++)
+ {
+ if (this[i] == DBNull.Value && !_table.Columns[i].AllowDBNull)
+ throw new NoNullAllowedException(_nullConstraintMessage);
+ }
+ _nullConstraintViolation = false;
+ }
}
#endregion // Methods
diff --git a/mcs/class/System.Data/System.Data/DataSet.cs b/mcs/class/System.Data/System.Data/DataSet.cs
index 317aade0a11..14b57c48c10 100644
--- a/mcs/class/System.Data/System.Data/DataSet.cs
+++ b/mcs/class/System.Data/System.Data/DataSet.cs
@@ -10,7 +10,7 @@
// Ville Palo <vi64pa@koti.soon.fi>
//
// (C) Ximian, Inc. 2002
-// Copyright (C) Tim Coleman, 2002
+// Copyright (C) Tim Coleman, 2002, 2003
//
using System;
@@ -26,14 +26,11 @@ using System.Xml.Serialization;
using System.Data.Common;
namespace System.Data {
- /// <summary>
- /// an in-memory cache of data
- /// </summary>
- //[Designer]
+
[ToolboxItem (false)]
[DefaultProperty ("DataSetName")]
[Serializable]
- public class DataSet : MarshalByValueComponent, IListSource,
+ public class DataSet : MarshalByValueComponent, IListSource,
ISupportInitialize, ISerializable, IXmlSerializable {
private string dataSetName;
private string _namespace = "";
@@ -46,23 +43,24 @@ namespace System.Data {
private DataViewManager defaultView;
private CultureInfo locale = System.Threading.Thread.CurrentThread.CurrentCulture;
- #region Constructors
+#region Constructors
- public DataSet() : this ("NewDataSet") {
+ public DataSet () : this ("NewDataSet") {
}
-
- public DataSet(string name) {
+
+ public DataSet (string name)
+ {
dataSetName = name;
tableCollection = new DataTableCollection (this);
relationCollection = new DataRelationCollection.DataSetRelationCollection (this);
- properties = new PropertyCollection();
+ properties = new PropertyCollection ();
this.prefix = String.Empty;
this.Locale = CultureInfo.CurrentCulture;
}
[MonoTODO]
- protected DataSet(SerializationInfo info, StreamingContext context) : this () {
+ protected DataSet (SerializationInfo info, StreamingContext context) : this () {
throw new NotImplementedException ();
}
@@ -74,7 +72,9 @@ namespace System.Data {
[DataSysDescription ("Indicates whether comparing strings within the DataSet is case sensitive.")]
[DefaultValue (false)]
public bool CaseSensitive {
- get { return caseSensitive; }
+ get {
+ return caseSensitive;
+ }
set {
foreach (DataTable T in Tables) {
if (T.VirginCaseSensitive)
@@ -82,12 +82,10 @@ namespace System.Data {
}
caseSensitive = value;
- if (!caseSensitive)
- {
- foreach (DataTable table in Tables)
- {
+ if (!caseSensitive) {
+ foreach (DataTable table in Tables) {
foreach (Constraint c in table.Constraints)
- c.AssertConstraint();
+ c.AssertConstraint ();
}
}
}
@@ -116,15 +114,12 @@ namespace System.Data {
public bool EnforceConstraints {
get { return enforceConstraints; }
set {
- if (value != enforceConstraints)
- {
+ if (value != enforceConstraints) {
enforceConstraints = value;
- if (value)
- {
- foreach (DataTable table in Tables)
- {
+ if (value) {
+ foreach (DataTable table in Tables) {
foreach (Constraint c in table.Constraints)
- c.AssertConstraint();
+ c.AssertConstraint ();
}
}
}
@@ -159,7 +154,7 @@ namespace System.Data {
return locale;
}
set {
- if (locale == null || !locale.Equals(value)) {
+ if (locale == null || !locale.Equals (value)) {
// TODO: check if the new locale is valid
// TODO: update locale of all tables
locale = value;
@@ -190,37 +185,37 @@ namespace System.Data {
[MonoTODO]
public void Merge (DataRow[] rows, bool preserveChanges, MissingSchemaAction missingSchemaAction)
{
- if(rows == null)
- throw new ArgumentNullException("rows");
- if(!IsLegalSchemaAction(missingSchemaAction))
- throw new ArgumentOutOfRangeException("missingSchemaAction");
+ if (rows == null)
+ throw new ArgumentNullException ("rows");
+ if (!IsLegalSchemaAction (missingSchemaAction))
+ throw new ArgumentOutOfRangeException ("missingSchemaAction");
- MergeManager.Merge(this, rows, preserveChanges, missingSchemaAction);
+ MergeManager.Merge (this, rows, preserveChanges, missingSchemaAction);
}
[MonoTODO]
public void Merge (DataSet dataSet, bool preserveChanges, MissingSchemaAction missingSchemaAction)
{
- if(dataSet == null)
- throw new ArgumentNullException("dataSet");
- if(!IsLegalSchemaAction(missingSchemaAction))
- throw new ArgumentOutOfRangeException("missingSchemaAction");
+ if (dataSet == null)
+ throw new ArgumentNullException ("dataSet");
+ if (!IsLegalSchemaAction (missingSchemaAction))
+ throw new ArgumentOutOfRangeException ("missingSchemaAction");
- MergeManager.Merge(this, dataSet, preserveChanges, missingSchemaAction);
+ MergeManager.Merge (this, dataSet, preserveChanges, missingSchemaAction);
}
[MonoTODO]
public void Merge (DataTable table, bool preserveChanges, MissingSchemaAction missingSchemaAction)
{
- if(table == null)
- throw new ArgumentNullException("table");
- if(!IsLegalSchemaAction(missingSchemaAction))
- throw new ArgumentOutOfRangeException("missingSchemaAction");
+ if (table == null)
+ throw new ArgumentNullException ("table");
+ if (!IsLegalSchemaAction (missingSchemaAction))
+ throw new ArgumentOutOfRangeException ("missingSchemaAction");
- MergeManager.Merge(this, table, preserveChanges, missingSchemaAction);
+ MergeManager.Merge (this, table, preserveChanges, missingSchemaAction);
}
- private static bool IsLegalSchemaAction(MissingSchemaAction missingSchemaAction)
+ private static bool IsLegalSchemaAction (MissingSchemaAction missingSchemaAction)
{
if (missingSchemaAction == MissingSchemaAction.Add || missingSchemaAction == MissingSchemaAction.AddWithKey
|| missingSchemaAction == MissingSchemaAction.Error || missingSchemaAction == MissingSchemaAction.Ignore)
@@ -252,14 +247,10 @@ namespace System.Data {
//TODO - trigger an event if this happens?
if (value == null)
- {
value = string.Empty;
- }
- if (value != this.prefix)
- {
- RaisePropertyChanging("Prefix");
- }
+ if (value != this.prefix)
+ RaisePropertyChanging ("Prefix");
prefix = value;
}
}
@@ -299,13 +290,13 @@ namespace System.Data {
#region Public Methods
[MonoTODO]
- public void AcceptChanges()
+ public void AcceptChanges ()
{
foreach (DataTable tempTable in tableCollection)
tempTable.AcceptChanges ();
}
- public void Clear()
+ public void Clear ()
{
// TODO: if currently bound to a XmlDataDocument
// throw a NotSupportedException
@@ -314,7 +305,7 @@ namespace System.Data {
}
}
- public virtual DataSet Clone()
+ public virtual DataSet Clone ()
{
DataSet Copy = new DataSet ();
CopyProperties (Copy);
@@ -325,25 +316,24 @@ namespace System.Data {
//Copy Relationships between tables after existance of tables
//and setting properties correctly
- CopyRelations(Copy);
+ CopyRelations (Copy);
return Copy;
}
// Copies both the structure and data for this DataSet.
- public DataSet Copy()
+ public DataSet Copy ()
{
DataSet Copy = new DataSet ();
CopyProperties (Copy);
// Copy DatSet's tables
- foreach (DataTable Table in Tables) {
+ foreach (DataTable Table in Tables)
Copy.Tables.Add (Table.Copy ());
- }
//Copy Relationships between tables after existance of tables
//and setting properties correctly
- CopyRelations(Copy);
+ CopyRelations (Copy);
return Copy;
}
@@ -381,22 +371,20 @@ namespace System.Data {
DataColumn[] P_DC = new DataColumn[MyRelation.ParentColumns.Length];
DataColumn[] C_DC = new DataColumn[MyRelation.ChildColumns.Length];
int i = 0;
- foreach(DataColumn DC in MyRelation.ParentColumns)
- {
+
+ foreach (DataColumn DC in MyRelation.ParentColumns) {
P_DC[i]=Copy.Tables[pTable].Columns[DC.ColumnName];
i++;
}
i = 0;
- foreach(DataColumn DC in MyRelation.ChildColumns)
- {
+ foreach (DataColumn DC in MyRelation.ChildColumns) {
C_DC[i]=Copy.Tables[cTable].Columns[DC.ColumnName];
i++;
}
-
- DataRelation cRel = new DataRelation(MyRelation.RelationName,P_DC,C_DC);
+ DataRelation cRel = new DataRelation (MyRelation.RelationName, P_DC, C_DC);
//cRel.ChildColumns = MyRelation.ChildColumns;
//cRel.ChildTable = MyRelation.ChildTable;
//cRel.ExtendedProperties = cRel.ExtendedProperties;
@@ -404,59 +392,70 @@ namespace System.Data {
//cRel.ParentColumns = MyRelation.ParentColumns;
//cRel.ParentTable = MyRelation.ParentTable;
- Copy.Relations.Add(cRel);
+ Copy.Relations.Add (cRel);
}
}
- public DataSet GetChanges()
+ public DataSet GetChanges ()
{
- return GetChanges(DataRowState.Added | DataRowState.Deleted | DataRowState.Modified);
+ return GetChanges (DataRowState.Added | DataRowState.Deleted | DataRowState.Modified);
}
- public DataSet GetChanges(DataRowState rowStates)
+ public DataSet GetChanges (DataRowState rowStates)
{
- if(!HasChanges(rowStates))
+ if (!HasChanges (rowStates))
return null;
- DataSet copySet = Clone();
- IEnumerator tableEnumerator = Tables.GetEnumerator();
+ DataSet copySet = Clone ();
+ IEnumerator tableEnumerator = Tables.GetEnumerator ();
DataTable origTable;
DataTable copyTable;
- while (tableEnumerator.MoveNext())
- {
+ while (tableEnumerator.MoveNext ()) {
origTable = (DataTable)tableEnumerator.Current;
copyTable = copySet.Tables[origTable.TableName];
- IEnumerator rowEnumerator = origTable.Rows.GetEnumerator();
- while (rowEnumerator.MoveNext())
- {
+ IEnumerator rowEnumerator = origTable.Rows.GetEnumerator ();
+ while (rowEnumerator.MoveNext ()) {
DataRow row = (DataRow)rowEnumerator.Current;
- if (row.IsRowChanged(rowStates))
+ if (row.IsRowChanged (rowStates))
{
- DataRow newRow = copyTable.NewRow();
- copyTable.Rows.Add(newRow);
- row.CopyValuesToRow(newRow);
+ DataRow newRow = copyTable.NewRow ();
+ copyTable.Rows.Add (newRow);
+ row.CopyValuesToRow (newRow);
}
}
}
return copySet;
}
+#if NET_1_2
+ [MonoTODO]
+ public DataTableReader GetDataReader (DataTable[] dataTables)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public DataTableReader GetDataReader ()
+ {
+ throw new NotImplementedException ();
+ }
+#endif
- public string GetXml()
+ public string GetXml ()
{
StringWriter Writer = new StringWriter ();
// Sending false for not printing the Processing instruction
- WriteXml (Writer, XmlWriteMode.IgnoreSchema,false);
+ WriteXml (Writer, XmlWriteMode.IgnoreSchema, false);
return Writer.ToString ();
}
- public string GetXmlSchema()
+ public string GetXmlSchema ()
{
StringWriter Writer = new StringWriter ();
WriteXmlSchema (Writer);
@@ -464,29 +463,28 @@ namespace System.Data {
}
[MonoTODO]
- public bool HasChanges()
+ public bool HasChanges ()
{
- return HasChanges(DataRowState.Added | DataRowState.Deleted | DataRowState.Modified);
+ return HasChanges (DataRowState.Added | DataRowState.Deleted | DataRowState.Modified);
}
[MonoTODO]
- public bool HasChanges(DataRowState rowState)
+ public bool HasChanges (DataRowState rowState)
{
- if(((int)rowState & 0xffffffe0) != 0)
- throw new ArgumentOutOfRangeException("rowState");
+ if (((int)rowState & 0xffffffe0) != 0)
+ throw new ArgumentOutOfRangeException ("rowState");
DataTableCollection tableCollection = Tables;
DataTable table;
DataRowCollection rowCollection;
DataRow row;
- for (int i = 0; i < tableCollection.Count; i++)
- {
+
+ for (int i = 0; i < tableCollection.Count; i++) {
table = tableCollection[i];
rowCollection = table.Rows;
- for (int j = 0; j < rowCollection.Count; j++)
- {
+ for (int j = 0; j < rowCollection.Count; j++) {
row = rowCollection[j];
- if((row.RowState & rowState) != 0)
+ if ((row.RowState & rowState) != 0)
return true;
}
}
@@ -495,23 +493,23 @@ namespace System.Data {
}
[MonoTODO]
- public void InferXmlSchema(XmlReader reader, string[] nsArray)
+ public void InferXmlSchema (XmlReader reader, string[] nsArray)
{
}
- public void InferXmlSchema(Stream stream, string[] nsArray)
+ public void InferXmlSchema (Stream stream, string[] nsArray)
{
- InferXmlSchema (new XmlTextReader(stream), nsArray);
+ InferXmlSchema (new XmlTextReader (stream), nsArray);
}
- public void InferXmlSchema(TextReader reader, string[] nsArray)
+ public void InferXmlSchema (TextReader reader, string[] nsArray)
{
- InferXmlSchema (new XmlTextReader(reader), nsArray);
+ InferXmlSchema (new XmlTextReader (reader), nsArray);
}
- public void InferXmlSchema(string fileName, string[] nsArray)
+ public void InferXmlSchema (string fileName, string[] nsArray)
{
- XmlTextReader reader = new XmlTextReader(fileName);
+ XmlTextReader reader = new XmlTextReader (fileName);
try {
InferXmlSchema (reader, nsArray);
} finally {
@@ -519,181 +517,218 @@ namespace System.Data {
}
}
- public virtual void RejectChanges()
+#if NET_1_2
+ [MonoTODO]
+ public void Load (IDataReader reader, LoadOption loadOption, DataTable[] tables)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void Load (IDataReader reader, LoadOption loadOption, string[] tables)
+ {
+ throw new NotImplementedException ();
+ }
+#endif
+
+ public virtual void RejectChanges ()
{
int i;
bool oldEnforceConstraints = this.EnforceConstraints;
this.EnforceConstraints = false;
- for (i=0;(i<this.Tables.Count);i++)
- {
- this.Tables[i].RejectChanges();
- }
+
+ for (i = 0; i < this.Tables.Count;i++)
+ this.Tables[i].RejectChanges ();
+
this.EnforceConstraints = oldEnforceConstraints;
}
- public virtual void Reset()
+ public virtual void Reset ()
{
IEnumerator constraintEnumerator;
+
// first we remove all ForeignKeyConstraints (if we will not do that
// we will get an exception when clearing the tables).
- for (int i = 0; i < Tables.Count; i++)
- {
+ for (int i = 0; i < Tables.Count; i++) {
ConstraintCollection cc = Tables[i].Constraints;
- for (int j = 0; j < cc.Count; j++)
- {
+ for (int j = 0; j < cc.Count; j++) {
if (cc[j] is ForeignKeyConstraint)
- cc.Remove(cc[j]);
+ cc.Remove (cc[j]);
}
}
- Clear();
- Relations.Clear();
- Tables.Clear();
+ Clear ();
+ Relations.Clear ();
+ Tables.Clear ();
}
- public void WriteXml(Stream stream)
+ public void WriteXml (Stream stream)
{
- XmlWriter writer = new XmlTextWriter(stream, null );
+ XmlWriter writer = new XmlTextWriter (stream, null);
- WriteXml( writer );
+ WriteXml (writer);
}
///<summary>
/// Writes the current data for the DataSet to the specified file.
/// </summary>
/// <param name="filename">Fully qualified filename to write to</param>
- public void WriteXml(string fileName)
+ public void WriteXml (string fileName)
{
- XmlWriter writer = new XmlTextWriter(fileName, null );
+ XmlWriter writer = new XmlTextWriter (fileName, null);
- WriteXml( writer );
+ WriteXml (writer);
- writer.Close();
+ writer.Close ();
}
- public void WriteXml(TextWriter writer)
+ public void WriteXml (TextWriter writer)
{
- XmlWriter xwriter = new XmlTextWriter(writer );
+ XmlWriter xwriter = new XmlTextWriter (writer);
- WriteXml( xwriter );
+ WriteXml (xwriter);
}
- public void WriteXml(XmlWriter writer)
+ public void WriteXml (XmlWriter writer)
{
- WriteXml( writer, XmlWriteMode.IgnoreSchema,false);
+ WriteXml (writer, XmlWriteMode.IgnoreSchema, false);
}
- public void WriteXml(Stream stream, XmlWriteMode mode,bool writePI)
+ public void WriteXml (string filename, XmlWriteMode mode)
{
- XmlWriter writer = new XmlTextWriter(stream, null );
+ XmlWriter writer = new XmlTextWriter (filename, null);
+ WriteXml (writer, mode, false);
+ }
+
+ public void WriteXml (Stream stream, XmlWriteMode mode)
+ {
+ XmlWriter writer = new XmlTextWriter (stream, null);
+
+ WriteXml (writer, mode, false);
+ }
+
+ public void WriteXml (TextWriter writer, XmlWriteMode mode)
+ {
+ XmlWriter xwriter = new XmlTextWriter (writer);
+ WriteXml (xwriter, mode, false);
+ }
+
+ public void WriteXml (XmlWriter writer, XmlWriteMode mode)
+ {
+ WriteXml (writer, mode, false);
+ }
+
+ public void WriteXml (Stream stream, XmlWriteMode mode, bool writePI)
+ {
+ XmlWriter writer = new XmlTextWriter (stream, null);
- WriteXml( writer, mode, writePI );
+ WriteXml (writer, mode, writePI);
}
- public void WriteXml(string fileName, XmlWriteMode mode, bool writePI)
+ public void WriteXml (string fileName, XmlWriteMode mode, bool writePI)
{
- XmlWriter writer = new XmlTextWriter(fileName, null );
+ XmlWriter writer = new XmlTextWriter (fileName, null);
- WriteXml( writer, mode, writePI );
+ WriteXml (writer, mode, writePI);
- writer.Close();
+ writer.Close ();
}
- public void WriteXml(TextWriter writer, XmlWriteMode mode, bool writePI)
+ public void WriteXml (TextWriter writer, XmlWriteMode mode, bool writePI)
{
- XmlWriter xwriter = new XmlTextWriter(writer);
+ XmlWriter xwriter = new XmlTextWriter (writer);
- WriteXml( xwriter, mode, writePI);
+ WriteXml (xwriter, mode, writePI);
}
- public void WriteXml(XmlWriter writer, XmlWriteMode mode, bool writePI)
+ public void WriteXml (XmlWriter writer, XmlWriteMode mode, bool writePI)
{
if (writePI && (writer.WriteState == WriteState.Start))
writer.WriteStartDocument (true);
- ((XmlTextWriter)writer).Formatting = Formatting.Indented;
- WriteStartElement( writer, mode, Namespace, Prefix, DataSetName );
+ ((XmlTextWriter)writer).Formatting = Formatting.Indented;
+ WriteStartElement (writer, mode, Namespace, Prefix, DataSetName);
- if( mode == XmlWriteMode.WriteSchema )
+ if (mode == XmlWriteMode.WriteSchema)
{
- DoWriteXmlSchema( writer );
+ DoWriteXmlSchema (writer);
}
//Write out each table in order, providing it is not
//part of another table structure via a nested parent relationship
- foreach( DataTable table in Tables )
+ foreach (DataTable table in Tables)
{
bool isTopLevel = true;
- foreach( DataRelation rel in table.ParentRelations )
+ foreach (DataRelation rel in table.ParentRelations)
{
- if( rel.Nested )
+ if (rel.Nested)
{
isTopLevel = false;
break;
}
}
- if( isTopLevel )
+ if (isTopLevel)
{
- WriteTable( writer, table, mode );
+ WriteTable ( writer, table, mode);
}
}
- writer.WriteEndElement();
+ writer.WriteEndElement ();
}
- public void WriteXmlSchema(Stream stream)
+ public void WriteXmlSchema (Stream stream)
{
- XmlWriter writer = new XmlTextWriter(stream, null );
+ XmlWriter writer = new XmlTextWriter (stream, null );
- WriteXmlSchema( writer );
+ WriteXmlSchema (writer);
}
- public void WriteXmlSchema(string fileName)
+ public void WriteXmlSchema (string fileName)
{
- XmlWriter writer = new XmlTextWriter( fileName, null );
+ XmlWriter writer = new XmlTextWriter (fileName, null);
- WriteXmlSchema( writer );
+ WriteXmlSchema (writer);
}
- public void WriteXmlSchema(TextWriter writer)
+ public void WriteXmlSchema (TextWriter writer)
{
- XmlWriter xwriter = new XmlTextWriter( writer );
+ XmlWriter xwriter = new XmlTextWriter (writer);
- WriteXmlSchema( xwriter );
+ WriteXmlSchema (xwriter);
}
- public void WriteXmlSchema(XmlWriter writer)
+ public void WriteXmlSchema (XmlWriter writer)
{
- ((XmlTextWriter)writer).Formatting = Formatting.Indented;
+ ((XmlTextWriter)writer).Formatting = Formatting.Indented;
//Create a skeleton doc and then write the schema
//proper which is common to the WriteXml method in schema mode
- writer.WriteStartDocument();
+ writer.WriteStartDocument ();
- DoWriteXmlSchema( writer );
+ DoWriteXmlSchema (writer);
- writer.WriteEndDocument();
+ writer.WriteEndDocument ();
}
- public void ReadXmlSchema(Stream stream)
+ public void ReadXmlSchema (Stream stream)
{
- XmlReader reader = new XmlTextReader( stream, null );
- ReadXmlSchema( reader);
+ XmlReader reader = new XmlTextReader (stream, null);
+ ReadXmlSchema (reader);
}
- public void ReadXmlSchema(string str)
+ public void ReadXmlSchema (string str)
{
- XmlReader reader = new XmlTextReader( str );
- ReadXmlSchema( reader );
+ XmlReader reader = new XmlTextReader (str);
+ ReadXmlSchema (reader);
}
- public void ReadXmlSchema(TextReader treader)
+ public void ReadXmlSchema (TextReader treader)
{
- XmlReader reader = new XmlTextReader( treader );
- ReadXmlSchema( reader );
+ XmlReader reader = new XmlTextReader (treader);
+ ReadXmlSchema (reader);
}
- public void ReadXmlSchema(XmlReader reader)
+ public void ReadXmlSchema (XmlReader reader)
{
XmlSchemaMapper SchemaMapper = new XmlSchemaMapper (this);
SchemaMapper.Read (reader);
@@ -790,7 +825,7 @@ namespace System.Data {
#region Destructors
- ~DataSet()
+ ~DataSet ()
{
}
@@ -827,24 +862,24 @@ namespace System.Data {
#endregion
#region Protected Methods
- protected void GetSerializationData(SerializationInfo info, StreamingContext context)
+ protected void GetSerializationData (SerializationInfo info, StreamingContext context)
{
string s = info.GetValue ("XmlDiffGram", typeof (String)) as String;
- if (s != null) ReadXmlSerializable (new XmlTextReader(new StringReader(s)));
+ if (s != null) ReadXmlSerializable (new XmlTextReader (new StringReader (s)));
}
- protected virtual System.Xml.Schema.XmlSchema GetSchemaSerializable()
+ protected virtual System.Xml.Schema.XmlSchema GetSchemaSerializable ()
{
return BuildSchema ();
}
- protected virtual void ReadXmlSerializable(XmlReader reader)
+ protected virtual void ReadXmlSerializable (XmlReader reader)
{
- ReadXml(reader, XmlReadMode.DiffGram); // FIXME
+ ReadXml (reader, XmlReadMode.DiffGram); // FIXME
}
- void IXmlSerializable.ReadXml(XmlReader reader)
+ void IXmlSerializable.ReadXml (XmlReader reader)
{
reader.MoveToContent ();
reader.ReadStartElement (); // <DataSet>
@@ -853,16 +888,16 @@ namespace System.Data {
ReadXmlSchema (reader);
reader.MoveToContent ();
- ReadXml(reader, XmlReadMode.IgnoreSchema);
+ ReadXml (reader, XmlReadMode.IgnoreSchema);
reader.MoveToContent ();
reader.ReadEndElement (); // </DataSet>
}
- void IXmlSerializable.WriteXml(XmlWriter writer)
+ void IXmlSerializable.WriteXml (XmlWriter writer)
{
DoWriteXmlSchema (writer);
- WriteXml(writer, XmlWriteMode.IgnoreSchema, true);
+ WriteXml (writer, XmlWriteMode.IgnoreSchema, true);
}
protected virtual bool ShouldSerializeRelations ()
@@ -893,7 +928,7 @@ namespace System.Data {
protected internal virtual void OnMergeFailed (MergeFailedEventArgs e)
{
if (MergeFailed != null)
- MergeFailed(this, e);
+ MergeFailed (this, e);
}
[MonoTODO]
@@ -904,7 +939,7 @@ namespace System.Data {
#region Private Xml Serialisation
- private string WriteObjectXml( object o ) {
+ private string WriteObjectXml (object o) {
switch (Type.GetTypeCode (o.GetType ())) {
case TypeCode.Boolean:
return XmlConvert.ToString ((Boolean) o);
@@ -937,17 +972,17 @@ namespace System.Data {
}
if (o is TimeSpan) return XmlConvert.ToString ((TimeSpan) o);
if (o is Guid) return XmlConvert.ToString ((Guid) o);
- return o.ToString();
+ return o.ToString ();
}
- private void WriteTable( XmlWriter writer, DataTable table, XmlWriteMode mode )
+ private void WriteTable (XmlWriter writer, DataTable table, XmlWriteMode mode)
{
DataRow[] rows = new DataRow [table.Rows.Count];
table.Rows.CopyTo (rows, 0);
WriteTable (writer, rows, mode);
}
- private void WriteTable( XmlWriter writer, DataRow[] rows, XmlWriteMode mode )
+ private void WriteTable (XmlWriter writer, DataRow[] rows, XmlWriteMode mode)
{
//The columns can be attributes, hidden, elements, or simple content
//There can be 0-1 simple content cols or 0-* elements
@@ -957,9 +992,9 @@ namespace System.Data {
if (rows.Length == 0) return;
DataTable table = rows[0].Table;
- SplitColumns( table, out atts, out elements, out simple );
+ SplitColumns (table, out atts, out elements, out simple);
- foreach( DataRow row in rows )
+ foreach (DataRow row in rows)
{
//sort out the namespacing
string nspc = table.Namespace.Length > 0 ? table.Namespace : Namespace;
@@ -980,20 +1015,20 @@ namespace System.Data {
continue;
}
- WriteStartElement( writer, mode, nspc, table.Prefix, table.TableName );
+ WriteStartElement (writer, mode, nspc, table.Prefix, table.TableName);
- foreach( DataColumn col in atts )
+ foreach (DataColumn col in atts)
{
- WriteAttributeString( writer, mode, col.Namespace, col.Prefix, col.ColumnName, row[col].ToString() );
+ WriteAttributeString (writer, mode, col.Namespace, col.Prefix, col.ColumnName, row[col].ToString ());
}
- if( simple != null )
+ if (simple != null)
{
- writer.WriteString( WriteObjectXml(row[simple]) );
+ writer.WriteString (WriteObjectXml (row[simple]));
}
else
{
- foreach( DataColumn col in elements )
+ foreach (DataColumn col in elements)
{
string colnspc = nspc;
object rowObject = row [col];
@@ -1001,76 +1036,76 @@ namespace System.Data {
if (rowObject == null || rowObject == DBNull.Value)
continue;
- if( col.Namespace != null )
+ if (col.Namespace != null)
{
colnspc = col.Namespace;
}
//TODO check if I can get away with write element string
- WriteStartElement( writer, mode, colnspc, col.Prefix, col.ColumnName );
- writer.WriteString( WriteObjectXml(rowObject) );
- writer.WriteEndElement();
+ WriteStartElement (writer, mode, colnspc, col.Prefix, col.ColumnName);
+ writer.WriteString (WriteObjectXml (rowObject));
+ writer.WriteEndElement ();
}
}
foreach (DataRelation relation in table.ChildRelations) {
if (relation.Nested) {
- WriteTable (writer, row.GetChildRows(relation), mode);
+ WriteTable (writer, row.GetChildRows (relation), mode);
}
}
- writer.WriteEndElement();
+ writer.WriteEndElement ();
}
}
- private void WriteStartElement( XmlWriter writer, XmlWriteMode mode, string nspc, string prefix, string name )
+ private void WriteStartElement (XmlWriter writer, XmlWriteMode mode, string nspc, string prefix, string name)
{
- switch( mode )
+ switch ( mode)
{
case XmlWriteMode.WriteSchema:
- if( nspc == null || nspc == "" )
+ if (nspc == null || nspc == "")
{
- writer.WriteStartElement( name );
+ writer.WriteStartElement (name);
}
- else if( prefix != null )
+ else if (prefix != null)
{
- writer.WriteStartElement(prefix, name, nspc );
+ writer.WriteStartElement (prefix, name, nspc);
}
else
{
- writer.WriteStartElement( writer.LookupPrefix( nspc ), name, nspc );
+ writer.WriteStartElement (writer.LookupPrefix (nspc), name, nspc);
}
break;
case XmlWriteMode.DiffGram:
- throw new NotImplementedException();
+ throw new NotImplementedException ();
default:
- writer.WriteStartElement(name );
+ writer.WriteStartElement (name);
break;
};
}
- private void WriteAttributeString( XmlWriter writer, XmlWriteMode mode, string nspc, string prefix, string name, string stringValue )
+ private void WriteAttributeString (XmlWriter writer, XmlWriteMode mode, string nspc, string prefix, string name, string stringValue)
{
- switch( mode )
+ switch ( mode)
{
case XmlWriteMode.WriteSchema:
- writer.WriteAttributeString(prefix, name, nspc );
+ writer.WriteAttributeString (prefix, name, nspc);
break;
case XmlWriteMode.DiffGram:
- throw new NotImplementedException();
+ throw new NotImplementedException ();
default:
- writer.WriteAttributeString(name, stringValue );
+ writer.WriteAttributeString (name, stringValue);
break;
};
}
- XmlSchema IXmlSerializable.GetSchema()
+ XmlSchema IXmlSerializable.GetSchema ()
{
return BuildSchema ();
}
- XmlSchema BuildSchema()
+ XmlSchema BuildSchema ()
{
XmlSchema schema = new XmlSchema ();
schema.AttributeFormDefault = XmlSchemaForm.Qualified;
@@ -1099,19 +1134,19 @@ namespace System.Data {
//Write out schema for each table in order, providing it is not
//part of another table structure via a nested parent relationship
- foreach( DataTable table in Tables )
+ foreach (DataTable table in Tables)
{
bool isTopLevel = true;
- foreach( DataRelation rel in table.ParentRelations )
+ foreach (DataRelation rel in table.ParentRelations)
{
- if( rel.Nested )
+ if (rel.Nested)
{
isTopLevel = false;
break;
}
}
- if( isTopLevel )
+ if (isTopLevel)
{
choice.Items.Add (GetTableSchema (doc, table));
}
@@ -1137,7 +1172,7 @@ namespace System.Data {
elem.SchemaType = complex;
//TODO - what about the simple content?
- if( elements.Count == 0 )
+ if (elements.Count == 0)
{
}
else
@@ -1147,7 +1182,7 @@ namespace System.Data {
XmlSchemaSequence seq = new XmlSchemaSequence ();
complex.Particle = seq;
- foreach( DataColumn col in elements )
+ foreach (DataColumn col in elements)
{
//<xs:element name=ColumnName type=MappedType Ordinal=index>
XmlSchemaElement colElem = new XmlSchemaElement ();
@@ -1166,15 +1201,15 @@ namespace System.Data {
colElem.SchemaTypeName = MapType (col.DataType);
- if( col.AllowDBNull )
+ if (col.AllowDBNull)
{
colElem.MinOccurs = 0;
}
- //writer.WriteAttributeString( XmlConstants.MsdataPrefix,
- // XmlConstants.Ordinal,
- // XmlConstants.MsdataNamespace,
- // col.Ordinal.ToString() );
+ //writer.WriteAttributeString (XmlConstants.MsdataPrefix,
+ // XmlConstants.Ordinal,
+ // XmlConstants.MsdataNamespace,
+ // col.Ordinal.ToString ());
// Write SimpleType if column have MaxLength
if (col.MaxLength > -1)
@@ -1187,7 +1222,7 @@ namespace System.Data {
}
//Then a list of attributes
- foreach( DataColumn col in atts )
+ foreach (DataColumn col in atts)
{
//<xs:attribute name=col.ColumnName form="unqualified" type=MappedType/>
XmlSchemaAttribute att = new XmlSchemaAttribute ();
@@ -1216,7 +1251,7 @@ namespace System.Data {
return simple;
}
- private void DoWriteXmlSchema( XmlWriter writer )
+ private void DoWriteXmlSchema (XmlWriter writer)
{
GetSchemaSerializable ().Write (writer);
}
@@ -1225,32 +1260,31 @@ namespace System.Data {
/// Helper function to split columns into attributes elements and simple
/// content
/// </summary>
- private void SplitColumns( DataTable table,
- out ArrayList atts,
- out ArrayList elements,
- out DataColumn simple)
+ private void SplitColumns (DataTable table,
+ out ArrayList atts,
+ out ArrayList elements,
+ out DataColumn simple)
{
//The columns can be attributes, hidden, elements, or simple content
//There can be 0-1 simple content cols or 0-* elements
- atts = new System.Collections.ArrayList();
- elements = new System.Collections.ArrayList();
+ atts = new System.Collections.ArrayList ();
+ elements = new System.Collections.ArrayList ();
simple = null;
//Sort out the columns
- foreach( DataColumn col in table.Columns )
- {
- switch( col.ColumnMapping )
+ foreach (DataColumn col in table.Columns) {
+ switch (col.ColumnMapping)
{
case MappingType.Attribute:
- atts.Add( col );
+ atts.Add (col);
break;
case MappingType.Element:
- elements.Add( col );
+ elements.Add (col);
break;
case MappingType.SimpleContent:
- if( simple != null )
+ if (simple != null)
{
- throw new System.InvalidOperationException( "There may only be one simple content element" );
+ throw new System.InvalidOperationException ("There may only be one simple content element");
}
simple = col;
break;
@@ -1282,11 +1316,16 @@ namespace System.Data {
case TypeCode.UInt64: return XmlConstants.QnUnsignedLong;
}
- if (typeof (TimeSpan) == type) return XmlConstants.QnDuration;
- else if (typeof (System.Uri) == type) return XmlConstants.QnUri;
- else if (typeof (byte[]) == type) return XmlConstants.QnBase64Binary;
- else if (typeof (XmlQualifiedName) == type) return XmlConstants.QnXmlQualifiedName;
- else return XmlConstants.QnString;
+ if (typeof (TimeSpan) == type)
+ return XmlConstants.QnDuration;
+ else if (typeof (System.Uri) == type)
+ return XmlConstants.QnUri;
+ else if (typeof (byte[]) == type)
+ return XmlConstants.QnBase64Binary;
+ else if (typeof (XmlQualifiedName) == type)
+ return XmlConstants.QnXmlQualifiedName;
+ else
+ return XmlConstants.QnString;
}
#endregion //Private Xml Serialisation
diff --git a/mcs/class/System.Data/System.Data/DataTable.cs b/mcs/class/System.Data/System.Data/DataTable.cs
index 40c82a42902..f12264468a5 100644
--- a/mcs/class/System.Data/System.Data/DataTable.cs
+++ b/mcs/class/System.Data/System.Data/DataTable.cs
@@ -11,7 +11,7 @@
//
// (C) Chris Podurgiel
// (C) Ximian, Inc 2002
-// Copyright (C) Tim Coleman, 2002
+// Copyright (C) Tim Coleman, 2002-2003
// Copyright (C) Daniel Morgan, 2002-2003
//
@@ -19,7 +19,9 @@ using System;
using System.Collections;
using System.ComponentModel;
using System.Globalization;
+using System.IO;
using System.Runtime.Serialization;
+using System.Xml;
namespace System.Data {
//[Designer]
@@ -109,6 +111,14 @@ namespace System.Data {
//
}
+#if NET_1_2
+ public DataTable (string tableName, string tbNamespace)
+ : this (tableName)
+ {
+ _nameSpace = tbNamespace;
+ }
+#endif
+
/// <summary>
/// Indicates whether string comparisons within the table are case-sensitive.
/// </summary>
@@ -722,6 +732,14 @@ namespace System.Data {
return copyTable;
}
+#if NET_1_2
+ [MonoTODO]
+ public DataTableReader GetDataReader ()
+ {
+ throw new NotImplementedException ();
+ }
+#endif
+
/// <summary>
/// Gets an array of DataRow objects that contain errors.
/// </summary>
@@ -789,6 +807,20 @@ namespace System.Data {
{
}
+#if NET_1_2
+ [MonoTODO]
+ public void Load (IDataReader reader)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void Load (IDataReader reader, LoadOption loadOption)
+ {
+ throw new NotImplementedException ();
+ }
+#endif
+
/// <summary>
/// Finds and updates a specific row. If no matching row
/// is found, a new row is created using the given values.
@@ -831,6 +863,32 @@ namespace System.Data {
return row;
}
+#if NET_1_2
+ [MonoTODO]
+ public DataRow LoadDataRow (object[] values, LoadOption loadOption)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void Merge (DataTable table)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void Merge (DataTable table, bool preserveChanges)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void Merge (DataTable table, bool preserveChanges, MissingSchemaAction missingSchemaAction)
+ {
+ throw new NotImplementedException ();
+ }
+#endif
+
/// <summary>
/// Creates a new DataRow with the same schema as the table.
/// </summary>
@@ -855,7 +913,38 @@ namespace System.Data {
{
return new DataRow (builder);
}
-
+
+#if NET_1_2
+ [MonoTODO]
+ XmlReadMode ReadXml (Stream stream)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void ReadXmlSchema (Stream stream)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void ReadXmlSchema (TextReader reader)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void ReadXmlSchema (string fileName)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void ReadXmlSchema (XmlReader reader)
+ {
+ throw new NotImplementedException ();
+ }
+#endif
/// <summary>
/// Rolls back all changes that have been made to the
@@ -1005,6 +1094,79 @@ namespace System.Data {
return retVal;
}
+#if NET_1_2
+ [MonoTODO]
+ public void WriteXml (Stream stream)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void WriteXml (TextWriter writer)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void WriteXml (XmlWriter writer)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void WriteXml (string fileName)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void WriteXml (Stream stream, XmlWriteMode mode)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void WriteXml (TextWriter writer, XmlWriteMode mode)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void WriteXml (XmlWriter writer, XmlWriteMode mode)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void WriteXml (string fileName, XmlWriteMode mode)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void WriteXmlSchema (Stream stream)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void WriteXmlSchema (TextWriter writer)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void WriteXmlSchema (XmlWriter writer)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void WriteXmlSchema (string fileName)
+ {
+ throw new NotImplementedException ();
+ }
+#endif
#region Events /////////////////
diff --git a/mcs/class/System.Data/System.Data/DataTableCollection.cs b/mcs/class/System.Data/System.Data/DataTableCollection.cs
index 0cf472d4b99..b4ff6191ee5 100644
--- a/mcs/class/System.Data/System.Data/DataTableCollection.cs
+++ b/mcs/class/System.Data/System.Data/DataTableCollection.cs
@@ -49,6 +49,13 @@ namespace System.Data {
}
}
+#if NET_1_2
+ [MonoTODO]
+ public DataTable this [string name, string tbNamespace] {
+ get { throw new NotImplementedException (); }
+ }
+#endif
+
protected override ArrayList List {
get { return list; }
}
@@ -96,6 +103,15 @@ namespace System.Data {
return table;
}
+#if NET_1_2
+ public virtual DataTable Add (string name, string tbNamespace)
+ {
+ DataTable table = new DataTable (name, tbNamespace);
+ this.Add (table);
+ return table;
+ }
+#endif
+
public void AddRange (DataTable[] tables)
{
foreach (DataTable table in tables)
diff --git a/mcs/class/System.Data/System.Data/DataTableReader.cs b/mcs/class/System.Data/System.Data/DataTableReader.cs
new file mode 100644
index 00000000000..12d2bcb0394
--- /dev/null
+++ b/mcs/class/System.Data/System.Data/DataTableReader.cs
@@ -0,0 +1,266 @@
+//
+// System.Data.DataTableReader.cs
+//
+// Author:
+// Tim Coleman (tim@timcoleman.com)
+//
+// Copyright (C) Tim Coleman, 2003
+//
+
+#if NET_1_2
+
+using System.Collections;
+using System.Data.Common;
+
+namespace System.Data {
+ public sealed class DataTableReader : DbDataReader
+ {
+ bool closed;
+ DataTable[] dataTables;
+ int index;
+
+ #region Constructors
+
+ [MonoTODO]
+ public DataTableReader (DataTable dt)
+ : this (new DataTable[] {dt})
+ {
+ }
+
+ [MonoTODO]
+ public DataTableReader (DataTable[] dataTables)
+ {
+ this.dataTables = dataTables;
+ closed = false;
+ index = 0;
+ }
+
+ #endregion // Constructors
+
+ #region Properties
+
+ public override int Depth {
+ get { return 0; }
+ }
+
+ public override int FieldCount {
+ get { return dataTables [index].Columns.Count; }
+ }
+
+ public override bool HasRows {
+ get { return dataTables [index].Rows.Count > 0; }
+ }
+
+ public override bool IsClosed {
+ get { return closed; }
+ }
+
+ [MonoTODO]
+ public override object this [int index] {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public override object this [string name] {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public override int RecordsAffected {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public override int VisibleFieldCount {
+ get { throw new NotImplementedException (); }
+ }
+
+ #endregion // Properties
+
+ #region Methods
+
+ [MonoTODO]
+ public override void Close ()
+ {
+ closed = true;
+ }
+
+ [MonoTODO]
+ public override void Dispose ()
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public override bool GetBoolean (int i)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public override byte GetByte (int i)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public override long GetBytes (int i, long dataIndex, byte[] buffer, int bufferIndex, int length)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public override char GetChar (int i)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public override long GetChars (int i, long dataIndex, char[] buffer, int bufferIndex, int length)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public override string GetDataTypeName (int i)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public override DateTime GetDateTime (int i)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public override decimal GetDecimal (int i)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public override double GetDouble (int i)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public override IEnumerator GetEnumerator ()
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public override Type GetFieldProviderSpecificType (int i)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public override Type GetFieldType (int i)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public override float GetFloat (int i)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public override Guid GetGuid (int i)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public override short GetInt16 (int i)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public override int GetInt32 (int i)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public override long GetInt64 (int i)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public override string GetName (int i)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public override int GetOrdinal (string name)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public override object GetProviderSpecificValue (int i)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public override int GetProviderSpecificValues (object[] values)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public override DataTable GetSchemaTable ()
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public override string GetString (int i)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public override object GetValue (int i)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public override int GetValues (object[] values)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public override bool IsDBNull (int i)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public override bool NextResult ()
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public override bool Read ()
+ {
+ throw new NotImplementedException ();
+ }
+
+ #endregion // Methods
+ }
+}
+
+#endif // NET_1_2
diff --git a/mcs/class/System.Data/System.Data/DataView.cs b/mcs/class/System.Data/System.Data/DataView.cs
index b28e45bf6fd..952d8785c6b 100644
--- a/mcs/class/System.Data/System.Data/DataView.cs
+++ b/mcs/class/System.Data/System.Data/DataView.cs
@@ -7,7 +7,7 @@
//
// Copyright (C) Daniel Morgan, 2002, 2003
// (C) Ximian, Inc 2002
-// Copyright (C) Tim Coleman, 2002
+// Copyright (C) Tim Coleman, 2002-2003
//
using System;
@@ -301,6 +301,14 @@ namespace System.Data
throw new NotImplementedException ();
}
+#if NET_1_2
+ [MonoTODO]
+ public virtual bool Equals (DataView dv)
+ {
+ throw new NotImplementedException ();
+ }
+#endif
+
[MonoTODO]
public void EndInit()
{
@@ -444,6 +452,20 @@ namespace System.Data
Open ();
}
+#if NET_1_2
+ [MonoTODO]
+ public DataTable ToTable ()
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public DataTable ToTable (bool isDistinct, string[] columnNames)
+ {
+ throw new NotImplementedException ();
+ }
+#endif
+
// internal use by Mono
protected virtual void UpdateIndex ()
{
diff --git a/mcs/class/System.Data/System.Data/DbMetaData.cs b/mcs/class/System.Data/System.Data/DbMetaData.cs
new file mode 100644
index 00000000000..2a15b599629
--- /dev/null
+++ b/mcs/class/System.Data/System.Data/DbMetaData.cs
@@ -0,0 +1,64 @@
+//
+// System.Data.DbMetaData.cs
+//
+// Author:
+// Tim Coleman (tim@timcoleman.com)
+//
+// Copyright (C) Tim Coleman, 2003
+//
+
+#if NET_1_2
+
+namespace System.Data {
+ public class DbMetaData
+ {
+ #region Fields
+
+ DbType dbType;
+ bool isNullable;
+ long maxLength;
+ string name;
+
+ #endregion // Fields
+
+ #region Constructors
+
+ [MonoTODO]
+ public DbMetaData ()
+ {
+ }
+
+ [MonoTODO]
+ public DbMetaData (DbMetaData source)
+ {
+ }
+
+ #endregion // Constructors
+
+ #region Properties
+
+ public virtual DbType DbType {
+ get { return dbType; }
+ set { dbType = value; }
+ }
+
+ public virtual bool IsNullable {
+ get { return isNullable; }
+ set { isNullable = value; }
+ }
+
+ public virtual long MaxLength {
+ get { return maxLength; }
+ set { maxLength = value; }
+ }
+
+ public string Name {
+ get { return name; }
+ set { name = value; }
+ }
+
+ #endregion // Properties
+ }
+}
+
+#endif // NET_1_2
diff --git a/mcs/class/System.Data/System.Data/FillOptions.cs b/mcs/class/System.Data/System.Data/FillOptions.cs
new file mode 100644
index 00000000000..7263a527840
--- /dev/null
+++ b/mcs/class/System.Data/System.Data/FillOptions.cs
@@ -0,0 +1,22 @@
+//
+// System.Data.FillOptions.cs
+//
+// Author:
+// Tim Coleman (tim@timcoleman.com)
+//
+// Copyright (C) Tim Coleman, 2003
+//
+
+#if NET_1_2
+
+namespace System.Data {
+ public enum FillOptions
+ {
+ None,
+ FillChildren,
+ FillExtendedSchema,
+ FillWithoutExtendedMetaData
+ }
+}
+
+#endif // NET_1_2
diff --git a/mcs/class/System.Data/System.Data/ForeignKeyConstraint.cs b/mcs/class/System.Data/System.Data/ForeignKeyConstraint.cs
index 6ac307e7f67..b7e3b8b1d1d 100644
--- a/mcs/class/System.Data/System.Data/ForeignKeyConstraint.cs
+++ b/mcs/class/System.Data/System.Data/ForeignKeyConstraint.cs
@@ -68,6 +68,14 @@ namespace System.Data {
{
}
+#if NET_1_2
+ [MonoTODO]
+ public ForeignKeyConstraint (string constraintName, string parentTableName, string parentTableNamespace, string[] parentColumnNames, string[] childColumnNames, AcceptRejectRule acceptRejectRule, Rule deleteRule, Rule updateRule)
+ {
+ throw new NotImplementedException ();
+ }
+#endif
+
private void _foreignKeyConstraint(string constraintName, DataColumn[] parentColumns,
DataColumn[] childColumns)
{
diff --git a/mcs/class/System.Data/System.Data/IDataReader2.cs b/mcs/class/System.Data/System.Data/IDataReader2.cs
new file mode 100644
index 00000000000..f40a90f7525
--- /dev/null
+++ b/mcs/class/System.Data/System.Data/IDataReader2.cs
@@ -0,0 +1,23 @@
+//
+// System.Data.IDataReader2.cs
+//
+// Author:
+// Tim Coleman (tim@timcoleman.com)
+//
+// Copyright (C) Tim Coleman, 2003
+//
+
+#if NET_1_2
+
+namespace System.Data {
+ public interface IDataReader2
+ {
+ #region Properties
+
+ bool HasRows { get; }
+
+ #endregion // Properties
+ }
+}
+
+#endif
diff --git a/mcs/class/System.Data/System.Data/IDataRecord2.cs b/mcs/class/System.Data/System.Data/IDataRecord2.cs
new file mode 100644
index 00000000000..888d804280b
--- /dev/null
+++ b/mcs/class/System.Data/System.Data/IDataRecord2.cs
@@ -0,0 +1,31 @@
+//
+// System.Data.IDataReader2.cs
+//
+// Author:
+// Tim Coleman (tim@timcoleman.com)
+//
+// Copyright (C) Tim Coleman, 2003
+//
+
+#if NET_1_2
+
+namespace System.Data {
+ public interface IDataRecord2
+ {
+ #region Properties
+
+ int VisibleFieldCount { get; }
+
+ #endregion // Properties
+
+ #region Methods
+
+ Type GetFieldProviderSpecificType (int i);
+ object GetProviderSpecificValue (int i);
+ int GetProviderSpecificValues (object[] values);
+
+ #endregion // Methods
+ }
+}
+
+#endif
diff --git a/mcs/class/System.Data/System.Data/IDataSources.cs b/mcs/class/System.Data/System.Data/IDataSources.cs
new file mode 100644
index 00000000000..4cc9fca9f86
--- /dev/null
+++ b/mcs/class/System.Data/System.Data/IDataSources.cs
@@ -0,0 +1,34 @@
+//
+// System.Data.IDataSources.cs
+//
+// Author:
+// Tim Coleman (tim@timcoleman.com)
+//
+// Copyright (C) Tim Coleman, 2003
+//
+
+#if NET_1_2
+
+namespace System.Data {
+ public interface IDataSources
+ {
+ #region Properties
+
+ int Count { get; }
+ object this [string name] { get; }
+
+ #endregion // Properties
+
+ #region Methods
+
+ void Add (string name, IDbConnection connection);
+ void Add (string name, IDbTransaction transaction);
+ void Clear ();
+ bool Contains (string name);
+ void Remove (string name);
+
+ #endregion // Methods
+ }
+}
+
+#endif // NET_1_2
diff --git a/mcs/class/System.Data/System.Data/IDataUpdatableRecord.cs b/mcs/class/System.Data/System.Data/IDataUpdatableRecord.cs
new file mode 100644
index 00000000000..1b3767424e5
--- /dev/null
+++ b/mcs/class/System.Data/System.Data/IDataUpdatableRecord.cs
@@ -0,0 +1,29 @@
+//
+// System.Data.IDataUpdatableRecord.cs
+//
+// Author:
+// Tim Coleman (tim@timcoleman.com)
+//
+// Copyright (C) Tim Coleman, 2003
+//
+
+#if NET_1_2
+
+namespace System.Data {
+ public interface IDataUpdatableRecord
+ {
+ #region Properties
+
+ bool Updatable { get; }
+
+ #endregion // Properties
+
+ #region Methods
+
+ int SetValues (object[] values);
+
+ #endregion // Methods
+ }
+}
+
+#endif // NET_1_2
diff --git a/mcs/class/System.Data/System.Data/IDbAsyncCommand.cs b/mcs/class/System.Data/System.Data/IDbAsyncCommand.cs
new file mode 100644
index 00000000000..2e8369c2a1b
--- /dev/null
+++ b/mcs/class/System.Data/System.Data/IDbAsyncCommand.cs
@@ -0,0 +1,26 @@
+//
+// System.Data.IDbAsyncCommand.cs
+//
+// Author:
+// Tim Coleman (tim@timcoleman.com)
+//
+// Copyright (C) Tim Coleman, 2003
+//
+
+#if NET_1_2
+
+namespace System.Data {
+ public interface IDbAsyncCommand
+ {
+ #region Methods
+
+ IAsyncResult BeginExecuteNonQuery (AsyncCallback callback, object stateObject);
+ IAsyncResult BeginExecuteReader (AsyncCallback callback, object stateObject, CommandBehavior behavior);
+ int EndExecuteNonQuery (IAsyncResult result);
+ IDataReader EndExecuteReader (IAsyncResult result);
+
+ #endregion // Methods
+ }
+}
+
+#endif // NET_1_2
diff --git a/mcs/class/System.Data/System.Data/IDbAsyncConnection.cs b/mcs/class/System.Data/System.Data/IDbAsyncConnection.cs
new file mode 100644
index 00000000000..6dc19661809
--- /dev/null
+++ b/mcs/class/System.Data/System.Data/IDbAsyncConnection.cs
@@ -0,0 +1,24 @@
+//
+// System.Data.IDbAsyncConnection.cs
+//
+// Author:
+// Tim Coleman (tim@timcoleman.com)
+//
+// Copyright (C) Tim Coleman, 2003
+//
+
+#if NET_1_2
+
+namespace System.Data {
+ public interface IDbAsyncConnection
+ {
+ #region Methods
+
+ IAsyncResult BeginOpen (AsyncCallback callback, object stateObject);
+ void EndOpen (IAsyncResult result);
+
+ #endregion // Methods
+ }
+}
+
+#endif // NET_1_2
diff --git a/mcs/class/System.Data/System.Data/IDbExecutionContext.cs b/mcs/class/System.Data/System.Data/IDbExecutionContext.cs
new file mode 100644
index 00000000000..2144eda3090
--- /dev/null
+++ b/mcs/class/System.Data/System.Data/IDbExecutionContext.cs
@@ -0,0 +1,44 @@
+//
+// System.Data.IDbExecutionContext.cs
+//
+// Author:
+// Tim Coleman (tim@timcoleman.com)
+//
+// Copyright (C) Tim Coleman, 2003
+//
+
+#if NET_1_2
+
+namespace System.Data {
+ public interface IDbExecutionContext
+ {
+ #region Properties
+
+ IDbConnection Connection { get; set; }
+ int ConnectionTimeOut { get; set; }
+ IDbTransaction Transaction { get; set; }
+
+ #endregion // Properties
+
+ #region Methods
+
+ IAsyncResult BeginExecuteNonQuery (AsyncCallback callback, object stateObject);
+ IAsyncResult BeginExecuteReader (AsyncCallback callback, object stateObject, CommandBehavior behavior);
+ IAsyncResult BeginExecuteScalar (AsyncCallback callback, object stateObject);
+
+ void Cancel ();
+
+ int EndExecuteNonQuery (IAsyncResult result);
+ IDataReader EndExecuteReader (IAsyncResult result);
+ object EndExecuteScalar (IAsyncResult result);
+
+ int ExecuteNonQuery ();
+ IDataReader ExecuteReader ();
+ IDataReader ExecuteReader (CommandBehavior behavior);
+ object ExecuteScalar ();
+
+ #endregion // Methods
+ }
+}
+
+#endif // NET_1_2
diff --git a/mcs/class/System.Data/System.Data/IGetTypedData.cs b/mcs/class/System.Data/System.Data/IGetTypedData.cs
new file mode 100644
index 00000000000..0ca85b79465
--- /dev/null
+++ b/mcs/class/System.Data/System.Data/IGetTypedData.cs
@@ -0,0 +1,40 @@
+//
+// System.Data.IGetTypedData.cs
+//
+// Author:
+// Tim Coleman (tim@timcoleman.com)
+//
+// Copyright (C) Tim Coleman, 2003
+//
+
+#if NET_1_2
+
+namespace System.Data {
+ public interface IGetTypedData
+ {
+ #region Methods
+
+ bool GetBoolean (int i);
+ byte GetByte (int i);
+ long GetBytes (int i, long fieldOffset, byte[] buffer, int bufferOffset, int length);
+ char GetChar (int i);
+ long GetChars (int i, long fieldOffset, char[] buffer, int bufferOffset, int length);
+ DateTime GetDateTime (int i);
+ decimal GetDecimal (int i);
+ double GetDouble (int i);
+ float GetFloat (int i);
+ Guid GetGuid (int i);
+ short GetInt16 (int i);
+ int GetInt32 (int i);
+ long GetInt64 (int i);
+ object GetObjectRef (int i);
+ string GetString (int i);
+ object GetValue (int i);
+ bool IsDBNull (int i);
+ bool IsSetAsDefault (int i);
+
+ #endregion // Methods
+ }
+}
+
+#endif // NET_1_2
diff --git a/mcs/class/System.Data/System.Data/ISetTypedData.cs b/mcs/class/System.Data/System.Data/ISetTypedData.cs
new file mode 100644
index 00000000000..87bd35386ad
--- /dev/null
+++ b/mcs/class/System.Data/System.Data/ISetTypedData.cs
@@ -0,0 +1,38 @@
+//
+// System.Data.ISetTypedData.cs
+//
+// Author:
+// Tim Coleman (tim@timcoleman.com)
+//
+// Copyright (C) Tim Coleman, 2003
+//
+
+#if NET_1_2
+
+namespace System.Data {
+ public interface ISetTypedData
+ {
+ #region Methods
+
+ void SetBoolean (int i, bool value);
+ void SetByte (int i, byte value);
+ void SetBytes (int i, long fieldOffset, byte[] buffer, int bufferOffset, int length);
+ void SetChar (int i, char value);
+ void SetChars (int i, long fieldOffset, char[] buffer, int bufferOffset, int length);
+ void SetDateTime (int i, DateTime value);
+ void SetDecimal (int i, decimal value);
+ void SetDouble (int i, double value);
+ void SetFloat (int i, float value);
+ void SetGuid (int i, Guid value);
+ void SetInt16 (int i, short value);
+ void SetInt32 (int i, int value);
+ void SetInt64 (int i, long value);
+ void SetObjectRef (int i, object o);
+ void SetString (int i, string value);
+ void SetValue (int i, object value);
+
+ #endregion // Methods
+ }
+}
+
+#endif // NET_1_2
diff --git a/mcs/class/System.Data/System.Data/LoadOption.cs b/mcs/class/System.Data/System.Data/LoadOption.cs
new file mode 100644
index 00000000000..c275b70e10c
--- /dev/null
+++ b/mcs/class/System.Data/System.Data/LoadOption.cs
@@ -0,0 +1,21 @@
+//
+// System.Data.LoadOption.cs
+//
+// Author:
+// Tim Coleman (tim@timcoleman.com)
+//
+// Copyright (C) Tim Coleman, 2003
+//
+
+#if NET_1_2
+
+namespace System.Data {
+ public enum LoadOption
+ {
+ OverwriteRow,
+ PreserveCurrentValues,
+ UpdateCurrentValues
+ }
+}
+
+#endif // NET_1_2
diff --git a/mcs/class/System.Data/System.Data/OperationAbortedException.cs b/mcs/class/System.Data/System.Data/OperationAbortedException.cs
new file mode 100644
index 00000000000..4dee0ee99ac
--- /dev/null
+++ b/mcs/class/System.Data/System.Data/OperationAbortedException.cs
@@ -0,0 +1,44 @@
+//
+// System.Data.OperationAbortedException.cs
+//
+// Author:
+// Tim Coleman (tim@timcoleman.com)
+//
+// Copyright (C) Tim Coleman, 2003
+//
+
+#if NET_1_2
+
+using System.Globalization;
+using System.Runtime.Serialization;
+
+namespace System.Data {
+ public class OperationAbortedException : SystemException
+ {
+ #region Constructors
+
+ public OperationAbortedException ()
+ : base (Locale.GetText ("An OperationAbortedException has occurred."))
+ {
+ }
+
+ public OperationAbortedException (string s)
+ : base (s)
+ {
+ }
+
+ public OperationAbortedException (string s, Exception innerException)
+ : base (s, innerException)
+ {
+ }
+
+ public OperationAbortedException (SerializationInfo info, StreamingContext context)
+ : base (info, context)
+ {
+ }
+
+ #endregion // Constructors
+ }
+}
+
+#endif // NET_1_2
diff --git a/mcs/class/System.Data/System.Data/ResultSetOptions.cs b/mcs/class/System.Data/System.Data/ResultSetOptions.cs
new file mode 100644
index 00000000000..a7c0056a7bb
--- /dev/null
+++ b/mcs/class/System.Data/System.Data/ResultSetOptions.cs
@@ -0,0 +1,23 @@
+//
+// System.Data.ResultSetOptions.cs
+//
+// Author:
+// Tim Coleman (tim@timcoleman.com)
+//
+// Copyright (C) Tim Coleman, 2003
+//
+
+#if NET_1_2
+
+namespace System.Data {
+ public enum ResultSetOptions
+ {
+ None,
+ Updatable,
+ Scrollable,
+ Sensitive,
+ Insensitive
+ }
+}
+
+#endif // NET_1_2
diff --git a/mcs/class/System.Data/System.Data/ResultSetSensitivity.cs b/mcs/class/System.Data/System.Data/ResultSetSensitivity.cs
new file mode 100644
index 00000000000..c2478f75dd3
--- /dev/null
+++ b/mcs/class/System.Data/System.Data/ResultSetSensitivity.cs
@@ -0,0 +1,21 @@
+//
+// System.Data.ResultSetSensitivity.cs
+//
+// Author:
+// Tim Coleman (tim@timcoleman.com)
+//
+// Copyright (C) Tim Coleman, 2003
+//
+
+#if NET_1_2
+
+namespace System.Data {
+ public enum ResultSetSensitivity
+ {
+ Asensitive,
+ Insensitive,
+ Sensitive
+ }
+}
+
+#endif // NET_1_2
diff --git a/mcs/class/System.Data/System.Data/StatementCompletedEventArgs.cs b/mcs/class/System.Data/System.Data/StatementCompletedEventArgs.cs
new file mode 100644
index 00000000000..6c7b2148fba
--- /dev/null
+++ b/mcs/class/System.Data/System.Data/StatementCompletedEventArgs.cs
@@ -0,0 +1,40 @@
+//
+// System.Data.StatementCompletedEventArgs.cs
+//
+// Author:
+// Tim Coleman (tim@timcoleman.com)
+//
+// Copyright (C) Tim Coleman, 2003
+//
+
+#if NET_1_2
+
+namespace System.Data {
+ public class StatementCompletedEventArgs : EventArgs
+ {
+ #region Fields
+
+ int recordCount;
+
+ #endregion // Fields
+
+ #region Constructors
+
+ public StatementCompletedEventArgs (int recordCount)
+ {
+ this.recordCount = recordCount;
+ }
+
+ #endregion // Constructors
+
+ #region Properties
+
+ public int RecordCount {
+ get { return recordCount; }
+ }
+
+ #endregion // Properties
+ }
+}
+
+#endif // NET_1_2
diff --git a/mcs/class/System.Data/System.Data/StatementCompletedEventHandler.cs b/mcs/class/System.Data/System.Data/StatementCompletedEventHandler.cs
new file mode 100644
index 00000000000..c22631fa17e
--- /dev/null
+++ b/mcs/class/System.Data/System.Data/StatementCompletedEventHandler.cs
@@ -0,0 +1,16 @@
+//
+// System.Data.StatementCompletedEventHandler.cs
+//
+// Author:
+// Tim Coleman (tim@timcoleman.com)
+//
+// Copyright (C) Tim Coleman, 2003
+//
+
+#if NET_1_2
+
+namespace System.Data {
+ public delegate void StatementCompletedEventHandler (object sender, StatementCompletedEventArgs e);
+}
+
+#endif // NET_1_2
diff --git a/mcs/class/System.Data/System.Data/UniqueConstraint.cs b/mcs/class/System.Data/System.Data/UniqueConstraint.cs
index 4af1b9fffd7..88490798ab2 100644
--- a/mcs/class/System.Data/System.Data/UniqueConstraint.cs
+++ b/mcs/class/System.Data/System.Data/UniqueConstraint.cs
@@ -398,7 +398,7 @@ namespace System.Data {
}
}
if (match)
- throw new ConstraintException (String.Format ("Column '{0}' contains non-unique values", this._dataColumns[0]));
+ throw new ArgumentException (String.Format ("Column '{0}' contains non-unique values", this._dataColumns[0]));
}
}
diff --git a/mcs/class/System.Data/System.Data/UpdateOptions.cs b/mcs/class/System.Data/System.Data/UpdateOptions.cs
new file mode 100644
index 00000000000..fdd971e5c0d
--- /dev/null
+++ b/mcs/class/System.Data/System.Data/UpdateOptions.cs
@@ -0,0 +1,22 @@
+//
+// System.Data.UpdateOptions.cs
+//
+// Author:
+// Tim Coleman (tim@timcoleman.com)
+//
+// Copyright (C) Tim Coleman, 2003
+//
+
+#if NET_1_2
+
+namespace System.Data {
+ public enum UpdateOptions
+ {
+ None,
+ DoNotAcceptChanges,
+ NotTransacted,
+ UpdateChildren
+ }
+}
+
+#endif // NET_1_2
diff --git a/mcs/class/System.DirectoryServices/ChangeLog b/mcs/class/System.DirectoryServices/ChangeLog
index 04dd8ce3156..ea87b4d845f 100644
--- a/mcs/class/System.DirectoryServices/ChangeLog
+++ b/mcs/class/System.DirectoryServices/ChangeLog
@@ -4,3 +4,6 @@
2003-02-23 Rafael Teixeira <rafaelteixeirabr@hotmail.com>
* added just files enough to compile a dummy DLL for now
+
+2003-11-24 Sunil Kumar <sunilk@novell.com>
+ * Added class files implementing System.DirectoryServices namespace
diff --git a/mcs/class/System.DirectoryServices/Makefile b/mcs/class/System.DirectoryServices/Makefile
index c67728eac14..c8dcf3bc6ad 100644
--- a/mcs/class/System.DirectoryServices/Makefile
+++ b/mcs/class/System.DirectoryServices/Makefile
@@ -3,7 +3,7 @@ SUBDIRS =
include ../../build/rules.make
LIBRARY = System.DirectoryServices.dll
-LIB_MCS_FLAGS = /r:$(corlib) /r:System.dll
+LIB_MCS_FLAGS = /r:$(corlib) /r:System.dll /r:Novell.Directory.Ldap.dll
NO_TEST = yes
include ../../build/library.make
diff --git a/mcs/class/System.DirectoryServices/System.DirectoryServices.dll.sources b/mcs/class/System.DirectoryServices/System.DirectoryServices.dll.sources
index 2920d75242c..567552a60ca 100755
--- a/mcs/class/System.DirectoryServices/System.DirectoryServices.dll.sources
+++ b/mcs/class/System.DirectoryServices/System.DirectoryServices.dll.sources
@@ -1 +1,13 @@
System.DirectoryServices/AssemblyInfo.cs
+System.DirectoryServices/DirectoryEntry.cs
+System.DirectoryServices/DirectoryEntries.cs
+System.DirectoryServices/SchemaNameCollection.cs
+System.DirectoryServices/AuthenticationTypes.cs
+System.DirectoryServices/PropertyCollection.cs
+System.DirectoryServices/PropertyValueCollection.cs
+System.DirectoryServices/DirectorySearcher.cs
+System.DirectoryServices/ReferralChasingOption.cs
+System.DirectoryServices/SearchScope.cs
+System.DirectoryServices/SortDirection.cs
+System.DirectoryServices/ResultPropertyValueCollection.cs
+System.DirectoryServices/ResultPropertyCollection.cs
diff --git a/mcs/class/System.DirectoryServices/System.DirectoryServices/AssemblyInfo.cs b/mcs/class/System.DirectoryServices/System.DirectoryServices/AssemblyInfo.cs
index 177a4f0e70a..7209991e9f9 100644
--- a/mcs/class/System.DirectoryServices/System.DirectoryServices/AssemblyInfo.cs
+++ b/mcs/class/System.DirectoryServices/System.DirectoryServices/AssemblyInfo.cs
@@ -1,3 +1,26 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc., www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+using System;
using System.Reflection;
using System.Runtime.CompilerServices;
@@ -14,6 +37,7 @@ using System.Runtime.CompilerServices;
[assembly: AssemblyCopyright("")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
+[assembly: CLSCompliant(true)]
//
// Version information for an assembly consists of the following four values:
diff --git a/mcs/class/System.DirectoryServices/System.DirectoryServices/AuthenticationTypes.cs b/mcs/class/System.DirectoryServices/System.DirectoryServices/AuthenticationTypes.cs
new file mode 100644
index 00000000000..aa959448b25
--- /dev/null
+++ b/mcs/class/System.DirectoryServices/System.DirectoryServices/AuthenticationTypes.cs
@@ -0,0 +1,60 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc., www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+
+//
+// System.DirectoryServices.AuthenticationTypes.cs
+//
+// Author:
+// Sunil Kumar (sunilk@novell.com)
+//
+// (C) Novell Inc.
+//
+
+namespace System.DirectoryServices
+{
+
+ /// <summary>
+ /// Specifies the types of authentication used in
+ /// System.DirectoryServices
+ /// This enumeration has a FlagsAttribute attribute
+ /// that allows a bitwise combination of its member values.
+ /// </summary>
+ [Flags]
+ [Serializable]
+ public enum AuthenticationTypes
+ {
+ Anonymous = 16,
+ Delegation = 256,
+ Encryption = 2,
+ FastBind = 32,
+ None = 0,
+ ReadonlyServer = 4,
+ Sealing = 128,
+ Secure = 1,
+ SecureSocketsLayer = 2,
+ ServerBind = 512,
+ Signing = 64
+ }
+
+}
+
diff --git a/mcs/class/System.DirectoryServices/System.DirectoryServices/DirectoryEntries.cs b/mcs/class/System.DirectoryServices/System.DirectoryServices/DirectoryEntries.cs
new file mode 100644
index 00000000000..2f250d633d2
--- /dev/null
+++ b/mcs/class/System.DirectoryServices/System.DirectoryServices/DirectoryEntries.cs
@@ -0,0 +1,303 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc., www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+
+//
+// System.DirectoryServices.DirectoryEntries.cs
+//
+// Author:
+// Sunil Kumar (sunilk@novell.com)
+//
+// (C) Novell Inc.
+//
+
+using System.Collections;
+using Novell.Directory.Ldap;
+
+namespace System.DirectoryServices
+{
+
+ /// <summary>
+ ///Contains the children (child entries) of an entry in
+ /// a Ldap Directory
+ /// </summary>
+ public class DirectoryEntries : IEnumerable
+ {
+ private ArrayList cList;
+ private LdapConnection _Conn=null;
+ private string _Bpath=null;
+ private string _Buser=null;
+ private string _Bpass=null;
+ private string _Basedn=null;
+ protected ArrayList m_oValues=null;
+
+
+ /// <summary> Initializes the Connection and other properties.
+ ///
+ /// </summary>
+ private void InitBlock()
+ {
+ try {
+ LdapUrl lUrl=new LdapUrl(_Bpath);
+ _Conn = new LdapConnection();
+ _Conn.Connect(lUrl.Host,lUrl.Port);
+ _Conn.Bind(_Buser,_Bpass);
+ }
+ catch(LdapException ex) {
+ Console.WriteLine("Error:" + ex.LdapErrorMessage);
+ throw ex;
+ }
+ catch(Exception e) {
+ Console.WriteLine("Error:" + e.Message);
+ throw e;
+ }
+ }
+
+ internal string Basedn
+ {
+ get {
+ if( _Basedn == null) {
+// Console.WriteLine("Basepath:" + _Bpath);
+ LdapUrl lurl=new LdapUrl(_Bpath);
+ string bdn = lurl.getDN();
+ if( bdn != null)
+ _Basedn = bdn;
+ else
+ _Basedn = "";
+ }
+ return _Basedn;
+ }
+ }
+
+ /// <summary> Contains the Path of the Container under which
+ /// the entries belongs to.
+ /// </summary>
+ internal string Bpath
+ {
+ get {
+ return _Bpath;
+ }
+ set {
+ _Bpath=value;
+ }
+ }
+
+ /// <summary> Returns the connection object used to communicate with
+ /// Ldap server
+ /// </summary>
+ internal LdapConnection Conn
+ {
+ get {
+ if( _Conn == null) {
+ InitBlock();
+ }
+ return _Conn;
+ }
+ set {
+ _Conn=value;
+ }
+ }
+
+ /// <summary> Constructs a collection of all the child entries of
+ /// an entry
+ /// </summary>
+ /// <param name="path"> Path of the entry
+ /// </param>
+ /// <param name="uname"> Username to Bind as while authenticating to ldap
+ /// server</param>
+ /// <param name="passwd"> Password of the user</param>
+ internal DirectoryEntries(string path, string uname, string passwd)
+ {
+ _Bpath = path;
+ _Buser = uname;
+ _Bpass = passwd;
+ }
+
+ /// <summary> Constructs a collection of all the child entries of
+ /// a entry
+ /// </summary>
+ /// <param name="path"> Path of the entry
+ /// </param>
+ /// <param name="lc"> connection object used to connect to ldap server
+ /// </param>
+ internal DirectoryEntries(string path, LdapConnection lc)
+ {
+ _Bpath = path;
+ _Conn = lc;
+ }
+
+ public IEnumerator GetEnumerator()
+ {
+ m_oValues= new ArrayList();
+ string[] attrs={"objectClass"};
+// Console.WriteLine("BaseDN is:" + Basedn);
+ LdapSearchResults lsc= Conn.Search( Basedn,
+ LdapConnection.SCOPE_ONE,
+ "objectClass=*",
+ attrs,
+ false);
+
+ LdapUrl Burl=new LdapUrl(_Bpath);
+ string host=Burl.Host;
+ int port=Burl.Port;
+
+ while (lsc.hasMore()) {
+ LdapEntry nextEntry = null;
+ try {
+ nextEntry = lsc.next();
+ }
+ catch(LdapException e) {
+ Console.WriteLine("Error: " + e.LdapErrorMessage);
+ // Exception is thrown, go for next entry
+ continue;
+ }
+ DirectoryEntry dEntry=new DirectoryEntry(Conn);
+ string eFdn=nextEntry.DN;
+ LdapUrl curl=new LdapUrl(host,port,eFdn);
+ dEntry.Path=curl.ToString();
+ Console.WriteLine("Path:" + eFdn);
+ m_oValues.Add((DirectoryEntry) dEntry);
+ }
+ return m_oValues.GetEnumerator();
+ }
+
+ /// <summary> Creates a request to create a new entry in the container.
+ ///
+ /// </summary>
+ /// <param name="name"> RDN of the entry to be created
+ /// </param>
+ /// <param name="schemaClassName"> StructuralClassName of the entry to be
+ /// created.
+ /// </param>
+ public DirectoryEntry Add( string name,string schemaClassName)
+ {
+ DirectoryEntry ent=new DirectoryEntry(Conn);
+ LdapUrl Burl=new LdapUrl(_Bpath);
+ string eFdn=name+","+Burl.getDN();
+ LdapUrl curl=new LdapUrl(Burl.Host,Burl.Port,eFdn);
+ ent.Path=curl.ToString();
+ ent.Nflag = true;
+ ent.Properties["objectclass"].Add(schemaClassName);
+ return ent;
+ }
+
+ /// <summary>
+ /// Deletes a child DirectoryEntry from this collection
+ /// </summary>
+ /// <param name="entry">The DirectoryEntry to delete</param>
+ public void Remove( DirectoryEntry entry )
+ {
+ LdapUrl Burl=new LdapUrl(_Bpath);
+ string eFDN = entry.Name + "," + Burl.getDN();
+ Conn.Delete( eFDN);
+ }
+
+ /// <summary>
+ /// Returns the child with the specified name.
+ /// </summary>
+ /// <param name="filter">relative distinguised name of the child
+ /// </param>
+ /// <returns>Child entry with the specified name </returns>
+ public DirectoryEntry Find(string filter)
+ {
+ DirectoryEntry child=CheckEntry(filter);
+ return child;
+ }
+
+ /// <summary>
+ /// Returns the child with the specified name and of the specified type.
+ /// </summary>
+ /// <param name="filter">relative distinguised name of the child
+ /// </param>
+ /// <param name="otype"> Type of the child i.e strutcuralObjectClass
+ /// name of the child </param>
+ /// <returns>Child entry with the specified name and type</returns>
+ public DirectoryEntry Find(string filter, string otype)
+ {
+ DirectoryEntry child=CheckEntry(filter);
+
+ if( child != null) {
+ if(child.Properties["objectClass"].ContainsCaselessStringValue(otype))
+ return child;
+ else
+ throw new Exception("An unknown directory object was requested");
+ }
+ return child;
+ }
+
+ /// <summary>
+ /// Checks whether the entry with the specified Relative distinguised name
+ /// exists or not.
+ /// </summary>
+ /// <param name="rdn"> Relative distinguished name of the entry</param>
+ /// <returns>DirectoryEntry object of Entry if entry exists,
+ /// Null if entry doesn't exist </returns>
+ private DirectoryEntry CheckEntry(string rdn)
+ {
+ string Ofdn=null;
+ DirectoryEntry cEntry=null;
+
+ Ofdn=rdn+","+Basedn;
+ string[] attrs={"objectClass"};
+ try {
+ LdapSearchResults lsc= Conn.Search( Ofdn,
+ LdapConnection.SCOPE_BASE,
+ "objectClass=*",
+ attrs,
+ false);
+ while(lsc.hasMore()) {
+ LdapEntry nextEntry = null;
+ try {
+ nextEntry = lsc.next();
+ cEntry = new DirectoryEntry(Conn);
+ LdapUrl Burl=new LdapUrl(_Bpath);
+ LdapUrl curl=new LdapUrl(Burl.Host,Burl.Port,Ofdn);
+ cEntry.Path=curl.ToString();
+ }
+ catch(LdapException e) {
+ Console.WriteLine("Error: " + e.LdapErrorMessage);
+ // Exception is thrown, go for next entry
+ throw e;
+ }
+ break;
+ }
+
+ }
+ catch(LdapException le)
+ {
+ if(le.ResultCode == LdapException.NO_SUCH_OBJECT) {
+ return null;
+ }
+ else {
+ throw le;
+ }
+ }
+ catch(Exception e) {
+ throw e;
+ }
+ return cEntry;
+ }
+
+ }
+
+}
+
diff --git a/mcs/class/System.DirectoryServices/System.DirectoryServices/DirectoryEntry.cs b/mcs/class/System.DirectoryServices/System.DirectoryServices/DirectoryEntry.cs
new file mode 100644
index 00000000000..f4d0852c966
--- /dev/null
+++ b/mcs/class/System.DirectoryServices/System.DirectoryServices/DirectoryEntry.cs
@@ -0,0 +1,833 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc., www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+
+//
+// System.DirectoryServices.DirectoryEntry.cs
+//
+// Author:
+// Sunil Kumar (sunilk@novell.com)
+//
+// (C) Novell Inc.
+//
+
+using System.ComponentModel;
+using Novell.Directory.Ldap;
+using Novell.Directory.Ldap.Utilclass;
+
+namespace System.DirectoryServices
+{
+
+ /// <summary>
+ ///Encapsulates a node or object in the Ldap Directory hierarchy.
+ /// </summary>
+ public class DirectoryEntry : Component
+ {
+
+ private LdapConnection _conn = null;
+ private AuthenticationTypes _AuthenticationType=AuthenticationTypes.None;
+ private DirectoryEntries _Children;
+ private string _Fdn = null;
+ private string _Path="";
+ private string _Name=null;
+ private DirectoryEntry _Parent=null;
+ private string _Username="";
+ private string _Password="";
+ private string _Nativeguid;
+ private PropertyCollection _Properties = null;
+ private string _SchemaClassName=null;
+ private bool _Nflag = false;
+
+ /// <summary>
+ /// Returns entry's Fully distinguished name.
+ /// </summary>
+ internal string Fdn
+ {
+ get {
+ if (_Fdn == null) {
+ LdapUrl lUrl = new LdapUrl(Path);
+ string fDn=lUrl.getDN();
+ if(fDn != null)
+ _Fdn = fDn;
+ else
+ _Fdn="";
+ }
+ return _Fdn;
+ }
+ }
+
+ /// <summary>
+ /// Returns the connection object used to communicate with
+ /// Ldap server
+ /// </summary>
+ internal LdapConnection conn
+ {
+ get {
+ if( _conn == null)
+ InitBlock();
+
+ return _conn;
+ }
+ set {
+ _conn=value;
+ }
+ }
+
+ /// <summary>
+ /// Flag to check whether the entry is to be cerated or it already
+ /// exists.
+ /// </summary>
+ internal bool Nflag
+ {
+ get {
+ return _Nflag;
+ }
+ set {
+ _Nflag = value;
+ }
+ }
+
+ /// <summary> Initializes the Connection and other properties.
+ ///
+ /// </summary>
+ private void InitBlock()
+ {
+ try {
+ _conn= new LdapConnection ();
+ LdapUrl lUrl=new LdapUrl (Path);
+ _conn.Connect(lUrl.Host,lUrl.Port);
+ _conn.Bind(Username,Password);
+ }
+ catch(LdapException ex) {
+ Console.WriteLine("Error:" + ex.LdapErrorMessage);
+ throw ex;
+ }
+ catch(Exception e) {
+ Console.WriteLine("Error:" + e.Message);
+ throw e;
+ }
+ }
+
+ /// <summary>
+ /// Initializes the Entry specific properties e.g entry DN etc.
+ /// </summary>
+ void InitEntry()
+ {
+ LdapUrl lUrl=new LdapUrl (Path);
+ if(lUrl.getDN()!=null) {
+ DN userDn = new DN(lUrl.getDN());
+ String[] lRdn = userDn.explodeDN(false);
+ _Name = (string)lRdn[0];
+ _Parent = new DirectoryEntry(conn);
+ LdapUrl cUrl=new LdapUrl(lUrl.Host,lUrl.Port,userDn.Parent.ToString());
+ _Parent.Path=cUrl.ToString();
+ }
+ else {
+ _Name=lUrl.Host+":"+lUrl.Port;
+ _Parent = new DirectoryEntry(conn);
+ _Parent.Path = "Ldap:";
+ }
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the DirectoryEntry class
+ /// </summary>
+ public DirectoryEntry()
+ {
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the DirectoryEntry class that binds
+ /// to the specified native Active Directory object.
+ /// </summary>
+ /// <param name="adsObject"> native active directory object</param>
+ public DirectoryEntry(object adsObject)
+ {
+ throw new NotImplementedException();
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the DirectoryEntry class that binds
+ /// this instance to the node in Ldap Directory located at the
+ /// specified path.
+ /// </summary>
+ /// <param name="path"> Path of the entry i.e Ldap URL specifying
+ /// entry path</param>
+ public DirectoryEntry(string path)
+ {
+ _Path=path;
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the DirectoryEntry class. The Path,
+ /// Username, and Password properties are set to the specified values.
+ /// </summary>
+ /// <param name="path">Path of the entry i.e Ldap URL specifying
+ /// entry path</param>
+ /// <param name="username">user name to use when authenticating the client
+ /// </param>
+ /// <param name="password">password to use when authenticating the client
+ /// </param>
+ public DirectoryEntry(string path,string username,string password)
+ {
+ _Path=path;
+ _Username=username;
+ _Password=password;
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the DirectoryEntry class. The Path,
+ /// Username, and Password properties are set to the specified values.
+ /// </summary>
+ /// <param name="path">Path of the entry i.e Ldap URL specifying
+ /// entry path</param>
+ /// <param name="username">user name to use when authenticating the client
+ /// </param>
+ /// <param name="password">password to use when authenticating the client
+ /// </param>
+ /// <param name="authenticationType"> type of authentication to use</param>
+ public DirectoryEntry(
+ string path,
+ string username,
+ string password,
+ AuthenticationTypes authenticationType)
+ {
+ _Path=path;
+ _Username=username;
+ _Password=password;
+ _AuthenticationType=authenticationType;
+ }
+
+ /// <summary>
+ /// Creates the entry object
+ /// </summary>
+ /// <param name="lconn">Connection object used to communicate with
+ /// Ldap server</param>
+ internal DirectoryEntry(LdapConnection lconn)
+ {
+ conn = lconn;
+ }
+
+ /// <summary>
+ /// Returns Type of authentication to use while Binding to Ldap server
+ /// </summary>
+ public AuthenticationTypes AuthenticationType
+ {
+ get
+ {
+ return _AuthenticationType;
+ }
+ set
+ {
+ _AuthenticationType = value;
+ }
+ }
+
+ /// <summary>
+ /// Gets a DirectoryEntries containing the child entries of this node
+ /// in the Ldap Directory hierarchy.
+ /// </summary>
+ /// <value>A DirectoryEntries containing the child entries of this node
+ /// in the Ldap Directory hierarchy.</value>
+ /// <remarks>
+ /// The child entries are only the immediate children of this node.
+ /// Use this property to find, retrieve, or create a directory entry
+ /// in the hierarchy. This property is a collection that, along with
+ /// usual iteration capabilities, provides an Add method through which
+ /// you add a node to the collection directly below the parent node
+ /// that you are currently bound to. When adding a node to the
+ /// collection, you must specify a name for the new node and the name of
+ /// a schema template that you want to associate with the node. For
+ /// example, you might want to use a schema titled "Computer" to add
+ /// new computers to the hierarchy.
+ /// </remarks>
+ public DirectoryEntries Children
+ {
+ get
+ {
+ _Children = new DirectoryEntries(Path, conn);
+ return _Children;
+ }
+ }
+
+ /// <summary>
+ /// Gets the globally unique identifier (GUID) of the DirectoryEntry
+ /// </summary>
+ /// <value>The globally unique identifier of the DirectoryEntry.</value>
+ /// <remarks>
+ /// Not implemented yet.
+ /// </remarks>
+ public Guid Guid
+ {
+ get
+ {
+ throw new NotImplementedException();
+ }
+
+ }
+
+ /// <summary>
+ /// Gets the name of the object as named with the underlying directory
+ /// service
+ /// </summary>
+ /// <value>The name of the object as named with the underlying directory
+ /// service</value>
+ /// <remarks>This name, along with SchemaClassName, distinguishes this
+ /// entry from its siblings and must be unique amongst its siblings
+ /// in each instance of DirectoryEntry.</remarks>
+ public string Name
+ {
+ get {
+ if(_Name==null) {
+ if(CheckEntry(conn,Path))
+ InitEntry();
+ else
+ throw new Exception("There is no such object on the server");
+ }
+ return _Name;
+ }
+ }
+
+ /// <summary>
+ /// Gets this entry's parent in the Ldap Directory hierarchy.
+ /// </summary>
+ /// <value>This entry's parent in the Active Directory hierarc</value>
+ public DirectoryEntry Parent
+ {
+ get {
+ if(_Parent==null) {
+ if(CheckEntry(conn,Path))
+ InitEntry();
+ else
+ throw new Exception("There is no such object on the server");
+ }
+ return _Parent;
+ }
+ }
+
+ /// <summary>
+ /// Gets the globally unique identifier of the DirectoryEntry, as
+ /// returned from the provider
+ /// </summary>
+ /// <value>
+ /// The globally unique identifier of the DirectoryEntry, as returned
+ /// from the provider.
+ /// </value>
+ /// <remarks>
+ /// Not implemented yet.
+ /// </remarks>
+ public string NativeGuid
+ {
+ get {
+ throw new NotImplementedException();
+ }
+ }
+
+ /// <summary>
+ /// Gets the native Active Directory Service Interfaces (ADSI) object.
+ /// </summary>
+ /// <remarks>
+ /// Not implemented yet
+ public object NativeObject
+ {
+ get {
+ throw new NotImplementedException();
+ }
+ }
+
+ /// <summary>
+ /// Gets or sets the password to use when authenticating the client.
+ /// </summary>
+ /// <value>
+ /// The password to use when authenticating the client.
+ /// </value>
+ /// <remarks>
+ /// You can set the Username and password in order to specify alternate
+ /// credentials with which to access the information in Ldap Directory.
+ /// Any other DirectoryEntry objects retrieved from this instance (for
+ /// example, through Children) are automatically created with the same
+ /// alternate credentials.
+ /// </remarks>
+ public string Password
+ {
+ get {
+ return _Password;
+ }
+ set {
+ _Password = value;
+ }
+
+ }
+
+ /// <summary>
+ /// Gets or sets the user name to use when authenticating the client.
+ /// </summary>
+ /// <value>
+ /// The user name to use when authenticating the client.
+ /// </value>
+ /// <remarks>
+ /// You can set the user name and Password in order to specify alternate
+ /// credentials with which to access the information in Ldap Directory.
+ /// Any other DirectoryEntry objects retrieved from this instance (for
+ /// example, through Children) are automatically created with the same
+ /// alternate
+ /// </remarks>
+ public string Username
+ {
+ get {
+ return _Username ;
+ }
+ set {
+ _Username = value;
+ }
+
+ }
+
+ /// <summary>
+ /// Gets or sets the path for this DirectoryEntry.
+ /// </summary>
+ /// <value>
+ /// The path of this DirectoryEntry. The default is an empty string ("").
+ /// </value>
+ /// <remarks>
+ /// The Path property uniquely identifies this entry in a networked
+ /// environment. This entry can always be retrieved using this Path.
+ ///
+ /// Setting the Path retrieves a new entry from the directory store; it
+ /// does not change the path of the currently bound entry.
+ ///
+ /// The classes associated with the DirectoryEntry component can be used
+ /// with any of the Directory service providers. Some of the current
+ /// providers are Internet Information Services (IIS), Lightweight Directory
+ /// Access Protocol (Ldap), Novell NetWare Directory Service (NDS), and WinNT.
+ ///
+ /// Currently we Support only Ldap provider.
+ /// e.g Ldap://[hostname]:[port number]/[ObjectFDN]
+ /// </remarks>
+ public string Path
+ {
+ get {
+ return _Path;
+ }
+ set {
+ _Path = value;
+ }
+
+ }
+
+
+ /// <summary>
+ /// Gets a PropertyCollection of properties set on this object.
+ /// </summary>
+ /// <value>
+ /// A PropertyCollection of properties set on this object.
+ /// </value>
+ public PropertyCollection Properties
+ {
+ get {
+ if ( _Properties == null ) {
+
+ _Properties = new PropertyCollection();
+
+ try {
+ LdapSearchResults lsc=conn.Search( Fdn,
+ LdapConnection.SCOPE_BASE,
+ "objectClass=*",
+ null,
+ false);
+ while(lsc.hasMore()) {
+
+ LdapEntry nextEntry = null;
+ try {
+ nextEntry = lsc.next();
+ }
+ catch(LdapException e) {
+ Console.WriteLine("Error: " + e.LdapErrorMessage);
+ // Exception is thrown, go for next entry
+ throw e;
+ }
+ LdapAttributeSet attributeSet = nextEntry.getAttributeSet();
+ System.Collections.IEnumerator ienum=attributeSet.GetEnumerator();
+ if(ienum!=null) {
+ while(ienum.MoveNext()) {
+ LdapAttribute attribute=(LdapAttribute)ienum.Current;
+ string attributeName = attribute.Name;
+ _Properties[attributeName].AddRange(attribute.StringValueArray);
+ _Properties[attributeName].Mbit=false;
+ // string attributeVal = attribute.StringValue;
+ // _Properties[attributeName].Add(attributeVal);
+ }
+ }
+ break;
+ }
+ }
+ catch( LdapException le) {
+ if(le.ResultCode == LdapException.NO_SUCH_OBJECT)
+ { }
+ }
+
+ }
+ return _Properties;
+ }
+ }
+
+ /// <summary>
+ /// Gets the name of the schema used for this DirectoryEntry
+ /// </summary>
+ /// <value>
+ /// The name of the schema used for this DirectoryEntry.
+ /// </value>
+ ///
+ public string SchemaClassName
+ {
+ get {
+ if(_SchemaClassName==null) {
+ _SchemaClassName = FindAttrValue("structuralObjectClass");
+ }
+ return _SchemaClassName;
+ }
+ }
+
+ /// <summary>
+ /// Searches an entry in the Ldap directory and returns the attribute value
+ /// </summary>
+ /// <param name="attrName">attribute whose value is required</param>
+ /// <returns> value of the attribute stored in Ldap directory</returns>
+ private string FindAttrValue(string attrName)
+ {
+ string aValue=null;
+ string[] attrs={attrName};
+
+ LdapSearchResults lsc=conn.Search( Fdn,
+ LdapConnection.SCOPE_BASE,
+ "objectClass=*",
+ attrs,
+ false);
+ while(lsc.hasMore()) {
+ LdapEntry nextEntry = null;
+ try {
+ nextEntry = lsc.next();
+ }
+ catch(LdapException e) {
+ Console.WriteLine("Error: " + e.LdapErrorMessage);
+ // Exception is thrown, go for next entry
+ throw e;
+ }
+ LdapAttribute attribute = nextEntry.getAttribute(attrName);
+ aValue = attribute.StringValue;
+ break;
+ }
+ return aValue;
+ }
+
+ /// <summary>
+ /// Modifies an entry in the Ldap directory with the input LdapModification
+ /// values.
+ /// </summary>
+ /// <param name="mods">Array consisting of the entry attribute name and the
+ /// attribute values to be modified.</param>
+ private void ModEntry(LdapModification[] mods)
+ {
+
+ try {
+ conn.Modify(Fdn,mods);
+ }
+ catch(LdapException le) {
+ throw le;
+ }
+ }
+
+ /// <summary>
+ /// Checks whether the entry exists in the Ldap directory or not
+ /// </summary>
+ /// <param name="lconn">
+ /// Connection used to communicate with directory
+ /// </param>
+ /// <param name="epath">
+ /// path of the entry
+ /// </param>
+ /// <returns>
+ /// true of the entry exists in the Ldap directory
+ /// false if entry doesn't exists
+ /// </returns>
+ private static bool CheckEntry(LdapConnection lconn, string epath)
+ {
+ LdapUrl lUrl=new LdapUrl(epath);
+ string eDn=lUrl.getDN();
+ if(eDn==null)
+ {
+ eDn="";
+ }
+ string[] attrs={"objectClass"};
+ try
+ {
+ LdapSearchResults lsc=lconn.Search( eDn,
+ LdapConnection.SCOPE_BASE,
+ "objectClass=*",
+ attrs,
+ false);
+ while(lsc.hasMore())
+ {
+ LdapEntry nextEntry = null;
+ try
+ {
+ nextEntry = lsc.next();
+ }
+ catch(LdapException e)
+ {
+ Console.WriteLine("Error: " + e.LdapErrorMessage);
+ // Exception is thrown, go for next entry
+ throw e;
+ }
+ break;
+ }
+
+ }
+ catch(LdapException le)
+ {
+ if(le.ResultCode == LdapException.NO_SUCH_OBJECT)
+ {
+ return false;
+ }
+ else
+ {
+ throw le;
+ }
+ }
+ catch(Exception e)
+ {
+ throw e;
+ }
+ return true;
+ }
+
+ /// <summary>
+ /// Closes the DirectoryEntry and releases any system resources associated
+ /// with this component.
+ /// </summary>
+ /// <remarks>
+ /// Following a call to Close, any operations on the DirectoryEntry might
+ /// raise exceptions.
+ /// </remarks>
+ public void Close()
+ {
+ conn.Disconnect();
+ }
+
+ /// <summary>
+ /// Creates a copy of this entry as a child of the specified parent.
+ /// </summary>
+ /// <param name="newParent">The parent DirectoryEntry. </param>
+ /// <returns>A copy of this entry as a child of the specified parent.
+ public DirectoryEntry CopyTo(DirectoryEntry newParent)
+ {
+ throw new NotImplementedException();
+ }
+
+ /// <summary>
+ /// Deletes this entry and its entire subtree from the Active Directory
+ /// hierarchy.
+ /// </summary>
+ /// <remarks>
+ /// CAUTION The entry and its entire subtree are deleted from the
+ /// Ldap Directory hierarchy.
+ /// </remarks>
+ public void DeleteTree()
+ {
+ System.Collections.IEnumerator ienum = Children.GetEnumerator();
+ while(ienum.MoveNext())
+ {
+ DirectoryEntry de=(DirectoryEntry)ienum.Current;
+ conn.Delete(de.Fdn);
+ }
+ conn.Delete(Fdn);
+ }
+
+ /// <summary>
+ /// Searches the directory store at the specified path to see whether
+ /// an entry exists
+ /// </summary>
+ /// <param name="path">
+ /// The path at which to search the directory store.
+ /// </param>
+ /// <returns>
+ /// true if an entry exists in the directory store at the specified
+ /// path; otherwise, false.
+ /// </returns>
+ public static bool Exists(string path)
+ {
+ LdapConnection aconn=new LdapConnection();
+ LdapUrl lurl=new LdapUrl(path);
+ aconn.Connect(lurl.Host,lurl.Port);
+ aconn.Bind("","");
+ if(CheckEntry(aconn,path))
+ return true;
+ else
+ return false;
+ }
+
+ /// <summary>
+ /// Moves this entry to the specified parent.
+ /// </summary>
+ /// <param name="pentry">
+ /// The parent to which you want to move this entry
+ /// </param>
+ public void MoveTo(DirectoryEntry newParent)
+ {
+ conn.Rename(Fdn, Name, newParent.Fdn, true);
+ }
+
+ /// <summary>
+ /// Moves this entry to the specified parent and changes its name to
+ /// the value of the newName parameter.
+ /// </summary>
+ /// <param name="newParent"> The parent to which you want to move
+ /// this entry
+ /// </param>
+ /// <param name="newName">
+ /// The new name of this entry.
+ /// </param>
+ public void MoveTo( DirectoryEntry newParent,
+ string newName )
+ {
+ conn.Rename(Fdn, newName, newParent.Fdn, true);
+ }
+
+ /// <summary>
+ /// Changes the name of this entry.
+ /// </summary>
+ /// <param name="newName">
+ /// The new name of the entry.
+ /// </param>
+ /// <remarks>
+ /// Note This will also affect the path used to refer to this entry.
+ /// </remarks>
+ public void Rename( string newName )
+ {
+ conn.Rename( Fdn, newName, true);
+ }
+
+ /// <summary>
+ /// Calls a method on the native Active Directory.
+ /// </summary>
+ /// <param name="methodName">The name of the method to invoke.
+ /// </param>
+ /// <param name="args">
+ /// An array of type Object that contains the arguments of the method
+ /// to invoke.
+ /// </param>
+ /// <returns>The return value of the invoked method</returns>
+ /// <remarks>
+ /// Not implemented.
+ public object Invoke(string methodName,
+ params object[] args)
+ {
+ throw new NotImplementedException();
+ }
+
+ /// <summary>
+ /// Creates a copy of this entry, as a child of the specified parent, with
+ /// the specified new name.
+ /// </summary>
+ /// <param name="newParent">The parent DirectoryEntry. </param>
+ /// <param name="newName"> The name of the copy of this entry.
+ /// </param>
+ /// <returns>A renamed copy of this entry as a child of the specified parent.
+ public DirectoryEntry CopyTo( DirectoryEntry newParent,
+ string newName )
+ {
+ throw new NotImplementedException();
+ }
+
+ /// <summary>
+ /// Saves any changes to the entry in the Ldap Directory store.
+ /// </summary>
+ /// <remarks>
+ /// By default, changes to properties are done locally to a cache, and
+ /// property values to be read are cached after the first read. For more
+ /// information, see UsePropertyCache.
+ /// Changes made to the cache include changes to the properties as well as
+ /// calls to Add (if this is the newly created entry).
+ /// </remarks>
+ public void CommitChanges()
+ {
+ if(!Nflag)
+ {
+ System.Collections.ArrayList modList = new System.Collections.ArrayList();
+ System.Collections.IDictionaryEnumerator id = Properties.GetEnumerator();
+ while(id.MoveNext())
+ {
+ string attribute=(string)id.Key;
+ LdapAttribute attr=null;
+ if(Properties[attribute].Mbit)
+ {
+ if(Properties[attribute].Count==1)
+ {
+ String val = (String)Properties[attribute].Value;
+ attr = new LdapAttribute( attribute , val);
+ }
+ else
+ {
+ Object[] vals=(Object [])Properties[attribute].Value;
+ String[] aStrVals= new String[Properties[attribute].Count];
+ Array.Copy(vals,0,aStrVals,0,Properties[attribute].Count);
+ attr = new LdapAttribute( attribute , aStrVals);
+ }
+ modList.Add( new LdapModification(LdapModification.REPLACE, attr));
+ Properties[attribute].Mbit=false;
+ }
+// Console.WriteLine(attribute + "Total no of attr value" + Properties[attribute].Count);
+ }
+ LdapModification[] mods = new LdapModification[modList.Count];
+ Type mtype=Type.GetType("System.DirectoryServices.LdapModification");
+ mods = (LdapModification[])modList.ToArray(typeof(LdapModification));
+ ModEntry(mods);
+ }
+ else
+ {
+ LdapAttributeSet attributeSet = new LdapAttributeSet();
+ System.Collections.IDictionaryEnumerator id = Properties.GetEnumerator();
+ while(id.MoveNext())
+ {
+ string attribute=(string)id.Key;
+// Console.WriteLine("attribute:" + attribute + "Vals:" + Properties[attribute][0]);
+ if(Properties[attribute].Count==1)
+ {
+ String val = (String)Properties[attribute].Value;
+ attributeSet.Add(new LdapAttribute(attribute, val));
+ }
+ else
+ {
+ Object[] vals=(Object [])Properties[attribute].Value;
+ String[] aStrVals= new String[Properties[attribute].Count];
+ Array.Copy(vals,0,aStrVals,0,Properties[attribute].Count);
+ attributeSet.Add( new LdapAttribute( attribute , aStrVals));
+ }
+ }
+ LdapEntry newEntry = new LdapEntry( Fdn, attributeSet );
+ conn.Add( newEntry );
+ }
+ }
+
+ }
+}
+
diff --git a/mcs/class/System.DirectoryServices/System.DirectoryServices/DirectorySearcher.cs b/mcs/class/System.DirectoryServices/System.DirectoryServices/DirectorySearcher.cs
new file mode 100644
index 00000000000..8f27a7f9388
--- /dev/null
+++ b/mcs/class/System.DirectoryServices/System.DirectoryServices/DirectorySearcher.cs
@@ -0,0 +1,499 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc., www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+
+//
+// System.DirectoryServices.DirectorySearcher.cs
+//
+// Author:
+// Sunil Kumar (sunilk@novell.com)
+//
+// (C) Novell Inc.
+//
+
+using System.ComponentModel;
+using Novell.Directory.Ldap;
+using Novell.Directory.Ldap.Utilclass;
+using System.Collections.Specialized;
+
+namespace System.DirectoryServices
+{
+
+ /// <summary>
+ ///Performs queries against Ldap directory.
+ /// </summary>
+ public class DirectorySearcher : Component
+ {
+
+ private DirectoryEntry _SearchRoot=null;
+ private bool _CacheResults=true;
+ private TimeSpan _ClientTimeout = new TimeSpan(-1);
+ private string _Filter="(objectClass=*)";
+ private int _PageSize=0;
+ private StringCollection _PropertiesToLoad=new StringCollection();
+ private bool _PropertyNamesOnly=false;
+ private ReferralChasingOption _ReferralChasing=
+ System.DirectoryServices.ReferralChasingOption.External;
+ private SearchScope _SearchScope=
+ System.DirectoryServices.SearchScope.Subtree;
+ private TimeSpan _ServerPageTimeLimit=new TimeSpan(-1);
+ private int _SizeLimit=1000;
+ private LdapConnection _conn = null;
+
+ /// <summary>
+ /// Gets or sets the node in the Ldap Directory hierarchy where the
+ /// search starts.
+ /// </summary>
+ /// <value>
+ /// The DirectoryEntry in the Ldap Directory hierarchy where the
+ /// search starts. The default is a null reference
+ /// </value>
+ public DirectoryEntry SearchRoot
+ {
+ get
+ {
+ return _SearchRoot;
+ }
+ set
+ {
+ _SearchRoot = value;
+ }
+ }
+
+ /// <summary>
+ /// Gets or sets a value indicating whether the result is
+ /// cached on the client computer.
+ /// </summary>
+ /// <value>
+ /// true if the result is cached on the client computer; otherwise,
+ /// false. The default is true
+ /// </value>
+ /// <remarks>
+ /// If the search returns a large result set, it is better to set
+ /// this property to false.
+ /// </remarks>
+ public bool CacheResults
+ {
+ get
+ {
+ return _CacheResults;
+ }
+ set
+ {
+ CacheResults = value;
+ }
+ }
+
+ /// <summary>
+ /// Gets or sets the maximum amount of time that the client waits for
+ /// the server to return results. If the server does not respond
+ /// within this time, the search is aborted and no results are
+ /// returned.
+ /// </summary>
+ /// <value>
+ /// A TimeSpan that represents the maximum amount of time (in seconds)
+ /// for the client to wait for the server to return results. The
+ /// default is -1, which means to wait indefinitely.
+ /// </value>
+ /// <remarks>
+ /// If the ServerTimeLimit is reached before the client times out,
+ /// the server returns its results and the client stops waiting. The
+ /// maximum server time limit is 120 seconds.
+ /// </remarks>
+ public TimeSpan ClientTimeout
+ {
+ get
+ {
+ return _ClientTimeout;
+ }
+ set
+ {
+ _ClientTimeout = value;
+ }
+ }
+
+ /// <summary>
+ /// Gets or sets the Lightweight Directory Access Protocol (Ldap)
+ /// format filter string.
+ /// </summary>
+ /// <value>
+ /// The search filter string in Ldap format, such as
+ /// "(objectClass=user)". The default is "(objectClass=*)", which
+ /// retrieves all objects.
+ /// </value>
+ /// <remarks>
+ /// The filter uses the following guidelines:
+ /// 1. The string must be enclosed in parentheses.
+ /// 2. Expressions can use the relational operators: <, <=, =, >=,
+ /// and >. An example is "(objectClass=user)". Another example is
+ /// "(lastName>=Davis)".
+ /// 3. Compound expressions are formed with the prefix operators &
+ /// and |. Anexampleis"(&(objectClass=user)(lastName= Davis))".
+ /// Anotherexampleis"(&(objectClass=printer)(|(building=42)
+ /// (building=43)))".
+ /// </remarks>
+ public string Filter
+ {
+ get
+ {
+ return _Filter;
+ }
+ set
+ {
+ _Filter = value;
+ }
+ }
+
+ /// <summary>
+ /// Gets or sets the page size in a paged search.
+ /// </summary>
+ /// <value>
+ /// The maximum number of objects the server can return in a paged
+ /// search. The default is zero, which means do not do a paged search.
+ /// </value>
+ /// <remarks>
+ /// After the server has found a PageSize object, it will stop
+ /// searching and return the results to the client. When the client
+ /// requests more data, the server will restart the search where it
+ /// left off.
+ /// </remarks>
+ public int PageSize
+ {
+ get
+ {
+ return _PageSize;
+ }
+ set
+ {
+ _PageSize = value;
+ }
+ }
+
+ /// <summary>
+ /// Gets the set of properties retrieved during the search.
+ /// </summary>
+ /// <value>
+ /// The set of properties retrieved during the search. The default is
+ /// an empty StringCollection, which retrieves all properties.
+ /// </value>
+ /// <remarks>
+ /// To retrieve specific properties, add them to this collection
+ /// before you begin the search. For example, searcher.
+ /// PropertiesToLoad.Add("phone");.
+ /// </remarks>
+ public StringCollection PropertiesToLoad
+ {
+ get
+ {
+ return _PropertiesToLoad;
+ }
+ }
+
+ /// <summary>
+ /// Gets or sets a value indicating whether the search retrieves only the
+ /// names of attributes to which values have been assigned.
+ /// </summary>
+ /// <value>
+ /// true if the search obtains only the names of attributes to which
+ /// values have been assigned; false if the search obtains the names
+ /// and values for all the requested attributes. The default is false.
+ /// </value>
+ public bool PropertyNamesOnly
+ {
+ get
+ {
+ return _PropertyNamesOnly;
+ }
+ set
+ {
+ _PropertyNamesOnly = value;
+ }
+ }
+
+ /// <summary>
+ /// Gets or sets how referrals are chased.
+ /// </summary>
+ /// <value>
+ /// One of the ReferralChasingOption values. The default is External.
+ /// </value>
+ /// <remarks>
+ /// If the root search is not specified in the naming context of the
+ /// server or when the search results cross a naming context (for
+ /// example, when you have child domains and search in the parent
+ /// domain), the server sends a referral message to the client that
+ /// the client can choose to ignore or chase.
+ /// </remarks>
+ public ReferralChasingOption ReferralChasing
+ {
+ get
+ {
+ return _ReferralChasing;
+ }
+ set
+ {
+ _ReferralChasing = value;
+ }
+ }
+
+ /// <summary>
+ /// Gets or sets the scope of the search that is observed by the
+ /// server.
+ /// </summary>
+ /// <value>
+ /// One of the SearchScope values. The default is Subtree.
+ /// </value>
+ public SearchScope SearchScope
+ {
+ get
+ {
+ return _SearchScope;
+ }
+ set
+ {
+ _SearchScope = value;
+ }
+ }
+
+ /// <summary>
+ /// Gets or sets the time limit the server should observe to search an
+ /// individual page of results (as opposed to the time limit for the
+ /// entire search).
+ /// </summary>
+ /// <value>
+ /// A TimeSpan that represents the amount of time the server should
+ /// observe to search a page of results. The default is -1, which
+ /// means to search indefinitely.
+ /// </value>
+ /// <remarks>
+ /// When the time limit is reached, the server stops searching and
+ /// returns the result obtained up to that point, along with a cookie
+ /// containing the information about where to resume searching.
+ /// A negative value means to search indefinitely.
+ /// Note: This property only applies to searches where PageSize
+ /// is set to a value that is not the default of -1.
+ /// </remarks>
+ public TimeSpan ServerPageTimeLimit
+ {
+ get
+ {
+ return _ServerPageTimeLimit;
+ }
+ set
+ {
+ _ServerPageTimeLimit = value;
+ }
+ }
+
+ /// <summary>
+ /// Gets or sets the maximum number of objects the server returns in
+ /// a search.
+ /// </summary>
+ /// <value>
+ /// The maximum number of objects the server returns in a search. The
+ /// default of zero means to use the server-determined default size
+ /// limit of 1000 entries.
+ /// </value>
+ /// <remarks>
+ /// The server stops searching after the size limit is reached and
+ /// returns the results accumulated up to that point.
+ /// Note: If you set SizeLimit to a value that is larger
+ /// than the server-determined default of 1000 entries, the
+ /// server-determined default is used.
+ /// </remarks>
+ public int SizeLimit
+ {
+ get
+ {
+ return _SizeLimit;
+ }
+ set
+ {
+ _SizeLimit = value;
+ }
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the DirectorySearcher class with
+ /// SearchRoot, Filter, PropertiesToLoad, and SearchScope set to the
+ /// default values.
+ /// </summary>
+ public DirectorySearcher()
+ {
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the DirectorySearcher class with
+ /// Filter, PropertiesToLoad, and SearchScope set to the default
+ /// values. SearchRoot is set to the specified value.
+ /// </summary>
+ /// <param name="searchRoot">
+ /// The node in the Active Directory hierarchy where the search starts.
+ /// The SearchRoot property is initialized to this value.
+ /// </param>
+ public DirectorySearcher(DirectoryEntry searchRoot)
+ {
+ _SearchRoot = searchRoot;
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the DirectorySearcher class with
+ /// SearchRoot, PropertiesToLoad, and SearchScope set to the default
+ /// values. Filter is set to the specified value.
+ /// </summary>
+ /// <param name="filter">
+ /// The search filter string in Lightweight Directory Access Protocol
+ /// (Ldap) format. The Filter property is initialized to this value.
+ /// </param>
+ public DirectorySearcher(string filter)
+ {
+ _Filter = filter;
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the DirectorySearcher class with
+ /// PropertiesToLoad and SearchScope set to the default values.
+ /// SearchRoot and Filter are set to the specified values.
+ /// </summary>
+ /// <param name="searchRoot">
+ /// The node in the Active Directory hierarchy where the search starts.
+ /// The SearchRoot property is initialized to this value.
+ /// </param>
+ /// <param name="filter">
+ /// The search filter string in Lightweight Directory Access Protocol
+ /// (Ldap) format. The Filter property is initialized to this value.
+ /// </param>
+ public DirectorySearcher( DirectoryEntry searchRoot,
+ string filter )
+ {
+ _SearchRoot = searchRoot;
+ _Filter = filter;
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the DirectorySearcher class with
+ /// SearchRoot and SearchScope set to the default values. Filter and
+ /// PropertiesToLoad are set to the specified values.
+ /// </summary>
+ /// <param name="filter">
+ /// The search filter string in Lightweight Directory Access Protocol
+ /// (Ldap) format. The Filter property is initialized to this value.
+ /// </param>
+ /// <param name="propertiesToLoad">
+ /// The set of properties to retrieve during the search. The
+ /// PropertiesToLoad property is initialized to this value.
+ /// </param>
+ public DirectorySearcher( string filter,
+ string[] propertiesToLoad )
+ {
+ _Filter = filter;
+ PropertiesToLoad.AddRange(propertiesToLoad);
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the DirectorySearcher class with
+ /// SearchScope set to its default value. SearchRoot, Filter, and
+ /// PropertiesToLoad are set to the specified values.
+ /// </summary>
+ /// <param name="searchRoot">
+ /// The node in the Active Directory hierarchy where the search starts.
+ /// The SearchRoot property is initialized to this value
+ /// </param>
+ /// <param name="filter">
+ /// The search filter string in Lightweight Directory Access Protocol
+ /// (Ldap) format. The Filter property is initialized to this value.
+ /// </param>
+ /// <param name="propertiesToLoad">
+ /// The set of properties retrieved during the search. The
+ /// PropertiesToLoad property is initialized to this value.
+ /// </param>
+ public DirectorySearcher( DirectoryEntry searchRoot,
+ string filter,
+ string[] propertiesToLoad )
+ {
+ _SearchRoot = searchRoot;
+ _Filter = filter;
+ PropertiesToLoad.AddRange(propertiesToLoad);
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the DirectorySearcher class with
+ /// SearchRoot set to its default value. Filter, PropertiesToLoad,
+ /// and SearchScope are set to the specified values
+ /// </summary>
+ /// <param name="filter">
+ /// The search filter string in Lightweight Directory Access Protocol
+ /// (Ldap) format. The Filter property is initialized to this value.
+ /// </param>
+ /// <param name="propertiesToLoad">
+ /// The set of properties to retrieve during the search. The
+ /// PropertiesToLoad property is initialized to this value.
+ /// </param>
+ /// <param name="scope">
+ /// The scope of the search that is observed by the server. The
+ /// SearchScope property is initialized to this value.
+ /// </param>
+ public DirectorySearcher( string filter,
+ string[] propertiesToLoad,
+ SearchScope scope )
+ {
+ _SearchScope = scope;
+ _Filter = filter;
+ PropertiesToLoad.AddRange(propertiesToLoad);
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the DirectorySearcher class with the
+ /// SearchRoot, Filter, PropertiesToLoad, and SearchScope properties
+ /// set to the specified values
+ /// </summary>
+ /// <param name="searchRoot">
+ /// The node in the Active Directory hierarchy where the search starts.
+ /// The SearchRoot property is initialized to this value.
+ /// </param>
+ /// <param name="filter">
+ /// The search filter string in Lightweight Directory Access Protocol
+ /// (Ldap) format. The Filter property is initialized to this value.
+ /// </param>
+ /// <param name="propertiesToLoad">
+ /// The set of properties to retrieve during the search. The
+ /// PropertiesToLoad property is initialized to this value.
+ /// </param>
+ /// <param name="scope">
+ /// The scope of the search that is observed by the server. The
+ /// SearchScope property is initialized to this value.
+ /// </param>
+ public DirectorySearcher( DirectoryEntry searchRoot,
+ string filter,
+ string[] propertiesToLoad,
+ SearchScope scope )
+ {
+ _SearchRoot = searchRoot;
+ _SearchScope = scope;
+ _Filter = filter;
+ PropertiesToLoad.AddRange(propertiesToLoad);
+
+ }
+
+
+ }
+}
+
diff --git a/mcs/class/System.DirectoryServices/System.DirectoryServices/PropertyCollection.cs b/mcs/class/System.DirectoryServices/System.DirectoryServices/PropertyCollection.cs
new file mode 100644
index 00000000000..f796ebf4903
--- /dev/null
+++ b/mcs/class/System.DirectoryServices/System.DirectoryServices/PropertyCollection.cs
@@ -0,0 +1,174 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc., www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+
+//
+// System.DirectoryServices.PropertyCollection.cs
+//
+// Author:
+// Sunil Kumar (sunilk@novell.com)
+//
+// (C) Novell Inc.
+//
+
+using System;
+using System.Collections;
+
+namespace System.DirectoryServices
+{
+ public class PropertyCollection : IDictionary, ICollection,IEnumerable
+ {
+ protected ArrayList m_oKeys = new ArrayList();
+ protected Hashtable m_oValues = new Hashtable();
+
+ internal PropertyCollection()
+ {
+ }
+ public int Count
+ {
+ get{return m_oValues.Count;}
+ }
+
+ bool ICollection.IsSynchronized
+ {
+ get{return m_oValues.IsSynchronized;}
+ }
+
+ object ICollection.SyncRoot
+ {
+ get{return m_oValues.SyncRoot;}
+ }
+
+ void CopyTo(System.Array oArray, int iArrayIndex)
+ {
+ m_oValues.CopyTo(oArray, iArrayIndex);
+ }
+
+ void ICollection.CopyTo(System.Array oArray, int iArrayIndex)
+ {
+ CopyTo(oArray,iArrayIndex);
+ }
+
+ public void CopyTo(PropertyValueCollection[] array, int index)
+ {
+ CopyTo(array,index);
+ }
+
+ void Add(object oKey, object oValue)
+ {
+ m_oKeys.Add(oKey);
+ m_oValues.Add(oKey, oValue);
+ }
+
+ void IDictionary.Add(object oKey, object oValue){
+ Add(oKey,oValue);
+ }
+
+ bool IDictionary.IsFixedSize
+ {
+ get{return m_oKeys.IsFixedSize;}
+ }
+
+ bool IDictionary.IsReadOnly
+ {
+ get{return m_oKeys.IsReadOnly;}
+ }
+
+ ICollection IDictionary.Keys
+ {
+ get{return m_oValues.Keys;}
+ }
+
+ public ICollection PropertyNames
+ {
+ get{return m_oValues.Keys;}
+ }
+
+ void IDictionary.Clear()
+ {
+ m_oValues.Clear();
+ m_oKeys.Clear();
+ }
+
+ bool IDictionary.Contains(object oKey)
+ {
+ return m_oValues.Contains(oKey);
+ }
+
+ public bool Contains (string propertyName)
+ {
+ return m_oValues.Contains(propertyName);
+ }
+
+ public bool ContainsKey(object oKey)
+ {
+ return m_oValues.ContainsKey(oKey);
+ }
+
+ public IDictionaryEnumerator GetEnumerator()
+ {
+ return m_oValues.GetEnumerator();
+ }
+
+ void IDictionary.Remove(object oKey)
+ {
+ m_oValues.Remove(oKey);
+ m_oKeys.Remove(oKey);
+ }
+
+ object IDictionary.this[object oKey]
+ {
+ get{return m_oValues[oKey];}
+ set{m_oValues[oKey] = value;}
+ }
+
+ public ICollection Values
+ {
+ get{return m_oValues.Values;}
+ }
+
+ IEnumerator IEnumerable.GetEnumerator()
+ {
+ return m_oValues.GetEnumerator();
+ }
+
+ public PropertyValueCollection this[string propertyName]
+ {
+ get
+ {
+ if(Contains(propertyName))
+ {
+ return (PropertyValueCollection)m_oValues[propertyName];
+ }
+ else
+ {
+ PropertyValueCollection _pValColl=new PropertyValueCollection();
+ Add((string)propertyName, (PropertyValueCollection)_pValColl);
+ return _pValColl;
+ }
+// throw new InvalidOperationException();
+ }
+ }
+
+ }
+}
+
diff --git a/mcs/class/System.DirectoryServices/System.DirectoryServices/PropertyValueCollection.cs b/mcs/class/System.DirectoryServices/System.DirectoryServices/PropertyValueCollection.cs
new file mode 100644
index 00000000000..4978f3845b3
--- /dev/null
+++ b/mcs/class/System.DirectoryServices/System.DirectoryServices/PropertyValueCollection.cs
@@ -0,0 +1,193 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc., www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+
+//
+// System.DirectoryServices.PropertyValueCollection .cs
+//
+// Author:
+// Sunil Kumar (sunilk@novell.com)
+//
+// (C) Novell Inc.
+//
+using System;
+using System.Collections;
+
+namespace System.DirectoryServices
+{
+ public class PropertyValueCollection : CollectionBase
+ {
+
+ private bool _Mbit;
+
+ internal PropertyValueCollection():base()
+ {
+ _Mbit = false;
+ }
+
+ internal bool Mbit
+ {
+ get
+ {
+ return _Mbit;
+ }
+ set
+ {
+ _Mbit = value;
+ }
+ }
+
+ public object this[ int index ]
+ {
+ get
+ {
+ return( (object) List[index] );
+ }
+ set
+ {
+ List[index] = value;
+ }
+ }
+
+ public int Add( object value )
+ {
+ if(Contains(value))
+ {
+ return -1;
+ }
+ else
+ {
+ _Mbit=true;
+ return( List.Add( value ) );
+ }
+
+ }
+
+ public void AddRange(object[] value)
+ {
+ int i=0;
+ while(true)
+ {
+ try
+ {
+ if(Add(value[i])!= -1)
+ {
+ ++i;
+ }
+ }
+ catch(IndexOutOfRangeException ex)
+ {
+ break;
+ }
+ catch(Exception ex)
+ {
+ throw ex;
+ }
+ }
+ return;
+ }
+
+ public int IndexOf( object value )
+ {
+ return( List.IndexOf( value ) );
+ }
+
+ public void Insert( int index, object value )
+ {
+ List.Insert( index, value );
+ }
+
+ public void Remove( object value )
+ {
+ List.Remove( value );
+ }
+
+ public bool Contains( object value )
+ {
+ return( List.Contains( value ) );
+ }
+
+ internal bool ContainsCaselessStringValue( string value )
+ {
+ for(int i=0; i< this.Count; ++i)
+ {
+ string lVal = (string) List[i];
+ if(String.Compare(value,lVal,true)==0)
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ protected override void OnInsert( int index, Object value )
+ {
+ // Insert additional code to be run only when inserting values.
+ }
+
+ protected override void OnRemove( int index, Object value )
+ {
+ // Insert additional code to be run only when removing values.
+ }
+
+ protected override void OnSet( int index, Object oldValue, Object newValue )
+ {
+ // Insert additional code to be run only when setting values.
+ }
+
+ protected override void OnValidate( Object value )
+ {
+// if ( value.GetType() != Type.GetType("System.Object") )
+// throw new ArgumentException( "value must be of type Object.", "value" );
+ }
+
+ public object Value
+ {
+ get
+ {
+ if(this.Count==1)
+ {
+ return (object) List[0];
+ }
+ else
+ {
+// System.Object[] oArray= new System.Object[this.Count];
+// object[] oArray= new object[this.Count];
+// Array.Copy((System.Array)List,0,(System.Array)oArray,0,this.Count);
+ Array LArray = Array.CreateInstance( Type.GetType("System.Object"), this.Count );
+ for ( int i = LArray.GetLowerBound(0); i <= LArray.GetUpperBound(0); i++ )
+ LArray.SetValue( List[i], i );
+ return LArray;
+ }
+ }
+ set
+ {
+ List.Clear();
+ Add(value);
+// List[0] = (object)value;
+// _Mbit=true;
+ }
+ }
+
+ }
+}
+
diff --git a/mcs/class/System.DirectoryServices/System.DirectoryServices/ReferralChasingOption.cs b/mcs/class/System.DirectoryServices/System.DirectoryServices/ReferralChasingOption.cs
new file mode 100644
index 00000000000..8c09748c3ba
--- /dev/null
+++ b/mcs/class/System.DirectoryServices/System.DirectoryServices/ReferralChasingOption.cs
@@ -0,0 +1,64 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc., www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+
+//
+// System.DirectoryServices.ReferralChasingOption.cs
+//
+// Author:
+// Sunil Kumar (sunilk@novell.com)
+//
+// (C) Novell Inc.
+//
+
+namespace System.DirectoryServices
+{
+
+ /// <summary>
+ /// Specifies if and how referral chasing is pursued.
+ /// </summary>
+ /// <remarks>
+ /// When a server determines that other servers hold relevant information,
+ /// in part or as a whole, it may refer the client to another server to
+ /// obtain the result. Referral chasing is the action taken by a client
+ /// to contact the referenced server to continue the directory search.
+ ///
+ /// Use the constants of this enumeration to set up search preferences for
+ /// referral chasing. The action amounts to assigning the appropriate
+ /// fields of DirectorySearcher to elements of the ReferralChasingOption
+ /// enumeration.
+ ///
+ /// The Lightweight Directory Access Protocol (Ldap) provider supports
+ /// external referrals for paged searches, but does not support
+ /// subordinate referrals during paging.
+ /// </remarks>
+ [Serializable]
+ public enum ReferralChasingOption
+ {
+ All,
+ External,
+ None,
+ Subordinate
+ }
+
+}
+
diff --git a/mcs/class/System.DirectoryServices/System.DirectoryServices/ResultPropertyCollection.cs b/mcs/class/System.DirectoryServices/System.DirectoryServices/ResultPropertyCollection.cs
new file mode 100644
index 00000000000..6144794f3c1
--- /dev/null
+++ b/mcs/class/System.DirectoryServices/System.DirectoryServices/ResultPropertyCollection.cs
@@ -0,0 +1,91 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc., www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+
+//
+// System.DirectoryServices.ResultPropertyCollection .cs
+//
+// Author:
+// Sunil Kumar (sunilk@novell.com)
+//
+// (C) Novell Inc.
+//
+
+using System;
+using System.Collections;
+
+namespace System.DirectoryServices
+{
+ /// <summary>
+ /// Contains the properties of a SearchResult instance.
+ ///
+ /// For a list of all members of this type, see ResultPropertyCollection
+ /// Members.
+ /// </summary>
+ /// <remarks>
+ /// SearchResult instances are similar to DirectoryEntry instances. The
+ /// notable difference is that the DirectoryEntry retrieves its
+ /// information from the Active Directory hierarchy each time a new object
+ /// is accessed, whereas the data for the SearchResult is already
+ /// available in the SearchResultCollection that a DirectorySearcher
+ /// query returns. If you try to get a SearchResult property that your
+ /// query did not specify for retrieval, the property will not be
+ /// available.
+ /// </remarks>
+ public class ResultPropertyCollection : DictionaryBase
+ {
+ public ResultPropertyValueCollection this[string key]
+ {
+ get {return (ResultPropertyValueCollection) this.Dictionary[key]; }
+
+ set { this.Dictionary[key] = value; }
+ }
+ //add a ResultPropertyValueCollection based on key
+ public void Add(string key, ResultPropertyValueCollection rpcoll)
+ {
+ this.Dictionary.Add(key, rpcoll);
+ }
+ //see if collection contains an entry corresponding to key
+ public bool Contains(string key)
+ {
+ return this.Dictionary.Contains(key);
+ }
+
+ public ICollection PropertyNames
+ {
+ get
+ {
+ return this.Dictionary.Keys;
+ }
+ }
+
+ public ICollection Values
+ {
+ get
+ {
+ return this.Dictionary.Values;
+ }
+ }
+
+ }
+}
+
diff --git a/mcs/class/System.DirectoryServices/System.DirectoryServices/ResultPropertyValueCollection.cs b/mcs/class/System.DirectoryServices/System.DirectoryServices/ResultPropertyValueCollection.cs
new file mode 100644
index 00000000000..1d3e85ca751
--- /dev/null
+++ b/mcs/class/System.DirectoryServices/System.DirectoryServices/ResultPropertyValueCollection.cs
@@ -0,0 +1,81 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc., www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+
+//
+// System.DirectoryServices.ResultPropertyValueCollection .cs
+//
+// Author:
+// Sunil Kumar (sunilk@novell.com)
+//
+// (C) Novell Inc.
+//
+
+using System;
+using System.Collections;
+
+namespace System.DirectoryServices
+{
+ /// <summary>
+ /// Contains the values of a SearchResult property.
+ /// </summary>
+ /// <remarks>
+ /// SearchResult instances are similar to DirectoryEntry instances. The
+ /// notable difference is that the DirectoryEntry retrieves its
+ /// information from the Active Directory hierarchy each time a new object
+ /// is accessed, whereas the data for the SearchResult is already
+ /// available in the SearchResultCollection that a DirectorySearcher
+ /// query returns. If you try to get a SearchResult property that your
+ /// query did not specify for retrieval, the property will not be
+ /// available.
+ /// </remarks>
+ public class ResultPropertyValueCollection : ReadOnlyCollectionBase
+ {
+ public ResultPropertyValueCollection (object[] components)
+ {
+ InnerList.AddRange (components);
+ }
+
+ public virtual object this [int index]
+ {
+ get { return (object) InnerList[index]; }
+ }
+
+ public bool Contains (object value)
+ {
+ return InnerList.Contains (value);
+ }
+
+ public void CopyTo (object[] array, int index)
+ {
+ InnerList.CopyTo (array, index);
+ }
+
+ public int IndexOf (object value)
+ {
+ return InnerList.IndexOf (value);
+ }
+
+
+ }
+}
+
diff --git a/mcs/class/System.DirectoryServices/System.DirectoryServices/SchemaNameCollection.cs b/mcs/class/System.DirectoryServices/System.DirectoryServices/SchemaNameCollection.cs
new file mode 100644
index 00000000000..ed3aa4e66f7
--- /dev/null
+++ b/mcs/class/System.DirectoryServices/System.DirectoryServices/SchemaNameCollection.cs
@@ -0,0 +1,147 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc., www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+
+//
+// System.DirectoryServices.SchemaNameCollection.cs
+//
+// Author:
+// Sunil Kumar (sunilk@novell.com)
+//
+// (C) Novell Inc.
+//
+
+using System.Collections;
+
+namespace System.DirectoryServices
+{
+
+ /// <summary>
+ ///Contains a list of the schema names that the
+ /// SchemaFilter property of a DirectoryEntries
+ /// object can use.
+ /// </summary>
+ public class SchemaNameCollection : IList, ICollection, IEnumerable
+ {
+ private SchemaNameCollection ()
+ {
+ }
+
+ int IList.Add(object avalue)
+ {
+ throw new NotImplementedException();
+ }
+
+ int Add (string value)
+ {
+ throw new NotImplementedException();
+ }
+
+ void IList.Clear()
+ {
+ throw new NotImplementedException();
+ }
+ bool IList.Contains(object cvalue)
+ {
+ throw new NotImplementedException();
+ }
+ int IList.IndexOf(object ivalue)
+ {
+ throw new NotImplementedException();
+ }
+ void IList.Insert(int index,object ivalue)
+ {
+ throw new NotImplementedException();
+ }
+ void IList.Remove(object rvalue)
+ {
+ throw new NotImplementedException();
+ }
+ void IList.RemoveAt(int index)
+ {
+ throw new NotImplementedException();
+ }
+
+ bool IList.IsFixedSize
+ {
+ get
+ {
+ return true;
+ }
+ }
+
+ bool IList.IsReadOnly
+ {
+ get
+ {
+ return true;
+ }
+ }
+ object IList.this[int recordIndex]
+ {
+ get
+ {
+ throw new InvalidOperationException();
+ }
+ set
+ {
+ throw new InvalidOperationException();
+ }
+ }
+
+ public void CopyTo(Array array,int index)
+ {
+ throw new NotImplementedException();
+ }
+
+ public int Count
+ {
+ get
+ {
+ return 0;
+ }
+ }
+ public bool IsSynchronized
+ {
+ get
+ {
+ return true;
+ }
+ }
+
+ object ICollection.SyncRoot {
+ get {
+ // FIXME:
+ return this;
+ }
+ }
+
+ public IEnumerator GetEnumerator()
+ {
+ throw new NotImplementedException();
+ }
+
+
+ }
+
+}
+
diff --git a/mcs/class/System.DirectoryServices/System.DirectoryServices/SearchResult.cs b/mcs/class/System.DirectoryServices/System.DirectoryServices/SearchResult.cs
new file mode 100644
index 00000000000..6b121074331
--- /dev/null
+++ b/mcs/class/System.DirectoryServices/System.DirectoryServices/SearchResult.cs
@@ -0,0 +1,102 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc., www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+
+//
+// System.DirectoryServices.SearchResult.cs
+//
+// Author:
+// Sunil Kumar (sunilk@novell.com)
+//
+// (C) Novell Inc.
+//
+
+using System.ComponentModel;
+
+namespace System.DirectoryServices
+{
+
+ /// <summary>
+ ///Encapsulates a node or object in the Ldap Directory hierarchy.
+ /// </summary>
+ public class SearchResult
+ {
+
+ private string _Path=null;
+ private Properties _Properties=null;
+
+ /// <summary>
+ /// Gets the path for this SearchResult.
+ /// </summary>
+ /// <value>
+ /// The path of this SearchResult.
+ /// </value>
+ /// <remarks>
+ /// The Path property uniquely identifies this entry in the Active
+ /// Directory hierarchy. The entry can always be retrieved using this
+ /// path
+ /// </remarks>
+ public string Path
+ {
+ get
+ {
+ return _Path;
+ }
+ }
+
+ /// <summary>
+ /// Gets a ResultPropertyCollection of properties set on this object.
+ /// </summary>
+ /// <value>
+ /// A ResultPropertyCollection of properties set on this object.
+ /// </value>
+ /// <remarks>
+ /// This collection only contains properties that were explicitly
+ /// requested through DirectorySearcher.PropertiesToLoad.
+ /// </remarks>
+ public ResultPropertyCollection Properties
+ {
+ get
+ {
+ return _Properties;
+ }
+ }
+
+ /// <summary>
+ /// Retrieves the DirectoryEntry that corresponds to the SearchResult,
+ /// from the Active Directory hierarchy.
+ /// </summary>
+ /// <returns>
+ /// The DirectoryEntry that corresponds to the SearchResult
+ /// </returns>
+ /// <remarks>
+ /// Use GetDirectoryEntry when you want to look at the live entry
+ /// instead of the entry returned through DirectorySearcher, or when
+ /// you want to invoke a method on the object that was returned.
+ /// </remarks>
+ public DirectoryEntry GetDirectoryEntry()
+ {
+ }
+
+ }
+}
+
diff --git a/mcs/class/System.DirectoryServices/System.DirectoryServices/SearchResultCollection.cs b/mcs/class/System.DirectoryServices/System.DirectoryServices/SearchResultCollection.cs
new file mode 100644
index 00000000000..906de6a9720
--- /dev/null
+++ b/mcs/class/System.DirectoryServices/System.DirectoryServices/SearchResultCollection.cs
@@ -0,0 +1,165 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc., www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+
+//
+// System.DirectoryServices.SearchResultCollection.cs
+//
+// Author:
+// Sunil Kumar (sunilk@novell.com)
+//
+// (C) Novell Inc.
+//
+
+using System;
+using System.Collections;
+
+namespace System.DirectoryServices
+{
+ /// <summary>
+ /// Contains the SearchResult instances that the Active Directory
+ /// hierarchy returned during a DirectorySearcher query.
+ /// </summary>
+ /// <remarks>
+ /// Each time you perform a query, DirectorySearcher creates a handle to
+ /// the corresponding SearchResultCollection instance. This handle
+ /// persists until you call Dispose or until garbage collection picks up
+ /// the instance.
+ /// </remarks>
+ public class SearchResultCollection : MarshalByRefObject, ICollection, IEnumerable, IDisposable
+ {
+ protected ArrayList m_oKeys = new ArrayList();
+ protected Hashtable m_oValues = new Hashtable();
+
+ internal PropertyCollection()
+ {
+ }
+ public int Count
+ {
+ get{return m_oValues.Count;}
+ }
+
+ public bool IsSynchronized
+ {
+ get{return m_oValues.IsSynchronized;}
+ }
+
+ public object SyncRoot
+ {
+ get{return m_oValues.SyncRoot;}
+ }
+
+ public void CopyTo(System.Array oArray, int iArrayIndex)
+ {
+ m_oValues.CopyTo(oArray, iArrayIndex);
+ }
+
+
+ public void Add(object oKey, object oValue)
+ {
+ m_oKeys.Add(oKey);
+ m_oValues.Add(oKey, oValue);
+ }
+
+ public bool IsFixedSize
+ {
+ get{return m_oKeys.IsFixedSize;}
+ }
+
+ public bool IsReadOnly
+ {
+ get{return m_oKeys.IsReadOnly;}
+ }
+
+ public ICollection Keys
+ {
+ get{return m_oValues.Keys;}
+ }
+
+ public void Clear()
+ {
+ m_oValues.Clear();
+ m_oKeys.Clear();
+ }
+
+ public bool Contains(object oKey)
+ {
+ return m_oValues.Contains(oKey);
+ }
+
+ public bool ContainsKey(object oKey)
+ {
+ return m_oValues.ContainsKey(oKey);
+ }
+
+ public IDictionaryEnumerator GetEnumerator()
+ {
+ return m_oValues.GetEnumerator();
+ }
+
+ public void Remove(object oKey)
+ {
+ m_oValues.Remove(oKey);
+ m_oKeys.Remove(oKey);
+ }
+
+ public object this[object oKey]
+ {
+ get{return m_oValues[oKey];}
+ set{m_oValues[oKey] = value;}
+ }
+
+ public ICollection Values
+ {
+ get{return m_oValues.Values;}
+ }
+
+ IEnumerator IEnumerable.GetEnumerator()
+ {
+ return m_oValues.GetEnumerator();
+ }
+
+ void IDisposable.Dispose ()
+ {
+ }
+
+ public SearchResult this[int index]
+ {
+ get
+ {
+ if(Contains(propertyName))
+ {
+ return (PropertyValueCollection)m_oValues[propertyName];
+ }
+ else
+ {
+ PropertyValueCollection _pValColl=new PropertyValueCollection();
+ Add((string)propertyName, (PropertyValueCollection)_pValColl);
+ return _pValColl;
+ }
+// throw new InvalidOperationException();
+ }
+ }
+
+ }
+}
+
diff --git a/mcs/class/System.DirectoryServices/System.DirectoryServices/SearchScope.cs b/mcs/class/System.DirectoryServices/System.DirectoryServices/SearchScope.cs
new file mode 100644
index 00000000000..dd213462dc1
--- /dev/null
+++ b/mcs/class/System.DirectoryServices/System.DirectoryServices/SearchScope.cs
@@ -0,0 +1,48 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc., www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+
+//
+// System.DirectoryServices.SearchScope.cs
+//
+// Author:
+// Sunil Kumar (sunilk@novell.com)
+//
+// (C) Novell Inc.
+//
+
+namespace System.DirectoryServices
+{
+
+ /// <summary>
+ /// Specifies the possible scopes for a directory search.
+ /// </summary>
+ [Serializable]
+ public enum SearchScope
+ {
+ Base,
+ OneLevel,
+ Subtree
+ }
+
+}
+
diff --git a/mcs/class/System.DirectoryServices/System.DirectoryServices/SortDirection.cs b/mcs/class/System.DirectoryServices/System.DirectoryServices/SortDirection.cs
new file mode 100644
index 00000000000..548c2efa32a
--- /dev/null
+++ b/mcs/class/System.DirectoryServices/System.DirectoryServices/SortDirection.cs
@@ -0,0 +1,47 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc., www.novell.com
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the Software), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*******************************************************************************/
+
+//
+// System.DirectoryServices.SortDirection .cs
+//
+// Author:
+// Sunil Kumar (sunilk@novell.com)
+//
+// (C) Novell Inc.
+//
+
+namespace System.DirectoryServices
+{
+
+ /// <summary>
+ /// Specifies how to sort the results of an Active Directory query.
+ /// </summary>
+ [Serializable]
+ public enum SortDirection
+ {
+ Ascending,
+ Descending
+ }
+
+}
+
diff --git a/mcs/class/System.Drawing/Assembly/ChangeLog b/mcs/class/System.Drawing/Assembly/ChangeLog
index 27bc6fb03f6..23091ac70de 100644
--- a/mcs/class/System.Drawing/Assembly/ChangeLog
+++ b/mcs/class/System.Drawing/Assembly/ChangeLog
@@ -1,3 +1,7 @@
+2003-11-13 Andreas Nahr <ClassDevelopment@A-SoftTech.com>
+
+ * Consts.cs: Added
+
2003-07-17 Andreas Nahr <ClassDevelopment@A-SoftTech.com>
* AssemblyInfo.cs: Added
diff --git a/mcs/class/System.Drawing/Assembly/Consts.cs b/mcs/class/System.Drawing/Assembly/Consts.cs
new file mode 100644
index 00000000000..2db814ab56a
--- /dev/null
+++ b/mcs/class/System.Drawing/Assembly/Consts.cs
@@ -0,0 +1,48 @@
+//
+// Consts.cs
+//
+// Author:
+// Andreas Nahr (ClassDevelopment@A-SoftTech.com)
+//
+// (C) 2003 Andreas Nahr
+//
+// NOTE:
+// Ensure that every constant is defined for every version symbol!
+//
+
+// This class contains constants that are dependent on the defined symbols
+// Use it to shorten and make code more maintainable in situations like:
+//
+//#if (NET_1_0)
+// [Designer ("System.Diagnostics.Design.ProcessDesigner, System.Design, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", typeof (IDesigner))]
+//#endif
+//#if (NET_1_1)
+// [Designer ("System.Diagnostics.Design.ProcessDesigner, System.Design, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", typeof (IDesigner))]
+//#endif
+//
+// by changing them into:
+//
+// [Designer ("System.Diagnostics.Design.ProcessDesigner, " + Consts.AssemblySystem_Design, typeof (IDesigner))]
+//
+
+internal sealed class Consts
+{
+
+ private Consts ()
+ {
+ }
+
+#if (NET_1_0)
+
+ public const string AssemblySystem_Drawing_Design = "System.Drawing.Design, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
+
+//#elif (NET_1_1)
+#else
+ // NET_1_1 is seen as default if somebody 'forgets' to specify any of the symbols
+ // to ensure we are not breaking the build in this case
+
+ public const string AssemblySystem_Drawing_Design = "System.Drawing.Design, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
+
+#endif
+
+} \ No newline at end of file
diff --git a/mcs/class/System.Drawing/ChangeLog b/mcs/class/System.Drawing/ChangeLog
index 22efa0806c3..fc4aa862440 100644
--- a/mcs/class/System.Drawing/ChangeLog
+++ b/mcs/class/System.Drawing/ChangeLog
@@ -1,3 +1,7 @@
+2003-11-13 Andreas Nahr <ClassDevelopment@A-SoftTech.com>
+
+ * System.Drawing.dll.sources: MetafileHeader added (was missing), Consts.cs added
+
2003-10-14 Bernie Solomon <bernard@ugsolutions.com>
* Makefile do not build gdiplus on Windows
diff --git a/mcs/class/System.Drawing/System.Drawing.Drawing2D/Blend.cs b/mcs/class/System.Drawing/System.Drawing.Drawing2D/Blend.cs
index 2a803c67b81..e11fcedbfa5 100644
--- a/mcs/class/System.Drawing/System.Drawing.Drawing2D/Blend.cs
+++ b/mcs/class/System.Drawing/System.Drawing.Drawing2D/Blend.cs
@@ -68,7 +68,7 @@ namespace System.Drawing.Drawing2D
}
public float [] Positions{
get {
- return Positions;
+ return positions;
}
set{
count = value.GetUpperBound(0) + 1;
diff --git a/mcs/class/System.Drawing/System.Drawing.Drawing2D/ChangeLog b/mcs/class/System.Drawing/System.Drawing.Drawing2D/ChangeLog
index 35ea86d887c..dc67c84467f 100644
--- a/mcs/class/System.Drawing/System.Drawing.Drawing2D/ChangeLog
+++ b/mcs/class/System.Drawing/System.Drawing.Drawing2D/ChangeLog
@@ -1,3 +1,31 @@
+2003-11-22 Duncan Mak <duncan@ximian.com>
+
+ * Matrix.cs: Rewrote to use GDI+ implementation, doing all the
+ math in unmanaged code instead of doing it in C#.
+
+2003-11-04 Miguel de Icaza <miguel@ximian.com>
+
+ * GraphicsPathIterator.cs: Do not make this protected.
+
+2003-11-13 Andreas Nahr <ClassDevelopment@A-SoftTech.com>
+
+ * QualityMode.cs: Fixed typo
+ * InterpolationMode.cs: Fixed typo
+ * RegionData.cs: Fixed signatures, partially implemented
+ * PathGradientBrush.cs: Fixed signatures
+ * PathData.cs: Fixed signature, implemented
+ * LinearGradientBrush.cs: Added missing MonoTODOs, fixed typo
+ * GraphicsContainer.cs: Added private constructor
+ * CustomLineCap.cs: Fixed typos, fixed inheritance, removed unneeded member
+
+2003-11-11 Ben Maurer <bmaurer@users.sourceforge.net>
+
+ * ColorBlend.cs (Positions): another one.
+
+2003-11-11 Ben Maurer <bmaurer@users.sourceforge.net>
+
+ * Blend.cs (Positions): recursion in prop.
+
2003-10-24 Miguel de Icaza <miguel@ximian.com>
* GraphicsPath.cs: Stub some more.
diff --git a/mcs/class/System.Drawing/System.Drawing.Drawing2D/ColorBlend.cs b/mcs/class/System.Drawing/System.Drawing.Drawing2D/ColorBlend.cs
index ea9dd4c8443..c574228b3d8 100644
--- a/mcs/class/System.Drawing/System.Drawing.Drawing2D/ColorBlend.cs
+++ b/mcs/class/System.Drawing/System.Drawing.Drawing2D/ColorBlend.cs
@@ -68,7 +68,7 @@ namespace System.Drawing.Drawing2D
public float [] Positions{
get {
- return Positions;
+ return positions;
}
set{
count = value.GetUpperBound(0) + 1;
diff --git a/mcs/class/System.Drawing/System.Drawing.Drawing2D/CustomLineCap.cs b/mcs/class/System.Drawing/System.Drawing.Drawing2D/CustomLineCap.cs
index f840345d9c4..35fb4286ebb 100644
--- a/mcs/class/System.Drawing/System.Drawing.Drawing2D/CustomLineCap.cs
+++ b/mcs/class/System.Drawing/System.Drawing.Drawing2D/CustomLineCap.cs
@@ -1,8 +1,9 @@
//
// System.Drawing.Drawing2D.CustomLineCap.cs
//
-// Author:
-// Dennis Hayes (dennish@Raytek.com)
+// Authors:
+// Dennis Hayes (dennish@Raytek.com)
+// Andreas Nahr (ClassDevelopment@A-SoftTech.com)
//
// (C) 2002/3 Ximian, Inc
//
@@ -12,9 +13,9 @@ namespace System.Drawing.Drawing2D {
/// <summary>
/// Summary description for CustomLineCap.
/// </summary>
- public class CustomLineCap {// : MarshalByRefObject, ICloneable, IDisposable {
+ public class CustomLineCap : MarshalByRefObject, ICloneable, IDisposable {
private LineCap baseCap;
- private float baseInsert;
+ private float baseInset;
private LineJoin strokeJoin;
private float widthScale;
@@ -23,7 +24,7 @@ namespace System.Drawing.Drawing2D {
protected CustomLineCap() {
}
public CustomLineCap(GraphicsPath fillPAth, GraphicsPath strokePath, LineCap baseCap, float baseInset) {
- this.baseInsert = baseInsert;
+ this.baseInset = baseInset;
}
public CustomLineCap(GraphicsPath fillPAth, GraphicsPath strokePAth, LineCap baseCap) {
this.baseCap = baseCap;
@@ -47,12 +48,12 @@ namespace System.Drawing.Drawing2D {
strokeJoin = value;
}
}
- public float BaseInsert{
+ public float BaseInset{
get {
- return baseInsert;
+ return baseInset;
}
set {
- baseInsert = value;
+ baseInset = value;
}
}
@@ -68,9 +69,10 @@ namespace System.Drawing.Drawing2D {
//Public Methods
// Implment IConeable.Clone
- //public virtural object Clone(){
- // //CustomLineCap newcustomlinecap = new CustomLineCap(
- //}
+ public object Clone(){
+ //FIXME
+ return new CustomLineCap();
+ }
public virtual void Dispose(){
Dispose(true);
@@ -85,10 +87,5 @@ namespace System.Drawing.Drawing2D {
public void SetStrokeCaps(LineCap startCap, LineCap endCap){
}
-
- // Protected Methods
-
- ~CustomLineCap(){
- }
}
}
diff --git a/mcs/class/System.Drawing/System.Drawing.Drawing2D/GraphicsContainer.cs b/mcs/class/System.Drawing/System.Drawing.Drawing2D/GraphicsContainer.cs
index 5dde4b3200e..97c2a42b507 100644
--- a/mcs/class/System.Drawing/System.Drawing.Drawing2D/GraphicsContainer.cs
+++ b/mcs/class/System.Drawing/System.Drawing.Drawing2D/GraphicsContainer.cs
@@ -1,8 +1,9 @@
//
// System.Drawing.Drawing2D.GraphicsContainer.cs
//
-// Author:
-// Dennis Hayes (dennish@Raytek.com)
+// Authors:
+// Dennis Hayes (dennish@Raytek.com)
+// Andreas Nahr (ClassDevelopment@A-SoftTech.com)
//
// (C) 2002/3 Ximian, Inc
//
@@ -13,6 +14,8 @@ namespace System.Drawing.Drawing2D {
/// Summary description for GraphicsContainer.
/// </summary>
public sealed class GraphicsContainer : MarshalByRefObject {
- //Everything is inherited!
+ private GraphicsContainer ()
+ {
+ }
}
}
diff --git a/mcs/class/System.Drawing/System.Drawing.Drawing2D/InterpolationMode.cs b/mcs/class/System.Drawing/System.Drawing.Drawing2D/InterpolationMode.cs
index 36427b5ac33..00f9b0ca783 100644
--- a/mcs/class/System.Drawing/System.Drawing.Drawing2D/InterpolationMode.cs
+++ b/mcs/class/System.Drawing/System.Drawing.Drawing2D/InterpolationMode.cs
@@ -22,6 +22,6 @@ namespace System.Drawing.Drawing2D {
HighQualityBilinear = 6,
Invalid = -1,
Low = 1,
- NearestNeighbour = 5
+ NearestNeighbor = 5
}
}
diff --git a/mcs/class/System.Drawing/System.Drawing.Drawing2D/LinearGradientBrush.cs b/mcs/class/System.Drawing/System.Drawing.Drawing2D/LinearGradientBrush.cs
index 44fff8831a2..412738f78c6 100644
--- a/mcs/class/System.Drawing/System.Drawing.Drawing2D/LinearGradientBrush.cs
+++ b/mcs/class/System.Drawing/System.Drawing.Drawing2D/LinearGradientBrush.cs
@@ -31,7 +31,8 @@ namespace System.Drawing.Drawing2D
}
- //public Properties
+ //public Properties
+ [MonoTODO()]
public Blend Blend {
get {
throw new NotImplementedException ();
@@ -39,7 +40,8 @@ namespace System.Drawing.Drawing2D
set {
}
}
-
+
+ [MonoTODO()]
public bool GammaCorrection {
get {
throw new NotImplementedException ();
@@ -47,7 +49,8 @@ namespace System.Drawing.Drawing2D
set {
}
}
-
+
+ [MonoTODO()]
public ColorBlend InterpolationColors {
get {
throw new NotImplementedException ();
@@ -64,12 +67,16 @@ namespace System.Drawing.Drawing2D
linear_colors[0] = value[0];
linear_colors[1] = value[1];
}
- }
- public RectangleF Rectange {
+ }
+
+ [MonoTODO()]
+ public RectangleF Rectangle {
get {
throw new NotImplementedException ();
}
- }
+ }
+
+ [MonoTODO()]
public Matrix Transform {
get {
throw new NotImplementedException ();
@@ -77,7 +84,8 @@ namespace System.Drawing.Drawing2D
set {
}
}
-
+
+ [MonoTODO()]
public WrapMode WrapMode {
get {
throw new NotImplementedException ();
@@ -87,27 +95,33 @@ namespace System.Drawing.Drawing2D
}
// Public Methods
-
+
+ [MonoTODO()]
public override object Clone (){
throw new NotImplementedException ();
}
-
+
+ [MonoTODO()]
public void MultiplyTransform (Matrix matrix){
throw new NotImplementedException ();
}
-
+
+ [MonoTODO()]
public void MultiplyTransform (Matrix matrix, MatrixOrder order){
throw new NotImplementedException ();
}
-
+
+ [MonoTODO()]
public void ResetTransform (){
throw new NotImplementedException ();
}
-
+
+ [MonoTODO()]
public void RotateTransform (float angle, MatrixOrder order){
throw new NotImplementedException ();
}
-
+
+ [MonoTODO()]
public void RotateTransform (float angle){
throw new NotImplementedException ();
}
diff --git a/mcs/class/System.Drawing/System.Drawing.Drawing2D/Matrix.cs b/mcs/class/System.Drawing/System.Drawing.Drawing2D/Matrix.cs
index a3b4ddccaec..d12587ab975 100644
--- a/mcs/class/System.Drawing/System.Drawing.Drawing2D/Matrix.cs
+++ b/mcs/class/System.Drawing/System.Drawing.Drawing2D/Matrix.cs
@@ -4,6 +4,7 @@
// Author:
// Stefan Maierhofer <sm@cg.tuwien.ac.at>
// Dennis Hayes (dennish@Raytek.com)
+// Duncan Mak (duncan@ximian.com)
//
// (C) Ximian, Inc. http://www.ximian.com
//
@@ -14,441 +15,251 @@ using System.Runtime.InteropServices;
namespace System.Drawing.Drawing2D
{
- public sealed class Matrix : MarshalByRefObject, IDisposable
- {
- // initialize to identity
- private float[] m = {1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f};
-
- // constructors
- public Matrix() { }
-
- /* TODO: depends on System.Drawing.Drawing2D.Rectangle
- public Matrix(Rectangle rect , Point[] plgpts)
- {
- // TODO
- }
- */
-
- /* TODO: depends on System.Drawing.Drawing2D.RectangleF
- public Matrix(RectangleF rect , PointF[] pa)
- {
- // TODO
- }
- */
- public Matrix(float m11, float m12,
- float m21, float m22,
- float dx, float dy)
- {
- m[0] = m11; m[1] = m12;
- m[2] = m21; m[3] = m22;
- m[4] = dx; m[5] = dy;
- }
-
- // properties
- public float[] Elements
- {
- get { return m; }
- }
-
- public bool IsIdentity
- {
- get
- {
- if ( (m[0] == 1.0f) && (m[1] == 0.0f) &&
- (m[2] == 0.0f) && (m[3] == 1.0f) &&
- (m[4] == 0.0f) && (m[5] == 0.0f) )
- return true;
- else
- return false;
- }
- }
-
- public bool IsInvertible
- {
- get
- {
- // matrix M is invertible if det(M) != 0
- float det = m[0] * m[3] - m[2] * m[1];
- if (det != 0.0f) return true;
- else return false;
- }
- }
-
- public float OffsetX
+ public sealed class Matrix : MarshalByRefObject, IDisposable
{
- get { return m[4]; }
- }
-
- public float OffsetY
- {
- get { return m[5]; }
- }
-
- // methods
- public Matrix Clone()
- {
- return new Matrix(m[0], m[1], m[2], m[3], m[4], m[5]);
- }
-
- public void Dispose() { }
-
- public override bool Equals(object obj)
- {
- if (obj is Matrix)
- {
- float[] a = ((Matrix)obj).Elements;
- if ( m[0] == a[0] && m[1] == a[1] &&
- m[2] == a[2] && m[3] == a[3] &&
- m[4] == a[4] && m[5] == a[5] )
- return true;
- else
- return false;
- }
- else
- {
- return false;
- }
- }
+ internal IntPtr nativeMatrix;
+
+ // constructors
+ Matrix (IntPtr ptr)
+ {
+ nativeMatrix = ptr;
+ }
+
+ public Matrix ()
+ {
+ Status s = GDIPlus.GdipCreateMatrix (out nativeMatrix);
+ }
- ~Matrix() {}
+ public Matrix (Rectangle rect , Point[] plgpts)
+ {
+ GpRect rectangle = new GpRect (rect);
+
+ GDIPlus.GdipCreateMatrix3I (rectangle, plgpts, out nativeMatrix);
+ }
- [StructLayout(LayoutKind.Explicit)]
- internal struct BitConverter
- {
- [FieldOffset(0)] public float f;
- [FieldOffset(0)] public int i;
- }
+ public Matrix (RectangleF rect , PointF[] pa)
+ {
+ GpRectF rectangle = new GpRectF (rect);
+
+ GDIPlus.GdipCreateMatrix3 (rectangle, pa, out nativeMatrix);
+ }
+
+ public Matrix (float m11, float m12, float m21, float m22, float dx, float dy)
+ {
+ GDIPlus.GdipCreateMatrix2 (m11, m12, m21, m22, dx, dy, out nativeMatrix);
+ }
- public override int GetHashCode()
- {
- BitConverter b;
- // compiler is not smart
- b.i = 0;
- int h = 0;
- for (int i = 0; i < 6; i++)
- {
- b.f = m[i];
- h ^= b.i >> i;
- }
- return h;
- }
+ // properties
+ public float[] Elements {
+ get {
+ IntPtr tmp = Marshal.AllocHGlobal (8 * 6);
+
+ Status s = GDIPlus.GdipGetMatrixElements (nativeMatrix, tmp);
+
+ float [] retval = new float [6];
+
+ Marshal.Copy (tmp, retval, 0, 6);
+
+ Marshal.FreeHGlobal (tmp);
+ return retval;
+ }
+ }
+
+ public bool IsIdentity {
+ get {
+ bool retval;
+ GDIPlus.GdipIsMatrixIdentity (nativeMatrix, out retval);
+
+ return retval;
+ }
+ }
+
+ public bool IsInvertible {
+ get {
+ bool retval;
+ GDIPlus.GdipIsMatrixInvertible (nativeMatrix, out retval);
+
+ return retval;
+ }
+ }
+
+ public float OffsetX {
+ get {
+ return this.Elements [4];
+ }
+ }
+
+ public float OffsetY {
+ get {
+ return this.Elements [5];
+ }
+ }
+
+ public Matrix Clone()
+ {
+ IntPtr retval;
+ Status s = GDIPlus.GdipCloneMatrix (nativeMatrix, out retval);
+ return new Matrix (retval);
+ }
+
- public void Invert()
- {
- float det = m[0] * m[3] - m[2] * m[1];
- if (det != 0.0f) // if invertible
- {
- float[] r =
+ public void Dispose ()
{
- m[3] / det,
- -m[1] / det,
- -m[2] / det,
- m[0] / det,
- (-m[3] * m[4] + m[1] * m[5]) / det,
- (m[2] * m[4] - m[0] * m[5]) / det
- };
- m = r;
- }
- }
+ GDIPlus.GdipDeleteMatrix (nativeMatrix);
+ }
- public void Multiply(Matrix matrix)
- {
- Multiply(matrix, MatrixOrder.Prepend);
- }
+ public override bool Equals (object obj)
+ {
+ Matrix m = obj as Matrix;
+
+ if (m != null) {
+ bool retval;
+ GDIPlus.GdipIsMatrixEqual (nativeMatrix, m.nativeMatrix, out retval);
+
+ return retval;
+
+ } else
+ return false;
+ }
- public void Multiply(Matrix matrix, MatrixOrder order)
- {
- switch (order)
- {
- case MatrixOrder.Prepend:
- // this = matrix * this
- float[] p = matrix.Elements;
- float[] r0 =
- {
- p[0] * m[0] + p[1] * m[2],
- p[0] * m[1] + p[1] * m[3],
- p[2] * m[0] + p[3] * m[2],
- p[2] * m[1] + p[3] * m[3],
- p[4] * m[0] + p[5] * m[2] + m[4],
- p[4] * m[1] + p[5] * m[3] + m[5]
- };
- m = r0;
- break;
- case MatrixOrder.Append:
- // this = this * matrix
- float[] a = matrix.Elements;
- float[] r1 =
- {
- m[0] * a[0] + m[1] * a[2],
- m[0] * a[1] + m[1] * a[3],
- m[2] * a[0] + m[3] * a[2],
- m[2] * a[1] + m[3] * a[3],
- m[4] * a[0] + m[5] * a[2] + a[4],
- m[4] * a[1] + m[5] * a[3] + a[5]
- };
- m = r1;
- break;
- }
- }
+ ~Matrix()
+ {
+ Dispose ();
+ }
+
+ public override int GetHashCode ()
+ {
+ return base.GetHashCode ();
+ }
- public void Reset()
- {
- m[0] = 1.0f; m[1] = 0.0f;
- m[2] = 0.0f; m[3] = 1.0f;
- m[4] = 0.0f; m[5] = 0.0f;
- }
+ public void Invert ()
+ {
+ GDIPlus.GdipInvertMatrix (nativeMatrix);
+ }
- public void Rotate(float angle)
- {
- Rotate(angle, MatrixOrder.Prepend);
- }
+ public void Multiply (Matrix matrix)
+ {
+ Multiply (matrix, MatrixOrder.Prepend);
+ }
- public void Rotate(float angle, MatrixOrder order)
- {
- angle *= (float)(Math.PI / 180.0); // degrees to randians
- float cos = (float)Math.Cos(angle);
- float sin = (float)Math.Sin(angle);
- switch (order)
- {
- case MatrixOrder.Prepend:
- // this = rotation * this
- float[] r0 =
- {
- cos * m[0] + sin * m[2],
- cos * m[1] + sin * m[3],
- -sin * m[0] + cos * m[2],
- -sin * m[1] + cos * m[3],
- m[4],
- m[5]
- };
- m = r0;
- break;
- case MatrixOrder.Append:
- // this = this * rotation
- float[] r1 =
- {
- m[0] * cos + m[1] * -sin,
- m[0] * sin + m[1] * cos,
- m[2] * cos + m[3] * -sin,
- m[2] * sin + m[3] * cos,
- m[4] * cos + m[5] * -sin,
- m[4] * sin + m[5] * cos
- };
- m = r1;
- break;
- }
- }
+ public void Multiply (Matrix matrix, MatrixOrder order)
+ {
+ GDIPlus.GdipMultiplyMatrix (nativeMatrix, matrix.nativeMatrix, order);
+ }
- public void RotateAt(float angle, PointF point)
- {
- RotateAt(angle, point, MatrixOrder.Prepend);
- }
+ public void Reset()
+ {
+ GDIPlus.GdipSetMatrixElements (nativeMatrix, 1, 0, 0, 1, 0, 0);
+ }
+
+ public override string ToString ()
+ {
+ System.Text.StringBuilder sb = new System.Text.StringBuilder ();
+ sb.Append ("(");
+ sb.Append (Elements [0] + " ");
+ sb.Append (Elements [1] + " ");
+ sb.Append (Elements [2] + " ");
+ sb.Append (Elements [3] + " ");
+ sb.Append (Elements [4] + " ");
+ sb.Append (Elements [5] + ")");
+ return sb.ToString ();
+ }
+
+ public void Rotate (float angle)
+ {
+ Rotate (angle, MatrixOrder.Prepend);
+ }
- public void RotateAt(float angle, PointF point, MatrixOrder order)
- {
- angle *= (float)(Math.PI / 180.0); // degrees to randians
- float cos = (float)Math.Cos(angle);
- float sin = (float)Math.Sin(angle);
- float e4 = -point.X * cos + point.Y * sin + point.X;
- float e5 = -point.X * sin - point.Y * cos + point.Y;
- switch (order)
- {
- case MatrixOrder.Prepend:
- // this = rotation * this
- float[] r0 =
- {
- cos * m[0] + sin * m[2],
- cos * m[1] + sin * m[3],
- -sin * m[0] + cos * m[2],
- -sin * m[1] + cos * m[3],
- e4 * m[0] + e5 * m[2] + m[4],
- e4 * m[1] + e5 * m[3] + m[5]
- };
- m = r0;
- break;
- case MatrixOrder.Append:
- // this = this * rotation
- float[] r1 =
- {
- m[0] * cos + m[1] * -sin,
- m[0] * sin + m[1] * cos,
- m[2] * cos + m[3] * -sin,
- m[2] * sin + m[3] * cos,
- m[4] * cos + m[5] * -sin + e4,
- m[4] * sin + m[5] * cos + e5
- };
- m = r1;
- break;
- }
- }
+ public void Rotate (float angle, MatrixOrder order)
+ {
+ GDIPlus.GdipRotateMatrix (nativeMatrix, angle, order);
+ }
- public void Scale(float scaleX, float scaleY)
- {
- Scale(scaleX, scaleY, MatrixOrder.Prepend);
- }
+ public void RotateAt (float angle, PointF point)
+ {
+ RotateAt (angle, point, MatrixOrder.Prepend);
+ }
- public void Scale(float scaleX, float scaleY, MatrixOrder order)
- {
- switch (order)
- {
- case MatrixOrder.Prepend:
- // this = scale * this
- m[0] *= scaleX; m[1] *= scaleX;
- m[2] *= scaleY; m[3] *= scaleY;
- break;
- case MatrixOrder.Append:
- // this = this * scale
- m[0] *= scaleX; m[1] *= scaleY;
- m[2] *= scaleX; m[3] *= scaleY;
- m[4] *= scaleX; m[5] *= scaleY;
- break;
- }
- }
+ public void RotateAt (float angle, PointF point, MatrixOrder order)
+ {
+ angle *= (float) (Math.PI / 180.0); // degrees to radians
+ float cos = (float) Math.Cos (angle);
+ float sin = (float) Math.Sin (angle);
+ float e4 = -point.X * cos + point.Y * sin + point.X;
+ float e5 = -point.X * sin - point.Y * cos + point.Y;
+ float[] m = this.Elements;
+
+ if (order == MatrixOrder.Prepend)
+ GDIPlus.GdipSetMatrixElements (nativeMatrix,
+ cos * m[0] + sin * m[2],
+ cos * m[1] + sin * m[3],
+ -sin * m[0] + cos * m[2],
+ -sin * m[1] + cos * m[3],
+ e4 * m[0] + e5 * m[2] + m[4],
+ e4 * m[1] + e5 * m[3] + m[5]);
+ else
+ GDIPlus.GdipSetMatrixElements (nativeMatrix,
+ m[0] * cos + m[1] * -sin,
+ m[0] * sin + m[1] * cos,
+ m[2] * cos + m[3] * -sin,
+ m[2] * sin + m[3] * cos,
+ m[4] * cos + m[5] * -sin + e4,
+ m[4] * sin + m[5] * cos + e5);
+ }
+
+ public void Scale (float scaleX, float scaleY)
+ {
+ Scale (scaleX, scaleY, MatrixOrder.Prepend);
+ }
- public void Shear(float shearX, float shearY)
- {
- Shear(shearX, shearY, MatrixOrder.Prepend);
- }
+ public void Scale (float scaleX, float scaleY, MatrixOrder order)
+ {
+ GDIPlus.GdipScaleMatrix (nativeMatrix, scaleX, scaleY, order);
+ }
- // LAMESPEC: quote from beta 2 sdk docs: "[To be supplied!]"
- //
- // assuming transformation matrix:
- //
- // (1 shearY 0)
- // (shearX 1 0)
- // (0 0 1)
- //
- public void Shear(float shearX, float shearY, MatrixOrder order)
- {
- switch (order)
- {
- case MatrixOrder.Prepend:
- // this = shear * this
- float[] r0 =
- {
- m[0] + shearY * m[2],
- m[1] + shearY * m[3],
- shearX * m[0] + m[2],
- shearX * m[1] + m[3],
- m[4],
- m[5]
- };
- m = r0;
- break;
- case MatrixOrder.Append:
- // this = this * shear
- float[] r1 =
- {
- m[0] + m[1] * shearX,
- m[0] * shearY + m[1],
- m[2] + m[3] * shearX,
- m[2] * shearY + m[3],
- m[4] + m[5] * shearX ,
- m[4] * shearY + m[5]
- };
- m = r1;
- break;
- }
- }
+ public void Shear (float shearX, float shearY)
+ {
+ Shear (shearX, shearY, MatrixOrder.Prepend);
+ }
- public void TransformPoints(Point[] pts)
- {
- for (int i = 0; i < pts.Length; i++)
- {
- float x = (float)pts[i].X;
- float y = (float)pts[i].Y;
- pts[i].X = (int)(x * m[0] + y * m[2] + m[4]);
- pts[i].Y = (int)(x * m[1] + y * m[3] + m[5]);
- }
- }
+ public void Shear (float shearX, float shearY, MatrixOrder order)
+ {
+ GDIPlus.GdipShearMatrix (nativeMatrix, shearX, shearY, order);
+ }
- public void TransformPoints(PointF[] pts)
- {
- for (int i = 0; i < pts.Length; i++)
- {
- float x = pts[i].X;
- float y = pts[i].Y;
- pts[i].X = x * m[0] + y * m[2] + m[4];
- pts[i].Y = x * m[1] + y * m[3] + m[5];
- }
- }
+ public void TransformPoints (Point[] pts)
+ {
+ GDIPlus.GdipTransformMatrixPointsI (nativeMatrix, pts, pts.Length);
+ }
- public void TransformVectors(Point[] pts)
- {
- for (int i = 0; i < pts.Length; i++)
- {
- float x = (float)pts[i].X;
- float y = (float)pts[i].Y;
- pts[i].X = (int)(x * m[0] + y * m[2]);
- pts[i].Y = (int)(x * m[1] + y * m[3]);
- }
- }
+ public void TransformPoints (PointF[] pts)
+ {
+ GDIPlus.GdipTransformMatrixPoints (nativeMatrix, pts, pts.Length);
+ }
- public void TransformVectors(PointF[] pts)
- {
- for (int i = 0; i < pts.Length; i++)
- {
- float x = pts[i].X;
- float y = pts[i].Y;
- pts[i].X = x * m[0] + y * m[2];
- pts[i].Y = x * m[1] + y * m[3];
- }
- }
+ public void TransformVectors (Point[] pts)
+ {
+ GDIPlus.GdipVectorTransformMatrixPointsI (nativeMatrix, pts, pts.Length);
+ }
- public void Translate(float offsetX, float offsetY)
- {
- Translate(offsetX, offsetY, MatrixOrder.Prepend);
- }
+ public void TransformVectors (PointF[] pts)
+ {
+ GDIPlus.GdipVectorTransformMatrixPoints (nativeMatrix, pts, pts.Length);
+ }
- public void Translate(float offsetX, float offsetY, MatrixOrder order)
- {
- switch (order)
- {
- case MatrixOrder.Prepend:
- // this = translation * this
- m[4] = offsetX * m[0] + offsetY * m[2] + m[4];
- m[5] = offsetX * m[1] + offsetY * m[3] + m[5];
- break;
- case MatrixOrder.Append:
- // this = this * translation
- m[4] += offsetX;
- m[5] += offsetY;
- break;
- }
- }
+ public void Translate (float offsetX, float offsetY)
+ {
+ Translate (offsetX, offsetY, MatrixOrder.Prepend);
+ }
- // LAMESPEC: quote from beta 2 sdk docs: "[To be supplied!]"
-// [MonoTODO]
- public void VectorTransformPoints(Point[] pts)
- {
- // TODO
- }
+ public void Translate (float offsetX, float offsetY, MatrixOrder order)
+ {
+ GDIPlus.GdipTranslateMatrix (nativeMatrix, offsetX, offsetY, order);
+ }
- // some simple test (TODO: remove)
- /*
- public static void Main()
- {
- PointF[] p = {new PointF(1.0f, 2.0f)};
- Console.WriteLine("(" + p[0].X + " " + p[0].Y + ")");
- Matrix m = new Matrix();
-
- m.Translate(1.0f, 1.0f);
- m.Scale(2.0f, 2.0f);
- m.Rotate(180.0f);
-
- m.TransformPoints(p);
- Console.WriteLine("(" + p[0].X + " " + p[0].Y + ")");
- m.Invert();
- m.TransformPoints(p);
- Console.WriteLine("(" + p[0].X + " " + p[0].Y + ")");
-
- Matrix a = new Matrix(1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f);
- Matrix b = new Matrix(2.0f, 0.0f, 0.0f, 2.0f, 0.0f, 0.0f);
-
- Console.WriteLine("h(a) = " + a.GetHashCode());
- Console.WriteLine("h(b) = " + b.GetHashCode());
+ public void VectorTransformPoints (Point[] pts)
+ {
+ TransformVectors (pts);
+ }
}
- */
-
- }
}
diff --git a/mcs/class/System.Drawing/System.Drawing.Drawing2D/PathData.cs b/mcs/class/System.Drawing/System.Drawing.Drawing2D/PathData.cs
index 60a1deb12f4..b1f28ce08c5 100644
--- a/mcs/class/System.Drawing/System.Drawing.Drawing2D/PathData.cs
+++ b/mcs/class/System.Drawing/System.Drawing.Drawing2D/PathData.cs
@@ -1,11 +1,13 @@
//
// System.Drawing.Drawing2D.PathData.cs
//
-// Author:
-// Dennis Hayes (dennish@Raytek.com)
+// Authors:
+// Dennis Hayes (dennish@Raytek.com)
+// Andreas Nahr (ClassDevelopment@A-SoftTech.com)
//
// (C) 2002/3 Ximian, Inc
-//
+//
+
using System;
namespace System.Drawing.Drawing2D
@@ -13,10 +15,24 @@ namespace System.Drawing.Drawing2D
/// <summary>
/// Summary description for PathData.
/// </summary>
- public class PathData
- {
+ public sealed class PathData
+ {
+
+ PointF[] points = null;
+ byte[] types = null;
+
public PathData()
{
+ }
+
+ public PointF[] Points {
+ get { return points; }
+ set { points = value; }
+ }
+
+ public byte[] Types {
+ get { return types; }
+ set { types = value; }
}
}
}
diff --git a/mcs/class/System.Drawing/System.Drawing.Drawing2D/PathGradientBrush.cs b/mcs/class/System.Drawing/System.Drawing.Drawing2D/PathGradientBrush.cs
index 99d1eeff68a..aec58b4b219 100644
--- a/mcs/class/System.Drawing/System.Drawing.Drawing2D/PathGradientBrush.cs
+++ b/mcs/class/System.Drawing/System.Drawing.Drawing2D/PathGradientBrush.cs
@@ -1,8 +1,9 @@
//
// System.Drawing.Drawing2D.PathGradientBrush.cs
//
-// Author:
-// Dennis Hayes (dennish@Raytek.com)
+// Authors:
+// Dennis Hayes (dennish@Raytek.com)
+// Andreas Nahr (ClassDevelopment@A-SoftTech.com)
//
// (C) 2002/3 Ximian, Inc
//
@@ -13,10 +14,16 @@ namespace System.Drawing.Drawing2D
/// <summary>
/// Summary description for PathGradientBrush.
/// </summary>
- public class PathGradientBrush
+ public sealed class PathGradientBrush : Brush
{
- public PathGradientBrush()
+ internal PathGradientBrush()
{
+ }
+
+ [MonoTODO("implement")]
+ public override object Clone ()
+ {
+ throw new NotImplementedException ();
}
}
}
diff --git a/mcs/class/System.Drawing/System.Drawing.Drawing2D/QualityMode.cs b/mcs/class/System.Drawing/System.Drawing.Drawing2D/QualityMode.cs
index 29f619b3caa..8c986092e4d 100644
--- a/mcs/class/System.Drawing/System.Drawing.Drawing2D/QualityMode.cs
+++ b/mcs/class/System.Drawing/System.Drawing.Drawing2D/QualityMode.cs
@@ -15,7 +15,7 @@ namespace System.Drawing.Drawing2D {
/// </summary>
public enum QualityMode {
Default = 0,
- Hight = 2,
+ High = 2,
Invalid = -1,
Low = 1
}
diff --git a/mcs/class/System.Drawing/System.Drawing.Drawing2D/RegionData.cs b/mcs/class/System.Drawing/System.Drawing.Drawing2D/RegionData.cs
index ebd92d3db26..aaf7dbdc542 100644
--- a/mcs/class/System.Drawing/System.Drawing.Drawing2D/RegionData.cs
+++ b/mcs/class/System.Drawing/System.Drawing.Drawing2D/RegionData.cs
@@ -1,11 +1,13 @@
//
// System.Drawing.Drawing2D.RegionData.cs
//
-// Author:
-// Dennis Hayes (dennish@Raytek.com)
+// Authors:
+// Dennis Hayes (dennish@Raytek.com)
+// Andreas Nahr (ClassDevelopment@A-SoftTech.com)
//
// (C) 2002/3 Ximian, Inc
-//
+//
+
using System;
namespace System.Drawing.Drawing2D
@@ -13,10 +15,18 @@ namespace System.Drawing.Drawing2D
/// <summary>
/// Summary description for RegionData.
/// </summary>
- public class RegionData
- {
- public RegionData()
+ public sealed class RegionData
+ {
+
+ byte[] data;
+
+ internal RegionData()
{
+ }
+
+ public byte[] Data {
+ get {return data;}
+ set {data = value;}
}
}
}
diff --git a/mcs/class/System.Drawing/System.Drawing.Imaging/BitmapData.cs b/mcs/class/System.Drawing/System.Drawing.Imaging/BitmapData.cs
index a08e082aa9a..c393a0d43c1 100755
--- a/mcs/class/System.Drawing/System.Drawing.Imaging/BitmapData.cs
+++ b/mcs/class/System.Drawing/System.Drawing.Imaging/BitmapData.cs
@@ -78,5 +78,24 @@ namespace System.Drawing.Imaging
stride = value;
}
}
+
+ internal unsafe void swap_red_blue_bytes ()
+ {
+ byte *start = (byte *) (void *) this.Scan0;
+ int stride = this.Stride;
+ for (int line = 0; line < this.Height; line++){
+ // Exchange red <=> blue bytes
+// fixed (byte *pbuf = start) {
+ byte* curByte = start;
+ for (int i = 0; i < this.Width; i++) {
+ byte t = *(curByte+2);
+ *(curByte+2) = *curByte;
+ *curByte = t;
+ curByte += 3;
+ }
+// }
+ start += stride;
+ }
+ }
}
}
diff --git a/mcs/class/System.Drawing/System.Drawing.Imaging/ChangeLog b/mcs/class/System.Drawing/System.Drawing.Imaging/ChangeLog
index 1257d401503..5533dfdb7cb 100644
--- a/mcs/class/System.Drawing/System.Drawing.Imaging/ChangeLog
+++ b/mcs/class/System.Drawing/System.Drawing.Imaging/ChangeLog
@@ -1,3 +1,22 @@
+2003-11-13 Andreas Nahr <ClassDevelopment@A-SoftTech.com>
+
+ * ColorMap.cs: Implemented
+ * ColorMatrix.cs: Implemented, Removed unneccesary members
+ * ImageAttributes.cs: Fixed signature
+ * ImageCodecInfo.cs: Added missing attribure, hide constructor
+ * ImageFormat.cs: Implemented, Added attribute
+ * MetaHeader.cs: Implemented
+ * PropertyItem.cs: Implemented
+ * ImageFlags.cs: Added Attribute
+ * ImageCodecFlags.cs: Added Attribute
+ * EmfPlusRecordType.cs: Added missing members
+
+2003-11-12 Alexandre Pigolkine <pigolkine@gmx.de>
+ * BitmapData.cs new function to convert BRG to RGB
+ * JPEGCodec.cs convert BRG to RBG
+ * PNGCodec.cs
+
+
2003-11-02 Alexandre Pigolkine <pigolkine@gmx.de>
* BmpCodec.cs
* ImageCodecInfo.cs
diff --git a/mcs/class/System.Drawing/System.Drawing.Imaging/ColorMap.cs b/mcs/class/System.Drawing/System.Drawing.Imaging/ColorMap.cs
index 14a2ccc77d5..0380eeee49c 100644
--- a/mcs/class/System.Drawing/System.Drawing.Imaging/ColorMap.cs
+++ b/mcs/class/System.Drawing/System.Drawing.Imaging/ColorMap.cs
@@ -1,11 +1,14 @@
//
// System.Drawing.Imaging.ColorMap.cs
//
-// (C) 2002 Ximian, Inc. http://www.ximian.com
-// Author: Everaldo Canuto
-// eMail: everaldo.canuto@bol.com.br
-// Dennis Hayes (dennish@raytek.com)
-//
+// Authors:
+// Everaldo Canuto (everaldo.canuto@bol.com.br)
+// Andreas Nahr (ClassDevelopment@A-SoftTech.com)
+// Dennis Hayes (dennish@raytek.com)
+//
+// (C) 2002 Ximian, Inc. http://www.ximian.com
+//
+
using System;
using System.IO;
using System.Reflection;
@@ -13,24 +16,23 @@ using System.Reflection;
namespace System.Drawing.Imaging {
public sealed class ColorMap {
+
+ private Color newColor;
+ private Color oldColor;
// constructors
- [MonoTODO]
public ColorMap() {
- throw new NotImplementedException ();
}
// properties
- [MonoTODO]
public Color NewColor {
- get { throw new NotImplementedException (); }
- set { throw new NotImplementedException (); }
+ get { return newColor; }
+ set { newColor = value; }
}
- [MonoTODO]
public Color OldColor {
- get { throw new NotImplementedException (); }
- set { throw new NotImplementedException (); }
+ get { return oldColor; }
+ set { oldColor = value; }
}
}
diff --git a/mcs/class/System.Drawing/System.Drawing.Imaging/ColorMatrix.cs b/mcs/class/System.Drawing/System.Drawing.Imaging/ColorMatrix.cs
index f03b107816e..91b20afbe3a 100644
--- a/mcs/class/System.Drawing/System.Drawing.Imaging/ColorMatrix.cs
+++ b/mcs/class/System.Drawing/System.Drawing.Imaging/ColorMatrix.cs
@@ -1,304 +1,179 @@
//
-// System.Drawing.Imaging.xxx.cs
-//
-// (C) 2002 Ximian, Inc. http://www.ximian.com
-// Author: Everaldo Canuto
-// eMail: everaldo.canuto@bol.com.br
-// Dennis Hayes (dennish@raytek.com)
+// System.Drawing.Imaging.ColorMatrix.cs
//
+// Authors:
+// Everaldo Canuto (everaldo.canuto@bol.com.br)
+// Andreas Nahr (ClassDevelopment@A-SoftTech.com)
+// Dennis Hayes (dennish@raytek.com)
+//
+// (C) 2002 Ximian, Inc. http://www.ximian.com
+//
+
using System;
namespace System.Drawing.Imaging {
public sealed class ColorMatrix {
+
+ float[] colors;
// constructors
- [MonoTODO]
- public ColorMatrix() {
- throw new NotImplementedException ();
+ public ColorMatrix()
+ {
+ colors = new float[25];
+ // Set identity matrix by default
+ colors[0] = 1;
+ colors[6] = 1;
+ colors[12] = 1;
+ colors[18] = 1;
+ colors[24] = 1;
}
- [MonoTODO]
[CLSCompliant(false)]
- public ColorMatrix(float[][] newColorMatrix) {
- throw new NotImplementedException ();
+ public ColorMatrix(float[][] newColorMatrix)
+ {
+ colors = new float[25];
+ for (int x = 0; x < 5; x++) {
+ for (int y = 0; y < 5; y++) {
+ colors[x * 5 + y] = newColorMatrix[x][y];
+ }
+ }
}
// properties
- [MonoTODO]
public float this[int row, int column] {
- get { throw new NotImplementedException (); }
- set { throw new NotImplementedException (); }
+ get { return colors[row * 5 + column]; }
+ set { colors[row * 5 + column] = value; }
}
- [MonoTODO]
+
public float Matrix00 {
- get { throw new NotImplementedException (); }
- set { throw new NotImplementedException (); }
+ get { return colors[0]; }
+ set { colors[0] = value; }
}
- [MonoTODO]
public float Matrix01 {
- get { throw new NotImplementedException (); }
- set { throw new NotImplementedException (); }
+ get { return colors[1]; }
+ set { colors[1] = value; }
}
- [MonoTODO]
public float Matrix02 {
- get { throw new NotImplementedException (); }
- set { throw new NotImplementedException (); }
+ get { return colors[2]; }
+ set { colors[2] = value; }
}
- [MonoTODO]
public float Matrix03 {
- get { throw new NotImplementedException (); }
- set { throw new NotImplementedException (); }
+ get { return colors[3]; }
+ set { colors[3] = value; }
}
- [MonoTODO]
public float Matrix04 {
- get { throw new NotImplementedException (); }
- set { throw new NotImplementedException (); }
- }
-
- [MonoTODO]
- public float Matrix05 {
- get { throw new NotImplementedException (); }
- set { throw new NotImplementedException (); }
- }
-
- [MonoTODO]
- public float Matrix06 {
- get { throw new NotImplementedException (); }
- set { throw new NotImplementedException (); }
- }
-
- [MonoTODO]
- public float Matrix07 {
- get { throw new NotImplementedException (); }
- set { throw new NotImplementedException (); }
- }
-
- [MonoTODO]
- public float Matrix08 {
- get { throw new NotImplementedException (); }
- set { throw new NotImplementedException (); }
+ get { return colors[4]; }
+ set { colors[4] = value; }
}
+
- [MonoTODO]
- public float Matrix09 {
- get { throw new NotImplementedException (); }
- set { throw new NotImplementedException (); }
- }
-
- [MonoTODO]
public float Matrix10 {
- get { throw new NotImplementedException (); }
- set { throw new NotImplementedException (); }
+ get { return colors[5]; }
+ set { colors[5] = value; }
}
- [MonoTODO]
public float Matrix11 {
- get { throw new NotImplementedException (); }
- set { throw new NotImplementedException (); }
+ get { return colors[6]; }
+ set { colors[6] = value; }
}
- [MonoTODO]
public float Matrix12 {
- get { throw new NotImplementedException (); }
- set { throw new NotImplementedException (); }
+ get { return colors[7]; }
+ set { colors[7] = value; }
}
- [MonoTODO]
public float Matrix13 {
- get { throw new NotImplementedException (); }
- set { throw new NotImplementedException (); }
+ get { return colors[8]; }
+ set { colors[8] = value; }
}
- [MonoTODO]
public float Matrix14 {
- get { throw new NotImplementedException (); }
- set { throw new NotImplementedException (); }
- }
-
- [MonoTODO]
- public float Matrix15 {
- get { throw new NotImplementedException (); }
- set { throw new NotImplementedException (); }
- }
-
- [MonoTODO]
- public float Matrix16 {
- get { throw new NotImplementedException (); }
- set { throw new NotImplementedException (); }
+ get { return colors[9]; }
+ set { colors[9] = value; }
}
- [MonoTODO]
- public float Matrix17 {
- get { throw new NotImplementedException (); }
- set { throw new NotImplementedException (); }
- }
- [MonoTODO]
- public float Matrix18 {
- get { throw new NotImplementedException (); }
- set { throw new NotImplementedException (); }
- }
-
- [MonoTODO]
- public float Matrix19 {
- get { throw new NotImplementedException (); }
- set { throw new NotImplementedException (); }
- }
-
- [MonoTODO]
public float Matrix20 {
- get { throw new NotImplementedException (); }
- set { throw new NotImplementedException (); }
+ get { return colors[10]; }
+ set { colors[10] = value; }
}
- [MonoTODO]
public float Matrix21 {
- get { throw new NotImplementedException (); }
- set { throw new NotImplementedException (); }
+ get { return colors[11]; }
+ set { colors[11] = value; }
}
- [MonoTODO]
public float Matrix22 {
- get { throw new NotImplementedException (); }
- set { throw new NotImplementedException (); }
+ get { return colors[12]; }
+ set { colors[12] = value; }
}
- [MonoTODO]
public float Matrix23 {
- get { throw new NotImplementedException (); }
- set { throw new NotImplementedException (); }
+ get { return colors[13]; }
+ set { colors[13] = value; }
}
- [MonoTODO]
public float Matrix24 {
- get { throw new NotImplementedException (); }
- set { throw new NotImplementedException (); }
- }
-
- [MonoTODO]
- public float Matrix25 {
- get { throw new NotImplementedException (); }
- set { throw new NotImplementedException (); }
- }
-
- [MonoTODO]
- public float Matrix26 {
- get { throw new NotImplementedException (); }
- set { throw new NotImplementedException (); }
+ get { return colors[14]; }
+ set { colors[14] = value; }
}
- [MonoTODO]
- public float Matrix27 {
- get { throw new NotImplementedException (); }
- set { throw new NotImplementedException (); }
- }
-
- [MonoTODO]
- public float Matrix28 {
- get { throw new NotImplementedException (); }
- set { throw new NotImplementedException (); }
- }
-
- [MonoTODO]
- public float Matrix29 {
- get { throw new NotImplementedException (); }
- set { throw new NotImplementedException (); }
- }
- [MonoTODO]
public float Matrix30 {
- get { throw new NotImplementedException (); }
- set { throw new NotImplementedException (); }
+ get { return colors[15]; }
+ set { colors[15] = value; }
}
- [MonoTODO]
public float Matrix31 {
- get { throw new NotImplementedException (); }
- set { throw new NotImplementedException (); }
+ get { return colors[16]; }
+ set { colors[16] = value; }
}
- [MonoTODO]
public float Matrix32 {
- get { throw new NotImplementedException (); }
- set { throw new NotImplementedException (); }
+ get { return colors[17]; }
+ set { colors[17] = value; }
}
- [MonoTODO]
public float Matrix33 {
- get { throw new NotImplementedException (); }
- set { throw new NotImplementedException (); }
+ get { return colors[18]; }
+ set { colors[18] = value; }
}
-
- [MonoTODO]
+
public float Matrix34 {
- get { throw new NotImplementedException (); }
- set { throw new NotImplementedException (); }
- }
-
- [MonoTODO]
- public float Matrix35 {
- get { throw new NotImplementedException (); }
- set { throw new NotImplementedException (); }
- }
-
- [MonoTODO]
- public float Matrix36 {
- get { throw new NotImplementedException (); }
- set { throw new NotImplementedException (); }
+ get { return colors[19]; }
+ set { colors[19] = value; }
}
- [MonoTODO]
- public float Matrix37 {
- get { throw new NotImplementedException (); }
- set { throw new NotImplementedException (); }
- }
-
- [MonoTODO]
- public float Matrix38 {
- get { throw new NotImplementedException (); }
- set { throw new NotImplementedException (); }
- }
-
- [MonoTODO]
- public float Matrix39 {
- get { throw new NotImplementedException (); }
- set { throw new NotImplementedException (); }
- }
- [MonoTODO]
public float Matrix40 {
- get { throw new NotImplementedException (); }
- set { throw new NotImplementedException (); }
+ get { return colors[20]; }
+ set { colors[20] = value; }
}
- [MonoTODO]
public float Matrix41 {
- get { throw new NotImplementedException (); }
- set { throw new NotImplementedException (); }
+ get { return colors[21]; }
+ set { colors[21] = value; }
}
- [MonoTODO]
public float Matrix42 {
- get { throw new NotImplementedException (); }
- set { throw new NotImplementedException (); }
+ get { return colors[22]; }
+ set { colors[22] = value; }
}
- [MonoTODO]
public float Matrix43 {
- get { throw new NotImplementedException (); }
- set { throw new NotImplementedException (); }
+ get { return colors[23]; }
+ set { colors[23] = value; }
}
- [MonoTODO]
public float Matrix44 {
- get { throw new NotImplementedException (); }
- set { throw new NotImplementedException (); }
+ get { return colors[24]; }
+ set { colors[24] = value; }
}
}
diff --git a/mcs/class/System.Drawing/System.Drawing.Imaging/EmfPlusRecordType.cs b/mcs/class/System.Drawing/System.Drawing.Imaging/EmfPlusRecordType.cs
index 052604968e7..9f883462bb7 100644
--- a/mcs/class/System.Drawing/System.Drawing.Imaging/EmfPlusRecordType.cs
+++ b/mcs/class/System.Drawing/System.Drawing.Imaging/EmfPlusRecordType.cs
@@ -69,7 +69,8 @@ namespace System.Drawing.Imaging
EmfIntersectClipRect = 30,
EmfInvertRgn = 73,
EmfLineTo = 54,
- EmfMaskBlt = 78,
+ EmfMaskBlt = 78,
+ EmfMax = 122,
EmfMin = 1,
EmfModifyWorldTransform = 36,
EmfMoveToEx = 27,
@@ -86,7 +87,9 @@ namespace System.Drawing.Imaging
EmfPolyBezierTo16 = 88,
EmfPolyDraw = 56,
EmfPolyDraw16 = 92,
- EmfPolygon = 3,
+ EmfPolygon = 3,
+ EmfPolygon16 = 86,
+ EmfPolyline = 4,
EmfPolyPolygon16 = 86,
EmfPolyPolyline = 4,
EmfPolyline16 = 87,
diff --git a/mcs/class/System.Drawing/System.Drawing.Imaging/ImageAttributes.cs b/mcs/class/System.Drawing/System.Drawing.Imaging/ImageAttributes.cs
index 3fac6936c43..69abf831ed3 100644
--- a/mcs/class/System.Drawing/System.Drawing.Imaging/ImageAttributes.cs
+++ b/mcs/class/System.Drawing/System.Drawing.Imaging/ImageAttributes.cs
@@ -1,5 +1,5 @@
//
-// System.Windows.Forms.FormBorderStyle.cs
+// System.Drawing.Imaging.ImageAttributes.cs
//
// Author:
// Dennis Hayes (dennish@raytek.com)
@@ -14,7 +14,7 @@ namespace System.Drawing.Imaging
/// <summary>
/// Summary description for ImageAttributes.
/// </summary>
- public class ImageAttributes {
+ public sealed class ImageAttributes : IDisposable {
public ImageAttributes() {
}
@@ -27,6 +27,21 @@ namespace System.Drawing.Imaging
}
+ public void SetColorMatrix(ColorMatrix colorMatrix) {
+ throw new NotImplementedException();
+ }
+
+ public void SetColorMatrix(ColorMatrix colorMatrix, ColorMatrixFlag colorMatrixFlag) {
+ throw new NotImplementedException();
+ }
+
+ public void SetColorMatrix(ColorMatrix colorMatrix, ColorMatrixFlag colorMatrixFlag, ColorAdjustType colorAdjustType) {
+ throw new NotImplementedException();
+ }
+
+ public void Dispose() {
+ }
+
~ImageAttributes() {
}
diff --git a/mcs/class/System.Drawing/System.Drawing.Imaging/ImageCodecFlags.cs b/mcs/class/System.Drawing/System.Drawing.Imaging/ImageCodecFlags.cs
index 235ebed2fc0..c656f5ba073 100644
--- a/mcs/class/System.Drawing/System.Drawing.Imaging/ImageCodecFlags.cs
+++ b/mcs/class/System.Drawing/System.Drawing.Imaging/ImageCodecFlags.cs
@@ -6,7 +6,8 @@
//
using System;
namespace System.Drawing.Imaging
-{
+{
+ [Flags]
public enum ImageCodecFlags {
BlockingDecode = 32,
Builtin = 65536,
diff --git a/mcs/class/System.Drawing/System.Drawing.Imaging/ImageCodecInfo.cs b/mcs/class/System.Drawing/System.Drawing.Imaging/ImageCodecInfo.cs
index dc6f1070bc9..5f6d48dd352 100644
--- a/mcs/class/System.Drawing/System.Drawing.Imaging/ImageCodecInfo.cs
+++ b/mcs/class/System.Drawing/System.Drawing.Imaging/ImageCodecInfo.cs
@@ -1,19 +1,22 @@
//
// System.Drawing.Imaging.ImageCodecInfo.cs
//
+// Authors:
+// Everaldo Canuto (everaldo.canuto@bol.com.br)
+// Andreas Nahr (ClassDevelopment@A-SoftTech.com)
+// Dennis Hayes (dennish@raytek.com)
+//
// (C) 2002 Ximian, Inc. http://www.ximian.com
-// Author: Everaldo Canuto
-// eMail: everaldo.canuto@bol.com.br
-// Dennis Hayes (dennish@raytek.com)
-// Alexandre Pigolkine (pigolkine@gmx.de)
//
+
using System;
+using System.Runtime.InteropServices;
using System.Collections;
using System.IO;
namespace System.Drawing.Imaging {
- //[ComVisible(false)]
+ [ComVisible (false)]
public sealed class ImageCodecInfo {
Guid clsid;
@@ -36,6 +39,10 @@ namespace System.Drawing.Imaging {
allCodecs.Add(PNGCodec.CodecInfo);
}
+ internal ImageCodecInfo()
+ {
+ }
+
internal delegate void DecodeFromStream (Image image, Stream stream, BitmapData info);
internal DecodeFromStream decode;
@@ -44,7 +51,6 @@ namespace System.Drawing.Imaging {
// methods
[MonoTODO]
- //[ComVisible(false)]
public static ImageCodecInfo[] GetImageDecoders() {
ArrayList decoders = new ArrayList();
foreach( ImageCodecInfo info in allCodecs) {
@@ -58,7 +64,6 @@ namespace System.Drawing.Imaging {
}
[MonoTODO]
- //[ComVisible(false)]
public static ImageCodecInfo[] GetImageEncoders() {
ArrayList encoders = new ArrayList();
foreach( ImageCodecInfo info in allCodecs) {
@@ -73,56 +78,48 @@ namespace System.Drawing.Imaging {
// properties
[MonoTODO]
- //[ComVisible(false)]
public Guid Clsid {
get { return clsid; }
set { clsid = value; }
}
[MonoTODO]
- //[ComVisible(false)]
public string CodecName {
get { return codecName; }
set { codecName = value; }
}
[MonoTODO]
- //[ComVisible(false)]
public string DllName {
get { return dllName; }
set { dllName = value; }
}
[MonoTODO]
- //[ComVisible(false)]
public string FilenameExtension {
get { return filenameExtension; }
set { filenameExtension = value; }
}
[MonoTODO]
- //[ComVisible(false)]
public ImageCodecFlags Flags {
get { return flags; }
set { flags = value; }
}
[MonoTODO]
- //[ComVisible(false)]
public string FormatDescription {
get { return formatDescription; }
set { formatDescription = value; }
}
[MonoTODO]
- //[ComVisible(false)]
public Guid FormatID {
get { return formatID; }
set { formatID = value; }
}
[MonoTODO]
- //[ComVisible(false)]
public string MimeType {
get { return mimeType; }
set { mimeType = value; }
@@ -130,7 +127,6 @@ namespace System.Drawing.Imaging {
[MonoTODO]
[CLSCompliant(false)]
- //[ComVisible(false)]
public byte[][] SignatureMasks {
get { return signatureMasks; }
set { signatureMasks = value; }
@@ -138,14 +134,12 @@ namespace System.Drawing.Imaging {
[MonoTODO]
[CLSCompliant(false)]
- //[ComVisible(false)]
public byte[][] SignaturePatterns {
get { return signaturePatterns; }
set { signaturePatterns = value; }
}
[MonoTODO]
- //[ComVisible(false)]
public int Version {
get { return version; }
set { version = value; }
diff --git a/mcs/class/System.Drawing/System.Drawing.Imaging/ImageFlags.cs b/mcs/class/System.Drawing/System.Drawing.Imaging/ImageFlags.cs
index 61e0ec878a1..39e22e49d9f 100644
--- a/mcs/class/System.Drawing/System.Drawing.Imaging/ImageFlags.cs
+++ b/mcs/class/System.Drawing/System.Drawing.Imaging/ImageFlags.cs
@@ -6,7 +6,8 @@
//
using System;
namespace System.Drawing.Imaging
-{
+{
+ [Flags]
public enum ImageFlags {
Caching = 131072,
ColorSpaceCmyk = 32,
diff --git a/mcs/class/System.Drawing/System.Drawing.Imaging/ImageFormat.cs b/mcs/class/System.Drawing/System.Drawing.Imaging/ImageFormat.cs
index 75a660bcf80..e08df6844d4 100644
--- a/mcs/class/System.Drawing/System.Drawing.Imaging/ImageFormat.cs
+++ b/mcs/class/System.Drawing/System.Drawing.Imaging/ImageFormat.cs
@@ -1,21 +1,25 @@
//
// System.Drawing.Imaging.ImageFormat.cs
//
+// Authors:
+// Everaldo Canuto (everaldo.canuto@bol.com.br)
+// Andreas Nahr (ClassDevelopment@A-SoftTech.com)
+// Dennis Hayes (dennish@raytek.com)
+//
// (C) 2002 Ximian, Inc. http://www.ximian.com
-// Author: Everaldo Canuto
-// eMail: everaldo.canuto@bol.com.br
-// Dennis Hayes (dennish@raytek.com)
//
+
using System;
+using System.ComponentModel;
namespace System.Drawing.Imaging {
+ [TypeConverter (typeof (ImageFormatConverter))]
public sealed class ImageFormat {
Guid guid;
// constructors
- [MonoTODO]
public ImageFormat(Guid guid) {
this.guid = guid;
}
@@ -33,67 +37,63 @@ namespace System.Drawing.Imaging {
[MonoTODO]
public override string ToString() {
+ // FIXME returns a string for the format like "Png"
return String.Format("ImageFormat.Guid {0}", guid);
}
// properties
- static ImageFormat BmpImageFormat = new ImageFormat (new Guid ("DFB9AC7D-498D-4bd8-9D42-E23E541964B1"));
+ public Guid Guid {
+ get { return guid; }
+ }
- [MonoTODO]
+ static ImageFormat BmpImageFormat = new ImageFormat (new Guid ("b96b3cab-0728-11d3-9d7b-0000f81ef32e"));
public static ImageFormat Bmp {
get { return BmpImageFormat; }
}
- [MonoTODO]
+ static ImageFormat EmfImageFormat = new ImageFormat (new Guid ("b96b3cac-0728-11d3-9d7b-0000f81ef32e"));
public static ImageFormat Emf {
- get { throw new NotImplementedException (); }
+ get { return EmfImageFormat; }
}
- [MonoTODO]
+ static ImageFormat ExifImageFormat = new ImageFormat (new Guid ("b96b3cb2-0728-11d3-9d7b-0000f81ef32e"));
public static ImageFormat Exif {
- get { throw new NotImplementedException (); }
+ get { return ExifImageFormat; }
}
- [MonoTODO]
+ static ImageFormat GifImageFormat = new ImageFormat (new Guid ("b96b3cb0-0728-11d3-9d7b-0000f81ef32e"));
public static ImageFormat Gif {
- get { throw new NotImplementedException (); }
+ get { return GifImageFormat; }
}
- [MonoTODO]
- public Guid Guid {
- get { return guid; }
- }
-
- [MonoTODO]
+ static ImageFormat IconImageFormat = new ImageFormat (new Guid ("b96b3cb5-0728-11d3-9d7b-0000f81ef32e"));
public static ImageFormat Icon {
- get { throw new NotImplementedException (); }
+ get { return IconImageFormat; }
}
- [MonoTODO]
- static ImageFormat JpegImageFormat = new ImageFormat(new Guid("83BFFDF8-398F-407f-BA33-A7993D11B2DA"));
+ static ImageFormat JpegImageFormat = new ImageFormat(new Guid("b96b3cae-0728-11d3-9d7b-0000f81ef32e"));
public static ImageFormat Jpeg {
get { return JpegImageFormat; }
}
- [MonoTODO]
+ static ImageFormat MemoryBmpImageFormat = new ImageFormat (new Guid ("b96b3caa-0728-11d3-9d7b-0000f81ef32e"));
public static ImageFormat MemoryBmp {
- get { throw new NotImplementedException (); }
+ get { return MemoryBmpImageFormat; }
}
- [MonoTODO]
- static ImageFormat PngImageFormat = new ImageFormat(new Guid("33CDFD76-3463-4273-BA28-A7993D11B2DA"));
+ static ImageFormat PngImageFormat = new ImageFormat(new Guid("b96b3caf-0728-11d3-9d7b-0000f81ef32e"));
public static ImageFormat Png {
get { return PngImageFormat; }
}
- [MonoTODO]
+ static ImageFormat TiffImageFormat = new ImageFormat (new Guid ("b96b3cb1-0728-11d3-9d7b-0000f81ef32e"));
public static ImageFormat Tiff {
- get { throw new NotImplementedException (); }
+ get { return TiffImageFormat; }
}
- [MonoTODO]
+ static ImageFormat WmfImageFormat = new ImageFormat (new Guid ("b96b3cad-0728-11d3-9d7b-0000f81ef32e"));
public static ImageFormat Wmf {
- get { throw new NotImplementedException (); }
+ get { return WmfImageFormat; }
}
}
diff --git a/mcs/class/System.Drawing/System.Drawing.Imaging/JPEGCodec.cs b/mcs/class/System.Drawing/System.Drawing.Imaging/JPEGCodec.cs
index f95fe2226a0..6d26f783e3b 100644
--- a/mcs/class/System.Drawing/System.Drawing.Imaging/JPEGCodec.cs
+++ b/mcs/class/System.Drawing/System.Drawing.Imaging/JPEGCodec.cs
@@ -718,6 +718,8 @@ namespace System.Drawing.Imaging
}
jpeg_finish_decompress(cinfo.raw_struct);
jpeg_destroy_decompress(cinfo.raw_struct);
+
+ info.swap_red_blue_bytes ();
return true;
}
@@ -792,35 +794,15 @@ namespace System.Drawing.Imaging
IntPtr scanline;
int stride;
+ info.swap_red_blue_bytes ();
+
switch (info.PixelFormat){
case PixelFormat.Format24bppRgb:
start = (byte *) (void *) info.Scan0;
stride = info.Stride;
while (cinfo.NextScanLine < cinfo.ImageHeight){
- // Exchange red <=> blue bytes
-// fixed (byte *pbuf = start) {
- byte* curByte = start;
- for (int i = 0; i < info.Width; i++) {
- byte t = *(curByte+2);
- *(curByte+2) = *curByte;
- *curByte = t;
- curByte += 3;
- }
-// }
-
scanline = (IntPtr) start;
jpeg_write_scanlines (cinfo.raw_struct, ref scanline, 1);
-
- // Exchange red <=> blue bytes back
-// fixed (byte *pbuf1 = start) {
- curByte = start;
- for (int i = 0; i < info.Width; i++) {
- byte t = *(curByte+2);
- *(curByte+2) = *curByte;
- *curByte = t;
- curByte += 3;
- }
-// }
start += stride;
}
break;
@@ -829,6 +811,7 @@ namespace System.Drawing.Imaging
throw new Exception ("Unhandled PixelFormat: " + info.PixelFormat);
}
+ info.swap_red_blue_bytes ();
jpeg_finish_compress(cinfo.raw_struct);
jpeg_destroy_compress(cinfo.raw_struct);
diff --git a/mcs/class/System.Drawing/System.Drawing.Imaging/MetaHeader.cs b/mcs/class/System.Drawing/System.Drawing.Imaging/MetaHeader.cs
index 5089aa82573..0303dd5445e 100644
--- a/mcs/class/System.Drawing/System.Drawing.Imaging/MetaHeader.cs
+++ b/mcs/class/System.Drawing/System.Drawing.Imaging/MetaHeader.cs
@@ -1,64 +1,67 @@
//
// System.Drawing.Imaging.MetaHeader.cs
//
-// (C) 2002 Ximian, Inc. http://www.ximian.com
-// Author: Everaldo Canuto
-// eMail: everaldo.canuto@bol.com.br
-// Dennis Hayes (dennish@raytek.com)
-//
+// Authors:
+// Everaldo Canuto (everaldo.canuto@bol.com.br)
+// Andreas Nahr (ClassDevelopment@A-SoftTech.com)
+// Dennis Hayes (dennish@raytek.com)
+//
+// (C) 2002 Ximian, Inc. http://www.ximian.com
+//
+
using System;
namespace System.Drawing.Imaging {
public sealed class MetaHeader {
+
+ short headerSize;
+ int maxRecord;
+ short noObjects;
+ short noParameters;
+ int size;
+ short type;
+ short version;
// constructors
- [MonoTODO]
- public MetaHeader() {
- throw new NotImplementedException ();
+ public MetaHeader()
+ {
}
// properties
- [MonoTODO]
public short HeaderSize {
- get { throw new NotImplementedException (); }
- set { throw new NotImplementedException (); }
+ get { return headerSize; }
+ set { headerSize = value; }
}
- [MonoTODO]
public int MaxRecord {
- get { throw new NotImplementedException (); }
- set { throw new NotImplementedException (); }
+ get { return maxRecord; }
+ set { maxRecord = value; }
}
- [MonoTODO]
public short NoObjects {
- get { throw new NotImplementedException (); }
- set { throw new NotImplementedException (); }
+ get { return noObjects; }
+ set { noObjects = value; }
}
- [MonoTODO]
public short NoParameters {
- get { throw new NotImplementedException (); }
- set { throw new NotImplementedException (); }
+ get { return noParameters; }
+ set { noParameters = value; }
}
- [MonoTODO]
public int Size {
- get { throw new NotImplementedException (); }
- set { throw new NotImplementedException (); }
+ get { return size; }
+ set { size = value; }
}
- [MonoTODO]
public short Type {
- get { throw new NotImplementedException (); }
- set { throw new NotImplementedException (); }
+ get { return type; }
+ set { type = value; }
}
- [MonoTODO]
public short Version {
- get { throw new NotImplementedException (); }
- set { throw new NotImplementedException (); }
+ get { return version; }
+ set { version = value; }
}
}
diff --git a/mcs/class/System.Drawing/System.Drawing.Imaging/PNGCodec.cs b/mcs/class/System.Drawing/System.Drawing.Imaging/PNGCodec.cs
index 47ccfd43990..b1cc7097fba 100644
--- a/mcs/class/System.Drawing/System.Drawing.Imaging/PNGCodec.cs
+++ b/mcs/class/System.Drawing/System.Drawing.Imaging/PNGCodec.cs
@@ -208,28 +208,13 @@ namespace System.Drawing.Imaging
{
PNGCodec png = new PNGCodec();
BitmapData info = ((Bitmap)image).LockBits (new Rectangle (new Point (0,0), image.Size),
- ImageLockMode.ReadOnly, image.PixelFormat);
+ ImageLockMode.ReadOnly, PixelFormat.Format24bppRgb);
png.Encode (image, stream, info);
((Bitmap)image).UnlockBits (info);
}
- internal unsafe void switch_color_bytes (byte[] image)
+ internal unsafe bool Decode (Image image, Stream stream, BitmapData info)
{
- fixed(byte* start = image) {
- byte *pb = start;
- byte t1;
- for (int ic = 0; ic < image.Length; ic +=3) {
- t1 = *pb;
- *(pb) = *(pb+2);
- *(pb+2) = t1;
- pb += 3;
- }
- }
- }
-
- internal bool Decode (Image image, Stream stream, BitmapData info)
- {
-#if false
fs = stream;
IntPtr png_ptr = png_create_read_struct (PNG_LIBPNG_VER_STRING, IntPtr.Zero,
@@ -257,39 +242,37 @@ namespace System.Drawing.Imaging
png_read_info (png_ptr, info_ptr);
int height = png_get_image_height (png_ptr, info_ptr);
- int row_width = png_get_rowbytes (png_ptr, info_ptr);
- while ((row_width & 3) != 0) row_width++;
+ int stride = png_get_rowbytes (png_ptr, info_ptr);
+ stride = (stride + 3) & ~3;
- info.Size = new Size (png_get_image_width (png_ptr, info_ptr), height);
- info.Stride = row_width;
+ info.Width = png_get_image_width (png_ptr, info_ptr);
+ info.Height = height;
+ info.Stride = stride;
// FIXME: do a real palette processing
//info.Palette = new ColorPalette(1, cinfo.ColorMap);
// FIXME: get color information from png info structure
info.PixelFormat = PixelFormat.Format24bppRgb;
- info.RawImageBytes = new byte[height * row_width];
+ info.Scan0 = Marshal.AllocHGlobal (height * stride);
- IntPtr row_data = Marshal.AllocHGlobal (row_width);
- int outputIndex = info.RawImageBytes.Length - row_width;
+ byte *start = (byte *) (void *) info.Scan0;
+ IntPtr scanline;
for (int row = 0; row < height; row++) {
- png_read_row (png_ptr, row_data, IntPtr.Zero);
- Marshal.Copy (row_data, info.RawImageBytes, outputIndex, row_width);
- outputIndex -= row_width;
+ scanline = (IntPtr) start;
+ png_read_row (png_ptr, scanline, IntPtr.Zero);
+ start += stride;
}
- Marshal.FreeHGlobal (row_data);
png_read_end (png_ptr, end_info);
png_destroy_read_struct (ref png_ptr, ref info_ptr, ref end_info);
- // FIXME: not sure if this always works, and use PNG library transformation
- switch_color_bytes(info.RawImageBytes);
-#endif
+ info.swap_red_blue_bytes();
+
return true;
}
internal unsafe bool Encode (Image image, Stream stream, BitmapData info)
{
-#if false
int bpp = Image.GetPixelFormatSize(info.PixelFormat) / 8;
if (bpp != 3 && bpp != 4) {
throw new ArgumentException(String.Format("Supplied pixel format is not yet supported: {0}, {1} bpp", info.PixelFormat, Image.GetPixelFormatSize(info.PixelFormat)));
@@ -314,56 +297,28 @@ namespace System.Drawing.Imaging
new cdeclCallback.cdeclRedirector.MethodVoidIntPtrIntPtrInt(this.write_data_fn),
new cdeclCallback.cdeclRedirector.MethodVoidIntPtr(this.output_flush_fn));
- png_set_IHDR (png_ptr, info_ptr, info.Size.Width, info.Size.Height, 8,
+ png_set_IHDR (png_ptr, info_ptr, info.Width, info.Height, 8,
(int)PNG_LIB.PNG_COLOR_TYPE_RGB/*(Image.IsAlphaPixelFormat(info.Format) ? (int)PNG_LIB.PNG_COLOR_TYPE_RGB_ALPHA : (int)PNG_LIB.PNG_COLOR_TYPE_RGB)*/,
(int)PNG_LIB.PNG_INTERLACE_NONE, (int)PNG_LIB.PNG_COMPRESSION_TYPE_DEFAULT, (int)PNG_LIB.PNG_FILTER_TYPE_DEFAULT);
png_write_info (png_ptr, info_ptr);
-
- int row_width = info.Size.Width;
- while ((row_width & 3) != 0) row_width++;
-
- int row_bytes_width = row_width * 3;
- int src_row_bytes_width = row_width * bpp;
-
- IntPtr row_data = Marshal.AllocHGlobal (row_bytes_width);
- int outputIndex = info.RawImageBytes.Length - src_row_bytes_width;
- byte[] buffer = new byte[row_bytes_width];
+ info.swap_red_blue_bytes ();
- fixed (byte *psrc = info.RawImageBytes, pbuf = buffer) {
- byte* curSrc = null;
- byte* curDst = null;
- for (int row = 0; row < info.Size.Height; row++) {
- curSrc = psrc + outputIndex;
- curDst = pbuf;
- for (int i = 0; i < row_width; i++) {
- *curDst++ = *(curSrc+2);
- *curDst++ = *(curSrc+1);
- *curDst++ = *curSrc;
-/*
- *curDst = *(curSrc+2);
- *(curDst+1) = *(curSrc+1);
- *(curDst+2) = *curSrc;
- if (bpp == 4) {
- *(curDst+3) = *(curSrc+3);
- }
- curDst += bpp;
-*/
- curSrc += bpp;
- }
- Marshal.Copy (buffer, 0, row_data, row_bytes_width);
- outputIndex -= src_row_bytes_width;
- png_write_row (png_ptr, row_data);
- }
+ byte *start = (byte *) (void *) info.Scan0;
+ IntPtr scanline;
+ int stride = info.Stride;
+ for (int row = 0; row < info.Height; row++) {
+ scanline = (IntPtr) start;
+ png_write_row (png_ptr, scanline);
+ start += stride;
}
-
- Marshal.FreeHGlobal (row_data);
png_write_end (png_ptr, info_ptr);
+ png_destroy_write_struct (ref png_ptr, ref info_ptr);
- png_destroy_write_struct (ref png_ptr, ref info_ptr);
-#endif
+ info.swap_red_blue_bytes ();
+
return true;
}
}
diff --git a/mcs/class/System.Drawing/System.Drawing.Imaging/PropertyItem.cs b/mcs/class/System.Drawing/System.Drawing.Imaging/PropertyItem.cs
index d65c278f02e..ee6ea242d09 100644
--- a/mcs/class/System.Drawing/System.Drawing.Imaging/PropertyItem.cs
+++ b/mcs/class/System.Drawing/System.Drawing.Imaging/PropertyItem.cs
@@ -1,40 +1,44 @@
//
// System.Drawing.Imaging.PropertyItem.cs
//
-// (C) 2002 Ximian, Inc. http://www.ximian.com
-// Author: Everaldo Canuto
-// eMail: everaldo.canuto@bol.com.br
-// Dennis Hayes (dennish@raytek.com)
-//
+// Authors:
+// Everaldo Canuto (everaldo.canuto@bol.com.br)
+// Andreas Nahr (ClassDevelopment@A-SoftTech.com)
+// Dennis Hayes (dennish@raytek.com)
+//
+// (C) 2002 Ximian, Inc. http://www.ximian.com
+//
+
using System;
namespace System.Drawing.Imaging {
public sealed class PropertyItem {
+
+ int id;
+ int len;
+ short type;
+ byte[] value;
// properties
- [MonoTODO]
public int Id {
- get { throw new NotImplementedException (); }
- set { throw new NotImplementedException (); }
+ get { return id; }
+ set { id = value; }
}
- [MonoTODO]
public int Len {
- get { throw new NotImplementedException (); }
- set { throw new NotImplementedException (); }
+ get { return len; }
+ set { len = value; }
}
- [MonoTODO]
public short Type {
- get { throw new NotImplementedException (); }
- set { throw new NotImplementedException (); }
+ get { return type; }
+ set { type = value; }
}
- [MonoTODO]
public byte[] Value {
- get { throw new NotImplementedException (); }
- set { throw new NotImplementedException (); }
+ get { return this.value; }
+ set { this.value = value; }
}
}
diff --git a/mcs/class/System.Drawing/System.Drawing.dll.sources b/mcs/class/System.Drawing/System.Drawing.dll.sources
index 3455adc5895..57c0816e0b8 100755
--- a/mcs/class/System.Drawing/System.Drawing.dll.sources
+++ b/mcs/class/System.Drawing/System.Drawing.dll.sources
@@ -1,4 +1,5 @@
Assembly/AssemblyInfo.cs
+Assembly/Consts.cs
System.Drawing/Bitmap.cs
System.Drawing/Brush.cs
System.Drawing/Brushes.cs
@@ -127,6 +128,7 @@ System.Drawing.Imaging/ImageLockMode.cs
System.Drawing.Imaging/JPEGCodec.cs
System.Drawing.Imaging/Metafile.cs
System.Drawing.Imaging/MetafileFrameUnit.cs
+System.Drawing.Imaging/MetafileHeader.cs
System.Drawing.Imaging/MetafileType.cs
System.Drawing.Imaging/MetaHeader.cs
System.Drawing.Imaging/PaletteFlags.cs
diff --git a/mcs/class/System.Drawing/System.Drawing/Bitmap.cs b/mcs/class/System.Drawing/System.Drawing/Bitmap.cs
index 3a779ea43e8..b14d837f947 100755
--- a/mcs/class/System.Drawing/System.Drawing/Bitmap.cs
+++ b/mcs/class/System.Drawing/System.Drawing/Bitmap.cs
@@ -13,10 +13,13 @@ using System.IO;
using System.Drawing.Imaging;
using System.Runtime.Serialization;
using System.Runtime.InteropServices;
+using System.ComponentModel;
namespace System.Drawing {
[Serializable]
+ [ComVisible (true)]
+ [Editor ("System.Drawing.Design.BitmapEditor, " + Consts.AssemblySystem_Drawing_Design, typeof (System.Drawing.Design.UITypeEditor))]
public sealed class Bitmap : Image {
//
// This one holds the actual memory buffer at the PixelFormat/height/width
@@ -57,9 +60,8 @@ namespace System.Drawing {
nativeObject = (IntPtr)bmp;
}
- public Bitmap (Image original)
+ public Bitmap (Image original) : this (original, original.Size)
{
- image_size = original.Size;
}
public Bitmap (Stream stream) : this (stream, false) {}
@@ -68,7 +70,19 @@ namespace System.Drawing {
public Bitmap (Image original, Size newSize)
{
- image_size = newSize;
+ if (original is Bitmap) {
+ Bitmap bmpOriginal = (Bitmap) original;
+ image_size = bmpOriginal.Size;
+ pixel_format = bmpOriginal.pixel_format;
+ int bmp = 0;
+ Status s = GDIPlus.GdipCloneBitmapAreaI (0, 0, newSize.Width, newSize.Height, bmpOriginal.PixelFormat, bmpOriginal.nativeObject, out bmp);
+ if (s != Status.Ok)
+ throw new ArgumentException ("Could not allocate the GdiPlus image: " + s);
+ nativeObject = (IntPtr)bmp;
+ }
+ else {
+ throw new NotImplementedException ();
+ }
}
void InitFromStream (Stream stream)
@@ -170,7 +184,7 @@ namespace System.Drawing {
public BitmapData LockBits (Rectangle rect, ImageLockMode flags, PixelFormat format)
{
- GdipRect rc = new GdipRect ();
+ GpRect rc = new GpRect ();
rc.left = rect.Left;
rc.right = rect.Right;
rc.top = rect.Top;
diff --git a/mcs/class/System.Drawing/System.Drawing/Brush.cs b/mcs/class/System.Drawing/System.Drawing/Brush.cs
index 2ae82b18a37..081b045c4ac 100755
--- a/mcs/class/System.Drawing/System.Drawing/Brush.cs
+++ b/mcs/class/System.Drawing/System.Drawing/Brush.cs
@@ -8,6 +8,7 @@
//
using System;
+using System.Drawing;
namespace System.Drawing {
@@ -15,11 +16,27 @@ namespace System.Drawing {
internal IntPtr nativeObject;
abstract public object Clone ();
+
+ internal Brush ()
+ { }
- internal Brush()
+ internal Brush (IntPtr ptr)
{
+ nativeObject = ptr;
}
+ internal Brush CreateBrush (IntPtr brush, System.Drawing.BrushType type)
+ {
+ switch (type) {
+
+ case BrushType.BrushTypeSolidColor:
+ return new SolidBrush (brush);
+
+ default:
+ throw new NotImplementedException ();
+ }
+ }
+
public void Dispose ()
{
Dispose (true);
diff --git a/mcs/class/System.Drawing/System.Drawing/ChangeLog b/mcs/class/System.Drawing/System.Drawing/ChangeLog
index 6ebed0886f4..c9e551072d5 100644
--- a/mcs/class/System.Drawing/System.Drawing/ChangeLog
+++ b/mcs/class/System.Drawing/System.Drawing/ChangeLog
@@ -1,5 +1,125 @@
-2003-11-06 Duncan Mak <duncan@ximian.com>
+2003-11-28 Duncan Mak <duncan@ximian.com>
+
+ * Pen.cs (CompoundArray): Hide this for now.
+
+2003-11-28 Duncan Mak <duncan@ximian.com>
+
+ * Brush.cs (CreateBrush): new internal factory method for creating
+ specific brushes based on the internal (GDI+ C API) BrushType
+ enum.
+ (Brush (IntPtr)): new internal constructor.
+
+ * Pen.cs: Removed all the C# fields. We are using GDI+ completely
+ now.
+ (Pen (IntPtr)): new internal constructor.
+ (Pen (Brush, float)): Use GdipCreateBrush2.
+ (Clone): Implemented using GdipClonePen.
+ (Alignment, Brush, Color, Width): Use GDI+ implementations
+ instead.
+ (CompoundArray, DashCap, DashOffset, DashPattern, DashStyle):
+ Implemented these properties.
+ (CustomStartCap, CustomEndCap, StartCap, EndCap, SetLineCap): Stubbed.
+ (MultiplyTransform, ResetTransform, RotateTransform):
+ (ScaleTransform, TranslateTransform): Implemented these methods.
+
+ * SolidBrush.cs (SolidBrush (IntPtr)): new internal constructor.
+
+ * gdipEnums.cs (BrushType): Added new GDI+ enum.
+
+ * gdipFunctions.cs: Imported new Brush and Pen functions.
+
+2003-11-22 Duncan Mak <duncan@ximian.com>
+
+ * gdipFunctions.cs
+ (GdipResetWorldTransform, GdipSetWorldTransform):
+ (GdipGetWorldTransform, GdipScaleWorldTransform): Imported.
+
+ * Graphics.cs: Remove unnecessary TODO, and reformatted the code.
+ (transform): Removed this field. Always use the
+ matrix associated in the GpGraphics ptr.
+ (DrawBeziers): Implemented.
+ (DrawLine): Don't need to manually invoke the transform now.
+ (MultiplyTransform, ResetTransform):
+ (ScaleTransform, TranslateTransform): Use GDI+ implementation.
+ (Transform): Instead of storing a Matrix in managed code, use
+ equivalent GDI+ functions.
+
+2003-11-21 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * SizeConverter.cs: fixed class signature and implemented some methods.
+
+2003-11-17 Duncan Mak <duncan@ximian.com>
+
+ * gdipFunctions.cs (GdipGetMatrixElements): Fix signature.
+
+ * Graphics.cs (MultiplyTransform): Commented out until my Matrix commit.
+
+2003-11-17 Duncan Mak <duncan@ximian.com>
+
+ * Bitmap.cs (LockBits):
+ * Graphics.cs (DrawString): Use GpRectF.
+ * gdipFunctions.cs: Updated method signatures.
+
+ * Graphics.cs (MultiplyTransform): Implemented using
+ GdipMultiplyWorldTransform from GDI+.
+
+ * gdipStructs.cs (GdipRectF, GdipRect): Renamed to GpRectF and
+ GpRect, to be more consistent with the C naming.
+
+2003-11-16 Miguel de Icaza <miguel@ximian.com>
+
+ * Graphics.cs: Implement the other DrawString overloads .
+
+2003-11-16 Miguel de Icaza <miguel@ximian.com>
+
+ * gdipStructs.cs (GdipRectF): Added utility constructor
+
+2003-11-15 Duncan Mak <duncan@ximian.com>
+
+ * gdipFunctions.cs: Imported matrix functions.
+
+2003-11-13 Andreas Nahr <ClassDevelopment@A-SoftTech.com>
+
+ * Bitmap.cs: Added Attributes
+ * ColorTranslator.cs: Added private constructor
+ * Font.cs: Added Attributes
+ * FontFamily.cs: sealed
+ * Icon.cs: Added Attributes
+ * IconConverter.cs: Fixed signature
+ * Image.cs: Added attributes
+ * ImageAnimator.cs:
+ * ImageConverter.cs:
+ * ImageFormatConverter.cs:
+ * SolidBrush.cs:
+ * StringFormat.cs:
+ * SystemBrushes.cs:
+ * SystemColors.cs:
+ * SystemIcons.cs:
+ * SystemPens.cs:
+ * TextureBrush.cs: Fixed signature
+ * Color.cs: Added attributes
+ * Point.cs:
+ * PointF.cs:
+ * Rectangle.cs:
+ * Size.cs:
+ * SizeF.cs: Added attributes
+ * ContentAlignment.cs: Added attribute
+
+2003-11-13 Duncan Mak <duncan@ximian.com>
+
+ * Pen.cs (LineCap, LineJoin, MiterLimit, Transform): implemented.
+
+ * gdipFunctions.cs
+ (GdipSetPenMiterLimit, GdipGetPenMiterLimit):
+ (GdipSetPenLineJoin, GdipGetPenLineJoin):
+ (GdipSetPenLineJoin, GdipGetPenTransform): imported.
+
+2003-11-12 Alexandre Pigolkine <pigolkine@gmx.de>
+ * Bitmap.cs
+ * gdipFunctions.cs copy image in Bitmap constructor
+
+2003-11-06 Duncan Mak <duncan@ximian.com>
* Graphics.cs (DrawPie): Use DrawPieI instead of DrawPie and fix
angle parameters for the integer case.
(DrawBezier): Hook it up with GdipDrawBezier.
diff --git a/mcs/class/System.Drawing/System.Drawing/Color.cs b/mcs/class/System.Drawing/System.Drawing/Color.cs
index 0bb005b1426..7d66bcabd4d 100644
--- a/mcs/class/System.Drawing/System.Drawing/Color.cs
+++ b/mcs/class/System.Drawing/System.Drawing/Color.cs
@@ -13,12 +13,15 @@
using System;
using System.Collections;
+using System.Runtime.InteropServices;
using System.ComponentModel;
using System.Reflection;
namespace System.Drawing
{
[TypeConverter(typeof(ColorConverter))]
+ [ComVisible (true)]
+ [Editor ("System.Drawing.Design.ColorEditor, " + Consts.AssemblySystem_Drawing_Design, typeof (System.Drawing.Design.UITypeEditor))]
[Serializable]
public struct Color
{
diff --git a/mcs/class/System.Drawing/System.Drawing/ColorTranslator.cs b/mcs/class/System.Drawing/System.Drawing/ColorTranslator.cs
index b41525f9ad1..c6a69872344 100644
--- a/mcs/class/System.Drawing/System.Drawing/ColorTranslator.cs
+++ b/mcs/class/System.Drawing/System.Drawing/ColorTranslator.cs
@@ -9,7 +9,12 @@
//
using System;
namespace System.Drawing {
- public class ColorTranslator{
+ public sealed class ColorTranslator{
+
+ private ColorTranslator ()
+ {
+ }
+
// From converisons
/// <summary>
///
diff --git a/mcs/class/System.Drawing/System.Drawing/ContentAlignment.cs b/mcs/class/System.Drawing/System.Drawing/ContentAlignment.cs
index 25dc8d25ce1..3227fbb2670 100644
--- a/mcs/class/System.Drawing/System.Drawing/ContentAlignment.cs
+++ b/mcs/class/System.Drawing/System.Drawing/ContentAlignment.cs
@@ -6,8 +6,11 @@
//
using System;
+using System.ComponentModel;
+
namespace System.Drawing
{
+ [Editor ("System.Drawing.Design.ContentAlignmentEditor, " + Consts.AssemblySystem_Drawing_Design, typeof (System.Drawing.Design.UITypeEditor))]
public enum ContentAlignment {
TopLeft = 0x001,
TopCenter = 0x002,
diff --git a/mcs/class/System.Drawing/System.Drawing/Font.cs b/mcs/class/System.Drawing/System.Drawing/Font.cs
index e550a218cd9..2a370ebcefd 100644
--- a/mcs/class/System.Drawing/System.Drawing/Font.cs
+++ b/mcs/class/System.Drawing/System.Drawing/Font.cs
@@ -1,8 +1,13 @@
using System.Runtime.Serialization;
+using System.Runtime.InteropServices;
+using System.ComponentModel;
namespace System.Drawing {
[Serializable]
+ [ComVisible (true)]
+ [Editor ("System.Drawing.Design.FontEditor, " + Consts.AssemblySystem_Drawing_Design, typeof (System.Drawing.Design.UITypeEditor))]
+ [TypeConverter(typeof(FontConverter))]
public sealed class Font : MarshalByRefObject, ISerializable, ICloneable, IDisposable
{
private Font (SerializationInfo info, StreamingContext context)
diff --git a/mcs/class/System.Drawing/System.Drawing/FontFamily.cs b/mcs/class/System.Drawing/System.Drawing/FontFamily.cs
index 372e3814f4f..9a4ddd8d34d 100644
--- a/mcs/class/System.Drawing/System.Drawing/FontFamily.cs
+++ b/mcs/class/System.Drawing/System.Drawing/FontFamily.cs
@@ -12,7 +12,7 @@ using System.Drawing.Text;
namespace System.Drawing {
- public class FontFamily : MarshalByRefObject, IDisposable {
+ public sealed class FontFamily : MarshalByRefObject, IDisposable {
static FontFamily genericMonospace;
static FontFamily genericSansSerif;
diff --git a/mcs/class/System.Drawing/System.Drawing/Graphics.cs b/mcs/class/System.Drawing/System.Drawing/Graphics.cs
index 0337a55a57e..a158c4a14e8 100755
--- a/mcs/class/System.Drawing/System.Drawing/Graphics.cs
+++ b/mcs/class/System.Drawing/System.Drawing/Graphics.cs
@@ -5,7 +5,7 @@
//
// Authors:
// Gonzalo Paniagua Javier (gonzalo@ximian.com) (stubbed out)
-// Alexandre Pigolkine(pigolkine@gmx.de)
+// Alexandre Pigolkine(pigolkine@gmx.de)
//
using System;
using System.Drawing.Drawing2D;
@@ -18,9 +18,7 @@ namespace System.Drawing
[ComVisible(false)]
public sealed class Graphics : MarshalByRefObject, IDisposable
{
- internal IntPtr nativeObject;
-
- internal Matrix transform = new Matrix();
+ internal IntPtr nativeObject;
public delegate bool EnumerateMetafileProc (EmfPlusRecordType recordType,
int flags,
@@ -110,16 +108,44 @@ namespace System.Drawing
GDIPlus.GdipDrawBezier (nativeObject, pen.nativeObject, x1, y1, x2, y2, x3, y3, x4, y4);
}
- [MonoTODO]
+ [MonoTODO]
public void DrawBeziers (Pen pen, Point [] points)
{
- throw new NotImplementedException ();
+ int length = points.Length;
+
+ if (length < 3)
+ return;
+
+ for (int i = 0; i < length; i += 3) {
+ Point p1 = points [i];
+ Point p2 = points [i + 1];
+ Point p3 = points [i + 2];
+ Point p4 = points [i + 3];
+
+ GDIPlus.GdipDrawBezier (nativeObject, pen.nativeObject,
+ p1.X, p1.Y, p2.X, p2.Y,
+ p3.X, p3.Y, p4.X, p4.Y);
+ }
}
- [MonoTODO]
+ [MonoTODO]
public void DrawBeziers (Pen pen, PointF [] points)
{
- throw new NotImplementedException ();
+ int length = points.Length;
+
+ if (length < 3)
+ return;
+
+ for (int i = 0; i < length; i += 3) {
+ PointF p1 = points [i];
+ PointF p2 = points [i + 1];
+ PointF p3 = points [i + 2];
+ PointF p4 = points [i + 3];
+
+ GDIPlus.GdipDrawBezier (nativeObject, pen.nativeObject,
+ p1.X, p1.Y, p2.X, p2.Y,
+ p3.X, p3.Y, p4.X, p4.Y);
+ }
}
[MonoTODO]
@@ -188,13 +214,11 @@ namespace System.Drawing
throw new NotImplementedException ();
}
- [MonoTODO]
public void DrawEllipse (Pen pen, Rectangle rect)
{
DrawEllipse (pen, rect.X, rect.Y, rect.Width, rect.Height);
}
- [MonoTODO]
public void DrawEllipse (Pen pen, RectangleF rect)
{
DrawEllipse (pen, rect.X, rect.Y, rect.Width, rect.Height);
@@ -432,32 +456,20 @@ namespace System.Drawing
throw new NotImplementedException ();
}
- [MonoTODO]
public void DrawLine (Pen pen, PointF pt1, PointF pt2)
{
- PointF[] pts = new PointF[2];
- pts[0] = pt1;
- pts[1] = pt2;
- transform.TransformPoints(pts);
-
GDIPlus.GdipDrawLine (
nativeObject, pen.nativeObject,
- pts [0].X, pts [0].Y,
- pts [1].X, pts [1].Y);
+ pt1.X, pt1.Y,
+ pt2.X, pt2.Y);
}
- [MonoTODO]
public void DrawLine (Pen pen, Point pt1, Point pt2)
{
- Point[] pts = new Point[2];
- pts[0] = pt1;
- pts[1] = pt2;
- transform.TransformPoints(pts);
-
GDIPlus.GdipDrawLine (
nativeObject, pen.nativeObject,
- pts [0].X, pts [0].Y,
- pts [1].X, pts [1].Y);
+ pt1.X, pt1.Y,
+ pt2.X, pt2.Y);
}
public void DrawLine (Pen pen, int x1, int y1, int x2, int y2)
@@ -515,7 +527,6 @@ namespace System.Drawing
GDIPlus.GdipDrawPolygonI (nativeObject, pen.nativeObject, points, points.Length);
}
- [MonoTODO]
public void DrawPolygon (Pen pen, PointF [] points)
{
GDIPlus.GdipDrawPolygon (nativeObject, pen.nativeObject, points, points.Length);
@@ -541,50 +552,61 @@ namespace System.Drawing
GDIPlus.GdipDrawRectangleI (nativeObject, pen.nativeObject, x, y, width, height);
}
- [MonoTODO]
public void DrawRectangles (Pen pen, RectangleF [] rects)
{
- foreach( RectangleF rc in rects) {
- DrawRectangle(pen, rc.Left, rc.Top, rc.Width, rc.Height);
- }
+ foreach (RectangleF rc in rects)
+ DrawRectangle (pen, rc.Left, rc.Top, rc.Width, rc.Height);
}
- [MonoTODO]
public void DrawRectangles (Pen pen, Rectangle [] rects)
{
- foreach( RectangleF rc in rects) {
+ foreach (RectangleF rc in rects)
DrawRectangle(pen, rc.Left, rc.Top, rc.Width, rc.Height);
- }
}
- [MonoTODO]
+ [MonoTODO("Ignores the font")]
public void DrawString (string s, Font font, Brush brush, RectangleF layoutRectangle)
{
- //throw new NotImplementedException ();
+ GpRectF rf = new GpRectF (layoutRectangle);
+
+ GDIPlus.GdipDrawString (nativeObject, s, s.Length, IntPtr.Zero, ref rf, IntPtr.Zero, brush.nativeObject);
}
- [MonoTODO]
+ [MonoTODO("This ignores the font")]
public void DrawString (string s, Font font, Brush brush, PointF point)
{
- //throw new NotImplementedException ();
+ GpRectF rc = new GpRectF ();
+ rc.left = point.X;
+ rc.top = point.Y;
+ rc.right = 0;
+ rc.bottom = 0;
+ GDIPlus.GdipDrawString (nativeObject, s, s.Length, IntPtr.Zero, ref rc, IntPtr.Zero, brush.nativeObject);
}
- [MonoTODO]
+ [MonoTODO ("This ignores the font and format")]
public void DrawString (string s, Font font, Brush brush, PointF point, StringFormat format)
{
- //throw new NotImplementedException ();
+ GpRectF rc = new GpRectF ();
+ rc.left = point.X;
+ rc.top = point.Y;
+ rc.right = 0;
+ rc.bottom = 0;
+ GDIPlus.GdipDrawString (nativeObject, s, s.Length, IntPtr.Zero, ref rc, IntPtr.Zero, brush.nativeObject);
}
- [MonoTODO]
+ [MonoTODO ("This ignores the font and the format")]
public void DrawString (string s, Font font, Brush brush, RectangleF layoutRectangle, StringFormat format)
{
- throw new NotImplementedException ();
+ GpRectF rect = new GpRectF (layoutRectangle);
+
+ GDIPlus.GdipDrawString (nativeObject, s, s.Length, IntPtr.Zero, ref rect, IntPtr.Zero, brush.nativeObject);
+
}
- [MonoTODO]
+ [MonoTODO("This ignores the font")]
public void DrawString (string s, Font font, Brush brush, float x, float y)
{
- GdipRectF rc = new GdipRectF ();
+ GpRectF rc = new GpRectF ();
rc.left = x;
rc.top = y;
rc.right = 0;
@@ -932,48 +954,36 @@ namespace System.Drawing
GDIPlus.GdipFillPolygon (nativeObject, brush.nativeObject, points, points.Length, fillMode);
}
- [MonoTODO]
public void FillRectangle (Brush brush, RectangleF rect)
{
- FillRectangle( brush, rect.Left, rect.Top, rect.Width, rect.Height);
+ FillRectangle (brush, rect.Left, rect.Top, rect.Width, rect.Height);
}
- [MonoTODO]
public void FillRectangle (Brush brush, Rectangle rect)
{
- FillRectangle( brush, rect.Left, rect.Top, rect.Width, rect.Height);
+ FillRectangle (brush, rect.Left, rect.Top, rect.Width, rect.Height);
}
- [MonoTODO]
public void FillRectangle (Brush brush, int x, int y, int width, int height)
{
GDIPlus.GdipFillRectangle (nativeObject, brush.nativeObject, (float)x, (float)y, (float)width, (float)height);
}
- [MonoTODO]
public void FillRectangle (Brush brush, float x, float y, float width, float height)
{
GDIPlus.GdipFillRectangle (nativeObject, brush.nativeObject, x, y, width, height);
}
- [MonoTODO]
public void FillRectangles (Brush brush, Rectangle [] rects)
{
- if(rects != null) {
- foreach( Rectangle rc in rects) {
- FillRectangle(brush, rc);
- }
- }
+ foreach (Rectangle rc in rects)
+ FillRectangle(brush, rc);
}
- [MonoTODO]
public void FillRectangles (Brush brush, RectangleF [] rects)
{
- if(rects != null) {
- foreach( RectangleF rc in rects) {
- FillRectangle(brush, rc);
- }
- }
+ foreach (RectangleF rc in rects)
+ FillRectangle(brush, rc);
}
[MonoTODO]
@@ -1167,21 +1177,19 @@ namespace System.Drawing
}
[MonoTODO]
- public SizeF MeasureString (string text, Font font, SizeF layoutArea, StringFormat stringFormat, ref int charactersFitted, ref int linesFilled)
+ public SizeF MeasureString (string text, Font font, SizeF layoutArea, StringFormat stringFormat, out int charactersFitted, out int linesFilled)
{
throw new NotImplementedException ();
}
- [MonoTODO]
public void MultiplyTransform (Matrix matrix)
{
- throw new NotImplementedException ();
+ MultiplyTransform (matrix, MatrixOrder.Prepend);
}
- [MonoTODO]
public void MultiplyTransform (Matrix matrix, MatrixOrder order)
{
- throw new NotImplementedException ();
+ GDIPlus.GdipMultiplyWorldTransform (nativeObject, matrix.nativeMatrix, order);
}
[MonoTODO]
@@ -1202,16 +1210,15 @@ namespace System.Drawing
throw new NotImplementedException ();
}
- [MonoTODO]
public void ResetTransform ()
{
- throw new NotImplementedException ();
+ GDIPlus.GdipResetWorldTransform (nativeObject);
}
[MonoTODO]
public void Restore (GraphicsState gstate)
{
- transform = gstate.matrix.Clone();
+ Transform = gstate.matrix.Clone();
GDIPlus.GdipRestoreGraphics (nativeObject, gstate.nativeState);
}
@@ -1225,7 +1232,7 @@ namespace System.Drawing
public void RotateTransform (float angle, MatrixOrder order)
{
//transform.Rotate(angle, order);
- GDIPlus.GdipRotateWorldTransform (nativeObject, angle, order);
+ // GDIPlus.GdipRotateWorldTransform (nativeObject, angle, order);
}
[MonoTODO]
@@ -1233,21 +1240,19 @@ namespace System.Drawing
{
//return implementation.Save();
GraphicsState state = new GraphicsState();
- state.matrix = transform.Clone();
+ state.matrix = Transform.Clone();
GDIPlus.GdipSaveGraphics (nativeObject, out state.nativeState);
return state;
}
- [MonoTODO]
public void ScaleTransform (float sx, float sy)
{
- throw new NotImplementedException ();
+ ScaleTransform (sx, sy, MatrixOrder.Prepend);
}
- [MonoTODO]
public void ScaleTransform (float sx, float sy, MatrixOrder order)
{
- throw new NotImplementedException ();
+ GDIPlus.GdipScaleWorldTransform (nativeObject, sx, sy, order);
}
[MonoTODO]
@@ -1328,10 +1333,9 @@ namespace System.Drawing
throw new NotImplementedException ();
}
- [MonoTODO]
public void TranslateTransform (float dx, float dy)
{
- TranslateTransform(dx, dy, MatrixOrder.Prepend);
+ TranslateTransform (dx, dy, MatrixOrder.Prepend);
}
[MonoTODO]
@@ -1341,8 +1345,7 @@ namespace System.Drawing
GDIPlus.GdipTranslateWorldTransform (nativeObject, dx, dy, order);
}
- public Region Clip
- {
+ public Region Clip {
get {
throw new NotImplementedException ();
}
@@ -1351,15 +1354,13 @@ namespace System.Drawing
}
}
- public RectangleF ClipBounds
- {
+ public RectangleF ClipBounds {
get {
throw new NotImplementedException ();
}
}
- public CompositingMode CompositingMode
- {
+ public CompositingMode CompositingMode {
get {
throw new NotImplementedException ();
}
@@ -1368,8 +1369,8 @@ namespace System.Drawing
}
}
- public CompositingQuality CompositingQuality
- {
+
+ public CompositingQuality CompositingQuality {
get {
throw new NotImplementedException ();
}
@@ -1378,22 +1379,19 @@ namespace System.Drawing
}
}
- public float DpiX
- {
+ public float DpiX {
get {
throw new NotImplementedException ();
}
}
- public float DpiY
- {
+ public float DpiY {
get {
throw new NotImplementedException ();
}
}
- public InterpolationMode InterpolationMode
- {
+ public InterpolationMode InterpolationMode {
get {
throw new NotImplementedException ();
}
@@ -1402,22 +1400,19 @@ namespace System.Drawing
}
}
- public bool IsClipEmpty
- {
+ public bool IsClipEmpty {
get {
throw new NotImplementedException ();
}
}
- public bool IsVisibleClipEmpty
- {
+ public bool IsVisibleClipEmpty {
get {
throw new NotImplementedException ();
}
}
- public float PageScale
- {
+ public float PageScale {
get {
throw new NotImplementedException ();
}
@@ -1426,8 +1421,7 @@ namespace System.Drawing
}
}
- public GraphicsUnit PageUnit
- {
+ public GraphicsUnit PageUnit {
get {
throw new NotImplementedException ();
}
@@ -1436,8 +1430,7 @@ namespace System.Drawing
}
}
- public PixelOffsetMode PixelOffsetMode
- {
+ public PixelOffsetMode PixelOffsetMode {
get {
throw new NotImplementedException ();
}
@@ -1489,10 +1482,13 @@ namespace System.Drawing
public Matrix Transform {
get {
- return transform;
+ Matrix matrix = new Matrix ();
+ GDIPlus.GdipGetWorldTransform (nativeObject, matrix.nativeMatrix);
+
+ return matrix;
}
set {
- transform = value.Clone();
+ GDIPlus.GdipSetWorldTransform (nativeObject, value.nativeMatrix);
}
}
diff --git a/mcs/class/System.Drawing/System.Drawing/Icon.cs b/mcs/class/System.Drawing/System.Drawing/Icon.cs
index 7b7a75348f3..4edb14ee706 100644
--- a/mcs/class/System.Drawing/System.Drawing/Icon.cs
+++ b/mcs/class/System.Drawing/System.Drawing/Icon.cs
@@ -10,11 +10,16 @@
using System;
using System.IO;
using System.Runtime.Serialization;
+using System.Runtime.InteropServices;
+using System.ComponentModel;
namespace System.Drawing
{
[Serializable]
+ [ComVisible (false)]
+ [Editor ("System.Drawing.Design.IconEditor, " + Consts.AssemblySystem_Drawing_Design, typeof (System.Drawing.Design.UITypeEditor))]
+ [TypeConverter(typeof(IconConverter))]
public sealed class Icon : MarshalByRefObject, ISerializable, ICloneable, IDisposable
{
diff --git a/mcs/class/System.Drawing/System.Drawing/IconConverter.cs b/mcs/class/System.Drawing/System.Drawing/IconConverter.cs
index 68d79cf2338..d3f8e5ffd5a 100644
--- a/mcs/class/System.Drawing/System.Drawing/IconConverter.cs
+++ b/mcs/class/System.Drawing/System.Drawing/IconConverter.cs
@@ -1,19 +1,24 @@
//
// System.Drawing.IconConverter.cs
//
-// Author:
-// Dennis Hayes (dennish@Raytek.com)
+// Authors:
+// Dennis Hayes (dennish@Raytek.com)
+// Andreas Nahr (ClassDevelopment@A-SoftTech.com)
//
// (C) 2002 Ximian, Inc
-//
-using System;
+//
+
+using System;
+using System.ComponentModel;
namespace System.Drawing {
/// <summary>
/// Summary description for IconConverter.
/// </summary>
- public class IconConverter {
- public IconConverter() {
+ public class IconConverter : ExpandableObjectConverter
+ {
+ public IconConverter()
+ {
}
}
}
diff --git a/mcs/class/System.Drawing/System.Drawing/Image.cs b/mcs/class/System.Drawing/System.Drawing/Image.cs
index c24adfc6ccd..258d5177a07 100644
--- a/mcs/class/System.Drawing/System.Drawing/Image.cs
+++ b/mcs/class/System.Drawing/System.Drawing/Image.cs
@@ -14,10 +14,15 @@ using System;
using System.Runtime.Remoting;
using System.Runtime.Serialization;
using System.Runtime.InteropServices;
+using System.ComponentModel;
using System.Drawing.Imaging;
using System.IO;
[Serializable]
+[ComVisible (true)]
+[Editor ("System.Drawing.Design.ImageEditor, " + Consts.AssemblySystem_Drawing_Design, typeof (System.Drawing.Design.UITypeEditor))]
+[TypeConverter (typeof(ImageConverter))]
+[ImmutableObject (true)]
public abstract class Image : MarshalByRefObject, IDisposable , ICloneable, ISerializable
{
public delegate bool GetThumbnailImageAbort ();
diff --git a/mcs/class/System.Drawing/System.Drawing/ImageAnimator.cs b/mcs/class/System.Drawing/System.Drawing/ImageAnimator.cs
index cd27fb008fc..46d4f799ddf 100644
--- a/mcs/class/System.Drawing/System.Drawing/ImageAnimator.cs
+++ b/mcs/class/System.Drawing/System.Drawing/ImageAnimator.cs
@@ -13,9 +13,9 @@ namespace System.Drawing
/// <summary>
/// Summary description for ImageAnimator.
/// </summary>
- public class ImageAnimator
+ public sealed class ImageAnimator
{
- public ImageAnimator()
+ private ImageAnimator ()
{
//
// TODO: Add constructor logic here
diff --git a/mcs/class/System.Drawing/System.Drawing/ImageConverter.cs b/mcs/class/System.Drawing/System.Drawing/ImageConverter.cs
index 4a2e6cfe935..a4f9efb2102 100644
--- a/mcs/class/System.Drawing/System.Drawing/ImageConverter.cs
+++ b/mcs/class/System.Drawing/System.Drawing/ImageConverter.cs
@@ -5,21 +5,20 @@
// Dennis Hayes (dennish@Raytek.com)
//
// (C) 2002 Ximian, Inc
-//
-using System;
+//
+
+using System;
+using System.ComponentModel;
namespace System.Drawing
{
/// <summary>
/// Summary description for ImageConverter.
/// </summary>
- public class ImageConverter
+ public class ImageConverter : TypeConverter
{
public ImageConverter()
{
- //
- // TODO: Add constructor logic here
- //
}
}
}
diff --git a/mcs/class/System.Drawing/System.Drawing/ImageFormatConverter.cs b/mcs/class/System.Drawing/System.Drawing/ImageFormatConverter.cs
index ea71b0444aa..85d4b5a467e 100644
--- a/mcs/class/System.Drawing/System.Drawing/ImageFormatConverter.cs
+++ b/mcs/class/System.Drawing/System.Drawing/ImageFormatConverter.cs
@@ -1,19 +1,21 @@
//
-// System.Drawing.FontConverter.cs
+// System.Drawing.ImageFormatConverter.cs
//
// Author:
// Dennis Hayes (dennish@Raytek.com)
//
// (C) 2002 Ximian, Inc
-//
-using System;
+//
+
+using System;
+using System.ComponentModel;
namespace System.Drawing
{
/// <summary>
/// Summary description for ImageFormatConverter.
/// </summary>
- public class ImageFormatConverter
+ public class ImageFormatConverter : TypeConverter
{
public ImageFormatConverter()
{
diff --git a/mcs/class/System.Drawing/System.Drawing/Pen.cs b/mcs/class/System.Drawing/System.Drawing/Pen.cs
index ed1d8c5232f..aca3ccfd8b5 100755
--- a/mcs/class/System.Drawing/System.Drawing/Pen.cs
+++ b/mcs/class/System.Drawing/System.Drawing/Pen.cs
@@ -4,23 +4,25 @@
// Author:
// Miguel de Icaza (miguel@ximian.com)
// Alexandre Pigolkine (pigolkine@gmx.de)
+// Duncan Mak (duncan@ximian.com)
//
// (C) Ximian, Inc. http://www.ximian.com
//
using System;
using System.Drawing.Drawing2D;
+using System.Runtime.InteropServices;
namespace System.Drawing {
public sealed class Pen : MarshalByRefObject, ICloneable, IDisposable {
- Brush brush;
- Color color;
- float width;
internal IntPtr nativeObject;
- PenAlignment alignment;
-
+ internal Pen (IntPtr p)
+ {
+ nativeObject = p;
+ }
+
public Pen (Brush brush) : this (brush, 1.0F)
{
}
@@ -31,14 +33,13 @@ namespace System.Drawing {
public Pen (Brush brush, float width)
{
- this.width = width;
- this.brush = brush;
+ int pen;
+ GDIPlus.GdipCreatePen2 (brush.nativeObject, width, Unit.UnitWorld, out pen);
+ nativeObject = (IntPtr) pen;
}
public Pen (Color color, float width)
{
- this.width = width;
- this.color = color;
int pen;
GDIPlus.GdipCreatePen1 (color.ToArgb (), width, Unit.UnitWorld, out pen);
nativeObject = (IntPtr)pen;
@@ -49,51 +50,251 @@ namespace System.Drawing {
//
public PenAlignment Alignment {
get {
- return alignment;
- }
+ PenAlignment retval;
+ GDIPlus.GdipGetPenMode (nativeObject, out retval);
+
+ return retval;
+ }
set {
- alignment = value;
+ GDIPlus.GdipSetPenMode (nativeObject, value);
}
}
public Brush Brush {
get {
- return brush;
- }
+ IntPtr retval;
+ GDIPlus.GdipGetPenBrushFill (nativeObject, out retval);
+ BrushType type;
+ GDIPlus.GdipGetBrushType (retval, out type);
+
+ return Brush.CreateBrush (retval, type);
+ }
set {
- brush = value;
+ GDIPlus.GdipSetPenBrushFill (nativeObject, value.nativeObject);
}
}
public Color Color {
get {
- return color;
+ int argb;
+ GDIPlus.GdipGetPenColor (nativeObject, out argb);
+
+ return Color.FromArgb (argb);
+ }
+
+ set {
+ GDIPlus.GdipSetPenColor (nativeObject, value.ToArgb ());
+ }
+ }
+
+ public float [] CompoundArray {
+ get {
+ throw new NotImplementedException ();
+// int count;
+// GDIPlus.GdipGetPenCompoundArrayCount (nativeObject, out count);
+
+// IntPtr tmp = Marshal.AllocHGlobal (8 * count);
+// GDIPlus.GdipGetPenCompoundArray (nativeObject, out tmp, out count);
+
+// float [] retval = new float [count];
+// Marshal.Copy (tmp, retval, 0, count);
+
+// Marshal.FreeHGlobal (tmp);
+
+// return retval;
+ }
+
+ set {
+ throw new NotImplementedException ();
+// int length = value.Length;
+// IntPtr tmp = Marshal.AllocHGlobal (8 * length);
+// Marshal.Copy (value, 0, tmp, length);
+// GDIPlus.GdipSetPenCompoundArray (nativeObject, tmp, length);
+
+// Marshal.FreeHGlobal (tmp);
+ }
+ }
+
+ [MonoTODO]
+ public CustomLineCap CustomEndCap {
+ get {
+ throw new NotImplementedException ();
+ }
+
+ set {
+ throw new NotImplementedException ();
+ }
+ }
+
+ [MonoTODO]
+ public CustomLineCap CustomStartCap {
+
+ get {
+ throw new NotImplementedException ();
+ }
+
+ set {
+ throw new NotImplementedException ();
+ }
+ }
+
+ public DashCap DashCap {
+
+ get {
+ DashCap retval;
+ GDIPlus.GdipGetPenDashCap (nativeObject, out retval);
+
+ return retval;
+ }
+
+ set {
+ GDIPlus.GdipSetPenDashCap (nativeObject, value);
+ }
+ }
+
+ public float DashOffset {
+
+ get {
+ float retval;
+ GDIPlus.GdipGetPenDashOffset (nativeObject, out retval);
+
+ return retval;
+ }
+
+ set {
+ GDIPlus.GdipSetPenDashOffset (nativeObject, value);
+ }
+ }
+
+ public float [] DashPattern {
+ get {
+ int count;
+ GDIPlus.GdipGetPenDashCount (nativeObject, out count);
+
+ IntPtr tmp = Marshal.AllocHGlobal (8 * count);
+ GDIPlus.GdipGetPenDashArray (nativeObject, out tmp, out count);
+
+ float [] retval = new float [count];
+ Marshal.Copy (tmp, retval, 0, count);
+
+ Marshal.FreeHGlobal (tmp);
+
+ return retval;
+ }
+
+ set {
+ int length = value.Length;
+ IntPtr tmp = Marshal.AllocHGlobal (8 * length);
+ Marshal.Copy (value, 0, tmp, length);
+ GDIPlus.GdipSetPenDashArray (nativeObject, tmp, length);
+
+ Marshal.FreeHGlobal (tmp);
+ }
+ }
+
+ public DashStyle DashStyle {
+ get {
+ DashStyle retval;
+ GDIPlus.GdipGetPenDashStyle (nativeObject, out retval);
+
+ return retval;
+ }
+
+ set {
+ GDIPlus.GdipSetPenDashStyle (nativeObject, value);
+ }
+ }
+
+ public LineCap StartCap {
+ get {
+ throw new NotImplementedException ();
+// LineCap retval;
+// GDIPlus.GdipGetPenStartCap (nativeObject, out retval);
+
+// return retval;
+ }
+
+ set {
+ throw new NotImplementedException ();
+// GDIPlus.GdipSetPenStartCap (nativeObject, value);
+ }
+ }
+
+ public LineCap EndCap {
+ get {
+ throw new NotImplementedException ();
+// LineCap retval;
+// GDIPlus.GdipGetPenEndCap (nativeObject, out retval);
+
+// return retval;
}
set {
- color = value;
+ throw new NotImplementedException ();
+// GDIPlus.GdipSetPenEndCap (nativeObject, value);
}
}
+
+ public LineJoin LineJoin {
+
+ get {
+ LineJoin result;
+ GDIPlus.GdipGetPenLineJoin (nativeObject, out result);
+ return result;
+ }
+
+ set {
+ GDIPlus.GdipSetPenLineJoin (nativeObject, value);
+ }
+
+ }
+
+ public float MiterLimit {
+
+ get {
+ float result;
+ GDIPlus.GdipGetPenMiterLimit (nativeObject, out result);
+ return result;
+ }
+
+ set {
+ GDIPlus.GdipSetPenMiterLimit (nativeObject, value);
+ }
+
+ }
+
+ public Matrix Transform {
+
+ get {
+ Matrix result;
+ GDIPlus.GdipGetPenTransform (nativeObject, out result);
+ return result;
+ }
+
+ set {
+ GDIPlus.GdipSetPenTransform (nativeObject, value);
+ }
+ }
public float Width {
get {
- return width;
+ float f;
+ GDIPlus.GdipGetPenWidth (nativeObject, out f);
+ return f;
}
set {
- width = value;
+ GDIPlus.GdipSetPenWidth (nativeObject, value);
}
}
public object Clone ()
{
- Pen p = new Pen (brush, width);
-
- p.color = color;
- p.alignment = alignment;
+ IntPtr ptr;
+ GDIPlus.GdipClonePen (nativeObject, out ptr);
- return p;
+ return new Pen (ptr);
}
public void Dispose ()
@@ -104,11 +305,62 @@ namespace System.Drawing {
void Dispose (bool disposing)
{
+ GDIPlus.GdipDeletePen (nativeObject);
}
~Pen ()
{
Dispose (false);
}
+
+ public void MultiplyTransform (Matrix matrix)
+ {
+ MultiplyTransform (matrix, MatrixOrder.Prepend);
+ }
+
+ public void MultiplyTransform (Matrix matrix, MatrixOrder order)
+ {
+ GDIPlus.GdipMultiplyPenTransform (nativeObject, matrix.nativeMatrix, order);
+ }
+
+ public void ResetTransform ()
+ {
+ GDIPlus.GdipResetPenTransform (nativeObject);
+ }
+
+ public void RotateTransform (float angle)
+ {
+ RotateTransform (angle, MatrixOrder.Prepend);
+ }
+
+ public void RotateTransform (float angle, MatrixOrder order)
+ {
+ GDIPlus.GdipRotatePenTransform (nativeObject, angle, order);
+ }
+
+ public void ScaleTransform (float sx, float sy)
+ {
+ ScaleTransform (sx, sy, MatrixOrder.Prepend);
+ }
+
+ public void ScaleTransform (float sx, float sy, MatrixOrder order)
+ {
+ GDIPlus.GdipScalePenTransform (nativeObject, sx, sy, order);
+ }
+
+ public void SetLineCap (LineCap startCap, LineCap endCap, DashCap dashCap)
+ {
+ // GDIPlus.GdipSetLineCap197819 (nativeObject, startCap, endCap, dashCap);
+ }
+
+ public void TranslateTransform (float dx, float dy)
+ {
+ TranslateTransform (dx, dy, MatrixOrder.Prepend);
+ }
+
+ public void TranslateTransform (float dx, float dy, MatrixOrder order)
+ {
+ GDIPlus.GdipTranslatePenTransform (nativeObject, dx, dy, order);
+ }
}
}
diff --git a/mcs/class/System.Drawing/System.Drawing/Point.cs b/mcs/class/System.Drawing/System.Drawing/Point.cs
index 126326cd508..de21009efeb 100644
--- a/mcs/class/System.Drawing/System.Drawing/Point.cs
+++ b/mcs/class/System.Drawing/System.Drawing/Point.cs
@@ -8,10 +8,14 @@
//
using System;
+using System.Runtime.InteropServices;
+using System.ComponentModel;
namespace System.Drawing {
[Serializable]
+ [ComVisible (true)]
+ [TypeConverter(typeof(PointConverter))]
public struct Point {
// Private x and y coordinate fields.
diff --git a/mcs/class/System.Drawing/System.Drawing/PointF.cs b/mcs/class/System.Drawing/System.Drawing/PointF.cs
index 42895bdac4a..1a6c0f9fd08 100644
--- a/mcs/class/System.Drawing/System.Drawing/PointF.cs
+++ b/mcs/class/System.Drawing/System.Drawing/PointF.cs
@@ -8,9 +8,11 @@
//
using System;
+using System.Runtime.InteropServices;
namespace System.Drawing {
+ [ComVisible (true)]
public struct PointF {
// Private x and y coordinate fields.
diff --git a/mcs/class/System.Drawing/System.Drawing/Rectangle.cs b/mcs/class/System.Drawing/System.Drawing/Rectangle.cs
index 2dd8b615368..90b8612cc43 100644
--- a/mcs/class/System.Drawing/System.Drawing/Rectangle.cs
+++ b/mcs/class/System.Drawing/System.Drawing/Rectangle.cs
@@ -9,10 +9,13 @@
using System;
using System.Runtime.InteropServices;
+using System.ComponentModel;
namespace System.Drawing {
[StructLayout(LayoutKind.Sequential)]
+ [ComVisible (true)]
+ [TypeConverter(typeof(RectangleConverter))]
public struct Rectangle {
int x, y, width, height;
diff --git a/mcs/class/System.Drawing/System.Drawing/Region.cs b/mcs/class/System.Drawing/System.Drawing/Region.cs
index ee84e2cde05..7b9e17c5bfc 100644
--- a/mcs/class/System.Drawing/System.Drawing/Region.cs
+++ b/mcs/class/System.Drawing/System.Drawing/Region.cs
@@ -1,179 +1,280 @@
-//
-// System.Drawing.Region.cs
-//
-// Author:
-// Miguel de Icaza (miguel@ximian.com)
-//
-// (C) 2003 Ximian, Inc
-//
-using System;
-using System.Drawing.Drawing2D;
-using System.Runtime.InteropServices;
-
-namespace System.Drawing
-{
- [ComVisible(false)]
- public sealed class Region : MarshalByRefObject, IDisposable
- {
- public Region()
- {
- // Initialize region with infinite interior.
- }
-
- public Region (GraphicsPath path)
- {
- // Initializes the Region from the GraphicsPath
- }
-
- public Region (Rectangle rect)
- {
- }
-
- public Region (RectangleF rect)
- {
- }
-
- public Region (RegionData region_data)
- {
- }
-
- //
- // Union
- //
-
- public void Union (GraphicsPath path)
- {
- }
-
- public void Union (Rectangle rect)
- {
- }
-
- public void Union (RectangleF rect)
- {
- }
-
- public void Union (Region region)
- {
- }
-
-
- //
- // Intersect
- //
- public void Intersect (GraphicsPath path)
- {
- }
-
- public void Intersect (Rectangle rect)
- {
- }
-
- public void Intersect (RectangleF rect)
- {
- }
-
- public void Intersect (Region region)
- {
- }
-
- //
- // Complement
- //
- public void Complement (GraphicsPath path)
- {
- }
-
- public void Complement (Rectangle rect)
- {
- }
-
- public void Complement (RectangleF rect)
- {
- }
-
- public void Complement (Region region)
- {
- }
-
- //
- // Exclude
- //
- public void Exclude (GraphicsPath path)
- {
- }
-
- public void Exclude (Rectangle rect)
- {
- }
-
- public void Exclude (RectangleF rect)
- {
- }
-
- public void Exclude (Region region)
- {
- }
-
- //
- // Xor
- //
- public void Xor (GraphicsPath path)
- {
- }
-
- public void Xor (Rectangle rect)
- {
- }
-
- public void Xor (RectangleF rect)
- {
- }
-
- public void Xor (Region region)
- {
- }
-
- //
- // GetBounds
- //
- public RectangleF GetBounds (Graphics graphics)
- {
- return new RectangleF ();
- }
-
- //
- // Translate
- //
- public void Translate (int dx, int dy)
- {
- }
-
- public void Translate (float dx, float dy)
- {
- }
-
-
-
- [ComVisible(false)]
- public Region Clone()
- {
- return this;
- }
-
- public void Dispose ()
- {
- Dispose (true);
- System.GC.SuppressFinalize (this);
- }
-
- void Dispose (bool disposing)
- {
- }
-
- ~Region ()
- {
- Dispose (false);
- }
- }
-}
+//
+// System.Drawing.Region.cs
+//
+// Author:
+// Miguel de Icaza (miguel@ximian.com)
+//
+// (C) 2003 Ximian, Inc
+//
+using System;
+using System.Drawing.Drawing2D;
+using System.Runtime.InteropServices;
+
+namespace System.Drawing
+{
+ [ComVisible(false)]
+ public sealed class Region : MarshalByRefObject, IDisposable
+ {
+ public Region()
+ {
+ // Initialize region with infinite interior.
+ }
+
+ public Region (GraphicsPath path)
+ {
+ // Initializes the Region from the GraphicsPath
+ }
+
+ public Region (Rectangle rect)
+ {
+ }
+
+ public Region (RectangleF rect)
+ {
+ }
+
+ public Region (RegionData region_data)
+ {
+ }
+
+ //
+ // Union
+ //
+
+ public void Union (GraphicsPath path)
+ {
+ }
+
+ public void Union (Rectangle rect)
+ {
+ }
+
+ public void Union (RectangleF rect)
+ {
+ }
+
+ public void Union (Region region)
+ {
+ }
+
+
+ //
+ // Intersect
+ //
+ public void Intersect (GraphicsPath path)
+ {
+ }
+
+ public void Intersect (Rectangle rect)
+ {
+ }
+
+ public void Intersect (RectangleF rect)
+ {
+ }
+
+ public void Intersect (Region region)
+ {
+ }
+
+ //
+ // Complement
+ //
+ public void Complement (GraphicsPath path)
+ {
+ }
+
+ public void Complement (Rectangle rect)
+ {
+ }
+
+ public void Complement (RectangleF rect)
+ {
+ }
+
+ public void Complement (Region region)
+ {
+ }
+
+ //
+ // Exclude
+ //
+ public void Exclude (GraphicsPath path)
+ {
+ }
+
+ public void Exclude (Rectangle rect)
+ {
+ }
+
+ public void Exclude (RectangleF rect)
+ {
+ }
+
+ public void Exclude (Region region)
+ {
+ }
+
+ //
+ // Xor
+ //
+ public void Xor (GraphicsPath path)
+ {
+ }
+
+ public void Xor (Rectangle rect)
+ {
+ }
+
+ public void Xor (RectangleF rect)
+ {
+ }
+
+ public void Xor (Region region)
+ {
+ }
+
+ //
+ // GetBounds
+ //
+ public RectangleF GetBounds (Graphics graphics)
+ {
+ return new RectangleF ();
+ }
+
+ //
+ // Translate
+ //
+ public void Translate (int dx, int dy)
+ {
+ }
+
+ public void Translate (float dx, float dy)
+ {
+ }
+
+ //
+ // IsVisible
+ //
+ public bool IsVisible(int x, int y, Graphics g)
+ {
+ throw new NotImplementedException ();
+ }
+
+ public bool IsVisible(int x, int y, int width, int height)
+ {
+ throw new NotImplementedException ();
+ }
+
+ public bool IsVisible(int x, int y, int width, int height, Graphics g)
+ {
+ throw new NotImplementedException ();
+ }
+
+ public bool IsVisible(Point point)
+ {
+ throw new NotImplementedException ();
+ }
+
+ public bool IsVisible(PointF point)
+ {
+ throw new NotImplementedException ();
+ }
+
+ public bool IsVisible(Point point, Graphics g)
+ {
+ throw new NotImplementedException ();
+ }
+
+ public bool IsVisible(PointF point, Graphics g)
+ {
+ throw new NotImplementedException ();
+ }
+
+ public bool IsVisible(Rectangle rect)
+ {
+ throw new NotImplementedException ();
+ }
+
+ public bool IsVisible(RectangleF rect)
+ {
+ throw new NotImplementedException ();
+ }
+
+ public bool IsVisible(Rectangle rect, Graphics g)
+ {
+ throw new NotImplementedException ();
+ }
+
+ public bool IsVisible(RectangleF rect, Graphics g)
+ {
+ throw new NotImplementedException ();
+ }
+
+ public bool IsVisible(float x, float y)
+ {
+ throw new NotImplementedException ();
+ }
+
+ public bool IsVisible(float x, float y, Graphics g)
+ {
+ throw new NotImplementedException ();
+ }
+
+ public bool IsVisible(float x, float y, float width, float height)
+ {
+ throw new NotImplementedException ();
+ }
+
+ public bool IsVisible(float x, float y, float width, float height, Graphics g)
+ {
+ throw new NotImplementedException ();
+ }
+
+
+ //
+ // Miscellaneous
+ //
+
+ public bool IsEmpty(Graphics g)
+ {
+ throw new NotImplementedException ();
+ }
+
+ public bool IsInfinite(Graphics g)
+ {
+ throw new NotImplementedException ();
+ }
+
+ public void MakeEmpty()
+ {
+ }
+
+ public void MakeInfinite()
+ {
+ throw new NotImplementedException ();
+ }
+
+
+ [ComVisible(false)]
+ public Region Clone()
+ {
+ return this;
+ }
+
+ public void Dispose ()
+ {
+ Dispose (true);
+ System.GC.SuppressFinalize (this);
+ }
+
+ void Dispose (bool disposing)
+ {
+ }
+
+ ~Region ()
+ {
+ Dispose (false);
+ }
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing/Size.cs b/mcs/class/System.Drawing/System.Drawing/Size.cs
index 3409d805321..441c4c8b3ba 100644
--- a/mcs/class/System.Drawing/System.Drawing/Size.cs
+++ b/mcs/class/System.Drawing/System.Drawing/Size.cs
@@ -9,10 +9,14 @@
using System;
using System.Runtime.Serialization;
+using System.Runtime.InteropServices;
+using System.ComponentModel;
namespace System.Drawing {
[Serializable]
+ [ComVisible (true)]
+ [TypeConverter(typeof(SizeConverter))]
public struct Size {
// Private Height and width fields.
diff --git a/mcs/class/System.Drawing/System.Drawing/SizeConverter.cs b/mcs/class/System.Drawing/System.Drawing/SizeConverter.cs
index b1fea07e3e0..5a91c0133c0 100644
--- a/mcs/class/System.Drawing/System.Drawing/SizeConverter.cs
+++ b/mcs/class/System.Drawing/System.Drawing/SizeConverter.cs
@@ -1,25 +1,71 @@
//
// System.Drawing.SizeConverter.cs
//
-// Author:
-// Dennis Hayes (dennish@Raytek.com)
+// Authors:
+// Dennis Hayes (dennish@Raytek.com)
+// Gonzalo Paniagua Javier (gonzalo@ximian.com)
//
// (C) 2002 Ximian, Inc
+// (C) 2003 Novell, Inc. (http://www.novell.com)
//
using System;
+using System.ComponentModel;
+using System.Globalization;
namespace System.Drawing
{
/// <summary>
/// Summary description for SizeConverter.
/// </summary>
- public class SizeConverter
+ public class SizeConverter : TypeConverter
{
public SizeConverter()
{
- //
- // TODO: Add constructor logic here
- //
+ }
+
+ public override bool CanConvertFrom (ITypeDescriptorContext context, Type sourceType)
+ {
+ if (sourceType == typeof (string))
+ return true;
+
+ return base.CanConvertFrom (context, sourceType);
+ }
+
+ [MonoTODO]
+ public override bool CanConvertTo (ITypeDescriptorContext context, Type destinationType)
+ {
+ throw new NotImplementedException ();
+ }
+
+ public override object ConvertFrom (ITypeDescriptorContext context,
+ CultureInfo culture,
+ object value)
+ {
+ string s = value as string;
+ if (s == null)
+ return base.ConvertFrom (context, culture, value);
+
+ string [] subs = s.Split (',');
+ if (subs.Length != 2)
+ throw new ArgumentException ("Error parsing " + s + " as Size", "value");
+
+ try {
+ int width = Int32.Parse (subs [0]);
+ int height = Int32.Parse (subs [0]);
+ return new Size (width, height);
+ } catch {
+ throw new ArgumentException ("Error parsing " + s + " as Size", "value");
+ }
+ }
+
+ [MonoTODO]
+ public override object ConvertTo (ITypeDescriptorContext context,
+ CultureInfo culture,
+ object value,
+ Type destinationType)
+ {
+ throw new NotImplementedException ();
}
}
}
+
diff --git a/mcs/class/System.Drawing/System.Drawing/SizeF.cs b/mcs/class/System.Drawing/System.Drawing/SizeF.cs
index 1aa0155c56d..1e51b4fb650 100644
--- a/mcs/class/System.Drawing/System.Drawing/SizeF.cs
+++ b/mcs/class/System.Drawing/System.Drawing/SizeF.cs
@@ -8,9 +8,11 @@
//
using System;
+using System.Runtime.InteropServices;
namespace System.Drawing {
-
+
+ [ComVisible (true)]
public struct SizeF {
// Private height and width fields.
diff --git a/mcs/class/System.Drawing/System.Drawing/SolidBrush.cs b/mcs/class/System.Drawing/System.Drawing/SolidBrush.cs
index 3a373772624..213ae792580 100644
--- a/mcs/class/System.Drawing/System.Drawing/SolidBrush.cs
+++ b/mcs/class/System.Drawing/System.Drawing/SolidBrush.cs
@@ -11,15 +11,21 @@ using System;
namespace System.Drawing
{
- public class SolidBrush : Brush {
+ public sealed class SolidBrush : Brush {
Color color;
- public SolidBrush( Color color ) {
+ internal SolidBrush (IntPtr ptr)
+ : base (ptr)
+ {
+ }
+
+ public SolidBrush (Color color)
+ {
this.Color = color;
int brush;
GDIPlus.GdipCreateSolidFill (color.ToArgb (), out brush);
- nativeObject = (IntPtr)brush;
+ nativeObject = (IntPtr) brush;
}
public Color Color {
diff --git a/mcs/class/System.Drawing/System.Drawing/StringFormat.cs b/mcs/class/System.Drawing/System.Drawing/StringFormat.cs
index 7603068272e..8f30edfd46c 100644
--- a/mcs/class/System.Drawing/System.Drawing/StringFormat.cs
+++ b/mcs/class/System.Drawing/System.Drawing/StringFormat.cs
@@ -16,8 +16,9 @@ namespace System.Drawing
/// <summary>
/// Summary description for StringFormat.
/// </summary>
- public class StringFormat
+ public sealed class StringFormat : IDisposable
{
+ private static StringFormat genericDefault;
StringAlignment alignment;
StringAlignment line_alignment;
StringFormatFlags format_flags;
@@ -34,6 +35,10 @@ namespace System.Drawing
format_flags = 0;
}
+ public void Dispose()
+ {
+ }
+
public StringFormat (StringFormat source)
{
alignment = source.alignment;
@@ -102,6 +107,20 @@ namespace System.Drawing
trimming = value;
}
}
-
+
+ public static StringFormat GenericDefault {
+ get {
+ lock (typeof (StringFormat)) {
+ if (genericDefault == null) {
+ genericDefault = new StringFormat ();
+ genericDefault.Alignment = StringAlignment.Near;
+ //genericDefault.DigitSubstitutionMethod = StringDigitSubstitute.User;
+ genericDefault.LineAlignment = StringAlignment.Near;
+ genericDefault.Trimming = StringTrimming.Character;
+ }
+ }
+ return(genericDefault);
+ }
+ }
}
}
diff --git a/mcs/class/System.Drawing/System.Drawing/SystemBrushes.cs b/mcs/class/System.Drawing/System.Drawing/SystemBrushes.cs
index 88be1b262ff..0c040b0eefc 100644
--- a/mcs/class/System.Drawing/System.Drawing/SystemBrushes.cs
+++ b/mcs/class/System.Drawing/System.Drawing/SystemBrushes.cs
@@ -13,14 +13,12 @@ namespace System.Drawing
/// <summary>
/// Summary description for SystemBrushes.
/// </summary>
- public class SystemBrushes
+ public sealed class SystemBrushes
{
- public SystemBrushes()
+ private SystemBrushes()
{
- //
- // TODO: Add constructor logic here
- //
}
+
public static Brush ActiveBorder
{
get {
@@ -67,6 +65,18 @@ namespace System.Drawing
}
}
+ public static Brush ControlDark {
+ get {
+ return new SolidBrush(SystemColors.ControlDark);
+ }
+ }
+
+ public static Brush ControlDarkDark {
+ get {
+ return new SolidBrush(SystemColors.ControlDarkDark);
+ }
+ }
+
public static Brush ControlText {
get {
return new SolidBrush(SystemColors.ControlText);
diff --git a/mcs/class/System.Drawing/System.Drawing/SystemColors.cs b/mcs/class/System.Drawing/System.Drawing/SystemColors.cs
index d7367e21153..bc9c47ac5af 100644
--- a/mcs/class/System.Drawing/System.Drawing/SystemColors.cs
+++ b/mcs/class/System.Drawing/System.Drawing/SystemColors.cs
@@ -1,5 +1,5 @@
//
-// System.Drawing.SystemColors
+// System.Drawing.SystemColors.cs
//
// Authors:
// Gonzalo Paniagua Javier (gonzalo@ximian.com)
@@ -14,6 +14,11 @@ namespace System.Drawing {
public sealed class SystemColors
{
+
+ private SystemColors ()
+ {
+ }
+
static public Color ActiveBorder
{
get {
diff --git a/mcs/class/System.Drawing/System.Drawing/SystemIcons.cs b/mcs/class/System.Drawing/System.Drawing/SystemIcons.cs
index fe66c145500..5d671a46e58 100644
--- a/mcs/class/System.Drawing/System.Drawing/SystemIcons.cs
+++ b/mcs/class/System.Drawing/System.Drawing/SystemIcons.cs
@@ -13,13 +13,10 @@ namespace System.Drawing
/// <summary>
/// Summary description for SystemIcons.
/// </summary>
- public class SystemIcons
+ public sealed class SystemIcons
{
- public SystemIcons()
+ private SystemIcons()
{
- //
- // TODO: Add constructor logic here
- //
}
}
}
diff --git a/mcs/class/System.Drawing/System.Drawing/SystemPens.cs b/mcs/class/System.Drawing/System.Drawing/SystemPens.cs
index bceb5f3ef4a..b748c094002 100644
--- a/mcs/class/System.Drawing/System.Drawing/SystemPens.cs
+++ b/mcs/class/System.Drawing/System.Drawing/SystemPens.cs
@@ -48,6 +48,10 @@ namespace System.Drawing
window_frame = new Pen (SystemColors.WindowFrame);
window_text = new Pen (SystemColors.WindowText);
info_text = new Pen (SystemColors.InfoText);
+ }
+
+ private SystemPens ()
+ {
}
public static Pen ActiveCaptionText {
diff --git a/mcs/class/System.Drawing/System.Drawing/TextureBrush.cs b/mcs/class/System.Drawing/System.Drawing/TextureBrush.cs
index c12cb29b4ef..f62928b49d4 100644
--- a/mcs/class/System.Drawing/System.Drawing/TextureBrush.cs
+++ b/mcs/class/System.Drawing/System.Drawing/TextureBrush.cs
@@ -13,13 +13,16 @@ namespace System.Drawing
/// <summary>
/// Summary description for TextureBrush.
/// </summary>
- public class TextureBrush
+ public sealed class TextureBrush : Brush
{
- public TextureBrush()
+ internal TextureBrush()
{
- //
- // TODO: Add constructor logic here
- //
+ }
+
+ [MonoTODO()]
+ public override object Clone()
+ {
+ throw new NotImplementedException ();
}
}
}
diff --git a/mcs/class/System.Drawing/System.Drawing/gdipEnums.cs b/mcs/class/System.Drawing/System.Drawing/gdipEnums.cs
index 890ac26aee3..74e73e7108b 100644
--- a/mcs/class/System.Drawing/System.Drawing/gdipEnums.cs
+++ b/mcs/class/System.Drawing/System.Drawing/gdipEnums.cs
@@ -49,5 +49,15 @@ namespace System.Drawing {
UnitMillimeter = 6
};
#endregion
+
+ #region BrushType
+ internal enum BrushType {
+ BrushTypeSolidColor = 0,
+ BrushTypeHatchFill = 1,
+ BrushTypeTextureFill = 2,
+ BrushTypePathGradient = 3,
+ BrushTypeLinearGradient = 4
+ }
+ #endregion
}
diff --git a/mcs/class/System.Drawing/System.Drawing/gdipFunctions.cs b/mcs/class/System.Drawing/System.Drawing/gdipFunctions.cs
index 9a9573f80d7..d3dfa316aca 100644
--- a/mcs/class/System.Drawing/System.Drawing/gdipFunctions.cs
+++ b/mcs/class/System.Drawing/System.Drawing/gdipFunctions.cs
@@ -18,7 +18,7 @@ namespace System.Drawing {
public class GDIPlus {
#region gdiplus.dll functions
-
+
// startup / shutdown
[DllImport("gdiplus.dll")]
static internal extern Status GdiplusStartup(ref ulong token, ref GdiplusStartupInput input, ref GdiplusStartupOutput output);
@@ -45,6 +45,8 @@ namespace System.Drawing {
static internal extern Status GdipCloneBrush (IntPtr brush, out IntPtr clonedBrush);
[DllImport("gdiplus.dll")]
static internal extern Status GdipDeleteBrush (IntPtr brush);
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipGetBrushType (IntPtr brush, out BrushType type);
// Solid brush functions
[DllImport("gdiplus.dll")]
@@ -53,105 +55,170 @@ namespace System.Drawing {
// Graphics functions
[DllImport("gdiplus.dll")]
static internal extern Status GdipCreateFromHDC(IntPtr hDC, out int graphics);
-
[DllImport("gdiplus.dll")]
static internal extern Status GdipDeleteGraphics(IntPtr graphics);
-
[DllImport("gdiplus.dll")]
static internal extern Status GdipRestoreGraphics(IntPtr graphics, uint graphicsState);
[DllImport("gdiplus.dll")]
static internal extern Status GdipSaveGraphics(IntPtr graphics, out uint state);
-
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipMultiplyWorldTransform (IntPtr graphics, IntPtr matrix, MatrixOrder order);
+
[DllImport("gdiplus.dll")]
static internal extern Status GdipRotateWorldTransform(IntPtr graphics, float angle, MatrixOrder order);
[DllImport("gdiplus.dll")]
static internal extern Status GdipTranslateWorldTransform(IntPtr graphics, float dx, float dy, MatrixOrder order);
-
[DllImport("gdiplus.dll")]
static internal extern Status GdipDrawBezier (IntPtr graphics, IntPtr pen, float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4);
-
[DllImport("gdiplus.dll")]
static internal extern Status GdipDrawBezierI (IntPtr graphics, IntPtr pen, int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4);
-
[DllImport("gdiplus.dll")]
static internal extern Status GdipDrawEllipseI (IntPtr graphics, IntPtr pen, int x, int y, int width, int height);
-
[DllImport("gdiplus.dll")]
static internal extern Status GdipDrawEllipse (IntPtr graphics, IntPtr pen, float x, float y, float width, float height);
-
[DllImport("gdiplus.dll")]
static internal extern Status GdipDrawLine (IntPtr graphics, IntPtr pen, float x1, float y1, float x2, float y2);
-
[DllImport("gdiplus.dll")]
static internal extern Status GdipDrawLineI (IntPtr graphics, IntPtr pen, int x1, int y1, int x2, int y2);
-
[DllImport ("gdiplus.dll")]
static internal extern Status GdipDrawLines (IntPtr graphics, IntPtr pen, PointF [] points, int count);
-
[DllImport ("gdiplus.dll")]
static internal extern Status GdipDrawLinesI (IntPtr graphics, IntPtr pen, Point [] points, int count);
-
[DllImport ("gdiplus.dll")]
static internal extern Status GdipDrawPie (IntPtr graphics, IntPtr pen, float x, float y, float width, float height, float startAngle, float sweepAngle);
-
[DllImport ("gdiplus.dll")]
static internal extern Status GdipDrawPieI (IntPtr graphics, IntPtr pen, int x, int y, int width, int height, float startAngle, float sweepAngle);
-
[DllImport ("gdiplus.dll")]
static internal extern Status GdipDrawPolygon (IntPtr graphics, IntPtr pen, PointF [] points, int count);
-
[DllImport ("gdiplus.dll")]
static internal extern Status GdipDrawPolygonI (IntPtr graphics, IntPtr pen, Point [] points, int count);
-
[DllImport ("gdiplus.dll")]
static internal extern Status GdipDrawRectangle (IntPtr graphics, IntPtr pen, float x, float y, float width, float height);
-
[DllImport ("gdiplus.dll")]
static internal extern Status GdipDrawRectangleI (IntPtr graphics, IntPtr pen, int x, int y, int width, int height);
-
[DllImport("gdiplus.dll")]
static internal extern Status GdipFillEllipseI (IntPtr graphics, IntPtr pen, int x, int y, int width, int height);
-
[DllImport("gdiplus.dll")]
static internal extern Status GdipFillEllipse (IntPtr graphics, IntPtr pen, float x, float y, float width, float height);
[DllImport ("gdiplus.dll")]
static internal extern Status GdipFillPolygon (IntPtr graphics, IntPtr brush, PointF [] points, int count, FillMode fillMode);
-
[DllImport ("gdiplus.dll")]
static internal extern Status GdipFillPolygonI (IntPtr graphics, IntPtr brush, Point [] points, int count, FillMode fillMode);
-
[DllImport ("gdiplus.dll")]
static internal extern Status GdipFillPolygon2 (IntPtr graphics, IntPtr brush, PointF [] points, int count);
-
[DllImport ("gdiplus.dll")]
static internal extern Status GdipFillPolygon2I (IntPtr graphics, IntPtr brush, Point [] points, int count);
-
[DllImport("gdiplus.dll")]
static internal extern Status GdipFillRectangle (IntPtr graphics, IntPtr brush, float x1, float y1, float x2, float y2);
-
[DllImport("gdiplus.dll")]
- static internal extern Status GdipDrawString (IntPtr graphics, string text, int len, IntPtr font, ref GdipRectF rc, IntPtr format, IntPtr brush);
-
+ static internal extern Status GdipDrawString (IntPtr graphics, string text, int len, IntPtr font, ref GpRectF rc, IntPtr format, IntPtr brush);
[DllImport("gdiplus.dll")]
static internal extern Status GdipGetDC (IntPtr graphics, out int hdc);
-
[DllImport("gdiplus.dll")]
static internal extern Status GdipReleaseDC (IntPtr graphics, IntPtr hdc);
-
[DllImport("gdiplus.dll")]
static internal extern Status GdipDrawImageRectI (IntPtr graphics, IntPtr image, int x, int y, int width, int height);
-
[DllImport ("gdiplus.dll")]
static internal extern Status GdipGetRenderingOrigin (IntPtr graphics, out int x, out int y);
-
[DllImport ("gdiplus.dll")]
static internal extern Status GdipSetRenderingOrigin (IntPtr graphics, int x, int y);
-
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipCloneBitmapAreaI (int x, int y, int width, int height, PixelFormat format, IntPtr original, out int bitmap);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipResetWorldTransform (IntPtr graphics);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipSetWorldTransform (IntPtr graphics, IntPtr matrix);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipGetWorldTransform (IntPtr graphics, IntPtr matrix);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipScaleWorldTransform (IntPtr graphics, float sx, float sy, MatrixOrder order);
+
// Pen functions
[DllImport("gdiplus.dll")]
internal static extern Status GdipCreatePen1(int argb, float width, Unit unit, out int pen);
[DllImport("gdiplus.dll")]
+ internal static extern Status GdipCreatePen2 (IntPtr brush, float width, Unit unit, out int pen);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipClonePen (IntPtr pen, out IntPtr clonepen);
+ [DllImport("gdiplus.dll")]
internal static extern Status GdipDeletePen(IntPtr pen);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipSetPenBrushFill (IntPtr pen, IntPtr brush);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipGetPenBrushFill (IntPtr pen, out IntPtr brush);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipSetPenColor (IntPtr pen, int color);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipGetPenColor (IntPtr pen, out int color);
+// [DllImport("gdiplus.dll")]
+// internal static extern Status GdipSetPenCompoundArray (IntPtr pen, IntPtr dash, int count);
+// [DllImport("gdiplus.dll")]
+// internal static extern Status GdipGetPenCompoundArray (IntPtr pen, out IntPtr dash, out int count);
+// [DllImport("gdiplus.dll")]
+// internal static extern Status GdipGetPenCompoundArrayCount (IntPtr pen, out int count);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipSetPenDashCap (IntPtr pen, DashCap dashCap);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipGetPenDashCap (IntPtr pen, out DashCap dashCap);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipSetPenDashStyle (IntPtr pen, DashStyle dashStyle);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipGetPenDashStyle (IntPtr pen, out DashStyle dashStyle);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipSetPenDashOffset (IntPtr pen, float offset);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipGetPenDashOffset (IntPtr pen, out float offset);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipSetPenDashCount (IntPtr pen, int count);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipGetPenDashCount (IntPtr pen, out int count);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipSetPenDashArray (IntPtr pen, IntPtr dash, int count);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipGetPenDashArray (IntPtr pen, out IntPtr dash, out int count);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipSetPenMiterLimit (IntPtr pen, float miterLimit);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipGetPenMiterLimit (IntPtr pen, out float miterLimit);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipSetPenLineJoin (IntPtr pen, LineJoin lineJoin);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipGetPenLineJoin (IntPtr pen, out LineJoin lineJoin);
+// [DllImport("gdiplus.dll")]
+// internal static extern Status GdipSetPenLineCap197819 (IntPtr pen, LineCap startCap, LineCap endCap, DashCap dashCap);
+// [DllImport("gdiplus.dll")]
+// internal static extern Status GdipGetPenLineCap197819 (IntPtr pen, out LineCap startCap, out LineCap endCap, out DashCap dashCap);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipSetPenMode (IntPtr pen, PenAlignment alignment);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipGetPenMode (IntPtr pen, out PenAlignment alignment);
+// [DllImport("gdiplus.dll")]
+// internal static extern Status GdipSetPenStartCap (IntPtr pen, LineCap startCap);
+// [DllImport("gdiplus.dll")]
+// internal static extern Status GdipGetPenStartCap (IntPtr pen, out LineCap startCap);
+// [DllImport("gdiplus.dll")]
+// internal static extern Status GdipSetPenEndCap (IntPtr pen, LineCap endCap);
+// [DllImport("gdiplus.dll")]
+// internal static extern Status GdipGetPenEndCap (IntPtr pen, out LineCap endCap);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipSetPenTransform (IntPtr pen, Matrix matrix);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipGetPenTransform (IntPtr pen, out Matrix matrix);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipSetPenWidth (IntPtr pen, float width);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipGetPenWidth (IntPtr pen, out float width);
+
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipResetPenTransform (IntPtr pen);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipMultiplyPenTransform (IntPtr pen, IntPtr matrix, MatrixOrder order);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipRotatePenTransform (IntPtr pen, float angle, MatrixOrder order);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipScalePenTransform (IntPtr pen, float sx, float sy, MatrixOrder order);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipTranslatePenTransform (IntPtr pen, float dx, float dy, MatrixOrder order);
// Bitmap functions
[DllImport("gdiplus.dll")]
@@ -161,9 +228,9 @@ namespace System.Drawing {
internal static extern Status GdipCreateBitmapFromGraphics (int width, int height, IntPtr target, out int bitmap);
[DllImport("gdiplus.dll")]
- internal static extern Status GdipBitmapLockBits (IntPtr bmp, ref GdipRect rc, ImageLockMode flags, PixelFormat format, [In, Out] BitmapData bmpData);
+ internal static extern Status GdipBitmapLockBits (IntPtr bmp, ref GpRect rc, ImageLockMode flags, PixelFormat format, [In, Out] BitmapData bmpData);
[DllImport("gdiplus.dll")]
- internal static extern Status ____BitmapLockBits (IntPtr bmp, ref GdipRect rc, ImageLockMode flags, PixelFormat format, ref int width, ref int height, ref int stride, ref int format2, ref int reserved, ref IntPtr scan0);
+ internal static extern Status ____BitmapLockBits (IntPtr bmp, ref GpRect rc, ImageLockMode flags, PixelFormat format, ref int width, ref int height, ref int stride, ref int format2, ref int reserved, ref IntPtr scan0);
[DllImport("gdiplus.dll")]
internal static extern Status GdipBitmapUnlockBits (IntPtr bmp, [In,Out] BitmapData bmpData);
@@ -175,6 +242,54 @@ namespace System.Drawing {
internal static extern Status GdipDrawImageI( IntPtr graphics, IntPtr image, int x, int y);
[DllImport("gdiplus.dll")]
internal static extern Status GdipGetImageGraphicsContext( IntPtr image, out int graphics);
+
+ // Matrix functions
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipCreateMatrix (out IntPtr matrix);
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipCreateMatrix2 (float m11, float m12, float m21, float m22, float dx, float dy, out IntPtr matrix);
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipCreateMatrix3 (GpRectF rect, PointF[] dstplg, out IntPtr matrix);
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipCreateMatrix3I (GpRect rect, Point[] dstplg, out IntPtr matrix);
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipDeleteMatrix (IntPtr matrix);
+
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipCloneMatrix (IntPtr matrix, out IntPtr cloneMatrix);
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipSetMatrixElements (IntPtr matrix, float m11, float m12, float m21, float m22, float dx, float dy);
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipGetMatrixElements (IntPtr matrix, IntPtr matrixOut);
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipMultiplyMatrix (IntPtr matrix, IntPtr matrix2, MatrixOrder order);
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipTranslateMatrix (IntPtr matrix, float offsetX, float offsetY, MatrixOrder order);
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipScaleMatrix (IntPtr matrix, float scaleX, float scaleY, MatrixOrder order);
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipRotateMatrix (IntPtr matrix, float angle, MatrixOrder order);
+
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipShearMatrix (IntPtr matrix, float shearX, float shearY, MatrixOrder order);
+
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipInvertMatrix (IntPtr matrix);
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipTransformMatrixPoints (IntPtr matrix, PointF[] pts, int count);
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipTransformMatrixPointsI (IntPtr matrix, Point[] pts, int count);
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipVectorTransformMatrixPoints (IntPtr matrix, PointF[] pts, int count);
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipVectorTransformMatrixPointsI (IntPtr matrix, Point[] pts, int count);
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipIsMatrixInvertible (IntPtr matrix, out bool result);
+
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipIsMatrixIdentity (IntPtr matrix, out bool result);
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipIsMatrixEqual (IntPtr matrix, IntPtr matrix2, out bool result);
#endregion
}
diff --git a/mcs/class/System.Drawing/System.Drawing/gdipStructs.cs b/mcs/class/System.Drawing/System.Drawing/gdipStructs.cs
index 15e8a78b4f5..1564bc07015 100644
--- a/mcs/class/System.Drawing/System.Drawing/gdipStructs.cs
+++ b/mcs/class/System.Drawing/System.Drawing/gdipStructs.cs
@@ -9,6 +9,7 @@ using System;
using System.Runtime.InteropServices;
using System.Text;
using System.Drawing.Imaging;
+using System.Drawing;
namespace System.Drawing {
[StructLayout(LayoutKind.Sequential)]
@@ -46,21 +47,37 @@ namespace System.Drawing {
}
[StructLayout(LayoutKind.Sequential)]
- internal struct GdipRect
+ internal struct GpRect
{
internal int left;
internal int top;
internal int right;
internal int bottom;
+
+ internal GpRect (Rectangle r)
+ {
+ left = r.Left;
+ top = r.Top;
+ right = r.Right;
+ bottom = r.Bottom;
+ }
}
[StructLayout(LayoutKind.Sequential)]
- internal struct GdipRectF
+ internal struct GpRectF
{
internal float left;
internal float top;
internal float right;
internal float bottom;
+
+ internal GpRectF (RectangleF r)
+ {
+ left = r.Left;
+ top = r.Top;
+ right = r.Right;
+ bottom = r.Bottom;
+ }
}
}
diff --git a/mcs/class/System.Drawing/gdiplus/ChangeLog b/mcs/class/System.Drawing/gdiplus/ChangeLog
index 7152ad14e3c..36055dd123d 100644
--- a/mcs/class/System.Drawing/gdiplus/ChangeLog
+++ b/mcs/class/System.Drawing/gdiplus/ChangeLog
@@ -1,3 +1,122 @@
+2003-11-28 Duncan Mak <duncan@ximian.com>
+
+ * brush.c (gdip_brush_setup): Check on the type of the brush and
+ delegate the implementation to the concrete Brushes,
+ (GdipCloneBrush, GdipDeleteBrush, GdipGetBrushType): Implemented.
+
+ * gdip.h (DashStyle): Fixed typo.
+ (PenAlignment, BrushType): Added new enumerations.
+ (GpBrush): Added new type field.
+ (GpPen): Added new fields: color, brush, mode, dash_array and
+ unit. Updated the header file to include new Pen functions.
+
+ * pen.c (convert_dash_array): Utitlity function for converting
+ from a float* from GDI+ to a double* for Cairo.
+ (GdipCreatePen2, GdipClonePen): Implemented.
+ (PenWidth, BrushFill, Color, PenMode, PenUnit, DashStyle):
+ (DashOffset, DashCount, DashArray): Implemented the Get/Set
+ function pairs for these properties.
+ (GdipGetPenCompoundArray, GdipSetPenCompoundArray):
+ (GdipGetPenCompoundArrayCount): Stubbed.
+
+ * solidbrush.c (gdip_solidfill_init): Utility for initializing a
+ SolidBrush. Sets type as BrushTypeSolidColor.
+ (gdip_solidfill_setup): Moved from gdip_brush_setup.
+ (gdip_solidfill_clone): Implementation for GdipCloneBrush for a
+ GpSolidFill.
+ (GdipSetSolidFillColor, GdipGetSolidFillColor): Implemented.
+
+2003-11-22 Duncan Mak <duncan@ximian.com>
+
+ * matrix.c (GdipCreateMatrix3, GdipCreateMatrix3I): Implemented.
+ (GdipCloneMatrix): Fixed.
+ (GdipShearMatrix, set_shear): Implemented.
+
+ * graphics.c:
+ (GdipGetWorldTransform, GdipMultiplyWorldTransform): Implemented.
+ (GdipRotatePenTransform, GdipTranslatePenTransform): Use GDI+
+ functions instead.
+
+ * gdip.h
+ (GdipRotatePenTransform, GdipTranslatePenTransform): Fix
+ signature.
+ (GdipCreateMatrix3, GdipCreateMatrix3I): Use const appropriately.
+
+2003-11-17 Duncan Mak <duncan@ximian.com>
+
+ * matrix.c (matrix_equals): New helper function help test matrix
+ equality.
+ (GdipIsMatrixIdentity, GdipIsMatrixEqual): Use matrix_equals.
+ (GdipGetMatrixElements): Don't malloc here, because the caller
+ should hand us an allocated array.
+
+2003-11-16 Duncan Mak <duncan@ximian.com>
+
+ * matrix.c (GdipCreateMatrix2, GdipCreateMatrix3)
+ (GdipCreateMatrix3I): Implemented.
+
+ * pen.c (GdipResetPenTransform):
+ (GdipMultiplyPenTransform, GdipTranslatePenTransform):
+ (GdipScalePenTransform, GdipRotatePenTransform): Implemented.
+
+ * matrix.c (set_translate, set_scale, set_rotate): Helper
+ functions copied from Cairo. We are doing this because you can
+ specify the order of multiplcation in GDI+, but not in Cairo.
+
+2003-11-15 Duncan Mak <duncan@ximian.com>
+
+ * graphics.c: Moved PI and GRADTORAD to gdip.h.
+ * gdip.h: Renamed GRADTORAD to DEGTORAD.
+
+ * matrix.c (GdipCloneMatrix): Fix argument order.
+ * matrix.c
+ (GdipMultiplyMatrix, GdipTranslateMatrix, GdipScaleMatrix):
+ (GdipRotateMatrix, GdipInvertMatrix):
+ (GdipTransformMatrixPoints, GdipVectorTransformMatrixPoints):
+ (GdipSetMatrixElements, GdipGetMatrixElements):
+ (GdipIsMatrixInvertible): Implemented.
+
+ * matrix.c (GdipIsMatrixIdentity, GdipIsMatrixEqual): Implemented.
+
+2003-11-14 Duncan Mak <duncan@ximian.com>
+
+ * general.c (gdip_get_status): Take cairo_status_t instead of
+ cairo_t. We need this because this is used in matrix.c and we only
+ have cairo_matrix_t there.
+ * graphics.c: Updated calls to gdip_get_status.
+
+ * pen.c
+ (convert_line_cap, convert_line_join): Added static keyword.
+ (GdipDeletePen): Implemented.
+
+ * matrix.c
+ (GdipCreateMatrix2, GdipCloneMatrix, GdipInvertMatrix): Use
+ gdip_get_status instead of just returning Ok.
+ (GdipRotateMatrix, GdipScaleMatrix, GdipTranslateMatrix):
+ Implemented.
+
+2003-11-12 Duncan Mak <duncan@ximian.com>
+
+ * bitmap.c, brush.c, general.c:
+ * graphics.c, image.c, matrix.c:
+ * pen.c, solidbrush.c: Use gdip.h instead of gdip_main.h.
+
+ * gdip.h: New header file, merged from gdip_main.h and
+ gdip_defs.h.
+
+ * gdip_main.h, gdip_defs.h: Removed.
+
+ * pen.c
+ (convert_line_join, convert_line_cap): new function for converting
+ enumerations between GDI+ and Cairo.
+ (gdip_pen_setup): set miter limit and line join.
+ (GdipSetPenMiterLimit, GdipGetPenMiterLimit):
+ (GdipSetPenLineJoin, GdipGetPenLineJoin):
+ (GdipSetPenLineJoin, GdipGetPenTransform): implemented.
+
+2003-11-12 Alexandre Pigolkine <pigolkine@gmx.de>
+ * bitmap.c copy image funciton added
+
2003-11-06 Duncan Mak <duncan@ximian.com>
* graphics.c (GdipDrawRectangle): Add call to gdip_pen_setup so
diff --git a/mcs/class/System.Drawing/gdiplus/Makefile b/mcs/class/System.Drawing/gdiplus/Makefile
index 4dc4670ec48..a0d8bc29869 100644
--- a/mcs/class/System.Drawing/gdiplus/Makefile
+++ b/mcs/class/System.Drawing/gdiplus/Makefile
@@ -32,6 +32,7 @@ all-local:
make guilibrary; \
else \
echo WARNING: Skipping gdiplus library compilation; \
+ gcc -shared -Wl,-soname,libgdiplus.dll.so -o $(gdiplus) empty.c; \
fi)
clean-local:
@@ -56,6 +57,10 @@ $(gdiplus) : $(local_sources:.c=.o)
$(CCOMPILE) -c -o $@ $^
test-local:
+ echo Done
+
+test:
+ echo DOne
#detect.h detect.libs: detect-stamp
# sh detect
diff --git a/mcs/class/System.Drawing/gdiplus/bitmap.c b/mcs/class/System.Drawing/gdiplus/bitmap.c
index 2adfa16d895..6c30f6ae22e 100644
--- a/mcs/class/System.Drawing/gdiplus/bitmap.c
+++ b/mcs/class/System.Drawing/gdiplus/bitmap.c
@@ -23,7 +23,7 @@
*/
#include <glib.h>
-#include "gdip_main.h"
+#include "gdip.h"
#include "gdip_win32.h"
#include <string.h>
#include <unistd.h>
@@ -225,6 +225,29 @@ GdipCreateBitmapFromGraphics (int width, int height, GpGraphics *graphics, GpBit
return Ok;
}
+GpStatus
+GdipCloneBitmapAreaI (int x, int y, int width, int height, int format, GpBitmap *original, GpBitmap **bitmap)
+{
+ GpBitmap *result = 0;
+ int bmpSize = original->data.Height * original->data.Stride;
+
+ /*
+ * FIXME: Convert format if needed and copy only specified rectangle
+ */
+ result = gdip_bitmap_new ();
+ result->cairo_format = original->cairo_format;
+ result->data.Width = original->data.Width;
+ result->data.Height = original->data.Height;
+ result->data.Stride = original->data.Stride;
+ result->data.PixelFormat = original->data.PixelFormat;
+ result->data.Scan0 = GdipAlloc (bmpSize);
+ memmove (result->data.Scan0, original->data.Scan0, bmpSize);
+ result->data.Reserved = 1;
+
+ *bitmap = result;
+ return Ok;
+}
+
static int
ChangePixelFormat (GpBitmap *bitmap, GdipBitmapData *destData)
{
@@ -234,8 +257,10 @@ ChangePixelFormat (GpBitmap *bitmap, GdipBitmapData *destData)
char * curDst = 0;
int i, j;
- //printf("ChangePixelFormat to %d. Src inc %d, Dest Inc %d\n",
- // destData->PixelFormat, sourcePixelIncrement, destinationPixelIncrement);
+ /*
+ printf("ChangePixelFormat to %d. Src inc %d, Dest Inc %d\n",
+ destData->PixelFormat, sourcePixelIncrement, destinationPixelIncrement);
+ */
if (bitmap->data.PixelFormat == destData->PixelFormat) return 0;
if (destData->PixelFormat != Format32bppArgb && destData->PixelFormat != Format24bppRgb) {
diff --git a/mcs/class/System.Drawing/gdiplus/brush.c b/mcs/class/System.Drawing/gdiplus/brush.c
index 3873e3137c1..dbeb859af84 100644
--- a/mcs/class/System.Drawing/gdiplus/brush.c
+++ b/mcs/class/System.Drawing/gdiplus/brush.c
@@ -22,23 +22,49 @@
* Alexandre Pigolkine(pigolkine@gmx.de)
*/
-#include "gdip_main.h"
+#include "gdip.h"
-void gdip_brush_setup (GpGraphics *graphics, GpBrush *brush)
+void
+gdip_brush_setup (GpGraphics *graphics, GpBrush *brush)
{
- int R = (brush->color & 0x00FF0000 ) >> 16;
- int G = (brush->color & 0x0000FF00 ) >> 8;
- int B = (brush->color & 0x000000FF );
- cairo_set_rgb_color (graphics->ct, (double) R, (double) G, (double) B);
+ GpBrushType type;
+ GdipGetBrushType (brush, &type);
+
+ if (type == BrushTypeSolidColor) {
+ GpSolidFill *solid = brush;
+ gdip_solidfill_setup (graphics, solid);
+ }
+}
+
+GpBrush *
+gdip_brush_new (void)
+{
+ GpBrush *result = (GpBrush *) GdipAlloc (sizeof (GpBrush));
+
+ return result;
}
-GpStatus GdipCloneBrush (GpBrush *brush, GpBrush **clonedBrush)
+GpStatus
+GdipCloneBrush (GpBrush *brush, GpBrush **clonedBrush)
{
- return NotImplemented;
+ GpBrushType type;
+ GdipGetBrushType (brush, &type);
+
+ if (type == BrushTypeSolidColor)
+ return gdip_solidfill_clone (brush, clonedBrush);
+ else
+ return NotImplemented;
}
-GpStatus GdipDeleteBrush (GpBrush *brush)
+GpStatus
+GdipDeleteBrush (GpBrush *brush)
{
- return NotImplemented;
+ GdipFree (brush);
}
+GpStatus
+GdipGetBrushType (GpBrush *brush, GpBrushType *type)
+{
+ *type = brush->type;
+ return Ok;
+}
diff --git a/mcs/class/System.Drawing/gdiplus/empty.c b/mcs/class/System.Drawing/gdiplus/empty.c
new file mode 100755
index 00000000000..264324c5bd1
--- /dev/null
+++ b/mcs/class/System.Drawing/gdiplus/empty.c
@@ -0,0 +1 @@
+/* empty file */
diff --git a/mcs/class/System.Drawing/gdiplus/gdip.h b/mcs/class/System.Drawing/gdiplus/gdip.h
new file mode 100644
index 00000000000..70e41388b9e
--- /dev/null
+++ b/mcs/class/System.Drawing/gdiplus/gdip.h
@@ -0,0 +1,408 @@
+/*
+ * gdip.h
+ *
+ * Authors:
+ * Alexandre Pigolkine (pigolkine@gmx.de)
+ * Duncan Mak (duncan@ximian.com)
+ * Miguel de Icaza (miguel@ximian.com)
+ *
+ * Copyright (C) Novell, Inc. 2003.
+ */
+
+#ifndef _GDIP_H
+#define _GDIP_H
+
+#include <stdlib.h>
+#include <stdio.h>
+
+#include <cairo.h>
+#include <cairo-xlib.h>
+#include <mono/io-layer/uglify.h>
+
+/*
+ * Constants
+ *
+ */
+#define PI 3.14159265358979323846
+#define DEGTORAD PI / 180.0
+
+/*
+ * Enums
+ *
+ */
+
+typedef enum {
+ Ok = 0,
+ GenericError = 1,
+ InvalidParameter = 2,
+ OutOfMemory = 3,
+ ObjectBusy = 4,
+ InsufficientBuffer = 5,
+ NotImplemented = 6,
+ Win32Error = 7,
+ WrongState = 8,
+ Aborted = 9,
+ FileNotFound = 10,
+ ValueOverflow = 11,
+ AccessDenied = 12,
+ UnknownImageFormat = 13,
+ FontFamilyNotFound = 14,
+ FontStyleNotFound = 15,
+ NotTrueTypeFont = 16,
+ UnsupportedGdiplusVersion = 17,
+ GdiplusNotInitialized = 18,
+ PropertyNotFound = 19,
+ PropertyNotSupported = 20
+} GpStatus;
+
+typedef enum {
+ MatrixOrderPrepend = 0,
+ MatrixOrderAppend = 1
+} MatrixOrder, GpMatrixOrder;
+
+typedef enum {
+ UnitWorld = 0,
+ UnitDisplay = 1,
+ UnitPixel = 2,
+ UnitPoint = 3,
+ UnitInch = 4,
+ UnitDocument = 5,
+ UnitMillimeter = 6
+} GpUnit, Unit;
+
+typedef enum {
+ Alpha = 262144,
+ Canonical = 2097152,
+ DontCare = 0,
+ Extended = 1048576,
+ Format16bppArgb1555 = 397319,
+ Format16bppGrayScale = 1052676,
+ Format16bppRgb555 = 135173,
+ Format16bppRgb565 = 135174,
+ Format1bppIndexed = 196865,
+ Format24bppRgb = 137224,
+ Format32bppArgb = 2498570,
+ Format32bppPArgb = 925707,
+ Format32bppRgb = 139273,
+ Format48bppRgb = 1060876,
+ Format4bppIndexed = 197634,
+ Format64bppArgb = 3424269,
+ Format64bppPArgb = 1851406,
+ Format8bppIndexed = 198659,
+ Gdi = 131072,
+ Indexed = 65536,
+ Max = 15,
+ PAlpha = 524288,
+ Undefined = 0
+} PixelFormat;
+
+typedef enum {
+ ReadOnly = 1,
+ ReadWrite = 3,
+ UserInputBuffer = 4,
+ WriteOnly = 2
+} ImageLockMode;
+
+typedef enum {
+ FillModeAlternate,
+ FillModeWinding
+} GpFillMode;
+
+typedef enum {
+ DashStyleSolid = 0, /* solid line */
+ DashStyleDash = 1, /* dashed line */
+ DashStyleDot = 2, /* dotted line */
+ DashStyleDashDot = 3, /* alt. dash-dot */
+ DashStyleDashDotDot = 4, /* alt. dash-dot-dot */
+ DashStyleCustom = 5 /* user-defined */
+} GpDashStyle;
+
+typedef enum {
+ LineJoinMiter = 0, /* sharp corner */
+ LineJoinBevel = 1, /* round corner */
+ LineJoinRound = 2, /* circular, smooth, circular arc */
+ LineJoinMiterClipped = 3 /* miter, sharp or beveled corner */
+} GpLineJoin;
+
+typedef enum {
+ imageUndefined,
+ imageBitmap,
+ imageMetafile
+} ImageType;
+
+typedef enum {
+ gtUndefined,
+ gtX11Drawable,
+ gtMemoryBitmap
+} GraphicsType;
+
+typedef enum {
+ LineCapFlat = 0,
+ LineCapSquare = 1,
+ LineCapRound = 2,
+ LineCapTriangle = 3,
+ LineCapNoAnchor = 0x10,
+ LineCapSquareAnchor = 0x11,
+ LineCapRoundAnchor = 0x12,
+ LineCapDiamondAnchor = 0x13,
+ LineCapArrowAnchor = 0x14,
+ LineCapCustom = 0xff
+} GpLineCap;
+
+typedef enum {
+ PenAlignmentCenter = 0,
+ PenAlignmentInset = 1
+} GpPenAlignment, PenAlignment;
+
+typedef enum {
+ BrushTypeSolidColor = 0,
+ BrushTypeHatchFill = 1,
+ BrushTypeTextureFill = 2,
+ BrushTypePathGradient = 3,
+ BrushTypeLinearGradient = 4
+} GpBrushType, BrushType;
+
+/*
+ * Structures
+ *
+ */
+typedef struct {
+ unsigned int Width;
+ unsigned int Height;
+ int Stride;
+ int PixelFormat;
+ void *Scan0;
+ unsigned int Reserved;
+} GdipBitmapData, BitmapData;
+
+typedef struct {
+ int left, top, right, bottom;
+} GpRect, Rect;
+
+typedef struct tagRectF{
+ float left, top, right, bottom;
+} GpRectF, RectF;
+
+typedef struct {
+ int X, Y;
+} GpPoint, Point;
+
+typedef struct {
+ float X, Y;
+} GpPointF, PointF;
+
+typedef struct {
+ cairo_t *ct;
+ cairo_matrix_t *copy_of_ctm;
+ void *hdc;
+ int hdc_busy_count;
+ void *image;
+ int type;
+} GpGraphics;
+
+typedef cairo_matrix_t GpMatrix;
+
+typedef struct {
+ int color;
+ GpBrushType type;
+} GpBrush, GpSolidFill;
+
+typedef struct {
+ int color;
+ GpBrush *brush;
+ float width;
+ float miter_limit;
+ GpLineJoin line_join;
+ GpDashStyle dash_style;
+ GpLineCap line_cap;
+ GpPenAlignment mode;
+ float dash_offset;
+ int dash_count;
+ float *dash_array;
+ GpUnit unit;
+ GpMatrix *matrix;
+} GpPen;
+
+typedef struct {
+ cairo_matrix_t *matrix;
+} GpState;
+
+typedef struct {
+ ImageType type;
+ cairo_surface_t *surface;
+ GpGraphics *graphics; /* created by GdipGetImageGraphicsContext */
+} GpImage;
+
+typedef struct {
+ GpImage image;
+ int cairo_format;
+ BitmapData data;
+ void *hBitmapDC;
+ void *hInitialBitmap;
+ void *hBitmap;
+} GpBitmap;
+
+typedef struct {
+ GpFillMode fillMode;
+ int count;
+ GpPointF *float_points;
+ GpPoint *int_points;
+} GpPath;
+
+/*
+ * Functions
+ *
+ */
+void gdip_image_init (GpImage *image);
+void *gdip_image_create_Win32_HDC (GpImage *image);
+void gdip_image_destroy_Win32_HDC (GpImage *image, void *hdc);
+
+void gdip_bitmap_init (GpBitmap *bitmap);
+GpBitmap *gdip_bitmap_new (void);
+void gdip_bitmap_dispose (GpBitmap *bitmap);
+
+void *gdip_bitmap_create_Win32_HDC (GpBitmap *bitmap);
+void gdip_bitmap_destroy_Win32_HDC (GpBitmap *bitmap, void *hdc);
+
+void *_get_gdi32Handle (void);
+void *_get_user32Handle (void);
+
+void gdip_graphics_init (GpGraphics *graphics);
+GpGraphics *gdip_graphics_new (void);
+void gdip_graphics_attach_bitmap (GpGraphics *graphics, GpBitmap *image);
+void gdip_graphics_detach_bitmap (GpGraphics *graphics, GpBitmap *image);
+
+/* Brush */
+void gdip_brush_setup (GpGraphics *graphics, GpBrush *brush);
+GpBrush *gdip_brush_new (void);
+
+/* Solid fill */
+void gdip_solidfill_init (GpSolidFill *brush);
+void gdip_solidfill_setup (GpGraphics *graphics, GpBrush *brush);
+GpStatus gdip_solidfill_clone (GpBrush *brush, GpBrush **clonedBrush);
+GpSolidFill *gdip_solidfill_new (void);
+
+/* Pen */
+void gdip_pen_init (GpPen *pen);
+GpPen *gdip_pen_new (void);
+void gdip_pen_setup (GpGraphics *graphics, GpPen *pen);
+
+extern Display *GDIP_display;
+
+void initializeGdipWin32 (void);
+
+/* Bitmap */
+GpStatus GdipCreateBitmapFromScan0 (int width, int height, int strideIn, int format, void *scan0, GpBitmap **bitmap);
+GpStatus GdipCreateBitmapFromGraphics (int width, int height, GpGraphics *graphics, GpBitmap **bitmap);
+GpStatus GdipBitmapLockBits (GpBitmap *bmp, Rect *rc, int flags, int format, GdipBitmapData *result);
+GpStatus GdipBitmapUnlockBits (GpBitmap *bmp, GdipBitmapData *bmpData);
+
+/* Graphics */
+GpStatus GdipCreateFromHDC (int hDC, GpGraphics **graphics);
+GpStatus GdipDeleteGraphics (GpGraphics *graphics);
+GpStatus GdipGetDC (GpGraphics *graphics, int *hDC);
+GpStatus GdipReleaseDC (GpGraphics *graphics, int hDC);
+GpStatus GdipRestoreGraphics (GpGraphics *graphics, unsigned int graphicsState);
+GpStatus GdipSaveGraphics(GpGraphics *graphics, unsigned int * state);
+GpStatus GdipRotateWorldTransform (GpGraphics *graphics, float angle, GpMatrixOrder order);
+GpStatus GdipTranslateWorldTransform (GpGraphics *graphics, float dx, float dy, GpMatrixOrder order);
+GpStatus GdipDrawBezier (GpGraphics *graphics, GpPen *pen, float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4);
+GpStatus GdipDrawBezierI (GpGraphics *graphics, GpPen *pen, int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4);
+GpStatus GdipDrawBeziers (GpGraphics *graphics, GpPen *pen, GpPointF *points, int count);
+GpStatus GdipDrawBeziersI (GpGraphics *graphics, GpPen *pen, GpPoint *points, int count);
+GpStatus GdipDrawEllipse (GpGraphics *graphics, GpPen *pen, float x, float y, float width, float height);
+GpStatus GdipDrawLine (GpGraphics *graphics, GpPen *pen, float x1, float y1, float x2, float y2);
+GpStatus GdipDrawLineI (GpGraphics *graphics, GpPen *pen, int x1, int y1, int x2, int y2);
+GpStatus GdipDrawLines (GpGraphics *graphics, GpPen *pen, GpPointF *points, int count);
+GpStatus GdipDrawLinesI (GpGraphics *graphics, GpPen *pen, GpPoint *points, int count);
+GpStatus GdipDrawPie (GpGraphics *graphics, GpPen *pen, float x, float y, float width, float height, float startAngle, float sweepAngle);
+GpStatus GdipDrawPieI (GpGraphics *graphics, GpPen *pen, int x, int y, int width, int height, float startAngle, float sweepAngle);
+GpStatus GdipDrawPolygon (GpGraphics *graphics, GpPen *pen, GpPointF *points, int count);
+GpStatus GdipDrawPolygonI (GpGraphics *graphics, GpPen *pen, GpPoint *points, int count);
+GpStatus GdipDrawRectangle (GpGraphics *graphics, GpPen *pen, float x, float y, float width, float height);
+GpStatus GdipDrawRectangleI (GpGraphics *graphics, GpPen *pen, int x, int y, int width, int height);
+GpStatus GdipFillEllipse (GpGraphics *graphics, GpBrush *brush, float x, float y, float width, float height);
+GpStatus GdipFillEllipseI (GpGraphics *graphics, GpBrush *brush, int x, int y, int width, int height);
+GpStatus GdipFillRectangle (GpGraphics *graphics, GpBrush *brush, float x1, float y1, float x2, float y2);
+GpStatus GdipFillPolygon (GpGraphics *graphics, GpBrush *brush, GpPointF *points, int count, GpFillMode fillMode);
+GpStatus GdipFillPolygonI (GpGraphics *graphics, GpBrush *brush, GpPoint *points, int count, GpFillMode fillMode);
+GpStatus GdipFillPolygon2 (GpGraphics *graphics, GpBrush *brush, GpPointF *points, int count);
+GpStatus GdipFillPolygon2I (GpGraphics *graphics, GpBrush *brush, GpPoint *points, int count);
+GpStatus GdipSetRenderingOrigin (GpGraphics *graphics, int x, int y);
+GpStatus GdipGetRenderingOrigin (GpGraphics *graphics, int *x, int *y);
+
+/* Status */
+GpStatus gdip_get_status (cairo_status_t status);
+
+/* Brush */
+GpStatus GdipCloneBrush (GpBrush *brush, GpBrush **clonedBrush);
+GpStatus GdipDeleteBrush (GpBrush *brush);
+GpStatus GdipGetBrushType (GpBrush *brush, GpBrushType *brushType);
+
+/* Solidfill Brush */
+GpStatus GdipGetSolidFillColor (GpSolidFill *brush, int *color);
+
+/* Pen */
+GpStatus GdipCreatePen1 (int argb, float width, GpUnit unit, GpPen **pen);
+GpStatus GdipCreatePen2 (GpBrush *brush, float width, GpUnit unit, GpPen **pen);
+GpStatus GdipClonePen (GpPen *pen, GpPen **clonedpen);
+GpStatus GdipSetPenWidth (GpPen *pen, float width);
+GpStatus GdipGetPenWidth (GpPen *pen, float *width);
+GpStatus GdipSetPenBrushFill (GpPen *pen, GpBrush *brush);
+GpStatus GdipGetPenBrushFill (GpPen *pen, GpBrush **brush);
+GpStatus GdipSetPenColor (GpPen *pen, int color);
+GpStatus GdipGetPenColor (GpPen *pen, int *color);;
+GpStatus GdipSetPenDashStyle (GpPen *pen, GpDashStyle dashStyle);
+GpStatus GdipGetPenDashStyle (GpPen *pen, GpDashStyle *dashStyle);
+GpStatus GdipSetPenDashOffset (GpPen *pen, float offset);
+GpStatus GdipGetPenDashOffset (GpPen *pen, float *offset);
+GpStatus GdipSetPenDashCount (GpPen *pen, int count);
+GpStatus GdipGetPenDashCount (GpPen *pen, int *count);
+GpStatus GdipSetPenDashArray (GpPen *pen, float *dash, int count);
+GpStatus GdipGetPenDashArray (GpPen *pen, float **dash, int *count);
+GpStatus GdipSetPenDashCompoundArray (GpPen *pen, float *dash, int count);
+GpStatus GdipGetPenDashCompoundArray (GpPen *pen, float **dash, int *count);
+GpStatus GdipGetPenDashCompoundCount (GpPen *pen, int *count);
+GpStatus GdipSetPenMode (GpPen *pen, GpPenAlignment penMode);
+GpStatus GdipGetPenMode (GpPen *pen, GpPenAlignment *penMode);
+GpStatus GdipSetPenUnit (GpPen *pen, GpUnit unit);
+GpStatus GdipGetPenUnit (GpPen *pen, GpUnit *unit);
+GpStatus GdipDeletePen (GpPen *pen);
+GpStatus GdipSetPenMiterLimit (GpPen *pen, float miterLimit);
+GpStatus GdipGetPenMiterLimit (GpPen *pen, float *miterLimit);
+GpStatus GdipSetPenLineCap (GpPen *pen, GpLineCap lineCap);
+GpStatus GdipGetPenLineCap (GpPen *pen, GpLineCap *lineCap);
+GpStatus GdipSetPenLineJoine (GpPen *pen, GpLineJoin lineJoin);
+GpStatus GdipGetPenLineCap (GpPen *pen, GpLineJoin *lineJoin);
+
+/* Text */
+GpStatus GdipDrawString (GpGraphics *graphics, const char *string, int len, void *font, RectF *rc, void *format, GpBrush *brush);
+
+/* Matrix */
+GpStatus GdipCreateMatrix (GpMatrix **matrix);
+GpStatus GdipCreateMatrix2 (float m11, float m12, float m21, float m22, float dx, float dy, GpMatrix **matrix);
+GpStatus GdipCreateMatrix3 (const GpRectF *rect, const GpPointF *dstplg, GpMatrix **matrix);
+GpStatus GdipCreateMatrix3I (const GpRect *rect, const GpPoint *dstplg, GpMatrix **matrix);
+GpStatus GdipCloneMatrix (GpMatrix *matrix, GpMatrix **cloneMatrix);
+GpStatus GdipDeleteMatrix (GpMatrix *matrix);
+GpStatus GdipSetMatrixElements (GpMatrix *matrix, float m11, float m12, float m21, float m22, float dx, float dy);
+GpStatus GdipMultiplyMatrix (GpMatrix *matrix, GpMatrix *matrix2, GpMatrixOrder order);
+GpStatus GdipTranslateMatrix (GpMatrix *matrix, float offsetX, float offsetY, GpMatrixOrder order);
+GpStatus GdipScaleMatrix (GpMatrix *matrix, float scaleX, float scaleY, GpMatrixOrder order);
+GpStatus GdipRotateMatrix(GpMatrix *matrix, float angle, GpMatrixOrder order);
+GpStatus GdipShearMatrix (GpMatrix *matrix, float shearX, float shearY, GpMatrixOrder order);
+GpStatus GdipInvertMatrix (GpMatrix *matrix);
+GpStatus GdipTransformMatrixPoints (GpMatrix *matrix, GpPointF *pts, int count);
+GpStatus GdipTransformMatrixPointsI (GpMatrix *matrix, GpPoint *pts, int count);
+GpStatus GdipVectorTransformMatrixPoints (GpMatrix *matrix, GpPointF *pts, int count);
+GpStatus GdipVectorTransformMatrixPointsI (GpMatrix *matrix, GpPoint *pts, int count);
+GpStatus GdipGetMatrixElements (GpMatrix *matrix, float *matrixOut);
+GpStatus GdipIsMatrixInvertible (GpMatrix *matrix, int *result);
+GpStatus GdipIsMatrixIdentity (GpMatrix *matrix, int *result);
+GpStatus GdipIsMatrixEqual (GpMatrix *matrix, GpMatrix *matrix2, int *result);
+
+/* Memory */
+void *GdipAlloc (int size);
+void GdipFree (void *ptr);
+
+#endif /* _GDIP_H */
diff --git a/mcs/class/System.Drawing/gdiplus/gdip_defs.h b/mcs/class/System.Drawing/gdiplus/gdip_defs.h
deleted file mode 100644
index 4424cbcf6f9..00000000000
--- a/mcs/class/System.Drawing/gdiplus/gdip_defs.h
+++ /dev/null
@@ -1,162 +0,0 @@
-/*
- * Enums, structs and functions
- */
-
-#ifndef _GDIP_DEFS_H
-#define _GDIP_DEFS_H
-
-typedef enum {
- Ok = 0,
- GenericError = 1,
- InvalidParameter = 2,
- OutOfMemory = 3,
- ObjectBusy = 4,
- InsufficientBuffer = 5,
- NotImplemented = 6,
- Win32Error = 7,
- WrongState = 8,
- Aborted = 9,
- FileNotFound = 10,
- ValueOverflow = 11,
- AccessDenied = 12,
- UnknownImageFormat = 13,
- FontFamilyNotFound = 14,
- FontStyleNotFound = 15,
- NotTrueTypeFont = 16,
- UnsupportedGdiplusVersion = 17,
- GdiplusNotInitialized = 18,
- PropertyNotFound = 19,
- PropertyNotSupported = 20
-} GpStatus;
-
-typedef enum {
- MatrixOrderPrepend = 0,
- MatrixOrderAppend = 1
-} MatrixOrder, GpMatrixOrder;
-
-typedef enum {
- UnitWorld = 0,
- UnitDisplay = 1,
- UnitPixel = 2,
- UnitPoint = 3,
- UnitInch = 4,
- UnitDocument = 5,
- UnitMillimeter = 6
-} Unit;
-
-typedef enum {
- Alpha = 262144,
- Canonical = 2097152,
- DontCare = 0,
- Extended = 1048576,
- Format16bppArgb1555 = 397319,
- Format16bppGrayScale = 1052676,
- Format16bppRgb555 = 135173,
- Format16bppRgb565 = 135174,
- Format1bppIndexed = 196865,
- Format24bppRgb = 137224,
- Format32bppArgb = 2498570,
- Format32bppPArgb = 925707,
- Format32bppRgb = 139273,
- Format48bppRgb = 1060876,
- Format4bppIndexed = 197634,
- Format64bppArgb = 3424269,
- Format64bppPArgb = 1851406,
- Format8bppIndexed = 198659,
- Gdi = 131072,
- Indexed = 65536,
- Max = 15,
- PAlpha = 524288,
- Undefined = 0
-} PixelFormat;
-
-typedef enum {
- ReadOnly = 1,
- ReadWrite = 3,
- UserInputBuffer = 4,
- WriteOnly = 2
-} ImageLockMode;
-
-typedef enum {
- FillModeAlternate,
- FillModeWinding
-} GpFillMode;
-
-/* Bitmap */
-GpStatus GdipCreateBitmapFromScan0 (int width, int height, int strideIn, int format, void *scan0, GpBitmap **bitmap);
-GpStatus GdipCreateBitmapFromGraphics (int width, int height, GpGraphics *graphics, GpBitmap **bitmap);
-GpStatus GdipBitmapLockBits (GpBitmap *bmp, Rect *rc, int flags, int format, GdipBitmapData *result);
-GpStatus GdipBitmapUnlockBits (GpBitmap *bmp, GdipBitmapData *bmpData);
-
-/* Graphics */
-GpStatus GdipCreateFromHDC (int hDC, GpGraphics **graphics);
-GpStatus GdipDeleteGraphics (GpGraphics *graphics);
-GpStatus GdipGetDC (GpGraphics *graphics, int *hDC);
-GpStatus GdipReleaseDC (GpGraphics *graphics, int hDC);
-GpStatus GdipRestoreGraphics (GpGraphics *graphics, unsigned int graphicsState);
-GpStatus GdipSaveGraphics(GpGraphics *graphics, unsigned int * state);
-GpStatus GdipRotateWorldTransform (GpGraphics *graphics, float angle, int order);
-GpStatus GdipTranslateWorldTransform (GpGraphics *graphics, float dx, float dy, int order);
-GpStatus GdipDrawBezier (GpGraphics *graphics, GpPen *pen, float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4);
-GpStatus GdipDrawBezierI (GpGraphics *graphics, GpPen *pen, int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4);
-GpStatus GdipDrawBeziers (GpGraphics *graphics, GpPen *pen, GpPointF *points, int count);
-GpStatus GdipDrawBeziersI (GpGraphics *graphics, GpPen *pen, GpPoint *points, int count);
-GpStatus GdipDrawEllipse (GpGraphics *graphics, GpPen *pen, float x, float y, float width, float height);
-GpStatus GdipDrawLine (GpGraphics *graphics, GpPen *pen, float x1, float y1, float x2, float y2);
-GpStatus GdipDrawLineI (GpGraphics *graphics, GpPen *pen, int x1, int y1, int x2, int y2);
-GpStatus GdipDrawLines (GpGraphics *graphics, GpPen *pen, GpPointF *points, int count);
-GpStatus GdipDrawLinesI (GpGraphics *graphics, GpPen *pen, GpPoint *points, int count);
-GpStatus GdipDrawPie (GpGraphics *graphics, GpPen *pen, float x, float y, float width, float height, float startAngle, float sweepAngle);
-GpStatus GdipDrawPieI (GpGraphics *graphics, GpPen *pen, int x, int y, int width, int height, float startAngle, float sweepAngle);
-GpStatus GdipDrawPolygon (GpGraphics *graphics, GpPen *pen, GpPointF *points, int count);
-GpStatus GdipDrawPolygonI (GpGraphics *graphics, GpPen *pen, GpPoint *points, int count);
-GpStatus GdipDrawRectangle (GpGraphics *graphics, GpPen *pen, float x, float y, float width, float height);
-GpStatus GdipDrawRectangleI (GpGraphics *graphics, GpPen *pen, int x, int y, int width, int height);
-GpStatus GdipFillEllipse (GpGraphics *graphics, GpBrush *brush, float x, float y, float width, float height);
-GpStatus GdipFillEllipseI (GpGraphics *graphics, GpBrush *brush, int x, int y, int width, int height);
-GpStatus GdipFillRectangle (GpGraphics *graphics, GpBrush *brush, float x1, float y1, float x2, float y2);
-GpStatus GdipFillPolygon (GpGraphics *graphics, GpBrush *brush, GpPointF *points, int count, GpFillMode fillMode);
-GpStatus GdipFillPolygonI (GpGraphics *graphics, GpBrush *brush, GpPoint *points, int count, GpFillMode fillMode);
-GpStatus GdipFillPolygon2 (GpGraphics *graphics, GpBrush *brush, GpPointF *points, int count);
-GpStatus GdipFillPolygon2I (GpGraphics *graphics, GpBrush *brush, GpPoint *points, int count);
-GpStatus GdipSetRenderingOrigin (GpGraphics *graphics, int x, int y);
-GpStatus GdipGetRenderingOrigin (GpGraphics *graphics, int *x, int *y);
-
-/* Status */
-GpStatus gdip_get_status (cairo_t *ct);
-
-/* Brush */
-GpStatus GdipCloneBrush (GpBrush *brush, GpBrush **clonedBrush);
-GpStatus GdipDeleteBrush (GpBrush *brush);
-
-/* Text */
-GpStatus GdipDrawString (GpGraphics *graphics, const char *string, int len, void *font, RectF *rc, void *format, GpBrush *brush);
-
-/* Matrix */
-GpStatus GdipCreateMatrix (GpMatrix **matrix);
-GpStatus GdipCreateMatrix2 (float m11, float m12, float m21, float m22, float dx, float dy, GpMatrix **matrix);
-GpStatus GdipCreateMatrix3 (GpRectF *rect, GpPointF *dstplg, GpMatrix **matrix);
-GpStatus GdipCreateMatrix3I (GpRect *rect, GpPoint *dstplg, GpMatrix **matrix);
-GpStatus GdipCloneMatrix (GpMatrix *matrix, GpMatrix **cloneMatrix);
-GpStatus GdipDeleteMatrix (GpMatrix *matrix);
-GpStatus GdipSetMatrixElements (GpMatrix *matrix, float m11, float m12, float m21, float m22, float dx, float dy);
-GpStatus GdipMultiplyMatrix (GpMatrix *matrix, GpMatrix *matrix2, GpMatrixOrder order);
-GpStatus GdipTranslateMatrix (GpMatrix *matrix, float offsetX, float offsetY, GpMatrixOrder order);
-GpStatus GdipScaleMatrix (GpMatrix *matrix, float scaleX, float scaleY, GpMatrixOrder order);
-GpStatus GdipRotateMatrix(GpMatrix *matrix, float angle, GpMatrixOrder order);
-GpStatus GdipShearMatrix (GpMatrix *matrix, float shearX, float shearY, GpMatrixOrder order);
-GpStatus GdipInvertMatrix (GpMatrix *matrix);
-GpStatus GdipTransformMatrixPoints (GpMatrix *matrix, GpPointF *pts, int count);
-GpStatus GdipTransformMatrixPointsI (GpMatrix *matrix, GpPoint *pts, int count);
-GpStatus GdipVectorTransformMatrixPoints (GpMatrix *matrix, GpPointF *pts, int count);
-GpStatus GdipVectorTransformMatrixPointsI (GpMatrix *matrix, GpPoint *pts, int count);
-GpStatus GdipGetMatrixElements (GpMatrix *matrix, float *matrixOut);
-GpStatus GdipIsMatrixInvertible (GpMatrix *matrix, int *result);
-GpStatus GdipIsMatrixIdentity (GpMatrix *matrix, int *result);
-GpStatus GdipIsMatrixEqual (GpMatrix *matrix, GpMatrix *matrix2, int *result);
-
-/* Memory */
-void *GdipAlloc (int size);
-void GdipFree (void *ptr);
-
-#endif /* _GDIP_DEFS_H */
diff --git a/mcs/class/System.Drawing/gdiplus/gdip_main.h b/mcs/class/System.Drawing/gdiplus/gdip_main.h
deleted file mode 100644
index 6c7ffa313c0..00000000000
--- a/mcs/class/System.Drawing/gdiplus/gdip_main.h
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- * gdip_main.h
- *
- * Copyright (c) 2003 Alexandre Pigolkine
- *
- * 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.
- *
- * Authors:
- * Alexandre Pigolkine(pigolkine@gmx.de)
- */
-
-#ifndef _GDIP_MAIN_H
-#define _GDIP_MAIN_H
-
-#include <stdlib.h>
-#include <stdio.h>
-
-#include <cairo.h>
-#include <cairo-xlib.h>
-#include <mono/io-layer/uglify.h>
-
-typedef struct {
- unsigned int Width;
- unsigned int Height;
- int Stride;
- int PixelFormat;
- void *Scan0;
- unsigned int Reserved;
-} GdipBitmapData, BitmapData;
-
-typedef struct {
- int left, top, right, bottom;
-} GpRect, Rect;
-
-typedef struct tagRectF{
- float left, top, right, bottom;
-} GpRectF, RectF;
-
-typedef struct {
- int X, Y;
-} GpPoint;
-
-typedef struct {
- float X, Y;
-} GpPointF;
-
-enum graphics_type {
- gtUndefined,
- gtX11Drawable,
- gtMemoryBitmap
-};
-
-typedef struct {
- cairo_t *ct;
- cairo_matrix_t *copy_of_ctm;
- void *hdc;
- int hdc_busy_count;
- void *image;
- int type;
-} GpGraphics;
-
-enum ImageType {
- imageUndefined,
- imageBitmap,
- imageMetafile
-};
-
-typedef struct {
- enum ImageType type;
- cairo_surface_t *surface;
- GpGraphics *graphics; /* created by GdipGetImageGraphicsContext */
-} GpImage;
-
-typedef struct {
- GpImage image;
- int cairo_format;
- BitmapData data;
- void *hBitmapDC;
- void *hInitialBitmap;
- void *hBitmap;
-} GpBitmap;
-
-typedef struct {
- int color;
-} GpBrush;
-
-typedef struct {
- int color;
- float width;
-} GpPen;
-
-typedef cairo_matrix_t GpMatrix;
-
-void gdip_image_init (GpImage *image);
-void *gdip_image_create_Win32_HDC (GpImage *image);
-void gdip_image_destroy_Win32_HDC (GpImage *image, void *hdc);
-
-void gdip_bitmap_init (GpBitmap *bitmap);
-GpBitmap *gdip_bitmap_new (void);
-void gdip_bitmap_dispose (GpBitmap *bitmap);
-
-void *gdip_bitmap_create_Win32_HDC (GpBitmap *bitmap);
-void gdip_bitmap_destroy_Win32_HDC (GpBitmap *bitmap, void *hdc);
-
-void *_get_gdi32Handle (void);
-void *_get_user32Handle (void);
-
-void gdip_graphics_init (GpGraphics *graphics);
-GpGraphics *gdip_graphics_new (void);
-void gdip_graphics_attach_bitmap (GpGraphics *graphics, GpBitmap *image);
-void gdip_graphics_detach_bitmap (GpGraphics *graphics, GpBitmap *image);
-
-void gdip_brush_init (GpBrush *brush);
-GpBrush *gdip_brush_new (void);
-void gdip_brush_setup (GpGraphics *graphics, GpBrush *brush);
-
-void gdip_pen_init (GpPen *pen);
-GpPen *gdip_pen_new (void);
-void gdip_pen_setup (GpGraphics *graphics, GpPen *pen);
-
-typedef struct {
- cairo_matrix_t *matrix;
-} GpState;
-
-extern Display *GDIP_display;
-
-void initializeGdipWin32 (void);
-
-#include "gdip_defs.h"
-
-#endif /* _GDIP_MAIN_H */
diff --git a/mcs/class/System.Drawing/gdiplus/general.c b/mcs/class/System.Drawing/gdiplus/general.c
index def4c74049a..3c11daf404c 100644
--- a/mcs/class/System.Drawing/gdiplus/general.c
+++ b/mcs/class/System.Drawing/gdiplus/general.c
@@ -23,7 +23,7 @@
* Duncan Mak (duncan@ximian.com)
*/
-#include "gdip_main.h"
+#include "gdip.h"
#include <dlfcn.h>
#include <cairo.h>
@@ -98,7 +98,7 @@ GdiplusStartup(unsigned long *token, const struct startupInput *input, struct st
}
void
-GdiplusShutdown(unsigned long * token)
+GdiplusShutdown(unsigned long *token)
{
if (closeDisplay) {
XCloseDisplay(GDIP_display);
@@ -115,17 +115,15 @@ GdipAlloc (int size)
}
void
-GdipFree (void * ptr)
+GdipFree (void *ptr)
{
free (ptr);
}
/* Helpers */
GpStatus
-gdip_get_status (cairo_t *ct)
+gdip_get_status (cairo_status_t status)
{
- cairo_status_t status = cairo_status (ct);
-
if (status == CAIRO_STATUS_SUCCESS)
return Ok;
@@ -135,6 +133,7 @@ gdip_get_status (cairo_t *ct)
case CAIRO_STATUS_NO_MEMORY:
return OutOfMemory;
+ case CAIRO_STATUS_INVALID_MATRIX:
case CAIRO_STATUS_INVALID_RESTORE:
case CAIRO_STATUS_INVALID_POP_GROUP:
return InvalidParameter;
@@ -142,9 +141,6 @@ gdip_get_status (cairo_t *ct)
case CAIRO_STATUS_NO_CURRENT_POINT:
case CAIRO_STATUS_NO_TARGET_SURFACE:
return WrongState;
-
- case CAIRO_STATUS_INVALID_MATRIX:
- return InsufficientBuffer;
default:
return GenericError;
diff --git a/mcs/class/System.Drawing/gdiplus/graphics.c b/mcs/class/System.Drawing/gdiplus/graphics.c
index c59ccad4f56..272ba1ab121 100644
--- a/mcs/class/System.Drawing/gdiplus/graphics.c
+++ b/mcs/class/System.Drawing/gdiplus/graphics.c
@@ -24,7 +24,7 @@
*
*/
-#include "gdip_main.h"
+#include "gdip.h"
#include "gdip_win32.h"
#include <math.h>
@@ -38,8 +38,8 @@ gdip_graphics_init (GpGraphics *graphics)
graphics->hdc_busy_count = 0;
graphics->image = 0;
graphics->type = gtUndefined;
- cairo_select_font (graphics->ct, "serif:12");
- /* cairo_select_font (graphics->ct, "serif:12", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL); */
+ /* cairo_select_font (graphics->ct, "serif:12"); */
+ cairo_select_font (graphics->ct, "serif:12", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
}
GpGraphics *
@@ -281,28 +281,72 @@ GdipSaveGraphics(GpGraphics *graphics, unsigned int *state)
}
return Ok;
}
+GpStatus
+GdipResetWorldTransform (GpGraphics *graphics)
+{
+ GpStatus s = cairo_matrix_set_identity (graphics->copy_of_ctm);
-#define PI 3.14159265358979323846
-#define GRADTORAD PI / 180.0
+ if (s != Ok)
+ return s;
+ else {
+ cairo_set_matrix (graphics->ct, graphics->copy_of_ctm);
+ return Ok;
+ }
+}
+
+GpStatus
+GdipSetWorldTransform (GpGraphics *graphics, GpMatrix *matrix)
+{
+ graphics->copy_of_ctm = matrix;
+ cairo_set_matrix (graphics->ct, graphics->copy_of_ctm);
+ return Ok;
+}
GpStatus
-GdipRotateWorldTransform (GpGraphics *graphics, float angle, int order)
+GdipGetWorldTransform (GpGraphics *graphics, GpMatrix *matrix)
{
- cairo_matrix_t *mtx = cairo_matrix_create ();
- cairo_matrix_rotate (mtx, angle * GRADTORAD);
- cairo_matrix_multiply (graphics->copy_of_ctm, mtx, graphics->copy_of_ctm );
- cairo_matrix_destroy ( mtx);
- cairo_set_matrix (graphics->ct, graphics->copy_of_ctm);
- return Ok;
+ cairo_current_matrix (graphics->ct, matrix);
+ return Ok;
+}
+
+GpStatus
+GdipMultiplyWorldTransform (GpGraphics *graphics, GpMatrix *matrix, GpMatrixOrder order)
+{
+ Status s = GdipMultiplyMatrix (graphics->copy_of_ctm, matrix, order);
+
+ if (s != Ok)
+ return s;
+
+ else {
+ cairo_set_matrix (graphics->ct, graphics->copy_of_ctm);
+ return Ok;
+ }
}
GpStatus
-GdipTranslateWorldTransform (GpGraphics *graphics, float dx, float dy, int order)
+GdipRotateWorldTransform (GpGraphics *graphics, float angle, GpMatrixOrder order)
{
- /* FIXME: consider order here */
- cairo_matrix_translate (graphics->copy_of_ctm, dx, dy);
- cairo_set_matrix (graphics->ct, graphics->copy_of_ctm);
- return Ok;
+ GpStatus s = GdipRotateMatrix (graphics->copy_of_ctm, angle, order);
+
+ if (s != Ok)
+ return s;
+ else {
+ cairo_set_matrix (graphics->ct, graphics->copy_of_ctm);
+ return Ok;
+ }
+}
+
+GpStatus
+GdipTranslateWorldTransform (GpGraphics *graphics, float dx, float dy, GpMatrixOrder order)
+{
+ GpStatus s = GdipTranslateMatrix (graphics->copy_of_ctm, dx, dy, order);
+
+ if (s != Ok)
+ return s;
+ else {
+ cairo_set_matrix (graphics->ct, graphics->copy_of_ctm);
+ return Ok;
+ }
}
/* XXX: TODO */
@@ -336,7 +380,7 @@ GdipDrawBezier (GpGraphics *graphics, GpPen *pen,
cairo_curve_to (graphics->ct, x2, y2, x3, y3, x4, y4);
cairo_stroke (graphics->ct);
- return gdip_get_status (graphics->ct);
+ return gdip_get_status (cairo_status (graphics->ct));
}
GpStatus GdipDrawBezierI (GpGraphics *graphics, GpPen *pen,
@@ -370,7 +414,7 @@ GdipDrawBeziers (GpGraphics *graphics, GpPen *pen,
cairo_stroke (graphics->ct);
- return gdip_get_status (graphics->ct);
+ return gdip_get_status (cairo_status (graphics->ct));
}
GpStatus
@@ -396,7 +440,7 @@ GdipDrawBeziersI (GpGraphics *graphics, GpPen *pen,
cairo_stroke (graphics->ct);
- return gdip_get_status (graphics->ct);
+ return gdip_get_status (cairo_status (graphics->ct));
}
GpStatus
@@ -407,7 +451,7 @@ GdipDrawEllipse (GpGraphics *graphics, GpPen *pen,
make_ellipse (graphics, x, y, width, height);
cairo_stroke (graphics->ct);
- return gdip_get_status (graphics->ct);
+ return gdip_get_status (cairo_status (graphics->ct));
}
GpStatus
@@ -428,7 +472,7 @@ GdipDrawLine (GpGraphics *graphics, GpPen *pen,
cairo_stroke (graphics->ct);
- return gdip_get_status (graphics->ct);
+ return gdip_get_status (cairo_status (graphics->ct));
}
GpStatus
@@ -484,7 +528,7 @@ GdipDrawPie (GpGraphics *graphics, GpPen *pen, float x, float y,
cairo_stroke (graphics->ct);
cairo_close_path (graphics->ct);
- return gdip_get_status (graphics->ct);
+ return gdip_get_status (cairo_status (graphics->ct));
}
GpStatus
@@ -496,7 +540,7 @@ GdipDrawPieI (GpGraphics *graphics, GpPen *pen, int x, int y,
cairo_stroke (graphics->ct);
cairo_close_path (graphics->ct);
- return gdip_get_status (graphics->ct);
+ return gdip_get_status (cairo_status (graphics->ct));
}
GpStatus
@@ -506,7 +550,7 @@ GdipDrawPolygon (GpGraphics *graphics, GpPen *pen, GpPointF *points, int count)
make_polygon (graphics, points, count);
cairo_stroke (graphics->ct);
- return gdip_get_status (graphics->ct);
+ return gdip_get_status (cairo_status (graphics->ct));
}
GpStatus
@@ -516,7 +560,7 @@ GdipDrawPolygonI (GpGraphics *graphics, GpPen *pen, GpPoint *points, int count)
make_polygon_from_integers (graphics, points, count);
cairo_stroke (graphics->ct);
- return gdip_get_status (graphics->ct);
+ return gdip_get_status (cairo_status (graphics->ct));
}
GpStatus
@@ -527,7 +571,7 @@ GdipDrawRectangle (GpGraphics *graphics, GpPen *pen,
cairo_rectangle (graphics->ct, x, y, width, height);
cairo_stroke (graphics->ct);
- return gdip_get_status (graphics->ct);
+ return gdip_get_status (cairo_status (graphics->ct));
}
GpStatus
@@ -545,7 +589,7 @@ GdipFillEllipse (GpGraphics *graphics, GpBrush *brush,
make_ellipse (graphics, x, y, width, height);
cairo_fill (graphics->ct);
- return gdip_get_status (graphics->ct);
+ return gdip_get_status (cairo_status (graphics->ct));
}
GpStatus
@@ -562,7 +606,7 @@ GdipFillRectangle (GpGraphics *graphics, GpBrush *brush,
gdip_brush_setup (graphics, brush);
cairo_rectangle (graphics->ct, x, y, width, height);
cairo_fill (graphics->ct);
- return gdip_get_status (graphics->ct);
+ return gdip_get_status (cairo_status (graphics->ct));
}
GpStatus
@@ -578,7 +622,7 @@ GdipFillPolygon (GpGraphics *graphics, GpBrush *brush,
cairo_fill (graphics->ct);
- return gdip_get_status (graphics->ct);
+ return gdip_get_status (cairo_status (graphics->ct));
}
GpStatus
@@ -594,7 +638,7 @@ GdipFillPolygonI (GpGraphics *graphics, GpBrush *brush,
cairo_fill (graphics->ct);
- return gdip_get_status (graphics->ct);
+ return gdip_get_status (cairo_status (graphics->ct));
}
GpStatus
@@ -624,7 +668,7 @@ GdipDrawString (GpGraphics *graphics, const char *string,
cairo_show_text (graphics->ct, string);
cairo_restore(graphics->ct);
- return gdip_get_status (graphics->ct);
+ return gdip_get_status (cairo_status (graphics->ct));
}
GpStatus
@@ -633,13 +677,9 @@ GdipSetRenderingOrigin (GpGraphics *graphics, int x, int y)
cairo_move_to (graphics->ct, x, y);
cairo_close_path (graphics->ct);
- return gdip_get_status (graphics->ct);
+ return gdip_get_status (cairo_status (graphics->ct));
}
-/*
- * FIXME: cairo_current_point does not reflect changes made from
- * cairo_move_to.
- */
GpStatus
GdipGetRenderingOrigin (GpGraphics *graphics, int *x, int *y)
{
@@ -649,6 +689,6 @@ GdipGetRenderingOrigin (GpGraphics *graphics, int *x, int *y)
*x = (int) cx;
*y = (int) cy;
- return gdip_get_status (graphics->ct);
+ return gdip_get_status (cairo_status (graphics->ct));
}
diff --git a/mcs/class/System.Drawing/gdiplus/image.c b/mcs/class/System.Drawing/gdiplus/image.c
index 4c6891a5905..8ba56f2f8b0 100644
--- a/mcs/class/System.Drawing/gdiplus/image.c
+++ b/mcs/class/System.Drawing/gdiplus/image.c
@@ -23,7 +23,7 @@
*
*/
-#include "gdip_main.h"
+#include "gdip.h"
#include <math.h>
void
diff --git a/mcs/class/System.Drawing/gdiplus/matrix.c b/mcs/class/System.Drawing/gdiplus/matrix.c
index 6754d873ac8..d125308713f 100644
--- a/mcs/class/System.Drawing/gdiplus/matrix.c
+++ b/mcs/class/System.Drawing/gdiplus/matrix.c
@@ -1,20 +1,20 @@
-/*
+/**
* matrix.c
*
* Author: Duncan Mak (duncan@ximian.com)
*
* Copyright (C) Novell, Inc. 2003.
*
- */
+ **/
-#include "gdip_main.h"
-#include "gdip_win32.h"
+#include <math.h>
+#include "gdip.h"
-GpStatus
+GpStatus
GdipCreateMatrix (GpMatrix **matrix)
{
*matrix = cairo_matrix_create ();
-
+ cairo_matrix_set_affine (*matrix, 1, 0, 0, 1, 0, 0);
return Ok;
}
@@ -22,126 +22,307 @@ GpStatus
GdipCreateMatrix2 (float m11, float m12, float m21, float m22, float dx, float dy, GpMatrix **matrix)
{
*matrix = cairo_matrix_create ();
- cairo_matrix_set_affine (*matrix, m11, m12, m21, m22, dx, dy);
- return Ok;
+ return gdip_get_status (
+ cairo_matrix_set_affine (
+ *matrix, m11, m12, m21, m22, dx, dy));
}
GpStatus
-GdipCreateMatrix3 (GpRectF *rect, GpPointF *dstplg, GpMatrix **matrix)
+GdipCreateMatrix3 (const GpRectF *rect, const GpPointF *dstplg, GpMatrix **matrix)
{
- return NotImplemented;
+ *matrix = cairo_matrix_create ();
+ double m11 = rect->left;
+ double m12 = rect->top;
+ double m21 = (rect->right) - (rect->left); /* width */
+ double m22 = (rect->bottom) - (rect->top); /* height */
+ double dx = dstplg->X;
+ double dy = dstplg->Y;
+
+ Status s = cairo_matrix_set_affine (
+ *matrix, m11, m12, m21, m22, dx, dy);
+
+ return gdip_get_status (s);
}
GpStatus
-GdipCreateMatrix3I (GpRect *rect, GpPoint *dstplg, GpMatrix **matrix)
+GdipCreateMatrix3I (const GpRect *rect, const GpPoint *dstplg, GpMatrix **matrix)
{
- return NotImplemented;
+ *matrix = cairo_matrix_create ();
+ double m11 = rect->left;
+ double m12 = rect->top;
+ double m21 = (rect->right) - (rect->left); /* width */
+ double m22 = (rect->bottom) - (rect->top); /* height */
+ double dx = dstplg->X;
+ double dy = dstplg->Y;
+
+ Status s = cairo_matrix_set_affine (
+ *matrix, m11, m12, m21, m22, dx, dy);
+
+ return gdip_get_status (s);
}
GpStatus
GdipCloneMatrix (GpMatrix *matrix, GpMatrix **cloneMatrix)
{
- cairo_matrix_copy (matrix, *cloneMatrix);
-
- return Ok;
+ *cloneMatrix = cairo_matrix_create ();
+
+ return gdip_get_status (
+ cairo_matrix_copy (*cloneMatrix, matrix));
}
GpStatus
GdipDeleteMatrix (GpMatrix *matrix)
{
- cairo_matrix_destroy (matrix);
-
+ if (matrix)
+ cairo_matrix_destroy (matrix);
return Ok;
}
GpStatus
GdipSetMatrixElements (GpMatrix *matrix, float m11, float m12, float m21, float m22, float dx, float dy)
{
- return NotImplemented;
+ return gdip_get_status (
+ cairo_matrix_set_affine (matrix, m11, m12, m21, m22, dx, dy));
+}
+
+GpStatus
+GdipGetMatrixElements (GpMatrix *matrix, float *matrixOut)
+{
+ double a, b, c, d, tx, ty;
+
+ cairo_matrix_get_affine (matrix, &a, &b, &c, &d, &tx, &ty);
+
+ matrixOut[0] = (float) a;
+ matrixOut[1] = (float) b;
+ matrixOut[2] = (float) c;
+ matrixOut[3] = (float) d;
+ matrixOut[4] = (float) tx;
+ matrixOut[5] = (float) ty;
+
+ return Ok;
}
GpStatus
GdipMultiplyMatrix (GpMatrix *matrix, GpMatrix *matrix2, GpMatrixOrder order)
{
- return NotImplemented;
+ cairo_status_t status;
+
+ if (order == MatrixOrderPrepend)
+ status = cairo_matrix_multiply (matrix, matrix, matrix2);
+
+ else if (order == MatrixOrderAppend)
+ status = cairo_matrix_multiply (matrix, matrix2, matrix);
+
+ else
+ return GenericError;
+
+ return gdip_get_status (status);
+}
+
+static GpMatrix *
+set_translate (float offsetX, float offsetY)
+{
+ GpMatrix *matrix = cairo_matrix_create ();
+ cairo_matrix_set_affine (matrix, 1, 0, 0, 1, offsetX, offsetY);
+ return matrix;
}
GpStatus
GdipTranslateMatrix (GpMatrix *matrix, float offsetX, float offsetY, GpMatrixOrder order)
{
- return NotImplemented;
+ GpMatrix *tmp = set_translate (offsetX, offsetY);
+ GpStatus s = GdipMultiplyMatrix (matrix, tmp, order);
+ GdipDeleteMatrix (tmp);
+
+ return s;
+}
+
+static GpMatrix *
+set_scale (float scaleX, float scaleY)
+{
+ GpMatrix *matrix = cairo_matrix_create ();
+ cairo_matrix_set_affine (matrix, scaleX, 0, 0, scaleY, 0, 0);
+ return matrix;
}
GpStatus
GdipScaleMatrix (GpMatrix *matrix, float scaleX, float scaleY, GpMatrixOrder order)
{
- return NotImplemented;
+ GpMatrix *tmp = set_scale (scaleX, scaleY);
+ GpStatus s = GdipMultiplyMatrix (matrix, tmp, order);
+ GdipDeleteMatrix (tmp);
+
+ return s;
+}
+
+static GpMatrix *
+set_rotate (float angle)
+{
+ float rad = angle * DEGTORAD;
+ GpMatrix *matrix = cairo_matrix_create ();
+ cairo_matrix_set_affine (matrix, cos (rad), sin (rad), -sin (rad), cos (rad), 0, 0);
+
+ return matrix;
}
GpStatus
-GdipRotateMatrix(GpMatrix *matrix, float angle, GpMatrixOrder order)
+GdipRotateMatrix (GpMatrix *matrix, float angle, GpMatrixOrder order)
+{
+ GpMatrix *tmp = set_rotate (angle);
+ GpStatus s = GdipMultiplyMatrix (matrix, tmp, order);
+ GdipDeleteMatrix (tmp);
+
+ return s;
+}
+
+static GpMatrix *
+set_shear (float shearX, float shearY)
{
- return NotImplemented;
+ GpMatrix *matrix = cairo_matrix_create ();
+ cairo_matrix_set_affine (matrix, 1, shearX, shearY, 1, 0, 0);
+ return matrix;
}
GpStatus
GdipShearMatrix (GpMatrix *matrix, float shearX, float shearY, GpMatrixOrder order)
{
- return NotImplemented;
+ GpMatrix *tmp = set_shear (shearX, shearY);
+ GpStatus s = GdipMultiplyMatrix (matrix, tmp, order);
+ GdipDeleteMatrix (tmp);
+
+ return s;
}
GpStatus
GdipInvertMatrix (GpMatrix *matrix)
{
- cairo_matrix_invert (matrix);
- return Ok;
+ return gdip_get_status (
+ cairo_matrix_invert (matrix));
}
GpStatus
GdipTransformMatrixPoints (GpMatrix *matrix, GpPointF *pts, int count)
{
- return NotImplemented;
+ int i;
+ cairo_status_t status;
+
+ for (i = 0; i < count; i++, pts++) {
+ double x = pts->X;
+ double y = pts->Y;
+ status = cairo_matrix_transform_point (matrix, &x, &y);
+ if (status != CAIRO_STATUS_SUCCESS)
+ return gdip_get_status (status);
+
+ pts->X = (float) x;
+ pts->Y = (float) y;
+ }
+
+ return Ok;
}
GpStatus
GdipTransformMatrixPointsI (GpMatrix *matrix, GpPoint *pts, int count)
{
- return NotImplemented;
+ int i;
+ cairo_status_t status;
+
+ for (i = 0; i < count; i++, pts++) {
+ double x = pts->X;
+ double y = pts->Y;
+ status = cairo_matrix_transform_point (matrix, &x, &y);
+ if (status != CAIRO_STATUS_SUCCESS)
+ return gdip_get_status (status);
+ pts->X = (int) x;
+ pts->Y = (int) y;
+ }
+
+ return Ok;
}
GpStatus
GdipVectorTransformMatrixPoints (GpMatrix *matrix, GpPointF *pts, int count)
{
- return NotImplemented;
+ int i;
+ cairo_status_t status;
+
+ for (i = 0; i < count; i++, pts++) {
+ double x = pts->X;
+ double y = pts->Y;
+ status = cairo_matrix_transform_distance (matrix, &x, &y);
+ if (status != CAIRO_STATUS_SUCCESS)
+ return gdip_get_status (status);
+ pts->X = (float) x;
+ pts->Y = (float) y;
+ }
+
+ return Ok;
}
GpStatus
GdipVectorTransformMatrixPointsI (GpMatrix *matrix, GpPoint *pts, int count)
{
- return NotImplemented;
+ int i;
+ cairo_status_t status;
+
+ for (i = 0; i < count; i++, pts++) {
+ double x = pts->X;
+ double y = pts->Y;
+ status = cairo_matrix_transform_distance (matrix, &x, &y);
+ if (status != CAIRO_STATUS_SUCCESS)
+ return gdip_get_status (status);
+
+ pts->X = (int) x;
+ pts->Y = (int) y;
+ }
+
+ return Ok;
}
GpStatus
-GdipGetMatrixElements (GpMatrix *matrix, float *matrixOut)
+GdipIsMatrixInvertible (GpMatrix *matrix, int *result)
{
- return NotImplemented;
-}
+ cairo_status_t status = cairo_matrix_invert (matrix);
-GpStatus
-GdipIsMatrixInvertible (GpMatrix *matrix, int *result)
+ if (status == CAIRO_STATUS_INVALID_MATRIX)
+ *result = 0;
+
+ *result = 1;
+ return Ok;
+}
+
+static int
+matrix_equals (GpMatrix *x, GpMatrix *y)
{
- return NotImplemented;
+ double ax, bx, cx, dx, ex, fx;
+ double ay, by, cy, dy, ey, fy;
+
+ cairo_matrix_get_affine (x, &ax, &bx, &cx, &dx, &ex, &fx);
+ cairo_matrix_get_affine (y, &ay, &by, &cy, &dy, &ey, &fy);
+
+ if ((ax != ay) || (bx != by) || (cx != cy) ||
+ (dx != dy) || (ex != ey) || (fx != fy))
+ return 0;
+
+ return 1;
}
GpStatus
GdipIsMatrixIdentity (GpMatrix *matrix, int *result)
{
- return NotImplemented;
+ GpMatrix *identity = cairo_matrix_create ();
+ cairo_matrix_set_identity (identity);
+
+ Status s = GdipIsMatrixEqual (matrix, identity, result);
+ GdipDeleteMatrix (identity);
+
+ return s;
}
GpStatus
GdipIsMatrixEqual (GpMatrix *matrix, GpMatrix *matrix2, int *result)
{
- return NotImplemented;
+ *result = matrix_equals (matrix, matrix2);
+ return Ok;
}
+
diff --git a/mcs/class/System.Drawing/gdiplus/pen.c b/mcs/class/System.Drawing/gdiplus/pen.c
index 1a94fe9b9d0..0f2adfb081d 100644
--- a/mcs/class/System.Drawing/gdiplus/pen.c
+++ b/mcs/class/System.Drawing/gdiplus/pen.c
@@ -20,48 +20,469 @@
*
* Authors:
* Alexandre Pigolkine(pigolkine@gmx.de)
+ * Duncan Mak (duncan@ximian.com)
*
*/
-#include "gdip_main.h"
+#include "gdip.h"
void
gdip_pen_init (GpPen *pen)
{
- pen->color = 0;
- pen->width = 1.0F;
+ pen->color = 0;
+ pen->width = 1;
+ pen->miter_limit = 10;
+ pen->line_join = LineJoinMiter;
+ pen->matrix = NULL;
+ pen->dash_offset = 0;
+ pen->line_cap = LineCapFlat;
+ pen->line_join = LineJoinMiter;
}
-GpPen *
+GpPen*
gdip_pen_new (void)
{
- GpPen *result = (GpPen *) GdipAlloc (sizeof (GpPen));
- gdip_pen_init (result);
- return result;
+ GpPen *result = (GpPen *) GdipAlloc (sizeof (GpPen));
+ gdip_pen_init (result);
+ return result;
+}
+
+static cairo_line_join_t
+convert_line_join (GpLineJoin join)
+{
+ switch (join) {
+
+ case LineJoinMiter:
+ return CAIRO_LINE_JOIN_MITER;
+
+ case LineJoinBevel:
+ return CAIRO_LINE_JOIN_BEVEL;
+
+ case LineJoinRound:
+ return CAIRO_LINE_JOIN_ROUND;
+
+ case LineJoinMiterClipped:
+ default:
+ return CAIRO_LINE_JOIN_MITER;
+ }
+}
+
+static cairo_line_cap_t
+convert_line_cap (GpLineCap cap)
+{
+ switch (cap) {
+
+ case LineCapSquare:
+ return CAIRO_LINE_CAP_SQUARE;
+
+ case LineCapRound:
+ return CAIRO_LINE_CAP_ROUND;
+
+ case LineCapFlat:
+ case LineCapTriangle:
+ case LineCapNoAnchor:
+ case LineCapSquareAnchor:
+ case LineCapRoundAnchor:
+ case LineCapDiamondAnchor:
+ case LineCapArrowAnchor:
+ case LineCapCustom:
+ default:
+ return CAIRO_LINE_CAP_BUTT;
+ }
+}
+
+static double *
+convert_dash_array (float *f, int count)
+{
+ double *retval = malloc (sizeof (double) * count);
+ int i;
+ for (i = 0; i < count; i++, f++, retval++)
+ *retval = (double) *f;
+
+ return retval;
}
void
gdip_pen_setup (GpGraphics *graphics, GpPen *pen)
{
- int R = (pen->color & 0x00FF0000 ) >> 16;
- int G = (pen->color & 0x0000FF00 ) >> 8;
- int B = (pen->color & 0x000000FF );
+ int R = (pen->color & 0x00FF0000 ) >> 16;
+ int G = (pen->color & 0x0000FF00 ) >> 8;
+ int B = (pen->color & 0x000000FF );
- cairo_set_rgb_color (graphics->ct, (double) R, (double) G, (double) B);
- cairo_set_line_width (graphics->ct, (double) pen->width);
+ cairo_set_rgb_color (graphics->ct, (double) R, (double) G, (double) B);
+ cairo_set_line_width (graphics->ct, (double) pen->width);
+ cairo_set_miter_limit (graphics->ct, (double) pen->miter_limit);
+ cairo_set_line_join (graphics->ct, convert_line_join (pen->line_join));
+ cairo_set_line_cap (graphics->ct, convert_line_cap (pen->line_cap));
+
+ if (pen->matrix != NULL)
+ cairo_set_matrix (graphics->ct, pen->matrix);
+
+ if (pen->dash_array != NULL && pen->dash_count != 0)
+ cairo_set_dash (graphics->ct,
+ convert_dash_array (pen->dash_array, pen->dash_count),
+ pen->dash_count, pen->dash_offset);
}
GpStatus
-GdipCreatePen1(int argb, float width, int unit, GpPen **pen)
+GdipCreatePen1(int argb, float width, GpUnit unit, GpPen **pen)
{
- *pen = gdip_pen_new ();
- (*pen)->color = argb;
- (*pen)->width = width;
- return Ok;
+ *pen = gdip_pen_new ();
+ (*pen)->color = argb;
+ (*pen)->width = width;
+ return Ok;
+}
+
+GpStatus
+GdipCreatePen2 (GpBrush *brush, float width, GpUnit unit, GpPen **pen)
+{
+ int color;
+ GpBrushType type;
+ *pen = gdip_pen_new ();
+ (*pen)->width = width;
+
+ GdipGetBrushType (brush, &type);
+
+ switch (type) {
+
+ case BrushTypeSolidColor:
+
+ GdipGetSolidFillColor (brush, &color);
+ (*pen)->color = color;
+ return Ok;
+
+ case BrushTypeHatchFill:
+ case BrushTypeTextureFill:
+ case BrushTypePathGradient:
+ case BrushTypeLinearGradient:
+ default:
+ return GenericError;
+ }
}
GpStatus
+GdipClonePen (GpPen *pen, GpPen **clonepen)
+{
+ GpPen *result = gdip_pen_new ();
+ result->color = pen->color;
+ result->width = pen->width;
+ result->miter_limit = pen->miter_limit;
+ result->line_join = pen->line_join;
+ result->matrix = pen->matrix;
+ result->dash_offset = pen->dash_offset;
+ result->line_cap = pen->line_cap;
+ result->line_join = pen->line_join;
+
+ *clonepen = result;
+
+ return Ok;
+}
+
+
+GpStatus
GdipDeletePen (GpPen *pen)
{
- return NotImplemented;
+ if (pen->matrix != NULL)
+ cairo_matrix_destroy (pen->matrix);
+
+ if (pen->dash_array != NULL)
+ free (pen->dash_array);
+
+ GdipFree (pen);
+}
+
+GpStatus
+GdipSetPenWidth (GpPen *pen, float width)
+{
+ pen->width = width;
+ return Ok;
+}
+
+GpStatus
+GdipGetPenWidth (GpPen *pen, float *width)
+{
+ *width = pen->width;
+ return Ok;
+}
+
+GpStatus
+GdipSetPenBrushFill (GpPen *pen, GpBrush *brush)
+{
+ GpStatus s;
+ pen->brush = brush;
+ int color;
+ s = GdipGetSolidFillColor (brush, &color);
+
+ if (s != Ok)
+ return s;
+
+ pen->color = color;
+ return Ok;
+}
+
+GpStatus
+GdipGetPenBrushFill (GpPen *pen, GpBrush **brush)
+{
+ *brush = pen->brush;
+ return Ok;
+}
+
+GpStatus
+GdipSetPenColor (GpPen *pen, int argb)
+{
+ pen->color = argb;
+
+ return Ok;
+}
+
+GpStatus
+GdipGetPenColor (GpPen *pen, int *argb)
+{
+ *argb = pen->color;
+ return Ok;
+}
+
+GpStatus
+GdipSetPenMiterLimit (GpPen *pen, float miterLimit)
+{
+ pen->miter_limit = miterLimit;
+ return Ok;
+}
+
+GpStatus
+GdipGetPenMiterLimit (GpPen *pen, float *miterLimit)
+{
+ *miterLimit = pen->miter_limit;
+
+ return Ok;
+}
+
+GpStatus
+GdipSetPenLineJoin (GpPen *pen, GpLineJoin lineJoin)
+{
+ pen->line_join = lineJoin;
+ return Ok;
+}
+
+GpStatus
+GdipGetPenLineJoin (GpPen *pen, GpLineJoin *lineJoin)
+{
+ *lineJoin = pen->line_join;
+ return Ok;
+}
+
+GpStatus
+GdipSetPenLineCap (GpPen *pen, GpLineCap lineCap)
+{
+ pen->line_cap = lineCap;
+ return Ok;
+}
+
+GpStatus
+GdipGetPenLineCap (GpPen *pen, GpLineJoin *lineCap)
+{
+ *lineCap = pen->line_cap;
+ return Ok;
+}
+
+GpStatus
+GdipSetPenMode (GpPen *pen, GpPenAlignment penMode)
+{
+ pen->mode = penMode;
+ return Ok;
+}
+
+GpStatus
+GdipGetPenMode (GpPen *pen, GpPenAlignment *penMode)
+{
+ *penMode = pen->mode;
+ return Ok;
+}
+
+GpStatus
+GdipGetPenUnit (GpPen *pen, GpUnit *unit)
+{
+ *unit = pen->unit;
+ return Ok;
+}
+
+GpStatus
+GdipSetPenUnit (GpPen *pen, GpUnit unit)
+{
+ pen->unit = unit;
+ return Ok;
+}
+
+GpStatus
+GdipSetPenTransform (GpPen *pen, GpMatrix *matrix)
+{
+ pen->matrix = matrix;
+ return Ok;
+}
+
+GpStatus
+GdipGetPenTransform (GpPen *pen, GpMatrix *matrix)
+{
+ matrix = pen->matrix;
+ return Ok;
+}
+
+GpStatus
+GdipResetPenTransform (GpPen *pen)
+{
+ pen->matrix = cairo_matrix_create ();
+ return Ok;
+}
+
+GpStatus
+GdipMultiplyPenTransform (GpPen *pen, GpMatrix *matrix, GpMatrixOrder order)
+{
+ return GdipMultiplyMatrix (pen->matrix, matrix, order);
+}
+
+GpStatus
+GdipTranslatePenTransform (GpPen *pen, float dx, float dy, GpMatrixOrder order)
+{
+ return GdipTranslateMatrix (pen->matrix, dx, dy, order);
+}
+
+GpStatus
+GdipScalePenTransform (GpPen *pen, float sx, float sy, GpMatrixOrder order)
+{
+ return GdipScaleMatrix (pen->matrix, sx, sy, order);
+}
+
+GpStatus
+GdipRotatePenTransform (GpPen *pen, float angle, GpMatrixOrder order)
+{
+ return GdipRotateMatrix (pen->matrix, angle, order);
+}
+
+GpStatus
+GdipGetPenDashStyle (GpPen *pen, GpDashStyle *dashStyle)
+{
+ *dashStyle = pen->dash_style;
+ return Ok;
+}
+
+static float Custom [] = { 1.0 };
+static float Dot [] = { 1.0, 1.0 };
+static float Dash [] = { 3.0, 1.0 };
+static float DashDot [] = { 3.0, 1.0, 1.0, 1.0 };
+static float DashDotDot [] = { 3.0, 1.0, 1.0, 1.0, 1.0, 1.0 };
+
+GpStatus
+GdipSetPenDashStyle (GpPen *pen, GpDashStyle dashStyle)
+{
+ pen->dash_style = dashStyle;
+
+ switch (dashStyle) {
+ case DashStyleSolid:
+ pen->dash_array = NULL;
+ return Ok;
+
+ case DashStyleDashDot:
+ pen->dash_array = DashDot;
+ pen->dash_count = 4;
+ return Ok;
+
+ case DashStyleDashDotDot:
+ pen->dash_array = DashDotDot;
+ pen->dash_count = 6;
+ return Ok;
+
+ case DashStyleDot:
+ pen->dash_array = Dot;
+ pen->dash_count = 2;
+ return Ok;
+
+ case DashStyleDash:
+ pen->dash_array = Dash;
+ pen->dash_count = 2;
+ return Ok;
+
+ case DashStyleCustom:
+ pen->dash_array = Custom;
+ pen->dash_count = 1;
+ return Ok;
+
+ default:
+ return GenericError;
+ }
+}
+
+GpStatus
+GdipGetPenDashOffset (GpPen *pen, float *offset)
+{
+ *offset = pen->dash_offset;
+ return Ok;
+}
+
+GpStatus
+GdipSetPenDashOffset (GpPen *pen, float offset)
+{
+ pen->dash_offset = offset;
+ return Ok;
+}
+
+GpStatus
+GdipGetPenDashCount (GpPen *pen, int *count)
+{
+ *count = pen->dash_count;
+
+ return Ok;
+}
+
+GpStatus
+GdipSetPenDashCount (GpPen *pen, int count)
+{
+ pen->dash_count = count;
+
+ return Ok;
+}
+
+/*
+ * This is the DashPattern property in Pen
+ */
+GpStatus
+GdipGetPenDashArray (GpPen *pen, float **dash, int *count)
+{
+ *dash = pen->dash_array;
+ *count = pen->dash_count;
+
+ return Ok;
+}
+
+GpStatus
+GdipSetPenDashArray (GpPen *pen, float *dash, int count)
+{
+ if (count == 0 || dash == NULL)
+ return Ok;
+
+ GdipSetPenDashStyle (pen, DashStyleCustom);
+ pen->dash_array = dash;
+ pen->dash_count = count;
+
+ return Ok;
+}
+
+/*
+ * MonoTODO: Find out what the difference is between CompoundArray and DashArray
+ */
+GpStatus
+GdipGetPenCompoundCount (GpPen *pen, int *count)
+{
+ return NotImplemented;
+}
+
+GpStatus
+GdipSetPenCompoundArray (GpPen *pen, const float *dash, int count)
+{
+ return NotImplemented;
+}
+
+GpStatus
+GdipGetPenCompoundArray (GpPen *pen, float **dash, int count)
+{
+ return NotImplemented;
}
diff --git a/mcs/class/System.Drawing/gdiplus/solidbrush.c b/mcs/class/System.Drawing/gdiplus/solidbrush.c
index 7ae47e61db1..73ef84ecbb1 100644
--- a/mcs/class/System.Drawing/gdiplus/solidbrush.c
+++ b/mcs/class/System.Drawing/gdiplus/solidbrush.c
@@ -22,22 +22,41 @@
* Alexandre Pigolkine(pigolkine@gmx.de)
*/
-#include "gdip_main.h"
+#include "gdip.h"
void
-gdip_brush_init (GpBrush *brush)
+gdip_solidfill_init (GpSolidFill *brush)
{
brush->color = 0;
+ brush->type = BrushTypeSolidColor;
}
-GpBrush *
-gdip_brush_new (void)
+GpSolidFill *
+gdip_solidfill_new (void)
{
- GpBrush *result = (GpBrush *) GdipAlloc (sizeof (GpBrush));
- gdip_brush_init (result);
+ GpSolidFill *result = (GpSolidFill *) gdip_brush_new ();
+ gdip_solidfill_init (result);
return result;
}
+void
+gdip_solidfill_setup (GpGraphics *graphics, GpBrush *brush)
+{
+ int R = (brush->color & 0x00FF0000 ) >> 16;
+ int G = (brush->color & 0x0000FF00 ) >> 8;
+ int B = (brush->color & 0x000000FF );
+ cairo_set_rgb_color (graphics->ct, (double) R, (double) G, (double) B);
+}
+
+GpStatus
+gdip_solidfill_clone (GpBrush *brush, GpBrush **clonedBrush)
+{
+ *clonedBrush = gdip_brush_new ();
+ (*clonedBrush)->color = brush->color;
+
+ return Ok;
+}
+
GpStatus
GdipCreateSolidFill (int color, GpBrush **brush)
{
@@ -45,3 +64,19 @@ GdipCreateSolidFill (int color, GpBrush **brush)
(*brush)->color = color;
return NotImplemented;
}
+
+GpStatus
+GdipSetSolidFillColor (GpSolidFill *brush, int color)
+{
+ brush->color = color;
+
+ return Ok;
+}
+
+GpStatus
+GdipGetSolidFillColor (GpSolidFill *brush, int *color)
+{
+ *color = brush->color;
+
+ return Ok;
+}
diff --git a/mcs/class/System.Runtime.Remoting/ChangeLog b/mcs/class/System.Runtime.Remoting/ChangeLog
index cb543ceab40..f2f2cc7100a 100644
--- a/mcs/class/System.Runtime.Remoting/ChangeLog
+++ b/mcs/class/System.Runtime.Remoting/ChangeLog
@@ -1,3 +1,18 @@
+2003-11-16 Lluis Sanchez Gual <lluis@ximian.com>
+
+ * System.Runtime.Remoting.dll.sources: Added:
+ System.Runtime.Remoting.Channels/BinaryCore.cs
+ System.Runtime.Remoting.Channels/ChannelCore.cs
+ System.Runtime.Remoting.Channels/SoapCore.cs
+
+2003-11-13 Lluis Sanchez Gual <lluis@ximian.com>
+
+ * System.Runtime.Remoting.dll.sources: Removed HttpThread.cs
+
+2003-11-11 Lluis Sanchez Gual <lluis@ximian.com>
+
+ * System.Runtime.Remoting_test.dll.sources: Added CrossDomainCalls.cs test file.
+
2003-09-14 Lluis Sanchez Gual <lluis@ximian.com>
* TcpClientChannel.cs: Fixed constructor.
diff --git a/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels.Http/ChangeLog b/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels.Http/ChangeLog
index 634c377d420..7f3ae9d6013 100644
--- a/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels.Http/ChangeLog
+++ b/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels.Http/ChangeLog
@@ -1,3 +1,33 @@
+2003-11-16 Lluis Sanchez Gual <lluis@ximian.com>
+
+ * HttpHelper.cs: Removed usnused method GetMachineIp.
+ * HttpServerChannel.cs: Added support for priority, bindTo, useIpAddress and
+ machineName properties.
+
+2003-11-13 Lluis Sanchez Gual <lluis@ximian.com>
+
+ * HttpChannel.cs: Create empty property dictionary in the default
+ constructor.
+
+2003-11-13 Lluis Sanchez Gual <lluis@ximian.com>
+
+ * HttpChannel.cs: Moved initialization code in SetupChannel to the
+ respective client and server channels. Added implementatoin of the
+ interface IChannelReceiverHook.
+ * HttpRemotingHandler.cs: Implemented.
+ * HttpRemotingHandlerFactory.cs: Implemented.
+ * HttpServer.cs: In general, use Stream instances instead of Socket. It is
+ more reusable in this way. Also improved formatting.
+ * HttpServerChannel.cs: Implemented support for IChannelReceiverHook.
+ Added new method DispatchRequest in HttpServerTransportSink that can
+ be reused by HttpRemotingHandler.
+
+2003-11-12 Lluis Sanchez Gual <lluis@ximian.com>
+
+ * HttpServerChannel.cs: Removed StartListening call from constructor. It
+ is called by the remoting framework.
+ * HttpClientChannel.cs, HttpHelper.cs: Fixed some formatting.
+
2003-09-17 Lluis Sanchez Gual <lluis@ximian.com>
* HttpHelper.cs: Fixed bug #48468. Patch by Jean-Marc Andre.
diff --git a/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels.Http/HttpChannel.cs b/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels.Http/HttpChannel.cs
index 57601fe3d3b..277033461ee 100644
--- a/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels.Http/HttpChannel.cs
+++ b/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels.Http/HttpChannel.cs
@@ -22,7 +22,7 @@ using System.Runtime.Remoting.Messaging;
namespace System.Runtime.Remoting.Channels.Http
{
- public class HttpChannel: IChannelReceiver, IChannelSender, IChannel
+ public class HttpChannel: IChannelReceiver, IChannelSender, IChannel, IChannelReceiverHook
{
private HttpServerChannel serverChannel;
private HttpClientChannel clientChannel;
@@ -31,93 +31,31 @@ namespace System.Runtime.Remoting.Channels.Http
public HttpChannel()
{
- SetupChannel(null,null,null);
+ SetupChannel (new Hashtable(), null, null);
}
- public HttpChannel(int port)
+ public HttpChannel (int port)
{
Hashtable prop = new Hashtable();
prop["port"] = port;
SetupChannel(prop,null,null);
}
- public HttpChannel(IDictionary Properties,IClientChannelSinkProvider clientSinkProvider,IServerChannelSinkProvider serverSinkProvider)
+ public HttpChannel (IDictionary Properties,IClientChannelSinkProvider clientSinkProvider,IServerChannelSinkProvider serverSinkProvider)
{
- SetupChannel(Properties,clientSinkProvider,serverSinkProvider);
+ SetupChannel (Properties,clientSinkProvider,serverSinkProvider);
}
-
- private void SetupChannel(IDictionary Properties,IClientChannelSinkProvider clientSinkProvider,IServerChannelSinkProvider serverSinkProvider)
+ private void SetupChannel (IDictionary properties, IClientChannelSinkProvider clientSinkProvider, IServerChannelSinkProvider serverSinkProvider)
{
- if(Properties == null)
- {
- clientChannel = new HttpClientChannel();
- serverChannel = new HttpServerChannel();
- }
- else if(Properties.Count == 1)
- {
- clientChannel = new HttpClientChannel();
- serverChannel = new HttpServerChannel(Convert.ToInt32(Properties["port"].ToString()));
- }
- else
- {
- IDictionary clientProperties = new Hashtable();
- IDictionary serverProperties = new Hashtable();
- foreach(DictionaryEntry DictEntry in Properties)
- {
- switch(DictEntry.Key.ToString())
- {
- // Properties Supported By : HttpChannel,HttpServerChannel,HttpClientChannel
- case "name":
- channelName = DictEntry.Value.ToString();
- break;
-
- case "priority":
- channelPriority = Convert.ToInt32(DictEntry.Value.ToString());
- break;
-
- // Properties Supported By : HttpChannel , HttpClientChannel ONLY
- case "clientConnectionLimit":
- clientProperties["clientConnectionLimit"] = DictEntry.Value;
- break;
-
- case "proxyName":
- clientProperties["proxyName"] = DictEntry.Value;
- break;
-
- case "proxyPort":
- clientProperties["proxyPort"] = DictEntry.Value;
- break;
-
- case "useDefaultCredentials":
- clientProperties["useDefaultCredentials"] = DictEntry.Value;
- break;
-
- // Properties Supported By : HttpChannel , HttpServerChannel ONLY
- case "bindTo":
- serverProperties["bindTo"] = DictEntry.Value;
- break;
- case "listen":
- serverProperties["listen"] = DictEntry.Value;
- break;
- case "machineName":
- serverProperties["machineName"] = DictEntry.Value;
- break;
- case "port":
- serverProperties["port"] = DictEntry.Value;
- break;
- case "suppressChannelData":
- serverProperties["suppressChannelData"] = DictEntry.Value;
- break;
- case "useIpAddress":
- serverProperties["useIpAddress"] = DictEntry.Value;
- break;
- }
-
- }
- clientChannel = new HttpClientChannel(clientProperties,clientSinkProvider);
- serverChannel = new HttpServerChannel(serverProperties,serverSinkProvider);
- }
+ clientChannel = new HttpClientChannel (properties, clientSinkProvider);
+ serverChannel = new HttpServerChannel (properties, serverSinkProvider);
+
+ object val = properties ["name"];
+ if (val != null) channelName = val as string;
+
+ val = properties ["priority"];
+ if (val != null) channelPriority = Convert.ToInt32 (val);
}
@@ -137,15 +75,12 @@ namespace System.Runtime.Remoting.Channels.Http
return HttpHelper.Parse(url, out objectURI);
}
-
-
//IChannelSender Members
public IMessageSink CreateMessageSink(String url, Object remoteChannelData, out String objectURI)
{
return clientChannel.CreateMessageSink(url, remoteChannelData, out objectURI);
}
-
//IChannelReciever Members
public String[] GetUrlsForUri(String objectURI)
{
@@ -161,9 +96,31 @@ namespace System.Runtime.Remoting.Channels.Http
{
serverChannel.StopListening(data);
}
+
public Object ChannelData
{
get { return serverChannel.ChannelData; }
}
+
+ public String ChannelScheme
+ {
+ get { return "http"; }
+ }
+
+ public bool WantsToListen
+ {
+ get { return serverChannel.WantsToListen; }
+ set { serverChannel.WantsToListen = value; }
+ }
+
+ public IServerChannelSink ChannelSinkChain
+ {
+ get { return serverChannel.ChannelSinkChain; }
+ }
+
+ public void AddHookChannelUri (String channelUri)
+ {
+ serverChannel.AddHookChannelUri (channelUri);
+ }
}
}
diff --git a/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels.Http/HttpClientChannel.cs b/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels.Http/HttpClientChannel.cs
index dedaa5aa4cc..de690e721cc 100644
--- a/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels.Http/HttpClientChannel.cs
+++ b/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels.Http/HttpClientChannel.cs
@@ -73,42 +73,39 @@ namespace System.Runtime.Remoting.Channels.Http
// constructor used by config file
public HttpClientChannel(IDictionary properties, IClientChannelSinkProvider sinkProvider)
{
- if(properties!=null)
- foreach(DictionaryEntry Dict in properties)
+ if (properties != null)
{
- switch(Dict.Key.ToString())
+ foreach(DictionaryEntry Dict in properties)
{
- case "name":
- _channelName = Dict.Value.ToString();
- break;
- case "priority":
- _channelPriority = Convert.ToInt32(Dict.Value);
- break;
- case "clientConnectionLimit":
- _clientConnectionLimit = Convert.ToInt32(Dict.Value);
- break;
- case "proxyName":
- _proxyName = Dict.Value.ToString();
- break;
- case "proxyPort":
- _proxyPort = Convert.ToInt32(Dict.Value);
- break;
- case "useDefaultCredentials":
- _bUseDefaultCredentials = Convert.ToBoolean(Dict.Value);
- break;
+ switch(Dict.Key.ToString())
+ {
+ case "name":
+ _channelName = Dict.Value.ToString();
+ break;
+ case "priority":
+ _channelPriority = Convert.ToInt32(Dict.Value);
+ break;
+ case "clientConnectionLimit":
+ _clientConnectionLimit = Convert.ToInt32(Dict.Value);
+ break;
+ case "proxyName":
+ _proxyName = Dict.Value.ToString();
+ break;
+ case "proxyPort":
+ _proxyPort = Convert.ToInt32(Dict.Value);
+ break;
+ case "useDefaultCredentials":
+ _bUseDefaultCredentials = Convert.ToBoolean(Dict.Value);
+ break;
+ }
}
}
- //UpdateProxy();
- SetupProvider(sinkProvider);
+
+ SetupProvider (sinkProvider);
}
- /*<note><private>
- private void SetupChannel()
- {
- } */
-
public int ChannelPriority
{
get { return _channelPriority; }
@@ -180,11 +177,7 @@ namespace System.Runtime.Remoting.Channels.Http
ServicePoint sp = ServicePointManager.FindServicePoint(channelURI,ProxyObject);
if(_clientConnectionLimit> 0)
sp.ConnectionLimit = _clientConnectionLimit;
-
-
- }
-
-
+ }
internal IWebProxy ProxyObject { get { return _proxyObject; } }
internal bool UseDefaultCredentials { get { return _bUseDefaultCredentials; } }
@@ -427,7 +420,6 @@ namespace System.Runtime.Remoting.Channels.Http
}
} // this[]
-
public override ICollection Keys
{
get
@@ -454,9 +446,6 @@ namespace System.Runtime.Remoting.Channels.Http
}
}
-
-
-
private void UpdateProxy()
{
// If the user values for the proxy object are valid , then the proxy
diff --git a/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels.Http/HttpHelper.cs b/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels.Http/HttpHelper.cs
index 09f6579155b..c3bb4e10878 100644
--- a/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels.Http/HttpHelper.cs
+++ b/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels.Http/HttpHelper.cs
@@ -78,6 +78,7 @@ namespace System.Runtime.Remoting.Channels.Http
return outStream;
}
+
public static bool CopyStream(Stream inStream, Stream outStream)
{
int temp;
@@ -107,7 +108,6 @@ namespace System.Runtime.Remoting.Channels.Http
}
-
public static String GetHostName()
{
string hostName = Dns.GetHostName();
@@ -134,27 +134,5 @@ namespace System.Runtime.Remoting.Channels.Http
return machineName;
}
-
- public static String GetMachineIp()
- {
-
- String hostName = GetMachineName();
- String MachineIp=null;
-
- IPHostEntry Entries = Dns.GetHostByName(hostName);
- if ((Entries.AddressList.Length > 0)&&(Entries != null))
- {
- MachineIp = Entries.AddressList[0].ToString();
- }
-
- if (MachineIp == null)
- {
- throw new ArgumentNullException("ip");
- }
- return MachineIp;
- }
-
}
-
-
}
diff --git a/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels.Http/HttpRemotingHandler.cs b/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels.Http/HttpRemotingHandler.cs
index a439cedb03c..49077feb94c 100644
--- a/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels.Http/HttpRemotingHandler.cs
+++ b/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels.Http/HttpRemotingHandler.cs
@@ -3,35 +3,77 @@
//
// Authors:
// Martin Willemoes Hansen (mwh@sysrq.dk)
+// Lluis Sanchez Gual (lluis@ximian.com)
//
// (C) 2003 Martin Willemoes Hansen
//
+using System;
+using System.IO;
using System.Web;
namespace System.Runtime.Remoting.Channels.Http
{
- public class HttpRemotingHandler : IHttpHandler
+ public class HttpRemotingHandler : IHttpHandler
{
- [MonoTODO]
- public HttpRemotingHandler()
+ HttpServerTransportSink transportSink;
+
+ public HttpRemotingHandler ()
{
}
+ internal HttpRemotingHandler (HttpServerTransportSink sink)
+ {
+ transportSink = sink;
+ }
+
public bool IsReusable {
- [MonoTODO]
- get { throw new NotImplementedException(); }
+ get { return true; }
}
- [MonoTODO]
public void ProcessRequest (HttpContext context)
{
- throw new NotImplementedException();
- }
+ HttpRequest request = context.Request;
+ HttpResponse response = context.Response;
+
+ // Create transport headers for the request
+
+ TransportHeaders theaders = new TransportHeaders();
- [MonoTODO]
- ~HttpRemotingHandler()
- {
+ string objectUri = request.RawUrl;
+ objectUri = objectUri.Substring (request.ApplicationPath.Length); // application path is not part of the uri
+
+ theaders ["__RequestUri"] = objectUri;
+ theaders ["Content-Type"] = request.ContentType;
+ theaders ["__RequestVerb"]= request.HttpMethod;
+ theaders ["__HttpVersion"] = request.Headers ["http-version"];
+ theaders ["User-Agent"] = request.UserAgent;
+ theaders ["Host"] = request.Headers ["host"];
+
+ ITransportHeaders responseHeaders;
+ Stream responseStream;
+
+ // Dispatch the request
+
+ transportSink.DispatchRequest (request.InputStream, theaders, out responseStream, out responseHeaders);
+
+ // Write the response
+
+ if (responseHeaders != null && responseHeaders["__HttpStatusCode"] != null)
+ {
+ // The formatter can set the status code
+ response.StatusCode = int.Parse ((string) responseHeaders["__HttpStatusCode"]);
+ response.StatusDescription = (string) responseHeaders["__HttpReasonPhrase"];
+ }
+
+ byte[] bodyBuffer = bodyBuffer = new byte [responseStream.Length];
+ responseStream.Seek (0, SeekOrigin.Begin);
+
+ int nr = 0;
+ while (nr < responseStream.Length)
+ nr += responseStream.Read (bodyBuffer, nr, bodyBuffer.Length - nr);
+
+ response.OutputStream.Write (bodyBuffer, 0, bodyBuffer.Length);
}
}
}
diff --git a/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels.Http/HttpRemotingHandlerFactory.cs b/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels.Http/HttpRemotingHandlerFactory.cs
index c7b7aabcf5a..a5cc1cc16e0 100644
--- a/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels.Http/HttpRemotingHandlerFactory.cs
+++ b/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels.Http/HttpRemotingHandlerFactory.cs
@@ -3,38 +3,75 @@
//
// Authors:
// Martin Willemoes Hansen (mwh@sysrq.dk)
+// Lluis Sanchez Gual (lluis@ximian.com)
//
// (C) 2003 Martin Willemoes Hansen
//
using System.Web;
+using System.IO;
+using System.Runtime.Remoting;
+using System.Runtime.Remoting.Channels;
namespace System.Runtime.Remoting.Channels.Http
{
public class HttpRemotingHandlerFactory : IHttpHandlerFactory
{
- [MonoTODO]
+ static bool webConfigLoaded = false;
+ static HttpServerTransportSink transportSink = null;
+
public HttpRemotingHandlerFactory ()
{
}
- [MonoTODO]
public IHttpHandler GetHandler (HttpContext context,
string verb,
string url,
string filePath)
{
- throw new NotImplementedException();
+ if (!webConfigLoaded)
+ ConfigureHttpChannel (context);
+
+ return new HttpRemotingHandler (transportSink);
}
-
- [MonoTODO]
- public void ReleaseHandler (IHttpHandler handler)
+
+ public void ConfigureHttpChannel (HttpContext context)
{
- throw new NotImplementedException();
+ lock (GetType())
+ {
+ if (webConfigLoaded) return;
+
+ // Read the configuration file
+
+ string webconfig = Path.Combine (context.Request.PhysicalApplicationPath, "web.config");
+ RemotingConfiguration.Configure (webconfig);
+
+ // Look for a channel that wants to receive http request
+
+ foreach (IChannel channel in ChannelServices.RegisteredChannels)
+ {
+ IChannelReceiverHook chook = channel as IChannelReceiverHook;
+ if (chook == null) continue;
+
+ if (chook.ChannelScheme != "http")
+ throw new RemotingException ("Only http channels are allowed when hosting remoting objects in a web server");
+
+ if (!chook.WantsToListen) continue;
+
+ // Register the uri for the channel. The channel uri includes the scheme, the
+ // host and the application path
+
+ string channelUrl = context.Request.Url.GetLeftPart(UriPartial.Authority);
+ channelUrl += context.Request.ApplicationPath;
+ chook.AddHookChannelUri (channelUrl);
+
+ transportSink = new HttpServerTransportSink (chook.ChannelSinkChain);
+ }
+ webConfigLoaded = true;
+ }
}
- [MonoTODO]
- ~HttpRemotingHandlerFactory()
+ public void ReleaseHandler (IHttpHandler handler)
{
}
}
diff --git a/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels.Http/HttpServer.cs b/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels.Http/HttpServer.cs
index aad9c710ac4..9aaada82cb2 100644
--- a/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels.Http/HttpServer.cs
+++ b/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels.Http/HttpServer.cs
@@ -28,15 +28,25 @@ using System.Runtime.Remoting.Messaging;
namespace System.Runtime.Remoting.Channels.Http
{
- class RequestArguments
+ internal class RequestArguments
{
- public RequestArguments(Socket SOCKET, HttpServerTransportSink SNK)
+ public RequestArguments (Socket socket, HttpServerTransportSink sink)
{
- socket = SOCKET;
- snk = SNK;
+ NetworkStream ns = new NetworkStream (socket);
+ InputStream = ns;
+ OutputStream = ns;
+ Sink = sink;
}
- public Socket socket;
- public HttpServerTransportSink snk;
+
+ public RequestArguments (Stream inputStream, Stream outputStream, HttpServerTransportSink sink)
+ {
+ InputStream = inputStream;
+ OutputStream = outputStream;
+ Sink = sink;
+ }
+ public Stream InputStream;
+ public Stream OutputStream;
+ public HttpServerTransportSink Sink;
}
internal sealed class HttpServer
@@ -57,153 +67,141 @@ namespace System.Runtime.Remoting.Channels.Http
}
- public static void ProcessRequest(object Object)
+ public static void ProcessRequest (object reqInfo)
{
- if(Object as RequestArguments == null)
+ if(reqInfo as RequestArguments == null)
return;
- Socket socket;
- HttpServerTransportSink snk;
-
- RequestArguments reqArg = (RequestArguments)Object;
+ RequestArguments reqArg = (RequestArguments)reqInfo;
- socket = reqArg.socket;
- snk = reqArg.snk;
-
- if(!socket.Connected)
- return;
-
//Step (1) Start Reciceve the header
- ArrayList Headers = RecieveHeader(socket);
+ ArrayList Headers = RecieveHeader (reqArg);
//Step (2) Start Parse the header
IDictionary HeaderFields = new Hashtable();
IDictionary CustomHeaders = new Hashtable();
- if(!ParseHeader(socket,Headers,HeaderFields,CustomHeaders))
+ if (!ParseHeader (reqArg, Headers, HeaderFields, CustomHeaders))
return;
//Step (3)
- if(!CheckRequest(socket,HeaderFields,CustomHeaders))
+ if (!CheckRequest (reqArg, HeaderFields, CustomHeaders))
return;
//Step (4) Recieve the entity body
byte [] buffer =new byte[(int)HeaderFields["content-length"]];
- if(!RecieveEntityBody(socket,buffer))
+ if (!RecieveEntityBody (reqArg, buffer))
return ;
//Step (5)
- if(! SendRequestForChannel(socket,snk,HeaderFields,CustomHeaders,buffer))
- return ;
+ SendRequestForChannel (reqArg, HeaderFields, CustomHeaders, buffer);
}
- private static ArrayList RecieveHeader(Socket socket)
+ private static ArrayList RecieveHeader (RequestArguments reqArg)
{
bool bLastLine = false;
bool bEndOfLine = false;
byte[] buffer = new byte[1024];
ArrayList Headers = new ArrayList();
+
+ Stream ist = reqArg.InputStream;
int index =0;
- while(!bLastLine)
+ while (!bLastLine)
{
//recieve line by line
index = 0;
bEndOfLine = false;
//Step (1) is it an empty line?
- socket.Receive(buffer,index,1,SocketFlags.None);
+ ist.Read (buffer, index, 1);
if(buffer[index++]==13)
{
- socket.Receive(buffer,index,1,SocketFlags.None);
+ ist.Read (buffer, index, 1);
bLastLine=true;
bEndOfLine = true;
}
//Step (2) recieve line bytes
- while(!bEndOfLine)
+ while (!bEndOfLine)
{
- socket.Receive(buffer,index,1,SocketFlags.None);
+ ist.Read (buffer, index, 1);
- if(buffer[index++]==13)
+ if(buffer [index++]==13)
{
bEndOfLine = true;
- socket.Receive(buffer,index,1,SocketFlags.None);
+ ist.Read (buffer,index,1);
}
-
}
//Step (3) convert bytes to a string
- if(bLastLine)
+ if (bLastLine)
continue;
- Headers.Add( Encoding.ASCII.GetString(buffer,0,index));
+
+ Headers.Add (Encoding.ASCII.GetString (buffer,0,index));
}//end while loop
return Headers;
}
- private static bool ParseHeader(Socket socket, ArrayList Headers,IDictionary HeaderFields, IDictionary CustomHeaders)
+ private static bool ParseHeader (RequestArguments reqArg, ArrayList Headers, IDictionary HeaderFields, IDictionary CustomHeaders)
{
-
- for(int i=0;i<Headers.Count;i++)
+ for (int i=0;i<Headers.Count;i++)
{
-
- if( ReqMessageParser.ParseHeaderField((string)Headers[i],HeaderFields))
+ if (ReqMessageParser.ParseHeaderField ((string)Headers[i],HeaderFields))
continue;
- if(!ReqMessageParser.IsCustomHeader((string)Headers[i],CustomHeaders ) )
+
+ if (!ReqMessageParser.IsCustomHeader((string)Headers[i],CustomHeaders ) )
{
- SendResponse(socket,400,null,null);
+ SendResponse (reqArg, 400, null, null);
return false;
}
-
}
return true;
}
-
-
- private static bool CheckRequest(Socket socket,IDictionary HeaderFields , IDictionary CustomHeaders)
+ private static bool CheckRequest (RequestArguments reqArg, IDictionary HeaderFields, IDictionary CustomHeaders)
{
string temp;
//Check the method
temp = HeaderFields["method"].ToString();
- if(temp!="POST")
+ if (temp!="POST")
{
- SendResponse(socket,501,null,null);
+ SendResponse (reqArg, 501, null, null);
return false;
}
if (HeaderFields["expect"].ToString() == "100-continue")
- SendResponse(socket,100,null,null);
+ SendResponse (reqArg, 100, null, null);
//Check for the content-length field
- if(HeaderFields["content-length"]==null)
+ if (HeaderFields["content-length"]==null)
{
- SendResponse(socket,411,null,null);
+ SendResponse (reqArg, 411, null, null);
return false;
}
return true;
}
- private static bool RecieveEntityBody(Socket socket, byte[] buffer)
+ private static bool RecieveEntityBody (RequestArguments reqArg, byte[] buffer)
{
try
{
int nr = 0;
while (nr < buffer.Length)
- nr += socket.Receive (buffer, nr, buffer.Length - nr,SocketFlags.None);
+ nr += reqArg.InputStream.Read (buffer, nr, buffer.Length - nr);
}
- catch(SocketException e)
+ catch (SocketException e)
{
switch(e.ErrorCode)
{
case 10060 : //TimeOut
- SendResponse(socket,408,null,null);
+ SendResponse (reqArg, 408, null, null);
break;
default :
//<Exception>
@@ -216,7 +214,7 @@ namespace System.Runtime.Remoting.Channels.Http
return true;
}
- private static bool SendRequestForChannel(Socket socket ,HttpServerTransportSink snk ,IDictionary HeaderFields , IDictionary CustomHeaders, byte[]buffer)
+ private static bool SendRequestForChannel (RequestArguments reqArg, IDictionary HeaderFields, IDictionary CustomHeaders, byte[] buffer)
{
TransportHeaders THeaders = new TransportHeaders();
@@ -230,9 +228,9 @@ namespace System.Runtime.Remoting.Channels.Http
//THeaders["__ConnectionId"] = Int64.Parse("1");
//THeaders["__IPAddress"]= ((IPEndPoint)socket.RemoteEndPoint).Address;
- THeaders["__RequestUri"] =FixURI((string)HeaderFields["request-url"]);
- THeaders["Content-Type"]=HeaderFields["content-type"];
- THeaders["__RequestVerb"]=HeaderFields["method"];
+ THeaders["__RequestUri"] = FixURI((string)HeaderFields["request-url"]);
+ THeaders["Content-Type"]= HeaderFields["content-type"];
+ THeaders["__RequestVerb"]= HeaderFields["method"];
THeaders["__HttpVersion"] = HeaderFields["http-version"];
THeaders["User-Agent"] = HeaderFields["user-agent"];
THeaders["Host"] = HeaderFields["host"];
@@ -242,7 +240,7 @@ namespace System.Runtime.Remoting.Channels.Http
THeaders[DictEntry.Key.ToString()] = DictEntry.Value.ToString();
}
- snk.ServiceRequest(socket,stream,THeaders);
+ reqArg.Sink.ServiceRequest (reqArg, stream, THeaders);
return true;
}
@@ -256,7 +254,7 @@ namespace System.Runtime.Remoting.Channels.Http
}
- public static bool SendResponse(Socket socket, int HttpStatusCode, ITransportHeaders headers , Stream responseStream)
+ public static bool SendResponse (RequestArguments reqArg, int HttpStatusCode, ITransportHeaders headers , Stream responseStream)
{
byte [] headersBuffer = null;
byte [] entityBuffer = null;
@@ -293,21 +291,15 @@ namespace System.Runtime.Remoting.Channels.Http
ResponseStr.Append("\r\n");
- headersBuffer = Encoding.ASCII.GetBytes(ResponseStr.ToString());
+ headersBuffer = Encoding.ASCII.GetBytes (ResponseStr.ToString());
try
{
-
//send headersBuffer
- if(socket.Send(headersBuffer,0,headersBuffer.Length,SocketFlags.None) != headersBuffer.Length)
- return false;
-
-
-
- if(entityBuffer != null)
- if(socket.Send(entityBuffer,0,entityBuffer.Length,SocketFlags.None) != entityBuffer.Length)
- return false;
+ reqArg.OutputStream.Write (headersBuffer, 0, headersBuffer.Length);
+ if (entityBuffer != null)
+ reqArg.OutputStream.Write (entityBuffer, 0, entityBuffer.Length);
}
catch (SocketException )
{
@@ -315,8 +307,8 @@ namespace System.Runtime.Remoting.Channels.Http
//may be its the client's fault so just return with false
return false;
}
-
- return true;
+
+ return true;
}
public static bool SendResponse(Socket socket , int HttpStatusCode ,string ReasonPhrase, ITransportHeaders headers , Stream responseStream )
@@ -325,7 +317,7 @@ namespace System.Runtime.Remoting.Channels.Http
return true;
}
- private static string GetReasonPhrase(int HttpStatusCode)
+ internal static string GetReasonPhrase(int HttpStatusCode)
{
switch (HttpStatusCode)
{
@@ -395,13 +387,11 @@ namespace System.Runtime.Remoting.Channels.Http
- public ReqMessageParser()
+ public ReqMessageParser ()
{
-
-
}
- public static bool ParseHeaderField(string buffer,IDictionary headers)
+ public static bool ParseHeaderField(string buffer,IDictionary headers)
{
try
diff --git a/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels.Http/HttpServerChannel.cs b/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels.Http/HttpServerChannel.cs
index 2f399a38977..682ed3d0cfd 100644
--- a/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels.Http/HttpServerChannel.cs
+++ b/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels.Http/HttpServerChannel.cs
@@ -34,20 +34,18 @@ namespace System.Runtime.Remoting.Channels.Http
public class HttpServerChannel : IChannel,
IChannelReceiver, IChannelReceiverHook
{
- private int _channelPriority = 1; // priority of channel (default=1)
+ private int _channelPriority = 1; // priority of channel (default=1)
private String _channelName = "http"; // channel name
private String _machineName = null; // machine name
private int _port = -1; // port to listen on
private ChannelDataStore _channelData = null; // channel data
- private String _forcedMachineName = null; // an explicitly configured machine name
private bool _bUseIpAddress = true; // by default, we'll use the ip address.
private IPAddress _bindToAddr = IPAddress.Any; // address to bind to.
private bool _bSuppressChannelData = false; // should we hand out null for our channel data
private IServerChannelSinkProvider _sinkProvider = null;
private HttpServerTransportSink _transportSink = null;
- private IServerChannelSink _sinkChain = null;
private bool _wantsToListen = true;
@@ -58,46 +56,37 @@ namespace System.Runtime.Remoting.Channels.Http
// to start listening, that will get set here.
private AutoResetEvent _waitForStartListening = new AutoResetEvent(false);
-
-
public HttpServerChannel() : base()
{
SetupChannel(null);
-
}
public HttpServerChannel(int port) : base()
{
_port = port;
SetupChannel(null);
-
}
-
public HttpServerChannel(String name, int port) : base()
{
_channelName = name;
_port = port;
+ _wantsToListen = false;
SetupChannel(null);
-
}
-
public HttpServerChannel(String name, int port, IServerChannelSinkProvider sinkProvider) : base()
{
//enter the name later ya gameeel
_port = port;
+ _wantsToListen = false;
SetupChannel(sinkProvider);
-
}
-
-
- public HttpServerChannel(IDictionary properties, IServerChannelSinkProvider sinkProvider) : base()
- {
-
- if(properties != null)
+ public HttpServerChannel (IDictionary properties, IServerChannelSinkProvider sinkProvider) : base()
+ {
+ if (properties != null)
foreach(DictionaryEntry Dict in properties)
{
switch((string)Dict.Key)
@@ -105,46 +94,46 @@ namespace System.Runtime.Remoting.Channels.Http
case "name":
_channelName = (string)Dict.Value;
break;
+ case "priority":
+ _channelPriority = Convert.ToInt32 (Dict.Value);
+ break;
case "bindTo":
- _bindToAddr = IPAddress.Parse((string)Dict.Value);
+ _bindToAddr = IPAddress.Parse ((string)Dict.Value);
break;
case "listen":
- _wantsToListen = Boolean.Parse((string)Dict.Value);;
+ _wantsToListen = Convert.ToBoolean (Dict.Value);;
break;
case "machineName":
_machineName = (string)Dict.Value;
break;
case "port":
- _port =(int) Dict.Value;
+ _wantsToListen = false;
+ _port = Convert.ToInt32 (Dict.Value);
break;
case "suppressChannelData":
- _bSuppressChannelData = Boolean.Parse((string)Dict.Value);
+ _bSuppressChannelData = Convert.ToBoolean (Dict.Value);
break;
case "useIpAddress":
- _bUseIpAddress = Boolean.Parse((string)Dict.Value);
+ _bUseIpAddress = Convert.ToBoolean (Dict.Value);
break;
}
}
- SetupChannel(sinkProvider);
-
+ SetupChannel (sinkProvider);
}
- void SetupChannel(IServerChannelSinkProvider sinkProvider)
+ void SetupChannel (IServerChannelSinkProvider sinkProvider)
{
-
SetupMachineName();
_sinkProvider = sinkProvider;
-
String[] urls = { this.GetChannelUri() };
// needed for CAOs
_channelData = new ChannelDataStore(urls);
-
if(_sinkProvider == null)
_sinkProvider = new SoapServerFormatterSinkProvider();
@@ -160,14 +149,7 @@ namespace System.Runtime.Remoting.Channels.Http
IServerChannelSink snk =
ChannelServices.CreateServerChannelSinkChain(_sinkProvider,this);
- _transportSink = new HttpServerTransportSink(snk);
-
- if(_port >= 0)
- {
- _tcpListener = new TcpListener( _bindToAddr,_port);
- // start to listen
- this.StartListening(null);
- }
+ _transportSink = new HttpServerTransportSink (snk);
}
public void Listen()
@@ -175,14 +157,18 @@ namespace System.Runtime.Remoting.Channels.Http
while(true)
{
Socket socket = _tcpListener.AcceptSocket();
- RequestArguments reqArg = new RequestArguments(socket,_transportSink);
+ RequestArguments reqArg = new RequestArguments (socket, _transportSink);
ThreadPool.QueueUserWorkItem (new WaitCallback (HttpServer.ProcessRequest), reqArg);
}
}
- public void StartListening(Object data)
+ public void StartListening (Object data)
{
+ if(_port <= 0) return; // TODO: take unused port
+
+ _tcpListener = new TcpListener (_bindToAddr, _port);
+
if(!_bListening)
_tcpListener.Start();
@@ -208,38 +194,22 @@ namespace System.Runtime.Remoting.Channels.Http
}
_bListening = false;
-
}
void SetupMachineName()
{
- if (_forcedMachineName != null)
+ if (_machineName == null)
{
- // an explicitly configured machine name was used
- //_machineName = CoreChannel.DecodeMachineName(_forcedMachineName);
- if (_forcedMachineName.Equals("$hostName"))
- {
- _machineName = Dns.GetHostName();
- if(_machineName == null)
- throw new ArgumentNullException("hostName");
-
+ if (_bUseIpAddress) {
+ IPHostEntry he = Dns.Resolve (Dns.GetHostName());
+ if (he.AddressList.Length == 0) throw new RemotingException ("IP address could not be determined for this host");
+ _machineName = he.AddressList [0].ToString ();
}
-
- else _machineName = _forcedMachineName;
- }
- else
- {
- if (!_bUseIpAddress)
- _machineName = HttpHelper.GetMachineName();
else
- {
- if (_bindToAddr == IPAddress.Any)
- _machineName = HttpHelper.GetMachineIp();
- else
- _machineName = _bindToAddr.ToString();
- }
+ _machineName = Dns.GetHostByName(Dns.GetHostName()).HostName;
}
+
} // SetupMachineName
@@ -264,7 +234,6 @@ namespace System.Runtime.Remoting.Channels.Http
return "http://" + _machineName + ":" + _port;
}
}
-
public virtual String[] GetUrlsForUri(String objectUri)
{
@@ -286,26 +255,35 @@ namespace System.Runtime.Remoting.Channels.Http
{
get
{
- return _channelData;
+ if (_bSuppressChannelData) return null;
+ else return _channelData;
}
- } // ChannelData
-
- public String ChannelScheme { get { return "http"; } }
+ }
+ public String ChannelScheme
+ {
+ get { return "http"; }
+ }
public bool WantsToListen
{
get { return _wantsToListen; }
set { _wantsToListen = value; }
}
-
- public IServerChannelSink ChannelSinkChain { get { return _sinkChain; } }
-
+ public IServerChannelSink ChannelSinkChain
+ {
+ get { return _transportSink.NextChannelSink; }
+ }
- public void AddHookChannelUri(String channelUri)
+ public void AddHookChannelUri (String channelUri)
{
- }
+ string [] uris = _channelData.ChannelUris;
+
+ string [] newUris = new string[1] { channelUri };
+ _channelData.ChannelUris = newUris;
+ _wantsToListen = false;
+ }
public Object this[Object key]
{
@@ -319,8 +297,7 @@ namespace System.Runtime.Remoting.Channels.Http
break;
}
}
- }
-
+ }
public ICollection Keys
{
@@ -330,12 +307,8 @@ namespace System.Runtime.Remoting.Channels.Http
}
}
-
-
} // HttpServerChannel
-
-
internal class HttpServerTransportSink : IServerChannelSink
{
@@ -346,43 +319,33 @@ namespace System.Runtime.Remoting.Channels.Http
private IServerChannelSink _nextSink;
- public HttpServerTransportSink(IServerChannelSink nextSink)
+ public HttpServerTransportSink (IServerChannelSink nextSink)
{
_nextSink = nextSink;
} // IServerChannelSink
-
-
-
- internal void ServiceRequest(Socket socket , Stream requestStream , ITransportHeaders headers)
- {
- ServerChannelSinkStack sinkStack = new ServerChannelSinkStack();
- sinkStack.Push(this, socket);
- IMessage responseMessage;
+ internal void ServiceRequest (RequestArguments reqArg, Stream requestStream, ITransportHeaders headers)
+ {
ITransportHeaders responseHeaders;
Stream responseStream;
- ServerProcessing processing = ServerProcessing.Complete;
+ ServerProcessing processing;
try
{
- processing =
- _nextSink.ProcessMessage(sinkStack, null, headers, requestStream,
- out responseMessage,
- out responseHeaders, out responseStream);
+ processing = DispatchRequest (requestStream, headers, out responseStream, out responseHeaders);
switch (processing)
{
case ServerProcessing.Complete:
- sinkStack.Pop(this);
- if(!HttpServer.SendResponse(socket,200,responseHeaders,responseStream))
+ if (!HttpServer.SendResponse (reqArg, 200, responseHeaders, responseStream))
{
//ooops couldnot send response !!!!!! and error occured
}
break;
case ServerProcessing.OneWay:
- if(!HttpServer.SendResponse(socket,200,null,null))
+ if (!HttpServer.SendResponse (reqArg, 200, null, null))
{
//ooops couldnot send response !!!!!! and error occured
}
@@ -392,17 +355,28 @@ namespace System.Runtime.Remoting.Channels.Http
break;
}
}
- catch(Exception )
+ catch (Exception ex)
{
+ Console.WriteLine (ex);
}
}
+ internal ServerProcessing DispatchRequest (Stream requestStream, ITransportHeaders headers, out Stream responseStream, out ITransportHeaders responseHeaders)
+ {
+ ServerChannelSinkStack sinkStack = new ServerChannelSinkStack();
+
+ IMessage responseMessage;
+ return _nextSink.ProcessMessage (sinkStack, null, headers, requestStream,
+ out responseMessage,
+ out responseHeaders, out responseStream);
+ }
+
//
// IServerChannelSink implementation
//
- public ServerProcessing ProcessMessage(IServerChannelSinkStack sinkStack,
+ public ServerProcessing ProcessMessage (IServerChannelSinkStack sinkStack,
IMessage requestMsg,
ITransportHeaders requestHeaders, Stream requestStream,
out IMessage responseMsg, out ITransportHeaders responseHeaders,
@@ -414,16 +388,12 @@ namespace System.Runtime.Remoting.Channels.Http
} // ProcessMessage
- public void AsyncProcessResponse(IServerResponseChannelSinkStack sinkStack, Object state,
+ public void AsyncProcessResponse (IServerResponseChannelSinkStack sinkStack, Object state,
IMessage msg, ITransportHeaders headers, Stream stream)
{
- Socket socket = (Socket) state;
-
- if(!HttpServer.SendResponse(socket,200,headers,stream))
- {
- //Ooops could not send response!!!!!!!!!1
- }
- } // AsyncProcessResponse
+ // Never called
+ throw new NotSupportedException ();
+ }
public Stream GetResponseStream(IServerResponseChannelSinkStack sinkStack, Object state,
diff --git a/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels.Http/HttpThread.cs b/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels.Http/HttpThread.cs
deleted file mode 100644
index 2b70e9b936d..00000000000
--- a/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels.Http/HttpThread.cs
+++ /dev/null
@@ -1,38 +0,0 @@
-//
-// System.Runtime.Remoting.Channels.Http.HttpThread
-//
-// Authors:
-// Ahmad Tantawy (popsito82@hotmail.com)
-// Ahmad Kadry (kadrianoz@hotmail.com)
-// Hussein Mehanna (hussein_mehanna@hotmail.com)
-//
-// (C) 2003 Ximian, Inc.
-//
-
-using System;
-using System.Threading;
-
-namespace System.Runtime.Remoting.Channels.Http
-{
-
- internal class HttpThread
- {
- RequestArguments reqArg;
- public HttpThread(object Object)
- {
- if(Object as RequestArguments == null)
- return;
-
- reqArg = (RequestArguments)Object;
-
- Thread proc = new Thread(new ThreadStart(ProcessRequest));
- proc.IsBackground = true;
- proc.Start();
-
- }
- private void ProcessRequest()
- {
- HttpServer.ProcessRequest(reqArg);
- }
- }
-}
diff --git a/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels.Tcp/ChangeLog b/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels.Tcp/ChangeLog
new file mode 100644
index 00000000000..487e07cbed0
--- /dev/null
+++ b/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels.Tcp/ChangeLog
@@ -0,0 +1,19 @@
+2003-11-16 Lluis Sanchez Gual <lluis@ximian.com>
+
+ * TcpClientChannel.cs: Added support for name and priority properties.
+ * TcpServerChannel.cs: Added support for priority, bindTo, useIpAddress,
+ machineName and supressChannelData properties.
+ * TcpChannel.cs, TcpServerTransportSink.cs: Formatting change.
+
+2003-11-13 Lluis Sanchez Gual <lluis@ximian.com>
+
+ * TcpChannel.cs: take into account name and priority properties.
+
+2003-11-12 Lluis Sanchez Gual <lluis@ximian.com>
+
+ * TcpServerChannel.cs: Remove listener initialization and StartListening
+ call from constructor. It is called now by the remoting framework.
+ * TcpConnectionPool.cs: Removed fixme.
+
+ Older log entries can be found in the System.Runtime.Remoting ChangeLog.
+
diff --git a/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels.Tcp/TcpChannel.cs b/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels.Tcp/TcpChannel.cs
index e5747c3bcff..0ef7dcc48c5 100644
--- a/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels.Tcp/TcpChannel.cs
+++ b/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels.Tcp/TcpChannel.cs
@@ -17,7 +17,8 @@ namespace System.Runtime.Remoting.Channels.Tcp
{
private TcpClientChannel _clientChannel;
private TcpServerChannel _serverChannel = null;
- private string _name;
+ private string _name = "tcp";
+ private int _priority = 1;
public TcpChannel (): this (0)
{
@@ -30,16 +31,18 @@ namespace System.Runtime.Remoting.Channels.Tcp
Init(ht, null, null);
}
- public void Init(IDictionary properties, IClientChannelSinkProvider clientSink, IServerChannelSinkProvider serverSink)
+ public void Init (IDictionary properties, IClientChannelSinkProvider clientSink, IServerChannelSinkProvider serverSink)
{
- _clientChannel = new TcpClientChannel(properties,clientSink);
-
+ _clientChannel = new TcpClientChannel (properties,clientSink);
+
if(properties["port"] != null)
- {
_serverChannel = new TcpServerChannel(properties, serverSink);
- }
- _name = properties["name"] as string;
+ object val = properties ["name"];
+ if (val != null) _name = val as string;
+
+ val = properties ["priority"];
+ if (val != null) _priority = Convert.ToInt32 (val);
}
@@ -62,7 +65,7 @@ namespace System.Runtime.Remoting.Channels.Tcp
public int ChannelPriority
{
- get { return 1; }
+ get { return _priority; }
}
public void StartListening (object data)
diff --git a/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels.Tcp/TcpClientChannel.cs b/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels.Tcp/TcpClientChannel.cs
index 22be8a5ba5f..04c4e798650 100644
--- a/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels.Tcp/TcpClientChannel.cs
+++ b/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels.Tcp/TcpClientChannel.cs
@@ -28,8 +28,12 @@ namespace System.Runtime.Remoting.Channels.Tcp
public TcpClientChannel (IDictionary properties, IClientChannelSinkProvider sinkProvider)
{
- priority = 1;
-
+ object val = properties ["name"];
+ if (val != null) name = val as string;
+
+ val = properties ["priority"];
+ if (val != null) priority = Convert.ToInt32 (val);
+
if (sinkProvider != null)
{
_sinkProvider = sinkProvider;
@@ -52,7 +56,6 @@ namespace System.Runtime.Remoting.Channels.Tcp
public TcpClientChannel (string name, IClientChannelSinkProvider sinkProvider)
{
- priority = 1;
this.name = name;
_sinkProvider = sinkProvider;
diff --git a/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels.Tcp/TcpConnectionPool.cs b/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels.Tcp/TcpConnectionPool.cs
index f3e36def999..278a2cc5bc6 100644
--- a/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels.Tcp/TcpConnectionPool.cs
+++ b/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels.Tcp/TcpConnectionPool.cs
@@ -44,7 +44,6 @@ namespace System.Runtime.Remoting.Channels.Tcp
public static void Shutdown ()
{
- // FIXME: this should not be needed when background threads work.
if (_poolThread != null)
_poolThread.Abort();
}
@@ -286,4 +285,4 @@ namespace System.Runtime.Remoting.Channels.Tcp
}
-}
+}
diff --git a/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels.Tcp/TcpServerChannel.cs b/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels.Tcp/TcpServerChannel.cs
index 67cfdfb6dde..d557622497b 100644
--- a/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels.Tcp/TcpServerChannel.cs
+++ b/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels.Tcp/TcpServerChannel.cs
@@ -21,8 +21,11 @@ namespace System.Runtime.Remoting.Channels.Tcp
{
int port = 0;
string name = "tcp";
- string host;
+ string host = null;
int priority = 1;
+ bool supressChannelData = false;
+ bool useIpAddress = false;
+
IPAddress bindAddress = IPAddress.Any;
Thread server_thread = null;
TcpListener listener;
@@ -31,6 +34,7 @@ namespace System.Runtime.Remoting.Channels.Tcp
int _maxConcurrentConnections = 100;
ArrayList _activeConnections = new ArrayList();
+
void Init (IServerChannelSinkProvider serverSinkProvider)
{
if (serverSinkProvider == null)
@@ -38,7 +42,16 @@ namespace System.Runtime.Remoting.Channels.Tcp
serverSinkProvider = new BinaryServerFormatterSinkProvider ();
}
- host = Dns.GetHostByName(Dns.GetHostName()).HostName;
+ if (host == null)
+ {
+ if (useIpAddress) {
+ IPHostEntry he = Dns.Resolve (Dns.GetHostName());
+ if (he.AddressList.Length == 0) throw new RemotingException ("IP address could not be determined for this host");
+ host = he.AddressList [0].ToString ();
+ }
+ else
+ host = Dns.GetHostByName(Dns.GetHostName()).HostName;
+ }
string [] uris = null;
@@ -61,9 +74,6 @@ namespace System.Runtime.Remoting.Channels.Tcp
IServerChannelSink next_sink = ChannelServices.CreateServerChannelSinkChain (serverSinkProvider, this);
sink = new TcpServerTransportSink (next_sink);
-
- listener = new TcpListener(bindAddress, port);
- StartListening (null);
}
public TcpServerChannel (int port)
@@ -91,7 +101,16 @@ namespace System.Runtime.Remoting.Channels.Tcp
case "rejectRemoteRequests":
if(Convert.ToBoolean(properties["rejectRemoteRequests"]))
bindAddress = IPAddress.Loopback;
+ break;
+ case "supressChannelData":
+ supressChannelData = Convert.ToBoolean (property.Value);
break;
+ case "useIpAddress":
+ useIpAddress = Convert.ToBoolean (property.Value);
+ break;
+ case "machineName":
+ host = property.Value as string;
+ break;
}
}
Init (serverSinkProvider);
@@ -115,7 +134,8 @@ namespace System.Runtime.Remoting.Channels.Tcp
public object ChannelData
{
get {
- return channel_data;
+ if (supressChannelData) return null;
+ else return channel_data;
}
}
@@ -198,6 +218,7 @@ namespace System.Runtime.Remoting.Channels.Tcp
public void StartListening (object data)
{
+ listener = new TcpListener (bindAddress, port);
if (server_thread == null)
{
listener.Start ();
@@ -281,8 +302,10 @@ namespace System.Runtime.Remoting.Channels.Tcp
}
}
}
- catch
- {}
+ catch (Exception ex)
+ {
+ Console.WriteLine (ex);
+ }
_stream.Close();
_serverChannel.ReleaseConnection (Thread.CurrentThread);
diff --git a/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels.Tcp/TcpServerTransportSink.cs b/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels.Tcp/TcpServerTransportSink.cs
index 409ecc81a71..d6fac7d45a9 100644
--- a/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels.Tcp/TcpServerTransportSink.cs
+++ b/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels.Tcp/TcpServerTransportSink.cs
@@ -83,7 +83,7 @@ namespace System.Runtime.Remoting.Channels.Tcp
ITransportHeaders responseHeaders;
Stream responseStream;
IMessage responseMsg;
-
+
ServerProcessing proc = next_sink.ProcessMessage(sinkStack, null, requestHeaders, requestStream, out responseMsg, out responseHeaders, out responseStream);
switch (proc)
diff --git a/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels/BinaryClientFormatterSink.cs b/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels/BinaryClientFormatterSink.cs
index 94e3845c260..30c3a6969c2 100644
--- a/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels/BinaryClientFormatterSink.cs
+++ b/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels/BinaryClientFormatterSink.cs
@@ -19,30 +19,24 @@ namespace System.Runtime.Remoting.Channels
public class BinaryClientFormatterSink : IClientFormatterSink,
IMessageSink, IClientChannelSink, IChannelSinkBase
{
- static BinaryFormatter _serializationFormatter;
- static BinaryFormatter _deserializationFormatter;
+ BinaryCore _binaryCore = BinaryCore.DefaultInstance;
+ IClientChannelSink _nextInChain;
- IClientChannelSink nextInChain;
-
- static BinaryClientFormatterSink ()
+ public BinaryClientFormatterSink (IClientChannelSink nextSink)
{
- RemotingSurrogateSelector surrogateSelector = new RemotingSurrogateSelector ();
- StreamingContext context = new StreamingContext(StreamingContextStates.Remoting, null);
-
- _serializationFormatter = new BinaryFormatter (surrogateSelector, context);
- _deserializationFormatter = new BinaryFormatter (null, context);
+ _nextInChain = nextSink;
}
-
- public BinaryClientFormatterSink (IClientChannelSink nextSink)
+ internal BinaryCore BinaryCore
{
- nextInChain = nextSink;
+ get { return _binaryCore; }
+ set { _binaryCore = value; }
}
public IClientChannelSink NextChannelSink
{
get {
- return nextInChain;
+ return _nextInChain;
}
}
@@ -76,7 +70,7 @@ namespace System.Runtime.Remoting.Channels
ITransportHeaders headers,
Stream stream)
{
- IMessage replyMessage = (IMessage)_deserializationFormatter.DeserializeMethodResponse (stream, null, (IMethodCallMessage)state);
+ IMessage replyMessage = (IMessage)_binaryCore.Deserializer.DeserializeMethodResponse (stream, null, (IMethodCallMessage)state);
sinkStack.DispatchReplyMessage (replyMessage);
}
@@ -104,16 +98,16 @@ namespace System.Runtime.Remoting.Channels
ITransportHeaders transportHeaders = new TransportHeaders();
transportHeaders[CommonTransportKeys.RequestUri] = ((IMethodCallMessage)msg).Uri;
- Stream stream = nextInChain.GetRequestStream(msg, transportHeaders);
+ Stream stream = _nextInChain.GetRequestStream(msg, transportHeaders);
if (stream == null) stream = new MemoryStream ();
- _serializationFormatter.Serialize (stream, msg, null);
+ _binaryCore.Serializer.Serialize (stream, msg, null);
if (stream is MemoryStream) stream.Position = 0;
ClientChannelSinkStack stack = new ClientChannelSinkStack(replySink);
stack.Push (this, msg);
- nextInChain.AsyncProcessRequest (stack, msg, transportHeaders, stream);
+ _nextInChain.AsyncProcessRequest (stack, msg, transportHeaders, stream);
// FIXME: No idea about how to implement IMessageCtrl
return null;
@@ -127,23 +121,23 @@ namespace System.Runtime.Remoting.Channels
call_headers[CommonTransportKeys.RequestUri] = ((IMethodCallMessage)msg).Uri;
call_headers["Content-Type"] = "application/octet-stream";
- Stream call_stream = nextInChain.GetRequestStream(msg, call_headers);
+ Stream call_stream = _nextInChain.GetRequestStream(msg, call_headers);
if (call_stream == null) call_stream = new MemoryStream ();
// Serialize msg to the stream
- _serializationFormatter.Serialize (call_stream, msg, null);
+ _binaryCore.Serializer.Serialize (call_stream, msg, null);
if (call_stream is MemoryStream) call_stream.Position = 0;
Stream response_stream;
ITransportHeaders response_headers;
- nextInChain.ProcessMessage (msg, call_headers, call_stream, out response_headers,
+ _nextInChain.ProcessMessage (msg, call_headers, call_stream, out response_headers,
out response_stream);
// Deserialize response_stream
- return (IMessage) _deserializationFormatter.DeserializeMethodResponse (response_stream, null, (IMethodCallMessage)msg);
+ return (IMessage) _binaryCore.Deserializer.DeserializeMethodResponse (response_stream, null, (IMethodCallMessage)msg);
} catch (Exception e) {
return new ReturnMessage (e, (IMethodCallMessage)msg);
diff --git a/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels/BinaryClientFormatterSinkProvider.cs b/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels/BinaryClientFormatterSinkProvider.cs
index be81cab2e41..408516de50a 100644
--- a/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels/BinaryClientFormatterSinkProvider.cs
+++ b/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels/BinaryClientFormatterSinkProvider.cs
@@ -2,6 +2,7 @@
// System.Runtime.Remoting.Channels.BinaryClientFormatterSinkProvider.cs
//
// Author: Rodrigo Moya (rodrigo@ximian.com)
+// Lluis Sanchez Gual (lluis@ximian.com)
//
// 2002 (C) Copyright, Ximian, Inc.
//
@@ -14,20 +15,18 @@ namespace System.Runtime.Remoting.Channels
IClientFormatterSinkProvider, IClientChannelSinkProvider
{
IClientChannelSinkProvider next = null;
+ BinaryCore _binaryCore;
+ static string[] allowedProperties = new string [] { "includeVersions", "strictBinding" };
- // add any sink properties here (private fields)
-
public BinaryClientFormatterSinkProvider ()
{
- // nothing to do
+ _binaryCore = BinaryCore.DefaultInstance;
}
public BinaryClientFormatterSinkProvider (IDictionary properties,
ICollection providerData)
- {
- // copy the contained properties to private fields
-
- // add a check that there is no providerData
+ {
+ _binaryCore = new BinaryCore (this, properties, allowedProperties);
}
public IClientChannelSinkProvider Next
@@ -52,8 +51,7 @@ namespace System.Runtime.Remoting.Channels
next_sink = next.CreateSink (channel, url, remoteChannelData);
result = new BinaryClientFormatterSink (next_sink);
-
- // set properties on the newly creates sink
+ result.BinaryCore = _binaryCore;
return result;
}
diff --git a/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels/BinaryCore.cs b/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels/BinaryCore.cs
new file mode 100644
index 00000000000..aaf562e8f02
--- /dev/null
+++ b/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels/BinaryCore.cs
@@ -0,0 +1,107 @@
+//
+// System.Runtime.Remoting.Channels.BinaryCore.cs
+//
+// Author: Lluis Sanchez Gual (lluis@ximian.com)
+//
+// 2003 (C) Copyright, Novell, Inc.
+//
+
+using System.Collections;
+using System.Runtime.Remoting.Messaging;
+using System.Runtime.Serialization;
+using System.Runtime.Serialization.Formatters;
+using System.Runtime.Serialization.Formatters.Binary;
+
+namespace System.Runtime.Remoting.Channels
+{
+ internal class BinaryCore
+ {
+ BinaryFormatter _serializationFormatter;
+ BinaryFormatter _deserializationFormatter;
+ bool _includeVersions = true;
+ bool _strictBinding = false;
+
+#if NET_1_1
+ TypeFilterLevel _filterLevel = TypeFilterLevel.Low;
+#endif
+
+ public static BinaryCore DefaultInstance = new BinaryCore ();
+
+ public BinaryCore (object owner, IDictionary properties, string[] allowedProperties)
+ {
+ foreach(DictionaryEntry property in properties)
+ {
+ string key = (string) property.Key;
+ if (Array.IndexOf (allowedProperties, key) == -1)
+ throw new RemotingException (owner.GetType().Name + " does not recognize '" + key + "' configuration property");
+
+ switch (key)
+ {
+ case "includeVersions":
+ _includeVersions = Convert.ToBoolean (property.Value);
+ break;
+
+ case "strictBinding":
+ _strictBinding = Convert.ToBoolean (property.Value);
+ break;
+
+#if NET_1_1
+ case "typeFilterLevel":
+ if (property.Value is TypeFilterLevel)
+ _filterLevel = (TypeFilterLevel) property.Value;
+ else {
+ string s = (string) property.Value;
+ _filterLevel = (TypeFilterLevel) Enum.Parse (typeof(TypeFilterLevel), s);
+ }
+ break;
+#endif
+
+ }
+ }
+
+ Init ();
+ }
+
+ public BinaryCore ()
+ {
+ Init ();
+ }
+
+ public void Init ()
+ {
+ RemotingSurrogateSelector surrogateSelector = new RemotingSurrogateSelector ();
+ StreamingContext context = new StreamingContext (StreamingContextStates.Remoting, null);
+
+ _serializationFormatter = new BinaryFormatter (surrogateSelector, context);
+ _deserializationFormatter = new BinaryFormatter (null, context);
+
+#if NET_1_1
+ _serializationFormatter.FilterLevel = _filterLevel;
+ _deserializationFormatter.FilterLevel = _filterLevel;
+#endif
+
+ if (!_includeVersions)
+ {
+ _serializationFormatter.AssemblyFormat = FormatterAssemblyStyle.Simple;
+ _deserializationFormatter.AssemblyFormat = FormatterAssemblyStyle.Simple;
+ }
+
+ if (!_strictBinding)
+ {
+ _serializationFormatter.Binder = ChannelCore.SimpleBinder;
+ _deserializationFormatter.Binder = ChannelCore.SimpleBinder;
+ }
+ }
+
+ public BinaryFormatter Serializer
+ {
+ get { return _serializationFormatter; }
+ }
+
+ public BinaryFormatter Deserializer
+ {
+ get { return _deserializationFormatter; }
+ }
+ }
+}
+
diff --git a/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels/BinaryServerFormatterSink.cs b/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels/BinaryServerFormatterSink.cs
index adf2c74dbc2..cee31cda284 100644
--- a/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels/BinaryServerFormatterSink.cs
+++ b/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels/BinaryServerFormatterSink.cs
@@ -24,22 +24,12 @@ namespace System.Runtime.Remoting.Channels {
Other = 1,
}
- static BinaryFormatter _serializationFormatter;
- static BinaryFormatter _deserializationFormatter;
+ BinaryCore _binaryCore = BinaryCore.DefaultInstance;
IServerChannelSink next_sink;
Protocol protocol;
IChannelReceiver receiver;
- static BinaryServerFormatterSink()
- {
- RemotingSurrogateSelector surrogateSelector = new RemotingSurrogateSelector ();
- StreamingContext context = new StreamingContext(StreamingContextStates.Remoting, null);
-
- _serializationFormatter = new BinaryFormatter (surrogateSelector, context);
- _deserializationFormatter = new BinaryFormatter (null, context);
- }
-
public BinaryServerFormatterSink (BinaryServerFormatterSink.Protocol protocol,
IServerChannelSink nextSink,
IChannelReceiver receiver)
@@ -49,6 +39,12 @@ namespace System.Runtime.Remoting.Channels {
this.receiver = receiver;
}
+ internal BinaryCore BinaryCore
+ {
+ get { return _binaryCore; }
+ set { _binaryCore = value; }
+ }
+
public IServerChannelSink NextChannelSink {
get {
return next_sink;
@@ -69,7 +65,7 @@ namespace System.Runtime.Remoting.Channels {
if (sinkStack != null) stream = sinkStack.GetResponseStream (message, responseHeaders);
if (stream == null) stream = new MemoryStream();
- _serializationFormatter.Serialize (stream, message, null);
+ _binaryCore.Serializer.Serialize (stream, message, null);
if (stream is MemoryStream) stream.Position = 0;
sinkStack.AsyncProcessResponse (message, responseHeaders, stream);
@@ -96,9 +92,7 @@ namespace System.Runtime.Remoting.Channels {
if (uri == null) uri = url;
MethodCallHeaderHandler mhh = new MethodCallHeaderHandler(uri);
- requestMsg = (IMessage) _deserializationFormatter.Deserialize (requestStream, new HeaderHandler(mhh.HandleHeaders));
-
- // Fixme: check if the message is an async msg
+ requestMsg = (IMessage) _binaryCore.Deserializer.Deserialize (requestStream, new HeaderHandler(mhh.HandleHeaders));
res = next_sink.ProcessMessage (sinkStack, requestMsg, requestHeaders, null, out responseMsg, out responseHeaders, out responseStream);
}
@@ -118,7 +112,7 @@ namespace System.Runtime.Remoting.Channels {
if (sinkStack != null) responseStream = sinkStack.GetResponseStream (responseMsg, responseHeaders);
if (responseStream == null) responseStream = new MemoryStream();
- _serializationFormatter.Serialize (responseStream, responseMsg);
+ _binaryCore.Serializer.Serialize (responseStream, responseMsg);
if (responseStream is MemoryStream) responseStream.Position = 0;
sinkStack.Pop (this);
@@ -143,4 +137,3 @@ namespace System.Runtime.Remoting.Channels {
}
}
}
-
diff --git a/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels/BinaryServerFormatterSinkProvider.cs b/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels/BinaryServerFormatterSinkProvider.cs
index ccbc3fcb2ca..2349bbfcb25 100644
--- a/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels/BinaryServerFormatterSinkProvider.cs
+++ b/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels/BinaryServerFormatterSinkProvider.cs
@@ -2,6 +2,7 @@
// System.Runtime.Remoting.Channels.BinaryServerFormatterSinkProvider.cs
//
// Author: Rodrigo Moya (rodrigo@ximian.com)
+// Lluis Sanchez Gual (lluis@ximian.com)
//
// 2002 (C) Copyright, Ximian, Inc.
//
@@ -14,16 +15,24 @@ namespace System.Runtime.Remoting.Channels
IServerFormatterSinkProvider, IServerChannelSinkProvider
{
IServerChannelSinkProvider next = null;
+ BinaryCore _binaryCore;
+
+#if NET_1_0
+ static string[] allowedProperties = new string [] { "includeVersions", "strictBinding" };
+#endif
+#if NET_1_1
+ static string[] allowedProperties = new string [] { "includeVersions", "strictBinding", "typeFilterLevel" };
+#endif
public BinaryServerFormatterSinkProvider ()
{
+ _binaryCore = BinaryCore.DefaultInstance;
}
- [MonoTODO]
public BinaryServerFormatterSinkProvider (IDictionary properties,
ICollection providerData)
- {
- throw new NotImplementedException ();
+ {
+ _binaryCore = new BinaryCore (this, properties, allowedProperties);
}
public IServerChannelSinkProvider Next
@@ -48,11 +57,11 @@ namespace System.Runtime.Remoting.Channels
result = new BinaryServerFormatterSink (BinaryServerFormatterSink.Protocol.Other,
next_sink, channel);
- // set properties on result
-
+ result.BinaryCore = _binaryCore;
return result;
}
+ [MonoTODO]
public void GetChannelData (IChannelDataStore channelData)
{
// no idea why we need this
diff --git a/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels/ChangeLog b/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels/ChangeLog
index 43006e9985a..24d9369c840 100644
--- a/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels/ChangeLog
+++ b/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels/ChangeLog
@@ -1,3 +1,40 @@
+2003-11-21 Lluis Sanchez Gual <lluis@ximian.com>
+
+ * BinaryClientFormatterSinkProvider.cs, BinaryServerFormatterSinkProvider.cs,
+ BinaryCore.cs, BinaryServerFormatterSinkProvider.cs,
+ SoapClientFormatterSinkProvider.cs, SoapCore.cs,
+ SoapServerFormatterSinkProvider.cs.cs: Added support for TypeFilterLevel
+ property.
+
+2003-11-17 Lluis Sanchez Gual <lluis@ximian.com>
+
+ * BinaryClientFormatterSinkProvider.cs, BinaryServerFormatterSinkProvider.cs:
+ SoapClientFormatterSinkProvider.cs, SoapServerFormatterSinkProvider.cs: Small fix.
+ * SoapServerFormatterSink.cs: Small fix in AsyncProcessResponse.
+ * BinaryCore.cs, SoapCore.cs: throw an exception if an unknown property
+ is found.
+
+2003-11-16 Lluis Sanchez Gual <lluis@ximian.com>
+
+ * BinaryClientFormatterSink.cs, BinaryClientFormatterSinkProvider.cs,
+ BinaryServerFormatterSink.cs, BinaryServerFormatterSinkProvider.cs:
+ Moved formatter code to BinaryCore. This adds support for the properties
+ "includeVersion" and "strictBinding" to the binary formatter.
+ * BinaryCore.cs: New file. Contains some code used by the binary formatter sinks.
+ * SoapClientFormatterSink.cs, SoapClientFormatterSinkProvider.cs,
+ SoapServerFormatterSink.cs, SoapServerFormatterSinkProvider.cs
+ Moved formatter code to BinaryCore. This adds support for the properties
+ "includeVersion" and "strictBinding" to the soap formatter.
+ * SoapCore.cs: New file. Contains some code used by the soap formatter sinks.
+ * ChannelCore.cs: New file. Implements a simple type binder used by the
+ formatter sinks.
+
+2003-11-12 Lluis Sanchez Gual <lluis@ximian.com>
+
+ * BinaryServerFormatterSink.cs: Removed fixme.
+ * BinaryServerFormatterSinkProvider.cs: Removed a NotImplementedException.
+ * SoapServerFormatterSinkProvider.cs: Removed some TODOs.
+
2003-09-25 Lluis Sanchez Gual <lluis@ximian.com>
* SoapMessageFormatter.cs: Consider parameters with Out flag when collectiong
diff --git a/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels/ChannelCore.cs b/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels/ChannelCore.cs
new file mode 100644
index 00000000000..78aad101fa0
--- /dev/null
+++ b/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels/ChannelCore.cs
@@ -0,0 +1,47 @@
+//
+// System.Runtime.Remoting.Channels.ChannelCore.cs
+//
+// Author: Lluis Sanchez Gual (lluis@ximian.com)
+//
+// 2003 (C) Copyright, Novell, Inc.
+//
+
+using System;
+using System.Reflection;
+using System.Runtime.Serialization;
+
+namespace System.Runtime.Remoting.Channels
+{
+ internal class ChannelCore
+ {
+ public static SerializationBinder SimpleBinder = new SimpleBinder();
+ }
+
+ internal class SimpleBinder: SerializationBinder
+ {
+ public override Type BindToType (String assemblyName, string typeName)
+ {
+ Assembly asm;
+
+ int i = assemblyName.IndexOf (",");
+ if (i != -1)
+ {
+ // Try using the full name
+ try
+ {
+ asm = Assembly.Load (assemblyName);
+ Type t = asm.GetType (typeName);
+ if (t != null) return t;
+ }
+ catch {}
+
+ assemblyName = assemblyName.Substring (0,i);
+ }
+
+ // Try using the simple name
+ asm = Assembly.Load (assemblyName);
+ return asm.GetType (typeName, true);
+ }
+ }
+}
+
diff --git a/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels/SoapClientFormatterSink.cs b/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels/SoapClientFormatterSink.cs
index 60abd818da4..246bc5b83a0 100644
--- a/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels/SoapClientFormatterSink.cs
+++ b/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels/SoapClientFormatterSink.cs
@@ -21,16 +21,17 @@ namespace System.Runtime.Remoting.Channels
IMessageSink, IClientChannelSink, IChannelSinkBase
{
private IClientChannelSink _nextChannelSink;
- private SoapFormatter _serializationFormatter;
- private SoapFormatter _deserializationFormatter;
-
+ private SoapCore _soapCore = SoapCore.DefaultInstance;
+
public SoapClientFormatterSink (IClientChannelSink sink)
{
_nextChannelSink = sink;
- RemotingSurrogateSelector surrogateSelector = new RemotingSurrogateSelector();
- StreamingContext context = new StreamingContext(StreamingContextStates.Remoting);
- _serializationFormatter = new SoapFormatter(surrogateSelector, context);
- _deserializationFormatter = new SoapFormatter(null, context);
+ }
+
+ internal SoapCore SoapCore
+ {
+ get { return _soapCore; }
+ set { _soapCore = value; }
}
// IClientChannelSink
@@ -139,7 +140,7 @@ namespace System.Runtime.Remoting.Channels
if(requestStream == null) requestStream = new MemoryStream();
// Serialize the message into the stream
- _serializationFormatter.Serialize(requestStream, soapMsg, null);
+ _soapCore.Serializer.Serialize(requestStream, soapMsg, null);
if(requestStream is MemoryStream){
requestStream.Position = 0;
@@ -147,10 +148,12 @@ namespace System.Runtime.Remoting.Channels
}
- private IMessage DeserializeMessage(Stream responseStream, ITransportHeaders responseHeaders,IMethodCallMessage mcm, SoapMessageFormatter soapMsgFormatter) {
+ private IMessage DeserializeMessage(Stream responseStream, ITransportHeaders responseHeaders,IMethodCallMessage mcm, SoapMessageFormatter soapMsgFormatter)
+ {
+ SoapFormatter fm = _soapCore.GetSafeDeserializer ();
SoapMessage rtnMessage = new SoapMessage();
- _deserializationFormatter.TopObject = rtnMessage;
- object objReturn = _deserializationFormatter.Deserialize(responseStream);
+ fm.TopObject = rtnMessage;
+ object objReturn = fm.Deserialize(responseStream);
return soapMsgFormatter.FormatResponse((ISoapMessage) objReturn, mcm);
}
diff --git a/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels/SoapClientFormatterSinkProvider.cs b/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels/SoapClientFormatterSinkProvider.cs
index 0da38c2ab17..d23b2991f4a 100644
--- a/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels/SoapClientFormatterSinkProvider.cs
+++ b/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels/SoapClientFormatterSinkProvider.cs
@@ -8,21 +8,22 @@ namespace System.Runtime.Remoting.Channels {
IClientChannelSinkProvider
{
private IClientChannelSinkProvider _nextClientChannelSinkProvider;
- private IDictionary _properties;
- private ICollection _providerData;
+ SoapCore _soapCore;
+ static string[] allowedProperties = new string [] { "includeVersions", "strictBinding" };
- public SoapClientFormatterSinkProvider() {
-
+ public SoapClientFormatterSinkProvider()
+ {
+ _soapCore = SoapCore.DefaultInstance;
}
public SoapClientFormatterSinkProvider(IDictionary properties,
ICollection providerData)
{
- _properties = properties;
- _providerData = providerData;
+ _soapCore = new SoapCore (this, properties, allowedProperties);
}
- public virtual IClientChannelSinkProvider Next {
+ public virtual IClientChannelSinkProvider Next
+ {
get { return _nextClientChannelSinkProvider;}
set { _nextClientChannelSinkProvider = value;}
}
@@ -33,9 +34,9 @@ namespace System.Runtime.Remoting.Channels {
{
IClientChannelSink _nextSink = _nextClientChannelSinkProvider.CreateSink(channel, url, remoteChannelData);
- IClientChannelSink scfs = new SoapClientFormatterSink(_nextSink);
+ SoapClientFormatterSink scfs = new SoapClientFormatterSink(_nextSink);
+ scfs.SoapCore = _soapCore;
return scfs;
-
}
}
}
diff --git a/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels/SoapCore.cs b/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels/SoapCore.cs
new file mode 100644
index 00000000000..5e53a478537
--- /dev/null
+++ b/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels/SoapCore.cs
@@ -0,0 +1,112 @@
+//
+// System.Runtime.Remoting.Channels.SoapCore.cs
+//
+// Author: Lluis Sanchez Gual (lluis@ximian.com)
+//
+// 2003 (C) Copyright, Novell, Inc.
+//
+
+using System.Collections;
+using System.Runtime.Remoting.Messaging;
+using System.Runtime.Serialization;
+using System.Runtime.Serialization.Formatters;
+using System.Runtime.Serialization.Formatters.Soap;
+
+namespace System.Runtime.Remoting.Channels
+{
+ internal class SoapCore
+ {
+ SoapFormatter _serializationFormatter;
+ SoapFormatter _deserializationFormatter;
+ bool _includeVersions = true;
+ bool _strictBinding = false;
+
+#if NET_1_1
+ TypeFilterLevel _filterLevel = TypeFilterLevel.Low;
+#endif
+
+ public static SoapCore DefaultInstance = new SoapCore ();
+
+ public SoapCore (object owner, IDictionary properties, string[] allowedProperties)
+ {
+ foreach(DictionaryEntry property in properties)
+ {
+ string key = (string) property.Key;
+ if (Array.IndexOf (allowedProperties, key) == -1)
+ throw new RemotingException (owner.GetType().Name + " does not recognize '" + key + "' configuration property");
+
+ switch (key)
+ {
+ case "includeVersions":
+ _includeVersions = Convert.ToBoolean (property.Value);
+ break;
+
+ case "strictBinding":
+ _strictBinding = Convert.ToBoolean (property.Value);
+ break;
+#if NET_1_1
+ case "typeFilterLevel":
+ if (property.Value is TypeFilterLevel)
+ _filterLevel = (TypeFilterLevel) property.Value;
+ else {
+ string s = (string) property.Value;
+ _filterLevel = (TypeFilterLevel) Enum.Parse (typeof(TypeFilterLevel), s);
+ }
+ break;
+#endif
+ }
+ }
+
+ Init ();
+ }
+
+ public SoapCore ()
+ {
+ Init ();
+ }
+
+ public void Init ()
+ {
+ RemotingSurrogateSelector surrogateSelector = new RemotingSurrogateSelector ();
+ StreamingContext context = new StreamingContext (StreamingContextStates.Remoting, null);
+
+ _serializationFormatter = CreateFormatter (surrogateSelector, context);
+ _deserializationFormatter = CreateFormatter (null, context);
+
+#if NET_1_1
+ _serializationFormatter.FilterLevel = _filterLevel;
+ _deserializationFormatter.FilterLevel = _filterLevel;
+#endif
+ }
+
+ SoapFormatter CreateFormatter (ISurrogateSelector selector, StreamingContext context)
+ {
+ SoapFormatter fm = new SoapFormatter (selector, context);
+
+ if (!_includeVersions)
+ fm.AssemblyFormat = FormatterAssemblyStyle.Simple;
+
+ if (!_strictBinding)
+ fm.Binder = ChannelCore.SimpleBinder;
+
+ return fm;
+ }
+
+ public SoapFormatter GetSafeDeserializer ()
+ {
+ StreamingContext context = new StreamingContext (StreamingContextStates.Remoting, null);
+ return CreateFormatter (null, context);
+ }
+
+ public SoapFormatter Serializer
+ {
+ get { return _serializationFormatter; }
+ }
+
+ public SoapFormatter Deserializer
+ {
+ get { return _deserializationFormatter; }
+ }
+ }
+}
+
diff --git a/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels/SoapServerFormatterSink.cs b/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels/SoapServerFormatterSink.cs
index 1fb925e2640..45541122748 100644
--- a/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels/SoapServerFormatterSink.cs
+++ b/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels/SoapServerFormatterSink.cs
@@ -30,8 +30,7 @@ namespace System.Runtime.Remoting.Channels {
{
IServerChannelSink next_sink;
IChannelReceiver _receiver;
- private SoapFormatter _serializationFormatter;
- private SoapFormatter _deserializationFormatter;
+ private SoapCore _soapCore = SoapCore.DefaultInstance;
public SoapServerFormatterSink (SoapServerFormatterSink.Protocol protocol,
IServerChannelSink nextSink,
@@ -39,12 +38,14 @@ namespace System.Runtime.Remoting.Channels {
{
this.next_sink = nextSink;
_receiver = receiver;
- RemotingSurrogateSelector surrogateSelector = new RemotingSurrogateSelector();
- StreamingContext context = new StreamingContext(StreamingContextStates.Other);
- _serializationFormatter = new SoapFormatter(surrogateSelector, context);
- _deserializationFormatter = new SoapFormatter(null, context);
}
+ internal SoapCore SoapCore
+ {
+ get { return _soapCore; }
+ set { _soapCore = value; }
+ }
+
/// <summary>
// Gets the next channel sink in the channel sink chain
// </summary>
@@ -76,9 +77,10 @@ namespace System.Runtime.Remoting.Channels {
SoapMessage soapMessage = (SoapMessage) soapMsgFormatter.BuildSoapMessageFromMethodResponse((IMethodReturnMessage)msg, out responseHeaders);
- _serializationFormatter.Serialize(stream, soapMessage, null);
+ _soapCore.Serializer.Serialize(stream, soapMessage, null);
if(stream is MemoryStream) stream.Position = 0;
+ sinkStack.AsyncProcessResponse (msg, responseHeaders, stream);
}
public Stream GetResponseStream (IServerResponseChannelSinkStack sinkStack, object state,
@@ -109,10 +111,11 @@ namespace System.Runtime.Remoting.Channels {
Type serverType = RemotingServices.GetServerTypeForUri(uri);
if (serverType == null) throw new RemotingException ("No receiver for uri " + uri);
+ SoapFormatter fm = _soapCore.GetSafeDeserializer ();
SoapMessage soapMessage = new SoapMessage();
- _deserializationFormatter.TopObject = soapMessage;
+ fm.TopObject = soapMessage;
requestStream.Position = 0;
- _deserializationFormatter.Deserialize(requestStream);
+ fm.Deserialize(requestStream);
requestMsg = soapMsgFormatter.BuildMethodCallFromSoapMessage(soapMessage, uri);
@@ -123,7 +126,7 @@ namespace System.Runtime.Remoting.Channels {
object rtnMessageObject = soapMsgFormatter.BuildSoapMessageFromMethodResponse((IMethodReturnMessage) responseMsg, out responseHeaders);
responseStream = new MemoryStream();
- _serializationFormatter.Serialize(responseStream, rtnMessageObject);
+ _soapCore.Serializer.Serialize(responseStream, rtnMessageObject);
}
}
}
@@ -132,7 +135,7 @@ namespace System.Runtime.Remoting.Channels {
responseMsg = (IMethodReturnMessage)new ReturnMessage(e, (IMethodCallMessage)requestMsg);
object rtnMessageObject = soapMsgFormatter.BuildSoapMessageFromMethodResponse((IMethodReturnMessage) responseMsg, out responseHeaders);
responseStream = new MemoryStream();
- _serializationFormatter.Serialize(responseStream, rtnMessageObject);
+ _soapCore.Serializer.Serialize(responseStream, rtnMessageObject);
sp = ServerProcessing.Complete;
}
diff --git a/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels/SoapServerFormatterSinkProvider.cs b/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels/SoapServerFormatterSinkProvider.cs
index fa308e91e66..2db8fd75a50 100644
--- a/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels/SoapServerFormatterSinkProvider.cs
+++ b/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels/SoapServerFormatterSinkProvider.cs
@@ -2,6 +2,7 @@
// System.Runtime.Remoting.Channels.SoapServerFormatterSinkProvider.cs
//
// Author: Rodrigo Moya (rodrigo@ximian.com)
+// Lluis Sanchez Gual (lluis@ximian.com)
//
// 2002 (C) Copyright, Ximian, Inc.
//
@@ -14,46 +15,46 @@ namespace System.Runtime.Remoting.Channels
IServerFormatterSinkProvider, IServerChannelSinkProvider
{
private IServerChannelSinkProvider _next;
-// ////[MonoTODO]
+ SoapCore _soapCore;
+
+#if NET_1_0
+ static string[] allowedProperties = new string [] { "includeVersions", "strictBinding" };
+#endif
+#if NET_1_1
+ static string[] allowedProperties = new string [] { "includeVersions", "strictBinding", "typeFilterLevel" };
+#endif
+
public SoapServerFormatterSinkProvider ()
{
-// throw new NotImplementedException ();
+ _soapCore = SoapCore.DefaultInstance;
}
-// ////[MonoTODO]
public SoapServerFormatterSinkProvider (IDictionary properties,
ICollection providerData)
{
-// throw new NotImplementedException ();
+ _soapCore = new SoapCore (this, properties, allowedProperties);
}
public IServerChannelSinkProvider Next
{
-// ////[MonoTODO]
- get {
- return _next;
- }
-
-// ////[MonoTODO]
- set {
- _next = value;
- }
+ get { return _next; }
+
+ set { _next = value; }
}
-// ////[MonoTODO]
public IServerChannelSink CreateSink (IChannelReceiver channel)
{
IServerChannelSink chain = _next.CreateSink(channel);
- IServerChannelSink sinkFormatter = new SoapServerFormatterSink(SoapServerFormatterSink.Protocol.Http, chain, channel);
+ SoapServerFormatterSink sinkFormatter = new SoapServerFormatterSink(SoapServerFormatterSink.Protocol.Http, chain, channel);
+ sinkFormatter.SoapCore = _soapCore;
return sinkFormatter;
}
-// ////[MonoTODO]
public void GetChannelData (IChannelDataStore channelData)
{
if(_next != null)
_next.GetChannelData(channelData);
}
}
-}
+}
diff --git a/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.dll.sources b/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.dll.sources
index 688ffe9cfc4..fd2e7c1f1da 100644
--- a/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.dll.sources
+++ b/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.dll.sources
@@ -1,10 +1,13 @@
./System.Runtime.Remoting/TODOAttribute.cs
./System.Runtime.Remoting.Channels/BinaryClientFormatterSink.cs
./System.Runtime.Remoting.Channels/BinaryClientFormatterSinkProvider.cs
+./System.Runtime.Remoting.Channels/BinaryCore.cs
./System.Runtime.Remoting.Channels/BinaryServerFormatterSink.cs
./System.Runtime.Remoting.Channels/BinaryServerFormatterSinkProvider.cs
+./System.Runtime.Remoting.Channels/ChannelCore.cs
./System.Runtime.Remoting.Channels/CommonTransportKeys.cs
./System.Runtime.Remoting.Channels/SoapClientFormatterSink.cs
+./System.Runtime.Remoting.Channels/SoapCore.cs
./System.Runtime.Remoting.Channels/SoapServerFormatterSink.cs
./System.Runtime.Remoting.Channels/SoapClientFormatterSinkProvider.cs
./System.Runtime.Remoting.Channels/SoapServerFormatterSinkProvider.cs
@@ -24,7 +27,6 @@
./System.Runtime.Remoting.Channels.Http/HttpRemotingHandlerFactory.cs
./System.Runtime.Remoting.Channels.Http/HttpServer.cs
./System.Runtime.Remoting.Channels.Http/HttpServerChannel.cs
-./System.Runtime.Remoting.Channels.Http/HttpThread.cs
./System.Runtime.Remoting.MetadataServices/MetaData.cs
./System.Runtime.Remoting.MetadataServices/SdlChannelSinkProvider.cs
./System.Runtime.Remoting.MetadataServices/ServiceType.cs
diff --git a/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting_test.dll.sources b/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting_test.dll.sources
index 282df16027b..c886f45c2f8 100644
--- a/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting_test.dll.sources
+++ b/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting_test.dll.sources
@@ -8,4 +8,5 @@ AsyncCalls.cs
ReflectionCalls.cs
DelegateCalls.cs
TcpCalls.cs
+CrossDomainCalls.cs
HttpCalls.cs
diff --git a/mcs/class/System.Runtime.Remoting/Test/BaseCalls.cs b/mcs/class/System.Runtime.Remoting/Test/BaseCalls.cs
index 2a987b548dd..5a5ceeab3d7 100644
--- a/mcs/class/System.Runtime.Remoting/Test/BaseCalls.cs
+++ b/mcs/class/System.Runtime.Remoting/Test/BaseCalls.cs
@@ -100,7 +100,11 @@ namespace MonoTests.System.Runtime.Remoting
public abstract InstanceSurrogate GetInstanceSurrogate ();
public abstract AbstractSurrogate GetAbstractSurrogate ();
public abstract InterfaceSurrogate GetInterfaceSurrogate ();
- public abstract ChannelManager CreateChannelManager ();
+
+ public virtual ChannelManager CreateChannelManager ()
+ {
+ return null;
+ }
//
// The tests
diff --git a/mcs/class/System.Runtime.Remoting/Test/CallSeq.cs b/mcs/class/System.Runtime.Remoting/Test/CallSeq.cs
index 32210d7c752..78fe1243212 100644
--- a/mcs/class/System.Runtime.Remoting/Test/CallSeq.cs
+++ b/mcs/class/System.Runtime.Remoting/Test/CallSeq.cs
@@ -98,4 +98,4 @@ namespace MonoTests.System.Runtime.Remoting
set { calls = value; }
}
}
-}
+}
diff --git a/mcs/class/System.Runtime.Remoting/Test/ChangeLog b/mcs/class/System.Runtime.Remoting/Test/ChangeLog
index bed2f044bef..b72ddbeb387 100644
--- a/mcs/class/System.Runtime.Remoting/Test/ChangeLog
+++ b/mcs/class/System.Runtime.Remoting/Test/ChangeLog
@@ -1,7 +1,8 @@
-2003-09-11 Lluis Sanchez Gual <lluis@ximian.com>
+2003-11-11 Lluis Sanchez Gual <lluis@ximian.com>
- * AsyncCalls.cs BaseCalls.cs DelegateCalls.cs ReflectionCalls.cs SyncCalls.cs:
- Added tests for CallContext and for parameters with the Out flag.
+ * BaseCalls.cs: Little fix.
+ * ContextsTest.cs: Unregister dynamic properties even if there is an exception.
+ * CrossDomainCalls.cs: New test for the cross-app domain channel.
2003-09-01 Nick Drochak <ndrochak@gol.com>
diff --git a/mcs/class/System.Runtime.Remoting/Test/ContextsTest.cs b/mcs/class/System.Runtime.Remoting/Test/ContextsTest.cs
index aabe7f28e63..722d2cee1f3 100644
--- a/mcs/class/System.Runtime.Remoting/Test/ContextsTest.cs
+++ b/mcs/class/System.Runtime.Remoting/Test/ContextsTest.cs
@@ -112,11 +112,11 @@ namespace MonoTests.System.Runtime.Remoting
void RunTestObject (ServerList list)
{
+ DynProperty prop1 = new DynProperty("defcontext");
+ DynProperty prop2 = new DynProperty("proxy");
+
try
{
- DynProperty prop1 = new DynProperty("defcontext");
- DynProperty prop2 = new DynProperty("proxy");
-
Context.RegisterDynamicProperty (prop1, null, Context.DefaultContext);
Context.RegisterDynamicProperty (prop2, list, null);
@@ -184,15 +184,15 @@ namespace MonoTests.System.Runtime.Remoting
CallSeq.Add (">> Processing items");
list.ProcessItems ();
CallSeq.Add ("<< Processing items");
-
- Context.UnregisterDynamicProperty ("defcontext", null, Context.DefaultContext);
- Context.UnregisterDynamicProperty ("proxy", list, null);
}
catch (Exception ex)
{
// Console.WriteLine (ex.ToString());
throw;
}
+
+ Context.UnregisterDynamicProperty ("defcontext", null, Context.DefaultContext);
+ Context.UnregisterDynamicProperty ("proxy", list, null);
}
}
@@ -1138,5 +1138,4 @@ namespace MonoTests.System.Runtime.Remoting
"235 (d1,c0) << TestRemoteContext",
};
}
-}
-
+}
diff --git a/mcs/class/System.Runtime.Remoting/Test/CrossDomainCalls.cs b/mcs/class/System.Runtime.Remoting/Test/CrossDomainCalls.cs
new file mode 100644
index 00000000000..0194f91f35c
--- /dev/null
+++ b/mcs/class/System.Runtime.Remoting/Test/CrossDomainCalls.cs
@@ -0,0 +1,153 @@
+//
+// MonoTests.System.Runtime.Remoting.CrossDomainCalls.cs
+//
+// Author: Lluis Sanchez Gual (lluis@ximian.com)
+//
+// 2003 (C) Copyright, Novell, Inc.
+//
+
+using System;
+using System.Threading;
+using System.Runtime.Remoting;
+using System.Runtime.Remoting.Channels;
+using System.Runtime.Remoting.Channels.Tcp;
+using NUnit.Framework;
+
+namespace MonoTests.System.Runtime.Remoting
+{
+ class CrossDomainServer: MarshalByRefObject
+ {
+ public RemoteObject CreateRemoteInstance ()
+ {
+ return new RemoteObject();
+ }
+
+ public AbstractRemoteObject CreateRemoteAbstract ()
+ {
+ return new RemoteObject();
+ }
+
+ public IRemoteObject CreateRemoteInterface ()
+ {
+ return new RemoteObject();
+ }
+
+ public int GetDomId ()
+ {
+ return Thread.GetDomainID();
+ }
+ }
+
+ [TestFixture]
+ public class CrossDomainSyncCallTest : SyncCallTest
+ {
+ CrossDomainServer server;
+
+ protected override int CreateServer ()
+ {
+ AppDomain domain = AppDomain.CreateDomain ("testdomain");
+ server = (CrossDomainServer) domain.CreateInstanceAndUnwrap(GetType().Assembly.FullName,"MonoTests.System.Runtime.Remoting.CrossDomainServer");
+ return server.GetDomId ();
+ }
+
+ protected override RemoteObject CreateRemoteInstance ()
+ {
+ return server.CreateRemoteInstance ();
+ }
+
+ protected override AbstractRemoteObject CreateRemoteAbstract ()
+ {
+ return server.CreateRemoteAbstract ();
+ }
+
+ protected override IRemoteObject CreateRemoteInterface ()
+ {
+ return server.CreateRemoteInterface ();
+ }
+ }
+
+ [TestFixture]
+ public class CrossDomainAsyncCallTest : AsyncCallTest
+ {
+ CrossDomainServer server;
+
+ protected override int CreateServer ()
+ {
+ AppDomain domain = AppDomain.CreateDomain ("testdomain");
+ server = (CrossDomainServer) domain.CreateInstanceAndUnwrap(GetType().Assembly.FullName,"MonoTests.System.Runtime.Remoting.CrossDomainServer");
+ return server.GetDomId ();
+ }
+
+ protected override RemoteObject CreateRemoteInstance ()
+ {
+ return server.CreateRemoteInstance ();
+ }
+
+ protected override AbstractRemoteObject CreateRemoteAbstract ()
+ {
+ return server.CreateRemoteAbstract ();
+ }
+
+ protected override IRemoteObject CreateRemoteInterface ()
+ {
+ return server.CreateRemoteInterface ();
+ }
+ }
+
+ [TestFixture]
+ public class CrossDomainReflectionCallTest : ReflectionCallTest
+ {
+ CrossDomainServer server;
+
+ protected override int CreateServer ()
+ {
+ AppDomain domain = AppDomain.CreateDomain ("testdomain");
+ server = (CrossDomainServer) domain.CreateInstanceAndUnwrap(GetType().Assembly.FullName,"MonoTests.System.Runtime.Remoting.CrossDomainServer");
+ return server.GetDomId ();
+ }
+
+ protected override RemoteObject CreateRemoteInstance ()
+ {
+ return server.CreateRemoteInstance ();
+ }
+
+ protected override AbstractRemoteObject CreateRemoteAbstract ()
+ {
+ return server.CreateRemoteAbstract ();
+ }
+
+ protected override IRemoteObject CreateRemoteInterface ()
+ {
+ return server.CreateRemoteInterface ();
+ }
+ }
+
+ [TestFixture]
+ public class CrossDomainDelegateCallTest : DelegateCallTest
+ {
+ CrossDomainServer server;
+
+ protected override int CreateServer ()
+ {
+ AppDomain domain = AppDomain.CreateDomain ("testdomain");
+ server = (CrossDomainServer) domain.CreateInstanceAndUnwrap(GetType().Assembly.FullName,"MonoTests.System.Runtime.Remoting.CrossDomainServer");
+ return server.GetDomId ();
+ }
+
+ protected override RemoteObject CreateRemoteInstance ()
+ {
+ return server.CreateRemoteInstance ();
+ }
+
+ protected override AbstractRemoteObject CreateRemoteAbstract ()
+ {
+ return server.CreateRemoteAbstract ();
+ }
+
+ protected override IRemoteObject CreateRemoteInterface ()
+ {
+ return server.CreateRemoteInterface ();
+ }
+ }
+}
+
diff --git a/mcs/class/System.Runtime.Serialization.Formatters.Soap/ChangeLog b/mcs/class/System.Runtime.Serialization.Formatters.Soap/ChangeLog
index 99930f6d60b..6d071bdc765 100644
--- a/mcs/class/System.Runtime.Serialization.Formatters.Soap/ChangeLog
+++ b/mcs/class/System.Runtime.Serialization.Formatters.Soap/ChangeLog
@@ -1,3 +1,9 @@
+2003-11-21 Jean-Marc Andre <jeanmarc.andre@cpe.fr>
+ * SoapReader.cs:
+ Bug fixed. SerializationBinder.BindToType wasn't called
+ the right way in GetElementInfo() (switched assemblyName and
+ typeName parameters).
+
2003-08-25 Lluis Sanchez Gual <lluis@ximian.com>
* SoapTypeMapper.cs: Added mappings for more primitive types.
diff --git a/mcs/class/System.Runtime.Serialization.Formatters.Soap/System.Runtime.Serialization.Formatters.Soap/ChangeLog b/mcs/class/System.Runtime.Serialization.Formatters.Soap/System.Runtime.Serialization.Formatters.Soap/ChangeLog
index 2b92835cd3e..588ede240f7 100644
--- a/mcs/class/System.Runtime.Serialization.Formatters.Soap/System.Runtime.Serialization.Formatters.Soap/ChangeLog
+++ b/mcs/class/System.Runtime.Serialization.Formatters.Soap/System.Runtime.Serialization.Formatters.Soap/ChangeLog
@@ -1,3 +1,16 @@
+2003-11-21 Lluis Sanchez Gual <lluis@ximian.com>
+
+ * SoapFormatter.cs: Added FilterLevel property.
+
+2003-11-16 Lluis Sanchez Gual <lluis@ximian.com>
+
+ * SoapFormatter.cs: Added AssemblyFormat property.
+
+2003-11-13 Lluis Sanchez Gual <lluis@ximian.com>
+
+ * ObjectWriter.cs: Added FIXME
+ * SoapParser.cs: Added null reference check.
+
2002-08-15 Tim Coleman <tim@timcoleman.com>
* SoapFormatter.cs:
That should be IRemotingFormatter, not IRemoteFormatter.
diff --git a/mcs/class/System.Runtime.Serialization.Formatters.Soap/System.Runtime.Serialization.Formatters.Soap/ObjectWriter.cs b/mcs/class/System.Runtime.Serialization.Formatters.Soap/System.Runtime.Serialization.Formatters.Soap/ObjectWriter.cs
index 2183a31a1bb..5e9adeb1acb 100644
--- a/mcs/class/System.Runtime.Serialization.Formatters.Soap/System.Runtime.Serialization.Formatters.Soap/ObjectWriter.cs
+++ b/mcs/class/System.Runtime.Serialization.Formatters.Soap/System.Runtime.Serialization.Formatters.Soap/ObjectWriter.cs
@@ -72,6 +72,9 @@ namespace System.Runtime.Serialization.Formatters.Soap {
}
Type objType = Type.GetType(_serializationInfo.FullTypeName);
+ // FIXME: we should store the type name returned by FullTypeName, no need to
+ // get the type again!! (Lluis)
+
//if objType == null
// try to load the proper assembly
if(objType == null) objType = FormatterServices.GetTypeFromAssembly(currentType.Assembly, _serializationInfo.FullTypeName);
diff --git a/mcs/class/System.Runtime.Serialization.Formatters.Soap/System.Runtime.Serialization.Formatters.Soap/SoapFormatter.cs b/mcs/class/System.Runtime.Serialization.Formatters.Soap/System.Runtime.Serialization.Formatters.Soap/SoapFormatter.cs
index 355a7a33877..99043516fe2 100755
--- a/mcs/class/System.Runtime.Serialization.Formatters.Soap/System.Runtime.Serialization.Formatters.Soap/SoapFormatter.cs
+++ b/mcs/class/System.Runtime.Serialization.Formatters.Soap/System.Runtime.Serialization.Formatters.Soap/SoapFormatter.cs
@@ -26,8 +26,13 @@ namespace System.Runtime.Serialization.Formatters.Soap {
private SerializationBinder _binder;
private StreamingContext _context;
private ISurrogateSelector _selector;
+ private FormatterAssemblyStyle _assemblyFormat = FormatterAssemblyStyle.Full;
private ISoapMessage _topObject;
+#if NET_1_1
+ TypeFilterLevel _filterLevel = TypeFilterLevel.Low;
+#endif
+
public SoapFormatter() {
}
@@ -112,5 +117,29 @@ namespace System.Runtime.Serialization.Formatters.Soap {
_topObject = value;
}
}
+
+#if NET_1_1
+ [MonoTODO ("Interpret this")]
+ public TypeFilterLevel FilterLevel {
+ get {
+ return _filterLevel;
+ }
+ set {
+ _filterLevel = value;
+ }
+ }
+#endif
+
+ [MonoTODO ("Interpret this")]
+ public FormatterAssemblyStyle AssemblyFormat
+ {
+ get {
+ return _assemblyFormat;
+ }
+ set {
+ _assemblyFormat = value;
+ }
+ }
+
}
}
diff --git a/mcs/class/System.Runtime.Serialization.Formatters.Soap/System.Runtime.Serialization.Formatters.Soap/SoapParser.cs b/mcs/class/System.Runtime.Serialization.Formatters.Soap/System.Runtime.Serialization.Formatters.Soap/SoapParser.cs
index 38f3d08c69e..3da5954a82f 100644
--- a/mcs/class/System.Runtime.Serialization.Formatters.Soap/System.Runtime.Serialization.Formatters.Soap/SoapParser.cs
+++ b/mcs/class/System.Runtime.Serialization.Formatters.Soap/System.Runtime.Serialization.Formatters.Soap/SoapParser.cs
@@ -73,6 +73,7 @@ namespace System.Runtime.Serialization.Formatters.Soap {
if(_xmlReader.Depth == 0 || _xmlReader.Name == "SOAP-ENV:Envelope") return;
break;
case XmlNodeType.Text:
+ if (entry == null) throw new SerializationException ("Invalid SOAP message");
entry.elementValue = _xmlReader.Value;
break;
case XmlNodeType.Attribute:
diff --git a/mcs/class/System.Runtime.Serialization.Formatters.Soap/System.Runtime.Serialization.Formatters.Soap/SoapReader.cs b/mcs/class/System.Runtime.Serialization.Formatters.Soap/System.Runtime.Serialization.Formatters.Soap/SoapReader.cs
index 27caa0c771e..6e31cf6dcb7 100755
--- a/mcs/class/System.Runtime.Serialization.Formatters.Soap/System.Runtime.Serialization.Formatters.Soap/SoapReader.cs
+++ b/mcs/class/System.Runtime.Serialization.Formatters.Soap/System.Runtime.Serialization.Formatters.Soap/SoapReader.cs
@@ -105,7 +105,7 @@ namespace System.Runtime.Serialization.Formatters.Soap {
Type elementType = SoapTypeMapper.GetType(mapping);
if(elementType != null && _binder != null) {
- elementType = _binder.BindToType(elementType.Name, elementType.Assembly.FullName);
+ elementType = _binder.BindToType(elementType.Assembly.FullName, elementType.Name);
if(elementType == null) throw new SerializationException();
}
diff --git a/mcs/class/System.Web.Services/System.Web.Services.Description/ChangeLog b/mcs/class/System.Web.Services/System.Web.Services.Description/ChangeLog
index 704d3aee7ba..be703fcc360 100644
--- a/mcs/class/System.Web.Services/System.Web.Services.Description/ChangeLog
+++ b/mcs/class/System.Web.Services/System.Web.Services.Description/ChangeLog
@@ -1,3 +1,8 @@
+2003-11-11 Lluis Sanchez Gual <lluis@ximian.com>
+
+ * ServiceDescription.cs, SoapBinding.cs, SoapHeaderBinding.cs,
+ SoapHeaderFaultBinding.cs: Removed some TODOs and FIXMEs.
+
2003-10-20 Lluis Sanchez Gual <lluis@ximian.com>
* ServiceDescription.cs: Fixed implementation of CanRead.
diff --git a/mcs/class/System.Web.Services/System.Web.Services.Description/ServiceDescription.cs b/mcs/class/System.Web.Services/System.Web.Services.Description/ServiceDescription.cs
index d9368d6e2a8..6330987a6ad 100644
--- a/mcs/class/System.Web.Services/System.Web.Services.Description/ServiceDescription.cs
+++ b/mcs/class/System.Web.Services/System.Web.Services.Description/ServiceDescription.cs
@@ -48,7 +48,6 @@ namespace System.Web.Services.Description {
serializer = new ServiceDescriptionSerializer ();
}
- [MonoTODO ("Move namespaces to subtype, use ServiceDescriptionSerializer")]
public ServiceDescription ()
{
bindings = new BindingCollection (this);
diff --git a/mcs/class/System.Web.Services/System.Web.Services.Description/SoapBinding.cs b/mcs/class/System.Web.Services/System.Web.Services.Description/SoapBinding.cs
index 762ce5905df..1f80605bebf 100644
--- a/mcs/class/System.Web.Services/System.Web.Services.Description/SoapBinding.cs
+++ b/mcs/class/System.Web.Services/System.Web.Services.Description/SoapBinding.cs
@@ -14,8 +14,6 @@ using System.Xml.Serialization;
namespace System.Web.Services.Description {
[XmlFormatExtensionPrefix ("soap", "http://schemas.xmlsoap.org/wsdl/soap/")]
[XmlFormatExtension ("binding", "http://schemas.xmlsoap.org/wsdl/soap/", typeof (Binding))]
- // FIXME: this won't compile!
- // [XmlFormatExtensionPrefix ("soapenc", "http://schemas.xmlsoap.org/soap/encoding/")]
public sealed class SoapBinding : ServiceDescriptionFormatExtension {
#region Fields
diff --git a/mcs/class/System.Web.Services/System.Web.Services.Description/SoapHeaderBinding.cs b/mcs/class/System.Web.Services/System.Web.Services.Description/SoapHeaderBinding.cs
index 74bfd6c90eb..13904e4276c 100644
--- a/mcs/class/System.Web.Services/System.Web.Services.Description/SoapHeaderBinding.cs
+++ b/mcs/class/System.Web.Services/System.Web.Services.Description/SoapHeaderBinding.cs
@@ -30,11 +30,10 @@ namespace System.Web.Services.Description {
#region Constructors
- [MonoTODO]
public SoapHeaderBinding ()
{
encoding = String.Empty;
- mapToProperty = false; // FIXME: is this right?
+ mapToProperty = false;
message = XmlQualifiedName.Empty;
ns = String.Empty;
part = String.Empty;
@@ -86,4 +85,4 @@ namespace System.Web.Services.Description {
#endregion // Properties
}
-}
+}
diff --git a/mcs/class/System.Web.Services/System.Web.Services.Description/SoapHeaderFaultBinding.cs b/mcs/class/System.Web.Services/System.Web.Services.Description/SoapHeaderFaultBinding.cs
index e33bcc685c0..5f1d384ce02 100644
--- a/mcs/class/System.Web.Services/System.Web.Services.Description/SoapHeaderFaultBinding.cs
+++ b/mcs/class/System.Web.Services/System.Web.Services.Description/SoapHeaderFaultBinding.cs
@@ -19,7 +19,6 @@ namespace System.Web.Services.Description {
#region Fields
string encoding;
- bool mapToProperty;
XmlQualifiedName message;
string ns;
string part;
@@ -33,7 +32,6 @@ namespace System.Web.Services.Description {
public SoapHeaderFaultBinding ()
{
encoding = String.Empty;
- mapToProperty = false; // FIXME: is this right?
message = XmlQualifiedName.Empty;
ns = String.Empty;
part = String.Empty;
@@ -79,4 +77,4 @@ namespace System.Web.Services.Description {
#endregion // Properties
}
-}
+}
diff --git a/mcs/class/System.Web.Services/System.Web.Services.Discovery/ChangeLog b/mcs/class/System.Web.Services/System.Web.Services.Discovery/ChangeLog
index 7504801c3fa..8ebdda50153 100755
--- a/mcs/class/System.Web.Services/System.Web.Services.Discovery/ChangeLog
+++ b/mcs/class/System.Web.Services/System.Web.Services.Discovery/ChangeLog
@@ -1,3 +1,7 @@
+2003-11-11 Lluis Sanchez Gual <lluis@ximian.com>
+
+ * DiscoveryDocumentSerializer.cs: The class must be internal.
+
2003-10-21 Lluis Sanchez Gual <lluis@ximian.com>
* DiscoveryClientProtocol.cs: Fixed little bug in DiscoverAny.
diff --git a/mcs/class/System.Web.Services/System.Web.Services.Discovery/DiscoveryDocumentSerializer.cs b/mcs/class/System.Web.Services/System.Web.Services.Discovery/DiscoveryDocumentSerializer.cs
index 8d49b09b80a..f38f1b536ab 100644
--- a/mcs/class/System.Web.Services/System.Web.Services.Discovery/DiscoveryDocumentSerializer.cs
+++ b/mcs/class/System.Web.Services/System.Web.Services.Discovery/DiscoveryDocumentSerializer.cs
@@ -16,7 +16,7 @@ using System.Globalization;
namespace System.Web.Services.Discovery
{
- public class DiscoveryDocumentReader : XmlSerializationReader
+ internal class DiscoveryDocumentReader : XmlSerializationReader
{
public System.Web.Services.Discovery.DiscoveryDocument ReadTree ()
{
@@ -292,7 +292,7 @@ namespace System.Web.Services.Discovery
}
- public class DiscoveryDocumentWriter : XmlSerializationWriter
+ internal class DiscoveryDocumentWriter : XmlSerializationWriter
{
public void WriteTree (System.Web.Services.Discovery.DiscoveryDocument ob)
{
diff --git a/mcs/class/System.Web.Services/System.Web.Services.Protocols/ChangeLog b/mcs/class/System.Web.Services/System.Web.Services.Protocols/ChangeLog
index a4cb0fa8098..37518fa8f95 100644
--- a/mcs/class/System.Web.Services/System.Web.Services.Protocols/ChangeLog
+++ b/mcs/class/System.Web.Services/System.Web.Services.Protocols/ChangeLog
@@ -1,3 +1,38 @@
+2003-11-27 Lluis Sanchez Gual <lluis@ximian.com>
+
+ * Methods.cs: Added correct namespace for serialization in Fault class.
+ * SoapHttpClientProtocol.cs: Changed the method used to check if the
+ result is a fault. Now the check is done inside
+ WebServiceHelper.ReadSoapMessage. Removed some debug writelines.
+ * WebServiceHelper.cs: If the message body is a fault, use the fault
+ serializer.
+
+2003-11-24 Lluis Sanchez Gual <lluis@ximian.com>
+
+ * Methods.cs, TypeStubManager.cs, SoapMessage.cs: Removed TODO comment.
+ * SoapDocumentationHandler.cs: Check that the documentation page exist.
+ * SoapHttpClientProtocol.cs: Removed cast from WebResponse to
+ HttpWebResponse. This fixes bug #51281.
+
+2003-11-20 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * HttpSoapWebServiceHandler.cs: WebException is ok here for wrong
+ content encoding...
+ * SoapHttpClientProtocol.cs: ... but here, we should throw an
+ InvalidOperationException including the full response.
+
+ * WebServiceHelper.cs:
+ (GetContentEncoding): now fills an output variable with the name of the
+ content encoding used.
+ (InvalidOperation): new method to build the message for
+ InvalidOperationException.
+
+2003-11-20 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * SoapHttpClientProtocol.cs:
+ * WebServiceHelper.cs: throw a WebException instead of an Exception.
+ Fixes bug #51193.
+
2003-10-26 Miguel de Icaza <miguel@ximian.com>
* WebServiceHelper.cs: Compute content type and encoding
diff --git a/mcs/class/System.Web.Services/System.Web.Services.Protocols/HttpSoapWebServiceHandler.cs b/mcs/class/System.Web.Services/System.Web.Services.Protocols/HttpSoapWebServiceHandler.cs
index f9ae93a44b9..718794d9ce2 100755
--- a/mcs/class/System.Web.Services/System.Web.Services.Protocols/HttpSoapWebServiceHandler.cs
+++ b/mcs/class/System.Web.Services/System.Web.Services.Protocols/HttpSoapWebServiceHandler.cs
@@ -8,6 +8,7 @@
//
using System;
+using System.Net;
using System.Web;
using System.Xml;
using System.Text;
@@ -60,7 +61,11 @@ namespace System.Web.Services.Protocols
{
string soapAction = null;
SoapMethodStubInfo methodInfo = null;
- Encoding encoding = WebServiceHelper.GetContentEncoding (request.ContentType);
+ string ctype;
+ Encoding encoding = WebServiceHelper.GetContentEncoding (request.ContentType, out ctype);
+ if (ctype != "text/xml")
+ throw new WebException ("Content is not XML: " + ctype);
+
object server = CreateServerInstance ();
SoapServerMessage message = new SoapServerMessage (request, server, stream);
diff --git a/mcs/class/System.Web.Services/System.Web.Services.Protocols/Methods.cs b/mcs/class/System.Web.Services/System.Web.Services.Protocols/Methods.cs
index 01ddafb82ef..d3987f4ae7f 100644
--- a/mcs/class/System.Web.Services/System.Web.Services.Protocols/Methods.cs
+++ b/mcs/class/System.Web.Services/System.Web.Services.Protocols/Methods.cs
@@ -7,9 +7,6 @@
//
// (C) 2003 Ximian, Inc.
//
-// TODO:
-//
-//
using System.Reflection;
using System.Collections;
@@ -278,6 +275,8 @@ namespace System.Web.Services.Protocols {
// FIXME: this class should be internal, but it needs to be public in
// order to be serialized using XmlSerializer.
+ [SoapType (Namespace="http://schemas.xmlsoap.org/soap/envelope/")]
+ [XmlType (Namespace="http://schemas.xmlsoap.org/soap/envelope/")]
public class Fault
{
public Fault () {}
diff --git a/mcs/class/System.Web.Services/System.Web.Services.Protocols/SoapDocumentationHandler.cs b/mcs/class/System.Web.Services/System.Web.Services.Protocols/SoapDocumentationHandler.cs
index 38fc86257fd..368adb80197 100644
--- a/mcs/class/System.Web.Services/System.Web.Services.Protocols/SoapDocumentationHandler.cs
+++ b/mcs/class/System.Web.Services/System.Web.Services.Protocols/SoapDocumentationHandler.cs
@@ -62,6 +62,10 @@ namespace System.Web.Services.Protocols
vpath += "/" + help;
string physPath = Path.Combine (path, help);
+
+ if (!File.Exists (physPath))
+ throw new InvalidOperationException ("Documentation page '" + physPath + "' not found");
+
_pageHandler = PageParser.GetCompiledPageInstance (vpath, physPath, context);
}
diff --git a/mcs/class/System.Web.Services/System.Web.Services.Protocols/SoapHttpClientProtocol.cs b/mcs/class/System.Web.Services/System.Web.Services.Protocols/SoapHttpClientProtocol.cs
index 9f5e814b77d..f0b21fb16b7 100644
--- a/mcs/class/System.Web.Services/System.Web.Services.Protocols/SoapHttpClientProtocol.cs
+++ b/mcs/class/System.Web.Services/System.Web.Services.Protocols/SoapHttpClientProtocol.cs
@@ -91,7 +91,6 @@ namespace System.Web.Services.Protocols {
}
catch (Exception ex)
{
- Console.WriteLine ("E1:" + ex);
ainfo.SetCompleted (null, ex, true);
}
}
@@ -105,7 +104,6 @@ namespace System.Web.Services.Protocols {
response = GetWebResponse (ainfo.Request, ar);
}
catch (WebException ex) {
- Console.WriteLine ("E2:" + ex);
response = ex.Response;
HttpWebResponse http_response = response as HttpWebResponse;
if (http_response == null || http_response.StatusCode != HttpStatusCode.InternalServerError) {
@@ -207,17 +205,26 @@ namespace System.Web.Services.Protocols {
//
object [] ReceiveResponse (WebResponse response, SoapClientMessage message, SoapExtension[] extensions)
{
- HttpWebResponse http_response = (HttpWebResponse) response;
- HttpStatusCode code = http_response.StatusCode;
SoapMethodStubInfo msi = message.MethodStubInfo;
-
- if (!(code == HttpStatusCode.Accepted || code == HttpStatusCode.OK || code == HttpStatusCode.InternalServerError))
- throw new Exception ("Return code was: " + http_response.StatusCode);
-
+ HttpWebResponse http_response = response as HttpWebResponse;
+
+ if (http_response != null)
+ {
+ HttpStatusCode code = http_response.StatusCode;
+
+ if (!(code == HttpStatusCode.Accepted || code == HttpStatusCode.OK || code == HttpStatusCode.InternalServerError))
+ throw new WebException ("Request error. Return code was: " + http_response.StatusCode);
+ }
+
//
// Remove optional encoding
//
- Encoding encoding = WebServiceHelper.GetContentEncoding (response.ContentType);
+ string ctype;
+ Encoding encoding = WebServiceHelper.GetContentEncoding (response.ContentType, out ctype);
+ if (ctype != "text/xml")
+ WebServiceHelper.InvalidOperation (
+ "Content is not 'text/xml' but '" + response.ContentType + "'",
+ response, encoding);
Stream stream = response.GetResponseStream ();
@@ -232,21 +239,20 @@ namespace System.Web.Services.Protocols {
StreamReader reader = new StreamReader (stream, encoding, false);
XmlTextReader xml_reader = new XmlTextReader (reader);
- bool isSuccessful = (code != HttpStatusCode.InternalServerError);
SoapHeaderCollection headers;
object content;
- if (isSuccessful) {
- WebServiceHelper.ReadSoapMessage (xml_reader, type_info, msi.Use, msi.ResponseSerializer, out content, out headers);
- message.OutParameters = (object[]) content;
- }
- else {
- WebServiceHelper.ReadSoapMessage (xml_reader, type_info, msi.Use, type_info.GetFaultSerializer (msi.Use), out content, out headers);
+ WebServiceHelper.ReadSoapMessage (xml_reader, type_info, msi.Use, msi.ResponseSerializer, out content, out headers);
+
+ if (content is Fault)
+ {
Fault fault = (Fault) content;
SoapException ex = new SoapException (fault.faultstring, fault.faultcode, fault.faultactor, fault.detail);
message.SetException (ex);
}
-
+ else
+ message.OutParameters = (object[]) content;
+
message.SetHeaders (headers);
message.UpdateHeaderValues (this, message.MethodStubInfo.Headers);
@@ -255,7 +261,7 @@ namespace System.Web.Services.Protocols {
SoapExtension.ExecuteProcessMessage (extensions, message, false);
}
- if (isSuccessful)
+ if (message.Exception == null)
return message.OutParameters;
else
throw message.Exception;
diff --git a/mcs/class/System.Web.Services/System.Web.Services.Protocols/SoapMessage.cs b/mcs/class/System.Web.Services/System.Web.Services.Protocols/SoapMessage.cs
index 499eba92aab..ac8f8195086 100644
--- a/mcs/class/System.Web.Services/System.Web.Services.Protocols/SoapMessage.cs
+++ b/mcs/class/System.Web.Services/System.Web.Services.Protocols/SoapMessage.cs
@@ -7,9 +7,6 @@
//
// Copyright (C) Tim Coleman, 2002
//
-// TODO:
-// Need to set the stream variable from the outside, or the constructor.
-//
using System.IO;
using System.Web.Services;
diff --git a/mcs/class/System.Web.Services/System.Web.Services.Protocols/TypeStubManager.cs b/mcs/class/System.Web.Services/System.Web.Services.Protocols/TypeStubManager.cs
index eb17a2bf66f..269238cadfb 100644
--- a/mcs/class/System.Web.Services/System.Web.Services.Protocols/TypeStubManager.cs
+++ b/mcs/class/System.Web.Services/System.Web.Services.Protocols/TypeStubManager.cs
@@ -7,9 +7,6 @@
//
// (C) 2003 Ximian, Inc.
//
-// TODO:
-//
-//
using System.Reflection;
using System.Collections;
diff --git a/mcs/class/System.Web.Services/System.Web.Services.Protocols/WebServiceHelper.cs b/mcs/class/System.Web.Services/System.Web.Services.Protocols/WebServiceHelper.cs
index ef1ba76034f..e3be12fe97b 100755
--- a/mcs/class/System.Web.Services/System.Web.Services.Protocols/WebServiceHelper.cs
+++ b/mcs/class/System.Web.Services/System.Web.Services.Protocols/WebServiceHelper.cs
@@ -8,6 +8,8 @@
//
using System;
+using System.IO;
+using System.Net;
using System.Text;
using System.Xml;
using System.Xml.Schema;
@@ -19,11 +21,10 @@ namespace System.Web.Services.Protocols
internal class WebServiceHelper
{
public const string SoapEnvelopeNamespace = "http://schemas.xmlsoap.org/soap/envelope/";
-
- public static Encoding GetContentEncoding (string cts)
+
+ public static Encoding GetContentEncoding (string cts, out string content_type)
{
string encoding;
- string content_type;
encoding = "utf-8";
int start = 0;
@@ -52,9 +53,6 @@ namespace System.Web.Services.Protocols
}
}
- if (content_type != "text/xml")
- throw new Exception ("Content is not XML: " + content_type);
-
return Encoding.GetEncoding (encoding);
}
@@ -95,7 +93,10 @@ namespace System.Web.Services.Protocols
xmlReader.MoveToContent ();
xmlReader.ReadStartElement ("Body", WebServiceHelper.SoapEnvelopeNamespace);
- xmlReader.MoveToContent ();
+ xmlReader.MoveToContent ();
+
+ if (xmlReader.LocalName == "Fault" && xmlReader.NamespaceURI == SoapEnvelopeNamespace)
+ bodySerializer = typeStubInfo.GetFaultSerializer (methodUse);
body = bodySerializer.Deserialize (xmlReader);
}
@@ -128,5 +129,26 @@ namespace System.Web.Services.Protocols
}
return headers;
}
+
+ public static void InvalidOperation (string message, WebResponse response, Encoding enc)
+ {
+ if (response == null)
+ throw new InvalidOperationException (message);
+
+ if (enc == null)
+ enc = Encoding.UTF8;
+
+ StringBuilder sb = new StringBuilder ();
+ sb.Append (message);
+ sb.Append ("\r\nResponse error message:\r\n--\r\n");
+
+ try {
+ StreamReader resp = new StreamReader (response.GetResponseStream (), enc);
+ sb.Append (resp.ReadToEnd ());
+ } catch (Exception) {
+ }
+
+ throw new InvalidOperationException (sb.ToString ());
+ }
}
}
diff --git a/mcs/class/System.Web/Assembly/AssemblyInfo.cs b/mcs/class/System.Web/Assembly/AssemblyInfo.cs
index 58f1f25e15b..5cd79f7551b 100644
--- a/mcs/class/System.Web/Assembly/AssemblyInfo.cs
+++ b/mcs/class/System.Web/Assembly/AssemblyInfo.cs
@@ -40,6 +40,7 @@ using System.Web.UI;
[assembly: AssemblyInformationalVersion("0.0.0.1")]
[assembly: NeutralResourcesLanguage("en-US")]
+[assembly: AllowPartiallyTrustedCallers()]
[assembly: TagPrefix("System.Web.UI.WebControls", "asp")]
//[assembly: AssemblyDelaySign(false)]
diff --git a/mcs/class/System.Web/Assembly/ChangeLog b/mcs/class/System.Web/Assembly/ChangeLog
index c9bcfd63171..fd56c58640b 100644
--- a/mcs/class/System.Web/Assembly/ChangeLog
+++ b/mcs/class/System.Web/Assembly/ChangeLog
@@ -1,3 +1,7 @@
+2003-11-13 Andreas Nahr <ClassDevelopment@A-SoftTech.com>
+
+ * AssemblyInfo.cs: Added attribute
+
2003-08-01 Andreas Nahr <ClassDevelopment@A-SoftTech.com>
* Consts.cs: Added entry
diff --git a/mcs/class/System.Web/ChangeLog b/mcs/class/System.Web/ChangeLog
index 7b923227550..c6f7c5a6a02 100644
--- a/mcs/class/System.Web/ChangeLog
+++ b/mcs/class/System.Web/ChangeLog
@@ -1,3 +1,37 @@
+2003-11-25 Jackson Harper <jackson@ximian.com>
+
+ * System.web.dll.sources: Add AltSerialization.cs to the build
+
+2003-11-24 Jackson Harper <jackson@ximian.com>
+
+ * System.web.dll.sources: Add State server classes to build.
+
+2003-11-21 Jackson Harper <jackson@ximian.com>
+
+ * System.web.dll.sources: Add CachedVaryBy.cs to the build
+
+2003-11-21 Andreas Nahr <ClassDevelopment@A-SoftTech.com>
+
+ * System.Web.dll.sources: added XmlBuilder.cs
+
+2003-11-20 Jackson Harper <jackson@ximian.com>
+
+ * System.web.dll.sources: add OutputCacheModule.cs and
+ CachedRawResponse.cs to the build.
+
+2003-11-19 Todd Berman <tberman@gentoo.org>
+
+ * System.Web.dll.sources: Add KeyedList.cs and KeyedListEnumerator.cs
+
+2003-11-18 Todd Berman <tberman@gentoo.org>
+
+ * System.Web.dll.sources: Add ParameterCollection.cs
+
+2003-11-13 Jackson Harper <jackson@ximian.com>
+
+ * System.web.dll.sources: Add System.Web.Util.TimeUtil.cs to the
+ build
+
2003-11-06 Jackson Harper <jackson@ximian.com>
* System.web.dll.sources: Add SessionId.cs to build
diff --git a/mcs/class/System.Web/System.Web.Caching/Cache.cs b/mcs/class/System.Web/System.Web.Caching/Cache.cs
index 7340f022a90..a14829d17ba 100644
--- a/mcs/class/System.Web/System.Web.Caching/Cache.cs
+++ b/mcs/class/System.Web/System.Web.Caching/Cache.cs
@@ -176,6 +176,19 @@ namespace System.Web.Caching
CacheItemPriority enumPriority,
CacheItemRemovedCallback eventRemoveCallback)
{
+ return Add (strKey, objItem, objDependency, absolutExpiration,
+ slidingExpiration, enumPriority, eventRemoveCallback, true);
+ }
+
+ private object Add (string strKey,
+ object objItem,
+ CacheDependency objDependency,
+ DateTime absolutExpiration,
+ TimeSpan slidingExpiration,
+ CacheItemPriority enumPriority,
+ CacheItemRemovedCallback eventRemoveCallback,
+ bool pub)
+ {
if (strKey == null)
throw new ArgumentNullException ("strKey");
@@ -200,7 +213,7 @@ namespace System.Web.Caching
absolutExpiration,
slidingExpiration,
longHitRange,
- true,
+ pub,
enumPriority);
Interlocked.Increment (ref _nItems);
@@ -217,7 +230,7 @@ namespace System.Web.Caching
return objEntry.Item;
}
-
+
/// <summary>
/// Inserts an item into the Cache object with a cache key to
/// reference its location and using default values provided by
@@ -344,6 +357,23 @@ namespace System.Web.Caching
eventRemoveCallback);
}
+ internal void InsertPrivate (string strKey,
+ object objItem,
+ CacheDependency objDependency,
+ DateTime absolutExpiration,
+ TimeSpan slidingExpiration,
+ CacheItemPriority enumPriority,
+ CacheItemRemovedCallback eventRemoveCallback)
+ {
+ Add (strKey,
+ objItem,
+ objDependency,
+ absolutExpiration,
+ slidingExpiration,
+ enumPriority,
+ eventRemoveCallback, false);
+ }
+
/// <summary>
/// Removes the specified item from the Cache object.
/// </summary>
diff --git a/mcs/class/System.Web/System.Web.Caching/CachedRawResponse.cs b/mcs/class/System.Web/System.Web.Caching/CachedRawResponse.cs
new file mode 100644
index 00000000000..b46e93940ec
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.Caching/CachedRawResponse.cs
@@ -0,0 +1,79 @@
+//
+// System.Web.Caching.CachedRawResponse
+//
+// Author(s):
+// Jackson Harper (jackson@ximian.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+
+using System;
+using System.Text;
+using System.Collections;
+
+namespace System.Web.Caching {
+
+ internal class CachedRawResponse {
+
+ private HttpCachePolicy policy;
+ private Hashtable vparams;
+ private int status_code;
+ private string status_desc;
+ private int content_length;
+ private ArrayList headers;
+ private byte[] buffer;
+
+ internal CachedRawResponse (HttpCachePolicy policy)
+ {
+ this.policy = policy;
+ this.buffer = new byte [HttpWriter.MaxBufferSize];
+ }
+
+ internal HttpCachePolicy Policy {
+ get { return policy; }
+ set { policy = value; }
+ }
+
+ internal int StatusCode {
+ get { return status_code; }
+ set { status_code = value; }
+ }
+
+ internal string StatusDescription {
+ get { return status_desc; }
+ set { status_desc = value; }
+ }
+
+ internal int ContentLength {
+ get { return content_length; }
+ set { content_length = value; }
+ }
+
+ internal ArrayList Headers {
+ get { return headers; }
+ }
+
+ internal void SetHeaders (ArrayList headers) {
+ this.headers = headers;
+ }
+
+ internal void SetData (byte[] buffer)
+ {
+ this.buffer = buffer;
+ }
+
+
+ internal void SetResponseHeaders (HttpResponse response)
+ {
+ foreach (HttpResponseHeader hdr in headers)
+ response.AppendHeader (hdr.Name, hdr.Value);
+ }
+
+ internal byte[] GetData ()
+ {
+ return buffer;
+ }
+ }
+}
+
diff --git a/mcs/class/System.Web/System.Web.Caching/CachedVaryBy.cs b/mcs/class/System.Web/System.Web.Caching/CachedVaryBy.cs
new file mode 100644
index 00000000000..5c915e6377f
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.Caching/CachedVaryBy.cs
@@ -0,0 +1,53 @@
+//
+// System.Web.Caching.CachedVaryBy
+//
+// Author(s):
+// Jackson Harper (jackson@ximian.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+
+using System;
+using System.Text;
+
+namespace System.Web.Caching {
+
+ internal class CachedVaryBy {
+
+ private string[] prms;
+ private string[] headers;
+ private string custom;
+
+ internal CachedVaryBy (HttpCachePolicy policy)
+ {
+ prms = policy.VaryByParams.GetParamNames ();
+ }
+
+ internal string CreateKey (string file_path, HttpRequest request)
+ {
+ StringBuilder builder = new StringBuilder ();
+
+ builder.Append ("CachedRawResponse\n");
+ builder.Append (file_path);
+ builder.Append ('\n');
+ builder.Append ("METHOD:" + request.HttpMethod);
+ builder.Append ('\n');
+
+ if (prms != null) {
+ for (int i=0; i<prms.Length; i++) {
+ if (request.Params [prms [i]] == null)
+ continue;
+ builder.Append ("VP:");
+ builder.Append (prms [i]);
+ builder.Append ('=');
+ builder.Append (request.Params [prms [i]]);
+ builder.Append ('\n');
+ }
+ }
+
+ return builder.ToString ();
+ }
+ }
+}
+
diff --git a/mcs/class/System.Web/System.Web.Caching/ChangeLog b/mcs/class/System.Web/System.Web.Caching/ChangeLog
index fbd858db686..172f97b784e 100644
--- a/mcs/class/System.Web/System.Web.Caching/ChangeLog
+++ b/mcs/class/System.Web/System.Web.Caching/ChangeLog
@@ -1,3 +1,32 @@
+2003-11-21 Jackson Harper <jackson@ximian.com>
+
+ * OutputCacheModule.cs: Only cache a page if it has a 200 status
+ code. Fix tabbing.
+ * CachedVaryBy.cs: Give raw response keys a name, use the
+ httpmethod in the key, and delimit items with \n so it is easier
+ to read when debugging.
+
+2003-11-21 Jackson Harper <jackson@ximian.com>
+
+ * OutputCacheModule.cs: Store a CachedVaryBy object for each
+ cached page. Then store a CachedRawResponse for each combination
+ of varried parameters for a page.
+ * CachedRawResponse.cs: Do not need to store param values anymore
+ those are stored in the CachedVaryBy now. Get the content length
+ so we dont send back the entire buffer.
+ * CachedVaryBy.cs: New file - holds the varyby data for a page,
+ and a method to generate a key based on params. Right now this
+ only works with VaryByParams. TODO: support VaryByHeaders and
+ VaryByCustom.
+
+2003-11-20 Jackson Harper <jackson@ximian.com>
+
+ * Cache.cs: New method so non public cache items can be added.
+ * CachedRawResponse.cs: New file - A snapshot of a response that
+ is stored in the cache and can be used to create a new response.
+ * OutputCacheModule.cs: Module for inserting and retrieving
+ responses from the cache.
+
2003-04-09 Gonzalo Paniagua Javier <gonzalo@ximian.com>
* CacheDependency.cs:
diff --git a/mcs/class/System.Web/System.Web.Caching/OutputCacheModule.cs b/mcs/class/System.Web/System.Web.Caching/OutputCacheModule.cs
new file mode 100644
index 00000000000..8c392a6749f
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.Caching/OutputCacheModule.cs
@@ -0,0 +1,135 @@
+//
+// System.Web.Caching.OutputCacheModule
+//
+// Authors:
+// Jackson Harper (jackson@ximian.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System.Web;
+
+namespace System.Web.Caching {
+
+ internal sealed class OutputCacheModule : IHttpModule {
+
+ public OutputCacheModule ()
+ {
+ }
+
+ public void Dispose ()
+ {
+ }
+
+ public void Init (HttpApplication app)
+ {
+ app.AddOnResolveRequestCacheAsync (
+ new BeginEventHandler (OnBeginRequestCache),
+ new EndEventHandler (OnEndRequestCache));
+
+ app.AddOnUpdateRequestCacheAsync (
+ new BeginEventHandler (OnBeginUpdateCache),
+ new EndEventHandler (OnEndUpdateCache));
+ }
+
+ IAsyncResult OnBeginRequestCache (object o, EventArgs args, AsyncCallback cb, object data)
+ {
+ HttpApplication app = (HttpApplication) o;
+ HttpContext context = app.Context;
+
+
+ string vary_key = context.Request.FilePath;
+ CachedVaryBy varyby = context.Cache [vary_key] as CachedVaryBy;
+ string key;
+ CachedRawResponse c;
+
+ if (varyby == null)
+ goto leave;
+
+ key = varyby.CreateKey (vary_key, context.Request);
+ c = context.Cache [key] as CachedRawResponse;
+
+ if (c != null && context.Timestamp < c.Policy.Expires) {
+
+ context.Response.ClearContent ();
+ context.Response.BinaryWrite (c.GetData (), 0, c.ContentLength);
+
+ context.Response.ClearHeaders ();
+ context.Response.SetCachedHeaders (c.Headers);
+ context.Response.StatusCode = c.StatusCode;
+ context.Response.StatusDescription = c.StatusDescription;
+
+ app.CompleteRequest ();
+ } else if (c != null) {
+ context.Cache.Remove (key);
+ }
+
+ leave:
+ HttpAsyncResult result = new HttpAsyncResult (cb,this);
+ result.Complete (true, o, null);
+
+ return result;
+ }
+
+ void OnEndRequestCache (IAsyncResult result)
+ {
+ }
+
+ IAsyncResult OnBeginUpdateCache (object o, EventArgs args, AsyncCallback cb, object data)
+ {
+ HttpApplication app = (HttpApplication) o;
+ HttpContext context = app.Context;
+ HttpAsyncResult result;
+
+ if (context.Response.IsCached && context.Response.StatusCode == 200)
+ DoCacheInsert (context);
+
+ result = new HttpAsyncResult (cb, this);
+ result.Complete (true, o, null);
+ return result;
+ }
+
+ void OnEndUpdateCache (IAsyncResult result)
+ {
+ }
+
+ private void DoCacheInsert (HttpContext context)
+ {
+ string vary_key = context.Request.FilePath;
+ string key;
+ CachedVaryBy varyby = context.Cache [vary_key] as CachedVaryBy;
+ CachedRawResponse prev = null;
+ bool lookup = true;
+
+ if (varyby == null) {
+ varyby = new CachedVaryBy (context.Response.Cache);
+ context.Cache.InsertPrivate (vary_key, varyby, null,
+ Cache.NoAbsoluteExpiration, Cache.NoSlidingExpiration,
+ CacheItemPriority.Normal, null);
+ lookup = false;
+ }
+
+ key = varyby.CreateKey (vary_key, context.Request);
+
+ if (lookup)
+ prev = context.Cache [key] as CachedRawResponse;
+
+ if (IsExpired (context, prev)) {
+ CachedRawResponse c = context.Response.GetCachedResponse ();
+
+ context.Cache.InsertPrivate (key, c, null,
+ context.Response.Cache.Expires,
+ Cache.NoSlidingExpiration,
+ CacheItemPriority.Normal, null);
+ }
+ }
+
+ private bool IsExpired (HttpContext context, CachedRawResponse crr)
+ {
+ if (crr == null || context.Timestamp > crr.Policy.Expires)
+ return true;
+ return false;
+ }
+ }
+}
+
diff --git a/mcs/class/System.Web/System.Web.Compilation/ChangeLog b/mcs/class/System.Web/System.Web.Compilation/ChangeLog
index 1798b0f0bff..3b967405564 100644
--- a/mcs/class/System.Web/System.Web.Compilation/ChangeLog
+++ b/mcs/class/System.Web/System.Web.Compilation/ChangeLog
@@ -1,3 +1,16 @@
+2003-11-20 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * TemplateControlCompiler.cs: support for expressions of
+ System.Drawing.Size type. Allow getting Color from comma separated
+ numbers, which is not allowed by ColorConverter.
+
+ This makes http://www.codeproject.com/aspnet/asppopup.asp work.
+
+2003-11-13 Jackson Harper <jackson@ximian.com>
+
+ * PageCompiler.cs: Call InitOutputCache when the OutputCache
+ directive is set.
+
2003-11-05 Gonzalo Paniagua Javier <gonzalo@ximian.com>
* AspGenerator.cs: use fileEncoding from configuration files.
diff --git a/mcs/class/System.Web/System.Web.Compilation/PageCompiler.cs b/mcs/class/System.Web/System.Web.Compilation/PageCompiler.cs
index 8e92ab5b1df..66ac137d4f6 100644
--- a/mcs/class/System.Web/System.Web.Compilation/PageCompiler.cs
+++ b/mcs/class/System.Web/System.Web.Compilation/PageCompiler.cs
@@ -71,10 +71,30 @@ namespace System.Web.Compilation
string contentType = pageParser.ContentType;
if (contentType != null)
method.Statements.Add (CreatePropertyAssign ("ContentType", contentType));
+
+ if (pageParser.OutputCache) {
+ CodeMethodReferenceExpression init = new CodeMethodReferenceExpression (null,
+ "InitOutputCache");
+ CodeMethodInvokeExpression invoke = new CodeMethodInvokeExpression (init,
+ OutputCacheParams ());
+ method.Statements.Add (invoke);
+ }
base.AddStatementsToFrameworkInitialize (method);
}
+ private CodeExpression[] OutputCacheParams ()
+ {
+ return new CodeExpression [] {
+ new CodePrimitiveExpression (pageParser.OutputCacheDuration),
+ new CodePrimitiveExpression (pageParser.OutputCacheVaryByHeader),
+ new CodePrimitiveExpression (pageParser.OutputCacheVaryByCustom),
+ new CodeSnippetExpression (typeof (OutputCacheLocation).ToString () +
+ "." + pageParser.OutputCacheLocation.ToString ()),
+ new CodePrimitiveExpression (pageParser.OutputCacheVaryByParam)
+ };
+ }
+
protected override void CreateMethods ()
{
base.CreateMethods ();
diff --git a/mcs/class/System.Web/System.Web.Compilation/TemplateControlCompiler.cs b/mcs/class/System.Web/System.Web.Compilation/TemplateControlCompiler.cs
index 6a548008a7a..0d48ac10f24 100644
--- a/mcs/class/System.Web/System.Web.Compilation/TemplateControlCompiler.cs
+++ b/mcs/class/System.Web/System.Web.Compilation/TemplateControlCompiler.cs
@@ -656,7 +656,6 @@ namespace System.Web.Compilation
if (builder.defaultPropertyBuilder != null) {
ControlBuilder b = builder.defaultPropertyBuilder;
CreateControlTree (b, false, true);
- Console.WriteLine ("Aqui");
AddChildCall (builder, b);
}
@@ -867,13 +866,53 @@ namespace System.Web.Compilation
return expr;
}
+ if (type == typeof (Size)) {
+ string [] subs = str.Split (',');
+ if (subs.Length != 2)
+ throw new ParseException (currentLocation,
+ String.Format ("Cannot create {0} from '{1}'", type, str));
+
+ int width = 0;
+ int height = 0;
+ try {
+ width = Int32.Parse (subs [0]);
+ height = Int32.Parse (subs [0]);
+ new Size (width, height);
+ } catch {
+ throw new ParseException (currentLocation,
+ String.Format ("Cannot create {0} from '{1}'", type, str));
+ }
+
+ CodeObjectCreateExpression expr = new CodeObjectCreateExpression ();
+ expr.CreateType = new CodeTypeReference (type);
+ expr.Parameters.Add (new CodePrimitiveExpression (width));
+ expr.Parameters.Add (new CodePrimitiveExpression (height));
+ return expr;
+ }
+
if (type == typeof (Color)){
if (colorConverter == null)
colorConverter = TypeDescriptor.GetConverter (typeof (Color));
Color c;
try {
- c = (Color) colorConverter.ConvertFromString (str);
+ if (str.IndexOf (',') == -1) {
+ c = (Color) colorConverter.ConvertFromString (str);
+ } else {
+ int [] argb = new int [4];
+ argb [0] = 255;
+
+ string [] parts = str.Split (',');
+ int length = parts.Length;
+ if (length < 3)
+ throw new Exception ();
+
+ int basei = (length == 4) ? 0 : 1;
+ for (int i = length - 1; i >= 0; i--) {
+ argb [basei + i] = (int) Byte.Parse (parts [i]);
+ }
+ c = Color.FromArgb (argb [0], argb [1], argb [2], argb [3]);
+ }
} catch (Exception e){
throw new ParseException (currentLocation,
"Color " + str + " is not a valid color.", e);
@@ -933,8 +972,8 @@ namespace System.Web.Compilation
}
return invoke;
}
-
- // FIXME: Arrays (arrays of string are implemented in old AspGenerator.cs
+
+ // FIXME: Arrays
Console.WriteLine ("Unknown type: " + type + " value: " + str);
return new CodePrimitiveExpression (str);
diff --git a/mcs/class/System.Web/System.Web.Configuration/ChangeLog b/mcs/class/System.Web/System.Web.Configuration/ChangeLog
index 073f745004c..bc8594c95e3 100644
--- a/mcs/class/System.Web/System.Web.Configuration/ChangeLog
+++ b/mcs/class/System.Web/System.Web.Configuration/ChangeLog
@@ -1,3 +1,15 @@
+2003-11-21 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * CompilationConfiguration.cs: don't throw an HttpException.
+ * HttpRuntimeConfig.cs:
+ * HttpRuntimeConfigurationHandler.cs: handle system.web/httpRuntime
+ configuration section.
+
+2003-11-10 Jackson Harper <jackson@ximian.com>
+
+ * CompilationConfigurationHandler.cs: Append .dll to shortened
+ assembly names.
+
2003-11-08 Jackson Harper <jackson@ximian.com>
* CompilationConfigurationHandler.cs: Trim extra versioning
diff --git a/mcs/class/System.Web/System.Web.Configuration/CompilationConfiguration.cs b/mcs/class/System.Web/System.Web.Configuration/CompilationConfiguration.cs
index 8ffed86fdbe..90dbcb56606 100644
--- a/mcs/class/System.Web/System.Web.Configuration/CompilationConfiguration.cs
+++ b/mcs/class/System.Web/System.Web.Configuration/CompilationConfiguration.cs
@@ -60,7 +60,7 @@ namespace System.Web.Configuration
config = context.GetConfig ("system.web/compilation") as CompilationConfiguration;
if (config == null)
- throw new HttpException ("Configuration error.", 500);
+ throw new Exception ("Configuration error.");
return config;
}
diff --git a/mcs/class/System.Web/System.Web.Configuration/CompilationConfigurationHandler.cs b/mcs/class/System.Web/System.Web.Configuration/CompilationConfigurationHandler.cs
index e070c7a2ded..05d5157e93e 100644
--- a/mcs/class/System.Web/System.Web.Configuration/CompilationConfigurationHandler.cs
+++ b/mcs/class/System.Web/System.Web.Configuration/CompilationConfigurationHandler.cs
@@ -102,9 +102,9 @@ namespace System.Web.Configuration
continue;
}
- aname = aname + ".dll";
+ aname = ShortAsmName (aname);
if (!assemblies.Contains (aname))
- assemblies.Add (ShortAsmName (aname));
+ assemblies.Add (aname);
continue;
}
@@ -114,8 +114,8 @@ namespace System.Web.Configuration
config.AssembliesInBin = false;
continue;
}
- aname = aname + ".dll";
- assemblies.Remove (ShortAsmName (aname));
+ aname = ShortAsmName (aname);
+ assemblies.Remove (aname);
continue;
}
@@ -171,8 +171,8 @@ namespace System.Web.Configuration
{
int i = long_name.IndexOf (',');
if (i < 0)
- return long_name;
- return long_name.Substring (0, i);
+ return long_name + ".dll";
+ return long_name.Substring (0, i) + ".dll";
}
static void ThrowException (string message, XmlNode node)
diff --git a/mcs/class/System.Web/System.Web.Configuration/HttpRuntimeConfig.cs b/mcs/class/System.Web/System.Web.Configuration/HttpRuntimeConfig.cs
new file mode 100644
index 00000000000..75ffb9bb525
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.Configuration/HttpRuntimeConfig.cs
@@ -0,0 +1,75 @@
+//
+// System.Web.Configuration.HttpRuntimeConfig
+//
+// Authors:
+// Gonzalo Paniagua Javier (gonzalo@ximian.com)
+//
+// (C) 2003 Novell, Inc. (http://www.novell.com)
+//
+
+using System;
+using System.CodeDom.Compiler;
+using System.Collections;
+using System.Configuration;
+using System.IO;
+using System.Web;
+using System.Xml;
+
+namespace System.Web.Configuration
+{
+ sealed class HttpRuntimeConfig
+ {
+ public int ExecutionTimeout = 90; // seconds
+ public int MaxRequestLength = 4096; // KB
+ public int RequestLengthDiskThreshold = 256; // KB
+ public bool UseFullyQualifiedRedirectUrl = false;
+ public int MinFreeThreads = 8;
+ public int MinLocalRequestFreeThreads = 4;
+ public int AppRequestQueueLimit = 100;
+ public bool EnableKernelOutputCache = true;
+ public bool EnableVersionHeader = true;
+ public bool RequireRootSaveAsPath = true;
+ public int IdleTimeout = 20; // minutes
+ public bool Enable = true;
+ public string VersionHeader;
+
+ /* Only the config. handler should create instances of this. Use GetInstance (context) */
+ public HttpRuntimeConfig (object p)
+ {
+ HttpRuntimeConfig parent = p as HttpRuntimeConfig;
+ if (parent != null)
+ Init (parent);
+ }
+
+ static public HttpRuntimeConfig GetInstance (HttpContext context)
+ {
+ HttpRuntimeConfig config;
+ if (context == null)
+ context = HttpContext.Context;
+
+ config = context.GetConfig ("system.web/httpRuntime") as HttpRuntimeConfig;
+
+ if (config == null)
+ throw new Exception ("Configuration error.");
+
+ return config;
+ }
+
+ void Init (HttpRuntimeConfig parent)
+ {
+ ExecutionTimeout = parent.ExecutionTimeout;
+ MaxRequestLength = parent.MaxRequestLength;
+ RequestLengthDiskThreshold = parent.RequestLengthDiskThreshold;
+ UseFullyQualifiedRedirectUrl = parent.UseFullyQualifiedRedirectUrl;
+ MinFreeThreads = parent.MinFreeThreads;
+ MinLocalRequestFreeThreads = parent.MinLocalRequestFreeThreads;
+ AppRequestQueueLimit = parent.AppRequestQueueLimit;
+ EnableKernelOutputCache = parent.EnableKernelOutputCache;
+ EnableVersionHeader = parent.EnableVersionHeader;
+ RequireRootSaveAsPath = parent.RequireRootSaveAsPath;
+ IdleTimeout = parent.IdleTimeout;
+ Enable = parent.Enable;
+ }
+ }
+}
+
diff --git a/mcs/class/System.Web/System.Web.Configuration/HttpRuntimeConfigurationHandler.cs b/mcs/class/System.Web/System.Web.Configuration/HttpRuntimeConfigurationHandler.cs
new file mode 100644
index 00000000000..5ca53e214df
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.Configuration/HttpRuntimeConfigurationHandler.cs
@@ -0,0 +1,87 @@
+//
+// System.Web.Configuration.HttpRuntimeConfigurationHandler
+//
+// Authors:
+// Gonzalo Paniagua Javier (gonzalo@ximian.com)
+//
+// (C) 2003 Novell, Inc. (http://www.novell.com)
+//
+
+using System;
+using System.Collections;
+using System.Configuration;
+using System.Security.Cryptography;
+using System.Xml;
+
+namespace System.Web.Configuration
+{
+ class HttpRuntimeConfigurationHandler : IConfigurationSectionHandler
+ {
+ public object Create (object parent, object context, XmlNode section)
+ {
+ if (section.HasChildNodes)
+ ThrowException ("Child nodes not allowed here", section.FirstChild);
+
+ HttpRuntimeConfig config = new HttpRuntimeConfig (parent);
+
+ config.ExecutionTimeout = AttUIntValue (section, "executionTimeout", 90);
+ config.MaxRequestLength = AttUIntValue (section, "maxRequestLength", 4096);
+ config.RequestLengthDiskThreshold = AttUIntValue (section, "requestLengthDiskThreshold", 256);
+ config.UseFullyQualifiedRedirectUrl = AttBoolValue (section, "useFullyQualifiedRedirectUrl", false);
+ config.MinFreeThreads = AttUIntValue (section, "minFresThreads", 8);
+ config.MinLocalRequestFreeThreads = AttUIntValue (section, "minLocalRequestFreeThreads", 4);
+ config.AppRequestQueueLimit = AttUIntValue (section, "appRequestQueueLimit", 100);
+ config.EnableKernelOutputCache = AttBoolValue (section, "requestLengthDiskThreshold", true);
+ config.EnableVersionHeader = AttBoolValue (section, "requestLengthDiskThreshold", true);
+ config.RequireRootSaveAsPath = AttBoolValue (section, "requestLengthDiskThreshold", true);
+ config.IdleTimeout = AttUIntValue (section, "requestLengthDiskThreshold", 20);
+ config.Enable = AttBoolValue (section, "requestLengthDiskThreshold", true);
+ config.VersionHeader = AttValue (section, "versionHeader");
+
+ return config;
+ }
+
+ //
+ static bool AttBoolValue (XmlNode node, string name, bool _default)
+ {
+ string v = AttValue (node, name);
+ if (v == null)
+ return _default;
+
+ bool result = (v == "true");
+ if (!result && v != "false")
+ ThrowException ("Invalid boolean value in " + name, node);
+
+ return result;
+ }
+
+ static int AttUIntValue (XmlNode node, string name, int _default)
+ {
+ string v = AttValue (node, name);
+ if (v == null)
+ return _default;
+
+ int result = 0;
+ try {
+ result = (int) UInt32.Parse (v);
+ } catch {
+ ThrowException ("Invalid number in " + name, node);
+ }
+
+ return result;
+ }
+
+
+ static string AttValue (XmlNode node, string name)
+ {
+ return HandlersUtil.ExtractAttributeValue (name, node, true);
+ }
+
+ static void ThrowException (string message, XmlNode node)
+ {
+ HandlersUtil.ThrowException (message, node);
+ }
+ //
+ }
+}
+
diff --git a/mcs/class/System.Web/System.Web.Mail/ChangeLog b/mcs/class/System.Web/System.Web.Mail/ChangeLog
index 87ccfd24521..4bfbd5fc2a2 100644
--- a/mcs/class/System.Web/System.Web.Mail/ChangeLog
+++ b/mcs/class/System.Web/System.Web.Mail/ChangeLog
@@ -1,3 +1,9 @@
+2003-11-20 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * MailMessageWrapper.cs: fixed typo that made all messages be sent as
+ html, even when the body is marked as text. Path by Mohammad DAMT.
+ Closes bug #51177.
+
2003-07-03 Gonzalo Paniagua Javier <gonzalo@ximian.com>
* MailAddress.cs: return null instead of exception when the address is
diff --git a/mcs/class/System.Web/System.Web.Mail/MailMessageWrapper.cs b/mcs/class/System.Web/System.Web.Mail/MailMessageWrapper.cs
index 451c49014c6..98a3e2e59a6 100644
--- a/mcs/class/System.Web/System.Web.Mail/MailMessageWrapper.cs
+++ b/mcs/class/System.Web/System.Web.Mail/MailMessageWrapper.cs
@@ -97,7 +97,7 @@ namespace System.Web.Mail {
case MailFormat.Text:
header.ContentType =
- String.Format( "text/html; charset=\"{0}\"" , message.BodyEncoding.BodyName );
+ String.Format( "text/plain; charset=\"{0}\"" , message.BodyEncoding.BodyName );
break;
default:
diff --git a/mcs/class/System.Web/System.Web.Security/ADMembershipProvider.cs b/mcs/class/System.Web/System.Web.Security/ADMembershipProvider.cs
new file mode 100644
index 00000000000..bb5f447ce57
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.Security/ADMembershipProvider.cs
@@ -0,0 +1,145 @@
+//
+// System.Web.Security.ADMembershipProvider
+//
+// Authors:
+// Ben Maurer (bmaurer@users.sourceforge.net)
+//
+// (C) 2003 Ben Maurer
+//
+
+#if NET_1_2
+using System.Collections;
+using System.Collections.Specialized;
+using System.Text;
+
+namespace System.Web.Security {
+ public class ADMembershipProvider : IMembershipProvider {
+
+ [MonoTODO]
+ public virtual bool ChangePassword (string username, string oldPwd, string newPwd)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public virtual bool ChangePasswordQuestionAndAnswer (string username, string password, string newPwdQuestion, string newPwdAnswer)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public virtual MembershipUser CreateUser (string username, string password, string email, out MembershipCreateStatus status)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public virtual bool DeleteUser (string username)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public virtual string GeneratePassword ()
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public MembershipUserCollection GetAllUsers ()
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public int GetNumberOfUsersOnline ()
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public virtual string GetPassword (string username, string answer)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public virtual MembershipUser GetUser (string username, bool userIsOnline)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public virtual string GetUserNameByEmail (string email)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public virtual void Initialize (string name, NameValueCollection config)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public virtual string ResetPassword (string username, string answer)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public virtual void UpdateUser (MembershipUser user)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public virtual bool ValidateUser (string username, string password)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public string ApplicationName {
+ get { throw new NotImplementedException (); }
+ set { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public virtual string Description {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public virtual bool EnablePasswordReset {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public virtual bool EnablePasswordRetrieval {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public virtual string Name {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public virtual MembershipPasswordFormat PasswordFormat {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public virtual bool RequiresQuestionAndAnswer {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public virtual bool RequiresUniqueEmail {
+ get { throw new NotImplementedException (); }
+ }
+ }
+}
+#endif
+
diff --git a/mcs/class/System.Web/System.Web.Security/AccessMembershipProvider.cs b/mcs/class/System.Web/System.Web.Security/AccessMembershipProvider.cs
new file mode 100644
index 00000000000..d0399829a07
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.Security/AccessMembershipProvider.cs
@@ -0,0 +1,145 @@
+//
+// System.Web.Security.AccessMembershipProvider
+//
+// Authors:
+// Ben Maurer (bmaurer@users.sourceforge.net)
+//
+// (C) 2003 Ben Maurer
+//
+
+#if NET_1_2
+using System.Collections;
+using System.Collections.Specialized;
+using System.Text;
+
+namespace System.Web.Security {
+ public class AccessMembershipProvider : IMembershipProvider {
+
+ [MonoTODO]
+ public virtual bool ChangePassword (string username, string oldPwd, string newPwd)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public virtual bool ChangePasswordQuestionAndAnswer (string username, string password, string newPwdQuestion, string newPwdAnswer)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public virtual MembershipUser CreateUser (string username, string password, string email, out MembershipCreateStatus status)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public virtual bool DeleteUser (string username)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public virtual string GeneratePassword ()
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public MembershipUserCollection GetAllUsers ()
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public int GetNumberOfUsersOnline ()
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public virtual string GetPassword (string username, string answer)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public virtual MembershipUser GetUser (string username, bool userIsOnline)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public virtual string GetUserNameByEmail (string email)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public virtual void Initialize (string name, NameValueCollection config)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public virtual string ResetPassword (string username, string answer)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public virtual void UpdateUser (MembershipUser user)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public virtual bool ValidateUser (string username, string password)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public string ApplicationName {
+ get { throw new NotImplementedException (); }
+ set { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public virtual string Description {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public virtual bool EnablePasswordReset {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public virtual bool EnablePasswordRetrieval {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public virtual string Name {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public virtual MembershipPasswordFormat PasswordFormat {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public virtual bool RequiresQuestionAndAnswer {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public virtual bool RequiresUniqueEmail {
+ get { throw new NotImplementedException (); }
+ }
+ }
+}
+#endif
+
diff --git a/mcs/class/System.Web/System.Web.Security/AccessRoleProvider.cs b/mcs/class/System.Web/System.Web.Security/AccessRoleProvider.cs
new file mode 100644
index 00000000000..3575cd88e4f
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.Security/AccessRoleProvider.cs
@@ -0,0 +1,96 @@
+//
+// System.Web.Security.AccessRoleProvider
+//
+// Authors:
+// Ben Maurer (bmaurer@users.sourceforge.net)
+//
+// (C) 2003 Ben Maurer
+//
+
+#if NET_1_2
+using System.Collections;
+using System.Collections.Specialized;
+using System.Text;
+
+namespace System.Web.Security {
+ public class AccessRoleProvider {
+
+ [MonoTODO]
+ public void AddUsersToRoles (string [] usernames, string [] rolenames)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void CreateRole (string rolename)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void DeleteRole (string rolename)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public string [] GetAllRoles ()
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public string [] GetRolesForUser (string username)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public string [] GetUsersInRole (string rolename)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public virtual void Initialize (string name, NameValueCollection config)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public bool IsUserInRole (string username, string rolename)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void RemoveUsersFromRoles (string [] usernames, string [] rolenames)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public bool RoleExists (string rolename)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public string ApplicationName {
+ get { throw new NotImplementedException (); }
+ set { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public virtual string Description {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public virtual string Name {
+ get { throw new NotImplementedException (); }
+ }
+ }
+}
+#endif
+
diff --git a/mcs/class/System.Web/System.Web.Security/AnonymousIdentificationEventArgs.cs b/mcs/class/System.Web/System.Web.Security/AnonymousIdentificationEventArgs.cs
new file mode 100644
index 00000000000..222a9e4058c
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.Security/AnonymousIdentificationEventArgs.cs
@@ -0,0 +1,31 @@
+//
+// System.Web.Security.AnonymousIdentificationEventArgs
+//
+// Authors:
+// Ben Maurer (bmaurer@users.sourceforge.net)
+//
+// (C) 2003 Ben Maurer
+//
+
+#if NET_1_2
+namespace System.Web.Security {
+ public sealed class AnonymousIdentificationEventArgs : EventArgs {
+ public AnonymousIdentificationEventArgs (HttpContext context)
+ {
+ this.context = context;
+ }
+
+ HttpContext context;
+ public HttpContext Context {
+ get { return context; }
+ }
+
+ string anonymousId;
+ public string AnonymousId {
+ get { return anonymousId; }
+ set { anonymousId = value; }
+ }
+ }
+}
+#endif
+
diff --git a/mcs/class/System.Web/System.Web.Security/AnonymousIdentificationEventHandler.cs b/mcs/class/System.Web/System.Web.Security/AnonymousIdentificationEventHandler.cs
new file mode 100644
index 00000000000..60eb7742c8c
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.Security/AnonymousIdentificationEventHandler.cs
@@ -0,0 +1,15 @@
+//
+// System.Web.Security.AnonymousIdentificationEventHandler
+//
+// Authors:
+// Ben Maurer (bmaurer@users.sourceforge.net)
+//
+// (C) 2003 Ben Maurer
+//
+
+#if NET_1_2
+namespace System.Web.Security {
+ public delegate void AnonymousIdentificationEventHandler (object sender, AnonymousIdentificationEventArgs e);
+}
+#endif
+
diff --git a/mcs/class/System.Web/System.Web.Security/AnonymousIdentificationModule.cs b/mcs/class/System.Web/System.Web.Security/AnonymousIdentificationModule.cs
new file mode 100644
index 00000000000..21a147a0edc
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.Security/AnonymousIdentificationModule.cs
@@ -0,0 +1,40 @@
+//
+// System.Web.Security.AnonymousIdentificationModule
+//
+// Authors:
+// Ben Maurer (bmaurer@users.sourceforge.net)
+//
+// (C) 2003 Ben Maurer
+//
+
+#if NET_1_2
+using System.Collections;
+using System.Collections.Specialized;
+using System.Text;
+
+namespace System.Web.Security {
+ public sealed class AnonymousIdentificationModule : IHttpModule {
+ public event AnonymousIdentificationEventHandler OnCreate;
+ public event EventHandler OnRemove;
+
+
+ [MonoTODO]
+ public void Dispose ()
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void Init (HttpApplication app)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public static bool Enabled {
+ get { throw new NotImplementedException (); }
+ }
+ }
+}
+#endif
+
diff --git a/mcs/class/System.Web/System.Web.Security/ChangeLog b/mcs/class/System.Web/System.Web.Security/ChangeLog
index 2557418eba1..babaef9f306 100644
--- a/mcs/class/System.Web/System.Web.Security/ChangeLog
+++ b/mcs/class/System.Web/System.Web.Security/ChangeLog
@@ -1,3 +1,33 @@
+2003-11-25 Ben Maurer <bmaurer@users.sourceforge.net>
+
+ * AccessMembershipProvider.cs: New v2 file
+ * AccessRoleProvider.cs: New v2 file
+ * ADMembershipProvider.cs: New v2 file
+ * AnonymousIdentificationEventArgs.cs: New v2 file
+ * AnonymousIdentificationEventHandler.cs: New v2 file
+ * AnonymousIdentificationModule.cs: New v2 file
+ * CookieProtection.cs: New v2 file
+ * IMembershipProvider.cs: New v2 file
+ * IRoleProvider.cs: New v2 file
+ * Membership.cs: New v2 file
+ * MembershipCreateStatus.cs: New v2 file
+ * MembershipCreateUserException.cs: New v2 file
+ * MembershipOnlineStatus.cs: New v2 file
+ * MembershipPasswordException.cs: New v2 file
+ * MembershipPasswordFormat.cs: New v2 file
+ * MembershipProviderCollection.cs: New v2 file
+ * MembershipSortOptions.cs: New v2 file
+ * MembershipUser.cs: New v2 file
+ * MembershipUserCollection.cs: New v2 file
+ * RoleManagerEventArgs.cs: New v2 file
+ * RoleManagerEventHandler.cs: New v2 file
+ * RoleManagerModule.cs: New v2 file
+ * RolePrincipal.cs: New v2 file
+ * RoleProviderCollection.cs: New v2 file
+ * Roles.cs: New v2 file
+ * SqlMembershipProvider.cs: New v2 file
+ * SqlRoleProvider.cs: New v2 file
+
2003-11-05 Gonzalo Paniagua Javier <gonzalo@ximian.com>
* FormsAuthentication.cs: encoding updates.
diff --git a/mcs/class/System.Web/System.Web.Security/CookieProtection.cs b/mcs/class/System.Web/System.Web.Security/CookieProtection.cs
new file mode 100644
index 00000000000..703cfc4e2f2
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.Security/CookieProtection.cs
@@ -0,0 +1,20 @@
+//
+// System.Web.Security.CookieProtection
+//
+// Authors:
+// Ben Maurer (bmaurer@users.sourceforge.net)
+//
+// (C) 2003 Ben Maurer
+//
+
+#if NET_1_2
+namespace System.Web.Security {
+ public enum CookieProtection {
+ None,
+ Validation,
+ Encryption,
+ All
+ }
+}
+#endif
+
diff --git a/mcs/class/System.Web/System.Web.Security/IMembershipProvider.cs b/mcs/class/System.Web/System.Web.Security/IMembershipProvider.cs
new file mode 100644
index 00000000000..4db3b7f7f43
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.Security/IMembershipProvider.cs
@@ -0,0 +1,34 @@
+//
+// System.Web.Security.IMembershipProvider
+//
+// Authors:
+// Ben Maurer (bmaurer@users.sourceforge.net)
+//
+// (C) 2003 Ben Maurer
+//
+
+#if NET_1_2
+using System.Configuration.Provider;
+
+namespace System.Web.Security {
+ public interface IMembershipProvider : IProvider {
+ bool ChangePassword (string name, string oldPwd, string newPwd);
+ bool ChangePasswordQuestionAndAnswer (string name, string password, string newPwdQuestion, string newPwdAnswer);
+ MembershipUser CreateUser (string username, string password, string email, out MembershipCreateStatus status);
+ bool DeleteUser (string name);
+ MembershipUserCollection GetAllUsers ();
+ int GetNumberOfUsersOnline ();
+ string GetPassword (string name, string answer);
+ MembershipUser GetUser (string name, bool userIsOnline);
+ string GetUserNameByEmail (string email);
+ string ResetPassword (string name, string answer);
+ void UpdateUser (MembershipUser user);
+ bool ValidateUser (string name, string password);
+ string ApplicationName { get; set; }
+ bool EnablePasswordReset { get; }
+ bool EnablePasswordRetrieval { get; }
+ bool RequiresQuestionAndAnswer { get; }
+ }
+}
+#endif
+
diff --git a/mcs/class/System.Web/System.Web.Security/IRoleProvider.cs b/mcs/class/System.Web/System.Web.Security/IRoleProvider.cs
new file mode 100644
index 00000000000..1fed1361e23
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.Security/IRoleProvider.cs
@@ -0,0 +1,28 @@
+//
+// System.Web.Security.IRoleProvider
+//
+// Authors:
+// Ben Maurer (bmaurer@users.sourceforge.net)
+//
+// (C) 2003 Ben Maurer
+//
+
+#if NET_1_2
+using System.Configuration.Provider;
+
+namespace System.Web.Security {
+ public interface IRoleProvider : IProvider {
+ void AddUsersToRoles (string [] usernames, string [] rolenames);
+ void CreateRole (string rolename);
+ void DeleteRole (string rolename);
+ string [] GetAllRoles ();
+ string [] GetRolesForUser (string username);
+ string [] GetUsersInRole (string rolename);
+ bool IsUserInRole (string username, string rolename);
+ void RemoveUsersFromRoles (string [] usernames, string [] rolenames);
+ bool RoleExists (string rolename);
+ string ApplicationName { get; set; }
+ }
+}
+#endif
+
diff --git a/mcs/class/System.Web/System.Web.Security/Membership.cs b/mcs/class/System.Web/System.Web.Security/Membership.cs
new file mode 100644
index 00000000000..109fb23470c
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.Security/Membership.cs
@@ -0,0 +1,128 @@
+//
+// System.Web.Security.Membership
+//
+// Authors:
+// Ben Maurer (bmaurer@users.sourceforge.net)
+//
+// (C) 2003 Ben Maurer
+//
+
+#if NET_1_2
+using System.Collections;
+using System.Collections.Specialized;
+using System.Text;
+
+namespace System.Web.Security {
+ public sealed class Membership {
+
+ public static MembershipUser CreateUser (string username, string password)
+ {
+ return CreateUser (username, password, null);
+ }
+
+ public static MembershipUser CreateUser (string username, string password, string email)
+ {
+ MembershipCreateStatus status;
+ MembershipUser usr = CreateUser (username, password, email, out status);
+ if (usr == null)
+ throw new MembershipCreateUserException (status);
+
+ return usr;
+ }
+
+ public static MembershipUser CreateUser (string username, string password, string email, out MembershipCreateStatus status)
+ {
+ return Provider.CreateUser (username, password, email, out status);
+ }
+
+ public static bool DeleteUser (string username)
+ {
+ return Provider.DeleteUser (username);
+ }
+
+ [MonoTODO]
+ public static string GeneratePassword (int length)
+ {
+ throw new NotImplementedException ();
+ }
+
+ public static MembershipUserCollection GetAllUsers ()
+ {
+ return Provider.GetAllUsers ();
+ }
+
+ public static int GetNumberOfUsersOnline ()
+ {
+ return Provider.GetNumberOfUsersOnline ();
+ }
+
+ public static MembershipUser GetUser ()
+ {
+ return GetUser (HttpContext.Current.User.Identity.Name, true);
+ }
+
+ public static MembershipUser GetUser (bool userIsOnline)
+ {
+ return GetUser (HttpContext.Current.User.Identity.Name, userIsOnline);
+ }
+
+ public static MembershipUser GetUser (string username)
+ {
+ return GetUser (username, false);
+ }
+
+ public static MembershipUser GetUser (string username, bool userIsOnline)
+ {
+ return Provider.GetUser (username, userIsOnline);
+ }
+
+ public static string GetUserNameByEmail (string email)
+ {
+ return Provider.GetUserNameByEmail (email);
+ }
+
+ public static void UpdateUser (MembershipUser user)
+ {
+ Provider.UpdateUser (user);
+ }
+
+ public static bool ValidateUser (string username, string password)
+ {
+ return Provider.ValidateUser (username, password);
+ }
+
+ public static string ApplicationName {
+ get { return Provider.ApplicationName; }
+ set { Provider.ApplicationName = value; }
+ }
+
+ public static bool EnablePasswordReset {
+ get { return Provider.EnablePasswordReset; }
+ }
+
+ public static bool EnablePasswordRetrieval {
+ get { return Provider.EnablePasswordRetrieval; }
+ }
+
+ public static bool RequiresQuestionAndAnswer {
+ get { return Provider.RequiresQuestionAndAnswer; }
+ }
+
+ [MonoTODO]
+ public static IMembershipProvider Provider {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public static MembershipProviderCollection Providers {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public static int UserIsOnlineTimeWindow {
+ get { throw new NotImplementedException (); }
+ }
+ }
+}
+#endif
+
diff --git a/mcs/class/System.Web/System.Web.Security/MembershipCreateStatus.cs b/mcs/class/System.Web/System.Web.Security/MembershipCreateStatus.cs
new file mode 100644
index 00000000000..67c17086a35
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.Security/MembershipCreateStatus.cs
@@ -0,0 +1,26 @@
+//
+// System.Web.Security.MembershipCreateStatus
+//
+// Authors:
+// Ben Maurer (bmaurer@users.sourceforge.net)
+//
+// (C) 2003 Ben Maurer
+//
+
+#if NET_1_2
+namespace System.Web.Security {
+ public enum MembershipCreateStatus {
+ Success,
+ UserNotFound,
+ InvalidPassword,
+ InvalidQuestion,
+ InvalidAnswer,
+ InvalidEmail,
+ DuplicateUsername,
+ DuplicateEmail,
+ UserRejected,
+ ProviderError
+ }
+}
+#endif
+
diff --git a/mcs/class/System.Web/System.Web.Security/MembershipCreateUserException.cs b/mcs/class/System.Web/System.Web.Security/MembershipCreateUserException.cs
new file mode 100644
index 00000000000..8d318962bd1
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.Security/MembershipCreateUserException.cs
@@ -0,0 +1,26 @@
+//
+// System.Web.Security.MembershipCreateUserException
+//
+// Authors:
+// Ben Maurer (bmaurer@users.sourceforge.net)
+//
+// (C) 2003 Ben Maurer
+//
+
+#if NET_1_2
+namespace System.Web.Security {
+ [MonoTODO ("make strings for the messages")]
+ public class MembershipCreateUserException : HttpException {
+ public MembershipCreateUserException (MembershipCreateStatus statusCode) : base (statusCode.ToString ())
+ {
+ this.statusCode = statusCode;
+ }
+
+ MembershipCreateStatus statusCode;
+ public MembershipCreateStatus StatusCode {
+ get { return statusCode; }
+ }
+ }
+}
+#endif
+
diff --git a/mcs/class/System.Web/System.Web.Security/MembershipOnlineStatus.cs b/mcs/class/System.Web/System.Web.Security/MembershipOnlineStatus.cs
new file mode 100644
index 00000000000..85eb74457c5
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.Security/MembershipOnlineStatus.cs
@@ -0,0 +1,19 @@
+//
+// System.Web.Security.MembershipOnlineStatus
+//
+// Authors:
+// Ben Maurer (bmaurer@users.sourceforge.net)
+//
+// (C) 2003 Ben Maurer
+//
+
+#if NET_1_2
+namespace System.Web.Security {
+ public enum MembershipOnlineStatus {
+ All,
+ Online,
+ Offline
+ }
+}
+#endif
+
diff --git a/mcs/class/System.Web/System.Web.Security/MembershipPasswordException.cs b/mcs/class/System.Web/System.Web.Security/MembershipPasswordException.cs
new file mode 100644
index 00000000000..2d0f9691d15
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.Security/MembershipPasswordException.cs
@@ -0,0 +1,19 @@
+//
+// System.Web.Security.MembershipPasswordException
+//
+// Authors:
+// Ben Maurer (bmaurer@users.sourceforge.net)
+//
+// (C) 2003 Ben Maurer
+//
+
+#if NET_1_2
+namespace System.Web.Security {
+ public class MembershipPasswordException : HttpException {
+ public MembershipPasswordException () : base () {}
+ public MembershipPasswordException (string message) : base (message) {}
+ public MembershipPasswordException (string message, Exception innerException) : base (message, innerException) {}
+ }
+}
+#endif
+
diff --git a/mcs/class/System.Web/System.Web.Security/MembershipPasswordFormat.cs b/mcs/class/System.Web/System.Web.Security/MembershipPasswordFormat.cs
new file mode 100644
index 00000000000..08fb0db7254
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.Security/MembershipPasswordFormat.cs
@@ -0,0 +1,19 @@
+//
+// System.Web.Security.MembershipPasswordFormat
+//
+// Authors:
+// Ben Maurer (bmaurer@users.sourceforge.net)
+//
+// (C) 2003 Ben Maurer
+//
+
+#if NET_1_2
+namespace System.Web.Security {
+ public enum MembershipPasswordFormat {
+ Clear,
+ Hashed,
+ Encrypted
+ }
+}
+#endif
+
diff --git a/mcs/class/System.Web/System.Web.Security/MembershipProviderCollection.cs b/mcs/class/System.Web/System.Web.Security/MembershipProviderCollection.cs
new file mode 100644
index 00000000000..0547d69c708
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.Security/MembershipProviderCollection.cs
@@ -0,0 +1,29 @@
+//
+// System.Web.Security.MembershipProviderCollection
+//
+// Authors:
+// Ben Maurer (bmaurer@users.sourceforge.net)
+//
+// (C) 2003 Ben Maurer
+//
+
+#if NET_1_2
+using System.Configuration.Provider;
+
+namespace System.Web.Security {
+ public class MembershipProviderCollection : ProviderCollection {
+ public override void Add (IProvider provider)
+ {
+ if (provider is IMembershipProvider)
+ base.Add (provider);
+ else
+ throw new HttpException ();
+ }
+
+ public IMembershipProvider this [string name] {
+ get { return (IMembershipProvider) base [name]; }
+ }
+ }
+}
+#endif
+
diff --git a/mcs/class/System.Web/System.Web.Security/MembershipSortOptions.cs b/mcs/class/System.Web/System.Web.Security/MembershipSortOptions.cs
new file mode 100644
index 00000000000..9d71fcbac51
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.Security/MembershipSortOptions.cs
@@ -0,0 +1,22 @@
+//
+// System.Web.Security.MembershipSortOptions
+//
+// Authors:
+// Ben Maurer (bmaurer@users.sourceforge.net)
+//
+// (C) 2003 Ben Maurer
+//
+
+#if NET_1_2
+namespace System.Web.Security {
+ public enum MembershipSortOptions {
+ UserName,
+ CreationDate,
+ LastActivityDate,
+ LastLoginDate,
+ LastPasswordChangeDate,
+ Email
+ }
+}
+#endif
+
diff --git a/mcs/class/System.Web/System.Web.Security/MembershipUser.cs b/mcs/class/System.Web/System.Web.Security/MembershipUser.cs
new file mode 100644
index 00000000000..f53bf87954b
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.Security/MembershipUser.cs
@@ -0,0 +1,141 @@
+//
+// System.Web.Security.MembershipUser
+//
+// Authors:
+// Ben Maurer (bmaurer@users.sourceforge.net)
+//
+// (C) 2003 Ben Maurer
+//
+
+#if NET_1_2
+namespace System.Web.Security {
+ public class MembershipUser {
+ protected MembershipUser ()
+ {
+ }
+
+ public MembershipUser (IMembershipProvider provider, string name, string email,
+ string passwordQuestion, string comment, bool isApproved,
+ DateTime creationDate, DateTime lastLoginDate, DateTime lastActivityDate,
+ DateTime lastPasswordChangedDate)
+ {
+ this.provider = provider;
+ this.name = name;
+ this.email = email;
+ this.passwordQuestion = passwordQuestion;
+ this.comment = comment;
+ this.isApproved = isApproved;
+ this.creationDate = creationDate;
+ this.lastLoginDate = lastLoginDate;
+ this.lastActivityDate = lastActivityDate;
+ this.lastPasswordChangedDate = lastPasswordChangedDate;
+ }
+
+ public virtual bool ChangePassword (string oldPassword, string newPassword)
+ {
+ bool success = Provider.ChangePassword (Username, oldPassword, newPassword);
+ if (success)
+ LastPasswordChangedDate = DateTime.Now;
+
+ return success;
+ }
+
+ public virtual bool ChangePasswordQuestionAndAnswer (string password, string newPasswordQuestion, string newPasswordAnswer)
+ {
+ bool success = Provider.ChangePasswordQuestionAndAnswer (Username, password, newPasswordQuestion, newPasswordAnswer);
+ if (success)
+ passwordQuestion = newPasswordQuestion;
+
+ return success;
+ }
+
+ public virtual string GetPassword ()
+ {
+ return GetPassword (null);
+ }
+
+ public virtual string GetPassword (string answer)
+ {
+ return Provider.GetPassword (Username, answer);
+ }
+
+ public virtual string ResetPassword ()
+ {
+ return ResetPassword (null);
+ }
+
+ public virtual string ResetPassword (string answer)
+ {
+ string newPass = Provider.ResetPassword (Username, answer);
+ if (newPass != null)
+ LastPasswordChangedDate = DateTime.Now;
+
+ return newPass;
+ }
+
+ public virtual string Comment {
+ get { return comment; }
+ set { comment = value; }
+ }
+
+ public virtual DateTime CreationDate {
+ get { return creationDate; }
+ set { creationDate = value; }
+ }
+
+ public virtual string Email {
+ get { return email; }
+ set { email = value; }
+ }
+
+ public virtual bool IsApproved {
+ get { return isApproved; }
+ set { isApproved = value; }
+ }
+
+ [MonoTODO]
+ public bool IsOnline {
+ get { throw new NotImplementedException (); }
+ }
+
+ public virtual DateTime LastActivityDate {
+ get { return lastActivityDate; }
+ set { lastActivityDate = value; }
+ }
+
+ public virtual DateTime LastLoginDate {
+ get { return lastLoginDate; }
+ set { lastLoginDate = value; }
+ }
+
+ public virtual DateTime LastPasswordChangedDate {
+ get { return lastPasswordChangedDate; }
+ set { lastPasswordChangedDate = value; }
+ }
+
+ public virtual string PasswordQuestion {
+ get { return passwordQuestion; }
+ }
+
+ public virtual IMembershipProvider Provider {
+ get { return provider; }
+ }
+
+ public virtual string Username {
+ get { return name; }
+ }
+
+ IMembershipProvider provider;
+ string name;
+ string email;
+ string passwordQuestion;
+ string comment;
+ bool isApproved;
+ DateTime creationDate;
+ DateTime lastLoginDate;
+ DateTime lastActivityDate;
+ DateTime lastPasswordChangedDate;
+ }
+}
+#endif
+
diff --git a/mcs/class/System.Web/System.Web.Security/MembershipUserCollection.cs b/mcs/class/System.Web/System.Web.Security/MembershipUserCollection.cs
new file mode 100644
index 00000000000..69b2d407777
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.Security/MembershipUserCollection.cs
@@ -0,0 +1,88 @@
+//
+// System.Web.Security.MembershipUserCollection
+//
+// Authors:
+// Ben Maurer (bmaurer@users.sourceforge.net)
+//
+// (C) 2003 Ben Maurer
+//
+
+#if NET_1_2
+using System.Collections;
+using System.Web.UI;
+
+namespace System.Web.Security {
+ public class MembershipUserCollection : ICloneable, ICollection {
+ public MembershipUserCollection ()
+ {
+ }
+
+ public void Add (MembershipUser user)
+ {
+ CheckNotReadOnly ();
+ store.Add (user.Username, user);
+ }
+
+ public void Clear ()
+ {
+ CheckNotReadOnly ();
+ store.Clear ();
+ }
+
+ public object Clone ()
+ {
+ MembershipUserCollection clone = new MembershipUserCollection ();
+ foreach (MembershipUser u in this)
+ clone.Add (u);
+ return clone;
+ }
+
+ public void CopyTo (Array array, int index)
+ {
+ store.CopyTo (array, index);
+ }
+
+ public IEnumerator GetEnumerator ()
+ {
+ return ((IEnumerable) store).GetEnumerator ();
+ }
+
+ public void Remove (string name)
+ {
+ CheckNotReadOnly ();
+ store.Remove (name);
+ }
+
+ public void SetReadOnly ()
+ {
+ readOnly = true;
+ }
+
+ public int Count {
+ get { return store.Count; }
+ }
+
+ public bool IsSynchronized {
+ get { return false; }
+ }
+
+ public MembershipUser this [string name] {
+ get { return (MembershipUser) store [name]; }
+ }
+
+ public object SyncRoot {
+ get { return this; }
+ }
+
+ void CheckNotReadOnly ()
+ {
+ if (readOnly)
+ throw new InvalidOperationException ();
+ }
+
+ KeyedList store = new KeyedList ();
+ bool readOnly = false;
+ }
+}
+#endif
+
diff --git a/mcs/class/System.Web/System.Web.Security/RoleManagerEventArgs.cs b/mcs/class/System.Web/System.Web.Security/RoleManagerEventArgs.cs
new file mode 100644
index 00000000000..547b8c3028c
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.Security/RoleManagerEventArgs.cs
@@ -0,0 +1,35 @@
+//
+// System.Web.Security.RoleManagerEventArgs
+//
+// Authors:
+// Ben Maurer (bmaurer@users.sourceforge.net)
+//
+// (C) 2003 Ben Maurer
+//
+
+#if NET_1_2
+using System.Collections;
+using System.Collections.Specialized;
+using System.Text;
+
+namespace System.Web.Security {
+ public sealed class RoleManagerEventArgs : EventArgs {
+ public RoleManagerEventArgs (HttpContext context)
+ {
+ this.context = context;
+ }
+
+ HttpContext context;
+ public HttpContext Context {
+ get { return context; }
+ }
+
+ bool rolesPopulated;
+ public bool RolesPopulated {
+ get { return rolesPopulated; }
+ set { rolesPopulated = value; }
+ }
+ }
+}
+#endif
+
diff --git a/mcs/class/System.Web/System.Web.Security/RoleManagerEventHandler.cs b/mcs/class/System.Web/System.Web.Security/RoleManagerEventHandler.cs
new file mode 100644
index 00000000000..82c2d5645b3
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.Security/RoleManagerEventHandler.cs
@@ -0,0 +1,15 @@
+//
+// System.Web.Security.RoleManagerEventHandler
+//
+// Authors:
+// Ben Maurer (bmaurer@users.sourceforge.net)
+//
+// (C) 2003 Ben Maurer
+//
+
+#if NET_1_2
+namespace System.Web.Security {
+ public delegate void RoleManagerEventHandler (object sender, RoleManagerEventArgs e);
+}
+#endif
+
diff --git a/mcs/class/System.Web/System.Web.Security/RoleManagerModule.cs b/mcs/class/System.Web/System.Web.Security/RoleManagerModule.cs
new file mode 100644
index 00000000000..c600f318db8
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.Security/RoleManagerModule.cs
@@ -0,0 +1,33 @@
+//
+// System.Web.Security.RoleManagerModule
+//
+// Authors:
+// Ben Maurer (bmaurer@users.sourceforge.net)
+//
+// (C) 2003 Ben Maurer
+//
+
+#if NET_1_2
+using System.Collections;
+using System.Collections.Specialized;
+using System.Text;
+
+namespace System.Web.Security {
+ public sealed class RoleManagerModule : IHttpModule {
+ public event RoleManagerEventHandler GetRoles;
+
+ [MonoTODO]
+ public void Dispose ()
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void Init (HttpApplication app)
+ {
+ throw new NotImplementedException ();
+ }
+ }
+}
+#endif
+
diff --git a/mcs/class/System.Web/System.Web.Security/RolePrincipal.cs b/mcs/class/System.Web/System.Web.Security/RolePrincipal.cs
new file mode 100644
index 00000000000..2f663384e2a
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.Security/RolePrincipal.cs
@@ -0,0 +1,121 @@
+//
+// System.Web.Security.RolePrincipal
+//
+// Authors:
+// Ben Maurer (bmaurer@users.sourceforge.net)
+//
+// (C) 2003 Ben Maurer
+//
+
+#if NET_1_2
+using System.Collections;
+using System.Collections.Specialized;
+using System.Text;
+using System.Security;
+using System.Security.Principal;
+
+namespace System.Web.Security {
+ public sealed class RolePrincipal : IPrincipal {
+
+ [MonoTODO]
+ public RolePrincipal ()
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public RolePrincipal (bool createFromCookie)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public RolePrincipal (string encryptedTicket)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public string [] GetRoles ()
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void Init ()
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void InitFromCookie (string cookieName)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void InitFromEncryptedTicket (string strTicket)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public bool IsInRole (string role)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public string ToEncryptedTicket ()
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public bool CachedListChanged {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public string CookiePath {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public bool Expired {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public DateTime ExpireDate {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public IIdentity Identity {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public bool IsRoleListCached {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public DateTime IssueDate {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public string UserData {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public int Version {
+ get { throw new NotImplementedException (); }
+ }
+ }
+}
+#endif
+
diff --git a/mcs/class/System.Web/System.Web.Security/RoleProviderCollection.cs b/mcs/class/System.Web/System.Web.Security/RoleProviderCollection.cs
new file mode 100644
index 00000000000..d759cf6dd4d
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.Security/RoleProviderCollection.cs
@@ -0,0 +1,29 @@
+//
+// System.Web.Security.RoleProviderCollection
+//
+// Authors:
+// Ben Maurer (bmaurer@users.sourceforge.net)
+//
+// (C) 2003 Ben Maurer
+//
+
+#if NET_1_2
+using System.Configuration.Provider;
+
+namespace System.Web.Security {
+ public class RoleProviderCollection : ProviderCollection {
+ public override void Add (IProvider provider)
+ {
+ if (provider is IRoleProvider)
+ base.Add (provider);
+ else
+ throw new HttpException ();
+ }
+
+ public IRoleProvider this [string name] {
+ get { return (IRoleProvider) base [name]; }
+ }
+ }
+}
+#endif
+
diff --git a/mcs/class/System.Web/System.Web.Security/Roles.cs b/mcs/class/System.Web/System.Web.Security/Roles.cs
new file mode 100644
index 00000000000..02b931ccdb1
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.Security/Roles.cs
@@ -0,0 +1,184 @@
+//
+// System.Web.Security.Roles
+//
+// Authors:
+// Ben Maurer (bmaurer@users.sourceforge.net)
+//
+// (C) 2003 Ben Maurer
+//
+
+#if NET_1_2
+using System.Collections;
+using System.Collections.Specialized;
+using System.Text;
+
+namespace System.Web.Security {
+ public sealed class Roles {
+
+ [MonoTODO]
+ public static void AddUsersToRole (string [] usernames, string rolename)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public static void AddUsersToRoles (string [] usernames, string [] rolenames)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public static void AddUserToRole (string username, string rolename)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public static void AddUserToRoles (string username, string [] rolenames)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public static void CreateRole (string rolename)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public static void DeleteCookie ()
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public static void DeleteRole (string rolename)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public static string [] GetAllRoles ()
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public static string [] GetRolesForUser ()
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public static string [] GetRolesForUser (string username)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public static string [] GetUsersInRole (string rolename)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public static bool IsUserInRole (string rolename)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public static bool IsUserInRole (string username, string rolename)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public static void RemoveUserFromRole (string username, string rolename)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public static void RemoveUserFromRoles (string username, string [] rolenames)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public static void RemoveUsersFromRole (string [] usernames, string rolename)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public static void RemoveUsersFromRoles (string [] usernames, string [] rolenames)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public static bool RoleExists (string rolename)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public static string ApplicationName {
+ get { throw new NotImplementedException (); }
+ set { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public static bool CacheRolesInCookie {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public static string CookieName {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public static string CookiePath {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public static CookieProtection CookieProtectionValue {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public static bool CookieRequireSSL {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public static bool CookieSlidingExpiration {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public static int CookieTimeout {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public static bool Enabled {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public static IRoleProvider Provider {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public static RoleProviderCollection Providers {
+ get { throw new NotImplementedException (); }
+ }
+ }
+}
+#endif
+
diff --git a/mcs/class/System.Web/System.Web.Security/SqlMembershipProvider.cs b/mcs/class/System.Web/System.Web.Security/SqlMembershipProvider.cs
new file mode 100644
index 00000000000..cc6ab319f6b
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.Security/SqlMembershipProvider.cs
@@ -0,0 +1,145 @@
+//
+// System.Web.Security.SqlMembershipProvider
+//
+// Authors:
+// Ben Maurer (bmaurer@users.sourceforge.net)
+//
+// (C) 2003 Ben Maurer
+//
+
+#if NET_1_2
+using System.Collections;
+using System.Collections.Specialized;
+using System.Text;
+
+namespace System.Web.Security {
+ public class SqlMembershipProvider : IMembershipProvider {
+
+ [MonoTODO]
+ public virtual bool ChangePassword (string username, string oldPwd, string newPwd)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public virtual bool ChangePasswordQuestionAndAnswer (string username, string password, string newPwdQuestion, string newPwdAnswer)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public virtual MembershipUser CreateUser (string username, string password, string email, out MembershipCreateStatus status)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public virtual bool DeleteUser (string username)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public virtual string GeneratePassword ()
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public MembershipUserCollection GetAllUsers ()
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public int GetNumberOfUsersOnline ()
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public virtual string GetPassword (string username, string answer)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public virtual MembershipUser GetUser (string username, bool userIsOnline)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public virtual string GetUserNameByEmail (string email)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public virtual void Initialize (string name, NameValueCollection config)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public virtual string ResetPassword (string username, string answer)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public virtual void UpdateUser (MembershipUser user)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public virtual bool ValidateUser (string username, string password)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public string ApplicationName {
+ get { throw new NotImplementedException (); }
+ set { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public virtual string Description {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public virtual bool EnablePasswordReset {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public virtual bool EnablePasswordRetrieval {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public virtual string Name {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public virtual MembershipPasswordFormat PasswordFormat {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public virtual bool RequiresQuestionAndAnswer {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public virtual bool RequiresUniqueEmail {
+ get { throw new NotImplementedException (); }
+ }
+ }
+}
+#endif
+
diff --git a/mcs/class/System.Web/System.Web.Security/SqlRoleProvider.cs b/mcs/class/System.Web/System.Web.Security/SqlRoleProvider.cs
new file mode 100644
index 00000000000..35af34fe86d
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.Security/SqlRoleProvider.cs
@@ -0,0 +1,96 @@
+//
+// System.Web.Security.SqlRoleProvider
+//
+// Authors:
+// Ben Maurer (bmaurer@users.sourceforge.net)
+//
+// (C) 2003 Ben Maurer
+//
+
+#if NET_1_2
+using System.Collections;
+using System.Collections.Specialized;
+using System.Text;
+
+namespace System.Web.Security {
+ public class SqlRoleProvider {
+
+ [MonoTODO]
+ public void AddUsersToRoles (string [] usernames, string [] rolenames)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void CreateRole (string rolename)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void DeleteRole (string rolename)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public string [] GetAllRoles ()
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public string [] GetRolesForUser (string username)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public string [] GetUsersInRole (string rolename)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public virtual void Initialize (string name, NameValueCollection config)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public bool IsUserInRole (string username, string rolename)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void RemoveUsersFromRoles (string [] usernames, string [] rolenames)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public bool RoleExists (string rolename)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public string ApplicationName {
+ get { throw new NotImplementedException (); }
+ set { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public virtual string Description {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public virtual string Name {
+ get { throw new NotImplementedException (); }
+ }
+ }
+}
+#endif
+
diff --git a/mcs/class/System.Web/System.Web.SessionState/ChangeLog b/mcs/class/System.Web/System.Web.SessionState/ChangeLog
index 3c925fa4fab..3a6feb535fe 100644
--- a/mcs/class/System.Web/System.Web.SessionState/ChangeLog
+++ b/mcs/class/System.Web/System.Web.SessionState/ChangeLog
@@ -1,3 +1,39 @@
+2003-11-26 Jackson Harper <jackson@ximian.com>
+
+ * SessionSQLServerHandler.cs: Fix typo in param name.
+
+2003-11-25 Jackson Harper <jackson@ximian.com>
+
+ * RemoteStateServer.cs: Update the session dictionary data and the
+ static objects data.
+ * SessionDictionary.cs: Remove type serialization methods, these
+ have been moved to a utility class. Add convenience methods for
+ converting to/from byte arrays.
+ * SessionSQLServerHandler.cs:
+ * SessionStateServerHandler.cs: Save/Restore static objects. Use new
+ to/from byte array methods.
+ * StateServerItem.cs: Hold static objects data.
+
+2003-11-24 Jackson Harper <jackson@ximian.com>
+
+ * SessionStateServerHandler.cs: Parse connection string. Need to
+ look into what MS allows/doesn't allow better.
+
+2003-11-24 Jackson Harper <jackson@ximian.com>
+
+ * RemoteStateServer.cs: The state server object that will reside
+ on the server and store session data and ids.
+ * StateServerItem.cs: Container for session data.
+ * SessionStateServerHandler.cs: Handler that communicates with the
+ StateServer so sessions can be stored out of process.
+ * SessionStateModule.cs: Allow state server mode.
+
+2003-11-13 Jackson Harper <jackson@ximian.com>
+
+ * SessionInProcHandler.cs: Use AppDomain.SetData so data is
+ available across all threads. Set the path of session id
+ cookies. Patch by Mohammad DAMT. Fixes bug #50922.
+
2003-11-06 Jackson Harper <jackson@ximian.com>
* ISessionHandler.cs: Pass the SessionStateModule to handlers when
diff --git a/mcs/class/System.Web/System.Web.SessionState/RemoteStateServer.cs b/mcs/class/System.Web/System.Web.SessionState/RemoteStateServer.cs
new file mode 100644
index 00000000000..6ad50c6202f
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.SessionState/RemoteStateServer.cs
@@ -0,0 +1,54 @@
+//
+// System.Web.SessionState.RemoteStateServer
+//
+// Author(s):
+// Jackson Harper (jackson@ximian.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+
+using System;
+using System.Collections;
+
+namespace System.Web.SessionState {
+
+ internal class RemoteStateServer : MarshalByRefObject {
+
+ private Hashtable table;
+
+ internal RemoteStateServer ()
+ {
+ table = new Hashtable ();
+ }
+
+ internal void Insert (string id, StateServerItem item)
+ {
+ table.Add (id, item);
+ }
+
+ internal void Update (string id, byte [] dict_data, byte [] sobjs_data)
+ {
+ StateServerItem item = table [id] as StateServerItem;
+
+ if (item == null)
+ return;
+
+ item.DictionaryData = dict_data;
+ item.StaticObjectsData = sobjs_data;
+ item.Touch ();
+ }
+
+ internal StateServerItem Get (string id)
+ {
+ StateServerItem item = table [id] as StateServerItem;
+
+ if (item == null || item.IsAbandoned ())
+ return null;
+
+ item.Touch ();
+ return item;
+ }
+ }
+}
+
diff --git a/mcs/class/System.Web/System.Web.SessionState/SessionDictionary.cs b/mcs/class/System.Web/System.Web.SessionState/SessionDictionary.cs
index a0bf55195cf..957b3231283 100644
--- a/mcs/class/System.Web/System.Web.SessionState/SessionDictionary.cs
+++ b/mcs/class/System.Web/System.Web.SessionState/SessionDictionary.cs
@@ -11,34 +11,12 @@ using System;
using System.IO;
using System.Collections;
using System.Collections.Specialized;
-using System.Runtime.Serialization.Formatters.Binary;
namespace System.Web.SessionState {
internal class SessionDictionary : NameObjectCollectionBase
{
- static ArrayList types;
bool _dirty;
-
- static SessionDictionary ()
- {
- types = new ArrayList ();
- types.Add ("");
- types.Add (typeof (string));
- types.Add (typeof (int));
- types.Add (typeof (bool));
- types.Add (typeof (DateTime));
- types.Add (typeof (Decimal));
- types.Add (typeof (Byte));
- types.Add (typeof (Char));
- types.Add (typeof (Single));
- types.Add (typeof (Double));
- types.Add (typeof (short));
- types.Add (typeof (long));
- types.Add (typeof (ushort));
- types.Add (typeof (uint));
- types.Add (typeof (ulong));
- }
-
+
public SessionDictionary ()
{
}
@@ -87,145 +65,30 @@ internal class SessionDictionary : NameObjectCollectionBase
w.Write (key);
object value = BaseGet (key);
if (value == null) {
- w.Write (16); // types.Count + 1
+ w.Write (System.Web.Util.AltSerialization.NullIndex);
continue;
}
- SerializeByType (w, value);
+ System.Web.Util.AltSerialization.SerializeByType (w, value);
}
}
}
- static void SerializeByType (BinaryWriter w, object value)
- {
- Type type = value.GetType ();
- int i = types.IndexOf (type);
- if (i == -1) {
- w.Write (15); // types.Count
- BinaryFormatter bf = new BinaryFormatter ();
- bf.Serialize (w.BaseStream, value);
- return;
- }
-
- w.Write (i);
- switch (i) {
- case 1:
- w.Write ((string) value);
- break;
- case 2:
- w.Write ((int) value);
- break;
- case 3:
- w.Write ((bool) value);
- break;
- case 4:
- w.Write (((DateTime) value).Ticks);
- break;
- case 5:
- w.Write ((decimal) value);
- break;
- case 6:
- w.Write ((byte) value);
- break;
- case 7:
- w.Write ((char) value);
- break;
- case 8:
- w.Write ((float) value);
- break;
- case 9:
- w.Write ((double) value);
- break;
- case 10:
- w.Write ((short) value);
- break;
- case 11:
- w.Write ((long) value);
- break;
- case 12:
- w.Write ((ushort) value);
- break;
- case 13:
- w.Write ((uint) value);
- break;
- case 14:
- w.Write ((ulong) value);
- break;
- }
- }
-
internal static SessionDictionary Deserialize (BinaryReader r)
{
SessionDictionary result = new SessionDictionary ();
for (int i = r.ReadInt32 (); i > 0; i--) {
string key = r.ReadString ();
int index = r.ReadInt32 ();
- if (index == 16)
+ if (index == System.Web.Util.AltSerialization.NullIndex)
result [key] = null;
else
- result [key] = DeserializeFromIndex (index, r);
+ result [key] = System.Web.Util.AltSerialization.DeserializeFromIndex (index, r);
}
return result;
}
- static object DeserializeFromIndex (int index, BinaryReader r)
- {
- if (index == 15){
- BinaryFormatter bf = new BinaryFormatter ();
- return bf.Deserialize (r.BaseStream);
- }
-
- object value = null;
- switch (index) {
- case 1:
- value = r.ReadString ();
- break;
- case 2:
- value = r.ReadInt32 ();
- break;
- case 3:
- value = r.ReadBoolean ();
- break;
- case 4:
- value = new DateTime (r.ReadInt64 ());
- break;
- case 5:
- value = r.ReadDecimal ();
- break;
- case 6:
- value = r.ReadByte ();
- break;
- case 7:
- value = r.ReadChar ();
- break;
- case 8:
- value = r.ReadSingle ();
- break;
- case 9:
- value = r.ReadDouble ();
- break;
- case 10:
- value = r.ReadInt16 ();
- break;
- case 11:
- value = r.ReadInt64 ();
- break;
- case 12:
- value = r.ReadUInt16 ();
- break;
- case 13:
- value = r.ReadUInt32 ();
- break;
- case 14:
- value = r.ReadUInt64 ();
- break;
- }
-
- return value;
- }
-
-
internal bool Dirty
{
get { return _dirty; }
@@ -266,6 +129,37 @@ internal class SessionDictionary : NameObjectCollectionBase
_dirty = true;
}
}
+
+ internal byte [] ToByteArray ()
+ {
+ MemoryStream stream = null;
+ try {
+ stream = new MemoryStream ();
+ Serialize (new BinaryWriter (stream));
+ return stream.GetBuffer ();
+ } catch {
+ throw;
+ } finally {
+ if (stream != null)
+ stream.Close ();
+ }
+ }
+
+ internal static SessionDictionary FromByteArray (byte [] data)
+ {
+ SessionDictionary result = null;
+ MemoryStream stream = null;
+ try {
+ stream = new MemoryStream (data);
+ result = Deserialize (new BinaryReader (stream));
+ } catch {
+ throw;
+ } finally {
+ if (stream != null)
+ stream.Close ();
+ }
+ return result;
+ }
}
}
diff --git a/mcs/class/System.Web/System.Web.SessionState/SessionInProcHandler.cs b/mcs/class/System.Web/System.Web.SessionState/SessionInProcHandler.cs
index fc0ed94fff2..d9d819c2ad9 100644
--- a/mcs/class/System.Web/System.Web.SessionState/SessionInProcHandler.cs
+++ b/mcs/class/System.Web/System.Web.SessionState/SessionInProcHandler.cs
@@ -16,6 +16,7 @@
* Generate SessionID:s in a good (more random) way.
*/
using System;
+using System.IO;
using System.Collections;
namespace System.Web.SessionState
@@ -67,7 +68,9 @@ namespace System.Web.SessionState
public void Init (HttpApplication context, SessionConfig config)
{
- _sessionTable = new Hashtable();
+ _sessionTable = (Hashtable) AppDomain.CurrentDomain.GetData (".MonoSessionInProc");
+ if (_sessionTable == null)
+ _sessionTable = new Hashtable();
}
public void UpdateHandler (HttpContext context, SessionStateModule module)
@@ -111,6 +114,7 @@ namespace System.Web.SessionState
false)); //readonly
// puts it in the table.
_sessionTable [sessionID]=container;
+ AppDomain.CurrentDomain.SetData (".MonoSessionInProc", _sessionTable);
// and returns it.
context.SetSession (container.SessionState);
@@ -118,7 +122,9 @@ namespace System.Web.SessionState
// sets the session cookie. We're assuming that session scope is the default mode.
- context.Response.AppendCookie (new HttpCookie (COOKIE_NAME,sessionID));
+ HttpCookie cookie = new HttpCookie (COOKIE_NAME,sessionID);
+ cookie.Path = Path.GetDirectoryName (context.Request.Path);
+ context.Response.AppendCookie (cookie);
// And we're done!
return true;
diff --git a/mcs/class/System.Web/System.Web.SessionState/SessionSQLServerHandler.cs b/mcs/class/System.Web/System.Web.SessionState/SessionSQLServerHandler.cs
index 38f2f5ad5ec..51f65f7a58e 100644
--- a/mcs/class/System.Web/System.Web.SessionState/SessionSQLServerHandler.cs
+++ b/mcs/class/System.Web/System.Web.SessionState/SessionSQLServerHandler.cs
@@ -146,30 +146,18 @@ namespace System.Web.SessionState {
if (!reader.Read ())
return null;
- SessionDictionary dict = null;
- MemoryStream stream = null;
- int len = (int) reader.GetBytes (reader.FieldCount-1, 0, null, 0, 0);
- byte[] data = new byte[len];
- reader.GetBytes (reader.FieldCount-1, 0, data, 0, len);
- try {
- stream = new MemoryStream (data);
- dict = SessionDictionary.Deserialize (new BinaryReader (stream));
- } catch {
- throw;
- } finally {
- if (stream != null)
- stream.Close ();
- }
-
- session = new HttpSessionState (id, dict,
- new HttpStaticObjectsCollection (),
- 100, true, false,
+ SessionDictionary dict;
+ HttpStaticObjectsCollection sobjs;
+
+ dict = SessionDictionary.FromByteArray (ReadBytes (reader, reader.FieldCount-1));
+ sobjs = HttpStaticObjectsCollection.FromByteArray (ReadBytes (reader, reader.FieldCount-2));
+
+ session = new HttpSessionState (id, dict, sobjs, 100, true, false,
SessionStateMode.SQLServer, false);
return session;
} catch {
throw;
}
-
}
private void InsertSession (HttpSessionState session, int timeout)
@@ -178,7 +166,7 @@ namespace System.Web.SessionState {
IDataParameterCollection param;
string insert = "INSERT INTO ASPStateTempSessions VALUES " +
- "(:SessionID, :Created, :Expires, :Timeout, :SessionData)";
+ "(:SessionID, :Created, :Expires, :Timeout, :StaticObjectsData, :SessionData)";
command.CommandText = insert;
@@ -187,8 +175,10 @@ namespace System.Web.SessionState {
param.Add (CreateParam (command, DbType.DateTime, ":Created", DateTime.Now));
param.Add (CreateParam (command, DbType.DateTime, ":Expires", Tommorow ()));
param.Add (CreateParam (command, DbType.Int32, ":Timeout", timeout));
+ param.Add (CreateParam (command, DbType.Binary, ":StaticObjectsData",
+ session.StaticObjects.ToByteArray ()));
param.Add (CreateParam (command, DbType.Binary, ":SessionData",
- GetDictData (session.SessionDictionary)));
+ session.SessionDictionary.ToByteArray ()));
command.ExecuteNonQuery ();
}
@@ -206,7 +196,7 @@ namespace System.Web.SessionState {
param = command.Parameters;
param.Add (CreateParam (command, DbType.String, ":SessionID", id));
param.Add (CreateParam (command, DbType.Binary, ":SessionData",
- GetDictData (dict)));
+ dict.ToByteArray ()));
command.ExecuteNonQuery ();
}
@@ -221,21 +211,6 @@ namespace System.Web.SessionState {
return result;
}
- private byte[] GetDictData (SessionDictionary dict)
- {
- MemoryStream stream = null;
- try {
- stream = new MemoryStream ();
- dict.Serialize (new BinaryWriter (stream));
- return stream.GetBuffer ();
- } catch {
- throw;
- } finally {
- if (stream != null)
- stream.Close ();
- }
- }
-
private DateTime Tommorow ()
{
return DateTime.Now.AddDays (1);
@@ -249,6 +224,14 @@ namespace System.Web.SessionState {
return null;
}
+
+ private byte [] ReadBytes (IDataReader reader, int index)
+ {
+ int len = (int) reader.GetBytes (reader.FieldCount-1, 0, null, 0, 0);
+ byte [] data = new byte [len];
+ reader.GetBytes (index, 0, data, 0, len);
+ return data;
+ }
}
}
diff --git a/mcs/class/System.Web/System.Web.SessionState/SessionStateModule.cs b/mcs/class/System.Web/System.Web.SessionState/SessionStateModule.cs
index 28f13366606..579190ad5ca 100644
--- a/mcs/class/System.Web/System.Web.SessionState/SessionStateModule.cs
+++ b/mcs/class/System.Web/System.Web.SessionState/SessionStateModule.cs
@@ -46,7 +46,7 @@ namespace System.Web.SessionState
config = new SessionConfig (null);
if (config.Mode == SessionStateMode.StateServer)
- throw new NotSupportedException ("StateServer mode is not supported.");
+ handlerType = typeof (SessionStateServerHandler);
if (config.Mode == SessionStateMode.SQLServer)
handlerType = typeof (SessionSQLServerHandler);
diff --git a/mcs/class/System.Web/System.Web.SessionState/SessionStateServerHandler.cs b/mcs/class/System.Web/System.Web.SessionState/SessionStateServerHandler.cs
new file mode 100644
index 00000000000..cffc3cf7864
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.SessionState/SessionStateServerHandler.cs
@@ -0,0 +1,130 @@
+//
+// System.Web.SessionState.SessionStateServerHandler
+//
+// Author(s):
+// Jackson Harper (jackson@ximian.com)
+//
+// (C) 2003 Novell, Inc, (http://www.novell.com)
+//
+
+
+using System;
+using System.IO;
+using System.Reflection;
+using System.Configuration;
+using System.Runtime.Remoting;
+
+namespace System.Web.SessionState {
+
+ internal class SessionStateServerHandler : ISessionHandler
+ {
+ const string CookieName = "ASPSESSION";
+ const int DefTimeout = 600;
+
+ private RemoteStateServer state_server;
+ private SessionConfig config;
+
+ public void Dispose ()
+ {
+ }
+
+ public void Init (HttpApplication context, SessionConfig config)
+ {
+ this.config = config;
+ RemotingConfiguration.Configure (null);
+ string cons, proto, server, port;
+ GetConData (config.StateConnectionString, out proto, out server, out port);
+ cons = String.Format ("{0}://{1}:{2}/StateServer", proto, server, port);
+ state_server = (RemoteStateServer) Activator.GetObject (typeof (RemoteStateServer), cons);
+ }
+
+ public void UpdateHandler (HttpContext context, SessionStateModule module)
+ {
+ if (context.Session == null)
+ return;
+
+ string id = context.Session.SessionID;
+ SessionDictionary dict = context.Session.SessionDictionary;
+ HttpStaticObjectsCollection sobjs = context.Session.StaticObjects;
+ state_server.Update (id, dict.ToByteArray (), sobjs.ToByteArray ());
+ }
+
+ public bool UpdateContext (HttpContext context, SessionStateModule module)
+ {
+ StateServerItem item = null;
+ HttpSessionState session = null;
+ SessionDictionary dict = null;
+ HttpStaticObjectsCollection sobjs = null;
+ string id = GetId (context);
+
+ if (id != null) {
+ item = state_server.Get (id);
+ if (item != null) {
+ dict = SessionDictionary.FromByteArray (item.DictionaryData);
+ sobjs = HttpStaticObjectsCollection.FromByteArray (item.StaticObjectsData);
+ session = new HttpSessionState (id, dict, sobjs,
+ config.Timeout, false, config.CookieLess,
+ SessionStateMode.StateServer, false);
+ context.SetSession (session);
+ return false;
+ }
+ }
+
+ id = SessionId.Create (module.Rng);
+ dict = new SessionDictionary ();
+ sobjs = new HttpStaticObjectsCollection ();
+ item = new StateServerItem (dict.ToByteArray (), sobjs.ToByteArray (), config.Timeout);
+
+ state_server.Insert (id, item);
+
+ session = new HttpSessionState (id, dict, sobjs, config.Timeout,
+ false, config.CookieLess, SessionStateMode.StateServer, false);
+
+ context.SetSession (session);
+ context.Session.IsNewSession = true;
+ context.Response.AppendCookie (new HttpCookie (CookieName, id));
+
+ return true;
+ }
+
+ private string GetId (HttpContext context)
+ {
+ if (!config.CookieLess &&
+ context.Request.Cookies [CookieName] != null)
+ return context.Request.Cookies [CookieName].Value;
+ return null;
+ }
+
+ private byte[] GetDictData (SessionDictionary dict)
+ {
+ MemoryStream stream = null;
+ try {
+ stream = new MemoryStream ();
+ dict.Serialize (new BinaryWriter (stream));
+ return stream.GetBuffer ();
+ } catch {
+ throw;
+ } finally {
+ if (stream != null)
+ stream.Close ();
+ }
+ }
+
+ private void GetConData (string cons, out string proto, out string server, out string port)
+ {
+ int ei = cons.IndexOf ('=');
+ int ci = cons.IndexOf (':');
+
+ if (ei < 0 || ci < 0)
+ throw new Exception ("Invalid StateConnectionString");
+
+ proto = cons.Substring (0, ei);
+ server = cons.Substring (ei+1, ci - ei - 1);
+ port = cons.Substring (ci+1, cons.Length - ci - 1);
+
+ if (proto == "tcpip")
+ proto = "tcp";
+ }
+ }
+}
+
diff --git a/mcs/class/System.Web/System.Web.SessionState/StateServerItem.cs b/mcs/class/System.Web/System.Web.SessionState/StateServerItem.cs
new file mode 100644
index 00000000000..14ca097a327
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.SessionState/StateServerItem.cs
@@ -0,0 +1,52 @@
+//
+// System.Web.SessionState.StateServerItem
+//
+// Author(s):
+// Jackson Harper (jackson@ximian.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+
+namespace System.Web.SessionState {
+
+ [Serializable]
+ public class StateServerItem {
+
+ private byte [] dict_data;
+ private byte [] sobjs_data;
+ private DateTime last_access;
+ private int timeout;
+
+ public StateServerItem (byte [] dict_data, byte [] sobjs_data, int timeout)
+ {
+ this.dict_data = dict_data;
+ this.sobjs_data = sobjs_data;
+ this.timeout = timeout;
+ this.last_access = DateTime.Now;
+ }
+
+ public byte [] DictionaryData {
+ get { return dict_data; }
+ set { dict_data = value; }
+ }
+
+ public byte [] StaticObjectsData {
+ get { return sobjs_data; }
+ set { sobjs_data = value; }
+ }
+
+ public void Touch ()
+ {
+ last_access = DateTime.Now;
+ }
+
+ public bool IsAbandoned () {
+ if (last_access.AddMinutes (timeout) < DateTime.Now)
+ return true;
+ return false;
+ }
+ }
+}
+
diff --git a/mcs/class/System.Web/System.Web.UI.HtmlControls/ChangeLog b/mcs/class/System.Web/System.Web.UI.HtmlControls/ChangeLog
index d9ae81d1dd1..258c6038e55 100644
--- a/mcs/class/System.Web/System.Web.UI.HtmlControls/ChangeLog
+++ b/mcs/class/System.Web/System.Web.UI.HtmlControls/ChangeLog
@@ -1,3 +1,13 @@
+2003-11-25 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * HtmlSelect.cs: don't add items without data. Patch by Alon Gazit
+ <along@mainsoft.com>. Fixes bug #51377.
+
+2003-11-24 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * HtmlInputRadioButton.cs: initialize event indexer. Patch by Alon Gazit
+ <along@mainsoft.com>.
+
2003-10-29 Jackson Harper <jackson@ximian.com>
* HtmlControl.cs: Make disabled an attribute of the control so it
diff --git a/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlInputFile.cs b/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlInputFile.cs
index 75d2d033a01..ef396ee4edb 100755
--- a/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlInputFile.cs
+++ b/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlInputFile.cs
@@ -82,6 +82,23 @@ namespace System.Web.UI.HtmlControls{
return Context.Request.Files[RenderedName];
}
}
+
+#if NET_1_1
+ [Browsable (false)]
+ public override string Value {
+ get {
+ HttpPostedFile file = PostedFile;
+ if (file == null)
+ return "";
+
+ return file.FileName;
+ }
+
+ set {
+ throw new NotSupportedException ();
+ }
+ }
+#endif
} // class HtmlInputFile
} // namespace System.Web.UI.HtmlControls
diff --git a/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlInputRadioButton.cs b/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlInputRadioButton.cs
index 68ebfde053f..5849c6e7190 100755
--- a/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlInputRadioButton.cs
+++ b/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlInputRadioButton.cs
@@ -15,7 +15,7 @@ namespace System.Web.UI.HtmlControls{
[DefaultEvent("ServerChange")]
public class HtmlInputRadioButton : HtmlInputControl, IPostBackDataHandler{
- private static readonly object EventServerChange;
+ private static readonly object EventServerChange = new object ();
public HtmlInputRadioButton(): base("radio"){}
diff --git a/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlSelect.cs b/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlSelect.cs
index eb0bd52bc50..29c9313e63c 100755
--- a/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlSelect.cs
+++ b/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlSelect.cs
@@ -88,7 +88,7 @@ namespace System.Web.UI.HtmlControls{
Items.Capacity = rdsCollection.Count;
bool valid = false;
- if (text.Length >= 0 && value.Length >= 0)
+ if (text.Length > 0 && value.Length > 0)
valid = true;
foreach (object current in resolvedDataSource) {
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/BaseDataList.cs b/mcs/class/System.Web/System.Web.UI.WebControls/BaseDataList.cs
index a89e246671a..03136fae87d 100755
--- a/mcs/class/System.Web/System.Web.UI.WebControls/BaseDataList.cs
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/BaseDataList.cs
@@ -163,24 +163,20 @@ namespace System.Web.UI.WebControls
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
[WebCategory("Data")]
[WebSysDescription("BaseDataList_DataSource")]
- public virtual object DataSource
- {
- get
- {
- return dataSource;
- }
- set
- {
- if( (value!=null) && (value is IListSource || value is IEnumerable) )
- {
- dataSource = value;
- } else
- {
- throw new ArgumentException(HttpRuntime.FormatResourceString("Invalid_DataSource_Type", ID));
- }
- }
- }
-
+ public virtual object DataSource {
+ get {
+ return dataSource;
+ }
+ set {
+ if (value == null || value is IListSource || value is IEnumerable) {
+ dataSource = value;
+ } else {
+ throw new ArgumentException (HttpRuntime.FormatResourceString (
+ "Invalid_DataSource_Type", ID));
+ }
+ }
+ }
+
[Bindable(true)]
[DefaultValue(GridLines.Both)]
[WebCategory("Appearance")]
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/Calendar.cs b/mcs/class/System.Web/System.Web.UI.WebControls/Calendar.cs
index eadac162220..bc6c67841ef 100755
--- a/mcs/class/System.Web/System.Web.UI.WebControls/Calendar.cs
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/Calendar.cs
@@ -779,9 +779,11 @@ namespace System.Web.UI.WebControls
}
protected override object SaveViewState()
- {
- ViewState["_CalendarSelectedDates"] = (SelectedDates.Count > 0 ? selectedDates.GetDateList () : null);
- object[] states = new object[11];
+ {
+ if (SelectedDates.Count > 0)
+ ViewState["_CalendarSelectedDates"] = selectedDates.GetDateList ();
+
+ object[] states = new object [10];
states[0] = base.SaveViewState();
states[1] = (dayHeaderStyle == null ? null : dayHeaderStyle.SaveViewState());
states[2] = (dayStyle == null ? null : dayStyle.SaveViewState());
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/ChangeLog b/mcs/class/System.Web/System.Web.UI.WebControls/ChangeLog
index 897458e6358..a97ae03790c 100644
--- a/mcs/class/System.Web/System.Web.UI.WebControls/ChangeLog
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/ChangeLog
@@ -1,3 +1,113 @@
+2003-11-29 Jackson Harper <jackson@ximian.com>
+
+ * DataGrid.cs: Display paging controls even when there is no
+ data. Path by Mohammad DAMT. Fixes bug #51487.
+
+2003-11-29 Jackson Harper <jackson@ximian.com>
+
+ * DataGrid.cs: Call TrackViewState when loading bound columns view
+ state. So that their state is saved. This fixes bug #51424. Also
+ set ReadOnly.
+
+2003-11-26 Jackson Harper <jackson@ximian.com>
+
+ * BaseDataList.cs: Change && to || We will call that a typo so no
+ one gets embarrased.
+
+2003-11-24 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * BaseDataList.cs: allow setting null as Datasource.
+
+ * DataGrid.cs: keep autogenerated columns in the ViewState.
+
+ Patches by Alon Gazit <along@mainsoft.com>.
+
+2003-11-22 Ben Maurer <bmaurer@users.sourceforge.net>
+
+ * SqlDataSource*: Implement almost everything. Data access is
+ still missing.
+
+2003-11-22 Ben Maurer <bmaurer@users.sourceforge.net>
+
+ * Calendar.cs (SaveViewState):
+ - We were allocating a 11 item array, we only used 10 items,
+ so only allocate 10.
+ - We only need to save the selected dates if there are any.
+ * DataGrid.cs (SaveViewState):
+ * DataGridColumn.cs (SaveViewState):
+ * DataGridColumnCollection.cs (SaveViewState):
+ - Only return the array if there is anything in it
+ * Style.cs (SaveViewState):
+ - Only save the bits if there were changes.
+ * WebControl.cs (SaveViewState), (LoadViewState):
+ - Don't save Enabled into the viewstate here, we already
+ do it in the property. This just caused *EVERY* control
+ to have a non-null state, taking up lots of extra room
+ in the ViewState.
+ - The style will always be created with this control's
+ viewstate, so the style will always return null for the
+ viewstate. As such, we do not need to store it. We can
+ also reduce the triplet to a pair because of this.
+
+2003-11-22 Jackson Harper <jackson@ximian.com>
+
+ * ValidationSummary.cs: Fix number of messages and message array computation.
+
+2003-11-21 Andreas Nahr <ClassDevelopment@A-SoftTech.com>
+
+ * Xml.cs: Corrected attribute
+ * XmlBuilder.cs: Added
+
+2003-11-21 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * Xml.cs: class status based fixes.
+
+2003-11-19 Jackson Harper <jackson@ximian.com>
+
+ * HyperLink.cs: Use ResolveUrl instead of ResolveBaseUrl.
+
+2003-11-19 Jackson Harper <jackson@ximian.com>
+
+ * HyperLink.cs: Use ResolveBaseUrl so that ~/ is interpreted as
+ teh applications base directory. This fixes bug #51092.
+
+2003-11-18 Todd Berman <tberman@gentoo.org>
+
+ * ControlParameter.cs:
+ * CookieParameter.cs:
+ * FormParameter.cs:
+ * QueryStringParameter.cs:
+ * SessionParameter.cs: added public .ctor ()
+ * Parameter.cs: added public .ctor (), internal SetOwnerCollection
+ and handling, as well as internal ParameterValue for easy access.
+ NOTE: ParameterValue doesnt respect TreatEmptyStringAsNull yet.
+ * ParameterCollection.cs: implementation redux.
+
+2003-11-18 Todd Berman <tberman@gentoo.org>
+
+ * ParameterCollection.cs: Implemented
+ * Parameter.cs: Added _owner, SetOwnerCollection and proper handling.
+ ToString () now matches asp.net
+
+2003-11-17 Ben Maurer <bmaurer@users.sourceforge.net>
+
+ * ControlParameter.cs:
+ * CookieParameter.cs:
+ * FormParameter.cs:
+ * Parameter.cs:
+ * QueryStringParameter.cs: New v2 files. Mostly
+ implemented, still need a few methods.
+
+2003-11-16 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * ListItem.cs: prevent nullrefs ni Get/SetAttribute. Thanks to Alon
+ Gazit <along@mainsoft.com>.
+
+2003-11-13 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * RadioButton.cs: fixed RenderInputTag for negative TabIndex values.
+ Patch by Alon Gazit <along@mainsoft.com>.
+
2003-11-09 Ben Maurer <bmaurer@users.sourceforge.net>
* DataBoundControl.cs: Implement
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/ControlParameter.cs b/mcs/class/System.Web/System.Web.UI.WebControls/ControlParameter.cs
new file mode 100644
index 00000000000..c3f8868a451
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/ControlParameter.cs
@@ -0,0 +1,91 @@
+//
+// System.Web.UI.WebControls.ControlParameter
+//
+// Authors:
+// Ben Maurer (bmaurer@users.sourceforge.net)
+//
+// (C) 2003 Ben Maurer
+//
+
+#if NET_1_2
+using System.Collections;
+using System.Collections.Specialized;
+using System.Text;
+
+namespace System.Web.UI.WebControls {
+ public class ControlParameter : Parameter {
+
+ public ControlParameter () : base ()
+ {
+ }
+
+ protected ControlParameter (ControlParameter original) : base (original)
+ {
+ this.ControlID = original.ControlID;
+ this.PropertyName = original.PropertyName;
+ }
+
+ public ControlParameter (string name, string controlID) : base (name)
+ {
+ ControlID = controlID;
+ }
+
+ public ControlParameter (string name, string controlID, string propertyName) : base (name)
+ {
+ ControlID = controlID;
+ PropertyName = propertyName;
+ }
+
+ public ControlParameter (string name, TypeCode type, string controlID, string propertyName) : base (name, type)
+ {
+ ControlID = controlID;
+ PropertyName = propertyName;
+ }
+
+ protected override Parameter Clone ()
+ {
+ return new ControlParameter (this);
+ }
+
+ [MonoTODO]
+ protected override object Evaluate (Control control)
+ {
+ throw new NotImplementedException ();
+ }
+
+ public string ControlID {
+ get {
+ string s = ViewState ["ControlID"] as string;
+ if (s != null)
+ return s;
+
+ return "";
+ }
+ set {
+ if (ControlID != value) {
+ ViewState ["ControlID"] = value;
+ OnParameterChanged ();
+ }
+ }
+ }
+
+ public string PropertyName {
+ get {
+ string s = ViewState ["PropertyName"] as string;
+ if (s != null)
+ return s;
+
+ return "";
+ }
+ set {
+
+ if (PropertyName != value) {
+ ViewState ["PropertyName"] = value;
+ OnParameterChanged ();
+ }
+ }
+ }
+ }
+}
+#endif
+
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/CookieParameter.cs b/mcs/class/System.Web/System.Web.UI.WebControls/CookieParameter.cs
new file mode 100644
index 00000000000..b6d269050b6
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/CookieParameter.cs
@@ -0,0 +1,74 @@
+//
+// System.Web.UI.WebControls.CookieParameter
+//
+// Authors:
+// Ben Maurer (bmaurer@users.sourceforge.net)
+//
+// (C) 2003 Ben Maurer
+//
+
+#if NET_1_2
+using System.Collections;
+using System.Collections.Specialized;
+using System.Text;
+
+namespace System.Web.UI.WebControls {
+ public class CookieParameter : Parameter {
+
+ public CookieParameter () : base ()
+ {
+ }
+
+ protected CookieParameter (CookieParameter original) : base (original)
+ {
+ this.CookieName = original.CookieName;
+ }
+
+ public CookieParameter (string name, string cookieName) : base (name)
+ {
+ CookieName = cookieName;
+ }
+
+ public CookieParameter (string name, TypeCode type, string cookieName) : base (name, type)
+ {
+ CookieName = cookieName;
+ }
+
+ protected override Parameter Clone()
+ {
+ return new CookieParameter (this);
+ }
+
+ protected override object Evaluate (Control control)
+ {
+ if (control == null || control.Page == null || control.Page.Request == null)
+ return null;
+
+ HttpCookie c = control.Page.Request.Cookies [CookieName];
+ if (c == null)
+ return null;
+
+ return c.Value;
+ }
+
+ public string CookieName {
+ get {
+ string s = ViewState ["CookieName"] as string;
+ if (s != null)
+ return s;
+
+ return "";
+ }
+ set {
+ if (CookieName != value) {
+ ViewState ["CookieName"] = value;
+ OnParameterChanged ();
+ }
+ }
+ }
+
+
+ }
+}
+#endif
+
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/DataGrid.cs b/mcs/class/System.Web/System.Web.UI.WebControls/DataGrid.cs
index e1bb56d4e9c..b875eadf846 100644
--- a/mcs/class/System.Web/System.Web.UI.WebControls/DataGrid.cs
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/DataGrid.cs
@@ -658,35 +658,48 @@ namespace System.Web.UI.WebControls
protected override void LoadViewState(object savedState)
{
- if(savedState != null)
- {
- object[] states = (object[])savedState;
- if(states != null)
- {
- base.LoadViewState(states[0]);
- if(columns != null)
- ((IStateManager)columns).LoadViewState(states[1]);
- if(pagerStyle != null)
- pagerStyle.LoadViewState(states[2]);
- if(headerStyle != null)
- headerStyle.LoadViewState(states[3]);
- if(footerStyle != null)
- footerStyle.LoadViewState(states[4]);
- if(itemStyle != null)
- itemStyle.LoadViewState(states[5]);
- if(alternatingItemStyle != null)
- alternatingItemStyle.LoadViewState(states[6]);
- if(selectedItemStyle != null)
- selectedItemStyle.LoadViewState(states[7]);
- if(editItemStyle != null)
- editItemStyle.LoadViewState(states[8]);
- }
+ if (savedState == null)
+ return;
+
+ object [] states = (object []) savedState;
+ base.LoadViewState (states[0]);
+ if(columns != null)
+ ((IStateManager)columns).LoadViewState(states[1]);
+ if(pagerStyle != null)
+ pagerStyle.LoadViewState(states[2]);
+ if(headerStyle != null)
+ headerStyle.LoadViewState(states[3]);
+ if(footerStyle != null)
+ footerStyle.LoadViewState(states[4]);
+ if(itemStyle != null)
+ itemStyle.LoadViewState(states[5]);
+ if(alternatingItemStyle != null)
+ alternatingItemStyle.LoadViewState(states[6]);
+ if(selectedItemStyle != null)
+ selectedItemStyle.LoadViewState(states[7]);
+ if(editItemStyle != null)
+ editItemStyle.LoadViewState(states[8]);
+
+ if (states [9] != null) {
+ object[] array = ((object[]) states [9]);
+ if (array.Length != 0)
+ this.autoGenColsArrayList = new ArrayList ();
+ else
+ this.autoGenColsArrayList = null;
+
+ for (int i = 0; i < array.Length; i++) {
+ BoundColumn column1 = new BoundColumn ();
+ ((IStateManager)column1).TrackViewState ();
+ ((IStateManager)column1).LoadViewState (array [i]);
+ column1.SetOwner (this);
+ this.autoGenColsArrayList.Add (column1);
+ }
}
}
protected override object SaveViewState()
{
- object[] states = new object[9];
+ object[] states = new object [10];
states[0] = base.SaveViewState();
states[1] = (columns == null ? null : ((IStateManager)columns).SaveViewState());
states[2] = (pagerStyle == null ? null : pagerStyle.SaveViewState());
@@ -696,7 +709,22 @@ namespace System.Web.UI.WebControls
states[6] = (alternatingItemStyle == null ? null : alternatingItemStyle.SaveViewState());
states[7] = (selectedItemStyle == null ? null : selectedItemStyle.SaveViewState());
states[8] = (editItemStyle == null ? null : editItemStyle.SaveViewState());
- return states;
+
+ object [] array = null;
+ if ((this.autoGenColsArrayList != null) && (this.autoGenColsArrayList.Count != 0)) {
+ array = new object [((uint) this.autoGenColsArrayList.Count)];
+ for (int i = 0; i < array.Length; i++)
+ array [i] = ((IStateManager) this.autoGenColsArrayList [i]).SaveViewState ();
+ }
+
+ states [9] = array;
+
+ for (int i = states.Length - 1; i >= 0; i--) {
+ if (states [i] != null)
+ return states;
+ }
+
+ return null;
}
protected override void TrackViewState()
@@ -1298,19 +1326,26 @@ namespace System.Web.UI.WebControls
toAdd.Controls.Add(label);
}
toAdd.Controls.Add(new LiteralControl("&nbsp;"));
- if(!pagedDataSource.IsLastPage)
- {
- LinkButton link = new DataGridLinkButton();
- link.Text = PagerStyle.NextPageText;
- link.CommandName = "Page";
- link.CommandArgument = "Next";
- link.CausesValidation = false;
- toAdd.Controls.Add(link);
- } else
- {
+
+ if (pagedDataSource.PageCount == 0) {
Label label = new Label();
label.Text = PagerStyle.NextPageText;
toAdd.Controls.Add(label);
+ } else {
+ if(!pagedDataSource.IsLastPage)
+ {
+ LinkButton link = new DataGridLinkButton();
+ link.Text = PagerStyle.NextPageText;
+ link.CommandName = "Page";
+ link.CommandArgument = "Next";
+ link.CausesValidation = false;
+ toAdd.Controls.Add(link);
+ } else
+ {
+ Label label = new Label();
+ label.Text = PagerStyle.NextPageText;
+ toAdd.Controls.Add(label);
+ }
}
} else
{
@@ -1322,6 +1357,7 @@ namespace System.Web.UI.WebControls
numberOfPages = pageCount;
int firstPageNumber = 1; // 10
int lastPageNumber = numberOfPages; // 11
+
if(currPage > lastPageNumber)
{
firstPageNumber = (pagedDataSource.CurrentPageIndex / btnCount) * btnCount + 1;
@@ -1341,25 +1377,31 @@ namespace System.Web.UI.WebControls
toAdd.Controls.Add(toAddBtn);
toAdd.Controls.Add(new LiteralControl("&nbsp;"));
}
- for(int i = firstPageNumber; i <= lastPageNumber; i++)
- {
- string argText = i.ToString(NumberFormatInfo.InvariantInfo);
- if(i == currPage)
- {
- Label cPageLabel = new Label();
- cPageLabel.Text = argText;
- toAdd.Controls.Add(cPageLabel);
- } else
+ if (lastPageNumber == 0) {
+ Label cPageLabel = new Label();
+ cPageLabel.Text = "1";
+ toAdd.Controls.Add(cPageLabel);
+ } else {
+ for(int i = firstPageNumber; i <= lastPageNumber; i++)
{
- LinkButton indexButton = new DataGridLinkButton();
- indexButton.Text = argText;
- indexButton.CommandName = "Page";
- indexButton.CommandArgument = argText;
- indexButton.CausesValidation = false;
- toAdd.Controls.Add(indexButton);
+ string argText = i.ToString(NumberFormatInfo.InvariantInfo);
+ if(i == currPage)
+ {
+ Label cPageLabel = new Label();
+ cPageLabel.Text = argText;
+ toAdd.Controls.Add(cPageLabel);
+ } else
+ {
+ LinkButton indexButton = new DataGridLinkButton();
+ indexButton.Text = argText;
+ indexButton.CommandName = "Page";
+ indexButton.CommandArgument = argText;
+ indexButton.CausesValidation = false;
+ toAdd.Controls.Add(indexButton);
+ }
+ if(i < lastPageNumber)
+ toAdd.Controls.Add(new LiteralControl("&nbsp;"));
}
- if(i < lastPageNumber)
- toAdd.Controls.Add(new LiteralControl("&nbsp;"));
}
if(pageCount > lastPageNumber)
{
@@ -1463,7 +1505,7 @@ namespace System.Web.UI.WebControls
if(IsBindableType(prop_type))
{
b_col = new BoundColumn();
- // b_col.TrackViewState();
+ ((IStateManager)b_col).TrackViewState();
b_col.HeaderText = "Item";
b_col.SortExpression = "Item";
b_col.DataField = BoundColumn.thisExpr;
@@ -1486,11 +1528,11 @@ namespace System.Web.UI.WebControls
if(IsBindableType(current.PropertyType))
{
b_col = new BoundColumn();
- // b_col.TrackViewState();
+ ((IStateManager)b_col).TrackViewState();
b_col.HeaderText = current.Name;
b_col.SortExpression = current.Name;
b_col.DataField = current.Name;
- // b_col.IsReadOnly = current.IsReadOnly;
+ b_col.ReadOnly = current.IsReadOnly;
b_col.SetOwner(this);
retVal.Add(b_col);
}
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/DataGridColumn.cs b/mcs/class/System.Web/System.Web.UI.WebControls/DataGridColumn.cs
index 007d00cdb9f..275867644bb 100644
--- a/mcs/class/System.Web/System.Web.UI.WebControls/DataGridColumn.cs
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/DataGridColumn.cs
@@ -360,7 +360,12 @@ namespace System.Web.UI.WebControls
states[1] = (footerStyle == null ? null : footerStyle.SaveViewState());
states[2] = (headerStyle == null ? null : headerStyle.SaveViewState());
states[3] = (itemStyle == null ? null : itemStyle.SaveViewState());
- return states;
+
+ for (int i = 0; i < states.Length; i++) {
+ if (states [i] != null)
+ return states;
+ }
+ return null;
}
protected virtual void LoadViewState(object savedState)
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/DataGridColumnCollection.cs b/mcs/class/System.Web/System.Web.UI.WebControls/DataGridColumnCollection.cs
index a2702f665d0..c247dcde350 100644
--- a/mcs/class/System.Web/System.Web.UI.WebControls/DataGridColumnCollection.cs
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/DataGridColumnCollection.cs
@@ -160,10 +160,18 @@ namespace System.Web.UI.WebControls
if (columns.Count == 0)
return null;
- ArrayList retVal = new ArrayList (columns.Count);
- foreach (IStateManager current in columns)
- retVal.Add (current.SaveViewState ());
+ ArrayList retVal = new ArrayList (columns.Count);
+ bool found = false;
+ foreach (IStateManager current in columns) {
+ object o = current.SaveViewState ();
+ retVal.Add (o);
+ if (o != null)
+ found = true;
+ }
+ if (!found)
+ return null;
+
return retVal;
}
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/FormParameter.cs b/mcs/class/System.Web/System.Web.UI.WebControls/FormParameter.cs
new file mode 100644
index 00000000000..8c2903fcb93
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/FormParameter.cs
@@ -0,0 +1,68 @@
+//
+// System.Web.UI.WebControls.FormParameter
+//
+// Authors:
+// Ben Maurer (bmaurer@users.sourceforge.net)
+//
+// (C) 2003 Ben Maurer
+//
+
+#if NET_1_2
+using System.Collections;
+using System.Collections.Specialized;
+using System.Text;
+
+namespace System.Web.UI.WebControls {
+ public class FormParameter : Parameter {
+
+ public FormParameter () : base ()
+ {
+ }
+
+ protected FormParameter (FormParameter original) : base (original)
+ {
+ this.FormField = original.FormField;
+ }
+
+ public FormParameter (string name, string formField) : base (name)
+ {
+ FormField = formField;
+ }
+
+ public FormParameter (string name, TypeCode type, string formField) : base (name, type)
+ {
+ FormField = formField;
+ }
+
+ protected override Parameter Clone ()
+ {
+ return new FormParameter (this);
+ }
+
+ protected override object Evaluate (Control control)
+ {
+ if (control == null || control.Page == null || control.Page.Request == null)
+ return null;
+
+ return control.Page.Request.Form [FormField];
+ }
+
+ public string FormField {
+ get {
+ string s = ViewState ["FormField"] as string;
+ if (s != null)
+ return s;
+
+ return "";
+ }
+ set {
+ if (FormField != value) {
+ ViewState ["FormField"] = value;
+ OnParameterChanged ();
+ }
+ }
+ }
+ }
+}
+#endif
+
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/HyperLink.cs b/mcs/class/System.Web/System.Web.UI.WebControls/HyperLink.cs
index 3537945286b..c58b03637b4 100755
--- a/mcs/class/System.Web/System.Web.UI.WebControls/HyperLink.cs
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/HyperLink.cs
@@ -115,8 +115,9 @@ namespace System.Web.UI.WebControls
{
base.AddAttributesToRender(writer);
if(NavigateUrl.Length > 0)
- {
- writer.AddAttribute(HtmlTextWriterAttribute.Href, NavigateUrl);
+ {
+ string url = ResolveUrl (NavigateUrl);
+ writer.AddAttribute(HtmlTextWriterAttribute.Href, url);
}
if(Target.Length > 0)
{
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/ListItem.cs b/mcs/class/System.Web/System.Web.UI.WebControls/ListItem.cs
index 069188bec15..1c090047ff3 100644
--- a/mcs/class/System.Web/System.Web.UI.WebControls/ListItem.cs
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/ListItem.cs
@@ -127,17 +127,20 @@ namespace System.Web.UI.WebControls
dirty_v = true;
}
}
-
- string IAttributeAccessor.GetAttribute(string key)
- {
- return attributes[key];
- }
-
- void IAttributeAccessor.SetAttribute(string key, string value)
- {
- attributes[key] = value;
- }
-
+
+ string IAttributeAccessor.GetAttribute (string key)
+ {
+ if (attributes == null)
+ return null;
+
+ return attributes [key];
+ }
+
+ void IAttributeAccessor.SetAttribute (string key, string value)
+ {
+ Attributes [key] = value;
+ }
+
/// <remarks>
/// The data is parsed - object must be of type LiteralControl or DataBoundLiteralControl.
/// In latter case, throw an exception telling that the data cannot be bind-ed.
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/Parameter.cs b/mcs/class/System.Web/System.Web.UI.WebControls/Parameter.cs
new file mode 100644
index 00000000000..9a6126fbf8e
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/Parameter.cs
@@ -0,0 +1,240 @@
+//
+// System.Web.UI.WebControls.Parameter
+//
+// Authors:
+// Ben Maurer (bmaurer@users.sourceforge.net)
+//
+// (C) 2003 Ben Maurer
+//
+
+#if NET_1_2
+using System.Collections;
+using System.Collections.Specialized;
+using System.Text;
+using System.Data;
+
+namespace System.Web.UI.WebControls {
+ public class Parameter : ICloneable, IStateManager {
+
+ public Parameter () : base ()
+ {
+ }
+
+ protected Parameter (Parameter original)
+ {
+ this.DefaultValue = original.DefaultValue;
+ this.Direction = original.Direction;
+ this.TreatEmptyStringAsNull = original.TreatEmptyStringAsNull;
+ this.Type = original.Type;
+ this.Name = original.Name;
+ }
+
+ public Parameter (string name)
+ {
+ this.Name = name;
+ }
+
+ public Parameter(string name, TypeCode type) : this (name)
+ {
+ this.Type = type;
+ }
+
+ public Parameter (string name, TypeCode type, string defaultValue) : this (name, type)
+ {
+ this.DefaultValue = defaultValue;
+ }
+
+ protected virtual Parameter Clone ()
+ {
+ return new Parameter (this);
+ }
+
+ protected virtual object Evaluate (Control control)
+ {
+ return this.DefaultValue;
+ }
+
+ protected void OnParameterChanged ()
+ {
+ if (_owner != null)
+ _owner.CallOnParameterChanged ();
+ }
+
+ protected virtual void LoadViewState (object savedState)
+ {
+ if (savedState == null)
+ return;
+
+ ViewState.LoadViewState (savedState);
+ }
+
+ protected virtual object SaveViewState ()
+ {
+ if (viewState == null)
+ return null;
+ return viewState.SaveViewState ();
+ }
+
+ protected virtual void TrackViewState ()
+ {
+ isTrackingViewState = true;
+ if (viewState != null)
+ viewState.TrackViewState ();
+ }
+
+ object ICloneable.Clone ()
+ {
+ return this.Clone ();
+ }
+
+ void IStateManager.LoadViewState (object savedState)
+ {
+ this.LoadViewState (savedState);
+ }
+
+ object IStateManager.SaveViewState ()
+ {
+ return this.SaveViewState ();
+ }
+
+ void IStateManager.TrackViewState ()
+ {
+ this.TrackViewState ();
+ }
+
+ bool IStateManager.IsTrackingViewState {
+ get { return this.IsTrackingViewState; }
+ }
+
+ [MonoTODO]
+ public override string ToString ()
+ {
+ return base.ToString ();
+ }
+
+ public string DefaultValue {
+ get {
+ return ViewState ["DefaultValue"] as string;
+ }
+ set {
+
+ if (DefaultValue != value) {
+ ViewState ["DefaultValue"] = value;
+ OnParameterChanged ();
+ }
+ }
+ }
+
+ public ParameterDirection Direction {
+ get {
+ object o = ViewState ["Direction"];
+ if (o != null)
+ return (ParameterDirection) o;
+
+ return ParameterDirection.Input;
+ }
+ set {
+
+ if (Direction != value) {
+ ViewState ["Direction"] = value;
+ OnParameterChanged ();
+ }
+ }
+ }
+
+
+ public string Name {
+ get {
+ string s = ViewState ["Name"] as string;
+ if (s != null)
+ return s;
+
+ return "";
+ }
+ set {
+
+ if (Name != value) {
+ ViewState ["Name"] = value;
+ OnParameterChanged ();
+ }
+ }
+ }
+
+ public bool TreatEmptyStringAsNull {
+ get {
+ object o = ViewState ["TreatEmptyStringAsNull"];
+ if (o != null)
+ return (bool) o;
+
+ return false;
+ }
+ set {
+
+ if (TreatEmptyStringAsNull != value) {
+ ViewState ["TreatEmptyStringAsNull"] = value;
+ OnParameterChanged ();
+ }
+ }
+ }
+
+ public TypeCode Type {
+ get {
+ object o = ViewState ["Type"];
+ if (o != null)
+ return (TypeCode) o;
+
+ return TypeCode.Object;
+ }
+ set {
+
+ if (Type != value) {
+ ViewState ["Type"] = value;
+ OnParameterChanged ();
+ }
+ }
+ }
+
+ StateBag viewState;
+
+ protected StateBag ViewState {
+ get {
+ if (viewState == null) {
+ viewState = new StateBag ();
+ if (IsTrackingViewState)
+ viewState.TrackViewState ();
+ }
+ return viewState;
+ }
+ }
+
+ bool isTrackingViewState = false;
+ protected bool IsTrackingViewState {
+ get { return isTrackingViewState; }
+ }
+
+ private ParameterCollection _owner;
+
+ internal void SetOwnerCollection (ParameterCollection own)
+ {
+ _owner = own;
+ }
+
+ internal object ParameterValue {
+ get {
+ object param = ViewState["ParameterValue"];
+ //FIXME: need to do some null string checking magic with TreatEmptyStringAsNull here
+ if (param == null)
+ {
+ param = DefaultValue;
+ if (param == null)
+ {
+ return null;
+ }
+ }
+ return Convert.ChangeType (param, Type);
+ }
+ }
+ }
+}
+#endif
+
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/ParameterCollection.cs b/mcs/class/System.Web/System.Web.UI.WebControls/ParameterCollection.cs
new file mode 100644
index 00000000000..244f6518660
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/ParameterCollection.cs
@@ -0,0 +1,199 @@
+//
+// System.Web.UI.WebControls/ParameterCollection.cs
+//
+// Author: Todd Berman <tberman@gentoo.org>
+//
+// (C) 2003 Todd Berman
+
+#if NET_1_2
+
+using System.Web.UI;
+using System.Collections;
+using System.Collections.Specialized;
+
+namespace System.Web.UI.WebControls
+{
+
+ public class ParameterCollection : StateManagedCollection
+ {
+
+ private static Type[] _knownTypes = new Type[] {
+ typeof (ControlParameter),
+ typeof (CookieParameter),
+ typeof (FormParameter),
+ typeof (Parameter),
+ typeof (QueryStringParameter),
+ typeof (SessionParameter) };
+
+ private EventHandler _parametersChanged;
+ private KeyedList _values;
+
+
+ public int Add (Parameter param)
+ {
+ return ((IList)this).Add (param);
+ }
+
+ public int Add (string name, string value)
+ {
+ return ((IList)this).Add (new Parameter (name, TypeCode.Object, value));
+ }
+
+ public int Add (string name, TypeCode type, string value)
+ {
+ return ((IList)this).Add (new Parameter (name, type, value));
+ }
+
+ protected override object CreateKnownType (int idx)
+ {
+ switch (idx) {
+ case 0:
+ return new ControlParameter ();
+ break;
+ case 1:
+ return new CookieParameter ();
+ break;
+ case 2:
+ return new FormParameter ();
+ break;
+ case 3:
+ return new Parameter ();
+ break;
+ case 4:
+ return new QueryStringParameter ();
+ break;
+ case 5:
+ return new SessionParameter ();
+ break;
+ }
+
+ throw new ArgumentOutOfRangeException ("index");
+ }
+
+ protected override Type[] GetKnownTypes ()
+ {
+ return _knownTypes;
+ }
+
+ public IOrderedDictionary GetValues (Control control)
+ {
+ if (_values == null)
+ {
+ _values = new KeyedList ();
+ foreach (Parameter param in this)
+ {
+ string name = param.Name;
+ for (int i = 1; _values.Contains (name); i++)
+ {
+ name = param.Name + i.ToString ();
+ }
+ _values.Add (name, param.ParameterValue);
+ }
+ }
+ return _values;
+ }
+
+ public void Insert (int idx, Parameter param)
+ {
+ ((IList)this).Insert (idx, param);
+ }
+
+ protected override void OnClearComplete ()
+ {
+ base.OnClearComplete ();
+ OnParametersChanged (EventArgs.Empty);
+ }
+
+ protected override void OnInsert (int idx, object value)
+ {
+ base.OnInsert (idx, value);
+ ((Parameter)value).SetOwnerCollection (this);
+ }
+
+ protected override void OnInsertComplete (int idx, object value)
+ {
+ base.OnInsertComplete (idx, value);
+ OnParametersChanged (EventArgs.Empty);
+ }
+
+ protected virtual void OnParametersChanged (EventArgs e)
+ {
+ if (_parametersChanged != null)
+ _parametersChanged(this, e);
+
+ _values = null;
+ }
+
+ protected override void OnValidate (object o)
+ {
+ base.OnValidate (o);
+
+ if ((o is Parameter) == false)
+ throw new ArgumentException ("o is not a Parameter");
+ }
+
+ public void Remove (Parameter param)
+ {
+ ((IList)this).Remove (param);
+ }
+
+ public void RemoveAt (int idx)
+ {
+ ((IList)this).RemoveAt (idx);
+ }
+
+ [MonoTODO("eh?")]
+ protected override void SetDirtyObject (object o)
+ {
+ throw new NotImplementedException ();
+ }
+
+ internal void CallOnParameterChanged ()
+ {
+ OnParametersChanged (EventArgs.Empty);
+ }
+
+ private int IndexOfString (string name)
+ {
+ for (int i = 0; i < Count; i++)
+ {
+ if (((Parameter)((IList)this)[i]).Name == name)
+ return i;
+ }
+ return -1;
+ }
+
+ public Parameter this[int idx] {
+ get {
+ return (Parameter) ((IList)this)[idx];
+ }
+ set {
+ ((IList)this)[idx] = value;
+ }
+ }
+
+ public Parameter this[string name] {
+ get {
+ int idx = IndexOfString (name);
+ if (idx == -1)
+ return null;
+ return ((Parameter) ((IList)this)[idx]);
+ }
+ set {
+ int idx = IndexOfString (name);
+ if (idx == -1) {
+ Add (value);
+ return;
+ }
+ ((IList)this)[idx] = value;
+ }
+ }
+
+ public event EventHandler ParametersChanged {
+ add { _parametersChanged += value; }
+ remove { _parametersChanged -= value; }
+ }
+ }
+}
+
+#endif
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/QueryStringParameter.cs b/mcs/class/System.Web/System.Web.UI.WebControls/QueryStringParameter.cs
new file mode 100644
index 00000000000..aeab80ef497
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/QueryStringParameter.cs
@@ -0,0 +1,69 @@
+//
+// System.Web.UI.WebControls.QueryStringParameter
+//
+// Authors:
+// Ben Maurer (bmaurer@users.sourceforge.net)
+//
+// (C) 2003 Ben Maurer
+//
+
+#if NET_1_2
+using System.Collections;
+using System.Collections.Specialized;
+using System.Text;
+
+namespace System.Web.UI.WebControls {
+ public class QueryStringParameter : Parameter {
+
+ public QueryStringParameter () : base ()
+ {
+ }
+
+ protected QueryStringParameter (QueryStringParameter original) : base (original)
+ {
+ this.QueryStringField = original.QueryStringField;
+
+ }
+
+ public QueryStringParameter (string name, string queryStringField) : base (name)
+ {
+ QueryStringField = queryStringField;
+ }
+
+ public QueryStringParameter (string name, TypeCode type, string queryStringField) : base (name, type)
+ {
+ QueryStringField = queryStringField;
+ }
+
+ protected override Parameter Clone ()
+ {
+ return new QueryStringParameter (this);
+ }
+
+ protected override object Evaluate (Control control)
+ {
+ if (control == null || control.Page == null || control.Page.Request == null)
+ return null;
+
+ return control.Page.Request.QueryString [QueryStringField];
+ }
+
+ public string QueryStringField {
+ get {
+ string s = ViewState ["QueryStringField"] as string;
+ if (s != null)
+ return s;
+
+ return "";
+ }
+ set {
+ if (QueryStringField != value) {
+ ViewState ["QueryStringField"] = value;
+ OnParameterChanged ();
+ }
+ }
+ }
+ }
+}
+#endif
+
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/RadioButton.cs b/mcs/class/System.Web/System.Web.UI.WebControls/RadioButton.cs
index 333111f439e..bbabc89342f 100644
--- a/mcs/class/System.Web/System.Web.UI.WebControls/RadioButton.cs
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/RadioButton.cs
@@ -71,7 +71,7 @@ namespace System.Web.UI.WebControls
if (AccessKey.Length > 0)
writer.AddAttribute (HtmlTextWriterAttribute.Accesskey, AccessKey);
- if (TabIndex > 0)
+ if (TabIndex != 0)
writer.AddAttribute (HtmlTextWriterAttribute.Tabindex,
TabIndex.ToString (NumberFormatInfo.InvariantInfo));
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/SessionParameter.cs b/mcs/class/System.Web/System.Web.UI.WebControls/SessionParameter.cs
new file mode 100644
index 00000000000..fa7441b0a98
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/SessionParameter.cs
@@ -0,0 +1,68 @@
+//
+// System.Web.UI.WebControls.SessionParameter
+//
+// Authors:
+// Ben Maurer (bmaurer@users.sourceforge.net)
+//
+// (C) 2003 Ben Maurer
+//
+
+#if NET_1_2
+using System.Collections;
+using System.Collections.Specialized;
+using System.Text;
+
+namespace System.Web.UI.WebControls {
+ public class SessionParameter : Parameter {
+
+ public SessionParameter () : base ()
+ {
+ }
+
+ protected SessionParameter (SessionParameter original) : base (original)
+ {
+ this.SessionField = original.SessionField;
+ }
+
+ public SessionParameter (string name, string sessionField) : base (name)
+ {
+ SessionField = sessionField;
+ }
+
+ public SessionParameter (string name, TypeCode type, string sessionField) : base (name, type)
+ {
+ SessionField = sessionField;
+ }
+
+ protected override Parameter Clone ()
+ {
+ return new SessionParameter (this);
+ }
+
+ protected override object Evaluate (Control control)
+ {
+ if (control == null || control.Page == null || control.Page.Session == null)
+ return null;
+
+ return control.Page.Session [SessionField];
+ }
+
+ public string SessionField {
+ get {
+ string s = ViewState ["SessionField"] as string;
+ if (s != null)
+ return s;
+
+ return "";
+ }
+ set {
+ if (SessionField != value) {
+ ViewState ["SessionField"] = value;
+ OnParameterChanged ();
+ }
+ }
+ }
+ }
+}
+#endif
+
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/SqlDataSource.cs b/mcs/class/System.Web/System.Web.UI.WebControls/SqlDataSource.cs
new file mode 100644
index 00000000000..5ff0c9a80a6
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/SqlDataSource.cs
@@ -0,0 +1,228 @@
+//
+// System.Web.UI.WebControls.SqlDataSource
+//
+// Authors:
+// Ben Maurer (bmaurer@users.sourceforge.net)
+//
+// (C) 2003 Ben Maurer
+//
+
+#if NET_1_2
+using System.Collections;
+using System.Collections.Specialized;
+using System.Text;
+
+namespace System.Web.UI.WebControls {
+ public class SqlDataSource : DataSourceControl {
+
+ public SqlDataSource ()
+ {
+ }
+
+ public SqlDataSource (string connectionString, string selectCommand)
+ {
+ ConnectionString = connectionString;
+ SelectCommand = selectCommand;
+ }
+
+ public SqlDataSource (string providerName, string connectionString, string selectCommand)
+ {
+ ProviderName = providerName;
+ ConnectionString = connectionString;
+ SelectCommand = selectCommand;
+ }
+
+ protected override DataSourceView GetView (string viewName)
+ {
+ if (viewName == "" || viewName == null)
+ return View;
+ else
+ throw new ArgumentException ("viewName");
+ }
+
+ protected override ICollection GetViewNames ()
+ {
+ return new string [] { "DefaultView" };
+ }
+
+ public int Insert ()
+ {
+ return View.Insert ();
+ }
+
+ public int Delete ()
+ {
+ return View.Delete ();
+ }
+
+ public IEnumerable Select ()
+ {
+ return View.Select ();
+ }
+
+ public int Update ()
+ {
+ return View.Update ();
+ }
+
+ protected override void LoadViewState (object savedState)
+ {
+ Pair p = savedState as Pair;
+ if (p != null) {
+ base.LoadViewState (p.First);
+ ((IStateManager) View).LoadViewState (p.Second);
+ }
+ }
+
+ protected override object SaveViewState ()
+ {
+ object me = base.SaveViewState (), view = ((IStateManager) View).SaveViewState ();
+ if (me != null || view != null)
+ return new Pair (me, view);
+ else
+ return null;
+ }
+
+ protected override void TrackViewState ()
+ {
+ base.TrackViewState ();
+ ((IStateManager) View).TrackViewState ();
+ }
+
+ //protected virtual DataSourceCache Cache { get; }
+ //public virtual int CacheDuration { get; set; }
+ //public virtual DataSourceCacheExpiry CacheExpirationPolicy { get; set; }
+ //public virtual string CacheKeyDependency { get; set; }
+ //public virtual string SqlCacheDependency { get; set; }
+ //public virtual bool EnableCaching { get; set; }
+
+ public virtual string ProviderName {
+ get {
+ string val = ViewState ["ProviderName"] as string;
+ return val == null ? "System.Data.SqlClient" : val;
+ }
+ set { ViewState ["ProviderName"] = value; }
+ }
+
+
+ public virtual string ConnectionString {
+ get {
+ string val = ViewState ["ConnectionString"] as string;
+ return val == null ? "" : val;
+ }
+ set { ViewState ["ConnectionString"] = value; }
+ }
+
+ public SqlDataSourceMode DataSourceMode {
+ get {
+ object val = ViewState ["DataSourceMode"];
+ return val == null ? SqlDataSourceMode.DataSet : (SqlDataSourceMode) val;
+ }
+ set { ViewState ["DataSourceMode"] = value; }
+ }
+
+ public string DeleteCommand {
+ get { return View.DeleteCommand; }
+ set { View.DeleteCommand = value; }
+ }
+
+ public ParameterCollection DeleteParameters {
+ get { return View.DeleteParameters; }
+ }
+
+ public ParameterCollection FilterParameters {
+ get { return View.FilterParameters; }
+ }
+
+ public string InsertCommand {
+ get { return View.InsertCommand; }
+ set { View.InsertCommand = value; }
+ }
+ public ParameterCollection InsertParameters {
+ get { return View.InsertParameters; }
+ }
+
+ public string SelectCommand {
+ get { return View.SelectCommand; }
+ set { View.SelectCommand = value; }
+ }
+
+ public ParameterCollection SelectParameters {
+ get { return View.SelectParameters; }
+ }
+
+ public string UpdateCommand {
+ get { return View.UpdateCommand; }
+ set { View.UpdateCommand = value; }
+ }
+
+ public ParameterCollection UpdateParameters {
+ get { return View.UpdateParameters; }
+ }
+
+ public string FilterExpression {
+ get { return View.FilterExpression; }
+ set { View.FilterExpression = value; }
+ }
+
+ public event SqlDataSourceStatusEventHandler Deleted {
+ add { View.Deleted += value; }
+ remove { View.Deleted -= value; }
+ }
+
+ public event SqlDataSourceCommandEventHandler Deleting {
+ add { View.Deleting += value; }
+ remove { View.Deleting -= value; }
+ }
+
+ public event SqlDataSourceStatusEventHandler Inserted {
+ add { View.Inserted += value; }
+ remove { View.Inserted -= value; }
+ }
+
+ public event SqlDataSourceCommandEventHandler Inserting {
+ add { View.Inserting += value; }
+ remove { View.Inserting -= value; }
+ }
+
+ public event SqlDataSourceStatusEventHandler Selected {
+ add { View.Selected += value; }
+ remove { View.Selected -= value; }
+ }
+
+ public event SqlDataSourceCommandEventHandler Selecting {
+ add { View.Selecting += value; }
+ remove { View.Selecting -= value; }
+ }
+
+ public event SqlDataSourceStatusEventHandler Updated {
+ add { View.Updated += value; }
+ remove { View.Updated -= value; }
+ }
+
+ public event SqlDataSourceCommandEventHandler Updating {
+ add { View.Updating += value; }
+ remove { View.Updating -= value; }
+ }
+
+ SqlDataSourceView view;
+ SqlDataSourceView View {
+ get {
+ if (view == null) {
+ view = new SqlDataSourceView (this, "DefaultView");
+ view.DataSourceViewChanged += new EventHandler (ViewChanged);
+ if (IsTrackingViewState)
+ ((IStateManager) view).TrackViewState ();
+ }
+ return view;
+ }
+ }
+
+ void ViewChanged (object source, EventArgs e)
+ {
+ OnDataSourceChanged (e);
+ }
+ }
+}
+#endif
+
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/SqlDataSourceCommandEventArgs.cs b/mcs/class/System.Web/System.Web.UI.WebControls/SqlDataSourceCommandEventArgs.cs
new file mode 100644
index 00000000000..ee37adb7306
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/SqlDataSourceCommandEventArgs.cs
@@ -0,0 +1,32 @@
+//
+// System.Web.UI.WebControls.SqlDataSourceCommandEventArgs
+//
+// Authors:
+// Ben Maurer (bmaurer@users.sourceforge.net)
+//
+// (C) 2003 Ben Maurer
+//
+
+#if NET_1_2
+using System.Collections;
+using System.Collections.Specialized;
+using System.Text;
+using System.Data;
+using System.ComponentModel;
+
+namespace System.Web.UI.WebControls {
+ public class SqlDataSourceCommandEventArgs : CancelEventArgs {
+
+ public SqlDataSourceCommandEventArgs (IDbCommand command)
+ {
+ this.command = command;
+ }
+
+ IDbCommand command;
+ public IDbCommand Command {
+ get { return command; }
+ }
+ }
+}
+#endif
+
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/SqlDataSourceCommandEventHandler.cs b/mcs/class/System.Web/System.Web.UI.WebControls/SqlDataSourceCommandEventHandler.cs
new file mode 100644
index 00000000000..244a9cbad44
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/SqlDataSourceCommandEventHandler.cs
@@ -0,0 +1,15 @@
+//
+// System.Web.UI.WebControls.SqlDataSourceCommandEventHandler
+//
+// Authors:
+// Ben Maurer (bmaurer@users.sourceforge.net)
+//
+// (C) 2003 Ben Maurer
+//
+
+#if NET_1_2
+namespace System.Web.UI.WebControls {
+ public delegate void SqlDataSourceCommandEventHandler (object source, SqlDataSourceCommandEventArgs e);
+}
+#endif
+
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/SqlDataSourceMode.cs b/mcs/class/System.Web/System.Web.UI.WebControls/SqlDataSourceMode.cs
new file mode 100644
index 00000000000..4d9071ded87
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/SqlDataSourceMode.cs
@@ -0,0 +1,22 @@
+//
+// System.Web.UI.WebControls.SqlDataSourceMode
+//
+// Authors:
+// Ben Maurer (bmaurer@users.sourceforge.net)
+//
+// (C) 2003 Ben Maurer
+//
+
+#if NET_1_2
+using System.Collections;
+using System.Collections.Specialized;
+using System.Text;
+
+namespace System.Web.UI.WebControls {
+ public enum SqlDataSourceMode {
+ DataReader,
+ DataSet
+ }
+}
+#endif
+
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/SqlDataSourceStatusEventArgs.cs b/mcs/class/System.Web/System.Web.UI.WebControls/SqlDataSourceStatusEventArgs.cs
new file mode 100644
index 00000000000..1e37ee59c1d
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/SqlDataSourceStatusEventArgs.cs
@@ -0,0 +1,42 @@
+//
+// System.Web.UI.WebControls.SqlDataSourceStatusEventArgs
+//
+// Authors:
+// Ben Maurer (bmaurer@users.sourceforge.net)
+//
+// (C) 2003 Ben Maurer
+//
+
+#if NET_1_2
+using System.Collections;
+using System.Collections.Specialized;
+using System.Text;
+
+namespace System.Web.UI.WebControls {
+ public class SqlDataSourceStatusEventArgs : EventArgs {
+ public SqlDataSourceStatusEventArgs (IOrderedDictionary outputParameters, object returnValue, int rowsAffected)
+ {
+ this.outputParameters = outputParameters;
+ this.returnValue = returnValue;
+ this.rowsAffected = rowsAffected;
+ }
+
+ IOrderedDictionary outputParameters;
+ object returnValue;
+ int rowsAffected;
+
+ public IOrderedDictionary OutputParameters {
+ get { return outputParameters; }
+ }
+
+ public object ReturnValue {
+ get { return returnValue; }
+ }
+
+ public int RowsAffected {
+ get { return rowsAffected; }
+ }
+ }
+}
+#endif
+
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/SqlDataSourceStatusEventHandler.cs b/mcs/class/System.Web/System.Web.UI.WebControls/SqlDataSourceStatusEventHandler.cs
new file mode 100644
index 00000000000..2446e91b260
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/SqlDataSourceStatusEventHandler.cs
@@ -0,0 +1,15 @@
+//
+// System.Web.UI.WebControls.SqlDataSourceStatusEventHandler
+//
+// Authors:
+// Ben Maurer (bmaurer@users.sourceforge.net)
+//
+// (C) 2003 Ben Maurer
+//
+
+#if NET_1_2
+namespace System.Web.UI.WebControls {
+ public delegate void SqlDataSourceStatusEventHandler (object source, SqlDataSourceStatusEventArgs e);
+}
+#endif
+
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/SqlDataSourceView.cs b/mcs/class/System.Web/System.Web.UI.WebControls/SqlDataSourceView.cs
new file mode 100644
index 00000000000..d78d702a852
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/SqlDataSourceView.cs
@@ -0,0 +1,411 @@
+//
+// System.Web.UI.WebControls.SqlDataSourceView
+//
+// Authors:
+// Ben Maurer (bmaurer@users.sourceforge.net)
+//
+// (C) 2003 Ben Maurer
+//
+
+#if NET_1_2
+using System.Collections;
+using System.Collections.Specialized;
+using System.Text;
+using System.Data;
+using System.ComponentModel;
+
+namespace System.Web.UI.WebControls {
+ public class SqlDataSourceView : DataSourceView, IStateManager {
+
+ public SqlDataSourceView (SqlDataSource owner, string name)
+ {
+ this.owner = owner;
+ this.name = name;
+ }
+
+ public int Delete ()
+ {
+ return Delete (null);
+ }
+
+ [MonoTODO]
+ public override int Delete (IDictionary parameters)
+ {
+ throw new NotImplementedException ();
+ }
+
+ public int Insert ()
+ {
+ return Insert (null);
+ }
+
+ [MonoTODO]
+ public override int Insert (IDictionary values)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public override IEnumerable Select ()
+ {
+ throw new NotImplementedException ();
+ }
+
+ public int Update ()
+ {
+ return Update (null, null);
+ }
+
+ [MonoTODO]
+ public override int Update (IDictionary parameters, IDictionary values)
+ {
+ throw new NotImplementedException ();
+ }
+
+ void IStateManager.LoadViewState (object savedState)
+ {
+ LoadViewState (savedState);
+ }
+
+ object IStateManager.SaveViewState ()
+ {
+ return SaveViewState ();
+ }
+
+ void IStateManager.TrackViewState ()
+ {
+ TrackViewState ();
+ }
+
+ protected virtual void LoadViewState (object savedState)
+ {
+ object [] vs = savedState as object [];
+ if (vs == null)
+ return;
+
+ if (vs [0] != null) ((IStateManager) deleteParameters).LoadViewState (vs [0]);
+ if (vs [1] != null) ((IStateManager) filterParameters).LoadViewState (vs [1]);
+ if (vs [2] != null) ((IStateManager) insertParameters).LoadViewState (vs [2]);
+ if (vs [3] != null) ((IStateManager) selectParameters).LoadViewState (vs [3]);
+ if (vs [4] != null) ((IStateManager) updateParameters).LoadViewState (vs [4]);
+ if (vs [5] != null) ((IStateManager) viewState).LoadViewState (vs [5]);
+ }
+
+ protected virtual object SaveViewState ()
+ {
+ object [] vs = new object [6];
+
+ if (deleteParameters != null) vs [0] = ((IStateManager) deleteParameters).SaveViewState ();
+ if (filterParameters != null) vs [1] = ((IStateManager) filterParameters).SaveViewState ();
+ if (insertParameters != null) vs [2] = ((IStateManager) insertParameters).SaveViewState ();
+ if (selectParameters != null) vs [3] = ((IStateManager) selectParameters).SaveViewState ();
+ if (updateParameters != null) vs [4] = ((IStateManager) updateParameters).SaveViewState ();
+ if (viewState != null) vs [5] = ((IStateManager) viewState).SaveViewState ();
+
+ foreach (object o in vs)
+ if (o != null) return vs;
+ return null;
+ }
+
+ protected virtual void TrackViewState ()
+ {
+ tracking = true;
+
+ if (deleteParameters != null) ((IStateManager) deleteParameters).TrackViewState ();
+ if (filterParameters != null) ((IStateManager) filterParameters).TrackViewState ();
+ if (insertParameters != null) ((IStateManager) insertParameters).TrackViewState ();
+ if (selectParameters != null) ((IStateManager) selectParameters).TrackViewState ();
+ if (updateParameters != null) ((IStateManager) updateParameters).TrackViewState ();
+ if (viewState != null) ((IStateManager) viewState).TrackViewState ();
+ }
+
+ protected bool IsTrackingViewState {
+ get { return tracking; }
+ }
+
+ bool IStateManager.IsTrackingViewState {
+ get { return IsTrackingViewState; }
+ }
+
+ public string DeleteCommand {
+ get {
+ string val = ViewState ["DeleteCommand"] as string;
+ return val == null ? "" : val;
+ }
+ set { ViewState ["DeleteCommand"] = value; }
+ }
+
+ public string FilterExpression {
+ get {
+ string val = ViewState ["FilterExpression"] as string;
+ return val == null ? "" : val;
+ }
+ set { ViewState ["FilterExpression"] = value; }
+ }
+
+ public string InsertCommand {
+ get {
+ string val = ViewState ["InsertCommand"] as string;
+ return val == null ? "" : val;
+ }
+ set { ViewState ["InsertCommand"] = value; }
+ }
+
+ public string SelectCommand {
+ get {
+ string val = ViewState ["SelectCommand"] as string;
+ return val == null ? "" : val;
+ }
+ set { ViewState ["SelectCommand"] = value; }
+ }
+
+ public string UpdateCommand {
+ get {
+ string val = ViewState ["UpdateCommand"] as string;
+ return val == null ? "" : val;
+ }
+ set { ViewState ["UpdateCommand"] = value; }
+ }
+
+ public override string SortExpression {
+ get {
+ string val = ViewState ["SortExpression"] as string;
+ return val == null ? "" : val;
+ }
+ set { ViewState ["SortExpression"] = value; }
+ }
+
+ public override bool CanDelete {
+ get { return DeleteCommand != ""; }
+ }
+
+ public override bool CanInsert {
+ get { return UpdateCommand != ""; }
+ }
+
+ public override bool CanSort {
+ get { return owner.DataSourceMode == SqlDataSourceMode.DataSet; }
+ }
+
+ public override bool CanUpdate {
+ get { return UpdateCommand != ""; }
+ }
+
+ EventHandlerList events;
+ protected EventHandlerList Events {
+ get {
+ if (events == null)
+ events = new EventHandlerList ();
+
+ return events;
+ }
+ }
+
+ void ParametersChanged (object source, EventArgs args)
+ {
+ OnDataSourceViewChanged (EventArgs.Empty);
+ }
+
+ ParameterCollection GetParameterCollection (ref ParameterCollection output)
+ {
+ if (output != null)
+ return output;
+
+ output = new ParameterCollection ();
+ output.ParametersChanged += new EventHandler (ParametersChanged);
+
+ if (IsTrackingViewState)
+ ((IStateManager) output).TrackViewState ();
+
+ return output;
+ }
+
+ public ParameterCollection DeleteParameters {
+ get { return GetParameterCollection (ref deleteParameters); }
+ }
+
+ public ParameterCollection FilterParameters {
+ get { return GetParameterCollection (ref filterParameters); }
+ }
+
+ public ParameterCollection InsertParameters {
+ get { return GetParameterCollection (ref insertParameters); }
+ }
+
+ public ParameterCollection SelectParameters {
+ get { return GetParameterCollection (ref selectParameters); }
+ }
+
+ public ParameterCollection UpdateParameters {
+ get { return GetParameterCollection (ref updateParameters); }
+ }
+
+
+ public override string Name {
+ get { return name; }
+ }
+
+ protected virtual string ParameterPrefix {
+ get { return "@"; }
+ }
+
+ StateBag viewState;
+ protected StateBag ViewState {
+ get {
+ if (viewState != null)
+ return viewState;
+
+ viewState = new StateBag ();
+ if (IsTrackingViewState)
+ viewState.TrackViewState ();
+
+ return viewState;
+ }
+ }
+
+ ParameterCollection deleteParameters;
+ ParameterCollection filterParameters;
+ ParameterCollection insertParameters;
+ ParameterCollection selectParameters;
+ ParameterCollection updateParameters;
+
+ bool tracking;
+
+ string name;
+ SqlDataSource owner;
+
+ static readonly object EventDataSourceViewChanged = new object ();
+
+ protected virtual void OnDataSourceViewChanged (EventArgs e)
+ {
+ if (events == null) return;
+ EventHandler h = events [EventDataSourceViewChanged] as EventHandler;
+ if (h != null)
+ h (this, e);
+ }
+
+ public event EventHandler DataSourceViewChanged {
+ add { Events.AddHandler (EventDataSourceViewChanged, value); }
+ remove { Events.RemoveHandler (EventDataSourceViewChanged, value); }
+ }
+
+ #region OnDelete
+ static readonly object EventDeleted = new object ();
+ protected virtual void OnDeleted (SqlDataSourceStatusEventArgs e)
+ {
+ if (events == null) return;
+ SqlDataSourceStatusEventHandler h = events [EventDeleted] as SqlDataSourceStatusEventHandler;
+ if (h != null)
+ h (this, e);
+ }
+
+ public event SqlDataSourceStatusEventHandler Deleted {
+ add { Events.AddHandler (EventDeleted, value); }
+ remove { Events.RemoveHandler (EventDeleted, value); }
+ }
+
+ static readonly object EventDeleting = new object ();
+ protected virtual void OnDeleting (SqlDataSourceCommandEventArgs e)
+ {
+ if (events == null) return;
+ SqlDataSourceCommandEventHandler h = events [EventDeleting] as SqlDataSourceCommandEventHandler;
+ if (h != null)
+ h (this, e);
+ }
+ public event SqlDataSourceCommandEventHandler Deleting {
+ add { Events.AddHandler (EventDeleting, value); }
+ remove { Events.RemoveHandler (EventDeleting, value); }
+ }
+ #endregion
+
+ #region OnInsert
+ static readonly object EventInserted = new object ();
+ protected virtual void OnInserted (SqlDataSourceStatusEventArgs e)
+ {
+ if (events == null) return;
+ SqlDataSourceStatusEventHandler h = events [EventInserted] as SqlDataSourceStatusEventHandler;
+ if (h != null)
+ h (this, e);
+ }
+
+ public event SqlDataSourceStatusEventHandler Inserted {
+ add { Events.AddHandler (EventInserted, value); }
+ remove { Events.RemoveHandler (EventInserted, value); }
+ }
+
+ static readonly object EventInserting = new object ();
+ protected virtual void OnInserting (SqlDataSourceCommandEventArgs e)
+ {
+ if (events == null) return;
+ SqlDataSourceCommandEventHandler h = events [EventInserting] as SqlDataSourceCommandEventHandler;
+ if (h != null)
+ h (this, e);
+ }
+ public event SqlDataSourceCommandEventHandler Inserting {
+ add { Events.AddHandler (EventInserting, value); }
+ remove { Events.RemoveHandler (EventInserting, value); }
+ }
+ #endregion
+
+ #region OnSelect
+ static readonly object EventSelected = new object ();
+ protected virtual void OnSelected (SqlDataSourceStatusEventArgs e)
+ {
+ if (events == null) return;
+ SqlDataSourceStatusEventHandler h = events [EventSelected] as SqlDataSourceStatusEventHandler;
+ if (h != null)
+ h (this, e);
+ }
+
+ public event SqlDataSourceStatusEventHandler Selected {
+ add { Events.AddHandler (EventSelected, value); }
+ remove { Events.RemoveHandler (EventSelected, value); }
+ }
+
+ static readonly object EventSelecting = new object ();
+ protected virtual void OnSelecting (SqlDataSourceCommandEventArgs e)
+ {
+ if (events == null) return;
+ SqlDataSourceCommandEventHandler h = events [EventSelecting] as SqlDataSourceCommandEventHandler;
+ if (h != null)
+ h (this, e);
+ }
+ public event SqlDataSourceCommandEventHandler Selecting {
+ add { Events.AddHandler (EventSelecting, value); }
+ remove { Events.RemoveHandler (EventSelecting, value); }
+ }
+ #endregion
+
+ #region OnUpdate
+ static readonly object EventUpdated = new object ();
+ protected virtual void OnUpdated (SqlDataSourceStatusEventArgs e)
+ {
+ if (events == null) return;
+ SqlDataSourceStatusEventHandler h = events [EventUpdated] as SqlDataSourceStatusEventHandler;
+ if (h != null)
+ h (this, e);
+ }
+
+ public event SqlDataSourceStatusEventHandler Updated {
+ add { Events.AddHandler (EventUpdated, value); }
+ remove { Events.RemoveHandler (EventUpdated, value); }
+ }
+
+ static readonly object EventUpdating = new object ();
+ protected virtual void OnUpdating (SqlDataSourceCommandEventArgs e)
+ {
+ if (events == null) return;
+ SqlDataSourceCommandEventHandler h = events [EventUpdating] as SqlDataSourceCommandEventHandler;
+ if (h != null)
+ h (this, e);
+ }
+ public event SqlDataSourceCommandEventHandler Updating {
+ add { Events.AddHandler (EventUpdating, value); }
+ remove { Events.RemoveHandler (EventUpdating, value); }
+ }
+ #endregion
+ }
+
+}
+#endif
+
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/Style.cs b/mcs/class/System.Web/System.Web.UI.WebControls/Style.cs
index 436a86902c2..67819dc3cd7 100644
--- a/mcs/class/System.Web/System.Web.UI.WebControls/Style.cs
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/Style.cs
@@ -451,7 +451,7 @@ namespace System.Web.UI.WebControls
protected internal virtual object SaveViewState ()
{
if (viewState != null) {
- if (marked)
+ if (marked && IsSet (MARKED))
ViewState [selectionBitString] = selectionBits;
if (selfStateBag)
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/ValidationSummary.cs b/mcs/class/System.Web/System.Web.UI.WebControls/ValidationSummary.cs
index 0ad52cfd352..40a108f78b1 100644
--- a/mcs/class/System.Web/System.Web.UI.WebControls/ValidationSummary.cs
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/ValidationSummary.cs
@@ -180,7 +180,8 @@ namespace System.Web.UI.WebControls
if (!currentValidator.IsValid)
{
showSummary = true;
- if (currentValidator.ErrorMessage.Length != 0)
+ if (currentValidator.ErrorMessage != null &&
+ currentValidator.ErrorMessage.Length != 0)
numOfMsg++;
}
}
@@ -188,13 +189,14 @@ namespace System.Web.UI.WebControls
if (numOfMsg != 0)
{
messages = new string[(int)numOfMsg];
+ int cur_msg = 0;
for (int i = 0; i < base.Page.Validators.Count; i++)
{
IValidator currentValidator = base.Page.Validators[i];
if (!currentValidator.IsValid &&
currentValidator.ErrorMessage != null &&
- currentValidator.ErrorMessage.Length != 0)
- messages[i] = String.Copy(currentValidator.ErrorMessage);
+ currentValidator.ErrorMessage.Length != 0)
+ messages[cur_msg++] = String.Copy(currentValidator.ErrorMessage);
}
}
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/WebControl.cs b/mcs/class/System.Web/System.Web.UI.WebControls/WebControl.cs
index 67cc1063d50..eed3bb0a6a1 100755
--- a/mcs/class/System.Web/System.Web.UI.WebControls/WebControl.cs
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/WebControl.cs
@@ -426,18 +426,14 @@ namespace System.Web.UI.WebControls
if (savedState == null)
return;
- Triplet saved = (Triplet) savedState;
+ Pair saved = (Pair) savedState;
base.LoadViewState (saved.First);
- if (saved.Second != null ||
- ViewState [System.Web.UI.WebControls.Style.selectionBitString] != null)
- ControlStyle.LoadViewState (saved.Second);
+
+ if (ControlStyleCreated || ViewState [System.Web.UI.WebControls.Style.selectionBitString] != null)
+ ControlStyle.LoadViewState (null);
if (attributeState != null)
- attributeState.LoadViewState (saved.Third);
-
- object e = ViewState ["Enabled"];
- if (e != null)
- enabled = (bool) e;
+ attributeState.LoadViewState (saved.Second);
}
protected override void Render(HtmlTextWriter writer)
@@ -454,17 +450,18 @@ namespace System.Web.UI.WebControls
protected override object SaveViewState()
{
- object controlView = null;
if (ControlStyleCreated)
- controlView = ControlStyle.SaveViewState ();
-
- ViewState ["Enabled"] = enabled;
+ ControlStyle.SaveViewState ();
+
object baseView = base.SaveViewState ();
object attrView = null;
if (attributeState != null)
attrView = attributeState.SaveViewState ();
+
+ if (baseView == null && attrView == null)
+ return null;
- return new Triplet (baseView, controlView, attrView);
+ return new Pair (baseView, attrView);
}
protected override void TrackViewState()
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/Xml.cs b/mcs/class/System.Web/System.Web.UI.WebControls/Xml.cs
index e06d42bcab6..e202b7cc5d3 100644
--- a/mcs/class/System.Web/System.Web.UI.WebControls/Xml.cs
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/Xml.cs
@@ -25,8 +25,7 @@ namespace System.Web.UI.WebControls
{
[DefaultProperty("DocumentSource")]
[PersistChildren(false)]
- // TODO add control builder
- //[ControlBuilder ()]
+ [ControlBuilder (typeof (XmlBuilder))]
[Designer ("System.Web.UI.Design.WebControls.XmlDesigner, " + Consts.AssemblySystem_Design, typeof (IDesigner))]
public class Xml : Control
{
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/XmlBuilder.cs b/mcs/class/System.Web/System.Web.UI.WebControls/XmlBuilder.cs
new file mode 100644
index 00000000000..2ce8f2825dc
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/XmlBuilder.cs
@@ -0,0 +1,37 @@
+//
+// System.Web.UI.WebControls.XmlBuilder.cs
+//
+// Author:
+// Andreas Nahr (ClassDevelopment@A-SoftTech.com)
+//
+//
+
+using System;
+using System.Collections;
+using System.Web.UI;
+
+namespace System.Web.UI.WebControls
+{
+ internal class XmlBuilder : ControlBuilder
+ {
+ public override void AppendLiteralString (string s)
+ {
+ }
+
+ public override Type GetChildControlType (string tagName, IDictionary attribs)
+ {
+ return null;
+ }
+
+ public override bool NeedsTagInnerText ()
+ {
+ return true;
+ }
+
+ [MonoTODO ("find out what this does and implement")]
+ public override void SetTagInnerText (string text)
+ {
+ throw new NotImplementedException ();
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI/ChangeLog b/mcs/class/System.Web/System.Web.UI/ChangeLog
index b890f6d9f4d..1f60570d3fb 100644
--- a/mcs/class/System.Web/System.Web.UI/ChangeLog
+++ b/mcs/class/System.Web/System.Web.UI/ChangeLog
@@ -1,3 +1,72 @@
+2003-11-27 Jackson Harper <jackson@ximian.com>
+
+ * TemplateParser.cs: Ignore aspCompat attribute. This fixes bug
+ 51434.
+
+2003-11-22 Ben Maurer <bmaurer@users.sourceforge.net>
+
+ * ObjectStateFormatter.cs: Fix bug when reading small ints.
+ Add some tracing so we can see what is going on.
+
+2003-11-21 Jackson Harper <jackson@ximian.com>
+
+ * Page.cs: Set vary by params when cache location is Server.
+
+2003-11-21 Ben Maurer <bmaurer@users.sourceforge.net>
+
+ * ObjectStateFormatter.cs: v2 file. In v1.x this will be
+ internal as LosFormatter will eventually use it to save
+ the view state.
+
+2003-11-21 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * PersistChildrenAttribute.cs:
+ * PersistenceModeAttribute.cs: implemented.
+
+ * TODO: Removed file.
+ * OutputCacheLocation.cs:
+ * TemplateControlParser.cs:
+ * HtmlInputFile.cs: class status based fixes.
+
+2003-11-19 Jackson Harper <jackson@ximian.com>
+
+ * Page.cs: Always set the cache expire time. Tell the response to
+ cache itself for server side cached pages.
+
+2003-11-19 Jackson Harper <jackson@ximian.com>
+
+ * Control.cs: Remove ResolveBaseUrl. ResolveUrl does the same
+ thing, some corner cases still need work though. Was this the
+ shortest lived method in the history of mono?
+
+2003-11-19 Jackson Harper <jackson@ximian.com>
+
+ * Control.cs: New method for resolving urls that use ~/ to denote
+ the applications base directory.
+
+2003-11-19 Jackson Harper <jackson@ximian.com>
+
+ * TemplateParser.cs: Fix typo in error message.
+
+2003-11-19 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * TemplateControlParser.cs: support @Reference. Fixes bug #49572. Thanks
+ to Sanjay Gupta.
+
+2003-11-19 Todd Berman <tberman@gentoo.org>
+
+ * KeyedList.cs:
+ * KeyedListEnumerator.cs: New v2 implementations.
+
+2003-11-17 Ben Maurer <bmaurer@users.sourceforge.net>
+
+ * StateManagedCollection.cs: Implement.
+
+2003-11-13 Jackson Harper <jackson@ximian.com>
+
+ * Page.cs: Initial implementation of InitOutputCache.
+ * TemplateParser.cs: Page OutputCache options
+
2003-11-09 Ben Maurer <bmaurer@users.sourceforge.net>
* HierarchicalDataSourceControl.cs: Implement.
diff --git a/mcs/class/System.Web/System.Web.UI/Control.cs b/mcs/class/System.Web/System.Web.UI/Control.cs
index 9f5b7ac3bea..3d37e78fd94 100644
--- a/mcs/class/System.Web/System.Web.UI/Control.cs
+++ b/mcs/class/System.Web/System.Web.UI/Control.cs
@@ -687,12 +687,43 @@ namespace System.Web.UI
}
public virtual void DataBind() //DIT
- {
- OnDataBinding(EventArgs.Empty);
- if (_controls != null)
- foreach (Control c in _controls)
- c.DataBind();
- }
+ {
+ #if NET_1_2
+ bool foundDataItem = false;
+
+ if (_isNamingContainer && Page != null) {
+ object o = DataBinder.GetDataItem (this, out foundDataItem);
+ if (foundDataItem)
+ Page.PushDataItemContext (o);
+ }
+
+ try {
+ #endif
+
+ OnDataBinding (EventArgs.Empty);
+ DataBindChildren();
+
+ #if NET_1_2
+ } finally {
+ if (foundDataItem)
+ Page.PopDataItemContext ();
+ }
+ #endif
+ }
+
+ #if NET_1_2
+ protected virtual
+ #endif
+
+ void DataBindChildren ()
+ {
+ if (_controls == null)
+ return;
+
+ foreach (Control c in _controls)
+ c.DataBind();
+ }
+
public virtual bool HasControls() //DIT
{
@@ -723,7 +754,7 @@ namespace System.Web.UI
HttpResponse resp = Context.Response;
return resp.ApplyAppPathModifier (UrlUtils.Combine (ts, relativeUrl));
- }
+ }
[EditorBrowsable (EditorBrowsableState.Advanced)]
public void SetRenderMethodDelegate(RenderMethod renderMethod) //DIT
diff --git a/mcs/class/System.Web/System.Web.UI/DataBinder.cs b/mcs/class/System.Web/System.Web.UI/DataBinder.cs
index 5ab388c6d89..5c1805d0124 100755
--- a/mcs/class/System.Web/System.Web.UI/DataBinder.cs
+++ b/mcs/class/System.Web/System.Web.UI/DataBinder.cs
@@ -152,7 +152,30 @@ namespace System.Web.UI {
{
object result = GetPropertyValue (container, propName);
return FormatResult (result, format);
- }
+ }
+
+ #if NET_1_2
+ public static object GetDataItem (object container, out bool foundDataItem)
+ {
+ foundDataItem = false;
+ if (container == null)
+ return null;
+
+ PropertyInfo pi = container.GetType ().GetProperty ("DataItem", BindingFlags.Public | BindingFlags.Instance);
+ if (pi == null)
+ return null;
+
+ foundDataItem = true;
+ return pi.GetValue (container, null);
+ }
+
+
+ public static object GetDataItem (object container)
+ {
+ bool flag;
+ return GetDataItem (container, out flag);
+ }
+ #endif
}
}
diff --git a/mcs/class/System.Web/System.Web.UI/KeyedList.cs b/mcs/class/System.Web/System.Web.UI/KeyedList.cs
new file mode 100644
index 00000000000..f16e95f21a8
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI/KeyedList.cs
@@ -0,0 +1,194 @@
+//
+// System.Web.UI/KeyedList.cs
+//
+// Author: Todd Berman <tberman@gentoo.org>
+//
+// (C) 2003 Todd Berman
+
+#if NET_1_2
+
+using System.Collections;
+using System.Collections.Specialized;
+
+namespace System.Web.UI
+{
+
+ public class KeyedList : IOrderedDictionary, IStateManager
+ {
+
+ private Hashtable objectTable = new Hashtable ();
+ private ArrayList objectList = new ArrayList ();
+
+ public void Add (object key, object value)
+ {
+ objectTable.Add (key, value);
+ objectList.Add (new DictionaryEntry (key, value));
+ }
+
+ public void Clear ()
+ {
+ objectTable.Clear ();
+ objectList.Clear ();
+ }
+
+ public bool Contains (object key)
+ {
+ return objectTable.Contains (key);
+ }
+
+ public void CopyTo (Array array, int idx)
+ {
+ objectTable.CopyTo (array, idx);
+ }
+
+ public void Insert (int idx, object key, object value)
+ {
+ if (idx > Count)
+ throw new ArgumentOutOfRangeException ("index");
+
+ objectTable.Add (key, value);
+ objectList.Insert (idx, new DictionaryEntry (key, value));
+ }
+
+ public void Remove (object key)
+ {
+ objectTable.Remove (key);
+ objectList.RemoveAt (IndexOf (key));
+ }
+
+ public void RemoveAt (int idx)
+ {
+ if (idx >= Count)
+ throw new ArgumentOutOfRangeException ("index");
+
+ objectTable.Remove ( ((DictionaryEntry)objectList[idx]).Key );
+ objectList.RemoveAt (idx);
+ }
+
+ private IDictionaryEnumerator IDictionary.GetEnumerator ()
+ {
+ return new KeyedListEnumerator (objectList);
+ }
+
+ private IEnumerator IEnumerable.GetEnumerator ()
+ {
+ return new KeyedListEnumerator (objectList);
+ }
+
+ private void IStateManager.LoadViewState (object state)
+ {
+ if (state != null)
+ {
+ object[] states = (object[]) state;
+ if (states[0] != null) {
+ objectList = (ArrayList) states[0];
+ for (int i = 0; i < objectList.Count; i++)
+ {
+ DictionaryEntry pair = (DictionaryEntry) objectList[i];
+ objectTable.Add (pair.Key, pair.Value);
+ }
+ }
+ }
+ }
+
+ private object IStateManager.SaveViewState ()
+ {
+ object[] ret = new object[] { objectList };
+ if (ret[0] == null)
+ return null;
+
+ return ret;
+ }
+
+ private void IStateManager.TrackViewState ()
+ {
+ trackViewState = true;
+ }
+
+ public int Count {
+ get { return objectList.Count; }
+ }
+
+ public bool IsFixedSize {
+ get { return false; }
+ }
+
+ public bool IsReadOnly {
+ get { return false; }
+ }
+
+ public bool IsSynchronized {
+ get { return false; }
+ }
+
+ public object this[int idx] {
+ get { return ((DictionaryEntry) objectList[idx]).Value; }
+ set {
+ if (idx < 0 || idx >= Count)
+ throw new ArgumentOutOfRangeException ("index");
+
+ object key = ((DictionaryEntry) objectList[idx]).Key;
+ objectList[idx] = new DictionaryEntry (key, value);
+ objectTable[key] = value;
+ }
+ }
+
+ public object this[object key] {
+ get { return objectTable[key]; }
+ set {
+ if (objectTable.Contains (key))
+ {
+ objectTable[key] = value;
+ objectTable[IndexOf (key)] = new DictionaryEntry (key, value);
+ return;
+ }
+ Add (key, value);
+ }
+ }
+
+ public ICollection Keys {
+ get {
+ ArrayList retList = new ArrayList ();
+ for (int i = 0; i < objectList.Count; i++)
+ {
+ retList.Add ( ((DictionaryEntry)objectList[i]).Key );
+ }
+ return retList;
+ }
+ }
+
+ public ICollection Values {
+ get {
+ ArrayList retList = new ArrayList ();
+ for (int i = 0; i < objectList.Count; i++)
+ {
+ retList.Add ( ((DictionaryEntry)objectList[i]).Value );
+ }
+ return retList;
+ }
+ }
+
+ public object SyncRoot {
+ get { return this; }
+ }
+
+ private bool trackViewState;
+ private bool IStateManager.IsTrackingViewState {
+ get { return trackViewState; }
+ }
+
+ private int IndexOf (object key)
+ {
+ for (int i = 0; i < objectList.Count; i++)
+ {
+ if (((DictionaryEntry) objectList[i]).Key.Equals (key))
+ {
+ return i;
+ }
+ }
+ return -1;
+ }
+ }
+}
+
+#endif
diff --git a/mcs/class/System.Web/System.Web.UI/KeyedListEnumerator.cs b/mcs/class/System.Web/System.Web.UI/KeyedListEnumerator.cs
new file mode 100644
index 00000000000..4e80dd230ff
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI/KeyedListEnumerator.cs
@@ -0,0 +1,67 @@
+//
+// System.Web.UI/KeyedListEnumerator.cs
+//
+// Author: Todd Berman <tberman@gentoo.org>
+//
+// (C) 2003 Todd Berman
+
+#if NET_1_2
+
+using System.Collections;
+
+namespace System.Web.UI
+{
+ public class KeyedListEnumerator : IDictionaryEnumerator
+ {
+ private int index = -1;
+ private ArrayList objs;
+
+ internal KeyedListEnumerator (ArrayList list)
+ {
+ objs = list;
+ }
+
+ public bool MoveNext ()
+ {
+ index++;
+ if (index >= objs.Count)
+ return false;
+
+ return true;
+ }
+
+ public void Reset ()
+ {
+ index = -1;
+ }
+
+ public object Current {
+ get {
+ if (index < 0 || index >= objs.Count)
+ throw new InvalidOperationException ();
+
+ return objs[index];
+ }
+ }
+
+ public DictionaryEntry Entry {
+ get {
+ return (DictionaryEntry) Current;
+ }
+ }
+
+ public object Key {
+ get {
+ return Entry.Key;
+ }
+ }
+
+ public object Value {
+ get {
+ return Entry.Value;
+ }
+ }
+ }
+}
+
+#endif
diff --git a/mcs/class/System.Web/System.Web.UI/ObjectStateFormatter.cs b/mcs/class/System.Web/System.Web.UI/ObjectStateFormatter.cs
new file mode 100644
index 00000000000..90d104b4af4
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI/ObjectStateFormatter.cs
@@ -0,0 +1,774 @@
+//
+// System.Web.UI.ObjectStateFormatter
+//
+// Authors:
+// Ben Maurer (bmaurer@users.sourceforge.net)
+//
+// (C) 2003 Ben Maurer
+//
+
+#define TRACE
+
+using System.Collections;
+using System.Drawing;
+using System.IO;
+using System.Reflection;
+using System.Runtime.Serialization.Formatters.Binary;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Web.UI.WebControls;
+using System.Web.Util;
+using System.Diagnostics;
+
+namespace System.Web.UI {
+ #if NET_1_2
+ public
+ #else
+ internal
+ #endif
+ sealed class ObjectStateFormatter : IFormatter {
+ public object Deserialize (Stream inputStream)
+ {
+ if (inputStream == null)
+ throw new ArgumentNullException ("inputStream");
+
+ return DeserializeObject (new BinaryReader (inputStream));
+ }
+
+ public object Deserialize (string inputString)
+ {
+ if (inputString == null)
+ throw new ArgumentNullException ("inputString");
+
+ if (inputString == "")
+ return null;
+
+ return Deserialize (new MemoryStream (Convert.FromBase64String (inputString)));
+ }
+
+ public string Serialize (object stateGraph)
+ {
+ if (stateGraph == null)
+ return "";
+
+ MemoryStream ms = new MemoryStream ();
+ Serialize (ms, stateGraph);
+
+ #if TRACE
+ ms.WriteTo (File.OpenWrite (Path.GetTempFileName ()));
+ #endif
+
+ return Convert.ToBase64String (ms.GetBuffer (), 0, (int) ms.Length);
+ }
+
+ public void Serialize (Stream outputStream, object stateGraph)
+ {
+ if (outputStream == null)
+ throw new ArgumentNullException ("outputStream");
+
+ if (stateGraph == null)
+ throw new ArgumentNullException ("stateGraph");
+
+ SerializeValue (new BinaryWriter (outputStream), stateGraph);
+ }
+
+ void SerializeValue (BinaryWriter w, object o)
+ {
+ ObjectFormatter.WriteObject (w, o, new WriterContext ());
+ }
+
+ object DeserializeObject (BinaryReader r)
+ {
+ return ObjectFormatter.ReadObject (r, new ReaderContext ());
+ }
+
+ #region IFormatter
+
+ object IFormatter.Deserialize (Stream serializationStream)
+ {
+ return Deserialize (serializationStream);
+ }
+
+ void IFormatter.Serialize (Stream serializationStream, object stateGraph)
+ {
+ Serialize (serializationStream, stateGraph);
+ }
+
+ SerializationBinder IFormatter.Binder {
+ get { return null; }
+ set { }
+ }
+
+ StreamingContext IFormatter.Context {
+ get { return new StreamingContext (StreamingContextStates.All); }
+ set { }
+ }
+
+ ISurrogateSelector IFormatter.SurrogateSelector {
+ get { return null; }
+ set { }
+ }
+
+ #endregion
+
+ #region Object Readers/Writers
+
+ class WriterContext {
+ Hashtable cache;
+ short nextKey = 0;
+
+ public bool RegisterCache (object o, out short key)
+ {
+ if (cache == null) {
+ cache = new Hashtable ();
+ cache.Add (o, key = nextKey++);
+ return false;
+ }
+
+ object posKey = cache [o];
+ if (posKey == null) {
+ cache.Add (o, key = nextKey++);
+ return false;
+ }
+
+ key = (short) posKey;
+ return true;
+ }
+ }
+
+ class ReaderContext {
+ ArrayList cache;
+
+ public void CacheItem (object o)
+ {
+ if (cache == null)
+ cache = new ArrayList ();
+
+ cache.Add (o);
+ }
+
+ public object GetCache (short key)
+ {
+ return cache [key];
+ }
+ }
+
+ abstract class ObjectFormatter {
+ static readonly Hashtable writeMap = new Hashtable ();
+ static ObjectFormatter [] readMap = new ObjectFormatter [256];
+ static BinaryObjectFormatter binaryObjectFormatter;
+ static TypeFormatter typeFormatter;
+ static EnumFormatter enumFormatter;
+ static SingleRankArrayFormatter singleRankArrayFormatter;
+
+ static ObjectFormatter ()
+ {
+ new StringFormatter ().Register ();
+ new Int64Formatter ().Register ();
+ new Int32Formatter ().Register ();
+ new Int16Formatter ().Register ();
+ new ByteFormatter ().Register ();
+ new BooleanFormatter ().Register ();
+ new CharFormatter ().Register ();
+ new DateTimeFormatter ().Register ();
+ new PairFormatter ().Register ();
+ new TripletFormatter ().Register ();
+ new ArrayListFormatter ().Register ();
+ new HashtableFormatter ().Register ();
+ new ObjectArrayFormatter ().Register ();
+
+ new ColorFormatter ().Register ();
+
+ enumFormatter = new EnumFormatter ();
+ enumFormatter.Register ();
+
+ typeFormatter = new TypeFormatter ();
+ typeFormatter.Register ();
+
+ singleRankArrayFormatter = new SingleRankArrayFormatter ();
+ singleRankArrayFormatter.Register ();
+
+ binaryObjectFormatter = new BinaryObjectFormatter ();
+ binaryObjectFormatter.Register ();
+ }
+
+ // 0 == null
+ static byte nextId = 1;
+
+ public ObjectFormatter ()
+ {
+ PrimaryId = nextId ++;
+ if (NumberOfIds == 1)
+ return;
+
+ SecondaryId = nextId ++;
+ if (NumberOfIds == 2)
+ return;
+
+ TertiaryId = nextId ++;
+ if (NumberOfIds == 3)
+ return;
+
+ throw new Exception ();
+ }
+
+ protected readonly byte PrimaryId, SecondaryId = 255, TertiaryId = 255;
+
+ protected abstract void Write (BinaryWriter w, object o, WriterContext ctx);
+ protected abstract object Read (byte token, BinaryReader r, ReaderContext ctx);
+ protected abstract Type Type { get; }
+ protected virtual int NumberOfIds { get { return 1; } }
+
+ public virtual void Register ()
+ {
+ writeMap [Type] = this;
+ readMap [PrimaryId] = this;
+ if (SecondaryId != 255) {
+ readMap [SecondaryId] = this;
+ if (TertiaryId != 255)
+ readMap [TertiaryId] = this;
+ }
+ }
+
+ public static void WriteObject (BinaryWriter w, object o, WriterContext ctx)
+ {
+ #if TRACE
+ if (o != null) {
+ Trace.WriteLine (String.Format ("Writing {0} (type: {1})", o, o.GetType ()));
+ Trace.Indent ();
+ } else {
+ Trace.WriteLine ("Writing null");
+ }
+ long pos = w.BaseStream.Position;
+ #endif
+
+ if (o == null) {
+ w.Write ((byte) 0);
+ return;
+ }
+
+ Type t = o.GetType ();
+
+ ObjectFormatter fmt = writeMap [t] as ObjectFormatter;
+ if (fmt == null) {
+ // Handle abstract types here
+
+ if (o is Type)
+ fmt = typeFormatter;
+ else if (t.IsEnum)
+ fmt = enumFormatter;
+ else if (t.IsArray && ((Array) o).Rank == 1)
+ fmt = singleRankArrayFormatter;
+ else
+ fmt = binaryObjectFormatter;
+ }
+
+ fmt.Write (w, o, ctx);
+ #if TRACE
+ Trace.Unindent ();
+ Trace.WriteLine (String.Format ("Wrote {0} (type: {1}) {2} bytes", o, o.GetType (), w.BaseStream.Position - pos));
+ #endif
+ }
+
+ public static object ReadObject (BinaryReader r, ReaderContext ctx)
+ {
+ byte sig = r.ReadByte ();
+
+ if (sig == 0)
+ return null;
+
+ return readMap [sig].Read (sig, r, ctx);
+ }
+
+ protected void Write7BitEncodedInt (BinaryWriter w, int value)
+ {
+ do {
+ int high = (value >> 7) & 0x01ffffff;
+ byte b = (byte)(value & 0x7f);
+
+ if (high != 0) {
+ b = (byte)(b | 0x80);
+ }
+
+ w.Write(b);
+ value = high;
+ } while(value != 0);
+ }
+
+ protected int Read7BitEncodedInt (BinaryReader r)
+ {
+ int ret = 0;
+ int shift = 0;
+ byte b;
+
+ do {
+ b = r.ReadByte();
+
+ ret = ret | ((b & 0x7f) << shift);
+ shift += 7;
+ } while ((b & 0x80) == 0x80);
+
+ return ret;
+ }
+ }
+
+ #region Primitive Formatters
+ class StringFormatter : ObjectFormatter {
+ protected override void Write (BinaryWriter w, object o, WriterContext ctx)
+ {
+ short key;
+ if (ctx.RegisterCache (o, out key)) {
+ w.Write (SecondaryId);
+ w.Write (key);
+ } else {
+ w.Write (PrimaryId);
+ w.Write ((string)o);
+ }
+ }
+
+ protected override object Read (byte token, BinaryReader r, ReaderContext ctx)
+ {
+ if (token == PrimaryId) {
+ string s = r.ReadString ();
+ ctx.CacheItem (s);
+ return s;
+ } else {
+ return ctx.GetCache (r.ReadInt16 ());
+ }
+ }
+ protected override Type Type {
+ get { return typeof (string); }
+ }
+
+ protected override int NumberOfIds {
+ get { return 2; }
+ }
+ }
+
+ class Int64Formatter : ObjectFormatter {
+ protected override void Write (BinaryWriter w, object o, WriterContext ctx)
+ {
+ w.Write (PrimaryId);
+ w.Write ((long)o);
+ }
+
+ protected override object Read (byte token, BinaryReader r, ReaderContext ctx)
+ {
+ return r.ReadInt64 ();
+ }
+ protected override Type Type {
+ get { return typeof (long); }
+ }
+ }
+
+ class Int32Formatter : ObjectFormatter {
+ protected override void Write (BinaryWriter w, object o, WriterContext ctx)
+ {
+ int i = (int) o;
+ if ((int)(byte) i == i) {
+ w.Write (SecondaryId);
+ w.Write ((byte) i);
+ } else {
+ w.Write (PrimaryId);
+ w.Write (i);
+ }
+ }
+
+ protected override object Read (byte token, BinaryReader r, ReaderContext ctx)
+ {
+ if (token == PrimaryId)
+ return r.ReadInt32 ();
+ else
+ return (int) r.ReadByte ();
+ }
+ protected override Type Type {
+ get { return typeof (int); }
+ }
+
+ protected override int NumberOfIds {
+ get { return 2; }
+ }
+ }
+
+ class Int16Formatter : ObjectFormatter {
+ protected override void Write (BinaryWriter w, object o, WriterContext ctx)
+ {
+ w.Write (PrimaryId);
+ w.Write ((short)o);
+ }
+
+ protected override object Read (byte token, BinaryReader r, ReaderContext ctx)
+ {
+ return r.ReadInt16 ();
+ }
+ protected override Type Type {
+ get { return typeof (short); }
+ }
+ }
+
+ class ByteFormatter : ObjectFormatter {
+ protected override void Write (BinaryWriter w, object o, WriterContext ctx)
+ {
+ w.Write (PrimaryId);
+ w.Write ((byte)o);
+ }
+
+ protected override object Read (byte token, BinaryReader r, ReaderContext ctx)
+ {
+ return r.ReadByte ();
+ }
+ protected override Type Type {
+ get { return typeof (byte); }
+ }
+ }
+
+ class BooleanFormatter : ObjectFormatter {
+ protected override void Write (BinaryWriter w, object o, WriterContext ctx)
+ {
+ if ((bool)o == true)
+ w.Write (PrimaryId);
+ else
+ w.Write (SecondaryId);
+ }
+
+ protected override object Read (byte token, BinaryReader r, ReaderContext ctx)
+ {
+ return token == PrimaryId;
+ }
+
+ protected override Type Type {
+ get { return typeof (bool); }
+ }
+
+ protected override int NumberOfIds {
+ get { return 2; }
+ }
+ }
+
+ class CharFormatter : ObjectFormatter {
+ protected override void Write (BinaryWriter w, object o, WriterContext ctx)
+ {
+ w.Write (PrimaryId);
+ w.Write ((char) o);
+ }
+
+ protected override object Read (byte token, BinaryReader r, ReaderContext ctx)
+ {
+ return r.ReadChar ();
+ }
+
+ protected override Type Type {
+ get { return typeof (char); }
+ }
+ }
+
+ class DateTimeFormatter : ObjectFormatter {
+ protected override void Write (BinaryWriter w, object o, WriterContext ctx)
+ {
+ w.Write (PrimaryId);
+ w.Write (((DateTime) o).Ticks);
+ }
+
+ protected override object Read (byte token, BinaryReader r, ReaderContext ctx)
+ {
+ return new DateTime (r.ReadInt64 ());
+ }
+
+ protected override Type Type {
+ get { return typeof (DateTime); }
+ }
+ }
+
+ class PairFormatter : ObjectFormatter {
+ protected override void Write (BinaryWriter w, object o, WriterContext ctx)
+ {
+ Pair p = (Pair) o;
+ w.Write (PrimaryId);
+ WriteObject (w, p.First, ctx);
+ WriteObject (w, p.Second, ctx);
+ }
+
+ protected override object Read (byte token, BinaryReader r, ReaderContext ctx)
+ {
+ Pair p = new Pair ();
+ p.First = ReadObject (r, ctx);
+ p.Second = ReadObject (r, ctx);
+ return p;
+ }
+
+ protected override Type Type {
+ get { return typeof (Pair); }
+ }
+ }
+
+ class TripletFormatter : ObjectFormatter {
+ protected override void Write (BinaryWriter w, object o, WriterContext ctx)
+ {
+ Triplet t = (Triplet) o;
+ w.Write (PrimaryId);
+ WriteObject (w, t.First, ctx);
+ WriteObject (w, t.Second, ctx);
+ WriteObject (w, t.Third, ctx);
+ }
+
+ protected override object Read (byte token, BinaryReader r, ReaderContext ctx)
+ {
+ Triplet t = new Triplet ();
+ t.First = ReadObject (r, ctx);
+ t.Second = ReadObject (r, ctx);
+ t.Third = ReadObject (r, ctx);
+ return t;
+ }
+
+ protected override Type Type {
+ get { return typeof (Triplet); }
+ }
+ }
+
+ class ArrayListFormatter : ObjectFormatter {
+ protected override void Write (BinaryWriter w, object o, WriterContext ctx)
+ {
+ ArrayList l = (ArrayList) o;
+
+ w.Write (PrimaryId);
+ Write7BitEncodedInt (w, l.Count);
+ foreach (object i in l)
+ WriteObject (w, i, ctx);
+ }
+
+ protected override object Read (byte token, BinaryReader r, ReaderContext ctx)
+ {
+ int len = Read7BitEncodedInt (r);
+ ArrayList l = new ArrayList (len);
+
+ for (int i = 0; i < len; i++)
+ l.Add (ReadObject (r, ctx));
+
+ return l;
+ }
+
+ protected override Type Type {
+ get { return typeof (ArrayList); }
+ }
+ }
+
+ class HashtableFormatter : ObjectFormatter {
+ protected override void Write (BinaryWriter w, object o, WriterContext ctx)
+ {
+ Hashtable ht = (Hashtable) o;
+
+ w.Write (PrimaryId);
+ Write7BitEncodedInt (w, ht.Count);
+ foreach (DictionaryEntry de in ht) {
+ WriteObject (w, de.Key, ctx);
+ WriteObject (w, de.Value, ctx);
+ }
+ }
+
+ protected override object Read (byte token, BinaryReader r, ReaderContext ctx)
+ {
+ int len = Read7BitEncodedInt (r);
+ Hashtable ht = new Hashtable (len);
+
+ for (int i = 0; i < len; i++) {
+ object key = ReadObject (r, ctx);
+ object val = ReadObject (r, ctx);
+
+ ht.Add (key, val);
+ }
+
+ return ht;
+ }
+
+ protected override Type Type {
+ get { return typeof (Hashtable); }
+ }
+ }
+
+ class ObjectArrayFormatter : ObjectFormatter {
+ protected override void Write (BinaryWriter w, object o, WriterContext ctx)
+ {
+ object [] val = (object []) o;
+
+ w.Write (PrimaryId);
+ Write7BitEncodedInt (w, val.Length);
+ foreach (object i in val)
+ WriteObject (w, i, ctx);
+ }
+
+ protected override object Read (byte token, BinaryReader r, ReaderContext ctx)
+ {
+ int len = Read7BitEncodedInt (r);
+ object [] ret = new object [len];
+
+ for (int i = 0; i < len; i++)
+ ret [i] = ReadObject (r, ctx);
+
+ return ret;
+ }
+
+ protected override Type Type {
+ get { return typeof (object []); }
+ }
+ }
+
+ #endregion
+
+ #region System.Web Optimizations
+ class ColorFormatter : ObjectFormatter {
+ protected override void Write (BinaryWriter w, object o, WriterContext ctx)
+ {
+ Color c = (Color) o;
+
+ if (!c.IsKnownColor) {
+ w.Write (PrimaryId);
+ w.Write (c.ToArgb ());
+ } else {
+ w.Write (SecondaryId);
+ w.Write ((int) c.ToKnownColor ());
+ }
+ }
+
+ protected override object Read (byte token, BinaryReader r, ReaderContext ctx)
+ {
+ if (token == PrimaryId)
+ return Color.FromArgb (r.ReadInt32 ());
+ else
+ return Color.FromKnownColor ((KnownColor) r.ReadInt32 ());
+ }
+
+ protected override Type Type {
+ get { return typeof (Color); }
+ }
+
+ protected override int NumberOfIds {
+ get { return 2; }
+ }
+ }
+
+ #endregion
+
+ #region Special Formatters
+ class EnumFormatter : ObjectFormatter {
+ protected override void Write (BinaryWriter w, object o, WriterContext ctx)
+ {
+ object value = Convert.ChangeType (o, ((Enum) o).GetTypeCode ());
+ w.Write (PrimaryId);
+ WriteObject (w, o.GetType (), ctx);
+ WriteObject (w, value, ctx);
+ }
+
+ protected override object Read (byte token, BinaryReader r, ReaderContext ctx)
+ {
+ Type t = (Type) ReadObject (r, ctx);
+ object value = ReadObject (r, ctx);
+
+ return Enum.ToObject (t, value);
+ }
+ protected override Type Type {
+ get { return typeof (Enum); }
+ }
+ }
+
+ class TypeFormatter : ObjectFormatter {
+ protected override void Write (BinaryWriter w, object o, WriterContext ctx)
+ {
+ short key;
+ if (ctx.RegisterCache (o, out key)) {
+ w.Write (SecondaryId);
+ w.Write (key);
+ } else {
+ w.Write (PrimaryId);
+ w.Write (((Type) o).FullName);
+
+ // We should cache the name of the assembly
+ w.Write (((Type) o).Assembly.FullName);
+ }
+ }
+
+ protected override object Read (byte token, BinaryReader r, ReaderContext ctx)
+ {
+ if (token == PrimaryId) {
+ string type = r.ReadString ();
+ string assembly = r.ReadString ();
+
+ Type t = Assembly.Load (assembly).GetType (type);
+ ctx.CacheItem (t);
+ return t;
+ } else {
+ return ctx.GetCache (r.ReadInt16 ());
+ }
+ }
+
+ protected override Type Type {
+ get { return typeof (Type); }
+ }
+
+ protected override int NumberOfIds {
+ get { return 2; }
+ }
+ }
+
+ class SingleRankArrayFormatter : ObjectFormatter {
+ protected override void Write (BinaryWriter w, object o, WriterContext ctx)
+ {
+ Array val = (Array) o;
+
+ w.Write (PrimaryId);
+ WriteObject (w, val.GetType ().GetElementType (), ctx);
+
+ Write7BitEncodedInt (w, val.Length);
+ foreach (object i in val)
+ WriteObject (w, i, ctx);
+ }
+
+ protected override object Read (byte token, BinaryReader r, ReaderContext ctx)
+ {
+ Type t = (Type) ReadObject (r, ctx);
+ int len = Read7BitEncodedInt (r);
+ Array val = Array.CreateInstance (t, len);
+
+ for (int i = 0; i < len; i++)
+ val.SetValue (ReadObject (r, ctx), i);
+
+ return val;
+ }
+
+ protected override Type Type {
+ get { return typeof (Array); }
+ }
+ }
+
+ class BinaryObjectFormatter : ObjectFormatter {
+ protected override void Write (BinaryWriter w, object o, WriterContext ctx)
+ {
+ w.Write (PrimaryId);
+
+ MemoryStream ms = new MemoryStream (128);
+ new BinaryFormatter ().Serialize (ms, o);
+
+ byte [] buf = ms.GetBuffer ();
+ Write7BitEncodedInt (w, buf.Length);
+ w.Write (buf, 0, buf.Length);
+ }
+
+ protected override object Read (byte token, BinaryReader r, ReaderContext ctx)
+ {
+ int len = Read7BitEncodedInt (r);
+ byte [] buf = r.ReadBytes (len);
+ if (buf.Length != len)
+ throw new Exception ();
+
+ return new BinaryFormatter ().Deserialize (new MemoryStream (buf));
+ }
+
+ protected override Type Type {
+ get { return typeof (object); }
+ }
+ }
+
+ #endregion
+
+ #endregion
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI/OutputCacheLocation.cs b/mcs/class/System.Web/System.Web.UI/OutputCacheLocation.cs
index 173654504c0..79489330818 100644
--- a/mcs/class/System.Web/System.Web.UI/OutputCacheLocation.cs
+++ b/mcs/class/System.Web/System.Web.UI/OutputCacheLocation.cs
@@ -18,6 +18,9 @@ namespace System.Web.UI
Client,
Downstream,
Server,
- None
+ None,
+#if NET_1_1
+ ServerAndClient
+#endif
}
}
diff --git a/mcs/class/System.Web/System.Web.UI/Page.cs b/mcs/class/System.Web/System.Web.UI/Page.cs
index ba67d4b8ac5..8e0574bf63a 100755
--- a/mcs/class/System.Web/System.Web.UI/Page.cs
+++ b/mcs/class/System.Web/System.Web.UI/Page.cs
@@ -346,7 +346,7 @@ public class Page : TemplateControl, IHttpHandler
NameValueCollection coll = null;
if (IsPostBack)
- coll = req.Form;
+ coll = req.Form;
else
coll = req.QueryString;
@@ -401,7 +401,48 @@ public class Page : TemplateControl, IHttpHandler
OutputCacheLocation location,
string varyByParam)
{
- throw new NotImplementedException ();
+ HttpCachePolicy cache = _context.Response.Cache;
+
+ switch (location) {
+ case OutputCacheLocation.Any:
+ cache.SetCacheability (HttpCacheability.Public);
+ cache.SetMaxAge (new TimeSpan (0, 0, duration));
+ cache.SetLastModified (_context.Timestamp);
+ goto case OutputCacheLocation.Server;
+ case OutputCacheLocation.Client:
+ cache.SetCacheability (HttpCacheability.Private);
+ cache.SetMaxAge (new TimeSpan (0, 0, duration));
+ cache.SetLastModified (_context.Timestamp);
+ break;
+ case OutputCacheLocation.Downstream:
+ cache.SetCacheability (HttpCacheability.Public);
+ cache.SetMaxAge (new TimeSpan (0, 0, duration));
+ cache.SetLastModified (_context.Timestamp);
+ break;
+ case OutputCacheLocation.Server:
+ if (varyByCustom != null)
+ cache.SetVaryByCustom (varyByCustom);
+
+ if (varyByParam.Length > 0) {
+ string[] prms = varyByParam.Split (';');
+ foreach (string p in prms)
+ cache.VaryByParams [p.Trim ()] = true;
+ cache.VaryByParams.IgnoreParams = false;
+ } else {
+ cache.VaryByParams.IgnoreParams = true;
+ }
+
+ if (varyByHeader != null) {
+ string[] hdrs = varyByHeader.Split (';');
+ foreach (string h in hdrs)
+ cache.VaryByHeaders [h.Trim ()] = true;
+ }
+ _context.Response.CacheResponse (_context.Request);
+ break;
+ case OutputCacheLocation.None:
+ break;
+ }
+ cache.SetExpires (_context.Timestamp.AddSeconds (duration));
}
[EditorBrowsable (EditorBrowsableState.Advanced)]
@@ -683,7 +724,7 @@ public class Page : TemplateControl, IHttpHandler
hiddenFields.Add (hiddenFieldName, hiddenFieldInitialValue);
}
- [MonoTODO]
+ [MonoTODO]
public void RegisterClientScriptFile (string a, string b, string c)
{
throw new NotImplementedException ();
@@ -828,8 +869,59 @@ public class Page : TemplateControl, IHttpHandler
throw new ArgumentNullException ("type");
return System.Web.Handlers.AssemblyResourceLoader.GetResourceUrl (type, resourceName);
- }
-
+ }
+
+ Stack dataItemCtx;
+
+ internal void PushDataItemContext (object o)
+ {
+ if (dataItemCtx == null)
+ dataItemCtx = new Stack ();
+
+ dataItemCtx.Push (o);
+ }
+
+ internal void PopDataItemContext ()
+ {
+ if (dataItemCtx == null)
+ throw new InvalidOperationException ();
+
+ dataItemCtx.Pop ();
+ }
+
+ internal object CurrentDataItem {
+ get {
+ if (dataItemCtx == null)
+ throw new InvalidOperationException ("No data item");
+
+ return dataItemCtx.Peek ();
+ }
+ }
+
+ protected object Eval (string expression)
+ {
+ return DataBinder.Eval (CurrentDataItem, expression);
+ }
+
+ protected object Eval (string expression, string format)
+ {
+ return DataBinder.Eval (CurrentDataItem, expression, format);
+ }
+
+ protected object XPath (string xpathexpression)
+ {
+ return XPathBinder.Eval (CurrentDataItem, xpathexpression);
+ }
+
+ protected object XPath (string xpathexpression, string format)
+ {
+ return XPathBinder.Eval (CurrentDataItem, xpathexpression, format);
+ }
+
+ protected IEnumerable XPathSelect (string xpathexpression)
+ {
+ return XPathBinder.Select (CurrentDataItem, xpathexpression);
+ }
#endif
}
diff --git a/mcs/class/System.Web/System.Web.UI/PersistChildrenAttribute.cs b/mcs/class/System.Web/System.Web.UI/PersistChildrenAttribute.cs
index a38d49c817f..a60e22ad0a5 100755
--- a/mcs/class/System.Web/System.Web.UI/PersistChildrenAttribute.cs
+++ b/mcs/class/System.Web/System.Web.UI/PersistChildrenAttribute.cs
@@ -20,31 +20,31 @@ namespace System.Web.UI {
this.persist = persist;
}
- public static readonly PersistChildrenAttribute Default;
- public static readonly PersistChildrenAttribute Yes;
- public static readonly PersistChildrenAttribute No;
+ public static readonly PersistChildrenAttribute Default = new PersistChildrenAttribute (true);
+ public static readonly PersistChildrenAttribute Yes = new PersistChildrenAttribute (true);
+ public static readonly PersistChildrenAttribute No = new PersistChildrenAttribute (false);
public bool Persist {
get { return persist; }
}
- [MonoTODO]
public override bool Equals (object obj)
{
- return false;
+ if (!(obj is PersistChildrenAttribute))
+ return false;
+
+ return (((PersistChildrenAttribute) obj).persist == persist);
}
- [MonoTODO]
public override int GetHashCode ()
{
- return 42;
+ return persist ? 1 : 0;
}
- [MonoTODO]
public override bool IsDefaultAttribute ()
{
- return false;
+ return (persist == true);
}
}
}
-
+
diff --git a/mcs/class/System.Web/System.Web.UI/PersistenceModeAttribute.cs b/mcs/class/System.Web/System.Web.UI/PersistenceModeAttribute.cs
index 905c99d7a12..68460ec2d28 100755
--- a/mcs/class/System.Web/System.Web.UI/PersistenceModeAttribute.cs
+++ b/mcs/class/System.Web/System.Web.UI/PersistenceModeAttribute.cs
@@ -20,32 +20,41 @@ namespace System.Web.UI {
this.mode = mode;
}
- public static readonly PersistenceModeAttribute Attribute;
- public static readonly PersistenceModeAttribute Default;
- public static readonly PersistenceModeAttribute EncodedInnerDefaultProperty;
- public static readonly PersistenceModeAttribute InnerDefaultProperty;
- public static readonly PersistenceModeAttribute InnerProperty;
+ public static readonly PersistenceModeAttribute Attribute =
+ new PersistenceModeAttribute (PersistenceMode.Attribute);
+
+ public static readonly PersistenceModeAttribute Default =
+ new PersistenceModeAttribute (PersistenceMode.Attribute);
+
+ public static readonly PersistenceModeAttribute EncodedInnerDefaultProperty =
+ new PersistenceModeAttribute (PersistenceMode.EncodedInnerDefaultProperty);
+
+ public static readonly PersistenceModeAttribute InnerDefaultProperty =
+ new PersistenceModeAttribute (PersistenceMode.InnerDefaultProperty);
+
+ public static readonly PersistenceModeAttribute InnerProperty =
+ new PersistenceModeAttribute (PersistenceMode.InnerProperty);
public PersistenceMode Mode {
get { return mode; }
}
- [MonoTODO]
public override bool Equals (object obj)
{
- return false;
+ if (!(obj is PersistenceModeAttribute))
+ return false;
+
+ return ((PersistenceModeAttribute) obj).mode == mode;
}
- [MonoTODO]
public override int GetHashCode ()
{
- return 42;
+ return (int) mode;
}
- [MonoTODO]
public override bool IsDefaultAttribute ()
{
- return false;
+ return (mode == PersistenceMode.Attribute);
}
}
}
diff --git a/mcs/class/System.Web/System.Web.UI/StateManagedCollection.cs b/mcs/class/System.Web/System.Web.UI/StateManagedCollection.cs
new file mode 100644
index 00000000000..839589de586
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI/StateManagedCollection.cs
@@ -0,0 +1,289 @@
+//
+// System.Web.UI.StateManagedCollection
+//
+// Authors:
+// Ben Maurer (bmaurer@users.sourceforge.net)
+//
+// (C) 2003 Ben Maurer
+//
+
+#if NET_1_2
+using System.Collections;
+using System.Collections.Specialized;
+using System.Text;
+
+namespace System.Web.UI {
+ public abstract class StateManagedCollection : IList, IStateManager {
+
+ protected abstract object CreateKnownType (int index);
+ protected abstract void SetDirtyObject (object o);
+ protected virtual Type [] GetKnownTypes ()
+ {
+ return null;
+ }
+
+ #region OnXXX
+ protected virtual void OnClear ()
+ {
+ }
+
+ protected virtual void OnClearComplete ()
+ {
+ }
+
+ protected virtual void OnInsert (int index, object value)
+ {
+ }
+
+ protected virtual void OnInsertComplete (int index, object value)
+ {
+ }
+
+ protected virtual void OnRemove (int index, object value)
+ {
+ }
+
+ protected virtual void OnRemoveComplete (int index, object value)
+ {
+ }
+
+ protected virtual void OnValidate (object value)
+ {
+ if (value == null)
+ throw new ArgumentNullException ("value");
+ }
+ #endregion
+
+ #region IStateManager
+ void IStateManager.LoadViewState (object savedState)
+ {
+ int pos = -1;
+ foreach (Pair p in (ArrayList)savedState) {
+ pos ++;
+
+ if (p == null)
+ continue;
+ IStateManager itm;
+
+ if (p.Second is Type)
+ itm = (IStateManager) Activator.CreateInstance ((Type) p.Second);
+ else
+ itm = (IStateManager) CreateKnownType ((int) p.Second);
+
+ itm.LoadViewState (p.First);
+
+ if (pos >= Count)
+ items.Add (itm);
+ else
+ items [pos] = itm;
+
+ }
+ }
+
+ object IStateManager.SaveViewState ()
+ {
+ ArrayList saved = new ArrayList ();
+ Type [] knownTypes = GetKnownTypes ();
+
+ foreach (IStateManager itm in items) {
+ object state = itm.SaveViewState ();
+ if (state == null && !saveEverything) {
+ saved.Add (null);
+ continue;
+ }
+
+ Pair p = new Pair ();
+ p.First = state;
+
+ Type t = itm.GetType ();
+ int idx = -1;
+ if (knownTypes != null)
+ idx = Array.IndexOf (knownTypes, t);
+
+ if (idx != -1)
+ p.Second = idx;
+ else
+ p.Second = t;
+
+ saved.Add (p);
+ }
+
+ return saved;
+ }
+
+ void IStateManager.TrackViewState ()
+ {
+ isTrackingViewState = true;
+
+ foreach (IStateManager i in items)
+ i.TrackViewState ();
+ }
+
+ bool isTrackingViewState;
+ bool IStateManager.IsTrackingViewState {
+ get { return isTrackingViewState; }
+ }
+ #endregion
+
+ #region ICollection, IList, IEnumerable
+
+ public void Clear ()
+ {
+ this.OnClear ();
+ items.Clear ();
+ this.OnClearComplete ();
+
+ SetSaveEverything ();
+ }
+
+ public int IndexOf (object o)
+ {
+ if (o == null)
+ return -1;
+ return items.IndexOf (o);
+ }
+
+ public bool Contains (object o)
+ {
+ return o != null && items.Contains (o);
+ }
+
+ public IEnumerator GetEnumerator ()
+ {
+ return items.GetEnumerator ();
+ }
+
+ void System.Collections.ICollection.CopyTo (Array array, int index)
+ {
+ items.CopyTo (array, index);
+ }
+
+ IEnumerator IEnumerable.GetEnumerator ()
+ {
+ return GetEnumerator ();
+ }
+
+ int IList.Add (object value)
+ {
+ OnValidate(value);
+ if (isTrackingViewState) {
+ ((IStateManager) value).TrackViewState ();
+ SetDirtyObject (value);
+ }
+
+ OnInsert (-1, value);
+ items.Add (value);
+ OnInsertComplete (-1, value);
+
+ return Count - 1;
+ }
+
+ void IList.Insert (int index, object value)
+ {
+ OnValidate(value);
+ if (isTrackingViewState) {
+ ((IStateManager) value).TrackViewState ();
+ SetDirtyObject (value);
+ }
+
+ OnInsert (index, value);
+ items.Insert (index, value);
+ OnInsertComplete(index, value);
+
+ SetSaveEverything ();
+ }
+
+ void IList.Remove (object value)
+ {
+ if (value == null)
+ return;
+ OnValidate (value);
+ ((IList)this).RemoveAt (IndexOf (value));
+ }
+ void IList.RemoveAt (int index)
+ {
+ object o = items [index];
+
+ OnRemove (index, o);
+ items.RemoveAt (index);
+ OnRemoveComplete(index, o);
+
+ SetSaveEverything ();
+ }
+
+ void IList.Clear ()
+ {
+ this.Clear ();
+ }
+
+ bool IList.Contains (object value)
+ {
+ if (value == null)
+ return false;
+
+ OnValidate (value);
+ return Contains (value);
+ }
+
+ int IList.IndexOf (object value)
+ {
+ if (value == null)
+ return -1;
+
+ OnValidate (value);
+ return IndexOf (value);
+ }
+
+ public int Count {
+ get { return items.Count; }
+ }
+
+ int ICollection.Count {
+ get { return items.Count; }
+ }
+
+ bool ICollection.IsSynchronized {
+ get { return false; }
+ }
+
+ object ICollection.SyncRoot {
+ get { return this; }
+ }
+
+ bool IList.IsFixedSize {
+ get { return false; }
+ }
+
+ bool IList.IsReadOnly {
+ get { return false; }
+ }
+
+ object IList.this [int index] {
+ get { return items [index]; }
+ set {
+ if (index < 0 || index >= Count)
+ throw new ArgumentOutOfRangeException ("index");
+
+ OnValidate (value);
+ if (isTrackingViewState) {
+ ((IStateManager) value).TrackViewState ();
+ SetDirtyObject (value);
+ }
+
+ items [index] = value;
+ }
+ }
+ #endregion
+
+ ArrayList items = new ArrayList ();
+
+ bool saveEverything = false;
+ void SetSaveEverything ()
+ {
+ if (isTrackingViewState)
+ saveEverything = true;
+ }
+ }
+}
+#endif
+
diff --git a/mcs/class/System.Web/System.Web.UI/TemplateControlParser.cs b/mcs/class/System.Web/System.Web.UI/TemplateControlParser.cs
index 9110c684163..d02e6229947 100644
--- a/mcs/class/System.Web/System.Web.UI/TemplateControlParser.cs
+++ b/mcs/class/System.Web/System.Web.UI/TemplateControlParser.cs
@@ -20,6 +20,10 @@ namespace System.Web.UI
bool autoEventWireup = true;
bool enableViewState = true;
+ protected TemplateControlParser ()
+ {
+ }
+
internal override void ProcessMainAttributes (Hashtable atts)
{
autoEventWireup = GetBool (atts, "AutoEventWireup", true);
@@ -103,9 +107,25 @@ namespace System.Web.UI
string page = GetString (atts, "Page", null);
string control = GetString (atts, "Control", null);
- //TODO: compile and store control/page
- Console.WriteLine ("WARNING: Reference is not supported yet!");
-
+ bool is_page = (page != null);
+ if (!is_page && control == null)
+ ThrowParseException ("Must provide 'page' or 'control' attribute");
+
+ if (is_page && control != null)
+ ThrowParseException ("'page' and 'control' are mutually exclusive");
+
+ string filepath = (!is_page) ? control : page;
+ filepath = MapPath (filepath);
+ AddDependency (filepath);
+ Type ctype;
+ if (is_page) {
+ PageParser pp = new PageParser (page, filepath, Context);
+ ctype = pp.CompileIntoType ();
+ } else {
+ ctype = UserControlParser.GetCompiledType (control, filepath, Context);
+ }
+
+ AddAssembly (ctype.Assembly, true);
if (atts.Count != 0)
ThrowParseException ("Unknown attribute: " + GetOneKey (atts));
diff --git a/mcs/class/System.Web/System.Web.UI/TemplateParser.cs b/mcs/class/System.Web/System.Web.UI/TemplateParser.cs
index 9b1c0d91988..358f75e03c5 100755
--- a/mcs/class/System.Web/System.Web.UI/TemplateParser.cs
+++ b/mcs/class/System.Web/System.Web.UI/TemplateParser.cs
@@ -36,7 +36,11 @@ namespace System.Web.UI
bool debug;
string compilerOptions;
string language;
-
+ bool output_cache;
+ int oc_duration;
+ string oc_header, oc_custom, oc_param;
+ OutputCacheLocation oc_location;
+
internal TemplateParser ()
{
imports = new ArrayList ();
@@ -146,9 +150,53 @@ namespace System.Web.UI
return;
}
+ cmp = String.Compare ("OutputCache", directive, true);
+ if (cmp == 0) {
+ output_cache = true;
+
+ if (atts ["Duration"] == null)
+ ThrowParseException ("The directive is missing a 'duration' attribute.");
+ if (atts ["VaryByParam"] == null)
+ ThrowParseException ("This directive is missing a 'VaryByParam' " +
+ "attribute, which should be set to \"none\", \"*\", " +
+ "or a list of name/value pairs.");
+
+ foreach (DictionaryEntry entry in atts) {
+ string key = (string) entry.Key;
+ switch (key.ToLower ()) {
+ case "duration":
+ oc_duration = Int32.Parse ((string) entry.Value);
+ if (oc_duration < 1)
+ ThrowParseException ("The 'd uration' attribute must be set " +
+ "to a positive integer value");
+ break;
+ case "varybyparam":
+ oc_param = (string) entry.Value;
+ break;
+ case "varybyheader":
+ oc_header = (string) entry.Value;
+ break;
+ case "varybycustom":
+ oc_custom = (string) entry.Value;
+ break;
+ case "location":
+ oc_location = (OutputCacheLocation) Enum.Parse (typeof (OutputCacheLocation),
+ (string) entry.Value);
+ break;
+ default:
+ ThrowParseException ("The '" + key + "' attribute is not " +
+ "supported by the 'Outputcache' directive.");
+ break;
+ }
+
+ }
+
+ return;
+ }
+
ThrowParseException ("Unknown directive: " + directive);
}
-
+
internal Type LoadType (string typeName)
{
// First try loaded assemblies, then try assemblies in Bin directory.
@@ -285,6 +333,7 @@ namespace System.Web.UI
{
atts.Remove ("Description"); // ignored
atts.Remove ("CodeBehind"); // ignored
+ atts.Remove ("AspCompat"); // ignored
debug = GetBool (atts, "Debug", true);
compilerOptions = GetString (atts, "CompilerOptions", null);
@@ -427,6 +476,31 @@ namespace System.Web.UI
internal bool Debug {
get { return debug; }
}
+
+ internal bool OutputCache {
+ get { return output_cache; }
+ }
+
+ internal int OutputCacheDuration {
+ get { return oc_duration; }
+ }
+
+ internal string OutputCacheVaryByHeader {
+ get { return oc_header; }
+ }
+
+ internal string OutputCacheVaryByCustom {
+ get { return oc_custom; }
+ }
+
+ internal OutputCacheLocation OutputCacheLocation {
+ get { return oc_location; }
+ }
+
+ internal string OutputCacheVaryByParam {
+ get { return oc_param; }
+ }
+
}
}
diff --git a/mcs/class/System.Web/System.Web.Util/AltSerialization.cs b/mcs/class/System.Web/System.Web.Util/AltSerialization.cs
new file mode 100644
index 00000000000..e336555bc37
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.Util/AltSerialization.cs
@@ -0,0 +1,162 @@
+//
+// System.Web.Util.AltSerialization
+//
+// Author(s):
+// Gonzalo Paniagua Javier (gonzalo@ximian.com)
+// Jackson Harper (jackson@ximian.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+using System.IO;
+using System.Collections;
+using System.Runtime.Serialization.Formatters.Binary;
+
+namespace System.Web.Util {
+
+ internal sealed class AltSerialization {
+
+ private static ArrayList types;
+
+ internal static readonly int NullIndex = 16;
+
+ private AltSerialization () { }
+
+
+ static AltSerialization ()
+ {
+ types = new ArrayList ();
+ types.Add ("");
+ types.Add (typeof (string));
+ types.Add (typeof (int));
+ types.Add (typeof (bool));
+ types.Add (typeof (DateTime));
+ types.Add (typeof (Decimal));
+ types.Add (typeof (Byte));
+ types.Add (typeof (Char));
+ types.Add (typeof (Single));
+ types.Add (typeof (Double));
+ types.Add (typeof (short));
+ types.Add (typeof (long));
+ types.Add (typeof (ushort));
+ types.Add (typeof (uint));
+ types.Add (typeof (ulong));
+ }
+
+ internal static void SerializeByType (BinaryWriter w, object value)
+ {
+ Type type = value.GetType ();
+ int i = types.IndexOf (type);
+ if (i == -1) {
+ w.Write (15); // types.Count
+ BinaryFormatter bf = new BinaryFormatter ();
+ bf.Serialize (w.BaseStream, value);
+ return;
+ }
+
+ w.Write (i);
+ switch (i) {
+ case 1:
+ w.Write ((string) value);
+ break;
+ case 2:
+ w.Write ((int) value);
+ break;
+ case 3:
+ w.Write ((bool) value);
+ break;
+ case 4:
+ w.Write (((DateTime) value).Ticks);
+ break;
+ case 5:
+ w.Write ((decimal) value);
+ break;
+ case 6:
+ w.Write ((byte) value);
+ break;
+ case 7:
+ w.Write ((char) value);
+ break;
+ case 8:
+ w.Write ((float) value);
+ break;
+ case 9:
+ w.Write ((double) value);
+ break;
+ case 10:
+ w.Write ((short) value);
+ break;
+ case 11:
+ w.Write ((long) value);
+ break;
+ case 12:
+ w.Write ((ushort) value);
+ break;
+ case 13:
+ w.Write ((uint) value);
+ break;
+ case 14:
+ w.Write ((ulong) value);
+ break;
+ }
+ }
+
+ internal static object DeserializeFromIndex (int index, BinaryReader r)
+ {
+ if (index == 15){
+ BinaryFormatter bf = new BinaryFormatter ();
+ return bf.Deserialize (r.BaseStream);
+ }
+
+ object value = null;
+ switch (index) {
+ case 1:
+ value = r.ReadString ();
+ break;
+ case 2:
+ value = r.ReadInt32 ();
+ break;
+ case 3:
+ value = r.ReadBoolean ();
+ break;
+ case 4:
+ value = new DateTime (r.ReadInt64 ());
+ break;
+ case 5:
+ value = r.ReadDecimal ();
+ break;
+ case 6:
+ value = r.ReadByte ();
+ break;
+ case 7:
+ value = r.ReadChar ();
+ break;
+ case 8:
+ value = r.ReadSingle ();
+ break;
+ case 9:
+ value = r.ReadDouble ();
+ break;
+ case 10:
+ value = r.ReadInt16 ();
+ break;
+ case 11:
+ value = r.ReadInt64 ();
+ break;
+ case 12:
+ value = r.ReadUInt16 ();
+ break;
+ case 13:
+ value = r.ReadUInt32 ();
+ break;
+ case 14:
+ value = r.ReadUInt64 ();
+ break;
+ }
+
+ return value;
+ }
+ }
+}
+
diff --git a/mcs/class/System.Web/System.Web.Util/ChangeLog b/mcs/class/System.Web/System.Web.Util/ChangeLog
index 0bf1d2b008f..20b8897f497 100644
--- a/mcs/class/System.Web/System.Web.Util/ChangeLog
+++ b/mcs/class/System.Web/System.Web.Util/ChangeLog
@@ -1,3 +1,20 @@
+2003-11-27 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * UrlUtils.cs: fix bug introduced with last change that makes relative
+ paths fail. Closes bug #51448.
+
+2003-11-27 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * UrlUtils.cs: fixed Combine() handling of ~.
+
+2003-11-25 Jackson Harper <jackson@ximian.com>
+
+ * AltSerialization.cs: Utility methods for optimized serializing.
+
+2003-11-13 Jackson Harper <jackson@ximian.com>
+
+ * TimeUtil.cs: Utility methods for dealing with time.
+
2003-11-08 Ben Maurer <bmaurer@users.sourceforge.net>
* UrlUtils.cs: new function to do the app mapping, but make
diff --git a/mcs/class/System.Web/System.Web.Util/TimeUtil.cs b/mcs/class/System.Web/System.Web.Util/TimeUtil.cs
new file mode 100644
index 00000000000..8f8ca72b2d0
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.Util/TimeUtil.cs
@@ -0,0 +1,24 @@
+//
+// System.Web.Util.TimeUtil
+//
+// Author(s):
+// Jackson Harper (jackson@ximian.com)
+//
+// (C) 2003 Novell, Inc, (http://www.novell.com)
+//
+
+using System;
+
+namespace System.Web.Util {
+
+ internal sealed class TimeUtil {
+
+ private TimeUtil () { }
+
+ internal static string ToUtcTimeString (DateTime dt)
+ {
+ return dt.ToUniversalTime ().ToString ("ddd, d MMM yyyy HH:mm:ss ") + "GMT";
+ }
+ }
+}
+
diff --git a/mcs/class/System.Web/System.Web.Util/UrlUtils.cs b/mcs/class/System.Web/System.Web.Util/UrlUtils.cs
index 35eb7e0dca4..5c6e765f97b 100644
--- a/mcs/class/System.Web/System.Web.Util/UrlUtils.cs
+++ b/mcs/class/System.Web/System.Web.Util/UrlUtils.cs
@@ -106,23 +106,40 @@ namespace System.Web.Util
public static string Combine (string basePath, string relPath)
{
+ if (relPath == null)
+ throw new ArgumentNullException ("relPath");
+
+ int rlength = relPath.Length;
+ if (rlength == 0)
+ return "";
+
FailIfPhysicalPath (relPath);
if (IsRooted (relPath))
return Reduce (relPath);
-
- if (relPath.Length < 3 || relPath [0] != '~' || relPath [0] == '/' || relPath [0] == '\\') {
- if (basePath == null || (basePath.Length == 1 && basePath [0] == '/'))
- basePath = String.Empty;
-
- string slash = relPath [0] == '/' ? "" : "/";
- return Reduce (basePath + slash + relPath);
- }
+
+ char first = relPath [0];
+ if (rlength < 3 || first == '~' || first == '/' || first == '\\') {
+ if (basePath == null || (basePath.Length == 1 && basePath [0] == '/'))
+ basePath = String.Empty;
+
+ if (first == '~') {
+ if (rlength == 1) {
+ relPath = "";
+ } else if (rlength > 1 && relPath [1] == '/') {
+ relPath = relPath.Substring (2);
+ }
+ }
+
+ string slash = (first == '/') ? "" : "/";
+ return Reduce (basePath + slash + relPath);
+ }
+
string vPath = HttpRuntime.AppDomainAppVirtualPath;
if (vPath.Length <= 1)
vPath = String.Empty;
- return Reduce (vPath + "/" + relPath.Substring (2));
+ return Reduce (vPath + "/" + relPath);
}
public static bool IsValidProtocol(string protocol)
diff --git a/mcs/class/System.Web/System.Web.dll.sources b/mcs/class/System.Web/System.Web.dll.sources
index 801d81f0303..1ed3f84d987 100755
--- a/mcs/class/System.Web/System.Web.dll.sources
+++ b/mcs/class/System.Web/System.Web.dll.sources
@@ -51,8 +51,10 @@ System.Web/ProcessInfo.cs
System.Web/ProcessModelInfo.cs
System.Web/ProcessShutdownReason.cs
System.Web/ProcessStatus.cs
+System.Web/QueueManager.cs
System.Web/StaticFileHandler.cs
System.Web/TODOAttribute.cs
+System.Web/TimeoutManager.cs
System.Web/TraceContext.cs
System.Web/TraceMode.cs
System.Web/WebCategoryAttribute.cs
@@ -66,8 +68,11 @@ System.Web.Caching/CacheDefinitions.cs
System.Web.Caching/CacheDependency.cs
System.Web.Caching/CacheEntry.cs
System.Web.Caching/CacheExpires.cs
+System.Web.Caching/OutputCacheModule.cs
System.Web.Caching/ExpiresBuckets.cs
System.Web.Caching/Watcher.cs
+System.Web.Caching/CachedRawResponse.cs
+System.Web.Caching/CachedVaryBy.cs
System.Web.Compilation/BaseCompiler.cs
System.Web.Compilation/AspParser.cs
System.Web.Compilation/AspGenerator.cs
@@ -103,6 +108,8 @@ System.Web.Configuration/HttpCapabilitiesBase.cs
System.Web.Configuration/HttpConfigurationContext.cs
System.Web.Configuration/HttpHandlersSectionHandler.cs
System.Web.Configuration/HttpModulesConfigurationHandler.cs
+System.Web.Configuration/HttpRuntimeConfig.cs
+System.Web.Configuration/HttpRuntimeConfigurationHandler.cs
System.Web.Configuration/ModuleItem.cs
System.Web.Configuration/ModulesConfiguration.cs
System.Web.Configuration/AuthorizationConfigHandler.cs
@@ -170,6 +177,9 @@ System.Web.SessionState/SessionStateSectionHandler.cs
System.Web.SessionState/ISessionHandler.cs
System.Web.SessionState/SessionInProcHandler.cs
System.Web.SessionState/SessionSQLServerHandler.cs
+System.Web.SessionState/SessionStateServerHandler.cs
+System.Web.SessionState/StateServerItem.cs
+System.Web.SessionState/RemoteStateServer.cs
System.Web.SessionState/SessionId.cs
System.Web.SessionState/StateRuntime.cs
System.Web.UI/ApplicationFileParser.cs
@@ -330,6 +340,7 @@ System.Web.UI.WebControls/DataListItemCollection.cs
System.Web.UI.WebControls/DataListItemEventArgs.cs
System.Web.UI.WebControls/DataListItemEventHandler.cs
System.Web.UI.WebControls/Xml.cs
+System.Web.UI.WebControls/XmlBuilder.cs
System.Web.UI.WebControls/DayNameFormat.cs
System.Web.UI.WebControls/DayRenderEventArgs.cs
System.Web.UI.WebControls/DayRenderEventHandler.cs
@@ -439,6 +450,8 @@ System.Web.Util/WebEqualComparer.cs
System.Web.Util/WebHashCodeProvider.cs
System.Web.Util/WebTrace.cs
System.Web.Util/WebEncoding.cs
+System.Web.Util/TimeUtil.cs
+System.Web.Util/AltSerialization.cs
System.Web.UI/IHierarchicalEnumerable.cs
System.Web.UI/IHierarchyData.cs
System.Web.UI/INavigateUIData.cs
@@ -464,3 +477,48 @@ System.Web.UI.WebControls/XmlHierarchicalEnumerable.cs
System.Web.UI.WebControls/XmlHierarchyData.cs
System.Web.UI/HierarchicalDataSourceControl.cs
System.Web.UI.WebControls/DataBoundControl.cs
+System.Web.UI.WebControls/ControlParameter.cs
+System.Web.UI.WebControls/CookieParameter.cs
+System.Web.UI.WebControls/FormParameter.cs
+System.Web.UI.WebControls/Parameter.cs
+System.Web.UI.WebControls/ParameterCollection.cs
+System.Web.UI.WebControls/QueryStringParameter.cs
+System.Web.UI.WebControls/SessionParameter.cs
+System.Web.UI/StateManagedCollection.cs
+System.Web.UI/KeyedList.cs
+System.Web.UI/KeyedListEnumerator.cs
+System.Web.UI/ObjectStateFormatter.cs
+System.Web.UI.WebControls/SqlDataSource.cs
+System.Web.UI.WebControls/SqlDataSourceCommandEventArgs.cs
+System.Web.UI.WebControls/SqlDataSourceCommandEventHandler.cs
+System.Web.UI.WebControls/SqlDataSourceStatusEventArgs.cs
+System.Web.UI.WebControls/SqlDataSourceStatusEventHandler.cs
+System.Web.UI.WebControls/SqlDataSourceView.cs
+System.Web.UI.WebControls/SqlDataSourceMode.cs
+System.Web.Security/ADMembershipProvider.cs
+System.Web.Security/AccessMembershipProvider.cs
+System.Web.Security/AccessRoleProvider.cs
+System.Web.Security/AnonymousIdentificationEventArgs.cs
+System.Web.Security/AnonymousIdentificationEventHandler.cs
+System.Web.Security/AnonymousIdentificationModule.cs
+System.Web.Security/CookieProtection.cs
+System.Web.Security/IMembershipProvider.cs
+System.Web.Security/IRoleProvider.cs
+System.Web.Security/Membership.cs
+System.Web.Security/MembershipCreateStatus.cs
+System.Web.Security/MembershipCreateUserException.cs
+System.Web.Security/MembershipOnlineStatus.cs
+System.Web.Security/MembershipPasswordException.cs
+System.Web.Security/MembershipPasswordFormat.cs
+System.Web.Security/MembershipProviderCollection.cs
+System.Web.Security/MembershipSortOptions.cs
+System.Web.Security/MembershipUser.cs
+System.Web.Security/MembershipUserCollection.cs
+System.Web.Security/RoleManagerEventArgs.cs
+System.Web.Security/RoleManagerEventHandler.cs
+System.Web.Security/RoleManagerModule.cs
+System.Web.Security/RolePrincipal.cs
+System.Web.Security/RoleProviderCollection.cs
+System.Web.Security/Roles.cs
+System.Web.Security/SqlMembershipProvider.cs
+System.Web.Security/SqlRoleProvider.cs
diff --git a/mcs/class/System.Web/System.Web/ChangeLog b/mcs/class/System.Web/System.Web/ChangeLog
index 7d32b336efb..297ac4154ff 100644
--- a/mcs/class/System.Web/System.Web/ChangeLog
+++ b/mcs/class/System.Web/System.Web/ChangeLog
@@ -1,3 +1,62 @@
+2003-11-26 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * HttpRuntime.cs: added request queue handling.
+
+ * QueueManager.cs: simple request queue.
+
+ * TimeoutManager.cs: added some locks to prevent the enumerator used in
+ CheckTimeouts to be out of synch.
+
+2003-11-25 Jackson Harper <jackson@ximian.com>
+
+ * HttpStaticObjectsCollection.cs: Add methods for serialization
+ and conversion to/from byte arrays.
+
+2003-11-21 Jackson Harper <jackson@ximian.com>
+
+ * HttpResponse.cs: When caching data set the content length in the
+ cached repsonse so that only that amount will be written back to
+ the client. Add method to write a range of binary data.
+ * HttpCacheVaryByParams.cs: Add method to retrieve param names.
+
+2003-11-21 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * HttpApplication.cs:
+ * HttpContext.cs:
+ * HttpRuntime.cs: add timeout handling.
+ * TimeoutManager.cs: new class that takes care of aborting threads on
+ timeout.
+
+2003-11-19 Jackson Harper <jackson@ximian.com>
+
+ * HttpWriter.cs: Use a constant for the buffer size so the cache
+ can get the buffer size. Add method to get the buffer.
+ * HttpResponse.cs: Methods for getting data to cache, and setting
+ vars from the cache.
+ * HttpCachePolicy.cs: Expose a pages cache expire time.
+
+2003-11-18 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * HttpResponse.cs:
+ * HttpWriter.cs: some fixes to allow closing a response stream without
+ messing the rest.
+
+2003-11-13 Jackson Harper <jackson@ximian.com>
+
+ * HttpCachePolicy.cs: Make sure cacheability and maxage get
+ set. Add method to set Http response header data
+ * HttpCacheVaryByParams.cs: Add method to create a response header.
+ * HttpCacheability.cs: Add ServerAndPrivate and ServerAndNoCache.
+ * HttpResponse.cs: Set cache headers.
+
+2003-11-11 Ben Maurer <bmaurer@users.sourceforge.net>
+
+ * HttpModuleCollection.cs (GetKey): Recursion, again!
+
+2003-11-11 Ben Maurer <bmaurer@users.sourceforge.net>
+
+ * HttpClientCertificate.cs (ValidUntil): recursion!
+
2003-11-08 Ben Maurer <bmaurer@users.sourceforge.net>
* SiteMapNode.cs (GetDataSourceView): Implement.
diff --git a/mcs/class/System.Web/System.Web/HttpApplication.cs b/mcs/class/System.Web/System.Web/HttpApplication.cs
index 4bee2ef2cde..761cf9b4528 100644
--- a/mcs/class/System.Web/System.Web/HttpApplication.cs
+++ b/mcs/class/System.Web/System.Web/HttpApplication.cs
@@ -655,34 +655,35 @@ namespace System.Web
ExecuteNext ((Exception) obj);
}
- [MonoTODO()]
private Exception ExecuteState (IStateHandler state, ref bool readysync)
{
Exception lasterror = null;
try {
-
if (state.PossibleToTimeout) {
- // TODO: Start timeout possible
- try {
- state.Execute ();
- } finally {
- // TODO: end timeout possible
- }
+ _app.Context.BeginTimeoutPossible ();
+ }
- // Check if we have a timeout and wait for the exception.
- } else {
- state.Execute ();
+ try {
+ state.Execute ();
+ } finally {
+ if (state.PossibleToTimeout) {
+ _app.Context.EndTimeoutPossible ();
+ }
}
- if (state.CompletedSynchronously)
- readysync = true;
- else
- readysync = false;
+ if (state.PossibleToTimeout) {
+ // Async Execute
+ _app.Context.TryWaitForTimeout ();
+ }
+ readysync = state.CompletedSynchronously;
} catch (ThreadAbortException obj) {
- obj = obj;
- // TODO!
- // handle request timeout and return timeout httpexception
+ StepTimeout timeout = obj.ExceptionState as StepTimeout;
+ if (timeout != null) {
+ Thread.ResetAbort ();
+ lasterror = new HttpException ("The request timed out.");
+ _app.CompleteRequest ();
+ }
} catch (Exception obj) {
lasterror = obj;
}
@@ -782,10 +783,10 @@ namespace System.Web
internal void OnStateExecuteEnter ()
{
// TODO: Set correct culture for the thread
- // TODO: Register in timeout manager
_savedContext = HttpContext.Context;
HttpContext.Context = _Context;
+ HttpRuntime.TimeoutManager.Add (_Context);
_savedUser = Thread.CurrentPrincipal;
Thread.CurrentPrincipal = Context.User;
@@ -794,8 +795,8 @@ namespace System.Web
internal void OnStateExecuteLeave ()
{
// TODO: Restore culture for the thread
- // TODO: Remove from timeout manager
+ HttpRuntime.TimeoutManager.Remove (_Context);
HttpContext.Context = _savedContext;
if (null != _savedUser) {
Thread.CurrentPrincipal = _savedUser;
diff --git a/mcs/class/System.Web/System.Web/HttpCachePolicy.cs b/mcs/class/System.Web/System.Web/HttpCachePolicy.cs
index b4f944acf0f..d34e9f4b2f9 100644
--- a/mcs/class/System.Web/System.Web/HttpCachePolicy.cs
+++ b/mcs/class/System.Web/System.Web/HttpCachePolicy.cs
@@ -2,14 +2,15 @@
// System.Web.HttpCachePolicy
//
// Authors:
-// Patrik Torstensson (Patrik.Torstensson@labs2.com)
-// Tim Coleman (tim@timcoleman.com)
+// Patrik Torstensson (Patrik.Torstensson@labs2.com)
+// Tim Coleman (tim@timcoleman.com)
// Gonzalo Paniagua Javier (gonzalo@ximian.com)
//
using System;
using System.Collections;
using System.Text;
using System.Web.UI;
+using System.Web.Util;
namespace System.Web {
public sealed class HttpCachePolicy {
@@ -45,7 +46,7 @@ namespace System.Web {
TimeSpan proxyMaxAge;
ArrayList fields;
bool slidingExpiration;
-
+
#endregion
#region Properties
@@ -58,6 +59,10 @@ namespace System.Web {
get { return varyByParams; }
}
+ internal DateTime Expires {
+ get { return expireDate; }
+ }
+
#endregion // Properties
#region Methods
@@ -89,9 +94,9 @@ namespace System.Web {
if (cacheability < HttpCacheability.NoCache || cacheability > HttpCacheability.Public)
throw new ArgumentOutOfRangeException ("cacheability");
- if (cacheability > this.cacheability)
+ if (this.cacheability > 0 && cacheability > this.cacheability)
return;
-
+
this.cacheability = cacheability;
}
@@ -162,11 +167,12 @@ namespace System.Web {
{
if (date < TimeSpan.Zero)
throw new ArgumentOutOfRangeException ("date");
-
+
if (haveMaxAge && maxAge < date)
return;
- proxyMaxAge = date;
+ maxAge = date;
+ haveMaxAge = true;
}
public void SetNoServerCaching ()
@@ -226,6 +232,33 @@ namespace System.Web {
varyByCustom = custom;
}
+ internal void SetHeaders (HttpResponse response, ArrayList headers)
+ {
+ string cc, expires;
+ if (cacheability > HttpCacheability.NoCache) {
+ cc = String.Format ("{0}, max-age={1}", cacheability, (long) maxAge.TotalSeconds);
+ expires = TimeUtil.ToUtcTimeString (expireDate);
+ } else {
+ cc = "no-cache";
+ response.CacheControl = cc;
+ expires = "-1";
+ }
+
+ headers.Add (new HttpResponseHeader ("Cache-Control", cc));
+ headers.Add (new HttpResponseHeader ("Expires", expires));
+
+ if (etag != null)
+ headers.Add (new HttpResponseHeader ("ETag", etag));
+
+ if (haveLastModified)
+ headers.Add (new HttpResponseHeader ("Last-Modified",
+ TimeUtil.ToUtcTimeString (lastModified)));
+
+ if (varyByParams.IgnoreParams)
+ headers.Add (varyByParams.GetResponseHeader ());
+
+ }
+
#endregion // Methods
}
}
diff --git a/mcs/class/System.Web/System.Web/HttpCacheVaryByParams.cs b/mcs/class/System.Web/System.Web/HttpCacheVaryByParams.cs
index 057ae081d7e..a745e8b4f76 100644
--- a/mcs/class/System.Web/System.Web/HttpCacheVaryByParams.cs
+++ b/mcs/class/System.Web/System.Web/HttpCacheVaryByParams.cs
@@ -5,6 +5,7 @@
// Patrik Torstensson (Patrik.Torstensson@labs2.com)
//
using System;
+using System.Text;
using System.Collections;
namespace System.Web {
@@ -33,7 +34,25 @@ namespace System.Web {
_IgnoreParams = value;
}
}
-
+
+ internal HttpResponseHeader GetResponseHeader ()
+ {
+ if (_IgnoreParams)
+ throw new Exception ("Can not get VaryByParams Header when params are ignored.");
+
+ if (_Wildcard)
+ return new HttpResponseHeader ("Vary", "*");
+
+ StringBuilder builder = new StringBuilder ();
+ foreach (string item in _Items.Keys) {
+ if (!(bool) _Items [item])
+ continue;
+ builder.Append (item + ";");
+ }
+
+ return new HttpResponseHeader ("Vary", builder.ToString ());
+ }
+
public bool this[string header] {
get {
if (null == header) {
@@ -77,5 +96,18 @@ namespace System.Web {
}
}
}
+
+ internal string [] GetParamNames ()
+ {
+ if (_Items == null)
+ return null;
+
+ string[] prms = new string [_Items.Count];
+ int i = 0;
+ foreach (string prm in _Items.Keys)
+ prms [i++] = prm;
+
+ return prms;
+ }
}
}
diff --git a/mcs/class/System.Web/System.Web/HttpCacheability.cs b/mcs/class/System.Web/System.Web/HttpCacheability.cs
index 448996473c4..e434dd7bce2 100644
--- a/mcs/class/System.Web/System.Web/HttpCacheability.cs
+++ b/mcs/class/System.Web/System.Web/HttpCacheability.cs
@@ -14,5 +14,7 @@ namespace System.Web {
Private,
Server,
Public,
+ ServerAndPrivate,
+ ServerAndNoCache = 0x3
}
}
diff --git a/mcs/class/System.Web/System.Web/HttpClientCertificate.cs b/mcs/class/System.Web/System.Web/HttpClientCertificate.cs
index 4ffc12c0cd8..0127fd408bd 100644
--- a/mcs/class/System.Web/System.Web/HttpClientCertificate.cs
+++ b/mcs/class/System.Web/System.Web/HttpClientCertificate.cs
@@ -135,7 +135,7 @@ namespace System.Web {
public DateTime ValidUntil {
get {
- return ValidUntil;
+ return _ValidTo;
}
}
diff --git a/mcs/class/System.Web/System.Web/HttpContext.cs b/mcs/class/System.Web/System.Web/HttpContext.cs
index 5813e6dfc92..6575fab1b4a 100644
--- a/mcs/class/System.Web/System.Web/HttpContext.cs
+++ b/mcs/class/System.Web/System.Web/HttpContext.cs
@@ -1,8 +1,11 @@
//
// System.Web.HttpContext
//
-// Author:
-// Patrik Torstensson (Patrik.Torstensson@labs2.com)
+// Authors:
+// Patrik Torstensson (Patrik.Torstensson@labs2.com)
+// Gonzalo Paniagua Javier (gonzalo@ximian.com)
+//
+// (c) 2003 Novell, Inc. (http://www.novell.com)
//
using System;
using System.Collections;
@@ -33,6 +36,9 @@ namespace System.Web
private bool _skipauth;
private Hashtable _oItems;
private DateTime _oTimestamp;
+ int timeoutPossible;
+ long timeoutBegin;
+ object configTimeout;
public HttpContext (HttpRequest Request, HttpResponse Response)
{
@@ -243,6 +249,42 @@ namespace System.Web
}
}
+ internal void BeginTimeoutPossible ()
+ {
+ timeoutPossible = 1;
+ timeoutBegin = DateTime.Now.Ticks;
+ }
+
+ internal void EndTimeoutPossible ()
+ {
+ Interlocked.CompareExchange (ref timeoutPossible, 0, 1);
+ }
+
+ internal void TryWaitForTimeout ()
+ {
+ while (Interlocked.CompareExchange (ref timeoutPossible, 1, 1) == 1) {
+ Thread.Sleep (500);
+ }
+ }
+
+ internal bool CheckIfTimeout (DateTime dt)
+ {
+ TimeSpan ts = new TimeSpan (dt.Ticks - timeoutBegin);
+ return (ts > ConfigTimeout);
+ }
+
+ internal TimeSpan ConfigTimeout {
+ get {
+ if (configTimeout == null) {
+ HttpRuntimeConfig config = (HttpRuntimeConfig)
+ GetConfig ("system.web/httpRuntime");
+ configTimeout = new TimeSpan (0, 0, config.ExecutionTimeout);
+ }
+
+ return (TimeSpan) configTimeout;
+ }
+ }
+
internal void SetSession (HttpSessionState session)
{
_oSession = session;
diff --git a/mcs/class/System.Web/System.Web/HttpModuleCollection.cs b/mcs/class/System.Web/System.Web/HttpModuleCollection.cs
index c7dc329abc8..04bce8d3fdf 100644
--- a/mcs/class/System.Web/System.Web/HttpModuleCollection.cs
+++ b/mcs/class/System.Web/System.Web/HttpModuleCollection.cs
@@ -45,7 +45,7 @@ namespace System.Web {
}
public string GetKey(int index) {
- return GetKey(index);
+ return BaseGetKey(index);
}
public string [] AllKeys {
diff --git a/mcs/class/System.Web/System.Web/HttpResponse.cs b/mcs/class/System.Web/System.Web/HttpResponse.cs
index 364b7649698..d729db33a6f 100644
--- a/mcs/class/System.Web/System.Web/HttpResponse.cs
+++ b/mcs/class/System.Web/System.Web/HttpResponse.cs
@@ -2,7 +2,7 @@
// System.Web.HttpResponse
//
// Authors:
-// Patrik Torstensson (Patrik.Torstensson@labs2.com)
+// Patrik Torstensson (Patrik.Torstensson@labs2.com)
// Gonzalo Paniagua Javier (gonzalo@ximian.com)
//
// (c) 2002 Ximian, Inc. (http://www.ximian.com)
@@ -14,6 +14,7 @@ using System.IO;
using System.Text;
using System.Threading;
using System.Web.Util;
+using System.Web.Caching;
namespace System.Web
{
@@ -39,6 +40,7 @@ namespace System.Web
int _iStatusCode;
bool _ClientDisconnected;
+ bool closed;
string _sContentType;
string _sCacheControl;
@@ -58,7 +60,9 @@ namespace System.Web
HttpWorkerRequest _WorkerRequest;
ArrayList fileDependencies;
-
+ CachedRawResponse cached_response;
+ ArrayList cached_headers;
+
public HttpResponse (TextWriter output)
{
_bBuffering = true;
@@ -124,6 +128,25 @@ namespace System.Web
filtered = true;
}
+ internal bool IsCached {
+ get { return cached_response != null; }
+ }
+
+ internal void CacheResponse (HttpRequest request) {
+ cached_response = new CachedRawResponse (_CachePolicy);
+ }
+
+ internal CachedRawResponse GetCachedResponse () {
+ cached_response.StatusCode = StatusCode;
+ cached_response.StatusDescription = StatusDescription;
+ return cached_response;
+ }
+
+ internal void SetCachedHeaders (ArrayList headers)
+ {
+ cached_headers = headers;
+ }
+
[MonoTODO("We need to add cache headers also")]
private ArrayList GenerateHeaders ()
{
@@ -160,6 +183,9 @@ namespace System.Web
_sContentType));
}
+ if (_CachePolicy != null)
+ _CachePolicy.SetHeaders (this, oHeaders);
+
if (_sCacheControl != null) {
oHeaders.Add (new HttpResponseHeader (HttpWorkerRequest.HeaderPragma,
_sCacheControl));
@@ -179,12 +205,21 @@ namespace System.Web
return oHeaders;
}
-
+
private void SendHeaders ()
{
_WorkerRequest.SendStatus (StatusCode, StatusDescription);
- ArrayList oHeaders = GenerateHeaders ();
+ ArrayList oHeaders;
+
+ if (cached_headers != null)
+ oHeaders = cached_headers;
+ else
+ oHeaders = GenerateHeaders ();
+
+ if (cached_response != null)
+ cached_response.SetHeaders (oHeaders);
+
foreach (HttpResponseHeader oHeader in oHeaders)
oHeader.SendContent (_WorkerRequest);
@@ -595,6 +630,11 @@ namespace System.Web
OutputStream.Write (buffer, 0, buffer.Length);
}
+ internal void BinaryWrite (byte [] buffer, int start, int length)
+ {
+ OutputStream.Write (buffer, start, length);
+ }
+
public void Clear ()
{
if (_Writer != null)
@@ -627,9 +667,11 @@ namespace System.Web
public void Close ()
{
- _bClientDisconnected = false;
- _WorkerRequest.CloseConnection ();
- _bClientDisconnected = true;
+ if (closed && !_bClientDisconnected) {
+ _bClientDisconnected = false;
+ _WorkerRequest.CloseConnection ();
+ _bClientDisconnected = true;
+ }
}
internal void Dispose ()
@@ -658,12 +700,15 @@ namespace System.Web
public void Flush ()
{
+ if (closed)
+ throw new HttpException ("Response already finished.");
+
Flush (false);
}
private void Flush (bool bFinish)
{
- if (_bFlushing)
+ if (_bFlushing || closed)
return;
_bFlushing = true;
@@ -750,15 +795,17 @@ namespace System.Web
} else {
_Writer.SendContent (_WorkerRequest);
}
- } else {
- _Writer.Clear ();
}
_WorkerRequest.FlushResponse (bFinish);
-
- if (!bFinish)
- _Writer.Clear ();
+ if (IsCached) {
+ cached_response.ContentLength = (int) length;
+ cached_response.SetData (_Writer.GetBuffer ());
+ }
+ _Writer.Clear ();
} finally {
+ if (bFinish)
+ closed = true;
_bFlushing = false;
}
}
diff --git a/mcs/class/System.Web/System.Web/HttpRuntime.cs b/mcs/class/System.Web/System.Web/HttpRuntime.cs
index d3ce2a67101..f0ac0e3e56d 100644
--- a/mcs/class/System.Web/System.Web/HttpRuntime.cs
+++ b/mcs/class/System.Web/System.Web/HttpRuntime.cs
@@ -44,6 +44,11 @@ namespace System.Web {
private DateTime _firstRequestStartTime;
private Exception _initError;
+ private TimeoutManager timeoutManager;
+ private QueueManager queueManager;
+ private WaitCallback doRequestCallback;
+ private int pendingCallbacks;
+
static HttpRuntime ()
{
@@ -58,7 +63,9 @@ namespace System.Web {
}
public HttpRuntime ()
- {
+ {
+ doRequestCallback = new WaitCallback (DoRequest);
+ queueManager = new QueueManager ();
}
static internal object CreateInternalObject(Type type) {
@@ -70,8 +77,8 @@ namespace System.Web {
{
try {
_cache = new Cache ();
+ timeoutManager = new TimeoutManager ();
- // TODO: timeout manager
// TODO: Load all app domain data
// TODO: Trace manager
_endOfSendCallback = new HttpWorkerRequest.EndOfSendNotification(OnEndOfSend);
@@ -85,7 +92,6 @@ namespace System.Web {
private void OnFirstRequestStart() {
if (null == _initError) {
- // TODO: First request initialize (config, trace, request queue)
}
// If we got an error during init, throw to client now..
@@ -161,42 +167,44 @@ namespace System.Web {
if (null != request)
request.EndOfRequest();
- // TODO: Schedule more work in request queue
+ TryExecuteQueuedRequests ();
+ }
+
+ internal static void FinishUnavailable (HttpWorkerRequest wr)
+ {
+ HttpContext context = new HttpContext (wr);
+ HttpException exception = new HttpException (503, "Service unavailable");
+ Interlocked.Increment (ref _runtime._activeRequests);
+ _runtime.FinishRequest (context, exception);
}
private void OnAppDomainUnload(object state) {
Dispose();
}
- [MonoTODO]
+ [MonoTODO ("Move timeout value to config")]
internal void Dispose() {
- // TODO: Drain Request queue
- // TODO: Stop request queue
- // TODO: Move timeout value to config
+ queueManager.Dispose (); // Send a 503 to all queued requests
+ queueManager = null;
WaitForRequests(5000);
_cache = null;
HttpApplicationFactory.EndApplication();
}
- [MonoTODO]
internal void WaitForRequests(int ms) {
DateTime timeout = DateTime.Now.AddMilliseconds(ms);
do {
- // TODO: We should check the request queue here also
- if (_activeRequests == 0)
+ if (Interlocked.CompareExchange (ref _activeRequests, 0, 0) == 0)
return;
- Thread.Sleep(100);
+ Thread.Sleep (100);
} while (timeout > DateTime.Now);
}
- internal void InternalExecuteRequest(HttpWorkerRequest request)
+ internal void InternalExecuteRequest (HttpWorkerRequest request)
{
- if (request == null)
- throw new ArgumentNullException ("request");
-
IHttpHandler handler;
IHttpAsyncHandler async_handler;
@@ -237,10 +245,43 @@ namespace System.Web {
}
}
+ void DoRequest (object o)
+ {
+ Interlocked.Decrement (ref pendingCallbacks);
+ InternalExecuteRequest ((HttpWorkerRequest) o);
+ }
+
+ void TryExecuteQueuedRequests ()
+ {
+ // Wait for pending jobs to start
+ if (Interlocked.CompareExchange (ref pendingCallbacks, 3, 3) == 3) {
+ return;
+ }
+
+ if (!queueManager.CanExecuteRequest (false)) {
+ return;
+ }
+
+ HttpWorkerRequest wr = queueManager.Dequeue ();
+ if (wr == null) {
+ return;
+ }
+
+ Interlocked.Increment (ref pendingCallbacks);
+ ThreadPool.QueueUserWorkItem (doRequestCallback, wr);
+ TryExecuteQueuedRequests ();
+ }
+
public static void ProcessRequest (HttpWorkerRequest Request)
{
- // TODO: Request queue
- _runtime.InternalExecuteRequest(Request);
+ if (Request == null)
+ throw new ArgumentNullException ("Request");
+
+ if (_runtime.queueManager.CanExecuteRequest (false)) {
+ _runtime.InternalExecuteRequest (Request);
+ } else {
+ _runtime.queueManager.Queue (Request);
+ }
}
public static Cache Cache {
@@ -327,6 +368,12 @@ namespace System.Web {
}
}
+ internal static TimeoutManager TimeoutManager {
+ get {
+ return HttpRuntime._runtime.timeoutManager;
+ }
+ }
+
public static void Close ()
{
_runtime.Dispose();
diff --git a/mcs/class/System.Web/System.Web/HttpStaticObjectsCollection.cs b/mcs/class/System.Web/System.Web/HttpStaticObjectsCollection.cs
index d2027061ea2..9744dd2b5b1 100644
--- a/mcs/class/System.Web/System.Web/HttpStaticObjectsCollection.cs
+++ b/mcs/class/System.Web/System.Web/HttpStaticObjectsCollection.cs
@@ -1,4 +1,5 @@
using System;
+using System.IO;
using System.Collections;
namespace System.Web {
@@ -55,5 +56,73 @@ namespace System.Web {
return this;
}
}
+
+ private void Set (string name, object obj)
+ {
+ _Objects [name] = obj;
+ }
+
+ internal void Serialize (BinaryWriter w)
+ {
+ lock (_Objects) {
+ w.Write (Count);
+ foreach (string key in _Objects.Keys) {
+ w.Write (key);
+ object value = _Objects [key];
+ if (value == null) {
+ w.Write (System.Web.Util.AltSerialization.NullIndex);
+ continue;
+ }
+
+ System.Web.Util.AltSerialization.SerializeByType (w, value);
+ }
+ }
+ }
+
+ internal static HttpStaticObjectsCollection Deserialize (BinaryReader r)
+ {
+ HttpStaticObjectsCollection result = new HttpStaticObjectsCollection ();
+ for (int i = r.ReadInt32 (); i > 0; i--) {
+ string key = r.ReadString ();
+ int index = r.ReadInt32 ();
+ if (index == System.Web.Util.AltSerialization.NullIndex)
+ result.Set (key, null);
+ else
+ result.Set (key, System.Web.Util.AltSerialization.DeserializeFromIndex (index, r));
+ }
+
+ return result;
+ }
+
+ internal byte [] ToByteArray ()
+ {
+ MemoryStream stream = null;
+ try {
+ stream = new MemoryStream ();
+ Serialize (new BinaryWriter (stream));
+ return stream.GetBuffer ();
+ } catch {
+ throw;
+ } finally {
+ if (stream != null)
+ stream.Close ();
+ }
+ }
+
+ internal static HttpStaticObjectsCollection FromByteArray (byte [] data)
+ {
+ HttpStaticObjectsCollection objs = null;
+ MemoryStream stream = null;
+ try {
+ stream = new MemoryStream (data);
+ objs = Deserialize (new BinaryReader (stream));
+ } catch {
+ throw;
+ } finally {
+ if (stream != null)
+ stream.Close ();
+ }
+ return objs;
+ }
}
}
diff --git a/mcs/class/System.Web/System.Web/HttpWriter.cs b/mcs/class/System.Web/System.Web/HttpWriter.cs
index c2abb490c6d..756960d75a9 100644
--- a/mcs/class/System.Web/System.Web/HttpWriter.cs
+++ b/mcs/class/System.Web/System.Web/HttpWriter.cs
@@ -13,6 +13,8 @@ namespace System.Web
{
public sealed class HttpWriter : TextWriter
{
+ internal const int MaxBufferSize = 32768;
+
HttpResponse _Response;
HttpResponseStream _ResponseStream;
@@ -28,7 +30,7 @@ namespace System.Web
{
_Response = Response;
- _OutputStream = new MemoryStream (32768);
+ _OutputStream = new MemoryStream (MaxBufferSize);
_OutputHelper = new StreamWriter (_OutputStream, _Response.ContentEncoding);
_ResponseStream = new HttpResponseStream (this);
@@ -97,7 +99,6 @@ namespace System.Web
_OutputHelper.Close ();
_OutputStream.Close ();
- // Quick way of doing cleanup
_OutputStream = new MemoryStream (32768);
_OutputHelper = new StreamWriter (_OutputStream, _Response.ContentEncoding);
}
@@ -134,6 +135,10 @@ namespace System.Web
_OutputStream.Flush ();
}
+ internal byte[] GetBuffer () {
+ return _OutputStream.GetBuffer ();
+ }
+
public override Encoding Encoding
{
get { return _Encoding; }
@@ -146,7 +151,6 @@ namespace System.Web
public override void Close ()
{
- FlushBuffers ();
_Response.Flush ();
_Response.Close ();
}
@@ -159,7 +163,6 @@ namespace System.Web
{
if (!_Response.BufferOutput) {
FlushBuffers ();
- _Response.Flush ();
}
}
diff --git a/mcs/class/System.Web/System.Web/QueueManager.cs b/mcs/class/System.Web/System.Web/QueueManager.cs
new file mode 100644
index 00000000000..158fa90f189
--- /dev/null
+++ b/mcs/class/System.Web/System.Web/QueueManager.cs
@@ -0,0 +1,82 @@
+//
+// System.Web.QueueManager
+//
+// Authors:
+// Gonzalo Paniagua Javier (gonzalo@ximian.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+using System.Collections;
+using System.Threading;
+using System.Web.Configuration;
+
+namespace System.Web
+{
+ class QueueManager
+ {
+ int minFree;
+ int minLocalFree;
+ int queueLimit;
+ Queue queue;
+ bool disposing;
+
+ public QueueManager ()
+ {
+ HttpRuntimeConfig config;
+ config = (HttpRuntimeConfig) HttpContext.GetAppConfig ("system.web/httpRuntime");
+ minFree = config.MinFreeThreads;
+ minLocalFree = config.MinLocalRequestFreeThreads;
+ queueLimit = config.AppRequestQueueLimit;
+ queue = new Queue (queueLimit);
+ }
+
+ // TODO: handle local connections
+ public bool CanExecuteRequest (bool local)
+ {
+ if (disposing)
+ return false;
+
+ int threads, cports;
+ ThreadPool.GetAvailableThreads (out threads, out cports);
+ return (threads > minFree) || (local && threads > minLocalFree);
+ }
+
+ public void Queue (HttpWorkerRequest wr)
+ {
+ lock (queue) {
+ if (queue.Count < queueLimit) {
+ queue.Enqueue (wr);
+ return;
+ }
+ }
+
+ HttpRuntime.FinishUnavailable (wr);
+ }
+
+ public HttpWorkerRequest Dequeue ()
+ {
+ lock (queue) {
+ if (queue.Count > 0)
+ return (HttpWorkerRequest) queue.Dequeue ();
+ }
+
+ return null;
+ }
+
+ public void Dispose ()
+ {
+ if (disposing)
+ return;
+
+ disposing = true;
+ HttpWorkerRequest wr;
+ while ((wr = Dequeue ()) != null)
+ HttpRuntime.FinishUnavailable (wr);
+
+ queue = null;
+ }
+ }
+}
+
diff --git a/mcs/class/System.Web/System.Web/TimeoutManager.cs b/mcs/class/System.Web/System.Web/TimeoutManager.cs
new file mode 100644
index 00000000000..3aa6ca590ee
--- /dev/null
+++ b/mcs/class/System.Web/System.Web/TimeoutManager.cs
@@ -0,0 +1,106 @@
+//
+// System.Web.TimeoutManager
+//
+// Authors:
+// Gonzalo Paniagua Javier (gonzalo@ximian.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+using System.Collections;
+using System.Threading;
+using System.Web.Configuration;
+
+namespace System.Web
+{
+ class StepTimeout
+ {
+ }
+
+ class TimeoutManager
+ {
+ Timer timer;
+ Hashtable contexts;
+
+ public TimeoutManager ()
+ {
+ timer = new Timer (new TimerCallback (CheckTimeouts), null, 0, 15000);
+ contexts = Hashtable.Synchronized (new Hashtable ());
+ }
+
+ public void Add (HttpContext context)
+ {
+ object value = contexts [context];
+ if (value == null) {
+ value = Thread.CurrentThread;
+ } else if (value is Thread) {
+ ArrayList list = new ArrayList ();
+ list.Add (value);
+ list.Add (Thread.CurrentThread);
+ value = list;
+ } else {
+ ArrayList list = (ArrayList) value;
+ list.Add (Thread.CurrentThread);
+ value = list;
+ }
+
+ lock (this) {
+ contexts [context] = value;
+ }
+ }
+
+ public Thread Remove (HttpContext context)
+ {
+ object value = contexts [context];
+ if (value == null)
+ return null;
+
+ if (value is Thread) {
+ lock (this) {
+ contexts.Remove (context);
+ }
+ return (Thread) value;
+ }
+
+ ArrayList list = (ArrayList) value;
+ Thread result = null;
+ if (list.Count > 0) {
+ result = (Thread) list [list.Count - 1];
+ list.RemoveAt (list.Count - 1);
+ }
+
+ if (list.Count == 0) {
+ lock (this) {
+ contexts.Remove (context);
+ }
+ }
+
+ return result;
+ }
+
+ void CheckTimeouts (object state)
+ {
+ if (contexts.Count == 0) {
+ return;
+ }
+
+ DateTime now = DateTime.Now;
+ ArrayList clist = new ArrayList ();
+
+ lock (this) { // The lock prevents Keys enumerator from being out of synch
+ clist.AddRange (contexts.Keys);
+ }
+
+ foreach (HttpContext context in clist) {
+ if (!context.CheckIfTimeout (now))
+ continue;
+
+ Thread thread = Remove (context);
+ if (thread != null) // Only if context is removed right after the lock
+ thread.Abort (new StepTimeout ());
+ }
+ }
+ }
+}
+
diff --git a/mcs/class/System.Windows.Forms/Gtk/AccessibleEvents.cs b/mcs/class/System.Windows.Forms/Gtk/AccessibleEvents.cs
new file mode 100644
index 00000000000..8e0e546281b
--- /dev/null
+++ b/mcs/class/System.Windows.Forms/Gtk/AccessibleEvents.cs
@@ -0,0 +1,59 @@
+//
+// System.Windows.Forms.AccessibleEvents.cs
+//
+// Author:
+// Dennis Hayes (dennish@raytek.com)
+// (C) 2002 Ximian = , Inc. http://www.ximian.com
+//
+
+using System;
+
+namespace System.Windows.Forms {
+
+ /// <summary>
+ /// </summary>
+ public enum AccessibleEvents{
+ AcceleratorChange = 32786,
+ Create = 32768,
+ DefaultActionChange = 32765,
+ DescriptionChange = 32781,
+ Destroy = 32769,
+ Focus = 32773,
+ HelpChange = 32784,
+ Hide = 32771,
+ LocationChange = 32779,
+ NameChange = 32780,
+ ParentChange = 32783,
+ Reorder = 32772,
+ Selection = 32774,
+ SelectionAdd = 32775,
+ SelectionRemove = 32776,
+ SelectionWithin = 32777,
+ Show = 32770,
+ StateChange = 32778,
+ SystemAlert = 2,
+ SystemCaptureEnd = 9,
+ SystemCaptureStart = 8,
+ SystemContextHelpEnd = 13,
+ SystemContextHelpStart = 12,
+ SystemDialogEnd = 17,
+ SystemDialogStart = 16,
+ SystemDragDropEnd = 15,
+ SystemDragDropStart = 14,
+ SystemForeground = 3,
+ SystemMenuEnd = 5,
+ SystemMenuPopupEnd = 7,
+ SystemMenuPopupStart = 6,
+ SystemMenuStart = 4,
+ SystemMinimizeEnd = 23,
+ SystemMinimizeStart = 22,
+ SystemMoveSizeEnd = 11,
+ SystemMoveSizeStart = 10,
+ SystemScrollingEnd = 19,
+ SystemScrollingStart = 18,
+ SystemSound = 1,
+ SystemSwitchEnd = 21,
+ SystemSwitchStart = 20,
+ ValueChange = 32782
+ }
+}
diff --git a/mcs/class/System.Windows.Forms/Gtk/AccessibleNavigation.cs b/mcs/class/System.Windows.Forms/Gtk/AccessibleNavigation.cs
new file mode 100644
index 00000000000..b34241ed6aa
--- /dev/null
+++ b/mcs/class/System.Windows.Forms/Gtk/AccessibleNavigation.cs
@@ -0,0 +1,31 @@
+//
+// System.Windows.Forms.AccessibleNavigation.cs
+//
+// Author:
+// Jaak Simm (jaaksimm@firm.ee)
+// Dennis Hayes (dennish@raytek.com)
+// (C) 2002 Ximian, Inc. http://www.ximian.com
+//
+
+using System;
+
+namespace System.Windows.Forms {
+
+
+ /// <summary>
+ /// Specifies a values for navigating among accessible objects.
+ /// </summary>
+
+ public enum AccessibleNavigation {
+
+ //Values were verified with enumcheck.
+ Down = 2,
+ FirstChild = 7,
+ LastChild = 8,
+ Left = 3,
+ Next = 5,
+ Previous = 6,
+ Right = 4,
+ Up = 1
+ }
+}
diff --git a/mcs/class/System.Windows.Forms/Gtk/AccessibleObject.cs b/mcs/class/System.Windows.Forms/Gtk/AccessibleObject.cs
new file mode 100644
index 00000000000..db2e1d37fbc
--- /dev/null
+++ b/mcs/class/System.Windows.Forms/Gtk/AccessibleObject.cs
@@ -0,0 +1,303 @@
+//
+// System.Windows.Forms.AccessibleObject.cs
+//
+// Author:
+// stubbed out by Jaak Simm (jaaksimm@firm.ee)
+// Dennis Hayes (dennish@raytek.com)
+// (C) 2002/3 Ximian, Inc
+//
+
+using System;
+using System.Reflection;
+using System.Globalization;
+//using System.Windows.Forms.AccessibleObject.IAccessible;
+using System.Drawing;
+using Accessibility;
+using System.Runtime.InteropServices;
+namespace System.Windows.Forms {
+
+ /// <summary>
+ /// Provides information that accessibility applications use to adjust an application's UI for users with impairments.
+ /// </summary>
+ [MonoTODO]
+ public class AccessibleObject : MarshalByRefObject, IReflect, IAccessible {
+ private string defaultAction;
+ private string description;
+ private string help;
+ private string keyboardShortcut;
+ private AccessibleObject parent;
+ private AccessibleRole role;
+ private AccessibleStates state;
+ private string name;
+ private string value;
+ // --- Constructor ---
+ [MonoTODO]
+ public AccessibleObject() {
+ name = null;
+ parent = null;
+ role = AccessibleRole.None;
+ state = AccessibleStates.None;
+ value = null;
+
+ }
+
+ // --- Properties ---
+
+ //Version 1.1
+ protected void UseStdAccessibleObjects(IntPtr handle){
+ }
+
+ //Version 1.1
+ protected void UseStdAccessibleObjects(IntPtr handle, int objid){
+ }
+
+ public virtual Rectangle Bounds {
+ get { return Rectangle.Empty; } // As per spec for default. Expect override.
+ }
+
+ public virtual string DefaultAction {
+ get {return null; }// As per spec for default. Expect override.
+ }
+
+ public virtual string Description {
+ get {return null; }// As per spec for default. Expect override.
+ }
+
+ public virtual string Help {
+ get {return null; }// As per spec for default. Expect override.
+ }
+
+ public virtual string KeyboardShortcut {
+ get {return null; }// As per spec for default. Expect override.
+ }
+
+ public virtual string Name {
+ get { return name; }
+ set { name = value; }
+ }
+
+ public virtual string Value {
+ get { return this.value; }
+ set { this.value = value; }
+ }
+
+ public virtual AccessibleObject Parent {
+ get { return parent; }
+ set { parent = value; }
+ }
+
+ public virtual AccessibleRole Role {
+ get { return role; }
+ set { role = value; }
+ }
+
+ public virtual AccessibleStates State {
+ get { return state; }
+ set { state = value; }
+ }
+
+ // --- Methods ---
+
+ public virtual void DoDefaultAction() {
+ return; //default action is "" and cannot be changed, must be overridden.
+ }
+
+ [MonoTODO]
+ public virtual AccessibleObject GetChild(int index) {
+ return null;
+ }
+
+ [MonoTODO]
+ public virtual int GetChildCount() {
+ return -1; //as per spec
+ }
+
+ [MonoTODO]
+ public virtual AccessibleObject GetFocused() {
+ return null;//FIXME: not quite to spec.
+ }
+
+ public virtual int GetHelpTopic(out string fileName) {
+ fileName = "";
+ return -1;//no help
+ }
+
+ public virtual AccessibleObject GetSelected() {
+ return null;
+ }
+
+ [MonoTODO]
+ public virtual AccessibleObject HitTest(int x,int y) {
+ return null; }
+
+ [MonoTODO]
+ public virtual AccessibleObject Navigate(AccessibleNavigation navdir) {
+ //by default, navagate back to here. Does this work?
+ //not to spec, but better than execption FIXME:
+ return this;
+ }
+
+ [MonoTODO]
+ public virtual void Select(AccessibleSelection flags) {
+ return;//FIXME: Not to spec. should be over ridden anyway.
+ }
+
+ //Not part of spec?
+ //[MonoTODO]
+ //[ComVisible(true)]
+ //protected void UseStdAccessibleObjects(IntPtr handle,int objid)
+ //{
+ // throw new NotImplementedException ();
+ //}
+
+ // --- Methods: IReflect ---
+ [MonoTODO]
+ FieldInfo IReflect.GetField( string name,BindingFlags bindingAttr) {
+ // FIXME
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ FieldInfo[] IReflect.GetFields (BindingFlags bindingAttr) {
+ // FIXME
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ MemberInfo[] IReflect.GetMember( string name, BindingFlags bindingAttr) {
+ // FIXME
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ MemberInfo[] IReflect.GetMembers( BindingFlags bindingAttr) {
+ // FIXME
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ MethodInfo IReflect.GetMethod( string name, BindingFlags bindingAttr, Binder binder, Type[] types, ParameterModifier[] modifiers) {
+ // FIXME
+ throw new NotImplementedException ();
+ }
+ [MonoTODO]
+ MethodInfo IReflect.GetMethod( string name, BindingFlags bindingAttr) {
+ // FIXME
+ throw new NotImplementedException ();
+ }
+
+
+
+ [MonoTODO]
+ MethodInfo[] IReflect.GetMethods( BindingFlags bindingAttr) {
+ // FIXME
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ PropertyInfo[] IReflect.GetProperties( BindingFlags bindingAttr) {
+ // FIXME
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ PropertyInfo IReflect.GetProperty( string name, BindingFlags bindingAttr) {
+ // FIXME
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ PropertyInfo IReflect.GetProperty( string name, BindingFlags bindingAttr, Binder binder, Type returnType, Type[] types, ParameterModifier[] modifiers) {
+ // FIXME
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ //[Guid("")]
+ object IReflect.InvokeMember( string name, BindingFlags invokeAttr, Binder binder, object target, object[] args, ParameterModifier[] modifiers, CultureInfo culture, string[] namedParameters) {
+ // FIXME
+ throw new NotImplementedException ();
+ }
+
+
+ Type IReflect.UnderlyingSystemType {
+ //private Type UnderlyingSystemType {
+ get { throw new NotImplementedException (); }
+ }
+
+ void IAccessible.accDoDefaultAction(object childID) {
+ //FIXME:
+ }
+ int IAccessible.accChildCount{
+ get{
+ throw new NotImplementedException ();
+ }
+ }
+
+ object IAccessible.accFocus{
+ get{
+ throw new NotImplementedException ();
+ }
+ }
+ object IAccessible.accHitTest(int xLeft, int yTop) {
+ throw new NotImplementedException ();
+ }
+ void IAccessible.accLocation(out int pxLeft, out int pyTop, out int pcxWidth, out int pcyHeight, object childID) {
+ throw new NotImplementedException ();
+ }
+ object IAccessible.accNavigate(int navDir, object childID) {
+ throw new NotImplementedException ();
+ }
+ object IAccessible.accParent {
+ get{
+ throw new NotImplementedException ();
+ }
+ }
+ void IAccessible.accSelect(int flagsSelect, object childID) {
+ //FIXME:
+ }
+ object IAccessible.accSelection {
+ get{
+ throw new NotImplementedException ();
+ }
+ }
+ object IAccessible.get_accChild(object childID) {
+ throw new NotImplementedException ();
+ }
+ string IAccessible.get_accDefaultAction(object childID) {
+ throw new NotImplementedException ();
+ }
+ string IAccessible.get_accDescription(object childID) {
+ throw new NotImplementedException ();
+ }
+ string IAccessible.get_accHelp(object childID) {
+ throw new NotImplementedException ();
+ }
+ int IAccessible.get_accHelpTopic(out string pszHelpFile,object childID) {
+ throw new NotImplementedException ();
+ }
+ string IAccessible.get_accKeyboardShortcut(object childID) {
+ throw new NotImplementedException ();
+ }
+ string IAccessible.get_accName(object childID) {
+ throw new NotImplementedException ();
+ }
+ object IAccessible.get_accRole(object childID) {
+ throw new NotImplementedException ();
+ }
+ object IAccessible.get_accState(object childID) {
+ throw new NotImplementedException ();
+ }
+ string IAccessible.get_accValue(object childID) {
+ throw new NotImplementedException ();
+ }
+ void IAccessible.set_accName(object childID, string newName) {
+ //FIXME:
+ }
+ void IAccessible.set_accValue(object childID, string newValue) {
+ //FIXME:
+ }
+ }
+
+}
+
diff --git a/mcs/class/System.Windows.Forms/Gtk/AccessibleRole.cs b/mcs/class/System.Windows.Forms/Gtk/AccessibleRole.cs
new file mode 100644
index 00000000000..3b2f4f95404
--- /dev/null
+++ b/mcs/class/System.Windows.Forms/Gtk/AccessibleRole.cs
@@ -0,0 +1,81 @@
+//
+// System.Windows.Forms.AccessibleRole.cs
+//
+// Author:
+// Dennis Hayes (dennish@raytek.com)
+// (C) 2002/3 Ximian, Inc. http://www.ximian.com
+//
+
+using System;
+
+namespace System.Windows.Forms {
+
+ /// <summary>
+ /// </summary>
+ public enum AccessibleRole{
+ Alert = 8,
+ Animation = 54,
+ Application = 14,
+ Border = 19,
+ ButtonDropDown = 56,
+ ButtonDropDownGrid = 58,
+ ButtonMenu = 57,
+ Caret = 7,
+ Cell = 29,
+ Character = 32,
+ Chart = 17,
+ CheckButton = 44,
+ Client = 10,
+ Clock = 61,
+ Column = 27,
+ ColumnHeader = 25,
+ ComboBox = 46,
+ Cursor = 6,
+ Default = -1,
+ Diagram = 53,
+ Dial = 49,
+ Dialog = 18,
+ Document = 15,
+ DropList = 47,
+ Equation = 55,
+ Graphic = 40,
+ Grip = 4,
+ Grouping = 20,
+ HelpBalloon = 31,
+ HotkeyField = 50,
+ Indicator = 39,
+ Link = 30,
+ List = 33,
+ ListItem = 34,
+ MenuBar = 2,
+ MenuItem = 12,
+ MenuPopup = 11,
+ None = 0,
+ Outline = 35,
+ OutlineItem = 36,
+ PageTab = 37,
+ PageTabList = 60,
+ Pane = 16,
+ ProgressBar = 48,
+ PropertyPage = 38,
+ PushButton = 43,
+ RadioButton = 45,
+ Row = 28,
+ RowHeader = 26,
+ ScrollBar = 3,
+ Separator = 21,
+ Slider = 51,
+ Sound = 5,
+ SpinButton = 52,
+ StaticText = 41,
+ StatusBar = 23,
+ Table = 24,
+ Text = 42,
+ TitleBar = 1,
+ ToolBar = 22,
+ ToolTip = 13,
+ WhiteSpace = 59,
+ Window = 9
+ }
+
+}
diff --git a/mcs/class/System.Windows.Forms/Gtk/AccessibleSelection.cs b/mcs/class/System.Windows.Forms/Gtk/AccessibleSelection.cs
new file mode 100644
index 00000000000..47f233eb2e0
--- /dev/null
+++ b/mcs/class/System.Windows.Forms/Gtk/AccessibleSelection.cs
@@ -0,0 +1,29 @@
+//
+// System.Windows.Forms.AccessibleSelection.cs
+//
+// Author:
+// Jaak Simm (jaaksimm@firm.ee)
+// Dennis Hayes (dennish@raytek.com)
+// (C) 2002 Ximian, Inc. http://www.ximian.com
+//
+
+using System;
+
+namespace System.Windows.Forms {
+
+
+ /// <summary>
+ /// Specifies how an accessible object is selected or receives focus.
+ /// This enumeration has a FlagsAttribute attribute that allows a bitwise combination of its member values.
+ /// </summary>
+ [Flags]
+ public enum AccessibleSelection {
+
+ AddSelection = 1,
+ ExtendSelection = 2,
+ None = 0,
+ RemoveSelection = 4,
+ TakeFocus = 8,
+ TakeSelection = 16
+ }
+}
diff --git a/mcs/class/System.Windows.Forms/Gtk/AccessibleStates.cs b/mcs/class/System.Windows.Forms/Gtk/AccessibleStates.cs
new file mode 100644
index 00000000000..a0efcaa50d0
--- /dev/null
+++ b/mcs/class/System.Windows.Forms/Gtk/AccessibleStates.cs
@@ -0,0 +1,59 @@
+//
+// System.Windows.Forms.AccessibleStates.cs
+//
+// Author:
+// Dennis Hayes (dennish@raytek.com)
+// (C) 2002/3 Ximian, Inc. http://www.ximian.com
+//
+
+using System;
+
+namespace System.Windows.Forms {
+
+ /// <summary>
+ /// </summary>
+ public enum AccessibleStates{
+ AlertLow = 67108864,
+ AlertMedium = 134217728,
+ AlertHigh = 268435456,
+ Animated = 16384,
+ Busy = 2048,
+ Checked = 16,
+ Collapsed = 1024,
+ Default = 256,
+ Expanded = 512,
+ ExtSelectable = 33554432,
+ Floating = 4096,
+ Focusable = 1048576,
+ Focused = 4,
+ HotTracked = 128,
+ Mixed = 32,
+ Indeterminate =32,
+ Invisible = 32768,
+ Linked = 4194304,
+ Marqueed = 8192,
+ Moveable = 262144,
+ MultiSelectable = 16777216,
+ None = 0,
+ Pressed = 8,
+ Protected = 536870912,
+ ReadOnly = 64,
+ Offscreen = 65536,
+ Selectable = 2097152,
+ Selected = 2,
+ SelfVoicing = 524288,
+ Sizeable = 131072,
+ Traversed =8388608,
+ Unavailable = 1,
+ Valid = 1073741823,
+
+
+ //Where did these come from, are they missing from elsewhere?
+ //AddSelection = ,
+ //ExtendSelection = ,
+ //None = ,
+ //RemoveSelection = ,
+ //TakeFocus = ,
+ //TakeSelection =
+ }
+}
diff --git a/mcs/class/System.Windows.Forms/Gtk/BaseCollection.cs b/mcs/class/System.Windows.Forms/Gtk/BaseCollection.cs
new file mode 100644
index 00000000000..666bdba213d
--- /dev/null
+++ b/mcs/class/System.Windows.Forms/Gtk/BaseCollection.cs
@@ -0,0 +1,73 @@
+//
+// System.Windows.Forms.BaseCollection
+//
+// Author:
+// stubbed out by Jaak Simm (jaaksimm@firm.ee)
+// Dennis hayes (dennish@raytek.com)
+//
+// (C) Ximian, Inc., 2002
+//
+
+using System;
+using System.Collections;
+
+namespace System.Windows.Forms {
+
+ /// <summary>
+ /// Provides the base functionality for creating data-related collections in the System.Windows.Forms namespace.
+ /// ToDo note:
+ /// - Synchronization is not implemented
+ /// - MarshalByRefObject members not stubbed out
+ /// </summary>
+
+ public class BaseCollection : MarshalByRefObject, ICollection, IEnumerable {
+
+ ArrayList list;
+
+ // --- Constructor ---
+ public BaseCollection()
+ {
+ this.list = null;
+ }
+
+ // --- public and protected Properties ---
+// public virtual int ICollection.Count {
+ public virtual int Count {
+ get {
+ return list.Count;
+ }
+ }
+
+ public bool IsReadOnly {
+ //always false as per spec.
+ get { return false; }
+ }
+
+ public bool IsSynchronized {
+ //always false as per spec.
+ get { return false; }
+ }
+
+ protected virtual ArrayList List {
+ get {
+ return list;
+ }
+ }
+
+ public object SyncRoot {
+ get { return this; }
+ }
+
+ // --- public Methods ---
+ public void CopyTo (Array ar, int index)
+ {
+ list.CopyTo(ar, index);
+ }
+
+ public IEnumerator GetEnumerator()
+ {
+ return list.GetEnumerator();
+ }
+
+ }
+}
diff --git a/mcs/class/System.Windows.Forms/Gtk/Binding.cs b/mcs/class/System.Windows.Forms/Gtk/Binding.cs
new file mode 100644
index 00000000000..cfc17a32870
--- /dev/null
+++ b/mcs/class/System.Windows.Forms/Gtk/Binding.cs
@@ -0,0 +1,104 @@
+//
+// System.Windows.Forms.Binding.cs
+//
+// Author:
+// stubbed out by Jaak Simm (jaaksimm@firm.ee)
+// Dennis hayes (dennish@raytek.com)
+//
+// (C) 2002/3 Ximian, Inc
+//
+
+namespace System.Windows.Forms {
+ public class Binding {
+
+ /// <summary>
+ /// Represents the simple binding between the property value of an object and the property value of a control.
+ ///
+ /// ToDo note:
+ /// - MarshalByRefObject members not stubbed out
+ /// </summary>
+
+ // --- Constructor
+ //
+ //Needed for CE
+ public Binding(string propertyName,object dataSource,string dataMember)
+ {
+
+ }
+
+ //
+ // --- Public Properties
+ //
+
+ //Most functions needed for compact frame work
+
+ //Needed for CE
+ [MonoTODO]
+ public BindingManagerBase BindingManagerBase {
+
+ get { throw new NotImplementedException (); }
+ }
+ //Needed for CE
+ [MonoTODO]
+ public BindingMemberInfo BindingMemberInfo {
+
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public Control Control {
+
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public object DataSource {
+
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public bool IsBinding {
+
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public string PropertyName {
+
+ get { throw new NotImplementedException (); }
+ }
+
+ //
+ // --- Public Methods
+ //
+ [MonoTODO]
+ protected virtual void OnFormat(ConvertEventArgs cevent)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ protected virtual void OnParse(ConvertEventArgs cevent)
+ {
+ throw new NotImplementedException ();
+ }
+
+ //
+ // --- Public Events
+ //
+ [MonoTODO]
+ public event ConvertEventHandler Format {
+
+ add { throw new NotImplementedException (); }
+ remove { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public event ConvertEventHandler Parse {
+
+ add { throw new NotImplementedException (); }
+ remove { throw new NotImplementedException (); }
+ }
+ }
+}
diff --git a/mcs/class/System.Windows.Forms/Gtk/BindingManagerBase.cs b/mcs/class/System.Windows.Forms/Gtk/BindingManagerBase.cs
new file mode 100644
index 00000000000..bb7e7254d95
--- /dev/null
+++ b/mcs/class/System.Windows.Forms/Gtk/BindingManagerBase.cs
@@ -0,0 +1,112 @@
+//
+// System.Windows.Forms.BindingManagerBase.cs
+//
+// Author:
+// stubbed out by Jaak Simm (jaaksimm@firm.ee)
+// Dennis hayes (dennish@raytek.com)
+// (C) 2002 Ximian, Inc
+//
+
+using System.ComponentModel;
+using System.Collections;
+
+namespace System.Windows.Forms {
+ //Compact Framework. Everything execpt suspend and resume binding needed for CE.
+ [MonoTODO]
+ public abstract class BindingManagerBase {
+
+
+ /// <summary>
+ /// Manages all Binding objects that are bound to the same data source and data member. This class is abstract.
+ /// </summary>
+
+ // --- Constructor
+ [MonoTODO]
+ public BindingManagerBase ()
+ {
+ }
+
+ //
+ // --- Fields
+ protected EventHandler onCurrentChangedHandler;
+ protected EventHandler onPositionChangedHandler;
+
+
+ //
+ // --- Public Properties
+ [MonoTODO]
+ public BindingsCollection Bindings {
+
+ get { throw new NotImplementedException (); }
+ }
+
+ public abstract int Count {
+
+ get;
+ }
+
+ public abstract object Current {
+
+ get;
+ }
+
+ public abstract int Position {
+
+ get;
+ set;
+ }
+
+ //
+ // --- Methods
+ public abstract void AddNew();
+
+ public abstract void CancelCurrentEdit();
+
+ public abstract void EndCurrentEdit();
+
+ public abstract PropertyDescriptorCollection GetItemProperties ();
+
+ [MonoTODO]
+ protected internal virtual PropertyDescriptorCollection GetItemProperties (ArrayList dataSources,ArrayList listAccessors)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ protected virtual PropertyDescriptorCollection GetItemProperties (Type listType,int offset,ArrayList dataSources,ArrayList listAccessors)
+ {
+ throw new NotImplementedException ();
+ }
+
+ //protected abstract string GetListName(ArrayList listAccessors);
+ protected internal abstract string GetListName(ArrayList listAccessors);
+
+ protected internal abstract void OnCurrentChanged(EventArgs e);
+
+ [MonoTODO]
+ protected void PullData()
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ protected void PushData()
+ {
+ throw new NotImplementedException ();
+ }
+
+ public abstract void RemoveAt(int index);
+
+ public abstract void ResumeBinding();
+ public abstract void SuspendBinding();
+
+ protected abstract void UpdateIsBinding();
+
+
+ //
+ // --- Public Events
+
+ public event EventHandler CurrentChanged;
+ public event EventHandler PositionChanged;
+ }
+}
diff --git a/mcs/class/System.Windows.Forms/Gtk/BindingMemberInfo.cs b/mcs/class/System.Windows.Forms/Gtk/BindingMemberInfo.cs
new file mode 100644
index 00000000000..ea00aadc82d
--- /dev/null
+++ b/mcs/class/System.Windows.Forms/Gtk/BindingMemberInfo.cs
@@ -0,0 +1,138 @@
+//
+// System.Drawing.BindingMemberInfo.cs
+//
+// Author:
+// Dennis Hayes (dennish@raytek.com)
+//
+// (C) 2002/3 Ximian, Inc. http://www.ximian.com
+//
+//TODO:
+// 1) Add real values in constructor.
+// 2) Verify nocheck needed in GetHashCode.
+// 3) Verify GetHashCode returns decent and valid hash.
+
+
+using System;
+using System.Windows.Forms;
+namespace System.Windows.Forms {
+
+ public struct BindingMemberInfo {
+
+ private string bindingfield;
+ private string bindingpath;
+ private string bindingmember;
+
+ // -----------------------
+ // Public Constructor
+ // -----------------------
+
+ /// <summary>
+ ///
+ /// </summary>
+ ///
+ /// <remarks>
+ ///
+ /// </remarks>
+
+ public BindingMemberInfo (string dataMember)
+ {
+ //TODO: Initilize with real values.
+ bindingmember = ("");
+ bindingfield = ("");
+ bindingpath = ("");
+ }
+
+ // -----------------------
+ // Public Shared Members
+ // -----------------------
+
+ /// <summary>
+ /// Equality Operator
+ /// </summary>
+ ///
+ /// <remarks>
+ /// Compares two BindingMemberInfo objects. The return value is
+ /// based on the equivalence of the BindingMember, BindingPath,
+ /// and BindingMember properties of the two objects.
+ /// </remarks>
+
+ public static bool operator == (BindingMemberInfo bmi_a,
+ BindingMemberInfo bmi_b) {
+
+ return ((bmi_a.bindingfield == bmi_b.bindingfield) &&
+ (bmi_a.bindingpath == bmi_b.bindingpath)&&
+ (bmi_a.bindingmember == bmi_b.bindingmember));
+ }
+
+ /// <summary>
+ /// Inequality Operator
+ /// </summary>
+ ///
+ /// <remarks>
+ /// Compares two BindingMemberInfo objects. The return value is
+ /// based on the equivalence of the BindingMember, BindingPath,
+ /// and BindingMember properties of the two objects.
+ /// </remarks>
+ public static bool operator != (BindingMemberInfo bmi_a,
+ BindingMemberInfo bmi_b) {
+ return ((bmi_a.bindingfield != bmi_b.bindingfield) ||
+ (bmi_a.bindingpath != bmi_b.bindingpath)||
+ (bmi_a.bindingmember != bmi_b.bindingmember));
+ }
+
+ // -----------------------
+ // Public Instance Members
+ // -----------------------
+
+
+ public string BindingField {
+ get{
+ return bindingfield;
+ }
+ }
+
+ public string BindingPath {
+ get{
+ return bindingpath;
+ }
+ }
+
+ public string BindingMember {
+ get{
+ return bindingmember;
+ }
+ }
+ /// <summary>
+ /// Equals Method
+ /// </summary>
+ ///
+ /// <remarks>
+ /// Checks equivalence of this BindingMemberInfo and another object.
+ /// </remarks>
+
+ public override bool Equals (object otherObject)
+ {
+ if (!(otherObject is BindingMemberInfo))
+ return false;
+
+ return (this == (BindingMemberInfo) otherObject);
+ }
+
+ /// <summary>
+ /// GetHashCode Method
+ /// </summary>
+ ///
+ /// <remarks>
+ /// Calculates a hashing value.
+ /// </remarks>
+
+ public override int GetHashCode ()
+ {
+ unchecked{
+ // MONOTODO: This should not be checked, remove unchecked, if redundant.
+ return (int)( bindingfield.GetHashCode() ^ bindingmember.GetHashCode() ^ bindingpath.GetHashCode());
+ }
+ }
+
+ }
+}
diff --git a/mcs/class/System.Windows.Forms/Gtk/BindingsCollection.cs b/mcs/class/System.Windows.Forms/Gtk/BindingsCollection.cs
new file mode 100644
index 00000000000..16cf98b6ac2
--- /dev/null
+++ b/mcs/class/System.Windows.Forms/Gtk/BindingsCollection.cs
@@ -0,0 +1,120 @@
+//
+// System.Windows.Forms.BindingsCollection.cs
+//
+// Author:
+// stubbed out by Jaak Simm (jaaksimm@firm.ee)
+// Dennis Hayes (dennish@Raytek.com)
+//
+// (C) 2002/3 Ximian, Inc
+//
+
+using System.Collections;
+using System.ComponentModel;
+
+namespace System.Windows.Forms {
+
+ /// <summary>
+ /// Represents a collection of Binding objects for a control.
+ ///
+ /// </summary>
+
+ public class BindingsCollection : BaseCollection {
+
+ #region Constructors
+ protected internal BindingsCollection ()
+ {
+ }
+ #endregion
+
+ // --- public and protected Properties ---
+ public override int Count {
+ get {
+ return base.Count;
+ }
+ }
+
+ public Binding this[int index] {
+ get {
+ return (Binding)(base.List[index]);
+ }
+ }
+
+ [MonoTODO]
+ protected override ArrayList List {
+ get {
+ return base.List;
+ }
+ }
+
+ // --- public Methods ---
+ // following internal methods are (will) not be stubbed out:
+ [MonoTODO]
+ protected virtual void AddCore(Binding dataBinding) {
+ }
+
+ [MonoTODO]
+ protected virtual void ClearCore(){
+ }
+
+ [MonoTODO]
+ protected virtual void RemoveCore(Binding dataBinding){
+ }
+
+ //
+ // CollectionChanged event:
+ // Though it was not documented, here methods Add and Remove
+ // cause the CollectionChanged event to occur, similarily as Clear.
+ // Would be nice if someone checked the exact event behavior of .NET implementation.
+
+ protected internal void Add(Binding binding)
+ {
+ base.List.Add(binding);
+ OnCollectionChanged(new CollectionChangeEventArgs(
+ CollectionChangeAction.Add,
+ base.List
+ ));
+ }
+
+ protected internal void Clear()
+ {
+ base.List.Clear();
+ OnCollectionChanged(new CollectionChangeEventArgs(
+ CollectionChangeAction.Refresh,
+ base.List
+ ));
+ }
+
+ protected virtual void OnCollectionChanged(CollectionChangeEventArgs ccevent)
+ {
+ if (CollectionChanged != null)
+ CollectionChanged(this, ccevent);
+ }
+
+ protected internal void Remove(Binding binding)
+ {
+ base.List.Remove(binding);
+ OnCollectionChanged(new CollectionChangeEventArgs(
+ CollectionChangeAction.Remove,
+ base.List
+ ));
+ }
+
+ protected internal void RemoveAt(int index)
+ {
+ base.List.RemoveAt(index);
+ OnCollectionChanged(new CollectionChangeEventArgs(
+ CollectionChangeAction.Remove,
+ base.List
+ ));
+ }
+
+ protected internal bool ShouldSerializeMyAll()
+ {
+ if (this.Count>0) return true;
+ else return false;
+ }
+
+ // public events
+ public event CollectionChangeEventHandler CollectionChanged;
+ }
+}
diff --git a/mcs/class/System.Windows.Forms/Gtk/BorderStyle.cs b/mcs/class/System.Windows.Forms/Gtk/BorderStyle.cs
new file mode 100644
index 00000000000..fcd173d53eb
--- /dev/null
+++ b/mcs/class/System.Windows.Forms/Gtk/BorderStyle.cs
@@ -0,0 +1,20 @@
+//
+// System.Windows.Forms.BorderStyle.cs
+//
+// Author:
+// Dennis Hayes (dennish@raytek.com)
+// (C) 2002 Ximian, Inc. http://www.ximian.com
+//
+
+using System;
+
+namespace System.Windows.Forms {
+
+ /// <summary>
+ /// </summary>
+ public enum BorderStyle {
+ Fixed3D = 2,
+ FixedSingle = 1,
+ None = 0
+ }
+}
diff --git a/mcs/class/System.Windows.Forms/Gtk/ChangeLog b/mcs/class/System.Windows.Forms/Gtk/ChangeLog
index c60eb06c8d2..a858586c6f3 100644
--- a/mcs/class/System.Windows.Forms/Gtk/ChangeLog
+++ b/mcs/class/System.Windows.Forms/Gtk/ChangeLog
@@ -1,3 +1,47 @@
+Tue Nov 18 23:00:00 GMT+2 2003 Joel Basson <jstrike@mweb.co.za>
+
+ * New start to DataGrid. Imported files from swf-winelib
+ * CurrencyManager.cs
+ * BindingManagerBase.cs
+ * BindingsCollection.cs
+ * BaseCollection.cs
+ * Binding.cs
+ * ItemChangedEventArgs.cs
+ * ItemChangedEventHandler.cs
+ * ConvertEventArgs.cs
+ * ConvertEventHandler.cs
+ * BindingMemberInfo.cs
+ * BorderStyle.cs
+ * KeyEventArgs.cs
+ * KeyEventHandler.cs
+ * KeyPressEventArgs.cs
+ * KeyPressEventHandler.cs
+ * Keys.cs
+ * AccessibleObject.cs
+ * AccessibleEvents.cs
+ * AccessibleNavigation.cs
+ * AccessibleRole.cs
+ * AccessibleSelection.cs
+ * AccessibleStates.cs
+ * NavigateEventArgs.cs
+ * NavigateEventHandler.cs
+ * PaintEventArgs.cs
+ * PaintEventHandler.cs
+ * GridTableStylesCollection.cs
+ * GridColumnStylesCollection.cs
+ * DataGrid.cs
+ * IDataGridColumnStyleEditingNotificationService.cs
+ * IDataGridEditingService.cs
+ * DataGridColumnStyle.cs
+ * DataGridBoolColumn.cs
+ * DataGridCell.cs
+ * DataGridLineStyle.cs
+ * DataGridParentRowsLabelStyle.cs
+ * DataGridPreferredColumnWidthTypeConverter.cs
+ * DataGridTableStyle.cs
+ * DataGridTextBoxColumn.cs
+ * DataGridTextBox.cs
+
Fri Oct 24 20:50:00 GMT+2 2003 Joel Basson <jstrike@mweb.co.za>
* Added start of DataGrid
diff --git a/mcs/class/System.Windows.Forms/Gtk/Control.cs b/mcs/class/System.Windows.Forms/Gtk/Control.cs
index ab0ee7727b9..aad48837644 100644
--- a/mcs/class/System.Windows.Forms/Gtk/Control.cs
+++ b/mcs/class/System.Windows.Forms/Gtk/Control.cs
@@ -434,6 +434,14 @@ namespace System.Windows.Forms {
this.widget.ModifyFg (Gtk.StateType.Normal, new Gdk.Color (value));
}
}
+
+ public event EventHandler ForeColorChanged;
+
+ protected virtual void OnForeColorChanged (EventArgs e) {
+
+ if (ForeColorChanged != null)
+ ForeColorChanged (this, e);
+ }
[MonoTODO]
public virtual System.Drawing.Image BackgroundImage {
@@ -455,6 +463,83 @@ namespace System.Windows.Forms {
}
}
+ public event EventHandler BackColorChanged;
+
+ protected virtual void OnBackColorChanged (EventArgs e) {
+
+ if (BackColorChanged != null)
+ BackColorChanged (this, e);
+ }
+
+ public event EventHandler MouseLeave;
+
+ [MonoTODO]
+ protected virtual void OnMouseLeave(EventArgs e)
+ {
+ }
+
+ [MonoTODO]
+ protected virtual void OnMouseMove(MouseEventArgs e)
+ {
+ }
+
+ [MonoTODO]
+ protected virtual AccessibleObject CreateAccessibilityInstance()
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ protected virtual void OnEnter(EventArgs e)
+ {
+ }
+
+ [MonoTODO]
+ protected virtual void OnKeyDown(KeyEventArgs e)
+ {
+ }
+
+ [MonoTODO]
+ protected virtual void OnKeyPress(KeyPressEventArgs kpe)
+ {
+ }
+
+ [MonoTODO]
+ protected virtual void OnLeave(EventArgs e)
+ {
+ }
+
+ [MonoTODO]
+ protected virtual void OnMouseWheel(MouseEventArgs e)
+ {
+ }
+
+ [MonoTODO]
+ protected virtual void OnPaint(PaintEventArgs pe)
+ {
+ }
+
+ [MonoTODO]
+ protected virtual void OnPaintBackground(PaintEventArgs ebe)
+ {
+ }
+
+ [MonoTODO]
+ protected virtual bool ProcessDialogKey(Keys keyData)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public virtual void ResetBackColor()
+ {
+ }
+
+ [MonoTODO]
+ public virtual void ResetForeColor()
+ {
+ }
+
public bool TabStop {
get {
return tabStop;
@@ -484,6 +569,11 @@ namespace System.Windows.Forms {
protected virtual void OnMouseDown(MouseEventArgs e)
{
}
+
+ [MonoTODO]
+ protected virtual void OnMouseUp(MouseEventArgs e)
+ {
+ }
[MonoTODO]
protected virtual void OnResize(EventArgs e)
@@ -501,6 +591,14 @@ namespace System.Windows.Forms {
get { throw new NotImplementedException(); }
set { throw new NotImplementedException(); }
}
+
+ public event EventHandler FontChanged;
+
+ protected virtual void OnFontChanged (EventArgs e) {
+
+ if (FontChanged != null)
+ FontChanged (this, e);
+ }
protected virtual Size DefaultSize {
get { return new Size ( 100, 100 ); }
diff --git a/mcs/class/System.Windows.Forms/Gtk/ConvertEventArgs.cs b/mcs/class/System.Windows.Forms/Gtk/ConvertEventArgs.cs
new file mode 100644
index 00000000000..39ca63f8e31
--- /dev/null
+++ b/mcs/class/System.Windows.Forms/Gtk/ConvertEventArgs.cs
@@ -0,0 +1,53 @@
+//
+// System.Windows.Forms.ConvertEventArgs.cs
+//
+// Author:
+// Stubbed out by Jaak Simm (jaaksimm@firm.ee)
+// Finished by Dennis Hayes (dennish@raytek.com)
+// Gianandrea Terzi (gianandrea.terzi@lario.com)
+//
+// (C) Ximian, Inc., 2002
+//
+
+namespace System.Windows.Forms {
+
+ /// <summary>
+ /// Provides data for the Format and Parse events.
+ /// </summary>
+
+ public class ConvertEventArgs : EventArgs {
+
+ #region Fields
+
+ private Type desiredtype;
+ private object objectvalue;
+
+ #endregion
+
+ //Constructor
+ public ConvertEventArgs(object objectValue,Type desiredType)
+ {
+ this.desiredtype = desiredType;
+ this.objectvalue = objectValue;
+ }
+
+ #region Public Properties
+
+ public Type DesiredType
+ {
+ get {
+ return desiredtype;
+ }
+ }
+
+ public object Value {
+ get {
+ return objectvalue;
+ }
+ set {
+ objectvalue = value;
+ }
+ }
+ #endregion
+ }
+}
diff --git a/mcs/class/System.Windows.Forms/Gtk/ConvertEventHandler.cs b/mcs/class/System.Windows.Forms/Gtk/ConvertEventHandler.cs
new file mode 100644
index 00000000000..e135d03e295
--- /dev/null
+++ b/mcs/class/System.Windows.Forms/Gtk/ConvertEventHandler.cs
@@ -0,0 +1,16 @@
+//
+// System.Windows.Forms.ConvertEventHandler.cs
+//
+// Author:
+// Dennis hayes (dennish@raytek.com)
+//
+// (C) 2002 Ximian, Inc. http://www.ximian.com
+//
+
+namespace System.Windows.Forms {
+ [Serializable]
+ public delegate void ConvertEventHandler (
+ object sender,
+ ConvertEventArgs e
+ );
+}
diff --git a/mcs/class/System.Windows.Forms/Gtk/CurrencyManager.cs b/mcs/class/System.Windows.Forms/Gtk/CurrencyManager.cs
new file mode 100644
index 00000000000..f28039e0263
--- /dev/null
+++ b/mcs/class/System.Windows.Forms/Gtk/CurrencyManager.cs
@@ -0,0 +1,175 @@
+//
+// System.Windows.Forms.CurrencyManager.cs
+//
+// Author:
+// stubbed out by Jaak Simm (jaaksimm@firm.ee)
+// Dennis Hayes (dennish@Raytek.com)
+//
+// (C) 2002 Ximian, Inc
+//
+
+using System.ComponentModel;
+using System.Collections;
+
+namespace System.Windows.Forms {
+
+ /// <summary>
+ /// Manages a list of Binding objects.
+ /// </summary>
+ [MonoTODO]
+ public class CurrencyManager : BindingManagerBase {
+
+ #region Fields
+ /* uncomment if needed
+ protected Type finalType;
+ protected int listposition;
+ */
+ internal int count = 0;
+ internal object current = null;
+ internal int position = 0;
+ #endregion
+
+ #region Properties
+ [MonoTODO]
+ public override int Count {
+ get {
+ return count;
+ }
+ }
+
+ [MonoTODO]
+ public override object Current {
+ get {
+ //FIXME:
+ return current;
+ }
+ }
+
+ [MonoTODO]
+ public IList List {
+ get {
+ throw new NotImplementedException ();
+ }
+ }
+
+ [MonoTODO]
+ public override int Position {
+
+ get {
+ //FIXME:
+ return position;
+ }
+ set {
+ //FIXME:
+ position = value;
+ }
+ }
+ #endregion
+
+ #region Methods
+ [MonoTODO]
+ public override void AddNew()
+ {
+ //FIXME:
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public override void CancelCurrentEdit()
+ {
+ //FIXME:
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ protected void CheckEmpty()
+ {
+ //FIXME:
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public override void EndCurrentEdit()
+ {
+ //FIXME:
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public override PropertyDescriptorCollection GetItemProperties()
+ {
+ //FIXME:
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ protected internal override string GetListName(ArrayList listAccessors)
+ {
+ //FIXME:
+ throw new NotImplementedException ();
+ }
+
+ /// <methods for events>
+ [MonoTODO]
+ protected internal override void OnCurrentChanged(EventArgs e)
+ {
+ //FIXME:
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ protected virtual void OnItemChanged(ItemChangedEventArgs e)
+ {
+ throw new NotImplementedException ();
+ }
+
+ /* this method only supports .NET framework
+ [MonoTODO]
+ protected virtual void OnPositionChanged(EventArgs e)
+ {
+ throw new NotImplementedException ();
+ }*/
+ /// </methods for events>
+
+ [MonoTODO]
+ public void Refresh()
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public override void RemoveAt(int index)
+ {
+ //FIXME:
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public override void ResumeBinding()
+ {
+ //FIXME:
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public override void SuspendBinding()
+ {
+ //FIXME:
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ protected override void UpdateIsBinding()
+ {
+ //FIXME:
+ throw new NotImplementedException ();
+ }
+ #endregion
+
+ #region Events
+ [MonoTODO]
+ public event ItemChangedEventHandler ItemChanged;
+ public event EventHandler MetaDataChanged; // .NET V1.1 Beta
+ #endregion
+ }
+}
diff --git a/mcs/class/System.Windows.Forms/Gtk/DataGrid.cs b/mcs/class/System.Windows.Forms/Gtk/DataGrid.cs
index 9c1b9f7e70e..49c255f19e0 100644
--- a/mcs/class/System.Windows.Forms/Gtk/DataGrid.cs
+++ b/mcs/class/System.Windows.Forms/Gtk/DataGrid.cs
@@ -1,110 +1,963 @@
//
-// System.Window.Forms.DataGrid
+// System.Windows.Forms.DataGrid
//
-//
-// Author: Kristian Rietveld <kris@gtk.org>
-// Daniel Morgan <danmorg@sc.rr.com>
-// Modified for System.Windows.Forms/GTK
-// by Joel Basson<jstrike@mweb.co.za>
-//
-// (c) 2002 Kristian Rietveld
-// (c) 2002 Daniel Morgan
+// Author:
+// stubbed out by Jaak Simm (jaaksimm@firm.ee)
+// Dennis Hayes (dennish@Raytek.com)
+// Modified for System.Window.Forms/Gtk by :
+// Joel Basson
+// (C) Ximian, Inc., 2002/3
//
using System;
-using System.Collections;
-using System.ComponentModel;
using System.Drawing;
+using System.ComponentModel;
+using System.Collections;
using System.Reflection;
using System.Text;
-
+using System.Runtime.InteropServices;
using GLib;
using Gtk;
using GtkSharp;
-using System.Runtime.InteropServices;
-
-namespace System.Windows.Forms
-{
+namespace System.Windows.Forms {
- public class DataGridColumn
- {
- private string columnName = "";
- private TreeViewColumn treeViewColumn = null;
+ /// <summary>
+ /// Displays ADO.NET data in a scrollable grid.
+ ///
+ /// </summary>
- public string ColumnName {
- get {
- return columnName;
- }
- set {
- columnName = value;
- }
+ [MonoTODO]
+ public class DataGrid : Control, ISupportInitialize {
+
+ TreeView treeView = null;
+ DataGridColumn[] gridColumns = null;
+ ListStore store = null;
+
+ #region Fields
+ bool allowNavigation;
+ bool allowSorting;
+ Color alternatingBackColor;
+ Color backgroundColor;
+ BorderStyle borderStyle;
+ Color captionBackColor;
+ Font captionFont;
+ Color captionForeColor;
+ string captionText;
+ bool captionVisible;
+ bool columnHeadersVisible;
+ string dataMember;
+ bool flatMode;
+ Color gridLineColor;
+ DataGridLineStyle gridLineStyle;
+ Color headerBackColor;
+ Color headerForeColor;
+ Color linkColor;
+ Color linkHoverColor;
+ Color parentRowsBackColor;
+ Color parentRowsForeColor;
+ DataGridParentRowsLabelStyle parentRowsLabelStyle;
+ bool parentRowsVisible;
+ bool readOnly;
+ int rowHeaderWidth;
+ Color selectionBackColor;
+ Color selectionForeColor;
+ #endregion
+
+ #region Constructors
+ [MonoTODO]
+ public DataGrid()
+ {
+ // setting default values:
+ allowNavigation=true;
+ borderStyle = BorderStyle.FixedSingle;
+ captionBackColor = SystemColors.ActiveCaption;
+ captionForeColor = SystemColors.ActiveCaptionText;
+ captionText = "";
+ captionVisible = true;
+ columnHeadersVisible = true;
+ dataMember = "";
+ flatMode = true;
+ gridLineColor = SystemColors.Control;
+ gridLineStyle = DataGridLineStyle.Solid;
+ headerBackColor = SystemColors.Control;
+ headerForeColor = SystemColors.ControlText;
+ linkColor = SystemColors.HotTrack;
+ linkHoverColor = SystemColors.HotTrack;
+ parentRowsBackColor = SystemColors.Control;
+ parentRowsForeColor = SystemColors.WindowText;
+ parentRowsLabelStyle = DataGridParentRowsLabelStyle.Both;
+ parentRowsVisible = true;
+ readOnly = false;
+ rowHeaderWidth = 50;
+ selectionBackColor = SystemColors.ActiveCaption;
+ selectionForeColor = SystemColors.ActiveCaptionText;
}
+
+ internal class DataGridColumn
+ {
+ internal string columnName = "";
+ internal TreeViewColumn treeViewColumn = null;
- public TreeViewColumn TreeViewColumn {
- get {
- return treeViewColumn;
+ internal string ColumnName {
+ get {
+ return columnName;
+ }
+ set {
+ columnName = value;
+ }
}
- set {
- treeViewColumn = value;
+
+ internal TreeViewColumn TreeViewColumn {
+ get {
+ return treeViewColumn;
+ }
+ set {
+ treeViewColumn = value;
+ }
}
}
- }
-
- public class DataGrid : VBox, Control
- {
- private ListStore store = null;
- private TreeView treeView = null;
-
- public DataGridColumn[] gridColumns = null;
-
- public DataGrid () : base(false, 4)
- {
+
+ internal override Gtk.Widget CreateWidget () {
+
+ //VBox vb = new VBox(false, 4);
+
ScrolledWindow sw = new ScrolledWindow ();
- this.PackStart (sw, true, true, 0);
+ //vb.PackStart (sw, true, true, 0);
treeView = new TreeView (store);
- treeView.HeadersVisible = true;
-
+ treeView.HeadersVisible = CaptionVisible;
+ treeView.Show();
sw.Add (treeView);
+ sw.Show();
+ //vb.Show();
+ return sw;
+ }
+ #endregion
+
+ protected override void Dispose(bool disposing){
}
- // FIXME: need to place in a base class
- // the DataSource, DataMember, DataBind()
- // public members.
- // maybe we can call the base class
- // BaseDataList for GTK#?
-
- private object dataSource = null;
-
- private string dataMember = "";
- public object DataSource {
+ #region Properties
+ public bool AllowNavigation {
get {
- return dataSource;
+ return allowNavigation;
}
set {
- dataSource = value;
+ allowNavigation=value;
}
}
-
+
+ public bool AllowSorting {
+ get {
+ return allowSorting;
+ }
+ set {
+ allowSorting=value;
+ }
+ }
+
+ public Color AlternatingBackColor {
+ get {
+ return alternatingBackColor;
+ }
+ set {
+ alternatingBackColor=value;
+ }
+ }
+
+ [MonoTODO]
+ public override Color BackColor {
+ get {
+ throw new NotImplementedException ();
+ }
+ set {
+ //FIXME:
+ }
+ }
+
+ public Color BackgroundColor {
+ get {
+ return backgroundColor;
+ }
+ set {
+ backgroundColor=value;
+ }
+ }
+
+ [MonoTODO]
+ public override System.Drawing.Image BackgroundImage {
+ get {
+ //FIXME:
+ return base.BackgroundImage;
+ }
+ set {
+ //FIXME:
+ base.BackgroundImage = value;
+ }
+ }
+
+ public BorderStyle BorderStyle {
+ get {
+ return borderStyle;
+ }
+ set {
+ borderStyle=value;
+ }
+ }
+
+ public Color CaptionBackColor {
+ get {
+ return captionBackColor;
+ }
+ set {
+ captionBackColor=value;
+ }
+ }
+
+ public Font CaptionFont {
+ get {
+ return captionFont;
+ }
+ set {
+ captionFont=value;
+ }
+ }
+
+ public Color CaptionForeColor {
+ get {
+ return captionForeColor;
+ }
+ set {
+ captionForeColor=value;
+ }
+ }
+
+ public string CaptionText {
+ get {
+ return captionText;
+ }
+ set {
+ captionText=value;
+ }
+ }
+
+ public bool CaptionVisible {
+ get {
+ return captionVisible;
+ }
+ set {
+ captionVisible=value;
+ }
+ }
+
+ public bool ColumnHeadersVisible {
+ get {
+ return columnHeadersVisible;
+ }
+ set {
+ columnHeadersVisible=value;
+ }
+ }
+
+ [MonoTODO]
+ public DataGridCell CurrentCell {
+ get {
+ throw new NotImplementedException ();
+ }
+ set {
+ //FIXME:
+ }
+ }
+
+ [MonoTODO]
+ public int CurrentRowIndex {
+ get {
+ throw new NotImplementedException ();
+ }
+ set {
+ //FIXME:
+ }
+ }
+
+ //[MonoTODO]
+ //public override Cursor Cursor {
+ // get {
+ // throw new NotImplementedException ();
+ // }
+ // set {
+ //FIXME:
+ // }
+ //}
+
public string DataMember {
+ get { return dataMember; }
+ set { dataMember=value; }
+ }
+
+ [MonoTODO]
+ public object DataSource {
get {
- return dataMember;
+ throw new NotImplementedException ();
}
set {
- dataMember = value;
+ //FIXME:
}
}
-
- public void setDataBinding (object DataSource, string DataMember)
+
+ protected override Size DefaultSize {
+ get {
+ //FIXME: verify numbers
+ return new Size(300,200);
+ }
+ }
+
+ [MonoTODO]
+ public int FirstVisibleColumn {
+ get { throw new NotImplementedException (); }
+ }
+
+ public bool FlatMode {
+ get { return flatMode; }
+ set { flatMode=value; }
+ }
+
+ [MonoTODO]
+ public override Color ForeColor {
+ get {
+ //FIXME:
+ return base.ForeColor;
+ }
+ set {
+ //FIXME:
+ base.ForeColor = value;
+ }
+ }
+
+ public Color GridLineColor {
+ get { return gridLineColor; }
+ set { gridLineColor=value; }
+ }
+
+ public DataGridLineStyle GridLineStyle {
+ get { return gridLineStyle; }
+ set { gridLineStyle=value; }
+ }
+
+ public Color HeaderBackColor {
+ get { return headerBackColor; }
+ set {
+ if (value==Color.Empty) throw new ArgumentNullException();
+ headerBackColor=value;
+ }
+ }
+
+ public Color HeaderForeColor {
+ get { return headerForeColor; }
+ set { headerForeColor=value; }
+ }
+
+ [MonoTODO]
+ protected ScrollBar HorizScrollBar {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public object this[DataGridCell cell] {
+ get { throw new NotImplementedException (); }
+ set { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public object this[int rowIndex,int columnIndex] {
+ get { throw new NotImplementedException (); }
+ set { throw new NotImplementedException (); }
+ }
+
+ public Color LinkColor {
+ get { return linkColor; }
+ set { linkColor=value; }
+ }
+
+ public Color LinkHoverColor {
+ get { return linkHoverColor; }
+ set { linkHoverColor=value; }
+ }
+
+ [MonoTODO]
+ protected internal CurrencyManager ListManager {
+ get { throw new NotImplementedException (); }
+ set { throw new NotImplementedException (); }
+ }
+
+ public Color ParentRowsBackColor {
+ get { return parentRowsBackColor; }
+ set { parentRowsBackColor=value; }
+ }
+
+ public Color ParentRowsForeColor {
+ get { return parentRowsForeColor; }
+ set { parentRowsForeColor=value; }
+ }
+
+ public DataGridParentRowsLabelStyle ParentRowsLabelStyle {
+ get { return parentRowsLabelStyle; }
+ set { parentRowsLabelStyle=value; }
+ }
+
+ public bool ParentRowsVisible {
+ get { return parentRowsVisible; }
+ set { parentRowsVisible=value; }
+ }
+
+ [MonoTODO]
+ public int PreferredColumnWidth {
+ get { throw new NotImplementedException (); }
+ set { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public int PreferredRowHeight {
+ get { throw new NotImplementedException (); }
+ set { throw new NotImplementedException (); }
+ }
+
+ public bool ReadOnly {
+ get { return readOnly; }
+ set { readOnly=value; }
+ }
+
+ [MonoTODO]
+ public bool RowHeadersVisible {
+ get { throw new NotImplementedException (); }
+ set { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public int RowHeaderWidth {
+ get { return rowHeaderWidth; }
+ set { rowHeaderWidth=value; }
+ }
+
+ public Color SelectionBackColor {
+ get { return selectionBackColor; }
+ set { selectionBackColor=value; }
+ }
+
+ public Color SelectionForeColor {
+ get { return selectionForeColor; }
+ set { selectionForeColor=value; }
+ }
+
+ [MonoTODO]
+ public override ISite Site {
+ get { throw new NotImplementedException (); }
+ set { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public GridTableStylesCollection TableStyles {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public override string Text {
+ get {
+ //FIXME:
+ return base.Text;
+ }
+ set {
+ //FIXME:
+ base.Text = value;
+ }
+ }
+
+ [MonoTODO]
+ protected ScrollBar VertScrollBar {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public int VisibleColumnCount {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public int VisibleRowCount {
+ get { throw new NotImplementedException (); }
+ }
+ #endregion
+
+ #region Methods
+ /* Following members support the .NET Framework infrastructure and are not intended to be used directly from your code.
+ * Methods not stubbed out:
+ - protected virtual string GetOutputTextDelimiter()
+ - public void ResetLinkHoverColor()
+ - public void SubObjectsSiteChange(bool site)
+ */
+ [MonoTODO]
+ public virtual bool BeginEdit(DataGridColumnStyle gridColumn,int rowNumber)
{
- Clear ();
-
- dataMember = DataMember;
- dataSource = DataSource;
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void BeginInit()
+ {
+ //FIXME:
+ }
+
+ [MonoTODO]
+ protected virtual void CancelEditing()
+ {
+ //FIXME:
+ }
+
+ [MonoTODO]
+ public void Collapse(int row)
+ {
+ //FIXME:
+ }
+
+ [MonoTODO]
+ protected internal virtual void ColumnStartedEditing(Control editingControl)
+ {
+ //FIXME:
+ }
+
+ [MonoTODO]
+ protected internal virtual void ColumnStartedEditing(Rectangle bounds)
+ {
+ //FIXME:
+ }
+
+ [MonoTODO]
+ protected override AccessibleObject CreateAccessibilityInstance()
+ {
+ //FIXME:
+ return base.CreateAccessibilityInstance();
+ }
+
+ [MonoTODO]
+ protected virtual DataGridColumnStyle CreateGridColumn(PropertyDescriptor prop)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ protected virtual DataGridColumnStyle CreateGridColumn(PropertyDescriptor prop,bool isDefault)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public virtual bool EndEdit(DataGridColumnStyle gridColumn,int rowNumber,bool shouldAbort)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void EndInit()
+ {
+ //FIXME:
+ }
+
+ [MonoTODO]
+ public void Expand(int row)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public Rectangle GetCellBounds(DataGridCell dgc)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public Rectangle GetCellBounds(int row,int col)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public Rectangle GetCurrentCellBounds()
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ protected virtual void GridHScrolled(object sender,ScrollEventArgs se)
+ {
+ //FIXME:
+ }
+
+ [MonoTODO]
+ protected virtual void GridVScrolled(object sender,ScrollEventArgs se)
+ {
+ //FIXME:
+ }
+
+ [MonoTODO]
+ public HitTestInfo HitTest(Point position)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public HitTestInfo HitTest(int x,int y)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public bool IsExpanded(int rowNumber)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public bool IsSelected(int row)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void NavigateBack()
+ {
+ //FIXME:
+ }
+
+ [MonoTODO]
+ public void NavigateTo(int rowNumber,string relationName)
+ {
+ //FIXME:
+ }
+
+ [MonoTODO]
+ protected virtual void OnAllowNavigationChanged(EventArgs e)
+ {
+ //FIXME:
+ }
+
+ [MonoTODO]
+ protected void OnBackButtonClicked(object sender,EventArgs e)
+ {
+ //FIXME:
+ }
+
+ [MonoTODO]
+ protected override void OnBackColorChanged(EventArgs e)
+ {
+ //FIXME:
+ base.OnBackColorChanged(e);
+ }
+
+ [MonoTODO]
+ protected virtual void OnBackgroundColorChanged(EventArgs e)
+ {
+ //FIXME:
+ }
+
+ [MonoTODO]
+ protected override void OnBindingContextChanged(EventArgs e)
+ {
+ //FIXME:
+ base.OnBindingContextChanged(e);
+ }
+
+ [MonoTODO]
+ protected virtual void OnBorderStyleChanged(EventArgs e)
+ {
+ //FIXME:
+ }
+
+ [MonoTODO]
+ protected virtual void OnCaptionVisibleChanged(EventArgs e)
+ {
+ //FIXME:
+ }
+
+ [MonoTODO]
+ protected virtual void OnCurrentCellChanged(EventArgs e)
+ {
+ //FIXME:
+ }
+
+ [MonoTODO]
+ protected virtual void OnDataSourceChanged(EventArgs e)
+ {
+ //FIXME:
+ }
+
+ [MonoTODO]
+ protected override void OnEnter(EventArgs e)
+ {
+ //FIXME:
+ base.OnEnter(e);
+ }
+
+ [MonoTODO]
+ protected virtual void OnFlatModeChanged(EventArgs e)
+ {
+ //FIXME:
+ }
+
+ [MonoTODO]
+ protected override void OnFontChanged(EventArgs e)
+ {
+ //FIXME:
+ base.OnFontChanged(e);
+ }
+
+ [MonoTODO]
+ protected override void OnForeColorChanged(EventArgs e)
+ {
+ //FIXME:
+ base.OnForeColorChanged(e);
+ }
+
+ [MonoTODO]
+ protected override void OnHandleCreated(EventArgs e)
+ {
+ //FIXME:
+ base.OnHandleCreated(e);
+ }
+
+ [MonoTODO]
+ protected override void OnHandleDestroyed(EventArgs e)
+ {
+ //FIXME:
+ base.OnHandleDestroyed(e);
+ }
+
+ [MonoTODO]
+ protected override void OnKeyDown(KeyEventArgs e)
+ {
+ //FIXME:
+ base.OnKeyDown(e);
+ }
+
+ [MonoTODO]
+ protected override void OnKeyPress(KeyPressEventArgs kpe)
+ {
+ //FIXME:
+ base.OnKeyPress(kpe);
+ }
+
+ [MonoTODO]
+ protected override void OnLayout(LayoutEventArgs levent)
+ {
+ //FIXME:
+ base.OnLayout(levent);
+ }
+
+ [MonoTODO]
+ protected override void OnLeave(EventArgs e)
+ {
+ //FIXME:
+ base.OnLeave(e);
+ }
+
+ [MonoTODO]
+ protected override void OnMouseDown(MouseEventArgs e)
+ {
+ //FIXME:
+ base.OnMouseDown(e);
+ }
+
+ [MonoTODO]
+ protected override void OnMouseLeave(EventArgs e)
+ {
+ //FIXME:
+ base.OnMouseLeave(e);
+ }
+
+ [MonoTODO]
+ protected override void OnMouseMove(MouseEventArgs e)
+ {
+ //FIXME:
+ base.OnMouseMove(e);
+ }
+
+ [MonoTODO]
+ protected override void OnMouseUp(MouseEventArgs e)
+ {
+ //FIXME:
+ base.OnMouseUp(e);
+ }
+
+ [MonoTODO]
+ protected override void OnMouseWheel(MouseEventArgs e)
+ {
+ //FIXME:
+ base.OnMouseWheel(e);
+ }
+
+ [MonoTODO]
+ protected void OnNavigate(NavigateEventArgs e)
+ {
+ //FIXME:
+ }
+
+ [MonoTODO]
+ protected override void OnPaint(PaintEventArgs pe)
+ {
+ //FIXME:
+ base.OnPaint(pe);
+ }
+
+ [MonoTODO]
+ protected override void OnPaintBackground(PaintEventArgs ebe)
+ {
+ //FIXME:
+ base.OnPaintBackground(ebe);
+ }
+
+ [MonoTODO]
+ protected virtual void OnParentRowsLabelStyleChanged(EventArgs e)
+ {
+ //FIXME:
+ }
+
+ [MonoTODO]
+ protected virtual void OnParentRowsVisibleChanged(EventArgs e)
+ {
+ //FIXME:
+ }
+
+
+ [MonoTODO]
+ protected virtual void OnReadOnlyChanged(EventArgs e)
+ {
+ //FIXME:
+ }
+ [MonoTODO]
+ protected void OnRowHeaderClick(EventArgs e)
+ {
+ //FIXME:
+ }
+
+ [MonoTODO]
+ protected void OnScroll(EventArgs e)
+ {
+ //FIXME:
+ }
+
+ [MonoTODO]
+ protected void OnShowParentDetailsButtonClicked(object sender,EventArgs e)
+ {
+ //FIXME:
+ }
+
+ [MonoTODO]
+ protected override bool ProcessDialogKey(Keys keyData)
+ {
+ //FIXME:
+ return base.ProcessDialogKey(keyData);
+ }
+
+ [MonoTODO]
+ protected bool ProcessGridKey(KeyEventArgs ke)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ //protected override bool ProcessKeyPreview(ref Message m)
+ //{
+ //FIXME:
+ //return base.ProcessKeyPreview(ref m);
+ //}
+
+ [MonoTODO]
+ protected bool ProcessTabKey(Keys keyData)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void ResetAlternatingBackColor()
+ {
+ //FIXME:
+ }
+
+ [MonoTODO]
+ public override void ResetBackColor()
+ {
+ //FIXME:
+ base.ResetBackColor();
+ }
+
+ [MonoTODO]
+ public override void ResetForeColor()
+ {
+ //FIXME:
+ base.ResetForeColor();
+ }
+
+ [MonoTODO]
+ public void ResetGridLineColor()
+ {
+ //FIXME:
+ }
+
+ [MonoTODO]
+ public void ResetHeaderBackColor()
+ {
+ //FIXME:
+ }
+
+ [MonoTODO]
+ public void ResetHeaderFont()
+ {
+ //FIXME:
+ }
+
+ [MonoTODO]
+ public void ResetHeaderForeColor()
+ {
+ //FIXME:
+ }
+
+ [MonoTODO]
+ public void ResetLinkColor()
+ {
+ //FIXME:
+ }
+
+ [MonoTODO]
+ protected void ResetSelection()
+ {
+ //FIXME:
+ }
+
+ [MonoTODO]
+ public void ResetSelectionBackColor()
+ {
+ //FIXME:
+ }
+
+ [MonoTODO]
+ public void ResetSelectionForeColor()
+ {
+ //FIXME:
+ }
+
+ [MonoTODO]
+ public void Select(int row)
+ {
+ //FIXME:
+ }
+
+ // start of Gtk# stuff
+ [MonoTODO]
+ public void SetDataBinding(object mydataSource, string mydataMember)
+ {
+ Clear();
System.Object o = null;
- o = GetResolvedDataSource (DataSource, DataMember);
+ o = GetResolvedDataSource (mydataSource, mydataMember);
IEnumerable ie = (IEnumerable) o;
ITypedList tlist = (ITypedList) o;
@@ -115,16 +968,17 @@ namespace System.Windows.Forms
// FIXME: does not belong in this base method
gridColumns = new DataGridColumn[pdc.Count];
-
+
// FIXME: does not belong in base method
// define the columns in the treeview store
// based on the schema of the result
uint[] theTypes = new uint[pdc.Count];
+
for (int col = 0; col < pdc.Count; col++) {
theTypes[col] = (int) TypeFundamentals.TypeString;
}
store.SetColumnTypes (theTypes);
-
+
// FIXME: does not belong in this base method
int colndx = -1;
foreach (PropertyDescriptor pd in pdc) {
@@ -132,7 +986,7 @@ namespace System.Windows.Forms
gridColumns[colndx] = new DataGridColumn ();
gridColumns[colndx].ColumnName = pd.Name;
}
-
+
foreach (System.Object obj in ie) {
ICustomTypeDescriptor custom = (ICustomTypeDescriptor) obj;
PropertyDescriptorCollection properties;
@@ -155,9 +1009,8 @@ namespace System.Windows.Forms
treeView.Model = store;
AutoCreateTreeViewColumns (treeView);
}
-
- // borrowed from Mono's System.Web implementation
- protected IEnumerable GetResolvedDataSource(object source, string member)
+
+ private IEnumerable GetResolvedDataSource(object source, string member)
{
if (source != null && source is IListSource) {
IListSource src = (IListSource) source;
@@ -192,60 +1045,14 @@ namespace System.Windows.Forms
}
return null;
}
-
- public void Clear ()
- {
- if (store != null) {
- store.Clear ();
- store = null;
- store = new ListStore ((int)TypeFundamentals.TypeString);
- }
- else
- store = new ListStore ((int)TypeFundamentals.TypeString);
-
- if (gridColumns != null) {
- for (int c = 0; c < gridColumns.Length; c++) {
- if (gridColumns[c] != null) {
- if (gridColumns[c].TreeViewColumn != null) {
- treeView.RemoveColumn (gridColumns[c].TreeViewColumn);
- gridColumns[c].TreeViewColumn = null;
- }
- gridColumns[c] = null;
- }
- }
- gridColumns = null;
- }
- }
-
- // for DEBUG only
- public void AppendText (string text)
- {
- Console.WriteLine ("DataGrid DEBUG: " + text);
- Console.Out.Flush ();
- }
-
- public TreeIter NewRow ()
+
+ private TreeIter NewRow ()
{
TreeIter rowTreeIter = new TreeIter();
store.Append (out rowTreeIter);
return rowTreeIter;
}
-
- public void AddRow (object[] columnValues)
- {
- TreeIter iter = NewRow ();
- for(int col = 0; col < columnValues.Length; col++) {
- string cellValue = columnValues[col].ToString ();
- SetColumnValue (iter, col, cellValue);
- }
- }
-
- public void SetColumnValue (TreeIter iter, int column, string value)
- {
- GLib.Value cell = new GLib.Value (value);
- store.SetValue (iter, column, cell);
- }
-
+
private void AutoCreateTreeViewColumns (TreeView theTreeView)
{
for(int col = 0; col < gridColumns.Length; col++) {
@@ -265,9 +1072,12 @@ namespace System.Windows.Forms
}
}
- // TODO: maybe need to create
- // a DataGridColumnCollection of DataGridColumn
- // and a DataGridColumn contain a TreeViewColumn
+ private void SetColumnValue (TreeIter iter, int column, string value)
+ {
+ GLib.Value cell = new GLib.Value (value);
+ store.SetValue (iter, column, cell);
+ }
+
public TreeViewColumn CreateColumn (TreeView theTreeView, int col,
string columnName)
{
@@ -282,5 +1092,191 @@ namespace System.Windows.Forms
return NameCol;
}
+
+ internal void Clear ()
+ {
+ if (store != null) {
+ store.Clear ();
+ store = null;
+ store = new ListStore ((int)TypeFundamentals.TypeString);
+ }
+ else
+ store = new ListStore ((int)TypeFundamentals.TypeString);
+
+ if (gridColumns != null) {
+ for (int c = 0; c < gridColumns.Length; c++) {
+ if (gridColumns[c] != null) {
+ if (gridColumns[c].TreeViewColumn != null) {
+ treeView.RemoveColumn (gridColumns[c].TreeViewColumn);
+ gridColumns[c].TreeViewColumn = null;
+ }
+ gridColumns[c] = null;
+ }
+ }
+ gridColumns = null;
+ }
+ }
+ // end of gtk# stuff
+
+ [MonoTODO]
+ protected virtual bool ShouldSerializeAlternatingBackColor()
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ protected virtual bool ShouldSerializeBackgroundColor()
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ protected virtual bool ShouldSerializeCaptionBackColor()
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ protected virtual bool ShouldSerializeCaptionForeColor()
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ protected virtual bool ShouldSerializeGridLineColor()
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ protected virtual bool ShouldSerializeHeaderBackColor()
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ protected bool ShouldSerializeHeaderFont()
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ protected virtual bool ShouldSerializeHeaderForeColor()
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ protected virtual bool ShouldSerializeLinkHoverColor()
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ protected virtual bool ShouldSerializeParentRowsBackColor()
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ protected virtual bool ShouldSerializeParentRowsForeColor()
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ protected bool ShouldSerializePreferredRowHeight()
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ protected bool ShouldSerializeSelectionBackColor()
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ protected virtual bool ShouldSerializeSelectionForeColor()
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void UnSelect(int row)
+ {
+ //FIXME:
+ }
+ #endregion
+
+ #region Events
+ public event EventHandler AllowNavigationChanged;
+ public event EventHandler BackButtonClick;
+ public event EventHandler BackgroundColorChanged;
+ public event EventHandler BorderStyleChanged;
+ public event EventHandler CaptionVisibleChanged;
+ public event EventHandler CurrentCellChanged;
+ public event EventHandler DataSourceChanged;
+ public event EventHandler FlatModeChanged;
+ public event NavigateEventHandler Navigate;
+ public event EventHandler ParentRowsLabelStyleChanged;
+ public event EventHandler ParentRowsVisibleChanged;
+ public event EventHandler ReadOnlyChanged;
+ protected event EventHandler RowHeaderClick;
+ public event EventHandler Scroll;
+ public event EventHandler ShowParentDetailsButtonClick;
+ #endregion
+
+ /// sub-class: DataGrid.HitTestInfo
+ /// <summary>
+ /// Contains information about a part of the System.Windows.Forms.DataGrid at a specified coordinate. This class cannot be inherited.
+ /// </summary>
+ [MonoTODO]
+ public sealed class HitTestInfo {
+ #region DataGrid.HitTestInfo: Fields
+ [MonoTODO]
+ public static readonly DataGrid.HitTestInfo Nowhere;
+ #endregion
+
+ #region DataGrid.HitTestInfo: Properties
+ [MonoTODO]
+ public int Column {
+ get {
+ throw new NotImplementedException ();
+ }
+ }
+
+ [MonoTODO]
+ public int Row {
+ get {
+ throw new NotImplementedException ();
+ }
+ }
+
+ [MonoTODO]
+ public HitTestType Type {
+ get {
+ throw new NotImplementedException ();
+ }
+ }
+ #endregion
+
+ /// sub-enumeration: DataGrid.HitTestType
+ /// <summary>
+ /// Specifies the part of the System.Windows.Forms.DataGrid control the user has clicked
+ /// </summary>
+ [Flags]
+ [Serializable]
+ public enum HitTestType {
+ Caption = 32,
+ Cell = 1,
+ ColumnHeader = 2,
+ ColumnResize = 8,
+ None = 0,
+ ParentRows = 64,
+ RowHeader = 4,
+ RowResize = 16
+ }
+ }
}
}
diff --git a/mcs/class/System.Windows.Forms/Gtk/DataGridBoolColumn.cs b/mcs/class/System.Windows.Forms/Gtk/DataGridBoolColumn.cs
new file mode 100644
index 00000000000..f0aa72ba6c2
--- /dev/null
+++ b/mcs/class/System.Windows.Forms/Gtk/DataGridBoolColumn.cs
@@ -0,0 +1,175 @@
+//
+// System.Windows.Forms.DataGridBoolColumn
+//
+// Author:
+// stubbed out by Jaak Simm (jaaksimm@firm.ee)
+// Dennis Hayes (dennish@Raytek.com)
+//
+// (C) Ximian, Inc., 2002
+//
+
+using System.Drawing;
+using System.ComponentModel;
+
+namespace System.Windows.Forms {
+
+ /// <summary>
+ /// Specifies a column in which each cell contains a check box for representing a Boolean value.
+ /// </summary>
+
+ [MonoTODO]
+ public class DataGridBoolColumn : DataGridColumnStyle {
+
+ #region Fields
+ bool allowNull;
+ object falseValue;
+ object nullValue;
+ object trueValue;
+ #endregion
+
+ #region Constructor
+ [MonoTODO]
+ public DataGridBoolColumn()
+ {
+
+ }
+
+ [MonoTODO]
+ public DataGridBoolColumn(PropertyDescriptor prop)
+ {
+
+ }
+
+ /*
+ * This member supports the .NET Framework infrastructure and is not intended to be used directly from your code.
+ [MonoTODO]
+ public DataGridBoolColumn(PropertyDescriptor prop,bool isDefault)
+ {
+ }
+ */
+ #endregion
+
+ #region Properties
+
+ public bool AllowNull {
+ get { return allowNull; }
+ set { allowNull=value; }
+ }
+
+ public object FalseValue {
+ get { return falseValue; }
+ set { falseValue=value; }
+ }
+
+ public object NullValue {
+ get { return nullValue; }
+ set { nullValue=value; }
+ }
+
+ public object TrueValue {
+ get { return trueValue; }
+ set { trueValue=value; }
+ }
+ #endregion
+
+ #region Methods
+ [MonoTODO]
+ protected internal override void Abort(int rowNum)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ protected internal override bool Commit(CurrencyManager dataSource,int rowNum)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ protected internal override void ConcedeFocus()
+ {
+ //FIXME:
+ base.ConcedeFocus();
+ }
+
+ [MonoTODO]
+ protected internal override void Edit(CurrencyManager source, int rowNum,
+ Rectangle bounds, bool readOnly, string instantText, bool cellIsVisible) {
+ //FIXME:
+ }
+
+ [MonoTODO]
+ protected internal override void EnterNullValue()
+ {
+ //FIXME:
+ base.EnterNullValue();
+ }
+
+ [MonoTODO]
+ protected internal override object GetColumnValueAtRow(CurrencyManager source,int rowNum)
+ {
+ //FIXME:
+ return base.GetColumnValueAtRow(source, rowNum);
+ }
+
+ [MonoTODO]
+ protected internal override int GetMinimumHeight()
+ {
+ //FIXME:made up number
+ return 20;
+ }
+
+ [MonoTODO]
+ protected internal override int GetPreferredHeight(Graphics g, object value)
+ {
+ //FIXME:made up number
+ return 300;
+ }
+
+ [MonoTODO]
+ protected internal override Size GetPreferredSize(Graphics g, object value)
+ {
+ //FIXME:made up number
+ return new Size(300,300);
+ }
+
+ [MonoTODO]
+ protected internal override void Paint(Graphics g, Rectangle bounds,
+ CurrencyManager source, int rowNum) {
+ //FIXME:made up number
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ protected internal override void Paint(Graphics g, Rectangle bounds,
+ CurrencyManager source, int rowNum, bool alignToRight) {
+
+ //return base.Paint(g, bounds, source, rowNum,
+ }
+
+ [MonoTODO]
+ protected internal override void Paint(Graphics g, Rectangle bounds, CurrencyManager source,
+ int rowNum, Brush backBrush, Brush foreBrush, bool alignToRight) {
+ //FIXME:
+ }
+
+ [MonoTODO]
+ protected internal override void SetColumnValueAtRow(CurrencyManager source,int rowNum, object value)
+ {
+ //FIXME:
+ base.SetColumnValueAtRow(source, rowNum, value);
+ }
+ #endregion
+
+ #region Events
+ [MonoTODO]
+ public event EventHandler AllowNullChanged;
+
+ [MonoTODO]
+ public event EventHandler FalseValueChanged;
+
+ [MonoTODO]
+ protected event EventHandler TrueValueChanged;
+ #endregion
+ }
+}
diff --git a/mcs/class/System.Windows.Forms/Gtk/DataGridCell.cs b/mcs/class/System.Windows.Forms/Gtk/DataGridCell.cs
new file mode 100644
index 00000000000..9fc0c2a3b23
--- /dev/null
+++ b/mcs/class/System.Windows.Forms/Gtk/DataGridCell.cs
@@ -0,0 +1,132 @@
+//
+// System.Windows.Forms.DataGridCell.cs
+//
+// Author:
+// Dennis Hayes (dennish@raytek.com)
+//
+// (C) 2002 Ximian, Inc. http://www.ximian.com
+//
+
+using System;
+
+namespace System.Windows.Forms {
+
+ public struct DataGridCell {
+
+ private int rownumber;
+ private int columnnumber;
+
+ // -----------------------
+ // Public Constructor
+ // -----------------------
+
+ /// <summary>
+ ///
+ /// </summary>
+ ///
+ /// <remarks>
+ ///
+ /// </remarks>
+
+ public DataGridCell (int r, int c)
+ {
+ rownumber = r;
+ columnnumber = c;
+ }
+
+ // -----------------------
+ // Public Shared Members
+ // -----------------------
+
+ /// <remarks>
+ /// Compares two DataGridCell objects. The return value is
+ /// based on the equivalence of the RowNumber and ColumnNumber properties of the two objects.
+ /// </remarks>
+
+ public static bool operator == (DataGridCell dgc_a,
+ DataGridCell dgc_b) {
+
+ return ((dgc_a.rownumber == dgc_b.rownumber) &&
+ (dgc_a.columnnumber == dgc_b.columnnumber));
+ }
+
+ /// <summary>
+ /// Inequality Operator
+ /// </summary>
+ ///
+ /// <remarks>
+ /// Compares two DataGridCell objects. The return value is
+ /// based on the equivalence of the RowNumber and ColumnNumber properties of the two objects.
+ /// </remarks>
+ public static bool operator != (DataGridCell dgc_a,
+ DataGridCell dgc_b) {
+ return ((dgc_a.rownumber != dgc_b.rownumber) ||
+ (dgc_a.columnnumber != dgc_b.columnnumber));
+ }
+
+ // -----------------------
+ // Public Instance Members
+ // -----------------------
+
+
+ public int RowNumber {
+ get{
+ return rownumber;
+ }
+ set{
+ rownumber = value;
+ }
+ }
+
+ public int ColumeNumber {
+ get{
+ return columnnumber;
+ }
+ set{
+ columnnumber = value;
+ }
+ }
+
+ /// <summary>
+ /// Equals Method
+ /// </summary>
+ ///
+ /// <remarks>
+ /// Checks equivalence of this DataGridCell and another object.
+ /// </remarks>
+
+ public override bool Equals (object obj)
+ {
+ if (!(obj is DataGridCell))
+ return false;
+
+ return (this == (DataGridCell) obj);
+ }
+
+ /// <summary>
+ /// GetHashCode Method
+ /// </summary>
+ ///
+ /// <remarks>
+ /// Calculates a hashing value.
+ /// </remarks>
+
+ public override int GetHashCode ()
+ {
+ return (int)( rownumber ^ columnnumber);
+ }
+
+ /// <summary>
+ /// ToString Method
+ /// </summary>
+ ///
+ /// <remarks>
+ /// Formats the DataGridCell as a string.
+ /// </remarks>
+
+ public override string ToString ()
+ {
+ return String.Format ("[{0},{1}]", rownumber, columnnumber );
+ }
+ }
+}
diff --git a/mcs/class/System.Windows.Forms/Gtk/DataGridColumnStyle.cs b/mcs/class/System.Windows.Forms/Gtk/DataGridColumnStyle.cs
new file mode 100644
index 00000000000..c2efd99c773
--- /dev/null
+++ b/mcs/class/System.Windows.Forms/Gtk/DataGridColumnStyle.cs
@@ -0,0 +1,254 @@
+//
+// System.Windows.Forms.DataGridColumnStyle
+//
+// Author:
+// stubbed out by Jaak Simm (jaaksimm@firm.ee)
+// Dennis Hayes (dennish@Raytek.com)
+//
+// (C) Ximian, Inc., 2002
+//
+
+using System.ComponentModel;
+using System.Drawing;
+using System.Collections;
+
+namespace System.Windows.Forms {
+
+ /// <summary>
+ /// Specifies the appearance and text formatting and behavior of a System.Windows.Forms.DataGrid control column. This class is abstract.
+ /// </summary>
+
+ [MonoTODO]
+ public abstract class DataGridColumnStyle : Component, IDataGridColumnStyleEditingNotificationService {
+
+ #region Fields
+ HorizontalAlignment alignment;
+ DataGridTableStyle dataGridTableStyle;
+ int fontHeight;
+ string headerText;
+ string mappingName;
+ string nullText;
+ PropertyDescriptor propertyDescriptor;
+ bool readOnly;
+ int width;
+ #endregion
+
+ #region Constructors
+ [MonoTODO]
+ public DataGridColumnStyle()
+ {
+ alignment=HorizontalAlignment.Left;
+ dataGridTableStyle=null;
+ fontHeight=-1;
+ headerText="";
+ readOnly=false;
+ }
+
+ [MonoTODO]
+ public DataGridColumnStyle(PropertyDescriptor prop) : this()
+ {
+ propertyDescriptor=prop;
+ }
+ #endregion
+
+ #region Properties
+ public virtual HorizontalAlignment Alignment {
+ get { return alignment; }
+ set { alignment=value; }
+ }
+
+ public virtual DataGridTableStyle DataGridTableStyle {
+ get { return dataGridTableStyle; }
+ }
+
+ protected int FontHeight {
+ get { return fontHeight; }
+ }
+ /*
+ * This member supports the .NET Framework infrastructure and is not intended to be used directly from your code.
+ public AccessibleObject HeaderAccessibleObject {get;}
+ */
+
+ public virtual string HeaderText {
+ get { return headerText; }
+ set { headerText=value; }
+ }
+
+ public string MappingName {
+ get { return mappingName; }
+ set { mappingName=value; }
+ }
+
+ public virtual string NullText {
+ get { return nullText; }
+ set { nullText=value; }
+ }
+
+ public virtual PropertyDescriptor PropertyDescriptor {
+ get { return propertyDescriptor; }
+ set { propertyDescriptor=value; }
+ }
+
+ public virtual bool ReadOnly {
+ get { return readOnly; }
+ set { readOnly=value; }
+ }
+
+ public virtual int Width {
+ get { return width; }
+ set { width=value; }
+ }
+ #endregion
+
+ #region Methods
+ protected internal abstract void Abort(int rowNum);
+
+ [MonoTODO]
+ protected void BeginUpdate()
+ {
+ //FIXME:
+ }
+
+ [MonoTODO]
+ protected void CheckValidDataSource(CurrencyManager value)
+ {
+ //FIXME:
+ }
+
+ [MonoTODO]
+ protected internal virtual void ColumnStartedEditing(Control editingControl)
+ {
+ //FIXME:
+ }
+
+ protected internal abstract bool Commit(CurrencyManager dataSource,int rowNum);
+
+ [MonoTODO]
+ protected internal virtual void ConcedeFocus()
+ {
+ //FIXME:
+ }
+
+ /*
+ * This member supports the .NET Framework infrastructure and is not intended to be used directly from your code.
+ protected virtual AccessibleObject CreateHeaderAccessibleObject()
+ */
+
+ [MonoTODO]
+ protected internal virtual void Edit(CurrencyManager source) {
+ //FIXME:
+ }
+
+ [MonoTODO]
+ protected internal virtual void Edit(CurrencyManager source, int rowNum) {
+ //FIXME:
+ }
+
+ [MonoTODO]
+ protected internal abstract void Edit(CurrencyManager source, int rowNum, Rectangle bounds,
+ bool readOnly, string instantText, bool cellIsVisible);
+
+ [MonoTODO]
+ protected void EndUpdate()
+ {
+ //FIXME:
+ }
+
+ [MonoTODO]
+ protected internal virtual void EnterNullValue()
+ {
+ //FIXME:
+ }
+
+ [MonoTODO]
+ protected internal virtual object GetColumnValueAtRow(CurrencyManager source,int rowNum)
+ {
+ throw new NotImplementedException ();
+ }
+
+ protected internal abstract int GetMinimumHeight();
+
+ protected internal abstract int GetPreferredHeight(Graphics g,object value);
+
+ protected internal abstract Size GetPreferredSize(Graphics g,object value);
+
+ /*
+ * This member supports the .NET Framework infrastructure and is not intended to be used directly from your code.
+ */
+ [MonoTODO]
+ void IDataGridColumnStyleEditingNotificationService.ColumnStartedEditing(Control editingControl)
+ {
+ //FIXME:
+ }
+
+ [MonoTODO]
+ protected virtual void Invalidate()
+ {
+ //FIXME:
+ }
+
+ protected internal abstract void Paint(Graphics g,Rectangle bounds,CurrencyManager source,int rowNum);
+
+ protected internal abstract void Paint(Graphics g,Rectangle bounds,CurrencyManager source,int rowNum,bool alignToRight);
+
+ [MonoTODO]
+ protected internal virtual void Paint(Graphics g, Rectangle bounds, CurrencyManager source,
+ int rowNum, Brush backBrush, Brush foreBrush, bool alignToRight) {
+ //FIXME:
+ }
+
+ [MonoTODO]
+ public void ResetHeaderText()
+ {
+ //FIXME:
+ }
+
+ [MonoTODO]
+ protected internal virtual void SetColumnValueAtRow(CurrencyManager source,int rowNum,object value)
+ {
+ //FIXME:
+ }
+
+ [MonoTODO]
+ protected virtual void SetDataGrid(DataGrid value)
+ {
+ //FIXME:
+ }
+
+ [MonoTODO]
+ protected virtual void SetDataGridInColumn(DataGrid value)
+ {
+ //FIXME:
+ }
+
+ [MonoTODO]
+ protected internal virtual void UpdateUI(CurrencyManager source,int rowNum,string instantText) {
+ //FIXME:
+ }
+ #endregion
+
+ #region Events
+
+ public event EventHandler AlignmentChanged;
+
+ /* This member supports the .NET Framework infrastructure and is not intended to be used directly from your code
+ public event EventHandler FontChanged;
+ */
+
+ public event EventHandler HeaderTextChanged;
+ public event EventHandler MappingNameChanged;
+ public event EventHandler NullTextChanged;
+ public event EventHandler PropertyDescriptorChanged;
+ public event EventHandler ReadOnlyChanged;
+ public event EventHandler WidthChanged;
+ #endregion
+
+ /// sub-classes:
+ /// This type supports the .NET Framework infrastructure and is not intended to be used directly from your code.
+ ///
+ /// protected class DataGridColumnStyle.CompModSwitches;
+ /// protected class DataGridColumnStyle.DataGridColumnHeaderAccessibleObject : AccessibleObject;
+
+ }
+}
+
diff --git a/mcs/class/System.Windows.Forms/Gtk/DataGridLineStyle.cs b/mcs/class/System.Windows.Forms/Gtk/DataGridLineStyle.cs
new file mode 100644
index 00000000000..732613e816c
--- /dev/null
+++ b/mcs/class/System.Windows.Forms/Gtk/DataGridLineStyle.cs
@@ -0,0 +1,19 @@
+//
+// System.Windows.Forms.DataGridLineStyle.cs
+//
+// Author:
+// Dennis Hayes (dennish@raytek.com)
+// (C) 2002 Ximian, Inc. http://www.ximian.com
+//
+
+using System;
+
+namespace System.Windows.Forms {
+
+ /// <summary>
+ /// </summary>
+ public enum DataGridLineStyle {
+ None = 0,
+ Solid = 1
+ }
+}
diff --git a/mcs/class/System.Windows.Forms/Gtk/DataGridParentRowsLabelStyle.cs b/mcs/class/System.Windows.Forms/Gtk/DataGridParentRowsLabelStyle.cs
new file mode 100644
index 00000000000..3f9d86b4d9f
--- /dev/null
+++ b/mcs/class/System.Windows.Forms/Gtk/DataGridParentRowsLabelStyle.cs
@@ -0,0 +1,26 @@
+//
+// System.Windows.Forms.DataGridParentRowsLabelStyle.cs
+//
+// Author:
+// Jaak Simm (jaaksimm@firm.ee)
+// Dennis Hayes (dennish@raytek.com)
+// (C) 2002 Ximian, Inc. http://www.ximian.com
+//
+
+using System;
+
+namespace System.Windows.Forms {
+
+
+ /// <summary>
+ /// Specifies how the parent row labels of a DataGrid control are displayed.
+ /// </summary>
+ public enum DataGridParentRowsLabelStyle {
+
+ //Values were verified with enumcheck.
+ None = 0,
+ TableName = 1,
+ ColumnName = 2,
+ Both = 3,
+ }
+}
diff --git a/mcs/class/System.Windows.Forms/Gtk/DataGridPreferredColumnWidthTypeConverter.cs b/mcs/class/System.Windows.Forms/Gtk/DataGridPreferredColumnWidthTypeConverter.cs
new file mode 100644
index 00000000000..f11031c35d8
--- /dev/null
+++ b/mcs/class/System.Windows.Forms/Gtk/DataGridPreferredColumnWidthTypeConverter.cs
@@ -0,0 +1,59 @@
+//
+// System.Windows.Forms.DataGridPreferredColumnWidthTypeConverter
+//
+// Author:
+// stubbed out by Jaak Simm (jaaksimm@firm.ee)
+// Dennis Hayes (dennish@Raytek.com)
+//
+// (C) Ximian, Inc., 2002
+//
+
+using System.ComponentModel;
+using System.Globalization;
+
+namespace System.Windows.Forms {
+
+ /// <summary>
+ /// Converts the value of an object to a different data type.
+ /// </summary>
+
+ [MonoTODO]
+ public class DataGridPreferredColumnWidthTypeConverter : TypeConverter {
+
+ #region Constructors
+ [MonoTODO]
+ public DataGridPreferredColumnWidthTypeConverter()
+ {
+
+ }
+ #endregion
+
+ #region Methods
+ [MonoTODO]
+ public override bool CanConvertFrom(ITypeDescriptorContext context,Type sourceType)
+ {
+ //FIXME:
+ return base.CanConvertFrom(context, sourceType);
+ }
+
+ [MonoTODO]
+ public override object ConvertFrom(ITypeDescriptorContext context,CultureInfo culture,object value)
+ {
+ //FIXME:
+ return base.ConvertFrom(context, culture, value);
+ }
+
+ [MonoTODO]
+ public override object ConvertTo(
+ ITypeDescriptorContext context,
+ CultureInfo culture,
+ object value,
+ Type destinationType) {
+ //FIXME:
+ return base.ConvertTo(context, culture, value, destinationType);
+ }
+ #endregion
+
+ }
+}
+
diff --git a/mcs/class/System.Windows.Forms/Gtk/DataGridTableStyle.cs b/mcs/class/System.Windows.Forms/Gtk/DataGridTableStyle.cs
new file mode 100644
index 00000000000..bfa8d5818c3
--- /dev/null
+++ b/mcs/class/System.Windows.Forms/Gtk/DataGridTableStyle.cs
@@ -0,0 +1,485 @@
+//
+// System.Windows.Forms.DataGridTableStyle
+//
+// Author:
+// stubbed out by Jaak Simm (jaaksimm@firm.ee)
+// Dennis Hayes (dennish@Raytek.com)
+//
+// (C) Ximian, Inc., 2002
+//
+
+using System.ComponentModel;
+using System.Drawing;
+using System.Collections;
+
+namespace System.Windows.Forms {
+
+ /// <summary>
+ /// Represents the table drawn by the System.Windows.Forms.DataGrid control at run time.
+ /// </summary>
+
+ [MonoTODO]
+ public class DataGridTableStyle : Component {
+
+ #region Fields
+ // This member supports the .NET Framework infrastructure and is not intended to be used directly from your code:
+ // public static DataGridTableStyle DefaultTableStyle;
+ bool allowSorting;
+ Color alternatingBackColor;
+ Color backColor;
+ bool columnHeadersVisible;
+ DataGrid dataGrid;
+ Color foreColor;
+ Color gridLineColor;
+ DataGridLineStyle gridLineStyle;
+ Color headerBackColor;
+ Font headerFont;
+ Color headerForeColor;
+ Color linkColor;
+ string mappingName;
+ int preferredColumnWidth;
+ int preferredRowHeight;
+ bool readOnly;
+ bool rowHeadersVisible;
+ int rowHeaderWidth;
+ Color selectionBackColor;
+ Color selectionForeColor;
+ #endregion
+
+ #region Constructors
+ [MonoTODO]
+ public DataGridTableStyle()
+ {
+ allowSorting=true;
+ alternatingBackColor=SystemColors.Window;
+ gridLineStyle=DataGridLineStyle.Solid;
+ rowHeadersVisible=true;
+ }
+
+ // This member supports the .NET Framework infrastructure and is not intended to be used directly from your code:
+ // public DataGridTableStyle(bool isDefaultTableStyle);
+
+ [MonoTODO]
+ public DataGridTableStyle(CurrencyManager listManager) : this()
+ {
+
+ }
+ #endregion
+
+ #region Properties
+ public bool AllowSorting {
+ get { return allowSorting; }
+ set { allowSorting=value; }
+ }
+
+ public Color AlternatingBackColor {
+ get { return alternatingBackColor; }
+ set { alternatingBackColor=value; }
+ }
+
+ public Color BackColor {
+ get { return backColor; }
+ set { backColor=value; }
+ }
+
+ public bool ColumnHeadersVisible {
+ get { return columnHeadersVisible; }
+ set { columnHeadersVisible=value; }
+ }
+
+ public virtual DataGrid DataGrid {
+ get { return dataGrid; }
+ set { dataGrid=value; }
+ }
+
+ public Color ForeColor {
+ get { return foreColor; }
+ set { foreColor=value; }
+ }
+
+ [MonoTODO]
+ public virtual GridColumnStylesCollection GridColumnStyles {
+ get { throw new NotImplementedException (); }
+ }
+
+ public Color GridLineColor {
+ get { return gridLineColor; }
+ set { gridLineColor=value; }
+ }
+
+ public DataGridLineStyle GridLineStyle {
+ get { return gridLineStyle; }
+ set { gridLineStyle=value; }
+ }
+
+ public Color HeaderBackColor {
+ get { return headerBackColor; }
+ set { headerBackColor=value; }
+ }
+
+ public Font HeaderFont {
+ get { return headerFont; }
+ set { headerFont=value; }
+ }
+
+ public Color HeaderForeColor {
+ get { return headerForeColor; }
+ set { headerForeColor=value; }
+ }
+
+ public Color LinkColor {
+ get { return linkColor; }
+ set { linkColor=value; }
+ }
+
+ // This member supports the .NET Framework infrastructure and is not intended to be used directly from your code.
+ // public Color LinkHoverColor {get; set;}
+
+ public string MappingName {
+ get { return mappingName; }
+ set { mappingName=value; }
+ }
+
+ public int PreferredColumnWidth {
+ get { return preferredColumnWidth; }
+ set { preferredColumnWidth=value; }
+ }
+
+ public int PreferredRowHeight {
+ get { return preferredRowHeight; }
+ set { preferredRowHeight=value; }
+ }
+
+ public virtual bool ReadOnly {
+ get { return allowSorting; }
+ set { allowSorting=value; }
+ }
+
+ public bool RowHeadersVisible {
+ get { return rowHeadersVisible; }
+ set { rowHeadersVisible=value; }
+ }
+
+ [MonoTODO]
+ public int RowHeaderWidth {
+ get { return rowHeaderWidth; }
+ set { rowHeaderWidth=value; }
+ }
+
+ public Color SelectionBackColor {
+ get { return selectionBackColor; }
+ set { selectionBackColor=value; }
+ }
+
+ public Color SelectionForeColor {
+ get { return selectionForeColor; }
+ set { selectionForeColor=value; }
+ }
+ #endregion
+
+ #region Methods
+ [MonoTODO]
+ public bool BeginEdit(DataGridColumnStyle gridColumn,int rowNumber)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ protected internal virtual DataGridColumnStyle CreateGridColumn(PropertyDescriptor prop)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ protected internal virtual DataGridColumnStyle CreateGridColumn(PropertyDescriptor prop,bool isDefault)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ protected override void Dispose(bool disposing)
+ {
+ //FIXME:
+ base.Dispose(disposing);;
+ }
+
+ [MonoTODO]
+ public bool EndEdit(DataGridColumnStyle gridColumn,int rowNumber,bool shouldAbort)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ protected virtual void OnAllowSortingChanged(EventArgs e)
+ {
+ //FIXME:
+ }
+
+ [MonoTODO]
+ protected virtual void OnAlternatingBackColorChanged(EventArgs e)
+ {
+ //FIXME:
+ }
+
+ [MonoTODO]
+ protected virtual void OnBackColorChanged(EventArgs e)
+ {
+ //FIXME:
+ }
+
+ [MonoTODO]
+ protected virtual void OnColumnHeadersVisibleChanged(EventArgs e)
+ {
+ //FIXME:
+ }
+
+ [MonoTODO]
+ protected virtual void OnForeColorChanged(EventArgs e)
+ {
+ //FIXME:
+ }
+
+ [MonoTODO]
+ protected virtual void OnGridLineColorChanged(EventArgs e)
+ {
+ //FIXME:
+ }
+
+ [MonoTODO]
+ protected virtual void OnGridLineStyleChanged(EventArgs e)
+ {
+ //FIXME:
+ }
+
+ [MonoTODO]
+ protected virtual void OnHeaderBackColorChanged(EventArgs e)
+ {
+ //FIXME:
+ }
+
+ [MonoTODO]
+ protected virtual void OnHeaderFontChanged(EventArgs e)
+ {
+ //FIXME:
+ }
+
+ [MonoTODO]
+ protected virtual void OnHeaderForeColorChanged(EventArgs e)
+ {
+ //FIXME:
+ }
+
+ [MonoTODO]
+ protected virtual void OnLinkColorChanged(EventArgs e)
+ {
+ //FIXME:
+ }
+
+ [MonoTODO]
+ protected virtual void OnLinkHoverColorChanged(EventArgs e)
+ {
+ //FIXME:
+ }
+
+ [MonoTODO]
+ protected virtual void OnMappingNameChanged(EventArgs e)
+ {
+ //FIXME:
+ }
+
+ [MonoTODO]
+ protected virtual void OnPreferredColumnWidthChanged(EventArgs e)
+ {
+ //FIXME:
+ }
+
+ [MonoTODO]
+ protected virtual void OnPreferredRowHeightChanged(EventArgs e)
+ {
+ //FIXME:
+ }
+
+ [MonoTODO]
+ protected virtual void OnReadOnlyChanged(EventArgs e)
+ {
+ //FIXME:
+ }
+
+ [MonoTODO]
+ protected virtual void OnRowHeadersVisibleChanged(EventArgs e)
+ {
+ //FIXME:
+ }
+
+ [MonoTODO]
+ protected virtual void OnRowHeaderWidthChanged(EventArgs e)
+ {
+ //FIXME:
+ }
+
+ [MonoTODO]
+ protected virtual void OnSelectionBackColorChanged(EventArgs e)
+ {
+ //FIXME:
+ }
+
+ [MonoTODO]
+ protected virtual void OnSelectionForeColorChanged(EventArgs e)
+ {
+ //FIXME:
+ }
+
+ [MonoTODO]
+ public void ResetAlternatingBackColor()
+ {
+ //FIXME:
+ }
+
+ [MonoTODO]
+ public void ResetBackColor()
+ {
+ //FIXME:
+ }
+
+ [MonoTODO]
+ public void ResetForeColor()
+ {
+ //FIXME:
+ }
+
+ [MonoTODO]
+ public void ResetGridLineColor()
+ {
+ //FIXME:
+ }
+
+ [MonoTODO]
+ public void ResetHeaderBackColor()
+ {
+ //FIXME:
+ }
+
+ [MonoTODO]
+ public void ResetHeaderFont()
+ {
+ //FIXME:
+ }
+
+ [MonoTODO]
+ public void ResetHeaderForeColor()
+ {
+ //FIXME:
+ }
+
+ [MonoTODO]
+ public void ResetLinkColor()
+ {
+ //FIXME:
+ }
+
+ /// This member supports the .NET Framework infrastructure and is not intended to be used directly from your code.
+ // public void ResetLinkHoverColor
+
+ [MonoTODO]
+ public void ResetSelectionBackColor()
+ {
+ //FIXME:
+ }
+
+ [MonoTODO]
+ public void ResetSelectionForeColor()
+ {
+ //FIXME:
+ }
+
+ [MonoTODO]
+ protected virtual bool ShouldSerializeAlternatingBackColor()
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ protected bool ShouldSerializeBackColor()
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ protected bool ShouldSerializeForeColor()
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ protected virtual bool ShouldSerializeGridLineColor()
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ protected virtual bool ShouldSerializeHeaderBackColor()
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ protected virtual bool ShouldSerializeHeaderForeColor()
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ protected virtual bool ShouldSerializeLinkColor()
+ {
+ throw new NotImplementedException ();
+ }
+
+ /// This member supports the .NET Framework infrastructure and is not intended to be used directly from your code.
+ /// protected virtual bool ShouldSerializeLinkHoverColor();
+
+ [MonoTODO]
+ protected bool ShouldSerializePreferredRowHeight()
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ protected bool ShouldSerializeSelectionBackColor()
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ protected virtual bool ShouldSerializeSelectionForeColor()
+ {
+ throw new NotImplementedException ();
+ }
+ #endregion
+
+ #region Events
+ public event EventHandler AllowSortingChanged ;
+ public event EventHandler AlternatingBackColorChanged;
+ public event EventHandler BackColorChanged;
+ public event EventHandler ColumnHeadersVisibleChanged;
+ public event EventHandler ForeColorChanged;
+ public event EventHandler GridLineColorChanged;
+ public event EventHandler GridLineStyleChanged;
+ public event EventHandler HeaderBackColorChanged;
+ public event EventHandler HeaderFontChanged;
+ public event EventHandler HeaderForeColorChanged;
+ public event EventHandler LinkColorChanged;
+
+ /// This member supports the .NET Framework infrastructure and is not intended to be used directly from your code.
+ /// public event EventHandler LinkHoverColorChanged;
+
+ public event EventHandler MappingNameChanged;
+ public event EventHandler PreferredColumnWidthChanged;
+ public event EventHandler PreferredRowHeightChanged;
+ public event EventHandler ReadOnlyChanged;
+ public event EventHandler RowHeadersVisibleChanged;
+ public event EventHandler RowHeaderWidthChanged;
+ public event EventHandler SelectionBackColorChanged;
+ public event EventHandler SelectionForeColorChanged;
+ #endregion
+ }
+}
diff --git a/mcs/class/System.Windows.Forms/Gtk/DataGridTextBox.cs b/mcs/class/System.Windows.Forms/Gtk/DataGridTextBox.cs
new file mode 100644
index 00000000000..b948ed34b59
--- /dev/null
+++ b/mcs/class/System.Windows.Forms/Gtk/DataGridTextBox.cs
@@ -0,0 +1,78 @@
+//
+// System.Windows.Forms.DataGridTextBox
+//
+// Author:
+// stubbed out by Jaak Simm (jaaksimm@firm.ee)
+// Dennis Hayes (dennish@Raytek.com)
+//
+// (C) Ximian, Inc., 2002
+//
+
+using System.Drawing;
+using System.ComponentModel;
+
+namespace System.Windows.Forms {
+
+ /// <summary>
+ /// Represents a TextBox control that is hosted in a DataGridTextBoxColumn.
+ /// </summary>
+
+ [MonoTODO]
+ public class DataGridTextBox : TextBox {
+
+ #region Fields
+ bool isInEditOrNavigateMode;
+ #endregion
+
+ #region Constructor
+ [MonoTODO]
+ public DataGridTextBox()
+ {
+ isInEditOrNavigateMode=true;
+ }
+ #endregion
+
+ #region Properties
+ public bool IsInEditOrNavigateMode {
+ get { return isInEditOrNavigateMode; }
+ set { isInEditOrNavigateMode=value; }
+ }
+ #endregion
+
+ #region Methods
+ [MonoTODO]
+ protected override void OnKeyPress(KeyPressEventArgs e)
+ {
+ //FIXME:
+ base.OnKeyPress(e);
+ }
+
+ [MonoTODO]
+ protected override void OnMouseWheel(MouseEventArgs e)
+ {
+ //FIXME:
+ base.OnMouseWheel(e);
+ }
+
+ //[MonoTODO]
+ //protected internal override bool ProcessKeyMessage(ref Message m)
+ //{
+ //FIXME:
+ //return base.ProcessKeyMessage(ref m);
+ //}
+
+ [MonoTODO]
+ public void SetDataGrid(DataGrid parentGrid)
+ {
+ //FIXME:
+ }
+
+ //[MonoTODO]
+ //protected override void WndProc(ref Message m)
+ //{
+ //FIXME:
+ //base.WndProc(ref m);
+ //}
+ #endregion
+ }
+}
diff --git a/mcs/class/System.Windows.Forms/Gtk/DataGridTextBoxColumn.cs b/mcs/class/System.Windows.Forms/Gtk/DataGridTextBoxColumn.cs
new file mode 100644
index 00000000000..32d158fd1db
--- /dev/null
+++ b/mcs/class/System.Windows.Forms/Gtk/DataGridTextBoxColumn.cs
@@ -0,0 +1,202 @@
+//
+// System.Windows.Forms.DataGridTextBoxColumn
+//
+// Author:
+// stubbed out by Richard Baumann (biochem333@nyc.rr.com)
+// Dennis Hayes (dennish@Raytek.com)
+//
+// (C) Ximian, Inc., 2002
+//
+using System.Drawing;
+using System.ComponentModel;
+namespace System.Windows.Forms {
+
+ // <summary>
+ // Hosts a TextBox control in a cell of a DataGridColumnStyle for editing strings.
+ // </summary>
+ public class DataGridTextBoxColumn : DataGridColumnStyle {
+
+ //
+ // --- Constructors/Destructors
+ //
+ [MonoTODO]
+ public DataGridTextBoxColumn() : base()
+ {
+
+ }
+ [MonoTODO]
+ public DataGridTextBoxColumn(PropertyDescriptor prop) : base(prop)
+ {
+
+ }
+ [MonoTODO]
+ public DataGridTextBoxColumn(PropertyDescriptor prop, bool isDefault) : base(prop)
+ {
+ // This method is internal to the .NET framework.
+
+ }
+ [MonoTODO]
+ public DataGridTextBoxColumn(PropertyDescriptor prop, string format) : base(prop)
+ {
+
+ }
+ [MonoTODO]
+ public DataGridTextBoxColumn(PropertyDescriptor prop, string format, bool isDefault) : base(prop)
+ {
+ // This method is internal to the .NET framework.
+ }
+
+ // --- Protected Methods
+
+ [MonoTODO]
+ protected internal override void Abort(int rowNum)
+ {
+ throw new NotImplementedException ();
+ }
+ [MonoTODO]
+ protected internal override bool Commit(CurrencyManager dataSource, int rowNum)
+ {
+ throw new NotImplementedException ();
+ }
+ [MonoTODO]
+ protected internal override void ConcedeFocus()
+ {
+ //FIXME:
+ base.ConcedeFocus();
+ }
+ [MonoTODO]
+ protected internal override void Edit(CurrencyManager source, int rowNum, Rectangle bounds,
+ bool readOnly, string instantText, bool cellIsVisible) {
+
+ // This method is internal to the .NET framework.
+ throw new NotImplementedException ();
+ }
+// [MonoTODO]
+// //FIXME
+// protected internal virtual void Edit(CurrencyManager source, int rowNum, Rectangle bounds, bool readOnly)
+// {
+// // This method is internal to the .NET framework.
+// throw new NotImplementedException ();
+// }
+ [MonoTODO]
+ protected internal virtual void Edit(CurrencyManager source, int rowNum, Rectangle bounds, bool readOnly, string instantText)
+ {
+ // This method is internal to the .NET framework.
+ //FIXME:
+ }
+ [MonoTODO]
+ protected void EndEdit()
+ {
+ // This method is internal to the .NET framework.
+ //FIXME:
+ }
+ [MonoTODO]
+ protected internal override void EnterNullValue()
+ {
+ //FIXME:
+ base.EnterNullValue();
+ }
+ [MonoTODO]
+ protected internal override int GetMinimumHeight()
+ {
+ throw new NotImplementedException ();
+ }
+ [MonoTODO]
+ protected internal override int GetPreferredHeight(Graphics g, object value)
+ {
+ //FIXME:
+ throw new NotImplementedException ();
+ }
+ [MonoTODO]
+ protected internal override Size GetPreferredSize(Graphics g, object value)
+ {
+ //FIXME:
+ throw new NotImplementedException ();
+ }
+ [MonoTODO]
+ protected void HideEditBox()
+ {
+ //FIXME:
+ }
+ [MonoTODO]
+ protected internal override void Paint(Graphics g, Rectangle bounds, CurrencyManager source, int rowNum)
+ {
+ // This method is internal to the .NET framework.
+ //FIXME:
+ }
+ [MonoTODO]
+ protected internal override void Paint(Graphics g, Rectangle bounds, CurrencyManager source, int rowNum, bool alignToRight)
+ {
+ // This method is internal to the .NET framework.
+ //FIXME:
+ }
+ [MonoTODO]
+ protected internal override void Paint(Graphics g, Rectangle bounds, CurrencyManager source, int rowNum,
+ Brush backBrush, Brush foreBrush, bool alignToRight) {
+
+ // This method is internal to the .NET framework.
+ //FIXME:
+ }
+ [MonoTODO]
+ protected void PaintText(Graphics g, Rectangle bounds, string text, bool alignToRight)
+ {
+ //FIXME:
+ }
+ [MonoTODO]
+ protected void PaintText(Graphics g, Rectangle textBounds, string text, Brush backBrush, Brush foreBrush, bool alignToRight)
+ {
+ //FIXME:
+ }
+ [MonoTODO]
+ protected override void SetDataGridInColumn(DataGrid value)
+ {
+ //FIXME:
+ }
+ [MonoTODO]
+ protected internal override void UpdateUI(CurrencyManager source, int rowNum, string instantText)
+ {
+ //FIXME:
+ }
+
+
+ // --- Public Properties
+
+ [MonoTODO]
+ public string Format {
+
+ get { throw new NotImplementedException (); }
+ set { throw new NotImplementedException (); }
+ }
+ [MonoTODO]
+ public IFormatProvider FormatInfo {
+
+ get { throw new NotImplementedException (); }
+ set { throw new NotImplementedException (); }
+ }
+ [MonoTODO]
+ public override PropertyDescriptor PropertyDescriptor {
+
+ set {
+ //FIXME:
+ base.PropertyDescriptor = value;
+ }
+ }
+ [MonoTODO]
+ public override bool ReadOnly {
+
+ get {
+ //FIXME:
+ return base.ReadOnly;
+ }
+ set {
+ //FIXME:
+ base.ReadOnly = value;
+ }
+ }
+ [MonoTODO]
+ public virtual TextBox TextBox {
+
+ get { throw new NotImplementedException (); }
+ }
+ }
+}
diff --git a/mcs/class/System.Windows.Forms/Gtk/Demo3.cs b/mcs/class/System.Windows.Forms/Gtk/Demo3.cs
new file mode 100644
index 00000000000..cf63331ec93
--- /dev/null
+++ b/mcs/class/System.Windows.Forms/Gtk/Demo3.cs
@@ -0,0 +1,96 @@
+//
+// System.Windows.Forms Demo2 app
+//
+//Authors:
+// Joel Basson (jstrike@mweb.co.za)
+//
+//
+
+using System;
+using System.Drawing;
+using System.Windows.Forms;
+using System.Data;
+using ByteFX.Data.MySqlClient;
+
+namespace demo3
+{
+
+ public class GtkForm : System.Windows.Forms.Form
+ {
+ private DataGrid dg1 = new DataGrid();
+
+ private void InitializeWidgets()
+ {
+ this.dg1.Location = new System.Drawing.Point(30,30);
+ this.dg1.Size = new System.Drawing.Size(100,100);
+
+ this.Controls.AddRange(new System.Windows.Forms.Control[] {
+ this.dg1});
+
+
+ this.Size = new Size(512, 250);
+
+ }
+
+ private void Connect()
+ {
+ //MySqlConnection dbcon;
+ DataSet custDS;
+ MySqlDataAdapter custDA;
+ string TableName;
+
+ string connectionString =
+ "Server=yoursever;" +
+ "Database=yourdatabase;" +
+ "User ID=username;" +
+ "Password=password;";
+ MySqlConnection dbcon;
+ dbcon = new MySqlConnection(connectionString);
+ dbcon.Open();
+
+ custDA = new MySqlDataAdapter();
+ custDA.SelectCommand = new MySqlCommand("SELECT * FROM Customer", dbcon);
+ MySqlCommandBuilder custCB = new MySqlCommandBuilder(custDA);
+
+
+ custDS = new DataSet();
+
+ //dbcon.Open();
+
+
+ custDA.Fill(custDS, "Customer");
+
+ //sbananaConn.Close();
+
+ //return custDS;
+
+
+ //dbcmd.Dispose();
+ //dbcmd = null;
+ dg1.DataMember = "Customer";
+ dg1.DataSource = custDS;
+ dg1.SetDataBinding(custDS, "Customer");
+ dbcon.Close();
+ dbcon = null;
+ }
+
+ public GtkForm()
+ {
+ InitializeWidgets();
+ Connect();
+ }
+
+
+ }
+
+ public class GtkMain
+ {
+ [STAThread]
+ public static void Main()
+ {
+ GtkForm form1 = new GtkForm ();
+ form1.Text = "System.Windows.Forms at work!";
+ Application.Run(form1);
+ }
+ }
+}
diff --git a/mcs/class/System.Windows.Forms/Gtk/GridColumnStylesCollection.cs b/mcs/class/System.Windows.Forms/Gtk/GridColumnStylesCollection.cs
new file mode 100644
index 00000000000..4c09e2716f0
--- /dev/null
+++ b/mcs/class/System.Windows.Forms/Gtk/GridColumnStylesCollection.cs
@@ -0,0 +1,178 @@
+//
+// System.Windows.Forms.GridColumnStylesCollection.cs
+//
+// Author:
+// stubbed out by Daniel Carrera (dcarrera@math.toronto.edu)
+// Dennis Hayes (dennish@Raytek.com)
+//
+// (C) 2002 Ximian, Inc
+//
+using System.Collections;
+using System.ComponentModel;
+namespace System.Windows.Forms {
+
+ // <summary>
+ // </summary>
+
+ public class GridColumnStylesCollection : BaseCollection, IList {
+ //
+ // --- Public Methods
+ //
+ [MonoTODO]
+ public virtual int Add(DataGridColumnStyle column) {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void AddRange(DataGridColumnStyle [] columns)
+ {
+ //FIXME:
+ }
+
+ [MonoTODO]
+ public void Clear()
+ {
+ //FIXME:
+ }
+
+ [MonoTODO]
+ public bool Contains()
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public int IndexOf(DataGridColumnStyle element)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void Remove(DataGridColumnStyle column)
+ {
+ //FIXME:
+ }
+
+ [MonoTODO]
+ public void RemoveAt(int index)
+ {
+ //FIXME:
+ }
+
+ [MonoTODO]
+ public void ResetPropertyDescriptors()
+ {
+ //FIXME:
+ }
+
+ //
+ // --- Public Events
+ //
+ [MonoTODO]
+ public event CollectionChangeEventHandler CollectionChanged;
+
+ //
+ // --- Protected Properties
+ //
+ [MonoTODO]
+ protected override ArrayList List {
+ get {
+ return base.List;
+ //FIXME:
+ }
+ }
+
+ //
+ // --- Protected Methods
+ //
+ [MonoTODO]
+ protected void OnCollectionChanged(CollectionChangeEventArgs cevent)
+ {
+ //FIXME:
+ }
+ /// <summary>
+ /// IList Interface implmentation.
+ /// </summary>
+ bool IList.IsReadOnly{
+ get{
+ // We allow addition, removeal, and editing of items after creation of the list.
+ return false;
+ }
+ }
+ bool IList.IsFixedSize{
+ get{
+ // We allow addition and removeal of items after creation of the list.
+ return false;
+ }
+ }
+
+ [MonoTODO]
+ public object this[int index]{
+ get{
+ throw new NotImplementedException ();
+ }
+ set{
+ //FIXME:
+ }
+ }
+
+ [MonoTODO]
+ void IList.Clear(){
+ //FIXME:
+ }
+
+ [MonoTODO]
+ int IList.Add( object value){
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ bool IList.Contains( object value){
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ int IList.IndexOf( object value){
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ void IList.Insert(int index, object value){
+ //FIXME:
+ }
+
+ [MonoTODO]
+ void IList.Remove( object value){
+ //FIXME:
+ }
+
+ [MonoTODO]
+ void IList.RemoveAt( int index){
+ //FIXME:
+ }
+ // End of IList interface
+
+ /// <summary>
+ /// ICollection Interface implmentation.
+ /// </summary>
+ int ICollection.Count{
+ get{
+ throw new NotImplementedException ();
+ }
+ }
+ bool ICollection.IsSynchronized{
+ get{
+ throw new NotImplementedException ();
+ }
+ }
+ object ICollection.SyncRoot{
+ get{
+ throw new NotImplementedException ();
+ }
+ }
+ void ICollection.CopyTo(Array array, int index){
+ //FIXME:
+ }
+ // End Of ICollection
+ }
+}
diff --git a/mcs/class/System.Windows.Forms/Gtk/GridTableStylesCollection.cs b/mcs/class/System.Windows.Forms/Gtk/GridTableStylesCollection.cs
new file mode 100644
index 00000000000..2cdc8264acb
--- /dev/null
+++ b/mcs/class/System.Windows.Forms/Gtk/GridTableStylesCollection.cs
@@ -0,0 +1,162 @@
+//
+// System.Windows.Forms.GridTableStylesCollection.cs
+//
+// Author:
+// stubbed out by Daniel Carrera (dcarrera@math.toronto.edu)
+// Dennis Hayes (dennish@Raytek.com)
+//
+// (C) 2002 Ximian, Inc
+//
+using System.Collections;
+using System.ComponentModel;
+namespace System.Windows.Forms {
+
+ // <summary>
+ // </summary>
+
+ public class GridTableStylesCollection : BaseCollection, IList {
+
+ //
+ // --- Public Properties
+ //
+ [MonoTODO]
+ public DataGridTableStyle this[int index] {
+ get {
+ throw new NotImplementedException ();
+ }
+ }
+ [MonoTODO]
+ public DataGridTableStyle this[string s] {
+ get {
+ throw new NotImplementedException ();
+ }
+ }
+
+ //
+ // --- Public Methods
+ //
+
+ [MonoTODO]
+ public virtual int Add(DataGridTableStyle table)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public virtual void AddRange(DataGridTableStyle[] tables)
+ {
+ //FIXME:
+ }
+
+ [MonoTODO]
+ public virtual void Clear()
+ {
+ //FIXME:
+ }
+
+ [MonoTODO]
+ public bool Contains(DataGridTableStyle table)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void Remove(DataGridTableStyle table)
+ {
+ //FIXME:
+ }
+
+ [MonoTODO]
+ public void RemoveAt(int index)
+ {
+ //FIXME:
+ }
+
+ //
+ // --- Public Events
+ //
+ [MonoTODO]
+ public event CollectionChangeEventHandler CollectionChanged;
+
+ //
+ // --- Protected Properties
+ //
+ [MonoTODO]
+ protected override ArrayList List {
+ get {
+ throw new NotImplementedException ();
+ }
+ }
+
+ //
+ // --- Protected Methods
+ //
+ [MonoTODO]
+ protected void OnCollectionChanged(CollectionChangeEventArgs cevent)
+ {
+ //FIXME:
+ }
+ /// <summary>
+ /// IList Interface implmentation.
+ /// </summary>
+ bool IList.IsReadOnly{
+ get{
+ // We allow addition, removeal, and editing of items after creation of the list.
+ return false;
+ }
+ }
+ bool IList.IsFixedSize{
+ get{
+ // We allow addition and removeal of items after creation of the list.
+ return false;
+ }
+ }
+
+ //[MonoTODO]
+ object IList.this[int index]{
+ get{
+ throw new NotImplementedException ();
+ }
+ set{
+ //FIXME:
+ }
+ }
+
+ [MonoTODO]
+ void IList.Clear(){
+ //FIXME:
+ }
+
+ [MonoTODO]
+ int IList.Add( object value){
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ bool IList.Contains( object value){
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ int IList.IndexOf( object value){
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ void IList.Insert(int index, object value){
+ //FIXME:
+ }
+
+ [MonoTODO]
+ void IList.Remove( object value){
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ void IList.RemoveAt( int index){
+ throw new NotImplementedException ();
+ }
+ // End of IList interface
+
+ }
+}
diff --git a/mcs/class/System.Windows.Forms/Gtk/IDataGridColumnStyleEditingNotificationService.cs b/mcs/class/System.Windows.Forms/Gtk/IDataGridColumnStyleEditingNotificationService.cs
new file mode 100644
index 00000000000..831d7eba35e
--- /dev/null
+++ b/mcs/class/System.Windows.Forms/Gtk/IDataGridColumnStyleEditingNotificationService.cs
@@ -0,0 +1,17 @@
+//
+// System.Windows.Forms.IDataGridColumnStyleEditingNotificationService.cs
+//
+// Author:
+// William Lamb (wdlamb@notwires.com)
+// Dennis Hayes (dennish@raytek.com)
+//
+// (C) 2002 Ximian, Inc. http://www.ximian.com
+//
+
+namespace System.Windows.Forms {
+
+ public interface IDataGridColumnStyleEditingNotificationService {
+
+ void ColumnStartedEditing(Control editingControl);
+ }
+}
diff --git a/mcs/class/System.Windows.Forms/Gtk/IDataGridEditingService.cs b/mcs/class/System.Windows.Forms/Gtk/IDataGridEditingService.cs
new file mode 100644
index 00000000000..be78fb1856d
--- /dev/null
+++ b/mcs/class/System.Windows.Forms/Gtk/IDataGridEditingService.cs
@@ -0,0 +1,24 @@
+//
+// System.Windows.Forms.IDataGridEditingService.cs
+//
+// Author:
+// William Lamb (wdlamb@notwires.com)
+// Dennis Hayes (dennish@raytek.com)
+//
+// (C) 2002 Ximian, Inc. http://www.ximian.com
+//
+
+namespace System.Windows.Forms {
+
+ public interface IDataGridEditingService {
+
+ // There is no documentation for this interface's members!
+ // Only a note saying that it supports the .NET infrastructure
+ // and is not intended to be used directly from your code.
+ // The following methods had their own listing in the documentation;
+ // I don't know what other methods and properties there may be.
+
+ bool BeginEdit(DataGridColumnStyle gridColumn, int rowNumber);
+ bool EndEdit(DataGridColumnStyle gridColumn, int rowNumber, bool shouldAbort);
+ }
+}
diff --git a/mcs/class/System.Windows.Forms/Gtk/ItemChangedEventArgs.cs b/mcs/class/System.Windows.Forms/Gtk/ItemChangedEventArgs.cs
new file mode 100644
index 00000000000..e196790f4df
--- /dev/null
+++ b/mcs/class/System.Windows.Forms/Gtk/ItemChangedEventArgs.cs
@@ -0,0 +1,36 @@
+//
+// System.Windows.Forms.ItemChangedEventArgs.cs
+//
+// Author:
+// stubbed out by Daniel Carrera (dcarrera@math.toronto.edu)
+// Dennis Hayes (dennish@Raytek.com)
+// Gianandrea Terzi (gianandrea.terzi@lario.com)
+//
+// (C) 2002 Ximian, Inc
+//
+
+namespace System.Windows.Forms {
+
+ // <summary>
+ //
+ // </summary>
+
+ public class ItemChangedEventArgs : EventArgs {
+
+ #region Fields
+ // After looking at ItemChangedEvent, It seems index is always zero.
+ // The ItemChangedEventhandler quierys the sender object to find the item changed.
+ private int index = 0; //Never assigned. default to 0.
+ #endregion
+
+ #region Public Properties
+ public int Index
+ {
+ get {
+ return index;
+ }
+ }
+ #endregion
+
+ }
+}
diff --git a/mcs/class/System.Windows.Forms/Gtk/ItemChangedEventHandler.cs b/mcs/class/System.Windows.Forms/Gtk/ItemChangedEventHandler.cs
new file mode 100644
index 00000000000..7e2564916d9
--- /dev/null
+++ b/mcs/class/System.Windows.Forms/Gtk/ItemChangedEventHandler.cs
@@ -0,0 +1,16 @@
+//
+// System.Windows.Forms.ItemChangedEventHandler.cs
+//
+// Author:
+// Dennis hayes (dennish@raytek.com)
+//
+// (C) 2002 Ximian, Inc. http://www.ximian.com
+//
+
+namespace System.Windows.Forms {
+ [Serializable]
+ public delegate void ItemChangedEventHandler (
+ object sender,
+ ItemChangedEventArgs e
+ );
+}
diff --git a/mcs/class/System.Windows.Forms/Gtk/KeyEventArgs.cs b/mcs/class/System.Windows.Forms/Gtk/KeyEventArgs.cs
new file mode 100644
index 00000000000..d2aa045a4d2
--- /dev/null
+++ b/mcs/class/System.Windows.Forms/Gtk/KeyEventArgs.cs
@@ -0,0 +1,111 @@
+//
+// System.Windows.Forms.KeyEventArgs.cs
+//
+// Author:
+// stubbed out by Daniel Carrera (dcarrera@math.toronto.edu)
+// Partially completed by Dennis Hayes (dennish@raytek.com)
+// Gianandrea Terzi (gianandrea.terzi@lario.com)
+//
+// (C) 2002 Ximian, Inc
+//
+
+using System.Runtime.InteropServices;
+
+namespace System.Windows.Forms {
+
+ // <summary>
+ // Complete
+ // </summary>
+
+ public class KeyEventArgs : EventArgs {
+
+ #region Fields
+
+ private Keys keydata;
+ private bool handled = false;
+
+ #endregion
+ //
+ // --- Constructor
+ //
+ public KeyEventArgs (Keys keyData)
+ {
+ this.keydata = keyData;
+ }
+
+ #region Public Properties
+
+ [ComVisible(true)]
+ public virtual bool Alt
+ {
+ get {
+ return (keydata == Keys.Alt);
+ }
+ }
+
+ [ComVisible(true)]
+ public bool Control
+ {
+ get {
+ return (keydata == Keys.Control);
+ }
+ }
+
+ [ComVisible(true)]
+ public bool Handled
+ {
+ get {
+ return handled;
+ }
+ set {
+ handled = value;
+ }
+ }
+
+ [ComVisible(true)]
+ public Keys KeyCode
+ {
+ get {
+ return keydata & Keys.KeyCode;
+ }
+ }
+
+ [ComVisible(true)]
+ public Keys KeyData
+ {
+ get {
+ return keydata;
+ }
+ }
+
+ [ComVisible(true)]
+ public int KeyValue
+ {
+ get {
+ return Convert.ToInt32(keydata);
+ }
+ }
+
+ [ComVisible(true)]
+ public Keys Modifiers
+ {
+ get {
+ Keys returnKeys = new Keys();
+ if(keydata == Keys.Alt)returnKeys = Keys.Alt;
+ if(keydata == Keys.Control)returnKeys = returnKeys | Keys.Control;
+ if(keydata == Keys.Shift)returnKeys = returnKeys | Keys.Shift;
+ return returnKeys;
+ }
+ }
+
+ [ComVisible(true)]
+ public bool Shift
+ {
+ get {
+ return (keydata == Keys.Shift);
+ }
+ }
+ #endregion
+
+ }
+}
diff --git a/mcs/class/System.Windows.Forms/Gtk/KeyEventHandler.cs b/mcs/class/System.Windows.Forms/Gtk/KeyEventHandler.cs
new file mode 100644
index 00000000000..4bf11a4a481
--- /dev/null
+++ b/mcs/class/System.Windows.Forms/Gtk/KeyEventHandler.cs
@@ -0,0 +1,16 @@
+//
+// System.Windows.Forms.KeyEventHandler.cs
+//
+// Author:
+// Dennis hayes (dennish@raytek.com)
+//
+// (C) 2002 Ximian, Inc. http://www.ximian.com
+//
+
+namespace System.Windows.Forms {
+ [Serializable]
+ public delegate void KeyEventHandler (
+ object sender,
+ KeyEventArgs e
+ );
+}
diff --git a/mcs/class/System.Windows.Forms/Gtk/KeyPressEventArgs.cs b/mcs/class/System.Windows.Forms/Gtk/KeyPressEventArgs.cs
new file mode 100644
index 00000000000..be1ddf64d8c
--- /dev/null
+++ b/mcs/class/System.Windows.Forms/Gtk/KeyPressEventArgs.cs
@@ -0,0 +1,55 @@
+//
+// System.Windows.Forms.KeyPressEventArgs.cs
+//
+// Author:
+// stubbed out by Daniel Carrera (dcarrera@math.toronto.edu)
+// Dennis Hayes (dennish@Raytek.com)
+// Gianandrea Terzi (gterzi@lario.com)
+//
+// (C) 2002 Ximian, Inc
+//
+
+using System.Runtime.InteropServices;
+
+namespace System.Windows.Forms {
+
+ // <summary>
+ // </summary>
+
+ public class KeyPressEventArgs : EventArgs {
+
+ #region Fields
+
+ private char keychar;
+ private bool handled = false; //Gian : Initialize?
+
+ #endregion
+
+ //
+ // --- Constructor
+ //
+ public KeyPressEventArgs (char keyChar)
+ {
+ this.keychar = keyChar;
+ }
+
+ #region Public Properties
+ [ComVisible(true)]
+ public bool Handled {
+ get {
+ return handled;
+ }
+ set {
+ handled = value;
+ }
+ }
+
+ [ComVisible(true)]
+ public char KeyChar {
+ get {
+ return keychar;
+ }
+ }
+ #endregion
+ }
+}
diff --git a/mcs/class/System.Windows.Forms/Gtk/KeyPressEventHandler.cs b/mcs/class/System.Windows.Forms/Gtk/KeyPressEventHandler.cs
new file mode 100644
index 00000000000..6acca0d7ac9
--- /dev/null
+++ b/mcs/class/System.Windows.Forms/Gtk/KeyPressEventHandler.cs
@@ -0,0 +1,16 @@
+//
+// System.Windows.Forms.KeyPressEventHandler.cs
+//
+// Author:
+// Dennis hayes (dennish@raytek.com)
+//
+// (C) 2002 Ximian, Inc. http://www.ximian.com
+//
+
+namespace System.Windows.Forms {
+ [Serializable]
+ public delegate void KeyPressEventHandler (
+ object sender,
+ KeyPressEventArgs e
+ );
+}
diff --git a/mcs/class/System.Windows.Forms/Gtk/Keys.cs b/mcs/class/System.Windows.Forms/Gtk/Keys.cs
new file mode 100644
index 00000000000..4a5e53bd0a4
--- /dev/null
+++ b/mcs/class/System.Windows.Forms/Gtk/Keys.cs
@@ -0,0 +1,202 @@
+//
+// System.Windows.Forms.Keys.cs
+//
+// Author:
+// Dennis Hayes (dennish@raytek.com)
+// (C) 2002 Ximian, Inc. http://www.ximian.com
+//
+
+using System;
+
+namespace System.Windows.Forms {
+
+ /// <summary>
+ /// </summary>
+ ///
+ [Flags]
+ public enum Keys {
+ A = 65,
+ Add = 107,
+ Alt = 262144,
+ Apps = 93,
+ Attn = 246,
+ B = 66,
+ Back = 8,
+ BrowserBack = 166,
+ BrowserFavorites = 171,
+ BrowserForward = 167,
+ BrowserHome = 172,
+ BrowserRefresh = 168,
+ BrowserSearch = 170,
+ BrowserStop = 169,
+ C = 67,
+ Cancel = 3,
+ Capital = 20,
+ CapsLock = 20,
+ Clear = 12,
+ Control = 131072,
+ ControlKey = 17,
+ Crsel = 247,
+ D = 68,
+ D0 = 48,
+ D1 = 49,
+ D2 = 50,
+ D3 = 51,
+ D4 = 52,
+ D5 = 53,
+ D6 = 54,
+ D7 = 55,
+ D8 = 56,
+ D9 = 57,
+ Decimal = 110,
+ Delete = 46,
+ Divide = 111,
+ Down = 40,
+ E = 69,
+ End = 35,
+ Enter = 13,
+ EraseEof = 249,
+ Escape = 27,
+ Execute = 43,
+ Exsel = 248,
+ F = 70,
+ F1 = 112,
+ F2 = 113,
+ F3 = 114,
+ F4 = 115,
+ F5 = 116,
+ F6 = 117,
+ F7 = 118,
+ F8 = 119,
+ F9 = 120,
+ F10 = 121,
+ F11 = 122,
+ F12 = 123,
+ F13 = 124,
+ F14 = 125,
+ F15 = 126,
+ F16 = 127,
+ F17 = 128,
+ F18 = 129,
+ F19 = 130,
+ F20 = 131,
+ F21 = 132,
+ F22 = 133,
+ F23 = 134,
+ F24 = 135,
+ FinalMode = 24,
+ G = 71,
+ H = 72,
+ HanguelMode = 21,
+ HangulMode = 21,
+ HanjaMode = 25,
+ Help = 47,
+ Home = 36,
+ I = 73,
+ IMEAceept = 30,
+ IMEConvert = 28,
+ IMEModeChange = 31,
+ IMENonconvert = 29,
+ Insert = 45,
+ J = 74,
+ JunjaMode = 23,
+ K = 75,
+ KanaMode = 21,
+ KanjiMode = 25,
+ KeyCode = 65535,
+ L = 76,
+ LaunchApplication1 = 182,
+ LaunchApplication2 = 183,
+ LaunchMail = 180,
+ LButton = 1,
+ LControlKey = 162,
+ Left = 37,
+ LineFeed = 10,
+ LShiftKey = 160,
+ LMenu = 164,
+ LWin = 91,
+ M = 77,
+ MButton = 4,
+ MediaNextTrack = 176,
+ MediaPlayPause = 179,
+ MediaPreviousTrack = 177,
+ MediaStop = 178,
+ Menu = 18,
+ Modifiers = -65536,
+ Multiply = 106,
+ N = 78,
+ Next = 34,
+ NoName = 252,
+ None = 0,
+ NumLock = 144,
+ NumPad0 = 96,
+ NumPad1 = 97,
+ NumPad2 = 98,
+ NumPad3 = 99,
+ NumPad4 = 100,
+ NumPad5 = 101,
+ NumPad6 = 102,
+ NumPad7 = 103,
+ NumPad8 = 104,
+ NumPad9 = 105,
+ O = 79,
+ Oem8 = 223,
+ OemBackslash = 226,
+ OemClear = 254,
+ OemCloseBrackets = 221,
+ Oemcomma = 188,
+ OemMinus = 189,
+ OemOpenBrackets = 219,
+ OemPeriod = 190,
+ OemPipe = 220,
+ Oemplus = 187,
+ OemQuestion = 191,
+ OemQuotes = 222,
+ OemSemicolon = 186,
+ Oemtilde = 192,
+ P = 80,
+ Pa1 = 253,
+ PageDown = 34,
+ PageUp = 33,
+ Pause = 19,
+ Play = 250,
+ Print = 42,
+ PrintScreen = 44,
+ Prior = 33,
+ ProcessKey = 229,
+ Q = 81,
+ R = 82,
+ RButton = 2,
+ RControlKey = 163,
+ Return = 13,
+ Right = 39,
+ RMenu = 165,
+ RShiftKey = 161,
+ RWin = 92,
+ S = 83,
+ Scroll = 145,
+ Select = 41,
+ SelectMedia = 181,
+ Separator = 108,
+ Shift = 65536,
+ ShiftKey = 16,
+ Snapshot = 44,
+ Space = 32,
+ Subtract = 109,
+ T = 84,
+ Tab = 9,
+ U = 85,
+ Up = 38,
+ V = 86,
+ VolumeDown = 174,
+ VolumeMute = 173,
+ VolumeUp = 175,
+ W = 87,
+ X = 88,
+ XButton1 = 5,
+ XButton2 = 6,
+ Y = 89,
+ Z = 90,
+ Zoom = 251
+ }
+}
diff --git a/mcs/class/System.Windows.Forms/Gtk/Makefile b/mcs/class/System.Windows.Forms/Gtk/Makefile
index 89f288b20c1..2a82ec4189e 100644
--- a/mcs/class/System.Windows.Forms/Gtk/Makefile
+++ b/mcs/class/System.Windows.Forms/Gtk/Makefile
@@ -10,13 +10,13 @@ CSCOMPILE=mcs
# features and our build rules are more complicated than it can
# handle.
-EXES = demo.exe Demo2.exe singlewidget.exe
+EXES = demo.exe Demo2.exe Demo3.exe singlewidget.exe
LIBRARY = System.Windows.Forms.dll
-LIB_MCS_FLAGS = /r:glib-sharp.dll /r:gdk-sharp.dll /r:gtk-sharp.dll \
+LIB_MCS_FLAGS = /r:Accessibility /r:glib-sharp.dll /r:gdk-sharp.dll /r:gtk-sharp.dll \
/r:gnome-sharp.dll /r:System.Drawing.dll -L `pkg-config --variable=prefix gtk-sharp`/lib
-EXE_MCS_FLAGS = /r:$(LIBRARY) /r:System.Drawing.dll
+EXE_MCS_FLAGS = /r:$(LIBRARY) /r:System.Drawing.dll /r:System.Data /r:ByteFX.Data.dll
LIB_SOURCES = \
TODOAttribute.cs \
@@ -77,8 +77,48 @@ LIB_SOURCES = \
DockStyle.cs \
ListControl.cs \
ListBox.cs \
- LayoutEventArgs.cs
-# DataGrid.cs \
+ CurrencyManager.cs \
+ BindingManagerBase.cs \
+ BindingsCollection.cs \
+ BaseCollection.cs \
+ Binding.cs \
+ ItemChangedEventArgs.cs \
+ ItemChangedEventHandler.cs \
+ ConvertEventArgs.cs \
+ ConvertEventHandler.cs \
+ BindingMemberInfo.cs \
+ BorderStyle.cs \
+ KeyEventArgs.cs \
+ KeyEventHandler.cs \
+ KeyPressEventArgs.cs \
+ KeyPressEventHandler.cs \
+ Keys.cs \
+ AccessibleObject.cs \
+ AccessibleEvents.cs \
+ AccessibleNavigation.cs \
+ AccessibleRole.cs \
+ AccessibleSelection.cs \
+ AccessibleStates.cs \
+ NavigateEventArgs.cs \
+ NavigateEventHandler.cs \
+ PaintEventArgs.cs \
+ PaintEventHandler.cs \
+ GridTableStylesCollection.cs \
+ GridColumnStylesCollection.cs \
+ DataGrid.cs \
+ IDataGridColumnStyleEditingNotificationService.cs \
+ IDataGridEditingService.cs \
+ DataGridColumnStyle.cs \
+ DataGridBoolColumn.cs \
+ DataGridCell.cs \
+ DataGridLineStyle.cs \
+ DataGridParentRowsLabelStyle.cs \
+ DataGridPreferredColumnWidthTypeConverter.cs \
+ DataGridTableStyle.cs \
+ DataGridTextBoxColumn.cs \
+ DataGridTextBox.cs \
+ LayoutEventArgs.cs
+
all-local: $(LIBRARY) $(EXES)
@@ -87,7 +127,7 @@ clean-local:
test-local run-test-local install-local:
-DISTFILES = demo.cs Demo2.cs singlewidget.cs $(LIB_SOURCES)
+DISTFILES = demo.cs Demo2.cs Demo3.cs singlewidget.cs $(LIB_SOURCES)
dist-local: dist-default
diff --git a/mcs/class/System.Windows.Forms/Gtk/NavigateEventArgs.cs b/mcs/class/System.Windows.Forms/Gtk/NavigateEventArgs.cs
new file mode 100644
index 00000000000..29985bc9109
--- /dev/null
+++ b/mcs/class/System.Windows.Forms/Gtk/NavigateEventArgs.cs
@@ -0,0 +1,48 @@
+//
+// System.Windows.Forms.NavigateEventArgs.cs
+//
+// Author:
+// stubbed out by Paul Osman (paul.osman@sympatico.ca)
+// Partially completed by Dennis Hayes (dennish@raytek.com)
+// Gianandrea Terzi (gianandrea.terzi@lario.com)
+//
+// (C) 2002 Ximian, Inc
+//
+
+using System.Runtime.InteropServices;
+
+namespace System.Windows.Forms {
+
+ // <summary>
+ //
+ // </summary>
+
+ public class NavigateEventArgs : EventArgs {
+
+ #region Fields
+
+ private bool isforward;
+
+ #endregion
+
+ //
+ // --- Constructor
+ //
+
+ public NavigateEventArgs(bool isForward)
+ {
+ isforward = isForward;
+ }
+
+ #region Public Properties
+
+ [ComVisible(true)]
+ public bool Forward
+ {
+ get {
+ return isforward;
+ }
+ }
+ #endregion
+ }
+}
diff --git a/mcs/class/System.Windows.Forms/Gtk/NavigateEventHandler.cs b/mcs/class/System.Windows.Forms/Gtk/NavigateEventHandler.cs
new file mode 100644
index 00000000000..a74a75e366f
--- /dev/null
+++ b/mcs/class/System.Windows.Forms/Gtk/NavigateEventHandler.cs
@@ -0,0 +1,18 @@
+//
+// System.Windows.Forms.NavigateEventHandler.cs
+//
+// Authors:
+// Jaak Simm (jaaksimm@firm.ee)
+// Dennis Hayes (dennish@Raytek.com)
+//
+// (C) 2002 Ximian, Inc. http://www.ximian.com
+//
+
+namespace System.Windows.Forms {
+
+ /// <summary>
+ /// Represents the method that will handle the NavigateEventArgs event of a DataGrid.
+ /// </summary>
+ [Serializable]
+ public delegate void NavigateEventHandler(object sender, NavigateEventArgs e);
+}
diff --git a/mcs/class/System.Windows.Forms/Gtk/PaintEventArgs.cs b/mcs/class/System.Windows.Forms/Gtk/PaintEventArgs.cs
new file mode 100644
index 00000000000..5e760e52ca5
--- /dev/null
+++ b/mcs/class/System.Windows.Forms/Gtk/PaintEventArgs.cs
@@ -0,0 +1,67 @@
+//
+// System.Windows.Forms.PaintEventArgs.cs
+//
+// Author:
+// stubbed out by Paul Osman (paul.osman@sympatico.ca)
+// Dennis Hayes (dennish@raytek.com)
+// Gianandrea Terzi (gianandrea.terzi@lario.com)
+//
+// (C) 2002 Ximian, Inc
+//
+using System.Drawing;
+
+namespace System.Windows.Forms {
+
+ // <summary>
+ //
+ // </summary>
+
+ public class PaintEventArgs : EventArgs, IDisposable {
+
+ #region Fields
+
+ private Graphics mgraphics;
+ private Rectangle mclipRect;
+
+ #endregion
+
+ public PaintEventArgs(Graphics graphics, Rectangle clipRect )
+ {
+ this.mgraphics = graphics;
+ this.mclipRect = clipRect;
+ }
+
+ #region Public Properties
+ public Rectangle ClipRectangle
+ {
+ get {
+ return mclipRect;
+ }
+ }
+
+ public Graphics Graphics {
+ get {
+ return mgraphics;
+ }
+ }
+ #endregion
+
+ #region Public Methods
+
+ public void Dispose()
+ {
+ //
+ mgraphics.Dispose();
+ }
+
+ #endregion
+
+ #region Protected Methods
+
+ protected virtual void Dispose(bool disposing)
+ {
+ //
+ }
+ #endregion
+ }
+}
diff --git a/mcs/class/System.Windows.Forms/Gtk/PaintEventHandler.cs b/mcs/class/System.Windows.Forms/Gtk/PaintEventHandler.cs
new file mode 100644
index 00000000000..029769efdc9
--- /dev/null
+++ b/mcs/class/System.Windows.Forms/Gtk/PaintEventHandler.cs
@@ -0,0 +1,18 @@
+//
+// System.Windows.Forms.PaintEventHandler.cs
+//
+// Authors:
+// Jaak Simm (jaaksimm@firm.ee)
+// Dennis Hayes (dennish@Raytek.com)
+//
+// (C) 2002 Ximian, Inc. http://www.ximian.com
+//
+
+namespace System.Windows.Forms {
+
+ /// <summary>
+ /// Represents the method that will handle the Paint event of a Control class.
+ /// </summary>
+ [Serializable]
+ public delegate void PaintEventHandler(object sender, PaintEventArgs e);
+}
diff --git a/mcs/class/System.Windows.Forms/System.Windows.Forms.Test/FolderBrowserDialogTest.cs b/mcs/class/System.Windows.Forms/System.Windows.Forms.Test/FolderBrowserDialogTest.cs
new file mode 100644
index 00000000000..c1bcb39066f
--- /dev/null
+++ b/mcs/class/System.Windows.Forms/System.Windows.Forms.Test/FolderBrowserDialogTest.cs
@@ -0,0 +1,41 @@
+//
+// Test application for the FolderBrowserDialog.cs class implementation
+//
+// Author:
+// (c) 2003 Jordi Mas i Hernàndez, jmas@softcatala.org
+//
+
+using System;
+using System.Windows.Forms;
+using System.IO;
+
+public class FolderBrowserDialogTest : System.Windows.Forms.Form
+{
+
+ // The main entry point for the application.
+ static void Main()
+ {
+ new FolderBrowserDialogTest();
+ }
+
+
+ // Constructor.
+ public FolderBrowserDialogTest()
+ {
+ FolderBrowserDialog folderBrowserDlg = new FolderBrowserDialog();
+
+
+ // Show default class values
+ Console.WriteLine("Default values---");
+ Console.WriteLine("ShowNewFolderButton " + folderBrowserDlg.ShowNewFolderButton);
+ Console.WriteLine("RootFolder " + folderBrowserDlg.RootFolder);
+
+ folderBrowserDlg.Description = "Select a file";
+
+ DialogResult result = folderBrowserDlg.ShowDialog();
+ if( result == DialogResult.OK )
+ Console.WriteLine("Selected folder: " + folderBrowserDlg.SelectedPath);
+
+ }
+
+} \ No newline at end of file
diff --git a/mcs/class/System.Windows.Forms/System.Windows.Forms/ButtonBase.cs b/mcs/class/System.Windows.Forms/System.Windows.Forms/ButtonBase.cs
index 172aef21fe1..6d5a1d84361 100644
--- a/mcs/class/System.Windows.Forms/System.Windows.Forms/ButtonBase.cs
+++ b/mcs/class/System.Windows.Forms/System.Windows.Forms/ButtonBase.cs
@@ -72,8 +72,7 @@ namespace System.Windows.Forms {
if( flatStyle == FlatStyle.System) {
Win32.UpdateWindowStyle(Handle, (int)ButtonStyles.BS_OWNERDRAW, 0);
- }
- else {
+ } else {
Win32.UpdateWindowStyle(Handle, 0, (int)ButtonStyles.BS_OWNERDRAW);
}
Invalidate();
@@ -258,27 +257,46 @@ namespace System.Windows.Forms {
switch (m.Msg) {
case Msg.WM_COMMAND: {
switch(m.HiWordWParam) {
- case (uint)ButtonNotification.BN_CLICKED:
+ case (uint)ButtonNotification.BN_CLICKED: {
OnClick(new ControlEventArgs(this));
+ Win32.SendMessage(Handle, Msg.WM_SETFOCUS, (int)Handle, 0);
CallControlWndProc(ref m);
break;
- case (uint)ButtonNotification.BN_DOUBLECLICKED:
+ }
+
+ case (uint)ButtonNotification.BN_DOUBLECLICKED: {
OnClick(new ControlEventArgs(this));
CallControlWndProc(ref m);
break;
+ }
+
+ case (uint)ButtonNotification.BN_SETFOCUS: {
+ OnGotFocus(new ControlEventArgs(this));
+ break;
+ }
+
+ case (uint)ButtonNotification.BN_KILLFOCUS: {
+ OnLostFocus(new ControlEventArgs(this));
+ break;
+ }
+
default:
CallControlWndProc(ref m);
break;
}
break;
}
- case Msg.WM_DRAWITEM:
+
+ case Msg.WM_DRAWITEM: {
m.Result = (IntPtr)1;
break;
- case Msg.WM_PAINT:
- PAINTSTRUCT ps = new PAINTSTRUCT ();
- IntPtr hdc = Win32.BeginPaint (Handle, ref ps);
- Rectangle rc = new Rectangle ();
+ }
+
+ case Msg.WM_PAINT: {
+ PAINTSTRUCT ps = new PAINTSTRUCT ();
+ IntPtr hdc = Win32.BeginPaint (Handle, ref ps);
+ Rectangle rc = new Rectangle ();
+
rc.X = ps.rcPaint.left;
rc.Y = ps.rcPaint.top;
rc.Width = ps.rcPaint.right - ps.rcPaint.left;
@@ -288,9 +306,12 @@ namespace System.Windows.Forms {
paintEventArgs.Dispose ();
Win32.EndPaint (Handle, ref ps);
break;
- default:
+ }
+
+ default: {
base.WndProc (ref m);
break;
+ }
}
}
diff --git a/mcs/class/System.Windows.Forms/System.Windows.Forms/ButtonState.cs b/mcs/class/System.Windows.Forms/System.Windows.Forms/ButtonState.cs
index f0f869d390e..abe556125f8 100644
--- a/mcs/class/System.Windows.Forms/System.Windows.Forms/ButtonState.cs
+++ b/mcs/class/System.Windows.Forms/System.Windows.Forms/ButtonState.cs
@@ -4,6 +4,7 @@
// Author:
// Dennis Hayes (dennish@raytek.com)
// (C) 2002 Ximian, Inc. http://www.ximian.com
+// (C) 2003 Novell, Inc. http://www.novell.com
//
using System;
@@ -13,11 +14,12 @@ namespace System.Windows.Forms {
/// <summary>
/// </summary>
public enum ButtonState {
- All = 181176,
+ All = 18176,
Checked = 1024,
Flat = 16384,
Inactive = 256,
Normal = 0,
- Pushed = 512
+ Pushed = 512,
+ ThreeState = 8
}
}
diff --git a/mcs/class/System.Windows.Forms/System.Windows.Forms/ChangeLog b/mcs/class/System.Windows.Forms/System.Windows.Forms/ChangeLog
index d58ef285596..3ff7c216edc 100644
--- a/mcs/class/System.Windows.Forms/System.Windows.Forms/ChangeLog
+++ b/mcs/class/System.Windows.Forms/System.Windows.Forms/ChangeLog
@@ -1,3 +1,14 @@
+2003-11-26 Jackson Harper <jackson@ximian.com>
+
+ * TabDrawMode.cs: OwnerDrawFixed (fix typo).
+
+2003-11-12 Jordi Mas i Hernàndez <jmas@softcatala.org>
+ * FolderBrowserDialog.cs, win32Enums.cs, win32Interfaces.cs, win32Structs.cs, win32functions.cs
+ FolderBrowserDialog implementation.
+
+2003-11-11 Ben Maurer <bmaurer@users.sourceforge.net>
+ * LinkLabel.cs, InputLanguageChangedEventArgs.cs: recursion!
+
2003-10-27 Jordi Mas i Hernàndez <jmas@softcatala.org>
* ListListView.cs, ListViewItem.cs, win32Enums.cs
More work on the ListView implementation (bug fixing, new methods and properties)
diff --git a/mcs/class/System.Windows.Forms/System.Windows.Forms/CheckBox.cs b/mcs/class/System.Windows.Forms/System.Windows.Forms/CheckBox.cs
index b7fe032f939..4826cc9ffa7 100644
--- a/mcs/class/System.Windows.Forms/System.Windows.Forms/CheckBox.cs
+++ b/mcs/class/System.Windows.Forms/System.Windows.Forms/CheckBox.cs
@@ -20,24 +20,53 @@ namespace System.Windows.Forms {
public class CheckBox : ButtonBase {
// private fields
- Appearance appearance;
- bool autoCheck;
- ContentAlignment checkAlign;
- bool _checked;
- CheckState checkState;
- bool threeState;
- ContentAlignment textAlign;
+ Appearance appearance;
+ bool autoCheck;
+ ContentAlignment checkAlign;
+ bool _checked;
+ CheckState checkState;
+ bool threeState;
+ ContentAlignment textAlign;
+ Rectangle textRect;
+ Rectangle checkRect;
+ StringFormat textFormat;
+ int checkMarkSize=13; // Keep it configurable for accessability
+ Graphics canvasDC;
+ Bitmap canvasBmp;
// --- Constructor ---
public CheckBox() : base()
{
+
appearance = Appearance.Normal;
autoCheck = true;
checkAlign = ContentAlignment.MiddleLeft;
_checked = false;
checkState = CheckState.Unchecked;
threeState = false;
- textAlign = ContentAlignment.MiddleCenter;
+
+ canvasBmp = new Bitmap(ClientRectangle.Width, ClientRectangle.Height);
+ canvasDC = Graphics.FromImage(canvasBmp);
+
+ /* Set defaults for drawing text... */
+ textAlign = ContentAlignment.MiddleLeft;
+ textFormat = new StringFormat();
+ textFormat.Alignment=StringAlignment.Near;
+ textFormat.LineAlignment=StringAlignment.Center;
+ textRect = ClientRectangle;
+ textRect.X+=checkMarkSize;
+ textRect.Width-=checkMarkSize;
+
+ /* ... and for drawing our checkbox */
+ checkRect.X=ClientRectangle.Left;
+ checkRect.Y=(ClientRectangle.Bottom-ClientRectangle.Top)/2-checkMarkSize/2;
+ checkRect.Width=checkMarkSize;
+ checkRect.Height=checkMarkSize;
+
+ SizeChanged+=new System.EventHandler(CheckboxSizeChanged);
+ GotFocus+=new System.EventHandler(CheckboxUpdate);
+ LostFocus+=new System.EventHandler(CheckboxUpdate);
+ TextChanged+=new System.EventHandler(CheckboxUpdate);
SubClassWndProc_ = true;
SetStyle (ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint, true);
@@ -57,7 +86,10 @@ namespace System.Windows.Forms {
public ContentAlignment CheckAlign {
get { return checkAlign; }
- set { checkAlign=value; }
+ set {
+ checkAlign=value;
+ UpdateCheckbox();
+ }
}
public bool Checked {
@@ -104,13 +136,18 @@ namespace System.Windows.Forms {
(int)WindowStyles.WS_CHILD |
(int)WindowStyles.WS_VISIBLE |
(int)ButtonStyles.BS_CHECKBOX |
+ (int)ButtonStyles.BS_NOTIFY |
(int)WindowStyles.WS_CLIPSIBLINGS |
+ (int)WindowStyles.WS_CLIPCHILDREN |
+ (int)WindowStyles.WS_TABSTOP |
(int)SS_Static_Control_Types.SS_LEFT );
- if( autoCheck) {
+ if (autoCheck) {
createParams.Style |= (int)ButtonStyles.BS_AUTOCHECKBOX;
}
- //createParams.Style |= (int) ButtonStyles.BS_OWNERDRAW;
+
+ /* We need this, we draw ourselves */
+ createParams.Style |= (int) ButtonStyles.BS_OWNERDRAW;
return createParams;
}
@@ -118,7 +155,7 @@ namespace System.Windows.Forms {
[MonoTODO]
protected override Size DefaultSize {
- get { return new Size(100,20); }
+ get { return new Size(100,checkMarkSize); }
}
[MonoTODO]
@@ -128,12 +165,18 @@ namespace System.Windows.Forms {
}
set {
textAlign = value;
+ UpdateCheckbox();
}
}
public bool ThreeState {
- get { return threeState; }
- set { threeState = value; }
+ get {
+ return threeState;
+ }
+
+ set {
+ threeState = value;
+ }
}
// --- CheckBox methods ---
@@ -148,7 +191,9 @@ namespace System.Windows.Forms {
[MonoTODO]
protected virtual void OnAppearanceChanged(EventArgs e)
{
- //FIXME:
+ if (AppearanceChanged != null) {
+ AppearanceChanged(this, e);
+ }
}
[MonoTODO]
@@ -194,21 +239,26 @@ namespace System.Windows.Forms {
{
if (ThreeState) {
switch (CheckState) {
- case CheckState.Unchecked:
+ case CheckState.Unchecked: {
CheckState = CheckState.Checked;
- break;
- case CheckState.Indeterminate:
+ break;
+ }
+
+ case CheckState.Indeterminate: {
CheckState = CheckState.Unchecked;
- break;
- case CheckState.Checked:
+ break;
+ }
+
+ case CheckState.Checked: {
CheckState = CheckState.Indeterminate;
- break;
+ break;
+ }
}
- }
- else {
+ } else {
Checked = Checked ? false : true;
}
- Invalidate ();
+ CheckboxRedraw();
+ Invalidate();
base.OnMouseUp(mevent);
}
// end of [event methods]
@@ -225,29 +275,194 @@ namespace System.Windows.Forms {
//FIXME: do a better tostring
public override string ToString()
{
- if(Checked){
+ if (Checked) {
return "CheckBox" + " Checked";
- }
- else{
+ } else {
return "CheckBox" + " Unchecked";
}
}
internal override void ButtonPaint (PaintEventArgs e)
{
- Rectangle paintBounds = ClientRectangle;
- Bitmap bmp = new Bitmap( paintBounds.Width, paintBounds.Height,e.Graphics);
- Graphics paintOn = Graphics.FromImage(bmp);
-
- SolidBrush sb = new SolidBrush (BackColor);
- paintOn.FillRectangle (sb, paintBounds);
- sb.Dispose ();
-
- // FIXME: Width/Heigth of checkmark are not correct
- Rectangle checkRect = new Rectangle(paintBounds.Left,paintBounds.Top,12,12);
- Rectangle textRect = new Rectangle( checkRect.Right,paintBounds.Top,paintBounds.Width - checkRect.Width - 1,paintBounds.Height);
- paintOn.DrawString(Text, Font, SystemBrushes.ControlText, textRect.X, textRect.Y);
-
+ if (canvasBmp!=null) {
+ e.Graphics.DrawImage(canvasBmp, e.ClipRectangle, e.ClipRectangle, GraphicsUnit.Pixel);
+ }
+ }
+
+ /// --- CheckBox events ---
+ public event EventHandler AppearanceChanged;
+ public event EventHandler CheckedChanged;
+ public event EventHandler CheckStateChanged;
+
+ /// --- public class CheckBox.CheckBoxAccessibleObject : AccessibleObject ---
+ /// the class is only used for .NET framework
+ ///
+ public class CheckBoxAccessibleObject : AccessibleObject {
+ }
+
+ private void UpdateCheckbox() {
+ /* Calculate the position of text and checkbox rectangle */
+ if (appearance!=Appearance.Button) {
+ switch(checkAlign) {
+ case ContentAlignment.BottomCenter: {
+ if (ClientRectangle.Height<checkMarkSize*2) {
+ ClientSize=new Size(ClientRectangle.Width, checkMarkSize*2);
+ }
+ checkRect.X=(ClientRectangle.Right-ClientRectangle.Left)/2-checkMarkSize/2;
+ checkRect.Y=ClientRectangle.Bottom-checkMarkSize;
+ textRect.X=ClientRectangle.X;
+ textRect.Width=ClientRectangle.Width;
+ break;
+ }
+
+ case ContentAlignment.BottomLeft: {
+ checkRect.X=ClientRectangle.Left;
+ checkRect.Y=ClientRectangle.Bottom-checkMarkSize;
+ textRect.X=ClientRectangle.X+checkMarkSize;
+ textRect.Width=ClientRectangle.Width-checkMarkSize;
+ break;
+ }
+
+ case ContentAlignment.BottomRight: {
+ checkRect.X=ClientRectangle.Right-checkMarkSize;
+ checkRect.Y=ClientRectangle.Bottom-checkMarkSize;
+ textRect.X=ClientRectangle.X;
+ textRect.Width=ClientRectangle.Width-checkMarkSize;
+ break;
+ }
+
+ case ContentAlignment.MiddleCenter: {
+ checkRect.X=(ClientRectangle.Right-ClientRectangle.Left)/2-checkMarkSize/2;
+ checkRect.Y=(ClientRectangle.Bottom-ClientRectangle.Top)/2-checkMarkSize/2;
+ textRect.X=ClientRectangle.X;
+ textRect.Width=ClientRectangle.Width;
+ break;
+ }
+
+ default:
+ case ContentAlignment.MiddleLeft: {
+ checkRect.X=ClientRectangle.Left;
+ checkRect.Y=(ClientRectangle.Bottom-ClientRectangle.Top)/2-checkMarkSize/2;
+ textRect.X=ClientRectangle.X+checkMarkSize;
+ textRect.Width=ClientRectangle.Width-checkMarkSize;
+ break;
+ }
+
+ case ContentAlignment.MiddleRight: {
+ checkRect.X=ClientRectangle.Right-checkMarkSize;
+ checkRect.Y=(ClientRectangle.Bottom-ClientRectangle.Top)/2-checkMarkSize/2;
+ textRect.X=ClientRectangle.X;
+ textRect.Width=ClientRectangle.Width-checkMarkSize;
+ break;
+ }
+
+ case ContentAlignment.TopCenter: {
+ if (ClientRectangle.Height<checkMarkSize*2) {
+ ClientSize=new Size(ClientRectangle.Width, checkMarkSize*2);
+ }
+ checkRect.X=(ClientRectangle.Right-ClientRectangle.Left)/2-checkMarkSize/2;
+ checkRect.Y=ClientRectangle.Top;
+ textRect.X=ClientRectangle.X;
+ textRect.Y=checkMarkSize;
+ textRect.Width=ClientRectangle.Width;
+ textRect.Height=ClientRectangle.Height-checkMarkSize;
+ break;
+ }
+
+ case ContentAlignment.TopLeft: {
+ checkRect.X=ClientRectangle.Left;
+ checkRect.Y=ClientRectangle.Top;
+ textRect.X=ClientRectangle.X+checkMarkSize;
+ textRect.Width=ClientRectangle.Width-checkMarkSize;
+ break;
+ }
+
+ case ContentAlignment.TopRight: {
+ checkRect.X=ClientRectangle.Right-checkMarkSize;
+ checkRect.Y=ClientRectangle.Top;
+ textRect.X=ClientRectangle.X;
+ textRect.Width=ClientRectangle.Width-checkMarkSize;
+ break;
+ }
+ }
+ } else {
+ textRect.X=ClientRectangle.X;
+ textRect.Width=ClientRectangle.Width;
+ }
+
+ /* Set the horizontal alignment of our text */
+ switch(textAlign) {
+ case ContentAlignment.BottomLeft:
+ case ContentAlignment.MiddleLeft:
+ case ContentAlignment.TopLeft: {
+ textFormat.Alignment=StringAlignment.Near;
+ break;
+ }
+
+ case ContentAlignment.BottomCenter:
+ case ContentAlignment.MiddleCenter:
+ case ContentAlignment.TopCenter: {
+ textFormat.Alignment=StringAlignment.Center;
+ break;
+ }
+
+ case ContentAlignment.BottomRight:
+ case ContentAlignment.MiddleRight:
+ case ContentAlignment.TopRight: {
+ textFormat.Alignment=StringAlignment.Far;
+ break;
+ }
+ }
+
+ /* Set the vertical alignment of our text */
+ switch(textAlign) {
+ case ContentAlignment.TopLeft:
+ case ContentAlignment.TopCenter:
+ case ContentAlignment.TopRight: {
+ textFormat.LineAlignment=StringAlignment.Near;
+ break;
+ }
+
+ case ContentAlignment.BottomLeft:
+ case ContentAlignment.BottomCenter:
+ case ContentAlignment.BottomRight: {
+ textFormat.LineAlignment=StringAlignment.Far;
+ break;
+ }
+
+ case ContentAlignment.MiddleLeft:
+ case ContentAlignment.MiddleCenter:
+ case ContentAlignment.MiddleRight: {
+ textFormat.LineAlignment=StringAlignment.Center;
+ break;
+ }
+ }
+ CheckboxRedraw();
+ Invalidate();
+ }
+
+ private void CheckboxRedraw() {
+ SolidBrush sb;
+
+ /* Build the image representing the control */
+
+ if (canvasDC!=null) {
+ canvasDC.Dispose();
+ }
+ if (canvasBmp!=null) {
+ canvasBmp.Dispose();
+ }
+
+ if (ClientRectangle.Width<1 || ClientRectangle.Height<1) {
+ return;
+ }
+ canvasBmp = new Bitmap(ClientRectangle.Width, ClientRectangle.Height);
+ canvasDC = Graphics.FromImage(canvasBmp);
+
+ sb=new SolidBrush(BackColor);
+ canvasDC.FillRectangle(sb, ClientRectangle);
+ sb.Dispose();
+
ButtonState state = ButtonState.Normal;
if (FlatStyle == FlatStyle.Flat) {
state |= ButtonState.Flat;
@@ -257,29 +472,39 @@ namespace System.Windows.Forms {
state |= ButtonState.Checked;
}
- if (ThreeState && CheckState == CheckState.Indeterminate) {
- state |= ButtonState.Pushed;
+ if (ThreeState && (CheckState == CheckState.Indeterminate)) {
+ state |= ButtonState.ThreeState;
}
- ControlPaint.DrawCheckBox (paintOn, checkRect, state);
-
+
+ if (appearance!=Appearance.Button) {
+ ControlPaint.DrawCheckBox(canvasDC, checkRect, state);
+ } else {
+ ControlPaint.DrawButton(canvasDC, textRect, state);
+ }
+
+ /* Place the text; to be compatible with Windows place it after the checkbox has been drawn */
+ sb=new SolidBrush(base.foreColor);
+ canvasDC.DrawString(Text, Font, sb, textRect, textFormat);
+ sb.Dispose();
+
if (Focused) {
- ControlPaint.DrawFocusRectangle (paintOn, textRect);
+ ControlPaint.DrawFocusRectangle(canvasDC, textRect);
}
-
- e.Graphics.DrawImage(bmp, 0, 0, paintBounds.Width, paintBounds.Height);
- paintOn.Dispose ();
- bmp.Dispose();
}
-
- /// --- CheckBox events ---
- public event EventHandler AppearanceChanged;
- public event EventHandler CheckedChanged;
- public event EventHandler CheckStateChanged;
-
- /// --- public class CheckBox.CheckBoxAccessibleObject : AccessibleObject ---
- /// the class is only used for .NET framework
- ///
- public class CheckBoxAccessibleObject : AccessibleObject {
+
+ private void CheckboxUpdate(object sender, System.EventArgs e) {
+ /* Force recalculation of text & checkbox rectangles */
+ UpdateCheckbox();
+ }
+
+ private void CheckboxSizeChanged(object sender, System.EventArgs e)
+ {
+ /* Force recalculation of text & checkbox rectangles */
+ textRect.Y=ClientRectangle.Y;
+ textRect.Height=ClientRectangle.Height;
+ UpdateCheckbox();
}
}
+
+
}
diff --git a/mcs/class/System.Windows.Forms/System.Windows.Forms/Control.cs b/mcs/class/System.Windows.Forms/System.Windows.Forms/Control.cs
index 14e9feb1c95..bbbda7067b9 100644
--- a/mcs/class/System.Windows.Forms/System.Windows.Forms/Control.cs
+++ b/mcs/class/System.Windows.Forms/System.Windows.Forms/Control.cs
@@ -349,7 +349,7 @@ namespace System.Windows.Forms {
get {
return allowDrop;
}
- set {
+ set {
allowDrop=value;
}
}
@@ -2962,8 +2962,8 @@ namespace System.Windows.Forms {
case Msg.WM_RBUTTONDOWN:
if (contextMenu != null){
contextMenu.Show (this,
- new Point (Win32.HIGH_ORDER (m.LParam.ToInt32 ()),
- Win32.LOW_ORDER (m.LParam.ToInt32 ())));
+ new Point (Win32.LOW_ORDER (m.LParam.ToInt32 ()),
+ Win32.HIGH_ORDER (m.LParam.ToInt32 ())));
}
OnMouseDown ( Msg2MouseEventArgs( ref m ) );
CallControlWndProc (ref m);
diff --git a/mcs/class/System.Windows.Forms/System.Windows.Forms/ControlPaint.cs b/mcs/class/System.Windows.Forms/System.Windows.Forms/ControlPaint.cs
index 622b08d90c0..58fcc7475f2 100644
--- a/mcs/class/System.Windows.Forms/System.Windows.Forms/ControlPaint.cs
+++ b/mcs/class/System.Windows.Forms/System.Windows.Forms/ControlPaint.cs
@@ -5,12 +5,19 @@
// stubbed out by Jaak Simm (jaaksimm@firm.ee)
// Dennis Hayes (dennish@Raytek.com)
// Alexandre Pigolkine (pigolkine@gmx.de)
+//
+// rewritten for System.Drawing
+// by Peter Dennis Bartok (pbartok@novell.com)
//
-// (C) Ximian, Inc 2002
+//
+// (C) Ximian, Inc 2002/3
+// (C) Novell, Inc 2003
//
using System.Drawing;
+using System.Drawing.Drawing2D;
+using System.Drawing.Imaging;
namespace System.Windows.Forms {
@@ -18,592 +25,1392 @@ namespace System.Windows.Forms {
/// Provides methods used to paint common Windows controls and their elements.
/// </summary>
- [MonoTODO]
public sealed class ControlPaint {
+ static int RGBMax=255;
+ static int HLSMax=255;
- private ControlPaint(){//For signiture compatablity. Prevents the auto creation of public constructor
+ private static Color Win32ToColor(int Win32Color) {
+ return(Color.FromArgb(
+ (int)(Win32Color) & 0xff0000 >> 16, // blue
+ (int)(Win32Color) & 0xff00 >> 8, // green
+ (int)(Win32Color) & 0xff // red
+ ));
}
#region Properties
- [MonoTODO]
public static Color ContrastControlDark {
-
- get { throw new NotImplementedException (); }
+ get { return(SystemColors.ControlDark); }
}
#endregion
#region Helpers
- /*
- internal static HISColorCheck() {
- Color[] cArr = new Color[] { SystemColors.ControlText, SystemColors.Control, SystemColors.GrayText};
- foreach( Color c in cArr) {
- double H1 = c.GetHue();
- double I1 = c.GetBrightness();
- double S1 = c.GetSaturation();
- double H2, I2, S2;
- ControlPaint.Color2HIS(c, out H2, out I2, out S2);
-
- Color c2 = ControlPaint.HIS2Color( H2, I2, S2);
- }
- }
- */
- internal static void Color2HIS(Color col, out double Hue, out double Intensity, out double Saturation) {
- Hue = 0.0;
- Saturation = 0.0;
-
- double red = (double)col.R / 255.0;
- double green = (double)col.G / 255.0;
- double blue = (double)col.B / 255.0;
-
- Intensity = Math.Max(red, green);
- Intensity = Math.Max(Intensity, blue);
-
- if( Intensity != 0.0) {
- double IntensityDiff = Intensity - Math.Min( Math.Min( red, green), blue);
- if( IntensityDiff != 0.0) {
- Saturation = IntensityDiff / Intensity;
- if( Intensity == red) {
- double b = ( Intensity - blue) / IntensityDiff;
- double g = ( Intensity - green) / IntensityDiff;
- Hue = 10.0 * ( b - g);
- }
- else if( Intensity == green) {
- double r = ( Intensity - red) / IntensityDiff;
- double b = ( Intensity - blue) / IntensityDiff;
- Hue = 10.0 * ( 2 + r - b);
- }
- else {
- double g = ( Intensity - green) / IntensityDiff;
- double r = ( Intensity - red) / IntensityDiff;
- Hue = 10.0 * ( 4 + g - r);
- }
- Hue = Hue * 60.0;
- Hue = Math.Round(Hue);
- }
- }
- }
-
- internal static Color HIS2Color(double Hue, double Intensity, double Saturation) {
- double R = Intensity, G = Intensity, B = Intensity;
- if( Saturation != 0) {
- double Hue1 = (Hue * 60.0) / 360.0;
- double X = Hue1 / 10.0;
- double h = Math.Floor(X);
- double P = Intensity * ( 1 - Saturation);
- double Q = Intensity * ( Saturation - ( X - h));
- double T = Intensity * ( 1 - Saturation * ( 1 - X + h));
- switch( (int)Math.Round(h)) {
- case 0:
- R = Intensity;
- G = T;
- B = P;
- break;
- case 1:
- R = Q;
- G = Intensity;
- B = P;
- break;
- case 2:
- R = P;
- G = Intensity;
- B = T;
- break;
- case 3:
- R = P;
- G = Q;
- B = Intensity;
- break;
- case 4:
- R = T;
- G = P;
- B = Intensity;
- break;
- case 5:
- R = Intensity;
- G = P;
- B = Q;
- break;
- }
+ internal static void Color2HBS(Color color, out int h, out int l, out int s) {
+ int r;
+ int g;
+ int b;
+ int cMax;
+ int cMin;
+ int rDelta;
+ int gDelta;
+ int bDelta;
+
+ r=color.R;
+ g=color.G;
+ b=color.B;
+
+ cMax = Math.Max(Math.Max(r, g), b);
+ cMin = Math.Min(Math.Min(r, g), b);
+
+ l = (((cMax+cMin)*HLSMax)+RGBMax)/(2*RGBMax);
+
+ if (cMax==cMin) { // Achromatic
+ h=0; // h undefined
+ s=0;
+ l=r;
+ return;
+ }
+
+ /* saturation */
+ if (l<=(HLSMax/2)) {
+ s=(((cMax-cMin)*HLSMax)+((cMax+cMin)/2))/(cMax+cMin);
+ } else {
+ s=(((cMax-cMin)*HLSMax)+((2*RGBMax-cMax-cMin)/2))/(2*RGBMax-cMax-cMin);
+ }
+
+ /* hue */
+ rDelta=(((cMax-r)*(HLSMax/6))+((cMax-cMin)/2))/(cMax-cMin);
+ gDelta=(((cMax-g)*(HLSMax/6))+((cMax-cMin)/2))/(cMax-cMin);
+ bDelta=(((cMax-b)*(HLSMax/6))+((cMax-cMin)/2))/(cMax-cMin);
+
+ if (r == cMax) {
+ h=bDelta - gDelta;
+ } else if (g == cMax) {
+ h=(HLSMax/3) + rDelta - bDelta;
+ } else { /* B == cMax */
+ h=((2*HLSMax)/3) + gDelta - rDelta;
+ }
+
+ if (h<0) {
+ h+=HLSMax;
+ }
+
+ if (h>HLSMax) {
+ h-=HLSMax;
}
- int red = (int)(R * 255.0);
- int gree = (int)(G * 255.0);
- int blue = (int)(B * 255.0);
- return Color.FromArgb(red, gree, blue);
}
+ private static int HueToRGB(int n1, int n2, int hue) {
+ if (hue<0) {
+ hue+=HLSMax;
+ }
+
+ if (hue>HLSMax) {
+ hue -= HLSMax;
+ }
+
+ /* return r,g, or b value from this tridrant */
+ if (hue<(HLSMax/6)) {
+ return(n1+(((n2-n1)*hue+(HLSMax/12))/(HLSMax/6)));
+ }
+
+ if (hue<(HLSMax/2)) {
+ return(n2);
+ }
+
+ if (hue<((HLSMax*2)/3)) {
+ return(n1+(((n2-n1)*(((HLSMax*2)/3)-hue)+(HLSMax/12))/(HLSMax/6)));
+ } else {
+ return(n1);
+ }
+ }
+
+ private static Color HBS2Color(int hue, int lum, int sat) {
+ int R;
+ int G;
+ int B;
+ int Magic1;
+ int Magic2;
+
+ if (sat == 0) { /* Achromatic */
+ R=G=B=(lum*RGBMax)/HLSMax;
+ // FIXME : Should throw exception if hue!=0
+ } else {
+ if (lum<=(HLSMax/2)) {
+ Magic2=(lum*(HLSMax+sat)+(HLSMax/2))/HLSMax;
+ } else {
+ Magic2=sat+lum-((sat*lum)+(HLSMax/2))/HLSMax;
+ }
+ Magic1=2*lum-Magic2;
+
+ R = Math.Min(255, (HueToRGB(Magic1,Magic2,hue+(HLSMax/3))*RGBMax+(HLSMax/2))/HLSMax);
+ G = Math.Min(255, (HueToRGB(Magic1,Magic2,hue)*RGBMax+(HLSMax/2))/HLSMax);
+ B = Math.Min(255, (HueToRGB(Magic1,Magic2,hue-(HLSMax/3))*RGBMax+(HLSMax/2))/HLSMax);
+ }
+ return(Color.FromArgb(R, G, B));
+ }
#endregion
#region Methods
/// following methods were not stubbed out, because they only support .NET framework:
- [MonoTODO]
public static IntPtr CreateHBitmap16Bit(Bitmap bitmap,Color background){
throw new NotImplementedException ();
}
- [MonoTODO]
public static IntPtr CreateHBitmapColorMask(Bitmap bitmap,IntPtr monochromeMask){
throw new NotImplementedException ();
}
- [MonoTODO]
public static IntPtr CreateHBitmapTransparencyMask(Bitmap bitmap){
throw new NotImplementedException ();
}
- [MonoTODO]
+ public static Color Light(Color baseColor) {
+ return Light( baseColor, 10.0f);
+ }
+
+ public static Color Light(Color baseColor,float percOfLightLight) {
+ int H, I, S;
+
+ ControlPaint.Color2HBS(baseColor, out H, out I, out S);
+ int NewIntensity = Math.Min( 255, I + ((255*(int)percOfLightLight)/100));
+ return ControlPaint.HBS2Color(H, NewIntensity, S);
+ }
+
+ public static Color LightLight(Color baseColor) {
+ return Light( baseColor, 20.0f);
+ }
+
public static Color Dark(Color baseColor) {
return Dark(baseColor, 10.0f);
}
- [MonoTODO]
public static Color Dark(Color baseColor,float percOfDarkDark) {
- double H, I, S;
- ControlPaint.Color2HIS(baseColor, out H, out I, out S);
- double NewIntensity = Math.Max( 0.0, I - (percOfDarkDark / 100.0));
- return ControlPaint.HIS2Color(H, NewIntensity, S);
+ int H, I, S;
+ ControlPaint.Color2HBS(baseColor, out H, out I, out S);
+ int NewIntensity = Math.Max(0, I - ((255*(int)percOfDarkDark) / 100));
+ return ControlPaint.HBS2Color(H, NewIntensity, S);
}
- [MonoTODO]
public static Color DarkDark(Color baseColor) {
return Dark(baseColor, 20.0f);
}
- [MonoTODO]
public static void DrawBorder(Graphics graphics, Rectangle bounds, Color color, ButtonBorderStyle style) {
DrawBorder(graphics, bounds, color, 1, style, color, 1, style, color, 1, style, color, 1, style);
}
- [MonoTODO]
public static void DrawBorder( Graphics graphics, Rectangle bounds, Color leftColor, int leftWidth,
ButtonBorderStyle leftStyle, Color topColor, int topWidth, ButtonBorderStyle topStyle,
Color rightColor, int rightWidth, ButtonBorderStyle rightStyle, Color bottomColor, int bottomWidth,
ButtonBorderStyle bottomStyle) {
- IntPtr hdc = graphics.GetHdc();
-
- RECT rc = new RECT();
-
- // Top side
- Win32.SetBkColor(hdc, (uint)Win32.RGB(topColor));
- rc.left = bounds.Left;
- rc.top = bounds.Top;
- rc.right = bounds.Right - rightWidth;
- rc.bottom = bounds.Top + topWidth;
- Win32.ExtTextOut(hdc, 0, 0, ExtTextOutFlags.ETO_OPAQUE, ref rc, 0, 0, IntPtr.Zero);
- // Left side
- Win32.SetBkColor(hdc, (uint)Win32.RGB(leftColor));
- rc.right = bounds.Left + leftWidth;
- rc.bottom = bounds.Bottom - bottomWidth;
- Win32.ExtTextOut(hdc, 0, 0, ExtTextOutFlags.ETO_OPAQUE, ref rc, 0, 0, IntPtr.Zero);
- // Right side
- Win32.SetBkColor(hdc, (uint)Win32.RGB(rightColor));
- rc.left = bounds.Right - rightWidth;
- rc.right = bounds.Right;
- Win32.ExtTextOut(hdc, 0, 0, ExtTextOutFlags.ETO_OPAQUE, ref rc, 0, 0, IntPtr.Zero);
- // Bottom side
- Win32.SetBkColor(hdc, (uint)Win32.RGB(bottomColor));
- rc.left = bounds.Left;
- rc.top = bounds.Bottom - bottomWidth;
- rc.bottom = bounds.Bottom;
- Win32.ExtTextOut(hdc, 0, 0, ExtTextOutFlags.ETO_OPAQUE, ref rc, 0, 0, IntPtr.Zero);
-
- graphics.ReleaseHdc(hdc);
+ DrawBorderInternal(graphics, bounds.Left, bounds.Top, bounds.Left, bounds.Bottom-1, leftWidth, leftColor, leftStyle, Border3DSide.Left);
+ DrawBorderInternal(graphics, bounds.Left, bounds.Top, bounds.Right-1, bounds.Top, topWidth, topColor, topStyle, Border3DSide.Top);
+ DrawBorderInternal(graphics, bounds.Right-1, bounds.Top, bounds.Right-1, bounds.Bottom-1, rightWidth, rightColor, rightStyle, Border3DSide.Right);
+ DrawBorderInternal(graphics, bounds.Left, bounds.Bottom-1, bounds.Right-1, bounds.Bottom-1, bottomWidth, bottomColor, bottomStyle, Border3DSide.Bottom);
+ }
+
+ private static void DrawBorderInternal(Graphics graphics, int startX, int startY, int endX, int endY,
+ int width, Color color, ButtonBorderStyle style, Border3DSide side) {
+
+ Pen pen=new Pen(color, 1);
+
+ switch(style) {
+ case ButtonBorderStyle.Solid: {
+ pen.DashStyle=DashStyle.Solid;
+ break;
+ }
+
+ case ButtonBorderStyle.Dashed: {
+ pen.DashStyle=DashStyle.Dash;
+ break;
+ }
+
+ case ButtonBorderStyle.Dotted: {
+ pen.DashStyle=DashStyle.Dot;
+ break;
+ }
+
+ case ButtonBorderStyle.Inset: {
+ pen.DashStyle=DashStyle.Solid;
+ break;
+ }
+
+ case ButtonBorderStyle.Outset: {
+ pen.DashStyle=DashStyle.Solid;
+ break;
+ }
+
+ default:
+ case ButtonBorderStyle.None: {
+ pen.Dispose();
+ return;
+ }
+ }
+
+
+ switch(style) {
+ case ButtonBorderStyle.Outset: {
+ Color colorGrade;
+ int hue, brightness, saturation;
+ int brightnessSteps;
+ int brightnessDownSteps;
+
+ Color2HBS(color, out hue, out brightness, out saturation);
+
+ brightnessDownSteps=brightness/width;
+ if (brightness>127) {
+ brightnessSteps=Math.Max(6, (160-brightness)/width);
+ } else {
+ brightnessSteps=(127-brightness)/width;
+ }
+
+ for (int i=0; i<width; i++) {
+ switch(side) {
+ case Border3DSide.Left: {
+ pen.Dispose();
+ colorGrade=HBS2Color(hue, Math.Min(255, brightness+brightnessSteps*(width-i)), saturation);
+ pen=new Pen(colorGrade, 1);
+ graphics.DrawLine(pen, startX+i, startY+i, endX+i, endY-i);
+ break;
+ }
+
+ case Border3DSide.Right: {
+ pen.Dispose();
+ colorGrade=HBS2Color(hue, Math.Max(0, brightness-brightnessDownSteps*(width-i)), saturation);
+ pen=new Pen(colorGrade, 1);
+ graphics.DrawLine(pen, startX-i, startY+i, endX-i, endY-i);
+ break;
+ }
+
+ case Border3DSide.Top: {
+ pen.Dispose();
+ colorGrade=HBS2Color(hue, Math.Min(255, brightness+brightnessSteps*(width-i)), saturation);
+ pen=new Pen(colorGrade, 1);
+ graphics.DrawLine(pen, startX+i, startY+i, endX-i, endY+i);
+ break;
+ }
+
+ case Border3DSide.Bottom: {
+ pen.Dispose();
+ colorGrade=HBS2Color(hue, Math.Max(0, brightness-brightnessDownSteps*(width-i)), saturation);
+ pen=new Pen(colorGrade, 1);
+ graphics.DrawLine(pen, startX+i, startY-i, endX-i, endY-i);
+ break;
+ }
+ }
+ }
+ break;
+ }
+
+ case ButtonBorderStyle.Inset: {
+ Color colorGrade;
+ int hue, brightness, saturation;
+ int brightnessSteps;
+ int brightnessDownSteps;
+
+ Color2HBS(color, out hue, out brightness, out saturation);
+
+ brightnessDownSteps=brightness/width;
+ if (brightness>127) {
+ brightnessSteps=Math.Max(6, (160-brightness)/width);
+ } else {
+ brightnessSteps=(127-brightness)/width;
+ }
+
+ for (int i=0; i<width; i++) {
+ switch(side) {
+ case Border3DSide.Left: {
+ pen.Dispose();
+ colorGrade=HBS2Color(hue, Math.Max(0, brightness-brightnessDownSteps*(width-i)), saturation);
+ pen=new Pen(colorGrade, 1);
+ graphics.DrawLine(pen, startX+i, startY+i, endX+i, endY-i);
+ break;
+ }
+
+ case Border3DSide.Right: {
+ pen.Dispose();
+ colorGrade=HBS2Color(hue, Math.Min(255, brightness+brightnessSteps*(width-i)), saturation);
+ pen=new Pen(colorGrade, 1);
+ graphics.DrawLine(pen, startX-i, startY+i, endX-i, endY-i);
+ break;
+ }
+
+ case Border3DSide.Top: {
+ pen.Dispose();
+ colorGrade=HBS2Color(hue, Math.Max(0, brightness-brightnessDownSteps*(width-i)), saturation);
+ pen=new Pen(colorGrade, 1);
+ graphics.DrawLine(pen, startX+i, startY+i, endX-i, endY+i);
+ break;
+ }
+
+ case Border3DSide.Bottom: {
+ pen.Dispose();
+ colorGrade=HBS2Color(hue, Math.Min(255, brightness+brightnessSteps*(width-i)), saturation);
+ pen=new Pen(colorGrade, 1);
+ graphics.DrawLine(pen, startX+i, startY-i, endX-i, endY-i);
+ break;
+ }
+ }
+ }
+ break;
+ }
+
+ /*
+ I decided to have the for-loop duplicated for speed reasons;
+ that way we only have to switch once (as opposed to have the
+ for-loop around the switch)
+ */
+ default: {
+ switch(side) {
+ case Border3DSide.Left: {
+ for (int i=0; i<width; i++) {
+ graphics.DrawLine(pen, startX+i, startY+i, endX+i, endY-i);
+ }
+ break;
+ }
+
+ case Border3DSide.Right: {
+ for (int i=0; i<width; i++) {
+ graphics.DrawLine(pen, startX-i, startY+i, endX-i, endY-i);
+ }
+ break;
+ }
+
+ case Border3DSide.Top: {
+ for (int i=0; i<width; i++) {
+ graphics.DrawLine(pen, startX+i, startY+i, endX-i, endY+i);
+ }
+ break;
+ }
+
+ case Border3DSide.Bottom: {
+ for (int i=0; i<width; i++) {
+ graphics.DrawLine(pen, startX+i, startY-i, endX-i, endY-i);
+ }
+ break;
+ }
+ }
+ break;
+ }
+ }
+ pen.Dispose();
}
- [MonoTODO]
public static void DrawBorder3D(Graphics graphics, Rectangle rectangle) {
DrawBorder3D(graphics, rectangle, Border3DStyle.Etched, Border3DSide.All);
}
- [MonoTODO]
public static void DrawBorder3D(Graphics graphics, Rectangle rectangle, Border3DStyle style) {
DrawBorder3D(graphics, rectangle, style, Border3DSide.All);
}
- [MonoTODO]
- public static void DrawBorder3D( Graphics graphics, Rectangle rectangle, Border3DStyle style, Border3DSide sides) {
- RECT rc = new RECT();
- rc.left = rectangle.Left;
- rc.top = rectangle.Top;
- rc.right = rectangle.Right;
- rc.bottom = rectangle.Bottom;
- IntPtr hdc = graphics.GetHdc();
- int res = Win32.DrawEdge( hdc, ref rc, style, sides);
- graphics.ReleaseHdc(hdc);
+ public static void DrawBorder3D(Graphics graphics, int x, int y, int width, int height) {
+ DrawBorder3D(graphics, new Rectangle(x, y, width, height), Border3DStyle.Etched, Border3DSide.All);
}
- [MonoTODO]
- public static void DrawBorder3D( Graphics graphics, int x, int y, int width, int height) {
- DrawBorder3D( graphics, new Rectangle(x, y, width, height));
- }
-
- [MonoTODO]
public static void DrawBorder3D(Graphics graphics, int x, int y, int width, int height, Border3DStyle style) {
- DrawBorder3D( graphics, new Rectangle(x, y, width, height), style);
+ DrawBorder3D(graphics, new Rectangle(x, y, width, height), style, Border3DSide.All);
}
- [MonoTODO]
- public static void DrawBorder3D( Graphics graphics, int x, int y, int width, int height,
- Border3DStyle style,Border3DSide sides) {
+ public static void DrawBorder3D( Graphics graphics, int x, int y, int width, int height, Border3DStyle style,Border3DSide sides) {
DrawBorder3D( graphics, new Rectangle(x, y, width, height), style, sides);
}
- [MonoTODO]
- public static void DrawButton( Graphics graphics, Rectangle rectangle, ButtonState state) {
- RECT rc = new RECT();
- rc.left = rectangle.Left;
- rc.top = rectangle.Top;
- rc.right = rectangle.Right;
- rc.bottom = rectangle.Bottom;
- IntPtr hdc = graphics.GetHdc();
- int res = Win32.DrawFrameControl( hdc, ref rc, (uint)DrawFrameControl.DFC_BUTTON,
- (uint)state | (uint)DrawFrameControl.DFCS_BUTTONPUSH);
- graphics.ReleaseHdc(hdc);
+ public static void DrawBorder3D( Graphics graphics, Rectangle rectangle, Border3DStyle style, Border3DSide sides) {
+ Pen penTopLeft;
+ Pen penTopLeftInner;
+ Pen penBottomRight;
+ Pen penBottomRightInner;
+ Rectangle rect= new Rectangle(rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height);
+ bool doInner = false;
+
+ if ((style & Border3DStyle.Adjust)!=0) {
+ rect.Y-=2;
+ rect.X-=2;
+ rect.Width+=4;
+ rect.Height+=4;
+ }
+
+ /* default to flat */
+ penTopLeft=SystemPens.ControlDark;
+ penTopLeftInner=SystemPens.ControlDark;
+ penBottomRight=SystemPens.ControlDark;
+ penBottomRightInner=SystemPens.ControlDark;
+
+ if ((style & Border3DStyle.RaisedOuter)!=0) {
+ penTopLeft=SystemPens.ControlLightLight;
+ penBottomRight=SystemPens.ControlDarkDark;
+ if ((style & (Border3DStyle.RaisedInner | Border3DStyle.SunkenInner))!=0) {
+ doInner=true;
+ }
+ } else if ((style & Border3DStyle.SunkenOuter)!=0) {
+ penTopLeft=SystemPens.ControlDarkDark;
+ penBottomRight=SystemPens.ControlLightLight;
+ if ((style & (Border3DStyle.RaisedInner | Border3DStyle.SunkenInner))!=0) {
+ doInner=true;
+ }
+ }
+
+ if ((style & Border3DStyle.RaisedInner)!=0) {
+ if (doInner) {
+ penTopLeftInner=SystemPens.ControlLight;
+ penBottomRightInner=SystemPens.ControlDark;
+ } else {
+ penTopLeft=SystemPens.ControlLightLight;
+ penBottomRight=SystemPens.ControlDarkDark;
+ }
+ } else if ((style & Border3DStyle.SunkenInner)!=0) {
+ if (doInner) {
+ penTopLeftInner=SystemPens.ControlDark;
+ penBottomRightInner=SystemPens.ControlLight;
+ } else {
+ penTopLeft=SystemPens.ControlDarkDark;
+ penBottomRight=SystemPens.ControlLightLight;
+ }
+ }
+
+ if ((sides & Border3DSide.Middle)!=0) {
+ graphics.FillRectangle(SystemBrushes.Control, rect);
+ }
+
+ if ((sides & Border3DSide.Left)!=0) {
+ graphics.DrawLine(penTopLeft, rect.Left, rect.Bottom-1, rect.Left, rect.Top);
+ if (doInner) {
+ graphics.DrawLine(penTopLeftInner, rect.Left+1, rect.Bottom-1, rect.Left+1, rect.Top);
+ }
+ }
+
+ if ((sides & Border3DSide.Top)!=0) {
+ graphics.DrawLine(penTopLeft, rect.Left, rect.Top, rect.Right-1, rect.Top);
+
+ if (doInner) {
+ if ((sides & Border3DSide.Left)!=0) {
+ graphics.DrawLine(penTopLeftInner, rect.Left+1, rect.Top+1, rect.Right-1, rect.Top+1);
+ } else {
+ graphics.DrawLine(penTopLeftInner, rect.Left, rect.Top+1, rect.Right-1, rect.Top+1);
+ }
+ }
+ }
+
+ if ((sides & Border3DSide.Right)!=0) {
+ graphics.DrawLine(penBottomRight, rect.Right-1, rect.Top, rect.Right-1, rect.Bottom-1);
+
+ if (doInner) {
+ if ((sides & Border3DSide.Top)!=0) {
+ graphics.DrawLine(penBottomRightInner, rect.Right-2, rect.Top+1, rect.Right-2, rect.Bottom-1);
+ } else {
+ graphics.DrawLine(penBottomRightInner, rect.Right-2, rect.Top, rect.Right-2, rect.Bottom-1);
+ }
+ }
+ }
+
+ if ((sides & Border3DSide.Bottom)!=0) {
+ int left=rect.Left;
+
+ if ((sides & Border3DSide.Left)!=0) {
+ left+=1;
+ }
+
+ graphics.DrawLine(penBottomRight, rect.Left, rect.Bottom-1, rect.Right-1, rect.Bottom-1);
+
+ if (doInner) {
+ if ((sides & Border3DSide.Right)!=0) {
+ graphics.DrawLine(penBottomRightInner, left, rect.Bottom-2, rect.Right-2, rect.Bottom-2);
+ } else {
+ graphics.DrawLine(penBottomRightInner, left, rect.Bottom-2, rect.Right-1, rect.Bottom-2);
+ }
+ }
+ }
}
- [MonoTODO]
public static void DrawButton( Graphics graphics, int x, int y, int width, int height, ButtonState state) {
- DrawButton( graphics, new Rectangle(x, y, width, height), state);
+ DrawButton(graphics, new Rectangle(x, y, width, height), state);
}
- [MonoTODO]
- public static void DrawCaptionButton(
- Graphics graphics,
- int x,
- int y,
- int width,
- int height,
- CaptionButton button,
- ButtonState state) {
- //FIXME:
+ public static void DrawButton( Graphics graphics, Rectangle rectangle, ButtonState state) {
+ DrawFrameControlStates dfcs=DrawFrameControlStates.DFCS_BUTTONPUSH;
+
+ if ((state & ButtonState.Pushed)!=0) {
+ dfcs |= DrawFrameControlStates.DFCS_PUSHED;
+ }
+
+ if ((state & ButtonState.Checked)!=0) {
+ dfcs |= DrawFrameControlStates.DFCS_CHECKED;
+ }
+
+ if ((state & ButtonState.Flat)!=0) {
+ dfcs |= DrawFrameControlStates.DFCS_FLAT;
+ }
+
+ if ((state & ButtonState.Inactive)!=0) {
+ dfcs |= DrawFrameControlStates.DFCS_INACTIVE;
+ }
+ DrawFrameControl(graphics, rectangle, DrawFrameControlTypes.DFC_BUTTON, dfcs);
}
- public static void DrawCheckBox( Graphics graphics, Rectangle rectangle, ButtonState state) {
- DrawFrameControlHelper (graphics, rectangle, (uint)DrawFrameControl.DFC_BUTTON, (uint)state | (uint)DrawFrameControl.DFCS_BUTTONCHECK);
+ /*
+ This function literally draws the various caption elements.
+ This way we can scale them nicely, no matter what size, and they
+ still look like MS's scaled caption buttons. (as opposed to scaling a bitmap)
+ */
+
+ private static void DrawCaptionHelper(Graphics graphics, Color color, Pen pen, int lineWidth, int shift, Rectangle captionRect, CaptionButton button) {
+ switch(button) {
+ case CaptionButton.Close: {
+ pen.StartCap=LineCap.Triangle;
+ pen.EndCap=LineCap.Triangle;
+ if (lineWidth<2) {
+ graphics.DrawLine(pen, captionRect.Left+2*lineWidth+1+shift, captionRect.Top+2*lineWidth+shift, captionRect.Right-2*lineWidth+1+shift, captionRect.Bottom-2*lineWidth+shift);
+ graphics.DrawLine(pen, captionRect.Right-2*lineWidth+1+shift, captionRect.Top+2*lineWidth+shift, captionRect.Left+2*lineWidth+1+shift, captionRect.Bottom-2*lineWidth+shift);
+ }
+
+ graphics.DrawLine(pen, captionRect.Left+2*lineWidth+shift, captionRect.Top+2*lineWidth+shift, captionRect.Right-2*lineWidth+shift, captionRect.Bottom-2*lineWidth+shift);
+ graphics.DrawLine(pen, captionRect.Right-2*lineWidth+shift, captionRect.Top+2*lineWidth+shift, captionRect.Left+2*lineWidth+shift, captionRect.Bottom-2*lineWidth+shift);
+ return;
+ }
+
+ case CaptionButton.Help: {
+ StringFormat sf = new StringFormat();
+ SolidBrush sb = new SolidBrush(color);
+ Font font = new Font("Microsoft Sans Serif", captionRect.Height, FontStyle.Bold, GraphicsUnit.Pixel);
+
+ sf.Alignment=StringAlignment.Center;
+ sf.LineAlignment=StringAlignment.Center;
+
+
+ graphics.DrawString("?", font, sb, captionRect.X+captionRect.Width/2+shift, captionRect.Y+captionRect.Height/2+shift+lineWidth/2, sf);
+
+ sf.Dispose();
+ sb.Dispose();
+ font.Dispose();
+
+ return;
+ }
+
+ case CaptionButton.Maximize: {
+ /* Top 'caption bar' line */
+ for (int i=0; i<Math.Max(2, lineWidth); i++) {
+ graphics.DrawLine(pen, captionRect.Left+lineWidth+shift, captionRect.Top+2*lineWidth+shift+i, captionRect.Right-lineWidth-lineWidth/2+shift, captionRect.Top+2*lineWidth+shift+i);
+ }
+
+ /* Left side line */
+ for (int i=0; i<Math.Max(1, lineWidth/2); i++) {
+ graphics.DrawLine(pen, captionRect.Left+lineWidth+shift+i, captionRect.Top+2*lineWidth+shift, captionRect.Left+lineWidth+shift+i, captionRect.Bottom-lineWidth+shift);
+ }
+
+ /* Right side line */
+ for (int i=0; i<Math.Max(1, lineWidth/2); i++) {
+ graphics.DrawLine(pen, captionRect.Right-lineWidth-lineWidth/2+shift+i, captionRect.Top+2*lineWidth+shift, captionRect.Right-lineWidth-lineWidth/2+shift+i, captionRect.Bottom-lineWidth+shift);
+ }
+
+ /* Bottom line */
+ for (int i=0; i<Math.Max(1, lineWidth/2); i++) {
+ graphics.DrawLine(pen, captionRect.Left+lineWidth+shift, captionRect.Bottom-lineWidth+shift-i, captionRect.Right-lineWidth-lineWidth/2+shift, captionRect.Bottom-lineWidth+shift-i);
+ }
+ return;
+ }
+
+ case CaptionButton.Minimize: {
+ /* Bottom line */
+ for (int i=0; i<Math.Max(2, lineWidth); i++) {
+ graphics.DrawLine(pen, captionRect.Left+lineWidth+shift, captionRect.Bottom-lineWidth+shift-i, captionRect.Right-3*lineWidth+shift, captionRect.Bottom-lineWidth+shift-i);
+ }
+ return;
+ }
+
+ case CaptionButton.Restore: {
+ /** First 'window' **/
+ /* Top 'caption bar' line */
+ for (int i=0; i<Math.Max(2, lineWidth); i++) {
+ graphics.DrawLine(pen, captionRect.Left+3*lineWidth+shift, captionRect.Top+2*lineWidth+shift-i, captionRect.Right-lineWidth-lineWidth/2+shift, captionRect.Top+2*lineWidth+shift-i);
+ }
+
+ /* Left side line */
+ for (int i=0; i<Math.Max(1, lineWidth/2); i++) {
+ graphics.DrawLine(pen, captionRect.Left+3*lineWidth+shift+i, captionRect.Top+2*lineWidth+shift, captionRect.Left+3*lineWidth+shift+i, captionRect.Top+4*lineWidth+shift);
+ }
+
+ /* Right side line */
+ for (int i=0; i<Math.Max(1, lineWidth/2); i++) {
+ graphics.DrawLine(pen, captionRect.Right-lineWidth-lineWidth/2+shift-i, captionRect.Top+2*lineWidth+shift, captionRect.Right-lineWidth-lineWidth/2+shift-i, captionRect.Top+5*lineWidth-lineWidth/2+shift);
+ }
+
+ /* Bottom line */
+ for (int i=0; i<Math.Max(1, lineWidth/2); i++) {
+ graphics.DrawLine(pen, captionRect.Right-3*lineWidth-lineWidth/2+shift, captionRect.Top+5*lineWidth-lineWidth/2+shift+1+i, captionRect.Right-lineWidth-lineWidth/2+shift, captionRect.Top+5*lineWidth-lineWidth/2+shift+1+i);
+ }
+
+ /** Second 'window' **/
+ /* Top 'caption bar' line */
+ for (int i=0; i<Math.Max(2, lineWidth); i++) {
+ graphics.DrawLine(pen, captionRect.Left+lineWidth+shift, captionRect.Top+4*lineWidth+shift+1-i, captionRect.Right-3*lineWidth-lineWidth/2+shift, captionRect.Top+4*lineWidth+shift+1-i);
+ }
+
+ /* Left side line */
+ for (int i=0; i<Math.Max(1, lineWidth/2); i++) {
+ graphics.DrawLine(pen, captionRect.Left+lineWidth+shift+i, captionRect.Top+4*lineWidth+shift+1, captionRect.Left+lineWidth+shift+i, captionRect.Bottom-lineWidth+shift);
+ }
+
+ /* Right side line */
+ for (int i=0; i<Math.Max(1, lineWidth/2); i++) {
+ graphics.DrawLine(pen, captionRect.Right-3*lineWidth-lineWidth/2+shift-i, captionRect.Top+4*lineWidth+shift+1, captionRect.Right-3*lineWidth-lineWidth/2+shift-i, captionRect.Bottom-lineWidth+shift);
+ }
+
+ /* Bottom line */
+ for (int i=0; i<Math.Max(1, lineWidth/2); i++) {
+ graphics.DrawLine(pen, captionRect.Left+lineWidth+shift, captionRect.Bottom-lineWidth+shift-i, captionRect.Right-3*lineWidth-lineWidth/2+shift, captionRect.Bottom-lineWidth+shift-i);
+ }
+
+ return;
+ }
+
+ }
}
-
- [MonoTODO]
- public static void DrawCaptionButton( Graphics graphics, Rectangle rectangle,CaptionButton button, ButtonState state) {
- //FIXME:
+
+ public static void DrawCaptionButton(Graphics graphics, int x, int y, int width, int height, CaptionButton button, ButtonState state) {
+ DrawCaptionButton(graphics, new Rectangle(x, y, width, height), button, state);
}
-
- [MonoTODO]
+
+ public static void DrawCaptionButton(Graphics graphics, Rectangle rectangle, CaptionButton button, ButtonState state) {
+ Rectangle captionRect;
+ int lineWidth;
+
+ DrawButton(graphics, rectangle, state);
+
+ if (rectangle.Width<rectangle.Height) {
+ captionRect=new Rectangle(rectangle.X+1, rectangle.Y+rectangle.Height/2-rectangle.Width/2+1, rectangle.Width-4, rectangle.Width-4);
+ } else {
+ captionRect=new Rectangle(rectangle.X+rectangle.Width/2-rectangle.Height/2+1, rectangle.Y+1, rectangle.Height-4, rectangle.Height-4);
+ }
+
+ if ((state & ButtonState.Pushed)!=0) {
+ captionRect=new Rectangle(rectangle.X+2, rectangle.Y+2, rectangle.Width-3, rectangle.Height-3);
+ }
+
+ /* Make sure we've got at least a line width of 1 */
+ lineWidth=Math.Max(1, captionRect.Width/7);
+
+ switch(button) {
+ case CaptionButton.Close: {
+ Pen pen;
+
+ if ((state & ButtonState.Inactive)!=0) {
+ pen=new Pen(SystemColors.ControlLightLight, lineWidth);
+ DrawCaptionHelper(graphics, SystemColors.ControlLightLight, pen, lineWidth, 1, captionRect, button);
+ pen.Dispose();
+
+ pen=new Pen(SystemColors.ControlDark, lineWidth);
+ DrawCaptionHelper(graphics, SystemColors.ControlDark, pen, lineWidth, 0, captionRect, button);
+ pen.Dispose();
+ return;
+ } else {
+ pen=new Pen(SystemColors.ControlText, lineWidth);
+ DrawCaptionHelper(graphics, SystemColors.ControlText, pen, lineWidth, 0, captionRect, button);
+ pen.Dispose();
+ return;
+ }
+ }
+
+ case CaptionButton.Help:
+ case CaptionButton.Maximize:
+ case CaptionButton.Minimize:
+ case CaptionButton.Restore: {
+ if ((state & ButtonState.Inactive)!=0) {
+ DrawCaptionHelper(graphics, SystemColors.ControlLightLight, SystemPens.ControlLightLight, lineWidth, 1, captionRect, button);
+
+ DrawCaptionHelper(graphics, SystemColors.ControlDark, SystemPens.ControlDark, lineWidth, 0, captionRect, button);
+ return;
+ } else {
+ DrawCaptionHelper(graphics, SystemColors.ControlText, SystemPens.ControlText, lineWidth, 0, captionRect, button);
+ return;
+ }
+ }
+ }
+ }
+
public static void DrawCheckBox(Graphics graphics, int x, int y, int width, int height, ButtonState state) {
DrawCheckBox(graphics, new Rectangle(x, y, width, height), state);
}
- [MonoTODO]
- public static void DrawComboButton(
- Graphics graphics,
- Rectangle rectangle,
- ButtonState state) {
- //FIXME:
+ public static void DrawCheckBox(Graphics graphics, Rectangle rectangle, ButtonState state) {
+ DrawFrameControlStates dfcs=DrawFrameControlStates.DFCS_BUTTONCHECK;
+
+ if ((state & ButtonState.Pushed)!=0) {
+ dfcs |= DrawFrameControlStates.DFCS_PUSHED;
+ }
+
+ if ((state & ButtonState.Checked)!=0) {
+ dfcs |= DrawFrameControlStates.DFCS_CHECKED;
+ }
+
+ if ((state & ButtonState.Flat)!=0) {
+ dfcs |= DrawFrameControlStates.DFCS_FLAT;
+ }
+
+ if ((state & ButtonState.Inactive)!=0) {
+ dfcs |= DrawFrameControlStates.DFCS_INACTIVE;
+ }
+
+ if ((state & ButtonState.ThreeState)!=0) {
+ dfcs |= DrawFrameControlStates.DFCS_CHECKED | DrawFrameControlStates.DFCS_PUSHED;
+ }
+
+ DrawFrameControl(graphics, rectangle, DrawFrameControlTypes.DFC_BUTTON, dfcs);
}
- [MonoTODO]
- public static void DrawComboButton(
- Graphics graphics,
- int x,
- int y,
- int width,
- int height,
- ButtonState state) {
- //FIXME:
+ public static void DrawComboButton(Graphics graphics, Rectangle rectangle, ButtonState state) {
+ Point[] arrow = new Point[3];
+ Point P1;
+ Point P2;
+ Point P3;
+ int centerX;
+ int centerY;
+ int shiftX;
+ int shiftY;
+ Rectangle rect;
+
+ if ((state & ButtonState.Checked)!=0) {
+ HatchBrush hatchBrush=new HatchBrush(HatchStyle.Percent50, SystemColors.ControlLight, SystemColors.ControlLightLight);
+ graphics.FillRectangle(hatchBrush,rectangle);
+ hatchBrush.Dispose();
+ }
+
+ if ((state & ButtonState.Flat)!=0) {
+ DrawBorder(graphics, rectangle, SystemColors.ControlDark, ButtonBorderStyle.Solid);
+ } else {
+ if ((state & (ButtonState.Pushed | ButtonState.Checked))!=0) {
+ DrawBorder3D(graphics, rectangle, Border3DStyle.Sunken, Border3DSide.Left | Border3DSide.Top | Border3DSide.Right | Border3DSide.Bottom);
+ } else {
+ DrawBorder3D(graphics, rectangle, Border3DStyle.Raised, Border3DSide.Left | Border3DSide.Top | Border3DSide.Right | Border3DSide.Bottom);
+ }
+ }
+
+ rect=new Rectangle(rectangle.X+rectangle.Width/4, rectangle.Y+rectangle.Height/4, rectangle.Width/2, rectangle.Height/2);
+ centerX=rect.Left+rect.Width/2;
+ centerY=rect.Top+rect.Height/2;
+ shiftX=Math.Max(1, rect.Width/8);
+ shiftY=Math.Max(1, rect.Height/8);
+
+ if ((state & ButtonState.Pushed)!=0) {
+ shiftX++;
+ shiftY++;
+ }
+
+ rect.Y-=shiftY;
+ centerY-=shiftY;
+ P1=new Point(rect.Left, centerY);
+ P2=new Point(rect.Right, centerY);
+ P3=new Point(centerX, rect.Bottom);
+
+ arrow[0]=P1;
+ arrow[1]=P2;
+ arrow[2]=P3;
+
+ /* Draw the arrow */
+ if ((state & ButtonState.Inactive)!=0) {
+ graphics.FillPolygon(SystemBrushes.ControlLightLight, arrow, FillMode.Winding);
+
+ /* Move away from the shadow */
+ P1.X-=1; P1.Y-=1;
+ P2.X-=1; P2.Y-=1;
+ P3.X-=1; P3.Y-=1;
+
+ arrow[0]=P1;
+ arrow[1]=P2;
+ arrow[2]=P3;
+
+
+ graphics.FillPolygon(SystemBrushes.ControlDark, arrow, FillMode.Winding);
+ } else {
+ graphics.FillPolygon(SystemBrushes.ControlText, arrow, FillMode.Winding);
+ }
}
- [MonoTODO]
- public static void DrawContainerGrabHandle(Graphics graphics,Rectangle bounds) {
- //FIXME:
+ public static void DrawComboButton(Graphics graphics, int x, int y, int width, int height, ButtonState state) {
+ DrawComboButton(graphics, new Rectangle(x, y, width, height), state);
+ }
+
+ public static void DrawContainerGrabHandle(Graphics graphics, Rectangle bounds) {
+ SolidBrush sb = new SolidBrush(Color.White);
+ Pen pen = new Pen(Color.Black, 1);
+ Rectangle rect = new Rectangle(bounds.X, bounds.Y, bounds.Width-1, bounds.Height-1); // Dunno why, but MS does it that way, too
+ int X;
+ int Y;
+
+ graphics.FillRectangle(sb, rect);
+ graphics.DrawRectangle(pen, rect);
+
+ X=rect.X+rect.Width/2;
+ Y=rect.Y+rect.Height/2;
+
+ /* Draw the cross */
+ graphics.DrawLine(pen, X, rect.Y+2, X, rect.Bottom-2);
+ graphics.DrawLine(pen, rect.X+2, Y, rect.Right-2, Y);
+
+ /* Draw 'arrows' for vertical lines */
+ graphics.DrawLine(pen, X-1, rect.Y+3, X+1, rect.Y+3);
+ graphics.DrawLine(pen, X-1, rect.Bottom-3, X+1, rect.Bottom-3);
+
+ /* Draw 'arrows' for horizontal lines */
+ graphics.DrawLine(pen, rect.X+3, Y-1, rect.X+3, Y+1);
+ graphics.DrawLine(pen, rect.Right-3, Y-1, rect.Right-3, Y+1);
}
- [MonoTODO]
public static void DrawFocusRectangle( Graphics graphics, Rectangle rectangle) {
- RECT rc = new RECT();
- rc.left = rectangle.Left;
- rc.top = rectangle.Top;
- rc.right = rectangle.Right;
- rc.bottom = rectangle.Bottom;
- IntPtr hdc = graphics.GetHdc();
- int res = Win32.DrawFocusRect( hdc, ref rc);
- graphics.ReleaseHdc(hdc);
+ DrawFocusRectangle(graphics, rectangle, Color.White, Color.Black);
}
- [MonoTODO]
public static void DrawFocusRectangle( Graphics graphics, Rectangle rectangle, Color foreColor, Color backColor) {
- //FIXME: what to do with colors ?
- DrawFocusRectangle( graphics, rectangle);
+ //Color colorForeInverted;
+ Color colorBackInverted;
+ Pen pen;
+
+ //colorForeInverted=Color.FromArgb(Math.Abs(foreColor.R-255), Math.Abs(foreColor.G-255), Math.Abs(foreColor.B-255));
+ //pen=new Pen(colorForeInverted, 1);
+ // MS seems to always use black
+ pen=new Pen(Color.Black, 1);
+ graphics.DrawRectangle(pen, rectangle);
+ pen.Dispose();
+
+ colorBackInverted=Color.FromArgb(Math.Abs(backColor.R-255), Math.Abs(backColor.G-255), Math.Abs(backColor.B-255));
+ pen=new Pen(colorBackInverted, 1);
+ pen.DashStyle=DashStyle.Dot;
+ graphics.DrawRectangle(pen, rectangle);
+ pen.Dispose();
}
- [MonoTODO]
- public static void DrawGrabHandle(
- Graphics graphics,
- Rectangle rectangle,
- bool primary,
- bool enabled) {
- //FIXME:
+ public static void DrawGrabHandle(Graphics graphics, Rectangle rectangle, bool primary, bool enabled) {
+ SolidBrush sb;
+ Pen pen;
+
+ if (primary==true) {
+ pen=new Pen(Color.Black, 1);
+ if (enabled==true) {
+ sb=new SolidBrush(Color.White);
+ } else {
+ sb=new SolidBrush(SystemColors.Control);
+ }
+ } else {
+ pen=new Pen(Color.White, 1);
+ if (enabled==true) {
+ sb=new SolidBrush(Color.Black);
+ } else {
+ sb=new SolidBrush(SystemColors.Control);
+ }
+ }
+ graphics.FillRectangle(sb, rectangle);
+ graphics.DrawRectangle(pen, rectangle);
+ sb.Dispose();
+ pen.Dispose();
}
- [MonoTODO]
- public static void DrawGrid(
- Graphics graphics,
- Rectangle area,
- Size pixelsBetweenDots,
- Color backColor) {
- //FIXME:
+ public static void DrawGrid(Graphics graphics, Rectangle area, Size pixelsBetweenDots, Color backColor) {
+ Color foreColor;
+ int h;
+ int b;
+ int s;
+
+ Color2HBS(backColor, out h, out b, out s);
+
+ if (b>127) {
+ foreColor=Color.Black;
+ } else {
+ foreColor=Color.White;
+ }
+
+#if false
+ /* Commented out until I take the time and figure out
+ which HatchStyle will match requirements. The code below
+ is only correct for Percent50.
+ */
+ if (pixelsBetweenDots.Width==pixelsBetweenDots.Height) {
+ HatchBrush brush=null;
+
+ switch(pixelsBetweenDots.Width) {
+ case 2: brush=new HatchBrush(HatchStyle.Percent50, foreColor, backColor); break;
+ case 4: brush=new HatchBrush(HatchStyle.Percent25, foreColor, backColor); break;
+ case 5: brush=new HatchBrush(HatchStyle.Percent20, foreColor, backColor); break;
+ default: {
+ /* Have to do it the slow way */
+ break;
+ }
+ }
+ if (brush!=null) {
+ graphics.FillRectangle(brush, area);
+ pen.Dispose();
+ brush.Dispose();
+ return;
+ }
+ }
+#endif
+ /* Slow method */
+
+ Bitmap bitmap = new Bitmap(area.Width, area.Height, graphics);
+
+ for (int x=0; x<area.Width; x+=pixelsBetweenDots.Width) {
+ for (int y=0; y<area.Height; y+=pixelsBetweenDots.Height) {
+ bitmap.SetPixel(x, y, foreColor);
+ }
+ }
+ graphics.DrawImage(bitmap, area.X, area.Y, area.Width, area.Height);
+ bitmap.Dispose();
}
- [MonoTODO]
- public static void DrawImageDisabled(
- Graphics graphics,
- Image image,
- int x,
- int y,
- Color background) {
- //FIXME:
+ public static void DrawImageDisabled(Graphics graphics, Image image, int x, int y, Color background) {
+ /*
+ Microsoft seems to ignore the background and simply make
+ the image grayscale. At least when having > 256 colors on
+ the display.
+ */
+
+ ImageAttributes imageAttributes=new ImageAttributes();
+ ColorMatrix colorMatrix=new ColorMatrix(new float[][] {
+// This table would create a perfect grayscale image, based on luminance
+// new float[]{0.3f,0.3f,0.3f,0,0},
+// new float[]{0.59f,0.59f,0.59f,0,0},
+// new float[]{0.11f,0.11f,0.11f,0,0},
+// new float[]{0,0,0,1,0,0},
+// new float[]{0,0,0,0,1,0},
+// new float[]{0,0,0,0,0,1}
+
+// This table generates a image that is grayscaled and then
+// brightened up. Seems to match MS close enough.
+ new float[]{0.2f,0.2f,0.2f,0,0},
+ new float[]{0.41f,0.41f,0.41f,0,0},
+ new float[]{0.11f,0.11f,0.11f,0,0},
+ new float[]{0.15f,0.15f,0.15f,1,0,0},
+ new float[]{0.15f,0.15f,0.15f,0,1,0},
+ new float[]{0.15f,0.15f,0.15f,0,0,1}
+ });
+
+ imageAttributes.SetColorMatrix(colorMatrix);
+ graphics.DrawImage(image, new Rectangle(x, y, image.Width, image.Height), 0, 0, image.Width, image.Height, GraphicsUnit.Pixel, imageAttributes);
+ imageAttributes.Dispose();
}
- [MonoTODO]
- public static void DrawLockedFrame(
- Graphics graphics,
- Rectangle rectangle,
- bool primary) {
- //FIXME:
+ public static void DrawLockedFrame(Graphics graphics, Rectangle rectangle, bool primary) {
+ Pen penBorder;
+ Pen penInside;
+
+ if (primary) {
+ penBorder=new Pen(Color.White, 2);
+ penInside=new Pen(Color.Black, 1);
+ } else {
+ penBorder=new Pen(Color.Black, 2);
+ penInside=new Pen(Color.White, 1);
+ }
+ penBorder.Alignment=PenAlignment.Inset;
+ penInside.Alignment=PenAlignment.Inset;
+
+ graphics.DrawRectangle(penBorder, rectangle);
+ graphics.DrawRectangle(penInside, rectangle.X+2, rectangle.Y+2, rectangle.Width-5, rectangle.Height-5);
+ penBorder.Dispose();
+ penInside.Dispose();
}
- [MonoTODO]
- public static void DrawMenuGlyph(
- Graphics graphics,
- Rectangle rectangle,
- MenuGlyph glyph) {
- //FIXME:
+ public static void DrawMenuGlyph(Graphics graphics, Rectangle rectangle, MenuGlyph glyph) {
+ Rectangle rect;
+ int lineWidth;
+
+ // MS seems to draw the background white
+ graphics.FillRectangle(new SolidBrush(Color.White), rectangle);
+
+ switch(glyph) {
+ case MenuGlyph.Arrow: {
+ Point[] arrow = new Point[3];
+ Point P1;
+ Point P2;
+ Point P3;
+ int centerX;
+ int centerY;
+ int shiftX;
+ int shiftY;
+
+ rect=new Rectangle(rectangle.X+rectangle.Width/4, rectangle.Y+rectangle.Height/4, rectangle.Width/2, rectangle.Height/2);
+ centerX=rect.Left+rect.Width/2;
+ centerY=rect.Top+rect.Height/2;
+ shiftX=Math.Max(1, rect.Width/8);
+ shiftY=Math.Max(1, rect.Height/8);
+
+ rect.X-=shiftX;
+ centerX-=shiftX;
+
+ P1=new Point(centerX, rect.Top-1);
+ P2=new Point(centerX, rect.Bottom);
+ P3=new Point(rect.Right, centerY);
+
+ arrow[0]=P1;
+ arrow[1]=P2;
+ arrow[2]=P3;
+
+ graphics.FillPolygon(SystemBrushes.ControlText, arrow, FillMode.Winding);
+
+ return;
+ }
+
+ case MenuGlyph.Bullet: {
+ SolidBrush sb;
+
+ lineWidth=Math.Max(2, rectangle.Width/3);
+ rect=new Rectangle(rectangle.X+lineWidth, rectangle.Y+lineWidth, rectangle.Width-lineWidth*2, rectangle.Height-lineWidth*2);
+
+ sb=new SolidBrush(SystemColors.MenuText);
+ graphics.FillEllipse(sb, rect);
+ sb.Dispose();
+ return;
+ }
+
+ case MenuGlyph.Checkmark: {
+ int Scale;
+
+ lineWidth=Math.Max(2, rectangle.Width/6);
+ Scale=Math.Max(1, rectangle.Width/12);
+
+ rect=new Rectangle(rectangle.X+lineWidth, rectangle.Y+lineWidth, rectangle.Width-lineWidth*2, rectangle.Height-lineWidth*2);
+
+ for (int i=0; i<lineWidth; i++) {
+ graphics.DrawLine(SystemPens.MenuText, rect.Left+lineWidth/2, rect.Top+lineWidth+i, rect.Left+lineWidth/2+2*Scale, rect.Top+lineWidth+2*Scale+i);
+ graphics.DrawLine(SystemPens.MenuText, rect.Left+lineWidth/2+2*Scale, rect.Top+lineWidth+2*Scale+i, rect.Left+lineWidth/2+6*Scale, rect.Top+lineWidth-2*Scale+i);
+ }
+ return;
+ }
+ }
}
- [MonoTODO]
- public static void DrawMenuGlyph(
- Graphics graphics,
- int x,
- int y,
- int width,
- int height,
- MenuGlyph glyph) {
- //FIXME:
+ public static void DrawMenuGlyph(Graphics graphics, int x, int y, int width, int height, MenuGlyph glyph) {
+ DrawMenuGlyph(graphics, new Rectangle(x, y, width, height), glyph);
}
- [MonoTODO]
- public static void DrawMixedCheckBox(
- Graphics graphics,
- Rectangle rectangle,
- ButtonState state) {
- //FIXME:
+ public static void DrawMixedCheckBox(Graphics graphics, Rectangle rectangle, ButtonState state) {
+ DrawCheckBox(graphics, rectangle, state);
}
- [MonoTODO]
- public static void DrawMixedCheckBox(
- Graphics graphics,
- int x,
- int y,
- int width,
- int height,
- ButtonState state) {
- //FIXME:
+ public static void DrawMixedCheckBox(Graphics graphics, int x, int y, int width, int height, ButtonState state) {
+ DrawMixedCheckBox(graphics, new Rectangle(x, y, width, height), state);
}
- internal static void CopyImageTransparent (IntPtr targetDC, IntPtr sourceDC, Rectangle rectangle, Color transparentColor) {
- // Monochrome mask
- IntPtr maskDC = Win32.CreateCompatibleDC (sourceDC);
- IntPtr maskBmp = Win32.CreateBitmap (rectangle.Width, rectangle.Height, 1, 1, IntPtr.Zero);
- IntPtr oldMaskBmp = Win32.SelectObject (maskDC, maskBmp);
+ internal static void DrawFrameControl(Graphics graphics, Rectangle rectangle, DrawFrameControlTypes Type, DrawFrameControlStates State) {
+ switch(Type) {
+ case DrawFrameControlTypes.DFC_BUTTON: {
+ if ((State & DrawFrameControlStates.DFCS_BUTTONPUSH)!=0) {
+ /* Goes first, affects the background */
+ if ((State & DrawFrameControlStates.DFCS_CHECKED)!=0) {
+ HatchBrush hatchBrush=new HatchBrush(HatchStyle.Percent50, SystemColors.ControlLight, SystemColors.ControlLightLight);
+ graphics.FillRectangle(hatchBrush,rectangle);
+ hatchBrush.Dispose();
+ }
- uint oldColor = Win32.SetBkColor (sourceDC, (uint)Win32.RGB (transparentColor));
- Win32.StretchBlt (maskDC, 0, 0, rectangle.Width, rectangle.Height, sourceDC,
- 0, 0, rectangle.Width, rectangle.Height, PatBltTypes.SRCCOPY);
- Win32.SetBkColor (sourceDC, oldColor);
+ if ((State & DrawFrameControlStates.DFCS_PUSHED)!=0) {
+ DrawBorder3D(graphics, rectangle, Border3DStyle.Sunken, Border3DSide.Left | Border3DSide.Top | Border3DSide.Right | Border3DSide.Bottom);
+ } else if ((State & DrawFrameControlStates.DFCS_FLAT)!=0) {
+ DrawBorder(graphics, rectangle, SystemColors.ControlDark, ButtonBorderStyle.Solid);
+ } else if ((State & DrawFrameControlStates.DFCS_INACTIVE)!=0) {
+ /* Same as normal, it would seem */
+ DrawBorder3D(graphics, rectangle, Border3DStyle.Raised, Border3DSide.Left | Border3DSide.Top | Border3DSide.Right | Border3DSide.Bottom);
+ } else {
+ DrawBorder3D(graphics, rectangle, Border3DStyle.Raised, Border3DSide.Left | Border3DSide.Top | Border3DSide.Right | Border3DSide.Bottom);
+ }
+ } else if ((State & DrawFrameControlStates.DFCS_BUTTONRADIO)!=0) {
+ Pen penFatDark = new Pen(SystemColors.ControlDarkDark, 2);
+ Pen penFatLight = new Pen(SystemColors.ControlLight, 2);
+ int lineWidth;
- Win32.StretchBlt (targetDC, rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height,
- sourceDC, 0, 0, rectangle.Width, rectangle.Height, PatBltTypes.SRCINVERT);
+ graphics.DrawArc(penFatDark, rectangle.X+1, rectangle.Y+1, rectangle.Width-2, rectangle.Height-2, 135, 180);
+ graphics.DrawArc(penFatLight, rectangle.X+1, rectangle.Y+1, rectangle.Width-2, rectangle.Height-2, 315, 180);
- uint oldBkClr = Win32.SetBkColor (targetDC, 0xFFFFFF);
- int oldTextClr = Win32.SetTextColor (targetDC, 0);
- Win32.StretchBlt (targetDC, rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height,
- maskDC, 0, 0, rectangle.Width, rectangle.Height, PatBltTypes.SRCAND);
- Win32.SetTextColor (targetDC, oldTextClr);
- Win32.SetBkColor (targetDC, oldBkClr);
+ graphics.DrawArc(SystemPens.ControlDark, rectangle, 135, 180);
+ graphics.DrawArc(SystemPens.ControlLightLight, rectangle, 315, 180);
- Win32.StretchBlt (targetDC, rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height,
- sourceDC, 0, 0, rectangle.Width, rectangle.Height, PatBltTypes.SRCINVERT);
+ lineWidth=Math.Max(1, Math.Min(rectangle.Width, rectangle.Height)/3);
- Win32.SelectObject (maskDC, oldMaskBmp);
- Win32.DeleteDC (maskDC);
- Win32.DeleteObject (maskBmp);
- }
+ if ((State & DrawFrameControlStates.DFCS_CHECKED)!=0) {
+ SolidBrush buttonBrush;
- internal static void DrawFrameControlHelper (Graphics graphics, Rectangle rectangle, uint type, uint state) {
+ if ((State & DrawFrameControlStates.DFCS_INACTIVE)!=0) {
+ buttonBrush=(SolidBrush)SystemBrushes.ControlDark;
+ } else {
+ buttonBrush=(SolidBrush)SystemBrushes.ControlText;
+ }
+ graphics.FillPie(buttonBrush, rectangle.X+lineWidth, rectangle.Y+lineWidth, rectangle.Width-lineWidth*2, rectangle.Height-lineWidth*2, 0, 359);
+ }
+ penFatDark.Dispose();
+ penFatLight.Dispose();
+ } else if ((State & DrawFrameControlStates.DFCS_BUTTONRADIOIMAGE)!=0) {
+ throw new NotImplementedException () ;
+ } else if ((State & DrawFrameControlStates.DFCS_BUTTONRADIOMASK)!=0) {
+ throw new NotImplementedException ();
+ } else { /* Must be Checkbox */
+ Pen pen;
+ int lineWidth;
+ Rectangle rect;
+ int Scale;
- IntPtr targetDC = graphics.GetHdc ();
- Bitmap bmp = new Bitmap (rectangle.Width, rectangle.Height, graphics);
- Graphics g = Graphics.FromImage (bmp);
- IntPtr memDC = g.GetHdc ();
+ /* FIXME: I'm sure there's an easier way to calculate all this, but it should do for now */
- RECT rc = new RECT();
- rc.left = 0;
- rc.top = 0;
- rc.right = rectangle.Width;
- rc.bottom = rectangle.Height;
+ /* Goes first, affects the background */
+ if ((State & DrawFrameControlStates.DFCS_PUSHED)!=0) {
+ HatchBrush hatchBrush=new HatchBrush(HatchStyle.Percent50, SystemColors.ControlLight, SystemColors.ControlLightLight);
+ graphics.FillRectangle(hatchBrush,rectangle);
+ hatchBrush.Dispose();
+ }
- Color transparentColor = Color.FromArgb (0, 0, 1);
- uint oldBk = Win32.SetBkColor (memDC, (uint)Win32.RGB(transparentColor));
- Win32.ExtTextOut (memDC, 0, 0, ExtTextOutFlags.ETO_OPAQUE, ref rc, 0, 0, IntPtr.Zero);
- Win32.SetBkColor (memDC, oldBk);
+ /* Draw the sunken frame */
+ if ((State & DrawFrameControlStates.DFCS_FLAT)!=0) {
+ DrawBorder(graphics, rectangle, SystemColors.ControlDark, ButtonBorderStyle.Solid);
+ } else {
+ DrawBorder3D(graphics, rectangle, Border3DStyle.Sunken, Border3DSide.Left | Border3DSide.Top | Border3DSide.Right | Border3DSide.Bottom);
+ }
- int res = Win32.DrawFrameControl( memDC, ref rc, type, state);
+ /* Make sure we've got at least a line width of 1 */
+ lineWidth=Math.Max(3, rectangle.Width/6);
+ Scale=Math.Max(1, rectangle.Width/12);
- CopyImageTransparent (targetDC, memDC, rectangle, transparentColor);
+ rect=new Rectangle(rectangle.X+lineWidth, rectangle.Y+lineWidth, rectangle.Width-lineWidth*2, rectangle.Height-lineWidth*2);
+ if ((State & DrawFrameControlStates.DFCS_INACTIVE)!=0) {
+ pen=SystemPens.ControlDark;
+ } else {
+ pen=SystemPens.ControlText;
+ }
- g.ReleaseHdc(memDC);
- g.Dispose();
- bmp.Dispose();
- graphics.ReleaseHdc (targetDC);
- }
+ if ((State & DrawFrameControlStates.DFCS_CHECKED)!=0) {
+ /* Need to draw a check-mark */
+ for (int i=0; i<lineWidth; i++) {
+ graphics.DrawLine(pen, rect.Left+lineWidth/2, rect.Top+lineWidth+i, rect.Left+lineWidth/2+2*Scale, rect.Top+lineWidth+2*Scale+i);
+ graphics.DrawLine(pen, rect.Left+lineWidth/2+2*Scale, rect.Top+lineWidth+2*Scale+i, rect.Left+lineWidth/2+6*Scale, rect.Top+lineWidth-2*Scale+i);
+ }
+
+ }
+ }
+ return;
+ }
+
+ case DrawFrameControlTypes.DFC_CAPTION: {
+ break;
+ }
- public static void DrawRadioButton (Graphics graphics, Rectangle rectangle, ButtonState state) {
- DrawFrameControlHelper (graphics, rectangle, (uint)DrawFrameControl.DFC_BUTTON, (uint)state | (uint)DrawFrameControl.DFCS_BUTTONRADIO);
+ case DrawFrameControlTypes.DFC_MENU: {
+ break;
+ }
+
+ case DrawFrameControlTypes.DFC_SCROLL: {
+ break;
+ }
+ }
}
-
- [MonoTODO]
- public static void DrawRadioButton(
- Graphics graphics,
- int x,
- int y,
- int width,
- int height,
- ButtonState state) {
+
+ public static void DrawRadioButton(Graphics graphics, int x, int y, int width, int height, ButtonState state) {
DrawRadioButton(graphics, new Rectangle(x, y, width, height), state);
}
- [MonoTODO]
- public static void DrawReversibleFrame(
- Rectangle rectangle,
- Color backColor,
- FrameStyle style) {
- //FIXME:
+ public static void DrawRadioButton(Graphics graphics, Rectangle rectangle, ButtonState state) {
+ DrawFrameControlStates dfcs=DrawFrameControlStates.DFCS_BUTTONRADIO;
+
+ if ((state & ButtonState.Pushed)!=0) {
+ dfcs |= DrawFrameControlStates.DFCS_PUSHED;
+ }
+
+ if ((state & ButtonState.Checked)!=0) {
+ dfcs |= DrawFrameControlStates.DFCS_CHECKED;
+ }
+
+ if ((state & ButtonState.Flat)!=0) {
+ dfcs |= DrawFrameControlStates.DFCS_FLAT;
+ }
+
+ if ((state & ButtonState.Inactive)!=0) {
+ dfcs |= DrawFrameControlStates.DFCS_INACTIVE;
+ }
+ DrawFrameControl(graphics, rectangle, DrawFrameControlTypes.DFC_BUTTON, dfcs);
}
[MonoTODO]
- public static void DrawReversibleLine(
- Point start,
- Point end,
- Color backColor) {
+ public static void DrawReversibleFrame(Rectangle rectangle, Color backColor, FrameStyle style) {
//FIXME:
}
[MonoTODO]
- public static void DrawScrollButton(
- Graphics graphics,
- Rectangle rectangle,
- ScrollButton button,
- ButtonState state) {
+ public static void DrawReversibleLine(Point start, Point end, Color backColor) {
//FIXME:
}
-
+
[MonoTODO]
- public static void DrawScrollButton(
- Graphics graphics,
- int x,
- int y,
- int width,
- int height,
- ScrollButton button,
- ButtonState state) {
+ public static void FillReversibleRectangle(Rectangle rectangle, Color backColor) {
//FIXME:
}
- [MonoTODO]
- public static void DrawSelectionFrame(
- Graphics graphics,
- bool active,
- Rectangle outsideRect,
- Rectangle insideRect,
- Color backColor) {
- //FIXME:
- }
- [MonoTODO]
- public static void DrawSizeGrip(
- Graphics graphics,
- Color backColor,
- Rectangle bounds) {
- //FIXME:
+ public static void DrawScrollButton(Graphics graphics, Rectangle rectangle, ScrollButton button, ButtonState state) {
+ Point[] arrow = new Point[3];
+ Point P1;
+ Point P2;
+ Point P3;
+ int centerX;
+ int centerY;
+ int shiftX;
+ int shiftY;
+ Rectangle rect;
+
+ if ((state & ButtonState.Checked)!=0) {
+ HatchBrush hatchBrush=new HatchBrush(HatchStyle.Percent50, SystemColors.ControlLight, SystemColors.ControlLightLight);
+ graphics.FillRectangle(hatchBrush,rectangle);
+ hatchBrush.Dispose();
+ }
+
+ if ((state & ButtonState.Flat)!=0) {
+ DrawBorder(graphics, rectangle, SystemColors.ControlDark, ButtonBorderStyle.Solid);
+ } else {
+ DrawBorder3D(graphics, rectangle, Border3DStyle.Raised, Border3DSide.Left | Border3DSide.Top | Border3DSide.Right | Border3DSide.Bottom);
+ }
+
+ rect=new Rectangle(rectangle.X+rectangle.Width/4, rectangle.Y+rectangle.Height/4, rectangle.Width/2, rectangle.Height/2);
+ centerX=rect.Left+rect.Width/2;
+ centerY=rect.Top+rect.Height/2;
+ shiftX=Math.Max(1, rect.Width/8);
+ shiftY=Math.Max(1, rect.Height/8);
+
+ if ((state & ButtonState.Pushed)!=0) {
+ shiftX++;
+ shiftY++;
+ }
+
+ switch(button) {
+ default:
+ case ScrollButton.Down: {
+ rect.Y-=shiftY;
+ centerY-=shiftY;
+ P1=new Point(rect.Left, centerY);
+ P2=new Point(rect.Right, centerY);
+ P3=new Point(centerX, rect.Bottom);
+ break;
+ }
+
+ case ScrollButton.Up: {
+ rect.Y+=shiftY;
+ centerY+=shiftY;
+ P1=new Point(rect.Left, centerY);
+ P2=new Point(rect.Right, centerY);
+ P3=new Point(centerX, rect.Top-1);
+ break;
+ }
+
+ case ScrollButton.Left: {
+ rect.X+=shiftX;
+ centerX+=shiftX;
+ P1=new Point(centerX, rect.Top-1);
+ P2=new Point(centerX, rect.Bottom);
+ P3=new Point(rect.Left, centerY);
+ break;
+ }
+
+ case ScrollButton.Right: {
+ rect.X-=shiftX;
+ centerX-=shiftX;
+ P1=new Point(centerX, rect.Top-1);
+ P2=new Point(centerX, rect.Bottom);
+ P3=new Point(rect.Right, centerY);
+ break;
+ }
+ }
+ arrow[0]=P1;
+ arrow[1]=P2;
+ arrow[2]=P3;
+
+ /* Draw the arrow */
+ if ((state & ButtonState.Inactive)!=0) {
+ graphics.FillPolygon(SystemBrushes.ControlLightLight, arrow, FillMode.Winding);
+
+ /* Move away from the shadow */
+ P1.X-=1; P1.Y-=1;
+ P2.X-=1; P2.Y-=1;
+ P3.X-=1; P3.Y-=1;
+
+ arrow[0]=P1;
+ arrow[1]=P2;
+ arrow[2]=P3;
+
+ graphics.FillPolygon(SystemBrushes.ControlDark, arrow, FillMode.Winding);
+ } else {
+ graphics.FillPolygon(SystemBrushes.ControlText, arrow, FillMode.Winding);
+ }
}
- [MonoTODO]
- public static void DrawSizeGrip(
- Graphics graphics,
- Color backColor,
- int x,
- int y,
- int width,
- int height) {
- //FIXME:
+ public static void DrawScrollButton(Graphics graphics, int x, int y, int width, int height, ScrollButton button, ButtonState state) {
+ DrawScrollButton(graphics, new Rectangle(x, y, width, height), button, state);
}
- [MonoTODO]
- public static void DrawStringDisabled(Graphics graphics, string s, Font font, Color color, RectangleF layoutRectangle, StringFormat format) {
- Rectangle rect = new Rectangle((int)layoutRectangle.Left, (int)layoutRectangle.Top, (int)layoutRectangle.Width, (int)layoutRectangle.Height);
- RECT rc = new RECT();
-
- rect.Offset(1,1);
- rc.left = rect.Left;
- rc.top = rect.Top;
- rc.right = rect.Right;
- rc.bottom = rect.Bottom;
-
- IntPtr hdc = graphics.GetHdc();
-
- int prevColor = Win32.SetTextColor(hdc, Win32.GetSysColor(GetSysColorIndex.COLOR_3DHILIGHT));
- BackgroundMode prevBkMode = Win32.SetBkMode(hdc, BackgroundMode.TRANSPARENT);
- IntPtr prevFont = Win32.SelectObject(hdc, font.ToHfont());
-
- Win32.DrawText(hdc, s, s.Length, ref rc, Win32.StringFormat2DrawTextFormat(format));
-
- rect.Offset(-1,-1);
- rc.left = rect.Left;
- rc.top = rect.Top;
- rc.right = rect.Right;
- rc.bottom = rect.Bottom;
- Win32.SetTextColor(hdc, Win32.GetSysColor(GetSysColorIndex.COLOR_3DSHADOW));
- Win32.DrawText(hdc, s, s.Length, ref rc, Win32.StringFormat2DrawTextFormat(format));
-
- Win32.SelectObject(hdc, prevFont);
- Win32.SetBkMode(hdc, prevBkMode);
- Win32.SetTextColor(hdc, prevColor);
-
- graphics.ReleaseHdc(hdc);
+ public static void DrawSelectionFrame(Graphics graphics, bool active, Rectangle outsideRect, Rectangle insideRect, Color backColor) {
+ int h;
+ int b;
+ int s;
+ Color foreColor;
+ HatchBrush brush;
+ Color transparent;
+ GraphicsContainer container;
+
+ Color2HBS(backColor, out h, out b, out s);
+
+ if (b>127) {
+ foreColor=SystemColors.ControlDark;
+ } else {
+ foreColor=SystemColors.ControlLight;
+ }
+ transparent=Color.FromArgb(0, backColor);
+
+ if (active==true) {
+ brush=new HatchBrush(HatchStyle.LightUpwardDiagonal, foreColor, transparent);
+ } else {
+ brush=new HatchBrush(HatchStyle.Percent25, foreColor, transparent);
+ }
+
+ container=graphics.BeginContainer();
+ graphics.ExcludeClip(insideRect);
+ graphics.FillRectangle(brush, outsideRect);
+ graphics.EndContainer(container);
+ brush.Dispose();
}
- [MonoTODO]
- public static void FillReversibleRectangle(
- Rectangle rectangle,
- Color backColor) {
- //FIXME:
+ public static void DrawSizeGrip(Graphics graphics, Color backColor, Rectangle bounds) {
+ int h;
+ int b;
+ int s;
+ Pen pen1;
+ Pen pen2;
+
+ Color2HBS(backColor, out h, out b, out s);
+
+ pen1=new Pen(HBS2Color(h, Math.Min(255, (b*166)/100), s), 1);
+ pen2=new Pen(HBS2Color(h, (b*33)/100, s), 1);
+
+ for (int i=0; i<bounds.Width; i+=4) {
+ graphics.DrawLine(pen1, bounds.Left+i, bounds.Bottom, bounds.Right, bounds.Top+i);
+ graphics.DrawLine(pen2, bounds.Left+i+1, bounds.Bottom, bounds.Right, bounds.Top+i+1);
+ graphics.DrawLine(pen2, bounds.Left+i+2, bounds.Bottom, bounds.Right, bounds.Top+i+2);
+ }
+ pen1.Dispose();
+ pen2.Dispose();
}
- [MonoTODO]
- public static Color Light(Color baseColor) {
- return Light( baseColor, 10.0f);
+ public static void DrawSizeGrip(Graphics graphics, Color backColor, int x, int y, int width, int height) {
+ DrawSizeGrip(graphics, backColor, new Rectangle(x, y, width, height));
}
- [MonoTODO]
- public static Color Light(Color baseColor,float percOfLightLight) {
- double H, I, S;
- ControlPaint.Color2HIS(baseColor, out H, out I, out S);
- double NewIntensity = Math.Min( 1.0, I + (percOfLightLight / 100.0));
- return ControlPaint.HIS2Color(H, NewIntensity, S);
- }
- [MonoTODO]
- public static Color LightLight(Color baseColor) {
- return Light( baseColor, 20.0f);
+ public static void DrawStringDisabled(Graphics graphics, string s, Font font, Color color, RectangleF layoutRectangle, StringFormat format) {
+ SolidBrush brush;
+
+ brush=new SolidBrush(ControlPaint.Light(color, 25));
+
+ layoutRectangle.Offset(1.0f, 1.0f);
+ graphics.DrawString(s, font, brush, layoutRectangle, format);
+
+ brush.Color=ControlPaint.Dark(color, 35);
+ layoutRectangle.Offset(-1.0f, -1.0f);
+ graphics.DrawString(s, font, brush, layoutRectangle, format);
+
+ brush.Dispose();
}
+
#endregion
}
}
diff --git a/mcs/class/System.Windows.Forms/System.Windows.Forms/FolderBrowserDialog.cs b/mcs/class/System.Windows.Forms/System.Windows.Forms/FolderBrowserDialog.cs
index 6dc5b9a55e8..7d882b70d5e 100644
--- a/mcs/class/System.Windows.Forms/System.Windows.Forms/FolderBrowserDialog.cs
+++ b/mcs/class/System.Windows.Forms/System.Windows.Forms/FolderBrowserDialog.cs
@@ -3,10 +3,14 @@
//
// Author:
// Dennis Hayes (dennish@raytek.com)
+// Implemented by Jordi Mas i Hernàndez (jmas@softcatala.org)
//
-// (C) 2002 Ximian, Inc
+// (C) 2002-3 Ximian, Inc
//
+using System.Runtime.InteropServices;
+using System.Text;
+
namespace System.Windows.Forms {
// <summary>
@@ -15,29 +19,166 @@ namespace System.Windows.Forms {
using System.Runtime.Remoting;
using System.ComponentModel;
-
// Beta specs do not specify what class to defrive from.
// Using CommonDialog because
public class FolderBrowserDialog : CommonDialog {
string description;
-
+ string selectedPath;
+ Environment.SpecialFolder folder = Environment.SpecialFolder.Desktop;
+ bool bShowNewFolderButton;
+
+ private IntPtr SpecialFolderConv(Environment.SpecialFolder fldr) {
+
+ IntPtr nRslt = IntPtr.Zero;
+
+ switch (fldr)
+ {
+ case Environment.SpecialFolder.ApplicationData:
+ nRslt = (IntPtr) ShellSpecialFolder.CSIDL_APPDATA;
+ break;
+
+ case Environment.SpecialFolder.CommonApplicationData:
+ nRslt = (IntPtr) ShellSpecialFolder.CSIDL_COMMON_APPDATA;
+ break;
+
+ case Environment.SpecialFolder.CommonProgramFiles:
+ nRslt = (IntPtr) ShellSpecialFolder.CSIDL_COMMON_PROGRAMS;
+ break;
+
+ case Environment.SpecialFolder.Cookies:
+ nRslt = (IntPtr) ShellSpecialFolder.CSIDL_COOKIES;
+ break;
+
+ case Environment.SpecialFolder.Desktop:
+ nRslt = (IntPtr) ShellSpecialFolder.CSIDL_DESKTOP;
+ break;
+
+ case Environment.SpecialFolder.DesktopDirectory:
+ nRslt = (IntPtr) ShellSpecialFolder.CSIDL_DESKTOPDIRECTORY;
+ break;
+
+ case Environment.SpecialFolder.Favorites:
+ nRslt = (IntPtr) ShellSpecialFolder.CSIDL_FAVORITES;
+ break;
+
+ case Environment.SpecialFolder.History:
+ nRslt = (IntPtr) ShellSpecialFolder.CSIDL_HISTORY;
+ break;
+
+ case Environment.SpecialFolder.InternetCache:
+ nRslt = (IntPtr) ShellSpecialFolder.CSIDL_INTERNET_CACHE;
+ break;
+
+ case Environment.SpecialFolder.LocalApplicationData:
+ nRslt = (IntPtr) ShellSpecialFolder.CSIDL_LOCAL_APPDATA;
+ break;
+
+ //case Environment.SpecialFolder.MyComputer: //TODO: Which value?
+ //nRslt = (IntPtr) ShellSpecialFolder.;
+ //break;
+
+ case Environment.SpecialFolder.MyMusic:
+ nRslt = (IntPtr) ShellSpecialFolder.CSIDL_MYMUSIC;
+ break;
+
+ case Environment.SpecialFolder.MyPictures:
+ nRslt = (IntPtr) ShellSpecialFolder.CSIDL_MYPICTURES;
+ break;
+
+ case Environment.SpecialFolder.Personal:
+ nRslt = (IntPtr) ShellSpecialFolder.CSIDL_PERSONAL;
+ break;
+
+ case Environment.SpecialFolder.ProgramFiles:
+ nRslt = (IntPtr) ShellSpecialFolder.CSIDL_PROGRAM_FILES;
+ break;
+
+ case Environment.SpecialFolder.Programs:
+ nRslt = (IntPtr) ShellSpecialFolder.CSIDL_PROGRAMS;
+ break;
+
+ case Environment.SpecialFolder.Recent:
+ nRslt = (IntPtr) ShellSpecialFolder.CSIDL_RECENT;
+ break;
+
+ case Environment.SpecialFolder.SendTo:
+ nRslt = (IntPtr) ShellSpecialFolder.CSIDL_SENDTO;
+ break;
+
+ case Environment.SpecialFolder.StartMenu:
+ nRslt = (IntPtr) ShellSpecialFolder.CSIDL_STARTMENU;
+ break;
+
+ case Environment.SpecialFolder.Startup:
+ nRslt = (IntPtr) ShellSpecialFolder.CSIDL_STARTUP;
+ break;
+
+ case Environment.SpecialFolder.System:
+ nRslt = (IntPtr) ShellSpecialFolder.CSIDL_SYSTEM;
+ break;
+
+ case Environment.SpecialFolder.Templates:
+ nRslt = (IntPtr) ShellSpecialFolder.CSIDL_TEMPLATES;
+ break;
+
+ default:
+ throw new InvalidEnumArgumentException();
+ }
+
+ return nRslt;
+ }
//
// --- Constructor
//
- [MonoTODO]
- public FolderBrowserDialog() {
- description = "";
+
+ public FolderBrowserDialog() {
+
+ Reset();
}
- [MonoTODO]
+
public override void Reset(){
- //
+
+ description = "";
+ selectedPath = "";
+ folder = Environment.SpecialFolder.Desktop;
+ bShowNewFolderButton = true;
}
- [MonoTODO]
+
protected override bool RunDialog(IntPtr hWndOwner){
- throw new NotImplementedException ();
+
+ BROWSEINFO bi = new BROWSEINFO();
+ IntPtr pidl = IntPtr.Zero;
+ IntPtr olePath = Marshal.AllocHGlobal(2048);
+ int nRet = 0;
+
+ bi.hwndOwner = hWndOwner;
+ bi.pidlRoot = (IntPtr) SpecialFolderConv(RootFolder);
+ bi.lpszTitle = Description;
+ bi.ulFlags = (uint) (BrowseDirFlags.BIF_RETURNONLYFSDIRS | BrowseDirFlags.BIF_STATUSTEXT);
+ bi.lpfn = IntPtr.Zero;
+ bi.lParam = IntPtr.Zero;
+ bi.iImage = 0;
+ bi.pszDisplayName = olePath;
+ pidl = Win32.SHBrowseForFolder(ref bi);
+
+ Marshal.FreeHGlobal(olePath);
+
+ if (pidl==IntPtr.Zero) return false;
+
+ StringBuilder sBuilder = new StringBuilder();
+
+ nRet = Win32.SHGetPathFromIDList(pidl, sBuilder);
+
+ // TODO: Dealocate the pidl returned by Win32.SHBrowseForFolder
+ // Win32.SHFreeMalloc(pidl);
+
+ if (nRet==0) return false;
+
+ selectedPath = sBuilder.ToString();
+ return true;
}
//
@@ -45,12 +186,8 @@ namespace System.Windows.Forms {
//
public string Description {
- get {
- return description;
- }
- set {
- description = value;
- }
+ get {return description;}
+ set {description = value;}
}
//beta docs do not have accessor.
@@ -61,33 +198,20 @@ namespace System.Windows.Forms {
//}
public Environment.SpecialFolder RootFolder {
- get {
- throw new NotImplementedException ();
- }
- set {
- //FIXME:
- }
+ get {return folder;}
+ set {folder = value;}
}
public string SelectedPath {
- get {
- throw new NotImplementedException ();
- }
- set {
- //FIXME:
- }
+ get {return selectedPath;}
+ set {selectedPath = value;}
}
public bool ShowNewFolderButton {
- get {
- throw new NotImplementedException ();
- }
- set {
- //FIXME:
- }
+ get {return bShowNewFolderButton;}
+ set {bShowNewFolderButton = value;}
}
-
//public virtual System.ComponentModel.IContainer Container {
// get {
// throw new NotImplementedException ();
diff --git a/mcs/class/System.Windows.Forms/System.Windows.Forms/Form.cs b/mcs/class/System.Windows.Forms/System.Windows.Forms/Form.cs
index 6817550cbd4..d3f552b6efa 100644
--- a/mcs/class/System.Windows.Forms/System.Windows.Forms/Form.cs
+++ b/mcs/class/System.Windows.Forms/System.Windows.Forms/Form.cs
@@ -692,7 +692,7 @@
}
// --- Public Events
-
+
public event EventHandler Activated;
public event EventHandler Closed;
@@ -877,7 +877,9 @@
//Compact Framework
protected virtual void OnActivated (EventArgs e) {
- Activated(this,e);
+ if (Activated != null) {
+ Activated(this,e);
+ }
}
//Compact Framework
@@ -1118,6 +1120,13 @@
//case ?:
//OnCreateControl()
//break;
+
+ case Msg.WM_ACTIVATE: {
+ EventArgs activateEventArgs = new EventArgs();
+ OnActivated(activateEventArgs);
+ break;
+ }
+
case Msg.WM_FONTCHANGE:
EventArgs fontChangedArgs = new EventArgs();
OnFontChanged (fontChangedArgs);
diff --git a/mcs/class/System.Windows.Forms/System.Windows.Forms/InputLanguageChangedEventArgs.cs b/mcs/class/System.Windows.Forms/System.Windows.Forms/InputLanguageChangedEventArgs.cs
index 3d9d7406eaf..fbc83bd1eca 100644
--- a/mcs/class/System.Windows.Forms/System.Windows.Forms/InputLanguageChangedEventArgs.cs
+++ b/mcs/class/System.Windows.Forms/System.Windows.Forms/InputLanguageChangedEventArgs.cs
@@ -57,7 +57,7 @@ namespace System.Windows.Forms {
[MonoTODO]
public InputLanguage InputLanguage {
get {
- return InputLanguage;
+ return inputLanguage;
}
}
diff --git a/mcs/class/System.Windows.Forms/System.Windows.Forms/LinkLabel.cs b/mcs/class/System.Windows.Forms/System.Windows.Forms/LinkLabel.cs
index 1987b6e014b..b6ae26a1eca 100644
--- a/mcs/class/System.Windows.Forms/System.Windows.Forms/LinkLabel.cs
+++ b/mcs/class/System.Windows.Forms/System.Windows.Forms/LinkLabel.cs
@@ -156,7 +156,7 @@ namespace System.Windows.Forms {
protected override ImeMode DefaultImeMode {
get {
//FIXME:
- return DefaultImeMode;
+ return base.DefaultImeMode;
}
}
@@ -167,7 +167,7 @@ namespace System.Windows.Forms {
protected override AccessibleObject CreateAccessibilityInstance()
{
//FIXME:
- return CreateAccessibilityInstance();
+ return base.CreateAccessibilityInstance();
}
[MonoTODO]
protected override void CreateHandle()
diff --git a/mcs/class/System.Windows.Forms/System.Windows.Forms/TabControl.cs b/mcs/class/System.Windows.Forms/System.Windows.Forms/TabControl.cs
index 7a5da228279..672a91ebd49 100644
--- a/mcs/class/System.Windows.Forms/System.Windows.Forms/TabControl.cs
+++ b/mcs/class/System.Windows.Forms/System.Windows.Forms/TabControl.cs
@@ -340,7 +340,7 @@ namespace System.Windows.Forms {
if ( Multiline )
createParams.Style |= (int) TabControlStyles.TCS_MULTILINE;
- if ( DrawMode == TabDrawMode.OwnerDrawfixed )
+ if (DrawMode == TabDrawMode.OwnerDrawFixed)
createParams.Style |= (int) TabControlStyles.TCS_OWNERDRAWFIXED;
if ( HotTrack )
diff --git a/mcs/class/System.Windows.Forms/System.Windows.Forms/TabDrawMode.cs b/mcs/class/System.Windows.Forms/System.Windows.Forms/TabDrawMode.cs
index a1e0387afb4..7f8f11ef4c8 100644
--- a/mcs/class/System.Windows.Forms/System.Windows.Forms/TabDrawMode.cs
+++ b/mcs/class/System.Windows.Forms/System.Windows.Forms/TabDrawMode.cs
@@ -10,10 +10,8 @@ using System;
namespace System.Windows.Forms {
- /// <summary>
- /// </summary>
public enum TabDrawMode {
Normal = 0,
- OwnerDrawfixed =1
+ OwnerDrawFixed =1
}
}
diff --git a/mcs/class/System.Windows.Forms/System.Windows.Forms/win32Enums.cs b/mcs/class/System.Windows.Forms/System.Windows.Forms/win32Enums.cs
index 5c17ef4aa91..725398784cf 100644
--- a/mcs/class/System.Windows.Forms/System.Windows.Forms/win32Enums.cs
+++ b/mcs/class/System.Windows.Forms/System.Windows.Forms/win32Enums.cs
@@ -1693,6 +1693,7 @@ namespace System.Windows.Forms{
CSIDL_SENDTO = 0x0009,
CSIDL_BITBUCKET = 0x000a,
CSIDL_STARTMENU = 0x000b,
+ CSIDL_MYMUSIC = 0x000d,
CSIDL_DESKTOPDIRECTORY = 0x0010,
CSIDL_DRIVES = 0x0011,
CSIDL_NETWORK = 0x0012,
@@ -1705,12 +1706,18 @@ namespace System.Windows.Forms{
CSIDL_COMMON_DESKTOPDIRECTORY = 0x0019,
CSIDL_APPDATA = 0x001a,
CSIDL_PRINTHOOD = 0x001b,
+ CSIDL_LOCAL_APPDATA = 0x001c,
CSIDL_ALTSTARTUP = 0x001d,
CSIDL_COMMON_ALTSTARTUP = 0x001e,
CSIDL_COMMON_FAVORITES = 0x001f,
CSIDL_INTERNET_CACHE = 0x0020,
CSIDL_COOKIES = 0x0021,
- CSIDL_HISTORY = 0x0022
+ CSIDL_HISTORY = 0x0022,
+ CSIDL_COMMON_APPDATA = 0x0023,
+ CSIDL_SYSTEM = 0x0025,
+ CSIDL_PROGRAM_FILES = 0x0026,
+ CSIDL_MYPICTURES = 0x0027,
+
}
#endregion
@@ -2723,28 +2730,32 @@ namespace System.Windows.Forms{
CW_USEDEFAULT = -2147483648
}
- internal enum DrawFrameControl : uint {
+ internal enum DrawFrameControlTypes : uint {
DFC_CAPTION =1,
DFC_MENU =2,
DFC_SCROLL =3,
- DFC_BUTTON =4,
+ DFC_BUTTON =4
+ }
+
+ internal enum DrawFrameControlStates : uint {
DFCS_BUTTONCHECK =0x0000,
DFCS_BUTTONRADIOIMAGE =0x0001,
DFCS_BUTTONRADIOMASK =0x0002,
DFCS_BUTTONRADIO =0x0004,
DFCS_BUTTON3STATE =0x0008,
- DFCS_BUTTONPUSH =0x0010,
- }
-/*
+ DFCS_BUTTONPUSH =0x0010,
+
DFCS_CAPTIONCLOSE =0x0000,
DFCS_CAPTIONMIN =0x0001,
DFCS_CAPTIONMAX =0x0002,
DFCS_CAPTIONRESTORE =0x0003,
DFCS_CAPTIONHELP =0x0004,
+
DFCS_MENUARROW =0x0000,
DFCS_MENUCHECK =0x0001,
DFCS_MENUBULLET =0x0002,
DFCS_MENUARROWRIGHT =0x0004,
+
DFCS_SCROLLUP =0x0000,
DFCS_SCROLLDOWN =0x0001,
DFCS_SCROLLLEFT =0x0002,
@@ -2752,6 +2763,7 @@ namespace System.Windows.Forms{
DFCS_SCROLLCOMBOBOX =0x0005,
DFCS_SCROLLSIZEGRIP =0x0008,
DFCS_SCROLLSIZEGRIPRIGHT =0x0010,
+
DFCS_INACTIVE =0x0100,
DFCS_PUSHED =0x0200,
DFCS_CHECKED =0x0400,
@@ -2761,7 +2773,7 @@ namespace System.Windows.Forms{
DFCS_FLAT =0x4000,
DFCS_MONO =0x8000
}
-*/
+
internal enum KeyStatusFlags : int {
MK_LBUTTON = 0x0001,
MK_RBUTTON = 0x0002,
@@ -3184,4 +3196,92 @@ namespace System.Windows.Forms{
CDERR_NOHOOK = 0x000B,
CDERR_REGISTERMSGFAIL = 0x000C
}
+
+ public enum BrowseDirFlags: uint // Browsing directory flags
+ {
+ BIF_RETURNONLYFSDIRS = 0x0001,
+ BIF_DONTGOBELOWDOMAIN = 0x0002,
+ BIF_STATUSTEXT = 0x0004,
+ BIF_RETURNFSANCESTORS = 0x0008,
+ BIF_EDITBOX = 0x0010,
+ BIF_VALIDATE = 0x0020,
+ BIF_BROWSEFORCOMPUTER = 0x1000,
+ BIF_BROWSEFORPRINTER = 0x2000,
+ BIF_BROWSEINCLUDEFILES = 0x4000
+ }
+
+ public enum DefaultCodePages: uint
+ {
+ CP_ACP = 0x0000, /* ANSI code page */
+ CP_OEMCP = 0x0001,
+ CP_MACCP = 0x0002,
+ CP_THREAD_ACP = 0x0003,
+ CP_SYMBOL = 0x002a,
+
+ }
+ public enum RichTextEditControlMessages: uint
+ {
+ WM_USER = 0x0400,
+ EM_CANPASTE = (WM_USER+50),
+ EM_DISPLAYBAND = (WM_USER+51),
+ EM_EXGETSEL = (WM_USER+52),
+ EM_EXLIMITTEXT = (WM_USER+53),
+ EM_EXLINEFROMCHAR = (WM_USER+54),
+ EM_EXSETSEL = (WM_USER+55),
+ EM_FINDTEXT = (WM_USER+56),
+ EM_FORMATRANGE = (WM_USER+57),
+ EM_GETCHARFORMAT = (WM_USER+58),
+ EM_GETEVENTMASK = (WM_USER+59),
+ EM_GETOLEINTERFACE = (WM_USER+60),
+ EM_GETPARAFORMAT = (WM_USER+61),
+ EM_GETSELTEXT = (WM_USER+62),
+ EM_HIDESELECTION = (WM_USER+63),
+ EM_PASTESPECIAL = (WM_USER+64),
+ EM_REQUESTRESIZE = (WM_USER+65),
+ EM_SELECTIONTYPE = (WM_USER+66),
+ EM_SETBKGNDCOLOR = (WM_USER+67),
+ EM_SETCHARFORMAT = (WM_USER+68),
+ EM_SETEVENTMASK = (WM_USER+69),
+ EM_SETOLECALLBACK = (WM_USER+70),
+ EM_SETPARAFORMAT = (WM_USER+71),
+ EM_SETTARGETDEVICE = (WM_USER+72),
+ EM_STREAMIN = (WM_USER+73),
+ EM_STREAMOUT = (WM_USER+74),
+ EM_GETTEXTRANGE = (WM_USER+75),
+ EM_FINDWORDBREAK = (WM_USER+76),
+ EM_SETOPTIONS = (WM_USER+77),
+ EM_GETOPTIONS = (WM_USER+78),
+ EM_FINDTEXTEX = (WM_USER+79),
+ EM_GETWORDBREAKPROCEX= (WM_USER+80),
+ EM_SETWORDBREAKPROCEX= (WM_USER+81),
+ EM_SETUNDOLIMIT = (WM_USER+82),
+ EM_REDO = (WM_USER+84),
+ EM_CANREDO = (WM_USER+85),
+ EM_GETUNDONAME = (WM_USER+86),
+ EM_GETREDONAME = (WM_USER+87),
+ EM_STOPGROUPTYPING = (WM_USER+88),
+ EM_SETTEXTMODE = (WM_USER+89),
+ EM_GETTEXTMODE = (WM_USER+90),
+ EM_AUTOURLDETECT = (WM_USER+91),
+ EM_GETAUTOURLDETECT = (WM_USER+92),
+ EM_SETPALETTE = (WM_USER+93),
+ EM_GETTEXTEX = (WM_USER+94),
+ EM_GETTEXTLENGTHEX = (WM_USER+95),
+ EM_SETPUNCTUATION = (WM_USER+100),
+ EM_GETPUNCTUATION = (WM_USER+101),
+ EM_SETWORDWRAPMODE = (WM_USER+102),
+ EM_GETWORDWRAPMODE = (WM_USER+103),
+ EM_SETIMECOLOR = (WM_USER+104),
+ EM_GETIMECOLOR = (WM_USER+105),
+ EM_SETIMEOPTIONS = (WM_USER+106),
+ EM_GETIMEOPTIONS = (WM_USER+107),
+ EM_CONVPOSITION = (WM_USER+108),
+ EM_SETLANGOPTIONS = (WM_USER+120),
+ EM_GETLANGOPTIONS = (WM_USER+121),
+ EM_GETIMECOMPMODE = (WM_USER+122),
+ EM_FINDTEXTW = (WM_USER+123),
+ EM_FINDTEXTEXW = (WM_USER+124),
+ EM_SETBIDIOPTIONS = (WM_USER + 200),
+ EM_GETBIDIOPTIONS = (WM_USER + 201)
+ }
} \ No newline at end of file
diff --git a/mcs/class/System.Windows.Forms/System.Windows.Forms/win32Interfaces.cs b/mcs/class/System.Windows.Forms/System.Windows.Forms/win32Interfaces.cs
index 0939b003d30..c111ef91cd7 100644
--- a/mcs/class/System.Windows.Forms/System.Windows.Forms/win32Interfaces.cs
+++ b/mcs/class/System.Windows.Forms/System.Windows.Forms/win32Interfaces.cs
@@ -82,7 +82,7 @@ namespace System.Windows.Forms{
{
[PreserveSig]
int ParseDisplayName(IntPtr hWnd, IntPtr bindingContext,
- IntPtr OLEString, out int chEaten, ref IntPtr idList, ref int attributes);
+ IntPtr OLEString, ref int chEaten, ref IntPtr idList, ref int attributes);
[PreserveSig]
int EnumObjects(IntPtr hWnd, ShellEnumFlags flags, ref IEnumIDList enumList);
diff --git a/mcs/class/System.Windows.Forms/System.Windows.Forms/win32Structs.cs b/mcs/class/System.Windows.Forms/System.Windows.Forms/win32Structs.cs
index 40eb2b5e5e6..a46bd431dc3 100644
--- a/mcs/class/System.Windows.Forms/System.Windows.Forms/win32Structs.cs
+++ b/mcs/class/System.Windows.Forms/System.Windows.Forms/win32Structs.cs
@@ -1011,8 +1011,13 @@ namespace System.Windows.Forms
internal TVITEM itemNew;
internal POINT ptDrag;
}
-
- [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Ansi, Pack=1)]
+
+ //
+ // This currently causes corlib to throw an exception
+ //
+ // [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Ansi, Pack=1)]
+ //
+ [StructLayout(LayoutKind.Sequential)]
internal struct PRINTDLG {
internal uint lStructSize;
internal IntPtr hwndOwner;
@@ -1034,5 +1039,17 @@ namespace System.Windows.Forms
internal IntPtr hPrintTemplate;
internal IntPtr hSetupTemplate;
}
+
+ [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Ansi, Pack=1)]
+ internal struct BROWSEINFO {
+ internal IntPtr hwndOwner;
+ internal IntPtr pidlRoot;
+ internal IntPtr pszDisplayName;
+ internal string lpszTitle;
+ internal uint ulFlags;
+ internal IntPtr lpfn;
+ internal IntPtr lParam;
+ internal int iImage;
+ }
}
diff --git a/mcs/class/System.Windows.Forms/System.Windows.Forms/win32functions.cs b/mcs/class/System.Windows.Forms/System.Windows.Forms/win32functions.cs
index 8bf252bd48c..120156c01bd 100644
--- a/mcs/class/System.Windows.Forms/System.Windows.Forms/win32functions.cs
+++ b/mcs/class/System.Windows.Forms/System.Windows.Forms/win32functions.cs
@@ -28,6 +28,8 @@
* authorization from Carlos Harvey Perez.
*/
+#define HAVE_SHELL_SUPPORT
+
using System;
using System.Threading;
using System.Drawing;
@@ -38,6 +40,7 @@ using System.Reflection;
using System.Xml;
using System.IO;
+
//using UtilityLibrary.WinControls;
//namespace UtilityLibrary.Win32
@@ -183,6 +186,12 @@ namespace System.Windows.Forms{
}
return result;
}
+
+
+ [DllImport("kernel32.dll", CharSet=CharSet.Auto)]
+ internal static extern int MultiByteToWideChar(DefaultCodePages CodePage, int dwFlags, string lpMultiByteStr,
+ int cbMultiByte, IntPtr lpWideCharSt, int cchWideChar);
+
#endregion
#region Gdi32.dll functions
@@ -610,8 +619,8 @@ namespace System.Windows.Forms{
#endregion
#region Shell32.dll functions
-#if HAVE_SHELL_SUPPORT
- [DllImport("shell32.dll", CharSet=CharSet.Auto)]
+#if HAVE_SHELL_SUPPORT
+ [DllImport("shell32.dll", CharSet=CharSet.Auto)]
internal static extern IntPtr SHGetFileInfo(string drivePath, int fileAttributes,
out SHFILEINFO fileInfo, int countBytesFileInfo, ShellFileInfoFlags flags);
@@ -630,6 +639,9 @@ namespace System.Windows.Forms{
[DllImport("shell32.dll", CharSet=CharSet.Auto)]
internal static extern int SHGetPathFromIDList(IntPtr idl, StringBuilder path);
+
+ [DllImport("shell32.dll", CharSet=CharSet.Auto)]
+ internal static extern IntPtr SHBrowseForFolder(ref BROWSEINFO browser);
internal static void SHFreeMalloc(IntPtr handle)
{
diff --git a/mcs/class/System.XML/ChangeLog b/mcs/class/System.XML/ChangeLog
index 5c461a056fd..2376532bf2d 100644
--- a/mcs/class/System.XML/ChangeLog
+++ b/mcs/class/System.XML/ChangeLog
@@ -1,3 +1,19 @@
+2003-11-25 Tim Coleman <tim@timcoleman.com>
+ * System.Xml.dll.sources: added XmlSchemaBuiltInType.cs
+
+2003-11-19 Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
+
+ * System.Xml.dll.sources: added XPathComparer.cs
+
+2003-11-17 Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
+
+ * System.Xml.dll.sources: added some new .NET 1.2 stuff,
+ and sorted some members of the list.
+
+2003-11-13 Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
+
+ * System.Xml.dll.sources: added HtmlEmitter.cs
+
2003-10-15 Lluis Sanchez Gual <lluis@ximian.com>
* System.Xml.dll.sources: added System.Xml.Serialization/MapCodeGenerator.cs
diff --git a/mcs/class/System.XML/Mono.Xml.XPath/ChangeLog b/mcs/class/System.XML/Mono.Xml.XPath/ChangeLog
index 06500474bf1..8284ce927a3 100644
--- a/mcs/class/System.XML/Mono.Xml.XPath/ChangeLog
+++ b/mcs/class/System.XML/Mono.Xml.XPath/ChangeLog
@@ -1,3 +1,14 @@
+2003-11-19 Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
+
+ * KeyPattern.cs : Matches() should iterate candidate keys to the end.
+
+2003-11-19 Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
+
+ * IdPattern.cs,
+ KeyPattern.cs : Implemented Matches(), overrode DefaultPriority,
+ modified inheritance.
+ * Pattern.cs : Added id and key pattern support.
+
2003-11-02 Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
* DTMXPathNavigator.cs : Fixed MoveToNamespace() that might result in
diff --git a/mcs/class/System.XML/Mono.Xml.XPath/IdPattern.cs b/mcs/class/System.XML/Mono.Xml.XPath/IdPattern.cs
index 3fe929f6080..ddba8ac0b17 100644
--- a/mcs/class/System.XML/Mono.Xml.XPath/IdPattern.cs
+++ b/mcs/class/System.XML/Mono.Xml.XPath/IdPattern.cs
@@ -16,18 +16,25 @@ using System.Xml.XPath;
using System.Xml.Xsl;
namespace Mono.Xml.XPath {
- internal class IdPattern : Pattern {
+ internal class IdPattern : LocationPathPattern {
- string arg0;
+ string [] ids;
public IdPattern (string arg0)
+ : base ((NodeTest) null)
{
- this.arg0 = arg0;
+ ids = arg0.Split (XmlChar.WhitespaceChars);
}
public override bool Matches (XPathNavigator node, XsltContext ctx)
{
- throw new NotImplementedException ();
+ XPathNavigator tmp = node.Clone ();
+ for (int i = 0; i < ids.Length; i++)
+ if (tmp.MoveToId (ids [i]) && tmp.IsSamePosition (node))
+ return true;
+ return false;
}
+
+ public override double DefaultPriority { get { return 0.5; } }
}
} \ No newline at end of file
diff --git a/mcs/class/System.XML/Mono.Xml.XPath/KeyPattern.cs b/mcs/class/System.XML/Mono.Xml.XPath/KeyPattern.cs
index 6530c84e660..91a24104a29 100644
--- a/mcs/class/System.XML/Mono.Xml.XPath/KeyPattern.cs
+++ b/mcs/class/System.XML/Mono.Xml.XPath/KeyPattern.cs
@@ -14,21 +14,38 @@ using System.Xml;
using System.Xml.Schema;
using System.Xml.XPath;
using System.Xml.Xsl;
+using Mono.Xml.Xsl;
+using Mono.Xml.Xsl.Functions;
namespace Mono.Xml.XPath {
- internal class KeyPattern : Pattern {
+ internal class KeyPattern : LocationPathPattern {
+ XmlQualifiedName keyName;
string arg0, arg1;
+ XsltKey key;
- public KeyPattern (string arg0, string arg1)
+ public KeyPattern (XsltKey key)
+ : base ((NodeTest) null)
{
- this.arg0 = arg0;
- this.arg1 = arg1;
+ this.key = key;
+ ExprLiteral keyName = key.KeyName as ExprLiteral;
+ ExprLiteral field = key.Field as ExprLiteral;
+ this.arg0 = keyName.Value;
+ this.arg1 = field.Value;
+ this.keyName = XslNameUtil.FromString (arg0, key.NamespaceManager);
}
public override bool Matches (XPathNavigator node, XsltContext ctx)
{
- throw new NotImplementedException ();
+ XsltCompiledContext xctx = ctx as XsltCompiledContext;
+ XslKey xslkey = xctx.Processor.CompiledStyle.Keys [keyName] as XslKey;
+ XPathNodeIterator iter = key.EvaluateNodeSet (new SelfIterator (node, ctx));
+ while (iter.MoveNext ())
+ if (iter.Current.IsSamePosition (node))
+ return true;
+ return false;
}
+
+ public override double DefaultPriority { get { return 0.5; } }
}
} \ No newline at end of file
diff --git a/mcs/class/System.XML/Mono.Xml.XPath/Pattern.cs b/mcs/class/System.XML/Mono.Xml.XPath/Pattern.cs
index 1a8eb5be1ff..4676e0513f0 100644
--- a/mcs/class/System.XML/Mono.Xml.XPath/Pattern.cs
+++ b/mcs/class/System.XML/Mono.Xml.XPath/Pattern.cs
@@ -15,6 +15,7 @@ using System.Xml.Schema;
using System.Xml.XPath;
using System.Xml.Xsl;
using Mono.Xml.Xsl;
+using Mono.Xml.Xsl.Functions;
namespace Mono.Xml.XPath {
public abstract class Pattern {
@@ -70,8 +71,17 @@ namespace Mono.Xml.XPath {
return p1;
}
- // TODO: Handle ID/KEY
-
+ if (e is XPathFunctionId)
+ {
+ ExprLiteral id = ((XPathFunctionId) e).Id as ExprLiteral;
+ return new IdPattern (id.Value);
+ }
+
+ if (e is XsltKey)
+ {
+ return new KeyPattern ((XsltKey) e);
+ }
+
throw new Exception ("Invalid Pattern");
}
diff --git a/mcs/class/System.XML/Mono.Xml.Xsl.Operations/ChangeLog b/mcs/class/System.XML/Mono.Xml.Xsl.Operations/ChangeLog
index 6e33073f2d1..6cbf913abf7 100644
--- a/mcs/class/System.XML/Mono.Xml.Xsl.Operations/ChangeLog
+++ b/mcs/class/System.XML/Mono.Xml.Xsl.Operations/ChangeLog
@@ -1,3 +1,23 @@
+2003-11-28 Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
+
+ * XslCopy.cs, XslCopyOf.cs : namespace nodes should be written.
+
+2003-11-24 Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
+
+ * XslAttribute.cs, XslElement.cs, XslLiteralElement.cs :
+ More precise namespace handling.
+ * XslCopy.cs, XslElement.cs, XslLiteralElement.cs :
+ Added cdata-section-elements support.
+ * XslNumber.cs :
+ Cases when value is NodeSet should be allowed.
+ Default output should be 1,2,3... not exception. see XSLT spec 7.7.1
+
+2003-11-21 Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
+
+ * XslAttribute.cs : Name verification.
+ * XslElement.cs : Name verification. Consider IsEmptyElement.
+ * XslCopy.cs : copy namespace nodes too.
+
2003-11-09 Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
* XslAttribute.cs : namespace should be String.Empty if no specification
diff --git a/mcs/class/System.XML/Mono.Xml.Xsl.Operations/XslAttribute.cs b/mcs/class/System.XML/Mono.Xml.Xsl.Operations/XslAttribute.cs
index 259b396d2aa..bba91d010cb 100644
--- a/mcs/class/System.XML/Mono.Xml.Xsl.Operations/XslAttribute.cs
+++ b/mcs/class/System.XML/Mono.Xml.Xsl.Operations/XslAttribute.cs
@@ -37,15 +37,28 @@ namespace Mono.Xml.Xsl.Operations {
ns = c.ParseAvtAttribute ("namespace");
calcName = XslAvt.AttemptPreCalc (ref name);
-
+ calcPrefix = String.Empty;
+
if (calcName != null && ns == null) {
int colonAt = calcName.IndexOf (':');
calcPrefix = colonAt < 0 ? String.Empty : calcName.Substring (0, colonAt);
calcName = colonAt < 0 ? calcName : calcName.Substring (colonAt + 1, calcName.Length - colonAt - 1);
calcNs = nav.GetNamespace (calcPrefix);
- } else if (ns != null)
+ } else if (ns != null) {
calcNs = XslAvt.AttemptPreCalc (ref ns);
-
+ }
+
+ if (calcNs ==null && calcPrefix != String.Empty) {
+ string test = c.CurrentStylesheet.PrefixInEffect (calcPrefix, null);
+ if (test != null) {
+ string alias = c.CurrentStylesheet.NamespaceAliases [calcPrefix] as string;
+ if (alias != null)
+ calcNs = c.Input.GetNamespace (alias);
+ else
+ calcNs = c.Input.NamespaceURI;
+ }
+ }
+
if (ns == null && calcNs == null)
nsm = c.GetNsm ();
@@ -98,6 +111,8 @@ namespace Mono.Xml.Xsl.Operations {
if (prefix == "xmlns")
prefix = String.Empty; // Should not be allowed.
+ XmlConvert.VerifyName (nm);
+
if (value == null)
p.Out.WriteAttributeString(prefix, nm, nmsp, "");
else {
diff --git a/mcs/class/System.XML/Mono.Xml.Xsl.Operations/XslCopy.cs b/mcs/class/System.XML/Mono.Xml.Xsl.Operations/XslCopy.cs
index 8ecfa5ca190..486ebdc3907 100644
--- a/mcs/class/System.XML/Mono.Xml.Xsl.Operations/XslCopy.cs
+++ b/mcs/class/System.XML/Mono.Xml.Xsl.Operations/XslCopy.cs
@@ -43,18 +43,28 @@ namespace Mono.Xml.Xsl.Operations {
if (children != null) children.Evaluate (p);
break;
case XPathNodeType.Element:
+ bool cdataStarted = false;
+ if (!p.InsideCDataElement && p.PushCDataState (p.CurrentNode.LocalName, p.CurrentNode.NamespaceURI))
+ cdataStarted = true;
p.Out.WriteStartElement (p.CurrentNode.Prefix, p.CurrentNode.LocalName, p.CurrentNode.NamespaceURI);
- p.TryStylesheetNamespaceOutput ();
+ p.TryStylesheetNamespaceOutput (null);
if (useAttributeSets != null)
foreach (XmlQualifiedName s in useAttributeSets)
p.ResolveAttributeSet (s).Evaluate (p);
+
+ if (p.CurrentNode.MoveToFirstNamespace (XPathNamespaceScope.Local)) {
+ do {
+ p.Out.WriteNamespaceDecl (p.CurrentNode.LocalName, p.CurrentNode.Value);
+ } while (p.CurrentNode.MoveToNextNamespace (XPathNamespaceScope.Local));
+ p.CurrentNode.MoveToParent ();
+ }
if (children != null) children.Evaluate (p);
- if (p.CurrentNode.IsEmptyElement)
- p.Out.WriteEndElement ();
- else
- p.Out.WriteFullEndElement ();
+
+ p.Out.WriteFullEndElement ();
+ if (cdataStarted)
+ p.PopCDataState ();
break;
case XPathNodeType.Attribute:
p.Out.WriteAttributeString (p.CurrentNode.Prefix, p.CurrentNode.LocalName, p.CurrentNode.NamespaceURI, p.CurrentNode.Value);
@@ -73,7 +83,11 @@ namespace Mono.Xml.Xsl.Operations {
case XPathNodeType.ProcessingInstruction:
p.Out.WriteProcessingInstruction (p.CurrentNode.Name, p.CurrentNode.Value);
break;
-
+
+ case XPathNodeType.Namespace:
+ p.Out.WriteNamespaceDecl (p.CurrentNode.Name, p.CurrentNode.Value);
+ break;
+
default:
Console.WriteLine ("unhandled node type {0}", p.CurrentNode.NodeType);
break;
diff --git a/mcs/class/System.XML/Mono.Xml.Xsl.Operations/XslCopyOf.cs b/mcs/class/System.XML/Mono.Xml.Xsl.Operations/XslCopyOf.cs
index b9725f3ca2b..85173ca540b 100644
--- a/mcs/class/System.XML/Mono.Xml.Xsl.Operations/XslCopyOf.cs
+++ b/mcs/class/System.XML/Mono.Xml.Xsl.Operations/XslCopyOf.cs
@@ -66,6 +66,9 @@ namespace Mono.Xml.Xsl.Operations {
outputter.WriteFullEndElement ();
break;
+ case XPathNodeType.Namespace:
+ outputter.WriteNamespaceDecl (nav.Name, nav.Value);
+ break;
case XPathNodeType.Attribute:
outputter.WriteAttributeString (nav.Prefix, nav.LocalName, nav.NamespaceURI, nav.Value);
break;
diff --git a/mcs/class/System.XML/Mono.Xml.Xsl.Operations/XslElement.cs b/mcs/class/System.XML/Mono.Xml.Xsl.Operations/XslElement.cs
index 9dc46f6f8a7..887a1c75b2c 100644
--- a/mcs/class/System.XML/Mono.Xml.Xsl.Operations/XslElement.cs
+++ b/mcs/class/System.XML/Mono.Xml.Xsl.Operations/XslElement.cs
@@ -64,15 +64,19 @@ namespace Mono.Xml.Xsl.Operations {
{
string nm, nmsp, localName, prefix;
- nm = calcName != null ? calcName : name.Evaluate (p);
+ localName = nm = calcName != null ? calcName : name.Evaluate (p);
nmsp = calcNs != null ? calcNs : ns != null ? ns.Evaluate (p) : null;
- prefix = calcPrefix != null ? calcPrefix : String.Empty;
if (nmsp == null) {
QName q = XslNameUtil.FromString (nm, nsm);
localName = q.Name;
nmsp = q.Namespace;
+ int colonAt = nm.IndexOf (':');
+ if (colonAt > 0)
+ calcPrefix = nm.Substring (0, colonAt);
}
+ prefix = calcPrefix != null ? calcPrefix : String.Empty;
+
if (calcPrefix == String.Empty) {
if (nav.MoveToFirstNamespace (XPathNamespaceScope.ExcludeXml)) {
do {
@@ -85,16 +89,26 @@ namespace Mono.Xml.Xsl.Operations {
}
}
- p.Out.WriteStartElement (prefix, nm, nmsp);
-
- p.TryStylesheetNamespaceOutput ();
+ XmlConvert.VerifyName (nm);
+
+ bool cdataStarted = false;
+ if (!p.InsideCDataElement && p.PushCDataState (localName, nmsp))
+ cdataStarted = true;
+ p.Out.WriteStartElement (prefix, localName, nmsp);
+ p.TryStylesheetNamespaceOutput (null);
+
if (useAttributeSets != null)
foreach (XmlQualifiedName s in useAttributeSets)
p.ResolveAttributeSet (s).Evaluate (p);
if (value != null) value.Evaluate (p);
- p.Out.WriteFullEndElement ();
+ if (isEmptyElement && useAttributeSets == null)
+ p.Out.WriteEndElement ();
+ else
+ p.Out.WriteFullEndElement ();
+ if (cdataStarted)
+ p.PopCDataState ();
}
}
}
diff --git a/mcs/class/System.XML/Mono.Xml.Xsl.Operations/XslLiteralElement.cs b/mcs/class/System.XML/Mono.Xml.Xsl.Operations/XslLiteralElement.cs
index 1c787b069af..f910a3b156f 100644
--- a/mcs/class/System.XML/Mono.Xml.Xsl.Operations/XslLiteralElement.cs
+++ b/mcs/class/System.XML/Mono.Xml.Xsl.Operations/XslLiteralElement.cs
@@ -17,12 +17,14 @@ using System.Xml.Xsl;
namespace Mono.Xml.Xsl.Operations {
public class XslLiteralElement : XslCompiledElement {
+ static char [] wsChars = new char [] {' ', '\t', '\n', '\r'};
XslOperation children;
string localname, prefix, nsUri;
bool isEmptyElement;
ArrayList attrs;
XmlQualifiedName [] useAttributeSets;
Hashtable nsDecls;
+ string excludeResultPrefixes;
public XslLiteralElement (Compiler c) : base (c) {}
@@ -46,14 +48,23 @@ namespace Mono.Xml.Xsl.Operations {
protected override void Compile (Compiler c)
{
-
this.prefix = c.Input.Prefix;
- this.nsUri = c.Input.NamespaceURI;
+
+ string alias = c.CurrentStylesheet.PrefixInEffect (c.Input.Prefix, null);
+ if (alias != c.Input.Prefix) {
+ nsUri = c.Input.GetNamespace (alias);
+ if (alias != null)
+ prefix = alias;
+ }
+ else
+ nsUri = c.Input.NamespaceURI;
+
this.localname = c.Input.LocalName;
this.useAttributeSets = c.ParseQNameListAttribute ("use-attribute-sets", XsltNamespace);
this.nsDecls = c.GetNamespacesToCopy ();
if (nsDecls.Count == 0) nsDecls = null;
this.isEmptyElement = c.Input.IsEmptyElement;
+ this.excludeResultPrefixes = c.Input.GetAttribute ("exclude-result-prefixes", XsltNamespace);
if (c.Input.MoveToFirstAttribute ())
{
@@ -73,6 +84,9 @@ namespace Mono.Xml.Xsl.Operations {
public override void Evaluate (XslTransformProcessor p)
{
+ bool cdataStarted = false;
+ if (!p.InsideCDataElement && p.PushCDataState (localname, nsUri))
+ cdataStarted = true;
p.Out.WriteStartElement (prefix, localname, nsUri);
if (useAttributeSets != null)
@@ -85,16 +99,20 @@ namespace Mono.Xml.Xsl.Operations {
((XslLiteralAttribute)attrs [i]).Evaluate (p);
}
- p.TryStylesheetNamespaceOutput ();
+ p.TryStylesheetNamespaceOutput (new ArrayList (excludeResultPrefixes.Split (wsChars)));
if (nsDecls != null)
foreach (DictionaryEntry de in nsDecls)
p.Out.WriteNamespaceDecl ((string)de.Key, (string)de.Value);
if (children != null) children.Evaluate (p);
+
if (isEmptyElement)
p.Out.WriteEndElement ();
else
p.Out.WriteFullEndElement ();
+
+ if (cdataStarted)
+ p.PopCDataState ();
}
}
}
diff --git a/mcs/class/System.XML/Mono.Xml.Xsl.Operations/XslNumber.cs b/mcs/class/System.XML/Mono.Xml.Xsl.Operations/XslNumber.cs
index f50a9202bba..cf860a532fa 100644
--- a/mcs/class/System.XML/Mono.Xml.Xsl.Operations/XslNumber.cs
+++ b/mcs/class/System.XML/Mono.Xml.Xsl.Operations/XslNumber.cs
@@ -66,8 +66,9 @@ namespace Mono.Xml.Xsl.Operations {
from = c.CompilePattern (c.GetAttribute ("from"));
value = c.CompileExpression (c.GetAttribute ("value"));
- if (value != null && value.ReturnType != XPathResultType.Number && value.ReturnType != XPathResultType.Any)
- throw new Exception ("The expression for attribute 'value' must return a number");
+ // This may result in NodeSet.
+// if (value != null && value.ReturnType != XPathResultType.Number && value.ReturnType != XPathResultType.Any)
+// throw new Exception ("The expression for attribute 'value' must return a number");
format = c.ParseAvtAttribute ("format");
lang = c.ParseAvtAttribute ("lang");
@@ -325,6 +326,7 @@ namespace Mono.Xml.Xsl.Operations {
{
switch (item [0])
{
+ default: // See XSLT 1.0 spec 7.7.1.
case '0': case '1':
return new DigitItem (sep, item.Length, gpSep, gpSize);
case 'a':
@@ -335,9 +337,6 @@ namespace Mono.Xml.Xsl.Operations {
return new RomanItem (sep, false);
case 'I':
return new RomanItem (sep, true);
-
- default:
- throw new Exception ();
}
}
}
diff --git a/mcs/class/System.XML/Mono.Xml.Xsl/ChangeLog b/mcs/class/System.XML/Mono.Xml.Xsl/ChangeLog
index b9822da3fee..d88548543e9 100644
--- a/mcs/class/System.XML/Mono.Xml.Xsl/ChangeLog
+++ b/mcs/class/System.XML/Mono.Xml.Xsl/ChangeLog
@@ -1,3 +1,75 @@
+2003-11-27 Ben Maurer <bmaurer@users.sourceforge.net>
+
+ * Compiler.cs
+ * MSXslScriptManager.cs
+ * XslStylesheet.cs
+ * XslTransformProcessor.cs
+ * XsltCompiledContext.cs: Some work on msxsl script.
+
+2003-11-24 Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
+
+ (in general: cdata-section-elements support, correct document()
+ base uri handling, and so on)
+ * Compiler.cs : Use XmlSpace.Preserve to parse included stylesheet.
+ And move to document element. Added XslNameUtil.FromListString().
+ * Emitter.cs, HtmlEmitter.cs, TextEmitter.cs XmlWriterEmitter.cs :
+ Added WriteCDataSection().
+ * Outputter.cs, GenericOutputter.cs, TextOutputter.cs :
+ Added InsideCDataSection.
+ * GenericOutputter.cs :
+ In .ctor(), WriteState should be succeeded from output XmlWriter.
+ WriteNamespaceDecl() now drops declaration identical to existing one.
+ Removed obsolete htmlEmulation.
+ * XslOutput.cs : Added CDataSectionElements support.
+ * XslStylesheet.cs : Added BaseUri, StyleDocument and PrefixInEffect().
+ * XslTransformProcessor.cs :
+ Added Output and CurrentOutputUri. TryStylesheetNamespaceOutput()
+ now considers xsl:exclude-element-prefixes on literal element.
+ Added PushCDataState() and PopCDataState().
+ * XsltCompiledContext.cs : When base uri of document() target is empty,
+ then it should use stylesheet's BaseURI, not that of current document.
+
+2003-11-21 Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
+
+ * Compiler.cs : Modified decimal-format comparison code.
+ * Outputter.cs,
+ TextOutputter.cs,
+ GenericOutputter.cs : Added WriteState. Now WriteStartDocument() will
+ be called only when required.
+ * HtmlEmitter.cs : Improved indentation stuff.
+ * XslDecimalFormat.cs : Added incomplete implementation of
+ CheckSameAs() and FormatNumber().
+ * XslStylesheet.cs,
+ XslTransformProcessor.cs : Changed XslStylesheet.StylesheetNamespaces
+ from StringDictionary to ArrayList of QName (to keep order).
+
+2003-11-19 Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
+
+ * XsltCompiledContext.cs : XsltGenerateId.Evaluate() should consider
+ node type (i.e. attribute and namespace). Removed extraneous Clone().
+ Fixed XsltKey.Evaluate() to use MoveToNextAttribute to iterate attrs.
+
+2003-11-19 Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
+
+ * Compiler.cs : Changed Keys from ArrayList to Hashtable.
+ XslStylesheet.cs : Added Keys support here.
+ * XslTransformProcessor.cs : Should call SetContext() to expressions
+ before evaluating current nodes.
+ * XsltCompiledContext.cs : 1) XsltDocument.GetDocument() should use
+ xsltContext. 2) XsltKey exposes KeyName, Field and NamespaceManager
+ for KeyPattern. It now uses CompiledStyle.FindKeys().
+
+2003-11-13 Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
+
+ * GenericOutputter.cs : Added HTML output support. Closer xmlns handling
+ to Xalan tests and MS.NET implementation (only for test convenience).
+ * XslOutput.cs : Indent holds string rathen than bool. Its default value
+ varies in the context. When method="html", then default is "yes".
+ * XslTransformProcessor.cs : Extension element prefixes should not
+ be written as stylesheet namespaces.
+ * XsltCompiledContext.cs : Return type of generate-id() is string.
+ Implemented unparsed-entity-uri().
+
2003-11-02 Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
* Compiler.cs : More complete attribute set gathering.
diff --git a/mcs/class/System.XML/Mono.Xml.Xsl/Compiler.cs b/mcs/class/System.XML/Mono.Xml.Xsl/Compiler.cs
index 9f68f44acc0..e9189365fb0 100644
--- a/mcs/class/System.XML/Mono.Xml.Xsl/Compiler.cs
+++ b/mcs/class/System.XML/Mono.Xml.Xsl/Compiler.cs
@@ -33,11 +33,13 @@ namespace Mono.Xml.Xsl {
Hashtable attrSets;
ExpressionStore exprStore;
XmlNamespaceManager nsMgr;
- ArrayList keys;
+ Hashtable keys;
Hashtable outputs;
Hashtable decimalFormats;
+ MSXslScriptManager msScripts;
- public CompiledStylesheet (XslStylesheet style, Hashtable globalVariables, Hashtable attrSets, ExpressionStore exprStore, XmlNamespaceManager nsMgr, ArrayList keys, Hashtable outputs, Hashtable decimalFormats)
+ public CompiledStylesheet (XslStylesheet style, Hashtable globalVariables, Hashtable attrSets, ExpressionStore exprStore, XmlNamespaceManager nsMgr, Hashtable keys, Hashtable outputs, Hashtable decimalFormats,
+ MSXslScriptManager msScripts)
{
this.style = style;
this.globalVariables = globalVariables;
@@ -47,14 +49,20 @@ namespace Mono.Xml.Xsl {
this.keys = keys;
this.outputs = outputs;
this.decimalFormats = decimalFormats;
+ this.msScripts = msScripts;
}
public Hashtable Variables {get{return globalVariables;}}
public XslStylesheet Style { get { return style; }}
public ExpressionStore ExpressionStore {get{return exprStore;}}
public XmlNamespaceManager NamespaceManager {get{return nsMgr;}}
- public ArrayList Keys {get { return keys;}}
+ public Hashtable Keys {get { return keys;}}
public Hashtable Outputs { get { return outputs; }}
+ public MSXslScriptManager ScriptManager {
+ get { return msScripts; }
+ }
+
+
public XslDecimalFormat LookupDecimalFormat (QName name)
{
XslDecimalFormat ret = decimalFormats [name] as XslDecimalFormat;
@@ -117,9 +125,15 @@ namespace Mono.Xml.Xsl {
}
this.rootStyle = new XslStylesheet (this);
- return new CompiledStylesheet (rootStyle, globalVariables, attrSets, exprStore, nsMgr, keys, outputs, decimalFormats);
+ return new CompiledStylesheet (rootStyle, globalVariables, attrSets, exprStore, nsMgr, rootStyle.Keys, outputs, decimalFormats, msScripts);
+ }
+
+ MSXslScriptManager msScripts = new MSXslScriptManager ();
+ public MSXslScriptManager ScriptManager {
+ get { return msScripts; }
}
+
#region Input
public XPathNavigator Input {
get { return currentInput; }
@@ -150,8 +164,12 @@ namespace Mono.Xml.Xsl {
using (Stream s = (Stream)res.GetEntity (absUri, null, typeof(Stream)))
{
- XPathNavigator n = new XPathDocument (new XmlTextReader (absUri.ToString (), s)).CreateNavigator ();
+ XPathNavigator n = new XPathDocument (new XmlTextReader (absUri.ToString (), s), XmlSpace.Preserve).CreateNavigator ();
n.MoveToFirstChild ();
+ do {
+ if (n.NodeType == XPathNodeType.Element)
+ break;
+ } while (n.MoveToNext ());
PushInputDocument (n);
}
}
@@ -398,26 +416,18 @@ namespace Mono.Xml.Xsl {
}
#endregion
-#region Key
- ArrayList keys = new ArrayList ();
-
- public void AddKeyPattern (XslKey key)
- {
- keys.Add (key);
- }
-#endregion
-
#region Decimal Format
Hashtable decimalFormats = new Hashtable ();
public void CompileDecimalFormat ()
{
QName nm = ParseQNameAttribute ("name");
+ XslDecimalFormat df = new XslDecimalFormat (this);
if (decimalFormats.Contains (nm))
- ((XslDecimalFormat)decimalFormats [nm]).CheckSameAs (this);
+ ((XslDecimalFormat)decimalFormats [nm]).CheckSameAs (df);
else
- decimalFormats [nm] = new XslDecimalFormat (this);
+ decimalFormats [nm] = df;
}
#endregion
#region Static XSLT context
@@ -668,6 +678,26 @@ namespace Mono.Xml.Xsl {
public class XslNameUtil
{
+ static char [] wsChars = new char [] {' ', '\t', '\n', '\r'};
+
+ public static QName [] FromListString (string names, XPathNavigator current)
+ {
+ string [] nameArray = names.Split (wsChars);
+ int idx = 0;
+ for (int i = 0; i < nameArray.Length; i++)
+ if (nameArray [i] != String.Empty)
+ idx++;
+
+ XmlQualifiedName [] qnames = new XmlQualifiedName [idx];
+
+ idx = 0;
+ for (int i = 0; i < nameArray.Length; i++)
+ if (nameArray [i] != String.Empty)
+ qnames [idx++] = FromString (nameArray [i], current);
+
+ return qnames;
+ }
+
public static QName FromString (string name, XPathNavigator current)
{
if (current.NodeType == XPathNodeType.Attribute)
diff --git a/mcs/class/System.XML/Mono.Xml.Xsl/Emitter.cs b/mcs/class/System.XML/Mono.Xml.Xsl/Emitter.cs
index 68141bfd19a..8b3c74ac3ad 100644
--- a/mcs/class/System.XML/Mono.Xml.Xsl/Emitter.cs
+++ b/mcs/class/System.XML/Mono.Xml.Xsl/Emitter.cs
@@ -31,7 +31,8 @@ namespace Mono.Xml.Xsl {
public abstract void WriteComment (string text);
public abstract void WriteProcessingInstruction (string name, string text);
public abstract void WriteString (string text);
- public abstract void WriteRaw (string data);
+ public abstract void WriteCDataSection (string text);
+ public abstract void WriteRaw (string data);
public abstract void Done ();
}
}
diff --git a/mcs/class/System.XML/Mono.Xml.Xsl/GenericOutputter.cs b/mcs/class/System.XML/Mono.Xml.Xsl/GenericOutputter.cs
index 04c7e27ce82..6cd08fe6142 100644
--- a/mcs/class/System.XML/Mono.Xml.Xsl/GenericOutputter.cs
+++ b/mcs/class/System.XML/Mono.Xml.Xsl/GenericOutputter.cs
@@ -42,8 +42,7 @@ namespace Mono.Xml.Xsl
private NameTable _nt;
//Determines whether xsl:copy can output attribute-sets or not.
bool canProcessAttributes;
- // FIXME: This is quick hack to eliminate XML declaration for HTML output.
- bool htmlEmulation;
+ bool insideCData;
private GenericOutputter (Hashtable outputs)
{
@@ -60,7 +59,8 @@ namespace Mono.Xml.Xsl
public GenericOutputter (XmlWriter writer, Hashtable outputs)
: this (outputs)
{
- _emitter = new XmlWriterEmitter (writer);
+ _emitter = new XmlWriterEmitter (writer);
+ _state = writer.WriteState;
}
public GenericOutputter (TextWriter writer, Hashtable outputs)
@@ -70,17 +70,12 @@ namespace Mono.Xml.Xsl
switch (xslOutput.Method) {
case OutputMethod.HTML:
- Console.WriteLine ("WARNING: HTML output not fully supported, using XML output");
- htmlEmulation = true;
- goto case OutputMethod.XML;
+ _emitter = new HtmlEmitter (writer, xslOutput);
+ break;
case OutputMethod.Unknown: //TODO: handle xml vs html
case OutputMethod.XML:
- //TODO: XmlTextEmitter goes here
- //_emitter = new XmlTextEmitter (writer);
XmlTextWriter w = new XmlTextWriter (writer);
- if (_currentOutput.Indent)
- w.Formatting = Formatting.Indented;
- if (htmlEmulation)
+ if (xslOutput.Indent == "yes")
w.Formatting = Formatting.Indented;
_emitter = new XmlWriterEmitter (w);
break;
@@ -97,7 +92,10 @@ namespace Mono.Xml.Xsl
/// when it's appropriate.
/// </summary>
private void CheckState ()
- {
+ {
+ if (_state == WriteState.Start)
+ WriteStartDocument ();
+
if (_state == WriteState.Element) {
//Push scope to allow to unwind namespaces scope back in WriteEndElement
//Subject to optimization - avoid redundant push/pop by moving
@@ -130,7 +128,7 @@ namespace Mono.Xml.Xsl
public override void WriteStartDocument ()
{
- if (!_currentOutput.OmitXmlDeclaration && !htmlEmulation)
+ if (!_currentOutput.OmitXmlDeclaration)
_emitter.WriteStartDocument (_currentOutput.Standalone);
_state = WriteState.Prolog;
@@ -141,8 +139,12 @@ namespace Mono.Xml.Xsl
_emitter.WriteEndDocument ();
}
+ int _nsCount;
public override void WriteStartElement (string prefix, string localName, string nsURI)
{
+ if (_state == WriteState.Start)
+ WriteStartDocument ();
+
if (_state == WriteState.Prolog) {
//Seems to be the first element - take care of Doctype
if (_currentOutput.DoctypeSystem != null)
@@ -179,7 +181,15 @@ namespace Mono.Xml.Xsl
}
public override void WriteAttributeString (string prefix, string localName, string nsURI, string value)
- {
+ {
+ if (prefix == String.Empty && nsURI != String.Empty) {
+ prefix = "xp_" + _nsCount;
+ _nsManager.AddNamespace (prefix, nsURI);
+ _currentNsPrefixes.Add (prefix);
+ _currentNamespaceDecls.Add (prefix, nsURI);
+ _nsCount++;
+ }
+
//Put attribute to pending attributes collection, replacing namesake one
for (int i = 0; i < pendingAttributesPos; i++) {
Attribute attr = pendingAttributes [i];
@@ -208,6 +218,9 @@ namespace Mono.Xml.Xsl
public override void WriteNamespaceDecl (string prefix, string nsUri)
{
+ if (_nsManager.LookupNamespace (prefix) == nsUri)
+ return;
+
if (prefix == String.Empty) {
//Default namespace
if (_nsManager.DefaultNamespace != nsUri)
@@ -237,7 +250,10 @@ namespace Mono.Xml.Xsl
public override void WriteString (string text)
{
CheckState ();
- _emitter.WriteString (text);
+ if (insideCData)
+ _emitter.WriteCDataSection (text);
+ else
+ _emitter.WriteString (text);
}
public override void WriteRaw (string data)
@@ -255,6 +271,13 @@ namespace Mono.Xml.Xsl
public override bool CanProcessAttributes {
get { return canProcessAttributes; }
}
+
+ public override WriteState WriteState { get { return _state; } }
+
+ public override bool InsideCDataSection {
+ get { return insideCData; }
+ set { insideCData = value; }
+ }
#endregion
}
}
diff --git a/mcs/class/System.XML/Mono.Xml.Xsl/HtmlEmitter.cs b/mcs/class/System.XML/Mono.Xml.Xsl/HtmlEmitter.cs
new file mode 100644
index 00000000000..b907fd3f061
--- /dev/null
+++ b/mcs/class/System.XML/Mono.Xml.Xsl/HtmlEmitter.cs
@@ -0,0 +1,320 @@
+//
+// HtmlEmitter.cs
+//
+// Author:
+// Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
+//
+// (C)2003 Atsushi Enomoto
+//
+// TODO:
+// indent, uri escape, allowed entity char such as &nbsp;,
+// encoding to meta tag, doctype-public/doctype-system.
+//
+
+using System;
+using System.Collections;
+using System.IO;
+using System.Text;
+using System.Xml;
+
+namespace Mono.Xml.Xsl
+{
+ public class HtmlEmitter : Emitter {
+ TextWriter writer;
+ Stack elementNameStack;
+ bool openElement;
+ bool openAttribute;
+ int xmlDepth;
+ bool indent;
+
+ public HtmlEmitter (TextWriter writer, XslOutput output)
+ {
+ this.writer = writer;
+ indent = !(output.Indent == "no");
+ elementNameStack = new Stack ();
+ xmlDepth = -1;
+ }
+
+ public override void WriteStartDocument (StandaloneType standalone)
+ {
+ // do nothing
+ }
+
+ public override void WriteEndDocument ()
+ {
+ // do nothing
+ }
+
+ public override void WriteDocType (string name, string publicId, string systemId)
+ {
+ writer.Write ("<!DOCTYPE ");
+ writer.Write (name);
+ writer.Write (' ');
+ if (publicId != null && publicId != String.Empty) {
+ writer.Write ("PUBLIC ");
+ writer.Write (publicId);
+ writer.Write (' ');
+ writer.Write (systemId);
+ } else if (systemId != null && systemId != String.Empty) {
+ writer.Write ("SYSTEM ");
+ writer.Write (systemId);
+ }
+ writer.Write ('>');
+ }
+
+ private void CloseAttribute ()
+ {
+ writer.Write ('\"');
+ openAttribute = false;
+ }
+
+ private void CloseStartElement ()
+ {
+ if (openAttribute)
+ CloseAttribute ();
+ writer.Write ('>');
+ openElement = false;
+ }
+
+ // FIXME: check all HTML elements' indentation.
+ private void Indent (string elementName, bool alwaysOutputNewLine)
+ {
+ if (!indent)
+ return;
+ switch (elementName.ToUpper ()) {
+ case "ADDRESS":
+ case "BDO":
+ case "BLOCKQUOTE":
+ case "BODY":
+ case "BUTTON":
+ case "CAPTION":
+ case "CENTER":
+ case "DD":
+ case "DEL":
+ case "DIR":
+ case "DIV":
+ case "DL":
+ case "DT":
+ case "FIELDSET":
+ case "H1":
+ case "H2":
+ case "H3":
+ case "H4":
+ case "H5":
+ case "H6":
+ case "HEAD":
+ case "HTML":
+ case "IFRAME":
+ case "INS":
+ case "LI":
+ case "MAP":
+ case "MENU":
+ case "NOFRAMES":
+ case "NOSCRIPT":
+ case "OBJECT":
+ case "P":
+ case "PRE":
+ case "TD":
+ case "TH":
+ if (alwaysOutputNewLine || elementNameStack.Count > 0)
+ writer.Write ("\r\n");
+ for (int i = 0; i < elementNameStack.Count; i++)
+ writer.Write (" ");
+ break;
+ }
+ }
+
+ public override void WriteStartElement (string prefix, string localName, string nsURI)
+ {
+ if (openElement)
+ CloseStartElement ();
+ Indent (elementNameStack.Count > 0 ? elementNameStack.Peek () as string : String.Empty, false);
+ string formatName = localName;
+
+ writer.Write ('<');
+ if (nsURI != String.Empty) {
+ // XML output
+ if (prefix != String.Empty) {
+ writer.Write (prefix);
+ writer.Write (':');
+ formatName = String.Concat (prefix, ":", localName);
+ }
+ // TODO: handle xmlns using namespaceManager
+
+ if (xmlDepth < 0)
+ xmlDepth = elementNameStack.Count + 1;
+ }
+ writer.Write (formatName);
+ elementNameStack.Push (formatName);
+ openElement = true;
+ }
+
+ public override void WriteEndElement ()
+ {
+ WriteFullEndElement ();
+ }
+
+ public override void WriteFullEndElement ()
+ {
+ string element = elementNameStack.Pop () as string;
+
+ switch (element.ToUpper ()) {
+ case "AREA":
+ case "BASE":
+ case "BASEFONT":
+ case "BR":
+ case "COL":
+ case "FRAME":
+ case "HR":
+ case "IMAGE":
+ case "INPUT":
+ case "ISINDEX":
+ case "LINK":
+ case "META":
+ case "PARAM":
+ if (openAttribute)
+ CloseAttribute ();
+ writer.Write ('>');
+ break;
+ default:
+ if (openElement)
+ CloseStartElement ();
+ Indent (element, true);
+ writer.Write ("</");
+ writer.Write (element);
+ writer.Write (">");
+ break;
+ }
+ openElement = false;
+
+ if (xmlDepth > elementNameStack.Count)
+ xmlDepth = -1;
+ }
+
+ public override void WriteAttributeString (string prefix, string localName, string nsURI, string value)
+ {
+ if (xmlDepth >= 0) {
+ writer.Write (' ');
+ writer.Write (localName);
+ writer.Write ("=\"");
+ openAttribute = true;
+ WriteFormattedString (value);
+ openAttribute = false;
+ writer.Write ('\"');
+ }
+
+ string attribute = localName.ToUpper ();
+ writer.Write (' ');
+ writer.Write (localName);
+
+ switch (attribute) {
+ case "OPTION":
+ case "CHECKED":
+ return;
+ }
+
+ writer.Write ("=\"");
+ openAttribute = true;
+ WriteFormattedString (value);
+ openAttribute = false;
+ writer.Write ('\"');
+ }
+
+ public override void WriteComment (string text) {
+ writer.Write ("<!--");
+ writer.Write (text);
+ writer.Write ("-->");
+ }
+
+ public override void WriteProcessingInstruction (string name, string text)
+ {
+ if ((text.IndexOf("?>") > 0))
+ throw new ArgumentException ("Processing instruction cannot contain \"?>\" as its value.");
+ writer.Write ("<?");
+ writer.Write (name);
+ if (text != null && text != String.Empty) {
+ writer.Write (' ');
+ writer.Write (text);
+ }
+
+ if (xmlDepth >= 0)
+ writer.Write ("?>");
+ else
+ writer.Write (">"); // HTML PI ends with '>'
+ }
+
+ public override void WriteString (string text)
+ {
+ if (openElement)
+ CloseStartElement ();
+ WriteFormattedString (text);
+ }
+
+ private void WriteFormattedString (string text)
+ {
+ // style and script should not be escaped.
+ if (!openAttribute) {
+ string element = ((string) elementNameStack.Peek ()).ToUpper ();
+ switch (element) {
+ case "SCRIPT":
+ case "STYLE":
+ writer.Write (text);
+ return;
+ }
+ }
+
+ int start = 0;
+ for (int i = 0; i < text.Length; i++) {
+ switch (text [i]) {
+ case '&':
+ // '&' '{' should be "&{", not "&amp;{"
+ if (xmlDepth < 0 && i + 1 < text.Length && text [i + 1] == '{')
+ continue;
+ writer.Write (text.ToCharArray (), start, i - start);
+ writer.Write ("&amp;");
+ start = i;
+ break;
+ case '<':
+ if (openAttribute)
+ continue;
+ writer.Write (text.ToCharArray (), start, i - start);
+ writer.Write ("&lt;");
+ start = i;
+ break;
+ case '>':
+ writer.Write (text.ToCharArray (), start, i - start);
+ writer.Write ("&gt;");
+ start = i;
+ break;
+ case '\'':
+ writer.Write (text.ToCharArray (), start, i - start);
+ writer.Write ("&apos;");
+ start = i;
+ break;
+ case '\"':
+ writer.Write (text.ToCharArray (), start, i - start);
+ writer.Write ("&quot;");
+ start = i;
+ break;
+ }
+ }
+ writer.Write (text.ToCharArray (), start, text.Length - start);
+ }
+
+ public override void WriteRaw (string data)
+ {
+ writer.Write (data);
+ }
+
+ public override void WriteCDataSection (string text) {
+ writer.Write ("<![CDATA[");
+ writer.Write (text);
+ writer.Write ("]]>");
+ }
+
+ public override void Done ()
+ {
+ writer.Flush ();
+ }
+ }
+}
diff --git a/mcs/class/System.XML/Mono.Xml.Xsl/MSXslScriptManager.cs b/mcs/class/System.XML/Mono.Xml.Xsl/MSXslScriptManager.cs
index 1ca0e5fa03c..9a11d970e9d 100644
--- a/mcs/class/System.XML/Mono.Xml.Xsl/MSXslScriptManager.cs
+++ b/mcs/class/System.XML/Mono.Xml.Xsl/MSXslScriptManager.cs
@@ -18,23 +18,14 @@ using System.Xml.Xsl;
namespace Mono.Xml.Xsl {
public class MSXslScriptManager {
- ArrayList jsScripts = new ArrayList ();
- ArrayList vbScripts = new ArrayList ();
- ArrayList csScripts = new ArrayList ();
+ Hashtable scripts = new Hashtable ();
public MSXslScriptManager () {}
public void AddScript (XPathNavigator nav)
{
MSXslScript s = new MSXslScript (nav);
- switch (s.Language) {
- case ScriptingLanguage.JScript:
- jsScripts.Add (s); break;
- case ScriptingLanguage.VisualBasic:
- vbScripts.Add (s); break;
- case ScriptingLanguage.CSharp:
- csScripts.Add (s); break;
- }
+ scripts.Add (s.ImplementsPrefix, s.Compile ());
}
enum ScriptingLanguage {
@@ -43,6 +34,11 @@ namespace Mono.Xml.Xsl {
CSharp
}
+ public object GetExtensionObject (string ns)
+ {
+ return scripts [ns];
+ }
+
class MSXslScript {
ScriptingLanguage language = ScriptingLanguage.JScript; // i think this is the default
string implementsPrefix = null;
@@ -89,6 +85,11 @@ namespace Mono.Xml.Xsl {
public string Code {
get { return code; }
}
+
+ public object Compile ()
+ {
+ throw new NotImplementedException ();
+ }
}
}
}
diff --git a/mcs/class/System.XML/Mono.Xml.Xsl/Outputter.cs b/mcs/class/System.XML/Mono.Xml.Xsl/Outputter.cs
index 3ce2d190451..8b4351e0a46 100644
--- a/mcs/class/System.XML/Mono.Xml.Xsl/Outputter.cs
+++ b/mcs/class/System.XML/Mono.Xml.Xsl/Outputter.cs
@@ -8,6 +8,7 @@
//
using System;
+using System.Xml;
namespace Mono.Xml.Xsl {
/// <summary>
@@ -52,5 +53,9 @@ namespace Mono.Xml.Xsl {
public virtual bool CanProcessAttributes {
get { return false; }
}
+
+ public abstract WriteState WriteState { get; }
+
+ public abstract bool InsideCDataSection { get; set; }
}
}
diff --git a/mcs/class/System.XML/Mono.Xml.Xsl/TextEmitter.cs b/mcs/class/System.XML/Mono.Xml.Xsl/TextEmitter.cs
index f4bea5a9092..2240199b7f5 100644
--- a/mcs/class/System.XML/Mono.Xml.Xsl/TextEmitter.cs
+++ b/mcs/class/System.XML/Mono.Xml.Xsl/TextEmitter.cs
@@ -63,6 +63,10 @@ namespace Mono.Xml.Xsl {
writer.Write (data);
}
+ public override void WriteCDataSection (string text) {
+ writer.Write (text);
+ }
+
public override void Done () {
//Do nothing
}
diff --git a/mcs/class/System.XML/Mono.Xml.Xsl/TextOutputter.cs b/mcs/class/System.XML/Mono.Xml.Xsl/TextOutputter.cs
index e21db5c06e9..95fb08e197b 100644
--- a/mcs/class/System.XML/Mono.Xml.Xsl/TextOutputter.cs
+++ b/mcs/class/System.XML/Mono.Xml.Xsl/TextOutputter.cs
@@ -62,5 +62,9 @@ namespace Mono.Xml.Xsl {
public override void Done () {
_writer.Flush ();
}
+
+ public override WriteState WriteState { get { return WriteState.Start; } }
+
+ public override bool InsideCDataSection { get { return false; } set { } }
}
}
diff --git a/mcs/class/System.XML/Mono.Xml.Xsl/XmlWriterEmitter.cs b/mcs/class/System.XML/Mono.Xml.Xsl/XmlWriterEmitter.cs
index 1babbbd7d4f..cb87c1756c3 100644
--- a/mcs/class/System.XML/Mono.Xml.Xsl/XmlWriterEmitter.cs
+++ b/mcs/class/System.XML/Mono.Xml.Xsl/XmlWriterEmitter.cs
@@ -80,6 +80,11 @@ namespace Mono.Xml.Xsl {
writer.WriteRaw (data);
}
+ public override void WriteCDataSection (string text)
+ {
+ writer.WriteCData (text);
+ }
+
public override void Done ()
{
writer.Flush ();
diff --git a/mcs/class/System.XML/Mono.Xml.Xsl/XslDecimalFormat.cs b/mcs/class/System.XML/Mono.Xml.Xsl/XslDecimalFormat.cs
index 7f8186208fa..11f5dbc3896 100644
--- a/mcs/class/System.XML/Mono.Xml.Xsl/XslDecimalFormat.cs
+++ b/mcs/class/System.XML/Mono.Xml.Xsl/XslDecimalFormat.cs
@@ -21,6 +21,10 @@ namespace Mono.Xml.Xsl {
NumberFormatInfo info = new NumberFormatInfo ();
char digit = '#', zeroDigit = '0', patternSeparator = ';';
+ XPathNavigator source;
+ string baseUri;
+ int lineNumber;
+ int linePosition;
public static readonly XslDecimalFormat Default = new XslDecimalFormat ();
@@ -28,9 +32,17 @@ namespace Mono.Xml.Xsl {
public XslDecimalFormat (Compiler c)
{
XPathNavigator n = c.Input;
+
+ IXmlLineInfo li = n as IXmlLineInfo;
+ if (li != null) {
+ lineNumber = li.LineNumber;
+ linePosition = li.LinePosition;
+ }
+ baseUri = n.BaseURI;
+
if (n.MoveToFirstAttribute ()) {
do {
- if (n.NamespaceURI != Compiler.XsltNamespace)
+ if (n.NamespaceURI != String.Empty)
continue;
switch (n.LocalName) {
@@ -58,10 +70,10 @@ namespace Mono.Xml.Xsl {
case "per-mille":
info.PerMilleSymbol = n.Value;
break;
- case "zero-digit":
+ case "digit":
digit = n.Value [0];
break;
- case "digit":
+ case "zero-digit":
zeroDigit = n.Value [0];
break;
case "pattern-separator":
@@ -74,17 +86,20 @@ namespace Mono.Xml.Xsl {
info.NegativeInfinitySymbol = info.NegativeSign + info.PositiveInfinitySymbol;
}
}
-
- // check that the data in c is the same as this one, as we
- // must do, per the spec.
- public void CheckSameAs (Compiler c)
+
+ // TODO: complete comparison for XSLT spec. 12.3.
+ public void CheckSameAs (XslDecimalFormat other)
{
- throw new NotImplementedException ();
+ if (this.digit != other.digit ||
+ this.patternSeparator != other.patternSeparator ||
+ this.zeroDigit != other.zeroDigit)
+ throw new XsltCompileException (null, other.baseUri, other.lineNumber, other.linePosition);
}
+ // TODO: format pattern check.
public string FormatNumber (double number, string pattern)
{
- throw new NotImplementedException ();
+ return number.ToString (pattern, info);
}
}
} \ No newline at end of file
diff --git a/mcs/class/System.XML/Mono.Xml.Xsl/XslOutput.cs b/mcs/class/System.XML/Mono.Xml.Xsl/XslOutput.cs
index 5c23c7dc51c..d39fcce407a 100644
--- a/mcs/class/System.XML/Mono.Xml.Xsl/XslOutput.cs
+++ b/mcs/class/System.XML/Mono.Xml.Xsl/XslOutput.cs
@@ -50,7 +50,7 @@ namespace Mono.Xml.Xsl
string doctypePublic;
string doctypeSystem;
QName [] cdataSectionElements;
- bool indent;
+ string indent;
string mediaType;
bool escapeUriAttributes;
bool includeContentType;
@@ -97,7 +97,7 @@ namespace Mono.Xml.Xsl
get { return doctypeSystem; }
}
- public QName [] CdataSectionElements {
+ public QName [] CDataSectionElements {
get {
if (cdataSectionElements == null)
cdataSectionElements = cdSectsList.ToArray (typeof (QName)) as QName [];
@@ -105,7 +105,7 @@ namespace Mono.Xml.Xsl
}
}
- public bool Indent {
+ public string Indent {
get { return indent; }
}
@@ -138,11 +138,9 @@ namespace Mono.Xml.Xsl
{
string att;
- // cdata-section-elements
- // FILL IN
- // att = nav.GetAttribute ("cdata-section-elements", "");
- // if (att != null)
- // cdSectsList.AddRange (XslNameUtil.ParseQNames (att, nav));
+ att = nav.GetAttribute ("cdata-section-elements", "");
+ if (att != String.Empty)
+ cdSectsList.AddRange (XslNameUtil.FromListString (att, nav));
att = nav.GetAttribute ("method", "");
@@ -200,7 +198,7 @@ namespace Mono.Xml.Xsl
att = nav.GetAttribute ("indent", "");
if (att != String.Empty)
- this.indent = att == "yes";
+ this.indent = att;
}
}
diff --git a/mcs/class/System.XML/Mono.Xml.Xsl/XslStylesheet.cs b/mcs/class/System.XML/Mono.Xml.Xsl/XslStylesheet.cs
index acd011c64ec..e17e5c20cf8 100644
--- a/mcs/class/System.XML/Mono.Xml.Xsl/XslStylesheet.cs
+++ b/mcs/class/System.XML/Mono.Xml.Xsl/XslStylesheet.cs
@@ -8,128 +8,149 @@
// (C) 2003 Ben Maurer
// (C) 2003 Atsushi Enomoto
//
-
-using System;
-using System.CodeDom;
+
+using System;
+using System.CodeDom;
using System.Collections;
-using System.Collections.Specialized;
-using System.Xml;
-using System.Xml.Schema;
-using System.Xml.XPath;
+using System.Collections.Specialized;
+using System.Xml;
+using System.Xml.Schema;
+using System.Xml.XPath;
using System.Xml.Xsl;
using System.IO;
using Mono.Xml.Xsl.Operations;
-
-using QName = System.Xml.XmlQualifiedName;
-
-namespace Mono.Xml.Xsl {
-
- public class XslStylesheet {
- public const string XsltNamespace = "http://www.w3.org/1999/XSL/Transform";
- public const string MSXsltNamespace = "urn:schemas-microsoft-com:xslt::script";
+
+using QName = System.Xml.XmlQualifiedName;
+
+namespace Mono.Xml.Xsl {
+
+ public class XslStylesheet {
+ public const string XsltNamespace = "http://www.w3.org/1999/XSL/Transform";
+ public const string MSXsltNamespace = "urn:schemas-microsoft-com:xslt";
- Compiler c;
-
- XslStylesheet importer;
- // Top-level elements
- ArrayList imports = new ArrayList ();
- // [QName]=>XmlSpace
- Hashtable spaceControls = new Hashtable ();
- // [string stylesheet-prefix]=>string result-prefix
- Hashtable namespaceAliases = new Hashtable ();
- // [QName]=>XmlSpace
- Hashtable parameters = new Hashtable ();
-
- MSXslScriptManager msScripts = new MSXslScriptManager ();
- XslTemplateTable templates;
-
- // stylesheet attributes
- string version;
- XmlQualifiedName [] extensionElementPrefixes;
- XmlQualifiedName [] excludeResultPrefixes;
- StringDictionary stylesheetNamespaces = new StringDictionary ();
-
- // below are newly introduced in XSLT 2.0
- // elements::
- // xsl:import-schema should be interpreted into it.
- XmlSchemaCollection schemas = new XmlSchemaCollection ();
- // [QName]=>XslCharacterMap
- Hashtable characterMap = new Hashtable ();
- // [QName]=>XslDateFormat
- Hashtable dateFormats = new Hashtable ();
- // [QName]=>XslFunction
- Hashtable functions = new Hashtable ();
- // [QName]=>XslSortKey
- Hashtable sortKeys = new Hashtable ();
- // attributes::
- string xpathDefaultNamespace = "";
- XslDefaultValidation defaultValidation = XslDefaultValidation.Lax;
-
- public XmlQualifiedName [] ExtensionElementPrefixes {
- get { return extensionElementPrefixes; }
- }
-
- public XmlQualifiedName [] ExcludeResultPrefixes {
- get { return excludeResultPrefixes; }
- }
-
- public StringDictionary StylesheetNamespaces {
- get { return stylesheetNamespaces; }
- }
-
- public ArrayList Imports {
- get { return imports; }
- }
-
- public Hashtable SpaceControls {
- get { return spaceControls; }
- }
-
- public Hashtable NamespaceAliases {
- get { return namespaceAliases; }
- }
-
- public Hashtable Parameters {
- get { return parameters; }
- }
-
- public MSXslScriptManager ScriptManager{
- get { return msScripts; }
- }
-
- public XslTemplateTable Templates {
- get { return templates; }
- }
-
-
- public XslStylesheet (Compiler c)
+ Compiler c;
+
+ XslStylesheet importer;
+ // Top-level elements
+ ArrayList imports = new ArrayList ();
+ // [QName]=>XmlSpace
+ Hashtable spaceControls = new Hashtable ();
+ // [string stylesheet-prefix]=>string result-prefix
+ Hashtable namespaceAliases = new Hashtable ();
+ // [QName]=>XmlSpace
+ Hashtable parameters = new Hashtable ();
+ // [QName]=>XslKey
+ Hashtable keys = new Hashtable();
+
+ XslTemplateTable templates;
+
+ // stylesheet attributes
+ string version;
+ XmlQualifiedName [] extensionElementPrefixes;
+ XmlQualifiedName [] excludeResultPrefixes;
+ ArrayList stylesheetNamespaces = new ArrayList ();
+
+ // below are newly introduced in XSLT 2.0
+ // elements::
+ // xsl:import-schema should be interpreted into it.
+ XmlSchemaCollection schemas = new XmlSchemaCollection ();
+ // [QName]=>XslCharacterMap
+ Hashtable characterMap = new Hashtable ();
+ // [QName]=>XslDateFormat
+ Hashtable dateFormats = new Hashtable ();
+ // [QName]=>XslFunction
+ Hashtable functions = new Hashtable ();
+ // [QName]=>XslSortKey
+ Hashtable sortKeys = new Hashtable ();
+ // attributes::
+ string xpathDefaultNamespace = "";
+ XslDefaultValidation defaultValidation = XslDefaultValidation.Lax;
+
+ public string BaseUri {
+ get { return c.Input.BaseURI; }
+ }
+
+ public XmlQualifiedName [] ExtensionElementPrefixes {
+ get { return extensionElementPrefixes; }
+ }
+
+ public XmlQualifiedName [] ExcludeResultPrefixes {
+ get { return excludeResultPrefixes; }
+ }
+
+ public ArrayList StylesheetNamespaces {
+ get { return stylesheetNamespaces; }
+ }
+
+ public ArrayList Imports {
+ get { return imports; }
+ }
+
+ public Hashtable SpaceControls {
+ get { return spaceControls; }
+ }
+
+ public Hashtable NamespaceAliases {
+ get { return namespaceAliases; }
+ }
+
+ public Hashtable Parameters {
+ get { return parameters; }
+ }
+
+ public XPathNavigator StyleDocument {
+ get { return c.Input; }
+ }
+
+ public XslTemplateTable Templates {
+ get { return templates; }
+ }
+
+ public Hashtable Keys {
+ get { return keys; }
+ }
+
+ public XslStylesheet (Compiler c)
{
this.c = c;
c.PushStylesheet (this);
- templates = new XslTemplateTable (this);
- if (c.Input.NamespaceURI != XsltNamespace) {
- // then it is simplified stylesheet.
- Templates.Add (new XslTemplate (c));
- } else {
- version = c.Input.GetAttribute ("version", "");
- extensionElementPrefixes = c.ParseQNameListAttribute ("extension-element-prefixes");
- excludeResultPrefixes = c.ParseQNameListAttribute ("exclude-result-prefixes");
+ templates = new XslTemplateTable (this);
+ if (c.Input.NamespaceURI != XsltNamespace) {
+ // then it is simplified stylesheet.
+ Templates.Add (new XslTemplate (c));
+ } else {
+ version = c.Input.GetAttribute ("version", "");
+ extensionElementPrefixes = c.ParseQNameListAttribute ("extension-element-prefixes");
+ excludeResultPrefixes = c.ParseQNameListAttribute ("exclude-result-prefixes");
if (c.Input.MoveToFirstNamespace (XPathNamespaceScope.Local)) {
do {
if (c.Input.Value == XsltNamespace)
continue;
- this.stylesheetNamespaces.Add (c.Input.Name, c.Input.Value);
+ this.stylesheetNamespaces.Insert (0, new QName (c.Input.Name, c.Input.Value));
} while (c.Input.MoveToNextNamespace (XPathNamespaceScope.Local));
c.Input.MoveToParent ();
}
- ProcessTopLevelElements ();
+ ProcessTopLevelElements ();
}
- c.PopStylesheet ();
+ c.PopStylesheet ();
}
+ public XslKey FindKey (QName name)
+ {
+ XslKey key = Keys [name] as XslKey;
+ if (key != null)
+ return key;
+ for (int i = Imports.Count - 1; i >= 0; i--) {
+ key = ((XslStylesheet) Imports [i]).FindKey (name);
+ if (key != null)
+ return key;
+ }
+ return null;
+ }
+
private XslStylesheet (Compiler c, XslStylesheet importer) : this (c)
{
this.importer = importer;
@@ -181,7 +202,7 @@ namespace Mono.Xml.Xsl {
break;
case "key":
- c.AddKeyPattern (new XslKey (c));
+ keys.Add (c.ParseQNameAttribute ("name"), new XslKey (c));
break;
case "output":
@@ -207,16 +228,16 @@ namespace Mono.Xml.Xsl {
switch (n.LocalName)
{
case "script":
- msScripts.AddScript (n);
+ c.ScriptManager.AddScript (n);
break;
}
break;
}
}
-
- private void ProcessTopLevelElements ()
+
+ private void ProcessTopLevelElements ()
{
- if (c.Input.MoveToFirstChild ()) {
+ if (c.Input.MoveToFirstChild ()) {
do {
if (c.Input.NodeType == XPathNodeType.Element) {
Debug.EnterNavigator (c);
@@ -226,23 +247,58 @@ namespace Mono.Xml.Xsl {
} while (c.Input.MoveToNext ());
c.Input.MoveToParent ();
- }
- }
-
- private void AddSpaceControls (QName [] names, XmlSpace result, XPathNavigator styleElem)
- {
- foreach (QName name in names)
- spaceControls.Add (name, result);
- }
-
- }
-
-
- public enum XslDefaultValidation
- {
- Strict,
- Lax,
- Preserve,
- Strip
- }
-}
+ }
+ }
+
+ private void AddSpaceControls (QName [] names, XmlSpace result, XPathNavigator styleElem)
+ {
+ foreach (QName name in names)
+ spaceControls.Add (name, result);
+ }
+
+ public string PrefixInEffect (string prefix, ArrayList additionalExcluded)
+ {
+ if (additionalExcluded != null && additionalExcluded.Contains (prefix == String.Empty ? "#default" : prefix))
+ return null;
+ if (prefix == "#default")
+ prefix = String.Empty;
+
+ if (ExcludeResultPrefixes != null) {
+ bool exclude = false;
+ foreach (XmlQualifiedName exc in ExcludeResultPrefixes)
+ if (exc.Name == "#default" && prefix == String.Empty || exc.Name == prefix) {
+ exclude = true;
+ break;
+ }
+ if (exclude)
+ return null;
+ }
+
+ if (ExtensionElementPrefixes != null) {
+ bool exclude = false;
+ foreach (XmlQualifiedName exc in ExtensionElementPrefixes)
+ if (exc.Name == "#default" && prefix == String.Empty || exc.Name == prefix) {
+ exclude = true;
+ break;
+ }
+ if (exclude)
+ return null;
+ }
+
+ string alias = NamespaceAliases [prefix] as string;
+ if (alias != null)
+ return alias;
+
+ return prefix;
+ }
+ }
+
+
+ public enum XslDefaultValidation
+ {
+ Strict,
+ Lax,
+ Preserve,
+ Strip
+ }
+}
diff --git a/mcs/class/System.XML/Mono.Xml.Xsl/XslTransformProcessor.cs b/mcs/class/System.XML/Mono.Xml.Xsl/XslTransformProcessor.cs
index 16655c006c3..2c05e68a665 100644
--- a/mcs/class/System.XML/Mono.Xml.Xsl/XslTransformProcessor.cs
+++ b/mcs/class/System.XML/Mono.Xml.Xsl/XslTransformProcessor.cs
@@ -23,6 +23,8 @@ using QName = System.Xml.XmlQualifiedName;
namespace Mono.Xml.Xsl {
public class XslTransformProcessor {
+ static char [] wsChars = new char [] {' ', '\t', '\n', '\r'};
+
CompiledStylesheet compiledStyle;
XslStylesheet style;
@@ -34,6 +36,8 @@ namespace Mono.Xml.Xsl {
XsltArgumentList args;
XmlResolver resolver;
bool outputStylesheetXmlns;
+ bool insideCDataSectionElements;
+ string currentOutputUri;
internal readonly XsltCompiledContext XPathContext;
@@ -53,8 +57,10 @@ namespace Mono.Xml.Xsl {
this.root = root;
this.resolver = resolver != null ? resolver : new XmlUrlResolver ();
this.outputStylesheetXmlns = true;
+ this.currentOutputUri = String.Empty;
- PushNodeset (root.Select ("."));
+ XPathExpression exp = root.Compile (".");
+ PushNodeset (root.Select (exp, this.XPathContext));
foreach (XslGlobalVariable v in CompiledStyle.Variables.Values) {
if (args != null && v is XslGlobalParam) {
@@ -70,7 +76,7 @@ namespace Mono.Xml.Xsl {
PopNodeset ();
this.PushOutput (outputtter);
- this.ApplyTemplates (root.Select ("."), QName.Empty, null);
+ this.ApplyTemplates (root.Select (exp, this.XPathContext), QName.Empty, null);
this.PopOutput ();
}
@@ -78,6 +84,11 @@ namespace Mono.Xml.Xsl {
public CompiledStylesheet CompiledStyle { get { return compiledStyle; }}
public XsltArgumentList Arguments {get{return args;}}
+ public MSXslScriptManager ScriptManager {
+ get { return compiledStyle.ScriptManager; }
+ }
+
+
#region Document Resolution
public XmlResolver Resolver {get{return resolver;}}
@@ -96,7 +107,7 @@ namespace Mono.Xml.Xsl {
}
XmlReader rdr = new XmlTextReader (uri.ToString(), (Stream) resolver.GetEntity (uri, null, null));
- result = new XPathDocument (rdr).CreateNavigator ();
+ result = new XPathDocument (rdr, XmlSpace.Preserve).CreateNavigator ();
rdr.Close ();
docCache [uri] = result.Clone ();
@@ -123,6 +134,12 @@ namespace Mono.Xml.Xsl {
}
public Hashtable Outputs { get { return compiledStyle.Outputs; }}
+
+ public XslOutput Output { get { return Outputs [currentOutputUri] as XslOutput; } }
+
+ public string CurrentOutputUri { get { return currentOutputUri; } }
+
+ public bool InsideCDataElement { get { return insideCDataSectionElements; } }
#endregion
#region AVT StringBuilder
@@ -259,21 +276,19 @@ namespace Mono.Xml.Xsl {
currentTemplateStack.Pop ();
}
- internal void TryStylesheetNamespaceOutput ()
+ internal void TryStylesheetNamespaceOutput (ArrayList excluded)
{
if (outputStylesheetXmlns) {
- foreach (string prefix in this.style.StylesheetNamespaces.Keys) {
- if (style.ExcludeResultPrefixes != null) {
- bool exclude = false;
- foreach (XmlQualifiedName exc in style.ExcludeResultPrefixes)
- if (exc.Name == "#default" && prefix == String.Empty || exc.Name == prefix) {
- exclude = true;
- break;
- }
- if (exclude)
- continue;
- }
- Out.WriteNamespaceDecl (prefix, this.style.StylesheetNamespaces [prefix]);
+ foreach (XmlQualifiedName qname in this.style.StylesheetNamespaces) {
+ string prefix = style.PrefixInEffect (qname.Name, excluded);
+ if (prefix == null)
+ continue;
+ else if (prefix == qname.Name)
+ Out.WriteNamespaceDecl (
+ prefix == "#default" ? String.Empty : prefix,
+ qname.Namespace);
+ else
+ Out.WriteNamespaceDecl (prefix, style.StyleDocument.GetNamespace (prefix));
}
outputStylesheetXmlns = false;
}
@@ -317,7 +332,6 @@ namespace Mono.Xml.Xsl {
}
#endregion
-
public void PushForEachContext ()
{
@@ -367,7 +381,8 @@ namespace Mono.Xml.Xsl {
public object Evaluate (XPathExpression expr)
{
expr = CompiledStyle.ExpressionStore.PrepForExecution (expr, this);
-
+ expr.SetContext (XPathContext);
+
XPathNodeIterator itr = CurrentNodeset;
return itr.Current.Evaluate (expr, itr, XPathContext);
}
@@ -375,6 +390,7 @@ namespace Mono.Xml.Xsl {
public string EvaluateString (XPathExpression expr)
{
expr = CompiledStyle.ExpressionStore.PrepForExecution (expr, this);
+ expr.SetContext (XPathContext);
XPathNodeIterator itr = CurrentNodeset;
return itr.Current.EvaluateString (expr, itr, XPathContext);
@@ -383,6 +399,7 @@ namespace Mono.Xml.Xsl {
public bool EvaluateBoolean (XPathExpression expr)
{
expr = CompiledStyle.ExpressionStore.PrepForExecution (expr, this);
+ expr.SetContext (XPathContext);
XPathNodeIterator itr = CurrentNodeset;
return itr.Current.EvaluateBoolean (expr, itr, XPathContext);
@@ -391,6 +408,7 @@ namespace Mono.Xml.Xsl {
public double EvaluateNumber (XPathExpression expr)
{
expr = CompiledStyle.ExpressionStore.PrepForExecution (expr, this);
+ expr.SetContext (XPathContext);
XPathNodeIterator itr = CurrentNodeset;
return itr.Current.EvaluateNumber (expr, itr, XPathContext);
@@ -399,6 +417,7 @@ namespace Mono.Xml.Xsl {
public XPathNodeIterator Select (XPathExpression expr)
{
expr = CompiledStyle.ExpressionStore.PrepForExecution (expr, this);
+ expr.SetContext (XPathContext);
return CurrentNodeset.Current.Select (expr, XPathContext);
}
@@ -455,6 +474,26 @@ namespace Mono.Xml.Xsl {
return busyTable [o] == busyObject;
}
#endregion
-
+
+ public bool PushCDataState (string name, string ns)
+ {
+ if (insideCDataSectionElements)
+ return false;
+ for (int i = 0; i < Output.CDataSectionElements.Length; i++) {
+ XmlQualifiedName qname = Output.CDataSectionElements [i];
+ if (qname.Name == name && qname.Namespace == ns) {
+ this.insideCDataSectionElements = true;
+ Out.InsideCDataSection = true;
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public void PopCDataState ()
+ {
+ Out.InsideCDataSection = false;
+ this.insideCDataSectionElements = false;
+ }
}
}
diff --git a/mcs/class/System.XML/Mono.Xml.Xsl/XsltCompiledContext.cs b/mcs/class/System.XML/Mono.Xml.Xsl/XsltCompiledContext.cs
index 7c1e4769a60..a1e3a7590d6 100644
--- a/mcs/class/System.XML/Mono.Xml.Xsl/XsltCompiledContext.cs
+++ b/mcs/class/System.XML/Mono.Xml.Xsl/XsltCompiledContext.cs
@@ -51,25 +51,35 @@ namespace Mono.Xml.Xsl {
string ns = name.Namespace;
- if (ns == null || p.Arguments == null) return null;
+ if (ns == null) return null;
- object extension = p.Arguments.GetExtensionObject (ns);
+ object extension = null;
+
+ if (p.Arguments != null)
+ extension = p.Arguments.GetExtensionObject (ns);
+
+ bool isScript = false;
+ if (extension == null) {
+ extension = p.ScriptManager.GetExtensionObject (ns);
+ if (extension == null)
+ return null;
- if (extension == null)
- return null;
+ isScript = true;
+ }
+
- MethodInfo method = FindBestMethod (extension.GetType (), name.Name, argTypes);
+ MethodInfo method = FindBestMethod (extension.GetType (), name.Name, argTypes, isScript);
if (method != null)
return new XsltExtensionFunction (extension, method);
return null;
}
- MethodInfo FindBestMethod (Type t, string name, XPathResultType [] argTypes)
+ MethodInfo FindBestMethod (Type t, string name, XPathResultType [] argTypes, bool isScript)
{
int free, length;
- MethodInfo [] mi = t.GetMethods (BF.Public | BF.Instance | BF.Static);
+ MethodInfo [] mi = t.GetMethods ((isScript ? BF.Public | BF.NonPublic : BF.Public) | BF.Instance | BF.Static);
if (mi.Length == 0)
return null;
@@ -317,7 +327,7 @@ namespace Mono.Xml.Xsl.Functions {
Hashtable got = new Hashtable ();
while (itr.MoveNext()) {
- Uri uri = Resolve (itr.Current.Value, baseUri != null ? baseUri : itr.Current.BaseURI, xsltContext.Processor);
+ Uri uri = Resolve (itr.Current.Value, baseUri != null ? baseUri : /*itr.Current.BaseURI*/doc.BaseURI, xsltContext.Processor);
if (!got.ContainsKey (uri)) {
got.Add (uri, null);
if (uri.ToString () == "") {
@@ -342,7 +352,7 @@ namespace Mono.Xml.Xsl.Functions {
} else
n = xsltContext.Processor.GetDocument (uri);
- return new SelfIterator (n, null);
+ return new SelfIterator (n, xsltContext);
}
}
@@ -506,7 +516,7 @@ namespace Mono.Xml.Xsl.Functions {
}
}
- public override XPathResultType ReturnType { get { return XPathResultType.NodeSet; }}
+ public override XPathResultType ReturnType { get { return XPathResultType.String; }}
public override object Evaluate (BaseIterator iter)
{
XPathNavigator n;
@@ -522,7 +532,9 @@ namespace Mono.Xml.Xsl.Functions {
StringBuilder sb = new StringBuilder ("Mono"); // Ensure begins with alpha
sb.Append (XmlConvert.EncodeLocalName (n.BaseURI));
sb.Replace ('_', 'm'); // remove underscores from EncodeLocalName
-
+ sb.Append (n.NodeType);
+ sb.Append ('m');
+
do {
sb.Append (IndexInParent (n));
sb.Append ('m');
@@ -533,8 +545,6 @@ namespace Mono.Xml.Xsl.Functions {
int IndexInParent (XPathNavigator nav)
{
- nav = nav.Clone();
-
int n = 0;
while (nav.MoveToPrevious ())
n++;
@@ -552,11 +562,13 @@ namespace Mono.Xml.Xsl.Functions {
{
if (args == null || args.Tail == null)
throw new XPathException ("key takes 2 args");
-
arg0 = args.Arg;
arg1 = args.Tail.Arg;
nsm = ctx.GetNsm ();
}
+ public Expression KeyName { get { return arg0; } }
+ public Expression Field { get { return arg1; } }
+ public XmlNamespaceManager NamespaceManager { get { return nsm; } }
public override XPathResultType ReturnType { get { return XPathResultType.NodeSet; }}
public override object Evaluate (BaseIterator iter)
@@ -580,22 +592,21 @@ namespace Mono.Xml.Xsl.Functions {
{
XPathNavigator searchDoc = context.Clone ();
searchDoc.MoveToRoot ();
- foreach (XslKey key in xsltContext.Processor.CompiledStyle.Keys) {
- if (key.Name == name) {
- XPathNodeIterator desc = searchDoc.SelectDescendants (XPathNodeType.All, true);
+ XslKey key = xsltContext.Processor.CompiledStyle.Style.FindKey (name);
+ if (key != null) {
+ XPathNodeIterator desc = searchDoc.SelectDescendants (XPathNodeType.All, true);
- while (desc.MoveNext ()) {
- if (key.Matches (desc.Current, value))
- AddResult (result, desc.Current);
+ while (desc.MoveNext ()) {
+ if (key.Matches (desc.Current, value))
+ AddResult (result, desc.Current);
+
+ if (desc.Current.MoveToFirstAttribute ()) {
+ do {
+ if (key.Matches (desc.Current, value))
+ AddResult (result, desc.Current);
+ } while (desc.Current.MoveToNextAttribute ());
- if (desc.Current.MoveToFirstAttribute ()) {
- do {
- if (key.Matches (desc.Current, value))
- AddResult (result, desc.Current);
- } while (desc.Current.MoveToNext ());
-
- desc.Current.MoveToParent ();
- }
+ desc.Current.MoveToParent ();
}
}
}
@@ -661,7 +672,18 @@ namespace Mono.Xml.Xsl.Functions {
public override XPathResultType ReturnType { get { return XPathResultType.String; }}
public override object Evaluate (BaseIterator iter)
{
- throw new NotImplementedException ();
+ IHasXmlNode xn = iter.Current as IHasXmlNode;
+ if (xn == null)
+ return String.Empty;
+ XmlNode n = xn.GetNode ();
+ XmlDocumentType doctype = n.OwnerDocument.DocumentType;
+ if (doctype == null)
+ return String.Empty;
+ XmlEntity ent = doctype.Entities.GetNamedItem (arg0.EvaluateString (iter)) as XmlEntity;
+ if (ent == null)
+ return String.Empty;
+ else
+ return ent.BaseURI;
}
}
} \ No newline at end of file
diff --git a/mcs/class/System.XML/System.Xml.Schema/ChangeLog b/mcs/class/System.XML/System.Xml.Schema/ChangeLog
index 243191f3f75..997e98a6a28 100755
--- a/mcs/class/System.XML/System.Xml.Schema/ChangeLog
+++ b/mcs/class/System.XML/System.Xml.Schema/ChangeLog
@@ -1,3 +1,8 @@
+2003-11-17 Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
+
+ * XmlSchemaSet.cs, XmlSchemaBuiltInType.cs : Added .NET 1.2 classes
+ (for convenience of ObjectSpaces stubbing).
+
2003-10-25 Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
* BuiltInDatatype.cs : XsdByte was incorrectly typed as byte, while
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaBuiltInType.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaBuiltInType.cs
new file mode 100644
index 00000000000..4b2ea34a522
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaBuiltInType.cs
@@ -0,0 +1,62 @@
+//
+// XmlSchemaBuiltInType.cs
+//
+// Author:
+// Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
+//
+#if NET_1_2
+
+namespace System.Xml.Schema
+{
+ public enum XmlSchemaBuiltInType
+ {
+ None,
+ AnyType,
+ AnySimpleType,
+ String,
+ Bool,
+ Float,
+ Double,
+ Decimal,
+ Duration,
+ AnyUri,
+ Base64Binary,
+ Byte,
+ Date,
+ DateTime,
+ GDay,
+ GMonth,
+ GMonthDay,
+ GYear,
+ GYearMonth,
+ HexBinary,
+ Entities,
+ Entity,
+ Id,
+ Idref,
+ Idrefs,
+ Int,
+ Integer,
+ Language,
+ Long,
+ Name,
+ NCName,
+ NegativeInteger,
+ NmToken,
+ NmTokens,
+ NonNegativeInteger,
+ NonPositiveInteger,
+ Normalizedstring,
+ Notation,
+ PositiveInteger,
+ QName,
+ Short,
+ Time,
+ Token,
+ UnsignedByte,
+ UnsignedInt,
+ UnsignedLong,
+ UnsignedShort
+ }
+}
+#endif
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaSet.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaSet.cs
new file mode 100644
index 00000000000..352149082cb
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaSet.cs
@@ -0,0 +1,120 @@
+//
+// XmlSchemaSet.cs
+//
+// Author:
+// Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
+//
+// (C)2003 Atsushi Enomoto
+//
+#if NET_1_2
+
+using System;
+using System.Collections;
+using System.Collections.Specialized;
+using System.ComponentModel;
+using System.IO;
+using System.Security.Policy;
+using System.Xml.Schema;
+using System.Xml.XPath;
+
+namespace System.Xml.Schema
+{
+ public class XmlSchemaSet
+ {
+ public int Count {
+ get { throw new NotImplementedException (); }
+ }
+
+ public XmlSchemaObjectTable GlobalAttributes {
+ get { throw new NotImplementedException (); }
+ }
+
+ public XmlSchemaObjectTable GlobalElements {
+ get { throw new NotImplementedException (); }
+ }
+
+ public XmlSchemaObjectTable GlobalTypes {
+ get { throw new NotImplementedException (); }
+ }
+
+ public bool IsCompiled {
+ get { throw new NotImplementedException (); }
+ }
+
+ public XmlNameTable NameTable {
+ get { throw new NotImplementedException (); }
+ }
+
+ public XmlResolver XmlResolver {
+ set { throw new NotImplementedException (); }
+ }
+
+
+ public XmlSchema Add (string targetNamespace, string url)
+ {
+ throw new NotImplementedException ();
+ }
+
+ public XmlSchema Add (string targetNamespace, XmlReader reader)
+ {
+ throw new NotImplementedException ();
+ }
+
+ public void Add (XmlSchemaSet schemaSet)
+ {
+ throw new NotImplementedException ();
+ }
+
+ public XmlSchema Add (XmlSchema schema)
+ {
+ throw new NotImplementedException ();
+ }
+
+ public void Compile ()
+ {
+ throw new NotImplementedException ();
+ }
+
+ public bool Contains (string targetNamespace)
+ {
+ throw new NotImplementedException ();
+ }
+
+ public bool Contains (XmlSchema targetNamespace)
+ {
+ throw new NotImplementedException ();
+ }
+
+ public void CopyTo (XmlSchema[] array, int index)
+ {
+ throw new NotImplementedException ();
+ }
+
+ public XmlSchema Remove (XmlSchema schema)
+ {
+ throw new NotImplementedException ();
+ }
+
+ public ArrayList Schemas ()
+ {
+ throw new NotImplementedException ();
+ }
+
+ public ArrayList Schemas (string targetNamespace)
+ {
+ throw new NotImplementedException ();
+ }
+
+ public XmlSchemaSet ()
+ {
+ throw new NotImplementedException ();
+ }
+
+ public XmlSchemaSet (XmlNameTable nameTable)
+ {
+ throw new NotImplementedException ();
+ }
+ }
+}
+
+#endif
diff --git a/mcs/class/System.XML/System.Xml.Serialization/ChangeLog b/mcs/class/System.XML/System.Xml.Serialization/ChangeLog
index 7234d63c50f..99e5f28e9b4 100755
--- a/mcs/class/System.XML/System.Xml.Serialization/ChangeLog
+++ b/mcs/class/System.XML/System.Xml.Serialization/ChangeLog
@@ -1,3 +1,25 @@
+2003-11-27 Lluis Sanchez Gual <lluis@ximian.com>
+
+ * XmlSerializationReader.cs: Generate identifiers for arrays user a counter.
+ delayedListFixups.Count cannot be used because elementes from
+ delayedListFixups are deleted sometimes.
+
+2003-11-27 Lluis Sanchez Gual <lluis@ximian.com>
+
+ * XmlReflectionImporter.cs: Indexer properties must not be serialized.
+ This fixes bug #51060.
+
+2003-11-24 Lluis Sanchez Gual <lluis@ximian.com>
+
+ * XmlSerializationWriterInterpreter.cs: Applied patch by Eran Domb:
+ If type is Enum the code use type.GetElememtType() instead of
+ Enum.GetUnderlyingType().
+
+2003-11-12 Lluis Sanchez Gual <lluis@ximian.com>
+
+ * XmlSerializationReader.cs, XmlSerializationWriter.cs, XmlSerializer.cs:
+ Removed several TODOs already done.
+
2003-11-03 Lluis Sanchez Gual <lluis@ximian.com>
* XmlCustomFormatter.cs: Added support for anyUri type. This fixes
diff --git a/mcs/class/System.XML/System.Xml.Serialization/XmlReflectionImporter.cs b/mcs/class/System.XML/System.Xml.Serialization/XmlReflectionImporter.cs
index 7d8223c495c..b10e5abc4d8 100644
--- a/mcs/class/System.XML/System.Xml.Serialization/XmlReflectionImporter.cs
+++ b/mcs/class/System.XML/System.Xml.Serialization/XmlReflectionImporter.cs
@@ -453,6 +453,7 @@ namespace System.Xml.Serialization {
if (!prop.CanRead) continue;
if (!prop.CanWrite && TypeTranslator.GetTypeData (prop.PropertyType).SchemaType != SchemaTypes.Array)
continue;
+ if (prop.GetIndexParameters().Length > 0) continue;
XmlAttributes atts = attributeOverrides[type, prop.Name];
if (atts == null) atts = new XmlAttributes (prop);
diff --git a/mcs/class/System.XML/System.Xml.Serialization/XmlSerializationReader.cs b/mcs/class/System.XML/System.Xml.Serialization/XmlSerializationReader.cs
index b4714e57853..1410f6c47cf 100644
--- a/mcs/class/System.XML/System.Xml.Serialization/XmlSerializationReader.cs
+++ b/mcs/class/System.XML/System.Xml.Serialization/XmlSerializationReader.cs
@@ -30,6 +30,7 @@ namespace System.Xml.Serialization {
Hashtable targets;
Hashtable delayedListFixups;
XmlSerializer eventSource;
+ int delayedFixupId = 0;
string w3SchemaNS;
string w3SchemaNS2000;
@@ -270,7 +271,6 @@ namespace System.Xml.Serialization {
return targets.ContainsKey (id);
}
- [MonoTODO ("Implement")]
protected XmlQualifiedName GetXsiType ()
{
string typeName = Reader.GetAttribute ("xsi:type");
@@ -568,7 +568,7 @@ namespace System.Xml.Serialization {
if (qname == arrayQName || arrayType != null)
{
delayedListFixups = EnsureHashtable (delayedListFixups);
- fixupReference = "__<" + delayedListFixups.Count + ">";
+ fixupReference = "__<" + (delayedFixupId++) + ">";
object items;
ReadList (out items);
delayedListFixups [fixupReference] = items;
diff --git a/mcs/class/System.XML/System.Xml.Serialization/XmlSerializationWriter.cs b/mcs/class/System.XML/System.Xml.Serialization/XmlSerializationWriter.cs
index cfaa8c47be3..f0d26ef07ac 100644
--- a/mcs/class/System.XML/System.Xml.Serialization/XmlSerializationWriter.cs
+++ b/mcs/class/System.XML/System.Xml.Serialization/XmlSerializationWriter.cs
@@ -198,7 +198,6 @@ namespace System.Xml.Serialization {
return prefix;
}
- [MonoTODO ("Need to check for namespace conflicts before blindly allocating qN")]
private string GetQualifiedName (string name, string ns)
{
string prefix = GetNamespacePrefix (ns);
@@ -327,7 +326,6 @@ namespace System.Xml.Serialization {
WriteElementString (localName, String.Empty, value, xsiType);
}
- [MonoTODO ("Implement")]
protected void WriteElementString (string localName, string ns, string value, XmlQualifiedName xsiType)
{
if (value == null) return;
@@ -379,7 +377,6 @@ namespace System.Xml.Serialization {
throw new NotImplementedException ();
}
- [MonoTODO ("Implement")]
protected void WriteElementStringRaw (string localName, string ns, string value, XmlQualifiedName xsiType)
{
localName = XmlCustomFormatter.FromXmlNCName (localName);
@@ -397,7 +394,6 @@ namespace System.Xml.Serialization {
WriteEmptyTag (name, String.Empty);
}
- [MonoTODO ("Verify")]
protected void WriteEmptyTag (string name, string ns)
{
name = XmlCustomFormatter.FromXmlName (name);
diff --git a/mcs/class/System.XML/System.Xml.Serialization/XmlSerializationWriterInterpreter.cs b/mcs/class/System.XML/System.Xml.Serialization/XmlSerializationWriterInterpreter.cs
index 2fb2c1e2a60..7053debe42a 100644
--- a/mcs/class/System.XML/System.Xml.Serialization/XmlSerializationWriterInterpreter.cs
+++ b/mcs/class/System.XML/System.Xml.Serialization/XmlSerializationWriterInterpreter.cs
@@ -262,7 +262,8 @@ namespace System.Xml.Serialization
if (val != null && val.GetType().IsEnum)
{
if (val.Equals (member.DefaultValue)) return false;
- val = Convert.ChangeType (val, val.GetType().GetElementType ());
+ Type t = Enum.GetUnderlyingType(val.GetType());
+ val = Convert.ChangeType (val, t);
}
if (val != null && val.Equals (member.DefaultValue)) return false;
}
diff --git a/mcs/class/System.XML/System.Xml.Serialization/XmlSerializer.cs b/mcs/class/System.XML/System.Xml.Serialization/XmlSerializer.cs
index cb9c9949f15..13b7f7ce7bc 100644
--- a/mcs/class/System.XML/System.Xml.Serialization/XmlSerializer.cs
+++ b/mcs/class/System.XML/System.Xml.Serialization/XmlSerializer.cs
@@ -146,7 +146,6 @@ namespace System.Xml.Serialization
#region Methods
- [MonoTODO ("Implement.")]
public virtual bool CanDeserialize (XmlReader xmlReader)
{
xmlReader.MoveToContent ();
diff --git a/mcs/class/System.XML/System.Xml.XPath/ChangeLog b/mcs/class/System.XML/System.Xml.XPath/ChangeLog
index f7b9b7d1eed..a6cae1751e4 100644
--- a/mcs/class/System.XML/System.Xml.XPath/ChangeLog
+++ b/mcs/class/System.XML/System.Xml.XPath/ChangeLog
@@ -1,3 +1,63 @@
+2003-11-28 Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
+
+ * Expression.cs : namespace axis now traversed in reverse order, so it
+ requires sorting.
+ * Iterator.cs : UnionIterator.Clone() was incomplete.
+ NamespaceItarator() should be reverse order (special handling
+ because of XPathNavigator specification).
+
+2003-11-24 Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
+
+ * Iterator.cs : PrecedingIterator.MoveNext() now breaks up at Root.
+ * XPathNavigator.cs : ComparePosition() didn't handle attributes
+ correctly.
+
+2003-11-24 Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
+
+ * Parser.jay, Expression.cs, Iterator.cs :
+ Added ExprParens and ParensIterator classes which is used to handle
+ precedence of parenthesized expressions.
+ (e.g. consider "(preceding::*)[3]" and "preceding::[3]" )
+
+ * Expression.cs, Iterator.cs :
+ Added RequireSorting property for each Expr and BaseIterator classes.
+ SlashIterator.MoveNext() now considers correct sorting. But
+ considering performance, it separates two logics, sorted and sortless
+ depending on RequireSorting of left iterator and right expression.
+
+ * Iterator.cs :
+ SimpleIterator.ctor() should consider when nav is null.
+ FollowingIterator.MoveNext() and PrecedingIterator.MoveNext() should
+ not return any nodes.
+ AncestorIterator and AncestorOrSelfIterator copy ctr() should clone
+ positions.
+ AncestorIterator.MoveNext() should skip Root if context node is
+ Root itself.
+ FollowingIterator.MoveNext() should not handle children of context
+ itself.
+ PrecedingIterator.MoveNext() should skip its ancestors.
+ AxisIterator.ReverseAxis should be dependent on its containing iter.
+ UnionIterator.MoveNext() should consider comparison of nodes in
+ different document. The behavior is implementation dependent.
+ (see XSLT spec 12.1)
+
+2003-11-19 Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
+
+ * Added XPathComparer.cs
+ * DefaultContext.cs : Fixed XPathFunctionId.Evaluate() to iterate base
+ iterator correctly, and sort results.
+
+2003-11-19 Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
+
+ * DefaultContext.cs : Imcomplete fix ;-)
+
+2003-11-19 Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
+
+ * DefaultContext.cs : XPathFunctions.ToNumber() should catch overflow.
+ XPathFunctionId.cs : Exposed Id expression.
+ * Expression.cs : Added ExprLiteral.Value, and class ExprParens (it
+ will be used to solve evaluation precedence problem).
+
2003-11-09 Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
* Iterator.cs : Fixed SlashIterator that might return nodes 1)in
diff --git a/mcs/class/System.XML/System.Xml.XPath/DefaultContext.cs b/mcs/class/System.XML/System.Xml.XPath/DefaultContext.cs
index 9d439861fce..c84d2d9f4cf 100644
--- a/mcs/class/System.XML/System.Xml.XPath/DefaultContext.cs
+++ b/mcs/class/System.XML/System.Xml.XPath/DefaultContext.cs
@@ -86,6 +86,8 @@ namespace System.Xml.XPath
{
try {
return XmlConvert.ToDouble ((string) arg); // TODO: spec? convert string to number
+ } catch (System.OverflowException) {
+ return double.NaN;
} catch (System.FormatException) {
return double.NaN;
}
@@ -172,6 +174,8 @@ namespace System.Xml.XPath
arg0 = args.Arg;
}
+
+ public Expression Id { get { return arg0; } }
private static char [] rgchWhitespace = {' ', '\t', '\r', '\n'};
public override XPathResultType ReturnType { get { return XPathResultType.NodeSet; }}
@@ -186,7 +190,7 @@ namespace System.Xml.XPath
if (valItr != null)
{
strArgs = "";
- while (!valItr.MoveNext ())
+ while (valItr.MoveNext ())
strArgs += valItr.Current.Value + " ";
}
else
@@ -196,14 +200,15 @@ namespace System.Xml.XPath
ArrayList rgNodes = new ArrayList ();
foreach (string strArg in strArgs.Split (rgchWhitespace))
{
- if (n.MoveToId (strArg))
+ if (n.MoveToId (strArg)) {
rgNodes.Add (n.Clone ());
+ }
}
+ rgNodes.Sort (XPathNavigatorComparer.Instance);
return new EnumeratorIterator (iter, rgNodes.GetEnumerator ());
}
}
-
internal class XPathFunctionLocalName : XPathFunction
{
Expression arg0;
diff --git a/mcs/class/System.XML/System.Xml.XPath/Expression.cs b/mcs/class/System.XML/System.Xml.XPath/Expression.cs
index fc2ee98819e..859af58d79d 100644
--- a/mcs/class/System.XML/System.Xml.XPath/Expression.cs
+++ b/mcs/class/System.XML/System.Xml.XPath/Expression.cs
@@ -448,6 +448,8 @@ namespace System.Xml.XPath
}
return Evaluate (iter);
}
+
+ public virtual bool RequireSorting { get { return false; } }
}
internal abstract class ExprBinary : Expression
@@ -841,6 +843,8 @@ namespace System.Xml.XPath
BaseIterator iterLeft = left.EvaluateNodeSet (iter);
return new SlashIterator (iterLeft, right);
}
+
+ public override bool RequireSorting { get { return left.RequireSorting || right.RequireSorting; } }
}
internal class ExprSLASH2 : NodeSet {
@@ -865,6 +869,8 @@ namespace System.Xml.XPath
right
);
}
+
+ public override bool RequireSorting { get { return left.RequireSorting || right.RequireSorting; } }
}
internal class ExprRoot : NodeSet
@@ -1004,6 +1010,22 @@ namespace System.Xml.XPath
}
public abstract void GetInfo (out string name, out string ns, out XPathNodeType nodetype, XmlNamespaceManager nsm);
+
+ public override bool RequireSorting {
+ get {
+ switch (_axis.Axis) {
+ case Axes.Ancestor:
+ case Axes.AncestorOrSelf:
+ case Axes.Preceding:
+ case Axes.PrecedingSibling:
+ case Axes.Namespace:
+ return true;
+ default:
+ return false;
+ }
+ }
+
+ }
}
internal class NodeTypeTest : NodeTest
@@ -1205,6 +1227,7 @@ namespace System.Xml.XPath
{
_value = value;
}
+ public string Value { get { return _value; } }
public override String ToString () { return "'" + _value + "'"; }
public override XPathResultType ReturnType { get { return XPathResultType.String; }}
public override object Evaluate (BaseIterator iter)
@@ -1260,6 +1283,26 @@ namespace System.Xml.XPath
}
}
+ internal class ExprParens : Expression
+ {
+ protected Expression _expr;
+ public ExprParens (Expression expr)
+ {
+ _expr = expr;
+ }
+ public override String ToString () { return "(" + _expr.ToString () + ")"; }
+ public override XPathResultType ReturnType { get { return _expr.ReturnType; }}
+ public override object Evaluate (BaseIterator iter)
+ {
+ object o = (_expr.Evaluate (iter));
+ BaseIterator predBase = o as BaseIterator;
+ if (predBase != null)
+ return new ParensIterator (predBase);
+ else
+ return o;
+ }
+ }
+
internal class FunctionArguments
{
protected Expression _arg;
diff --git a/mcs/class/System.XML/System.Xml.XPath/Iterator.cs b/mcs/class/System.XML/System.Xml.XPath/Iterator.cs
index fa36ceb58ef..a7527065346 100644
--- a/mcs/class/System.XML/System.Xml.XPath/Iterator.cs
+++ b/mcs/class/System.XML/System.Xml.XPath/Iterator.cs
@@ -38,6 +38,8 @@ namespace System.Xml.XPath
get { return false; }
}
+ public abstract bool RequireSorting { get; }
+
public virtual int ComparablePosition {
get {
if (ReverseAxis) {
@@ -104,20 +106,28 @@ namespace System.Xml.XPath
}
}
public override int CurrentPosition { get { return _pos; }}
+
+ public override bool RequireSorting { get { return true; } }
}
internal abstract class SimpleIterator : BaseIterator
{
+ protected readonly BaseIterator _iter;
protected readonly XPathNavigator _nav;
protected int _pos;
public SimpleIterator (BaseIterator iter) : base (iter)
{
- _nav = iter.Current.Clone ();
+ _iter = iter;
+ if (iter.Current != null)
+ _nav = iter.Current.Clone ();
}
protected SimpleIterator (SimpleIterator other) : base (other)
{
- _nav = other._nav.Clone ();
+ if (other._nav == null)
+ _iter = (BaseIterator) other._iter.Clone ();
+ else
+ _nav = other._nav.Clone ();
_pos = other._pos;
}
public SimpleIterator (XPathNavigator nav, XmlNamespaceManager nsm) : base (nsm)
@@ -144,6 +154,8 @@ namespace System.Xml.XPath
}
return false;
}
+
+ public override bool RequireSorting { get { return false; } }
}
internal class NullIterator : SelfIterator
@@ -159,6 +171,29 @@ namespace System.Xml.XPath
}
}
+ internal class ParensIterator : SimpleIterator
+ {
+ BaseIterator _iter;
+ public ParensIterator (BaseIterator iter) : base (iter)
+ {
+ _iter = iter;
+ }
+ protected ParensIterator (ParensIterator other) : base (other)
+ {
+ _iter = (BaseIterator) other._iter.Clone ();
+ }
+ public override XPathNodeIterator Clone () { return new ParensIterator (this); }
+ public override bool MoveNext ()
+ {
+ return _iter.MoveNext ();
+ }
+
+ public override XPathNavigator Current { get { return _iter.Current; }}
+ public override int CurrentPosition { get { return _iter.CurrentPosition; } }
+
+ public override bool RequireSorting { get { return _iter.RequireSorting; } }
+ }
+
internal class ParentIterator : SimpleIterator
{
public ParentIterator (BaseIterator iter) : base (iter) {}
@@ -174,6 +209,8 @@ namespace System.Xml.XPath
}
return false;
}
+
+ public override bool RequireSorting { get { return true; } }
}
internal class ChildIterator : SimpleIterator
@@ -188,6 +225,8 @@ namespace System.Xml.XPath
_pos ++;
return fSuccess;
}
+
+ public override bool RequireSorting { get { return false; } }
}
internal class FollowingSiblingIterator : SimpleIterator
@@ -197,6 +236,12 @@ namespace System.Xml.XPath
public override XPathNodeIterator Clone () { return new FollowingSiblingIterator (this); }
public override bool MoveNext ()
{
+ switch (_nav.NodeType) {
+ case XPathNodeType.Attribute:
+ case XPathNodeType.Namespace:
+ // They have no siblings.
+ return false;
+ }
if (_nav.MoveToNext ())
{
_pos ++;
@@ -204,6 +249,8 @@ namespace System.Xml.XPath
}
return false;
}
+
+ public override bool RequireSorting { get { return false; } }
}
internal class PrecedingSiblingIterator : SimpleIterator
@@ -230,6 +277,14 @@ namespace System.Xml.XPath
return false;
if (!started) {
started = true;
+ switch (_nav.NodeType) {
+ case XPathNodeType.Attribute:
+ case XPathNodeType.Namespace:
+ // They have no siblings.
+ finished = true;
+ return false;
+ }
+
_nav.MoveToFirst ();
if (_nav.ComparePosition (startPosition) == XmlNodeOrder.Same) {
_pos++;
@@ -253,6 +308,8 @@ namespace System.Xml.XPath
public override bool ReverseAxis {
get { return true; }
}
+
+ public override bool RequireSorting { get { return true; } }
}
internal class AncestorIterator : SimpleIterator
@@ -271,7 +328,7 @@ namespace System.Xml.XPath
startPosition = other.startPosition;
started = other.started;
finished = other.finished;
- positions = other.positions;
+ positions = (ArrayList) other.positions.Clone ();
nextDepth = other.nextDepth;
}
public override XPathNodeIterator Clone () { return new AncestorIterator (this); }
@@ -284,7 +341,7 @@ namespace System.Xml.XPath
XPathNavigator ancestors = startPosition.Clone ();
ancestors.MoveToParent ();
_nav.MoveToParent ();
- do {
+ while (ancestors.NodeType != XPathNodeType.Root) {
int i = 0;
_nav.MoveToFirst ();
while (_nav.ComparePosition (ancestors) == XmlNodeOrder.Before) {
@@ -294,8 +351,16 @@ namespace System.Xml.XPath
positions.Add (i);
ancestors.MoveToParent ();
_nav.MoveToParent ();
- } while (ancestors.NodeType != XPathNodeType.Root);
+ }
+
+
positions.Reverse ();
+
+ if (startPosition.NodeType != XPathNodeType.Root) {
+ // First time it returns Root
+ _pos++;
+ return true;
+ }
}
if (nextDepth < positions.Count) {
int thisTimePos = (int) positions [nextDepth];
@@ -313,6 +378,8 @@ namespace System.Xml.XPath
public override bool ReverseAxis {
get { return true; }
}
+
+ public override bool RequireSorting { get { return true; } }
}
internal class AncestorOrSelfIterator : SimpleIterator
@@ -331,7 +398,7 @@ namespace System.Xml.XPath
startPosition = other.startPosition;
started = other.started;
finished = other.finished;
- positions = other.positions;
+ positions = (ArrayList) other.positions.Clone ();
nextDepth = other.nextDepth;
}
public override XPathNodeIterator Clone () { return new AncestorOrSelfIterator (this); }
@@ -371,6 +438,8 @@ namespace System.Xml.XPath
public override bool ReverseAxis {
get { return true; }
}
+
+ public override bool RequireSorting { get { return true; } }
}
internal class DescendantIterator : SimpleIterator
@@ -413,6 +482,8 @@ namespace System.Xml.XPath
_finished = true;
return false;
}
+
+ public override bool RequireSorting { get { return false; } }
}
internal class DescendantOrSelfIterator : SimpleIterator
@@ -461,6 +532,8 @@ namespace System.Xml.XPath
_finished = true;
return false;
}
+
+ public override bool RequireSorting { get { return false; } }
}
internal class FollowingIterator : SimpleIterator
@@ -479,6 +552,13 @@ namespace System.Xml.XPath
{
_pos ++;
return true;
+ } else {
+ while (_nav.MoveToParent ()) {
+ if (_nav.MoveToNext ()) {
+ _pos ++;
+ return true;
+ }
+ }
}
}
else
@@ -501,6 +581,8 @@ namespace System.Xml.XPath
_finished = true;
return false;
}
+
+ public override bool RequireSorting { get { return false; } }
}
internal class PrecedingIterator : SimpleIterator
@@ -527,17 +609,22 @@ namespace System.Xml.XPath
if (!started) {
started = true;
_nav.MoveToRoot ();
- _nav.MoveToFirstChild ();
- if (_nav.ComparePosition (startPosition) == XmlNodeOrder.Same) {
- _pos++;
- return true;
- }
- } else {
+ }
+ bool loop = true;
+ while (loop) {
while (!_nav.MoveToFirstChild ()) {
- while (!_nav.MoveToNext ())
- _nav.MoveToParent (); // Should not finish, at least before startPosition.
+ while (!_nav.MoveToNext ()) {
+ if (!_nav.MoveToParent ()) { // Should not finish, at least before startPosition.
+ finished = true;
+ return false;
+ }
+ }
break;
}
+ if (_nav.IsDescendant (startPosition))
+ continue;
+ loop = false;
+ break;
}
if (_nav.ComparePosition (startPosition) != XmlNodeOrder.Before) {
// Note that if _nav contains only 1 node, it won't be Same.
@@ -551,6 +638,8 @@ namespace System.Xml.XPath
public override bool ReverseAxis {
get { return true; }
}
+
+ public override bool RequireSorting { get { return true; } }
}
internal class NamespaceIterator : SimpleIterator
@@ -575,6 +664,9 @@ namespace System.Xml.XPath
}
return false;
}
+
+ public override bool ReverseAxis { get { return true; } }
+ public override bool RequireSorting { get { return false; } }
}
internal class AttributeIterator : SimpleIterator
@@ -599,6 +691,8 @@ namespace System.Xml.XPath
}
return false;
}
+
+ public override bool RequireSorting { get { return false; } }
}
internal class AxisIterator : BaseIterator
@@ -647,7 +741,6 @@ namespace System.Xml.XPath
}
public override XPathNavigator Current { get { return _iter.Current; }}
public override int CurrentPosition { get { return _pos; }}
- //public override int ComparablePosition { get { return _iter.ComparablePosition; } }
bool Match ()
{
@@ -660,6 +753,11 @@ namespace System.Xml.XPath
return (object)ns == (object)Current.NamespaceURI &&
(name == null || (object)name == (object)Current.LocalName);
}
+ public override bool ReverseAxis {
+ get { return _iter.ReverseAxis; }
+ }
+
+ public override bool RequireSorting { get { return _iter.RequireSorting; } }
}
#if false
@@ -713,7 +811,9 @@ namespace System.Xml.XPath
protected BaseIterator _iterRight;
protected NodeSet _expr;
protected int _pos;
- Stack _iterStack;
+// Stack _iterStack;
+ ArrayList _navStore;//(XPathIteratorComparer.Instance);
+ SortedList _iterList;
bool _finished;
BaseIterator _nextIterRight;
@@ -730,8 +830,10 @@ namespace System.Xml.XPath
_iterRight = (BaseIterator) other._iterRight.Clone ();
_expr = other._expr;
_pos = other._pos;
- if (other._iterStack != null)
- _iterStack = other._iterStack.Clone () as Stack;
+ if (other._iterList != null)
+ _iterList = other._iterList.Clone () as SortedList;
+ if (other._navStore != null)
+ _navStore = other._navStore.Clone () as ArrayList;
_finished = other._finished;
_nextIterRight = other._nextIterRight;
}
@@ -741,73 +843,174 @@ namespace System.Xml.XPath
{
if (_finished)
return false;
-
- if (_iterRight == null) {
- if (!_iterLeft.MoveNext ())
- return false;
- _iterRight = _expr.EvaluateNodeSet (_iterLeft);
- _iterStack = new Stack ();
- }
-
- while (true) {
- while (!_iterRight.MoveNext ()) {
- if (_iterStack.Count > 0) {
- _iterRight = _iterStack.Pop () as BaseIterator;
- break;
- } else if (_nextIterRight != null) {
- _iterRight = _nextIterRight;
- _nextIterRight = null;
- break;
- } else if (!_iterLeft.MoveNext ()) {
+ if (RequireSorting) {
+ if (_pos <= 0) {
+ CollectResults ();
+ if (_navStore.Count == 0) {
_finished = true;
return false;
}
+ }
+ _pos++;
+ if (_navStore.Count < _pos) {
+ _finished = true;
+ _pos--;
+ return false;
+ }
+ while (_navStore.Count > _pos) {
+ if (((XPathNavigator) _navStore [_pos]).ComparePosition (
+ (XPathNavigator) _navStore [_pos - 1]) == XmlNodeOrder.Same)
+ _navStore.RemoveAt (_pos);
else
- _iterRight = _expr.EvaluateNodeSet (_iterLeft);
+ break;
}
- bool loop = true;
- while (loop) {
- loop = false;
- if (_nextIterRight == null) {
- bool noMoreNext = false;
- while (_nextIterRight == null || !_nextIterRight.MoveNext ()) {
- if(_iterLeft.MoveNext ())
- _nextIterRight = _expr.EvaluateNodeSet (_iterLeft);
- else {
- noMoreNext = true;
- break;
- }
- }
- if (noMoreNext)
- _nextIterRight = null; // FIXME: More efficient code. Maybe making noMoreNext class scope would be better.
- }
- if (_nextIterRight != null) {
- switch (_iterRight.Current.ComparePosition (_nextIterRight.Current)) {
- case XmlNodeOrder.After:
- _iterStack.Push (_iterRight);
- _iterRight = _nextIterRight;
- _nextIterRight = null;
- break;
- case XmlNodeOrder.Same:
- if (!_nextIterRight.MoveNext ())
- _nextIterRight = null;
- loop = true;
- break;
- }
- }
+
+ return true;
+ } else {
+#if false
+ while (_iterRight == null || !_iterRight.MoveNext ())
+ {
+ if (!_iterLeft.MoveNext ())
+ return false;
+ _iterRight = _expr.EvaluateNodeSet (_iterLeft);
}
_pos ++;
return true;
+#else
+ if (_iterRight == null) {
+ if (!_iterLeft.MoveNext ())
+ return false;
+ _iterRight = _expr.EvaluateNodeSet (_iterLeft);
+ _iterList = new SortedList (XPathIteratorComparer.Instance);
+ }
+
+ while (true) {
+ while (!_iterRight.MoveNext ()) {
+ if (_iterList.Count > 0) {
+ int last = _iterList.Count - 1;
+ BaseIterator tmpIter = _iterList.GetByIndex (last) as BaseIterator;
+ _iterList.RemoveAt (last);
+ switch (tmpIter.Current.ComparePosition (_iterRight.Current)) {
+ case XmlNodeOrder.Same:
+ case XmlNodeOrder.Before:
+ _iterRight = tmpIter;
+ continue;
+ default:
+ _iterRight = tmpIter;
+ break;
+ }
+ break;
+ } else if (_nextIterRight != null) {
+ _iterRight = _nextIterRight;
+ _nextIterRight = null;
+ break;
+ } else if (!_iterLeft.MoveNext ()) {
+ _finished = true;
+ return false;
+ }
+ else
+ _iterRight = _expr.EvaluateNodeSet (_iterLeft);
+ }
+ bool loop = true;
+ while (loop) {
+ loop = false;
+ if (_nextIterRight == null) {
+ bool noMoreNext = false;
+ /*
+ if (_iterList.Count > 0) {
+ int last = _iterList.Count -1;
+ BaseIterator tmpIter = _iterList.GetByIndex (last) as BaseIterator;
+ _iterList.RemoveAt (last);
+ switch (tmpIter.Current.ComparePosition (_iterRight.Current)) {
+ case XmlNodeOrder.Same:
+ case XmlNodeOrder.Before:
+ _iterList.Add (_iterRight, _iterRight);
+ _iterRight = tmpIter;
+ break;
+ default:
+ _iterList.Add (_iterRight, _iterRight);
+ break;
+ }
+ }
+ */
+ while (_nextIterRight == null || !_nextIterRight.MoveNext ()) {
+ if(_iterLeft.MoveNext ())
+ _nextIterRight = _expr.EvaluateNodeSet (_iterLeft);
+ else {
+ noMoreNext = true;
+ break;
+ }
+ }
+ if (noMoreNext)
+ _nextIterRight = null; // FIXME: More efficient code. Maybe making noMoreNext class scope would be better.
+ }
+ if (_nextIterRight != null) {
+ switch (_iterRight.Current.ComparePosition (_nextIterRight.Current)) {
+ case XmlNodeOrder.After:
+ _iterList.Add (_iterList.Count, _iterRight);
+ _iterRight = _nextIterRight;
+ _nextIterRight = null;
+ loop = true;
+ break;
+ case XmlNodeOrder.Same:
+ if (!_nextIterRight.MoveNext ())
+ _nextIterRight = null;
+
+ else {
+ int last = _iterList.Count;
+ if (last > 0) {
+ _iterList.Add (last, _nextIterRight);
+ _nextIterRight = _iterList.GetByIndex (last) as BaseIterator;
+ _iterList.RemoveAt (last);
+ }
+ }
+
+ loop = true;
+ break;
+ }
+ }
+ }
+ _pos ++;
+ return true;
+ }
+#endif
+ }
+ }
+ private void CollectResults ()
+ {
+ if (_navStore != null)
+ return;
+ _navStore = new ArrayList ();
+ while (true) {
+ while (_iterRight == null || !_iterRight.MoveNext ()) {
+ if (!_iterLeft.MoveNext ()) {
+ _navStore.Sort (XPathNavigatorComparer.Instance);
+ return;
+ }
+ _iterRight = _expr.EvaluateNodeSet (_iterLeft);
+ }
+ XPathNavigator nav = _iterRight.Current.Clone ();
+ _navStore.Add (nav);
}
}
+
public override XPathNavigator Current {
- get {
- if (_iterRight == null) return null;
-
- return _iterRight.Current;
+ get {
+ if (_pos <= 0) return null;
+ if (RequireSorting) {
+ return _navStore [_pos - 1] as XPathNavigator;
+ } else {
+ return _iterRight.Current;
+ }
}
}
public override int CurrentPosition { get { return _pos; }}
+
+ public override bool RequireSorting {
+ get {
+ return _iterLeft.RequireSorting || _expr.RequireSorting;
+ }
+ }
}
#endif
@@ -870,6 +1073,11 @@ namespace System.Xml.XPath
}
public override XPathNavigator Current { get { return _iter.Current; }}
public override int CurrentPosition { get { return _pos; }}
+ public override bool ReverseAxis {
+ get { return _iter.ReverseAxis; }
+ }
+
+ public override bool RequireSorting { get { return true; } }
}
internal class EnumeratorIterator : BaseIterator
@@ -889,7 +1097,10 @@ namespace System.Xml.XPath
protected EnumeratorIterator (EnumeratorIterator other) : base (other)
{
- _enum = other._enum;
+ ICloneable enumClone = other._enum as ICloneable;
+ if (enumClone == null)
+ throw new ArgumentException ("Enumerator must be cloneable.");
+ _enum = enumClone.Clone () as IEnumerator;
_pos = other._pos;
}
public override XPathNodeIterator Clone () { return new EnumeratorIterator (this); }
@@ -903,6 +1114,8 @@ namespace System.Xml.XPath
}
public override XPathNavigator Current { get { return (XPathNavigator) _enum.Current; }}
public override int CurrentPosition { get { return _pos; }}
+
+ public override bool RequireSorting { get { return true; } }
}
@@ -922,9 +1135,12 @@ namespace System.Xml.XPath
protected UnionIterator (UnionIterator other) : base (other)
{
- _left = other._left;
- _right = other._right;
+ _left = (BaseIterator) other._left.Clone ();
+ _right = (BaseIterator) other._right.Clone ();
_pos = other._pos;
+ keepLeft = other.keepLeft;
+ keepRight = other.keepRight;
+ useRight = other.useRight;
}
public override XPathNodeIterator Clone () { return new UnionIterator (this); }
@@ -955,6 +1171,7 @@ namespace System.Xml.XPath
useRight = true;
return true;
case XmlNodeOrder.Before:
+ case XmlNodeOrder.Unknown: // Maybe happen because of "document(a) | document(b)"
keepLeft = useRight = false;
return true;
case XmlNodeOrder.After:
@@ -978,5 +1195,7 @@ namespace System.Xml.XPath
}
}
public override int CurrentPosition { get { return _pos; }}
+
+ public override bool RequireSorting { get { return _left.RequireSorting || _right.RequireSorting; } }
}
}
diff --git a/mcs/class/System.XML/System.Xml.XPath/Parser.jay b/mcs/class/System.XML/System.Xml.XPath/Parser.jay
index 1f1aafd8f79..8b4c7356c7c 100644
--- a/mcs/class/System.XML/System.Xml.XPath/Parser.jay
+++ b/mcs/class/System.XML/System.Xml.XPath/Parser.jay
@@ -335,7 +335,7 @@ PrimaryExpr
}
| PAREN_OPEN Expr PAREN_CLOSE
{
- $$ = $2;
+ $$ = new ExprParens ((Expression) $2);
}
| LITERAL
{
diff --git a/mcs/class/System.XML/System.Xml.XPath/XPathComparer.cs b/mcs/class/System.XML/System.Xml.XPath/XPathComparer.cs
new file mode 100644
index 00000000000..604f0ee855a
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.XPath/XPathComparer.cs
@@ -0,0 +1,69 @@
+//
+// System.Xml.XPath.XPathComparer
+//
+// Author:
+// Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
+//
+// (C) 2003 Atsushi Enomoto
+//
+
+using System;
+using System.Collections;
+using System.Xml;
+using System.Xml.XPath;
+using System.Xml.Xsl;
+
+namespace System.Xml.XPath
+{
+ internal class XPathIteratorComparer : IComparer
+ {
+ public static XPathIteratorComparer Instance = new XPathIteratorComparer ();
+ private XPathIteratorComparer ()
+ {
+ }
+
+ public int Compare (object o1, object o2)
+ {
+ BaseIterator nav1 = o1 as BaseIterator;
+ BaseIterator nav2 = o2 as BaseIterator;
+ if (nav1 == null)
+ return -1;
+ if (nav2 == null)
+ return 1;
+ switch (nav1.Current.ComparePosition (nav2.Current)) {
+ case XmlNodeOrder.Same:
+ return 0;
+ case XmlNodeOrder.After:
+ return -1;
+ default:
+ return 1;
+ }
+ }
+ }
+
+ internal class XPathNavigatorComparer : IComparer
+ {
+ public static XPathNavigatorComparer Instance = new XPathNavigatorComparer ();
+ private XPathNavigatorComparer ()
+ {
+ }
+
+ public int Compare (object o1, object o2)
+ {
+ XPathNavigator nav1 = o1 as XPathNavigator;
+ XPathNavigator nav2 = o2 as XPathNavigator;
+ if (nav1 == null)
+ return -1;
+ if (nav2 == null)
+ return 1;
+ switch (nav1.ComparePosition (nav2)) {
+ case XmlNodeOrder.Same:
+ return 0;
+ case XmlNodeOrder.After:
+ return 1;
+ default:
+ return -1;
+ }
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.XPath/XPathNavigator.cs b/mcs/class/System.XML/System.Xml.XPath/XPathNavigator.cs
index d6018aa31a0..6a3db1f3301 100644
--- a/mcs/class/System.XML/System.Xml.XPath/XPathNavigator.cs
+++ b/mcs/class/System.XML/System.Xml.XPath/XPathNavigator.cs
@@ -130,6 +130,11 @@ namespace System.Xml.XPath
}
else
{
+ switch (nav2.NodeType) {
+ case XPathNodeType.Namespace:
+ case XPathNodeType.Attribute:
+ return XmlNodeOrder.After;
+ }
// match children
while (nav2.MoveToNext ())
if (nav2.IsSamePosition (nav1))
diff --git a/mcs/class/System.XML/System.Xml.Xsl/ChangeLog b/mcs/class/System.XML/System.Xml.Xsl/ChangeLog
index 90d226819da..d7468c3df16 100644
--- a/mcs/class/System.XML/System.Xml.Xsl/ChangeLog
+++ b/mcs/class/System.XML/System.Xml.Xsl/ChangeLog
@@ -1,3 +1,13 @@
+2003-11-21 Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
+
+ * ManagedXslTransform.cs : Now WriteStartDocument() is moved internal to
+ GenericOutputter.
+
+2003-11-19 Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
+
+ * ManagedXslTransform.cs : Transform() should raise an error if no
+ stylesheet was loaded.
+
2003-10-04 Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
* XslTransformImpl.cs : Load(url, resolver) now uses XPathDocument
diff --git a/mcs/class/System.XML/System.Xml.Xsl/ManagedXslTransform.cs b/mcs/class/System.XML/System.Xml.Xsl/ManagedXslTransform.cs
index 225cef4dd51..8d0b04c4172 100644
--- a/mcs/class/System.XML/System.Xml.Xsl/ManagedXslTransform.cs
+++ b/mcs/class/System.XML/System.Xml.Xsl/ManagedXslTransform.cs
@@ -28,6 +28,9 @@ namespace System.Xml.Xsl {
public override void Transform (XPathNavigator input, XsltArgumentList args, XmlWriter output, XmlResolver resolver)
{
+ if (s == null)
+ throw new XsltException ("No stylesheet was loaded.", null);
+
Outputter outputter = new GenericOutputter(output, s.Outputs);
bool wroteStartDocument = false;
if (output.WriteState == WriteState.Start) {
@@ -42,9 +45,16 @@ namespace System.Xml.Xsl {
public override void Transform (XPathNavigator input, XsltArgumentList args, TextWriter output, XmlResolver resolver) {
Outputter outputter = new GenericOutputter(output, s.Outputs);
- outputter.WriteStartDocument();
+// outputter.WriteStartDocument();
new XslTransformProcessor (s).Process (input, outputter, args, resolver);
- outputter.WriteEndDocument();
+ switch (outputter.WriteState) {
+ case WriteState.Start:
+ case WriteState.Closed:
+ break;
+ default:
+ outputter.WriteEndDocument();
+ break;
+ }
output.Flush ();
}
diff --git a/mcs/class/System.XML/System.Xml.dll.sources b/mcs/class/System.XML/System.Xml.dll.sources
index 5ed8823cc9d..b547ec15afb 100755
--- a/mcs/class/System.XML/System.Xml.dll.sources
+++ b/mcs/class/System.XML/System.Xml.dll.sources
@@ -43,6 +43,7 @@ Mono.Xml.Xsl/Compiler.cs
Mono.Xml.Xsl/Debug.cs
Mono.Xml.Xsl/Emitter.cs
Mono.Xml.Xsl/GenericOutputter.cs
+Mono.Xml.Xsl/HtmlEmitter.cs
Mono.Xml.Xsl/MSXslScriptManager.cs
Mono.Xml.Xsl/Outputter.cs
Mono.Xml.Xsl/TextEmitter.cs
@@ -59,17 +60,24 @@ Mono.Xml.Xsl/XsltCompiledContext.cs
Mono.Xml/IHasXmlParserContext.cs
Mono.Xml/IHasXmlSchemaInfo.cs
Mono.Xml/XmlNodeWriter.cs
-System.Xml/IHasXmlNode.cs
+System.Xml/AsyncXmlTextWriter.cs
System.Xml/DTDAutomata.cs
System.Xml/DTDObjectModel.cs
System.Xml/DTDReader.cs
System.Xml/DTDValidatingReader.cs
System.Xml/EntityHandling.cs
System.Xml/Formatting.cs
+System.Xml/IHasXmlNode.cs
+System.Xml/IXmlDataEvidence.cs
System.Xml/IXmlLineInfo.cs
+System.Xml/IXmlNamespaceResolver.cs
+System.Xml/IXPathChangeNavigator.cs
+System.Xml/IXPathEditor.cs
+System.Xml/IXPathNavigator.cs
System.Xml/NameTable.cs
System.Xml/ReadState.cs
System.Xml/TODOAttribute.cs
+System.Xml/UpdateEventHandler.cs
System.Xml/ValidationType.cs
System.Xml/XmlEntity.cs
System.Xml/WhitespaceHandling.cs
@@ -80,33 +88,41 @@ System.Xml/XmlAttributeCollection.cs
System.Xml/XmlCDataSection.cs
System.Xml/XmlConstructs.cs
System.Xml/XmlChar.cs
+System.Xml/XmlChangeFilters.cs
System.Xml/XmlCharacterData.cs
System.Xml/XmlComment.cs
System.Xml/XmlNotation.cs
System.Xml/XmlDeclaration.cs
System.Xml/XmlDocument.cs
System.Xml/XmlDocumentFragment.cs
+System.Xml/XmlDocumentNavigator.cs
System.Xml/XmlDocumentType.cs
System.Xml/XmlElement.cs
System.Xml/XmlEntityReference.cs
System.Xml/XmlException.cs
-System.Xml/XmlNodeReader.cs
System.Xml/XmlImplementation.cs
+System.Xml/XmlInfoItemType.cs
System.Xml/XmlConvert.cs
System.Xml/XmlLinkedNode.cs
System.Xml/XmlNameTable.cs
System.Xml/XmlNamedNodeMap.cs
+System.Xml/XmlNamespaceScope.cs
System.Xml/XmlNamespaceManager.cs
System.Xml/XmlNode.cs
+System.Xml/XmlNodeChangeType.cs
System.Xml/XmlNodeChangedAction.cs
System.Xml/XmlNodeChangedEventArgs.cs
+System.Xml/XmlNodeChangedEventHandler.cs
System.Xml/XmlNodeList.cs
System.Xml/XmlNodeListChildren.cs
System.Xml/XmlNodeOrder.cs
+System.Xml/XmlNodeReader.cs
System.Xml/XmlNodeType.cs
System.Xml/XmlParserContext.cs
System.Xml/XmlProcessingInstruction.cs
System.Xml/XmlQualifiedName.cs
+System.Xml/XmlQualifiedNameTable.cs
+System.Xml/XmlQueryDialect.cs
System.Xml/XmlReader.cs
System.Xml/XmlResolver.cs
System.Xml/XmlSecureResolver.cs
@@ -115,16 +131,21 @@ System.Xml/XmlSpace.cs
System.Xml/XmlText.cs
System.Xml/XmlTextReader.cs
System.Xml/XmlTokenizedType.cs
+System.Xml/XmlUpdateEventArgs.cs
System.Xml/XmlUrlResolver.cs
System.Xml/XmlValidatingReader.cs
System.Xml/XmlWhitespace.cs
System.Xml/XmlWriter.cs
-System.Xml/XmlNodeChangedEventHandler.cs
System.Xml/XmlTextWriterOpenElement.cs
-System.Xml/XmlDocumentNavigator.cs
System.Xml/XmlNodeArrayList.cs
System.Xml/XmlInputStream.cs
System.Xml/XmlParserInput.cs
+System.Xml/XPathChangeNavigator.cs
+System.Xml/XPathDocument2.cs
+System.Xml/XPathDocument2ChangedEventAction.cs
+System.Xml/XPathDocument2ChangedEventHandler.cs
+System.Xml/XPathEditor.cs
+System.Xml/XPathNavigator2.cs
System.Xml.XPath/IXPathNavigable.cs
System.Xml.XPath/XPathNavigator.cs
System.Xml.XPath/XPathExpression.cs
@@ -137,6 +158,7 @@ System.Xml.XPath/XmlSortOrder.cs
System.Xml.XPath/XmlCaseOrder.cs
System.Xml.XPath/XPathDocument.cs
System.Xml.XPath/XPathException.cs
+System.Xml.XPath/XPathComparer.cs
System.Xml.XPath/DefaultContext.cs
System.Xml.XPath/Expression.cs
System.Xml.XPath/Iterator.cs
@@ -209,6 +231,7 @@ System.Xml.Schema/XmlSchemaObjectTable.cs
System.Xml.Schema/XmlSchemaParticle.cs
System.Xml.Schema/XmlSchemaPatternFacet.cs
System.Xml.Schema/XmlSchemaRedefine.cs
+System.Xml.Schema/XmlSchemaSet.cs
System.Xml.Schema/XmlSchemaSequence.cs
System.Xml.Schema/XmlSchemaSimpleContent.cs
System.Xml.Schema/XmlSchemaSimpleContentExtension.cs
diff --git a/mcs/class/System.XML/System.Xml/AsyncXmlTextWriter.cs b/mcs/class/System.XML/System.Xml/AsyncXmlTextWriter.cs
new file mode 100644
index 00000000000..8242899ff1d
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml/AsyncXmlTextWriter.cs
@@ -0,0 +1,42 @@
+//
+// AsyncXmlTextWriter.cs
+//
+// Author:
+// Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
+//
+//
+#if NET_1_2
+
+using System;
+using System.IO;
+
+namespace System.Xml
+{
+ public class AsyncXmlTextWriter : XmlTextWriter
+ {
+
+ // TODO
+ public AsyncXmlTextWriter (/*Async*/StreamWriter writer)
+ : base (writer)
+ {
+ }
+
+ public virtual IAsyncResult BeginFlush (AsyncCallback callback, object state)
+ {
+ throw new NotImplementedException ();
+ }
+
+
+ public virtual void EndFlush (IAsyncResult result)
+ {
+ throw new NotImplementedException ();
+ }
+
+ public override void WriteNode (XmlReader reader, bool defaultAttribute)
+ {
+ throw new NotImplementedException ();
+ }
+ }
+}
+
+#endif
diff --git a/mcs/class/System.XML/System.Xml/ChangeLog b/mcs/class/System.XML/System.Xml/ChangeLog
index f7994bc001f..c1311661a60 100644
--- a/mcs/class/System.XML/System.Xml/ChangeLog
+++ b/mcs/class/System.XML/System.Xml/ChangeLog
@@ -1,3 +1,65 @@
+2003-11-28 Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
+
+ * XmlAttribute.cs : set_Prefix checks value when existing is "xmlns".
+
+2003-11-28 Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
+
+ * XmlWriter.cs : patch by Gonzalo (I modified a bit). WriteNode()
+ shouldn't expect non-empty element content. This will fix bug #48287.
+
+2003-11-28 Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
+
+ * XmlTextWriter.cs : When element's namespace should be overwritten by
+ one of its attribute, if exist as such. This fixes bug #51305.
+
+2003-11-24 Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
+
+ * DTDValidatingReader.cs : Fixed ReadContent() which may result in
+ invalid additional Text node.
+
+2003-11-24 Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
+
+ * XmlTextWriter.cs :
+ On WriteProcessingInstruction(), ArgumentException() is expected ;-)
+
+2003-11-24 Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
+
+ * XmlTextWriter.cs :
+ WriteProcessingInstruction() should check name validity.
+ AddMissingElementXmlns() should allow namespace emission even if it
+ is identical to existing one.
+
+2003-11-22 Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
+
+ * XmlTextReader.cs : Fixed ReadInnerXml(). This fixes bug #51267.
+
+2003-11-20 Eran Domb <erand@mainsoft.com>
+
+ * XmlTextWriter.cs (WriteStartAttribute) : Check if the ket already exists in the newAttributeNamespaces table
+ before trying to add it to the table.
+
+2003-11-19 Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
+
+ * DTDValidatingReader.cs : Replaced entity should not treat whitespaces
+ as significant.
+ * XmlNode.cs : Removed extraneous MonoTODOs.
+
+2003-11-17 Jackson Harper <jackson@ximian.com>
+
+ * XPathEditor.cs: .net 1.2 only
+
+2003-11-17 Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
+
+ * AsyncXmlTextWriter.cs, IXPathChangeNavigator.cs, IXPathEditor.cs,
+ IXPathNavigator.cs, IXmlDataEvidence.cs, IXmlNamespaceResolver.cs,
+ UpdateEventHandler.cs, XPathChangeNavigator.cs, XPathDocument2.cs,
+ XPathDocument2ChangedEventAction.cs,
+ XPathDocument2ChangedEventHandler.cs, XPathEditor.cs,
+ XPathNavigator2.cs, XmlChangeFilters.cs, XmlInfoItemType.cs,
+ XmlNamespaceScope.cs, XmlNodeChangeType.cs, XmlQualifiedNameTable,cs,
+ XmlQueryDialect.cs, XmlUpdateEventArgs.cs
+ : Added .NET 1.2 classes (for convenience of ObjectSpaces stubbing).
+
2003-11-02 Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
* XmlDocumentNavigator.cs : Fixed MoveToFirstChild() and MoveToNext()
diff --git a/mcs/class/System.XML/System.Xml/DTDValidatingReader.cs b/mcs/class/System.XML/System.Xml/DTDValidatingReader.cs
index 84d2298cc6f..9e67574c4d3 100644
--- a/mcs/class/System.XML/System.Xml/DTDValidatingReader.cs
+++ b/mcs/class/System.XML/System.Xml/DTDValidatingReader.cs
@@ -303,7 +303,6 @@ namespace Mono.Xml
private bool ReadContent ()
{
if (nextEntityReader != null) {
- nextMaybeSignificantWhitespace = true;
if (DTD == null || DTD.EntityDecls [reader.Name] == null)
throw new XmlException ("Entity '" + reader.Name + "' was not declared.");
entityReaderStack.Push (reader);
@@ -527,6 +526,7 @@ namespace Mono.Xml
}
break;
}
+ constructingTextValue = null;
MoveToElement ();
return true;
}
diff --git a/mcs/class/System.XML/System.Xml/IXPathChangeNavigator.cs b/mcs/class/System.XML/System.Xml/IXPathChangeNavigator.cs
new file mode 100644
index 00000000000..1c566d63e98
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml/IXPathChangeNavigator.cs
@@ -0,0 +1,27 @@
+//
+// IXPathChangeNavigator.cs
+//
+// Author:
+// Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
+//
+#if NET_1_2
+
+using System;
+using System.Collections;
+
+namespace System.Xml
+{
+ public interface IXPathChangeNavigator
+ {
+ void AcceptChange ();
+
+ void RejectChange ();
+
+ IEnumerable SelectChanges (XmlChangeFilters changeType);
+
+ IEnumerable SelectChanges ();
+
+ }
+
+}
+#endif
diff --git a/mcs/class/System.XML/System.Xml/IXPathEditor.cs b/mcs/class/System.XML/System.Xml/IXPathEditor.cs
new file mode 100644
index 00000000000..ab14a73a1c3
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml/IXPathEditor.cs
@@ -0,0 +1,28 @@
+//
+// IXPathEditor.cs
+//
+// Author:
+// Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
+//
+#if NET_1_2
+
+using System;
+
+namespace System.Xml
+{
+ public interface IXPathEditor
+ {
+ XmlWriter CreateAttributes ();
+
+ XmlWriter CreateFirstChild ();
+
+ XmlWriter CreateNextSibling ();
+
+ void DeleteCurrent ();
+
+ void SetValue (string value);
+ }
+
+
+}
+#endif
diff --git a/mcs/class/System.XML/System.Xml/IXPathNavigator.cs b/mcs/class/System.XML/System.Xml/IXPathNavigator.cs
new file mode 100644
index 00000000000..822b58ecee0
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml/IXPathNavigator.cs
@@ -0,0 +1,61 @@
+//
+// IXPathNavigator.cs
+//
+// Author:
+// Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
+//
+#if NET_1_2
+
+using System;
+using System.Collections;
+
+namespace System.Xml
+{
+
+ public interface IXPathNavigator
+ {
+ IXPathNavigator Clone ();
+
+ XmlNodeOrder ComparePosition (IXPathNavigator other);
+
+ bool IsDescendant (IXPathNavigator other);
+
+ bool IsSamePosition (IXPathNavigator other);
+
+ IXPathNavigator MoveTo (IXPathNavigator other);
+
+ IXPathNavigator MoveToAttribute (string localName, string namespaceName, bool atomizedNames);
+ IXPathNavigator MoveToChild (string localName, string namespaceName, bool atomizedNames);
+
+ IXPathNavigator MoveToDescendantOf (IXPathNavigator root, string localName, string namespaceName, bool atomizedNames);
+
+ IXPathNavigator MoveToDescendantOf (IXPathNavigator root, XmlInfoItemType type);
+
+ IXPathNavigator MoveToFirstAttribute ();
+
+ IXPathNavigator MoveToFirstChild ();
+
+ IXPathNavigator MoveToFirstNamespace (XmlNamespaceScope scope);
+
+ IXPathNavigator MoveToFirstValue ();
+
+ IXPathNavigator MoveToId (string id);
+
+ IXPathNavigator MoveToNextAttribute ();
+
+ IXPathNavigator MoveToNextNamespace (XmlNamespaceScope scope);
+
+ IXPathNavigator MoveToNextSibling ();
+
+ IXPathNavigator MoveToNextValue ();
+
+ IXPathNavigator MoveToParent ();
+
+ IXPathNavigator MoveToRoot ();
+
+ IXPathNavigator MoveToSibling (string localName, string namespaceName, bool atomizedNames);
+ IXPathNavigator MoveToSibling (XmlInfoItemType type);
+ }
+
+}
+#endif
diff --git a/mcs/class/System.XML/System.Xml/IXmlDataEvidence.cs b/mcs/class/System.XML/System.Xml/IXmlDataEvidence.cs
new file mode 100644
index 00000000000..03fb4ffd984
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml/IXmlDataEvidence.cs
@@ -0,0 +1,20 @@
+//
+// IXmlDataEvidence.cs
+//
+// Author:
+// Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
+//
+#if NET_1_2
+
+using System;
+using System.Security.Policy;
+
+namespace System.Xml
+{
+
+ public interface IXmlDataEvidence
+ {
+ Evidence[] Evidences { get; }
+ }
+}
+#endif
diff --git a/mcs/class/System.XML/System.Xml/IXmlNamespaceResolver.cs b/mcs/class/System.XML/System.Xml/IXmlNamespaceResolver.cs
new file mode 100644
index 00000000000..b521d62042f
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml/IXmlNamespaceResolver.cs
@@ -0,0 +1,32 @@
+//
+// IXmlNamespaceResolver.cs
+//
+// Author:
+// Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
+//
+#if NET_1_2
+
+using System;
+using System.Collections.Specialized;
+using System.Security.Policy;
+using System.Xml.XPath;
+
+namespace System.Xml
+{
+ public interface IXmlNamespaceResolver
+ {
+ XmlNameTable NameTable { get; }
+
+ StringDictionary GetNamespacesInScope (XmlNamespaceScope scope);
+
+ string LookupNamespace (string prefix);
+
+ string LookupNamespace (string prefix, bool atomizedName);
+
+ string LookupPrefix (string ns);
+
+ string LookupPrefix (string ns, bool atomizedName);
+ }
+}
+
+#endif
diff --git a/mcs/class/System.XML/System.Xml/UpdateEventHandler.cs b/mcs/class/System.XML/System.Xml/UpdateEventHandler.cs
new file mode 100644
index 00000000000..c6458709292
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml/UpdateEventHandler.cs
@@ -0,0 +1,15 @@
+//
+// UpdateEventHandler.cs
+//
+// Author:
+// Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
+//
+//
+
+#if NET_1_2
+namespace System.Xml
+{
+ public delegate void UpdateEventHandler (object sender, XmlUpdateEventArgs e);
+}
+
+#endif
diff --git a/mcs/class/System.XML/System.Xml/XPathChangeNavigator.cs b/mcs/class/System.XML/System.Xml/XPathChangeNavigator.cs
new file mode 100644
index 00000000000..8bb6201d9ed
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml/XPathChangeNavigator.cs
@@ -0,0 +1,35 @@
+//
+// XPathChangeNavigator.cs
+//
+// Author:
+// Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
+//
+//
+#if NET_1_2
+
+using System;
+using System.Collections;
+
+namespace System.Xml
+{
+ public abstract class XPathChangeNavigator
+ : XPathNavigator2, IXPathChangeNavigator
+ {
+ protected XPathChangeNavigator ()
+ {
+ }
+
+ public abstract void AcceptChange ();
+
+ public abstract XmlNodeChangeType NodeChangeType { get; }
+
+ public abstract XPathEditor CreateXmlEditor ();
+
+ public abstract void RejectChange ();
+
+ public abstract IEnumerable SelectChanges (XmlChangeFilters changeTypes);
+ public abstract IEnumerable SelectChanges ();
+ }
+}
+
+#endif
diff --git a/mcs/class/System.XML/System.Xml/XPathDocument2.cs b/mcs/class/System.XML/System.Xml/XPathDocument2.cs
new file mode 100644
index 00000000000..a11d9977845
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml/XPathDocument2.cs
@@ -0,0 +1,205 @@
+//
+// XPathDocument2.cs
+//
+// Author:
+// Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
+//
+// (C)2003 Atsushi Enomoto
+//
+#if NET_1_2
+
+using System;
+using System.Collections;
+using System.IO;
+using System.Xml.Schema;
+
+namespace System.Xml
+{
+ public class XPathDocument2
+ {
+// XPathDocumentTree tree;
+ bool acceptChangesOnLoad;
+ XmlNameTable nameTable;
+ bool createDefaultDocument;
+
+ public XPathDocument2 () : this (null, false) {}
+
+ public XPathDocument2 (XmlNameTable nameTable) : this (nameTable, false) {}
+
+ public XPathDocument2 (bool createDefaultDocument) : this (null, createDefaultDocument) {}
+
+ // TODO
+ public XPathDocument2 (XmlNameTable nameTable, bool createDefaultDocument)
+ {
+ this.nameTable = nameTable;
+ this.createDefaultDocument = createDefaultDocument;
+ }
+
+// internal XPathDocumentTree Tree {
+// get { return tree; }
+// }
+
+ internal void DeleteNode (XPathNavigator2 nav)
+ {
+ throw new NotImplementedException ();
+ }
+
+ public event XPathDocument2ChangedEventHandler ChangeRejected;
+
+ public event XPathDocument2ChangedEventHandler ItemChanged;
+
+ public event XPathDocument2ChangedEventHandler ItemChanging;
+
+ public event XPathDocument2ChangedEventHandler ItemInserted;
+
+ public event XPathDocument2ChangedEventHandler ItemInserting;
+
+ public event XPathDocument2ChangedEventHandler ItemRemoved;
+
+ public event XPathDocument2ChangedEventHandler ItemRemoving;
+
+ public event XPathDocument2ChangedEventHandler RejectingChange;
+
+ public bool AcceptChangesOnLoad {
+ get { return acceptChangesOnLoad; }
+ set { acceptChangesOnLoad = value; }
+ }
+
+ public bool DefaultRoot {
+ get { throw new NotImplementedException (); }
+ }
+
+ public XmlNameTable NameTable {
+ get { return nameTable; }
+ }
+
+ public void AcceptChanges ()
+ {
+ throw new NotImplementedException ();
+ }
+
+ public bool CheckValidity (XmlSchemaSet schemas, ValidationEventHandler validationEventHandler)
+ {
+ throw new NotImplementedException ();
+ }
+
+ public XPathChangeNavigator CreateXPathChangeNavigator ()
+ {
+ throw new NotImplementedException ();
+ }
+
+ public XPathEditor CreateXPathEditor ()
+ {
+// return new XPathDocumentEditor (this);
+ throw new NotImplementedException ();
+ }
+
+ public XPathNavigator2 CreateXPathNavigator2 ()
+ {
+// return new XPathDocumentNavigator2 (this);
+ throw new NotImplementedException ();
+ }
+
+ public bool HasChanges ()
+ {
+ throw new NotImplementedException ();
+ }
+
+ public bool HasChanges (XmlChangeFilters changeFilter)
+ {
+ throw new NotImplementedException ();
+ }
+
+ public bool IsDeletedFragment (XPathNavigator2 xmlNavigator, bool isPermanent)
+ {
+ throw new NotImplementedException ();
+ }
+
+ public bool IsDeletedFragment (XPathNavigator2 xmlNavigator)
+ {
+ throw new NotImplementedException ();
+ }
+
+ public void Load (string url)
+ {
+ XmlTextReader xtr = new XmlTextReader (url);
+ Load (xtr);
+ xtr.Close ();
+ }
+
+ public void Load (TextReader reader)
+ {
+ XmlTextReader xtr = new XmlTextReader (reader);
+ Load (xtr);
+ }
+
+ public void Load (Stream stream)
+ {
+ XmlTextReader xtr = new XmlTextReader (stream);
+ Load (xtr);
+ }
+
+ public void LoadXml (string xml)
+ {
+ XmlTextReader xtr = new XmlTextReader (xml, XmlNodeType.Document, null);
+ Load (xtr);
+ xtr.Close ();
+ }
+
+ public void Load (XmlReader xmlReader)
+ {
+// tree = new XPathDocumentTree (xmlReader);
+ if (acceptChangesOnLoad)
+ AcceptChanges ();
+ }
+
+ public void RejectChanges ()
+ {
+ throw new NotImplementedException ();
+ }
+
+ public void Validate (XmlSchemaSet schemas, ValidationEventHandler validationEventHandler)
+ {
+ throw new NotImplementedException ();
+ }
+ }
+
+ public class XPathDocument2ChangedEventArgs : EventArgs
+ {
+ XPathDocument2ChangedEventAction action;
+
+ internal XPathDocument2ChangedEventArgs (XPathDocument2ChangedEventAction action, XPathNavigator2 nav)
+ {
+ this.action = action;
+ throw new NotImplementedException ();
+ }
+
+ public XPathDocument2ChangedEventAction Action {
+ get { return action; }
+ }
+
+ public XPathNavigator2 Item {
+ get { throw new NotImplementedException (); }
+ }
+ public XPathNavigator2 NewParent {
+ get { throw new NotImplementedException (); }
+ }
+ public XPathNavigator2 NewPreviousItem {
+ get { throw new NotImplementedException (); }
+ }
+ public string NewValue {
+ get { throw new NotImplementedException (); }
+ }
+ public XPathNavigator2 OldParent {
+ get { throw new NotImplementedException (); }
+ }
+ public XPathNavigator2 OldPreviousItem {
+ get { throw new NotImplementedException (); }
+ }
+ public string OldValue {
+ get { throw new NotImplementedException (); }
+ }
+ }
+}
+
+#endif
diff --git a/mcs/class/System.XML/System.Xml/XPathDocument2ChangedEventAction.cs b/mcs/class/System.XML/System.Xml/XPathDocument2ChangedEventAction.cs
new file mode 100644
index 00000000000..b27df9480ca
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml/XPathDocument2ChangedEventAction.cs
@@ -0,0 +1,23 @@
+//
+// XPathDocument2ChangedEventAction.cs
+//
+// Author:
+// Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
+//
+#if NET_1_2
+
+namespace System.Xml
+{
+ public enum XPathDocument2ChangedEventAction
+ {
+ Inserted,
+ Removed,
+ Changed,
+ Inserting,
+ Removing,
+ Changing,
+ Rejecting,
+ Rejected
+ }
+}
+#endif
diff --git a/mcs/class/System.XML/System.Xml/XPathDocument2ChangedEventHandler.cs b/mcs/class/System.XML/System.Xml/XPathDocument2ChangedEventHandler.cs
new file mode 100644
index 00000000000..9bc699c518a
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml/XPathDocument2ChangedEventHandler.cs
@@ -0,0 +1,15 @@
+//
+// XPathDocument2ChangedEventHandler.cs
+//
+// Author:
+// Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
+//
+//
+
+#if NET_1_2
+namespace System.Xml
+{
+ public delegate void XPathDocument2ChangedEventHandler (object sender, XmlUpdateEventArgs e);
+}
+
+#endif
diff --git a/mcs/class/System.XML/System.Xml/XPathEditor.cs b/mcs/class/System.XML/System.Xml/XPathEditor.cs
new file mode 100644
index 00000000000..82674f4a6ae
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml/XPathEditor.cs
@@ -0,0 +1,76 @@
+//
+// XPathEditor.cs
+//
+// Author:
+// Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
+//
+// (C)2003 Atsushi Enomoto
+//
+
+#if NET_1_2
+
+using System;
+using System.Collections;
+using System.Collections.Specialized;
+using System.ComponentModel;
+using System.IO;
+using System.Security.Policy;
+using System.Xml.Schema;
+using System.Xml.XPath;
+//using Mono.Xml.XPath2;
+//using MS.Internal.Xml;
+
+namespace System.Xml
+{
+ public abstract class XPathEditor : XPathNavigator2, IXPathEditor
+ {
+ protected XPathEditor ()
+ {
+ }
+
+ public abstract XPathNavigator2 CloneAsNavigator ();
+
+ public abstract XmlWriter CreateAttributes ();
+
+ // TODO: Where to use schemaType?
+ public void CreateAttributeString (string prefix, string name, string ns, XmlSchemaType schemaType, string value)
+ {
+ XmlWriter xw = CreateAttributes ();
+ xw.WriteAttributeString (prefix, name, ns, value);
+ xw.Close ();
+ }
+
+ public abstract XmlWriter CreateFirstChild ();
+
+ public abstract void CreateFirstChild (string xmlFragments);
+
+ // TODO: Where to use schemaType?
+ public void CreateFirstChildElement (string prefix, string name, string ns, XmlSchemaType schemaType, string value)
+ {
+ XmlWriter xw = CreateFirstChild ();
+ xw.WriteStartElement (prefix, name, ns);
+ xw.WriteString (value);
+ xw.WriteEndElement ();
+ xw.Close ();
+ }
+
+ public abstract XmlWriter CreateNextSibling ();
+ public abstract void CreateNextSibling (string xmlFragment);
+
+ // TODO: Where to use schemaType?
+ public void CreateNextSiblingElement (string prefix, string name, string ns, XmlSchemaType schemaType, string value)
+ {
+ XmlWriter xw = CreateNextSibling ();
+ xw.WriteStartElement (prefix, name, ns);
+ xw.WriteString (value);
+ xw.WriteEndElement ();
+ xw.Close ();
+ }
+
+ public abstract void DeleteCurrent ();
+
+ public abstract void SetValue (string text);
+ }
+}
+
+#endif
diff --git a/mcs/class/System.XML/System.Xml/XPathNavigator2.cs b/mcs/class/System.XML/System.Xml/XPathNavigator2.cs
new file mode 100644
index 00000000000..cfa6b39179f
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml/XPathNavigator2.cs
@@ -0,0 +1,644 @@
+//
+// XPathNavigator2.cs
+//
+// Author:
+// Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
+//
+// (C)2003 Atsushi Enomoto
+//
+#if NET_1_2
+
+using System;
+using System.Collections;
+using System.Collections.Specialized;
+using System.ComponentModel;
+using System.IO;
+using System.Security.Policy;
+//using System.Xml.Query;
+using System.Xml.Schema;
+using System.Xml.XPath;
+//using Mono.Xml.XPath2;
+//using MS.Internal.Xml;
+
+namespace System.Xml
+{
+ public abstract class XPathNavigator2
+ : ICloneable, ICustomTypeDescriptor, IXmlDataEvidence,
+ IXmlNamespaceResolver, IXPathNavigator//,
+// MS.Internal.Xml.IXmlInfoItem
+ {
+ protected XPathNavigator2 ()
+ {
+ }
+
+ public abstract string BaseUri { get; }
+
+ public virtual Evidence [] Evidences {
+ get { throw new NotImplementedException (); }
+ }
+
+ public bool HasAttributes {
+ get {
+ if (ItemType != XmlInfoItemType.Element)
+ return false;
+ if (MoveToFirstAttribute () == null)
+ return false;
+ MoveToParent ();
+ return true;
+ }
+ }
+
+ public bool HasChildren {
+ get {
+ if (MoveToFirstChild () == null)
+ return false;
+ MoveToParent ();
+ return true;
+ }
+ }
+
+ public string InnerXml {
+ get { throw new NotImplementedException (); }
+ }
+
+ public abstract XmlInfoItemType ItemType { get; }
+
+ public abstract string LocalName { get; }
+
+ public abstract string Name { get; }
+
+ public abstract string Namespace { get; }
+
+ public abstract XmlNameTable NameTable { get; }
+
+ public string OuterXml {
+ get { throw new NotImplementedException (); }
+ }
+
+ public abstract string Prefix { get; }
+
+// public MS.Internal.Xml.IXmlSchemaInfo SchemaInfo {
+// get { throw new NotImplementedException (); }
+// }
+
+ public virtual object Schemas {
+ get { throw new NotImplementedException (); }
+ }
+
+ public virtual Type StorageType {
+ get { throw new NotImplementedException (); }
+ }
+
+ public virtual object UnderlyingObject {
+ get { throw new NotImplementedException (); }
+ }
+
+// public virtual IXmlType XmlType {
+// get { throw new NotImplementedException (); }
+// }
+
+ public virtual bool CheckValidity (XmlSchemaSet schemas, ValidationEventHandler validationEventHandler)
+ {
+ throw new NotImplementedException ();
+ }
+
+ public abstract XPathNavigator2 Clone ();
+
+ IXPathNavigator IXPathNavigator.Clone ()
+ {
+ return this.Clone ();
+ }
+
+ public abstract XmlNodeOrder ComparePosition (IXPathNavigator other);
+
+// public IXmlInfosetReader CopyToReader ()
+// {
+// throw new NotImplementedException ();
+// }
+
+ // IMHO it should be virtual, even if Microsoft has excellent implementation.
+ public string GetAttribute (string localName, string namespaceName)
+ {
+ string value = null;
+ XmlInfoItemType cacheItemType = ItemType;
+ string currentName = LocalName;
+ string currentNs = Namespace;
+ IXPathNavigator tmp = MoveToAttribute (localName, namespaceName);
+ if (tmp != null) {
+ value = ReadStringValue ();
+ MoveToParent ();
+ switch (cacheItemType) {
+ case XmlInfoItemType.Attribute:
+ MoveToAttribute (currentName, currentNs);
+ break;
+ case XmlInfoItemType.Namespace:
+ MoveToNamespace (currentNs);
+ break;
+ }
+ }
+ return value;
+ }
+
+ public virtual StringDictionary GetNamespacesInScope (XmlNamespaceScope scope)
+ {
+ StringDictionary dict = new StringDictionary ();
+ XPathNavigator2 nav = Clone ();
+ IXPathNavigator ns = nav.MoveToFirstNamespace (scope);
+ if (ns != null) {
+ do {
+ dict.Add (nav.LocalName, nav.Namespace);
+ ns = nav.MoveToNextNamespace (scope);
+ } while (ns != null);
+ }
+ return dict;
+ }
+
+ /*private*/ object ICloneable.Clone()
+ {
+ return Clone ();
+ }
+
+ /*private*/ AttributeCollection ICustomTypeDescriptor.GetAttributes ()
+ {
+ throw new NotImplementedException ();
+ }
+
+ /*private*/ string ICustomTypeDescriptor.GetClassName()
+ {
+ throw new NotImplementedException ();
+ }
+
+ /*private*/ string ICustomTypeDescriptor.GetComponentName()
+ {
+ throw new NotImplementedException ();
+ }
+
+ /*private*/ TypeConverter ICustomTypeDescriptor.GetConverter()
+ {
+ throw new NotImplementedException ();
+ }
+
+ /*private*/ EventDescriptor ICustomTypeDescriptor.GetDefaultEvent ()
+ {
+ throw new NotImplementedException ();
+ }
+
+ /*private*/ PropertyDescriptor ICustomTypeDescriptor.GetDefaultProperty ()
+ {
+ throw new NotImplementedException ();
+ }
+
+ /*private*/ object ICustomTypeDescriptor.GetEditor (Type editorBaseType)
+ {
+ throw new NotImplementedException ();
+ }
+
+ /*private*/ EventDescriptorCollection ICustomTypeDescriptor.GetEvents ()
+ {
+ throw new NotImplementedException ();
+ }
+
+ /*private*/ EventDescriptorCollection ICustomTypeDescriptor.GetEvents (Attribute[] attrs)
+ {
+ throw new NotImplementedException ();
+ }
+
+ /*private*/ PropertyDescriptorCollection ICustomTypeDescriptor.GetProperties ()
+ {
+ throw new NotImplementedException ();
+ }
+
+ /*private*/ PropertyDescriptorCollection ICustomTypeDescriptor.GetProperties (Attribute [] attrs)
+ {
+ throw new NotImplementedException ();
+ }
+
+ /*private*/ object ICustomTypeDescriptor.GetPropertyOwner (PropertyDescriptor pd)
+ {
+ throw new NotImplementedException ();
+ }
+
+ public virtual bool IsDescendant (IXPathNavigator other)
+ {
+ IXPathNavigator nav = other as XPathNavigator2;
+ if (nav == null)
+ throw new ArgumentException ();
+
+ nav = nav.Clone ();
+ do {
+ if (IsSamePosition (nav))
+ return true;
+ nav = nav.MoveToParent ();
+ } while (nav != null);
+
+ return false;
+ }
+
+ public virtual bool IsSamePosition (IXPathNavigator other)
+ {
+ return (ComparePosition (other) == XmlNodeOrder.Same);
+ }
+/*
+ MS.Internal.Xml.IXmlInfosetReader IXmlInfoItem.CopyToReader ()
+ {
+ throw new NotImplementedException ();
+ }
+
+ IXPathNavigator IXPathNavigator.Clone ()
+ {
+ return Clone ();
+ }
+*/
+ public virtual string LookupNamespace (string prefix)
+ {
+ return LookupNamespace (prefix, false);
+ }
+
+ public virtual string LookupNamespace (string prefix, bool atomizedNames)
+ {
+ return LookupNamespaceNode (prefix, atomizedNames, true);
+ }
+
+ public virtual string LookupPrefix (string ns)
+ {
+ return LookupPrefix (ns, false);
+ }
+
+ public virtual string LookupPrefix (string ns, bool atomizedNames)
+ {
+ return LookupNamespaceNode (ns, atomizedNames, false);
+ }
+
+ private string LookupNamespaceNode (string str, bool atomizedNames, bool isPrefix)
+ {
+ string value = null;
+ XmlInfoItemType cacheItemType = ItemType;
+ string currentName = LocalName;
+ string currentNs = Namespace;
+ IXPathNavigator tmp = MoveToFirstNamespace (XmlNamespaceScope.All);
+ if (tmp == null)
+ return null;
+ do {
+ if (atomizedNames) {
+ if (isPrefix) {
+ if (Object.ReferenceEquals (LocalName, str)) {
+ value = Namespace;
+ break;
+ }
+ } else {
+ if (Object.ReferenceEquals (Namespace, str)) {
+ value = LocalName;
+ break;
+ }
+ }
+ } else {
+ if (isPrefix) {
+ if (LocalName == str) {
+ value = Namespace;
+ break;
+ }
+ } else {
+ if (Namespace == str) {
+ value = Name;
+ break;
+ }
+ }
+ }
+ tmp = MoveToNextNamespace (XmlNamespaceScope.All);
+ } while (tmp != null);
+ MoveToParent ();
+
+ switch (cacheItemType) {
+ case XmlInfoItemType.Attribute:
+ MoveToAttribute (currentName, currentNs);
+ break;
+ case XmlInfoItemType.Namespace:
+ MoveToNamespace (currentNs);
+ break;
+ }
+
+ return value;
+ }
+
+ public abstract IXPathNavigator MoveTo (IXPathNavigator other);
+ // In the meantime, we should wait System.Data.SqlXml.dll became public.
+// public abstract XPathNavigator2 MoveTo (XmlCommand command, XmlQueryArgumentList argList);
+ public abstract XPathNavigator2 MoveTo (string query);
+ public abstract XPathNavigator2 MoveTo (string query, IXmlNamespaceResolver namespaceResolver);
+ public abstract XPathNavigator2 MoveTo (string query, IXmlNamespaceResolver namespaceResolver, XmlQueryDialect dialect);
+
+ public virtual XPathNavigator2 MoveToAttribute (string localName, string namespaceName)
+ {
+ return MoveToAttribute (localName, namespaceName, false) as XPathNavigator2;
+ }
+
+ public virtual IXPathNavigator MoveToAttribute (string localName, string namespaceName, bool atomizedNames)
+ {
+ XmlInfoItemType cacheItemType = ItemType;
+ string currentName = LocalName;
+ string currentNs = Namespace;
+ IXPathNavigator tmp = MoveToFirstAttribute ();
+ if (tmp == null)
+ return null;
+ do {
+ if (atomizedNames) {
+ if (Object.ReferenceEquals (LocalName, localName) && Object.ReferenceEquals (Namespace, namespaceName))
+ return this;
+ } else {
+ if (LocalName == localName && Namespace == namespaceName)
+ return this;
+ }
+ tmp = MoveToNextAttribute ();
+ } while (tmp != null);
+ MoveToParent ();
+
+ switch (cacheItemType) {
+ case XmlInfoItemType.Attribute:
+ MoveToAttribute (currentName, currentNs);
+ break;
+ case XmlInfoItemType.Namespace:
+ MoveToNamespace (currentNs);
+ break;
+ }
+
+ return null;
+ }
+
+ public virtual IXPathNavigator MoveToChild (string localName, string namespaceName, bool atomizedNames)
+ {
+ return MoveToChild (localName, namespaceName, atomizedNames, XmlInfoItemType.Document, false);
+ }
+
+ public virtual IXPathNavigator MoveToChild (XmlInfoItemType type)
+ {
+ return MoveToChild (null, null, false, type, true);
+ }
+
+ public virtual XPathNavigator2 MoveToChild (string localName, string namespaceName)
+ {
+ return MoveToChild (localName, namespaceName, false) as XPathNavigator2;
+ }
+
+ private IXPathNavigator MoveToChild (string localName, string namespaceName, bool atomizedNames, XmlInfoItemType type, bool byType)
+ {
+ XmlInfoItemType cacheItemType = ItemType;
+ string currentName = LocalName;
+ string currentNs = Namespace;
+ IXPathNavigator tmp = MoveToFirstChild ();
+ if (tmp == null)
+ return null;
+
+ do {
+ if (byType) {
+ if (type == ItemType)
+ return this;
+ } else if (atomizedNames) {
+ if (Object.ReferenceEquals (LocalName, localName) && Object.ReferenceEquals (Namespace, namespaceName))
+ return this;
+ } else {
+ if (LocalName == localName && Namespace == namespaceName)
+ return this;
+ }
+ tmp = MoveToNextSibling ();
+ } while (tmp != null);
+ MoveToParent ();
+
+ switch (cacheItemType) {
+ case XmlInfoItemType.Attribute:
+ MoveToAttribute (currentName, currentNs);
+ break;
+ case XmlInfoItemType.Namespace:
+ MoveToNamespace (currentNs);
+ break;
+ }
+
+ return null;
+ }
+
+ public virtual IXPathNavigator MoveToDescendantOf (IXPathNavigator root, string localName, string namespaceName, bool atomizedNames)
+ {
+ throw new NotImplementedException ();
+ }
+
+ public virtual IXPathNavigator MoveToDescendantOf (IXPathNavigator root, XmlInfoItemType type)
+ {
+ throw new NotImplementedException ();
+ }
+
+ public abstract IXPathNavigator MoveToFirstAttribute ();
+
+ public abstract IXPathNavigator MoveToFirstChild ();
+
+ public abstract IXPathNavigator MoveToFirstNamespace (XmlNamespaceScope scope);
+
+ public abstract IXPathNavigator MoveToFirstValue ();
+
+
+ public virtual IXPathNavigator MoveToId (string id)
+ {
+ throw new NotImplementedException ();
+ }
+
+ public XPathNavigator2 MoveToNamespace (string prefix)
+ {
+ return MoveToNamespace (prefix, false);
+ }
+
+ public XPathNavigator2 MoveToNamespace (string prefix, bool atomizedNames)
+ {
+ throw new NotImplementedException ();
+ }
+
+ public abstract IXPathNavigator MoveToNextAttribute ();
+
+ public abstract IXPathNavigator MoveToNextNamespace (XmlNamespaceScope scope);
+
+ public abstract IXPathNavigator MoveToNextSibling ();
+
+ public abstract IXPathNavigator MoveToNextValue ();
+
+ public abstract IXPathNavigator MoveToParent ();
+
+ public virtual IXPathNavigator MoveToPreviousSibling ()
+ {
+ IXPathNavigator backup = Clone ();
+ IXPathNavigator tmp = MoveToParent ();
+ if (tmp == null)
+ return null;
+ tmp = MoveToFirstChild ();
+ do {
+ if (tmp.IsSamePosition (backup))
+ return this;
+ tmp = MoveToNextSibling ();
+ } while (tmp != null);
+
+ return null;
+ }
+
+ public virtual IXPathNavigator MoveToRoot ()
+ {
+ IXPathNavigator tmp = MoveToParent ();
+ while (tmp != null)
+ MoveToParent ();
+ return this;
+ }
+
+ public virtual XPathNavigator2 MoveToSibling (string localName, string namespaceName)
+ {
+ return (XPathNavigator2) MoveToSibling (localName, namespaceName, false);
+ }
+
+ public virtual IXPathNavigator MoveToSibling (string localName, string namespaceName, bool atomizedNames)
+ {
+ return MoveToSibling (localName, namespaceName, atomizedNames, XmlInfoItemType.Document, false);
+ }
+
+ public virtual IXPathNavigator MoveToSibling (XmlInfoItemType type)
+ {
+ return MoveToSibling (null, null, false, type, true);
+ }
+
+ private IXPathNavigator MoveToSibling (string localName, string namespaceName, bool atomizedNames, XmlInfoItemType type, bool byType)
+ {
+ XmlInfoItemType cacheItemType = ItemType;
+ string currentName = LocalName;
+ string currentNs = Namespace;
+ IXPathNavigator tmp = MoveToNextSibling ();
+ if (tmp == null)
+ return null;
+
+ int count = 0;
+ while (tmp != null) {
+ count++;
+ if (byType) {
+ if (type == ItemType)
+ return this;
+ } else if (atomizedNames) {
+ if (Object.ReferenceEquals (LocalName, localName) && Object.ReferenceEquals (Namespace, namespaceName))
+ return this;
+ } else {
+ if (LocalName == localName && Namespace == namespaceName)
+ return this;
+ }
+ tmp = MoveToNextSibling ();
+ }
+ for (int i = 0; i < count; i++)
+ MoveToPreviousSibling ();
+ return null;
+ }
+
+ public virtual bool ReadboolValue ()
+ {
+ throw new NotImplementedException ();
+ }
+
+ public virtual byte ReadByteValue ()
+ {
+ throw new NotImplementedException ();
+ }
+
+ public virtual char ReadCharValue ()
+ {
+ throw new NotImplementedException ();
+ }
+
+ public virtual DateTime ReadDateTimeValue ()
+ {
+ throw new NotImplementedException ();
+ }
+
+ public virtual decimal ReadDecimalValue ()
+ {
+ throw new NotImplementedException ();
+ }
+
+ public virtual double ReadDoubleValue ()
+ {
+ throw new NotImplementedException ();
+ }
+
+ public virtual short ReadInt16Value ()
+ {
+ throw new NotImplementedException ();
+ }
+
+ public virtual int ReadintValue ()
+ {
+ throw new NotImplementedException ();
+ }
+
+ public virtual long ReadInt64Value ()
+ {
+ throw new NotImplementedException ();
+ }
+
+ public virtual float ReadSingleValue ()
+ {
+ throw new NotImplementedException ();
+ }
+
+ public virtual string ReadStringValue ()
+ {
+ throw new NotImplementedException ();
+ }
+
+ public virtual object ReadValue ()
+ {
+ throw new NotImplementedException ();
+ }
+
+ public virtual object ReadValue (Type type)
+ {
+ throw new NotImplementedException ();
+ }
+
+ // TODO
+ // In the meantime, we should wait System.Data.SqlXml.dll became public.
+// public IEnumerable Select (XmlCommand command, XmlQueryArgumentList argList)
+// {
+// throw new NotImplementedException ();
+// }
+
+ public IEnumerable Select (string query)
+ {
+ return Select (query, null);
+ }
+
+ public IEnumerable Select (string query, IXmlNamespaceResolver namespaceResolver)
+ {
+ // TODO: check the true default dialect
+ return Select (query, namespaceResolver, XmlQueryDialect.XPath1);
+ }
+
+ // TODO
+ public IEnumerable Select (string query, IXmlNamespaceResolver namespaceResolver, XmlQueryDialect dialect)
+ {
+ throw new NotImplementedException ();
+ }
+
+ // TODO
+ // In the meantime, we should wait System.Data.SqlXml.dll became public.
+// public object SelectSingleValue (XmlCommand command, XmlQueryArgumentList argList)
+// {
+// throw new NotImplementedException ();
+// }
+
+ public object SelectSingleValue (string query)
+ {
+ return SelectSingleValue (query, null);
+ }
+
+ public object SelectSingleValue (string query, IXmlNamespaceResolver namespaceResolver)
+ {
+ return SelectSingleValue (query, namespaceResolver, XmlQueryDialect.XPath1);
+ }
+
+ // TODO
+ public object SelectSingleValue (string query, IXmlNamespaceResolver namespaceResolver, XmlQueryDialect dialect)
+ {
+ throw new NotImplementedException ();
+ }
+ }
+}
+
+#endif
diff --git a/mcs/class/System.XML/System.Xml/XmlAttribute.cs b/mcs/class/System.XML/System.Xml/XmlAttribute.cs
index 696bbcd4f50..dd1906646d9 100644
--- a/mcs/class/System.XML/System.Xml/XmlAttribute.cs
+++ b/mcs/class/System.XML/System.Xml/XmlAttribute.cs
@@ -161,6 +161,8 @@ namespace System.Xml
throw new XmlException ("This node is readonly.");
if (!XmlChar.IsNCName (value))
throw new ArgumentException ("Specified name is not a valid NCName: " + value);
+ if (prefix == "xmlns" && value != "xmlns")
+ throw new ArgumentException ("Cannot bind to the reserved namespace.");
prefix = value;
}
diff --git a/mcs/class/System.XML/System.Xml/XmlChangeFilters.cs b/mcs/class/System.XML/System.Xml/XmlChangeFilters.cs
new file mode 100644
index 00000000000..a5a5c2bee72
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml/XmlChangeFilters.cs
@@ -0,0 +1,19 @@
+//
+// XmlChangeFilters.cs
+//
+// Author:
+// Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
+//
+#if NET_1_2
+
+namespace System.Xml
+{
+ public enum XmlChangeFilters
+ {
+ Updated,
+ Inserted,
+ Deleted,
+ AllChanges
+ }
+}
+#endif
diff --git a/mcs/class/System.XML/System.Xml/XmlInfoItemType.cs b/mcs/class/System.XML/System.Xml/XmlInfoItemType.cs
new file mode 100644
index 00000000000..457ff5c64eb
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml/XmlInfoItemType.cs
@@ -0,0 +1,23 @@
+//
+// XmlInfoItemType.cs
+//
+// Author:
+// Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
+//
+#if NET_1_2
+
+namespace System.Xml
+{
+ public enum XmlInfoItemType
+ {
+ Element,
+ Attribute,
+ Namespace,
+ Text,
+ ProcessingInstruction,
+ Comment,
+ Document,
+ AtomicValue
+ }
+}
+#endif
diff --git a/mcs/class/System.XML/System.Xml/XmlNamespaceScope.cs b/mcs/class/System.XML/System.Xml/XmlNamespaceScope.cs
new file mode 100644
index 00000000000..372d0cc24d9
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml/XmlNamespaceScope.cs
@@ -0,0 +1,21 @@
+//
+// XmlNamespaceScope.cs
+//
+// Author:
+// Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
+//
+// Note that this is different from "XPathNamespaceScope"
+// while the member definitions are all the same.
+//
+#if NET_1_2
+
+namespace System.Xml
+{
+ public enum XmlNamespaceScope
+ {
+ All,
+ ExcludeXml,
+ Local
+ }
+}
+#endif
diff --git a/mcs/class/System.XML/System.Xml/XmlNode.cs b/mcs/class/System.XML/System.Xml/XmlNode.cs
index 9614da918c3..17e2ccf33ee 100644
--- a/mcs/class/System.XML/System.Xml/XmlNode.cs
+++ b/mcs/class/System.XML/System.Xml/XmlNode.cs
@@ -615,7 +615,6 @@ namespace System.Xml
return SelectNodes (xpath, null);
}
- [MonoTODO ("return nodes in document order")]
public XmlNodeList SelectNodes (string xpath, XmlNamespaceManager nsmgr)
{
XPathNavigator nav = CreateNavigator ();
@@ -636,7 +635,6 @@ namespace System.Xml
return SelectSingleNode (xpath, null);
}
- [MonoTODO ("return node in document order")]
public XmlNode SelectSingleNode (string xpath, XmlNamespaceManager nsmgr)
{
XPathNavigator nav = CreateNavigator ();
@@ -665,7 +663,6 @@ namespace System.Xml
// It parses this and all the ancestor elements,
// find 'xmlns' declarations, stores and then return them.
- // TODO: tests
internal XmlNamespaceManager ConstructNamespaceManager ()
{
XmlDocument doc = this is XmlDocument ? (XmlDocument)this : this.OwnerDocument;
diff --git a/mcs/class/System.XML/System.Xml/XmlNodeChangeType.cs b/mcs/class/System.XML/System.Xml/XmlNodeChangeType.cs
new file mode 100644
index 00000000000..71ad70ee3b0
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml/XmlNodeChangeType.cs
@@ -0,0 +1,19 @@
+//
+// XmlNodeChangeType.cs
+//
+// Author:
+// Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
+//
+#if NET_1_2
+
+namespace System.Xml
+{
+ public enum XmlNodeChangeType
+ {
+ Updated,
+ Inserted,
+ Deleted,
+ Unchanged
+ }
+}
+#endif
diff --git a/mcs/class/System.XML/System.Xml/XmlQualifiedNameTable.cs b/mcs/class/System.XML/System.Xml/XmlQualifiedNameTable.cs
new file mode 100644
index 00000000000..e7e5a5428e7
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml/XmlQualifiedNameTable.cs
@@ -0,0 +1,53 @@
+//
+// XmlQualifiedNameTable.cs
+//
+// Author:
+// Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
+//
+//
+#if NET_1_2
+
+using System;
+using System.Collections;
+
+namespace System.Xml
+{
+ public class XmlQualifiedNameTable
+ {
+ public XmlQualifiedNameTable (XmlNameTable nt)
+ {
+ throw new NotImplementedException ();
+ }
+
+ public XmlNameTable NameTable {
+ get { throw new NotImplementedException (); }
+ }
+
+ public XmlQualifiedName Add (string name, string ns)
+ {
+ throw new NotImplementedException ();
+ }
+
+ public XmlQualifiedName AtomizedAdd (string name, string ns)
+ {
+ throw new NotImplementedException ();
+ }
+
+ public XmlQualifiedName AtomizedGet (string name, string ns)
+ {
+ throw new NotImplementedException ();
+ }
+
+ public XmlQualifiedName Get (string name, string ns)
+ {
+ throw new NotImplementedException ();
+ }
+
+ public IEnumerator GetEnumerator()
+ {
+ throw new NotImplementedException ();
+ }
+ }
+}
+
+#endif
diff --git a/mcs/class/System.XML/System.Xml/XmlQueryDialect.cs b/mcs/class/System.XML/System.Xml/XmlQueryDialect.cs
new file mode 100644
index 00000000000..7bf29aa9c6b
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml/XmlQueryDialect.cs
@@ -0,0 +1,17 @@
+//
+// XmlQueryDialect.cs
+//
+// Author:
+// Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
+//
+#if NET_1_2
+
+namespace System.Xml
+{
+ public enum XmlQueryDialect
+ {
+ XPath1,
+ XQuery
+ }
+}
+#endif
diff --git a/mcs/class/System.XML/System.Xml/XmlTextReader.cs b/mcs/class/System.XML/System.Xml/XmlTextReader.cs
index 641f574ea94..49985b54853 100644
--- a/mcs/class/System.XML/System.Xml/XmlTextReader.cs
+++ b/mcs/class/System.XML/System.Xml/XmlTextReader.cs
@@ -649,6 +649,7 @@ namespace System.Xml
}
#if NET_1_0
+ StringBuilder innerXmlBuilder;
public override string ReadInnerXml ()
{
if (readState != ReadState.Interactive)
@@ -656,7 +657,7 @@ namespace System.Xml
switch (NodeType) {
case XmlNodeType.Attribute:
- return value.Substring (1, value.Length - 2);
+ return Value;
case XmlNodeType.Element:
if (IsEmptyElement)
return String.Empty;
diff --git a/mcs/class/System.XML/System.Xml/XmlTextWriter.cs b/mcs/class/System.XML/System.Xml/XmlTextWriter.cs
index 9bedad9fc90..706a28a6a69 100644
--- a/mcs/class/System.XML/System.Xml/XmlTextWriter.cs
+++ b/mcs/class/System.XML/System.Xml/XmlTextWriter.cs
@@ -47,6 +47,7 @@ namespace System.Xml
string openElementNS;
bool hasRoot = false;
Hashtable newAttributeNamespaces = new Hashtable ();
+ Hashtable userWrittenNamespaces = new Hashtable ();
XmlNamespaceManager namespaceManager = new XmlNamespaceManager (new NameTable ());
string savingAttributeValue = String.Empty;
@@ -210,8 +211,9 @@ namespace System.Xml
namespaceManager.AddNamespace (prefix, ns);
}
}
- else if ((prefix == String.Empty) && (namespaceManager.LookupNamespace (prefix) != ns))
- {
+ else if ((prefix == String.Empty) &&
+ (namespaceManager.LookupNamespace (prefix) != ns) &&
+ userWrittenNamespaces [prefix] == null) {
namespaceManager.AddNamespace (prefix, ns);
formatXmlns = String.Format ("xmlns={0}{0}", quoteChar);
}
@@ -228,8 +230,6 @@ namespace System.Xml
string ans = (string) ent.Value;
string aprefix = (string) ent.Key;
- if (aprefix == prefix)
- continue;
if (namespaceManager.LookupNamespace (aprefix) == ans)
continue;
@@ -289,6 +289,7 @@ namespace System.Xml
openStartElement = false;
attributeWrittenForElement = false;
newAttributeNamespaces.Clear ();
+ userWrittenNamespaces.Clear ();
}
public override void Flush ()
@@ -469,6 +470,7 @@ namespace System.Xml
// add namespace
namespaceManager.AddNamespace (
savedAttributePrefix, savingAttributeValue);
+ userWrittenNamespaces [savedAttributePrefix] = savingAttributeValue;
saveAttributeValue = false;
savedAttributePrefix = String.Empty;
savingAttributeValue = String.Empty;
@@ -570,9 +572,12 @@ namespace System.Xml
// WriteStartDocument() cannot specify encoding, while WriteNode() can write it).
public override void WriteProcessingInstruction (string name, string text)
{
- if ((name == null) || (name == string.Empty) || (name.IndexOf("?>") > 0) || (text.IndexOf("?>") > 0)) {
+ if ((name == null) || (name == string.Empty))
throw new ArgumentException ();
- }
+ if (!XmlChar.IsName (name))
+ throw new ArgumentException ("Invalid processing instruction name.");
+ if ((text.IndexOf("?>") > 0))
+ throw new ArgumentException ("Processing instruction cannot contain \"?>\" as its value.");
CheckState ();
CloseStartElement ();
@@ -663,7 +668,12 @@ namespace System.Xml
}
if (createPrefix)
prefix = "d" + indentLevel + "p" + (newAttributeNamespaces.Count + 1);
- newAttributeNamespaces.Add (prefix, ns);
+
+ // check if prefix exists. If yes - check if namespace is the same.
+ if (newAttributeNamespaces [prefix] == null)
+ newAttributeNamespaces.Add (prefix, ns);
+ else if (!newAttributeNamespaces [prefix].Equals (ns))
+ throw new ArgumentException ("Duplicate prefix with different namespace");
}
if (prefix == String.Empty && ns != XmlnsNamespace)
@@ -756,6 +766,7 @@ namespace System.Xml
CheckState ();
CloseStartElement ();
newAttributeNamespaces.Clear ();
+ userWrittenNamespaces.Clear ();
if (prefix == null)
prefix = namespaceManager.LookupPrefix (ns);
diff --git a/mcs/class/System.XML/System.Xml/XmlUpdateEventArgs.cs b/mcs/class/System.XML/System.Xml/XmlUpdateEventArgs.cs
new file mode 100644
index 00000000000..ebec93cc16f
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml/XmlUpdateEventArgs.cs
@@ -0,0 +1,28 @@
+//
+// XmlUpdateEventArgs.cs
+//
+// Author:
+// Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
+//
+#if NET_1_2
+
+using System;
+using System.Collections;
+
+namespace System.Xml
+{
+ public abstract class XmlUpdateEventArgs
+ {
+
+ public XmlUpdateEventArgs ()
+ {
+ }
+
+ public abstract IEnumerable ErrorItems { get; }
+
+ public abstract bool Executed { get; }
+
+ public abstract Exception InnerException { get; }
+ }
+}
+#endif
diff --git a/mcs/class/System.XML/System.Xml/XmlWriter.cs b/mcs/class/System.XML/System.Xml/XmlWriter.cs
index de6317e25be..eba4dfa783f 100644
--- a/mcs/class/System.XML/System.Xml/XmlWriter.cs
+++ b/mcs/class/System.XML/System.Xml/XmlWriter.cs
@@ -173,9 +173,11 @@ namespace System.Xml
else {
int depth = reader.Depth;
reader.Read ();
- do {
- WriteNode (reader, defattr);
- } while (depth < reader.Depth);
+ if (reader.NodeType != XmlNodeType.EndElement) {
+ do {
+ WriteNode (reader, defattr);
+ } while (depth < reader.Depth);
+ }
WriteFullEndElement ();
}
break;
diff --git a/mcs/class/System.XML/Test/System.Xml/ChangeLog b/mcs/class/System.XML/Test/System.Xml/ChangeLog
index 5b416eaca51..c497a438ebf 100644
--- a/mcs/class/System.XML/Test/System.Xml/ChangeLog
+++ b/mcs/class/System.XML/Test/System.Xml/ChangeLog
@@ -1,3 +1,17 @@
+2003-11-28 Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
+
+ * XmlWriterTests.cs : Added WriteNodeFullDocument() with
+ encoding specification. Added WriteNodeNonEmptyElement().
+ * XmlUrlResolverTests.cs : Added GetEntityWithNonStreamReturnType()
+ and GetEntityWithRelativeFileUri().
+ * XmlTextWriterTests.cs : Added some namespace related tests.
+ * XmlTextReaderTests.cs : Added char-entity and ReadBase64() tests.
+ * XmlNodeTests.cs : GetPrefixOfNamespace() test also for disconnected
+ nodes.
+ * XmlElementTests.cs : Added ConstructionAndDefaultAttributes().
+ * XmlDeclarationTests.cs : Added InvalidInnerText().
+ * XmlAttributeTests.cs : Added CheckPrefixWithNamespace().
+
2003-10-13 Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
* XmlWriterTests.cs : Added WriteSurrogateCharEntity().
diff --git a/mcs/class/System.XML/Test/System.Xml/XmlAttributeTests.cs b/mcs/class/System.XML/Test/System.Xml/XmlAttributeTests.cs
index 929351cf0a7..20bfcc9bb40 100644
--- a/mcs/class/System.XML/Test/System.Xml/XmlAttributeTests.cs
+++ b/mcs/class/System.XML/Test/System.Xml/XmlAttributeTests.cs
@@ -87,6 +87,18 @@ namespace MonoTests.System.Xml
}
[Test]
+ [ExpectedException (typeof (ArgumentException))]
+ public void CheckPrefixWithNamespace ()
+ {
+ XmlDocument doc = new XmlDocument ();
+ doc.LoadXml ("<root xmlns:foo='urn:foo' foo='attfoo' foo:foo='attfoofoo' />");
+ // hogehoge does not match to any namespace.
+ AssertEquals ("xmlns:foo", doc.DocumentElement.Attributes [0].Name);
+ doc.DocumentElement.Attributes [0].Prefix="hogehoge";
+ doc.Save (Console.Out);
+ }
+
+ [Test]
public void NamespaceAttributes ()
{
try {
diff --git a/mcs/class/System.XML/Test/System.Xml/XmlElementTests.cs b/mcs/class/System.XML/Test/System.Xml/XmlElementTests.cs
index 49df8d408dc..4ac2f2681b3 100644
--- a/mcs/class/System.XML/Test/System.Xml/XmlElementTests.cs
+++ b/mcs/class/System.XML/Test/System.Xml/XmlElementTests.cs
@@ -87,6 +87,19 @@ namespace MonoTests.System.Xml
}
[Test]
+ public void ConstructionAndDefaultAttributes ()
+ {
+ string dtd = "<!DOCTYPE root [<!ELEMENT root EMPTY><!ATTLIST root foo CDATA 'def'>]>";
+ string xml = dtd + "<root />";
+ XmlValidatingReader xvr = new XmlValidatingReader (new XmlTextReader (xml, XmlNodeType.Document, null));
+ XmlDocument doc = new XmlDocument ();
+ doc.Load (xvr);
+ Console.WriteLine (doc.DocumentElement.Attributes.Count);
+ Console.WriteLine (doc.CreateElement ("root").Attributes.Count);
+ Console.WriteLine (doc.CreateElement ("root2").Attributes.Count);
+ }
+
+ [Test]
public void CreateElement1 ()
{
XmlElement element = document.CreateElement ("name");
diff --git a/mcs/class/System.XML/Test/System.Xml/XmlNodeTests.cs b/mcs/class/System.XML/Test/System.Xml/XmlNodeTests.cs
index e983c57c0a6..89798c150b0 100644
--- a/mcs/class/System.XML/Test/System.Xml/XmlNodeTests.cs
+++ b/mcs/class/System.XML/Test/System.Xml/XmlNodeTests.cs
@@ -204,36 +204,36 @@ namespace MonoTests.System.Xml
public void Normalize ()
{
XmlDocument doc = new XmlDocument ();
- doc.LoadXml ("<root>This is the <b>hardest</b> one.</root>");
- doc.NodeInserted += new XmlNodeChangedEventHandler (EventNodeInserted);
- doc.NodeChanged += new XmlNodeChangedEventHandler (EventNodeChanged);
- doc.NodeRemoved += new XmlNodeChangedEventHandler (EventNodeRemoved);
-
- AssertEquals (3, doc.DocumentElement.ChildNodes.Count);
-
- doc.DocumentElement.Normalize ();
- AssertEquals (3, doc.DocumentElement.ChildNodes.Count);
- Assert (changed);
- inserted = changed = removed = false;
-
- doc.DocumentElement.AppendChild (doc.CreateTextNode ("Addendum."));
- AssertEquals (4, doc.DocumentElement.ChildNodes.Count);
- inserted = changed = removed = false;
-
- doc.DocumentElement.Normalize ();
- AssertEquals (3, doc.DocumentElement.ChildNodes.Count);
- Assert (changed);
- Assert (removed);
- inserted = changed = removed = false;
-
- doc.DocumentElement.SetAttribute ("attr", "");
- XmlAttribute attr = doc.DocumentElement.Attributes [0] as XmlAttribute;
- AssertEquals (1, attr.ChildNodes.Count);
- inserted = changed = removed = false;
- attr.Normalize ();
- // Such behavior violates DOM Level 2 Node#normalize(),
- // but MS DOM is designed as such.
- AssertEquals (1, attr.ChildNodes.Count);
+ doc.LoadXml ("<root>This is the <b>hardest</b> one.</root>");
+ doc.NodeInserted += new XmlNodeChangedEventHandler (EventNodeInserted);
+ doc.NodeChanged += new XmlNodeChangedEventHandler (EventNodeChanged);
+ doc.NodeRemoved += new XmlNodeChangedEventHandler (EventNodeRemoved);
+
+ AssertEquals (3, doc.DocumentElement.ChildNodes.Count);
+
+ doc.DocumentElement.Normalize ();
+ AssertEquals (3, doc.DocumentElement.ChildNodes.Count);
+ Assert (changed);
+ inserted = changed = removed = false;
+
+ doc.DocumentElement.AppendChild (doc.CreateTextNode ("Addendum."));
+ AssertEquals (4, doc.DocumentElement.ChildNodes.Count);
+ inserted = changed = removed = false;
+
+ doc.DocumentElement.Normalize ();
+ AssertEquals (3, doc.DocumentElement.ChildNodes.Count);
+ Assert (changed);
+ Assert (removed);
+ inserted = changed = removed = false;
+
+ doc.DocumentElement.SetAttribute ("attr", "");
+ XmlAttribute attr = doc.DocumentElement.Attributes [0] as XmlAttribute;
+ AssertEquals (1, attr.ChildNodes.Count);
+ inserted = changed = removed = false;
+ attr.Normalize ();
+ // Such behavior violates DOM Level 2 Node#normalize(),
+ // but MS DOM is designed as such.
+ AssertEquals (1, attr.ChildNodes.Count);
}
[Test]
@@ -285,6 +285,13 @@ namespace MonoTests.System.Xml
AssertEquals ("c2", String.Empty, document.DocumentElement.FirstChild.GetPrefixOfNamespace ("urn:foo"));
AssertEquals ("c3", "foo", document.DocumentElement.FirstChild.FirstChild.GetPrefixOfNamespace ("urn:foo"));
+ // disconnected nodes.
+ XmlNode n = document.CreateElement ("foo");
+ AssertEquals (String.Empty, n.GetPrefixOfNamespace ("foo"));
+ n = document.CreateTextNode ("text"); // does not have Attributes
+ AssertEquals (String.Empty, n.GetPrefixOfNamespace ("foo"));
+ n = document.CreateXmlDeclaration ("1.0", null, null); // does not have Attributes
+ AssertEquals (String.Empty, n.GetPrefixOfNamespace ("foo"));
}
[Test]
@@ -317,12 +324,12 @@ namespace MonoTests.System.Xml
[Test]
public void InnerXmlWithXmlns ()
{
- XmlDocument document = new XmlDocument ();
- XmlElement xel = document.CreateElement ("KeyValue", "http://www.w3.org/2000/09/xmldsig#");
- xel.SetAttribute ("xmlns", "http://www.w3.org/2000/09/xmldsig#");
- xel.InnerXml = "<DSAKeyValue>blablabla</DSAKeyValue>";
- string expected = "<KeyValue xmlns=\"http://www.w3.org/2000/09/xmldsig#\"><DSAKeyValue>blablabla</DSAKeyValue></KeyValue>";
- AssertEquals (expected, xel.OuterXml);
+ XmlDocument document = new XmlDocument ();
+ XmlElement xel = document.CreateElement ("KeyValue", "http://www.w3.org/2000/09/xmldsig#");
+ xel.SetAttribute ("xmlns", "http://www.w3.org/2000/09/xmldsig#");
+ xel.InnerXml = "<DSAKeyValue>blablabla</DSAKeyValue>";
+ string expected = "<KeyValue xmlns=\"http://www.w3.org/2000/09/xmldsig#\"><DSAKeyValue>blablabla</DSAKeyValue></KeyValue>";
+ AssertEquals (expected, xel.OuterXml);
}
}
}
diff --git a/mcs/class/System.XML/Test/System.Xml/XmlTextReaderTests.cs b/mcs/class/System.XML/Test/System.Xml/XmlTextReaderTests.cs
index 25f6e96b798..fcde6e751f4 100644
--- a/mcs/class/System.XML/Test/System.Xml/XmlTextReaderTests.cs
+++ b/mcs/class/System.XML/Test/System.Xml/XmlTextReaderTests.cs
@@ -648,13 +648,22 @@ namespace MonoTests.System.Xml
doc.Load ("XmlFiles/nested-dtd-test.xml");
}
- // MS.NET 1.0 fails this test.
[Test]
[ExpectedException (typeof (XmlException))]
public void NotAllowedCharRef ()
{
string xml = "<root>&#0;</root>";
XmlTextReader xtr = new XmlTextReader (xml, XmlNodeType.Document, null);
+ xtr.Normalization = true;
+ xtr.Read ();
+ xtr.Read ();
+ }
+
+ [Test]
+ public void NotAllowedCharRefButPassNormalizationFalse ()
+ {
+ string xml = "<root>&#0;</root>";
+ XmlTextReader xtr = new XmlTextReader (xml, XmlNodeType.Document, null);
xtr.Read ();
xtr.Read ();
}
@@ -709,5 +718,53 @@ namespace MonoTests.System.Xml
doc.LoadXml (xml);
}
+ [Test]
+ public void ReadBase64 ()
+ {
+ byte [] bytes = new byte [] {4,14,54,114,134,184,254,255};
+
+ string base64 = "<root><foo>BA42coa44</foo></root>";
+ XmlTextReader xtr = new XmlTextReader (base64, XmlNodeType.Document, null);
+ byte [] bytes2 = new byte [10];
+ xtr.Read (); // root
+ xtr.Read (); // foo
+ this.AssertNodeValues (xtr, XmlNodeType.Element, 1, false, "foo", String.Empty,
+ "foo", String.Empty, String.Empty, 0);
+ AssertEquals (6, xtr.ReadBase64 (bytes2, 0, 10));
+ this.AssertNodeValues (xtr, XmlNodeType.EndElement, 0, false, "root", String.Empty,
+ "root", String.Empty, String.Empty, 0);
+ Assert (!xtr.Read ());
+ AssertEquals (4, bytes2 [0]);
+ AssertEquals (14, bytes2 [1]);
+ AssertEquals (54, bytes2 [2]);
+ AssertEquals (114, bytes2 [3]);
+ AssertEquals (134, bytes2 [4]);
+ AssertEquals (184, bytes2 [5]);
+ AssertEquals (0, bytes2 [6]);
+
+ xtr = new XmlTextReader (base64, XmlNodeType.Document, null);
+ bytes2 = new byte [10];
+ xtr.Read (); // root
+ xtr.Read (); // foo
+ this.AssertNodeValues (xtr, XmlNodeType.Element, 1, false, "foo", String.Empty,
+ "foo", String.Empty, String.Empty, 0);
+
+ // Read less than 4 (i.e. one Base64 block)
+ AssertEquals (1, xtr.ReadBase64 (bytes2, 0, 1));
+ this.AssertNodeValues (xtr, XmlNodeType.Element, 1, false, "foo", String.Empty,
+ "foo", String.Empty, String.Empty, 0);
+ AssertEquals (4, bytes2 [0]);
+
+ AssertEquals (5, xtr.ReadBase64 (bytes2, 0, 10));
+ this.AssertNodeValues (xtr, XmlNodeType.EndElement, 0, false, "root", String.Empty,
+ "root", String.Empty, String.Empty, 0);
+ Assert (!xtr.Read ());
+ AssertEquals (14, bytes2 [0]);
+ AssertEquals (54, bytes2 [1]);
+ AssertEquals (114, bytes2 [2]);
+ AssertEquals (134, bytes2 [3]);
+ AssertEquals (184, bytes2 [4]);
+ AssertEquals (0, bytes2 [5]);
+ }
}
}
diff --git a/mcs/class/System.XML/Test/System.Xml/XmlTextWriterTests.cs b/mcs/class/System.XML/Test/System.Xml/XmlTextWriterTests.cs
index 00a6d70ab3c..8154ac87528 100644
--- a/mcs/class/System.XML/Test/System.Xml/XmlTextWriterTests.cs
+++ b/mcs/class/System.XML/Test/System.Xml/XmlTextWriterTests.cs
@@ -94,8 +94,8 @@ namespace MonoTests.System.Xml
xtw.WriteStartElement ("foo");
try {
xtw.WriteAttributeString ("xmlns", "xmlns", null, "http://abc.def");
- // This should not be allowed, even though
- // MS.NET doesn't treat as an error.
+ // This should not be allowed, even though MS.NET doesn't treat as an error.
+ // See http://www.w3.org/TR/REC-xml-names/ Namespace Constraint: Prefix Declared
Fail ("any prefix which name starts from \"xml\" must not be allowed.");
}
catch (ArgumentException) {}
@@ -174,7 +174,7 @@ namespace MonoTests.System.Xml
{
xtw.WriteCData("foo]]>bar");
}
-
+
[Test]
public void CloseOpenElements ()
{
@@ -355,6 +355,15 @@ namespace MonoTests.System.Xml
}
[Test]
+ public void ElementAndAttributeSameXmlns ()
+ {
+ xtw.WriteStartElement ("ped", "foo", "urn:foo");
+ xtw.WriteStartAttribute ("ped", "foo", "urn:foo");
+ xtw.WriteEndElement ();
+ AssertEquals ("<ped:foo ped:foo='' xmlns:ped='urn:foo' />", StringWriterText);
+ }
+
+ [Test]
public void ElementEmpty ()
{
xtw.WriteStartElement ("foo");
@@ -539,19 +548,17 @@ namespace MonoTests.System.Xml
}
[Test]
- public void NamespacesPrefixWithEmptyAndNullNamespace ()
+ [ExpectedException (typeof (ArgumentException))]
+ public void NamespacesPrefixWithEmptyAndNullNamespaceEmpty ()
{
- try {
- xtw.WriteStartElement ("foo", "bar", "");
- Fail ("Should have thrown an ArgumentException.");
- } catch (ArgumentException) {}
+ xtw.WriteStartElement ("foo", "bar", "");
+ }
- try
- {
- xtw.WriteStartElement ("foo", "bar", null);
- Fail ("Should have thrown an ArgumentException.");
- }
- catch (ArgumentException) {}
+ [Test]
+ [ExpectedException (typeof (ArgumentException))]
+ public void NamespacesPrefixWithEmptyAndNullNamespaceNull ()
+ {
+ xtw.WriteStartElement ("foo", "bar", null);
}
[Test]
@@ -659,6 +666,14 @@ namespace MonoTests.System.Xml
}
[Test]
+ public void WriteBinHex ()
+ {
+ byte [] bytes = new byte [] {4,14,34, 54,94,114, 134,194,255, 0,5};
+ xtw.WriteBinHex (bytes, 0, 11);
+ AssertEquals ("040E22365E7286C2FF0005", StringWriterText);
+ }
+
+ [Test]
public void WriteCharEntity ()
{
xtw.WriteCharEntity ('a');
@@ -1059,9 +1074,9 @@ namespace MonoTests.System.Xml
[Test]
public void DontOutputMultipleXmlns ()
{
- XmlDocument doc = new XmlDocument();
- doc.LoadXml("<a xmlns:dt=\"b\" dt:dt=\"c\"/>");
- XmlDocument doc2 = new XmlDocument();
+ XmlDocument doc = new XmlDocument();
+ doc.LoadXml("<a xmlns:dt=\"b\" dt:dt=\"c\"/>");
+ XmlDocument doc2 = new XmlDocument();
doc2.LoadXml(doc.InnerXml);
AssertEquals ("<a xmlns:dt=\"b\" dt:dt=\"c\" />",
doc2.OuterXml);
@@ -1071,9 +1086,9 @@ namespace MonoTests.System.Xml
public void DontOutputNonDeclaredXmlns ()
{
string xml = "<x:a foo='foo' xmlns:x='urn:foo'><b /></x:a>";
- XmlDocument doc = new XmlDocument();
- doc.LoadXml(xml);
- XmlDocument doc2 = new XmlDocument();
+ XmlDocument doc = new XmlDocument();
+ doc.LoadXml(xml);
+ XmlDocument doc2 = new XmlDocument();
doc2.LoadXml(doc.InnerXml);
AssertEquals (xml.Replace ('\'', '"'), doc2.OuterXml);
}
diff --git a/mcs/class/System.XML/Test/System.Xml/XmlUrlResolverTests.cs b/mcs/class/System.XML/Test/System.Xml/XmlUrlResolverTests.cs
index 6f4f78524d0..f9c3d078fdb 100644
--- a/mcs/class/System.XML/Test/System.Xml/XmlUrlResolverTests.cs
+++ b/mcs/class/System.XML/Test/System.Xml/XmlUrlResolverTests.cs
@@ -65,5 +65,19 @@ namespace MonoTests.System.Xml
Uri uri = new Uri ("http://www.go-mono.com/index.rss");
resolver.GetEntity (uri, null, null);
}
+
+ [Test]
+ [ExpectedException (typeof (ArgumentException))]
+ public void GetEntityWithRelativeFileUri ()
+ {
+ resolver.GetEntity (new Uri ("file://file.txt"), null, typeof (Stream));
+ }
+
+ [Test]
+ [ExpectedException (typeof (XmlException))]
+ public void GetEntityWithNonStreamReturnType ()
+ {
+ resolver.GetEntity (new Uri ("http://www.go-mono.com/"), null, typeof (File));
+ }
}
}
diff --git a/mcs/class/System.XML/Test/System.Xml/XmlWriterTests.cs b/mcs/class/System.XML/Test/System.Xml/XmlWriterTests.cs
index cc8d338d95f..47d2a9ff91a 100644
--- a/mcs/class/System.XML/Test/System.Xml/XmlWriterTests.cs
+++ b/mcs/class/System.XML/Test/System.Xml/XmlWriterTests.cs
@@ -44,8 +44,14 @@ namespace MonoTests.System.Xml
{
setupWriter ();
string xml = "<?xml version='1.0'?><root />";
- StringReader sr = new StringReader (xml);
- XmlTextReader xtr = new XmlTextReader (sr);
+ XmlTextReader xtr = new XmlTextReader (xml, XmlNodeType.Document, null);
+ xtw.WriteNode (xtr, false);
+ AssertEquals (xml, writer.ToString ());
+
+ // With encoding
+ setupWriter ();
+ xml = "<?xml version='1.0' encoding='iso-2022-jp' ?><root />";
+ xtr = new XmlTextReader (xml, XmlNodeType.Document, null);
xtw.WriteNode (xtr, false);
AssertEquals (xml, writer.ToString ());
}
@@ -76,6 +82,15 @@ namespace MonoTests.System.Xml
}
[Test]
+ public void WriteNodeNonEmptyElement ()
+ {
+ setupWriter ();
+ string xml = @"<foo><bar></bar></foo>";
+ xtw.WriteNode (new XmlTextReader (xml, XmlNodeType.Document, null), false);
+ AssertEquals (xml, writer.ToString ());
+ }
+
+ [Test]
public void WriteNodeSingleContentElement ()
{
setupWriter ();
diff --git a/mcs/class/System/Assembly/AssemblyInfo.cs b/mcs/class/System/Assembly/AssemblyInfo.cs
index edc766acfa9..23142610f3e 100644
--- a/mcs/class/System/Assembly/AssemblyInfo.cs
+++ b/mcs/class/System/Assembly/AssemblyInfo.cs
@@ -41,6 +41,7 @@ using System.Runtime.InteropServices;
[assembly: NeutralResourcesLanguage("en-US")]
[assembly: AllowPartiallyTrustedCallers]
+[assembly: ComVisible(false)]
//[assembly: AssemblyDelaySign(false)]
//[assembly: AssemblyKeyFile("")] \ No newline at end of file
diff --git a/mcs/class/System/Assembly/ChangeLog b/mcs/class/System/Assembly/ChangeLog
index 2306df752bb..a0cb3770386 100644
--- a/mcs/class/System/Assembly/ChangeLog
+++ b/mcs/class/System/Assembly/ChangeLog
@@ -1,3 +1,7 @@
+2003-11-12 Andreas Nahr <ClassDevelopment@A-SoftTech.com>
+
+ * AssemblyInfo.cs: Added missing attribute
+
2003-07-18 Andreas Nahr <ClassDevelopment@A-SoftTech.com>
* Locale.cs: Added
diff --git a/mcs/class/System/ChangeLog b/mcs/class/System/ChangeLog
index 4aeb127ec2e..558da53aa54 100644
--- a/mcs/class/System/ChangeLog
+++ b/mcs/class/System/ChangeLog
@@ -1,3 +1,11 @@
+2003-11-18 Todd Berman <tberman@gentoo.org>
+
+ * System.dll.sources: Added IOrderedDictionary.cs
+
+2003-11-12 Andreas Nahr <ClassDevelopment@A-SoftTech.com>
+
+ * System.dll.sources: Added some new class files
+
2003-09-04 Duncan Mak <duncan@ximian.com>
* System_test.dll.sources: Add new test, ListDictionaryTest.cs.
diff --git a/mcs/class/System/Microsoft.CSharp/CSharpCodeCompiler.cs b/mcs/class/System/Microsoft.CSharp/CSharpCodeCompiler.cs
index f1a06bb0f86..09ee6b98b20 100644
--- a/mcs/class/System/Microsoft.CSharp/CSharpCodeCompiler.cs
+++ b/mcs/class/System/Microsoft.CSharp/CSharpCodeCompiler.cs
@@ -173,6 +173,8 @@ namespace Mono.CSharp
foreach (string import in options.ReferencedAssemblies)
args.AppendFormat("/r:\"{0}\" ",import);
}
+
+ args.Append (" -- ");
foreach (string source in fileNames)
args.AppendFormat("\"{0}\" ",source);
return args.ToString();
diff --git a/mcs/class/System/Microsoft.CSharp/ChangeLog b/mcs/class/System/Microsoft.CSharp/ChangeLog
index 68a08d68386..7e0a2c11c03 100644
--- a/mcs/class/System/Microsoft.CSharp/ChangeLog
+++ b/mcs/class/System/Microsoft.CSharp/ChangeLog
@@ -1,3 +1,8 @@
+2003-11-12 Lluis Sanchez Gual <lluis@ximian.com>
+
+ * CSharpCodeCompiler.cs: In BuildArgs, add "--" separator between options
+ and source files.
+
2003-10-15 Lluis Sanchez Gual <lluis@ximian.com>
* CSharpCodeGenerator.cs: added override for the method
diff --git a/mcs/class/System/Microsoft.VisualBasic/ChangeLog b/mcs/class/System/Microsoft.VisualBasic/ChangeLog
index f22797e0a30..839213bdc0f 100644
--- a/mcs/class/System/Microsoft.VisualBasic/ChangeLog
+++ b/mcs/class/System/Microsoft.VisualBasic/ChangeLog
@@ -1,3 +1,20 @@
+2003-11-27 Rafael Teixeira <rafaelteixeirabr@hotmail.com>
+
+ * Microsoft.VisualBasic/VBCodeGenerator.cs: Support for Option Strict/Option Explicit
+
+2003-11-27 Jackson Harper <jackson@ximian.com>
+
+ * VBCodeCompiler.cs: Put a space between Property and the
+ properties name. Only add a closing quote to strings if we are
+ still in a quote. Use BaseType == "System.Void" to determine if a
+ method is void. This prevents getting As Nothing functions. Many
+ thanks to Anirban for helping me with VB Syntax.
+
+2003-11-27 Jackson Harper <jackson@ximian.com>
+
+ * VBCodeCompiler.cs: use /wlevel for warning level. This is what
+ mbas uses.
+
2003-11-06 Gonzalo Paniagua Javier <gonzalo@ximian.com>
* VBCodeGenerator.cs: some corrections regarding missing spaces in
@@ -41,4 +58,3 @@
these options)
* VBCodeProvider.cs: Added and implemented
-
diff --git a/mcs/class/System/Microsoft.VisualBasic/VBCodeCompiler.cs b/mcs/class/System/Microsoft.VisualBasic/VBCodeCompiler.cs
index efeb0ad5c51..c0ade31de10 100644
--- a/mcs/class/System/Microsoft.VisualBasic/VBCodeCompiler.cs
+++ b/mcs/class/System/Microsoft.VisualBasic/VBCodeCompiler.cs
@@ -1,236 +1,249 @@
-//
-// Microsoft VisualBasic VBCodeCompiler Class implementation
-//
-// Authors:
-// Jochen Wezel (jwezel@compumaster.de)
-// Gonzalo Paniagua Javier (gonzalo@ximian.com)
-//
-// (c) 2003 Jochen Wezel
-// (c) 2003 Ximian, Inc. (http://www.ximian.com)
-//
-
-namespace Microsoft.VisualBasic
-{
- using System;
- using System.CodeDom;
- using System.CodeDom.Compiler;
- using System.IO;
- using System.Text;
- using System.Reflection;
- using System.Collections;
- using System.Collections.Specialized;
- using System.Diagnostics;
- using System.Text.RegularExpressions;
-
- internal class VBCodeCompiler: VBCodeGenerator, ICodeCompiler
- {
- //
- // Constructors
- //
- public VBCodeCompiler()
- {
- }
-
- //
- // Methods
- //
- [MonoTODO]
- public CompilerResults CompileAssemblyFromDom (CompilerParameters options,CodeCompileUnit e)
- {
- return CompileAssemblyFromDomBatch (options, new CodeCompileUnit []{e});
- }
-
- public CompilerResults CompileAssemblyFromDomBatch (CompilerParameters options,
- CodeCompileUnit [] ea)
- {
- string [] fileNames = new string [ea.Length];
- int i = 0;
- if (options == null)
- options = new CompilerParameters ();
-
- StringCollection assemblies = options.ReferencedAssemblies;
-
- foreach (CodeCompileUnit e in ea) {
- fileNames [i] = GetTempFileNameWithExtension ("vb");
- FileStream f = new FileStream (fileNames [i], FileMode.OpenOrCreate);
- StreamWriter s = new StreamWriter (f);
- if (e.ReferencedAssemblies != null) {
- foreach (string str in e.ReferencedAssemblies) {
- if (!assemblies.Contains (str))
- assemblies.Add (str);
- }
- }
-
- ((ICodeGenerator)this).GenerateCodeFromCompileUnit (e, s, new CodeGeneratorOptions());
- s.Close();
- f.Close();
- i++;
- }
- return CompileAssemblyFromFileBatch (options, fileNames);
- }
-
- public CompilerResults CompileAssemblyFromFile (CompilerParameters options,string fileName)
- {
- return CompileAssemblyFromFileBatch (options, new string []{fileName});
- }
-
- public CompilerResults CompileAssemblyFromFileBatch (CompilerParameters options,
- string [] fileNames)
- {
- if (null == options)
- throw new ArgumentNullException ("options");
-
- if (null == fileNames)
- throw new ArgumentNullException ("fileNames");
-
- CompilerResults results = new CompilerResults (options.TempFiles);
- Process mbas = new Process ();
-
- string mbas_output;
- string [] mbas_output_lines;
- mbas.StartInfo.FileName = "mbas";
- mbas.StartInfo.Arguments = BuildArgs(options,fileNames);
- mbas.StartInfo.CreateNoWindow = true;
- mbas.StartInfo.UseShellExecute = false;
- mbas.StartInfo.RedirectStandardOutput = true;
- try {
- mbas.Start();
- mbas_output = mbas.StandardOutput.ReadToEnd ();
- mbas.WaitForExit();
- } finally {
- results.NativeCompilerReturnValue = mbas.ExitCode;
- mbas.Close ();
- }
-
- mbas_output_lines = mbas_output.Split(Environment.NewLine.ToCharArray());
- bool loadIt=true;
- foreach (string error_line in mbas_output_lines) {
- CompilerError error = CreateErrorFromString (error_line);
- if (null != error) {
- results.Errors.Add (error);
- if (!error.IsWarning)
- loadIt = false;
- }
- }
-
- if (loadIt)
- results.CompiledAssembly=Assembly.LoadFrom(options.OutputAssembly);
- else
- results.CompiledAssembly=null;
-
- return results;
- }
-
- public CompilerResults CompileAssemblyFromSource (CompilerParameters options,
- string source)
- {
- return CompileAssemblyFromSourceBatch (options, new string [] {source});
- }
-
- public CompilerResults CompileAssemblyFromSourceBatch (CompilerParameters options,
- string [] sources)
- {
- string [] fileNames = new string [sources.Length];
- int i = 0;
- foreach (string source in sources) {
- fileNames [i] = GetTempFileNameWithExtension ("vb");
- FileStream f = new FileStream (fileNames [i], FileMode.OpenOrCreate);
- StreamWriter s = new StreamWriter (f);
- s.Write (source);
- s.Close ();
- f.Close ();
- i++;
- }
- return CompileAssemblyFromFileBatch(options,fileNames);
- }
-
- static string BuildArgs (CompilerParameters options, string [] fileNames)
- {
- StringBuilder args = new StringBuilder ();
- if (options.GenerateExecutable)
- args.AppendFormat("/target:exe ");
- else
- args.AppendFormat("/target:library ");
-
- /* Disabled. It causes problems now. -- Gonzalo
- if (options.IncludeDebugInformation)
- args.AppendFormat("/debug ");
- */
-
- if (options.TreatWarningsAsErrors)
- args.AppendFormat ("/warnaserror ");
-
- if (options.WarningLevel != -1)
- args.AppendFormat ("/warn:{0} ", options.WarningLevel);
-
- if (options.OutputAssembly == null)
- options.OutputAssembly = GetTempFileNameWithExtension ("dll");
-
- args.AppendFormat ("/out:\"{0}\" ", options.OutputAssembly);
- if (null != options.ReferencedAssemblies) {
- foreach (string import in options.ReferencedAssemblies)
- args.AppendFormat ("/r:\"{0}\" ", import);
- }
-
- args.AppendFormat(" -- "); // makes mbas not try to process filenames as options
-
- foreach (string source in fileNames)
- args.AppendFormat("\"{0}\" ",source);
-
- return args.ToString();
- }
-
- static CompilerError CreateErrorFromString (string error_string)
- {
- // When IncludeDebugInformation is true, prevents the debug symbols stats from braeking this.
- if (error_string.StartsWith ("WROTE SYMFILE") || error_string.StartsWith ("OffsetTable"))
- return null;
-
- CompilerError error = new CompilerError ();
- Regex reg = new Regex (@"^(\s*(?<file>.*)\((?<line>\d*)(,(?<column>\d*))?\)\s+)*" +
- @"(?<level>\w+)\s*(?<number>.*):\s(?<message>.*)",
- RegexOptions.Compiled | RegexOptions.ExplicitCapture);
-
- Match match = reg.Match (error_string);
- if (!match.Success)
- return null;
-
- if (String.Empty != match.Result("${file}"))
- error.FileName = match.Result ("${file}");
-
- if (String.Empty != match.Result ("${line}"))
- error.Line = Int32.Parse (match.Result ("${line}"));
-
- if (String.Empty != match.Result( "${column}"))
- error.Column = Int32.Parse (match.Result ("${column}"));
-
- if (match.Result ("${level}") ==" warning")
- error.IsWarning = true;
-
- error.ErrorNumber = match.Result ("${number}");
- error.ErrorText = match.Result ("${message}");
- return error;
- }
-
- static string GetTempFileNameWithExtension (string extension)
- {
- Exception exc;
- string extFile;
-
- do {
- string tmpFile = Path.GetTempFileName ();
- FileInfo fileInfo = new FileInfo (tmpFile);
- extFile = Path.ChangeExtension (tmpFile, extension);
- try {
- fileInfo.MoveTo (extFile);
- exc = null;
- } catch (Exception e) {
- exc = e;
- }
- } while (exc != null);
-
- return extFile;
- }
- }
-}
-
+//
+// Microsoft VisualBasic VBCodeCompiler Class implementation
+//
+// Authors:
+// Jochen Wezel (jwezel@compumaster.de)
+// Gonzalo Paniagua Javier (gonzalo@ximian.com)
+//
+// (c) 2003 Jochen Wezel (http://www.compumaster.de)
+// (c) 2003 Ximian, Inc. (http://www.ximian.com)
+//
+// Modifications:
+// 2003-11-28 JW: create reference to Microsoft.VisualBasic if not explicitly done
+
+namespace Microsoft.VisualBasic
+{
+ using System;
+ using System.CodeDom;
+ using System.CodeDom.Compiler;
+ using System.IO;
+ using System.Text;
+ using System.Reflection;
+ using System.Collections;
+ using System.Collections.Specialized;
+ using System.Diagnostics;
+ using System.Text.RegularExpressions;
+
+ internal class VBCodeCompiler: VBCodeGenerator, ICodeCompiler
+ {
+ //
+ // Constructors
+ //
+ public VBCodeCompiler()
+ {
+ }
+
+ //
+ // Methods
+ //
+ [MonoTODO]
+ public CompilerResults CompileAssemblyFromDom (CompilerParameters options,CodeCompileUnit e)
+ {
+ return CompileAssemblyFromDomBatch (options, new CodeCompileUnit []{e});
+ }
+
+ public CompilerResults CompileAssemblyFromDomBatch (CompilerParameters options,
+ CodeCompileUnit [] ea)
+ {
+ string [] fileNames = new string [ea.Length];
+ int i = 0;
+ if (options == null)
+ options = new CompilerParameters ();
+
+ StringCollection assemblies = options.ReferencedAssemblies;
+
+ foreach (CodeCompileUnit e in ea) {
+ fileNames [i] = GetTempFileNameWithExtension ("vb");
+ FileStream f = new FileStream (fileNames [i], FileMode.OpenOrCreate);
+ StreamWriter s = new StreamWriter (f);
+ if (e.ReferencedAssemblies != null) {
+ foreach (string str in e.ReferencedAssemblies) {
+ if (!assemblies.Contains (str))
+ assemblies.Add (str);
+ }
+ }
+
+ ((ICodeGenerator)this).GenerateCodeFromCompileUnit (e, s, new CodeGeneratorOptions());
+ s.Close();
+ f.Close();
+ i++;
+ }
+ return CompileAssemblyFromFileBatch (options, fileNames);
+ }
+
+ public CompilerResults CompileAssemblyFromFile (CompilerParameters options,string fileName)
+ {
+ return CompileAssemblyFromFileBatch (options, new string []{fileName});
+ }
+
+ public CompilerResults CompileAssemblyFromFileBatch (CompilerParameters options,
+ string [] fileNames)
+ {
+ if (null == options)
+ throw new ArgumentNullException ("options");
+
+ if (null == fileNames)
+ throw new ArgumentNullException ("fileNames");
+
+ CompilerResults results = new CompilerResults (options.TempFiles);
+ Process mbas = new Process ();
+
+ string mbas_output;
+ string [] mbas_output_lines;
+ mbas.StartInfo.FileName = "mbas";
+ mbas.StartInfo.Arguments = BuildArgs(options,fileNames);
+ mbas.StartInfo.CreateNoWindow = true;
+ mbas.StartInfo.UseShellExecute = false;
+ mbas.StartInfo.RedirectStandardOutput = true;
+ try {
+ mbas.Start();
+ mbas_output = mbas.StandardOutput.ReadToEnd ();
+ mbas.WaitForExit();
+ } finally {
+ results.NativeCompilerReturnValue = mbas.ExitCode;
+ mbas.Close ();
+ }
+
+ mbas_output_lines = mbas_output.Split(Environment.NewLine.ToCharArray());
+ bool loadIt=true;
+ foreach (string error_line in mbas_output_lines) {
+ CompilerError error = CreateErrorFromString (error_line);
+ if (null != error) {
+ results.Errors.Add (error);
+ if (!error.IsWarning)
+ loadIt = false;
+ }
+ }
+
+ if (loadIt)
+ results.CompiledAssembly=Assembly.LoadFrom(options.OutputAssembly);
+ else
+ results.CompiledAssembly=null;
+
+ return results;
+ }
+
+ public CompilerResults CompileAssemblyFromSource (CompilerParameters options,
+ string source)
+ {
+ return CompileAssemblyFromSourceBatch (options, new string [] {source});
+ }
+
+ public CompilerResults CompileAssemblyFromSourceBatch (CompilerParameters options,
+ string [] sources)
+ {
+ string [] fileNames = new string [sources.Length];
+ int i = 0;
+ foreach (string source in sources) {
+ fileNames [i] = GetTempFileNameWithExtension ("vb");
+ FileStream f = new FileStream (fileNames [i], FileMode.OpenOrCreate);
+ StreamWriter s = new StreamWriter (f);
+ s.Write (source);
+ s.Close ();
+ f.Close ();
+ i++;
+ }
+ return CompileAssemblyFromFileBatch(options,fileNames);
+ }
+
+ static string BuildArgs (CompilerParameters options, string [] fileNames)
+ {
+ StringBuilder args = new StringBuilder ();
+ if (options.GenerateExecutable)
+ args.AppendFormat("/target:exe ");
+ else
+ args.AppendFormat("/target:library ");
+
+ /* Disabled. It causes problems now. -- Gonzalo
+ if (options.IncludeDebugInformation)
+ args.AppendFormat("/debug ");
+ */
+
+ if (options.TreatWarningsAsErrors)
+ args.AppendFormat ("/warnaserror ");
+
+ if (options.WarningLevel != -1)
+ args.AppendFormat ("/wlevel:{0} ", options.WarningLevel);
+
+ if (options.OutputAssembly == null)
+ options.OutputAssembly = GetTempFileNameWithExtension ("dll");
+
+ args.AppendFormat ("/out:\"{0}\" ", options.OutputAssembly);
+
+ bool Reference2MSVBFound;
+ Reference2MSVBFound = false;
+ if (null != options.ReferencedAssemblies)
+ {
+ foreach (string import in options.ReferencedAssemblies)
+ {
+ if (string.Compare (import, "Microsoft.VisualBasic", true, System.Globalization.CultureInfo.InvariantCulture) == 0)
+ Reference2MSVBFound = true;
+ args.AppendFormat ("/r:\"{0}\" ", import);
+ }
+ }
+ // add standard import to Microsoft.VisualBasic if missing
+ if (Reference2MSVBFound == false)
+ args.AppendFormat ("/r:\"{0}\" ", "Microsoft.VisualBasic");
+
+ args.AppendFormat(" -- "); // makes mbas not try to process filenames as options
+
+ foreach (string source in fileNames)
+ args.AppendFormat("\"{0}\" ",source);
+
+ return args.ToString();
+ }
+
+ static CompilerError CreateErrorFromString (string error_string)
+ {
+ // When IncludeDebugInformation is true, prevents the debug symbols stats from braeking this.
+ if (error_string.StartsWith ("WROTE SYMFILE") || error_string.StartsWith ("OffsetTable"))
+ return null;
+
+ CompilerError error = new CompilerError ();
+ Regex reg = new Regex (@"^(\s*(?<file>.*)\((?<line>\d*)(,(?<column>\d*))?\)\s+)*" +
+ @"(?<level>\w+)\s*(?<number>.*):\s(?<message>.*)",
+ RegexOptions.Compiled | RegexOptions.ExplicitCapture);
+
+ Match match = reg.Match (error_string);
+ if (!match.Success)
+ return null;
+
+ if (String.Empty != match.Result("${file}"))
+ error.FileName = match.Result ("${file}");
+
+ if (String.Empty != match.Result ("${line}"))
+ error.Line = Int32.Parse (match.Result ("${line}"));
+
+ if (String.Empty != match.Result( "${column}"))
+ error.Column = Int32.Parse (match.Result ("${column}"));
+
+ if (match.Result ("${level}") ==" warning")
+ error.IsWarning = true;
+
+ error.ErrorNumber = match.Result ("${number}");
+ error.ErrorText = match.Result ("${message}");
+ return error;
+ }
+
+ static string GetTempFileNameWithExtension (string extension)
+ {
+ Exception exc;
+ string extFile;
+
+ do {
+ string tmpFile = Path.GetTempFileName ();
+ FileInfo fileInfo = new FileInfo (tmpFile);
+ extFile = Path.ChangeExtension (tmpFile, extension);
+ try {
+ fileInfo.MoveTo (extFile);
+ exc = null;
+ } catch (Exception e) {
+ exc = e;
+ }
+ } while (exc != null);
+
+ return extFile;
+ }
+ }
+}
+
diff --git a/mcs/class/System/Microsoft.VisualBasic/VBCodeGenerator.cs b/mcs/class/System/Microsoft.VisualBasic/VBCodeGenerator.cs
index 6da964e3232..77ba53b31e3 100644
--- a/mcs/class/System/Microsoft.VisualBasic/VBCodeGenerator.cs
+++ b/mcs/class/System/Microsoft.VisualBasic/VBCodeGenerator.cs
@@ -1,1173 +1,1221 @@
-//
-// Microsoft.VisualBasic.VBCodeGenerator.cs
-//
-// Author:
-// Andreas Nahr (ClassDevelopment@A-SoftTech.com)
-// (partially based on CSharpCodeGenerator)
-// Jochen Wezel (jwezel@compumaster.de)
-//
-// (C) 2003 Andreas Nahr
-// (C) 2003 Jochen Wezel
-//
-
-using System;
-using System.Text;
-using System.Text.RegularExpressions;
-using System.CodeDom;
-using System.CodeDom.Compiler;
-using System.IO;
-using System.Reflection;
-using System.Collections;
-
-namespace Microsoft.VisualBasic
-{
- internal class VBCodeGenerator : CodeGenerator
- {
- private string[] Keywords = new string[] {
- "AddHandler", "AddressOf", "Alias", "And",
- "AndAlso", "Ansi", "As", "Assembly",
- "Auto", "Boolean", "ByRef", "Byte",
- "ByVal", "Call", "Case", "Catch",
- "CBool", "CByte", "CChar", "CDate",
- "CDec", "CDbl", "Char", "CInt",
- "Class", "CLng", "CObj", "Const",
- "CShort", "CSng", "CStr", "CType",
- "Date", "Decimal", "Declare", "Default",
- "Delegate", "Dim", "DirectCast", "Do",
- "Double", "Each", "Else", "ElseIf",
- "End", "Enum", "Erase", "Error",
- "Event", "Exit", "False", "Finally",
- "For", "Friend", "Function", "Get",
- "GetType", "GoSub", "GoTo", "Handles",
- "If", "Implements", "Imports", "In",
- "Inherits", "Integer", "Interface", "Is",
- "Let", "Lib", "Like", "Long",
- "Loop", "Me", "Mod", "Module",
- "MustInherit", "MustOverride", "MyBase", "MyClass",
- "Namespace", "New", "Next", "Not",
- "Nothing", "NotInheritable", "NotOverridable", "Object",
- "On", "Option", "Optional", "Or",
- "OrElse", "Overloads", "Overridable", "Overrides",
- "ParamArray", "Preserve", "Private", "Property",
- "Protected", "Public", "RaiseEvent", "ReadOnly",
- "ReDim", "REM", "RemoveHandler", "Resume",
- "Return", "Select", "Set", "Shadows",
- "Shared", "Short", "Single", "Static",
- "Step", "Stop", "String", "Structure",
- "Sub", "SyncLock", "Then", "Throw",
- "To", "True", "Try", "TypeOf",
- "Unicode", "Until", "Variant", "When",
- "While", "With", "WithEvents", "WriteOnly",
- "Xor"
- };
-
- public VBCodeGenerator()
- {
- }
-
- protected override string NullToken {
- get {
- return "Nothing";
- }
- }
-
- protected override void GenerateArrayCreateExpression (CodeArrayCreateExpression expression)
- {
- TextWriter output = Output;
-
- output.Write ("New ");
-
- CodeExpressionCollection initializers = expression.Initializers;
- CodeTypeReference createType = expression.CreateType;
-
- if (initializers.Count > 0) {
-
- OutputType (createType);
-
- output.WriteLine (" {");
- ++Indent;
- OutputExpressionList (initializers, true);
- --Indent;
- output.Write ("}");
-
- }
- else {
- CodeTypeReference arrayType = createType.ArrayElementType;
- while (arrayType != null)
- {
- createType = arrayType;
- arrayType = arrayType.ArrayElementType;
- }
-
- OutputType (createType);
-
- output.Write ('(');
-
- CodeExpression size = expression.SizeExpression;
- if (size != null)
- GenerateExpression (size);
- else
- output.Write (expression.Size);
-
- output.Write (')');
- }
- }
-
- protected override void GenerateBaseReferenceExpression (CodeBaseReferenceExpression expression)
- {
- Output.Write ("MyBase");
- }
-
- protected override void GenerateCastExpression (CodeCastExpression expression)
- {
- TextWriter output = Output;
- // ENHANCE: Use a DirectCast if it is known that expression.Expression is no Value-Type
- output.Write ("CType(");
- GenerateExpression (expression.Expression);
- output.Write (", ");
- OutputType (expression.TargetType);
- output.Write (")");
- }
-
- protected override void GenerateCompileUnitStart (CodeCompileUnit compileUnit)
- {
- GenerateComment (new CodeComment ("------------------------------------------------------------------------------"));
- GenerateComment (new CodeComment (" <autogenerated>"));
- GenerateComment (new CodeComment (" This code was generated by a tool."));
- GenerateComment (new CodeComment (" Mono Runtime Version: " + System.Environment.Version));
- GenerateComment (new CodeComment (""));
- GenerateComment (new CodeComment (" Changes to this file may cause incorrect behavior and will be lost if "));
- GenerateComment (new CodeComment (" the code is regenerated."));
- GenerateComment (new CodeComment (" </autogenerated>"));
- GenerateComment (new CodeComment ("------------------------------------------------------------------------------"));
- Output.WriteLine ();
- }
-
- protected override void GenerateDelegateCreateExpression (CodeDelegateCreateExpression expression)
- {
- TextWriter output = Output;
-
- output.Write ("AddressOf ");
-
- CodeExpression targetObject = expression.TargetObject;
- if (targetObject != null) {
- GenerateExpression (targetObject);
- Output.Write ('.');
- }
- output.Write (expression.MethodName);
- }
-
- protected override void GenerateFieldReferenceExpression (CodeFieldReferenceExpression expression)
- {
- CodeExpression targetObject = expression.TargetObject;
- if (targetObject != null) {
- GenerateExpression (targetObject);
- Output.Write ('.');
- }
- Output.Write (expression.FieldName);
- }
-
- protected override void GenerateArgumentReferenceExpression (CodeArgumentReferenceExpression expression)
- {
- Output.Write (expression.ParameterName);
- }
-
- protected override void GenerateVariableReferenceExpression (CodeVariableReferenceExpression expression)
- {
- Output.Write (expression.VariableName);
- }
-
- protected override void GenerateIndexerExpression (CodeIndexerExpression expression)
- {
- TextWriter output = Output;
-
- GenerateExpression (expression.TargetObject);
- output.Write ('(');
- OutputExpressionList (expression.Indices);
- output.Write (')');
- }
-
- protected override void GenerateArrayIndexerExpression (CodeArrayIndexerExpression expression)
- {
- TextWriter output = Output;
-
- GenerateExpression (expression.TargetObject);
- output.Write (".Item(");
- OutputExpressionList (expression.Indices);
- output.Write (')');
- }
-
- protected override void GenerateSnippetExpression (CodeSnippetExpression expression)
- {
- Output.Write (expression.Value);
- }
-
- protected override void GenerateMethodInvokeExpression (CodeMethodInvokeExpression expression)
- {
- TextWriter output = Output;
-
- GenerateMethodReferenceExpression (expression.Method);
-
- output.Write ('(');
- OutputExpressionList (expression.Parameters);
- output.Write (')');
- }
-
- protected override void GenerateMethodReferenceExpression (CodeMethodReferenceExpression expression)
- {
- GenerateExpression (expression.TargetObject);
- Output.Write ('.');
- Output.Write (expression.MethodName);
- }
-
- protected override void GenerateEventReferenceExpression (CodeEventReferenceExpression expression)
- {
- GenerateExpression (expression.TargetObject);
- Output.Write ('.');
- Output.Write (expression.EventName);
- }
-
- protected override void GenerateDelegateInvokeExpression (CodeDelegateInvokeExpression expression)
- {
- Output.Write ("RaiseEvent ");
- GenerateExpression (expression.TargetObject);
- Output.Write ('(');
- OutputExpressionList (expression.Parameters);
- Output.WriteLine (')');
- }
-
- protected override void GenerateObjectCreateExpression (CodeObjectCreateExpression expression)
- {
- Output.Write( "New " );
- OutputType (expression.CreateType);
- Output.Write ('(');
- OutputExpressionList (expression.Parameters);
- Output.Write (')');
- }
-
- protected override void GenerateParameterDeclarationExpression (CodeParameterDeclarationExpression e)
- {
- if (e.CustomAttributes != null && e.CustomAttributes.Count > 0)
- OutputAttributeDeclarations (e.CustomAttributes);
- OutputDirection (e.Direction);
- OutputTypeNamePair (e.Type, e.Name);
- }
-
- protected override void GeneratePrimitiveExpression (CodePrimitiveExpression e)
- {
- TextWriter output = Output;
-
- if (e.Value == null) {
- output.Write (NullToken);
- return;
- }
-
- Type type = e.Value.GetType ();
- if (type == typeof (bool)) {
- if ((bool)e.Value)
- output.Write ("True");
- else
- output.Write ("False");
- }
- else if (type == typeof (char)) {
- output.Write ("\"" + e.Value.ToString () + "\"c");
- }
- else if (type == typeof (string)) {
- output.Write (QuoteSnippetString ((string) e.Value));
- }
- else if (type == typeof (byte) || type == typeof (sbyte) || type == typeof (short) ||
- type == typeof (int) || type == typeof (long) || type == typeof (float) ||
- type == typeof (double) || type == typeof (decimal)) {
- output.Write (e.Value.ToString ());
- }
- else {
- throw new ArgumentException ("Value type (" + type + ") is not a primitive type");
- }
- }
-
- protected override void GeneratePropertyReferenceExpression (CodePropertyReferenceExpression expression)
- {
- GenerateMemberReferenceExpression (expression.TargetObject, expression.PropertyName);
- }
-
- protected override void GeneratePropertySetValueReferenceExpression (CodePropertySetValueReferenceExpression expression)
- {
- Output.Write ("Value");
- }
-
- protected override void GenerateThisReferenceExpression (CodeThisReferenceExpression expression)
- {
- Output.Write ("Me");
- }
-
- protected override void GenerateExpressionStatement (CodeExpressionStatement statement)
- {
- GenerateExpression (statement.Expression);
- Output.WriteLine (); //start new line
- }
-
- protected override void GenerateIterationStatement (CodeIterationStatement statement)
- {
- TextWriter output = Output;
-
- GenerateStatement (statement.InitStatement);
- output.Write ("Do While ");
- GenerateExpression (statement.TestExpression);
- output.WriteLine ();
- GenerateStatements (statement.Statements);
- GenerateStatement (statement.IncrementStatement);
- output.WriteLine ("Loop");
- }
-
- protected override void GenerateThrowExceptionStatement (CodeThrowExceptionStatement statement)
- {
- Output.Write ("Throw ");
- GenerateExpression (statement.ToThrow);
- }
-
- protected override void GenerateComment (CodeComment comment)
- {
- TextWriter output = Output;
-
- if (comment.DocComment)
- output.Write ("''' ");
- else
- output.Write ("' ");
-
- output.WriteLine (comment.Text);
- }
-
- protected override void GenerateMethodReturnStatement (CodeMethodReturnStatement statement)
- {
- TextWriter output = Output;
-
- output.Write ("Return ");
- GenerateExpression (statement.Expression);
- output.WriteLine ();
- }
-
- protected override void GenerateConditionStatement (CodeConditionStatement statement)
- {
- TextWriter output = Output;
- output.Write ("If (");
-
- GenerateExpression (statement.Condition);
-
- output.WriteLine (") Then");
- ++Indent;
- GenerateStatements (statement.TrueStatements);
- --Indent;
-
- CodeStatementCollection falses = statement.FalseStatements;
- if (falses.Count > 0) {
- output.WriteLine ("Else");
- ++Indent;
- GenerateStatements (falses);
- --Indent;
- }
- else {
- if (Options.ElseOnClosing)
- output.WriteLine ("Else");
- }
- output.WriteLine ("End If");
- }
-
- protected override void GenerateTryCatchFinallyStatement (CodeTryCatchFinallyStatement statement)
- {
- TextWriter output = Output;
- CodeGeneratorOptions options = Options;
-
- output.WriteLine ("Try");
- ++Indent;
- GenerateStatements (statement.TryStatements);
- --Indent;
- output.WriteLine ();
-
- foreach (CodeCatchClause clause in statement.CatchClauses) {
- output.Write ("Catch ");
- OutputTypeNamePair (clause.CatchExceptionType, clause.LocalName);
- output.WriteLine ();
- ++Indent;
- GenerateStatements (clause.Statements);
- --Indent;
- output.WriteLine ();
- }
-
- CodeStatementCollection finallies = statement.FinallyStatements;
- if (finallies.Count > 0) {
-
- output.WriteLine ("Finally");
- ++Indent;
- GenerateStatements (finallies);
- --Indent;
- output.WriteLine ();
- }
-
- if (Options.ElseOnClosing) {
- if (statement.CatchClauses.Count == 0)
- output.WriteLine ("Catch");
- if (statement.FinallyStatements.Count == 0)
- output.WriteLine ("Finally");
- }
-
- output.WriteLine("End Try");
- }
-
- protected override void GenerateAssignStatement (CodeAssignStatement statement)
- {
- TextWriter output = Output;
- GenerateExpression (statement.Left);
- output.Write (" = ");
- GenerateExpression (statement.Right);
- output.WriteLine ();
- }
-
- protected override void GenerateAttachEventStatement (CodeAttachEventStatement statement)
- {
- TextWriter output = Output;
-
- Output.Write ("AddHandler ");
- GenerateEventReferenceExpression (statement.Event);
- Output.Write ( ", ");
- GenerateExpression (statement.Listener);
- output.WriteLine ();
- }
-
- protected override void GenerateRemoveEventStatement (CodeRemoveEventStatement statement)
- {
- TextWriter output = Output;
-
- Output.Write ("RemoveHandler ");
- GenerateEventReferenceExpression (statement.Event);
- Output.Write ( ", ");
- GenerateExpression (statement.Listener);
- output.WriteLine ();
- }
-
- protected override void GenerateGotoStatement (CodeGotoStatement statement)
- {
- TextWriter output = Output;
-
- output.Write ("Goto ");
- output.Write (statement.Label);
- output.WriteLine ();
- }
-
- protected override void GenerateLabeledStatement (CodeLabeledStatement statement)
- {
- TextWriter output = Output;
-
- output.Write (statement.Label + ":");
- GenerateStatement (statement.Statement);
- }
-
- protected override void GenerateTypeOfExpression (CodeTypeOfExpression e)
- {
- TextWriter output = Output;
-
- output.Write ("GetType(");
- OutputType (e.Type);
- output.Write (")");
- }
-
- protected override void GenerateVariableDeclarationStatement( CodeVariableDeclarationStatement statement )
- {
- TextWriter output = Output;
-
- output.Write ("Dim ");
- OutputTypeNamePair (statement.Type, statement.Name);
-
- CodeExpression initExpression = statement.InitExpression;
- if (initExpression != null)
- {
- output.Write (" = ");
- GenerateExpression (initExpression);
- }
-
- output.WriteLine();
- }
-
- protected override void GenerateLinePragmaStart (CodeLinePragma linePragma)
- {
- Output.WriteLine ();
- Output.Write ("#ExternalSource(");
- Output.Write (linePragma.FileName);
- Output.Write (", ");
- Output.Write (linePragma.LineNumber);
- Output.WriteLine (")");
- }
-
- protected override void GenerateLinePragmaEnd (CodeLinePragma linePragma)
- {
- Output.WriteLine ("#End ExternalSource");
- }
-
- protected override void GenerateEvent (CodeMemberEvent eventRef, CodeTypeDeclaration declaration)
- {
- TextWriter output = Output;
-
- if (eventRef.CustomAttributes.Count > 0)
- OutputAttributeDeclarations (eventRef.CustomAttributes);
-
- MemberAttributes attributes = eventRef.Attributes;
-
- OutputMemberAccessModifier (attributes);
- OutputMemberScopeModifier (attributes);
-
- output.Write ("Event ");
- OutputTypeNamePair (eventRef.Type, eventRef.Name);
- output.WriteLine ();
- }
-
- protected override void GenerateField (CodeMemberField field)
- {
- TextWriter output = Output;
-
- if (field.CustomAttributes.Count > 0)
- OutputAttributeDeclarations (field.CustomAttributes);
-
- MemberAttributes attributes = field.Attributes;
- OutputMemberAccessModifier (attributes);
- OutputFieldScopeModifier (attributes);
-
- OutputTypeNamePair (field.Type, field.Name);
-
- CodeExpression initExpression = field.InitExpression;
- if (initExpression != null) {
- output.Write (" = ");
- GenerateExpression (initExpression);
- }
-
- output.WriteLine();
- }
-
- protected override void GenerateSnippetMember (CodeSnippetTypeMember member)
- {
- Output.Write (member.Text);
- }
-
- protected override void GenerateEntryPointMethod( CodeEntryPointMethod method, CodeTypeDeclaration declaration )
- {
- method.Name = "Main";
- GenerateMethod (method, declaration);
- }
-
- [MonoTODO ("partially implemented")]
- protected override void GenerateMethod (CodeMemberMethod method, CodeTypeDeclaration declaration)
- {
- bool isSub = method.ReturnType == null || method.ReturnType.ToString() == "System.Void";
-
- TextWriter output = Output;
-
- if (method.CustomAttributes.Count > 0)
- OutputAttributeDeclarations (method.CustomAttributes);
-
- MemberAttributes attributes = method.Attributes;
-
- OutputMemberAccessModifier (attributes);
- OutputMemberScopeModifier (attributes);
-
- if (isSub)
- output.Write ("Sub ");
- else
- output.Write ("Function ");
-
- output.Write (method.Name);
- output.Write ('(');
- OutputParameters (method.Parameters);
- output.Write (')');
-
- if (!isSub) {
- output.Write (" As ");
- OutputType (method.ReturnType);
- }
-
- if (method.ImplementationTypes.Count > 0) {
- output.Write (" Implements ");
- foreach (CodeTypeReference type in method.ImplementationTypes)
- {
- OutputType (type);
- output.Write ('.');
- // TODO implementation incomplete
-
- }
- }
-
- // TODO private implementations
-
- if ((attributes & MemberAttributes.ScopeMask) == MemberAttributes.Abstract)
- output.WriteLine ();
- else {
- output.WriteLine ();
- ++Indent;
- GenerateStatements (method.Statements);
- --Indent;
- if (isSub)
- output.WriteLine ("End Sub");
- else
- output.WriteLine ("End Function");
- }
- }
-
- protected override void GenerateProperty (CodeMemberProperty property, CodeTypeDeclaration declaration)
- {
- TextWriter output = Output;
-
- if (property.CustomAttributes.Count > 0)
- OutputAttributeDeclarations (property.CustomAttributes);
-
- MemberAttributes attributes = property.Attributes;
- OutputMemberAccessModifier (attributes);
- OutputMemberScopeModifier (attributes);
-
- if (property.HasGet && (property.HasSet = false))
- output.Write ("ReadOnly " );
-
- if (property.HasSet && (property.HasGet = false))
- output.Write ("WriteOnly " );
-
- output.Write ("Property" );
-
- OutputTypeNamePair (property.Type, property.Name);
- output.WriteLine ();
- ++Indent;
-
- if (property.HasGet) {
- output.WriteLine ("Get");
- ++Indent;
-
- GenerateStatements (property.GetStatements);
-
- --Indent;
- output.WriteLine ("End Get");
- }
-
- if (property.HasSet) {
- output.WriteLine ("Set");
- ++Indent;
-
- GenerateStatements (property.SetStatements);
-
- --Indent;
- output.WriteLine ("End Set");
- }
-
- --Indent;
- output.WriteLine ("End Property");
- }
-
- [MonoTODO ("not implemented")]
- protected override void GenerateConstructor (CodeConstructor constructor, CodeTypeDeclaration declaration)
- {
- if (constructor.CustomAttributes.Count > 0)
- OutputAttributeDeclarations (constructor.CustomAttributes);
- OutputMemberAccessModifier (constructor.Attributes);
- Output.Write ("Sub New(");
- OutputParameters (constructor.Parameters);
- Output.WriteLine (")");
- // Handle BaseConstructorArgs, ChainedConstructorArgs, ImplementationTypes
- Indent++;
- GenerateStatements (constructor.Statements);
- Indent--;
- Output.WriteLine ("End Sub");
- }
-
- protected override void GenerateTypeConstructor (CodeTypeConstructor constructor)
- {
- Output.WriteLine ("Shared Sub New()");
- Indent++;
- GenerateStatements (constructor.Statements);
- Indent--;
- Output.WriteLine ("End Sub");
- }
-
- [MonoTODO ("not implemented")]
- protected override void GenerateTypeStart (CodeTypeDeclaration declaration)
- {
- TextWriter output = Output;
-
- if (declaration.CustomAttributes.Count > 0)
- OutputAttributeDeclarations (declaration.CustomAttributes);
- TypeAttributes attributes = declaration.TypeAttributes;
- OutputTypeAttributes (attributes,
- declaration.IsStruct,
- declaration.IsEnum);
-
- output.WriteLine (declaration.Name);
-
- ++Indent;
-
- IEnumerator enumerator = declaration.BaseTypes.GetEnumerator();
- if (enumerator.MoveNext())
- {
- CodeTypeReference type = (CodeTypeReference)enumerator.Current;
-
- if (type != null)
- {
- output.Write ("Inherits ");
- OutputType (type);
- output.WriteLine ();
- }
-
- while (enumerator.MoveNext())
- {
- type = (CodeTypeReference)enumerator.Current;
-
- if (type != null)
- {
- output.Write ("Implements ");
- OutputType (type);
- output.WriteLine ();
- }
- }
- }
- }
-
- protected override void GenerateTypeEnd (CodeTypeDeclaration declaration)
- {
- string output = string.Empty;
-
- --Indent;
- if (declaration.IsStruct)
- output = "End Structure";
- if (declaration.IsInterface)
- output = "End Interface";
- if (declaration.IsEnum)
- output = "End Enum";
- if (declaration.IsClass)
- output = "End Class";
-
- Output.WriteLine (output);
- }
-
- protected override void GenerateNamespaceStart (CodeNamespace ns)
- {
- TextWriter output = Output;
-
- string name = ns.Name;
- if (name != null && name != string.Empty) {
- output.Write ("Namespace ");
- output.WriteLine (name);
- ++Indent;
- }
- }
-
- protected override void GenerateNamespaceEnd (CodeNamespace ns)
- {
- string name = ns.Name;
- if (name != null && name != string.Empty) {
- --Indent;
- Output.WriteLine ("End Namespace");
- }
- }
-
- protected override void GenerateNamespaceImport (CodeNamespaceImport import)
- {
- TextWriter output = Output;
-
- output.Write ("Imports ");
- output.Write (import.Namespace);
- output.WriteLine ();
- }
-
- protected override void GenerateAttributeDeclarationsStart (CodeAttributeDeclarationCollection attributes)
- {
- Output.Write ('<');
- }
-
- protected override void GenerateAttributeDeclarationsEnd (CodeAttributeDeclarationCollection attributes)
- {
- Output.WriteLine ('>');
- }
-
- protected override void OutputDirection (FieldDirection direction)
- {
- switch (direction) {
- case FieldDirection.In:
- //there is no "In"
- break;
- case FieldDirection.Out:
- Output.Write ("ByVal ");
- break;
- case FieldDirection.Ref:
- Output.Write ("ByRef ");
- break;
- }
- }
-
- protected override void OutputFieldScopeModifier (MemberAttributes attributes)
- {
- if ((attributes & MemberAttributes.VTableMask) == MemberAttributes.New)
- Output.Write ("New ");
-
- switch (attributes & MemberAttributes.ScopeMask) {
- case MemberAttributes.Static:
- Output.Write ("Shared ");
- break;
- case MemberAttributes.Const:
- Output.Write ("Const ");
- break;
- }
- }
-
- protected override void OutputMemberAccessModifier (MemberAttributes attributes)
- {
- switch (attributes & MemberAttributes.AccessMask) {
- case MemberAttributes.Assembly:
- Output.Write ("Friend ");
- break;
- case MemberAttributes.FamilyAndAssembly:
- Output.Write ("Friend ");
- break;
- case MemberAttributes.Family:
- Output.Write ("Protected ");
- break;
- case MemberAttributes.FamilyOrAssembly:
- Output.Write ("Protected Friend ");
- break;
- case MemberAttributes.Private:
- Output.Write ("Private ");
- break;
- case MemberAttributes.Public:
- Output.Write ("Public ");
- break;
- }
- }
-
- protected override void OutputMemberScopeModifier (MemberAttributes attributes)
- {
- if ((attributes & MemberAttributes.VTableMask) == MemberAttributes.New)
- Output.Write ("New ");
-
- switch (attributes & MemberAttributes.ScopeMask) {
- case MemberAttributes.Abstract:
- Output.Write ("MustOverride ");
- break;
- case MemberAttributes.Final:
- Output.Write ("NotOverridable ");
- break;
- case MemberAttributes.Static:
- Output.Write ("Shared ");
- break;
- case MemberAttributes.Override:
- Output.Write ("Overrides ");
- break;
- default:
- //
- // FUNNY! if the scope value is
- // rubbish (0 or >Const), and access
- // is public or protected, make it
- // "virtual".
- //
- // i'm not sure whether this is 100%
- // correct, but it seems to be MS
- // behavior.
- //
- MemberAttributes access = attributes & MemberAttributes.AccessMask;
- if ( access == MemberAttributes.Public ||
- access == MemberAttributes.Family )
- Output.Write ("Overridable ");
- break;
- }
- }
-
- protected override void OutputOperator (CodeBinaryOperatorType op)
- {
- switch (op) {
- case CodeBinaryOperatorType.Add:
- Output.Write ("+");
- break;
- case CodeBinaryOperatorType.Subtract:
- Output.Write ("-");
- break;
- case CodeBinaryOperatorType.Multiply:
- Output.Write ("*");
- break;
- case CodeBinaryOperatorType.Divide:
- Output.Write ("/");
- break;
- case CodeBinaryOperatorType.Modulus:
- Output.Write ("Mod");
- break;
- case CodeBinaryOperatorType.Assign:
- Output.Write ("=");
- break;
- case CodeBinaryOperatorType.IdentityInequality:
- Output.Write ("<>");
- break;
- case CodeBinaryOperatorType.IdentityEquality:
- Output.Write ("Is");
- break;
- case CodeBinaryOperatorType.ValueEquality:
- Output.Write ("=");
- break;
- case CodeBinaryOperatorType.BitwiseOr:
- Output.Write ("Or");
- break;
- case CodeBinaryOperatorType.BitwiseAnd:
- Output.Write ("And");
- break;
- case CodeBinaryOperatorType.BooleanOr:
- Output.Write ("OrElse");
- break;
- case CodeBinaryOperatorType.BooleanAnd:
- Output.Write ("AndAlso");
- break;
- case CodeBinaryOperatorType.LessThan:
- Output.Write ("<");
- break;
- case CodeBinaryOperatorType.LessThanOrEqual:
- Output.Write ("<=");
- break;
- case CodeBinaryOperatorType.GreaterThan:
- Output.Write (">");
- break;
- case CodeBinaryOperatorType.GreaterThanOrEqual:
- Output.Write (">=");
- break;
- }
- }
-
- protected override void OutputTypeAttributes (TypeAttributes attributes, bool isStruct, bool isEnum)
- {
- TextWriter output = Output;
-
- switch (attributes & TypeAttributes.VisibilityMask) {
- case TypeAttributes.NotPublic:
- // Does this mean friend access?
- output.Write ("Friend ");
- break;
-
- case TypeAttributes.Public:
- case TypeAttributes.NestedPublic:
- output.Write ("Public ");
- break;
-
- case TypeAttributes.NestedPrivate:
- output.Write ("Private ");
- break;
- case TypeAttributes.NestedAssembly:
- output.Write ("Friend ");
- break;
- case TypeAttributes.NestedFamily:
- output.Write ("Protected ");
- break;
- case TypeAttributes.NestedFamORAssem:
- output.Write ("Protected Friend ");
- break;
- case TypeAttributes.NestedFamANDAssem:
- output.Write ("Friend ");
- break;
- }
-
- if (isStruct)
- output.Write ("Structure ");
-
- else if (isEnum)
- output.Write ("Enumeration ");
-
- else {
- if ((attributes & TypeAttributes.Interface) != 0)
- output.Write ("Interface ");
-
- else {
- if ((attributes & TypeAttributes.Sealed) != 0)
- output.Write ("NotInheritable ");
-
- if ((attributes & TypeAttributes.Abstract) != 0)
- output.Write ("MustInherit ");
-
- output.Write ("Class ");
- }
- }
- }
-
- protected override void OutputTypeNamePair (CodeTypeReference typeRef, String name)
- {
- Output.Write (name + " As " + GetTypeOutput (typeRef));
- }
-
- protected override void OutputType (CodeTypeReference type)
- {
- Output.Write (GetTypeOutput (type));
- }
-
- protected override string QuoteSnippetString (string value)
- {
- StringBuilder mySBuilder = new StringBuilder(value.Length);
- mySBuilder.Append ("\"");
- bool inQuotes = true;
- for (int MyCounter = 0; MyCounter < value.Length; MyCounter++)
- {
- if (value[MyCounter] == 34) //quotation mark
- {
- if (!inQuotes)
- {
- mySBuilder.Append ("&\"");
- inQuotes = true;
- }
- mySBuilder.Append (value[MyCounter]);
- mySBuilder.Append (value[MyCounter]);
- }
- else if (value[MyCounter] >= 32) //standard ansi/unicode characters
- {
- if (!inQuotes)
- {
- mySBuilder.Append ("&\"");
- inQuotes = true;
- }
- mySBuilder.Append (value[MyCounter]);
- }
- else //special chars, e.g. line break
- {
- if (inQuotes)
- {
- mySBuilder.Append ("\"");
- inQuotes = false;
- }
- mySBuilder.Append ("&Microsoft.VisualBasic.ChrW(");
- mySBuilder.Append ((int)value[MyCounter]);
- mySBuilder.Append (")");
- }
- }
- mySBuilder.Append ("\"");
- return mySBuilder.ToString();
- }
-
- private void GenerateDeclaration (CodeTypeReference type, string name, CodeExpression initExpression)
- {
- TextWriter output = Output;
-
- OutputTypeNamePair (type, name);
-
- if (initExpression != null) {
- output.Write (" = ");
- GenerateExpression (initExpression);
- }
-
- output.WriteLine ();
- }
-
- private void GenerateMemberReferenceExpression (CodeExpression targetObject, string memberName)
- {
- GenerateExpression (targetObject);
- Output.Write ('.');
- Output.Write (memberName);
- }
-
- /*
- * ICodeGenerator
- */
-
- protected override string CreateEscapedIdentifier (string value)
- {
- for (int x = 0; x < Keywords.Length; x++)
- if (value.ToLower().Equals (Keywords[x].ToLower()))
- return "[" + value + "]";
- return value;
- }
-
- protected override string CreateValidIdentifier (string value)
- {
- for (int x = 0; x < Keywords.Length; x++)
- if (value.ToLower().Equals (Keywords[x].ToLower()))
- return "_" + value;
- return value;
- }
-
- protected override string GetTypeOutput (CodeTypeReference type)
- {
- string output;
- CodeTypeReference arrayType;
-
- arrayType = type.ArrayElementType;
- if (arrayType != null)
- output = GetTypeOutput (arrayType);
- else {
- switch (type.BaseType) {
-
- case "System.Decimal":
- output = "Decimal";
- break;
- case "System.Double":
- output = "Double";
- break;
- case "System.Single":
- output = "Single";
- break;
-
- case "System.Byte":
- output = "Byte";
- break;
- case "System.SByte":
- output = "SByte";
- break;
- case "System.Int32":
- output = "Integer";
- break;
- case "System.UInt32":
- output = "UInt32";
- break;
- case "System.Int64":
- output = "Long";
- break;
- case "System.UInt64":
- output = "UInt64";
- break;
- case "System.Int16":
- output = "Short";
- break;
- case "System.UInt16":
- output = "UInt16";
- break;
-
- case "System.Boolean":
- output = "Boolean";
- break;
-
- case "System.Char":
- output = "Char";
- break;
-
- case "System.String":
- output = "String";
- break;
- case "System.Object":
- output = "Object";
- break;
-
- case "System.Void":
- output = "Nothing";
- break;
-
- default:
- output = type.BaseType;
- break;
- }
- }
-
- int rank = type.ArrayRank;
- if (rank > 0) {
- output += "(";
- for (--rank; rank > 0; --rank)
- output += ",";
- output += ")";
- }
-
- return output;
- }
-
- protected override bool IsValidIdentifier (string identifier)
- {
- for (int x = 0; x < Keywords.Length; x++)
- if (identifier.ToLower().Equals (Keywords[x].ToLower()))
- return false;
- return true;
- }
-
- protected override bool Supports (GeneratorSupport supports)
- {
- return true;
- }
- }
-}
+//
+// Microsoft.VisualBasic.VBCodeGenerator.cs
+//
+// Author:
+// Andreas Nahr (ClassDevelopment@A-SoftTech.com)
+// (partially based on CSharpCodeGenerator)
+// Jochen Wezel (jwezel@compumaster.de)
+//
+// (C) 2003 Andreas Nahr
+// (C) 2003 Jochen Wezel (http://www.compumaster.de)
+//
+// Modifications:
+// 2003-11-06 JW: some corrections regarding missing spaces in generated code (e. g. "Property ")
+// 2003-11-06 JW: QuoteSnippetString implemented
+// 2003-11-08 JW: automatically add Microsoft.VisualBasic
+// 2003-11-12 JW: some corrections to allow correct compilation
+// 2003-11-28 JW: implementing code differences into current build of this file
+
+using System;
+using System.Text;
+using System.Text.RegularExpressions;
+using System.CodeDom;
+using System.CodeDom.Compiler;
+using System.IO;
+using System.Reflection;
+using System.Collections;
+
+namespace Microsoft.VisualBasic
+{
+ internal class VBCodeGenerator : CodeGenerator
+ {
+ private string[] Keywords = new string[] {
+ "AddHandler", "AddressOf", "Alias", "And",
+ "AndAlso", "Ansi", "As", "Assembly",
+ "Auto", "Boolean", "ByRef", "Byte",
+ "ByVal", "Call", "Case", "Catch",
+ "CBool", "CByte", "CChar", "CDate",
+ "CDec", "CDbl", "Char", "CInt",
+ "Class", "CLng", "CObj", "Const",
+ "CShort", "CSng", "CStr", "CType",
+ "Date", "Decimal", "Declare", "Default",
+ "Delegate", "Dim", "DirectCast", "Do",
+ "Double", "Each", "Else", "ElseIf",
+ "End", "Enum", "Erase", "Error",
+ "Event", "Exit", "False", "Finally",
+ "For", "Friend", "Function", "Get",
+ "GetType", "GoSub", "GoTo", "Handles",
+ "If", "Implements", "Imports", "In",
+ "Inherits", "Integer", "Interface", "Is",
+ "Let", "Lib", "Like", "Long",
+ "Loop", "Me", "Mod", "Module",
+ "MustInherit", "MustOverride", "MyBase", "MyClass",
+ "Namespace", "New", "Next", "Not",
+ "Nothing", "NotInheritable", "NotOverridable", "Object",
+ "On", "Option", "Optional", "Or",
+ "OrElse", "Overloads", "Overridable", "Overrides",
+ "ParamArray", "Preserve", "Private", "Property",
+ "Protected", "Public", "RaiseEvent", "ReadOnly",
+ "ReDim", "REM", "RemoveHandler", "Resume",
+ "Return", "Select", "Set", "Shadows",
+ "Shared", "Short", "Single", "Static",
+ "Step", "Stop", "String", "Structure",
+ "Sub", "SyncLock", "Then", "Throw",
+ "To", "True", "Try", "TypeOf",
+ "Unicode", "Until", "Variant", "When",
+ "While", "With", "WithEvents", "WriteOnly",
+ "Xor"
+ };
+
+ public VBCodeGenerator()
+ {
+ }
+
+ protected override string NullToken {
+ get {
+ return "Nothing";
+ }
+ }
+
+ protected override void GenerateArrayCreateExpression (CodeArrayCreateExpression expression)
+ {
+ TextWriter output = Output;
+
+ output.Write ("New ");
+
+ CodeExpressionCollection initializers = expression.Initializers;
+ CodeTypeReference createType = expression.CreateType;
+
+ if (initializers.Count > 0) {
+
+ OutputType (createType);
+
+ output.WriteLine (" {");
+ ++Indent;
+ OutputExpressionList (initializers, true);
+ --Indent;
+ output.Write ("}");
+
+ }
+ else {
+ CodeTypeReference arrayType = createType.ArrayElementType;
+ while (arrayType != null)
+ {
+ createType = arrayType;
+ arrayType = arrayType.ArrayElementType;
+ }
+
+ OutputType (createType);
+
+ output.Write ('(');
+
+ CodeExpression size = expression.SizeExpression;
+ if (size != null)
+ GenerateExpression (size);
+ else
+ output.Write (expression.Size);
+
+ output.Write (')');
+ }
+ }
+
+ protected override void GenerateBaseReferenceExpression (CodeBaseReferenceExpression expression)
+ {
+ Output.Write ("MyBase");
+ }
+
+ protected override void GenerateCastExpression (CodeCastExpression expression)
+ {
+ TextWriter output = Output;
+ // ENHANCE: Use a DirectCast if it is known that expression.Expression is no Value-Type
+ output.Write ("CType(");
+ GenerateExpression (expression.Expression);
+ output.Write (", ");
+ OutputType (expression.TargetType);
+ output.Write (")");
+ }
+
+ private bool AsBool(object datavalue)
+ {
+ return datavalue != null && datavalue is bool && (bool)datavalue;
+ }
+
+ private string OnOff(bool datavalue)
+ {
+ return datavalue?"On":"Off";
+ }
+
+ protected override void GenerateCompileUnitStart (CodeCompileUnit compileUnit)
+ {
+ GenerateComment (new CodeComment ("------------------------------------------------------------------------------"));
+ GenerateComment (new CodeComment (" <autogenerated>"));
+ GenerateComment (new CodeComment (" This code was generated by a tool."));
+ GenerateComment (new CodeComment (" Mono Runtime Version: " + System.Environment.Version));
+ GenerateComment (new CodeComment (""));
+ GenerateComment (new CodeComment (" Changes to this file may cause incorrect behavior and will be lost if "));
+ GenerateComment (new CodeComment (" the code is regenerated."));
+ GenerateComment (new CodeComment (" </autogenerated>"));
+ GenerateComment (new CodeComment ("------------------------------------------------------------------------------"));
+ Output.WriteLine ();
+ Output.WriteLine("Option Explicit {0}",OnOff(AsBool(compileUnit.UserData["RequireVariableDeclaration"])));
+ Output.WriteLine("Option Strict {0}",OnOff(!AsBool(compileUnit.UserData["AllowLateBound"])));
+ Output.WriteLine ();
+ }
+
+ protected override void GenerateDelegateCreateExpression (CodeDelegateCreateExpression expression)
+ {
+ TextWriter output = Output;
+
+ output.Write ("AddressOf ");
+
+ CodeExpression targetObject = expression.TargetObject;
+ if (targetObject != null) {
+ GenerateExpression (targetObject);
+ Output.Write ('.');
+ }
+ output.Write (expression.MethodName);
+ }
+
+ protected override void GenerateFieldReferenceExpression (CodeFieldReferenceExpression expression)
+ {
+ CodeExpression targetObject = expression.TargetObject;
+ if (targetObject != null) {
+ GenerateExpression (targetObject);
+ Output.Write ('.');
+ }
+ Output.Write (expression.FieldName);
+ }
+
+ protected override void GenerateArgumentReferenceExpression (CodeArgumentReferenceExpression expression)
+ {
+ Output.Write (expression.ParameterName);
+ }
+
+ protected override void GenerateVariableReferenceExpression (CodeVariableReferenceExpression expression)
+ {
+ Output.Write (expression.VariableName);
+ }
+
+ protected override void GenerateIndexerExpression (CodeIndexerExpression expression)
+ {
+ TextWriter output = Output;
+
+ GenerateExpression (expression.TargetObject);
+ output.Write ('(');
+ OutputExpressionList (expression.Indices);
+ output.Write (')');
+ }
+
+ protected override void GenerateArrayIndexerExpression (CodeArrayIndexerExpression expression)
+ {
+ TextWriter output = Output;
+
+ GenerateExpression (expression.TargetObject);
+ output.Write (".Item(");
+ OutputExpressionList (expression.Indices);
+ output.Write (')');
+ }
+
+ protected override void GenerateSnippetExpression (CodeSnippetExpression expression)
+ {
+ Output.Write (expression.Value);
+ }
+
+ protected override void GenerateMethodInvokeExpression (CodeMethodInvokeExpression expression)
+ {
+ TextWriter output = Output;
+
+ GenerateMethodReferenceExpression (expression.Method);
+
+ output.Write ('(');
+ OutputExpressionList (expression.Parameters);
+ output.Write (')');
+ }
+
+ protected override void GenerateMethodReferenceExpression (CodeMethodReferenceExpression expression)
+ {
+ GenerateExpression (expression.TargetObject);
+ Output.Write ('.');
+ Output.Write (expression.MethodName);
+ }
+
+ protected override void GenerateEventReferenceExpression (CodeEventReferenceExpression expression)
+ {
+ GenerateExpression (expression.TargetObject);
+ Output.Write ('.');
+ Output.Write (expression.EventName);
+ }
+
+ protected override void GenerateDelegateInvokeExpression (CodeDelegateInvokeExpression expression)
+ {
+ Output.Write ("RaiseEvent ");
+ GenerateExpression (expression.TargetObject);
+ Output.Write ('(');
+ OutputExpressionList (expression.Parameters);
+ Output.WriteLine (')');
+ }
+
+ protected override void GenerateObjectCreateExpression (CodeObjectCreateExpression expression)
+ {
+ Output.Write( "New " );
+ OutputType (expression.CreateType);
+ Output.Write ('(');
+ OutputExpressionList (expression.Parameters);
+ Output.Write (')');
+ }
+
+ protected override void GenerateParameterDeclarationExpression (CodeParameterDeclarationExpression e)
+ {
+ if (e.CustomAttributes != null && e.CustomAttributes.Count > 0)
+ OutputAttributeDeclarations (e.CustomAttributes);
+ OutputDirection (e.Direction);
+ OutputTypeNamePair (e.Type, e.Name);
+ }
+
+ protected override void GeneratePrimitiveExpression (CodePrimitiveExpression e)
+ {
+ TextWriter output = Output;
+
+ if (e.Value == null) {
+ output.Write (NullToken);
+ return;
+ }
+
+ Type type = e.Value.GetType ();
+ if (type == typeof (bool)) {
+ if ((bool)e.Value)
+ output.Write ("True");
+ else
+ output.Write ("False");
+ }
+ else if (type == typeof (char)) {
+ output.Write ("\"" + e.Value.ToString () + "\"c");
+ }
+ else if (type == typeof (string)) {
+ output.Write (QuoteSnippetString ((string) e.Value));
+ }
+ else if (type == typeof (byte) || type == typeof (sbyte) || type == typeof (short) ||
+ type == typeof (int) || type == typeof (long) || type == typeof (float) ||
+ type == typeof (double) || type == typeof (decimal)) {
+ output.Write (e.Value.ToString ());
+ }
+ else {
+ throw new ArgumentException ("Value type (" + type + ") is not a primitive type");
+ }
+ }
+
+ protected override void GeneratePropertyReferenceExpression (CodePropertyReferenceExpression expression)
+ {
+ GenerateMemberReferenceExpression (expression.TargetObject, expression.PropertyName);
+ }
+
+ protected override void GeneratePropertySetValueReferenceExpression (CodePropertySetValueReferenceExpression expression)
+ {
+ Output.Write ("Value");
+ }
+
+ protected override void GenerateThisReferenceExpression (CodeThisReferenceExpression expression)
+ {
+ Output.Write ("Me");
+ }
+
+ protected override void GenerateExpressionStatement (CodeExpressionStatement statement)
+ {
+ GenerateExpression (statement.Expression);
+ Output.WriteLine (); //start new line
+ }
+
+ protected override void GenerateIterationStatement (CodeIterationStatement statement)
+ {
+ TextWriter output = Output;
+
+ GenerateStatement (statement.InitStatement);
+ output.Write ("Do While ");
+ GenerateExpression (statement.TestExpression);
+ output.WriteLine ();
+ GenerateStatements (statement.Statements);
+ GenerateStatement (statement.IncrementStatement);
+ output.WriteLine ("Loop");
+ }
+
+ protected override void GenerateThrowExceptionStatement (CodeThrowExceptionStatement statement)
+ {
+ Output.Write ("Throw ");
+ GenerateExpression (statement.ToThrow);
+ }
+
+ protected override void GenerateComment (CodeComment comment)
+ {
+ TextWriter output = Output;
+
+ if (comment.DocComment)
+ output.Write ("''' ");
+ else
+ output.Write ("' ");
+
+ output.WriteLine (comment.Text);
+ }
+
+ protected override void GenerateMethodReturnStatement (CodeMethodReturnStatement statement)
+ {
+ TextWriter output = Output;
+
+ output.Write ("Return ");
+ GenerateExpression (statement.Expression);
+ output.WriteLine ();
+ }
+
+ protected override void GenerateConditionStatement (CodeConditionStatement statement)
+ {
+ TextWriter output = Output;
+ output.Write ("If (");
+
+ GenerateExpression (statement.Condition);
+
+ output.WriteLine (") Then");
+ ++Indent;
+ GenerateStatements (statement.TrueStatements);
+ --Indent;
+
+ CodeStatementCollection falses = statement.FalseStatements;
+ if (falses.Count > 0) {
+ output.WriteLine ("Else");
+ ++Indent;
+ GenerateStatements (falses);
+ --Indent;
+ }
+ else {
+ if (Options.ElseOnClosing)
+ output.WriteLine ("Else");
+ }
+ output.WriteLine ("End If");
+ }
+
+ protected override void GenerateTryCatchFinallyStatement (CodeTryCatchFinallyStatement statement)
+ {
+ TextWriter output = Output;
+ CodeGeneratorOptions options = Options;
+
+ output.WriteLine ("Try");
+ ++Indent;
+ GenerateStatements (statement.TryStatements);
+ --Indent;
+ output.WriteLine ();
+
+ foreach (CodeCatchClause clause in statement.CatchClauses) {
+ output.Write ("Catch ");
+ OutputTypeNamePair (clause.CatchExceptionType, clause.LocalName);
+ output.WriteLine ();
+ ++Indent;
+ GenerateStatements (clause.Statements);
+ --Indent;
+ output.WriteLine ();
+ }
+
+ CodeStatementCollection finallies = statement.FinallyStatements;
+ if (finallies.Count > 0) {
+
+ output.WriteLine ("Finally");
+ ++Indent;
+ GenerateStatements (finallies);
+ --Indent;
+ output.WriteLine ();
+ }
+
+ if (Options.ElseOnClosing) {
+ if (statement.CatchClauses.Count == 0)
+ output.WriteLine ("Catch");
+ if (statement.FinallyStatements.Count == 0)
+ output.WriteLine ("Finally");
+ }
+
+ output.WriteLine("End Try");
+ }
+
+ protected override void GenerateAssignStatement (CodeAssignStatement statement)
+ {
+ TextWriter output = Output;
+ GenerateExpression (statement.Left);
+ output.Write (" = ");
+ GenerateExpression (statement.Right);
+ output.WriteLine ();
+ }
+
+ protected override void GenerateAttachEventStatement (CodeAttachEventStatement statement)
+ {
+ TextWriter output = Output;
+
+ Output.Write ("AddHandler ");
+ GenerateEventReferenceExpression (statement.Event);
+ Output.Write ( ", ");
+ GenerateExpression (statement.Listener);
+ output.WriteLine ();
+ }
+
+ protected override void GenerateRemoveEventStatement (CodeRemoveEventStatement statement)
+ {
+ TextWriter output = Output;
+
+ Output.Write ("RemoveHandler ");
+ GenerateEventReferenceExpression (statement.Event);
+ Output.Write ( ", ");
+ GenerateExpression (statement.Listener);
+ output.WriteLine ();
+ }
+
+ protected override void GenerateGotoStatement (CodeGotoStatement statement)
+ {
+ TextWriter output = Output;
+
+ output.Write ("Goto ");
+ output.Write (statement.Label);
+ output.WriteLine ();
+ }
+
+ protected override void GenerateLabeledStatement (CodeLabeledStatement statement)
+ {
+ TextWriter output = Output;
+
+ output.Write (statement.Label + ":");
+ GenerateStatement (statement.Statement);
+ }
+
+ protected override void GenerateTypeOfExpression (CodeTypeOfExpression e)
+ {
+ TextWriter output = Output;
+
+ output.Write ("GetType(");
+ OutputType (e.Type);
+ output.Write (")");
+ }
+
+ protected override void GenerateVariableDeclarationStatement( CodeVariableDeclarationStatement statement )
+ {
+ TextWriter output = Output;
+
+ output.Write ("Dim ");
+ OutputTypeNamePair (statement.Type, statement.Name);
+
+ CodeExpression initExpression = statement.InitExpression;
+ if (initExpression != null)
+ {
+ output.Write (" = ");
+ GenerateExpression (initExpression);
+ }
+
+ output.WriteLine();
+ }
+
+ protected override void GenerateLinePragmaStart (CodeLinePragma linePragma)
+ {
+ Output.WriteLine ();
+ Output.Write ("#ExternalSource(");
+ Output.Write (linePragma.FileName);
+ Output.Write (", ");
+ Output.Write (linePragma.LineNumber);
+ Output.WriteLine (")");
+ }
+
+ protected override void GenerateLinePragmaEnd (CodeLinePragma linePragma)
+ {
+ Output.WriteLine ("#End ExternalSource");
+ }
+
+ protected override void GenerateEvent (CodeMemberEvent eventRef, CodeTypeDeclaration declaration)
+ {
+ TextWriter output = Output;
+
+ if (eventRef.CustomAttributes.Count > 0)
+ OutputAttributeDeclarations (eventRef.CustomAttributes);
+
+ MemberAttributes attributes = eventRef.Attributes;
+
+ OutputMemberAccessModifier (attributes);
+ OutputMemberScopeModifier (attributes);
+
+ output.Write ("Event ");
+ OutputTypeNamePair (eventRef.Type, eventRef.Name);
+ output.WriteLine ();
+ }
+
+ protected override void GenerateField (CodeMemberField field)
+ {
+ TextWriter output = Output;
+
+ if (field.CustomAttributes.Count > 0)
+ OutputAttributeDeclarations (field.CustomAttributes);
+
+ MemberAttributes attributes = field.Attributes;
+ OutputMemberAccessModifier (attributes);
+ OutputFieldScopeModifier (attributes);
+
+ OutputTypeNamePair (field.Type, field.Name);
+
+ CodeExpression initExpression = field.InitExpression;
+ if (initExpression != null) {
+ output.Write (" = ");
+ GenerateExpression (initExpression);
+ }
+
+ output.WriteLine();
+ }
+
+ protected override void GenerateSnippetMember (CodeSnippetTypeMember member)
+ {
+ Output.Write (member.Text);
+ }
+
+ protected override void GenerateEntryPointMethod( CodeEntryPointMethod method, CodeTypeDeclaration declaration )
+ {
+ method.Name = "Main";
+ GenerateMethod (method, declaration);
+ }
+
+ [MonoTODO ("partially implemented")]
+ protected override void GenerateMethod (CodeMemberMethod method, CodeTypeDeclaration declaration)
+ {
+ bool isSub = method.ReturnType == null || method.ReturnType.BaseType == "System.Void";
+
+ TextWriter output = Output;
+
+ if (method.CustomAttributes.Count > 0)
+ OutputAttributeDeclarations (method.CustomAttributes);
+
+ MemberAttributes attributes = method.Attributes;
+
+ OutputMemberAccessModifier (attributes);
+ OutputMemberScopeModifier (attributes);
+
+ if (isSub)
+ output.Write ("Sub ");
+ else
+ output.Write ("Function ");
+
+ output.Write (method.Name);
+ output.Write ('(');
+ OutputParameters (method.Parameters);
+ output.Write (')');
+
+ if (!isSub) {
+ output.Write (" As ");
+ OutputType (method.ReturnType);
+ }
+
+ if (method.ImplementationTypes.Count > 0) {
+ output.Write (" Implements ");
+ foreach (CodeTypeReference type in method.ImplementationTypes)
+ {
+ OutputType (type);
+ output.Write ('.');
+ // TODO implementation incomplete
+
+ }
+ }
+
+ // TODO private implementations
+
+ if ((attributes & MemberAttributes.ScopeMask) == MemberAttributes.Abstract)
+ output.WriteLine ();
+ else {
+ output.WriteLine ();
+ ++Indent;
+ GenerateStatements (method.Statements);
+ --Indent;
+ if (isSub)
+ output.WriteLine ("End Sub");
+ else
+ output.WriteLine ("End Function");
+ }
+ }
+
+ protected override void GenerateProperty (CodeMemberProperty property, CodeTypeDeclaration declaration)
+ {
+ TextWriter output = Output;
+
+ if (property.CustomAttributes.Count > 0)
+ OutputAttributeDeclarations (property.CustomAttributes);
+
+ MemberAttributes attributes = property.Attributes;
+ OutputMemberAccessModifier (attributes);
+ OutputMemberScopeModifier (attributes);
+
+ if (property.HasGet && (property.HasSet = false))
+ output.Write ("ReadOnly " );
+
+ if (property.HasSet && (property.HasGet = false))
+ output.Write ("WriteOnly " );
+
+ output.Write ("Property " );
+
+ OutputTypeNamePair (property.Type, property.Name);
+ output.WriteLine ();
+ ++Indent;
+
+ if (property.HasGet) {
+ output.WriteLine ("Get");
+ ++Indent;
+
+ GenerateStatements (property.GetStatements);
+
+ --Indent;
+ output.WriteLine ("End Get");
+ }
+
+ if (property.HasSet) {
+ output.WriteLine ("Set");
+ ++Indent;
+
+ GenerateStatements (property.SetStatements);
+
+ --Indent;
+ output.WriteLine ("End Set");
+ }
+
+ --Indent;
+ output.WriteLine ("End Property");
+ }
+
+ [MonoTODO ("not implemented")]
+ protected override void GenerateConstructor (CodeConstructor constructor, CodeTypeDeclaration declaration)
+ {
+ if (constructor.CustomAttributes.Count > 0)
+ OutputAttributeDeclarations (constructor.CustomAttributes);
+ OutputMemberAccessModifier (constructor.Attributes);
+ Output.Write ("Sub New(");
+ OutputParameters (constructor.Parameters);
+ Output.WriteLine (")");
+ // Handle BaseConstructorArgs, ChainedConstructorArgs, ImplementationTypes
+ Indent++;
+ GenerateStatements (constructor.Statements);
+ Indent--;
+ Output.WriteLine ("End Sub");
+ }
+
+ protected override void GenerateTypeConstructor (CodeTypeConstructor constructor)
+ {
+ Output.WriteLine ("Shared Sub New()");
+ Indent++;
+ GenerateStatements (constructor.Statements);
+ Indent--;
+ Output.WriteLine ("End Sub");
+ }
+
+ [MonoTODO ("not implemented")]
+ protected override void GenerateTypeStart (CodeTypeDeclaration declaration)
+ {
+ TextWriter output = Output;
+
+ if (declaration.CustomAttributes.Count > 0)
+ OutputAttributeDeclarations (declaration.CustomAttributes);
+ TypeAttributes attributes = declaration.TypeAttributes;
+ OutputTypeAttributes (attributes,
+ declaration.IsStruct,
+ declaration.IsEnum);
+
+ output.WriteLine (declaration.Name);
+
+ ++Indent;
+
+ IEnumerator enumerator = declaration.BaseTypes.GetEnumerator();
+ if (enumerator.MoveNext())
+ {
+ CodeTypeReference type = (CodeTypeReference)enumerator.Current;
+
+ if (type != null)
+ {
+ output.Write ("Inherits ");
+ OutputType (type);
+ output.WriteLine ();
+ }
+
+ while (enumerator.MoveNext())
+ {
+ type = (CodeTypeReference)enumerator.Current;
+
+ if (type != null)
+ {
+ output.Write ("Implements ");
+ OutputType (type);
+ output.WriteLine ();
+ }
+ }
+ }
+ }
+
+ protected override void GenerateTypeEnd (CodeTypeDeclaration declaration)
+ {
+ string output = string.Empty;
+
+ --Indent;
+ if (declaration.IsStruct)
+ output = "End Structure";
+ if (declaration.IsInterface)
+ output = "End Interface";
+ if (declaration.IsEnum)
+ output = "End Enum";
+ if (declaration.IsClass)
+ output = "End Class";
+
+ Output.WriteLine (output);
+ }
+
+ protected override void GenerateNamespace(CodeNamespace ns)
+ {
+ GenerateCommentStatements (ns.Comments);
+
+ bool Imports2MSVBFound;
+ Imports2MSVBFound = false;
+ if (null != ns.Imports)
+ {
+ foreach (CodeNamespaceImport import in ns.Imports)
+ {
+ if (string.Compare (import.Namespace, "Microsoft.VisualBasic", true, System.Globalization.CultureInfo.InvariantCulture) == 0)
+ Imports2MSVBFound = true;
+ }
+ }
+ // add standard import to Microsoft.VisualBasic if missing
+ if (Imports2MSVBFound == false)
+ Output.WriteLine ("Imports Microsoft.VisualBasic");
+ // add regular imports
+ GenerateNamespaceImports (ns);
+
+ TextWriter output = Output;
+ output.WriteLine();
+ GenerateNamespaceStart (ns);
+ GenerateTypes (ns);
+ GenerateNamespaceEnd (ns);
+ }
+
+
+ protected override void GenerateNamespaceStart (CodeNamespace ns)
+ {
+ TextWriter output = Output;
+
+ string name = ns.Name;
+ if (name != null && name != string.Empty) {
+ output.Write ("Namespace ");
+ output.WriteLine (name);
+ ++Indent;
+ }
+ }
+
+ protected override void GenerateNamespaceEnd (CodeNamespace ns)
+ {
+ string name = ns.Name;
+ if (name != null && name != string.Empty) {
+ --Indent;
+ Output.WriteLine ("End Namespace");
+ }
+ }
+
+ protected override void GenerateNamespaceImport (CodeNamespaceImport import)
+ {
+ TextWriter output = Output;
+
+ output.Write ("Imports ");
+ output.Write (import.Namespace);
+ output.WriteLine ();
+ }
+
+ protected override void GenerateAttributeDeclarationsStart (CodeAttributeDeclarationCollection attributes)
+ {
+ Output.Write ('<');
+ }
+
+ protected override void GenerateAttributeDeclarationsEnd (CodeAttributeDeclarationCollection attributes)
+ {
+ Output.WriteLine ('>');
+ }
+
+ protected override void OutputDirection (FieldDirection direction)
+ {
+ switch (direction) {
+ case FieldDirection.In:
+ //there is no "In"
+ break;
+ case FieldDirection.Out:
+ Output.Write ("ByVal ");
+ break;
+ case FieldDirection.Ref:
+ Output.Write ("ByRef ");
+ break;
+ }
+ }
+
+ protected override void OutputFieldScopeModifier (MemberAttributes attributes)
+ {
+ if ((attributes & MemberAttributes.VTableMask) == MemberAttributes.New)
+ Output.Write ("New ");
+
+ switch (attributes & MemberAttributes.ScopeMask) {
+ case MemberAttributes.Static:
+ Output.Write ("Shared ");
+ break;
+ case MemberAttributes.Const:
+ Output.Write ("Const ");
+ break;
+ }
+ }
+
+ protected override void OutputMemberAccessModifier (MemberAttributes attributes)
+ {
+ switch (attributes & MemberAttributes.AccessMask) {
+ case MemberAttributes.Assembly:
+ Output.Write ("Friend ");
+ break;
+ case MemberAttributes.FamilyAndAssembly:
+ Output.Write ("Friend ");
+ break;
+ case MemberAttributes.Family:
+ Output.Write ("Protected ");
+ break;
+ case MemberAttributes.FamilyOrAssembly:
+ Output.Write ("Protected Friend ");
+ break;
+ case MemberAttributes.Private:
+ Output.Write ("Private ");
+ break;
+ case MemberAttributes.Public:
+ Output.Write ("Public ");
+ break;
+ }
+ }
+
+ protected override void OutputMemberScopeModifier (MemberAttributes attributes)
+ {
+ if ((attributes & MemberAttributes.VTableMask) == MemberAttributes.New)
+ Output.Write ("New ");
+
+ switch (attributes & MemberAttributes.ScopeMask) {
+ case MemberAttributes.Abstract:
+ Output.Write ("MustOverride ");
+ break;
+ case MemberAttributes.Final:
+ Output.Write ("NotOverridable ");
+ break;
+ case MemberAttributes.Static:
+ Output.Write ("Shared ");
+ break;
+ case MemberAttributes.Override:
+ Output.Write ("Overrides ");
+ break;
+ default:
+ //
+ // FUNNY! if the scope value is
+ // rubbish (0 or >Const), and access
+ // is public or protected, make it
+ // "virtual".
+ //
+ // i'm not sure whether this is 100%
+ // correct, but it seems to be MS
+ // behavior.
+ //
+ MemberAttributes access = attributes & MemberAttributes.AccessMask;
+ if ( access == MemberAttributes.Public ||
+ access == MemberAttributes.Family )
+ Output.Write ("Overridable ");
+ break;
+ }
+ }
+
+ protected override void OutputOperator (CodeBinaryOperatorType op)
+ {
+ switch (op) {
+ case CodeBinaryOperatorType.Add:
+ Output.Write ("+");
+ break;
+ case CodeBinaryOperatorType.Subtract:
+ Output.Write ("-");
+ break;
+ case CodeBinaryOperatorType.Multiply:
+ Output.Write ("*");
+ break;
+ case CodeBinaryOperatorType.Divide:
+ Output.Write ("/");
+ break;
+ case CodeBinaryOperatorType.Modulus:
+ Output.Write ("Mod");
+ break;
+ case CodeBinaryOperatorType.Assign:
+ Output.Write ("=");
+ break;
+ case CodeBinaryOperatorType.IdentityInequality:
+ Output.Write ("<>");
+ break;
+ case CodeBinaryOperatorType.IdentityEquality:
+ Output.Write ("Is");
+ break;
+ case CodeBinaryOperatorType.ValueEquality:
+ Output.Write ("=");
+ break;
+ case CodeBinaryOperatorType.BitwiseOr:
+ Output.Write ("Or");
+ break;
+ case CodeBinaryOperatorType.BitwiseAnd:
+ Output.Write ("And");
+ break;
+ case CodeBinaryOperatorType.BooleanOr:
+ Output.Write ("OrElse");
+ break;
+ case CodeBinaryOperatorType.BooleanAnd:
+ Output.Write ("AndAlso");
+ break;
+ case CodeBinaryOperatorType.LessThan:
+ Output.Write ("<");
+ break;
+ case CodeBinaryOperatorType.LessThanOrEqual:
+ Output.Write ("<=");
+ break;
+ case CodeBinaryOperatorType.GreaterThan:
+ Output.Write (">");
+ break;
+ case CodeBinaryOperatorType.GreaterThanOrEqual:
+ Output.Write (">=");
+ break;
+ }
+ }
+
+ protected override void OutputTypeAttributes (TypeAttributes attributes, bool isStruct, bool isEnum)
+ {
+ TextWriter output = Output;
+
+ switch (attributes & TypeAttributes.VisibilityMask) {
+ case TypeAttributes.NotPublic:
+ // Does this mean friend access?
+ output.Write ("Friend ");
+ break;
+
+ case TypeAttributes.Public:
+ case TypeAttributes.NestedPublic:
+ output.Write ("Public ");
+ break;
+
+ case TypeAttributes.NestedPrivate:
+ output.Write ("Private ");
+ break;
+ case TypeAttributes.NestedAssembly:
+ output.Write ("Friend ");
+ break;
+ case TypeAttributes.NestedFamily:
+ output.Write ("Protected ");
+ break;
+ case TypeAttributes.NestedFamORAssem:
+ output.Write ("Protected Friend ");
+ break;
+ case TypeAttributes.NestedFamANDAssem:
+ output.Write ("Friend ");
+ break;
+ }
+
+ if (isStruct)
+ output.Write ("Structure ");
+
+ else if (isEnum)
+ output.Write ("Enumeration ");
+
+ else {
+ if ((attributes & TypeAttributes.Interface) != 0)
+ output.Write ("Interface ");
+
+ else {
+ if ((attributes & TypeAttributes.Sealed) != 0)
+ output.Write ("NotInheritable ");
+
+ if ((attributes & TypeAttributes.Abstract) != 0)
+ output.Write ("MustInherit ");
+
+ output.Write ("Class ");
+ }
+ }
+ }
+
+ protected override void OutputTypeNamePair (CodeTypeReference typeRef, String name)
+ {
+ Output.Write (name + " As " + GetTypeOutput (typeRef));
+ }
+
+ protected override void OutputType (CodeTypeReference type)
+ {
+ Output.Write (GetTypeOutput (type));
+ }
+
+ protected override string QuoteSnippetString (string value)
+ {
+ StringBuilder mySBuilder = new StringBuilder(value.Length);
+ mySBuilder.Append ("\"");
+ bool inQuotes = true;
+ for (int MyCounter = 0; MyCounter < value.Length; MyCounter++)
+ {
+ if (value[MyCounter] == 34) //quotation mark
+ {
+ if (!inQuotes)
+ {
+ mySBuilder.Append ("&\"");
+ inQuotes = true;
+ }
+ mySBuilder.Append (value[MyCounter]);
+ mySBuilder.Append (value[MyCounter]);
+ }
+ else if (value[MyCounter] >= 32) //standard ansi/unicode characters
+ {
+ if (!inQuotes)
+ {
+ mySBuilder.Append ("&\"");
+ inQuotes = true;
+ }
+ mySBuilder.Append (value[MyCounter]);
+ }
+ else //special chars, e.g. line break
+ {
+ if (inQuotes)
+ {
+ mySBuilder.Append ("\"");
+ inQuotes = false;
+ }
+ mySBuilder.Append ("&Microsoft.VisualBasic.ChrW(");
+ mySBuilder.Append ((int)value[MyCounter]);
+ mySBuilder.Append (")");
+ }
+ }
+ if (inQuotes)
+ mySBuilder.Append ("\"");
+ return mySBuilder.ToString();
+ }
+
+ private void GenerateDeclaration (CodeTypeReference type, string name, CodeExpression initExpression)
+ {
+ TextWriter output = Output;
+
+ OutputTypeNamePair (type, name);
+
+ if (initExpression != null) {
+ output.Write (" = ");
+ GenerateExpression (initExpression);
+ }
+
+ output.WriteLine ();
+ }
+
+ private void GenerateMemberReferenceExpression (CodeExpression targetObject, string memberName)
+ {
+ GenerateExpression (targetObject);
+ Output.Write ('.');
+ Output.Write (memberName);
+ }
+
+ /*
+ * ICodeGenerator
+ */
+
+ protected override string CreateEscapedIdentifier (string value)
+ {
+ for (int x = 0; x < Keywords.Length; x++)
+ if (value.ToLower().Equals (Keywords[x].ToLower()))
+ return "[" + value + "]";
+ return value;
+ }
+
+ protected override string CreateValidIdentifier (string value)
+ {
+ for (int x = 0; x < Keywords.Length; x++)
+ if (value.ToLower().Equals (Keywords[x].ToLower()))
+ return "_" + value;
+ return value;
+ }
+
+ protected override string GetTypeOutput (CodeTypeReference type)
+ {
+ string output;
+ CodeTypeReference arrayType;
+
+ arrayType = type.ArrayElementType;
+ if (arrayType != null)
+ output = GetTypeOutput (arrayType);
+ else {
+ switch (type.BaseType) {
+
+ case "System.Decimal":
+ output = "Decimal";
+ break;
+ case "System.Double":
+ output = "Double";
+ break;
+ case "System.Single":
+ output = "Single";
+ break;
+
+ case "System.Byte":
+ output = "Byte";
+ break;
+ case "System.SByte":
+ output = "SByte";
+ break;
+ case "System.Int32":
+ output = "Integer";
+ break;
+ case "System.UInt32":
+ output = "UInt32";
+ break;
+ case "System.Int64":
+ output = "Long";
+ break;
+ case "System.UInt64":
+ output = "UInt64";
+ break;
+ case "System.Int16":
+ output = "Short";
+ break;
+ case "System.UInt16":
+ output = "UInt16";
+ break;
+
+ case "System.Boolean":
+ output = "Boolean";
+ break;
+
+ case "System.Char":
+ output = "Char";
+ break;
+
+ case "System.String":
+ output = "String";
+ break;
+ case "System.Object":
+ output = "Object";
+ break;
+
+ case "System.Void":
+ output = "Nothing";
+ break;
+
+ default:
+ output = type.BaseType;
+ break;
+ }
+ }
+
+ int rank = type.ArrayRank;
+ if (rank > 0) {
+ output += "(";
+ for (--rank; rank > 0; --rank)
+ output += ",";
+ output += ")";
+ }
+
+ return output;
+ }
+
+ protected override bool IsValidIdentifier (string identifier)
+ {
+ for (int x = 0; x < Keywords.Length; x++)
+ if (identifier.ToLower().Equals (Keywords[x].ToLower()))
+ return false;
+ return true;
+ }
+
+ protected override bool Supports (GeneratorSupport supports)
+ {
+ return true;
+ }
+ }
+}
diff --git a/mcs/class/System/Microsoft.Win32/ChangeLog b/mcs/class/System/Microsoft.Win32/ChangeLog
index 166c27d2a89..ff621c1f43e 100644
--- a/mcs/class/System/Microsoft.Win32/ChangeLog
+++ b/mcs/class/System/Microsoft.Win32/ChangeLog
@@ -1,37 +1,33 @@
+2003-11-12 Andreas Nahr <ClassDevelopment@A-SoftTech.com>
+
+ * TimerElapsedEventArgs.cs: Added missing Attribute, restyled
+
2003-07-10 Andreas Nahr <ClassDevelopment@A-SoftTech.com>
* SystemEvents.cs: Implemented preliminary timer support, added private constructor, fixed events
-2003-06-12 Duncan Mak <duncan@ximian.com>
-
- * UserPreferenceChangedEventArgs.cs
- * UserPreferenceChangingEventArgs.cs
- (Category): Fixed typo. Patch from Andreas. Nahr.
- (ClassDevelopment@A-SoftTech.com>.
-
-2003-04-17 Nick Drochak <ndrochak@gol.com>
-
- * UserPreferenceCategory.cs: Fix typo.
- * SystemEvents.cs: Fix inheritance.
-
-2002-9-15 Johannes Roith <johannes@jroith.de>
-
- * ChangeLog: Add the change log to this directory
-
- * PowerModeChangedEventArgs.cs
- * PowerModeChangedEventHandler.cs
- * PowerModes.cs
- * SessionEndedEventArgs.cs
- * SessionEndedEventHandler.cs
- * SessionEndingEventArgs.cs
- * SessionEndingEventHandler.cs
- * SessionEndReasons.cs
- * SystemEvents.cs
- * TimerElapsedEventArgs.cs
- * TimerElapsedEventHandler.cs
- * UserPreferenceCategory.cs
- * UserPreferenceChangedEventArgs.cs
- * UserPreferenceChangedEventHandler.cs
- * UserPreferenceChangingEventArgs.cs
- * UserPreferenceChangingEventHandler.cs:
- Initial import.
+2003-06-12 Duncan Mak <duncan@ximian.com>
+ * UserPreferenceChangedEventArgs.cs
+ * UserPreferenceChangingEventArgs.cs
+ (Category): Fixed typo. Patch from Andreas. Nahr.
+ (ClassDevelopment@A-SoftTech.com>.
+2003-04-17 Nick Drochak <ndrochak@gol.com>
+ * UserPreferenceCategory.cs: Fix typo.
+ * SystemEvents.cs: Fix inheritance.2002-9-15 Johannes Roith <johannes@jroith.de>
+ * ChangeLog: Add the change log to this directory
+ * PowerModeChangedEventArgs.cs
+ * PowerModeChangedEventHandler.cs
+ * PowerModes.cs * SessionEndedEventArgs.cs
+ * SessionEndedEventHandler.cs
+ * SessionEndingEventArgs.cs
+ * SessionEndingEventHandler.cs
+ * SessionEndReasons.cs
+ * SystemEvents.cs
+ * TimerElapsedEventArgs.cs
+ * TimerElapsedEventHandler.cs
+ * UserPreferenceCategory.cs
+ * UserPreferenceChangedEventArgs.cs
+ * UserPreferenceChangedEventHandler.cs
+ * UserPreferenceChangingEventArgs.cs
+ * UserPreferenceChangingEventHandler.cs:
+ Initial import. \ No newline at end of file
diff --git a/mcs/class/System/Microsoft.Win32/TimerElapsedEventArgs.cs b/mcs/class/System/Microsoft.Win32/TimerElapsedEventArgs.cs
index a44c8eecee7..1a4e10a35c6 100644
--- a/mcs/class/System/Microsoft.Win32/TimerElapsedEventArgs.cs
+++ b/mcs/class/System/Microsoft.Win32/TimerElapsedEventArgs.cs
@@ -1,33 +1,31 @@
-//
-// TimerElapsedEventArgs.cs
-//
-// Author:
-// Johannes Roith (johannes@jroith.de)
-//
-// (C) 2002 Johannes Roith
-//
-namespace Microsoft.Win32 {
-
- /// <summary>
- /// </summary>
-public class TimerElapsedEventArgs : System.EventArgs{
-
- System.IntPtr mytimerId;
-
-
- public TimerElapsedEventArgs(System.IntPtr timerId)
- {
- this.mytimerId = timerId;
- }
-
- public System.IntPtr TimerId {
-
- get{
- return mytimerId;
- }
-
- }
-
-}
-
-}
+//
+// TimerElapsedEventArgs.cs
+//
+// Authors:
+// Johannes Roith (johannes@jroith.de)
+// Andreas Nahr (ClassDevelopment@A-SoftTech.com)
+//
+// (C) 2002 Johannes Roith
+//
+
+using System.Runtime.InteropServices;
+
+namespace Microsoft.Win32
+{
+ [ComVisible(false)]
+ public class TimerElapsedEventArgs : System.EventArgs
+ {
+ System.IntPtr mytimerId;
+
+ public TimerElapsedEventArgs (System.IntPtr timerId)
+ {
+ this.mytimerId = timerId;
+ }
+
+ public System.IntPtr TimerId {
+ get {
+ return mytimerId;
+ }
+ }
+ }
+}
diff --git a/mcs/class/System/System.CodeDom.Compiler/ChangeLog b/mcs/class/System/System.CodeDom.Compiler/ChangeLog
index 83df61e92e9..f71ce4ca08b 100755
--- a/mcs/class/System/System.CodeDom.Compiler/ChangeLog
+++ b/mcs/class/System/System.CodeDom.Compiler/ChangeLog
@@ -1,7 +1,11 @@
+2003-11-21 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * CodeGenerator.cs: fixed assembly level attribute generation.
+
2003-08-08 Lluis Sanchez Gual <lluis@ximian.com>
- * CodeGenerator.cs: When sorting the members of a type, keep the relative
- order of the members of the same kind.
+ * CodeGenerator.cs: When sorting the members of a type, keep the
+ relative order of the members of the same kind.
2003-08-05 Lluis Sanchez Gual <lluis@ximian.com>
diff --git a/mcs/class/System/System.CodeDom.Compiler/CodeGenerator.cs b/mcs/class/System/System.CodeDom.Compiler/CodeGenerator.cs
index d8b7cf95642..aed571cc4c6 100755
--- a/mcs/class/System/System.CodeDom.Compiler/CodeGenerator.cs
+++ b/mcs/class/System/System.CodeDom.Compiler/CodeGenerator.cs
@@ -172,10 +172,12 @@ namespace System.CodeDom.Compiler {
CodeAttributeDeclarationCollection attributes = compileUnit.AssemblyCustomAttributes;
if (attributes.Count != 0) {
- GenerateAttributeDeclarationsStart (attributes);
- output.Write ("assembly: ");
- OutputAttributeDeclarations (compileUnit.AssemblyCustomAttributes);
- GenerateAttributeDeclarationsEnd (attributes);
+ foreach (CodeAttributeDeclaration att in attributes) {
+ GenerateAttributeDeclarationsStart (attributes);
+ output.Write ("assembly: ");
+ OutputAttributeDeclaration (att);
+ GenerateAttributeDeclarationsEnd (attributes);
+ }
}
foreach (CodeNamespace ns in compileUnit.Namespaces)
diff --git a/mcs/class/System/System.Collections.Specialized/ChangeLog b/mcs/class/System/System.Collections.Specialized/ChangeLog
index 8db4fa8645a..c2f2bcaafc5 100755
--- a/mcs/class/System/System.Collections.Specialized/ChangeLog
+++ b/mcs/class/System/System.Collections.Specialized/ChangeLog
@@ -1,3 +1,7 @@
+2003-11-18 Todd Berman <tberman@gentoo.org>
+
+ * IOrderedDictionary.cs: new v2 interface
+
2003-10-21 Gonzalo Paniagua Javier <gonzalo@ximian.com>
* NameObjectCollectionBase.cs: added serialization support.
diff --git a/mcs/class/System/System.Collections.Specialized/IOrderedDictionary.cs b/mcs/class/System/System.Collections.Specialized/IOrderedDictionary.cs
new file mode 100644
index 00000000000..afc9f334d77
--- /dev/null
+++ b/mcs/class/System/System.Collections.Specialized/IOrderedDictionary.cs
@@ -0,0 +1,23 @@
+//
+// System.Collections.Specialized/IOrderedDictionary.cs
+//
+// Author: Todd Berman <tberman@gentoo.org>
+//
+// (C) 2003 Todd Berman
+
+#if NET_1_2
+
+namespace System.Collections.Specialized
+{
+ public interface IOrderedDictionary : IDictionary
+ {
+ void Insert (int idx, object key, object value);
+ void RemoveAt (int idx);
+
+ object this[int idx] {
+ get; set;
+ }
+ }
+}
+
+#endif
diff --git a/mcs/class/System/System.ComponentModel/ChangeLog b/mcs/class/System/System.ComponentModel/ChangeLog
index 21777a6e411..572e5b319b4 100644
--- a/mcs/class/System/System.ComponentModel/ChangeLog
+++ b/mcs/class/System/System.ComponentModel/ChangeLog
@@ -1,3 +1,17 @@
+2003-11-22 Miguel de Icaza <miguel@ximian.com>
+
+ * PropertyDescriptorCollection.cs (Insert): Another one.
+
+ * PropertyTabAttribute.cs (Equals): Avoid recurssion
+
+2003-11-13 Andreas Nahr <ClassDevelopment@A-SoftTech.com>
+
+ * IComponent.cs: Added missing attribute
+
+2003-11-12 Andreas Nahr <ClassDevelopment@A-SoftTech.com>
+
+ * ComponentResourceManager.cs: Added and partially implemented
+
2003-09-13 Duncan Mak <duncan@ximian.com>
Patch from Jörg Rosenkranz <joergr@voelcker.com>, this fixes the
diff --git a/mcs/class/System/System.ComponentModel/ComponentResourceManager.cs b/mcs/class/System/System.ComponentModel/ComponentResourceManager.cs
new file mode 100644
index 00000000000..ee090ae6760
--- /dev/null
+++ b/mcs/class/System/System.ComponentModel/ComponentResourceManager.cs
@@ -0,0 +1,42 @@
+//
+// System.ComponentModel.ComponentResourceManager.cs
+//
+// Author:
+// Andreas Nahr (ClassDevelopment@A-SoftTech.com)
+//
+// (C) 2003 Andreas Nahr
+//
+//
+
+#if NET_1_1
+
+using System.Resources;
+using System.Globalization;
+
+namespace System.ComponentModel {
+
+ public class ComponentResourceManager : ResourceManager
+ {
+ public ComponentResourceManager ()
+ {
+ }
+
+ public ComponentResourceManager (Type t)
+ : base (t)
+ {
+ }
+
+ public void ApplyResources (object value, string objectName)
+ {
+ ApplyResources (value, objectName, null);
+ }
+
+ [MonoTODO("Implement")]
+ public virtual void ApplyResources (object value, string objectName, CultureInfo culture)
+ {
+ throw new NotImplementedException ();
+ }
+ }
+}
+
+#endif
diff --git a/mcs/class/System/System.ComponentModel/IComponent.cs b/mcs/class/System/System.ComponentModel/IComponent.cs
index e430196a884..3a42fe2be14 100644
--- a/mcs/class/System/System.ComponentModel/IComponent.cs
+++ b/mcs/class/System/System.ComponentModel/IComponent.cs
@@ -17,6 +17,7 @@ using System.ComponentModel.Design.Serialization;
namespace System.ComponentModel
{
[ComVisible (true), TypeConverter (typeof (System.ComponentModel.ComponentConverter))]
+ [Designer ("System.Windows.Forms.Design.ComponentDocumentDesigner, " + Consts.AssemblySystem_Design, typeof (IDesigner))]
[Designer ("System.Windows.Forms.Design.ComponentDocumentDesigner, " + Consts.AssemblySystem_Design, typeof (IRootDesigner))]
[RootDesignerSerializer ("System.ComponentModel.Design.Serialization.RootCodeDomSerializer, " + Consts.AssemblySystem_Design, "System.ComponentModel.Design.Serialization.CodeDomSerializer, " + Consts.AssemblySystem_Design, true)]
public interface IComponent : IDisposable
diff --git a/mcs/class/System/System.ComponentModel/PropertyDescriptorCollection.cs b/mcs/class/System/System.ComponentModel/PropertyDescriptorCollection.cs
index 6962cfe79e1..0bc8e330a14 100644
--- a/mcs/class/System/System.ComponentModel/PropertyDescriptorCollection.cs
+++ b/mcs/class/System/System.ComponentModel/PropertyDescriptorCollection.cs
@@ -114,7 +114,8 @@ namespace System.ComponentModel
}
public void Insert (int index, PropertyDescriptor value)
- { Insert (index, value);
+ {
+ properties.Insert (index, value);
}
void IList.Insert (int index, object value)
diff --git a/mcs/class/System/System.ComponentModel/PropertyTabAttribute.cs b/mcs/class/System/System.ComponentModel/PropertyTabAttribute.cs
index bbc8056de17..b1da465fd1d 100644
--- a/mcs/class/System/System.ComponentModel/PropertyTabAttribute.cs
+++ b/mcs/class/System/System.ComponentModel/PropertyTabAttribute.cs
@@ -71,7 +71,7 @@ namespace System.ComponentModel
public bool Equals (PropertyTabAttribute other)
{
- return this.Equals (other);
+ return this.Equals ((object) other);
}
public override int GetHashCode()
diff --git a/mcs/class/System/System.Configuration/ChangeLog b/mcs/class/System/System.Configuration/ChangeLog
index 1f09efee6e0..25573cca945 100644
--- a/mcs/class/System/System.Configuration/ChangeLog
+++ b/mcs/class/System/System.Configuration/ChangeLog
@@ -1,3 +1,10 @@
+2003-11-17 Ben Maurer <bmaurer@users.sourceforge.net>
+
+ * ConfigurationSettings.cs: make the *Mark objects static
+ because they need to be comparable across instances.
+ (ReadSectionGroup): You can add an element to a group declared
+ in the parent config files (MS.net's QuickStarts do this).
+
2003-11-06 Gonzalo Paniagua Javier <gonzalo@ximian.com>
* ConfigurationSettings.cs: don't handle null or non-existent file in
diff --git a/mcs/class/System/System.Configuration/ConfigurationSettings.cs b/mcs/class/System/System.Configuration/ConfigurationSettings.cs
index c134f36f223..a418b3e27f9 100644
--- a/mcs/class/System/System.Configuration/ConfigurationSettings.cs
+++ b/mcs/class/System/System.Configuration/ConfigurationSettings.cs
@@ -185,9 +185,9 @@ namespace System.Configuration
ConfigurationData parent;
Hashtable factories;
string fileName;
- object removedMark = new object ();
- object groupMark = new object ();
- object emptyMark = new object ();
+ static object removedMark = new object ();
+ static object groupMark = new object ();
+ static object emptyMark = new object ();
FileWatcherCache fileCache = null;
private FileWatcherCache FileCache {
@@ -474,7 +474,7 @@ namespace System.Configuration
value = configSection + '/' + value;
object o = LookForFactory (value);
- if (o != null && o != removedMark)
+ if (o != null && o != removedMark && o != groupMark)
ThrowException ("Already have a factory for " + value, reader);
factories [value] = groupMark;
diff --git a/mcs/class/System/System.Diagnostics/ChangeLog b/mcs/class/System/System.Diagnostics/ChangeLog
index 5b58888db0b..77f86bd298b 100644
--- a/mcs/class/System/System.Diagnostics/ChangeLog
+++ b/mcs/class/System/System.Diagnostics/ChangeLog
@@ -1,3 +1,11 @@
+2003-11-13 Andreas Nahr <ClassDevelopment@A-SoftTech.com>
+
+ * ICollectData.cs: Fixed signature
+
+2003-11-12 Andreas Nahr <ClassDevelopment@A-SoftTech.com>
+
+ * ICollectData.cs: Added missing attribute
+
2003-07-27 Andreas Nahr <ClassDevelopment@A-SoftTech.com>
* SRDescriptionAttribute.cs: Moved to System directory
@@ -311,34 +319,31 @@
support
* DefaultTraceListener.cs: new file; the default trace listener
-2002-01-17 Miguel de Icaza <miguel@ximian.com>
-
- * TraceListenerCollection.cs: Remove Warnings.
-
-2002-01-06 Ravi Pratap <ravi@ximian.com>
-
- * Switch.cs, TraceListenerCollection.cs : Decorate incomplete bits
- with the MonoTODO attribute.
-
-2002-01-04 John R. Hicks <angryjohn69@nc.rr.com>
- * Added Debug.cs to the build.
-2002-01-04 John R. Hicks <angryjohn69@nc.rr.com>
- * Added preliminary TraceListenerCollection.cs to the build.
-2002-01-04 John R. Hicks <angryjohn69@nc.rr.com>
- * Added TraceListener.cs, TextWriterTraceListener.cs, and
- DefaultTraceListener.cs to the build and moved them into the
- proper assembly.
-2002-01-04 John R. Hicks <angryjohn69@nc.rr.com>
- * Added DiagnosticsConfigurationHandler.cs to the build.
-
-2001-09-09 Nick Drochak <ndrochak@gol.com>
-
- * BooleanSwitch.cs: Make this class use it's parent class's features. Namely, use SwitchSetting
- so that we can get OnSwitchSettingChanged() to fire for free.
-
-2001-09-09 Nick Drochak <ndrochak@gol.com>
-
- * ChangeLog: added this file
-
- * Switch.cs: call OnSwitchSettingChanged() when the switch setting is, yes you gessed it, changed.
-
+2002-01-17 Miguel de Icaza <miguel@ximian.com>
+ * TraceListenerCollection.cs: Remove Warnings.
+
+2002-01-06 Ravi Pratap <ravi@ximian.com>
+ * Switch.cs, TraceListenerCollection.cs : Decorate incomplete bits
+ with the MonoTODO attribute.
+
+2002-01-04 John R. Hicks <angryjohn69@nc.rr.com>
+ * Added Debug.cs to the build.
+
+2002-01-04 John R. Hicks <angryjohn69@nc.rr.com>
+ * Added preliminary TraceListenerCollection.cs to the build.
+
+2002-01-04 John R. Hicks <angryjohn69@nc.rr.com>
+ * Added TraceListener.cs, TextWriterTraceListener.cs, and
+ DefaultTraceListener.cs to the build and moved them into the
+ proper assembly.
+
+2002-01-04 John R. Hicks <angryjohn69@nc.rr.com>
+ * Added DiagnosticsConfigurationHandler.cs to the build.
+
+2001-09-09 Nick Drochak <ndrochak@gol.com>
+ * BooleanSwitch.cs: Make this class use it's parent class's features. Namely, use SwitchSetting
+ so that we can get OnSwitchSettingChanged() to fire for free.
+
+2001-09-09 Nick Drochak <ndrochak@gol.com>
+ * ChangeLog: added this file
+ * Switch.cs: call OnSwitchSettingChanged() when the switch setting is, yes you gessed it, changed. \ No newline at end of file
diff --git a/mcs/class/System/System.Diagnostics/ICollectData.cs b/mcs/class/System/System.Diagnostics/ICollectData.cs
index 8ed58307627..ff7fe82eac7 100644
--- a/mcs/class/System/System.Diagnostics/ICollectData.cs
+++ b/mcs/class/System/System.Diagnostics/ICollectData.cs
@@ -11,16 +11,17 @@ using System;
using System.Diagnostics;
using System.Runtime.InteropServices;
-namespace System.Diagnostics {
+namespace System.Diagnostics
+{
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
+ [Guid("73386977-D6FD-11D2-BED5-00C04F79E3AE")]
public interface ICollectData {
void CloseData ();
void CollectData (
- int id,
- IntPtr valueName,
- IntPtr data,
- int totalBytes,
+ [In] int id,
+ [In] IntPtr valueName,
+ [In] IntPtr data,
+ [In] int totalBytes,
out IntPtr res);
}
}
-
diff --git a/mcs/class/System/System.Net/ChangeLog b/mcs/class/System/System.Net/ChangeLog
index 6b0fccfb870..04cf247755b 100644
--- a/mcs/class/System/System.Net/ChangeLog
+++ b/mcs/class/System/System.Net/ChangeLog
@@ -1,3 +1,37 @@
+2003-11-27 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * HttpWebRequest.cs: removed unneeded StringBuilder.
+ * WebConnection.cs: default to keep the connection open for HTTP/1.1
+ only or HTTP/1.0 + (Proxy-)Connection header. Fixes bug #51208.
+
+2003-11-17 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * WebConnection.cs: turns out that socket.Connected is not useful until
+ we actually try to send/receive data, even if the other end has already
+ closed the socket. Added TryReconnect() and Connected.
+
+ * WebConnectionData.cs: default value for StatusCode is 0 now.
+
+ * WebConnectionGroup.cs: reuse the connection since the beginning,
+ instead of opening up to ConnectionLimit and then reusing.
+
+ * WebConnectionStream.cs: reopen the socket if we're trying to reuse
+ one which fails on first write.
+
+2003-11-14 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * WebConnectionStream.cs: when a callback is passed to BeginRead/Write,
+ wrap it and do our job before calling it. Fixes bug #48497.
+
+2003-11-12 Andreas Nahr <ClassDevelopment@A-SoftTech.com>
+
+ * WebExceptionStatus.cs: Restyled, Added .Net 1.1 members
+ * SecurityProtocolType.cs: Added and implemented
+
+2003-11-12 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * HttpWebRequest.cs: fixed redirects when they target another host.
+
2003-11-06 Gonzalo Paniagua Javier <gonzalo@ximian.com>
* IPAddress.cs: prevent exceptions when trying to parse the static IPv6
diff --git a/mcs/class/System/System.Net/HttpWebRequest.cs b/mcs/class/System/System.Net/HttpWebRequest.cs
index efec581ce94..4a9e36ab503 100644
--- a/mcs/class/System/System.Net/HttpWebRequest.cs
+++ b/mcs/class/System/System.Net/HttpWebRequest.cs
@@ -26,6 +26,7 @@ namespace System.Net
{
Uri requestUri;
Uri actualUri;
+ bool hostChanged;
bool allowAutoRedirect = true;
bool allowBuffering = true;
X509CertificateCollection certificates;
@@ -427,12 +428,14 @@ namespace System.Net
internal ServicePoint GetServicePoint ()
{
- if (servicePoint != null)
+ if (!hostChanged && servicePoint != null)
return servicePoint;
lock (this) {
- if (servicePoint == null)
+ if (hostChanged || servicePoint == null) {
servicePoint = ServicePointManager.FindServicePoint (actualUri, proxy);
+ hostChanged = false;
+ }
}
return servicePoint;
@@ -759,13 +762,14 @@ namespace System.Net
if (e != null)
throw e;
+ string host = actualUri.Host;
actualUri = new Uri (uriString);
+ hostChanged = (actualUri.Host != host);
return true;
}
string GetHeaders ()
{
- StringBuilder result = new StringBuilder ();
bool continue100 = false;
if (gotRequestStream && contentLength != -1) {
continue100 = true;
diff --git a/mcs/class/System/System.Net/SecurityProtocolType.cs b/mcs/class/System/System.Net/SecurityProtocolType.cs
new file mode 100644
index 00000000000..981bca25b76
--- /dev/null
+++ b/mcs/class/System/System.Net/SecurityProtocolType.cs
@@ -0,0 +1,20 @@
+//
+// System.Net.SecurityProtocolType.cs
+//
+// Author:
+// Andreas Nahr (ClassDevelopment@A-SoftTech.com)
+//
+
+#if NET_1_1
+
+namespace System.Net
+{
+ [Flags]
+ public enum SecurityProtocolType
+ {
+ Ssl3 = 48,
+ Tls = 192
+ }
+}
+
+#endif \ No newline at end of file
diff --git a/mcs/class/System/System.Net/WebConnection.cs b/mcs/class/System/System.Net/WebConnection.cs
index ffe2c079cc5..e9f96d68673 100644
--- a/mcs/class/System/System.Net/WebConnection.cs
+++ b/mcs/class/System/System.Net/WebConnection.cs
@@ -45,6 +45,7 @@ namespace System.Net
AutoResetEvent goAhead;
bool waitingForContinue;
Queue queue;
+ bool reused;
public WebConnection (WebConnectionGroup group, ServicePoint sPoint)
{
@@ -61,41 +62,39 @@ namespace System.Net
public void Connect ()
{
- if (socket != null && socket.Connected && status == WebExceptionStatus.Success)
- return;
-
lock (this) {
- if (socket != null && socket.Connected && status == WebExceptionStatus.Success)
+ if (socket != null && socket.Connected && status == WebExceptionStatus.Success) {
+ reused = true;
return;
+ }
+ reused = false;
if (socket != null) {
socket.Close();
socket = null;
}
+ chunkStream = null;
IPHostEntry hostEntry = sPoint.HostEntry;
- if(hostEntry == null) {
+ if (hostEntry == null) {
status = sPoint.UsesProxy ? WebExceptionStatus.ProxyNameResolutionFailure :
WebExceptionStatus.NameResolutionFailure;
- socket.Close();
- socket = null;
- } else {
- foreach(IPAddress address in hostEntry.AddressList) {
- socket = new Socket (address.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
- try {
- socket.Connect (new IPEndPoint(address, sPoint.Address.Port));
- status = WebExceptionStatus.Success;
- break;
- } catch (SocketException) {
- socket.Close();
- socket = null;
- status = WebExceptionStatus.ConnectFailure;
- }
- }
+ return;
}
- chunkStream = null;
+ foreach (IPAddress address in hostEntry.AddressList) {
+ socket = new Socket (address.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
+ try {
+ socket.Connect (new IPEndPoint(address, sPoint.Address.Port));
+ status = WebExceptionStatus.Success;
+ break;
+ } catch (SocketException) {
+ socket.Close();
+ socket = null;
+ status = WebExceptionStatus.ConnectFailure;
+ }
+ }
}
}
@@ -125,7 +124,7 @@ namespace System.Net
if (e == null) { // At least we now where it comes from
try {
- throw new Exception ();
+ throw new Exception (new System.Diagnostics.StackTrace ().ToString ());
} catch (Exception e2) {
e = e2;
}
@@ -139,7 +138,6 @@ namespace System.Net
internal bool WaitForContinue (byte [] headers, int offset, int size)
{
- Data.StatusCode = 0;
waitingForContinue = sPoint.SendContinue;
if (waitingForContinue && waitForContinue == null)
waitForContinue = new AutoResetEvent (false);
@@ -259,7 +257,7 @@ namespace System.Net
{
WebConnection cnc = (WebConnection) state;
NetworkStream ns = cnc.nstream;
-
+
try {
ns.BeginRead (cnc.buffer, 0, cnc.buffer.Length, readDoneDelegate, cnc);
} catch (Exception e) {
@@ -413,16 +411,17 @@ namespace System.Net
}
}
}
+
internal void NextRead ()
{
lock (this) {
busy = false;
string header = (sPoint.UsesProxy) ? "Proxy-Connection" : "Connection";
string cncHeader = (Data.Headers != null) ? Data.Headers [header] : null;
- bool keepAlive = this.keepAlive;
+ bool keepAlive = (Data.Version == HttpVersion.Version11);
if (cncHeader != null) {
cncHeader = cncHeader.ToLower ();
- keepAlive = (keepAlive && cncHeader.IndexOf ("keep-alive") != -1);
+ keepAlive = (this.keepAlive && cncHeader.IndexOf ("keep-alive") != -1);
}
if ((socket != null && !socket.Connected) ||
@@ -571,12 +570,34 @@ namespace System.Net
try {
nstream.Write (buffer, offset, size);
- } catch (Exception e) {
- status = WebExceptionStatus.SendFailure;
- HandleError (status, e);
+ } catch (Exception) {
}
}
+ internal bool TryReconnect ()
+ {
+ lock (this) {
+ if (!reused) {
+ HandleError (WebExceptionStatus.SendFailure, null);
+ return false;
+ }
+
+ Close (false);
+ reused = false;
+ Connect ();
+ if (status != WebExceptionStatus.Success) {
+ HandleError (WebExceptionStatus.SendFailure, null);
+ return false;
+ }
+
+ if (!CreateStream (Data.request)) {
+ HandleError (WebExceptionStatus.SendFailure, null);
+ return false;
+ }
+ }
+ return true;
+ }
+
void Close (bool sendNext)
{
lock (this) {
@@ -611,6 +632,14 @@ namespace System.Net
get { lock (this) return busy; }
}
+ internal bool Connected {
+ get {
+ lock (this) {
+ return (socket != null && socket.Connected);
+ }
+ }
+ }
+
~WebConnection ()
{
Close (false);
diff --git a/mcs/class/System/System.Net/WebConnectionData.cs b/mcs/class/System/System.Net/WebConnectionData.cs
index a3d49e3a363..4112ea4991d 100644
--- a/mcs/class/System/System.Net/WebConnectionData.cs
+++ b/mcs/class/System/System.Net/WebConnectionData.cs
@@ -26,7 +26,7 @@ namespace System.Net
public void Init ()
{
request = null;
- StatusCode = -1;
+ StatusCode = 0;
StatusDescription = null;
Headers = null;
stream = null;
diff --git a/mcs/class/System/System.Net/WebConnectionGroup.cs b/mcs/class/System/System.Net/WebConnectionGroup.cs
index ce0a87f252b..307b921bec3 100644
--- a/mcs/class/System/System.Net/WebConnectionGroup.cs
+++ b/mcs/class/System/System.Net/WebConnectionGroup.cs
@@ -67,6 +67,21 @@ namespace System.Net
WeakReference cncRef;
int count = connections.Count;
+ for (int i = 0; i < count; i++) {
+ WeakReference wr = connections [i] as WeakReference;
+ cnc = wr.Target as WebConnection;
+ if (cnc == null || !cnc.Connected) {
+ connections.RemoveAt (i);
+ count--;
+ continue;
+ }
+
+ if (cnc.Busy)
+ continue;
+
+ return cnc;
+ }
+
if (sPoint.ConnectionLimit > count) {
cnc = new WebConnection (this, sPoint);
connections.Add (new WeakReference (cnc));
@@ -76,14 +91,6 @@ namespace System.Net
if (rnd == null)
rnd = new Random ();
- foreach (WeakReference wr in connections) {
- cnc = wr.Target as WebConnection;
- if (cnc.Busy)
- continue;
-
- return cnc;
- }
-
int idx = (count > 1) ? rnd.Next (0, count - 1) : 0;
cncRef = (WeakReference) connections [idx];
cnc = cncRef.Target as WebConnection;
diff --git a/mcs/class/System/System.Net/WebConnectionStream.cs b/mcs/class/System/System.Net/WebConnectionStream.cs
index 819823ebf5f..cf74554b9ec 100644
--- a/mcs/class/System/System.Net/WebConnectionStream.cs
+++ b/mcs/class/System/System.Net/WebConnectionStream.cs
@@ -127,6 +127,13 @@ namespace System.Net
cnc.NextRead ();
}
+ static void CallbackWrapper (IAsyncResult r)
+ {
+ WebAsyncResult result = (WebAsyncResult) r.AsyncState;
+ result.InnerAsyncResult = r;
+ result.DoCallback ();
+ }
+
public override int Read (byte [] buffer, int offset, int size)
{
if (!isRead)
@@ -154,7 +161,7 @@ namespace System.Net
WebAsyncResult result = new WebAsyncResult (cb, state, buffer, offset, size);
if (totalRead >= contentLength) {
- result.SetCompleted (true, 0);
+ result.SetCompleted (true, -1);
result.DoCallback ();
return result;
}
@@ -180,7 +187,13 @@ namespace System.Net
pending.Reset ();
}
- result.InnerAsyncResult = cnc.BeginRead (buffer, offset, size, null, null);
+ if (cb != null)
+ cb = new AsyncCallback (CallbackWrapper);
+
+ if (contentLength != Int32.MaxValue && contentLength - totalRead < size)
+ size = contentLength - totalRead;
+
+ result.InnerAsyncResult = cnc.BeginRead (buffer, offset, size, cb, result);
return result;
}
@@ -196,9 +209,13 @@ namespace System.Net
pending.Set ();
}
+ bool finished = (nbytes == -1);
+ if (finished && result.NBytes > 0)
+ nbytes = 0;
+
result.SetCompleted (false, nbytes + result.NBytes);
totalRead += nbytes;
- if (nbytes == 0)
+ if (finished || nbytes == 0)
contentLength = totalRead;
}
@@ -229,7 +246,10 @@ namespace System.Net
result.SetCompleted (true, 0);
result.DoCallback ();
} else {
- result.InnerAsyncResult = cnc.BeginWrite (buffer, offset, size, cb, state);
+ if (cb != null)
+ cb = new AsyncCallback (CallbackWrapper);
+
+ result.InnerAsyncResult = cnc.BeginWrite (buffer, offset, size, cb, result);
if (result.InnerAsyncResult == null)
throw new WebException ("Aborted");
}
@@ -269,7 +289,17 @@ namespace System.Net
internal void SetHeaders (byte [] buffer, int offset, int size)
{
if (!allowBuffering) {
- Write (buffer, offset, size);
+ try {
+ Write (buffer, offset, size);
+ } catch (IOException e) {
+ if (cnc.Connected)
+ throw;
+
+ if (!cnc.TryReconnect ())
+ throw;
+
+ Write (buffer, offset, size);
+ }
} else {
headers = new byte [size];
Buffer.BlockCopy (buffer, offset, headers, 0, size);
@@ -291,11 +321,24 @@ namespace System.Net
request.InternalContentLength = length;
request.SendRequestHeaders ();
requestWritten = true;
- cnc.WaitForContinue (headers, 0, headers.Length);
- if (cnc.Data.StatusCode != 0 && cnc.Data.StatusCode != 100)
- return;
+ while (true) {
+ cnc.WaitForContinue (headers, 0, headers.Length);
+ if (!cnc.Connected) {
+ if (!cnc.TryReconnect ())
+ return;
+
+ continue;
+ }
- cnc.Write (bytes, 0, length);
+ if (cnc.Data.StatusCode != 0 && cnc.Data.StatusCode != 100)
+ return;
+
+ cnc.Write (bytes, 0, length);
+ if (!cnc.Connected && cnc.TryReconnect ())
+ continue;
+
+ break;
+ }
}
internal void InternalClose ()
diff --git a/mcs/class/System/System.Net/WebExceptionStatus.cs b/mcs/class/System/System.Net/WebExceptionStatus.cs
index 05dd876bac0..e633fab756d 100755
--- a/mcs/class/System/System.Net/WebExceptionStatus.cs
+++ b/mcs/class/System/System.Net/WebExceptionStatus.cs
@@ -1,85 +1,36 @@
-// WebExceptionStatus.cs
+// System.Net.WebExceptionStatus.cs
//
-// This code was automatically generated from
-// ECMA CLI XML Library Specification.
-// Generator: libgen.xsl [1.0; (C) Sergey Chaban (serge@wildwestsoftware.com)]
-// Created: Wed, 5 Sep 2001 06:33:08 UTC
-// Source file: AllTypes.xml
-// URL: http://msdn.microsoft.com/net/ecma/AllTypes.xml
+// Author:
+// Andreas Nahr (ClassDevelopment@A-SoftTech.com)
+// originally autogenerated by Sergey Chaban (serge@wildwestsoftware.com)
//
// (C) 2001 Ximian, Inc. http://www.ximian.com
-
-namespace System.Net {
-
-
- /// <summary>
- /// </summary>
- public enum WebExceptionStatus {
-
- /// <summary>
- /// </summary>
+namespace System.Net
+{
+ public enum WebExceptionStatus
+ {
Success = 0,
-
- /// <summary>
- /// </summary>
NameResolutionFailure = 1,
-
- /// <summary>
- /// </summary>
ConnectFailure = 2,
-
- /// <summary>
- /// </summary>
ReceiveFailure = 3,
-
- /// <summary>
- /// </summary>
SendFailure = 4,
-
- /// <summary>
- /// </summary>
PipelineFailure = 5,
-
- /// <summary>
- /// </summary>
RequestCanceled = 6,
-
- /// <summary>
- /// </summary>
ProtocolError = 7,
-
- /// <summary>
- /// </summary>
ConnectionClosed = 8,
-
- /// <summary>
- /// </summary>
TrustFailure = 9,
-
- /// <summary>
- /// </summary>
SecureChannelFailure = 10,
-
- /// <summary>
- /// </summary>
ServerProtocolViolation = 11,
-
- /// <summary>
- /// </summary>
KeepAliveFailure = 12,
-
- /// <summary>
- /// </summary>
Pending = 13,
-
- /// <summary>
- /// </summary>
Timeout = 14,
-
- /// <summary>
- /// </summary>
ProxyNameResolutionFailure = 15,
- } // WebExceptionStatus
-} // System.Net
+#if NET_1_1
+ UnknownError = 16,
+ MessageLengthLimitExceeded = 17,
+#endif
+
+ }
+}
diff --git a/mcs/class/System/System.Text.RegularExpressions/ChangeLog b/mcs/class/System/System.Text.RegularExpressions/ChangeLog
index ae9ae32d588..5572dae8fb9 100644
--- a/mcs/class/System/System.Text.RegularExpressions/ChangeLog
+++ b/mcs/class/System/System.Text.RegularExpressions/ChangeLog
@@ -1,3 +1,23 @@
+2003-11-27 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * interpreter.cs: when evaluating a degenerate match, restore the
+ RepeatContext if fail. Fixes bug #42529.
+
+2003-11-22 Jackson Harper <jackson@ximian.com>
+
+ * regex.cs: Add CultureInvariant flag to RegexOptions.
+
+2003-11-20 Juraj Skripsky <js@hotfeet.ch>
+
+ * quicksearch.cs: Use a hashtable instead of an array for the
+ shift table to improve the memory usage.
+
+2003-11-19 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * regex.cs:
+ (Split): include capture groups in the results, if any. Fixes bug
+ #51146.
+
2003-07-09 Gonzalo Paniagua Javier <gonzalo@ximian.com>
* regex.cs: patch from Eric Lindvall <eric@5stops.com> that fixes bug
diff --git a/mcs/class/System/System.Text.RegularExpressions/RegexTest.cs b/mcs/class/System/System.Text.RegularExpressions/RegexTest.cs
new file mode 100644
index 00000000000..f3d218f3215
--- /dev/null
+++ b/mcs/class/System/System.Text.RegularExpressions/RegexTest.cs
@@ -0,0 +1,28 @@
+//
+// assembly: System_test
+// namespace: MonoTests.System.Text.RegularExpressions
+// file: RegexTest.cs
+//
+// Authors:
+// Juraj Skripsky (juraj@hotfeet.ch)
+//
+// (c) 2003 Juraj Skripsky
+
+using System;
+using System.Text.RegularExpressions;
+
+using NUnit.Framework;
+
+namespace MonoTests.System.Text.RegularExpressions {
+
+ [TestFixture]
+ public class RegexTest {
+
+ [Test]
+ public void Simple () {
+ char[] c = { (char)32, (char)8212, (char)32 };
+ string s = new String(c);
+ Assertion.AssertEquals ("char", true, Regex.IsMatch(s, s));
+ }
+ }
+}
diff --git a/mcs/class/System/System.Text.RegularExpressions/interpreter.cs b/mcs/class/System/System.Text.RegularExpressions/interpreter.cs
index 1be1a36b2ee..91dcf23f18f 100644
--- a/mcs/class/System/System.Text.RegularExpressions/interpreter.cs
+++ b/mcs/class/System/System.Text.RegularExpressions/interpreter.cs
@@ -381,6 +381,7 @@ namespace System.Text.RegularExpressions {
if (Eval (Mode.Match, ref ptr, pc + 1))
goto Pass;
+ this.repeat = current;
goto Fail;
}
diff --git a/mcs/class/System/System.Text.RegularExpressions/quicksearch.cs b/mcs/class/System/System.Text.RegularExpressions/quicksearch.cs
index 65665a2518b..6ba50763267 100644
--- a/mcs/class/System/System.Text.RegularExpressions/quicksearch.cs
+++ b/mcs/class/System/System.Text.RegularExpressions/quicksearch.cs
@@ -7,6 +7,7 @@
// (c) 2002
using System;
+using System.Collections;
namespace System.Text.RegularExpressions {
@@ -49,7 +50,7 @@ namespace System.Text.RegularExpressions {
}
if (ptr < end)
- ptr += shift[text[ptr + len]];
+ ptr += GetShiftDistance (text[ptr + len]);
else
break;
}
@@ -66,7 +67,7 @@ namespace System.Text.RegularExpressions {
}
if (ptr < end)
- ptr += shift[text[ptr + len]];
+ ptr += GetShiftDistance (text[ptr + len]);
else
break;
}
@@ -81,15 +82,7 @@ namespace System.Text.RegularExpressions {
if (ignore)
str = str.ToLower ();
- // this is a 64k entry shift table. that's 128kb per pattern!
- // is it worth compressing this by only storing shifts within
- // a (lo, hi) character range? for most substrings this would
- // be around 50 bytes...
-
- shift = new int[0x1000];
- for (int i = 0; i < 0x1000; ++ i)
- shift[i] = len + 1;
-
+ shift = new Hashtable ();
for (int i = 0; i < len; ++ i) {
char c = str[i];
@@ -98,11 +91,17 @@ namespace System.Text.RegularExpressions {
shift[Char.ToUpper (c)] = len - i;
}
}
-
+
+ int GetShiftDistance (char c){
+ object s = shift[c];
+ return (s != null ? (int)s : len + 1);
+ }
+
private string str;
private int len;
private bool ignore;
- private int[] shift;
+ Hashtable shift;
}
+
}
diff --git a/mcs/class/System/System.Text.RegularExpressions/regex.cs b/mcs/class/System/System.Text.RegularExpressions/regex.cs
index 22720e31baf..bca4fab53f9 100644
--- a/mcs/class/System/System.Text.RegularExpressions/regex.cs
+++ b/mcs/class/System/System.Text.RegularExpressions/regex.cs
@@ -30,7 +30,8 @@ namespace System.Text.RegularExpressions {
Singleline = 0x010,
IgnorePatternWhitespace = 0x020,
RightToLeft = 0x040,
- ECMAScript = 0x100
+ ECMAScript = 0x100,
+ CultureInvariant = 0x200
}
[Serializable]
@@ -327,6 +328,12 @@ namespace System.Text.RegularExpressions {
break;
splits.Add (input.Substring (ptr, m.Index - ptr));
+ int gcount = m.Groups.Count;
+ for (int gindex = 1; gindex < gcount; gindex++) {
+ Group grp = m.Groups [gindex];
+ splits.Add (input.Substring (grp.Index, grp.Length));
+ }
+
ptr = m.Index + m.Length;
}
diff --git a/mcs/class/System/System.Web/AspNetHostingPermission.cs b/mcs/class/System/System.Web/AspNetHostingPermission.cs
new file mode 100644
index 00000000000..b8c063a4092
--- /dev/null
+++ b/mcs/class/System/System.Web/AspNetHostingPermission.cs
@@ -0,0 +1,82 @@
+//
+// System.Web.AspNetHostingPermission.cs
+//
+// Author:
+// Andreas Nahr (ClassDevelopment@A-SoftTech.com)
+//
+
+#if NET_1_1
+
+using System.Security;
+using System.Security.Permissions;
+
+namespace System.Web
+{
+ public sealed class AspNetHostingPermission : CodeAccessPermission, IUnrestrictedPermission
+ {
+ AspNetHostingPermissionLevel level;
+
+ public AspNetHostingPermission (AspNetHostingPermissionLevel level)
+ {
+ this.level = level;
+ }
+ public AspNetHostingPermission (PermissionState state)
+ {
+ switch (state) {
+ case PermissionState.None:
+ level = AspNetHostingPermissionLevel.None;
+ break;
+ case PermissionState.Unrestricted:
+ level = AspNetHostingPermissionLevel.Unrestricted;
+ break;
+ }
+ }
+
+ public AspNetHostingPermissionLevel Level {
+ get { return level; }
+ set { level = value; }
+ }
+
+ public bool IsUnrestricted ()
+ {
+ return (level == AspNetHostingPermissionLevel.Unrestricted);
+ }
+
+ public override IPermission Copy ()
+ {
+ return new AspNetHostingPermission (level);
+ }
+
+ [MonoTODO ("implement")]
+ public override void FromXml (SecurityElement securityElement)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO ("implement")]
+ public override SecurityElement ToXml ()
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO ("implement")]
+ public override IPermission Intersect (IPermission target)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO ("implement")]
+ public override bool IsSubsetOf (IPermission target)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO ("implement")]
+ public override IPermission Union (IPermission target)
+ {
+ throw new NotImplementedException ();
+ }
+ }
+}
+
+#endif \ No newline at end of file
diff --git a/mcs/class/System/System.Web/AspNetHostingPermissionAttribute.cs b/mcs/class/System/System.Web/AspNetHostingPermissionAttribute.cs
new file mode 100644
index 00000000000..d397bceff83
--- /dev/null
+++ b/mcs/class/System/System.Web/AspNetHostingPermissionAttribute.cs
@@ -0,0 +1,40 @@
+//
+// System.Web.AspNetHostingPermissionAttribute.cs
+//
+// Author:
+// Andreas Nahr (ClassDevelopment@A-SoftTech.com)
+//
+
+#if NET_1_1
+
+using System.Security;
+using System.Security.Permissions;
+
+namespace System.Web
+{
+ [AttributeUsage (AttributeTargets.All, AllowMultiple = true, Inherited = false)]
+ public sealed class AspNetHostingPermissionAttribute : CodeAccessSecurityAttribute
+ {
+ AspNetHostingPermissionLevel level;
+
+ public AspNetHostingPermissionAttribute (SecurityAction action)
+ : base (action)
+ {
+ // LAMESPEC: seems to initialize to None
+ level = AspNetHostingPermissionLevel.None;
+ }
+
+ [MonoTODO("implement")]
+ public override IPermission CreatePermission ()
+ {
+ throw new NotImplementedException ();
+ }
+
+ public AspNetHostingPermissionLevel Level {
+ get { return level; }
+ set { level = value; }
+ }
+ }
+}
+
+#endif \ No newline at end of file
diff --git a/mcs/class/System/System.Web/AspNetHostingPermissionLevel.cs b/mcs/class/System/System.Web/AspNetHostingPermissionLevel.cs
new file mode 100644
index 00000000000..f0f946b482a
--- /dev/null
+++ b/mcs/class/System/System.Web/AspNetHostingPermissionLevel.cs
@@ -0,0 +1,23 @@
+//
+// System.Web.AspNetHostingPermissionLevel.cs
+//
+// Author:
+// Andreas Nahr (ClassDevelopment@A-SoftTech.com)
+//
+
+#if NET_1_1
+
+namespace System.Web
+{
+ public enum AspNetHostingPermissionLevel
+ {
+ None = 100,
+ Minimal = 200,
+ Low = 300,
+ Medium = 400,
+ High = 500,
+ Unrestricted = 600
+ }
+}
+
+#endif \ No newline at end of file
diff --git a/mcs/class/System/System.Web/ChangeLog b/mcs/class/System/System.Web/ChangeLog
new file mode 100644
index 00000000000..9dec08cb999
--- /dev/null
+++ b/mcs/class/System/System.Web/ChangeLog
@@ -0,0 +1,14 @@
+2003-11-13 Andreas Nahr <ClassDevelopment@A-SoftTech.com>
+
+ * AspNetHostingPermissionAttribute.cs: Accidentially set to wrong value
+
+2003-11-13 Andreas Nahr <ClassDevelopment@A-SoftTech.com>
+
+ * AspNetHostingPermissionAttribute.cs: Added missing AttributeUsageAttribute
+
+2003-11-12 Andreas Nahr <ClassDevelopment@A-SoftTech.com>
+
+ * ChangeLog: Added
+ * AspNetHostingPermissionLevel.cs: Added and implemented
+ * AspNetHostingPermissionAttribute.cs: Added and partially implemented
+ * AspNetHostingPermission.cs: Added and partially implemented
diff --git a/mcs/class/System/System.dll.sources b/mcs/class/System/System.dll.sources
index 8eb4c9a7eeb..40e22aeb66c 100755
--- a/mcs/class/System/System.dll.sources
+++ b/mcs/class/System/System.dll.sources
@@ -121,6 +121,7 @@ System.CodeDom/MemberAttributes.cs
System.Collections.Specialized/BitVector32.cs
System.Collections.Specialized/CollectionsUtil.cs
System.Collections.Specialized/HybridDictionary.cs
+System.Collections.Specialized/IOrderedDictionary.cs
System.Collections.Specialized/ListDictionary.cs
System.Collections.Specialized/NameObjectCollectionBase.cs
System.Collections.Specialized/NameValueCollection.cs
@@ -139,6 +140,7 @@ System.ComponentModel/CollectionChangeAction.cs
System.ComponentModel/CollectionChangeEventArgs.cs
System.ComponentModel/CollectionChangeEventHandler.cs
System.ComponentModel/ComponentCollection.cs
+System.ComponentModel/ComponentResourceManager.cs
System.ComponentModel/Component.cs
System.ComponentModel/Container.cs
System.ComponentModel/DefaultEventAttribute.cs
@@ -440,6 +442,7 @@ System.Net/NetConfig.cs
System.Net/NetworkAccess.cs
System.Net/NetworkCredential.cs
System.Net/ProtocolViolationException.cs
+System.Net/SecurityProtocolType.cs
System.Net/ServicePoint.cs
System.Net/ServicePointManager.cs
System.Net/SocketAddress.cs
@@ -503,6 +506,9 @@ System.Timers/ElapsedEventArgs.cs
System.Timers/ElapsedEventHandler.cs
System.Timers/Timer.cs
System.Timers/TimersDescriptionAttribute.cs
+System.Web/AspNetHostingPermission.cs
+System.Web/AspNetHostingPermissionAttribute.cs
+System.Web/AspNetHostingPermissionLevel.cs
System/SRDescriptionAttribute.cs
System/TODOAttribute.cs
System/UriBuilder.cs
diff --git a/mcs/class/System/System/Uri.cs b/mcs/class/System/System/Uri.cs
index ca667aa3b34..7bfdc83f9af 100755
--- a/mcs/class/System/System/Uri.cs
+++ b/mcs/class/System/System/Uri.cs
@@ -155,7 +155,7 @@ namespace System
relativeUri = relativeUri.Substring (0, pos);
}
- if (relativeUri [0] == '/') {
+ if (relativeUri.Length > 0 && relativeUri [0] == '/') {
path = relativeUri;
if (!userEscaped)
path = EscapeString (path);
@@ -164,10 +164,15 @@ namespace System
// par 5.2 step 6 a)
path = baseUri.path;
- pos = path.LastIndexOf ('/');
- if (pos >= 0)
- path = path.Substring (0, pos + 1);
+ if (relativeUri.Length > 0 || query.Length > 0) {
+ pos = path.LastIndexOf ('/');
+ if (pos >= 0)
+ path = path.Substring (0, pos + 1);
+ }
+ if(relativeUri.Length == 0)
+ return;
+
// 6 b)
path += relativeUri;
diff --git a/mcs/class/System/System_test.dll.sources b/mcs/class/System/System_test.dll.sources
index 77445c616fc..9ca4921ee52 100644
--- a/mcs/class/System/System_test.dll.sources
+++ b/mcs/class/System/System_test.dll.sources
@@ -36,3 +36,5 @@ System.Net.Sockets/TcpListenerTest.cs
System.Text.RegularExpressions/PerlTest.cs
System.Text.RegularExpressions/PerlTrials.cs
System.Text.RegularExpressions/RegexTrial.cs
+System.Text.RegularExpressions/RegexTest.cs
+System.Text.RegularExpressions/RegexBugs.cs
diff --git a/mcs/class/System/Test/Microsoft.CSharp/ChangeLog b/mcs/class/System/Test/Microsoft.CSharp/ChangeLog
index bdd75602dea..3462d1fd8e4 100644
--- a/mcs/class/System/Test/Microsoft.CSharp/ChangeLog
+++ b/mcs/class/System/Test/Microsoft.CSharp/ChangeLog
@@ -1,3 +1,8 @@
+2003-11-21 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * Test/Microsoft.CSharp/CodeGeneratorFromCompileUnitTest.cs: don't
+ compare whitespace for assembly level attribute.
+
2003-07-09 Gonzalo Paniagua Javier <gonzalo@ximian.com>
* system_linux_test.args: added new tests in Microsoft.CSharp.
diff --git a/mcs/class/System/Test/Microsoft.CSharp/CodeGeneratorFromCompileUnitTest.cs b/mcs/class/System/Test/Microsoft.CSharp/CodeGeneratorFromCompileUnitTest.cs
index c2ba3261c40..7c549a8c2bf 100644
--- a/mcs/class/System/Test/Microsoft.CSharp/CodeGeneratorFromCompileUnitTest.cs
+++ b/mcs/class/System/Test/Microsoft.CSharp/CodeGeneratorFromCompileUnitTest.cs
@@ -103,7 +103,7 @@ namespace MonoTests.Microsoft.CSharp
codeUnit.AssemblyCustomAttributes.Add (attrDec);
Generate ();
- Assertion.AssertEquals ("[assembly: A()]\n\n", Code);
+ Assertion.AssertEquals ("[assembly: A()]", Code.Trim ());
}
/* FIXME
diff --git a/mcs/class/System/Test/System.Text.RegularExpressions/ChangeLog b/mcs/class/System/Test/System.Text.RegularExpressions/ChangeLog
new file mode 100644
index 00000000000..f22b84fc777
--- /dev/null
+++ b/mcs/class/System/Test/System.Text.RegularExpressions/ChangeLog
@@ -0,0 +1,4 @@
+2003-11-27 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * RegexBugs.cs: added tests from bug #42529.
+
diff --git a/mcs/class/System/Test/System.Text.RegularExpressions/RegexBugs.cs b/mcs/class/System/Test/System.Text.RegularExpressions/RegexBugs.cs
new file mode 100644
index 00000000000..79c63a02daf
--- /dev/null
+++ b/mcs/class/System/Test/System.Text.RegularExpressions/RegexBugs.cs
@@ -0,0 +1,67 @@
+//
+// MonoTests.System.Text.RegularExpressions misc. test cases
+//
+// Authors:
+// Gonzalo Paniagua Javier (gonzalo@ximian.com)
+//
+// (c) 2003 Novell, Inc. (http://www.novell.com)
+//
+
+using NUnit.Framework;
+using System;
+using System.Text.RegularExpressions;
+
+namespace MonoTests.System.Text.RegularExpressions
+{
+ [TestFixture]
+ public class RegexBugs : Assertion
+ {
+ [Test]
+ public void SplitGroup () // bug51146
+ {
+ string [] splitResult = new Regex ("-").Split ("a-bcd-e-fg");
+ string [] expected = new string [] {"a", "bcd", "e", "fg"};
+ int length = expected.Length;
+ int i;
+ AssertEquals ("#01", length, splitResult.Length);
+ for (i = 0; i < length; i++)
+ AssertEquals ("#02 " + i, expected [i], splitResult [i]);
+
+ splitResult = new Regex ("(-)").Split ("a-bcd-e-fg");
+ expected = new string [] {"a", "-", "bcd", "-", "e", "-", "fg"};
+ length = expected.Length;
+ AssertEquals ("#03", length, splitResult.Length);
+ for (i = 0; i < length; i++)
+ AssertEquals ("#04 " + i, expected [i], splitResult [i]);
+
+ splitResult = new Regex ("(-)b(c)").Split ("a-bcd-e-fg");
+ expected = new string [] {"a", "-", "c", "d-e-fg" };
+ length = expected.Length;
+ AssertEquals ("#04", length, splitResult.Length);
+ for (i = 0; i < length; i++)
+ AssertEquals ("#05 " + i, expected [i], splitResult [i]);
+ }
+
+ [Test]
+ public void MathEmptyGroup () // bug 42529
+ {
+ string str = "Match something from here.";
+
+ AssertEquals ("MEG #01", false, Regex.IsMatch(str, @"(something|dog)$"));
+ AssertEquals ("MEG #02", true, Regex.IsMatch(str, @"(|something|dog)$"));
+ AssertEquals ("MEG #03", true, Regex.IsMatch(str, @"(something||dog)$"));
+ AssertEquals ("MEG #04", true, Regex.IsMatch(str, @"(something|dog|)$"));
+
+ AssertEquals ("MEG #05", true, Regex.IsMatch(str, @"(something|dog)*"));
+ AssertEquals ("MEG #06", true, Regex.IsMatch(str, @"(|something|dog)*"));
+ AssertEquals ("MEG #07", true, Regex.IsMatch(str, @"(something||dog)*"));
+ AssertEquals ("MEG #08", true, Regex.IsMatch(str, @"(something|dog|)*"));
+
+ AssertEquals ("MEG #09", true, Regex.IsMatch(str, @"(something|dog)*$"));
+ AssertEquals ("MEG #10", true, Regex.IsMatch(str, @"(|something|dog)*$"));
+ AssertEquals ("MEG #11", true, Regex.IsMatch(str, @"(something||dog)*$"));
+ AssertEquals ("MEG #12", true, Regex.IsMatch(str, @"(something|dog|)*$"));
+
+ }
+ }
+}
diff --git a/mcs/class/System/Test/System.Text.RegularExpressions/RegexTest.cs b/mcs/class/System/Test/System.Text.RegularExpressions/RegexTest.cs
new file mode 100644
index 00000000000..f3d218f3215
--- /dev/null
+++ b/mcs/class/System/Test/System.Text.RegularExpressions/RegexTest.cs
@@ -0,0 +1,28 @@
+//
+// assembly: System_test
+// namespace: MonoTests.System.Text.RegularExpressions
+// file: RegexTest.cs
+//
+// Authors:
+// Juraj Skripsky (juraj@hotfeet.ch)
+//
+// (c) 2003 Juraj Skripsky
+
+using System;
+using System.Text.RegularExpressions;
+
+using NUnit.Framework;
+
+namespace MonoTests.System.Text.RegularExpressions {
+
+ [TestFixture]
+ public class RegexTest {
+
+ [Test]
+ public void Simple () {
+ char[] c = { (char)32, (char)8212, (char)32 };
+ string s = new String(c);
+ Assertion.AssertEquals ("char", true, Regex.IsMatch(s, s));
+ }
+ }
+}
diff --git a/mcs/class/System/Test/System/UriTest.cs b/mcs/class/System/Test/System/UriTest.cs
index 2f86a10b691..cb8d33466a6 100644
--- a/mcs/class/System/Test/System/UriTest.cs
+++ b/mcs/class/System/Test/System/UriTest.cs
@@ -1,209 +1,216 @@
-//
-// UriTest.cs - NUnit Test Cases for System.Uri
-//
-// Authors:
-// Lawrence Pit (loz@cable.a2000.nl)
+//
+// UriTest.cs - NUnit Test Cases for System.Uri
+//
+// Authors:
+// Lawrence Pit (loz@cable.a2000.nl)
// Martin Willemoes Hansen (mwh@sysrq.dk)
-// Ben Maurer (bmaurer@users.sourceforge.net)
-//
+// Ben Maurer (bmaurer@users.sourceforge.net)
+//
// (C) 2003 Martin Willemoes Hansen
-// (C) 2003 Ben Maurer
-//
-
-using NUnit.Framework;
-using System;
-using System.IO;
-
-namespace MonoTests.System
-{
- [TestFixture]
- public class UriTest
- {
- protected bool isWin32 = false;
-
- [SetUp]
- public void GetReady ()
- {
- isWin32 = (Path.DirectorySeparatorChar == '\\');
- }
-
- [Test]
- public void Constructors ()
- {
- Uri uri = null;
-
- /*
- uri = new Uri ("http://www.ximian.com/foo" + ((char) 0xa9) + "/bar/index.cgi?a=1&b=" + ((char) 0xa9) + "left#fragm?ent2");
- Print (uri);
-
- uri = new Uri ("http://www.ximian.com/foo/xxx\"()-._;<=>@{|}~-,.`_^]\\[xx/" + ((char) 0xa9) + "/bar/index.cgi#fra+\">=@[gg]~gment2");
- Print (uri);
-
- uri = new Uri("http://11.22.33.588:9090");
- Print (uri);
-
- uri = new Uri("http://[11:22:33::88]:9090");
- Print (uri);
-
- uri = new Uri("http://[::127.11.22.33]:8080");
- Print (uri);
-
- uri = new Uri("http://[abcde::127.11.22.33]:8080");
- Print (uri);
- */
-
- /*
- uri = new Uri ("http://www.contoso.com:1234/foo/bar/");
- Print (uri);
-
- uri = new Uri ("http://www.contoso.com:1234/foo/bar");
- Print (uri);
-
- uri = new Uri ("http://www.contoso.com:1234/");
- Print (uri);
-
- uri = new Uri ("http://www.contoso.com:1234");
- Print (uri);
- */
-
- uri = new Uri ("http://contoso.com?subject=uri");
- Assertion.AssertEquals ("#k1", "/", uri.AbsolutePath);
- Assertion.AssertEquals ("#k2", "http://contoso.com/?subject=uri", uri.AbsoluteUri);
- Assertion.AssertEquals ("#k3", "contoso.com", uri.Authority);
- Assertion.AssertEquals ("#k4", "", uri.Fragment);
- Assertion.AssertEquals ("#k5", "contoso.com", uri.Host);
- Assertion.AssertEquals ("#k6", UriHostNameType.Dns, uri.HostNameType);
- Assertion.AssertEquals ("#k7", true, uri.IsDefaultPort);
- Assertion.AssertEquals ("#k8", false, uri.IsFile);
- Assertion.AssertEquals ("#k9", false, uri.IsLoopback);
- Assertion.AssertEquals ("#k10", false, uri.IsUnc);
- Assertion.AssertEquals ("#k11", "/", uri.LocalPath);
- Assertion.AssertEquals ("#k12", "/?subject=uri", uri.PathAndQuery);
- Assertion.AssertEquals ("#k13", 80, uri.Port);
- Assertion.AssertEquals ("#k14", "?subject=uri", uri.Query);
- Assertion.AssertEquals ("#k15", "http", uri.Scheme);
- Assertion.AssertEquals ("#k16", false, uri.UserEscaped);
- Assertion.AssertEquals ("#k17", "", uri.UserInfo);
-
- uri = new Uri ("mailto:user:pwd@contoso.com?subject=uri");
- Assertion.AssertEquals ("#m1", "", uri.AbsolutePath);
- Assertion.AssertEquals ("#m2", "mailto:user:pwd@contoso.com?subject=uri", uri.AbsoluteUri);
- Assertion.AssertEquals ("#m3", "contoso.com", uri.Authority);
- Assertion.AssertEquals ("#m4", "", uri.Fragment);
- Assertion.AssertEquals ("#m5", "contoso.com", uri.Host);
- Assertion.AssertEquals ("#m6", UriHostNameType.Dns, uri.HostNameType);
- Assertion.AssertEquals ("#m7", true, uri.IsDefaultPort);
- Assertion.AssertEquals ("#m8", false, uri.IsFile);
- Assertion.AssertEquals ("#m9", false, uri.IsLoopback);
- Assertion.AssertEquals ("#m10", false, uri.IsUnc);
- Assertion.AssertEquals ("#m11", "", uri.LocalPath);
- Assertion.AssertEquals ("#m12", "?subject=uri", uri.PathAndQuery);
- Assertion.AssertEquals ("#m13", 25, uri.Port);
- Assertion.AssertEquals ("#m14", "?subject=uri", uri.Query);
- Assertion.AssertEquals ("#m15", "mailto", uri.Scheme);
- Assertion.AssertEquals ("#m16", false, uri.UserEscaped);
- Assertion.AssertEquals ("#m17", "user:pwd", uri.UserInfo);
-
- uri = new Uri (@"\\myserver\mydir\mysubdir\myfile.ext");
- Assertion.AssertEquals ("#n1", "/mydir/mysubdir/myfile.ext", uri.AbsolutePath);
- Assertion.AssertEquals ("#n2", "file://myserver/mydir/mysubdir/myfile.ext", uri.AbsoluteUri);
- Assertion.AssertEquals ("#n3", "myserver", uri.Authority);
- Assertion.AssertEquals ("#n4", "", uri.Fragment);
- Assertion.AssertEquals ("#n5", "myserver", uri.Host);
- Assertion.AssertEquals ("#n6", UriHostNameType.Dns, uri.HostNameType);
- Assertion.AssertEquals ("#n7", true, uri.IsDefaultPort);
- Assertion.AssertEquals ("#n8", true, uri.IsFile);
- Assertion.AssertEquals ("#n9", false, uri.IsLoopback);
- Assertion.AssertEquals ("#n10", true, uri.IsUnc);
-
- if (isWin32)
- Assertion.AssertEquals ("#n11", @"\\myserver\mydir\mysubdir\myfile.ext", uri.LocalPath);
- else
- Assertion.AssertEquals ("#n11", "//myserver/mydir/mysubdir/myfile.ext", uri.LocalPath);
-
- Assertion.AssertEquals ("#n12", "/mydir/mysubdir/myfile.ext", uri.PathAndQuery);
- Assertion.AssertEquals ("#n13", -1, uri.Port);
- Assertion.AssertEquals ("#n14", "", uri.Query);
- Assertion.AssertEquals ("#n15", "file", uri.Scheme);
- Assertion.AssertEquals ("#n16", false, uri.UserEscaped);
- Assertion.AssertEquals ("#n17", "", uri.UserInfo);
-
- uri = new Uri (new Uri("http://www.contoso.com"), "Hello World.htm", true);
- Assertion.AssertEquals ("#rel1a", "http://www.contoso.com/Hello World.htm", uri.AbsoluteUri);
- Assertion.AssertEquals ("#rel1b", true, uri.UserEscaped);
- uri = new Uri (new Uri("http://www.contoso.com"), "Hello World.htm", false);
- Assertion.AssertEquals ("#rel2a", "http://www.contoso.com/Hello%20World.htm", uri.AbsoluteUri);
- Assertion.AssertEquals ("#rel2b", false, uri.UserEscaped);
- uri = new Uri (new Uri("http://www.contoso.com"), "http://www.xxx.com/Hello World.htm", false);
- Assertion.AssertEquals ("#rel3", "http://www.xxx.com/Hello%20World.htm", uri.AbsoluteUri);
- //uri = new Uri (new Uri("http://www.contoso.com"), "foo:8080/bar/Hello World.htm", false);
- //Assertion.AssertEquals ("#rel4", "foo:8080/bar/Hello%20World.htm", uri.AbsoluteUri);
- uri = new Uri (new Uri("http://www.contoso.com"), "foo/bar/Hello World.htm?x=0:8", false);
- Assertion.AssertEquals ("#rel5", "http://www.contoso.com/foo/bar/Hello%20World.htm?x=0:8", uri.AbsoluteUri);
- uri = new Uri (new Uri("http://www.contoso.com/xxx/yyy/index.htm"), "foo/bar/Hello World.htm?x=0:8", false);
- Assertion.AssertEquals ("#rel6", "http://www.contoso.com/xxx/yyy/foo/bar/Hello%20World.htm?x=0:8", uri.AbsoluteUri);
- uri = new Uri (new Uri("http://www.contoso.com/xxx/yyy/index.htm"), "/foo/bar/Hello World.htm?x=0:8", false);
- Assertion.AssertEquals ("#rel7", "http://www.contoso.com/foo/bar/Hello%20World.htm?x=0:8", uri.AbsoluteUri);
- uri = new Uri (new Uri("http://www.contoso.com/xxx/yyy/index.htm"), "../foo/bar/Hello World.htm?x=0:8", false);
- Assertion.AssertEquals ("#rel8", "http://www.contoso.com/xxx/foo/bar/Hello%20World.htm?x=0:8", uri.AbsoluteUri);
- uri = new Uri (new Uri("http://www.contoso.com/xxx/yyy/index.htm"), "../../../foo/bar/Hello World.htm?x=0:8", false);
- Assertion.AssertEquals ("#rel9", "http://www.contoso.com/../foo/bar/Hello%20World.htm?x=0:8", uri.AbsoluteUri);
- uri = new Uri (new Uri("http://www.contoso.com/xxx/yyy/index.htm"), "./foo/bar/Hello World.htm?x=0:8", false);
- Assertion.AssertEquals ("#rel10", "http://www.contoso.com/xxx/yyy/foo/bar/Hello%20World.htm?x=0:8", uri.AbsoluteUri);
-
- try {
- uri = new Uri (null, "http://www.contoso.com/index.htm", false);
- Assertion.Fail ("#rel20");
- } catch (NullReferenceException) {
- }
- try {
- uri = new Uri (new Uri("http://www.contoso.com"), null, false);
- Assertion.Fail ("#rel21");
- } catch (NullReferenceException) {
- }
- try {
- uri = new Uri (new Uri("http://www.contoso.com/foo/bar/index.html?x=0"), String.Empty, false);
- Assertion.AssertEquals("#22", "http://www.contoso.com/foo/bar/index.html?x=0", uri.ToString ());
- } catch (NullReferenceException) {
- }
- }
-
- [Test]
- public void LocalPath ()
- {
- Uri uri = new Uri ("c:\\tmp\\hello.txt");
- Assertion.AssertEquals ("#1a", "file:///c:/tmp/hello.txt", uri.ToString ());
- Assertion.AssertEquals ("#1b", "c:\\tmp\\hello.txt", uri.LocalPath);
- Assertion.AssertEquals ("#1c", "file", uri.Scheme);
- Assertion.AssertEquals ("#1d", "", uri.Host);
- Assertion.AssertEquals ("#1e", "c:/tmp/hello.txt", uri.AbsolutePath);
-
- uri = new Uri ("file:////////cygwin/tmp/hello.txt");
- Assertion.AssertEquals ("#3a", "file://cygwin/tmp/hello.txt", uri.ToString ());
- if (isWin32)
- Assertion.AssertEquals ("#3b win32", "\\\\cygwin\\tmp\\hello.txt", uri.LocalPath);
- else
- Assertion.AssertEquals ("#3b *nix", "/cygwin/tmp/hello.txt", uri.LocalPath);
- Assertion.AssertEquals ("#3c", "file", uri.Scheme);
- Assertion.AssertEquals ("#3d", "cygwin", uri.Host);
- Assertion.AssertEquals ("#3e", "/tmp/hello.txt", uri.AbsolutePath);
-
- uri = new Uri ("file://mymachine/cygwin/tmp/hello.txt");
- Assertion.AssertEquals ("#4a", "file://mymachine/cygwin/tmp/hello.txt", uri.ToString ());
- if (isWin32)
- Assertion.AssertEquals ("#4b win32", "\\\\mymachine\\cygwin\\tmp\\hello.txt", uri.LocalPath);
- else
- Assertion.AssertEquals ("#4b *nix", "/mymachine/cygwin/tmp/hello.txt", uri.LocalPath);
- Assertion.AssertEquals ("#4c", "file", uri.Scheme);
- Assertion.AssertEquals ("#4d", "mymachine", uri.Host);
- Assertion.AssertEquals ("#4e", "/cygwin/tmp/hello.txt", uri.AbsolutePath);
-
- uri = new Uri ("file://///c:/cygwin/tmp/hello.txt");
- Assertion.AssertEquals ("#5a", "file:///c:/cygwin/tmp/hello.txt", uri.ToString ());
- Assertion.AssertEquals ("#5b", "c:\\cygwin\\tmp\\hello.txt", uri.LocalPath);
- Assertion.AssertEquals ("#5c", "file", uri.Scheme);
- Assertion.AssertEquals ("#5d", "", uri.Host);
- Assertion.AssertEquals ("#5e", "c:/cygwin/tmp/hello.txt", uri.AbsolutePath);
+// (C) 2003 Ben Maurer
+//
+
+using NUnit.Framework;
+using System;
+using System.IO;
+
+namespace MonoTests.System
+{
+ [TestFixture]
+ public class UriTest
+ {
+ protected bool isWin32 = false;
+
+ [SetUp]
+ public void GetReady ()
+ {
+ isWin32 = (Path.DirectorySeparatorChar == '\\');
+ }
+
+ [Test]
+ public void Constructors ()
+ {
+ Uri uri = null;
+
+ /*
+ uri = new Uri ("http://www.ximian.com/foo" + ((char) 0xa9) + "/bar/index.cgi?a=1&b=" + ((char) 0xa9) + "left#fragm?ent2");
+ Print (uri);
+
+ uri = new Uri ("http://www.ximian.com/foo/xxx\"()-._;<=>@{|}~-,.`_^]\\[xx/" + ((char) 0xa9) + "/bar/index.cgi#fra+\">=@[gg]~gment2");
+ Print (uri);
+
+ uri = new Uri("http://11.22.33.588:9090");
+ Print (uri);
+
+ uri = new Uri("http://[11:22:33::88]:9090");
+ Print (uri);
+
+ uri = new Uri("http://[::127.11.22.33]:8080");
+ Print (uri);
+
+ uri = new Uri("http://[abcde::127.11.22.33]:8080");
+ Print (uri);
+ */
+
+ /*
+ uri = new Uri ("http://www.contoso.com:1234/foo/bar/");
+ Print (uri);
+
+ uri = new Uri ("http://www.contoso.com:1234/foo/bar");
+ Print (uri);
+
+ uri = new Uri ("http://www.contoso.com:1234/");
+ Print (uri);
+
+ uri = new Uri ("http://www.contoso.com:1234");
+ Print (uri);
+ */
+
+ uri = new Uri ("http://contoso.com?subject=uri");
+ Assertion.AssertEquals ("#k1", "/", uri.AbsolutePath);
+ Assertion.AssertEquals ("#k2", "http://contoso.com/?subject=uri", uri.AbsoluteUri);
+ Assertion.AssertEquals ("#k3", "contoso.com", uri.Authority);
+ Assertion.AssertEquals ("#k4", "", uri.Fragment);
+ Assertion.AssertEquals ("#k5", "contoso.com", uri.Host);
+ Assertion.AssertEquals ("#k6", UriHostNameType.Dns, uri.HostNameType);
+ Assertion.AssertEquals ("#k7", true, uri.IsDefaultPort);
+ Assertion.AssertEquals ("#k8", false, uri.IsFile);
+ Assertion.AssertEquals ("#k9", false, uri.IsLoopback);
+ Assertion.AssertEquals ("#k10", false, uri.IsUnc);
+ Assertion.AssertEquals ("#k11", "/", uri.LocalPath);
+ Assertion.AssertEquals ("#k12", "/?subject=uri", uri.PathAndQuery);
+ Assertion.AssertEquals ("#k13", 80, uri.Port);
+ Assertion.AssertEquals ("#k14", "?subject=uri", uri.Query);
+ Assertion.AssertEquals ("#k15", "http", uri.Scheme);
+ Assertion.AssertEquals ("#k16", false, uri.UserEscaped);
+ Assertion.AssertEquals ("#k17", "", uri.UserInfo);
+
+ uri = new Uri ("mailto:user:pwd@contoso.com?subject=uri");
+ Assertion.AssertEquals ("#m1", "", uri.AbsolutePath);
+ Assertion.AssertEquals ("#m2", "mailto:user:pwd@contoso.com?subject=uri", uri.AbsoluteUri);
+ Assertion.AssertEquals ("#m3", "contoso.com", uri.Authority);
+ Assertion.AssertEquals ("#m4", "", uri.Fragment);
+ Assertion.AssertEquals ("#m5", "contoso.com", uri.Host);
+ Assertion.AssertEquals ("#m6", UriHostNameType.Dns, uri.HostNameType);
+ Assertion.AssertEquals ("#m7", true, uri.IsDefaultPort);
+ Assertion.AssertEquals ("#m8", false, uri.IsFile);
+ Assertion.AssertEquals ("#m9", false, uri.IsLoopback);
+ Assertion.AssertEquals ("#m10", false, uri.IsUnc);
+ Assertion.AssertEquals ("#m11", "", uri.LocalPath);
+ Assertion.AssertEquals ("#m12", "?subject=uri", uri.PathAndQuery);
+ Assertion.AssertEquals ("#m13", 25, uri.Port);
+ Assertion.AssertEquals ("#m14", "?subject=uri", uri.Query);
+ Assertion.AssertEquals ("#m15", "mailto", uri.Scheme);
+ Assertion.AssertEquals ("#m16", false, uri.UserEscaped);
+ Assertion.AssertEquals ("#m17", "user:pwd", uri.UserInfo);
+
+ uri = new Uri (@"\\myserver\mydir\mysubdir\myfile.ext");
+ Assertion.AssertEquals ("#n1", "/mydir/mysubdir/myfile.ext", uri.AbsolutePath);
+ Assertion.AssertEquals ("#n2", "file://myserver/mydir/mysubdir/myfile.ext", uri.AbsoluteUri);
+ Assertion.AssertEquals ("#n3", "myserver", uri.Authority);
+ Assertion.AssertEquals ("#n4", "", uri.Fragment);
+ Assertion.AssertEquals ("#n5", "myserver", uri.Host);
+ Assertion.AssertEquals ("#n6", UriHostNameType.Dns, uri.HostNameType);
+ Assertion.AssertEquals ("#n7", true, uri.IsDefaultPort);
+ Assertion.AssertEquals ("#n8", true, uri.IsFile);
+ Assertion.AssertEquals ("#n9", false, uri.IsLoopback);
+ Assertion.AssertEquals ("#n10", true, uri.IsUnc);
+
+ if (isWin32)
+ Assertion.AssertEquals ("#n11", @"\\myserver\mydir\mysubdir\myfile.ext", uri.LocalPath);
+ else
+ Assertion.AssertEquals ("#n11", "//myserver/mydir/mysubdir/myfile.ext", uri.LocalPath);
+
+ Assertion.AssertEquals ("#n12", "/mydir/mysubdir/myfile.ext", uri.PathAndQuery);
+ Assertion.AssertEquals ("#n13", -1, uri.Port);
+ Assertion.AssertEquals ("#n14", "", uri.Query);
+ Assertion.AssertEquals ("#n15", "file", uri.Scheme);
+ Assertion.AssertEquals ("#n16", false, uri.UserEscaped);
+ Assertion.AssertEquals ("#n17", "", uri.UserInfo);
+
+ uri = new Uri (new Uri("http://www.contoso.com"), "Hello World.htm", true);
+ Assertion.AssertEquals ("#rel1a", "http://www.contoso.com/Hello World.htm", uri.AbsoluteUri);
+ Assertion.AssertEquals ("#rel1b", true, uri.UserEscaped);
+ uri = new Uri (new Uri("http://www.contoso.com"), "Hello World.htm", false);
+ Assertion.AssertEquals ("#rel2a", "http://www.contoso.com/Hello%20World.htm", uri.AbsoluteUri);
+ Assertion.AssertEquals ("#rel2b", false, uri.UserEscaped);
+ uri = new Uri (new Uri("http://www.contoso.com"), "http://www.xxx.com/Hello World.htm", false);
+ Assertion.AssertEquals ("#rel3", "http://www.xxx.com/Hello%20World.htm", uri.AbsoluteUri);
+ //uri = new Uri (new Uri("http://www.contoso.com"), "foo:8080/bar/Hello World.htm", false);
+ //Assertion.AssertEquals ("#rel4", "foo:8080/bar/Hello%20World.htm", uri.AbsoluteUri);
+ uri = new Uri (new Uri("http://www.contoso.com"), "foo/bar/Hello World.htm?x=0:8", false);
+ Assertion.AssertEquals ("#rel5", "http://www.contoso.com/foo/bar/Hello%20World.htm?x=0:8", uri.AbsoluteUri);
+ uri = new Uri (new Uri("http://www.contoso.com/xxx/yyy/index.htm"), "foo/bar/Hello World.htm?x=0:8", false);
+ Assertion.AssertEquals ("#rel6", "http://www.contoso.com/xxx/yyy/foo/bar/Hello%20World.htm?x=0:8", uri.AbsoluteUri);
+ uri = new Uri (new Uri("http://www.contoso.com/xxx/yyy/index.htm"), "/foo/bar/Hello World.htm?x=0:8", false);
+ Assertion.AssertEquals ("#rel7", "http://www.contoso.com/foo/bar/Hello%20World.htm?x=0:8", uri.AbsoluteUri);
+ uri = new Uri (new Uri("http://www.contoso.com/xxx/yyy/index.htm"), "../foo/bar/Hello World.htm?x=0:8", false);
+ Assertion.AssertEquals ("#rel8", "http://www.contoso.com/xxx/foo/bar/Hello%20World.htm?x=0:8", uri.AbsoluteUri);
+ uri = new Uri (new Uri("http://www.contoso.com/xxx/yyy/index.htm"), "../../../foo/bar/Hello World.htm?x=0:8", false);
+ Assertion.AssertEquals ("#rel9", "http://www.contoso.com/../foo/bar/Hello%20World.htm?x=0:8", uri.AbsoluteUri);
+ uri = new Uri (new Uri("http://www.contoso.com/xxx/yyy/index.htm"), "./foo/bar/Hello World.htm?x=0:8", false);
+ Assertion.AssertEquals ("#rel10", "http://www.contoso.com/xxx/yyy/foo/bar/Hello%20World.htm?x=0:8", uri.AbsoluteUri);
+
+ try {
+ uri = new Uri (null, "http://www.contoso.com/index.htm", false);
+ Assertion.Fail ("#rel20");
+ } catch (NullReferenceException) {
+ }
+ try {
+ uri = new Uri (new Uri("http://www.contoso.com"), null, false);
+ Assertion.Fail ("#rel21");
+ } catch (NullReferenceException) {
+ }
+ try {
+ uri = new Uri (new Uri("http://www.contoso.com/foo/bar/index.html?x=0"), String.Empty, false);
+ Assertion.AssertEquals("#22", "http://www.contoso.com/foo/bar/index.html?x=0", uri.ToString ());
+ } catch (NullReferenceException) {
+ }
+
+ uri = new Uri (new Uri("http://www.xxx.com"), "?x=0");
+ Assertion.AssertEquals ("#rel30", "http://www.xxx.com/?x=0", uri.ToString());
+ uri = new Uri (new Uri("http://www.xxx.com/index.htm"), "?x=0");
+ Assertion.AssertEquals ("#rel31", "http://www.xxx.com/?x=0", uri.ToString());
+ uri = new Uri (new Uri("http://www.xxx.com/index.htm"), "#here");
+ Assertion.AssertEquals ("#rel32", "http://www.xxx.com/index.htm#here", uri.ToString());
+ }
+
+ [Test]
+ public void LocalPath ()
+ {
+ Uri uri = new Uri ("c:\\tmp\\hello.txt");
+ Assertion.AssertEquals ("#1a", "file:///c:/tmp/hello.txt", uri.ToString ());
+ Assertion.AssertEquals ("#1b", "c:\\tmp\\hello.txt", uri.LocalPath);
+ Assertion.AssertEquals ("#1c", "file", uri.Scheme);
+ Assertion.AssertEquals ("#1d", "", uri.Host);
+ Assertion.AssertEquals ("#1e", "c:/tmp/hello.txt", uri.AbsolutePath);
+
+ uri = new Uri ("file:////////cygwin/tmp/hello.txt");
+ Assertion.AssertEquals ("#3a", "file://cygwin/tmp/hello.txt", uri.ToString ());
+ if (isWin32)
+ Assertion.AssertEquals ("#3b win32", "\\\\cygwin\\tmp\\hello.txt", uri.LocalPath);
+ else
+ Assertion.AssertEquals ("#3b *nix", "/cygwin/tmp/hello.txt", uri.LocalPath);
+ Assertion.AssertEquals ("#3c", "file", uri.Scheme);
+ Assertion.AssertEquals ("#3d", "cygwin", uri.Host);
+ Assertion.AssertEquals ("#3e", "/tmp/hello.txt", uri.AbsolutePath);
+
+ uri = new Uri ("file://mymachine/cygwin/tmp/hello.txt");
+ Assertion.AssertEquals ("#4a", "file://mymachine/cygwin/tmp/hello.txt", uri.ToString ());
+ if (isWin32)
+ Assertion.AssertEquals ("#4b win32", "\\\\mymachine\\cygwin\\tmp\\hello.txt", uri.LocalPath);
+ else
+ Assertion.AssertEquals ("#4b *nix", "/mymachine/cygwin/tmp/hello.txt", uri.LocalPath);
+ Assertion.AssertEquals ("#4c", "file", uri.Scheme);
+ Assertion.AssertEquals ("#4d", "mymachine", uri.Host);
+ Assertion.AssertEquals ("#4e", "/cygwin/tmp/hello.txt", uri.AbsolutePath);
+
+ uri = new Uri ("file://///c:/cygwin/tmp/hello.txt");
+ Assertion.AssertEquals ("#5a", "file:///c:/cygwin/tmp/hello.txt", uri.ToString ());
+ Assertion.AssertEquals ("#5b", "c:\\cygwin\\tmp\\hello.txt", uri.LocalPath);
+ Assertion.AssertEquals ("#5c", "file", uri.Scheme);
+ Assertion.AssertEquals ("#5d", "", uri.Host);
+ Assertion.AssertEquals ("#5e", "c:/cygwin/tmp/hello.txt", uri.AbsolutePath);
uri = new Uri("file://one_file.txt");
Assertion.AssertEquals("#6a", "file://one_file.txt", uri.ToString());
@@ -215,456 +222,456 @@ namespace MonoTests.System
Assertion.AssertEquals("#6d", "one_file.txt", uri.Host);
Assertion.AssertEquals("#6e", "", uri.AbsolutePath);
- }
+ }
[Test]
public void UnixPath () {
if (!isWin32)
Assertion.AssertEquals ("#6a", "file://cygwin/tmp/hello.txt", new Uri ("/cygwin/tmp/hello.txt").ToString ());
}
-
- [Test]
- public void Unc ()
- {
- Uri uri = new Uri ("http://www.contoso.com");
- Assertion.Assert ("#1", !uri.IsUnc);
-
- uri = new Uri ("news:123456@contoso.com");
- Assertion.Assert ("#2", !uri.IsUnc);
-
- uri = new Uri ("file://server/filename.ext");
- Assertion.Assert ("#3", uri.IsUnc);
-
- uri = new Uri (@"\\server\share\filename.ext");
- Assertion.Assert ("#6", uri.IsUnc);
- }
-
- [Test]
- [Ignore ("Known to fail under MS runtime")]
- public void Unc2 ()
- {
- try {
- Uri uri = new Uri ("file:/filename.ext");
- Assertion.Assert ("#4", uri.IsUnc);
- } catch (UriFormatException) {
- Assertion.Fail ("#5: known to fail with ms.net");
- }
- }
-
- [Test]
- public void FromHex ()
- {
- Assertion.AssertEquals ("#1", 0, Uri.FromHex ('0'));
- Assertion.AssertEquals ("#2", 9, Uri.FromHex ('9'));
- Assertion.AssertEquals ("#3", 10, Uri.FromHex ('a'));
- Assertion.AssertEquals ("#4", 15, Uri.FromHex ('f'));
- Assertion.AssertEquals ("#5", 10, Uri.FromHex ('A'));
- Assertion.AssertEquals ("#6", 15, Uri.FromHex ('F'));
- try {
- Uri.FromHex ('G');
- Assertion.Fail ("#7");
- } catch (ArgumentException) {}
- try {
- Uri.FromHex (' ');
- Assertion.Fail ("#8");
- } catch (ArgumentException) {}
- try {
- Uri.FromHex ('%');
- Assertion.Fail ("#8");
- } catch (ArgumentException) {}
- }
-
- [Test]
- public void HexEscape ()
- {
- Assertion.AssertEquals ("#1","%20", Uri.HexEscape (' '));
- Assertion.AssertEquals ("#2","%A9", Uri.HexEscape ((char) 0xa9));
- Assertion.AssertEquals ("#3","%41", Uri.HexEscape ('A'));
- try {
- Uri.HexEscape ((char) 0x0369);
- Assertion.Fail ("#4");
- } catch (ArgumentOutOfRangeException) {}
- }
-
- [Test]
- public void HexUnescape ()
- {
- int i = 0;
- Assertion.AssertEquals ("#1", ' ', Uri.HexUnescape ("%20", ref i));
- Assertion.AssertEquals ("#2", 3, i);
- i = 4;
- Assertion.AssertEquals ("#3", (char) 0xa9, Uri.HexUnescape ("test%a9test", ref i));
- Assertion.AssertEquals ("#4", 7, i);
- Assertion.AssertEquals ("#5", 't', Uri.HexUnescape ("test%a9test", ref i));
- Assertion.AssertEquals ("#6", 8, i);
- i = 4;
- Assertion.AssertEquals ("#5", '%', Uri.HexUnescape ("test%a", ref i));
- Assertion.AssertEquals ("#6", 5, i);
- Assertion.AssertEquals ("#7", '%', Uri.HexUnescape ("testx%xx", ref i));
- Assertion.AssertEquals ("#8", 6, i);
- }
-
- [Test]
- public void IsHexDigit ()
- {
- Assertion.Assert ("#1", Uri.IsHexDigit ('a'));
- Assertion.Assert ("#2", Uri.IsHexDigit ('f'));
- Assertion.Assert ("#3", !Uri.IsHexDigit ('g'));
- Assertion.Assert ("#4", Uri.IsHexDigit ('0'));
- Assertion.Assert ("#5", Uri.IsHexDigit ('9'));
- Assertion.Assert ("#6", Uri.IsHexDigit ('A'));
- Assertion.Assert ("#7", Uri.IsHexDigit ('F'));
- Assertion.Assert ("#8", !Uri.IsHexDigit ('G'));
- }
-
- [Test]
- public void IsHexEncoding ()
- {
- Assertion.Assert ("#1", Uri.IsHexEncoding ("test%a9test", 4));
- Assertion.Assert ("#2", !Uri.IsHexEncoding ("test%a9test", 3));
- Assertion.Assert ("#3", Uri.IsHexEncoding ("test%a9", 4));
- Assertion.Assert ("#4", !Uri.IsHexEncoding ("test%a", 4));
- }
-
- [Test]
- public void GetLeftPart ()
- {
- Uri uri = new Uri ("http://www.contoso.com/index.htm#main");
- Assertion.AssertEquals ("#1", "http://", uri.GetLeftPart (UriPartial.Scheme));
- Assertion.AssertEquals ("#2", "http://www.contoso.com", uri.GetLeftPart (UriPartial.Authority));
- Assertion.AssertEquals ("#3", "http://www.contoso.com/index.htm", uri.GetLeftPart (UriPartial.Path));
-
- uri = new Uri ("mailto:user@contoso.com?subject=uri");
- Assertion.AssertEquals ("#4", "mailto:", uri.GetLeftPart (UriPartial.Scheme));
- Assertion.AssertEquals ("#5", "", uri.GetLeftPart (UriPartial.Authority));
- Assertion.AssertEquals ("#6", "mailto:user@contoso.com", uri.GetLeftPart (UriPartial.Path));
-
- uri = new Uri ("nntp://news.contoso.com/123456@contoso.com");
- Assertion.AssertEquals ("#7", "nntp://", uri.GetLeftPart (UriPartial.Scheme));
- Assertion.AssertEquals ("#8", "nntp://news.contoso.com", uri.GetLeftPart (UriPartial.Authority));
- Assertion.AssertEquals ("#9", "nntp://news.contoso.com/123456@contoso.com", uri.GetLeftPart (UriPartial.Path));
-
- uri = new Uri ("news:123456@contoso.com");
- Assertion.AssertEquals ("#10", "news:", uri.GetLeftPart (UriPartial.Scheme));
- Assertion.AssertEquals ("#11", "", uri.GetLeftPart (UriPartial.Authority));
- Assertion.AssertEquals ("#12", "news:123456@contoso.com", uri.GetLeftPart (UriPartial.Path));
-
- uri = new Uri ("file://server/filename.ext");
- Assertion.AssertEquals ("#13", "file://", uri.GetLeftPart (UriPartial.Scheme));
- Assertion.AssertEquals ("#14", "file://server", uri.GetLeftPart (UriPartial.Authority));
- Assertion.AssertEquals ("#15", "file://server/filename.ext", uri.GetLeftPart (UriPartial.Path));
-
- uri = new Uri (@"\\server\share\filename.ext");
- Assertion.AssertEquals ("#20", "file://", uri.GetLeftPart (UriPartial.Scheme));
- Assertion.AssertEquals ("#21", "file://server", uri.GetLeftPart (UriPartial.Authority));
- Assertion.AssertEquals ("#22", "file://server/share/filename.ext", uri.GetLeftPart (UriPartial.Path));
-
- uri = new Uri ("http://www.contoso.com:8080/index.htm#main");
- Assertion.AssertEquals ("#23", "http://", uri.GetLeftPart (UriPartial.Scheme));
- Assertion.AssertEquals ("#24", "http://www.contoso.com:8080", uri.GetLeftPart (UriPartial.Authority));
- Assertion.AssertEquals ("#25", "http://www.contoso.com:8080/index.htm", uri.GetLeftPart (UriPartial.Path));
- }
-
- [Test]
- [Ignore("Known to fail under MS runtime")]
- public void GetLeftPart2 ()
- {
- try {
- Uri uri = new Uri ("file:/filename.ext");
- Assertion.AssertEquals ("#16", "file://", uri.GetLeftPart (UriPartial.Scheme));
- Assertion.AssertEquals ("#17", "", uri.GetLeftPart (UriPartial.Authority));
- Assertion.AssertEquals ("#18", "file:///filename.ext", uri.GetLeftPart (UriPartial.Path));
- } catch (UriFormatException) {
- Assertion.Fail ("#19: known to fail with ms.net (it's their own example!)");
- }
- }
-
- [Test]
- public void CheckHostName ()
- {
- Assertion.AssertEquals ("#1", UriHostNameType.Unknown, Uri.CheckHostName (null));
- Assertion.AssertEquals ("#2", UriHostNameType.Unknown, Uri.CheckHostName (""));
- Assertion.AssertEquals ("#3", UriHostNameType.Unknown, Uri.CheckHostName ("^&()~`!@"));
- Assertion.AssertEquals ("#4", UriHostNameType.Dns, Uri.CheckHostName ("x"));
- Assertion.AssertEquals ("#5", UriHostNameType.IPv4, Uri.CheckHostName ("1.2.3.4"));
- Assertion.AssertEquals ("#6", UriHostNameType.IPv4, Uri.CheckHostName ("0001.002.03.4"));
- Assertion.AssertEquals ("#7", UriHostNameType.Dns, Uri.CheckHostName ("0001.002.03.256"));
- Assertion.AssertEquals ("#8", UriHostNameType.Dns, Uri.CheckHostName ("9001.002.03.4"));
- Assertion.AssertEquals ("#9", UriHostNameType.Dns, Uri.CheckHostName ("www.contoso.com"));
- Assertion.AssertEquals ("#10", UriHostNameType.Unknown, Uri.CheckHostName (".www.contoso.com"));
- Assertion.AssertEquals ("#11: known to fail with ms.net: this is not a valid domain address", UriHostNameType.Unknown, Uri.CheckHostName ("www.contoso.com."));
- Assertion.AssertEquals ("#12", UriHostNameType.Dns, Uri.CheckHostName ("www.con-toso.com"));
- Assertion.AssertEquals ("#13", UriHostNameType.Dns, Uri.CheckHostName ("www.con_toso.com"));
- Assertion.AssertEquals ("#14", UriHostNameType.Unknown, Uri.CheckHostName ("www.con,toso.com"));
-
- // test IPv6
- Assertion.AssertEquals ("#15", UriHostNameType.IPv6, Uri.CheckHostName ("11:22:33:44:55:66:77:88"));
- Assertion.AssertEquals ("#16", UriHostNameType.IPv6, Uri.CheckHostName ("11::33:44:55:66:77:88"));
- Assertion.AssertEquals ("#17", UriHostNameType.IPv6, Uri.CheckHostName ("::22:33:44:55:66:77:88"));
- Assertion.AssertEquals ("#18", UriHostNameType.IPv6, Uri.CheckHostName ("11:22:33:44:55:66:77::"));
- Assertion.AssertEquals ("#19", UriHostNameType.IPv6, Uri.CheckHostName ("11::88"));
- Assertion.AssertEquals ("#20", UriHostNameType.IPv6, Uri.CheckHostName ("11::77:88"));
- Assertion.AssertEquals ("#21", UriHostNameType.IPv6, Uri.CheckHostName ("11:22::88"));
- Assertion.AssertEquals ("#22", UriHostNameType.IPv6, Uri.CheckHostName ("11::"));
- Assertion.AssertEquals ("#23", UriHostNameType.IPv6, Uri.CheckHostName ("::88"));
- Assertion.AssertEquals ("#24", UriHostNameType.IPv6, Uri.CheckHostName ("::1"));
- Assertion.AssertEquals ("#25", UriHostNameType.IPv6, Uri.CheckHostName ("::"));
- Assertion.AssertEquals ("#26", UriHostNameType.IPv6, Uri.CheckHostName ("0:0:0:0:0:0:127.0.0.1"));
- Assertion.AssertEquals ("#27", UriHostNameType.IPv6, Uri.CheckHostName ("::127.0.0.1"));
- Assertion.AssertEquals ("#28", UriHostNameType.IPv6, Uri.CheckHostName ("::ffFF:169.32.14.5"));
- Assertion.AssertEquals ("#29", UriHostNameType.IPv6, Uri.CheckHostName ("2001:03A0::/35"));
- Assertion.AssertEquals ("#30", UriHostNameType.IPv6, Uri.CheckHostName ("[2001:03A0::/35]"));
-
- Assertion.AssertEquals ("#31", UriHostNameType.Unknown, Uri.CheckHostName ("2001::03A0::/35"));
- Assertion.AssertEquals ("#32", UriHostNameType.Unknown, Uri.CheckHostName ("2001:03A0::/35a"));
- Assertion.AssertEquals ("#33 known to fail with ms.net: this is not a valid IPv6 address.", UriHostNameType.Unknown, Uri.CheckHostName ("2001::03A0:1.2.3.4"));
- Assertion.AssertEquals ("#34", UriHostNameType.Unknown, Uri.CheckHostName ("::ffff:123.256.155.43"));
- Assertion.AssertEquals ("#35", UriHostNameType.Unknown, Uri.CheckHostName (":127.0.0.1"));
- Assertion.AssertEquals ("#36 known to fail with ms.net: this is not a valid IPv6 address.", UriHostNameType.Unknown, Uri.CheckHostName (":11:22:33:44:55:66:77:88"));
- Assertion.AssertEquals ("#37", UriHostNameType.Unknown, Uri.CheckHostName ("::11:22:33:44:55:66:77:88"));
- Assertion.AssertEquals ("#38", UriHostNameType.Unknown, Uri.CheckHostName ("11:22:33:44:55:66:77:88::"));
- Assertion.AssertEquals ("#39", UriHostNameType.Unknown, Uri.CheckHostName ("11:22:33:44:55:66:77:88:"));
- Assertion.AssertEquals ("#40", UriHostNameType.Unknown, Uri.CheckHostName ("::acbde"));
- Assertion.AssertEquals ("#41", UriHostNameType.Unknown, Uri.CheckHostName ("::abce:"));
- Assertion.AssertEquals ("#42", UriHostNameType.Unknown, Uri.CheckHostName ("::abcg"));
- Assertion.AssertEquals ("#43", UriHostNameType.Unknown, Uri.CheckHostName (":::"));
- Assertion.AssertEquals ("#44", UriHostNameType.Unknown, Uri.CheckHostName (":"));
- }
-
- [Test]
- public void IsLoopback ()
- {
- Uri uri = new Uri("http://loopback:8080");
- Assertion.AssertEquals ("#1", true, uri.IsLoopback);
- uri = new Uri("http://localhost:8080");
- Assertion.AssertEquals ("#2", true, uri.IsLoopback);
- uri = new Uri("http://127.0.0.1:8080");
- Assertion.AssertEquals ("#3", true, uri.IsLoopback);
- uri = new Uri("http://127.0.0.001:8080");
- Assertion.AssertEquals ("#4", true, uri.IsLoopback);
- uri = new Uri("http://[::1]");
- Assertion.AssertEquals ("#5", true, uri.IsLoopback);
- uri = new Uri("http://[::1]:8080");
- Assertion.AssertEquals ("#6", true, uri.IsLoopback);
- uri = new Uri("http://[::0001]:8080");
- Assertion.AssertEquals ("#7", true, uri.IsLoopback);
- uri = new Uri("http://[0:0:0:0::1]:8080");
- Assertion.AssertEquals ("#8", true, uri.IsLoopback);
- uri = new Uri("http://[0:0:0:0::127.0.0.1]:8080");
- Assertion.AssertEquals ("#9", true, uri.IsLoopback);
- uri = new Uri("http://[0:0:0:0::127.11.22.33]:8080");
- Assertion.AssertEquals ("#10: known to fail with ms.net", true, uri.IsLoopback);
- uri = new Uri("http://[::ffff:127.11.22.33]:8080");
- Assertion.AssertEquals ("#11: known to fail with ms.net", true, uri.IsLoopback);
- uri = new Uri("http://[::ff00:7f11:2233]:8080");
- Assertion.AssertEquals ("#12", false, uri.IsLoopback);
- uri = new Uri("http://[1:0:0:0::1]:8080");
- Assertion.AssertEquals ("#13", false, uri.IsLoopback);
- }
-
- [Test]
- public void Equals ()
- {
- Uri uri1 = new Uri ("http://www.contoso.com/index.htm#main");
- Uri uri2 = new Uri ("http://www.contoso.com/index.htm#fragment");
- Assertion.Assert ("#1", uri1.Equals (uri2));
- uri2 = new Uri ("http://www.contoso.com/index.htm?x=1");
- Assertion.Assert ("#2 known to fail with ms.net", !uri1.Equals (uri2));
- Assertion.Assert ("#3", !uri2.Equals ("http://www.contoso.com/index.html?x=1"));
- Assertion.Assert ("#4: known to fail with ms.net", !uri1.Equals ("http://www.contoso.com:8080/index.htm?x=1"));
- }
-
- [Test]
- public void GetHashCodeTest ()
- {
- Uri uri1 = new Uri ("http://www.contoso.com/index.htm#main");
- Uri uri2 = new Uri ("http://www.contoso.com/index.htm#fragment");
- Assertion.AssertEquals ("#1", uri1.GetHashCode (), uri2.GetHashCode ());
- uri2 = new Uri ("http://www.contoso.com/index.htm?x=1");
- Assertion.Assert ("#2", uri1.GetHashCode () != uri2.GetHashCode ());
- uri2 = new Uri ("http://www.contoso.com:80/index.htm");
- Assertion.AssertEquals ("#3", uri1.GetHashCode (), uri2.GetHashCode ());
- uri2 = new Uri ("http://www.contoso.com:8080/index.htm");
- Assertion.Assert ("#4", uri1.GetHashCode () != uri2.GetHashCode ());
- }
-
- [Test]
- public void MakeRelative ()
- {
- Uri uri1 = new Uri ("http://www.contoso.com/index.htm?x=2");
- Uri uri2 = new Uri ("http://www.contoso.com/foo/bar/index.htm#fragment");
- Uri uri3 = new Uri ("http://www.contoso.com/bar/foo/index.htm?y=1");
- Uri uri4 = new Uri ("http://www.contoso.com/bar/foo2/index.htm?x=0");
- Uri uri5 = new Uri ("https://www.contoso.com/bar/foo/index.htm?y=1");
- Uri uri6 = new Uri ("http://www.contoso2.com/bar/foo/index.htm?x=0");
- Uri uri7 = new Uri ("http://www.contoso2.com/bar/foo/foobar.htm?z=0&y=5");
- Uri uri8 = new Uri ("http://www.xxx.com/bar/foo/foobar.htm?z=0&y=5" + (char) 0xa9);
-
- Assertion.AssertEquals ("#1", "foo/bar/index.htm", uri1.MakeRelative (uri2));
- Assertion.AssertEquals ("#2", "../../index.htm", uri2.MakeRelative (uri1));
-
- Assertion.AssertEquals ("#3", "../../bar/foo/index.htm", uri2.MakeRelative (uri3));
- Assertion.AssertEquals ("#4", "../../foo/bar/index.htm", uri3.MakeRelative (uri2));
-
- Assertion.AssertEquals ("#5", "../foo2/index.htm", uri3.MakeRelative (uri4));
- Assertion.AssertEquals ("#6", "../foo/index.htm", uri4.MakeRelative (uri3));
-
- Assertion.AssertEquals ("#7", "https://www.contoso.com/bar/foo/index.htm?y=1",
- uri4.MakeRelative (uri5));
-
- Assertion.AssertEquals ("#8", "http://www.contoso2.com/bar/foo/index.htm?x=0",
- uri4.MakeRelative (uri6));
-
- Assertion.AssertEquals ("#9", "", uri6.MakeRelative (uri6));
- Assertion.AssertEquals ("#10", "foobar.htm", uri6.MakeRelative (uri7));
-
- Uri uri10 = new Uri ("mailto:xxx@xxx.com");
- Uri uri11 = new Uri ("mailto:xxx@xxx.com?subject=hola");
- Assertion.AssertEquals ("#11", "", uri10.MakeRelative (uri11));
-
- Uri uri12 = new Uri ("mailto:xxx@mail.xxx.com?subject=hola");
- Assertion.AssertEquals ("#12", "mailto:xxx@mail.xxx.com?subject=hola", uri10.MakeRelative (uri12));
-
- Uri uri13 = new Uri ("mailto:xxx@xxx.com/foo/bar");
- Assertion.AssertEquals ("#13", "/foo/bar", uri10.MakeRelative (uri13));
-
- Assertion.AssertEquals ("#14", "http://www.xxx.com/bar/foo/foobar.htm?z=0&y=5" + (char) 0xa9, uri1.MakeRelative (uri8));
- }
-
- [Test]
- public void ToStringTest()
- {
- Uri uri = new Uri ("dummy://xxx");
- Assertion.AssertEquals ("#1", "dummy://xxx/", uri.ToString ());
- }
-
- [Test]
- public void CheckSchemeName ()
- {
- Assertion.AssertEquals ("#01", false, Uri.CheckSchemeName (null));
- Assertion.AssertEquals ("#02", false, Uri.CheckSchemeName (""));
- Assertion.AssertEquals ("#03", true, Uri.CheckSchemeName ("http"));
- Assertion.AssertEquals ("#04", true, Uri.CheckSchemeName ("http-"));
- Assertion.AssertEquals ("#05", false, Uri.CheckSchemeName ("6http-"));
- Assertion.AssertEquals ("#06", true, Uri.CheckSchemeName ("http6-"));
- Assertion.AssertEquals ("#07", false, Uri.CheckSchemeName ("http6,"));
- Assertion.AssertEquals ("#08", true, Uri.CheckSchemeName ("http6."));
- Assertion.AssertEquals ("#09", false, Uri.CheckSchemeName ("+http"));
- Assertion.AssertEquals ("#10", true, Uri.CheckSchemeName ("htt+p6"));
- // 0x00E1 -> &atilde;
- Assertion.AssertEquals ("#11", true, Uri.CheckSchemeName ("htt\u00E1+p6"));
- }
-
- [Test]
- [ExpectedException (typeof (UriFormatException))]
- public void NoHostname ()
- {
- Uri uri = new Uri ("http://");
- }
-
- [Test]
- [ExpectedException (typeof (UriFormatException))]
- [Ignore ("MS throws an IndexOutOfRangeException. Bug?")]
- public void NoHostname2 ()
- {
- Uri uri = new Uri ("file://");
- }
-
- [Test]
- public void Segments1 ()
- {
- Uri uri = new Uri ("http://localhost/");
- string [] segments = uri.Segments;
- Assertion.AssertEquals ("#01", 1, segments.Length);
- Assertion.AssertEquals ("#02", "/", segments [0]);
-
- }
-
- [Test]
- public void Segments2 ()
- {
- Uri uri = new Uri ("http://localhost/dir/dummypage.html");
- string [] segments = uri.Segments;
- Assertion.AssertEquals ("#01", 3, segments.Length);
- Assertion.AssertEquals ("#02", "/", segments [0]);
- Assertion.AssertEquals ("#03", "dir/", segments [1]);
- Assertion.AssertEquals ("#04", "dummypage.html", segments [2]);
-
- }
-
- [Test]
- public void Segments3 ()
- {
- Uri uri = new Uri ("http://localhost/dir/dummypage/");
- string [] segments = uri.Segments;
- Assertion.AssertEquals ("#01", 3, segments.Length);
- Assertion.AssertEquals ("#02", "/", segments [0]);
- Assertion.AssertEquals ("#03", "dir/", segments [1]);
- Assertion.AssertEquals ("#04", "dummypage/", segments [2]);
-
- }
-
- [Test]
- public void Segments4 ()
- {
- Uri uri = new Uri ("file:///c:/hello");
- string [] segments = uri.Segments;
- Assertion.AssertEquals ("#01", 3, segments.Length);
- Assertion.AssertEquals ("#02", "c:", segments [0]);
- Assertion.AssertEquals ("#03", "/", segments [1]);
- Assertion.AssertEquals ("#04", "hello", segments [2]);
-
- }
-
- [Test]
- [ExpectedException (typeof (UriFormatException))]
- public void EmptyScheme ()
- {
- new Uri ("hey");
- }
-
- [Test]
- public void InvalidPortsThatWorkWithMS ()
- {
- new Uri ("http://www.contoso.com:12345678/foo/bar/");
- // UInt32.MaxValue gives port == -1 !!!
- new Uri ("http://www.contoso.com:4294967295/foo/bar/");
- // ((uint) Int32.MaxValue + (uint) 1) gives port == -2147483648 !!!
- new Uri ("http://www.contoso.com:2147483648/foo/bar/");
- }
-
- public static void Print (Uri uri)
- {
- Console.WriteLine ("ToString: " + uri.ToString ());
-
- Console.WriteLine ("AbsolutePath: " + uri.AbsolutePath);
- Console.WriteLine ("AbsoluteUri: " + uri.AbsoluteUri);
- Console.WriteLine ("Authority: " + uri.Authority);
- Console.WriteLine ("Fragment: " + uri.Fragment);
- Console.WriteLine ("Host: " + uri.Host);
- Console.WriteLine ("HostNameType: " + uri.HostNameType);
- Console.WriteLine ("IsDefaultPort: " + uri.IsDefaultPort);
- Console.WriteLine ("IsFile: " + uri.IsFile);
- Console.WriteLine ("IsLoopback: " + uri.IsLoopback);
- Console.WriteLine ("IsUnc: " + uri.IsUnc);
- Console.WriteLine ("LocalPath: " + uri.LocalPath);
- Console.WriteLine ("PathAndQuery: " + uri.PathAndQuery);
- Console.WriteLine ("Port: " + uri.Port);
- Console.WriteLine ("Query: " + uri.Query);
- Console.WriteLine ("Scheme: " + uri.Scheme);
- Console.WriteLine ("UserEscaped: " + uri.UserEscaped);
- Console.WriteLine ("UserInfo: " + uri.UserInfo);
-
- Console.WriteLine ("Segments:");
- string [] segments = uri.Segments;
- if (segments == null)
- Console.WriteLine ("\tNo Segments");
- else
- for (int i = 0; i < segments.Length; i++)
- Console.WriteLine ("\t" + segments[i]);
- Console.WriteLine ("");
- }
-
- }
-}
-
+
+ [Test]
+ public void Unc ()
+ {
+ Uri uri = new Uri ("http://www.contoso.com");
+ Assertion.Assert ("#1", !uri.IsUnc);
+
+ uri = new Uri ("news:123456@contoso.com");
+ Assertion.Assert ("#2", !uri.IsUnc);
+
+ uri = new Uri ("file://server/filename.ext");
+ Assertion.Assert ("#3", uri.IsUnc);
+
+ uri = new Uri (@"\\server\share\filename.ext");
+ Assertion.Assert ("#6", uri.IsUnc);
+ }
+
+ [Test]
+ [Ignore ("Known to fail under MS runtime")]
+ public void Unc2 ()
+ {
+ try {
+ Uri uri = new Uri ("file:/filename.ext");
+ Assertion.Assert ("#4", uri.IsUnc);
+ } catch (UriFormatException) {
+ Assertion.Fail ("#5: known to fail with ms.net");
+ }
+ }
+
+ [Test]
+ public void FromHex ()
+ {
+ Assertion.AssertEquals ("#1", 0, Uri.FromHex ('0'));
+ Assertion.AssertEquals ("#2", 9, Uri.FromHex ('9'));
+ Assertion.AssertEquals ("#3", 10, Uri.FromHex ('a'));
+ Assertion.AssertEquals ("#4", 15, Uri.FromHex ('f'));
+ Assertion.AssertEquals ("#5", 10, Uri.FromHex ('A'));
+ Assertion.AssertEquals ("#6", 15, Uri.FromHex ('F'));
+ try {
+ Uri.FromHex ('G');
+ Assertion.Fail ("#7");
+ } catch (ArgumentException) {}
+ try {
+ Uri.FromHex (' ');
+ Assertion.Fail ("#8");
+ } catch (ArgumentException) {}
+ try {
+ Uri.FromHex ('%');
+ Assertion.Fail ("#8");
+ } catch (ArgumentException) {}
+ }
+
+ [Test]
+ public void HexEscape ()
+ {
+ Assertion.AssertEquals ("#1","%20", Uri.HexEscape (' '));
+ Assertion.AssertEquals ("#2","%A9", Uri.HexEscape ((char) 0xa9));
+ Assertion.AssertEquals ("#3","%41", Uri.HexEscape ('A'));
+ try {
+ Uri.HexEscape ((char) 0x0369);
+ Assertion.Fail ("#4");
+ } catch (ArgumentOutOfRangeException) {}
+ }
+
+ [Test]
+ public void HexUnescape ()
+ {
+ int i = 0;
+ Assertion.AssertEquals ("#1", ' ', Uri.HexUnescape ("%20", ref i));
+ Assertion.AssertEquals ("#2", 3, i);
+ i = 4;
+ Assertion.AssertEquals ("#3", (char) 0xa9, Uri.HexUnescape ("test%a9test", ref i));
+ Assertion.AssertEquals ("#4", 7, i);
+ Assertion.AssertEquals ("#5", 't', Uri.HexUnescape ("test%a9test", ref i));
+ Assertion.AssertEquals ("#6", 8, i);
+ i = 4;
+ Assertion.AssertEquals ("#5", '%', Uri.HexUnescape ("test%a", ref i));
+ Assertion.AssertEquals ("#6", 5, i);
+ Assertion.AssertEquals ("#7", '%', Uri.HexUnescape ("testx%xx", ref i));
+ Assertion.AssertEquals ("#8", 6, i);
+ }
+
+ [Test]
+ public void IsHexDigit ()
+ {
+ Assertion.Assert ("#1", Uri.IsHexDigit ('a'));
+ Assertion.Assert ("#2", Uri.IsHexDigit ('f'));
+ Assertion.Assert ("#3", !Uri.IsHexDigit ('g'));
+ Assertion.Assert ("#4", Uri.IsHexDigit ('0'));
+ Assertion.Assert ("#5", Uri.IsHexDigit ('9'));
+ Assertion.Assert ("#6", Uri.IsHexDigit ('A'));
+ Assertion.Assert ("#7", Uri.IsHexDigit ('F'));
+ Assertion.Assert ("#8", !Uri.IsHexDigit ('G'));
+ }
+
+ [Test]
+ public void IsHexEncoding ()
+ {
+ Assertion.Assert ("#1", Uri.IsHexEncoding ("test%a9test", 4));
+ Assertion.Assert ("#2", !Uri.IsHexEncoding ("test%a9test", 3));
+ Assertion.Assert ("#3", Uri.IsHexEncoding ("test%a9", 4));
+ Assertion.Assert ("#4", !Uri.IsHexEncoding ("test%a", 4));
+ }
+
+ [Test]
+ public void GetLeftPart ()
+ {
+ Uri uri = new Uri ("http://www.contoso.com/index.htm#main");
+ Assertion.AssertEquals ("#1", "http://", uri.GetLeftPart (UriPartial.Scheme));
+ Assertion.AssertEquals ("#2", "http://www.contoso.com", uri.GetLeftPart (UriPartial.Authority));
+ Assertion.AssertEquals ("#3", "http://www.contoso.com/index.htm", uri.GetLeftPart (UriPartial.Path));
+
+ uri = new Uri ("mailto:user@contoso.com?subject=uri");
+ Assertion.AssertEquals ("#4", "mailto:", uri.GetLeftPart (UriPartial.Scheme));
+ Assertion.AssertEquals ("#5", "", uri.GetLeftPart (UriPartial.Authority));
+ Assertion.AssertEquals ("#6", "mailto:user@contoso.com", uri.GetLeftPart (UriPartial.Path));
+
+ uri = new Uri ("nntp://news.contoso.com/123456@contoso.com");
+ Assertion.AssertEquals ("#7", "nntp://", uri.GetLeftPart (UriPartial.Scheme));
+ Assertion.AssertEquals ("#8", "nntp://news.contoso.com", uri.GetLeftPart (UriPartial.Authority));
+ Assertion.AssertEquals ("#9", "nntp://news.contoso.com/123456@contoso.com", uri.GetLeftPart (UriPartial.Path));
+
+ uri = new Uri ("news:123456@contoso.com");
+ Assertion.AssertEquals ("#10", "news:", uri.GetLeftPart (UriPartial.Scheme));
+ Assertion.AssertEquals ("#11", "", uri.GetLeftPart (UriPartial.Authority));
+ Assertion.AssertEquals ("#12", "news:123456@contoso.com", uri.GetLeftPart (UriPartial.Path));
+
+ uri = new Uri ("file://server/filename.ext");
+ Assertion.AssertEquals ("#13", "file://", uri.GetLeftPart (UriPartial.Scheme));
+ Assertion.AssertEquals ("#14", "file://server", uri.GetLeftPart (UriPartial.Authority));
+ Assertion.AssertEquals ("#15", "file://server/filename.ext", uri.GetLeftPart (UriPartial.Path));
+
+ uri = new Uri (@"\\server\share\filename.ext");
+ Assertion.AssertEquals ("#20", "file://", uri.GetLeftPart (UriPartial.Scheme));
+ Assertion.AssertEquals ("#21", "file://server", uri.GetLeftPart (UriPartial.Authority));
+ Assertion.AssertEquals ("#22", "file://server/share/filename.ext", uri.GetLeftPart (UriPartial.Path));
+
+ uri = new Uri ("http://www.contoso.com:8080/index.htm#main");
+ Assertion.AssertEquals ("#23", "http://", uri.GetLeftPart (UriPartial.Scheme));
+ Assertion.AssertEquals ("#24", "http://www.contoso.com:8080", uri.GetLeftPart (UriPartial.Authority));
+ Assertion.AssertEquals ("#25", "http://www.contoso.com:8080/index.htm", uri.GetLeftPart (UriPartial.Path));
+ }
+
+ [Test]
+ [Ignore("Known to fail under MS runtime")]
+ public void GetLeftPart2 ()
+ {
+ try {
+ Uri uri = new Uri ("file:/filename.ext");
+ Assertion.AssertEquals ("#16", "file://", uri.GetLeftPart (UriPartial.Scheme));
+ Assertion.AssertEquals ("#17", "", uri.GetLeftPart (UriPartial.Authority));
+ Assertion.AssertEquals ("#18", "file:///filename.ext", uri.GetLeftPart (UriPartial.Path));
+ } catch (UriFormatException) {
+ Assertion.Fail ("#19: known to fail with ms.net (it's their own example!)");
+ }
+ }
+
+ [Test]
+ public void CheckHostName ()
+ {
+ Assertion.AssertEquals ("#1", UriHostNameType.Unknown, Uri.CheckHostName (null));
+ Assertion.AssertEquals ("#2", UriHostNameType.Unknown, Uri.CheckHostName (""));
+ Assertion.AssertEquals ("#3", UriHostNameType.Unknown, Uri.CheckHostName ("^&()~`!@"));
+ Assertion.AssertEquals ("#4", UriHostNameType.Dns, Uri.CheckHostName ("x"));
+ Assertion.AssertEquals ("#5", UriHostNameType.IPv4, Uri.CheckHostName ("1.2.3.4"));
+ Assertion.AssertEquals ("#6", UriHostNameType.IPv4, Uri.CheckHostName ("0001.002.03.4"));
+ Assertion.AssertEquals ("#7", UriHostNameType.Dns, Uri.CheckHostName ("0001.002.03.256"));
+ Assertion.AssertEquals ("#8", UriHostNameType.Dns, Uri.CheckHostName ("9001.002.03.4"));
+ Assertion.AssertEquals ("#9", UriHostNameType.Dns, Uri.CheckHostName ("www.contoso.com"));
+ Assertion.AssertEquals ("#10", UriHostNameType.Unknown, Uri.CheckHostName (".www.contoso.com"));
+ Assertion.AssertEquals ("#11: known to fail with ms.net: this is not a valid domain address", UriHostNameType.Unknown, Uri.CheckHostName ("www.contoso.com."));
+ Assertion.AssertEquals ("#12", UriHostNameType.Dns, Uri.CheckHostName ("www.con-toso.com"));
+ Assertion.AssertEquals ("#13", UriHostNameType.Dns, Uri.CheckHostName ("www.con_toso.com"));
+ Assertion.AssertEquals ("#14", UriHostNameType.Unknown, Uri.CheckHostName ("www.con,toso.com"));
+
+ // test IPv6
+ Assertion.AssertEquals ("#15", UriHostNameType.IPv6, Uri.CheckHostName ("11:22:33:44:55:66:77:88"));
+ Assertion.AssertEquals ("#16", UriHostNameType.IPv6, Uri.CheckHostName ("11::33:44:55:66:77:88"));
+ Assertion.AssertEquals ("#17", UriHostNameType.IPv6, Uri.CheckHostName ("::22:33:44:55:66:77:88"));
+ Assertion.AssertEquals ("#18", UriHostNameType.IPv6, Uri.CheckHostName ("11:22:33:44:55:66:77::"));
+ Assertion.AssertEquals ("#19", UriHostNameType.IPv6, Uri.CheckHostName ("11::88"));
+ Assertion.AssertEquals ("#20", UriHostNameType.IPv6, Uri.CheckHostName ("11::77:88"));
+ Assertion.AssertEquals ("#21", UriHostNameType.IPv6, Uri.CheckHostName ("11:22::88"));
+ Assertion.AssertEquals ("#22", UriHostNameType.IPv6, Uri.CheckHostName ("11::"));
+ Assertion.AssertEquals ("#23", UriHostNameType.IPv6, Uri.CheckHostName ("::88"));
+ Assertion.AssertEquals ("#24", UriHostNameType.IPv6, Uri.CheckHostName ("::1"));
+ Assertion.AssertEquals ("#25", UriHostNameType.IPv6, Uri.CheckHostName ("::"));
+ Assertion.AssertEquals ("#26", UriHostNameType.IPv6, Uri.CheckHostName ("0:0:0:0:0:0:127.0.0.1"));
+ Assertion.AssertEquals ("#27", UriHostNameType.IPv6, Uri.CheckHostName ("::127.0.0.1"));
+ Assertion.AssertEquals ("#28", UriHostNameType.IPv6, Uri.CheckHostName ("::ffFF:169.32.14.5"));
+ Assertion.AssertEquals ("#29", UriHostNameType.IPv6, Uri.CheckHostName ("2001:03A0::/35"));
+ Assertion.AssertEquals ("#30", UriHostNameType.IPv6, Uri.CheckHostName ("[2001:03A0::/35]"));
+
+ Assertion.AssertEquals ("#31", UriHostNameType.Unknown, Uri.CheckHostName ("2001::03A0::/35"));
+ Assertion.AssertEquals ("#32", UriHostNameType.Unknown, Uri.CheckHostName ("2001:03A0::/35a"));
+ Assertion.AssertEquals ("#33 known to fail with ms.net: this is not a valid IPv6 address.", UriHostNameType.Unknown, Uri.CheckHostName ("2001::03A0:1.2.3.4"));
+ Assertion.AssertEquals ("#34", UriHostNameType.Unknown, Uri.CheckHostName ("::ffff:123.256.155.43"));
+ Assertion.AssertEquals ("#35", UriHostNameType.Unknown, Uri.CheckHostName (":127.0.0.1"));
+ Assertion.AssertEquals ("#36 known to fail with ms.net: this is not a valid IPv6 address.", UriHostNameType.Unknown, Uri.CheckHostName (":11:22:33:44:55:66:77:88"));
+ Assertion.AssertEquals ("#37", UriHostNameType.Unknown, Uri.CheckHostName ("::11:22:33:44:55:66:77:88"));
+ Assertion.AssertEquals ("#38", UriHostNameType.Unknown, Uri.CheckHostName ("11:22:33:44:55:66:77:88::"));
+ Assertion.AssertEquals ("#39", UriHostNameType.Unknown, Uri.CheckHostName ("11:22:33:44:55:66:77:88:"));
+ Assertion.AssertEquals ("#40", UriHostNameType.Unknown, Uri.CheckHostName ("::acbde"));
+ Assertion.AssertEquals ("#41", UriHostNameType.Unknown, Uri.CheckHostName ("::abce:"));
+ Assertion.AssertEquals ("#42", UriHostNameType.Unknown, Uri.CheckHostName ("::abcg"));
+ Assertion.AssertEquals ("#43", UriHostNameType.Unknown, Uri.CheckHostName (":::"));
+ Assertion.AssertEquals ("#44", UriHostNameType.Unknown, Uri.CheckHostName (":"));
+ }
+
+ [Test]
+ public void IsLoopback ()
+ {
+ Uri uri = new Uri("http://loopback:8080");
+ Assertion.AssertEquals ("#1", true, uri.IsLoopback);
+ uri = new Uri("http://localhost:8080");
+ Assertion.AssertEquals ("#2", true, uri.IsLoopback);
+ uri = new Uri("http://127.0.0.1:8080");
+ Assertion.AssertEquals ("#3", true, uri.IsLoopback);
+ uri = new Uri("http://127.0.0.001:8080");
+ Assertion.AssertEquals ("#4", true, uri.IsLoopback);
+ uri = new Uri("http://[::1]");
+ Assertion.AssertEquals ("#5", true, uri.IsLoopback);
+ uri = new Uri("http://[::1]:8080");
+ Assertion.AssertEquals ("#6", true, uri.IsLoopback);
+ uri = new Uri("http://[::0001]:8080");
+ Assertion.AssertEquals ("#7", true, uri.IsLoopback);
+ uri = new Uri("http://[0:0:0:0::1]:8080");
+ Assertion.AssertEquals ("#8", true, uri.IsLoopback);
+ uri = new Uri("http://[0:0:0:0::127.0.0.1]:8080");
+ Assertion.AssertEquals ("#9", true, uri.IsLoopback);
+ uri = new Uri("http://[0:0:0:0::127.11.22.33]:8080");
+ Assertion.AssertEquals ("#10: known to fail with ms.net", true, uri.IsLoopback);
+ uri = new Uri("http://[::ffff:127.11.22.33]:8080");
+ Assertion.AssertEquals ("#11: known to fail with ms.net", true, uri.IsLoopback);
+ uri = new Uri("http://[::ff00:7f11:2233]:8080");
+ Assertion.AssertEquals ("#12", false, uri.IsLoopback);
+ uri = new Uri("http://[1:0:0:0::1]:8080");
+ Assertion.AssertEquals ("#13", false, uri.IsLoopback);
+ }
+
+ [Test]
+ public void Equals ()
+ {
+ Uri uri1 = new Uri ("http://www.contoso.com/index.htm#main");
+ Uri uri2 = new Uri ("http://www.contoso.com/index.htm#fragment");
+ Assertion.Assert ("#1", uri1.Equals (uri2));
+ uri2 = new Uri ("http://www.contoso.com/index.htm?x=1");
+ Assertion.Assert ("#2 known to fail with ms.net", !uri1.Equals (uri2));
+ Assertion.Assert ("#3", !uri2.Equals ("http://www.contoso.com/index.html?x=1"));
+ Assertion.Assert ("#4: known to fail with ms.net", !uri1.Equals ("http://www.contoso.com:8080/index.htm?x=1"));
+ }
+
+ [Test]
+ public void GetHashCodeTest ()
+ {
+ Uri uri1 = new Uri ("http://www.contoso.com/index.htm#main");
+ Uri uri2 = new Uri ("http://www.contoso.com/index.htm#fragment");
+ Assertion.AssertEquals ("#1", uri1.GetHashCode (), uri2.GetHashCode ());
+ uri2 = new Uri ("http://www.contoso.com/index.htm?x=1");
+ Assertion.Assert ("#2", uri1.GetHashCode () != uri2.GetHashCode ());
+ uri2 = new Uri ("http://www.contoso.com:80/index.htm");
+ Assertion.AssertEquals ("#3", uri1.GetHashCode (), uri2.GetHashCode ());
+ uri2 = new Uri ("http://www.contoso.com:8080/index.htm");
+ Assertion.Assert ("#4", uri1.GetHashCode () != uri2.GetHashCode ());
+ }
+
+ [Test]
+ public void MakeRelative ()
+ {
+ Uri uri1 = new Uri ("http://www.contoso.com/index.htm?x=2");
+ Uri uri2 = new Uri ("http://www.contoso.com/foo/bar/index.htm#fragment");
+ Uri uri3 = new Uri ("http://www.contoso.com/bar/foo/index.htm?y=1");
+ Uri uri4 = new Uri ("http://www.contoso.com/bar/foo2/index.htm?x=0");
+ Uri uri5 = new Uri ("https://www.contoso.com/bar/foo/index.htm?y=1");
+ Uri uri6 = new Uri ("http://www.contoso2.com/bar/foo/index.htm?x=0");
+ Uri uri7 = new Uri ("http://www.contoso2.com/bar/foo/foobar.htm?z=0&y=5");
+ Uri uri8 = new Uri ("http://www.xxx.com/bar/foo/foobar.htm?z=0&y=5" + (char) 0xa9);
+
+ Assertion.AssertEquals ("#1", "foo/bar/index.htm", uri1.MakeRelative (uri2));
+ Assertion.AssertEquals ("#2", "../../index.htm", uri2.MakeRelative (uri1));
+
+ Assertion.AssertEquals ("#3", "../../bar/foo/index.htm", uri2.MakeRelative (uri3));
+ Assertion.AssertEquals ("#4", "../../foo/bar/index.htm", uri3.MakeRelative (uri2));
+
+ Assertion.AssertEquals ("#5", "../foo2/index.htm", uri3.MakeRelative (uri4));
+ Assertion.AssertEquals ("#6", "../foo/index.htm", uri4.MakeRelative (uri3));
+
+ Assertion.AssertEquals ("#7", "https://www.contoso.com/bar/foo/index.htm?y=1",
+ uri4.MakeRelative (uri5));
+
+ Assertion.AssertEquals ("#8", "http://www.contoso2.com/bar/foo/index.htm?x=0",
+ uri4.MakeRelative (uri6));
+
+ Assertion.AssertEquals ("#9", "", uri6.MakeRelative (uri6));
+ Assertion.AssertEquals ("#10", "foobar.htm", uri6.MakeRelative (uri7));
+
+ Uri uri10 = new Uri ("mailto:xxx@xxx.com");
+ Uri uri11 = new Uri ("mailto:xxx@xxx.com?subject=hola");
+ Assertion.AssertEquals ("#11", "", uri10.MakeRelative (uri11));
+
+ Uri uri12 = new Uri ("mailto:xxx@mail.xxx.com?subject=hola");
+ Assertion.AssertEquals ("#12", "mailto:xxx@mail.xxx.com?subject=hola", uri10.MakeRelative (uri12));
+
+ Uri uri13 = new Uri ("mailto:xxx@xxx.com/foo/bar");
+ Assertion.AssertEquals ("#13", "/foo/bar", uri10.MakeRelative (uri13));
+
+ Assertion.AssertEquals ("#14", "http://www.xxx.com/bar/foo/foobar.htm?z=0&y=5" + (char) 0xa9, uri1.MakeRelative (uri8));
+ }
+
+ [Test]
+ public void ToStringTest()
+ {
+ Uri uri = new Uri ("dummy://xxx");
+ Assertion.AssertEquals ("#1", "dummy://xxx/", uri.ToString ());
+ }
+
+ [Test]
+ public void CheckSchemeName ()
+ {
+ Assertion.AssertEquals ("#01", false, Uri.CheckSchemeName (null));
+ Assertion.AssertEquals ("#02", false, Uri.CheckSchemeName (""));
+ Assertion.AssertEquals ("#03", true, Uri.CheckSchemeName ("http"));
+ Assertion.AssertEquals ("#04", true, Uri.CheckSchemeName ("http-"));
+ Assertion.AssertEquals ("#05", false, Uri.CheckSchemeName ("6http-"));
+ Assertion.AssertEquals ("#06", true, Uri.CheckSchemeName ("http6-"));
+ Assertion.AssertEquals ("#07", false, Uri.CheckSchemeName ("http6,"));
+ Assertion.AssertEquals ("#08", true, Uri.CheckSchemeName ("http6."));
+ Assertion.AssertEquals ("#09", false, Uri.CheckSchemeName ("+http"));
+ Assertion.AssertEquals ("#10", true, Uri.CheckSchemeName ("htt+p6"));
+ // 0x00E1 -> &atilde;
+ Assertion.AssertEquals ("#11", true, Uri.CheckSchemeName ("htt\u00E1+p6"));
+ }
+
+ [Test]
+ [ExpectedException (typeof (UriFormatException))]
+ public void NoHostname ()
+ {
+ Uri uri = new Uri ("http://");
+ }
+
+ [Test]
+ [ExpectedException (typeof (UriFormatException))]
+ [Ignore ("MS throws an IndexOutOfRangeException. Bug?")]
+ public void NoHostname2 ()
+ {
+ Uri uri = new Uri ("file://");
+ }
+
+ [Test]
+ public void Segments1 ()
+ {
+ Uri uri = new Uri ("http://localhost/");
+ string [] segments = uri.Segments;
+ Assertion.AssertEquals ("#01", 1, segments.Length);
+ Assertion.AssertEquals ("#02", "/", segments [0]);
+
+ }
+
+ [Test]
+ public void Segments2 ()
+ {
+ Uri uri = new Uri ("http://localhost/dir/dummypage.html");
+ string [] segments = uri.Segments;
+ Assertion.AssertEquals ("#01", 3, segments.Length);
+ Assertion.AssertEquals ("#02", "/", segments [0]);
+ Assertion.AssertEquals ("#03", "dir/", segments [1]);
+ Assertion.AssertEquals ("#04", "dummypage.html", segments [2]);
+
+ }
+
+ [Test]
+ public void Segments3 ()
+ {
+ Uri uri = new Uri ("http://localhost/dir/dummypage/");
+ string [] segments = uri.Segments;
+ Assertion.AssertEquals ("#01", 3, segments.Length);
+ Assertion.AssertEquals ("#02", "/", segments [0]);
+ Assertion.AssertEquals ("#03", "dir/", segments [1]);
+ Assertion.AssertEquals ("#04", "dummypage/", segments [2]);
+
+ }
+
+ [Test]
+ public void Segments4 ()
+ {
+ Uri uri = new Uri ("file:///c:/hello");
+ string [] segments = uri.Segments;
+ Assertion.AssertEquals ("#01", 3, segments.Length);
+ Assertion.AssertEquals ("#02", "c:", segments [0]);
+ Assertion.AssertEquals ("#03", "/", segments [1]);
+ Assertion.AssertEquals ("#04", "hello", segments [2]);
+
+ }
+
+ [Test]
+ [ExpectedException (typeof (UriFormatException))]
+ public void EmptyScheme ()
+ {
+ new Uri ("hey");
+ }
+
+ [Test]
+ public void InvalidPortsThatWorkWithMS ()
+ {
+ new Uri ("http://www.contoso.com:12345678/foo/bar/");
+ // UInt32.MaxValue gives port == -1 !!!
+ new Uri ("http://www.contoso.com:4294967295/foo/bar/");
+ // ((uint) Int32.MaxValue + (uint) 1) gives port == -2147483648 !!!
+ new Uri ("http://www.contoso.com:2147483648/foo/bar/");
+ }
+
+ public static void Print (Uri uri)
+ {
+ Console.WriteLine ("ToString: " + uri.ToString ());
+
+ Console.WriteLine ("AbsolutePath: " + uri.AbsolutePath);
+ Console.WriteLine ("AbsoluteUri: " + uri.AbsoluteUri);
+ Console.WriteLine ("Authority: " + uri.Authority);
+ Console.WriteLine ("Fragment: " + uri.Fragment);
+ Console.WriteLine ("Host: " + uri.Host);
+ Console.WriteLine ("HostNameType: " + uri.HostNameType);
+ Console.WriteLine ("IsDefaultPort: " + uri.IsDefaultPort);
+ Console.WriteLine ("IsFile: " + uri.IsFile);
+ Console.WriteLine ("IsLoopback: " + uri.IsLoopback);
+ Console.WriteLine ("IsUnc: " + uri.IsUnc);
+ Console.WriteLine ("LocalPath: " + uri.LocalPath);
+ Console.WriteLine ("PathAndQuery: " + uri.PathAndQuery);
+ Console.WriteLine ("Port: " + uri.Port);
+ Console.WriteLine ("Query: " + uri.Query);
+ Console.WriteLine ("Scheme: " + uri.Scheme);
+ Console.WriteLine ("UserEscaped: " + uri.UserEscaped);
+ Console.WriteLine ("UserInfo: " + uri.UserInfo);
+
+ Console.WriteLine ("Segments:");
+ string [] segments = uri.Segments;
+ if (segments == null)
+ Console.WriteLine ("\tNo Segments");
+ else
+ for (int i = 0; i < segments.Length; i++)
+ Console.WriteLine ("\t" + segments[i]);
+ Console.WriteLine ("");
+ }
+
+ }
+}
+
diff --git a/mcs/class/corlib/Assembly/AssemblyInfo.cs b/mcs/class/corlib/Assembly/AssemblyInfo.cs
index 15203257a46..cf0a0bca0fb 100644
--- a/mcs/class/corlib/Assembly/AssemblyInfo.cs
+++ b/mcs/class/corlib/Assembly/AssemblyInfo.cs
@@ -27,8 +27,8 @@ using System.Runtime.InteropServices;
[assembly: TypeLibVersion(1, 10)]
#endif
-[assembly: AssemblyTitle("corlib.dll")]
-[assembly: AssemblyDescription("corlib.dll")]
+[assembly: AssemblyTitle("mscorlib.dll")]
+[assembly: AssemblyDescription("mscorlib.dll")]
[assembly: AssemblyConfiguration("Development version")]
[assembly: AssemblyCompany("MONO development team")]
[assembly: AssemblyProduct("MONO CLI")]
@@ -36,11 +36,11 @@ using System.Runtime.InteropServices;
// FIXME Already defined in System.IntPtr.cs - probably should be moved here
//[assembly: CLSCompliant(true)]
-[assembly: AssemblyDefaultAlias("corlib.dll")]
+[assembly: AssemblyDefaultAlias("mscorlib.dll")]
[assembly: AssemblyInformationalVersion("0.0.0.1")]
[assembly: NeutralResourcesLanguage("en-US")]
[assembly: AllowPartiallyTrustedCallers]
//[assembly: AssemblyDelaySign(false)]
-//[assembly: AssemblyKeyFile("")] \ No newline at end of file
+//[assembly: AssemblyKeyFile("")]
diff --git a/mcs/class/corlib/Assembly/ChangeLog b/mcs/class/corlib/Assembly/ChangeLog
index 9ad7c6df637..b91530dcd27 100644
--- a/mcs/class/corlib/Assembly/ChangeLog
+++ b/mcs/class/corlib/Assembly/ChangeLog
@@ -1,3 +1,7 @@
+2003-11-12 Jackson Harper <jackson@ximian.com>
+
+ * AssemblyInfo.cs: Change assembly name to mscorlib
+
2003-08-06 Andreas Nahr <ClassDevelopment@A-SoftTech.com>
* Locale.cs: Added
diff --git a/mcs/class/corlib/ChangeLog b/mcs/class/corlib/ChangeLog
index 47d2b28930c..7cf86d30ccb 100644
--- a/mcs/class/corlib/ChangeLog
+++ b/mcs/class/corlib/ChangeLog
@@ -1,3 +1,62 @@
+2003-11-26 Andreas Nahr <ClassDevelopment@A-SoftTech.com>
+
+ * corlib.dll.sources: Added file:
+ System.Runtime.InteropServices.DispatchWrapper.cs
+
+2003-11-26 Lluis Sanchez Gual <lluis@ximian.com>
+
+ * corlib.dll.sources: Added
+ System.Runtime.Remoting.Services/EnterpriseServicesHelper.cs
+ * corlib_test.dll.sources: Added System.Runtime.Remoting/SoapServicesTest.cs
+
+2003-11-24 Zoltan Varga <vargaz@freemail.hu>
+
+ * corlib.dll.sources: Add System.Reflection.Emit/DynamicMethod.cs.
+
+2003-11-19 Lluis Sanchez Gual <lluis@ximian.com>
+
+ * corlib_test.dll.sources: Added some test files:
+ System.Runtime.Remoting/ContextTest.cs
+ System.Runtime.Remoting/SynchronizationAttributeTest.cs
+
+2003-11-18 Lluis Sanchez Gual <lluis@ximian.com>
+
+ * corlib.dll.sources: Added some files:
+ System.Runtime.Remoting.Contexts/IContextPropertyActivator.cs
+ System.Runtime.Remoting.Contexts/SynchronizationAttribute.cs
+ System.Runtime.Remoting.Messaging/ISerializationRootObject.cs
+
+2003-11-18 Andreas Nahr <ClassDevelopment@A-SoftTech.com>
+
+ * corlib.dll.sources: Added already existing, but not added delegate
+ Added various classes in System.InteropServices
+
+2003-11-18 Andreas Nahr <ClassDevelopment@A-SoftTech.com>
+
+ * corlib.dll.sources: Added some files:
+ System.Runtime.Serialization.Formatter.cs
+ System.Runtime.Serialization.Formatters/InternalRM.cs
+ System.Runtime.Serialization.Formatters/InternalST.cs
+ System.Runtime.Serialization.Formatters/TypeFilterLevel.cs
+
+2003-11-17 Lluis Sanchez Gual <lluis@ximian.com>
+
+ * corlib.dll.sources: Added some files:
+ System.Runtime.Remoting.Channels/AggregateDictionary.cs
+ System.Runtime.Remoting.Metadata.W3cXsd2001/SoapHelper.cs
+
+2003-11-16 Lluis Sanchez Gual <lluis@ximian.com>
+
+ * corlib.dll.sources: Add System.Runtime.Remoting/InternalRemotingServices.cs
+
+2003-11-15 Zoltan Varga <vargaz@freemail.hu>
+
+ * corlib.dll.sources: Add System.Runtime.CompilerServices/IsVolatile.cs.
+
+2003-11-12 Jackson Harper <jackson@ximian.com>
+
+ * Makefile: corlib is now named mscorlib.
+
2003-11-09 Sebastien Pouliot <spouliot@videotron.ca>
* corlib.dll.sources: Added new 1.2 classes for System.Security.Cryptography.
diff --git a/mcs/class/corlib/Makefile b/mcs/class/corlib/Makefile
index 3c762f6e69a..66d55ae9bd9 100644
--- a/mcs/class/corlib/Makefile
+++ b/mcs/class/corlib/Makefile
@@ -14,7 +14,8 @@ test_against = $(reslib)
endif
LOCAL_MCS_FLAGS = /nowarn:649 /nowarn:169 -d:INSIDE_CORLIB
-corlib = $(topdir)/class/lib/corlib.dll
+
+corlib = $(topdir)/class/lib/mscorlib.dll
testlib = corlib_test.dll
cmplib = $(topdir)/class/lib/corlib_cmp.dll
reslib = $(topdir)/class/lib/corlib_res.dll
diff --git a/mcs/class/corlib/Microsoft.Win32/RegistryKey.cs b/mcs/class/corlib/Microsoft.Win32/RegistryKey.cs
index dde5c71ddf4..ab0c4727bcb 100644
--- a/mcs/class/corlib/Microsoft.Win32/RegistryKey.cs
+++ b/mcs/class/corlib/Microsoft.Win32/RegistryKey.cs
@@ -128,6 +128,10 @@ namespace Microsoft.Win32 {
{
throw new NotImplementedException ();
}
+
+ private RegistryKey ()
+ {
+ }
}
}
diff --git a/mcs/class/corlib/Mono.Math/BigInteger.cs b/mcs/class/corlib/Mono.Math/BigInteger.cs
index 864c3af2034..f0f6de80359 100644
--- a/mcs/class/corlib/Mono.Math/BigInteger.cs
+++ b/mcs/class/corlib/Mono.Math/BigInteger.cs
@@ -723,7 +723,7 @@ namespace Mono.Math {
for (int p = 0; p < smallPrimes.Length; p++) {
if (this % smallPrimes [p] == 0)
- return false;
+ return this == smallPrimes [p];
}
return
@@ -736,7 +736,7 @@ namespace Mono.Math {
for (int p = 0; p < smallPrimes.Length; p++) {
if (this % smallPrimes [p] == 0)
- return false;
+ return this == smallPrimes [p];
}
return
diff --git a/mcs/class/corlib/Mono.Math/ChangeLog b/mcs/class/corlib/Mono.Math/ChangeLog
index 8bce5888aaf..c7e1d005a01 100644
--- a/mcs/class/corlib/Mono.Math/ChangeLog
+++ b/mcs/class/corlib/Mono.Math/ChangeLog
@@ -1,3 +1,7 @@
+2003-11-20 Ben Maurer <bmaurer@users.sourceforge.net>
+
+ * BigInteger.cs: Fix prob. prime test for small numbers (Pieter Philippaerts)
+
2003-06-11 Sebastien Pouliot <spouliot@motus.com>
* BigInteger.cs: Added Clear to zeroize big integers and code to allow
diff --git a/mcs/class/corlib/System.Collections.Generic/ICollection.cs b/mcs/class/corlib/System.Collections.Generic/ICollection.cs
index b4dbd871b84..4739c35adb7 100644
--- a/mcs/class/corlib/System.Collections.Generic/ICollection.cs
+++ b/mcs/class/corlib/System.Collections.Generic/ICollection.cs
@@ -8,7 +8,7 @@
// (C) 2003 Novell, Inc.
//
-#if GENERICS && NET_1_2
+#if NET_1_2
using System;
using System.Runtime.InteropServices;
@@ -25,4 +25,4 @@ namespace System.Collections.Generic
}
}
}
-#endif \ No newline at end of file
+#endif
diff --git a/mcs/class/corlib/System.Collections.Generic/IComparable.cs b/mcs/class/corlib/System.Collections.Generic/IComparable.cs
index 7d5f2a9a205..5d0215ee8dc 100644
--- a/mcs/class/corlib/System.Collections.Generic/IComparable.cs
+++ b/mcs/class/corlib/System.Collections.Generic/IComparable.cs
@@ -7,7 +7,7 @@
// (C) 2003 Ben Maurer
//
-#if GENERICS && NET_1_2
+#if NET_1_2
using System;
using System.Runtime.InteropServices;
@@ -18,4 +18,4 @@ namespace System.Collections.Generic {
int CompareTo(T other);
}
}
-#endif \ No newline at end of file
+#endif
diff --git a/mcs/class/corlib/System.Collections.Generic/IComparer.cs b/mcs/class/corlib/System.Collections.Generic/IComparer.cs
index 58417cf8af5..bf6fdccea37 100644
--- a/mcs/class/corlib/System.Collections.Generic/IComparer.cs
+++ b/mcs/class/corlib/System.Collections.Generic/IComparer.cs
@@ -7,7 +7,7 @@
// (C) 2003 Ben Maurer
//
-#if GENERICS && NET_1_2
+#if NET_1_2
using System;
using System.Runtime.InteropServices;
@@ -18,4 +18,4 @@ namespace System.Collections.Generic {
int Compare(T x, T y);
}
}
-#endif \ No newline at end of file
+#endif
diff --git a/mcs/class/corlib/System.Collections.Generic/IEnumerable.cs b/mcs/class/corlib/System.Collections.Generic/IEnumerable.cs
index cb387436c44..d5a2d4b6e93 100644
--- a/mcs/class/corlib/System.Collections.Generic/IEnumerable.cs
+++ b/mcs/class/corlib/System.Collections.Generic/IEnumerable.cs
@@ -8,7 +8,7 @@
// (C) 2003 Novell, Inc.
//
-#if GENERICS && NET_1_2
+#if NET_1_2
using System;
using System.Runtime.InteropServices;
@@ -21,4 +21,4 @@ namespace System.Collections.Generic
IEnumerator<T> GetEnumerator ();
}
}
-#endif \ No newline at end of file
+#endif
diff --git a/mcs/class/corlib/System.Collections.Generic/IEnumerator.cs b/mcs/class/corlib/System.Collections.Generic/IEnumerator.cs
index fdb03f5fdd8..76248692cce 100644
--- a/mcs/class/corlib/System.Collections.Generic/IEnumerator.cs
+++ b/mcs/class/corlib/System.Collections.Generic/IEnumerator.cs
@@ -8,7 +8,7 @@
// (C) 2003 Novell, Inc.
//
-#if GENERICS && NET_1_2
+#if NET_1_2
using System;
using System.Runtime.InteropServices;
@@ -25,4 +25,4 @@ namespace System.Collections.Generic
}
}
}
-#endif \ No newline at end of file
+#endif
diff --git a/mcs/class/corlib/System.Collections.Generic/IKeyComparer.cs b/mcs/class/corlib/System.Collections.Generic/IKeyComparer.cs
index c4d78eab955..745b81c5e50 100644
--- a/mcs/class/corlib/System.Collections.Generic/IKeyComparer.cs
+++ b/mcs/class/corlib/System.Collections.Generic/IKeyComparer.cs
@@ -7,7 +7,7 @@
// (C) 2003 Ben Maurer
//
-#if GENERICS && NET_1_2
+#if NET_1_2
using System;
using System.Runtime.InteropServices;
@@ -19,4 +19,4 @@ namespace System.Collections.Generic {
int GetHashCode (T obj);
}
}
-#endif \ No newline at end of file
+#endif
diff --git a/mcs/class/corlib/System.Collections.Generic/IList.cs b/mcs/class/corlib/System.Collections.Generic/IList.cs
index 83404103dfa..c1355064add 100644
--- a/mcs/class/corlib/System.Collections.Generic/IList.cs
+++ b/mcs/class/corlib/System.Collections.Generic/IList.cs
@@ -8,7 +8,7 @@
// (C) 2003 Novell, Inc.
//
-#if GENERICS && NET_1_2
+#if NET_1_2
using System;
using System.Runtime.InteropServices;
@@ -45,4 +45,4 @@ namespace System.Collections.Generic
}
}
}
-#endif \ No newline at end of file
+#endif
diff --git a/mcs/class/corlib/System.Collections.Generic/KeyValuePair.cs b/mcs/class/corlib/System.Collections.Generic/KeyValuePair.cs
index 23515bfc510..8666a1478d3 100644
--- a/mcs/class/corlib/System.Collections.Generic/KeyValuePair.cs
+++ b/mcs/class/corlib/System.Collections.Generic/KeyValuePair.cs
@@ -7,7 +7,7 @@
// (C) 2003 Ben Maurer
//
-#if GENERICS && NET_1_2
+#if NET_1_2
using System;
using System.Runtime.InteropServices;
@@ -37,4 +37,4 @@ namespace System.Collections.Generic {
}
}
}
-#endif \ No newline at end of file
+#endif
diff --git a/mcs/class/corlib/System.Collections/CaseInsensitiveComparer.cs b/mcs/class/corlib/System.Collections/CaseInsensitiveComparer.cs
index 2ec923bd1c4..ad2b4cf834e 100644
--- a/mcs/class/corlib/System.Collections/CaseInsensitiveComparer.cs
+++ b/mcs/class/corlib/System.Collections/CaseInsensitiveComparer.cs
@@ -13,20 +13,19 @@ using System.Threading;
using System.Collections;
using System.Globalization;
-
-
namespace System.Collections {
[Serializable]
public class CaseInsensitiveComparer : IComparer {
- private static CaseInsensitiveComparer singleton;
+ private static CaseInsensitiveComparer default_comparer, default_invariant_comparer;
private CultureInfo cinfo;
// Class constructor
static CaseInsensitiveComparer ()
{
- singleton=new CaseInsensitiveComparer ();
+ default_comparer = new CaseInsensitiveComparer ();
+ default_invariant_comparer = new CaseInsensitiveComparer (CultureInfo.InvariantCulture);
}
@@ -39,9 +38,9 @@ namespace System.Collections {
public CaseInsensitiveComparer (CultureInfo culture)
{
- if (culture==null)
- throw new ArgumentNullException("culture");
- cinfo = culture;
+ if (culture == null)
+ throw new ArgumentNullException("culture");
+ cinfo = culture;
}
@@ -51,11 +50,16 @@ namespace System.Collections {
public static CaseInsensitiveComparer Default {
get {
- return singleton;
+ return default_comparer;
}
}
-
+ public static CaseInsensitiveComparer DefaultInvariant {
+ get {
+ return default_invariant_comparer;
+ }
+ }
+
//
// Instance methods
//
diff --git a/mcs/class/corlib/System.Collections/ChangeLog b/mcs/class/corlib/System.Collections/ChangeLog
index ed8adf0b29c..9279fd93c4a 100644
--- a/mcs/class/corlib/System.Collections/ChangeLog
+++ b/mcs/class/corlib/System.Collections/ChangeLog
@@ -1,3 +1,11 @@
+2003-11-13 Andreas Nahr <ClassDevelopment@A-SoftTech.com>
+
+ * IEnumerator.cs: Added missing attribute
+
+2003-11-12 Miguel de Icaza <miguel@ximian.com>
+
+ * CaseInsensitiveComparer.cs: Add missing method.
+
2003-11-10 Zoltan Varga <vargaz@freemail.hu>
* Stack.cs: Applied patch from Carlos A. Barcenilla to fix minor
diff --git a/mcs/class/corlib/System.Collections/IEnumerator.cs b/mcs/class/corlib/System.Collections/IEnumerator.cs
index 06d250c8b7e..cc90a034867 100644
--- a/mcs/class/corlib/System.Collections/IEnumerator.cs
+++ b/mcs/class/corlib/System.Collections/IEnumerator.cs
@@ -1,5 +1,5 @@
//
-// System.Collections.IEnumerator
+// System.Collections.IEnumerator.cs
//
// Author:
// Vladimir Vukicevic (vladimir@pobox.com)
@@ -8,15 +8,19 @@
//
using System;
+using System.Runtime.InteropServices;
-namespace System.Collections {
+namespace System.Collections
+{
- public interface IEnumerator {
- object Current { get; }
+ [Guid ("496B0ABF-CDEE-11D3-88E8-00902754C43A")]
+ public interface IEnumerator
+ {
+ object Current { get; }
- bool MoveNext ();
+ bool MoveNext ();
- void Reset ();
- }
+ void Reset ();
+ }
}
diff --git a/mcs/class/corlib/System.Configuration.Assemblies/ProcessorID.cs b/mcs/class/corlib/System.Configuration.Assemblies/ProcessorID.cs
index 10cb2e9fe5d..6afb3148448 100755
--- a/mcs/class/corlib/System.Configuration.Assemblies/ProcessorID.cs
+++ b/mcs/class/corlib/System.Configuration.Assemblies/ProcessorID.cs
@@ -12,7 +12,7 @@
namespace System.Configuration.Assemblies {
-
+#if ECMA
/// <summary>
/// </summary>
public enum ProcessorID {
@@ -97,5 +97,6 @@ namespace System.Configuration.Assemblies {
/// </summary>
ARM_7TDMI = 70001,
} // ProcessorID
-
+#endif
+
} // System.Configuration.Assemblies
diff --git a/mcs/class/corlib/System.Diagnostics/StackFrame.cs b/mcs/class/corlib/System.Diagnostics/StackFrame.cs
index 2980c772d2c..42dcd010372 100644
--- a/mcs/class/corlib/System.Diagnostics/StackFrame.cs
+++ b/mcs/class/corlib/System.Diagnostics/StackFrame.cs
@@ -267,6 +267,10 @@ namespace System.Diagnostics {
+ ":" + GetFileColumnNumber();
}
+ //
+ // These are not on the Framework
+ //
+#if false
public override bool Equals(Object obj) {
if ((obj == null) || (!(obj is StackFrame))) {
return false;
@@ -305,6 +309,7 @@ namespace System.Diagnostics {
public override int GetHashCode() {
return GetFileLineNumber();
}
+#endif
/// <summary>
/// Checks whether two objects are equal.
diff --git a/mcs/class/corlib/System.Diagnostics/StackTrace.cs b/mcs/class/corlib/System.Diagnostics/StackTrace.cs
index c8ac9ca51bd..baf041e91a3 100644
--- a/mcs/class/corlib/System.Diagnostics/StackTrace.cs
+++ b/mcs/class/corlib/System.Diagnostics/StackTrace.cs
@@ -230,7 +230,12 @@ namespace System.Diagnostics {
return result;
}
-
+
+ //
+ // These are not on the Framework
+ //
+#if false
+
public override bool Equals(Object obj) {
if ((obj == null) || (!(obj is StackTrace))) {
return false;
@@ -254,6 +259,7 @@ namespace System.Diagnostics {
public override int GetHashCode() {
return FrameCount;
}
+#endif
/// <summary>
/// Converts single stack frame to string to be used in
diff --git a/mcs/class/corlib/System.Globalization/CalendricalCalculations.cs b/mcs/class/corlib/System.Globalization/CalendricalCalculations.cs
index 3f493f2cc2e..3e4095df14f 100644
--- a/mcs/class/corlib/System.Globalization/CalendricalCalculations.cs
+++ b/mcs/class/corlib/System.Globalization/CalendricalCalculations.cs
@@ -1549,7 +1549,7 @@ internal class CCHebrewCalendar {
/// </para>
/// <seealso cref="T:CCFixed"/>
/// </remarks>
-public class CCHijriCalendar {
+internal class CCHijriCalendar {
/// <summary>An integer defining the epoch of the Gregorian calendar
/// as fixed day number.</summary>
/// <remarks>
@@ -1822,7 +1822,7 @@ public class CCHijriCalendar {
/// (e.g. <see cref="T:System.Gloablization.JapaneseCalendar"/>).
/// </summary>
[System.Serializable]
-public class CCGregorianEraHandler {
+internal class CCGregorianEraHandler {
/// <summary>
/// A struct that represents a single era.
/// </summary>
diff --git a/mcs/class/corlib/System.Globalization/CultureInfo.cs b/mcs/class/corlib/System.Globalization/CultureInfo.cs
index 052d2c417a6..00bcea96cff 100644
--- a/mcs/class/corlib/System.Globalization/CultureInfo.cs
+++ b/mcs/class/corlib/System.Globalization/CultureInfo.cs
@@ -1096,12 +1096,6 @@ namespace System.Globalization
{
return Thread.CurrentThread.CurrentCulture;
}
-
- /* FIXME: the set method isnt listed in the spec */
- set
- {
- Thread.CurrentThread.CurrentCulture = value;
- }
}
public static CultureInfo CurrentUICulture
@@ -1110,12 +1104,6 @@ namespace System.Globalization
{
return Thread.CurrentThread.CurrentUICulture;
}
-
- /* FIXME: the set method isnt listed in the spec */
- set
- {
- Thread.CurrentThread.CurrentUICulture = value;
- }
}
diff --git a/mcs/class/corlib/System.Globalization/HebrewCalendar.cs b/mcs/class/corlib/System.Globalization/HebrewCalendar.cs
index 0747a3818df..5d87df8f18b 100644
--- a/mcs/class/corlib/System.Globalization/HebrewCalendar.cs
+++ b/mcs/class/corlib/System.Globalization/HebrewCalendar.cs
@@ -197,6 +197,11 @@ public class HebrewCalendar : Calendar {
era));
}
+#if false
+ //
+ // The following routines are commented out as they do not appear on the .NET Framework 1.1
+ //
+
/// <summary>
/// Overridden. Adds days to a given date.
/// </summary>
@@ -410,7 +415,8 @@ public class HebrewCalendar : Calendar {
M_CheckDateTime(time);
return base.GetMinute(time);
}
-
+#endif
+
/// <summary>
/// Overrideden. Adds months to a given date.
/// </summary>
@@ -871,12 +877,6 @@ public class HebrewCalendar : Calendar {
hour, minute, second, milliseconds);
}
- [MonoTODO]
- public override int ToFourDigitYear(int year)
- {
- throw new NotImplementedException();
- }
-
} // class HebrewCalendar
} // namespace System.Globalization
diff --git a/mcs/class/corlib/System.Globalization/HijriCalendar.cs b/mcs/class/corlib/System.Globalization/HijriCalendar.cs
index d7f76d0809b..9673695008f 100644
--- a/mcs/class/corlib/System.Globalization/HijriCalendar.cs
+++ b/mcs/class/corlib/System.Globalization/HijriCalendar.cs
@@ -8,6 +8,7 @@ namespace System.Globalization {
using System;
using System.IO;
+
/// <summary>
/// This is the Hijri calendar which might be called Islamic calendar.
/// </summary>
@@ -90,7 +91,7 @@ public class HijriCalendar : Calendar {
/// <value>An integer property representing the adjustment to the epoch
/// of the Hijri calendar. Not supported by .NET.
/// </value>
- public virtual int AddHijriDate {
+ internal virtual int AddHijriDate {
get {
return M_AddHijriDate;
}
@@ -312,6 +313,11 @@ public class HijriCalendar : Calendar {
}
}
+#if false
+ //
+ // The following routines are commented out as they do not appear on the .NET Framework 1.1
+ //
+
/// <summary>
/// Overridden. Adds days to a given date.
/// </summary>
@@ -525,7 +531,8 @@ public class HijriCalendar : Calendar {
M_CheckDateTime(time);
return base.GetMinute(time);
}
-
+#endif
+
/// <summary>
/// Overrideden. Adds months to a given date.
/// </summary>
diff --git a/mcs/class/corlib/System.Globalization/JapaneseCalendar.cs b/mcs/class/corlib/System.Globalization/JapaneseCalendar.cs
index 75e553ded50..44ce16b158b 100644
--- a/mcs/class/corlib/System.Globalization/JapaneseCalendar.cs
+++ b/mcs/class/corlib/System.Globalization/JapaneseCalendar.cs
@@ -216,7 +216,10 @@ public class JapaneseCalendar : Calendar {
return gregorianYear;
}
+#if false
+ // Ifdefed out because this is not on the .NET Framewokr.
+
/// <summary>
/// Overridden. Adds days to a given date.
/// </summary>
@@ -431,7 +434,8 @@ public class JapaneseCalendar : Calendar {
M_CheckDateTime(time);
return base.GetMinute(time);
}
-
+#endif
+
/// <summary>
/// Overrideden. Adds months to a given date.
/// </summary>
diff --git a/mcs/class/corlib/System.Globalization/TaiwanCalendar.cs b/mcs/class/corlib/System.Globalization/TaiwanCalendar.cs
index e1875667752..e0dc6a4d848 100644
--- a/mcs/class/corlib/System.Globalization/TaiwanCalendar.cs
+++ b/mcs/class/corlib/System.Globalization/TaiwanCalendar.cs
@@ -180,6 +180,10 @@ public class TaiwanCalendar : Calendar {
return gregorianYear;
}
+#if false
+
+ // Ifdefed out because this is not on the .NET Framework
+
/// <summary>
/// Overridden. Adds days to a given date.
/// </summary>
@@ -394,7 +398,8 @@ public class TaiwanCalendar : Calendar {
M_CheckDateTime(time);
return base.GetMinute(time);
}
-
+#endif
+
/// <summary>
/// Overrideden. Adds months to a given date.
/// </summary>
diff --git a/mcs/class/corlib/System.Globalization/TextInfo.cs b/mcs/class/corlib/System.Globalization/TextInfo.cs
index a067433da60..2ec12dbe1df 100755
--- a/mcs/class/corlib/System.Globalization/TextInfo.cs
+++ b/mcs/class/corlib/System.Globalization/TextInfo.cs
@@ -18,7 +18,7 @@ namespace System.Globalization {
{
private int lcid;
- public TextInfo ()
+ internal TextInfo ()
{
}
diff --git a/mcs/class/corlib/System.IO/ChangeLog b/mcs/class/corlib/System.IO/ChangeLog
index 1b7aca19ac7..22db144c4b2 100644
--- a/mcs/class/corlib/System.IO/ChangeLog
+++ b/mcs/class/corlib/System.IO/ChangeLog
@@ -1,3 +1,62 @@
+2003-11-28 Dick Porter <dick@ximian.com>
+
+ * Path.cs: Use the char form of LastIndexOf, so that the
+ comparison is done with the Invariant culture.
+
+2003-11-24 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * Directory.cs: provide the path when getting the IOException.
+
+2003-11-18 John Luke <jluke@cfl.rr.com>
+
+ * CheckArgument.cs:
+ (PathLength): fix recursion found by JonK
+
+2003-11-15 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * Directory.cs:
+ (GetCurrentDirectory):
+ (SetCurrentDirectory): moved here from Environment. Handle error cases.
+
+ * MonoIO.cs: add path to the default error message.
+
+2003-11-15 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * StringReader.cs: fixed ReadLine for some cases where there are mixed
+ '\r' and '\n'. Closes bug #51020.
+
+2003-11-14 Ben Maurer <bmaurer@users.sourceforge.net>
+
+ * MemoryStream.cs (.ctor): We need to check if buffer is null
+ before we get the Length of it.
+
+2003-11-14 Miguel de Icaza <miguel@ximian.com>
+
+ * StreamReader.cs, TextReader, StreamReader (Read): Add [Out]
+
+2003-11-14 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * Directory.cs: allow directory names without wildcards in the pattern.
+ Fixes bug #3 50969.
+
+ * SearchPattern.cs: made InvalidChars and WildcardChars internal.
+
+2003-11-14 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * FileStream.cs: use the argument name when throwing exception.
+
+ * StreamReader.cs:
+ * StringReader.cs:
+ * TextReader.cs: added [In] attribute for the array in Read.
+
+2003-11-12 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * DirectoryInfo.cs: fixed ToString. Closes bug #50842.
+
+2003-11-12 Miguel de Icaza <miguel@ximian.com>
+
+ * Directory.cs: Adjust for missing PlatformID.Unix.
+
2003-10-28 Miguel de Icaza <miguel@ximian.com>
* StreamReader.cs: Add checks for disposed stream from bug report
diff --git a/mcs/class/corlib/System.IO/CheckArgument.cs b/mcs/class/corlib/System.IO/CheckArgument.cs
index 0e879cf3cc8..4b38a9f9439 100644
--- a/mcs/class/corlib/System.IO/CheckArgument.cs
+++ b/mcs/class/corlib/System.IO/CheckArgument.cs
@@ -122,7 +122,7 @@ namespace System.IO
/// </summary>
public static void PathLength (string path)
{
- PathLength (path);
+ PathLength (path, "Path is too long");
}
/// <summary>
diff --git a/mcs/class/corlib/System.IO/Directory.cs b/mcs/class/corlib/System.IO/Directory.cs
index 68635acc1f6..edb58c0eba3 100644
--- a/mcs/class/corlib/System.IO/Directory.cs
+++ b/mcs/class/corlib/System.IO/Directory.cs
@@ -41,7 +41,7 @@ namespace System.IO
throw new ArgumentException ("Only blank characters in path");
// LAMESPEC: with .net 1.0 version this throw NotSupportedException and msdn says so too
- // byt v1.1 throws ArgumentException.
+ // but v1.1 throws ArgumentException.
if (path == ":")
throw new ArgumentException ("Only ':' In path");
@@ -56,8 +56,17 @@ namespace System.IO
MonoIOError error;
if (!MonoIO.CreateDirectory (path, out error)) {
+ // LAMESPEC: 1.1 and 1.2alpha allow CreateDirectory on a file path.
+ // So CreateDirectory ("/tmp/somefile") will succeed if 'somefile' is
+ // not a directory. However, 1.0 will throw an exception.
+ // We behave like 1.0 here (emulating 1.1-like behavior is just a matter
+ // of comparing error to ERROR_FILE_EXISTS, but it's lame to do:
+ // DirectoryInfo di = Directory.CreateDirectory (something);
+ // and having di.Exists return false afterwards.
+ // I hope we don't break anyone's code, as they should be catching
+ // the exception anyway.
if (error != MonoIOError.ERROR_ALREADY_EXISTS)
- throw MonoIO.GetException (error);
+ throw MonoIO.GetException (path, error);
}
return info;
@@ -168,7 +177,14 @@ namespace System.IO
string str = Environment.CurrentDirectory;
CheckPermission.Demand (FileIOPermissionAccess.Read & FileIOPermissionAccess.Write, str);
*/
- return Environment.CurrentDirectory;
+
+ MonoIOError error;
+
+ string result = MonoIO.GetCurrentDirectory (out error);
+ if (error != MonoIOError.ERROR_SUCCESS)
+ throw MonoIO.GetException (error);
+
+ return result;
}
public static string [] GetDirectories (string path)
@@ -210,7 +226,7 @@ namespace System.IO
public static string[] GetLogicalDrives ()
{
//FIXME: Hardcoded Paths
- if (Environment.OSVersion.Platform == PlatformID.Unix)
+ if ((int)Environment.OSVersion.Platform == 128)
return new string[] { "/" };
else
return new string [] { "A:\\", "C:\\" };
@@ -274,11 +290,15 @@ namespace System.IO
CheckArgument.Path (path, true);
CheckPermission.Demand (FileIOPermissionAccess.Read & FileIOPermissionAccess.Write, path);
*/
- if (!Exists (path))
- {
- throw new DirectoryNotFoundException ("Directory \"" + path + "\" not found.");
- }
- Environment.CurrentDirectory = path;
+ MonoIOError error;
+
+ if (!Exists (path))
+ throw new DirectoryNotFoundException ("Directory \"" +
+ path + "\" not found.");
+
+ MonoIO.SetCurrentDirectory (path, out error);
+ if (error != MonoIOError.ERROR_SUCCESS)
+ throw MonoIO.GetException (path, error);
}
public static void SetLastAccessTime (string path, DateTime last_access_time)
@@ -327,30 +347,45 @@ namespace System.IO
if (path == "")
throw new ArgumentException ("The Path do not have a valid format");
- if (path.IndexOfAny (Path.InvalidPathChars) != -1)
+ string wild = Path.Combine (path, pattern);
+ string wildpath = Path.GetDirectoryName (wild);
+ if (wildpath.IndexOfAny (Path.InvalidPathChars) != -1)
throw new ArgumentException ("Path contains invalid characters");
- if (!Directory.Exists (path)) {
- throw new DirectoryNotFoundException ("Directory '" + path + "' not found.");
+ if (wildpath.IndexOfAny (Path.InvalidPathChars) != -1) {
+ if (path.IndexOfAny (SearchPattern.InvalidChars) == -1)
+ throw new ArgumentException ("Path contains invalid characters", "path");
+
+ throw new ArgumentException ("Pattern contains invalid characters", "pattern");
+ }
+
+ if (!Directory.Exists (wildpath)) {
+ if (wildpath.IndexOfAny (SearchPattern.WildcardChars) == -1)
+ throw new DirectoryNotFoundException ("Directory '" + wildpath + "' not found.");
+
+ if (path.IndexOfAny (SearchPattern.WildcardChars) == -1)
+ throw new ArgumentException ("Pattern is invalid", "pattern");
+
+ throw new ArgumentException ("Path is invalid", "path");
}
- search = new SearchPattern (pattern);
+ search = new SearchPattern (Path.GetFileName (wild));
MonoIOError error;
- find = MonoIO.FindFirstFile (Path.Combine (path , "*"), out stat, out error);
+ find = MonoIO.FindFirstFile (Path.Combine (wildpath , "*"), out stat, out error);
if (find == MonoIO.InvalidHandle) {
switch (error) {
case MonoIOError.ERROR_FILE_NOT_FOUND:
case MonoIOError.ERROR_PATH_NOT_FOUND:
- string message = String.Format ("Could not find a part of the path \"{0}\"", path);
+ string message = String.Format ("Could not find a part of the path \"{0}\"",
+ wildpath);
throw new DirectoryNotFoundException (message);
case MonoIOError.ERROR_NO_MORE_FILES:
return new string [0];
default:
- throw MonoIO.GetException (path,
- error);
+ throw MonoIO.GetException (wildpath, error);
}
}
@@ -367,10 +402,9 @@ namespace System.IO
search.IsMatch (stat.Name) &&
stat.Name != "." &&
stat.Name != "..")
- entries.Add (Path.Combine (path, stat.Name));
+ entries.Add (Path.Combine (wildpath, stat.Name));
- if (!MonoIO.FindNextFile (find, out stat,
- out error))
+ if (!MonoIO.FindNextFile (find, out stat, out error))
break;
}
MonoIO.FindClose (find, out error);
diff --git a/mcs/class/corlib/System.IO/DirectoryInfo.cs b/mcs/class/corlib/System.IO/DirectoryInfo.cs
index a798f2db516..b46376bb77b 100644
--- a/mcs/class/corlib/System.IO/DirectoryInfo.cs
+++ b/mcs/class/corlib/System.IO/DirectoryInfo.cs
@@ -140,7 +140,7 @@ namespace System.IO {
}
public override string ToString () {
- return Path.GetFileName (OriginalPath);
+ return OriginalPath;
}
}
}
diff --git a/mcs/class/corlib/System.IO/FileStream.cs b/mcs/class/corlib/System.IO/FileStream.cs
index be74f79bf73..707dfe515cb 100644
--- a/mcs/class/corlib/System.IO/FileStream.cs
+++ b/mcs/class/corlib/System.IO/FileStream.cs
@@ -77,7 +77,7 @@ namespace System.IO
public FileStream (string name, FileMode mode, FileAccess access, FileShare share, int bufferSize, bool isAsync)
{
if (name == null) {
- throw new ArgumentNullException ("Name is null");
+ throw new ArgumentNullException ("name");
}
if (name == "") {
diff --git a/mcs/class/corlib/System.IO/MemoryStream.cs b/mcs/class/corlib/System.IO/MemoryStream.cs
index 39d0df14245..c7f2e3f12b8 100644
--- a/mcs/class/corlib/System.IO/MemoryStream.cs
+++ b/mcs/class/corlib/System.IO/MemoryStream.cs
@@ -46,11 +46,17 @@ namespace System.IO
public MemoryStream (byte [] buffer)
{
+ if (buffer == null)
+ throw new ArgumentNullException ("buffer");
+
InternalConstructor (buffer, 0, buffer.Length, true, false);
}
public MemoryStream (byte [] buffer, bool writeable)
{
+ if (buffer == null)
+ throw new ArgumentNullException ("buffer");
+
InternalConstructor (buffer, 0, buffer.Length, writeable, false);
}
diff --git a/mcs/class/corlib/System.IO/MonoIO.cs b/mcs/class/corlib/System.IO/MonoIO.cs
index 8f9e5c49b96..d6f0c0c1454 100644
--- a/mcs/class/corlib/System.IO/MonoIO.cs
+++ b/mcs/class/corlib/System.IO/MonoIO.cs
@@ -47,7 +47,7 @@ namespace System.IO
return new UnauthorizedAccessException (message);
default:
- message = String.Format ("Win32 IO returned {0}", error);
+ message = String.Format ("Win32 IO returned {0}. Path: {1}", error, path);
return new IOException (message);
}
}
diff --git a/mcs/class/corlib/System.IO/Path.cs b/mcs/class/corlib/System.IO/Path.cs
index 5bc89171674..1e426e9833f 100644
--- a/mcs/class/corlib/System.IO/Path.cs
+++ b/mcs/class/corlib/System.IO/Path.cs
@@ -267,7 +267,7 @@ namespace System.IO
// method should return the index of the path extension
// start or -1 if no valid extension
if (path != null){
- int iLastDot = path.LastIndexOf (".");
+ int iLastDot = path.LastIndexOf ('.');
int iLastSep = path.LastIndexOfAny ( PathSeparatorChars );
if (iLastDot > iLastSep)
diff --git a/mcs/class/corlib/System.IO/SearchPattern.cs b/mcs/class/corlib/System.IO/SearchPattern.cs
index 4db60d2fadc..12063b06891 100644
--- a/mcs/class/corlib/System.IO/SearchPattern.cs
+++ b/mcs/class/corlib/System.IO/SearchPattern.cs
@@ -142,8 +142,8 @@ namespace System.IO {
// private static
- private static readonly char [] WildcardChars = { '*', '?' };
- private static readonly char [] InvalidChars = { Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar };
+ internal static readonly char [] WildcardChars = { '*', '?' };
+ internal static readonly char [] InvalidChars = { Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar };
private class Op {
public Op (OpCode code)
diff --git a/mcs/class/corlib/System.IO/StreamReader.cs b/mcs/class/corlib/System.IO/StreamReader.cs
index d8cf02d1670..29bfccf4bc4 100644
--- a/mcs/class/corlib/System.IO/StreamReader.cs
+++ b/mcs/class/corlib/System.IO/StreamReader.cs
@@ -10,7 +10,7 @@
using System;
using System.Text;
-
+using System.Runtime.InteropServices;
namespace System.IO {
[Serializable]
@@ -64,7 +64,7 @@ namespace System.IO {
return -1;
}
- public override int Read (char[] buffer, int index, int count)
+ public override int Read ([In, Out] char[] buffer, int index, int count)
{
return 0;
}
@@ -307,7 +307,7 @@ namespace System.IO {
return decoded_buffer [pos++];
}
- public override int Read (char[] dest_buffer, int index, int count)
+ public override int Read ([In, Out] char[] dest_buffer, int index, int count)
{
if (base_stream == null)
throw new ObjectDisposedException ("StreamReader", "Cannot read from a closed StreamReader");
diff --git a/mcs/class/corlib/System.IO/StreamWriter.cs b/mcs/class/corlib/System.IO/StreamWriter.cs
index 93d5931775b..ef07d479d65 100644
--- a/mcs/class/corlib/System.IO/StreamWriter.cs
+++ b/mcs/class/corlib/System.IO/StreamWriter.cs
@@ -57,7 +57,7 @@ namespace System.IO {
if (bufferSize < 0)
throw new ArgumentOutOfRangeException("bufferSize");
if (!stream.CanWrite)
- throw new ArgumentException("bufferSize");
+ throw new ArgumentException("Can not write to stream", "stream");
internalStream = stream;
diff --git a/mcs/class/corlib/System.IO/StringReader.cs b/mcs/class/corlib/System.IO/StringReader.cs
index b4739148cf1..f820cba7f50 100644
--- a/mcs/class/corlib/System.IO/StringReader.cs
+++ b/mcs/class/corlib/System.IO/StringReader.cs
@@ -6,6 +6,7 @@
using System;
+using System.Runtime.InteropServices;
namespace System.IO {
[Serializable]
@@ -68,8 +69,8 @@ namespace System.IO {
// the actual number of characters read, or zero if the end of the string
// has been reached and no characters are read.
- public override int Read( char[] buffer, int index, int count ) {
-
+ public override int Read ([In, Out] char[] buffer, int index, int count )
+ {
CheckObjectDisposedException ();
if( buffer == null ) {
@@ -95,48 +96,48 @@ namespace System.IO {
return charsToRead;
}
- public override string ReadLine() {
+ public override string ReadLine ()
+ {
// Reads until next \r or \n or \r\n, otherwise return null
- // LAMESPEC:
- // The Beta 2 SDK help says that the ReadLine method returns
- // "The next line from the input stream [...] A line is defined as a sequence of
- // characters followed by a carriage return (\r), a line feed (\n), or a carriage
- // return immediately followed by a line feed (\r\n). [...]
- // The returned value is a null reference if the end of the input stream has been reached."
- //
- // HOWEVER, the MS implementation returns the rest of the string if no \r and/or \n is found
- // in the string
+ // LAMESPEC:
+ // The Beta 2 SDK help says that the ReadLine method
+ // returns "The next line from the input stream [...] A
+ // line is defined as a sequence of characters followed by
+ // a carriage return (\r), a line feed (\n), or a carriage
+ // return immediately followed by a line feed (\r\n).
+ // [...] The returned value is a null reference if the end
+ // of the input stream has been reached."
+ //
+ // HOWEVER, the MS implementation returns the rest of
+ // the string if no \r and/or \n is found in the string
if (disposed)
- throw new ObjectDisposedException ("StringReader", "Cannot read from a closed StringReader");
+ throw new ObjectDisposedException ("StringReader",
+ "Cannot read from a closed StringReader");
if (nextChar >= source.Length)
return null;
- int nextCR = source.IndexOf( '\r', nextChar );
- int nextLF = source.IndexOf( '\n', nextChar );
-
- if( nextCR == -1 && nextLF == -1 ) {
- return ReadToEnd();
- }
+ int nextCR = source.IndexOf ('\r', nextChar);
+ int nextLF = source.IndexOf ('\n', nextChar);
+ int readTo;
+ bool consecutive = false;
- int readTo;
+ if (nextCR == -1) {
+ if (nextLF == -1)
+ return ReadToEnd ();
- if( nextCR == -1 ) {
- readTo = nextLF;
- } else {
- readTo = nextCR;
- }
-
- string nextLine = source.Substring( nextChar, readTo - nextChar );
-
- if( nextLF == nextCR + 1 ) {
- nextChar = readTo + 2;
- } else {
- nextChar = readTo + 1;
- }
+ readTo = nextLF;
+ } else if (nextLF == -1) {
+ readTo = nextCR;
+ } else {
+ readTo = (nextCR > nextLF) ? nextLF : nextCR;
+ consecutive = (nextCR + 1 == nextLF || nextLF + 1 == nextCR);
+ }
+ string nextLine = source.Substring (nextChar, readTo - nextChar);
+ nextChar = readTo + ((consecutive) ? 2 : 1);
return nextLine;
}
diff --git a/mcs/class/corlib/System.IO/TextReader.cs b/mcs/class/corlib/System.IO/TextReader.cs
index 1cffe3a5be9..4c256f26631 100644
--- a/mcs/class/corlib/System.IO/TextReader.cs
+++ b/mcs/class/corlib/System.IO/TextReader.cs
@@ -43,7 +43,8 @@ namespace System.IO {
return -1;
}
- public virtual int Read (char[] buffer, int index, int count)
+
+ public virtual int Read ([In, Out] char[] buffer, int index, int count)
{
int c, i;
diff --git a/mcs/class/corlib/System.Reflection.Emit/AssemblyBuilder.cs b/mcs/class/corlib/System.Reflection.Emit/AssemblyBuilder.cs
index b4124084f60..153fe598c76 100755
--- a/mcs/class/corlib/System.Reflection.Emit/AssemblyBuilder.cs
+++ b/mcs/class/corlib/System.Reflection.Emit/AssemblyBuilder.cs
@@ -191,8 +191,8 @@ namespace System.Reflection.Emit {
return DefineDynamicModule (name, fileName, emitSymbolInfo, false);
}
- public ModuleBuilder DefineDynamicModule (string name, string fileName,
- bool emitSymbolInfo, bool transient)
+ private ModuleBuilder DefineDynamicModule (string name, string fileName,
+ bool emitSymbolInfo, bool transient)
{
check_name_and_filename (name, fileName, false);
@@ -352,7 +352,12 @@ namespace System.Reflection.Emit {
mainModule.IsMain = true;
foreach (ModuleBuilder module in modules)
- module.Save ();
+ if (module != mainModule)
+ module.Save ();
+
+ // Write out the main module at the end, because it needs to
+ // contain the hash of the other modules
+ mainModule.Save ();
created = true;
}
@@ -386,7 +391,7 @@ namespace System.Reflection.Emit {
data = customBuilder.Data;
pos = 2;
len = CustomAttributeBuilder.decode_len (data, pos, out pos);
- version = CustomAttributeBuilder.string_from_bytes (data, pos, len);
+ version = create_assembly_version (CustomAttributeBuilder.string_from_bytes (data, pos, len));
return;
} else if (attrname == "System.Reflection.AssemblyKeyFileAttribute") {
data = customBuilder.Data;
@@ -522,9 +527,39 @@ namespace System.Reflection.Emit {
}
}
- // Same as in Mono.Security/Mono>Security.Cryptography/CryptoConvert.cs
+ private String create_assembly_version (String version) {
+ String[] parts = version.Split ('.');
+ int[] ver = new int [4] { 0, 0, 0, 0 };
+ if ((parts.Length < 0) || (parts.Length > 4))
+ throw new ArgumentException ("The version specified '" + version + "' is invalid");
+ for (int i = 0; i < parts.Length; ++i) {
+ if (parts [i] == "*") {
+ DateTime now = DateTime.Now;
+ if (i == 2) {
+ ver [2] = (now - new DateTime (2000, 1, 1)).Days;
+ if (parts.Length == 3)
+ ver [3] = (now.Second + (now.Minute * 60) + (now.Hour * 3600)) / 2;
+ }
+ else
+ if (i == 3)
+ ver [3] = (now.Second + (now.Minute * 60) + (now.Hour * 3600)) / 2;
+ else
+ throw new ArgumentException ("The version specified '" + version + "' is invalid");
+ }
+ else {
+ try {
+ ver [i] = Int32.Parse (parts [i]);
+ }
+ catch (FormatException) {
+ throw new ArgumentException ("The version specified '" + version + "' is invalid");
+ }
+ }
+ }
+
+ return ver [0] + "." + ver [1] + "." + ver [2] + "." + ver [3];
+ }
}
}
diff --git a/mcs/class/corlib/System.Reflection.Emit/AssemblyBuilderAccess.cs b/mcs/class/corlib/System.Reflection.Emit/AssemblyBuilderAccess.cs
index 2c6a97d9aca..641da5f5c64 100644
--- a/mcs/class/corlib/System.Reflection.Emit/AssemblyBuilderAccess.cs
+++ b/mcs/class/corlib/System.Reflection.Emit/AssemblyBuilderAccess.cs
@@ -7,6 +7,7 @@
namespace System.Reflection.Emit
{
+ [Flags]
public enum AssemblyBuilderAccess
{
Run = 1,
diff --git a/mcs/class/corlib/System.Reflection.Emit/ChangeLog b/mcs/class/corlib/System.Reflection.Emit/ChangeLog
index 2009cde9339..38484412538 100644
--- a/mcs/class/corlib/System.Reflection.Emit/ChangeLog
+++ b/mcs/class/corlib/System.Reflection.Emit/ChangeLog
@@ -1,3 +1,54 @@
+2003-11-28 Dick Porter <dick@ximian.com>
+
+ * ModuleBuilder.cs: Do string compares with the Invariant culture.
+
+2003-11-28 Zoltan Varga <vargaz@freemail.hu>
+
+ * AssemblyBuilder.cs (SetCustomAttribute): Implement automatic
+ generation of build and revision numbers. Fixes #46492.
+
+2003-11-25 Zoltan Varga <vargaz@freemail.hu>
+
+ * TypeBuilder.cs: Implement GetField.
+
+2003-11-24 Zoltan Varga <vargaz@freemail.hu>
+
+ * DynamicMethod.cs: New class.
+
+ * ILGenerator.cs MethodBuilder.cs ConstructorBuilder.cs: Retrieve
+ tokens from a token generator object instead of from the ModuleBuilder,
+ to support the implementation of DynamicMethod. Also get rid of the
+ unused 'mbuilder' field.
+
+ * ModuleBuilder.cs: Create a token generator object which can be
+ passed to ILGenerator.
+
+ * LocalBuilder.cs ILGenerator.cs: Get rid of 'module' field, obtain
+ needed objects from the ilgen object instead.
+
+2003-11-21 Zoltan Varga <vargaz@freemail.hu>
+
+ * TypeBuilder.cs FieldBuilder.cs MethodBuilder.cs ConstructorBuilder.cs: Add support for custom modifiers from NET 1.2.
+
+ * ILGenerator.cs: Remove unused abuilder member.
+
+2003-11-19 Andreas Nahr <ClassDevelopment@A-SoftTech.com>
+
+ * OpCodes.cs: Remove Boxval for v1.1+
+
+2003-11-19 Andreas Nahr <ClassDevelopment@A-SoftTech.com>
+
+ * OpCodes.cs: Small rearrange to fix csc compiler warning about obsolete member used
+
+2003-11-12 Zoltan Varga <vargaz@freemail.hu>
+
+ * AssemblyBuilderAccess.cs PackingSize: Add [Flags].
+
+ * AssemblyBuilder.cs (DefineDynamicModule): Make internal method
+ private.
+
+ * AssemblyBuilder.cs (Save): Write out the main module at the end.
+
2003-11-06 Zoltan Varga <vargaz@freemail.hu>
* ConstructorBuilder.cs (.ctor): Automatically add RTSpecialName flag
diff --git a/mcs/class/corlib/System.Reflection.Emit/ConstructorBuilder.cs b/mcs/class/corlib/System.Reflection.Emit/ConstructorBuilder.cs
index e3d70765ad5..418e03a843e 100644
--- a/mcs/class/corlib/System.Reflection.Emit/ConstructorBuilder.cs
+++ b/mcs/class/corlib/System.Reflection.Emit/ConstructorBuilder.cs
@@ -29,8 +29,10 @@ namespace System.Reflection.Emit {
private ParameterBuilder[] pinfo;
private CustomAttributeBuilder[] cattrs;
private bool init_locals = true;
+ private Type[][] paramModReq;
+ private Type[][] paramModOpt;
- internal ConstructorBuilder (TypeBuilder tb, MethodAttributes attributes, CallingConventions callingConvention, Type[] parameterTypes) {
+ internal ConstructorBuilder (TypeBuilder tb, MethodAttributes attributes, CallingConventions callingConvention, Type[] parameterTypes, Type[][] paramModReq, Type[][] paramModOpt) {
attrs = attributes | MethodAttributes.SpecialName | MethodAttributes.RTSpecialName;
call_conv = callingConvention;
if (parameterTypes != null) {
@@ -39,6 +41,8 @@ namespace System.Reflection.Emit {
}
type = tb;
table_idx = get_next_table_index (this, 0x06, true);
+ this.paramModReq = paramModReq;
+ this.paramModOpt = paramModOpt;
}
public bool InitLocals {
@@ -123,7 +127,7 @@ namespace System.Reflection.Emit {
return GetILGenerator (64);
}
internal ILGenerator GetILGenerator (int size) {
- ilgen = new ILGenerator (this, size);
+ ilgen = new ILGenerator (type.Module, ((ModuleBuilder)type.Module).GetTokenGenerator (), size);
return ilgen;
}
diff --git a/mcs/class/corlib/System.Reflection.Emit/DynamicMethod.cs b/mcs/class/corlib/System.Reflection.Emit/DynamicMethod.cs
new file mode 100644
index 00000000000..a8b7b0a238d
--- /dev/null
+++ b/mcs/class/corlib/System.Reflection.Emit/DynamicMethod.cs
@@ -0,0 +1,315 @@
+//
+// System.Reflection.Emit/DynamicMethod.cs
+//
+// Author:
+// Paolo Molaro (lupus@ximian.com)
+// Zoltan Varga (vargaz@freemail.hu)
+//
+// (C) 2003 Ximian, Inc. http://www.ximian.com
+//
+
+#if NET_1_2
+
+using System;
+using System.Reflection;
+using System.Reflection.Emit;
+using System.Globalization;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+namespace System.Reflection.Emit {
+
+ public sealed class DynamicMethod : MethodInfo {
+ #region Sync with reflection.h
+ private RuntimeMethodHandle mhandle;
+ private string name;
+ private Type returnType;
+ private Type[] parameters;
+ private MethodAttributes attributes;
+ private CallingConventions callingConvention;
+ private Module module;
+ private bool skipVisibility;
+ private bool init_locals = true;
+ private ILGenerator ilgen;
+ private int nrefs;
+ private object[] refs;
+ #endregion
+ private Delegate deleg;
+ private MonoMethod method;
+ private ParameterBuilder[] pinfo;
+
+ public DynamicMethod (string name, Type returnType, Type[] parameterTypes, Module m) : this (name, returnType, parameterTypes, m, false) {
+ }
+
+ public DynamicMethod (string name, Type returnType, Type[] parameterTypes, Type owner) : this (name, returnType, parameterTypes, owner, false) {
+ }
+
+ public DynamicMethod (string name, Type returnType, Type[] parameterTypes, Module m, bool skipVisibility) : this (name, MethodAttributes.Public | MethodAttributes.Static, CallingConventions.Standard, returnType, parameterTypes, m, skipVisibility) {
+ }
+
+ public DynamicMethod (string name, Type returnType, Type[] parameterTypes, Type owner, bool skipVisibility) : this (name, MethodAttributes.Public | MethodAttributes.Static, CallingConventions.Standard, returnType, parameterTypes, owner, skipVisibility) {
+ }
+
+ public DynamicMethod (string name, MethodAttributes attributes, CallingConventions callingConvention, Type returnType, Type[] parameterTypes, Type owner, bool skipVisibility) : this (name, attributes, callingConvention, returnType, parameterTypes, owner.Module, skipVisibility) {
+ }
+
+ public DynamicMethod (string name, MethodAttributes attributes, CallingConventions callingConvention, Type returnType, Type[] parameterTypes, Module m, bool skipVisibility) {
+ if (name == null)
+ throw new ArgumentNullException ("name");
+ if (name == String.Empty)
+ throw new ArgumentException ("Name can't be empty", "name");
+ if (returnType == null)
+ throw new ArgumentNullException ("returnType");
+ if (m == null)
+ throw new ArgumentNullException ("m");
+ if (returnType.IsByRef)
+ throw new ArgumentException ("Return type can't be a byref type", "returnType");
+ if (parameterTypes != null) {
+ for (int i = 0; i < parameterTypes.Length; ++i)
+ if (parameterTypes [i] == null)
+ throw new ArgumentException ("Parameter " + i + " is null", "parameterTypes");
+ }
+
+ this.name = name;
+ this.attributes = attributes | MethodAttributes.Static;
+ this.callingConvention = callingConvention;
+ this.returnType = returnType;
+ this.parameters = parameterTypes;
+ this.module = m;
+ this.skipVisibility = skipVisibility;
+ }
+
+ [MethodImplAttribute(MethodImplOptions.InternalCall)]
+ private extern void create_dynamic_method (DynamicMethod m);
+
+ private void CreateDynMethod () {
+ if (mhandle.Value == IntPtr.Zero)
+ create_dynamic_method (this);
+ }
+
+ public Delegate CreateDelegate (Type delegateType) {
+ if (delegateType == null)
+ throw new ArgumentNullException ("delegateType");
+ if (deleg != null)
+ return deleg;
+
+ CreateDynMethod ();
+
+ deleg = Delegate.CreateDelegate (delegateType, this);
+ return deleg;
+ }
+
+ [MonoTODO]
+ public ParameterBuilder DefineParameter (int position, ParameterAttributes attributes, string strParamName)
+ {
+ //
+ // Extension: Mono allows position == 0 for the return attribute
+ //
+ if ((position < 0) || (position > parameters.Length))
+ throw new ArgumentOutOfRangeException ("position");
+
+ RejectIfCreated ();
+
+ throw new NotImplementedException ();
+ }
+
+ public override MethodInfo GetBaseDefinition () {
+ return this;
+ }
+
+ [MonoTODO]
+ public override object[] GetCustomAttributes (bool inherit) {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public override object[] GetCustomAttributes (Type attributeType,
+ bool inherit) {
+ throw new NotImplementedException ();
+ }
+
+ public ILGenerator GetILGenerator () {
+ return GetILGenerator (64);
+ }
+
+ public ILGenerator GetILGenerator (int size) {
+ if (((GetMethodImplementationFlags () & MethodImplAttributes.CodeTypeMask) !=
+ MethodImplAttributes.IL) ||
+ ((GetMethodImplementationFlags () & MethodImplAttributes.ManagedMask) !=
+ MethodImplAttributes.Managed))
+ throw new InvalidOperationException ("Method body should not exist.");
+ if (ilgen != null)
+ return ilgen;
+ ilgen = new ILGenerator (Module, new DynamicMethodTokenGenerator (this), size);
+ return ilgen;
+ }
+
+ public override MethodImplAttributes GetMethodImplementationFlags () {
+ return MethodImplAttributes.IL | MethodImplAttributes.Managed;
+ }
+
+ public override ParameterInfo[] GetParameters () {
+ if (parameters == null)
+ return new ParameterInfo [0];
+
+ ParameterInfo[] retval = new ParameterInfo [parameters.Length];
+ for (int i = 0; i < parameters.Length; i++) {
+ retval [i] = new ParameterInfo (pinfo == null ? null : pinfo [i + 1], parameters [i], this, i + 1);
+ }
+ return retval;
+ }
+
+ public override object Invoke (object obj, object[] parameters) {
+ CreateDynMethod ();
+ if (method == null)
+ method = new MonoMethod (mhandle);
+ return method.Invoke (obj, parameters);
+ }
+
+ public override object Invoke (object obj, BindingFlags invokeAttr,
+ Binder binder, object[] parameters,
+ CultureInfo culture) {
+ CreateDynMethod ();
+ if (method == null)
+ method = new MonoMethod (mhandle);
+ return method.Invoke (obj, parameters);
+ }
+
+ [MonoTODO]
+ public override bool IsDefined (Type attributeType, bool inherit) {
+ throw new NotImplementedException ();
+ }
+
+ public override string ToString () {
+ string parms = "";
+ ParameterInfo[] p = GetParameters ();
+ for (int i = 0; i < p.Length; ++i) {
+ if (i > 0)
+ parms = parms + ", ";
+ parms = parms + p [i].ParameterType.Name;
+ }
+ return ReturnType.Name+" "+Name+"("+parms+")";
+ }
+
+ public override MethodAttributes Attributes {
+ get {
+ return attributes;
+ }
+ }
+
+ public override CallingConventions CallingConvention {
+ get {
+ return callingConvention;
+ }
+ }
+
+ public override Type DeclaringType {
+ get {
+ return null;
+ }
+ }
+
+ public bool InitLocals {
+ get {
+ return init_locals;
+ }
+ set {
+ init_locals = value;
+ }
+ }
+
+ public override RuntimeMethodHandle MethodHandle {
+ get {
+ return mhandle;
+ }
+ }
+
+ public Module Module {
+ get {
+ return module;
+ }
+ }
+
+ public override string Name {
+ get {
+ return name;
+ }
+ }
+
+ public override Type ReflectedType {
+ get {
+ return null;
+ }
+ }
+
+ [MonoTODO]
+ public ParameterInfo ReturnParameter {
+ get {
+ throw new NotImplementedException ();
+ }
+ }
+
+ public override Type ReturnType {
+ get {
+ return returnType;
+ }
+ }
+
+ [MonoTODO]
+ public override ICustomAttributeProvider ReturnTypeCustomAttributes {
+ get {
+ throw new NotImplementedException ();
+ }
+ }
+
+ private void RejectIfCreated () {
+ if (mhandle.Value != IntPtr.Zero)
+ throw new InvalidOperationException ("Type definition of the method is complete.");
+ }
+
+ private Exception NotSupported () {
+ return new NotSupportedException ("The invoked member is not supported on a dynamic method.");
+ }
+
+ public override Type[] GetGenericArguments ()
+ {
+ throw new NotImplementedException ();
+ }
+
+ internal int AddRef (object reference) {
+ if (refs == null)
+ refs = new object [4];
+ if (nrefs >= refs.Length) {
+ object [] new_refs = new object [refs.Length * 2];
+ System.Array.Copy (refs, new_refs, refs.Length);
+ refs = new_refs;
+ }
+ refs [nrefs] = reference;
+ nrefs ++;
+ return nrefs;
+ }
+ }
+
+ internal class DynamicMethodTokenGenerator : TokenGenerator {
+
+ private DynamicMethod m;
+
+ public DynamicMethodTokenGenerator (DynamicMethod m) {
+ this.m = m;
+ }
+
+ public int GetToken (string str) {
+ return m.AddRef (str);
+ }
+
+ public int GetToken (MemberInfo member) {
+ return m.AddRef (member);
+ }
+
+ public int GetToken (SignatureHelper helper) {
+ return m.AddRef (helper);
+ }
+ }
+}
+
+#endif
diff --git a/mcs/class/corlib/System.Reflection.Emit/EnumBuilder.cs b/mcs/class/corlib/System.Reflection.Emit/EnumBuilder.cs
index b5ddecace33..8edb5698ca7 100755
--- a/mcs/class/corlib/System.Reflection.Emit/EnumBuilder.cs
+++ b/mcs/class/corlib/System.Reflection.Emit/EnumBuilder.cs
@@ -265,7 +265,7 @@ namespace System.Reflection.Emit {
SetCustomAttribute (new CustomAttributeBuilder (con, binaryAttribute));
}
-#if GENERICS
+#if NET_1_2
public override bool HasGenericArguments {
get {
throw new NotImplementedException ();
diff --git a/mcs/class/corlib/System.Reflection.Emit/FieldBuilder.cs b/mcs/class/corlib/System.Reflection.Emit/FieldBuilder.cs
index 7b36d7fb54e..cbc08a6b420 100755
--- a/mcs/class/corlib/System.Reflection.Emit/FieldBuilder.cs
+++ b/mcs/class/corlib/System.Reflection.Emit/FieldBuilder.cs
@@ -28,11 +28,15 @@ namespace System.Reflection.Emit {
private CustomAttributeBuilder[] cattrs;
private UnmanagedMarshal marshal_info;
private RuntimeFieldHandle handle;
+ private Type[] modReq;
+ private Type[] modOpt;
- internal FieldBuilder (TypeBuilder tb, string fieldName, Type type, FieldAttributes attributes) {
+ internal FieldBuilder (TypeBuilder tb, string fieldName, Type type, FieldAttributes attributes, Type[] modReq, Type[] modOpt) {
attrs = attributes;
name = fieldName;
this.type = type;
+ this.modReq = modReq;
+ this.modOpt = modOpt;
offset = -1;
typeb = tb;
table_idx = tb.get_next_table_index (this, 0x04, true);
diff --git a/mcs/class/corlib/System.Reflection.Emit/ILGenerator.cs b/mcs/class/corlib/System.Reflection.Emit/ILGenerator.cs
index ba28f1a4de6..6ff8e5bd3f4 100644
--- a/mcs/class/corlib/System.Reflection.Emit/ILGenerator.cs
+++ b/mcs/class/corlib/System.Reflection.Emit/ILGenerator.cs
@@ -117,6 +117,14 @@ namespace System.Reflection.Emit {
public int code_pos;
}
+ internal interface TokenGenerator {
+ int GetToken (string str);
+
+ int GetToken (MemberInfo member);
+
+ int GetToken (SignatureHelper helper);
+ }
+
public class ILGenerator: Object {
private struct LabelFixup {
public int size;
@@ -125,8 +133,8 @@ namespace System.Reflection.Emit {
public int label_idx;
};
static Type void_type = typeof (void);
+ #region Sync with reflection.h
private byte[] code;
- private MethodBase mbuilder; /* a MethodBuilder or ConstructorBuilder */
private int code_len;
private int max_stack;
private int cur_stack;
@@ -139,20 +147,20 @@ namespace System.Reflection.Emit {
private int num_labels;
private LabelFixup[] fixups;
private int num_fixups;
- private ModuleBuilder module;
- private AssemblyBuilder abuilder;
- private IMonoSymbolWriter sym_writer;
+ #endregion
+ internal Module module;
+ internal IMonoSymbolWriter sym_writer;
private Stack scopes;
private int cur_block;
private Stack open_blocks;
+ private TokenGenerator token_gen;
- internal ILGenerator (MethodBase mb, int size)
+ internal ILGenerator (Module m, TokenGenerator token_gen, int size)
{
if (size < 0)
size = 128;
code_len = 0;
code = new byte [size];
- mbuilder = mb;
cur_stack = max_stack = 0;
num_fixups = num_labels = 0;
label_to_addr = new int [8];
@@ -160,14 +168,11 @@ namespace System.Reflection.Emit {
fixups = new LabelFixup [8];
token_fixups = new ILTokenInfo [8];
num_token_fixups = 0;
- if (mb is MethodBuilder) {
- module = (ModuleBuilder)((MethodBuilder)mb).TypeBuilder.Module;
- } else if (mb is ConstructorBuilder) {
- module = (ModuleBuilder)((ConstructorBuilder)mb).TypeBuilder.Module;
- }
- abuilder = (AssemblyBuilder)module.Assembly;
- sym_writer = module.symbol_writer;
+ module = m;
+ if (module is ModuleBuilder)
+ sym_writer = ((ModuleBuilder)module).symbol_writer;
open_blocks = new Stack ();
+ this.token_gen = token_gen;
}
private void add_token_fixup (MemberInfo mi)
@@ -351,7 +356,7 @@ namespace System.Reflection.Emit {
public LocalBuilder DeclareLocal (Type localType)
{
- LocalBuilder res = new LocalBuilder (module, localType, this);
+ LocalBuilder res = new LocalBuilder (localType, this);
if (locals != null) {
LocalBuilder[] new_l = new LocalBuilder [locals.Length + 1];
System.Array.Copy (locals, new_l, locals.Length);
@@ -395,7 +400,7 @@ namespace System.Reflection.Emit {
public virtual void Emit (OpCode opcode, ConstructorInfo constructor)
{
- int token = module.GetToken (constructor);
+ int token = token_gen.GetToken (constructor);
make_room (6);
ll_emit (opcode);
if (constructor.DeclaringType.Module == module)
@@ -430,7 +435,7 @@ namespace System.Reflection.Emit {
public virtual void Emit (OpCode opcode, FieldInfo field)
{
- int token = module.GetToken (field);
+ int token = token_gen.GetToken (field);
make_room (6);
ll_emit (opcode);
if (field.DeclaringType.Module == module)
@@ -580,7 +585,7 @@ namespace System.Reflection.Emit {
if (method == null)
throw new ArgumentNullException ("method");
- int token = module.GetToken (method);
+ int token = token_gen.GetToken (method);
make_room (6);
ll_emit (opcode);
if (method.DeclaringType.Module == module)
@@ -603,7 +608,7 @@ namespace System.Reflection.Emit {
public virtual void Emit (OpCode opcode, SignatureHelper shelper)
{
- int token = module.GetToken (shelper);
+ int token = token_gen.GetToken (shelper);
make_room (6);
ll_emit (opcode);
emit_int (token);
@@ -627,7 +632,7 @@ namespace System.Reflection.Emit {
public virtual void Emit (OpCode opcode, string val)
{
- int token = module.GetToken (val);
+ int token = token_gen.GetToken (val);
make_room (6);
ll_emit (opcode);
emit_int (token);
@@ -637,7 +642,7 @@ namespace System.Reflection.Emit {
{
make_room (6);
ll_emit (opcode);
- emit_int (module.GetToken (type));
+ emit_int (token_gen.GetToken (type));
}
[MonoTODO ("Do something about varargs method")]
diff --git a/mcs/class/corlib/System.Reflection.Emit/LocalBuilder.cs b/mcs/class/corlib/System.Reflection.Emit/LocalBuilder.cs
index 6ab80c7f2a7..43a6ff90cc0 100755
--- a/mcs/class/corlib/System.Reflection.Emit/LocalBuilder.cs
+++ b/mcs/class/corlib/System.Reflection.Emit/LocalBuilder.cs
@@ -30,13 +30,11 @@ namespace System.Reflection.Emit {
//
// Order does not matter after here
//
- private ModuleBuilder module;
internal uint position;
internal ILGenerator ilgen;
- internal LocalBuilder (ModuleBuilder m, Type t, ILGenerator ilgen)
+ internal LocalBuilder (Type t, ILGenerator ilgen)
{
- this.module = m;
this.type = t;
this.ilgen = ilgen;
}
@@ -44,11 +42,11 @@ namespace System.Reflection.Emit {
{
this.name = lname;
- SignatureHelper sighelper = SignatureHelper.GetLocalVarSigHelper (module);
+ SignatureHelper sighelper = SignatureHelper.GetLocalVarSigHelper (ilgen.module);
sighelper.AddArgument (type);
byte[] signature = sighelper.GetSignature ();
- module.symbol_writer.DefineLocalVariable (lname, FieldAttributes.Private,
+ ilgen.sym_writer.DefineLocalVariable (lname, FieldAttributes.Private,
signature, SymAddressKind.ILOffset,
(int) position, 0, 0,
startOffset, endOffset);
diff --git a/mcs/class/corlib/System.Reflection.Emit/MethodBuilder.cs b/mcs/class/corlib/System.Reflection.Emit/MethodBuilder.cs
index 783343cdf0a..f5bd829957e 100755
--- a/mcs/class/corlib/System.Reflection.Emit/MethodBuilder.cs
+++ b/mcs/class/corlib/System.Reflection.Emit/MethodBuilder.cs
@@ -38,12 +38,20 @@ namespace System.Reflection.Emit {
private CallingConventions call_conv;
private bool init_locals = true;
private TypeBuilder.MonoGenericParam[] generic_params;
+ private Type[] returnModReq;
+ private Type[] returnModOpt;
+ private Type[][] paramModReq;
+ private Type[][] paramModOpt;
- internal MethodBuilder (TypeBuilder tb, string name, MethodAttributes attributes, CallingConventions callingConvention, Type returnType, Type[] parameterTypes) {
+ internal MethodBuilder (TypeBuilder tb, string name, MethodAttributes attributes, CallingConventions callingConvention, Type returnType, Type[] returnModReq, Type[] returnModOpt, Type[] parameterTypes, Type[][] paramModReq, Type[][] paramModOpt) {
this.name = name;
this.attrs = attributes;
this.call_conv = callingConvention;
this.rtype = returnType;
+ this.returnModReq = returnModReq;
+ this.returnModOpt = returnModOpt;
+ this.paramModReq = paramModReq;
+ this.paramModOpt = paramModOpt;
// The MSDN docs does not specify this, but the MS MethodBuilder
// appends a HasThis flag if the method is not static
if ((attributes & MethodAttributes.Static) == 0)
@@ -58,9 +66,9 @@ namespace System.Reflection.Emit {
}
internal MethodBuilder (TypeBuilder tb, string name, MethodAttributes attributes,
- CallingConventions callingConvention, Type returnType, Type[] parameterTypes,
+ CallingConventions callingConvention, Type returnType, Type[] returnModReq, Type[] returnModOpt, Type[] parameterTypes, Type[][] paramModReq, Type[][] paramModOpt,
String dllName, String entryName, CallingConvention nativeCConv, CharSet nativeCharset)
- : this (tb, name, attributes, callingConvention, returnType, parameterTypes) {
+ : this (tb, name, attributes, callingConvention, returnType, returnModReq, returnModOpt, parameterTypes, paramModReq, paramModOpt) {
pi_dll = dllName;
pi_entry = entryName;
native_cc = nativeCConv;
@@ -159,7 +167,7 @@ namespace System.Reflection.Emit {
throw new InvalidOperationException ("Method body should not exist.");
if (ilgen != null)
return ilgen;
- ilgen = new ILGenerator (this, size);
+ ilgen = new ILGenerator (type.Module, ((ModuleBuilder)type.Module).GetTokenGenerator (), size);
return ilgen;
}
@@ -235,7 +243,7 @@ namespace System.Reflection.Emit {
return new NotSupportedException ("The invoked member is not supported in a dynamic module.");
}
-#if GENERICS
+#if NET_1_2
[MethodImplAttribute(MethodImplOptions.InternalCall)]
private extern Type define_generic_parameter (TypeBuilder.MonoGenericParam param);
diff --git a/mcs/class/corlib/System.Reflection.Emit/ModuleBuilder.cs b/mcs/class/corlib/System.Reflection.Emit/ModuleBuilder.cs
index 23300a07f27..8f50832b1dd 100644
--- a/mcs/class/corlib/System.Reflection.Emit/ModuleBuilder.cs
+++ b/mcs/class/corlib/System.Reflection.Emit/ModuleBuilder.cs
@@ -16,6 +16,7 @@ using System.Runtime.InteropServices;
using System.Diagnostics.SymbolStore;
using System.IO;
using Mono.CSharp.Debugger;
+using System.Globalization;
namespace System.Reflection.Emit {
public class ModuleBuilder : Module {
@@ -35,6 +36,7 @@ namespace System.Reflection.Emit {
Hashtable us_string_cache = new Hashtable ();
private int[] table_indexes;
bool transient;
+ ModuleBuilderTokenGenerator token_gen;
[MethodImplAttribute(MethodImplOptions.InternalCall)]
private static extern void basic_init (ModuleBuilder ab);
@@ -243,7 +245,7 @@ namespace System.Reflection.Emit {
private TypeBuilder search_in_array (TypeBuilder[] arr, string className) {
int i;
for (i = 0; i < arr.Length; ++i) {
- if (String.Compare (className, arr [i].FullName, true) == 0) {
+ if (String.Compare (className, arr [i].FullName, true, CultureInfo.InvariantCulture) == 0) {
return arr [i];
}
}
@@ -253,7 +255,7 @@ namespace System.Reflection.Emit {
private TypeBuilder search_nested_in_array (TypeBuilder[] arr, string className) {
int i;
for (i = 0; i < arr.Length; ++i) {
- if (String.Compare (className, arr [i].Name, true) == 0)
+ if (String.Compare (className, arr [i].Name, true, CultureInfo.InvariantCulture) == 0)
return arr [i];
}
return null;
@@ -397,6 +399,12 @@ namespace System.Reflection.Emit {
return getToken (this, helper);
}
+ internal TokenGenerator GetTokenGenerator () {
+ if (token_gen == null)
+ token_gen = new ModuleBuilderTokenGenerator (this);
+ return token_gen;
+ }
+
[MethodImplAttribute(MethodImplOptions.InternalCall)]
private static extern void build_metadata (ModuleBuilder mb);
@@ -455,4 +463,25 @@ namespace System.Reflection.Emit {
}
}
}
+
+ internal class ModuleBuilderTokenGenerator : TokenGenerator {
+
+ private ModuleBuilder mb;
+
+ public ModuleBuilderTokenGenerator (ModuleBuilder mb) {
+ this.mb = mb;
+ }
+
+ public int GetToken (string str) {
+ return mb.GetToken (str);
+ }
+
+ public int GetToken (MemberInfo member) {
+ return mb.GetToken (member);
+ }
+
+ public int GetToken (SignatureHelper helper) {
+ return mb.GetToken (helper);
+ }
+ }
}
diff --git a/mcs/class/corlib/System.Reflection.Emit/MonoArrayMethod.cs b/mcs/class/corlib/System.Reflection.Emit/MonoArrayMethod.cs
index 32fda9135b8..a94a2d1752e 100755
--- a/mcs/class/corlib/System.Reflection.Emit/MonoArrayMethod.cs
+++ b/mcs/class/corlib/System.Reflection.Emit/MonoArrayMethod.cs
@@ -108,7 +108,7 @@ namespace System.Reflection {
return ReturnType.Name+" "+Name+"("+parms+")";
}
-#if GENERICS
+#if NET_1_2
public override Type[] GetGenericArguments ()
{
throw new NotImplementedException ();
diff --git a/mcs/class/corlib/System.Reflection.Emit/OpCodes.cs b/mcs/class/corlib/System.Reflection.Emit/OpCodes.cs
index c73bd928a60..b73393fb9a0 100644
--- a/mcs/class/corlib/System.Reflection.Emit/OpCodes.cs
+++ b/mcs/class/corlib/System.Reflection.Emit/OpCodes.cs
@@ -36,7 +36,9 @@ namespace System.Reflection.Emit {
public static readonly OpCode Bne_Un;
public static readonly OpCode Bne_Un_S;
public static readonly OpCode Box;
-[Obsolete] public static readonly OpCode Boxval;
+#if NET_1_0
+[Obsolete] public static readonly OpCode Boxval = new OpCode("boxval", 1, OpCodeType.Primitive, OperandType.InlineType, StackBehaviour.Pop1, StackBehaviour.Pushref, FlowControl.Next, 0xFF, 0x8C);
+#endif
public static readonly OpCode Br;
public static readonly OpCode Br_S;
public static readonly OpCode Break;
@@ -133,7 +135,7 @@ namespace System.Reflection.Emit {
public static readonly OpCode Ldelem_U2;
public static readonly OpCode Ldelem_U4;
public static readonly OpCode Ldelema;
-#if GENERICS
+#if NET_1_2
public static readonly OpCode Ldelem_Any;
#endif
public static readonly OpCode Ldfld;
@@ -208,7 +210,7 @@ namespace System.Reflection.Emit {
public static readonly OpCode Stelem_R4;
public static readonly OpCode Stelem_R8;
public static readonly OpCode Stelem_Ref;
-#if GENERICS
+#if NET_1_2
public static readonly OpCode Stelem_Any;
#endif
public static readonly OpCode Stfld;
@@ -236,7 +238,7 @@ namespace System.Reflection.Emit {
public static readonly OpCode Throw;
public static readonly OpCode Unaligned;
public static readonly OpCode Unbox;
-#if GENERICS
+#if NET_1_2
public static readonly OpCode Unbox_Any;
#endif
public static readonly OpCode Volatile;
@@ -377,7 +379,7 @@ namespace System.Reflection.Emit {
Isinst = new OpCode("isinst", 1, OpCodeType.Objmodel, OperandType.InlineType, StackBehaviour.Popref, StackBehaviour.Pushi, FlowControl.Next, 0xFF, 0x75);
Conv_R_Un = new OpCode("conv.r.un", 1, OpCodeType.Primitive, OperandType.InlineNone, StackBehaviour.Pop1, StackBehaviour.Pushr8, FlowControl.Next, 0xFF, 0x76);
Unbox = new OpCode("unbox", 1, OpCodeType.Primitive, OperandType.InlineType, StackBehaviour.Popref, StackBehaviour.Pushi, FlowControl.Next, 0xFF, 0x79);
-#if GENERICS
+#if NET_1_2
Unbox_Any = new OpCode("unbox.any", 1, OpCodeType.Objmodel, OperandType.InlineType, StackBehaviour.Popref, StackBehaviour.Push1, FlowControl.Next, 0xFF, 0xa5);
#endif
Throw = new OpCode("throw", 1, OpCodeType.Objmodel, OperandType.InlineNone, StackBehaviour.Popref, StackBehaviour.Push0, FlowControl.Throw, 0xFF, 0x7A);
@@ -399,12 +401,11 @@ namespace System.Reflection.Emit {
Conv_Ovf_U8_Un = new OpCode("conv.ovf.u8.un", 1, OpCodeType.Primitive, OperandType.InlineNone, StackBehaviour.Pop1, StackBehaviour.Pushi8, FlowControl.Next, 0xFF, 0x89);
Conv_Ovf_I_Un = new OpCode("conv.ovf.i.un", 1, OpCodeType.Primitive, OperandType.InlineNone, StackBehaviour.Pop1, StackBehaviour.Pushi, FlowControl.Next, 0xFF, 0x8A);
Conv_Ovf_U_Un = new OpCode("conv.ovf.u.un", 1, OpCodeType.Primitive, OperandType.InlineNone, StackBehaviour.Pop1, StackBehaviour.Pushi, FlowControl.Next, 0xFF, 0x8B);
- Boxval = new OpCode("boxval", 1, OpCodeType.Primitive, OperandType.InlineType, StackBehaviour.Pop1, StackBehaviour.Pushref, FlowControl.Next, 0xFF, 0x8C);
Box = new OpCode("box", 1, OpCodeType.Primitive, OperandType.InlineType, StackBehaviour.Pop1, StackBehaviour.Pushref, FlowControl.Next, 0xFF, 0x8C);
Newarr = new OpCode("newarr", 1, OpCodeType.Objmodel, OperandType.InlineType, StackBehaviour.Popi, StackBehaviour.Pushref, FlowControl.Next, 0xFF, 0x8D);
Ldlen = new OpCode("ldlen", 1, OpCodeType.Objmodel, OperandType.InlineNone, StackBehaviour.Popref, StackBehaviour.Pushi, FlowControl.Next, 0xFF, 0x8E);
Ldelema = new OpCode("ldelema", 1, OpCodeType.Objmodel, OperandType.InlineType, StackBehaviour.Popref_popi, StackBehaviour.Pushi, FlowControl.Next, 0xFF, 0x8F);
-#if GENERICS
+#if NET_1_2
Ldelem_Any = new OpCode("ldelem.any", 1, OpCodeType.Objmodel, OperandType.InlineType, StackBehaviour.Popref_popi, StackBehaviour.Push1, FlowControl.Next, 0xFF, 0xA3);
#endif
Ldloc_3 = new OpCode("ldloc.3", 1, OpCodeType.Macro, OperandType.InlineNone, StackBehaviour.Pop0, StackBehaviour.Push1, FlowControl.Next, 0xFF, 0x9);
@@ -430,7 +431,7 @@ namespace System.Reflection.Emit {
Stelem_R4 = new OpCode("stelem.r4", 1, OpCodeType.Objmodel, OperandType.InlineNone, StackBehaviour.Popref_popi_popr4, StackBehaviour.Push0, FlowControl.Next, 0xFF, 0xA0);
Stelem_R8 = new OpCode("stelem.r8", 1, OpCodeType.Objmodel, OperandType.InlineNone, StackBehaviour.Popref_popi_popr8, StackBehaviour.Push0, FlowControl.Next, 0xFF, 0xA1);
Stelem_Ref = new OpCode("stelem.ref", 1, OpCodeType.Objmodel, OperandType.InlineNone, StackBehaviour.Popref_popi_popref, StackBehaviour.Push0, FlowControl.Next, 0xFF, 0xA2);
-#if GENERICS
+#if NET_1_2
Stelem_Any = new OpCode("stelem.any", 1, OpCodeType.Objmodel, OperandType.InlineType, StackBehaviour.Popref_popi_popref, StackBehaviour.Push0, FlowControl.Next, 0xFF, 0xA4);
#endif
Stloc_1 = new OpCode("stloc.1", 1, OpCodeType.Macro, OperandType.InlineNone, StackBehaviour.Pop1, StackBehaviour.Push0, FlowControl.Next, 0xFF, 0xB);
diff --git a/mcs/class/corlib/System.Reflection.Emit/PackingSize.cs b/mcs/class/corlib/System.Reflection.Emit/PackingSize.cs
index 82c74276386..ffddfeb1a26 100644
--- a/mcs/class/corlib/System.Reflection.Emit/PackingSize.cs
+++ b/mcs/class/corlib/System.Reflection.Emit/PackingSize.cs
@@ -8,6 +8,7 @@ namespace System.Reflection.Emit {
/// <summary>
/// Specifies the packing size (data alignment) of a type.
/// </summary>
+ [Flags]
public enum PackingSize {
/// <summary>
diff --git a/mcs/class/corlib/System.Reflection.Emit/StringToken.cs b/mcs/class/corlib/System.Reflection.Emit/StringToken.cs
index a872b8967bd..b5ef7a3d7ff 100644
--- a/mcs/class/corlib/System.Reflection.Emit/StringToken.cs
+++ b/mcs/class/corlib/System.Reflection.Emit/StringToken.cs
@@ -14,12 +14,8 @@ namespace System.Reflection.Emit {
internal int tokValue;
- public static readonly StringToken Empty;
-
-
static StringToken ()
{
- Empty = new StringToken ();
}
diff --git a/mcs/class/corlib/System.Reflection.Emit/TypeBuilder.cs b/mcs/class/corlib/System.Reflection.Emit/TypeBuilder.cs
index 61d1995b38a..15963b0bba5 100644
--- a/mcs/class/corlib/System.Reflection.Emit/TypeBuilder.cs
+++ b/mcs/class/corlib/System.Reflection.Emit/TypeBuilder.cs
@@ -317,11 +317,20 @@ namespace System.Reflection.Emit {
return DefineNestedType (name, attr, parent, null, packsize, UnspecifiedTypeSize);
}
- public ConstructorBuilder DefineConstructor (MethodAttributes attributes, CallingConventions callingConvention, Type[] parameterTypes)
+ public ConstructorBuilder DefineConstructor (MethodAttributes attributes, CallingConventions callingConvention, Type[] parameterTypes) {
+ return DefineConstructor (attributes, callingConvention, parameterTypes, null, null);
+ }
+
+#if NET_1_2
+ public
+#else
+ internal
+#endif
+ ConstructorBuilder DefineConstructor (MethodAttributes attributes, CallingConventions callingConvention, Type[] parameterTypes, Type[][] requiredCustomModifiers, Type[][] optionalCustomModifiers)
{
if (is_created)
throw not_after_created ();
- ConstructorBuilder cb = new ConstructorBuilder (this, attributes, callingConvention, parameterTypes);
+ ConstructorBuilder cb = new ConstructorBuilder (this, attributes, callingConvention, parameterTypes, requiredCustomModifiers, optionalCustomModifiers);
if (ctors != null) {
ConstructorBuilder[] new_ctors = new ConstructorBuilder [ctors.Length+1];
System.Array.Copy (ctors, new_ctors, ctors.Length);
@@ -376,6 +385,15 @@ namespace System.Reflection.Emit {
}
public MethodBuilder DefineMethod( string name, MethodAttributes attributes, CallingConventions callingConvention, Type returnType, Type[] parameterTypes) {
+ return DefineMethod (name, attributes, callingConvention, returnType, null, null, parameterTypes, null, null);
+ }
+
+#if NET_1_2
+ public
+#else
+ internal
+#endif
+ MethodBuilder DefineMethod( string name, MethodAttributes attributes, CallingConventions callingConvention, Type returnType, Type[] returnTypeRequiredCustomModifiers, Type[] returnTypeOptionalCustomModifiers, Type[] parameterTypes, Type[][] parameterTypeRequiredCustomModifiers, Type[][] parameterTypeOptionalCustomModifiers) {
check_name ("name", name);
if (is_created)
throw not_after_created ();
@@ -386,12 +404,33 @@ namespace System.Reflection.Emit {
if (returnType == null)
returnType = pmodule.assemblyb.corlib_void_type;
- MethodBuilder res = new MethodBuilder (this, name, attributes, callingConvention, returnType, parameterTypes);
+ MethodBuilder res = new MethodBuilder (this, name, attributes, callingConvention, returnType, returnTypeRequiredCustomModifiers, returnTypeOptionalCustomModifiers, parameterTypes, parameterTypeRequiredCustomModifiers, parameterTypeOptionalCustomModifiers);
append_method (res);
return res;
}
public MethodBuilder DefinePInvokeMethod (string name, string dllName, string entryName, MethodAttributes attributes, CallingConventions callingConvention, Type returnType, Type[] parameterTypes, CallingConvention nativeCallConv, CharSet nativeCharSet) {
+ return DefinePInvokeMethod (name, dllName, entryName, attributes, callingConvention, returnType, null, null, parameterTypes, null, null, nativeCallConv, nativeCharSet);
+ }
+
+#if NET_1_2
+ public
+#else
+ internal
+#endif
+ MethodBuilder DefinePInvokeMethod (
+ string name,
+ string dllName,
+ string entryName, MethodAttributes attributes,
+ CallingConventions callingConvention,
+ Type returnType,
+ Type[] returnTypeRequiredCustomModifiers,
+ Type[] returnTypeOptionalCustomModifiers,
+ Type[] parameterTypes,
+ Type[][] parameterTypeRequiredCustomModifiers,
+ Type[][] parameterTypeOptionalCustomModifiers,
+ CallingConvention nativeCallConv,
+ CharSet nativeCharSet) {
check_name ("name", name);
check_name ("dllName", dllName);
check_name ("entryName", entryName);
@@ -402,8 +441,22 @@ namespace System.Reflection.Emit {
if (is_created)
throw not_after_created ();
- MethodBuilder res = new MethodBuilder (this, name, attributes, callingConvention, returnType, parameterTypes,
- dllName, entryName, nativeCallConv, nativeCharSet);
+ MethodBuilder res
+ = new MethodBuilder (
+ this,
+ name,
+ attributes,
+ callingConvention,
+ returnType,
+ returnTypeRequiredCustomModifiers,
+ returnTypeOptionalCustomModifiers,
+ parameterTypes,
+ parameterTypeRequiredCustomModifiers,
+ parameterTypeOptionalCustomModifiers,
+ dllName,
+ entryName,
+ nativeCallConv,
+ nativeCharSet);
append_method (res);
return res;
}
@@ -428,13 +481,22 @@ namespace System.Reflection.Emit {
}
public FieldBuilder DefineField( string fieldName, Type type, FieldAttributes attributes) {
+ return DefineField (fieldName, type, null, null, attributes);
+ }
+
+#if NET_1_2
+ public
+#else
+ internal
+#endif
+ FieldBuilder DefineField( string fieldName, Type type, Type[] requiredCustomAttributes, Type[] optionalCustomAttributes, FieldAttributes attributes) {
check_name ("fieldName", fieldName);
if (type == typeof (void))
throw new ArgumentException ("type", "Bad field type in defining field.");
if (is_created)
throw not_after_created ();
- FieldBuilder res = new FieldBuilder (this, fieldName, type, attributes);
+ FieldBuilder res = new FieldBuilder (this, fieldName, type, attributes, requiredCustomAttributes, optionalCustomAttributes);
if (fields != null) {
FieldBuilder[] new_fields = new FieldBuilder [fields.Length+1];
System.Array.Copy (fields, new_fields, fields.Length);
@@ -588,7 +650,39 @@ namespace System.Reflection.Emit {
}
public override FieldInfo GetField( string name, BindingFlags bindingAttr) {
- throw not_supported ();
+ if (fields == null)
+ return null;
+
+ bool match;
+ FieldAttributes mattrs;
+
+ foreach (FieldInfo c in fields) {
+ if (c.Name != name)
+ continue;
+ match = false;
+ mattrs = c.Attributes;
+ if ((mattrs & FieldAttributes.FieldAccessMask) == FieldAttributes.Public) {
+ if ((bindingAttr & BindingFlags.Public) != 0)
+ match = true;
+ } else {
+ if ((bindingAttr & BindingFlags.NonPublic) != 0)
+ match = true;
+ }
+ if (!match)
+ continue;
+ match = false;
+ if ((mattrs & FieldAttributes.Static) != 0) {
+ if ((bindingAttr & BindingFlags.Static) != 0)
+ match = true;
+ } else {
+ if ((bindingAttr & BindingFlags.Instance) != 0)
+ match = true;
+ }
+ if (!match)
+ continue;
+ return c;
+ }
+ return null;
}
public override FieldInfo[] GetFields (BindingFlags bindingAttr) {
@@ -998,7 +1092,7 @@ namespace System.Reflection.Emit {
throw new ArgumentException (argName, "Illegal name.");
}
-#if GENERICS
+#if NET_1_2
public override Type GetGenericTypeDefinition ()
{
setup_generic_class (this);
diff --git a/mcs/class/corlib/System.Reflection/Assembly.cs b/mcs/class/corlib/System.Reflection/Assembly.cs
index 5be72af2c25..d32b0d79a5b 100644
--- a/mcs/class/corlib/System.Reflection/Assembly.cs
+++ b/mcs/class/corlib/System.Reflection/Assembly.cs
@@ -20,6 +20,7 @@ using System.Collections;
namespace System.Reflection {
[Serializable]
+ [ClassInterface(ClassInterfaceType.AutoDual)]
public class Assembly : System.Reflection.ICustomAttributeProvider,
System.Security.IEvidenceFactory, System.Runtime.Serialization.ISerializable {
private IntPtr _mono_assembly;
@@ -230,6 +231,9 @@ namespace System.Reflection {
return InternalGetType (null, name, throwOnError, ignoreCase);
}
+
+ [MethodImplAttribute (MethodImplOptions.InternalCall)]
+ internal extern static void InternalGetAssemblyName (string assemblyFile, AssemblyName aname);
[MethodImplAttribute (MethodImplOptions.InternalCall)]
static extern void FillName (Assembly ass, AssemblyName aname);
@@ -352,10 +356,16 @@ namespace System.Reflection {
[MonoTODO]
public static Assembly LoadWithPartialName (string partialName, Evidence securityEvidence)
{
- return AppDomain.CurrentDomain.Load (partialName, securityEvidence);
+ try {
+ return AppDomain.CurrentDomain.Load (partialName, securityEvidence);
+ }
+ catch (Exception ex) {
+ // According to MSDN, this should return null instead of
+ // throwing an exception
+ return null;
+ }
}
-
public Object CreateInstance (String typeName)
{
return CreateInstance (typeName, false);
@@ -416,7 +426,7 @@ namespace System.Reflection {
}
[MethodImplAttribute (MethodImplOptions.InternalCall)]
- public extern Module[] GetModulesInternal ();
+ internal extern Module[] GetModulesInternal ();
public Module[] GetModules (bool getResourceModules) {
Module[] modules = GetModulesInternal ();
@@ -433,7 +443,7 @@ namespace System.Reflection {
}
[MethodImplAttribute (MethodImplOptions.InternalCall)]
- public extern string[] GetNamespaces ();
+ internal extern string[] GetNamespaces ();
[MethodImplAttribute (MethodImplOptions.InternalCall)]
public extern virtual String[] GetManifestResourceNames ();
@@ -467,6 +477,8 @@ namespace System.Reflection {
//
// The following functions are only for the Mono Debugger.
//
+ // They should be marked `internal', and extracted with GetMethod from the debugger.
+ //
[MethodImplAttribute (MethodImplOptions.InternalCall)]
public extern MethodBase MonoDebugger_GetMethod (int token);
diff --git a/mcs/class/corlib/System.Reflection/AssemblyName.cs b/mcs/class/corlib/System.Reflection/AssemblyName.cs
index e57fe1e4334..ffa48138915 100755
--- a/mcs/class/corlib/System.Reflection/AssemblyName.cs
+++ b/mcs/class/corlib/System.Reflection/AssemblyName.cs
@@ -17,6 +17,7 @@ using System.Runtime.Serialization;
using System.Security.Cryptography;
using System.Text;
using System.Runtime.InteropServices;
+using System.Runtime.CompilerServices;
namespace System.Reflection {
@@ -97,8 +98,14 @@ namespace System.Reflection {
fname.Append ("neutral");
else
fname.Append (cultureinfo.ToString ()); // ???
- if (keypair == null)
+ byte[] pub_tok = GetPublicKeyToken ();
+ if (pub_tok == null || pub_tok.Length == 0)
fname.Append (", PublicKeyToken=null");
+ else {
+ fname.Append (", PublicKeyToken=");
+ for (int i = 0; i < pub_tok.Length; i++)
+ fname.Append (pub_tok[i].ToString ("x2"));
+ }
// TODO
return fname.ToString ();
}
@@ -216,8 +223,12 @@ namespace System.Reflection {
public static AssemblyName GetAssemblyName (string assemblyFile)
{
- Assembly a = Assembly.LoadFrom (assemblyFile);
- return a.GetName ();
+ if (assemblyFile == null)
+ throw new ArgumentNullException ("assemblyFile");
+
+ AssemblyName aname = new AssemblyName ();
+ Assembly.InternalGetAssemblyName (assemblyFile, aname);
+ return aname;
}
}
}
diff --git a/mcs/class/corlib/System.Reflection/AssemblyNameFlags.cs b/mcs/class/corlib/System.Reflection/AssemblyNameFlags.cs
index daa3cd97148..3c59d33add6 100755
--- a/mcs/class/corlib/System.Reflection/AssemblyNameFlags.cs
+++ b/mcs/class/corlib/System.Reflection/AssemblyNameFlags.cs
@@ -28,6 +28,10 @@ namespace System.Reflection {
/// Perhaps this has changed since the beta.
/// </summary>
PublicKey = 1,
+
+#if NET_1_1
+ Retargetable = 256
+#endif
} // AssemblyNameFlags
} // System.Reflection
diff --git a/mcs/class/corlib/System.Reflection/Binder.cs b/mcs/class/corlib/System.Reflection/Binder.cs
index c1a914fc729..1c930654f7e 100644
--- a/mcs/class/corlib/System.Reflection/Binder.cs
+++ b/mcs/class/corlib/System.Reflection/Binder.cs
@@ -6,10 +6,12 @@
// (C) Ximian, Inc. 2001 - 2002
using System.Globalization;
+using System.Runtime.InteropServices;
namespace System.Reflection
{
[Serializable]
+ [ClassInterface(ClassInterfaceType.AutoDual)]
public abstract class Binder
{
protected Binder () {}
diff --git a/mcs/class/corlib/System.Reflection/ChangeLog b/mcs/class/corlib/System.Reflection/ChangeLog
index 7f5e2aabc9f..445848ac697 100644
--- a/mcs/class/corlib/System.Reflection/ChangeLog
+++ b/mcs/class/corlib/System.Reflection/ChangeLog
@@ -1,3 +1,52 @@
+2003-11-25 Zoltan Varga <vargaz@freemail.hu>
+
+ * Assembly.cs (LoadWithPartialName): Return null instead of throwing
+ an exception to match MS behavior.
+
+2003-11-24 Zoltan Varga <vargaz@freemail.hu>
+
+ * MonoMethod.cs: Add missing constructor.
+
+2003-11-21 Zoltan Varga <vargaz@freemail.hu>
+
+ * MethodBase.cs (Invoke): Make this virtual under NET 1.2.
+
+2003-11-16 Martin Baulig <martin@ximian.com>
+
+ * MonoGenericInst.cs (MonoGenericInst.inflate): Call
+ `parent.inflate (parent,...)' instead of
+ `parent.inflate (reflected,...)'.
+
+2003-11-16 Zoltan Varga <vargaz@freemail.hu>
+
+ * Assembly.cs (InternalGetAssemblyName): New icall.
+
+ * AssemblyName.cs (GetAssemblyName): Implement this without loading
+ the assembly in question. Fixes #51035.
+
+2003-11-14 Martin Baulig <martin@ximian.com>
+
+ * MonoGenericInst.cs (MonoGenericInst): Added
+ `MonoGenericInst[] interfaces' field. This is only used for
+ interface types.
+ (MonoGenericInst.inflate): If we're an interface type, add the
+ methods from all interfaces we inherit.
+
+2003-11-14 Zoltan Varga <vargaz@freemail.hu>
+
+ * AssemblyNameFlags.cs MethodAttributes.cs: Add new enumerated values
+ from NET 1.1.
+
+ * *.cs: Add missing attributes.
+
+2003-11-11 Todd Berman <tberman@gentoo.org>
+
+ * AssemblyName.cs (FullName): Fixed to include a proper PublicKeyToken.
+
+2003-11-11 Zoltan Varga <vargaz@freemail.hu>
+
+ * MonoMethod.cs: Implement CallingConvention member.
+
2003-11-10 Zoltan Varga <vargaz@freemail.hu>
* Assembly.cs (InternalGetType): Add a 'module' argument so this
diff --git a/mcs/class/corlib/System.Reflection/ConstructorInfo.cs b/mcs/class/corlib/System.Reflection/ConstructorInfo.cs
index 936f50ef8df..d9790690672 100644
--- a/mcs/class/corlib/System.Reflection/ConstructorInfo.cs
+++ b/mcs/class/corlib/System.Reflection/ConstructorInfo.cs
@@ -10,9 +10,12 @@
using System;
using System.Reflection;
using System.Globalization;
+using System.Runtime.InteropServices;
namespace System.Reflection {
+
[Serializable]
+ [ClassInterface(ClassInterfaceType.AutoDual)]
public abstract class ConstructorInfo : MethodBase {
public static readonly string ConstructorName = ".ctor";
public static readonly string TypeConstructorName = ".cctor";
diff --git a/mcs/class/corlib/System.Reflection/EventAttributes.cs b/mcs/class/corlib/System.Reflection/EventAttributes.cs
index efb1154e21c..7d18940423d 100755
--- a/mcs/class/corlib/System.Reflection/EventAttributes.cs
+++ b/mcs/class/corlib/System.Reflection/EventAttributes.cs
@@ -15,6 +15,7 @@ namespace System.Reflection {
/// <summary>
/// </summary>
+ [Flags]
public enum EventAttributes {
/// <summary>
diff --git a/mcs/class/corlib/System.Reflection/EventInfo.cs b/mcs/class/corlib/System.Reflection/EventInfo.cs
index 3f4c5963f90..626ecbc1f39 100755
--- a/mcs/class/corlib/System.Reflection/EventInfo.cs
+++ b/mcs/class/corlib/System.Reflection/EventInfo.cs
@@ -9,8 +9,11 @@
using System;
using System.Reflection;
+using System.Runtime.InteropServices;
namespace System.Reflection {
+
+ [ClassInterface(ClassInterfaceType.AutoDual)]
public abstract class EventInfo : MemberInfo {
public abstract EventAttributes Attributes {get;}
diff --git a/mcs/class/corlib/System.Reflection/FieldAttributes.cs b/mcs/class/corlib/System.Reflection/FieldAttributes.cs
index 5462fc2b102..f37118c1bba 100755
--- a/mcs/class/corlib/System.Reflection/FieldAttributes.cs
+++ b/mcs/class/corlib/System.Reflection/FieldAttributes.cs
@@ -15,6 +15,7 @@ namespace System.Reflection {
/// <summary>
/// </summary>
+ [Flags]
public enum FieldAttributes {
/// <summary>
diff --git a/mcs/class/corlib/System.Reflection/FieldInfo.cs b/mcs/class/corlib/System.Reflection/FieldInfo.cs
index 136fabf0535..356105d3d7e 100755
--- a/mcs/class/corlib/System.Reflection/FieldInfo.cs
+++ b/mcs/class/corlib/System.Reflection/FieldInfo.cs
@@ -14,15 +14,18 @@ using System.Reflection;
using System.Reflection.Emit;
using System.Globalization;
using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
namespace System.Reflection {
[Serializable]
+ [ClassInterface(ClassInterfaceType.AutoDual)]
public abstract class FieldInfo : MemberInfo {
-
public abstract FieldAttributes Attributes {get;}
public abstract RuntimeFieldHandle FieldHandle {get;}
+ internal FieldInfo () {}
+
public abstract Type FieldType { get; }
public abstract object GetValue(object obj);
diff --git a/mcs/class/corlib/System.Reflection/IReflect.cs b/mcs/class/corlib/System.Reflection/IReflect.cs
index e89c3298a69..a7013ffb5d4 100755
--- a/mcs/class/corlib/System.Reflection/IReflect.cs
+++ b/mcs/class/corlib/System.Reflection/IReflect.cs
@@ -9,10 +9,13 @@
// TODO: Mucho left to implement.
//
+using System;
using System.Globalization;
+using System.Runtime.InteropServices;
namespace System.Reflection {
+ [Guid("AFBF15E5-C37C-11d2-B88E-00A0C9B471B8")]
public interface IReflect {
Type UnderlyingSystemType {
diff --git a/mcs/class/corlib/System.Reflection/MemberInfo.cs b/mcs/class/corlib/System.Reflection/MemberInfo.cs
index 9e3c52b8038..3fb28043a17 100755
--- a/mcs/class/corlib/System.Reflection/MemberInfo.cs
+++ b/mcs/class/corlib/System.Reflection/MemberInfo.cs
@@ -9,11 +9,16 @@
// TODO: Mucho left to implement.
//
+using System.Runtime.InteropServices;
+
namespace System.Reflection {
[Serializable]
+ [ClassInterface(ClassInterfaceType.AutoDual)]
public abstract class MemberInfo : ICustomAttributeProvider {
+ internal MemberInfo () {}
+
public abstract Type DeclaringType {
get;
}
diff --git a/mcs/class/corlib/System.Reflection/MemberTypes.cs b/mcs/class/corlib/System.Reflection/MemberTypes.cs
index 00a1234ef36..3c50ec86935 100755
--- a/mcs/class/corlib/System.Reflection/MemberTypes.cs
+++ b/mcs/class/corlib/System.Reflection/MemberTypes.cs
@@ -15,6 +15,7 @@ namespace System.Reflection {
/// <summary>
/// </summary>
+ [Flags]
public enum MemberTypes {
/// <summary>
diff --git a/mcs/class/corlib/System.Reflection/MethodAttributes.cs b/mcs/class/corlib/System.Reflection/MethodAttributes.cs
index 51ac6f18a6a..ef60d21ca37 100755
--- a/mcs/class/corlib/System.Reflection/MethodAttributes.cs
+++ b/mcs/class/corlib/System.Reflection/MethodAttributes.cs
@@ -15,6 +15,7 @@ namespace System.Reflection {
/// <summary>
/// </summary>
+ [Flags]
public enum MethodAttributes {
/// <summary>
@@ -69,6 +70,12 @@ namespace System.Reflection {
/// </summary>
VtableLayoutMask = 256,
+#if NET_1_1
+ /// <summary>
+ /// </summary>
+ CheckAccessOnOverride = 512,
+#endif
+
/// <summary>
/// </summary>
ReuseSlot = 0,
diff --git a/mcs/class/corlib/System.Reflection/MethodBase.cs b/mcs/class/corlib/System.Reflection/MethodBase.cs
index fda971d8d95..a34263a0749 100644
--- a/mcs/class/corlib/System.Reflection/MethodBase.cs
+++ b/mcs/class/corlib/System.Reflection/MethodBase.cs
@@ -11,10 +11,12 @@ using System;
using System.Globalization;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
namespace System.Reflection {
[Serializable]
+ [ClassInterface(ClassInterfaceType.AutoDual)]
public abstract class MethodBase: MemberInfo {
[MethodImplAttribute (MethodImplOptions.InternalCall)]
@@ -29,6 +31,9 @@ namespace System.Reflection {
public abstract ParameterInfo[] GetParameters();
+#if NET_1_2
+ virtual
+#endif
public Object Invoke(Object obj, Object[] parameters) {
return Invoke (obj, 0, null, parameters, null);
}
diff --git a/mcs/class/corlib/System.Reflection/MethodImplAttributes.cs b/mcs/class/corlib/System.Reflection/MethodImplAttributes.cs
index aaa243ab6d3..f966ce4a958 100755
--- a/mcs/class/corlib/System.Reflection/MethodImplAttributes.cs
+++ b/mcs/class/corlib/System.Reflection/MethodImplAttributes.cs
@@ -15,6 +15,7 @@ namespace System.Reflection {
/// <summary>
/// </summary>
+ [Flags]
public enum MethodImplAttributes {
/// <summary>
diff --git a/mcs/class/corlib/System.Reflection/MethodInfo.cs b/mcs/class/corlib/System.Reflection/MethodInfo.cs
index 4bcd0c580a5..e1c0087b343 100644
--- a/mcs/class/corlib/System.Reflection/MethodInfo.cs
+++ b/mcs/class/corlib/System.Reflection/MethodInfo.cs
@@ -9,10 +9,12 @@
using System;
using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
namespace System.Reflection {
[Serializable]
+ [ClassInterface(ClassInterfaceType.AutoDual)]
public abstract class MethodInfo: MethodBase {
public abstract MethodInfo GetBaseDefinition();
@@ -23,7 +25,7 @@ namespace System.Reflection {
public abstract Type ReturnType { get; }
public abstract ICustomAttributeProvider ReturnTypeCustomAttributes { get; }
-#if GENERICS
+#if NET_1_2
public extern bool IsGenericMethodDefinition {
[MethodImplAttribute(MethodImplOptions.InternalCall)]
get;
diff --git a/mcs/class/corlib/System.Reflection/MonoGenericInst.cs b/mcs/class/corlib/System.Reflection/MonoGenericInst.cs
index 95df5c2208e..a7ec1a86bb9 100644
--- a/mcs/class/corlib/System.Reflection/MonoGenericInst.cs
+++ b/mcs/class/corlib/System.Reflection/MonoGenericInst.cs
@@ -21,6 +21,7 @@ namespace System.Reflection
private IntPtr klass;
protected MonoGenericInst parent;
protected Type generic_type;
+ private MonoGenericInst[] interfaces;
private MethodInfo[] methods;
private ConstructorInfo[] ctors;
private FieldInfo[] fields;
@@ -49,11 +50,14 @@ namespace System.Reflection
ArrayList mlist, ArrayList clist, ArrayList flist)
{
if (parent != null)
- parent.inflate (reflected, mlist, clist, flist);
+ parent.inflate (parent, mlist, clist, flist);
else if (BaseType != null) {
mlist.AddRange (generic_type.BaseType.GetMethods (flags));
clist.AddRange (generic_type.BaseType.GetConstructors (flags));
flist.AddRange (generic_type.BaseType.GetFields (flags));
+ } else if (interfaces != null) {
+ foreach (MonoGenericInst iface in interfaces)
+ iface.inflate (iface, mlist, clist, flist);
}
foreach (MethodInfo m in generic_type.GetMethods (flags))
diff --git a/mcs/class/corlib/System.Reflection/MonoMethod.cs b/mcs/class/corlib/System.Reflection/MonoMethod.cs
index 30177a24287..f93a37ef9c9 100755
--- a/mcs/class/corlib/System.Reflection/MonoMethod.cs
+++ b/mcs/class/corlib/System.Reflection/MonoMethod.cs
@@ -12,7 +12,7 @@ using System;
using System.Globalization;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
-using System.Runtime.Serialization;
+using System.Runtime.Serialization;
namespace System.Reflection {
@@ -22,6 +22,7 @@ namespace System.Reflection {
internal Type ret;
internal MethodAttributes attrs;
internal MethodImplAttributes iattrs;
+ internal CallingConventions callconv;
[MethodImplAttribute(MethodImplOptions.InternalCall)]
internal static extern void get_method_info (IntPtr handle, out MonoMethodInfo info);
@@ -40,6 +41,13 @@ namespace System.Reflection {
internal IntPtr mhandle;
string name;
Type reftype;
+
+ internal MonoMethod () {
+ }
+
+ internal MonoMethod (RuntimeMethodHandle mhandle) {
+ this.mhandle = mhandle.Value;
+ }
[MethodImplAttribute(MethodImplOptions.InternalCall)]
internal static extern MonoMethod get_base_definition (MonoMethod method);
@@ -104,6 +112,14 @@ namespace System.Reflection {
return info.attrs;
}
}
+
+ public override CallingConventions CallingConvention {
+ get {
+ MonoMethodInfo info;
+ MonoMethodInfo.get_method_info (mhandle, out info);
+ return info.callconv;
+ }
+ }
public override Type ReflectedType {
get {
@@ -158,7 +174,7 @@ namespace System.Reflection {
ReflectionSerializationHolder.Serialize ( info, Name, ReflectedType, ToString(), MemberTypes.Method);
}
-#if GENERICS
+#if NET_1_2
[MethodImplAttribute(MethodImplOptions.InternalCall)]
public override extern Type [] GetGenericArguments ();
#endif
@@ -216,6 +232,14 @@ namespace System.Reflection {
return info.attrs;
}
}
+
+ public override CallingConventions CallingConvention {
+ get {
+ MonoMethodInfo info;
+ MonoMethodInfo.get_method_info (mhandle, out info);
+ return info.callconv;
+ }
+ }
public override Type ReflectedType {
get {
diff --git a/mcs/class/corlib/System.Reflection/PropertyInfo.cs b/mcs/class/corlib/System.Reflection/PropertyInfo.cs
index cad58c2a604..feaa6eded62 100755
--- a/mcs/class/corlib/System.Reflection/PropertyInfo.cs
+++ b/mcs/class/corlib/System.Reflection/PropertyInfo.cs
@@ -10,9 +10,11 @@
using System;
using System.Reflection;
using System.Globalization;
+using System.Runtime.InteropServices;
namespace System.Reflection {
[Serializable]
+ [ClassInterface(ClassInterfaceType.AutoDual)]
public abstract class PropertyInfo : MemberInfo {
public abstract PropertyAttributes Attributes { get; }
diff --git a/mcs/class/corlib/System.Reflection/TypeDelegator.cs b/mcs/class/corlib/System.Reflection/TypeDelegator.cs
index 9e7cc0a6373..94a6d2a6353 100755
--- a/mcs/class/corlib/System.Reflection/TypeDelegator.cs
+++ b/mcs/class/corlib/System.Reflection/TypeDelegator.cs
@@ -229,7 +229,7 @@ namespace System.Reflection {
throw new NotImplementedException ();
//return typeImpl.IsValueTypeImpl ();
}
-#if GENERICS
+#if NET_1_2
public override bool HasGenericArguments {
get {
throw new NotImplementedException ();
diff --git a/mcs/class/corlib/System.Reflection/common.src b/mcs/class/corlib/System.Reflection/common.src
deleted file mode 100644
index 022b6768fcc..00000000000
--- a/mcs/class/corlib/System.Reflection/common.src
+++ /dev/null
@@ -1,25 +0,0 @@
-Assembly.cs
-AssemblyNameFlags.cs
-BindingFlags.cs
-CallingConventions.cs
-ConstructorInfo.cs
-DefaultMemberAttribute.cs
-EventAttributes.cs
-EventInfo.cs
-FieldAttributes.cs
-FieldInfo.cs
-ICustomAttributeProvider.cs
-MemberFilter.cs
-MemberInfo.cs
-MemberTypes.cs
-MethodAttributes.cs
-MethodBase.cs
-MethodImplAttributes.cs
-MethodInfo.cs
-Module.cs
-ParameterAttributes.cs
-PropertyAttributes.cs
-PropertyInfo.cs
-ResourceAttributes.cs
-ResourceLocation.cs
-TypeAttributes.cs
diff --git a/mcs/class/corlib/System.Resources/ChangeLog b/mcs/class/corlib/System.Resources/ChangeLog
index 2201d913013..2928744f694 100644
--- a/mcs/class/corlib/System.Resources/ChangeLog
+++ b/mcs/class/corlib/System.Resources/ChangeLog
@@ -1,3 +1,11 @@
+2003-11-28 Dick Porter <dick@ximian.com>
+
+ * ResourceSet.cs: Do string compares with the Invariant culture.
+
+2003-11-18 Andreas Nahr <ClassDevelopment@A-SoftTech.com>
+
+ * ResourceSet.cs: Implemented v1.1 updates
+
2003-09-07 Dick Porter <dick@ximian.com>
* Temporary workaround for bug 43567, so that Npgsql at least
diff --git a/mcs/class/corlib/System.Resources/ResourceSet.cs b/mcs/class/corlib/System.Resources/ResourceSet.cs
index 14a954c8e2e..b242634aefe 100644
--- a/mcs/class/corlib/System.Resources/ResourceSet.cs
+++ b/mcs/class/corlib/System.Resources/ResourceSet.cs
@@ -4,17 +4,25 @@
// Authors:
// Duncan Mak (duncan@ximian.com)
// Dick Porter (dick@ximian.com)
+// Andreas Nahr (ClassDevelopment@A-SoftTech.com)
//
// (C) 2001, 2002 Ximian, Inc. http://www.ximian.com
//
using System.Collections;
using System.IO;
+using System.Globalization;
+using System.Runtime.InteropServices;
namespace System.Resources
{
[Serializable]
public class ResourceSet : IDisposable
+
+#if (NET_1_1)
+ , IEnumerable
+#endif
+
{
protected IResourceReader Reader;
@@ -83,6 +91,23 @@ namespace System.Resources
return (typeof (ResourceWriter));
}
+#if (NET_1_1)
+
+ [ComVisible (false)]
+ public virtual IDictionaryEnumerator GetEnumerator ()
+ {
+ if (Table == null)
+ ReadResources ();
+ return Table.GetEnumerator();
+ }
+
+ IEnumerator IEnumerable.GetEnumerator ()
+ {
+ return this.GetEnumerator ();
+ }
+
+#endif
+
public virtual object GetObject (string name)
{
if (name == null)
@@ -109,7 +134,7 @@ namespace System.Resources
if (ignoreCase) {
foreach (DictionaryEntry de in Table) {
string key = (string) de.Key;
- if (String.Compare (key, name, true) == 0)
+ if (String.Compare (key, name, true, CultureInfo.InvariantCulture) == 0)
return de.Value;
}
return null;
diff --git a/mcs/class/corlib/System.Runtime.CompilerServices/ChangeLog b/mcs/class/corlib/System.Runtime.CompilerServices/ChangeLog
index 3054797e9ea..6aecc80bd22 100644
--- a/mcs/class/corlib/System.Runtime.CompilerServices/ChangeLog
+++ b/mcs/class/corlib/System.Runtime.CompilerServices/ChangeLog
@@ -1,3 +1,10 @@
+2003-11-18 Zoltan Varga <vargaz@freemail.hu>
+
+ * RuntimeHelpers.cs (Equals): Track changes to ValueType.
+
+2003-11-15 Zoltan Varga <vargaz@freemail.hu>
+
+ * MethodImplOptions.cs MethodCodeType.cs: Add [Flags].
Tue Jul 29 12:15:13 CEST 2003 Paolo Molaro <lupus@ximian.com>
diff --git a/mcs/class/corlib/System.Runtime.CompilerServices/MethodCodeType.cs b/mcs/class/corlib/System.Runtime.CompilerServices/MethodCodeType.cs
index 3608120e516..8973ef522b4 100644
--- a/mcs/class/corlib/System.Runtime.CompilerServices/MethodCodeType.cs
+++ b/mcs/class/corlib/System.Runtime.CompilerServices/MethodCodeType.cs
@@ -11,7 +11,7 @@
namespace System.Runtime.CompilerServices
{
-
+[Flags]
public enum MethodCodeType
{
IL,
diff --git a/mcs/class/corlib/System.Runtime.CompilerServices/MethodImplOptions.cs b/mcs/class/corlib/System.Runtime.CompilerServices/MethodImplOptions.cs
index 45a98baeb79..01a7b3b6835 100644
--- a/mcs/class/corlib/System.Runtime.CompilerServices/MethodImplOptions.cs
+++ b/mcs/class/corlib/System.Runtime.CompilerServices/MethodImplOptions.cs
@@ -15,6 +15,7 @@ namespace System.Runtime.CompilerServices {
/// <summary>
/// </summary>
+ [Flags]
public enum MethodImplOptions {
/// <summary>
diff --git a/mcs/class/corlib/System.Runtime.CompilerServices/RuntimeHelpers.cs b/mcs/class/corlib/System.Runtime.CompilerServices/RuntimeHelpers.cs
index 295bae23dfa..d41f7b17880 100644
--- a/mcs/class/corlib/System.Runtime.CompilerServices/RuntimeHelpers.cs
+++ b/mcs/class/corlib/System.Runtime.CompilerServices/RuntimeHelpers.cs
@@ -47,7 +47,7 @@ namespace System.Runtime.CompilerServices
if ((o1 == null) || (o2 == null))
return false;
if (o1 is ValueType)
- return ValueType.InternalEquals (o1, o2);
+ return ValueType.DefaultEquals (o1, o2);
else
return Object.Equals (o1, o2);
}
diff --git a/mcs/class/corlib/System.Runtime.InteropServices.Expando/Changelog b/mcs/class/corlib/System.Runtime.InteropServices.Expando/Changelog
index 81e31e8744c..daa71471645 100644
--- a/mcs/class/corlib/System.Runtime.InteropServices.Expando/Changelog
+++ b/mcs/class/corlib/System.Runtime.InteropServices.Expando/Changelog
@@ -1,3 +1,7 @@
+2003-11-13 Andreas Nahr <ClassDevelopment@A-SoftTech.com>
+
+ * IExpando.cs: Added attribute
+
2002-11-20 Alejandro Sánchez Acosta <raciel@es.gnu.org>
* IExpando.cs added.
diff --git a/mcs/class/corlib/System.Runtime.InteropServices.Expando/IExpando.cs b/mcs/class/corlib/System.Runtime.InteropServices.Expando/IExpando.cs
index 98c3b8015ac..1957c3827ae 100644
--- a/mcs/class/corlib/System.Runtime.InteropServices.Expando/IExpando.cs
+++ b/mcs/class/corlib/System.Runtime.InteropServices.Expando/IExpando.cs
@@ -12,7 +12,7 @@ using System.Reflection.Emit;
namespace System.Runtime.InteropServices.Expando
{
- //[Guid("")]
+ [Guid("afbf15e6-c37c-11d2-b88e-00a0c9b471b8")]
public interface IExpando : IReflect
{
FieldInfo AddField (string name);
diff --git a/mcs/class/corlib/System.Runtime.InteropServices/ArrayWithOffset.cs b/mcs/class/corlib/System.Runtime.InteropServices/ArrayWithOffset.cs
new file mode 100644
index 00000000000..b0444cdd097
--- /dev/null
+++ b/mcs/class/corlib/System.Runtime.InteropServices/ArrayWithOffset.cs
@@ -0,0 +1,49 @@
+//
+// System.Runtime.InteropServices.ArrayWithOffset.cs
+//
+// Author:
+// Miguel de Icaza (miguel@ximian.com)
+//
+// (C) Novell, Inc. http://www.ximian.com
+//
+using System;
+
+namespace System.Runtime.InteropServices {
+
+ public struct ArrayWithOffset {
+ object array;
+ int offset;
+
+ public ArrayWithOffset (object array, int offset)
+ {
+ this.array = array;
+ this.offset = offset;
+ }
+
+ public override bool Equals (object obj)
+ {
+ if (obj == null)
+ return false;
+ if (!(obj is ArrayWithOffset))
+ return false;
+ ArrayWithOffset other = (ArrayWithOffset) obj;
+
+ return (other.array == array && other.offset == offset);
+ }
+
+ public override int GetHashCode ()
+ {
+ return offset;
+ }
+
+ public object GetArray ()
+ {
+ return array;
+ }
+
+ public object GetOffset ()
+ {
+ return offset;
+ }
+ }
+}
diff --git a/mcs/class/corlib/System.Runtime.InteropServices/BestFitMappingAttribute.cs b/mcs/class/corlib/System.Runtime.InteropServices/BestFitMappingAttribute.cs
new file mode 100644
index 00000000000..23782902783
--- /dev/null
+++ b/mcs/class/corlib/System.Runtime.InteropServices/BestFitMappingAttribute.cs
@@ -0,0 +1,31 @@
+//
+// System.Runtime.InteropServices.BestFitMappingAttribute.cs
+//
+// Author:
+// Miguel de Icaza (miguel@ximian.com)
+//
+// (C) Novell, Inc. http://www.ximian.com
+//
+using System;
+
+namespace System.Runtime.InteropServices {
+
+ [AttributeUsage (AttributeTargets.Assembly | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Interface)]
+ [Serializable]
+ public sealed class BestFitMappingAttribute : Attribute {
+ bool bfm;
+
+ public BestFitMappingAttribute (bool bfm)
+ {
+ this.bfm = bfm;
+ }
+
+ public bool ThrowOnUnmappableChar = false;
+
+ public bool BestFitMapping {
+ get {
+ return bfm;
+ }
+ }
+ }
+}
diff --git a/mcs/class/corlib/System.Runtime.InteropServices/COMException.cs b/mcs/class/corlib/System.Runtime.InteropServices/COMException.cs
index 0d720b04967..a59d0174d1b 100644
--- a/mcs/class/corlib/System.Runtime.InteropServices/COMException.cs
+++ b/mcs/class/corlib/System.Runtime.InteropServices/COMException.cs
@@ -29,10 +29,12 @@ public class COMException : ExternalException {
protected COMException (SerializationInfo info, StreamingContext context)
: base (info, context) {}
- [MonoTODO()]
public override string ToString ()
{
- return null;
+ return String.Format (
+ "{0} (0x{1:x}) {2} {3}\n{4}",
+ GetType (), HResult, Message, InnerException == null ? "" : InnerException.ToString (),
+ StackTrace != null ? StackTrace : "");
}
}
diff --git a/mcs/class/corlib/System.Runtime.InteropServices/ChangeLog b/mcs/class/corlib/System.Runtime.InteropServices/ChangeLog
index 9de29c8f529..6a69ee6dba5 100644
--- a/mcs/class/corlib/System.Runtime.InteropServices/ChangeLog
+++ b/mcs/class/corlib/System.Runtime.InteropServices/ChangeLog
@@ -1,3 +1,48 @@
+2003-11-26 Andreas Nahr <ClassDevelopment@A-SoftTech.com>
+
+ * DispatchWrapper.cs: Added and implemented
+ * ErrorWrapper.cs: Fixed bug
+ * Marshal.cs: Added missing members
+
+2003-11-18 Jackson Harper <jackson@ximian.com>
+
+ * CurrencyWrapper.cs: Fix file name.
+
+2003-11-18 Andreas Nahr <ClassDevelopment@A-SoftTech.com>
+
+ * BestFitMappingAttribute.cs: Signature fix
+ * Marshal.cs: Add attribute, fix signatures
+ * MarshalAsAttribute.cs: Add head, add entry
+ * DllImportAttribute.cs: Added v1.1 entries
+ * TypeLibConverter.cs: Added, stubbed
+ * RegistrationServices.cs: Added, stubbed
+ * ExtensibleClassFactory.cs: Added, stubbed
+ * ErrorWrapper.cs: Added, implemented
+ * CurrencyWrapper.cs: Added, implemented
+
+2003-11-13 Andreas Nahr <ClassDevelopment@A-SoftTech.com>
+
+ * IRegistrationServices.cs:
+ * ITypeLibConverter.cs:
+ * ITypeLibExporterNameProvider.cs:
+ * ITypeLibExporterNotifySink.cs:
+ * ITypeLibImporterNotifySink.cs: Added missing attribute
+ * UCOMIBindCtx.cs: Added missing attribute, fixed in attribute
+ * UCOMIConnectionPoint.cs:
+ * UCOMIConnectionPointContainer.cs:
+ * UCOMIEnumConnectionPoints.cs:
+ * UCOMIEnumConnections.cs:
+ * UCOMIEnumMoniker.cs:
+ * UCOMIEnumString.cs:
+ * UCOMIEnumVARIANT.cs:
+ * UCOMIMoniker.cs:
+ * UCOMIPersistFile.cs:
+ * UCOMIRunningObjectTable.cs:
+ * UCOMIStream.cs:
+ * UCOMITypeComp.cs:
+ * UCOMITypeInfo.cs:
+ * UCOMITypeLib.cs: Added missing attribute
+
2003-08-06 Andreas Nahr <ClassDevelopment@A-SoftTech.com>
* UCOMIBindCtx.cs: Added and implemented
diff --git a/mcs/class/corlib/System.Runtime.InteropServices/CurrencyWrapper.cs b/mcs/class/corlib/System.Runtime.InteropServices/CurrencyWrapper.cs
new file mode 100644
index 00000000000..6d340fea140
--- /dev/null
+++ b/mcs/class/corlib/System.Runtime.InteropServices/CurrencyWrapper.cs
@@ -0,0 +1,32 @@
+//
+// System.Runtime.InteropServices.CurrencyWrapper.cs
+//
+// Author:
+// Andreas Nahr (ClassDevelopment@A-SoftTech.com)
+//
+
+using System;
+
+namespace System.Runtime.InteropServices
+{
+ public sealed class CurrencyWrapper
+ {
+ Decimal currency;
+
+ public CurrencyWrapper (decimal obj)
+ {
+ currency = obj;
+ }
+
+ public CurrencyWrapper (object obj)
+ {
+ if (obj.GetType() != typeof(Decimal))
+ throw new ArgumentException ("obj has to be a Decimal type");
+ currency = (Decimal)obj;
+ }
+
+ public decimal WrappedObject {
+ get { return currency; }
+ }
+ }
+}
diff --git a/mcs/class/corlib/System.Runtime.InteropServices/DispatchWrapper.cs b/mcs/class/corlib/System.Runtime.InteropServices/DispatchWrapper.cs
new file mode 100644
index 00000000000..7321cd25366
--- /dev/null
+++ b/mcs/class/corlib/System.Runtime.InteropServices/DispatchWrapper.cs
@@ -0,0 +1,26 @@
+//
+// System.Runtime.InteropServices.DispatchWrapper.cs
+//
+// Author:
+// Andreas Nahr (ClassDevelopment@A-SoftTech.com)
+//
+
+using System;
+
+namespace System.Runtime.InteropServices
+{
+ public sealed class DispatchWrapper
+ {
+ object wrappedObject;
+
+ public DispatchWrapper (object obj)
+ {
+ Marshal.GetIDispatchForObject (obj);
+ wrappedObject = obj;
+ }
+
+ public object WrappedObject {
+ get { return wrappedObject; }
+ }
+ }
+}
diff --git a/mcs/class/corlib/System.Runtime.InteropServices/DllImportAttribute.cs b/mcs/class/corlib/System.Runtime.InteropServices/DllImportAttribute.cs
index 9d6466527ea..7bf4ca9cea7 100755
--- a/mcs/class/corlib/System.Runtime.InteropServices/DllImportAttribute.cs
+++ b/mcs/class/corlib/System.Runtime.InteropServices/DllImportAttribute.cs
@@ -1,5 +1,5 @@
//
-// System.Runtime.InteropServices/DllImportAttribute.cs
+// System.Runtime.InteropServices.DllImportAttribute.cs
//
// Author:
// Paolo Molaro (lupus@ximian.com)
@@ -20,6 +20,14 @@ namespace System.Runtime.InteropServices {
public bool ExactSpelling;
public bool PreserveSig;
public bool SetLastError;
+
+#if (NET_1_1)
+
+ public bool BestFitMapping;
+ public bool ThrowOnUnmappableChar;
+
+#endif
+
private string Dll;
public string Value {
diff --git a/mcs/class/corlib/System.Runtime.InteropServices/ErrorWrapper.cs b/mcs/class/corlib/System.Runtime.InteropServices/ErrorWrapper.cs
new file mode 100644
index 00000000000..2cb121b2547
--- /dev/null
+++ b/mcs/class/corlib/System.Runtime.InteropServices/ErrorWrapper.cs
@@ -0,0 +1,37 @@
+//
+// System.Runtime.InteropServices.ErrorWrapper.cs
+//
+// Author:
+// Andreas Nahr (ClassDevelopment@A-SoftTech.com)
+//
+
+using System;
+
+namespace System.Runtime.InteropServices
+{
+ public sealed class ErrorWrapper
+ {
+ int errorCode;
+
+ public ErrorWrapper (Exception e)
+ {
+ this.errorCode = Marshal.GetHRForException (e);
+ }
+
+ public ErrorWrapper (int errorCode)
+ {
+ this.errorCode = errorCode;
+ }
+
+ public ErrorWrapper (object errorCode)
+ {
+ if (errorCode.GetType() != typeof(int))
+ throw new ArgumentException ("errorCode has to be an int type");
+ this.errorCode = (int)errorCode;
+ }
+
+ public int ErrorCode {
+ get { return errorCode; }
+ }
+ }
+}
diff --git a/mcs/class/corlib/System.Runtime.InteropServices/ExtensibleClassFactory.cs b/mcs/class/corlib/System.Runtime.InteropServices/ExtensibleClassFactory.cs
new file mode 100644
index 00000000000..1a1e8916d6c
--- /dev/null
+++ b/mcs/class/corlib/System.Runtime.InteropServices/ExtensibleClassFactory.cs
@@ -0,0 +1,22 @@
+//
+// System.Runtime.InteropServices.ExtensibleClassFactory.cs
+//
+// Author:
+// Andreas Nahr (ClassDevelopment@A-SoftTech.com)
+//
+
+namespace System.Runtime.InteropServices
+{
+ public sealed class ExtensibleClassFactory
+ {
+ private ExtensibleClassFactory ()
+ {
+ }
+
+ [MonoTODO ("implement")]
+ public static void RegisterObjectCreationCallback (ObjectCreationDelegate callback)
+ {
+ throw new NotImplementedException ();
+ }
+ }
+}
diff --git a/mcs/class/corlib/System.Runtime.InteropServices/IRegistrationServices.cs b/mcs/class/corlib/System.Runtime.InteropServices/IRegistrationServices.cs
index a42e935895c..c006a1bc56d 100755
--- a/mcs/class/corlib/System.Runtime.InteropServices/IRegistrationServices.cs
+++ b/mcs/class/corlib/System.Runtime.InteropServices/IRegistrationServices.cs
@@ -11,7 +11,7 @@ using System.Reflection;
namespace System.Runtime.InteropServices {
- //[Guid("")]
+ [Guid("CCBD682C-73A5-4568-B8B0-C7007E11ABA2")]
public interface IRegistrationServices {
Guid GetManagedCategoryGuid ();
string GetProgIdForType (Type type);
diff --git a/mcs/class/corlib/System.Runtime.InteropServices/ITypeLibConverter.cs b/mcs/class/corlib/System.Runtime.InteropServices/ITypeLibConverter.cs
index f7838977e04..63efb4a7a5f 100644
--- a/mcs/class/corlib/System.Runtime.InteropServices/ITypeLibConverter.cs
+++ b/mcs/class/corlib/System.Runtime.InteropServices/ITypeLibConverter.cs
@@ -12,7 +12,7 @@ using System.Reflection.Emit;
namespace System.Runtime.InteropServices {
- //[Guid("")]
+ [Guid("F1C3BF78-C3E4-11D3-88E7-00902754C43A")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface ITypeLibConverter {
object ConvertAssemblyToTypeLib (Assembly assembly, string typeLibName, TypeLibExporterFlags flags, ITypeLibExporterNotifySink notifySink);
diff --git a/mcs/class/corlib/System.Runtime.InteropServices/ITypeLibExporterNameProvider.cs b/mcs/class/corlib/System.Runtime.InteropServices/ITypeLibExporterNameProvider.cs
index 3e937ae4b22..69f1a2d6884 100755
--- a/mcs/class/corlib/System.Runtime.InteropServices/ITypeLibExporterNameProvider.cs
+++ b/mcs/class/corlib/System.Runtime.InteropServices/ITypeLibExporterNameProvider.cs
@@ -9,7 +9,7 @@
namespace System.Runtime.InteropServices {
- //[Guid("")]
+ [Guid("fa1f3615-acb9-486d-9eac-1bef87e36b09")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface ITypeLibExporterNameProvider {
string[] GetNames ();
diff --git a/mcs/class/corlib/System.Runtime.InteropServices/ITypeLibExporterNotifySink.cs b/mcs/class/corlib/System.Runtime.InteropServices/ITypeLibExporterNotifySink.cs
index 547b87d73d3..4aa0036b83f 100644
--- a/mcs/class/corlib/System.Runtime.InteropServices/ITypeLibExporterNotifySink.cs
+++ b/mcs/class/corlib/System.Runtime.InteropServices/ITypeLibExporterNotifySink.cs
@@ -11,7 +11,7 @@ using System.Reflection;
namespace System.Runtime.InteropServices {
- //[Guid("")]
+ [Guid("f1c3bf77-c3e4-11d3-88e7-00902754c43a")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface ITypeLibExporterNotifySink {
void ReportEvent (ExporterEventKind eventKind, int eventCode, string eventMsg);
diff --git a/mcs/class/corlib/System.Runtime.InteropServices/ITypeLibImporterNotifySink.cs b/mcs/class/corlib/System.Runtime.InteropServices/ITypeLibImporterNotifySink.cs
index 3c9199e4063..63fd4e158d2 100755
--- a/mcs/class/corlib/System.Runtime.InteropServices/ITypeLibImporterNotifySink.cs
+++ b/mcs/class/corlib/System.Runtime.InteropServices/ITypeLibImporterNotifySink.cs
@@ -11,7 +11,7 @@ using System.Reflection;
namespace System.Runtime.InteropServices {
- //[Guid("")]
+ [Guid("f1c3bf76-c3e4-11d3-88e7-00902754c43a")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface ITypeLibImporterNotifySink {
void ReportEvent(ImporterEventKind eventKind, int eventCode, string eventMsg);
diff --git a/mcs/class/corlib/System.Runtime.InteropServices/Marshal.cs b/mcs/class/corlib/System.Runtime.InteropServices/Marshal.cs
index 5a07b084477..7fffb889623 100644
--- a/mcs/class/corlib/System.Runtime.InteropServices/Marshal.cs
+++ b/mcs/class/corlib/System.Runtime.InteropServices/Marshal.cs
@@ -1,4 +1,4 @@
-// System.Runtime.InteropServices.Marshal
+// System.Runtime.InteropServices.Marshal.cs
//
// Sean MacIsaac (macisaac@ximian.com)
// Paolo Molaro (lupus@ximian.com)
@@ -8,11 +8,13 @@
using System.Runtime.CompilerServices;
using System;
+using System.Security;
using System.Reflection;
using System.Threading;
namespace System.Runtime.InteropServices
{
+ [SuppressUnmanagedCodeSecurity ()]
public sealed class Marshal
{
/* fields */
@@ -354,7 +356,7 @@ namespace System.Runtime.InteropServices
public extern static byte ReadByte (IntPtr ptr, int ofs);
[MonoTODO]
- public static byte ReadByte (object ptr, int ofs) {
+ public static byte ReadByte ([In] object ptr, int ofs) {
throw new NotImplementedException ();
}
@@ -366,7 +368,7 @@ namespace System.Runtime.InteropServices
public extern static short ReadInt16 (IntPtr ptr, int ofs);
[MonoTODO]
- public static short ReadInt16 (object ptr, int ofs) {
+ public static short ReadInt16 ([In] object ptr, int ofs) {
throw new NotImplementedException ();
}
@@ -378,7 +380,7 @@ namespace System.Runtime.InteropServices
public extern static int ReadInt32 (IntPtr ptr, int ofs);
[MonoTODO]
- public static int ReadInt32 (object ptr, int ofs) {
+ public static int ReadInt32 ([In] object ptr, int ofs) {
throw new NotImplementedException ();
}
@@ -390,7 +392,7 @@ namespace System.Runtime.InteropServices
public extern static long ReadInt64 (IntPtr ptr, int ofs);
[MonoTODO]
- public static long ReadInt64(object ptr, int ofs) {
+ public static long ReadInt64([In] object ptr, int ofs) {
throw new NotImplementedException ();
}
@@ -402,7 +404,7 @@ namespace System.Runtime.InteropServices
public extern static IntPtr ReadIntPtr (IntPtr ptr, int ofs);
[MonoTODO]
- public static IntPtr ReadIntPtr(object ptr, int ofs) {
+ public static IntPtr ReadIntPtr([In] object ptr, int ofs) {
throw new NotImplementedException ();
}
@@ -496,7 +498,7 @@ namespace System.Runtime.InteropServices
public extern static void WriteByte (IntPtr ptr, int ofs, byte val);
[MonoTODO]
- public static void WriteByte(object ptr, int ofs, byte val) {
+ public static void WriteByte([In,Out] object ptr, int ofs, byte val) {
throw new NotImplementedException ();
}
@@ -508,7 +510,20 @@ namespace System.Runtime.InteropServices
public extern static void WriteInt16 (IntPtr ptr, int ofs, short val);
[MonoTODO]
- public static void WriteInt16(object ptr, int ofs, short val) {
+ public static void WriteInt16([In,Out] object ptr, int ofs, short val) {
+ throw new NotImplementedException ();
+ }
+
+ public static void WriteInt16 (IntPtr ptr, char val) {
+ WriteInt16 (ptr, 0, val);
+ }
+
+ [MonoTODO]
+ [MethodImplAttribute(MethodImplOptions.InternalCall)]
+ public extern static void WriteInt16 (IntPtr ptr, int ofs, char val);
+
+ [MonoTODO]
+ public static void WriteInt16([In,Out] object ptr, int ofs, char val) {
throw new NotImplementedException ();
}
@@ -520,7 +535,7 @@ namespace System.Runtime.InteropServices
public extern static void WriteInt32 (IntPtr ptr, int ofs, int val);
[MonoTODO]
- public static void WriteInt32(object ptr, int ofs, int val) {
+ public static void WriteInt32([In,Out] object ptr, int ofs, int val) {
throw new NotImplementedException ();
}
@@ -532,7 +547,7 @@ namespace System.Runtime.InteropServices
public extern static void WriteInt64 (IntPtr ptr, int ofs, long val);
[MonoTODO]
- public static void WriteInt64(object ptr, int ofs, long val) {
+ public static void WriteInt64([In] object ptr, int ofs, long val) {
throw new NotImplementedException ();
}
@@ -544,7 +559,7 @@ namespace System.Runtime.InteropServices
public extern static void WriteIntPtr (IntPtr ptr, int ofs, IntPtr val);
[MonoTODO]
- public static void WriteIntPtr(object ptr, int ofs, IntPtr val) {
+ public static void WriteIntPtr([In] object ptr, int ofs, IntPtr val) {
throw new NotImplementedException ();
}
diff --git a/mcs/class/corlib/System.Runtime.InteropServices/MarshalAsAttribute.cs b/mcs/class/corlib/System.Runtime.InteropServices/MarshalAsAttribute.cs
index 48e9f523d07..d4961d1d889 100755
--- a/mcs/class/corlib/System.Runtime.InteropServices/MarshalAsAttribute.cs
+++ b/mcs/class/corlib/System.Runtime.InteropServices/MarshalAsAttribute.cs
@@ -1,3 +1,10 @@
+//
+// System.Runtime.InteropServices.MarshalAsAttribute.cs
+//
+// Author:
+// Andreas Nahr (ClassDevelopment@A-SoftTech.com)
+//
+
using System;
namespace System.Runtime.InteropServices {
@@ -12,6 +19,7 @@ namespace System.Runtime.InteropServices {
public VarEnum SafeArraySubType;
public int SizeConst;
public short SizeParamIndex;
+ public Type SafeArrayUserDefinedSubType;
public MarshalAsAttribute (short unmanagedType) {
utype = (UnmanagedType)unmanagedType;
diff --git a/mcs/class/corlib/System.Runtime.InteropServices/ObjectCreationDelegate.cs b/mcs/class/corlib/System.Runtime.InteropServices/ObjectCreationDelegate.cs
new file mode 100644
index 00000000000..8e08d997b9e
--- /dev/null
+++ b/mcs/class/corlib/System.Runtime.InteropServices/ObjectCreationDelegate.cs
@@ -0,0 +1,14 @@
+//
+// System.Runtime.InteropServices.ObjectCreationDelegate.cs
+//
+// Author:
+// Miguel de Icaza (miguel@ximian.com)
+//
+// (C) Novell, Inc. http://www.ximian.com
+//
+using System;
+
+namespace System.Runtime.InteropServices {
+
+ public delegate IntPtr ObjectCreationDelegate (IntPtr aggregator);
+}
diff --git a/mcs/class/corlib/System.Runtime.InteropServices/RegistrationServices.cs b/mcs/class/corlib/System.Runtime.InteropServices/RegistrationServices.cs
new file mode 100644
index 00000000000..2317aa6c170
--- /dev/null
+++ b/mcs/class/corlib/System.Runtime.InteropServices/RegistrationServices.cs
@@ -0,0 +1,69 @@
+//
+// System.Runtime.InteropServices.RegistrationServices.cs
+//
+// Author:
+// Andreas Nahr (ClassDevelopment@A-SoftTech.com)
+//
+
+using System;
+using System.Reflection;
+
+namespace System.Runtime.InteropServices
+{
+ [Guid ("475e398f-8afa-43a7-a3be-f4ef8d6787c9")]
+ [ClassInterface (ClassInterfaceType.None)]
+ public class RegistrationServices : IRegistrationServices
+ {
+ public RegistrationServices ()
+ {
+ }
+
+ [MonoTODO ("implement")]
+ public virtual Guid GetManagedCategoryGuid ()
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO ("implement")]
+ public virtual string GetProgIdForType (Type type)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO ("implement")]
+ public virtual Type[] GetRegistrableTypesInAssembly (Assembly assembly)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO ("implement")]
+ public virtual bool RegisterAssembly (Assembly assembly, AssemblyRegistrationFlags flags)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO ("implement")]
+ public virtual void RegisterTypeForComClients (Type type, ref Guid g)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO ("implement")]
+ public virtual bool TypeRepresentsComType (Type type)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO ("implement")]
+ public virtual bool TypeRequiresRegistration (Type type)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO ("implement")]
+ public virtual bool UnregisterAssembly (Assembly assembly)
+ {
+ throw new NotImplementedException ();
+ }
+ }
+}
diff --git a/mcs/class/corlib/System.Runtime.InteropServices/TypeLibConverter.cs b/mcs/class/corlib/System.Runtime.InteropServices/TypeLibConverter.cs
new file mode 100644
index 00000000000..37d6f02307e
--- /dev/null
+++ b/mcs/class/corlib/System.Runtime.InteropServices/TypeLibConverter.cs
@@ -0,0 +1,46 @@
+//
+// System.Runtime.InteropServices.TypeLibConverter.cs
+//
+// Author:
+// Andreas Nahr (ClassDevelopment@A-SoftTech.com)
+//
+
+using System;
+using System.Reflection;
+using System.Reflection.Emit;
+
+namespace System.Runtime.InteropServices
+{
+ [Guid ("f1c3bf79-c3e4-11d3-88e7-00902754c43a")]
+ [ClassInterface (ClassInterfaceType.None)]
+ public sealed class TypeLibConverter : ITypeLibConverter
+ {
+ public TypeLibConverter ()
+ {
+ }
+
+ [MonoTODO ("implement")]
+ public object ConvertAssemblyToTypeLib (Assembly assembly, string strTypeLibName, TypeLibExporterFlags flags, ITypeLibExporterNotifySink notifySink)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO ("implement")]
+ public AssemblyBuilder ConvertTypeLibToAssembly (object typeLib, string asmFileName, int flags, ITypeLibImporterNotifySink notifySink, byte[] publicKey, StrongNameKeyPair keyPair, bool unsafeInterfaces)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO ("implement")]
+ public AssemblyBuilder ConvertTypeLibToAssembly (object typeLib, string asmFileName, TypeLibImporterFlags flags, ITypeLibImporterNotifySink notifySink, byte[] publicKey, StrongNameKeyPair keyPair, string asmNamespace, Version asmVersion)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO ("implement")]
+ public bool GetPrimaryInteropAssembly (Guid g, int major, int minor, int lcid, out string asmName, out string asmCodeBase)
+ {
+ throw new NotImplementedException ();
+ }
+ }
+}
diff --git a/mcs/class/corlib/System.Runtime.InteropServices/UCOMIBindCtx.cs b/mcs/class/corlib/System.Runtime.InteropServices/UCOMIBindCtx.cs
index 1b0c9ed016e..b25e8b758c0 100644
--- a/mcs/class/corlib/System.Runtime.InteropServices/UCOMIBindCtx.cs
+++ b/mcs/class/corlib/System.Runtime.InteropServices/UCOMIBindCtx.cs
@@ -9,18 +9,19 @@ using System;
namespace System.Runtime.InteropServices
{
+ [Guid ("0000000e-0000-0000-c000-000000000046")]
[InterfaceType (ComInterfaceType.InterfaceIsIUnknown)]
public interface UCOMIBindCtx
{
- void EnumObjectParam (ref UCOMIEnumString ppenum);
+ void EnumObjectParam (out UCOMIEnumString ppenum);
void GetBindOptions (ref BIND_OPTS pbindopts);
- void GetObjectParam (string pszKey, ref object ppunk);
- void GetRunningObjectTable (ref UCOMIRunningObjectTable pprot);
+ void GetObjectParam (string pszKey, out object ppunk);
+ void GetRunningObjectTable (out UCOMIRunningObjectTable pprot);
void RegisterObjectBound (object punk);
void RegisterObjectParam (string pszKey, object punk);
void ReleaseBoundObjects ();
void RevokeObjectBound (object punk);
void RevokeObjectParam (string pszKey);
- void SetBindOptions (ref BIND_OPTS pbindopts);
+ void SetBindOptions ([In] ref BIND_OPTS pbindopts);
}
}
diff --git a/mcs/class/corlib/System.Runtime.InteropServices/UCOMIConnectionPoint.cs b/mcs/class/corlib/System.Runtime.InteropServices/UCOMIConnectionPoint.cs
index db6a0c7b526..7879c87331c 100644
--- a/mcs/class/corlib/System.Runtime.InteropServices/UCOMIConnectionPoint.cs
+++ b/mcs/class/corlib/System.Runtime.InteropServices/UCOMIConnectionPoint.cs
@@ -9,13 +9,14 @@ using System;
namespace System.Runtime.InteropServices
{
+ [Guid ("b196b286-bab4-101a-b69c-00aa00341d07")]
[InterfaceType (ComInterfaceType.InterfaceIsIUnknown)]
public interface UCOMIConnectionPoint
{
- void Advise (object pUnkSink, ref int pdwCookie);
- void EnumConnections (ref UCOMIEnumConnections ppEnum);
- void GetConnectionInterface (ref Guid pIID);
- void GetConnectionPointContainer (ref UCOMIConnectionPointContainer ppCPC);
+ void Advise (object pUnkSink, out int pdwCookie);
+ void EnumConnections (out UCOMIEnumConnections ppEnum);
+ void GetConnectionInterface (out Guid pIID);
+ void GetConnectionPointContainer (out UCOMIConnectionPointContainer ppCPC);
void Unadvise (int dwCookie);
}
}
diff --git a/mcs/class/corlib/System.Runtime.InteropServices/UCOMIConnectionPointContainer.cs b/mcs/class/corlib/System.Runtime.InteropServices/UCOMIConnectionPointContainer.cs
index f34c40b678c..3b60cc0e508 100644
--- a/mcs/class/corlib/System.Runtime.InteropServices/UCOMIConnectionPointContainer.cs
+++ b/mcs/class/corlib/System.Runtime.InteropServices/UCOMIConnectionPointContainer.cs
@@ -9,10 +9,11 @@ using System;
namespace System.Runtime.InteropServices
{
+ [Guid ("b196b284-bab4-101a-b69c-00aa00341d07")]
[InterfaceType (ComInterfaceType.InterfaceIsIUnknown)]
public interface UCOMIConnectionPointContainer
{
- void EnumConnectionPoints (ref UCOMIEnumConnectionPoints ppEnum);
- void FindConnectionPoint (ref Guid riid, ref UCOMIConnectionPoint ppCP);
+ void EnumConnectionPoints (out UCOMIEnumConnectionPoints ppEnum);
+ void FindConnectionPoint (ref Guid riid, out UCOMIConnectionPoint ppCP);
}
}
diff --git a/mcs/class/corlib/System.Runtime.InteropServices/UCOMIEnumConnectionPoints.cs b/mcs/class/corlib/System.Runtime.InteropServices/UCOMIEnumConnectionPoints.cs
index b3d0b5cd58a..5bb6a537518 100644
--- a/mcs/class/corlib/System.Runtime.InteropServices/UCOMIEnumConnectionPoints.cs
+++ b/mcs/class/corlib/System.Runtime.InteropServices/UCOMIEnumConnectionPoints.cs
@@ -9,11 +9,12 @@ using System;
namespace System.Runtime.InteropServices
{
+ [Guid ("b196b285-bab4-101a-b69c-00aa00341d07")]
[InterfaceType (ComInterfaceType.InterfaceIsIUnknown)]
public interface UCOMIEnumConnectionPoints
{
- void Clone (ref UCOMIEnumConnectionPoints ppenum);
- int Next (int celt, UCOMIConnectionPoint[] rgelt, ref int pceltFetched);
+ void Clone (out UCOMIEnumConnectionPoints ppenum);
+ int Next (int celt, [Out] UCOMIConnectionPoint[] rgelt, out int pceltFetched);
int Reset ();
int Skip (int celt);
}
diff --git a/mcs/class/corlib/System.Runtime.InteropServices/UCOMIEnumConnections.cs b/mcs/class/corlib/System.Runtime.InteropServices/UCOMIEnumConnections.cs
index 300930ebb2a..a9e815196ce 100644
--- a/mcs/class/corlib/System.Runtime.InteropServices/UCOMIEnumConnections.cs
+++ b/mcs/class/corlib/System.Runtime.InteropServices/UCOMIEnumConnections.cs
@@ -9,11 +9,12 @@ using System;
namespace System.Runtime.InteropServices
{
+ [Guid ("b196b287-bab4-101a-b69c-00aa00341d07")]
[InterfaceType (ComInterfaceType.InterfaceIsIUnknown)]
public interface UCOMIEnumConnections
{
- void Clone (ref UCOMIEnumConnections ppenum);
- int Next (int celt, CONNECTDATA[] rgelt, ref int pceltFetched);
+ void Clone (out UCOMIEnumConnections ppenum);
+ int Next (int celt, [Out] CONNECTDATA[] rgelt, out int pceltFetched);
void Reset ();
int Skip (int celt);
}
diff --git a/mcs/class/corlib/System.Runtime.InteropServices/UCOMIEnumMoniker.cs b/mcs/class/corlib/System.Runtime.InteropServices/UCOMIEnumMoniker.cs
index acdbdab9ae2..efec1fc821e 100644
--- a/mcs/class/corlib/System.Runtime.InteropServices/UCOMIEnumMoniker.cs
+++ b/mcs/class/corlib/System.Runtime.InteropServices/UCOMIEnumMoniker.cs
@@ -9,11 +9,12 @@ using System;
namespace System.Runtime.InteropServices
{
+ [Guid ("00000102-0000-0000-c000-000000000046")]
[InterfaceType (ComInterfaceType.InterfaceIsIUnknown)]
public interface UCOMIEnumMoniker
{
- void Clone (ref UCOMIEnumMoniker ppenum);
- int Next (int celt, UCOMIMoniker[] rgelt, ref int pceltFetched);
+ void Clone (out UCOMIEnumMoniker ppenum);
+ int Next (int celt, [Out] UCOMIMoniker[] rgelt, out int pceltFetched);
int Reset ();
int Skip (int celt);
}
diff --git a/mcs/class/corlib/System.Runtime.InteropServices/UCOMIEnumString.cs b/mcs/class/corlib/System.Runtime.InteropServices/UCOMIEnumString.cs
index 052b12f460c..e7d6fc5ff22 100644
--- a/mcs/class/corlib/System.Runtime.InteropServices/UCOMIEnumString.cs
+++ b/mcs/class/corlib/System.Runtime.InteropServices/UCOMIEnumString.cs
@@ -9,11 +9,12 @@ using System;
namespace System.Runtime.InteropServices
{
+ [Guid ("00000101-0000-0000-c000-000000000046")]
[InterfaceType (ComInterfaceType.InterfaceIsIUnknown)]
public interface UCOMIEnumString
{
- void Clone (ref UCOMIEnumString ppenum);
- int Next (int celt, string[] rgelt, ref int pceltFetched);
+ void Clone (out UCOMIEnumString ppenum);
+ int Next (int celt, [Out] string[] rgelt, out int pceltFetched);
int Reset ();
int Skip (int celt);
}
diff --git a/mcs/class/corlib/System.Runtime.InteropServices/UCOMIEnumVARIANT.cs b/mcs/class/corlib/System.Runtime.InteropServices/UCOMIEnumVARIANT.cs
index 70f5068a89d..d2c353f348c 100644
--- a/mcs/class/corlib/System.Runtime.InteropServices/UCOMIEnumVARIANT.cs
+++ b/mcs/class/corlib/System.Runtime.InteropServices/UCOMIEnumVARIANT.cs
@@ -9,6 +9,7 @@ using System;
namespace System.Runtime.InteropServices
{
+ [Guid ("00020404-0000-0000-c000-000000000046")]
[InterfaceType (ComInterfaceType.InterfaceIsIUnknown)]
public interface UCOMIEnumVARIANT
{
diff --git a/mcs/class/corlib/System.Runtime.InteropServices/UCOMIMoniker.cs b/mcs/class/corlib/System.Runtime.InteropServices/UCOMIMoniker.cs
index f3ababd1533..1cdca0a82e0 100644
--- a/mcs/class/corlib/System.Runtime.InteropServices/UCOMIMoniker.cs
+++ b/mcs/class/corlib/System.Runtime.InteropServices/UCOMIMoniker.cs
@@ -9,28 +9,29 @@ using System;
namespace System.Runtime.InteropServices
{
+ [Guid ("0000000f-0000-0000-c000-000000000046")]
[InterfaceType (ComInterfaceType.InterfaceIsIUnknown)]
public interface UCOMIMoniker
{
- void BindToObject (UCOMIBindCtx pbc, UCOMIMoniker pmkToLeft, ref Guid riidResult, ref object ppvResult);
- void BindToStorage (UCOMIBindCtx pbc, UCOMIMoniker pmkToLeft, ref Guid riid, ref object ppvObj);
- void CommonPrefixWith (UCOMIMoniker pmkOther, ref UCOMIMoniker ppmkPrefix);
- void ComposeWith (UCOMIMoniker pmkRight, bool fOnlyIfNotGeneric, ref UCOMIMoniker ppmkComposite);
- void Enum (bool fForward, ref UCOMIEnumMoniker ppenumMoniker);
- void GetClassID (ref Guid pClassID);
- void GetDisplayName (UCOMIBindCtx pbc, UCOMIMoniker pmkToLeft, ref string ppszDisplayName);
- void GetSizeMax (ref long pcbSize);
- void GetTimeOfLastChange (UCOMIBindCtx pbc, UCOMIMoniker pmkToLeft, ref FILETIME pFileTime);
- void Hash (ref int pdwHash);
- void Inverse (ref UCOMIMoniker ppmk);
+ void BindToObject (UCOMIBindCtx pbc, UCOMIMoniker pmkToLeft, [In] ref Guid riidResult, out object ppvResult);
+ void BindToStorage (UCOMIBindCtx pbc, UCOMIMoniker pmkToLeft, [In] ref Guid riid, out object ppvObj);
+ void CommonPrefixWith (UCOMIMoniker pmkOther, out UCOMIMoniker ppmkPrefix);
+ void ComposeWith (UCOMIMoniker pmkRight, bool fOnlyIfNotGeneric, out UCOMIMoniker ppmkComposite);
+ void Enum (bool fForward, out UCOMIEnumMoniker ppenumMoniker);
+ void GetClassID (out Guid pClassID);
+ void GetDisplayName (UCOMIBindCtx pbc, UCOMIMoniker pmkToLeft, out string ppszDisplayName);
+ void GetSizeMax (out long pcbSize);
+ void GetTimeOfLastChange (UCOMIBindCtx pbc, UCOMIMoniker pmkToLeft, out FILETIME pFileTime);
+ void Hash (out int pdwHash);
+ void Inverse (out UCOMIMoniker ppmk);
int IsDirty ();
void IsEqual (UCOMIMoniker pmkOtherMoniker);
void IsRunning (UCOMIBindCtx pbc, UCOMIMoniker pmkToLeft, UCOMIMoniker pmkNewlyRunning);
- void IsSystemMoniker (ref int pdwMksys);
+ void IsSystemMoniker (out int pdwMksys);
void Load (UCOMIStream pStm);
- void ParseDisplayName (UCOMIBindCtx pbc, UCOMIMoniker pmkToLeft, string pszDisplayName, ref int pchEaten, ref UCOMIMoniker ppmkOut);
- void Reduce (UCOMIBindCtx pbc, int dwReduceHowFar, ref UCOMIMoniker ppmkToLeft, ref UCOMIMoniker ppmkReduced);
- void RelativePathTo (UCOMIMoniker pmkOther, ref UCOMIMoniker ppmkRelPath);
+ void ParseDisplayName (UCOMIBindCtx pbc, UCOMIMoniker pmkToLeft, string pszDisplayName, out int pchEaten, out UCOMIMoniker ppmkOut);
+ void Reduce (UCOMIBindCtx pbc, int dwReduceHowFar, ref UCOMIMoniker ppmkToLeft, out UCOMIMoniker ppmkReduced);
+ void RelativePathTo (UCOMIMoniker pmkOther, out UCOMIMoniker ppmkRelPath);
void Save (UCOMIStream pStm, bool fClearDirty);
}
}
diff --git a/mcs/class/corlib/System.Runtime.InteropServices/UCOMIPersistFile.cs b/mcs/class/corlib/System.Runtime.InteropServices/UCOMIPersistFile.cs
index 0b644268cb0..1bfea178c65 100644
--- a/mcs/class/corlib/System.Runtime.InteropServices/UCOMIPersistFile.cs
+++ b/mcs/class/corlib/System.Runtime.InteropServices/UCOMIPersistFile.cs
@@ -9,11 +9,12 @@ using System;
namespace System.Runtime.InteropServices
{
+ [Guid ("0000010b-0000-0000-c000-000000000046")]
[InterfaceType (ComInterfaceType.InterfaceIsIUnknown)]
public interface UCOMIPersistFile
{
- void GetClassID (ref Guid pClassID);
- void GetCurFile (ref string ppszFileName);
+ void GetClassID (out Guid pClassID);
+ void GetCurFile (out string ppszFileName);
int IsDirty ();
void Load (string pszFileName, int dwMode);
void Save (string pszFileName, bool fRemember);
diff --git a/mcs/class/corlib/System.Runtime.InteropServices/UCOMIRunningObjectTable.cs b/mcs/class/corlib/System.Runtime.InteropServices/UCOMIRunningObjectTable.cs
index 2d2cd02db65..0b22cafcff8 100644
--- a/mcs/class/corlib/System.Runtime.InteropServices/UCOMIRunningObjectTable.cs
+++ b/mcs/class/corlib/System.Runtime.InteropServices/UCOMIRunningObjectTable.cs
@@ -9,15 +9,16 @@ using System;
namespace System.Runtime.InteropServices
{
+ [Guid ("00000010-0000-0000-c000-000000000046")]
[InterfaceType (ComInterfaceType.InterfaceIsIUnknown)]
public interface UCOMIRunningObjectTable
{
- void EnumRunning (ref UCOMIEnumMoniker ppenumMoniker);
- void GetObject (UCOMIMoniker pmkObjectName, ref object ppunkObject);
- void GetTimeOfLastChange (UCOMIMoniker pmkObjectName, ref FILETIME pfiletime);
+ void EnumRunning (out UCOMIEnumMoniker ppenumMoniker);
+ void GetObject (UCOMIMoniker pmkObjectName, out object ppunkObject);
+ void GetTimeOfLastChange (UCOMIMoniker pmkObjectName, out FILETIME pfiletime);
void IsRunning (UCOMIMoniker pmkObjectName);
void NoteChangeTime (int dwRegister, ref FILETIME pfiletime);
- void Register (int grfFlags, object punkObject, UCOMIMoniker pmkObjectName, ref int pdwRegister);
+ void Register (int grfFlags, object punkObject, UCOMIMoniker pmkObjectName, out int pdwRegister);
void Revoke (int dwRegister);
}
}
diff --git a/mcs/class/corlib/System.Runtime.InteropServices/UCOMIStream.cs b/mcs/class/corlib/System.Runtime.InteropServices/UCOMIStream.cs
index 74efa92e227..1612c9cbf48 100644
--- a/mcs/class/corlib/System.Runtime.InteropServices/UCOMIStream.cs
+++ b/mcs/class/corlib/System.Runtime.InteropServices/UCOMIStream.cs
@@ -6,21 +6,23 @@
//
using System;
+using System.Runtime.InteropServices;
namespace System.Runtime.InteropServices
{
+ [Guid ("0000000c-0000-0000-c000-000000000046")]
[InterfaceType (ComInterfaceType.InterfaceIsIUnknown)]
public interface UCOMIStream
{
- void Clone (ref UCOMIStream ppstm);
+ void Clone (out UCOMIStream ppstm);
void Commit (int grfCommitFlags);
void CopyTo (UCOMIStream pstm, long cb, IntPtr pcbRead, IntPtr pcbWritten);
void LockRegion (long libOffset, long cb, int dwLockType);
- void Read (byte[] pv, int cb, IntPtr pcbRead);
+ void Read ([Out] byte[] pv, int cb, IntPtr pcbRead);
void Revert ();
void Seek (long dlibMove, int dwOrigin, IntPtr plibNewPosition);
void SetSize (long libNewSize);
- void Stat (ref STATSTG pstatstg, int grfStatFlag);
+ void Stat (out STATSTG pstatstg, int grfStatFlag);
void UnlockRegion (long libOffset, long cb, int dwLockType);
void Write (byte[] pv, int cb, IntPtr pcbWritten);
}
diff --git a/mcs/class/corlib/System.Runtime.InteropServices/UCOMITypeComp.cs b/mcs/class/corlib/System.Runtime.InteropServices/UCOMITypeComp.cs
index 8bb02c82f49..87c43e0c8d1 100644
--- a/mcs/class/corlib/System.Runtime.InteropServices/UCOMITypeComp.cs
+++ b/mcs/class/corlib/System.Runtime.InteropServices/UCOMITypeComp.cs
@@ -1,5 +1,5 @@
-// System.Runtime.InteropServices/UCOMITypeComp.cs
+// System.Runtime.InteropServices.UCOMITypeComp.cs
//
// Paolo Molaro (lupus@ximian.com)
//
@@ -10,7 +10,7 @@ using System;
namespace System.Runtime.InteropServices
{
- //[Guid("")]
+ [Guid("00020403-0000-0000-c000-000000000046")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface UCOMITypeComp {
void Bind( string szName, int lHashVal, short wFlags, out UCOMITypeInfo ppTInfo, out DESCKIND pDescKind, out BINDPTR pBindPtr);
diff --git a/mcs/class/corlib/System.Runtime.InteropServices/UCOMITypeInfo.cs b/mcs/class/corlib/System.Runtime.InteropServices/UCOMITypeInfo.cs
index 1e36703c46d..29deaa10265 100644
--- a/mcs/class/corlib/System.Runtime.InteropServices/UCOMITypeInfo.cs
+++ b/mcs/class/corlib/System.Runtime.InteropServices/UCOMITypeInfo.cs
@@ -1,5 +1,5 @@
-// System.Runtime.InteropServices/UCOMITypeInfo.cs
+// System.Runtime.InteropServices.UCOMITypeInfo.cs
//
// Paolo Molaro (lupus@ximian.com)
//
@@ -10,7 +10,7 @@ using System;
namespace System.Runtime.InteropServices
{
- //[Guid("")]
+ [Guid("00020401-0000-0000-c000-000000000046")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface UCOMITypeInfo {
void AddressOfMember (int memid, INVOKEKIND invKind, out IntPtr ppv);
@@ -19,10 +19,10 @@ namespace System.Runtime.InteropServices
void GetDllEntry (int memid, INVOKEKIND invKind, out string pBstrDllName, out string pBstrName, out short pwOrdinal);
void GetDocumentation (int index, out string strName, out string strDocString, out int dwHelpContext, out string strHelpFile);
void GetFuncDesc (int index, out IntPtr ppFuncDesc);
- void GetIDsOfNames (string[] rgszNames, int cNames, int[] pMemId);
+ void GetIDsOfNames ([In] string[] rgszNames, int cNames, [Out] int[] pMemId);
void GetImplTypeFlags (int index, out int pImplTypeFlags);
void GetMops (int memid, out string pBstrMops);
- void GetNames (int memid, string[] rgBstrNames, int cMaxNames, out int pcNames);
+ void GetNames (int memid, [Out] string[] rgBstrNames, int cMaxNames, out int pcNames);
void GetRefTypeInfo (int hRef, out UCOMITypeInfo ppTI);
void GetRefTypeOfImplType (int index, out int href);
void GetTypeAttr (out IntPtr ppTypeAttr);
diff --git a/mcs/class/corlib/System.Runtime.InteropServices/UCOMITypeLib.cs b/mcs/class/corlib/System.Runtime.InteropServices/UCOMITypeLib.cs
index db6593d6489..a43c9760712 100644
--- a/mcs/class/corlib/System.Runtime.InteropServices/UCOMITypeLib.cs
+++ b/mcs/class/corlib/System.Runtime.InteropServices/UCOMITypeLib.cs
@@ -1,19 +1,20 @@
-// System.Runtime.InteropServices/UCOMITypeLib.cs
+// System.Runtime.InteropServices.UCOMITypeLib.cs
//
// Paolo Molaro (lupus@ximian.com)
//
// (C) 2002 Ximian, Inc.
using System;
+using System.Runtime.InteropServices;
namespace System.Runtime.InteropServices
{
- //[Guid("")]
+ [Guid("00020402-0000-0000-c000-000000000046")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface UCOMITypeLib {
- void FindName( string szNameBuf, int lHashVal, UCOMITypeInfo[] ppTInfo, int[] rgMemId, ref short pcFound);
+ void FindName( string szNameBuf, int lHashVal, [Out] UCOMITypeInfo[] ppTInfo, [Out] int[] rgMemId, ref short pcFound);
void GetDocumentation( int index, out string strName, out string strDocString, out int dwHelpContext, out string strHelpFile);
void GetLibAttr( out IntPtr ppTLibAttr);
void GetTypeComp( out UCOMITypeComp ppTComp);
diff --git a/mcs/class/corlib/System.Runtime.Remoting.Channels/AggregateDictionary.cs b/mcs/class/corlib/System.Runtime.Remoting.Channels/AggregateDictionary.cs
new file mode 100644
index 00000000000..0a721808696
--- /dev/null
+++ b/mcs/class/corlib/System.Runtime.Remoting.Channels/AggregateDictionary.cs
@@ -0,0 +1,189 @@
+//
+// System.Runtime.Remoting.Channels.AggregateDictionary.cs
+//
+// Author: Lluis Sanchez Gual (lluis@ximian.com)
+//
+// 2002 (C) Copyright, Novell, Inc.
+//
+
+using System.Collections;
+
+namespace System.Runtime.Remoting
+{
+ internal class AggregateDictionary: IDictionary
+ {
+ IDictionary[] dictionaries;
+ ArrayList _values;
+ ArrayList _keys;
+
+ public AggregateDictionary (IDictionary[] dics)
+ {
+ dictionaries = dics;
+ }
+
+ public bool IsFixedSize
+ {
+ get { return true; }
+ }
+
+ public bool IsReadOnly
+ {
+ get { return true; }
+ }
+
+ public object this [object key]
+ {
+ get
+ {
+ foreach (IDictionary dic in dictionaries)
+ if (dic.Contains (key)) return dic [key];
+ return null;
+ }
+
+ set
+ {
+ throw new NotSupportedException ();
+ }
+ }
+
+ public ICollection Keys
+ {
+ get
+ {
+ if (_keys != null) return _keys;
+
+ _keys = new ArrayList ();
+ foreach (IDictionary dic in dictionaries)
+ _keys.AddRange (dic.Keys);
+ return _keys;
+ }
+ }
+
+ public ICollection Values
+ {
+ get
+ {
+ if (_values != null) return _values;
+
+ _values = new ArrayList ();
+ foreach (IDictionary dic in dictionaries)
+ _values.AddRange (dic.Values);
+ return _values;
+ }
+ }
+
+ public void Add (object key, object value)
+ {
+ throw new NotSupportedException ();
+ }
+
+ public void Clear ()
+ {
+ throw new NotSupportedException ();
+ }
+
+ public bool Contains (object ob)
+ {
+ foreach (IDictionary dic in dictionaries)
+ if (dic.Contains (ob)) return true;
+ return false;
+ }
+
+ public IDictionaryEnumerator GetEnumerator ()
+ {
+ return new AggregateEnumerator (dictionaries);
+ }
+
+ IEnumerator IEnumerable.GetEnumerator ()
+ {
+ return new AggregateEnumerator (dictionaries);
+ }
+
+ public void Remove (object ob)
+ {
+ throw new NotSupportedException ();
+ }
+
+ public void CopyTo (Array array, int index)
+ {
+ foreach (object ob in this)
+ array.SetValue (ob, index++);
+ }
+
+ public int Count
+ {
+ get
+ {
+ int c = 0;
+ foreach (IDictionary dic in dictionaries)
+ c += dic.Count;
+ return c;
+ }
+ }
+
+ public bool IsSynchronized
+ {
+ get { return false; }
+ }
+
+ public object SyncRoot
+ {
+ get { return this; }
+ }
+ }
+
+ internal class AggregateEnumerator: IDictionaryEnumerator
+ {
+ IDictionary[] dictionaries;
+ int pos = 0;
+ IDictionaryEnumerator currente;
+
+ public AggregateEnumerator (IDictionary[] dics)
+ {
+ dictionaries = dics;
+ Reset ();
+ }
+
+ public DictionaryEntry Entry
+ {
+ get { return currente.Entry; }
+ }
+
+ public object Key
+ {
+ get { return currente.Key; }
+ }
+
+ public object Value
+ {
+ get { return currente.Value; }
+ }
+
+ public object Current
+ {
+ get { return currente.Current; }
+ }
+
+ public bool MoveNext ()
+ {
+ if (pos >= dictionaries.Length) return false;
+
+ if (!currente.MoveNext())
+ {
+ pos++;
+ if (pos >= dictionaries.Length) return false;
+ currente = dictionaries [pos].GetEnumerator ();
+ return MoveNext ();
+ }
+
+ return true;
+ }
+
+ public void Reset ()
+ {
+ pos = 0;
+ if (dictionaries.Length > 0)
+ currente = dictionaries [0].GetEnumerator ();
+ }
+ }
+}
diff --git a/mcs/class/corlib/System.Runtime.Remoting.Channels/ChangeLog b/mcs/class/corlib/System.Runtime.Remoting.Channels/ChangeLog
index 4c39596d93c..c929235c4bd 100644
--- a/mcs/class/corlib/System.Runtime.Remoting.Channels/ChangeLog
+++ b/mcs/class/corlib/System.Runtime.Remoting.Channels/ChangeLog
@@ -1,3 +1,28 @@
+2003-11-17 Lluis Sanchez Gual <lluis@ximian.com>
+
+ * GetChannelSinkProperties.cs: Implemented GetChannelSinkProperties().
+ * ServerDispatchSink.cs: Removed some TODOs.
+ * AggregateDictionary.cs: Added.
+
+2003-11-16 Lluis Sanchez Gual <lluis@ximian.com>
+
+ * ChannelServices.cs: Removed some TODOs. Implemented AsyncDispatchMessage.
+
+2003-11-13 Lluis Sanchez Gual <lluis@ximian.com>
+
+ * ChannelServices.cs: Catch errors when creating configured channels.
+
+2003-11-12 Lluis Sanchez Gual <lluis@ximian.com>
+
+ * ChannelServices.cs: Added support for creating channels from configuration
+ files. Added some locks.
+ * SinkProviderData.cs: Implemented.
+
+2003-11-11 Lluis Sanchez Gual <lluis@ximian.com>
+
+ * CrossAppDomainChannel.cs: Implemented support for async calls.
+ * ClientChannelSinkStack.cs, ServerDispatchSinkProvider.cs: Removed some TODOs
+
2003-11-01 Zoltan Varga <vargaz@freemail.hu>
* CrossAppDomainChannel.cs (SyncProcessMessage): Use the new
diff --git a/mcs/class/corlib/System.Runtime.Remoting.Channels/ChannelServices.cs b/mcs/class/corlib/System.Runtime.Remoting.Channels/ChannelServices.cs
index f56ce3fc243..59923319861 100644
--- a/mcs/class/corlib/System.Runtime.Remoting.Channels/ChannelServices.cs
+++ b/mcs/class/corlib/System.Runtime.Remoting.Channels/ChannelServices.cs
@@ -9,6 +9,7 @@
//
using System.Collections;
+using System.Reflection;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Messaging;
@@ -49,6 +50,8 @@ namespace System.Runtime.Remoting.Channels
public sealed class ChannelServices
{
private static ArrayList registeredChannels = new ArrayList ();
+ private static ArrayList delayedClientChannels = new ArrayList ();
+
private static CrossContextChannel _crossContextSink = new CrossContextChannel();
internal static string CrossContextUrl = "__CrossContext";
@@ -69,43 +72,62 @@ namespace System.Runtime.Remoting.Channels
object[] channelDataArray = (object[])remoteChannelData;
- foreach (IChannel c in registeredChannels)
+ lock (registeredChannels.SyncRoot)
{
- IChannelSender sender = c as IChannelSender;
- if (c == null) continue;
-
- if (channelDataArray == null) {
- IMessageSink sink = sender.CreateMessageSink (url, null, out objectUri);
- if (sink != null) return sink; // URL is ok, this is the channel and the sink
+ // First of all, try registered channels
+ foreach (IChannel c in registeredChannels)
+ {
+ IChannelSender sender = c as IChannelSender;
+ if (sender == null) continue;
+
+ IMessageSink sink = CreateClientChannelSinkChain (sender, url, channelDataArray, out objectUri);
+ if (sink != null) return sink;
}
- else {
- foreach (object data in channelDataArray) {
- IMessageSink sink = sender.CreateMessageSink (url, data, out objectUri);
- if (sink != null) return sink;
+
+ // Not found. Try now creation delayed channels
+ foreach (IChannelSender sender in delayedClientChannels)
+ {
+ IMessageSink sink = CreateClientChannelSinkChain (sender, url, channelDataArray, out objectUri);
+ if (sink != null) {
+ delayedClientChannels.Remove (sender);
+ RegisterChannel (sender);
+ return sink;
}
}
}
+
objectUri = null;
return null;
}
- public static IChannel[] RegisteredChannels
+ internal static IMessageSink CreateClientChannelSinkChain (IChannelSender sender, string url, object[] channelDataArray, out string objectUri)
{
- get {
- IChannel[] channels = new IChannel[registeredChannels.Count];
-
- for (int i = 0; i < registeredChannels.Count; i++)
- channels[i] = (IChannel) registeredChannels[i];
-
- return channels;
+ objectUri = null;
+ if (channelDataArray == null) {
+ return sender.CreateMessageSink (url, null, out objectUri);
+ }
+ else {
+ foreach (object data in channelDataArray) {
+ IMessageSink sink = sender.CreateMessageSink (url, data, out objectUri);
+ if (sink != null) return sink;
+ }
}
+ return null;
}
-
- [MonoTODO]
- public static IMessageCtrl AsyncDispatchMessage (IMessage msg,
- IMessageSink replySink)
+
+ public static IChannel[] RegisteredChannels
{
- throw new NotImplementedException ();
+ get {
+ lock (registeredChannels.SyncRoot)
+ {
+ IChannel[] channels = new IChannel[registeredChannels.Count];
+
+ for (int i = 0; i < registeredChannels.Count; i++)
+ channels[i] = (IChannel) registeredChannels[i];
+
+ return channels;
+ }
+ }
}
public static IServerChannelSink CreateServerChannelSinkChain (
@@ -119,13 +141,15 @@ namespace System.Runtime.Remoting.Channels
return provider.CreateSink (channel);
}
- [MonoTODO]
public static ServerProcessing DispatchMessage (
IServerChannelSinkStack sinkStack,
IMessage msg,
out IMessage replyMsg)
{
- // TODO: Async processing
+ if (msg == null) throw new ArgumentNullException ("msg");
+
+ // Async processing is not done here because there isn't any way
+ // to know if a message is to be dispatched sync or asynchronously.
replyMsg = SyncDispatchMessage (msg);
@@ -137,16 +161,39 @@ namespace System.Runtime.Remoting.Channels
public static IChannel GetChannel (string name)
{
- foreach (IChannel chnl in registeredChannels) {
- if (chnl.ChannelName == name && !(chnl is CrossAppDomainChannel)) return chnl;
+ lock (registeredChannels.SyncRoot)
+ {
+ foreach (IChannel chnl in registeredChannels) {
+ if (chnl.ChannelName == name && !(chnl is CrossAppDomainChannel)) return chnl;
+ }
+ return null;
}
- return null;
}
- [MonoTODO]
public static IDictionary GetChannelSinkProperties (object obj)
{
- throw new NotImplementedException ();
+ if (!RemotingServices.IsTransparentProxy (obj))
+ throw new ArgumentException ("obj must be a proxy","obj");
+
+ ClientIdentity ident = (ClientIdentity) RemotingServices.GetRealProxy (obj).ObjectIdentity;
+ IMessageSink sink = ident.ChannelSink;
+ ArrayList dics = new ArrayList ();
+
+ while (sink != null && !(sink is IClientChannelSink))
+ sink = sink.NextSink;
+
+ if (sink == null)
+ return new Hashtable ();
+
+ IClientChannelSink csink = sink as IClientChannelSink;
+ while (csink != null)
+ {
+ dics.Add (csink.Properties);
+ csink = csink.NextChannelSink;
+ }
+
+ IDictionary[] adics = (IDictionary[]) dics.ToArray (typeof(IDictionary[]));
+ return new AggregateDictionary (adics);
}
public static string[] GetUrlsForObject (MarshalByRefObject obj)
@@ -156,15 +203,18 @@ namespace System.Runtime.Remoting.Channels
ArrayList list = new ArrayList ();
- foreach (object chnl_obj in registeredChannels) {
- if (chnl_obj is CrossAppDomainChannel) continue;
-
- IChannelReceiver chnl = chnl_obj as IChannelReceiver;
-
- if (chnl != null)
- list.AddRange (chnl.GetUrlsForUri (uri));
+ lock (registeredChannels.SyncRoot)
+ {
+ foreach (object chnl_obj in registeredChannels) {
+ if (chnl_obj is CrossAppDomainChannel) continue;
+
+ IChannelReceiver chnl = chnl_obj as IChannelReceiver;
+
+ if (chnl != null)
+ list.AddRange (chnl.GetUrlsForUri (uri));
+ }
}
-
+
return (string[]) list.ToArray (typeof(string));
}
@@ -173,54 +223,180 @@ namespace System.Runtime.Remoting.Channels
// Put the channel in the correct place according to its priority.
// Since there are not many channels, a linear search is ok.
- for (int n = 0; n < registeredChannels.Count; n++) {
- if ( ((IChannel)registeredChannels[n]).ChannelPriority < chnl.ChannelPriority)
+ lock (registeredChannels.SyncRoot)
+ {
+ int pos = -1;
+ for (int n = 0; n < registeredChannels.Count; n++)
{
- registeredChannels.Insert (n, chnl);
- return;
+ IChannel regc = (IChannel) registeredChannels[n];
+
+ if (regc.ChannelName == chnl.ChannelName)
+ throw new RemotingException ("Channel " + regc.ChannelName + " already registered");
+
+ if (regc.ChannelPriority < chnl.ChannelPriority && pos==-1)
+ pos = n;
}
+
+ if (pos != -1) registeredChannels.Insert (pos, chnl);
+ else registeredChannels.Add (chnl);
+
+ IChannelReceiver receiver = chnl as IChannelReceiver;
+ if (receiver != null) receiver.StartListening (null);
+ }
+ }
+
+ internal static void RegisterChannelConfig (ChannelData channel)
+ {
+ IServerChannelSinkProvider serverSinks = null;
+ IClientChannelSinkProvider clientSinks = null;
+
+ // Create server providers
+ for (int n=channel.ServerProviders.Count-1; n>=0; n--)
+ {
+ ProviderData prov = channel.ServerProviders[n] as ProviderData;
+ IServerChannelSinkProvider sinkp = (IServerChannelSinkProvider) CreateProvider (prov);
+ sinkp.Next = serverSinks;
+ serverSinks = sinkp;
+ }
+
+ // Create client providers
+ for (int n=channel.ClientProviders.Count-1; n>=0; n--)
+ {
+ ProviderData prov = channel.ClientProviders[n] as ProviderData;
+ IClientChannelSinkProvider sinkp = (IClientChannelSinkProvider) CreateProvider (prov);
+ sinkp.Next = clientSinks;
+ clientSinks = sinkp;
+ }
+
+ // Create the channel
+
+ Type type = Type.GetType (channel.Type);
+ if (type == null) throw new RemotingException ("Type '" + channel.Type + "' not found");
+
+ Object[] parms;
+ Type[] signature;
+ bool clienc = typeof (IChannelSender).IsAssignableFrom (type);
+ bool serverc = typeof (IChannelReceiver).IsAssignableFrom (type);
+
+ if (clienc && serverc) {
+ signature = new Type [] {typeof(IDictionary), typeof(IClientChannelSinkProvider), typeof(IServerChannelSinkProvider)};
+ parms = new Object[] {channel.CustomProperties, clientSinks, serverSinks};
+ }
+ else if (clienc) {
+ signature = new Type [] {typeof(IDictionary), typeof(IClientChannelSinkProvider)};
+ parms = new Object[] {channel.CustomProperties, clientSinks};
+ }
+ else if (serverc) {
+ signature = new Type [] {typeof(IDictionary), typeof(IServerChannelSinkProvider)};
+ parms = new Object[] {channel.CustomProperties, serverSinks};
+ }
+ else
+ throw new RemotingException (type + " is not a valid channel type");
+
+ ConstructorInfo ctor = type.GetConstructor (signature);
+ if (ctor == null)
+ throw new RemotingException (type + " does not have a valid constructor");
+
+ IChannel ch;
+ try
+ {
+ ch = (IChannel) ctor.Invoke (parms);
+ }
+ catch (TargetInvocationException ex)
+ {
+ throw ex.InnerException;
+ }
+
+ lock (registeredChannels.SyncRoot)
+ {
+ if (channel.DelayLoadAsClientChannel == "true" && !(ch is IChannelReceiver))
+ delayedClientChannels.Add (ch);
+ else
+ RegisterChannel (ch);
+ }
+ }
+
+ static object CreateProvider (ProviderData prov)
+ {
+ Type pvtype = Type.GetType (prov.Type);
+ if (pvtype == null) throw new RemotingException ("Type '" + prov.Type + "' not found");
+ Object[] pvparms = new Object[] {prov.CustomProperties, prov.CustomData};
+
+ try
+ {
+ return Activator.CreateInstance (pvtype, pvparms);
+ }
+ catch (Exception ex)
+ {
+ if (ex is TargetInvocationException) ex = ((TargetInvocationException)ex).InnerException;
+ throw new RemotingException ("An instance of provider '" + pvtype + "' could not be created: " + ex.Message);
}
- registeredChannels.Add (chnl);
}
public static IMessage SyncDispatchMessage (IMessage msg)
{
+ IMessage ret = CheckIncomingMessage (msg);
+ if (ret != null) return ret;
+ return _crossContextSink.SyncProcessMessage (msg);
+ }
+
+ public static IMessageCtrl AsyncDispatchMessage (IMessage msg, IMessageSink replySink)
+ {
+ IMessage ret = CheckIncomingMessage (msg);
+ if (ret != null) {
+ replySink.SyncProcessMessage (ret);
+ return null;
+ }
+ return _crossContextSink.AsyncProcessMessage (msg, replySink);
+ }
+
+ static ReturnMessage CheckIncomingMessage (IMessage msg)
+ {
IMethodMessage call = (IMethodMessage)msg;
- ServerIdentity identity = RemotingServices.GetIdentityForUri(call.Uri) as ServerIdentity;
- if (identity == null) return new ReturnMessage (new RemotingException ("No receiver for uri " + call.Uri), (IMethodCallMessage) msg);
+ ServerIdentity identity = RemotingServices.GetIdentityForUri (call.Uri) as ServerIdentity;
+
+ if (identity == null)
+ return new ReturnMessage (new RemotingException ("No receiver for uri " + call.Uri), (IMethodCallMessage) msg);
RemotingServices.SetMessageTargetIdentity (msg, identity);
- return _crossContextSink.SyncProcessMessage (msg);
+ return null;
}
public static void UnregisterChannel (IChannel chnl)
{
if (chnl == null)
throw new ArgumentNullException ();
- if (!registeredChannels.Contains ((object) chnl))
- throw new RemotingException ();
-
- registeredChannels.Remove ((object) chnl);
-
- IChannelReceiver chnlReceiver = chnl as IChannelReceiver;
- if(chnlReceiver != null)
- chnlReceiver.StopListening(null);
-}
+
+ lock (registeredChannels.SyncRoot)
+ {
+ if (!registeredChannels.Contains ((object) chnl))
+ throw new RemotingException ();
+
+ registeredChannels.Remove ((object) chnl);
+
+ IChannelReceiver chnlReceiver = chnl as IChannelReceiver;
+ if(chnlReceiver != null)
+ chnlReceiver.StopListening(null);
+ }
+ }
internal static object [] GetCurrentChannelInfo ()
{
ArrayList list = new ArrayList ();
- foreach (object chnl_obj in registeredChannels) {
- IChannelReceiver chnl = chnl_obj as IChannelReceiver;
-
- if (chnl != null) {
- object chnl_data = chnl.ChannelData;
- if (chnl_data != null)
- list.Add (chnl_data);
+ lock (registeredChannels.SyncRoot)
+ {
+ foreach (object chnl_obj in registeredChannels) {
+ IChannelReceiver chnl = chnl_obj as IChannelReceiver;
+
+ if (chnl != null) {
+ object chnl_data = chnl.ChannelData;
+ if (chnl_data != null)
+ list.Add (chnl_data);
+ }
}
}
-
+
return list.ToArray ();
}
}
diff --git a/mcs/class/corlib/System.Runtime.Remoting.Channels/ClientChannelSinkStack.cs b/mcs/class/corlib/System.Runtime.Remoting.Channels/ClientChannelSinkStack.cs
index b5573a4457f..f5dcc37a22a 100644
--- a/mcs/class/corlib/System.Runtime.Remoting.Channels/ClientChannelSinkStack.cs
+++ b/mcs/class/corlib/System.Runtime.Remoting.Channels/ClientChannelSinkStack.cs
@@ -20,10 +20,9 @@ namespace System.Runtime.Remoting.Channels
// The stack. It is a chain of ChanelSinkStackEntry.
ChanelSinkStackEntry _sinkStack = null;
- [MonoTODO ("Initialize new instance with default values")]
- public ClientChannelSinkStack ()
- {
- }
+ public ClientChannelSinkStack ()
+ {
+ }
public ClientChannelSinkStack (IMessageSink sink)
{
diff --git a/mcs/class/corlib/System.Runtime.Remoting.Channels/CrossAppDomainChannel.cs b/mcs/class/corlib/System.Runtime.Remoting.Channels/CrossAppDomainChannel.cs
index e4c15adff5c..407f0554996 100755
--- a/mcs/class/corlib/System.Runtime.Remoting.Channels/CrossAppDomainChannel.cs
+++ b/mcs/class/corlib/System.Runtime.Remoting.Channels/CrossAppDomainChannel.cs
@@ -244,11 +244,20 @@ namespace System.Runtime.Remoting.Channels
return retMessage;
}
- public virtual IMessageCtrl AsyncProcessMessage(IMessage reqMsg, IMessageSink replySink)
+ public virtual IMessageCtrl AsyncProcessMessage (IMessage reqMsg, IMessageSink replySink)
{
- throw new NotSupportedException();
+ AsyncRequest req = new AsyncRequest (reqMsg, replySink);
+ ThreadPool.QueueUserWorkItem (new WaitCallback (SendAsyncMessage), req);
+ return null;
}
+ public void SendAsyncMessage (object data)
+ {
+ AsyncRequest req = (AsyncRequest)data;
+ IMessage response = SyncProcessMessage (req.MsgRequest);
+ req.ReplySink.SyncProcessMessage (response);
+ }
+
public IMessageSink NextSink { get { return null; } }
}
@@ -302,6 +311,18 @@ namespace System.Runtime.Remoting.Channels
return serializer.Deserialize (mem);
}
+ }
+
+ internal class AsyncRequest
+ {
+ internal IMessageSink ReplySink;
+ internal IMessage MsgRequest;
+
+ public AsyncRequest (IMessage msgRequest, IMessageSink replySink)
+ {
+ ReplySink = replySink;
+ MsgRequest = msgRequest;
+ }
}
}
diff --git a/mcs/class/corlib/System.Runtime.Remoting.Channels/ServerDispatchSink.cs b/mcs/class/corlib/System.Runtime.Remoting.Channels/ServerDispatchSink.cs
index 26be2551474..fd83a6f1e5a 100644
--- a/mcs/class/corlib/System.Runtime.Remoting.Channels/ServerDispatchSink.cs
+++ b/mcs/class/corlib/System.Runtime.Remoting.Channels/ServerDispatchSink.cs
@@ -30,18 +30,17 @@ namespace System.Runtime.Remoting.Channels {
}
}
- [MonoTODO]
public void AsyncProcessResponse (IServerResponseChannelSinkStack sinkStack, object state,
IMessage msg, ITransportHeaders headers, Stream stream)
{
- throw new NotImplementedException ();
+ // Never called (this sink does not push itself into the sink stack)
+ throw new NotSupportedException ();
}
- [MonoTODO]
public Stream GetResponseStream (IServerResponseChannelSinkStack sinkStack, object state,
IMessage msg, ITransportHeaders headers)
{
- throw new NotImplementedException ();
+ return null;
}
public ServerProcessing ProcessMessage (IServerChannelSinkStack sinkStack,
diff --git a/mcs/class/corlib/System.Runtime.Remoting.Channels/ServerDispatchSinkProvider.cs b/mcs/class/corlib/System.Runtime.Remoting.Channels/ServerDispatchSinkProvider.cs
index 57ccdb460cc..c1824e919d3 100644
--- a/mcs/class/corlib/System.Runtime.Remoting.Channels/ServerDispatchSinkProvider.cs
+++ b/mcs/class/corlib/System.Runtime.Remoting.Channels/ServerDispatchSinkProvider.cs
@@ -17,11 +17,8 @@ namespace System.Runtime.Remoting.Channels
{
}
- [MonoTODO]
- public ServerDispatchSinkProvider (IDictionary properties,
- ICollection providerData)
- {
- throw new NotImplementedException ();
+ public ServerDispatchSinkProvider (IDictionary properties, ICollection providerData)
+ {
}
public IServerChannelSinkProvider Next
diff --git a/mcs/class/corlib/System.Runtime.Remoting.Channels/SinkProviderData.cs b/mcs/class/corlib/System.Runtime.Remoting.Channels/SinkProviderData.cs
index 02882ef4c4a..92769fa2053 100644
--- a/mcs/class/corlib/System.Runtime.Remoting.Channels/SinkProviderData.cs
+++ b/mcs/class/corlib/System.Runtime.Remoting.Channels/SinkProviderData.cs
@@ -2,6 +2,7 @@
// System.Runtime.Remoting.Channels.SinkProviderData.cs
//
// Author: Rodrigo Moya (rodrigo@ximian.com)
+// Lluis Sanchez Gual (lluis@ximian.com)
//
// 2002 (C) Copyright, Ximian, Inc.
//
@@ -12,18 +13,21 @@ namespace System.Runtime.Remoting.Channels
{
public class SinkProviderData
{
- private string sinkName;
+ string sinkName;
+ ArrayList children;
+ Hashtable properties;
public SinkProviderData (string name)
{
sinkName = name;
+ children = new ArrayList ();
+ properties = new Hashtable ();
}
public IList Children
{
- [MonoTODO]
get {
- throw new NotImplementedException ();
+ return children;
}
}
@@ -36,9 +40,8 @@ namespace System.Runtime.Remoting.Channels
public IDictionary Properties
{
- [MonoTODO]
get {
- throw new NotImplementedException ();
+ return properties;
}
}
}
diff --git a/mcs/class/corlib/System.Runtime.Remoting.Contexts/ChangeLog b/mcs/class/corlib/System.Runtime.Remoting.Contexts/ChangeLog
index 3b367402df9..d24f3909b2e 100644
--- a/mcs/class/corlib/System.Runtime.Remoting.Contexts/ChangeLog
+++ b/mcs/class/corlib/System.Runtime.Remoting.Contexts/ChangeLog
@@ -1,3 +1,22 @@
+2003-11-21 Lluis Sanchez Gual <lluis@ximian.com>
+
+ * Context.cs: Added internal static_data field.
+
+2003-11-19 Lluis Sanchez Gual <lluis@ximian.com>
+
+ * Context.cs: Implemented several missing methods and properties:
+ ContextProperties, DoCallBack, AllocateDataSlot, AllocateNamedDataSlot,
+ FreeNamedDataSlot, GetData, GetNamedDataSlot, SetData.
+ * SynchronizationAttribute.cs: Fixed check for current context.
+
+2003-11-18 Lluis Sanchez Gual <lluis@ximian.com>
+
+ * SynchronizationAttribute.cs: Implemented.
+
+2003-11-14 Miguel de Icaza <miguel@ximian.com>
+
+ * ContextProperty.cs: Add implementaion bits.
+
2003-07-28 Duncan Mak <duncan@ximian.com>
* ContextAttribute.cs: Removed constructor.
diff --git a/mcs/class/corlib/System.Runtime.Remoting.Contexts/Context.cs b/mcs/class/corlib/System.Runtime.Remoting.Contexts/Context.cs
index 1744dd64538..3292428a398 100644
--- a/mcs/class/corlib/System.Runtime.Remoting.Contexts/Context.cs
+++ b/mcs/class/corlib/System.Runtime.Remoting.Contexts/Context.cs
@@ -21,9 +21,10 @@ namespace System.Runtime.Remoting.Contexts {
public class Context
{
- public int domain_id;
+ int domain_id;
int context_id;
int process_id;
+ IntPtr static_data;
// Default server context sink chain
static IMessageSink default_server_context_sink;
@@ -34,12 +35,16 @@ namespace System.Runtime.Remoting.Contexts {
// The sink chain that has to be used by all calls exiting the context
IMessageSink client_context_sink_chain = null;
+ Hashtable datastore;
ArrayList context_properties;
bool frozen;
+
static int global_count;
+ static Hashtable namedSlots;
static DynamicPropertyCollection global_dynamic_properties;
DynamicPropertyCollection context_dynamic_properties;
+ ContextCollbackObject callback_object = null;
public Context ()
{
@@ -59,6 +64,15 @@ namespace System.Runtime.Remoting.Contexts {
}
}
+ public IContextProperty[] ContextProperties
+ {
+ get
+ {
+ if (context_properties == null) return new IContextProperty[0];
+ else return (IContextProperty[]) context_properties.ToArray (typeof(IContextProperty[]));
+ }
+ }
+
internal bool IsDefaultContext
{
get { return context_id == 0; }
@@ -135,7 +149,6 @@ namespace System.Runtime.Remoting.Contexts {
}
}
-
public virtual IContextProperty GetProperty (string name)
{
if (context_properties == null)
@@ -278,6 +291,99 @@ namespace System.Runtime.Remoting.Contexts {
return newContext;
}
+
+ public void DoCallBack (CrossContextDelegate deleg)
+ {
+ if (callback_object == null)
+ {
+ lock (this)
+ {
+ if (callback_object == null) {
+ Context oldContext = Context.SwitchToContext (this);
+ callback_object = new ContextCollbackObject ();
+ Context.SwitchToContext (oldContext);
+ }
+ }
+ }
+
+ callback_object.DoCallBack (deleg);
+ }
+
+ public static LocalDataStoreSlot AllocateDataSlot ()
+ {
+ return new LocalDataStoreSlot ();
+ }
+
+ public static LocalDataStoreSlot AllocateNamedDataSlot (string name)
+ {
+ if (namedSlots == null)
+ {
+ lock (typeof(Context))
+ {
+ if (namedSlots == null)
+ namedSlots = new Hashtable ();
+ }
+ }
+
+ lock (namedSlots.SyncRoot)
+ {
+ LocalDataStoreSlot slot = new LocalDataStoreSlot ();
+ namedSlots.Add (name, slot);
+ return slot;
+ }
+ }
+
+ public static void FreeNamedDataSlot (string name)
+ {
+ if (namedSlots == null) return;
+
+ lock (namedSlots.SyncRoot)
+ {
+ namedSlots.Remove (name);
+ }
+ }
+
+ public static object GetData (LocalDataStoreSlot slot)
+ {
+ Context ctx = Thread.CurrentContext;
+ if (ctx.datastore == null) return null;
+
+ lock (ctx.datastore.SyncRoot)
+ {
+ return ctx.datastore [slot];
+ }
+ }
+
+ public static LocalDataStoreSlot GetNamedDataSlot (string name)
+ {
+ if (namedSlots == null)
+ return AllocateNamedDataSlot (name);
+
+ lock (namedSlots)
+ {
+ LocalDataStoreSlot slot = namedSlots [name] as LocalDataStoreSlot;
+ if (slot == null) return AllocateNamedDataSlot (name);
+ else return slot;
+ }
+ }
+
+ public static void SetData (LocalDataStoreSlot slot, object data)
+ {
+ Context ctx = Thread.CurrentContext;
+ if (ctx.datastore == null)
+ {
+ lock (ctx)
+ {
+ if (ctx.datastore == null)
+ ctx.datastore = new Hashtable ();
+ }
+ }
+
+ lock (ctx.datastore.SyncRoot)
+ {
+ ctx.datastore [slot] = data;
+ }
+ }
}
class DynamicPropertyCollection
@@ -352,4 +458,11 @@ namespace System.Runtime.Remoting.Contexts {
return -1;
}
}
+
+ class ContextCollbackObject: ContextBoundObject
+ {
+ public void DoCallBack (CrossContextDelegate deleg)
+ {
+ }
+ }
}
diff --git a/mcs/class/corlib/System.Runtime.Remoting.Contexts/ContextProperty.cs b/mcs/class/corlib/System.Runtime.Remoting.Contexts/ContextProperty.cs
index a053cef5b45..e8702767820 100644
--- a/mcs/class/corlib/System.Runtime.Remoting.Contexts/ContextProperty.cs
+++ b/mcs/class/corlib/System.Runtime.Remoting.Contexts/ContextProperty.cs
@@ -12,14 +12,21 @@ namespace System.Runtime.Remoting.Contexts {
public class ContextProperty
{
- [MonoTODO]
+ string name;
+ object prop;
+
+ private ContextProperty (string name, object prop)
+ {
+ this.name = name;
+ this.prop = prop;
+ }
+
public virtual string Name {
- get { throw new NotImplementedException (); }
+ get { return name; }
}
- [MonoTODO]
public virtual object Property {
- get { throw new NotImplementedException (); }
+ get { return prop; }
}
}
}
diff --git a/mcs/class/corlib/System.Runtime.Remoting.Contexts/SynchronizationAttribute.cs b/mcs/class/corlib/System.Runtime.Remoting.Contexts/SynchronizationAttribute.cs
new file mode 100644
index 00000000000..d1f47199bbc
--- /dev/null
+++ b/mcs/class/corlib/System.Runtime.Remoting.Contexts/SynchronizationAttribute.cs
@@ -0,0 +1,284 @@
+//
+// System.Runtime.Remoting.Contexts.SynchronizationAttribute.cs
+//
+// Author:
+// Lluis Sanchez Gual (lluis@ximian.com)
+//
+// (C) Novell, Inc. http://www.ximian.com
+//
+
+using System.Threading;
+using System.Runtime.Remoting.Messaging;
+using System.Runtime.Remoting.Activation;
+
+namespace System.Runtime.Remoting.Contexts
+{
+ [AttributeUsage(AttributeTargets.Class)]
+ [Serializable]
+ public class SynchronizationAttribute: ContextAttribute, IContributeClientContextSink, IContributeServerContextSink
+ {
+ public const int NOT_SUPPORTED = 1;
+ public const int SUPPORTED = 2;
+ public const int REQUIRED = 4;
+ public const int REQUIRES_NEW = 8;
+
+ bool _isReentrant;
+ bool _locked;
+ int _flag;
+ int _lockCount = 0;
+
+ Mutex _mutex = new Mutex ();
+
+ public SynchronizationAttribute ()
+ : this (REQUIRES_NEW, false)
+ {
+ }
+
+ public SynchronizationAttribute (bool reEntrant)
+ : this (REQUIRES_NEW, reEntrant)
+ {
+ }
+
+ public SynchronizationAttribute (int flag)
+ : this (flag, false)
+ {
+ }
+
+ public SynchronizationAttribute (int flag, bool reEntrant)
+ : base ("Synchronization")
+ {
+ if (flag != NOT_SUPPORTED && flag != REQUIRED && flag != REQUIRES_NEW && flag != SUPPORTED)
+ throw new ArgumentException ("flag");
+
+ _isReentrant = reEntrant;
+ _flag = flag;
+ }
+
+ public virtual bool IsReEntrant
+ {
+ get { return _isReentrant; }
+ }
+
+ public virtual bool Locked
+ {
+ get
+ {
+ return _locked;
+ }
+
+ set
+ {
+ if (value)
+ {
+ _mutex.WaitOne ();
+ lock (this)
+ {
+ if (_lockCount > 0)
+ ReleaseLock (); // Thread already had the lock
+ else
+ _lockCount++;
+ }
+ }
+ else
+ {
+ lock (this)
+ {
+ while (_lockCount > 0)
+ {
+ _lockCount--;
+ _mutex.ReleaseMutex ();
+ }
+ }
+ }
+ }
+ }
+
+ internal void AcquireLock ()
+ {
+ _mutex.WaitOne ();
+
+ lock (this)
+ {
+ _lockCount++;
+ }
+ }
+
+ internal void ReleaseLock ()
+ {
+ lock (this)
+ {
+ if (_lockCount > 0) {
+ _lockCount--;
+ _mutex.ReleaseMutex ();
+ }
+ }
+ }
+
+ public override void GetPropertiesForNewContext (IConstructionCallMessage ctorMsg)
+ {
+ if (_flag != NOT_SUPPORTED)
+ ctorMsg.ContextProperties.Add (this);
+ }
+
+ public virtual IMessageSink GetClientContextSink (IMessageSink nextSink)
+ {
+ return new SynchronizedClientContextSink (nextSink, this);
+ }
+
+ public virtual IMessageSink GetServerContextSink (IMessageSink nextSink)
+ {
+ return new SynchronizedServerContextSink (nextSink, this);
+ }
+
+ public override bool IsContextOK (Context ctx, IConstructionCallMessage msg)
+ {
+ SynchronizationAttribute prop = ctx.GetProperty ("Synchronization") as SynchronizationAttribute;
+ switch (_flag)
+ {
+ case NOT_SUPPORTED: return (prop == null);
+ case REQUIRED: return (prop != null);
+ case REQUIRES_NEW: return false;
+ case SUPPORTED: return true;
+ }
+ return false;
+ }
+
+ internal static void ExitContext ()
+ {
+ if (Thread.CurrentContext.IsDefaultContext) return;
+ SynchronizationAttribute prop = Thread.CurrentContext.GetProperty ("Synchronization") as SynchronizationAttribute;
+ if (prop == null) return;
+ prop.Locked = false;
+ }
+
+ internal static void EnterContext ()
+ {
+ if (Thread.CurrentContext.IsDefaultContext) return;
+ SynchronizationAttribute prop = Thread.CurrentContext.GetProperty ("Synchronization") as SynchronizationAttribute;
+ if (prop == null) return;
+ prop.Locked = true;
+ }
+ }
+
+ internal class SynchronizedClientContextSink: IMessageSink
+ {
+ IMessageSink _next;
+ SynchronizationAttribute _att;
+
+ public SynchronizedClientContextSink (IMessageSink next, SynchronizationAttribute att)
+ {
+ _att = att;
+ _next = next;
+ }
+
+ public IMessageSink NextSink
+ {
+ get { return _next; }
+ }
+
+ public IMessageCtrl AsyncProcessMessage (IMessage msg, IMessageSink replySink)
+ {
+ if (_att.IsReEntrant)
+ {
+ _att.ReleaseLock(); // Unlock when leaving the context
+ replySink = new SynchronizedContextReplySink (replySink, _att, true);
+ }
+ return _next.AsyncProcessMessage (msg, replySink);
+ }
+
+ public IMessage SyncProcessMessage (IMessage msg)
+ {
+ if (_att.IsReEntrant)
+ _att.ReleaseLock (); // Unlock when leaving the context
+
+ try
+ {
+ return _next.SyncProcessMessage (msg);
+ }
+ finally
+ {
+ if (_att.IsReEntrant)
+ _att.AcquireLock ();
+ }
+ }
+ }
+
+ internal class SynchronizedServerContextSink: IMessageSink
+ {
+ IMessageSink _next;
+ SynchronizationAttribute _att;
+
+ public SynchronizedServerContextSink (IMessageSink next, SynchronizationAttribute att)
+ {
+ _att = att;
+ _next = next;
+ }
+
+ public IMessageSink NextSink
+ {
+ get { return _next; }
+ }
+
+ public IMessageCtrl AsyncProcessMessage (IMessage msg, IMessageSink replySink)
+ {
+ _att.AcquireLock ();
+ replySink = new SynchronizedContextReplySink (replySink, _att, false);
+ return _next.AsyncProcessMessage (msg, replySink);
+ }
+
+ public IMessage SyncProcessMessage (IMessage msg)
+ {
+ _att.AcquireLock ();
+ try
+ {
+ return _next.SyncProcessMessage (msg);
+ }
+ finally
+ {
+ _att.ReleaseLock ();
+ }
+ }
+ }
+
+ internal class SynchronizedContextReplySink: IMessageSink
+ {
+ IMessageSink _next;
+ bool _newLock;
+ SynchronizationAttribute _att;
+
+ public SynchronizedContextReplySink (IMessageSink next, SynchronizationAttribute att, bool newLock)
+ {
+ _newLock = newLock;
+ _next = next;
+ _att = att;
+ }
+
+ public IMessageSink NextSink
+ {
+ get { return _next; }
+ }
+
+ public IMessageCtrl AsyncProcessMessage (IMessage msg, IMessageSink replySink)
+ {
+ // Never called
+ throw new NotSupportedException ();
+ }
+
+ public IMessage SyncProcessMessage (IMessage msg)
+ {
+ if (_newLock) _att.AcquireLock ();
+ else _att.ReleaseLock ();
+
+ try
+ {
+ return _next.SyncProcessMessage (msg);
+ }
+ finally
+ {
+ if (_newLock)
+ _att.ReleaseLock ();
+ }
+ }
+ }
+}
+
diff --git a/mcs/class/corlib/System.Runtime.Remoting.Messaging/ArgInfo.cs b/mcs/class/corlib/System.Runtime.Remoting.Messaging/ArgInfo.cs
index 57612769fe0..bb07e2d1363 100644
--- a/mcs/class/corlib/System.Runtime.Remoting.Messaging/ArgInfo.cs
+++ b/mcs/class/corlib/System.Runtime.Remoting.Messaging/ArgInfo.cs
@@ -11,9 +11,9 @@ using System.Reflection;
namespace System.Runtime.Remoting.Messaging
{
- public enum ArgInfoType : byte { In, Out };
+ internal enum ArgInfoType : byte { In, Out };
- public class ArgInfo
+ internal class ArgInfo
{
int[] _paramMap;
int _inoutArgCount;
diff --git a/mcs/class/corlib/System.Runtime.Remoting.Messaging/AsyncResult.cs b/mcs/class/corlib/System.Runtime.Remoting.Messaging/AsyncResult.cs
index 581c7d52394..2181431b264 100644
--- a/mcs/class/corlib/System.Runtime.Remoting.Messaging/AsyncResult.cs
+++ b/mcs/class/corlib/System.Runtime.Remoting.Messaging/AsyncResult.cs
@@ -29,6 +29,10 @@ public class AsyncResult : IAsyncResult, IMessageSink {
IMessageCtrl message_ctrl;
IMessage reply_message;
+ internal AsyncResult ()
+ {
+ }
+
public virtual object AsyncState
{
get {
diff --git a/mcs/class/corlib/System.Runtime.Remoting.Messaging/CADMessages.cs b/mcs/class/corlib/System.Runtime.Remoting.Messaging/CADMessages.cs
index 027b058c59c..785893d256a 100755
--- a/mcs/class/corlib/System.Runtime.Remoting.Messaging/CADMessages.cs
+++ b/mcs/class/corlib/System.Runtime.Remoting.Messaging/CADMessages.cs
@@ -230,6 +230,26 @@ namespace System.Runtime.Remoting.Messaging {
return unmarshalledArgs;
}
+
+ protected void SaveLogicalCallContext (IMethodMessage msg, ref ArrayList serializeList)
+ {
+ if (msg.LogicalCallContext != null && msg.LogicalCallContext.HasInfo)
+ {
+ if (serializeList == null)
+ serializeList = new ArrayList();
+
+ _callContext = new CADArgHolder (serializeList.Count);
+ serializeList.Add (msg.LogicalCallContext);
+ }
+ }
+
+ internal LogicalCallContext GetLogicalCallContext (ArrayList args)
+ {
+ if (null == _callContext)
+ return null;
+
+ return (LogicalCallContext) args [_callContext.index];
+ }
}
// Used when passing a IMethodCallMessage between appdomains
@@ -287,7 +307,10 @@ namespace System.Runtime.Remoting.Messaging {
serializeList.Add(callMsg.MethodSignature);
}
- // todo: save callcontext
+ // Save callcontext
+ SaveLogicalCallContext (callMsg, ref serializeList);
+
+ // Serialize message data if needed
if (null != serializeList) {
MemoryStream stm = CADSerializer.SerializeObject (serializeList.ToArray());
@@ -354,7 +377,8 @@ namespace System.Runtime.Remoting.Messaging {
serializeList.Add(retMsg.Exception);
}
- // todo: save callcontext
+ // Save callcontext
+ SaveLogicalCallContext (retMsg, ref serializeList);
if (null != serializeList) {
MemoryStream stm = CADSerializer.SerializeObject (serializeList.ToArray());
diff --git a/mcs/class/corlib/System.Runtime.Remoting.Messaging/CallContext.cs b/mcs/class/corlib/System.Runtime.Remoting.Messaging/CallContext.cs
index 26c2b04ef0a..d253466a266 100644
--- a/mcs/class/corlib/System.Runtime.Remoting.Messaging/CallContext.cs
+++ b/mcs/class/corlib/System.Runtime.Remoting.Messaging/CallContext.cs
@@ -23,6 +23,10 @@ namespace System.Runtime.Remoting.Messaging
{
internal const string HeadersKey = "__Headers";
internal const string ContextKey = "__CallContext";
+
+ private CallContext ()
+ {
+ }
// public methods
public static void FreeNamedDataSlot (string name)
diff --git a/mcs/class/corlib/System.Runtime.Remoting.Messaging/ChangeLog b/mcs/class/corlib/System.Runtime.Remoting.Messaging/ChangeLog
index 9938cc17a7a..e0da7e3a20a 100644
--- a/mcs/class/corlib/System.Runtime.Remoting.Messaging/ChangeLog
+++ b/mcs/class/corlib/System.Runtime.Remoting.Messaging/ChangeLog
@@ -1,3 +1,46 @@
+2003-11-28 Dick Porter <dick@ximian.com>
+
+ * MethodCall.cs: Use the char form of IndexOf, so that the
+ comparison is done with the Invariant culture.
+
+2003-11-26 Lluis Sanchez Gual <lluis@ximian.com>
+
+ * MethodCall.cs, MethodResponse.cs, ReturnMessage.cs: Implemented
+ HasVarArgs property.
+
+2003-11-25 Lluis Sanchez Gual <lluis@ximian.com>
+
+ * AsyncResult.cs, CallContext.cs: Added private constructor.
+ * ReturnMessage.cs: Added parameter array length check.
+
+2003-11-18 Lluis Sanchez Gual <lluis@ximian.com>
+
+ * ArgInfo.cs, ClientContextTerminatorSink.cs, ErrorMessage.cs, MethodCall.cs,
+ MethodResponse.cs, MonoMethodMessage.cs, ServerContextTerminatorSink.cs,
+ StackBuilderSink.cs: Fixed class visibility.
+ * CADMessages.cs: Added null reference check in SaveLogicalCallContext.
+ * ISerializationRootObject.cs: Added.
+
+2003-11-17 Lluis Sanchez Gual <lluis@ximian.com>
+
+ * StackBuilderSink.cs: Implemented AsyncProcessMessage().
+
+2003-11-16 Lluis Sanchez Gual <lluis@ximian.com>
+
+ * CADMessages.cs: Added methods for setting and getting the logical call
+ context.
+ * ConstructionCall.cs: Fixed signature of some methods.
+ * ConstructionResponse.cs: Fixed signature of constructor and added missing
+ property.
+ * LogicalCallContext.cs: Removed TODO.
+ * MethodCall.cs, MethodResponse.cs: Added support for LogicalCallContext in
+ consturctor.
+ * MethodReturnMessageWrapper.cs: Removed some unneded methods.
+
+2003-11-11 Lluis Sanchez Gual <lluis@ximian.com>
+
+ * ConstructionCall.cs, ReturnMessage.cs: minor fixes.
+
2003-10-23 Lluis Sanchez Gual <lluis@ximian.com>
* MethodCall.cs: In the constructor that takes a CADMethodCallMessage
diff --git a/mcs/class/corlib/System.Runtime.Remoting.Messaging/ClientContextTerminatorSink.cs b/mcs/class/corlib/System.Runtime.Remoting.Messaging/ClientContextTerminatorSink.cs
index b19c6a4d9d2..583d9d604a3 100644
--- a/mcs/class/corlib/System.Runtime.Remoting.Messaging/ClientContextTerminatorSink.cs
+++ b/mcs/class/corlib/System.Runtime.Remoting.Messaging/ClientContextTerminatorSink.cs
@@ -13,7 +13,7 @@ using System.Runtime.Remoting.Contexts;
namespace System.Runtime.Remoting.Messaging
{
- public class ClientContextTerminatorSink: IMessageSink
+ internal class ClientContextTerminatorSink: IMessageSink
{
Context _context;
diff --git a/mcs/class/corlib/System.Runtime.Remoting.Messaging/ConstructionCall.cs b/mcs/class/corlib/System.Runtime.Remoting.Messaging/ConstructionCall.cs
index 762beb02fde..9e902833720 100644
--- a/mcs/class/corlib/System.Runtime.Remoting.Messaging/ConstructionCall.cs
+++ b/mcs/class/corlib/System.Runtime.Remoting.Messaging/ConstructionCall.cs
@@ -28,11 +28,10 @@ namespace System.Runtime.Remoting.Messaging
public ConstructionCall(IMessage msg): base (msg)
{
_activationTypeName = TypeName;
- _activationAttributes = null; // FIXME: put something here
_isContextOk = true;
}
- public ConstructionCall (Type type)
+ internal ConstructionCall (Type type)
{
_activationType = type;
_activationTypeName = type.AssemblyQualifiedName;
@@ -125,5 +124,10 @@ namespace System.Runtime.Remoting.Messaging
info.AddValue ("__ContextProperties", props);
info.AddValue ("__ActivationTypeName", _activationTypeName);
}
+
+ public override IDictionary Properties
+ {
+ get { return base.Properties; }
+ }
}
}
diff --git a/mcs/class/corlib/System.Runtime.Remoting.Messaging/ConstructionResponse.cs b/mcs/class/corlib/System.Runtime.Remoting.Messaging/ConstructionResponse.cs
index 9a4a8eb5845..68b06d13a62 100644
--- a/mcs/class/corlib/System.Runtime.Remoting.Messaging/ConstructionResponse.cs
+++ b/mcs/class/corlib/System.Runtime.Remoting.Messaging/ConstructionResponse.cs
@@ -7,6 +7,7 @@
//
using System;
+using System.Collections;
using System.Runtime.Remoting.Activation;
using System.Runtime.Serialization;
@@ -15,13 +16,23 @@ namespace System.Runtime.Remoting.Messaging
[Serializable] [CLSCompliant (false)]
public class ConstructionResponse: MethodResponse, IConstructionReturnMessage
{
- public ConstructionResponse(object resultObject, LogicalCallContext callCtx, IMethodCallMessage msg)
+ public ConstructionResponse (Header[] headers, IMethodCallMessage mcm)
+ : base (headers, mcm)
+ {
+ }
+
+ internal ConstructionResponse(object resultObject, LogicalCallContext callCtx, IMethodCallMessage msg)
: base (resultObject, null, callCtx, msg)
{
}
internal ConstructionResponse (SerializationInfo info, StreamingContext context): base (info, context)
{
- }
+ }
+
+ public override IDictionary Properties
+ {
+ get { return base.Properties; }
+ }
}
}
diff --git a/mcs/class/corlib/System.Runtime.Remoting.Messaging/ErrorMessage.cs b/mcs/class/corlib/System.Runtime.Remoting.Messaging/ErrorMessage.cs
index 4bb81b6aff0..a065232bf75 100755
--- a/mcs/class/corlib/System.Runtime.Remoting.Messaging/ErrorMessage.cs
+++ b/mcs/class/corlib/System.Runtime.Remoting.Messaging/ErrorMessage.cs
@@ -15,7 +15,7 @@ namespace System.Runtime.Remoting.Messaging {
// simple message to avoid serialization of crap data
[Serializable]
- public class ErrorMessage : IMethodCallMessage
+ internal class ErrorMessage : IMethodCallMessage
{
string _uri = "Exception";
diff --git a/mcs/class/corlib/System.Runtime.Remoting.Messaging/ISerializationRootObject.cs b/mcs/class/corlib/System.Runtime.Remoting.Messaging/ISerializationRootObject.cs
new file mode 100644
index 00000000000..6624486da7e
--- /dev/null
+++ b/mcs/class/corlib/System.Runtime.Remoting.Messaging/ISerializationRootObject.cs
@@ -0,0 +1,19 @@
+//
+// System.Runtime.Remoting.Messaging.ISerializationRootObject.cs
+//
+// Author: Lluis Sanchez Gual (lluis@ximian.com)
+//
+// 2003 (C) Copyright, Novell, Inc.
+//
+
+using System;
+using System.Runtime.Remoting;
+using System.Runtime.Serialization;
+
+namespace System.Runtime.Remoting.Messaging
+{
+ internal interface ISerializationRootObject
+ {
+ void RootSetObjectData (SerializationInfo info, StreamingContext context);
+ }
+}
diff --git a/mcs/class/corlib/System.Runtime.Remoting.Messaging/LogicalCallContext.cs b/mcs/class/corlib/System.Runtime.Remoting.Messaging/LogicalCallContext.cs
index 686764f781c..0580c421cc0 100644
--- a/mcs/class/corlib/System.Runtime.Remoting.Messaging/LogicalCallContext.cs
+++ b/mcs/class/corlib/System.Runtime.Remoting.Messaging/LogicalCallContext.cs
@@ -11,9 +11,8 @@
using System.Collections;
using System.Runtime.Serialization;
-namespace System.Runtime.Remoting.Messaging {
-
- [MonoTODO]
+namespace System.Runtime.Remoting.Messaging
+{
[Serializable]
public sealed class LogicalCallContext : ISerializable, ICloneable
{
diff --git a/mcs/class/corlib/System.Runtime.Remoting.Messaging/MethodCall.cs b/mcs/class/corlib/System.Runtime.Remoting.Messaging/MethodCall.cs
index c03df7267d8..eea28a76435 100644
--- a/mcs/class/corlib/System.Runtime.Remoting.Messaging/MethodCall.cs
+++ b/mcs/class/corlib/System.Runtime.Remoting.Messaging/MethodCall.cs
@@ -15,7 +15,7 @@ using System.Runtime.Serialization;
namespace System.Runtime.Remoting.Messaging {
[Serializable] [CLSCompliant (false)]
- public class MethodCall : IMethodCallMessage, IMethodMessage, IMessage, ISerializable, IInternalMessage
+ public class MethodCall : IMethodCallMessage, IMethodMessage, IMessage, ISerializable, IInternalMessage, ISerializationRootObject
{
string _uri;
string _typeName;
@@ -63,6 +63,8 @@ namespace System.Runtime.Remoting.Messaging {
_args = msg.GetArgs (args);
_methodSignature = (Type []) msg.GetMethodSignature (args);
+ _callContext = msg.GetLogicalCallContext (args);
+ if (_callContext == null) _callContext = new LogicalCallContext ();
ResolveMethod ();
Init();
@@ -149,9 +151,8 @@ namespace System.Runtime.Remoting.Messaging {
get { return _args; }
}
- [MonoTODO]
public bool HasVarArgs {
- get { throw new NotImplementedException (); }
+ get { return (MethodBase.CallingConvention | CallingConventions.VarArgs) != 0; }
}
public int InArgCount
@@ -279,9 +280,9 @@ namespace System.Runtime.Remoting.Messaging {
_methodBase = RemotingServices.GetMethodBaseFromMethodMessage (this);
}
- public bool CanCastTo (string clientType, Type serverType)
+ bool CanCastTo (string clientType, Type serverType)
{
- int i = clientType.IndexOf(",");
+ int i = clientType.IndexOf(',');
if (i != -1) clientType = clientType.Substring (0,i).Trim();
if (clientType == serverType.FullName) return true;
diff --git a/mcs/class/corlib/System.Runtime.Remoting.Messaging/MethodResponse.cs b/mcs/class/corlib/System.Runtime.Remoting.Messaging/MethodResponse.cs
index 14c46a646b2..ec4cda59064 100644
--- a/mcs/class/corlib/System.Runtime.Remoting.Messaging/MethodResponse.cs
+++ b/mcs/class/corlib/System.Runtime.Remoting.Messaging/MethodResponse.cs
@@ -16,7 +16,7 @@ using System.Runtime.Serialization;
namespace System.Runtime.Remoting.Messaging {
[Serializable] [CLSCompliant (false)]
- public class MethodResponse : IMethodReturnMessage, ISerializable, IInternalMessage
+ public class MethodResponse : IMethodReturnMessage, ISerializable, IInternalMessage, ISerializationRootObject
{
string _methodName;
string _uri;
@@ -94,6 +94,9 @@ namespace System.Runtime.Remoting.Messaging {
_returnValue = retmsg.GetReturnValue (args);
_outArgs = retmsg.GetArgs (args);
+ _callContext = retmsg.GetLogicalCallContext (args);
+ if (_callContext == null) _callContext = new LogicalCallContext ();
+
if (retmsg.PropertiesCount > 0)
CADMessageBase.UnmarshalProperties (Properties, retmsg.PropertiesCount, args);
}
@@ -143,7 +146,7 @@ namespace System.Runtime.Remoting.Messaging {
public bool HasVarArgs {
get {
- return false; // TODO: implement var args
+ return (MethodBase.CallingConvention | CallingConventions.VarArgs) != 0;
}
}
diff --git a/mcs/class/corlib/System.Runtime.Remoting.Messaging/MethodReturnMessageWrapper.cs b/mcs/class/corlib/System.Runtime.Remoting.Messaging/MethodReturnMessageWrapper.cs
index 7abdc1a4b1e..0f00089f586 100644
--- a/mcs/class/corlib/System.Runtime.Remoting.Messaging/MethodReturnMessageWrapper.cs
+++ b/mcs/class/corlib/System.Runtime.Remoting.Messaging/MethodReturnMessageWrapper.cs
@@ -106,12 +106,6 @@ namespace System.Runtime.Remoting.Messaging {
return ((IMethodReturnMessage)WrappedMessage).GetArgName(index);
}
- [MonoTODO]
- public void GetObjectData (SerializationInfo info, StreamingContext context)
- {
- throw new NotImplementedException ();
- }
-
public virtual object GetOutArg (int argNum)
{
return _args [_outArgInfo.GetInOutArgIndex (argNum)];
@@ -122,18 +116,6 @@ namespace System.Runtime.Remoting.Messaging {
return _outArgInfo.GetInOutArgName(index);
}
- [MonoTODO]
- public virtual object HeaderHandler (Header[] h)
- {
- throw new NotImplementedException ();
- }
-
- [MonoTODO]
- public void RootSetObjectData (SerializationInfo info, StreamingContext context)
- {
- throw new NotImplementedException ();
- }
-
class DictionaryWrapper : MethodReturnDictionary
{
IDictionary _wrappedDictionary;
diff --git a/mcs/class/corlib/System.Runtime.Remoting.Messaging/MonoMethodMessage.cs b/mcs/class/corlib/System.Runtime.Remoting.Messaging/MonoMethodMessage.cs
index 57ebd2c274b..5cc718de1da 100644
--- a/mcs/class/corlib/System.Runtime.Remoting.Messaging/MonoMethodMessage.cs
+++ b/mcs/class/corlib/System.Runtime.Remoting.Messaging/MonoMethodMessage.cs
@@ -16,7 +16,7 @@ using System.Runtime.CompilerServices;
namespace System.Runtime.Remoting.Messaging {
[Serializable]
- public class MonoMethodMessage : IMethodCallMessage, IMethodReturnMessage, IInternalMessage {
+ internal class MonoMethodMessage : IMethodCallMessage, IMethodReturnMessage, IInternalMessage {
MonoMethod method;
diff --git a/mcs/class/corlib/System.Runtime.Remoting.Messaging/ReturnMessage.cs b/mcs/class/corlib/System.Runtime.Remoting.Messaging/ReturnMessage.cs
index eea0d9d1909..82cf5bb8aef 100644
--- a/mcs/class/corlib/System.Runtime.Remoting.Messaging/ReturnMessage.cs
+++ b/mcs/class/corlib/System.Runtime.Remoting.Messaging/ReturnMessage.cs
@@ -36,7 +36,7 @@ namespace System.Runtime.Remoting.Messaging {
int outArgCount, LogicalCallContext callCtx,
IMethodCallMessage request)
{
- // fixme: why do we need outArgCount?
+ // outArgCount tells how many values of outArgs are valid
_returnValue = returnValue;
_args = outArgs;
@@ -78,7 +78,7 @@ namespace System.Runtime.Remoting.Messaging {
public bool HasVarArgs {
get {
- return false; //todo: complete
+ return (MethodBase.CallingConvention | CallingConventions.VarArgs) != 0;
}
}
@@ -148,6 +148,7 @@ namespace System.Runtime.Remoting.Messaging {
public int OutArgCount {
get {
+ if (_args.Length == 0) return 0;
if (_inArgInfo == null) _inArgInfo = new ArgInfo (MethodBase, ArgInfoType.Out);
return _inArgInfo.GetInOutArgCount ();
}
diff --git a/mcs/class/corlib/System.Runtime.Remoting.Messaging/ServerContextTerminatorSink.cs b/mcs/class/corlib/System.Runtime.Remoting.Messaging/ServerContextTerminatorSink.cs
index 6fed04b5ecf..11f1e36bc55 100644
--- a/mcs/class/corlib/System.Runtime.Remoting.Messaging/ServerContextTerminatorSink.cs
+++ b/mcs/class/corlib/System.Runtime.Remoting.Messaging/ServerContextTerminatorSink.cs
@@ -15,7 +15,7 @@ namespace System.Runtime.Remoting.Messaging
// The final sink of the Server Context Sink Chain.
// It forwards the message to the object's context sink chain.
- public class ServerContextTerminatorSink: IMessageSink
+ internal class ServerContextTerminatorSink: IMessageSink
{
public IMessage SyncProcessMessage (IMessage msg)
{
diff --git a/mcs/class/corlib/System.Runtime.Remoting.Messaging/StackBuilderSink.cs b/mcs/class/corlib/System.Runtime.Remoting.Messaging/StackBuilderSink.cs
index 96a4d2f2b3b..1c4afda39eb 100644
--- a/mcs/class/corlib/System.Runtime.Remoting.Messaging/StackBuilderSink.cs
+++ b/mcs/class/corlib/System.Runtime.Remoting.Messaging/StackBuilderSink.cs
@@ -7,13 +7,14 @@
//
using System;
+using System.Threading;
using System.Reflection;
namespace System.Runtime.Remoting.Messaging
{
// Sink that calls the real method of the object
- public class StackBuilderSink: IMessageSink
+ internal class StackBuilderSink: IMessageSink
{
MarshalByRefObject _target;
@@ -30,10 +31,23 @@ namespace System.Runtime.Remoting.Messaging
return RemotingServices.InternalExecuteMessage (_target, (IMethodCallMessage)msg);
}
- [MonoTODO]
public IMessageCtrl AsyncProcessMessage (IMessage msg, IMessageSink replySink)
{
- throw new NotImplementedException ();
+ object[] parms = new object[] {msg, replySink};
+ ThreadPool.QueueUserWorkItem (new WaitCallback (ExecuteAsyncMessage), parms);
+ return null;
+ }
+
+ void ExecuteAsyncMessage (object ob)
+ {
+ object[] parms = (object[]) ob;
+ IMethodCallMessage msg = (IMethodCallMessage) parms[0];
+ IMessageSink replySink = (IMessageSink)parms[1];
+
+ CheckParameters (msg);
+ IMessage res = RemotingServices.InternalExecuteMessage (_target, msg);
+
+ replySink.SyncProcessMessage (res);
}
public IMessageSink NextSink
diff --git a/mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/ChangeLog b/mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/ChangeLog
new file mode 100644
index 00000000000..74fdd5b376f
--- /dev/null
+++ b/mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/ChangeLog
@@ -0,0 +1,19 @@
+2003-11-28 Dick Porter <dick@ximian.com>
+
+ * SoapQName.cs: Use the char form of IndexOf, so that the
+ comparison is done with the Invariant culture.
+
+2003-11-17 Lluis Sanchez Gual <lluis@ximian.com>
+
+ * SoapAnyUri.cs, SoapBase64Binary.cs, SoapDate.cs, SoapDateTime.cs
+ SoapDay.cs, SoapDuration.cs, SoapEntities.cs, SoapEntity.cs,
+ SoapHexBinary.cs, SoapId.cs, SoapIdref.cs, SoapIdrefs.cs, SoapInteger.cs,
+ SoapLanguage.cs, SoapMonth.cs, SoapMonthDay.cs, SoapName.cs,
+ SoapNcName.cs, SoapNegativeInteger.cs, SoapNmtoken.cs, SoapNmtokens.cs,
+ SoapNonNegativeInteger.cs, SoapNonPositiveInteger.cs,
+ SoapNormalizedString.cs, SoapNotation.cs, SoapPositiveInteger.cs,
+ SoapQName.cs, SoapTime.cs, SoapToken.cs, SoapYear.cs, SoapYearMonth.cs:
+ Implemented
+
+ * SoapHelper.cs: Added
+
diff --git a/mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapAnyUri.cs b/mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapAnyUri.cs
index ce67d5cc618..78f56890ce5 100644
--- a/mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapAnyUri.cs
+++ b/mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapAnyUri.cs
@@ -3,54 +3,51 @@
//
// Authors:
// Martin Willemoes Hansen (mwh@sysrq.dk)
+// Lluis Sanchez Gual (lluis@ximian.com)
//
// (C) 2003 Martin Willemoes Hansen
//
+using System;
+
namespace System.Runtime.Remoting.Metadata.W3cXsd2001
{
[Serializable]
- public sealed class SoapAnyUri : ISoapXsd
+ public sealed class SoapAnyUri : ISoapXsd
{
- [MonoTODO]
- public SoapAnyUri()
+ string _value;
+
+ public SoapAnyUri ()
{
}
- public string Value {
- [MonoTODO]
- get { throw new NotImplementedException(); }
+ public SoapAnyUri (string value)
+ {
+ _value = value;
+ }
- [MonoTODO]
- set { throw new NotImplementedException(); }
+ public string Value {
+ get { return _value; }
+ set { _value = value; }
}
public static string XsdType {
- [MonoTODO]
- get { throw new NotImplementedException(); }
+ get { return "anyUri"; }
}
- [MonoTODO]
public string GetXsdType()
{
- throw new NotImplementedException();
+ return XsdType;
}
- [MonoTODO]
public static SoapAnyUri Parse (string value)
{
- throw new NotImplementedException();
+ return new SoapAnyUri (value);
}
- [MonoTODO]
public override string ToString()
{
- throw new NotImplementedException();
- }
-
- [MonoTODO]
- ~SoapAnyUri()
- {
+ return _value;
}
}
}
diff --git a/mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapBase64Binary.cs b/mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapBase64Binary.cs
index 0b61750f295..3fc805a4614 100644
--- a/mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapBase64Binary.cs
+++ b/mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapBase64Binary.cs
@@ -3,54 +3,51 @@
//
// Authors:
// Martin Willemoes Hansen (mwh@sysrq.dk)
+// Lluis Sanchez Gual (lluis@ximian.com)
//
// (C) 2003 Martin Willemoes Hansen
//
+using System;
+
namespace System.Runtime.Remoting.Metadata.W3cXsd2001
{
[Serializable]
- public sealed class SoapBase64Binary : ISoapXsd
+ public sealed class SoapBase64Binary : ISoapXsd
{
- [MonoTODO]
- public SoapBase64Binary()
+ byte[] _value;
+
+ public SoapBase64Binary ()
{
}
- public byte [] Value {
- [MonoTODO]
- get { throw new NotImplementedException(); }
+ public SoapBase64Binary (byte[] value)
+ {
+ _value = value;
+ }
- [MonoTODO]
- set { throw new NotImplementedException(); }
+ public byte [] Value {
+ get { return _value; }
+ set { _value = value; }
}
public static string XsdType {
- [MonoTODO]
- get { throw new NotImplementedException(); }
+ get { return "base64Binary"; }
}
- [MonoTODO]
public string GetXsdType()
{
- throw new NotImplementedException();
+ return XsdType;
}
- [MonoTODO]
public static SoapBase64Binary Parse (string value)
{
- throw new NotImplementedException();
+ return new SoapBase64Binary (Convert.FromBase64String (value));
}
- [MonoTODO]
public override string ToString()
{
- throw new NotImplementedException();
- }
-
- [MonoTODO]
- ~SoapBase64Binary()
- {
+ return Convert.ToBase64String (_value);
}
}
}
diff --git a/mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapDate.cs b/mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapDate.cs
index 4e19cdb9ce1..7adc0e4d82e 100644
--- a/mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapDate.cs
+++ b/mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapDate.cs
@@ -3,62 +3,82 @@
//
// Authors:
// Martin Willemoes Hansen (mwh@sysrq.dk)
+// Lluis Sanchez Gual (lluis@ximian.com)
//
// (C) 2003 Martin Willemoes Hansen
//
+using System;
+using System.Globalization;
+
namespace System.Runtime.Remoting.Metadata.W3cXsd2001
{
[Serializable]
- public sealed class SoapDate : ISoapXsd
+ public sealed class SoapDate : ISoapXsd
{
- [MonoTODO]
- public SoapDate()
+ static string[] _datetimeFormats = new string[]
+ {
+ "yyyy-MM-dd",
+ "'+'yyyy-MM-dd",
+ "'-'yyyy-MM-dd",
+ "yyyy-MM-ddzzz",
+ "'+'yyyy-MM-ddzzz",
+ "'-'yyyy-MM-ddzzz"
+ };
+
+ int _sign;
+ DateTime _value;
+
+ public SoapDate ()
{
}
- public int Sign {
- [MonoTODO]
- get { throw new NotImplementedException(); }
+ public SoapDate (DateTime date)
+ {
+ _value = date;
+ }
- [MonoTODO]
- set { throw new NotImplementedException(); }
+ public SoapDate (DateTime date, int sign)
+ {
+ _value = date;
+ _sign = sign;
+ }
+
+ public int Sign {
+ get { return _sign; }
+ set { _sign = value; }
}
public DateTime Value {
- [MonoTODO]
- get { throw new NotImplementedException(); }
-
- [MonoTODO]
- set { throw new NotImplementedException(); }
+ get { return _value; }
+ set { _value = value; }
}
public static string XsdType {
- [MonoTODO]
- get { throw new NotImplementedException(); }
+ get { return "date"; }
}
- [MonoTODO]
public string GetXsdType()
{
- throw new NotImplementedException();
+ return XsdType;
}
- [MonoTODO]
public static SoapDate Parse (string value)
{
- throw new NotImplementedException();
+ DateTime d = DateTime.ParseExact (value, _datetimeFormats, null, DateTimeStyles.None);
+
+ SoapDate res = new SoapDate (d);
+ if (value.StartsWith ("-")) res.Sign = -1;
+ else res.Sign = 0;
+ return res;
}
- [MonoTODO]
public override string ToString()
{
- throw new NotImplementedException();
- }
-
- [MonoTODO]
- ~SoapDate()
- {
+ if (_sign >= 0)
+ return _value.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture);
+ else
+ return _value.ToString("'-'yyyy-MM-dd", CultureInfo.InvariantCulture);
}
}
}
diff --git a/mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapDateTime.cs b/mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapDateTime.cs
index d8a122f584e..ff048b7e905 100644
--- a/mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapDateTime.cs
+++ b/mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapDateTime.cs
@@ -3,39 +3,61 @@
//
// Authors:
// Martin Willemoes Hansen (mwh@sysrq.dk)
+// Lluis Sanchez Gual (lluis@ximian.com)
//
// (C) 2003 Martin Willemoes Hansen
//
+using System;
+using System.Globalization;
+
namespace System.Runtime.Remoting.Metadata.W3cXsd2001
{
public sealed class SoapDateTime
{
- [MonoTODO]
+ static string[] _datetimeFormats = new string[] {
+ "yyyy-MM-ddTHH:mm:ss",
+ "yyyy-MM-ddTHH:mm:ss.f",
+ "yyyy-MM-ddTHH:mm:ss.ff",
+ "yyyy-MM-ddTHH:mm:ss.fff",
+ "yyyy-MM-ddTHH:mm:ss.ffff",
+ "yyyy-MM-ddTHH:mm:ss.fffff",
+ "yyyy-MM-ddTHH:mm:ss.ffffff",
+ "yyyy-MM-ddTHH:mm:ss.fffffff",
+ "yyyy-MM-ddTHH:mm:sszzz",
+ "yyyy-MM-ddTHH:mm:ss.fzzz",
+ "yyyy-MM-ddTHH:mm:ss.ffzzz",
+ "yyyy-MM-ddTHH:mm:ss.fffzzz",
+ "yyyy-MM-ddTHH:mm:ss.ffffzzz",
+ "yyyy-MM-ddTHH:mm:ss.fffffzzz",
+ "yyyy-MM-ddTHH:mm:ss.ffffffzzz",
+ "yyyy-MM-ddTHH:mm:ss.fffffffzzz",
+ "yyyy-MM-ddTHH:mm:ssZ",
+ "yyyy-MM-ddTHH:mm:ss.fZ",
+ "yyyy-MM-ddTHH:mm:ss.ffZ",
+ "yyyy-MM-ddTHH:mm:ss.fffZ",
+ "yyyy-MM-ddTHH:mm:ss.ffffZ",
+ "yyyy-MM-ddTHH:mm:ss.fffffZ",
+ "yyyy-MM-ddTHH:mm:ss.ffffffZ",
+ "yyyy-MM-ddTHH:mm:ss.fffffffZ"
+ };
+
public SoapDateTime()
{
}
public static string XsdType {
- [MonoTODO]
- get { throw new NotImplementedException(); }
+ get { return "dateTime"; }
}
- [MonoTODO]
public static DateTime Parse (string value)
{
- throw new NotImplementedException();
- }
-
- [MonoTODO]
- public override string ToString()
- {
- throw new NotImplementedException();
+ return DateTime.ParseExact (value, _datetimeFormats, null, DateTimeStyles.None);
}
- [MonoTODO]
- ~SoapDateTime()
+ public static string ToString(DateTime value)
{
+ return value.ToString("yyyy-MM-ddTHH:mm:ss.fffffffzzz", CultureInfo.InvariantCulture);
}
}
}
diff --git a/mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapDay.cs b/mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapDay.cs
index 1f9df28c360..5458b1c31a5 100644
--- a/mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapDay.cs
+++ b/mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapDay.cs
@@ -3,54 +3,59 @@
//
// Authors:
// Martin Willemoes Hansen (mwh@sysrq.dk)
+// Lluis Sanchez Gual (lluis@ximian.com)
//
// (C) 2003 Martin Willemoes Hansen
//
+using System;
+using System.Globalization;
+
namespace System.Runtime.Remoting.Metadata.W3cXsd2001
{
[Serializable]
- public sealed class SoapDay : ISoapXsd
+ public sealed class SoapDay : ISoapXsd
{
- [MonoTODO]
- public SoapDay()
+ static string[] _datetimeFormats = new string[]
+ {
+ "---dd",
+ "---ddzzz"
+ };
+
+ DateTime _value;
+
+ public SoapDay ()
+ {
+ }
+
+ public SoapDay (DateTime value)
{
+ _value = value;
}
public DateTime Value {
- [MonoTODO]
- get { throw new NotImplementedException(); }
-
- [MonoTODO]
- set { throw new NotImplementedException(); }
+ get { return _value; }
+ set { _value = value; }
}
public static string XsdType {
- [MonoTODO]
- get { throw new NotImplementedException(); }
+ get { return "gDay"; }
}
- [MonoTODO]
public string GetXsdType()
{
- throw new NotImplementedException();
+ return XsdType;
}
- [MonoTODO]
public static SoapDay Parse (string value)
{
- throw new NotImplementedException();
+ DateTime d = DateTime.ParseExact (value, _datetimeFormats, null, DateTimeStyles.None);
+ return new SoapDay (d);
}
-
- [MonoTODO]
+
public override string ToString()
{
- throw new NotImplementedException();
- }
-
- [MonoTODO]
- ~SoapDay()
- {
+ return _value.ToString("---dd", CultureInfo.InvariantCulture);
}
}
}
diff --git a/mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapDuration.cs b/mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapDuration.cs
index 8cfdd6e666c..6703b8b9cca 100644
--- a/mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapDuration.cs
+++ b/mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapDuration.cs
@@ -3,39 +3,138 @@
//
// Authors:
// Martin Willemoes Hansen (mwh@sysrq.dk)
+// Lluis Sanchez Gual (lluis@ximian.com)
//
// (C) 2003 Martin Willemoes Hansen
//
+using System;
+using System.Text;
+
namespace System.Runtime.Remoting.Metadata.W3cXsd2001
{
public sealed class SoapDuration
{
- [MonoTODO]
public SoapDuration()
{
}
public static string XsdType {
- [MonoTODO]
- get { throw new NotImplementedException(); }
+ get { return "duration"; }
}
- [MonoTODO]
- public static TimeSpan Parse (string value)
+ public static TimeSpan Parse (string s)
{
- throw new NotImplementedException();
- }
+ if (s.Length == 0)
+ throw new ArgumentException ("Invalid format string for duration schema datatype.");
- [MonoTODO]
- public override string ToString()
- {
- throw new NotImplementedException();
+ int start = 0;
+ if (s [0] == '-')
+ start = 1;
+ bool minusValue = (start == 1);
+
+ if (s [start] != 'P')
+ throw new ArgumentException ("Invalid format string for duration schema datatype.");
+ start++;
+
+ int parseStep = 0;
+ int days = 0;
+ bool isTime = false;
+ int hours = 0;
+ int minutes = 0;
+ int seconds = 0;
+
+ bool error = false;
+
+ int i = start;
+ while (i < s.Length) {
+ if (s [i] == 'T') {
+ isTime = true;
+ parseStep = 4;
+ i++;
+ start = i;
+ continue;
+ }
+ for (; i < s.Length; i++) {
+ if (!Char.IsDigit (s [i]))
+ break;
+ }
+ int value = int.Parse (s.Substring (start, i - start));
+ switch (s [i]) {
+ case 'Y':
+ days += value * 365;
+ if (parseStep > 0)
+ error = true;
+ else
+ parseStep = 1;
+ break;
+ case 'M':
+ if (parseStep < 2) {
+ days += 365 * (value / 12) + 30 * (value % 12);
+ parseStep = 2;
+ } else if (isTime && parseStep < 6) {
+ minutes = value;
+ parseStep = 6;
+ }
+ else
+ error = true;
+ break;
+ case 'D':
+ days += value;
+ if (parseStep > 2)
+ error = true;
+ else
+ parseStep = 3;
+ break;
+ case 'H':
+ hours = value;
+ if (!isTime || parseStep > 4)
+ error = true;
+ else
+ parseStep = 5;
+ break;
+ case 'S':
+ seconds = value;
+ if (!isTime || parseStep > 6)
+ error = true;
+ else
+ parseStep = 7;
+ break;
+ default:
+ error = true;
+ break;
+ }
+ if (error)
+ break;
+ ++i;
+ start = i;
+ }
+ if (error)
+ throw new ArgumentException ("Invalid format string for duration schema datatype.");
+ TimeSpan ts = new TimeSpan (days, hours, minutes, seconds);
+ return minusValue ? -ts : ts;
}
- [MonoTODO]
- ~SoapDuration()
+ public static string ToString (TimeSpan value)
{
+ StringBuilder builder = new StringBuilder();
+ if (value.Ticks < 0) {
+ builder.Append('-');
+ value = value.Negate();
+ }
+ builder.Append('P');
+ if (value.Days > 0) builder.Append(value.Days).Append('D');
+ if (value.Days > 0 || value.Minutes > 0 || value.Seconds > 0 || value.Milliseconds > 0) {
+ builder.Append('T');
+ if (value.Hours > 0) builder.Append(value.Hours).Append('D');
+ if (value.Minutes > 0) builder.Append(value.Minutes).Append('M');
+ if (value.Seconds > 0 || value.Milliseconds > 0) {
+ builder.Append(value.Seconds);
+ if (value.Milliseconds > 0) builder.Append('.').Append(String.Format("{0:000}", value.Milliseconds));
+ builder.Append('S');
+ }
+ }
+ return builder.ToString();
}
}
}
diff --git a/mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapEntities.cs b/mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapEntities.cs
index 9a28ab56663..a66582c86eb 100644
--- a/mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapEntities.cs
+++ b/mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapEntities.cs
@@ -3,54 +3,51 @@
//
// Authors:
// Martin Willemoes Hansen (mwh@sysrq.dk)
+// Lluis Sanchez Gual (lluis@ximian.com)
//
// (C) 2003 Martin Willemoes Hansen
//
+using System;
+
namespace System.Runtime.Remoting.Metadata.W3cXsd2001
{
[Serializable]
- public sealed class SoapEntities : ISoapXsd
+ public sealed class SoapEntities : ISoapXsd
{
- [MonoTODO]
- public SoapEntities()
+ string _value;
+
+ public SoapEntities ()
+ {
+ }
+
+ public SoapEntities (string value)
{
+ _value = SoapHelper.Normalize (value);
}
public string Value {
- [MonoTODO]
- get { throw new NotImplementedException(); }
-
- [MonoTODO]
- set { throw new NotImplementedException(); }
+ get { return _value; }
+ set { _value = value; }
}
public static string XsdType {
- [MonoTODO]
- get { throw new NotImplementedException(); }
+ get { return "ENTITIES"; }
}
- [MonoTODO]
public string GetXsdType()
{
- throw new NotImplementedException();
+ return XsdType;
}
- [MonoTODO]
public static SoapEntities Parse (string value)
{
- throw new NotImplementedException();
+ return new SoapEntities (value);
}
- [MonoTODO]
public override string ToString()
{
- throw new NotImplementedException();
- }
-
- [MonoTODO]
- ~SoapEntities()
- {
+ return _value;
}
}
}
diff --git a/mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapEntity.cs b/mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapEntity.cs
index b22cde98f3c..17a8916e9ec 100644
--- a/mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapEntity.cs
+++ b/mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapEntity.cs
@@ -3,54 +3,51 @@
//
// Authors:
// Martin Willemoes Hansen (mwh@sysrq.dk)
+// Lluis Sanchez Gual (lluis@ximian.com)
//
// (C) 2003 Martin Willemoes Hansen
//
+using System;
+
namespace System.Runtime.Remoting.Metadata.W3cXsd2001
{
[Serializable]
- public sealed class SoapEntity : ISoapXsd
+ public sealed class SoapEntity : ISoapXsd
{
- [MonoTODO]
- public SoapEntity()
+ string _value;
+
+ public SoapEntity ()
+ {
+ }
+
+ public SoapEntity (string value)
{
+ _value = SoapHelper.Normalize (value);
}
public string Value {
- [MonoTODO]
- get { throw new NotImplementedException(); }
-
- [MonoTODO]
- set { throw new NotImplementedException(); }
+ get { return _value; }
+ set { _value = value; }
}
public static string XsdType {
- [MonoTODO]
- get { throw new NotImplementedException(); }
+ get { return "ENTITY"; }
}
- [MonoTODO]
public string GetXsdType()
{
- throw new NotImplementedException();
+ return XsdType;
}
- [MonoTODO]
public static SoapEntity Parse (string value)
{
- throw new NotImplementedException();
+ return new SoapEntity (value);
}
- [MonoTODO]
public override string ToString()
{
- throw new NotImplementedException();
- }
-
- [MonoTODO]
- ~SoapEntity()
- {
+ return _value;
}
}
}
diff --git a/mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapHelper.cs b/mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapHelper.cs
new file mode 100644
index 00000000000..d4a82e9a86d
--- /dev/null
+++ b/mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapHelper.cs
@@ -0,0 +1,27 @@
+//
+// System.Runtime.Remoting.Metadata.W3cXsd2001.SoapNmtoken
+//
+// Authors:
+// Lluis Sanchez Gual (lluis@ximian.com)
+//
+// (C) 2003 Novell, Inc.
+//
+
+using System;
+
+namespace System.Runtime.Remoting.Metadata.W3cXsd2001
+{
+ internal class SoapHelper
+ {
+ public static Exception GetException (ISoapXsd type, string msg)
+ {
+ return new RemotingException ("Soap Parse error, xsd:type xsd:" + type.GetXsdType() + " " + msg);
+ }
+
+ public static string Normalize (string s)
+ {
+ return s;
+ }
+ }
+}
+
diff --git a/mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapHexBinary.cs b/mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapHexBinary.cs
index 92490f4be17..2871ddefdde 100644
--- a/mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapHexBinary.cs
+++ b/mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapHexBinary.cs
@@ -3,54 +3,80 @@
//
// Authors:
// Martin Willemoes Hansen (mwh@sysrq.dk)
+// Lluis Sanchez Gual (lluis@ximian.com)
//
// (C) 2003 Martin Willemoes Hansen
//
+using System;
+using System.Text;
+
namespace System.Runtime.Remoting.Metadata.W3cXsd2001
{
[Serializable]
- public sealed class SoapHexBinary : ISoapXsd
+ public sealed class SoapHexBinary : ISoapXsd
{
- [MonoTODO]
- public SoapHexBinary()
+ byte[] _value;
+
+ public SoapHexBinary ()
+ {
+ }
+
+ public SoapHexBinary (byte[] value)
{
}
public byte [] Value {
- [MonoTODO]
- get { throw new NotImplementedException(); }
-
- [MonoTODO]
- set { throw new NotImplementedException(); }
+ get { return _value; }
+ set { _value = value; }
}
public static string XsdType {
- [MonoTODO]
- get { throw new NotImplementedException(); }
+ get { return "hexBinary"; }
}
- [MonoTODO]
public string GetXsdType()
{
- throw new NotImplementedException();
+ return XsdType;
}
- [MonoTODO]
- public static SoapHexBinary Parse (string value)
+ public static SoapHexBinary Parse (string s)
{
- throw new NotImplementedException();
+ char [] chars = s.ToCharArray ();
+ byte [] bytes = new byte [chars.Length / 2 + chars.Length % 2];
+ FromBinHexString (chars, 0, chars.Length, bytes);
+ return new SoapHexBinary (bytes);
}
- [MonoTODO]
- public override string ToString()
+ internal static int FromBinHexString (char [] chars, int offset, int charLength, byte [] buffer)
{
- throw new NotImplementedException();
+ int bufIndex = offset;
+ for (int i = 0; i < charLength - 1; i += 2) {
+ buffer [bufIndex] = (chars [i] > '9' ?
+ (byte) (chars [i] - 'A' + 10) :
+ (byte) (chars [i] - '0'));
+ buffer [bufIndex] <<= 4;
+ buffer [bufIndex] += chars [i + 1] > '9' ?
+ (byte) (chars [i + 1] - 'A' + 10) :
+ (byte) (chars [i + 1] - '0');
+ bufIndex++;
+ }
+ if (charLength %2 != 0)
+ buffer [bufIndex++] = (byte)
+ ((chars [charLength - 1] > '9' ?
+ (byte) (chars [charLength - 1] - 'A' + 10) :
+ (byte) (chars [charLength - 1] - '0'))
+ << 4);
+
+ return bufIndex - offset;
}
- [MonoTODO]
- ~SoapHexBinary()
+ public override string ToString()
{
+ StringBuilder sb = new StringBuilder ();
+ foreach (byte b in _value)
+ sb.Append (b.ToString ("X2"));
+ return sb.ToString ();
}
}
}
diff --git a/mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapId.cs b/mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapId.cs
index dc0f2e0b9d1..748abe49671 100644
--- a/mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapId.cs
+++ b/mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapId.cs
@@ -3,54 +3,51 @@
//
// Authors:
// Martin Willemoes Hansen (mwh@sysrq.dk)
+// Lluis Sanchez Gual (lluis@ximian.com)
//
// (C) 2003 Martin Willemoes Hansen
//
+using System;
+
namespace System.Runtime.Remoting.Metadata.W3cXsd2001
{
[Serializable]
- public sealed class SoapId : ISoapXsd
+ public sealed class SoapId : ISoapXsd
{
- [MonoTODO]
+ string _value;
+
public SoapId()
{
}
+ public SoapId (string value)
+ {
+ _value = SoapHelper.Normalize (value);
+ }
+
public string Value {
- [MonoTODO]
- get { throw new NotImplementedException(); }
-
- [MonoTODO]
- set { throw new NotImplementedException(); }
+ get { return _value; }
+ set { _value = value; }
}
public static string XsdType {
- [MonoTODO]
- get { throw new NotImplementedException(); }
+ get { return "ID"; }
}
- [MonoTODO]
public string GetXsdType()
{
- throw new NotImplementedException();
+ return XsdType;
}
- [MonoTODO]
public static SoapId Parse (string value)
{
- throw new NotImplementedException();
+ return new SoapId (value);
}
- [MonoTODO]
public override string ToString()
{
- throw new NotImplementedException();
- }
-
- [MonoTODO]
- ~SoapId()
- {
+ return _value;
}
}
}
diff --git a/mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapIdref.cs b/mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapIdref.cs
index 134dfe63a31..9cbc97a3172 100644
--- a/mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapIdref.cs
+++ b/mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapIdref.cs
@@ -3,54 +3,51 @@
//
// Authors:
// Martin Willemoes Hansen (mwh@sysrq.dk)
+// Lluis Sanchez Gual (lluis@ximian.com)
//
// (C) 2003 Martin Willemoes Hansen
//
+using System;
+
namespace System.Runtime.Remoting.Metadata.W3cXsd2001
{
[Serializable]
- public sealed class SoapIdref : ISoapXsd
+ public sealed class SoapIdref : ISoapXsd
{
- [MonoTODO]
+ string _value;
+
public SoapIdref()
{
}
+ public SoapIdref (string value)
+ {
+ _value = SoapHelper.Normalize (value);
+ }
+
public string Value {
- [MonoTODO]
- get { throw new NotImplementedException(); }
-
- [MonoTODO]
- set { throw new NotImplementedException(); }
+ get { return _value; }
+ set { _value = value; }
}
public static string XsdType {
- [MonoTODO]
- get { throw new NotImplementedException(); }
+ get { return "IDREF"; }
}
- [MonoTODO]
public string GetXsdType()
{
- throw new NotImplementedException();
+ return XsdType;
}
- [MonoTODO]
public static SoapIdref Parse (string value)
{
- throw new NotImplementedException();
+ return new SoapIdref (value);
}
- [MonoTODO]
public override string ToString()
{
- throw new NotImplementedException();
- }
-
- [MonoTODO]
- ~SoapIdref()
- {
+ return _value;
}
}
}
diff --git a/mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapIdrefs.cs b/mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapIdrefs.cs
index 32c24801446..b857f2e9fb5 100644
--- a/mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapIdrefs.cs
+++ b/mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapIdrefs.cs
@@ -3,54 +3,51 @@
//
// Authors:
// Martin Willemoes Hansen (mwh@sysrq.dk)
+// Lluis Sanchez Gual (lluis@ximian.com)
//
// (C) 2003 Martin Willemoes Hansen
//
+using System;
+
namespace System.Runtime.Remoting.Metadata.W3cXsd2001
{
[Serializable]
- public sealed class SoapIdrefs : ISoapXsd
+ public sealed class SoapIdrefs : ISoapXsd
{
- [MonoTODO]
+ string _value;
+
public SoapIdrefs()
{
}
+ public SoapIdrefs (string value)
+ {
+ _value = SoapHelper.Normalize (value);
+ }
+
public string Value {
- [MonoTODO]
- get { throw new NotImplementedException(); }
-
- [MonoTODO]
- set { throw new NotImplementedException(); }
+ get { return _value; }
+ set { _value = value; }
}
public static string XsdType {
- [MonoTODO]
- get { throw new NotImplementedException(); }
+ get { return "IDREFS"; }
}
- [MonoTODO]
public string GetXsdType()
{
- throw new NotImplementedException();
+ return XsdType;
}
- [MonoTODO]
public static SoapIdrefs Parse (string value)
{
- throw new NotImplementedException();
+ return new SoapIdrefs (value);
}
- [MonoTODO]
public override string ToString()
{
- throw new NotImplementedException();
- }
-
- [MonoTODO]
- ~SoapIdrefs()
- {
+ return _value;
}
}
}
diff --git a/mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapInteger.cs b/mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapInteger.cs
index e382bfb3808..906efd86a09 100644
--- a/mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapInteger.cs
+++ b/mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapInteger.cs
@@ -3,54 +3,51 @@
//
// Authors:
// Martin Willemoes Hansen (mwh@sysrq.dk)
+// Lluis Sanchez Gual (lluis@ximian.com)
//
// (C) 2003 Martin Willemoes Hansen
//
+using System;
+
namespace System.Runtime.Remoting.Metadata.W3cXsd2001
{
[Serializable]
- public sealed class SoapInteger : ISoapXsd
+ public sealed class SoapInteger : ISoapXsd
{
- [MonoTODO]
- public SoapInteger()
+ decimal _value;
+
+ public SoapInteger ()
+ {
+ }
+
+ public SoapInteger (decimal value)
{
+ _value = value;
}
public decimal Value {
- [MonoTODO]
- get { throw new NotImplementedException(); }
-
- [MonoTODO]
- set { throw new NotImplementedException(); }
+ get { return _value; }
+ set { _value = value; }
}
public static string XsdType {
- [MonoTODO]
- get { throw new NotImplementedException(); }
+ get { return "integer"; }
}
- [MonoTODO]
public string GetXsdType()
{
- throw new NotImplementedException();
+ return XsdType;
}
- [MonoTODO]
public static SoapInteger Parse (string value)
{
- throw new NotImplementedException();
+ return new SoapInteger (decimal.Parse (value));
}
- [MonoTODO]
public override string ToString()
{
- throw new NotImplementedException();
- }
-
- [MonoTODO]
- ~SoapInteger()
- {
+ return _value.ToString ();
}
}
}
diff --git a/mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapLanguage.cs b/mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapLanguage.cs
index 69e5f0f6947..2f580dc246e 100644
--- a/mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapLanguage.cs
+++ b/mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapLanguage.cs
@@ -3,54 +3,51 @@
//
// Authors:
// Martin Willemoes Hansen (mwh@sysrq.dk)
+// Lluis Sanchez Gual (lluis@ximian.com)
//
// (C) 2003 Martin Willemoes Hansen
//
+using System;
+
namespace System.Runtime.Remoting.Metadata.W3cXsd2001
{
[Serializable]
- public sealed class SoapLanguage : ISoapXsd
+ public sealed class SoapLanguage : ISoapXsd
{
- [MonoTODO]
- public SoapLanguage()
+ string _value;
+
+ public SoapLanguage ()
+ {
+ }
+
+ public SoapLanguage (string value)
{
+ _value = SoapHelper.Normalize (value);
}
public string Value {
- [MonoTODO]
- get { throw new NotImplementedException(); }
-
- [MonoTODO]
- set { throw new NotImplementedException(); }
+ get { return _value; }
+ set { _value = value; }
}
public static string XsdType {
- [MonoTODO]
- get { throw new NotImplementedException(); }
+ get { return "language"; }
}
- [MonoTODO]
public string GetXsdType()
{
- throw new NotImplementedException();
+ return XsdType;
}
- [MonoTODO]
public static SoapLanguage Parse (string value)
{
- throw new NotImplementedException();
+ return new SoapLanguage (value);
}
- [MonoTODO]
public override string ToString()
{
- throw new NotImplementedException();
- }
-
- [MonoTODO]
- ~SoapLanguage()
- {
+ return _value;
}
}
}
diff --git a/mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapMonth.cs b/mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapMonth.cs
index 4aef058d6b8..d4157c3cf27 100644
--- a/mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapMonth.cs
+++ b/mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapMonth.cs
@@ -3,54 +3,59 @@
//
// Authors:
// Martin Willemoes Hansen (mwh@sysrq.dk)
+// Lluis Sanchez Gual (lluis@ximian.com)
//
// (C) 2003 Martin Willemoes Hansen
//
+using System;
+using System.Globalization;
+
namespace System.Runtime.Remoting.Metadata.W3cXsd2001
{
[Serializable]
- public sealed class SoapMonth : ISoapXsd
+ public sealed class SoapMonth : ISoapXsd
{
- [MonoTODO]
- public SoapMonth()
+ static string[] _datetimeFormats = new string[]
+ {
+ "--MM--",
+ "--MM--zzz"
+ };
+
+ DateTime _value;
+
+ public SoapMonth ()
{
}
+ public SoapMonth (DateTime value)
+ {
+ _value = value;
+ }
+
public DateTime Value {
- [MonoTODO]
- get { throw new NotImplementedException(); }
-
- [MonoTODO]
- set { throw new NotImplementedException(); }
+ get { return _value; }
+ set { _value = value; }
}
public static string XsdType {
- [MonoTODO]
- get { throw new NotImplementedException(); }
+ get { return "gMonth"; }
}
- [MonoTODO]
public string GetXsdType()
{
- throw new NotImplementedException();
+ return XsdType;
}
- [MonoTODO]
public static SoapMonth Parse (string value)
{
- throw new NotImplementedException();
+ DateTime d = DateTime.ParseExact (value, _datetimeFormats, null, DateTimeStyles.None);
+ return new SoapMonth (d);
}
- [MonoTODO]
public override string ToString()
{
- throw new NotImplementedException();
- }
-
- [MonoTODO]
- ~SoapMonth()
- {
+ return _value.ToString("--MM--", CultureInfo.InvariantCulture);
}
}
}
diff --git a/mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapMonthDay.cs b/mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapMonthDay.cs
index 92bec9662e4..a8c533f5e85 100644
--- a/mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapMonthDay.cs
+++ b/mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapMonthDay.cs
@@ -3,54 +3,59 @@
//
// Authors:
// Martin Willemoes Hansen (mwh@sysrq.dk)
+// Lluis Sanchez Gual (lluis@ximian.com)
//
// (C) 2003 Martin Willemoes Hansen
//
+using System;
+using System.Globalization;
+
namespace System.Runtime.Remoting.Metadata.W3cXsd2001
{
[Serializable]
- public sealed class SoapMonthDay : ISoapXsd
+ public sealed class SoapMonthDay : ISoapXsd
{
- [MonoTODO]
- public SoapMonthDay()
+ static string[] _datetimeFormats = new string[]
+ {
+ "--MM-dd",
+ "--MM-ddzzz"
+ };
+
+ DateTime _value;
+
+ public SoapMonthDay ()
{
}
+ public SoapMonthDay (DateTime value)
+ {
+ _value = value;
+ }
+
public DateTime Value {
- [MonoTODO]
- get { throw new NotImplementedException(); }
-
- [MonoTODO]
- set { throw new NotImplementedException(); }
+ get { return _value; }
+ set { _value = value; }
}
public static string XsdType {
- [MonoTODO]
- get { throw new NotImplementedException(); }
+ get { return "gMonthDay"; }
}
- [MonoTODO]
public string GetXsdType()
{
- throw new NotImplementedException();
+ return XsdType;
}
- [MonoTODO]
public static SoapMonthDay Parse (string value)
{
- throw new NotImplementedException();
+ DateTime d = DateTime.ParseExact (value, _datetimeFormats, null, DateTimeStyles.None);
+ return new SoapMonthDay (d);
}
- [MonoTODO]
public override string ToString()
{
- throw new NotImplementedException();
- }
-
- [MonoTODO]
- ~SoapMonthDay()
- {
+ return _value.ToString("--MM-dd", CultureInfo.InvariantCulture);
}
}
}
diff --git a/mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapName.cs b/mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapName.cs
index 58dc23d8b72..e933bd5f224 100644
--- a/mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapName.cs
+++ b/mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapName.cs
@@ -3,54 +3,51 @@
//
// Authors:
// Martin Willemoes Hansen (mwh@sysrq.dk)
+// Lluis Sanchez Gual (lluis@ximian.com)
//
// (C) 2003 Martin Willemoes Hansen
//
+using System;
+
namespace System.Runtime.Remoting.Metadata.W3cXsd2001
{
[Serializable]
- public sealed class SoapName : ISoapXsd
+ public sealed class SoapName : ISoapXsd
{
- [MonoTODO]
- public SoapName()
+ string _value;
+
+ public SoapName ()
+ {
+ }
+
+ public SoapName (string value)
{
+ _value = SoapHelper.Normalize (value);
}
public string Value {
- [MonoTODO]
- get { throw new NotImplementedException(); }
-
- [MonoTODO]
- set { throw new NotImplementedException(); }
+ get { return _value; }
+ set { _value = value; }
}
public static string XsdType {
- [MonoTODO]
- get { throw new NotImplementedException(); }
+ get { return "Name"; }
}
- [MonoTODO]
public string GetXsdType()
{
- throw new NotImplementedException();
+ return XsdType;
}
- [MonoTODO]
public static SoapName Parse (string value)
{
- throw new NotImplementedException();
+ return new SoapName (value);
}
- [MonoTODO]
public override string ToString()
{
- throw new NotImplementedException();
- }
-
- [MonoTODO]
- ~SoapName()
- {
+ return _value;
}
}
}
diff --git a/mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapNcName.cs b/mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapNcName.cs
index e21435b00e5..5621753acc0 100644
--- a/mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapNcName.cs
+++ b/mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapNcName.cs
@@ -3,54 +3,51 @@
//
// Authors:
// Martin Willemoes Hansen (mwh@sysrq.dk)
+// Lluis Sanchez Gual (lluis@ximian.com)
//
// (C) 2003 Martin Willemoes Hansen
//
+using System;
+
namespace System.Runtime.Remoting.Metadata.W3cXsd2001
{
[Serializable]
- public sealed class SoapNcName : ISoapXsd
+ public sealed class SoapNcName : ISoapXsd
{
- [MonoTODO]
+ string _value;
+
public SoapNcName()
{
}
+ public SoapNcName (string value)
+ {
+ _value = SoapHelper.Normalize (value);
+ }
+
public string Value {
- [MonoTODO]
- get { throw new NotImplementedException(); }
-
- [MonoTODO]
- set { throw new NotImplementedException(); }
+ get { return _value; }
+ set { _value = value; }
}
public static string XsdType {
- [MonoTODO]
- get { throw new NotImplementedException(); }
+ get { return "NCName"; }
}
- [MonoTODO]
public string GetXsdType()
{
- throw new NotImplementedException();
+ return XsdType;
}
- [MonoTODO]
public static SoapNcName Parse (string value)
{
- throw new NotImplementedException();
+ return new SoapNcName (value);
}
- [MonoTODO]
public override string ToString()
{
- throw new NotImplementedException();
- }
-
- [MonoTODO]
- ~SoapNcName()
- {
+ return _value;
}
}
}
diff --git a/mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapNegativeInteger.cs b/mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapNegativeInteger.cs
index 8a841a3a9eb..26f379adb29 100644
--- a/mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapNegativeInteger.cs
+++ b/mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapNegativeInteger.cs
@@ -3,54 +3,54 @@
//
// Authors:
// Martin Willemoes Hansen (mwh@sysrq.dk)
+// Lluis Sanchez Gual (lluis@ximian.com)
//
// (C) 2003 Martin Willemoes Hansen
//
+using System;
+using System.Runtime.Remoting;
+
namespace System.Runtime.Remoting.Metadata.W3cXsd2001
{
[Serializable]
- public sealed class SoapNegativeInteger : ISoapXsd
+ public sealed class SoapNegativeInteger : ISoapXsd
{
- [MonoTODO]
+ decimal _value;
+
public SoapNegativeInteger()
{
}
+ public SoapNegativeInteger(decimal value)
+ {
+ if (value >= 0)
+ throw SoapHelper.GetException (this, "invalid " + value);
+ _value = value;
+ }
+
public decimal Value {
- [MonoTODO]
- get { throw new NotImplementedException(); }
-
- [MonoTODO]
- set { throw new NotImplementedException(); }
+ get { return _value; }
+ set { _value = value; }
}
public static string XsdType {
- [MonoTODO]
- get { throw new NotImplementedException(); }
+ get { return "negativeInteger"; }
}
- [MonoTODO]
public string GetXsdType()
{
- throw new NotImplementedException();
+ return XsdType;
}
- [MonoTODO]
public static SoapNegativeInteger Parse (string value)
{
- throw new NotImplementedException();
+ return new SoapNegativeInteger (decimal.Parse (value));
}
- [MonoTODO]
public override string ToString()
{
- throw new NotImplementedException();
- }
-
- [MonoTODO]
- ~SoapNegativeInteger()
- {
+ return _value.ToString ();
}
}
}
diff --git a/mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapNmtoken.cs b/mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapNmtoken.cs
index 56e28dfab7f..b28ba303cd4 100644
--- a/mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapNmtoken.cs
+++ b/mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapNmtoken.cs
@@ -3,54 +3,51 @@
//
// Authors:
// Martin Willemoes Hansen (mwh@sysrq.dk)
+// Lluis Sanchez Gual (lluis@ximian.com)
//
// (C) 2003 Martin Willemoes Hansen
//
+using System;
+
namespace System.Runtime.Remoting.Metadata.W3cXsd2001
{
[Serializable]
- public sealed class SoapNmtoken : ISoapXsd
+ public sealed class SoapNmtoken : ISoapXsd
{
- [MonoTODO]
+ string _value;
+
public SoapNmtoken()
{
}
+ public SoapNmtoken (string value)
+ {
+ _value = SoapHelper.Normalize (value);
+ }
+
public string Value {
- [MonoTODO]
- get { throw new NotImplementedException(); }
-
- [MonoTODO]
- set { throw new NotImplementedException(); }
+ get { return _value; }
+ set { _value = value; }
}
public static string XsdType {
- [MonoTODO]
- get { throw new NotImplementedException(); }
+ get { return "NMTOKEN"; }
}
- [MonoTODO]
public string GetXsdType()
{
- throw new NotImplementedException();
+ return XsdType;
}
- [MonoTODO]
public static SoapNmtoken Parse (string value)
{
- throw new NotImplementedException();
+ return new SoapNmtoken (value);
}
- [MonoTODO]
public override string ToString()
{
- throw new NotImplementedException();
- }
-
- [MonoTODO]
- ~SoapNmtoken()
- {
+ return _value;
}
}
}
diff --git a/mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapNmtokens.cs b/mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapNmtokens.cs
index 21ac3b8e1dd..6e233c07513 100644
--- a/mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapNmtokens.cs
+++ b/mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapNmtokens.cs
@@ -3,54 +3,51 @@
//
// Authors:
// Martin Willemoes Hansen (mwh@sysrq.dk)
+// Lluis Sanchez Gual (lluis@ximian.com)
//
// (C) 2003 Martin Willemoes Hansen
//
+using System;
+
namespace System.Runtime.Remoting.Metadata.W3cXsd2001
{
[Serializable]
- public sealed class SoapNmtokens : ISoapXsd
+ public sealed class SoapNmtokens : ISoapXsd
{
- [MonoTODO]
+ string _value;
+
public SoapNmtokens()
{
}
+ public SoapNmtokens (string value)
+ {
+ _value = SoapHelper.Normalize (value);
+ }
+
public string Value {
- [MonoTODO]
- get { throw new NotImplementedException(); }
-
- [MonoTODO]
- set { throw new NotImplementedException(); }
+ get { return _value; }
+ set { _value = value; }
}
public static string XsdType {
- [MonoTODO]
- get { throw new NotImplementedException(); }
+ get { return "NMTOKENS"; }
}
- [MonoTODO]
public string GetXsdType()
{
- throw new NotImplementedException();
+ return XsdType;
}
- [MonoTODO]
public static SoapNmtokens Parse (string value)
{
- throw new NotImplementedException();
+ return new SoapNmtokens (value);
}
- [MonoTODO]
public override string ToString()
{
- throw new NotImplementedException();
- }
-
- [MonoTODO]
- ~SoapNmtokens()
- {
+ return _value;
}
}
}
diff --git a/mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapNonNegativeInteger.cs b/mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapNonNegativeInteger.cs
index ae46a823f76..52c2c5399c5 100644
--- a/mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapNonNegativeInteger.cs
+++ b/mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapNonNegativeInteger.cs
@@ -3,54 +3,53 @@
//
// Authors:
// Martin Willemoes Hansen (mwh@sysrq.dk)
+// Lluis Sanchez Gual (lluis@ximian.com)
//
// (C) 2003 Martin Willemoes Hansen
//
+using System;
+
namespace System.Runtime.Remoting.Metadata.W3cXsd2001
{
[Serializable]
- public sealed class SoapNonNegativeInteger : ISoapXsd
+ public sealed class SoapNonNegativeInteger : ISoapXsd
{
- [MonoTODO]
+ decimal _value;
+
public SoapNonNegativeInteger()
{
}
+ public SoapNonNegativeInteger(decimal value)
+ {
+ if (value < 0)
+ throw SoapHelper.GetException (this, "invalid " + value);
+ _value = value;
+ }
+
public decimal Value {
- [MonoTODO]
- get { throw new NotImplementedException(); }
-
- [MonoTODO]
- set { throw new NotImplementedException(); }
+ get { return _value; }
+ set { _value = value; }
}
public static string XsdType {
- [MonoTODO]
- get { throw new NotImplementedException(); }
+ get { return "nonNegativeInteger"; }
}
- [MonoTODO]
public string GetXsdType()
{
- throw new NotImplementedException();
+ return XsdType;
}
- [MonoTODO]
public static SoapNonNegativeInteger Parse (string value)
{
- throw new NotImplementedException();
+ return new SoapNonNegativeInteger (decimal.Parse (value));
}
- [MonoTODO]
public override string ToString()
{
- throw new NotImplementedException();
- }
-
- [MonoTODO]
- ~SoapNonNegativeInteger()
- {
+ return _value.ToString ();
}
}
}
diff --git a/mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapNonPositiveInteger.cs b/mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapNonPositiveInteger.cs
index 63453851b2c..6f2419c85d8 100644
--- a/mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapNonPositiveInteger.cs
+++ b/mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapNonPositiveInteger.cs
@@ -3,54 +3,53 @@
//
// Authors:
// Martin Willemoes Hansen (mwh@sysrq.dk)
+// Lluis Sanchez Gual (lluis@ximian.com)
//
// (C) 2003 Martin Willemoes Hansen
//
+using System;
+
namespace System.Runtime.Remoting.Metadata.W3cXsd2001
{
[Serializable]
- public sealed class SoapNonPositiveInteger : ISoapXsd
+ public sealed class SoapNonPositiveInteger : ISoapXsd
{
- [MonoTODO]
+ decimal _value;
+
public SoapNonPositiveInteger()
{
}
+ public SoapNonPositiveInteger(decimal value)
+ {
+ if (value > 0)
+ throw SoapHelper.GetException (this, "invalid " + value);
+ _value = value;
+ }
+
public decimal Value {
- [MonoTODO]
- get { throw new NotImplementedException(); }
-
- [MonoTODO]
- set { throw new NotImplementedException(); }
+ get { return _value; }
+ set { _value = value; }
}
public static string XsdType {
- [MonoTODO]
- get { throw new NotImplementedException(); }
+ get { return "nonPositiveInteger"; }
}
- [MonoTODO]
public string GetXsdType()
{
- throw new NotImplementedException();
+ return XsdType;
}
- [MonoTODO]
public static SoapNonPositiveInteger Parse (string value)
{
- throw new NotImplementedException();
+ return new SoapNonPositiveInteger (decimal.Parse (value));
}
- [MonoTODO]
public override string ToString()
{
- throw new NotImplementedException();
- }
-
- [MonoTODO]
- ~SoapNonPositiveInteger()
- {
+ return _value.ToString ();
}
}
}
diff --git a/mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapNormalizedString.cs b/mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapNormalizedString.cs
index 6044692d74a..3d9782d1fc1 100644
--- a/mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapNormalizedString.cs
+++ b/mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapNormalizedString.cs
@@ -3,54 +3,51 @@
//
// Authors:
// Martin Willemoes Hansen (mwh@sysrq.dk)
+// Lluis Sanchez Gual (lluis@ximian.com)
//
// (C) 2003 Martin Willemoes Hansen
//
+using System;
+
namespace System.Runtime.Remoting.Metadata.W3cXsd2001
{
[Serializable]
- public sealed class SoapNormalizedString : ISoapXsd
+ public sealed class SoapNormalizedString : ISoapXsd
{
- [MonoTODO]
+ string _value;
+
public SoapNormalizedString()
{
}
+ public SoapNormalizedString (string value)
+ {
+ _value = SoapHelper.Normalize (value);
+ }
+
public string Value {
- [MonoTODO]
- get { throw new NotImplementedException(); }
-
- [MonoTODO]
- set { throw new NotImplementedException(); }
+ get { return _value; }
+ set { _value = value; }
}
public static string XsdType {
- [MonoTODO]
- get { throw new NotImplementedException(); }
+ get { return "normalizedString"; }
}
- [MonoTODO]
public string GetXsdType()
{
- throw new NotImplementedException();
+ return XsdType;
}
- [MonoTODO]
public static SoapNormalizedString Parse (string value)
{
- throw new NotImplementedException();
+ return new SoapNormalizedString (value);
}
- [MonoTODO]
public override string ToString()
{
- throw new NotImplementedException();
- }
-
- [MonoTODO]
- ~SoapNormalizedString()
- {
+ return _value;
}
}
}
diff --git a/mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapNotation.cs b/mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapNotation.cs
index 339b93d901e..debc82504ba 100644
--- a/mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapNotation.cs
+++ b/mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapNotation.cs
@@ -3,54 +3,51 @@
//
// Authors:
// Martin Willemoes Hansen (mwh@sysrq.dk)
+// Lluis Sanchez Gual (lluis@ximian.com)
//
// (C) 2003 Martin Willemoes Hansen
//
+using System;
+
namespace System.Runtime.Remoting.Metadata.W3cXsd2001
{
[Serializable]
- public sealed class SoapNotation : ISoapXsd
+ public sealed class SoapNotation : ISoapXsd
{
- [MonoTODO]
+ string _value;
+
public SoapNotation()
{
}
+ public SoapNotation (string value)
+ {
+ _value = value;
+ }
+
public string Value {
- [MonoTODO]
- get { throw new NotImplementedException(); }
-
- [MonoTODO]
- set { throw new NotImplementedException(); }
+ get { return _value; }
+ set { _value = value; }
}
public static string XsdType {
- [MonoTODO]
- get { throw new NotImplementedException(); }
+ get { return "NOTATION"; }
}
- [MonoTODO]
public string GetXsdType()
{
- throw new NotImplementedException();
+ return XsdType;
}
- [MonoTODO]
public static SoapNotation Parse (string value)
{
- throw new NotImplementedException();
+ return new SoapNotation (value);
}
- [MonoTODO]
public override string ToString()
{
- throw new NotImplementedException();
- }
-
- [MonoTODO]
- ~SoapNotation()
- {
+ return _value;
}
}
}
diff --git a/mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapPositiveInteger.cs b/mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapPositiveInteger.cs
index adaf8fa5def..68f009e5124 100644
--- a/mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapPositiveInteger.cs
+++ b/mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapPositiveInteger.cs
@@ -3,54 +3,53 @@
//
// Authors:
// Martin Willemoes Hansen (mwh@sysrq.dk)
+// Lluis Sanchez Gual (lluis@ximian.com)
//
// (C) 2003 Martin Willemoes Hansen
//
+using System;
+
namespace System.Runtime.Remoting.Metadata.W3cXsd2001
{
[Serializable]
public sealed class SoapPositiveInteger : ISoapXsd
{
- [MonoTODO]
+ decimal _value;
+
public SoapPositiveInteger()
{
}
+ public SoapPositiveInteger (decimal value)
+ {
+ if (value <= 0)
+ throw SoapHelper.GetException (this, "invalid " + value);
+ _value = value;
+ }
+
public decimal Value {
- [MonoTODO]
- get { throw new NotImplementedException(); }
-
- [MonoTODO]
- set { throw new NotImplementedException(); }
+ get { return _value; }
+ set { _value = value; }
}
public static string XsdType {
- [MonoTODO]
- get { throw new NotImplementedException(); }
+ get { return "nonPositiveInteger"; }
}
- [MonoTODO]
public string GetXsdType()
{
- throw new NotImplementedException();
+ return XsdType;
}
- [MonoTODO]
public static SoapPositiveInteger Parse (string value)
{
- throw new NotImplementedException();
+ return new SoapPositiveInteger (decimal.Parse (value));
}
- [MonoTODO]
public override string ToString()
{
- throw new NotImplementedException();
- }
-
- [MonoTODO]
- ~SoapPositiveInteger()
- {
+ return _value.ToString ();
}
}
}
diff --git a/mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapQName.cs b/mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapQName.cs
index 218c7324bd5..9000312c1c3 100644
--- a/mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapQName.cs
+++ b/mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapQName.cs
@@ -3,70 +3,86 @@
//
// Authors:
// Martin Willemoes Hansen (mwh@sysrq.dk)
+// Lluis Sanchez Gual (lluis@ximian.com)
//
// (C) 2003 Martin Willemoes Hansen
//
+using System;
+
namespace System.Runtime.Remoting.Metadata.W3cXsd2001
{
[Serializable]
public sealed class SoapQName : ISoapXsd
{
- [MonoTODO]
- public SoapQName()
+ string _name;
+ string _prefix;
+ string _namespace;
+
+ public SoapQName ()
{
}
- public string Key {
- [MonoTODO]
- get { throw new NotImplementedException(); }
+ public SoapQName (string localName)
+ {
+ _name = localName;
+ }
- [MonoTODO]
- set { throw new NotImplementedException(); }
+ public SoapQName (string prefix, string localName)
+ {
+ _prefix = prefix;
+ _name = localName;
}
- public string Name {
- [MonoTODO]
- get { throw new NotImplementedException(); }
+ public SoapQName (string prefix, string localName, string namspace)
+ {
+ _prefix = prefix;
+ _name = localName;
+ _namespace = namspace;
+ }
- [MonoTODO]
- set { throw new NotImplementedException(); }
+ public string Key {
+ get { return _prefix; }
+ set { _prefix = value; }
}
- public string Namespace {
- [MonoTODO]
- get { throw new NotImplementedException(); }
+ public string Name {
+ get { return _name; }
+ set { _name = value; }
+ }
- [MonoTODO]
- set { throw new NotImplementedException(); }
+ public string Namespace {
+ get { return _namespace; }
+ set { _namespace = value; }
}
public static string XsdType {
- [MonoTODO]
- get { throw new NotImplementedException(); }
+ get { return "QName"; }
}
- [MonoTODO]
public string GetXsdType()
{
- throw new NotImplementedException();
+ return XsdType;
}
- [MonoTODO]
public static SoapQName Parse (string value)
{
- throw new NotImplementedException();
+ SoapQName res = new SoapQName ();
+ int i = value.IndexOf (':');
+ if (i != -1)
+ {
+ res.Key = value.Substring (0,i);
+ res.Name = value.Substring (i+1);
+ }
+ else
+ res.Name = value;
+ return res;
}
- [MonoTODO]
public override string ToString()
{
- throw new NotImplementedException();
- }
-
- [MonoTODO]
- ~SoapQName()
- {
+ if (_prefix == null || _prefix == "") return _name;
+ else return _prefix + ":" + _name;
}
}
}
diff --git a/mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapTime.cs b/mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapTime.cs
index d08ce5683e1..24bdd2a5b32 100644
--- a/mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapTime.cs
+++ b/mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapTime.cs
@@ -3,54 +3,80 @@
//
// Authors:
// Martin Willemoes Hansen (mwh@sysrq.dk)
+// Lluis Sanchez Gual (lluis@ximian.com)
//
// (C) 2003 Martin Willemoes Hansen
//
+using System;
+using System.Globalization;
+
namespace System.Runtime.Remoting.Metadata.W3cXsd2001
{
[Serializable]
- public sealed class SoapTime : ISoapXsd
+ public sealed class SoapTime : ISoapXsd
{
- [MonoTODO]
- public SoapTime()
+ static string[] _datetimeFormats = new string[]
+ {
+ "HH:mm:ss",
+ "HH:mm:ss.f",
+ "HH:mm:ss.ff",
+ "HH:mm:ss.fff",
+ "HH:mm:ss.ffff",
+ "HH:mm:ss.fffff",
+ "HH:mm:ss.ffffff",
+ "HH:mm:ss.fffffff",
+ "HH:mm:sszzz",
+ "HH:mm:ss.fzzz",
+ "HH:mm:ss.ffzzz",
+ "HH:mm:ss.fffzzz",
+ "HH:mm:ss.ffffzzz",
+ "HH:mm:ss.fffffzzz",
+ "HH:mm:ss.ffffffzzz",
+ "HH:mm:ss.fffffffzzz",
+ "HH:mm:ssZ",
+ "HH:mm:ss.fZ",
+ "HH:mm:ss.ffZ",
+ "HH:mm:ss.fffZ",
+ "HH:mm:ss.ffffZ",
+ "HH:mm:ss.fffffZ",
+ "HH:mm:ss.ffffffZ",
+ "HH:mm:ss.fffffffZ"
+ };
+
+ DateTime _value;
+
+ public SoapTime ()
{
}
- public DateTime Value {
- [MonoTODO]
- get { throw new NotImplementedException(); }
+ public SoapTime (DateTime value)
+ {
+ _value = value;
+ }
- [MonoTODO]
- set { throw new NotImplementedException(); }
+ public DateTime Value {
+ get { return _value; }
+ set { _value = value; }
}
+
public static string XsdType {
- [MonoTODO]
- get { throw new NotImplementedException(); }
+ get { return "time"; }
}
- [MonoTODO]
public string GetXsdType()
{
- throw new NotImplementedException();
+ return XsdType;
}
- [MonoTODO]
public static SoapTime Parse (string value)
{
- throw new NotImplementedException();
+ return new SoapTime (DateTime.ParseExact (value, _datetimeFormats, null, DateTimeStyles.None));
}
- [MonoTODO]
public override string ToString()
{
- throw new NotImplementedException();
- }
-
- [MonoTODO]
- ~SoapTime()
- {
+ return _value.ToString("HH:mm:ss.fffffffzzz", CultureInfo.InvariantCulture);
}
-
}
}
diff --git a/mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapToken.cs b/mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapToken.cs
index 365763cf0ea..a292c66ace3 100644
--- a/mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapToken.cs
+++ b/mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapToken.cs
@@ -3,54 +3,51 @@
//
// Authors:
// Martin Willemoes Hansen (mwh@sysrq.dk)
+// Lluis Sanchez Gual (lluis@ximian.com)
//
// (C) 2003 Martin Willemoes Hansen
//
+using System;
+
namespace System.Runtime.Remoting.Metadata.W3cXsd2001
{
[Serializable]
- public sealed class SoapToken : ISoapXsd
+ public sealed class SoapToken : ISoapXsd
{
- [MonoTODO]
+ string _value;
+
public SoapToken()
{
}
-
+
+ public SoapToken (string value)
+ {
+ _value = SoapHelper.Normalize (value);
+ }
+
public string Value {
- [MonoTODO]
- get { throw new NotImplementedException(); }
-
- [MonoTODO]
- set { throw new NotImplementedException(); }
+ get { return _value; }
+ set { _value = value; }
}
public static string XsdType {
- [MonoTODO]
- get { throw new NotImplementedException(); }
+ get { return "token"; }
}
- [MonoTODO]
public string GetXsdType()
{
- throw new NotImplementedException();
+ return XsdType;
}
-
- [MonoTODO]
+
public static SoapToken Parse (string value)
{
- throw new NotImplementedException();
+ return new SoapToken (value);
}
- [MonoTODO]
public override string ToString()
{
- throw new NotImplementedException();
- }
-
- [MonoTODO]
- ~SoapToken()
- {
+ return _value;
}
}
}
diff --git a/mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapYear.cs b/mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapYear.cs
index fe962b8dc5f..4ec9ffba0a6 100644
--- a/mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapYear.cs
+++ b/mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapYear.cs
@@ -3,62 +3,82 @@
//
// Authors:
// Martin Willemoes Hansen (mwh@sysrq.dk)
+// Lluis Sanchez Gual (lluis@ximian.com)
//
// (C) 2003 Martin Willemoes Hansen
//
+using System;
+using System.Globalization;
+
namespace System.Runtime.Remoting.Metadata.W3cXsd2001
{
[Serializable]
- public sealed class SoapYear : ISoapXsd
+ public sealed class SoapYear : ISoapXsd
{
- [MonoTODO]
+ static string[] _datetimeFormats = new string[]
+ {
+ "yyyy",
+ "'+'yyyy",
+ "'-'yyyy",
+ "yyyyzzz",
+ "'+'yyyyzzz",
+ "'-'yyyyzzz"
+ };
+
+ int _sign;
+ DateTime _value;
+
public SoapYear()
{
}
- public int Sign {
- [MonoTODO]
- get { throw new NotImplementedException(); }
+ public SoapYear (DateTime date)
+ {
+ _value = date;
+ }
- [MonoTODO]
- set { throw new NotImplementedException(); }
+ public SoapYear (DateTime date, int sign)
+ {
+ _value = date;
+ _sign = sign;
}
+ public int Sign {
+ get { return _sign; }
+ set { _sign = value; }
+ }
+
public DateTime Value {
- [MonoTODO]
- get { throw new NotImplementedException(); }
-
- [MonoTODO]
- set { throw new NotImplementedException(); }
+ get { return _value; }
+ set { _value = value; }
}
public static string XsdType {
- [MonoTODO]
- get { throw new NotImplementedException(); }
+ get { return "gYear"; }
}
-
- [MonoTODO]
+
public string GetXsdType()
{
- throw new NotImplementedException();
+ return XsdType;
}
-
- [MonoTODO]
+
public static SoapYear Parse (string value)
{
- throw new NotImplementedException();
+ DateTime d = DateTime.ParseExact (value, _datetimeFormats, null, DateTimeStyles.None);
+
+ SoapYear res = new SoapYear (d);
+ if (value.StartsWith ("-")) res.Sign = -1;
+ else res.Sign = 0;
+ return res;
}
- [MonoTODO]
public override string ToString()
{
- throw new NotImplementedException();
- }
-
- [MonoTODO]
- ~SoapYear()
- {
+ if (_sign >= 0)
+ return _value.ToString("yyyy", CultureInfo.InvariantCulture);
+ else
+ return _value.ToString("'-'yyyy", CultureInfo.InvariantCulture);
}
}
}
diff --git a/mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapYearMonth.cs b/mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapYearMonth.cs
index 5da6079061a..3addca3c5d1 100644
--- a/mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapYearMonth.cs
+++ b/mcs/class/corlib/System.Runtime.Remoting.Metadata.W3cXsd2001/SoapYearMonth.cs
@@ -3,62 +3,82 @@
//
// Authors:
// Martin Willemoes Hansen (mwh@sysrq.dk)
+// Lluis Sanchez Gual (lluis@ximian.com)
//
// (C) 2003 Martin Willemoes Hansen
//
+using System;
+using System.Globalization;
+
namespace System.Runtime.Remoting.Metadata.W3cXsd2001
{
[Serializable]
- public sealed class SoapYearMonth : ISoapXsd
+ public sealed class SoapYearMonth : ISoapXsd
{
- [MonoTODO]
+ static string[] _datetimeFormats = new string[]
+ {
+ "yyyy-MM",
+ "'+'yyyy-MM",
+ "'-'yyyy-MM",
+ "yyyy-MMzzz",
+ "'+'yyyy-MMzzz",
+ "'-'yyyy-MMzzz"
+ };
+
+ int _sign;
+ DateTime _value;
+
public SoapYearMonth()
{
}
- public int Sign {
- [MonoTODO]
- get { throw new NotImplementedException(); }
+ public SoapYearMonth (DateTime date)
+ {
+ _value = date;
+ }
- [MonoTODO]
- set { throw new NotImplementedException(); }
+ public SoapYearMonth (DateTime date, int sign)
+ {
+ _value = date;
+ _sign = sign;
}
+ public int Sign {
+ get { return _sign; }
+ set { _sign = value; }
+ }
+
public DateTime Value {
- [MonoTODO]
- get { throw new NotImplementedException(); }
-
- [MonoTODO]
- set { throw new NotImplementedException(); }
+ get { return _value; }
+ set { _value = value; }
}
public static string XsdType {
- [MonoTODO]
- get { throw new NotImplementedException(); }
+ get { return "gYearMonth"; }
}
- [MonoTODO]
public string GetXsdType()
{
- throw new NotImplementedException();
+ return XsdType;
}
-
- [MonoTODO]
+
public static SoapYearMonth Parse (string value)
{
- throw new NotImplementedException();
+ DateTime d = DateTime.ParseExact (value, _datetimeFormats, null, DateTimeStyles.None);
+
+ SoapYearMonth res = new SoapYearMonth (d);
+ if (value.StartsWith ("-")) res.Sign = -1;
+ else res.Sign = 0;
+ return res;
}
- [MonoTODO]
public override string ToString()
{
- throw new NotImplementedException();
- }
-
- [MonoTODO]
- ~SoapYearMonth()
- {
+ if (_sign >= 0)
+ return _value.ToString("yyyy-MM", CultureInfo.InvariantCulture);
+ else
+ return _value.ToString("'-'yyyy-MM", CultureInfo.InvariantCulture);
}
}
}
diff --git a/mcs/class/corlib/System.Runtime.Remoting.Metadata/ChangeLog b/mcs/class/corlib/System.Runtime.Remoting.Metadata/ChangeLog
index 9669e4ef58a..f663b51ebeb 100644
--- a/mcs/class/corlib/System.Runtime.Remoting.Metadata/ChangeLog
+++ b/mcs/class/corlib/System.Runtime.Remoting.Metadata/ChangeLog
@@ -1,3 +1,14 @@
+2003-11-26 Lluis Sanchez Gual <lluis@ximian.com>
+
+ * SoapAttribute.cs, SoapFieldAttribute.cs, SoapMethodAttribute.cs,
+ SoapTypeAttribute.cs: Added SetReflectionObject. Used to initialize some
+ attribute properties.
+
+2003-11-11 Lluis Sanchez Gual <lluis@ximian.com>
+
+ * SoapAttribute.cs, SoapFieldAttribute.cs, SoapMethodAttribute.cs,
+ SoapTypeAttribute.cs: Implemented several simple methods and properties.
+
2002-07-29 Duncan Mak <duncan@ximian.com>
* SoapAttribute.cs: Fixed typo, renamed ReflectionInfo to ReflectInfo.
diff --git a/mcs/class/corlib/System.Runtime.Remoting.Metadata/SoapAttribute.cs b/mcs/class/corlib/System.Runtime.Remoting.Metadata/SoapAttribute.cs
index c84d8d8bfe4..37f15c761a2 100644
--- a/mcs/class/corlib/System.Runtime.Remoting.Metadata/SoapAttribute.cs
+++ b/mcs/class/corlib/System.Runtime.Remoting.Metadata/SoapAttribute.cs
@@ -2,6 +2,7 @@
// System.Runtime.Remoting.Metadata.SoapAttribute.cs
//
// Author: Duncan Mak (duncan@ximian.com)
+// Lluis Sanchez Gual (lluis@ximian.com)
//
// 2002 (C) Copyright, Ximian, Inc.
//
@@ -12,44 +13,47 @@ namespace System.Runtime.Remoting.Metadata {
public class SoapAttribute : Attribute
{
+ bool _nested;
+ bool _useAttribute;
+ string _namespace;
+ object _reflectionObject;
+
public SoapAttribute ()
{
}
- protected string ProtXmlNamespace;
- protected object ReflectInfo;
-
- [MonoTODO]
public virtual bool Embedded {
get {
- throw new NotImplementedException ();
+ return _nested;
}
set {
- throw new NotImplementedException ();
+ _nested = value;
}
}
- [MonoTODO]
public virtual bool UseAttribute {
get {
- throw new NotImplementedException ();
+ return _useAttribute;
}
set {
- throw new NotImplementedException ();
+ _useAttribute = value;
}
}
- [MonoTODO]
public virtual string XmlNamespace {
get {
- throw new NotImplementedException ();
+ return _namespace;
}
set {
- throw new NotImplementedException ();
+ _namespace = value;
}
}
+
+ internal virtual void SetReflectionObject (object reflectionObject)
+ {
+ }
}
}
diff --git a/mcs/class/corlib/System.Runtime.Remoting.Metadata/SoapFieldAttribute.cs b/mcs/class/corlib/System.Runtime.Remoting.Metadata/SoapFieldAttribute.cs
index 8809748b259..f2f0d5cc45d 100644
--- a/mcs/class/corlib/System.Runtime.Remoting.Metadata/SoapFieldAttribute.cs
+++ b/mcs/class/corlib/System.Runtime.Remoting.Metadata/SoapFieldAttribute.cs
@@ -2,47 +2,58 @@
// System.Runtime.Remoting.Metadata.SoapFieldAttribute.cs
//
// Author: Duncan Mak (duncan@ximian.com)
+// Lluis Sanchez Gual (lluis@ximian.com)
//
// 2002 (C) Copyright, Ximian, Inc.
//
+using System.Runtime.Remoting;
using System.Runtime.Remoting.Metadata;
+using System.Reflection;
namespace System.Runtime.Remoting.Metadata {
[AttributeUsage (AttributeTargets.Field)]
public sealed class SoapFieldAttribute : SoapAttribute
{
+ int _order;
+ string _elementName;
+ bool _isElement = false;
+
public SoapFieldAttribute ()
{
}
- [MonoTODO]
public int Order {
get {
- throw new NotImplementedException ();
+ return _order;
}
set {
- throw new NotImplementedException ();
+ _order = value;
}
}
- [MonoTODO]
public string XmlElementName {
get {
- throw new NotImplementedException ();
+ return _elementName;
}
set {
- throw new NotImplementedException ();
+ _isElement = value != null;
+ _elementName = value;
}
}
- [MonoTODO]
public bool IsInteropXmlElement ()
{
- throw new NotImplementedException ();
+ return _isElement;
+ }
+
+ internal override void SetReflectionObject (object reflectionObject)
+ {
+ FieldInfo f = (FieldInfo) reflectionObject;
+ if (_elementName == null) _elementName = f.Name;
}
}
}
diff --git a/mcs/class/corlib/System.Runtime.Remoting.Metadata/SoapMethodAttribute.cs b/mcs/class/corlib/System.Runtime.Remoting.Metadata/SoapMethodAttribute.cs
index a3b39de29fa..dd65014c78d 100644
--- a/mcs/class/corlib/System.Runtime.Remoting.Metadata/SoapMethodAttribute.cs
+++ b/mcs/class/corlib/System.Runtime.Remoting.Metadata/SoapMethodAttribute.cs
@@ -2,11 +2,14 @@
// System.Runtime.Remoting.Metadata.SoapMethodAttribute.cs
//
// Author: Duncan Mak (duncan@ximian.com)
+// Lluis Sanchez Gual (lluis@ximian.com)
//
// 2002 (C) Copyright, Ximian, Inc.
//
using System;
+using System.Reflection;
+using System.Runtime.Remoting;
using System.Runtime.Remoting.Metadata;
namespace System.Runtime.Remoting.Metadata {
@@ -14,74 +17,96 @@ namespace System.Runtime.Remoting.Metadata {
[AttributeUsage (AttributeTargets.Method)]
public sealed class SoapMethodAttribute : SoapAttribute
{
+ string _responseElement;
+ string _responseNamespace;
+ string _returnElement;
+ string _soapAction;
+ bool _useAttribute;
+ string _namespace;
+
public SoapMethodAttribute ()
{
}
- [MonoTODO]
public string ResponseXmlElementName {
get {
- throw new NotImplementedException ();
+ return _responseElement;
}
set {
- throw new NotImplementedException ();
+ _responseElement = value;
}
}
- [MonoTODO]
public string ResponseXmlNamespace {
get {
- throw new NotImplementedException ();
+ return _responseNamespace;
}
set {
- throw new NotImplementedException ();
+ _responseNamespace = value;
}
}
- [MonoTODO]
public string ReturnXmlElementName {
get {
- throw new NotImplementedException ();
+ return _returnElement;
}
set {
- throw new NotImplementedException ();
+ _returnElement = value;
}
}
- [MonoTODO]
public string SoapAction {
get {
- throw new NotImplementedException ();
+ return _soapAction;
}
set {
- throw new NotImplementedException ();
+ _soapAction = value;
}
}
- [MonoTODO]
public override bool UseAttribute {
get {
- throw new NotImplementedException ();
+ return _useAttribute;
}
set {
- throw new NotImplementedException ();
+ _useAttribute = value;
}
}
- [MonoTODO]
public override string XmlNamespace {
get {
- throw new NotImplementedException ();
+ return _namespace;
}
set {
- throw new NotImplementedException ();
+ _namespace = value;
+ }
+ }
+
+ internal override void SetReflectionObject (object reflectionObject)
+ {
+ MethodBase mb = (MethodBase) reflectionObject;
+
+ if (_responseElement == null)
+ _responseElement = mb.Name + "Response";
+
+ if (_responseNamespace == null)
+ _responseNamespace = SoapServices.GetXmlNamespaceForMethodResponse (mb);
+
+ if (_returnElement == null)
+ _returnElement = "return";
+
+ if (_soapAction == null) {
+ _soapAction = SoapServices.GetXmlNamespaceForMethodCall (mb) + "#" + mb.Name;
}
+
+ if (_namespace == null)
+ _namespace = SoapServices.GetXmlNamespaceForMethodCall (mb);
}
}
}
diff --git a/mcs/class/corlib/System.Runtime.Remoting.Metadata/SoapTypeAttribute.cs b/mcs/class/corlib/System.Runtime.Remoting.Metadata/SoapTypeAttribute.cs
index 2e015537312..8785c92b4a5 100644
--- a/mcs/class/corlib/System.Runtime.Remoting.Metadata/SoapTypeAttribute.cs
+++ b/mcs/class/corlib/System.Runtime.Remoting.Metadata/SoapTypeAttribute.cs
@@ -2,11 +2,13 @@
// System.Runtime.Remoting.Metadata.SoapTypeAttribute.cs
//
// Author: Duncan Mak (duncan@ximian.com)
+// Lluis Sanchez Gual (lluis@ximian.com)
//
// 2002 (C) Copyright, Ximian, Inc.
//
using System;
+using System.Runtime.Remoting;
using System.Runtime.Remoting.Metadata;
namespace System.Runtime.Remoting.Metadata {
@@ -15,85 +17,119 @@ namespace System.Runtime.Remoting.Metadata {
AttributeTargets.Enum | AttributeTargets.Interface)]
public sealed class SoapTypeAttribute : SoapAttribute
{
+ SoapOption _soapOption;
+ bool _useAttribute;
+ string _xmlElementName;
+ XmlFieldOrderOption _xmlFieldOrder;
+ string _xmlNamespace;
+ string _xmlTypeName;
+ string _xmlTypeNamespace;
+ bool _isType;
+ bool _isElement;
+
public SoapTypeAttribute ()
{
}
- [MonoTODO]
public SoapOption SoapOptions {
get {
- throw new NotImplementedException ();
+ return _soapOption;
}
set {
- throw new NotImplementedException ();
+ _soapOption = value;
}
}
- [MonoTODO]
public override bool UseAttribute {
get {
- throw new NotImplementedException ();
+ return _useAttribute;
}
set {
- throw new NotImplementedException ();
+ _useAttribute = value;
}
}
- [MonoTODO]
public string XmlElementName {
get {
- throw new NotImplementedException ();
+ return _xmlElementName;
}
set {
- throw new NotImplementedException ();
+ _isElement = value != null;
+ _xmlElementName = value;
}
}
- [MonoTODO]
public XmlFieldOrderOption XmlFieldOrder {
get {
- throw new NotImplementedException ();
+ return _xmlFieldOrder;
}
set {
- throw new NotImplementedException ();
+ _xmlFieldOrder = value;
}
}
- [MonoTODO]
public override string XmlNamespace {
get {
- throw new NotImplementedException ();
+ return _xmlNamespace;
}
set {
- throw new NotImplementedException ();
+ _isElement = value != null;
+ _xmlNamespace = value;
}
}
- [MonoTODO]
public string XmlTypeName {
get {
- throw new NotImplementedException ();
+ return _xmlTypeName;
}
set {
- throw new NotImplementedException ();
+ _isType = value != null;
+ _xmlTypeName = value;
}
}
- [MonoTODO]
public string XmlTypeNamespace {
get {
- throw new NotImplementedException ();
+ return _xmlTypeNamespace;
}
set {
- throw new NotImplementedException ();
+ _isType = value != null;
+ _xmlTypeNamespace = value;
}
}
+
+ internal bool IsInteropXmlElement
+ {
+ get { return _isElement; }
+ }
+
+ internal bool IsInteropXmlType
+ {
+ get { return _isType; }
+ }
+
+ internal override void SetReflectionObject (object reflectionObject)
+ {
+ Type type = (Type) reflectionObject;
+
+ if (_xmlElementName == null)
+ _xmlElementName = type.Name;
+
+ if (_xmlTypeName == null)
+ _xmlTypeName = type.Name;
+
+ if (_xmlTypeNamespace == null)
+ _xmlTypeNamespace = SoapServices.CodeXmlNamespaceForClrTypeNamespace (type.Namespace, type.Assembly.GetName().Name);
+
+ if (_xmlNamespace == null)
+ _xmlNamespace = _xmlTypeNamespace;
+ }
}
}
diff --git a/mcs/class/corlib/System.Runtime.Remoting.Proxies/ChangeLog b/mcs/class/corlib/System.Runtime.Remoting.Proxies/ChangeLog
index 14376844280..024e3f3dfe3 100644
--- a/mcs/class/corlib/System.Runtime.Remoting.Proxies/ChangeLog
+++ b/mcs/class/corlib/System.Runtime.Remoting.Proxies/ChangeLog
@@ -1,3 +1,18 @@
+2003-11-26 Lluis Sanchez Gual <lluis@ximian.com>
+
+ * RealProxy.cs: Signature fix.
+
+2003-11-25 Lluis Sanchez Gual <lluis@ximian.com>
+
+ * RealProxy.cs: Added some missing methods.
+ * RemotingProxy.cs: ActivateRemoteObject() must return a ConstructionResponse
+ instead of a ReturnMessage.
+
+2003-11-11 Lluis Sanchez Gual <lluis@ximian.com>
+
+ * RemotingProxy.cs: Do not dispose proxy identity when it is a local
+ ContextBoundObject proxy.
+
2003-10-21 Lluis Sanchez Gual <lluis@ximian.com>
* RealProxy.cs: In PrivateInvoke() do not try to return the out parameters
diff --git a/mcs/class/corlib/System.Runtime.Remoting.Proxies/RealProxy.cs b/mcs/class/corlib/System.Runtime.Remoting.Proxies/RealProxy.cs
index 323b07f857f..23196a3be24 100644
--- a/mcs/class/corlib/System.Runtime.Remoting.Proxies/RealProxy.cs
+++ b/mcs/class/corlib/System.Runtime.Remoting.Proxies/RealProxy.cs
@@ -24,6 +24,7 @@ namespace System.Runtime.Remoting.Proxies
internal class TransparentProxy {
public RealProxy _rp;
IntPtr _class;
+ bool _custom_type_info;
}
public abstract class RealProxy {
@@ -33,6 +34,7 @@ namespace System.Runtime.Remoting.Proxies
MarshalByRefObject _server;
internal Identity _objectIdentity;
Object _objTP;
+ object _stubData;
protected RealProxy ()
{
@@ -80,6 +82,34 @@ namespace System.Runtime.Remoting.Proxies
{
get { return _objectIdentity; }
}
+
+ [MonoTODO]
+ public virtual IntPtr GetCOMIUnknown (bool fIsMarshalled)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public virtual void SetCOMIUnknown (IntPtr i)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public virtual IntPtr SupportsInterface (ref Guid iid)
+ {
+ throw new NotImplementedException ();
+ }
+
+ public static object GetStubData (RealProxy rp)
+ {
+ return rp._stubData;
+ }
+
+ public static void SetStubData (RealProxy rp, object stubData)
+ {
+ rp._stubData = stubData;
+ }
public abstract IMessage Invoke (IMessage msg);
@@ -122,7 +152,7 @@ namespace System.Runtime.Remoting.Proxies
}
[MethodImplAttribute(MethodImplOptions.InternalCall)]
- public extern virtual object InternalGetTransparentProxy ();
+ internal extern virtual object InternalGetTransparentProxy ();
public virtual object GetTransparentProxy ()
{
diff --git a/mcs/class/corlib/System.Runtime.Remoting.Proxies/RemotingProxy.cs b/mcs/class/corlib/System.Runtime.Remoting.Proxies/RemotingProxy.cs
index e409e8a4d38..52a7dce3fae 100644
--- a/mcs/class/corlib/System.Runtime.Remoting.Proxies/RemotingProxy.cs
+++ b/mcs/class/corlib/System.Runtime.Remoting.Proxies/RemotingProxy.cs
@@ -21,7 +21,7 @@ using System.Threading;
namespace System.Runtime.Remoting.Proxies
{
- public class RemotingProxy : RealProxy
+ internal class RemotingProxy : RealProxy
{
static MethodInfo _cache_GetTypeMethod = typeof(System.Object).GetMethod("GetType");
static MethodInfo _cache_GetHashCodeMethod = typeof(System.Object).GetMethod("GetHashCode");
@@ -50,7 +50,7 @@ namespace System.Runtime.Remoting.Proxies
if (mMsg.CallType == CallType.EndInvoke)
return mMsg.AsyncResult.EndInvoke ();
-
+
if (mMsg.MethodBase.IsConstructor)
return ActivateRemoteObject (mMsg);
@@ -108,7 +108,7 @@ namespace System.Runtime.Remoting.Proxies
else
_targetUri = identity.ObjectUri;
- if (_objectIdentity.EnvoySink != null)
+ if (_objectIdentity.EnvoySink != null)
{
_sink = _objectIdentity.EnvoySink;
_hasEnvoySink = true;
@@ -122,7 +122,7 @@ namespace System.Runtime.Remoting.Proxies
IMessage ActivateRemoteObject (IMethodMessage request)
{
if (_ctorCall == null) // It must be a WKO
- return new ReturnMessage (this, new object[0], 0, null, (IMethodCallMessage) request); // Ignore constructor call for WKOs
+ return new ConstructionResponse (this, null, (IMethodCallMessage) request); // Ignore constructor call for WKOs
_ctorCall.CopyFrom (request);
return ActivationServices.Activate (this, _ctorCall);
@@ -131,7 +131,10 @@ namespace System.Runtime.Remoting.Proxies
~RemotingProxy()
{
if (_objectIdentity != null)
- RemotingServices.DisposeIdentity (_objectIdentity);
+ {
+ if (!(_objectIdentity is ClientActivatedIdentity)) // Local CBO proxy?
+ RemotingServices.DisposeIdentity (_objectIdentity);
+ }
}
}
diff --git a/mcs/class/corlib/System.Runtime.Remoting.Services/ChangeLog b/mcs/class/corlib/System.Runtime.Remoting.Services/ChangeLog
index 36146b59681..7a246a91087 100644
--- a/mcs/class/corlib/System.Runtime.Remoting.Services/ChangeLog
+++ b/mcs/class/corlib/System.Runtime.Remoting.Services/ChangeLog
@@ -1,3 +1,7 @@
+2003-11-26 Lluis Sanchez Gual <lluis@ximian.com>
+
+ * EnterpriseServicesHelper.cs: Added to CVS.
+
2003-02-03 Patrik Torstensson
* TrackingServices.cs: Implemented
diff --git a/mcs/class/corlib/System.Runtime.Remoting.Services/EnterpriseServicesHelper.cs b/mcs/class/corlib/System.Runtime.Remoting.Services/EnterpriseServicesHelper.cs
new file mode 100644
index 00000000000..81fca128613
--- /dev/null
+++ b/mcs/class/corlib/System.Runtime.Remoting.Services/EnterpriseServicesHelper.cs
@@ -0,0 +1,39 @@
+//
+// System.Runtime.Remoting.Services.EnterpriseServicesHelper.cs
+//
+// Author: Lluis Sanchez Gual (lluis@ximian.com)
+//
+// 2003 (C) Copyright, Novell, Inc.
+//
+
+using System.Runtime.Remoting;
+using System.Runtime.Remoting.Messaging;
+using System.Runtime.Remoting.Activation;
+using System.Runtime.Remoting.Proxies;
+
+namespace System.Runtime.Remoting.Services
+{
+ public sealed class EnterpriseServicesHelper
+ {
+ public EnterpriseServicesHelper ()
+ {
+ }
+
+ public static IConstructionReturnMessage CreateConstructionReturnMessage (IConstructionCallMessage ctorMsg, MarshalByRefObject retObj)
+ {
+ return new ConstructionResponse (retObj, null, ctorMsg);
+ }
+
+ [MonoTODO]
+ public static void SwitchWrappers (RealProxy oldcp, RealProxy newcp)
+ {
+ throw new NotSupportedException ();
+ }
+
+ [MonoTODO]
+ public static object WrapIUnknownWithComObject (IntPtr punk)
+ {
+ throw new NotSupportedException ();
+ }
+ }
+}
diff --git a/mcs/class/corlib/System.Runtime.Remoting/ActivatedClientTypeEntry.cs b/mcs/class/corlib/System.Runtime.Remoting/ActivatedClientTypeEntry.cs
index 404f2f9e86c..088442cfb53 100644
--- a/mcs/class/corlib/System.Runtime.Remoting/ActivatedClientTypeEntry.cs
+++ b/mcs/class/corlib/System.Runtime.Remoting/ActivatedClientTypeEntry.cs
@@ -7,6 +7,7 @@
//
using System;
+using System.Reflection;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Contexts;
@@ -30,6 +31,10 @@ namespace System.Runtime.Remoting {
AssemblyName = assemblyName;
TypeName = typeName;
applicationUrl = appUrl;
+ Assembly a = Assembly.Load (assemblyName);
+ obj_type = a.GetType (typeName);
+ if (obj_type == null)
+ throw new RemotingException ("Type not found: " + typeName + ", " + assemblyName);
}
public string ApplicationUrl {
@@ -45,7 +50,6 @@ namespace System.Runtime.Remoting {
get { return obj_type; }
}
- [MonoTODO]
public override string ToString ()
{
return TypeName + AssemblyName + ApplicationUrl;
diff --git a/mcs/class/corlib/System.Runtime.Remoting/ActivatedServiceTypeEntry.cs b/mcs/class/corlib/System.Runtime.Remoting/ActivatedServiceTypeEntry.cs
index bf0365cbfb6..ab52016fc2b 100644
--- a/mcs/class/corlib/System.Runtime.Remoting/ActivatedServiceTypeEntry.cs
+++ b/mcs/class/corlib/System.Runtime.Remoting/ActivatedServiceTypeEntry.cs
@@ -30,6 +30,8 @@ namespace System.Runtime.Remoting {
TypeName = typeName;
Assembly a = Assembly.Load (assemblyName);
obj_type = a.GetType (typeName);
+ if (obj_type == null)
+ throw new RemotingException ("Type not found: " + typeName + ", " + assemblyName);
}
public IContextAttribute [] ContextAttributes {
@@ -41,7 +43,6 @@ namespace System.Runtime.Remoting {
get { return obj_type; }
}
- [MonoTODO]
public override string ToString ()
{
return AssemblyName + TypeName;
diff --git a/mcs/class/corlib/System.Runtime.Remoting/ChangeLog b/mcs/class/corlib/System.Runtime.Remoting/ChangeLog
index 78e3aae672c..0dcfa86f98b 100755
--- a/mcs/class/corlib/System.Runtime.Remoting/ChangeLog
+++ b/mcs/class/corlib/System.Runtime.Remoting/ChangeLog
@@ -1,3 +1,68 @@
+2003-11-28 Dick Porter <dick@ximian.com>
+
+ * TypeInfo.cs:
+ * RemotingConfiguration.cs: Use the char form of IndexOf, so that
+ the comparison is done with the Invariant culture.
+
+2003-11-26 Lluis Sanchez Gual <lluis@ximian.com>
+
+ * InternalRemotingServices.cs: Fixed GetCachedSoapAttribute().
+ * RemotingConfiguration.cs: Implemented CustomErrorsEnabled().
+ Added support for soapInterop configuration section.
+ * SoapServices.cs: Several fixes to match MS behavior.
+
+2003-11-25 Lluis Sanchez Gual <lluis@ximian.com>
+
+ * InternalRemotingServices.cs: Implemented GetCachedSoapAttribute().
+ * SoapServices.cs: Implemented missing methods.
+ * WellKnownClientTypeEntry.cs: Initialize object_url in constructor.
+
+2003-11-24 Jackson Harper <jackson@ximian.com>
+
+ * ServerIdentity.cs: Get non public types, so remote objects can
+ be non public or have non public constructors.
+
+2003-11-19 Lluis Sanchez Gual <lluis@ximian.com>
+
+ * InternalRemotingServices.cs: Added missing attributes.
+
+2003-11-17 Lluis Sanchez Gual <lluis@ximian.com>
+
+ * InternalRemotingServices.cs: Added CLSCompliant to SetServerIdentity
+ (MethodCall is not compliant)
+ * IObjectHandle.cs: Set correct value for Guid.
+
+2003-11-16 Lluis Sanchez Gual <lluis@ximian.com>
+
+ * IObjectHandle.cs, ObjectHandle.cs: Added missing attributes.
+ * RemotingConfiguration.cs: GetRegisteredActivatedClientTypes made public.
+ Declared CustomErrorsEnabled() method.
+ * RemotingServices.cs: Implemented GetSessionIdForMethodMessage().
+ IsAsyncMessage must be internal.
+ * InternalRemotingServices.cs: Added.
+
+2003-11-13 Lluis Sanchez Gual <lluis@ximian.com>
+
+ * RemotingServices.cs: Add ".rem" suffix to generated uri names.
+
+2003-11-12 Lluis Sanchez Gual <lluis@ximian.com>
+
+ * RemotingConfiguration.cs: Implemented all remaining functionality.
+ * ActivatedClientTypeEntry.cs: Set the value of ObjectType in the constructor
+ * ActivatedServiceTypeEntry.cs, WellKnownClientTypeEntry.cs,
+ WellKnownServiceTypeEntry.cs: Check that the provided type is valid.
+
+2003-11-11 Lluis Sanchez Gual <lluis@ximian.com>
+
+ * RemotingConfiguration.cs: Added initial implementation of Configure method
+ by Jaime Anguiano.
+
+2003-11-11 Lluis Sanchez Gual <lluis@ximian.com>
+
+ * ActivatedClientTypeEntry.cs, ActivatedServiceTypeEntry.cs,
+ IRemotingTypeInfo.cs, RemotingServices.cs, WellKnownServiceTypeEntry.cs:
+ Removed some TODOs.
+
2003-11-01 Zoltan Varga <vargaz@freemail.hu>
* RemotingServices.cs (GetDomainProxy): Use the new InvokeInDomain
diff --git a/mcs/class/corlib/System.Runtime.Remoting/IObjectHandle.cs b/mcs/class/corlib/System.Runtime.Remoting/IObjectHandle.cs
index 20bf4bc4907..c77f86ed43d 100644
--- a/mcs/class/corlib/System.Runtime.Remoting/IObjectHandle.cs
+++ b/mcs/class/corlib/System.Runtime.Remoting/IObjectHandle.cs
@@ -7,8 +7,12 @@
// (C) 2002 Ximian, Inc. http://www.ximian.com
//
+using System.Runtime.InteropServices;
+
namespace System.Runtime.Remoting
{
+ [Guid("C460E2B4-E199-412a-8456-84DC3E4838C3")]
+ [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IObjectHandle
{
object Unwrap ();
diff --git a/mcs/class/corlib/System.Runtime.Remoting/IRemotingTypeInfo.cs b/mcs/class/corlib/System.Runtime.Remoting/IRemotingTypeInfo.cs
index 238b55c827a..78f9890973c 100644
--- a/mcs/class/corlib/System.Runtime.Remoting/IRemotingTypeInfo.cs
+++ b/mcs/class/corlib/System.Runtime.Remoting/IRemotingTypeInfo.cs
@@ -16,49 +16,4 @@ namespace System.Runtime.Remoting {
string TypeName { get; set; }
bool CanCastTo (Type fromType, object o);
}
-
- // fixme: dont know if we really need this
- internal class RemotingTypeInfo : IRemotingTypeInfo
- {
-
- string type_name;
-
- public RemotingTypeInfo (Type type)
- {
- type_name = type.AssemblyQualifiedName;
- }
-
- public string TypeName {
-
- get {
- return type_name;
- }
-
- set {
- type_name = value;
- }
- }
-
- public Type GetRealType ()
- {
- string type_name = null;
- Assembly assembly = null;
-
- int pos = type_name.IndexOf (",");
- if (pos >= 0) {
- if (pos != 0) {
- string ass_name = type_name.Substring (0, pos - 1);
- assembly = Assembly.Load (ass_name);
- }
- type_name = type_name.Substring (pos + 1);
- }
- return assembly.GetType (type_name);
- }
-
- public bool CanCastTo (Type fromType, object o)
- {
- return false;
- }
- }
}
-
diff --git a/mcs/class/corlib/System.Runtime.Remoting/InternalRemotingServices.cs b/mcs/class/corlib/System.Runtime.Remoting/InternalRemotingServices.cs
new file mode 100644
index 00000000000..46642737a37
--- /dev/null
+++ b/mcs/class/corlib/System.Runtime.Remoting/InternalRemotingServices.cs
@@ -0,0 +1,95 @@
+//
+// System.Runtime.Remoting.InternalRemotingServices.cs
+//
+// Authors:
+// Lluis Sanchez Gual (lluis@ximian.com)
+//
+// (C) 2003 Novell, Inc.
+//
+
+using System;
+using System.Reflection;
+using System.Diagnostics;
+using System.Collections;
+using System.Runtime.Remoting.Metadata;
+using System.Runtime.Remoting.Messaging;
+
+namespace System.Runtime.Remoting
+{
+ public class InternalRemotingServices
+ {
+ static Hashtable _soapAttributes;
+
+ public InternalRemotingServices ()
+ {
+ }
+
+ [Conditional("_LOGGING")]
+ public static void DebugOutChnl (string s)
+ {
+ // Mono does not support this internal method
+ throw new NotSupportedException ();
+ }
+
+ public static SoapAttribute GetCachedSoapAttribute (object reflectionObject)
+ {
+ if (_soapAttributes == null)
+ {
+ lock (typeof(InternalRemotingServices))
+ {
+ if (_soapAttributes == null)
+ _soapAttributes = new Hashtable ();
+ }
+ }
+
+ lock (_soapAttributes.SyncRoot)
+ {
+ SoapAttribute att = _soapAttributes [reflectionObject] as SoapAttribute;
+ if (att != null) return att;
+
+ ICustomAttributeProvider ap = (ICustomAttributeProvider) reflectionObject;
+ object[] atts = ap.GetCustomAttributes (typeof(SoapAttribute), true);
+ if (atts.Length > 0)
+ att = (SoapAttribute) atts[0];
+ else
+ {
+ if (reflectionObject is Type)
+ att = new SoapTypeAttribute ();
+ else if (reflectionObject is FieldInfo)
+ att = new SoapFieldAttribute ();
+ else if (reflectionObject is MethodBase)
+ att = new SoapMethodAttribute ();
+ else if (reflectionObject is ParameterInfo)
+ att = new SoapParameterAttribute ();
+ }
+
+ att.SetReflectionObject (reflectionObject);
+ _soapAttributes [reflectionObject] = att;
+ return att;
+ }
+ }
+
+ [Conditional("_DEBUG")]
+ public static void RemotingAssert (bool condition, string message)
+ {
+ // Mono does not support this internal method
+ throw new NotSupportedException ();
+ }
+
+ [Conditional("_LOGGING")]
+ public static void RemotingTrace (params object[] messages)
+ {
+ // Mono does not support this internal method
+ throw new NotSupportedException ();
+ }
+
+ [CLSCompliant (false)]
+ public static void SetServerIdentity (MethodCall m, object srvID)
+ {
+ Identity ident = srvID as Identity;
+ if (ident == null) throw new ArgumentException ("srvID");
+
+ RemotingServices.SetMessageTargetIdentity (m, ident);
+ }
+ }
+}
diff --git a/mcs/class/corlib/System.Runtime.Remoting/ObjectHandle.cs b/mcs/class/corlib/System.Runtime.Remoting/ObjectHandle.cs
index 2c9ecedb268..1928f3525f6 100644
--- a/mcs/class/corlib/System.Runtime.Remoting/ObjectHandle.cs
+++ b/mcs/class/corlib/System.Runtime.Remoting/ObjectHandle.cs
@@ -13,9 +13,11 @@
using System;
using System.Runtime.Serialization;
using System.Runtime.Remoting.Lifetime;
+using System.Runtime.InteropServices;
namespace System.Runtime.Remoting {
+ [ClassInterface(ClassInterfaceType.AutoDual)]
public class ObjectHandle : MarshalByRefObject, IObjectHandle {
private object _wrapped;
diff --git a/mcs/class/corlib/System.Runtime.Remoting/RemotingConfiguration.cs b/mcs/class/corlib/System.Runtime.Remoting/RemotingConfiguration.cs
index 897c380c7ba..9f99d9c2449 100644
--- a/mcs/class/corlib/System.Runtime.Remoting/RemotingConfiguration.cs
+++ b/mcs/class/corlib/System.Runtime.Remoting/RemotingConfiguration.cs
@@ -6,30 +6,44 @@
//
// (C) 2002, Jaime Anguiano Olarra
//
-// FIXME: This is just the skeleton for practical purposes
using System;
using System.IO;
using System.Reflection;
using System.Collections;
using System.Runtime.Remoting.Activation;
+using System.Runtime.Remoting.Channels;
+using System.Runtime.Remoting.Lifetime;
using Mono.Xml;
namespace System.Runtime.Remoting
{
public class RemotingConfiguration
{
+ //
+ // Private constructor: nobody instantiates this.
+ //
+ private RemotingConfiguration ()
+ {
+ }
+
static string applicationID = null;
static string applicationName = null;
static string configFile = "";
static MiniParser parser = null;
static string processGuid = null;
+ static bool defaultConfigRead = false;
+ static string _errorMode;
static Hashtable wellKnownClientEntries = new Hashtable();
static Hashtable activatedClientEntries = new Hashtable();
static Hashtable wellKnownServiceEntries = new Hashtable();
static Hashtable activatedServiceEntries = new Hashtable();
+ static Hashtable channelTemplates = new Hashtable ();
+ static Hashtable clientProviderTemplates = new Hashtable ();
+ static Hashtable serverProviderTemplates = new Hashtable ();
+
// public properties
// At this time the ID will be the application name
public static string ApplicationId
@@ -71,9 +85,31 @@ namespace System.Runtime.Remoting
public static void Configure (string filename)
{
- throw new NotImplementedException ();
+ if (!defaultConfigRead)
+ {
+ ReadConfigFile (Environment.GetMachineConfigPath ());
+ defaultConfigRead = true;
+ }
+
+ if (filename != null)
+ ReadConfigFile (filename);
}
+ private static void ReadConfigFile (string filename)
+ {
+ try
+ {
+ MiniParser parser = new MiniParser ();
+ RReader rreader = new RReader (filename);
+ ConfigHandler handler = new ConfigHandler ();
+ parser.Parse (rreader, handler);
+ }
+ catch (Exception ex)
+ {
+ throw new RemotingException ("Configuration file '" + filename + "' could not be loaded: " + ex.Message);
+ }
+ }
+
public static ActivatedClientTypeEntry[] GetRegisteredActivatedClientTypes ()
{
ActivatedClientTypeEntry[] entries = new ActivatedClientTypeEntry[activatedClientEntries.Count];
@@ -181,7 +217,639 @@ namespace System.Runtime.Remoting
wellKnownServiceEntries [entry.ObjectUri] = entry;
RemotingServices.CreateWellKnownServerIdentity (entry.ObjectType, entry.ObjectUri, entry.Mode);
}
- }
-}
+ internal static void RegisterChannelTemplate (ChannelData channel)
+ {
+ channelTemplates [channel.Id] = channel;
+ }
+
+ internal static void RegisterClientProviderTemplate (ProviderData prov)
+ {
+ clientProviderTemplates [prov.Id] = prov;
+ }
+
+ internal static void RegisterServerProviderTemplate (ProviderData prov)
+ {
+ serverProviderTemplates [prov.Id] = prov;
+ }
+
+ internal static void RegisterChannels (ArrayList channels)
+ {
+ foreach (ChannelData channel in channels)
+ {
+ if (channel.Ref != null)
+ {
+ ChannelData template = (ChannelData) channelTemplates [channel.Ref];
+ if (template == null) throw new RemotingException ("Channel template '" + channel.Ref + "' not found");
+ channel.CopyFrom (template);
+ }
+
+ foreach (ProviderData prov in channel.ServerProviders)
+ {
+ if (prov.Ref != null)
+ {
+ ProviderData template = (ProviderData) serverProviderTemplates [prov.Ref];
+ if (template == null) throw new RemotingException ("Provider template '" + prov.Ref + "' not found");
+ prov.CopyFrom (template);
+ }
+ }
+
+ foreach (ProviderData prov in channel.ClientProviders)
+ {
+ if (prov.Ref != null)
+ {
+ ProviderData template = (ProviderData) clientProviderTemplates [prov.Ref];
+ if (template == null) throw new RemotingException ("Provider template '" + prov.Ref + "' not found");
+ prov.CopyFrom (template);
+ }
+ }
+
+ ChannelServices.RegisterChannelConfig (channel);
+ }
+ }
+
+ internal static void RegisterTypes (ArrayList types)
+ {
+ foreach (TypeEntry type in types)
+ {
+ if (type is ActivatedClientTypeEntry)
+ RegisterActivatedClientType ((ActivatedClientTypeEntry)type);
+ else if (type is ActivatedServiceTypeEntry)
+ RegisterActivatedServiceType ((ActivatedServiceTypeEntry)type);
+ else if (type is WellKnownClientTypeEntry)
+ RegisterWellKnownClientType ((WellKnownClientTypeEntry)type);
+ else if (type is WellKnownServiceTypeEntry)
+ RegisterWellKnownServiceType ((WellKnownServiceTypeEntry)type);
+ }
+ }
+
+#if NET_1_1
+ public static bool CustomErrorsEnabled (bool isLocalRequest)
+ {
+ if (_errorMode == "off") return false;
+ if (_errorMode == "on") return true;
+ return !isLocalRequest;
+ }
+#endif
+
+ internal static void SetCustomErrorsMode (string mode)
+ {
+ if (mode != "on" && mode != "off" && mode != "remoteOnly")
+ throw new RemotingException ("Invalid custom error mode: " + mode);
+
+ _errorMode = mode;
+ }
+ }
+
+ /***************************************************************
+ * Internal classes used by RemotingConfiguration.Configure () *
+ ***************************************************************/
+
+ internal class RReader : MiniParser.IReader {
+ private string xml; // custom remoting config file
+ private int pos;
+
+ public RReader (string filename)
+ {
+ try {
+ StreamReader sr = new StreamReader (filename);
+ xml = sr.ReadToEnd ();
+ sr.Close ();
+ }
+ catch {
+ xml = null;
+ }
+ }
+
+ public int Read () {
+ try {
+ return (int) xml[pos++];
+ }
+ catch {
+ return -1;
+ }
+ }
+ }
+
+ internal class ConfigHandler : MiniParser.IHandler
+ {
+ ArrayList typeEntries = new ArrayList ();
+ ArrayList channelInstances = new ArrayList ();
+
+ ChannelData currentChannel = null;
+ Stack currentProviderData = null;
+
+ string currentClientUrl = null;
+ string appName;
+
+ string currentXmlPath = "";
+
+ public ConfigHandler ()
+ {
+ }
+
+ void ValidatePath (string element, params string[] paths)
+ {
+ foreach (string path in paths)
+ if (CheckPath (path)) return;
+
+ throw new RemotingException ("Element " + element + " not allowed in this context");
+ }
+
+ bool CheckPath (string path)
+ {
+ if (path.StartsWith ("/"))
+ return path == currentXmlPath;
+ else
+ return currentXmlPath.EndsWith (path);
+ }
+
+ public void OnStartParsing (MiniParser parser) {}
+
+ public void OnStartElement (string name, MiniParser.IAttrList attrs)
+ {
+ try
+ {
+ if (currentXmlPath.StartsWith ("/configuration/system.runtime.remoting"))
+ ParseElement (name, attrs);
+
+ currentXmlPath += "/" + name;
+ }
+ catch (Exception ex)
+ {
+ throw new RemotingException ("Error in element " + name + ": " + ex.Message);
+ }
+ }
+
+ public void ParseElement (string name, MiniParser.IAttrList attrs)
+ {
+ if (currentProviderData != null)
+ {
+ ReadCustomProviderData (name, attrs);
+ return;
+ }
+
+ switch (name)
+ {
+ case "application":
+ ValidatePath (name, "system.runtime.remoting");
+ if (attrs.Names.Length > 0)
+ appName = attrs.Values[0];
+ break;
+
+ case "lifetime":
+ ValidatePath (name, "application");
+ ReadLifetine (attrs);
+ break;
+
+ case "channels":
+ ValidatePath (name, "system.runtime.remoting", "application");
+ break;
+
+ case "channel":
+ ValidatePath (name, "channels");
+ if (currentXmlPath.IndexOf ("application") != -1)
+ ReadChannel (attrs, false);
+ else
+ ReadChannel (attrs, true);
+ break;
+
+ case "serverProviders":
+ ValidatePath (name, "channelSinkProviders", "channel");
+ break;
+
+ case "clientProviders":
+ ValidatePath (name, "channelSinkProviders", "channel");
+ break;
+
+ case "provider":
+ case "formatter":
+ ProviderData prov;
+
+ if (CheckPath ("application/channels/channel/serverProviders") ||
+ CheckPath ("channels/channel/serverProviders"))
+ {
+ prov = ReadProvider (name, attrs, false);
+ currentChannel.ServerProviders.Add (prov);
+ }
+ else if (CheckPath ("application/channels/channel/clientProviders") ||
+ CheckPath ("channels/channel/clientProviders"))
+ {
+ prov = ReadProvider (name, attrs, false);
+ currentChannel.ClientProviders.Add (prov);
+ }
+ else if (CheckPath ("channelSinkProviders/serverProviders"))
+ {
+ prov = ReadProvider (name, attrs, true);
+ RemotingConfiguration.RegisterServerProviderTemplate (prov);
+ }
+ else if (CheckPath ("channelSinkProviders/clientProviders"))
+ {
+ prov = ReadProvider (name, attrs, true);
+ RemotingConfiguration.RegisterClientProviderTemplate (prov);
+ }
+ else
+ ValidatePath (name);
+ break;
+
+ case "client":
+ ValidatePath (name, "application");
+ currentClientUrl = attrs.GetValue ("url");
+ break;
+
+ case "service":
+ ValidatePath (name, "application");
+ break;
+
+ case "wellknown":
+ ValidatePath (name, "client", "service");
+ if (CheckPath ("client"))
+ ReadClientWellKnown (attrs);
+ else
+ ReadServiceWellKnown (attrs);
+ break;
+
+ case "activated":
+ ValidatePath (name, "client", "service");
+ if (CheckPath ("client"))
+ ReadClientActivated (attrs);
+ else
+ ReadServiceActivated (attrs);
+ break;
+
+ case "soapInterop":
+ ValidatePath (name, "application");
+ break;
+
+ case "interopXmlType":
+ ValidatePath (name, "soapInterop");
+ ReadInteropXml (attrs, false);
+ break;
+
+ case "interopXmlElement":
+ ValidatePath (name, "soapInterop");
+ ReadInteropXml (attrs, false);
+ break;
+
+ case "preLoad":
+ ValidatePath (name, "soapInterop");
+ ReadPreload (attrs);
+ break;
+
+ case "debug":
+ ValidatePath (name, "system.runtime.remoting");
+ break;
+
+ case "channelSinkProviders":
+ ValidatePath (name, "system.runtime.remoting");
+ break;
+
+ case "customErrors":
+ ValidatePath (name, "system.runtime.remoting");
+ RemotingConfiguration.SetCustomErrorsMode (attrs.GetValue ("mode"));
+ break;
+
+ default:
+ throw new RemotingException ("Element '" + name + "' is not valid in system.remoting.configuration section");
+ }
+ }
+
+ public void OnEndElement (string name)
+ {
+ if (currentProviderData != null)
+ {
+ currentProviderData.Pop ();
+ if (currentProviderData.Count > 0) return;
+ currentProviderData = null;
+ }
+
+ currentXmlPath = currentXmlPath.Substring (0, currentXmlPath.Length - name.Length - 1);
+ }
+
+ void ReadCustomProviderData (string name, MiniParser.IAttrList attrs)
+ {
+ SinkProviderData parent = (SinkProviderData) currentProviderData.Peek ();
+
+ SinkProviderData data = new SinkProviderData (name);
+ for (int i=0; i < attrs.Names.Length; ++i)
+ data.Properties [attrs.Names[i]] = attrs.GetValue (i);
+
+ parent.Children.Add (data);
+ currentProviderData.Push (data);
+ }
+ void ReadLifetine (MiniParser.IAttrList attrs)
+ {
+ for (int i=0; i < attrs.Names.Length; ++i) {
+ switch (attrs.Names[i]) {
+ case "leaseTime":
+ LifetimeServices.LeaseTime = ParseTime (attrs.GetValue(i));
+ break;
+ case "sponsorShipTimeOut":
+ LifetimeServices.SponsorshipTimeout = ParseTime (attrs.GetValue(i));
+ break;
+ case "renewOnCallTime":
+ LifetimeServices.RenewOnCallTime = ParseTime (attrs.GetValue(i));
+ break;
+ case "leaseManagerPollTime":
+ LifetimeServices.LeaseManagerPollTime = ParseTime (attrs.GetValue(i));
+ break;
+ default:
+ throw new RemotingException ("Invalid attribute: " + attrs.Names[i]);
+ }
+ }
+ }
+
+ TimeSpan ParseTime (string s)
+ {
+ if (s == "" || s == null) throw new RemotingException ("Invalid time value");
+
+ int i = s.IndexOfAny (new char[] { 'D','H','M','S' });
+
+ string unit;
+ if (i == -1)
+ unit = "S";
+ else {
+ unit = s.Substring (i);
+ s = s.Substring (0,i);
+ }
+ double val;
+
+ try {
+ val = double.Parse (s);
+ }
+ catch {
+ throw new RemotingException ("Invalid time value: " + s);
+ }
+
+ if (unit == "D") return TimeSpan.FromDays (val);
+ if (unit == "H") return TimeSpan.FromHours (val);
+ if (unit == "M") return TimeSpan.FromMinutes (val);
+ if (unit == "S") return TimeSpan.FromSeconds (val);
+ if (unit == "MS") return TimeSpan.FromMilliseconds (val);
+ throw new RemotingException ("Invalid time unit: " + unit);
+ }
+
+ void ReadChannel (MiniParser.IAttrList attrs, bool isTemplate)
+ {
+ ChannelData channel = new ChannelData ();
+
+ for (int i=0; i < attrs.Names.Length; ++i)
+ {
+ string at = attrs.Names[i];
+ string val = attrs.Values[i];
+
+ if (at == "ref" && !isTemplate)
+ channel.Ref = val;
+ else if (at == "delayLoadAsClientChannel")
+ channel.DelayLoadAsClientChannel = val;
+ else if (at == "id" && isTemplate)
+ channel.Id = val;
+ else if (at == "type")
+ channel.Type = val;
+ else
+ channel.CustomProperties.Add (at, val);
+ }
+
+ if (isTemplate)
+ {
+ if (channel.Id == null) throw new RemotingException ("id attribute is required");
+ if (channel.Type == null) throw new RemotingException ("id attribute is required");
+ RemotingConfiguration.RegisterChannelTemplate (channel);
+ }
+ else
+ channelInstances.Add (channel);
+
+ currentChannel = channel;
+ }
+
+ ProviderData ReadProvider (string name, MiniParser.IAttrList attrs, bool isTemplate)
+ {
+ ProviderData prov = (name == "provider") ? new ProviderData () : new FormatterData ();
+ SinkProviderData data = new SinkProviderData ("root");
+ prov.CustomData = data.Children;
+
+ currentProviderData = new Stack ();
+ currentProviderData.Push (data);
+
+ for (int i=0; i < attrs.Names.Length; ++i)
+ {
+ string at = attrs.Names[i];
+ string val = attrs.Values[i];
+
+ if (at == "id" && isTemplate)
+ prov.Id = val;
+ if (at == "type")
+ prov.Type = val;
+ if (at == "ref" && !isTemplate)
+ prov.Ref = val;
+ else
+ prov.CustomProperties.Add (at, val);
+ }
+
+ if (prov.Id == null && isTemplate) throw new RemotingException ("id attribute is required");
+ return prov;
+ }
+
+ void ReadClientActivated (MiniParser.IAttrList attrs)
+ {
+ string type = GetNotNull (attrs, "type");
+ string assm = ExtractAssembly (ref type);
+
+ if (currentClientUrl == null || currentClientUrl == "")
+ throw new RemotingException ("url attribute is required in client element when it contains activated entries");
+
+ typeEntries.Add (new ActivatedClientTypeEntry (type, assm, currentClientUrl));
+ }
+
+ void ReadServiceActivated (MiniParser.IAttrList attrs)
+ {
+ string type = GetNotNull (attrs, "type");
+ string assm = ExtractAssembly (ref type);
+
+ typeEntries.Add (new ActivatedServiceTypeEntry (type, assm));
+ }
+
+ void ReadClientWellKnown (MiniParser.IAttrList attrs)
+ {
+ string url = GetNotNull (attrs, "url");
+ string type = GetNotNull (attrs, "type");
+ string assm = ExtractAssembly (ref type);
+
+ typeEntries.Add (new WellKnownClientTypeEntry (type, assm, url));
+ }
+
+ void ReadServiceWellKnown (MiniParser.IAttrList attrs)
+ {
+ string objectUri = GetNotNull (attrs, "objectUri");
+ string smode = GetNotNull (attrs, "mode");
+ string type = GetNotNull (attrs, "type");
+ string assm = ExtractAssembly (ref type);
+
+ WellKnownObjectMode mode;
+ if (smode == "SingleCall") mode = WellKnownObjectMode.SingleCall;
+ else if (smode == "Singleton") mode = WellKnownObjectMode.Singleton;
+ else throw new RemotingException ("wellknown object mode '" + smode + "' is invalid");
+
+ typeEntries.Add (new WellKnownServiceTypeEntry (type, assm, objectUri, mode));
+ }
+
+ void ReadInteropXml (MiniParser.IAttrList attrs, bool isElement)
+ {
+ Type t = Type.GetType (GetNotNull (attrs, "clr"));
+ string[] xmlName = GetNotNull (attrs, "xml").Split (',');
+ string localName = xmlName [0].Trim ();
+ string ns = xmlName.Length > 0 ? xmlName[1].Trim() : null;
+
+ if (isElement) SoapServices.RegisterInteropXmlElement (localName, ns, t);
+ else SoapServices.RegisterInteropXmlType (localName, ns, t);
+ }
+
+ void ReadPreload (MiniParser.IAttrList attrs)
+ {
+ string type = attrs.GetValue ("type");
+ string assm = attrs.GetValue ("assembly");
+
+ if (type != null && assm != null)
+ throw new RemotingException ("Type and assembly attributes cannot be specified together");
+
+ if (type != null)
+ SoapServices.PreLoad (Type.GetType (type));
+ else if (assm != null)
+ SoapServices.PreLoad (Assembly.Load (assm));
+ else
+ throw new RemotingException ("Either type or assembly attributes must be specified");
+ }
+
+ string GetNotNull (MiniParser.IAttrList attrs, string name)
+ {
+ string value = attrs.GetValue (name);
+ if (value == null || value == "")
+ throw new RemotingException (name + " attribute is required");
+ return value;
+ }
+
+ string ExtractAssembly (ref string type)
+ {
+ int i = type.IndexOf (',');
+ if (i == -1) return "";
+
+ string asm = type.Substring (i+1).Trim();
+ type = type.Substring (0, i).Trim();
+ return asm;
+ }
+
+ public void OnChars (string ch) {}
+
+ public void OnEndParsing (MiniParser parser)
+ {
+ RemotingConfiguration.RegisterChannels (channelInstances);
+ RemotingConfiguration.RegisterTypes (typeEntries);
+ }
+ }
+
+
+ /*******************************************************************
+ * Internal data structures used by ConfigHandler, to store *
+ * machine.config's remoting related data. *
+ * If having them implemented this way, makes configuration too *
+ * slow, we can use string arrays. *
+ *******************************************************************/
+
+ internal class ChannelData {
+ internal string Ref;
+ internal string Type;
+ internal string Id;
+ internal string DelayLoadAsClientChannel;
+
+ ArrayList _serverProviders = new ArrayList ();
+ ArrayList _clientProviders = new ArrayList ();
+ Hashtable _customProperties = new Hashtable ();
+
+ internal ArrayList ServerProviders {
+ get {
+ if (_serverProviders == null) _serverProviders = new ArrayList ();
+ return _serverProviders;
+ }
+ }
+
+ public ArrayList ClientProviders {
+ get {
+ if (_clientProviders == null) _clientProviders = new ArrayList ();
+ return _clientProviders;
+ }
+ }
+
+ public Hashtable CustomProperties {
+ get {
+ if (_customProperties == null) _customProperties = new Hashtable ();
+ return _customProperties;
+ }
+ }
+
+ public void CopyFrom (ChannelData other)
+ {
+ if (Ref == null) Ref = other.Ref;
+ if (Id == null) Id = other.Id;
+ if (Type == null) Type = other.Type;
+ if (DelayLoadAsClientChannel == null) DelayLoadAsClientChannel = other.DelayLoadAsClientChannel;
+
+ if (other._customProperties != null)
+ {
+ foreach (DictionaryEntry entry in other._customProperties)
+ if (!CustomProperties.ContainsKey (entry.Key))
+ CustomProperties [entry.Key] = entry.Value;
+ }
+
+ if (_serverProviders == null && other._serverProviders != null)
+ {
+ foreach (ProviderData prov in other._serverProviders)
+ {
+ ProviderData np = new ProviderData();
+ np.CopyFrom (prov);
+ ServerProviders.Add (np);
+ }
+ }
+
+ if (_clientProviders == null && other._clientProviders != null)
+ {
+ foreach (ProviderData prov in other._clientProviders)
+ {
+ ProviderData np = new ProviderData();
+ np.CopyFrom (prov);
+ ClientProviders.Add (np);
+ }
+ }
+ }
+ }
+
+ internal class ProviderData {
+ internal string Ref;
+ internal string Type;
+ internal string Id;
+
+ internal Hashtable CustomProperties = new Hashtable ();
+ internal IList CustomData;
+
+ public void CopyFrom (ProviderData other)
+ {
+ if (Ref == null) Ref = other.Ref;
+ if (Id == null) Id = other.Id;
+ if (Type == null) Type = other.Type;
+
+ foreach (DictionaryEntry entry in other.CustomProperties)
+ if (!CustomProperties.ContainsKey (entry.Key))
+ CustomProperties [entry.Key] = entry.Value;
+
+ if (other.CustomData != null)
+ {
+ if (CustomData == null) CustomData = new ArrayList ();
+ foreach (SinkProviderData data in other.CustomData)
+ CustomData.Add (data);
+ }
+ }
+ }
+
+ internal class FormatterData: ProviderData {
+ }
+}
diff --git a/mcs/class/corlib/System.Runtime.Remoting/RemotingServices.cs b/mcs/class/corlib/System.Runtime.Remoting/RemotingServices.cs
index db59cc84130..68b3c441cb1 100644
--- a/mcs/class/corlib/System.Runtime.Remoting/RemotingServices.cs
+++ b/mcs/class/corlib/System.Runtime.Remoting/RemotingServices.cs
@@ -166,8 +166,6 @@ namespace System.Runtime.Remoting
public static object Unmarshal (ObjRef objref, bool fRefine)
{
- // FIXME: use type name when fRefine==true
-
Type classToProxy = fRefine ? objref.ServerType : typeof (MarshalByRefObject);
if (classToProxy == null) classToProxy = typeof (MarshalByRefObject);
@@ -247,7 +245,7 @@ namespace System.Runtime.Remoting
static string NewUri ()
{
int n = Interlocked.Increment (ref next_id);
- return app_id + Environment.TickCount + "_" + n;
+ return app_id + Environment.TickCount + "_" + n + ".rem";
}
public static RealProxy GetRealProxy (object proxy)
@@ -303,14 +301,15 @@ namespace System.Runtime.Remoting
throw new NotImplementedException ();
}
- [MonoTODO]
public static string GetSessionIdForMethodMessage(IMethodMessage msg)
{
- throw new NotImplementedException ();
+ // It seems that this it what MS returns.
+ return msg.Uri;
}
public static bool IsMethodOverloaded(IMethodMessage msg)
{
+ // TODO: use internal call for better performance
Type type = msg.MethodBase.DeclaringType;
MemberInfo[] members = type.GetMember (msg.MethodName, MemberTypes.Method, BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance);
return members.Length > 1;
@@ -318,6 +317,7 @@ namespace System.Runtime.Remoting
public static bool IsObjectOutOfAppDomain(object tp)
{
+ // TODO: use internal call for better performance
Identity ident = GetObjectIdentity((MarshalByRefObject)tp);
if (ident != null) return !ident.IsFromThisAppDomain;
else return false;
@@ -325,6 +325,7 @@ namespace System.Runtime.Remoting
public static bool IsObjectOutOfContext(object tp)
{
+ // TODO: use internal call for better performance
ServerIdentity ident = GetObjectIdentity((MarshalByRefObject)tp) as ServerIdentity;
if (ident != null) return ident.Context != System.Threading.Thread.CurrentContext;
else return false;
@@ -337,7 +338,7 @@ namespace System.Runtime.Remoting
return atts.Length > 0;
}
- public static bool IsAsyncMessage(IMessage msg)
+ internal static bool IsAsyncMessage(IMessage msg)
{
if (! (msg is MonoMethodMessage)) return false;
else if (((MonoMethodMessage)msg).IsAsync) return true;
diff --git a/mcs/class/corlib/System.Runtime.Remoting/ServerIdentity.cs b/mcs/class/corlib/System.Runtime.Remoting/ServerIdentity.cs
index 27ccd77cd3d..2d0e7c60c8a 100644
--- a/mcs/class/corlib/System.Runtime.Remoting/ServerIdentity.cs
+++ b/mcs/class/corlib/System.Runtime.Remoting/ServerIdentity.cs
@@ -142,7 +142,7 @@ namespace System.Runtime.Remoting
lock (this)
{
if (_serverObject == null) {
- MarshalByRefObject server = (MarshalByRefObject) Activator.CreateInstance (_objectType);
+ MarshalByRefObject server = (MarshalByRefObject) Activator.CreateInstance (_objectType, true);
AttachServerObject (server, Context.DefaultContext);
StartTrackingLifetime ((ILease)server.InitializeLifetimeService ());
}
@@ -175,7 +175,7 @@ namespace System.Runtime.Remoting
{
// SingleCallIdentity creates and disposes an instance in each call
- MarshalByRefObject obj = (MarshalByRefObject)Activator.CreateInstance (_objectType);
+ MarshalByRefObject obj = (MarshalByRefObject)Activator.CreateInstance (_objectType, true);
obj.ObjectIdentity = this;
IMessageSink serverSink = _context.CreateServerObjectSinkChain(obj);
IMessage result = serverSink.SyncProcessMessage (msg);
@@ -185,7 +185,7 @@ namespace System.Runtime.Remoting
public override IMessageCtrl AsyncObjectProcessMessage (IMessage msg, IMessageSink replySink)
{
- MarshalByRefObject obj = (MarshalByRefObject)Activator.CreateInstance (_objectType);
+ MarshalByRefObject obj = (MarshalByRefObject)Activator.CreateInstance (_objectType, true);
IMessageSink serverSink = _context.CreateServerObjectSinkChain(obj);
if (obj is IDisposable) replySink = new DisposerReplySink(replySink, ((IDisposable)obj));
return serverSink.AsyncProcessMessage (msg, replySink);
diff --git a/mcs/class/corlib/System.Runtime.Remoting/SoapServices.cs b/mcs/class/corlib/System.Runtime.Remoting/SoapServices.cs
index 0fca23bef2e..45a74cc0de9 100644
--- a/mcs/class/corlib/System.Runtime.Remoting/SoapServices.cs
+++ b/mcs/class/corlib/System.Runtime.Remoting/SoapServices.cs
@@ -2,23 +2,38 @@
// System.Runtime.Remoting.SoapServices.cs
//
// Author: Jaime Anguiano Olarra (jaime@gnome.org)
-// Lluis Sanchez Gual (lsg@ctv.es)
+// Lluis Sanchez Gual (lluis@ximian.com)
//
// (c) 2002, Jaime Anguiano Olarra
//
using System;
+using System.Collections;
using System.Runtime.Remoting;
+using System.Runtime.Remoting.Metadata;
using System.Reflection;
using System.Runtime.InteropServices;
namespace System.Runtime.Remoting {
- [Serializable]
- [ClassInterface (ClassInterfaceType.AutoDual)]
public class SoapServices
{
+ static Hashtable _xmlTypes = new Hashtable ();
+ static Hashtable _xmlElements = new Hashtable ();
+ static Hashtable _soapActions = new Hashtable ();
+ static Hashtable _soapActionsMethods = new Hashtable ();
+ static Hashtable _typeInfos = new Hashtable ();
+
+ class TypeInfo
+ {
+ public Hashtable Attributes;
+ public Hashtable Elements;
+ }
+
+ // Private constructor: nobody instantiates this class
+ private SoapServices () {}
+
// properties
public static string XmlNsForClrType
@@ -84,33 +99,62 @@ namespace System.Runtime.Remoting {
return false;
}
- [MonoTODO]
public static void GetInteropFieldTypeAndNameFromXmlAttribute (Type containingType,
- string xmlAttribute,
- string xmlNamespace,
- out Type type,
- out string name) {
- throw new NotImplementedException ();
-
+ string xmlAttribute, string xmlNamespace,
+ out Type type, out string name)
+ {
+ TypeInfo tf = (TypeInfo) _typeInfos [containingType];
+ Hashtable ht = tf != null ? tf.Attributes : null;
+ GetInteropFieldInfo (ht, xmlAttribute, xmlNamespace, out type, out name);
}
- [MonoTODO]
public static void GetInteropFieldTypeAndNameFromXmlElement (Type containingType,
- string xmlElement,
- string xmlNamespace,
- out Type type,
- out string name) {
- throw new NotImplementedException ();
+ string xmlElement, string xmlNamespace,
+ out Type type, out string name)
+ {
+ TypeInfo tf = (TypeInfo) _typeInfos [containingType];
+ Hashtable ht = tf != null ? tf.Elements : null;
+ GetInteropFieldInfo (ht, xmlElement, xmlNamespace, out type, out name);
}
- [MonoTODO]
- public static Type GetInteropTypeFromXmlElement (string xmlElement, string xmlNamespace) {
- throw new NotImplementedException ();
+ static void GetInteropFieldInfo (Hashtable fields,
+ string xmlName, string xmlNamespace,
+ out Type type, out string name)
+ {
+ if (fields != null)
+ {
+ FieldInfo field = (FieldInfo) fields [GetNameKey (xmlName, xmlNamespace)];
+ if (field != null)
+ {
+ type = field.FieldType;
+ name = field.Name;
+ return;
+ }
+ }
+ type = null;
+ name = null;
+ }
+
+ static string GetNameKey (string name, string namspace)
+ {
+ if (namspace == null) return name;
+ else return name + " " + namspace;
+ }
+
+ public static Type GetInteropTypeFromXmlElement (string xmlElement, string xmlNamespace)
+ {
+ lock (_xmlElements.SyncRoot)
+ {
+ return (Type) _xmlElements [xmlElement + " " + xmlNamespace];
+ }
}
- [MonoTODO]
- public static Type GetInteropTypeFromXmlType (string xmlType, string xmlTypeNamespace) {
- throw new NotImplementedException ();
+ public static Type GetInteropTypeFromXmlType (string xmlType, string xmlTypeNamespace)
+ {
+ lock (_xmlTypes.SyncRoot)
+ {
+ return (Type) _xmlTypes [xmlType + " " + xmlTypeNamespace];
+ }
}
private static string GetAssemblyName(MethodBase mb)
@@ -123,18 +167,24 @@ namespace System.Runtime.Remoting {
public static string GetSoapActionFromMethodBase (MethodBase mb)
{
- string ns = CodeXmlNamespaceForClrTypeNamespace (mb.DeclaringType.Name, GetAssemblyName(mb));
- return ns + "#" + mb.Name;
- }
-
- [MonoTODO]
- public new Type GetType () {
- throw new NotImplementedException ();
+ return InternalGetSoapAction (mb);
}
public static bool GetTypeAndMethodNameFromSoapAction (string soapAction,
out string typeName,
- out string methodName) {
+ out string methodName)
+ {
+ lock (_soapActions.SyncRoot)
+ {
+ MethodBase mb = (MethodBase) _soapActionsMethods [soapAction];
+ if (mb != null)
+ {
+ typeName = mb.DeclaringType.AssemblyQualifiedName;
+ methodName = mb.Name;
+ return true;
+ }
+ }
+
string type;
string assembly;
@@ -157,30 +207,45 @@ namespace System.Runtime.Remoting {
return true;
}
- [MonoTODO]
- public static bool GetXmlElementForInteropType (Type type,
- out string xmlElement,
- out string xmlNamespace) {
- throw new NotImplementedException ();
-
+ public static bool GetXmlElementForInteropType (Type type, out string xmlElement, out string xmlNamespace)
+ {
+ SoapTypeAttribute att = (SoapTypeAttribute) InternalRemotingServices.GetCachedSoapAttribute (type);
+ if (!att.IsInteropXmlElement)
+ {
+ xmlElement = null;
+ xmlNamespace = null;
+ return false;
+ }
+
+ xmlElement = att.XmlElementName;
+ xmlNamespace = att.XmlNamespace;
+ return true;
}
public static string GetXmlNamespaceForMethodCall (MethodBase mb)
{
- return CodeXmlNamespaceForClrTypeNamespace (mb.DeclaringType.Name, GetAssemblyName(mb));
+ return CodeXmlNamespaceForClrTypeNamespace (mb.DeclaringType.FullName, GetAssemblyName(mb));
}
public static string GetXmlNamespaceForMethodResponse (MethodBase mb)
{
- return CodeXmlNamespaceForClrTypeNamespace (mb.DeclaringType.Name, GetAssemblyName(mb));
+ return CodeXmlNamespaceForClrTypeNamespace (mb.DeclaringType.FullName, GetAssemblyName(mb));
}
- [MonoTODO]
- public static bool GetXmlTypeForInteropType (Type type,
- out string xmlType,
- out string xmlTypeNamespace) {
- throw new NotImplementedException ();
-
+ public static bool GetXmlTypeForInteropType (Type type, out string xmlType, out string xmlTypeNamespace)
+ {
+ SoapTypeAttribute att = (SoapTypeAttribute) InternalRemotingServices.GetCachedSoapAttribute (type);
+
+ if (!att.IsInteropXmlType)
+ {
+ xmlType = null;
+ xmlTypeNamespace = null;
+ return false;
+ }
+
+ xmlType = att.XmlTypeName;
+ xmlTypeNamespace = att.XmlTypeNamespace;
+ return true;
}
public static bool IsClrTypeNamespace (string namespaceString)
@@ -196,47 +261,98 @@ namespace System.Runtime.Remoting {
if (methodName != mb.Name) return false;
- string methodClassType = mb.DeclaringType.FullName + ", " + mb.DeclaringType.Assembly.GetName().Name;
+ string methodClassType = mb.DeclaringType.AssemblyQualifiedName;
return typeName == methodClassType;
}
- [MonoTODO]
- public static void PreLoad (Assembly assembly) {
- throw new NotImplementedException ();
-
+ public static void PreLoad (Assembly assembly)
+ {
+ foreach (Type t in assembly.GetTypes ())
+ PreLoad (t);
}
- [MonoTODO]
- public static void PreLoad (Type type) {
- throw new NotImplementedException ();
-
+ public static void PreLoad (Type type)
+ {
+ string name, namspace;
+ TypeInfo tf = _typeInfos [type] as TypeInfo;
+ if (tf != null) return;
+
+ if (GetXmlTypeForInteropType (type, out name, out namspace))
+ RegisterInteropXmlType (name, namspace, type);
+
+ if (GetXmlElementForInteropType (type, out name, out namspace))
+ RegisterInteropXmlElement (name, namspace, type);
+
+ lock (_typeInfos.SyncRoot)
+ {
+ tf = new TypeInfo ();
+ FieldInfo[] fields = type.GetFields (BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
+
+ foreach (FieldInfo field in fields)
+ {
+ SoapFieldAttribute att = (SoapFieldAttribute) InternalRemotingServices.GetCachedSoapAttribute (field);
+ if (!att.IsInteropXmlElement ()) continue;
+
+ string key = GetNameKey (att.XmlElementName, att.XmlNamespace);
+ if (att.UseAttribute)
+ {
+ if (tf.Attributes == null) tf.Attributes = new Hashtable ();
+ tf.Attributes [key] = field;
+ }
+ else
+ {
+ if (tf.Elements == null) tf.Elements = new Hashtable ();
+ tf.Elements [key] = field;
+ }
+ }
+ _typeInfos [type] = tf;
+ }
}
- [MonoTODO]
- public static void RegisterInteropXmlElement (string xmlElement,
- string xmlNamespace,
- Type type) {
- throw new NotImplementedException ();
-
+ public static void RegisterInteropXmlElement (string xmlElement, string xmlNamespace, Type type)
+ {
+ lock (_xmlElements.SyncRoot)
+ {
+ _xmlElements [xmlElement + " " + xmlNamespace] = type;
+ }
}
- [MonoTODO]
- public static void RegisterInteropXmlType (string xmlType,
- string xmlTypeNamespace,
- Type type) {
- throw new NotImplementedException ();
-
+ public static void RegisterInteropXmlType (string xmlType, string xmlTypeNamespace, Type type)
+ {
+ lock (_xmlTypes.SyncRoot)
+ {
+ _xmlTypes [xmlType + " " + xmlTypeNamespace] = type;
+ }
}
- [MonoTODO]
- public static void RegisterSoapActionForMethodBase (MethodBase mb) {
- throw new NotImplementedException ();
-
+ public static void RegisterSoapActionForMethodBase (MethodBase mb)
+ {
+ InternalGetSoapAction (mb);
+ }
+
+ static string InternalGetSoapAction (MethodBase mb)
+ {
+ lock (_soapActions.SyncRoot)
+ {
+ string action = (string) _soapActions [mb];
+ if (action == null)
+ {
+ SoapMethodAttribute att = (SoapMethodAttribute) InternalRemotingServices.GetCachedSoapAttribute (mb);
+ action = att.SoapAction;
+ _soapActions [mb] = action;
+ _soapActionsMethods [action] = mb;
+ }
+ return action;
+ }
}
- [MonoTODO]
- public static void RegisterSoapActionForMethodBase (MethodBase mb, string soapAction) {
- throw new NotImplementedException ();
+ public static void RegisterSoapActionForMethodBase (MethodBase mb, string soapAction)
+ {
+ lock (_soapActions.SyncRoot)
+ {
+ _soapActions [mb] = soapAction;
+ _soapActionsMethods [soapAction] = mb;
+ }
}
}
}
diff --git a/mcs/class/corlib/System.Runtime.Remoting/TypeInfo.cs b/mcs/class/corlib/System.Runtime.Remoting/TypeInfo.cs
index 7e803be93b6..f859c9d1c24 100644
--- a/mcs/class/corlib/System.Runtime.Remoting/TypeInfo.cs
+++ b/mcs/class/corlib/System.Runtime.Remoting/TypeInfo.cs
@@ -72,8 +72,8 @@ namespace System.Runtime.Remoting
// Find the type comparing the name of the type and the name of the assembly,
// excluding version and other assembly info
- int i = fromName.IndexOf (",");
- if (i != -1) i = fromName.IndexOf (",", i+1);
+ int i = fromName.IndexOf (',');
+ if (i != -1) i = fromName.IndexOf (',', i+1);
if (i != -1) fromName = fromName.Substring (0,i+1);
else fromName += ",";
diff --git a/mcs/class/corlib/System.Runtime.Remoting/WellKnownClientTypeEntry.cs b/mcs/class/corlib/System.Runtime.Remoting/WellKnownClientTypeEntry.cs
index e361bb5a758..65a31e76eb5 100644
--- a/mcs/class/corlib/System.Runtime.Remoting/WellKnownClientTypeEntry.cs
+++ b/mcs/class/corlib/System.Runtime.Remoting/WellKnownClientTypeEntry.cs
@@ -27,10 +27,13 @@ namespace System.Runtime.Remoting {
public WellKnownClientTypeEntry (string typeName, string assemblyName, string objectUrl)
{
+ obj_url = objectUrl;
AssemblyName = assemblyName;
TypeName = typeName;
Assembly a = Assembly.Load (assemblyName);
obj_type = a.GetType (typeName);
+ if (obj_type == null)
+ throw new RemotingException ("Type not found: " + typeName + ", " + assemblyName);
}
public string ApplicationUrl {
diff --git a/mcs/class/corlib/System.Runtime.Remoting/WellKnownServiceTypeEntry.cs b/mcs/class/corlib/System.Runtime.Remoting/WellKnownServiceTypeEntry.cs
index e97b5038ba5..971d5b69ae4 100644
--- a/mcs/class/corlib/System.Runtime.Remoting/WellKnownServiceTypeEntry.cs
+++ b/mcs/class/corlib/System.Runtime.Remoting/WellKnownServiceTypeEntry.cs
@@ -36,6 +36,8 @@ namespace System.Runtime.Remoting {
obj_type = a.GetType (typeName);
obj_uri = objectUri;
obj_mode = mode;
+ if (obj_type == null)
+ throw new RemotingException ("Type not found: " + typeName + ", " + assemblyName);
}
public IContextAttribute [] ContextAttributes {
@@ -55,10 +57,9 @@ namespace System.Runtime.Remoting {
get { return obj_uri; }
}
- [MonoTODO]
public override string ToString ()
{
- return TypeName + AssemblyName + ObjectUri;
+ return TypeName + ", " + AssemblyName + " " + ObjectUri;
}
}
}
diff --git a/mcs/class/corlib/System.Runtime.Serialization.Formatters.Binary/BinaryFormatter.cs b/mcs/class/corlib/System.Runtime.Serialization.Formatters.Binary/BinaryFormatter.cs
index 7309eb923bb..0c0c211c7f0 100755
--- a/mcs/class/corlib/System.Runtime.Serialization.Formatters.Binary/BinaryFormatter.cs
+++ b/mcs/class/corlib/System.Runtime.Serialization.Formatters.Binary/BinaryFormatter.cs
@@ -14,14 +14,19 @@ using System.IO;
using System.Runtime.Remoting.Messaging;
namespace System.Runtime.Serialization.Formatters.Binary {
+
public sealed class BinaryFormatter : IRemotingFormatter, IFormatter
{
- private FormatterAssemblyStyle assembly_format; // TODO: Do something with this
+ private FormatterAssemblyStyle assembly_format = FormatterAssemblyStyle.Full;
private SerializationBinder binder;
private StreamingContext context;
private ISurrogateSelector surrogate_selector;
private FormatterTypeStyle type_format; // TODO: Do something with this
+#if NET_1_1
+ private TypeFilterLevel filter_level;
+#endif
+
public BinaryFormatter()
{
surrogate_selector=null;
@@ -84,6 +89,15 @@ namespace System.Runtime.Serialization.Formatters.Binary {
}
}
+#if NET_1_1
+ [System.Runtime.InteropServices.ComVisible (false)]
+ public TypeFilterLevel FilterLevel
+ {
+ get { return filter_level; }
+ set { filter_level = value; }
+ }
+#endif
+
public object Deserialize(Stream serializationStream)
{
return Deserialize (serializationStream, null);
@@ -112,13 +126,13 @@ namespace System.Runtime.Serialization.Formatters.Binary {
BinaryElement elem = (BinaryElement) reader.PeekChar();
if (elem == BinaryElement.MethodCall) {
- return MessageFormatter.ReadMethodCall (reader, hasHeader, handler, surrogate_selector, context, binder);
+ return MessageFormatter.ReadMethodCall (reader, hasHeader, handler, this);
}
else if (elem == BinaryElement.MethodResponse) {
- return MessageFormatter.ReadMethodResponse (reader, hasHeader, handler, null, surrogate_selector, context, binder);
+ return MessageFormatter.ReadMethodResponse (reader, hasHeader, handler, null, this);
}
else {
- ObjectReader serializer = new ObjectReader (surrogate_selector, context, binder);
+ ObjectReader serializer = new ObjectReader (this);
object result;
Header[] headers;
@@ -142,7 +156,7 @@ namespace System.Runtime.Serialization.Formatters.Binary {
bool hasHeader;
ReadBinaryHeader (reader, out hasHeader);
- return MessageFormatter.ReadMethodResponse (reader, hasHeader, handler, methodCallmessage, surrogate_selector, context, binder);
+ return MessageFormatter.ReadMethodResponse (reader, hasHeader, handler, methodCallmessage, this);
}
public void Serialize(Stream serializationStream, object graph)
@@ -160,18 +174,32 @@ namespace System.Runtime.Serialization.Formatters.Binary {
WriteBinaryHeader (writer, headers!=null);
if (graph is IMethodCallMessage) {
- MessageFormatter.WriteMethodCall (writer, graph, headers, surrogate_selector, context);
+ MessageFormatter.WriteMethodCall (writer, graph, headers, surrogate_selector, context, assembly_format);
}
else if (graph is IMethodReturnMessage) {
- MessageFormatter.WriteMethodResponse (writer, graph, headers, surrogate_selector, context);
+ MessageFormatter.WriteMethodResponse (writer, graph, headers, surrogate_selector, context, assembly_format);
}
else {
- ObjectWriter serializer = new ObjectWriter (surrogate_selector, context);
+ ObjectWriter serializer = new ObjectWriter (surrogate_selector, context, assembly_format);
serializer.WriteObjectGraph (writer, graph, headers);
}
writer.Flush();
}
+ [MonoTODO]
+ [System.Runtime.InteropServices.ComVisible (false)]
+ public object UnsafeDeserialize(Stream serializationStream, HeaderHandler handler)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ [System.Runtime.InteropServices.ComVisible (false)]
+ public object UnsafeDeserializeMethodResponse(Stream serializationStream, HeaderHandler handler, IMethodCallMessage methodCallmessage)
+ {
+ throw new NotImplementedException ();
+ }
+
private void WriteBinaryHeader (BinaryWriter writer, bool hasHeaders)
{
writer.Write ((byte)BinaryElement.Header);
diff --git a/mcs/class/corlib/System.Runtime.Serialization.Formatters.Binary/ChangeLog b/mcs/class/corlib/System.Runtime.Serialization.Formatters.Binary/ChangeLog
index b8fb4fb89a0..57a8f538e31 100755
--- a/mcs/class/corlib/System.Runtime.Serialization.Formatters.Binary/ChangeLog
+++ b/mcs/class/corlib/System.Runtime.Serialization.Formatters.Binary/ChangeLog
@@ -1,3 +1,21 @@
+2003-11-26 Lluis Sanchez Gual <lluis@ximian.com>
+
+ * BinaryFormatter.cs: Added missing methods.
+
+2003-11-20 Lluis Sanchez Gual <lluis@ximian.com>
+
+ * BinaryFormatter.cs, MessageFormatter.cs, ObjectReader.cs: Added support
+ for TypeFilter property.
+
+2003-11-16 Lluis Sanchez Gual <lluis@ximian.com>
+
+ * BinaryFormatter.cs, MessageFormatter.cs, ObjectWriter.cs:
+ Implemented support for AssemblyFormat property.
+
+2003-11-12 Lluis Sanchez Gual <lluis@ximian.com>
+
+ * ObjectReader.cs, ObjectWriter.cs: Changed some GetType calls to "is" checks.
+
2003-07-28 Duncan Mak <duncan@ximian.com>
* BinaryFormatter.cs (WriteBinaryHeader): changed from public to
@@ -87,5 +105,3 @@
2002-08-18 Dick Porter <dick@ximian.com>
* BinaryFormatter.cs: Stubbed out
-
-
diff --git a/mcs/class/corlib/System.Runtime.Serialization.Formatters.Binary/MessageFormatter.cs b/mcs/class/corlib/System.Runtime.Serialization.Formatters.Binary/MessageFormatter.cs
index c2e8070343d..78cecd18c75 100644
--- a/mcs/class/corlib/System.Runtime.Serialization.Formatters.Binary/MessageFormatter.cs
+++ b/mcs/class/corlib/System.Runtime.Serialization.Formatters.Binary/MessageFormatter.cs
@@ -18,7 +18,7 @@ namespace System.Runtime.Serialization.Formatters.Binary
{
internal class MessageFormatter
{
- public static void WriteMethodCall (BinaryWriter writer, object obj, Header[] headers, ISurrogateSelector surrogateSelector, StreamingContext context)
+ public static void WriteMethodCall (BinaryWriter writer, object obj, Header[] headers, ISurrogateSelector surrogateSelector, StreamingContext context, FormatterAssemblyStyle assemblyFormat)
{
IMethodCallMessage call = (IMethodCallMessage)obj;
writer.Write ((byte) BinaryElement.MethodCall);
@@ -110,14 +110,14 @@ namespace System.Runtime.Serialization.Formatters.Binary
if (info != null)
{
- ObjectWriter objectWriter = new ObjectWriter(surrogateSelector, context);
+ ObjectWriter objectWriter = new ObjectWriter (surrogateSelector, context, assemblyFormat);
objectWriter.WriteObjectGraph (writer, info, headers);
}
else
writer.Write ((byte) BinaryElement.End);
}
- public static void WriteMethodResponse (BinaryWriter writer, object obj, Header[] headers, ISurrogateSelector surrogateSelector, StreamingContext context)
+ public static void WriteMethodResponse (BinaryWriter writer, object obj, Header[] headers, ISurrogateSelector surrogateSelector, StreamingContext context, FormatterAssemblyStyle assemblyFormat)
{
IMethodReturnMessage resp = (IMethodReturnMessage)obj;
writer.Write ((byte) BinaryElement.MethodResponse);
@@ -238,14 +238,14 @@ namespace System.Runtime.Serialization.Formatters.Binary
if (info != null)
{
- ObjectWriter objectWriter = new ObjectWriter(surrogateSelector, context);
+ ObjectWriter objectWriter = new ObjectWriter (surrogateSelector, context, assemblyFormat);
objectWriter.WriteObjectGraph (writer, info, headers);
}
else
writer.Write ((byte) BinaryElement.End);
}
- public static object ReadMethodCall (BinaryReader reader, bool hasHeaders, HeaderHandler headerHandler, ISurrogateSelector surrogateSelector, StreamingContext context, SerializationBinder binder)
+ public static object ReadMethodCall (BinaryReader reader, bool hasHeaders, HeaderHandler headerHandler, BinaryFormatter formatter)
{
BinaryElement elem = (BinaryElement)reader.ReadByte(); // The element code
if (elem != BinaryElement.MethodCall) throw new SerializationException("Invalid format. Expected BinaryElement.MethodCall, found " + elem);
@@ -284,7 +284,7 @@ namespace System.Runtime.Serialization.Formatters.Binary
if ((flags & MethodFlags.NeedsInfoArrayMask) > 0)
{
- ObjectReader objectReader = new ObjectReader(surrogateSelector, context, binder);
+ ObjectReader objectReader = new ObjectReader (formatter);
object result;
objectReader.ReadObjectGraph (reader, hasHeaders, out result, out headers);
@@ -339,7 +339,7 @@ namespace System.Runtime.Serialization.Formatters.Binary
return call;
}
- public static object ReadMethodResponse (BinaryReader reader, bool hasHeaders, HeaderHandler headerHandler, IMethodCallMessage methodCallMessage, ISurrogateSelector surrogateSelector, StreamingContext context, SerializationBinder binder)
+ public static object ReadMethodResponse (BinaryReader reader, bool hasHeaders, HeaderHandler headerHandler, IMethodCallMessage methodCallMessage, BinaryFormatter formatter)
{
BinaryElement elem = (BinaryElement)reader.ReadByte(); // The element code
if (elem != BinaryElement.MethodResponse) throw new SerializationException("Invalid format. Expected BinaryElement.MethodResponse, found " + elem);
@@ -382,7 +382,7 @@ namespace System.Runtime.Serialization.Formatters.Binary
{
// There objects that need to be deserialized using an ObjectReader
- ObjectReader objectReader = new ObjectReader(surrogateSelector, context, binder);
+ ObjectReader objectReader = new ObjectReader (formatter);
object result;
objectReader.ReadObjectGraph (reader, hasHeaders, out result, out headers);
object[] msgInfo = (object[]) result;
diff --git a/mcs/class/corlib/System.Runtime.Serialization.Formatters.Binary/ObjectReader.cs b/mcs/class/corlib/System.Runtime.Serialization.Formatters.Binary/ObjectReader.cs
index ee8f208a679..262cd10a5f7 100644
--- a/mcs/class/corlib/System.Runtime.Serialization.Formatters.Binary/ObjectReader.cs
+++ b/mcs/class/corlib/System.Runtime.Serialization.Formatters.Binary/ObjectReader.cs
@@ -19,9 +19,14 @@ namespace System.Runtime.Serialization.Formatters.Binary
{
internal class ObjectReader
{
+ BinaryFormatter _formatter;
ISurrogateSelector _surrogateSelector;
StreamingContext _context;
SerializationBinder _binder;
+
+#if NET_1_1
+ TypeFilterLevel _filterLevel;
+#endif
ObjectManager _manager;
Hashtable _registeredAssemblies = new Hashtable();
@@ -47,12 +52,17 @@ namespace System.Runtime.Serialization.Formatters.Binary
public int NullCount;
}
- public ObjectReader(ISurrogateSelector surrogateSelector, StreamingContext context, SerializationBinder binder)
+ public ObjectReader (BinaryFormatter formatter)
{
- _manager = new ObjectManager (surrogateSelector, context);
- _surrogateSelector = surrogateSelector;
- _context = context;
- _binder = binder;
+ _formatter = formatter;
+ _surrogateSelector = formatter.SurrogateSelector;
+ _context = formatter.Context;
+ _binder = formatter.Binder;
+ _manager = new ObjectManager (_surrogateSelector, _context);
+
+#if NET_1_1
+ _filterLevel = formatter.FilterLevel;
+#endif
}
public void ReadObjectGraph (BinaryReader reader, bool readHeaders, out object result, out Header[] headers)
@@ -214,7 +224,13 @@ namespace System.Runtime.Serialization.Formatters.Binary
private void ReadObjectContent (BinaryReader reader, TypeMetadata metadata, long objectId, out object objectInstance, out SerializationInfo info)
{
- objectInstance = FormatterServices.GetUninitializedObject (metadata.Type);
+#if NET_1_1
+ if (_filterLevel == TypeFilterLevel.Low)
+ objectInstance = FormatterServices.GetSafeUninitializedObject (metadata.Type);
+ else
+#endif
+ objectInstance = FormatterServices.GetUninitializedObject (metadata.Type);
+
info = metadata.NeedsSerializationInfo ? new SerializationInfo(metadata.Type, new FormatterConverter()) : null;
if (metadata.MemberNames != null)
@@ -477,7 +493,7 @@ namespace System.Runtime.Serialization.Formatters.Binary
// Register the value
- if (info == null && !parentObject.GetType().IsArray)
+ if (info == null && !(parentObject is Array))
RegisterObject (objectId, val, objectInfo, parentObjectId, memberInfo, null);
else
RegisterObject (objectId, val, objectInfo, parentObjectId, null, indices);
@@ -493,7 +509,7 @@ namespace System.Runtime.Serialization.Formatters.Binary
if (value is IObjectReference)
value = ((IObjectReference)value).GetRealObject (_context);
- if (parentObject.GetType().IsArray)
+ if (parentObject is Array)
{
if (value is ArrayNullFiller)
{
@@ -521,7 +537,7 @@ namespace System.Runtime.Serialization.Formatters.Binary
if (info != null) {
_manager.RecordDelayedFixup (parentObjectId, fieldName, childObjectId);
}
- else if (parentObject.GetType().IsArray) {
+ else if (parentObject is Array) {
if (indices.Length == 1)
_manager.RecordArrayElementFixup (parentObjectId, indices[0], childObjectId);
else
@@ -645,4 +661,4 @@ namespace System.Runtime.Serialization.Formatters.Binary
}
}
}
-}
+}
diff --git a/mcs/class/corlib/System.Runtime.Serialization.Formatters.Binary/ObjectWriter.cs b/mcs/class/corlib/System.Runtime.Serialization.Formatters.Binary/ObjectWriter.cs
index 73a03d2b4eb..5b9067ce1ca 100644
--- a/mcs/class/corlib/System.Runtime.Serialization.Formatters.Binary/ObjectWriter.cs
+++ b/mcs/class/corlib/System.Runtime.Serialization.Formatters.Binary/ObjectWriter.cs
@@ -27,6 +27,7 @@ namespace System.Runtime.Serialization.Formatters.Binary
ISurrogateSelector _surrogateSelector;
StreamingContext _context;
+ FormatterAssemblyStyle _assemblyFormat;
class TypeMetadata
{
@@ -54,10 +55,11 @@ namespace System.Runtime.Serialization.Formatters.Binary
}
}
- public ObjectWriter(ISurrogateSelector surrogateSelector, StreamingContext context)
+ public ObjectWriter (ISurrogateSelector surrogateSelector, StreamingContext context, FormatterAssemblyStyle assemblyFormat)
{
_surrogateSelector = surrogateSelector;
_context = context;
+ _assemblyFormat = assemblyFormat;
}
public void WriteObjectGraph (BinaryWriter writer, object obj, Header[] headers)
@@ -93,10 +95,10 @@ namespace System.Runtime.Serialization.Formatters.Binary
if (isValueObject) id = _idGenerator.NextId;
else id = _idGenerator.GetId (obj, out firstTime);
- if (obj.GetType() == typeof(string)) {
+ if (obj is string) {
WriteString (writer, id, (string)obj);
}
- else if (obj.GetType().IsArray) {
+ else if (obj is Array) {
WriteArray (writer, id, (Array)obj);
}
else
@@ -504,7 +506,7 @@ namespace System.Runtime.Serialization.Formatters.Binary
// Value types are written embedded in the containing object
WriteObjectInstance (writer, val, true);
}
- else if (val.GetType() == typeof(string))
+ else if (val is string)
{
// Strings are written embedded, unless already registered
bool firstTime;
@@ -537,7 +539,10 @@ namespace System.Runtime.Serialization.Formatters.Binary
{
writer.Write ((byte) BinaryElement.Assembly);
writer.Write (id);
- writer.Write (assembly.GetName ().FullName);
+ if (_assemblyFormat == FormatterAssemblyStyle.Full)
+ writer.Write (assembly.GetName ().FullName);
+ else
+ writer.Write (assembly.GetName ().Name);
}
private int GetAssemblyId (Assembly assembly)
diff --git a/mcs/class/corlib/System.Runtime.Serialization.Formatters/ChangeLog b/mcs/class/corlib/System.Runtime.Serialization.Formatters/ChangeLog
index f5beb450d4a..56c13ecc73c 100644
--- a/mcs/class/corlib/System.Runtime.Serialization.Formatters/ChangeLog
+++ b/mcs/class/corlib/System.Runtime.Serialization.Formatters/ChangeLog
@@ -1,3 +1,11 @@
+2003-11-18 Andreas Nahr <ClassDevelopment@A-SoftTech.com>
+
+ * ServerFault.cs: Added missing attribute
+ * SoapFault.cs: Added missing attribute
+ * InternalRM.cs: Added
+ * InternalST.cs: Added
+ * TypeFilterLevel.cs: Added (complete)
+
2003-05-28 Jean-Marc Andre <jean-marc.andre@polymtl.ca>
* SoapFault.cs: finishing implementation
diff --git a/mcs/class/corlib/System.Runtime.Serialization.Formatters/FormatterTopObjectStyle.cs b/mcs/class/corlib/System.Runtime.Serialization.Formatters/FormatterTopObjectStyle.cs
index 2bba90aaafa..963f991fc8e 100755
--- a/mcs/class/corlib/System.Runtime.Serialization.Formatters/FormatterTopObjectStyle.cs
+++ b/mcs/class/corlib/System.Runtime.Serialization.Formatters/FormatterTopObjectStyle.cs
@@ -13,6 +13,8 @@
namespace System.Runtime.Serialization.Formatters {
+#if ECMA
+
/// <summary>
/// </summary>
public enum FormatterTopObjectStyle {
@@ -25,5 +27,6 @@ namespace System.Runtime.Serialization.Formatters {
/// </summary>
SoapMessage = 1,
} // FormatterTopObjectStyle
-
+#endif
+
} // System.Runtime.Serialization.Formatters
diff --git a/mcs/class/corlib/System.Runtime.Serialization.Formatters/InternalArrayTypeE.cs b/mcs/class/corlib/System.Runtime.Serialization.Formatters/InternalArrayTypeE.cs
index 5c8f704520e..f7ca8121db2 100755
--- a/mcs/class/corlib/System.Runtime.Serialization.Formatters/InternalArrayTypeE.cs
+++ b/mcs/class/corlib/System.Runtime.Serialization.Formatters/InternalArrayTypeE.cs
@@ -12,7 +12,8 @@
namespace System.Runtime.Serialization.Formatters {
-
+#if ECMA
+
/// <summary>
/// </summary>
public enum InternalArrayTypeE {
@@ -37,5 +38,6 @@ namespace System.Runtime.Serialization.Formatters {
/// </summary>
Base64 = 4,
} // InternalArrayTypeE
-
+#endif
+
} // System.Runtime.Serialization.Formatters
diff --git a/mcs/class/corlib/System.Runtime.Serialization.Formatters/InternalElementTypeE.cs b/mcs/class/corlib/System.Runtime.Serialization.Formatters/InternalElementTypeE.cs
index 2112390e67d..5e37d50a8d2 100755
--- a/mcs/class/corlib/System.Runtime.Serialization.Formatters/InternalElementTypeE.cs
+++ b/mcs/class/corlib/System.Runtime.Serialization.Formatters/InternalElementTypeE.cs
@@ -12,7 +12,7 @@
namespace System.Runtime.Serialization.Formatters {
-
+#if ECMA
/// <summary>
/// </summary>
public enum InternalElementTypeE {
@@ -29,5 +29,6 @@ namespace System.Runtime.Serialization.Formatters {
/// </summary>
Member = 2,
} // InternalElementTypeE
-
+#endif
+
} // System.Runtime.Serialization.Formatters
diff --git a/mcs/class/corlib/System.Runtime.Serialization.Formatters/InternalMemberTypeE.cs b/mcs/class/corlib/System.Runtime.Serialization.Formatters/InternalMemberTypeE.cs
index 4854703471e..652394cd84e 100755
--- a/mcs/class/corlib/System.Runtime.Serialization.Formatters/InternalMemberTypeE.cs
+++ b/mcs/class/corlib/System.Runtime.Serialization.Formatters/InternalMemberTypeE.cs
@@ -12,7 +12,7 @@
namespace System.Runtime.Serialization.Formatters {
-
+#if ECMA
/// <summary>
/// </summary>
public enum InternalMemberTypeE {
@@ -33,5 +33,5 @@ namespace System.Runtime.Serialization.Formatters {
/// </summary>
Item = 3,
} // InternalMemberTypeE
-
+#endif
} // System.Runtime.Serialization.Formatters
diff --git a/mcs/class/corlib/System.Runtime.Serialization.Formatters/InternalMemberValueE.cs b/mcs/class/corlib/System.Runtime.Serialization.Formatters/InternalMemberValueE.cs
index 3459d9e43b5..09757e6dc22 100755
--- a/mcs/class/corlib/System.Runtime.Serialization.Formatters/InternalMemberValueE.cs
+++ b/mcs/class/corlib/System.Runtime.Serialization.Formatters/InternalMemberValueE.cs
@@ -12,7 +12,7 @@
namespace System.Runtime.Serialization.Formatters {
-
+#if ECMA
/// <summary>
/// </summary>
public enum InternalMemberValueE {
@@ -37,5 +37,5 @@ namespace System.Runtime.Serialization.Formatters {
/// </summary>
Null = 4,
} // InternalMemberValueE
-
+#endif
} // System.Runtime.Serialization.Formatters
diff --git a/mcs/class/corlib/System.Runtime.Serialization.Formatters/InternalNameSpaceE.cs b/mcs/class/corlib/System.Runtime.Serialization.Formatters/InternalNameSpaceE.cs
index 6074981b751..a32c011fb10 100755
--- a/mcs/class/corlib/System.Runtime.Serialization.Formatters/InternalNameSpaceE.cs
+++ b/mcs/class/corlib/System.Runtime.Serialization.Formatters/InternalNameSpaceE.cs
@@ -12,7 +12,7 @@
namespace System.Runtime.Serialization.Formatters {
-
+#if ECMA
/// <summary>
/// </summary>
public enum InternalNameSpaceE {
@@ -57,5 +57,5 @@ namespace System.Runtime.Serialization.Formatters {
/// </summary>
CallElement = 9,
} // InternalNameSpaceE
-
+#endif
} // System.Runtime.Serialization.Formatters
diff --git a/mcs/class/corlib/System.Runtime.Serialization.Formatters/InternalObjectPositionE.cs b/mcs/class/corlib/System.Runtime.Serialization.Formatters/InternalObjectPositionE.cs
index 9229202af82..bdcac0c22ad 100755
--- a/mcs/class/corlib/System.Runtime.Serialization.Formatters/InternalObjectPositionE.cs
+++ b/mcs/class/corlib/System.Runtime.Serialization.Formatters/InternalObjectPositionE.cs
@@ -12,7 +12,7 @@
namespace System.Runtime.Serialization.Formatters {
-
+#if ECMA
/// <summary>
/// </summary>
public enum InternalObjectPositionE {
@@ -33,5 +33,5 @@ namespace System.Runtime.Serialization.Formatters {
/// </summary>
Headers = 3,
} // InternalObjectPositionE
-
+#endif
} // System.Runtime.Serialization.Formatters
diff --git a/mcs/class/corlib/System.Runtime.Serialization.Formatters/InternalObjectTypeE.cs b/mcs/class/corlib/System.Runtime.Serialization.Formatters/InternalObjectTypeE.cs
index 986b6bd4bc1..f0dd79b7d78 100755
--- a/mcs/class/corlib/System.Runtime.Serialization.Formatters/InternalObjectTypeE.cs
+++ b/mcs/class/corlib/System.Runtime.Serialization.Formatters/InternalObjectTypeE.cs
@@ -12,7 +12,7 @@
namespace System.Runtime.Serialization.Formatters {
-
+#if ECMA
/// <summary>
/// </summary>
public enum InternalObjectTypeE {
@@ -29,5 +29,5 @@ namespace System.Runtime.Serialization.Formatters {
/// </summary>
Array = 2,
} // InternalObjectTypeE
-
+#endif
} // System.Runtime.Serialization.Formatters
diff --git a/mcs/class/corlib/System.Runtime.Serialization.Formatters/InternalParseStateE.cs b/mcs/class/corlib/System.Runtime.Serialization.Formatters/InternalParseStateE.cs
index 87627fcc2bb..dc31e128896 100755
--- a/mcs/class/corlib/System.Runtime.Serialization.Formatters/InternalParseStateE.cs
+++ b/mcs/class/corlib/System.Runtime.Serialization.Formatters/InternalParseStateE.cs
@@ -12,7 +12,7 @@
namespace System.Runtime.Serialization.Formatters {
-
+#if ECMA
/// <summary>
/// </summary>
public enum InternalParseStateE {
@@ -33,5 +33,5 @@ namespace System.Runtime.Serialization.Formatters {
/// </summary>
MemberChild = 3,
} // InternalParseStateE
-
+#endif
} // System.Runtime.Serialization.Formatters
diff --git a/mcs/class/corlib/System.Runtime.Serialization.Formatters/InternalParseTypeE.cs b/mcs/class/corlib/System.Runtime.Serialization.Formatters/InternalParseTypeE.cs
index 9747bffcbe8..bdd35866ca8 100755
--- a/mcs/class/corlib/System.Runtime.Serialization.Formatters/InternalParseTypeE.cs
+++ b/mcs/class/corlib/System.Runtime.Serialization.Formatters/InternalParseTypeE.cs
@@ -12,7 +12,7 @@
namespace System.Runtime.Serialization.Formatters {
-
+#if ECMA
/// <summary>
/// </summary>
public enum InternalParseTypeE {
@@ -69,5 +69,6 @@ namespace System.Runtime.Serialization.Formatters {
/// </summary>
BodyEnd = 12,
} // InternalParseTypeE
-
+#endif
+
} // System.Runtime.Serialization.Formatters
diff --git a/mcs/class/corlib/System.Runtime.Serialization.Formatters/InternalPrimitiveTypeE.cs b/mcs/class/corlib/System.Runtime.Serialization.Formatters/InternalPrimitiveTypeE.cs
index 09adef22214..406e66df8f1 100755
--- a/mcs/class/corlib/System.Runtime.Serialization.Formatters/InternalPrimitiveTypeE.cs
+++ b/mcs/class/corlib/System.Runtime.Serialization.Formatters/InternalPrimitiveTypeE.cs
@@ -11,7 +11,7 @@
namespace System.Runtime.Serialization.Formatters {
-
+#if ECMA
/// <summary>
/// </summary>
@@ -85,5 +85,5 @@ namespace System.Runtime.Serialization.Formatters {
/// </summary>
UInt64 = 16,
} // InternalPrimitiveTypeE
-
+#endif
} // System.Runtime.Serialization.Formatters
diff --git a/mcs/class/corlib/System.Runtime.Serialization.Formatters/InternalRM.cs b/mcs/class/corlib/System.Runtime.Serialization.Formatters/InternalRM.cs
new file mode 100644
index 00000000000..9367c4c71a0
--- /dev/null
+++ b/mcs/class/corlib/System.Runtime.Serialization.Formatters/InternalRM.cs
@@ -0,0 +1,19 @@
+//
+// System.Runtime.Serialization.Formatters.InternalRM.cs
+//
+// Author:
+// Andreas Nahr (ClassDevelopment@A-SoftTech.com)
+//
+// (C) 2003 Andreas Nahr
+//
+
+namespace System.Runtime.Serialization.Formatters
+{
+ //LAMESPEC: Use of this class??
+ public sealed class InternalRM
+ {
+ private InternalRM ()
+ {
+ }
+ }
+}
diff --git a/mcs/class/corlib/System.Runtime.Serialization.Formatters/InternalST.cs b/mcs/class/corlib/System.Runtime.Serialization.Formatters/InternalST.cs
new file mode 100644
index 00000000000..cc0bcc0df2e
--- /dev/null
+++ b/mcs/class/corlib/System.Runtime.Serialization.Formatters/InternalST.cs
@@ -0,0 +1,19 @@
+//
+// System.Runtime.Serialization.Formatters.InternalST.cs
+//
+// Author:
+// Andreas Nahr (ClassDevelopment@A-SoftTech.com)
+//
+// (C) 2003 Andreas Nahr
+//
+
+namespace System.Runtime.Serialization.Formatters
+{
+ //LAMESPEC: Use of this class??
+ public sealed class InternalST
+ {
+ private InternalST ()
+ {
+ }
+ }
+}
diff --git a/mcs/class/corlib/System.Runtime.Serialization.Formatters/InternalSerializerTypeE.cs b/mcs/class/corlib/System.Runtime.Serialization.Formatters/InternalSerializerTypeE.cs
index 51f70341f93..ead23ec3740 100755
--- a/mcs/class/corlib/System.Runtime.Serialization.Formatters/InternalSerializerTypeE.cs
+++ b/mcs/class/corlib/System.Runtime.Serialization.Formatters/InternalSerializerTypeE.cs
@@ -12,7 +12,7 @@
namespace System.Runtime.Serialization.Formatters {
-
+#if ECMA
/// <summary>
/// </summary>
public enum InternalSerializerTypeE {
@@ -25,5 +25,6 @@ namespace System.Runtime.Serialization.Formatters {
/// </summary>
Binary = 2,
} // InternalSerializerTypeE
-
+#endif
+
} // System.Runtime.Serialization.Formatters
diff --git a/mcs/class/corlib/System.Runtime.Serialization.Formatters/ServerFault.cs b/mcs/class/corlib/System.Runtime.Serialization.Formatters/ServerFault.cs
index e72af6ff059..c73caaae2fb 100644
--- a/mcs/class/corlib/System.Runtime.Serialization.Formatters/ServerFault.cs
+++ b/mcs/class/corlib/System.Runtime.Serialization.Formatters/ServerFault.cs
@@ -7,12 +7,14 @@
// 2002 (C) Copyright, Ximian, Inc.
//
-using System;
+using System;
+using System.Runtime.Remoting.Metadata;
using System.Runtime.Serialization;
namespace System.Runtime.Serialization.Formatters {
- [Serializable]
+ [Serializable]
+ [SoapType()]
public sealed class ServerFault
{
string exceptionType;
diff --git a/mcs/class/corlib/System.Runtime.Serialization.Formatters/SoapFault.cs b/mcs/class/corlib/System.Runtime.Serialization.Formatters/SoapFault.cs
index 3fd79287401..d70502b7740 100644
--- a/mcs/class/corlib/System.Runtime.Serialization.Formatters/SoapFault.cs
+++ b/mcs/class/corlib/System.Runtime.Serialization.Formatters/SoapFault.cs
@@ -7,12 +7,14 @@
// 2002 (C) Copyright, Ximian, Inc.
//
-using System;
+using System;
+using System.Runtime.Remoting.Metadata;
using System.Runtime.Serialization;
namespace System.Runtime.Serialization.Formatters {
- [Serializable]
+ [Serializable]
+ [SoapType()]
public sealed class SoapFault : ISerializable
{
string code;
diff --git a/mcs/class/corlib/System.Runtime.Serialization.Formatters/TypeFilterLevel.cs b/mcs/class/corlib/System.Runtime.Serialization.Formatters/TypeFilterLevel.cs
new file mode 100644
index 00000000000..5f47938d891
--- /dev/null
+++ b/mcs/class/corlib/System.Runtime.Serialization.Formatters/TypeFilterLevel.cs
@@ -0,0 +1,21 @@
+//
+// System.Runtime.Serialization.Formatters.TypeFilterLevel.cs
+//
+// Author:
+// Andreas Nahr (ClassDevelopment@A-SoftTech.com)
+//
+// (C) 2003 Andreas Nahr
+//
+
+#if NET_1_1
+
+namespace System.Runtime.Serialization.Formatters
+{
+ public enum TypeFilterLevel
+ {
+ Low = 2,
+ Full = 3
+ }
+}
+
+#endif
diff --git a/mcs/class/corlib/System.Runtime.Serialization/ChangeLog b/mcs/class/corlib/System.Runtime.Serialization/ChangeLog
index 05c0f61d287..486da8563ba 100644
--- a/mcs/class/corlib/System.Runtime.Serialization/ChangeLog
+++ b/mcs/class/corlib/System.Runtime.Serialization/ChangeLog
@@ -1,3 +1,17 @@
+2003-11-21 Andreas Nahr <ClassDevelopment@A-SoftTech.com>
+
+ * FormatterServices.cs: Added CheckTypeSecurity() and
+ GetSafeUninitializedObject().
+
+2003-11-18 Andreas Nahr <ClassDevelopment@A-SoftTech.com>
+
+ * ObjectManager.cs: Fixed header, internalized enum
+ * Formatter.cs: Implemented
+
+2003-11-11 Lluis Sanchez Gual <lluis@ximian.com>
+
+ * FormatterServices.cs: Fixed some comments.
+
2003-10-21 Lluis Sanchez Gual <lluis@ximian.com>
* SerializationInfo.cs: Fixed bug in GetValue. Use IsAssignableFrom instead
diff --git a/mcs/class/corlib/System.Runtime.Serialization/Formatter.cs b/mcs/class/corlib/System.Runtime.Serialization/Formatter.cs
index 4c4d79626cf..4387ddf2e5c 100755
--- a/mcs/class/corlib/System.Runtime.Serialization/Formatter.cs
+++ b/mcs/class/corlib/System.Runtime.Serialization/Formatter.cs
@@ -1,7 +1,9 @@
//
// System.Runtime.Serialization.Formatter.cs
//
-// Duncan Mak (duncan@ximian.com)
+// Authors:
+// Duncan Mak (duncan@ximian.com)
+// Andreas Nahr (ClassDevelopment@A-SoftTech.com)
//
// (C) Ximian, Inc.
//
@@ -40,16 +42,33 @@ public abstract class Formatter : IFormatter
public abstract object Deserialize (Stream serializationStream);
- [MonoTODO]
protected virtual object GetNext (out long objID)
{
- throw new NotImplementedException ();
+ if (m_objectQueue.Count == 0)
+ {
+ // set the out field to 0
+ objID = 0L;
+ return null;
+ }
+
+ Object o = m_objectQueue.Dequeue ();
+ bool FirstTime;
+ objID = m_idGenerator.HasId (o, out FirstTime);
+
+ return o;
}
- [MonoTODO]
protected virtual long Schedule (object obj)
{
- throw new NotImplementedException ();
+ if (obj == null)
+ return 0L;
+
+ bool FirstTime;
+ long ID = m_idGenerator.GetId (obj, out FirstTime);
+ if (FirstTime)
+ m_objectQueue.Enqueue (obj);
+
+ return ID;
}
public abstract void Serialize (Stream serializationStream, object graph);
@@ -74,10 +93,48 @@ public abstract class Formatter : IFormatter
protected abstract void WriteInt64 (long val, string name);
- [MonoTODO]
protected virtual void WriteMember (string memberName, object data)
{
- throw new NotImplementedException ();
+ if (data == null)
+ WriteObjectRef (data, memberName, typeof(Object));
+
+ Type dataType = data.GetType ();
+ if (dataType.IsArray)
+ WriteArray (data, memberName, dataType);
+ else if (dataType == typeof(bool))
+ WriteBoolean ((bool)data, memberName);
+ else if (dataType == typeof(byte))
+ WriteByte ((byte)data, memberName);
+ else if (dataType == typeof(char))
+ WriteChar ((char)data, memberName);
+ else if (dataType == typeof(DateTime))
+ WriteDateTime ((DateTime)data, memberName);
+ else if (dataType == typeof(decimal))
+ WriteDecimal ((decimal)data, memberName);
+ else if (dataType == typeof(double))
+ WriteDouble ((double)data, memberName);
+ else if (dataType == typeof(Int16))
+ WriteInt16 ((Int16)data, memberName);
+ else if (dataType == typeof(Int32))
+ WriteInt32 ((Int32)data, memberName);
+ else if (dataType == typeof(Int64))
+ WriteInt64 ((Int64)data, memberName);
+ else if (dataType == typeof(sbyte))
+ WriteSByte ((sbyte)data, memberName);
+ else if (dataType == typeof(float))
+ WriteSingle ((float)data, memberName);
+ else if (dataType == typeof(TimeSpan))
+ WriteTimeSpan ((TimeSpan)data, memberName);
+ else if (dataType == typeof(UInt16))
+ WriteUInt16 ((UInt16)data, memberName);
+ else if (dataType == typeof(UInt32))
+ WriteUInt32 ((UInt32)data, memberName);
+ else if (dataType == typeof(UInt64))
+ WriteUInt64 ((UInt64)data, memberName);
+ else if (dataType.IsValueType)
+ WriteValueType (data, memberName, dataType);
+
+ WriteObjectRef (data, memberName, dataType);
}
protected abstract void WriteObjectRef (object obj, string name, Type memberType);
diff --git a/mcs/class/corlib/System.Runtime.Serialization/FormatterServices.cs b/mcs/class/corlib/System.Runtime.Serialization/FormatterServices.cs
index d5c37f83c03..1a03f703682 100644
--- a/mcs/class/corlib/System.Runtime.Serialization/FormatterServices.cs
+++ b/mcs/class/corlib/System.Runtime.Serialization/FormatterServices.cs
@@ -10,6 +10,7 @@ using System;
using System.Collections;
using System.Reflection;
using System.Runtime.CompilerServices;
+using System.Runtime.Serialization.Formatters;
namespace System.Runtime.Serialization
{
@@ -43,7 +44,7 @@ namespace System.Runtime.Serialization
throw new SerializationException (
String.Format ("members [{0}] is not a field.", i));
- FieldInfo fi = member as FieldInfo; //FIXME: Can fi be null?
+ FieldInfo fi = member as FieldInfo; // members must be fields
result [i] = fi.GetValue (obj);
}
@@ -136,11 +137,44 @@ namespace System.Runtime.Serialization
throw new SerializationException (
String.Format ("members [{0}] is not a field.", i));
- FieldInfo fi = member as FieldInfo; //FIXME: can fi be null?
+ FieldInfo fi = member as FieldInfo; // members must be fields
fi.SetValue (obj, data [i]);
}
return obj;
}
+
+#if NET_1_1
+
+ public static void CheckTypeSecurity (Type t, TypeFilterLevel securityLevel)
+ {
+ if (securityLevel == TypeFilterLevel.Full) return;
+ CheckNotAssignable (typeof(System.DelegateSerializationHolder), t);
+ CheckNotAssignable (typeof(System.Runtime.Remoting.Lifetime.ISponsor), t);
+ CheckNotAssignable (typeof(System.Runtime.Remoting.IEnvoyInfo), t);
+ CheckNotAssignable (typeof(System.Runtime.Remoting.ObjRef), t);
+ }
+
+ static void CheckNotAssignable (Type basetype, Type type)
+ {
+ if (basetype.IsAssignableFrom (type)) {
+ string msg = "Type " + basetype + " and the types derived from it";
+ msg += " (such as " + type + ") are not permitted to be deserialized at this security level";
+ throw new System.Security.SecurityException (msg);
+ }
+ }
+
+ public static object GetSafeUninitializedObject (Type type)
+ {
+ // FIXME: MS.NET uses code access permissions to check if the caller is
+ // allowed to create an instance of this type. We can't support this
+ // because it is not implemented in mono.
+
+ // In concrete, the it will request a SecurityPermission of
+ // type "Infrastructure".
+
+ return GetUninitializedObject (type);
+ }
+#endif
}
}
diff --git a/mcs/class/corlib/System.Runtime.Serialization/ObjectManager.cs b/mcs/class/corlib/System.Runtime.Serialization/ObjectManager.cs
index a758b00f616..0c62cff86ca 100644
--- a/mcs/class/corlib/System.Runtime.Serialization/ObjectManager.cs
+++ b/mcs/class/corlib/System.Runtime.Serialization/ObjectManager.cs
@@ -1,5 +1,5 @@
//
-// System.Runtime.Serialization.ObjectIDGenerator.cs
+// System.Runtime.Serialization.ObjectManager.cs
//
// Author: Lluis Sanchez Gual (lluis@ideary.com)
//
@@ -344,7 +344,7 @@ namespace System.Runtime.Serialization
// Object Record
- public enum ObjectRecordStatus: byte { Unregistered, ReferenceUnsolved, ReferenceSolvingDelayed, ReferenceSolved }
+ internal enum ObjectRecordStatus: byte { Unregistered, ReferenceUnsolved, ReferenceSolvingDelayed, ReferenceSolved }
internal class ObjectRecord
{
diff --git a/mcs/class/corlib/System.Security.Cryptography/ChangeLog b/mcs/class/corlib/System.Security.Cryptography/ChangeLog
index 4235ebb0057..c5ebc5e8bbb 100644
--- a/mcs/class/corlib/System.Security.Cryptography/ChangeLog
+++ b/mcs/class/corlib/System.Security.Cryptography/ChangeLog
@@ -1,3 +1,15 @@
+2003-11-13 Sebastien Pouliot <spouliot@videotron.ca>
+
+ * ProtectedData.cs: Added exceptions - core is still TODO.
+ * ProtectedMemory.cs: Added exceptions - core is still TODO.
+
+2003-11-11 Sebastien Pouliot <spouliot@videotron.ca>
+
+ * Rfc2898DeriveBytes.cs: Now handle resets and keys longer than 160
+ bits (HMACSHA1 block size). Removed TODO.
+ * SymmetricAlgorithm.cs: Fixed decryption when inputOffset > 0.
+ [#50826].
+
2003-11-10 Sebastien Pouliot <spouliot@videotron.ca>
* Rfc2898DeriveBytes.cs: Implementation for PKCS5 PBKDF2. It works
diff --git a/mcs/class/corlib/System.Security.Cryptography/ProtectedData.cs b/mcs/class/corlib/System.Security.Cryptography/ProtectedData.cs
index 2871f954f9e..5973e1c37b6 100755
--- a/mcs/class/corlib/System.Security.Cryptography/ProtectedData.cs
+++ b/mcs/class/corlib/System.Security.Cryptography/ProtectedData.cs
@@ -13,18 +13,33 @@ using System;
namespace System.Security.Cryptography {
+ // References:
+ // a. Windows Data Protection
+ // http://msdn.microsoft.com/library/en-us/dnsecure/html/windataprotection-dpapi.asp?frame=true
+
public sealed class ProtectedData {
+ // FIXME: interop could be important under windows - if one application protect some data using
+ // mono and another one unprotects it using ms.net
+
[MonoTODO ("interop with MS implementation ?")]
public static byte[] Protect (byte[] userData, byte[] optionalEntropy, DataProtectionScope scope)
{
- return userData;
+ if (userData == null)
+ throw new ArgumentNullException ("userData");
+
+ // on Windows this is supported only under 2000 and later OS
+ throw new PlatformNotSupportedException ();
}
[MonoTODO ("interop with MS implementation ?")]
public static byte[] Unprotect (byte[] encryptedData, byte[] optionalEntropy, DataProtectionScope scope)
{
- return encryptedData;
+ if (encryptedData == null)
+ throw new ArgumentNullException ("encryptedData");
+
+ // on Windows this is supported only under 2000 and later OS
+ throw new PlatformNotSupportedException ();
}
}
}
diff --git a/mcs/class/corlib/System.Security.Cryptography/ProtectedMemory.cs b/mcs/class/corlib/System.Security.Cryptography/ProtectedMemory.cs
index b5c44490721..e068acc4829 100755
--- a/mcs/class/corlib/System.Security.Cryptography/ProtectedMemory.cs
+++ b/mcs/class/corlib/System.Security.Cryptography/ProtectedMemory.cs
@@ -13,16 +13,34 @@ using System;
namespace System.Security.Cryptography {
+ // References:
+ // a. Windows Data Protection
+ // http://msdn.microsoft.com/library/en-us/dnsecure/html/windataprotection-dpapi.asp?frame=true
+
public sealed class ProtectedMemory {
[MonoTODO]
public static void Protect (byte[] userData, MemoryProtectionScope scope)
{
+ if (userData == null)
+ throw new ArgumentNullException ("userData");
+ if (userData.Length % 16 != 0)
+ throw new CryptographicException ("not a multiple of 16 bytes");
+
+ // on Windows this is supported only under XP and later OS
+ throw new PlatformNotSupportedException ();
}
[MonoTODO]
public static void Unprotect (byte[] encryptedData, MemoryProtectionScope scope)
{
+ if (encryptedData == null)
+ throw new ArgumentNullException ("encryptedData");
+ if (encryptedData.Length % 16 != 0)
+ throw new CryptographicException ("not a multiple of 16 bytes");
+
+ // on Windows this is supported only under XP and later OS
+ throw new PlatformNotSupportedException ();
}
}
}
diff --git a/mcs/class/corlib/System.Security.Cryptography/Rfc2898DeriveBytes.cs b/mcs/class/corlib/System.Security.Cryptography/Rfc2898DeriveBytes.cs
index a6b5a816ee6..98d7e1f8e78 100755
--- a/mcs/class/corlib/System.Security.Cryptography/Rfc2898DeriveBytes.cs
+++ b/mcs/class/corlib/System.Security.Cryptography/Rfc2898DeriveBytes.cs
@@ -19,9 +19,13 @@ namespace System.Security.Cryptography {
public class Rfc2898DeriveBytes : DeriveBytes {
private const int defaultIterations = 1000;
+
private int _iteration;
private byte[] _salt;
private HMACSHA1 _hmac;
+ private byte[] _buffer;
+ private int _pos;
+ private int _f;
// constructors
@@ -103,27 +107,42 @@ namespace System.Security.Cryptography {
public override byte[] GetBytes (int cb)
{
+ if (cb < 1)
+ throw new ArgumentOutOfRangeException ("cb");
+
int l = cb / 20; // HMACSHA1 == 160 bits == 20 bytes
int r = cb % 20; // remainder
if (r != 0)
l++; // rounding up
byte[] result = new byte [cb];
- int pos = 0;
+ int rpos = 0;
+ if (_pos > 0) {
+ int count = Math.Min (20 - _pos, cb);
+ Buffer.BlockCopy (_buffer, _pos, result, 0, count);
+ if (count >= cb)
+ return result;
+ _pos = 0;
+ rpos = 20 - cb;
+ r = cb - rpos;
+ }
- for (int i=0; i < l; i++) {
- byte[] t = F (_salt, _iteration, l);
- int count = ((i == l - 1) ? r : 20);
- Buffer.BlockCopy (t, 0, result, pos, count);
- pos += count;
+ for (int i=1; i <= l; i++) {
+ _buffer = F (_salt, _iteration, ++_f);
+ int count = ((i == l) ? r : 20);
+ Buffer.BlockCopy (_buffer, _pos, result, rpos, count);
+ rpos += _pos + count;
+ _pos = ((count == 20) ? 0 : count);
}
return result;
}
- [MonoTODO]
public override void Reset ()
{
+ _buffer = null;
+ _pos = 0;
+ _f = 0;
}
}
}
diff --git a/mcs/class/corlib/System.Security.Cryptography/SymmetricAlgorithm.cs b/mcs/class/corlib/System.Security.Cryptography/SymmetricAlgorithm.cs
index 7795d819121..951200aa662 100755
--- a/mcs/class/corlib/System.Security.Cryptography/SymmetricAlgorithm.cs
+++ b/mcs/class/corlib/System.Security.Cryptography/SymmetricAlgorithm.cs
@@ -268,9 +268,11 @@ namespace System.Security.Cryptography {
int total = inputCount;
byte[] res = new byte [total];
- while (inputCount > 0) {
- TransformBlock (inputBuffer, inputOffset, BlockSizeByte, res, inputOffset);
- inputOffset += BlockSizeByte;
+ int nres = 0;
+ while (inputCount > 0) {
+ TransformBlock (inputBuffer, inputOffset, BlockSizeByte, res, nres);
+ inputOffset += BlockSizeByte;
+ nres += BlockSizeByte;
inputCount -= BlockSizeByte;
}
diff --git a/mcs/class/corlib/System.Security.Permissions/IsolatedStoragePermissionAttribute.cs b/mcs/class/corlib/System.Security.Permissions/IsolatedStoragePermissionAttribute.cs
index 21563b6b516..c6da340b529 100644
--- a/mcs/class/corlib/System.Security.Permissions/IsolatedStoragePermissionAttribute.cs
+++ b/mcs/class/corlib/System.Security.Permissions/IsolatedStoragePermissionAttribute.cs
@@ -31,11 +31,6 @@ namespace System.Security.Permissions {
set { user_quota = value; }
}
- [MonoTODO]
- public override IPermission CreatePermission () {
- return null;
- }
-
// private
private IsolatedStorageContainment usage_allowed;
diff --git a/mcs/class/corlib/System.Security.Permissions/RegistryPermissionAttribute.cs b/mcs/class/corlib/System.Security.Permissions/RegistryPermissionAttribute.cs
index 3ab3eeb160d..ce8fc5a8e3c 100644
--- a/mcs/class/corlib/System.Security.Permissions/RegistryPermissionAttribute.cs
+++ b/mcs/class/corlib/System.Security.Permissions/RegistryPermissionAttribute.cs
@@ -30,6 +30,7 @@ namespace System.Security.Permissions
public string All
{
set { all = value; }
+ get { return all; }
}
public string Create
diff --git a/mcs/class/corlib/System.Text/ASCIIEncoding.cs b/mcs/class/corlib/System.Text/ASCIIEncoding.cs
index 4f07982e3c8..2fb48828a00 100755
--- a/mcs/class/corlib/System.Text/ASCIIEncoding.cs
+++ b/mcs/class/corlib/System.Text/ASCIIEncoding.cs
@@ -2,6 +2,7 @@
* ASCIIEncoding.cs - Implementation of the "System.Text.ASCIIEncoding" class.
*
* Copyright (c) 2001 Southern Storm Software, Pty Ltd
+ * Copyright (C) 2003 Novell, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the "Software"),
@@ -34,7 +35,12 @@ public class ASCIIEncoding : Encoding
internal const int ASCII_CODE_PAGE = 20127;
// Constructor.
- public ASCIIEncoding () : base(ASCII_CODE_PAGE) {}
+ public ASCIIEncoding () : base(ASCII_CODE_PAGE) {
+ body_name = header_name = web_name= "us-ascii";
+ encoding_name = "US-ASCII";
+ is_mail_news_display = true;
+ is_mail_news_save = true;
+ }
// Get the number of bytes needed to encode a character buffer.
public override int GetByteCount (char[] chars, int index, int count)
@@ -232,58 +238,6 @@ public class ASCIIEncoding : Encoding
}
}
-#if !ECMA_COMPAT
-
- // Get the mail body name for this encoding.
- public override String BodyName
- {
- get {
- return "us-ascii";
- }
- }
-
- // Get the human-readable name for this encoding.
- public override String EncodingName
- {
- get {
- return "US-ASCII";
- }
- }
-
- // Get the mail agent header name for this encoding.
- public override String HeaderName
- {
- get {
- return "us-ascii";
- }
- }
-
- // Determine if this encoding can be displayed in a mail/news agent.
- public override bool IsMailNewsDisplay
- {
- get {
- return true;
- }
- }
-
- // Determine if this encoding can be saved from a mail/news agent.
- public override bool IsMailNewsSave
- {
- get {
- return true;
- }
- }
-
- // Get the IANA-preferred Web name for this encoding.
- public override String WebName
- {
- get {
- return "us-ascii";
- }
- }
-
-#endif // !ECMA_COMPAT
-
}; // class ASCIIEncoding
}; // namespace System.Text
diff --git a/mcs/class/corlib/System.Text/ChangeLog b/mcs/class/corlib/System.Text/ChangeLog
index 959ff311f7a..c768afcf3c6 100755
--- a/mcs/class/corlib/System.Text/ChangeLog
+++ b/mcs/class/corlib/System.Text/ChangeLog
@@ -1,3 +1,18 @@
+2003-11-17 Ben Maurer <bmaurer@users.sourceforge.net>
+
+ * StringBuilder.cs (Insert int, char): It is really silly and
+ wasteful to allocate an array here. We can just copy the value
+ over.
+
+2003-11-11 Miguel de Icaza <miguel@ximian.com>
+
+ * Encoding.cs: Use an internal variable to track the parameters of
+ each encoder, since the .NET API does not expose virtual methods
+ in the child classes, we should not depend on that.
+
+ * ASCIIEncoding.cs, UTF7Encoding, UTF8Encoding, UnicodeEncoding:
+ Initialize the parameters for base class encoding here.
+
2003-09-01 Miguel de Icaza <miguel@ximian.com>
* Encoding.cs (UTF8Unmarked): make it also not error out on
diff --git a/mcs/class/corlib/System.Text/Encoding.cs b/mcs/class/corlib/System.Text/Encoding.cs
index ea1e74a1ed9..ab817d6b214 100755
--- a/mcs/class/corlib/System.Text/Encoding.cs
+++ b/mcs/class/corlib/System.Text/Encoding.cs
@@ -3,6 +3,7 @@
*
* Copyright (c) 2001, 2002 Southern Storm Software, Pty Ltd
* Copyright (c) 2002, Ximian, Inc.
+ * Copyright (c) 2003, Novell, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the "Software"),
@@ -37,6 +38,7 @@ public abstract class Encoding
{
// Code page used by this encoding.
internal int codePage;
+ internal int windows_code_page;
// Constructor.
protected Encoding ()
@@ -50,7 +52,7 @@ public abstract class Encoding
#endif
Encoding (int codePage)
{
- this.codePage = codePage;
+ this.codePage = windows_code_page = codePage;
}
// until we change the callers:
@@ -477,11 +479,20 @@ public abstract class Encoding
#if !ECMA_COMPAT
+ internal protected string body_name;
+ internal protected string encoding_name;
+ internal protected string header_name;
+ internal protected bool is_mail_news_display;
+ internal protected bool is_mail_news_save;
+ internal protected bool is_browser_save = false;
+ internal protected bool is_browser_display = false;
+ internal protected string web_name;
+
// Get the mail body name for this encoding.
public virtual String BodyName
{
get {
- return null;
+ return body_name;
}
}
@@ -497,7 +508,7 @@ public abstract class Encoding
public virtual String EncodingName
{
get {
- return null;
+ return encoding_name;
}
}
@@ -505,7 +516,7 @@ public abstract class Encoding
public virtual String HeaderName
{
get {
- return null;
+ return header_name;
}
}
@@ -513,7 +524,7 @@ public abstract class Encoding
public virtual bool IsBrowserDisplay
{
get {
- return false;
+ return is_browser_display;
}
}
@@ -521,7 +532,7 @@ public abstract class Encoding
public virtual bool IsBrowserSave
{
get {
- return false;
+ return is_browser_save;
}
}
@@ -529,7 +540,7 @@ public abstract class Encoding
public virtual bool IsMailNewsDisplay
{
get {
- return false;
+ return is_mail_news_display;
}
}
@@ -537,7 +548,7 @@ public abstract class Encoding
public virtual bool IsMailNewsSave
{
get {
- return false;
+ return is_mail_news_save;
}
}
@@ -545,7 +556,7 @@ public abstract class Encoding
public virtual String WebName
{
get {
- return null;
+ return web_name;
}
}
@@ -555,7 +566,7 @@ public abstract class Encoding
get {
// We make no distinction between normal and
// Windows code pages in this implementation.
- return codePage;
+ return windows_code_page;
}
}
@@ -605,7 +616,7 @@ public abstract class Encoding
}
[MethodImpl (MethodImplOptions.InternalCall)]
- extern private static string InternalCodePage ();
+ extern internal static string InternalCodePage ();
// Get the default encoding object.
public static Encoding Default
diff --git a/mcs/class/corlib/System.Text/StringBuilder.cs b/mcs/class/corlib/System.Text/StringBuilder.cs
index cd769bc77e2..8ce8960d624 100644
--- a/mcs/class/corlib/System.Text/StringBuilder.cs
+++ b/mcs/class/corlib/System.Text/StringBuilder.cs
@@ -569,11 +569,21 @@ namespace System.Text {
return Insert( index, value.ToString());
}
- public StringBuilder Insert( int index, char value) {
- char[] insertChar = new char[1];
-
- insertChar[0] = value;
- return Insert( index, insertChar );
+ public StringBuilder Insert( int index, char value) {
+ if (index > sLength || index < 0)
+ throw new ArgumentOutOfRangeException ("index");
+ // Check we have the capacity to insert this array
+ if( sCapacity < sLength + 1) {
+ Capacity = 1 + ( sCapacity + sCapacity );
+ }
+
+ // Move everything to the right of the insert point across
+ Array.Copy( sString, index, sString, index + 1, sLength - index);
+
+ sString [index] = value;
+ sLength += 1;
+ thestring = null;
+ return this;
}
public StringBuilder Insert( int index, decimal value ) {
diff --git a/mcs/class/corlib/System.Text/UTF7Encoding.cs b/mcs/class/corlib/System.Text/UTF7Encoding.cs
index f8a34c2072c..a9e8372445e 100755
--- a/mcs/class/corlib/System.Text/UTF7Encoding.cs
+++ b/mcs/class/corlib/System.Text/UTF7Encoding.cs
@@ -3,6 +3,7 @@
* "System.Text.UTF7Encoding" class.
*
* Copyright (c) 2002 Southern Storm Software, Pty Ltd
+ * Copyright (c) 2003, Novell, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the "Software"),
@@ -85,14 +86,22 @@ class UTF7Encoding : Encoding
// Constructors.
public UTF7Encoding ()
- : base (UTF7_CODE_PAGE)
+ : this (false)
{
- allowOptionals = false;
}
+
public UTF7Encoding (bool allowOptionals)
: base (UTF7_CODE_PAGE)
{
this.allowOptionals = allowOptionals;
+
+ body_name = "utf-7";
+ encoding_name = "Unicode (UTF-7)";
+ header_name = "utf-7";
+ is_mail_news_display = true;
+ is_mail_news_save = true;
+ web_name = "utf-7";
+ windows_code_page = UnicodeEncoding.UNICODE_CODE_PAGE;
}
// Internal version of "GetByteCount" that can handle
@@ -525,66 +534,6 @@ class UTF7Encoding : Encoding
return new UTF7Encoder (allowOptionals);
}
-#if !ECMA_COMPAT
-
- // Get the mail body name for this encoding.
- public override String BodyName
- {
- get {
- return "utf-7";
- }
- }
-
- // Get the human-readable name for this encoding.
- public override String EncodingName
- {
- get {
- return "Unicode (UTF-7)";
- }
- }
-
- // Get the mail agent header name for this encoding.
- public override String HeaderName
- {
- get {
- return "utf-7";
- }
- }
-
- // Determine if this encoding can be displayed in a mail/news agent.
- public override bool IsMailNewsDisplay
- {
- get {
- return true;
- }
- }
-
- // Determine if this encoding can be saved from a mail/news agent.
- public override bool IsMailNewsSave
- {
- get {
- return true;
- }
- }
-
- // Get the IANA-preferred Web name for this encoding.
- public override String WebName
- {
- get {
- return "utf-7";
- }
- }
-
- // Get the Windows code page represented by this object.
- public override int WindowsCodePage
- {
- get {
- return UnicodeEncoding.UNICODE_CODE_PAGE;
- }
- }
-
-#endif // !ECMA_COMPAT
-
// UTF-7 decoder implementation.
private sealed class UTF7Decoder : Decoder
{
diff --git a/mcs/class/corlib/System.Text/UTF8Encoding.cs b/mcs/class/corlib/System.Text/UTF8Encoding.cs
index 7cd8f361acf..0f66bf2b95d 100755
--- a/mcs/class/corlib/System.Text/UTF8Encoding.cs
+++ b/mcs/class/corlib/System.Text/UTF8Encoding.cs
@@ -41,11 +41,19 @@ public class UTF8Encoding : Encoding
public UTF8Encoding () : this (false, false) {}
public UTF8Encoding (bool encoderShouldEmitUTF8Identifier)
: this (encoderShouldEmitUTF8Identifier, false) {}
+
public UTF8Encoding (bool encoderShouldEmitUTF8Identifier, bool throwOnInvalidBytes)
: base (UTF8_CODE_PAGE)
{
emitIdentifier = encoderShouldEmitUTF8Identifier;
throwOnInvalid = throwOnInvalidBytes;
+
+ web_name = body_name = header_name = "utf-8";
+ encoding_name = "Unicode (UTF-8)";
+ is_browser_save = true;
+ is_browser_display = true;
+ is_mail_news_display = true;
+ windows_code_page = UnicodeEncoding.UNICODE_CODE_PAGE;
}
// Internal version of "GetByteCount" which can handle a rolling
@@ -648,88 +656,17 @@ public class UTF8Encoding : Encoding
}
}
+ public override byte [] GetBytes (String s)
+ {
+ return base.GetBytes (s);
+ }
+
// Get the hash code for this object.
public override int GetHashCode ()
{
return base.GetHashCode ();
}
-#if !ECMA_COMPAT
-
- // Get the mail body name for this encoding.
- public override String BodyName
- {
- get {
- return "utf-8";
- }
- }
-
- // Get the human-readable name for this encoding.
- public override String EncodingName
- {
- get {
- return "Unicode (UTF-8)";
- }
- }
-
- // Get the mail agent header name for this encoding.
- public override String HeaderName
- {
- get {
- return "utf-8";
- }
- }
-
- // Determine if this encoding can be displayed in a Web browser.
- public override bool IsBrowserDisplay
- {
- get {
- return true;
- }
- }
-
- // Determine if this encoding can be saved from a Web browser.
- public override bool IsBrowserSave
- {
- get {
- return true;
- }
- }
-
- // Determine if this encoding can be displayed in a mail/news agent.
- public override bool IsMailNewsDisplay
- {
- get {
- return true;
- }
- }
-
- // Determine if this encoding can be saved from a mail/news agent.
- public override bool IsMailNewsSave
- {
- get {
- return true;
- }
- }
-
- // Get the IANA-preferred Web name for this encoding.
- public override String WebName
- {
- get {
- return "utf-8";
- }
- }
-
- // Get the Windows code page represented by this object.
- public override int WindowsCodePage
- {
- get {
- return UnicodeEncoding.UNICODE_CODE_PAGE;
- }
- }
-
-#endif // !ECMA_COMPAT
-
// UTF-8 decoder implementation.
[Serializable]
private class UTF8Decoder : Decoder
diff --git a/mcs/class/corlib/System.Text/UnicodeEncoding.cs b/mcs/class/corlib/System.Text/UnicodeEncoding.cs
index d073e810ad8..9e7ee47a73c 100755
--- a/mcs/class/corlib/System.Text/UnicodeEncoding.cs
+++ b/mcs/class/corlib/System.Text/UnicodeEncoding.cs
@@ -3,6 +3,7 @@
* "System.Text.UnicodeEncoding" class.
*
* Copyright (c) 2001, 2002 Southern Storm Software, Pty Ltd
+ * Copyright (C) 2003 Novell, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the "Software"),
@@ -45,7 +46,7 @@ public class UnicodeEncoding : Encoding
private bool byteOrderMark;
// Constructors.
- public UnicodeEncoding () : base(UNICODE_CODE_PAGE)
+ public UnicodeEncoding () : this (false, true)
{
bigEndian = false;
byteOrderMark = true;
@@ -55,6 +56,24 @@ public class UnicodeEncoding : Encoding
{
this.bigEndian = bigEndian;
this.byteOrderMark = byteOrderMark;
+
+ if (bigEndian){
+ body_name = "unicodeFFFE";
+ encoding_name = "Unicode (Big-Endian)";
+ header_name = "unicodeFFFE";
+ is_browser_save = false;
+ web_name = "utf-16be";
+ } else {
+ body_name = "utf-16";
+ encoding_name = "Unicode";
+ header_name = "utf-16";
+ is_browser_save = true;
+ web_name = "utf-16";
+ }
+
+ // Windows reports the same code page number for
+ // both the little-endian and big-endian forms.
+ windows_code_page = UNICODE_CODE_PAGE;
}
// Get the number of bytes needed to encode a character buffer.
@@ -161,6 +180,11 @@ public class UnicodeEncoding : Encoding
return posn - byteIndex;
}
+ public override byte [] GetBytes (String s)
+ {
+ return base.GetBytes (s);
+ }
+
// Get the number of characters needed to decode a byte buffer.
public override int GetCharCount (byte[] bytes, int index, int count)
{
@@ -311,79 +335,6 @@ public class UnicodeEncoding : Encoding
return base.GetHashCode ();
}
-#if !ECMA_COMPAT
-
- // Get the mail body name for this encoding.
- public override String BodyName
- {
- get {
- if (bigEndian) {
- return "unicodeFFFE";
- } else {
- return "utf-16";
- }
- }
- }
-
- // Get the human-readable name for this encoding.
- public override String EncodingName
- {
- get {
- if (bigEndian) {
- return "Unicode (Big-Endian)";
- } else {
- return "Unicode";
- }
- }
- }
-
- // Get the mail agent header name for this encoding.
- public override String HeaderName
- {
- get {
- if (bigEndian) {
- return "unicodeFFFE";
- } else {
- return "utf-16";
- }
- }
- }
-
- // Determine if this encoding can be saved from a Web browser.
- public override bool IsBrowserSave
- {
- get {
- return !bigEndian;
- }
- }
-
- // Get the IANA-preferred Web name for this encoding.
- public override String WebName
- {
- get {
- if (bigEndian) {
- // unicodeFFFE is MS compliant, but it is not
- // valid IANA name.
-// return "unicodeFFFE";
- return "utf-16be";
- } else {
- return "utf-16";
- }
- }
- }
-
- // Get the Windows code page represented by this object.
- public override int WindowsCodePage
- {
- get {
- // Windows reports the same code page number for
- // both the little-endian and big-endian forms.
- return UNICODE_CODE_PAGE;
- }
- }
-
-#endif // !ECMA_COMPAT
-
// Unicode decoder implementation.
private sealed class UnicodeDecoder : Decoder
{
diff --git a/mcs/class/corlib/System.Threading/ChangeLog b/mcs/class/corlib/System.Threading/ChangeLog
index 9d0aac67e54..e089886e13d 100644
--- a/mcs/class/corlib/System.Threading/ChangeLog
+++ b/mcs/class/corlib/System.Threading/ChangeLog
@@ -1,3 +1,7 @@
+2003-11-12 Miguel de Icaza <miguel@ximian.com>
+
+ * Thread.cs: Add new VolatileRead/VolatileWrite methods from 1.1
+
2003-10-23 Lluis Sanchez Gual <lluis@ximian.com>
* Thread.cs: Added ResetDataStoreStatus and RestoreDataStoreStatus
diff --git a/mcs/class/corlib/System.Threading/Thread.cs b/mcs/class/corlib/System.Threading/Thread.cs
index 26f01314121..c72639a0143 100755
--- a/mcs/class/corlib/System.Threading/Thread.cs
+++ b/mcs/class/corlib/System.Threading/Thread.cs
@@ -495,5 +495,97 @@ namespace System.Threading
state &= ~clr;
}
}
+
+#if NET_1_1
+ [MethodImplAttribute (MethodImplOptions.InternalCall)]
+ extern public static byte VolatileRead (ref byte address);
+
+ [MethodImplAttribute (MethodImplOptions.InternalCall)]
+ extern public static double VolatileRead (ref double address);
+
+ [MethodImplAttribute (MethodImplOptions.InternalCall)]
+ extern public static short VolatileRead (ref short address);
+
+ [MethodImplAttribute (MethodImplOptions.InternalCall)]
+ extern public static int VolatileRead (ref int address);
+
+ [MethodImplAttribute (MethodImplOptions.InternalCall)]
+ extern public static long VolatileRead (ref long address);
+
+ [MethodImplAttribute (MethodImplOptions.InternalCall)]
+ extern public static IntPtr VolatileRead (ref IntPtr address);
+
+ [MethodImplAttribute (MethodImplOptions.InternalCall)]
+ extern public static object VolatileRead (ref object address);
+
+ [CLSCompliant(false)]
+ [MethodImplAttribute (MethodImplOptions.InternalCall)]
+ extern public static sbyte VolatileRead (ref sbyte address);
+
+ [MethodImplAttribute (MethodImplOptions.InternalCall)]
+ extern public static float VolatileRead (ref float address);
+
+ [CLSCompliant (false)]
+ [MethodImplAttribute (MethodImplOptions.InternalCall)]
+ extern public static ushort VolatileRead (ref ushort address);
+
+ [CLSCompliant (false)]
+ [MethodImplAttribute (MethodImplOptions.InternalCall)]
+ extern public static uint VolatileRead (ref uint address);
+
+ [CLSCompliant (false)]
+ [MethodImplAttribute (MethodImplOptions.InternalCall)]
+ extern public static ulong VolatileRead (ref ulong address);
+
+ [CLSCompliant (false)]
+ [MethodImplAttribute (MethodImplOptions.InternalCall)]
+ extern public static byte VolatileRead (ref UIntPtr address);
+
+ [MethodImplAttribute (MethodImplOptions.InternalCall)]
+ extern public static void VolatileWrite (ref byte address, byte value);
+
+ [MethodImplAttribute (MethodImplOptions.InternalCall)]
+ extern public static void VolatileWrite (ref double address, double value);
+
+ [MethodImplAttribute (MethodImplOptions.InternalCall)]
+ extern public static void VolatileWrite (ref short address, short value);
+
+ [MethodImplAttribute (MethodImplOptions.InternalCall)]
+ extern public static void VolatileWrite (ref int address, int value);
+
+ [MethodImplAttribute (MethodImplOptions.InternalCall)]
+ extern public static void VolatileWrite (ref long address, long value);
+
+ [MethodImplAttribute (MethodImplOptions.InternalCall)]
+ extern public static void VolatileWrite (ref IntPtr address, IntPtr value);
+
+ [MethodImplAttribute (MethodImplOptions.InternalCall)]
+ extern public static void VolatileWrite (ref object address, object value);
+
+ [CLSCompliant(false)]
+ [MethodImplAttribute (MethodImplOptions.InternalCall)]
+ extern public static void VolatileWrite (ref sbyte address, sbyte value);
+
+ [MethodImplAttribute (MethodImplOptions.InternalCall)]
+ extern public static void VolatileWrite (ref float address, float value);
+
+ [CLSCompliant (false)]
+ [MethodImplAttribute (MethodImplOptions.InternalCall)]
+ extern public static void VolatileWrite (ref ushort address, ushort value);
+
+ [CLSCompliant (false)]
+ [MethodImplAttribute (MethodImplOptions.InternalCall)]
+ extern public static void VolatileWrite (ref uint address, uint value);
+
+ [CLSCompliant (false)]
+ [MethodImplAttribute (MethodImplOptions.InternalCall)]
+ extern public static void VolatileWrite (ref ulong address, ulong value);
+
+ [CLSCompliant (false)]
+ [MethodImplAttribute (MethodImplOptions.InternalCall)]
+ extern public static void VolatileWrite (ref UIntPtr address, UIntPtr value);
+
+#endif
+
}
}
diff --git a/mcs/class/corlib/System/Activator.cs b/mcs/class/corlib/System/Activator.cs
index 9c5fb134a7f..addeb58f530 100644
--- a/mcs/class/corlib/System/Activator.cs
+++ b/mcs/class/corlib/System/Activator.cs
@@ -15,6 +15,7 @@ using System.Runtime.Remoting;
using System.Runtime.Remoting.Activation;
using System.Runtime.CompilerServices;
using System.Security.Policy;
+using System.Configuration.Assemblies;
namespace System
{
@@ -32,6 +33,15 @@ namespace System
throw new NotImplementedException();
}
+#if NET_1_1
+ [MonoTODO]
+ public static ObjectHandle CreateComInstanceFrom (string assemblyFile, string typeName,
+ byte []hash, AssemblyHashAlgorithm hashalgo)
+ {
+ throw new NotImplementedException();
+ }
+#endif
+
public static ObjectHandle CreateInstanceFrom (string assemblyFile, string typeName)
{
return CreateInstanceFrom (assemblyFile, typeName, null);
diff --git a/mcs/class/corlib/System/AppDomain.cs b/mcs/class/corlib/System/AppDomain.cs
index bb01555ea56..03f1e95ad34 100755
--- a/mcs/class/corlib/System/AppDomain.cs
+++ b/mcs/class/corlib/System/AppDomain.cs
@@ -27,6 +27,7 @@ using System.Runtime.Remoting.Messaging;
using System.Security.Principal;
using System.Security.Policy;
using System.Security;
+using System.Configuration.Assemblies;
namespace System {
@@ -150,7 +151,15 @@ namespace System {
throw new NotImplementedException();
}
-
+
+#if NET_1_1
+ [MonoTODO]
+ public static ObjectHandle CreateComInstanceFrom (string assemblyFile, string typeName,
+ byte []hash, AssemblyHashAlgorithm hashalgo)
+ {
+ throw new NotImplementedException();
+ }
+#endif
public ObjectHandle CreateInstance (string assemblyName, string typeName)
{
@@ -486,13 +495,16 @@ namespace System {
return Load (rawAssembly, rawSymbolStore, new Evidence ());
}
- [MonoTODO]
+ [MethodImplAttribute (MethodImplOptions.InternalCall)]
+ private extern Assembly LoadAssemblyRaw (byte[] rawAssembly, byte[] rawSymbolStore,
+ Evidence securityEvidence);
+
public Assembly Load (byte[] rawAssembly, byte[] rawSymbolStore, Evidence securityEvidence)
{
if (rawAssembly == null)
throw new ArgumentNullException ("rawAssembly");
- throw new NotImplementedException ();
+ return LoadAssemblyRaw (rawAssembly, rawSymbolStore, securityEvidence);
}
[MonoTODO]
diff --git a/mcs/class/corlib/System/AppDomainSetup.cs b/mcs/class/corlib/System/AppDomainSetup.cs
index 8910f465d4d..7a4a5508bf7 100755
--- a/mcs/class/corlib/System/AppDomainSetup.cs
+++ b/mcs/class/corlib/System/AppDomainSetup.cs
@@ -31,6 +31,8 @@ namespace System {
bool publisher_policy;
private bool path_changed;
private LoaderOptimization loader_optimization;
+ bool disallow_binding_redirects;
+ bool disallow_code_downloads;
[MethodImplAttribute(MethodImplOptions.InternalCall)]
private static extern AppDomainSetup InitAppDomainSetup (AppDomainSetup setup);
@@ -53,10 +55,6 @@ namespace System {
appBase = Path.GetFullPath (appBase);
}
- len = appBase.Length;
- if (len == 0 || appBase [len - 1] != Path.DirectorySeparatorChar)
- appBase = appBase + Path.DirectorySeparatorChar;
-
return appBase;
}
@@ -193,6 +191,27 @@ namespace System {
shadow_copy_files = value;
}
}
-
+
+#if NET_1_1
+ public bool DisallowBindingRedirects {
+ get {
+ return disallow_binding_redirects;
+ }
+
+ set {
+ disallow_binding_redirects = value;
+ }
+ }
+
+ public bool DisallowCodeDownload {
+ get {
+ return disallow_code_downloads;
+ }
+
+ set {
+ disallow_code_downloads = value;
+ }
+ }
+#endif
}
}
diff --git a/mcs/class/corlib/System/Array.cs b/mcs/class/corlib/System/Array.cs
index 958d769c187..ff45734ae21 100644
--- a/mcs/class/corlib/System/Array.cs
+++ b/mcs/class/corlib/System/Array.cs
@@ -11,6 +11,7 @@
using System.Collections;
using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
namespace System
{
@@ -39,6 +40,12 @@ namespace System
}
}
+#if NET_1_1
+ [ComVisible (false)]
+ public long LongLength {
+ get { return Length; }
+ }
+#endif
public int Rank
{
get
@@ -122,6 +129,14 @@ namespace System
[MethodImplAttribute(MethodImplOptions.InternalCall)]
public extern int GetLength (int dimension);
+#if NET_1_1
+ [ComVisible (false)]
+ public long GetLongLength (int dimension)
+ {
+ return GetLength (dimension);
+ }
+#endif
+
[MethodImplAttribute(MethodImplOptions.InternalCall)]
public extern int GetLowerBound (int dimension);
@@ -221,6 +236,7 @@ namespace System
}
#if NET_1_1
+ [ComVisible (false)]
public object GetValue (long idx)
{
if (idx < 0 || idx > Int32.MaxValue)
@@ -229,6 +245,7 @@ namespace System
return GetValue ((int) idx);
}
+ [ComVisible (false)]
public object GetValue (long idx1, long idx2)
{
if (idx1 < 0 || idx1 > Int32.MaxValue)
@@ -240,6 +257,7 @@ namespace System
return GetValue ((int) idx1, (int) idx2);
}
+ [ComVisible (false)]
public object GetValue (long idx1, long idx2, long idx3)
{
if (idx1 < 0 || idx1 > Int32.MaxValue)
@@ -254,6 +272,7 @@ namespace System
return GetValue ((int) idx1, (int) idx2, (int) idx3);
}
+ [ComVisible (false)]
public void SetValue (object value, long idx)
{
if (idx < 0 || idx > Int32.MaxValue)
@@ -262,6 +281,7 @@ namespace System
SetValue (value, (int) idx);
}
+ [ComVisible (false)]
public void SetValue (object value, long idx1, long idx2)
{
if (idx1 < 0 || idx1 > Int32.MaxValue)
@@ -278,6 +298,7 @@ namespace System
SetValue (value, ind);
}
+ [ComVisible (false)]
public void SetValue (object value, long idx1, long idx2, long idx3)
{
if (idx1 < 0 || idx1 > Int32.MaxValue)
@@ -446,6 +467,7 @@ namespace System
return CreateInstance (elementType, GetIntArray (lengths));
}
+ [ComVisible (false)]
public object GetValue (long [] indices)
{
if (indices == null)
@@ -453,6 +475,7 @@ namespace System
return GetValue (GetIntArray (indices));
}
+ [ComVisible (false)]
public void SetValue (object value, long [] indices)
{
if (indices == null)
@@ -581,14 +604,13 @@ namespace System
if (array.Rank > 1)
throw new RankException ();
- if (index < array.GetLowerBound (0) || length < 0 ||
- index + length > array.GetUpperBound (0) + 1)
+ int low = array.GetLowerBound (0);
+ if (index < low || length < 0 || index + length > array.GetUpperBound (0) + 1)
throw new ArgumentOutOfRangeException ();
+ low = index - low;
for (int i = 0; i < length; i++)
- {
- array.SetValueImpl(null, index + i);
- }
+ array.SetValueImpl (null, low + i);
}
[MethodImplAttribute(MethodImplOptions.InternalCall)]
@@ -676,7 +698,41 @@ namespace System
}
}
}
-
+#if NET_1_1
+ public static void Copy (Array sourceArray, long sourceIndex, Array destinationArray,
+ long destinationIndex, long length)
+ {
+ if (sourceArray == null)
+ throw new ArgumentNullException ("sourceArray");
+
+ if (destinationArray == null)
+ throw new ArgumentNullException ("destinationArray");
+
+ if (sourceIndex < Int32.MinValue || sourceIndex > Int32.MaxValue)
+ throw new ArgumentOutOfRangeException ("sourceIndex",
+ "Must be in the Int32 range");
+
+ if (destinationIndex < Int32.MinValue || destinationIndex > Int32.MaxValue)
+ throw new ArgumentOutOfRangeException ("destinationIndex",
+ "Must be in the Int32 range");
+
+ if (length < 0 || length > Int32.MaxValue)
+ throw new ArgumentOutOfRangeException ("length",
+ "Must be >= 0 and <= Int32.MaxValue");
+
+ Copy (sourceArray, (int) sourceIndex, destinationArray,
+ (int) destinationIndex, (int) length);
+ }
+
+ public static void Copy (Array source, Array dest, long length)
+ {
+ if (length < 0 || length > Int32.MaxValue)
+ throw new ArgumentOutOfRangeException ("length",
+ "Must be >= 0 and <= Int32.MaxValue");
+
+ Copy (source, dest, (int) length);
+ }
+#endif
public static int IndexOf (Array array, object value)
{
if (array == null)
@@ -949,8 +1005,18 @@ namespace System
Copy (this, this.GetLowerBound(0), array, index, this.GetLength (0));
}
+#if NET_1_1
+ [ComVisible (false)]
+ public virtual void CopyTo (Array array, long index)
+ {
+ if (index < 0 || index > Int32.MaxValue)
+ throw new ArgumentOutOfRangeException ("index",
+ "Must be >= 0 and <= Int32.MaxValue");
- internal class SimpleEnumerator : IEnumerator {
+ CopyTo (array, (int) index);
+ }
+#endif
+ internal class SimpleEnumerator : IEnumerator, ICloneable {
Array enumeratee;
int currentpos;
int length;
@@ -993,6 +1059,11 @@ namespace System
public void Reset() {
currentpos= -1;
}
+
+ public object Clone ()
+ {
+ return MemberwiseClone ();
+ }
}
}
}
diff --git a/mcs/class/corlib/System/BadImageFormatException.cs b/mcs/class/corlib/System/BadImageFormatException.cs
index 8ea5857f5fa..0c948f82950 100644
--- a/mcs/class/corlib/System/BadImageFormatException.cs
+++ b/mcs/class/corlib/System/BadImageFormatException.cs
@@ -87,7 +87,10 @@ namespace System
public override string ToString ()
{
- return inner.ToString();
+ if (inner != null)
+ return inner.ToString();
+ else
+ return base.ToString ();
}
}
}
diff --git a/mcs/class/corlib/System/Boolean.cs b/mcs/class/corlib/System/Boolean.cs
index e28e7cb00fa..d9a1c8e575a 100644
--- a/mcs/class/corlib/System/Boolean.cs
+++ b/mcs/class/corlib/System/Boolean.cs
@@ -146,10 +146,12 @@ namespace System {
val = val.Trim ();
- if (String.Compare (val, TrueString, true) == 0)
+ if (String.Compare (val, TrueString, true,
+ CultureInfo.InvariantCulture) == 0)
return true;
- if (String.Compare (val, FalseString, true) == 0)
+ if (String.Compare (val, FalseString, true,
+ CultureInfo.InvariantCulture) == 0)
return false;
throw new FormatException (Locale.GetText (
diff --git a/mcs/class/corlib/System/ChangeLog b/mcs/class/corlib/System/ChangeLog
index 0a5fd40649f..efd3625e7f9 100644
--- a/mcs/class/corlib/System/ChangeLog
+++ b/mcs/class/corlib/System/ChangeLog
@@ -1,3 +1,133 @@
+2003-11-28 Dick Porter <dick@ximian.com>
+
+ * Type.cs:
+ * MonoType.cs:
+ * Enum.cs:
+ * Boolean.cs: Do string compares with the Invariant culture.
+
+2003-11-27 Ben Maurer <bmaurer@users.sourceforge.net>
+
+ * Array.cs: make the enumerator ICloneable
+
+2003-11-27 Ben Maurer <bmaurer@users.sourceforge.net>
+
+ * Decimal.cs (ToXXX): Call Convert.ToXXX.
+
+2003-11-26 Zoltan Varga <vargaz@freemail.hu>
+
+ * AppDomain.cs: Applied patch from ztashev@openlinksw.co.uk (Zdravko Tashev).
+ Implement Load(byte[]) methods.
+
+ * BadImageFormatException.cs: Fix ToString.
+
+2003-11-24 Zoltan Varga <vargaz@freemail.hu>
+
+ * MonoType.cs: Make Standard|HasThis match Standard in GetMethod and
+ GetConstructor, as done by MS.
+
+2003-11-19 Andreas Nahr <ClassDevelopment@A-SoftTech.com>
+
+ * FloatingPointFormatter.cs: Removed some unused variables to prevent csc compiler warnings
+
+2003-11-18 Lluis Sanchez Gual <lluis@ximian.com>
+
+ * TypeInitializationException.cs: Added missing serialization constructor.
+
+2003-11-18 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * AppDomainSetup.cs: Don't add an extra '/' at the end of
+ ApplicationBase. The tests pass now with mono.
+
+2003-11-18 Zoltan Varga <vargaz@freemail.hu>
+
+ * ValueType.cs: New optimized implementation for Equals and GetHashCode.
+
+2003-11-15 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * Environment.cs: use Directory in CurrentDirectory property.
+ We were not throwing any exception when setting the directory to an
+ invalid path.
+
+2003-11-14 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * Array.cs:
+ * Delegate.cs: implemented 1.1 stuff.
+
+ * Enum.cs:
+ * IntPtr.cs: removed extra attribute.
+ * PlatformID.cs: added WinCE.
+
+2003-11-14 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * ValueType.cs:
+ (Equals): compare the fields of structs too.
+ (GetHashCode): combine the hash code of all the fields.
+ Fixes bug #50901 (will remove the icall in a couple of days).
+
+2003-11-14 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * Array.cs: fixed Clear for non-zero bounded arrays. Fixes bug #50968.
+
+2003-11-14 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * DateTime.cs: handle century when we try to parse 4-digit years and
+ only 2 digits are present. Fixes bug #49394.
+
+2003-11-13 Miguel de Icaza <miguel@ximian.com>
+
+ * Console.cs: On utf-8 consoles, use unmarked output.
+
+2003-11-13 Andreas Nahr <ClassDevelopment@A-SoftTech.com>
+
+ * IAppDomainSetup.cs:
+ * _AppDomain.cs:
+ * Object.cs:
+ * Type.cs: Added missing attribute
+
+2003-11-12 Lluis Sanchez Gual <lluis@ximian.com>
+
+ * Environment.cs: Added internal method for getting the path to
+ machine.config.
+
+2003-11-12 Jackson Harper <jackson@ximian.com>
+
+ * Environment.cs: Add MyMusic and MyPictures to the SpecialFolder
+ enum. This fixes the SWF build.
+
+2003-11-12 Miguel de Icaza <miguel@ximian.com>
+
+ * PlatformID.cs: Remove Unix platform, we cant expose constants
+ that are not in the framework.
+
+ * OperatingSystem.cs: Adjust for the breakage.
+
+ * RuntimeMethodHandle.cs: Fix signature.
+
+ * Double.cs: Fix signature of TryParse.
+
+ * String.cs (Concat (object, object, object, object)): Add missing method.
+
+ * OperatingSystem.cs: Removed Equals, GetHashCode, they were not
+ in the .NET Framework.
+
+ * Enum.cs: Hide constructor.
+
+ Fix ToUint16 to be explicitly implemented.
+
+ * Console.cs: Add couple of extra missing methods (Write and
+ WriteLine overloaded)
+
+2003-11-11 Miguel de Icaza <miguel@ximian.com>
+
+ * AppDomain.cs, Activator.cs: New unimplmented entry points from
+ 1.1 (Com activation related).
+
+ * Exception.cs: Formatting.
+
+ * IServiceProvider.cs: Add ComVisible (true).
+
+ * AppDomainSetup.cs: Add a couple more properties from .NET 1.1
+
2003-11-03 Lluis Sanchez Gual <lluis@ximian.com>
* AppDomain.cs: Added some null checks in Load methods. This fixes bug
diff --git a/mcs/class/corlib/System/Console.cs b/mcs/class/corlib/System/Console.cs
index 8994105eb84..c2959b750fd 100644
--- a/mcs/class/corlib/System/Console.cs
+++ b/mcs/class/corlib/System/Console.cs
@@ -20,15 +20,23 @@ namespace System {
static Console ()
{
- stderr = new StreamWriter (OpenStandardError (), Encoding.Default);
+ string codepage = Encoding.InternalCodePage ();
+ Encoding encoding;
+
+ if (codepage.ToLower ().Replace ('-', '_') == "utf_8")
+ encoding = Encoding.UTF8Unmarked;
+ else
+ encoding = Encoding.Default;
+
+ stderr = new StreamWriter (OpenStandardError (), encoding);
((StreamWriter)stderr).AutoFlush = true;
stderr = TextWriter.Synchronized (stderr);
- stdout = new StreamWriter (OpenStandardOutput (), Encoding.Default);
+ stdout = new StreamWriter (OpenStandardOutput (), encoding);
((StreamWriter)stdout).AutoFlush = true;
stdout = TextWriter.Synchronized (stdout);
- stdin = new StreamReader (OpenStandardInput (), Encoding.Default);
+ stdin = new StreamReader (OpenStandardInput (), encoding);
stdin = TextReader.Synchronized (stdin);
}
@@ -201,6 +209,12 @@ namespace System {
{
stdout.Write (format, arg0, arg1, arg2);
}
+
+ [CLSCompliant(false)]
+ public static void Write (string format, object arg0, object arg1, object arg2, object arg3)
+ {
+ stdout.Write (String.Format (format, arg0, arg1, arg2, arg3));
+ }
public static void WriteLine ()
{
@@ -311,6 +325,12 @@ namespace System {
stdout.WriteLine();
}
+ [CLSCompliant(false)]
+ public static void WriteLine (string format, object arg0, object arg1, object arg2, object arg3)
+ {
+ stdout.WriteLine (String.Format (format, arg0, arg1, arg2, arg3));
+ }
+
public static int Read ()
{
return stdin.Read ();
diff --git a/mcs/class/corlib/System/DateTime.cs b/mcs/class/corlib/System/DateTime.cs
index b9feeffab92..262a8e15dc9 100644
--- a/mcs/class/corlib/System/DateTime.cs
+++ b/mcs/class/corlib/System/DateTime.cs
@@ -745,14 +745,17 @@ namespace System
if (num == 0) {
year = _ParseNumber (s, 2, false, sloppy_parsing, out num_parsed);
- year += (year < 30) ? 2000 : 1900;
} else if (num < 3) {
year = _ParseNumber (s, 2, true, sloppy_parsing, out num_parsed);
- year += (year < 30) ? 2000 : 1900;
} else {
year = _ParseNumber (s, 4, false, sloppy_parsing, out num_parsed);
num = 3;
}
+
+ //FIXME: We should do use dfi.Calendat.TwoDigitYearMax
+ if (num_parsed <= 2)
+ year += (year < 30) ? 2000 : 1900;
+
// if there is another digit next to the ones we just parsed, then the year value
// is too big for sure.
//if (num_parsed < s.Length && Char.IsDigit(s[num_parsed]) || (year != 0 && (year < 1 || year > 9999)))
@@ -1476,9 +1479,9 @@ namespace System
// TODO Implement me
[MonoTODO]
- public System.DateTime ToDateTime(IFormatProvider provider)
+ System.DateTime IConvertible.ToDateTime(IFormatProvider provider)
{
- return new System.DateTime(true,this.ticks);
+ return new System.DateTime (true,this.ticks);
}
decimal IConvertible.ToDecimal(IFormatProvider provider)
diff --git a/mcs/class/corlib/System/Decimal.cs b/mcs/class/corlib/System/Decimal.cs
index 46e8a807422..736dc24ba15 100644
--- a/mcs/class/corlib/System/Decimal.cs
+++ b/mcs/class/corlib/System/Decimal.cs
@@ -908,98 +908,64 @@ namespace System
return TypeCode.Decimal;
}
- [MonoTODO]
- public static byte ToByte(decimal value)
+ public static byte ToByte (decimal value)
{
- if(value < Byte.MinValue || value > Byte.MaxValue) {
- throw new OverflowException("Invalid value");
- }
- throw new NotImplementedException();
+ return Convert.ToByte (value);
}
- [MonoTODO]
- public static double ToDouble(decimal d)
+ public static double ToDouble (decimal value)
{
- throw new NotImplementedException();
+ return Convert.ToDouble (value);
}
- [MonoTODO]
- public static short ToInt16(decimal value)
+ public static short ToInt16 (decimal value)
{
- if(value < Int16.MinValue || value > Int16.MaxValue) {
- throw new OverflowException("Invalid value");
- }
- throw new NotImplementedException();
+ return Convert.ToInt16 (value);
}
- [MonoTODO]
- public static int ToInt32(decimal d)
+ public static int ToInt32 (decimal value)
{
- if(d < Int32.MinValue || d > Int32.MaxValue) {
- throw new OverflowException("Invalid value");
- }
- throw new NotImplementedException();
+ return Convert.ToInt32 (value);
}
-
- [MonoTODO]
- public static long ToInt64(decimal d)
+
+ public static long ToInt64 (decimal value)
{
- if(d < Int64.MinValue || d > Int64.MaxValue) {
- throw new OverflowException("Invalid value");
- }
- throw new NotImplementedException();
+ return Convert.ToInt64 (value);
}
[MonoTODO]
- public static long ToOACurrency(decimal value)
+ public static long ToOACurrency (decimal value)
{
- throw new NotImplementedException();
+ throw new NotImplementedException ();
}
- [MonoTODO]
[CLSCompliant(false)]
- public static sbyte ToSByte(decimal value)
+ public static sbyte ToSByte (decimal value)
{
- if(value < SByte.MinValue || value > SByte.MaxValue) {
- throw new OverflowException("Invalid value");
- }
- throw new NotImplementedException();
+ return Convert.ToSByte (value);
}
-
- [MonoTODO]
- public static float ToSingle(decimal d)
+
+ public static float ToSingle (decimal value)
{
- throw new NotImplementedException();
+ return Convert.ToSingle (value);
}
- [MonoTODO]
[CLSCompliant(false)]
- public static ushort ToUInt16(decimal value)
+ public static ushort ToUInt16 (decimal value)
{
- if(value < UInt16.MinValue || value > UInt16.MaxValue) {
- throw new OverflowException("Invalid value");
- }
- throw new NotImplementedException();
+ return Convert.ToUInt16 (value);
}
- [MonoTODO]
[CLSCompliant(false)]
- public static uint ToUInt32(decimal d)
+ public static uint ToUInt32 (decimal value)
{
- if(d < 0 || d > UInt32.MaxValue) {
- throw new OverflowException("Invalid value");
- }
- throw new NotImplementedException();
+ return Convert.ToUInt32 (value);
}
- [MonoTODO]
[CLSCompliant(false)]
- public static ulong ToUInt64(decimal d)
+ public static ulong ToUInt64 (decimal value)
{
- if(d < 0 || d > UInt64.MaxValue) {
- throw new OverflowException("Invalid value");
- }
- throw new NotImplementedException();
+ return Convert.ToUInt64 (value);
}
object IConvertible.ToType (Type conversionType, IFormatProvider provider)
diff --git a/mcs/class/corlib/System/Delegate.cs b/mcs/class/corlib/System/Delegate.cs
index 409d39adc4b..63a16863368 100644
--- a/mcs/class/corlib/System/Delegate.cs
+++ b/mcs/class/corlib/System/Delegate.cs
@@ -14,10 +14,14 @@ using System.Globalization;
using System.Reflection;
using System.Runtime.Serialization;
using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
namespace System {
+#if NET_1_1
+ [ClassInterface (ClassInterfaceType.AutoDual)]
+#endif
[MonoTODO]
public abstract class Delegate : ICloneable, ISerializable {
protected Type target_type;
@@ -182,7 +186,7 @@ namespace System {
return DynamicInvokeImpl (args);
}
- public virtual object DynamicInvokeImpl (object[] args)
+ internal virtual object DynamicInvokeImpl (object[] args)
{
if (Method == null){
Type[] mtypes = new Type [args.Length];
@@ -286,7 +290,16 @@ namespace System {
return this;
}
+#if NET_1_1
+ public static Delegate RemoveAll (Delegate source, Delegate value)
+ {
+ Delegate tmp = source;
+ while ((source = Delegate.Remove (source, value)) != tmp)
+ tmp = source;
+ return tmp;
+ }
+#endif
public static bool operator == (Delegate a, Delegate b)
{
if ((object)a == null) {
diff --git a/mcs/class/corlib/System/Double.cs b/mcs/class/corlib/System/Double.cs
index 7b7d655b9a2..0c0cd634024 100644
--- a/mcs/class/corlib/System/Double.cs
+++ b/mcs/class/corlib/System/Double.cs
@@ -317,12 +317,13 @@ namespace System {
public static bool TryParse (string s,
NumberStyles style,
IFormatProvider provider,
- ref double result)
+ out double result)
{
try {
result = Parse (s, style, provider);
return true;
} catch {
+ result = 0;
return false;
}
}
diff --git a/mcs/class/corlib/System/Enum.cs b/mcs/class/corlib/System/Enum.cs
index f4d1c801d8e..195f3922e97 100644
--- a/mcs/class/corlib/System/Enum.cs
+++ b/mcs/class/corlib/System/Enum.cs
@@ -51,9 +51,11 @@ namespace System {
[Serializable]
public abstract class Enum : ValueType, IComparable, IConvertible, IFormattable {
+ internal Enum () {
+ }
+
// IConvertible methods Start -->
- [CLSCompliant(false)]
public TypeCode GetTypeCode () {
MonoEnumInfo info;
MonoEnumInfo.GetInfo (this.GetType (), out info);
@@ -122,7 +124,7 @@ namespace System {
}
[CLSCompliant(false)]
- public ushort ToUInt16 (IFormatProvider provider)
+ ushort IConvertible.ToUInt16 (IFormatProvider provider)
{
return Convert.ToUInt16 (get_value (), provider);
}
@@ -273,7 +275,7 @@ namespace System {
foreach (string name in names) {
bool found = false;
for (i = 0; i < info.values.Length; ++i) {
- if (String.Compare (name, info.names [i], ignoreCase) == 0) {
+ if (String.Compare (name, info.names [i], ignoreCase, CultureInfo.InvariantCulture) == 0) {
switch (typeCode) {
case TypeCode.Byte:
retVal |= (long)((byte)info.values.GetValue (i));
diff --git a/mcs/class/corlib/System/Environment.cs b/mcs/class/corlib/System/Environment.cs
index c52666af6e0..ec912af6f90 100644
--- a/mcs/class/corlib/System/Environment.cs
+++ b/mcs/class/corlib/System/Environment.cs
@@ -40,6 +40,7 @@ namespace System
Recent = 0x08,
SendTo = 0x09,
StartMenu = 0x0b,
+ MyMusic = 0x0d,
DesktopDirectory = 0x10,
Templates = 0x15,
ApplicationData = 0x1a,
@@ -50,6 +51,7 @@ namespace System
CommonApplicationData = 0x23,
System = 0x25,
ProgramFiles = 0x26,
+ MyPictures = 0x27,
CommonProgramFiles = 0x2b,
}
@@ -82,16 +84,12 @@ namespace System
// [EnvironmentPermissionAttribute(SecurityAction.Demand, Unrestricted = true)]
get {
- MonoIOError error;
-
- return MonoIO.GetCurrentDirectory (out error);
+ return Directory.GetCurrentDirectory ();
}
[MonoTODO("disabled because of compile error. Need mcs magic.")]
//[SecurityPermissionAttribute(SecurityAction.Demand, Flags = SecurityPermissionFlag.UnmanagedCode)]
set {
- MonoIOError error;
-
- MonoIO.SetCurrentDirectory (value, out error);
+ Directory.SetCurrentDirectory (value);
}
}
@@ -330,6 +328,8 @@ namespace System
[MethodImplAttribute (MethodImplOptions.InternalCall)]
private extern static string [] GetEnvironmentVariableNames ();
+ [MethodImplAttribute (MethodImplOptions.InternalCall)]
+ internal extern static string GetMachineConfigPath ();
}
}
diff --git a/mcs/class/corlib/System/Exception.cs b/mcs/class/corlib/System/Exception.cs
index 3fca9ae2396..cbc061a3b98 100644
--- a/mcs/class/corlib/System/Exception.cs
+++ b/mcs/class/corlib/System/Exception.cs
@@ -49,13 +49,13 @@ namespace System {
class_name = info.GetString ("ClassName");
message = info.GetString ("Message");
- inner_exception = (Exception) info.GetValue ("InnerException", typeof (Exception));
help_link = info.GetString ("HelpURL");
stack_trace = info.GetString ("StackTraceString");
remote_stack_trace = info.GetString ("RemoteStackTrace");
remote_stack_index = info.GetInt32 ("RemoteStackIndex");
- hresult = info.GetInt32 ("HResult");
- source = info.GetString ("Source");
+ hresult = info.GetInt32 ("HResult");
+ source = info.GetString ("Source");
+ inner_exception = (Exception) info.GetValue ("InnerException", typeof (Exception));
}
public Exception (string msg, Exception e)
@@ -98,6 +98,11 @@ namespace System {
}
}
+ internal void SetMessage (string s)
+ {
+ message = s;
+ }
+
public virtual string Message
{
get
diff --git a/mcs/class/corlib/System/FloatingPointFormatter.cs b/mcs/class/corlib/System/FloatingPointFormatter.cs
index 77fec21e81d..9e0b89660aa 100644
--- a/mcs/class/corlib/System/FloatingPointFormatter.cs
+++ b/mcs/class/corlib/System/FloatingPointFormatter.cs
@@ -68,7 +68,7 @@ namespace System {
try {
return FormatCustom(value, nfi, format);
}
- catch (Exception e) {
+ catch (Exception) {
string msg = "An exception was thrown but the " +
"application will continue working right.\n" +
"Please mail to \"yoros@wanadoo.es\" with the " +
@@ -678,7 +678,6 @@ namespace System {
private string FormatCustom (double value,
NumberFormatInfo nfi, string format) {
- string first, middle, last;
int first_semicolon, last_semicolon;
first_semicolon = format.IndexOf(';');
last_semicolon = format.LastIndexOf(';');
diff --git a/mcs/class/corlib/System/IAppDomainSetup.cs b/mcs/class/corlib/System/IAppDomainSetup.cs
index 31eddcd62b7..8abbde1eac9 100644
--- a/mcs/class/corlib/System/IAppDomainSetup.cs
+++ b/mcs/class/corlib/System/IAppDomainSetup.cs
@@ -1,6 +1,5 @@
-
//
-// System/IAppDomainSetup.cs
+// System.IAppDomainSetup.cs
//
// Author:
// Dietmar Maurer (dietmar@ximian.com)
@@ -9,9 +8,12 @@
//
using System;
+using System.Runtime.InteropServices;
namespace System {
+ [InterfaceType (ComInterfaceType.InterfaceIsIUnknown)]
+ [Guid ("27FFF232-A7A8-40DD-8D4A-734AD59fCD41")]
public interface IAppDomainSetup {
string ApplicationBase { get; set; }
diff --git a/mcs/class/corlib/System/IServiceProvider.cs b/mcs/class/corlib/System/IServiceProvider.cs
index 13992c20145..e215c2ed7fd 100644
--- a/mcs/class/corlib/System/IServiceProvider.cs
+++ b/mcs/class/corlib/System/IServiceProvider.cs
@@ -8,13 +8,12 @@
//
using System;
+using System.Runtime.InteropServices;
namespace System {
-// [ComVisible(false)]
+ [ComVisible(true)]
public interface IServiceProvider {
-
object GetService (Type serviceType);
-
}
}
diff --git a/mcs/class/corlib/System/IntPtr.cs b/mcs/class/corlib/System/IntPtr.cs
index aec5aede972..8d16681f67b 100644
--- a/mcs/class/corlib/System/IntPtr.cs
+++ b/mcs/class/corlib/System/IntPtr.cs
@@ -30,9 +30,6 @@ using System.Runtime.Serialization;
namespace System {
- [
- CLSCompliant(true)
- ]
[Serializable]
public unsafe struct IntPtr : ISerializable {
diff --git a/mcs/class/corlib/System/MonoType.cs b/mcs/class/corlib/System/MonoType.cs
index 2641e5dbe65..21b2d923792 100644
--- a/mcs/class/corlib/System/MonoType.cs
+++ b/mcs/class/corlib/System/MonoType.cs
@@ -66,7 +66,8 @@ namespace System
MethodBase[] match;
int count = 0;
foreach (ConstructorInfo m in methods) {
- if (callConvention != CallingConventions.Any && m.CallingConvention != callConvention)
+ // Under MS.NET, Standard|HasThis matches Standard...
+ if (callConvention != CallingConventions.Any && ((m.CallingConvention & callConvention) != callConvention))
continue;
found = m;
count++;
@@ -84,7 +85,7 @@ namespace System
else {
count = 0;
foreach (ConstructorInfo m in methods) {
- if (callConvention != CallingConventions.Any && m.CallingConvention != callConvention)
+ if (callConvention != CallingConventions.Any && ((m.CallingConvention & callConvention) != callConvention))
continue;
match [count++] = m;
}
@@ -125,9 +126,9 @@ namespace System
Type[] interfaces = GetInterfaces();
foreach (Type type in interfaces) {
- if (String.Compare (type.Name, name, ignoreCase) == 0)
+ if (String.Compare (type.Name, name, ignoreCase, CultureInfo.InvariantCulture) == 0)
return type;
- if (String.Compare (type.FullName, name, ignoreCase) == 0)
+ if (String.Compare (type.FullName, name, ignoreCase, CultureInfo.InvariantCulture) == 0)
return type;
}
@@ -156,9 +157,10 @@ namespace System
MethodBase[] match;
int count = 0;
foreach (MethodInfo m in methods) {
- if (String.Compare (m.Name, name, ignoreCase) != 0)
+ if (String.Compare (m.Name, name, ignoreCase, CultureInfo.InvariantCulture) != 0)
continue;
- if (callConvention != CallingConventions.Any && m.CallingConvention != callConvention)
+ // Under MS.NET, Standard|HasThis matches Standard...
+ if (callConvention != CallingConventions.Any && ((m.CallingConvention & callConvention) != callConvention))
continue;
found = m;
count++;
@@ -176,9 +178,9 @@ namespace System
else {
count = 0;
foreach (MethodInfo m in methods) {
- if (String.Compare (m.Name, name, ignoreCase) != 0)
+ if (String.Compare (m.Name, name, ignoreCase, CultureInfo.InvariantCulture) != 0)
continue;
- if (callConvention != CallingConventions.Any && m.CallingConvention != callConvention)
+ if (callConvention != CallingConventions.Any && ((m.CallingConvention & callConvention) != callConvention))
continue;
match [count++] = m;
}
@@ -212,7 +214,7 @@ namespace System
bool ignoreCase = ((bindingAttr & BindingFlags.IgnoreCase) != 0);
foreach (PropertyInfo info in props) {
- if (String.Compare (info.Name, name, ignoreCase) != 0)
+ if (String.Compare (info.Name, name, ignoreCase, CultureInfo.InvariantCulture) != 0)
continue;
if (returnType != null && info.PropertyType != returnType)
@@ -331,13 +333,13 @@ namespace System
object state = null;
int i, count = 0;
for (i = 0; i < methods.Length; ++i) {
- if (String.Compare (methods [i].Name, name, ignoreCase) == 0)
+ if (String.Compare (methods [i].Name, name, ignoreCase, CultureInfo.InvariantCulture) == 0)
count++;
}
MethodBase[] smethods = new MethodBase [count];
count = 0;
for (i = 0; i < methods.Length; ++i) {
- if (String.Compare (methods [i].Name, name, ignoreCase) == 0)
+ if (String.Compare (methods [i].Name, name, ignoreCase, CultureInfo.InvariantCulture) == 0)
smethods [count++] = methods [i];
}
MethodBase m = binder.BindToMethod (invokeAttr, smethods, ref args, modifiers, culture, namedParameters, out state);
@@ -370,14 +372,14 @@ namespace System
object state = null;
int i, count = 0;
for (i = 0; i < properties.Length; ++i) {
- if (String.Compare (properties [i].Name, name, ignoreCase) == 0 && (properties [i].GetGetMethod () != null))
+ if (String.Compare (properties [i].Name, name, ignoreCase, CultureInfo.InvariantCulture) == 0 && (properties [i].GetGetMethod () != null))
count++;
}
MethodBase[] smethods = new MethodBase [count];
count = 0;
for (i = 0; i < properties.Length; ++i) {
MethodBase mb = properties [i].GetGetMethod ();
- if (String.Compare (properties [i].Name, name, ignoreCase) == 0 && (mb != null))
+ if (String.Compare (properties [i].Name, name, ignoreCase, CultureInfo.InvariantCulture) == 0 && (mb != null))
smethods [count++] = mb;
}
MethodBase m = binder.BindToMethod (invokeAttr, smethods, ref args, modifiers, culture, namedParameters, out state);
@@ -391,14 +393,14 @@ namespace System
object state = null;
int i, count = 0;
for (i = 0; i < properties.Length; ++i) {
- if (String.Compare (properties [i].Name, name, ignoreCase) == 0 && (properties [i].GetSetMethod () != null))
+ if (String.Compare (properties [i].Name, name, ignoreCase, CultureInfo.InvariantCulture) == 0 && (properties [i].GetSetMethod () != null))
count++;
}
MethodBase[] smethods = new MethodBase [count];
count = 0;
for (i = 0; i < properties.Length; ++i) {
MethodBase mb = properties [i].GetSetMethod ();
- if (String.Compare (properties [i].Name, name, ignoreCase) == 0 && (mb != null))
+ if (String.Compare (properties [i].Name, name, ignoreCase, CultureInfo.InvariantCulture) == 0 && (mb != null))
smethods [count++] = mb;
}
MethodBase m = binder.BindToMethod (invokeAttr, smethods, ref args, modifiers, culture, namedParameters, out state);
@@ -538,7 +540,7 @@ namespace System
UnitySerializationHolder.GetTypeData (this, info, context);
}
-#if GENERICS
+#if NET_1_2
public extern override bool HasGenericArguments {
[MethodImplAttribute(MethodImplOptions.InternalCall)]
get;
diff --git a/mcs/class/corlib/System/MulticastDelegate.cs b/mcs/class/corlib/System/MulticastDelegate.cs
index 1078c19f1aa..e7ca231afa6 100644
--- a/mcs/class/corlib/System/MulticastDelegate.cs
+++ b/mcs/class/corlib/System/MulticastDelegate.cs
@@ -48,7 +48,7 @@ namespace System {
}
#endif
- public override object DynamicInvokeImpl( object[] args )
+ internal override object DynamicInvokeImpl( object[] args )
{
if ( prev != null )
prev.DynamicInvokeImpl( args );
diff --git a/mcs/class/corlib/System/Object.cs b/mcs/class/corlib/System/Object.cs
index 79ba4e50ed5..675b43162b6 100644
--- a/mcs/class/corlib/System/Object.cs
+++ b/mcs/class/corlib/System/Object.cs
@@ -8,11 +8,13 @@
//
//
+using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
namespace System {
[Serializable]
+ [ClassInterface (ClassInterfaceType.AutoDual)]
public class Object {
// <summary>
diff --git a/mcs/class/corlib/System/OperatingSystem.cs b/mcs/class/corlib/System/OperatingSystem.cs
index 93729bb4a45..dee889cd13e 100644
--- a/mcs/class/corlib/System/OperatingSystem.cs
+++ b/mcs/class/corlib/System/OperatingSystem.cs
@@ -65,38 +65,18 @@ namespace System
}
/// <summary>
- /// Return true if obj equals this object
- /// </summary>
- public override bool Equals(object obj)
- {
- //Check for null and compare run-time types.
- if (obj == null || GetType() != obj.GetType()) return false;
- OperatingSystem os = (OperatingSystem)obj;
- return (itsPlatform == os.itsPlatform) &&
- (os.itsVersion.Equals(itsVersion));
- }
-
- /// <summary>
- /// Return hash code
- /// </summary>
- public override int GetHashCode()
- { // this leave us enuf for 256 unique platforms which should suffice for a good while
- return ((int)itsPlatform << 24) | itsVersion.GetHashCode() >> 8;
- }
-
- /// <summary>
/// Return a string reprentation of this instance
/// </summary>
public override string ToString()
{
string str;
- switch(itsPlatform)
+ switch((int) itsPlatform)
{
- case System.PlatformID.Win32NT: str = "Microsoft Windows NT"; break;
- case System.PlatformID.Win32S: str = "Microsoft Win32S"; break;
- case System.PlatformID.Win32Windows: str = "Microsoft Windows 98"; break;
- case System.PlatformID.Unix: str = "Unix"; break;
+ case (int) System.PlatformID.Win32NT: str = "Microsoft Windows NT"; break;
+ case (int) System.PlatformID.Win32S: str = "Microsoft Win32S"; break;
+ case (int) System.PlatformID.Win32Windows: str = "Microsoft Windows 98"; break;
+ case 128 /* PlatformID.Unix */: str = "Unix"; break;
default: str = Locale.GetText ("<unknown>"); break;
}
diff --git a/mcs/class/corlib/System/PlatformID.cs b/mcs/class/corlib/System/PlatformID.cs
index 56d2299e9fb..0cda8fb3502 100644
--- a/mcs/class/corlib/System/PlatformID.cs
+++ b/mcs/class/corlib/System/PlatformID.cs
@@ -17,21 +17,18 @@ namespace System {
/// </summary>
public enum PlatformID {
- /// <summary>
- /// </summary>
Win32S = 0,
- /// <summary>
- /// </summary>
Win32Windows = 1,
- /// <summary>
- /// </summary>
Win32NT = 2,
+#if NET_1_1
+ WinCE = 3
+#endif
- /// <summary>
- /// </summary>
- Unix = 128
+ // We can not expose this to userland, since it would break bin compat
+
+ // Unix = 128
} // PlatformID
} // System
diff --git a/mcs/class/corlib/System/RuntimeMethodHandle.cs b/mcs/class/corlib/System/RuntimeMethodHandle.cs
index c1b367d4f9f..1877f88753a 100755
--- a/mcs/class/corlib/System/RuntimeMethodHandle.cs
+++ b/mcs/class/corlib/System/RuntimeMethodHandle.cs
@@ -39,7 +39,7 @@ namespace System {
}
[MethodImpl (MethodImplOptions.InternalCall)]
- public static extern IntPtr GetFunctionPointer (IntPtr m);
+ static extern IntPtr GetFunctionPointer (IntPtr m);
public IntPtr GetFunctionPointer ()
{
diff --git a/mcs/class/corlib/System/String.cs b/mcs/class/corlib/System/String.cs
index c4f705c084e..5e8cf799619 100644
--- a/mcs/class/corlib/System/String.cs
+++ b/mcs/class/corlib/System/String.cs
@@ -704,6 +704,34 @@ namespace System {
return Concat (s1, s2, s3);
}
+ public static String Concat (Object obj1, Object obj2, Object obj3, Object obj4)
+ {
+ string s1, s2, s3, s4;
+
+ if (obj1 == null)
+ s1 = String.Empty;
+ else
+ s1 = obj1.ToString ();
+
+ if (obj2 == null)
+ s2 = String.Empty;
+ else
+ s2 = obj2.ToString ();
+
+ if (obj3 == null)
+ s3 = String.Empty;
+ else
+ s3 = obj3.ToString ();
+
+ if (obj4 == null)
+ s4 = String.Empty;
+ else
+ s4 = obj4.ToString ();
+
+ return Concat (s1, s2, s3, s4);
+
+ }
+
public static String Concat(String s1, String s2)
{
if (s1 == null) {
diff --git a/mcs/class/corlib/System/Type.cs b/mcs/class/corlib/System/Type.cs
index 206d75ff12f..46b5efd9dbe 100644
--- a/mcs/class/corlib/System/Type.cs
+++ b/mcs/class/corlib/System/Type.cs
@@ -11,6 +11,7 @@
using System.Reflection;
using System.Collections;
+using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
using System.Globalization;
@@ -22,6 +23,7 @@ namespace System {
[MonoTODO]
[Serializable]
+ [ClassInterface (ClassInterfaceType.AutoDual)]
public abstract class Type : MemberInfo, IReflect {
internal RuntimeTypeHandle _impl;
@@ -46,7 +48,7 @@ namespace System {
static bool FilterNameIgnoreCase_impl (MemberInfo m, object filterCriteria)
{
string name = (string) filterCriteria;
- return String.Compare (name, m.Name, true) == 0;
+ return String.Compare (name, m.Name, true, CultureInfo.InvariantCulture) == 0;
}
[MonoTODO]
@@ -929,7 +931,7 @@ namespace System {
return FullName;
}
-#if GENERICS
+#if NET_1_2
[MethodImplAttribute(MethodImplOptions.InternalCall)]
public extern Type [] GetGenericArguments ();
diff --git a/mcs/class/corlib/System/TypeInitializationException.cs b/mcs/class/corlib/System/TypeInitializationException.cs
index cae537d64b5..13264478f0b 100644
--- a/mcs/class/corlib/System/TypeInitializationException.cs
+++ b/mcs/class/corlib/System/TypeInitializationException.cs
@@ -22,6 +22,12 @@ namespace System {
this.type_name = type_name;
}
+ internal TypeInitializationException (SerializationInfo info, StreamingContext sc)
+ : base (info, sc)
+ {
+ type_name = info.GetString ("TypeName");
+ }
+
// Properties
public string TypeName {
get {
diff --git a/mcs/class/corlib/System/ValueType.cs b/mcs/class/corlib/System/ValueType.cs
index 77b485bf0c0..d6747770259 100644
--- a/mcs/class/corlib/System/ValueType.cs
+++ b/mcs/class/corlib/System/ValueType.cs
@@ -3,10 +3,13 @@
//
// Author:
// Miguel de Icaza (miguel@ximian.com)
+// Gonzalo Paniagua Javier (gonzalo@ximian.com)
//
// (C) Ximian, Inc. http://www.ximian.com
+// (C) 2003 Novell, Inc. http://www.novell.com
//
+using System.Reflection;
using System.Runtime.CompilerServices;
namespace System {
@@ -21,20 +24,65 @@ namespace System {
{
}
+ [MethodImplAttribute(MethodImplOptions.InternalCall)]
+ internal extern static bool InternalEquals (object o1, object o2, out object[] fields);
+
+ // This is also used by RuntimeHelpers
+ internal static bool DefaultEquals (object o1, object o2)
+ {
+ object[] fields;
+
+ if (o2 == null)
+ return false;
+
+ bool res = InternalEquals (o1, o2, out fields);
+ if (fields == null)
+ return res;
+
+ for (int i = 0; i < fields.Length; i += 2) {
+ object meVal = fields [i];
+ object youVal = fields [i + 1];
+ if (meVal == null) {
+ if (youVal == null)
+ continue;
+
+ return false;
+ }
+
+ if (!meVal.Equals (youVal))
+ return false;
+ }
+
+ return true;
+ }
+
// <summary>
// True if this instance and o represent the same type
// and have the same value.
// </summary>
public override bool Equals (object o) {
- return InternalEquals (this, o);
+ return DefaultEquals (this, o);
}
+ [MethodImplAttribute(MethodImplOptions.InternalCall)]
+ internal extern static int InternalGetHashCode (object o, out object[] fields);
+
// <summary>
// Gets a hashcode for this value type using the
// bits in the structure
// </summary>
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- public extern override int GetHashCode ();
+ public override int GetHashCode ()
+ {
+ object[] fields;
+ int result = InternalGetHashCode (this, out fields);
+
+ if (fields != null)
+ for (int i = 0; i < fields.Length; ++i)
+ if (fields [i] != null)
+ result ^= fields [i].GetHashCode ();
+
+ return result;
+ }
// <summary>
// Stringified representation of this ValueType.
@@ -45,8 +93,5 @@ namespace System {
{
return GetType().FullName;
}
-
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- public extern static bool InternalEquals (object o1, object o2);
}
}
diff --git a/mcs/class/corlib/System/_AppDomain.cs b/mcs/class/corlib/System/_AppDomain.cs
index ceeff566375..4c1c459c4d5 100755
--- a/mcs/class/corlib/System/_AppDomain.cs
+++ b/mcs/class/corlib/System/_AppDomain.cs
@@ -12,11 +12,14 @@ using System.Reflection;
using System.Reflection.Emit;
using System.Globalization;
using System.Runtime.Remoting;
+using System.Runtime.InteropServices;
namespace System
{
[CLSCompliant(false)]
+[InterfaceType (ComInterfaceType.InterfaceIsIUnknown)]
+[Guid ("05F696DC-2B29-3663-AD8B-C4389CF2A713")]
public interface _AppDomain {
string BaseDirectory {get; }
diff --git a/mcs/class/corlib/Test/ChangeLog b/mcs/class/corlib/Test/ChangeLog
index 3f80f2b7b1b..00a5be75cfc 100644
--- a/mcs/class/corlib/Test/ChangeLog
+++ b/mcs/class/corlib/Test/ChangeLog
@@ -1,3 +1,8 @@
+2003-11-14 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * corlib_linux_test.args: Removed file.
+ * corlib_test.args: Removed file.
+
2003-08-11 Duncan Mak <duncan@ximian.com>
* corlib_linux_test.args: Add DictionaryBaseTest.cs by Carlos
diff --git a/mcs/class/corlib/Test/System.IO/ChangeLog b/mcs/class/corlib/Test/System.IO/ChangeLog
index 280b1b8269a..1af6a5e067e 100644
--- a/mcs/class/corlib/Test/System.IO/ChangeLog
+++ b/mcs/class/corlib/Test/System.IO/ChangeLog
@@ -1,3 +1,7 @@
+2003-11-15 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * StringReaderTest.cs: added test from bug #51020.
+
2003-10-21 Nick Drochak <ndrochak@gol.com>
* BufferedSTreamTest.cs: Make TearDown smarter about possible
diff --git a/mcs/class/corlib/Test/System.IO/StringReaderTest.cs b/mcs/class/corlib/Test/System.IO/StringReaderTest.cs
index 48f419b2a4c..a8ed892a5ea 100644
--- a/mcs/class/corlib/Test/System.IO/StringReaderTest.cs
+++ b/mcs/class/corlib/Test/System.IO/StringReaderTest.cs
@@ -165,6 +165,20 @@ public class StringReaderTest : Assertion {
}
}
+ [Test]
+ public void MoreEOL ()
+ {
+ TextReader tr = new StringReader ("There she was just a walking\n" +
+ "Down the street singin'\r" +
+ "Do wah diddy diddy dum diddy do");
+
+ int i = 0;
+ while (tr.ReadLine () != null)
+ i++;
+
+ AssertEquals ("#01", 3, i);
+ }
+
}
}
diff --git a/mcs/class/corlib/Test/System.Reflection.Emit/ChangeLog b/mcs/class/corlib/Test/System.Reflection.Emit/ChangeLog
index e31fea4ecaa..b1284b42092 100644
--- a/mcs/class/corlib/Test/System.Reflection.Emit/ChangeLog
+++ b/mcs/class/corlib/Test/System.Reflection.Emit/ChangeLog
@@ -1,3 +1,8 @@
+2003-11-17 Zoltan Varga <vargaz@freemail.hu>
+
+ * ConstructorBuilderTest.cs (TestAttributes): Make this test more
+ general so it runs on mono too.
+
2003-07-11 Zoltan Varga <vargaz@freemail.hu>
* ModuleBuilderTest.cs: Added tests for IsTransient ().
diff --git a/mcs/class/corlib/Test/System.Reflection.Emit/ConstructorBuilderTest.cs b/mcs/class/corlib/Test/System.Reflection.Emit/ConstructorBuilderTest.cs
index d3bba9dd0de..435a836a990 100644
--- a/mcs/class/corlib/Test/System.Reflection.Emit/ConstructorBuilderTest.cs
+++ b/mcs/class/corlib/Test/System.Reflection.Emit/ConstructorBuilderTest.cs
@@ -46,8 +46,10 @@ public class ConstructorBuilderTest : Assertion
ConstructorBuilder cb = genClass.DefineConstructor (
MethodAttributes.Public, 0, new Type [0]);
- AssertEquals ("Attributes works",
- cb.Attributes, MethodAttributes.Public | MethodAttributes.SpecialName);
+ Assert ("Attributes works",
+ (cb.Attributes & MethodAttributes.Public) != 0);
+ Assert ("Attributes works",
+ (cb.Attributes & MethodAttributes.SpecialName) != 0);
}
public void TestCallingConvention () {
diff --git a/mcs/class/corlib/Test/System.Reflection/ChangeLog b/mcs/class/corlib/Test/System.Reflection/ChangeLog
index 579f178026d..d82f5dad5b4 100644
--- a/mcs/class/corlib/Test/System.Reflection/ChangeLog
+++ b/mcs/class/corlib/Test/System.Reflection/ChangeLog
@@ -1,3 +1,12 @@
+2003-11-24 Zoltan Varga <vargaz@freemail.hu>
+
+ * ModuleTest.cs: Make the assembly name unique to fix the GlobalData
+ test.
+
+2003-11-17 Zoltan Varga <vargaz@freemail.hu>
+
+ * ModuleTest.cs: Fix temp folder path
+
2003-10-17 Zoltan Varga <vargaz@freemail.hu>
* AssemblyNameTest.cs: Convert to Nunit2 format, add tests for
diff --git a/mcs/class/corlib/Test/System.Reflection/ModuleTest.cs b/mcs/class/corlib/Test/System.Reflection/ModuleTest.cs
index 4598e3e2b31..cb92a9d760b 100644
--- a/mcs/class/corlib/Test/System.Reflection/ModuleTest.cs
+++ b/mcs/class/corlib/Test/System.Reflection/ModuleTest.cs
@@ -23,7 +23,7 @@ namespace MonoTests.System.Reflection
[TestFixture]
public class ModuleTest : Assertion
{
- static string TempFolder = Path.Combine (Path.GetTempPath (), "MonoTests.System.Reflection.Emit.ModuleTest");
+ static string TempFolder = Path.Combine (Path.GetTempPath (), "MonoTests.System.Reflection.ModuleTest");
[SetUp]
public void SetUp () {
@@ -48,8 +48,11 @@ public class ModuleTest : Assertion
[Test]
public void TestGlobalData () {
+ string name = "moduletest-assembly";
+ string fileName = name + ".dll";
+
AssemblyName assemblyName = new AssemblyName();
- assemblyName.Name = "foo";
+ assemblyName.Name = name;
AssemblyBuilder ab
= Thread.GetDomain().DefineDynamicAssembly(
@@ -60,10 +63,9 @@ public class ModuleTest : Assertion
sw.WriteLine ("FOO");
}
- // Why the hell do linked resources need to be in the same dir as the assembly ???
ab.AddResourceFile ("res", "res");
- ModuleBuilder mb = ab.DefineDynamicModule("foo.dll", "foo.dll");
+ ModuleBuilder mb = ab.DefineDynamicModule(fileName, fileName);
mb.DefineInitializedData ("DATA", new byte [100], FieldAttributes.Public);
mb.DefineInitializedData ("DATA2", new byte [100], FieldAttributes.Public);
@@ -72,9 +74,9 @@ public class ModuleTest : Assertion
mb.DefineInitializedData ("DATA_PRIVATE", new byte [100], 0);
mb.CreateGlobalFunctions ();
- ab.Save ("foo.dll");
+ ab.Save (fileName);
- Assembly assembly = Assembly.LoadFrom (Path.Combine (TempFolder, "foo.dll"));
+ Assembly assembly = Assembly.LoadFrom (Path.Combine (TempFolder, fileName));
Module module = assembly.GetLoadedModules ()[0];
diff --git a/mcs/class/corlib/Test/System.Runtime.Remoting/ChangeLog b/mcs/class/corlib/Test/System.Runtime.Remoting/ChangeLog
index 80b6f69e5bf..3847c91aacb 100644
--- a/mcs/class/corlib/Test/System.Runtime.Remoting/ChangeLog
+++ b/mcs/class/corlib/Test/System.Runtime.Remoting/ChangeLog
@@ -1,3 +1,11 @@
+2003-11-26 Lluis Sanchez Gual <lluis@ximian.com>
+
+ * SoapServicesTest.cs: New test added.
+
+2003-11-19 Lluis Sanchez Gual <lluis@ximian.com>
+
+ * ContextTest.cs, SynchronizationAttributeTest.cs: New tests added.
+
2003-06-19 Nick Drochak <ndrochak@gol.com>
* RemotingServicesTest.cs: Lazy fix/workaround for "can't reuse
diff --git a/mcs/class/corlib/Test/System.Runtime.Remoting/ContextTest.cs b/mcs/class/corlib/Test/System.Runtime.Remoting/ContextTest.cs
new file mode 100644
index 00000000000..6560d1b7336
--- /dev/null
+++ b/mcs/class/corlib/Test/System.Runtime.Remoting/ContextTest.cs
@@ -0,0 +1,112 @@
+//
+// MonoTests.System.Runtime.Remoting.BaseCalls.cs
+//
+// Author: Lluis Sanchez Gual (lluis@ximian.com)
+//
+// 2003 (C) Copyright, Novell, Inc.
+//
+
+using System;
+using System.Threading;
+using System.Collections;
+using System.Runtime.Remoting;
+using System.Runtime.Remoting.Activation;
+using System.Runtime.Remoting.Contexts;
+using NUnit.Framework;
+
+namespace MonoTests.System.Runtime.Remoting
+{
+
+ public class NeedsContextAttribute: Attribute, IContextAttribute
+ {
+ public void GetPropertiesForNewContext (IConstructionCallMessage msg) {}
+ public bool IsContextOK (Context ctx, IConstructionCallMessage msg) { return false; }
+ }
+
+ [NeedsContextAttribute]
+ public class TestCbo: ContextBoundObject
+ {
+ public Context GetContext ()
+ {
+ return Thread.CurrentContext;
+ }
+ }
+
+ [TestFixture]
+ public class ContextText: Assertion
+ {
+ TestCbo cbo = new TestCbo ();
+ Context otherCtx;
+ LocalDataStoreSlot slot;
+
+ [Test]
+ public void TestDoCallback ()
+ {
+ otherCtx = cbo.GetContext ();
+ Assert ("New context not created", Thread.CurrentContext != otherCtx);
+
+ otherCtx.DoCallBack (new CrossContextDelegate (DelegateTarget));
+ }
+
+ void DelegateTarget ()
+ {
+ Assert ("Wrong context", Thread.CurrentContext == otherCtx);
+ }
+
+ [Test]
+ public void TestDatastore ()
+ {
+ otherCtx = cbo.GetContext ();
+
+ slot = Context.AllocateDataSlot ();
+ LocalDataStoreSlot namedSlot1 = Context.AllocateNamedDataSlot ("slot1");
+ LocalDataStoreSlot namedSlot2 = Context.GetNamedDataSlot ("slot2");
+
+ Context.SetData (slot, "data");
+ Context.SetData (namedSlot1, "data1");
+ Context.SetData (namedSlot2, "data2");
+
+ otherCtx.DoCallBack (new CrossContextDelegate (CheckOtherContextDatastore));
+
+ Assert ("Wrong data 1", Context.GetData (slot).Equals ("data"));
+ Assert ("Wrong data 2", Context.GetData (namedSlot1).Equals ("data1"));
+ Assert ("Wrong data 3", Context.GetData (namedSlot2).Equals ("data2"));
+
+ try
+ {
+ namedSlot1 = Context.AllocateNamedDataSlot ("slot1");
+ Assert ("Exception expected",false);
+ }
+ catch {}
+
+ Context.FreeNamedDataSlot ("slot1");
+ Context.FreeNamedDataSlot ("slot2");
+
+ try
+ {
+ namedSlot1 = Context.AllocateNamedDataSlot ("slot1");
+ }
+ catch
+ {
+ Assert ("Exception not expected",false);
+ }
+
+ Context.FreeNamedDataSlot ("slot1");
+ }
+
+ void CheckOtherContextDatastore ()
+ {
+ LocalDataStoreSlot namedSlot1 = Context.GetNamedDataSlot ("slot1");
+ LocalDataStoreSlot namedSlot2 = Context.GetNamedDataSlot ("slot2");
+
+ Assert ("Slot already has data", Context.GetData (slot) == null);
+ Assert ("Slot already has data", Context.GetData (namedSlot1) == null);
+ Assert ("Slot already has data", Context.GetData (namedSlot2) == null);
+
+ Context.SetData (slot, "other data");
+ Context.SetData (namedSlot1, "other data1");
+ Context.SetData (namedSlot2, "other data2");
+ }
+
+ }
+}
diff --git a/mcs/class/corlib/Test/System.Runtime.Remoting/SoapServicesTest.cs b/mcs/class/corlib/Test/System.Runtime.Remoting/SoapServicesTest.cs
new file mode 100644
index 00000000000..1debd5c8c03
--- /dev/null
+++ b/mcs/class/corlib/Test/System.Runtime.Remoting/SoapServicesTest.cs
@@ -0,0 +1,230 @@
+//
+// MonoTests.System.Runtime.Remoting.SoapServicesTest.cs
+//
+// Author: Lluis Sanchez Gual (lluis@ximian.com)
+//
+// 2003 (C) Copyright, Novell, Inc.
+//
+
+using System;
+using System.Reflection;
+using System.Runtime.Remoting;
+using System.Runtime.Remoting.Metadata;
+using NUnit.Framework;
+
+namespace MonoTests.System.Runtime.Remoting
+{
+ [SoapTypeAttribute (XmlElementName="ename", XmlNamespace="ens", XmlTypeName="tname", XmlTypeNamespace="tns")]
+ public class SoapTest
+ {
+ [SoapField(XmlElementName="atrib",XmlNamespace="ns1",UseAttribute=true)]
+ public string atribut;
+
+ [SoapField(XmlElementName="elem",XmlNamespace="ns1")]
+ public int element;
+
+ [SoapField(XmlElementName="elem2")]
+ public int element2;
+
+ [SoapMethod (SoapAction="myaction")]
+ public void FesAlgo ()
+ {
+ }
+
+ public void FesAlgoMes ()
+ {
+ }
+
+ public void FesAlgoMesEspecial ()
+ {
+ }
+ }
+
+ public class SoapTest1
+ {
+ }
+
+ [SoapTypeAttribute (XmlElementName="ename", XmlTypeName="tname")]
+ public class SoapTest2
+ {
+ }
+
+ [SoapTypeAttribute (XmlNamespace="ens", XmlTypeNamespace="tns")]
+ public class SoapTest3
+ {
+ }
+
+ [TestFixture]
+ public class SoapServicesTest: Assertion
+ {
+ public string ThisNamespace
+ {
+ get
+ {
+ string tn = "http://schemas.microsoft.com/clr/nsassem/";
+ tn += GetType ().Namespace + "/" + GetType ().Assembly.GetName().Name;
+ return tn;
+ }
+ }
+
+ public string GetClassNs (Type t)
+ {
+ string tn = "http://schemas.microsoft.com/clr/nsassem/";
+ tn += t.FullName + "/" + t.Assembly.GetName().Name;
+ return tn;
+ }
+
+ public string GetSimpleTypeName (Type t)
+ {
+ return t.FullName + ", " + t.Assembly.GetName().Name;
+ }
+
+ [Test]
+ public void TestGetXmlType ()
+ {
+ bool res;
+ string name, ns;
+
+ // XmlType
+
+ res = SoapServices.GetXmlElementForInteropType (typeof(SoapTest), out name, out ns);
+ Assert ("E1",res);
+ AssertEquals ("E2", "ename", name);
+ AssertEquals ("E3", "ens", ns);
+
+ res = SoapServices.GetXmlElementForInteropType (typeof(SoapTest1), out name, out ns);
+ Assert ("E4",!res);
+
+ res = SoapServices.GetXmlElementForInteropType (typeof(SoapTest2), out name, out ns);
+ Assert ("E5",res);
+ AssertEquals ("E6", "ename", name);
+ AssertEquals ("E7", ThisNamespace, ns);
+
+ res = SoapServices.GetXmlElementForInteropType (typeof(SoapTest3), out name, out ns);
+ Assert ("E8",res);
+ AssertEquals ("E9", "SoapTest3", name);
+ AssertEquals ("E10", "ens", ns);
+
+ // XmlElement
+
+ res = SoapServices.GetXmlTypeForInteropType (typeof(SoapTest), out name, out ns);
+ Assert ("T1",res);
+ AssertEquals ("T2", "tname", name);
+ AssertEquals ("T3", "tns", ns);
+
+ res = SoapServices.GetXmlTypeForInteropType (typeof(SoapTest1), out name, out ns);
+ Assert ("T4",!res);
+
+ res = SoapServices.GetXmlTypeForInteropType (typeof(SoapTest2), out name, out ns);
+ Assert ("T5",res);
+ AssertEquals ("T6", "tname", name);
+ AssertEquals ("T7", ThisNamespace, ns);
+
+ res = SoapServices.GetXmlTypeForInteropType (typeof(SoapTest3), out name, out ns);
+ Assert ("T8",res);
+ AssertEquals ("T9", "SoapTest3", name);
+ AssertEquals ("T10", "tns", ns);
+ }
+
+ [Test]
+ public void TestGetInteropType ()
+ {
+ Type t;
+
+ // Manual registration
+
+ t = SoapServices.GetInteropTypeFromXmlElement ("aa","bb");
+ AssertEquals ("M1", t, null);
+
+ SoapServices.RegisterInteropXmlElement ("aa","bb",typeof(SoapTest));
+ t = SoapServices.GetInteropTypeFromXmlElement ("aa","bb");
+ AssertEquals ("M2", typeof (SoapTest), t);
+
+
+ t = SoapServices.GetInteropTypeFromXmlType ("aa","bb");
+ AssertEquals ("M3", null, t);
+
+ SoapServices.RegisterInteropXmlType ("aa","bb",typeof(SoapTest));
+ t = SoapServices.GetInteropTypeFromXmlType ("aa","bb");
+ AssertEquals ("M4", typeof (SoapTest), t);
+
+ // Preload type
+
+ SoapServices.PreLoad (typeof(SoapTest2));
+
+ t = SoapServices.GetInteropTypeFromXmlElement ("ename",ThisNamespace);
+ AssertEquals ("T1", typeof (SoapTest2), t);
+
+ t = SoapServices.GetInteropTypeFromXmlType ("tname",ThisNamespace);
+ AssertEquals ("T2", typeof (SoapTest2), t);
+
+ // Preload assembly
+
+ SoapServices.PreLoad (typeof(SoapTest).Assembly);
+
+ t = SoapServices.GetInteropTypeFromXmlElement ("SoapTest3","ens");
+ AssertEquals ("A1", typeof (SoapTest3), t);
+
+ t = SoapServices.GetInteropTypeFromXmlType ("SoapTest3","tns");
+ AssertEquals ("A2", typeof (SoapTest3), t);
+
+ }
+
+ [Test]
+ public void TestSoapFields ()
+ {
+ string name;
+ Type t;
+
+ SoapServices.GetInteropFieldTypeAndNameFromXmlAttribute (typeof(SoapTest), "atrib", "ns1", out t, out name);
+ AssertEquals ("#1", "atribut", name);
+ AssertEquals ("#2", typeof(string), t);
+
+ SoapServices.GetInteropFieldTypeAndNameFromXmlElement (typeof(SoapTest), "elem", "ns1", out t, out name);
+ AssertEquals ("#3", "element", name);
+ AssertEquals ("#4", typeof(int), t);
+
+ SoapServices.GetInteropFieldTypeAndNameFromXmlElement (typeof(SoapTest), "elem2", null, out t, out name);
+ AssertEquals ("#5", "element2", name);
+ AssertEquals ("#6", typeof(int), t);
+ }
+
+ [Test]
+ public void TestSoapActions ()
+ {
+ string act;
+ MethodBase mb;
+
+ mb = typeof(SoapTest).GetMethod ("FesAlgo");
+ act = SoapServices.GetSoapActionFromMethodBase (mb);
+ AssertEquals ("S1", "myaction", act);
+
+ mb = typeof(SoapTest).GetMethod ("FesAlgoMes");
+ SoapServices.RegisterSoapActionForMethodBase (mb, "anotheraction");
+ act = SoapServices.GetSoapActionFromMethodBase (mb);
+ AssertEquals ("S2", "anotheraction", act);
+
+ mb = typeof(SoapTest).GetMethod ("FesAlgoMesEspecial");
+ act = SoapServices.GetSoapActionFromMethodBase (mb);
+ AssertEquals ("S3", GetClassNs (typeof(SoapTest))+ "#FesAlgoMesEspecial", act);
+
+ string typeName, methodName;
+ bool res;
+
+ res = SoapServices.GetTypeAndMethodNameFromSoapAction ("myaction", out typeName, out methodName);
+ Assert ("M1", res);
+ AssertEquals ("M2", GetSimpleTypeName (typeof(SoapTest)), typeName);
+ AssertEquals ("M3", "FesAlgo", methodName);
+
+ res = SoapServices.GetTypeAndMethodNameFromSoapAction ("anotheraction", out typeName, out methodName);
+ Assert ("M4", res);
+ AssertEquals ("M5", GetSimpleTypeName (typeof(SoapTest)), typeName);
+ AssertEquals ("M6", "FesAlgoMes", methodName);
+
+ res = SoapServices.GetTypeAndMethodNameFromSoapAction (GetClassNs (typeof(SoapTest))+ "#FesAlgoMesEspecial", out typeName, out methodName);
+ Assert ("M7", res);
+ AssertEquals ("M8", GetSimpleTypeName (typeof(SoapTest)), typeName);
+ AssertEquals ("M9", "FesAlgoMesEspecial", methodName);
+ }
+ }
+}
diff --git a/mcs/class/corlib/Test/System.Runtime.Remoting/SynchronizationAttributeTest.cs b/mcs/class/corlib/Test/System.Runtime.Remoting/SynchronizationAttributeTest.cs
new file mode 100755
index 00000000000..99c1bac582d
--- /dev/null
+++ b/mcs/class/corlib/Test/System.Runtime.Remoting/SynchronizationAttributeTest.cs
@@ -0,0 +1,308 @@
+//
+// MonoTests.System.Runtime.Remoting.SynchronizationAttributeTest.cs
+//
+// Author: Lluis Sanchez Gual (lluis@ximian.com)
+//
+// 2003 (C) Copyright, Novell, Inc.
+//
+
+using System;
+using System.Threading;
+using System.Runtime.Remoting.Contexts;
+using NUnit.Framework;
+
+namespace MonoTests.System.Runtime.Remoting
+{
+ enum SynchRes { SameSync, NewSync, NoSync }
+
+ class SincroBase: ContextBoundObject
+ {
+ public int idx = 0;
+
+ public bool CheckConcurrency ()
+ {
+ int t = idx;
+ for (int n=0; n<40; n++)
+ {
+ idx++;
+ Thread.Sleep (25);
+ }
+ return (t+40 != idx);
+ }
+
+ public bool CheckUnlockedConcurrency ()
+ {
+ Lock (false);
+ return CheckConcurrency ();
+ }
+
+ public SynchRes CheckContext (Context ctx)
+ {
+ object otherp = ctx.GetProperty ("Synchronization");
+ object thisp = Thread.CurrentContext.GetProperty ("Synchronization");
+
+ if (thisp == null) return SynchRes.NoSync;
+ if (thisp == otherp) return SynchRes.SameSync;
+ return SynchRes.NewSync;
+ }
+
+ public SynchRes CheckContextTransition (Type type)
+ {
+ SincroBase bob = (SincroBase)Activator.CreateInstance (type);
+ return bob.CheckContext (Thread.CurrentContext);
+ }
+
+ public bool CheckCalloutConcurrency (SincroBase bob)
+ {
+ bool res = bob.CheckConcurrency ();
+ return res;
+ }
+
+ public void CheckLock1 ()
+ {
+ Thread.Sleep (2000);
+ Lock (false);
+ Thread.Sleep (6000);
+ }
+
+ public void CheckLock2 ()
+ {
+ Thread.Sleep (1000);
+ Lock (true);
+ Thread.Sleep (2000);
+ }
+
+ public void Lock (bool b)
+ {
+ SynchronizationAttribute thisp = (SynchronizationAttribute) Thread.CurrentContext.GetProperty ("Synchronization");
+ thisp.Locked = b;
+ }
+
+ public bool GetLocked ()
+ {
+ SynchronizationAttribute thisp = (SynchronizationAttribute) Thread.CurrentContext.GetProperty ("Synchronization");
+ return thisp.Locked;
+ }
+ }
+
+ [Synchronization (SynchronizationAttribute.SUPPORTED)]
+ class SincroSupported: SincroBase
+ {
+ }
+
+ [Synchronization (SynchronizationAttribute.REQUIRED)]
+ class SincroRequired: SincroBase
+ {
+ }
+
+ [Synchronization (SynchronizationAttribute.REQUIRES_NEW)]
+ class SincroRequiresNew: SincroBase
+ {
+ public bool TestCallback ()
+ {
+ SincroNotSupported bob = new SincroNotSupported ();
+ return bob.CallBack (this);
+ }
+ }
+
+ [Synchronization (SynchronizationAttribute.NOT_SUPPORTED)]
+ class SincroNotSupported: SincroBase
+ {
+ public bool CallBack (SincroRequiresNew bob)
+ {
+ return bob.CheckConcurrency ();
+ }
+ }
+
+ [Synchronization (SynchronizationAttribute.REQUIRES_NEW, true)]
+ class SincroRequiresNewReentrant: SincroBase
+ {
+ }
+
+ [TestFixture]
+ public class SynchronizationAttributeTest: Assertion
+ {
+ SincroRequiresNew sincob = new SincroRequiresNew ();
+ SincroNotSupported notsup = new SincroNotSupported ();
+ SincroRequiresNewReentrant reentrant = new SincroRequiresNewReentrant ();
+ SincroRequiresNew notreentrant = new SincroRequiresNew ();
+
+ [Test]
+ public void TestSynchronization ()
+ {
+ Thread tr = new Thread (new ThreadStart (FirstSyncThread));
+ tr.Start ();
+ Thread.Sleep (200);
+ SecondSyncThread ();
+ }
+
+ void FirstSyncThread ()
+ {
+ bool concurrent = sincob.CheckConcurrency ();
+ Assert ("Concurrency detected", !concurrent);
+ }
+
+ void SecondSyncThread ()
+ {
+ bool concurrent = sincob.CheckConcurrency ();
+ Assert ("Concurrency detected", !concurrent);
+ }
+
+ [Test]
+ public void TestSupported ()
+ {
+ SincroRequiresNew ob = new SincroRequiresNew ();
+ SynchRes res = ob.CheckContextTransition (typeof(SincroSupported));
+ Assert ("Synchronizaton context expected", res == SynchRes.SameSync);
+
+ SincroSupported ob2 = new SincroSupported ();
+ res = ob2.CheckContext (Thread.CurrentContext);
+ Assert ("Synchronizaton context not expected", res == SynchRes.NoSync);
+ }
+
+ [Test]
+ public void TestRequired ()
+ {
+ SincroRequiresNew ob = new SincroRequiresNew ();
+ SynchRes res = ob.CheckContextTransition (typeof(SincroRequired));
+ Assert ("Synchronizaton context expected 1", res == SynchRes.SameSync);
+
+ SincroRequired ob2 = new SincroRequired ();
+ res = ob2.CheckContext (Thread.CurrentContext);
+ Assert ("Synchronizaton context expected 2", res == SynchRes.NewSync);
+ }
+
+ [Test]
+ public void TestRequiresNew ()
+ {
+ SincroRequiresNew ob = new SincroRequiresNew ();
+ SynchRes res = ob.CheckContextTransition (typeof(SincroRequiresNew));
+ Assert ("New synchronizaton context expected", res == SynchRes.NewSync);
+
+ SincroRequiresNew ob2 = new SincroRequiresNew ();
+ res = ob2.CheckContext (Thread.CurrentContext);
+ Assert ("Synchronizaton context not expected", res == SynchRes.NewSync);
+ }
+
+ [Test]
+ public void TestNotSupported ()
+ {
+ SincroRequiresNew ob = new SincroRequiresNew ();
+ SynchRes res = ob.CheckContextTransition (typeof(SincroNotSupported));
+ Assert ("Synchronizaton context not expected 1", res == SynchRes.NoSync);
+
+ SincroNotSupported ob2 = new SincroNotSupported ();
+ res = ob2.CheckContext (Thread.CurrentContext);
+ Assert ("Synchronizaton context not expected 2", res == SynchRes.NoSync);
+ }
+
+ [Test]
+ public void TestLocked1 ()
+ {
+ sincob.Lock (false);
+ Thread tr = new Thread (new ThreadStart (FirstSyncThread));
+ tr.Start ();
+ Thread.Sleep (200);
+ SecondSyncThread ();
+ }
+
+ [Test]
+ public void TestLocked2 ()
+ {
+ Thread tr = new Thread (new ThreadStart (FirstNotSyncThread));
+ tr.Start ();
+ Thread.Sleep (200);
+ SecondNotSyncThread ();
+ }
+
+ void FirstNotSyncThread ()
+ {
+ bool concurrent = sincob.CheckUnlockedConcurrency ();
+ Assert ("Concurrency not detected", concurrent);
+ }
+
+ void SecondNotSyncThread ()
+ {
+ bool concurrent = sincob.CheckConcurrency ();
+ Assert ("Concurrency not detected", concurrent);
+ }
+
+ [Test]
+ public void TestLocked3 ()
+ {
+ Thread tr = new Thread (new ThreadStart (Lock1Thread));
+ tr.Start ();
+ Thread.Sleep (200);
+ Lock2Thread ();
+ }
+
+ void Lock1Thread ()
+ {
+ sincob.CheckLock1 ();
+ }
+
+ void Lock2Thread ()
+ {
+ sincob.CheckLock2 ();
+ }
+
+ [Test]
+ public void TestReentry ()
+ {
+ Thread tr = new Thread (new ThreadStart (FirstReentryThread));
+ tr.Start ();
+ Thread.Sleep (200);
+ SecondReentryThread ();
+ }
+
+ void FirstReentryThread ()
+ {
+ bool concurrent = reentrant.CheckCalloutConcurrency (notsup);
+ Assert ("Concurrency not detected", concurrent);
+ }
+
+ void SecondReentryThread ()
+ {
+ bool concurrent = reentrant.CheckCalloutConcurrency (notsup);
+ Assert ("Concurrency not detected", concurrent);
+ }
+
+ [Test]
+ public void TestNoReentry ()
+ {
+ Thread tr = new Thread (new ThreadStart (FirstNoReentryThread));
+ tr.Start ();
+ Thread.Sleep (200);
+ SecondNoReentryThread ();
+ }
+
+ void FirstNoReentryThread ()
+ {
+ bool concurrent = notreentrant.CheckCalloutConcurrency (notsup);
+ Assert ("Concurrency detected", !concurrent);
+ }
+
+ void SecondNoReentryThread ()
+ {
+ bool concurrent = notreentrant.CheckCalloutConcurrency (notsup);
+ Assert ("Concurrency detected", !concurrent);
+ }
+
+ [Test]
+ public void TestCallback ()
+ {
+ Thread tr = new Thread (new ThreadStart (CallbackThread));
+ tr.Start ();
+ Thread.Sleep (200);
+ bool concurrent = notreentrant.CheckConcurrency ();
+ Assert ("Concurrency detected", !concurrent);
+ notreentrant.CheckContext (Thread.CurrentContext);
+ }
+
+ void CallbackThread ()
+ {
+ bool concurrent = notreentrant.TestCallback ();
+ Assert ("Concurrency detected", !concurrent);
+ }
+ }
+}
diff --git a/mcs/class/corlib/Test/System.Security.Cryptography.X509Certificates/ChangeLog b/mcs/class/corlib/Test/System.Security.Cryptography.X509Certificates/ChangeLog
index dd751f89203..5b96c04a92c 100644
--- a/mcs/class/corlib/Test/System.Security.Cryptography.X509Certificates/ChangeLog
+++ b/mcs/class/corlib/Test/System.Security.Cryptography.X509Certificates/ChangeLog
@@ -1,3 +1,13 @@
+2003-11-17 Nick Drochak <ndrochak@gol.com>
+
+ * X509SpcTest.cs: OK, I misread the test and the file is created by the
+ test itself. I've un-ingored the test, but it still fails for me.
+ Entered bugzilla #51057 for this.
+
+2003-11-14 Nick Drochak <ndrochak@gol.com>
+
+ * X509SpcTest.cs: Ignore for now test where we need an exe to load.
+
2003-10-12 Sebastien Pouliot <spouliot@videotron.ca>
* X509SpcTest.cs: New. Test for Software Publisher Certificates
diff --git a/mcs/class/corlib/Test/System.Security.Cryptography.X509Certificates/X509SpcTest.cs b/mcs/class/corlib/Test/System.Security.Cryptography.X509Certificates/X509SpcTest.cs
index 37788718ee5..430be5a0a2c 100755
--- a/mcs/class/corlib/Test/System.Security.Cryptography.X509Certificates/X509SpcTest.cs
+++ b/mcs/class/corlib/Test/System.Security.Cryptography.X509Certificates/X509SpcTest.cs
@@ -860,6 +860,7 @@ namespace MonoTests.System.Security.Cryptography.X509Certificates {
0x72, 0xE9, 0x83, 0x6F, 0x93, 0xD8 };
[Test]
+// [Ignore ("need to get smallspc.exe before this test will pass")]
public void ValidSignature ()
{
FileStream fs = new FileStream ("smallspc.exe", FileMode.Create, FileAccess.Write);
diff --git a/mcs/class/corlib/Test/System.Security.Cryptography/ChangeLog b/mcs/class/corlib/Test/System.Security.Cryptography/ChangeLog
index 39685566ca1..4eef4920be5 100644
--- a/mcs/class/corlib/Test/System.Security.Cryptography/ChangeLog
+++ b/mcs/class/corlib/Test/System.Security.Cryptography/ChangeLog
@@ -1,3 +1,13 @@
+2003-11-13 Sebastien Pouliot <spouliot@videotron.ca>
+
+ * ProtectedDataTest.cs: New. Unit tests for ProtectedData (1.2).
+ * ProtectedMemoryTest.cs: New. Unit tests for ProtectedMemory (1.2).
+
+2003-11-11 Sebastien Pouliot <spouliot@videotron.ca>
+
+ * Rfc2898DeriveBytesTest.cs: More tests for Reset and keys longer than
+ a single block.
+
2003-11-10 Sebastien Pouliot <spouliot@videotron.ca>
* Rfc2898DeriveBytesTest.cs: New. Unit tests for Rfc2898DeriveBytes
diff --git a/mcs/class/corlib/Test/System.Security.Cryptography/ProtectedDataTest.cs b/mcs/class/corlib/Test/System.Security.Cryptography/ProtectedDataTest.cs
new file mode 100755
index 00000000000..b8cf08cedfb
--- /dev/null
+++ b/mcs/class/corlib/Test/System.Security.Cryptography/ProtectedDataTest.cs
@@ -0,0 +1,109 @@
+//
+// ProtectedDataTest.cs - NUnit Test Cases for ProtectedData
+//
+// Author:
+// Sebastien Pouliot (spouliot@motus.com)
+//
+// (C) 2003 Motus Technologies Inc. (http://www.motus.com)
+//
+
+#if NET_1_2
+
+using NUnit.Framework;
+
+using System;
+using System.Security.Cryptography;
+
+namespace MonoTests.System.Security.Cryptography {
+
+ // References:
+ // a.
+
+ [TestFixture]
+ public class ProtectedDataTest : Assertion {
+
+ private void ProtectUnprotect (byte[] entropy, DataProtectionScope scope)
+ {
+ byte[] data = new byte [16];
+ byte[] encdata = ProtectedData.Protect (data, entropy, scope);
+ int total = 0;
+ for (int i=0; i < 16; i++)
+ total += encdata [i];
+ Assert ("Protect", (total != 0));
+
+ byte[] decdata = ProtectedData.Unprotect (encdata, entropy, scope);
+ total = 0;
+ for (int i=0; i < 16; i++)
+ total += decdata [i];
+ Assert ("Unprotect", (total == 0));
+ }
+
+ [Test]
+ public void ProtectCurrentUser ()
+ {
+ try {
+ byte[] notMuchEntropy = new byte [16];
+ // we're testing the DataProtectionScope definition but
+ // not if it's really limited to the scope specified
+ ProtectUnprotect (notMuchEntropy, DataProtectionScope.CurrentUser);
+ }
+ catch (PlatformNotSupportedException) {
+ Console.WriteLine ("Only supported under Windows 2000 and later");
+ }
+ }
+
+ [Test]
+ public void ProtectLocalMachine ()
+ {
+ try {
+ byte[] notMuchEntropy = new byte [16];
+ // we're testing the DataProtectionScope definition but
+ // not if it's really limited to the scope specified
+ ProtectUnprotect (notMuchEntropy, DataProtectionScope.LocalMachine);
+ }
+ catch (PlatformNotSupportedException) {
+ Console.WriteLine ("Only supported under Windows 2000 and later");
+ }
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentNullException))]
+ public void ProtectNull ()
+ {
+ byte[] notMuchEntropy = new byte [16];
+ ProtectedData.Protect (null, notMuchEntropy, DataProtectionScope.CurrentUser);
+ }
+
+ [Test]
+ public void ProtectNullEntropy ()
+ {
+ try {
+ // we're testing the DataProtectionScope definition but
+ // not if it's really limited to the scope specified
+ ProtectUnprotect (null, DataProtectionScope.LocalMachine);
+ }
+ catch (PlatformNotSupportedException) {
+ Console.WriteLine ("Only supported under Windows 2000 and later");
+ }
+ }
+
+ [Test]
+ [ExpectedException (typeof (CryptographicException))]
+ public void UnprotectNotProtectedData ()
+ {
+ byte[] baddata = new byte [16];
+ byte[] notMuchEntropy = new byte [16];
+ ProtectedData.Unprotect (baddata, notMuchEntropy, DataProtectionScope.CurrentUser);
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentNullException))]
+ public void UnprotectNull ()
+ {
+ byte[] notMuchEntropy = new byte [16];
+ ProtectedData.Unprotect (null, notMuchEntropy, DataProtectionScope.CurrentUser);
+ }
+ }
+}
+
+#endif \ No newline at end of file
diff --git a/mcs/class/corlib/Test/System.Security.Cryptography/ProtectedMemoryTest.cs b/mcs/class/corlib/Test/System.Security.Cryptography/ProtectedMemoryTest.cs
new file mode 100755
index 00000000000..6892e77ec7b
--- /dev/null
+++ b/mcs/class/corlib/Test/System.Security.Cryptography/ProtectedMemoryTest.cs
@@ -0,0 +1,112 @@
+//
+// ProtectedMemoryTest.cs - NUnit Test Cases for ProtectedMemory
+//
+// Author:
+// Sebastien Pouliot (spouliot@motus.com)
+//
+// (C) 2003 Motus Technologies Inc. (http://www.motus.com)
+//
+
+#if NET_1_2
+
+using NUnit.Framework;
+
+using System;
+using System.Security.Cryptography;
+
+namespace MonoTests.System.Security.Cryptography {
+
+ // References:
+ // a.
+
+ [TestFixture]
+ public class ProtectedMemoryTest : Assertion {
+
+ private void ProtectUnprotect (MemoryProtectionScope scope)
+ {
+ byte[] data = new byte [16];
+ ProtectedMemory.Protect (data, scope);
+ int total = 0;
+ for (int i=0; i < 16; i++)
+ total += data [i];
+ Assert ("Protect", (total != 0));
+
+ ProtectedMemory.Unprotect (data, scope);
+ total = 0;
+ for (int i=0; i < 16; i++)
+ total += data [i];
+ Assert ("Unprotect", (total == 0));
+ }
+
+ [Test]
+ public void ProtectSameProcess ()
+ {
+ try {
+ // we're testing the MemoryProtectionScope definition but
+ // not if it's really limited to the scope specified
+ ProtectUnprotect (MemoryProtectionScope.SameProcess);
+ }
+ catch (PlatformNotSupportedException) {
+ Console.WriteLine ("Only supported under Windows XP and later");
+ }
+ }
+
+ [Test]
+ public void ProtectSameLogon ()
+ {
+ try {
+ // we're testing the MemoryProtectionScope definition but
+ // not if it's really limited to the scope specified
+ ProtectUnprotect (MemoryProtectionScope.SameLogon);
+ }
+ catch (PlatformNotSupportedException) {
+ Console.WriteLine ("Only supported under Windows XP and later");
+ }
+ }
+
+ [Test]
+ public void ProtectCrossProcess ()
+ {
+ try {
+ // we're testing the MemoryProtectionScope definition but
+ // not if it's really limited to the scope specified
+ ProtectUnprotect (MemoryProtectionScope.CrossProcess);
+ }
+ catch (PlatformNotSupportedException) {
+ Console.WriteLine ("Only supported under Windows XP and later");
+ }
+ }
+
+ [Test]
+ [ExpectedException (typeof (CryptographicException))]
+ public void ProtectBadDataLength ()
+ {
+ byte[] data = new byte [15];
+ ProtectedMemory.Protect (data, MemoryProtectionScope.SameProcess);
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentNullException))]
+ public void ProtectNull ()
+ {
+ ProtectedMemory.Protect (null, MemoryProtectionScope.SameProcess);
+ }
+
+ [Test]
+ [ExpectedException (typeof (CryptographicException))]
+ public void UnprotectBadDataLength ()
+ {
+ byte[] data = new byte [15];
+ ProtectedMemory.Unprotect (data, MemoryProtectionScope.SameProcess);
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentNullException))]
+ public void UnprotectNull ()
+ {
+ ProtectedMemory.Unprotect (null, MemoryProtectionScope.SameProcess);
+ }
+ }
+}
+
+#endif \ No newline at end of file
diff --git a/mcs/class/corlib/Test/System.Security.Cryptography/Rfc2898DeriveBytesTest.cs b/mcs/class/corlib/Test/System.Security.Cryptography/Rfc2898DeriveBytesTest.cs
index df6353e3cca..45ad175cd7e 100755
--- a/mcs/class/corlib/Test/System.Security.Cryptography/Rfc2898DeriveBytesTest.cs
+++ b/mcs/class/corlib/Test/System.Security.Cryptography/Rfc2898DeriveBytesTest.cs
@@ -210,6 +210,24 @@ namespace MonoTests.System.Security.Cryptography {
}
[Test]
+ [ExpectedException (typeof (ArgumentOutOfRangeException))]
+ public void GetBytesZero ()
+ {
+ byte[] expected = { 0xd1, 0xda, 0xa7, 0x86, 0x15, 0xf2, 0x87, 0xe6 };
+ Rfc2898DeriveBytes pkcs5 = new Rfc2898DeriveBytes ("password", salt, 5);
+ byte[] key = pkcs5.GetBytes (0);
+ AssertEquals ("GetBytesZero", 0, key.Length);
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentOutOfRangeException))]
+ public void GetBytesNegative ()
+ {
+ Rfc2898DeriveBytes pkcs5 = new Rfc2898DeriveBytes ("password", salt, 5);
+ byte[] key = pkcs5.GetBytes (Int32.MinValue);
+ }
+
+ [Test]
public void RFC3211_TC1 ()
{
byte[] expected = { 0xd1, 0xda, 0xa7, 0x86, 0x15, 0xf2, 0x87, 0xe6 };
@@ -228,15 +246,36 @@ namespace MonoTests.System.Security.Cryptography {
}
[Test]
- public void RFC3211_TC2_Splitted ()
+ public void RFC3211_TC2_TwoBlocks ()
+ {
+ byte[] expected = { 0x6A, 0x89, 0x70, 0xBF, 0x68, 0xC9, 0x2C, 0xAE, 0xA8, 0x4A, 0x8D, 0xF2, 0x85, 0x10, 0x85, 0x86, 0x07, 0x12, 0x63, 0x80, 0xcc, 0x47, 0xab, 0x2d, 0xa6, 0xcc, 0xda, 0xfb, 0x26, 0x83, 0xdf, 0xe8 };
+ Rfc2898DeriveBytes pkcs5 = new Rfc2898DeriveBytes ("All n-entities must communicate with other n-entities via n-1 entiteeheehees", salt, 500);
+ byte[] key = pkcs5.GetBytes (32);
+ AssertEquals ("RFC3211_TC2_TwoBlocks", expected, key);
+ }
+
+ [Test]
+ public void RFC3211_TC2_Splitted_OneBlock ()
{
Rfc2898DeriveBytes pkcs5 = new Rfc2898DeriveBytes ("All n-entities must communicate with other n-entities via n-1 entiteeheehees", salt, 500);
byte[] key1 = pkcs5.GetBytes (8);
byte[] expected_part1 = { 0x6A, 0x89, 0x70, 0xBF, 0x68, 0xC9, 0x2C, 0xAE };
- AssertEquals ("RFC3211_TC2_part1", expected_part1, key1);
+ AssertEquals ("RFC3211_TC2_Splitted_OneBlock-1", expected_part1, key1);
byte[] expected_part2 = { 0xA8, 0x4A, 0x8D, 0xF2, 0x85, 0x10, 0x85, 0x86 };
byte[] key2 = pkcs5.GetBytes (8);
- AssertEquals ("RFC3211_TC2_part2", expected_part2, key2);
+ AssertEquals ("RFC3211_TC2_Splitted_OneBlock-2", expected_part2, key2);
+ }
+
+ [Test]
+ public void RFC3211_TC2_Splitted_TwoBlocks ()
+ {
+ Rfc2898DeriveBytes pkcs5 = new Rfc2898DeriveBytes ("All n-entities must communicate with other n-entities via n-1 entiteeheehees", salt, 500);
+ byte[] key1 = pkcs5.GetBytes (16);
+ byte[] expected_part1 = { 0x6A, 0x89, 0x70, 0xBF, 0x68, 0xC9, 0x2C, 0xAE, 0xA8, 0x4A, 0x8D, 0xF2, 0x85, 0x10, 0x85, 0x86 };
+ AssertEquals ("RFC3211_TC2_Splitted_TwoBlocks-1", expected_part1, key1);
+ byte[] expected_part2 = { 0x07, 0x12, 0x63, 0x80, 0xcc, 0x47, 0xab, 0x2d, 0xa6, 0xcc, 0xda, 0xfb, 0x26, 0x83, 0xdf, 0xe8 };
+ byte[] key2 = pkcs5.GetBytes (16);
+ AssertEquals ("RFC3211_TC2_Splitted_TwoBlocks-2", expected_part2, key2);
}
[Test]
diff --git a/mcs/class/corlib/Test/System/ArrayTest.cs b/mcs/class/corlib/Test/System/ArrayTest.cs
index 200d5b4248d..c14d43f0775 100644
--- a/mcs/class/corlib/Test/System/ArrayTest.cs
+++ b/mcs/class/corlib/Test/System/ArrayTest.cs
@@ -676,7 +676,7 @@ public class ArrayTest : Assertion
#if NET_1_1
[Test]
- [ExpectedException (typeof (ArgumentNullException))]
+ [ExpectedException (typeof (NullReferenceException))]
public void TestCreateInstance2b ()
{
Array a = Array.CreateInstance (typeof (Int32), (long[])null);
@@ -1143,7 +1143,7 @@ public class ArrayTest : Assertion
#if NET_1_1
[Test]
- [ExpectedException (typeof (ArgumentNullException))]
+ [ExpectedException (typeof (NullReferenceException))]
public void TestGetValueLongArray() {
char[] c = new Char[2];
c.GetValue((long [])null);
@@ -1738,7 +1738,7 @@ public class ArrayTest : Assertion
#if NET_1_1
[Test]
- [ExpectedException (typeof (ArgumentNullException))]
+ [ExpectedException (typeof (NullReferenceException))]
public void TestSetValueLongArray() {
char[] c = new Char[2];
c.SetValue("buh", (long [])null);
diff --git a/mcs/class/corlib/Test/System/ChangeLog b/mcs/class/corlib/Test/System/ChangeLog
index aaad14f6a2e..0f10f9e82d4 100644
--- a/mcs/class/corlib/Test/System/ChangeLog
+++ b/mcs/class/corlib/Test/System/ChangeLog
@@ -1,3 +1,22 @@
+2003-11-14 Nick Drochak <ndrochak@gol.com>
+
+ * FloatingPointFormatterTest.cs: Make test pass on .NET 1.1.
+
+2003-11-14 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * ValueTypeTest.cs: New tests.
+
+2003-11-14 Nick Drochak <ndrochak@gol.com>
+
+ * DateTime.cs: Running tests in different timezones give different
+ results. Need to change the way these tests work. Disabling some
+ tests for now.
+
+2003-11-14 Nick Drochak <ndrochak@gol.com>
+
+ * ArrayTest.cs: Fix a few tests where NullReferenceException
+ is expected, not ArgumentNullException.
+
2003-11-01 Pedro Martínez Juliá <yoros@wanadoo.es>
* DateTimeTest.cs: Changed the Asserts to fix some things related to
diff --git a/mcs/class/corlib/Test/System/DateTimeTest.cs b/mcs/class/corlib/Test/System/DateTimeTest.cs
index c5ac2eba65c..16c614d6af2 100755
--- a/mcs/class/corlib/Test/System/DateTimeTest.cs
+++ b/mcs/class/corlib/Test/System/DateTimeTest.cs
@@ -320,6 +320,15 @@ public class DateTimeTest : Assertion
AssertEquals("C32", " d", t1.ToString (" \\d"));
}
+ [Ignore ("need a better way to handle these tests with them running on different timezones")]
+ public void TestParseExact2 ()
+ {
+ DateTime t1 = DateTime.ParseExact ("2002-02-25 04:25:13Z", "u", null);
+ t1 = TimeZone.CurrentTimeZone.ToUniversalTime(t1);
+ AssertEquals ("D07d", 04 + TimeZone.CurrentTimeZone.GetUtcOffset(t1).Hours, t1.Hour);
+
+ }
+
public void TestParseExact ()
{
// Standard patterns
@@ -339,7 +348,6 @@ public class DateTimeTest : Assertion
AssertEquals ("D07a", 2002, t1.Year);
AssertEquals ("D07b", 02, t1.Month);
AssertEquals ("D07c", 25, t1.Day);
- AssertEquals ("D07d", 04 + TimeZone.CurrentTimeZone.GetUtcOffset(t1).Hours, t1.Hour);
AssertEquals ("D07e", 25, t1.Minute);
AssertEquals ("D07f", 13, t1.Second);
t1 = DateTime.ParseExact ("Monday, 25 February 2002 04:25:13", "U", null);
@@ -523,6 +531,15 @@ public class DateTimeTest : Assertion
AssertEquals ("M06", myTicks[6], t1.Ticks);
}
+ [Ignore ("need to fix tests that run on different timezones")]
+ public void TestParse2 ()
+ {
+ DateTime t1 = DateTime.Parse ("Mon, 25 Feb 2002 04:25:13 GMT");
+ t1 = TimeZone.CurrentTimeZone.ToUniversalTime(t1);
+ AssertEquals ("H10d", 04 - TimeZone.CurrentTimeZone.GetUtcOffset(t1).Hours, t1.Hour);
+
+ }
+
public void TestParse ()
{
// Standard patterns
@@ -567,7 +584,6 @@ public class DateTimeTest : Assertion
AssertEquals ("H10a", 2002, t1.Year);
AssertEquals ("H10b", 02, t1.Month);
AssertEquals ("H10c", 25, t1.Day);
- AssertEquals ("H10d", 04 - TimeZone.CurrentTimeZone.GetUtcOffset(t1).Hours, t1.Hour);
AssertEquals ("H10e", 25, t1.Minute);
AssertEquals ("H10f", 13, t1.Second);
diff --git a/mcs/class/corlib/Test/System/FloatingPointFormatterTest.cs b/mcs/class/corlib/Test/System/FloatingPointFormatterTest.cs
index 18fd149e98f..d8aecd8ebd9 100644
--- a/mcs/class/corlib/Test/System/FloatingPointFormatterTest.cs
+++ b/mcs/class/corlib/Test/System/FloatingPointFormatterTest.cs
@@ -19,9 +19,9 @@ namespace MonoTests.System
public void Format1 ()
{
AssertEquals ("F1", "100000000000000", 1.0e+14.ToString ());
- AssertEquals ("F2", "1.E+15", 1.0e+15.ToString ());
- AssertEquals ("F3", "1.E+16", 1.0e+16.ToString ());
- AssertEquals ("F4", "1.E+17", 1.0e+17.ToString ());
+ AssertEquals ("F2", "1E+15", 1.0e+15.ToString ());
+ AssertEquals ("F3", "1E+16", 1.0e+16.ToString ());
+ AssertEquals ("F4", "1E+17", 1.0e+17.ToString ());
}
}
}
diff --git a/mcs/class/corlib/Test/System/ValueTypeTest.cs b/mcs/class/corlib/Test/System/ValueTypeTest.cs
new file mode 100644
index 00000000000..39519bbef1f
--- /dev/null
+++ b/mcs/class/corlib/Test/System/ValueTypeTest.cs
@@ -0,0 +1,71 @@
+//
+// VersionTest.cs - NUnit Test Cases for the System.ValueType class
+//
+// Authors:
+// Gonzalo Paniagua Javier (gonzalo@ximian.com)
+//
+// (c) 2003 Novell, Inc. (http://www.novell.com)
+//
+
+using NUnit.Framework;
+using System;
+
+namespace MonoTests.System
+{
+ struct Blah
+ {
+ public string s;
+ public int x;
+
+ public Blah (string s, int x)
+ {
+ this.s = s;
+ this.x = x;
+ }
+ }
+
+ struct Lalala
+ {
+ public int x;
+ public string s;
+
+ public Lalala (string s, int x)
+ {
+ this.s = s;
+ this.x = x;
+ }
+ }
+
+ [TestFixture]
+ public class ValueTypeTest : Assertion
+ {
+ [Test]
+ public void TestEquals ()
+ {
+ Blah a = new Blah ("abc", 1);
+ Blah b = new Blah (string.Format ("ab{0}", 'c'), 1);
+ AssertEquals ("#01", a.Equals (b), true);
+ }
+
+ [Test]
+ public void TestGetHash ()
+ {
+ Blah a = new Blah ("abc", 1);
+ Blah b = new Blah (string.Format ("ab{0}", 'c'), 1);
+ AssertEquals ("#01", a.GetHashCode (), b.GetHashCode ());
+
+ Lalala la = new Lalala ("abc", 1);
+ Lalala lb = new Lalala (string.Format ("ab{0}", 'c'), 1);
+ AssertEquals ("#02", la.GetHashCode (), lb.GetHashCode ());
+
+ a = new Blah (null, 1);
+ b = new Blah (null, 1);
+ AssertEquals ("#03", la.GetHashCode (), lb.GetHashCode ());
+
+ la = new Lalala (null, 1);
+ lb = new Lalala (null, 1);
+ AssertEquals ("#04", la.GetHashCode (), lb.GetHashCode ());
+ }
+ }
+}
+
diff --git a/mcs/class/corlib/Test/corlib_linux_test.args b/mcs/class/corlib/Test/corlib_linux_test.args
deleted file mode 100644
index 847d5c5d5d6..00000000000
--- a/mcs/class/corlib/Test/corlib_linux_test.args
+++ /dev/null
@@ -1,158 +0,0 @@
---target library
--o corlib_linux_test.dll
---noconfig
--r ../../lib/corlib.dll
--r ../../lib/System.dll
--r ../../../nunit/NUnitCore_mono.dll
-Mono.Math/ArithmeticBigTest.cs
-Mono.Math/BigIntegerSetTest.cs
-Mono.Math/BitwiseTest.cs
-Mono.Math/GcdBigTest.cs
-Mono.Math/ModInverseBigTest.cs
-Mono.Math/ModRingTest.cs
-Mono.Math/PrimeGenerationTest.cs
-Mono.Math/PrimeTestingTest.cs
-Mono.Math/SearchGeneratorTest.cs
-System/AppDomainSetupTest.cs
-System/ArrayTest.cs
-System/AttributeTest.cs
-System/BitConverterTest.cs
-System/BooleanTest.cs
-System/BufferTest.cs
-System/ByteTest.cs
-System/CharEnumeratorTest.cs
-System/CharTest.cs
-System/ConsoleTest.cs
-System/ConvertTest.cs
-System/DateTimeTest.cs
-System/DecimalTest.cs
-System/DecimalTest2.cs
-System/DoubleTest.cs
-System/EnumTest.cs
-System/ExceptionTest.cs
-System/GuidTest.cs
-System/Int16Test.cs
-System/Int32Test.cs
-System/Int64Test.cs
-System/IntegerFormatterTest.cs
-System/MathTest.cs
-System/MulticastDelegate.cs
-System/ObjectTest.cs
-System/RandomTest.cs
-System/ResolveEventArgsTest.cs
-System/SByteTest.cs
-System/StringTest.cs
-System/TimeSpanTest.cs
-System/TimeZoneTest.cs
-System/UInt16Test.cs
-System/UInt32Test.cs
-System/UInt64Test.cs
-System/VersionTest.cs
-System.Collections/ArrayListTest.cs
-System.Collections/BitArrayTest.cs
-System.Collections/CaseInsensitiveComparerTest.cs
-System.Collections/CaseInsensitiveHashCodeProviderTest.cs
-System.Collections/CollectionBaseTest.cs
-System.Collections/ComparerTest.cs
-System.Collections/DictionaryBaseTest.cs
-System.Collections/DictionaryEntryTest.cs
-System.Collections/HashtableTest.cs
-System.Collections/QueueTest.cs
-System.Collections/ReadOnlyCollectionBaseTest.cs
-System.Collections/SortedListTest.cs
-System.Collections/StackTest.cs
-System.Diagnostics/DebugTest.cs
-System.Diagnostics/StackFrameTest.cs
-System.Diagnostics/StackTraceTest.cs
-System.Diagnostics/TextWriterTraceListenerTest.cs
-System.Globalization/CalendarTest.cs
-System.IO/BinaryReaderTest.cs
-System.IO/BinaryWriterTest.cs
-System.IO/BufferedStreamTest.cs
-System.IO/DirectoryTest.cs
-System.IO/FileTest.cs
-System.IO/FileInfoTest.cs
-System.IO/FileSystemInfoTest.cs
-System.IO/DirectoryInfoTest.cs
-System.IO/FileStreamTest.cs
-System.IO/MemoryStreamTest.cs
-System.IO/PathTest.cs
-System.IO/StreamReaderTest.cs
-System.IO/StreamWriterTest.cs
-System.IO/StringReaderTest.cs
-System.IO/StringWriterTest.cs
-System.Resources/ResourceReaderTest.cs
-System.Runtime.CompilerServices/RuntimeHelpersTest.cs
-System.Runtime.Serialization/FormatterServicesTests.cs
-System.Runtime.Serialization/ObjectIDGeneratorTests.cs
-System.Security/PermissionSetTest.cs
-System.Security/NamedPermissionSetTest.cs
-System.Security/SecurityElementTest.cs
-System.Security.Cryptography/AsymmetricAlgorithmTest.cs
-System.Security.Cryptography/CryptoConfigTest.cs
-System.Security.Cryptography/DSACryptoServiceProviderTest.cs
-System.Security.Cryptography/DSASignatureDeformatterTest.cs
-System.Security.Cryptography/DSASignatureFormatterTest.cs
-System.Security.Cryptography/DSATest.cs
-System.Security.Cryptography/FromBase64Transform.cs
-System.Security.Cryptography/HashAlgorithmTest.cs
-System.Security.Cryptography/HMACSHA1Test.cs
-System.Security.Cryptography/KeyedHashAlgorithmTest.cs
-System.Security.Cryptography/MACTripleDESTest.cs
-System.Security.Cryptography/MD5Test.cs
-System.Security.Cryptography/PasswordDeriveBytesTest.cs
-System.Security.Cryptography/PKCS1MaskGenerationMethodTest.cs
-System.Security.Cryptography/RandomNumberGeneratorTest.cs
-System.Security.Cryptography/RC2Test.cs
-System.Security.Cryptography/RijndaelManagedTest.cs
-System.Security.Cryptography/RijndaelTest.cs
-System.Security.Cryptography/RNGCryptoServiceProviderTest.cs
-System.Security.Cryptography/RSATest.cs
-System.Security.Cryptography/RSACryptoServiceProviderTest.cs
-System.Security.Cryptography/RSAOAEPKeyExchangeDeformatterTest.cs
-System.Security.Cryptography/RSAOAEPKeyExchangeFormatterTest.cs
-System.Security.Cryptography/RSAPKCS1KeyExchangeDeformatterTest.cs
-System.Security.Cryptography/RSAPKCS1KeyExchangeFormatterTest.cs
-System.Security.Cryptography/RSAPKCS1SignatureDeformatterTest.cs
-System.Security.Cryptography/RSAPKCS1SignatureFormatterTest.cs
-System.Security.Cryptography/SHA1CryptoServiceProviderTest.cs
-System.Security.Cryptography/SHA1Test.cs
-System.Security.Cryptography/SHA256ManagedTest.cs
-System.Security.Cryptography/SHA256Test.cs
-System.Security.Cryptography/SHA384ManagedTest.cs
-System.Security.Cryptography/SHA384Test.cs
-System.Security.Cryptography/SHA512ManagedTest.cs
-System.Security.Cryptography/SHA512Test.cs
-System.Security.Cryptography/SignatureDescriptionTest.cs
-System.Security.Cryptography/SymmetricAlgorithmTest.cs
-System.Security.Cryptography.X509Certificates/X509CertificateTest.cs
-System.Security.Permissions/EnvironmentPermissionAttributeTest.cs
-System.Security.Permissions/EnvironmentPermissionTest.cs
-System.Security.Permissions/FileDialogPermissionAttributeTest.cs
-System.Security.Permissions/FileDialogPermissionTest.cs
-System.Security.Permissions/FileIOPermissionAttributeTest.cs
-System.Security.Permissions/FileIOPermissionTest.cs
-System.Security.Permissions/PrincipalPermissionAttributeTest.cs
-System.Security.Permissions/PrincipalPermissionTest.cs
-System.Security.Permissions/PublisherIdentityPermissionAttributeTest.cs
-System.Security.Permissions/PublisherIdentityPermissionTest.cs
-System.Security.Permissions/ReflectionPermissionAttributeTest.cs
-System.Security.Permissions/ReflectionPermissionTest.cs
-System.Security.Permissions/StrongNamePublicKeyBlobTest.cs
-System.Security.Policy/CodeGroupTest.cs
-System.Security.Policy/EvidenceTest.cs
-System.Security.Policy/PublisherTest.cs
-System.Security.Policy/PublisherMembershipConditionTest.cs
-System.Security.Policy/StrongNameTest.cs
-System.Security.Policy/ZoneTest.cs
-System.Security.Principal/GenericIdentityTest.cs
-System.Security.Principal/GenericPrincipalTest.cs
-System.Text/ASCIIEncodingTest.cs
-System.Text/StringBuilderTest.cs
-System.Text/UTF7EncodingTest.cs
-System.Text/UTF8EncodingTest.cs
-System.Threading/ThreadTest.cs
-System.Threading/MutexTest.cs
-System.Reflection/AssemblyNameTest.cs
-System.Reflection/AssemblyTest.cs
-System.Reflection/StrongNameKeyPairTest.cs
diff --git a/mcs/class/corlib/Test/corlib_test.args b/mcs/class/corlib/Test/corlib_test.args
deleted file mode 100755
index bb75b23c778..00000000000
--- a/mcs/class/corlib/Test/corlib_test.args
+++ /dev/null
@@ -1,171 +0,0 @@
---target library
--o corlib_test.dll
---noconfig
--r ../../lib/corlib.dll
--r ../../lib/System.dll
--r ../../../nunit20/NUnit.Framework.dll
-Mono.Math/ArithmeticBigTest.cs
-Mono.Math/BigIntegerSetTest.cs
-Mono.Math/BitwiseTest.cs
-Mono.Math/GcdBigTest.cs
-Mono.Math/ModInverseBigTest.cs
-Mono.Math/ModRingTest.cs
-Mono.Math/PrimeGenerationTest.cs
-Mono.Math/PrimeTestingTest.cs
-Mono.Math/SearchGeneratorTest.cs
-System/AppDomainSetupTest.cs
-System/ArrayTest.cs
-System/AttributeTest.cs
-System/BitConverterTest.cs
-System/BooleanTest.cs
-System/BufferTest.cs
-System/ByteTest.cs
-System/CharEnumeratorTest.cs
-System/CharTest.cs
-System/ConsoleTest.cs
-System/ConvertTest.cs
-System/DateTimeTest.cs
-System/DecimalTest.cs
-System/DecimalTest2.cs
-System/DoubleTest.cs
-System/DoubleFormatterTest.cs
-System/DecimalFormatterTest.cs
-System/EnumTest.cs
-System/ExceptionTest.cs
-System/GuidTest.cs
-System/Int16Test.cs
-System/Int32Test.cs
-System/Int64Test.cs
-System/IntegerFormatterTest.cs
-System/MathTest.cs
-System/MulticastDelegate.cs
-System/ObjectTest.cs
-System/RandomTest.cs
-System/ResolveEventArgsTest.cs
-System/SByteTest.cs
-System/SingleFormatterTest.cs
-System/StringTest.cs
-System/TimeSpanTest.cs
-System/TimeZoneTest.cs
-System/UInt16Test.cs
-System/UInt32Test.cs
-System/UInt64Test.cs
-System/VersionTest.cs
-System/TypeTest.cs
-System.Collections/ArrayListTest.cs
-System.Collections/BitArrayTest.cs
-System.Collections/CaseInsensitiveComparerTest.cs
-System.Collections/CaseInsensitiveHashCodeProviderTest.cs
-System.Collections/CollectionBaseTest.cs
-System.Collections/ComparerTest.cs
-System.Collections/DictionaryEntryTest.cs
-System.Collections/HashtableTest.cs
-System.Collections/QueueTest.cs
-System.Collections/ReadOnlyCollectionBaseTest.cs
-System.Collections/SortedListTest.cs
-System.Collections/StackTest.cs
-System.Diagnostics/DebugTest.cs
-System.Diagnostics/StackFrameTest.cs
-System.Diagnostics/StackTraceTest.cs
-System.Diagnostics/TextWriterTraceListenerTest.cs
-System.Globalization/CalendarTest.cs
-System.IO/BinaryReaderTest.cs
-System.IO/BinaryWriterTest.cs
-System.IO/BufferedStreamTest.cs
-System.IO/DirectoryTest.cs
-System.IO/FileInfoTest.cs
-System.IO/FileSystemInfoTest.cs
-System.IO/DirectoryInfoTest.cs
-System.IO/FileTest.cs
-System.IO/FileStreamTest.cs
-System.IO/MemoryStreamTest.cs
-System.IO/PathTest.cs
-System.IO/StreamReaderTest.cs
-System.IO/StreamWriterTest.cs
-System.IO/StringReaderTest.cs
-System.IO/StringWriterTest.cs
-System.Resources/ResourceReaderTest.cs
-System.Runtime.CompilerServices/RuntimeHelpersTest.cs
-System.Runtime.Serialization/FormatterServicesTests.cs
-System.Runtime.Serialization/ObjectIDGeneratorTests.cs
-System.Security/PermissionSetTest.cs
-System.Security/NamedPermissionSetTest.cs
-System.Security/SecurityElementTest.cs
-System.Security.Cryptography/AllTests2.cs
-System.Security.Cryptography/AsymmetricAlgorithmTest.cs
-System.Security.Cryptography/CryptoConfigTest.cs
-System.Security.Cryptography/DSACryptoServiceProviderTest.cs
-System.Security.Cryptography/DSASignatureDeformatterTest.cs
-System.Security.Cryptography/DSASignatureFormatterTest.cs
-System.Security.Cryptography/DSATest.cs
-System.Security.Cryptography/FromBase64Transform.cs
-System.Security.Cryptography/HashAlgorithmTest.cs
-System.Security.Cryptography/HMACSHA1Test.cs
-System.Security.Cryptography/KeyedHashAlgorithmTest.cs
-System.Security.Cryptography/MD5Test.cs
-System.Security.Cryptography/PasswordDeriveBytesTest.cs
-System.Security.Cryptography/PKCS1MaskGenerationMethodTest.cs
-System.Security.Cryptography/RandomNumberGeneratorTest.cs
-System.Security.Cryptography/RC2Test.cs
-System.Security.Cryptography/RijndaelManagedTest.cs
-System.Security.Cryptography/RijndaelTest.cs
-System.Security.Cryptography/RNGCryptoServiceProviderTest.cs
-System.Security.Cryptography/RSATest.cs
-System.Security.Cryptography/RSACryptoServiceProviderTest.cs
-System.Security.Cryptography/RSAOAEPKeyExchangeDeformatterTest.cs
-System.Security.Cryptography/RSAOAEPKeyExchangeFormatterTest.cs
-System.Security.Cryptography/RSAPKCS1KeyExchangeDeformatterTest.cs
-System.Security.Cryptography/RSAPKCS1KeyExchangeFormatterTest.cs
-System.Security.Cryptography/RSAPKCS1SignatureDeformatterTest.cs
-System.Security.Cryptography/RSAPKCS1SignatureFormatterTest.cs
-System.Security.Cryptography/SHA1CryptoServiceProviderTest.cs
-System.Security.Cryptography/SHA1Test.cs
-System.Security.Cryptography/SHA256ManagedTest.cs
-System.Security.Cryptography/SHA256Test.cs
-System.Security.Cryptography/SHA384ManagedTest.cs
-System.Security.Cryptography/SHA384Test.cs
-System.Security.Cryptography/SHA512ManagedTest.cs
-System.Security.Cryptography/SHA512Test.cs
-System.Security.Cryptography/SignatureDescriptionTest.cs
-System.Security.Cryptography/SymmetricAlgorithmTest.cs
-System.Security.Cryptography.X509Certificates/X509CertificateTest.cs
-System.Security.Permissions/EnvironmentPermissionAttributeTest.cs
-System.Security.Permissions/EnvironmentPermissionTest.cs
-System.Security.Permissions/FileDialogPermissionAttributeTest.cs
-System.Security.Permissions/FileDialogPermissionTest.cs
-System.Security.Permissions/FileIOPermissionAttributeTest.cs
-System.Security.Permissions/FileIOPermissionTest.cs
-System.Security.Permissions/PrincipalPermissionAttributeTest.cs
-System.Security.Permissions/PrincipalPermissionTest.cs
-System.Security.Permissions/PublisherIdentityPermissionAttributeTest.cs
-System.Security.Permissions/PublisherIdentityPermissionTest.cs
-System.Security.Permissions/ReflectionPermissionAttributeTest.cs
-System.Security.Permissions/ReflectionPermissionTest.cs
-System.Security.Permissions/StrongNamePublicKeyBlobTest.cs
-System.Security.Policy/CodeGroupTest.cs
-System.Security.Policy/EvidenceTest.cs
-System.Security.Policy/PublisherTest.cs
-System.Security.Policy/PublisherMembershipConditionTest.cs
-System.Security.Policy/StrongNameTest.cs
-System.Security.Policy/ZoneTest.cs
-System.Security.Principal/GenericIdentityTest.cs
-System.Security.Principal/GenericPrincipalTest.cs
-System.Text/ASCIIEncodingTest.cs
-System.Text/StringBuilderTest.cs
-System.Text/UTF7EncodingTest.cs
-System.Text/UTF8EncodingTest.cs
-System.Text/UnicodeEncodingTest.cs
-System.Threading/ThreadTest.cs
-System.Threading/MutexTest.cs
-System.Reflection/AssemblyNameTest.cs
-System.Reflection/AssemblyTest.cs
-System.Reflection/StrongNameKeyPairTest.cs
-System.Reflection/ModuleTest.cs
-System.Reflection.Emit/MethodBuilderTest.cs
-System.Reflection.Emit/TypeBuilderTest.cs
-System.Reflection.Emit/ConstructorBuilderTest.cs
-System.Reflection.Emit/AssemblyBuilderTest.cs
-System.Reflection.Emit/ModuleBuilderTest.cs
-System.Reflection.Emit/PropertyBuilderTest.cs
-System.Reflection.Emit/EventBuilderTest.cs
-
diff --git a/mcs/class/corlib/Unix/Errno.cs b/mcs/class/corlib/Unix/Errno.cs
index 36c3b4bc698..a4e9da7560d 100755
--- a/mcs/class/corlib/Unix/Errno.cs
+++ b/mcs/class/corlib/Unix/Errno.cs
@@ -8,54 +8,150 @@ namespace System.Private {
internal static string Message (int code)
{
- switch (code){
+ switch (code) {
case Wrapper.EPERM:
- return "No permission";
+ return "Operation not permitted";
case Wrapper.ENOENT:
- return "The name does not exist";
+ return "No such file or directory";
case Wrapper.EISDIR:
- return "error: Is a directory";
+ return "Is a directory";
case Wrapper.EBADF:
return "Bad file descriptor";
case Wrapper.ENOMEM:
- return "Out of memory";
+ return "Cannot allocate memory";
case Wrapper.EEXIST:
return "File already exists";
case Wrapper.ENOTEMPTY:
- return "Directory is not empty";
-
+ return "Directory not empty";
case Wrapper.ESRCH:
+ return "No such process";
case Wrapper.EINTR:
+ return "Interrupted function call";
case Wrapper.EIO:
+ return "Input/output error";
case Wrapper.ENXIO:
+ return "No such device or address";
case Wrapper.E2BIG:
+ return "Argument list too long";
case Wrapper.ENOEXEC:
+ return "Exec format error";
case Wrapper.ECHILD:
+ return "No child processes";
case Wrapper.EAGAIN:
+ return "Resource temporarily unavailable";
case Wrapper.EACCES:
+ return "Permission denied";
case Wrapper.EFAULT:
+ return "Bad address";
case Wrapper.ENOTBLK:
+ return "Block device required";
case Wrapper.EBUSY:
+ return "Device or resource busy";
case Wrapper.EXDEV:
+ return "Invalid cross-device link";
case Wrapper.ENODEV:
+ return "No such device";
+ case Wrapper.ENOTDIR:
+ return "Not a directory";
case Wrapper.EINVAL:
+ return "Invalid argument";
case Wrapper.ENFILE:
+ return "Too many open files in system";
case Wrapper.EMFILE:
+ return "Too many open files";
case Wrapper.ENOTTY:
+ return "Inappropriate ioctl for device";
case Wrapper.ETXTBSY:
+ return "Text file busy";
case Wrapper.EFBIG:
+ return "File too large";
case Wrapper.ENOSPC:
+ return "No space left on device";
case Wrapper.ESPIPE:
+ return "Illegal seek";
case Wrapper.EROFS:
+ return "Read-only file system";
case Wrapper.EMLINK:
+ return "Too many links";
case Wrapper.EPIPE:
+ return "Broken pipe";
case Wrapper.EDOM:
+ return "Numerical argument out of domain";
case Wrapper.ERANGE:
+ return "Numerical result out of range";
case Wrapper.EDEADLK:
+ return "Resource deadlock avoided";
case Wrapper.ENAMETOOLONG:
+ return "File name too long";
case Wrapper.ENOLCK:
+ return "No locks available";
case Wrapper.ENOSYS:
+ return "Function not implemented";
case Wrapper.ELOOP:
+ return "Too many levels of symbolic links";
+ case Wrapper.EUSERS:
+ return "Too many users";
+ case Wrapper.ENOTSOCK:
+ return "Socket operation on non-socket";
+ case Wrapper.EDESTADDRREQ:
+ return "Destination address required";
+ case Wrapper.EMSGSIZE:
+ return "Message too long";
+ case Wrapper.EPROTOTYPE:
+ return "Protocol wrong type for socket";
+ case Wrapper.ENOPROTOOPT:
+ return "Protocol not available";
+ case Wrapper.EPROTONOSUPPORT:
+ return "Protocol not supported";
+ case Wrapper.ESOCKTNOSUPPORT:
+ return "Socket type not supported";
+ case Wrapper.EOPNOTSUPP:
+ return "Operation not supported";
+ case Wrapper.EPFNOSUPPORT:
+ return "Protocol family not supported";
+ case Wrapper.EAFNOSUPPORT:
+ return "Address family not supported by protocol";
+ case Wrapper.EADDRINUSE:
+ return "Address already in use";
+ case Wrapper.EADDRNOTAVAIL:
+ return "Cannot assign requested address";
+ case Wrapper.ENETDOWN:
+ return "Network is down";
+ case Wrapper.ENETUNREACH:
+ return "Network is unreachable";
+ case Wrapper.ENETRESET:
+ return "Network dropped connection on reset";
+ case Wrapper.ECONNABORTED:
+ return "Software caused connection abort";
+ case Wrapper.ECONNRESET:
+ return "Connection reset by peer";
+ case Wrapper.ENOBUFS:
+ return "No buffer space available";
+ case Wrapper.EISCONN:
+ return "Transport endpoint is already connected";
+ case Wrapper.ENOTCONN:
+ return "Transport endpoint is not connected";
+ case Wrapper.ESHUTDOWN:
+ return "Cannot send after transport endpoint shutdown";
+ case Wrapper.ETOOMANYREFS:
+ return "Too many references: cannot splice";
+ case Wrapper.ETIMEDOUT:
+ return "Connection timed out";
+ case Wrapper.ECONNREFUSED:
+ return "Connection refused";
+ case Wrapper.EHOSTDOWN:
+ return "Host is down";
+ case Wrapper.EHOSTUNREACH:
+ return "No route to host";
+ case Wrapper.EALREADY:
+ return "Operation already in progress";
+ case Wrapper.EINPROGRESS:
+ return "Operation now in progress";
+ case Wrapper.ESTALE:
+ return "Stale NFS file handle";
+ case Wrapper.EDQUOT:
+ return "Disk quota exceeded";
+ case Wrapper.ENOMEDIUM:
case Wrapper.ENOMSG:
case Wrapper.EIDRM:
case Wrapper.ECHRNG:
@@ -96,42 +192,7 @@ namespace System.Private {
case Wrapper.ELIBSCN:
case Wrapper.ELIBMAX:
case Wrapper.ELIBEXEC:
- case Wrapper.EUSERS:
- case Wrapper.ENOTSOCK:
- case Wrapper.EDESTADDRREQ:
- case Wrapper.EMSGSIZE:
- case Wrapper.EPROTOTYPE:
- case Wrapper.ENOPROTOOPT:
- case Wrapper.EPROTONOSUPPORT:
- case Wrapper.ESOCKTNOSUPPORT:
- case Wrapper.EOPNOTSUPP:
- case Wrapper.EPFNOSUPPORT:
- case Wrapper.EAFNOSUPPORT:
- case Wrapper.EADDRINUSE:
- case Wrapper.EADDRNOTAVAIL:
- case Wrapper.ENETDOWN:
- case Wrapper.ENETUNREACH:
- case Wrapper.ENETRESET:
- case Wrapper.ECONNABORTED:
- case Wrapper.ECONNRESET:
- case Wrapper.ENOBUFS:
- case Wrapper.EISCONN:
- case Wrapper.ENOTCONN:
- case Wrapper.ESHUTDOWN:
- case Wrapper.ETOOMANYREFS:
- case Wrapper.ETIMEDOUT:
- case Wrapper.ECONNREFUSED:
- case Wrapper.EHOSTDOWN:
- case Wrapper.EHOSTUNREACH:
- case Wrapper.EALREADY:
- case Wrapper.EINPROGRESS:
- case Wrapper.ESTALE:
- case Wrapper.EDQUOT:
- case Wrapper.ENOMEDIUM:
break;
-
- case Wrapper.ENOTDIR:
- return "Not a directory";
}
return String.Format ("Errno code={0}", code);
}
diff --git a/mcs/class/corlib/corlib.dll.sources b/mcs/class/corlib/corlib.dll.sources
index 9c8f805402d..edfbbdad530 100755
--- a/mcs/class/corlib/corlib.dll.sources
+++ b/mcs/class/corlib/corlib.dll.sources
@@ -370,6 +370,7 @@ System.Reflection.Emit/AssemblyBuilder.cs
System.Reflection.Emit/AssemblyBuilderAccess.cs
System.Reflection.Emit/ConstructorBuilder.cs
System.Reflection.Emit/CustomAttributeBuilder.cs
+System.Reflection.Emit/DynamicMethod.cs
System.Reflection.Emit/EnumBuilder.cs
System.Reflection.Emit/EventBuilder.cs
System.Reflection.Emit/EventToken.cs
@@ -424,13 +425,16 @@ System.Runtime.CompilerServices/DiscardableAttribute.cs
System.Runtime.CompilerServices/IDispatchConstantAttribute.cs
System.Runtime.CompilerServices/IUnknownConstantAttribute.cs
System.Runtime.CompilerServices/IndexerNameAttribute.cs
+System.Runtime.CompilerServices/IsVolatile.cs
System.Runtime.CompilerServices/MethodCodeType.cs
System.Runtime.CompilerServices/MethodImplAttribute.cs
System.Runtime.CompilerServices/MethodImplOptions.cs
System.Runtime.CompilerServices/RequiredAttributeAttribute.cs
System.Runtime.CompilerServices/RuntimeHelpers.cs
+System.Runtime.InteropServices/ArrayWithOffset.cs
System.Runtime.InteropServices/AssemblyRegistrationFlags.cs
System.Runtime.InteropServices/AutomationProxyAttribute.cs
+System.Runtime.InteropServices/BestFitMappingAttribute.cs
System.Runtime.InteropServices/BIND_OPTS.cs
System.Runtime.InteropServices/BINDPTR.cs
System.Runtime.InteropServices/CALLCONV.cs
@@ -452,13 +456,17 @@ System.Runtime.InteropServices/ComSourceInterfacesAttribute.cs
System.Runtime.InteropServices/ComUnregisterFunctionAttribute.cs
System.Runtime.InteropServices/ComVisible.cs
System.Runtime.InteropServices/CONNECTDATA.cs
+System.Runtime.InteropServices/CurrencyWrapper.cs
System.Runtime.InteropServices/DESCKIND.cs
+System.Runtime.InteropServices/DispatchWrapper.cs
System.Runtime.InteropServices/DISPPARAMS.cs
System.Runtime.InteropServices/DispIdAttribute.cs
System.Runtime.InteropServices/DllImportAttribute.cs
System.Runtime.InteropServices/ELEMDESC.cs
+System.Runtime.InteropServices/ErrorWrapper.cs
System.Runtime.InteropServices/EXCEPINFO.cs
System.Runtime.InteropServices/ExporterEventKind.cs
+System.Runtime.InteropServices/ExtensibleClassFactory.cs
System.Runtime.InteropServices/ExternalException.cs
System.Runtime.InteropServices/FieldOffsetAttribute.cs
System.Runtime.InteropServices/FILETIME.cs
@@ -495,6 +503,7 @@ System.Runtime.InteropServices/LayoutKind.cs
System.Runtime.InteropServices/Marshal.cs
System.Runtime.InteropServices/MarshalAsAttribute.cs
System.Runtime.InteropServices/MarshalDirectiveException.cs
+System.Runtime.InteropServices/ObjectCreationDelegate.cs
System.Runtime.InteropServices/OptionalAttribute.cs
System.Runtime.InteropServices/OutAttribute.cs
System.Runtime.InteropServices/PARAMDESC.cs
@@ -504,6 +513,7 @@ System.Runtime.InteropServices/PrimaryInteropAssemblyAttribute.cs
System.Runtime.InteropServices/SEHException.cs
System.Runtime.InteropServices/STATSTG.cs
System.Runtime.InteropServices/ProgIdAttribute.cs
+System.Runtime.InteropServices/RegistrationServices.cs
System.Runtime.InteropServices/RuntimeEnvironment.cs
System.Runtime.InteropServices/SafeArrayRankMismatchException.cs
System.Runtime.InteropServices/SafeArrayTypeMismatchException.cs
@@ -514,6 +524,7 @@ System.Runtime.InteropServices/TYPEDESC.cs
System.Runtime.InteropServices/TYPEFLAGS.cs
System.Runtime.InteropServices/TYPEKIND.cs
System.Runtime.InteropServices/TYPELIBATTR.cs
+System.Runtime.InteropServices/TypeLibConverter.cs
System.Runtime.InteropServices/TypeLibExporterFlags.cs
System.Runtime.InteropServices/TypeLibFuncAttribute.cs
System.Runtime.InteropServices/TypeLibFuncFlags.cs
@@ -550,6 +561,7 @@ System.Runtime.Remoting/EnvoyInfo.cs
System.Runtime.Remoting/IObjectHandle.cs
System.Runtime.Remoting/IChannelInfo.cs
System.Runtime.Remoting/Identity.cs
+System.Runtime.Remoting/InternalRemotingServices.cs
System.Runtime.Remoting/IEnvoyInfo.cs
System.Runtime.Remoting/IRemotingTypeInfo.cs
System.Runtime.Remoting/ObjectHandle.cs
@@ -577,6 +589,7 @@ System.Runtime.Remoting.Activation/IConstructionReturnMessage.cs
System.Runtime.Remoting.Activation/RemoteActivator.cs
System.Runtime.Remoting.Activation/RemoteActivationAttribute.cs
System.Runtime.Remoting.Activation/UrlAttribute.cs
+System.Runtime.Remoting.Channels/AggregateDictionary.cs
System.Runtime.Remoting.Channels/BaseChannelObjectWithProperties.cs
System.Runtime.Remoting.Channels/BaseChannelSinkWithProperties.cs
System.Runtime.Remoting.Channels/BaseChannelWithProperties.cs
@@ -616,6 +629,7 @@ System.Runtime.Remoting.Contexts/CrossContextChannel.cs
System.Runtime.Remoting.Contexts/CrossContextDelegate.cs
System.Runtime.Remoting.Contexts/IContextAttribute.cs
System.Runtime.Remoting.Contexts/IContextProperty.cs
+System.Runtime.Remoting.Contexts/IContextPropertyActivator.cs
System.Runtime.Remoting.Contexts/IContributeClientContextSink.cs
System.Runtime.Remoting.Contexts/IContributeDynamicSink.cs
System.Runtime.Remoting.Contexts/IContributeEnvoySink.cs
@@ -623,6 +637,7 @@ System.Runtime.Remoting.Contexts/IContributeObjectSink.cs
System.Runtime.Remoting.Contexts/IContributeServerContextSink.cs
System.Runtime.Remoting.Contexts/IDynamicMessageSink.cs
System.Runtime.Remoting.Contexts/IDynamicProperty.cs
+System.Runtime.Remoting.Contexts/SynchronizationAttribute.cs
System.Runtime.Remoting.Lifetime/ClientSponsor.cs
System.Runtime.Remoting.Lifetime/ILease.cs
System.Runtime.Remoting.Lifetime/ISponsor.cs
@@ -651,6 +666,7 @@ System.Runtime.Remoting.Messaging/IMethodMessage.cs
System.Runtime.Remoting.Messaging/IMethodReturnMessage.cs
System.Runtime.Remoting.Messaging/IRemotingFormatter.cs
System.Runtime.Remoting.Messaging/InternalMessageWrapper.cs
+System.Runtime.Remoting.Messaging/ISerializationRootObject.cs
System.Runtime.Remoting.Messaging/LogicalCallContext.cs
System.Runtime.Remoting.Messaging/MessageSurrogateFilter.cs
System.Runtime.Remoting.Messaging/MethodCall.cs
@@ -688,6 +704,7 @@ System.Runtime.Remoting.Metadata.W3cXsd2001/SoapMonthDay.cs
System.Runtime.Remoting.Metadata.W3cXsd2001/SoapNonPositiveInteger.cs
System.Runtime.Remoting.Metadata.W3cXsd2001/SoapYear.cs
System.Runtime.Remoting.Metadata.W3cXsd2001/SoapDate.cs
+System.Runtime.Remoting.Metadata.W3cXsd2001/SoapHelper.cs
System.Runtime.Remoting.Metadata.W3cXsd2001/SoapId.cs
System.Runtime.Remoting.Metadata.W3cXsd2001/SoapName.cs
System.Runtime.Remoting.Metadata.W3cXsd2001/SoapNormalizedString.cs
@@ -711,8 +728,10 @@ System.Runtime.Remoting.Metadata.W3cXsd2001/SoapTime.cs
System.Runtime.Remoting.Proxies/RealProxy.cs
System.Runtime.Remoting.Proxies/RemotingProxy.cs
System.Runtime.Remoting.Proxies/ProxyAttribute.cs
+System.Runtime.Remoting.Services/EnterpriseServicesHelper.cs
System.Runtime.Remoting.Services/ITrackingHandler.cs
System.Runtime.Remoting.Services/TrackingServices.cs
+System.Runtime.Serialization/Formatter.cs
System.Runtime.Serialization/FormatterConverter.cs
System.Runtime.Serialization/FormatterServices.cs
System.Runtime.Serialization/IDeserializationCallback.cs
@@ -746,11 +765,14 @@ System.Runtime.Serialization.Formatters/InternalObjectTypeE.cs
System.Runtime.Serialization.Formatters/InternalParseStateE.cs
System.Runtime.Serialization.Formatters/InternalParseTypeE.cs
System.Runtime.Serialization.Formatters/InternalPrimitiveTypeE.cs
+System.Runtime.Serialization.Formatters/InternalRM.cs
System.Runtime.Serialization.Formatters/InternalSerializerTypeE.cs
+System.Runtime.Serialization.Formatters/InternalST.cs
System.Runtime.Serialization.Formatters/ISoapMessage.cs
System.Runtime.Serialization.Formatters/ServerFault.cs
System.Runtime.Serialization.Formatters/SoapFault.cs
System.Runtime.Serialization.Formatters/SoapMessage.cs
+System.Runtime.Serialization.Formatters/TypeFilterLevel.cs
System.Runtime.Serialization.Formatters.Binary/BinaryFormatter.cs
System.Runtime.Serialization.Formatters.Binary/BinaryCommon.cs
System.Runtime.Serialization.Formatters.Binary/ObjectReader.cs
diff --git a/mcs/class/corlib/corlib_test.dll.sources b/mcs/class/corlib/corlib_test.dll.sources
index 11e58e333c7..15f7fc8e4e0 100755
--- a/mcs/class/corlib/corlib_test.dll.sources
+++ b/mcs/class/corlib/corlib_test.dll.sources
@@ -75,6 +75,9 @@ System.Reflection/StrongNameKeyPairTest.cs
System/ResolveEventArgsTest.cs
System.Resources/ResourceReaderTest.cs
System.Runtime.CompilerServices/RuntimeHelpersTest.cs
+System.Runtime.Remoting/ContextTest.cs
+System.Runtime.Remoting/SoapServicesTest.cs
+System.Runtime.Remoting/SynchronizationAttributeTest.cs
System.Runtime.Serialization/FormatterServicesTests.cs
System.Runtime.Serialization/ObjectIDGeneratorTests.cs
System.Runtime.Serialization/SerializationTest.cs
@@ -98,6 +101,8 @@ System.Security.Cryptography/MACTripleDESTest.cs
System.Security.Cryptography/MD5Test.cs
System.Security.Cryptography/PasswordDeriveBytesTest.cs
System.Security.Cryptography/PKCS1MaskGenerationMethodTest.cs
+System.Security.Cryptography/ProtectedDataTest.cs
+System.Security.Cryptography/ProtectedMemoryTest.cs
System.Security.Cryptography/RandomNumberGeneratorTest.cs
System.Security.Cryptography/RC2Test.cs
System.Security.Cryptography/RijndaelManagedTest.cs
@@ -163,3 +168,4 @@ System/UInt16Test.cs
System/UInt32Test.cs
System/UInt64Test.cs
System/VersionTest.cs
+System/ValueTypeTest.cs
diff --git a/mcs/docs/compiler b/mcs/docs/compiler
index 921075b290f..72d54e2ef4e 100755
--- a/mcs/docs/compiler
+++ b/mcs/docs/compiler
@@ -147,6 +147,11 @@
statements live in this file. This also drives the
semantic analysis process.
+ iterators.cs:
+
+ Contains the support for implementing iterators from
+ the C# 2.0 specification.
+
Declarations, Classes, Structs, Enumerations
decl.cs
diff --git a/mcs/errors/ChangeLog b/mcs/errors/ChangeLog
index 3277ba29c29..1040ad68e90 100644
--- a/mcs/errors/ChangeLog
+++ b/mcs/errors/ChangeLog
@@ -1,3 +1,7 @@
+2003-11-01 Marek Safar <marek.safar@seznam.cz>
+
+ * makefile: Added "// Compiler options:" handling
+
2003-09-22 Martin Baulig <martin@ximian.com>
* errors.txt: Added -219.
diff --git a/mcs/errors/Makefile b/mcs/errors/Makefile
index f10e5f5ec32..26c7c8e48ab 100644
--- a/mcs/errors/Makefile
+++ b/mcs/errors/Makefile
@@ -6,11 +6,10 @@ include ../build/rules.make
# means we can use --options, yay.
MCS = $(INTERNAL_MCS)
-LOCAL_MCS_FLAGS = /nowarn:162 /unsafe --wlevel 4
+LOCAL_MCS_FLAGS = /nowarn:162 --wlevel 4
RUNTEST_PL = ./runtest.pl
-
DISTFILES = \
CONTRIBUTORS_README \
README.tests \
@@ -39,7 +38,8 @@ run-test-local:
;;\
esac; \
echo -n "Running test $$i ... "; \
- if $(CSCOMPILE) --expect-error $$error $$i > /dev/null; \
+ options=`fgrep "// Compiler options:" $$i | sed -e 's/\/\/ Compiler options://'`; \
+ if $(CSCOMPILE) --expect-error $$error $$i $$options > /dev/null; \
then echo OK; \
else echo FAILED; \
flist="$$flist $$i"; \
@@ -71,8 +71,8 @@ test-multi-local:
clean-local:
rm -f *.exe
+ rm -f *.dll
dist-local: dist-default
install-local uninstall-local:
-
diff --git a/mcs/errors/cs0035.cs b/mcs/errors/cs0035.cs
index c536f7d1402..e69de29bb2d 100644
--- a/mcs/errors/cs0035.cs
+++ b/mcs/errors/cs0035.cs
@@ -1,27 +0,0 @@
-// cs0035.cs: Ambiguous 'operator' on an operand of type 'foo'
-// Line: 23
-
-using System;
-
-class ErrorCS0035 {
- int i;
- public ErrorCS0035 (int x) {
- i = x;
- }
-
- public static implicit operator long (ErrorCS0035 x) {
- return (long) x.i;
- }
-
- public static implicit operator ulong (ErrorCS0035 x) {
- return (ulong) x.i;
- }
-
- public static void Main () {
- object o;
- ErrorCS0035 error = new ErrorCS0035 (10);
- Console.WriteLine ("o = -i = {0}", - error);
-
- }
-}
-
diff --git a/mcs/errors/cs0052.cs b/mcs/errors/cs0052.cs
new file mode 100644
index 00000000000..36709a24967
--- /dev/null
+++ b/mcs/errors/cs0052.cs
@@ -0,0 +1,9 @@
+// cs0052.cs: Inconsistent accessibility: field type `InternalClass' is less accessible than field 'PublicClass.member'
+// Line: 8
+
+class InternalClass {
+}
+
+public class PublicClass {
+ public InternalClass member;
+}
diff --git a/mcs/errors/cs0065.cs b/mcs/errors/cs0065.cs
new file mode 100644
index 00000000000..67548f8421e
--- /dev/null
+++ b/mcs/errors/cs0065.cs
@@ -0,0 +1,14 @@
+// cs0065.cs: 'EventClass.handler' : event property must have both add and remove accessors
+// Line : 9
+
+using System;
+
+public delegate void EventHandler (object sender, EventArgs e);
+
+public class EventClass {
+ event EventHandler handler {}
+}
+
+public class MainClass {
+ public static void Main () {}
+}
diff --git a/mcs/errors/cs0103.cs b/mcs/errors/cs0103.cs
new file mode 100644
index 00000000000..b86707d574c
--- /dev/null
+++ b/mcs/errors/cs0103.cs
@@ -0,0 +1,9 @@
+// cs0103.cs: The name 'count' does not exist in the class or namespace 'ClassMain'
+// Line: 6
+
+class ClassMain {
+ public static void Main () {
+ count++;
+ }
+}
+
diff --git a/mcs/errors/cs0123.cs b/mcs/errors/cs0123.cs
new file mode 100644
index 00000000000..441189c02bf
--- /dev/null
+++ b/mcs/errors/cs0123.cs
@@ -0,0 +1,14 @@
+// cs0123.cs: Method 'MainClass.Delegate()' does not match delegate 'void TestDelegate()'
+// Line: 12
+
+delegate void TestDelegate();
+
+public class MainClass {
+ public static int Delegate() {
+ return 0;
+ }
+
+ public static void Main() {
+ TestDelegate delegateInstance = new TestDelegate (Delegate);
+ }
+}
diff --git a/mcs/errors/cs0134.cs b/mcs/errors/cs0134.cs
new file mode 100644
index 00000000000..4032d3c39d3
--- /dev/null
+++ b/mcs/errors/cs0134.cs
@@ -0,0 +1,11 @@
+// cs0134.cs: Cannot use qualified namespace names in nested namespace declarations
+// Line: 5
+
+namespace Level1 {
+ namespace Level1.Level2 {
+ public class MainClass {
+ public static void Main() {
+ }
+ }
+ }
+}
diff --git a/mcs/errors/cs0135.cs b/mcs/errors/cs0135.cs
new file mode 100644
index 00000000000..4c67abca7e1
--- /dev/null
+++ b/mcs/errors/cs0135.cs
@@ -0,0 +1,14 @@
+// cs0135.cs: 'test' conflicts with the declaration 'ClassMain.test'
+// Line: 11
+
+class ClassMain {
+ static bool test = true;
+
+ public static void Main() {
+ if (true) {
+ bool test = false;
+ }
+ test = false;
+ }
+}
+
diff --git a/mcs/errors/cs0145.cs b/mcs/errors/cs0145.cs
new file mode 100644
index 00000000000..d248cea6bec
--- /dev/null
+++ b/mcs/errors/cs0145.cs
@@ -0,0 +1,7 @@
+// cs0145.cs: A const field requires a value to be provided
+// Line: 5
+
+class Test {
+ const long value;
+}
+
diff --git a/mcs/errors/cs0149.cs b/mcs/errors/cs0149.cs
new file mode 100644
index 00000000000..d962e397fe3
--- /dev/null
+++ b/mcs/errors/cs0149.cs
@@ -0,0 +1,10 @@
+// cs0149.cs: Method 'MainClass.Delegate()' does not match delegate 'void TestDelegate()'
+// Line: 8
+
+delegate void TestDelegate();
+
+public class MainClass {
+ public static void Main() {
+ TestDelegate delegateInstance = new TestDelegate (0);
+ }
+}
diff --git a/mcs/errors/cs0158.cs b/mcs/errors/cs0158.cs
new file mode 100644
index 00000000000..e0058b20db1
--- /dev/null
+++ b/mcs/errors/cs0158.cs
@@ -0,0 +1,13 @@
+// cs0158.cs: The label 'start' shadows another label by the same name in a contained scope
+// Line: 9
+
+class ClassMain {
+ public static void Main() {
+ start:
+ {
+ start:
+ goto start;
+ }
+ }
+}
+
diff --git a/mcs/errors/cs0160.cs b/mcs/errors/cs0160.cs
new file mode 100644
index 00000000000..5b9b1deb46c
--- /dev/null
+++ b/mcs/errors/cs0160.cs
@@ -0,0 +1,11 @@
+// cs0160.cs: A previous catch clause already catches all exceptions of this or a super type 'System.Exception'
+// Line: 8
+
+class ClassMain {
+ public static void Main() {
+ try { }
+ catch (System.Exception) { }
+ catch (System.ApplicationException) { }
+ }
+}
+
diff --git a/mcs/errors/cs0173.cs b/mcs/errors/cs0173.cs
new file mode 100644
index 00000000000..65b5c1e710b
--- /dev/null
+++ b/mcs/errors/cs0173.cs
@@ -0,0 +1,31 @@
+// cs0173.cs: Type of conditional expression can't be determined because there is no implicit conversion between 'ClassA' and 'ClassB'
+// Line: 29
+
+class ClassA {
+ public static implicit operator ClassB (ClassA value) {
+ return null;
+ }
+
+ public static implicit operator ClassA (ClassB value) {
+ return null;
+ }
+}
+
+class ClassB {
+ public static implicit operator ClassA (ClassB value) {
+ return null;
+ }
+
+ public static implicit operator ClassB (ClassA value) {
+ return null;
+ }
+}
+
+public class MainClass {
+ public static void Main() {
+ ClassA a = new ClassA();
+ ClassB b = new ClassB();
+
+ Console.WriteLine(true ? a : b);
+ }
+}
diff --git a/mcs/errors/cs0175-2.cs b/mcs/errors/cs0175-2.cs
new file mode 100644
index 00000000000..51ea9dd9f85
--- /dev/null
+++ b/mcs/errors/cs0175-2.cs
@@ -0,0 +1,9 @@
+// cs0175.cs: Use of keyword base is not valid in this context
+// Line: 13
+
+class DerivedClass {
+ public DerivedClass() {
+ base = null;
+ }
+}
+
diff --git a/mcs/errors/cs0175.cs b/mcs/errors/cs0175.cs
new file mode 100644
index 00000000000..9801963858a
--- /dev/null
+++ b/mcs/errors/cs0175.cs
@@ -0,0 +1,12 @@
+// cs0175: wrong context for use of `base' keyword
+// Line: 8
+using System.Collections;
+class Collection : CollectionBase
+{
+ public int Add (int x)
+ {
+ return ((IList) base).Add (x);
+ }
+}
+
+
diff --git a/mcs/errors/cs0177.cs b/mcs/errors/cs0177.cs
new file mode 100644
index 00000000000..dd79297026f
--- /dev/null
+++ b/mcs/errors/cs0177.cs
@@ -0,0 +1,11 @@
+// cs0177.cs: The out parameter 'display' must be assigned to before control leaves the current method
+// Line: 5
+
+class ClassMain {
+ void Error(out bool display) {
+ }
+
+ public static void Main() {
+ }
+}
+
diff --git a/mcs/errors/cs0186.cs b/mcs/errors/cs0186.cs
new file mode 100644
index 00000000000..f15e79b02e5
--- /dev/null
+++ b/mcs/errors/cs0186.cs
@@ -0,0 +1,11 @@
+// cs0186.cs: Use of null is not valid in this context
+// Line: 8
+
+using System;
+
+class ClassMain {
+ public static void Main() {
+ Exception e = (object)null as Exception;
+ }
+}
+
diff --git a/mcs/errors/cs0188.cs b/mcs/errors/cs0188.cs
new file mode 100644
index 00000000000..09fe4259f51
--- /dev/null
+++ b/mcs/errors/cs0188.cs
@@ -0,0 +1,14 @@
+// cs0188.cs: The this object cannot be used before all of its fields are assigned to
+// Line: 6
+
+struct Sample {
+ public Sample(string text) {
+ Initialize();
+ this.text = text;
+ }
+
+ void Initialize() {
+ }
+
+ string text;
+} \ No newline at end of file
diff --git a/mcs/errors/cs0193.cs b/mcs/errors/cs0193.cs
index fe2662a82af..ad22f1856be 100755
--- a/mcs/errors/cs0193.cs
+++ b/mcs/errors/cs0193.cs
@@ -1,5 +1,6 @@
// cs0193.cs: * or -> operator can only be applied to pointer types.
-// Line: 8
+// Line: 9
+// Compiler options: -unsafe
unsafe class X {
static void Main ()
diff --git a/mcs/errors/cs0196.cs b/mcs/errors/cs0196.cs
index 57dd9c2b7b1..04c158b0e86 100755
--- a/mcs/errors/cs0196.cs
+++ b/mcs/errors/cs0196.cs
@@ -1,6 +1,8 @@
// cs0196.cs: pointers must be indexed by a single value
-// line: 8
+// line: 10
+// Compiler options: -unsafe
using System;
+
unsafe class ZZ {
static void Main () {
int *p = null;
diff --git a/mcs/errors/cs0199.cs b/mcs/errors/cs0199.cs
new file mode 100644
index 00000000000..ef9b8f081b1
--- /dev/null
+++ b/mcs/errors/cs0199.cs
@@ -0,0 +1,19 @@
+// cs0158.cs: A static readonly field cannot be passed ref or out (except in a static constructor)
+// Line: 16
+
+class ClassMain {
+ static readonly int index;
+
+ static ClassMain () {
+ GetMaxIndex (ref index);
+ }
+
+ static void GetMaxIndex (ref int value) {
+ value = 5;
+ }
+
+ public static void Main () {
+ GetMaxIndex (ref index);
+ }
+}
+
diff --git a/mcs/errors/cs0208-2.cs b/mcs/errors/cs0208-2.cs
index 8b0ac360a63..cdb2ea49349 100644
--- a/mcs/errors/cs0208-2.cs
+++ b/mcs/errors/cs0208-2.cs
@@ -1,5 +1,6 @@
// cs0208.cs: Cannot take the address or size of a variable of a managed type ('cs208.Foo')
-// Line: 19
+// Line: 20
+// Compiler options: -unsafe
namespace cs208
{
diff --git a/mcs/errors/cs0208.cs b/mcs/errors/cs0208.cs
index 25a3529b99a..d447ba527ab 100644
--- a/mcs/errors/cs0208.cs
+++ b/mcs/errors/cs0208.cs
@@ -1,5 +1,6 @@
// cs0208.cs: Cannot take the address or size of a variable of a managed type ('cs208.Foo')
-// Line: 19
+// Line: 20
+// Compiler options: -unsafe
namespace cs208
{
diff --git a/mcs/errors/cs0209.cs b/mcs/errors/cs0209.cs
index 8aa58b38872..5b2d201d892 100644
--- a/mcs/errors/cs0209.cs
+++ b/mcs/errors/cs0209.cs
@@ -1,5 +1,7 @@
// cs0209.cs: variable in a fixed statement must be a pointer
-// Line: 7
+// Line: 9
+// Compiler options: -unsafe
+
public class A
{
unsafe static void Main ()
diff --git a/mcs/errors/cs0210.cs b/mcs/errors/cs0210.cs
new file mode 100644
index 00000000000..76de5e4ddbc
--- /dev/null
+++ b/mcs/errors/cs0210.cs
@@ -0,0 +1,13 @@
+// cs0210.cs: You must provide an initializer in a fixed or using statement declaration
+// Line: 8
+
+using System.Resources;
+
+public class MainClass {
+ static void Main () {
+ using (ResourceReader reader) {
+ }
+ }
+}
+
+
diff --git a/mcs/errors/cs0211.cs b/mcs/errors/cs0211.cs
new file mode 100644
index 00000000000..89aa68f3510
--- /dev/null
+++ b/mcs/errors/cs0211.cs
@@ -0,0 +1,11 @@
+// cs0211.cs: Cannot take the address of the given expression
+// Line: 7
+// Compiler options: -unsafe
+
+class UnsafeClass {
+ unsafe UnsafeClass () {
+ fixed (int* a = &(2)) {}
+ }
+}
+
+
diff --git a/mcs/errors/cs0212.cs b/mcs/errors/cs0212.cs
index d51f6748ace..32ed536a21c 100644
--- a/mcs/errors/cs0212.cs
+++ b/mcs/errors/cs0212.cs
@@ -1,6 +1,8 @@
// cs0212: You can only take the address of an unfixed expression inside
// a fixed statement initializer.
-// Line: 17
+// Line: 19
+// Compiler options: -unsafe
+
using System;
class X
diff --git a/mcs/errors/cs0213.cs b/mcs/errors/cs0213.cs
new file mode 100644
index 00000000000..65c8b3b0a7e
--- /dev/null
+++ b/mcs/errors/cs0213.cs
@@ -0,0 +1,16 @@
+// cs0213.cs: You do not need to use the fixed statement to take the address of an already fixed expression
+// Line: 12
+// Compiler options: -unsafe
+
+class UnsafeClass {
+ unsafe UnsafeClass () {
+ int value = 5;
+ Calculate(value);
+ }
+
+ unsafe void Calculate (int value) {
+ fixed (int *x = &value) {}
+ }
+}
+
+
diff --git a/mcs/errors/cs0214-2.cs b/mcs/errors/cs0214-2.cs
index 2526a9fc682..6e47b4905f9 100755
--- a/mcs/errors/cs0214-2.cs
+++ b/mcs/errors/cs0214-2.cs
@@ -1,3 +1,5 @@
+// Compiler options: -unsafe
+
class X {
static void Main ()
{
diff --git a/mcs/errors/cs0214-3.cs b/mcs/errors/cs0214-3.cs
index e40bbfb7247..8b00f242192 100755
--- a/mcs/errors/cs0214-3.cs
+++ b/mcs/errors/cs0214-3.cs
@@ -1,3 +1,5 @@
+// Compiler options: -unsafe
+
struct X {
static unsafe void *a ()
{
diff --git a/mcs/errors/cs0214.cs b/mcs/errors/cs0214.cs
index 08eb088af39..c8bbad1905d 100644
--- a/mcs/errors/cs0214.cs
+++ b/mcs/errors/cs0214.cs
@@ -1,5 +1,7 @@
// cs0214: Pointer can only be used in unsafe context
-// Line: 4
+// Line: 6
+// Compiler options: -unsafe
+
class X {
void *a;
}
diff --git a/mcs/errors/cs0217.cs b/mcs/errors/cs0217.cs
new file mode 100644
index 00000000000..f7f7687f254
--- /dev/null
+++ b/mcs/errors/cs0217.cs
@@ -0,0 +1,26 @@
+// cs0217.cs: In order to be applicable as a short circuit operator a user-defined logical operator ('UserOperatorClass.operator &(UserOperatorClass, UserOperatorClass)') must have the same return type as the type of its 2 parameters
+// Line: 22
+
+public class UserOperatorClass
+{
+ public static bool operator & (UserOperatorClass u1, UserOperatorClass u2) {
+ return true;
+ }
+
+ public static bool operator true (UserOperatorClass u) {
+ return true;
+ }
+
+ public static bool operator false (UserOperatorClass u) {
+ return false;
+ }
+
+ public static void Main () {
+
+ UserOperatorClass x = new UserOperatorClass();
+ UserOperatorClass y = new UserOperatorClass();
+ UserOperatorClass z = x && y;
+ }
+}
+
+
diff --git a/mcs/errors/cs0218.cs b/mcs/errors/cs0218.cs
new file mode 100644
index 00000000000..1cd0cf91d5e
--- /dev/null
+++ b/mcs/errors/cs0218.cs
@@ -0,0 +1,26 @@
+// cs0218.cs: The type ('UserOperatorClass') must contain declarations of operator true and operator false
+// Line: 22
+
+public class UserOperatorClass
+{
+ public static UserOperatorClass operator & (UserOperatorClass u1, UserOperatorClass u2) {
+ return new UserOperatorClass();
+ }
+
+// public static bool operator true (UserOperatorClass u) {
+// return true;
+// }
+
+// public static bool operator false (UserOperatorClass u) {
+// return false;
+// }
+
+ public static void Main() {
+
+ UserOperatorClass x = new UserOperatorClass();
+ UserOperatorClass y = new UserOperatorClass();
+ UserOperatorClass z = x && y;
+ }
+}
+
+
diff --git a/mcs/errors/cs0220.cs b/mcs/errors/cs0220.cs
new file mode 100644
index 00000000000..aa5982aea9d
--- /dev/null
+++ b/mcs/errors/cs0220.cs
@@ -0,0 +1,11 @@
+// cs0220.cs: The operation overflows at compile time in checked mode
+// Line: 7
+
+public class MainClass {
+ static void Main () {
+ const long a = long.MaxValue;
+ long b = 2 * a;
+ }
+}
+
+
diff --git a/mcs/errors/cs0227.cs b/mcs/errors/cs0227.cs
new file mode 100644
index 00000000000..df54a254a9b
--- /dev/null
+++ b/mcs/errors/cs0227.cs
@@ -0,0 +1,8 @@
+// cs0227.cs: Unsafe code may only appear if compiling with /unsafe
+// Line: 5
+
+class UnsafeClass {
+ unsafe UnsafeClass () {}
+}
+
+
diff --git a/mcs/errors/cs0231.cs b/mcs/errors/cs0231.cs
new file mode 100644
index 00000000000..478cfe65223
--- /dev/null
+++ b/mcs/errors/cs0231.cs
@@ -0,0 +1,7 @@
+// cs0231.cs: A params or __arglist parameter must be the last in a formal parameter list
+// Line: 5
+
+class Test {
+ void Foo (params object[] o, bool b) {}
+}
+
diff --git a/mcs/errors/cs0233.cs b/mcs/errors/cs0233.cs
new file mode 100644
index 00000000000..6ff22a4940c
--- /dev/null
+++ b/mcs/errors/cs0233.cs
@@ -0,0 +1,11 @@
+// cs0233.cs: sizeof can only be used in an unsafe context (consider using System.Runtime.InteropServices.Marshal.SizeOf)
+// Line: 7
+// Compiler options: -unsafe
+
+public class MainClass {
+ static void Main () {
+ const int size = sizeof(int);
+ }
+}
+
+
diff --git a/mcs/errors/cs0238.cs b/mcs/errors/cs0238.cs
new file mode 100644
index 00000000000..fb291a4e60b
--- /dev/null
+++ b/mcs/errors/cs0238.cs
@@ -0,0 +1,13 @@
+// cs0238.cs: 'DerivedClass.Show()' cannot be sealed because it is not an override
+// Line: 10
+
+class BaseClass {
+ void Show() {}
+}
+
+class DerivedClass: BaseClass {
+ sealed void Show() {}
+
+ static void Main() {}
+}
+
diff --git a/mcs/errors/cs0241.cs b/mcs/errors/cs0241.cs
new file mode 100644
index 00000000000..439ede5a4b6
--- /dev/null
+++ b/mcs/errors/cs0241.cs
@@ -0,0 +1,8 @@
+// cs0241.cs: Default parameter specifiers are not permitted
+// Line: 5
+
+class TestClass {
+ public TestClass(int value = 0) {
+ }
+}
+
diff --git a/mcs/errors/cs0242.cs b/mcs/errors/cs0242.cs
index c775f17342e..494e3b7d0a0 100755
--- a/mcs/errors/cs0242.cs
+++ b/mcs/errors/cs0242.cs
@@ -1,6 +1,8 @@
// cs0242: operation is not defined for void *
-// Line: 8
+// Line: 10
+// Compiler options: -unsafe
using System;
+
unsafe class ZZ {
static void Main () {
void *p = null;
diff --git a/mcs/errors/cs0243.cs b/mcs/errors/cs0243.cs
new file mode 100644
index 00000000000..69085285b6e
--- /dev/null
+++ b/mcs/errors/cs0243.cs
@@ -0,0 +1,13 @@
+// cs0238.cs: Conditional not valid on 'DerivedClass.Show()' because it is an override method
+// Line: 10
+
+class BaseClass {
+ protected virtual void Show () {}
+}
+
+class DerivedClass: BaseClass {
+ [System.Diagnostics.Conditional("DEBUG")] protected override void Show () {}
+
+ static void Main () {}
+}
+
diff --git a/mcs/errors/cs0244.cs b/mcs/errors/cs0244.cs
new file mode 100644
index 00000000000..bac103f120f
--- /dev/null
+++ b/mcs/errors/cs0244.cs
@@ -0,0 +1,11 @@
+// cs0244.cs: "is" or "as" are not valid on pointer types
+// Line: 7
+// Compiler options: -unsafe
+
+class UnsafeClass {
+ unsafe UnsafeClass (int* pointer) {
+ if (pointer is string) {}
+ }
+}
+
+
diff --git a/mcs/errors/cs0245.cs b/mcs/errors/cs0245.cs
new file mode 100644
index 00000000000..0b7c7f2c8b9
--- /dev/null
+++ b/mcs/errors/cs0245.cs
@@ -0,0 +1,9 @@
+// cs0245.cs: Destructors and object.Finalize cannot be called directly. Consider calling IDisposable.Dispose if available
+// Line: 6
+
+class Sample {
+ void Close () {
+ this.Finalize();
+ }
+}
+
diff --git a/mcs/errors/cs0247.cs b/mcs/errors/cs0247.cs
new file mode 100644
index 00000000000..0a0aef92d28
--- /dev/null
+++ b/mcs/errors/cs0247.cs
@@ -0,0 +1,11 @@
+// cs0247.cs: Cannot use a negative size with stackalloc
+// Line: 7
+// Compiler options: -unsafe
+
+public class MainClass {
+ static unsafe void Main () {
+ int* ptr = stackalloc int[-1];
+ }
+}
+
+
diff --git a/mcs/errors/cs0248.cs b/mcs/errors/cs0248.cs
new file mode 100644
index 00000000000..1b026c41341
--- /dev/null
+++ b/mcs/errors/cs0248.cs
@@ -0,0 +1,10 @@
+// cs0248.cs: Cannot create an array with a negative size
+// Line: 6
+
+public class MainClass {
+ public static void Main () {
+ byte[] byteArray = new byte[-1];
+ }
+}
+
+
diff --git a/mcs/errors/cs0249.cs b/mcs/errors/cs0249.cs
new file mode 100644
index 00000000000..bc9ca9fdbd1
--- /dev/null
+++ b/mcs/errors/cs0249.cs
@@ -0,0 +1,7 @@
+// cs0249.cs: Do not override object.Finalize. Instead, provide a destructor
+// Line: 5
+
+class Sample {
+ protected override void Finalize() {}
+}
+
diff --git a/mcs/errors/cs0250.cs b/mcs/errors/cs0250.cs
new file mode 100644
index 00000000000..d2ff1c40506
--- /dev/null
+++ b/mcs/errors/cs0250.cs
@@ -0,0 +1,12 @@
+// cs0250.cs: Do not directly call your base class Finalize method. It is called automatically from your destructor
+// Line: 9
+
+class BaseClass {
+}
+
+class DerivedClass: BaseClass {
+ ~DerivedClass () {
+ base.Finalize ();
+ }
+}
+
diff --git a/mcs/errors/cs0255.cs b/mcs/errors/cs0255.cs
index 5319b82f5e1..ed9aae54cc2 100755
--- a/mcs/errors/cs0255.cs
+++ b/mcs/errors/cs0255.cs
@@ -1,5 +1,7 @@
// cs0255.cs: Can not use stackalloc in finally or catch
-// Line: 10
+// Line: 12
+// Compiler options: -unsafe
+
unsafe class X {
static void Main ()
diff --git a/mcs/errors/cs0502.cs b/mcs/errors/cs0502.cs
new file mode 100644
index 00000000000..e2232ec0c29
--- /dev/null
+++ b/mcs/errors/cs0502.cs
@@ -0,0 +1,6 @@
+// cs0502.cs: The class 'Sample' is abstract and sealed
+// Line: 4
+
+abstract sealed class Sample {
+}
+
diff --git a/mcs/errors/cs0504.cs b/mcs/errors/cs0504.cs
new file mode 100644
index 00000000000..a2d1126de67
--- /dev/null
+++ b/mcs/errors/cs0504.cs
@@ -0,0 +1,9 @@
+// cs0504.cs: The constant 'Sample.constant' cannot be marked static
+// Line: 5
+
+class Sample {
+ static const bool constant = false;
+}
+
+
+
diff --git a/mcs/errors/cs0505.cs b/mcs/errors/cs0505.cs
new file mode 100644
index 00000000000..19faa79e205
--- /dev/null
+++ b/mcs/errors/cs0505.cs
@@ -0,0 +1,11 @@
+// cs0505.cs: 'DerivedClass.value()' : cannot override; 'BaseClass.value' is not a function
+// Line: 9
+
+class BaseClass {
+ protected int value;
+}
+
+class DerivedClass: BaseClass {
+ protected override int value() {}
+}
+
diff --git a/mcs/errors/cs0506.cs b/mcs/errors/cs0506.cs
new file mode 100644
index 00000000000..24260864656
--- /dev/null
+++ b/mcs/errors/cs0506.cs
@@ -0,0 +1,11 @@
+// cs0506.cs: 'DerivedClass.Show()' : cannot override inherited member 'BaseClass.Show()' because it is not marked "virtual", "abstract", or "override"
+// Line: 9
+
+class BaseClass {
+ protected void Show () {}
+}
+
+class DerivedClass: BaseClass {
+ protected override void Show () {}
+}
+
diff --git a/mcs/errors/cs0507.cs b/mcs/errors/cs0507.cs
new file mode 100644
index 00000000000..30b51b45165
--- /dev/null
+++ b/mcs/errors/cs0507.cs
@@ -0,0 +1,11 @@
+// cs0506.cs: 'DerivedClass.Show()' : cannot change access modifiers when overriding inherited member 'BaseClass.Show()'
+// Line: 9
+
+class BaseClass {
+ protected virtual void Show () {}
+}
+
+class DerivedClass: BaseClass {
+ public override void Show () {}
+}
+
diff --git a/mcs/errors/cs0508.cs b/mcs/errors/cs0508.cs
new file mode 100644
index 00000000000..8788e0fc1b1
--- /dev/null
+++ b/mcs/errors/cs0508.cs
@@ -0,0 +1,11 @@
+// cs0508.cs: 'DerivedClass.Show()' : cannot change return type when overriding inherited member 'BaseClass.Show()'
+// Line: 9
+
+class BaseClass {
+ protected virtual void Show () {}
+}
+
+class DerivedClass: BaseClass {
+ protected override bool Show () {}
+}
+
diff --git a/mcs/errors/cs0516.cs b/mcs/errors/cs0516.cs
new file mode 100644
index 00000000000..818fc92e8dd
--- /dev/null
+++ b/mcs/errors/cs0516.cs
@@ -0,0 +1,9 @@
+// cs0516.cs: Constructor 'Sample.Sample()' can not call itself
+// Line: 5
+
+class Sample {
+ public Sample (): this () {}
+}
+
+
+
diff --git a/mcs/errors/cs0522.cs b/mcs/errors/cs0522.cs
new file mode 100644
index 00000000000..801144d8974
--- /dev/null
+++ b/mcs/errors/cs0522.cs
@@ -0,0 +1,7 @@
+// cs0522.cs: 'SampleStruct.SampleStruct(int)' : structs cannot call base class constructors
+// Line: 5
+
+struct SampleStruct {
+ public SampleStruct (int value): base (value) {}
+}
+
diff --git a/mcs/errors/cs0524.cs b/mcs/errors/cs0524.cs
new file mode 100644
index 00000000000..c19367335a5
--- /dev/null
+++ b/mcs/errors/cs0524.cs
@@ -0,0 +1,10 @@
+// cs0524.cs: 'Struct' : interfaces cannot declare types
+// Line: 5
+
+interface Interface {
+ public struct Struct {
+ }
+}
+
+
+
diff --git a/mcs/errors/cs0525.cs b/mcs/errors/cs0525.cs
new file mode 100644
index 00000000000..f0112ef1f24
--- /dev/null
+++ b/mcs/errors/cs0525.cs
@@ -0,0 +1,9 @@
+// cs0525.cs: Interfaces cannot contain fields
+// Line: 5
+
+interface Interface {
+ bool value = false;
+}
+
+
+
diff --git a/mcs/errors/cs0526.cs b/mcs/errors/cs0526.cs
new file mode 100644
index 00000000000..58855fb77e7
--- /dev/null
+++ b/mcs/errors/cs0526.cs
@@ -0,0 +1,10 @@
+// cs0526.cs: Interfaces cannot contain constructors
+// Line: 5
+
+public interface Interface {
+ public Interface () {
+ }
+}
+
+
+
diff --git a/mcs/errors/cs0531.cs b/mcs/errors/cs0531.cs
new file mode 100644
index 00000000000..318b5296d8b
--- /dev/null
+++ b/mcs/errors/cs0531.cs
@@ -0,0 +1,10 @@
+// cs0531.cs: 'Interface.Foo()' : interface members cannot have a definition
+// Line: 5
+
+public interface Interface {
+ void Foo () {
+ }
+}
+
+
+
diff --git a/mcs/errors/cs0533.cs b/mcs/errors/cs0533.cs
new file mode 100644
index 00000000000..0628e3f1ab6
--- /dev/null
+++ b/mcs/errors/cs0533.cs
@@ -0,0 +1,11 @@
+// cs0533.cs: 'DerivedClass.Foo()' hides inherited abstract member 'BaseClass.Foo()'
+// Line: 9
+
+abstract public class BaseClass {
+ abstract protected void Foo ();
+}
+
+abstract class DerivedClass: BaseClass {
+ public new void Foo () {}
+}
+
diff --git a/mcs/errors/cs0535.cs b/mcs/errors/cs0535.cs
new file mode 100644
index 00000000000..99226b52ff4
--- /dev/null
+++ b/mcs/errors/cs0535.cs
@@ -0,0 +1,11 @@
+// cs0535.cs: 'Class' does not implement interface member 'Interface.Method()'
+// Line: 8
+
+interface Interface {
+ void Method();
+}
+
+class Class: Interface {
+}
+
+
diff --git a/mcs/errors/cs0537.cs b/mcs/errors/cs0537.cs
new file mode 100644
index 00000000000..defc9f75068
--- /dev/null
+++ b/mcs/errors/cs0537.cs
@@ -0,0 +1,10 @@
+// cs0537.cs: The class System.Object cannot have a base class or implement an interface
+// Line: 5
+
+namespace System {
+ class Object: ICloneable {
+ }
+}
+
+
+
diff --git a/mcs/errors/cs0538.cs b/mcs/errors/cs0538.cs
new file mode 100644
index 00000000000..bf42e10d9d2
--- /dev/null
+++ b/mcs/errors/cs0538.cs
@@ -0,0 +1,14 @@
+// cs0538.cs: 'BaseClass' in explicit interface declaration is not an interface
+// Line: 9
+
+class BaseClass {
+ public void Foo() {}
+}
+
+class InstanceClass: BaseClass {
+ void BaseClass.Foo() {
+ }
+}
+
+
+
diff --git a/mcs/errors/cs0541.cs b/mcs/errors/cs0541.cs
new file mode 100644
index 00000000000..efa1a588aa4
--- /dev/null
+++ b/mcs/errors/cs0541.cs
@@ -0,0 +1,10 @@
+// cs0541.cs: 'ICloneable.Clone' : explicit interface declaration can only be declared in a class or struct
+// Line: 7
+
+using System;
+
+interface Interface: ICloneable {
+ void ICloneable.Clone ();
+}
+
+
diff --git a/mcs/errors/cs0544.cs b/mcs/errors/cs0544.cs
new file mode 100644
index 00000000000..25905fea9d9
--- /dev/null
+++ b/mcs/errors/cs0544.cs
@@ -0,0 +1,11 @@
+// cs0544.cs: 'DerivedClass.value' : cannot override; 'BaseClass.value' is not a property
+// Line: 9
+
+class BaseClass {
+ protected int value;
+}
+
+class DerivedClass: BaseClass {
+ protected override int value { get {} }
+}
+
diff --git a/mcs/errors/cs0545.cs b/mcs/errors/cs0545.cs
new file mode 100644
index 00000000000..4f95aa4f91f
--- /dev/null
+++ b/mcs/errors/cs0545.cs
@@ -0,0 +1,11 @@
+// cs0545.cs: 'DerivedClass.Value.get' : cannot override because 'BaseClass.Value' does not have an overridable get accessor
+// Line: 9
+
+abstract class BaseClass {
+ protected abstract int Value { set; }
+}
+
+class DerivedClass: BaseClass {
+ protected override int Value { get {} set {} }
+}
+
diff --git a/mcs/errors/cs0546.cs b/mcs/errors/cs0546.cs
new file mode 100644
index 00000000000..0514d64ad64
--- /dev/null
+++ b/mcs/errors/cs0546.cs
@@ -0,0 +1,11 @@
+// cs0546.cs: 'DerivedClass.Value.set' : cannot override because 'BaseClass.Value' does not have an overridable set accessor
+// Line: 9
+
+abstract class BaseClass {
+ protected abstract int Value { get; }
+}
+
+class DerivedClass: BaseClass {
+ protected override int Value { get {} set {} }
+}
+
diff --git a/mcs/errors/cs0547.cs b/mcs/errors/cs0547.cs
new file mode 100644
index 00000000000..b58f4b3f971
--- /dev/null
+++ b/mcs/errors/cs0547.cs
@@ -0,0 +1,9 @@
+// cs0547.cs: 'PropertyClass.Value' : property or indexer cannot have void type
+// Line: 5
+
+class PropertyClass {
+ public void Value { get {}
+ }
+}
+
+
diff --git a/mcs/errors/cs0548.cs b/mcs/errors/cs0548.cs
new file mode 100644
index 00000000000..0620b8938ec
--- /dev/null
+++ b/mcs/errors/cs0548.cs
@@ -0,0 +1,9 @@
+// cs0548.cs: 'PropertyClass.Value' : property or indexer must have at least one accessor
+// Line: 5
+
+class PropertyClass {
+ public int Value {
+ }
+}
+
+
diff --git a/mcs/errors/cs0549.cs b/mcs/errors/cs0549.cs
new file mode 100644
index 00000000000..2ae30a39c0e
--- /dev/null
+++ b/mcs/errors/cs0549.cs
@@ -0,0 +1,9 @@
+// cs0549.cs: 'SealedClass.Foo()' is a new virtual member in sealed class 'SealedClass'
+// Line: 5
+
+sealed class SealedClass {
+ protected virtual void Foo() {
+ }
+}
+
+
diff --git a/mcs/errors/cs0550.cs b/mcs/errors/cs0550.cs
new file mode 100644
index 00000000000..e02dc7d5389
--- /dev/null
+++ b/mcs/errors/cs0550.cs
@@ -0,0 +1,17 @@
+// cs0550.cs: 'PropertyClass.PropertyInterface.Value.set' adds an accessor not found in interface member 'PropertyInterface.Value'
+// Line: 13
+
+interface PropertyInterface {
+ int Value { get; }
+}
+
+public class PropertyClass: PropertyInterface {
+ int PropertyInterface.Value {
+ get {
+ return 0;
+ }
+ set { }
+ }
+}
+
+
diff --git a/mcs/errors/cs0551.cs b/mcs/errors/cs0551.cs
new file mode 100644
index 00000000000..38884615f61
--- /dev/null
+++ b/mcs/errors/cs0551.cs
@@ -0,0 +1,16 @@
+// cs0551.cs: Explicit interface implementation 'PropertyClass.PropertyInterface.Value' is missing accessor 'PropertyInterface.Value.set'
+// Line: 9
+
+interface PropertyInterface {
+ int Value { get; set; }
+}
+
+public class PropertyClass: PropertyInterface {
+ int PropertyInterface.Value {
+ get {
+ return 0;
+ }
+ }
+}
+
+
diff --git a/mcs/errors/cs0553.cs b/mcs/errors/cs0553.cs
new file mode 100644
index 00000000000..eb2b91c540d
--- /dev/null
+++ b/mcs/errors/cs0553.cs
@@ -0,0 +1,12 @@
+// cs0553.cs: 'BaseClass(DerivedClass)' : user defined conversion to/from base class
+// Line: 8
+
+class BaseClass {
+}
+
+class DerivedClass: BaseClass {
+ public static implicit operator BaseClass(DerivedClass value) {
+ return new BaseClass();
+ }
+}
+
diff --git a/mcs/errors/cs0554.cs b/mcs/errors/cs0554.cs
new file mode 100644
index 00000000000..1c7b7757f7b
--- /dev/null
+++ b/mcs/errors/cs0554.cs
@@ -0,0 +1,12 @@
+// cs0554.cs: 'BaseClass.implicit operator BaseClass(DerivedClass)' : user defined conversion to/from derived class
+// Line: 5
+
+class BaseClass {
+ public static implicit operator BaseClass(DerivedClass value) {
+ return new BaseClass();
+ }
+}
+
+class DerivedClass: BaseClass {
+}
+
diff --git a/mcs/errors/cs0557.cs b/mcs/errors/cs0557.cs
new file mode 100644
index 00000000000..89784be5714
--- /dev/null
+++ b/mcs/errors/cs0557.cs
@@ -0,0 +1,12 @@
+// cs0557.cs: Duplicate user-defined conversion in class 'SampleClass'
+// Line: 5
+
+class SampleClass {
+ public static implicit operator bool (SampleClass value) {
+ return true;
+ }
+
+ public static implicit operator bool (SampleClass value) {
+ return true;
+ }
+}
diff --git a/mcs/errors/cs0558.cs b/mcs/errors/cs0558.cs
new file mode 100644
index 00000000000..6b0dc3ad3e3
--- /dev/null
+++ b/mcs/errors/cs0558.cs
@@ -0,0 +1,8 @@
+// cs0558.cs: User-defined operator 'SampleClass.implicit operator bool(SampleClass)' must be declared static and public
+// Line: 5
+
+class SampleClass {
+ static implicit operator bool (SampleClass value) {
+ return true;
+ }
+}
diff --git a/mcs/errors/cs0559.cs b/mcs/errors/cs0559.cs
new file mode 100644
index 00000000000..78d8580f109
--- /dev/null
+++ b/mcs/errors/cs0559.cs
@@ -0,0 +1,8 @@
+// cs0559.cs: The parameter and return type for ++ or — operator must be the containing type
+// Line: 5
+
+class SampleClass {
+ public static SampleClass operator ++ (int value) {
+ return new SampleClass();
+ }
+}
diff --git a/mcs/errors/cs0560.cs b/mcs/errors/cs0560.cs
new file mode 100644
index 00000000000..0b4e98b2e0c
--- /dev/null
+++ b/mcs/errors/cs0560.cs
@@ -0,0 +1,28 @@
+// cs0560.cs: Accessor 'ErrorClass.Value.get' : cannot override 'BaseClass.Value.get' because it is hidden by 'DerivedClass.get_Value()'
+// Line: 22
+
+class BaseClass {
+ protected virtual int Value {
+ get {
+ return 0;
+ }
+ set { }
+ }
+}
+
+abstract class DerivedClass: BaseClass {
+ protected new int get_Value () {
+ return 1;
+ }
+}
+
+
+class ErrorClass: DerivedClass {
+ protected override int Value {
+ get {
+ return 0;
+ }
+ set { }
+ }
+}
+
diff --git a/mcs/errors/cs0561.cs b/mcs/errors/cs0561.cs
new file mode 100644
index 00000000000..ecca1cafb31
--- /dev/null
+++ b/mcs/errors/cs0561.cs
@@ -0,0 +1,16 @@
+// cs0561.cs: 'DerivedClass.get_Value()' : cannot override 'BaseClass.Value.get' because it is a special compiler-generated method
+// Line: 13
+
+class BaseClass {
+ protected virtual int Value {
+ get {
+ return 0;
+ }
+ }
+}
+
+class DerivedClass: BaseClass {
+ protected override int get_Value () {
+ return 1;
+ }
+}
diff --git a/mcs/errors/cs0562.cs b/mcs/errors/cs0562.cs
new file mode 100644
index 00000000000..f8ba8032d32
--- /dev/null
+++ b/mcs/errors/cs0562.cs
@@ -0,0 +1,8 @@
+// cs0562.cs: The parameter of a unary operator must be the containing type
+// Line: 5
+
+class SampleClass {
+ public static SampleClass operator - (int value) {
+ return new SampleClass();
+ }
+}
diff --git a/mcs/errors/cs0564.cs b/mcs/errors/cs0564.cs
new file mode 100644
index 00000000000..a9a818e07bc
--- /dev/null
+++ b/mcs/errors/cs0564.cs
@@ -0,0 +1,8 @@
+// cs0564.cs: Overloaded shift operator must have the type of the first operand be the containing type, and the type of the second operand must be int
+// Line: 5
+
+class SampleClass {
+ public static int operator << (SampleClass value, SampleClass count) {
+ return 0;
+ }
+}
diff --git a/mcs/errors/cs0567.cs b/mcs/errors/cs0567.cs
new file mode 100644
index 00000000000..e9821c88786
--- /dev/null
+++ b/mcs/errors/cs0567.cs
@@ -0,0 +1,8 @@
+// cs0567.cs: Interfaces cannot contain operators
+// Line: 5
+
+interface Interface {
+ bool operator == (int a, int b);
+}
+
+
diff --git a/mcs/errors/cs0571.cs b/mcs/errors/cs0571.cs
new file mode 100644
index 00000000000..1b719f10f04
--- /dev/null
+++ b/mcs/errors/cs0571.cs
@@ -0,0 +1,14 @@
+// cs0571.cs: 'MainClass.Value.get' : cannot explicitly call operator or accessor
+// Line: 12
+
+class MainClass {
+ static int Value {
+ get {
+ return 1;
+ }
+ }
+
+ public static void Main() {
+ int value = get_Value();
+ }
+}
diff --git a/mcs/errors/cs0576.cs b/mcs/errors/cs0576.cs
new file mode 100644
index 00000000000..32febd72ede
--- /dev/null
+++ b/mcs/errors/cs0576.cs
@@ -0,0 +1,10 @@
+// cs0576.cs: Namespace already contains a definition for 'System'
+// Line: 5
+
+using System;
+using System = System;
+
+class MainClass {
+ public static void Main() {
+ }
+}
diff --git a/mcs/errors/cs0577.cs b/mcs/errors/cs0577.cs
new file mode 100644
index 00000000000..d53a2972d5a
--- /dev/null
+++ b/mcs/errors/cs0577.cs
@@ -0,0 +1,9 @@
+// cs0577.cs: Conditional not valid on 'MainClass.MainClass()' because it is a constructor, destructor, operator, or explicit interface implementation
+// Line: 5
+
+class MainClass {
+ [System.Diagnostics.Conditional("DEBUG")] public MainClass () {}
+
+ public static void Main () {}
+}
+
diff --git a/mcs/errors/cs0578.cs b/mcs/errors/cs0578.cs
new file mode 100644
index 00000000000..6557a01c44e
--- /dev/null
+++ b/mcs/errors/cs0578.cs
@@ -0,0 +1,11 @@
+// cs0578.cs: Conditional not valid on 'MainClass.Foo()' because its return type is not void
+// Line: 10
+
+class MainClass {
+ [System.Diagnostics.Conditional("DEBUG")] bool Foo() {
+ return false;
+ }
+
+ public static void Main () {}
+}
+
diff --git a/mcs/errors/cs0580.cs b/mcs/errors/cs0580.cs
new file mode 100644
index 00000000000..f7553e88144
--- /dev/null
+++ b/mcs/errors/cs0580.cs
@@ -0,0 +1,14 @@
+// cs0580.cs: Too many unnamed arguments to attribute 'System.Runtime.CompilerServices.IndexerName'
+// Line: 5
+
+class MainClass {
+ [System.Runtime.CompilerServices.IndexerName("Index", "", "", "", "")]
+ int this [int index] {
+ get {
+ return 0;
+ }
+ }
+
+ public static void Main () {}
+}
+
diff --git a/mcs/errors/cs0582.cs b/mcs/errors/cs0582.cs
new file mode 100644
index 00000000000..fb5efb518a2
--- /dev/null
+++ b/mcs/errors/cs0582.cs
@@ -0,0 +1,8 @@
+// cs0582.cs: Conditional not valid on interface members
+// Line: 5
+
+interface Interface {
+ [System.Diagnostics.ConditionalAttribute("DEBUG")]
+ void Method ();
+}
+
diff --git a/mcs/errors/cs0590.cs b/mcs/errors/cs0590.cs
new file mode 100644
index 00000000000..2030b59aa8a
--- /dev/null
+++ b/mcs/errors/cs0590.cs
@@ -0,0 +1,8 @@
+// cs0590.cs: User-defined operators cannot return void
+// Line: 5
+
+class SampleClass {
+ public static void operator - (SampleClass value) {
+ return new SampleClass();
+ }
+}
diff --git a/mcs/errors/cs0591.cs b/mcs/errors/cs0591.cs
new file mode 100644
index 00000000000..58abf1007cb
--- /dev/null
+++ b/mcs/errors/cs0591.cs
@@ -0,0 +1,10 @@
+// cs0591.cs: Invalid value for argument to 'System.AttributeUsage' attribute
+// Line: 4
+
+[System.AttributeUsage(0)]
+class ClassMain {
+
+ public static void Main () {
+ }
+}
+
diff --git a/mcs/errors/cs0609.cs b/mcs/errors/cs0609.cs
new file mode 100644
index 00000000000..45832f243b0
--- /dev/null
+++ b/mcs/errors/cs0609.cs
@@ -0,0 +1,23 @@
+// cs0609.cs: Cannot set the name attribute on an indexer marked override
+// Line: 14
+using System.Runtime.CompilerServices;
+
+class BaseClass {
+ protected virtual bool this[int index] {
+ get {
+ return true;
+ }
+ }
+}
+
+class DerivedClass: BaseClass {
+ [IndexerName("Error")]
+ protected override int this[int index] {
+ get {
+ return false;
+ }
+ }
+
+ static void Main() {}
+}
+
diff --git a/mcs/errors/cs0610-2.cs b/mcs/errors/cs0610-2.cs
new file mode 100644
index 00000000000..84adbbe94b1
--- /dev/null
+++ b/mcs/errors/cs0610-2.cs
@@ -0,0 +1,13 @@
+// cs0610.cs: Field or property cannot be of type 'System.TypedReference'
+// Line: 5
+
+public class Sample {
+ System.TypedReference reference {
+ get {
+ return null;
+ }
+ }
+}
+
+
+
diff --git a/mcs/errors/cs0610.cs b/mcs/errors/cs0610.cs
new file mode 100644
index 00000000000..0153f6e80b0
--- /dev/null
+++ b/mcs/errors/cs0610.cs
@@ -0,0 +1,9 @@
+// cs0610.cs: Field or property cannot be of type 'System.ArgIterator'
+// Line: 5
+
+public class Sample {
+ System.ArgIterator arg;
+}
+
+
+
diff --git a/mcs/errors/cs0611-2.cs b/mcs/errors/cs0611-2.cs
new file mode 100644
index 00000000000..777e43828c1
--- /dev/null
+++ b/mcs/errors/cs0611-2.cs
@@ -0,0 +1,13 @@
+// cs0611.cs: Array elements cannot be of type 'System.TypedReference'
+// Line: 5
+
+public class Sample {
+ System.TypedReference[] references {
+ get {
+ return null;
+ }
+ }
+}
+
+
+
diff --git a/mcs/errors/cs0611.cs b/mcs/errors/cs0611.cs
new file mode 100644
index 00000000000..29394d51fcc
--- /dev/null
+++ b/mcs/errors/cs0611.cs
@@ -0,0 +1,9 @@
+// cs0611.cs: Array elements cannot be of type 'System.ArgIterator'
+// Line: 5
+
+public class Sample {
+ System.ArgIterator[] arg;
+}
+
+
+
diff --git a/mcs/errors/cs0619.cs b/mcs/errors/cs0619.cs
new file mode 100644
index 00000000000..b5954df0fd6
--- /dev/null
+++ b/mcs/errors/cs0619.cs
@@ -0,0 +1,20 @@
+// cs0619.cs: 'MethodError()' is obsolete: 'Do not use it'
+// Line: 17
+
+class Obsolete {
+ [System.Obsolete]
+ public static void MethodWarning() {
+ }
+
+ [System.Obsolete("Do not use it.", true)]
+ public static void MethodError() {
+ }
+}
+
+class MainClass {
+ public static void Main () {
+ Obsolete.MethodWarning();
+ Obsolete.MethodError();
+ }
+}
+
diff --git a/mcs/errors/cs0676-2.cs b/mcs/errors/cs0676-2.cs
index 6f1d0bbf5e8..b35d5920e70 100644
--- a/mcs/errors/cs0676-2.cs
+++ b/mcs/errors/cs0676-2.cs
@@ -1,3 +1,5 @@
+// Compiler options: -unsafe
+
unsafe class XX {
static volatile int j;
diff --git a/mcs/errors/cs0676.cs b/mcs/errors/cs0676.cs
index b2f8ad7c846..416391df55c 100644
--- a/mcs/errors/cs0676.cs
+++ b/mcs/errors/cs0676.cs
@@ -1,3 +1,5 @@
+// Compiler options: -unsafe
+
unsafe class X {
static volatile int j;
diff --git a/mcs/errors/cs1900.cs b/mcs/errors/cs1900.cs
new file mode 100644
index 00000000000..f8bdc539c27
--- /dev/null
+++ b/mcs/errors/cs1900.cs
@@ -0,0 +1,8 @@
+// cs1900.cs: Warning level must be in the range 0-4
+// Line: 0
+// Compiler options: -warn:-1
+
+class ClassMain {
+ public static void Main () {}
+}
+
diff --git a/mcs/errors/cs1901.cs b/mcs/errors/cs1901.cs
new file mode 100644
index 00000000000..141523d03af
--- /dev/null
+++ b/mcs/errors/cs1901.cs
@@ -0,0 +1,8 @@
+// cs1901.cs: Conflicting options specified: Warning level 0; Treat warnings as errors
+// Line: 0
+// Compiler options: -warn:0 -warnaserror
+
+class ClassMain {
+ public static void Main () {}
+}
+
diff --git a/mcs/errors/cs1904.cs b/mcs/errors/cs1904.cs
new file mode 100644
index 00000000000..f92c29ff31f
--- /dev/null
+++ b/mcs/errors/cs1904.cs
@@ -0,0 +1,8 @@
+// cs1904.cs: '-1' is not a valid warning number
+// Line: 0
+// Compiler options: -nowarn:1,-1
+
+class ClassMain {
+ public static void Main () {}
+}
+
diff --git a/mcs/errors/cs2001.cs b/mcs/errors/cs2001.cs
new file mode 100644
index 00000000000..5b5e34f351b
--- /dev/null
+++ b/mcs/errors/cs2001.cs
@@ -0,0 +1,3 @@
+// cs2001.cs: Source file 'notexisting.cs' could not be found
+// Line: 0
+// Compiler options: notexisting.cs
diff --git a/mcs/errors/cs2007.cs b/mcs/errors/cs2007.cs
new file mode 100644
index 00000000000..8e86366ce66
--- /dev/null
+++ b/mcs/errors/cs2007.cs
@@ -0,0 +1,3 @@
+// cs2007.cs: Unrecognized command-line option: '-wrong-option'
+// Line: 0
+// Compiler options: -wrong-option
diff --git a/mcs/errors/cs2016.cs b/mcs/errors/cs2016.cs
new file mode 100644
index 00000000000..591e407b84c
--- /dev/null
+++ b/mcs/errors/cs2016.cs
@@ -0,0 +1,3 @@
+// cs2016.cs: Code page 'XX' is invalid or not installed
+// Line: 0
+// Compiler options: -codepage:XX
diff --git a/mcs/errors/cs2017.cs b/mcs/errors/cs2017.cs
new file mode 100644
index 00000000000..50364a26867
--- /dev/null
+++ b/mcs/errors/cs2017.cs
@@ -0,0 +1,8 @@
+// cs2017.cs: Cannot specify -main if building a module or library
+// Line: 0
+// Compiler options: -main:ClassMain -target:library
+
+class ClassMain {
+ public static void Main () {}
+}
+
diff --git a/mcs/errors/cs2019.cs b/mcs/errors/cs2019.cs
new file mode 100644
index 00000000000..7abaf6c4323
--- /dev/null
+++ b/mcs/errors/cs2019.cs
@@ -0,0 +1,8 @@
+// cs2019.cs: Invalid target type for -target: must specify 'exe', 'winexe', 'library', or 'module'
+// Line: 0
+// Compiler options: -target:unknown
+
+class ClassMain {
+ public static void Main () {}
+}
+
diff --git a/mcs/errors/cs8200.cs b/mcs/errors/cs8200.cs
new file mode 100644
index 00000000000..d9819f677a1
--- /dev/null
+++ b/mcs/errors/cs8200.cs
@@ -0,0 +1,12 @@
+// cs8200.cs: Do not allow type-parameter-constraint-clauses when
+// there is no type-parameter list
+//
+using System.Collections;
+class Dingus where T : IEnumerable {
+}
+
+class D {
+ static void Main ()
+ {
+ }
+}
diff --git a/mcs/errors/cs8212.cs b/mcs/errors/cs8212.cs
new file mode 100644
index 00000000000..14477fe1118
--- /dev/null
+++ b/mcs/errors/cs8212.cs
@@ -0,0 +1,26 @@
+// cs8212.cs: Array creation present on attribute, but array is not initialized
+// Line: 14
+using System;
+using System.Reflection;
+
+[AttributeUsage (AttributeTargets.All)]
+public class MineAttribute : Attribute {
+ public MineAttribute (Type [] t)
+ {
+ }
+}
+
+
+[Mine(new Type [2])]
+public class Foo {
+ public static int Main ()
+ {
+ return 0;
+ }
+}
+
+
+
+
+
+
diff --git a/mcs/errors/cs8213.cs b/mcs/errors/cs8213.cs
new file mode 100644
index 00000000000..c67e23ee52d
--- /dev/null
+++ b/mcs/errors/cs8213.cs
@@ -0,0 +1,6 @@
+// cs8213.cs: This feature requires MCS v2 support (pass the -v2 flag to mcs)
+// Line: 3
+class X<V> : V
+{
+}
+
diff --git a/mcs/gmcs/ChangeLog b/mcs/gmcs/ChangeLog
index 52857101a30..c418a8d8252 100755
--- a/mcs/gmcs/ChangeLog
+++ b/mcs/gmcs/ChangeLog
@@ -1,3 +1,44 @@
+2003-11-18 Miguel de Icaza <miguel@ximian.com>
+
+ * expression.cs (Invocation.VerifyArgumentsCompat): Remove
+ debugging message.
+
+ (SizeOf.DoResolve): assign the `type_queried' field. This gets
+ corlib to compile.
+
+2003-11-16 Martin Baulig <martin@ximian.com>
+
+ * codegen.cs (EmitContext.IsGeneric): Removed.
+
+ * ecore.cs (SimpleName.ResolveAsTypeStep): Always call
+ ResolveGeneric() on the DeclSpace.
+
+2003-11-16 Martin Baulig <martin@ximian.com>
+
+ * generic.cs (TypeArguments.Resolve):
+ `Expression.ResolveAsTypeTerminal()' returns a TypeExpr; call
+ `ResolveType()' on it to get the Type.
+
+2003-11-15 Martin Baulig <martin@ximian.com>
+
+ * generic.cs (ConstructedType.GetInterfaces): Override this.
+
+2003-11-14 Martin Baulig <martin@ximian.com>
+
+ * interface.cs (Interface.DefineType): Define all type parameters
+ before adding the interfaces we inherit.
+
+2003-11-11 Martin Baulig <martin@ximian.com>
+
+ * generic.cs (ConstructedType.ResolveType): Always call
+ `gt.BindGenericParameters (atypes)'; also if `args.HasTypeArguments'.
+
+2003-11-10 Martin Baulig <martin@ximian.com>
+
+ * typemanager.cs (TypeManager.ResolveExpressionTypes): Removed.
+ (TypeManager.InitCoreTypes): Initialize them here, but instead of
+ calling `ResolveType()' on them, directly assign their `Type'.
+
2003-11-08 Martin Baulig <martin@ximian.com>
* generic.cs (ConstructedType): Override `IsClass' etc.
diff --git a/mcs/gmcs/codegen.cs b/mcs/gmcs/codegen.cs
index df4a0f40552..a8c6ca296da 100755
--- a/mcs/gmcs/codegen.cs
+++ b/mcs/gmcs/codegen.cs
@@ -321,12 +321,6 @@ namespace Mono.CSharp {
/// </summary>
public bool InEnumContext;
- /// <summary>
- /// If our type container, or the method we are generating code
- /// for is Generic
- /// </summary>
- public bool IsGeneric;
-
protected Stack FlowStack;
public EmitContext (DeclSpace parent, DeclSpace ds, Location l, ILGenerator ig,
@@ -361,11 +355,6 @@ namespace Mono.CSharp {
if (ReturnType == TypeManager.void_type)
ReturnType = null;
-
- //
- // We should also set it if the method is generic
- //
- IsGeneric = ds.IsGeneric || ((code_flags & Modifiers.METHOD_GENERIC) != 0);
}
public EmitContext (TypeContainer tc, Location l, ILGenerator ig,
diff --git a/mcs/gmcs/decl.cs b/mcs/gmcs/decl.cs
index 8cf9f1cc922..b657a35ece4 100755
--- a/mcs/gmcs/decl.cs
+++ b/mcs/gmcs/decl.cs
@@ -316,8 +316,6 @@ namespace Mono.CSharp {
type_resolve_ec = new EmitContext (parent, this, loc, null, null, ModFlags, false);
type_resolve_ec.ResolvingTypeTree = true;
- TypeManager.ResolveExpressionTypes (type_resolve_ec);
-
return type_resolve_ec;
}
diff --git a/mcs/gmcs/ecore.cs b/mcs/gmcs/ecore.cs
index e760942258f..6cf243f231d 100755
--- a/mcs/gmcs/ecore.cs
+++ b/mcs/gmcs/ecore.cs
@@ -1984,12 +1984,9 @@ namespace Mono.CSharp {
return new SimpleName (alias_value, loc);
}
- if (ec.IsGeneric){
- TypeParameterExpr generic_type = ds.LookupGeneric (Name, loc);
-
- if (generic_type != null)
- return generic_type.ResolveAsTypeTerminal (ec);
- }
+ TypeParameterExpr generic_type = ds.LookupGeneric (Name, loc);
+ if (generic_type != null)
+ return generic_type.ResolveAsTypeTerminal (ec);
//
// Stage 2: Lookup up if we are an alias to a type
diff --git a/mcs/gmcs/expression.cs b/mcs/gmcs/expression.cs
index bad0d226c4b..d298d0a475b 100755
--- a/mcs/gmcs/expression.cs
+++ b/mcs/gmcs/expression.cs
@@ -4767,11 +4767,6 @@ namespace Mono.CSharp {
conv = Convert.ImplicitConversion (ec, a_expr, parameter_type, loc);
if (conv == null) {
- Console.WriteLine ("GAA: {0} {1} {2}",
- pd.ParameterType (j),
- pd.ParameterType (j).Assembly == CodeGen.AssemblyBuilder,
- method.DeclaringType.Assembly == CodeGen.AssemblyBuilder);
-
if (!Location.IsNull (loc))
Error_InvalidArguments (
loc, j, method, delegate_type,
@@ -6529,7 +6524,8 @@ namespace Mono.CSharp {
((TypeParameterExpr)QueriedType).Error_CannotUseAsUnmanagedType (loc);
return null;
}
-
+
+ type_queried = QueriedType.Type;
if (!TypeManager.IsUnmanagedType (type_queried)){
Report.Error (208, loc, "Cannot take the size of an unmanaged type (" + TypeManager.CSharpName (type_queried) + ")");
return null;
diff --git a/mcs/gmcs/generic.cs b/mcs/gmcs/generic.cs
index b64fd4193d7..1d6668370ee 100644
--- a/mcs/gmcs/generic.cs
+++ b/mcs/gmcs/generic.cs
@@ -271,7 +271,7 @@ namespace Mono.CSharp {
atypes = new Type [count];
for (int i = 0; i < count; i++){
- Expression e = ((Expression)args [i]).ResolveAsTypeTerminal (ec);
+ TypeExpr e = ((Expression)args [i]).ResolveAsTypeTerminal (ec);
if (e == null) {
ok = false;
continue;
@@ -279,7 +279,10 @@ namespace Mono.CSharp {
if (e is TypeParameterExpr)
has_type_args = true;
args [i] = e;
- atypes [i] = e.Type;
+ atypes [i] = e.ResolveType (ec);
+
+ if (atypes [i] == null)
+ ok = false;
}
return ok;
}
@@ -342,7 +345,7 @@ namespace Mono.CSharp {
// First, resolve the generic type.
//
SimpleName sn = new SimpleName (name, loc);
- Expression resolved = sn.ResolveAsTypeStep (ec);
+ TypeExpr resolved = sn.ResolveAsTypeTerminal (ec);
if (resolved == null)
return null;
@@ -361,8 +364,11 @@ namespace Mono.CSharp {
//
// Resolve the arguments.
//
- if (args.Resolve (ec) == false)
+ if (args.Resolve (ec) == false) {
+ Report.Error (-220, loc, "Failed to resolve constructed type `{0}'",
+ full_name);
return null;
+ }
gen_params = gt.GetGenericArguments ();
atypes = args.Arguments;
@@ -374,11 +380,6 @@ namespace Mono.CSharp {
return null;
}
- if (args.HasTypeArguments) {
- type = gt;
- return type;
- }
-
for (int i = 0; i < gen_params.Length; i++) {
if (!CheckConstraints (i))
return null;
@@ -417,6 +418,12 @@ namespace Mono.CSharp {
get { return gt.IsSealed; }
}
+ public override TypeExpr[] GetInterfaces ()
+ {
+ TypeExpr[] ifaces = TypeManager.GetInterfaces (gt);
+ return ifaces;
+ }
+
public override string Name {
get {
return full_name;
diff --git a/mcs/gmcs/interface.cs b/mcs/gmcs/interface.cs
index fdd49336cc5..92821a5e8b7 100755
--- a/mcs/gmcs/interface.cs
+++ b/mcs/gmcs/interface.cs
@@ -775,6 +775,11 @@ namespace Mono.CSharp {
tc.RegisterOrder (this);
}
+ if (IsGeneric) {
+ foreach (TypeParameter type_param in TypeParameters)
+ type_param.Define (TypeBuilder);
+ }
+
if (ifaces != null) {
foreach (TypeExpr iface in ifaces) {
Type itype = iface.ResolveType (ec);
@@ -782,11 +787,6 @@ namespace Mono.CSharp {
}
}
- if (IsGeneric) {
- foreach (TypeParameter type_param in TypeParameters)
- type_param.Define (TypeBuilder);
- }
-
TypeManager.AddUserInterface (Name, TypeBuilder, this, ifaces);
InTransit = false;
diff --git a/mcs/gmcs/typemanager.cs b/mcs/gmcs/typemanager.cs
index 44b7d5ca525..f8868ff207b 100755
--- a/mcs/gmcs/typemanager.cs
+++ b/mcs/gmcs/typemanager.cs
@@ -311,29 +311,6 @@ public class TypeManager {
system_valuetype_expr = new TypeLookupExpression ("System.ValueType");
}
- public static void ResolveExpressionTypes (EmitContext ec)
- {
- system_object_expr.ResolveType (ec);
- system_string_expr.ResolveType (ec);
- system_boolean_expr.ResolveType (ec);
- system_decimal_expr.ResolveType (ec);
- system_single_expr.ResolveType (ec);
- system_double_expr.ResolveType (ec);
- system_sbyte_expr.ResolveType (ec);
- system_byte_expr.ResolveType (ec);
- system_int16_expr.ResolveType (ec);
- system_uint16_expr.ResolveType (ec);
- system_int32_expr.ResolveType (ec);
- system_uint32_expr.ResolveType (ec);
- system_int64_expr.ResolveType (ec);
- system_uint64_expr.ResolveType (ec);
- system_char_expr.ResolveType (ec);
- system_void_expr.ResolveType (ec);
- system_asynccallback_expr.ResolveType (ec);
- system_iasyncresult_expr.ResolveType (ec);
- system_valuetype_expr.ResolveType (ec);
- }
-
static TypeManager ()
{
assemblies = new Assembly [0];
@@ -1046,6 +1023,26 @@ public class TypeManager {
set_corlib_type_builders.Invoke (CodeGen.AssemblyBuilder, args);
}
}
+
+ system_object_expr.Type = object_type;
+ system_string_expr.Type = string_type;
+ system_boolean_expr.Type = bool_type;
+ system_decimal_expr.Type = decimal_type;
+ system_single_expr.Type = float_type;
+ system_double_expr.Type = double_type;
+ system_sbyte_expr.Type = sbyte_type;
+ system_byte_expr.Type = byte_type;
+ system_int16_expr.Type = short_type;
+ system_uint16_expr.Type = ushort_type;
+ system_int32_expr.Type = int32_type;
+ system_uint32_expr.Type = uint32_type;
+ system_int64_expr.Type = int64_type;
+ system_uint64_expr.Type = uint64_type;
+ system_char_expr.Type = char_type;
+ system_void_expr.Type = void_type;
+ system_asynccallback_expr.Type = asynccallback_type;
+ system_iasyncresult_expr.Type = iasyncresult_type;
+ system_valuetype_expr.Type = value_type;
}
//
diff --git a/mcs/ilasm/ChangeLog b/mcs/ilasm/ChangeLog
index b459e4929c7..1e331d728b5 100644
--- a/mcs/ilasm/ChangeLog
+++ b/mcs/ilasm/ChangeLog
@@ -1,3 +1,13 @@
+2003-11-16 Jackson Harper <jackson@ximian.com>
+
+ * Driver.cs: Give the parser an instance of the stream reader so
+ it can get the streams encoding.
+
+2003-11-16 Jackson Harper <jackson@ximian.com>
+
+ * Driver.cs: If an arg isn't a switch and starts with a / add it
+ as a file to be compiled. This fixes bug #51041.
+
2003-10-28 Jackson Harper <jackson@ximian.com>
* Driver.cs: Stub some command line args to maintain compatibility
diff --git a/mcs/ilasm/Driver.cs b/mcs/ilasm/Driver.cs
index 479f59a0d4e..6121796e2ff 100644
--- a/mcs/ilasm/Driver.cs
+++ b/mcs/ilasm/Driver.cs
@@ -104,7 +104,7 @@ namespace Mono.ILASM {
return;
}
- ILParser parser = new ILParser (codegen);
+ ILParser parser = new ILParser (codegen, reader);
try {
if (show_parser)
parser.yyparse (new ScannerAdapter (scanner),
@@ -204,6 +204,11 @@ namespace Mono.ILASM {
break;
Version ();
break;
+ default:
+ if (str [0] == '-')
+ break;
+ il_file_list.Add (str);
+ break;
}
}
}
diff --git a/mcs/ilasm/codegen/ChangeLog b/mcs/ilasm/codegen/ChangeLog
index 205cea0cfbe..c6510d19f3b 100644
--- a/mcs/ilasm/codegen/ChangeLog
+++ b/mcs/ilasm/codegen/ChangeLog
@@ -1,3 +1,12 @@
+2003-11-18 Jackson Harper <jackson@ximian.com>
+
+ * MethodDef.cs: Add support for .zeroinit. This is just another
+ way of initializing locals.
+
+2003-11-17 Jackson Harper <jackson@ximian.com>
+
+ * LdstrInstr.cs: Allow strings to be created as bytearrays.
+
2003-10-28 Jackson Harper <jackson@ximian.com>
* ExternTable.cs: Revert back to resolving value and class types
diff --git a/mcs/ilasm/codegen/LdstrInstr.cs b/mcs/ilasm/codegen/LdstrInstr.cs
index fb7afd60529..b27b50ab80e 100644
--- a/mcs/ilasm/codegen/LdstrInstr.cs
+++ b/mcs/ilasm/codegen/LdstrInstr.cs
@@ -15,16 +15,25 @@ namespace Mono.ILASM {
public class LdstrInstr : IInstr {
private string operand;
-
+ private byte[] b_operand;
+
public LdstrInstr (string operand)
{
this.operand = operand;
}
+ public LdstrInstr (byte[] b_operand)
+ {
+ this.b_operand = b_operand;
+ }
+
public void Emit (CodeGen code_gen, MethodDef meth,
PEAPI.CILInstructions cil)
{
- cil.ldstr (operand);
+ if (operand != null)
+ cil.ldstr (operand);
+ else
+ cil.ldstr (b_operand);
}
}
diff --git a/mcs/ilasm/codegen/MethodDef.cs b/mcs/ilasm/codegen/MethodDef.cs
index 393a0b4c6bd..3c53943aa5c 100644
--- a/mcs/ilasm/codegen/MethodDef.cs
+++ b/mcs/ilasm/codegen/MethodDef.cs
@@ -38,6 +38,7 @@ namespace Mono.ILASM {
private ArrayList label_list;
private PEAPI.MethodDef methoddef;
private bool entry_point;
+ private bool zero_init;
private bool is_resolved;
private bool is_defined;
private ArrayList local_list;
@@ -70,6 +71,7 @@ namespace Mono.ILASM {
named_param_table = new Hashtable ();
entry_point = false;
+ zero_init = false;
init_locals = false;
max_stack = -1;
pinvoke_info = false;
@@ -191,6 +193,11 @@ namespace Mono.ILASM {
entry_point = true;
}
+ public void ZeroInit ()
+ {
+ zero_init = true;
+ }
+
public void SetMaxStack (int max_stack)
{
this.max_stack = max_stack;
@@ -323,6 +330,9 @@ namespace Mono.ILASM {
if (code_gen.Report.ErrorCount > ec)
return;
+ if (zero_init)
+ init_locals = true;
+
methoddef.AddLocals (local_array, init_locals);
}
diff --git a/mcs/ilasm/parser/ChangeLog b/mcs/ilasm/parser/ChangeLog
index 6b56325bc55..223d240a708 100644
--- a/mcs/ilasm/parser/ChangeLog
+++ b/mcs/ilasm/parser/ChangeLog
@@ -1,3 +1,17 @@
+2003-11-18 Jackson Harper <jackson@ximian.com>
+
+ * ILParser.jay: Add zeroinit.
+
+2003-11-17 Jackson Harper <jackson@ximian.com>
+
+ * ILParser.jay: Create strings from byte arrays. Fix parsing of
+ bytes that are passed as INT64.
+
+2003-11-16 Jackson Harper <jackson@ximian.com>
+
+ * ILParser.jay: Handle string instructions that are given byte
+ arrays. This fixes bug #51039.
+
2003-10-28 Jackson Harper <jackson@ximian.com>
* ILParser.jay: Use the ExternTable to create external type
diff --git a/mcs/ilasm/parser/ILParser.jay b/mcs/ilasm/parser/ILParser.jay
index cd998661d20..ea442215b4b 100644
--- a/mcs/ilasm/parser/ILParser.jay
+++ b/mcs/ilasm/parser/ILParser.jay
@@ -24,9 +24,11 @@ namespace Mono.ILASM {
private string pinvoke_mod;
private string pinvoke_meth;
private PEAPI.PInvokeAttr pinvoke_attr;
-
- public ILParser (CodeGen codegen) {
+ private StreamReader stream;
+
+ public ILParser (CodeGen codegen, StreamReader stream) {
this.codegen = codegen;
+ this.stream = stream;
}
public CodeGen CodeGen {
@@ -1638,6 +1640,9 @@ method_decl : D_EMITBYTE int32
codegen.CurrentMethodDef.EntryPoint ();
}
| D_ZEROINIT
+ {
+ codegen.CurrentMethodDef.ZeroInit ();
+ }
| D_EXPORT OPEN_BRACKET int32 CLOSE_BRACKET
| D_EXPORT OPEN_BRACKET int32 CLOSE_BRACKET K_AS id
| D_VTENTRY int32 COLON int32
@@ -1950,8 +1955,20 @@ instr : INSTR_NONE
if ((MiscInstr) $1 == MiscInstr.ldstr)
codegen.CurrentMethodDef.AddInstr (new LdstrInstr ((string) $2));
}
- | INSTR_STRING K_BYTEARRAY ASSIGN OPEN_PARENS bytes CLOSE_PARENS
- | INSTR_STRING K_BYTEARRAY OPEN_PARENS bytes CLOSE_PARENS // ****** ADDED
+ | INSTR_STRING K_BYTEARRAY ASSIGN OPEN_PARENS
+ bytes CLOSE_PARENS
+ {
+ byte[] bs = (byte[]) $5;
+ if ((MiscInstr) $1 == MiscInstr.ldstr)
+ codegen.CurrentMethodDef.AddInstr (new LdstrInstr (bs));
+ }
+ | INSTR_STRING K_BYTEARRAY OPEN_PARENS bytes
+ CLOSE_PARENS
+ {
+ byte[] bs = (byte[]) $4;
+ if ((MiscInstr) $1 == MiscInstr.ldstr)
+ codegen.CurrentMethodDef.AddInstr (new LdstrInstr (bs));
+ }
| INSTR_SIG call_conv type OPEN_PARENS type_list CLOSE_PARENS
{
ArrayList arg_list = (ArrayList) $5;
@@ -2455,8 +2472,13 @@ float64 : FLOAT64
}
;
-hexbyte : HEXBYTE
- | INT64 { $$ = Convert.ToByte ($1); }
+hexbyte : HEXBYTE { }
+ | INT64
+ {
+ long l = (long) $1;
+ byte b = Byte.Parse (l.ToString (), NumberStyles.HexNumber);
+ $$ = b;
+ }
| ID
{
$$ = Byte.Parse ((string) $1, NumberStyles.HexNumber);
diff --git a/mcs/mbas/AssemblyInfo.cs b/mcs/mbas/AssemblyInfo.cs
index df804e5623b..d1ddb04a952 100644
--- a/mcs/mbas/AssemblyInfo.cs
+++ b/mcs/mbas/AssemblyInfo.cs
@@ -56,7 +56,7 @@ using System.Runtime.CompilerServices;
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:
-[assembly: AssemblyVersion("0.28")]
+[assembly: AssemblyVersion("0.29")]
//
// In order to sign your assembly you must specify a key to use. Refer to the
diff --git a/mcs/mbas/ChangeLog b/mcs/mbas/ChangeLog
index 99e715864f6..faf5d868846 100644
--- a/mcs/mbas/ChangeLog
+++ b/mcs/mbas/ChangeLog
@@ -1,3 +1,21 @@
+2003/11/12 Rafael Teixeira <rafaelteixeirabr@hotmail.com>
+ * driver.cs : /imports option now is implemented
+ * mb-parser.jay: support for pre-imported namespaces (the default Microsoft.VisualBasic and those from /imports)
+
+2003/11/12 Rafael Teixeira <rafaelteixeirabr@hotmail.com>
+ * mb-tokenizer.cs : integer literal (Hex starts with &H not 0x), handle Octal literals (&O)
+ * handle unicode specialized double-quotes in string literals
+ * corrected some mishandling of conversions in numeric literals
+ * implemented support for char literals ("z"c)
+ * Makefile : verbose target uses verbose argument
+ * testmbas/WriteOK.vb: many tests for literals implemented
+ * literal.cs: correcting lack of a ShortLiteral class
+ * mb-parser.jay: removed support for unsigned int literals, added support for short int literals
+
+2003/11/10 Rafael Teixeira <rafaelteixeirabr@hotmail.com>
+ * *.cs, mb-parser.jay: Switched all from defining/using namespace Mono.CSharp to Mono.MonoBASIC
+ * location.cs: SymbolDocument now returns a SymbolDocumentWriter using the right (SymLanguageType.Basic) GUID
+
2003/10/17 Rafael Teixeira <rafaelteixeirabr@hotmail.com>
* genericparser.cs:
Don't print exception when a file is not found to be parsed
diff --git a/mcs/mbas/Makefile b/mcs/mbas/Makefile
index a1dc0c2e349..17cf83cc326 100644
--- a/mcs/mbas/Makefile
+++ b/mcs/mbas/Makefile
@@ -22,9 +22,9 @@ mb-parser.cs: mb-parser.jay
$(topdir)/jay/jay -ctv <$(topdir)/jay/skeleton.cs $< >$@
verbose: mbas.exe
- $(TEST_RUNTIME) ./mbas.exe --verbosegetoptions --stacktrace /libpath:../class/lib /r:Mono.GetOptions /r:System.Data,System.Windows.Forms --main WriteOK testmbas/WriteOK.vb testmbas/WriteOK2.mbs
+ $(TEST_RUNTIME) ./mbas.exe --verbosegetoptions --verbose --stacktrace /libpath:../class/lib /r:Mono.GetOptions /r:System.Data,System.Windows.Forms --main WriteOK testmbas/WriteOK.vb testmbas/WriteOK2.mbs
-testmbas/WriteOK.exe: mbas.exe
+testmbas/WriteOK.exe: mbas.exe testmbas/*.vb testmbas/*.mbs
$(TEST_RUNTIME) ./mbas.exe --stacktrace --verbosegetoptions /libpath:../class/lib /r:Mono.GetOptions /r:System.Data,System.Windows.Forms --main WriteOK testmbas/WriteOK.vb testmbas/WriteOK2.mbs
test-aspx: mbas.exe testmbas/aspx_temp.vb
diff --git a/mcs/mbas/argument.cs b/mcs/mbas/argument.cs
index 90ee46cc97d..518c15a355a 100644
--- a/mcs/mbas/argument.cs
+++ b/mcs/mbas/argument.cs
@@ -9,7 +9,7 @@
//
#define USE_OLD
-namespace Mono.CSharp {
+namespace Mono.MonoBASIC {
using System;
using System.Collections;
using System.Reflection;
@@ -64,7 +64,7 @@ namespace Mono.CSharp {
{
return (a.ArgType == AType.Ref ? "ref " :
(a.ArgType == AType.Out ? "out " : "")) +
- TypeManager.CSharpName (a.Expr.Type);
+ TypeManager.MonoBASIC_Name (a.Expr.Type);
}
public bool ResolveMethodGroup (EmitContext ec, Location loc)
diff --git a/mcs/mbas/assign.cs b/mcs/mbas/assign.cs
index aae7b634acf..76deb1fdde9 100644
--- a/mcs/mbas/assign.cs
+++ b/mcs/mbas/assign.cs
@@ -26,7 +26,7 @@ using System.Collections;
using System.Reflection;
using System.Reflection.Emit;
-namespace Mono.CSharp {
+namespace Mono.MonoBASIC {
/// <summary>
/// This interface is implemented by expressions that can be assigned to.
@@ -522,7 +522,3 @@ namespace Mono.CSharp {
}
}
}
-
-
-
-
diff --git a/mcs/mbas/attribute.cs b/mcs/mbas/attribute.cs
index bfe5a39da1d..9f6cff3cb97 100644
--- a/mcs/mbas/attribute.cs
+++ b/mcs/mbas/attribute.cs
@@ -18,7 +18,7 @@ using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
using System.Text;
-namespace Mono.CSharp {
+namespace Mono.MonoBASIC {
public class Attribute {
public readonly string Name;
diff --git a/mcs/mbas/cfold.cs b/mcs/mbas/cfold.cs
index 72726d97335..e53b71e1ebc 100644
--- a/mcs/mbas/cfold.cs
+++ b/mcs/mbas/cfold.cs
@@ -9,7 +9,7 @@
using System;
-namespace Mono.CSharp {
+namespace Mono.MonoBASIC {
public class ConstantFold {
diff --git a/mcs/mbas/class.cs b/mcs/mbas/class.cs
index cce911ccc1b..500d02f3af2 100644
--- a/mcs/mbas/class.cs
+++ b/mcs/mbas/class.cs
@@ -37,7 +37,7 @@ using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Diagnostics.SymbolStore;
-namespace Mono.CSharp {
+namespace Mono.MonoBASIC {
/// <summary>
/// This is the base class for structs and classes.
@@ -169,7 +169,7 @@ namespace Mono.CSharp {
return AdditionResult.Success;
}
- public AdditionResult AddEnum (Mono.CSharp.Enum e)
+ public AdditionResult AddEnum (Mono.MonoBASIC.Enum e)
{
AdditionResult res;
@@ -688,7 +688,7 @@ namespace Mono.CSharp {
if (!AsAccessible (parent, ModFlags))
Report.Error (60, Location,
"Inconsistent accessibility: base class `" +
- TypeManager.CSharpName (parent) + "' is less " +
+ TypeManager.MonoBASIC_Name (parent) + "' is less " +
"accessible than class `" +
Name + "'");
@@ -774,7 +774,7 @@ namespace Mono.CSharp {
else
is_class = false;
- ec = new EmitContext (this, Mono.CSharp.Location.Null, null, null, ModFlags);
+ ec = new EmitContext (this, Mono.MonoBASIC.Location.Null, null, null, ModFlags);
ifaces = GetClassBases (is_class, out parent, out error);
@@ -788,7 +788,7 @@ namespace Mono.CSharp {
parent == TypeManager.array_type){
Report.Error (
644, Location, "`" + Name + "' cannot inherit from " +
- "special class `" + TypeManager.CSharpName (parent) + "'");
+ "special class `" + TypeManager.MonoBASIC_Name (parent) + "'");
return null;
}
}
@@ -2229,7 +2229,7 @@ namespace Mono.CSharp {
17, location,
"Program `" + CodeGen.FileName +
"' has more than one entry point defined: `" +
- TypeManager.CSharpSignature(b) + "'");
+ TypeManager.MonoBASIC_Signature(b) + "'");
}
void Report28 (MethodInfo b)
@@ -2239,7 +2239,7 @@ namespace Mono.CSharp {
Report.Warning (
28, Location,
- "`" + TypeManager.CSharpSignature(b) +
+ "`" + TypeManager.MonoBASIC_Signature(b) +
"' has the wrong signature to be an entry point");
}
@@ -3064,13 +3064,13 @@ namespace Mono.CSharp {
if ((modifiers & Modifiers.ABSTRACT) != 0)
Report.Error (
500, Location, "Abstract method `" +
- TypeManager.CSharpSignature (builder) +
+ TypeManager.MonoBASIC_Signature (builder) +
"' can not have a body");
if ((modifiers & Modifiers.EXTERN) != 0)
Report.Error (
179, Location, "External method `" +
- TypeManager.CSharpSignature (builder) +
+ TypeManager.MonoBASIC_Signature (builder) +
"' can not have a body");
return;
@@ -3082,7 +3082,7 @@ namespace Mono.CSharp {
if (block == null) {
Report.Error (
501, Location, "Method `" +
- TypeManager.CSharpSignature (builder) +
+ TypeManager.MonoBASIC_Signature (builder) +
"' must declare a body since it is not marked " +
"abstract or extern");
return;
@@ -3233,12 +3233,12 @@ namespace Mono.CSharp {
if (this is Indexer)
Report.Error (55, Location,
"Inconsistent accessibility: parameter type `" +
- TypeManager.CSharpName (partype) + "' is less " +
+ TypeManager.MonoBASIC_Name (partype) + "' is less " +
"accessible than indexer `" + Name + "'");
else
Report.Error (51, Location,
"Inconsistent accessibility: parameter type `" +
- TypeManager.CSharpName (partype) + "' is less " +
+ TypeManager.MonoBASIC_Name (partype) + "' is less " +
"accessible than method `" + Name + "'");
error = true;
}
@@ -3266,22 +3266,22 @@ namespace Mono.CSharp {
if (this is Property)
Report.Error (53, Location,
"Inconsistent accessibility: property type `" +
- TypeManager.CSharpName (MemberType) + "' is less " +
+ TypeManager.MonoBASIC_Name (MemberType) + "' is less " +
"accessible than property `" + Name + "'");
else if (this is Indexer)
Report.Error (54, Location,
"Inconsistent accessibility: indexer return type `" +
- TypeManager.CSharpName (MemberType) + "' is less " +
+ TypeManager.MonoBASIC_Name (MemberType) + "' is less " +
"accessible than indexer `" + Name + "'");
else if (this is Method)
Report.Error (50, Location,
"Inconsistent accessibility: return type `" +
- TypeManager.CSharpName (MemberType) + "' is less " +
+ TypeManager.MonoBASIC_Name (MemberType) + "' is less " +
"accessible than method `" + Name + "'");
else
Report.Error (52, Location,
"Inconsistent accessibility: field type `" +
- TypeManager.CSharpName (MemberType) + "' is less " +
+ TypeManager.MonoBASIC_Name (MemberType) + "' is less " +
"accessible than field `" + Name + "'");
return false;
}
@@ -3414,7 +3414,7 @@ namespace Mono.CSharp {
if (!parent.AsAccessible (t, ModFlags)) {
Report.Error (52, Location,
"Inconsistent accessibility: field type `" +
- TypeManager.CSharpName (t) + "' is less " +
+ TypeManager.MonoBASIC_Name (t) + "' is less " +
"accessible than field `" + Name + "'");
return false;
}
@@ -3452,7 +3452,7 @@ namespace Mono.CSharp {
Report.Error (
677, Location, parent.MakeName (Name) +
" A volatile field can not be of type `" +
- TypeManager.CSharpName (t) + "'");
+ TypeManager.MonoBASIC_Name (t) + "'");
return false;
}
}
@@ -4440,7 +4440,7 @@ namespace Mono.CSharp {
OperatorMethod = new Method (ReturnType, ModFlags, MethodName,
new Parameters (param_list, null, Location),
- OptAttributes, Mono.CSharp.Location.Null);
+ OptAttributes, Mono.MonoBASIC.Location.Null);
OperatorMethod.IsOperator = true;
OperatorMethod.Define (parent);
@@ -4630,13 +4630,13 @@ namespace Mono.CSharp {
if (SecondArgType == null)
return String.Format (
"{0} operator {1}({2})",
- TypeManager.CSharpName (return_type),
+ TypeManager.MonoBASIC_Name (return_type),
GetName (OperatorType),
param_types [0]);
else
return String.Format (
"{0} operator {1}({2}, {3})",
- TypeManager.CSharpName (return_type),
+ TypeManager.MonoBASIC_Name (return_type),
GetName (OperatorType),
param_types [0], param_types [1]);
}
diff --git a/mcs/mbas/codegen.cs b/mcs/mbas/codegen.cs
index 613888bbf82..0ece01942c1 100644
--- a/mcs/mbas/codegen.cs
+++ b/mcs/mbas/codegen.cs
@@ -14,7 +14,7 @@ using System.Reflection;
using System.Reflection.Emit;
using System.Diagnostics.SymbolStore;
-namespace Mono.CSharp {
+namespace Mono.MonoBASIC {
/// <summary>
/// Code generator class.
diff --git a/mcs/mbas/const.cs b/mcs/mbas/const.cs
index 2708592a86e..04d19dda622 100644
--- a/mcs/mbas/const.cs
+++ b/mcs/mbas/const.cs
@@ -17,7 +17,7 @@
// function aborts because it requires its argument to be of the same type
//
-namespace Mono.CSharp {
+namespace Mono.MonoBASIC {
using System;
using System.Reflection;
@@ -228,5 +228,3 @@ namespace Mono.CSharp {
}
}
}
-
-
diff --git a/mcs/mbas/constant.cs b/mcs/mbas/constant.cs
index 4030080a0b2..f31cb733ae1 100644
--- a/mcs/mbas/constant.cs
+++ b/mcs/mbas/constant.cs
@@ -8,7 +8,7 @@
//
//
-namespace Mono.CSharp {
+namespace Mono.MonoBASIC {
using System;
using System.Reflection.Emit;
@@ -970,5 +970,3 @@ namespace Mono.CSharp {
}
}
-
-
diff --git a/mcs/mbas/decl.cs b/mcs/mbas/decl.cs
index 6b49c3b9085..ff8b249568d 100644
--- a/mcs/mbas/decl.cs
+++ b/mcs/mbas/decl.cs
@@ -15,7 +15,7 @@ using System.Collections;
using System.Reflection.Emit;
using System.Reflection;
-namespace Mono.CSharp {
+namespace Mono.MonoBASIC {
/// <summary>
/// Base representation for members. This is only used to keep track
diff --git a/mcs/mbas/defaultparserattribute.cs b/mcs/mbas/defaultparserattribute.cs
index fbe87d7f095..2a6b687898d 100644
--- a/mcs/mbas/defaultparserattribute.cs
+++ b/mcs/mbas/defaultparserattribute.cs
@@ -13,9 +13,6 @@ namespace Mono.Languages
{
using System;
using System.Reflection;
- using System.Collections;
- using System.IO;
- using Mono.CSharp;
[AttributeUsage(AttributeTargets.Class)]
public class DefaultParserAttribute : System.Attribute
diff --git a/mcs/mbas/delegate.cs b/mcs/mbas/delegate.cs
index add8e2579b1..898f0c2ad2e 100644
--- a/mcs/mbas/delegate.cs
+++ b/mcs/mbas/delegate.cs
@@ -15,7 +15,7 @@ using System.Reflection;
using System.Reflection.Emit;
using System.Text;
-namespace Mono.CSharp {
+namespace Mono.MonoBASIC {
/// <summary>
/// Holds Delegates
@@ -150,7 +150,7 @@ namespace Mono.CSharp {
if (!container.AsAccessible (partype, ModFlags)) {
Report.Error (59, Location,
"Inconsistent accessibility: parameter type `" +
- TypeManager.CSharpName (partype) + "` is less " +
+ TypeManager.MonoBASIC_Name (partype) + "` is less " +
"accessible than delegate `" + Name + "'");
return false;
}
@@ -163,7 +163,7 @@ namespace Mono.CSharp {
if (!container.AsAccessible (ret_type, ModFlags)) {
Report.Error (58, Location,
"Inconsistent accessibility: return type `" +
- TypeManager.CSharpName (ret_type) + "` is less " +
+ TypeManager.MonoBASIC_Name (ret_type) + "` is less " +
"accessible than delegate `" + Name + "'");
return false;
}
@@ -437,7 +437,7 @@ namespace Mono.CSharp {
public static string FullDelegateDesc (Type del_type, MethodBase mb, ParameterData pd)
{
- StringBuilder sb = new StringBuilder (TypeManager.CSharpName (((MethodInfo) mb).ReturnType));
+ StringBuilder sb = new StringBuilder (TypeManager.MonoBASIC_Name (((MethodInfo) mb).ReturnType));
sb.Append (" " + del_type.ToString ());
sb.Append (" (");
@@ -447,7 +447,7 @@ namespace Mono.CSharp {
for (int i = length; i > 0; ) {
i--;
- sb.Append (TypeManager.CSharpName (pd.ParameterType (length - i - 1)));
+ sb.Append (TypeManager.MonoBASIC_Name (pd.ParameterType (length - i - 1)));
if (i != 0)
sb.Append (", ");
}
diff --git a/mcs/mbas/driver.cs b/mcs/mbas/driver.cs
index bf3b423e28c..7d8ce4d36c3 100644
--- a/mcs/mbas/driver.cs
+++ b/mcs/mbas/driver.cs
@@ -17,7 +17,7 @@ namespace Mono.Languages
using System.Collections;
using System.IO;
using System.Globalization;
- using Mono.CSharp;
+ using Mono.MonoBASIC;
using Mono.GetOptions;
enum Target
@@ -221,12 +221,10 @@ namespace Mono.Languages
}
}
- private string[] importsList = null;
-
- [Option("[NOT IMPLEMENTED YET]Declare global Imports for namespaces in referenced metadata files. {import-list}:namespace,...", "imports")]
+ [Option("Declare global Imports for namespaces in referenced metadata files. {import-list}:namespace,...", "imports")]
public WhatToDoNext imports(string importslist)
{
- importsList = importslist.Split(',');
+ Mono.MonoBASIC.Parser.ImportsList.AddRange(importslist.Split(','));
return WhatToDoNext.GoAhead;
}
@@ -302,6 +300,7 @@ namespace Mono.Languages
ArrayList defines = new ArrayList();
ArrayList references = new ArrayList();
ArrayList soft_references = new ArrayList();
+
string first_source = null;
Target target = Target.Exe;
string target_ext = ".exe";
@@ -411,6 +410,12 @@ namespace Mono.Languages
defines = new ArrayList ();
defines.Add ("__MonoBASIC__");
}
+
+ void SetupDefaultImports()
+ {
+ Mono.MonoBASIC.Parser.ImportsList = new ArrayList();
+ Mono.MonoBASIC.Parser.ImportsList.Add("Microsoft.VisualBasic");
+ }
//
@@ -857,6 +862,8 @@ namespace Mono.Languages
int MainDriver(string [] args)
{
SetupDefaultDefines();
+
+ SetupDefaultImports();
ProcessArgs(args);
diff --git a/mcs/mbas/ecore.cs b/mcs/mbas/ecore.cs
index bc58fe7574b..2824125e2d3 100644
--- a/mcs/mbas/ecore.cs
+++ b/mcs/mbas/ecore.cs
@@ -8,7 +8,7 @@
//
//
-namespace Mono.CSharp {
+namespace Mono.MonoBASIC {
using System;
using System.Collections;
using System.Diagnostics;
@@ -241,8 +241,8 @@ namespace Mono.CSharp {
static public void Error_CannotConvertType (Location loc, Type source, Type target)
{
Report.Error (30, loc, "Cannot convert type '" +
- TypeManager.CSharpName (source) + "' to '" +
- TypeManager.CSharpName (target) + "'");
+ TypeManager.MonoBASIC_Name (source) + "' to '" +
+ TypeManager.MonoBASIC_Name (target) + "'");
}
/// <summary>
@@ -1876,8 +1876,8 @@ namespace Mono.CSharp {
static public void Error_CannotConvertImplicit (Location loc, Type source, Type target)
{
string msg = "Cannot convert implicitly from `"+
- TypeManager.CSharpName (source) + "' to `" +
- TypeManager.CSharpName (target) + "'";
+ TypeManager.MonoBASIC_Name (source) + "' to `" +
+ TypeManager.MonoBASIC_Name (target) + "'";
Report.Error (29, loc, msg);
}
@@ -2538,7 +2538,7 @@ namespace Mono.CSharp {
static void Error_ConstantValueCannotBeConverted (Location l, string val, Type t)
{
Report.Error (31, l, "Constant value `" + val + "' cannot be converted to " +
- TypeManager.CSharpName (t));
+ TypeManager.MonoBASIC_Name (t));
}
public static void UnsafeError (Location loc)
@@ -4532,4 +4532,4 @@ namespace Mono.CSharp {
ec, false, IsStatic, instance_expr, remove_accessor, args, loc);
}
}
-}
+}
diff --git a/mcs/mbas/enum.cs b/mcs/mbas/enum.cs
index fe94a611d9e..57e5f01edd2 100644
--- a/mcs/mbas/enum.cs
+++ b/mcs/mbas/enum.cs
@@ -14,7 +14,7 @@ using System.Collections;
using System.Reflection;
using System.Reflection.Emit;
-namespace Mono.CSharp {
+namespace Mono.MonoBASIC {
/// <summary>
/// Enumeration container
@@ -141,7 +141,7 @@ namespace Mono.CSharp {
Report.Error (1008, Location,
"Type byte, sbyte, short, ushort, int, uint, " +
"long, or ulong expected (got: " +
- TypeManager.CSharpName (UnderlyingType) + ")");
+ TypeManager.MonoBASIC_Name (UnderlyingType) + ")");
return null;
}
@@ -249,11 +249,11 @@ namespace Mono.CSharp {
if (val is Constant)
Report.Error (31, loc, "Constant value '" + ((Constant) val).AsString () +
"' cannot be converted" +
- " to a " + TypeManager.CSharpName (UnderlyingType));
+ " to a " + TypeManager.MonoBASIC_Name (UnderlyingType));
else
Report.Error (31, loc, "Constant value '" + val +
"' cannot be converted" +
- " to a " + TypeManager.CSharpName (UnderlyingType));
+ " to a " + TypeManager.MonoBASIC_Name (UnderlyingType));
return;
}
@@ -422,7 +422,7 @@ namespace Mono.CSharp {
else {
for (int i = 0; i < idx; ++i) {
string n = (string) ordered_enums [i];
- Location m_loc = (Mono.CSharp.Location)
+ Location m_loc = (Mono.MonoBASIC.Location)
member_to_location [n];
in_transit.Add (name, true);
default_value = LookupEnumValue (ec, n, m_loc);
@@ -529,7 +529,7 @@ namespace Mono.CSharp {
if (member_to_value.Contains (name))
continue;
- Location loc = (Mono.CSharp.Location) member_to_location [name];
+ Location loc = (Mono.MonoBASIC.Location) member_to_location [name];
if (this [name] != null) {
default_value = LookupEnumValue (ec, name, loc);
diff --git a/mcs/mbas/expression.cs b/mcs/mbas/expression.cs
index fc024f9e84e..91f86df2170 100644
--- a/mcs/mbas/expression.cs
+++ b/mcs/mbas/expression.cs
@@ -9,7 +9,7 @@
//
#define USE_OLD
-namespace Mono.CSharp {
+namespace Mono.MonoBASIC {
using System;
using System.Collections;
using System.Reflection;
@@ -143,7 +143,7 @@ namespace Mono.CSharp {
Error (
23, "Operator " + OperName (Oper) +
" cannot be applied to operand of type '" +
- TypeManager.CSharpName (t) + "'");
+ TypeManager.MonoBASIC_Name (t) + "'");
}
/// <remarks>
@@ -484,7 +484,7 @@ namespace Mono.CSharp {
}
Error (187, "No such operator '" + OperName (Oper) + "' defined for type '" +
- TypeManager.CSharpName (expr_type) + "'");
+ TypeManager.MonoBASIC_Name (expr_type) + "'");
return null;
}
@@ -692,7 +692,7 @@ namespace Mono.CSharp {
Error (
23, "Operator " + OperName (mode) +
" cannot be applied to operand of type '" +
- TypeManager.CSharpName (t) + "'");
+ TypeManager.MonoBASIC_Name (t) + "'");
}
/// <summary>
@@ -781,7 +781,7 @@ namespace Mono.CSharp {
}
Error (187, "No such operator '" + OperName (mode) + "' defined for type '" +
- TypeManager.CSharpName (expr_type) + "'");
+ TypeManager.MonoBASIC_Name (expr_type) + "'");
return null;
}
@@ -1074,13 +1074,13 @@ namespace Mono.CSharp {
Warning (
183,
"The expression is always of type '" +
- TypeManager.CSharpName (probe_type) + "'");
+ TypeManager.MonoBASIC_Name (probe_type) + "'");
else if (warning_never_matches){
if (!(probe_type.IsInterface || expr.Type.IsInterface))
Warning (
184,
"The expression is never of type '" +
- TypeManager.CSharpName (probe_type) + "'");
+ TypeManager.MonoBASIC_Name (probe_type) + "'");
}
}
@@ -1113,8 +1113,8 @@ namespace Mono.CSharp {
{
Report.Error (
39, loc, "as operator can not convert from '" +
- TypeManager.CSharpName (source) + "' to '" +
- TypeManager.CSharpName (target) + "'");
+ TypeManager.MonoBASIC_Name (source) + "' to '" +
+ TypeManager.MonoBASIC_Name (target) + "'");
}
public override Expression DoResolve (EmitContext ec)
@@ -1130,7 +1130,7 @@ namespace Mono.CSharp {
if (TypeManager.IsValueType (probe_type)){
Report.Error (77, loc, "The as operator should be used with a reference type only (" +
- TypeManager.CSharpName (probe_type) + " is a value type");
+ TypeManager.MonoBASIC_Name (probe_type) + " is a value type");
return null;
}
@@ -1647,8 +1647,8 @@ namespace Mono.CSharp {
Report.Error (
34, loc, "Operator '" + OperName (oper)
+ "' is ambiguous on operands of type '"
- + TypeManager.CSharpName (l) + "' "
- + "and '" + TypeManager.CSharpName (r)
+ + TypeManager.MonoBASIC_Name (l) + "' "
+ + "and '" + TypeManager.MonoBASIC_Name (r)
+ "'");
}
@@ -1814,8 +1814,8 @@ namespace Mono.CSharp {
{
Report.Error (19, loc,
"Operator " + name + " cannot be applied to operands of type '" +
- TypeManager.CSharpName (l) + "' and '" +
- TypeManager.CSharpName (r) + "'");
+ TypeManager.MonoBASIC_Name (l) + "' and '" +
+ TypeManager.MonoBASIC_Name (r) + "'");
}
void Error_OperatorCannotBeApplied ()
@@ -2752,8 +2752,8 @@ namespace Mono.CSharp {
if (ConvertImplicit (ec, falseExpr, true_type, loc) != null){
Error (172,
"Can not compute type of conditional expression " +
- "as '" + TypeManager.CSharpName (trueExpr.Type) +
- "' and '" + TypeManager.CSharpName (falseExpr.Type) +
+ "as '" + TypeManager.MonoBASIC_Name (trueExpr.Type) +
+ "' and '" + TypeManager.MonoBASIC_Name (falseExpr.Type) +
"' convert implicitly to each other");
return null;
}
@@ -2765,8 +2765,8 @@ namespace Mono.CSharp {
} else {
Error (173, "The type of the conditional expression can " +
"not be computed because there is no implicit conversion" +
- " from '" + TypeManager.CSharpName (trueExpr.Type) + "'" +
- " and '" + TypeManager.CSharpName (falseExpr.Type) + "'");
+ " from '" + TypeManager.MonoBASIC_Name (trueExpr.Type) + "'" +
+ " and '" + TypeManager.MonoBASIC_Name (falseExpr.Type) + "'");
return null;
}
}
@@ -3422,7 +3422,7 @@ namespace Mono.CSharp {
string ret_type = "";
if (mb is MethodInfo)
- ret_type = TypeManager.CSharpName (((MethodInfo) mb).ReturnType) + " ";
+ ret_type = TypeManager.MonoBASIC_Name (((MethodInfo) mb).ReturnType) + " ";
StringBuilder sb = new StringBuilder (ret_type + mb.Name);
ParameterData pd = GetParameterData (mb);
@@ -5566,7 +5566,7 @@ namespace Mono.CSharp {
return null;
if (!TypeManager.IsUnmanagedType (type_queried)){
- Report.Error (208, "Cannot take the size of an unmanaged type (" + TypeManager.CSharpName (type_queried) + ")");
+ Report.Error (208, "Cannot take the size of an unmanaged type (" + TypeManager.MonoBASIC_Name (type_queried) + ")");
return null;
}
@@ -5867,7 +5867,7 @@ namespace Mono.CSharp {
if (expr_type.IsPointer){
Error (23, "The '.' operator can not be applied to pointer operands (" +
- TypeManager.CSharpName (expr_type) + ")");
+ TypeManager.MonoBASIC_Name (expr_type) + ")");
return null;
}
@@ -5908,8 +5908,8 @@ namespace Mono.CSharp {
if (lookup != null)
Error (1540, "Cannot access protected member '" +
expr_type + "." + Identifier + "' " +
- "via a qualifier of type '" + TypeManager.CSharpName (expr_type) + "'; the " +
- "qualifier must be of type '" + TypeManager.CSharpName (ec.ContainerType) + "' " +
+ "via a qualifier of type '" + TypeManager.MonoBASIC_Name (expr_type) + "'; the " +
+ "qualifier must be of type '" + TypeManager.MonoBASIC_Name (ec.ContainerType) + "' " +
"(or derived from it)");
else
Error (122, "'" + expr_type + "." + Identifier + "' " +
@@ -6601,7 +6601,7 @@ namespace Mono.CSharp {
}
Report.Error (21, loc,
- "Type '" + TypeManager.CSharpName (lookup_type) +
+ "Type '" + TypeManager.MonoBASIC_Name (lookup_type) +
"' does not have any indexers defined");
return null;
}
@@ -6705,7 +6705,7 @@ namespace Mono.CSharp {
}
if (set == null){
- Error (200, "indexer X.this [" + TypeManager.CSharpName (right_type) +
+ Error (200, "indexer X.this [" + TypeManager.MonoBASIC_Name (right_type) +
"] lacks a 'set' accessor");
return null;
}
@@ -6763,7 +6763,7 @@ namespace Mono.CSharp {
if (member_lookup == null) {
Error (117,
- TypeManager.CSharpName (base_type) + " does not " +
+ TypeManager.MonoBASIC_Name (base_type) + " does not " +
"contain a definition for '" + member + "'");
return null;
}
diff --git a/mcs/mbas/genericparser.cs b/mcs/mbas/genericparser.cs
index 14f8abccb17..074f1428e76 100644
--- a/mcs/mbas/genericparser.cs
+++ b/mcs/mbas/genericparser.cs
@@ -14,7 +14,7 @@ namespace Mono.Languages
using System.Reflection;
using System.Collections;
using System.IO;
- using Mono.CSharp;
+ using Mono.MonoBASIC;
/// <summary>
/// Base class to support multiple Jay generated parsers
diff --git a/mcs/mbas/interface.cs b/mcs/mbas/interface.cs
index 1d2dc2f5cca..90909c48706 100644
--- a/mcs/mbas/interface.cs
+++ b/mcs/mbas/interface.cs
@@ -14,7 +14,7 @@ using System.IO;
using System.Reflection;
using System.Reflection.Emit;
-namespace Mono.CSharp {
+namespace Mono.MonoBASIC {
/// <summary>
/// Interfaces
@@ -713,7 +713,7 @@ namespace Mono.CSharp {
if (!Parent.AsAccessible (t, ModFlags))
Report.Error (61, Location,
"Inconsistent accessibility: base interface `" +
- TypeManager.CSharpName (t) + "' is less " +
+ TypeManager.MonoBASIC_Name (t) + "' is less " +
"accessible than interface `" +
Name + "'");
diff --git a/mcs/mbas/literal.cs b/mcs/mbas/literal.cs
index a307030db6a..ea7c6dc4118 100644
--- a/mcs/mbas/literal.cs
+++ b/mcs/mbas/literal.cs
@@ -22,7 +22,7 @@ using System;
using System.Reflection;
using System.Reflection.Emit;
-namespace Mono.CSharp {
+namespace Mono.MonoBASIC {
public class NullLiteral : Constant {
public static readonly NullLiteral Null;
@@ -97,6 +97,18 @@ namespace Mono.CSharp {
}
}
+ public class ShortLiteral : ShortConstant {
+ public ShortLiteral (short l) : base (l)
+ {
+ }
+
+ public override Expression DoResolve (EmitContext ec)
+ {
+ type = TypeManager.short_type;
+ return this;
+ }
+ }
+
public class UIntLiteral : UIntConstant {
public UIntLiteral (uint l) : base (l)
{
diff --git a/mcs/mbas/location.cs b/mcs/mbas/location.cs
index 0fd04aab6c9..308778f6cb2 100644
--- a/mcs/mbas/location.cs
+++ b/mcs/mbas/location.cs
@@ -12,7 +12,8 @@ using System.IO;
using System.Collections;
using System.Diagnostics.SymbolStore;
-namespace Mono.CSharp {
+namespace Mono.MonoBASIC {
+
/// <summary>
/// Keeps track of the location in the program
/// </summary>
@@ -157,7 +158,7 @@ namespace Mono.CSharp {
else {
// Create a new ISymbolDocumentWriter instance and
// store it in the hash table.
- doc = sw.DefineDocument (path, SymLanguageType.CSharp,
+ doc = sw.DefineDocument (path, SymLanguageType.Basic,
SymLanguageVendor.Microsoft,
SymDocumentType.Text);
diff --git a/mcs/mbas/mb-parser.jay b/mcs/mbas/mb-parser.jay
index 8834e6062fc..32db9ae3e53 100644
--- a/mcs/mbas/mb-parser.jay
+++ b/mcs/mbas/mb-parser.jay
@@ -19,7 +19,7 @@ namespace Mono.MonoBASIC
using System.Reflection;
using System.Collections;
using Mono.Languages;
- using Mono.CSharp;
+ using Mono.MonoBASIC;
/// <summary>
/// The MonoBASIC Parser
@@ -136,6 +136,7 @@ namespace Mono.MonoBASIC
static public bool InitialOptionExplicit = false;
static public bool InitialOptionStrict = false;
static public bool InitialOptionCompareBinary = true;
+ static public ArrayList ImportsList = null;
bool OptionExplicit;
bool OptionStrict;
@@ -650,7 +651,7 @@ attribute
}
opt_attribute_arguments
{
- $$ = new Mono.CSharp.Attribute ((string) $1, (ArrayList) $3, (Location) $2);
+ $$ = new Mono.MonoBASIC.Attribute ((string) $1, (ArrayList) $3, (Location) $2);
}
;
@@ -1199,7 +1200,7 @@ enum_declaration
if (implicit_modifiers && ((current_modifiers & Modifiers.STATIC) != 0))
current_modifiers = (current_modifiers & ~Modifiers.STATIC);
- Mono.CSharp.Enum e = new Mono.CSharp.Enum (current_container, enum_type,
+ Mono.MonoBASIC.Enum e = new Mono.MonoBASIC.Enum (current_container, enum_type,
(int) current_modifiers, full_name,
(Attributes) current_attributes, enum_location);
@@ -1632,7 +1633,7 @@ delegate_declaration
if (implicit_modifiers && ((current_modifiers & Modifiers.STATIC) != 0))
current_modifiers = (current_modifiers & ~Modifiers.STATIC);
- Mono.CSharp.Delegate del = new Mono.CSharp.Delegate (current_container, TypeManager.system_void_expr,
+ Mono.MonoBASIC.Delegate del = new Mono.MonoBASIC.Delegate (current_container, TypeManager.system_void_expr,
(int) current_modifiers,
MakeName ((string) $3), (Parameters) $5,
(Attributes) current_attributes, l);
@@ -1646,7 +1647,7 @@ delegate_declaration
CLOSE_PARENS AS type
{
Location l = lexer.Location;
- Mono.CSharp.Delegate del = new Mono.CSharp.Delegate (
+ Mono.MonoBASIC.Delegate del = new Mono.MonoBASIC.Delegate (
current_container,
(Expression) $8, (int) current_modifiers, MakeName ((string) $3),
(Parameters) $5, (Attributes) current_attributes, l);
@@ -3072,13 +3073,11 @@ integer_literal
object v = lexer.Value;
if (v is int)
- $$ = new IntLiteral ((Int32) v);
- else if (v is uint)
- $$ = new UIntLiteral ((UInt32) v);
+ $$ = new IntLiteral ((Int32)v);
+ else if (v is short)
+ $$ = new ShortLiteral ((Int16)v);
else if (v is long)
- $$ = new LongLiteral ((Int64) v);
- else if (v is ulong)
- $$ = new ULongLiteral ((UInt64) v);
+ $$ = new LongLiteral ((Int64)v);
else
Console.WriteLine ("OOPS. Unexpected result from scanner");
@@ -3578,14 +3577,6 @@ integral_type
| LONG { $$ = TypeManager.system_int64_expr; }
| INTEGER { $$ = TypeManager.system_int32_expr; }
| CHAR { $$ = TypeManager.system_char_expr; }
-/*
- | SBYTE { $$ = TypeManager.system_sbyte_expr; }
- | UINT { $$ = TypeManager.system_uint32_expr; }
- | ULONG { $$ = TypeManager.system_uint64_expr; }
- | USHORT { $$ = TypeManager.system_uint16_expr; }
- | CHAR { $$ = TypeManager.system_char_expr; }
- | VOID { $$ = TypeManager.system_void_expr; }
-*/
;
interface_type
@@ -4043,7 +4034,7 @@ private ConstructorInitializer FixConstructorInitializer (ref ArrayList s)
s.Remove(0);
}
}
- if (i.expr.ToString() == "Mono.CSharp.This..ctor") {
+ if (i.expr.ToString() == "Mono.MonoBASIC.This..ctor") {
ci = new ConstructorThisInitializer (i.Arguments, current_local_parameters, lexer.Location);
s.Remove(0);
}
@@ -4073,6 +4064,8 @@ private void ReportError9998()
protected override int parse ()
{
current_namespace = new Namespace (null, RootContext.RootNamespace);
+ foreach(string preImportedNamespace in ImportsList)
+ current_namespace.Using(preImportedNamespace, Location.Null);
current_container = RootContext.Tree.Types;
current_container.Namespace = current_namespace;
oob_stack = new Stack ();
@@ -4099,8 +4092,7 @@ protected override int parse ()
}
catch (Exception e)
{
- Report.Error (9999, lexer.Location, lexer.location + "Parsing error in " + lexer.ref_name + "\n");
- Console.WriteLine (e);
+ Report.Error (9999, lexer.Location, lexer.location + "\nParsing error in " + lexer.ref_name + "\n" + e.ToString());
}
return Report.Errors;
diff --git a/mcs/mbas/mb-tokenizer.cs b/mcs/mbas/mb-tokenizer.cs
index dc845726bb2..415a1bdbadc 100644
--- a/mcs/mbas/mb-tokenizer.cs
+++ b/mcs/mbas/mb-tokenizer.cs
@@ -18,7 +18,7 @@ namespace Mono.MonoBASIC
using System.IO;
using System.Globalization;
using Mono.Languages;
- using Mono.CSharp;
+ using Mono.MonoBASIC;
/// <summary>
/// Tokenizer for MonoBASIC source code.
@@ -354,12 +354,8 @@ namespace Mono.MonoBASIC
return Token.CLOSE_PARENS;
case ',':
return Token.COMMA;
- //case ':':
- // return Token.COLON;
case '?':
return Token.INTERR;
- //case '&':
- // return Token.OP_CONCAT;
}
d = peekChar ();
@@ -374,12 +370,15 @@ namespace Mono.MonoBASIC
doread = true;
return t;
}
- if (c == '&'){
- if (d == '=')
- t = Token.OP_CONCAT_ASSIGN;
- else
- return Token.OP_CONCAT;
- doread = true;
+ if (c == '&') {
+ t = handle_integer_literal_in_other_bases(d);
+ if (t == Token.NONE) {
+ if (d == '=') {
+ doread = true;
+ t = Token.OP_CONCAT_ASSIGN;
+ } else
+ return Token.OP_CONCAT;
+ }
return t;
}
if (c == '-'){
@@ -392,10 +391,6 @@ namespace Mono.MonoBASIC
}
if (c == '='){
- /*if (d == '='){
- doread = true;
- return Token.OP_EQ;
- }*/
return Token.ASSIGN;
}
@@ -480,23 +475,6 @@ namespace Mono.MonoBASIC
return seen_digits;
}
- void hex_digits (int c)
- {
- int d;
-
- if (c != -1)
- number.Append ((char) c);
- while ((d = peekChar ()) != -1){
- char e = Char.ToUpper ((char) d);
-
- if (Char.IsDigit (e) ||
- (e >= 'A' && e <= 'F')){
- number.Append ((char) e);
- getChar ();
- } else
- break;
- }
- }
int real_type_suffix (int c)
{
@@ -506,10 +484,10 @@ namespace Mono.MonoBASIC
case 'F': case 'f':
t = Token.LITERAL_SINGLE;
break;
- case 'D': case 'd':
+ case 'R': case 'r':
t = Token.LITERAL_DOUBLE;
break;
- case 'M': case 'm':
+ case 'D': case 'd':
t= Token.LITERAL_DECIMAL;
break;
default:
@@ -521,23 +499,45 @@ namespace Mono.MonoBASIC
int integer_type_suffix (int c)
{
- // FIXME: Handle U and L suffixes.
- // We also need to see in which kind of
- // Int the thing fits better according to the spec.
- return Token.LITERAL_INTEGER;
+ int t;
+
+ try {
+
+ switch (c){
+ case 'S': case 's':
+ t = Token.LITERAL_INTEGER; // SHORT ?
+ val = ((IConvertible)val).ToInt16(null);
+ break;
+ case 'I': case 'i':
+ t = Token.LITERAL_INTEGER;
+ val = ((IConvertible)val).ToInt32(null);
+ break;
+ case 'L': case 'l':
+ t= Token.LITERAL_INTEGER; // LONG ?
+ val = ((IConvertible)val).ToInt64(null);
+ break;
+ default:
+ if ((long)val <= System.Int32.MaxValue &&
+ (long)val >= System.Int32.MinValue) {
+ val = ((IConvertible)val).ToInt32(null);
+ return Token.LITERAL_INTEGER;
+ } else {
+ val = ((IConvertible)val).ToInt64(null);
+ return Token.LITERAL_INTEGER; // LONG ?
+ }
+ }
+ getChar ();
+ return t;
+ } catch (Exception e) {
+ val = e.ToString();
+ return Token.ERROR;
+ }
}
- void adjust_int (int t)
- {
- val = new System.Int32();
- val = System.Int32.Parse (number.ToString (), 0);
- }
-
int adjust_real (int t)
{
string s = number.ToString ();
- Console.WriteLine (s);
switch (t){
case Token.LITERAL_DECIMAL:
val = new System.Decimal ();
@@ -565,6 +565,60 @@ namespace Mono.MonoBASIC
return t;
}
+ long hex_digits ()
+ {
+ System.Text.StringBuilder hexNumber = new System.Text.StringBuilder ();
+
+ int d;
+
+ while ((d = peekChar ()) != -1){
+ char e = Char.ToUpper ((char) d);
+
+ if (Char.IsDigit (e) || (e >= 'A' && e <= 'F')){
+ hexNumber.Append (e);
+ getChar ();
+ } else
+ break;
+ }
+ return System.Int64.Parse (hexNumber.ToString(), NumberStyles.HexNumber);
+ }
+
+ long octal_digits ()
+ {
+ long valueToReturn = 0;
+
+ int d;
+
+ while ((d = peekChar ()) != -1){
+ char e = (char)d;
+ if (Char.IsDigit (e) && (e < '8')){
+ valueToReturn *= 8;
+ valueToReturn += (d - (int)'0');
+ getChar ();
+ } else
+ break;
+ }
+
+ return valueToReturn;
+ }
+
+ int handle_integer_literal_in_other_bases(int peek)
+ {
+ if (peek == 'h' || peek == 'H'){
+ getChar ();
+ val = hex_digits ();
+ return integer_type_suffix (peekChar ());
+ }
+
+ if (peek == 'o' || peek == 'O'){
+ getChar ();
+ val = octal_digits ();
+ return integer_type_suffix (peekChar ());
+ }
+
+ return Token.NONE;
+ }
+
//
// Invoked if we know we have .digits or digits
//
@@ -577,30 +631,23 @@ namespace Mono.MonoBASIC
number.Length = 0;
if (Char.IsDigit ((char)c)){
- if (c == '0' && peekChar () == 'x' || peekChar () == 'X'){
- getChar ();
- hex_digits (-1);
- val = new System.Int32 ();
- val = System.Int32.Parse (number.ToString (), NumberStyles.HexNumber);
- return integer_type_suffix (peekChar ());
- }
decimal_digits (c);
- c = getChar ();
+ c = peekChar ();
}
//
// We need to handle the case of
- // "1.1" vs "1.string" (LITERAL_SINGLE vs NUMBER DOT IDENTIFIER)
+ // "1.1" vs "1.ToString()" (LITERAL_SINGLE vs NUMBER DOT IDENTIFIER)
//
if (c == '.'){
- if (decimal_digits ('.')){
+ if (decimal_digits (getChar())){
is_real = true;
c = peekChar ();
} else {
putback ('.');
number.Length -= 1;
- adjust_int (Token.LITERAL_INTEGER);
- return Token.LITERAL_INTEGER;
+ val = System.Int64.Parse(number.ToString());
+ return integer_type_suffix('.');
}
}
@@ -625,25 +672,13 @@ namespace Mono.MonoBASIC
type = real_type_suffix (c);
if (type == Token.NONE && !is_real){
- type = integer_type_suffix (c);
- adjust_int (type);
- putback (c);
- return type;
- } else
- is_real = true;
-
- if (is_real)
- return adjust_real (type);
-
- Console.WriteLine ("This should not be reached");
- throw new Exception ("Is Number should never reach this point");
- }
+ val = System.Int64.Parse(number.ToString());
+ return integer_type_suffix(c);
+ }
- int escape (int c)
- {
- return peekChar ();
+ return adjust_real (type);
}
-
+
int getChar ()
{
if (putback_char != -1){
@@ -753,6 +788,13 @@ namespace Mono.MonoBASIC
return id.ToString ();
}
+ private bool is_doublequote(int currentChar)
+ {
+ return (currentChar == '"' ||
+ currentChar == 0x201C || // unicode left double-quote character
+ currentChar == 0x201D); // unicode right double-quote character
+ }
+
private bool tokens_seen = false;
public int xtoken ()
@@ -880,18 +922,31 @@ namespace Mono.MonoBASIC
}
// Treat string literals
- if (c == '"'){
+ if (is_doublequote(c)){
System.Text.StringBuilder s = new System.Text.StringBuilder ();
tokens_seen = true;
while ((c = getChar ()) != -1){
- if (c == '"'){
- if (peekChar() == '"')
+ if (is_doublequote(c)){
+ if (is_doublequote(peekChar()))
getChar();
else {
- val = s.ToString ();
- return Token.LITERAL_STRING;
+ //handle Char Literals
+ if (peekChar() == 'C' || peekChar() == 'c') {
+ getChar();
+ if (s.Length == 1) {
+ val = s[0];
+ return Token.LITERAL_CHARACTER;
+ } else {
+ val = "Incorrect length for a character literal";
+ return Token.ERROR;
+ }
+
+ } else {
+ val = s.ToString ();
+ return Token.LITERAL_STRING;
+ }
}
}
@@ -900,6 +955,8 @@ namespace Mono.MonoBASIC
s.Append ((char) c);
}
+
+ return Token.ERROR;
}
// expand tabs for location and ignore it as whitespace
diff --git a/mcs/mbas/modifiers.cs b/mcs/mbas/modifiers.cs
index 613cc2a86e5..f742fc5e6f8 100644
--- a/mcs/mbas/modifiers.cs
+++ b/mcs/mbas/modifiers.cs
@@ -4,7 +4,7 @@
using System;
using System.Reflection;
-namespace Mono.CSharp {
+namespace Mono.MonoBASIC {
public class Modifiers {
//
diff --git a/mcs/mbas/module.cs b/mcs/mbas/module.cs
index 20677a84767..d16f54ed109 100644
--- a/mcs/mbas/module.cs
+++ b/mcs/mbas/module.cs
@@ -13,7 +13,7 @@ using System.Diagnostics.SymbolStore;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
-using Mono.CSharp ;
+using Mono.MonoBASIC ;
namespace Mono.MonoBASIC
{
@@ -21,7 +21,7 @@ namespace Mono.MonoBASIC
{
public static void AddSpecializedAttribute(ref Attributes attrs, string attributeName, ArrayList args, Location loc)
{
- Mono.CSharp.Attribute specialAttr = new Mono.CSharp.Attribute(attributeName, args, loc);
+ Mono.MonoBASIC.Attribute specialAttr = new Mono.MonoBASIC.Attribute(attributeName, args, loc);
ArrayList al = new ArrayList();
al.Add(specialAttr);
AttributeSection asec = new AttributeSection(null, al);
@@ -35,7 +35,7 @@ namespace Mono.MonoBASIC
/// <summary>
/// Summary description for module.
/// </summary>
- public class Module : Mono.CSharp.Class
+ public class Module : Mono.MonoBASIC.Class
{
// <summary>
// Modifiers allowed in a class declaration
diff --git a/mcs/mbas/namespace.cs b/mcs/mbas/namespace.cs
index 371e7522454..1d47903d7f7 100644
--- a/mcs/mbas/namespace.cs
+++ b/mcs/mbas/namespace.cs
@@ -10,7 +10,7 @@ using System;
using System.Collections;
using Mono.Languages;
-namespace Mono.CSharp {
+namespace Mono.MonoBASIC {
/// <summary>
/// Keeps track of the namespaces defined in the C# code.
diff --git a/mcs/mbas/parameter.cs b/mcs/mbas/parameter.cs
index d0eac31da32..6dd1593ebd1 100644
--- a/mcs/mbas/parameter.cs
+++ b/mcs/mbas/parameter.cs
@@ -14,7 +14,7 @@ using System.Reflection;
using System.Reflection.Emit;
using System.Collections;
-namespace Mono.CSharp {
+namespace Mono.MonoBASIC {
/// <summary>
@@ -532,6 +532,3 @@ namespace Mono.CSharp {
}
}
}
-
-
-
diff --git a/mcs/mbas/pending.cs b/mcs/mbas/pending.cs
index cd453dd4ce1..29d11648265 100644
--- a/mcs/mbas/pending.cs
+++ b/mcs/mbas/pending.cs
@@ -15,7 +15,7 @@ using System.Collections;
using System.Reflection;
using System.Reflection.Emit;
-namespace Mono.CSharp {
+namespace Mono.MonoBASIC {
struct TypeAndMethods {
public Type type;
diff --git a/mcs/mbas/report.cs b/mcs/mbas/report.cs
index 5a9501a6887..55d0f04d28d 100644
--- a/mcs/mbas/report.cs
+++ b/mcs/mbas/report.cs
@@ -14,7 +14,7 @@ using System.Text;
using System.Collections;
using System.Diagnostics;
-namespace Mono.CSharp {
+namespace Mono.MonoBASIC {
/// <summary>
/// This class is used to report errors and warnings t te user.
diff --git a/mcs/mbas/rootcontext.cs b/mcs/mbas/rootcontext.cs
index a56f93475a4..678f320e850 100644
--- a/mcs/mbas/rootcontext.cs
+++ b/mcs/mbas/rootcontext.cs
@@ -14,7 +14,7 @@ using System.Reflection;
using System.Reflection.Emit;
using System.Diagnostics;
-namespace Mono.CSharp {
+namespace Mono.MonoBASIC {
public class RootContext {
@@ -742,7 +742,7 @@ namespace Mono.CSharp {
AssemblyBuilder ab = CodeGen.AssemblyBuilder;
TypeContainer dummy = new TypeContainer (null, "", new Location (-1, 0));
EmitContext temp_ec = new EmitContext (
- dummy, Mono.CSharp.Location.Null, null, null, 0, false);
+ dummy, Mono.MonoBASIC.Location.Null, null, null, 0, false);
foreach (DictionaryEntry de in global_attributes){
Namespace ns = (Namespace) de.Key;
diff --git a/mcs/mbas/statement.cs b/mcs/mbas/statement.cs
index 222c6ab09e1..bc7885b4c86 100644
--- a/mcs/mbas/statement.cs
+++ b/mcs/mbas/statement.cs
@@ -14,7 +14,7 @@ using System.Reflection;
using System.Reflection.Emit;
using System.Diagnostics;
-namespace Mono.CSharp {
+namespace Mono.MonoBASIC {
using System.Collections;
@@ -673,7 +673,7 @@ namespace Mono.CSharp {
} else {
if (Expr == null){
Report.Error (126, loc, "An object of type `" +
- TypeManager.CSharpName (ec.ReturnType) + "' is " +
+ TypeManager.MonoBASIC_Name (ec.ReturnType) + "' is " +
"expected for the return statement");
return true;
}
@@ -2506,7 +2506,7 @@ namespace Mono.CSharp {
FieldInfo field = struct_info [i];
Report.Error (171, loc,
- "Field `" + TypeManager.CSharpName (VariableType) +
+ "Field `" + TypeManager.MonoBASIC_Name (VariableType) +
"." + field.Name + "' must be fully initialized " +
"before control leaves the constructor");
return false;
@@ -3404,7 +3404,7 @@ namespace Mono.CSharp {
if (converted != null){
Report.Error (-12, loc, "More than one conversion to an integral " +
" type exists for type `" +
- TypeManager.CSharpName (Expr.Type)+"'");
+ TypeManager.MonoBASIC_Name (Expr.Type)+"'");
return null;
} else
converted = e;
@@ -4065,7 +4065,7 @@ namespace Mono.CSharp {
if (type.IsValueType){
Report.Error (185, loc, "lock statement requires the expression to be " +
" a reference type (type is: `" +
- TypeManager.CSharpName (type) + "'");
+ TypeManager.MonoBASIC_Name (type) + "'");
return false;
}
diff --git a/mcs/mbas/statementCollection.cs b/mcs/mbas/statementCollection.cs
index 9e5141dfdc6..352cb132b59 100644
--- a/mcs/mbas/statementCollection.cs
+++ b/mcs/mbas/statementCollection.cs
@@ -7,7 +7,7 @@
// (C) 2001 Ximian, Inc.
//
-namespace Mono.CSharp {
+namespace Mono.MonoBASIC {
using System.Collections;
using System;
diff --git a/mcs/mbas/support.cs b/mcs/mbas/support.cs
index 9577e1b0a97..21a1affd7e3 100644
--- a/mcs/mbas/support.cs
+++ b/mcs/mbas/support.cs
@@ -15,7 +15,7 @@ using System.Collections;
using System.Reflection.Emit;
using System.Globalization;
-namespace Mono.CSharp {
+namespace Mono.MonoBASIC {
public interface ParameterData {
Type ParameterType (int pos);
@@ -82,7 +82,7 @@ namespace Mono.CSharp {
if (pos >= pi.Length - 1 && last_arg_is_params)
sb.Append ("params ");
- sb.Append (TypeManager.CSharpName (ParameterType (pos)));
+ sb.Append (TypeManager.MonoBASIC_Name (ParameterType (pos)));
return sb.ToString ();
@@ -183,7 +183,7 @@ namespace Mono.CSharp {
Type t = ParameterType (pos);
- return tmp + TypeManager.CSharpName (t);
+ return tmp + TypeManager.MonoBASIC_Name (t);
}
public Parameter.Modifier ParameterModifier (int pos)
diff --git a/mcs/mbas/testmbas/WriteOK.vb b/mcs/mbas/testmbas/WriteOK.vb
index f61b630e263..62eeb973735 100644
--- a/mcs/mbas/testmbas/WriteOK.vb
+++ b/mcs/mbas/testmbas/WriteOK.vb
@@ -9,14 +9,34 @@ Module WriteOK
Sub Main()
Dim nodim as integer ' comment out to test explicit
+ Dim octalLit as integer = &O177
+ Dim hexLit as long = &h1F34A6BFL
+
+ dim singleLit as single = -1.1F
+ dim doubleLit as double = 8e-3
+ dim decimalLit as decimal = 1.1234567890123456789012D
+
+ dim charLit as char = "?"c
+
REM Testing old-fashioned comments
Console.WriteLine("OK!") ' Simple comments
WriteOK2.[Sub]()
- IO.WriteLine("OK! via aliased name") ' from alias
+ IO.WriteLine("OK! ""via"" aliased name") ' from alias
nodim = 1 ' test for explicit
- Console.WriteLine(nodim)
+ Console.WriteLine("nodim {0}" + _
+ Constants.vbCRLF + "octalLit {1}" + _
+ Constants.vbCRLF + "hexLit {2}" + _
+ Constants.vbCRLF + "singleLit {3}" + _
+ Constants.vbCRLF + "doubleLit {4}" + _
+ Constants.vbCRLF + "decimalLit {5}" + _
+ Constants.vbCRLF + "charLit {6}", _
+ nodim, octalLit, hexLit, singleLit, doubleLit, decimalLit, charLit)
+ Console.WriteLine(123.ToString("g"))
WriteOK5.ModuleSub() ' 122
' ModuleSub() ' 103
+
+ Console.WriteLine(Strings.ChrW(64))
+
End Sub
End Module
diff --git a/mcs/mbas/tree.cs b/mcs/mbas/tree.cs
index 8ae4b68630c..6ff1923dbe7 100644
--- a/mcs/mbas/tree.cs
+++ b/mcs/mbas/tree.cs
@@ -15,7 +15,7 @@ using System.Reflection;
using System.Reflection.Emit;
using System.IO;
-namespace Mono.CSharp
+namespace Mono.MonoBASIC
{
public interface ITreeDump {
diff --git a/mcs/mbas/typemanager.cs b/mcs/mbas/typemanager.cs
index e1e8d6b4c18..3574c7ff391 100644
--- a/mcs/mbas/typemanager.cs
+++ b/mcs/mbas/typemanager.cs
@@ -18,7 +18,7 @@ using System.Text.RegularExpressions;
using System.Runtime.CompilerServices;
using System.Diagnostics;
-namespace Mono.CSharp {
+namespace Mono.MonoBASIC {
public class TypeManager {
//
@@ -581,7 +581,7 @@ public class TypeManager {
/// <summary>
/// Returns the C# name of a type if possible, or the full type name otherwise
/// </summary>
- static public string CSharpName (Type t)
+ static public string MonoBASIC_Name (Type t)
{
return Regex.Replace (t.FullName,
@"^System\." +
@@ -589,10 +589,10 @@ public class TypeManager {
@"Single|Double|Char|Decimal|Byte|SByte|Object|" +
@"Boolean|String|Void)" +
@"(\W+|\b)",
- new MatchEvaluator (CSharpNameMatch));
+ new MatchEvaluator (MonoBASIC_NameMatch));
}
- static String CSharpNameMatch (Match match)
+ static String MonoBASIC_NameMatch (Match match)
{
string s = match.Groups [1].Captures [0].Value;
return s.ToLower ().
@@ -610,7 +610,7 @@ public class TypeManager {
/// <summary>
/// Returns the signature of the method
/// </summary>
- static public string CSharpSignature (MethodBase mb)
+ static public string MonoBASIC_Signature (MethodBase mb)
{
string sig = "(";
@@ -1713,7 +1713,7 @@ public class TypeManager {
Report.Error (
208, loc,
"Cannot take the address or size of a variable of a managed type ('" +
- CSharpName (t) + "')");
+ MonoBASIC_Name (t) + "')");
return false;
}
@@ -1862,7 +1862,7 @@ public class TypeManager {
if (a.TypeId == TypeManager.obsolete_attribute_type){
ObsoleteAttribute oa = (ObsoleteAttribute) a;
- string method_desc = TypeManager.CSharpSignature (mb);
+ string method_desc = TypeManager.MonoBASIC_Signature (mb);
if (oa.IsError) {
Report.Error (619, loc, "Method `" + method_desc +
diff --git a/mcs/mcs/ChangeLog b/mcs/mcs/ChangeLog
index 6284c8f54d8..38afb9314d0 100755
--- a/mcs/mcs/ChangeLog
+++ b/mcs/mcs/ChangeLog
@@ -1,3 +1,128 @@
+2003-11-30 Zoltan Varga <vargaz@freemail.hu>
+
+ * typemanager.cs: Fix lookup of GetNamespaces.
+
+2003-11-29 Miguel de Icaza <miguel@ximian.com>
+
+ * expression.cs: Removed redundant line.
+
+ * statement.cs (Block.Resolve, Block.Emit): Avoid foreach on
+ ArrayLists, use for loops with bounds.
+
+ * flowanalysis.cs (FlowBranching.Merge): Avoid foreach on
+ arraylist.
+
+ * expression.cs (Invocation.OverloadResolve): Avoid foreach on
+ arraylists, use for loop with bounds.
+
+ The above three changes give us a 0.071 second performance
+ improvement out of 3.294 seconds down to 3.223. On my machine
+ the above changes reduced the memory usage by 1,387 KB during
+ compiler bootstrap.
+
+ * cs-parser.jay (QualifiedIdentifier): New class used to represent
+ QualifiedIdentifiers. Before we created a new string through
+ concatenation, and mostly later on, the result would be
+ manipulated by DecomposeQI through string manipulation.
+
+ This reduced the compiler memory usage for bootstrapping from
+ 59380 KB to 59007 KB on my machine, 373 KB, and also reduced the
+ compile times in 0.05 seconds.
+
+2003-11-28 Dick Porter <dick@ximian.com>
+
+ * support.cs: Do string compares with the Invariant culture.
+
+ * rootcontext.cs:
+ * gen-treedump.cs:
+ * expression.cs:
+ * driver.cs:
+ * decl.cs:
+ * codegen.cs:
+ * class.cs: Use the char forms of IndexOf and LastIndexOf, so that
+ the comparison is done with the Invariant culture.
+
+2003-11-27 Miguel de Icaza <miguel@ximian.com>
+
+ * statement.cs (Foreach.TryType): Use DeclaredOnly to find the
+ GetEnumerator method.
+
+ (ProbeCollectionType): Iterate starting at the most specific type
+ upwards looking for a GetEnumerator
+
+ * expression.cs: Shift count can be up to 31 for int/uint and 63
+ for long/ulong.
+
+2003-11-26 Miguel de Icaza <miguel@ximian.com>
+
+ * statement.cs (Block.LookupLabel): Also look for the label on the
+ children blocks. Use a hash table to keep track of visited
+ nodes.
+
+ * cfold.cs (IntConstant to UIntConstant mapping): Only return if
+ we actually did transform the other operand, otherwise fall back
+ to the common codepath that casts to long.
+
+ * cs-tokenizer.cs: Use the same code pattern as the int case.
+ Maybe I should do the parsing myself, and avoid depending on the
+ Parse routines to get this done.
+
+2003-11-25 Miguel de Icaza <miguel@ximian.com>
+
+ * expression.cs: Apply fix from l_m@pacbell.net (Laurent Morichetti),
+ which fixes bug 51347. This time test it.
+
+ * expression.cs: Make TypeOfVoid derive from TypeOf, so code in
+ attributes for example can not tell the difference between these.
+ The difference was only a syntax feature of the language.
+
+ * attribute.cs: Apply attributes to delegates.
+
+ * delegate.cs: Call the apply attributes method.
+
+2003-11-24 Miguel de Icaza <miguel@ximian.com>
+
+ * convert.cs (TryImplicitIntConversion): One line bug fix: we were
+ comparing 0 vs Byte.MinValue, not the value
+
+ (ImplicitConversionRequired): When reporting a conversion error,
+ use error 31 to print out the constant error instead of the
+ simpler 29.
+
+ * expression.cs: Apply fix from l_m@pacbell.net (Laurent Morichetti),
+ which fixes bug 51347.
+
+2003-11-22 Miguel de Icaza <miguel@ximian.com>
+
+ * driver.cs: Applied patch from gert.driesen@pandora.be (Gert Driesen)
+ which fixes the -warnaserror command line option.
+
+2003-11-21 Miguel de Icaza <miguel@ximian.com>
+
+ * cfold.cs (DoNumericPromotions): During constant folding of
+ additions on UIntConstant, special case intconstants with
+ IntConstants like we do on the expression binary operator.
+
+2003-11-12 Miguel de Icaza <miguel@ximian.com>
+
+ * convert.cs (ImplicitReferenceConversion): We were missing a case
+ (System.Enum are not value types or class types, so we need to
+ classify them separatedly).
+
+ * driver.cs: We do not support error 2007.
+
+2003-11-12 Jackson Harper <jackson@ximian.com>
+
+ * driver.cs: Use corlib.dll or mscorlib.dll when looking up the
+ system directory. Also use the full file name so users can
+ libraries names mscorlib-o-tron.dll in a non system dir.
+
+2003-11-10 Martin Baulig <martin@ximian.com>
+
+ * typemanager.cs (TypeManager.ResolveExpressionTypes): Removed.
+ (TypeManager.InitCoreTypes): Initialize them here, but instead of
+ calling `ResolveType()' on them, directly assign their `Type'.
+
2003-11-08 Martin Baulig <martin@ximian.com>
* class.cs (TypeContainer.GetClassBases): Use TypeExpr's for the
diff --git a/mcs/mcs/assign.cs b/mcs/mcs/assign.cs
index b489fc60d27..dae00366584 100755
--- a/mcs/mcs/assign.cs
+++ b/mcs/mcs/assign.cs
@@ -303,7 +303,7 @@ namespace Mono.CSharp {
return null;
}
}
-
+
source = Convert.ImplicitConversionRequired (ec, source, target_type, loc);
if (source == null)
return null;
diff --git a/mcs/mcs/attribute.cs b/mcs/mcs/attribute.cs
index eeab31cd0c4..e049cf0e008 100644
--- a/mcs/mcs/attribute.cs
+++ b/mcs/mcs/attribute.cs
@@ -925,7 +925,22 @@ namespace Mono.CSharp {
"\tor compile using the Mono runtime instead of the\n"+
"\tMicrosoft .NET runtime");
}
-
+ } else if (kind is Delegate){
+ if (!CheckAttributeTarget (a, kind)) {
+ Error_AttributeNotValidForElement (a, loc);
+ return;
+ }
+ try {
+ ((TypeBuilder) builder).SetCustomAttribute (cb);
+ } catch (System.ArgumentException e) {
+ Report.Warning (
+ -21, loc,
+ "The CharSet named property on StructLayout\n"+
+ "\tdoes not work correctly on Microsoft.NET\n"+
+ "\tYou might want to remove the CharSet declaration\n"+
+ "\tor compile using the Mono runtime instead of the\n"+
+ "\tMicrosoft .NET runtime");
+ }
} else if (kind is Interface) {
Interface iface = (Interface) kind;
diff --git a/mcs/mcs/cfold.cs b/mcs/mcs/cfold.cs
index 7d0860211da..d4d130ca5da 100755
--- a/mcs/mcs/cfold.cs
+++ b/mcs/mcs/cfold.cs
@@ -98,21 +98,28 @@ namespace Mono.CSharp {
// operand is of type sbyte, short or int, the operands are
// converted to type long.
//
- Constant match, other;
- if (left is UIntConstant){
+ Constant other;
+ if (left is UIntConstant)
other = right;
- match = left;
- } else {
+ else
other = left;
- match = right;
- }
// Nothing to do.
if (other is UIntConstant)
return;
- if (other is SByteConstant || other is ShortConstant ||
- other is IntConstant){
+ IntConstant ic = other as IntConstant;
+ if (ic != null){
+ if (ic.Value >= 0){
+ if (left == other)
+ left = new UIntConstant ((uint) ic.Value);
+ else
+ right = new UIntConstant ((uint) ic.Value);
+ return;
+ }
+ }
+
+ if (other is SByteConstant || other is ShortConstant || ic != null){
left = left.ToLong (loc);
right = right.ToLong (loc);
}
@@ -180,7 +187,7 @@ namespace Mono.CSharp {
Type rt = right.Type;
Type result_type = null;
bool bool_res;
-
+
//
// Enumerator folding
//
@@ -960,7 +967,7 @@ namespace Mono.CSharp {
((StringConstant) right).Value);
}
-
+
DoConstantNumericPromotions (ec, oper, ref left, ref right, loc);
if (left == null || right == null)
return null;
diff --git a/mcs/mcs/class.cs b/mcs/mcs/class.cs
index a671a511d57..b6a251fac61 100755
--- a/mcs/mcs/class.cs
+++ b/mcs/mcs/class.cs
@@ -245,7 +245,7 @@ namespace Mono.CSharp {
if (methods == null)
methods = new ArrayList ();
- if (method.Name.IndexOf (".") != -1)
+ if (method.Name.IndexOf ('.') != -1)
methods.Insert (0, method);
else
methods.Add (method);
@@ -357,7 +357,7 @@ namespace Mono.CSharp {
if (properties == null)
properties = new ArrayList ();
- if (prop.Name.IndexOf (".") != -1)
+ if (prop.Name.IndexOf ('.') != -1)
properties.Insert (0, prop);
else
properties.Add (prop);
@@ -3673,8 +3673,8 @@ namespace Mono.CSharp {
//
// Check for explicit interface implementation
//
- if ((ExplicitInterfaceName == null) && (Name.IndexOf (".") != -1)){
- int pos = Name.LastIndexOf (".");
+ if ((ExplicitInterfaceName == null) && (Name.IndexOf ('.') != -1)){
+ int pos = Name.LastIndexOf ('.');
ExplicitInterfaceName = Name.Substring (0, pos);
ShortName = Name.Substring (pos + 1);
diff --git a/mcs/mcs/codegen.cs b/mcs/mcs/codegen.cs
index a8c6ca296da..3eff8d66167 100755
--- a/mcs/mcs/codegen.cs
+++ b/mcs/mcs/codegen.cs
@@ -27,12 +27,12 @@ namespace Mono.CSharp {
public static string Basename (string name)
{
- int pos = name.LastIndexOf ("/");
+ int pos = name.LastIndexOf ('/');
if (pos != -1)
return name.Substring (pos + 1);
- pos = name.LastIndexOf ("\\");
+ pos = name.LastIndexOf ('\\');
if (pos != -1)
return name.Substring (pos + 1);
@@ -41,12 +41,12 @@ namespace Mono.CSharp {
public static string Dirname (string name)
{
- int pos = name.LastIndexOf ("/");
+ int pos = name.LastIndexOf ('/');
if (pos != -1)
return name.Substring (0, pos);
- pos = name.LastIndexOf ("\\");
+ pos = name.LastIndexOf ('\\');
if (pos != -1)
return name.Substring (0, pos);
@@ -55,7 +55,7 @@ namespace Mono.CSharp {
static string TrimExt (string name)
{
- int pos = name.LastIndexOf (".");
+ int pos = name.LastIndexOf ('.');
return name.Substring (0, pos);
}
diff --git a/mcs/mcs/convert.cs b/mcs/mcs/convert.cs
index 24fef0d3428..5dabe481751 100644
--- a/mcs/mcs/convert.cs
+++ b/mcs/mcs/convert.cs
@@ -91,8 +91,10 @@ namespace Mono.CSharp {
if (TypeManager.ImplementsInterface (expr_type, target_type)){
if (expr_type.IsClass)
return new EmptyCast (expr, target_type);
- else if (expr_type.IsValueType)
+ else if (expr_type.IsValueType || expr_type == TypeManager.enum_type)
return new BoxedCast (expr, target_type);
+ else
+ return new EmptyCast (expr, target_type);
}
}
@@ -163,9 +165,9 @@ namespace Mono.CSharp {
if (expr_type.IsClass || expr_type.IsValueType ||
expr_type.IsInterface || expr_type == TypeManager.enum_type)
return true;
- } else if (expr_type.IsSubclassOf (target_type)) {
+ } else if (expr_type.IsSubclassOf (target_type))
return true;
- } else {
+ else {
// Please remember that all code below actually comes
// from ImplicitReferenceConversion so make sure code remains in sync
@@ -236,7 +238,7 @@ namespace Mono.CSharp {
Type target_type, Location loc)
{
Type expr_type = expr.Type;
-
+
//
// Attempt to do the implicit constant expression conversions
@@ -1085,7 +1087,7 @@ namespace Mono.CSharp {
if (value >= SByte.MinValue && value <= SByte.MaxValue)
return new SByteConstant ((sbyte) value);
} else if (target_type == TypeManager.byte_type){
- if (Byte.MinValue >= 0 && value <= Byte.MaxValue)
+ if (value >= Byte.MinValue && value <= Byte.MaxValue)
return new ByteConstant ((byte) value);
} else if (target_type == TypeManager.short_type){
if (value >= Int16.MinValue && value <= Int16.MaxValue)
@@ -1156,6 +1158,13 @@ namespace Mono.CSharp {
"float type, use F suffix to create a float literal");
}
+ if (source is Constant){
+ Constant c = (Constant) source;
+
+ Expression.Error_ConstantValueCannotBeConverted (loc, c.AsString (), target_type);
+ return null;
+ }
+
Error_CannotImplicitConversion (loc, source.Type, target_type);
return null;
@@ -1626,7 +1635,6 @@ namespace Mono.CSharp {
return new UnboxCast (expr, target_type);
}
-
ne = ExplicitReferenceConversion (expr, target_type);
if (ne != null)
return ne;
diff --git a/mcs/mcs/cs-parser.jay b/mcs/mcs/cs-parser.jay
index 292afb79c04..78306ff0dcb 100755
--- a/mcs/mcs/cs-parser.jay
+++ b/mcs/mcs/cs-parser.jay
@@ -307,7 +307,7 @@ using_alias_directive
: USING IDENTIFIER ASSIGN
namespace_or_type_name SEMICOLON
{
- current_namespace.UsingAlias ((string) $2, (string) $4, lexer.Location);
+ current_namespace.UsingAlias ((string) $2, (string) ($4).ToString (), lexer.Location);
}
| USING error {
CheckIdentifierToken (yyToken);
@@ -341,7 +341,7 @@ namespace_declaration
+ " Expected class, delegate, enum, interface, or struct");
}
- current_namespace = RootContext.Tree.RecordNamespace (current_namespace, file, (string) $3, lexer.Location);
+ current_namespace = RootContext.Tree.RecordNamespace (current_namespace, file, (string) ($3).ToString (), lexer.Location);
}
namespace_body opt_semicolon
{
@@ -360,14 +360,15 @@ opt_comma
;
qualified_identifier
- : IDENTIFIER
+ : IDENTIFIER { $$ = new QualifiedIdentifier ((string) $1); }
| qualified_identifier DOT IDENTIFIER {
- $$ = (($1).ToString ()) + "." + ($3.ToString ()); }
+ $$ = new QualifiedIdentifier ((QualifiedIdentifier) $1, (string) $3);
+ }
;
namespace_name
- : namespace_or_type_name
+ : namespace_or_type_name { $$ = ($1).ToString (); }
;
namespace_body
@@ -534,7 +535,7 @@ attribute
}
opt_attribute_arguments
{
- $$ = new Attribute ((string) $1, (ArrayList) $3, (Location) $2);
+ $$ = new Attribute ((string) ($1).ToString (), (ArrayList) $3, (Location) $2);
}
;
@@ -1007,7 +1008,7 @@ parameter_array
;
member_name
- : qualified_identifier
+ : qualified_identifier { $$ = ($1).ToString (); }
;
property_declaration
@@ -1172,13 +1173,13 @@ interface_type_list
{
ArrayList interfaces = new ArrayList (4);
- interfaces.Add ($1);
+ interfaces.Add (($1).ToString ());
$$ = interfaces;
}
| interface_type_list COMMA interface_type
{
ArrayList interfaces = (ArrayList) $1;
- interfaces.Add ($3);
+ interfaces.Add (($3).ToString ());
$$ = interfaces;
}
;
@@ -1735,7 +1736,7 @@ indexer_declarator
if (pars.FixedParameters == null && pars.ArrayParameter == null){
Report.Error (1551, lexer.Location, "Indexers must have at least one parameter");
}
- $$ = new IndexerDeclaration ((Expression) $1, (string) $2, pars);
+ $$ = new IndexerDeclaration ((Expression) $1, (string) ($2).ToString (), pars);
}
;
@@ -1872,7 +1873,7 @@ type
This does interfaces, delegates, struct_types, class_types,
parent classes, and more! 4.2
*/
- $$ = DecomposeQI ((string) $1, lexer.Location);
+ $$ = DecomposeQI ((QualifiedIdentifier) $1, lexer.Location);
}
| builtin_types
| array_type
@@ -1991,10 +1992,7 @@ primary_expression
| qualified_identifier
{
- string name = (string) $1;
-
- $$ = null;
- $$ = DecomposeQI (name, lexer.Location);
+ $$ = DecomposeQI ((QualifiedIdentifier) $1, lexer.Location);
}
| parenthesized_expression
| member_access
@@ -3837,7 +3835,6 @@ public class VariableDeclaration {
// <summary>
// A class used to hold info about an indexer declarator
// </summary>
-
public class IndexerDeclaration {
public Expression type;
public string interface_type;
@@ -3854,7 +3851,6 @@ public class IndexerDeclaration {
// <summary>
// A class used to hold info about an operator declarator
// </summary>
-
public class OperatorDeclaration {
public Operator.OpType optype;
public Expression ret_type, arg1type, arg2type;
@@ -3876,6 +3872,51 @@ public class OperatorDeclaration {
}
+public class QualifiedIdentifier {
+ public string s;
+ public QualifiedIdentifier prev;
+
+ public QualifiedIdentifier (string s)
+ {
+ this.s = s;
+ prev = null;
+ }
+
+ public QualifiedIdentifier (QualifiedIdentifier prev, string s)
+ {
+ this.s = s;
+ this.prev = prev;
+ }
+
+ public override string ToString ()
+ {
+ if (prev == null)
+ return s;
+
+ // Common cases
+
+ if (prev.prev == null)
+ return prev.s + "." + s;
+ if (prev.prev.prev == null)
+ return prev.prev.s + "." + prev.s + "." + s;
+
+ // Uncommon cases.
+ QualifiedIdentifier ptr = this.prev;
+ int count = 1;
+ while (ptr != null){
+ count++;
+ ptr = ptr.prev;
+ }
+ string [] ss = new string [count];
+ ptr = this;
+ for (int i = count; i-- > 0;){
+ ss [i] = ptr.s;
+ ptr = ptr.prev;
+ }
+ return String.Join (".", ss, 0, ss.Length);
+ }
+}
+
void Error_ExpectingTypeName (Location l, Expression expr)
{
if (expr is Invocation){
@@ -3955,20 +3996,15 @@ CheckDef (bool result, string name, Location l)
CheckDef (DeclSpace.AdditionResult.NameExists, name, l);
}
-Expression DecomposeQI (string name, Location loc)
+Expression DecomposeQI (QualifiedIdentifier qi, Location loc)
{
Expression o;
- if (name.IndexOf ('.') == -1){
- return new SimpleName (name, loc);
- } else {
- int pos = name.LastIndexOf (".");
- string left = name.Substring (0, pos);
- string right = name.Substring (pos + 1);
-
- o = DecomposeQI (left, loc);
-
- return new MemberAccess (o, right, loc);
+ if (qi.prev == null)
+ return new SimpleName (qi.s, loc);
+ else {
+ o = DecomposeQI (qi.prev, loc);
+ return new MemberAccess (o, qi.s, loc);
}
}
diff --git a/mcs/mcs/cs-tokenizer.cs b/mcs/mcs/cs-tokenizer.cs
index 1bcbfba6d66..f71627e7bae 100755
--- a/mcs/mcs/cs-tokenizer.cs
+++ b/mcs/mcs/cs-tokenizer.cs
@@ -779,10 +779,6 @@ namespace Mono.CSharp
getChar ();
while ((d = peekChar ()) != -1){
if (is_hex (d)){
- if (number_pos == 16){
- Report.Error (1021, Location, "Integral constant too large");
- return Token.ERROR;
- }
number_builder [number_pos++] = (char) d;
getChar ();
} else
@@ -790,10 +786,18 @@ namespace Mono.CSharp
}
string s = new String (number_builder, 0, number_pos);
- if (number_pos <= 8)
- ul = System.UInt32.Parse (s, NumberStyles.HexNumber);
- else
- ul = System.UInt64.Parse (s, NumberStyles.HexNumber);
+ try {
+ if (number_pos <= 8)
+ ul = System.UInt32.Parse (s, NumberStyles.HexNumber);
+ else
+ ul = System.UInt64.Parse (s, NumberStyles.HexNumber);
+ } catch (OverflowException){
+ error_details = "Integral constant is too large";
+ Report.Error (1021, Location, error_details);
+ val = 0ul;
+ return Token.LITERAL_INTEGER;
+ }
+
return integer_type_suffix (ul, peekChar ());
}
diff --git a/mcs/mcs/decl.cs b/mcs/mcs/decl.cs
index 618f8812ea7..57843461d12 100755
--- a/mcs/mcs/decl.cs
+++ b/mcs/mcs/decl.cs
@@ -189,7 +189,7 @@ namespace Mono.CSharp {
defined_names.Add (name, o);
#if DEBUGME
- int p = name.LastIndexOf (".");
+ int p = name.LastIndexOf ('.');
int l = name.Length;
length += l;
small += l -p;
@@ -311,8 +311,6 @@ namespace Mono.CSharp {
type_resolve_ec = new EmitContext (parent, this, loc, null, null, ModFlags, false);
type_resolve_ec.ResolvingTypeTree = true;
- TypeManager.ResolveExpressionTypes (type_resolve_ec);
-
return type_resolve_ec;
}
@@ -403,7 +401,7 @@ namespace Mono.CSharp {
string check_type_name = check_type.FullName;
string type_name = TypeBuilder.FullName;
- int cio = check_type_name.LastIndexOf ("+");
+ int cio = check_type_name.LastIndexOf ('+');
string container = check_type_name.Substring (0, cio);
//
@@ -451,7 +449,7 @@ namespace Mono.CSharp {
string check_type_name = check_type.FullName;
string type_name = TypeBuilder.FullName;
- int cio = check_type_name.LastIndexOf ("+");
+ int cio = check_type_name.LastIndexOf ('+');
string container = check_type_name.Substring (0, cio);
//
diff --git a/mcs/mcs/delegate.cs b/mcs/mcs/delegate.cs
index 35a9e43a0b5..b671ef6f52c 100644
--- a/mcs/mcs/delegate.cs
+++ b/mcs/mcs/delegate.cs
@@ -350,6 +350,7 @@ namespace Mono.CSharp {
new InternalParameters (container, end_parameters),
end_param_types);
+ Attribute.ApplyAttributes (ec, TypeBuilder, this, OptAttributes);
return true;
}
diff --git a/mcs/mcs/driver.cs b/mcs/mcs/driver.cs
index 0b9787209b5..a53729d1bab 100755
--- a/mcs/mcs/driver.cs
+++ b/mcs/mcs/driver.cs
@@ -213,7 +213,7 @@ namespace Mono.CSharp
" --timestamp Displays time stamps of various compiler events\n" +
" -unsafe[+|-] Allows unsafe code\n" +
" -warnaserror[+|-] Treat warnings as errors\n" +
- " -warn:LEVEL Sets warning level (the highest is 4, the default)\n" +
+ " -warn:LEVEL Sets warning level (the highest is 4, the default is 2)\n" +
" -v Verbose parsing (for debugging the parser)\n" +
" -2 Enables experimental C# features\n" +
"\n" +
@@ -390,7 +390,8 @@ namespace Mono.CSharp
foreach (Assembly a in assemblies){
string codebase = a.Location;
- if (codebase.EndsWith ("corlib.dll")){
+ string fn = System.IO.Path.GetFileName (codebase);
+ if (fn == "corlib.dll" || fn == "mscorlib.dll"){
return codebase.Substring (0, codebase.LastIndexOf (System.IO.Path.DirectorySeparatorChar));
}
}
@@ -404,7 +405,7 @@ namespace Mono.CSharp
//
static void SplitPathAndPattern (string spec, out string path, out string pattern)
{
- int p = spec.LastIndexOf ("/");
+ int p = spec.LastIndexOf ('/');
if (p != -1){
//
// Windows does not like /file.cs, switch that to:
@@ -420,7 +421,7 @@ namespace Mono.CSharp
return;
}
- p = spec.LastIndexOf ("\\");
+ p = spec.LastIndexOf ('\\');
if (p != -1){
path = spec.Substring (0, p);
pattern = spec.Substring (p + 1);
@@ -457,7 +458,7 @@ namespace Mono.CSharp
string path, pattern;
SplitPathAndPattern (spec, out path, out pattern);
- if (pattern.IndexOf ("*") == -1){
+ if (pattern.IndexOf ('*') == -1){
ProcessFile (spec);
return;
}
@@ -553,8 +554,17 @@ namespace Mono.CSharp
if (level < 0 || level > 4){
Report.Error (1900, "Warning level must be 0 to 4");
Environment.Exit (1);
- } else
- RootContext.WarningLevel = level;
+ }
+ RootContext.WarningLevel = level;
+ TestWarningConflict ();
+ }
+
+ static void TestWarningConflict ()
+ {
+ if (RootContext.WarningLevel == 0 && Report.WarningsAreErrors) {
+ Report.Error (1901, "Conflicting options specified: Warning level 0; Treat warnings as errors");
+ Environment.Exit (1);
+ }
}
static void SetupV2 ()
@@ -743,6 +753,7 @@ namespace Mono.CSharp
case "--werror":
Report.WarningsAreErrors = true;
+ TestWarningConflict();
return true;
case "--nowarn":
@@ -825,7 +836,7 @@ namespace Mono.CSharp
//
static bool CSCParseOption (string option, ref string [] args, ref int i)
{
- int idx = option.IndexOf (":");
+ int idx = option.IndexOf (':');
string arg, value;
if (idx == -1){
@@ -995,6 +1006,7 @@ namespace Mono.CSharp
case "/warnaserror":
case "/warnaserror+":
Report.WarningsAreErrors = true;
+ TestWarningConflict();
return true;
case "/warnaserror-":
@@ -1015,15 +1027,16 @@ namespace Mono.CSharp
warns = value.Split (new Char [] {','});
foreach (string wc in warns){
- int warn = 0;
-
try {
- warn = Int32.Parse (wc);
+ int warn = Int32.Parse (wc);
+ if (warn < 1) {
+ throw new ArgumentOutOfRangeException("warn");
+ }
+ Report.SetIgnoreWarning (warn);
} catch {
- Usage ();
+ Report.Error (1904, String.Format("'{0}' is not a valid warning number", wc));
Environment.Exit (1);
}
- Report.SetIgnoreWarning (warn);
}
return true;
}
@@ -1091,22 +1104,16 @@ namespace Mono.CSharp
try {
cp = Int32.Parse (value);
- } catch { }
-
- if (cp == -1){
- Console.WriteLine ("Invalid code-page requested");
- Usage ();
- }
-
- try {
encoding = Encoding.GetEncoding (cp);
using_default_encoder = false;
} catch {
- Console.WriteLine ("Code page: {0} not supported", cp);
+ Report.Error (2016, String.Format("Code page '{0}' is invalid or not installed", cp));
+ Environment.Exit (1);
}
return true;
-
}
+ //Report.Error (2007, String.Format ("Unrecognized command-line option: '{0}'", option));
+ //Environment.Exit (1);
return false;
}
@@ -1120,7 +1127,7 @@ namespace Mono.CSharp
/// now, needs to be turned into a real driver soon.
/// </remarks>
// [MonoTODO("Change error code for unknown argument to something reasonable")]
- static bool MainDriver (string [] args)
+ internal static bool MainDriver (string [] args)
{
int i;
bool parsing_options = true;
@@ -1253,7 +1260,7 @@ namespace Mono.CSharp
// Quick hack
//
if (output_file == null){
- int pos = first_source.LastIndexOf (".");
+ int pos = first_source.LastIndexOf ('.');
if (pos > 0)
output_file = first_source.Substring (0, pos) + target_ext;
@@ -1427,4 +1434,23 @@ namespace Mono.CSharp
}
}
+
+ //
+ // This is the only public entry point
+ //
+ public class CompilerCallableEntryPoint : MarshalByRefObject {
+ static bool used = false;
+
+ public bool InvokeCompiler (string [] args)
+ {
+ if (used)
+ Reset ();
+ bool ok = Driver.MainDriver (args);
+ return ok && Report.Errors == 0;
+ }
+
+ public void Reset ()
+ {
+ }
+ }
}
diff --git a/mcs/mcs/ecore.cs b/mcs/mcs/ecore.cs
index 6374714ba82..9c1f0aa8144 100755
--- a/mcs/mcs/ecore.cs
+++ b/mcs/mcs/ecore.cs
@@ -820,7 +820,7 @@ namespace Mono.CSharp {
"a `" + sb.ToString () + "' was expected");
}
- static void Error_ConstantValueCannotBeConverted (Location l, string val, Type t)
+ static public void Error_ConstantValueCannotBeConverted (Location l, string val, Type t)
{
Report.Error (31, l, "Constant value `" + val + "' cannot be converted to " +
TypeManager.CSharpName (t));
diff --git a/mcs/mcs/expression.cs b/mcs/mcs/expression.cs
index 8edfec86602..b85db1630b6 100755
--- a/mcs/mcs/expression.cs
+++ b/mcs/mcs/expression.cs
@@ -1720,9 +1720,9 @@ namespace Mono.CSharp {
if (real_expr is DoubleConstant){
double v = ((DoubleConstant) real_expr).Value;
- if (target_type == TypeManager.byte_type)
+ if (target_type == TypeManager.byte_type){
return new ByteConstant ((byte) v);
- if (target_type == TypeManager.sbyte_type)
+ } if (target_type == TypeManager.sbyte_type)
return new SByteConstant ((sbyte) v);
if (target_type == TypeManager.short_type)
return new ShortConstant ((short) v);
@@ -2091,7 +2091,7 @@ namespace Mono.CSharp {
//
// If either operand is of type uint, and the other
// operand is of type sbyte, short or int, othe operands are
- // converted to type long.
+ // converted to type long (unless we have an int constant).
//
Type other = null;
@@ -2209,6 +2209,14 @@ namespace Mono.CSharp {
left = e;
type = e.Type;
+ if (type == TypeManager.int32_type || type == TypeManager.uint32_type){
+ right = new Binary (Binary.Operator.BitwiseAnd, right, new IntLiteral (31), loc);
+ right = right.DoResolve (ec);
+ } else {
+ right = new Binary (Binary.Operator.BitwiseAnd, right, new IntLiteral (63), loc);
+ right = right.DoResolve (ec);
+ }
+
return this;
}
Error_OperatorCannotBeApplied ();
@@ -2310,15 +2318,18 @@ namespace Mono.CSharp {
//
if (b.method == TypeManager.string_concat_string_string ||
b.method == TypeManager.string_concat_string_string_string){
- ArrayList bargs = b.Arguments;
- int count = bargs.Count;
+ int count = b.Arguments.Count;
if (count == 2){
+ ArrayList bargs = new ArrayList (3);
+ bargs.AddRange (b.Arguments);
bargs.Add (new Argument (right, Argument.AType.Expression));
return new BinaryMethod (
TypeManager.string_type,
TypeManager.string_concat_string_string_string, bargs);
} else if (count == 3){
+ ArrayList bargs = new ArrayList (4);
+ bargs.AddRange (b.Arguments);
bargs.Add (new Argument (right, Argument.AType.Expression));
return new BinaryMethod (
TypeManager.string_type,
@@ -2341,9 +2352,10 @@ namespace Mono.CSharp {
}
//
- // Cascading concats will hold up to 4 arguments
+ // Cascading concats will hold up to 2 arguments, any extras will be
+ // reallocated above.
//
- ArrayList args = new ArrayList (4);
+ ArrayList args = new ArrayList (2);
args.Add (new Argument (left, Argument.AType.Expression));
args.Add (new Argument (right, Argument.AType.Expression));
@@ -2658,8 +2670,9 @@ namespace Mono.CSharp {
(l == TypeManager.short_type) ||
(l == TypeManager.ushort_type) ||
(l == TypeManager.int64_type) ||
- (l == TypeManager.uint64_type)))
+ (l == TypeManager.uint64_type))){
type = l;
+ }
} else {
Error_OperatorCannotBeApplied ();
return null;
@@ -3007,7 +3020,8 @@ namespace Mono.CSharp {
right.Emit (ec);
bool isUnsigned = is_unsigned (left.Type);
-
+ IntConstant ic;
+
switch (oper){
case Operator.Multiply:
if (ec.CheckState){
@@ -4549,7 +4563,8 @@ namespace Mono.CSharp {
}
bool found_applicable = false;
- foreach (MethodBase candidate in me.Methods) {
+
+ foreach (MethodBase candidate in me.Methods){
Type decl_type = candidate.DeclaringType;
//
@@ -4585,7 +4600,10 @@ namespace Mono.CSharp {
//
// Now we actually find the best method
//
- foreach (MethodBase candidate in candidates) {
+ int candidate_top = candidates.Count;
+ for (int ix = 0; ix < candidate_top; ix++){
+ MethodBase candidate = (MethodBase) candidates [ix];
+
bool cand_params = (bool) candidate_to_form [candidate];
bool method_params = false;
@@ -4644,7 +4662,8 @@ namespace Mono.CSharp {
//
bool best_params = (bool) candidate_to_form [method];
- foreach (MethodBase candidate in candidates){
+ for (int ix = 0; ix < candidate_top; ix++){
+ MethodBase candidate = (MethodBase) candidates [ix];
if (candidate == method)
continue;
@@ -5566,9 +5585,9 @@ namespace Mono.CSharp {
this.rank = rank;
loc = l;
- //this.rank = rank.Substring (0, rank.LastIndexOf ("["));
+ //this.rank = rank.Substring (0, rank.LastIndexOf ('['));
//
- //string tmp = rank.Substring (rank.LastIndexOf ("["));
+ //string tmp = rank.Substring (rank.LastIndexOf ('['));
//
//dimensions = tmp.Length - 1;
expect_initializers = true;
@@ -6425,13 +6444,13 @@ namespace Mono.CSharp {
ec.ig.Emit (OpCodes.Ldarg_0);
}
}
-
+
/// <summary>
/// Implements the typeof operator
/// </summary>
public class TypeOf : Expression {
public readonly Expression QueriedType;
- Type typearg;
+ protected Type typearg;
public TypeOf (Expression queried_type, Location l)
{
@@ -6471,8 +6490,8 @@ namespace Mono.CSharp {
/// <summary>
/// Implements the `typeof (void)' operator
/// </summary>
- public class TypeOfVoid : Expression {
- public TypeOfVoid (Location l)
+ public class TypeOfVoid : TypeOf {
+ public TypeOfVoid (Location l) : base (null, l)
{
loc = l;
}
@@ -6480,19 +6499,10 @@ namespace Mono.CSharp {
public override Expression DoResolve (EmitContext ec)
{
type = TypeManager.type_type;
+ typearg = TypeManager.void_type;
eclass = ExprClass.Type;
return this;
}
-
- public override void Emit (EmitContext ec)
- {
- ec.ig.Emit (OpCodes.Ldtoken, TypeManager.void_type);
- ec.ig.Emit (OpCodes.Call, TypeManager.system_type_get_type_from_handle);
- }
-
- public Type TypeArg {
- get { return TypeManager.void_type; }
- }
}
/// <summary>
diff --git a/mcs/mcs/flowanalysis.cs b/mcs/mcs/flowanalysis.cs
index cab8a5108a5..9d8ca8dc9c3 100644
--- a/mcs/mcs/flowanalysis.cs
+++ b/mcs/mcs/flowanalysis.cs
@@ -718,7 +718,10 @@ namespace Mono.CSharp
Report.Debug (2, "MERGING CHILDREN", this, Type, children.Count);
- foreach (UsageVector child in children) {
+ int children_count = children.Count;
+ for (int ix = 0; ix < children_count; ix++){
+ UsageVector child = (UsageVector) children [ix];
+
Report.Debug (2, " MERGING CHILD", child, child.AlwaysBreaks, child.AlwaysReturns,
child.IsUnreachable, child.Locals, child.Parameters,
child.Returns, child.Breaks, child.Reachable);
diff --git a/mcs/mcs/gen-treedump.cs b/mcs/mcs/gen-treedump.cs
index 8ad20e812d7..d7931355273 100755
--- a/mcs/mcs/gen-treedump.cs
+++ b/mcs/mcs/gen-treedump.cs
@@ -898,7 +898,7 @@ namespace Generator {
string ClassName (string name)
{
return name;
- //return name.Substring (1 + name.LastIndexOf ("."));
+ //return name.Substring (1 + name.LastIndexOf ('.'));
}
string GenBases (ArrayList bases)
diff --git a/mcs/mcs/rootcontext.cs b/mcs/mcs/rootcontext.cs
index 67ef6b9baf2..d7504227772 100755
--- a/mcs/mcs/rootcontext.cs
+++ b/mcs/mcs/rootcontext.cs
@@ -452,7 +452,7 @@ namespace Mono.CSharp {
//
static public string ImplicitParent (string ns)
{
- int i = ns.LastIndexOf (".");
+ int i = ns.LastIndexOf ('.');
if (i < 0)
return null;
diff --git a/mcs/mcs/statement.cs b/mcs/mcs/statement.cs
index 28bf6036360..85ca6bb5751 100755
--- a/mcs/mcs/statement.cs
+++ b/mcs/mcs/statement.cs
@@ -1280,16 +1280,39 @@ namespace Mono.CSharp {
public LabeledStatement LookupLabel (string name)
{
+ Hashtable l = new Hashtable ();
+
+ return LookupLabel (name, l);
+ }
+
+ //
+ // Lookups a label in the current block, parents and children.
+ // It skips during child recurssion on `source'
+ //
+ LabeledStatement LookupLabel (string name, Hashtable seen)
+ {
if (switch_block != null)
- return switch_block.LookupLabel (name);
+ return switch_block.LookupLabel (name, seen);
- if (labels != null){
+ if (seen [this] != null)
+ return null;
+
+ seen [this] = this;
+
+ if (labels != null)
if (labels.Contains (name))
return ((LabeledStatement) labels [name]);
+
+ if (children != null){
+ foreach (Block b in children){
+ LabeledStatement s = b.LookupLabel (name, seen);
+ if (s != null)
+ return s;
+ }
}
if (Parent != null)
- return Parent.LookupLabel (name);
+ return Parent.LookupLabel (name, seen);
return null;
}
@@ -1732,7 +1755,10 @@ namespace Mono.CSharp {
ArrayList new_statements = new ArrayList ();
bool unreachable = false, warning_shown = false;
- foreach (Statement s in statements){
+ int statement_count = statements.Count;
+ for (int ix = 0; ix < statement_count; ix++){
+ Statement s = (Statement) statements [ix];
+
if (unreachable && !(s is LabeledStatement)) {
if (!warning_shown && !(s is EmptyStatement)) {
warning_shown = true;
@@ -1787,8 +1813,11 @@ namespace Mono.CSharp {
protected override bool DoEmit (EmitContext ec)
{
- foreach (Statement s in statements)
+ int statement_count = statements.Count;
+ for (int ix = 0; ix < statement_count; ix++){
+ Statement s = (Statement) statements [ix];
s.Emit (ec);
+ }
return (flags & Flags.HasRet) != 0;
}
@@ -3613,16 +3642,16 @@ namespace Mono.CSharp {
//
static MethodInfo FetchMethodGetCurrent (Type t)
{
- MemberList move_next_list;
-
- move_next_list = TypeContainer.FindMembers (
+ MemberList get_current_list;
+
+ get_current_list = TypeContainer.FindMembers (
t, MemberTypes.Method,
BindingFlags.Public | BindingFlags.Instance,
Type.FilterName, "get_Current");
- if (move_next_list.Count == 0)
+ if (get_current_list.Count == 0)
return null;
- foreach (MemberInfo m in move_next_list){
+ foreach (MemberInfo m in get_current_list){
MethodInfo mi = (MethodInfo) m;
Type [] args;
@@ -3776,7 +3805,7 @@ namespace Mono.CSharp {
mi = TypeContainer.FindMembers (t, MemberTypes.Method,
BindingFlags.Public | BindingFlags.NonPublic |
- BindingFlags.Instance,
+ BindingFlags.Instance | BindingFlags.DeclaredOnly,
FilterEnumerator, hm);
if (mi.Count == 0)
@@ -3794,8 +3823,11 @@ namespace Mono.CSharp {
{
ForeachHelperMethods hm = new ForeachHelperMethods (ec);
- if (TryType (t, hm))
- return hm;
+ for (Type tt = t; tt != null && tt != TypeManager.object_type;){
+ if (TryType (tt, hm))
+ return hm;
+ tt = tt.BaseType;
+ }
//
// Now try to find the method in the interfaces
diff --git a/mcs/mcs/support.cs b/mcs/mcs/support.cs
index 43d7e746302..a40d4607b94 100755
--- a/mcs/mcs/support.cs
+++ b/mcs/mcs/support.cs
@@ -236,12 +236,12 @@ namespace Mono.CSharp {
}
if (a is string)
- return String.Compare ((string) a, ((MemberInfo)b).Name);
+ return String.Compare ((string) a, ((MemberInfo)b).Name, false, CultureInfo.InvariantCulture);
if (b is string)
- return String.Compare (((MemberInfo)a).Name, (string) b);
+ return String.Compare (((MemberInfo)a).Name, (string) b, false, CultureInfo.InvariantCulture);
- return String.Compare (((MemberInfo)a).Name, ((MemberInfo)b).Name);
+ return String.Compare (((MemberInfo)a).Name, ((MemberInfo)b).Name, false, CultureInfo.InvariantCulture);
}
}
diff --git a/mcs/mcs/typemanager.cs b/mcs/mcs/typemanager.cs
index c432a9c7c30..62d5512ed95 100755
--- a/mcs/mcs/typemanager.cs
+++ b/mcs/mcs/typemanager.cs
@@ -311,29 +311,6 @@ public class TypeManager {
system_valuetype_expr = new TypeLookupExpression ("System.ValueType");
}
- public static void ResolveExpressionTypes (EmitContext ec)
- {
- system_object_expr.ResolveType (ec);
- system_string_expr.ResolveType (ec);
- system_boolean_expr.ResolveType (ec);
- system_decimal_expr.ResolveType (ec);
- system_single_expr.ResolveType (ec);
- system_double_expr.ResolveType (ec);
- system_sbyte_expr.ResolveType (ec);
- system_byte_expr.ResolveType (ec);
- system_int16_expr.ResolveType (ec);
- system_uint16_expr.ResolveType (ec);
- system_int32_expr.ResolveType (ec);
- system_uint32_expr.ResolveType (ec);
- system_int64_expr.ResolveType (ec);
- system_uint64_expr.ResolveType (ec);
- system_char_expr.ResolveType (ec);
- system_void_expr.ResolveType (ec);
- system_asynccallback_expr.ResolveType (ec);
- system_iasyncresult_expr.ResolveType (ec);
- system_valuetype_expr.ResolveType (ec);
- }
-
static TypeManager ()
{
assemblies = new Assembly [0];
@@ -719,7 +696,7 @@ public class TypeManager {
/// </summary>
public static void ComputeNamespaces ()
{
- MethodInfo assembly_get_namespaces = typeof (Assembly).GetMethod ("GetNamespaces");
+ MethodInfo assembly_get_namespaces = typeof (Assembly).GetMethod ("GetNamespaces", BindingFlags.Instance|BindingFlags.NonPublic);
//
// First add the assembly namespaces
@@ -1046,6 +1023,26 @@ public class TypeManager {
set_corlib_type_builders.Invoke (CodeGen.AssemblyBuilder, args);
}
}
+
+ system_object_expr.Type = object_type;
+ system_string_expr.Type = string_type;
+ system_boolean_expr.Type = bool_type;
+ system_decimal_expr.Type = decimal_type;
+ system_single_expr.Type = float_type;
+ system_double_expr.Type = double_type;
+ system_sbyte_expr.Type = sbyte_type;
+ system_byte_expr.Type = byte_type;
+ system_int16_expr.Type = short_type;
+ system_uint16_expr.Type = ushort_type;
+ system_int32_expr.Type = int32_type;
+ system_uint32_expr.Type = uint32_type;
+ system_int64_expr.Type = int64_type;
+ system_uint64_expr.Type = uint64_type;
+ system_char_expr.Type = char_type;
+ system_void_expr.Type = void_type;
+ system_asynccallback_expr.Type = asynccallback_type;
+ system_iasyncresult_expr.Type = iasyncresult_type;
+ system_valuetype_expr.Type = value_type;
}
//
diff --git a/mcs/tests/ChangeLog b/mcs/tests/ChangeLog
index 20fc2e88401..d5381d4b338 100755
--- a/mcs/tests/ChangeLog
+++ b/mcs/tests/ChangeLog
@@ -1,3 +1,7 @@
+2003-11-21 Miguel de Icaza <miguel@ximian.com>
+
+ * test-150.cs: Improved test.
+
2003-10-17 Martin Baulig <martin@ximian.com>
* gen-test.sh: Removed.
diff --git a/mcs/tests/Makefile b/mcs/tests/Makefile
index 273028f0702..d2e305f4775 100644
--- a/mcs/tests/Makefile
+++ b/mcs/tests/Makefile
@@ -15,26 +15,26 @@ USE_MCS_FLAGS :=
TEST_SOURCES = \
test-1 test-2 test-3 test-4 test-5 test-6 test-7 test-8 test-9 test-10 \
test-11 test-12 test-13 test-14 test-15 test-16 test-17 test-18 test-19 test-20 \
- test-21 test-22 test-23 test-24 test-25 test-26 test-27 test-29 test-30 \
+ test-21 test-22 test-23 test-24 test-25 test-26 test-27 test-28 test-29 test-30 \
test-31 test-32 test-33 test-34 test-35 test-36 test-37 test-38 test-39 test-40 \
- test-41 test-42 test-43 test-44 test-46 test-47 test-48 test-49 \
- test-51 test-52 test-54 test-55 test-56 test-57 test-59 test-60 \
+ test-41 test-42 test-43 test-44 test-45 test-46 test-47 test-48 test-49 \
+ test-51 test-52 test-53 test-54 test-55 test-56 test-57 test-59 test-60 \
test-61 test-62 test-63 test-64 test-65 test-66 test-68 test-69 test-70 \
test-71 test-72 test-73 test-74 test-75 test-76 test-77 test-78 test-79 test-80 \
test-81 test-82 test-83 test-84 test-85 test-86 test-87 test-88 test-89 test-90 \
- test-92 test-93 test-94 test-95 test-96 test-97 test-98 test-99 test-100\
- test-101 test-103 test-104 test-105 test-108 test-109 test-110\
+ test-91 test-92 test-93 test-94 test-95 test-96 test-97 test-98 test-99 test-100\
+ test-101 test-102 test-103 test-104 test-105 test-106 test-107 test-108 test-109 test-110\
test-111 test-112 test-113 test-114 test-115 test-116 test-117 test-118 test-119 \
- test-121 test-123 test-125 test-126 test-127 test-128 test-129 test-130 \
+ test-121 test-122 test-123 test-125 test-126 test-127 test-128 test-129 test-130 \
test-131 test-134 test-135 test-136 test-137 test-138 test-139 test-140 \
test-141 test-142 test-143 test-144 test-145 test-146 test-147 test-148 test-149 test-150 \
- test-153 test-154 test-155 test-156 test-157 test-158 test-159 test-160 \
+ test-151 test-152 test-153 test-154 test-155 test-156 test-157 test-158 test-159 test-160 \
test-161 test-162 test-163 test-164 test-165 test-166 test-167 test-168 test-169 test-170 \
test-172 test-173 test-174 test-175 test-176 test-177 test-178 test-179 test-180 \
test-181 test-182 test-183 test-184 test-185 test-186 test-187 test-188 test-189 test-190 \
test-191 test-192 test-193 test-194 test-195 test-196 test-197 test-198 test-199 test-200 \
test-201 test-202 test-203 test-204 test-205 test-206 test-207 test-208 test-209 test-210 \
- test-211 test-212 test-213 test-214 test-215 test-216 test-217 test-218
+ test-211 test-212 test-213 test-214 test-215 test-216 test-217 test-218 test-219 test-220
#
# C# 2.0 tests
diff --git a/mcs/tests/README.tests b/mcs/tests/README.tests
index e49e0d5dbac..9915a34e2c4 100644
--- a/mcs/tests/README.tests
+++ b/mcs/tests/README.tests
@@ -394,6 +394,16 @@ Tests delegate creation inside an array; This exposed a bug in the
fact that New is called for DoResolve twice from array initialization.
Bug #48800
+test-219.cs:
+------------
+Tests that we can call typeof(void) in an attribtue delcaration, since
+we removed previously typeof (System.Void) as a valid way of referencing void.
+
+test-220.cs:
+------------
+Test for a bug in foreach, where it would pick the wrong GetEnumerator in a class.
+Bug # was 51446
+
verify-1.cs
-----------
Test whether we do not jump out of the method in a Try/Finally block.
diff --git a/mcs/tests/gen-30.cs b/mcs/tests/gen-30.cs
new file mode 100755
index 00000000000..e5ca71c103a
--- /dev/null
+++ b/mcs/tests/gen-30.cs
@@ -0,0 +1,32 @@
+class Foo<T>
+{
+ public Foo ()
+ { }
+
+ public void Hello (T t)
+ { }
+}
+
+class Bar<T,U> : Foo<U>
+{
+ public Bar ()
+ { }
+
+ public void Test (T t, U u)
+ { }
+}
+
+class X
+{
+ static void Test (Bar<int,string> bar)
+ {
+ bar.Hello ("Test");
+ bar.Test (7, "Hello");
+ }
+
+ static void Main ()
+ {
+ Bar<int,string> bar = new Bar<int,string> ();
+ Test (bar);
+ }
+}
diff --git a/mcs/tests/gen-31-dll.cs b/mcs/tests/gen-31-dll.cs
new file mode 100644
index 00000000000..54f36c9e9d5
--- /dev/null
+++ b/mcs/tests/gen-31-dll.cs
@@ -0,0 +1,11 @@
+public class Foo<T>
+{
+ public void Hello (T t)
+ { }
+}
+
+public class Bar<T,U> : Foo<U>
+{
+ public void Test (T t, U u)
+ { }
+}
diff --git a/mcs/tests/gen-31-exe.cs b/mcs/tests/gen-31-exe.cs
new file mode 100644
index 00000000000..a964ee4f06e
--- /dev/null
+++ b/mcs/tests/gen-31-exe.cs
@@ -0,0 +1,11 @@
+public class X
+{
+ public static void Test (Bar<int,string> bar)
+ {
+ bar.Hello ("Test");
+ bar.Test (7, "Hello");
+ }
+
+ static void Main ()
+ { }
+}
diff --git a/mcs/tests/gen-32.cs b/mcs/tests/gen-32.cs
new file mode 100644
index 00000000000..c289645d6aa
--- /dev/null
+++ b/mcs/tests/gen-32.cs
@@ -0,0 +1,21 @@
+interface Foo<S>
+{
+ void Hello (S s);
+}
+
+interface Bar<T,U> : Foo<U>
+{
+ void Test (T t, U u);
+}
+
+class X
+{
+ static void Test (Bar<int,string> bar)
+ {
+ bar.Hello ("Test");
+ bar.Test (7, "Hello");
+ }
+
+ static void Main ()
+ { }
+}
diff --git a/mcs/tests/gen-33.cs b/mcs/tests/gen-33.cs
new file mode 100644
index 00000000000..ef6c0456353
--- /dev/null
+++ b/mcs/tests/gen-33.cs
@@ -0,0 +1,21 @@
+interface Foo<R,S>
+{
+ void Hello (R r, S s);
+}
+
+interface Bar<T,U,V> : Foo<V,float>
+{
+ void Test (T t, U u, V v);
+}
+
+class X
+{
+ static void Test (Bar<long,int,string> bar)
+ {
+ bar.Hello ("Test", 3.14F);
+ bar.Test (512, 7, "Hello");
+ }
+
+ static void Main ()
+ { }
+}
diff --git a/mcs/tests/gen-34.cs b/mcs/tests/gen-34.cs
new file mode 100644
index 00000000000..e9d31e40e32
--- /dev/null
+++ b/mcs/tests/gen-34.cs
@@ -0,0 +1,14 @@
+class Foo<T>
+{ }
+
+class Stack<T>
+{ }
+
+class Bar<T> : Foo<Stack<T>>
+{ }
+
+class X
+{
+ static void Main ()
+ { }
+}
diff --git a/mcs/tests/gen-test.pl b/mcs/tests/gen-test.pl
index c002e22d19a..f1fbf68fbe6 100755
--- a/mcs/tests/gen-test.pl
+++ b/mcs/tests/gen-test.pl
@@ -6,8 +6,8 @@ my $mono = "mono";
my @normal = qw[gen-1 gen-2 gen-3 gen-4 gen-5 gen-6 gen-7 gen-8 gen-9 gen-10 gen-11 gen-12
gen-14 gen-15 gen-16 gen-18 gen-19 gen-20 gen-21 gen-22 gen-23 gen-24 gen-25
- gen-26 gen-27 gen-28 gen-29];
-my @library = qw[gen-13 gen-17];
+ gen-26 gen-27 gen-28 gen-29 gen-30 gen-32 gen-33 gen-34];
+my @library = qw[gen-13 gen-17 gen-31];
sub RunTest
{
diff --git a/mcs/tests/test-150.cs b/mcs/tests/test-150.cs
index 544d297fa7e..c81aff38239 100644
--- a/mcs/tests/test-150.cs
+++ b/mcs/tests/test-150.cs
@@ -1,8 +1,15 @@
using System;
class T {
+ //
+ // Tests that the following compiles
+
+ uint bar = (uint) int.MaxValue + 1;
+
public static int Main() {
if (Int32.MinValue == 0x80000000)
return 1;
+
+
return 0;
}
}
diff --git a/mcs/tests/test-219.cs b/mcs/tests/test-219.cs
new file mode 100644
index 00000000000..90112f5c335
--- /dev/null
+++ b/mcs/tests/test-219.cs
@@ -0,0 +1,27 @@
+using System;
+
+public class TestAttribute : Attribute {
+ Type type;
+
+ public TestAttribute(Type type)
+ {
+ this.type = type;
+ }
+
+ public Type Type
+ {
+ get { return type; }
+ }
+}
+
+[TestAttribute(typeof(void))]
+public class Test {
+ public static void Main()
+ {
+ object[] attrs =
+ typeof(Test).GetCustomAttributes(typeof(TestAttribute), false);
+ foreach (TestAttribute attr in attrs) {
+ Console.WriteLine("TestAttribute({0})", attr.Type);
+ }
+ }
+}
diff --git a/mcs/tests/test-220.cs b/mcs/tests/test-220.cs
new file mode 100644
index 00000000000..245eb381967
--- /dev/null
+++ b/mcs/tests/test-220.cs
@@ -0,0 +1,124 @@
+//
+// Tests for bug #51446, where MCS did not pick the right enumerator
+// from a class.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Specialized;
+
+namespace MonoBUG
+{
+
+ public class Bug
+ {
+ public static int Main(string[] args)
+ {
+ FooList l = new FooList();
+ Foo f1 = new Foo("First");
+ Foo f2 = new Foo("Second");
+
+ l.Add(f1);
+ l.Add(f2);
+
+ foreach (Foo f in l) {
+ }
+
+ if (FooList.foo_current_called != true)
+ return 1;
+ if (FooList.ienumerator_current_called != false)
+ return 2;
+ Console.WriteLine ("Test passes");
+ return 0;
+ }
+ }
+
+ public class Foo
+ {
+ private string m_name;
+
+ public Foo(string name)
+ {
+ m_name = name;
+ }
+
+ public string Name {
+ get { return m_name; }
+ }
+ }
+
+ [Serializable()]
+ public class FooList : DictionaryBase
+ {
+ public static bool foo_current_called = false;
+ public static bool ienumerator_current_called = false;
+
+ public FooList()
+ {
+ }
+
+ public void Add(Foo value)
+ {
+ Dictionary.Add(value.Name, value);
+ }
+
+ public new FooEnumerator GetEnumerator()
+ {
+ return new FooEnumerator(this);
+ }
+
+ public class FooEnumerator : object, IEnumerator
+ {
+
+ private IEnumerator baseEnumerator;
+
+ private IEnumerable temp;
+
+ public FooEnumerator(FooList mappings)
+ {
+ this.temp = (IEnumerable) (mappings);
+ this.baseEnumerator = temp.GetEnumerator();
+ }
+
+ public Foo Current
+ {
+ get
+ {
+ Console.WriteLine("Foo Current()");
+ foo_current_called = true;
+ return (Foo) ((DictionaryEntry) (baseEnumerator.Current)).Value;
+ }
+ }
+
+ object IEnumerator.Current
+ {
+ get
+ {
+ Console.WriteLine("object IEnumerator.Current()");
+ ienumerator_current_called = true;
+ return baseEnumerator.Current;
+ }
+ }
+
+ public bool MoveNext()
+ {
+ return baseEnumerator.MoveNext();
+ }
+
+ bool IEnumerator.MoveNext()
+ {
+ return baseEnumerator.MoveNext();
+ }
+
+ public void Reset()
+ {
+ baseEnumerator.Reset();
+ }
+
+ void IEnumerator.Reset()
+ {
+ baseEnumerator.Reset();
+ }
+ }
+ }
+}
diff --git a/mcs/tests/verify-5.cs b/mcs/tests/verify-5.cs
index 9a2bc27e519..8ddf88f6c2c 100644
--- a/mcs/tests/verify-5.cs
+++ b/mcs/tests/verify-5.cs
@@ -47,5 +47,19 @@ class T {
;
}
+ // Another case of goto that we did not handle properly
+ static void XXXA () {
+ goto each_logic_expr;
+
+ int j;
+ bool x = true;
+ try {
+ }
+ catch {}
+ int dd;
+ each_logic_expr:
+ ;
+ }
+
static void Main() {}
}
diff --git a/mcs/tests/verify-6.cs b/mcs/tests/verify-6.cs
index a776fbc14a4..c5638962762 100644
--- a/mcs/tests/verify-6.cs
+++ b/mcs/tests/verify-6.cs
@@ -20,5 +20,9 @@ class X
Bar bar = (Bar) se;
Foo blah = (Foo) obj1;
+
+ Enum Ea = Foo.A;
+
+ IConvertible iconv = Ea;
}
}
diff --git a/mcs/tools/SqlSharp/gui/gtk-sharp/ChangeLog b/mcs/tools/SqlSharp/gui/gtk-sharp/ChangeLog
index 2a56a6eb8b2..ad3616eb0b2 100644
--- a/mcs/tools/SqlSharp/gui/gtk-sharp/ChangeLog
+++ b/mcs/tools/SqlSharp/gui/gtk-sharp/ChangeLog
@@ -1,3 +1,10 @@
+2003-11-13 Pedro Martínez Juliá <yoros@wanadoo.es>
+
+ * LoginDialog.cs
+ * SqlEditorSharp.cs
+ * sqlsharpgtk.cs: Updated to the new changes in gtk-sharp
+ library.
+
2003-10-16 Daniel Morgan <danielmorgan@verizon.net>
* Makefile
diff --git a/mcs/tools/SqlSharp/gui/gtk-sharp/LoginDialog.cs b/mcs/tools/SqlSharp/gui/gtk-sharp/LoginDialog.cs
index 9f26963d23e..e74c07ad7d5 100755
--- a/mcs/tools/SqlSharp/gui/gtk-sharp/LoginDialog.cs
+++ b/mcs/tools/SqlSharp/gui/gtk-sharp/LoginDialog.cs
@@ -74,13 +74,13 @@ namespace Mono.Data.SqlSharp.Gui.GtkSharp
dialog.VBox.PackStart (frame, true, true, 0);
Button button = null;
- button = Button.NewFromStock (Stock.Ok);
+ button = new Button(Stock.Ok);
button.Clicked += new EventHandler (Connect_Action);
button.CanDefault = true;
dialog.ActionArea.PackStart (button, true, true, 0);
button.GrabDefault ();
- button = Button.NewFromStock (Stock.Cancel);
+ button = new Button(Stock.Cancel);
button.Clicked += new EventHandler (Dialog_Cancel);
dialog.ActionArea.PackStart (button, true, true, 0);
dialog.Modal = true;
diff --git a/mcs/tools/SqlSharp/gui/gtk-sharp/SqlEditorSharp.cs b/mcs/tools/SqlSharp/gui/gtk-sharp/SqlEditorSharp.cs
index 6b0af0971bb..afad1c3176a 100755
--- a/mcs/tools/SqlSharp/gui/gtk-sharp/SqlEditorSharp.cs
+++ b/mcs/tools/SqlSharp/gui/gtk-sharp/SqlEditorSharp.cs
@@ -172,8 +172,9 @@ namespace SqlEditorSharp
SqlSharpGtk.DebugWriteLine ("[[[[[ Syntax Hi-Light Text BEGIN ]]]]]");
- if (use_hi_lighting == true)
+ if (use_hi_lighting == true) {
SyntaxHiLightText ();
+ }
SqlSharpGtk.DebugWriteLine ("[[[[[ Syntax Hi-Light Text END ]]]]]\n");
}
@@ -250,7 +251,7 @@ namespace SqlEditorSharp
match_start2 = start_iter; // dummy
match_end2 = end_iter; // dummy
- while (start_iter.IsEnd() == false) {
+ while (start_iter.IsEnd == false) {
// FIXME: match_start1, match_end1, end_iter
// need to be set to have ref in front
// Problem with TextIter's ForwardSearch()
@@ -376,7 +377,7 @@ namespace SqlEditorSharp
// look for singled quoted constants
// and keywords
if (hyphen < 2) {
- if (start_iter.IsEnd() == true)
+ if (start_iter.IsEnd == true)
break; // break out of for loop
start_word = -1;
@@ -414,7 +415,7 @@ namespace SqlEditorSharp
match_start1 = start_iter;
match_end1 = start_iter;
- if (match_end1.IsEnd () == true)
+ if (match_end1.IsEnd == true)
break;
if (CharHasTag (start_iter,
diff --git a/mcs/tools/SqlSharp/gui/gtk-sharp/sqlsharpgtk.cs b/mcs/tools/SqlSharp/gui/gtk-sharp/sqlsharpgtk.cs
index 17a899e8331..bb5fd6505b9 100755
--- a/mcs/tools/SqlSharp/gui/gtk-sharp/sqlsharpgtk.cs
+++ b/mcs/tools/SqlSharp/gui/gtk-sharp/sqlsharpgtk.cs
@@ -154,6 +154,7 @@ namespace Mono.Data.SqlSharp.Gui.GtkSharp
{
SqlEditorSharp editor;
editor = new SqlEditorSharp ();
+ editor.UseSyntaxHiLighting = true;
editor.View.Show ();
editor.View.KeyPressEvent +=
new GtkSharp.KeyPressEventHandler(OnKeyPressEventKey);
diff --git a/mcs/tools/corcompare/ChangeLog b/mcs/tools/corcompare/ChangeLog
index 5cd3470001d..5b882d377f5 100644
--- a/mcs/tools/corcompare/ChangeLog
+++ b/mcs/tools/corcompare/ChangeLog
@@ -1,16 +1,67 @@
+2003-11-14 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * mono-api.xsl: handle <interface>, which is different from
+ <class name="x" type="interface"...>.
+
+2003-11-14 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * mono-api-diff.cs: added a couple of missing attributes for extra
+ classes.
+
+2003-11-13 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * mono-api-diff.cs: ensure no nested type gets in as non-nested.
+ (May be a bug in MS?). Added ptype and params attributes for properties.
+
+ * mono-api-info.cs: fixed some cases where there's a name duplication
+ (multiple attributes, properties). Fixed completion counters.
+
+2003-11-12 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * mono-api-diff.cs: fixed attribute handling for members. Fixed counts
+ for properties.
+ * mono-api-info.cs: don't output .cctor information.
+
+2003-11-11 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * mono-api-diff.cs: fixed nullref and add warning when class type do not
+ match.
+
+ * mono-api-info.cs: ignore private classes.
+
+2003-11-11 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * CorCompare.exe.sources: not needed now.
+
+ * Makefile: updated to build the 3 exes we have now.
+
+ * mono-api-info.cs: new program. Given an assembly name, it generates
+ an xml file with its public data.
+
+ * mono-api-diff.cs: compares 2 xml files generated with mono-api-info
+ and outputs an xml file suitable for building class status pages with
+ mono-api.xsl.
+
+ * mono-api.xsl: small modifications to corcompare.xsl to match the new
+ file format.
+
2003-07-12 Andreas Nahr <ClassDevelopment@A-SoftTech.com>
- * cormissing.xsl: Change percentage to display percentage for all sub-members, not just direct members
+ * cormissing.xsl: Change percentage to display percentage for all
+ sub-members, not just direct members
2003-07-12 Andreas Nahr <ClassDevelopment@A-SoftTech.com>
- * MissingNameSpace.cs: Fixed the case where a private/ internal class that per chance has a class with the same name
- in the compared assembly gets compared -> now only public classes are compared.
- * MissingType: Internal nested types were always compared -> internal nested types are never compared
+ * MissingNameSpace.cs: Fixed the case where a private/ internal class
+ that per chance has a class with the same name in the compared
+ assembly gets compared -> now only public classes are compared.
+ * MissingType: Internal nested types were always compared -> internal
+ nested types are never compared
+
+2002-02-25 Nick Drochak <ndrochak@gol.com>
+
+ * ToDoAssembly.cs: remove unused code
+ * ToDoNamespace.cs: using BindingFlags for GetMembers
+ * ToDoType.cs: throw exception if we encounter a member type
+ that we didn't expect. Also remove unused property.
-2002-02-25 Nick Drochak <ndrochak@gol.com>
-
- * ToDoAssembly.cs: remove unused code
- * ToDoNamespace.cs: using BindingFlags for GetMembers
- * ToDoType.cs: throw exception if we encounter a member type
- that we didn't expect. Also remove unused property. \ No newline at end of file
diff --git a/mcs/tools/corcompare/CorCompare.exe.sources b/mcs/tools/corcompare/CorCompare.exe.sources
deleted file mode 100644
index de21228d001..00000000000
--- a/mcs/tools/corcompare/CorCompare.exe.sources
+++ /dev/null
@@ -1,15 +0,0 @@
-CompletionInfo.cs
-CorCompare.cs
-MissingAttribute.cs
-MissingBase.cs
-MissingConstructor.cs
-MissingEvent.cs
-MissingField.cs
-MissingInterface.cs
-MissingMember.cs
-MissingMethod.cs
-MissingNameSpace.cs
-MissingNestedType.cs
-MissingProperty.cs
-MissingType.cs
-ToDoAssembly.cs
diff --git a/mcs/tools/corcompare/Makefile b/mcs/tools/corcompare/Makefile
index 30533c1d242..d73c82ed68b 100644
--- a/mcs/tools/corcompare/Makefile
+++ b/mcs/tools/corcompare/Makefile
@@ -2,7 +2,58 @@ thisdir = tools/corcompare
SUBDIRS =
include ../../build/rules.make
-PROGRAM = CorCompare.exe
-EXTRA_DISTFILES = cormissing.xsl TODO transform.js
+ALL_PROGRAMS = CorCompare.exe mono-api-info.exe mono-api-diff.exe
+EXTRA_DISTFILES = cormissing.xsl TODO transform.js mono-api.xsl
+CORCOMPARE_SOURCES = \
+ CompletionInfo.cs \
+ CorCompare.cs \
+ MissingAttribute.cs \
+ MissingBase.cs \
+ MissingConstructor.cs \
+ MissingEvent.cs \
+ MissingField.cs \
+ MissingInterface.cs \
+ MissingMember.cs \
+ MissingMethod.cs \
+ MissingNameSpace.cs \
+ MissingNestedType.cs \
+ MissingProperty.cs \
+ MissingType.cs \
+ ToDoAssembly.cs
+
+APIINFO_SOURCES = mono-api-info.cs
+APIDIFF_SOURCES = mono-api-diff.cs
+
+DISTFILES= $(CORCOMPARE_SOURCES) $(APIINFO_SOURCES) $(APIDIFF_SOURCES)
+
+all-local: $(ALL_PROGRAMS)
+
+install-local: $(ALL_PROGRAMS)
+ $(MKINSTALLDIRS) $(DESTDIR)$(prefix)/bin
+ for i in $(ALL_PROGRAMS) ; do \
+ $(INSTALL_BIN) $$i $(DESTDIR)$(prefix)/bin ; \
+ done
+
+uninstall-local:
+ for i in $(ALL_PROGRAMS) ; do \
+ rm -f $(DESTDIR)$(prefix)/bin/$$i ; \
+ done
+
+test-local:
+
+run-test-local:
+
+clean-local:
+ rm -f *.exe *.pdb
+
+dist-local: dist-default
+
+CorCompare.exe: $(CORCOMPARE_SOURCES)
+ $(CSCOMPILE) -out:$@ $^
+
+mono-api-info.exe: $(APIINFO_SOURCES)
+ $(CSCOMPILE) -out:$@ $^
+
+mono-api-diff.exe: $(APIDIFF_SOURCES)
+ $(CSCOMPILE) -out:$@ $^
-include ../../build/executable.make
diff --git a/mcs/tools/corcompare/mono-api-diff.cs b/mcs/tools/corcompare/mono-api-diff.cs
new file mode 100644
index 00000000000..e4924529ddd
--- /dev/null
+++ b/mcs/tools/corcompare/mono-api-diff.cs
@@ -0,0 +1,1220 @@
+//
+// acompare.cs
+//
+// Authors:
+// Gonzalo Paniagua Javier (gonzalo@ximian.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+using System.Collections;
+using System.IO;
+using System.Reflection;
+using System.Text;
+using System.Xml;
+
+namespace Mono.AssemblyCompare
+{
+ class Driver
+ {
+ static int Main (string [] args)
+ {
+ if (args.Length != 2)
+ return 1;
+
+ XMLAssembly ms = CreateXMLAssembly (args [0]);
+ XMLAssembly mono = CreateXMLAssembly (args [1]);
+ XmlDocument doc = ms.CompareAndGetDocument (mono);
+
+ XmlTextWriter writer = new XmlTextWriter (Console.Out);
+ writer.Formatting = Formatting.Indented;
+ doc.WriteTo (writer);
+
+ return 0;
+ }
+
+ static XMLAssembly CreateXMLAssembly (string file)
+ {
+ XmlDocument doc = new XmlDocument ();
+ doc.Load (File.OpenRead (file));
+
+ XmlNode node = doc.SelectSingleNode ("/assemblies/assembly");
+ XMLAssembly result = new XMLAssembly ();
+ try {
+ result.LoadData (node);
+ } catch (Exception e) {
+ Console.Error.WriteLine ("Error loading {0}: {1}\n{2}", file, e.Message, e);
+ Environment.Exit (1);
+ }
+
+ return result;
+ }
+ }
+
+ class Counters
+ {
+ public int Present;
+ public int PresentTotal;
+ public int Missing;
+ public int MissingTotal;
+ public int Todo;
+ public int TodoTotal;
+
+ public int Extra;
+ public int ExtraTotal;
+ public int Warning;
+ public int WarningTotal;
+ public int ErrorTotal;
+
+ public Counters ()
+ {
+ }
+
+ public void AddPartialToPartial (Counters other)
+ {
+ Present += other.Present;
+ Extra += other.Extra;
+ Missing += other.Missing;
+
+ Todo += other.Todo;
+ Warning += other.Warning;
+ AddPartialToTotal (other);
+ }
+
+ public void AddPartialToTotal (Counters other)
+ {
+ PresentTotal += other.Present;
+ ExtraTotal += other.Extra;
+ MissingTotal += other.Missing;
+
+ TodoTotal += other.Todo;
+ WarningTotal += other.Warning;
+ }
+
+ public void AddTotalToPartial (Counters other)
+ {
+ Present += other.PresentTotal;
+ Extra += other.ExtraTotal;
+ Missing += other.MissingTotal;
+
+ Todo += other.TodoTotal;
+ Warning += other.WarningTotal;
+ AddTotalToTotal (other);
+ }
+
+ public void AddTotalToTotal (Counters other)
+ {
+ PresentTotal += other.PresentTotal;
+ ExtraTotal += other.ExtraTotal;
+ MissingTotal += other.MissingTotal;
+
+ TodoTotal += other.TodoTotal;
+ WarningTotal += other.WarningTotal;
+ ErrorTotal += other.ErrorTotal;
+ }
+
+ public int Total {
+ get { return Present + Missing; }
+ }
+
+ public int AbsTotal {
+ get { return PresentTotal + MissingTotal; }
+ }
+
+ public int Ok {
+ get { return Present - Todo; }
+ }
+
+ public int OkTotal {
+ get { return PresentTotal - TodoTotal - ErrorTotal; }
+ }
+
+ public override string ToString ()
+ {
+ StringWriter sw = new StringWriter ();
+ sw.WriteLine ("Present: {0}", Present);
+ sw.WriteLine ("PresentTotal: {0}", PresentTotal);
+ sw.WriteLine ("Missing: {0}", Missing);
+ sw.WriteLine ("MissingTotal: {0}", MissingTotal);
+ sw.WriteLine ("Todo: {0}", Todo);
+ sw.WriteLine ("TodoTotal: {0}", TodoTotal);
+ sw.WriteLine ("Extra: {0}", Extra);
+ sw.WriteLine ("ExtraTotal: {0}", ExtraTotal);
+ sw.WriteLine ("Warning: {0}", Warning);
+ sw.WriteLine ("WarningTotal: {0}", WarningTotal);
+ sw.WriteLine ("ErrorTotal: {0}", ErrorTotal);
+ sw.WriteLine ("--");
+ return sw.GetStringBuilder ().ToString ();
+ }
+ }
+
+ abstract class XMLData
+ {
+ protected XmlDocument document;
+ protected Counters counters;
+ bool haveWarnings;
+
+ public XMLData ()
+ {
+ counters = new Counters ();
+ }
+
+ public virtual void LoadData (XmlNode node)
+ {
+ }
+
+ protected object [] LoadRecursive (XmlNodeList nodeList, Type type)
+ {
+ ArrayList list = new ArrayList ();
+ foreach (XmlNode node in nodeList) {
+ XMLData data = (XMLData) Activator.CreateInstance (type);
+ data.LoadData (node);
+ list.Add (data);
+ }
+
+ return (object []) list.ToArray (type);
+ }
+
+ protected void AddAttribute (XmlNode node, string name, string value)
+ {
+ XmlAttribute attr = document.CreateAttribute (name);
+ attr.Value = value;
+ node.Attributes.Append (attr);
+ }
+
+ protected void AddExtra (XmlNode node)
+ {
+ //TODO: count all the subnodes?
+ AddAttribute (node, "presence", "extra");
+ AddAttribute (node, "ok", "1");
+ AddAttribute (node, "ok_total", "1");
+ AddAttribute (node, "extra", "1");
+ AddAttribute (node, "extra_total", "1");
+ }
+
+ public void AddCountersAttributes (XmlNode node)
+ {
+ if (counters.Missing > 0)
+ AddAttribute (node, "missing", counters.Missing.ToString ());
+
+ if (counters.Present > 0)
+ AddAttribute (node, "present", counters.Present.ToString ());
+
+ if (counters.Extra > 0)
+ AddAttribute (node, "extra", counters.Extra.ToString ());
+
+ if (counters.Ok > 0)
+ AddAttribute (node, "ok", counters.Ok.ToString ());
+
+ if (counters.Total > 0) {
+ int percent = (100 * counters.Ok / counters.Total);
+ AddAttribute (node, "complete", percent.ToString ());
+ }
+
+ if (counters.Todo > 0)
+ AddAttribute (node, "todo", counters.Todo.ToString ());
+
+ if (counters.Warning > 0)
+ AddAttribute (node, "warning", counters.Warning.ToString ());
+
+ if (counters.MissingTotal > 0)
+ AddAttribute (node, "missing_total", counters.MissingTotal.ToString ());
+
+ if (counters.PresentTotal > 0)
+ AddAttribute (node, "present_total", counters.PresentTotal.ToString ());
+
+ if (counters.ExtraTotal > 0)
+ AddAttribute (node, "extra_total", counters.ExtraTotal.ToString ());
+
+ if (counters.OkTotal > 0)
+ AddAttribute (node, "ok_total", counters.OkTotal.ToString ());
+
+ if (counters.AbsTotal > 0) {
+ int percent = (100 * counters.OkTotal / counters.AbsTotal);
+ AddAttribute (node, "complete_total", percent.ToString ());
+ }
+
+ if (counters.TodoTotal > 0) {
+ AddAttribute (node, "todo_total", counters.TodoTotal.ToString ());
+ //TODO: should be different on error. check error cases in corcompare.
+ AddAttribute (node, "error_total", counters.Todo.ToString ());
+ }
+
+ if (counters.WarningTotal > 0)
+ AddAttribute (node, "warning_total", counters.WarningTotal.ToString ());
+
+ }
+
+ protected void AddWarning (XmlNode parent, string fmt, params object [] args)
+ {
+ counters.Warning++;
+ haveWarnings = true;
+ XmlNode warnings = parent.SelectSingleNode ("warnings");
+ if (warnings == null) {
+ warnings = document.CreateElement ("warnings", null);
+ parent.AppendChild (warnings);
+ }
+
+ AddAttribute (parent, "error", "warning");
+ XmlNode warning = document.CreateElement ("warnings", null);
+ AddAttribute (warning, "text", String.Format (fmt, args));
+ warnings.AppendChild (warning);
+ }
+
+ public bool HaveWarnings {
+ get { return haveWarnings; }
+ }
+
+ public Counters Counters {
+ get { return counters; }
+ }
+
+ public abstract void CompareTo (XmlDocument doc, XmlNode parent, object other);
+ }
+
+ abstract class XMLNameGroup : XMLData
+ {
+ protected XmlNode group;
+ protected Hashtable keys;
+
+ public override void LoadData (XmlNode node)
+ {
+ if (node == null)
+ throw new ArgumentNullException ("node");
+
+ if (node.Name != GroupName)
+ throw new FormatException (String.Format ("Expecting <{0}>", GroupName));
+
+ keys = new Hashtable ();
+ foreach (XmlNode n in node.ChildNodes) {
+ string name = n.Attributes ["name"].Value;
+ if (CheckIfAdd (name)) {
+ string key = GetNodeKey (name, n);
+ keys.Add (key, name);
+ if (n.HasChildNodes)
+ LoadExtraData (key, n.FirstChild);
+ }
+ }
+ }
+
+ protected virtual bool CheckIfAdd (string value)
+ {
+ return true;
+ }
+
+ protected virtual void LoadExtraData (string name, XmlNode node)
+ {
+ }
+
+ public override void CompareTo (XmlDocument doc, XmlNode parent, object other)
+ {
+ this.document = doc;
+ if (group == null)
+ group = doc.CreateElement (GroupName, null);
+
+ Hashtable okeys = null;
+ if (other != null && ((XMLNameGroup) other).keys != null) {
+ okeys = ((XMLNameGroup) other).keys;
+ }
+
+ XmlNode node = null;
+ bool onull = (okeys == null);
+ if (keys != null) {
+ foreach (DictionaryEntry entry in keys) {
+ node = doc.CreateElement (Name, null);
+ group.AppendChild (node);
+ string key = (string) entry.Key;
+ string name = (string) entry.Value;
+ AddAttribute (node, "name", name);
+
+ if (!onull && HasKey (key, okeys)) {
+ CompareToInner (key, node, (XMLNameGroup) other);
+ okeys.Remove (key);
+ counters.Present++;
+ } else {
+ AddAttribute (node, "presence", "missing");
+ counters.Missing++;
+ }
+ }
+ }
+
+ if (!onull && okeys.Count != 0) {
+ foreach (string value in okeys.Values) {
+ node = doc.CreateElement (Name, null);
+ AddAttribute (node, "name", (string) value);
+ AddAttribute (node, "presence", "extra");
+ group.AppendChild (node);
+ counters.Extra++;
+ }
+ }
+
+ if (group.HasChildNodes)
+ parent.AppendChild (group);
+ }
+
+ protected virtual void CompareToInner (string name, XmlNode node, XMLNameGroup other)
+ {
+ }
+
+ public virtual string GetNodeKey (string name, XmlNode node)
+ {
+ return name;
+ }
+
+ public virtual bool HasKey (string key, Hashtable other)
+ {
+ return other.ContainsKey (key);
+ }
+
+ public abstract string GroupName { get; }
+ public abstract string Name { get; }
+ }
+
+ class XMLAssembly : XMLData
+ {
+ XMLAttributes attributes;
+ XMLNamespace [] namespaces;
+ string name;
+ string version;
+
+ public override void LoadData (XmlNode node)
+ {
+ if (node == null)
+ throw new ArgumentNullException ("node");
+
+ name = node.Attributes ["name"].Value;
+ version = node.Attributes ["version"].Value;
+ XmlNode atts = node.FirstChild;
+ attributes = new XMLAttributes ();
+ if (atts.Name == "attributes") {
+ attributes.LoadData (atts);
+ atts = atts.NextSibling;
+ }
+
+ if (atts == null || atts.Name != "namespaces") {
+ Console.Error.WriteLine ("Warning: no namespaces found!");
+ return;
+ }
+
+ namespaces = (XMLNamespace []) LoadRecursive (atts.ChildNodes, typeof (XMLNamespace));
+ }
+
+ public override void CompareTo (XmlDocument doc, XmlNode parent, object other)
+ {
+ XMLAssembly assembly = (XMLAssembly) other;
+
+ XmlNode childA = doc.CreateElement ("assembly", null);
+ AddAttribute (childA, "name", name);
+ AddAttribute (childA, "version", version);
+ if (name != assembly.name)
+ AddWarning (childA, "Assembly names not equal: {0}, {1}", name, assembly.name);
+
+ if (version != assembly.version)
+ AddWarning (childA, "Assembly version not equal: {0}, {1}", version, assembly.version);
+
+ parent.AppendChild (childA);
+
+ attributes.CompareTo (doc, childA, assembly.attributes);
+ counters.AddPartialToPartial (attributes.Counters);
+
+ CompareNamespaces (childA, assembly.namespaces);
+ if (assembly.attributes != null && assembly.attributes.IsTodo) {
+ counters.Todo++;
+ counters.TodoTotal++;
+ counters.ErrorTotal++;
+ AddAttribute (childA, "error", "todo");
+ }
+
+ AddCountersAttributes (childA);
+ }
+
+ void CompareNamespaces (XmlNode parent, XMLNamespace [] other)
+ {
+ ArrayList newNS = new ArrayList ();
+ XmlNode group = document.CreateElement ("namespaces", null);
+ parent.AppendChild (group);
+
+ Hashtable oh = CreateHash (other);
+ XmlNode node = null;
+ int count = (namespaces == null) ? 0 : namespaces.Length;
+ for (int i = 0; i < count; i++) {
+ XMLNamespace xns = namespaces [i];
+
+ node = document.CreateElement ("namespace", null);
+ newNS.Add (node);
+ AddAttribute (node, "name", xns.Name);
+
+ if (oh.ContainsKey (xns.Name)) {
+ int idx = (int) oh [xns.Name];
+ xns.CompareTo (document, node, other [idx]);
+ other [idx] = null;
+ xns.AddCountersAttributes (node);
+ counters.Present++;
+ counters.PresentTotal++;
+ counters.AddPartialToTotal (xns.Counters);
+ } else {
+ AddAttribute (node, "presence", "missing");
+ counters.Missing++;
+ counters.MissingTotal++;
+ }
+ }
+
+ if (other != null) {
+ count = other.Length;
+ for (int i = 0; i < count; i++) {
+ XMLNamespace n = other [i];
+ if (n == null)
+ continue;
+
+ node = document.CreateElement ("namespace", null);
+ newNS.Add (node);
+ AddAttribute (node, "name", n.Name);
+ AddExtra (node);
+ counters.ExtraTotal++;
+ }
+ }
+
+ XmlNode [] nodes = (XmlNode []) newNS.ToArray (typeof (XmlNode));
+ Array.Sort (nodes, XmlNodeComparer.Default);
+ foreach (XmlNode nn in nodes)
+ group.AppendChild (nn);
+ }
+
+ static Hashtable CreateHash (XMLNamespace [] other)
+ {
+ Hashtable result = new Hashtable ();
+ if (other != null) {
+ int i = 0;
+ foreach (XMLNamespace n in other) {
+ result [n.Name] = i++;
+ }
+ }
+
+ return result;
+ }
+
+ public XmlDocument CompareAndGetDocument (XMLAssembly other)
+ {
+ XmlDocument doc = new XmlDocument ();
+ this.document = doc;
+ XmlNode parent = doc.CreateElement ("assemblies", null);
+ doc.AppendChild (parent);
+
+ CompareTo (doc, parent, other);
+
+ XmlNode decl = doc.CreateXmlDeclaration ("1.0", null, null);
+ doc.InsertBefore (decl, doc.DocumentElement);
+
+ return doc;
+ }
+ }
+
+ class XMLNamespace : XMLData
+ {
+ string name;
+ XMLClass [] types;
+
+ public override void LoadData (XmlNode node)
+ {
+ if (node == null)
+ throw new ArgumentNullException ("node");
+
+ if (node.Name != "namespace")
+ throw new FormatException ("Expecting <namespace>");
+
+ name = node.Attributes ["name"].Value;
+ XmlNode classes = node.FirstChild;
+ if (classes == null) {
+ Console.Error.WriteLine ("Warning: no classes for {0}", node.Attributes ["name"]);
+ return;
+ }
+
+ if (classes.Name != "classes")
+ throw new FormatException ("Expecting <classes>. Got <" + classes.Name + ">");
+
+ types = (XMLClass []) LoadRecursive (classes.ChildNodes, typeof (XMLClass));
+ }
+
+ public override void CompareTo (XmlDocument doc, XmlNode parent, object other)
+ {
+ this.document = doc;
+ XMLNamespace nspace = (XMLNamespace) other;
+
+ XmlNode childA = doc.CreateElement ("classes", null);
+ parent.AppendChild (childA);
+
+ CompareTypes (childA, nspace.types);
+ }
+
+ void CompareTypes (XmlNode parent, XMLClass [] other)
+ {
+ ArrayList newNodes = new ArrayList ();
+ Hashtable oh = CreateHash (other);
+ XmlNode node = null;
+ int count = (types == null) ? 0 : types.Length;
+ for (int i = 0; i < count; i++) {
+ XMLClass xclass = types [i];
+
+ node = document.CreateElement ("class", null);
+ newNodes.Add (node);
+ AddAttribute (node, "name", xclass.Name);
+ AddAttribute (node, "type", xclass.Type);
+
+ if (oh.ContainsKey (xclass.Name)) {
+ int idx = (int) oh [xclass.Name];
+ xclass.CompareTo (document, node, other [idx]);
+ other [idx] = null;
+ counters.AddPartialToPartial (xclass.Counters);
+ } else {
+ AddAttribute (node, "presence", "missing");
+ counters.Missing++;
+ counters.MissingTotal++;
+ }
+ }
+
+ if (other != null) {
+ count = other.Length;
+ for (int i = 0; i < count; i++) {
+ XMLClass c = other [i];
+ if (c == null || c.Name == "MonoTODOAttribute")
+ continue;
+
+ node = document.CreateElement ("class", null);
+ newNodes.Add (node);
+ AddAttribute (node, "name", c.Name);
+ AddAttribute (node, "type", c.Type);
+ AddExtra (node);
+ counters.Extra++;
+ counters.ExtraTotal++;
+ }
+ }
+
+ XmlNode [] nodes = (XmlNode []) newNodes.ToArray (typeof (XmlNode));
+ Array.Sort (nodes, XmlNodeComparer.Default);
+ foreach (XmlNode nn in nodes)
+ parent.AppendChild (nn);
+ }
+
+ static Hashtable CreateHash (XMLClass [] other)
+ {
+ Hashtable result = new Hashtable ();
+ if (other != null) {
+ int i = 0;
+ foreach (XMLClass c in other) {
+ result [c.Name] = i++;
+ }
+ }
+
+ return result;
+ }
+
+ public string Name {
+ get { return name; }
+ }
+ }
+
+ class XMLClass : XMLData
+ {
+ string name;
+ string type;
+ string baseName;
+ bool isSealed;
+ XMLAttributes attributes;
+ XMLInterfaces interfaces;
+ XMLFields fields;
+ XMLConstructors constructors;
+ XMLProperties properties;
+ XMLEvents events;
+ XMLMethods methods;
+ XMLClass [] nested;
+
+ public override void LoadData (XmlNode node)
+ {
+ if (node == null)
+ throw new ArgumentNullException ("node");
+
+ name = node.Attributes ["name"].Value;
+ type = node.Attributes ["type"].Value;
+ XmlAttribute xatt = node.Attributes ["base"];
+ if (xatt != null)
+ baseName = xatt.Value;
+
+ xatt = node.Attributes ["sealed"];
+ isSealed = (xatt != null && xatt.Value == "true");
+
+ XmlNode child = node.FirstChild;
+ if (child == null) {
+ // Console.Error.WriteLine ("Empty class {0} {1}", name, type);
+ return;
+ }
+
+ if (child.Name == "attributes") {
+ attributes = new XMLAttributes ();
+ attributes.LoadData (child);
+ child = child.NextSibling;
+ }
+
+ if (child != null && child.Name == "interfaces") {
+ interfaces = new XMLInterfaces ();
+ interfaces.LoadData (child);
+ child = child.NextSibling;
+ }
+
+ if (child != null && child.Name == "fields") {
+ fields = new XMLFields ();
+ fields.LoadData (child);
+ child = child.NextSibling;
+ }
+
+ if (child != null && child.Name == "constructors") {
+ constructors = new XMLConstructors ();
+ constructors.LoadData (child);
+ child = child.NextSibling;
+ }
+
+ if (child != null && child.Name == "properties") {
+ properties = new XMLProperties ();
+ properties.LoadData (child);
+ child = child.NextSibling;
+ }
+
+ if (child != null && child.Name == "events") {
+ events = new XMLEvents ();
+ events.LoadData (child);
+ child = child.NextSibling;
+ }
+
+ if (child != null && child.Name == "methods") {
+ methods = new XMLMethods ();
+ methods.LoadData (child);
+ child = child.NextSibling;
+ }
+
+ if (child == null)
+ return;
+
+ if (child.Name != "classes") {
+ Console.WriteLine ("name: {0} type: {1} {2}", name, type, child.NodeType);
+ throw new FormatException ("Expecting <classes>. Got <" + child.Name + ">");
+ }
+
+ nested = (XMLClass []) LoadRecursive (child.ChildNodes, typeof (XMLClass));
+ }
+
+ public override void CompareTo (XmlDocument doc, XmlNode parent, object other)
+ {
+ this.document = doc;
+ XMLClass oclass = (XMLClass) other;
+
+ if (attributes != null || oclass.attributes != null) {
+ if (attributes == null)
+ attributes = new XMLAttributes ();
+
+ attributes.CompareTo (doc, parent, oclass.attributes);
+ counters.AddPartialToPartial (attributes.Counters);
+ if (oclass.attributes != null && oclass.attributes.IsTodo) {
+ counters.Todo++;
+ counters.TodoTotal++;
+ counters.ErrorTotal++;
+ AddAttribute (parent, "error", "todo");
+ }
+ }
+
+ if (type != oclass.type)
+ AddWarning (parent, "Class type is wrong: {0} != {1}", type, oclass.type);
+
+ if (baseName != oclass.baseName)
+ AddWarning (parent, "Base class is wrong: {0} != {1}", baseName, oclass.baseName);
+
+ if (isSealed != oclass.isSealed)
+ AddWarning (parent, "Should {0}be sealed", isSealed ? "" : "not ");
+
+ if (interfaces != null || oclass.interfaces != null) {
+ if (interfaces == null)
+ interfaces = new XMLInterfaces ();
+
+ interfaces.CompareTo (doc, parent, oclass.interfaces);
+ counters.AddPartialToPartial (interfaces.Counters);
+ }
+
+ if (fields != null || oclass.fields != null) {
+ if (fields == null)
+ fields = new XMLFields ();
+
+ fields.CompareTo (doc, parent, oclass.fields);
+ counters.AddPartialToPartial (fields.Counters);
+ }
+
+ if (constructors != null || oclass.constructors != null) {
+ if (constructors == null)
+ constructors = new XMLConstructors ();
+
+ constructors.CompareTo (doc, parent, oclass.constructors);
+ counters.AddPartialToPartial (constructors.Counters);
+ }
+
+ if (properties != null || oclass.properties != null) {
+ if (properties == null)
+ properties = new XMLProperties ();
+
+ properties.CompareTo (doc, parent, oclass.properties);
+ counters.AddPartialToPartial (properties.Counters);
+ }
+
+ if (events != null || oclass.events != null) {
+ if (events == null)
+ events = new XMLEvents ();
+
+ events.CompareTo (doc, parent, oclass.events);
+ counters.AddPartialToPartial (events.Counters);
+ }
+
+ if (methods != null || oclass.methods != null) {
+ if (methods == null)
+ methods = new XMLMethods ();
+
+ methods.CompareTo (doc, parent, oclass.methods);
+ counters.AddPartialToPartial (methods.Counters);
+ }
+
+ if (nested != null || oclass.nested != null) {
+ XmlNode n = doc.CreateElement ("classes", null);
+ parent.AppendChild (n);
+ CompareTypes (n, oclass.nested);
+ }
+
+ AddCountersAttributes (parent);
+ }
+
+ void CompareTypes (XmlNode parent, XMLClass [] other)
+ {
+ ArrayList newNodes = new ArrayList ();
+ Hashtable oh = CreateHash (other);
+ XmlNode node = null;
+ int count = (nested == null) ? 0 : nested.Length;
+ for (int i = 0; i < count; i++) {
+ XMLClass xclass = nested [i];
+
+ node = document.CreateElement ("nestedclass", null);
+ newNodes.Add (node);
+ AddAttribute (node, "name", xclass.Name);
+ AddAttribute (node, "type", xclass.Type);
+
+ if (oh.ContainsKey (xclass.Name)) {
+ int idx = (int) oh [xclass.Name];
+ xclass.CompareTo (document, node, other [idx]);
+ other [idx] = null;
+ counters.AddPartialToPartial (xclass.Counters);
+ } else {
+ // TODO: Should I count here?
+ AddAttribute (node, "presence", "missing");
+ counters.Missing++;
+ counters.MissingTotal++;
+ }
+ }
+
+ if (other != null) {
+ count = other.Length;
+ for (int i = 0; i < count; i++) {
+ XMLClass c = other [i];
+ if (c == null || c.Name == "MonoTODOAttribute")
+ continue;
+
+ node = document.CreateElement ("nestedclass", null);
+ newNodes.Add (node);
+ AddAttribute (node, "name", c.Name);
+ AddExtra (node);
+ counters.Extra++;
+ counters.ExtraTotal++;
+ }
+ }
+
+ XmlNode [] nodes = (XmlNode []) newNodes.ToArray (typeof (XmlNode));
+ Array.Sort (nodes, XmlNodeComparer.Default);
+ foreach (XmlNode nn in nodes)
+ parent.AppendChild (nn);
+ }
+
+ static Hashtable CreateHash (XMLClass [] other)
+ {
+ Hashtable result = new Hashtable ();
+ if (other != null) {
+ int i = 0;
+ foreach (XMLClass c in other) {
+ result [c.Name] = i++;
+ }
+ }
+
+ return result;
+ }
+
+ public string Name {
+ get { return name; }
+ }
+
+ public string Type {
+ get { return type; }
+ }
+ }
+
+ class XMLAttributes : XMLNameGroup
+ {
+ bool isTodo;
+
+ protected override bool CheckIfAdd (string value)
+ {
+ if (value.EndsWith (".MonoTODOAttribute")) {
+ isTodo = true;
+ return false;
+ }
+
+ return true;
+ }
+
+ public override string GetNodeKey (string name, XmlNode node)
+ {
+ int i = 0;
+ while (keys.ContainsKey (name)) {
+ name = String.Format ("{0}:{1}", name, i++);
+ }
+
+ return name;
+ }
+
+ public override string GroupName {
+ get { return "attributes"; }
+ }
+
+ public override string Name {
+ get { return "attribute"; }
+ }
+
+ public bool IsTodo {
+ get { return isTodo; }
+ }
+ }
+
+ class XMLInterfaces : XMLNameGroup
+ {
+ public override string GroupName {
+ get { return "interfaces"; }
+ }
+
+ public override string Name {
+ get { return "interface"; }
+ }
+ }
+
+ abstract class XMLMember : XMLNameGroup
+ {
+ Hashtable attributeMap;
+ Hashtable access = new Hashtable ();
+
+ protected override void LoadExtraData (string name, XmlNode node)
+ {
+ XmlAttribute xatt = node.Attributes ["attrib"];
+ if (xatt != null)
+ access [name] = xatt.Value;
+
+ XmlNode orig = node;
+ while (node != null) {
+ if (node != null && node.Name == "attributes") {
+ XMLAttributes a = new XMLAttributes ();
+ a.LoadData (node);
+ if (attributeMap == null)
+ attributeMap = new Hashtable ();
+
+ attributeMap [name] = a;
+ break;
+ }
+ node = node.NextSibling;
+ }
+
+ base.LoadExtraData (name, orig);
+ }
+
+ protected override void CompareToInner (string name, XmlNode parent, XMLNameGroup other)
+ {
+ base.CompareToInner (name, parent, other);
+ XMLMember mb = other as XMLMember;
+ XMLAttributes att = null;
+ XMLAttributes oatt = null;
+ if (attributeMap != null)
+ att = attributeMap [name] as XMLAttributes;
+
+ if (mb != null && mb.attributeMap != null)
+ oatt = mb.attributeMap [name] as XMLAttributes;
+
+ if (att != null || oatt != null) {
+ if (att == null)
+ att = new XMLAttributes ();
+
+ att.CompareTo (document, parent, oatt);
+ counters.AddPartialToTotal (att.Counters);
+ if (oatt != null && oatt.IsTodo) {
+ counters.Todo++;
+ counters.ErrorTotal++;
+ AddAttribute (parent, "error", "todo");
+ }
+ }
+
+ if (access == null)
+ return;
+
+ XMLMember member = (XMLMember) other;
+ string acc = access [name] as string;
+ if (acc == null)
+ return;
+
+ string oacc = null;
+ if (member.access != null)
+ oacc = member.access [name] as string;
+
+ string accName = ConvertToString (Int32.Parse (acc));
+ string oaccName = "";
+ if (oacc != null)
+ oaccName = ConvertToString (Int32.Parse (oacc));
+
+ AddWarning (parent, "Incorrect attributes: '{0}' != '{1}'", accName, oaccName);
+ }
+
+ protected virtual string ConvertToString (int att)
+ {
+ return null;
+ }
+ }
+
+ class XMLFields : XMLMember
+ {
+ Hashtable fieldTypes;
+
+ protected override void LoadExtraData (string name, XmlNode node)
+ {
+ XmlAttribute xatt = node.Attributes ["fieldtype"];
+ if (xatt != null) {
+ if (fieldTypes == null)
+ fieldTypes = new Hashtable ();
+
+ fieldTypes [name] = xatt.Value;
+ }
+
+ base.LoadExtraData (name, node);
+ }
+
+ protected override void CompareToInner (string name, XmlNode parent, XMLNameGroup other)
+ {
+ base.CompareToInner (name, parent, other);
+ if (fieldTypes == null)
+ return;
+
+ XMLFields fields = (XMLFields) other;
+ string ftype = fieldTypes [name] as string;
+ string oftype = null;
+ if (fields.fieldTypes != null)
+ oftype = fields.fieldTypes [name] as string;
+
+ AddWarning (parent, "Field type is {0} and should be {1}", oftype, ftype);
+ }
+
+ protected override string ConvertToString (int att)
+ {
+ FieldAttributes fa = (FieldAttributes) att;
+ return fa.ToString ();
+ }
+
+ public override string GroupName {
+ get { return "fields"; }
+ }
+
+ public override string Name {
+ get { return "field"; }
+ }
+ }
+
+ class XMLProperties : XMLMember
+ {
+ Hashtable nameToMethod = new Hashtable ();
+
+ protected override void CompareToInner (string name, XmlNode parent, XMLNameGroup other)
+ {
+ XMLProperties oprop = other as XMLProperties;
+ if (oprop != null) {
+ XMLMethods m = nameToMethod [name] as XMLMethods;
+ XMLMethods om = oprop.nameToMethod [name] as XMLMethods;
+ if (m != null || om != null) {
+ if (m == null)
+ m = new XMLMethods ();
+
+ Counters copy = counters;
+ m.CompareTo (document, parent, om);
+ counters = new Counters ();
+ counters.AddPartialToPartial (m.Counters);
+ AddCountersAttributes (parent);
+ counters = copy;
+ counters.AddPartialToPartial (m.Counters);
+ }
+ }
+
+ base.CompareToInner (name, parent, other);
+ }
+
+ protected override void LoadExtraData (string name, XmlNode node)
+ {
+ XmlNode orig = node;
+ while (node != null) {
+ if (node != null && node.Name == "methods") {
+ XMLMethods m = new XMLMethods ();
+ XmlNode parent = node.ParentNode;
+ string key = GetNodeKey (name, parent);
+ m.LoadData (node);
+ nameToMethod [key] = m;
+ break;
+ }
+ node = node.NextSibling;
+ }
+
+ base.LoadExtraData (name, orig);
+ }
+
+ public override string GetNodeKey (string name, XmlNode node)
+ {
+ XmlAttributeCollection atts = node.Attributes;
+ return String.Format ("{0}:{1}:{2}", atts ["name"].Value,
+ atts ["ptype"].Value,
+ atts ["params"].Value);
+ }
+
+ public override string GroupName {
+ get { return "properties"; }
+ }
+
+ public override string Name {
+ get { return "property"; }
+ }
+ }
+
+ class XMLEvents : XMLMember
+ {
+ Hashtable eventTypes;
+
+ public override void CompareTo (XmlDocument doc, XmlNode parent, object other)
+ {
+ base.CompareTo (doc, parent, other);
+ AddCountersAttributes (parent);
+ }
+
+ protected override void LoadExtraData (string name, XmlNode node)
+ {
+ XmlAttribute xatt = node.Attributes ["eventtype"];
+ if (xatt != null) {
+ if (eventTypes == null)
+ eventTypes = new Hashtable ();
+
+ eventTypes [name] = xatt.Value;
+ }
+
+ base.LoadExtraData (name, node);
+ }
+
+ protected override void CompareToInner (string name, XmlNode parent, XMLNameGroup other)
+ {
+ base.CompareToInner (name, parent, other);
+ if (eventTypes == null)
+ return;
+
+ XMLEvents evt = (XMLEvents) other;
+ string etype = eventTypes [name] as string;
+ string oetype = null;
+ if (evt.eventTypes != null)
+ oetype = evt.eventTypes [name] as string;
+
+ AddWarning (parent, "Event type is {0} and should be {1}", oetype, etype);
+ }
+
+ protected override string ConvertToString (int att)
+ {
+ EventAttributes ea = (EventAttributes) att;
+ return ea.ToString ();
+ }
+
+ public override string GroupName {
+ get { return "events"; }
+ }
+
+ public override string Name {
+ get { return "event"; }
+ }
+ }
+
+ class XMLMethods : XMLMember
+ {
+ Hashtable returnTypes;
+
+ protected override void LoadExtraData (string name, XmlNode node)
+ {
+ XmlAttribute xatt = node.Attributes ["returntype"];
+ if (xatt != null) {
+ if (returnTypes == null)
+ returnTypes = new Hashtable ();
+
+ returnTypes [name] = xatt.Value;
+ }
+
+ base.LoadExtraData (name, node);
+ }
+
+ protected override void CompareToInner (string name, XmlNode parent, XMLNameGroup other)
+ {
+ base.CompareToInner (name, parent, other);
+ if (returnTypes == null)
+ return;
+
+ XMLMethods methods = (XMLMethods) other;
+ string rtype = returnTypes [name] as string;
+ string ortype = null;
+ if (methods.returnTypes != null)
+ ortype = methods.returnTypes [name] as string;
+
+ AddWarning (parent, "Event type is {0} and should be {1}", ortype, rtype);
+ }
+
+ protected override string ConvertToString (int att)
+ {
+ MethodAttributes ma = (MethodAttributes) att;
+ return ma.ToString ();
+ }
+
+ public override string GroupName {
+ get { return "methods"; }
+ }
+
+ public override string Name {
+ get { return "method"; }
+ }
+ }
+
+ class XMLConstructors : XMLMethods
+ {
+ public override string GroupName {
+ get { return "constructors"; }
+ }
+
+ public override string Name {
+ get { return "constructor"; }
+ }
+ }
+
+ class XmlNodeComparer : IComparer
+ {
+ public static XmlNodeComparer Default = new XmlNodeComparer ();
+
+ public int Compare (object a, object b)
+ {
+ XmlNode na = (XmlNode) a;
+ XmlNode nb = (XmlNode) b;
+ return String.Compare (na.Attributes ["name"].Value, nb.Attributes ["name"].Value);
+ }
+ }
+}
+
diff --git a/mcs/tools/corcompare/mono-api-info.cs b/mcs/tools/corcompare/mono-api-info.cs
new file mode 100644
index 00000000000..bd2be77d36f
--- /dev/null
+++ b/mcs/tools/corcompare/mono-api-info.cs
@@ -0,0 +1,725 @@
+//
+// ainfo.cs
+//
+// Authors:
+// Gonzalo Paniagua Javier (gonzalo@ximian.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+using System.Collections;
+using System.Reflection;
+using System.Text;
+using System.Xml;
+
+namespace Mono.AssemblyInfo
+{
+ class Driver
+ {
+ static int Main (string [] args)
+ {
+ if (args.Length == 0)
+ return 1;
+
+ AssemblyCollection acoll = new AssemblyCollection ();
+
+ foreach (string fullName in args) {
+ acoll.Add (fullName);
+ }
+
+ XmlDocument doc = new XmlDocument ();
+ acoll.Document = doc;
+ acoll.DoOutput ();
+
+ XmlTextWriter writer = new XmlTextWriter (Console.Out);
+ writer.Formatting = Formatting.Indented;
+ XmlNode decl = doc.CreateXmlDeclaration ("1.0", null, null);
+ doc.InsertBefore (decl, doc.DocumentElement);
+ doc.WriteTo (writer);
+ return 0;
+ }
+ }
+
+ class AssemblyCollection
+ {
+ XmlDocument document;
+ ArrayList assemblies;
+
+ public AssemblyCollection ()
+ {
+ assemblies = new ArrayList ();
+ }
+
+ public bool Add (string name)
+ {
+ Assembly ass = LoadAssembly (name);
+ if (ass == null)
+ return false;
+
+ assemblies.Add (ass);
+ return true;
+ }
+
+ public void DoOutput ()
+ {
+ if (document == null)
+ throw new InvalidOperationException ("Document not set");
+
+ XmlNode nassemblies = document.CreateElement ("assemblies", null);
+ document.AppendChild (nassemblies);
+ foreach (Assembly a in assemblies) {
+ AssemblyData data = new AssemblyData (document, nassemblies, a);
+ data.DoOutput ();
+ }
+ }
+
+ public XmlDocument Document {
+ set { document = value; }
+ }
+
+ static Assembly LoadAssembly (string aname)
+ {
+ Assembly ass = null;
+ try {
+ string name = aname;
+ if (!name.EndsWith (".dll"))
+ name += ".dll";
+ ass = Assembly.LoadFrom (name);
+ return ass;
+ } catch { }
+
+ try {
+ ass = Assembly.LoadWithPartialName (aname);
+ return ass;
+ } catch { }
+
+ return null;
+ }
+ }
+
+ abstract class BaseData
+ {
+ protected XmlDocument document;
+ protected XmlNode parent;
+
+ protected BaseData (XmlDocument doc, XmlNode parent)
+ {
+ this.document = doc;
+ this.parent = parent;
+ }
+
+ public abstract void DoOutput ();
+
+ protected void AddAttribute (XmlNode node, string name, string value)
+ {
+ XmlAttribute attr = document.CreateAttribute (name);
+ attr.Value = value;
+ node.Attributes.Append (attr);
+ }
+ }
+
+ class AssemblyData : BaseData
+ {
+ Assembly ass;
+
+ public AssemblyData (XmlDocument document, XmlNode parent, Assembly ass)
+ : base (document, parent)
+ {
+ this.ass = ass;
+ }
+
+ public override void DoOutput ()
+ {
+ if (document == null)
+ throw new InvalidOperationException ("Document not set");
+
+ XmlNode nassembly = document.CreateElement ("assembly", null);
+ AssemblyName aname = ass.GetName ();
+ AddAttribute (nassembly, "name", aname.Name);
+ AddAttribute (nassembly, "version", aname.Version.ToString ());
+ parent.AppendChild (nassembly);
+ AttributeData.OutputAttributes (document, nassembly, ass.GetCustomAttributes (false));
+ Type [] types = ass.GetTypes ();
+ if (types == null || types.Length == 0)
+ return;
+
+ Array.Sort (types, TypeComparer.Default);
+
+ XmlNode nss = document.CreateElement ("namespaces", null);
+ nassembly.AppendChild (nss);
+
+ string currentNS = "$%&$&";
+ XmlNode ns = null;
+ XmlNode classes = null;
+ foreach (Type t in types) {
+ if (t.Namespace == null || t.Namespace == "")
+ continue;
+
+ if (t.IsNotPublic)
+ continue;
+
+ if (t.IsNestedPublic || t.IsNestedAssembly || t.IsNestedFamANDAssem ||
+ t.IsNestedFamORAssem || t.IsNestedPrivate)
+ continue;
+
+ if (t.DeclaringType != null)
+ continue; // enforce !nested
+
+ if (t.Namespace != currentNS) {
+ currentNS = t.Namespace;
+ ns = document.CreateElement ("namespace", null);
+ AddAttribute (ns, "name", currentNS);
+ nss.AppendChild (ns);
+ classes = document.CreateElement ("classes", null);
+ ns.AppendChild (classes);
+ }
+
+ TypeData bd = new TypeData (document, classes, t);
+ bd.DoOutput ();
+ }
+ }
+ }
+
+ abstract class MemberData : BaseData
+ {
+ MemberInfo [] members;
+
+ public MemberData (XmlDocument document, XmlNode parent, MemberInfo [] members)
+ : base (document, parent)
+ {
+ this.members = members;
+ }
+
+ public override void DoOutput ()
+ {
+ XmlNode mclass = document.CreateElement (ParentTag, null);
+ parent.AppendChild (mclass);
+
+ foreach (MemberInfo member in members) {
+ XmlNode mnode = document.CreateElement (Tag, null);
+ mclass.AppendChild (mnode);
+ AddAttribute (mnode, "name", GetName (member));
+ if (!NoMemberAttributes)
+ AddAttribute (mnode, "attrib", GetMemberAttributes (member));
+
+ AttributeData.OutputAttributes (document, mnode,
+ member.GetCustomAttributes (false));
+
+ AddExtraData (mnode, member);
+ }
+ }
+
+ protected virtual void AddExtraData (XmlNode p, MemberInfo member)
+ {
+ }
+
+ protected virtual string GetName (MemberInfo member)
+ {
+ return "NoNAME";
+ }
+
+ protected virtual string GetMemberAttributes (MemberInfo member)
+ {
+ return null;
+ }
+
+ public virtual bool NoMemberAttributes {
+ get { return false; }
+ set {}
+ }
+
+ public virtual string ParentTag {
+ get { return "NoPARENTTAG"; }
+ }
+
+ public virtual string Tag {
+ get { return "NoTAG"; }
+ }
+ }
+
+ class TypeData : MemberData
+ {
+ Type type;
+ const BindingFlags flags = BindingFlags.Public | BindingFlags.Static |
+ BindingFlags.Instance | BindingFlags.DeclaredOnly;
+
+ public TypeData (XmlDocument document, XmlNode parent, Type type)
+ : base (document, parent, null)
+ {
+ this.type = type;
+ }
+
+ public override void DoOutput ()
+ {
+ if (document == null)
+ throw new InvalidOperationException ("Document not set");
+
+ XmlNode nclass = document.CreateElement ("class", null);
+ AddAttribute (nclass, "name", type.Name);
+ string classType = GetClassType (type);
+ AddAttribute (nclass, "type", classType);
+ if (type.BaseType != null)
+ AddAttribute (nclass, "base", type.BaseType.FullName);
+
+ if (type.IsSealed)
+ AddAttribute (nclass, "sealed", "true");
+
+ parent.AppendChild (nclass);
+
+ AttributeData.OutputAttributes (document, nclass, type.GetCustomAttributes (false));
+
+ Type [] interfaces = type.GetInterfaces ();
+ if (interfaces != null && interfaces.Length > 0) {
+ XmlNode ifaces = document.CreateElement ("interfaces", null);
+ nclass.AppendChild (ifaces);
+ foreach (Type t in interfaces) {
+ XmlNode iface = document.CreateElement ("interface", null);
+ if (t == null)
+ Console.WriteLine (type);
+ AddAttribute (iface, "name", t.FullName);
+ ifaces.AppendChild (iface);
+ }
+ }
+
+ ArrayList members = new ArrayList ();
+
+ FieldInfo [] fields = type.GetFields (flags);
+ if (fields != null && fields.Length > 0) {
+ fields = FieldRemoveSpecials (fields);
+ if (fields != null) {
+ Array.Sort (fields, MemberInfoComparer.Default);
+ FieldData fd = new FieldData (document, nclass, fields);
+ // Special case for enum fields
+ if (classType == "enum") {
+ string etype = fields [0].GetType ().FullName;
+ AddAttribute (nclass, "enumtype", etype);
+ }
+
+ members.Add (fd);
+ }
+ }
+
+ // No .cctor
+ ConstructorInfo [] ctors = type.GetConstructors (flags);
+
+ if (ctors.Length > 0) {
+ Array.Sort (ctors, MethodBaseComparer.Default);
+ members.Add (new ConstructorData (document, nclass, ctors));
+ }
+
+ PropertyInfo [] props = type.GetProperties (flags);
+ if (props != null && props.Length > 0) {
+ Array.Sort (props, MemberInfoComparer.Default);
+ members.Add (new PropertyData (document, nclass, props));
+ }
+
+ EventInfo [] events = type.GetEvents (flags);
+ if (events != null && events.Length > 0) {
+ Array.Sort (events, MemberInfoComparer.Default);
+ members.Add (new EventData (document, nclass, events));
+ }
+
+ MethodInfo [] methods = type.GetMethods (flags);
+ if (methods != null && methods.Length > 0) {
+ methods = MethodRemoveSpecials (methods);
+ if (methods != null) {
+ Array.Sort (methods, MethodBaseComparer.Default);
+ members.Add (new MethodData (document, nclass, methods));
+ }
+ }
+
+ foreach (MemberData md in members)
+ md.DoOutput ();
+
+ Type [] nested = type.GetNestedTypes ();
+ if (nested != null && nested.Length > 0) {
+ XmlNode classes = document.CreateElement ("classes", null);
+ nclass.AppendChild (classes);
+ foreach (Type t in nested) {
+ TypeData td = new TypeData (document, classes, t);
+ td.DoOutput ();
+ }
+ }
+ }
+
+ protected override string GetMemberAttributes (MemberInfo member)
+ {
+ if (member != type)
+ throw new InvalidOperationException ("odd");
+
+ return ((int) type.Attributes).ToString ();
+ }
+
+ static MethodInfo [] MethodRemoveSpecials (MethodInfo [] methods)
+ {
+ ArrayList list = null;
+ foreach (MethodInfo method in methods) {
+ if (method.IsSpecialName)
+ continue;
+
+ if (list == null)
+ list = new ArrayList ();
+
+ list.Add (method);
+ }
+
+ if (list == null)
+ return null;
+
+ return (MethodInfo []) list.ToArray (typeof (MethodInfo));
+ }
+
+ static FieldInfo [] FieldRemoveSpecials (FieldInfo [] fields)
+ {
+ ArrayList list = null;
+ foreach (FieldInfo field in fields) {
+ if (field.IsSpecialName)
+ continue;
+
+ if (list == null)
+ list = new ArrayList ();
+
+ list.Add (field);
+ }
+
+ if (list == null)
+ return null;
+
+ return (FieldInfo []) list.ToArray (typeof (FieldInfo));
+ }
+
+ static string GetClassType (Type t)
+ {
+ if (t.IsEnum)
+ return "enum";
+
+ if (t.IsValueType)
+ return "struct";
+
+ if (t.IsInterface)
+ return "interface";
+
+ if (typeof (Delegate).IsAssignableFrom (t))
+ return "delegate";
+
+ return "class";
+ }
+ }
+
+ class FieldData : MemberData
+ {
+ public FieldData (XmlDocument document, XmlNode parent, FieldInfo [] members)
+ : base (document, parent, members)
+ {
+ }
+
+ protected override string GetName (MemberInfo member)
+ {
+ FieldInfo field = (FieldInfo) member;
+ return field.Name;
+ }
+
+ protected override string GetMemberAttributes (MemberInfo member)
+ {
+ FieldInfo field = (FieldInfo) member;
+ return ((int) field.Attributes).ToString ();
+ }
+
+ protected override void AddExtraData (XmlNode p, MemberInfo member)
+ {
+ base.AddExtraData (p, member);
+ FieldInfo field = (FieldInfo) member;
+ AddAttribute (p, "fieldtype", field.FieldType.FullName);
+ }
+
+ public override string ParentTag {
+ get { return "fields"; }
+ }
+
+ public override string Tag {
+ get { return "field"; }
+ }
+ }
+
+ class PropertyData : MemberData
+ {
+ public PropertyData (XmlDocument document, XmlNode parent, PropertyInfo [] members)
+ : base (document, parent, members)
+ {
+ }
+
+ protected override string GetName (MemberInfo member)
+ {
+ PropertyInfo prop = (PropertyInfo) member;
+ return prop.Name;
+ }
+
+ protected override void AddExtraData (XmlNode p, MemberInfo member)
+ {
+ base.AddExtraData (p, member);
+ PropertyInfo prop = (PropertyInfo) member;
+ AddAttribute (p, "ptype", prop.PropertyType.FullName);
+ MethodInfo _get = prop.GetGetMethod ();
+ MethodInfo _set = prop.GetSetMethod ();
+ bool haveGet = (_get != null);
+ bool haveSet = (_set != null);
+ MethodInfo [] methods;
+
+ if (haveGet && haveSet) {
+ methods = new MethodInfo [] {_get, _set};
+ } else if (haveGet) {
+ methods = new MethodInfo [] {_get};
+ } else if (haveSet) {
+ methods = new MethodInfo [] {_set};
+ } else {
+ //odd
+ return;
+ }
+
+ string parms = Parameters.GetSignature (methods [0].GetParameters ());
+ AddAttribute (p, "params", parms);
+
+ MethodData data = new MethodData (document, p, methods);
+ data.NoMemberAttributes = true;
+ data.DoOutput ();
+ }
+
+ protected override string GetMemberAttributes (MemberInfo member)
+ {
+ PropertyInfo prop = (PropertyInfo) member;
+ return ((int) prop.Attributes).ToString ();
+ }
+
+ public override string ParentTag {
+ get { return "properties"; }
+ }
+
+ public override string Tag {
+ get { return "property"; }
+ }
+ }
+
+ class EventData : MemberData
+ {
+ public EventData (XmlDocument document, XmlNode parent, EventInfo [] members)
+ : base (document, parent, members)
+ {
+ }
+
+ protected override string GetName (MemberInfo member)
+ {
+ EventInfo evt = (EventInfo) member;
+ return evt.Name;
+ }
+
+ protected override string GetMemberAttributes (MemberInfo member)
+ {
+ EventInfo evt = (EventInfo) member;
+ return ((int) evt.Attributes).ToString ();
+ }
+
+ protected override void AddExtraData (XmlNode p, MemberInfo member)
+ {
+ base.AddExtraData (p, member);
+ EventInfo evt = (EventInfo) member;
+ AddAttribute (p, "eventtype", evt.EventHandlerType.FullName);
+ }
+
+ public override string ParentTag {
+ get { return "events"; }
+ }
+
+ public override string Tag {
+ get { return "event"; }
+ }
+ }
+
+ class MethodData : MemberData
+ {
+ bool noAtts;
+
+ public MethodData (XmlDocument document, XmlNode parent, MethodBase [] members)
+ : base (document, parent, members)
+ {
+ }
+
+ protected override string GetName (MemberInfo member)
+ {
+ MethodBase method = (MethodBase) member;
+ string name = method.Name;
+ string parms = Parameters.GetSignature (method.GetParameters ());
+ return String.Format ("{0}({1})", name, parms);
+ }
+
+ protected override string GetMemberAttributes (MemberInfo member)
+ {
+ MethodBase method = (MethodBase) member;
+ return ((int) method.Attributes).ToString ();
+ }
+
+ protected override void AddExtraData (XmlNode p, MemberInfo member)
+ {
+ base.AddExtraData (p, member);
+ if (!(member is MethodInfo))
+ return;
+
+ MethodInfo method = (MethodInfo) member;
+ AddAttribute (p, "returntype", method.ReturnType.FullName);
+ }
+
+ public override bool NoMemberAttributes {
+ get { return noAtts; }
+ set { noAtts = value; }
+ }
+
+ public override string ParentTag {
+ get { return "methods"; }
+ }
+
+ public override string Tag {
+ get { return "method"; }
+ }
+ }
+
+ class ConstructorData : MethodData
+ {
+ public ConstructorData (XmlDocument document, XmlNode parent, ConstructorInfo [] members)
+ : base (document, parent, members)
+ {
+ }
+
+ public override string ParentTag {
+ get { return "constructors"; }
+ }
+
+ public override string Tag {
+ get { return "constructor"; }
+ }
+ }
+
+ class AttributeData : BaseData
+ {
+ object [] atts;
+
+ AttributeData (XmlDocument doc, XmlNode parent, object [] attributes)
+ : base (doc, parent)
+ {
+ this.atts = attributes;
+ }
+
+ public override void DoOutput ()
+ {
+ if (document == null)
+ throw new InvalidOperationException ("Document not set");
+
+ if (atts == null || atts.Length == 0)
+ return;
+
+ XmlNode natts = document.CreateElement ("attributes", null);
+ parent.AppendChild (natts);
+
+ Type [] types = new Type [atts.Length];
+ for (int i = atts.Length - 1; i >= 0; i--)
+ types [i] = atts [i].GetType ();
+
+ Array.Sort (types, TypeComparer.Default);
+ foreach (Type t in types) {
+ XmlNode node = document.CreateElement ("attribute");
+ AddAttribute (node, "name", t.FullName);
+ natts.AppendChild (node);
+ }
+ }
+
+ public static void OutputAttributes (XmlDocument doc, XmlNode parent, object [] attributes)
+ {
+ AttributeData ad = new AttributeData (doc, parent, attributes);
+ ad.DoOutput ();
+ }
+ }
+
+ class Parameters
+ {
+ private Parameters () {}
+
+ public static string GetSignature (ParameterInfo [] infos)
+ {
+ if (infos == null || infos.Length == 0)
+ return "";
+
+ StringBuilder sb = new StringBuilder ();
+ foreach (ParameterInfo info in infos) {
+ string modifier;
+ if (info.IsIn)
+ modifier = "in ";
+ else if (info.IsRetval)
+ modifier = "ref ";
+ else if (info.IsOut)
+ modifier = "out ";
+ else
+ modifier = "";
+
+ //TODO: parameter attributes
+
+ string type_name = info.ParameterType.ToString ();
+ sb.AppendFormat ("{0}{1}, ", modifier, type_name);
+ }
+
+ sb.Length -= 2; // remove ", "
+ return sb.ToString ();
+ }
+
+ }
+
+ class TypeComparer : IComparer
+ {
+ public static TypeComparer Default = new TypeComparer ();
+
+ public int Compare (object a, object b)
+ {
+ Type ta = (Type) a;
+ Type tb = (Type) b;
+ int result = String.Compare (ta.Namespace, tb.Namespace);
+ if (result != 0)
+ return result;
+
+ return String.Compare (ta.Name, tb.Name);
+ }
+ }
+
+ class MemberInfoComparer : IComparer
+ {
+ public static MemberInfoComparer Default = new MemberInfoComparer ();
+
+ public int Compare (object a, object b)
+ {
+ MemberInfo ma = (MemberInfo) a;
+ MemberInfo mb = (MemberInfo) b;
+ return String.Compare (ma.Name, mb.Name);
+ }
+ }
+
+ class MethodBaseComparer : IComparer
+ {
+ public static MethodBaseComparer Default = new MethodBaseComparer ();
+
+ public int Compare (object a, object b)
+ {
+ MethodBase ma = (MethodBase) a;
+ MethodBase mb = (MethodBase) b;
+ int res = String.Compare (ma.Name, mb.Name);
+ if (res != 0)
+ return res;
+
+ ParameterInfo [] pia = ma.GetParameters ();
+ ParameterInfo [] pib = mb.GetParameters ();
+ if (pia.Length != pib.Length)
+ return pia.Length - pib.Length;
+
+ string siga = Parameters.GetSignature (pia);
+ string sigb = Parameters.GetSignature (pib);
+ return String.Compare (siga, sigb);
+ }
+ }
+}
+
diff --git a/mcs/tools/corcompare/mono-api.xsl b/mcs/tools/corcompare/mono-api.xsl
new file mode 100644
index 00000000000..b0fefcd4e1d
--- /dev/null
+++ b/mcs/tools/corcompare/mono-api.xsl
@@ -0,0 +1,493 @@
+<?xml version="1.0" ?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
+
+ <xsl:output method="html" indent="no"/>
+ <!-- <xsl:output method="xml"/>-->
+ <xsl:strip-space elements="*"/>
+
+ <xsl:template match="/">
+<!--
+ <HTML>
+ <HEAD>
+ <TITLE>
+ Mono Class Library Status
+ </TITLE>
+ <SCRIPT src="cormissing.js"></SCRIPT>
+ <LINK rel="stylesheet" type="text/css" href="cormissing.css"></LINK>
+ </HEAD>
+ <BODY onLoad="onLoad();">
+ <P>
+ <H1>Mono Class Library Status</H1>
+ </P>
+-->
+ <P>
+ <TABLE>
+ <TR>
+ <TD> <INPUT type="checkbox" ID="todo" onClick="selectTodo();" checked="1"/> </TD>
+ <TD> <IMG src="cm/st.gif"/> </TD>
+ <TD> TODO </TD>
+ <TD width="20"/>
+ <TD> <INPUT type="checkbox" ID="missing" onClick="selectMissing();" checked="1"/> </TD>
+ <TD> <IMG src="cm/sm.gif"/> </TD>
+ <TD> Missing </TD>
+ </TR>
+ <TR>
+ <TD> <INPUT type="checkbox" ID="extra" onClick="selectExtra();" checked="1"/> </TD>
+ <TD> <IMG src="cm/sx.gif"/> </TD>
+ <TD> Extra </TD>
+ <TD width="20"/>
+ <TD> <INPUT type="checkbox" ID="errors" onClick="selectErrors();" checked="1"/> </TD>
+ <TD> <IMG src="cm/se.gif"/> </TD>
+ <TD> Errors </TD>
+ </TR>
+ <TR>
+ <TD> </TD>
+ <TD> <IMG src="cm/sc.gif"/> </TD>
+ <TD> Completed </TD>
+ </TR>
+ </TABLE>
+ </P>
+ <DIV ID="ROOT">
+ <xsl:apply-templates/>
+ </DIV>
+ <P>
+ Legend :<BR/>
+ <TABLE>
+ <TR>
+ <TD> <IMG src="cm/y.gif"/> </TD>
+ <TD> Assembly </TD>
+ <TD width="20"/>
+ <TD> <IMG src="cm/n.gif"/> </TD>
+ <TD> Namespace </TD>
+ <TD width="20"/>
+ <TD> <IMG src="cm/c.gif"/> </TD>
+ <TD> Class </TD>
+ <TD width="20"/>
+ <TD> <IMG src="cm/s.gif"/> </TD>
+ <TD> Struct </TD>
+ <TR>
+ </TR>
+ <TD> <IMG src="cm/i.gif"/> </TD>
+ <TD> Interface </TD>
+ <TD width="20"/>
+ <TD> <IMG src="cm/d.gif"/> </TD>
+ <TD> Delegate </TD>
+ <TD width="20"/>
+ <TD> <IMG src="cm/en.gif"/> </TD>
+ <TD> Enum </TD>
+ <TD width="20"/>
+ <TD> <IMG src="cm/m.gif"/> </TD>
+ <TD> Method </TD>
+ </TR>
+ <TR>
+ <TD> <IMG src="cm/f.gif"/> </TD>
+ <TD> Field </TD>
+ <TD width="20"/>
+ <TD> <IMG src="cm/p.gif"/> </TD>
+ <TD> Property </TD>
+ <TD width="20"/>
+ <TD> <IMG src="cm/e.gif"/> </TD>
+ <TD> Event </TD>
+ <TD width="20"/>
+ <TD> <IMG src="cm/r.gif"/> </TD>
+ <TD> Attribute </TD>
+ </TR>
+ </TABLE>
+
+ </P>
+<!--
+ </BODY>
+ </HTML>
+-->
+ </xsl:template>
+
+
+
+ <!-- assembly -->
+ <xsl:template match="/assemblies">
+ <xsl:apply-templates select="assembly">
+ <xsl:sort select="@name"/>
+ </xsl:apply-templates>
+ </xsl:template>
+
+ <xsl:template match="assemblies/assembly">
+ <DIV>
+ <xsl:call-template name="ELEMENT">
+ <xsl:with-param name="class">y</xsl:with-param>
+ </xsl:call-template>
+ <xsl:if test="not(@presence)">
+ <xsl:apply-templates/>
+ </xsl:if>
+ </DIV>
+ </xsl:template>
+
+
+ <!-- namespace -->
+ <xsl:template match="assembly/namespaces">
+ <xsl:apply-templates select="namespace">
+ <xsl:sort select="@name"/>
+ </xsl:apply-templates>
+ </xsl:template>
+
+ <xsl:template match="namespaces/namespace">
+ <DIV>
+ <xsl:call-template name="ELEMENT">
+ <xsl:with-param name="class">n</xsl:with-param>
+ </xsl:call-template>
+ <xsl:if test="not(@presence)">
+ <xsl:apply-templates/>
+ </xsl:if>
+ </DIV>
+ </xsl:template>
+
+
+ <xsl:template match="namespace/classes">
+ <xsl:apply-templates select="class[@type='interface']">
+ <xsl:sort select="@name"/>
+ </xsl:apply-templates>
+ <xsl:apply-templates select="class[@type='class']">
+ <xsl:sort select="@name"/>
+ </xsl:apply-templates>
+ <xsl:apply-templates select="class[@type='struct']">
+ <xsl:sort select="@name"/>
+ </xsl:apply-templates>
+ <xsl:apply-templates select="class[@type='delegate']">
+ <xsl:sort select="@name"/>
+ </xsl:apply-templates>
+ <xsl:apply-templates select="class[@type='enum']">
+ <xsl:sort select="@name"/>
+ </xsl:apply-templates>
+ </xsl:template>
+
+
+ <!-- class -->
+ <xsl:template match="classes/class[@type='class']">
+ <DIV>
+ <xsl:call-template name="ELEMENT">
+ <xsl:with-param name="class">c</xsl:with-param>
+ </xsl:call-template>
+ <xsl:if test="(@missing_total or @todo_total or @extra_total or @warning_total or @error) and not(@presence)">
+ <xsl:apply-templates select="attributes"/>
+ <xsl:apply-templates select="interfaces"/>
+ <xsl:apply-templates select="constructors"/>
+ <xsl:apply-templates select="./*[local-name() != 'attributes' and local-name() != 'constructors' and local-name() != 'interfaces']"/>
+ </xsl:if>
+ </DIV>
+ </xsl:template>
+
+
+ <!-- struct -->
+ <xsl:template match="classes/class[@type='struct'][@missing_total or @todo_total or @extra_total or @warning_total or @error or @presence]">
+ <DIV>
+ <xsl:call-template name="ELEMENT">
+ <xsl:with-param name="class">s</xsl:with-param>
+ </xsl:call-template>
+ <xsl:if test="not(@presence)">
+ <xsl:apply-templates/>
+ </xsl:if>
+ </DIV>
+ </xsl:template>
+
+
+
+ <!-- interface types -->
+ <xsl:template match="class[@type='interface']">
+ <xsl:apply-templates select="class[@type='interface']">
+ <xsl:sort select="@name"/>
+ </xsl:apply-templates>
+ </xsl:template>
+
+ <xsl:template match="class[@type='interface'][@missing_total or @todo_total or @extra_total or @warning_total or @error or @presence]">
+ <DIV>
+ <xsl:call-template name="ELEMENT">
+ <xsl:with-param name="class">i</xsl:with-param>
+ </xsl:call-template>
+ <xsl:if test="not(@presence)">
+ <xsl:apply-templates/>
+ </xsl:if>
+ </DIV>
+ </xsl:template>
+
+ <!-- interfaces implemented by Types -->
+ <xsl:template match="interface">
+ <xsl:apply-templates select="interface">
+ <xsl:sort select="@name"/>
+ </xsl:apply-templates>
+ </xsl:template>
+
+ <xsl:template match="interface[@missing_total or @todo_total or @extra_total or @warning_total or @error or @presence]">
+ <DIV>
+ <xsl:call-template name="ELEMENT">
+ <xsl:with-param name="class">i</xsl:with-param>
+ </xsl:call-template>
+ <xsl:if test="not(@presence)">
+ <xsl:apply-templates/>
+ </xsl:if>
+ </DIV>
+ </xsl:template>
+
+
+
+ <!-- delegate -->
+ <xsl:template match="classes/class[@type='delegate'][@missing_total or @todo_total or @extra_total or @warning_total or @error or @presence]">
+ <DIV>
+ <xsl:call-template name="ELEMENT">
+ <xsl:with-param name="class">d</xsl:with-param>
+ </xsl:call-template>
+ <xsl:if test="not(@presence)">
+ <xsl:apply-templates/>
+ </xsl:if>
+ </DIV>
+ </xsl:template>
+
+
+ <!-- enumeration -->
+ <xsl:template match="classes/class[@type='enum'][@missing_total or @todo_total or @extra_total or @warning_total or @error or @presence]">
+ <DIV>
+ <xsl:call-template name="ELEMENT">
+ <xsl:with-param name="class">en</xsl:with-param>
+ </xsl:call-template>
+ <xsl:if test="not(@presence)">
+ <xsl:apply-templates/>
+ </xsl:if>
+ </DIV>
+ </xsl:template>
+
+
+ <!-- method -->
+ <xsl:template match="methods">
+ <xsl:apply-templates select="method">
+ <xsl:sort select="@name"/>
+ </xsl:apply-templates>
+ </xsl:template>
+
+ <xsl:template match="methods/method[@missing_total or @todo_total or @extra_total or @warning_total or @error or @presence]">
+ <DIV>
+ <xsl:call-template name="ELEMENT">
+ <xsl:with-param name="class">m</xsl:with-param>
+ </xsl:call-template>
+ <xsl:if test="not(@presence)">
+ <xsl:apply-templates/>
+ </xsl:if>
+ </DIV>
+ </xsl:template>
+
+
+ <!-- property -->
+ <xsl:template match="properties">
+ <xsl:apply-templates select="property">
+ <xsl:sort select="@name"/>
+ </xsl:apply-templates>
+ </xsl:template>
+
+ <xsl:template match="properties/property[@missing_total or @todo_total or @extra_total or @warning_total or @error or @presence]">
+ <DIV>
+ <xsl:call-template name="ELEMENT">
+ <xsl:with-param name="class">p</xsl:with-param>
+ </xsl:call-template>
+ <xsl:if test="not(@presence)">
+ <xsl:apply-templates/>
+ </xsl:if>
+ </DIV>
+ </xsl:template>
+
+
+ <!-- event -->
+ <xsl:template match="events">
+ <xsl:apply-templates select="event">
+ <xsl:sort select="@name"/>
+ </xsl:apply-templates>
+ </xsl:template>
+
+ <xsl:template match="events/event[@missing_total or @todo_total or @extra_total or @warning_total or @error or @presence]">
+ <DIV>
+ <xsl:call-template name="ELEMENT">
+ <xsl:with-param name="class">e</xsl:with-param>
+ </xsl:call-template>
+ <xsl:if test="not(@presence)">
+ <xsl:apply-templates/>
+ </xsl:if>
+ </DIV>
+ </xsl:template>
+
+
+ <!-- constructor -->
+ <xsl:template match="constructors">
+ <xsl:apply-templates select="constructor">
+ <xsl:sort select="@name"/>
+ </xsl:apply-templates>
+ </xsl:template>
+
+ <xsl:template match="constructors/constructor[@missing_total or @todo_total or @extra_total or @warning_total or @error or @presence]">
+ <DIV>
+ <xsl:call-template name="ELEMENT">
+ <xsl:with-param name="class">x</xsl:with-param>
+ <xsl:with-param name="image">m</xsl:with-param>
+ </xsl:call-template>
+ <xsl:if test="not(@presence)">
+ <xsl:apply-templates/>
+ </xsl:if>
+ </DIV>
+ </xsl:template>
+
+
+ <!-- field -->
+ <xsl:template match="fields">
+ <xsl:apply-templates select="field">
+ <xsl:sort select="@name"/>
+ </xsl:apply-templates>
+ </xsl:template>
+
+ <xsl:template match="fields/field[@missing_total or @todo_total or @extra_total or @warning_total or @error or @presence]">
+ <DIV>
+ <xsl:call-template name="ELEMENT">
+ <xsl:with-param name="class">f</xsl:with-param>
+ </xsl:call-template>
+ <xsl:if test="not(@presence)">
+ <xsl:apply-templates/>
+ </xsl:if>
+ </DIV>
+ </xsl:template>
+
+ <!-- accessor -->
+ <xsl:template match="property/methods">
+ <xsl:apply-templates select="method">
+ <xsl:sort select="@name"/>
+ </xsl:apply-templates>
+ </xsl:template>
+
+ <xsl:template match="property[@missing_total or @todo_total or @extra_total or @warning_total or @error or @presence]/methods/method[@missing_total or @todo_total or @extra_total or @warning_total or @error or @presence]">
+ <DIV>
+ <xsl:call-template name="ELEMENT">
+ <xsl:with-param name="class">o</xsl:with-param>
+ <xsl:with-param name="image">m</xsl:with-param>
+ </xsl:call-template>
+ <xsl:if test="not(@presence)">
+ <xsl:apply-templates/>
+ </xsl:if>
+ </DIV>
+ </xsl:template>
+
+
+ <!-- attribute -->
+ <xsl:template match="attributes">
+ <xsl:apply-templates select="attribute">
+ <xsl:sort select="@name"/>
+ </xsl:apply-templates>
+ </xsl:template>
+
+ <xsl:template match="attributes/attribute[@missing_total or @todo_total or @extra_total or @warning_total or @error or @presence]">
+ <DIV>
+ <xsl:call-template name="ELEMENT">
+ <xsl:with-param name="class">r</xsl:with-param>
+ </xsl:call-template>
+ <xsl:if test="not(@presence)">
+ <xsl:apply-templates/>
+ </xsl:if>
+ </DIV>
+ </xsl:template>
+
+
+
+ <!-- support templates -->
+
+ <xsl:template name="ELEMENT">
+ <xsl:param name="class"/>
+ <xsl:param name="image"/>
+ <xsl:attribute name="class">
+ <xsl:value-of select="$class"/>
+ <xsl:if test="./node() and local-name() != 'assembly'">_</xsl:if>
+ </xsl:attribute>
+ <xsl:call-template name="toggle"/>
+ <xsl:choose>
+ <xsl:when test="@error and @error != 'todo'">
+ <xsl:element name="img">
+ <xsl:attribute name="src">cm/se.gif</xsl:attribute>
+ <xsl:attribute name="class">t</xsl:attribute>
+ <xsl:attribute name="title"><xsl:apply-templates select="warnings/warning" mode="hover"/></xsl:attribute>
+ </xsl:element>
+ </xsl:when>
+ <xsl:when test="@error = 'todo'">
+ <img src="cm/st.gif" class="t"/>
+ </xsl:when>
+ <xsl:when test="@presence = 'missing'">
+ <img src="cm/sm.gif" class="t"/>
+ </xsl:when>
+ <xsl:when test="@presence = 'extra'">
+ <img src="cm/sx.gif" class="t"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <img src="cm/sc.gif" class="t"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ <xsl:choose>
+ <xsl:when test="$image">
+ <img src="cm/{$image}.gif" class="t"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <img src="cm/{$class}.gif" class="t"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ <xsl:call-template name="name"/>
+ <xsl:if test="not(@presence)">
+ <xsl:call-template name="status"/>
+ </xsl:if>
+ </xsl:template>
+
+ <xsl:template name="status">
+ <xsl:if test="@complete_total and @complete_total != 0">
+ <SPAN class="st">
+ <img src="cm/sc.gif"/>
+ <xsl:text>: </xsl:text>
+ <xsl:value-of select="@complete_total"/>
+ <xsl:text>%</xsl:text>
+ </SPAN>
+ </xsl:if>
+ <xsl:if test="@todo_total">
+ <SPAN class="st">
+ <img src="cm/st.gif"/>: <xsl:value-of select="@todo_total"/>
+ </SPAN>
+ </xsl:if>
+ <xsl:if test="@missing_total">
+ <SPAN class="st">
+ <img src="cm/sm.gif"/>: <xsl:value-of select="@missing_total"/>
+ </SPAN>
+ </xsl:if>
+ <xsl:if test="@extra_total">
+ <SPAN class="st">
+ <img src="cm/sx.gif"/>: <xsl:value-of select="@extra_total"/>
+ </SPAN>
+ </xsl:if>
+ <xsl:if test="@warning_total">
+ <SPAN class="st">
+ <img src="cm/se.gif"/>: <xsl:value-of select="@warning_total"/>
+ </SPAN>
+ </xsl:if>
+ </xsl:template>
+
+ <xsl:template name="toggle">
+ <xsl:choose>
+ <xsl:when test="not(@presence) and .//*[@missing_total or @todo_total or @extra_total or @warning_total or @error or @presence] and local-name() != 'assembly'">
+ <IMG src="cm/tp.gif" class="t"/>
+ </xsl:when>
+ <xsl:when test="not(@presence) and .//*[@missing_total or @todo_total or @extra_total or @warning_total or @error or @presence]">
+ <IMG src="cm/tm.gif" class="t"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <IMG src="cm/tb.gif"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+ <xsl:template name="name">
+ <xsl:if test="@name">
+ <SPAN class="l"><xsl:value-of select="@name"/></SPAN>
+ </xsl:if>
+ </xsl:template>
+
+ <xsl:template match="warnings/warning" mode="hover">
+ <xsl:text>WARNING: </xsl:text>
+ <xsl:value-of select="@text"/>
+ </xsl:template>
+
+</xsl:stylesheet>
diff --git a/mcs/tools/gacutil/ChangeLog b/mcs/tools/gacutil/ChangeLog
new file mode 100644
index 00000000000..95b50485816
--- /dev/null
+++ b/mcs/tools/gacutil/ChangeLog
@@ -0,0 +1,37 @@
+2003-11-16 Sebastien Pouliot <spouliot@videotron.ca>
+
+ * gacutil.cs: Added strongname validation
+ * Makefile: Added a reference to Mono.Security assembly.
+
+2003-11-16 Todd Berman <tberman@gentoo.org>
+
+ * gacutil.cs: /il functionality
+ * gacutil.cs: /ul functionality
+ * TODO: updated
+ * gacutil.cs: help text added.
+
+2003-11-15 Todd Berman <tberman@gentoo.org>
+
+ * gacutil.cs: Added reference counting for installation and deletion.
+ An assembly will have a RefCount of 1 if --force is used.
+ * gacutil.cs: Changed ... + Path.DirSepChar + ... to Path.Combine
+ Thanks to Ben Maurer. Turns out code marked as potentially not
+ needed was not needed, now refcounting with /u assemblyname works
+ as well.
+ * gacutil.cs: Incorporated uac (User Assembly Cache), needs some
+ machine.config security checking as well.
+
+2003-11-14 Todd Berman <tberman@gentoo.org>
+
+ * gacutil.cs: added proper removal of assemblies, now the version=
+ syntax also works.
+ * gacutil.exe: somehow got added, removing, duh.
+
+2003-11-12 Todd Berman <tberman@gentoo.org>
+
+ * Makefile:
+ * TODO:
+ * README:
+ * ChangeLog:
+ * gacutil.exe.sources:
+ * gacutil.cs: Added
diff --git a/mcs/tools/gacutil/Makefile b/mcs/tools/gacutil/Makefile
new file mode 100644
index 00000000000..f72b7176ee8
--- /dev/null
+++ b/mcs/tools/gacutil/Makefile
@@ -0,0 +1,8 @@
+thisdir = tools/gacutil
+SUBDIRS =
+include ../../build/rules.make
+
+LOCAL_MCS_FLAGS = /r:Mono.Security.dll
+PROGRAM = gacutil.exe
+
+include ../../build/executable.make
diff --git a/mcs/tools/gacutil/README b/mcs/tools/gacutil/README
new file mode 100644
index 00000000000..fc09613bf02
--- /dev/null
+++ b/mcs/tools/gacutil/README
@@ -0,0 +1,9 @@
+The gacutil.exe is mostly feature complete with the ms.net impl.
+
+Right now the gac_path is hardcoded to a very unportable value:
+
+/usr/lib/mono/gac
+
+This will be changed when the icall to retreive the location of the gac is put into the runtime.
+
+NOTE: not all exceptions are caught, if you get one, file a bug and I will fix it.
diff --git a/mcs/tools/gacutil/TODO b/mcs/tools/gacutil/TODO
new file mode 100644
index 00000000000..1fb3f9ca6e3
--- /dev/null
+++ b/mcs/tools/gacutil/TODO
@@ -0,0 +1,5 @@
+Items that need to be completed, in a relative scale of importance:
+
+1) icall to get gac location.
+2) Checking for valid strong names before installing to gac. (spoulit)
+3) Code audit.
diff --git a/mcs/tools/gacutil/gacutil.cs b/mcs/tools/gacutil/gacutil.cs
new file mode 100644
index 00000000000..e17040af1ba
--- /dev/null
+++ b/mcs/tools/gacutil/gacutil.cs
@@ -0,0 +1,403 @@
+// GacUtil
+//
+// Author: Todd Berman <tberman@gentoo.org>
+//
+// (C) 2003 Todd Berman
+
+using System;
+using System.IO;
+using System.Text;
+using System.Reflection;
+using System.Collections;
+
+using Mono.Security;
+
+namespace Mono.Tools
+{
+
+ public class Driver
+ {
+
+ private string gac_path = "/usr/lib/mono/gac/";
+
+ public static void Main (string[] args)
+ {
+ Driver d = new Driver ();
+ d.Run (args);
+ }
+
+ public void Run (string[] args)
+ {
+ if (args.Length == 0) {
+ ShowHelp (false);
+ return;
+ }
+
+ if (args[0] == "/user" || args[0] == "--user") {
+ //FIXME: Need to check machine.config to make sure this is legal (potential security hole)
+ gac_path = Path.Combine (Path.Combine (Environment.GetFolderPath (Environment.SpecialFolder.Personal), ".mono"), "gac");
+ gac_path += Path.DirectorySeparatorChar;
+
+ string[] stripped = new string[args.Length - 1];
+ Array.Copy (args, 1, stripped, 0, args.Length - 1);
+ args = stripped;
+ }
+
+ string[] remainder_args = new string[args.Length - 1];
+
+ if (args.Length >= 2) {
+ Array.Copy (args, 1, remainder_args, 0, args.Length - 1);
+ }
+
+ switch (args[0]) {
+ case "/?":
+ case "--help":
+ ShowHelp (true);
+ break;
+ case "/i":
+ case "--install":
+ InstallAssembly (remainder_args);
+ break;
+ case "/l":
+ case "--ls":
+ ListAssemblies (remainder_args);
+ break;
+ case "/u":
+ case "--uninstall":
+ UninstallAssemblies (remainder_args);
+ break;
+ case "/il":
+ case "--install-from-list":
+ InstallAssembliesFromList (remainder_args);
+ break;
+ case "/ul":
+ case "--uninstall-from-list":
+ UninstallAssembliesFromList (remainder_args);
+ break;
+ default:
+ ShowHelp (false);
+ break;
+ }
+ }
+
+ public void InstallAssembliesFromList (string[] args)
+ {
+ if (args.Length == 0) {
+ Console.WriteLine ("ERROR: need a file passed");
+ return;
+ }
+
+ if (!File.Exists (args[0])) {
+ Console.WriteLine ("ERROR: file '" + args[0] + "' does not exist");
+ return;
+ }
+
+ string[] perFile = args;
+
+ using (StreamReader s = File.OpenText (args[0])) {
+ string line;
+
+ while((line = s.ReadLine()) != null) {
+ perFile[0] = line;
+ InstallAssembly (perFile);
+ }
+ }
+ }
+
+ public void UninstallAssembliesFromList (string[] args)
+ {
+ if (args.Length == 0) {
+ Console.WriteLine ("ERROR: file must be passed.");
+ return;
+ }
+
+ if (!File.Exists (args[0])) {
+ Console.WriteLine ("ERROR: file '" + args[0] + "' does not exist");
+ return;
+ }
+
+ using (StreamReader s = File.OpenText (args[0])) {
+ string line;
+
+ while ((line = s.ReadLine ()) != null) {
+ UninstallAssemblies (new string[] { line } );
+ }
+ }
+ }
+
+ public void UninstallAssemblies (string[] args)
+ {
+ if(args.Length == 0) {
+ Console.WriteLine ("ERROR: need an argument to uninstall");
+ return;
+ }
+
+ string joinedArgs = String.Join ("", args);
+
+ string[] assemblyPieces = joinedArgs.Split(new char[] { ',' });
+
+ Hashtable paramInfo = new Hashtable ();
+
+ foreach (string item in assemblyPieces) {
+ string[] pieces = item.Trim ().Split (new char[] { '=' }, 2);
+ if(pieces.Length == 1)
+ paramInfo["assembly"] = pieces[0];
+ else
+ paramInfo[pieces[0].ToLower ()] = pieces[1];
+ }
+
+ if (!Directory.Exists (Path.Combine (gac_path, (string) paramInfo["assembly"]))) {
+ Console.WriteLine ("ERROR: Assembly not in gac.");
+ return;
+ }
+
+ string searchString = (string) paramInfo["assembly"] + Path.DirectorySeparatorChar;
+
+ if (paramInfo.Keys.Count != 1) {
+ if (paramInfo["version"] != null) {
+ searchString += (string) paramInfo["version"] + "*";
+ }
+ } else {
+ searchString += "*";
+ }
+
+ string[] directories = Directory.GetDirectories (gac_path, searchString);
+
+ foreach (string dir in directories) {
+ Hashtable info = GetAssemblyInfo (Path.Combine (dir, "__AssemblyInfo__"));
+ if(Convert.ToInt32 (info["RefCount"]) == 1) {
+ Directory.Delete (dir, true);
+ Console.WriteLine ("Assembly removed from the gac.");
+ } else {
+ info["RefCount"] = ((int) Convert.ToInt32 (info["RefCount"]) - 1).ToString ();
+ WriteAssemblyInfo (Path.Combine (dir, "__AssemblyInfo__"), info);
+ Console.WriteLine ("Assembly was not deleted because its still needed by other applications");
+ }
+ }
+ if(Directory.GetDirectories (Path.Combine (gac_path, (string) paramInfo["assembly"])).Length == 0) {
+ Console.WriteLine ("Cleaning assembly dir, its empty");
+ Directory.Delete (Path.Combine (gac_path, (string) paramInfo["assembly"]));
+ }
+
+ }
+
+ public void ListAssemblies (string[] args)
+ {
+ Console.WriteLine ("The following assemblies are installed into the GAC:");
+ DirectoryInfo d = new DirectoryInfo (gac_path);
+ foreach (DirectoryInfo namedDir in d.GetDirectories ()) {
+ foreach (DirectoryInfo assemblyDir in namedDir.GetDirectories ()) {
+ Hashtable assemblyInfo = GetAssemblyInfo (Path.Combine (assemblyDir.FullName, "__AssemblyInfo__"));
+ Console.WriteLine ("\t" + assemblyInfo["DisplayName"]);
+ }
+ }
+ }
+
+ private Hashtable GetAssemblyInfo (string filename)
+ {
+ Hashtable infoHash = new Hashtable ();
+ using (StreamReader s = new StreamReader (filename)) {
+ string line;
+
+ while ((line = s.ReadLine ()) != null) {
+ string[] splitStr = line.Split (new char[] { '=' }, 2);
+ infoHash[splitStr[0]] = splitStr[1];
+ }
+ }
+ return infoHash;
+ }
+
+ private void WriteAssemblyInfo (string filename, Hashtable info)
+ {
+ using (StreamWriter s = File.CreateText (filename)) {
+ foreach (string key in info.Keys) {
+ s.WriteLine (key + "=" + (string) info[key]);
+ }
+ }
+ }
+
+ public void InstallAssembly (string[] args)
+ {
+ if(args.Length == 0) {
+ Console.WriteLine ("ERROR: You must specify a valid assembly name after the install switch");
+ return;
+ }
+
+ if(!File.Exists (args[0])) {
+ Console.WriteLine ("ERROR: The assembly: '" + args[0] + "' does not exist");
+ return;
+ }
+
+ AssemblyName an = AssemblyName.GetAssemblyName (args[0]);
+
+ byte[] pub_tok = an.GetPublicKeyToken ();
+
+ if (pub_tok == null || pub_tok.Length == 0) {
+ Console.WriteLine ("ERROR: assembly has no valid public key token");
+ return;
+ }
+
+ byte[] akey = an.GetPublicKey ();
+ if (akey == null || akey.Length < 12) {
+ Console.WriteLine ("ERROR: assembly has no valid public key token");
+ return;
+ }
+ byte[] pkey = new byte [akey.Length - 12];
+ Buffer.BlockCopy (akey, 12, pkey, 0, pkey.Length);
+ StrongName sn = new StrongName (pkey);
+ if (!sn.Verify (args[0])) {
+ Console.WriteLine ("ERROR: invalid strongname signature in assembly");
+ return;
+ }
+
+ bool force = false;
+
+ if(args.Length == 2 && (args[1] == "/f" || args[1] == "--force"))
+ force = true;
+
+
+ string version_token = an.Version + "__" + GetStringToken (an.GetPublicKeyToken ());
+
+ string fullPath = String.Format ("{0}{3}{1}{3}{2}{3}", gac_path, an.Name, version_token, Path.DirectorySeparatorChar);
+
+ if (File.Exists (fullPath + an.Name + ".dll") && force == false) {
+ Hashtable assemInfo = GetAssemblyInfo (fullPath + "__AssemblyInfo__");
+ assemInfo["RefCount"] = ((int) Convert.ToInt32 (assemInfo["RefCount"]) + 1).ToString ();
+ WriteAssemblyInfo (fullPath + "__AssemblyInfo__", assemInfo);
+ Console.WriteLine ("RefCount of assembly '" + an.Name + "' increased by one.");
+ return;
+ }
+
+ if(!EnsureDirectories (an.Name, version_token)) {
+ Console.WriteLine ("ERROR: gac directories could not be created, possibly permission issues");
+ return;
+ }
+
+ File.Copy (args[0], fullPath + an.Name + ".dll", force);
+
+ Hashtable info = new Hashtable ();
+
+ info["DisplayName"] = an.FullName;
+ info["RefCount"] = 1.ToString ();
+
+ WriteAssemblyInfo (fullPath + "__AssemblyInfo__", info);
+
+ Console.WriteLine ("Assembly installed into the gac");
+ }
+
+ private bool EnsureDirectories (string name, string tok)
+ {
+ //FIXME: Workaround for broken DirectoryInfo.CreateSubdirectory
+ try {
+ DirectoryInfo d = new DirectoryInfo (gac_path);
+
+ d.CreateSubdirectory (name);
+ d = new DirectoryInfo (Path.Combine (gac_path, name));
+ d.CreateSubdirectory (tok);
+ } catch {
+ return false;
+ }
+ return true;
+ }
+
+ private string GetStringToken (byte[] tok)
+ {
+ StringBuilder sb = new StringBuilder ();
+ for (int i = 0; i < tok.Length ; i++) {
+ sb.Append (tok[i].ToString ("x2"));
+ }
+ return sb.ToString ();
+ }
+
+ public void ShowHelp (bool detailed)
+ {
+ StringBuilder sb = new StringBuilder ();
+
+ sb.Append ("Usage: gacutil.exe <commands> [ <options> ]\n");
+ sb.Append ("Commands:\n");
+ sb.Append (" /i <assembly_path> [ /f ]\n");
+ if (detailed == false) {
+ sb.Append (" Installs an assembly into the global assembly cache\n");
+ } else {
+ sb.Append (" Installs an assembly to the global assembly cache. <assembly_path> is the\n name of the file that contains the assembly manifest. \n Example: /i myDll.dll\n");
+ }
+
+ sb.Append ("\n");
+
+ sb.Append (" /il <assembly_path_list_file> [ /f ]\n");
+ if (detailed == false) {
+ sb.Append (" Installs one or more assemblies into the global assembly cache\n");
+ } else {
+ sb.Append (" Installs on or more assemblies to the global assembly cache. \n <assembly_list_file is the path to a text file that contains a list of \n assembly manifest file paths. Individual paths in the text file must be \n separated by a newline.\n");
+ sb.Append (" Example: /il MyAssemblyList\n");
+ sb.Append (" MyAssemblyList content:\n");
+ sb.Append (" Mydll.dll\n");
+ sb.Append (" Mydll2.dll\n");
+ sb.Append (" path/to/myDll3.dll\n");
+ }
+
+ sb.Append ("\n");
+
+ sb.Append (" /u <assembly_display_name>\n");
+ if (detailed == false) {
+ sb.Append (" Uninstalls an assembly from the global assembly cache\n");
+ } else {
+ sb.Append (" Uninstalls an assembly. <assembly_display_name> is the name of the assembly\n");
+ sb.Append (" (partial or fully qualified) to remove from the global assembly cache. \n If a partial name is specified all matching assemblies will be uninstalled.\n");
+ sb.Append (" Example: /u myDll,Version=1.2.1.0\n");
+ }
+
+ sb.Append ("\n");
+
+ sb.Append (" /ul <assembly_display_name_list_file>\n");
+ if (detailed == false) {
+ sb.Append (" Uninstalls one or more assemblies from the global assembly cache\n");
+ } else {
+ sb.Append (" Uninstalls one or more assemblies from the global assembly cache. \n <assembly_display_name_list_file> is the path to a text file that contains\n a list of assembly names. Individual names in the text file must be \n separated by a newline.\n");
+ sb.Append (" Example: /ul MyAssemblyList\n");
+ sb.Append (" MyAssemblyList content:\n");
+ sb.Append (" MyDll1.dll,Version=1.0.0.0\n");
+ sb.Append (" MyDll2.dll,Version=1.2.0.0\n");
+ }
+
+ sb.Append ("\n");
+
+ sb.Append (" /l\n");
+ if (detailed == false) {
+ sb.Append (" List the global assembly cache\n");
+ } else {
+ sb.Append (" Lists the contents of the global assembly cache.\n");
+ }
+
+ sb.Append ("\n");
+
+ sb.Append (" /?\n");
+ if (detailed == false) {
+ sb.Append (" Displays a detailed help screen\n");
+ } else {
+ sb.Append (" Displays a detailed help screen\n");
+ }
+
+ sb.Append ("\n");
+
+ if (detailed == true) {
+ sb.Append ("Options:\n");
+ sb.Append (" /f\n");
+ sb.Append (" Forces reinstall of assembly, resets reference count\n");
+ sb.Append ("\n");
+ sb.Append ("\n");
+ sb.Append ("Note, mono's gacutil also supports these unix like aliases for its commands:\n");
+ sb.Append (" /i -> --install\n");
+ sb.Append (" /il -> --install-from-list\n");
+ sb.Append (" /u -> --uninstall\n");
+ sb.Append (" /ul -> --uninstall-from-list\n");
+ sb.Append (" /l -> --ls\n");
+ sb.Append (" /f -> --force\n");
+ sb.Append ("\n");
+ sb.Append ("Mono also allows a User Assembly Cache, this cache can be accessed by passing\n/user as the first argument to gacutil.exe\n");
+ }
+
+ Console.WriteLine (sb.ToString ());
+ }
+ }
+}
diff --git a/mcs/tools/gacutil/gacutil.exe.sources b/mcs/tools/gacutil/gacutil.exe.sources
new file mode 100644
index 00000000000..c8046f4e2bd
--- /dev/null
+++ b/mcs/tools/gacutil/gacutil.exe.sources
@@ -0,0 +1 @@
+gacutil.cs
diff --git a/mcs/tools/security/ChangeLog b/mcs/tools/security/ChangeLog
index b48747bd496..478fbf2fe11 100644
--- a/mcs/tools/security/ChangeLog
+++ b/mcs/tools/security/ChangeLog
@@ -1,3 +1,13 @@
+2003-11-10 Todd Berman <tberman@gentoo.org>
+
+ * sn.cs: Wow, gonzalo is so super s-m-a-r-t, changing up last fix to
+ make it nice and pretty.
+
+2003-11-10 Todd Berman <tberman@gentoo.org>
+
+ * sn.cs: No more OutOfMemoryExceptions if the GetPublicKey returns
+ a new byte[0].
+
2003-10-30 Sebastien Pouliot <spouliot@videotron.ca>
* sn.cs: Fixed strongname generation for small exponents (like 17).
diff --git a/mcs/tools/security/sn.cs b/mcs/tools/security/sn.cs
index 2b8970405ed..5ee7e0fc817 100644
--- a/mcs/tools/security/sn.cs
+++ b/mcs/tools/security/sn.cs
@@ -383,6 +383,10 @@ namespace Mono.Tools {
filename = args [i++];
an = AssemblyName.GetAssemblyName (filename);
byte[] akey = an.GetPublicKey ();
+ if(akey == null || akey.Length < 12) {
+ Console.WriteLine (filename + " is not a strongly named assembly");
+ break;
+ }
byte[] pkey = new byte [akey.Length - 12];
Buffer.BlockCopy (akey, 12, pkey, 0, pkey.Length);
sn = new StrongName (pkey);
diff --git a/mono/arch/ChangeLog b/mono/arch/ChangeLog
index 655dcbaff24..1dadd04cbd0 100644
--- a/mono/arch/ChangeLog
+++ b/mono/arch/ChangeLog
@@ -1,3 +1,8 @@
+
+Thu Nov 13 16:24:29 CET 2003 Paolo Molaro <lupus@ximian.com>
+
+ * ppc/ppc-codegen.h: fixed most of the incorrect macros from ct.
+
2003-10-31 Zoltan Varga <vargaz@freemail.hu>
* */tramp.c (mono_create_method_pointer): Rename to
diff --git a/mono/arch/ppc/ppc-codegen.h b/mono/arch/ppc/ppc-codegen.h
index 2f62aa4d3d2..dd7b4b7e1cb 100644
--- a/mono/arch/ppc/ppc-codegen.h
+++ b/mono/arch/ppc/ppc-codegen.h
@@ -114,6 +114,7 @@ enum {
#define ppc_emit32(c,x) do { *((guint32 *) c) = x; ((guint32 *)c)++;} while (0)
#define ppc_is_imm16(val) ((gint)val >= (gint)-(1<<15) && (gint)val <= (gint)((1<<15)-1))
+#define ppc_is_uimm16(val) ((gint)val >= 0 && (gint)val <= 65535)
#define ppc_load(c,D,v) do { \
if (ppc_is_imm16 ((v))) { \
@@ -290,70 +291,70 @@ my and Ximian's copyright to this code. ;)
#define ppc_eqv(c,A,S,B) ppc_eqvx(c,A,S,B,0)
#define ppc_eqvd(c,A,S,B) ppc_eqvx(c,A,S,B,1)
-#define ppc_extsbx(c,A,S,Rc) ppc_emit32(c, (31 << 26) | (S << 21) | (A << 16) | (0 << 12) | (954 << 1) | Rc)
+#define ppc_extsbx(c,A,S,Rc) ppc_emit32(c, (31 << 26) | (S << 21) | (A << 16) | (0 << 11) | (954 << 1) | Rc)
#define ppc_extsb(c,A,S) ppc_extsbx(c,A,S,0)
#define ppc_extsbd(c,A,S) ppc_extsbx(c,A,S,1)
-#define ppc_extshx(c,A,S,Rc) ppc_emit32(c, (31 << 26) | (S << 21) | (A << 16) | (0 << 12) | (922 << 1) | Rc)
+#define ppc_extshx(c,A,S,Rc) ppc_emit32(c, (31 << 26) | (S << 21) | (A << 16) | (0 << 11) | (922 << 1) | Rc)
#define ppc_extsh(c,A,S) ppc_extshx(c,A,S,0)
#define ppc_extshd(c,A,S) ppc_extshx(c,A,S,1)
-#define ppc_fabsx(c,D,B,Rc) ppc_emit32(c, (63 << 26) | (D << 21) | (0 << 16) | (B << 12) | (264 << 1) | Rc)
+#define ppc_fabsx(c,D,B,Rc) ppc_emit32(c, (63 << 26) | (D << 21) | (0 << 16) | (B << 11) | (264 << 1) | Rc)
#define ppc_fabs(c,D,B) ppc_fabsx(c,D,B,0)
#define ppc_fabsd(c,D,B) ppc_fabsx(c,D,B,1)
-#define ppc_faddx(c,D,A,B,Rc) ppc_emit32(c, (63 << 26) | (D << 21) | (A << 16) | (B << 12) | (0 << 7) | (21 << 1) | Rc)
+#define ppc_faddx(c,D,A,B,Rc) ppc_emit32(c, (63 << 26) | (D << 21) | (A << 16) | (B << 11) | (0 << 6) | (21 << 1) | Rc)
#define ppc_fadd(c,D,A,B) ppc_faddx(c,D,A,B,0)
#define ppc_faddd(c,D,A,B) ppc_faddx(c,D,A,B,1)
-#define ppc_faddsx(c,D,A,B,Rc) ppc_emit32(c, (59 << 26) | (D << 21) | (A << 16) | (B << 12) | (0 << 7) | (21 << 1) | Rc)
+#define ppc_faddsx(c,D,A,B,Rc) ppc_emit32(c, (59 << 26) | (D << 21) | (A << 16) | (B << 11) | (0 << 6) | (21 << 1) | Rc)
#define ppc_fadds(c,D,A,B) ppc_faddsx(c,D,A,B,0)
#define ppc_faddsd(c,D,A,B) ppc_faddsx(c,D,A,B,1)
-#define ppc_fcmpo(c,crfD,A,B) ppc_emit32(c, (63 << 26) | (crfD << 23) | (0 << 21) | (A << 16) | (B << 12) | (32 << 1) | 0)
-#define ppc_fcmpu(c,crfD,A,B) ppc_emit32(c, (63 << 26) | (crfD << 23) | (0 << 21) | (A << 16) | (B << 12) | (0 << 1) | 0)
+#define ppc_fcmpo(c,crfD,A,B) ppc_emit32(c, (63 << 26) | (crfD << 23) | (0 << 21) | (A << 16) | (B << 11) | (32 << 1) | 0)
+#define ppc_fcmpu(c,crfD,A,B) ppc_emit32(c, (63 << 26) | (crfD << 23) | (0 << 21) | (A << 16) | (B << 11) | (0 << 1) | 0)
-#define ppc_fctiwx(c,D,B,Rc) ppc_emit32(c, (63 << 26) | (D << 21) | (0 << 16) | (B << 12) | (14 << 1) | Rc)
+#define ppc_fctiwx(c,D,B,Rc) ppc_emit32(c, (63 << 26) | (D << 21) | (0 << 16) | (B << 11) | (14 << 1) | Rc)
#define ppc_fctiw(c,D,B) ppc_fctiwx(c,D,B,0)
#define ppc_fctiwd(c,D,B) ppc_fctiwx(c,D,B,1)
-#define ppc_fctiwzx(c,D,B,Rc) ppc_emit32(c, (63 << 26) | (D << 21) | (0 << 16) | (B << 12) | (15 << 1) | Rc)
+#define ppc_fctiwzx(c,D,B,Rc) ppc_emit32(c, (63 << 26) | (D << 21) | (0 << 16) | (B << 11) | (15 << 1) | Rc)
#define ppc_fctiwz(c,D,B) ppc_fctiwzx(c,D,B,0)
#define ppc_fctiwzd(c,D,B) ppc_fctiwzx(c,D,B,1)
-#define ppc_fdivx(c,D,A,B,Rc) ppc_emit32(c, (63 << 26) | (D << 21) | (A << 16) | (B << 12) | (0 << 7) | (18 << 1) | Rc)
+#define ppc_fdivx(c,D,A,B,Rc) ppc_emit32(c, (63 << 26) | (D << 21) | (A << 16) | (B << 11) | (0 << 6) | (18 << 1) | Rc)
#define ppc_fdiv(c,D,A,B) ppc_fdivx(c,D,A,B,0)
#define ppc_fdivd(c,D,A,B) ppc_fdivx(c,D,A,B,1)
-#define ppc_fdivsx(c,D,A,B,Rc) ppc_emit32(c, (59 << 26) | (D << 21) | (A << 16) | (B << 12) | (0 << 7) | (18 << 1) | Rc)
+#define ppc_fdivsx(c,D,A,B,Rc) ppc_emit32(c, (59 << 26) | (D << 21) | (A << 16) | (B << 11) | (0 << 6) | (18 << 1) | Rc)
#define ppc_fdivs(c,D,A,B) ppc_fdivsx(c,D,A,B,0)
#define ppc_fdivsd(c,D,A,B) ppc_fdivsx(c,D,A,B,1)
-#define ppc_fmaddx(c,D,A,B,C,Rc) ppc_emit32(c, (63 << 26) | (D << 21) | (A << 16) | (B << 12) | (C << 7) | (29 << 1) | Rc)
+#define ppc_fmaddx(c,D,A,B,C,Rc) ppc_emit32(c, (63 << 26) | (D << 21) | (A << 16) | (B << 11) | (C << 6) | (29 << 1) | Rc)
#define ppc_fmadd(c,D,A,B,C) ppc_fmaddx(c,D,A,B,C,0)
#define ppc_fmaddd(c,D,A,B,C) ppc_fmaddx(c,D,A,B,C,1)
-#define ppc_fmaddsx(c,D,A,B,C,Rc) ppc_emit32(c, (59 << 26) | (D << 21) | (A << 16) | (B << 12) | (C << 7) | (29 << 1) | Rc)
+#define ppc_fmaddsx(c,D,A,B,C,Rc) ppc_emit32(c, (59 << 26) | (D << 21) | (A << 16) | (B << 11) | (C << 6) | (29 << 1) | Rc)
#define ppc_fmadds(c,D,A,B,C) ppc_fmaddsx(c,D,A,B,C,0)
#define ppc_fmaddsd(c,D,A,B,C) ppc_fmaddsx(c,D,A,B,C,1)
-#define ppc_fmrx(c,D,B,Rc) ppc_emit32(c, (63 << 26) | (D << 21) | (0 << 16) | (B << 12) | (72 << 1) | Rc)
+#define ppc_fmrx(c,D,B,Rc) ppc_emit32(c, (63 << 26) | (D << 21) | (0 << 16) | (B << 11) | (72 << 1) | Rc)
#define ppc_fmr(c,D,B) ppc_fmrx(c,D,B,0)
#define ppc_fmrd(c,D,B) ppc_fmrx(c,D,B,1)
-#define ppc_fmsubx(c,D,A,C,B,Rc) ppc_emit32(c, (63 << 26) | (D << 21) | (A << 16) | (C << 7) | (28 << 1) | Rc)
+#define ppc_fmsubx(c,D,A,C,B,Rc) ppc_emit32(c, (63 << 26) | (D << 21) | (A << 16) | (B << 11) | (C << 6) | (28 << 1) | Rc)
#define ppc_fmsub(c,D,A,C,B) ppc_fmsubx(c,D,A,C,B,0)
#define ppc_fmsubd(c,D,A,C,B) ppc_fmsubx(c,D,A,C,B,1)
-#define ppc_fmsubsx(c,D,A,C,B,Rc) ppc_emit32(c, (59 << 26) | (D << 21) | (A << 16) | (B << 11) | (C << 7) | (28 << 1) | Rc)
+#define ppc_fmsubsx(c,D,A,C,B,Rc) ppc_emit32(c, (59 << 26) | (D << 21) | (A << 16) | (B << 11) | (C << 6) | (28 << 1) | Rc)
#define ppc_fmsubs(c,D,A,C,B) ppc_fmsubsx(c,D,A,C,B,0)
#define ppc_fmsubsd(c,D,A,C,B) ppc_fmsubsx(c,D,A,C,B,1)
-#define ppc_fmulx(c,D,A,C,Rc) ppc_emit32(c, (63 << 26) | (D << 21) | (A << 16) | (0 << 11) | (C << 7) | (25 << 1) | Rc)
+#define ppc_fmulx(c,D,A,C,Rc) ppc_emit32(c, (63 << 26) | (D << 21) | (A << 16) | (0 << 11) | (C << 6) | (25 << 1) | Rc)
#define ppc_fmul(c,D,A,C) ppc_fmulx(c,D,A,C,0)
#define ppc_fmuld(c,D,A,C) ppc_fmulx(c,D,A,C,1)
-#define ppc_fmulsx(c,D,A,C,Rc) ppc_emit32(c, (59 << 26) | (D << 21) | (A << 16) | (0 << 11) | (C << 7) | (25 << 1) | Rc)
+#define ppc_fmulsx(c,D,A,C,Rc) ppc_emit32(c, (59 << 26) | (D << 21) | (A << 16) | (0 << 11) | (C << 6) | (25 << 1) | Rc)
#define ppc_fmuls(c,D,A,C) ppc_fmulsx(c,D,A,C,0)
#define ppc_fmulsd(c,D,A,C) ppc_fmulsx(c,D,A,C,1)
@@ -365,23 +366,23 @@ my and Ximian's copyright to this code. ;)
#define ppc_fneg(c,D,B) ppc_fnegx(c,D,B,0)
#define ppc_fnegd(c,D,B) ppc_fnegx(c,D,B,1)
-#define ppc_fnmaddx(c,D,A,C,B,Rc) ppc_emit32(c, (63 << 26) | (D << 21) | (A << 16) | (B << 11) | (C << 7) | (31 << 1) | Rc)
+#define ppc_fnmaddx(c,D,A,C,B,Rc) ppc_emit32(c, (63 << 26) | (D << 21) | (A << 16) | (B << 11) | (C << 6) | (31 << 1) | Rc)
#define ppc_fnmadd(c,D,A,C,B) ppc_fnmaddx(c,D,A,C,B,0)
#define ppc_fnmaddd(c,D,A,C,B) ppc_fnmaddx(c,D,A,C,B,1)
-#define ppc_fnmaddsx(c,D,A,C,B,Rc) ppc_emit32(c, (59 << 26) | (D << 21) | (A << 16) | (B << 11) | (C << 7) | (31 << 1) | Rc)
+#define ppc_fnmaddsx(c,D,A,C,B,Rc) ppc_emit32(c, (59 << 26) | (D << 21) | (A << 16) | (B << 11) | (C << 6) | (31 << 1) | Rc)
#define ppc_fnmadds(c,D,A,C,B) ppc_fnmaddsx(c,D,A,C,B,0)
#define ppc_fnmaddsd(c,D,A,C,B) ppc_fnmaddsx(c,D,A,C,B,1)
-#define ppc_fnmsubx(c,D,A,C,B,Rc) ppc_emit32(c, (63 << 26) | (D << 21) | (A << 16) | (B << 11) | (C << 7) | (30 << 1) | Rc)
+#define ppc_fnmsubx(c,D,A,C,B,Rc) ppc_emit32(c, (63 << 26) | (D << 21) | (A << 16) | (B << 11) | (C << 6) | (30 << 1) | Rc)
#define ppc_fnmsub(c,D,A,C,B) ppc_fnmsubx(c,D,A,C,B,0)
#define ppc_fnmsubd(c,D,A,C,B) ppc_fnmsubx(c,D,A,C,B,1)
-#define ppc_fnmsubsx(c,D,A,C,B,Rc) ppc_emit32(c, (59 << 26) | (D << 21) | (A << 16) | (B << 11) | (C << 7) | (30 << 1) | Rc)
+#define ppc_fnmsubsx(c,D,A,C,B,Rc) ppc_emit32(c, (59 << 26) | (D << 21) | (A << 16) | (B << 11) | (C << 6) | (30 << 1) | Rc)
#define ppc_fnmsubs(c,D,A,C,B) ppc_fnmsubsx(c,D,A,C,B,0)
#define ppc_fnmsubsd(c,D,A,C,B) ppc_fnmsubsx(c,D,A,C,B,1)
-#define ppc_fresx(c,D,B,Rc) ppc_emit32(c, (59 << 26) | (D << 21) | (0 << 16) | (B << 11) | (0 << 7) | (24 << 1) | Rc)
+#define ppc_fresx(c,D,B,Rc) ppc_emit32(c, (59 << 26) | (D << 21) | (0 << 16) | (B << 11) | (0 << 6) | (24 << 1) | Rc)
#define ppc_fres(c,D,B) ppc_fresx(c,D,B,0)
#define ppc_fresd(c,D,B) ppc_fresx(c,D,B,1)
@@ -389,27 +390,27 @@ my and Ximian's copyright to this code. ;)
#define ppc_frsp(c,D,B) ppc_frspx(c,D,B,0)
#define ppc_frspd(c,D,B) ppc_frspx(c,D,B,1)
-#define ppc_frsqrtex(c,D,B,Rc) ppc_emit32(c, (63 << 26) | (D << 21) | (0 << 16) | (B << 11) | (0 << 7) | (26 << 1) | Rc)
+#define ppc_frsqrtex(c,D,B,Rc) ppc_emit32(c, (63 << 26) | (D << 21) | (0 << 16) | (B << 11) | (0 << 6) | (26 << 1) | Rc)
#define ppc_frsqrte(c,D,B) ppc_frsqrtex(c,D,B,0)
#define ppc_frsqrted(c,D,B) ppc_frsqrtex(c,D,B,1)
-#define ppc_fselx(c,D,A,C,B,Rc) ppc_emit32(c, (63 << 26) | (D << 21) | (A << 16) | (B << 11) | (C << 7) | (23 << 1) | Rc)
+#define ppc_fselx(c,D,A,C,B,Rc) ppc_emit32(c, (63 << 26) | (D << 21) | (A << 16) | (B << 11) | (C << 6) | (23 << 1) | Rc)
#define ppc_fsel(c,D,A,C,B) ppc_fselx(c,D,A,C,B,0)
#define ppc_fseld(c,D,A,C,B) ppc_fselx(c,D,A,C,B,1)
-#define ppc_fsqrtx(c,D,B,Rc) ppc_emit32(c, (63 << 26) | (D << 21) | (0 << 16) | (B << 11) | (0 << 7) | (22 << 1) | Rc)
+#define ppc_fsqrtx(c,D,B,Rc) ppc_emit32(c, (63 << 26) | (D << 21) | (0 << 16) | (B << 11) | (0 << 6) | (22 << 1) | Rc)
#define ppc_fsqrt(c,D,B) ppc_fsqrtx(c,D,B,0)
#define ppc_fsqrtd(c,D,B) ppc_fsqrtx(c,D,B,1)
-#define ppc_fsqrtsx(c,D,B,Rc) ppc_emit32(c, (59 << 26) | (D << 21) | (0 << 16) | (B << 11) | (0 << 7) | (22 << 1) | Rc)
+#define ppc_fsqrtsx(c,D,B,Rc) ppc_emit32(c, (59 << 26) | (D << 21) | (0 << 16) | (B << 11) | (0 << 6) | (22 << 1) | Rc)
#define ppc_fsqrts(c,D,B) ppc_fsqrtsx(c,D,B,0)
#define ppc_fsqrtsd(c,D,B) ppc_fsqrtsx(c,D,B,1)
-#define ppc_fsubx(c,D,A,B,Rc) ppc_emit32(c, (63 << 26) | (D << 21) | (A << 16) | (B << 11) | (0 << 7) | (20 << 1) | Rc)
+#define ppc_fsubx(c,D,A,B,Rc) ppc_emit32(c, (63 << 26) | (D << 21) | (A << 16) | (B << 11) | (0 << 6) | (20 << 1) | Rc)
#define ppc_fsub(c,D,A,B) ppc_fsubx(c,D,A,B,0)
#define ppc_fsubd(c,D,A,B) ppc_fsubx(c,D,A,B,1)
-#define ppc_fsubsx(c,D,A,B,Rc) ppc_emit32(c, (59 << 26) | (D << 21) | (A << 16) | (B << 11) | (0 << 7) | (20 << 1) | Rc)
+#define ppc_fsubsx(c,D,A,B,Rc) ppc_emit32(c, (59 << 26) | (D << 21) | (A << 16) | (B << 11) | (0 << 6) | (20 << 1) | Rc)
#define ppc_fsubs(c,D,A,B) ppc_fsubsx(c,D,A,B,0)
#define ppc_fsubsd(c,D,A,B) ppc_fsubsx(c,D,A,B,1)
diff --git a/mono/benchmark/Makefile.am b/mono/benchmark/Makefile.am
index 857e5403f24..4273a7d134d 100644
--- a/mono/benchmark/Makefile.am
+++ b/mono/benchmark/Makefile.am
@@ -24,7 +24,8 @@ TESTSRC= \
readonly.cs \
bulkcpy.il \
math.cs \
- boxtest.cs
+ boxtest.cs \
+ valuetype-hash-equals.cs
TESTSI_TMP=$(TESTSRC:.cs=.exe)
TESTSI=$(TESTSI_TMP:.il=.exe)
diff --git a/mono/benchmark/valuetype-hash-equals.cs b/mono/benchmark/valuetype-hash-equals.cs
new file mode 100644
index 00000000000..2aa1a4ba324
--- /dev/null
+++ b/mono/benchmark/valuetype-hash-equals.cs
@@ -0,0 +1,75 @@
+using System;
+
+public class ValueType1
+{
+ static int Main ()
+ {
+ Blah a = new Blah ("abc", 1);
+ Blah b = new Blah ("ab" + 'c', 1);
+ long start, end;
+ start = Environment.TickCount;
+
+ start = Environment.TickCount;
+ for (int i = 0; i < 1000000; i++)
+ a.GetHashCode ();
+ end = Environment.TickCount;
+ Console.WriteLine ("struct common GetHashCode(): {0}", end-start);
+
+ start = Environment.TickCount;
+ for (int i = 0; i < 1000000; i++)
+ a.Equals (b);
+ end = Environment.TickCount;
+ Console.WriteLine ("struct common Equals(): {0}", end-start);
+
+ Blah2 a2 = new Blah2 ("abc", 1);
+ Blah2 b2 = new Blah2 ("abc", 1);
+ start = Environment.TickCount;
+ for (int i = 0; i < 1000000; i++)
+ a2.GetHashCode ();
+ end = Environment.TickCount;
+ Console.WriteLine ("struct specific GetHashCode(): {0}", end-start);
+
+ start = Environment.TickCount;
+ for (int i = 0; i < 1000000; i++)
+ a2.Equals (b2);
+ end = Environment.TickCount;
+ Console.WriteLine ("struct specific Equals(): {0}", end-start);
+
+ return 0;
+ }
+
+ struct Blah
+ {
+ public string s;
+ public int i;
+
+ public Blah (string s, int k)
+ {
+ this.s = s;
+ i = k;
+ }
+ }
+
+ struct Blah2
+ {
+ public string s;
+ public int i;
+
+ public Blah2 (string s, int k)
+ {
+ this.s = s;
+ i = k;
+ }
+
+ public override int GetHashCode () {
+ return i ^ s.GetHashCode ();
+ }
+ public override bool Equals (object obj) {
+ if (obj == null || !(obj is Blah2))
+ return false;
+ Blah2 b = (Blah2)obj;
+ return b.s == this.s && b.i == this.i;
+ }
+ }
+}
+
diff --git a/mono/dis/ChangeLog b/mono/dis/ChangeLog
index 6b23ebfed38..ed0357dffa4 100644
--- a/mono/dis/ChangeLog
+++ b/mono/dis/ChangeLog
@@ -1,3 +1,18 @@
+2003-11-26 Zoltan Varga <vargaz@freemail.hu>
+
+ * dump.c dump.h main.c: Added support for dumping the ImplMap table
+ (--implmap).
+
+ * main.c (dis_method_list): Avoid disassembling native code.
+
+2003-11-19 Zoltan Varga <vargaz@freemail.hu>
+
+ * get.c (dis_stringify_modifiers): Fix display of modreq and modopt.
+
+Thu Nov 13 16:12:09 CET 2003 Paolo Molaro <lupus@ximian.com>
+
+ * util.h, dump.c: get rid of ugly CSIZE macro.
+
2003-11-01 Zoltan Varga <vargaz@freemail.hu>
* main.c: Add disassembly of module, moduleref and file tables.
diff --git a/mono/dis/dump.c b/mono/dis/dump.c
index 1cf772da3a0..c518f528e39 100644
--- a/mono/dis/dump.c
+++ b/mono/dis/dump.c
@@ -137,7 +137,7 @@ dump_table_param (MonoImage *m)
for (i = 0; i < t->rows; i++){
guint32 cols [MONO_PARAM_SIZE];
- mono_metadata_decode_row (t, i, cols, CSIZE (cols));
+ mono_metadata_decode_row (t, i, cols, MONO_PARAM_SIZE);
fprintf (output, "%d: 0x%04x %d %s\n",
i + 1,
cols [MONO_PARAM_FLAGS], cols [MONO_PARAM_SEQUENCE],
@@ -271,7 +271,7 @@ dump_table_class_layout (MonoImage *m)
for (i = 0; i < t->rows; i++){
guint32 cols [MONO_CLASS_LAYOUT_SIZE];
- mono_metadata_decode_row (t, i, cols, CSIZE (cols));
+ mono_metadata_decode_row (t, i, cols, MONO_CLASS_LAYOUT_SIZE);
fprintf (output, "%d: PackingSize=%d ClassSize=%d Parent=%s\n",
i + 1, cols [MONO_CLASS_LAYOUT_PACKING_SIZE],
@@ -559,6 +559,31 @@ dump_table_method (MonoImage *m)
}
+void
+dump_table_implmap (MonoImage *m)
+{
+ MonoTableInfo *t = &m->tables [MONO_TABLE_IMPLMAP];
+ MonoTableInfo *td = &m->tables [MONO_TABLE_MODULEREF];
+ int i;
+
+ fprintf (output, "ImplMap Table (1..%d)\n", t->rows);
+
+ for (i = 1; i <= t->rows; i++){
+ guint32 cols [MONO_IMPLMAP_SIZE];
+ char *method;
+
+ mono_metadata_decode_row (t, i - 1, cols, MONO_IMPLMAP_SIZE);
+
+ method = get_method (m, MONO_TOKEN_METHOD_DEF | (cols [MONO_IMPLMAP_MEMBER] >> MEMBERFORWD_BITS));
+
+ fprintf (output, "%d: %s %d (%s %s)\n", i,
+ method,
+ cols [MONO_IMPLMAP_FLAGS],
+ mono_metadata_string_heap (m, cols [MONO_IMPLMAP_NAME]),
+ mono_metadata_string_heap (m, mono_metadata_decode_row_col (td, cols [MONO_IMPLMAP_SCOPE] - 1, MONO_MODULEREF_NAME)));
+ }
+}
+
static guint32
method_dor_to_token (guint32 idx) {
switch (idx & METHODDEFORREF_MASK) {
@@ -903,6 +928,7 @@ dump_table_exported (MonoImage *m)
int i;
const char *name, *nspace;
char *impl;
+ guint32 index;
fprintf (output, "ExportedType Table (1..%d)\n", t->rows);
for (i = 1; i <= t->rows; i++) {
@@ -910,7 +936,8 @@ dump_table_exported (MonoImage *m)
name = mono_metadata_string_heap (m, cols [MONO_EXP_TYPE_NAME]);
nspace = mono_metadata_string_heap (m, cols [MONO_EXP_TYPE_NAMESPACE]);
impl = get_manifest_implementation (m, cols [MONO_EXP_TYPE_IMPLEMENTATION]);
- fprintf (output, "%d: %s.%s is in %s\n", i, nspace, name, impl);
+ index = cols [MONO_EXP_TYPE_TYPEDEF];
+ fprintf (output, "%d: %s-%s%s is in %s, token %x\n", i, nspace, *nspace ? "." : "", name, impl, index);
g_free (impl);
}
diff --git a/mono/dis/dump.h b/mono/dis/dump.h
index c7cdf4c583e..90b04e860ca 100644
--- a/mono/dis/dump.h
+++ b/mono/dis/dump.h
@@ -28,3 +28,4 @@ void dump_table_field_marshal (MonoImage *m);
void dump_table_genericpar (MonoImage *m);
void dump_table_methodspec (MonoImage *m);
void dump_table_parconstraint(MonoImage *m);
+void dump_table_implmap (MonoImage *m);
diff --git a/mono/dis/get.c b/mono/dis/get.c
index a20c039b287..d2a20d3ca9f 100644
--- a/mono/dis/get.c
+++ b/mono/dis/get.c
@@ -308,7 +308,7 @@ get_typeref (MonoImage *m, int idx)
char *
get_typedef_or_ref (MonoImage *m, guint32 dor_token)
{
- char *temp = NULL, *s;
+ char *temp = NULL, *s = NULL;
int table, idx;
/*
@@ -498,7 +498,7 @@ dis_stringify_modifiers (MonoImage *m, int n, MonoCustomMod *mod)
char *tok = dis_stringify_token (m, mod[i].token);
if (i > 0)
g_string_sprintfa (s, " ");
- g_string_sprintfa (s, "%s (%s)", mod[i].required ? "modopt": "modreq", tok);
+ g_string_sprintfa (s, "%s (%s)", mod[i].required ? "modreq": "modopt", tok);
g_free (tok);
}
g_string_append_c (s, ' ');
@@ -1587,7 +1587,7 @@ get_token (MonoImage *m, guint32 token)
char *
get_token_type (MonoImage *m, guint32 token)
{
- char *temp = NULL, *s;
+ char *temp = NULL, *s = NULL;
int idx;
idx = mono_metadata_token_index (token);
diff --git a/mono/dis/main.c b/mono/dis/main.c
index 2458fea3fb6..03e51619776 100644
--- a/mono/dis/main.c
+++ b/mono/dis/main.c
@@ -593,7 +593,7 @@ dis_method_list (const char *klass_name, MonoImage *m, guint32 start, guint32 en
fprintf (output, " // method line %d\n", i + 1);
fprintf (output, " .method %s", flags);
- if (cols [MONO_METHOD_FLAGS] & METHOD_ATTRIBUTE_PINVOKE_IMPL)
+ if ((cols [MONO_METHOD_FLAGS] & METHOD_ATTRIBUTE_PINVOKE_IMPL) && (cols [MONO_METHOD_RVA] == 0))
fprintf (output, "%s", pinvoke_info (m, i));
fprintf (output, "\n %s", sig_str);
@@ -606,7 +606,10 @@ dis_method_list (const char *klass_name, MonoImage *m, guint32 start, guint32 en
cattrs_for_method (m, i, ms);
/* FIXME: need to sump also param custom attributes */
fprintf (output, " // Method begins at RVA 0x%x\n", cols [MONO_METHOD_RVA]);
- dis_code (m, cols [MONO_METHOD_RVA]);
+ if (cols [MONO_METHOD_IMPLFLAGS] & METHOD_IMPL_ATTRIBUTE_NATIVE)
+ fprintf (output, " // Disassembly of native methods is not supported\n");
+ else
+ dis_code (m, cols [MONO_METHOD_RVA]);
fprintf (output, " } // end of method %s::%s\n\n", klass_name, sig_str);
mono_metadata_free_method_signature (ms);
g_free (sig_str);
@@ -748,7 +751,7 @@ dis_event_methods (MonoImage *m, guint32 event)
MonoTableInfo *msemt = &m->tables [MONO_TABLE_METHODSEMANTICS];
guint32 cols [MONO_METHOD_SEMA_SIZE];
char *sig;
- const char *type;
+ const char *type = "";
start = mono_metadata_methods_from_event (m, event, &end);
while (start < end) {
@@ -1134,6 +1137,7 @@ struct {
{ "--propertymap", MONO_TABLE_PROPERTYMAP, dump_table_property_map },
{ "--typedef", MONO_TABLE_TYPEDEF, dump_table_typedef },
{ "--typeref", MONO_TABLE_TYPEREF, dump_table_typeref },
+ { "--implmap", MONO_TABLE_IMPLMAP, dump_table_implmap },
{ NULL, -1 }
};
diff --git a/mono/dis/util.h b/mono/dis/util.h
index 108c8eacb79..4fda209b27d 100644
--- a/mono/dis/util.h
+++ b/mono/dis/util.h
@@ -9,4 +9,3 @@ const char *flags (guint32 code, map_t *table);
void hex_dump (const char *buffer, int base, int count);
char* data_dump (const char *data, int len, const char* prefix);
-#define CSIZE(x) (sizeof (x) / 4)
diff --git a/mono/interpreter/ChangeLog b/mono/interpreter/ChangeLog
index 453ef412323..f71bc794f95 100644
--- a/mono/interpreter/ChangeLog
+++ b/mono/interpreter/ChangeLog
@@ -1,3 +1,7 @@
+2003-11-21 Lluis Sanchez Gual <lluis@ximian.com>
+
+ * interp.c: Added support for context static fields.
+
2003-10-31 Zoltan Varga <vargaz@freemail.hu>
* interp.c (mono_create_method_pointer): New function which contains
diff --git a/mono/interpreter/interp.c b/mono/interpreter/interp.c
index 4adc01a3ec9..fcb75865f34 100644
--- a/mono/interpreter/interp.c
+++ b/mono/interpreter/interp.c
@@ -3340,10 +3340,11 @@ array_constructed:
vt = mono_class_vtable (domain, field->parent);
if (!vt->initialized)
mono_runtime_class_init (vt);
- if (!domain->thread_static_fields || !(addr = g_hash_table_lookup (domain->thread_static_fields, field)))
- addr = (char*)(vt->data) + field->offset;
+
+ if (domain->special_static_fields && (addr = g_hash_table_lookup (domain->special_static_fields, field)))
+ addr = mono_get_special_static_data (GPOINTER_TO_UINT (addr));
else
- addr = mono_threads_get_static_data (GPOINTER_TO_UINT (addr));
+ addr = (char*)(vt->data) + field->offset;
if (load_addr) {
sp->type = VAL_MP;
@@ -3370,10 +3371,11 @@ array_constructed:
vt = mono_class_vtable (domain, field->parent);
if (!vt->initialized)
mono_runtime_class_init (vt);
- if (!domain->thread_static_fields || !(addr = g_hash_table_lookup (domain->thread_static_fields, field)))
- addr = (char*)(vt->data) + field->offset;
+
+ if (domain->special_static_fields && (addr = g_hash_table_lookup (domain->special_static_fields, field)))
+ addr = mono_get_special_static_data (GPOINTER_TO_UINT (addr));
else
- addr = mono_threads_get_static_data (GPOINTER_TO_UINT (addr));
+ addr = (char*)(vt->data) + field->offset;
stackval_to_data (field->type, sp, addr, FALSE);
vt_free (sp);
diff --git a/mono/io-layer/ChangeLog b/mono/io-layer/ChangeLog
index 2ba531575a7..921a5ab9d32 100644
--- a/mono/io-layer/ChangeLog
+++ b/mono/io-layer/ChangeLog
@@ -1,3 +1,14 @@
+2003-11-24 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * io.c: don't call g_free before testing errno as it may modify it.
+ If the path exists, return an error if it's not a directory. Fixes
+ bug #50753.
+
+2003-11-20 Dick Porter <dick@ximian.com>
+
+ * io.c: Missed a little-endian UTF16 conversion. Patch from
+ Jeroen Zwartepoorte (Jeroen@xs4all.nl), fixes bug 51065.
+
2003-10-29 Dick Porter <dick@ximian.com>
* io.c (MoveFile): If the move crosses filesystems, try and fall
diff --git a/mono/io-layer/io.c b/mono/io-layer/io.c
index 551b7fb36cb..8ef29e07f5f 100644
--- a/mono/io-layer/io.c
+++ b/mono/io-layer/io.c
@@ -2367,9 +2367,10 @@ gboolean FindNextFile (gpointer handle, WapiFindData *find_data)
gboolean ok;
struct stat buf;
const gchar *filename;
- gchar *utf8_filename, *utf8_basename, *utf16_basename;
+ gchar *utf8_filename, *utf8_basename;
+ gunichar2 *utf16_basename;
time_t create_time;
- gsize bytes;
+ glong bytes;
ok=_wapi_lookup_handle (handle, WAPI_HANDLE_FIND,
(gpointer *)&find_handle, NULL);
@@ -2444,12 +2445,15 @@ retry:
find_data->dwReserved1 = 0;
utf8_basename = g_path_get_basename (utf8_filename);
- utf16_basename = g_convert (utf8_basename, -1, "UTF16LE", "UTF8",
- NULL, &bytes, NULL);
+ utf16_basename = g_utf8_to_utf16 (utf8_basename, -1, NULL, &bytes,
+ NULL);
if(utf16_basename==NULL) {
goto retry;
}
+ /* utf16 is 2 * utf8 */
+ bytes *= 2;
+
memset (find_data->cFileName, '\0', (MAX_PATH*2));
/* Truncating a utf16 string like this might leave the last
@@ -2508,6 +2512,8 @@ gboolean CreateDirectory (const gunichar2 *name, WapiSecurityAttributes *securit
{
gchar *utf8_name;
int result;
+ struct stat buf;
+ guint32 attrs;
utf8_name = mono_unicode_to_external (name);
if (utf8_name == NULL) {
@@ -2519,19 +2525,32 @@ gboolean CreateDirectory (const gunichar2 *name, WapiSecurityAttributes *securit
}
result = mkdir (utf8_name, 0777);
- g_free (utf8_name);
- if (result == 0)
+ if (result == 0) {
+ g_free (utf8_name);
return TRUE;
+ }
- switch (errno) {
- case EEXIST:
- return TRUE;
- default:
+ if (errno == EEXIST) {
+ result = stat (utf8_name, &buf);
+ if (result == -1) {
+ _wapi_set_last_error_from_errno ();
+ g_free (utf8_name);
+ return FALSE;
+ }
+
+ g_free (utf8_name);
+ attrs = _wapi_stat_to_file_attributes (&buf);
+ if ((attrs & FILE_ATTRIBUTE_DIRECTORY) == FILE_ATTRIBUTE_DIRECTORY)
+ return TRUE;
+
+ errno = EEXIST;
_wapi_set_last_error_from_errno ();
- break;
+ return FALSE;
}
-
+
+ _wapi_set_last_error_from_errno ();
+ g_free (utf8_name);
return FALSE;
}
diff --git a/mono/metadata/ChangeLog b/mono/metadata/ChangeLog
index 8a55e33be7c..05192716e37 100644
--- a/mono/metadata/ChangeLog
+++ b/mono/metadata/ChangeLog
@@ -1,5 +1,300 @@
+2003-11-30 Zoltan Varga <vargaz@freemail.hu>
+
+ * reflection.c (fixup_method): Add support for MonoCMethod.
+
+2003-11-28 Zoltan Varga <vargaz@freemail.hu>
+
+ * gc.c: Fix hangs and error messages when GC_DONT_GC is set.
+
+ * reflection.c (assembly_name_to_aname): Allow extra characters in
+ assembly names. Fixes #51468.
+
+2003-11-26 Zoltan Varga <vargaz@freemail.hu>
+
+ * exception.c (mono_exception_from_name_domain): New helper function.
+
+ * appdomain.c (ves_icall_System_AppDomain_createDomain): Create the
+ exception object in the correct domain.
+
+ * appdomain.c (ves_icall_System_AppDomain_LoadAssemblyRaw): Fix
+ formatting + make a copy a the input data.
+
+ * loader.c (mono_get_method_from_token): Methods which contain
+ native code do not have entries in the ImplMap.
+
+ (ves_icall_System_AppDomain_LoadAssemblyRaw): Fix exception throw.
+ Thanks to Gonzalo for spotting this.
+
+ * appdomain.c (ves_icall_System_AppDomain_LoadAssemblyRaw): Applied
+ patch from ztashev@openlinksw.co.uk (Zdravko Tashev). New icall.
+
+ * assembly.h (mono_assembly_load_from): Split the second part of
+ assembly loading into a new public function.
+
+ * exception.h (mono_get_exception_bad_image_format): New function.
+
+2003-11-24 Zoltan Varga <vargaz@freemail.hu>
+
+ icall.c (ves_icall_System_Reflection_Assembly_InternalGetType):
+ Enumerate all modules inside a dynamic assembly. Fixes #51293.
+
+ * icall.c: Add new icall for creating dynamic methods.
+
+ * loader.h debug-helpers.c: Add new wrapper type for dynamic methods.
+
+ * reflection.h (MonoReflectionDynamicMethod): Fix type of bool fields.
+
+ * reflection.c (mono_reflection_create_dynamic_method): New icall to
+ create a dynamic method.
+
+ * reflection.c (resolve_object): New helper function.
+
+ * reflection.c: Generalize ReflectionMethodBuilder and the functions
+ which manipulate it so they can also work on dynamic methods.
+
+ * reflection.c (reflection_method_builder_to_mono_method): Avoid
+ creating the MonoReflectionMethodAux structure if it is not needed.
+
+ * reflection.h verify.c: Update after changes to object layout.
+
+ * reflection.c (method_builder_encode_signature): Fix compilation on
+ gcc 2.95.x.
+
+2003-11-21 Lluis Sanchez Gual <lluis@ximian.com>
+
+ * appdomain.h: Added support for context static fields. Added static_data
+ field to MonoAppContext and renamed thread_static_fields to a more
+ generic special_static_fields in MonoAppDomain, since it can now contain
+ context static fields.
+ * domain.c: Updated hashtable name.
+ * object.c: Replaced field_is_thread_static() for a more generic
+ field_is_special_static() which also checks for context static attribute.
+ In mono_class_vtable(), added support for static context fields.
+ * threads.c: Changed methods that manage thread static fields to more
+ generic methods so they can be reused both for thread and context static
+ data.
+ * threads.h: Declared some new methods.
+
+2003-11-21 Zoltan Varga <vargaz@freemail.hu>
+
+ * reflection.h: Update after changes to the managed types.
+
+ * reflection.c (encode_custom_modifiers): New helper function.
+
+ * reflection.c (method_encode_signature): Emit custom modifiers.
+
+ * reflection.c (field_encode_signature): Emit custom modifiers.
+
+2003-11-18 Zoltan Varga <vargaz@freemail.hu>
+
+ * reflection.h (MonoReflectionAssemblyName): Applied patch from Laurent Morichetti (l_m@pacbell.net). Fix type of 'flags' field.
+
+ * icall.c (ves_icall_System_ValueType_Equals): New optimized
+ implementation.
+
+ * icall.c (ves_icall_System_ValueType_InternalGetHashCode): New
+ icall.
+
+ * object.c (mono_field_get_value_object): New function.
+
+ * object.c appdomain.h appdomain.c: Make out_of_memory_ex domain
+ specific.
+
+2003-11-17 Zoltan Varga <vargaz@freemail.hu>
+
+ * appdomain.c (mono_runtime_get_out_of_memory_ex): New function to
+ return a preallocated out-of-memory exception instance.
+
+ * object.c (out_of_memory): Use the new function.
+
+ * metadata.c (mono_metadata_parse_type): Handle the case when the byref
+ flag is before the custom modifiers. Fixes #49802.
+
+2003-11-16 Martin Baulig <martin@ximian.com>
+
+ * class.c (mono_class_is_open_constructed_type): Implemented the
+ MONO_TYPE_GENERICINST case.
+
+2003-11-16 Zoltan Varga <vargaz@freemail.hu>
+
+ * assembly.c (mono_assembly_fill_assembly_name): New function to
+ fill out the MonoAssemblyName structure.
+ (mono_assembly_open): Use the new function.
+
+ * icall.c (fill_reflection_assembly_name): New helper function.
+
+ * icall.c (ves_icall_System_Reflection_Assembly_FillName): Use the
+ new function.
+
+ * icall.c (ves_icall_System_Reflection_Assembly_InternalGetAssemblyName): New icall.
+
+2003-11-15 Martin Baulig <martin@ximian.com>
+
+ * class.c (mono_class_is_open_constructed_type): New public
+ function; checks whether a type is an open constructed type,
+ ie. whether it still contains type parameters.
+ (mono_class_inflate_generic_type): If we're a type parameter and
+ the inflated type is also a MONO_TYPE_(M)VAR, return the original
+ type.
+
+ * class.h (MonoGenericInst): Added `guint32 is_open'.
+
+ * loader.c (method_from_methodspec): Check whether we're an open
+ or closed constructed type and set `ginst->is_open'.
+
+ * reflection.c (mono_reflection_bind_generic_parameters): Check
+ whether we're an open or closed constructed type and set
+ `ginst->is_open'.
+ (mono_reflection_inflate_method_or_ctor): Don't inflate methods
+ from open constructed types.
+
+2003-11-15 Martin Baulig <martin@ximian.com>
+
+ * reflection.c (mono_reflection_bind_generic_parameters): If we're
+ a generic instance (instead of a generic type declaration) with
+ unbound generic parameters, bind them to our actual types.
+
+2003-11-14 Martin Baulig <martin@ximian.com>
+
+ * reflection.h (MonoReflectionGenericInst): Added `MonoArray *interfaces'.
+
+ * reflection.c (mono_reflection_bind_generic_parameters): If we're
+ an interface type, populate `res->interfaces' with instantiated
+ versions of all the interfaces we inherit.
+
+2003-11-13 Aleksey Demakov <avd@openlinksw.com>
+
+ * assembly.c (mono_assembly_load): Fixed problem finding mscorlib.dll
+ when MONO_PATH is set but doesn't contain the install dir.
+
+2003-11-13 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * icall.c:
+ (ves_icall_Type_GetInterfaces): don't return an interface twice when
+ it's also implemented in base classes. Fixes bug #50927.
+
+2003-11-13 Zoltan Varga <vargaz@freemail.hu>
+
+ * gc.c (ves_icall_System_GC_WaitForPendingFinalizers): Avoid deadlocks
+ if this method is called from a finalizer. Fixes #50913.
+
+2003-11-12 Miguel de Icaza <miguel@ximian.com>
+
+ * threads.c: Implement VolatileRead/VolatileWrite
+
+ * icall.c: Add new icalls for VolatileRead/VolatileWrite
+
+2003-11-12 Zoltan Varga <vargaz@freemail.hu>
+
+ * icall.c (ves_icall_System_Reflection_Assembly_GetTypes): Applied
+ patch from Danilo Sagan (dsegan@gmx.net). Fix compilation under gcc
+ 2.95.3.
+
+ * assembly.c (mono_assembly_open): Fix windows build. Applied patch
+ from Peter Ross (pro@missioncriticalit.com).
+
+2003-11-12 Lluis Sanchez Gual <lluis@ximian.com>
+
+ * icall.c: Added internal call for System.Environment::GetMachineConfigPath
+
+2003-11-12 Zoltan Varga <vargaz@freemail.hu>
+
+ * assembly.c (mono_assembly_load_references): Disable check because it
+ triggers on older corlibs which lots of people have.
+
+2003-11-12 Jackson Harper <jackson@ximian.com>
+
+ * assembly.c: Change corlib name to mscorlib. Add a temp. hack to
+ load corlib.dll if mscorlib.dll is not found.
+ * assembly.h: Remove corlib name define.
+ * class.c:
+ * domain.c:
+ * image.c: Change corlib name to mscorlib.
+
+2003-11-12 Zoltan Varga <vargaz@freemail.hu>
+
+ * debug-mono-symfile.c: Add patch from FreeBSD ports tree.
+
+2003-11-11 Miguel de Icaza <miguel@ximian.com>
+
+ * appdomain.h: Added loader_optimization here to sync with the C#
+ code, and add disallow_binding_redirects field.
+
+2003-11-11 Zoltan Varga <vargaz@freemail.hu>
+
+ * mono-debug.c (mono_debug_add_method): Ignore unknown modules.
+
+ * reflection.c (mono_image_build_metadata): Fix crash on modules
+ with no types.
+
+ * reflection.h (MonoMethodInfo): Track changes to the managed structure.
+
+ * icall.c (ves_icall_get_method_info): Return callingConvention as
+ well.
+
+ * icall.c (ves_icall_System_Reflection_Assembly_GetNamespaces): Add
+ namespaces from the EXPORTEDTYPE table as well.
+
+ * icall.c (ves_icall_System_Reflection_Assembly_GetTypes): Merge types
+ from all modules inside the assembly.
+
+2003-11-11 Martin Baulig <martin@ximian.com>
+
+ * reflection.c (mono_reflection_bind_generic_parameters): Make
+ this work for interfaces.
+
+2003-11-11 Martin Baulig <martin@ximian.com>
+
+ * mono-debug.c (mono_debug_add_type): Ignore unknown modules.
+
+2003-11-11 Martin Baulig <martin@ximian.com>
+
+ * reflection.c (mono_reflection_inflate_method_or_ctor): Allow
+ "MonoInflatedMethod" and "MonoInflatedCtor".
+
+2003-11-11 Zoltan Varga <vargaz@freemail.hu>
+
+ * reflection.c (resolution_scope_from_image): Use the assembly table
+ from the manifest module, since other modules don't have it.
+
+ * debug-helpers.c (mono_type_full_name): New helper function.
+
+ * image.h (MonoAssembly): Change 'dynamic' to a boolean.
+
+ * image.c (mono_image_load_file_for_image): New public function which
+ is a replacement for the load_file_for_image in class.c.
+
+ * assembly.c (mono_assembly_load_module): A wrapper for the function
+ above which does assembly association and reference loading too.
+
+ * class.c (mono_class_from_name): Call mono_assembly_load_module.
+
+2003-11-11 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * appdomain.c: not all of the attributes for the full assembly name
+ are required and the order doesn't matter. Fixes bug #50787.
+
+2003-11-10 Dick Porter <dick@ximian.com>
+
+ * locales.c: Use platform-endian UTF16
+
2003-11-10 Zoltan Varga <vargaz@freemail.hu>
+ * reflection.c: Emit FILE and EXPORTEDTYPE tables.
+
+2003-11-10 Martin Baulig <martin@ximian.com>
+
+ * metadata.c
+ (mono_metadata_load_generic_params): Make this actually work.
+
+ * reflection.c (mono_reflection_bind_generic_parameters): If our
+ parent is a generic instance, pass all the `types' to it, no
+ matter whether it has the same number of type parameters or not.
+
+2003-11-10 Zoltan Varga <vargaz@freemail.hu>
+
+ * reflection.c: Emit FILE and EXPORTEDTYPE tables.
+
* assembly.c (mono_assembly_load_references): Move the image<->assembly
assignment code to this function so it gets called recursively for all
modules.
diff --git a/mono/metadata/appdomain.c b/mono/metadata/appdomain.c
index 2fedba28a03..7bfaabf434c 100644
--- a/mono/metadata/appdomain.c
+++ b/mono/metadata/appdomain.c
@@ -85,6 +85,11 @@ mono_runtime_init (MonoDomain *domain, MonoThreadStartCB start_cb,
mono_context_set (domain->default_context);
mono_thread_init (start_cb, attach_cb);
+
+ /*
+ * Create an instance early since we can't do it when there is no memory.
+ */
+ domain->out_of_memory_ex = mono_exception_from_name (mono_defaults.corlib, "System", "OutOfMemoryException");
/* GC init has to happen after thread init */
mono_gc_init ();
@@ -342,6 +347,7 @@ ves_icall_System_AppDomain_createDomain (MonoString *friendly_name, MonoAppDomai
data->domain = ad;
data->setup = setup;
data->friendly_name = mono_string_to_utf8 (friendly_name);
+ data->out_of_memory_ex = mono_exception_from_name_domain (data, mono_defaults.corlib, "System", "OutOfMemoryException");
mono_context_init (data);
@@ -713,95 +719,79 @@ get_info_from_assembly_name (MonoReflectionAssemblyName *assRef, MonoAssemblyNam
return TRUE;
}
- value = g_strstrip (*tmp);
- if (strncmp (value, "Version=", 8)) {
- g_strfreev (parts);
- return FALSE;
- }
-
- if (sscanf (value + 8, "%u.%u.%u.%u", &major, &minor, &build, &revision) != 4) {
- g_strfreev (parts);
- return FALSE;
- }
-
- /* g_print ("Version: %u.%u.%u.%u\n", major, minor, build, revision); */
- aname->major = major;
- aname->minor = minor;
- aname->build = build;
- aname->revision = revision;
- tmp++;
-
- if (!*tmp) {
- g_strfreev (parts);
- return FALSE;
- }
-
- value = g_strstrip (*tmp);
- if (strncmp (value, "Culture=", 8)) {
- g_strfreev (parts);
- return FALSE;
- }
-
- /* g_print ("Culture: %s\n", aname->culture); */
- aname->culture = g_strstrip (g_strdup (value + 8));
- tmp++;
-
- if (!*tmp) {
- g_strfreev (parts);
- return FALSE;
- }
-
- value = g_strstrip (*tmp);
- if (strncmp (value, "PublicKeyToken=", 15)) {
- g_strfreev (parts);
- return FALSE;
- }
+ while (*tmp) {
+ value = g_strstrip (*tmp);
+ if (!strncmp (value, "Version=", 8)) {
+ if (sscanf (value + 8, "%u.%u.%u.%u",
+ &major, &minor, &build, &revision) != 4) {
+ g_strfreev (parts);
+ return FALSE;
+ }
+ /* g_print ("Version: %u.%u.%u.%u\n", major, minor, build, revision); */
+ aname->major = major;
+ aname->minor = minor;
+ aname->build = build;
+ aname->revision = revision;
+ tmp++;
+ continue;
+ }
- value += 15;
- if (*value && strcmp (value, "null")) {
- gint i, len;
- gchar h, l;
- gchar *result;
-
- value = g_strstrip (g_strdup (value));
- len = strlen (value);
- if (len % 2) {
- g_free (value);
- g_strfreev (parts);
- return FALSE;
+ if (!strncmp (value, "Culture=", 8)) {
+ /* g_print ("Culture: %s\n", aname->culture); */
+ aname->culture = g_strstrip (g_strdup (value + 8));
+ tmp++;
+ continue;
}
-
- aname->hash_len = len / 2;
- aname->hash_value = g_malloc0 (aname->hash_len);
- result = (gchar *) aname->hash_value;
-
- for (i = 0; i < len; i++) {
- if (i % 2) {
- l = g_ascii_xdigit_value (value [i]);
- if (l == -1) {
+
+ if (!strncmp (value, "PublicKeyToken=", 15)) {
+ tmp++;
+ value += 15;
+ if (*value && strcmp (value, "null")) {
+ gint i, len;
+ gchar h, l;
+ gchar *result;
+
+ value = g_strstrip (g_strdup (value));
+ len = strlen (value);
+ if (len % 2) {
g_free (value);
g_strfreev (parts);
return FALSE;
}
- result [i / 2] = (h * 16) + l;
- } else {
- h = g_ascii_xdigit_value (value [i]);
- if (h == -1) {
- g_free (value);
- g_strfreev (parts);
- return FALSE;
+
+ aname->hash_len = len / 2;
+ aname->hash_value = g_malloc0 (aname->hash_len);
+ result = (gchar *) aname->hash_value;
+
+ for (i = 0; i < len; i++) {
+ if (i % 2) {
+ l = g_ascii_xdigit_value (value [i]);
+ if (l == -1) {
+ g_free (value);
+ g_strfreev (parts);
+ return FALSE;
+ }
+ result [i / 2] = (h * 16) + l;
+ } else {
+ h = g_ascii_xdigit_value (value [i]);
+ if (h == -1) {
+ g_free (value);
+ g_strfreev (parts);
+ return FALSE;
+ }
+ }
}
- }
- }
- g_free (value);
+ g_free (value);
- /*
- g_print ("PublicKeyToken: ");
- for (i = 0; i < aname->hash_len; i++) {
- g_print ("%x", 0x00FF & aname->hash_value [i]);
+ /*
+ g_print ("PublicKeyToken: ");
+ for (i = 0; i < aname->hash_len; i++) {
+ g_print ("%x", 0x00FF & aname->hash_value [i]);
+ }
+ g_print ("\n");
+ */
+ }
}
- g_print ("\n");
- */
}
g_strfreev (parts);
@@ -809,6 +799,36 @@ get_info_from_assembly_name (MonoReflectionAssemblyName *assRef, MonoAssemblyNam
}
MonoReflectionAssembly *
+ves_icall_System_AppDomain_LoadAssemblyRaw (MonoAppDomain *ad,
+ MonoArray *raw_assembly,
+ MonoArray *raw_symbol_store, MonoObject *evidence)
+{
+ MonoAssembly *ass;
+ MonoDomain *domain = ad->data;
+ MonoImageOpenStatus status;
+ guint32 raw_assembly_len = mono_array_length (raw_assembly);
+ MonoImage *image = mono_image_open_from_data (mono_array_addr (raw_assembly, gchar, 0), raw_assembly_len, TRUE, NULL);
+
+ if (raw_symbol_store)
+ mono_raise_exception (mono_get_exception_not_implemented ());
+
+ if (!image) {
+ mono_raise_exception (mono_get_exception_bad_image_format (""));
+ return NULL;
+ }
+
+ ass = mono_assembly_load_from (image, "", &status);
+
+ if (!ass) {
+ mono_image_close (image);
+ mono_raise_exception (mono_get_exception_bad_image_format (""));
+ return NULL;
+ }
+
+ return mono_assembly_get_object (domain, ass);
+}
+
+MonoReflectionAssembly *
ves_icall_System_AppDomain_LoadAssembly (MonoAppDomain *ad, MonoReflectionAssemblyName *assRef, MonoObject *evidence)
{
MonoDomain *domain = ad->data;
diff --git a/mono/metadata/appdomain.h b/mono/metadata/appdomain.h
index efdec8296c4..e6dc1097bfa 100644
--- a/mono/metadata/appdomain.h
+++ b/mono/metadata/appdomain.h
@@ -37,6 +37,9 @@ typedef struct {
MonoString *shadow_copy_files;
MonoBoolean publisher_policy;
MonoBoolean path_changed;
+ int loader_optimization;
+ MonoBoolean disallow_binding_redirects;
+ MonoBoolean disallow_code_downloads;
} MonoAppDomainSetup;
typedef GArray MonoJitInfoTable;
@@ -68,6 +71,7 @@ typedef struct {
MonoObject obj;
gint32 domain_id;
gint32 context_id;
+ gpointer *static_data;
} MonoAppContext;
typedef enum {
@@ -106,7 +110,9 @@ struct _MonoDomain {
MonoMethod *create_proxy_for_type_method;
MonoMethod *private_invoke_method;
MonoAppContext *default_context;
- GHashTable *thread_static_fields;
+ MonoException *out_of_memory_ex;
+ /* Used to store offsets of thread and context static fields */
+ GHashTable *special_static_fields;
GHashTable *jump_target_hash;
MonoGHashTable *class_init_trampoline_hash;
/*
@@ -204,6 +210,12 @@ MonoObject *
ves_icall_System_AppDomain_GetData (MonoAppDomain *ad,
MonoString *name);
+MonoReflectionAssembly *
+ves_icall_System_AppDomain_LoadAssemblyRaw (MonoAppDomain *ad,
+ MonoArray *raw_assembly,
+ MonoArray *raw_symbol_store,
+ MonoObject *evidence);
+
void
ves_icall_System_AppDomain_SetData (MonoAppDomain *ad,
MonoString *name,
diff --git a/mono/metadata/assembly.c b/mono/metadata/assembly.c
index 912e2a68c1d..7982ff79451 100644
--- a/mono/metadata/assembly.c
+++ b/mono/metadata/assembly.c
@@ -168,6 +168,35 @@ mono_assemblies_init (void)
assemblies_loading = g_hash_table_new (NULL, NULL);
}
+gboolean
+mono_assembly_fill_assembly_name (MonoImage *image, MonoAssemblyName *aname)
+{
+ MonoTableInfo *t = &image->tables [MONO_TABLE_ASSEMBLY];
+ guint32 cols [MONO_ASSEMBLY_SIZE];
+
+ if (!t->rows)
+ return FALSE;
+
+ mono_metadata_decode_row (t, 0, cols, MONO_ASSEMBLY_SIZE);
+
+ aname->hash_len = 0;
+ aname->hash_value = NULL;
+ aname->name = mono_metadata_string_heap (image, cols [MONO_ASSEMBLY_NAME]);
+ aname->culture = mono_metadata_string_heap (image, cols [MONO_ASSEMBLY_CULTURE]);
+ aname->flags = cols [MONO_ASSEMBLY_FLAGS];
+ aname->major = cols [MONO_ASSEMBLY_MAJOR_VERSION];
+ aname->minor = cols [MONO_ASSEMBLY_MINOR_VERSION];
+ aname->build = cols [MONO_ASSEMBLY_BUILD_NUMBER];
+ aname->revision = cols [MONO_ASSEMBLY_REV_NUMBER];
+ aname->hash_alg = cols [MONO_ASSEMBLY_HASH_ALG];
+ if (cols [MONO_ASSEMBLY_PUBLIC_KEY])
+ aname->public_key = mono_metadata_blob_heap (image, cols [MONO_ASSEMBLY_PUBLIC_KEY]);
+ else
+ aname->public_key = 0;
+
+ return TRUE;
+}
+
static void
mono_assembly_load_references (MonoImage *image, MonoImageOpenStatus *status)
{
@@ -215,8 +244,14 @@ mono_assembly_load_references (MonoImage *image, MonoImageOpenStatus *status)
return;
}
+ /*
+ * This check is disabled since lots of people seem to have an older
+ * corlib which triggers this.
+ */
+ /*
if (image->references [i]->image == image)
g_error ("Error: Assembly %s references itself", image->name);
+ */
}
image->references [i] = NULL;
@@ -417,14 +452,10 @@ do_mono_assembly_open (const char *filename, MonoImageOpenStatus *status)
MonoAssembly *
mono_assembly_open (const char *filename, MonoImageOpenStatus *status)
{
- MonoAssembly *ass, *ass2;
MonoImage *image;
- MonoTableInfo *t;
- guint32 cols [MONO_ASSEMBLY_SIZE];
- char *base_dir;
+ MonoAssembly *ass;
MonoImageOpenStatus def_status;
gchar *fname;
- GList *loading;
g_return_val_if_fail (filename != NULL, NULL);
@@ -465,9 +496,26 @@ mono_assembly_open (const char *filename, MonoImageOpenStatus *status)
return NULL;
}
+ ass = mono_assembly_load_from (image, fname, status);
+
+ g_free (fname);
+
+ return ass;
+}
+
+MonoAssembly *
+mono_assembly_load_from (MonoImage *image, const char*fname,
+ MonoImageOpenStatus *status)
+{
+ MonoAssembly *ass, *ass2;
+ char *base_dir;
+ GList *loading;
+
#if defined (PLATFORM_WIN32)
{
gchar *tmp_fn;
+ int i;
+
tmp_fn = g_strdup (fname);
for (i = strlen (tmp_fn) - 1; i >= 0; i--) {
if (tmp_fn [i] == '/')
@@ -488,26 +536,7 @@ mono_assembly_open (const char *filename, MonoImageOpenStatus *status)
ass->basedir = base_dir;
ass->image = image;
-
- g_free (fname);
-
- t = &image->tables [MONO_TABLE_ASSEMBLY];
- if (t->rows) {
- mono_metadata_decode_row (t, 0, cols, MONO_ASSEMBLY_SIZE);
-
- ass->aname.hash_len = 0;
- ass->aname.hash_value = NULL;
- ass->aname.name = mono_metadata_string_heap (image, cols [MONO_ASSEMBLY_NAME]);
- ass->aname.culture = mono_metadata_string_heap (image, cols [MONO_ASSEMBLY_CULTURE]);
- ass->aname.flags = cols [MONO_ASSEMBLY_FLAGS];
- ass->aname.major = cols [MONO_ASSEMBLY_MAJOR_VERSION];
- ass->aname.minor = cols [MONO_ASSEMBLY_MINOR_VERSION];
- ass->aname.build = cols [MONO_ASSEMBLY_BUILD_NUMBER];
- ass->aname.revision = cols [MONO_ASSEMBLY_REV_NUMBER];
- ass->aname.hash_alg = cols [MONO_ASSEMBLY_HASH_ALG];
- if (cols [MONO_ASSEMBLY_PUBLIC_KEY])
- ass->aname.public_key = mono_metadata_blob_heap (image, cols [MONO_ASSEMBLY_PUBLIC_KEY]);
- }
+ mono_assembly_fill_assembly_name (image, &ass->aname);
/*
* Atomically search the loaded list and add ourselves to it if necessary.
@@ -588,11 +617,16 @@ mono_assembly_load (MonoAssemblyName *aname, const char *basedir, MonoImageOpenS
}
/* g_print ("corlib load\n"); */
if (assemblies_path) {
- corlib = load_in_path (CORLIB_NAME, (const char**)assemblies_path, status);
+ corlib = load_in_path ("mscorlib.dll", (const char**)assemblies_path, status);
+ if (corlib)
+ return corlib;
+ corlib = load_in_path ("corlib.dll", (const char**)assemblies_path, status);
if (corlib)
return corlib;
}
- corlib = load_in_path (CORLIB_NAME, default_path, status);
+ corlib = load_in_path ("mscorlib.dll", default_path, status);
+ if (!corlib)
+ corlib = load_in_path ("corlib.dll", default_path, status);
return corlib;
}
result = search_loaded (aname);
@@ -652,6 +686,19 @@ mono_assembly_close (MonoAssembly *assembly)
g_free (assembly);
}
+MonoImage*
+mono_assembly_load_module (MonoAssembly *assembly, guint32 idx)
+{
+ MonoImageOpenStatus status;
+ MonoImage *module;
+
+ module = mono_image_load_file_for_image (assembly->image, idx);
+ if (module)
+ mono_assembly_load_references (module, &status);
+
+ return module;
+}
+
void
mono_assembly_foreach (GFunc func, gpointer user_data)
{
diff --git a/mono/metadata/assembly.h b/mono/metadata/assembly.h
index 6d744ac4123..79e9e872298 100644
--- a/mono/metadata/assembly.h
+++ b/mono/metadata/assembly.h
@@ -5,19 +5,21 @@
#include <mono/metadata/image.h>
-#define CORLIB_NAME "corlib.dll"
-
void mono_assemblies_init (void);
MonoAssembly *mono_assembly_open (const char *filename,
MonoImageOpenStatus *status);
MonoAssembly* mono_assembly_load (MonoAssemblyName *aname,
const char *basedir,
MonoImageOpenStatus *status);
+MonoAssembly* mono_assembly_load_from (MonoImage *image, const char *fname,
+ MonoImageOpenStatus *status);
+MonoImage* mono_assembly_load_module (MonoAssembly *assembly, guint32 idx);
void mono_assembly_close (MonoAssembly *assembly);
void mono_assembly_setrootdir (const char *root_dir);
void mono_assembly_foreach (GFunc func, gpointer user_data);
void mono_assembly_set_main (MonoAssembly *assembly);
MonoAssembly *mono_assembly_get_main (void);
+gboolean mono_assembly_fill_assembly_name (MonoImage *image, MonoAssemblyName *aname);
/* Installs a function which is called each time a new assembly is loaded. */
typedef void (*MonoAssemblyLoadFunc) (MonoAssembly *assembly, gpointer user_data);
diff --git a/mono/metadata/class.c b/mono/metadata/class.c
index aa802c5a106..2a16c3a2954 100644
--- a/mono/metadata/class.c
+++ b/mono/metadata/class.c
@@ -20,6 +20,7 @@
#include <stdlib.h>
#include <signal.h>
#include <mono/metadata/image.h>
+#include <mono/metadata/assembly.h>
#include <mono/metadata/cil-coff.h>
#include <mono/metadata/metadata.h>
#include <mono/metadata/tabledefs.h>
@@ -179,6 +180,35 @@ mono_type_get_name (MonoType *type)
return g_string_free (result, FALSE);
}
+gboolean
+mono_class_is_open_constructed_type (MonoType *t)
+{
+ switch (t->type) {
+ case MONO_TYPE_VAR:
+ case MONO_TYPE_MVAR:
+ return TRUE;
+ case MONO_TYPE_SZARRAY:
+ return mono_class_is_open_constructed_type (&t->data.klass->byval_arg);
+ case MONO_TYPE_ARRAY:
+ return mono_class_is_open_constructed_type (&t->data.array->eklass->byval_arg);
+ case MONO_TYPE_PTR:
+ return mono_class_is_open_constructed_type (t->data.type);
+ case MONO_TYPE_GENERICINST: {
+ MonoGenericInst *ginst = t->data.generic_inst;
+ int i;
+
+ if (mono_class_is_open_constructed_type (ginst->generic_type))
+ return TRUE;
+ for (i = 0; i < ginst->type_argc; i++)
+ if (mono_class_is_open_constructed_type (ginst->type_argv [i]))
+ return TRUE;
+ return FALSE;
+ }
+ default:
+ return FALSE;
+ }
+}
+
MonoType*
mono_class_inflate_generic_type (MonoType *type, MonoGenericInst *ginst)
{
@@ -188,8 +218,14 @@ mono_class_inflate_generic_type (MonoType *type, MonoGenericInst *ginst)
return dup_type (ginst->type_argv [type->data.generic_param->num]);
else
return type;
- case MONO_TYPE_VAR:
- return dup_type (ginst->type_argv [type->data.generic_param->num]);
+ case MONO_TYPE_VAR: {
+ MonoType *t = ginst->type_argv [type->data.generic_param->num];
+
+ if ((t->type == MONO_TYPE_VAR) || (t->type == MONO_TYPE_MVAR))
+ return type;
+ else
+ return dup_type (t);
+ }
case MONO_TYPE_SZARRAY: {
MonoClass *eclass = type->data.klass;
MonoClass *nclass;
@@ -1990,7 +2026,7 @@ mono_array_class_get (MonoClass *eclass, guint32 rank)
}
/* for the building corlib use System.Array from it */
- if (image->assembly && image->assembly->dynamic && strcmp (image->assembly_name, "corlib") == 0) {
+ if (image->assembly && image->assembly->dynamic && strcmp (image->assembly_name, "mscorlib") == 0) {
parent = mono_class_from_name (image, "System", "Array");
corlib_type = TRUE;
} else {
@@ -2258,37 +2294,6 @@ mono_class_from_name_case (MonoImage *image, const char* name_space, const char
return NULL;
}
-static MonoImage*
-load_file_for_image (MonoImage *image, int fileidx)
-{
- char *base_dir, *name;
- MonoImage *res;
- MonoTableInfo *t = &image->tables [MONO_TABLE_FILE];
- const char *fname;
- guint32 fname_id;
-
- if (fileidx < 1 || fileidx > t->rows)
- return NULL;
- fname_id = mono_metadata_decode_row_col (t, fileidx - 1, MONO_FILE_NAME);
- fname = mono_metadata_string_heap (image, fname_id);
- base_dir = g_path_get_dirname (image->name);
- name = g_build_filename (base_dir, fname, NULL);
- res = mono_image_open (name, NULL);
- if (res) {
- int i;
- t = &res->tables [MONO_TABLE_MODULEREF];
- //g_print ("loaded file %s from %s (%p)\n", name, image->name, image->assembly);
- res->assembly = image->assembly;
- for (i = 0; i < t->rows; ++i) {
- if (res->modules [i] && !res->modules [i]->assembly)
- res->modules [i]->assembly = image->assembly;
- }
- }
- g_free (name);
- g_free (base_dir);
- return res;
-}
-
static MonoClass*
return_nested_in (MonoClass *class, char *nested) {
MonoClass *found;
@@ -2354,7 +2359,7 @@ mono_class_from_name (MonoImage *image, const char* name_space, const char *name
if (strcmp (name, ename) == 0 && strcmp (name_space, enspace) == 0) {
guint32 impl = cols [MONO_EXP_TYPE_IMPLEMENTATION];
if ((impl & IMPLEMENTATION_MASK) == IMPLEMENTATION_FILE) {
- loaded_image = load_file_for_image (image, impl >> IMPLEMENTATION_BITS);
+ loaded_image = mono_assembly_load_module (image->assembly, impl >> IMPLEMENTATION_BITS);
if (!loaded_image)
return NULL;
class = mono_class_from_name (loaded_image, name_space, name);
diff --git a/mono/metadata/class.h b/mono/metadata/class.h
index 486550b33b8..0818829d7cd 100644
--- a/mono/metadata/class.h
+++ b/mono/metadata/class.h
@@ -218,6 +218,7 @@ struct _MonoGenericInst {
MonoMethod *generic_method;
int type_argc;
MonoType **type_argv;
+ guint32 is_open;
};
struct _MonoGenericParam {
@@ -284,6 +285,9 @@ mono_class_from_name_case (MonoImage *image, const char* name_space, const char
MonoClass *
mono_class_from_typeref (MonoImage *image, guint32 type_token);
+gboolean
+mono_class_is_open_constructed_type (MonoType *t);
+
MonoClass *
mono_class_from_generic_parameter (MonoGenericParam *param, MonoImage *image, gboolean is_mvar);
diff --git a/mono/metadata/debug-helpers.c b/mono/metadata/debug-helpers.c
index 1d2268239ea..f1ca3be7b14 100644
--- a/mono/metadata/debug-helpers.c
+++ b/mono/metadata/debug-helpers.c
@@ -27,6 +27,7 @@ static const char *wrapper_type_names [] = {
"ldfld",
"stfld",
"synchronized",
+ "dynamic-method",
"unknown"
};
@@ -109,6 +110,20 @@ mono_type_get_desc (GString *res, MonoType *type, gboolean include_namespace) {
}
char*
+mono_type_full_name (MonoType *type)
+{
+ GString *str;
+ char *res;
+
+ str = g_string_new ("");
+ mono_type_get_desc (str, type, TRUE);
+
+ res = g_strdup (str->str);
+ g_string_free (str, TRUE);
+ return res;
+}
+
+char*
mono_signature_get_desc (MonoMethodSignature *sig, gboolean include_namespace)
{
int i;
@@ -471,7 +486,7 @@ mono_method_full_name (MonoMethod *method, gboolean signature)
if (method->wrapper_type != MONO_WRAPPER_NONE)
sprintf (wrapper, "(wrapper %s) ", wrapper_type_to_str (method->wrapper_type));
else
- sprintf (wrapper, "");
+ strcpy (wrapper, "");
res = g_strdup_printf ("%s%s.%s:%s (%s)", wrapper, method->klass->name_space,
method->klass->name, method->name, tmpsig);
g_free (tmpsig);
diff --git a/mono/metadata/debug-helpers.h b/mono/metadata/debug-helpers.h
index 2622c2af3cd..56fbaddf9f7 100644
--- a/mono/metadata/debug-helpers.h
+++ b/mono/metadata/debug-helpers.h
@@ -24,6 +24,8 @@ char* mono_disasm_code (MonoDisHelper *dh, MonoMethod *method, const guchar
typedef struct MonoMethodDesc MonoMethodDesc;
void mono_type_get_desc (GString *res, MonoType *type, gboolean include_namespace);
+char* mono_type_full_name (MonoType *type);
+
char* mono_signature_get_desc (MonoMethodSignature *sig, gboolean include_namespace);
MonoMethodDesc* mono_method_desc_new (const char *name, gboolean include_namespace);
diff --git a/mono/metadata/debug-mono-symfile.c b/mono/metadata/debug-mono-symfile.c
index 364521339c9..c4ca9931fbc 100644
--- a/mono/metadata/debug-mono-symfile.c
+++ b/mono/metadata/debug-mono-symfile.c
@@ -2,6 +2,7 @@
#include <stdlib.h>
#include <string.h>
#include <signal.h>
+#include <sys/param.h>
#include <mono/metadata/metadata.h>
#include <mono/metadata/tabledefs.h>
#include <mono/metadata/rawbuffer.h>
diff --git a/mono/metadata/domain.c b/mono/metadata/domain.c
index 91bfb1e4243..da0a2862c4d 100644
--- a/mono/metadata/domain.c
+++ b/mono/metadata/domain.c
@@ -257,19 +257,19 @@ mono_init (const char *filename)
TlsSetValue (appdomain_thread_id, domain);
/* find the corlib */
- corlib_aname.name = "corlib";
+ corlib_aname.name = "mscorlib";
ass = mono_assembly_load (&corlib_aname, NULL, &status);
if ((status != MONO_IMAGE_OK) || (ass == NULL)) {
switch (status){
case MONO_IMAGE_ERROR_ERRNO:
- g_print ("The assembly corlib.dll was not found or could not be loaded.\n");
+ g_print ("The assembly mscorlib.dll was not found or could not be loaded.\n");
g_print ("It should have been installed in the `%s' directory.\n", MONO_ASSEMBLIES);
break;
case MONO_IMAGE_IMAGE_INVALID:
- g_print ("The file %s/corlib.dll is an invalid CIL image\n", MONO_ASSEMBLIES);
+ g_print ("The file %s/mscorlib.dll is an invalid CIL image\n", MONO_ASSEMBLIES);
break;
case MONO_IMAGE_MISSING_ASSEMBLYREF:
- g_print ("Minning assembly reference in %s/corlib.dll\n", MONO_ASSEMBLIES);
+ g_print ("Minning assembly reference in %s/mscorlib.dll\n", MONO_ASSEMBLIES);
break;
case MONO_IMAGE_OK:
/* to suppress compiler warning */
@@ -619,8 +619,8 @@ mono_domain_free (MonoDomain *domain, gboolean force)
}
mono_g_hash_table_destroy (domain->class_init_trampoline_hash);
g_hash_table_destroy (domain->finalizable_objects_hash);
- if (domain->thread_static_fields)
- g_hash_table_destroy (domain->thread_static_fields);
+ if (domain->special_static_fields)
+ g_hash_table_destroy (domain->special_static_fields);
DeleteCriticalSection (&domain->lock);
domain->setup = NULL;
diff --git a/mono/metadata/exception.c b/mono/metadata/exception.c
index 30420c8c7ca..b579cdd2dc3 100644
--- a/mono/metadata/exception.c
+++ b/mono/metadata/exception.c
@@ -29,7 +29,15 @@ MonoException *
mono_exception_from_name (MonoImage *image, const char *name_space,
const char *name)
{
- MonoDomain *domain = mono_domain_get ();
+ return mono_exception_from_name_domain (mono_domain_get (), image, name_space, name);
+}
+
+MonoException *
+mono_exception_from_name_domain (MonoDomain *domain,
+ MonoImage *image,
+ const char* name_space,
+ const char *name)
+{
MonoClass *klass;
MonoObject *o;
@@ -349,3 +357,9 @@ mono_get_exception_appdomain_unloaded (void)
{
return mono_exception_from_name (mono_defaults.corlib, "System", "AppDomainUnloadedException");
}
+
+MonoException *
+mono_get_exception_bad_image_format (const guchar *msg)
+{
+ return mono_exception_from_name_msg (mono_defaults.corlib, "System", "BadImageFormatException", msg);
+}
diff --git a/mono/metadata/exception.h b/mono/metadata/exception.h
index 79eb4b253ad..ccd818cfe1e 100644
--- a/mono/metadata/exception.h
+++ b/mono/metadata/exception.h
@@ -22,6 +22,11 @@ mono_exception_from_name (MonoImage *image,
const char* name_space,
const char *name);
+extern MonoException *
+mono_exception_from_name_domain (MonoDomain *domain, MonoImage *image,
+ const char* name_space,
+ const char *name);
+
MonoException *
mono_get_exception_divide_by_zero (void);
@@ -94,4 +99,7 @@ mono_get_exception_cannot_unload_appdomain (const guchar *msg);
MonoException *
mono_get_exception_appdomain_unloaded (void);
+MonoException *
+mono_get_exception_bad_image_format (const guchar *msg);
+
#endif /* _MONO_METADATA_EXCEPTION_H_ */
diff --git a/mono/metadata/gc.c b/mono/metadata/gc.c
index 3bf7f2251df..e5833a28c6f 100644
--- a/mono/metadata/gc.c
+++ b/mono/metadata/gc.c
@@ -42,6 +42,8 @@ static CRITICAL_SECTION finalizer_mutex;
static GSList *domains_to_finalize= NULL;
+static HANDLE gc_thread;
+
static void object_register_finalizer (MonoObject *obj, void (*callback)(void *, void*));
#if HAVE_BOEHM_GC
@@ -166,6 +168,9 @@ mono_domain_finalize (MonoDomain *domain, guint32 timeout)
*/
#if HAVE_BOEHM_GC
+ if (gc_disabled)
+ return TRUE;
+
GC_gcollect ();
done_event = CreateEvent (NULL, TRUE, FALSE, NULL);
@@ -255,6 +260,10 @@ ves_icall_System_GC_WaitForPendingFinalizers (void)
if (!GC_should_invoke_finalizers ())
return;
+ if (GetCurrentThread () == gc_thread)
+ /* Avoid deadlocks */
+ return;
+
ResetEvent (pending_done_event);
finalize_notify ();
/* g_print ("Waiting for pending finalizers....\n"); */
@@ -584,8 +593,6 @@ static GCThreadFunctions mono_gc_thread_vtable = {
void mono_gc_init (void)
{
- HANDLE gc_thread;
-
InitializeCriticalSection (&handle_section);
InitializeCriticalSection (&allocator_section);
@@ -630,9 +637,9 @@ void mono_gc_cleanup (void)
#endif
#ifdef ENABLE_FINALIZER_THREAD
- ResetEvent (shutdown_event);
- finished = TRUE;
if (!gc_disabled) {
+ ResetEvent (shutdown_event);
+ finished = TRUE;
finalize_notify ();
/* Finishing the finalizer thread, so wait a little bit... */
/* MS seems to wait for about 2 seconds */
diff --git a/mono/metadata/icall.c b/mono/metadata/icall.c
index 80272e652a1..a40dc7efa10 100644
--- a/mono/metadata/icall.c
+++ b/mono/metadata/icall.c
@@ -44,6 +44,7 @@
#include <mono/metadata/locales.h>
#include <mono/io-layer/io-layer.h>
#include <mono/utils/strtod.h>
+#include <mono/utils/monobitset.h>
#if defined (PLATFORM_WIN32)
#include <windows.h>
@@ -726,38 +727,69 @@ ves_icall_System_Object_GetHashCode (MonoObject *this)
return key & 0x7fffffff;
}
-/*
- * A hash function for value types. I have no idea if this is a good hash
- * function (its similar to g_str_hash).
- */
static gint32
-ves_icall_System_ValueType_GetHashCode (MonoObject *this)
+ves_icall_System_ValueType_InternalGetHashCode (MonoObject *this, MonoArray **fields)
{
- gint32 i, size;
- const char *p;
- guint h = 0;
+ int i;
+ MonoClass *klass;
+ MonoObject **values = NULL;
+ MonoObject *o;
+ int count = 0;
+ gint32 result = 0;
MONO_ARCH_SAVE_REGS;
- MONO_CHECK_ARG_NULL (this);
-
- size = this->vtable->klass->instance_size - sizeof (MonoObject);
+ klass = this->vtable->klass;
- p = (const char *)this + sizeof (MonoObject);
+ if (klass->field.count == 0)
+ return ves_icall_System_Object_GetHashCode (this);
- for (i = 0; i < size; i++) {
- h = (h << 5) - h + *p;
- p++;
+ /*
+ * Compute the starting value of the hashcode for fields of primitive
+ * types, and return the remaining fields in an array to the managed side.
+ * This way, we can avoid costly reflection operations in managed code.
+ */
+ for (i = 0; i < klass->field.count; ++i) {
+ MonoClassField *field = &klass->fields [i];
+ if (field->type->attrs & FIELD_ATTRIBUTE_STATIC)
+ continue;
+ /* FIXME: Add more types */
+ switch (field->type->type) {
+ case MONO_TYPE_I4:
+ result ^= *(gint32*)((guint8*)this + field->offset);
+ break;
+ case MONO_TYPE_STRING: {
+ MonoString *s;
+ s = *(MonoString**)((guint8*)this + field->offset);
+ if (s != NULL)
+ result ^= ves_icall_System_String_GetHashCode (s);
+ break;
+ }
+ default:
+ if (!values)
+ values = alloca (klass->field.count * sizeof (MonoObject*));
+ o = mono_field_get_value_object (mono_object_domain (this), field, this);
+ values [count++] = o;
+ }
}
- return h;
+ if (values) {
+ *fields = mono_array_new (mono_domain_get (), mono_defaults.object_class, count);
+ memcpy (mono_array_addr (*fields, MonoObject*, 0), values, count * sizeof (MonoObject*));
+ }
+ else
+ *fields = NULL;
+ return result;
}
static MonoBoolean
-ves_icall_System_ValueType_Equals (MonoObject *this, MonoObject *that)
+ves_icall_System_ValueType_Equals (MonoObject *this, MonoObject *that, MonoArray **fields)
{
- gint32 size;
- const char *p, *s;
+ int i;
+ MonoClass *klass;
+ MonoObject **values = NULL;
+ MonoObject *o;
+ int count = 0;
MONO_ARCH_SAVE_REGS;
@@ -766,12 +798,61 @@ ves_icall_System_ValueType_Equals (MonoObject *this, MonoObject *that)
if (this->vtable != that->vtable)
return FALSE;
- size = this->vtable->klass->instance_size - sizeof (MonoObject);
+ klass = this->vtable->klass;
+
+ /*
+ * Do the comparison for fields of primitive type and return a result if
+ * possible. Otherwise, return the remaining fields in an array to the
+ * managed side. This way, we can avoid costly reflection operations in
+ * managed code.
+ */
+ *fields = NULL;
+ for (i = 0; i < klass->field.count; ++i) {
+ MonoClassField *field = &klass->fields [i];
+ if (field->type->attrs & FIELD_ATTRIBUTE_STATIC)
+ continue;
+ /* FIXME: Add more types */
+ switch (field->type->type) {
+ case MONO_TYPE_I4:
+ if (*(gint32*)((guint8*)this + field->offset) != *(gint32*)((guint8*)that + field->offset))
+ return FALSE;
+ break;
+ case MONO_TYPE_STRING: {
+ MonoString *s1, *s2;
+ guint32 s1len, s2len;
+ s1 = *(MonoString**)((guint8*)this + field->offset);
+ s2 = *(MonoString**)((guint8*)that + field->offset);
+ if (s1 == s2)
+ break;
+ if ((s1 == NULL) || (s2 == NULL))
+ return FALSE;
+ s1len = mono_string_length (s1);
+ s2len = mono_string_length (s2);
+ if (s1len != s2len)
+ return FALSE;
+
+ if (memcmp (mono_string_chars (s1), mono_string_chars (s2), s1len * sizeof (gunichar2)) != 0)
+ return FALSE;
+ break;
+ }
+ default:
+ if (!values)
+ values = alloca (klass->field.count * 2 * sizeof (MonoObject*));
+ o = mono_field_get_value_object (mono_object_domain (this), field, this);
+ values [count++] = o;
+ o = mono_field_get_value_object (mono_object_domain (this), field, that);
+ values [count++] = o;
+ }
+ }
- p = (const char *)this + sizeof (MonoObject);
- s = (const char *)that + sizeof (MonoObject);
+ if (values) {
+ *fields = mono_array_new (mono_domain_get (), mono_defaults.object_class, count);
+ memcpy (mono_array_addr (*fields, MonoObject*, 0), values, count * sizeof (MonoObject*));
- return memcmp (p, s, size)? FALSE: TRUE;
+ return FALSE;
+ }
+ else
+ return TRUE;
}
static MonoReflectionType *
@@ -1070,6 +1151,14 @@ ves_icall_get_method_info (MonoMethod *method, MonoMethodInfo *info)
info->ret = mono_type_get_object (domain, method->signature->ret);
info->attrs = method->flags;
info->implattrs = method->iflags;
+ if (method->signature->call_convention == MONO_CALL_DEFAULT)
+ info->callconv = 1;
+ else
+ if (method->signature->call_convention == MONO_CALL_VARARG)
+ info->callconv = 2;
+ else
+ info->callconv = 0;
+ info->callconv |= (method->signature->hasthis << 5) | (method->signature->explicit_this << 6);
}
static MonoArray*
@@ -1262,6 +1351,7 @@ ves_icall_Type_GetInterfaces (MonoReflectionType* type)
int ninterf, i;
MonoClass *class = mono_class_from_mono_type (type->type);
MonoClass *parent;
+ MonoBitSet *slots = mono_bitset_new (class->max_interface_id + 1, 0);
MONO_ARCH_SAVE_REGS;
@@ -1272,16 +1362,30 @@ ves_icall_Type_GetInterfaces (MonoReflectionType* type)
ninterf = 0;
for (parent = class; parent; parent = parent->parent) {
- ninterf += parent->interface_count;
+ for (i = 0; i < parent->interface_count; ++i) {
+ if (mono_bitset_test (slots, parent->interfaces [i]->interface_id))
+ continue;
+
+ mono_bitset_set (slots, parent->interfaces [i]->interface_id);
+ ++ninterf;
+ }
}
+
intf = mono_array_new (domain, mono_defaults.monotype_class, ninterf);
ninterf = 0;
for (parent = class; parent; parent = parent->parent) {
for (i = 0; i < parent->interface_count; ++i) {
- mono_array_set (intf, gpointer, ninterf, mono_type_get_object (domain, &parent->interfaces [i]->byval_arg));
+ if (!mono_bitset_test (slots, parent->interfaces [i]->interface_id))
+ continue;
+
+ mono_bitset_clear (slots, parent->interfaces [i]->interface_id);
+ mono_array_set (intf, gpointer, ninterf,
+ mono_type_get_object (domain, &parent->interfaces [i]->byval_arg));
++ninterf;
}
}
+
+ mono_bitset_free (slots);
return intf;
}
@@ -2428,7 +2532,24 @@ ves_icall_System_Reflection_Assembly_InternalGetType (MonoReflectionAssembly *as
type = NULL;
}
else
- type = mono_reflection_get_type (assembly->assembly->image, &info, ignoreCase);
+ if (assembly->assembly->dynamic) {
+ /* Enumerate all modules */
+ MonoReflectionAssemblyBuilder *abuilder = (MonoReflectionAssemblyBuilder*)assembly;
+ int i;
+
+ if (!abuilder->modules)
+ type = NULL;
+ else {
+ for (i = 0; i < mono_array_length (abuilder->modules); ++i) {
+ MonoReflectionModuleBuilder *mb = mono_array_get (abuilder->modules, MonoReflectionModuleBuilder*, i);
+ type = mono_reflection_get_type (&mb->dynamic_image->image, &info, ignoreCase);
+ if (type)
+ break;
+ }
+ }
+ }
+ else
+ type = mono_reflection_get_type (assembly->assembly->image, &info, ignoreCase);
g_free (str);
g_list_free (info.modifiers);
g_list_free (info.nested);
@@ -2582,7 +2703,9 @@ ves_icall_System_Reflection_Assembly_GetNamespaces (MonoReflectionAssembly *asse
int n;
MonoArray *res;
NameSpaceInfo info;
-
+ MonoTableInfo *t = &img->tables [MONO_TABLE_EXPORTEDTYPE];
+ int i;
+
MONO_ARCH_SAVE_REGS;
n = g_hash_table_size (img->name_cache);
@@ -2590,6 +2713,31 @@ ves_icall_System_Reflection_Assembly_GetNamespaces (MonoReflectionAssembly *asse
info.res = res;
info.idx = 0;
g_hash_table_foreach (img->name_cache, (GHFunc)foreach_namespace, &info);
+
+ /* Add namespaces from the EXPORTEDTYPES table as well */
+ if (t->rows) {
+ MonoArray *res2;
+ GPtrArray *nspaces = g_ptr_array_new ();
+ for (i = 0; i < t->rows; ++i) {
+ const char *nspace = mono_metadata_string_heap (img, mono_metadata_decode_row_col (t, i, MONO_EXP_TYPE_NAMESPACE));
+ if (!g_hash_table_lookup (img->name_cache, nspace)) {
+ g_ptr_array_add (nspaces, (char*)nspace);
+ }
+ }
+ if (nspaces->len > 0) {
+ res2 = mono_array_new (mono_object_domain (assembly), mono_defaults.string_class, n + nspaces->len);
+ memcpy (mono_array_addr (res2, MonoString*, 0),
+ mono_array_addr (res, MonoString*, 0),
+ n * sizeof (MonoString*));
+ for (i = 0; i < nspaces->len; ++i)
+ mono_array_set (res2, MonoString*, n + i,
+ mono_string_new (mono_object_domain (assembly),
+ g_ptr_array_index (nspaces, i)));
+ res = res2;
+ }
+ g_ptr_array_free (nspaces, TRUE);
+ }
+
return res;
}
@@ -2860,22 +3008,20 @@ ves_icall_System_MonoType_getFullName (MonoReflectionType *object)
}
static void
-ves_icall_System_Reflection_Assembly_FillName (MonoReflectionAssembly *assembly, MonoReflectionAssemblyName *aname)
+fill_reflection_assembly_name (MonoDomain *domain, MonoReflectionAssemblyName *aname, MonoAssemblyName *name, const char *absolute)
{
- MonoAssemblyName *name = &assembly->assembly->aname;
static MonoMethod *create_culture = NULL;
gpointer args [1];
guint32 pkey_len;
const char *pkey_ptr;
- gchar *absolute;
gchar *codebase;
MONO_ARCH_SAVE_REGS;
if (strcmp (name->name, "corlib") == 0)
- aname->name = mono_string_new (mono_object_domain (assembly), "mscorlib");
+ aname->name = mono_string_new (domain, "mscorlib");
else
- aname->name = mono_string_new (mono_object_domain (assembly), name->name);
+ aname->name = mono_string_new (domain, name->name);
aname->major = name->major;
aname->minor = name->minor;
@@ -2883,11 +3029,11 @@ ves_icall_System_Reflection_Assembly_FillName (MonoReflectionAssembly *assembly,
aname->revision = name->revision;
aname->hashalg = name->hash_alg;
- absolute = g_build_filename (assembly->assembly->basedir, assembly->assembly->image->module_name, NULL);
codebase = g_filename_to_uri (absolute, NULL, NULL);
- aname->codebase = mono_string_new (mono_object_domain (assembly), codebase);
- g_free (codebase);
- g_free (absolute);
+ if (codebase) {
+ aname->codebase = mono_string_new (domain, codebase);
+ g_free (codebase);
+ }
if (!create_culture) {
MonoMethodDesc *desc = mono_method_desc_new ("System.Globalization.CultureInfo:CreateSpecificCulture(string)", TRUE);
@@ -2896,7 +3042,7 @@ ves_icall_System_Reflection_Assembly_FillName (MonoReflectionAssembly *assembly,
mono_method_desc_free (desc);
}
- args [0] = mono_string_new (mono_object_domain (assembly), name->culture);
+ args [0] = mono_string_new (domain, name->culture);
aname->cultureInfo =
mono_runtime_invoke (create_culture, NULL, args, NULL);
@@ -2904,11 +3050,62 @@ ves_icall_System_Reflection_Assembly_FillName (MonoReflectionAssembly *assembly,
pkey_ptr = name->public_key;
pkey_len = mono_metadata_decode_blob_size (pkey_ptr, &pkey_ptr);
- aname->publicKey = mono_array_new (mono_object_domain (assembly), mono_defaults.byte_class, pkey_len);
+ aname->publicKey = mono_array_new (domain, mono_defaults.byte_class, pkey_len);
memcpy (mono_array_addr (aname->publicKey, guint8, 0), pkey_ptr, pkey_len);
}
}
+static void
+ves_icall_System_Reflection_Assembly_FillName (MonoReflectionAssembly *assembly, MonoReflectionAssemblyName *aname)
+{
+ gchar *absolute;
+
+ MONO_ARCH_SAVE_REGS;
+
+ absolute = g_build_filename (assembly->assembly->basedir, assembly->assembly->image->module_name, NULL);
+
+ fill_reflection_assembly_name (mono_object_domain (assembly), aname,
+ &assembly->assembly->aname, absolute);
+
+ g_free (absolute);
+}
+
+static void
+ves_icall_System_Reflection_Assembly_InternalGetAssemblyName (MonoString *fname, MonoReflectionAssemblyName *aname)
+{
+ char *filename;
+ MonoImageOpenStatus status = MONO_IMAGE_OK;
+ gboolean res;
+ MonoImage *image;
+ MonoAssemblyName name;
+
+ MONO_ARCH_SAVE_REGS;
+
+ filename = mono_string_to_utf8 (fname);
+
+ image = mono_image_open (filename, &status);
+
+ if (!image){
+ MonoException *exc;
+
+ g_free (filename);
+ exc = mono_get_exception_file_not_found (fname);
+ mono_raise_exception (exc);
+ }
+
+ res = mono_assembly_fill_assembly_name (image, &name);
+ if (!res) {
+ mono_image_close (image);
+ g_free (filename);
+ mono_raise_exception (mono_get_exception_argument ("assemblyFile", "The file does not contain a manifest"));
+ }
+
+ fill_reflection_assembly_name (mono_domain_get (), aname, &name, filename);
+
+ g_free (filename);
+ mono_image_close (image);
+}
+
static MonoArray*
mono_module_get_types (MonoDomain *domain, MonoImage *image,
MonoBoolean exportedOnly)
@@ -2919,8 +3116,6 @@ mono_module_get_types (MonoDomain *domain, MonoImage *image,
int i, count;
guint32 attrs, visibility;
- MONO_ARCH_SAVE_REGS;
-
/* we start the count from 1 because we skip the special type <Module> */
if (exportedOnly) {
count = 0;
@@ -2951,7 +3146,44 @@ mono_module_get_types (MonoDomain *domain, MonoImage *image,
static MonoArray*
ves_icall_System_Reflection_Assembly_GetTypes (MonoReflectionAssembly *assembly, MonoBoolean exportedOnly)
{
- return mono_module_get_types (mono_object_domain (assembly), assembly->assembly->image, exportedOnly);
+ MonoArray *res;
+ MonoImage *image = assembly->assembly->image;
+ MonoTableInfo *table = &image->tables [MONO_TABLE_FILE];
+ MonoDomain *domain;
+ int i;
+
+ MONO_ARCH_SAVE_REGS;
+
+ domain = mono_object_domain (assembly);
+ res = mono_module_get_types (domain, image, exportedOnly);
+
+ /* Append data from all modules in the assembly */
+ for (i = 0; i < table->rows; ++i) {
+ if (!(mono_metadata_decode_row_col (table, i, MONO_FILE_FLAGS) & FILE_CONTAINS_NO_METADATA)) {
+ MonoImage *loaded_image = mono_assembly_load_module (image->assembly, i + 1);
+ if (loaded_image) {
+ MonoArray *res2 = mono_module_get_types (domain, loaded_image, exportedOnly);
+ /* Append the new types to the end of the array */
+ if (mono_array_length (res2) > 0) {
+ guint32 len1, len2;
+ MonoArray *res3;
+
+ len1 = mono_array_length (res);
+ len2 = mono_array_length (res2);
+ res3 = mono_array_new (domain, mono_defaults.monotype_class, len1 + len2);
+ memcpy (mono_array_addr (res3, MonoReflectionType*, 0),
+ mono_array_addr (res, MonoReflectionType*, 0),
+ len1 * sizeof (MonoReflectionType*));
+ memcpy (mono_array_addr (res3, MonoReflectionType*, len1),
+ mono_array_addr (res2, MonoReflectionType*, 0),
+ len2 * sizeof (MonoReflectionType*));
+ res = res3;
+ }
+ }
+ }
+ }
+
+ return res;
}
static MonoReflectionType*
@@ -2981,6 +3213,8 @@ ves_icall_System_Reflection_Module_GetGuidInternal (MonoReflectionModule *module
static MonoArray*
ves_icall_System_Reflection_Module_InternalGetTypes (MonoReflectionModule *module)
{
+ MONO_ARCH_SAVE_REGS;
+
if (!module->image)
return mono_array_new (mono_object_domain (module), mono_defaults.monotype_class, 0);
else
@@ -4028,7 +4262,7 @@ static gconstpointer icall_map [] = {
/*
* System.ValueType
*/
- "System.ValueType::GetHashCode", ves_icall_System_ValueType_GetHashCode,
+ "System.ValueType::InternalGetHashCode", ves_icall_System_ValueType_InternalGetHashCode,
"System.ValueType::InternalEquals", ves_icall_System_ValueType_Equals,
/*
@@ -4081,6 +4315,7 @@ static gconstpointer icall_map [] = {
"System.AppDomain::getFriendlyName", ves_icall_System_AppDomain_getFriendlyName,
"System.AppDomain::GetAssemblies", ves_icall_System_AppDomain_GetAssemblies,
"System.AppDomain::LoadAssembly", ves_icall_System_AppDomain_LoadAssembly,
+ "System.AppDomain::LoadAssemblyRaw", ves_icall_System_AppDomain_LoadAssemblyRaw,
"System.AppDomain::InternalIsFinalizingForUnload", ves_icall_System_AppDomain_InternalIsFinalizingForUnload,
"System.AppDomain::InternalUnload", ves_icall_System_AppDomain_InternalUnload,
"System.AppDomain::ExecuteAssembly", ves_icall_System_AppDomain_ExecuteAssembly,
@@ -4174,6 +4409,11 @@ static gconstpointer icall_map [] = {
"System.Reflection.Emit.TypeBuilder::setup_generic_class", mono_reflection_setup_generic_class,
/*
+ * DynamicMethod
+ */
+ "System.Reflection.Emit.DynamicMethod::create_dynamic_method", mono_reflection_create_dynamic_method,
+
+ /*
* TypeBuilder generics icalls.
*/
"System.Reflection.Emit.TypeBuilder::get_IsGenericParameter", ves_icall_TypeBuilder_get_IsGenericParameter,
@@ -4264,6 +4504,32 @@ static gconstpointer icall_map [] = {
"System.Threading.NativeEventCalls::CloseEvent_internal", ves_icall_System_Threading_Events_CloseEvent_internal,
"System.Threading.ThreadPool::GetAvailableThreads", ves_icall_System_Threading_ThreadPool_GetAvailableThreads,
"System.Threading.ThreadPool::GetMaxThreads", ves_icall_System_Threading_ThreadPool_GetMaxThreads,
+ "System.Threading.Thread::VolatileRead(byte&)", ves_icall_System_Threading_Thread_VolatileRead1,
+ "System.Threading.Thread::VolatileRead(double&)", ves_icall_System_Threading_Thread_VolatileRead8,
+ "System.Threading.Thread::VolatileRead(short&)", ves_icall_System_Threading_Thread_VolatileRead2,
+ "System.Threading.Thread::VolatileRead(int&)", ves_icall_System_Threading_Thread_VolatileRead4,
+ "System.Threading.Thread::VolatileRead(long&)", ves_icall_System_Threading_Thread_VolatileRead8,
+ "System.Threading.Thread::VolatileRead(IntPtr&)", ves_icall_System_Threading_Thread_VolatileReadIntPtr,
+ "System.Threading.Thread::VolatileRead(object&)", ves_icall_System_Threading_Thread_VolatileReadIntPtr,
+ "System.Threading.Thread::VolatileRead(sbyte&)", ves_icall_System_Threading_Thread_VolatileRead1,
+ "System.Threading.Thread::VolatileRead(float&)", ves_icall_System_Threading_Thread_VolatileRead4,
+ "System.Threading.Thread::VolatileRead(ushort&)", ves_icall_System_Threading_Thread_VolatileRead2,
+ "System.Threading.Thread::VolatileRead(uint&)", ves_icall_System_Threading_Thread_VolatileRead2,
+ "System.Threading.Thread::VolatileRead(ulong&)", ves_icall_System_Threading_Thread_VolatileRead8,
+ "System.Threading.Thread::VolatileRead(UIntPtr&)", ves_icall_System_Threading_Thread_VolatileReadIntPtr,
+ "System.Threading.Thread::VolatileWrite(byte&,byte)", ves_icall_System_Threading_Thread_VolatileWrite1,
+ "System.Threading.Thread::VolatileWrite(double&,double)", ves_icall_System_Threading_Thread_VolatileWrite8,
+ "System.Threading.Thread::VolatileWrite(short&,short)", ves_icall_System_Threading_Thread_VolatileWrite2,
+ "System.Threading.Thread::VolatileWrite(int&,int)", ves_icall_System_Threading_Thread_VolatileWrite4,
+ "System.Threading.Thread::VolatileWrite(long&,long)", ves_icall_System_Threading_Thread_VolatileWrite8,
+ "System.Threading.Thread::VolatileWrite(IntPtr&,IntPtr)", ves_icall_System_Threading_Thread_VolatileWriteIntPtr,
+ "System.Threading.Thread::VolatileWrite(object&,object)", ves_icall_System_Threading_Thread_VolatileWriteIntPtr,
+ "System.Threading.Thread::VolatileWrite(sbyte&,sbyte)", ves_icall_System_Threading_Thread_VolatileWrite1,
+ "System.Threading.Thread::VolatileWrite(float&,float)", ves_icall_System_Threading_Thread_VolatileWrite4,
+ "System.Threading.Thread::VolatileWrite(ushort&,ushort)", ves_icall_System_Threading_Thread_VolatileWrite2,
+ "System.Threading.Thread::VolatileWrite(uint&,uint)", ves_icall_System_Threading_Thread_VolatileWrite2,
+ "System.Threading.Thread::VolatileWrite(ulong&,ulong)", ves_icall_System_Threading_Thread_VolatileWrite8,
+ "System.Threading.Thread::VolatileWrite(UIntPtr&,UIntPtr)", ves_icall_System_Threading_Thread_VolatileWriteIntPtr,
/*
* System.Threading.WaitHandle
@@ -4317,6 +4583,7 @@ static gconstpointer icall_map [] = {
"System.Reflection.Assembly::InternalGetType", ves_icall_System_Reflection_Assembly_InternalGetType,
"System.Reflection.Assembly::GetTypes", ves_icall_System_Reflection_Assembly_GetTypes,
"System.Reflection.Assembly::FillName", ves_icall_System_Reflection_Assembly_FillName,
+ "System.Reflection.Assembly::InternalGetAssemblyName", ves_icall_System_Reflection_Assembly_InternalGetAssemblyName,
"System.Reflection.Assembly::get_code_base", ves_icall_System_Reflection_Assembly_get_code_base,
"System.Reflection.Assembly::get_location", ves_icall_System_Reflection_Assembly_get_location,
"System.Reflection.Assembly::InternalImageRuntimeVersion", ves_icall_System_Reflection_Assembly_InternalImageRuntimeVersion,
@@ -4517,6 +4784,7 @@ static gconstpointer icall_map [] = {
"System.Environment::get_Platform", ves_icall_System_Environment_get_Platform,
"System.Environment::get_ExitCode", mono_environment_exitcode_get,
"System.Environment::set_ExitCode", mono_environment_exitcode_set,
+ "System.Environment::GetMachineConfigPath", ves_icall_System_Configuration_DefaultConfig_get_machine_config_path,
/*
* System.Runtime.Remoting
diff --git a/mono/metadata/image.c b/mono/metadata/image.c
index 852e1c2991c..55b926baaa2 100644
--- a/mono/metadata/image.c
+++ b/mono/metadata/image.c
@@ -743,9 +743,10 @@ MonoImage *
mono_image_loaded (const char *name)
{
MonoImage *res;
-
- if (strcmp (name, "mscorlib") == 0)
- name = "corlib";
+
+ if (strcmp (name, "corlib") == 0)
+ name = "mscorlib";
+
EnterCriticalSection (&images_mutex);
res = g_hash_table_lookup (loaded_images_hash, name);
LeaveCriticalSection (&images_mutex);
@@ -1104,6 +1105,37 @@ mono_image_get_resource (MonoImage *image, guint32 offset, guint32 *size)
return data;
}
+MonoImage*
+mono_image_load_file_for_image (MonoImage *image, int fileidx)
+{
+ char *base_dir, *name;
+ MonoImage *res;
+ MonoTableInfo *t = &image->tables [MONO_TABLE_FILE];
+ const char *fname;
+ guint32 fname_id;
+
+ if (fileidx < 1 || fileidx > t->rows)
+ return NULL;
+ fname_id = mono_metadata_decode_row_col (t, fileidx - 1, MONO_FILE_NAME);
+ fname = mono_metadata_string_heap (image, fname_id);
+ base_dir = g_path_get_dirname (image->name);
+ name = g_build_filename (base_dir, fname, NULL);
+ res = mono_image_open (name, NULL);
+ if (res) {
+ int i;
+ t = &res->tables [MONO_TABLE_MODULEREF];
+ //g_print ("loaded file %s from %s (%p)\n", name, image->name, image->assembly);
+ res->assembly = image->assembly;
+ for (i = 0; i < t->rows; ++i) {
+ if (res->modules [i] && !res->modules [i]->assembly)
+ res->modules [i]->assembly = image->assembly;
+ }
+ }
+ g_free (name);
+ g_free (base_dir);
+ return res;
+}
+
const char*
mono_image_get_strong_name (MonoImage *image, guint32 *size)
{
diff --git a/mono/metadata/image.h b/mono/metadata/image.h
index fd7e3966fc6..04f138c462f 100644
--- a/mono/metadata/image.h
+++ b/mono/metadata/image.h
@@ -25,7 +25,7 @@ typedef struct {
GModule *aot_module;
MonoImage *image;
/* Load files here */
- void *dynamic;
+ gboolean dynamic;
} MonoAssembly;
typedef struct {
@@ -165,6 +165,7 @@ int mono_image_ensure_section_idx (MonoImage *image,
guint32 mono_image_get_entry_point (MonoImage *image);
const char *mono_image_get_resource (MonoImage *image, guint32 offset, guint32 *size);
+MonoImage* mono_image_load_file_for_image (MonoImage *image, int fileidx);
/* This actually returns a MonoPEResourceDataEntry *, but declaring it
* causes an include file loop.
diff --git a/mono/metadata/loader.c b/mono/metadata/loader.c
index 1bf463401e5..00e212c7cd8 100644
--- a/mono/metadata/loader.c
+++ b/mono/metadata/loader.c
@@ -495,9 +495,13 @@ method_from_methodspec (MonoImage *image, guint32 idx)
ginst->type_argc = param_count;
ginst->type_argv = g_new0 (MonoType *, param_count);
- for (i = 0; i < param_count; i++)
+ for (i = 0; i < param_count; i++) {
ginst->type_argv [i] = mono_metadata_parse_type (image, MONO_PARSE_TYPE, 0, ptr, &ptr);
+ if (!ginst->is_open)
+ ginst->is_open = mono_class_is_open_constructed_type (ginst->type_argv [i]);
+ }
+
return mono_class_inflate_generic_method (method, ginst);
}
@@ -717,10 +721,10 @@ mono_get_method_from_token (MonoImage *image, guint32 token, MonoClass *klass)
result->string_ctor = 1;
result->signature->pinvoke = 1;
- } else if (cols [2] & METHOD_ATTRIBUTE_PINVOKE_IMPL) {
+ } else if ((cols [2] & METHOD_ATTRIBUTE_PINVOKE_IMPL) && (!(cols [1] & METHOD_IMPL_ATTRIBUTE_NATIVE))) {
MonoMethodPInvoke *piinfo = (MonoMethodPInvoke *)result;
MonoTableInfo *im = &tables [MONO_TABLE_IMPLMAP];
- MonoCallConvention conv;
+ MonoCallConvention conv = 0;
result->signature->pinvoke = 1;
piinfo->implmap_idx = mono_metadata_implmap_from_method (image, idx - 1);
diff --git a/mono/metadata/loader.h b/mono/metadata/loader.h
index 545816be471..99341efb6f9 100644
--- a/mono/metadata/loader.h
+++ b/mono/metadata/loader.h
@@ -18,6 +18,7 @@ typedef enum {
MONO_WRAPPER_LDFLD,
MONO_WRAPPER_STFLD,
MONO_WRAPPER_SYNCHRONIZED,
+ MONO_WRAPPER_DYNAMIC_METHOD,
MONO_WRAPPER_UNKNOWN
} MonoWrapperType;
diff --git a/mono/metadata/locales.c b/mono/metadata/locales.c
index 1e5d36cc42d..cb0a53402f9 100644
--- a/mono/metadata/locales.c
+++ b/mono/metadata/locales.c
@@ -183,7 +183,9 @@ static MonoObject *create_DateTimeFormat (const char *locale)
mono_runtime_object_init (new_dtf);
ec=U_ZERO_ERROR;
- conv=ucnv_open ("UTF-16LE", &ec);
+
+ /* Plain "UTF-16" adds a BOM, which confuses other stuff */
+ conv=ucnv_open ("UTF16_PlatformEndian", &ec);
if(U_FAILURE (ec)) {
goto error0;
}
@@ -307,7 +309,7 @@ void ves_icall_System_Globalization_CultureInfo_construct_internal_locale (MonoO
}
ec=U_ZERO_ERROR;
- conv=ucnv_open ("UTF-16LE", &ec);
+ conv=ucnv_open ("UTF16_PlatformEndian", &ec);
if(U_FAILURE (ec)) {
g_free (icu_locale);
mono_raise_exception((MonoException *)mono_exception_from_name(mono_defaults.corlib, "System", "SystemException"));
@@ -473,7 +475,7 @@ gint32 ves_icall_System_Globalization_CompareInfo_internal_compare (MonoObject *
}
ec=U_ZERO_ERROR;
- conv=ucnv_open ("UTF-16LE", &ec);
+ conv=ucnv_open ("UTF16_PlatformEndian", &ec);
if(U_FAILURE (ec)) {
return(0);
}
@@ -524,7 +526,7 @@ void ves_icall_System_Globalization_CompareInfo_assign_sortkey (MonoObject *this
}
ec=U_ZERO_ERROR;
- conv=ucnv_open ("UTF-16LE", &ec);
+ conv=ucnv_open ("UTF16_PlatformEndian", &ec);
if(U_FAILURE (ec)) {
mono_raise_exception((MonoException *)mono_exception_from_name(mono_defaults.corlib, "System", "SystemException"));
return;
diff --git a/mono/metadata/locales.h b/mono/metadata/locales.h
index 3ecc8714f28..34de3c6ad43 100644
--- a/mono/metadata/locales.h
+++ b/mono/metadata/locales.h
@@ -10,7 +10,6 @@
#ifndef _MONO_METADATA_LOCALES_H_
#define _MONO_METADATA_LOCALES_H_
-#include <config.h>
#include <glib.h>
#include <mono/metadata/object.h>
diff --git a/mono/metadata/metadata.c b/mono/metadata/metadata.c
index 0ee805fcc95..0bf69355150 100644
--- a/mono/metadata/metadata.c
+++ b/mono/metadata/metadata.c
@@ -1201,6 +1201,21 @@ MonoType*
mono_metadata_parse_type (MonoImage *m, MonoParseTypeMode mode, short opt_attrs, const char *ptr, const char **rptr)
{
MonoType *type, *cached;
+ gboolean byref = FALSE;
+
+ /*
+ * According to the spec, custom modifiers should come before the byref
+ * flag, but the IL produced by ilasm from the following signature:
+ * object modopt(...) &
+ * starts with a byref flag, followed by the modifiers. (bug #49802)
+ * Also, this type seems to be different from 'object & modopt(...)'. Maybe
+ * it would be better to treat byref as real type constructor instead of
+ * a modifier...
+ */
+ if (*ptr == MONO_TYPE_BYREF) {
+ byref = TRUE;
+ ++ptr;
+ }
switch (mode) {
case MONO_PARSE_MOD_TYPE:
@@ -1236,6 +1251,7 @@ mono_metadata_parse_type (MonoImage *m, MonoParseTypeMode mode, short opt_attrs,
}
type->attrs = opt_attrs;
+ type->byref = byref;
if (mode == MONO_PARSE_LOCAL) {
/*
* check for pinned flag
@@ -3260,8 +3276,9 @@ mono_metadata_load_generic_params (MonoImage *image, guint32 token, guint32 *num
if (i >= tdef->rows)
return NULL;
params = NULL;
- n = 1;
+ n = 0;
do {
+ n++;
params = g_realloc (params, sizeof (MonoGenericParam) * n);
params [n - 1].pklass = NULL;
params [n - 1].method = NULL;
@@ -3272,7 +3289,6 @@ mono_metadata_load_generic_params (MonoImage *image, guint32 token, guint32 *num
if (++i >= tdef->rows)
break;
mono_metadata_decode_row (tdef, i, cols, MONO_GENERICPARAM_SIZE);
- n++;
} while (cols [MONO_GENERICPARAM_OWNER] == owner);
if (num)
diff --git a/mono/metadata/mono-debug.c b/mono/metadata/mono-debug.c
index 783059a5790..06061865d4f 100644
--- a/mono/metadata/mono-debug.c
+++ b/mono/metadata/mono-debug.c
@@ -159,7 +159,8 @@ mono_debug_add_type (MonoClass *klass)
MonoDebugHandle *handle;
handle = _mono_debug_get_image (klass->image);
- g_assert (handle);
+ if (!handle)
+ return;
if (handle->_priv->debugger_info)
mono_debugger_add_type (handle->_priv->debugger_info, klass);
@@ -266,7 +267,8 @@ mono_debug_add_method (MonoMethod *method, MonoDebugMethodJitInfo *jit, MonoDoma
return;
handle = _mono_debug_get_image (klass->image);
- g_assert (handle);
+ if (!handle)
+ return;
minfo = _mono_debug_lookup_method (method);
if (!minfo)
diff --git a/mono/metadata/object.c b/mono/metadata/object.c
index 1d95b14568b..2dfa28010b3 100644
--- a/mono/metadata/object.c
+++ b/mono/metadata/object.c
@@ -69,7 +69,7 @@ mono_runtime_class_init (MonoVTable *vtable)
int i;
MonoException *exc;
MonoException *exc_to_throw;
- MonoMethod *method;
+ MonoMethod *method = NULL;
MonoClass *klass;
gchar *full_name;
gboolean found;
@@ -323,8 +323,14 @@ mono_class_compute_gc_descriptor (MonoClass *class)
}
#endif /* CREATION_SPEEDUP */
-static gboolean
-field_is_thread_static (MonoClass *fklass, MonoClassField *field)
+/**
+ * field_is_special_static:
+ *
+ * Returns SPECIAL_STATIC_THREAD if the field is thread static, SPECIAL_STATIC_CONTEXT if it is context static,
+ * SPECIAL_STATIC_NONE otherwise.
+ */
+static gint32
+field_is_special_static (MonoClass *fklass, MonoClassField *field)
{
MonoCustomAttrInfo *ainfo;
int i;
@@ -333,13 +339,19 @@ field_is_thread_static (MonoClass *fklass, MonoClassField *field)
return FALSE;
for (i = 0; i < ainfo->num_attrs; ++i) {
MonoClass *klass = ainfo->attrs [i].ctor->klass;
- if (strcmp (klass->name, "ThreadStaticAttribute") == 0 && klass->image == mono_defaults.corlib) {
- mono_custom_attrs_free (ainfo);
- return TRUE;
+ if (klass->image == mono_defaults.corlib) {
+ if (strcmp (klass->name, "ThreadStaticAttribute") == 0) {
+ mono_custom_attrs_free (ainfo);
+ return SPECIAL_STATIC_THREAD;
+ }
+ else if (strcmp (klass->name, "ContextStaticAttribute") == 0) {
+ mono_custom_attrs_free (ainfo);
+ return SPECIAL_STATIC_CONTEXT;
+ }
}
}
mono_custom_attrs_free (ainfo);
- return FALSE;
+ return SPECIAL_STATIC_NONE;
}
/**
@@ -423,13 +435,14 @@ mono_class_vtable (MonoDomain *domain, MonoClass *class)
if (!(field->type->attrs & FIELD_ATTRIBUTE_STATIC))
continue;
if (!(field->type->attrs & FIELD_ATTRIBUTE_LITERAL)) {
- if (field_is_thread_static (class, field)) {
+ gint32 special_static = field_is_special_static (class, field);
+ if (special_static != SPECIAL_STATIC_NONE) {
guint32 size, align, offset;
size = mono_type_size (field->type, &align);
- offset = mono_threads_alloc_static_data (size, align);
- if (!domain->thread_static_fields)
- domain->thread_static_fields = g_hash_table_new (NULL, NULL);
- g_hash_table_insert (domain->thread_static_fields, field, GUINT_TO_POINTER (offset));
+ offset = mono_alloc_special_static_data (special_static, size, align);
+ if (!domain->special_static_fields)
+ domain->special_static_fields = g_hash_table_new (NULL, NULL);
+ g_hash_table_insert (domain->special_static_fields, field, GUINT_TO_POINTER (offset));
continue;
}
}
@@ -840,6 +853,77 @@ mono_field_get_value (MonoObject *obj, MonoClassField *field, void *value)
set_value (field->type, value, src, TRUE);
}
+MonoObject *
+mono_field_get_value_object (MonoDomain *domain, MonoClassField *field, MonoObject *obj)
+{
+ MonoObject *o;
+ MonoClass *klass;
+ MonoVTable *vtable;
+ gchar *v;
+ gboolean is_static = FALSE;
+ gboolean is_ref = FALSE;
+
+ switch (field->type->type) {
+ case MONO_TYPE_STRING:
+ case MONO_TYPE_OBJECT:
+ case MONO_TYPE_CLASS:
+ case MONO_TYPE_ARRAY:
+ case MONO_TYPE_SZARRAY:
+ is_ref = TRUE;
+ break;
+ case MONO_TYPE_U1:
+ case MONO_TYPE_I1:
+ case MONO_TYPE_BOOLEAN:
+ case MONO_TYPE_U2:
+ case MONO_TYPE_I2:
+ case MONO_TYPE_CHAR:
+ case MONO_TYPE_U:
+ case MONO_TYPE_I:
+ case MONO_TYPE_U4:
+ case MONO_TYPE_I4:
+ case MONO_TYPE_R4:
+ case MONO_TYPE_U8:
+ case MONO_TYPE_I8:
+ case MONO_TYPE_R8:
+ case MONO_TYPE_VALUETYPE:
+ is_ref = field->type->byref;
+ break;
+ default:
+ g_error ("type 0x%x not handled in "
+ "mono_field_get_value_object", field->type->type);
+ return NULL;
+ }
+
+ if (field->type->attrs & FIELD_ATTRIBUTE_STATIC) {
+ is_static = TRUE;
+ vtable = mono_class_vtable (domain, field->parent);
+ if (!vtable->initialized)
+ mono_runtime_class_init (vtable);
+ }
+
+ if (is_ref) {
+ if (is_static) {
+ mono_field_static_get_value (vtable, field, &o);
+ } else {
+ mono_field_get_value (obj, field, &o);
+ }
+ return o;
+ }
+
+ /* boxed value type */
+ klass = mono_class_from_mono_type (field->type);
+ o = mono_object_new (domain, klass);
+ v = ((gchar *) o) + sizeof (MonoObject);
+ if (is_static) {
+ mono_field_static_get_value (vtable, field, v);
+ } else {
+ mono_field_get_value (obj, field, v);
+ }
+
+ return o;
+}
+
+
void
mono_field_static_get_value (MonoVTable *vt, MonoClassField *field, void *value)
{
@@ -1209,8 +1293,7 @@ out_of_memory (size_t size)
* back to the system at this point if we're really low on memory (ie, size is
* lower than the memory we set apart)
*/
- MonoException * ex = mono_exception_from_name (mono_defaults.corlib, "System", "OutOfMemoryException");
- mono_raise_exception (ex);
+ mono_raise_exception (mono_domain_get ()->out_of_memory_ex);
}
/**
diff --git a/mono/metadata/object.h b/mono/metadata/object.h
index 17d0322c236..28c9da4aea3 100644
--- a/mono/metadata/object.h
+++ b/mono/metadata/object.h
@@ -471,6 +471,9 @@ mono_field_get_value (MonoObject *obj, MonoClassField *field, void *value);
void
mono_field_static_get_value (MonoVTable *vt, MonoClassField *field, void *value);
+MonoObject *
+mono_field_get_value_object (MonoDomain *domain, MonoClassField *field, MonoObject *obj);
+
void
mono_property_set_value (MonoProperty *prop, void *obj, void **params, MonoObject **exc);
diff --git a/mono/metadata/reflection.c b/mono/metadata/reflection.c
index 9a27e566888..2c965ccab32 100644
--- a/mono/metadata/reflection.c
+++ b/mono/metadata/reflection.c
@@ -50,7 +50,13 @@ typedef struct {
MonoObject *type;
MonoString *name;
MonoBoolean init_locals;
+ MonoArray *return_modreq;
+ MonoArray *return_modopt;
+ MonoArray *param_modreq;
+ MonoArray *param_modopt;
MonoMethod *mhandle;
+ guint32 nrefs;
+ gpointer *refs;
} ReflectionMethodBuilder;
const unsigned char table_sizes [64] = {
@@ -130,6 +136,7 @@ static void mono_image_get_generic_param_info (MonoReflectionGenericParam *gp
static guint32 encode_marshal_blob (MonoDynamicImage *assembly, MonoReflectionMarshal *minfo);
static char* type_get_qualified_name (MonoType *type, MonoAssembly *ass);
static void ensure_runtime_vtable (MonoClass *klass);
+static gpointer resolve_object (MonoImage *image, MonoObject *obj);
static void
alloc_table (MonoDynamicTable *table, guint nrows)
@@ -418,6 +425,30 @@ encode_reflection_type (MonoDynamicImage *assembly, MonoReflectionType *type, ch
}
+static void
+encode_custom_modifiers (MonoDynamicImage *assembly, MonoArray *modreq, MonoArray *modopt, char *p, char **endbuf)
+{
+ int i;
+
+ if (modreq) {
+ for (i = 0; i < mono_array_length (modreq); ++i) {
+ MonoReflectionType *mod = mono_array_get (modreq, MonoReflectionType*, i);
+ *p = MONO_TYPE_CMOD_REQD;
+ p++;
+ mono_metadata_encode_value (mono_image_typedef_or_ref (assembly, mod->type), p, &p);
+ }
+ }
+ if (modopt) {
+ for (i = 0; i < mono_array_length (modopt); ++i) {
+ MonoReflectionType *mod = mono_array_get (modopt, MonoReflectionType*, i);
+ *p = MONO_TYPE_CMOD_OPT;
+ p++;
+ mono_metadata_encode_value (mono_image_typedef_or_ref (assembly, mod->type), p, &p);
+ }
+ }
+ *endbuf = p;
+}
+
static guint32
method_encode_signature (MonoDynamicImage *assembly, MonoMethodSignature *sig)
{
@@ -468,7 +499,7 @@ method_builder_encode_signature (MonoDynamicImage *assembly, ReflectionMethodBui
int i;
guint32 nparams = mb->parameters ? mono_array_length (mb->parameters): 0;
guint32 ngparams = mb->generic_params ? mono_array_length (mb->generic_params): 0;
- guint32 size = 11 + nparams * 10;
+ guint32 size = 21 + nparams * 20;
guint32 idx;
char blob_size [6];
char *b = blob_size;
@@ -486,9 +517,19 @@ method_builder_encode_signature (MonoDynamicImage *assembly, ReflectionMethodBui
if (ngparams)
mono_metadata_encode_value (ngparams, p, &p);
mono_metadata_encode_value (nparams, p, &p);
+ encode_custom_modifiers (assembly, mb->return_modreq, mb->return_modopt, p, &p);
encode_reflection_type (assembly, mb->rtype, p, &p);
for (i = 0; i < nparams; ++i) {
- MonoReflectionType *pt = mono_array_get (mb->parameters, MonoReflectionType*, i);
+ MonoArray *modreq = NULL;
+ MonoArray *modopt = NULL;
+ MonoReflectionType *pt;
+
+ if (mb->param_modreq && (i < mono_array_length (mb->param_modreq)))
+ modreq = mono_array_get (mb->param_modreq, MonoArray*, i);
+ if (mb->param_modopt && (i < mono_array_length (mb->param_modopt)))
+ modopt = mono_array_get (mb->param_modopt, MonoArray*, i);
+ encode_custom_modifiers (assembly, modreq, modopt, p, &p);
+ pt = mono_array_get (mb->parameters, MonoReflectionType*, i);
encode_reflection_type (assembly, pt, p, &p);
}
/* store length */
@@ -945,7 +986,13 @@ reflection_methodbuilder_from_method_builder (ReflectionMethodBuilder *rmb,
rmb->name = mb->name;
rmb->table_idx = &mb->table_idx;
rmb->init_locals = mb->init_locals;
+ rmb->return_modreq = mb->return_modreq;
+ rmb->return_modopt = mb->return_modopt;
+ rmb->param_modreq = mb->param_modreq;
+ rmb->param_modopt = mb->param_modopt;
rmb->mhandle = mb->mhandle;
+ rmb->nrefs = 0;
+ rmb->refs = NULL;
}
static void
@@ -967,10 +1014,42 @@ reflection_methodbuilder_from_ctor_builder (ReflectionMethodBuilder *rmb,
rmb->name = mono_string_new (mono_domain_get (), name);
rmb->table_idx = &mb->table_idx;
rmb->init_locals = mb->init_locals;
+ rmb->return_modreq = NULL;
+ rmb->return_modopt = NULL;
+ rmb->param_modreq = mb->param_modreq;
+ rmb->param_modopt = mb->param_modopt;
rmb->mhandle = mb->mhandle;
+ rmb->nrefs = 0;
+ rmb->refs = NULL;
}
static void
+reflection_methodbuilder_from_dynamic_method (ReflectionMethodBuilder *rmb,
+ MonoReflectionDynamicMethod *mb)
+{
+ rmb->ilgen = mb->ilgen;
+ rmb->rtype = mb->rtype;
+ rmb->parameters = mb->parameters;
+ rmb->generic_params = NULL;
+ rmb->pinfo = NULL;
+ rmb->attrs = mb->attrs;
+ rmb->iattrs = 0;
+ rmb->call_conv = mb->call_conv;
+ rmb->code = NULL;
+ rmb->type = NULL;
+ rmb->name = mb->name;
+ rmb->table_idx = NULL;
+ rmb->init_locals = mb->init_locals;
+ rmb->return_modreq = NULL;
+ rmb->return_modopt = NULL;
+ rmb->param_modreq = NULL;
+ rmb->param_modopt = NULL;
+ rmb->mhandle = mb->mhandle;
+ rmb->nrefs = 0;
+ rmb->refs = NULL;
+}
+
+static void
mono_image_get_method_info (MonoReflectionMethodBuilder *mb, MonoDynamicImage *assembly)
{
MonoDynamicTable *table;
@@ -1093,6 +1172,7 @@ field_encode_signature (MonoDynamicImage *assembly, MonoReflectionFieldBuilder *
p = buf = g_malloc (64);
mono_metadata_encode_value (0x06, p, &p);
+ encode_custom_modifiers (assembly, fb->modreq, fb->modopt, p, &p);
/* encode custom attributes before the type */
encode_reflection_type (assembly, fb->type, p, &p);
g_assert (p-buf < 64);
@@ -1593,13 +1673,6 @@ resolution_scope_from_image (MonoDynamicImage *assembly, MonoImage *image)
return token;
if (image->assembly->dynamic && (image->assembly == assembly->image.assembly)) {
- table = &assembly->tables [MONO_TABLE_FILE];
- table->rows++;
- alloc_table (table, table->rows);
- values = table->values + table->next_idx * MONO_FILE_SIZE;
- values [MONO_FILE_FLAGS] = FILE_CONTAINS_METADATA;
- values [MONO_FILE_NAME] = string_heap_insert (&assembly->sheap, image->module_name);
-
table = &assembly->tables [MONO_TABLE_MODULEREF];
token = table->next_idx ++;
table->rows ++;
@@ -1617,8 +1690,11 @@ resolution_scope_from_image (MonoDynamicImage *assembly, MonoImage *image)
if (image->assembly->dynamic)
/* FIXME: */
memset (cols, 0, sizeof (cols));
- else
+ else {
+ /* image->assembly->image is the manifest module */
+ image = image->assembly->image;
mono_metadata_decode_row (&image->tables [MONO_TABLE_ASSEMBLY], 0, cols, MONO_ASSEMBLY_SIZE);
+ }
table = &assembly->tables [MONO_TABLE_ASSEMBLYREF];
token = table->next_idx ++;
@@ -1875,7 +1951,6 @@ mono_image_get_methodbuilder_token (MonoDynamicImage *assembly, MonoReflectionMe
return token;
reflection_methodbuilder_from_method_builder (&rmb, mb);
-
token = mono_image_get_memberref_token (assembly, ((MonoReflectionTypeBuilder*)rmb.type)->type.type,
mono_string_to_utf8 (rmb.name),
@@ -2532,6 +2607,35 @@ module_add_cattrs (MonoDynamicImage *assembly, MonoReflectionModuleBuilder *mb)
}
static void
+mono_image_fill_file_table (MonoDomain *domain, MonoReflectionModuleBuilder *mb,
+ MonoDynamicImage *assembly)
+{
+ MonoDynamicTable *table;
+ guint32 *values;
+ char blob_size [6];
+ guchar hash [20];
+ char *b = blob_size;
+ char *dir, *path;
+
+ table = &assembly->tables [MONO_TABLE_FILE];
+ table->rows++;
+ alloc_table (table, table->rows);
+ values = table->values + table->next_idx * MONO_FILE_SIZE;
+ values [MONO_FILE_FLAGS] = FILE_CONTAINS_METADATA;
+ values [MONO_FILE_NAME] = string_heap_insert (&assembly->sheap, mb->dynamic_image->image.module_name);
+ /* This depends on the fact that the main module is emitted last */
+ dir = mono_string_to_utf8 (mb->assemblyb->dir);
+ path = g_strdup_printf ("%s%c%s", dir, G_DIR_SEPARATOR, mb->dynamic_image->image.module_name);
+ mono_sha1_get_digest_from_file (path, hash);
+ g_free (dir);
+ g_free (path);
+ mono_metadata_encode_value (20, b, &b);
+ values [MONO_FILE_HASH_VALUE] = mono_image_add_stream_data (&assembly->blob, blob_size, b-blob_size);
+ mono_image_add_stream_data (&assembly->blob, hash, 20);
+ table->next_idx ++;
+}
+
+static void
mono_image_fill_module_table (MonoDomain *domain, MonoReflectionModuleBuilder *mb, MonoDynamicImage *assembly)
{
MonoDynamicTable *table;
@@ -2551,6 +2655,54 @@ mono_image_fill_module_table (MonoDomain *domain, MonoReflectionModuleBuilder *m
table->values [mb->table_idx * MONO_MODULE_SIZE + MONO_MODULE_ENCBASE] = 0;
}
+static void
+mono_image_fill_export_table (MonoDomain *domain, MonoReflectionTypeBuilder *tb,
+ guint32 module_index, guint32 parent_index,
+ MonoDynamicImage *assembly)
+{
+ MonoDynamicTable *table;
+ guint32 *values;
+ guint32 visib;
+ char *name;
+ char *name_space;
+ int i;
+
+ visib = tb->attrs & TYPE_ATTRIBUTE_VISIBILITY_MASK;
+ if (! ((visib & TYPE_ATTRIBUTE_PUBLIC) || (visib & TYPE_ATTRIBUTE_NESTED_PUBLIC)))
+ return;
+
+ name = mono_string_to_utf8 (tb->name);
+ name_space = mono_string_to_utf8 (tb->nspace);
+
+ table = &assembly->tables [MONO_TABLE_EXPORTEDTYPE];
+ table->rows++;
+ alloc_table (table, table->rows);
+ values = table->values + table->next_idx * MONO_EXP_TYPE_SIZE;
+
+ values [MONO_EXP_TYPE_FLAGS] = tb->attrs;
+ values [MONO_EXP_TYPE_TYPEDEF] = mono_metadata_make_token (MONO_TABLE_TYPEDEF, tb->table_idx);
+ if (tb->nesting_type) {
+ values [MONO_EXP_TYPE_IMPLEMENTATION] = (parent_index << IMPLEMENTATION_BITS) + IMPLEMENTATION_EXP_TYPE;
+ }
+ else {
+ values [MONO_EXP_TYPE_TYPEDEF] = mono_metadata_make_token (MONO_TABLE_TYPEDEF, tb->table_idx);
+ values [MONO_EXP_TYPE_IMPLEMENTATION] = (module_index << IMPLEMENTATION_BITS) + IMPLEMENTATION_FILE;
+ }
+ values [MONO_EXP_TYPE_NAME] = string_heap_insert (&assembly->sheap, name);
+ values [MONO_EXP_TYPE_NAMESPACE] = string_heap_insert (&assembly->sheap, name_space);
+
+ g_free (name);
+ g_free (name_space);
+
+ table->next_idx ++;
+
+ /* Emit nested types */
+ if (tb->subtypes) {
+ for (i = 0; i < mono_array_length (tb->subtypes); ++i)
+ mono_image_fill_export_table (domain, mono_array_get (tb->subtypes, MonoReflectionTypeBuilder*, i), module_index, table->next_idx - 1, assembly);
+ }
+}
+
#define align_pointer(base,p)\
do {\
guint32 __diff = (unsigned char*)(p)-(unsigned char*)(base);\
@@ -2838,7 +2990,8 @@ fixup_method (MonoReflectionILGen *ilgen, gpointer value, MonoDynamicImage *asse
} else if (!strcmp (iltoken->member->vtable->klass->name, "ConstructorBuilder")) {
ctor = (MonoReflectionCtorBuilder *)iltoken->member;
idx = ctor->table_idx;
- } else if (!strcmp (iltoken->member->vtable->klass->name, "MonoMethod")) {
+ } else if (!strcmp (iltoken->member->vtable->klass->name, "MonoMethod") ||
+ !strcmp (iltoken->member->vtable->klass->name, "MonoCMethod")) {
MonoMethod *m = ((MonoReflectionMethod*)iltoken->member)->method;
idx = GPOINTER_TO_UINT (mono_g_hash_table_lookup (assembly->method_to_table_idx, m));
} else {
@@ -3012,6 +3165,7 @@ mono_image_build_metadata (MonoReflectionModuleBuilder *moduleb)
guint32 *values;
char *name;
int i;
+ guint32 module_index;
assemblyb = moduleb->assemblyb;
assembly = moduleb->dynamic_image;
@@ -3041,6 +3195,25 @@ mono_image_build_metadata (MonoReflectionModuleBuilder *moduleb)
values [MONO_ASSEMBLY_PUBLIC_KEY] = load_public_key (assemblyb->public_key, assembly);
values [MONO_ASSEMBLY_FLAGS] = assemblyb->flags;
set_version_from_string (assemblyb->version, values);
+
+ /* Emit FILE + EXPORTED_TYPE table */
+ module_index = 0;
+ for (i = 0; i < mono_array_length (assemblyb->modules); ++i) {
+ int j;
+ MonoReflectionModuleBuilder *file_module =
+ mono_array_get (assemblyb->modules, MonoReflectionModuleBuilder*, i);
+ if (file_module != moduleb) {
+ mono_image_fill_file_table (domain, file_module, assembly);
+ module_index ++;
+ if (file_module->types) {
+ for (j = 0; j < mono_array_length (file_module->types); ++j) {
+ MonoReflectionTypeBuilder *tb = mono_array_get (file_module->types, MonoReflectionTypeBuilder*, j);
+ mono_image_fill_export_table (domain, tb, module_index, 0,
+ assembly);
+ }
+ }
+ }
+ }
}
table = &assembly->tables [MONO_TABLE_TYPEDEF];
@@ -4204,7 +4377,7 @@ assembly_name_to_aname (MonoAssemblyName *assembly, char *p) {
assembly->name = p;
assembly->culture = "";
- while (*p && (isalnum (*p) || *p == '.' || *p == '-'))
+ while (*p && (isalnum (*p) || *p == '.' || *p == '-' || *p == '_' || *p == '$' || *p == '@'))
p++;
found_sep = 0;
while (*p == ' ' || *p == ',') {
@@ -5211,6 +5384,17 @@ method_builder_to_signature (MonoReflectionMethodBuilder *method) {
return sig;
}
+static MonoMethodSignature*
+dynamic_method_to_signature (MonoReflectionDynamicMethod *method) {
+ MonoMethodSignature *sig;
+
+ sig = parameters_to_signature (method->parameters);
+ sig->hasthis = method->attrs & METHOD_ATTRIBUTE_STATIC? 0: 1;
+ sig->ret = method->rtype? method->rtype->type: &mono_defaults.void_class->byval_arg;
+ sig->generic_param_count = 0;
+ return sig;
+}
+
static void
get_prop_name_and_type (MonoObject *prop, char **name, MonoType **type)
{
@@ -5780,6 +5964,9 @@ reflection_methodbuilder_to_mono_method (MonoClass *klass,
(rmb->iattrs & METHOD_IMPL_ATTRIBUTE_INTERNAL_CALL))
m = (MonoMethod *)g_new0 (MonoMethodPInvoke, 1);
else
+ if (rmb->refs)
+ m = (MonoMethod *)g_new0 (MonoMethodWrapper, 1);
+ else
m = (MonoMethod *)g_new0 (MonoMethodNormal, 1);
pm = (MonoMethodNormal*)m;
@@ -5790,7 +5977,8 @@ reflection_methodbuilder_to_mono_method (MonoClass *klass,
m->name = mono_string_to_utf8 (rmb->name);
m->klass = klass;
m->signature = sig;
- m->token = MONO_TOKEN_METHOD_DEF | (*rmb->table_idx);
+ if (rmb->table_idx)
+ m->token = MONO_TOKEN_METHOD_DEF | (*rmb->table_idx);
if (m->iflags & METHOD_IMPL_ATTRIBUTE_INTERNAL_CALL) {
if (klass == mono_defaults.string_class && !strcmp (m->name, ".ctor"))
@@ -5860,10 +6048,22 @@ reflection_methodbuilder_to_mono_method (MonoClass *klass,
pm->header = header;
}
- method_aux = g_new0 (MonoReflectionMethodAux, 1);
+ if (rmb->refs) {
+ MonoMethodWrapper *mw = (MonoMethodWrapper*)m;
+ int i;
+
+ m->wrapper_type = MONO_WRAPPER_DYNAMIC_METHOD;
+
+ for (i = 0; i < rmb->nrefs; ++i)
+ mw->data = g_list_append (mw->data, rmb->refs [i]);
+ }
+
+ method_aux = NULL;
/* Parameter names */
if (rmb->parameters) {
+ if (!method_aux)
+ method_aux = g_new0 (MonoReflectionMethodAux, 1);
method_aux->param_names = g_new0 (char *, m->signature->param_count);
for (i = 0; i < m->signature->param_count; ++i) {
MonoReflectionParamBuilder *pb;
@@ -5888,10 +6088,14 @@ reflection_methodbuilder_to_mono_method (MonoClass *klass,
}
}
}
- if (specs != NULL)
+ if (specs != NULL) {
+ if (!method_aux)
+ method_aux = g_new0 (MonoReflectionMethodAux, 1);
method_aux->param_marshall = specs;
+ }
- mono_g_hash_table_insert (((MonoDynamicImage*)klass->image)->method_aux_hash, m, method_aux);
+ if (klass->image->assembly->dynamic && method_aux)
+ mono_g_hash_table_insert (((MonoDynamicImage*)klass->image)->method_aux_hash, m, method_aux);
return m;
}
@@ -6013,15 +6217,20 @@ MonoReflectionGenericInst*
mono_reflection_bind_generic_parameters (MonoReflectionType *type, MonoArray *types)
{
static MonoClass *System_Reflection_MonoGenericInst;
+ MonoDomain *domain;
MonoType *geninst;
MonoGenericInst *ginst;
- MonoClass *klass, *iklass;
- MonoReflectionTypeBuilder *tb = NULL;
+ MonoArray *ifaces = NULL;
+ MonoReflectionType *ptype = NULL;
+ MonoClass *klass, *iklass, *pklass = NULL;
MonoReflectionGenericInst *res, *parent = NULL;
+ MonoReflectionTypeBuilder *tb = NULL;
int i;
+ domain = mono_object_domain (type);
+
klass = mono_class_from_mono_type (type->type);
- if (klass->num_gen_params != mono_array_length (types))
+ if (!klass->gen_params && !klass->generic_inst)
return NULL;
if (!System_Reflection_MonoGenericInst) {
@@ -6033,32 +6242,94 @@ mono_reflection_bind_generic_parameters (MonoReflectionType *type, MonoArray *ty
if (klass->wastypebuilder && klass->reflection_info) {
tb = klass->reflection_info;
- if (tb->parent)
- parent = mono_reflection_bind_generic_parameters (tb->parent, types);
+ ptype = tb->parent;
+ if (ptype)
+ pklass = mono_class_from_mono_type (ptype->type);
+ } else {
+ pklass = klass->parent;
+ if (pklass)
+ ptype = mono_type_get_object (domain, &pklass->byval_arg);
+ }
+
+ if (pklass && pklass->generic_inst)
+ parent = mono_reflection_bind_generic_parameters (ptype, types);
+ else if (!pklass) {
+ int icount;
+
+ pklass = mono_defaults.object_class;
+
+ icount = klass->interface_count;
+ ifaces = mono_array_new (domain, System_Reflection_MonoGenericInst, icount);
+
+ for (i = 0; i < icount; i++) {
+ MonoReflectionGenericInst *iface;
+ MonoReflectionType *itype;
+
+ if (tb)
+ itype = mono_array_get (tb->interfaces, gpointer, i);
+ else
+ itype = mono_type_get_object (domain, &klass->interfaces [i]->byval_arg);
+ iface = mono_reflection_bind_generic_parameters (itype, types);
+
+ mono_array_set (ifaces, gpointer, i, iface);
+ }
}
geninst = g_new0 (MonoType, 1);
geninst->type = MONO_TYPE_GENERICINST;
geninst->data.generic_inst = ginst = g_new0 (MonoGenericInst, 1);
- ginst->generic_type = &klass->byval_arg;
- ginst->type_argc = klass->num_gen_params;
- ginst->type_argv = g_new0 (MonoType *, klass->num_gen_params);
- for (i = 0; i < klass->num_gen_params; ++i) {
- MonoReflectionType *garg = mono_array_get (types, gpointer, i);
- ginst->type_argv [i] = garg->type;
+
+ if (klass->gen_params) {
+ ginst->type_argc = mono_array_length (types);
+ ginst->type_argv = g_new0 (MonoType *, ginst->type_argc);
+
+ for (i = 0; i < ginst->type_argc; ++i) {
+ MonoReflectionType *garg = mono_array_get (types, gpointer, i);
+
+ ginst->type_argv [i] = garg->type;
+
+ if (!ginst->is_open)
+ ginst->is_open = mono_class_is_open_constructed_type (garg->type);
+ }
+
+ ginst->generic_type = &klass->byval_arg;
+ } else {
+ MonoGenericInst *kginst = klass->generic_inst->data.generic_inst;
+
+ ginst->type_argc = kginst->type_argc;
+ ginst->type_argv = g_new0 (MonoType *, ginst->type_argc);
+
+ for (i = 0; i < ginst->type_argc; i++) {
+ MonoType *t = kginst->type_argv [i];
+
+ if (t->type == MONO_TYPE_VAR) {
+ int num = t->data.generic_param->num;
+ MonoReflectionType *garg = mono_array_get (types, gpointer, num);
+
+ t = garg->type;
+ }
+
+ if (!ginst->is_open)
+ ginst->is_open = mono_class_is_open_constructed_type (t);
+
+ ginst->type_argv [i] = t;
+ }
+
+ ginst->generic_type = kginst->generic_type;
}
iklass = mono_class_from_generic (geninst, FALSE);
- mono_class_setup_parent (iklass, parent ? parent->klass : mono_defaults.object_class);
+ mono_class_setup_parent (iklass, parent ? parent->klass : pklass);
mono_class_setup_mono_type (iklass);
- res = (MonoReflectionGenericInst *)mono_object_new (mono_object_domain (type), System_Reflection_MonoGenericInst);
+ res = (MonoReflectionGenericInst *)mono_object_new (domain, System_Reflection_MonoGenericInst);
res->type.type = iklass->generic_inst;
res->klass = iklass;
res->parent = parent;
res->generic_type = type;
+ res->interfaces = ifaces;
return res;
}
@@ -6124,6 +6395,9 @@ mono_reflection_inflate_method_or_ctor (MonoReflectionGenericInst *declaring_typ
else if (!strcmp (obj->vtable->klass->name, "MonoMethod") ||
!strcmp (obj->vtable->klass->name, "MonoCMethod"))
method = ((MonoReflectionMethod *) obj)->method;
+ else if (!strcmp (obj->vtable->klass->name, "MonoInflatedMethod") ||
+ !strcmp (obj->vtable->klass->name, "MonoInflatedCtor"))
+ method = ((MonoReflectionInflatedMethod *) obj)->rmethod.method;
else
g_assert_not_reached ();
@@ -6132,10 +6406,14 @@ mono_reflection_inflate_method_or_ctor (MonoReflectionGenericInst *declaring_typ
ginst->generic_type = reflected_type->type.type;
ginst->type_argc = type_ginst->type_argc;
ginst->type_argv = type_ginst->type_argv;
+ ginst->is_open = type_ginst->is_open;
ginst->klass = mono_class_from_generic (ginst->generic_type, FALSE);
- inflated = mono_class_inflate_generic_method (method, ginst);
+ if (type_ginst->is_open)
+ inflated = method;
+ else
+ inflated = mono_class_inflate_generic_method (method, ginst);
res = inflated_method_get_object (
mono_object_domain (reflected_type), inflated, (MonoReflectionMethod *) obj, ginst);
@@ -6530,6 +6808,42 @@ mono_reflection_sighelper_get_signature_field (MonoReflectionSigHelper *sig)
return result;
}
+void
+mono_reflection_create_dynamic_method (MonoReflectionDynamicMethod *mb)
+{
+ ReflectionMethodBuilder rmb;
+ MonoMethodSignature *sig;
+ int i;
+
+ sig = dynamic_method_to_signature (mb);
+
+ reflection_methodbuilder_from_dynamic_method (&rmb, mb);
+
+ /*
+ * Resolve references.
+ */
+ rmb.nrefs = mb->nrefs;
+ rmb.refs = g_new0 (gpointer, mb->nrefs + 1);
+ for (i = 0; i < mb->nrefs; ++i) {
+ gpointer ref = resolve_object (mb->module->image,
+ mono_array_get (mb->refs, MonoObject*, i));
+ if (!ref) {
+ g_free (rmb.refs);
+ mono_raise_exception (mono_get_exception_type_load (NULL));
+ return;
+ }
+ rmb.refs [i] = ref;
+ }
+
+ /* FIXME: class */
+ mb->mhandle = reflection_methodbuilder_to_mono_method (mono_defaults.object_class, &rmb, sig);
+
+ g_free (rmb.refs);
+
+ /* ilgen is no longer needed */
+ mb->ilgen = NULL;
+}
+
/**
* mono_reflection_lookup_dynamic_token:
*
@@ -6541,11 +6855,18 @@ mono_reflection_lookup_dynamic_token (MonoImage *image, guint32 token)
{
MonoDynamicImage *assembly = (MonoDynamicImage*)image;
MonoObject *obj;
- gpointer result;
obj = mono_g_hash_table_lookup (assembly->tokens, GUINT_TO_POINTER (token));
g_assert (obj);
+ return resolve_object (image, obj);
+}
+
+static gpointer
+resolve_object (MonoImage *image, MonoObject *obj)
+{
+ gpointer result;
+
if (strcmp (obj->vtable->klass->name, "String") == 0) {
result = mono_string_intern ((MonoString*)obj);
g_assert (result);
@@ -6662,8 +6983,3 @@ mono_reflection_lookup_dynamic_token (MonoImage *image, guint32 token)
}
return result;
}
-
-
-
-
-
diff --git a/mono/metadata/reflection.h b/mono/metadata/reflection.h
index 7affb8ffb04..724736769e2 100644
--- a/mono/metadata/reflection.h
+++ b/mono/metadata/reflection.h
@@ -99,6 +99,7 @@ typedef struct {
MonoReflectionType *ret;
guint32 attrs;
guint32 implattrs;
+ guint32 callconv;
} MonoMethodInfo;
typedef struct {
@@ -136,7 +137,6 @@ typedef struct {
typedef struct {
MonoObject object;
MonoArray *code;
- MonoObject *mbuilder;
gint32 code_len;
gint32 max_stack;
gint32 cur_stack;
@@ -202,6 +202,8 @@ typedef struct {
MonoArray *pinfo;
MonoArray *cattrs;
MonoBoolean init_locals;
+ MonoArray *param_modreq;
+ MonoArray *param_modopt;
} MonoReflectionCtorBuilder;
typedef struct {
@@ -226,6 +228,10 @@ typedef struct {
guint32 call_conv;
MonoBoolean init_locals;
MonoArray *generic_params;
+ MonoArray *return_modreq;
+ MonoArray *return_modopt;
+ MonoArray *param_modreq;
+ MonoArray *param_modopt;
} MonoReflectionMethodBuilder;
typedef struct {
@@ -344,6 +350,8 @@ typedef struct {
MonoArray *cattrs;
MonoReflectionMarshal *marshal_info;
MonoClassField *handle;
+ MonoArray *modreq;
+ MonoArray *modopt;
} MonoReflectionFieldBuilder;
typedef struct {
@@ -419,6 +427,7 @@ struct _MonoReflectionGenericInst {
MonoClass *klass;
MonoReflectionGenericInst *parent;
MonoReflectionType *generic_type;
+ MonoArray *interfaces;
MonoArray *methods;
MonoArray *ctors;
MonoArray *fields;
@@ -451,7 +460,7 @@ typedef struct {
StrongNameKeyPair keypair;
AssemblyVersionCompatibility versioncompat;*/
MonoObject *cultureInfo;
- MonoObject *flags;
+ guint32 flags;
guint32 hashalg;
MonoObject *keypair;
MonoArray *publicKey;
@@ -479,6 +488,22 @@ typedef struct {
MonoArray *data;
} MonoReflectionCustomAttr;
+typedef struct {
+ MonoObject object;
+ MonoMethod *mhandle;
+ MonoString *name;
+ MonoReflectionType *rtype;
+ MonoArray *parameters;
+ guint32 attrs;
+ guint32 call_conv;
+ MonoReflectionModule *module;
+ MonoBoolean skip_visibility;
+ MonoBoolean init_locals;
+ MonoReflectionILGen *ilgen;
+ gint32 nrefs;
+ MonoArray *refs;
+} MonoReflectionDynamicMethod;
+
typedef struct MonoTypeNameParse MonoTypeNameParse;
struct MonoTypeNameParse {
@@ -567,6 +592,8 @@ void mono_reflection_setup_generic_class (MonoReflectionTypeBuilder *tb
MonoReflectionType* mono_reflection_create_runtime_class (MonoReflectionTypeBuilder *tb);
+void mono_reflection_create_dynamic_method (MonoReflectionDynamicMethod *m);
+
MonoReflectionType *mono_reflection_define_generic_parameter (MonoReflectionTypeBuilder *tb, MonoReflectionMethodBuilder *mb, guint32 index, MonoReflectionGenericParam *gparam);
MonoReflectionGenericInst*
diff --git a/mono/metadata/threads.c b/mono/metadata/threads.c
index 23d7e102e80..510e1467713 100644
--- a/mono/metadata/threads.c
+++ b/mono/metadata/threads.c
@@ -42,6 +42,11 @@ typedef union {
gfloat fval;
} IntFloatUnion;
+typedef struct {
+ int idx;
+ int offset;
+} StaticDataInfo;
+
/*
* The "os_handle" field of the WaitHandle class.
*/
@@ -50,6 +55,13 @@ static MonoClassField *wait_handle_os_handle_field = NULL;
/* Controls access to the 'threads' hash table */
static CRITICAL_SECTION threads_mutex;
+/* Controls access to context static data */
+static CRITICAL_SECTION contexts_mutex;
+
+/* Holds current status of static data heap */
+static StaticDataInfo thread_static_info;
+static StaticDataInfo context_static_info;
+
/* The hash of existing threads (key is thread ID) that need joining
* before exit
*/
@@ -77,6 +89,8 @@ static guint32 slothash_key = -1;
static guint32 default_stacksize = 0;
static void thread_adjust_static_data (MonoThread *thread);
+static void mono_init_static_data_info (StaticDataInfo *static_data);
+static guint32 mono_alloc_static_data_slot (StaticDataInfo *static_data, guint32 size, guint32 align);
/* Spin lock for InterlockedXXX 64 bit functions */
static CRITICAL_SECTION interlocked_mutex;
@@ -930,12 +944,76 @@ ves_icall_System_Threading_Thread_ResetAbort (void)
}
}
+gint8
+ves_icall_System_Threading_Thread_VolatileRead1 (void *ptr)
+{
+ return *((volatile gint8 *) (ptr));
+}
+
+gint16
+ves_icall_System_Threading_Thread_VolatileRead2 (void *ptr)
+{
+ return *((volatile gint16 *) (ptr));
+}
+
+gint32
+ves_icall_System_Threading_Thread_VolatileRead4 (void *ptr)
+{
+ return *((volatile gint32 *) (ptr));
+}
+
+gint64
+ves_icall_System_Threading_Thread_VolatileRead8 (void *ptr)
+{
+ return *((volatile gint64 *) (ptr));
+}
+
+void *
+ves_icall_System_Threading_Thread_VolatileReadIntPtr (void *ptr)
+{
+ return (void *) *((volatile void **) ptr);
+}
+
+void
+ves_icall_System_Threading_Thread_VolatileWrite1 (void *ptr, gint8 value)
+{
+ *((volatile gint8 *) ptr) = value;
+}
+
+void
+ves_icall_System_Threading_Thread_VolatileWrite2 (void *ptr, gint16 value)
+{
+ *((volatile gint16 *) ptr) = value;
+}
+
+void
+ves_icall_System_Threading_Thread_VolatileWrite4 (void *ptr, gint32 value)
+{
+ *((volatile gint32 *) ptr) = value;
+}
+
+void
+ves_icall_System_Threading_Thread_VolatileWrite8 (void *ptr, gint64 value)
+{
+ *((volatile gint64 *) ptr) = value;
+}
+
+void
+ves_icall_System_Threading_Thread_VolatileWriteIntPtr (void *ptr, void *value)
+{
+ *((volatile void **) ptr) = value;
+}
+
void mono_thread_init (MonoThreadStartCB start_cb,
MonoThreadAttachCB attach_cb)
{
InitializeCriticalSection(&threads_mutex);
InitializeCriticalSection(&interlocked_mutex);
+ InitializeCriticalSection(&contexts_mutex);
+ mono_init_static_data_info (&thread_static_info);
+ mono_init_static_data_info (&context_static_info);
+
current_object_key=TlsAlloc();
#ifdef THREAD_DEBUG
g_message (G_GNUC_PRETTY_FUNCTION ": Allocated current_object_key %d",
@@ -1249,37 +1327,94 @@ mono_thread_get_pending_exception (void)
return NULL;
}
-static int static_data_idx = 0;
-static int static_data_offset = 0;
#define NUM_STATIC_DATA_IDX 8
static const int static_data_size [NUM_STATIC_DATA_IDX] = {
1024, 4096, 16384, 65536, 262144, 1048576, 4194304, 16777216
};
+
+/*
+ * mono_alloc_static_data
+ *
+ * Allocate memory blocks for storing threads or context static data
+ */
static void
-thread_alloc_static_data (MonoThread *thread, guint32 offset)
+mono_alloc_static_data (gpointer **static_data_ptr, guint32 offset)
{
guint idx = (offset >> 24) - 1;
int i;
- if (!thread->static_data) {
+ gpointer* static_data = *static_data_ptr;
+ if (!static_data) {
#if HAVE_BOEHM_GC
- thread->static_data = GC_MALLOC (static_data_size [0]);
+ static_data = GC_MALLOC (static_data_size [0]);
#else
- thread->static_data = g_malloc0 (static_data_size [0]);
+ static_data = g_malloc0 (static_data_size [0]);
#endif
- thread->static_data [0] = thread->static_data;
+ *static_data_ptr = static_data;
+ static_data [0] = static_data;
}
+
for (i = 1; i < idx; ++i) {
- if (thread->static_data [i])
+ if (static_data [i])
continue;
#if HAVE_BOEHM_GC
- thread->static_data [i] = GC_MALLOC (static_data_size [i]);
+ static_data [i] = GC_MALLOC (static_data_size [i]);
#else
- thread->static_data [i] = g_malloc0 (static_data_size [i]);
+ static_data [i] = g_malloc0 (static_data_size [i]);
#endif
}
-
+}
+
+/*
+ * mono_init_static_data_info
+ *
+ * Initializes static data counters
+ */
+static void mono_init_static_data_info (StaticDataInfo *static_data)
+{
+ static_data->idx = 0;
+ static_data->offset = 0;
+}
+
+/*
+ * mono_alloc_static_data_slot
+ *
+ * Generates an offset for static data. static_data contains the counters
+ * used to generate it.
+ */
+static guint32
+mono_alloc_static_data_slot (StaticDataInfo *static_data, guint32 size, guint32 align)
+{
+ guint32 offset;
+
+ if (!static_data->idx && !static_data->offset) {
+ /*
+ * we use the first chunk of the first allocation also as
+ * an array for the rest of the data
+ */
+ static_data->offset = sizeof (gpointer) * NUM_STATIC_DATA_IDX;
+ }
+ static_data->offset += align - 1;
+ static_data->offset &= ~(align - 1);
+ if (static_data->offset + size >= static_data_size [static_data->idx]) {
+ static_data->idx ++;
+ g_assert (size <= static_data_size [static_data->idx]);
+ /*
+ * massive unloading and reloading of domains with thread-static
+ * data may eventually exceed the allocated storage...
+ * Need to check what the MS runtime does in that case.
+ * Note that for each appdomain, we need to allocate a separate
+ * thread data slot for security reasons. We could keep track
+ * of the slots per-domain and when the domain is unloaded
+ * out the slots on a sort of free list.
+ */
+ g_assert (static_data->idx < NUM_STATIC_DATA_IDX);
+ static_data->offset = 0;
+ }
+ offset = static_data->offset | ((static_data->idx + 1) << 24);
+ static_data->offset += size;
+ return offset;
}
/*
@@ -1292,10 +1427,10 @@ thread_adjust_static_data (MonoThread *thread)
guint32 offset;
EnterCriticalSection (&threads_mutex);
- if (static_data_offset || static_data_idx > 0) {
+ if (thread_static_info.offset || thread_static_info.idx > 0) {
/* get the current allocated size */
- offset = static_data_offset | ((static_data_idx + 1) << 24);
- thread_alloc_static_data (thread, offset);
+ offset = thread_static_info.offset | ((thread_static_info.idx + 1) << 24);
+ mono_alloc_static_data (&(thread->static_data), offset);
}
LeaveCriticalSection (&threads_mutex);
}
@@ -1306,62 +1441,67 @@ alloc_thread_static_data_helper (gpointer key, gpointer value, gpointer user)
MonoThread *thread = value;
guint32 offset = GPOINTER_TO_UINT (user);
- thread_alloc_static_data (thread, offset);
+ mono_alloc_static_data (&(thread->static_data), offset);
}
/*
- * The offset for a thread static variable is composed of two parts:
+ * The offset for a special static variable is composed of three parts:
+ * a bit that indicates the type of static data (0:thread, 1:context),
* an index in the array of chunks of memory for the thread (thread->static_data)
* and an offset in that chunk of mem. This allows allocating less memory in the
* common case.
*/
+
guint32
-mono_threads_alloc_static_data (guint32 size, guint32 align)
+mono_alloc_special_static_data (guint32 static_type, guint32 size, guint32 align)
{
guint32 offset;
-
- EnterCriticalSection (&threads_mutex);
-
- if (!static_data_idx && !static_data_offset) {
- /*
- * we use the first chunk of the first allocation also as
- * an array for the rest of the data
- */
- static_data_offset = sizeof (gpointer) * NUM_STATIC_DATA_IDX;
+ if (static_type == SPECIAL_STATIC_THREAD)
+ {
+ EnterCriticalSection (&threads_mutex);
+ offset = mono_alloc_static_data_slot (&thread_static_info, size, align);
+ mono_g_hash_table_foreach (threads, alloc_thread_static_data_helper, GUINT_TO_POINTER (offset));
+ LeaveCriticalSection (&threads_mutex);
}
- static_data_offset += align - 1;
- static_data_offset &= ~(align - 1);
- if (static_data_offset + size >= static_data_size [static_data_idx]) {
- static_data_idx ++;
- g_assert (size <= static_data_size [static_data_idx]);
- /*
- * massive unloading and reloading of domains with thread-static
- * data may eventually exceed the allocated storage...
- * Need to check what the MS runtime does in that case.
- * Note that for each appdomain, we need to allocate a separate
- * thread data slot for security reasons. We could keep track
- * of the slots per-domain and when the domain is unloaded
- * out the slots on a sort of free list.
- */
- g_assert (static_data_idx < NUM_STATIC_DATA_IDX);
- static_data_offset = 0;
+ else
+ {
+ g_assert (static_type == SPECIAL_STATIC_CONTEXT);
+ EnterCriticalSection (&contexts_mutex);
+ offset = mono_alloc_static_data_slot (&context_static_info, size, align);
+ LeaveCriticalSection (&contexts_mutex);
+ offset |= 0x80000000; // Set the high bit to indicate context static data
}
- offset = static_data_offset | ((static_data_idx + 1) << 24);
- static_data_offset += size;
-
- mono_g_hash_table_foreach (threads, alloc_thread_static_data_helper, GUINT_TO_POINTER (offset));
-
- LeaveCriticalSection (&threads_mutex);
return offset;
}
gpointer
-mono_threads_get_static_data (guint32 offset)
+mono_get_special_static_data (guint32 offset)
{
- MonoThread *thread = mono_thread_current ();
- int idx = offset >> 24;
-
- return ((char*) thread->static_data [idx - 1]) + (offset & 0xffffff);
+ // The high bit means either thread (0) or static (1) data.
+
+ guint32 static_type = (offset & 0x80000000);
+ int idx;
+
+ offset &= 0x7fffffff;
+ idx = (offset >> 24) - 1;
+
+ if (static_type == 0)
+ {
+ MonoThread *thread = mono_thread_current ();
+ return ((char*) thread->static_data [idx]) + (offset & 0xffffff);
+ }
+ else
+ {
+ // Allocate static data block under demand, since we don't have a list
+ // of contexts
+ MonoAppContext *context = mono_context_get ();
+ if (!context->static_data || !context->static_data [idx]) {
+ EnterCriticalSection (&contexts_mutex);
+ mono_alloc_static_data (&(context->static_data), offset);
+ LeaveCriticalSection (&contexts_mutex);
+ }
+ return ((char*) context->static_data [idx]) + (offset & 0xffffff);
+ }
}
static void gc_stop_world (gpointer key, gpointer value, gpointer user)
diff --git a/mono/metadata/threads.h b/mono/metadata/threads.h
index d801502d9e0..2453b07f0c9 100644
--- a/mono/metadata/threads.h
+++ b/mono/metadata/threads.h
@@ -28,6 +28,10 @@ typedef enum {
ThreadState_Aborted = 0x00000100,
} MonoThreadState;
+#define SPECIAL_STATIC_NONE 0
+#define SPECIAL_STATIC_THREAD 1
+#define SPECIAL_STATIC_CONTEXT 2
+
typedef void (*MonoThreadCleanupFunc) (MonoThread* thread);
extern int mono_thread_get_abort_signal (void);
@@ -65,8 +69,8 @@ void mono_threads_install_cleanup (MonoThreadCleanupFunc func);
extern void mono_threads_set_default_stacksize (guint32 stacksize);
extern guint32 mono_threads_get_default_stacksize (void);
-guint32 mono_threads_alloc_static_data (guint32 size, guint32 align);
-gpointer mono_threads_get_static_data (guint32 offset);
+guint32 mono_alloc_special_static_data (guint32 static_type, guint32 size, guint32 align);
+gpointer mono_get_special_static_data (guint32 offset);
void mono_gc_stop_world (void);
@@ -109,5 +113,16 @@ extern void ves_icall_System_Threading_Thread_ResetAbort (void);
extern void ves_icall_System_Threading_ThreadPool_GetAvailableThreads (int *workerThreads, int *completionPortThreads);
extern void ves_icall_System_Threading_ThreadPool_GetMaxThreads (int *workerThreads, int *completionPortThreads);
+gint8 ves_icall_System_Threading_Thread_VolatileRead1 (void *ptr);
+gint16 ves_icall_System_Threading_Thread_VolatileRead2 (void *ptr);
+gint32 ves_icall_System_Threading_Thread_VolatileRead4 (void *ptr);
+gint64 ves_icall_System_Threading_Thread_VolatileRead8 (void *ptr);
+void * ves_icall_System_Threading_Thread_VolatileReadIntPtr (void *ptr);
+
+void ves_icall_System_Threading_Thread_VolatileWrite1 (void *ptr, gint8);
+void ves_icall_System_Threading_Thread_VolatileWrite2 (void *ptr, gint16);
+void ves_icall_System_Threading_Thread_VolatileWrite4 (void *ptr, gint32);
+void ves_icall_System_Threading_Thread_VolatileWrite8 (void *ptr, gint64);
+void ves_icall_System_Threading_Thread_VolatileWriteIntPtr (void *ptr, void *);
#endif /* _MONO_METADATA_THREADS_H_ */
diff --git a/mono/metadata/verify.c b/mono/metadata/verify.c
index 93394bca4de..bed0b096caf 100644
--- a/mono/metadata/verify.c
+++ b/mono/metadata/verify.c
@@ -2245,7 +2245,6 @@ propertybuilder_fields[] = {
static const FieldDesc
ilgenerator_fields[] = {
{"code", G_STRUCT_OFFSET (MonoReflectionILGen, code)},
- {"mbuilder", G_STRUCT_OFFSET (MonoReflectionILGen, mbuilder)},
{"code_len", G_STRUCT_OFFSET (MonoReflectionILGen, code_len)},
{"max_stack", G_STRUCT_OFFSET (MonoReflectionILGen, max_stack)},
{"cur_stack", G_STRUCT_OFFSET (MonoReflectionILGen, cur_stack)},
diff --git a/mono/mini/ChangeLog b/mono/mini/ChangeLog
index 8426418d8de..c93259df42b 100644
--- a/mono/mini/ChangeLog
+++ b/mono/mini/ChangeLog
@@ -1,3 +1,147 @@
+
+Fri Nov 28 23:03:05 CET 2003 Paolo Molaro <lupus@ximian.com>
+
+ * cpu-g4.md, inssel-ppc.brg, mini-ppc.c: better long return support.
+ * tramp-ppc.c: fixed class init trampoline.
+ * inssel-ppc.brg, mini.c, jit-icalls.c, mini-ppc.h: more emulation.
+
+Fri Nov 28 16:36:29 CET 2003 Paolo Molaro <lupus@ximian.com>
+
+ * cpu-g4.md, inssel-ppc.brg, jit-icalls.c, mini-ppc.c, mini-ppc.h,
+ mini.c: more ppc changes/fixes.
+
+2003-11-27 Zoltan Varga <vargaz@freemail.hu>
+
+ * mini.c (mono_method_to_ir): Fix tail calls with valuetype arguments.
+ Also optimize the case when the arguments are the same in the caller
+ and in the callee.
+
+ * iltests.il: Add tests for tail calls with valuetype arguments.
+
+Thu Nov 27 21:06:37 CET 2003 Paolo Molaro <lupus@ximian.com>
+
+ * mini-ppc.c: fixes for struct return type.
+
+Thu Nov 27 19:02:07 CET 2003 Paolo Molaro <lupus@ximian.com>
+
+ * mini.h, mini.c, mini-x86.c, mini-ppc.c, mini-sparc.c: move
+ mono_spillvar_offset() to arch-specific code.
+
+Thu Nov 27 18:30:42 CET 2003 Paolo Molaro <lupus@ximian.com>
+
+ * mini-ppc.h, mini-ppc.c: handle some different ABI call convention issues.
+
+2003-11-27 Zoltan Varga <vargaz@freemail.hu>
+
+ * exceptions-x86.c: Fix stack space leaks.
+
+ * exceptions-x86.c (mono_arch_find_jit_info): Restore callee saved
+ registers from the lmf if the method has save_lmf set.
+
+2003-11-26 Zoltan Varga <vargaz@freemail.hu>
+
+ * tramp-x86.c (x86_magic_trampoline): Avoid patching in the addresses
+ of icall wrappers into InvokeInDomain, since these are now per-domain.
+
+Wed Nov 26 20:15:04 CET 2003 Paolo Molaro <lupus@ximian.com>
+
+ * mini-ppc.h, mini-x86.h, mini.c, inssel-ppc.brg, jit-icalls.c:
+ make some opcode emulation and intrinsic ops enabled/disabled
+ according to the architecture. More fixes.
+
+Wed Nov 26 19:59:09 CET 2003 Paolo Molaro <lupus@ximian.com>
+
+ * mini-ppc.c, mini-sparc.c, cpu-g4.md: more bug fixes.
+
+Wed Nov 26 19:18:29 CET 2003 Paolo Molaro <lupus@ximian.com>
+
+ * mini.h, inssel.brg, mini-x86.c, mini-ppc.c, mini-sparc.c: move
+ arch-specific handling for 'this' and struct return type to
+ arch-specific code.
+
+2003-11-26 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * aot.c: prevent divide by zero error when reporting (it happened with
+ Accessibility.dll).
+
+2003-11-25 Zoltan Varga <vargaz@freemail.hu>
+
+ * mini.h (inst_switch): Remove unused macro.
+
+2003-11-25 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * aot.c:
+ (load_aot_module): free 'info->methods' and 'info' properly. No more
+ "free(): invalid pointer blah" messages when you have an old aot
+ compiled assembly.
+
+2003-11-21 Lluis Sanchez Gual <lluis@ximian.com>
+
+ * jit-icalls.c, mini.c: Added support for context static fields.
+
+2003-11-18 Zoltan Varga <vargaz@freemail.hu>
+
+ * mini.c (mono_method_blittable): Methods which set LastError are not
+ blittable either. Fixes #51108.
+
+Tue Nov 18 16:41:37 CET 2003 Paolo Molaro <lupus@ximian.com>
+
+ * mini.c: flush icache.
+ * cpu-g4.md, mini-ppc.c, inssel.brg: more fixes. Trace support.
+
+2003-11-18 Zoltan Varga <vargaz@freemail.hu>
+
+ * mini.c (mono_type_blittable): OBJECT is not blittable. Fixes #47842.
+
+2003-11-17 Zoltan Varga <vargaz@freemail.hu>
+
+ * tramp-x86.c (x86_class_init_trampoline): Make code patching thread
+ safe on IA32.
+
+ * mini-x86.c (mono_arch_call_opcode): Disable AOT for methods with
+ vararg calls.
+
+ * inssel.brg (CEE_MKREFANY): Fix AOT case.
+
+2003-11-16 Zoltan Varga <vargaz@freemail.hu>
+
+ * mini-x86.c (mono_arch_local_regalloc): Fix regalloc for div
+ instruction when the result is discarded.
+
+ * iltests.il (test_0_div_regalloc): New regression test.
+
+ * arrays.cs: Fix compilation error.
+
+Fri Nov 14 21:34:06 CET 2003 Paolo Molaro <lupus@ximian.com>
+
+ * inssel-x86.brg, inssel-float.brg, mini-ops.h: move x86-specific
+ float rules to inssel-x86.brg: sane architectures with FP registers
+ don't need to implement these rules.
+
+Fri Nov 14 20:52:12 CET 2003 Paolo Molaro <lupus@ximian.com>
+
+ * mini-ppc.c, cpu-g4.md, inssel-ppc.brg: updates and fixes to the ppc port.
+
+Fri Nov 14 17:58:27 CET 2003 Paolo Molaro <lupus@ximian.com>
+
+ * mini.h, inssel-long32.brg: fixed endianess issues in int64
+ implementation of 32 bit systems.
+
+Thu Nov 13 16:14:41 CET 2003 Paolo Molaro <lupus@ximian.com>
+
+ * exceptions-ppc.c: fix build on Linux/ppc from Jeroen@xs4all.nl
+ (Jeroen Zwartepoorte).
+
+2003-11-12 Zoltan Varga <vargaz@freemail.hu>
+
+ * mini.c (mono_method_to_ir): Use CEE_JMP only if the signature of
+ the caller and the callee matches.
+
+ * mini.c (mono_method_to_ir): Add comment.
+
+ * mini-x86.c (mono_arch_output_basic_block): Use mono_signbit, since
+ signbit is missing on some platforms.
+
2003-11-06 Zoltan Varga <vargaz@freemail.hu>
* mini.h (mono_arch_setup_jit_tls_data): New arch specific function.
diff --git a/mono/mini/aot.c b/mono/mini/aot.c
index 654c2235789..aa1a4f8c449 100644
--- a/mono/mini/aot.c
+++ b/mono/mini/aot.c
@@ -170,9 +170,11 @@ load_aot_module (MonoAssembly *assembly, gpointer user_data)
if (!info->image_table [i]) {
if (mono_aot_verbose > 0)
printf ("AOT module %s is out of date.\n", aot_name);
- g_free (info->methods);
+ mono_g_hash_table_destroy (info->methods);
g_free (info->image_table);
+#ifndef HAVE_BOEHM_GC
g_free (info);
+#endif
g_free (aot_name);
g_module_close (assembly->aot_module);
assembly->aot_module = NULL;
@@ -1236,11 +1238,11 @@ mono_compile_assembly (MonoAssembly *ass, guint32 opts)
system (com);
g_free (com);*/
- printf ("Compiled %d out of %d methods (%d%%)\n", ccount, mcount, (ccount*100)/mcount);
- printf ("%d methods contain absolute addresses (%d%%)\n", abscount, (abscount*100)/mcount);
- printf ("%d methods contain wrapper references (%d%%)\n", wrappercount, (wrappercount*100)/mcount);
- printf ("%d methods contain lmf pointers (%d%%)\n", lmfcount, (lmfcount*100)/mcount);
- printf ("%d methods have other problems (%d%%)\n", ocount, (ocount*100)/mcount);
+ printf ("Compiled %d out of %d methods (%d%%)\n", ccount, mcount, mcount ? (ccount*100)/mcount : 100);
+ printf ("%d methods contain absolute addresses (%d%%)\n", abscount, mcount ? (abscount*100)/mcount : 100);
+ printf ("%d methods contain wrapper references (%d%%)\n", wrappercount, mcount ? (wrappercount*100)/mcount : 100);
+ printf ("%d methods contain lmf pointers (%d%%)\n", lmfcount, mcount ? (lmfcount*100)/mcount : 100);
+ printf ("%d methods have other problems (%d%%)\n", ocount, mcount ? (ocount*100)/mcount : 100);
unlink (tmpfname);
return 0;
diff --git a/mono/mini/arrays.cs b/mono/mini/arrays.cs
index 1a200c37885..380f7c7cd1c 100644
--- a/mono/mini/arrays.cs
+++ b/mono/mini/arrays.cs
@@ -93,7 +93,7 @@ class Tests {
}
/* Regression test for #30073 */
- public static test_0_newarr_emulation () {
+ public static int test_0_newarr_emulation () {
double d = 500;
checked {
double [] arr = new double [(int)d];
diff --git a/mono/mini/cpu-g4.md b/mono/mini/cpu-g4.md
index 629cf6a9c91..034a4126c1c 100644
--- a/mono/mini/cpu-g4.md
+++ b/mono/mini/cpu-g4.md
@@ -13,6 +13,7 @@
#
# register may have the following values:
# i integer register
+# a r3 register (output from calls)
# b base register (used in address references)
# f floating point register
#
@@ -150,8 +151,8 @@ conv.i1: dest:i src1:i len:4
conv.i2: dest:i src1:i len:4
conv.i4: dest:i src1:i len:4
conv.i8:
-conv.r4: dest:f src1:i len:7
-conv.r8: dest:f src1:i len:7
+conv.r4: dest:f src1:i len:36
+conv.r8: dest:f src1:i len:36
conv.u4: dest:i src1:i
conv.u8:
callvirt:
@@ -228,7 +229,8 @@ mul.ovf: dest:i src1:i src2:i len:8
mul.ovf.un: dest:i src1:i src2:i len:12
sub.ovf:
sub.ovf.un:
-endfinally: len:10
+start_handler: len:8
+endfinally: len:12
leave:
leave.s:
stind.i:
@@ -256,7 +258,7 @@ ldloc:
ldloca:
stloc:
localloc: dest:i src1:i len:30
-endfilter:
+endfilter: len:12
unaligned.:
volatile.:
tail.:
@@ -292,30 +294,30 @@ outarg: src1:i len:1
outarg_imm: len:5
retarg:
setret: dest:a src1:i len:4
-setlret: dest:l src1:i src2:i len:8
+setlret: src1:i src2:i len:12
setreg: dest:i src1:i len:4 clob:r
setregimm: dest:i len:8 clob:r
setfreg: dest:f src1:f len:4 clob:r
checkthis: src1:b len:4
voidcall: len:8 clob:c
voidcall_reg: src1:i len:8 clob:c
-voidcall_membase: src1:b len:8 clob:c
+voidcall_membase: src1:b len:12 clob:c
fcall: dest:f len:8 clob:c
fcall_reg: dest:f src1:i len:8 clob:c
-fcall_membase: dest:f src1:b len:8 clob:c
+fcall_membase: dest:f src1:b len:12 clob:c
lcall: dest:l len:8 clob:c
lcall_reg: dest:l src1:i len:8 clob:c
-lcall_membase: dest:l src1:b len:8 clob:c
+lcall_membase: dest:l src1:b len:12 clob:c
vcall: len:8 clob:c
vcall_reg: src1:i len:8 clob:c
-vcall_membase: src1:b len:8 clob:c
-call_reg: dest:i src1:i len:8 clob:c
-call_membase: dest:i src1:b len:8 clob:c
+vcall_membase: src1:b len:12 clob:c
+call_reg: dest:a src1:i len:8 clob:c
+call_membase: dest:a src1:b len:12 clob:c
trap:
-iconst: dest:i len:8
+iconst: dest:i len:12
i8const:
-r4const: dest:f len:8
-r8const: dest:f len:8
+r4const: dest:f len:12
+r8const: dest:f len:12
regvar:
reg:
regoffset:
@@ -344,6 +346,7 @@ loadr4_membase: dest:f src1:b len:8
loadr8_membase: dest:f src1:b len:12
loadu4_mem: dest:i len:8
move: dest:i src1:i len:4
+fmove: dest:f src1:f len:4
add_imm: dest:i src1:i len:12
sub_imm: dest:i src1:i len:12
mul_imm: dest:i src1:i len:12
@@ -458,20 +461,20 @@ float_bge: len:8
float_bge_un: len:8
float_ble: len:8
float_ble_un: len:8
-float_add: len:4
-float_sub: len:4
-float_mul: len:4
-float_div: len:4
-float_div_un: len:4
-float_rem: len:16
-float_rem_un: len:16
+float_add: dest:f src1:f src2:f len:4
+float_sub: dest:f src1:f src2:f len:4
+float_mul: dest:f src1:f src2:f len:4
+float_div: dest:f src1:f src2:f len:4
+float_div_un: dest:f src1:f src2:f len:4
+float_rem: dest:f src1:f src2:f len:16
+float_rem_un: dest:f src1:f src2:f len:16
float_neg: dest:f src1:f len:4
float_not: dest:f src1:f len:4
float_conv_to_i1: dest:i src1:f len:40
float_conv_to_i2: dest:i src1:f len:40
float_conv_to_i4: dest:i src1:f len:40
float_conv_to_i8: dest:l src1:f len:40
-float_conv_to_r4:
+float_conv_to_r4: dest:f src1:f len:4
float_conv_to_r8:
float_conv_to_u4: dest:i src1:f len:40
float_conv_to_u8: dest:l src1:f len:40
@@ -504,11 +507,11 @@ float_conv_to_ovf_i4:
float_conv_to_ovf_u4:
float_conv_to_ovf_i8:
float_conv_to_ovf_u8:
-float_ceq: dest:i src1:f src2:f len:12
-float_cgt: dest:i src1:f src2:f len:12
-float_cgt_un: dest:i src1:f src2:f len:12
-float_clt: dest:i src1:f src2:f len:12
-float_clt_un: dest:i src1:f src2:f len:12
+float_ceq: dest:i src1:f src2:f len:16
+float_cgt: dest:i src1:f src2:f len:16
+float_cgt_un: dest:i src1:f src2:f len:16
+float_clt: dest:i src1:f src2:f len:16
+float_clt_un: dest:i src1:f src2:f len:16
float_conv_to_u: dest:i src1:f len:36
call_handler: len:12
op_endfilter: src1:i len:12
diff --git a/mono/mini/exceptions-ppc.c b/mono/mini/exceptions-ppc.c
index 1e095b48920..f05102e6f42 100644
--- a/mono/mini/exceptions-ppc.c
+++ b/mono/mini/exceptions-ppc.c
@@ -98,6 +98,8 @@ typedef struct mcontext * mcontext_t;
*/
+#ifdef __APPLE__
+
/* we have the stack pointer, not the base pointer in sigcontext */
#define MONO_CONTEXT_SET_IP(ctx,ip) do { (ctx)->sc_ir = (int)ip; } while (0);
#define MONO_CONTEXT_SET_BP(ctx,bp) do { (ctx)->sc_sp = (int)bp; } while (0);
@@ -105,6 +107,16 @@ typedef struct mcontext * mcontext_t;
#define MONO_CONTEXT_GET_IP(ctx) ((gpointer)((ctx)->sc_ir))
#define MONO_CONTEXT_GET_BP(ctx) ((gpointer)((ctx)->sc_sp))
+#else /* sigcontext is different on linux/ppc. See /usr/include/asm/ptrace.h. */
+
+#define MONO_CONTEXT_SET_IP(ctx,ip) do { (ctx)->regs->nip = (unsigned long)ip; } while (0);
+#define MONO_CONTEXT_SET_BP(ctx,bp) do { (ctx)->regs->gpr[1] = (unsigned long)bp; } while (0);
+
+#define MONO_CONTEXT_GET_IP(ctx) ((gpointer)((ctx)->regs->nip))
+#define MONO_CONTEXT_GET_BP(ctx) ((gpointer)((ctx)->regs->gpr[1]))
+
+#endif
+
/* disbale this for now */
#undef MONO_USE_EXC_TABLES
diff --git a/mono/mini/exceptions-x86.c b/mono/mini/exceptions-x86.c
index 3645827fdb6..7c0e853f265 100644
--- a/mono/mini/exceptions-x86.c
+++ b/mono/mini/exceptions-x86.c
@@ -573,7 +573,8 @@ throw_exception (unsigned long eax, unsigned long ecx, unsigned long edx, unsign
/* adjust eip so that it point into the call instruction */
eip -= 1;
- ctx.SC_ESP = esp;
+ /* Pop argument and return address */
+ ctx.SC_ESP = esp + (2 * sizeof (gpointer));
ctx.SC_EIP = eip;
ctx.SC_EBP = ebp;
ctx.SC_EDI = edi;
@@ -725,11 +726,6 @@ mono_arch_find_jit_info (MonoDomain *domain, MonoJitTlsData *jit_tls, MonoJitInf
*new_ctx = *ctx;
- if (*lmf && (MONO_CONTEXT_GET_BP (ctx) >= (gpointer)(*lmf)->ebp)) {
- /* remove any unused lmf */
- *lmf = (*lmf)->previous_lmf;
- }
-
address = (char *)ip - (char *)ji->code_start;
if (native_offset)
@@ -759,22 +755,46 @@ mono_arch_find_jit_info (MonoDomain *domain, MonoJitTlsData *jit_tls, MonoJitInf
g_free (source_location);
g_free (tmpaddr);
}
-
- offset = -1;
- /* restore caller saved registers */
- if (ji->used_regs & X86_EBX_MASK) {
- new_ctx->SC_EBX = *((int *)ctx->SC_EBP + offset);
- offset--;
+
+ /*
+ * Some managed methods like pinvoke wrappers might have save_lmf set.
+ * In this case, register save/restore code is not generated by the
+ * JIT, so we have to restore callee saved registers from the lmf.
+ */
+ if (ji->method->save_lmf) {
+ /*
+ * We only need to do this if the exception was raised in managed
+ * code, since otherwise the lmf was already popped of the stack.
+ */
+ if (*lmf && (MONO_CONTEXT_GET_BP (ctx) >= (gpointer)(*lmf)->ebp)) {
+ new_ctx->SC_ESI = (*lmf)->esi;
+ new_ctx->SC_EDI = (*lmf)->edi;
+ new_ctx->SC_EBX = (*lmf)->ebx;
+ }
}
- if (ji->used_regs & X86_EDI_MASK) {
- new_ctx->SC_EDI = *((int *)ctx->SC_EBP + offset);
- offset--;
+ else {
+ offset = -1;
+ /* restore caller saved registers */
+ if (ji->used_regs & X86_EBX_MASK) {
+ new_ctx->SC_EBX = *((int *)ctx->SC_EBP + offset);
+ offset--;
+ }
+ if (ji->used_regs & X86_EDI_MASK) {
+ new_ctx->SC_EDI = *((int *)ctx->SC_EBP + offset);
+ offset--;
+ }
+ if (ji->used_regs & X86_ESI_MASK) {
+ new_ctx->SC_ESI = *((int *)ctx->SC_EBP + offset);
+ }
}
- if (ji->used_regs & X86_ESI_MASK) {
- new_ctx->SC_ESI = *((int *)ctx->SC_EBP + offset);
+
+ if (*lmf && (MONO_CONTEXT_GET_BP (ctx) >= (gpointer)(*lmf)->ebp)) {
+ /* remove any unused lmf */
+ *lmf = (*lmf)->previous_lmf;
}
- new_ctx->SC_ESP = ctx->SC_EBP;
+ /* Pop EBP and the return address */
+ new_ctx->SC_ESP = ctx->SC_EBP + (2 * sizeof (gpointer));
/* we substract 1, so that the IP points into the call instruction */
new_ctx->SC_EIP = *((int *)ctx->SC_EBP + 1) - 1;
new_ctx->SC_EBP = *((int *)ctx->SC_EBP);
diff --git a/mono/mini/iltests.il b/mono/mini/iltests.il
index d397cc40fdf..dcbc6a766ab 100644
--- a/mono/mini/iltests.il
+++ b/mono/mini/iltests.il
@@ -13,6 +13,21 @@
ret
}
+ // make sure the register allocator works when the return value of
+ // 'div' is discarded
+ .method static public int32 test_0_div_regalloc () il managed {
+ .locals init (
+ int32 i
+ )
+
+ ldloc 0
+ ldc.i4.s 0xa
+ div
+ pop
+ ldc.i4.0
+ ret
+ }
+
.method static public int32 test_3_copy_used_bug () il managed {
.locals init (
@@ -100,4 +115,58 @@
ldc.i4 1
ret
}
+
+ .class nested private auto ansi sealed beforefieldinit TailCallStruct
+ extends [mscorlib]System.ValueType {
+ .field public int32 a
+ .field public int32 b
+ }
+
+ .method static valuetype Tests/TailCallStruct tail1 (valuetype Tests/TailCallStruct arg) {
+ ldarga 0
+ ldarga 0
+ ldfld int32 Tests/TailCallStruct::a
+ ldc.i4.1
+ add
+ stfld int32 Tests/TailCallStruct::a
+ ldarga 0
+ ldarga 0
+ ldfld int32 Tests/TailCallStruct::a
+ ldc.i4.2
+ add
+ stfld int32 Tests/TailCallStruct::a
+ ldarg.0
+ ret
+ }
+
+ .method static valuetype Tests/TailCallStruct tail2 (valuetype Tests/TailCallStruct arg) {
+ ldarg.0
+ tail.
+ call valuetype Tests/TailCallStruct Tests::tail1 (valuetype Tests/TailCallStruct)
+ ret
+ }
+
+ .method static public int32 test_0_tail_calls () il managed {
+ .maxstack 16
+ .locals init (
+ valuetype Tests/TailCallStruct arg
+ )
+ ldloca 0
+ ldc.i4.2
+ stfld int32 Tests/TailCallStruct::a
+ ldloca 0
+ ldc.i4.4
+ stfld int32 Tests/TailCallStruct::b
+ ldloc.0
+ call valuetype Tests/TailCallStruct Tests::tail2 (valuetype Tests/TailCallStruct)
+ stloc.0
+ ldloca 0
+ ldfld int32 Tests/TailCallStruct::a
+ ldloca 0
+ ldfld int32 Tests/TailCallStruct::b
+ add
+ ldc.i4 9
+ sub
+ ret
+ }
}
diff --git a/mono/mini/inssel-float.brg b/mono/mini/inssel-float.brg
index b3d0e643426..cc9bc579dcb 100644
--- a/mono/mini/inssel-float.brg
+++ b/mono/mini/inssel-float.brg
@@ -160,11 +160,11 @@ reg: OP_FCONV_TO_U1 (freg) {
}
freg: OP_FCONV_TO_R8 (freg) {
- /* nothing to do */
+ MONO_EMIT_UNALU (s, tree, OP_FMOVE, state->reg1, state->left->reg1);
}
freg: OP_FCONV_TO_R4 (freg) {
- /* fixme: nothing to do ??*/
+ MONO_EMIT_UNALU (s, tree, tree->opcode, state->reg1, state->left->reg1);
}
freg: CEE_CONV_R4 (reg) "2" {
diff --git a/mono/mini/inssel-long32.brg b/mono/mini/inssel-long32.brg
index a48e2503a02..852fe267c33 100644
--- a/mono/mini/inssel-long32.brg
+++ b/mono/mini/inssel-long32.brg
@@ -21,18 +21,18 @@ stmt: CEE_POP (lreg) {
i8con: CEE_CONV_I8 (OP_ICONST) "0" {
int data = state->left->tree->inst_c0;
tree->opcode = OP_I8CONST;
- tree->inst_c0 = data;
+ tree->inst_ls_word = data;
if (data < 0)
- tree->inst_c1 = -1;
+ tree->inst_ms_word = -1;
else
- tree->inst_c1 = 0;
+ tree->inst_ms_word = 0;
}
i8con: CEE_CONV_U8 (OP_ICONST) "0" {
int data = state->left->tree->inst_c0;
tree->opcode = OP_I8CONST;
- tree->inst_c0 = data;
- tree->inst_c1 = 0;
+ tree->inst_ls_word = data;
+ tree->inst_ms_word = 0;
}
i8con: OP_I8CONST "0"
@@ -49,29 +49,29 @@ lreg: OP_ICONST {
}
lreg: OP_I8CONST {
- MONO_EMIT_NEW_ICONST (s, state->reg1, tree->inst_c0);
- MONO_EMIT_NEW_ICONST (s, state->reg2, tree->inst_c1);
+ MONO_EMIT_NEW_ICONST (s, state->reg1, tree->inst_ls_word);
+ MONO_EMIT_NEW_ICONST (s, state->reg2, tree->inst_ms_word);
}
lreg: CEE_LDIND_I8 (base) {
MONO_EMIT_NEW_LOAD_MEMBASE_OP (s, OP_LOADI4_MEMBASE, state->reg1,
- state->left->tree->inst_basereg, state->left->tree->inst_offset);
+ state->left->tree->inst_basereg, state->left->tree->inst_offset + MINI_LS_WORD_OFFSET);
MONO_EMIT_NEW_LOAD_MEMBASE_OP (s, OP_LOADI4_MEMBASE, state->reg2,
- state->left->tree->inst_basereg, state->left->tree->inst_offset + 4);
+ state->left->tree->inst_basereg, state->left->tree->inst_offset + MINI_MS_WORD_OFFSET);
}
stmt: CEE_STIND_I8 (base, lreg) {
MONO_EMIT_NEW_STORE_MEMBASE (s, OP_STOREI4_MEMBASE_REG, state->left->tree->inst_basereg,
- state->left->tree->inst_offset + 4, state->right->reg2);
+ state->left->tree->inst_offset + MINI_MS_WORD_OFFSET, state->right->reg2);
MONO_EMIT_NEW_STORE_MEMBASE (s, OP_STOREI4_MEMBASE_REG, state->left->tree->inst_basereg,
- state->left->tree->inst_offset, state->right->reg1);
+ state->left->tree->inst_offset + MINI_LS_WORD_OFFSET, state->right->reg1);
}
stmt: CEE_STIND_I8 (base, i8con) {
MONO_EMIT_NEW_STORE_MEMBASE_IMM (s, OP_STOREI4_MEMBASE_IMM, state->left->tree->inst_basereg,
- state->left->tree->inst_offset + 4, state->right->tree->inst_c1);
+ state->left->tree->inst_offset + MINI_MS_WORD_OFFSET, state->right->tree->inst_ms_word);
MONO_EMIT_NEW_STORE_MEMBASE_IMM (s, OP_STOREI4_MEMBASE_IMM, state->left->tree->inst_basereg,
- state->left->tree->inst_offset, state->right->tree->inst_c0);
+ state->left->tree->inst_offset + MINI_LS_WORD_OFFSET, state->right->tree->inst_ls_word);
}
lreg: OP_BIGMUL (reg, reg) {
@@ -102,8 +102,8 @@ lreg: OP_LADD_OVF_UN (lreg, lreg) {
}
lreg: OP_LADD (lreg, i8con) {
- MONO_EMIT_NEW_BIALU_IMM (s, OP_ADD_IMM, state->reg1, state->left->reg1, state->right->tree->inst_c0);
- MONO_EMIT_BIALU_IMM (s, tree, OP_ADC_IMM, state->reg2, state->left->reg2, state->right->tree->inst_c1);
+ MONO_EMIT_NEW_BIALU_IMM (s, OP_ADD_IMM, state->reg1, state->left->reg1, state->right->tree->inst_ls_word);
+ MONO_EMIT_BIALU_IMM (s, tree, OP_ADC_IMM, state->reg2, state->left->reg2, state->right->tree->inst_ms_word);
}
lreg: OP_LSUB (lreg, lreg) {
@@ -112,8 +112,8 @@ lreg: OP_LSUB (lreg, lreg) {
}
lreg: OP_LSUB (lreg, i8con) {
- MONO_EMIT_NEW_BIALU_IMM (s, OP_SUB_IMM, state->reg1, state->left->reg1, state->right->tree->inst_c0);
- MONO_EMIT_BIALU_IMM (s, tree, OP_SBB_IMM, state->reg2, state->left->reg2, state->right->tree->inst_c1);
+ MONO_EMIT_NEW_BIALU_IMM (s, OP_SUB_IMM, state->reg1, state->left->reg1, state->right->tree->inst_ls_word);
+ MONO_EMIT_BIALU_IMM (s, tree, OP_SBB_IMM, state->reg2, state->left->reg2, state->right->tree->inst_ms_word);
}
lreg: OP_LSUB_OVF (lreg, lreg) {
@@ -136,8 +136,8 @@ lreg: OP_LAND (lreg, lreg) {
}
lreg: OP_LAND (lreg, i8con) {
- MONO_EMIT_NEW_BIALU_IMM (s, OP_AND_IMM, state->reg1, state->left->reg1, state->right->tree->inst_c0);
- MONO_EMIT_BIALU_IMM (s, tree, OP_AND_IMM, state->reg2, state->left->reg2, state->right->tree->inst_c1);
+ MONO_EMIT_NEW_BIALU_IMM (s, OP_AND_IMM, state->reg1, state->left->reg1, state->right->tree->inst_ls_word);
+ MONO_EMIT_BIALU_IMM (s, tree, OP_AND_IMM, state->reg2, state->left->reg2, state->right->tree->inst_ms_word);
}
lreg: OP_LOR (lreg, lreg) {
@@ -146,8 +146,8 @@ lreg: OP_LOR (lreg, lreg) {
}
lreg: OP_LOR (lreg, i8con) {
- MONO_EMIT_NEW_BIALU_IMM (s, OP_OR_IMM, state->reg1, state->left->reg1, state->right->tree->inst_c0);
- MONO_EMIT_BIALU_IMM (s, tree, OP_OR_IMM, state->reg2, state->left->reg2, state->right->tree->inst_c1);
+ MONO_EMIT_NEW_BIALU_IMM (s, OP_OR_IMM, state->reg1, state->left->reg1, state->right->tree->inst_ls_word);
+ MONO_EMIT_BIALU_IMM (s, tree, OP_OR_IMM, state->reg2, state->left->reg2, state->right->tree->inst_ms_word);
}
lreg: OP_LXOR (lreg, lreg) {
@@ -156,8 +156,8 @@ lreg: OP_LXOR (lreg, lreg) {
}
lreg: OP_LXOR (lreg, i8con) {
- MONO_EMIT_NEW_BIALU_IMM (s, OP_XOR_IMM, state->reg1, state->left->reg1, state->right->tree->inst_c0);
- MONO_EMIT_BIALU_IMM (s, tree, OP_XOR_IMM, state->reg2, state->left->reg2, state->right->tree->inst_c1);
+ MONO_EMIT_NEW_BIALU_IMM (s, OP_XOR_IMM, state->reg1, state->left->reg1, state->right->tree->inst_ls_word);
+ MONO_EMIT_BIALU_IMM (s, tree, OP_XOR_IMM, state->reg2, state->left->reg2, state->right->tree->inst_ms_word);
}
lreg: OP_LNOT (lreg) {
@@ -263,9 +263,9 @@ stmt: CEE_BNE_UN (OP_COMPARE (lreg, lreg)) {
}
stmt: CEE_BNE_UN (OP_COMPARE (lreg, i8con)) {
- MONO_EMIT_NEW_BIALU_IMM (s, OP_COMPARE_IMM, -1, state->left->left->reg1, state->left->right->tree->inst_c0);
+ MONO_EMIT_NEW_BIALU_IMM (s, OP_COMPARE_IMM, -1, state->left->left->reg1, state->left->right->tree->inst_ls_word);
MONO_EMIT_NEW_BRANCH_BLOCK (s, CEE_BNE_UN, tree->inst_true_bb);
- MONO_EMIT_NEW_BIALU_IMM (s, OP_COMPARE_IMM, -1, state->left->left->reg2, state->left->right->tree->inst_c1);
+ MONO_EMIT_NEW_BIALU_IMM (s, OP_COMPARE_IMM, -1, state->left->left->reg2, state->left->right->tree->inst_ms_word);
mono_bblock_add_inst (s->cbb, tree);
}
@@ -279,9 +279,9 @@ stmt: CEE_BEQ (OP_COMPARE (lreg, lreg)) {
stmt: CEE_BEQ (OP_COMPARE (lreg, i8con)) {
- MONO_EMIT_NEW_BIALU_IMM (s, OP_COMPARE_IMM, -1, state->left->left->reg1, state->left->right->tree->inst_c0);
+ MONO_EMIT_NEW_BIALU_IMM (s, OP_COMPARE_IMM, -1, state->left->left->reg1, state->left->right->tree->inst_ls_word);
MONO_EMIT_NEW_BRANCH_BLOCK (s, CEE_BNE_UN, tree->inst_false_bb);
- MONO_EMIT_NEW_BIALU_IMM (s, OP_COMPARE_IMM, -1, state->left->left->reg2, state->left->right->tree->inst_c1);
+ MONO_EMIT_NEW_BIALU_IMM (s, OP_COMPARE_IMM, -1, state->left->left->reg2, state->left->right->tree->inst_ms_word);
mono_bblock_add_inst (s->cbb, tree);
}
@@ -296,10 +296,10 @@ stmt: CEE_BLE (OP_COMPARE (lreg, lreg)) {
stmt: CEE_BLE (OP_COMPARE (lreg, i8con)) {
- MONO_EMIT_NEW_BIALU_IMM (s, OP_COMPARE_IMM, -1, state->left->left->reg2, state->left->right->tree->inst_c1);
+ MONO_EMIT_NEW_BIALU_IMM (s, OP_COMPARE_IMM, -1, state->left->left->reg2, state->left->right->tree->inst_ms_word);
MONO_EMIT_NEW_BRANCH_BLOCK (s, CEE_BLT, tree->inst_true_bb);
MONO_EMIT_NEW_BRANCH_BLOCK (s, CEE_BNE_UN, tree->inst_false_bb);
- MONO_EMIT_NEW_BIALU_IMM (s, OP_COMPARE_IMM, -1, state->left->left->reg1, state->left->right->tree->inst_c0);
+ MONO_EMIT_NEW_BIALU_IMM (s, OP_COMPARE_IMM, -1, state->left->left->reg1, state->left->right->tree->inst_ls_word);
MONO_EMIT_NEW_BRANCH_BLOCK (s, CEE_BLE_UN, tree->inst_true_bb);
}
@@ -314,10 +314,10 @@ stmt: CEE_BLE_UN (OP_COMPARE (lreg, lreg)) {
stmt: CEE_BLE_UN (OP_COMPARE (lreg, i8con)) {
- MONO_EMIT_NEW_BIALU_IMM (s, OP_COMPARE_IMM, -1, state->left->left->reg2, state->left->right->tree->inst_c1);
+ MONO_EMIT_NEW_BIALU_IMM (s, OP_COMPARE_IMM, -1, state->left->left->reg2, state->left->right->tree->inst_ms_word);
MONO_EMIT_NEW_BRANCH_BLOCK (s, CEE_BLT_UN, tree->inst_true_bb);
MONO_EMIT_NEW_BRANCH_BLOCK (s, CEE_BNE_UN, tree->inst_false_bb);
- MONO_EMIT_NEW_BIALU_IMM (s, OP_COMPARE_IMM, -1, state->left->left->reg1, state->left->right->tree->inst_c0);
+ MONO_EMIT_NEW_BIALU_IMM (s, OP_COMPARE_IMM, -1, state->left->left->reg1, state->left->right->tree->inst_ls_word);
MONO_EMIT_NEW_BRANCH_BLOCK (s, CEE_BLE_UN, tree->inst_true_bb);
}
@@ -332,10 +332,10 @@ stmt: CEE_BGE (OP_COMPARE (lreg, lreg)) {
stmt: CEE_BGE (OP_COMPARE (lreg, i8con)) {
- MONO_EMIT_NEW_BIALU_IMM (s, OP_COMPARE_IMM, -1, state->left->left->reg2, state->left->right->tree->inst_c1);
+ MONO_EMIT_NEW_BIALU_IMM (s, OP_COMPARE_IMM, -1, state->left->left->reg2, state->left->right->tree->inst_ms_word);
MONO_EMIT_NEW_BRANCH_BLOCK (s, CEE_BGT, tree->inst_true_bb);
MONO_EMIT_NEW_BRANCH_BLOCK (s, CEE_BNE_UN, tree->inst_false_bb);
- MONO_EMIT_NEW_BIALU_IMM (s, OP_COMPARE_IMM, -1, state->left->left->reg1, state->left->right->tree->inst_c0);
+ MONO_EMIT_NEW_BIALU_IMM (s, OP_COMPARE_IMM, -1, state->left->left->reg1, state->left->right->tree->inst_ls_word);
MONO_EMIT_NEW_BRANCH_BLOCK (s, CEE_BGE_UN, tree->inst_true_bb);
}
@@ -350,10 +350,10 @@ stmt: CEE_BGE_UN (OP_COMPARE (lreg, lreg)) {
stmt: CEE_BGE_UN (OP_COMPARE (lreg, i8con)) {
- MONO_EMIT_NEW_BIALU_IMM (s, OP_COMPARE_IMM, -1, state->left->left->reg2, state->left->right->tree->inst_c1);
+ MONO_EMIT_NEW_BIALU_IMM (s, OP_COMPARE_IMM, -1, state->left->left->reg2, state->left->right->tree->inst_ms_word);
MONO_EMIT_NEW_BRANCH_BLOCK (s, CEE_BGT_UN, tree->inst_true_bb);
MONO_EMIT_NEW_BRANCH_BLOCK (s, CEE_BNE_UN, tree->inst_false_bb);
- MONO_EMIT_NEW_BIALU_IMM (s, OP_COMPARE_IMM, -1, state->left->left->reg1, state->left->right->tree->inst_c0);
+ MONO_EMIT_NEW_BIALU_IMM (s, OP_COMPARE_IMM, -1, state->left->left->reg1, state->left->right->tree->inst_ls_word);
MONO_EMIT_NEW_BRANCH_BLOCK (s, CEE_BGE_UN, tree->inst_true_bb);
}
@@ -368,10 +368,10 @@ stmt: CEE_BLT (OP_COMPARE (lreg, lreg)) {
stmt: CEE_BLT (OP_COMPARE (lreg, i8con)) {
- MONO_EMIT_NEW_BIALU_IMM (s, OP_COMPARE_IMM, -1, state->left->left->reg2, state->left->right->tree->inst_c1);
+ MONO_EMIT_NEW_BIALU_IMM (s, OP_COMPARE_IMM, -1, state->left->left->reg2, state->left->right->tree->inst_ms_word);
MONO_EMIT_NEW_BRANCH_BLOCK (s, CEE_BLT, tree->inst_true_bb);
MONO_EMIT_NEW_BRANCH_BLOCK (s, CEE_BNE_UN, tree->inst_false_bb);
- MONO_EMIT_NEW_BIALU_IMM (s, OP_COMPARE_IMM, -1, state->left->left->reg1, state->left->right->tree->inst_c0);
+ MONO_EMIT_NEW_BIALU_IMM (s, OP_COMPARE_IMM, -1, state->left->left->reg1, state->left->right->tree->inst_ls_word);
MONO_EMIT_NEW_BRANCH_BLOCK (s, CEE_BLT_UN, tree->inst_true_bb);
}
@@ -386,10 +386,10 @@ stmt: CEE_BLT_UN (OP_COMPARE (lreg, lreg)) {
stmt: CEE_BLT_UN (OP_COMPARE (lreg, i8con)) {
- MONO_EMIT_NEW_BIALU_IMM (s, OP_COMPARE_IMM, -1, state->left->left->reg2, state->left->right->tree->inst_c1);
+ MONO_EMIT_NEW_BIALU_IMM (s, OP_COMPARE_IMM, -1, state->left->left->reg2, state->left->right->tree->inst_ms_word);
MONO_EMIT_NEW_BRANCH_BLOCK (s, CEE_BLT_UN, tree->inst_true_bb);
MONO_EMIT_NEW_BRANCH_BLOCK (s, CEE_BNE_UN, tree->inst_false_bb);
- MONO_EMIT_NEW_BIALU_IMM (s, OP_COMPARE_IMM, -1, state->left->left->reg1, state->left->right->tree->inst_c0);
+ MONO_EMIT_NEW_BIALU_IMM (s, OP_COMPARE_IMM, -1, state->left->left->reg1, state->left->right->tree->inst_ls_word);
MONO_EMIT_NEW_BRANCH_BLOCK (s, CEE_BLT_UN, tree->inst_true_bb);
}
@@ -404,10 +404,10 @@ stmt: CEE_BGT (OP_COMPARE (lreg, lreg)) {
stmt: CEE_BGT (OP_COMPARE (lreg, i8con)) {
- MONO_EMIT_NEW_BIALU_IMM (s, OP_COMPARE_IMM, -1, state->left->left->reg2, state->left->right->tree->inst_c1);
+ MONO_EMIT_NEW_BIALU_IMM (s, OP_COMPARE_IMM, -1, state->left->left->reg2, state->left->right->tree->inst_ms_word);
MONO_EMIT_NEW_BRANCH_BLOCK (s, CEE_BGT, tree->inst_true_bb);
MONO_EMIT_NEW_BRANCH_BLOCK (s, CEE_BNE_UN, tree->inst_false_bb);
- MONO_EMIT_NEW_BIALU_IMM (s, OP_COMPARE_IMM, -1, state->left->left->reg1, state->left->right->tree->inst_c0);
+ MONO_EMIT_NEW_BIALU_IMM (s, OP_COMPARE_IMM, -1, state->left->left->reg1, state->left->right->tree->inst_ls_word);
MONO_EMIT_NEW_BRANCH_BLOCK (s, CEE_BGT_UN, tree->inst_true_bb);
}
@@ -422,10 +422,10 @@ stmt: CEE_BGT_UN (OP_COMPARE (lreg, lreg)) {
stmt: CEE_BGT_UN (OP_COMPARE (lreg, i8con)) {
- MONO_EMIT_NEW_BIALU_IMM (s, OP_COMPARE_IMM, -1, state->left->left->reg2, state->left->right->tree->inst_c1);
+ MONO_EMIT_NEW_BIALU_IMM (s, OP_COMPARE_IMM, -1, state->left->left->reg2, state->left->right->tree->inst_ms_word);
MONO_EMIT_NEW_BRANCH_BLOCK (s, CEE_BGT_UN, tree->inst_true_bb);
MONO_EMIT_NEW_BRANCH_BLOCK (s, CEE_BNE_UN, tree->inst_false_bb);
- MONO_EMIT_NEW_BIALU_IMM (s, OP_COMPARE_IMM, -1, state->left->left->reg1, state->left->right->tree->inst_c0);
+ MONO_EMIT_NEW_BIALU_IMM (s, OP_COMPARE_IMM, -1, state->left->left->reg1, state->left->right->tree->inst_ls_word);
MONO_EMIT_NEW_BRANCH_BLOCK (s, CEE_BGT_UN, tree->inst_true_bb);
}
@@ -511,7 +511,7 @@ lreg: OP_FCONV_TO_U8 (freg) {
}
reg: OP_LCONV_TO_I4 (i8con) {
- MONO_EMIT_NEW_ICONST (s, state->reg1, state->left->tree->inst_c0);
+ MONO_EMIT_NEW_ICONST (s, state->reg1, state->left->tree->inst_ls_word);
}
reg: OP_LCONV_TO_I4 (lreg) {
diff --git a/mono/mini/inssel-ppc.brg b/mono/mini/inssel-ppc.brg
index e2b7bb22721..85447734ee0 100644
--- a/mono/mini/inssel-ppc.brg
+++ b/mono/mini/inssel-ppc.brg
@@ -1,7 +1,7 @@
%%
#
-# inssel-x86.brg: burg file for special x86 instructions
+# inssel-ppc.brg: burg file for special ppc instructions
#
# Author:
# Dietmar Maurer (dietmar@ximian.com)
@@ -10,6 +10,27 @@
# (C) 2002 Ximian, Inc.
#
+stmt: OP_START_HANDLER {
+ MonoInst *spvar = mono_find_spvar_for_region (s, s->cbb->region);
+ /*MONO_EMIT_NEW_STORE_MEMBASE (s, OP_STORE_MEMBASE_REG, spvar->inst_basereg, spvar->inst_offset, ppc_sp);
+ */
+ tree->inst_left = spvar;
+ mono_bblock_add_inst (s->cbb, tree);
+}
+
+stmt: CEE_ENDFINALLY {
+ MonoInst *spvar = mono_find_spvar_for_region (s, s->cbb->region);
+ tree->inst_left = spvar;
+ mono_bblock_add_inst (s->cbb, tree);
+}
+
+stmt: OP_ENDFILTER (reg) {
+ MonoInst *spvar = mono_find_spvar_for_region (s, s->cbb->region);
+ tree->inst_left = spvar;
+ tree->sreg1 = state->left->reg1;
+ mono_bblock_add_inst (s->cbb, tree);
+}
+
stmt: CEE_STIND_I8 (OP_REGVAR, lreg) {
/* this should only happen for methods returning a long */
MONO_EMIT_NEW_UNALU (s, OP_MOVE, ppc_r3, state->right->reg1);
@@ -52,15 +73,17 @@ stmt: OP_SETRET (reg) {
}
stmt: OP_SETRET (lreg) {
- MONO_EMIT_NEW_UNALU (s, OP_MOVE, ppc_r3, state->left->reg2);
- tree->opcode = OP_MOVE;
+ tree->opcode = OP_SETLRET;
tree->sreg1 = state->left->reg1;
- tree->dreg = ppc_r4;
+ tree->sreg2 = state->left->reg2;
mono_bblock_add_inst (s->cbb, tree);
}
stmt: OP_SETRET (freg) {
- /* FIXME */
+ tree->opcode = OP_FMOVE;
+ tree->sreg1 = state->left->reg1;
+ tree->dreg = ppc_f1;
+ mono_bblock_add_inst (s->cbb, tree);
}
stmt: OP_SETRET (OP_ICONST) {
@@ -88,6 +111,7 @@ stmt: OP_OUTARG (lreg) {
MONO_EMIT_NEW_UNALU (s, OP_SETREG, tree->unused, state->left->reg2);
tree->opcode = OP_SETREG;
tree->dreg = tree->unused + 1;
+ tree->sreg1 = state->left->reg1;
mono_bblock_add_inst (s->cbb, tree);
}
@@ -140,29 +164,23 @@ stmt: OP_OUTARG (CEE_LDIND_REF (OP_REGVAR)) {
#}
stmt: OP_OUTARG (freg) {
- MONO_EMIT_NEW_BIALU_IMM (s, OP_SUB_IMM, X86_ESP, X86_ESP, 8);
- tree->opcode = OP_STORER8_MEMBASE_REG;
+ tree->opcode = OP_SETFREG;
tree->sreg1 = state->left->reg1;
- tree->inst_destbasereg = X86_ESP;
- tree->inst_offset = 0;
+ tree->dreg = tree->unused;
mono_bblock_add_inst (s->cbb, tree);
}
stmt: OP_OUTARG_R4 (freg) {
- MONO_EMIT_NEW_BIALU_IMM (s, OP_SUB_IMM, X86_ESP, X86_ESP, 4);
- tree->opcode = OP_STORER4_MEMBASE_REG;
+ tree->opcode = OP_SETFREG;
tree->sreg1 = state->left->reg1;
- tree->inst_destbasereg = X86_ESP;
- tree->inst_offset = 0;
+ tree->dreg = tree->unused;
mono_bblock_add_inst (s->cbb, tree);
}
stmt: OP_OUTARG_R8 (freg) {
- MONO_EMIT_NEW_BIALU_IMM (s, OP_SUB_IMM, X86_ESP, X86_ESP, 8);
- tree->opcode = OP_STORER8_MEMBASE_REG;
+ tree->opcode = OP_SETFREG;
tree->sreg1 = state->left->reg1;
- tree->inst_destbasereg = X86_ESP;
- tree->inst_offset = 0;
+ tree->dreg = tree->unused;
mono_bblock_add_inst (s->cbb, tree);
}
@@ -247,4 +265,45 @@ stmt: CEE_POP (freg) "0" {
/* nothing to do */
}
+freg: OP_LCONV_TO_R8 (lreg) {
+ /* nothing to do - emulated */
+}
+
+freg: OP_LCONV_TO_R4 (lreg) {
+ /* nothing to do - emulated */
+}
+
+freg: OP_LCONV_TO_R_UN (lreg) {
+ /* nothing to do - emulated */
+}
+
+freg: OP_FREM (freg, freg) {
+ /* nothing to do - emulated */
+}
+
+reg: OP_CEQ (OP_COMPARE (freg, freg)) {
+ MONO_EMIT_BIALU (s, tree, OP_FCEQ, state->reg1, state->left->left->reg1,
+ state->left->right->reg1);
+}
+
+reg: OP_CLT (OP_COMPARE (freg, freg)) {
+ MONO_EMIT_BIALU (s, tree, OP_FCLT, state->reg1, state->left->left->reg1,
+ state->left->right->reg1);
+}
+
+reg: OP_CLT_UN (OP_COMPARE (freg, freg)) {
+ MONO_EMIT_BIALU (s, tree, OP_FCLT_UN, state->reg1, state->left->left->reg1,
+ state->left->right->reg1);
+}
+
+reg: OP_CGT (OP_COMPARE (freg, freg)) {
+ MONO_EMIT_BIALU (s, tree, OP_FCGT, state->reg1, state->left->left->reg1,
+ state->left->right->reg1);
+}
+
+reg: OP_CGT_UN (OP_COMPARE (freg, freg)) {
+ MONO_EMIT_BIALU (s, tree, OP_FCGT_UN, state->reg1, state->left->left->reg1,
+ state->left->right->reg1);
+}
+
%%
diff --git a/mono/mini/inssel-x86.brg b/mono/mini/inssel-x86.brg
index 1765fc054ad..8187d035b93 100644
--- a/mono/mini/inssel-x86.brg
+++ b/mono/mini/inssel-x86.brg
@@ -574,4 +574,14 @@ stmt: CEE_POP (freg) "0" {
MONO_EMIT_UNALU (s, tree, OP_X86_FPOP, -1, state->left->reg1);
}
+# override the rules in inssel-float.brg that work for machines with FP registers
+
+freg: OP_FCONV_TO_R8 (freg) "0" {
+ /* nothing to do */
+}
+
+freg: OP_FCONV_TO_R4 (freg) "0" {
+ /* fixme: nothing to do ??*/
+}
+
%%
diff --git a/mono/mini/inssel.brg b/mono/mini/inssel.brg
index a37aa9e4a30..b0487335657 100644
--- a/mono/mini/inssel.brg
+++ b/mono/mini/inssel.brg
@@ -1071,25 +1071,12 @@ lreg: OP_LCALL_REG (reg) {
}
stmt: OP_VCALL (reg) {
- MonoInst *vtarg;
- /* FIXME: this is actually arch-specific... */
- MONO_INST_NEW (s, vtarg, OP_OUTARG);
- vtarg->inst_left = state->left->tree;
- vtarg->type = STACK_MP;
- vtarg->sreg1 = state->left->reg1;
- mono_bblock_add_inst (s->cbb, vtarg);
-
+ mono_arch_emit_this_vret_args (s, (MonoCallInst*)tree, -1, -1, state->left->reg1);
mono_bblock_add_inst (s->cbb, tree);
}
stmt: OP_VCALL_REG (reg, reg) {
- MonoInst *vtarg;
- /* FIXME: this is actually arch-specific... */
- MONO_INST_NEW (s, vtarg, OP_OUTARG);
- vtarg->inst_left = state->right->tree;
- vtarg->type = STACK_MP;
- vtarg->sreg1 = state->right->reg1;
- mono_bblock_add_inst (s->cbb, vtarg);
+ mono_arch_emit_this_vret_args (s, (MonoCallInst*)tree, -1, -1, state->right->reg1);
tree->sreg1 = state->left->reg1;
mono_bblock_add_inst (s->cbb, tree);
@@ -1184,10 +1171,7 @@ stmt: CEE_THROW (reg) {
}
stmt: OP_THROW_OR_NULL (reg) {
- MonoClass *klass = tree->inst_newa_class;
- MonoInst *object_is_null, *end_label, *false_label;
- int obj_reg = state->left->reg1;
- int vtable_reg = mono_regstate_next_int (s->rs);
+ MonoInst *object_is_null;
MONO_NEW_LABEL (s, object_is_null);
@@ -1643,7 +1627,7 @@ stmt: CEE_MKREFANY (OP_GROUP (reg, OP_ICONST), reg) {
int const_reg = mono_regstate_next_int (s->rs);
int type_reg = mono_regstate_next_int (s->rs);
MONO_EMIT_NEW_CLASSCONST (s, const_reg, klass);
- MONO_EMIT_NEW_STORE_MEMBASE (s, OP_STOREI4_MEMBASE_REG, state->right->reg1, G_STRUCT_OFFSET (MonoTypedRef, type), const_reg);
+ MONO_EMIT_NEW_STORE_MEMBASE (s, OP_STOREI4_MEMBASE_REG, state->right->reg1, G_STRUCT_OFFSET (MonoTypedRef, klass), const_reg);
MONO_EMIT_NEW_BIALU_IMM (s, OP_ADD_IMM, type_reg, const_reg, G_STRUCT_OFFSET (MonoClass, byval_arg));
MONO_EMIT_NEW_STORE_MEMBASE (s, OP_STOREI4_MEMBASE_REG, state->right->reg1, G_STRUCT_OFFSET (MonoTypedRef, type), type_reg);
}
@@ -1741,26 +1725,12 @@ mini_emit_load_intf_reg_class (MonoCompile *s, int intf_reg, int klass_reg, Mono
void
mini_emit_virtual_call (MonoCompile *cfg, void *st, MonoInst *tree, int novirtop, int virtop)
{
- MonoInst *this, *vtarg;
MonoMethod *method = ((MonoCallInst*)tree)->method;
- int vtable_reg, slot_reg;
+ int vtable_reg, slot_reg, this_reg;
MBState *state = st;
- /* add the this argument */
- MONO_INST_NEW (cfg, this, OP_OUTARG);
- this->inst_left = state->left->tree;
- this->type = this->inst_left->type;
- this->sreg1 = state->left->reg1;
- mono_bblock_add_inst (cfg->cbb, this);
-
- if (novirtop == OP_VCALL) {
- /* FIXME: this is actually arch-specific... */
- MONO_INST_NEW (cfg, vtarg, OP_OUTARG);
- vtarg->inst_left = state->right->tree;
- vtarg->type = STACK_MP;
- vtarg->sreg1 = state->right->reg1;
- mono_bblock_add_inst (cfg->cbb, vtarg);
- }
+ this_reg = state->left->reg1;
+ mono_arch_emit_this_vret_args (cfg, (MonoCallInst*)tree, this_reg, state->left->tree->type, novirtop == OP_VCALL? state->right->reg1: -1);
if (!(method->flags & METHOD_ATTRIBUTE_VIRTUAL) ||
((method->flags & METHOD_ATTRIBUTE_FINAL) &&
@@ -1774,7 +1744,7 @@ mini_emit_virtual_call (MonoCompile *cfg, void *st, MonoInst *tree, int novirtop
}
if (!method->string_ctor)
- MONO_EMIT_NEW_UNALU (cfg, OP_CHECK_THIS, -1, this->sreg1);
+ MONO_EMIT_NEW_UNALU (cfg, OP_CHECK_THIS, -1, this_reg);
tree->dreg = state->reg1;
tree->opcode = novirtop;
@@ -1783,7 +1753,7 @@ mini_emit_virtual_call (MonoCompile *cfg, void *st, MonoInst *tree, int novirtop
}
vtable_reg = mono_regstate_next_int (cfg->rs);
- MONO_EMIT_NEW_LOAD_MEMBASE (cfg, vtable_reg, this->sreg1, G_STRUCT_OFFSET (MonoObject, vtable));
+ MONO_EMIT_NEW_LOAD_MEMBASE (cfg, vtable_reg, this_reg, G_STRUCT_OFFSET (MonoObject, vtable));
if (method->klass->flags & TYPE_ATTRIBUTE_INTERFACE) {
slot_reg = mono_regstate_next_int (cfg->rs);
mini_emit_load_intf_reg_vtable (cfg, slot_reg, vtable_reg, method->klass);
diff --git a/mono/mini/jit-icalls.c b/mono/mini/jit-icalls.c
index 9dffa6f899c..f5363c6177e 100644
--- a/mono/mini/jit-icalls.c
+++ b/mono/mini/jit-icalls.c
@@ -80,8 +80,12 @@ mono_llmult (gint64 a, gint64 b)
}
static guint64
-mono_llmult_ovf_un (guint32 al, guint32 ah, guint32 bl, guint32 bh)
+mono_llmult_ovf_un (guint64 a, guint64 b)
{
+ guint32 al = a;
+ guint32 ah = a >> 32;
+ guint32 bl = b;
+ guint32 bh = b >> 32;
guint64 res, t1;
MONO_ARCH_SAVE_REGS;
@@ -109,8 +113,12 @@ mono_llmult_ovf_un (guint32 al, guint32 ah, guint32 bl, guint32 bh)
static guint64
-mono_llmult_ovf (guint32 al, gint32 ah, guint32 bl, gint32 bh)
+mono_llmult_ovf (gint64 a, gint64 b)
{
+ guint32 al = a;
+ gint32 ah = a >> 32;
+ guint32 bl = b;
+ gint32 bh = b >> 32;
/*
Use Karatsuba algorithm where:
a*b is: AhBh(R^2+R)+(Ah-Al)(Bl-Bh)R+AlBl(R+1)
@@ -363,10 +371,10 @@ mono_class_static_field_address (MonoDomain *domain, MonoClassField *field)
//printf ("SFLDA1 %p\n", (char*)vtable->data + field->offset);
- if (!domain->thread_static_fields || !(addr = g_hash_table_lookup (domain->thread_static_fields, field)))
- addr = (char*)vtable->data + field->offset;
+ if (domain->special_static_fields && (addr = g_hash_table_lookup (domain->special_static_fields, field)))
+ addr = mono_get_special_static_data (GPOINTER_TO_UINT (addr));
else
- addr = mono_threads_get_static_data (GPOINTER_TO_UINT (addr));
+ addr = (char*)vtable->data + field->offset;
return addr;
}
@@ -391,6 +399,15 @@ mono_fconv_u8 (double v)
return (guint64)v;
}
+#ifdef MONO_ARCH_EMULATE_FCONV_TO_I8
+static gint64
+mono_fconv_i8 (double v)
+{
+ /* no need, no exceptions: MONO_ARCH_SAVE_REGS;*/
+ return (gint64)v;
+}
+#endif
+
static guint32
mono_fconv_u4 (double v)
{
@@ -427,3 +444,28 @@ mono_fconv_ovf_u8 (double v)
}
return res;
}
+
+#ifdef MONO_ARCH_EMULATE_LCONV_TO_R8
+static double
+mono_lconv_to_r8 (gint64 a)
+{
+ return (double)a;
+}
+#endif
+
+#ifdef MONO_ARCH_EMULATE_LCONV_TO_R4
+static float
+mono_lconv_to_r4 (gint64 a)
+{
+ return (float)a;
+}
+#endif
+
+#ifdef MONO_ARCH_EMULATE_LCONV_TO_R8_UN
+static double
+mono_lconv_to_r8_un (guint64 a)
+{
+ return (double)a;
+}
+#endif
+
diff --git a/mono/mini/mini-ops.h b/mono/mini/mini-ops.h
index 2bffc9be8fd..96830316905 100644
--- a/mono/mini/mini-ops.h
+++ b/mono/mini/mini-ops.h
@@ -80,6 +80,7 @@ MINI_OP(OP_LOADR4_MEMBASE,"loadr4_membase")
MINI_OP(OP_LOADR8_MEMBASE,"loadr8_membase")
MINI_OP(OP_LOADU4_MEM,"loadu4_mem")
MINI_OP(OP_MOVE, "move")
+MINI_OP(OP_FMOVE, "fmove")
MINI_OP(OP_ADD_IMM, "add_imm")
MINI_OP(OP_SUB_IMM, "sub_imm")
diff --git a/mono/mini/mini-ppc.c b/mono/mini/mini-ppc.c
index 24444fa891b..9414cd61c91 100644
--- a/mono/mini/mini-ppc.c
+++ b/mono/mini/mini-ppc.c
@@ -124,7 +124,11 @@ enter_method (MonoMethod *method, char *ebp)
indent (1);
printf ("ENTER: %s(", fname);
g_free (fname);
-
+
+ if (!ebp) {
+ printf (") ip: %p\n", __builtin_return_address (1));
+ return;
+ }
if (((int)ebp & (MONO_ARCH_FRAME_ALIGNMENT - 1)) != 0) {
g_error ("unaligned stack detected (%p)", ebp);
}
@@ -346,7 +350,7 @@ handle_enum:
printf ("(unknown return type %x)", method->signature->ret->type);
}
- printf ("\n");
+ printf (" ip: %p\n", __builtin_return_address (1));
}
/*
@@ -480,15 +484,23 @@ mono_arch_flush_icache (guint8 *code, gint size)
#define STACK_PARAM_OFFSET 8
#endif
+enum {
+ RegTypeGeneral,
+ RegTypeBase,
+ RegTypeFP
+};
+
typedef struct {
gint16 offset;
gint8 reg;
- gint8 regtype; /* 0 general, 1 basereg, 2 floating point register */
+ guint8 regtype : 2; /* 0 general, 1 basereg, 2 floating point register */
+ guint8 size : 6; /* 1, 2, 4, 8 */
} ArgInfo;
typedef struct {
int nargs;
guint32 stack_usage;
+ guint32 struct_ret;
ArgInfo ret;
ArgInfo args [1];
} CallInfo;
@@ -502,7 +514,7 @@ add_general (guint *gr, guint *stack_size, ArgInfo *ainfo, gboolean simple)
if (*gr >= 3 + GENERAL_REGS) {
ainfo->offset = *stack_size;
ainfo->reg = ppc_sp; /* in the caller */
- ainfo->regtype = 1;
+ ainfo->regtype = RegTypeBase;
*stack_size += 4;
} else {
ALWAYS_ON_STACK (*stack_size += 4);
@@ -512,7 +524,7 @@ add_general (guint *gr, guint *stack_size, ArgInfo *ainfo, gboolean simple)
if (*gr >= 3 + GENERAL_REGS - 1) {
ainfo->offset = *stack_size;
ainfo->reg = ppc_sp; /* in the caller */
- ainfo->regtype = 1;
+ ainfo->regtype = RegTypeBase;
*stack_size += 8;
#ifdef ALIGN_DOUBLES
*stack_size += (*stack_size % 8);
@@ -543,6 +555,10 @@ calculate_sizes (MonoMethodSignature *sig, gboolean is_pinvoke)
gr = 3;
/* FIXME: handle returning a struct */
+ if (MONO_TYPE_ISSTRUCT (sig->ret)) {
+ add_general (&gr, &stack_size, &cinfo->ret, TRUE);
+ cinfo->struct_ret = ppc_r3;
+ }
n = 0;
if (sig->hasthis) {
@@ -562,13 +578,25 @@ calculate_sizes (MonoMethodSignature *sig, gboolean is_pinvoke)
enum_calc_size:
switch (simpletype) {
case MONO_TYPE_BOOLEAN:
- case MONO_TYPE_CHAR:
case MONO_TYPE_I1:
case MONO_TYPE_U1:
+ cinfo->args [n].size = 1;
+ add_general (&gr, &stack_size, cinfo->args + n, TRUE);
+ n++;
+ break;
+ case MONO_TYPE_CHAR:
case MONO_TYPE_I2:
case MONO_TYPE_U2:
+ cinfo->args [n].size = 2;
+ add_general (&gr, &stack_size, cinfo->args + n, TRUE);
+ n++;
+ break;
case MONO_TYPE_I4:
case MONO_TYPE_U4:
+ cinfo->args [n].size = 4;
+ add_general (&gr, &stack_size, cinfo->args + n, TRUE);
+ n++;
+ break;
case MONO_TYPE_I:
case MONO_TYPE_U:
case MONO_TYPE_PTR:
@@ -577,6 +605,7 @@ calculate_sizes (MonoMethodSignature *sig, gboolean is_pinvoke)
case MONO_TYPE_STRING:
case MONO_TYPE_SZARRAY:
case MONO_TYPE_ARRAY:
+ cinfo->args [n].size = sizeof (gpointer);
add_general (&gr, &stack_size, cinfo->args + n, TRUE);
n++;
break;
@@ -586,31 +615,24 @@ calculate_sizes (MonoMethodSignature *sig, gboolean is_pinvoke)
simpletype = sig->params [i]->data.klass->enum_basetype->type;
goto enum_calc_size;
}
-#if 0
size = mono_class_value_size (sig->params [i]->data.klass, NULL);
- if (size != 4) {
- DEBUG(printf ("copy %d bytes struct on stack\n",
- mono_class_value_size (sig->params [i]->data.klass, NULL)));
- *stack_size += (size + 3) & (~3);
- if (gr > 3 + GENERAL_REGS) {
- *stack_size += 4;
- }
- } else {
- DEBUG(printf ("load %d bytes struct\n",
- mono_class_value_size (sig->params [i]->data.klass, NULL)));
- add_general (&gr, stack_size, code_size, TRUE);
- }
-#endif
- g_assert_not_reached ();
+ DEBUG(printf ("load %d bytes struct\n",
+ mono_class_value_size (sig->params [i]->data.klass, NULL)));
+ add_general (&gr, &stack_size, cinfo->args + n, TRUE);
+ n++;
break;
}
case MONO_TYPE_U8:
case MONO_TYPE_I8:
+ cinfo->args [n].size = 8;
add_general (&gr, &stack_size, cinfo->args + n, FALSE);
n++;
break;
case MONO_TYPE_R4:
+ cinfo->args [n].size = 4;
if (fr < 7) {
+ cinfo->args [n].regtype = RegTypeFP;
+ cinfo->args [n].reg = fr;
fr ++;
FP_ALSO_IN_REG (gr ++);
ALWAYS_ON_STACK (stack_size += 4);
@@ -620,7 +642,10 @@ calculate_sizes (MonoMethodSignature *sig, gboolean is_pinvoke)
n++;
break;
case MONO_TYPE_R8:
+ cinfo->args [n].size = 8;
if (fr < 7) {
+ cinfo->args [n].regtype = RegTypeFP;
+ cinfo->args [n].reg = fr;
fr ++;
FP_ALSO_IN_REG (gr += 2);
ALWAYS_ON_STACK (stack_size += 8);
@@ -662,7 +687,7 @@ enum_retvalue:
case MONO_TYPE_R4:
case MONO_TYPE_R8:
cinfo->ret.reg = ppc_f1;
- cinfo->ret.regtype = 2;
+ cinfo->ret.regtype = RegTypeFP;
break;
case MONO_TYPE_VALUETYPE:
if (sig->ret->data.klass->enumtype) {
@@ -728,7 +753,7 @@ mono_arch_allocate_vars (MonoCompile *m)
* also note that if the function uses alloca, we use ppc_r31
* to point at the local variables.
*/
- offset = 24; /* linkage area */
+ offset = PPC_MINIMAL_STACK_SIZE; /* linkage area */
/* align the offset to 16 bytes: not sure this is needed here */
//offset += 16 - 1;
//offset &= ~(16 - 1);
@@ -754,6 +779,15 @@ mono_arch_allocate_vars (MonoCompile *m)
mono_exc_esp_offset = offset;
#endif
+ if (MONO_TYPE_ISSTRUCT (sig->ret)) {
+ inst = m->ret;
+ offset += sizeof(gpointer) - 1;
+ offset &= ~(sizeof(gpointer) - 1);
+ inst->inst_offset = offset;
+ inst->opcode = OP_REGOFFSET;
+ inst->inst_basereg = frame_reg;
+ offset += sizeof(gpointer);
+ }
curinst = m->locals_start;
for (i = curinst; i < m->num_varinfo; ++i) {
inst = m->varinfo [i];
@@ -837,12 +871,15 @@ mono_arch_call_opcode (MonoCompile *cfg, MonoBasicBlock* bb, MonoCallInst *call,
n = sig->param_count + sig->hasthis;
cinfo = calculate_sizes (sig, sig->pinvoke);
+ if (cinfo->struct_ret)
+ call->used_iregs |= 1 << cinfo->struct_ret;
for (i = 0; i < n; ++i) {
ainfo = cinfo->args + i;
if (is_virtual && i == 0) {
/* the argument will be attached to the call instrucion */
in = call->args [i];
+ call->used_iregs |= 1 << ainfo->reg;
} else {
MONO_INST_NEW (cfg, arg, OP_OUTARG);
in = call->args [i];
@@ -852,12 +889,14 @@ mono_arch_call_opcode (MonoCompile *cfg, MonoBasicBlock* bb, MonoCallInst *call,
/* prepend, we'll need to reverse them later */
arg->next = call->out_args;
call->out_args = arg;
- if (ainfo->regtype == 0) {
+ if (ainfo->regtype == RegTypeGeneral) {
arg->unused = ainfo->reg;
call->used_iregs |= 1 << ainfo->reg;
- } else if (ainfo->regtype == 1) {
+ if (arg->type == STACK_I8)
+ call->used_iregs |= 1 << (ainfo->reg + 1);
+ } else if (ainfo->regtype == RegTypeBase) {
g_assert_not_reached ();
- } else if (ainfo->regtype == 2) {
+ } else if (ainfo->regtype == RegTypeFP) {
arg->opcode = OP_OUTARG_R8;
arg->unused = ainfo->reg;
call->used_fregs |= 1 << ainfo->reg;
@@ -877,6 +916,7 @@ mono_arch_call_opcode (MonoCompile *cfg, MonoBasicBlock* bb, MonoCallInst *call,
prev = list;
list = next;
}
+ call->out_args = prev;
}
call->stack_usage = cinfo->stack_usage;
cfg->param_area = MAX (cfg->param_area, cinfo->stack_usage);
@@ -910,14 +950,12 @@ void*
mono_arch_instrument_prolog (MonoCompile *cfg, void *func, void *p, gboolean enable_arguments)
{
guchar *code = p;
-#if 0
- /* if some args are passed in registers, we need to save them here */
- x86_push_reg (code, X86_EBP);
- x86_push_imm (code, cfg->method);
- mono_add_patch_info (cfg, code-cfg->native_code, MONO_PATCH_INFO_ABS, func);
- x86_call_code (code, 0);
- x86_alu_reg_imm (code, X86_ADD, X86_ESP, 8);
-#endif
+
+ ppc_load (code, ppc_r3, cfg->method);
+ ppc_li (code, ppc_r4, 0); /* NULL ebp for now */
+ ppc_load (code, ppc_r0, func);
+ ppc_mtlr (code, ppc_r0);
+ ppc_blrl (code);
return code;
}
@@ -933,7 +971,7 @@ void*
mono_arch_instrument_epilog (MonoCompile *cfg, void *func, void *p, gboolean enable_arguments)
{
guchar *code = p;
- int arg_size = 0, save_mode = SAVE_NONE;
+ int save_mode = SAVE_NONE;
MonoMethod *method = cfg->method;
int rtype = method->signature->ret->type;
@@ -968,34 +1006,30 @@ handle_enum:
switch (save_mode) {
case SAVE_TWO:
- //x86_push_reg (code, X86_EDX);
- //x86_push_reg (code, X86_EAX);
+ ppc_stw (code, ppc_r3, cfg->stack_usage - 8, cfg->frame_reg);
+ ppc_stw (code, ppc_r4, cfg->stack_usage - 4, cfg->frame_reg);
if (enable_arguments) {
- //x86_push_reg (code, X86_EDX);
- //x86_push_reg (code, X86_EAX);
- arg_size = 8;
+ ppc_mr (code, ppc_r5, ppc_r4);
+ ppc_mr (code, ppc_r4, ppc_r3);
}
break;
case SAVE_ONE:
- //x86_push_reg (code, X86_EAX);
+ ppc_stw (code, ppc_r3, cfg->stack_usage - 8, cfg->frame_reg);
if (enable_arguments) {
- //x86_push_reg (code, X86_EAX);
- arg_size = 4;
+ ppc_mr (code, ppc_r4, ppc_r3);
}
break;
case SAVE_FP:
- //x86_alu_reg_imm (code, X86_SUB, X86_ESP, 8);
- ///x86_fst_membase (code, X86_ESP, 0, TRUE, TRUE);
+ ppc_stfd (code, ppc_f1, cfg->stack_usage - 8, cfg->frame_reg);
if (enable_arguments) {
- //x86_alu_reg_imm (code, X86_SUB, X86_ESP, 8);
- //x86_fst_membase (code, X86_ESP, 0, TRUE, TRUE);
- arg_size = 8;
+ /* FIXME: what reg? */
+ ppc_fmr (code, ppc_f3, ppc_f1);
}
break;
case SAVE_STRUCT:
if (enable_arguments) {
- //x86_push_membase (code, X86_EBP, 8);
- arg_size = 4;
+ /* FIXME: get the actual address */
+ ppc_mr (code, ppc_r4, ppc_r3);
}
break;
case SAVE_NONE:
@@ -1003,23 +1037,21 @@ handle_enum:
break;
}
- /*x86_push_imm (code, method);
- mono_add_patch_info (cfg, code-cfg->native_code, MONO_PATCH_INFO_ABS, func);
- x86_call_code (code, 0);
- x86_alu_reg_imm (code, X86_ADD, X86_ESP, arg_size + 4);
- */
+ ppc_load (code, ppc_r3, cfg->method);
+ ppc_load (code, ppc_r0, func);
+ ppc_mtlr (code, ppc_r0);
+ ppc_blrl (code);
switch (save_mode) {
case SAVE_TWO:
- //x86_pop_reg (code, X86_EAX);
- //x86_pop_reg (code, X86_EDX);
+ ppc_lwz (code, ppc_r3, cfg->stack_usage - 8, cfg->frame_reg);
+ ppc_lwz (code, ppc_r4, cfg->stack_usage - 4, cfg->frame_reg);
break;
case SAVE_ONE:
- //x86_pop_reg (code, X86_EAX);
+ ppc_lwz (code, ppc_r3, cfg->stack_usage - 8, cfg->frame_reg);
break;
case SAVE_FP:
- //x86_fld_membase (code, X86_ESP, 0, TRUE);
- //x86_alu_reg_imm (code, X86_ADD, X86_ESP, 8);
+ ppc_lfd (code, ppc_f1, cfg->stack_usage - 8, cfg->frame_reg);
break;
case SAVE_NONE:
default:
@@ -1252,10 +1284,73 @@ branch_b1_table [] = {
PPC_BR_LT
};
+/*
+ * returns the offset used by spillvar. It allocates a new
+ * spill variable if necessary.
+ */
+static int
+mono_spillvar_offset (MonoCompile *cfg, int spillvar)
+{
+ MonoSpillInfo **si, *info;
+ int i = 0;
+
+ si = &cfg->spill_info;
+
+ while (i <= spillvar) {
+
+ if (!*si) {
+ *si = info = mono_mempool_alloc (cfg->mempool, sizeof (MonoSpillInfo));
+ info->next = NULL;
+ info->offset = cfg->stack_offset;
+ cfg->stack_offset += sizeof (gpointer);
+ }
+
+ if (i == spillvar)
+ return (*si)->offset;
+
+ i++;
+ si = &(*si)->next;
+ }
+
+ g_assert_not_reached ();
+ return 0;
+}
+
+static int
+mono_spillvar_offset_float (MonoCompile *cfg, int spillvar)
+{
+ MonoSpillInfo **si, *info;
+ int i = 0;
+
+ si = &cfg->spill_info_float;
+
+ while (i <= spillvar) {
+
+ if (!*si) {
+ *si = info = mono_mempool_alloc (cfg->mempool, sizeof (MonoSpillInfo));
+ info->next = NULL;
+ cfg->stack_offset += 7;
+ cfg->stack_offset &= ~7;
+ info->offset = cfg->stack_offset;
+ cfg->stack_offset += sizeof (double);
+ }
+
+ if (i == spillvar)
+ return (*si)->offset;
+
+ i++;
+ si = &(*si)->next;
+ }
+
+ g_assert_not_reached ();
+ return 0;
+}
+
#undef DEBUG
#define DEBUG(a) if (cfg->verbose_level > 1) a
//#define DEBUG(a)
#define reg_is_freeable(r) ((r) >= 3 && (r) <= 10)
+#define freg_is_freeable(r) ((r) >= 1 && (r) <= 14)
typedef struct {
int born_in;
@@ -1427,6 +1522,66 @@ get_register_spilling (MonoCompile *cfg, InstList *item, MonoInst *ins, guint32
return sel;
}
+static int
+get_float_register_spilling (MonoCompile *cfg, InstList *item, MonoInst *ins, guint32 regmask, int reg)
+{
+ MonoInst *load;
+ int i, sel, spill;
+
+ DEBUG (g_print ("start regmask to assign R%d: 0x%08x (R%d <- R%d R%d)\n", reg, regmask, ins->dreg, ins->sreg1, ins->sreg2));
+ /* exclude the registers in the current instruction */
+ if (reg != ins->sreg1 && (freg_is_freeable (ins->sreg1) || (ins->sreg1 >= MONO_MAX_FREGS && cfg->rs->fassign [ins->sreg1] >= 0))) {
+ if (ins->sreg1 >= MONO_MAX_FREGS)
+ regmask &= ~ (1 << cfg->rs->fassign [ins->sreg1]);
+ else
+ regmask &= ~ (1 << ins->sreg1);
+ DEBUG (g_print ("excluding sreg1 %s\n", mono_arch_regname (ins->sreg1)));
+ }
+ if (reg != ins->sreg2 && (freg_is_freeable (ins->sreg2) || (ins->sreg2 >= MONO_MAX_FREGS && cfg->rs->fassign [ins->sreg2] >= 0))) {
+ if (ins->sreg2 >= MONO_MAX_FREGS)
+ regmask &= ~ (1 << cfg->rs->fassign [ins->sreg2]);
+ else
+ regmask &= ~ (1 << ins->sreg2);
+ DEBUG (g_print ("excluding sreg2 %s %d\n", mono_arch_regname (ins->sreg2), ins->sreg2));
+ }
+ if (reg != ins->dreg && freg_is_freeable (ins->dreg)) {
+ regmask &= ~ (1 << ins->dreg);
+ DEBUG (g_print ("excluding dreg %s\n", mono_arch_regname (ins->dreg)));
+ }
+
+ DEBUG (g_print ("available regmask: 0x%08x\n", regmask));
+ g_assert (regmask); /* need at least a register we can free */
+ sel = -1;
+ /* we should track prev_use and spill the register that's farther */
+ for (i = 0; i < MONO_MAX_FREGS; ++i) {
+ if (regmask & (1 << i)) {
+ sel = i;
+ DEBUG (g_print ("selected register %s has assignment %d\n", mono_arch_regname (sel), cfg->rs->fassign [sel]));
+ break;
+ }
+ }
+ i = cfg->rs->fsymbolic [sel];
+ spill = ++cfg->spill_count;
+ cfg->rs->fassign [i] = -spill - 1;
+ mono_regstate_free_float(cfg->rs, sel);
+ /* we need to create a spill var and insert a load to sel after the current instruction */
+ MONO_INST_NEW (cfg, load, OP_LOADR8_MEMBASE);
+ load->dreg = sel;
+ load->inst_basereg = cfg->frame_reg;
+ load->inst_offset = mono_spillvar_offset_float (cfg, spill);
+ if (item->prev) {
+ while (ins->next != item->prev->data)
+ ins = ins->next;
+ }
+ load->next = ins->next;
+ ins->next = load;
+ DEBUG (g_print ("SPILLED LOAD (%d at 0x%08x(%%sp)) R%d (freed %s)\n", spill, load->inst_offset, i, mono_arch_regname (sel)));
+ i = mono_regstate_alloc_float (cfg->rs, 1 << sel);
+ g_assert (i == sel);
+
+ return sel;
+}
+
static MonoInst*
create_copy_ins (MonoCompile *cfg, int dest, int src, MonoInst *ins)
{
@@ -1443,12 +1598,27 @@ create_copy_ins (MonoCompile *cfg, int dest, int src, MonoInst *ins)
}
static MonoInst*
+create_copy_ins_float (MonoCompile *cfg, int dest, int src, MonoInst *ins)
+{
+ MonoInst *copy;
+ MONO_INST_NEW (cfg, copy, OP_FMOVE);
+ copy->dreg = dest;
+ copy->sreg1 = src;
+ if (ins) {
+ copy->next = ins->next;
+ ins->next = copy;
+ }
+ DEBUG (g_print ("\tforced copy from %s to %s\n", mono_arch_regname (src), mono_arch_regname (dest)));
+ return copy;
+}
+
+static MonoInst*
create_spilled_store (MonoCompile *cfg, int spill, int reg, int prev_reg, MonoInst *ins)
{
MonoInst *store;
MONO_INST_NEW (cfg, store, OP_STORE_MEMBASE_REG);
store->sreg1 = reg;
- store->inst_destbasereg = ppc_r1;
+ store->inst_destbasereg = cfg->frame_reg;
store->inst_offset = mono_spillvar_offset (cfg, spill);
if (ins) {
store->next = ins->next;
@@ -1458,6 +1628,22 @@ create_spilled_store (MonoCompile *cfg, int spill, int reg, int prev_reg, MonoIn
return store;
}
+static MonoInst*
+create_spilled_store_float (MonoCompile *cfg, int spill, int reg, int prev_reg, MonoInst *ins)
+{
+ MonoInst *store;
+ MONO_INST_NEW (cfg, store, OP_STORER8_MEMBASE_REG);
+ store->sreg1 = reg;
+ store->inst_destbasereg = cfg->frame_reg;
+ store->inst_offset = mono_spillvar_offset_float (cfg, spill);
+ if (ins) {
+ store->next = ins->next;
+ ins->next = store;
+ }
+ DEBUG (g_print ("SPILLED STORE (%d at 0x%08x(%%sp)) R%d (from %s)\n", spill, store->inst_offset, prev_reg, mono_arch_regname (reg)));
+ return store;
+}
+
static void
insert_before_ins (MonoInst *ins, InstList *item, MonoInst* to_insert)
{
@@ -1498,8 +1684,9 @@ alloc_int_reg (MonoCompile *cfg, InstList *curinst, MonoInst *ins, int sym_reg,
return val;
}
-/* use ppc_r3-ppc_310 as temp registers */
-#define PPC_CALLER_REGS (0xf<<3)
+/* use ppc_r3-ppc_10 as temp registers */
+#define PPC_CALLER_REGS (0xff<<3)
+#define PPC_CALLER_FREGS (0xff<<2)
/*
* Local register allocation.
@@ -1513,12 +1700,13 @@ mono_arch_local_regalloc (MonoCompile *cfg, MonoBasicBlock *bb)
{
MonoInst *ins;
MonoRegState *rs = cfg->rs;
- int i, val, fpcount;
+ int i, val;
RegTrack *reginfo, *reginfof;
RegTrack *reginfo1, *reginfo2, *reginfod;
InstList *tmp, *reversed = NULL;
const char *spec;
guint32 src1_mask, src2_mask, dest_mask;
+ guint32 cur_iregs, cur_fregs;
if (!bb->code)
return;
@@ -1528,15 +1716,19 @@ mono_arch_local_regalloc (MonoCompile *cfg, MonoBasicBlock *bb)
reginfo = mono_mempool_alloc0 (cfg->mempool, sizeof (RegTrack) * rs->next_vireg);
reginfof = mono_mempool_alloc0 (cfg->mempool, sizeof (RegTrack) * rs->next_vfreg);
rs->ifree_mask = PPC_CALLER_REGS;
+ rs->ffree_mask = PPC_CALLER_FREGS;
ins = bb->code;
i = 1;
- fpcount = 0; /* FIXME: track fp stack utilization */
DEBUG (g_print ("LOCAL regalloc: basic block: %d\n", bb->block_num));
/* forward pass on the instructions to collect register liveness info */
while (ins) {
spec = ins_spec [ins->opcode];
DEBUG (print_ins (i, ins));
+ if (spec [MONO_INST_CLOB] == 'c') {
+ MonoCallInst * call = (MonoCallInst*)ins;
+ int j;
+ }
if (spec [MONO_INST_SRC1]) {
if (spec [MONO_INST_SRC1] == 'f')
reginfo1 = reginfof;
@@ -1583,19 +1775,71 @@ mono_arch_local_regalloc (MonoCompile *cfg, MonoBasicBlock *bb)
ins = ins->next;
}
+ cur_iregs = PPC_CALLER_REGS;
+ cur_fregs = PPC_CALLER_FREGS;
+
DEBUG (print_regtrack (reginfo, rs->next_vireg));
DEBUG (print_regtrack (reginfof, rs->next_vfreg));
tmp = reversed;
while (tmp) {
int prev_dreg, prev_sreg1, prev_sreg2;
- dest_mask = src1_mask = src2_mask = PPC_CALLER_REGS;
--i;
ins = tmp->data;
spec = ins_spec [ins->opcode];
DEBUG (g_print ("processing:"));
DEBUG (print_ins (i, ins));
+ /* make the register available for allocation: FIXME add fp reg */
+ if (ins->opcode == OP_SETREG) {
+ cur_iregs |= 1 << ins->dreg;
+ DEBUG (g_print ("adding %d to cur_iregs\n", ins->dreg));
+ } else if (ins->opcode == OP_SETFREG) {
+ cur_fregs |= 1 << ins->dreg;
+ DEBUG (g_print ("adding %d to cur_fregs\n", ins->dreg));
+ } else if (spec [MONO_INST_CLOB] == 'c') {
+ MonoCallInst *cinst = (MonoCallInst*)ins;
+ DEBUG (g_print ("excluding regs 0x%x from cur_iregs (0x%x)\n", cinst->used_iregs, cur_iregs));
+ cur_iregs &= ~cinst->used_iregs;
+ cur_fregs &= ~cinst->used_fregs;
+ DEBUG (g_print ("available cur_iregs: 0x%x\n", cur_iregs));
+ /* registers used by the calling convention are excluded from
+ * allocation: they will be selectively enabled when they are
+ * assigned by the special SETREG opcodes.
+ */
+ }
+ dest_mask = src1_mask = src2_mask = cur_iregs;
/* update for use with FP regs... */
- if (spec [MONO_INST_DEST] != 'f' && ins->dreg >= MONO_MAX_IREGS) {
+ if (spec [MONO_INST_DEST] == 'f') {
+ if (ins->dreg >= MONO_MAX_FREGS) {
+ val = rs->fassign [ins->dreg];
+ prev_dreg = ins->dreg;
+ if (val < 0) {
+ int spill = 0;
+ if (val < -1) {
+ /* the register gets spilled after this inst */
+ spill = -val -1;
+ }
+ val = mono_regstate_alloc_float (rs, dest_mask);
+ if (val < 0)
+ val = get_float_register_spilling (cfg, tmp, ins, dest_mask, ins->dreg);
+ rs->fassign [ins->dreg] = val;
+ if (spill)
+ create_spilled_store_float (cfg, spill, val, prev_dreg, ins);
+ }
+ DEBUG (g_print ("\tassigned dreg %s to dest R%d\n", mono_arch_regname (val), ins->dreg));
+ rs->fsymbolic [val] = prev_dreg;
+ ins->dreg = val;
+ if (spec [MONO_INST_CLOB] == 'c' && ins->dreg != ppc_f1) {
+ /* this instruction only outputs to ppc_f3, need to copy */
+ create_copy_ins_float (cfg, ins->dreg, ppc_f1, ins);
+ }
+ } else {
+ prev_dreg = -1;
+ }
+ if (freg_is_freeable (ins->dreg) && prev_dreg >= 0 && (reginfo [prev_dreg].born_in >= i || !(cur_fregs & (1 << ins->dreg)))) {
+ DEBUG (g_print ("\tfreeable %s (R%d) (born in %d)\n", mono_arch_regname (ins->dreg), prev_dreg, reginfo [prev_dreg].born_in));
+ mono_regstate_free_float (rs, ins->dreg);
+ }
+ } else if (ins->dreg >= MONO_MAX_IREGS) {
val = rs->iassign [ins->dreg];
prev_dreg = ins->dreg;
if (val < 0) {
@@ -1639,9 +1883,9 @@ mono_arch_local_regalloc (MonoCompile *cfg, MonoBasicBlock *bb)
} else if (ins->dreg == ppc_r3) {
if (val == ppc_r4) {
/* swap */
- create_copy_ins (cfg, ppc_r0, ppc_r3, ins);
- create_copy_ins (cfg, ppc_r3, ppc_r4, ins);
create_copy_ins (cfg, ppc_r4, ppc_r0, ins);
+ create_copy_ins (cfg, ppc_r3, ppc_r4, ins);
+ create_copy_ins (cfg, ppc_r0, ppc_r3, ins);
} else {
/* two forced copies */
create_copy_ins (cfg, val, ppc_r3, ins);
@@ -1656,19 +1900,48 @@ mono_arch_local_regalloc (MonoCompile *cfg, MonoBasicBlock *bb)
create_copy_ins (cfg, ins->dreg, ppc_r4, ins);
}
}
- if (reg_is_freeable (val) && hreg >= 0 && reginfo [hreg].born_in >= i) {
+ if (reg_is_freeable (val) && hreg >= 0 && (reginfo [hreg].born_in >= i && !(cur_iregs & (1 << val)))) {
DEBUG (g_print ("\tfreeable %s (R%d)\n", mono_arch_regname (val), hreg));
mono_regstate_free_int (rs, val);
}
+ } else if (spec [MONO_INST_DEST] == 'a' && ins->dreg != ppc_r3 && spec [MONO_INST_CLOB] != 'd') {
+ /* this instruction only outputs to ppc_r3, need to copy */
+ create_copy_ins (cfg, ins->dreg, ppc_r3, ins);
}
} else {
prev_dreg = -1;
}
- if (spec [MONO_INST_DEST] != 'f' && reg_is_freeable (ins->dreg) && prev_dreg >= 0 && reginfo [prev_dreg].born_in >= i) {
+ if (spec [MONO_INST_DEST] != 'f' && reg_is_freeable (ins->dreg) && prev_dreg >= 0 && (reginfo [prev_dreg].born_in >= i)) {
DEBUG (g_print ("\tfreeable %s (R%d) (born in %d)\n", mono_arch_regname (ins->dreg), prev_dreg, reginfo [prev_dreg].born_in));
mono_regstate_free_int (rs, ins->dreg);
}
- if (spec [MONO_INST_SRC1] != 'f' && ins->sreg1 >= MONO_MAX_IREGS) {
+ if (spec [MONO_INST_SRC1] == 'f') {
+ if (ins->sreg1 >= MONO_MAX_FREGS) {
+ val = rs->fassign [ins->sreg1];
+ prev_sreg1 = ins->sreg1;
+ if (val < 0) {
+ int spill = 0;
+ if (val < -1) {
+ /* the register gets spilled after this inst */
+ spill = -val -1;
+ }
+ //g_assert (val == -1); /* source cannot be spilled */
+ val = mono_regstate_alloc_float (rs, src1_mask);
+ if (val < 0)
+ val = get_float_register_spilling (cfg, tmp, ins, src1_mask, ins->sreg1);
+ rs->fassign [ins->sreg1] = val;
+ DEBUG (g_print ("\tassigned sreg1 %s to R%d\n", mono_arch_regname (val), ins->sreg1));
+ if (spill) {
+ MonoInst *store = create_spilled_store_float (cfg, spill, val, prev_sreg1, NULL);
+ insert_before_ins (ins, tmp, store);
+ }
+ }
+ rs->fsymbolic [val] = prev_sreg1;
+ ins->sreg1 = val;
+ } else {
+ prev_sreg1 = -1;
+ }
+ } else if (ins->sreg1 >= MONO_MAX_IREGS) {
val = rs->iassign [ins->sreg1];
prev_sreg1 = ins->sreg1;
if (val < 0) {
@@ -1708,7 +1981,30 @@ mono_arch_local_regalloc (MonoCompile *cfg, MonoBasicBlock *bb)
} else {
prev_sreg1 = -1;
}
- if (spec [MONO_INST_SRC2] != 'f' && ins->sreg2 >= MONO_MAX_IREGS) {
+ if (spec [MONO_INST_SRC2] == 'f') {
+ if (ins->sreg2 >= MONO_MAX_FREGS) {
+ val = rs->fassign [ins->sreg2];
+ prev_sreg2 = ins->sreg2;
+ if (val < 0) {
+ int spill = 0;
+ if (val < -1) {
+ /* the register gets spilled after this inst */
+ spill = -val -1;
+ }
+ val = mono_regstate_alloc_float (rs, src2_mask);
+ if (val < 0)
+ val = get_float_register_spilling (cfg, tmp, ins, src2_mask, ins->sreg2);
+ rs->fassign [ins->sreg2] = val;
+ DEBUG (g_print ("\tassigned sreg2 %s to R%d\n", mono_arch_regname (val), ins->sreg2));
+ if (spill)
+ create_spilled_store_float (cfg, spill, val, prev_sreg2, ins);
+ }
+ rs->fsymbolic [val] = prev_sreg2;
+ ins->sreg2 = val;
+ } else {
+ prev_sreg2 = -1;
+ }
+ } else if (ins->sreg2 >= MONO_MAX_IREGS) {
val = rs->iassign [ins->sreg2];
prev_sreg2 = ins->sreg2;
if (val < 0) {
@@ -1756,8 +2052,23 @@ mono_arch_local_regalloc (MonoCompile *cfg, MonoBasicBlock *bb)
}
static guchar*
-emit_float_to_int (MonoCompile *cfg, guchar *code, int dreg, int size, gboolean is_signed)
+emit_float_to_int (MonoCompile *cfg, guchar *code, int dreg, int sreg, int size, gboolean is_signed)
{
+ /* sreg is a float, dreg is an integer reg. ppc_f1 is used a scratch */
+ ppc_fctiwz (code, ppc_f1, sreg);
+ ppc_stfd (code, ppc_f1, -8, ppc_sp);
+ ppc_lwz (code, dreg, -4, ppc_sp);
+ if (!is_signed) {
+ if (size == 1)
+ ppc_andid (code, dreg, dreg, 0xff);
+ else if (size == 2)
+ ppc_andid (code, dreg, dreg, 0xffff);
+ } else {
+ if (size == 1)
+ ppc_extsb (code, dreg, dreg);
+ else if (size == 2)
+ ppc_extsh (code, dreg, dreg);
+ }
return code;
}
@@ -1994,23 +2305,26 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb)
ppc_rlwinm (code, ins->dreg, ins->sreg1, 0, 16, 31);
break;
case OP_COMPARE:
- if (ins->next && ins->next->opcode >= CEE_BNE_UN && ins->next->opcode <= CEE_BLT_UN)
+ if (ins->next && (ins->next->opcode >= CEE_BNE_UN && ins->next->opcode <= CEE_BLT_UN))
ppc_cmpl (code, 0, 0, ins->sreg1, ins->sreg2);
else
ppc_cmp (code, 0, 0, ins->sreg1, ins->sreg2);
break;
case OP_COMPARE_IMM:
- if (ppc_is_imm16 (ins->inst_imm)) {
- if (ins->next && ins->next->opcode >= CEE_BNE_UN && ins->next->opcode <= CEE_BLT_UN)
+ if (ins->next && ins->next->opcode >= CEE_BNE_UN && ins->next->opcode <= CEE_BLT_UN) {
+ if (ppc_is_uimm16 (ins->inst_imm)) {
ppc_cmpli (code, 0, 0, ins->sreg1, (ins->inst_imm & 0xffff));
- else
- ppc_cmpi (code, 0, 0, ins->sreg1, (ins->inst_imm & 0xffff));
+ } else {
+ ppc_load (code, ppc_r11, ins->inst_imm);
+ ppc_cmpl (code, 0, 0, ins->sreg1, ppc_r11);
+ }
} else {
- ppc_load (code, ppc_r11, ins->inst_imm);
- if (ins->next && ins->next->opcode >= CEE_BNE_UN && ins->next->opcode <= CEE_BLT_UN)
+ if (ppc_is_imm16 (ins->inst_imm)) {
+ ppc_cmpi (code, 0, 0, ins->sreg1, (ins->inst_imm & 0xffff));
+ } else {
+ ppc_load (code, ppc_r11, ins->inst_imm);
ppc_cmp (code, 0, 0, ins->sreg1, ppc_r11);
- else
- ppc_cmpl (code, 0, 0, ins->sreg1, ppc_r11);
+ }
}
break;
case OP_X86_TEST_NULL:
@@ -2051,8 +2365,11 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb)
break;
case OP_SUB_IMM:
// we add the negated value
- g_assert (ppc_is_imm16 (-ins->inst_imm));
- ppc_addi (code, ins->dreg, ins->sreg1, -ins->inst_imm);
+ if (ppc_is_imm16 (-ins->inst_imm))
+ ppc_addi (code, ins->dreg, ins->sreg1, -ins->inst_imm);
+ else
+ ppc_load (code, ppc_r11, ins->inst_imm);
+ ppc_subf (code, ins->dreg, ins->sreg2, ppc_r11);
break;
case OP_SBB_IMM:
ppc_load (code, ppc_r11, ins->inst_imm);
@@ -2197,13 +2514,31 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb)
case OP_SETREG:
ppc_mr (code, ins->dreg, ins->sreg1);
break;
+ case OP_SETLRET: {
+ int saved = ins->sreg1;
+ if (ins->sreg1 == ppc_r3) {
+ ppc_mr (code, ppc_r0, ins->sreg1);
+ saved = ppc_r0;
+ }
+ if (ins->sreg2 != ppc_r3)
+ ppc_mr (code, ppc_r3, ins->sreg2);
+ if (saved != ppc_r4)
+ ppc_mr (code, ppc_r4, saved);
+ break;
+ }
+ case OP_SETFREG:
+ case OP_FMOVE:
+ ppc_fmr (code, ins->dreg, ins->sreg1);
+ break;
+ case OP_FCONV_TO_R4:
+ ppc_frsp (code, ins->dreg, ins->sreg1);
+ break;
case CEE_JMP:
g_assert_not_reached ();
break;
case OP_CHECK_THIS:
/* ensure ins->sreg1 is not NULL */
- g_assert_not_reached ();
- //x86_alu_membase_imm (code, X86_CMP, ins->sreg1, 0, 0);
+ ppc_lwz (code, ppc_r0, 0, ins->sreg1);
break;
case OP_FCALL:
case OP_LCALL:
@@ -2238,6 +2573,7 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb)
g_assert_not_reached ();
break;
case OP_LOCALLOC:
+ g_assert_not_reached ();
/* keep alignment */
#define MONO_FRAME_ALIGNMENT 32
ppc_addi (code, ppc_r0, ins->sreg1, MONO_FRAME_ALIGNMENT-1);
@@ -2246,7 +2582,6 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb)
ppc_neg (code, ppc_r0, ppc_r0);
ppc_stwux (code, ppc_sp, ppc_r0, ppc_sp);
ppc_mr (code, ins->dreg, ppc_sp);
- g_assert_not_reached ();
break;
case CEE_RET:
ppc_blr (code);
@@ -2254,16 +2589,24 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb)
case CEE_THROW: {
ppc_mr (code, ppc_r3, ins->sreg1);
mono_add_patch_info (cfg, code - cfg->native_code, MONO_PATCH_INFO_INTERNAL_METHOD,
- (gpointer)"throw_exception");
+ (gpointer)"mono_arch_throw_exception");
ppc_bl (code, 0);
break;
}
+ case OP_START_HANDLER:
+ ppc_mflr (code, ppc_r0);
+ ppc_stw (code, ppc_r0, ins->inst_left->inst_offset, ins->inst_left->inst_basereg);
+ break;
case OP_ENDFILTER:
if (ins->sreg1 != ppc_r3)
ppc_mr (code, ppc_r3, ins->sreg1);
+ ppc_lwz (code, ppc_r0, ins->inst_left->inst_offset, ins->inst_left->inst_basereg);
+ ppc_mtlr (code, ppc_r0);
ppc_blr (code);
break;
case CEE_ENDFINALLY:
+ ppc_lwz (code, ppc_r0, ins->inst_left->inst_offset, ins->inst_left->inst_basereg);
+ ppc_mtlr (code, ppc_r0);
ppc_blr (code);
break;
case OP_CALL_HANDLER:
@@ -2313,7 +2656,7 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb)
case OP_CGT:
case OP_CGT_UN:
ppc_li (code, ins->dreg, 1);
- ppc_bc (code, PPC_BR_TRUE, PPC_BR_LT, 2);
+ ppc_bc (code, PPC_BR_TRUE, PPC_BR_GT, 2);
ppc_li (code, ins->dreg, 0);
break;
case OP_COND_EXC_EQ:
@@ -2368,12 +2711,19 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb)
ppc_lfs (code, ins->dreg, ins->inst_offset, ins->inst_basereg);
break;
case CEE_CONV_R4: /* FIXME: change precision */
- case CEE_CONV_R8:
- g_assert_not_reached ();
- x86_push_reg (code, ins->sreg1);
- x86_fild_membase (code, X86_ESP, 0, FALSE);
- x86_alu_reg_imm (code, X86_ADD, X86_ESP, 4);
+ case CEE_CONV_R8: {
+ static const guint64 adjust_val = 0x4330000000000000UL;
+ ppc_li (code, ppc_r0, 0);
+ ppc_addis (code, ppc_r0, ppc_r0, 0x4330);
+ ppc_stw (code, ins->sreg1, -8, ppc_sp);
+ ppc_xoris (code, ppc_r11, ins->sreg1, 0x8000);
+ ppc_stw (code, ppc_r11, -4, ppc_sp);
+ ppc_lfd (code, ins->dreg, -8, ppc_sp);
+ ppc_li (code, ppc_r11, &adjust_val);
+ ppc_lfd (code, ppc_f0, 0, ppc_r11);
+ ppc_fsub (code, ins->dreg, ins->dreg, ppc_f0);
break;
+ }
case OP_X86_FP_LOAD_I8:
g_assert_not_reached ();
x86_fild_membase (code, ins->inst_basereg, ins->inst_offset, TRUE);
@@ -2383,78 +2733,34 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb)
x86_fild_membase (code, ins->inst_basereg, ins->inst_offset, FALSE);
break;
case OP_FCONV_TO_I1:
- g_assert_not_reached ();
- code = emit_float_to_int (cfg, code, ins->dreg, 1, TRUE);
+ code = emit_float_to_int (cfg, code, ins->dreg, ins->sreg1, 1, TRUE);
break;
case OP_FCONV_TO_U1:
- g_assert_not_reached ();
- code = emit_float_to_int (cfg, code, ins->dreg, 1, FALSE);
+ code = emit_float_to_int (cfg, code, ins->dreg, ins->sreg1, 1, FALSE);
break;
case OP_FCONV_TO_I2:
- g_assert_not_reached ();
- code = emit_float_to_int (cfg, code, ins->dreg, 2, TRUE);
+ code = emit_float_to_int (cfg, code, ins->dreg, ins->sreg1, 2, TRUE);
break;
case OP_FCONV_TO_U2:
- g_assert_not_reached ();
- code = emit_float_to_int (cfg, code, ins->dreg, 2, FALSE);
+ code = emit_float_to_int (cfg, code, ins->dreg, ins->sreg1, 2, FALSE);
break;
case OP_FCONV_TO_I4:
case OP_FCONV_TO_I:
- g_assert_not_reached ();
- code = emit_float_to_int (cfg, code, ins->dreg, 4, TRUE);
+ code = emit_float_to_int (cfg, code, ins->dreg, ins->sreg1, 4, TRUE);
break;
case OP_FCONV_TO_U4:
case OP_FCONV_TO_U:
- g_assert_not_reached ();
- code = emit_float_to_int (cfg, code, ins->dreg, 4, FALSE);
+ code = emit_float_to_int (cfg, code, ins->dreg, ins->sreg1, 4, FALSE);
break;
case OP_FCONV_TO_I8:
case OP_FCONV_TO_U8:
g_assert_not_reached ();
- /*x86_alu_reg_imm (code, X86_SUB, X86_ESP, 4);
- x86_fnstcw_membase(code, X86_ESP, 0);
- x86_mov_reg_membase (code, ins->inst_dreg_low, X86_ESP, 0, 2);
- x86_alu_reg_imm (code, X86_OR, ins->inst_dreg_low, 0xc00);
- x86_mov_membase_reg (code, X86_ESP, 2, ins->inst_dreg_low, 2);
- x86_fldcw_membase (code, X86_ESP, 2);
- x86_alu_reg_imm (code, X86_SUB, X86_ESP, 8);
- x86_fist_pop_membase (code, X86_ESP, 0, TRUE);
- x86_pop_reg (code, ins->inst_dreg_low);
- x86_pop_reg (code, ins->inst_dreg_high);
- x86_fldcw_membase (code, X86_ESP, 0);
- x86_alu_reg_imm (code, X86_ADD, X86_ESP, 4);*/
- break;
- case OP_LCONV_TO_R_UN: {
-#if 0
- static guint8 mn[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3f, 0x40 };
- guint8 *br;
-
- /* load 64bit integer to FP stack */
- x86_push_imm (code, 0);
- x86_push_reg (code, ins->sreg2);
- x86_push_reg (code, ins->sreg1);
- x86_fild_membase (code, X86_ESP, 0, TRUE);
- /* store as 80bit FP value */
- x86_fst80_membase (code, X86_ESP, 0);
-
- /* test if lreg is negative */
- x86_test_reg_reg (code, ins->sreg2, ins->sreg2);
- br = code; x86_branch8 (code, X86_CC_GEZ, 0, TRUE);
-
- /* add correction constant mn */
- x86_fld80_mem (code, mn);
- x86_fld80_membase (code, X86_ESP, 0);
- x86_fp_op_reg (code, X86_FADD, 1, TRUE);
- x86_fst80_membase (code, X86_ESP, 0);
-
- x86_patch (br, code);
-
- x86_fld80_membase (code, X86_ESP, 0);
- x86_alu_reg_imm (code, X86_ADD, X86_ESP, 12);
-#endif
+ /* Implemented as helper calls */
+ break;
+ case OP_LCONV_TO_R_UN:
g_assert_not_reached ();
+ /* Implemented as helper calls */
break;
- }
case OP_LCONV_TO_OVF_I: {
#if 0
guint8 *br [3], *label [1];
@@ -2506,74 +2812,71 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb)
ppc_fneg (code, ins->dreg, ins->sreg1);
break;
case OP_FREM:
+ /* emulated */
g_assert_not_reached ();
break;
case OP_FCOMPARE:
- g_assert_not_reached ();
- /* this overwrites EAX */
- EMIT_FPCOMPARE(code);
+ ppc_fcmpo (code, 0, ins->sreg1, ins->sreg2);
break;
case OP_FCEQ:
- g_assert_not_reached ();
- /*if (ins->dreg != X86_EAX)
- x86_push_reg (code, X86_EAX);
-
- EMIT_FPCOMPARE(code);
- x86_alu_reg_imm (code, X86_CMP, X86_EAX, 0x4000);
- x86_set_reg (code, X86_CC_EQ, ins->dreg, TRUE);
- x86_widen_reg (code, ins->dreg, ins->dreg, FALSE, FALSE);
-
- if (ins->dreg != X86_EAX)
- x86_pop_reg (code, X86_EAX);*/
+ ppc_fcmpo (code, 0, ins->sreg1, ins->sreg2);
+ ppc_li (code, ins->dreg, 0);
+ ppc_bc (code, PPC_BR_FALSE, PPC_BR_EQ, 2);
+ ppc_li (code, ins->dreg, 1);
break;
case OP_FCLT:
+ ppc_fcmpo (code, 0, ins->sreg1, ins->sreg2);
+ ppc_li (code, ins->dreg, 1);
+ ppc_bc (code, PPC_BR_TRUE, PPC_BR_LT, 2);
+ ppc_li (code, ins->dreg, 0);
+ break;
case OP_FCLT_UN:
- g_assert_not_reached ();
- /*if (ins->dreg != X86_EAX)
- x86_push_reg (code, X86_EAX);
-
- EMIT_FPCOMPARE(code);
- x86_set_reg (code, X86_CC_EQ, ins->dreg, TRUE);
- x86_widen_reg (code, ins->dreg, ins->dreg, FALSE, FALSE);
-
- if (ins->dreg != X86_EAX)
- x86_pop_reg (code, X86_EAX);*/
+ ppc_fcmpu (code, 0, ins->sreg1, ins->sreg2);
+ ppc_li (code, ins->dreg, 1);
+ ppc_bc (code, PPC_BR_TRUE, PPC_BR_LT, 2);
+ ppc_li (code, ins->dreg, 0);
break;
case OP_FCGT:
+ ppc_fcmpu (code, 0, ins->sreg1, ins->sreg2);
+ ppc_li (code, ins->dreg, 1);
+ ppc_bc (code, PPC_BR_TRUE, PPC_BR_LT, 2);
+ ppc_li (code, ins->dreg, 0);
+ break;
case OP_FCGT_UN:
- g_assert_not_reached ();
- /*if (ins->dreg != X86_EAX)
- x86_push_reg (code, X86_EAX);
-
- EMIT_FPCOMPARE(code);
- x86_alu_reg_imm (code, X86_CMP, X86_EAX, 0x0100);
- x86_set_reg (code, X86_CC_EQ, ins->dreg, TRUE);
- x86_widen_reg (code, ins->dreg, ins->dreg, FALSE, FALSE);
-
- if (ins->dreg != X86_EAX)
- x86_pop_reg (code, X86_EAX);*/
+ ppc_fcmpo (code, 0, ins->sreg1, ins->sreg2);
+ ppc_li (code, ins->dreg, 1);
+ ppc_bc (code, PPC_BR_TRUE, PPC_BR_LT, 2);
+ ppc_li (code, ins->dreg, 0);
break;
case OP_FBEQ:
- g_assert_not_reached ();
+ EMIT_COND_BRANCH (ins, CEE_BEQ - CEE_BEQ);
break;
case OP_FBNE_UN:
- g_assert_not_reached ();
+ EMIT_COND_BRANCH (ins, CEE_BNE_UN - CEE_BEQ);
break;
case OP_FBLT:
+ EMIT_COND_BRANCH (ins, CEE_BLT - CEE_BEQ);
+ break;
case OP_FBLT_UN:
- g_assert_not_reached ();
+ EMIT_COND_BRANCH (ins, CEE_BLT_UN - CEE_BEQ);
break;
case OP_FBGT:
+ EMIT_COND_BRANCH (ins, CEE_BGT - CEE_BEQ);
+ break;
case OP_FBGT_UN:
- g_assert_not_reached ();
+ EMIT_COND_BRANCH (ins, CEE_BGT_UN - CEE_BEQ);
break;
case OP_FBGE:
+ EMIT_COND_BRANCH (ins, CEE_BGE - CEE_BEQ);
+ break;
case OP_FBGE_UN:
- g_assert_not_reached ();
+ EMIT_COND_BRANCH (ins, CEE_BGE_UN - CEE_BEQ);
break;
case OP_FBLE:
+ EMIT_COND_BRANCH (ins, CEE_BLE - CEE_BEQ);
+ break;
case OP_FBLE_UN:
- g_assert_not_reached ();
+ EMIT_COND_BRANCH (ins, CEE_BLE_UN - CEE_BEQ);
break;
case CEE_CKFINITE: {
g_assert_not_reached ();
@@ -2637,6 +2940,9 @@ mono_arch_patch_code (MonoMethod *method, MonoDomain *domain, guint8 *code, Mono
case MONO_PATCH_INFO_IP:
*((gpointer *)(ip)) = ip;
continue;
+ case MONO_PATCH_INFO_METHOD_REL:
+ *((gpointer *)(ip)) = code + patch_info->data.offset;
+ continue;
case MONO_PATCH_INFO_INTERNAL_METHOD: {
MonoJitICallInfo *mi = mono_find_jit_icall_by_name (patch_info->data.name);
if (!mi) {
@@ -2646,6 +2952,9 @@ mono_arch_patch_code (MonoMethod *method, MonoDomain *domain, guint8 *code, Mono
target = mi->wrapper;
break;
}
+ case MONO_PATCH_INFO_METHOD_JUMP:
+ g_assert_not_reached ();
+ break;
case MONO_PATCH_INFO_METHOD:
if (patch_info->data.method == method) {
target = code;
@@ -2680,6 +2989,67 @@ mono_arch_patch_code (MonoMethod *method, MonoDomain *domain, guint8 *code, Mono
g_assert_not_reached ();
*((gconstpointer *)(ip + 2)) = patch_info->data.target;
continue;
+ case MONO_PATCH_INFO_IID:
+ g_assert_not_reached ();
+ mono_class_init (patch_info->data.klass);
+ *((guint32 *)(ip + 1)) = patch_info->data.klass->interface_id;
+ continue;
+ case MONO_PATCH_INFO_VTABLE:
+ g_assert_not_reached ();
+ *((gconstpointer *)(ip + 1)) = mono_class_vtable (domain, patch_info->data.klass);
+ continue;
+ case MONO_PATCH_INFO_CLASS_INIT:
+ target = mono_create_class_init_trampoline (mono_class_vtable (domain, patch_info->data.klass));
+ break;
+ case MONO_PATCH_INFO_SFLDA: {
+ MonoVTable *vtable = mono_class_vtable (domain, patch_info->data.field->parent);
+ if (!vtable->initialized && !(vtable->klass->flags & TYPE_ATTRIBUTE_BEFORE_FIELD_INIT) && mono_class_needs_cctor_run (vtable->klass, method))
+ /* Done by the generated code */
+ ;
+ else {
+ mono_runtime_class_init (vtable);
+ }
+ g_assert_not_reached ();
+ *((gconstpointer *)(ip + 1)) =
+ (char*)vtable->data + patch_info->data.field->offset;
+ continue;
+ }
+ case MONO_PATCH_INFO_EXC_NAME:
+ g_assert_not_reached ();
+ *((gconstpointer *)(ip + 1)) = patch_info->data.name;
+ continue;
+ case MONO_PATCH_INFO_LDSTR:
+ g_assert_not_reached ();
+ *((gconstpointer *)(ip + 1)) =
+ mono_ldstr (domain, patch_info->data.token->image,
+ mono_metadata_token_index (patch_info->data.token->token));
+ continue;
+ case MONO_PATCH_INFO_TYPE_FROM_HANDLE: {
+ gpointer handle;
+ MonoClass *handle_class;
+
+ handle = mono_ldtoken (patch_info->data.token->image,
+ patch_info->data.token->token, &handle_class);
+ mono_class_init (handle_class);
+ mono_class_init (mono_class_from_mono_type (handle));
+
+ g_assert_not_reached ();
+ *((gconstpointer *)(ip + 1)) =
+ mono_type_get_object (domain, handle);
+ continue;
+ }
+ case MONO_PATCH_INFO_LDTOKEN: {
+ gpointer handle;
+ MonoClass *handle_class;
+
+ handle = mono_ldtoken (patch_info->data.token->image,
+ patch_info->data.token->token, &handle_class);
+ mono_class_init (handle_class);
+
+ g_assert_not_reached ();
+ *((gconstpointer *)(ip + 1)) = handle;
+ continue;
+ }
default:
g_assert_not_reached ();
}
@@ -2728,13 +3098,17 @@ mono_arch_emit_prolog (MonoCompile *cfg)
int alloc_size, pos, max_offset, i;
guint8 *code;
CallInfo *cinfo;
+ int tracing = 0;
+
+ if (mono_jit_trace_calls != NULL && mono_trace_eval (method))
+ tracing = 1;
cfg->code_size = 256;
code = cfg->native_code = g_malloc (cfg->code_size);
if (1 || cfg->flags & MONO_CFG_HAS_CALLS) {
ppc_mflr (code, ppc_r0);
- ppc_stw (code, ppc_r0, 8, ppc_sp);
+ ppc_stw (code, ppc_r0, PPC_RET_ADDR_OFFSET, ppc_sp);
}
if (cfg->flags & MONO_CFG_HAS_ALLOCA) {
cfg->used_int_regs |= 1 << 31;
@@ -2742,6 +3116,9 @@ mono_arch_emit_prolog (MonoCompile *cfg)
alloc_size = cfg->stack_offset;
pos = 0;
+ /* reserve room to save return value */
+ if (tracing)
+ pos += 8;
if (method->save_lmf) {
#if 0
@@ -2783,9 +3160,9 @@ mono_arch_emit_prolog (MonoCompile *cfg)
}
alloc_size += pos;
- // align to 16 bytes
- if (alloc_size & (16 - 1))
- alloc_size += 16 - (alloc_size & (16 - 1));
+ // align to PPC_STACK_ALIGNMENT bytes
+ if (alloc_size & (PPC_STACK_ALIGNMENT - 1))
+ alloc_size += PPC_STACK_ALIGNMENT - (alloc_size & (PPC_STACK_ALIGNMENT - 1));
cfg->stack_usage = alloc_size;
if (alloc_size)
@@ -2810,32 +3187,65 @@ mono_arch_emit_prolog (MonoCompile *cfg)
}
}
- if (mono_jit_trace_calls != NULL && mono_trace_eval (method))
- code = mono_arch_instrument_prolog (cfg, enter_method, code, TRUE);
-
/* load arguments allocated to register from the stack */
sig = method->signature;
pos = 0;
cinfo = calculate_sizes (sig, sig->pinvoke);
+ if (MONO_TYPE_ISSTRUCT (sig->ret)) {
+ ArgInfo *ainfo = &cinfo->ret;
+ inst = cfg->ret;
+ ppc_stw (code, ainfo->reg, inst->inst_offset, inst->inst_basereg);
+ }
for (i = 0; i < sig->param_count + sig->hasthis; ++i) {
ArgInfo *ainfo = cinfo->args + i;
inst = cfg->varinfo [pos];
if (inst->opcode == OP_REGVAR) {
- g_assert (!ainfo->regtype); // fine for now
- ppc_mr (code, inst->dreg, ainfo->reg);
+ if (ainfo->regtype == RegTypeGeneral)
+ ppc_mr (code, inst->dreg, ainfo->reg);
+ else if (ainfo->regtype == RegTypeFP)
+ ppc_fmr (code, inst->dreg, ainfo->reg);
+ else
+ g_assert_not_reached ();
if (cfg->verbose_level > 2)
g_print ("Argument %d assigned to register %s\n", pos, mono_arch_regname (inst->dreg));
} else {
/* the argument should be put on the stack: FIXME handle size != word */
- ppc_stw (code, ainfo->reg, inst->inst_offset, inst->inst_basereg);
+ if (ainfo->regtype == RegTypeGeneral) {
+ switch (ainfo->size) {
+ case 1:
+ ppc_stb (code, ainfo->reg, inst->inst_offset, inst->inst_basereg);
+ break;
+ case 2:
+ ppc_sth (code, ainfo->reg, inst->inst_offset, inst->inst_basereg);
+ break;
+ case 8:
+ ppc_stw (code, ainfo->reg, inst->inst_offset, inst->inst_basereg);
+ ppc_stw (code, ainfo->reg + 1, inst->inst_offset + 4, inst->inst_basereg);
+ break;
+ default:
+ ppc_stw (code, ainfo->reg, inst->inst_offset, inst->inst_basereg);
+ }
+ } else if (ainfo->regtype == RegTypeFP) {
+ if (ainfo->size == 8)
+ ppc_stfd (code, ainfo->reg, inst->inst_offset, inst->inst_basereg);
+ else if (ainfo->size == 4)
+ ppc_stfs (code, ainfo->reg, inst->inst_offset, inst->inst_basereg);
+ else
+ g_assert_not_reached ();
+ } else
+ g_assert_not_reached ();
}
pos++;
}
+ if (tracing)
+ code = mono_arch_instrument_prolog (cfg, enter_method, code, TRUE);
+
cfg->code_len = code - cfg->native_code;
+ g_free (cinfo);
return code;
}
@@ -2850,11 +3260,12 @@ mono_arch_emit_epilog (MonoCompile *cfg)
code = cfg->native_code + cfg->code_len;
- if (mono_jit_trace_calls != NULL && mono_trace_eval (method))
+ if (mono_jit_trace_calls != NULL && mono_trace_eval (method)) {
code = mono_arch_instrument_epilog (cfg, leave_method, code, TRUE);
-
-
- pos = 0;
+ pos = 8;
+ } else {
+ pos = 0;
+ }
if (method->save_lmf) {
pos = -sizeof (MonoLMF);
@@ -2881,7 +3292,7 @@ mono_arch_emit_epilog (MonoCompile *cfg)
}
if (1 || cfg->flags & MONO_CFG_HAS_CALLS) {
- ppc_lwz (code, ppc_r0, cfg->stack_usage + 8, cfg->frame_reg);
+ ppc_lwz (code, ppc_r0, cfg->stack_usage + PPC_RET_ADDR_OFFSET, cfg->frame_reg);
ppc_mtlr (code, ppc_r0);
}
ppc_addic (code, ppc_sp, cfg->frame_reg, cfg->stack_usage);
@@ -2901,7 +3312,7 @@ mono_arch_emit_epilog (MonoCompile *cfg)
x86_push_imm (code, patch_info->data.target);
x86_push_imm (code, patch_info->ip.i + cfg->native_code);
patch_info->type = MONO_PATCH_INFO_INTERNAL_METHOD;
- patch_info->data.name = "throw_exception_by_name";
+ patch_info->data.name = "mono_arch_throw_exception_by_name";
patch_info->ip.i = code - cfg->native_code;
x86_jump_code (code, 0);*/
break;
@@ -2921,3 +3332,32 @@ void
mono_arch_setup_jit_tls_data (MonoJitTlsData *tls)
{
}
+
+void
+mono_arch_emit_this_vret_args (MonoCompile *cfg, MonoCallInst *inst, int this_reg, int this_type, int vt_reg)
+{
+ int this_dreg = ppc_r3;
+
+ if (vt_reg != -1)
+ this_dreg = ppc_r4;
+
+ /* add the this argument */
+ if (this_reg != -1) {
+ MonoInst *this;
+ MONO_INST_NEW (cfg, this, OP_SETREG);
+ this->type = this_type;
+ this->sreg1 = this_reg;
+ this->dreg = this_dreg;
+ mono_bblock_add_inst (cfg->cbb, this);
+ }
+
+ if (vt_reg != -1) {
+ MonoInst *vtarg;
+ MONO_INST_NEW (cfg, vtarg, OP_SETREG);
+ vtarg->type = STACK_MP;
+ vtarg->sreg1 = vt_reg;
+ vtarg->dreg = ppc_r3;
+ mono_bblock_add_inst (cfg->cbb, vtarg);
+ }
+}
+
diff --git a/mono/mini/mini-ppc.h b/mono/mini/mini-ppc.h
index c2a6d4677de..998d8c688fb 100644
--- a/mono/mini/mini-ppc.h
+++ b/mono/mini/mini-ppc.h
@@ -25,4 +25,25 @@ struct MonoLMF {
guint32 eip;
};
+#define MONO_ARCH_EMULATE_FCONV_TO_I8 1
+#define MONO_ARCH_EMULATE_LCONV_TO_R8 1
+#define MONO_ARCH_EMULATE_LCONV_TO_R4 1
+#define MONO_ARCH_EMULATE_LCONV_TO_R8_UN 1
+#define MONO_ARCH_EMULATE_FREM 1
+
+/* deal with some of the ABI differences here */
+#ifdef __APPLE__
+#define PPC_RET_ADDR_OFFSET 8
+#define PPC_STACK_ALIGNMENT 16
+#define PPC_STACK_PARAM_OFFSET 24
+#define PPC_MINIMAL_STACK_SIZE 24
+#else
+/* Linux */
+#define PPC_RET_ADDR_OFFSET 4
+#define PPC_STACK_ALIGNMENT 16
+#define PPC_STACK_PARAM_OFFSET 8
+#define PPC_MINIMAL_STACK_SIZE 8
+#endif
+
+
#endif /* __MONO_MINI_PPC_H__ */
diff --git a/mono/mini/mini-sparc.c b/mono/mini/mini-sparc.c
index 812ecd05fd9..cb4e48254cd 100644
--- a/mono/mini/mini-sparc.c
+++ b/mono/mini/mini-sparc.c
@@ -1199,6 +1199,38 @@ peephole_pass (MonoCompile *cfg, MonoBasicBlock *bb)
bb->last_ins = last_ins;
}
+/*
+ * returns the offset used by spillvar. It allocates a new
+ * spill variable if necessary. Likely incorrect for sparc.
+ */
+static int
+mono_spillvar_offset (MonoCompile *cfg, int spillvar)
+{
+ MonoSpillInfo **si, *info;
+ int i = 0;
+
+ si = &cfg->spill_info;
+
+ while (i <= spillvar) {
+
+ if (!*si) {
+ *si = info = mono_mempool_alloc (cfg->mempool, sizeof (MonoSpillInfo));
+ info->next = NULL;
+ cfg->stack_offset -= sizeof (gpointer);
+ info->offset = cfg->stack_offset;
+ }
+
+ if (i == spillvar)
+ return (*si)->offset;
+
+ i++;
+ si = &(*si)->next;
+ }
+
+ g_assert_not_reached ();
+ return 0;
+}
+
#undef DEBUG
#define DEBUG(a) if (cfg->verbose_level > 1) a
//#define DEBUG(a)
@@ -2810,3 +2842,32 @@ void
mono_arch_setup_jit_tls_data (MonoJitTlsData *tls)
{
}
+
+void
+mono_arch_emit_this_vret_args (MonoCompile *cfg, MonoCallInst *inst, int this_reg, int this_type, int vt_reg)
+{
+ int this_dreg = sparc_o0;
+
+ if (vt_reg != -1)
+ this_dreg = sparc_o1;
+
+ /* add the this argument */
+ if (this_reg != -1) {
+ MonoInst *this;
+ MONO_INST_NEW (cfg, this, OP_SETREG);
+ this->type = this_type;
+ this->sreg1 = this_reg;
+ this->dreg = this_dreg;
+ mono_bblock_add_inst (cfg->cbb, this);
+ }
+
+ if (vt_reg != -1) {
+ MonoInst *vtarg;
+ MONO_INST_NEW (cfg, vtarg, OP_SETREG);
+ vtarg->type = STACK_MP;
+ vtarg->sreg1 = vt_reg;
+ vtarg->dreg = sparc_o0;
+ mono_bblock_add_inst (cfg->cbb, vtarg);
+ }
+}
+
diff --git a/mono/mini/mini-x86.c b/mono/mini/mini-x86.c
index fcac57e5c33..997dd355bca 100644
--- a/mono/mini/mini-x86.c
+++ b/mono/mini/mini-x86.c
@@ -14,6 +14,7 @@
#include <mono/metadata/appdomain.h>
#include <mono/metadata/debug-helpers.h>
#include <mono/metadata/profiler-private.h>
+#include <mono/utils/mono-math.h>
#include "mini-x86.h"
#include "inssel.h"
@@ -659,6 +660,8 @@ mono_arch_call_opcode (MonoCompile *cfg, MonoBasicBlock* bb, MonoCallInst *call,
/* add the vararg cookie before the non-implicit args */
if (call->signature->call_convention == MONO_CALL_VARARG) {
MonoInst *sig_arg;
+ /* FIXME: Add support for signature tokens to AOT */
+ cfg->disable_aot = TRUE;
MONO_INST_NEW (cfg, arg, OP_OUTARG);
MONO_INST_NEW (cfg, sig_arg, OP_ICONST);
sig_arg->inst_p0 = call->signature;
@@ -1132,6 +1135,38 @@ branch_cc_table [] = {
X86_CC_O, X86_CC_NO, X86_CC_C, X86_CC_NC
};
+/*
+ * returns the offset used by spillvar. It allocates a new
+ * spill variable if necessary.
+ */
+static int
+mono_spillvar_offset (MonoCompile *cfg, int spillvar)
+{
+ MonoSpillInfo **si, *info;
+ int i = 0;
+
+ si = &cfg->spill_info;
+
+ while (i <= spillvar) {
+
+ if (!*si) {
+ *si = info = mono_mempool_alloc (cfg->mempool, sizeof (MonoSpillInfo));
+ info->next = NULL;
+ cfg->stack_offset -= sizeof (gpointer);
+ info->offset = cfg->stack_offset;
+ }
+
+ if (i == spillvar)
+ return (*si)->offset;
+
+ i++;
+ si = &(*si)->next;
+ }
+
+ g_assert_not_reached ();
+ return 0;
+}
+
#define DEBUG(a) if (cfg->verbose_level > 1) a
//#define DEBUG(a)
#define reg_is_freeable(r) ((r) >= 0 && (r) <= 7 && X86_IS_CALLEE ((r)))
@@ -1479,6 +1514,7 @@ mono_arch_local_regalloc (MonoCompile *cfg, MonoBasicBlock *bb)
--i;
ins = tmp->data;
spec = ins_spec [ins->opcode];
+ prev_dreg = -1;
DEBUG (g_print ("processing:"));
DEBUG (print_ins (i, ins));
if (spec [MONO_INST_CLOB] == 's') {
@@ -1582,6 +1618,7 @@ mono_arch_local_regalloc (MonoCompile *cfg, MonoBasicBlock *bb)
}
} else {
DEBUG (g_print ("\tshortcut assignment of R%d to %s\n", ins->dreg, mono_arch_regname (dest_reg)));
+ prev_dreg = ins->dreg;
rs->iassign [ins->dreg] = dest_reg;
rs->isymbolic [dest_reg] = ins->dreg;
ins->dreg = dest_reg;
@@ -1684,8 +1721,6 @@ mono_arch_local_regalloc (MonoCompile *cfg, MonoBasicBlock *bb)
} else if (spec [MONO_INST_DEST] == 'd' && ins->dreg != X86_EDX && spec [MONO_INST_CLOB] != 'd') {
create_copy_ins (cfg, ins->dreg, X86_EDX, ins);
}
- } else {
- prev_dreg = -1;
}
if (spec [MONO_INST_DEST] != 'f' && reg_is_freeable (ins->dreg) && prev_dreg >= 0 && reginfo [prev_dreg].born_in >= i) {
DEBUG (g_print ("\tfreeable %s (R%d) (born in %d)\n", mono_arch_regname (ins->dreg), prev_dreg, reginfo [prev_dreg].born_in));
@@ -2503,7 +2538,7 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb)
case OP_R8CONST: {
double d = *(double *)ins->inst_p0;
- if ((d == 0.0) && (signbit (d) == 0)) {
+ if ((d == 0.0) && (mono_signbit (d) == 0)) {
x86_fldz (code);
} else if (d == 1.0) {
x86_fld1 (code);
@@ -2516,7 +2551,7 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb)
case OP_R4CONST: {
float f = *(float *)ins->inst_p0;
- if ((f == 0.0) && (signbit (f) == 0)) {
+ if ((f == 0.0) && (mono_signbit (f) == 0)) {
x86_fldz (code);
} else if (f == 1.0) {
x86_fld1 (code);
@@ -3439,3 +3474,26 @@ mono_arch_setup_jit_tls_data (MonoJitTlsData *tls)
mono_lmf_addr = &tls->lmf;
#endif
}
+
+void
+mono_arch_emit_this_vret_args (MonoCompile *cfg, MonoCallInst *inst, int this_reg, int this_type, int vt_reg)
+{
+
+ /* add the this argument */
+ if (this_reg != -1) {
+ MonoInst *this;
+ MONO_INST_NEW (cfg, this, OP_OUTARG);
+ this->type = this_type;
+ this->sreg1 = this_reg;
+ mono_bblock_add_inst (cfg->cbb, this);
+ }
+
+ if (vt_reg != -1) {
+ MonoInst *vtarg;
+ MONO_INST_NEW (cfg, vtarg, OP_OUTARG);
+ vtarg->type = STACK_MP;
+ vtarg->sreg1 = vt_reg;
+ mono_bblock_add_inst (cfg->cbb, vtarg);
+ }
+}
+
diff --git a/mono/mini/mini-x86.h b/mono/mini/mini-x86.h
index 1acb3bc49b3..ba7627ee5a1 100644
--- a/mono/mini/mini-x86.h
+++ b/mono/mini/mini-x86.h
@@ -36,4 +36,6 @@ struct MonoLMF {
guint32 eip;
};
+#define MONO_ARCH_BIGMUL_INTRINS 1
+
#endif /* __MONO_MINI_X86_H__ */
diff --git a/mono/mini/mini.c b/mono/mini/mini.c
index 93e560c84d7..6862e83fd29 100644
--- a/mono/mini/mini.c
+++ b/mono/mini/mini.c
@@ -11,6 +11,7 @@
#include <config.h>
#include <signal.h>
#include <unistd.h>
+#include <math.h>
#ifdef HAVE_VALGRIND_MEMCHECK_H
#include <valgrind/memcheck.h>
@@ -90,6 +91,9 @@ static MonoMethodSignature *helper_sig_memcpy = NULL;
static MonoMethodSignature *helper_sig_memset = NULL;
static MonoMethodSignature *helper_sig_ulong_double = NULL;
static MonoMethodSignature *helper_sig_long_double = NULL;
+static MonoMethodSignature *helper_sig_double_long = NULL;
+static MonoMethodSignature *helper_sig_float_long = NULL;
+static MonoMethodSignature *helper_sig_double_double_double = NULL;
static MonoMethodSignature *helper_sig_uint_double = NULL;
static MonoMethodSignature *helper_sig_int_double = NULL;
static MonoMethodSignature *helper_sig_stelem_ref = NULL;
@@ -132,7 +136,6 @@ mono_type_blittable (MonoType *type)
return TRUE;
case MONO_TYPE_VALUETYPE:
case MONO_TYPE_CLASS:
- case MONO_TYPE_OBJECT:
return type->data.klass->blittable;
break;
default:
@@ -170,6 +173,9 @@ mono_method_blittable (MonoMethod *method)
if (mono_method_has_marshal_info (method))
return FALSE;
+ if ((method->flags & METHOD_ATTRIBUTE_PINVOKE_IMPL) && ((MonoMethodPInvoke*)method)->piflags & PINVOKE_ATTRIBUTE_SUPPORTS_LAST_ERROR)
+ return FALSE;
+
return TRUE;
}
#endif
@@ -3073,7 +3079,6 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
fsig = mono_metadata_parse_signature (image, token);
n = fsig->param_count + fsig->hasthis;
-
} else {
if (method->wrapper_type != MONO_WRAPPER_NONE) {
cmethod = (MonoMethod *)mono_method_get_wrapper_data (method, token);
@@ -3120,12 +3125,23 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
if (*ip != CEE_CALLI && check_call_signature (cfg, fsig, sp))
goto unverified;
- if ((ins_flag & MONO_INST_TAILCALL) && cmethod && (*ip == CEE_CALL)) {
+ if ((ins_flag & MONO_INST_TAILCALL) && cmethod && (*ip == CEE_CALL) && (mono_metadata_signature_equal (method->signature, cmethod->signature))) {
int i;
+ /* FIXME: This assumes the two methods has the same number and type of arguments */
for (i = 0; i < n; ++i) {
+ /* Check if argument is the same */
+ NEW_ARGLOAD (cfg, ins, i);
+ if ((ins->opcode == sp [i]->opcode) && (ins->inst_i0 == sp [i]->inst_i0))
+ continue;
+
NEW_ARGSTORE (cfg, ins, i, sp [i]);
ins->cil_code = ip;
- MONO_ADD_INS (bblock, ins);
+ if (ins->opcode == CEE_STOBJ) {
+ NEW_ARGLOADA (cfg, ins, i);
+ handle_stobj (cfg, bblock, ins, sp [i], sp [i]->cil_code, ins->klass, FALSE, FALSE);
+ }
+ else
+ MONO_ADD_INS (bblock, ins);
}
MONO_INST_NEW (cfg, ins, CEE_JMP);
ins->cil_code = ip;
@@ -4129,8 +4145,8 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
handle_loaded_temps (cfg, bblock, stack_start, sp);
- if (cfg->domain->thread_static_fields)
- addr = g_hash_table_lookup (cfg->domain->thread_static_fields, field);
+ if (cfg->domain->special_static_fields)
+ addr = g_hash_table_lookup (cfg->domain->special_static_fields, field);
if ((cfg->opt & MONO_OPT_SHARED) || (mono_compile_aot && addr)) {
int temp;
@@ -4170,7 +4186,7 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
int temp;
MonoInst *iargs [1];
NEW_ICONST (cfg, iargs [0], GPOINTER_TO_UINT (addr));
- temp = mono_emit_jit_icall (cfg, bblock, mono_threads_get_static_data, iargs, ip);
+ temp = mono_emit_jit_icall (cfg, bblock, mono_get_special_static_data, iargs, ip);
NEW_TEMPLOAD (cfg, ins, temp);
}
}
@@ -5160,6 +5176,7 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
ins->inst_left = *sp;
ins->cil_code = ip;
+ cfg->flags |= MONO_CFG_HAS_ALLOCA;
if (header->init_locals)
ins->flags |= MONO_INST_INIT;
@@ -5183,6 +5200,7 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
ip += 2;
nearest = NULL;
+ nearest_num = 0;
for (cc = 0; cc < header->num_clauses; ++cc) {
clause = &header->clauses [cc];
if ((clause->flags & MONO_EXCEPTION_CLAUSE_FILTER) &&
@@ -5700,6 +5718,25 @@ create_helper_signature (void)
helper_sig_long_double->ret = &mono_defaults.int64_class->byval_arg;
helper_sig_long_double->pinvoke = 1;
+ /* double amethod (long) */
+ helper_sig_double_long = mono_metadata_signature_alloc (mono_defaults.corlib, 1);
+ helper_sig_double_long->params [0] = &mono_defaults.int64_class->byval_arg;
+ helper_sig_double_long->ret = &mono_defaults.double_class->byval_arg;
+ helper_sig_double_long->pinvoke = 1;
+
+ /* float amethod (long) */
+ helper_sig_float_long = mono_metadata_signature_alloc (mono_defaults.corlib, 1);
+ helper_sig_float_long->params [0] = &mono_defaults.int64_class->byval_arg;
+ helper_sig_float_long->ret = &mono_defaults.single_class->byval_arg;
+ helper_sig_float_long->pinvoke = 1;
+
+ /* double amethod (double, double) */
+ helper_sig_double_double_double = mono_metadata_signature_alloc (mono_defaults.corlib, 2);
+ helper_sig_double_double_double->params [0] = &mono_defaults.double_class->byval_arg;
+ helper_sig_double_double_double->params [1] = &mono_defaults.double_class->byval_arg;
+ helper_sig_double_double_double->ret = &mono_defaults.double_class->byval_arg;
+ helper_sig_double_double_double->pinvoke = 1;
+
/* uint amethod (double) */
helper_sig_uint_double = mono_metadata_signature_alloc (mono_defaults.corlib, 1);
helper_sig_uint_double->params [0] = &mono_defaults.double_class->byval_arg;
@@ -6029,38 +6066,6 @@ print_dfn (MonoCompile *cfg) {
g_print ("\n");
}
-/*
- * returns the offset used by spillvar. It allocates a new
- * spill variable if necessary.
- */
-int
-mono_spillvar_offset (MonoCompile *cfg, int spillvar)
-{
- MonoSpillInfo **si, *info;
- int i = 0;
-
- si = &cfg->spill_info;
-
- while (i <= spillvar) {
-
- if (!*si) {
- *si = info = mono_mempool_alloc (cfg->mempool, sizeof (MonoSpillInfo));
- info->next = NULL;
- cfg->stack_offset -= sizeof (gpointer);
- info->offset = cfg->stack_offset;
- }
-
- if (i == spillvar)
- return (*si)->offset;
-
- i++;
- si = &(*si)->next;
- }
-
- g_assert_not_reached ();
- return 0;
-}
-
void
mono_bblock_add_inst (MonoBasicBlock *bb, MonoInst *inst)
{
@@ -6234,6 +6239,7 @@ dec_foreach (MonoInst *tree, MonoCompile *cfg) {
break;
case 2:
+#ifdef MONO_ARCH_BIGMUL_INTRINS
if (tree->opcode == OP_LMUL
&& (cfg->opt & MONO_OPT_INTRINS)
&& (tree->inst_left->opcode == CEE_CONV_I8
@@ -6246,7 +6252,9 @@ dec_foreach (MonoInst *tree, MonoCompile *cfg) {
tree->inst_left = tree->inst_left->inst_left;
tree->inst_right = tree->inst_right->inst_left;
dec_foreach (tree, cfg);
- } else if ((info = mono_find_jit_opcode_emulation (tree->opcode))) {
+ } else
+#endif
+ if ((info = mono_find_jit_opcode_emulation (tree->opcode))) {
MonoInst *iargs [2];
iargs [0] = tree->inst_i0;
@@ -6845,6 +6853,8 @@ mono_codegen (MonoCompile *cfg)
mono_arch_patch_code (cfg->method, cfg->domain, cfg->native_code, cfg->patch_info);
+ mono_arch_flush_icache (cfg->native_code, cfg->code_len);
+
mono_debug_close_method (cfg);
}
@@ -7649,11 +7659,17 @@ mini_init (const char *filename)
mono_runtime_install_handlers ();
mono_threads_install_cleanup (mini_thread_cleanup);
+#define JIT_TRAMPOLINES_WORK
+#ifdef JIT_TRAMPOLINES_WORK
mono_install_compile_method (mono_jit_compile_method);
mono_install_trampoline (mono_arch_create_jit_trampoline);
mono_install_remoting_trampoline (mono_jit_create_remoting_trampoline);
+#endif
+#define JIT_INVOKE_WORKS
+#ifdef JIT_INVOKE_WORKS
mono_install_runtime_invoke (mono_jit_runtime_invoke);
mono_install_handler (mono_arch_get_throw_exception ());
+#endif
mono_install_stack_walk (mono_jit_walk_stack);
mono_install_get_config_dir ();
@@ -7670,6 +7686,8 @@ mini_init (const char *filename)
create_helper_signature ();
+#define JIT_CALLS_WORK
+#ifdef JIT_CALLS_WORK
/* Needs to be called here since register_jit_icall depends on it */
mono_marshal_init ();
@@ -7711,6 +7729,22 @@ mini_init (const char *filename)
mono_register_opcode_emulation (OP_FCONV_TO_OVF_I8, "__emul_fconv_to_ovf_i8", helper_sig_long_double, mono_fconv_ovf_i8, TRUE);
mono_register_opcode_emulation (OP_FCONV_TO_OVF_U8, "__emul_fconv_to_ovf_u8", helper_sig_ulong_double, mono_fconv_ovf_u8, TRUE);
+#ifdef MONO_ARCH_EMULATE_FCONV_TO_I8
+ mono_register_opcode_emulation (OP_FCONV_TO_I8, "__emul_fconv_to_i8", helper_sig_long_double, mono_fconv_i8, FALSE);
+#endif
+#ifdef MONO_ARCH_EMULATE_LCONV_TO_R8
+ mono_register_opcode_emulation (OP_LCONV_TO_R8, "__emul_lconv_to_r8", helper_sig_double_long, mono_lconv_to_r8, FALSE);
+#endif
+#ifdef MONO_ARCH_EMULATE_LCONV_TO_R4
+ mono_register_opcode_emulation (OP_LCONV_TO_R4, "__emul_lconv_to_r4", helper_sig_float_long, mono_lconv_to_r4, FALSE);
+#endif
+#ifdef MONO_ARCH_EMULATE_LCONV_TO_R8_UN
+ mono_register_opcode_emulation (OP_LCONV_TO_R_UN, "__emul_lconv_to_r8_un", helper_sig_double_long, mono_lconv_to_r8_un, FALSE);
+#endif
+#ifdef MONO_ARCH_EMULATE_FREM
+ mono_register_opcode_emulation (OP_FREM, "__emul_frem", helper_sig_double_double_double, fmod, FALSE);
+#endif
+
#if SIZEOF_VOID_P == 4
mono_register_opcode_emulation (OP_FCONV_TO_U, "__emul_fconv_to_u", helper_sig_uint_double, mono_fconv_u4, TRUE);
#else
@@ -7721,7 +7755,7 @@ mini_init (const char *filename)
mono_register_jit_icall (mono_class_static_field_address , "mono_class_static_field_address",
helper_sig_ptr_ptr_ptr, FALSE);
mono_register_jit_icall (mono_ldtoken_wrapper, "mono_ldtoken_wrapper", helper_sig_ptr_ptr_ptr, FALSE);
- mono_register_jit_icall (mono_threads_get_static_data, "mono_threads_get_static_data", helper_sig_ptr_int, FALSE);
+ mono_register_jit_icall (mono_get_special_static_data, "mono_get_special_static_data", helper_sig_ptr_int, FALSE);
mono_register_jit_icall (mono_ldstr, "mono_ldstr", helper_sig_ldstr, FALSE);
mono_register_jit_icall (helper_memcpy, "helper_memcpy", helper_sig_memcpy, FALSE);
mono_register_jit_icall (helper_memset, "helper_memset", helper_sig_memset, FALSE);
@@ -7751,9 +7785,13 @@ mini_init (const char *filename)
mono_register_jit_icall (mono_runtime_class_init, "mono_runtime_class_init", helper_sig_void_ptr, FALSE);
mono_register_jit_icall (mono_ldftn, "mono_ldftn", helper_sig_compile, FALSE);
mono_register_jit_icall (mono_ldvirtfn, "mono_ldvirtfn", helper_sig_compile_virt, FALSE);
+#endif
+#define JIT_RUNTIME_WORKS
+#ifdef JIT_RUNTIME_WORKS
mono_runtime_install_cleanup ((MonoDomainFunc)mini_cleanup);
mono_runtime_init (domain, mono_thread_start_cb, mono_thread_attach_cb);
+#endif
//mono_thread_attach (domain);
return domain;
diff --git a/mono/mini/mini.h b/mono/mini/mini.h
index 2caf36834ed..391e24c9b90 100644
--- a/mono/mini/mini.h
+++ b/mono/mini/mini.h
@@ -1,6 +1,7 @@
#ifndef __MONO_MINI_H__
#define __MONO_MINI_H__
+#include "config.h"
#include <glib.h>
#include <signal.h>
#include <mono/metadata/loader.h>
@@ -17,6 +18,19 @@
#define MONO_USE_AOT_COMPILER
+/* for 32 bit systems */
+#if G_BYTE_ORDER == G_LITTLE_ENDIAN
+#define MINI_LS_WORD_OFFSET 0
+#define MINI_MS_WORD_OFFSET 4
+#define inst_ls_word data.op[0].const_val
+#define inst_ms_word data.op[1].const_val
+#else
+#define MINI_LS_WORD_OFFSET 4
+#define MINI_MS_WORD_OFFSET 0
+#define inst_ls_word data.op[1].const_val
+#define inst_ms_word data.op[0].const_val
+#endif
+
/* Version number of the AOT file format */
#define MONO_AOT_FILE_VERSION "6"
@@ -265,7 +279,6 @@ enum {
#define inst_newa_len data.op[0].src
#define inst_newa_class data.op[1].klass
-#define inst_switch data.op[0].switch_blocks
#define inst_var data.op[0].var
#define inst_vtype data.op[1].vtype
/* in branch instructions */
@@ -450,7 +463,8 @@ typedef struct {
guint varinfo_count; /* total storage in varinfo */
gint stack_offset;
MonoRegState *rs;
- MonoSpillInfo *spill_info;
+ MonoSpillInfo *spill_info; /* machine register spills */
+ MonoSpillInfo *spill_info_float; /* fp register spills */
gint spill_count;
// unsigned char *cil_code;
@@ -626,7 +640,6 @@ void mono_blockset_print (MonoCompile *cfg, MonoBitSet *set,
void mono_print_tree (MonoInst *tree);
void mono_print_tree_nl (MonoInst *tree);
void mono_print_code (MonoCompile *cfg);
-int mono_spillvar_offset (MonoCompile *cfg, int spillvar);
void mono_select_instructions (MonoCompile *cfg);
const char* mono_inst_name (int op);
void mono_inst_foreach (MonoInst *tree, MonoInstFunc func, gpointer data);
@@ -687,6 +700,7 @@ void mono_arch_local_regalloc (MonoCompile *cfg, MonoBasicBloc
void mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb);
gboolean mono_arch_has_unwind_info (gconstpointer addr);
void mono_arch_setup_jit_tls_data (MonoJitTlsData *tls);
+void mono_arch_emit_this_vret_args (MonoCompile *cfg, MonoCallInst *inst, int this_reg, int this_type, int vt_reg);
void mono_arch_allocate_vars (MonoCompile *m);
void mono_jit_walk_stack (MonoStackWalk func, gpointer user_data);
MonoArray *ves_icall_get_trace (MonoException *exc, gint32 skip, MonoBoolean need_file_info);
diff --git a/mono/mini/tramp-ppc.c b/mono/mini/tramp-ppc.c
index d21ec2c2240..9f13292e508 100644
--- a/mono/mini/tramp-ppc.c
+++ b/mono/mini/tramp-ppc.c
@@ -210,6 +210,7 @@ ppc_class_init_trampoline (void *vtable, guint32 *code, char *sp)
{
mono_runtime_class_init (vtable);
+#if 0
/* This is the 'bl' instruction */
--code;
@@ -220,6 +221,7 @@ ppc_class_init_trampoline (void *vtable, guint32 *code, char *sp)
} else {
g_assert_not_reached ();
}
+#endif
}
static guchar*
@@ -496,6 +498,7 @@ mono_arch_create_jit_trampoline (MonoMethod *method)
/* Now save LR - we'll overwrite it now */
ppc_mflr (buf, ppc_r11);
ppc_stw (buf, ppc_r11, 4, ppc_r1);
+ ppc_stw (buf, ppc_r11, 8, ppc_r1);
/* Prepare the jump to the generic trampoline code.*/
ppc_lis (buf, ppc_r11, (guint32) vc >> 16);
@@ -750,7 +753,23 @@ mono_arch_create_class_init_trampoline (MonoVTable *vtable)
the trampoline relies on r11 having the same value it had before coming
here, so we must save it before. */
code = buf = g_malloc(METHOD_TRAMPOLINE_SIZE);
-
+
+#if 1
+ ppc_mflr (buf, ppc_r4);
+ ppc_stw (buf, ppc_r4, PPC_RET_ADDR_OFFSET, ppc_sp);
+ ppc_stwu (buf, ppc_sp, -32, ppc_sp);
+ ppc_load (buf, ppc_r3, vtable);
+ ppc_load (buf, ppc_r5, 0);
+
+ ppc_load (buf, ppc_r0, ppc_class_init_trampoline);
+ ppc_mtlr (buf, ppc_r0);
+ ppc_blrl (buf);
+
+ ppc_lwz (buf, ppc_r0, 32 + PPC_RET_ADDR_OFFSET, ppc_sp);
+ ppc_mtlr (buf, ppc_r0);
+ ppc_addic (buf, ppc_sp, ppc_sp, 32);
+ ppc_blr (buf);
+#else
/* Save r11. There's nothing magic in the '44', its just an arbitrary
position - see above */
ppc_stw (buf, ppc_r11, -44, ppc_r1);
@@ -758,6 +777,7 @@ mono_arch_create_class_init_trampoline (MonoVTable *vtable)
/* Now save LR - we'll overwrite it now */
ppc_mflr (buf, ppc_r11);
ppc_stw (buf, ppc_r11, 4, ppc_r1);
+ ppc_stw (buf, ppc_r11, PPC_RET_ADDR_OFFSET, ppc_r1);
/* Prepare the jump to the generic trampoline code.*/
ppc_lis (buf, ppc_r11, (guint32) tramp >> 16);
@@ -767,8 +787,13 @@ mono_arch_create_class_init_trampoline (MonoVTable *vtable)
/* And finally put 'vtable' in r11 and fly! */
ppc_lis (buf, ppc_r11, (guint32) vtable >> 16);
ppc_ori (buf, ppc_r11, ppc_r11, (guint32) vtable & 0xffff);
- ppc_blr (buf);
-
+ ppc_blrl (buf);
+ ppc_lwz (buf, ppc_r0, PPC_RET_ADDR_OFFSET, ppc_r1);
+ ppc_mtlr (buf, ppc_r0);
+ ppc_blr (buf);
+
+#endif
+
/* Flush instruction cache, since we've generated code */
mono_arch_flush_icache (code, buf - code);
diff --git a/mono/mini/tramp-x86.c b/mono/mini/tramp-x86.c
index 817b8125810..fa247869def 100644
--- a/mono/mini/tramp-x86.c
+++ b/mono/mini/tramp-x86.c
@@ -122,9 +122,9 @@ x86_magic_trampoline (int eax, int ecx, int edx, int esi, int edi,
MonoJitInfo *target_ji =
mono_jit_info_table_find (mono_domain_get (), addr);
- /* m->addr means pinvoke or icall */
- if (m->addr || mono_method_same_domain (ji, target_ji)) {
- *((guint32*)(code + 2)) = (guint)addr - ((guint)code + 1) - 5;
+ /* The first part of the condition means an icall without a wrapper */
+ if ((!target_ji && m->addr) || mono_method_same_domain (ji, target_ji)) {
+ InterlockedExchange ((gint32*)(code + 2), (guint)addr - ((guint)code + 1) - 5);
#ifdef HAVE_VALGRIND_MEMCHECK_H
/* Tell valgrind to recompile the patched code */
VALGRIND_DISCARD_TRANSLATIONS (code + 2, code + 6);
@@ -197,18 +197,31 @@ static void
x86_class_init_trampoline (int eax, int ecx, int edx, int esi, int edi,
int ebx, guint8 *code, MonoVTable *vtable)
{
- int i;
-
mono_runtime_class_init (vtable);
code -= 5;
if (code [0] == 0xe8) {
+ guint32 ops;
+ /*
+ * Thread safe code patching using the algorithm from the paper
+ * 'Practicing JUDO: Java Under Dynamic Optimizations'
+ */
/*
- * FIXME: This is not thread safe, since another thread might execute
- * the partially changed code.
+ * First atomically change the the first 2 bytes of the call to a
+ * spinning jump.
*/
- for (i = 0; i < 5; ++i)
- x86_nop (code);
+ ops = 0xfeeb;
+ InterlockedExchange ((gint32*)code, ops);
+
+ /* Then change the other bytes to a nop */
+ code [2] = 0x90;
+ code [3] = 0x90;
+ code [4] = 0x90;
+
+ /* Then atomically change the first 4 bytes to a nop as well */
+ ops = 0x90909090;
+ InterlockedExchange ((guint32*)code, ops);
+
#ifdef HAVE_VALGRIND_MEMCHECK_H
/* FIXME: the calltree skin trips on the self modifying code above */
@@ -217,7 +230,7 @@ x86_class_init_trampoline (int eax, int ecx, int edx, int esi, int edi,
#endif
}
else
- if (code [0] == 0x90)
+ if (code [0] == 0x90 || code [0] == 0xeb)
/* Already changed by another thread */
;
else {
diff --git a/mono/monoburg/monoburg.1 b/mono/monoburg/monoburg.1
index 175df78be9a..8310de4d5d9 100644
--- a/mono/monoburg/monoburg.1
+++ b/mono/monoburg/monoburg.1
@@ -15,6 +15,7 @@ monoburg \- code generator generator
[\-p]
[\-c VALUE]
[\-d HEADER]
+[\-DVALUE]
[FILE...]
.SH DESCRIPTION
The \fImonoburg\fP program is used to generate tree pattern matchers
@@ -74,7 +75,8 @@ reg: Fetch (addr)
.RE
.fi
.PP
-
+A simple pre-processor is included, consisting of: %ifdef, %else and
+%endif. %ifdef operates on definitions from the command line.
.SH OPTIONS
The following options are supported:
.TP
@@ -94,7 +96,10 @@ Extended mode. Enables monoburg to work with DAGs.
.TP
.I "-c VALUE"
Set the default costs to VALUE
-
+.TP
+.I "-Dvar"
+Defines the variable "var" as true. This is used with %ifdef, %else
+and %endif in the source files to perform conditional compilation.
.PP
.SH AUTHOR
monoburg was written by Dietmar Maurer. It is based on the papers from
diff --git a/mono/monoburg/monoburg.c b/mono/monoburg/monoburg.c
index 36f5dd81486..64e71371399 100644
--- a/mono/monoburg/monoburg.c
+++ b/mono/monoburg/monoburg.c
@@ -23,6 +23,7 @@ static GList *prefix_list;
FILE *inputfd;
FILE *outputfd;
+GHashTable *definedvars;
static FILE *deffd;
static FILE *cfd;
@@ -975,6 +976,7 @@ main (int argc, char *argv [])
GList *infiles = NULL;
int i;
+ definedvars = g_hash_table_new (g_str_hash, g_str_equal);
g_log_set_handler (NULL, G_LOG_LEVEL_WARNING, warning_handler, stderr);
for (i = 1; i < argc; i++){
@@ -991,6 +993,9 @@ main (int argc, char *argv [])
cfile = argv [++i];
} else if (argv [i][1] == 'c') {
default_cost = atoi (argv [++i]);
+ } else if (argv [i][1] == 'D') {
+ g_hash_table_insert (definedvars, &argv [i][2],
+ GUINT_TO_POINTER (1));
} else {
usage ();
}
diff --git a/mono/monoburg/monoburg.h b/mono/monoburg/monoburg.h
index a2ca13b4450..1c379094708 100644
--- a/mono/monoburg/monoburg.h
+++ b/mono/monoburg/monoburg.h
@@ -8,6 +8,7 @@ int yylex (void);
extern FILE *inputfd;
extern FILE *outputfd;
+extern GHashTable *definedvars;
typedef struct _Rule Rule;
diff --git a/mono/monoburg/monoburg.y b/mono/monoburg/monoburg.y
index 22a615f3859..e1ae661e678 100644
--- a/mono/monoburg/monoburg.y
+++ b/mono/monoburg/monoburg.y
@@ -107,6 +107,64 @@ reset_parser ()
state = 0;
}
+struct pplist {
+ struct pplist *next;
+ gboolean ignore;
+};
+
+static struct pplist *pp = NULL;
+
+static char*
+getvar (const char *input)
+{
+ char *var = g_strchug (g_strdup (input));
+ char *ptr;
+
+ for (ptr = var; *ptr && *ptr != '\n'; ++ptr) {
+ if (g_ascii_isspace (*ptr)) {
+ break;
+ }
+ }
+ *ptr = '\0';
+
+ return var;
+}
+
+static void
+push_if (char *input, gboolean flip)
+{
+ struct pplist *new_pp = g_new (struct pplist, 1);
+ char *var = getvar (input);
+
+ new_pp->ignore = (g_hash_table_lookup (definedvars, var) == NULL) ^ flip;
+ new_pp->next = pp;
+
+ new_pp->ignore |= (pp ? pp->ignore : 0);
+ pp = new_pp;
+ g_free (var);
+}
+
+static void
+flip_if ()
+{
+ if (!pp)
+ yyerror ("%%else without %%if");
+
+ pp->ignore = !pp->ignore | (pp->next ? pp->next->ignore : 0);
+}
+
+static void
+pop_if ()
+{
+ struct pplist *prev_pp = pp;
+
+ if (!pp)
+ yyerror ("%%endif without %%if");
+
+ pp = pp->next;
+ g_free (prev_pp);
+}
+
static char
nextchar ()
{
@@ -123,6 +181,35 @@ nextchar ()
ll = (input [0] == '%' && input [1] == '%');
next_state = state;
+ if (state == 1) {
+ if (!ll && input [0] == '%') {
+ if (!strncmp (&input [1], "ifdef", 5)) {
+ push_if (&input [6], FALSE);
+ ll = TRUE;
+ continue;
+ }
+ else if (!strncmp (&input [1], "ifndef", 6)) {
+ push_if (&input [7], TRUE);
+ ll = TRUE;
+ continue;
+ }
+ else if (!strncmp (&input [1], "else", 4)) {
+ flip_if ();
+ ll = TRUE;
+ continue;
+ }
+ else if (!strncmp (&input [1], "endif", 5)) {
+ pop_if ();
+ ll = TRUE;
+ continue;
+ }
+ }
+ if (pp && pp->ignore) {
+ ll = TRUE;
+ continue;
+ }
+ }
+
switch (state) {
case 0:
if (ll) {
diff --git a/mono/monograph/ChangeLog b/mono/monograph/ChangeLog
index 977ac27d159..3daf128f2bd 100644
--- a/mono/monograph/ChangeLog
+++ b/mono/monograph/ChangeLog
@@ -1,3 +1,7 @@
+2003-11-12 Jackson Harper <jackson@ximian.com>
+
+ * monograph.c: Change default assembly name to mscorlib.dll
+
Thu Feb 6 02:43:23 PST 2003 Piers Haken <piersh@friskit.com>
* monograph.c: more warning cleanups
diff --git a/mono/monograph/monograph.c b/mono/monograph/monograph.c
index 710d17fd152..6595a29dd44 100644
--- a/mono/monograph/monograph.c
+++ b/mono/monograph/monograph.c
@@ -1042,7 +1042,7 @@ main (int argc, char *argv[]) {
if (argc > i + 1)
cname = argv [i + 1];
if (!aname)
- aname = "corlib.dll";
+ aname = "mscorlib.dll";
if (!cname && (graphtype == GRAPH_TYPES))
cname = "System.Object";
diff --git a/mono/profiler/ChangeLog b/mono/profiler/ChangeLog
index eefd12d6020..e4f70e52634 100644
--- a/mono/profiler/ChangeLog
+++ b/mono/profiler/ChangeLog
@@ -1,4 +1,7 @@
+2003-11-12 Jackson Harper <jackson@ximian.com>
+ * mono-cov.c: Change default assembly name to mscorlib.dll
+
Tue Jul 1 11:26:10 CEST 2003 Paolo Molaro <lupus@ximian.com>
* Makefile.am: added.
diff --git a/mono/profiler/mono-cov.c b/mono/profiler/mono-cov.c
index 1429452b767..c0112577a47 100644
--- a/mono/profiler/mono-cov.c
+++ b/mono/profiler/mono-cov.c
@@ -133,7 +133,7 @@ mono_profiler_startup (const char *desc)
prof->class_name = cname + 1;
}
} else {
- prof->assembly_name = g_strdup ("corlib");
+ prof->assembly_name = g_strdup ("mscorlib");
}
mono_profiler_install (prof, cov_shutdown);
diff --git a/mono/tests/ChangeLog b/mono/tests/ChangeLog
index 960f990312d..470feba750e 100644
--- a/mono/tests/ChangeLog
+++ b/mono/tests/ChangeLog
@@ -1,3 +1,13 @@
+2003-11-21 Lluis Sanchez Gual <lluis@ximian.com>
+
+ * context-static.cs: new test for ContextStaticAttribute.
+ * Makefile.am: added context-static.cs.
+
+2003-11-17 Zoltan Varga <vargaz@freemail.hu>
+
+ * cattr-object.cs: Fix test so it does not count the attributes on the
+ Object class.
+
2003-10-31 Zoltan Varga <vargaz@freemail.hu>
* appdomain-unload.cs: Get rid of hardcoded file names.
diff --git a/mono/tests/Makefile.am b/mono/tests/Makefile.am
index 68e0a766b9f..64045ef3bd1 100644
--- a/mono/tests/Makefile.am
+++ b/mono/tests/Makefile.am
@@ -155,6 +155,7 @@ TEST_CS_SRC= \
thread5.cs \
thread6.cs \
thread-static.cs \
+ context-static.cs \
float-pop.cs \
interfacecast.cs \
array3.cs \
diff --git a/mono/tests/cattr-object.cs b/mono/tests/cattr-object.cs
index 3d47a258da8..015f5ed7d8e 100644
--- a/mono/tests/cattr-object.cs
+++ b/mono/tests/cattr-object.cs
@@ -5,7 +5,7 @@ using System;
[My(typeof(System.Enum))]
class T {
static int Main() {
- object[] a = Attribute.GetCustomAttributes (typeof (T), true);
+ object[] a = Attribute.GetCustomAttributes (typeof (T), false);
if (a.Length != 3)
return 1;
foreach (object o in a) {
diff --git a/mono/tests/context-static.cs b/mono/tests/context-static.cs
new file mode 100644
index 00000000000..4d8d7a5d68c
--- /dev/null
+++ b/mono/tests/context-static.cs
@@ -0,0 +1,36 @@
+using System;
+using System.Runtime.Remoting.Contexts;
+
+[Synchronization (SynchronizationAttribute.REQUIRES_NEW)]
+class CBO: ContextBoundObject
+{
+ public bool Test () {
+ Console.WriteLine ("start value: {0}", T.var);
+ if (T.var != 0) return true;
+ T.var = 100;
+ Console.WriteLine ("end value: {0}", T.var);
+ return (T.var != 100);
+ }
+}
+
+class T {
+ [ContextStatic]
+ public static int var = 5;
+
+ static int Main () {
+ bool failed = false;
+ var = 10;
+
+ CBO cbo = new CBO();
+ failed = cbo.Test ();
+
+ if (var != 10)
+ failed = true;
+
+ Console.WriteLine ("value in main context: {0}", var);
+
+ if (failed)
+ return 1;
+ return 0;
+ }
+}
diff --git a/mono/utils/ChangeLog b/mono/utils/ChangeLog
index bb36d23f05a..dc977e7b2e8 100644
--- a/mono/utils/ChangeLog
+++ b/mono/utils/ChangeLog
@@ -1,3 +1,12 @@
+2003-11-12 Zoltan Varga <vargaz@freemail.hu>
+
+ * mono-math.h mono-math.c: New file which contains implementations of
+ math functions/macros which are missing on some platforms.
+
+2003-11-10 Dick Porter <dick@ximian.com>
+
+ * strenc.c: Use platform-endian UTF16
+
2003-10-28 Dick Porter <dick@ximian.com>
* strenc.h:
diff --git a/mono/utils/Makefile.am b/mono/utils/Makefile.am
index 8cc86242eac..e7958ff2896 100644
--- a/mono/utils/Makefile.am
+++ b/mono/utils/Makefile.am
@@ -8,6 +8,7 @@ libmonoutils_la_SOURCES = \
mono-sha1.c \
mono-logger.c \
monobitset.c \
+ mono-math.c \
strtod.h \
strtod.c \
strenc.h \
@@ -19,7 +20,8 @@ libmonoutilsinclude_HEADERS = \
monobitset.h \
mono-digest.h \
mono-logger.h \
- mono-hash.h
+ mono-hash.h \
+ mono-math.h
EXTRA_DIST = ChangeLog
diff --git a/mono/utils/mono-math.c b/mono/utils/mono-math.c
new file mode 100644
index 00000000000..ccff08ce493
--- /dev/null
+++ b/mono/utils/mono-math.c
@@ -0,0 +1,22 @@
+
+#include "mono-math.h"
+
+#ifndef HAVE_SIGNBIT
+
+int
+mono_signbit_float (float x)
+{
+ union { float f; int i; } u = { f: x };
+
+ return u.i < 0;
+}
+
+int
+mono_signbit_double (double x)
+{
+ union { double d; int i[2]; } u = { d: x };
+
+ return u.i [1] < 0;
+}
+
+#endif
diff --git a/mono/utils/mono-math.h b/mono/utils/mono-math.h
new file mode 100644
index 00000000000..90d14b6c611
--- /dev/null
+++ b/mono/utils/mono-math.h
@@ -0,0 +1,20 @@
+
+#ifndef __MONO_SIGNBIT_H__
+#define __MONO_SIGNBIT_H__
+
+#include <math.h>
+
+#ifdef HAVE_SIGNBIT
+#define mono_signbit signbit
+#else
+#define mono_signbit(x) (sizeof (x) == sizeof (float) ? mono_signbit_float (x) : mono_signbit_double (x))
+
+int
+mono_signbit_double (double x);
+
+int
+mono_signbit_float (float x);
+
+#endif
+
+#endif
diff --git a/mono/utils/strenc.c b/mono/utils/strenc.c
index c719914f80e..3d0fd5d4d73 100644
--- a/mono/utils/strenc.c
+++ b/mono/utils/strenc.c
@@ -9,17 +9,18 @@
#include <config.h>
#include <glib.h>
+#include <string.h>
#include "strenc.h"
#undef DEBUG
-/* Tries to turn a NULL-terminated string into UTF16LE.
+/* Tries to turn a NULL-terminated string into UTF16.
*
* First, see if it's valid UTF8, in which case just turn it directly
- * into UTF16LE. Next, run through the colon-separated encodings in
+ * into UTF16. Next, run through the colon-separated encodings in
* MONO_EXTERNAL_ENCODINGS and do an iconv conversion on each,
- * returning the first successful conversion to utf16. If no
+ * returning the first successful conversion to UTF16. If no
* conversion succeeds, return NULL.
*
* Callers must free the returned string if not NULL. bytes holds the number
@@ -37,11 +38,9 @@ gunichar2 *mono_unicode_from_external (const gchar *in, gsize *bytes)
}
if(g_utf8_validate (in, -1, NULL)) {
- /* Use g_convert not g_utf8_to_utf16 because we need
- * to specify LE
- */
- res=g_convert (in, -1, "UTF16LE", "UTF8", NULL, bytes, NULL);
- return((gunichar2 *)res);
+ gunichar2 *unires=g_utf8_to_utf16 (in, -1, NULL, (glong *)bytes, NULL);
+ *bytes *= 2;
+ return(unires);
}
encoding_list=g_getenv ("MONO_EXTERNAL_ENCODINGS");
@@ -61,13 +60,13 @@ gunichar2 *mono_unicode_from_external (const gchar *in, gsize *bytes)
gchar *utf8=g_locale_to_utf8 (in, -1, NULL, NULL,
NULL);
if(utf8!=NULL && g_utf8_validate (utf8, -1, NULL)) {
- res=g_convert (utf8, -1, "UTF16LE",
+ res=g_convert (utf8, -1, "UTF16",
encodings[i], NULL, bytes,
NULL);
}
g_free (utf8);
} else {
- res=g_convert (in, -1, "UTF16LE", encodings[i], NULL,
+ res=g_convert (in, -1, "UTF16", encodings[i], NULL,
bytes, NULL);
}
@@ -146,7 +145,7 @@ gchar *mono_utf8_from_external (const gchar *in)
return(NULL);
}
-/* Turns NULL-terminated UTF16LE into either UTF8, or the first
+/* Turns NULL-terminated UTF16 into either UTF8, or the first
* working item in MONO_EXTERNAL_ENCODINGS if set. If no conversions
* work, then UTF8 is returned.
*
diff --git a/runtime/Makefile.am b/runtime/Makefile.am
index 481692ee6be..3188fcec98e 100644
--- a/runtime/Makefile.am
+++ b/runtime/Makefile.am
@@ -6,7 +6,7 @@ assemblies_DATA = \
Accessibility.dll \
ByteFX.Data.dll \
Commons.Xml.Relaxng.dll \
- corlib.dll \
+ mscorlib.dll \
Cscompmgd.dll \
I18N.CJK.dll \
I18N.dll \
@@ -27,7 +27,7 @@ assemblies_DATA = \
Mono.Data.SybaseClient.dll \
Mono.Data.TdsClient.dll \
Mono.Data.Tds.dll \
- Mono.Directory.LDAP.dll \
+ Novell.Directory.Ldap.dll \
Mono.GetOptions.dll \
Mono.Http.dll \
Mono.PEToolkit.dll \
@@ -56,7 +56,8 @@ assemblies_DATA = \
System.Web.dll \
System.Web.Services.dll \
System.Windows.Forms.dll \
- System.Xml.dll
+ System.Xml.dll \
+ libgdiplus.dll.so
monobins_DATA = mcs.exe mbas.exe monoresgen.exe secutil.exe ilasm.exe cilc.exe xsd.exe wsdl.exe genxs.exe disco.exe sqlsharp.exe signcode.exe chktrust.exe
diff --git a/scripts/.cvsignore b/scripts/.cvsignore
index 78619f1ed7a..8dddd00eaa9 100644
--- a/scripts/.cvsignore
+++ b/scripts/.cvsignore
@@ -11,4 +11,6 @@ xsd
wsdl
genxs
chktrust
-signcode \ No newline at end of file
+signcode
+disco
+
diff --git a/web/Makefile.am b/web/Makefile.am
index cc45aa4aac2..68e822f30f7 100644
--- a/web/Makefile.am
+++ b/web/Makefile.am
@@ -8,7 +8,7 @@ WEB_FILES= \
tds-providers status testing thanks tools \
porting anoncvs monodoc-xml winforms
-OTHERS= pending resources-pending todo mono-build.sh mono-build-w32.sh
+OTHERS= pending resources-pending todo mono-build.sh mono-build-w32.sh print-stack
EXTRA_DIST = $(WEB_FILES) README $(OTHERS)
@@ -17,8 +17,8 @@ all-docs: $(WEB_FILES)
runtime documentation download faq contributing \
resources status > all-docs
-class-status: class-status.in pending-classes Makefile.am
- cat class-status.in pending-classes > class-status
+class-status: class-status.in Makefile.am
+ cat class-status.in > class-status
pending-classes:
diff --git a/web/anoncvs b/web/anoncvs
index 2e72173b458..c52d510fc53 100644
--- a/web/anoncvs
+++ b/web/anoncvs
@@ -2,7 +2,7 @@
Anonymous access to the Mono is available currently from three
servers (anoncvs-spain-1.go-mono.com,
- anoncvs-spain-2.go-mono.com and anoncvs-us-1.go-mono.com).
+ anoncvs-spain-2.go-mono.com and us-anoncvs.go-mono.com).
You can also use `anoncvs.go-mono.com', and that will pick a
server automatically for you.
@@ -43,6 +43,9 @@
Special thanks to Jesus Climent, Rodrigo Moya, Juantomás
García and Ismael Olea for making this happen.
+ Thanks to Matt Liotta of MontaraSoftware for hosting our
+ US-based AnonCVS server.
+
<a name="#mirror">
** Becoming an AnonCVS mirror
diff --git a/web/blogs b/web/blogs
index e1187bb52cc..4ed29e1010a 100644
--- a/web/blogs
+++ b/web/blogs
@@ -32,5 +32,7 @@
<br>
<a href="http://primates.ximian.com/~gonzalo/mono/blog/index.xml"><img align="center" src="images/xml.gif"></a>
<a href="http://primates.ximian.com/~gonzalo/mono/blog/">Gonzalo Paniagua</a>
-
+ <br>
+ <a href="http://codeblogs.ximian.com/blogs/ndrochak/index.rdf"><img align="center" src="images/xml.gif"></a>
+ <a href="http://codeblogs.ximian.com/blogs/ndrochak/">Nick Drochak</a>
diff --git a/web/class-status.in b/web/class-status.in
index 3a6af7b980f..9aa5311698d 100644
--- a/web/class-status.in
+++ b/web/class-status.in
@@ -5,36 +5,26 @@
Here is the status of the different assemblies:
<ul>
<li><a href="http://www.go-mono.com/class-status-corlib.html">corlib</a>: The core library.
- <li><a href="http://www.go-mono.com/class-status-System.html">System</a>.
+ <li><a href="http://www.go-mono.com/class-status-System.html">System</a>: Extra modules
<li><a href="http://www.go-mono.com/class-status-System.Xml.html">System.Xml</a>.
-
<li><a
href="http://www.go-mono.com/class-status-System.Data.html">System.Data</a>:
Database access functionality (also check the <a href="ado-net.html">Mono ADO.NET status</a> pages).
-
<li><a href="http://www.go-mono.com/class-status-System.Drawing.html">System.Drawing</a>.
-
<li><a
href="http://www.go-mono.com/class-status-System.Web.html">System.Web</a>:
ASP.NET classes, also check the <a href="asp-net.html">Mono ASP.NET status pages</a>
-
<li><a href="http://www.go-mono.com/class-status-System.Web.Services.html">System.Web.Services</a>.
-
<li><a
href="http://www.go-mono.com/class-status-Microsoft.VisualBasic.html">Microsoft.VisualBasic</a>:
Support runtime for Visual Basic applications
-
<li><a
href="http://www.go-mono.com/class-status-System.Windows.Forms.html">Windows.Forms</a>:
there is also a <a
href="http://lists.ximian.com/mailman/listinfo/mono-winforms-list">mailing
list available</a>
-
- <li><a href="http://www.go-mono.com/class-status-System.EnterpriseServices.html">EnterpriseServices</a>.
-
<li><a
href="http://www.go-mono.com/class-status-System.Runtime.Serialization.Formatters.Soap.html">System.Runtime.Serialization.Formatters.Soap</a>.
-
<li><a
href="http://www.go-mono.com/class-status-System.Security.html">System.Security</a>:
Xml Signature Security classes, also check the <a href="crypto.html">Cryptography status pages</a>
diff --git a/web/drawing b/web/drawing
new file mode 100644
index 00000000000..b8867f63d43
--- /dev/null
+++ b/web/drawing
@@ -0,0 +1,43 @@
+* Drawing
+
+ Mono provides two mechanism to draw. The first exposes the
+ Microsoft System.Drawing API and the second exposes the <a
+ href="http://www.cairographics.org">Cairo</a> API.
+
+* System.Drawing
+
+ The System.Drawing implementation in Mono is designed to be
+ compatible with the Microsoft API. The imaging model is very
+ similar to the PDF 1.4 composition-based imaging model.
+
+ Our implementation is a C# wrapper around the GDI+ C API (also
+ called the "GDI+ Flat API").
+
+ <center>
+ <img src="images/system-drawing.png">
+ </center>
+
+ In Windows Mono uses the GDI+ library that is included
+ with the operating system, while in Unix we provide an
+ implementation of this API which uses Cairo to do the heavy
+ lifting.
+
+ The implementation of GDI+ lives in mcs/class/System.Drawing
+ in the gdiplus directory and requires <a
+ href="http://www.cairographics.org">Cairo</a> to be installed
+ to get the package built.
+
+ The C# code that implement System.Drawing is the same for
+ Windows and Unix builds.
+
+ Since this is an implementation of an existing Microsoft API
+ no architectural changes go here.
+
+* Mono.Cairo
+
+ The Mono.Cairo.dll assembly exposes the Cairo API to managed
+ applications. The mapping is a pretty straightforward one,
+ and the programming model is very close to the C API.
+
+ This API is still unstable due to the nature of the underlying
+ API being used and will be revisited as Cairo evolves.
diff --git a/web/index b/web/index
index 0b6e3482aab..0ddfb13b6ee 100644
--- a/web/index
+++ b/web/index
@@ -141,6 +141,34 @@
</tr>
</table>
+@item Nov 25th: Gtk# 0.14, System.DirectoryServices
+
+ Gtk# 0.14 has been released, and it is available from <a
+ href="http://gtk-sharp.sf.net">the Gtk# web site</a>.
+
+ Sunil has checked in the implementation of
+ System.DirectoryServices as well as the Novell.Directory.Ldap
+ code into Mono CVS.
+
+@item Nov 14th: Gtk# 0.13 released.
+
+ Mike Kestner has <a
+ href="http://lists.ximian.com/archives/public/mono-list/2003-November/016943.html">announced</a>
+ the release of the <a href="http://gtk-sharp.sf.net">Gtk#</a>
+ GUI toolkit for .NET and Mono.
+
+@item Nov 13th: Managed LDAP binding for Mono and .NET
+
+ Sunil Kumar at Novell has <a
+ href="http://lists.ximian.com/archives/public/mono-list/2003-November/016907.html">announced</a>
+ the availability of a fully managed implementation of LDAP for
+ Mono and the .NET Framework.
+
+ You can obtain the library from <a
+ href="http://forge.novell.com">Novell Forge's</a> <a
+ href="http://forge.novell.com/modules/xfmod/cvs/cvsbrowse.php/ldapcsharp/CsharpLDAP">CSharpLDAP</a>
+ module.
+
@item Nov 4th: Mono Roadmap announced.
The <a href="mono-roadmap.html">Mono Roadmap</a> and <a
diff --git a/web/jit-debug b/web/jit-debug
index 85f92906989..e33deb65579 100644
--- a/web/jit-debug
+++ b/web/jit-debug
@@ -13,6 +13,34 @@
Notice that the program will need to be compiled with the -g
flag and that running with --debug will slow down the execution.
+* Debugging with GDB
+
+ If you use GDB to debug your mono process, you can use the function
+ print_method_from_ip(void *address) to obtain the name of a method
+ given an address.
+
+ For example:
+
+ <pre>
+(gdb) where
+#0 ves_icall_System_String_GetHashCode (me=0x80795d0) at string-icalls.c:861
+#1 0x0817f490 in ?? ()
+#2 0x0817f42a in ?? ()
+#3 0x0817f266 in ?? ()
+#4 0x0817f1a5 in ?? ()
+</pre>
+
+ You can now use:
+
+<pre>
+(gdb) p print_method_from_ip (0x0817f490)
+IP 0x817f490 at offset 0x28 of method (wrapper managed-to-native) System.String:GetHashCode () (0x817f468 0x817f4a4)
+$1 = void
+(gdb) p print_method_from_ip (0x0817f42a)
+IP 0x817f42a at offset 0x52 of method System.Collections.Hashtable:GetHash (object) (0x817f3d8 0x817f43b)
+$2 = void
+</pre>
+
* Mono Debugger
The Mono debugger is written in C# and can debug both managed
@@ -38,4 +66,4 @@
- \ No newline at end of file
+
diff --git a/web/mono-roadmap.html b/web/mono-roadmap.html
index e35e9e1741b..8f4b8037333 100644
--- a/web/mono-roadmap.html
+++ b/web/mono-roadmap.html
@@ -212,7 +212,7 @@ vertical-align: top;
components.
</ul>
- <p>Release target: Q1/2004.
+ <p>Release target: Q2/2004.
<p>Bug fix releases would be done on a monthly basis.
diff --git a/web/plans b/web/plans
index db6f6dde7c8..f53aecd4e95 100755
--- a/web/plans
+++ b/web/plans
@@ -8,7 +8,7 @@
Currently you can read our plans for <a
href="ado-net.html">ADO.NET</a>, <a
- href="asp-net">ASP.NET</a>, <a href="java.html">Java</a> and
+ href="asp-net.html">ASP.NET</a>, <a href="java.html">Java</a> and
<a href="winforms.html">WinForms</a>.
diff --git a/web/runtime b/web/runtime
index f828bb13221..c2ecdf425a8 100644
--- a/web/runtime
+++ b/web/runtime
@@ -19,7 +19,7 @@
We are using the Boehm conservative garbage collector.
The Mono runtime can be used as a stand-alone process, or it
- can be <a href="embedded-api">embedded into applications</a> (see
+ can be <a href="embedded-api.html">embedded into applications</a> (see
the documentation in mono/samples/embed for more details).
Embedding the Mono runtime allows applications to be extended
diff --git a/web/sqlite b/web/sqlite
index 35ee3056896..6730477202c 100755
--- a/web/sqlite
+++ b/web/sqlite
@@ -82,7 +82,7 @@
{
string connectionString = "URI=file:SqliteTest.db";
IDbConnection dbcon;
- dbcon = new MySQLConnection(connectionString);
+ dbcon = new SqliteConnection(connectionString);
dbcon.Open();
IDbCommand dbcmd = dbcon.CreateCommand();
// requires a table to be created named employee
diff --git a/web/web/commands b/web/web/commands
index 64c8d24ff58..5eac2a24831 100644
--- a/web/web/commands
+++ b/web/web/commands
@@ -42,6 +42,7 @@
1,Debugging,jit-debug.html,jit-debug.src
0,Plans,plans.html,plans.src
1,ADO.NET,ado-net.html,ado-net.src
+1,Drawing,drawing.html,drawing.src
2,ProviderFactory,provider-factory.html,provider-factory.src
2,Firebird Interbase,firebird.html,firebird.src
2,IBM DB2,ibmdb2.html,ibmdb2.src
@@ -68,6 +69,7 @@
1,Web.Services,class-status-System.Web.Services.html,class-status-System.Web.Services.src,cm/cormissing.css,cm/cormissing.js
1,Microsoft.VisualBasic,class-status-Microsoft.VisualBasic.html,class-status-Microsoft.VisualBasic.src,cm/cormissing.css,cm/cormissing.js
1,Windows.Forms,class-status-System.Windows.Forms.html,class-status-System.Windows.Forms.src,cm/cormissing.css,cm/cormissing.js
+1,DirectoryServices,class-status-System.DirectoryServices.html,class-status-System.DirectoryServices.src,cm/cormissing.css,cm/cormissing.js
1,Formatters.Soap,class-status-System.Runtime.Serialization.Formatters.Soap.html,class-status-System.Runtime.Serialization.Formatters.Soap.src,cm/cormissing.css,cm/cormissing.js
1,Cscompmgd,class-status-Cscompmgd.html,class-status-Cscompmgd.src,cm/cormissing.css,cm/cormissing.js
1,System.Security,class-status-System.Security.html,class-status-System.Security.src,cm/cormissing.css,cm/cormissing.js
diff --git a/web/web/infos/.cvsignore b/web/web/infos/.cvsignore
new file mode 100644
index 00000000000..6722cd96e78
--- /dev/null
+++ b/web/web/infos/.cvsignore
@@ -0,0 +1 @@
+*.xml
diff --git a/web/web/makefile b/web/web/makefile
index 91ac5b5129d..be86dab63fe 100644
--- a/web/web/makefile
+++ b/web/web/makefile
@@ -20,6 +20,7 @@ OBJECTS= \
deploy/ccvs.html \
deploy/documentation.html \
deploy/download.html \
+ deploy/drawing.html \
deploy/crypto.html \
deploy/embedded-api.html \
deploy/faq.html \
@@ -55,7 +56,6 @@ OBJECTS= \
deploy/provider-factory.html \
deploy/rationale.html \
deploy/resources.html \
- deploy/roadmap.html \
deploy/runtime.html \
deploy/screenshots.html \
deploy/sqlclient.html \
@@ -76,9 +76,11 @@ OBJECTS= \
deploy/class-status-System.Data.html \
deploy/class-status-System.Security.html \
deploy/class-status-System.Web.html \
+ deploy/class-status-System.Web.Services.html \
deploy/class-status-System.Drawing.html \
deploy/class-status-Microsoft.VisualBasic.html \
deploy/class-status-System.Windows.Forms.html \
+ deploy/class-status-System.DirectoryServices.html \
deploy/class-status-Cscompmgd.html \
deploy/class-status-System.Runtime.Serialization.Formatters.Soap.html
@@ -97,7 +99,7 @@ NON_HTML_SOURCES= \
all: $(OBJECTS) deploy/index.rss ../team
perl process.pl commands template.html.in deploy
cp $(HTML_SOURCES) deploy
- -mkdir deploy/team
+ test -d deploy/team || mkdir deploy/team
cp team/*png deploy/team
tutorial: mono-beginning.html.stamp mono-beginning.pdf
@@ -126,14 +128,16 @@ render-team-page.exe: render-team-page.cs
$(CSC) render-team-page.cs
clean:
- rm -f $(OBJECTS) $(patsubst deploy/%.html,src/%.src, $(OBJECTS)) src/*.xml src/*.html.in ../class-status-* ../class-status
+ rm -f $(OBJECTS) $(patsubst deploy/%.html,src/%.src, $(OBJECTS)) src/*.xml src/*.html.in ../class-status-* ../class-status infos/*
push:
cp -f $(NON_HTML_SOURCES) deploy
+ cp ../mono-roadmap.html deploy
#echo scp -P 2200 -r deploy/* www@www.go-mono.com:/web/cvsmodules/mono
#(cd deploy; rsync --verbose --recursive --checksum --update --rsh='ssh' . www@www.go-mono.com:/web/cvsmodules/mono )
(cd deploy; rsync --verbose --recursive --checksum --update --rsh='ssh' . mono-web@www.go-mono.com:/web/cvsmodules/mono )
+
push2:
scp -r deploy/* primates:public_html/xxx
@@ -155,21 +159,41 @@ src/%.src: ../% commands template.html.in makefile
.PRECIOUS: src/%.html.in
-src/%.html.in: src/%.xml transform.exe $(CORCOMPARE)/cormissing.xsl
- cscript $(CORCOMPARE)/transform.js $< $(CORCOMPARE)/cormissing.xsl > $@
- #$(RUN_MONO) ./transform.exe
+src/%.html.in: src/%.xml transform.exe $(CORCOMPARE)/mono-api.xsl
+ $(RUN_MONO) ./transform.exe $< $(CORCOMPARE)/mono-api.xsl > $@ || (rm -f $@ && exit 1)
+.PRECIOUS: infos/%.xml
+infos/%.xml: ../../../mcs/class/lib/%.dll $(CORCOMPARE)/mono-api-info.exe
+ $(RUN_MONO) $(CORCOMPARE)/mono-api-info.exe $< > $@ || (rm -f $@ && exit 1)
.PRECIOUS: src/%.xml
-src/%.xml: ../../../mcs/class/lib/%.dll $(CORCOMPARE)/CorCompare.exe
- $(RUN_MONO) $(CORCOMPARE)/CorCompare.exe -x $@ $<
+src/%.xml: infos/%.xml $(CORCOMPARE)/mono-api-diff.exe
+ $(RUN_MONO) $(CORCOMPARE)/mono-api-diff.exe masterinfos/$(notdir $<) $< > $@ || (rm -f $@ && exit 1)
+
+# corlib, corlib...
+infos/mscorlib.xml: ../../../mcs/class/lib/mscorlib.dll $(CORCOMPARE)/mono-api-info.exe
+ $(RUN_MONO) $(CORCOMPARE)/mono-api-info.exe $(notdir $(basename $<)) > $@ || (rm -f $@ && exit 1)
+
+src/corlib.xml: infos/mscorlib.xml $(CORCOMPARE)/mono-api-diff.exe
+ $(RUN_MONO) $(CORCOMPARE)/mono-api-diff.exe masterinfos/mscorlib.xml $< > $@ || (rm -f $@ && exit 1)
+
+# System
+infos/System.xml: ../../../mcs/class/lib/System.dll $(CORCOMPARE)/mono-api-info.exe
+ $(RUN_MONO) $(CORCOMPARE)/mono-api-info.exe $(notdir $(basename $<)) > $@ || (rm -f $@ && exit 1)
+
+src/System.xml: infos/System.xml $(CORCOMPARE)/mono-api-diff.exe
+ $(RUN_MONO) $(CORCOMPARE)/mono-api-diff.exe masterinfos/System.xml $< > $@ || (rm -f $@ && exit 1)
+
+# System.Xml
+infos/System.Xml.xml: ../../../mcs/class/lib/System.Xml.dll $(CORCOMPARE)/mono-api-info.exe
+ $(RUN_MONO) $(CORCOMPARE)/mono-api-info.exe $(notdir $(basename $<)) > $@ || (rm -f $@ && exit 1)
-src/corlib.xml: ../../../mcs/class/lib/corlib_cmp.dll $(CORCOMPARE)/CorCompare.exe
- $(RUN_MONO) $(CORCOMPARE)/CorCompare.exe -f corlib -ms mscorlib -x $@ $<
+src/System.Xml.xml: infos/System.Xml.xml $(CORCOMPARE)/mono-api-diff.exe
+ $(RUN_MONO) $(CORCOMPARE)/mono-api-diff.exe masterinfos/System.Xml.xml $< > $@ || (rm -f $@ && exit 1)
-src/System.Security.xml: ../../../mcs/class/lib/System.Security_cmp.dll $(CORCOMPARE)/CorCompare.exe
- $(RUN_MONO) $(CORCOMPARE)/CorCompare.exe -f System.Security -ms System.Security -x $@ $<
+src/System.DirectoryServices.xml: infos/System.DirectoryServices.xml $(CORCOMPARE)/mono-api-diff.exe
+ $(RUN_MONO) $(CORCOMPARE)/mono-api-diff.exe masterinfos/System.DirectoryServices.xml $< > $@ || (rm -f $@ && exit 1)
../class-status: ../class-status.in
cp -f $< $@
diff --git a/web/web/masterinfos/.cvsignore b/web/web/masterinfos/.cvsignore
new file mode 100644
index 00000000000..6722cd96e78
--- /dev/null
+++ b/web/web/masterinfos/.cvsignore
@@ -0,0 +1 @@
+*.xml
diff --git a/web/web/team.xml b/web/web/team.xml
index 726757b1b90..cf5eeb63163 100644
--- a/web/web/team.xml
+++ b/web/web/team.xml
@@ -648,7 +648,7 @@
</name>
- <e-mail>jackson@latitudegeo.com</e-mail>
+ <e-mail>jackson@ximian.com</e-mail>
<image>jackson.png</image>
@@ -658,11 +658,11 @@
<tasks>
- <task>Misc Bug fixes</task>
+ <task>IL Assembler</task>
- <task>Cscompmgd</task>
+ <task>System.Web</task>
- <task>IL Assembler</task>
+ <task>Bug Fix0r</task>
</tasks>
@@ -678,7 +678,7 @@
</name>
- <e-mail>ndrochak AT gol.com</e-mail>
+ <e-mail>ndrochak AT ieee.org</e-mail>
<image>nickd.png</image>
diff --git a/web/web/team/jackson.png b/web/web/team/jackson.png
index fd99a69a1a7..2fb5545ee61 100644
--- a/web/web/team/jackson.png
+++ b/web/web/team/jackson.png
Binary files differ
diff --git a/web/winforms b/web/winforms
index e2b3ad59398..b98d0d3a561 100644
--- a/web/winforms
+++ b/web/winforms
@@ -90,9 +90,7 @@
* System.Drawing
- We currently have two code paths: the Wine-based
- System.Drawing and the Cairo-based one. We will eventually
- unify everything to use Cairo, but currently the effort can
- continue with the approach we have.
-
+ For details, see the <a
+ href="drawing.html">System.Drawing implementation notes</a>
+ section of the web site.