Listing 4-1. The Initial Content of the Home Controller

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc; namespace LanguageFeatures.Controllers
{
public class HomeController : Controller
{
public string Index()
{
return "Navigate to a URL to show an example";
} }
}

Listing 4-2. The Contents of the Result View File

@model String

@{
Layout = null;
} <!DOCTYPE html> <html>
<head>
<meta name="viewport" content="width=device-width" />
<title>Result</title>
</head>
<body>
<div>
@Model
</div>
</body>
</html>

Listing 4-3. Defining a Property

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web; namespace LanguageFeatures.Models
{
public class Product
{
private string name; public string Name
{
get { return name; }
set { name = value; }
}
}
}

Listing 4-4. Consuming a Property

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using LanguageFeatures.Models; namespace LanguageFeatures.Controllers
{
public class HomeController : Controller
{
public string Index()
{
return "Navigate to a URL to show an example";
} public ViewResult AutoProperty()
{
Product product = new Product();
product.Name = "Kayak"; string productName = product.Name; return View("Result", (object)String.Format("Product name: {0}", productName));
}
}
}

Listing 4-5. Verbose Property Definitions

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web; namespace LanguageFeatures.Models
{
public class Product
{
private int productId;
private string name;
private string description;
private decimal price;
private string category; public int ProductId
{
get { return productId; }
set { productId = value; }
} public string Name
{
get { return name; }
set { name = value; }
} public string Description
{
get { return description; }
set { description = value; }
} public decimal Price
{
get { return price; }
set { price = value; }
} public string Category
{
get { return category; }
set { category = value; }
}
}
}

Listing 4-6. Using Automatically Implemented Properties

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web; namespace LanguageFeatures.Models
{
public class Product
{
public int ProductId { get; set; }
public string Name { get; set; }
public string Description { get; set; }
public decimal Price { get; set; }
public string Category { get; set; }
}
}

Listing 4-7. Reverting from an Automatic to a Regular Property

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web; namespace LanguageFeatures.Models
{
public class Product
{
private string name; public int ProductId { get; set; } public string Name
{
get {
return ProductId + name;
}
set {
name = value;
}
}
public string Description { get; set; }
public decimal Price { get; set; }
public string Category { get; set; }
}
}

Listing 4-8. Constructing and Initializing an Object with Properties

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using LanguageFeatures.Models; namespace LanguageFeatures.Controllers
{
public class HomeController : Controller
{
public string Index()
{
return "Navigate to a URL to show an example";
} public ViewResult AutoProperty()
{
Product product = new Product();
product.Name = "Kayak"; string productName = product.Name; return View("Result", (object)String.Format("Product name: {0}", productName));
} public ViewResult CreateProduct()
{
Product product = new Product();
product.ProductId = ;
product.Name = "Kayak";
product.Description = "A boat for one person";
product.Price = 275M;
product.Category = "Watersports"; return View("Result", (object)String.Format("Category: {0}", product.Category));
}
}
}

Listing 4-9. Using the Object Initializer Feature

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using LanguageFeatures.Models; namespace LanguageFeatures.Controllers
{
public class HomeController : Controller
{
public string Index()
{
return "Navigate to a URL to show an example";
} public ViewResult AutoProperty()
{
Product product = new Product();
product.Name = "Kayak"; string productName = product.Name; return View("Result", (object)String.Format("Product name: {0}", productName));
} public ViewResult CreateProduct()
{
Product product = new Product {
ProductId = ,
Name = "Kayak",
Description = "A boat for one person",
Price = 275M,
Category = "Waterports"
}; return View("Result", (object)String.Format("Category: {0}", product.Category));
}
}
}

Listing 4-10. Initializing Collections and Arrays

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using LanguageFeatures.Models; namespace LanguageFeatures.Controllers
{
public class HomeController : Controller
{
public string Index()
{
return "Navigate to a URL to show an example";
} public ViewResult AutoProperty()
{
Product product = new Product();
product.Name = "Kayak"; string productName = product.Name; return View("Result", (object)String.Format("Product name: {0}", productName));
} public ViewResult CreateProduct()
{
Product product = new Product {
ProductId = ,
Name = "Kayak",
Description = "A boat for one person",
Price = 275M,
Category = "Waterports"
}; return View("Result", (object)String.Format("Category: {0}", product.Category));
} public ViewResult CreateCollection()
{
string[] stringArray = { "apple", "orange", "plum"};
List<int> intList = new List<int> { , , , };
Dictionary<string, int> dict = new Dictionary<string, int> {
{ "apple", },
{ "orange", },
{ "plum", }
}; return View("Result", (object)stringArray[]);
}
}
}

