本文整理汇总了C#中NSObject.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# NSObject.GetType方法的具体用法?C# NSObject.GetType怎么用?C# NSObject.GetType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NSObject
的用法示例。
在下文中一共展示了NSObject.GetType方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: IsEqual
public override bool IsEqual (NSObject obj)
{
if (obj.GetType () != typeof(MyCollectionViewGridLayoutAttributes))
return false;
var other = (MyCollectionViewGridLayoutAttributes)obj;
if (!base.IsEqual (other))
return false;
if (!BackgroundColor.Equals (other.BackgroundColor))
return false;
return true;
}
示例2: CheckHandle
protected override void CheckHandle(NSObject obj)
{
bool result = obj.Handle != IntPtr.Zero;
if (!result) {
string name = obj.GetType ().Name;
switch (name) {
// FIXME: it's not clear what's the alternative to 'init' and it could be because I have no phone device
case "CTCallCenter":
case "CTTelephonyNetworkInfo":
return;
// to avoid crashes we do not really create (natively) default instances (iOS gives them to us)
// for compatibility purpose - we should never had included the default .ctor in monotouch.dll
case "CAMediaTimingFunction":
case "CLHeading":
case "CLRegion":
case "CLPlacemark":
case "CMAccelerometerData":
case "CMLogItem":
case "CMAttitude":
case "CMDeviceMotion":
case "CMGyroData":
case "CMMagnetometerData":
return;
// under iOS5 only - MPMediaPickerController: Unable to access iPod library.
case "MPMediaPickerController":
return;
// re-enabled as an [Obsolete ("", true)] but it will crash if we create it (which we can since we use reflection)
case "NSTimer":
case "NSCompoundPredicate":
return;
// iOS9 - the instance was "kind of valid" before
case "PKPaymentAuthorizationViewController":
if (CheckiOSSystemVersion (9,0))
return;
break;
}
base.CheckHandle (obj);
}
}
示例3: Scrub
partial void Scrub (NSObject sender)
{
if(sender.GetType() == typeof(UISlider) && !IsSeeking)
{
IsSeeking = true;
UISlider slider = (UISlider)sender;
CMTime playerDuration = _playerItem.Duration;
if(playerDuration == CMTime.Invalid){
return;
}
double duration = playerDuration.Seconds;
if(!double.IsInfinity(duration) && !double.IsNaN(duration))
{
float minValue = slider.MinValue;
float maxValue = slider.MaxValue;
float value = slider.Value;
double time = duration * (value - minValue) / (maxValue - minValue);
_player.Seek(CMTime.FromSeconds(time, NSEC_PER_SEC), async delegate(bool finished) {
IsSeeking = false;
});
/*TODO We can update time labels here */
}
}
}
示例4: CheckToString
protected override void CheckToString(NSObject obj)
{
string name = obj.GetType ().Name;
switch (name) {
// crash at at MonoTouch.Foundation.NSObject.get_Description () [0x0000b] in /mono/ios/monotouch-ios7/monotouch/src/Foundation/NSObject.g.cs:500
case "SKTexture":
case "MCSession":
// crash at at MonoTouch.Foundation.NSObject.get_Description () [0x0000b] in /Developer/MonoTouch/Source/monotouch/src/Foundation/NSObject.g.cs:554
case "AVPlayerItemTrack":
case "AVCaptureConnection":
return;
// worked before ios6.0 beta 1
case "AVComposition":
// new API in iOS7
case "AVAssetResourceLoadingDataRequest":
// Objective-C exception thrown. Name: NSInvalidArgumentException Reason: Unable to create description in descriptionForLayoutAttribute_layoutItem_coefficient. Something is nil
case "NSLayoutConstraint":
// new in 6.0
case "AVAssetResourceLoadingRequest":
case "GKScoreChallenge": // Objective-C exception thrown. Name: NSInvalidArgumentException Reason: -[GKScoreChallenge challengeID]: unrecognized selector sent to instance 0x18acc340
case "GKAchievementChallenge": // Objective-C exception thrown. Name: NSInvalidArgumentException Reason: -[GKAchievementChallenge challengeID]: unrecognized selector sent to instance 0x160f4840
if (CheckiOSOrTVOSSystemVersion (6,0))
return;
break;
// crash (when asking `description`) under iOS5 (only) simulator
case "NSUrlConnection":
return;
// iOS 9 beta 1 - crash when called
case "WKFrameInfo":
case "WKNavigation":
case "WKNavigationAction":
if (CheckiOSSystemVersion (9,0))
return;
break;
default:
base.CheckToString (obj);
break;
}
}
示例5: CheckNSObjectProtocol
protected override void CheckNSObjectProtocol(NSObject obj)
{
switch (obj.GetType ().Name) {
case "NSString":
// according to bots `isKindOf (null)` returns true before iOS 8, ref: #36726
if (!CheckiOSOrTVOSSystemVersion (8, 0))
return;
break;
}
base.CheckNSObjectProtocol (obj);
}
示例6: Write
static void Write (string desc, NSObject value)
{
Console.Write ("# Extra Tests: {0}={1}", desc, value);
Console.Write ("; Null? {0}; Type={1}", value == null, value == null ? "<none>" : value.GetType().Name);
Console.WriteLine ();
}
示例7: StringFor
// Gets the string for the text field from the object passed in.
public override string StringFor(NSObject value)
{
// Not a color?
if (value.GetType() != typeof(NSColor)) {
return null;
}
// Convert to an RGB color space
NSColor color = ((NSColor)value).UsingColorSpace(NSColorSpace.CalibratedRGB);
// Get components as floats between 0 and 1
nfloat red, green, blue, alpha;
color.GetRgba(out red, out green, out blue, out alpha);
// Initialize the distance to something large
double minDistance = 3.0f;
string closestKey = "";
// Find the closest color
foreach (string key in colorList.AllKeys()) {
NSColor c = colorList.ColorWithKey(key);
nfloat r, g, b, a;
c.GetRgba(out r, out g, out b, out a);
// How far apart are color and c?
double distance = (Math.Pow(red - r, 2) + Math.Pow(green - g, 2) + Math.Pow(blue - b, 2));
// Is this the closest yet?
if (distance < minDistance) {
minDistance = distance;
closestKey = key;
}
}
return closestKey;
}
示例8: PrepareForSegue
public override void PrepareForSegue(UIStoryboardSegue segue, NSObject sender)
{
//photoDetailController controller = segue.DestinationViewController as photoDetailController;
Console.WriteLine ("Preparing for segue: " + segue.ToString ());
Console.WriteLine ("From object: " + sender.GetType ().ToString ());
}