本文整理汇总了C#中Point.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# Point.GetType方法的具体用法?C# Point.GetType怎么用?C# Point.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Point
的用法示例。
在下文中一共展示了Point.GetType方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main3
public static void Main3()
{
// Create two Point instances on the stack.
Point p1 = new Point(10, 10);
Point p2 = new Point(20, 20);
// p1 does NOT get boxed to call ToString (a virtual method).
Console.WriteLine(p1.ToString());// "(10, 10)"
// p DOES get boxed to call GetType (a non-virtual method).
Console.WriteLine(p1.GetType());// "Point"
// p1 does NOT get boxed to call CompareTo.
// p2 does NOT get boxed because CompareTo(Point) is called.
Console.WriteLine(p1.CompareTo(p2));// "-1"
// p1 DOES get boxed, and the reference is placed in c.
IComparable c = p1;
Console.WriteLine(c.GetType());// "Point"
// p1 does NOT get boxed to call CompareTo.
// Since CompareTo is not being passed a Point variable,
// CompareTo(Object) is called which requires a reference to
// a boxed Point.
// c does NOT get boxed because it already refers to a boxed Point.
Console.WriteLine(p1.CompareTo(c));// "0"
// c does NOT get boxed because it already refers to a boxed Point.
// p2 does get boxed because CompareTo(Object) is called.
Console.WriteLine(c.CompareTo(p2));// "-1"
// c is unboxed, and fields are copied into p2.
p2 = (Point)c;
// Proves that the fields got copied into p2.
Console.WriteLine(p2.ToString());// "(10, 10)"
}
示例2: Main
public static void Main()
{
Point p = new Point(7, 3);
p.Print();
Console.WriteLine(p.ToString()); // Redefinido em Point
Console.WriteLine(p.GetType()); // box + call
Console.WriteLine(p.GetHashCode()); // Herdado de Object
}
示例3: Main
static void Main()
{
A a = new A();
Point p = new Point(7, 11);
Type typeOfA = a.GetType();
Type typeOfPoint = p.GetType();
}
示例4: PointShouldBeValidWithCorrectValues
public void PointShouldBeValidWithCorrectValues()
{
var newPoint = new Point(10, 10, 102100);
newPoint.Should().Not.Be.Null();
newPoint.GetType().Should().Be<Point>();
newPoint.X.Should().Be(10);
newPoint.Y.Should().Be(10);
newPoint.SpatialReference.WKID.Should().Be(102100);
}
示例5: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
Point p = new Point(100, 200);
JavaScriptSerializer jss = new JavaScriptSerializer();
string json = jss.Serialize(p);
JsonOutput.Text = HttpUtility.HtmlEncode (json);
MemoryStream ms = new MemoryStream();
XmlSerializer xs = new XmlSerializer(p.GetType());
xs.Serialize(ms, p);
string xml = new ASCIIEncoding().GetString(ms.ToArray());
XmlOutput.Text = HttpUtility.HtmlEncode (xml);
}
示例6: ClickablePointPropertyTest
public virtual void ClickablePointPropertyTest ()
{
IRawElementProviderSimple provider = GetProvider ();
bool offscreen
= (bool) provider.GetPropertyValue (AutomationElementIdentifiers.IsOffscreenProperty.Id);
object clickablePointObj
= provider.GetPropertyValue (AutomationElementIdentifiers.ClickablePointProperty.Id);
Point clickablePoint = new Point (0, 0);
// Clickable point should be either null or Rect.Empty
if (offscreen) {
if (clickablePointObj != null) {
try {
clickablePoint = (Point) clickablePointObj;
Assert.IsTrue (clickablePoint.X >= 0,
string.Format ("X is negative, your provider should be OffScreen: {0}", clickablePoint.X));
Assert.IsTrue (clickablePoint.Y >= 0,
string.Format ("Y is negative, your provider should be OffScreen: {0}", clickablePoint.Y));
} catch (InvalidCastException) {
Assert.Fail (string.Format ("You are not returning System.Windows.Point in ClickablePointProperty: {0}",
clickablePoint,GetType ()));
}
}
// Clickable point should intersect bounding rectangle...
} else {
if (clickablePointObj == null) // ...unless you are not clickable at all
return;
Assert.IsNotNull (clickablePoint,
"Your ClickablePointProperty should not be null.");
try {
clickablePoint = (Point) clickablePointObj;
Assert.IsTrue (clickablePoint.X >= 0,
string.Format ("X is negative, your provider should be OffScreen: {0}", clickablePoint.X));
Assert.IsTrue (clickablePoint.Y >= 0,
string.Format ("Y is negative, your provider should be OffScreen: {0}", clickablePoint.Y));
} catch (InvalidCastException) {
Assert.Fail (string.Format ("You are not returning System.Windows.Point in ClickablePointProperty: {0}",
clickablePoint.GetType ()));
}
object boundingRectangle
= provider.GetPropertyValue (AutomationElementIdentifiers.BoundingRectangleProperty.Id);
Assert.IsNotNull (boundingRectangle,
"You need to return BoundingRectangle if you return ClickablePointProperty.");
try {
Rect boundingRectangleRect = (Rect) boundingRectangle;
Assert.AreNotEqual (Rect.Empty,
boundingRectangleRect,
"BoundingRectangle SHOULD NOT be Rect.Empty");
Rect clickablePointRect = new Rect (clickablePoint.X, clickablePoint.Y, 1, 1);
Assert.IsTrue (boundingRectangleRect.Contains (clickablePointRect),
string.Format ("ClickablePoint ({0}) SHOULD Intersect with BoundingRectangle: {1}",
clickablePointRect.ToString (),
boundingRectangleRect.ToString ()));
} catch (InvalidCastException) {
Assert.Fail (string.Format ("You are not returning System.Windows.Rect in BoundingRectangle: {0}",
boundingRectangle.GetType ()));
}
}
}
示例7: Equals
/// <summary>
/// Compares for reference AND value equality.
/// </summary>
/// <param name="obj">The object to compare with this instance.</param>
/// <returns>
/// <c>true</c> if both operands are equal; otherwise, <c>false</c>.
/// </returns>
public bool Equals(Point obj)
{
bool ivarsEqual = true;
if (obj.GetType() != this.GetType())
{
return false;
}
if (this._x != obj._x)
{
ivarsEqual = false;
}
if (this._y != obj._y)
{
ivarsEqual = false;
}
return ivarsEqual;
}
示例8: equals
/**
* The equals method doesn't always work--mostly on on classes that consist only of primitives. Be careful.
*/
public bool equals(Point rhs)
{
bool ivarsEqual = true;
if(rhs.GetType() != this.GetType())
return false;
if( ! (_x == rhs._x)) ivarsEqual = false;
if( ! (_y == rhs._y)) ivarsEqual = false;
return ivarsEqual;
}
示例9: XMLDeserializer
private static Point XMLDeserializer()
{
FileStream stream = new FileStream("data.xml", FileMode.Open, FileAccess.Read);
Point p = new Point();
XmlSerializer serializer = new XmlSerializer(p.GetType());
p = (Point)serializer.Deserialize(stream);
stream.Close();
return p;
}