Listing 4-11. The ShoppingCart Class

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web; namespace LanguageFeatures.Models
{
public class ShoppingCart
{
public List<Product> Products { get; set; }
}
}

Listing 4-12. Defining an Extension Method

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web; namespace LanguageFeatures.Models
{
public static class MyExtensionMethods
{
public static decimal TotalPrices(this ShoppingCart cart)
{
decimal total = ; foreach (Product prod in cart.Products)
{
total += prod.Price;
} return total;
}
}
}

Listing 4-13. Applying an Extension Method

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using LanguageFeatures.Models; namespace LanguageFeatures.Controllers
{
public class HomeController : Controller
{
public string Index()
{
return "Navigate to a URL to show an example";
} // Other action methods omitted for brevity public ViewResult UseExtension()
{
// Create and populate ShoppingCart
ShoppingCart cart = new ShoppingCart
{
Products = new List<Product> {
new Product{Name = "Kayak", Price = 275M},
new Product{Name = "Lifejacket", Price = 48.95M},
new Product{Name = "Soccer ball", Price = 19.50M},
new Product{Name = "Corner flag", Price = 34.95M}
}
}; // Get the total value of the products in the cart
decimal cartTotal = cart.TotalPrices(); return View("Result", (object)String.Format("Total: {0:c}", cartTotal));
}
}
}

Listing 4-14. Implementing an Interface in the ShoppingCart Class

using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Web; namespace LanguageFeatures.Models
{
public class ShoppingCart : IEnumerable<Product>
{
public List<Product> Products { get; set; } public IEnumerator<Product> GetEnumerator()
{
return Products.GetEnumerator();
} IEnumerator IEnumerable.GetEnumerator()
{
return GetEnumerator();
}
}
}

Listing 4-15. An Extension Method That Works on an Interface

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web; namespace LanguageFeatures.Models
{
public static class MyExtensionMethods
{
public static decimal TotalPrices(this IEnumerable<Product> productEnum)
{
decimal total = ; foreach (Product prod in productEnum)
{
total += prod.Price;
} return total;
}
}
}

Listing 4-16. Applying an Extension Method to Different Implementations of the Same Interface

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using LanguageFeatures.Models; namespace LanguageFeatures.Controllers
{
public class HomeController : Controller
{
public string Index()
{
return "Navigate to a URL to show an example";
} // Other action methods omitted for brevity public ViewResult UseExtensionEnumerable()
{
IEnumerable<Product> products = new ShoppingCart
{
Products = new List<Product> {
new Product{Name = "Kayak", Price = 275M},
new Product{Name = "Lifejacket", Price = 48.95M},
new Product{Name = "Soccer ball", Price = 19.50M},
new Product{Name = "Corner flag", Price = 34.95M}
}
}; Product[] productArray = {
new Product{Name = "Kayak", Price = 275M},
new Product{Name = "Lifejacket", Price = 48.95M},
new Product{Name = "Soccer ball", Price = 19.50M},
new Product{Name = "Corner flag", Price = 34.95M}
}; decimal cartTotal = products.TotalPrices();
decimal arrayTotal = productArray.TotalPrices(); return View("Result",
(object)String.Format("Cart Total: {0}, Array Total: {1}",
cartTotal, arrayTotal));
}
}
}

Listing 4-17. A Filtering Extension Method

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web; namespace LanguageFeatures.Models
{
public static class MyExtensionMethods
{
public static decimal TotalPrices(this IEnumerable<Product> productEnum)
{
decimal total = ; foreach (Product prod in productEnum)
{
total += prod.Price;
} return total;
} public static IEnumerable<Product> FilterByCategory(
this IEnumerable<Product> productEnum, string category)
{
foreach (Product prod in productEnum)
{
if (prod.Category == category)
{
yield return prod;
}
}
}
}
}

Listing 4-18. Using the Filtering Extension Method

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using LanguageFeatures.Models; namespace LanguageFeatures.Controllers
{
public class HomeController : Controller
{
public string Index()
{
return "Navigate to a URL to show an example";
} // Other action methods omitted for brevity public ViewResult UseFilterExtensionMethod()
{
IEnumerable<Product> products = new ShoppingCart
{
Products = new List<Product> {
new Product{Name = "Kayak", Category = "Watersports", Price = 275M},
new Product{Name = "Lifejacket", Category = "Watersports", Price = 48.95M},
new Product{Name = "Soccer ball", Category = "Soccer", Price = 19.50M},
new Product{Name = "Corner flag", Category = "Soccer", Price = 34.95M}
}
}; decimal total = ; foreach (Product prod in products.FilterByCategory("Soccer"))
{
total += prod.Price;
} return View("Result", (object)String.Format("Total: {0}", total));
}
}
}

