xamarin-macios/src/AddressBookUI/ABAddressFormatting.cs

44 строки
1.4 KiB
C#
Исходник Обычный вид История

2016-04-21 15:30:02 +03:00
//
// ABAddressFormatting.cs:
//
// Authors:
// Sebastien Pouliot <sebastien@xamarin.com>
//
// Copyright (C) 2012 Xamarin Inc. All rights reserved.
//
#nullable enable
2016-04-21 15:30:02 +03:00
using System;
using System.Runtime.InteropServices;
using Foundation;
using ObjCRuntime;
2016-04-21 15:30:02 +03:00
namespace AddressBookUI {
2016-04-21 15:30:02 +03:00
// http://developer.apple.com/library/ios/#DOCUMENTATION/AddressBookUI/Reference/AddressBookUI_Functions/Reference/reference.html#//apple_ref/c/func/ABCreateStringWithAddressDictionary
#if NET
[UnsupportedOSPlatform ("ios9.0")]
#if IOS
[Obsolete ("Starting with ios9.0 use the 'Contacts' API instead.", DiagnosticId = "BI1234", UrlFormat = "https://github.com/xamarin/xamarin-macios/wiki/Obsolete")]
#endif
#else
[Deprecated (PlatformName.iOS, 9, 0, message : "Use the 'Contacts' API instead.")]
#endif
2016-04-21 15:30:02 +03:00
static public class ABAddressFormatting {
[DllImport (Constants.AddressBookUILibrary)]
static extern IntPtr /* NSString */ ABCreateStringWithAddressDictionary (IntPtr /* NSDictionary */ address, [MarshalAs (UnmanagedType.I1)] bool addCountryName);
2016-04-21 15:30:02 +03:00
static public string ToString (NSDictionary address, bool addCountryName)
{
if (address is null)
ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (address));
2016-04-21 15:30:02 +03:00
using (NSString s = new NSString (ABCreateStringWithAddressDictionary (address.Handle, addCountryName)))
return s.ToString ();
}
}
}