本文整理汇总了C#中NSObject.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# NSObject.ToString方法的具体用法?C# NSObject.ToString怎么用?C# NSObject.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NSObject
的用法示例。
在下文中一共展示了NSObject.ToString方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DescriptionForValue
// Returns the description for a provided value, taking the characteristic's metadata and possible values into account.
public static string DescriptionForValue(this HMCharacteristic self, NSObject value)
{
if (self.IsWriteOnly ())
return "Write-Only Characteristic";
var number = value as NSNumber;
return number != null ? self.DescriptionForValue (number.Int32Value) : value.ToString ();
}
示例2: Awake
public override void Awake(NSObject context)
{
base.Awake (context);
// Configure interface objects here.
if (context is NSString) {
contextFromPreviousScreen = context.ToString ();
}
Console.WriteLine ("{0} awake with context", this);
}
示例3: SetObjectValue
public override void SetObjectValue (NSTableView tableView, NSObject editedVal, NSTableColumn col, nint row)
{
try {
if (Entries != null && !string.IsNullOrEmpty (editedVal.ToString ())) {
if (col.Identifier == "Value") {
string currKey = this.Entries.Keys.ElementAt ((int)row);
if (currKey != "objectClass") {
VMDirBagItem currVal = this.Entries [currKey];
this.Entries [currKey] = new VMDirBagItem {
Description = currVal.Description,
IsReadOnly = currVal.IsReadOnly,
IsRequired = currVal.IsRequired,
Value = Utilities.StringToLdapValue ((NSString)editedVal)
};
this.PendingMod.Add (currKey, (NSString)Utilities.LdapValueToString (this.Entries [currKey].Value));
}
}
}
} catch (Exception e) {
System.Diagnostics.Debug.WriteLine ("Error in List Operation " + e.Message);
}
}
示例4: InsertText
public override void InsertText (NSObject insertString)
{
if (!((TextBoxBase)Host.Host).Multiline && insertString.ToString () == "\n")
return ;
base.InsertText (insertString);
}
示例5: SetValueForKey
public override void SetValueForKey(NSObject value, NSString key)
{
if (key == "bindingText")
BindingText = value.ToString();
}
示例6: ContinueUserActivity
public override bool ContinueUserActivity (UIApplication application, NSUserActivity userActivity, UIApplicationRestorationHandler completionHandler)
{
switch (userActivity.ActivityType)
{
case "com.micjames.beerdrinkin.mybeers":
break;
case "com.micjames.beerdrinkin.wishlist":
break;
case "com.micjames.beerdrinkin.search":
break;
case "com.micjames.beerdrinkin.profile":
break;
case "com.micjames.beerdrinkin.beerdetails":
var info = userActivity.UserInfo;
if (this.Window.RootViewController.ChildViewControllers[0] is UITabBarController)
{
var tabController = this.Window.RootViewController.ChildViewControllers[0] as UITabBarController;
tabController.SelectedIndex = 2;
var beerItem = new BeerItem();
var id = new NSObject();
info.TryGetValue(new NSString("id"), out id);
var name = new NSObject();
info.TryGetValue(new NSString("name"), out name);
var description = new NSObject();
info.TryGetValue(new NSString("description"), out description);
var imageUrl = new NSObject();
info.TryGetValue(new NSString("imageUrl"), out imageUrl);
var breweryDbId = new NSObject();
info.TryGetValue(new NSString("breweryDbId"), out breweryDbId);
beerItem.Name = name.ToString();
beerItem.Description = description.ToString();
beerItem.ImageMedium = imageUrl.ToString();
beerItem.BreweryDbId = breweryDbId.ToString();
if (!string.IsNullOrEmpty(beerItem.BreweryDbId))
{
var storyboard = UIStoryboard.FromName("Main", null);
var vc = storyboard.InstantiateViewController ("beerDescriptionTableView") as BeerDescriptionTableView;
vc.SetBeer (beerItem);
var navigationControler = tabController.SelectedViewController as UINavigationController;
navigationControler.PushViewController (vc, true);
}
}
break;
}
return true;
}
示例7: SetObjectValue
public override void SetObjectValue (NSTableView tableView, NSObject editedVal, NSTableColumn col, nint row)
{
try {
if (data != null && !string.IsNullOrEmpty (editedVal.ToString ())) {
if (col.Identifier == "Value") {
string currKey = this.data [(int)row].Key;
if (currKey != "objectClass") {
this.data [(int)row] = new KeyValuePair<string, string> (currKey, (NSString)editedVal);
this.PendingMod.Add (currKey, this.data [(int)row].Value);
}
}
}
} catch (Exception e) {
System.Diagnostics.Debug.WriteLine ("Error in List Operation " + e.Message);
}
}
示例8: ToObject
/// <summary>
/// Converts to an object.
/// </summary>
/// <returns>The object.</returns>
/// <param name="nsO">Ns o.</param>
/// <param name="targetType">Target type.</param>
public static Object ToObject (NSObject nsO, Type targetType)
{
if (nsO is NSString) {
return nsO.ToString ();
}
if (nsO is NSDate) {
var nsDate = (NSDate)nsO;
return DateTime.SpecifyKind ((DateTime)nsDate, DateTimeKind.Unspecified);
}
if (nsO is NSDecimalNumber) {
return decimal.Parse (nsO.ToString (), CultureInfo.InvariantCulture);
}
if (nsO is NSNumber) {
var x = (NSNumber)nsO;
switch (Type.GetTypeCode (targetType)) {
case TypeCode.Boolean:
return x.BoolValue;
case TypeCode.Char:
return Convert.ToChar (x.ByteValue);
case TypeCode.SByte:
return x.SByteValue;
case TypeCode.Byte:
return x.ByteValue;
case TypeCode.Int16:
return x.Int16Value;
case TypeCode.UInt16:
return x.UInt16Value;
case TypeCode.Int32:
return x.Int32Value;
case TypeCode.UInt32:
return x.UInt32Value;
case TypeCode.Int64:
return x.Int64Value;
case TypeCode.UInt64:
return x.UInt64Value;
case TypeCode.Single:
return x.FloatValue;
case TypeCode.Double:
return x.DoubleValue;
}
}
if (nsO is NSValue) {
var v = (NSValue)nsO;
if (targetType == typeof(IntPtr)) {
return v.PointerValue;
}
if (targetType == typeof(CGSize)) {
return v.SizeFValue;
}
if (targetType == typeof(CGRect)) {
return v.RectangleFValue;
}
if (targetType == typeof(CGPoint)) {
return v.PointFValue;
}
}
return nsO;
}
示例9: WriteKeyAndValueToOutput
//========================================================================
//========================================================================
/// <summary>
/// Writes out the key and value information to the console, useful for debugging,
/// or understanding how the user preferences are stored.
/// </summary>
private static void WriteKeyAndValueToOutput(NSDictionary dict, NSObject key)
{
Console.Write (key.ToString () + ":");
if (dict[key] is NSString)
{
Console.WriteLine (dict[key].ToString ());
}
else
{
switch (dict[key].GetType ().ToString ())
{
case "MonoTouch.Foundation.NSNumber":
Console.WriteLine ((dict[key] as NSNumber).FloatValue.ToString ());
break;
case "MonoTouch.Foundation.NSArray":
Console.WriteLine ("");
NSArray items = dict[key] as NSArray;
for (uint j = 0; j < items.Count; j++)
{
Console.WriteLine ("\t" + NSString.FromHandle (items.ValueAt (j)).ToString ());
}
break;
}
}
}