private static void ParseCodePackages(CodePackageActivationContext context, ServiceManifest manifest) { IList <string> names = context.GetCodePackageNames(); foreach (string name in names) { manifest.CodePackages.Add(context.GetCodePackageObject(name)); } }
// internal for test hook internal void ActivateCodePackageInternal( string activationContextId, string codePackageName, CodePackageActivationContext activationContext, NativeRuntime.IFabricRuntime fabricRuntimePointer) { this.ThrowIfDisposed(); CodePackage codePackage; try { codePackage = activationContext.GetCodePackageObject(codePackageName); } catch (KeyNotFoundException) { AppTrace.TraceSource.WriteError("FabricHostEntryPoint.ActivateCodePackageInternal", "The code package {0} to activate was not found", codePackageName); throw new ArgumentException(StringResources.Error_CodePackageNotFound); } DllHostEntryPointDescription description = codePackage.Description.EntryPoint as DllHostEntryPointDescription; if (description == null) { AppTrace.TraceSource.WriteError("FabricHostEntryPoint.ActivateCodePackageInternal", "Code package {0} does not have a FabricHostEntryPoint", codePackageName); throw new ArgumentException(StringResources.Error_FabricHostEntryPoint_No_EntryPoint_Found); } AppTrace.TraceSource.WriteNoise("FabricHostEntryPoint.ActivateCodePackageInternal", "Adding assembly resolver path: {0}", codePackage.Path); this.assemblyResolver.AddApplicationBinariesPath(codePackage.Path); var workerEntryPoints = description.HostedDlls .Where(i => i.Kind == DllHostHostedDllKind.Managed) .Select(FabricWorkerEntryPoint.CreateFromAssemblyDescription) .ToArray(); var fabricRuntime = new FabricRuntime(fabricRuntimePointer, activationContext); ActivatedCodePackage activatedCodePackage = new ActivatedCodePackage(fabricRuntime, workerEntryPoints); bool activateSucceeded = false; try { workerEntryPoints.ForEach(wep => wep.InvokeActivate(fabricRuntime, activationContext)); this.activeCodePackages[activationContextId] = activatedCodePackage; activateSucceeded = true; } finally { if (!activateSucceeded) { activatedCodePackage.Dispose(); } } }