Listing 4-19. Using a Delegate in an Extension Method

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web; namespace LanguageFeatures.Models
{
public static class MyExtensionMethods
{
public static decimal TotalPrices(this IEnumerable<Product> productEnum)
{
decimal total = ; foreach (Product prod in productEnum)
{
total += prod.Price;
} return total;
} public static IEnumerable<Product> FilterByCategory(
this IEnumerable<Product> productEnum, string category)
{
foreach (Product prod in productEnum)
{
if (prod.Category == category)
{
yield return prod;
}
}
} public static IEnumerable<Product> Filter(
this IEnumerable<Product> productEnum, Func<Product, bool> selector)
{
foreach (Product prod in productEnum)
{
if (selector(prod))
{
yield return prod;
}
}
}
}
}

Listing 4-20. Using the Filtering Extension Method with a Func

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using LanguageFeatures.Models; namespace LanguageFeatures.Controllers
{
public class HomeController : Controller
{
public string Index()
{
return "Navigate to a URL to show an example";
} // Other action methods omitted for brevity public ViewResult UseFilterExtensionMethod()
{
IEnumerable<Product> products = new ShoppingCart
{
Products = new List<Product> {
new Product{Name = "Kayak", Category = "Watersports", Price = 275M},
new Product{Name = "Lifejacket", Category = "Watersports", Price = 48.95M},
new Product{Name = "Soccer ball", Category = "Soccer", Price = 19.50M},
new Product{Name = "Corner flag", Category = "Soccer", Price = 34.95M}
}
}; Func<Product, bool> categoryFilter = delegate(Product prod)
{
return prod.Category == "Soccer";
}; decimal total = ; foreach (Product prod in products.Filter(categoryFilter))
{
total += prod.Price;
} return View("Result", (object)String.Format("Total: {0}", total));
}
}
}

Listing 4-21. Using a Lambda Expression to Replace a Delegate Definition

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using LanguageFeatures.Models; namespace LanguageFeatures.Controllers
{
public class HomeController : Controller
{
public string Index()
{
return "Navigate to a URL to show an example";
} // Other action methods omitted for brevity public ViewResult UseFilterExtensionMethod()
{
IEnumerable<Product> products = new ShoppingCart
{
Products = new List<Product> {
new Product{Name = "Kayak", Category = "Watersports", Price = 275M},
new Product{Name = "Lifejacket", Category = "Watersports", Price = 48.95M},
new Product{Name = "Soccer ball", Category = "Soccer", Price = 19.50M},
new Product{Name = "Corner flag", Category = "Soccer", Price = 34.95M}
}
}; Func<Product, bool> categoryFilter = prod => prod.Category == "Soccer"; decimal total = ; foreach (Product prod in products.Filter(categoryFilter))
{
total += prod.Price;
} return View("Result", (object)String.Format("Total: {0}", total));
}
}
}

Listing 4-22. A Lambda Expression Without a Func

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using LanguageFeatures.Models; namespace LanguageFeatures.Controllers
{
public class HomeController : Controller
{
public string Index()
{
return "Navigate to a URL to show an example";
} // Other action methods omitted for brevity public ViewResult UseFilterExtensionMethod()
{
IEnumerable<Product> products = new ShoppingCart
{
Products = new List<Product> {
new Product{Name = "Kayak", Category = "Watersports", Price = 275M},
new Product{Name = "Lifejacket", Category = "Watersports", Price = 48.95M},
new Product{Name = "Soccer ball", Category = "Soccer", Price = 19.50M},
new Product{Name = "Corner flag", Category = "Soccer", Price = 34.95M}
}
}; decimal total = ; foreach (Product prod in products.Filter(prod => prod.Category == "Soccer"))
{
total += prod.Price;
} return View("Result", (object)String.Format("Total: {0}", total));
}
}
}

