Featured post

c# - Usage of Server Side Controls in MVC Frame work -

i using asp.net 4.0 , mvc 2.0 web application. project requiremrnt have use server side control in application not possibl in noraml case. ideally want use adrotator control , datalist control. i saw few samples , references in codepleax mvc controllib howwver found less useful. can tell how utilize theese controls in asp.net application along mvc. note: please provide functionalities related adrotator , datalist controls not equivalent functionalities thanks in advace. mvc pages not use normal .net solution makes use of normal .net components impossible. a normal .net page use event driven solution call different methods service side mvc use actions , view completly different way handle things. also, mvc not use viewstate normal .net controlls require. found article discussing mixing of normal .net , mvc.

c# - IEnumerable parser class design -


i'm creating class can read dicom file. binary file filled lot of objects. want create solid class can this. i've designed following.

using system; using system.collections.generic; using system.linq; using system.text; using system.io;  namespace medicom {     public class ddocument : ienumerable<ddataelement>     {         /// <summary>         /// creates new ddocument file.         /// </summary>         /// <param name="path">the path of file load </param>         /// <returns>an ddocument contains dicom information file</returns>         public static ddocument load(string path)         {             return ddocument.load(new filestream(path, filemode.open));          }          /// <summary>         /// creates new xdocument instance using specified stream.         /// </summary>         /// <param name="stream">the stream contains dicom information.</param>         /// <returns>an ddocument contains dicom information stream.</returns>         public static ddocument load(stream stream)         {             //logic here read whole stream , list<ddataelement> data data         }          /// <summary>         /// gets or sets list metainformation containing ddataelements         /// </summary>         public list<ddataelement> data         {             get;             set;         }          /// <summary>         /// returns enumerator can used iterate through ddocument         /// </summary>         /// <returns>an ienumerator can used iterate through ddocument</returns>         public ienumerator<ddataelement> getenumerator()         {             foreach (ddataelement dataelement in data)             {                 yield return dataelement;             }         }     } } 

i wanted know think of it. there changes make in class?

two things:

first, should close filestream when you're done it:

public static ddocument load(string path) {     using(filestream fs = new filestream(path, filemode.open)) {         return ddocument.load(fs);      } } 

second, list has ienumerable! should use it!

public ienumerator<ddataelement> getenumerator() {     return (ienumerator<ddataelement>)data.getenumerator(); } 

Comments

Popular posts from this blog

c# - Usage of Server Side Controls in MVC Frame work -

cocoa - Nesting arrays into NSDictionary object (Objective-C) -

ios - Very simple iPhone App crashes on UILabel settext -