Example #1
0
        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);
        }
        internal static unsafe ConfigurationPackage CreateFromNative(NativeRuntime.IFabricConfigurationPackage nativePackage)
        {
            ReleaseAssert.AssertIfNull(nativePackage, "nativePackage");

            string path     = NativeTypes.FromNativeString(nativePackage.get_Path());
            var    settings = ConfigurationSettings.CreateFromNative(nativePackage.get_Settings());

            var nativeDescription = *((NativeTypes.FABRIC_CONFIGURATION_PACKAGE_DESCRIPTION *)nativePackage.get_Description());
            var description       = ConfigurationPackageDescription.CreateFromNative(nativeDescription, path, settings);

            var returnValue = new ConfigurationPackage()
            {
                Description = description,
                Path        = path,
                Settings    = settings
            };

            GC.KeepAlive(nativePackage);
            return(returnValue);
        }