[prev in list] [next in list] [prev in thread] [next in thread]
List: mono-patches
Subject: [Mono-patches] [mono/mono] [2 commits] 46cd052a: Implementation of Properties and Methods in MethodS
From: "Marek Safar (marek.safar () gmail ! com)" <mono-patches () lists ! ximian ! com>
Date: 2013-10-31 7:00:31
Message-ID: 000001420d503ddc-5debdbdd-e748-4294-9512-cf43fce92889-000000 () email ! amazonses ! com
[Download RAW message or body]
Branch: refs/heads/master
Home: https://github.com/mono/mono
Compare: https://github.com/mono/mono/compare/724f6285a356...96a201f7fe81
Commit: 46cd052a3ab3102c59ed70f60a6290b4ed63da97
Author: aakashapoorv <aakash.apoorv@outlook.com> (aakashapoorv)
Date: 2013-10-31 03:00:22 GMT
URL: https://github.com/mono/mono/commit/46cd052a3ab3102c59ed70f60a6290b4ed63da97
Implementation of Properties and Methods in MethodSignatureGenerator.cs
Implemented following properties:-
CodeProvider
ContainerParameterType
DataSetClassName
IsGetMethod
PagingMethod
ParameterGenerationOption
ParameterOption
TableClassName
and following methods:-
GenerateMethod
GenerateMethodSignature
GenerateUpdatingMethods
SetDesignTableContent
SetMethodSourceContent
Changed paths:
M mcs/class/System.Design/System.Data.Design/MethodSignatureGenerator.cs
Modified: mcs/class/System.Design/System.Data.Design/MethodSignatureGenerator.cs
===================================================================
@@ -2,7 +2,8 @@
// MethodSignatureGenerator.cs
//
// Author:
-// Atsushi Enomoto (atsushi@ximian.com)
+// Atsushi Enomoto (atsushi@ximian.com)
+// Aakash Apoorv (aakash.apoorv@outlook.com)
//
// Copyright (C) 2007 Novell, Inc.
//
@@ -28,93 +29,237 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-#if NET_2_0
-
using System.CodeDom;
using System.CodeDom.Compiler;
using System.Collections;
using System.ComponentModel.Design;
+using System.Globalization;
+using System.IO;
+using System.Runtime;
namespace System.Data.Design
{
- public class MethodSignatureGenerator
- {
- public MethodSignatureGenerator ()
- {
- }
-
- [MonoTODO]
- public CodeDomProvider CodeProvider {
- get { throw new NotImplementedException (); }
- set { throw new NotImplementedException (); }
- }
-
- [MonoTODO]
- public Type ContainerParameterType {
- get { throw new NotImplementedException (); }
- set { throw new NotImplementedException (); }
- }
-
- [MonoTODO]
- public string DataSetClassName {
- get { throw new NotImplementedException (); }
- set { throw new NotImplementedException (); }
- }
-
- [MonoTODO]
- public bool IsGetMethod {
- get { throw new NotImplementedException (); }
- set { throw new NotImplementedException (); }
- }
-
- [MonoTODO]
- public bool PagingMethod {
- get { throw new NotImplementedException (); }
- set { throw new NotImplementedException (); }
- }
-
- [MonoTODO]
- public ParameterGenerationOption ParameterOption {
- get { throw new NotImplementedException (); }
- set { throw new NotImplementedException (); }
- }
-
- [MonoTODO]
- public string TableClassName {
- get { throw new NotImplementedException (); }
- set { throw new NotImplementedException (); }
- }
-
- [MonoTODO]
- public CodeMemberMethod GenerateMethod ()
- {
- throw new NotImplementedException ();
- }
-
- [MonoTODO]
- public string GenerateMethodSignature ()
- {
- throw new NotImplementedException ();
- }
-
- [MonoTODO]
- public CodeTypeDeclaration GenerateUpdatingMethods ()
- {
- throw new NotImplementedException ();
- }
-
- [MonoTODO]
- public void SetDesignTableContent (string designTableContent)
- {
- throw new NotImplementedException ();
- }
-
- [MonoTODO]
- public void SetMethodSourceContent (string methodSourceContent)
- {
- throw new NotImplementedException ();
- }
- }
-}
+ public class MethodSignatureGenerator
+ {
+ private static readonly char endOfStatement = ';';
+ private CodeDomProvider codeProvider;
+ private DbSource methodSource;
+ private Type containerParameterType = typeof (DataSet);
+ private bool pagingMethod;
+ private bool getMethod;
+ private ParameterGenerationOption parameterOption;
+ private string tableClassName;
+ private string datasetClassName;
+ private DesignTable designTable;
+
+ public CodeDomProvider CodeProvider {
+ get { return this.codeProvider; }
+ set { this.codeProvider = value; }
+ }
+
+ public Type ContainerParameterType {
+ get { return this.containerParameterType; }
+ set {
+ if (value != typeof (DataSet) && value != typeof \
(DataTable)) + throw new InternalException \
("Unsupported container parameter type."); +
+ this.containerParameterType = value;
+ }
+ }
+
+ public string DataSetClassName {
+ get { return this.datasetClassName; }
+ set { this.datasetClassName = value; }
+ }
+
+ public bool IsGetMethod {
+ get { return this.getMethod; }
+ set { this.getMethod = value; }
+ }
+
+ public bool PagingMethod {
+ get { return this.pagingMethod; }
+ set { this.pagingMethod = value; }
+ }
+
+ public ParameterGenerationOption ParameterOption {
+ get { return this.parameterOption; }
+ set { this.parameterOption = value; }
+ }
+
+ public string TableClassName {
+ get { return this.tableClassName; }
+ set { this.tableClassName = value; }
+ }
+
+ public CodeMemberMethod GenerateMethod () {
+
+ if (this.codeProvider == null)
+ throw new ArgumentException ("codeProvider");
+
+ if (this.methodSource == null)
+ throw new ArgumentException ("MethodSource");
+
+ QueryGeneratorBase queryGeneratorBase = null;
+
+ if (this.methodSource.QueryType == QueryType.Rowset && \
this.methodSource.CommandOperation == CommandOperation.Select) { + \
queryGeneratorBase = new QueryGenerator (null); + \
queryGeneratorBase.ContainerParameterTypeName = this.GetParameterTypeName (); + \
queryGeneratorBase.ContainerParameterName = this.GetParameterName (); + \
queryGeneratorBase.ContainerParameterType = this.containerParameterType; + \
} else { + queryGeneratorBase = new FunctionGenerator \
(null); + }
+
+ queryGeneratorBase.DeclarationOnly = true;
+ queryGeneratorBase.CodeProvider = this.codeProvider;
+ queryGeneratorBase.MethodSource = this.methodSource;
+ queryGeneratorBase.MethodName = this.GetMethodName ();
+ queryGeneratorBase.ParameterOption = this.parameterOption;
+ queryGeneratorBase.GeneratePagingMethod = this.pagingMethod;
+ queryGeneratorBase.GenerateGetMethod = this.getMethod;
+
+ return queryGeneratorBase.Generate ();
+ }
+
+ public string GenerateMethodSignature () {
+
+ if (this.codeProvider == null)
+ throw new ArgumentException ("codeProvider");
+
+ if (this.methodSource == null)
+ throw new ArgumentException ("MethodSource");
+
+ string value = null;
+ CodeTypeDeclaration codeType = this.GenerateMethodWrapper \
(out value); + StringWriter stringWriter = new \
StringWriter(CultureInfo.CurrentCulture); + \
this.codeProvider.GenerateCodeFromType (codeType, stringWriter, null); + \
string text = stringWriter.GetStringBuilder().ToString(); + \
string[] array = text.Split(Environment.NewLine.ToCharArray()); + \
string[] array2 = array; +
+ for (int i = 0; i < array2.Length; i++) {
+ string text2 = array2[i];
+
+ if (text2.Contains(value))
+ return text2.Trim().TrimEnd( new char[] { \
MethodSignatureGenerator.endOfStatement }); +
+ return null;
+ }
+ }
+
+ public CodeTypeDeclaration GenerateUpdatingMethods () {
+
+ if (this.designTable == null)
+ throw new InternalException ("DesignTable should not \
be null."); +
+ if (StringUtil.Empty (this.datasetClassName))
+ throw new InternalException ("DatasetClassName \
should not be empty."); +
+ CodeTypeDeclaration codeTypeDeclaration = new \
CodeTypeDeclaration ("wrapper"); + \
codeTypeDeclaration.IsInterface = true; + new QueryHandler \
(this.codeProvider, this.designTable) { + \
DeclarationsOnly = true + \
}.AddUpdateQueriesToDataComponent (codeTypeDeclaration, this.datasetClassName, \
this.codeProvider); +
+ return codeTypeDeclaration;
+ }
+
+ public void SetDesignTableContent (string designTableContent) {
+
+ DesignDataSource designDataSource = new DesignDataSource();
+ StringReader textReader = new StringReader \
(designTableContent); + designDataSource.ReadXmlSchema \
(textReader, null); +
+ if (designDataSource.DesignTables == null || \
designDataSource.DesignTables.Count != 1) + throw new \
InternalException ("Unexpected number of sources in deserialized DataSource."); + \
+ IEnumerator enumerator = \
designDataSource.DesignTables.GetEnumerator (); + \
enumerator.MoveNext (); + this.designTable = (DesignTable) \
enumerator.Current; + }
+
+ public void SetMethodSourceContent (string methodSourceContent) {
-#endif
+ DesignDataSource designDataSource = new DesignDataSource ();
+ StringReader textReader = new StringReader \
(methodSourceContent); + designDataSource.ReadXmlSchema \
(textReader, null); +
+ if (designDataSource.Sources == null || \
designDataSource.Sources.Count != 1) + throw new \
InternalException ("Unexpected number of sources in deserialized DataSource."); +
+ IEnumerator enumerator = \
designDataSource.Sources.GetEnumerator (); + \
enumerator.MoveNext (); + this.methodSource = (DbSource) \
enumerator.Current; + }
+
+ private CodeTypeDeclaration GenerateMethodWrapper (out string \
methodName) { +
+ CodeTypeDeclaration codeTypeDeclaration = new \
CodeTypeDeclaration ("Wrapper"); + \
codeTypeDeclaration.IsInterface = true; + CodeMemberMethod \
codeMemberMethod = this.GenerateMethod(); + \
codeTypeDeclaration.Members.Add (codeMemberMethod); + \
methodName = codeMemberMethod.Name; +
+ return codeTypeDeclaration;
+ }
+
+ private string GetParameterName () {
+
+ if (this.containerParameterType == typeof (DataTable))
+ return "dataTable";
+
+ return "dataSet";
+ }
+
+ private string GetParameterTypeName () {
+
+ if (StringUtil.Empty (this.datasetClassName))
+ throw new InternalException ("DatasetClassName \
should not be empty."); +
+ if (!(this.containerParameterType == typeof (DataTable)))
+ return this.datasetClassName;
+
+ if (StringUtil.Empty (this.tableClassName))
+ throw new InternalException ("TableClassName should \
not be empty."); +
+ return CodeGenHelper.GetTypeName (this.codeProvider, \
this.datasetClassName, this.tableClassName); + }
+
+ private string GetMethodName () {
+
+ if (this.methodSource.QueryType == QueryType.Rowset) {
+ if (this.getMethod) {
+ if (this.pagingMethod) {
+ if \
(this.methodSource.GeneratorGetMethodNameForPaging != null) + \
return this.methodSource.GeneratorGetMethodNameForPaging; +
+ return \
this.methodSource.GetMethodName + DataComponentNameHandler.PagingMethodSuffix; + \
} else { + if \
(this.methodSource.GeneratorGetMethodName != null) + \
return this.methodSource.GeneratorGetMethodName; +
+ return \
this.methodSource.GetMethodName; + }
+ } else {
+ if (this.pagingMethod) {
+ if \
(this.methodSource.GeneratorSourceNameForPaging != null) + \
return this.methodSource.GeneratorSourceNameForPaging; +
+ return this.methodSource.Name + \
DataComponentNameHandler.PagingMethodSuffix; + \
} else { + if \
(this.methodSource.GeneratorSourceName != null) + \
return this.methodSource.GeneratorSourceName; +
+ return this.methodSource.Name;
+ }
+ }
+ } else {
+ if (this.methodSource.GeneratorSourceName != null)
+ return \
this.methodSource.GeneratorSourceName; +
+ return this.methodSource.Name;
+ }
+ }
+ }
+}
Commit: 96a201f7fe81583e494bfaf647055d4f8acf64d3
Author: Marek Safar <marek.safar@gmail.com> (marek-safar)
Date: 2013-10-31 06:58:27 GMT
URL: https://github.com/mono/mono/commit/96a201f7fe81583e494bfaf647055d4f8acf64d3
Merge pull request #794 from aakashapoorv/patch-1
Implementation of Properties and Methods in MethodSignatureGenerator.cs
Changed paths:
M mcs/class/System.Design/System.Data.Design/MethodSignatureGenerator.cs
Modified: mcs/class/System.Design/System.Data.Design/MethodSignatureGenerator.cs
===================================================================
@@ -2,7 +2,8 @@
// MethodSignatureGenerator.cs
//
// Author:
-// Atsushi Enomoto (atsushi@ximian.com)
+// Atsushi Enomoto (atsushi@ximian.com)
+// Aakash Apoorv (aakash.apoorv@outlook.com)
//
// Copyright (C) 2007 Novell, Inc.
//
@@ -28,93 +29,237 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-#if NET_2_0
-
using System.CodeDom;
using System.CodeDom.Compiler;
using System.Collections;
using System.ComponentModel.Design;
+using System.Globalization;
+using System.IO;
+using System.Runtime;
namespace System.Data.Design
{
- public class MethodSignatureGenerator
- {
- public MethodSignatureGenerator ()
- {
- }
-
- [MonoTODO]
- public CodeDomProvider CodeProvider {
- get { throw new NotImplementedException (); }
- set { throw new NotImplementedException (); }
- }
-
- [MonoTODO]
- public Type ContainerParameterType {
- get { throw new NotImplementedException (); }
- set { throw new NotImplementedException (); }
- }
-
- [MonoTODO]
- public string DataSetClassName {
- get { throw new NotImplementedException (); }
- set { throw new NotImplementedException (); }
- }
-
- [MonoTODO]
- public bool IsGetMethod {
- get { throw new NotImplementedException (); }
- set { throw new NotImplementedException (); }
- }
-
- [MonoTODO]
- public bool PagingMethod {
- get { throw new NotImplementedException (); }
- set { throw new NotImplementedException (); }
- }
-
- [MonoTODO]
- public ParameterGenerationOption ParameterOption {
- get { throw new NotImplementedException (); }
- set { throw new NotImplementedException (); }
- }
-
- [MonoTODO]
- public string TableClassName {
- get { throw new NotImplementedException (); }
- set { throw new NotImplementedException (); }
- }
-
- [MonoTODO]
- public CodeMemberMethod GenerateMethod ()
- {
- throw new NotImplementedException ();
- }
-
- [MonoTODO]
- public string GenerateMethodSignature ()
- {
- throw new NotImplementedException ();
- }
-
- [MonoTODO]
- public CodeTypeDeclaration GenerateUpdatingMethods ()
- {
- throw new NotImplementedException ();
- }
-
- [MonoTODO]
- public void SetDesignTableContent (string designTableContent)
- {
- throw new NotImplementedException ();
- }
-
- [MonoTODO]
- public void SetMethodSourceContent (string methodSourceContent)
- {
- throw new NotImplementedException ();
- }
- }
-}
+ public class MethodSignatureGenerator
+ {
+ private static readonly char endOfStatement = ';';
+ private CodeDomProvider codeProvider;
+ private DbSource methodSource;
+ private Type containerParameterType = typeof (DataSet);
+ private bool pagingMethod;
+ private bool getMethod;
+ private ParameterGenerationOption parameterOption;
+ private string tableClassName;
+ private string datasetClassName;
+ private DesignTable designTable;
+
+ public CodeDomProvider CodeProvider {
+ get { return this.codeProvider; }
+ set { this.codeProvider = value; }
+ }
+
+ public Type ContainerParameterType {
+ get { return this.containerParameterType; }
+ set {
+ if (value != typeof (DataSet) && value != typeof \
(DataTable)) + throw new InternalException \
("Unsupported container parameter type."); +
+ this.containerParameterType = value;
+ }
+ }
+
+ public string DataSetClassName {
+ get { return this.datasetClassName; }
+ set { this.datasetClassName = value; }
+ }
+
+ public bool IsGetMethod {
+ get { return this.getMethod; }
+ set { this.getMethod = value; }
+ }
+
+ public bool PagingMethod {
+ get { return this.pagingMethod; }
+ set { this.pagingMethod = value; }
+ }
+
+ public ParameterGenerationOption ParameterOption {
+ get { return this.parameterOption; }
+ set { this.parameterOption = value; }
+ }
+
+ public string TableClassName {
+ get { return this.tableClassName; }
+ set { this.tableClassName = value; }
+ }
+
+ public CodeMemberMethod GenerateMethod () {
+
+ if (this.codeProvider == null)
+ throw new ArgumentException ("codeProvider");
+
+ if (this.methodSource == null)
+ throw new ArgumentException ("MethodSource");
+
+ QueryGeneratorBase queryGeneratorBase = null;
+
+ if (this.methodSource.QueryType == QueryType.Rowset && \
this.methodSource.CommandOperation == CommandOperation.Select) { + \
queryGeneratorBase = new QueryGenerator (null); + \
queryGeneratorBase.ContainerParameterTypeName = this.GetParameterTypeName (); + \
queryGeneratorBase.ContainerParameterName = this.GetParameterName (); + \
queryGeneratorBase.ContainerParameterType = this.containerParameterType; + \
} else { + queryGeneratorBase = new FunctionGenerator \
(null); + }
+
+ queryGeneratorBase.DeclarationOnly = true;
+ queryGeneratorBase.CodeProvider = this.codeProvider;
+ queryGeneratorBase.MethodSource = this.methodSource;
+ queryGeneratorBase.MethodName = this.GetMethodName ();
+ queryGeneratorBase.ParameterOption = this.parameterOption;
+ queryGeneratorBase.GeneratePagingMethod = this.pagingMethod;
+ queryGeneratorBase.GenerateGetMethod = this.getMethod;
+
+ return queryGeneratorBase.Generate ();
+ }
+
+ public string GenerateMethodSignature () {
+
+ if (this.codeProvider == null)
+ throw new ArgumentException ("codeProvider");
+
+ if (this.methodSource == null)
+ throw new ArgumentException ("MethodSource");
+
+ string value = null;
+ CodeTypeDeclaration codeType = this.GenerateMethodWrapper \
(out value); + StringWriter stringWriter = new \
StringWriter(CultureInfo.CurrentCulture); + \
this.codeProvider.GenerateCodeFromType (codeType, stringWriter, null); + \
string text = stringWriter.GetStringBuilder().ToString(); + \
string[] array = text.Split(Environment.NewLine.ToCharArray()); + \
string[] array2 = array; +
+ for (int i = 0; i < array2.Length; i++) {
+ string text2 = array2[i];
+
+ if (text2.Contains(value))
+ return text2.Trim().TrimEnd( new char[] { \
MethodSignatureGenerator.endOfStatement }); +
+ return null;
+ }
+ }
+
+ public CodeTypeDeclaration GenerateUpdatingMethods () {
+
+ if (this.designTable == null)
+ throw new InternalException ("DesignTable should not \
be null."); +
+ if (StringUtil.Empty (this.datasetClassName))
+ throw new InternalException ("DatasetClassName \
should not be empty."); +
+ CodeTypeDeclaration codeTypeDeclaration = new \
CodeTypeDeclaration ("wrapper"); + \
codeTypeDeclaration.IsInterface = true; + new QueryHandler \
(this.codeProvider, this.designTable) { + \
DeclarationsOnly = true + \
}.AddUpdateQueriesToDataComponent (codeTypeDeclaration, this.datasetClassName, \
this.codeProvider); +
+ return codeTypeDeclaration;
+ }
+
+ public void SetDesignTableContent (string designTableContent) {
+
+ DesignDataSource designDataSource = new DesignDataSource();
+ StringReader textReader = new StringReader \
(designTableContent); + designDataSource.ReadXmlSchema \
(textReader, null); +
+ if (designDataSource.DesignTables == null || \
designDataSource.DesignTables.Count != 1) + throw new \
InternalException ("Unexpected number of sources in deserialized DataSource."); + \
+ IEnumerator enumerator = \
designDataSource.DesignTables.GetEnumerator (); + \
enumerator.MoveNext (); + this.designTable = (DesignTable) \
enumerator.Current; + }
+
+ public void SetMethodSourceContent (string methodSourceContent) {
-#endif
+ DesignDataSource designDataSource = new DesignDataSource ();
+ StringReader textReader = new StringReader \
(methodSourceContent); + designDataSource.ReadXmlSchema \
(textReader, null); +
+ if (designDataSource.Sources == null || \
designDataSource.Sources.Count != 1) + throw new \
InternalException ("Unexpected number of sources in deserialized DataSource."); +
+ IEnumerator enumerator = \
designDataSource.Sources.GetEnumerator (); + \
enumerator.MoveNext (); + this.methodSource = (DbSource) \
enumerator.Current; + }
+
+ private CodeTypeDeclaration GenerateMethodWrapper (out string \
methodName) { +
+ CodeTypeDeclaration codeTypeDeclaration = new \
CodeTypeDeclaration ("Wrapper"); + \
codeTypeDeclaration.IsInterface = true; + CodeMemberMethod \
codeMemberMethod = this.GenerateMethod(); + \
codeTypeDeclaration.Members.Add (codeMemberMethod); + \
methodName = codeMemberMethod.Name; +
+ return codeTypeDeclaration;
+ }
+
+ private string GetParameterName () {
+
+ if (this.containerParameterType == typeof (DataTable))
+ return "dataTable";
+
+ return "dataSet";
+ }
+
+ private string GetParameterTypeName () {
+
+ if (StringUtil.Empty (this.datasetClassName))
+ throw new InternalException ("DatasetClassName \
should not be empty."); +
+ if (!(this.containerParameterType == typeof (DataTable)))
+ return this.datasetClassName;
+
+ if (StringUtil.Empty (this.tableClassName))
+ throw new InternalException ("TableClassName should \
not be empty."); +
+ return CodeGenHelper.GetTypeName (this.codeProvider, \
this.datasetClassName, this.tableClassName); + }
+
+ private string GetMethodName () {
+
+ if (this.methodSource.QueryType == QueryType.Rowset) {
+ if (this.getMethod) {
+ if (this.pagingMethod) {
+ if \
(this.methodSource.GeneratorGetMethodNameForPaging != null) + \
return this.methodSource.GeneratorGetMethodNameForPaging; +
+ return \
this.methodSource.GetMethodName + DataComponentNameHandler.PagingMethodSuffix; + \
} else { + if \
(this.methodSource.GeneratorGetMethodName != null) + \
return this.methodSource.GeneratorGetMethodName; +
+ return \
this.methodSource.GetMethodName; + }
+ } else {
+ if (this.pagingMethod) {
+ if \
(this.methodSource.GeneratorSourceNameForPaging != null) + \
return this.methodSource.GeneratorSourceNameForPaging; +
+ return this.methodSource.Name + \
DataComponentNameHandler.PagingMethodSuffix; + \
} else { + if \
(this.methodSource.GeneratorSourceName != null) + \
return this.methodSource.GeneratorSourceName; +
+ return this.methodSource.Name;
+ }
+ }
+ } else {
+ if (this.methodSource.GeneratorSourceName != null)
+ return \
this.methodSource.GeneratorSourceName; +
+ return this.methodSource.Name;
+ }
+ }
+ }
+}
_______________________________________________
Mono-patches maillist - Mono-patches@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-patches
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic