Table of Contents

Class CFObject

Namespace
CarinaStudio.MacOS.CoreFoundation
Assembly
CarinaStudio.AppBase.MacOS.dll

Object of Core Foundation.

public class CFObject : IShareableDisposable<CFObject>, IDisposable
Inheritance
CFObject
Implements
Derived
Inherited Members
Extension Methods

Constructors

CFObject(IntPtr, bool)

Initialize new CFObject instance.

protected CFObject(IntPtr handle, bool ownsInstance)

Parameters

handle nint

Handle of instance.

ownsInstance bool

True to get ownership of instance.

CFObject(IntPtr, uint, bool)

Initialize new CFObject instance.

protected CFObject(IntPtr handle, uint typeId, bool ownsInstance)

Parameters

handle nint

Handle of instance.

typeId uint

Type ID.

ownsInstance bool

True to get ownership of instance.

Properties

Handle

Get native handle of instance.

public IntPtr Handle { get; }

Property Value

nint

IsDefaultInstance

Check whether the instance is default instance which cannot be released or not.

public bool IsDefaultInstance { get; protected set; }

Property Value

bool

IsReleased

Check whether instance has been released or not.

public bool IsReleased { get; }

Property Value

bool

TypeDescription

Get description of type.

public string TypeDescription { get; }

Property Value

string

TypeId

Get type ID.

public uint TypeId { get; }

Property Value

uint

Methods

Equals(object?)

Determines whether the specified object is equal to the current object.

public override bool Equals(object? obj)

Parameters

obj object

The object to compare with the current object.

Returns

bool

true if the specified object is equal to the current object; otherwise, false.

~CFObject()

Finalizer.

protected ~CFObject()

FromHandle(IntPtr, bool)

Wrap a native object.

public static CFObject FromHandle(IntPtr cf, bool ownsInstance = false)

Parameters

cf nint

Handle of instance.

ownsInstance bool

True to owns the native object.

Returns

CFObject

Wrapped object.

FromHandle(Type, IntPtr, bool)

Wrap a native object.

public static CFObject FromHandle(Type type, IntPtr cf, bool ownsInstance = false)

Parameters

type Type

Target type.

cf nint

Handle of instance.

ownsInstance bool

True to owns the native object.

Returns

CFObject

Wrapped object.

FromHandle<T>(IntPtr, bool)

Wrap a native object.

public static T FromHandle<T>(IntPtr cf, bool ownsInstance = false) where T : CFObject

Parameters

cf nint

Handle of instance.

ownsInstance bool

True to owns the native object.

Returns

T

Wrapped object.

Type Parameters

T

Target type.

GetHashCode()

Serves as the default hash function.

public override int GetHashCode()

Returns

int

A hash code for the current object.

OnRelease()

Called when releasing instance.

public virtual void OnRelease()

Release()

Release the instance.

public void Release()

Release(IntPtr)

Release given instance.

public static void Release(IntPtr cf)

Parameters

cf nint

Handle of instance.

Retain()

Retain the object.

public virtual CFObject Retain()

Returns

CFObject

New instance of retained object.

Retain(IntPtr)

Retain given instance.

public static IntPtr Retain(IntPtr cf)

Parameters

cf nint

Handle of instance.

Returns

nint

Handle of retained instance.

Retain<T>()

Retain the object with specific type.

public T Retain<T>() where T : CFObject

Returns

T

New instance of retained object.

Type Parameters

T

Specific type.

ToString()

Returns a string that represents the current object.

public override string? ToString()

Returns

string

A string that represents the current object.

VerifyReleased()

Throw ObjectDisposedException if instance has been released.

protected void VerifyReleased()

Operators

operator ==(CFObject?, CFObject?)

Equality operator.

public static bool operator ==(CFObject? l, CFObject? r)

Parameters

l CFObject
r CFObject

Returns

bool

operator !=(CFObject?, CFObject?)

Inequality operator.

public static bool operator !=(CFObject? l, CFObject? r)

Parameters

l CFObject
r CFObject

Returns

bool