Simplified object lifecycle verification.

This commit is contained in:
antiduh
2014-07-01 18:40:35 +00:00
parent 2e6962bcc0
commit ce64bf9d9a

View File

@@ -38,10 +38,7 @@ namespace NSspi.Credentials
{ {
get get
{ {
if( this.disposed ) CheckLifecycle();
{
throw new ObjectDisposedException( base.GetType().Name );
}
return this.securityPackage; return this.securityPackage;
} }
@@ -56,10 +53,7 @@ namespace NSspi.Credentials
string name = null; string name = null;
bool gotRef = false; bool gotRef = false;
if( this.disposed ) CheckLifecycle();
{
throw new ObjectDisposedException( "Credential" );
}
status = SecurityStatus.InternalError; status = SecurityStatus.InternalError;
carrier = new QueryNameAttribCarrier(); carrier = new QueryNameAttribCarrier();
@@ -117,21 +111,15 @@ namespace NSspi.Credentials
{ {
get get
{ {
if( this.disposed ) CheckLifecycle();
{
throw new ObjectDisposedException( "Credential" );
}
return this.expiry; return this.expiry;
} }
protected set protected set
{ {
if( this.disposed ) CheckLifecycle();
{
throw new ObjectDisposedException( "Credential" );
}
this.expiry = value; this.expiry = value;
} }
} }
@@ -140,20 +128,14 @@ namespace NSspi.Credentials
{ {
get get
{ {
if( this.disposed ) CheckLifecycle();
{
throw new ObjectDisposedException( "Credential" );
}
return this.safeCredHandle; return this.safeCredHandle;
} }
protected set protected set
{ {
if( this.disposed ) CheckLifecycle();
{
throw new ObjectDisposedException( "Credential" );
}
this.safeCredHandle = value; this.safeCredHandle = value;
} }
@@ -177,5 +159,13 @@ namespace NSspi.Credentials
this.disposed = true; this.disposed = true;
} }
} }
private void CheckLifecycle()
{
if( this.disposed )
{
throw new ObjectDisposedException( "Credential" );
}
}
} }
} }