Two namespaces and similar class name inside in C#

by Deepak Dhakal 7. February 2012 13:04
I have namaspace for two version of the same class, V1 and v2
namespace Hello.ThisIsAnExample.Noway.StillAnExample.V1
{
Class A
{
public void Nothing()
{
}
}
}

namespace Hello.ThisIsAnExample.Noway.StillAnExample.V2
{
Class A
{
public void Nothing()
{
}
}
}


Then in the Main class, use like this

using V1=Hello.ThisIsAnExample.Noway.StillAnExample.V1
using V2=Hello.ThisIsAnExample.Noway.StillAnExample.V2

Pubic Main()
{
 V1.A.Nothing(); // Calls V1
 V2.A.Nothing(); // Calls V2
}



Sweet !!! is not it ???

Tags:

.Net

Prevent iphone going to sleep mode

by Deepak Dhakal 30. January 2012 07:17

use one line of code

[UIApplication sharedApplication].idleTimerDisabled=YES'

Note: This will leave the screen's background light on, (after the user pressed the sleep button,) which will drain the battery.

Tags:

xml serialization in .Net with datetime

by Deepak Dhakal 8. December 2011 11:22

If you have

<xs:element name="start" type="xs:date"/>

make sure you parse as

<start>2002-09-24</start>

 

or if you have

<xs:element name="startdate" type="xs:dateTime"/>

 

you parse as

<startdate>2002-05-30T09:30:10.5</startdate>

 

if you don't then you will get error like

