Click here to Skip to main content
15,898,996 members
Home / Discussions / C#
   

C#

 
NewsRe: getting GPS coordinates on pocketpc Pin
BlackDice15-Mar-06 5:22
BlackDice15-Mar-06 5:22 
GeneralRe: getting GPS coordinates on pocketpc Pin
Dave Kreskowiak15-Mar-06 11:26
mveDave Kreskowiak15-Mar-06 11:26 
QuestionMicrosoft.Jet.OLEDB Extended Properties Pin
mcljava13-Mar-06 8:10
mcljava13-Mar-06 8:10 
AnswerRe: Microsoft.Jet.OLEDB Extended Properties Pin
mcljava15-Mar-06 7:54
mcljava15-Mar-06 7:54 
QuestionHow to find Serializable attribute with reflection? Pin
vineas13-Mar-06 7:18
vineas13-Mar-06 7:18 
AnswerRe: How to find Serializable attribute with reflection? Pin
leppie13-Mar-06 7:58
leppie13-Mar-06 7:58 
GeneralRe: How to find Serializable attribute with reflection? Pin
vineas13-Mar-06 8:23
vineas13-Mar-06 8:23 
GeneralRe: How to find Serializable attribute with reflection? Pin
superpzgpzg8-Dec-09 21:11
superpzgpzg8-Dec-09 21:11 
Smile | :) You need to find all the serializable types within an assembly.

Solution
Instead of testing the implemented interfaces and attributes on every type, you can query the Type.IsSerialized property to determine whether it is marked as serializable, as the following method does:

public static Type[] GetSerializableTypes(Assembly asm)
{
List<Type> serializableTypes = new List<Type>();

// Look at all types in the assembly.
foreach(Type type in asm.GetTypes())
{
if (type.IsSerializable)
{
// Add the name of the serializable type.
serializableTypes.Add(type);
}
}

return (serializableTypes.ToArray());
}



The GetSerializableTypes method accepts an Assembly through its asm parameter. This assembly is searched for any serializable types, and their full names (including namespaces) are returned in a Type[].

In order to use this method to display the serializable types in an assembly, run the following code:

public static void FindSerializable()
{
Assembly asm = Assembly.GetExecutingAssembly();
Type[] serializable = GetSerializableTypes(asm);
// Write out the serializable types in the assembly.
if(serializable.Length > 0)
{
Console.WriteLine("{0} has serializable types:",asm.Location);
foreach (Type t in serializable)
{
Console.WriteLine("\t{0}", t.FullName);
}
}
}
QuestionHow to import URLs from Google page to listview Pin
Rajendra Rana13-Mar-06 6:35
Rajendra Rana13-Mar-06 6:35 
AnswerRe: How to import URLs from Google page to listview Pin
Somanova42013-Mar-06 9:59
Somanova42013-Mar-06 9:59 
Questionuser control Pin
ap_sa13-Mar-06 6:05
ap_sa13-Mar-06 6:05 
QuestionHow can I make a DataGrid scroll up&down (or left&right) programmactically C#??? Pin
coloso13-Mar-06 4:16
coloso13-Mar-06 4:16 
Questionposition of cursor in Text Box? Pin
superdragon13-Mar-06 4:08
superdragon13-Mar-06 4:08 
AnswerRe: position of cursor in Text Box? Pin
Roy Heil13-Mar-06 4:56
professionalRoy Heil13-Mar-06 4:56 
GeneralRe: position of cursor in Text Box? Pin
superdragon13-Mar-06 11:55
superdragon13-Mar-06 11:55 
QuestionGridView link with two data???? Pin
papa198013-Mar-06 3:29
papa198013-Mar-06 3:29 
QuestionCreate a very big PictureBox Pin
Sasuko13-Mar-06 2:31
Sasuko13-Mar-06 2:31 
QuestionFolderBrowserDialog Problem in C# Pin
AyBee13-Mar-06 2:24
AyBee13-Mar-06 2:24 
AnswerRe: FolderBrowserDialog Problem in C# Pin
J4amieC13-Mar-06 4:05
J4amieC13-Mar-06 4:05 
AnswerRe: FolderBrowserDialog Problem in C# Pin
vineas13-Mar-06 4:18
vineas13-Mar-06 4:18 
AnswerRe: FolderBrowserDialog Problem in C# Pin
Ed.Poore13-Mar-06 6:29
Ed.Poore13-Mar-06 6:29 
QuestionCookie and ticket expiration Pin
Brendan Vogt13-Mar-06 1:47
Brendan Vogt13-Mar-06 1:47 
Questionaccessing xml file Pin
rah_sin13-Mar-06 1:21
professionalrah_sin13-Mar-06 1:21 
AnswerRe: accessing xml file Pin
darkelv13-Mar-06 12:59
darkelv13-Mar-06 12:59 
Questionlock columns's size Pin
sebastianos13-Mar-06 1:11
sebastianos13-Mar-06 1:11 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.