private static unsafe void ParseCodePackages(NativeRuntime.IFabricCodePackageActivationContext nativeContext, ServiceManifest manifest) { IList <string> names = new List <string>(); NativeCommon.IFabricStringListResult nativeResult = nativeContext.GetCodePackageNames(); uint count; IntPtr nativeNames = nativeResult.GetStrings(out count); for (int i = 0; i < count; i++) { NativeRuntime.IFabricCodePackage codePackageResult = nativeContext.GetCodePackage(Marshal.ReadIntPtr((IntPtr)(nativeNames + i))); NativeTypes.FABRIC_CODE_PACKAGE_DESCRIPTION nativeDescription = *(NativeTypes.FABRIC_CODE_PACKAGE_DESCRIPTION *)(codePackageResult.get_Description()); NativeRuntime.IFabricCodePackage nativePackage = null; string packageName = NativeTypes.FromNativeString(nativeDescription.Name); using (var pin = new PinBlittable(packageName)) { nativePackage = nativeContext.GetCodePackage(pin.AddrOfPinnedObject()); } manifest.CodePackages.Add(CodePackage.CreateFromNative(nativePackage)); GC.KeepAlive(codePackageResult); } GC.KeepAlive(nativeResult); }
internal static unsafe CodePackage CreateFromNative(NativeRuntime.IFabricCodePackage nativePackage) { ReleaseAssert.AssertIfNull(nativePackage, "nativePackage"); string path = NativeTypes.FromNativeString(nativePackage.get_Path()); var nativeDescription = *((NativeTypes.FABRIC_CODE_PACKAGE_DESCRIPTION *)nativePackage.get_Description()); var description = CodePackageDescription.CreateFromNative(nativeDescription, path); var returnValue = new CodePackage() { Description = description, Path = path }; var nativePackage2 = (NativeRuntime.IFabricCodePackage2)nativePackage; if (nativePackage2.get_SetupEntryPointRunAsPolicy() != IntPtr.Zero) { returnValue.SetupEntryPointRunAsPolicy = RunAsPolicyDescription.CreateFromNative( *(NativeTypes.FABRIC_RUNAS_POLICY_DESCRIPTION *)nativePackage2.get_SetupEntryPointRunAsPolicy()); } if (nativePackage2.get_EntryPointRunAsPolicy() != IntPtr.Zero) { returnValue.EntryPointRunAsPolicy = RunAsPolicyDescription.CreateFromNative( *(NativeTypes.FABRIC_RUNAS_POLICY_DESCRIPTION *)nativePackage2.get_EntryPointRunAsPolicy()); } GC.KeepAlive(nativePackage2); GC.KeepAlive(nativePackage); return(returnValue); }