at System.DateTimeParse.ParseExactMultiple(String s, String[ formats, DateTimeFormatInfo dtfi, DateTimeStyles style)
at System.DateTime.ParseExact(String s, String[ formats, IFormatProvider provider, DateTimeStyles style)
at System.Data.SQLite.SQLiteConvert.ToDateTime(String dateText)
at System.Data.SQLite.SQLiteConvert.ToDateTime(IntPtr ptr, Int32 len)
at System.Data.SQLite.SQLite3.GetDateTime(SQLiteStatement stmt, Int32 index)
at System.Data.SQLite.SQLite3.GetValue(SQLiteStatement stmt, Int32 index, SQLiteType typ)
at System.Data.SQLite.SQLiteDataReader.GetValue(Int32 i)
at System.Data.SQLite.SQLiteDataReader.GetValues(Object[ values)
at System.Data.ProviderBase.DataReaderContainer.CommonLanguageSubsetDataReader.GetValues(Object[ values)
at System.Data.ProviderBase.SchemaMapping.LoadDataRow()br /> at System.Data.Common.DataAdapter.FillLoadDataRow(SchemaMapping mapping)
at System.Data.Common.DataAdapter.FillFromReader(DataSet dataset, DataTable datatable, String srcTable, DataReaderContainer dataReader, Int32 startRecord, Int32 maxRecords, DataColumn parentChapterColumn, Object parentChapterValue)
at System.Data.Common.DataAdapter.Fill(DataTable[ dataTables, IDataReader dataReader, Int32 startRecord, Int32 maxRecords)
at System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[ datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataTable[ dataTables, Int32 startRecord, Int32 maxRecords, IDbCommand command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataTable dataTable)
at WindowsFormsApplication2.AssetManagerDBDataSetTableAdapters.AssetsTableAdapter.Fill(AssetsDataTable dataTable) in C:\Users\Administrator\Desktop\SQLite Version\WiscoAssetImporter\AssetManagerDBDataSet1.Designer.cs:line 4408
at WindowsFormsApplication2.FormMerge.FormAnalyse_Load(Object sender, EventArgs e) in C:\Users\Administrator\Desktop\SQLite Version\WiscoAssetImporter\FormMerge.cs:line 71

Tags:

Add Archos on your Device list in Eclipse for Android Development

by Deepak Dhakal 1. October 2011 19:22

Archos support proposes a solution to the bug on ADB connection mode with Mac OSX 10.6.2 with firmwares updates since 1.4.07 to the latest 1.4.16 :

You actually need to modify or create the adb_usb.ini file

In terminal, you need to type :
echo "0x0e79" >~/.android/adb_usb.ini
Then
./adb kill-server
and
./adb start-server


I just modify the first command in order to preserve the original contents of the ~/.android/adb_usb.ini file by issuing the following command
echo "0x0e79" >> ~/.android/adb_usb.ini


Here is the result :

$ adb devices
List of devices attached

$ adb devices
List of devices attached

$ more ~/.android/adb_usb.ini
# ANDROID 3RD PARTY USB VENDOR ID LIST -- DO NOT EDIT.
# USE 'android update adb' TO GENERATE.
# 1 USB VENDOR ID PER LINE.
$ echo "0x0e79" >> ~/.android/adb_usb.ini
$ more ~/.android/adb_usb.ini
# ANDROID 3RD PARTY USB VENDOR ID LIST -- DO NOT EDIT.
# USE 'android update adb' TO GENERATE.
# 1 USB VENDOR ID PER LINE.
0x0e79
$ adb kill-server
$ adb start-server
$ adb devices
List of devices attached
A5S-xxxx0004-xxxx0000-0403xxxx-1500xxxx device

Tags:

Is there any tool that converts Objective C code to java for Android

by Deepak Dhakal 9. February 2011 13:42

I have a working iPhone app and want to convert to Android app with minimal effort. Can anyone suggest ?

ANS:

I don't think so. You're best bet would have been to develop the application from scratch using a platform like Appcelerator or Phone Gap.

The commenter makes an excellent point: the platforms are fundamentally different. A straight conversion of code won't work. You also have to convert framework/api calls and restructure all of your UI. Not only is the framework different, but the assumptions made by the platform are totally different as well.

Possibly the best way to reuse the most code (this isn't necessarily the easiest, keep in mind) would be to convert as much objective c code into C or C++ and make use of the Android NDK. You won't be able to reuse any of the UI code, but you might be able to reuse a significant amount of your application logic depending on what your application does.

Tags:

.Net | iPhone

C++ Code, Is your code Messy ?

by Deepak Dhakal 14. December 2010 08:32

I’m pretty sure that every programmer would agree that good code is difficult to write. I think though that the C++ language makes this abundantly clear.

C++ is a compiled language frequently used for GUI applications and for games. It has a high barrier to entry due to the complexity of the language. However, this complexity is also what proves that good code is difficult to write. For example, the use of the ‘const’ keyword can be used to indicate that a member function does not change the class. It can mean that a parameter cannot be modified within a function. It can mean that a return value cannot be modified. And the list goes on. Remembering all these details and making sure they are applied correctly is very difficult.

Added to this, there are ways to take shortcuts that can have very detrimental effects down the road. For example if you take a shortcut with the use of ‘const’ you will most likely get a very confusing compiler message that could be very difficult to figure out.

Here at Worthwhile we mostly use interpreted languages. This means that translation of the source code to machine code happens when the program is run. C++ is a compiled language which means that a programmer must use a tool to generate the machine code before the program can be run. Interpreted languages in general are more flexible than compiled languages and make it less difficult to get the details right. However, if the programmer is not thinking about all of the possible ways his code might be used he will undoubtedly get burned later.

For example, consider a function that retrieves data from a database. The function accepts parameters that are used to filter the results down to what the user wants to see. The simplest way to do this is to use string concatenation. So if I am looking for people with the name of ‘Fred’ the query would look like: “SELECT * FROM people WHERE name = ‘Fred’”. If Fred is stored in a variable, the line would look like this in PHP: “SELECT * FROM people WHERE name = ’”. $variable .’”. So what is wrong with that? What if the variable that contains “Fred” is changed to contain “Fred; DELETE * FROM people;”? Well now you could have just inadvertently allowed the user to delete all the data you were trying to keep in the table. This is an example of a SQL injection attack technique.

Good code requires lots of thought. C++ makes you consider additional aspects of how code could be used. Scripting languages do not require that you do that. Lazy or partially thought out coding practices can lead to major security flaws! Have you ever been bitten by poorly written code?

Tags:

Powered by BlogEngine.NET 1.5.0.7 - Old School Theme by n3o Web Designers