Announcement

Collapse
No announcement yet.

API Namespace wierdness

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    API Namespace wierdness

    I've noticed that when coding in C# I have to add an additional qualifier to certain types. It's easiest to illustrate by example:

    VB
    Code:
    Dim DT As New DeviceTypeInfo
    DT.Device_Type = DeviceTypeInfo.eDeviceAPI.Plug_In
    The same code must be written in C# as this:
    Code:
    DeviceTypeInfo_m.DeviceTypeInfo dt = new DeviceTypeInfo_m.DeviceTypeInfo();
    dt.Device_Type = (int) DeviceTypeInfo_m.DeviceTypeInfo.eDeviceAPI.Plug_In;
    Why do I specifically have to reference DeviceTypeInfo_m? Since the compiler can't find DeviceTypeInfo on its own it makes finding my way through the API rather difficult. Right now I'm having to go back to the VB sample plugin and look up type definitions in order to figure out how to reference them in C#.
    HS Pro 3.0 | Linux Ubuntu 16.04 x64 virtualized under Proxmox (KVM)
    Hardware: Z-NET - W800 Serial - Digi PortServer TS/8 and TS/16 serial to Ethernet - Insteon PLM - RFXCOM - X10 Wireless
    Plugins: HSTouch iOS and Android, RFXCOM, BlueIris, BLLock, BLDSC, BLRF, Insteon PLM (MNSandler), Device History, Ecobee, BLRing, Kodi, UltraWeatherWU3
    Second home: Zee S2 with Z-Wave, CT101 Z-Wave Thermostat, Aeotec Z-Wave microswitches, HSM200 occupancy sensor, Ecolink Z-Wave door sensors, STI Driveway Monitor interfaced to Zee S2 GPIO pins.

    #2
    Could you give me an example where you don't have to qualify it as well?
    Wade

    "I know nothing... nothing!"

    Comment


      #3
      DeviceTypeInfo_m is the name of the module that the DeviceTypeInfo class is in. Since DeviceTypeInfo is not an Interface, it is not picked up automatically by the other Imports your plug-in has, but it is Public in the HomeSeerAPI so your plug-in can still access it. If you add a reference to the HomeSeerAPI dll and import it in your project, then it should find it without you having to explicitly reference it.
      Regards,

      Rick Tinker (a.k.a. "Tink")

      Comment


        #4
        Originally posted by Rick Tinker View Post
        DeviceTypeInfo_m is the name of the module that the DeviceTypeInfo class is in. Since DeviceTypeInfo is not an Interface, it is not picked up automatically by the other Imports your plug-in has, but it is Public in the HomeSeerAPI so your plug-in can still access it. If you add a reference to the HomeSeerAPI dll and import it in your project, then it should find it without you having to explicitly reference it.
        I have HomeSeerAPI.dll as a reference, and I also import the namespace with "using HomeSeerAPI;". I still have to explicitly reference DeviceTypeInfo_m in order to access its types.
        HS Pro 3.0 | Linux Ubuntu 16.04 x64 virtualized under Proxmox (KVM)
        Hardware: Z-NET - W800 Serial - Digi PortServer TS/8 and TS/16 serial to Ethernet - Insteon PLM - RFXCOM - X10 Wireless
        Plugins: HSTouch iOS and Android, RFXCOM, BlueIris, BLLock, BLDSC, BLRF, Insteon PLM (MNSandler), Device History, Ecobee, BLRing, Kodi, UltraWeatherWU3
        Second home: Zee S2 with Z-Wave, CT101 Z-Wave Thermostat, Aeotec Z-Wave microswitches, HSM200 occupancy sensor, Ecolink Z-Wave door sensors, STI Driveway Monitor interfaced to Zee S2 GPIO pins.

        Comment


          #5
          Well, the module is Public but I just noticed that the class did not have a qualifier on it, (Public/Friend/Private) so that may explain why - I threw a Public in front of it, so in the next release see if that fixes the problem.
          Regards,

          Rick Tinker (a.k.a. "Tink")

          Comment


            #6
            Originally posted by Rick Tinker View Post
            Well, the module is Public but I just noticed that the class did not have a qualifier on it, (Public/Friend/Private) so that may explain why - I threw a Public in front of it, so in the next release see if that fixes the problem.
            I think it defaulted to public. If I use "go to definition" on the module name I see this:

            Code:
            namespace HomeSeerAPI
            {
                public sealed class DeviceTypeInfo_m
                {
            
                    [Serializable]
                    public class DeviceTypeInfo : MarshalByRefObject
                    {
                        public DeviceTypeInfo();
            
                        public DeviceTypeInfo_m.DeviceTypeInfo.eDeviceAPI Device_API { get; set; }
            .
            .
            .
            HS Pro 3.0 | Linux Ubuntu 16.04 x64 virtualized under Proxmox (KVM)
            Hardware: Z-NET - W800 Serial - Digi PortServer TS/8 and TS/16 serial to Ethernet - Insteon PLM - RFXCOM - X10 Wireless
            Plugins: HSTouch iOS and Android, RFXCOM, BlueIris, BLLock, BLDSC, BLRF, Insteon PLM (MNSandler), Device History, Ecobee, BLRing, Kodi, UltraWeatherWU3
            Second home: Zee S2 with Z-Wave, CT101 Z-Wave Thermostat, Aeotec Z-Wave microswitches, HSM200 occupancy sensor, Ecolink Z-Wave door sensors, STI Driveway Monitor interfaced to Zee S2 GPIO pins.

            Comment

            Working...
            X