System.Resources.WindowsRuntimeResourceManager.InitializeStaticsForDependentPackages C# (CSharp) Méthode

InitializeStaticsForDependentPackages() private static méthode

private static InitializeStaticsForDependentPackages ( ) : void
Résultat void
        private static void InitializeStaticsForDependentPackages()
        {
            if (s_dependentPackageInfoList == null)
            {
                // Create an empty list. If there are no dependencies, this will be our way of knowing that we ran
                // through this function once.
                List<PackageInfo> dependentPackageInfoList = new List<PackageInfo>();

                // We call Package.Current here and in InitializeStatics. This may cause a small perf hit.
                // In theory we could have cached it as a static variable.
                // However, we don't want to have to keep a reference to it alive for the lifetime of the AppDomain.
                // Also having InitializeStaticsForDependentPackages not depend on InitializeStatics leads to a simpler design.
                Package currentPackage = Package.Current;

                if (currentPackage != null)
                {
                    IReadOnlyList<Package> dependencies = currentPackage.Dependencies;
                    if (dependencies != null)
                    {
                        int dependenciesCount = dependencies.Count;

                        if (dependenciesCount > 0)
                        {
                            // We have dependencies. Throw away the old empty list, and create a list with
                            // capacity exactly equal to the number of dependencies.
                            dependentPackageInfoList = new List<PackageInfo>(dependenciesCount);

                            foreach (Package package in dependencies)
                            {
                                if (package != null)
                                {
                                    StorageFolder dependentPackageLocation = package.InstalledLocation;
                                    PackageInfo dependentPackageInfo;

                                    dependentPackageInfo.Path = null;
                                    dependentPackageInfo.Name = null;
                                    dependentPackageInfo.FullName = null;

                                    if (dependentPackageLocation != null)
                                        dependentPackageInfo.Path = dependentPackageLocation.Path;

                                    PackageId id = package.Id;
                                    if (id != null)
                                    {
                                        dependentPackageInfo.Name = id.Name;
                                        dependentPackageInfo.FullName = id.FullName;
                                    }

                                    dependentPackageInfoList.Add(dependentPackageInfo);
                                }
                            }
                        }
                    }
                }

                // Assign even if the list is empty. That way we know we ran through this function once.
                s_dependentPackageInfoList = dependentPackageInfoList;
            }

            Debug.Assert(s_dependentPackageInfoList != null);
        }