当前位置: 首页>>代码示例>>C#>>正文


C# Collection.OfType方法代码示例

本文整理汇总了C#中Collection.OfType方法的典型用法代码示例。如果您正苦于以下问题:C# Collection.OfType方法的具体用法?C# Collection.OfType怎么用?C# Collection.OfType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Collection的用法示例。


在下文中一共展示了Collection.OfType方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SetFilterAttributeFilterProvider

        private static void SetFilterAttributeFilterProvider(this IContainer container, Collection<IFilterProvider> filterProviders = null)
        {
            filterProviders = filterProviders ?? FilterProviders.Providers;

            var filterAttributeFilterProviders = filterProviders.OfType<FilterAttributeFilterProvider>().ToArray();
            for (var i = filterAttributeFilterProviders.Length - 1; i >= 0; --i)
            {
                filterProviders.RemoveAt(i);
            }

            var filterProvider = new DryIocFilterAttributeFilterProvider(container);
            filterProviders.Add(filterProvider);

            container.RegisterInstance<IFilterProvider>(filterProvider);
        }
开发者ID:devworker55,项目名称:SourceLab,代码行数:15,代码来源:DryIocExtensions.cs

示例2: ChangeTheme

        private static void ChangeTheme(Collection<ResourceDictionary> mergedDictionaries, ThemeTones tone, Color accentColor)
        {
            var metroDictionaries = mergedDictionaries.OfType<MetroDictionary>().ToArray();

            foreach (var d in metroDictionaries)
                mergedDictionaries.Remove(d);

            if (tone == ThemeTones.None)
                return;

            ResourceDictionary toneDictionary = null;

            switch (tone)
            {
                case ThemeTones.Light:
                    toneDictionary = GetThemeResourceDictionary("StyleLight");
                    break;
                case ThemeTones.Dark:
                    toneDictionary = GetThemeResourceDictionary("StyleDark");
                    break;
            }

            var accentDictionary = CreateAccentDictionary(accentColor);

            mergedDictionaries.Add(toneDictionary);

            mergedDictionaries.Add(accentDictionary);

            foreach (var s in StyleFiles)
            {
                var dict = GetThemeResourceDictionary(s);
                dict.MergedDictionaries.Add(toneDictionary);
                dict.MergedDictionaries.Add(accentDictionary);

                mergedDictionaries.Add(dict);
            }
        }
开发者ID:distantcam,项目名称:MetroChrome,代码行数:37,代码来源:ThemeManager.cs

示例3: MapConfigurationSets

        public static  IList<MCM.ConfigurationSet> MapConfigurationSets(Collection<ConfigurationSet> configurationSets)
        {
            var result = new Collection<Management.Compute.Models.ConfigurationSet>();
            foreach (var networkConfig in configurationSets.OfType<NetworkConfigurationSet>())
            {
                result.Add(Mapper.Map<Management.Compute.Models.ConfigurationSet>(networkConfig));
            }

            foreach (var windowsConfig in configurationSets.OfType<WindowsProvisioningConfigurationSet>())
            {
                var newWinCfg = Mapper.Map<Management.Compute.Models.ConfigurationSet>(windowsConfig);
                if (windowsConfig.WinRM != null)
                {
                    newWinCfg.WindowsRemoteManagement = new WindowsRemoteManagementSettings();

                    // AutoMapper doesn't work for WinRM.Listeners -> WindowsRemoteManagement.Listeners
                    if (windowsConfig.WinRM.Listeners != null)
                    {
                        foreach (var s in windowsConfig.WinRM.Listeners)
                        {
                            newWinCfg.WindowsRemoteManagement.Listeners.Add(new WindowsRemoteManagementListener
                            {
                                ListenerType = (VirtualMachineWindowsRemoteManagementListenerType)Enum.Parse(typeof(VirtualMachineWindowsRemoteManagementListenerType), s.Protocol, true),
                                CertificateThumbprint = s.CertificateThumbprint
                            });
                        }
                    }
                }

                result.Add(newWinCfg);
            }

            foreach (var linuxConfig in configurationSets.OfType<LinuxProvisioningConfigurationSet>())
            {
                result.Add(Mapper.Map<Management.Compute.Models.ConfigurationSet>(linuxConfig));
            }

            return result;
        }
开发者ID:shuainie,项目名称:azure-powershell,代码行数:39,代码来源:PersistentVMHelper.cs

示例4: ApplyTheme

        private static void ApplyTheme(Collection<ResourceDictionary> mergedDictionaries, Uri dictionaryUri)
        {
            if (mergedDictionaries == null) return;

            using (var d = Application.Current.Dispatcher.DisableProcessing())
            {
                try
                {
                    ThemeResourceDictionary themeDictionary = null;
                    if (dictionaryUri != null)
                    {
                        themeDictionary = new ThemeResourceDictionary();
                        themeDictionary.Source = dictionaryUri;

                    }

                    // Find if the target element already has a theme applied
                    // we always want to remove them in case 'None' was selected.
                    var existingDictionaries = mergedDictionaries
                        .OfType<ThemeResourceDictionary>()
                        .ToList();

                    // Remove the existing dictionaries
                    foreach (ThemeResourceDictionary thDictionary in existingDictionaries)
                    {
                        mergedDictionaries.Remove(thDictionary);
                    }

                    if (themeDictionary != null)
                    {
                        // Add the new dictionary to the collection of merged dictionaries of the target object
                        mergedDictionaries.Insert(0, themeDictionary);
                    }
                }
                finally { }
            }
        }
开发者ID:FineRedMist,项目名称:memhack,代码行数:37,代码来源:MkThemeSelector.cs


注:本文中的Collection.OfType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。