Listing 4-23. Extending the Filtering Expressed by the Lambda Expression

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using LanguageFeatures.Models; namespace LanguageFeatures.Controllers
{
public class HomeController : Controller
{
public string Index()
{
return "Navigate to a URL to show an example";
} // Other action methods omitted for brevity public ViewResult UseFilterExtensionMethod()
{
IEnumerable<Product> products = new ShoppingCart
{
Products = new List<Product> {
new Product{Name = "Kayak", Category = "Watersports", Price = 275M},
new Product{Name = "Lifejacket", Category = "Watersports", Price = 48.95M},
new Product{Name = "Soccer ball", Category = "Soccer", Price = 19.50M},
new Product{Name = "Corner flag", Category = "Soccer", Price = 34.95M}
}
}; decimal total = ; foreach (Product prod in products.Filter(
prod => prod.Category == "Soccer" || prod.Price > ))
{
total += prod.Price;
} return View("Result", (object)String.Format("Total: {0}", total));
}
}
}

Listing 4-24. Using Type Inference

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using LanguageFeatures.Models; namespace LanguageFeatures.Controllers
{
public class HomeController : Controller
{
public string Index()
{
return "Navigate to a URL to show an example";
} // Other action methods omitted for brevity public ViewResult UseTypeInference()
{
var myVariable = new Product { Name = "Kayak", Category = "Watersports", Price = 275M }; string name = myVariable.Name; // Legal
int price = myVariable.Price; // Compiler error return View("Result", (object)String.Format("Name: {0}, Price: {1}", name, price));
}
}
}

Listing 4-25. Creating an Anonymous Type

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using LanguageFeatures.Models; namespace LanguageFeatures.Controllers
{
public class HomeController : Controller
{
public string Index()
{
return "Navigate to a URL to show an example";
} // Other action methods omitted for brevity public ViewResult UseTypeInference()
{
var myAnonType = new { Name = "Kayak", Category = "Watersports", Price = 275M }; string name = myAnonType.Name;
decimal price = myAnonType.Price; return View("Result", (object)String.Format("Name: {0}, Price: {1}", name, price));
}
}
}

Listing 4-26. Creating an Array of Anonymously Typed Objects

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.Mvc;
using LanguageFeatures.Models; namespace LanguageFeatures.Controllers
{
public class HomeController : Controller
{
public string Index()
{
return "Navigate to a URL to show an example";
} // Other action methods omitted for brevity public ViewResult CreateAnonArray()
{
var oddsAnonEnds = new[] {
new {Name = "MVC", Category = "Pattern"},
new {Name = "Hat", Category = "Clothing"},
new {Name = "Apple", Category = "Fruit"}
}; StringBuilder result = new StringBuilder();
foreach (var item in oddsAnonEnds)
{
result.Append(item.Name).Append(" ");
} return View("Result", (object)result.ToString());
}
}
}

Listing 4-27. Querying Without LINQ

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.Mvc;
using LanguageFeatures.Models; namespace LanguageFeatures.Controllers
{
public class HomeController : Controller
{
public string Index()
{
return "Navigate to a URL to show an example";
} // Other action methods omitted for brevity public ViewResult FindProducts()
{
Product[] products =
{
new Product {Name = "Kayak", Category = "Watersports", Price = 275M},
new Product {Name = "Lifejacket", Category = "Watersports", Price = 48.95M},
new Product {Name = "Soccer ball", Category = "Soccer", Price = 19.50M},
new Product {Name = "Corner flag", Category = "Soccer", Price = 34.95M}
}; Product[] foundProducts = new Product[]; Array.Sort(products, (item1, item2) => {
return Comparer<decimal>.Default.Compare(item1.Price, item2.Price);
}); Array.Copy(products, foundProducts, ); StringBuilder result = new StringBuilder();
foreach (Product p in foundProducts)
{
result.AppendFormat("Price: {0} ", p.Price);
} return View("Result", (object)result.ToString());
}
}
}

Listing 4-28. Using LINQ to Query Data

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.Mvc;
using LanguageFeatures.Models; namespace LanguageFeatures.Controllers
{
public class HomeController : Controller
{
public string Index()
{
return "Navigate to a URL to show an example";
} // Other action methods omitted for brevity public ViewResult FindProducts()
{
Product[] products =
{
new Product {Name = "Kayak", Category = "Watersports", Price = 275M},
new Product {Name = "Lifejacket", Category = "Watersports", Price = 48.95M},
new Product {Name = "Soccer ball", Category = "Soccer", Price = 19.50M},
new Product {Name = "Corner flag", Category = "Soccer", Price = 34.95M}
}; var foundProducts = from match in products
orderby match.Price descending
select new {
match.Name,
match.Price
}; int count = ; StringBuilder result = new StringBuilder();
foreach (var p in foundProducts)
{
result.AppendFormat("Price: {0} ", p.Price);
if (++count == )
{
break;
}
} return View("Result", (object)result.ToString());
}
}
}

