misterstick
Programmer
i have a wrapper which provides access to a web service.
i'd like to provide a lookup facility on the wrapper so that the developer can write code like this:
my initial thought was to have the lookup code in a class wholly contained by the wrapper.
the actual database call to do the lookup should be via a wrapper object. i could create a new one, but since the lookup is wholly contained by a wrapper object this seems unnecessary.
is there a way i can get at the containing instance of the parent class?
do i have to cache a pointer to it in the contained class?
if it's IDisposable, would i have to make the contained class IDisposable too and dispose of the pointer?
forgive my overdensity,
many thanks,
mr s. <
i'd like to provide a lookup facility on the wrapper so that the developer can write code like this:
Code:
string code = arbitraryValue;
Wrapper wrapper = new Wrapper();
if ( wrapper.Code.Exists(code) )
{
txtField1.Text = wrapper.Code.Description;
txtField2.Text = wrapper.Code.OtherData;
}
my initial thought was to have the lookup code in a class wholly contained by the wrapper.
Code:
public class Wrapper
{
public class CodeLookup
{
public bool Exists(string code)
{
CodeTable record = [red]wrapper[/red].LookupByKey(code);
if ( record == null ) return false;
return true;
}
//...
private CodeLookup lookup = new CodeLookup();
public CodeLookup Code { get { return lookup; } }
}
}
the actual database call to do the lookup should be via a wrapper object. i could create a new one, but since the lookup is wholly contained by a wrapper object this seems unnecessary.
is there a way i can get at the containing instance of the parent class?
do i have to cache a pointer to it in the contained class?
if it's IDisposable, would i have to make the contained class IDisposable too and dispose of the pointer?
forgive my overdensity,
many thanks,
mr s. <