c++.announce - Source Code Formatting while Converting C# Code to Java using
- "zarfishan" <social codeporting.com> Jun 21 2012
While converting C# code to java, CodePorting C#2Java Engine also handles the conversion of code formatting which is an important feature of CodePorting Engine. C# and Java both have completely different style of code commenting, But in contempt of this difference C#2Java Engine intelligently converts the code comments in C# and produce the comments which are used in Java. Developers can take advantage of this great feature by using CodePorting’s web Application as well as Visual Studio Add-in. Developers who use Microsoft Visual Studio can use the Add-in to convert their project directly from their IDE. Following example will show you how CodePorting Engine handles code formatting while converting C# code to Java. C# Code: using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace CsPorter.Example.Convert.XmlComments { /// <summary> /// Appender that logs to a database. /// </summary> /// /// /// appends logging events to a table within a /// database. The appender can be configured to specify the connection /// string by setting the property. /// The connection type (provider) can be specified by setting the /// property. For more information on database connection strings for /// your specific database see <a href="http://www.connectionstrings.com/">http://www.connectionstrings.com/</a>. /// /// /// Records are written into the database either using a prepared /// statement or a stored procedure. The property /// is set to (System.Data.CommandType.Text) to specify a prepared statement /// or to (System.Data.CommandType.StoredProcedure) to specify a stored /// procedure. /// /// /// The prepared statement text or the name of the stored procedure /// must be set in the property. /// /// /// The prepared statement or stored procedure can take a number /// of parameters. Parameters are added using the /// method. This adds a single to the /// ordered list of parameters. The /// type may be subclassed if required to provide database specific /// functionality. The specifies /// the parameter name, database type, size, and how the value should /// be generated using a . /// /// /// /// An example of a SQL Server table that could be logged to: /// <code lang="SQL"> /// CREATE TABLE [dbo].[Log] ( /// [ID] [int] IDENTITY (1, 1) NOT NULL , /// [Date] [datetime] NOT NULL , /// [Thread] [varchar] (255) NOT NULL , /// [Level] [varchar] (20) NOT NULL , /// [Logger] [varchar] (255) NOT NULL , /// [Message] [varchar] (4000) NOT NULL /// ) ON [PRIMARY] /// </code> /// /// /// An example configuration to log to the above table: /// <code lang="XML"> /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// </code> /// /// Julian Biddle /// Nicko Cadell /// Gert Driesen /// Lance Nehring class ComplexTest { /// <summary> ///Gets or sets the database connection string that is used to connect to ///the database. ///</summary> /// ///The database connection string used to connect to the database. /// /// /// ///The connections string is specific to the connection type. ///See for more information. /// /// ///Connection string for MS Access via ODBC: ///<code>"DSN=MS Access Database;UID=admin;PWD=;SystemDB=C:\data\System.mdw;SafeTransactions = 0;FIL=MS Access;DriverID = 25;DBQ=C:\data\train33.mdb"</code> /// ///Another connection string for MS Access via ODBC: ///<code>"Driver={Microsoft Access Driver (*.mdb)};DBQ=C:\Work\cvs_root\log4net-1.2\access.mdb;UID=;PWD=;"</code> /// ///Connection string for MS Access via OLE DB: ///<code>"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Work\cvs_root\log4net-1.2\access.mdb;User Id=;Password=;"</code> /// private String Str { get; set; } } } Java Code: package CsPorter.Example.Convert.XmlComments; // ********* THIS FILE IS AUTO PORTED FORM C# USING CODEPORTING.COM ********* /** * <p> * Appender that logs to a database. * </p><p><hr><blockquote> * An example of a SQL Server table that could be logged to: * * CREATE TABLE [dbo].[Log] ( * [ID] [int] IDENTITY (1, 1) NOT NULL , * [Date] [datetime] NOT NULL , * [Thread] [varchar] (255) NOT NULL , * [Level] [varchar] (20) NOT NULL , * [Logger] [varchar] (255) NOT NULL , * [Message] [varchar] (4000) NOT NULL * ) ON [PRIMARY] * * </blockquote></hr></p><p><hr><blockquote> * An example configuration to log to the above table: * * { code <appender name="AdoNetAppender_SqlServer" type="log4net.Appender.AdoNetAppender"> * <connectionType value="System.Data.SqlClient.SqlConnection, System.Data, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"></connectionType> * <connectionString value="data source=SQLSVR;initial catalog=test_log4net;integrated security=false;persist security info=True;User ID=sa;Password=sa"></connectionString> * <commandText value="INSERT INTO Log ([Date],[Thread],[Level],[Logger],[Message]) VALUES ( log_date, thread, log_level, logger, message)"></commandText> * <parameter> * <parameterName value=" log_date"></parameterName> * <dbType value="DateTime"></dbType> * <layout type="log4net.Layout.PatternLayout" value="%date{yyyy'-'MM'-'dd HH':'mm':'ss'.'fff}"></layout> * </parameter> * <parameter> * <parameterName value=" thread"></parameterName> * <dbType value="String"></dbType> * <size value="255"></size> * <layout type="log4net.Layout.PatternLayout" value="%thread"></layout> * </parameter> * <parameter> * <parameterName value=" log_level"></parameterName> * <dbType value="String"></dbType> * <size value="50"></size> * <layout type="log4net.Layout.PatternLayout" value="%level"></layout> * </parameter> * <parameter> * <parameterName value=" logger"></parameterName> * <dbType value="String"></dbType> * <size value="255"></size> * <layout type="log4net.Layout.PatternLayout" value="%logger"></layout> * </parameter> * <parameter> * <parameterName value=" message"></parameterName> * <dbType value="String"></dbType> * <size value="4000"></size> * <layout type="log4net.Layout.PatternLayout" value="%message"></layout> * </parameter> * </appender>} * * </blockquote></hr></p><p><hr> * <p> * { code T:log4net.Appender.AdoNetAppender} appends logging events to a table within a * database. The appender can be configured to specify the connection * string by setting the { code P:log4net.Appender.AdoNetAppender.ConnectionString} property. * The connection type (provider) can be specified by setting the { code P:log4net.Appender.AdoNetAppender.ConnectionType} * property. For more information on database connection strings for * your specific database see { code <a href="http://www.connectionstrings.com/">http://www.connectionstrings.com/</a>}. * </p> * <p> * Records are written into the database either using a prepared * statement or a stored procedure. The { code P:log4net.Appender.AdoNetAppender.CommandType} property * is set to { code F:System.Data.CommandType.Text} ({ code System.Data.CommandType.Text}) to specify a prepared statement * or to { code F:System.Data.CommandType.StoredProcedure} ({ code System.Data.CommandType.StoredProcedure}) to specify a stored * procedure. * </p> * <p> * The prepared statement text or the name of the stored procedure * must be set in the { code P:log4net.Appender.AdoNetAppender.CommandText} property. * </p> * <p> * The prepared statement or stored procedure can take a number * of parameters. Parameters are added using the { code M:log4net.Appender.AdoNetAppender.AddParameter(log4net.Appender.AdoNetAppenderParameter)} * method. This adds a single { code T:log4net.Appender.AdoNetAppenderParameter} to the * ordered list of parameters. The { code T:log4net.Appender.AdoNetAppenderParameter} * type may be subclassed if required to provide database specific * functionality. The { code T:log4net.Appender.AdoNetAppenderParameter} specifies * the parameter name, database type, size, and how the value should * be generated using a { code T:log4net.Layout.ILayout}. * </p> * </hr></p>{ code <author>Julian Biddle</author>}{ code <author>Nicko Cadell</author>}{ code <author>Gert Driesen</author>}{ code <author>Lance Nehring</author>} */ class ComplexTest { /** * <p> * Gets or sets the database connection string that is used to connect to * the database. * </p><p><hr><blockquote>Connection string for MS Access via ODBC: * "DSN=MS Access Database;UID=admin;PWD=;SystemDB=C:\data\System.mdw;SafeTransactions = 0;FIL=MS Access;DriverID = 25;DBQ=C:\data\train33.mdb" * </blockquote></hr></p><p><hr><blockquote>Another connection string for MS Access via ODBC: * "Driver={Microsoft Access Driver (*.mdb)};DBQ=C:\Work\cvs_root\log4net-1.2\access.mdb;UID=;PWD=;" * </blockquote></hr></p><p><hr><blockquote>Connection string for MS Access via OLE DB: * "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Work\cvs_root\log4net-1.2\access.mdb;User Id=;Password=;" * </blockquote></hr></p>Value: * The database connection string used to connect to the database. * <p><hr> * <p> * The connections string is specific to the connection type. * See { code P:log4net.Appender.AdoNetAppender.ConnectionType} for more information. * </p> * </hr></p> */ String _Str;private String getStr(){ return _Str; }; private void setStr(String value){_Str = value; }; } The above examples shows that commenting styles are different for both programming languages and CodePorting C#2Java engine intelligently converts these comments from C# to java accurately which helps to generate documents for the converted java code.
Jun 21 2012