Listing 4-29. Using LINQ Dot Notation

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.Mvc;
using LanguageFeatures.Models; namespace LanguageFeatures.Controllers
{
public class HomeController : Controller
{
public string Index()
{
return "Navigate to a URL to show an example";
} // Other action methods omitted for brevity public ViewResult FindProducts()
{
Product[] products =
{
new Product {Name = "Kayak", Category = "Watersports", Price = 275M},
new Product {Name = "Lifejacket", Category = "Watersports", Price = 48.95M},
new Product {Name = "Soccer ball", Category = "Soccer", Price = 19.50M},
new Product {Name = "Corner flag", Category = "Soccer", Price = 34.95M}
}; var foundProducts = products.OrderByDescending(e => e.Price)
.Take()
.Select(e => new {
e.Name,
e.Price
}); int count = ; StringBuilder result = new StringBuilder();
foreach (var p in foundProducts)
{
result.AppendFormat("Price: {0} ", p.Price);
if (++count == )
{
break;
}
} return View("Result", (object)result.ToString());
}
}
}

Listing 4-30. Using Deferred LINQ Extension Methods in a Query

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.Mvc;
using LanguageFeatures.Models; namespace LanguageFeatures.Controllers
{
public class HomeController : Controller
{
public string Index()
{
return "Navigate to a URL to show an example";
} // Other action methods omitted for brevity public ViewResult FindProducts()
{
Product[] products =
{
new Product {Name = "Kayak", Category = "Watersports", Price = 275M},
new Product {Name = "Lifejacket", Category = "Watersports", Price = 48.95M},
new Product {Name = "Soccer ball", Category = "Soccer", Price = 19.50M},
new Product {Name = "Corner flag", Category = "Soccer", Price = 34.95M}
}; var foundProducts = products.OrderByDescending(e => e.Price)
.Take()
.Select(e => new {
e.Name,
e.Price
}); products[] = new Product { Name = "Stadium", Price = 79600M }; StringBuilder result = new StringBuilder();
foreach (var p in foundProducts)
{
result.AppendFormat("Price: {0} ", p.Price);
} return View("Result", (object)result.ToString());
}
}
}

Listing 4-31. An Immediately Executed LINQ Query

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.Mvc;
using LanguageFeatures.Models; namespace LanguageFeatures.Controllers
{
public class HomeController : Controller
{
public string Index()
{
return "Navigate to a URL to show an example";
} // Other action methods omitted for brevity public ViewResult SumProducts()
{
Product[] products =
{
new Product {Name = "Kayak", Category = "Watersports", Price = 275M},
new Product {Name = "Lifejacket", Category = "Watersports", Price = 48.95M},
new Product {Name = "Soccer ball", Category = "Soccer", Price = 19.50M},
new Product {Name = "Corner flag", Category = "Soccer", Price = 34.95M}
}; var results = products.Sum(e => e.Price); products[] = new Product { Name = "Stadium", Price = 79600M }; return View("Result", (object)String.Format("Sum: {0:c}", results));
}
}
}

Listing 4-32. A Simple Asynchronous Method

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Net.Http;
using System.Threading.Tasks; namespace LanguageFeatures.Models
{
public class MyAsyncMethods
{
public static Task<long?> GetPageLength()
{
HttpClient client = new HttpClient();
var httpTask = client.GetAsync("http://apress.com"); // We could do other things here while we are waiting
// for the HTTP request to complete return httpTask.ContinueWith((Task<HttpResponseMessage> antecedent) => {
return antecedent.Result.Content.Headers.ContentLength;
});
}
}
}

Listing 4-33. Using the async and await Keywords

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Net.Http;
using System.Threading.Tasks; namespace LanguageFeatures.Models
{
public class MyAsyncMethods
{
public async static Task<long?> GetPageLength()
{
HttpClient client = new HttpClient();
var httpMessage = await client.GetAsync("http://apress.com"); // We could do other things here while we are waiting
// for the HTTP request to complete return httpMessage.Content.Headers.ContentLength;
}
}
}

