mirror of
https://github.com/BepInEx/mono.git
synced 2026-11-16 11:21:08 -10:00
Compare commits
2
Commits
fsharp47
...
NUNIT_1_11
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7f0542b133 | ||
|
|
9f187b5dd0 |
No files matched your search
-13
@@ -1,13 +0,0 @@
|
||||
C# Compiler:
|
||||
Miguel de Icaza ([email protected])
|
||||
|
||||
Class Libraries:
|
||||
Gaurav Vaish <[email protected]>
|
||||
Jeff Stedfast ([email protected])
|
||||
Joe Shaw ([email protected])
|
||||
Miguel de Icaza ([email protected])
|
||||
Sean MacIsaac ([email protected])
|
||||
Vladimir Vukicevic ([email protected])
|
||||
Garrett Rooney ([email protected])
|
||||
Bob Smith ([email protected])
|
||||
John Barnette ([email protected])
|
||||
@@ -1,12 +0,0 @@
|
||||
2002-02-14 Nick Drochak <[email protected]>
|
||||
|
||||
* makefile: Build mcs/doctools too when one does 'make'
|
||||
|
||||
2002-01-20 Nick Drochak <[email protected]>
|
||||
|
||||
* on the 'test' target, make sure NUnit is built first before building
|
||||
and running tests
|
||||
|
||||
2002-01-20 Nick Drochak <[email protected]>
|
||||
|
||||
* add nunit directory to the list of dirs to build in
|
||||
-23
@@ -1,23 +0,0 @@
|
||||
|
||||
This contains the Mono C# compiler as well as the Mono runtime
|
||||
library.
|
||||
|
||||
Layout:
|
||||
|
||||
class/
|
||||
Class libraries
|
||||
|
||||
errors/
|
||||
Sample programs that should generate errors by the compiler.
|
||||
|
||||
jay/
|
||||
Yacc-based parser generator.
|
||||
|
||||
mcs/
|
||||
The Mono C# compiler
|
||||
|
||||
tests/
|
||||
Sample tests
|
||||
|
||||
Thanks a lot to Sergey Chaban for his help during the development of
|
||||
the C# compiler.
|
||||
@@ -1 +0,0 @@
|
||||
lib
|
||||
@@ -1,70 +0,0 @@
|
||||
The class libraries are grouped together in the assemblies they belong.
|
||||
|
||||
Each directory here represents an assembly, and inside each directory we
|
||||
divide the code based on the namespace they implement.
|
||||
|
||||
In addition, each assembly directory contains a Test directory that holds the
|
||||
NUnit tests for that assembly.
|
||||
|
||||
The nant build file for an assembly creates two versions of the dll for that
|
||||
assembly. One version is a "full" dll. The full dll contains (almost) all
|
||||
of the classes, regardless of how complete the classes are. The name of this
|
||||
dll is the normal name you would expect, like "corlib.dll" or "System.dll".
|
||||
These full dll's are created in the /mcs/class/lib directory.
|
||||
|
||||
The other dll which is built is a "restricted" dll. The restricted dll
|
||||
omits incomplete classes that would prevent the NUnit testrunner from actually
|
||||
running the tests. These restricted dll's are created in the Test directory
|
||||
of their respective assembly and named with a "_res" suffix. So, for example,
|
||||
the NUnit-testable dll for corlib is /mcs/class/corlib/Test/corlib_res.dll.
|
||||
|
||||
The final dll which is built is the one which houses the actual NUnit tests.
|
||||
This dll is built from all of the classes in the Test directory and below, and
|
||||
is named with a "_test" suffix. So, for example, the NUnit tests for corlib
|
||||
are in /mcs/class/corlib/Test/corlib_test.dll. This dll is also linked with
|
||||
the restricted dll found in the same directory.
|
||||
|
||||
|
||||
* Missing implementation bits
|
||||
|
||||
If you implement a class and you are missing implementation bits,
|
||||
please put in the code the word "TODO" and a description of what
|
||||
is missing to be implemented.
|
||||
|
||||
* Tagging buggy code
|
||||
|
||||
If there is a bug in your implementation tag the problem by using
|
||||
the word "FIXME" in the code, together with a description of the
|
||||
problem.
|
||||
|
||||
Do not use XXX or obscure descriptions, because otherwise people
|
||||
will not be able to understand what you mean.
|
||||
|
||||
* Tagging Lame specs
|
||||
|
||||
Sometimes the specification will be lame (consider Version.ToString (fieldCount)
|
||||
where there is no way of knowing how many fields are available, making the API
|
||||
not only stupid, but leading to unreliable code).
|
||||
|
||||
In those cases, use the keyword "LAMESPEC".
|
||||
|
||||
* Coding consideration
|
||||
|
||||
Use 8 space tabs for writing your code (hopefully we can keep
|
||||
this consistent). If you are modifying someone else's code, try
|
||||
to keep the coding style similar.
|
||||
|
||||
Please use code that looks like this:
|
||||
|
||||
bool Method (int argument_1, int argument_2)
|
||||
{
|
||||
if (argument_1 == argument_2)
|
||||
throw new Exception (Locale.GetText ("They are equal!");
|
||||
|
||||
if (argument_1 < argument_2) {
|
||||
if (argument_1 * 3 > 4)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
2002-02-10 Christopher Podurgiel <[email protected]>
|
||||
|
||||
* Removed *.cs from System.Data as the correct files are in mcs/class/System.Data/System.Data
|
||||
* Updated all Enums, Interfaces, and Delegates in System.Data
|
||||
|
||||
2002-02-11 Christopher Podurgiel <[email protected]>
|
||||
|
||||
* DataColumnChangeEventArgs.cs : Added
|
||||
* DataColumnChangeEventHandler.cs : Added
|
||||
@@ -1,24 +0,0 @@
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
|
||||
<!-- NAnt build file for System.Data.dll -->
|
||||
|
||||
<project name="System.Data" default="build">
|
||||
<property name="debug" value="false"/>
|
||||
|
||||
<target name="build">
|
||||
<csc target="library" output="../lib/System.Data.dll" debug="${debug}">
|
||||
<arg value="/nowarn:1595"/>
|
||||
<arg value="/unsafe"/>
|
||||
<sources>
|
||||
<includes name="**/*.cs"/>
|
||||
<excludes name="Test/**"/>
|
||||
</sources>
|
||||
<references>
|
||||
<includes name="../lib/corlib.dll"/>
|
||||
</references>
|
||||
</csc>
|
||||
</target>
|
||||
<target name="clean">
|
||||
<delete file="../lib/System.Data.dll" failonerror="false"/>
|
||||
</target>
|
||||
</project>
|
||||
@@ -1,23 +0,0 @@
|
||||
//
|
||||
// System.Data.AcceptRejectRule.cs
|
||||
//
|
||||
// Author:
|
||||
// Christopher Podurgiel ([email protected])
|
||||
//
|
||||
// (C) Chris Podurgiel
|
||||
//
|
||||
|
||||
namespace System.Data
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Determines the action that occurs when the AcceptChanges or RejectChanges method is invoked on a DataTable with a ForeignKeyConstraint.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public enum AcceptRejectRule
|
||||
{
|
||||
Cascade = 1,
|
||||
None = 0
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
//
|
||||
// System.Data.CommandBehavior.cs
|
||||
//
|
||||
// Author:
|
||||
// Christopher Podurgiel ([email protected])
|
||||
//
|
||||
// (C) Chris Podurgiel
|
||||
//
|
||||
|
||||
namespace System.Data
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Specifies a description of the results and the affect on the database of the query command.
|
||||
/// This enumeration has a FlagsAttribute that allows a bitwise combination of its member values.
|
||||
/// </summary>
|
||||
[Flags]
|
||||
[Serializable]
|
||||
public enum CommandBehavior
|
||||
{
|
||||
Default = 0,
|
||||
SingleResult = 1,
|
||||
SchemaOnly = 2,
|
||||
KeyInfo = 4,
|
||||
SingleRow = 8,
|
||||
SequentialAccess = 16,
|
||||
CloseConnection = 32
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
//
|
||||
// System.Data.CommandType.cs
|
||||
//
|
||||
// Author:
|
||||
// Christopher Podurgiel ([email protected])
|
||||
//
|
||||
// (C) Chris Podurgiel
|
||||
//
|
||||
|
||||
using System;
|
||||
|
||||
namespace mono.System.Data
|
||||
{
|
||||
/// <summary>
|
||||
/// Specifies how a command string is interpreted.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public enum CommandType
|
||||
{
|
||||
Text = 1,
|
||||
StoredProcedure = 4,
|
||||
TableDirect = 512
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
//
|
||||
// System.Data.ConnectionState.cs
|
||||
//
|
||||
// Author:
|
||||
// Christopher Podurgiel ([email protected])
|
||||
//
|
||||
// (C) Chris Podurgiel
|
||||
//
|
||||
|
||||
using System;
|
||||
|
||||
namespace mono.System.Data
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Returns the current state of the connection to a data source.
|
||||
/// This enumeration has a FlagsAttribute that allows a bitwise combination of its member values.
|
||||
/// </summary>
|
||||
[Flags]
|
||||
[Serializable]
|
||||
public enum ConnectionState
|
||||
{
|
||||
Closed = 0,
|
||||
Open = 1,
|
||||
Connecting = 2,
|
||||
Executing = 4,
|
||||
Fetching = 8,
|
||||
Broken = 16
|
||||
}
|
||||
}
|
||||
@@ -1,80 +0,0 @@
|
||||
//
|
||||
// System.Data.DataColumnChangeEventArgs.cs
|
||||
//
|
||||
// Author:
|
||||
// Christopher Podurgiel ([email protected])
|
||||
//
|
||||
// (C) Chris Podurgiel
|
||||
//
|
||||
|
||||
using System;
|
||||
|
||||
namespace System.Data
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides data for the ColumnChanging event.
|
||||
/// </summary>
|
||||
public class DataColumnChangeEventArgs : EventArgs
|
||||
{
|
||||
|
||||
private DataColumn _column = null;
|
||||
private DataRow _row = null;
|
||||
private object _proposedValue = null;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the DataColumnChangeEventArgs class.
|
||||
/// </summary>
|
||||
/// <param name="row"></param>
|
||||
/// <param name="column"></param>
|
||||
/// <param name="value"></param>
|
||||
public DataColumnChangeEventArgs(DataRow row, DataColumn column, object value)
|
||||
{
|
||||
_column = column;
|
||||
_row = row;
|
||||
_proposedValue = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the DataColumn with a changing value.
|
||||
/// </summary>
|
||||
public DataColumn Column
|
||||
{
|
||||
get
|
||||
{
|
||||
return _column;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the proposed new value for the column.
|
||||
/// </summary>
|
||||
public object ProposedValue
|
||||
{
|
||||
get
|
||||
{
|
||||
return _proposedValue;
|
||||
}
|
||||
set
|
||||
{
|
||||
_proposedValue = value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets the DataRow of the column with a changing value.
|
||||
/// </summary>
|
||||
public DataRow Row
|
||||
{
|
||||
get
|
||||
{
|
||||
return _row;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
//
|
||||
// System.Data.DataColumnChangeEventHandler.cs
|
||||
//
|
||||
// Author:
|
||||
// Christopher Podurgiel ([email protected])
|
||||
//
|
||||
// (C) Chris Podurgiel
|
||||
//
|
||||
|
||||
namespace System.Data
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents the method that will handle the the ColumnChanging event.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public delegate void DataColumnChangeEventHandler(object sender, DataColumnChangeEventArgs e);
|
||||
|
||||
}
|
||||
@@ -1,413 +0,0 @@
|
||||
//
|
||||
// System.Data.DataColumnCollection.cs
|
||||
//
|
||||
// Author:
|
||||
// Christopher Podurgiel ([email protected])
|
||||
//
|
||||
// (C) Chris Podurgiel
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace System.Data
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a collection of DataColumn objects for a DataTable.
|
||||
/// </summary>
|
||||
public class DataColumnCollection : InternalDataCollectionBase
|
||||
{
|
||||
|
||||
protected ArrayList list = null;
|
||||
|
||||
// The defaultNameIndex is used to create a default name for a column if one wasn't given.
|
||||
private int defaultNameIndex;
|
||||
|
||||
//table should be the DataTable this DataColumnCollection belongs to.
|
||||
private DataTable parentTable = null;
|
||||
|
||||
// Internal Constructor. This Class can only be created from other classes in this assembly.
|
||||
internal DataColumnCollection(DataTable table):base()
|
||||
{
|
||||
list = new ArrayList();
|
||||
defaultNameIndex = 1;
|
||||
parentTable = table;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets the DataColumn from the collection at the specified index.
|
||||
/// </summary>
|
||||
public virtual DataColumn this[int index]
|
||||
{
|
||||
get
|
||||
{
|
||||
return (DataColumn)list[index];
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the DataColumn from the collection with the specified name.
|
||||
/// </summary>
|
||||
public virtual DataColumn this[string name]
|
||||
{
|
||||
get
|
||||
{
|
||||
foreach (DataColumn column in list)
|
||||
{
|
||||
if (column.ColumnName == name)
|
||||
{
|
||||
return column;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets a list of the DataColumnCollection items.
|
||||
/// </summary>
|
||||
protected override ArrayList List
|
||||
{
|
||||
get
|
||||
{
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates and adds a DataColumn object to the DataColumnCollection.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public virtual DataColumn Add()
|
||||
{
|
||||
DataColumn column = new DataColumn("Column" + defaultNameIndex.ToString());
|
||||
CollectionChangeEventArgs e = new CollectionChangeEventArgs(CollectionChangeAction.Add, this);
|
||||
list.Add(column);
|
||||
OnCollectionChanged(e);
|
||||
defaultNameIndex++;
|
||||
return column;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates and adds the specified DataColumn object to the DataColumnCollection.
|
||||
/// </summary>
|
||||
/// <param name="column">The DataColumn to add.</param>
|
||||
public void Add(DataColumn column)
|
||||
{
|
||||
if(Contains(column.ColumnName))
|
||||
{
|
||||
throw new DuplicateNameException("A column named " + column.ColumnName + " already belongs to this DataTable.");
|
||||
}
|
||||
else
|
||||
{
|
||||
CollectionChangeEventArgs e = new CollectionChangeEventArgs(CollectionChangeAction.Add, this);
|
||||
list.Add(column);
|
||||
OnCollectionChanged(e);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates and adds a DataColumn object with the specified name to the DataColumnCollection.
|
||||
/// </summary>
|
||||
/// <param name="columnName">The name of the column.</param>
|
||||
/// <returns>The newly created DataColumn.</returns>
|
||||
public virtual DataColumn Add(string columnName)
|
||||
{
|
||||
|
||||
if (columnName == null || columnName == String.Empty)
|
||||
{
|
||||
columnName = "Column" + defaultNameIndex.ToString();
|
||||
defaultNameIndex++;
|
||||
}
|
||||
|
||||
if(Contains(columnName))
|
||||
{
|
||||
throw new DuplicateNameException("A column named " + columnName + " already belongs to this DataTable.");
|
||||
}
|
||||
else
|
||||
{
|
||||
DataColumn column = new DataColumn(columnName);
|
||||
|
||||
CollectionChangeEventArgs e = new CollectionChangeEventArgs(CollectionChangeAction.Add, this);
|
||||
list.Add(column);
|
||||
OnCollectionChanged(e);
|
||||
return column;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates and adds a DataColumn object with the specified name and type to the DataColumnCollection.
|
||||
/// </summary>
|
||||
/// <param name="columnName">The ColumnName to use when cretaing the column.</param>
|
||||
/// <param name="type">The DataType of the new column.</param>
|
||||
/// <returns>The newly created DataColumn.</returns>
|
||||
public virtual DataColumn Add(string columnName, Type type)
|
||||
{
|
||||
if (columnName == null || columnName == "")
|
||||
{
|
||||
columnName = "Column" + defaultNameIndex.ToString();
|
||||
defaultNameIndex++;
|
||||
}
|
||||
|
||||
if(Contains(columnName))
|
||||
{
|
||||
throw new DuplicateNameException("A column named " + columnName + " already belongs to this DataTable.");
|
||||
}
|
||||
else
|
||||
{
|
||||
DataColumn column = new DataColumn(columnName, type);
|
||||
CollectionChangeEventArgs e = new CollectionChangeEventArgs(CollectionChangeAction.Add, this);
|
||||
list.Add(column);
|
||||
OnCollectionChanged(e);
|
||||
return column;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates and adds a DataColumn object with the specified name, type, and expression to the DataColumnCollection.
|
||||
/// </summary>
|
||||
/// <param name="columnName">The name to use when creating the column.</param>
|
||||
/// <param name="type">The DataType of the new column.</param>
|
||||
/// <param name="expression">The expression to assign to the Expression property.</param>
|
||||
/// <returns>The newly created DataColumn.</returns>
|
||||
public virtual DataColumn Add(string columnName, Type type, string expression)
|
||||
{
|
||||
if (columnName == null || columnName == "")
|
||||
{
|
||||
columnName = "Column" + defaultNameIndex.ToString();
|
||||
defaultNameIndex++;
|
||||
}
|
||||
|
||||
if(Contains(columnName))
|
||||
{
|
||||
throw new DuplicateNameException("A column named " + columnName + " already belongs to this DataTable.");
|
||||
}
|
||||
else
|
||||
{
|
||||
DataColumn column = new DataColumn(columnName, type, expression);
|
||||
CollectionChangeEventArgs e = new CollectionChangeEventArgs(CollectionChangeAction.Add, this);
|
||||
list.Add(column);
|
||||
OnCollectionChanged(e);
|
||||
return column;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Copies the elements of the specified DataColumn array to the end of the collection.
|
||||
/// </summary>
|
||||
/// <param name="columns">The array of DataColumn objects to add to the collection.</param>
|
||||
public void AddRange(DataColumn[] columns)
|
||||
{
|
||||
foreach (DataColumn column in columns)
|
||||
{
|
||||
Add(column);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks whether a given column can be removed from the collection.
|
||||
/// </summary>
|
||||
/// <param name="column">A DataColumn in the collection.</param>
|
||||
/// <returns>true if the column can be removed; otherwise, false.</returns>
|
||||
public bool CanRemove(DataColumn column)
|
||||
{
|
||||
|
||||
//Check that the column does not have a null reference.
|
||||
if (column == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
//Check that the column is part of this collection.
|
||||
if (!Contains(column.ColumnName))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//Check if this column is part of a relationship. (this could probably be written better)
|
||||
foreach (DataRelation childRelation in parentTable.ChildRelations)
|
||||
{
|
||||
foreach (DataColumn childColumn in childRelation.ChildColumns)
|
||||
{
|
||||
if (childColumn == column)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
foreach (DataColumn parentColumn in childRelation.ParentColumns)
|
||||
{
|
||||
if (parentColumn == column)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Check if this column is part of a relationship. (this could probably be written better)
|
||||
foreach (DataRelation parentRelation in parentTable.ParentRelations)
|
||||
{
|
||||
foreach (DataColumn childColumn in parentRelation.ChildColumns)
|
||||
{
|
||||
if (childColumn == column)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
foreach (DataColumn parentColumn in parentRelation.ParentColumns)
|
||||
{
|
||||
if (parentColumn == column)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//Check if another column's expression depends on this column.
|
||||
|
||||
foreach (DataColumn dataColumn in list)
|
||||
{
|
||||
if (dataColumn.Expression.ToString().IndexOf(column.ColumnName) > 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clears the collection of any columns.
|
||||
/// </summary>
|
||||
public void Clear()
|
||||
{
|
||||
CollectionChangeEventArgs e = new CollectionChangeEventArgs(CollectionChangeAction.Refresh, this);
|
||||
list.Clear();
|
||||
OnCollectionChanged(e);
|
||||
return;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks whether the collection contains a column with the specified name.
|
||||
/// </summary>
|
||||
/// <param name="name">The ColumnName of the column to check for.</param>
|
||||
/// <returns>true if a column exists with this name; otherwise, false.</returns>
|
||||
public bool Contains(string name)
|
||||
{
|
||||
return (IndexOf(name) != -1);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the index of a column specified by name.
|
||||
/// </summary>
|
||||
/// <param name="column">The name of the column to return.</param>
|
||||
/// <returns>The index of the column specified by column if it is found; otherwise, -1.</returns>
|
||||
public virtual int IndexOf(DataColumn column)
|
||||
{
|
||||
return list.IndexOf(column);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the index of the column with the given name (the name is not case sensitive).
|
||||
/// </summary>
|
||||
/// <param name="columnName">The name of the column to find.</param>
|
||||
/// <returns>The zero-based index of the column with the specified name, or -1 if the column doesn't exist in the collection.</returns>
|
||||
public int IndexOf(string columnName)
|
||||
{
|
||||
|
||||
DataColumn column = this[columnName];
|
||||
|
||||
if (column != null)
|
||||
{
|
||||
return IndexOf(column);
|
||||
}
|
||||
else
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raises the OnCollectionChanged event.
|
||||
/// </summary>
|
||||
/// <param name="ccevent">A CollectionChangeEventArgs that contains the event data.</param>
|
||||
protected virtual void OnCollectionChanged(CollectionChangeEventArgs ccevent)
|
||||
{
|
||||
if (CollectionChanged != null)
|
||||
{
|
||||
// Invokes the delegate.
|
||||
CollectionChanged(this, ccevent);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raises the OnCollectionChanging event.
|
||||
/// </summary>
|
||||
/// <param name="ccevent">A CollectionChangeEventArgs that contains the event data.</param>
|
||||
protected internal virtual void OnCollectionChanging(CollectionChangeEventArgs ccevent)
|
||||
{
|
||||
if (CollectionChanged != null)
|
||||
{
|
||||
// Invokes the delegate.
|
||||
CollectionChanged(this, ccevent);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes the specified DataColumn object from the collection.
|
||||
/// </summary>
|
||||
/// <param name="column">The DataColumn to remove.</param>
|
||||
public void Remove(DataColumn column)
|
||||
{
|
||||
CollectionChangeEventArgs e = new CollectionChangeEventArgs(CollectionChangeAction.Remove, this);
|
||||
list.Remove(column);
|
||||
OnCollectionChanged(e);
|
||||
return;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes the DataColumn object with the specified name from the collection.
|
||||
/// </summary>
|
||||
/// <param name="name">The name of the column to remove.</param>
|
||||
public void Remove(string name)
|
||||
{
|
||||
DataColumn column = this[name];
|
||||
CollectionChangeEventArgs e = new CollectionChangeEventArgs(CollectionChangeAction.Remove, this);
|
||||
list.Remove(column);
|
||||
OnCollectionChanged(e);
|
||||
return;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes the column at the specified index from the collection.
|
||||
/// </summary>
|
||||
/// <param name="index">The index of the column to remove.</param>
|
||||
public void RemoveAt(int index)
|
||||
{
|
||||
CollectionChangeEventArgs e = new CollectionChangeEventArgs(CollectionChangeAction.Remove, this);
|
||||
list.RemoveAt(index);
|
||||
OnCollectionChanged(e);
|
||||
return;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when the columns collection changes, either by adding or removing a column.
|
||||
/// </summary>
|
||||
public event CollectionChangeEventHandler CollectionChanged;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
//
|
||||
// System.Data.DataRowAction.cs
|
||||
//
|
||||
// Author:
|
||||
// Christopher Podurgiel ([email protected])
|
||||
//
|
||||
// (C) Chris Podurgiel
|
||||
//
|
||||
|
||||
namespace System.Data
|
||||
{
|
||||
/// <summary>
|
||||
/// Describes the action taken on a DataRow.
|
||||
/// This enumeration has a FlagsAttribute that allows a bitwise combination of its member values.
|
||||
/// </summary>
|
||||
[Flags]
|
||||
[Serializable]
|
||||
public enum DataRowAction
|
||||
{
|
||||
Nothing = 0,
|
||||
Delete = 1,
|
||||
Change = 2,
|
||||
Rollback = 4,
|
||||
Commit = 8,
|
||||
Add = 16
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
//
|
||||
// System.Data.DataRowChangeEventHandler.cs
|
||||
//
|
||||
// Author:
|
||||
// Christopher Podurgiel ([email protected])
|
||||
//
|
||||
// (C) Chris Podurgiel
|
||||
//
|
||||
|
||||
namespace System.Data
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents the method that will handle the RowChanging, RowChanged, RowDeleting, and RowDeleted events of a DataTable.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public delegate void DataRowChangeEventHandler(object sender, DataRowChangeEventArgs e);
|
||||
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
//
|
||||
// System.Data.DataRowState.cs
|
||||
//
|
||||
// Author:
|
||||
// Christopher Podurgiel ([email protected])
|
||||
//
|
||||
// (C) Chris Podurgiel
|
||||
//
|
||||
|
||||
namespace System.Data
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the state of a DataRow object.
|
||||
/// </summary>
|
||||
[Flags]
|
||||
[Serializable]
|
||||
public enum DataRowState
|
||||
{
|
||||
Detached = 1,
|
||||
Unchanged = 2,
|
||||
Added = 4,
|
||||
Deleted = 8,
|
||||
Modified = 16
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
//
|
||||
// System.Data.DataRowVersion.cs
|
||||
//
|
||||
// Author:
|
||||
// Christopher Podurgiel ([email protected])
|
||||
//
|
||||
// (C) Chris Podurgiel
|
||||
//
|
||||
|
||||
namespace System.Data
|
||||
{
|
||||
/// <summary>
|
||||
/// Describes the version of a DataRow.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public enum DataRowVersion
|
||||
{
|
||||
Original = 256,
|
||||
Current = 512,
|
||||
Proposed = 1024,
|
||||
Default = 1536
|
||||
}
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
//
|
||||
// System.Data.DataViewRowState.cs
|
||||
//
|
||||
// Author:
|
||||
// Christopher Podurgiel ([email protected])
|
||||
//
|
||||
// (C) Chris Podurgiel
|
||||
//
|
||||
|
||||
namespace System.Data
|
||||
{
|
||||
/// <summary>
|
||||
/// Describes the version of data in a DataRow.
|
||||
/// This enumeration has a FlagsAttribute that allows a bitwise combination of its member values.
|
||||
/// </summary>
|
||||
[Flags]
|
||||
[Serializable]
|
||||
public enum DataViewRowState
|
||||
{
|
||||
None = 0,
|
||||
Unchanged = 2,
|
||||
Added = 4,
|
||||
Deleted = 8,
|
||||
ModifiedCurrent = 16,
|
||||
CurrentRows = 22,
|
||||
ModifiedOriginal = 32,
|
||||
OriginalRows = 42
|
||||
}
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
//
|
||||
// System.Data.DbType.cs
|
||||
//
|
||||
// Author:
|
||||
// Christopher Podurgiel ([email protected])
|
||||
//
|
||||
// (C) Chris Podurgiel
|
||||
//
|
||||
|
||||
namespace System.Data
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the data type of a field, a property, or a Parameter object of a .NET data provider.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public enum DbType
|
||||
{
|
||||
AnsiString = 0,
|
||||
Binary = 1,
|
||||
Byte = 2,
|
||||
Boolean = 3,
|
||||
Currency = 4,
|
||||
Date = 5,
|
||||
DateTime = 6,
|
||||
Decimal = 7,
|
||||
Double = 8,
|
||||
Guid = 9,
|
||||
Int16 = 10,
|
||||
Int32 = 11,
|
||||
Int64 = 12,
|
||||
Object = 13,
|
||||
SByte = 14,
|
||||
Single = 15,
|
||||
String = 16,
|
||||
Time = 17,
|
||||
UInt16 = 18,
|
||||
UInt32 = 19,
|
||||
UInt64 = 20,
|
||||
VarNumeric = 21,
|
||||
AnsiStringFixedLength = 22,
|
||||
StringFixedLength = 23
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
//
|
||||
// System.Data.FillErrorEventHandler.cs
|
||||
//
|
||||
// Author:
|
||||
// Christopher Podurgiel ([email protected])
|
||||
//
|
||||
// (C) Chris Podurgiel
|
||||
//
|
||||
|
||||
namespace System.Data
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents the method that will handle the FillError event.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public delegate void FillErrorEventHandler(object sender, FillErrorEventArgs e);
|
||||
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
//
|
||||
// System.Data.IColumnMapping.cs
|
||||
//
|
||||
// Author:
|
||||
// Christopher Podurgiel ([email protected])
|
||||
//
|
||||
// (C) Chris Podurgiel
|
||||
//
|
||||
|
||||
namespace System.Data
|
||||
{
|
||||
/// <summary>
|
||||
/// Associates a data source column with a DataSet column, and is implemented by the DataColumnMapping class, which is used in common by .NET data providers.
|
||||
/// </summary>
|
||||
public interface IColumnMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the name of the column within the DataSet to map to.
|
||||
/// </summary>
|
||||
string DataSetColumn
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the name of the column within the data source to map from. The name is case-sensitive.
|
||||
/// </summary>
|
||||
string SourceColumn
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
//
|
||||
// System.Data.IColumnMappingCollection.cs
|
||||
//
|
||||
// Author:
|
||||
// Christopher Podurgiel ([email protected])
|
||||
//
|
||||
// (C) Chris Podurgiel
|
||||
//
|
||||
|
||||
using System.Collections;
|
||||
|
||||
namespace System.Data
|
||||
{
|
||||
/// <summary>
|
||||
/// Contains a collection of ColumnMapping objects, and is implemented by the DataColumnMappingCollection, which is used in common by .NET data providers.
|
||||
/// </summary>
|
||||
public interface IColumnMappingCollection : IList, ICollection, IEnumerable
|
||||
{
|
||||
IColumnMapping Add(string sourceColumnName, string dataSetColumnName);
|
||||
|
||||
bool Contains(string sourceColumnName);
|
||||
|
||||
IColumnMapping GetByDataSetColumn(string dataSetColumnName);
|
||||
|
||||
int IndexOf(string sourceColumnName);
|
||||
|
||||
void RemoveAt(string sourceColumnName);
|
||||
|
||||
object this[string index]
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
//
|
||||
// System.Data.IDataAdapter.cs
|
||||
//
|
||||
// Author:
|
||||
// Christopher Podurgiel ([email protected])
|
||||
//
|
||||
// (C) Chris Podurgiel
|
||||
//
|
||||
|
||||
namespace System.Data
|
||||
{
|
||||
/// <summary>
|
||||
/// Allows an object to implement a DataAdapter, and represents a set of methods and mapping action-related properties used to fill and refresh a DataSet and update a data source.
|
||||
/// </summary>
|
||||
public interface IDataAdapter
|
||||
{
|
||||
int Fill(DataSet dataSet);
|
||||
|
||||
DataTable[] FillSchema(DataSet dataSet, SchemaType schemaType);
|
||||
|
||||
IDataParameter[] GetFillParameters();
|
||||
|
||||
int Update(DataSet dataSet);
|
||||
|
||||
MissingMappingAction MissingMappingAction{get;set;}
|
||||
|
||||
MissingSchemaAction MissingSchemaAction{get;set;}
|
||||
|
||||
ITableMappingCollection TableMappings{get;}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
//
|
||||
// System.Data.IDataParameter.cs
|
||||
//
|
||||
// Author:
|
||||
// Christopher Podurgiel ([email protected])
|
||||
//
|
||||
// (C) Chris Podurgiel
|
||||
//
|
||||
|
||||
namespace System.Data
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a parameter to a Command object, and optionally, its mapping to DataSet columns; and is implemented by .NET data providers that access data sources.
|
||||
/// </summary>
|
||||
public interface IDataParameter
|
||||
{
|
||||
|
||||
DbType DbType{get;set;}
|
||||
|
||||
ParameterDirection Direction{get;set;}
|
||||
|
||||
bool IsNullable{get;}
|
||||
|
||||
string ParameterName{get;set;}
|
||||
|
||||
string SourceColumn{get;set;}
|
||||
|
||||
DataRowVersion SourceVersion {get;set;}
|
||||
|
||||
object Value {get;set;}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
//
|
||||
// System.Data.IDataParameterCollection.cs
|
||||
//
|
||||
// Author:
|
||||
// Christopher Podurgiel ([email protected])
|
||||
//
|
||||
// (C) Chris Podurgiel
|
||||
//
|
||||
|
||||
using System.Collections;
|
||||
|
||||
namespace System.Data
|
||||
{
|
||||
/// <summary>
|
||||
/// Collects all parameters relevant to a Command object and their mappings to DataSet columns, and is implemented by .NET data providers that access data sources.
|
||||
/// </summary>
|
||||
public interface IDataParameterCollection : IList, ICollection, IEnumerable
|
||||
{
|
||||
void RemoveAt(string parameterName);
|
||||
|
||||
int IndexOf(string parameterName);
|
||||
|
||||
bool Contains(string parameterName);
|
||||
|
||||
object this[string parameterName]{get; set;}
|
||||
}
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
//
|
||||
// System.Data.IDataReader.cs
|
||||
//
|
||||
// Author:
|
||||
// Christopher Podurgiel ([email protected])
|
||||
//
|
||||
// (C) Chris Podurgiel
|
||||
//
|
||||
|
||||
namespace System.Data
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides a means of reading one or more forward-only streams of result sets obtained by executing a command at a data source, and is implemented by .NET data providers that access relational databases.
|
||||
/// </summary>
|
||||
public interface IDataReader : IDisposable, IDataRecord
|
||||
{
|
||||
void Close();
|
||||
|
||||
DataTable GetSchemaTable();
|
||||
|
||||
bool NextResult();
|
||||
|
||||
bool Read();
|
||||
|
||||
int Depth{get;}
|
||||
|
||||
bool IsClosed{get;}
|
||||
|
||||
int RecordsAffected{get;}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,67 +0,0 @@
|
||||
//
|
||||
// System.Data.IDataRecord.cs
|
||||
//
|
||||
// Author:
|
||||
// Christopher Podurgiel ([email protected])
|
||||
//
|
||||
// (C) Chris Podurgiel
|
||||
//
|
||||
|
||||
namespace System.Data
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides access to the column values within each row for a DataReader, and is implemented by .NET data providers that access relational databases.
|
||||
/// </summary>
|
||||
public interface IDataRecord
|
||||
{
|
||||
bool GetBoolean(int i);
|
||||
|
||||
byte GetByte(int i);
|
||||
|
||||
long GetBytes(int i, long fieldOffset, byte[] buffer, int bufferOffset, int length);
|
||||
|
||||
char GetChar(int i);
|
||||
|
||||
long GetChars(int i, long fieldOffset, char[] buffer, int bufferOffset, int length);
|
||||
|
||||
IDataReader GetData(int i);
|
||||
|
||||
string GetDataTypeName(int i);
|
||||
|
||||
DateTime GetDateTime(int i);
|
||||
|
||||
decimal GetDecimal(int i);
|
||||
|
||||
double GetDouble(int i);
|
||||
|
||||
Type GetFieldType(int i);
|
||||
|
||||
float GetFloat(int i);
|
||||
|
||||
Guid GetGuid(int i);
|
||||
|
||||
short GetInt16(int i);
|
||||
|
||||
int GetInt32(int i);
|
||||
|
||||
long GetInt64(int i);
|
||||
|
||||
string GetName(int i);
|
||||
|
||||
int GetOrdinal(string name);
|
||||
|
||||
string GetString(int i);
|
||||
|
||||
object GetValue(int i);
|
||||
|
||||
int GetValues(object[] values);
|
||||
|
||||
bool IsDBNull(int i);
|
||||
|
||||
int FieldCount{get;}
|
||||
|
||||
object this[string name]{get;}
|
||||
|
||||
object this[int i]{get;}
|
||||
}
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
//
|
||||
// System.Data.IDBCommand.cs
|
||||
//
|
||||
// Author:
|
||||
// Christopher Podurgiel ([email protected])
|
||||
//
|
||||
// (C) Chris Podurgiel
|
||||
//
|
||||
|
||||
namespace System.Data
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a SQL statement that is executed while connected to a data source, and is implemented by .NET data providers that access relational databases.
|
||||
/// </summary>
|
||||
public interface IDBCommand
|
||||
{
|
||||
void Cancel();
|
||||
|
||||
IDbDataParameter CreateParameter();
|
||||
|
||||
int ExecuteNonQuery();
|
||||
|
||||
IDataReader ExecuteReader();
|
||||
|
||||
IDataReader ExecuteReader(CommandBehavior behavior);
|
||||
|
||||
object ExecuteScalar();
|
||||
|
||||
void Prepare();
|
||||
|
||||
|
||||
string CommandText{get; set;}
|
||||
|
||||
int CommandTimeout{get; set;}
|
||||
|
||||
CommandType CommandType{get; set;}
|
||||
|
||||
IDbConnection Connection{get; set;}
|
||||
|
||||
IDataParameterCollection Parameters{get;}
|
||||
|
||||
IDbTransaction Transaction{get; set;}
|
||||
|
||||
UpdateRowSource UpdatedRowSource{get; set;}
|
||||
}
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
//
|
||||
// System.Data.IDBConnection.cs
|
||||
//
|
||||
// Author:
|
||||
// Christopher Podurgiel ([email protected])
|
||||
//
|
||||
// (C) Chris Podurgiel
|
||||
//
|
||||
|
||||
namespace System.Data
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents an open connection to a data source, and is implemented by .NET data providers that access relational databases.
|
||||
/// </summary>
|
||||
public interface IDBConnection
|
||||
{
|
||||
IDbTransaction BeginTransaction();
|
||||
|
||||
IDbTransaction BeginTransaction(IsolationLevel il);
|
||||
|
||||
void ChangeDatabase(string databaseName);
|
||||
|
||||
void Close();
|
||||
|
||||
IDbCommand CreateCommand();
|
||||
|
||||
void Open();
|
||||
|
||||
|
||||
string ConnectionString{get; set;}
|
||||
|
||||
int ConnectionTimeout{get;}
|
||||
|
||||
string Database{get;}
|
||||
|
||||
ConnectionState State{get;}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
//
|
||||
// System.Data.IDbDataAdapter.cs
|
||||
//
|
||||
// Author:
|
||||
// Christopher Podurgiel ([email protected])
|
||||
//
|
||||
// (C) Chris Podurgiel
|
||||
//
|
||||
|
||||
namespace System.Data
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a set of command-related properties that are used to fill the DataSet and update a data source, and is implemented by .NET data providers that access relational databases.
|
||||
/// </summary>
|
||||
public interface IDbDataAdapter : IDataAdapter
|
||||
{
|
||||
IDbCommand DeleteCommand{get; set;}
|
||||
|
||||
IDbCommand InsertCommand{get; set;}
|
||||
|
||||
IDbCommand SelectCommand{get; set;}
|
||||
|
||||
IDbCommand UpdateCommand{get; set;}
|
||||
}
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
//
|
||||
// System.Data.IDbDataParameter.cs
|
||||
//
|
||||
// Author:
|
||||
// Christopher Podurgiel ([email protected])
|
||||
//
|
||||
// (C) Chris Podurgiel
|
||||
//
|
||||
|
||||
namespace System.Data
|
||||
{
|
||||
/// <summary>
|
||||
/// Used by the Visual Basic .NET Data Designers to represent a parameter to a Command object, and optionally, its mapping to DataSet columns.
|
||||
/// </summary>
|
||||
public interface IDbDataParameter
|
||||
{
|
||||
byte Precision{get; set;}
|
||||
|
||||
byte Scale{get; set;}
|
||||
|
||||
int Size{get; set;}
|
||||
}
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
//
|
||||
// System.Data.IDbTransaction.cs
|
||||
//
|
||||
// Author:
|
||||
// Christopher Podurgiel ([email protected])
|
||||
//
|
||||
// (C) Chris Podurgiel
|
||||
//
|
||||
|
||||
namespace System.Data
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a transaction to be performed at a data source, and is implemented by .NET data providers that access relational databases.
|
||||
/// </summary>
|
||||
public interface IDbTransaction
|
||||
{
|
||||
void Commit();
|
||||
|
||||
void Rollback();
|
||||
|
||||
IDbConnection Connection{get;}
|
||||
|
||||
IsolationLevel IsolationLevel{get;}
|
||||
}
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
//
|
||||
// System.Data.ITableMapping.cs
|
||||
//
|
||||
// Author:
|
||||
// Christopher Podurgiel ([email protected])
|
||||
//
|
||||
// (C) Chris Podurgiel
|
||||
//
|
||||
|
||||
namespace System.Data
|
||||
{
|
||||
/// <summary>
|
||||
/// Associates a source table with a table in a DataSet, and is implemented by the DataTableMapping class, which is used in common by .NET data providers.
|
||||
/// </summary>
|
||||
public interface ITableMapping
|
||||
{
|
||||
IColumnMappingCollection ColumnMappings{get;}
|
||||
|
||||
string DataSetTable{get; set;}
|
||||
|
||||
string SourceTable{get; set;}
|
||||
}
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
//
|
||||
// System.Data.ITableMappingCollection.cs
|
||||
//
|
||||
// Author:
|
||||
// Christopher Podurgiel ([email protected])
|
||||
//
|
||||
// (C) Chris Podurgiel
|
||||
//
|
||||
|
||||
using System.Collections;
|
||||
|
||||
namespace System.Data
|
||||
{
|
||||
/// <summary>
|
||||
/// Contains a collection of TableMapping objects, and is implemented by the DataTableMappingCollection, which is used in common by .NET data providers.
|
||||
/// </summary>
|
||||
public interface ITableMappingCollection : IList, ICollection, IEnumerable
|
||||
{
|
||||
ITableMapping Add(string sourceTableName, string dataSetTableName);
|
||||
|
||||
bool Contains(string sourceTableName);
|
||||
|
||||
ITableMapping GetByDataSetTable(string dataSetTableName);
|
||||
|
||||
int IndexOf(string sourceTableName);
|
||||
|
||||
void RemoveAt(string sourceTableName);
|
||||
|
||||
object this[string index]{get; set;}
|
||||
}
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
//
|
||||
// System.Data.IsolationLevel.cs
|
||||
//
|
||||
// Author:
|
||||
// Christopher Podurgiel ([email protected])
|
||||
//
|
||||
// (C) Chris Podurgiel
|
||||
//
|
||||
|
||||
namespace System.Data
|
||||
{
|
||||
/// <summary>
|
||||
/// Specifies the transaction locking behavior for the connection.
|
||||
/// This enumeration has a FlagsAttribute that allows a bitwise combination of its member values.
|
||||
/// </summary>
|
||||
[Flags]
|
||||
[Serializable]
|
||||
public enum IsolationLevel
|
||||
{
|
||||
Unspecified = -1,
|
||||
Chaos = 16,
|
||||
ReadUncommitted = 256,
|
||||
ReadCommitted = 4096,
|
||||
RepeatableRead = 65536,
|
||||
Serializable = 1048576
|
||||
}
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
//
|
||||
// System.Data.MappingType.cs
|
||||
//
|
||||
// Author:
|
||||
// Christopher Podurgiel ([email protected])
|
||||
//
|
||||
// (C) Chris Podurgiel
|
||||
//
|
||||
|
||||
using System;
|
||||
|
||||
namespace mono.System.Data
|
||||
{
|
||||
/// <summary>
|
||||
/// Specifies how a DataColumn is mapped.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public enum MappingType
|
||||
{
|
||||
Element = 1,
|
||||
Attribute = 2,
|
||||
SimpleContent = 3,
|
||||
Hidden = 4
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
//
|
||||
// System.Data.MergeFailedEventHandler.cs
|
||||
//
|
||||
// Author:
|
||||
// Christopher Podurgiel ([email protected])
|
||||
//
|
||||
// (C) Chris Podurgiel
|
||||
//
|
||||
|
||||
namespace System.Data
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents the method that will handle the MergeFailed event.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public delegate void MergeFailedEventHandler(object sender, MergeFailedEventArgs e);
|
||||
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
//
|
||||
// System.Data.MissingMappingAction.cs
|
||||
//
|
||||
// Author:
|
||||
// Christopher Podurgiel ([email protected])
|
||||
//
|
||||
// (C) Chris Podurgiel
|
||||
//
|
||||
|
||||
using System;
|
||||
|
||||
namespace mono.System.Data
|
||||
{
|
||||
/// <summary>
|
||||
/// Determines the action that occurs when a mapping is missing from a source table or a source column.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public enum MissingMappingAction
|
||||
{
|
||||
Passthrough = 1,
|
||||
Ignore = 2,
|
||||
Error = 3
|
||||
}
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
//
|
||||
// System.Data.MissingSchemaAction.cs
|
||||
//
|
||||
// Author:
|
||||
// Christopher Podurgiel ([email protected])
|
||||
//
|
||||
// (C) Chris Podurgiel
|
||||
//
|
||||
|
||||
using System;
|
||||
|
||||
namespace mono.System.Data
|
||||
{
|
||||
/// <summary>
|
||||
/// Specifies the action to take when adding data to the DataSet and the required DataTable or DataColumn is missing.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public enum MissingSchemaAction
|
||||
{
|
||||
Add = 1,
|
||||
Ignore = 2,
|
||||
Error = 3,
|
||||
AddWithKey = 4
|
||||
}
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
//
|
||||
// System.Data.ParameterDirection.cs
|
||||
//
|
||||
// Author:
|
||||
// Christopher Podurgiel ([email protected])
|
||||
//
|
||||
// (C) Chris Podurgiel
|
||||
//
|
||||
|
||||
using System;
|
||||
|
||||
namespace mono.System.Data
|
||||
{
|
||||
/// <summary>
|
||||
/// Specifies the type of a parameter within a query relative to the DataSet.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public enum ParameterDirection
|
||||
{
|
||||
Input = 1,
|
||||
Output = 2,
|
||||
InputOutput = 3,
|
||||
ReturnValue = 6
|
||||
}
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
//
|
||||
// System.Data.PropertyAttributes.cs
|
||||
//
|
||||
// Author:
|
||||
// Christopher Podurgiel ([email protected])
|
||||
//
|
||||
// (C) Chris Podurgiel
|
||||
//
|
||||
|
||||
using System;
|
||||
|
||||
namespace mono.System.Data
|
||||
{
|
||||
/// <summary>
|
||||
/// Specifies the attributes of a property.
|
||||
/// This enumeration has a FlagsAttribute that allows a bitwise combination of its member values
|
||||
/// </summary>
|
||||
[Flags]
|
||||
[Serializable]
|
||||
public enum PropertyAttributes
|
||||
{
|
||||
NotSupported = 0,
|
||||
Required = 1,
|
||||
Optional = 2,
|
||||
Read = 512,
|
||||
Write = 1024
|
||||
}
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
//
|
||||
// System.Data.Rule.cs
|
||||
//
|
||||
// Author:
|
||||
// Christopher Podurgiel ([email protected])
|
||||
//
|
||||
// (C) Chris Podurgiel
|
||||
//
|
||||
|
||||
using System;
|
||||
|
||||
namespace mono.System.Data
|
||||
{
|
||||
/// <summary>
|
||||
/// Indicates the action that occurs when a ForeignKeyConstraint is enforced.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public enum Rule
|
||||
{
|
||||
None = 0,
|
||||
Cascade = 1,
|
||||
SetNull = 2,
|
||||
SetDefault = 3
|
||||
}
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
//
|
||||
// System.Data.SchemaType.cs
|
||||
//
|
||||
// Author:
|
||||
// Christopher Podurgiel ([email protected])
|
||||
//
|
||||
// (C) Chris Podurgiel
|
||||
//
|
||||
|
||||
using System;
|
||||
|
||||
namespace mono.System.Data
|
||||
{
|
||||
/// <summary>
|
||||
/// Specifies how to handle existing schema mappings when performing a FillSchema operation.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public enum SchemaType
|
||||
{
|
||||
Source = 1,
|
||||
Mapped = 2
|
||||
}
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
//
|
||||
// System.Data.SqlDbType.cs
|
||||
//
|
||||
// Author:
|
||||
// Christopher Podurgiel ([email protected])
|
||||
//
|
||||
// (C) Chris Podurgiel
|
||||
//
|
||||
|
||||
using System;
|
||||
|
||||
namespace mono.System.Data
|
||||
{
|
||||
/// <summary>
|
||||
/// Specifies SQL Server data types.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public enum SqlDbType
|
||||
{
|
||||
BigInt = 0,
|
||||
Binary = 1,
|
||||
Bit = 2,
|
||||
Char = 3,
|
||||
DateTime = 4,
|
||||
Decimal = 5,
|
||||
Float = 6,
|
||||
Image = 7,
|
||||
Int = 8,
|
||||
Money = 9,
|
||||
NChar = 10,
|
||||
NText = 11,
|
||||
NVarChar = 12,
|
||||
Real = 13,
|
||||
UniqueIdentifier = 14,
|
||||
SmallDateTime = 15,
|
||||
SmallInt = 16,
|
||||
SmallMoney = 17,
|
||||
Text = 18,
|
||||
Timestamp = 19,
|
||||
TinyInt = 20,
|
||||
VarBinary = 21,
|
||||
VarChar = 22,
|
||||
Variant = 23
|
||||
}
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
//
|
||||
// System.Data.StateChangeEventHandler.cs
|
||||
//
|
||||
// Author:
|
||||
// Christopher Podurgiel ([email protected])
|
||||
//
|
||||
// (C) Chris Podurgiel
|
||||
//
|
||||
|
||||
namespace System.Data
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents the method that will handle the StateChange event.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public delegate void StateChangeEventHandler(object sender, StateChangeEventArgs e);
|
||||
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
//
|
||||
// System.Data.StatementType.cs
|
||||
//
|
||||
// Author:
|
||||
// Christopher Podurgiel ([email protected])
|
||||
//
|
||||
// (C) Chris Podurgiel
|
||||
//
|
||||
|
||||
using System;
|
||||
|
||||
namespace mono.System.Data
|
||||
{
|
||||
/// <summary>
|
||||
/// Specifies the type of SQL query to be used by the OleDbRowUpdatedEventArgs, OleDbRowUpdatingEventArgs, SqlRowUpdatedEventArgs, or SqlRowUpdatingEventArgs class.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public enum StatementType
|
||||
{
|
||||
Select = 0,
|
||||
Insert = 1,
|
||||
Update = 2,
|
||||
Delete = 3
|
||||
}
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
//
|
||||
// System.Data.UpdateRowSource.cs
|
||||
//
|
||||
// Author:
|
||||
// Christopher Podurgiel ([email protected])
|
||||
//
|
||||
// (C) Chris Podurgiel
|
||||
//
|
||||
|
||||
using System;
|
||||
|
||||
namespace mono.System.Data
|
||||
{
|
||||
/// <summary>
|
||||
/// Specifies how query command results are applied to the row being updated.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public enum UpdateRowSource
|
||||
{
|
||||
None = 0,
|
||||
OutputParameters = 1,
|
||||
FirstReturnedRecord = 2,
|
||||
Both = 3
|
||||
}
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
//
|
||||
// System.Data.UpdateStatus.cs
|
||||
//
|
||||
// Author:
|
||||
// Christopher Podurgiel ([email protected])
|
||||
//
|
||||
// (C) Chris Podurgiel
|
||||
//
|
||||
|
||||
using System;
|
||||
|
||||
namespace mono.System.Data
|
||||
{
|
||||
/// <summary>
|
||||
/// Specifies the action to take with regard to the current and remaining rows during an Update.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public enum UpdateStatus
|
||||
{
|
||||
Continue = 0,
|
||||
ErrorsOccurred = 1,
|
||||
SkipCurrentRow = 2,
|
||||
SkipAllRemainingRows = 3
|
||||
}
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
//
|
||||
// System.Data.XmlReadMode.cs
|
||||
//
|
||||
// Author:
|
||||
// Christopher Podurgiel ([email protected])
|
||||
//
|
||||
// (C) Chris Podurgiel
|
||||
//
|
||||
|
||||
using System;
|
||||
|
||||
namespace mono.System.Data
|
||||
{
|
||||
/// <summary>
|
||||
/// Specifies how to read XML data and a relational schema into a DataSet.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public enum XmlReadMode
|
||||
{
|
||||
Auto = 0,
|
||||
ReadSchema = 1,
|
||||
IgnoreSchema = 2,
|
||||
InferSchema = 3,
|
||||
DiffGram = 4,
|
||||
Fragment = 5
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
//
|
||||
// System.Data.XmlWriteMode.cs
|
||||
//
|
||||
// Author:
|
||||
// Christopher Podurgiel ([email protected])
|
||||
//
|
||||
// (C) Chris Podurgiel
|
||||
//
|
||||
|
||||
using System;
|
||||
|
||||
namespace mono.System.Data
|
||||
{
|
||||
/// <summary>
|
||||
/// Use the members of this enumeration when setting the WriteMode parameter of the WriteXml method.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public enum XmlWriteMode
|
||||
{
|
||||
WriteSchema = 0,
|
||||
IgnoreSchema = 1,
|
||||
DiffGram = 2
|
||||
}
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
2002-01-06 Ravi Pratap <[email protected]>
|
||||
|
||||
* ChangeLog : Add.
|
||||
|
||||
* Matrix.cs : MonoTODO everywhere.
|
||||
|
||||
* TODOAttribute.cs : Add here too.
|
||||
@@ -1,258 +0,0 @@
|
||||
//
|
||||
// System.Drawing.Drawing2D.Matrix.cs
|
||||
//
|
||||
// Author:
|
||||
// Stefan Maierhofer <[email protected]>
|
||||
//
|
||||
// (C) Ximian, Inc. http://www.ximian.com
|
||||
//
|
||||
|
||||
namespace System.Drawing.Drawing2D
|
||||
{
|
||||
|
||||
public enum CombineMode
|
||||
{
|
||||
Complement,
|
||||
Exclude,
|
||||
Intersect,
|
||||
Replace,
|
||||
Union,
|
||||
Xor
|
||||
}
|
||||
|
||||
public enum CompositingMode
|
||||
{
|
||||
SourceCopy,
|
||||
SourceOver
|
||||
}
|
||||
|
||||
public enum CompositingQuality
|
||||
{
|
||||
AssumeLinear,
|
||||
Default,
|
||||
GammaCorrected,
|
||||
HighQuality,
|
||||
HighSpeed,
|
||||
Invalid
|
||||
}
|
||||
|
||||
public enum CoordinateSpace
|
||||
{
|
||||
Device,
|
||||
Page,
|
||||
World
|
||||
}
|
||||
|
||||
public enum DashCap
|
||||
{
|
||||
Flat,
|
||||
Round,
|
||||
Triangle
|
||||
}
|
||||
|
||||
public enum DashStyle
|
||||
{
|
||||
Custom,
|
||||
Dash,
|
||||
DashDot,
|
||||
DashDotDot,
|
||||
Dot,
|
||||
Solid
|
||||
}
|
||||
|
||||
public enum FillMode
|
||||
{
|
||||
Alternate,
|
||||
Winding
|
||||
}
|
||||
|
||||
public enum FlushIntention
|
||||
{
|
||||
Flush,
|
||||
Sync
|
||||
}
|
||||
|
||||
public enum HatchStyle
|
||||
{
|
||||
BackwardDiagonal,
|
||||
Cross,
|
||||
DarkDownwardDiagonal,
|
||||
DarkHorizontal,
|
||||
DarkUpwardDiagonal,
|
||||
DarkVertical,
|
||||
DashedDownwardDiagonal,
|
||||
DashedHorizontal,
|
||||
DashedUpwardDiagonal,
|
||||
DashedVertical,
|
||||
DiagonalBrick,
|
||||
DiagonalCross,
|
||||
Divot,
|
||||
DottedDiamond,
|
||||
DottedGrid,
|
||||
ForwardDiagonal,
|
||||
Horizontal,
|
||||
HorizontalBrick,
|
||||
LargeCheckerBoard,
|
||||
LargeConfetti,
|
||||
LargeGrid,
|
||||
LightDownwardDiagonal,
|
||||
LightHorizontal,
|
||||
LightUpwardDiagonal,
|
||||
LightVertical,
|
||||
Max,
|
||||
Min,
|
||||
NarrowHorizontal,
|
||||
NarrowVertical,
|
||||
OutlinedDiamond,
|
||||
Percent05,
|
||||
Percent10,
|
||||
Percent20,
|
||||
Percent25,
|
||||
Percent30,
|
||||
Percent40,
|
||||
Percent50,
|
||||
Percent60,
|
||||
Percent70,
|
||||
Percent75,
|
||||
Percent80,
|
||||
Percent90,
|
||||
Plaid,
|
||||
Shingle,
|
||||
SmallCheckerBoard,
|
||||
SmallConfetti,
|
||||
SmallGrid,
|
||||
SolidDiamond,
|
||||
Sphere,
|
||||
Trellis,
|
||||
Vertical,
|
||||
Wave,
|
||||
Weave,
|
||||
WideDownwardDiagonal,
|
||||
WideUpwardDiagonal,
|
||||
ZigZag
|
||||
}
|
||||
|
||||
public enum InterpolationMode
|
||||
{
|
||||
Bicubic,
|
||||
Bilinear,
|
||||
Default,
|
||||
High,
|
||||
HighQualityBicubic,
|
||||
HighQualityBilinear,
|
||||
Invalid,
|
||||
Low,
|
||||
NearestNeighbour
|
||||
}
|
||||
|
||||
public enum LinearGradientMode
|
||||
{
|
||||
BackwardDiagonal,
|
||||
ForwardDiagonal,
|
||||
Horizontal,
|
||||
Vertical
|
||||
}
|
||||
|
||||
public enum LineCap
|
||||
{
|
||||
AnchorMask,
|
||||
ArrowAnchor,
|
||||
Custom,
|
||||
DiamondAnchor,
|
||||
Flat,
|
||||
NoAnchor,
|
||||
Round,
|
||||
RoundAnchor,
|
||||
Square,
|
||||
SquareAnchor,
|
||||
Triangle
|
||||
}
|
||||
|
||||
public enum LineJoin
|
||||
{
|
||||
Bevel,
|
||||
Miter,
|
||||
MiterClipped,
|
||||
Round
|
||||
}
|
||||
|
||||
public enum MatrixOrder
|
||||
{
|
||||
Append,
|
||||
Prepend
|
||||
}
|
||||
|
||||
public enum PathPointType
|
||||
{
|
||||
Bezier,
|
||||
Bezier3,
|
||||
CloseSubpath,
|
||||
DashMode,
|
||||
Line,
|
||||
PathMarker,
|
||||
PathTypeMask,
|
||||
Start
|
||||
}
|
||||
|
||||
public enum PenAlignment
|
||||
{
|
||||
Center,
|
||||
Inset,
|
||||
Left,
|
||||
Outset,
|
||||
Right
|
||||
}
|
||||
|
||||
public enum PenType
|
||||
{
|
||||
HatchFill,
|
||||
LinearGradient,
|
||||
PathGradient,
|
||||
SolidColor,
|
||||
TextureFill
|
||||
}
|
||||
|
||||
public enum PixelOffsetMode
|
||||
{
|
||||
Default,
|
||||
Half,
|
||||
HighQuality,
|
||||
HighSpeed,
|
||||
Invalid,
|
||||
None
|
||||
}
|
||||
|
||||
public enum QualityMode
|
||||
{
|
||||
Default,
|
||||
Hight,
|
||||
Invalid,
|
||||
Low
|
||||
}
|
||||
|
||||
public enum SmoothingMode
|
||||
{
|
||||
AntiAlias,
|
||||
Default,
|
||||
HighQuality,
|
||||
HighSpeed,
|
||||
Invalid,
|
||||
None
|
||||
}
|
||||
|
||||
public enum WarpMode
|
||||
{
|
||||
Bilinear,
|
||||
Perspective
|
||||
}
|
||||
|
||||
public enum WrapMode
|
||||
{
|
||||
Clamp,
|
||||
Tile,
|
||||
TileFlipX,
|
||||
TileFlipXY,
|
||||
TileFlipY
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,453 +0,0 @@
|
||||
//
|
||||
// System.Drawing.Drawing2D.Matrix.cs
|
||||
//
|
||||
// Author:
|
||||
// Stefan Maierhofer <[email protected]>
|
||||
//
|
||||
// (C) Ximian, Inc. http://www.ximian.com
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace System.Drawing.Drawing2D
|
||||
{
|
||||
public sealed class Matrix : MarshalByRefObject, IDisposable
|
||||
{
|
||||
// initialize to identity
|
||||
private float[] m = {1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f};
|
||||
|
||||
// constructors
|
||||
public Matrix() { }
|
||||
|
||||
/* TODO: depends on System.Drawing.Drawing2D.Rectangle
|
||||
public Matrix(Rectangle rect , Point[] plgpts)
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
*/
|
||||
|
||||
/* TODO: depends on System.Drawing.Drawing2D.RectangleF
|
||||
public Matrix(RectangleF rect , PointF[] pa)
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
*/
|
||||
public Matrix(float m11, float m12,
|
||||
float m21, float m22,
|
||||
float dx, float dy)
|
||||
{
|
||||
m[0] = m11; m[1] = m12;
|
||||
m[2] = m21; m[3] = m22;
|
||||
m[4] = dx; m[5] = dy;
|
||||
}
|
||||
|
||||
// properties
|
||||
public float[] Elements
|
||||
{
|
||||
get { return m; }
|
||||
}
|
||||
|
||||
public bool IsIdentity
|
||||
{
|
||||
get
|
||||
{
|
||||
if ( (m[0] == 1.0f) && (m[1] == 0.0f) &&
|
||||
(m[2] == 0.0f) && (m[3] == 1.0f) &&
|
||||
(m[4] == 0.0f) && (m[5] == 0.0f) )
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsInvertible
|
||||
{
|
||||
get
|
||||
{
|
||||
// matrix M is invertible if det(M) != 0
|
||||
float det = m[0] * m[3] - m[2] * m[1];
|
||||
if (det != 0.0f) return true;
|
||||
else return false;
|
||||
}
|
||||
}
|
||||
|
||||
public float OffsetX
|
||||
{
|
||||
get { return m[4]; }
|
||||
}
|
||||
|
||||
public float OffsetY
|
||||
{
|
||||
get { return m[5]; }
|
||||
}
|
||||
|
||||
// methods
|
||||
public Matrix Clone()
|
||||
{
|
||||
return new Matrix(m[0], m[1], m[2], m[3], m[4], m[5]);
|
||||
}
|
||||
|
||||
public void Dispose() { }
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (obj is Matrix)
|
||||
{
|
||||
float[] a = ((Matrix)obj).Elements;
|
||||
if ( m[0] == a[0] && m[1] == a[1] &&
|
||||
m[2] == a[2] && m[3] == a[3] &&
|
||||
m[4] == a[4] && m[5] == a[5] )
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
~Matrix() {}
|
||||
|
||||
[StructLayout(LayoutKind.Explicit)]
|
||||
internal struct BitConverter
|
||||
{
|
||||
[FieldOffset(0)] public float f;
|
||||
[FieldOffset(0)] public int i;
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
BitConverter b;
|
||||
// compiler is not smart
|
||||
b.i = 0;
|
||||
int h = 0;
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
b.f = m[i];
|
||||
h ^= b.i >> i;
|
||||
}
|
||||
return h;
|
||||
}
|
||||
|
||||
public void Invert()
|
||||
{
|
||||
float det = m[0] * m[3] - m[2] * m[1];
|
||||
if (det != 0.0f) // if invertible
|
||||
{
|
||||
float[] r =
|
||||
{
|
||||
m[3] / det,
|
||||
-m[1] / det,
|
||||
-m[2] / det,
|
||||
m[0] / det,
|
||||
(-m[3] * m[4] + m[1] * m[5]) / det,
|
||||
(m[2] * m[4] - m[0] * m[5]) / det
|
||||
};
|
||||
m = r;
|
||||
}
|
||||
}
|
||||
|
||||
public void Multiply(Matrix matrix)
|
||||
{
|
||||
Multiply(matrix, MatrixOrder.Prepend);
|
||||
}
|
||||
|
||||
public void Multiply(Matrix matrix, MatrixOrder order)
|
||||
{
|
||||
switch (order)
|
||||
{
|
||||
case MatrixOrder.Prepend:
|
||||
// this = matrix * this
|
||||
float[] p = matrix.Elements;
|
||||
float[] r0 =
|
||||
{
|
||||
p[0] * m[0] + p[1] * m[2],
|
||||
p[0] * m[1] + p[1] * m[3],
|
||||
p[2] * m[0] + p[3] * m[2],
|
||||
p[2] * m[1] + p[3] * m[3],
|
||||
p[4] * m[0] + p[5] * m[2] + m[4],
|
||||
p[4] * m[1] + p[5] * m[3] + m[5]
|
||||
};
|
||||
m = r0;
|
||||
break;
|
||||
case MatrixOrder.Append:
|
||||
// this = this * matrix
|
||||
float[] a = matrix.Elements;
|
||||
float[] r1 =
|
||||
{
|
||||
m[0] * a[0] + m[1] * a[2],
|
||||
m[0] * a[1] + m[1] * a[3],
|
||||
m[2] * a[0] + m[3] * a[2],
|
||||
m[2] * a[1] + m[3] * a[3],
|
||||
m[4] * a[0] + m[5] * a[2] + a[4],
|
||||
m[4] * a[1] + m[5] * a[3] + a[5]
|
||||
};
|
||||
m = r1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
m[0] = 1.0f; m[1] = 0.0f;
|
||||
m[2] = 0.0f; m[3] = 1.0f;
|
||||
m[4] = 0.0f; m[5] = 0.0f;
|
||||
}
|
||||
|
||||
public void Rotate(float angle)
|
||||
{
|
||||
Rotate(angle, MatrixOrder.Prepend);
|
||||
}
|
||||
|
||||
public void Rotate(float angle, MatrixOrder order)
|
||||
{
|
||||
angle *= (float)(Math.PI / 180.0); // degrees to randians
|
||||
float cos = (float)Math.Cos(angle);
|
||||
float sin = (float)Math.Sin(angle);
|
||||
switch (order)
|
||||
{
|
||||
case MatrixOrder.Prepend:
|
||||
// this = rotation * this
|
||||
float[] r0 =
|
||||
{
|
||||
cos * m[0] + sin * m[2],
|
||||
cos * m[1] + sin * m[3],
|
||||
-sin * m[0] + cos * m[2],
|
||||
-sin * m[1] + cos * m[3],
|
||||
m[4],
|
||||
m[5]
|
||||
};
|
||||
m = r0;
|
||||
break;
|
||||
case MatrixOrder.Append:
|
||||
// this = this * rotation
|
||||
float[] r1 =
|
||||
{
|
||||
m[0] * cos + m[1] * -sin,
|
||||
m[0] * sin + m[1] * cos,
|
||||
m[2] * cos + m[3] * -sin,
|
||||
m[2] * sin + m[3] * cos,
|
||||
m[4] * cos + m[5] * -sin,
|
||||
m[4] * sin + m[5] * cos
|
||||
};
|
||||
m = r1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void RotateAt(float angle, PointF point)
|
||||
{
|
||||
RotateAt(angle, point, MatrixOrder.Prepend);
|
||||
}
|
||||
|
||||
public void RotateAt(float angle, PointF point, MatrixOrder order)
|
||||
{
|
||||
angle *= (float)(Math.PI / 180.0); // degrees to randians
|
||||
float cos = (float)Math.Cos(angle);
|
||||
float sin = (float)Math.Sin(angle);
|
||||
float e4 = -point.X * cos + point.Y * sin + point.X;
|
||||
float e5 = -point.X * sin - point.Y * cos + point.Y;
|
||||
switch (order)
|
||||
{
|
||||
case MatrixOrder.Prepend:
|
||||
// this = rotation * this
|
||||
float[] r0 =
|
||||
{
|
||||
cos * m[0] + sin * m[2],
|
||||
cos * m[1] + sin * m[3],
|
||||
-sin * m[0] + cos * m[2],
|
||||
-sin * m[1] + cos * m[3],
|
||||
e4 * m[0] + e5 * m[2] + m[4],
|
||||
e4 * m[1] + e5 * m[3] + m[5]
|
||||
};
|
||||
m = r0;
|
||||
break;
|
||||
case MatrixOrder.Append:
|
||||
// this = this * rotation
|
||||
float[] r1 =
|
||||
{
|
||||
m[0] * cos + m[1] * -sin,
|
||||
m[0] * sin + m[1] * cos,
|
||||
m[2] * cos + m[3] * -sin,
|
||||
m[2] * sin + m[3] * cos,
|
||||
m[4] * cos + m[5] * -sin + e4,
|
||||
m[4] * sin + m[5] * cos + e5
|
||||
};
|
||||
m = r1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void Scale(float scaleX, float scaleY)
|
||||
{
|
||||
Scale(scaleX, scaleY, MatrixOrder.Prepend);
|
||||
}
|
||||
|
||||
public void Scale(float scaleX, float scaleY, MatrixOrder order)
|
||||
{
|
||||
switch (order)
|
||||
{
|
||||
case MatrixOrder.Prepend:
|
||||
// this = scale * this
|
||||
m[0] *= scaleX; m[1] *= scaleX;
|
||||
m[2] *= scaleY; m[3] *= scaleY;
|
||||
break;
|
||||
case MatrixOrder.Append:
|
||||
// this = this * scale
|
||||
m[0] *= scaleX; m[1] *= scaleY;
|
||||
m[2] *= scaleX; m[3] *= scaleY;
|
||||
m[4] *= scaleX; m[5] *= scaleY;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void Shear(float shearX, float shearY)
|
||||
{
|
||||
Shear(shearX, shearY, MatrixOrder.Prepend);
|
||||
}
|
||||
|
||||
// LAMESPEC: quote from beta 2 sdk docs: "[To be supplied!]"
|
||||
//
|
||||
// assuming transformation matrix:
|
||||
//
|
||||
// (1 shearY 0)
|
||||
// (shearX 1 0)
|
||||
// (0 0 1)
|
||||
//
|
||||
public void Shear(float shearX, float shearY, MatrixOrder order)
|
||||
{
|
||||
switch (order)
|
||||
{
|
||||
case MatrixOrder.Prepend:
|
||||
// this = shear * this
|
||||
float[] r0 =
|
||||
{
|
||||
m[0] + shearY * m[2],
|
||||
m[1] + shearY * m[3],
|
||||
shearX * m[0] + m[2],
|
||||
shearX * m[1] + m[3],
|
||||
m[4],
|
||||
m[5]
|
||||
};
|
||||
m = r0;
|
||||
break;
|
||||
case MatrixOrder.Append:
|
||||
// this = this * shear
|
||||
float[] r1 =
|
||||
{
|
||||
m[0] + m[1] * shearX,
|
||||
m[0] * shearY + m[1],
|
||||
m[2] + m[3] * shearX,
|
||||
m[2] * shearY + m[3],
|
||||
m[4] + m[5] * shearX ,
|
||||
m[4] * shearY + m[5]
|
||||
};
|
||||
m = r1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void TransformPoints(Point[] pts)
|
||||
{
|
||||
for (int i = 0; i < pts.Length; i++)
|
||||
{
|
||||
float x = (float)pts[i].X;
|
||||
float y = (float)pts[i].Y;
|
||||
pts[i].X = (int)(x * m[0] + y * m[2] + m[4]);
|
||||
pts[i].Y = (int)(x * m[1] + y * m[3] + m[5]);
|
||||
}
|
||||
}
|
||||
|
||||
public void TransformPoints(PointF[] pts)
|
||||
{
|
||||
for (int i = 0; i < pts.Length; i++)
|
||||
{
|
||||
float x = pts[i].X;
|
||||
float y = pts[i].Y;
|
||||
pts[i].X = x * m[0] + y * m[2] + m[4];
|
||||
pts[i].Y = x * m[1] + y * m[3] + m[5];
|
||||
}
|
||||
}
|
||||
|
||||
public void TransformVectors(Point[] pts)
|
||||
{
|
||||
for (int i = 0; i < pts.Length; i++)
|
||||
{
|
||||
float x = (float)pts[i].X;
|
||||
float y = (float)pts[i].Y;
|
||||
pts[i].X = (int)(x * m[0] + y * m[2]);
|
||||
pts[i].Y = (int)(x * m[1] + y * m[3]);
|
||||
}
|
||||
}
|
||||
|
||||
public void TransformVectors(PointF[] pts)
|
||||
{
|
||||
for (int i = 0; i < pts.Length; i++)
|
||||
{
|
||||
float x = pts[i].X;
|
||||
float y = pts[i].Y;
|
||||
pts[i].X = x * m[0] + y * m[2];
|
||||
pts[i].Y = x * m[1] + y * m[3];
|
||||
}
|
||||
}
|
||||
|
||||
public void Translate(float offsetX, float offsetY)
|
||||
{
|
||||
Translate(offsetX, offsetY, MatrixOrder.Prepend);
|
||||
}
|
||||
|
||||
public void Translate(float offsetX, float offsetY, MatrixOrder order)
|
||||
{
|
||||
switch (order)
|
||||
{
|
||||
case MatrixOrder.Prepend:
|
||||
// this = translation * this
|
||||
m[4] = offsetX * m[0] + offsetY * m[2] + m[4];
|
||||
m[5] = offsetX * m[1] + offsetY * m[3] + m[5];
|
||||
break;
|
||||
case MatrixOrder.Append:
|
||||
// this = this * translation
|
||||
m[4] += offsetX;
|
||||
m[5] += offsetY;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// LAMESPEC: quote from beta 2 sdk docs: "[To be supplied!]"
|
||||
[MonoTODO]
|
||||
public void VectorTransformPoints(Point[] pts)
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
// some simple test (TODO: remove)
|
||||
/*
|
||||
public static void Main()
|
||||
{
|
||||
PointF[] p = {new PointF(1.0f, 2.0f)};
|
||||
Console.WriteLine("(" + p[0].X + " " + p[0].Y + ")");
|
||||
Matrix m = new Matrix();
|
||||
|
||||
m.Translate(1.0f, 1.0f);
|
||||
m.Scale(2.0f, 2.0f);
|
||||
m.Rotate(180.0f);
|
||||
|
||||
m.TransformPoints(p);
|
||||
Console.WriteLine("(" + p[0].X + " " + p[0].Y + ")");
|
||||
m.Invert();
|
||||
m.TransformPoints(p);
|
||||
Console.WriteLine("(" + p[0].X + " " + p[0].Y + ")");
|
||||
|
||||
Matrix a = new Matrix(1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f);
|
||||
Matrix b = new Matrix(2.0f, 0.0f, 0.0f, 2.0f, 0.0f, 0.0f);
|
||||
|
||||
Console.WriteLine("h(a) = " + a.GetHashCode());
|
||||
Console.WriteLine("h(b) = " + b.GetHashCode());
|
||||
}
|
||||
*/
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
//
|
||||
// System.Drawing.Drawing2D.PenAlignment.cs
|
||||
//
|
||||
// Author:
|
||||
// Miguel de Icaza ([email protected])
|
||||
//
|
||||
// (C) Ximian, Inc. http://www.ximian.com
|
||||
//
|
||||
|
||||
using System;
|
||||
|
||||
namespace System.Drawing {
|
||||
|
||||
public enum PenAlignment {
|
||||
Center = 0,
|
||||
Inset = 1,
|
||||
Outset = 2,
|
||||
Left = 3,
|
||||
Right =4
|
||||
}
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
//
|
||||
// TODOAttribute.cs
|
||||
//
|
||||
// Author:
|
||||
// Ravi Pratap ([email protected])
|
||||
//
|
||||
// (C) Ximian, Inc. http://www.ximian.com
|
||||
//
|
||||
|
||||
namespace System {
|
||||
|
||||
/// <summary>
|
||||
/// The TODO attribute is used to flag all incomplete bits in our class libraries
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// Use this to decorate any element which you think is not complete
|
||||
/// </remarks>
|
||||
[AttributeUsage (AttributeTargets.All, AllowMultiple=true)]
|
||||
public class MonoTODOAttribute : Attribute {
|
||||
|
||||
private string comment;
|
||||
|
||||
public MonoTODOAttribute ()
|
||||
{}
|
||||
|
||||
public MonoTODOAttribute (string comment)
|
||||
{
|
||||
this.comment = comment;
|
||||
}
|
||||
|
||||
public string Comment
|
||||
{
|
||||
get { return comment; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,59 +0,0 @@
|
||||
// created on 21.02.2002 at 17:06
|
||||
//
|
||||
// FrameDimension.cs
|
||||
//
|
||||
// Author: Christian Meyer
|
||||
// eMail: [email protected]
|
||||
//
|
||||
|
||||
namespace System.Drawing.Imaging {
|
||||
|
||||
using System;
|
||||
|
||||
public sealed class FrameDimension {
|
||||
|
||||
// constructor
|
||||
public FrameDimension (Guid guid) {}
|
||||
|
||||
//properties
|
||||
public Guid Guid {
|
||||
get {
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
}
|
||||
|
||||
public static FrameDimension Page {
|
||||
get {
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
}
|
||||
|
||||
public static FrameDimension Resolution {
|
||||
get {
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
}
|
||||
|
||||
public static FrameDimension Time {
|
||||
get {
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
}
|
||||
|
||||
//methods
|
||||
public override bool Equals (object o) {
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
|
||||
public override int GetHashCode () {
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
|
||||
public override string ToString() {
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
|
||||
//destructor
|
||||
~FrameDimension () {}
|
||||
}
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
// created on 20.02.2002 at 21:18
|
||||
//
|
||||
// Image.cs
|
||||
//
|
||||
// Author: Christian Meyer
|
||||
// eMail: [email protected]
|
||||
//
|
||||
//
|
||||
namespace System.Drawing.Imaging {
|
||||
|
||||
public enum PixelFormat {
|
||||
Alpha,
|
||||
Canonical,
|
||||
DontCare,
|
||||
Extended,
|
||||
Format16bppArgb1555,
|
||||
Format16bppGrayScale,
|
||||
Format16bppRgb555,
|
||||
Format16bppRgb565,
|
||||
Format1bppIndexed,
|
||||
Format24bppRgb,
|
||||
Format32bppArgb,
|
||||
Format32bppPArgb,
|
||||
Format32bppRgb,
|
||||
Format48bppRgb,
|
||||
Format4bppIndexed,
|
||||
Format64bppArgb,
|
||||
Format64bppPArgb,
|
||||
Format8bppIndexed,
|
||||
Gdi,
|
||||
Indexed,
|
||||
Max,
|
||||
PAlpha,
|
||||
Undefined
|
||||
}
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
|
||||
<!-- NAnt build file for SystemDrawing.dll -->
|
||||
|
||||
<project name="System" default="build">
|
||||
<property name="debug" value="false"/>
|
||||
|
||||
<target name="build">
|
||||
<csc target="library" output="../lib/System.Drawing.dll" debug="${debug}">
|
||||
<arg value="/nowarn:1595"/>
|
||||
<arg value="/unsafe"/>
|
||||
<sources>
|
||||
<includes name="**/*.cs"/>
|
||||
<excludes name="Test/**"/>
|
||||
</sources>
|
||||
<references>
|
||||
<includes name="../lib/corlib.dll"/>
|
||||
</references>
|
||||
</csc>
|
||||
</target>
|
||||
</project>
|
||||
@@ -1,146 +0,0 @@
|
||||
// created on 25.02.2002 at 22:43
|
||||
//
|
||||
// Bitmap.cs
|
||||
//
|
||||
// Author: Christian Meyer
|
||||
// eMail: [email protected]
|
||||
//
|
||||
// No implementation has been done yet. I first want to write the method
|
||||
// headers of every System.Drawing.
|
||||
//
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Imaging;
|
||||
|
||||
namespace System.Drawing {
|
||||
|
||||
public sealed class Bitmap : Image {
|
||||
|
||||
// constructors
|
||||
public Bitmap (Image origial) {
|
||||
this.original = original;
|
||||
}
|
||||
|
||||
/* public Bitmap (Stream stream) {
|
||||
this.stream = stream;
|
||||
}
|
||||
*/
|
||||
public Bitmap (string filename) {
|
||||
this.filename = filename;
|
||||
}
|
||||
|
||||
public Bitmap (Image original, Size newSize) {
|
||||
this.original = original;
|
||||
this.newSize = newSize;
|
||||
}
|
||||
|
||||
public Bitmap (int width, int heigth) {
|
||||
this.width = width;
|
||||
this.heigth = heigth;
|
||||
}
|
||||
|
||||
/* public Bitmap (Stream stream, bool useIcm) {
|
||||
this.stream = stream;
|
||||
this.useIcm = useIcm;
|
||||
}
|
||||
*/
|
||||
public Bitmap (string filename, bool useIcm) {
|
||||
this.filename = filename;
|
||||
this.useIcm = useIcm;
|
||||
}
|
||||
|
||||
public Bitmap (Type type, string resource) {
|
||||
this.type = type;
|
||||
this.resource = resource;
|
||||
}
|
||||
|
||||
public Bitmap (Image original, int width, int heigth) {
|
||||
this.original = original;
|
||||
this.width = width;
|
||||
this.heigth = heigth;
|
||||
}
|
||||
|
||||
public Bitmap (int width, int heigth, Graphics g) {
|
||||
this.width = width;
|
||||
this.heigth = heigth;
|
||||
this.g = g;
|
||||
}
|
||||
/*
|
||||
public Bitmap (int width, int heigth, PixelFormat format) {
|
||||
this.width = width;
|
||||
this.heigth = heigth;
|
||||
this.format = format;
|
||||
}
|
||||
|
||||
public Bitmap (int width, int height, int stride,
|
||||
PixelFormat format, IntPtr scan0) {
|
||||
this.width = width;
|
||||
this.heigth = heigth;
|
||||
this.stride = stride;
|
||||
this.format = format;
|
||||
this.scan0 = scan0;
|
||||
}
|
||||
|
||||
// methods
|
||||
public Bitmap Clone (Rectangle rect,PixelFormat format) {
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
|
||||
public Bitmap Clone (RectangleF rect, PixelFormat format) {
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
*/
|
||||
public static Bitmap FromHicon (IntPtr hicon) {
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
|
||||
public static Bitmap FromResource (IntPtr hinstance,
|
||||
string bitmapName) {
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
|
||||
public IntPtr GetHbitmap () {
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
|
||||
public IntPtr GetHbitmap (Color background) {
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
|
||||
public IntPtr GetHicon () {
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
|
||||
public Color GetPixel (int x, int y) {
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
|
||||
/* public BitmapData LockBits (Rectangle rect, ImageLockMode flags,
|
||||
PixelFormat format) {
|
||||
throw new NotImplementedException ();
|
||||
} */
|
||||
|
||||
public void MakeTransparent () {
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
|
||||
public void MakeTransparent (Color transparentColor) {
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
|
||||
public void SetPixel (int x, int y, Color color) {
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
|
||||
public void SetResolution (float xDpi, float yDpi) {
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
|
||||
/* public void UnlockBits (BitmapData bitmapdata) {
|
||||
throw new NotImplementedException ();
|
||||
} */
|
||||
|
||||
// properties
|
||||
// needs to be done ###FIXME###
|
||||
}
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
//
|
||||
// System.Drawing.Brush.cs
|
||||
//
|
||||
// Author:
|
||||
// Miguel de Icaza ([email protected])
|
||||
//
|
||||
// (C) Ximian, Inc. http://www.ximian.com
|
||||
//
|
||||
|
||||
using System;
|
||||
|
||||
namespace System.Drawing {
|
||||
|
||||
public abstract class Brush : MarshalByRefObject, ICloneable, IDisposable {
|
||||
|
||||
abstract public object Clone ();
|
||||
|
||||
public void Dispose ()
|
||||
{
|
||||
Dispose (true);
|
||||
System.GC.SuppressFinalize (this);
|
||||
}
|
||||
|
||||
void Dispose (bool disposing)
|
||||
{
|
||||
// Nothing for now.
|
||||
}
|
||||
|
||||
~Brush ()
|
||||
{
|
||||
Dispose (false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
2002-02-26 Christian Meyer <[email protected]>
|
||||
|
||||
* Bitmap.cs: Added method headers.
|
||||
|
||||
2002-02-25 Christian Meyer <[email protected]>
|
||||
|
||||
* Bitmap.cs: Added, no implementation's done, yet.
|
||||
|
||||
2001-12-15 Mike Kestner <[email protected]>
|
||||
|
||||
* Rectangle.cs : Add a doc comment.
|
||||
* RectangleF.cs : New struct implementation.
|
||||
|
||||
2001-12-15 Mike Kestner <[email protected]>
|
||||
|
||||
* Rectangle.cs : New struct implementation.
|
||||
|
||||
2001-08-17 Mike Kestner <[email protected]>
|
||||
|
||||
* PointF.cs, Size.cs, SizeF.cs : New struct implementations.
|
||||
|
||||
2001-08-16 Mike Kestner <[email protected]>
|
||||
|
||||
* Point.cs : New. Implementation of System.Drawing.Point struct.
|
||||
|
||||
@@ -1,217 +0,0 @@
|
||||
// created on 20.02.2002 at 21:18
|
||||
//
|
||||
// Image.cs
|
||||
//
|
||||
// Author: Christian Meyer
|
||||
// eMail: [email protected]
|
||||
//
|
||||
// Many methods are still commented. I'll care about them when all necessary
|
||||
// classes are implemented.
|
||||
//
|
||||
namespace System.Drawing {
|
||||
|
||||
using System;
|
||||
using System.Runtime.Remoting;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Drawing.Imaging;
|
||||
|
||||
//[Serializable]
|
||||
//[ComVisible(true)]
|
||||
|
||||
public abstract class Image : MarshalByRefObject, ICloneable, IDisposable /*, ISerializable */ {
|
||||
|
||||
// constructor
|
||||
public Image () {}
|
||||
|
||||
// public methods
|
||||
// static
|
||||
public static Image FromFile (string filename)
|
||||
{
|
||||
// Fixme: implement me
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
|
||||
public static Image FromFile (string filename, bool useEmbeddedColorManagement)
|
||||
{
|
||||
// Fixme: implement me
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
|
||||
public static Bitmap FromHbitmap (IntPtr hbitmap)
|
||||
{
|
||||
// Fixme: implement me
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
|
||||
public static Bitmap FromHbitmap (IntPtr hbitmap, IntPtr hpalette)
|
||||
{
|
||||
// Fixme: implement me
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
|
||||
public static int GetPixelFormatSize (PixelFormat pixfmt)
|
||||
{
|
||||
// Fixme: implement me
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
|
||||
public static bool IsAlphaPixelFormat (PixelFormat pixfmt)
|
||||
{
|
||||
// Fixme: implement me
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
|
||||
public static bool IsCanonicalPixelFormat (PixelFormat pixfmt)
|
||||
{
|
||||
// Fixme: implement me
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
|
||||
public static bool IsExtendedPixelFormat (PixelFormat pixfmt)
|
||||
{
|
||||
// Fixme: implement me
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
|
||||
// non-static
|
||||
public object Clone ()
|
||||
{
|
||||
// Fixme: implement me
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
|
||||
public void Dispose ()
|
||||
{
|
||||
// Fixme: implement me
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
|
||||
protected virtual void Dispose (bool disposing)
|
||||
{
|
||||
// Fixme: implement me
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
|
||||
public RectangleF GetBounds (ref GraphicsUnit pageUnit)
|
||||
{
|
||||
// Fixme: implement me
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
|
||||
//public EncoderParameters GetEncoderParameterList(Guid encoder);
|
||||
//public int GetFrameCount(FrameDimension dimension);
|
||||
//public PropertyItem GetPropertyItem(int propid);
|
||||
/*
|
||||
public Image GetThumbnailImage(int thumbWidth, int thumbHeight,
|
||||
Image.GetThumbnailImageAbort callback,
|
||||
IntPtr callbackData);
|
||||
*/
|
||||
|
||||
public void RemovePropertyItem (int propid)
|
||||
{
|
||||
// Fixme: implement me
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
|
||||
public void RotateFlip (RotateFlipType rotateFlipType)
|
||||
{
|
||||
// Fixme: implement me
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
|
||||
public void Save (string filename)
|
||||
{
|
||||
// Fixme: implement me
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
|
||||
//public void Save(Stream stream, ImageFormat format);
|
||||
//public void Save(string filename, ImageFormat format);
|
||||
//public void Save(Stream stream, ImageCodecInfo encoder,
|
||||
// EncoderParameters encoderParams);
|
||||
//public void Save(string filename, ImageCodecInfo encoder,
|
||||
// EncoderParameters encoderParams);
|
||||
//public void SaveAdd(EncoderParameters_ encoderParams);
|
||||
//public void SaveAdd(Image image, EncoderParameters_ encoderParams);
|
||||
//public int SelectActiveFrame(FrameDimension dimension, int frameIndex);
|
||||
//public void SetPropertyItem(PropertyItem propitem);
|
||||
|
||||
// destructor
|
||||
~Image() {}
|
||||
|
||||
// properties
|
||||
public int Flags {
|
||||
get {
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
}
|
||||
|
||||
public Guid[] FrameDimensionsList {
|
||||
get {
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
}
|
||||
|
||||
public int Height {
|
||||
get {
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
}
|
||||
|
||||
public float HorizontalResolution {
|
||||
get {
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
}
|
||||
|
||||
public ColorPalette Palette {
|
||||
get {
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
set {
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
}
|
||||
|
||||
public SizeF PhysicalDimension {
|
||||
get {
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
}
|
||||
|
||||
public PixelFormat PixelFormat {
|
||||
get {
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
}
|
||||
|
||||
public int[] PropertyIdList {
|
||||
get {
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
}
|
||||
|
||||
//public PropertyItem[] PropertyItems {get;}
|
||||
//public ImageFormat RawFormat {get;}
|
||||
|
||||
public Size Size {
|
||||
get {
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
}
|
||||
|
||||
public float VerticalResolution {
|
||||
get {
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
}
|
||||
|
||||
public int Width {
|
||||
get {
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,113 +0,0 @@
|
||||
//
|
||||
// System.Drawing.Pen.cs
|
||||
//
|
||||
// Author:
|
||||
// Miguel de Icaza ([email protected])
|
||||
//
|
||||
// (C) Ximian, Inc. http://www.ximian.com
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.Drawing.Drawing2D;
|
||||
|
||||
namespace System.Drawing {
|
||||
|
||||
public sealed class Pen : MarshalByRefObject, ICloneable, IDisposable {
|
||||
Brush brush;
|
||||
Color color;
|
||||
float width;
|
||||
PenAlignment alignment;
|
||||
|
||||
public Pen (Brush brush)
|
||||
{
|
||||
this.brush = brush;
|
||||
width = 1;
|
||||
}
|
||||
|
||||
public Pen (Color color)
|
||||
{
|
||||
this.color = color;
|
||||
width = 1;
|
||||
}
|
||||
|
||||
public Pen (Brush brush, float width)
|
||||
{
|
||||
this.width = width;
|
||||
this.brush = brush;
|
||||
}
|
||||
|
||||
public Pen (Color color, float width)
|
||||
{
|
||||
this.width = width;
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
//
|
||||
// Properties
|
||||
//
|
||||
public PenAlignment Alignment {
|
||||
get {
|
||||
return alignment;
|
||||
}
|
||||
|
||||
set {
|
||||
alignment = value;
|
||||
}
|
||||
}
|
||||
|
||||
public Brush Brush {
|
||||
get {
|
||||
return brush;
|
||||
}
|
||||
|
||||
set {
|
||||
brush = value;
|
||||
}
|
||||
}
|
||||
|
||||
public Color Color {
|
||||
get {
|
||||
return color;
|
||||
}
|
||||
|
||||
set {
|
||||
color = value;
|
||||
}
|
||||
}
|
||||
|
||||
public float Width {
|
||||
get {
|
||||
return width;
|
||||
}
|
||||
set {
|
||||
width = value;
|
||||
}
|
||||
}
|
||||
|
||||
public object Clone ()
|
||||
{
|
||||
Pen p = new Pen (brush, width);
|
||||
|
||||
p.color = color;
|
||||
p.alignment = alignment;
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
public void Dispose ()
|
||||
{
|
||||
Dispose (true);
|
||||
System.GC.SuppressFinalize (this);
|
||||
}
|
||||
|
||||
void Dispose (bool disposing)
|
||||
{
|
||||
// Nothing for now.
|
||||
}
|
||||
|
||||
~Pen ()
|
||||
{
|
||||
Dispose (false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,339 +0,0 @@
|
||||
//
|
||||
// System.Drawing.Point.cs
|
||||
//
|
||||
// Author:
|
||||
// Mike Kestner ([email protected])
|
||||
//
|
||||
// (C) 2001 Mike Kestner
|
||||
//
|
||||
|
||||
using System;
|
||||
|
||||
namespace System.Drawing {
|
||||
|
||||
public struct Point {
|
||||
|
||||
// Private x and y coordinate fields.
|
||||
int cx, cy;
|
||||
|
||||
// -----------------------
|
||||
// Public Shared Members
|
||||
// -----------------------
|
||||
|
||||
/// <summary>
|
||||
/// Empty Shared Field
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// An uninitialized Point Structure.
|
||||
/// </remarks>
|
||||
|
||||
public static readonly Point Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Ceiling Shared Method
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// Produces a Point structure from a PointF structure by
|
||||
/// taking the ceiling of the X and Y properties.
|
||||
/// </remarks>
|
||||
|
||||
public static Point Ceiling (PointF value)
|
||||
{
|
||||
int x, y;
|
||||
checked {
|
||||
x = (int) Math.Ceiling (value.X);
|
||||
y = (int) Math.Ceiling (value.Y);
|
||||
}
|
||||
|
||||
return new Point (x, y);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Round Shared Method
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// Produces a Point structure from a PointF structure by
|
||||
/// rounding the X and Y properties.
|
||||
/// </remarks>
|
||||
|
||||
public static Point Round (PointF value)
|
||||
{
|
||||
int x, y;
|
||||
checked {
|
||||
x = (int) Math.Round (value.X);
|
||||
y = (int) Math.Round (value.Y);
|
||||
}
|
||||
|
||||
return new Point (x, y);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Truncate Shared Method
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// Produces a Point structure from a PointF structure by
|
||||
/// truncating the X and Y properties.
|
||||
/// </remarks>
|
||||
|
||||
// LAMESPEC: Should this be floor, or a pure cast to int?
|
||||
|
||||
public static Point Truncate (PointF value)
|
||||
{
|
||||
int x, y;
|
||||
checked {
|
||||
x = (int) value.X;
|
||||
y = (int) value.Y;
|
||||
}
|
||||
|
||||
return new Point (x, y);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Addition Operator
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// Translates a Point using the Width and Height
|
||||
/// properties of the given <typeref>Size</typeref>.
|
||||
/// </remarks>
|
||||
|
||||
public static Point operator + (Point pt, Size sz)
|
||||
{
|
||||
return new Point (pt.X + sz.Width, pt.Y + sz.Height);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Equality Operator
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// Compares two Point objects. The return value is
|
||||
/// based on the equivalence of the X and Y properties
|
||||
/// of the two points.
|
||||
/// </remarks>
|
||||
|
||||
public static bool operator == (Point pt_a, Point pt_b)
|
||||
{
|
||||
return ((pt_a.X == pt_b.X) && (pt_a.Y == pt_b.Y));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Inequality Operator
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// Compares two Point objects. The return value is
|
||||
/// based on the equivalence of the X and Y properties
|
||||
/// of the two points.
|
||||
/// </remarks>
|
||||
|
||||
public static bool operator != (Point pt_a, Point pt_b)
|
||||
{
|
||||
return ((pt_a.X != pt_b.X) || (pt_a.Y != pt_b.Y));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Subtraction Operator
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// Translates a Point using the negation of the Width
|
||||
/// and Height properties of the given Size.
|
||||
/// </remarks>
|
||||
|
||||
public static Point operator - (Point pt, Size sz)
|
||||
{
|
||||
return new Point (pt.X - sz.Width, pt.Y - sz.Height);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Point to Size Conversion
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// Returns a Size based on the Coordinates of a given
|
||||
/// Point. Requires explicit cast.
|
||||
/// </remarks>
|
||||
|
||||
public static explicit operator Size (Point pt)
|
||||
{
|
||||
return new Size (pt.X, pt.Y);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Point to PointF Conversion
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// Creates a PointF based on the coordinates of a given
|
||||
/// Point. No explicit cast is required.
|
||||
/// </remarks>
|
||||
|
||||
public static implicit operator PointF (Point pt)
|
||||
{
|
||||
return new PointF (pt.X, pt.Y);
|
||||
}
|
||||
|
||||
|
||||
// -----------------------
|
||||
// Public Constructors
|
||||
// -----------------------
|
||||
|
||||
/// <summary>
|
||||
/// Point Constructor
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// Creates a Point from an integer which holds the X
|
||||
/// coordinate in the high order 16 bits and the Y
|
||||
/// coordinate in the low order 16 bits.
|
||||
/// </remarks>
|
||||
|
||||
public Point (int dw)
|
||||
{
|
||||
cx = dw >> 16;
|
||||
cy = dw & 0xffff;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Point Constructor
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// Creates a Point from a Size value.
|
||||
/// </remarks>
|
||||
|
||||
public Point (Size sz)
|
||||
{
|
||||
cx = sz.Width;
|
||||
cy = sz.Height;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Point Constructor
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// Creates a Point from a specified x,y coordinate pair.
|
||||
/// </remarks>
|
||||
|
||||
public Point (int x, int y)
|
||||
{
|
||||
cx = x;
|
||||
cy = y;
|
||||
}
|
||||
|
||||
// -----------------------
|
||||
// Public Instance Members
|
||||
// -----------------------
|
||||
|
||||
/// <summary>
|
||||
/// IsEmpty Property
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// Indicates if both X and Y are zero.
|
||||
/// </remarks>
|
||||
|
||||
public bool IsEmpty {
|
||||
get {
|
||||
return ((cx == 0) && (cy == 0));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// X Property
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// The X coordinate of the Point.
|
||||
/// </remarks>
|
||||
|
||||
public int X {
|
||||
get {
|
||||
return cx;
|
||||
}
|
||||
set {
|
||||
cx = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Y Property
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// The Y coordinate of the Point.
|
||||
/// </remarks>
|
||||
|
||||
public int Y {
|
||||
get {
|
||||
return cy;
|
||||
}
|
||||
set {
|
||||
cy = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Equals Method
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// Checks equivalence of this Point and another object.
|
||||
/// </remarks>
|
||||
|
||||
public override bool Equals (object o)
|
||||
{
|
||||
if (!(o is Point))
|
||||
return false;
|
||||
|
||||
return (this == (Point) o);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// GetHashCode Method
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// Calculates a hashing value.
|
||||
/// </remarks>
|
||||
|
||||
public override int GetHashCode ()
|
||||
{
|
||||
return cx^cy;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Offset Method
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// Moves the Point a specified distance.
|
||||
/// </remarks>
|
||||
|
||||
public void Offset (int dx, int dy)
|
||||
{
|
||||
cx += dx;
|
||||
cy += dy;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ToString Method
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// Formats the Point as a string in coordinate notation.
|
||||
/// </remarks>
|
||||
|
||||
public override string ToString ()
|
||||
{
|
||||
return String.Format ("[{0},{1}]", cx, cy);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,204 +0,0 @@
|
||||
//
|
||||
// System.Drawing.PointF.cs
|
||||
//
|
||||
// Author:
|
||||
// Mike Kestner ([email protected])
|
||||
//
|
||||
// (C) 2001 Mike Kestner
|
||||
//
|
||||
|
||||
using System;
|
||||
|
||||
namespace System.Drawing {
|
||||
|
||||
public struct PointF {
|
||||
|
||||
// Private x and y coordinate fields.
|
||||
float cx, cy;
|
||||
|
||||
// -----------------------
|
||||
// Public Shared Members
|
||||
// -----------------------
|
||||
|
||||
/// <summary>
|
||||
/// Empty Shared Field
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// An uninitialized PointF Structure.
|
||||
/// </remarks>
|
||||
|
||||
public static readonly PointF Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Addition Operator
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// Translates a PointF using the Width and Height
|
||||
/// properties of the given Size.
|
||||
/// </remarks>
|
||||
|
||||
public static PointF operator + (PointF pt, Size sz)
|
||||
{
|
||||
return new PointF (pt.X + sz.Width, pt.Y + sz.Height);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Equality Operator
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// Compares two PointF objects. The return value is
|
||||
/// based on the equivalence of the X and Y properties
|
||||
/// of the two points.
|
||||
/// </remarks>
|
||||
|
||||
public static bool operator == (PointF pt_a, PointF pt_b)
|
||||
{
|
||||
return ((pt_a.X == pt_b.X) && (pt_a.Y == pt_b.Y));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Inequality Operator
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// Compares two PointF objects. The return value is
|
||||
/// based on the equivalence of the X and Y properties
|
||||
/// of the two points.
|
||||
/// </remarks>
|
||||
|
||||
public static bool operator != (PointF pt_a, PointF pt_b)
|
||||
{
|
||||
return ((pt_a.X != pt_b.X) || (pt_a.Y != pt_b.Y));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Subtraction Operator
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// Translates a PointF using the negation of the Width
|
||||
/// and Height properties of the given Size.
|
||||
/// </remarks>
|
||||
|
||||
public static PointF operator - (PointF pt, Size sz)
|
||||
{
|
||||
return new PointF (pt.X - sz.Width, pt.Y - sz.Height);
|
||||
}
|
||||
|
||||
// -----------------------
|
||||
// Public Constructor
|
||||
// -----------------------
|
||||
|
||||
/// <summary>
|
||||
/// PointF Constructor
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// Creates a PointF from a specified x,y coordinate pair.
|
||||
/// </remarks>
|
||||
|
||||
public PointF (float x, float y)
|
||||
{
|
||||
cx = x;
|
||||
cy = y;
|
||||
}
|
||||
|
||||
// -----------------------
|
||||
// Public Instance Members
|
||||
// -----------------------
|
||||
|
||||
/// <summary>
|
||||
/// IsEmpty Property
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// Indicates if both X and Y are zero.
|
||||
/// </remarks>
|
||||
|
||||
public bool IsEmpty {
|
||||
get {
|
||||
return ((cx == 0.0) && (cy == 0.0));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// X Property
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// The X coordinate of the PointF.
|
||||
/// </remarks>
|
||||
|
||||
public float X {
|
||||
get {
|
||||
return cx;
|
||||
}
|
||||
set {
|
||||
cx = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Y Property
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// The Y coordinate of the PointF.
|
||||
/// </remarks>
|
||||
|
||||
public float Y {
|
||||
get {
|
||||
return cy;
|
||||
}
|
||||
set {
|
||||
cy = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Equals Method
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// Checks equivalence of this PointF and another object.
|
||||
/// </remarks>
|
||||
|
||||
public override bool Equals (object o)
|
||||
{
|
||||
if (!(o is PointF))
|
||||
return false;
|
||||
|
||||
return (this == (PointF) o);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// GetHashCode Method
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// Calculates a hashing value.
|
||||
/// </remarks>
|
||||
|
||||
public override int GetHashCode ()
|
||||
{
|
||||
return (int) cx ^ (int) cy;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ToString Method
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// Formats the PointF as a string in coordinate notation.
|
||||
/// </remarks>
|
||||
|
||||
public override string ToString ()
|
||||
{
|
||||
return String.Format ("[{0},{1}]", cx, cy);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,584 +0,0 @@
|
||||
//
|
||||
// System.Drawing.Rectangle.cs
|
||||
//
|
||||
// Author:
|
||||
// Mike Kestner ([email protected])
|
||||
//
|
||||
// (C) 2001 Mike Kestner
|
||||
//
|
||||
|
||||
using System;
|
||||
|
||||
namespace System.Drawing {
|
||||
|
||||
public struct Rectangle {
|
||||
|
||||
// Private position and size fields.
|
||||
private Point loc;
|
||||
private Size sz;
|
||||
|
||||
/// <summary>
|
||||
/// Empty Shared Field
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// An uninitialized Rectangle Structure.
|
||||
/// </remarks>
|
||||
|
||||
public static readonly Rectangle Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Ceiling Shared Method
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// Produces a Rectangle structure from a RectangleF
|
||||
/// structure by taking the ceiling of the X, Y, Width,
|
||||
/// and Height properties.
|
||||
/// </remarks>
|
||||
|
||||
public static Rectangle Ceiling (RectangleF value)
|
||||
{
|
||||
int x, y, w, h;
|
||||
checked {
|
||||
x = (int) Math.Ceiling (value.X);
|
||||
y = (int) Math.Ceiling (value.Y);
|
||||
w = (int) Math.Ceiling (value.Width);
|
||||
h = (int) Math.Ceiling (value.Height);
|
||||
}
|
||||
|
||||
return new Rectangle (x, y, w, h);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// FromLTRB Shared Method
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// Produces a Rectangle structure from left, top, right,
|
||||
/// and bottom coordinates.
|
||||
/// </remarks>
|
||||
|
||||
public static Rectangle FromLTRB (int left, int top,
|
||||
int right, int bottom)
|
||||
{
|
||||
return new Rectangle (left, top, right - left,
|
||||
bottom - top);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Inflate Shared Method
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// Produces a new Rectangle by inflating an existing
|
||||
/// Rectangle by the specified coordinate values.
|
||||
/// </remarks>
|
||||
|
||||
public static Rectangle Inflate (Rectangle rect, int x, int y)
|
||||
{
|
||||
Rectangle r = new Rectangle (rect.Location, rect.Size);
|
||||
r.Inflate (x, y);
|
||||
return r;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Inflate Method
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// Inflates the Rectangle by a specified width and height.
|
||||
/// </remarks>
|
||||
|
||||
public void Inflate (int width, int height)
|
||||
{
|
||||
Inflate (new Size (width, height));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Inflate Method
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// Inflates the Rectangle by a specified Size.
|
||||
/// </remarks>
|
||||
|
||||
public void Inflate (Size sz)
|
||||
{
|
||||
loc -= sz;
|
||||
Size ds = new Size (sz.Width * 2, sz.Height * 2);
|
||||
this.sz += ds;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Intersect Shared Method
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// Produces a new Rectangle by intersecting 2 existing
|
||||
/// Rectangles. Returns null if there is no intersection.
|
||||
/// </remarks>
|
||||
|
||||
public static Rectangle Intersect (Rectangle r1, Rectangle r2)
|
||||
{
|
||||
Rectangle r = new Rectangle (r1.Location, r1.Size);
|
||||
r.Intersect (r2);
|
||||
return r;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Intersect Method
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// Replaces the Rectangle with the intersection of itself
|
||||
/// and another Rectangle.
|
||||
/// </remarks>
|
||||
|
||||
public void Intersect (Rectangle r)
|
||||
{
|
||||
if (!IntersectsWith (r)) {
|
||||
loc = Point.Empty;
|
||||
sz = Size.Empty;
|
||||
}
|
||||
|
||||
X = Math.Max (Left, r.Left);
|
||||
Y = Math.Max (Top, r.Top);
|
||||
Width = Math.Min (Right, r.Right) - X;
|
||||
Height = Math.Min (Bottom, r.Bottom) - Y;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Round Shared Method
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// Produces a Rectangle structure from a RectangleF by
|
||||
/// rounding the X, Y, Width, and Height properties.
|
||||
/// </remarks>
|
||||
|
||||
public static Rectangle Round (RectangleF value)
|
||||
{
|
||||
int x, y, w, h;
|
||||
checked {
|
||||
x = (int) Math.Round (value.X);
|
||||
y = (int) Math.Round (value.Y);
|
||||
w = (int) Math.Round (value.Width);
|
||||
h = (int) Math.Round (value.Height);
|
||||
}
|
||||
|
||||
return new Rectangle (x, y, w, h);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Truncate Shared Method
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// Produces a Rectangle structure from a RectangleF by
|
||||
/// truncating the X, Y, Width, and Height properties.
|
||||
/// </remarks>
|
||||
|
||||
// LAMESPEC: Should this be floor, or a pure cast to int?
|
||||
|
||||
public static Rectangle Truncate (RectangleF value)
|
||||
{
|
||||
int x, y, w, h;
|
||||
checked {
|
||||
x = (int) value.X;
|
||||
y = (int) value.Y;
|
||||
w = (int) value.Width;
|
||||
h = (int) value.Height;
|
||||
}
|
||||
|
||||
return new Rectangle (x, y, w, h);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Union Shared Method
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// Produces a new Rectangle from the union of 2 existing
|
||||
/// Rectangles.
|
||||
/// </remarks>
|
||||
|
||||
public static Rectangle Union (Rectangle r1, Rectangle r2)
|
||||
{
|
||||
return FromLTRB (Math.Min (r1.Left, r2.Left),
|
||||
Math.Min (r1.Top, r2.Top),
|
||||
Math.Max (r1.Right, r2.Right),
|
||||
Math.Max (r1.Bottom, r2.Bottom));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Equality Operator
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// Compares two Rectangle objects. The return value is
|
||||
/// based on the equivalence of the Location and Size
|
||||
/// properties of the two Rectangles.
|
||||
/// </remarks>
|
||||
|
||||
public static bool operator == (Rectangle r1, Rectangle r2)
|
||||
{
|
||||
return ((r1.Location == r2.Location) &&
|
||||
(r1.Size == r2.Size));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Inequality Operator
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// Compares two Rectangle objects. The return value is
|
||||
/// based on the equivalence of the Location and Size
|
||||
/// properties of the two Rectangles.
|
||||
/// </remarks>
|
||||
|
||||
public static bool operator != (Rectangle r1, Rectangle r2)
|
||||
{
|
||||
return ((r1.Location != r2.Location) ||
|
||||
(r1.Size != r2.Size));
|
||||
}
|
||||
|
||||
|
||||
// -----------------------
|
||||
// Public Constructors
|
||||
// -----------------------
|
||||
|
||||
/// <summary>
|
||||
/// Rectangle Constructor
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// Creates a Rectangle from Point and Size values.
|
||||
/// </remarks>
|
||||
|
||||
public Rectangle (Point loc, Size sz)
|
||||
{
|
||||
this.loc = loc;
|
||||
this.sz = sz;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Rectangle Constructor
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// Creates a Rectangle from a specified x,y location and
|
||||
/// width and height values.
|
||||
/// </remarks>
|
||||
|
||||
public Rectangle (int x, int y, int width, int height)
|
||||
{
|
||||
loc = new Point (x, y);
|
||||
sz = new Size (width, height);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Bottom Property
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// The Y coordinate of the bottom edge of the Rectangle.
|
||||
/// Read only.
|
||||
/// </remarks>
|
||||
|
||||
public int Bottom {
|
||||
get {
|
||||
return Y + Height;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Height Property
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// The Height of the Rectangle.
|
||||
/// </remarks>
|
||||
|
||||
public int Height {
|
||||
get {
|
||||
return sz.Height;
|
||||
}
|
||||
set {
|
||||
sz.Height = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// IsEmpty Property
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// Indicates if the width or height are zero. Read only.
|
||||
/// </remarks>
|
||||
|
||||
public bool IsEmpty {
|
||||
get {
|
||||
return ((sz.Width == 0) || (sz.Height == 0));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Left Property
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// The X coordinate of the left edge of the Rectangle.
|
||||
/// Read only.
|
||||
/// </remarks>
|
||||
|
||||
public int Left {
|
||||
get {
|
||||
return X;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Location Property
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// The Location of the top-left corner of the Rectangle.
|
||||
/// </remarks>
|
||||
|
||||
public Point Location {
|
||||
get {
|
||||
return loc;
|
||||
}
|
||||
set {
|
||||
loc = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Right Property
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// The X coordinate of the right edge of the Rectangle.
|
||||
/// Read only.
|
||||
/// </remarks>
|
||||
|
||||
public int Right {
|
||||
get {
|
||||
return X + Width;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Size Property
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// The Size of the Rectangle.
|
||||
/// </remarks>
|
||||
|
||||
public Size Size {
|
||||
get {
|
||||
return sz;
|
||||
}
|
||||
set {
|
||||
sz = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Top Property
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// The Y coordinate of the top edge of the Rectangle.
|
||||
/// Read only.
|
||||
/// </remarks>
|
||||
|
||||
public int Top {
|
||||
get {
|
||||
return Y;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Width Property
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// The Width of the Rectangle.
|
||||
/// </remarks>
|
||||
|
||||
public int Width {
|
||||
get {
|
||||
return sz.Width;
|
||||
}
|
||||
set {
|
||||
sz.Width = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// X Property
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// The X coordinate of the Rectangle.
|
||||
/// </remarks>
|
||||
|
||||
public int X {
|
||||
get {
|
||||
return loc.X;
|
||||
}
|
||||
set {
|
||||
loc.X = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Y Property
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// The Y coordinate of the Rectangle.
|
||||
/// </remarks>
|
||||
|
||||
public int Y {
|
||||
get {
|
||||
return loc.Y;
|
||||
}
|
||||
set {
|
||||
loc.Y = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Contains Method
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// Checks if an x,y coordinate lies within this Rectangle.
|
||||
/// </remarks>
|
||||
|
||||
public bool Contains (int x, int y)
|
||||
{
|
||||
return ((x >= Left) && (x <= Right) &&
|
||||
(y >= Top) && (y <= Bottom));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Contains Method
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// Checks if a Point lies within this Rectangle.
|
||||
/// </remarks>
|
||||
|
||||
public bool Contains (Point pt)
|
||||
{
|
||||
return Contains (pt.X, pt.Y);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Contains Method
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// Checks if a Rectangle lies entirely within this
|
||||
/// Rectangle.
|
||||
/// </remarks>
|
||||
|
||||
public bool Contains (Rectangle rect)
|
||||
{
|
||||
return (rect == Intersect (this, rect));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Equals Method
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// Checks equivalence of this Rectangle and another object.
|
||||
/// </remarks>
|
||||
|
||||
public override bool Equals (object o)
|
||||
{
|
||||
if (!(o is Rectangle))
|
||||
return false;
|
||||
|
||||
return (this == (Rectangle) o);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// GetHashCode Method
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// Calculates a hashing value.
|
||||
/// </remarks>
|
||||
|
||||
public override int GetHashCode ()
|
||||
{
|
||||
return loc.GetHashCode()^sz.GetHashCode();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// IntersectsWith Method
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// Checks if a Rectangle intersects with this one.
|
||||
/// </remarks>
|
||||
|
||||
public bool IntersectsWith (Rectangle r)
|
||||
{
|
||||
return !((Left > r.Right) || (Right < r.Left) ||
|
||||
(Top > r.Bottom) || (Bottom < r.Top));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Offset Method
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// Moves the Rectangle a specified distance.
|
||||
/// </remarks>
|
||||
|
||||
public void Offset (int dx, int dy)
|
||||
{
|
||||
X += dx;
|
||||
Y += dy;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Offset Method
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// Moves the Rectangle a specified distance.
|
||||
/// </remarks>
|
||||
|
||||
public void Offset (Point pt)
|
||||
{
|
||||
loc.Offset(pt.X, pt.Y);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ToString Method
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// Formats the Rectangle as a string in (x,y,w,h) notation.
|
||||
/// </remarks>
|
||||
|
||||
public override string ToString ()
|
||||
{
|
||||
return String.Format ("[{0},{1},{2},{3}]",
|
||||
X, Y, Width, Height);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,531 +0,0 @@
|
||||
//
|
||||
// System.Drawing.RectangleF.cs
|
||||
//
|
||||
// Author:
|
||||
// Mike Kestner ([email protected])
|
||||
//
|
||||
// (C) 2001 Mike Kestner
|
||||
//
|
||||
|
||||
using System;
|
||||
|
||||
namespace System.Drawing {
|
||||
|
||||
public struct RectangleF {
|
||||
|
||||
// Private position and size fields.
|
||||
private PointF loc;
|
||||
private SizeF sz;
|
||||
|
||||
/// <summary>
|
||||
/// Empty Shared Field
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// An uninitialized RectangleF Structure.
|
||||
/// </remarks>
|
||||
|
||||
public static readonly RectangleF Empty;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// FromLTRB Shared Method
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// Produces a RectangleF structure from left, top, right,
|
||||
/// and bottom coordinates.
|
||||
/// </remarks>
|
||||
|
||||
public static RectangleF FromLTRB (float left, float top,
|
||||
float right, float bottom)
|
||||
{
|
||||
return new RectangleF (left, top, right - left,
|
||||
bottom - top);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Inflate Shared Method
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// Produces a new RectangleF by inflating an existing
|
||||
/// RectangleF by the specified coordinate values.
|
||||
/// </remarks>
|
||||
|
||||
public static RectangleF Inflate (RectangleF r,
|
||||
float x, float y)
|
||||
{
|
||||
RectangleF ir = new RectangleF (r.Location, r.Size);
|
||||
ir.Inflate (x, y);
|
||||
return ir;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Inflate Method
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// Inflates the RectangleF by a specified width and height.
|
||||
/// </remarks>
|
||||
|
||||
public void Inflate (float width, float height)
|
||||
{
|
||||
Inflate (new SizeF (width, height));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Inflate Method
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// Inflates the RectangleF by a specified Size.
|
||||
/// </remarks>
|
||||
|
||||
public void Inflate (SizeF sz)
|
||||
{
|
||||
Offset(sz.Width, sz.Height);
|
||||
SizeF ds = new SizeF (sz.Width * 2, sz.Height * 2);
|
||||
this.sz += ds;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Intersect Shared Method
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// Produces a new RectangleF by intersecting 2 existing
|
||||
/// RectangleFs. Returns null if there is no intersection.
|
||||
/// </remarks>
|
||||
|
||||
public static RectangleF Intersect (RectangleF r1,
|
||||
RectangleF r2)
|
||||
{
|
||||
RectangleF r = new RectangleF (r1.Location, r1.Size);
|
||||
r.Intersect (r2);
|
||||
return r;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Intersect Method
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// Replaces the RectangleF with the intersection of itself
|
||||
/// and another RectangleF.
|
||||
/// </remarks>
|
||||
|
||||
public void Intersect (RectangleF r)
|
||||
{
|
||||
if (!IntersectsWith (r)) {
|
||||
loc = PointF.Empty;
|
||||
sz = SizeF.Empty;
|
||||
}
|
||||
|
||||
X = Math.Max (Left, r.Left);
|
||||
Y = Math.Max (Top, r.Top);
|
||||
Width = Math.Min (Right, r.Right) - X;
|
||||
Height = Math.Min (Bottom, r.Bottom) - Y;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Union Shared Method
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// Produces a new RectangleF from the union of 2 existing
|
||||
/// RectangleFs.
|
||||
/// </remarks>
|
||||
|
||||
public static RectangleF Union (RectangleF r1, RectangleF r2)
|
||||
{
|
||||
return FromLTRB (Math.Min (r1.Left, r2.Left),
|
||||
Math.Min (r1.Top, r2.Top),
|
||||
Math.Max (r1.Right, r2.Right),
|
||||
Math.Max (r1.Bottom, r2.Bottom));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Equality Operator
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// Compares two RectangleF objects. The return value is
|
||||
/// based on the equivalence of the Location and Size
|
||||
/// properties of the two RectangleFs.
|
||||
/// </remarks>
|
||||
|
||||
public static bool operator == (RectangleF r1, RectangleF r2)
|
||||
{
|
||||
return ((r1.Location == r2.Location) &&
|
||||
(r1.Size == r2.Size));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Inequality Operator
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// Compares two RectangleF objects. The return value is
|
||||
/// based on the equivalence of the Location and Size
|
||||
/// properties of the two RectangleFs.
|
||||
/// </remarks>
|
||||
|
||||
public static bool operator != (RectangleF r1, RectangleF r2)
|
||||
{
|
||||
return ((r1.Location != r2.Location) ||
|
||||
(r1.Size != r2.Size));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Rectangle to RectangleF Conversion
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// Converts a Rectangle object to a RectangleF.
|
||||
/// </remarks>
|
||||
|
||||
public static implicit operator RectangleF (Rectangle r)
|
||||
{
|
||||
return new RectangleF (r.Location, r.Size);
|
||||
}
|
||||
|
||||
|
||||
// -----------------------
|
||||
// Public Constructors
|
||||
// -----------------------
|
||||
|
||||
/// <summary>
|
||||
/// RectangleF Constructor
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// Creates a RectangleF from PointF and SizeF values.
|
||||
/// </remarks>
|
||||
|
||||
public RectangleF (PointF loc, SizeF sz)
|
||||
{
|
||||
this.loc = loc;
|
||||
this.sz = sz;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// RectangleF Constructor
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// Creates a RectangleF from a specified x,y location and
|
||||
/// width and height values.
|
||||
/// </remarks>
|
||||
|
||||
public RectangleF (float x, float y, float width, float height)
|
||||
{
|
||||
loc = new PointF (x, y);
|
||||
sz = new SizeF (width, height);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Bottom Property
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// The Y coordinate of the bottom edge of the RectangleF.
|
||||
/// Read only.
|
||||
/// </remarks>
|
||||
|
||||
public float Bottom {
|
||||
get {
|
||||
return Y + Height;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Height Property
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// The Height of the RectangleF.
|
||||
/// </remarks>
|
||||
|
||||
public float Height {
|
||||
get {
|
||||
return sz.Height;
|
||||
}
|
||||
set {
|
||||
sz.Height = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// IsEmpty Property
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// Indicates if the width or height are zero. Read only.
|
||||
/// </remarks>
|
||||
|
||||
public bool IsEmpty {
|
||||
get {
|
||||
return ((sz.Width == 0) || (sz.Height == 0));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Left Property
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// The X coordinate of the left edge of the RectangleF.
|
||||
/// Read only.
|
||||
/// </remarks>
|
||||
|
||||
public float Left {
|
||||
get {
|
||||
return X;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Location Property
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// The Location of the top-left corner of the RectangleF.
|
||||
/// </remarks>
|
||||
|
||||
public PointF Location {
|
||||
get {
|
||||
return loc;
|
||||
}
|
||||
set {
|
||||
loc = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Right Property
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// The X coordinate of the right edge of the RectangleF.
|
||||
/// Read only.
|
||||
/// </remarks>
|
||||
|
||||
public float Right {
|
||||
get {
|
||||
return X + Width;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Size Property
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// The Size of the RectangleF.
|
||||
/// </remarks>
|
||||
|
||||
public SizeF Size {
|
||||
get {
|
||||
return sz;
|
||||
}
|
||||
set {
|
||||
sz = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Top Property
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// The Y coordinate of the top edge of the RectangleF.
|
||||
/// Read only.
|
||||
/// </remarks>
|
||||
|
||||
public float Top {
|
||||
get {
|
||||
return Y;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Width Property
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// The Width of the RectangleF.
|
||||
/// </remarks>
|
||||
|
||||
public float Width {
|
||||
get {
|
||||
return sz.Width;
|
||||
}
|
||||
set {
|
||||
sz.Width = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// X Property
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// The X coordinate of the RectangleF.
|
||||
/// </remarks>
|
||||
|
||||
public float X {
|
||||
get {
|
||||
return loc.X;
|
||||
}
|
||||
set {
|
||||
loc.X = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Y Property
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// The Y coordinate of the RectangleF.
|
||||
/// </remarks>
|
||||
|
||||
public float Y {
|
||||
get {
|
||||
return loc.Y;
|
||||
}
|
||||
set {
|
||||
loc.Y = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Contains Method
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// Checks if an x,y coordinate lies within this RectangleF.
|
||||
/// </remarks>
|
||||
|
||||
public bool Contains (float x, float y)
|
||||
{
|
||||
return ((x >= Left) && (x <= Right) &&
|
||||
(y >= Top) && (y <= Bottom));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Contains Method
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// Checks if a Point lies within this RectangleF.
|
||||
/// </remarks>
|
||||
|
||||
public bool Contains (PointF pt)
|
||||
{
|
||||
return Contains (pt.X, pt.Y);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Contains Method
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// Checks if a RectangleF lies entirely within this
|
||||
/// RectangleF.
|
||||
/// </remarks>
|
||||
|
||||
public bool Contains (RectangleF rect)
|
||||
{
|
||||
return (rect == Intersect (this, rect));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Equals Method
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// Checks equivalence of this RectangleF and an object.
|
||||
/// </remarks>
|
||||
|
||||
public override bool Equals (object o)
|
||||
{
|
||||
if (!(o is RectangleF))
|
||||
return false;
|
||||
|
||||
return (this == (RectangleF) o);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// GetHashCode Method
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// Calculates a hashing value.
|
||||
/// </remarks>
|
||||
|
||||
public override int GetHashCode ()
|
||||
{
|
||||
return loc.GetHashCode()^sz.GetHashCode();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// IntersectsWith Method
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// Checks if a RectangleF intersects with this one.
|
||||
/// </remarks>
|
||||
|
||||
public bool IntersectsWith (RectangleF r)
|
||||
{
|
||||
return !((Left > r.Right) || (Right < r.Left) ||
|
||||
(Top > r.Bottom) || (Bottom < r.Top));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Offset Method
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// Moves the RectangleF a specified distance.
|
||||
/// </remarks>
|
||||
|
||||
public void Offset (float dx, float dy)
|
||||
{
|
||||
X += dx;
|
||||
Y += dy;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Offset Method
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// Moves the RectangleF a specified distance.
|
||||
/// </remarks>
|
||||
|
||||
public void Offset (PointF pt)
|
||||
{
|
||||
Offset(pt.X, pt.Y);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ToString Method
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// Formats the RectangleF in (x,y,w,h) notation.
|
||||
/// </remarks>
|
||||
|
||||
public override string ToString ()
|
||||
{
|
||||
return String.Format ("[{0},{1},{2},{3}]",
|
||||
X, Y, Width, Height);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,309 +0,0 @@
|
||||
//
|
||||
// System.Drawing.Size.cs
|
||||
//
|
||||
// Author:
|
||||
// Mike Kestner ([email protected])
|
||||
//
|
||||
// (C) 2001 Mike Kestner
|
||||
//
|
||||
|
||||
using System;
|
||||
|
||||
namespace System.Drawing {
|
||||
|
||||
public struct Size {
|
||||
|
||||
// Private height and width fields.
|
||||
int wd, ht;
|
||||
|
||||
// -----------------------
|
||||
// Public Shared Members
|
||||
// -----------------------
|
||||
|
||||
/// <summary>
|
||||
/// Empty Shared Field
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// An uninitialized Size Structure.
|
||||
/// </remarks>
|
||||
|
||||
public static readonly Size Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Ceiling Shared Method
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// Produces a Size structure from a SizeF structure by
|
||||
/// taking the ceiling of the Width and Height properties.
|
||||
/// </remarks>
|
||||
|
||||
public static Size Ceiling (SizeF value)
|
||||
{
|
||||
int w, h;
|
||||
checked {
|
||||
w = (int) Math.Ceiling (value.Width);
|
||||
h = (int) Math.Ceiling (value.Height);
|
||||
}
|
||||
|
||||
return new Size (w, h);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Round Shared Method
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// Produces a Size structure from a SizeF structure by
|
||||
/// rounding the Width and Height properties.
|
||||
/// </remarks>
|
||||
|
||||
public static Size Round (SizeF value)
|
||||
{
|
||||
int w, h;
|
||||
checked {
|
||||
w = (int) Math.Round (value.Width);
|
||||
h = (int) Math.Round (value.Height);
|
||||
}
|
||||
|
||||
return new Size (w, h);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Truncate Shared Method
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// Produces a Size structure from a SizeF structure by
|
||||
/// truncating the Width and Height properties.
|
||||
/// </remarks>
|
||||
|
||||
public static Size Truncate (SizeF value)
|
||||
{
|
||||
int w, h;
|
||||
checked {
|
||||
w = (int) value.Width;
|
||||
h = (int) value.Height;
|
||||
}
|
||||
|
||||
return new Size (w, h);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Addition Operator
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// Addition of two Size structures.
|
||||
/// </remarks>
|
||||
|
||||
public static Size operator + (Size sz1, Size sz2)
|
||||
{
|
||||
return new Size (sz1.Width + sz2.Width,
|
||||
sz1.Height + sz2.Height);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Equality Operator
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// Compares two Size objects. The return value is
|
||||
/// based on the equivalence of the Width and Height
|
||||
/// properties of the two Sizes.
|
||||
/// </remarks>
|
||||
|
||||
public static bool operator == (Size sz_a, Size sz_b)
|
||||
{
|
||||
return ((sz_a.Width == sz_b.Width) &&
|
||||
(sz_a.Height == sz_b.Height));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Inequality Operator
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// Compares two Size objects. The return value is
|
||||
/// based on the equivalence of the Width and Height
|
||||
/// properties of the two Sizes.
|
||||
/// </remarks>
|
||||
|
||||
public static bool operator != (Size sz_a, Size sz_b)
|
||||
{
|
||||
return ((sz_a.Width != sz_b.Width) ||
|
||||
(sz_a.Height != sz_b.Height));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Subtraction Operator
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// Subtracts two Size structures.
|
||||
/// </remarks>
|
||||
|
||||
public static Size operator - (Size sz1, Size sz2)
|
||||
{
|
||||
return new Size (sz1.Width - sz2.Width,
|
||||
sz1.Height - sz2.Height);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Size to Point Conversion
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// Returns a Point based on the dimensions of a given
|
||||
/// Size. Requires explicit cast.
|
||||
/// </remarks>
|
||||
|
||||
public static explicit operator Point (Size sz)
|
||||
{
|
||||
return new Point (sz.Width, sz.Height);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Size to SizeF Conversion
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// Creates a SizeF based on the dimensions of a given
|
||||
/// Size. No explicit cast is required.
|
||||
/// </remarks>
|
||||
|
||||
public static implicit operator SizeF (Size sz)
|
||||
{
|
||||
return new SizeF (sz.Width, sz.Height);
|
||||
}
|
||||
|
||||
|
||||
// -----------------------
|
||||
// Public Constructors
|
||||
// -----------------------
|
||||
|
||||
/// <summary>
|
||||
/// Size Constructor
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// Creates a Size from a Point value.
|
||||
/// </remarks>
|
||||
|
||||
public Size (Point pt)
|
||||
{
|
||||
wd = pt.X;
|
||||
ht = pt.Y;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Size Constructor
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// Creates a Size from specified dimensions.
|
||||
/// </remarks>
|
||||
|
||||
public Size (int width, int height)
|
||||
{
|
||||
wd = width;
|
||||
ht = height;
|
||||
}
|
||||
|
||||
// -----------------------
|
||||
// Public Instance Members
|
||||
// -----------------------
|
||||
|
||||
/// <summary>
|
||||
/// IsEmpty Property
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// Indicates if both Width and Height are zero.
|
||||
/// </remarks>
|
||||
|
||||
public bool IsEmpty {
|
||||
get {
|
||||
return ((wd == 0) && (ht == 0));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Width Property
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// The Width coordinate of the Size.
|
||||
/// </remarks>
|
||||
|
||||
public int Width {
|
||||
get {
|
||||
return wd;
|
||||
}
|
||||
set {
|
||||
wd = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Height Property
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// The Height coordinate of the Size.
|
||||
/// </remarks>
|
||||
|
||||
public int Height {
|
||||
get {
|
||||
return ht;
|
||||
}
|
||||
set {
|
||||
ht = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Equals Method
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// Checks equivalence of this Size and another object.
|
||||
/// </remarks>
|
||||
|
||||
public override bool Equals (object o)
|
||||
{
|
||||
if (!(o is Size))
|
||||
return false;
|
||||
|
||||
return (this == (Size) o);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// GetHashCode Method
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// Calculates a hashing value.
|
||||
/// </remarks>
|
||||
|
||||
public override int GetHashCode ()
|
||||
{
|
||||
return wd^ht;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ToString Method
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// Formats the Size as a string in coordinate notation.
|
||||
/// </remarks>
|
||||
|
||||
public override string ToString ()
|
||||
{
|
||||
return String.Format ("[{0},{1}]", wd, ht);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,249 +0,0 @@
|
||||
//
|
||||
// System.Drawing.SizeF.cs
|
||||
//
|
||||
// Author:
|
||||
// Mike Kestner ([email protected])
|
||||
//
|
||||
// (C) 2001 Mike Kestner
|
||||
//
|
||||
|
||||
using System;
|
||||
|
||||
namespace System.Drawing {
|
||||
|
||||
public struct SizeF {
|
||||
|
||||
// Private height and width fields.
|
||||
float wd, ht;
|
||||
|
||||
// -----------------------
|
||||
// Public Shared Members
|
||||
// -----------------------
|
||||
|
||||
/// <summary>
|
||||
/// Empty Shared Field
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// An uninitialized SizeF Structure.
|
||||
/// </remarks>
|
||||
|
||||
public static readonly SizeF Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Addition Operator
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// Addition of two SizeF structures.
|
||||
/// </remarks>
|
||||
|
||||
public static SizeF operator + (SizeF sz1, SizeF sz2)
|
||||
{
|
||||
return new SizeF (sz1.Width + sz2.Width,
|
||||
sz1.Height + sz2.Height);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Equality Operator
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// Compares two SizeF objects. The return value is
|
||||
/// based on the equivalence of the Width and Height
|
||||
/// properties of the two Sizes.
|
||||
/// </remarks>
|
||||
|
||||
public static bool operator == (SizeF sz_a, SizeF sz_b)
|
||||
{
|
||||
return ((sz_a.Width == sz_b.Width) &&
|
||||
(sz_a.Height == sz_b.Height));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Inequality Operator
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// Compares two SizeF objects. The return value is
|
||||
/// based on the equivalence of the Width and Height
|
||||
/// properties of the two Sizes.
|
||||
/// </remarks>
|
||||
|
||||
public static bool operator != (SizeF sz_a, SizeF sz_b)
|
||||
{
|
||||
return ((sz_a.Width != sz_b.Width) ||
|
||||
(sz_a.Height != sz_b.Height));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Subtraction Operator
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// Subtracts two SizeF structures.
|
||||
/// </remarks>
|
||||
|
||||
public static SizeF operator - (SizeF sz1, SizeF sz2)
|
||||
{
|
||||
return new SizeF (sz1.Width - sz2.Width,
|
||||
sz1.Height - sz2.Height);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// SizeF to PointF Conversion
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// Returns a PointF based on the dimensions of a given
|
||||
/// SizeF. Requires explicit cast.
|
||||
/// </remarks>
|
||||
|
||||
public static explicit operator PointF (SizeF sz)
|
||||
{
|
||||
return new PointF (sz.Width, sz.Height);
|
||||
}
|
||||
|
||||
|
||||
// -----------------------
|
||||
// Public Constructors
|
||||
// -----------------------
|
||||
|
||||
/// <summary>
|
||||
/// SizeF Constructor
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// Creates a SizeF from a PointF value.
|
||||
/// </remarks>
|
||||
|
||||
public SizeF (PointF pt)
|
||||
{
|
||||
wd = pt.X;
|
||||
ht = pt.Y;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// SizeF Constructor
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// Creates a SizeF from an existing SizeF value.
|
||||
/// </remarks>
|
||||
|
||||
public SizeF (SizeF sz)
|
||||
{
|
||||
wd = sz.Width;
|
||||
ht = sz.Height;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// SizeF Constructor
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// Creates a SizeF from specified dimensions.
|
||||
/// </remarks>
|
||||
|
||||
public SizeF (float width, float height)
|
||||
{
|
||||
wd = width;
|
||||
ht = height;
|
||||
}
|
||||
|
||||
// -----------------------
|
||||
// Public Instance Members
|
||||
// -----------------------
|
||||
|
||||
/// <summary>
|
||||
/// IsEmpty Property
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// Indicates if both Width and Height are zero.
|
||||
/// </remarks>
|
||||
|
||||
public bool IsEmpty {
|
||||
get {
|
||||
return ((wd == 0.0) && (ht == 0.0));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Width Property
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// The Width coordinate of the SizeF.
|
||||
/// </remarks>
|
||||
|
||||
public float Width {
|
||||
get {
|
||||
return wd;
|
||||
}
|
||||
set {
|
||||
wd = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Height Property
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// The Height coordinate of the SizeF.
|
||||
/// </remarks>
|
||||
|
||||
public float Height {
|
||||
get {
|
||||
return ht;
|
||||
}
|
||||
set {
|
||||
ht = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Equals Method
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// Checks equivalence of this SizeF and another object.
|
||||
/// </remarks>
|
||||
|
||||
public override bool Equals (object o)
|
||||
{
|
||||
if (!(o is SizeF))
|
||||
return false;
|
||||
|
||||
return (this == (SizeF) o);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// GetHashCode Method
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// Calculates a hashing value.
|
||||
/// </remarks>
|
||||
|
||||
public override int GetHashCode ()
|
||||
{
|
||||
return (int) wd ^ (int) ht;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ToString Method
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// Formats the SizeF as a string in coordinate notation.
|
||||
/// </remarks>
|
||||
|
||||
public override string ToString ()
|
||||
{
|
||||
return String.Format ("[{0},{1}]", wd, ht);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
2001-10-31 Mike Kestner <[email protected]>
|
||||
|
||||
* TestPoint.cs : Tests I've had in my node forever.
|
||||
|
||||
@@ -1,159 +0,0 @@
|
||||
// Tests for System.Drawing.Point.cs
|
||||
//
|
||||
// Author: Mike Kestner ([email protected])
|
||||
//
|
||||
// Copyright (c) 2001 Ximian, Inc.
|
||||
|
||||
using NUnit.Framework;
|
||||
using System;
|
||||
using System.Drawing;
|
||||
|
||||
public class PointTest : TestCase {
|
||||
Point pt1_1;
|
||||
Point pt1_0;
|
||||
Point pt0_1;
|
||||
|
||||
protected override void SetUp ()
|
||||
{
|
||||
pt1_1 = new Point (1, 1);
|
||||
pt1_0 = new Point (1, 0);
|
||||
pt0_1 = new Point (0, 1);
|
||||
}
|
||||
|
||||
public PointTest(String name) : base (name) {}
|
||||
|
||||
public static ITest Suite {
|
||||
get {
|
||||
TestSuite suite = new TestSuite ();
|
||||
suite.AddTest (new PointTest ("EqualsTest"));
|
||||
suite.AddTest (new PointTest ("EqualityOpTest"));
|
||||
suite.AddTest (new PointTest ("InequalityOpTest"));
|
||||
suite.AddTest (new PointTest ("CeilingTest"));
|
||||
suite.AddTest (new PointTest ("RoundTest"));
|
||||
suite.AddTest (new PointTest ("TruncateTest"));
|
||||
suite.AddTest (new PointTest ("NullTest"));
|
||||
suite.AddTest (new PointTest ("AdditionTest"));
|
||||
suite.AddTest (new PointTest ("SubtractionTest"));
|
||||
suite.AddTest (new PointTest ("Point2SizeTest"));
|
||||
suite.AddTest (new PointTest ("Point2PointFTest"));
|
||||
suite.AddTest (new PointTest ("ConstructorTest"));
|
||||
suite.AddTest (new PointTest ("PropertyTest"));
|
||||
suite.AddTest (new PointTest ("OffsetTest"));
|
||||
return suite;
|
||||
}
|
||||
}
|
||||
|
||||
public void EqualsTest ()
|
||||
{
|
||||
AssertEquals (pt1_1, pt1_1);
|
||||
AssertEquals (pt1_1, new Point (1, 1));
|
||||
Assert (!pt1_1.Equals (pt1_0));
|
||||
Assert (!pt1_1.Equals (pt0_1));
|
||||
Assert (!pt1_0.Equals (pt0_1));
|
||||
}
|
||||
|
||||
public void EqualityOpTest ()
|
||||
{
|
||||
Assert (pt1_1 == pt1_1);
|
||||
Assert (pt1_1 == new Point (1, 1));
|
||||
Assert (!(pt1_1 == pt1_0));
|
||||
Assert (!(pt1_1 == pt0_1));
|
||||
Assert (!(pt1_0 == pt0_1));
|
||||
}
|
||||
|
||||
public void InequalityOpTest ()
|
||||
{
|
||||
Assert (!(pt1_1 != pt1_1));
|
||||
Assert (!(pt1_1 != new Point (1, 1)));
|
||||
Assert (pt1_1 != pt1_0);
|
||||
Assert (pt1_1 != pt0_1);
|
||||
Assert (pt1_0 != pt0_1);
|
||||
}
|
||||
|
||||
public void CeilingTest ()
|
||||
{
|
||||
PointF ptf = new PointF (0.8f, 0.3f);
|
||||
AssertEquals (pt1_1, Point.Ceiling (ptf));
|
||||
}
|
||||
|
||||
public void RoundTest ()
|
||||
{
|
||||
PointF ptf = new PointF (0.8f, 1.3f);
|
||||
AssertEquals (pt1_1, Point.Round (ptf));
|
||||
}
|
||||
|
||||
public void TruncateTest ()
|
||||
{
|
||||
PointF ptf = new PointF (0.8f, 1.3f);
|
||||
AssertEquals (pt0_1, Point.Truncate (ptf));
|
||||
}
|
||||
|
||||
public void NullTest ()
|
||||
{
|
||||
Point pt = new Point (0, 0);
|
||||
AssertEquals (pt, Point.Empty);
|
||||
}
|
||||
|
||||
public void AdditionTest ()
|
||||
{
|
||||
AssertEquals (pt1_1, pt1_0 + new Size (0, 1));
|
||||
AssertEquals (pt1_1, pt0_1 + new Size (1, 0));
|
||||
}
|
||||
|
||||
public void SubtractionTest ()
|
||||
{
|
||||
AssertEquals (pt1_0, pt1_1 - new Size (0, 1));
|
||||
AssertEquals (pt0_1, pt1_1 - new Size (1, 0));
|
||||
}
|
||||
|
||||
public void Point2SizeTest ()
|
||||
{
|
||||
Size sz1 = new Size (1, 1);
|
||||
Size sz2 = (Size) pt1_1;
|
||||
|
||||
AssertEquals (sz1, sz2);
|
||||
}
|
||||
|
||||
public void Point2PointFTest ()
|
||||
{
|
||||
PointF ptf1 = new PointF (1, 1);
|
||||
PointF ptf2 = pt1_1;
|
||||
|
||||
AssertEquals (ptf1, ptf2);
|
||||
}
|
||||
|
||||
public void ConstructorTest ()
|
||||
{
|
||||
int i = (1 << 16) + 1;
|
||||
Size sz = new Size (1, 1);
|
||||
Point pt_i = new Point (i);
|
||||
Point pt_sz = new Point (sz);
|
||||
|
||||
AssertEquals (pt_i, pt_sz);
|
||||
AssertEquals (pt_i, pt1_1);
|
||||
AssertEquals (pt_sz, pt1_1);
|
||||
}
|
||||
|
||||
public void PropertyTest ()
|
||||
{
|
||||
Point pt = new Point (0, 0);
|
||||
|
||||
Assert (pt.IsEmpty);
|
||||
Assert (!pt1_1.IsEmpty);
|
||||
AssertEquals (1, pt1_0.X);
|
||||
AssertEquals (1, pt0_1.Y);
|
||||
}
|
||||
|
||||
public void OffsetTest ()
|
||||
{
|
||||
Point pt = new Point (0, 0);
|
||||
pt.Offset (0, 1);
|
||||
AssertEquals (pt, pt0_1);
|
||||
pt.Offset (1, 0);
|
||||
AssertEquals (pt, pt1_1);
|
||||
pt.Offset (0, -1);
|
||||
AssertEquals (pt, pt1_0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
Temp.build
|
||||
*.dll
|
||||
lib
|
||||
makefile
|
||||
@@ -1,29 +0,0 @@
|
||||
2001-12-20 Gaurav Vaish <[email protected]>
|
||||
|
||||
Did first successful build of System.Web.dll that included System.Web.UI.WebControls namespace. Though, not updating the System.Web.build file, since with the changes that followed, the build again fails :(
|
||||
|
||||
2001-11-30 Gaurav Vaish <[email protected]>
|
||||
|
||||
* System.Web.WebUtils: Removed
|
||||
* System.Web.Utils : Added --- replacement of WebUtils
|
||||
|
||||
2001-11-08 Gaurav Vaish <[email protected]>
|
||||
|
||||
* System.Web.WebUtils: Added directory
|
||||
|
||||
2001-08-22 Bob Smith <[email protected]>
|
||||
|
||||
* Added directory: System.Web.UI.HtmlControls
|
||||
* Added directory: Test
|
||||
|
||||
2001-08-17 Bob Smith <[email protected]>
|
||||
|
||||
* Added directory: System.Web.UI
|
||||
|
||||
2001-08-09 Bob Smith <[email protected]>
|
||||
|
||||
* Added directory: System.Web
|
||||
|
||||
2001-07-20 Patrik Torstensson ([email protected])
|
||||
|
||||
* Added directory: System.Web.Caching
|
||||
@@ -1,520 +0,0 @@
|
||||
//
|
||||
// System.Web.Caching
|
||||
//
|
||||
// Author:
|
||||
// Patrik Torstensson ([email protected])
|
||||
//
|
||||
// (C) Copyright Patrik Torstensson, 2001
|
||||
//
|
||||
namespace System.Web.Caching
|
||||
{
|
||||
/// <summary>
|
||||
/// Implements a cache for Web applications and other. The difference from the MS.NET implementation is that we
|
||||
/// support to use the Cache object as cache in our applications.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The Singleton cache is created per application domain, and it remains valid as long as the application domain remains active.
|
||||
/// </remarks>
|
||||
/// <example>
|
||||
/// Usage of the singleton cache:
|
||||
///
|
||||
/// Cache objManager = Cache.SingletonCache;
|
||||
///
|
||||
/// String obj = "tobecached";
|
||||
/// objManager.Add("kalle", obj);
|
||||
/// </example>
|
||||
public class Cache : System.Collections.IEnumerable, System.IDisposable
|
||||
{
|
||||
// Declarations
|
||||
|
||||
// MS.NET Does only have the cache connected to the HttpRuntime and we don't have the HttpRuntime (yet)
|
||||
static Cache objSingletonCache = new Cache();
|
||||
|
||||
private bool _boolDisposed;
|
||||
|
||||
// Helper objects
|
||||
private CacheExpires _objExpires;
|
||||
|
||||
// The data storage
|
||||
// Todo: Make a specialized storage for the cache entries?
|
||||
// todo: allow system to replace the storage?
|
||||
private System.Collections.Hashtable _arrEntries;
|
||||
private System.Threading.ReaderWriterLock _lockEntries;
|
||||
|
||||
static private System.TimeSpan _datetimeOneYear = System.TimeSpan.FromDays(365);
|
||||
|
||||
// Number of items in the cache
|
||||
private long _longItems;
|
||||
|
||||
// Constructor
|
||||
public Cache()
|
||||
{
|
||||
_boolDisposed = false;
|
||||
_longItems = 0;
|
||||
|
||||
_lockEntries = new System.Threading.ReaderWriterLock();
|
||||
_arrEntries = new System.Collections.Hashtable();
|
||||
|
||||
_objExpires = new CacheExpires(this);
|
||||
}
|
||||
|
||||
// Public methods and properties
|
||||
|
||||
//
|
||||
/// <summary>
|
||||
/// Returns a static version of the cache. In MS.NET the cache is stored in the System.Web.HttpRuntime
|
||||
/// but we keep it here as a singleton (right now anyway).
|
||||
/// </summary>
|
||||
public static Cache SingletonCache
|
||||
{
|
||||
get
|
||||
{
|
||||
if (objSingletonCache == null)
|
||||
{
|
||||
throw new System.InvalidOperationException();
|
||||
}
|
||||
|
||||
return objSingletonCache;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Used in the absoluteExpiration parameter in an Insert method call to indicate the item should never expire. This field is read-only.
|
||||
/// </summary>
|
||||
public static readonly System.DateTime NoAbsoluteExpiration = System.DateTime.MaxValue;
|
||||
|
||||
/// <summary>
|
||||
/// Used as the slidingExpiration parameter in an Insert method call to disable sliding expirations. This field is read-only.
|
||||
/// </summary>
|
||||
public static readonly System.TimeSpan NoSlidingExpiration = System.TimeSpan.Zero;
|
||||
|
||||
/// <summary>
|
||||
/// Internal method to create a enumerator and over all public items in the cache and is used by GetEnumerator method.
|
||||
/// </summary>
|
||||
/// <returns>Returns IDictionaryEnumerator that contains all public items in the cache</returns>
|
||||
private System.Collections.IDictionaryEnumerator CreateEnumerator()
|
||||
{
|
||||
System.Collections.Hashtable objTable;
|
||||
|
||||
_lockEntries.AcquireReaderLock(int.MaxValue);
|
||||
try
|
||||
{
|
||||
// Create a new hashtable to return as collection of public items
|
||||
objTable = new System.Collections.Hashtable(_arrEntries.Count);
|
||||
|
||||
foreach(System.Collections.DictionaryEntry objEntry in _arrEntries)
|
||||
{
|
||||
if (objEntry.Key != null)
|
||||
{
|
||||
// Check if this is a public entry
|
||||
if (((CacheEntry) objEntry.Value).TestFlag(CacheEntry.Flags.Public))
|
||||
{
|
||||
// Add to the collection
|
||||
objTable.Add(objEntry.Key, ((CacheEntry) objEntry.Value).Item);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
_lockEntries.ReleaseReaderLock();
|
||||
}
|
||||
|
||||
return objTable.GetEnumerator();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Implementation of IEnumerable interface and calls the GetEnumerator that returns
|
||||
/// IDictionaryEnumerator.
|
||||
/// </summary>
|
||||
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
|
||||
{
|
||||
return GetEnumerator();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Virtual override of the IEnumerable.GetEnumerator() method, returns a specialized enumerator.
|
||||
/// </summary>
|
||||
public virtual System.Collections.IDictionaryEnumerator GetEnumerator()
|
||||
{
|
||||
return CreateEnumerator();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Touches a object in the cache. Used to update expire time and hit count.
|
||||
/// </summary>
|
||||
/// <param name="strKey">The identifier for the cache item to retrieve.</param>
|
||||
public void Touch(string strKey)
|
||||
{
|
||||
// Just touch the object
|
||||
Get(strKey);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds the specified item to the Cache object with dependencies, expiration and priority policies, and a
|
||||
/// delegate you can use to notify your application when the inserted item is removed from the Cache.
|
||||
/// </summary>
|
||||
/// <param name="strKey">The cache key used to reference the item.</param>
|
||||
/// <param name="objItem">The item to be added to the cache.</param>
|
||||
/// <param name="objDependency">The file or cache key dependencies for the item. When any dependency changes, the object becomes invalid and is removed from the cache. If there are no dependencies, this paramter contains a null reference.</param>
|
||||
/// <param name="absolutExpiration">The time at which the added object expires and is removed from the cache. </param>
|
||||
/// <param name="slidingExpiration">The interval between the time the added object was last accessed and when that object expires. If this value is the equivalent of 20 minutes, the object expires and is removed from the cache 20 minutes after it is last accessed.</param>
|
||||
/// <param name="enumPriority">The relative cost of the object, as expressed by the CacheItemPriority enumeration. The cache uses this value when it evicts objects; objects with a lower cost are removed from the cache before objects with a higher cost.</param>
|
||||
/// <param name="enumPriorityDecay">The rate at which an object in the cache decays in importance. Objects that decay quickly are more likely to be removed.</param>
|
||||
/// <param name="eventRemoveCallback">A delegate that, if provided, is called when an object is removed from the cache. You can use this to notify applications when their objects are deleted from the cache.</param>
|
||||
/// <returns>The Object item added to the Cache.</returns>
|
||||
public object Add(string strKey, object objItem, CacheDependency objDependency, System.DateTime absolutExpiration, System.TimeSpan slidingExpiration, CacheItemPriority enumPriority, CacheItemPriorityDecay enumPriorityDecay, CacheItemRemovedCallback eventRemoveCallback)
|
||||
{
|
||||
if (_boolDisposed)
|
||||
{
|
||||
throw new System.ObjectDisposedException("System.Web.Cache");
|
||||
}
|
||||
|
||||
if (strKey == null)
|
||||
{
|
||||
throw new System.ArgumentNullException("strKey");
|
||||
}
|
||||
|
||||
if (objItem == null)
|
||||
{
|
||||
throw new System.ArgumentNullException("objItem");
|
||||
}
|
||||
|
||||
if (slidingExpiration > _datetimeOneYear)
|
||||
{
|
||||
throw new System.ArgumentOutOfRangeException("slidingExpiration");
|
||||
}
|
||||
|
||||
CacheEntry objEntry;
|
||||
CacheEntry objNewEntry;
|
||||
|
||||
long longHitRange = 10000;
|
||||
|
||||
// todo: check decay and make up the minHit range
|
||||
|
||||
objEntry = new CacheEntry(this, strKey, objItem, objDependency, eventRemoveCallback, absolutExpiration, slidingExpiration, longHitRange, true, enumPriority);
|
||||
|
||||
System.Threading.Interlocked.Increment(ref _longItems);
|
||||
|
||||
// If we have any kind of expiration add into the CacheExpires class
|
||||
if (objEntry.HasSlidingExpiration || objEntry.HasAbsoluteExpiration)
|
||||
{
|
||||
// Add it to CacheExpires
|
||||
_objExpires.Add(objEntry);
|
||||
}
|
||||
|
||||
// Check and get the new item..
|
||||
objNewEntry = UpdateCache(strKey, objEntry, true, CacheItemRemovedReason.Removed);
|
||||
|
||||
if (objNewEntry != null)
|
||||
{
|
||||
// Return added item
|
||||
return objEntry.Item;
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Inserts an item into the Cache object with a cache key to reference its location and using default values
|
||||
/// provided by the CacheItemPriority and CacheItemPriorityDecay enumerations.
|
||||
/// </summary>
|
||||
/// <param name="strKey">The cache key used to reference the item.</param>
|
||||
/// <param name="objItem">The item to be added to the cache.</param>
|
||||
public void Insert(string strKey, object objItem)
|
||||
{
|
||||
Add(strKey, objItem, null, System.DateTime.MaxValue, System.TimeSpan.Zero, CacheItemPriority.Default, CacheItemPriorityDecay.Default, null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Inserts an object into the Cache that has file or key dependencies.
|
||||
/// </summary>
|
||||
/// <param name="strKey">The cache key used to reference the item.</param>
|
||||
/// <param name="objItem">The item to be added to the cache.</param>
|
||||
/// <param name="objDependency">The file or cache key dependencies for the item. When any dependency changes, the object becomes invalid and is removed from the cache. If there are no dependencies, this paramter contains a null reference.</param>
|
||||
public void Insert(string strKey, object objItem, CacheDependency objDependency)
|
||||
{
|
||||
Add(strKey, objItem, objDependency, System.DateTime.MaxValue, System.TimeSpan.Zero, CacheItemPriority.Default, CacheItemPriorityDecay.Default, null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Inserts an object into the Cache with dependencies and expiration policies.
|
||||
/// </summary>
|
||||
/// <param name="strKey">The cache key used to reference the item.</param>
|
||||
/// <param name="objItem">The item to be added to the cache.</param>
|
||||
/// <param name="objDependency">The file or cache key dependencies for the item. When any dependency changes, the object becomes invalid and is removed from the cache. If there are no dependencies, this paramter contains a null reference.</param>
|
||||
/// <param name="absolutExpiration">The time at which the added object expires and is removed from the cache. </param>
|
||||
/// <param name="slidingExpiration">The interval between the time the added object was last accessed and when that object expires. If this value is the equivalent of 20 minutes, the object expires and is removed from the cache 20 minutes after it is last accessed.</param>
|
||||
public void Insert(string strKey, object objItem, CacheDependency objDependency, System.DateTime absolutExpiration, System.TimeSpan slidingExpiration)
|
||||
{
|
||||
Add(strKey, objItem, objDependency, absolutExpiration, slidingExpiration, CacheItemPriority.Default, CacheItemPriorityDecay.Default, null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Inserts an object into the Cache object with dependencies, expiration and priority policies, and a delegate
|
||||
/// you can use to notify your application when the inserted item is removed from the Cache.
|
||||
/// </summary>
|
||||
/// <param name="strKey">The cache key used to reference the item.</param>
|
||||
/// <param name="objItem">The item to be added to the cache.</param>
|
||||
/// <param name="objDependency">The file or cache key dependencies for the item. When any dependency changes, the object becomes invalid and is removed from the cache. If there are no dependencies, this paramter contains a null reference.</param>
|
||||
/// <param name="absolutExpiration">The time at which the added object expires and is removed from the cache. </param>
|
||||
/// <param name="slidingExpiration">The interval between the time the added object was last accessed and when that object expires. If this value is the equivalent of 20 minutes, the object expires and is removed from the cache 20 minutes after it is last accessed.</param>
|
||||
/// <param name="enumPriority">The relative cost of the object, as expressed by the CacheItemPriority enumeration. The cache uses this value when it evicts objects; objects with a lower cost are removed from the cache before objects with a higher cost.</param>
|
||||
/// <param name="enumPriorityDecay">The rate at which an object in the cache decays in importance. Objects that decay quickly are more likely to be removed.</param>
|
||||
/// <param name="eventRemoveCallback">A delegate that, if provided, is called when an object is removed from the cache. You can use this to notify applications when their objects are deleted from the cache.</param>
|
||||
public void Insert(string strKey, object objItem, CacheDependency objDependency, System.DateTime absolutExpiration, System.TimeSpan slidingExpiration, CacheItemPriority enumPriority, CacheItemPriorityDecay enumPriorityDecay, CacheItemRemovedCallback eventRemoveCallback)
|
||||
{
|
||||
Add(strKey, objItem, objDependency, absolutExpiration, slidingExpiration, enumPriority, enumPriorityDecay, eventRemoveCallback);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes the specified item from the Cache object.
|
||||
/// </summary>
|
||||
/// <param name="strKey">The cache key for the cache item to remove.</param>
|
||||
/// <returns>The item removed from the Cache. If the value in the key parameter is not found, returns a null reference.</returns>
|
||||
public object Remove(string strKey)
|
||||
{
|
||||
return Remove(strKey, CacheItemRemovedReason.Removed);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Internal method that updates the cache, decremenents the number of existing items and call close on the cache entry. This method
|
||||
/// is also used from the ExpiresBuckets class to remove an item during GC flush.
|
||||
/// </summary>
|
||||
/// <param name="strKey">The cache key for the cache item to remove.</param>
|
||||
/// <param name="enumReason">Reason why the item is removed.</param>
|
||||
/// <returns>The item removed from the Cache. If the value in the key parameter is not found, returns a null reference.</returns>
|
||||
internal object Remove(string strKey, CacheItemRemovedReason enumReason)
|
||||
{
|
||||
CacheEntry objEntry = UpdateCache(strKey, null, true, enumReason);
|
||||
|
||||
if (objEntry != null)
|
||||
{
|
||||
System.Threading.Interlocked.Decrement(ref _longItems);
|
||||
|
||||
// Close the cache entry (calls the remove delegate)
|
||||
objEntry.Close(enumReason);
|
||||
|
||||
return objEntry.Item;
|
||||
} else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves the specified item from the Cache object.
|
||||
/// </summary>
|
||||
/// <param name="strKey">The identifier for the cache item to retrieve.</param>
|
||||
/// <returns>The retrieved cache item, or a null reference.</returns>
|
||||
public object Get(string strKey)
|
||||
{
|
||||
CacheEntry objEntry = UpdateCache(strKey, null, false, CacheItemRemovedReason.Expired);
|
||||
|
||||
if (objEntry == null)
|
||||
{
|
||||
return null;
|
||||
} else
|
||||
{
|
||||
return objEntry.Item;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Internal method used for removing, updating and adding CacheEntries into the cache.
|
||||
/// </summary>
|
||||
/// <param name="strKey">The identifier for the cache item to modify</param>
|
||||
/// <param name="objEntry">CacheEntry to use for overwrite operation, if this parameter is null and overwrite true the item is going to be removed</param>
|
||||
/// <param name="boolOverwrite">If true the objEntry parameter is used to overwrite the strKey entry</param>
|
||||
/// <param name="enumReason">Reason why an item was removed</param>
|
||||
/// <returns></returns>
|
||||
private CacheEntry UpdateCache(string strKey, CacheEntry objEntry, bool boolOverwrite, CacheItemRemovedReason enumReason)
|
||||
{
|
||||
if (_boolDisposed)
|
||||
{
|
||||
throw new System.ObjectDisposedException("System.Web.Cache", "Can't update item(s) in a disposed cache");
|
||||
}
|
||||
|
||||
if (strKey == null)
|
||||
{
|
||||
throw new System.ArgumentNullException("System.Web.Cache");
|
||||
}
|
||||
|
||||
long ticksNow = System.DateTime.Now.Ticks;
|
||||
long ticksExpires = long.MaxValue;
|
||||
|
||||
bool boolGetItem = false;
|
||||
bool boolExpiried = false;
|
||||
bool boolWrite = false;
|
||||
bool boolRemoved = false;
|
||||
|
||||
// Are we getting the item from the hashtable
|
||||
if (boolOverwrite == false && strKey.Length > 0 && objEntry == null)
|
||||
{
|
||||
boolGetItem = true;
|
||||
}
|
||||
|
||||
// TODO: Optimize this method, move out functionality outside the lock
|
||||
_lockEntries.AcquireReaderLock(int.MaxValue);
|
||||
try
|
||||
{
|
||||
if (boolGetItem)
|
||||
{
|
||||
objEntry = (CacheEntry) _arrEntries[strKey];
|
||||
if (objEntry == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
if (objEntry != null)
|
||||
{
|
||||
// Check if we have expired
|
||||
if (objEntry.HasSlidingExpiration || objEntry.HasAbsoluteExpiration)
|
||||
{
|
||||
if (objEntry.Expires < ticksNow)
|
||||
{
|
||||
// We have expired, remove the item from the cache
|
||||
boolWrite = true;
|
||||
boolExpiried = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Check if we going to modify the hashtable
|
||||
if (boolWrite || (boolOverwrite && !boolExpiried))
|
||||
{
|
||||
// Upgrade our lock to write
|
||||
System.Threading.LockCookie objCookie = _lockEntries.UpgradeToWriterLock(int.MaxValue);
|
||||
try
|
||||
{
|
||||
// Check if we going to just modify an existing entry (or add)
|
||||
if (boolOverwrite && objEntry != null)
|
||||
{
|
||||
_arrEntries[strKey] = objEntry;
|
||||
}
|
||||
else
|
||||
{
|
||||
// We need to remove the item, fetch the item first
|
||||
objEntry = (CacheEntry) _arrEntries[strKey];
|
||||
if (objEntry != null)
|
||||
{
|
||||
_arrEntries.Remove(strKey);
|
||||
}
|
||||
|
||||
boolRemoved = true;
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
_lockEntries.DowngradeFromWriterLock(ref objCookie);
|
||||
}
|
||||
}
|
||||
|
||||
// If the entry haven't expired or been removed update the info
|
||||
if (!boolExpiried && !boolRemoved)
|
||||
{
|
||||
// Update that we got a hit
|
||||
objEntry.Hits++;
|
||||
if (objEntry.HasSlidingExpiration)
|
||||
{
|
||||
ticksExpires = ticksNow + objEntry.SlidingExpiration;
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
_lockEntries.ReleaseLock();
|
||||
|
||||
}
|
||||
|
||||
// If the item was removed we need to remove it from the CacheExpired class also
|
||||
if (boolRemoved)
|
||||
{
|
||||
if (objEntry != null)
|
||||
{
|
||||
if (objEntry.HasAbsoluteExpiration || objEntry.HasSlidingExpiration)
|
||||
{
|
||||
_objExpires.Remove(objEntry);
|
||||
}
|
||||
}
|
||||
|
||||
// Return the entry, it's not up to the UpdateCache to call Close on the entry
|
||||
return objEntry;
|
||||
}
|
||||
|
||||
// If we have sliding expiration and we have a correct hit, update the expiration manager
|
||||
if (objEntry.HasSlidingExpiration)
|
||||
{
|
||||
_objExpires.Update(objEntry, ticksExpires);
|
||||
}
|
||||
|
||||
// Return the cache entry
|
||||
return objEntry;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the number of items stored in the cache.
|
||||
/// </summary>
|
||||
long Count
|
||||
{
|
||||
get
|
||||
{
|
||||
return _longItems;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the cache item at the specified key.
|
||||
/// </summary>
|
||||
public object this[string strKey]
|
||||
{
|
||||
get
|
||||
{
|
||||
return Get(strKey);
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
Insert(strKey, value);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called to close the cache when the AppDomain is closing down or the GC has decided it's time to destroy the object.
|
||||
/// </summary>
|
||||
public void Dispose()
|
||||
{
|
||||
_boolDisposed = true;
|
||||
|
||||
_lockEntries.AcquireReaderLock(int.MaxValue);
|
||||
try
|
||||
{
|
||||
foreach(System.Collections.DictionaryEntry objEntry in _arrEntries)
|
||||
{
|
||||
if (objEntry.Key != null)
|
||||
{
|
||||
// Check if this is active
|
||||
if ( ((CacheEntry) objEntry.Value).TestFlag(CacheEntry.Flags.Removed) )
|
||||
{
|
||||
try
|
||||
{
|
||||
((CacheEntry) objEntry.Value).Close(CacheItemRemovedReason.Removed);
|
||||
}
|
||||
catch (System.Exception objException)
|
||||
{
|
||||
System.Diagnostics.Debug.Fail("System.Web.Cache.Dispose() Exception when closing cache entry", "Message: " + objException.Message + " Stack: " + objException.StackTrace + " Source:" + objException.Source);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
_lockEntries.ReleaseReaderLock();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
//
|
||||
// System.Web.Caching
|
||||
//
|
||||
// Author:
|
||||
// Patrik Torstensson ([email protected])
|
||||
//
|
||||
// (C) Copyright Patrik Torstensson, 2001
|
||||
//
|
||||
namespace System.Web.Caching
|
||||
{
|
||||
/// <summary>
|
||||
/// Specifies the relative priority of items stored in the Cache.
|
||||
/// </summary>
|
||||
public enum CacheItemPriority {
|
||||
AboveNormal,
|
||||
BelowNormal,
|
||||
Default,
|
||||
High,
|
||||
Low,
|
||||
Normal,
|
||||
NotRemovable
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Specifies the rate at which the priority of items stored in the Cache are downgraded when not accessed frequently.
|
||||
/// </summary>
|
||||
public enum CacheItemPriorityDecay {
|
||||
Default,
|
||||
Fast,
|
||||
Medium,
|
||||
Never,
|
||||
Slow
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Specifies the reason an item was removed from the Cache.
|
||||
/// </summary>
|
||||
public enum CacheItemRemovedReason {
|
||||
DependencyChanged,
|
||||
Expired,
|
||||
Removed,
|
||||
Underused
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Defines a callback method for notifying applications when a cached item is removed from the Cache.
|
||||
/// </summary>
|
||||
/// <param name="key">The index location for the item removed from the cache. </param>
|
||||
/// <param name="value">The Object item removed from the cache. </param>
|
||||
/// <param name="reason">The reason the item was removed from the cache, as specified by the CacheItemRemovedReason enumeration.</param>
|
||||
public delegate void CacheItemRemovedCallback(string key, object value, CacheItemRemovedReason reason);
|
||||
|
||||
}
|
||||
@@ -1,97 +0,0 @@
|
||||
//
|
||||
// System.Web.Caching
|
||||
//
|
||||
// Author:
|
||||
// Patrik Torstensson ([email protected])
|
||||
//
|
||||
// (C) Copyright Patrik Torstensson, 2001
|
||||
//
|
||||
namespace System.Web.Caching
|
||||
{
|
||||
/// <summary>
|
||||
/// Class to handle cache dependency, right now this class is only a mookup
|
||||
/// </summary>
|
||||
public class CacheDependency : System.IDisposable
|
||||
{
|
||||
private bool _boolDisposed;
|
||||
|
||||
public CacheDependency()
|
||||
{
|
||||
_boolDisposed = false;
|
||||
}
|
||||
|
||||
/// <remarks>
|
||||
/// Added by [email protected]
|
||||
/// </remarks>
|
||||
[MonoTODO("Constrcutor")]
|
||||
public CacheDependency(string filename)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
/// <remarks>
|
||||
/// Added by [email protected]
|
||||
/// </remarks>
|
||||
[MonoTODO("Constrcutor")]
|
||||
public CacheDependency(string[] filenames, string[] cachekeys)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public delegate void CacheDependencyCallback(CacheDependency objDependency);
|
||||
|
||||
public event CacheDependencyCallback Changed;
|
||||
|
||||
public void OnChanged()
|
||||
{
|
||||
if (_boolDisposed)
|
||||
{
|
||||
throw new System.ObjectDisposedException("System.Web.CacheDependency");
|
||||
}
|
||||
|
||||
if (Changed != null)
|
||||
{
|
||||
Changed(this);
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsDisposed
|
||||
{
|
||||
get
|
||||
{
|
||||
return _boolDisposed;
|
||||
}
|
||||
}
|
||||
|
||||
public bool HasEvents
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_boolDisposed)
|
||||
{
|
||||
throw new System.ObjectDisposedException("System.Web.CacheDependency");
|
||||
}
|
||||
|
||||
if (Changed != null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_boolDisposed = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Used in testing.
|
||||
/// </summary>
|
||||
public void Signal()
|
||||
{
|
||||
OnChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,363 +0,0 @@
|
||||
//
|
||||
// System.Web.Caching
|
||||
//
|
||||
// Author:
|
||||
// Patrik Torstensson ([email protected])
|
||||
//
|
||||
// (C) Copyright Patrik Torstensson, 2001
|
||||
//
|
||||
namespace System.Web.Caching
|
||||
{
|
||||
/// <summary>
|
||||
/// Class responsible for representing a cache entry.
|
||||
/// </summary>
|
||||
public class CacheEntry
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines the status of the current cache entry
|
||||
/// </summary>
|
||||
public enum Flags
|
||||
{
|
||||
Removed = 0,
|
||||
Public = 1
|
||||
}
|
||||
|
||||
private CacheItemPriority _enumPriority;
|
||||
|
||||
private long _longHits;
|
||||
|
||||
private byte _byteExpiresBucket;
|
||||
private int _intExpiresIndex;
|
||||
|
||||
private long _ticksExpires;
|
||||
private long _ticksSlidingExpiration;
|
||||
|
||||
private string _strKey;
|
||||
private object _objItem;
|
||||
|
||||
private long _longMinHits;
|
||||
|
||||
private Flags _enumFlags;
|
||||
|
||||
private CacheDependency _objDependency;
|
||||
private Cache _objCache;
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a new cache entry
|
||||
/// </summary>
|
||||
/// <param name="strKey">The cache key used to reference the item.</param>
|
||||
/// <param name="objItem">The item to be added to the cache.</param>
|
||||
/// <param name="objDependency">The file or cache key dependencies for the item. When any dependency changes, the object becomes invalid and is removed from the cache. If there are no dependencies, this paramter contains a null reference.</param>
|
||||
/// <param name="dtExpires">The time at which the added object expires and is removed from the cache. </param>
|
||||
/// <param name="tsSpan">The interval between the time the added object was last accessed and when that object expires. If this value is the equivalent of 20 minutes, the object expires and is removed from the cache 20 minutes after it is last accessed.</param>
|
||||
/// <param name="longMinHits">Used to detect and control if the item should be flushed due to under usage</param>
|
||||
/// <param name="boolPublic">Defines if the item is public or not</param>
|
||||
/// <param name="enumPriority">The relative cost of the object, as expressed by the CacheItemPriority enumeration. The cache uses this value when it evicts objects; objects with a lower cost are removed from the cache before objects with a higher cost.</param>
|
||||
public CacheEntry( Cache objManager, string strKey, object objItem, CacheDependency objDependency, CacheItemRemovedCallback eventRemove,
|
||||
System.DateTime dtExpires, System.TimeSpan tsSpan, long longMinHits, bool boolPublic, CacheItemPriority enumPriority )
|
||||
{
|
||||
if (boolPublic)
|
||||
{
|
||||
SetFlag(Flags.Public);
|
||||
}
|
||||
|
||||
_strKey = strKey;
|
||||
_objItem = objItem;
|
||||
_objCache = objManager;
|
||||
|
||||
_onRemoved += eventRemove;
|
||||
|
||||
_enumPriority = enumPriority;
|
||||
|
||||
_ticksExpires = dtExpires.Ticks;
|
||||
|
||||
_ticksSlidingExpiration = tsSpan.Ticks;
|
||||
|
||||
// If we have a sliding expiration it overrides the absolute expiration (MS behavior)
|
||||
if (tsSpan.Ticks != System.TimeSpan.Zero.Ticks)
|
||||
{
|
||||
_ticksExpires = System.DateTime.Now.AddTicks(_ticksSlidingExpiration).Ticks;
|
||||
}
|
||||
|
||||
_objDependency = objDependency;
|
||||
if (_objDependency != null)
|
||||
{
|
||||
if (_objDependency.IsDisposed)
|
||||
{
|
||||
throw new System.ObjectDisposedException("System.Web.CacheDependency");
|
||||
}
|
||||
|
||||
// Add the entry to the cache dependency handler (we support multiple entries per handler)
|
||||
_objDependency.Changed += new CacheDependency.CacheDependencyCallback(OnChanged);
|
||||
}
|
||||
|
||||
_longMinHits = longMinHits;
|
||||
}
|
||||
|
||||
private event CacheItemRemovedCallback _onRemoved;
|
||||
|
||||
public void OnChanged(CacheDependency objDependency)
|
||||
{
|
||||
_objCache.Remove(_strKey, CacheItemRemovedReason.DependencyChanged);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Cleans up the cache entry, removes the cache dependency and calls the remove delegate.
|
||||
/// </summary>
|
||||
/// <param name="enumReason">The reason why the cache entry are going to be removed</param>
|
||||
public void Close(CacheItemRemovedReason enumReason)
|
||||
{
|
||||
lock(this)
|
||||
{
|
||||
// Check if the item already is removed
|
||||
if (TestFlag(Flags.Removed))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
SetFlag(Flags.Removed);
|
||||
|
||||
if (_onRemoved != null)
|
||||
{
|
||||
// Call the delegate to tell that we are now removing the entry
|
||||
try
|
||||
{
|
||||
_onRemoved(_strKey, _objItem, enumReason);
|
||||
}
|
||||
catch (System.Exception objException)
|
||||
{
|
||||
System.Diagnostics.Debug.Fail("System.Web.CacheEntry.Close() Exception when calling remove delegate", "Message: " + objException.Message + " Stack: " + objException.StackTrace + " Source:" + objException.Source);
|
||||
}
|
||||
}
|
||||
|
||||
// If we have a dependency, remove the entry
|
||||
if (_objDependency != null)
|
||||
{
|
||||
_objDependency.Changed -= new CacheDependency.CacheDependencyCallback(OnChanged);
|
||||
if (!_objDependency.HasEvents)
|
||||
{
|
||||
_objDependency.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tests a specific flag is set or not.
|
||||
/// </summary>
|
||||
/// <param name="oFlag">Flag to test agains</param>
|
||||
/// <returns>Returns true if the flag is set.</returns>
|
||||
public bool TestFlag(Flags oFlag)
|
||||
{
|
||||
lock(this)
|
||||
{
|
||||
if ((_enumFlags & oFlag) != 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets a specific flag.
|
||||
/// </summary>
|
||||
/// <param name="oFlag">Flag to set.</param>
|
||||
public void SetFlag(Flags oFlag)
|
||||
{
|
||||
lock (this)
|
||||
{
|
||||
_enumFlags |= oFlag;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the object has minimum hit usage flushing enabled.
|
||||
/// </summary>
|
||||
public bool HasUsage
|
||||
{
|
||||
get {
|
||||
if (_longMinHits == System.Int64.MaxValue)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the entry has absolute expiration.
|
||||
/// </summary>
|
||||
public bool HasAbsoluteExpiration
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_ticksExpires == System.DateTime.MaxValue.Ticks)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the entry has sliding expiration enabled.
|
||||
/// </summary>
|
||||
public bool HasSlidingExpiration
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_ticksSlidingExpiration == System.TimeSpan.Zero.Ticks)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets and sets the current expires bucket the entry is active in.
|
||||
/// </summary>
|
||||
public byte ExpiresBucket
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (this)
|
||||
{
|
||||
return _byteExpiresBucket;
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
lock (this)
|
||||
{
|
||||
_byteExpiresBucket = ExpiresBucket;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets and sets the current index in the expires bucket of the current cache entry.
|
||||
/// </summary>
|
||||
public int ExpiresIndex
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (this)
|
||||
{
|
||||
return _intExpiresIndex;
|
||||
}
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
lock (this)
|
||||
{
|
||||
_intExpiresIndex = ExpiresIndex;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets and sets the expiration of the cache entry.
|
||||
/// </summary>
|
||||
public long Expires
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (this)
|
||||
{
|
||||
return _ticksExpires;
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
lock (this)
|
||||
{
|
||||
_ticksExpires = Expires;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the sliding expiration value. The return value is in ticks (since 0/0-01 in 100nanosec)
|
||||
/// </summary>
|
||||
public long SlidingExpiration
|
||||
{
|
||||
get
|
||||
{
|
||||
return _ticksSlidingExpiration;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the current cached item.
|
||||
/// </summary>
|
||||
public object Item
|
||||
{
|
||||
get
|
||||
{
|
||||
return _objItem;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the current cache identifier.
|
||||
/// </summary>
|
||||
public string Key
|
||||
{
|
||||
get
|
||||
{
|
||||
return _strKey;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets and sets the current number of hits on the cache entry.
|
||||
/// </summary>
|
||||
public long Hits
|
||||
{
|
||||
// todo: Could be optimized by using interlocked methods..
|
||||
get
|
||||
{
|
||||
lock (this)
|
||||
{
|
||||
return _longHits;
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
lock (this)
|
||||
{
|
||||
_longHits = Hits;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns minimum hits for the usage flushing rutine.
|
||||
/// </summary>
|
||||
public long MinimumHits
|
||||
{
|
||||
get
|
||||
{
|
||||
return _longMinHits;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the priority of the cache entry.
|
||||
/// </summary>
|
||||
public CacheItemPriority Priority
|
||||
{
|
||||
get
|
||||
{
|
||||
return _enumPriority;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,145 +0,0 @@
|
||||
//
|
||||
// System.Web.Caching
|
||||
//
|
||||
// Author:
|
||||
// Patrik Torstensson ([email protected])
|
||||
//
|
||||
// (C) Copyright Patrik Torstensson, 2001
|
||||
//
|
||||
namespace System.Web.Caching
|
||||
{
|
||||
/// <summary>
|
||||
/// Class responsible for handling time based flushing of entries in the cache. The class creates
|
||||
/// and manages 60 buckets each holding every item that expires that minute. The bucket calculated
|
||||
/// for an entry is one minute more than the timeout just to make sure that the item end up in the
|
||||
/// bucket where it should be flushed.
|
||||
/// </summary>
|
||||
public class CacheExpires : System.IDisposable
|
||||
{
|
||||
static int _intFlush;
|
||||
static long _ticksPerBucket = 600000000;
|
||||
static long _ticksPerCycle = _ticksPerBucket * 60;
|
||||
|
||||
private ExpiresBucket[] _arrBuckets;
|
||||
private System.Threading.Timer _objTimer;
|
||||
private Cache _objManager;
|
||||
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
/// <param name="objManager">The cache manager, used when flushing items in a bucket.</param>
|
||||
public CacheExpires(Cache objManager)
|
||||
{
|
||||
_objManager = objManager;
|
||||
Initialize();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes the class.
|
||||
/// </summary>
|
||||
private void Initialize()
|
||||
{
|
||||
// Create one bucket per minute
|
||||
_arrBuckets = new ExpiresBucket[60];
|
||||
|
||||
byte bytePos = 0;
|
||||
do
|
||||
{
|
||||
_arrBuckets[bytePos] = new ExpiresBucket(bytePos, _objManager);
|
||||
bytePos++;
|
||||
} while (bytePos < 60);
|
||||
|
||||
// GC Bucket controller
|
||||
_intFlush = System.DateTime.Now.Minute - 1;
|
||||
_objTimer = new System.Threading.Timer(new System.Threading.TimerCallback(GarbageCleanup), null, 10000, 60000);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a Cache entry to the correct flush bucket.
|
||||
/// </summary>
|
||||
/// <param name="objEntry">Cache entry to add.</param>
|
||||
public void Add(CacheEntry objEntry)
|
||||
{
|
||||
long ticksNow = System.DateTime.Now.Ticks;
|
||||
|
||||
lock(this)
|
||||
{
|
||||
// If the entry doesn't have a expires time we assume that the entry is due to expire now.
|
||||
if (objEntry.Expires == 0)
|
||||
{
|
||||
objEntry.Expires = ticksNow;
|
||||
}
|
||||
|
||||
_arrBuckets[GetHashBucket(objEntry.Expires)].Add(objEntry);
|
||||
}
|
||||
}
|
||||
|
||||
public void Remove(CacheEntry objEntry)
|
||||
{
|
||||
long ticksNow = System.DateTime.Now.Ticks;
|
||||
|
||||
lock(this)
|
||||
{
|
||||
// If the entry doesn't have a expires time we assume that the entry is due to expire now.
|
||||
if (objEntry.Expires == 0)
|
||||
{
|
||||
objEntry.Expires = ticksNow;
|
||||
}
|
||||
|
||||
_arrBuckets[GetHashBucket(objEntry.Expires)].Remove(objEntry);
|
||||
}
|
||||
}
|
||||
|
||||
public void Update(CacheEntry objEntry, long ticksExpires)
|
||||
{
|
||||
long ticksNow = System.DateTime.Now.Ticks;
|
||||
|
||||
lock(this)
|
||||
{
|
||||
// If the entry doesn't have a expires time we assume that the entry is due to expire now.
|
||||
if (objEntry.Expires == 0)
|
||||
{
|
||||
objEntry.Expires = ticksNow;
|
||||
}
|
||||
|
||||
_arrBuckets[GetHashBucket(objEntry.Expires)].Update(objEntry, ticksExpires);
|
||||
}
|
||||
}
|
||||
|
||||
public void GarbageCleanup(object State)
|
||||
{
|
||||
ExpiresBucket objBucket;
|
||||
|
||||
lock(this)
|
||||
{
|
||||
// Do cleanup of the bucket
|
||||
objBucket = _arrBuckets[(++_intFlush) % 60];
|
||||
}
|
||||
|
||||
// Flush expired items in the current bucket (defined by _intFlush)
|
||||
objBucket.FlushExpiredItems();
|
||||
}
|
||||
|
||||
private int GetHashBucket(long ticks)
|
||||
{
|
||||
// Get bucket to add expire item into, add one minute to the bucket just to make sure that we get it in the bucket gc
|
||||
return (int) (((((ticks + 60000) % _ticksPerCycle) / _ticksPerBucket) + 1) % 60);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called by the cache for cleanup.
|
||||
/// </summary>
|
||||
public void Dispose()
|
||||
{
|
||||
lock(this)
|
||||
{
|
||||
// Cleanup the internal timer
|
||||
if (_objTimer != null)
|
||||
{
|
||||
_objTimer.Dispose();
|
||||
_objTimer = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
2001-12-21 Gaurav Vaish <[email protected]>
|
||||
|
||||
* CacheDependency.cs: Some unimplemented methods to make build
|
||||
|
||||
2001-07-20 Patrik Torstensson ([email protected])
|
||||
|
||||
* Cache.cs: Implemented. (90% ready)
|
||||
* CacheDefinitions.cs: Implemented.
|
||||
* CacheDependency.cs: Added. (20% ready)
|
||||
* CacheExpires: Implemented.
|
||||
* CacheEntry.cs: Implemented. (95% ready, going to be changed due to CacheDependecy support)
|
||||
* ExpiresBuckets.cs: Implemented.
|
||||
@@ -1,253 +0,0 @@
|
||||
//
|
||||
// System.Web.Caching
|
||||
//
|
||||
// Author:
|
||||
// Patrik Torstensson ([email protected])
|
||||
//
|
||||
// (C) Copyright Patrik Torstensson, 2001
|
||||
//
|
||||
namespace System.Web.Caching
|
||||
{
|
||||
/// <summary>
|
||||
/// Responsible for holding a cache entry in the linked list bucket.
|
||||
/// </summary>
|
||||
public struct ExpiresEntry
|
||||
{
|
||||
public CacheEntry _objEntry;
|
||||
public long _ticksExpires;
|
||||
public int _intNext;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Holds cache entries that has a expiration in a bucket list.
|
||||
/// </summary>
|
||||
public class ExpiresBucket
|
||||
{
|
||||
private static int MIN_ENTRIES = 16;
|
||||
|
||||
private byte _byteID;
|
||||
private int _intSize;
|
||||
private int _intCount;
|
||||
private int _intNext;
|
||||
|
||||
private Cache _objManager;
|
||||
|
||||
private ExpiresEntry [] _arrEntries;
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a new bucket.
|
||||
/// </summary>
|
||||
/// <param name="bucket">Current bucket ID.</param>
|
||||
/// <param name="objManager">Cache manager reponsible for the item(s) in the expires bucket.</param>
|
||||
public ExpiresBucket(byte bucket, Cache objManager)
|
||||
{
|
||||
_objManager = objManager;
|
||||
Initialize(bucket);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes the expires bucket, creates a linked list of MIN_ENTRIES.
|
||||
/// </summary>
|
||||
/// <param name="bucket">Bucket ID.</param>
|
||||
private void Initialize(byte bucket)
|
||||
{
|
||||
_byteID = bucket;
|
||||
_intNext = 0;
|
||||
_intCount = 0;
|
||||
|
||||
_arrEntries = new ExpiresEntry[MIN_ENTRIES];
|
||||
_intSize = MIN_ENTRIES;
|
||||
|
||||
int intPos = 0;
|
||||
do
|
||||
{
|
||||
_arrEntries[intPos]._intNext = intPos + 1;
|
||||
_arrEntries[intPos]._ticksExpires = System.DateTime.MaxValue.Ticks;
|
||||
|
||||
intPos++;
|
||||
} while (intPos < _intSize);
|
||||
|
||||
_arrEntries[_intSize - 1]._intNext = -1;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Expands the bucket linked array list.
|
||||
/// </summary>
|
||||
private void Expand()
|
||||
{
|
||||
ExpiresEntry [] arrData;
|
||||
int intPos = 0;
|
||||
int intOldSize;
|
||||
|
||||
lock(this)
|
||||
{
|
||||
intOldSize = _intSize;
|
||||
_intSize *= 2;
|
||||
|
||||
// Create a new array and copy the old data into the new array
|
||||
arrData = new ExpiresEntry[_intSize];
|
||||
do
|
||||
{
|
||||
arrData[intPos] = _arrEntries[intPos];
|
||||
intPos++;
|
||||
} while (intPos < intOldSize);
|
||||
|
||||
_intNext = intPos;
|
||||
|
||||
// Initialize the "new" positions.
|
||||
do
|
||||
{
|
||||
arrData[intPos]._intNext = intPos + 1;
|
||||
intPos++;
|
||||
} while (intPos < _intSize);
|
||||
|
||||
arrData[_intSize - 1]._intNext = -1;
|
||||
|
||||
_arrEntries = arrData;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a cache entry into the expires bucket.
|
||||
/// </summary>
|
||||
/// <param name="objEntry">Cache Entry object to be added.</param>
|
||||
public void Add(CacheEntry objEntry)
|
||||
{
|
||||
if (_intNext == -1)
|
||||
{
|
||||
Expand();
|
||||
}
|
||||
|
||||
lock(this)
|
||||
{
|
||||
_arrEntries[_intNext]._ticksExpires = objEntry.Expires;
|
||||
_arrEntries[_intNext]._objEntry = objEntry;
|
||||
|
||||
_intNext = _arrEntries[_intNext]._intNext;
|
||||
|
||||
_intCount++;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes a cache entry from the expires bucket.
|
||||
/// </summary>
|
||||
/// <param name="objEntry">Cache entry to be removed.</param>
|
||||
public void Remove(CacheEntry objEntry)
|
||||
{
|
||||
lock(this)
|
||||
{
|
||||
// Check if this is our bucket
|
||||
if (objEntry.ExpiresIndex != _byteID) return;
|
||||
if (objEntry.ExpiresIndex == System.Int32.MaxValue) return;
|
||||
if (_arrEntries.Length < objEntry.ExpiresIndex) return;
|
||||
|
||||
_intCount--;
|
||||
|
||||
_arrEntries[objEntry.ExpiresIndex]._objEntry.ExpiresBucket = byte.MaxValue;
|
||||
_arrEntries[objEntry.ExpiresIndex]._objEntry.ExpiresIndex = int.MaxValue;
|
||||
_arrEntries[objEntry.ExpiresIndex]._objEntry = null;
|
||||
_intNext = _arrEntries[objEntry.ExpiresIndex]._intNext;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updates a cache entry in the expires bucket, this is called during a hit of an item if the
|
||||
/// cache item has a sliding expiration. The function is responsible for updating the cache
|
||||
/// entry.
|
||||
/// </summary>
|
||||
/// <param name="objEntry">Cache entry to update.</param>
|
||||
/// <param name="ticksExpires">New expiration value for the cache entry.</param>
|
||||
public void Update(CacheEntry objEntry, long ticksExpires)
|
||||
{
|
||||
lock(this)
|
||||
{
|
||||
// Check if this is our bucket
|
||||
if (objEntry.ExpiresIndex != _byteID) return;
|
||||
if (objEntry.ExpiresIndex == System.Int32.MaxValue) return;
|
||||
if (_arrEntries.Length < objEntry.ExpiresIndex) return;
|
||||
|
||||
_arrEntries[objEntry.ExpiresIndex]._ticksExpires = ticksExpires;
|
||||
_arrEntries[objEntry.ExpiresIndex]._objEntry.Expires = ticksExpires;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Flushes all cache entries that has expired and removes them from the cache manager.
|
||||
/// </summary>
|
||||
public void FlushExpiredItems()
|
||||
{
|
||||
ExpiresEntry objEntry;
|
||||
CacheEntry [] arrCacheEntries;
|
||||
|
||||
int intCachePos;
|
||||
int intPos;
|
||||
long ticksNow;
|
||||
|
||||
ticksNow = System.DateTime.Now.Ticks;
|
||||
|
||||
intCachePos = 0;
|
||||
|
||||
// Lookup all items that needs to be removed, this is done in a two part
|
||||
// operation to minimize the locking time.
|
||||
lock (this)
|
||||
{
|
||||
arrCacheEntries = new CacheEntry[_intSize];
|
||||
|
||||
intPos = 0;
|
||||
do
|
||||
{
|
||||
objEntry = _arrEntries[intPos];
|
||||
if (objEntry._objEntry != null)
|
||||
{
|
||||
if (objEntry._ticksExpires < ticksNow)
|
||||
{
|
||||
arrCacheEntries[intCachePos++] = objEntry._objEntry;
|
||||
|
||||
objEntry._objEntry.ExpiresBucket = byte.MaxValue;
|
||||
objEntry._objEntry.ExpiresIndex = int.MaxValue;
|
||||
objEntry._objEntry = null;
|
||||
_intNext = objEntry._intNext;
|
||||
}
|
||||
}
|
||||
|
||||
intPos++;
|
||||
} while (intPos < _intSize);
|
||||
}
|
||||
|
||||
// If we have any entries to remove, go ahead and call the cache manager remove.
|
||||
if (intCachePos > 0)
|
||||
{
|
||||
intPos = 0;
|
||||
do
|
||||
{
|
||||
_objManager.Remove(arrCacheEntries[intPos].Key, CacheItemRemovedReason.Expired);
|
||||
|
||||
intPos++;
|
||||
} while (intPos < intCachePos);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the current size of the expires bucket.
|
||||
/// </summary>
|
||||
public int Size
|
||||
{
|
||||
get
|
||||
{
|
||||
return _arrEntries.Length;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns number of items in the bucket.
|
||||
/// </summary>
|
||||
public int Count
|
||||
{
|
||||
get
|
||||
{
|
||||
return _intCount;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
/* System.Web.Configuration
|
||||
* Authors:
|
||||
* Leen Toelen ([email protected])
|
||||
* Copyright (C) 2001 Leen Toelen
|
||||
*/
|
||||
|
||||
namespace System.Web.Configuration {
|
||||
|
||||
/// <summary>
|
||||
/// Defines the AuthenticationMode for a Web Application.
|
||||
/// </summary>
|
||||
public enum AuthenticationMode{
|
||||
Forms,
|
||||
None,
|
||||
Passport,
|
||||
Windows
|
||||
}
|
||||
|
||||
} //namespace System.Web.Configuration
|
||||
@@ -1,44 +0,0 @@
|
||||
/* System.Web.Configuration
|
||||
* Authors:
|
||||
* Leen Toelen ([email protected])
|
||||
* Copyright (C) 2001 Leen Toelen
|
||||
*/
|
||||
using System;
|
||||
using System.Configuration;
|
||||
|
||||
namespace System.Web.Configuration
|
||||
{
|
||||
/// <summary>
|
||||
/// Summary description for ClientTargetSectionHandler.
|
||||
/// </summary>
|
||||
public class ClientTargetSectionHandler: NameValueSectionHandler
|
||||
{
|
||||
/// <summary>
|
||||
/// ClientTargetSectionHandler Constructor
|
||||
/// </summary>
|
||||
public ClientTargetSectionHandler(){}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name of the key in the key-value pair.
|
||||
/// </summary>
|
||||
protected override string KeyAttributeName
|
||||
{
|
||||
get
|
||||
{
|
||||
return "alias";
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the value for the key in the key-value pair.
|
||||
/// </summary>
|
||||
protected override string ValueAttributeName
|
||||
{
|
||||
get
|
||||
{
|
||||
return "userAgent";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
} //namespace System.Web.Configuration
|
||||
@@ -1,18 +0,0 @@
|
||||
/* System.Web.Configuration
|
||||
* Authors:
|
||||
* Leen Toelen ([email protected])
|
||||
* Copyright (C) 2001 Leen Toelen
|
||||
*/
|
||||
|
||||
namespace System.Web.Configuration {
|
||||
|
||||
/// <summary>
|
||||
/// Defines the password encryption format.
|
||||
/// </summary>
|
||||
public enum FormsAuthPasswordFormat{
|
||||
Clear,
|
||||
MD5,
|
||||
SHA1
|
||||
}
|
||||
|
||||
} //namespace System.Web.Configuration
|
||||
@@ -1,19 +0,0 @@
|
||||
/* System.Web.Configuration
|
||||
* Authors:
|
||||
* Leen Toelen ([email protected])
|
||||
* Copyright (C) 2001 Leen Toelen
|
||||
*/
|
||||
|
||||
namespace System.Web.Configuration {
|
||||
|
||||
/// <summary>
|
||||
/// Defines the method used for securing web forms.
|
||||
/// </summary>
|
||||
public enum FormsProtectionEnum{
|
||||
All,
|
||||
Encryption,
|
||||
None,
|
||||
Validation
|
||||
}
|
||||
|
||||
} //namespace System.Web.Configuration
|
||||
@@ -1,19 +0,0 @@
|
||||
//
|
||||
// System.Web.Hosting.AppDomainFactory.cs
|
||||
//
|
||||
// Author:
|
||||
// Bob Smith <[email protected]>
|
||||
//
|
||||
// (C) Bob Smith
|
||||
//
|
||||
|
||||
using System;
|
||||
|
||||
namespace System.Web.Hosting
|
||||
{
|
||||
public sealed class AppDomainFactory : IAppDomainFactory
|
||||
{
|
||||
public AppDomainFactory();
|
||||
public object Create(string module, string typeName, string appId, string appPath, string strUrlOfAppOrigin, int iZone);
|
||||
}
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
//
|
||||
// System.Web.Hosting.ApplicationHost.cs
|
||||
//
|
||||
// Author:
|
||||
// Bob Smith <[email protected]>
|
||||
//
|
||||
// (C) Bob Smith
|
||||
//
|
||||
|
||||
using System;
|
||||
|
||||
namespace System.Web.Hosting
|
||||
{
|
||||
public sealed class ApplicationHost
|
||||
public static object CreateApplicationHost(Type hostType, string virtualDir, string physicalDir);
|
||||
}
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
2001-08-30 Bob Smith <[email protected]>
|
||||
|
||||
* AppDomainFactory.cs: Stubbed.
|
||||
* ApplicationHost.cs: Stubbed.
|
||||
* IAppDomainFactory.cs: Stubbed.
|
||||
* IISAPIRuntime.cs: Stubbed.
|
||||
* ISAPIRuntime.cs: Implemented.
|
||||
* SimpleWorkerRequest.cs: Implemented.
|
||||
@@ -1,18 +0,0 @@
|
||||
//
|
||||
// System.Web.Hosting.IAppDomainFactory.cs
|
||||
//
|
||||
// Author:
|
||||
// Bob Smith <[email protected]>
|
||||
//
|
||||
// (C) Bob Smith
|
||||
//
|
||||
|
||||
using System;
|
||||
|
||||
namespace System.Web.Hosting
|
||||
{
|
||||
public interface IAppDomainFactory
|
||||
{
|
||||
object Create(in string module, in string typeName, in string appId, in string appPath, in string strUrlOfAppOrigin, in int iZone);
|
||||
}
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
//
|
||||
// System.Web.Hosting.IISAPIRuntime.cs
|
||||
//
|
||||
// Author:
|
||||
// Bob Smith <[email protected]>
|
||||
//
|
||||
// (C) Bob Smith
|
||||
//
|
||||
|
||||
using System;
|
||||
|
||||
namespace System.Web.Hosting
|
||||
{
|
||||
public interface IISAPIRuntime
|
||||
{
|
||||
void DoGCCollect();
|
||||
int ProcessRequest(in IntPtr ecb, in int useProcessModel);
|
||||
void StartProcessing();
|
||||
void StopProcessing();
|
||||
}
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
//
|
||||
// System.Web.Hosting.ISAPIRuntime.cs
|
||||
//
|
||||
// Author:
|
||||
// Bob Smith <[email protected]>
|
||||
//
|
||||
// (C) Bob Smith
|
||||
//
|
||||
|
||||
using System;
|
||||
|
||||
namespace System.Web.Hosting
|
||||
{
|
||||
public sealed class ISAPIRuntime : IISAPIRuntime
|
||||
{
|
||||
public ISAPIRuntime();
|
||||
public void DoGCCollect();
|
||||
public int ProcessRequest(IntPtr ecb, int iWRType);
|
||||
public void StartProcessing();
|
||||
public void StopProcessing();
|
||||
}
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
//
|
||||
// System.Web.Hosting.SimpleWorkerRequest.cs
|
||||
//
|
||||
// Author:
|
||||
// Bob Smith <[email protected]>
|
||||
//
|
||||
// (C) Bob Smith
|
||||
//
|
||||
|
||||
using System;
|
||||
|
||||
namespace System.Web.Hosting
|
||||
{
|
||||
public class SimpleWorkerRequest : HttpWorkerRequest
|
||||
{
|
||||
public SimpleWorkerRequest(string page, string query, TextWriter output);
|
||||
public SimpleWorkerRequest(string appVirtualDir, string appPhysicalDir, string page, string query, TextWriter output);
|
||||
public override string MachineConfigPath {get;}
|
||||
public override void EndOfRequest();
|
||||
public override void FlushResponse(bool finalFlush);
|
||||
public override string GetAppPath();
|
||||
public override string GetAppPathTranslated();
|
||||
public override string GetFilePath();
|
||||
public override string GetFilePathTranslated();
|
||||
public override string GetHttpVerbName();
|
||||
public override string GetHttpVersion();
|
||||
public override string GetLocalAddress();
|
||||
public override int GetLocalPort();
|
||||
public override string GetPathInfo();
|
||||
public override string GetQueryString();
|
||||
public override string GetRawUrl();
|
||||
public override string GetRemoteAddress();
|
||||
public override int GetRemotePort();
|
||||
public override string GetServerVariable(string name);
|
||||
public override string GetUriPath();
|
||||
public override IntPtr GetUserToken();
|
||||
public override string MapPath(string path);
|
||||
public override void SendKnownResponseHeader(int index, string value);
|
||||
public override void SendResponseFromFile(IntPtr handle, long offset, long length);
|
||||
public override void SendResponseFromFile(string filename, long offset, long length);
|
||||
public override void SendResponseFromMemory(byte[] data, int length);
|
||||
public virtual void SendResponseFromMemory(IntPtr data, int length);
|
||||
public override void SendStatus(int statusCode, string statusDescription);
|
||||
public override void SendUnknownResponseHeader(string name, string value);
|
||||
}
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
2001-09-03 Leen Toelen <[email protected]>
|
||||
|
||||
* HtmlAnchor.cs: Initial implementation.
|
||||
* HtmlTextArea.cs: Initial implementation.
|
||||
|
||||
2001-08-22 Bob Smith <[email protected]>
|
||||
|
||||
* HtmlContainerControl.cs: Initial implementation.
|
||||
* HtmlControl.cs: Initial implementation.
|
||||
* HtmlGenericControl.cs: Initial implementation.
|
||||
@@ -1,99 +0,0 @@
|
||||
/* System.Web.UI.HtmlControls
|
||||
* Authors
|
||||
* Leen Toelen ([email protected])
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Web;
|
||||
using System.Web.UI;
|
||||
|
||||
namespace System.Web.UI.HtmlControls{
|
||||
|
||||
public class HtmlAnchor : HtmlContainerControl, IPostBackEventHandler{
|
||||
|
||||
private static readonly object EventServerClick;
|
||||
|
||||
static HtmlAnchor(){
|
||||
EventServerClick = new Object();
|
||||
}
|
||||
|
||||
public HtmlAnchor(): base("a"){}
|
||||
|
||||
protected virtual void OnServerClick(EventArgs e){
|
||||
EventHandler handler;
|
||||
handler = (EventHandler) Events[EventServerClick];
|
||||
if(handler != null) handler.Invoke(this, e);
|
||||
}
|
||||
|
||||
protected new void RenderAttributes(HtmlTextWriter writer){
|
||||
if ( Events[EventServerClick] != null){
|
||||
Attributes.Remove("href");
|
||||
base.RenderAttributes(writer);
|
||||
writer.WriteAttribute("href", Page.GetPostBackClientHyperlink(this,String.Empty));
|
||||
}
|
||||
else{
|
||||
PreProcessRelativeReference(writer,"href");
|
||||
RenderAttributes(writer);
|
||||
}
|
||||
}
|
||||
|
||||
void System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(string eventArgument){
|
||||
OnServerClick(EventArgs.Empty);
|
||||
}
|
||||
|
||||
public event EventHandler ServerClick{
|
||||
add{
|
||||
Events.AddHandler(EventServerClick, value);
|
||||
}
|
||||
remove{
|
||||
Events.RemoveHandler(EventServerClick, value);
|
||||
}
|
||||
}
|
||||
|
||||
public string HRef{
|
||||
get{
|
||||
string attr = Attributes["href"];
|
||||
if (attr != null) return attr;
|
||||
return String.Empty;
|
||||
}
|
||||
set{
|
||||
Attributes["href"] = AttributeToString(value);
|
||||
}
|
||||
}
|
||||
|
||||
public string Name{
|
||||
get{
|
||||
string attr = Attributes["name"];
|
||||
if (attr != null) return attr;
|
||||
return String.Empty;
|
||||
}
|
||||
set{
|
||||
Attributes["name"] = AttributeToString(value);
|
||||
}
|
||||
}
|
||||
|
||||
public string Target{
|
||||
get{
|
||||
string attr = Attributes["target"];
|
||||
if (attr != null) return attr;
|
||||
return String.Empty;
|
||||
}
|
||||
set{
|
||||
Attributes["target"] = AttributeToString(value);
|
||||
}
|
||||
}
|
||||
|
||||
public string Title{
|
||||
get{
|
||||
string attr = Attributes["title"];
|
||||
if (attr != null) return attr;
|
||||
return String.Empty;
|
||||
}
|
||||
set{
|
||||
Attributes["title"] = AttributeToString(value);
|
||||
}
|
||||
}
|
||||
|
||||
} // class HtmlAnchor
|
||||
} // namespace System.Web.UI.HtmlControls
|
||||
|
||||
@@ -1,74 +0,0 @@
|
||||
/* System.Web.UI.HtmlControls
|
||||
* Authors
|
||||
* Leen Toelen ([email protected])
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Web;
|
||||
using System.Web.UI;
|
||||
|
||||
namespace System.Web.UI.HtmlControls{
|
||||
|
||||
public class HtmlButton : HtmlContainerControl, IPostBackEventHandler{
|
||||
|
||||
private static readonly object EventServerClick;
|
||||
|
||||
//Checked
|
||||
static HtmlButton(){
|
||||
EventServerClick = new Object();
|
||||
}
|
||||
//Checked
|
||||
public HtmlButton(): base("button"){}
|
||||
|
||||
//Checked
|
||||
protected virtual void OnServerClick(EventArgs e){
|
||||
EventHandler handler;
|
||||
handler = (EventHandler) Events[EventServerClick];
|
||||
if(handler != null){
|
||||
handler.Invoke(this, e);
|
||||
}
|
||||
}
|
||||
|
||||
protected new void RenderAttributes(HtmlTextWriter writer){
|
||||
if (Page != null && Events[EventServerClick] != null){
|
||||
WriteOnClickAttribute(
|
||||
writer,
|
||||
false,
|
||||
true,
|
||||
CausesValidation == false? Page.Validators.Count > 0: false);
|
||||
}
|
||||
base.RenderAttributes(writer);
|
||||
}
|
||||
|
||||
void System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(string eventArgument){
|
||||
if (CausesValidation){
|
||||
Page.Validate();
|
||||
}
|
||||
OnServerClick(EventArgs.Empty);
|
||||
}
|
||||
|
||||
public event EventHandler ServerClick{
|
||||
add{
|
||||
Events.AddHandler(EventServerClick, value);
|
||||
}
|
||||
remove{
|
||||
Events.RemoveHandler(EventServerClick, value);
|
||||
}
|
||||
}
|
||||
|
||||
public bool CausesValidation{
|
||||
get{
|
||||
object attr = ViewState["CausesValidation"];
|
||||
if (attr != null){
|
||||
return (Boolean) attr;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
set{
|
||||
ViewState["CausesValidation"] = (Boolean) value;
|
||||
}
|
||||
}
|
||||
|
||||
} // class HtmlButton
|
||||
} // namespace System.Web.UI.HtmlControls
|
||||
|
||||
@@ -1,83 +0,0 @@
|
||||
//
|
||||
// System.Web.UI.HtmlControls.HtmlContainerControl.cs
|
||||
//
|
||||
// Author
|
||||
// Bob Smith <[email protected]>
|
||||
//
|
||||
// (C) Bob Smith
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.Web;
|
||||
using System.Web.UI;
|
||||
|
||||
//LAMESPEC: The dox talk about HttpException but are very ambigious.
|
||||
//TODO: Check to see if Render really is overridden instead of a LiteralControl being added. It apears that this is the
|
||||
//case due to testing. Anything inside the block is overwritten by the content of this control, so it doesnt apear
|
||||
//to do anything with children.
|
||||
// a doc references this. add? protected override ControlCollection CreateControlCollection();
|
||||
|
||||
//TODO: If Test.InnerText = Test.InnerHtml without ever assigning anything into InnerHtml, you get this:
|
||||
// Exception Details: System.Web.HttpException: Cannot get inner content of Message because the contents are not literal.
|
||||
//[HttpException (0x80004005): Cannot get inner content of Message because the contents are not literal.]
|
||||
// System.Web.UI.HtmlControls.HtmlContainerControl.get_InnerHtml() +278
|
||||
// ASP.test3_aspx.AnchorBtn_Click(Object Source, EventArgs E) in \\genfs2\www24\bobsmith11\test3.aspx:6
|
||||
// System.Web.UI.HtmlControls.HtmlAnchor.OnServerClick(EventArgs e) +108
|
||||
// System.Web.UI.HtmlControls.HtmlAnchor.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +26
|
||||
// System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +18
|
||||
// System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +149
|
||||
// System.Web.UI.Page.ProcessRequestMain() +660
|
||||
|
||||
|
||||
namespace System.Web.UI.HtmlControls
|
||||
{
|
||||
public abstract class HtmlContainerControl : HtmlControl{
|
||||
|
||||
private string _innerHtml = String.Empty;
|
||||
private string _innerText = String.Empty;
|
||||
private bool _doText = false;
|
||||
private bool _doChildren = true;
|
||||
protected string _tagName;
|
||||
|
||||
public HtmlContainerControl() : base(){}
|
||||
|
||||
public HtmlContainerControl(string tag) : base(tag) {}
|
||||
|
||||
public virtual string InnerHtml
|
||||
{
|
||||
get
|
||||
{
|
||||
return _innerHtml;
|
||||
}
|
||||
set
|
||||
{
|
||||
_innerHtml = value;
|
||||
_doText = false;
|
||||
_doChildren = false;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual string InnerText
|
||||
{
|
||||
get
|
||||
{
|
||||
return _innerText;
|
||||
}
|
||||
set
|
||||
{
|
||||
_innerText = value;
|
||||
_doText = true;
|
||||
_doChildren = false;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void Render(HtmlTextWriter writer)
|
||||
{
|
||||
if(_doChildren) RenderChildren(writer);
|
||||
else if(_doText) Page.Server.HtmlEncode(_innerText, writer);
|
||||
else writer.Write(_innerHtml);
|
||||
}
|
||||
|
||||
protected virtual void RenderEndTag(HtmlTextWriter writer){}
|
||||
}
|
||||
}
|
||||
@@ -1,138 +0,0 @@
|
||||
//
|
||||
// System.Web.UI.HtmlControls.HtmlControl.cs
|
||||
//
|
||||
// Author
|
||||
// Bob Smith <[email protected]>
|
||||
//
|
||||
//
|
||||
// (C) Bob Smith
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Web;
|
||||
using System.Web.UI;
|
||||
|
||||
namespace System.Web.UI.HtmlControls{
|
||||
|
||||
public abstract class HtmlControl : Control, IAttributeAccessor
|
||||
{
|
||||
private string _tagName = "span";
|
||||
//TODO: Is this correct, or is the StateBag really the ViewState?
|
||||
private AttributeCollection _attributes = new AttributeCollection(new StateBag(true));
|
||||
private bool _disabled = false;
|
||||
|
||||
public HtmlControl(){}
|
||||
|
||||
public HtmlControl(string tag)
|
||||
{
|
||||
if(tag != null && tag != String.Empty) _tagName = tag;
|
||||
}
|
||||
|
||||
internal static string AttributeToString(int n){
|
||||
if (n != -1)return n.ToString(NumberFormatInfo.InvariantInfo);
|
||||
return null;
|
||||
}
|
||||
|
||||
internal static string AttributeToString(string s){
|
||||
if (s != null && s.Length != 0) return s;
|
||||
return null;
|
||||
}
|
||||
|
||||
internal void PreProcessRelativeReference(HtmlTextWriter writer, string attribName){
|
||||
string attr = Attributes[attribName];
|
||||
if (attr != null){
|
||||
if (attr.Length != 0){
|
||||
try{
|
||||
attr = ResolveUrl(attr);
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new HttpException(attribName + " property had malformed url");
|
||||
}
|
||||
writer.WriteAttribute(attribName, attr);
|
||||
Attributes.Remove(attribName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
string System.Web.UI.IAttributeAccessor.GetAttribute(string name){
|
||||
return Attributes[name];
|
||||
}
|
||||
|
||||
void System.Web.UI.IAttributeAccessor.SetAttribute(string name, string value){
|
||||
Attributes[name] = value;
|
||||
}
|
||||
|
||||
protected virtual void RenderAttributes(HtmlTextWriter writer){
|
||||
if (ID != null){
|
||||
writer.WriteAttribute("id",ClientID);
|
||||
}
|
||||
Attributes.Render(writer);
|
||||
}
|
||||
|
||||
internal static void WriteOnClickAttribute(HtmlTextWriter writer, bool submitsAutomatically, bool submitsProgramatically, bool causesValidation) {
|
||||
string local1;
|
||||
string local2;
|
||||
string local3;
|
||||
|
||||
AttributeCollection attr = Attributes;
|
||||
local1 = null;
|
||||
if (submitsAutomatically) {
|
||||
if ((causesValidation))
|
||||
local1 = System.Web.UI.Utils.GetClientValidateEvent(Page);
|
||||
}
|
||||
else if (submitsProgramatically) {
|
||||
if (causesValidation)
|
||||
local1 = System.Web.UI.Utils.GetClientValidatedPostback(this);
|
||||
else
|
||||
local1 = Page.GetPostBackClientEvent(this, String.Empty);
|
||||
}
|
||||
if (local1 != null) {
|
||||
local2 = attr["language"];
|
||||
if (local2 != null)
|
||||
attr.Remove("language");
|
||||
writer.WriteAttribute("language", "javascript");
|
||||
local3 = attr["onclick"];
|
||||
if (local3 != null) {
|
||||
attr.Remove("onclick");
|
||||
writer.WriteAttribute("onclick", local3 + " " + local1);
|
||||
return;
|
||||
}
|
||||
writer.WriteAttribute("onclick", local1);
|
||||
}
|
||||
}
|
||||
|
||||
public AttributeCollection Attributes
|
||||
{
|
||||
get
|
||||
{
|
||||
return _attributes;
|
||||
}
|
||||
}
|
||||
public bool Disabled
|
||||
{
|
||||
get
|
||||
{
|
||||
return _disabled;
|
||||
}
|
||||
set
|
||||
{
|
||||
_disabled = value;
|
||||
}
|
||||
}
|
||||
public CssStyleCollection Style
|
||||
{
|
||||
get
|
||||
{
|
||||
return _attributes.CssStyle;
|
||||
}
|
||||
}
|
||||
public virtual string TagName
|
||||
{
|
||||
get
|
||||
{
|
||||
return _tagName;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,152 +0,0 @@
|
||||
/* System.Web.UI.HtmlControls
|
||||
* Authors
|
||||
* Leen Toelen ([email protected])
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Web;
|
||||
using System.Web.UI;
|
||||
|
||||
namespace System.Web.UI.HtmlControls{
|
||||
|
||||
public class HtmlForm : HtmlContainerControl{
|
||||
|
||||
private static string SmartNavIncludeScriptKey = "SmartNavIncludeScript";
|
||||
|
||||
public HtmlForm(): base("form"){}
|
||||
|
||||
protected new void RenderAttributes(HtmlTextWriter writer){
|
||||
writer.WriteAttribute("name",RenderedName);
|
||||
Attributes.Remove("name");
|
||||
writer.WriteAttribute("method",Method);
|
||||
Attributes.Remove("method");
|
||||
writer.WriteAttribute("action",Action,true);
|
||||
Attributes.Remove("action");
|
||||
|
||||
string clientOnSubmit = Page.ClientOnSubmitEvent;
|
||||
if (clientOnSubmit != null && clientOnSubmit.Length > 0){
|
||||
if (Attributes["onsubmit"] != null){
|
||||
clientOnSubmit = String.Concat(clientOnSubmit,Attributes["onsubmit"]);
|
||||
Attributes.Remove("onsubmit");
|
||||
}
|
||||
writer.WriteAttribute("language","javascript");
|
||||
writer.WriteAttribute("onsubmit",clientOnSubmit);
|
||||
}
|
||||
if (ID == null){
|
||||
writer.WriteAttribute("id",ClientID);
|
||||
}
|
||||
base.RenderAttributes(writer);
|
||||
}
|
||||
|
||||
//TODO: adapt code for non-IE browsers
|
||||
protected override void Render(HtmlTextWriter output){
|
||||
if (Page.SmartNavigation == true){
|
||||
IAttributeAccessor.SetAttribute("_smartNavigation","true");
|
||||
HttpBrowserCapabilities browserCap = Context.Request.Browser;
|
||||
if (browserCap.Browser.ToLower() != "ie" && browserCap.MajorVersion < 5){
|
||||
base.Render(output);
|
||||
return;
|
||||
}
|
||||
output.WriteLine("<IFRAME ID=_hifSmartNav NAME=_hifSmartNav STYLE=display:none ></IFRAME>");
|
||||
|
||||
if (browserCap.MinorVersion < 0.5 && browserCap.MajorVersion != 5)
|
||||
Page.RegisterClientScriptFile("SmartNavIncludeScript","JScript","SmartNavIE5.js");
|
||||
else if (Page.IsPostBack) Page.RegisterClientScriptFile("SmartNavIncludeScript","JScript","SmartNav.js");
|
||||
base.Render(output);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void RenderChildren(HtmlTextWriter writer){
|
||||
Page.OnFormRender(writer,ClientID);
|
||||
base.RenderChildren(writer);
|
||||
Page.OnFormPostRender(writer,ClientID);
|
||||
}
|
||||
|
||||
protected override void OnInit(EventArgs e){
|
||||
base.OnInit(e);
|
||||
Page.RegisterViewStateHandler();
|
||||
}
|
||||
|
||||
internal string Action{
|
||||
get{
|
||||
string executionFilePath = Context.Request.CurrentExecutionFilePath;
|
||||
string filePath = Context.Request.FilePath;
|
||||
string attr;
|
||||
if (String.ReferenceEquals(executionFilePath, filePath) == true){
|
||||
attr = filePath;
|
||||
int lastSlash = attr.LastIndexOf('/');
|
||||
if (lastSlash >= 0)
|
||||
attr = attr.Substring(lastSlash + 1);
|
||||
}
|
||||
else{
|
||||
attr = Util.UrlPath.MakeRelative(filePath,executionFilePath);
|
||||
}
|
||||
string queryString = Context.Request.QueryStringText;
|
||||
if (queryString != null && queryString.Length > 0)
|
||||
attr = String.Concat(attr, '?', queryString);
|
||||
return attr;
|
||||
}
|
||||
}
|
||||
|
||||
public string EncType{
|
||||
get{
|
||||
string attr = Attributes["enctype"];
|
||||
if (attr != null){
|
||||
return attr;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
set{
|
||||
Attributes["enctype"] = AttributeToString(value);
|
||||
}
|
||||
}
|
||||
|
||||
public string Method{
|
||||
get{
|
||||
string attr = Attributes["method"];
|
||||
if (attr != null){
|
||||
return attr;
|
||||
}
|
||||
return "post";
|
||||
}
|
||||
set{
|
||||
Attributes["method"] = AttributeToString(value);
|
||||
}
|
||||
}
|
||||
|
||||
public string Target{
|
||||
get{
|
||||
string attr = Attributes["target"];
|
||||
if (attr != null){
|
||||
return attr;
|
||||
}
|
||||
return String.Empty;
|
||||
}
|
||||
set{
|
||||
Attributes["target"] = AttributeToString(value);
|
||||
}
|
||||
}
|
||||
|
||||
public string Name{
|
||||
get{
|
||||
string attr = Attributes["name"];
|
||||
if (attr != null){
|
||||
return attr;
|
||||
}
|
||||
return String.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
internal string RenderedName{
|
||||
get{
|
||||
string attr = Name;
|
||||
if (attr.Length > 0){
|
||||
return attr;
|
||||
}
|
||||
return UniqueID;
|
||||
}
|
||||
}
|
||||
|
||||
} // class HtmlForm
|
||||
} // namespace System.Web.UI.HtmlControls
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
//
|
||||
// System.Web.UI.HtmlControls.HtmlGenericControl.cs
|
||||
//
|
||||
// Author:
|
||||
// Bob Smith <[email protected]>
|
||||
//
|
||||
// (C) Bob Smith
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.Web;
|
||||
using System.Web.UI;
|
||||
|
||||
namespace System.Web.UI.HtmlControls{
|
||||
|
||||
public class HtmlGenericControl : HtmlContainerControl {
|
||||
|
||||
public HtmlGenericControl(){}
|
||||
|
||||
public HtmlGenericControl(string tag): base(tag){}
|
||||
|
||||
public new string TagName {
|
||||
get
|
||||
{
|
||||
return _tagName;
|
||||
}
|
||||
set{
|
||||
_tagName = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,90 +0,0 @@
|
||||
/* System.Web.UI.HtmlControls
|
||||
* Authors
|
||||
* Leen Toelen ([email protected])
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Web;
|
||||
using System.Web.UI;
|
||||
using System.Globalization;
|
||||
|
||||
namespace System.Web.UI.HtmlControls{
|
||||
|
||||
public class HtmlImage : HtmlControl{
|
||||
|
||||
public HtmlImage(): base("img"){}
|
||||
|
||||
protected new void RenderAttributes(HtmlTextWriter writer){
|
||||
PreProcessRelativeReference(writer,"src");
|
||||
RenderAttributes(writer);
|
||||
writer.Write(" /");
|
||||
}
|
||||
|
||||
public string Align{
|
||||
get{
|
||||
string attr = Attributes["align"];
|
||||
if (attr != null){
|
||||
return attr;
|
||||
}
|
||||
return String.Empty;
|
||||
}
|
||||
set{
|
||||
Attributes["align"] = AttributeToString(value);
|
||||
}
|
||||
}
|
||||
|
||||
public string Alt{
|
||||
get{
|
||||
string attr = Attributes["alt"];
|
||||
if (attr != null){
|
||||
return attr;
|
||||
}
|
||||
return String.Empty;
|
||||
}
|
||||
set{
|
||||
Attributes["alt"] = AttributeToString(value);
|
||||
}
|
||||
}
|
||||
|
||||
public int Border{
|
||||
get{
|
||||
string attr = Attributes["border"];
|
||||
if (attr != null){
|
||||
return Int32.Parse(attr,CultureInfo.InvariantCulture);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
set{
|
||||
Attributes["border"] = AttributeToString(value);
|
||||
}
|
||||
}
|
||||
|
||||
public string Src{
|
||||
get{
|
||||
string attr = Attributes["src"];
|
||||
if (attr != null){
|
||||
return attr;
|
||||
}
|
||||
return String.Empty;
|
||||
}
|
||||
set{
|
||||
Attributes["src"] = AttributeToString(value);
|
||||
}
|
||||
}
|
||||
|
||||
public int Width{
|
||||
get{
|
||||
string attr = Attributes["width"];
|
||||
if (attr != null){
|
||||
return Int32.Parse(attr,CultureInfo.InvariantCulture);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
set{
|
||||
Attributes["width"] = AttributeToString(value);
|
||||
}
|
||||
}
|
||||
|
||||
} // class HtmlImage
|
||||
} // namespace System.Web.UI.HtmlControls
|
||||
|
||||
Loaded 100 of 1748 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user