You've already forked linux-packaging-mono
Imported Upstream version 4.8.0.309
Former-commit-id: 5f9c6ae75f295e057a7d2971f3a6df4656fa8850
This commit is contained in:
parent
ee1447783b
commit
94b2861243
45
external/cecil/Mono/Disposable.cs
vendored
Normal file
45
external/cecil/Mono/Disposable.cs
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
//
|
||||
// Author:
|
||||
// Jb Evain (jbevain@gmail.com)
|
||||
//
|
||||
// Copyright (c) 2008 - 2015 Jb Evain
|
||||
// Copyright (c) 2008 - 2011 Novell, Inc.
|
||||
//
|
||||
// Licensed under the MIT/X11 license.
|
||||
//
|
||||
|
||||
using System;
|
||||
|
||||
namespace Mono {
|
||||
|
||||
static class Disposable {
|
||||
|
||||
public static Disposable<T> Owned<T> (T value) where T : class, IDisposable
|
||||
{
|
||||
return new Disposable<T> (value, owned: true);
|
||||
}
|
||||
|
||||
public static Disposable<T> NotOwned<T> (T value) where T : class, IDisposable
|
||||
{
|
||||
return new Disposable<T> (value, owned: false);
|
||||
}
|
||||
}
|
||||
|
||||
struct Disposable<T> : IDisposable where T : class, IDisposable {
|
||||
|
||||
internal readonly T value;
|
||||
readonly bool owned;
|
||||
|
||||
public Disposable (T value, bool owned)
|
||||
{
|
||||
this.value = value;
|
||||
this.owned = owned;
|
||||
}
|
||||
|
||||
public void Dispose ()
|
||||
{
|
||||
if (value != null && owned)
|
||||
value.Dispose ();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user