internal static string GetTargetPlatformIdentifier(this IVsHierarchy project) { string targetPlatformIdentifier = ConnectedServicesUtilities.GetProjectProperty(project, __VSHPROPID5.VSHPROPID_TargetPlatformIdentifier); if (!string.IsNullOrEmpty(targetPlatformIdentifier)) { targetPlatformIdentifier = targetPlatformIdentifier.CleanForCapabilitiesComponent(); } return(targetPlatformIdentifier); }
internal static Version GetTargetPlatformVersion(this IVsHierarchy project) { Version platformVersion = null; string targetPlatformVersion = ConnectedServicesUtilities.GetProjectProperty(project, __VSHPROPID5.VSHPROPID_TargetPlatformVersion); if (!string.IsNullOrEmpty(targetPlatformVersion)) { Version.TryParse(targetPlatformVersion, out platformVersion); } return(platformVersion); }
/// <summary> /// Get the built-in set of tokens supported by the handler helper. /// </summary> /// <returns> /// Returns a new dictionary with built-in tokens and their values. /// </returns> private IDictionary <string, string> CreateTokenReplacementValues() { Dictionary <string, string> extended = new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase) { { "ServiceInstance.Name", this.HandlerContext.ServiceInstance.Name }, { "ServiceInstance.InstanceId", this.HandlerContext.ServiceInstance.InstanceId }, { "ProjectName", ConnectedServicesUtilities.GetProjectProperty(this.context.ProjectHierarchy, __VSHPROPID.VSHPROPID_Name) }, { "vslcid", "0x{0:X}".FormatInvariantCulture(CultureInfo.CurrentUICulture.LCID) } }; string defaultNamespace = this.context.ProjectHierarchy.GetDefaultNamespace(); if (defaultNamespace != null) { extended.Add(AzureIoTHubConnectedServiceHandlerHelper.RootNamespaceKey, defaultNamespace); extended.Add("ProjectDefaultNamespace", defaultNamespace); } Project project = ConnectedServicesUtilities.GetDteProject(this.context.ProjectHierarchy); Property assemblyNameProperty = project.Properties.OfType <Property>().FirstOrDefault(p => string.Equals(p.Name, "AssemblyName", StringComparison.OrdinalIgnoreCase)); if (assemblyNameProperty != null) { string assemblyName = assemblyNameProperty.Value as string; if (!string.IsNullOrWhiteSpace(assemblyName)) { extended.Add("AssemblyName", assemblyName); } } // Tokens for service metadata. if (this.HandlerContext.ServiceInstance.Metadata != null) { foreach (var item in this.HandlerContext.ServiceInstance.Metadata) { if (item.Value is string) { // use the indexer instead of "Add" in case the Metadata dictionary conflicts with // any 'extended' tokens above. The Metadata dictionary will overwrite the built-in value. extended["ServiceInstance.{0}".FormatInvariantCulture(item.Key)] = (string)item.Value; } } } return(extended); }