Month: February 2013

Deserialize this / Deserialize inside of the instance

Type type = this.GetType(); PropertyInfo[] properties = type.GetProperties(); reader.Read(); while (reader.Read()) { PropertyInfo property = properties.GetPropertyByXmlElement(reader.Name); if (property != null) { property.SetValue(this, reader.ReadElementContentAs(property.PropertyType, null)); } } this is the extension method `GetPropertyByXmlElement(string)` public static PropertyInfo GetPropertyByXmlElement(this PropertyInfo[] properties, string name) { XmlElementAttribute attr = new XmlElementAttribute(name); PropertyInfo property = ( from p in properties where p.GetCustomAttributes().Any(a => a.Equals(attr)) select p)… Read more →

MVC

simple ajax controller (for countries etc) ajax (these are research notes) consuming WebApi with MVC consuming WebApi with MVC Dynamic content in MVC/Razor the following contains xml entries to get past razor runtime compilation errors of namespace not found: @Html.LabelFor(model => model.path.Value, “Path”) @Html.DropDownList(“Path”, new List { new SelectListItem { Text = TypeSafeEnum.a.Value, Value = TypeSafeEnum.a.Value }, new SelectListItem {… Read more →