Mad Library also contains unclassified functions which are also usable in more sections of programming. Some of them are in examples which are written here.

Program properties

.NET framework provides more automatically and unautomatically generated properties which are usable for programmer. Mad Library also offers you attribute tagging. ProgramPropertyAttributte serves for setting custom properties of program when you don’t want or you don’t have time for own attributes. Example is missing because program properties are attributes. ProgramPropertyAttributte is documented, so you can read comments written for it in source code.

Collection

Collections such as List or Dictionary are often used in code. Mad Library offers you Collection<> class for storing and managing reference types with public implicit constructor. Example of usage:

 

Collection<MyType> col = new Collection<MyType>();
col.Add(new MyType("BCD"));
col.Add(new MyType("ABC"));
col.Add(new MyType("CDE"));
col.Add(new MyType("1T"));
IOrderedEnumerable<MyType> ocol = col.OrderBy(t => t.Name);
col.InsertAt(0, new MyType("ZABC"));
col.InsertAt(col.Count - 1, new MyType("XYZ"));
foreach (MyType mt in col)
    Console.WriteLine(mt.Name);
Console.WriteLine("===============");
foreach (MyType t in ocol)
    Console.WriteLine(t.Name);

Console.Read();

 

IBuildable and IParsable

Mad Library is systematical. Most of data and information holding types are deriving from this interface, so when you’re working with some HTML or CSS elements or properties, or when you’re working with requests and responses, you can use functions of these interfaces for parsing string into it or for building string from it. This small example shows you how can you these interfaces for managing communicating data types.

 

HttpResponse resp = new HttpResponse();
IParsable ip = resp as IParsable;
ip.Parse("HTTP/1.1 200 OK\r\nOPTIONS\r\n\r\nDATADATA\r\n\r\n");

Console.WriteLine((resp as IBuildable).Build());
Console.Read();

Last edited Jun 16, 2012 at 6:42 PM by FrewCen, version 3

Comments

No comments yet.