internal PackageId() { #if __ANDROID__ _packageInfo = Android.App.Application.Context.PackageManager.GetPackageInfo(Android.App.Application.Context.PackageName, PackageInfoFlags.MetaData); #elif __IOS__ #elif WINDOWS_APP || WINDOWS_PHONE_APP || WINDOWS_PHONE_81 || WINDOWS_UWP _packageId = Windows.ApplicationModel.Package.Current.Id; #endif }
public Adapter(string DCGWURLParam, string userName, string userPassword) { //setting IP of gateway from UI DCGWUrl = "http://" + DCGWURLParam + ":8080/"; user = userPassword; password = userPassword; Windows.ApplicationModel.Package package = Windows.ApplicationModel.Package.Current; Windows.ApplicationModel.PackageId packageId = package.Id; Windows.ApplicationModel.PackageVersion versionFromPkg = packageId.Version; this.Vendor = "EnOcean"; this.AdapterName = "Bridge"; // the adapter prefix must be something like "com.mycompany" (only alpha num and dots) // it is used by the Device System Bridge as root string for all services and interfaces it exposes this.ExposedAdapterPrefix = "com." + this.Vendor.ToLower(); this.ExposedApplicationGuid = Guid.Parse("{0x0b2b3b87,0xc1fc,0x4282,{0x96,0xad,0x88,0xc7,0x90,0xaf,0x15,0xe3}}"); if (null != package && null != packageId) { this.ExposedApplicationName = packageId.Name; this.Version = versionFromPkg.Major.ToString() + "." + versionFromPkg.Minor.ToString() + "." + versionFromPkg.Revision.ToString() + "." + versionFromPkg.Build.ToString(); } else { this.ExposedApplicationName = "EnOcean Alljoyn DSB"; this.Version = "0.0.0.0"; } try { this.Signals = new List <IAdapterSignal>(); this.devices = new List <IAdapterDevice>(); this.devicesDict = new Dictionary <string, IAdapterDevice>(); this.deviceSignals = new Dictionary <string, IAdapterSignal>(); this.signalListeners = new Dictionary <int, IList <SIGNAL_LISTENER_ENTRY> >(); //Create Adapter Signals this.createSignals(); } catch (OutOfMemoryException ex) { throw; } }
/// <summary> /// Figure out the user agent and add it to the header collection. /// </summary> /// <param name="userAgent">User agent header collection.</param> /// <param name="packageId">PackageId to extract application name and version from.</param> private static void AddUserAgent(ICollection<ProductInfoHeaderValue> userAgent, PackageId packageId) { userAgent.Add(new ProductInfoHeaderValue(packageId.Name, FormatVersion(packageId.Version))); var agentParts = new[] { "Windows NT " + SystemInformation.GetWindowsVersionAsync().Result, GetProcessorArchitectureAsync().Result }; userAgent.Add(new ProductInfoHeaderValue("(" + String.Join("; ", agentParts) + ")")); }