Use a service provider method exclusively in code
Most service provider methods are accessible and can be configured using Service Provider Methods. For those that are not accessible, follow the tips in this topic for assistance.
In Designer-generated forms or user displays, access the IServiceDirectory service from the host as follows:
IServiceDirectory serviceDirectory = this.Host.GetService(typeof(IServiceDirectory)) as IServiceDirectory;
ICustomSP someCustomSP = serviceDirectory.CreateLogicalServiceProxy(typeof(ICustomSP).FullName) as ICustomSP;
IEquipment equipmentSP = serviceDirectory.CreateLogicalServiceProxy(typeof(ICustomSP).FullName) as ICustomSP; Proficy.Platform.Forms.Editor.CustomControls.UniversalBrowser browser = UniversalBrowser1; int result = equipmentSP.QueryPropertyCount(browser.SelectedItem as DirectoryResource,"%"); TextBox tb = TextBox1; tb.Text= result.ToString();
For this code to work, add an assembly reference to Proficy.Platform.Services.EquipmentInterfaces.dll. Also add the following using statements:
- using Proficy.Platform.Services.Equipment.Interfaces
- using Proficy.Platform.Core.ProficySystem.Types
For a custom service provider, add the appropriate assembly and namespace references.