private static unsafe void ParseConfigurationPackages(NativeRuntime.IFabricCodePackageActivationContext nativeContext, ServiceManifest manifest) { IList <string> names = new List <string>(); NativeCommon.IFabricStringListResult nativeResult = nativeContext.GetConfigurationPackageNames(); uint count; IntPtr nativeNames = nativeResult.GetStrings(out count); for (int i = 0; i < count; i++) { NativeRuntime.IFabricConfigurationPackage configPackageResult = nativeContext.GetConfigurationPackage(Marshal.ReadIntPtr((IntPtr)(nativeNames + i))); NativeTypes.FABRIC_CONFIGURATION_PACKAGE_DESCRIPTION nativeDescription = *(((NativeTypes.FABRIC_CONFIGURATION_PACKAGE_DESCRIPTION *)configPackageResult.get_Description())); NativeRuntime.IFabricConfigurationPackage nativePackage = null; string packageName = NativeTypes.FromNativeString(nativeDescription.Name); using (var pin = new PinBlittable(packageName)) { nativePackage = nativeContext.GetConfigurationPackage(pin.AddrOfPinnedObject()); } manifest.ConfigurationPackages.Add(ConfigurationPackage.CreateFromNative(nativePackage)); GC.KeepAlive(configPackageResult); } GC.KeepAlive(nativeResult); }
private static unsafe void ParseEndPoints(NativeRuntime.IFabricCodePackageActivationContext nativeContext, ServiceManifest manifest) { var list = (NativeTypes.FABRIC_ENDPOINT_RESOURCE_DESCRIPTION_LIST *)nativeContext.get_ServiceEndpointResources(); if (list != null) { for (int i = 0; i < list->Count; i++) { IntPtr nativeDescription = list->Items + i * Marshal.SizeOf(typeof(NativeTypes.FABRIC_ENDPOINT_RESOURCE_DESCRIPTION)); manifest.Endpoints.Add(EndpointResourceDescription.CreateFromNative(nativeDescription)); } } }
internal static unsafe ServiceManifest CreateFromNative(NativeRuntime.IFabricCodePackageActivationContext nativeContext) { ServiceManifest manifest = new ServiceManifest(); var nativeServiceTypes = (NativeTypes.FABRIC_SERVICE_TYPE_DESCRIPTION_LIST *)nativeContext.get_ServiceTypes(); if (nativeServiceTypes != null) { for (int i = 0; i < nativeServiceTypes->Count; i++) { manifest.ServiceTypeDescriptions.Add(ServiceTypeDescription.CreateFromNative(nativeServiceTypes->Items + i * Marshal.SizeOf(typeof(NativeTypes.FABRIC_SERVICE_TYPE_DESCRIPTION)))); } } var nativeServiceGroupTypes = (NativeTypes.FABRIC_SERVICE_GROUP_TYPE_DESCRIPTION_LIST *)nativeContext.get_ServiceGroupTypes(); if (nativeServiceGroupTypes != null) { for (int i = 0; i < nativeServiceGroupTypes->Count; i++) { manifest.ServiceGroupTypeDescriptions.Add(ServiceGroupTypeDescription.CreateFromNative(nativeServiceGroupTypes->Items + i * Marshal.SizeOf(typeof(NativeTypes.FABRIC_SERVICE_GROUP_TYPE_DESCRIPTION)))); } } ServiceManifest.ParseCodePackages(nativeContext, manifest); ServiceManifest.ParseConfigurationPackages(nativeContext, manifest); ServiceManifest.ParseDataPackages(nativeContext, manifest); ServiceManifest.ParseEndPoints(nativeContext, manifest); ReleaseAssert.AssertIfNot(manifest.CodePackages.Count > 0, "There should be at least one code package"); manifest.Name = manifest.CodePackages[0].Description.ServiceManifestName; manifest.Version = manifest.CodePackages[0].Description.ServiceManifestVersion; GC.KeepAlive(nativeContext); return(manifest); }