コード例 #1
0
        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);
        }
コード例 #2
0
        internal static ServiceManifest CreateFromCodePackageActivationContext(CodePackageActivationContext context)
        {
            ServiceManifest manifest = new ServiceManifest();

            foreach (ServiceTypeDescription description in context.GetServiceTypes())
            {
                manifest.ServiceTypeDescriptions.Add(description);
            }

            foreach (ServiceGroupTypeDescription description in context.GetServiceGroupTypes())
            {
                manifest.ServiceGroupTypeDescriptions.Add(description);
            }

            ServiceManifest.ParseCodePackages(context, manifest);
            ServiceManifest.ParseConfigurationPackages(context, manifest);
            ServiceManifest.ParseDataPackages(context, manifest);
            ServiceManifest.ParseEndPoints(context, manifest);

            manifest.Name    = manifest.CodePackages[context.CodePackageName].Description.ServiceManifestName;
            manifest.Version = manifest.CodePackages[context.CodePackageName].Description.ServiceManifestVersion;

            return(manifest);
        }