@ -612,14 +612,26 @@ namespace Std
public void Dispose ( )
public void Dispose ( )
{
{
Dispose ( disposing : true ) ;
Dispose ( disposing : true , callNativeDtor : _ _ ownsNativeInstance ) ;
}
}
public virtual void Dispose ( bool disposing )
partial void DisposePartial ( bool disposing ) ;
internal protected virtual void Dispose ( bool disposing , bool callNativeDtor )
{
{
if ( _ _ Instance = = IntPtr . Zero )
if ( _ _ Instance = = IntPtr . Zero )
return ;
return ;
NativeToManagedMap . TryRemove ( _ _ Instance , out _ ) ;
NativeToManagedMap . TryRemove ( _ _ Instance , out _ ) ;
DisposePartial ( disposing ) ;
if ( callNativeDtor )
{
var _ _ _ Ty = typeof ( _ Ty ) ;
if ( _ _ _ Ty . IsAssignableFrom ( typeof ( sbyte ) ) )
{
return ;
}
throw new ArgumentOutOfRangeException ( "_Ty" , string . Join ( ", " , new [ ] { typeof ( _ Ty ) . FullName } ) , "global::Std.Allocator<_Ty> maps a C++ template class and therefore it only supports a limited set of types and their subclasses: <sbyte>." ) ;
}
if ( _ _ ownsNativeInstance )
if ( _ _ ownsNativeInstance )
Marshal . FreeHGlobal ( _ _ Instance ) ;
Marshal . FreeHGlobal ( _ _ Instance ) ;
_ _ Instance = IntPtr . Zero ;
_ _ Instance = IntPtr . Zero ;
@ -742,15 +754,18 @@ namespace Std
public void Dispose ( )
public void Dispose ( )
{
{
Dispose ( disposing : true ) ;
Dispose ( disposing : true , callNativeDtor : _ _ ownsNativeInstance ) ;
}
}
public virtual void Dispose ( bool disposing )
partial void DisposePartial ( bool disposing ) ;
internal protected virtual void Dispose ( bool disposing , bool callNativeDtor )
{
{
if ( _ _ Instance = = IntPtr . Zero )
if ( _ _ Instance = = IntPtr . Zero )
return ;
return ;
NativeToManagedMap . TryRemove ( _ _ Instance , out _ ) ;
NativeToManagedMap . TryRemove ( _ _ Instance , out _ ) ;
if ( disposing )
DisposePartial ( disposing ) ;
if ( callNativeDtor )
{
{
var _ _ _ Elem = typeof ( _ Elem ) ;
var _ _ _ Elem = typeof ( _ Elem ) ;
var _ _ _ Traits = typeof ( _ Traits ) ;
var _ _ _ Traits = typeof ( _ Traits ) ;
@ -857,14 +872,17 @@ namespace Std
public void Dispose ( )
public void Dispose ( )
{
{
Dispose ( disposing : true ) ;
Dispose ( disposing : true , callNativeDtor : _ _ ownsNativeInstance ) ;
}
}
public virtual void Dispose ( bool disposing )
partial void DisposePartial ( bool disposing ) ;
internal protected virtual void Dispose ( bool disposing , bool callNativeDtor )
{
{
if ( _ _ Instance = = IntPtr . Zero )
if ( _ _ Instance = = IntPtr . Zero )
return ;
return ;
NativeToManagedMap . TryRemove ( _ _ Instance , out _ ) ;
NativeToManagedMap . TryRemove ( _ _ Instance , out _ ) ;
DisposePartial ( disposing ) ;
if ( _ _ ownsNativeInstance )
if ( _ _ ownsNativeInstance )
Marshal . FreeHGlobal ( _ _ Instance ) ;
Marshal . FreeHGlobal ( _ _ Instance ) ;
_ _ Instance = IntPtr . Zero ;
_ _ Instance = IntPtr . Zero ;