Pro Aspnet MVC 4读书笔记(3) - Essential Language Features的更多相关文章

  1. Pro Aspnet MVC 4读书笔记(5) - Essential Tools for MVC

    Listing 6-1. The Product Model Class using System; using System.Collections.Generic; using System.Li ...

  2. Pro Aspnet MVC 4读书笔记(1) - Your First MVC Application

    Listing 2-1. The default contents of the HomeController class using System; using System.Collections ...

  3. Pro Aspnet MVC 4读书笔记(4) - Working with Razor

    Listing 5-1. Creating a Simple Domain Model Class using System; using System.Collections.Generic; us ...

  4. Pro Aspnet MVC 4读书笔记(2) - The MVC Pattern

    Listing 3-1. The C# Auction Domain Model using System; using System.Collections.Generic; using Syste ...

  5. 【Tools】Pro Git 一二章读书笔记

    记得知乎以前有个问题说:如果用一天的时间学习一门技能,选什么好?里面有个说学会Git是个很不错选择,今天就抽时间感受下Git的魅力吧.   Pro Git (Scott Chacon) 读书笔记:   ...

  6. [Git00] Pro Git 一二章读书笔记

    记得知乎以前有个问题说:如果用一天的时间学习一门技能,选什么好?里面有个说学会Git是个很不错选择,今天就抽时间感受下Git的魅力吧.   Pro Git (Scott Chacon) 读书笔记:   ...

  7. 《Pro Android Graphics》读书笔记之第四节

    Android Procedural Animation: : XML, Concepts and Optimization Procedural Animation Concepts: Tweens ...

  8. 《Pro Android Graphics》读书笔记之第三节

    Android Frame Animation: XML, Concepts and Optimization Frame Animation Concepts: Cels, Framerate, a ...

  9. 《Pro Android Graphics》读书笔记之第六节

    Android UI Layouts: Graphics Design Using the ViewGroup Class Android ViewGroup Superclass: A Founda ...

随机推荐

  1. Red Gate系列之一 SQL Compare 10.4.8.87 Edition 数据库比较工具 完全破解+使用教程

    原文:Red Gate系列之一 SQL Compare 10.4.8.87 Edition 数据库比较工具 完全破解+使用教程 Red Gate系列之一 SQL Compare 10.4.8.87 E ...

  2. c#并行任务多种优化方案分享(异步委托)

    遇到一个多线程任务优化的问题,现在解决了,分享如下. 假设有四个任务: 任务1:登陆验证(CheckUser) 任务2:验证成功后从Web服务获取数据(GetDataFromWeb) 任务3:验证成功 ...

  3. 重新想象 Windows 8 Store Apps (12) - 控件之 GridView 特性: 拖动项, 项尺寸可变, 分组显示

    原文:重新想象 Windows 8 Store Apps (12) - 控件之 GridView 特性: 拖动项, 项尺寸可变, 分组显示 [源码下载] 重新想象 Windows 8 Store Ap ...

  4. 重新想象 Windows 8 Store Apps (20) - 动画: ThemeAnimation(主题动画)

    原文:重新想象 Windows 8 Store Apps (20) - 动画: ThemeAnimation(主题动画) [源码下载] 重新想象 Windows 8 Store Apps (20) - ...

  5. 【Linux】lvm基础操作

    新增两块硬盘,来进行实验: [root@jp ~]# fdisk -l Disk /dev/sda: 107.3 GB, 107374182400 bytes 255 heads, 63 sector ...

  6. python遗产

    1.    python类方法的定义: class Animal(): def __init__(self,name): self.name=name; def show(self): print s ...

  7. 设计模式 - 出厂模式(factory pattern) 详细说明

    出厂模式(factory pattern) 详细说明 本文地址: http://blog.csdn.net/caroline_wendy/article/details/27081511 工厂方法模式 ...

  8. 写一个 docker 打击一系列手册

    感谢您的关注,分享也再次给自己一个学习的.机会组织和总结.对未来一段时间内准备一个关于 docker 一系列的实际应用,其中的一些内容此前曾宣布.准备再次修改和整理. 以下是主要的文件夹中的一个: 创 ...

  9. unity调用安卓打包apk时的错误unable to convert classes into dex format

    出现这种问题一般是由于有重复的文件所致,看下unity报的错误那些文件重复了,把重复的文件删了即可 例如,将eclipse中的安卓工程bin\class导出jar包时,会将下面的.class文件打包, ...

  10. 获取activity的根视图

    Activity的根视图是什么? Activity所谓的根视图,就是Activity的最底层的View,也就是在Acitivty创建的时候setContentView的时候传入的View. 如何获取到 ...