Imported Upstream version 3.6.0

Former-commit-id: da6be194a6b1221998fc28233f2503bd61dd9d14
This commit is contained in:
Jo Shields
2014-08-13 10:39:27 +01:00
commit a575963da9
50588 changed files with 8155799 additions and 0 deletions

View File

@@ -0,0 +1,10 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
public class TestData
{
public string ProductID { get; set; }
public string ProductName { get; set; }
}

View File

@@ -0,0 +1,39 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
public class TestDataComparer : IComparer<TestData>
{
bool byID;
bool ascending;
public TestDataComparer (bool byID, bool ascending)
{
this.byID = byID;
this.ascending = ascending;
}
public int Compare (TestData x, TestData y)
{
if (x == null) {
if (y == null)
return 0;
else
return -1;
}
if (y == null)
return 1;
if (byID) {
int xid = Int32.Parse (x.ProductID);
int yid = Int32.Parse (y.ProductID);
return ascending ? xid - yid : yid - xid;
} else {
int ret = String.Compare (x.ProductName, y.ProductName);
return ascending ? ret : -ret;
}
}
}

View File

@@ -0,0 +1,46 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
public class TestDatabase
{
List <TestData> data = new List<TestData> {
new TestData { ProductID="1", ProductName="Pear"},
new TestData { ProductID="2", ProductName="Apple"},
new TestData { ProductID="3", ProductName="Orange"}
};
public List<TestData> GetData (string sortExpression)
{
if (String.IsNullOrEmpty (sortExpression))
return data;
bool ascending;
string field;
int subtract;
if (sortExpression.EndsWith (" desc", StringComparison.OrdinalIgnoreCase)) {
ascending = false;
subtract = 5;
} else {
ascending = true;
subtract = 0;
}
if (subtract == 0)
field = sortExpression;
else
field = sortExpression.Substring (0, sortExpression.Length - subtract);
TestDataComparer comparer;
if (String.Compare (field, "ProductName", StringComparison.OrdinalIgnoreCase) == 0)
comparer = new TestDataComparer (false, ascending);
else
comparer = new TestDataComparer (true, ascending);
data.Sort (comparer);
return data;
}
}

View File

@@ -0,0 +1,24 @@
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div><%= AppDomain.CurrentDomain.GetData ("BEGIN_CODE_MARKER") %><asp:GridView id="GridView1" runat="server" AutoGenerateColumns="false" AllowSorting="true" DataSourceID="dataSource1"
SortedAscendingCellStyle-BackColor="LightYellow" SortedAscendingHeaderStyle-BackColor="Yellow"
SortedDescendingCellStyle-BackColor="AliceBlue" SortedDescendingHeaderStyle-BackColor="LightBlue">
<Columns>
<asp:BoundField SortExpression="ProductName" DataField="ProductName" HeaderText="Name" />
<asp:BoundField SortExpression="ProductID" DataField="ProductID" HeaderText="ID" />
</Columns>
</asp:GridView><%= AppDomain.CurrentDomain.GetData ("END_CODE_MARKER") %>
<asp:ObjectDataSource ID="dataSource1" runat="server" TypeName="TestDatabase" SelectMethod="GetData"
DataObjectTypeName="TestData" SortParameterName="sortExpression" />
</div>
</form>
</body>
</html>

View File

@@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load (object sender, EventArgs e)
{
}
}

View File

@@ -0,0 +1,10 @@
<?xml version="1.0"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0"/>
</system.web>
</configuration>