Refactor
:my
=>
'code'
Codes
Refactorings
Popular
Best
Submit
Spam
Account
Logout
Login
JavaScript doesn't seem to be activated, expect things to be ugly and sloppy!
Learn How to Create Your Own Programming Language
createyourproglang.com
Recent
Simple Particle Engine for a shooter game
Snake / Nibbles clone in C and Ncurses
Please improve
Parsing of XML data has high CPU usage
Convert simple Javascript to jQuery plugin
Active Record getting unique records
List the files in a directory without the directory name or the extension
clean the code
ohs system, recruitment software, hr software, oh&s software, human resources software, ohs software
Array parsing in a block
Popular
Parsing of XML data has high CPU usage
Please improve
Snake / Nibbles clone in C and Ncurses
List the files in a directory without the directory name or the extension
Convert simple Javascript to jQuery plugin
Simple Particle Engine for a shooter game
Active Record getting unique records
Breadth first cartesian product iterator
php refactoring
first BST
Pastable version of
Generic Lists of Different Types
<pre class='prettyprint' language='cs'>public IList<IStatus> RepsonseHandler(string responseText) { IList<IStatus> Output = null; bool multipleStatus = responseText.Contains("statuses type=\"array\""); XElement xmlElement = XElement.Load(new XmlTextReader(new StringReader(responseText))); if(!multipleStatus) { IStatus status = Status.ParseStatusXML(responseText); status.User = User.ParseUserXml(xmlElement.Element("user").ToString()); if(status != null) { Output = new List<IStatus>(); Output.Add(status); } } else { Output = new List<IStatus>(); //Query for count of statuses to make sure we have some var query = from c in xmlElement.Descendants("status") select c; if (query.Count() > 0) { Output = new List<IStatus>(); foreach (var status in query) { IStatus currentStatus = Status.ParseStatusXML(status.ToString()); currentStatus.User = User.ParseUserXml(status.Element("user").ToString()); Output.Add(currentStatus); } } } return Output; } //TODO: Figure out a better way to handle this public IList<IUser> RepsonseHandler(string responseText, string DoesNothing) { IList<IUser> Output = null; bool multipleUsers = responseText.Contains("users type=\"array\""); XElement xmlElement = XElement.Load(new XmlTextReader(new StringReader(responseText))); if (!multipleUsers) { IUser user = User.ParseUserXml(responseText); user.Status = Status.ParseStatusXML(xmlElement.Element("status").ToString()); if (user != null) { Output = new List<IUser>(); Output.Add(user); } } else { Output = new List<IUser>(); //Query for count of statuses to make sure we have some var query = from c in xmlElement.Descendants("user") select c; if (query.Count() > 0) { Output = new List<IUser>(); foreach (var user in query) { IUser currentUser = User.ParseUserXml(user.ToString()); currentUser.Status = Status.ParseStatusXML(user.Element("status").ToString()); Output.Add(currentUser); } } } return Output; }</pre> <a href="http://www.refactormycode.com/codes/862-generic-lists-of-different-types" style="color:#fff" title="As seen on RefactorMyCode.com"><img alt="Small_logo" src="http://www.refactormycode.com/images/small_logo.gif" style="border:0" /></a>