[libvirt] C# bindings need and advice from the experts

arnaud.champion at devatom.fr arnaud.champion at devatom.fr
Fri Jan 28 10:28:06 UTC 2011


?Hi,

I'm working on C# bindings. The goal is to obtain a more C# API for the API users.
So I have create object for libvirt familly function (an object Connect, Domain, Storage and so on).

All is almost done, but I need and advice about the way to handle object properties. For example, for the Connect object, I expose a "RunningDomains" property that can be used in this manner :

Connect myConn = new Connect("qemu+tcp://192.168.220.198/system");
List<Domain> runningDomains = myConn.RunningsDomains;

In the Connect object, the property "RunningDomains" is coded in this :

/// <summary>

/// Get the list of running domains

/// </summary>

public List<Domain> RunningDomains

{

    get

    {

        if (_conn == IntPtr.Zero) return null;

        int nbRunningDomain = NumOfDomains(_conn);

        int[] runningDomainIds = new int[nbRunningDomain];

        ListDomains(_conn, runningDomainIds, nbRunningDomain);

        return runningDomainIds.Select(id => new Domain(Domain.LookupByID(_conn, id), this)).ToList();

    }

}



So the property call "virConnectNumOfDomains" and "virConnectListDomains" each time the property is called. And I don't know if it is a good thing. The other way, is to keep the list in the Connect object and handle domain adding or removing in this via callbacks. This avoid multiple call to the librar.



Any advice ?



Regards,



Arnaud
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20110128/1de37276/attachment-0001.htm>


More information about the libvir-list mailing list