Convert a class(strongly typed dataset) into an interface

  • Thread starter Thread starter Jeff
  • Start date Start date
J

Jeff

I want to remote several strongly typed datasets and I don't want to
distribute the assemblies. I wish to create interface assemblies for
these datasets but I don't know where to start.

I've tried to use soapsuds, but this did not work correctly. I tried
to use NMatrix XofG, but this seems very complicated.

All I need is something that will convert a class file into an
interface. Is there anything already built that will do this? If
not, where do I start to build my own?
 
Jeff,
if I read you correctly you are trying to do the following, take the current
class that you have and redefine it as an interface such as: (copy the file
before editing)

public interface Ifoo

as opposed to

public class foo

then delete the methods and properties that you do not want to expose via
the interface. from there you just clean out your methods and properties and
make them definitions such as

int GetAnInt();

once you have build your interface just implement it in your class as such

public class foo : Ifoo

then you will be able to create and cast the class to the interface like
this

foo Myfoo = new foo();
Ifoo InterfacedFoo = (Ifoo)Myfoo;

and that should work. Sorry for the DR. Souse code.

Kenton
 
Yes, in essence that’s what I’ll be doing. For the remoting server
hosted object, I will use the strongly typed dataset’s file (modifying
each class, the dataset, datatable and datarow to inherit from the
interface class). On the client application I will simply distribute
the interface classes.

But, without a code generation tool to create the interfaces for each of
my strongly typed datasets, it would take too long for us to accomplish
the job.
 
Wait wait wait...

If you expose the strongly typed dataset as a parameter somewhere in the web
service, the web service will actually host the class to the consumers

ie, if you have MyCompany.MyLib.DocumentsDataSet as a return parameter on a
web method, then in the client that References the web method, code that
mimics the DataSet is essentially copied to have the same structure but a
different namespace, making it a near-perfect copy of the implementation in
your library.
 
Sorry I guess I read you wrong, you are looking for a tool that builds an
interface from a class correct. You could write a simple tool that uses
reflection to build the interfaces but I dont know of a tool off the top of
my head.

Kenton
 
That would be great if I were to use webservices, but I don't want that,
I want to use remoting.
 
Hi Jeff,

If you only want to conver the strong typed datasets, you may consider
generate some classes from XSD file with xsd.exe. This tool will generates
runtime classes from an XSD schema file. You can compile these classed and
integrated in the client appplication. They are not interfaces, however, I
think it is also an thin client.

Hope this help,

Luke
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 
Sorry, didnt read it thoroughly.

refer to "MSFT"'s suggestion of establishing the XSD in both places, which
will generate the exact same layout and structure

what was the original reason of not wanting to distribute the assembly with
the dataset? perhaps just build an assembly with the public types that you
and the clients can have access to... (dont forget to strong name it for
opening the door to proper security)
 
Back
Top