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


C# HashSet.OfType方法代码示例

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


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

示例1: GetInterfaces

        public ReadOnlyCollection<IInterfaceType> GetInterfaces(bool includeInherited)
        {
            if (includeInherited && _allInterfaces == null)
            {
                List<InterfaceType> allInterfaces = new List<InterfaceType>();

                HashSet<ReferenceType> inheritedTypes = new HashSet<ReferenceType>();
                GetInheritedTypes(this, inheritedTypes);
                allInterfaces.AddRange(inheritedTypes.OfType<InterfaceType>());

                _allInterfaces = allInterfaces.ToArray();
            }
            else if (!includeInherited && _interfaces == null)
            {
                InterfaceId[] interfaceIds;
                DebugErrorHandler.ThrowOnFailure(VirtualMachine.ProtocolService.GetInterfaces(out interfaceIds, ReferenceTypeId));
                InterfaceType[] interfaces = Array.ConvertAll(interfaceIds, VirtualMachine.GetMirrorOf);
                _interfaces = interfaces;
            }

            return new ReadOnlyCollection<IInterfaceType>(includeInherited ? _allInterfaces : _interfaces);
        }
开发者ID:Kav2018,项目名称:JavaForVS,代码行数:22,代码来源:ClassType.cs

示例2: CreateUnifiedGroupForPropertyAsync

        public async Task<IGroup> CreateUnifiedGroupForPropertyAsync(GraphService graphService, ListItem propertyItem, IEnumerable<Graph.IUser> members)
        {
            var propertyTitle = propertyItem["Title"] as string;
            var propertyOwnerName = propertyItem["sl_owner"] as string;
            var propertyOwner = await graphService.GetFirstUserAsync(i => i.displayName == propertyOwnerName);

            // Create group
            var group = new Graph.Group
            {
                displayName = propertyTitle,
                mailNickname = propertyTitle.Replace(" ", ""),
                securityEnabled = false,
                mailEnabled = true,
                groupType = "Unified",
                description = "Property Group",
            };
            try
            {
                await graphService.groups.AddGroupAsync(group);
            }
            catch { }

            // Add users to group
            var groupMembers = new HashSet<Graph.IUser>(members);
            var groupOwners = new HashSet<Graph.IUser>();
            var adminUserName = HttpContext.Current.User.Identity.Name;
            var admin = await graphService.GetFirstUserAsync(i => i.mail == adminUserName);
            if (admin != null)
            {
                groupMembers.Add(admin);
                groupOwners.Add(admin);
            }
            if (propertyOwner != null)
            {
                groupMembers.Add(propertyOwner);
                groupOwners.Add(propertyOwner);
            }
            
            foreach (var user in groupMembers.OfType<Graph.User>())
            {
                group.members.Add(user);
                try
                {
                    await group.SaveChangesAsync();
                }
                catch { }
            }

            foreach (var user in groupOwners.OfType<Graph.User>())
            {
                group.owners.Add(user);
                try
                {
                    await group.SaveChangesAsync();
                }
                catch { }
            }

            return group;
        }
开发者ID:modulexcite,项目名称:Property-Inspection-Code-Sample,代码行数:60,代码来源:SiteProvisioning.cs

示例3: FastCheckNeedsBuild

		bool FastCheckNeedsBuild (IBuildTarget target, ConfigurationSelector configuration)
		{
			var env = Environment.GetEnvironmentVariable ("DisableFastUpToDateCheck");
			if (!string.IsNullOrEmpty (env) && env != "0" && !env.Equals ("false", StringComparison.OrdinalIgnoreCase))
				return true;

			var sei = target as SolutionEntityItem;
			if (sei != null) {
				if (sei.FastCheckNeedsBuild (configuration))
					return true;
				//TODO: respect solution level dependencies
				var deps = new HashSet<SolutionItem> ();
				CollectReferencedItems (sei, deps, configuration);
				foreach (var dep in deps.OfType<SolutionEntityItem> ()) {
					if (dep.FastCheckNeedsBuild (configuration))
						return true;
				}
				return false;
			}

			var sln = target as Solution;
			if (sln != null) {
				foreach (var item in sln.GetAllSolutionItems<SolutionEntityItem> ()) {
					if (item.FastCheckNeedsBuild (configuration))
						return true;
				}
				return false;
			}

			//TODO: handle other IBuildTargets
			return true;
		}
开发者ID:lkalif,项目名称:monodevelop,代码行数:32,代码来源:ProjectOperations.cs

示例4: GetReturnValue

        internal INamespaceSet GetReturnValue(int unionStrength = 0)
        {
            var result = (unionStrength >= 0 && unionStrength <= UnionComparer.MAX_STRENGTH)
                ? NamespaceSet.CreateUnion(UnionComparer.Instances[unionStrength])
                : NamespaceSet.Empty;

            var units = new HashSet<AnalysisUnit>();
            units.Add(AnalysisUnit);
            if (_allCalls != null) {
                units.UnionWith(_allCalls.Values);
            }

            result = result.UnionAll(units.OfType<FunctionAnalysisUnit>().Select(unit => unit.ReturnValue.TypesNoCopy));

            return result;
        }
开发者ID:borota,项目名称:JTVS,代码行数:16,代码来源:FunctionInfo.cs

示例5: PropNet

 /// <summary>
 /// Creates a new PropNet from a list of Components, along with indices over
 /// those components.
 /// </summary>
 /// <param name="roles"></param>
 /// <param name="components">A list of Components.</param>
 public PropNet(List<TermObject> roles, HashSet<IComponent> components)
 {
     Roles = roles;
     Components = components;
     Propositions = RecordPropositions();
     BasePropositions = RecordBasePropositions();
     InputPropositions = RecordInputPropositions();
     LegalPropositions = RecordLegalPropositions();
     GoalPropositions = RecordGoalPropositions();
     InitProposition = RecordInitProposition();
     TerminalProposition = RecordTerminalProposition();
     LegalInputMap = MakeLegalInputMap();
     Transitions = new HashSet<ITransition>(Components.OfType<ITransition>());
 }
开发者ID:druzil,项目名称:nggp-base,代码行数:20,代码来源:PropNet.cs

示例6: CollectUsedSymbols

        private static void CollectUsedSymbols(RemovableDeclarationCollector declarationCollector,
            HashSet<ISymbol> usedSymbols, HashSet<ISymbol> declaredPrivateSymbols)
        {
            var symbolNames = declaredPrivateSymbols.Select(s => s.Name).ToImmutableHashSet();
            var anyRemovableIndexers = declaredPrivateSymbols
                .OfType<IPropertySymbol>()
                .Any(p => p.IsIndexer);
            var anyRemovableCtors = declaredPrivateSymbols
                .OfType<IMethodSymbol>()
                .Any(m => m.MethodKind == MethodKind.Constructor);

            var identifiers = declarationCollector.ClassDeclarations
                .SelectMany(container => container.SyntaxNode.DescendantNodes()
                    .Where(node =>
                        node.IsKind(SyntaxKind.IdentifierName))
                    .Cast<IdentifierNameSyntax>()
                    .Where(node => symbolNames.Contains(node.Identifier.ValueText))
                    .Select(node =>
                        new SyntaxNodeSemanticModelTuple<SyntaxNode>
                        {
                            SyntaxNode = node,
                            SemanticModel = container.SemanticModel
                        }));

            var generic = declarationCollector.ClassDeclarations
                .SelectMany(container => container.SyntaxNode.DescendantNodes()
                    .Where(node =>
                        node.IsKind(SyntaxKind.GenericName))
                    .Cast<GenericNameSyntax>()
                    .Where(node => symbolNames.Contains(node.Identifier.ValueText))
                    .Select(node =>
                        new SyntaxNodeSemanticModelTuple<SyntaxNode>
                        {
                            SyntaxNode = node,
                            SemanticModel = container.SemanticModel
                        }));

            var allNodes = identifiers.Concat(generic);

            if (anyRemovableIndexers)
            {
                var nodes = declarationCollector.ClassDeclarations
                    .SelectMany(container => container.SyntaxNode.DescendantNodes()
                        .Where(node => node.IsKind(SyntaxKind.ElementAccessExpression))
                        .Select(node =>
                            new SyntaxNodeSemanticModelTuple<SyntaxNode>
                            {
                                SyntaxNode = node,
                                SemanticModel = container.SemanticModel
                            }));

                allNodes = allNodes.Concat(nodes);
            }

            if (anyRemovableCtors)
            {
                var nodes = declarationCollector.ClassDeclarations
                    .SelectMany(container => container.SyntaxNode.DescendantNodes()
                        .Where(node => node.IsKind(SyntaxKind.ObjectCreationExpression))
                        .Select(node =>
                            new SyntaxNodeSemanticModelTuple<SyntaxNode>
                            {
                                SyntaxNode = node,
                                SemanticModel = container.SemanticModel
                            }));

                allNodes = allNodes.Concat(nodes);
            }

            foreach (var node in allNodes)
            {
                var symbol = node.SemanticModel.GetSymbolInfo(node.SyntaxNode).Symbol;
                var methodSymbol = symbol as IMethodSymbol;

                if (methodSymbol != null &&
                    methodSymbol.MethodKind == MethodKind.ReducedExtension)
                {
                    symbol = methodSymbol.ReducedFrom;
                }

                if (symbol != null)
                {
                    usedSymbols.Add(symbol.OriginalDefinition);
                }
            }
        }
开发者ID:dbolkensteyn,项目名称:sonarlint-vs,代码行数:86,代码来源:UnusedPrivateMember.cs

示例7: GetAllItems

        public IEnumerable<Document> GetAllItems()
        {
            foreach (Type universalSearchItemType in GetUniversalSearchItemTypes.Keys.OrderByDescending(type => type.FullName))
            {
                using (MiniProfiler.Current.Step("Getting " + universalSearchItemType.FullName))
                {
                    var objects = new HashSet<object>();
                    using (MiniProfiler.Current.Step("Loading objects " + universalSearchItemType.Name))
                    {
                        Type type = universalSearchItemType;
                        var criteria = _session.CreateCriteria(universalSearchItemType);
                        if (typeof (SiteEntity).IsAssignableFrom(type))
                        {
                            criteria = criteria.Add(Restrictions.Eq("Site.Id", _site.Id));
                        }
                        objects.AddRange(
                            criteria
                    .Add(Restrictions.Eq("IsDeleted", false))
                                .SetCacheable(true)
                                .List()
                                .Cast<object>()
                                .Where(o => o.GetType() == type));
                    }
                    foreach (
                        var generateDocument in
                            GenerateDocuments(objects.OfType<SystemEntity>().ToHashSet(), universalSearchItemType))
                    {
                        yield return generateDocument;
                    }
                }

            }
        }
开发者ID:neozhu,项目名称:MrCMS,代码行数:33,代码来源:UniversalSearchItemGenerator.cs

示例8: CreateUnifiedGroupForPropertyAsync

        public async Task<Graph.Group> CreateUnifiedGroupForPropertyAsync(GraphServiceClient graphService, string graphAccessToken, ListItem propertyItem, IEnumerable<Graph.User> members)
        {
            var propertyTitle = propertyItem["Title"] as string;
            var propertyOwnerName = propertyItem["sl_owner"] as string;
            var querypropertyOwners = (await graphService.Users.Request().Filter(string.Format("displayName eq '{0}'", propertyOwnerName)).GetAsync()).CurrentPage;
            var propertyOwner = querypropertyOwners.Count > 0 ? querypropertyOwners[0] : null;
            if (propertyOwner == null) return null;
            // Create Office 365 Group
            string groupId = string.Empty;
            dynamic groupJSON = new JObject();
            groupJSON.displayName = propertyTitle;
            groupJSON.mailNickname = propertyTitle.Replace(" ", "");
            groupJSON.securityEnabled = false;
            groupJSON.mailEnabled = true;
            groupJSON.description = "Property Group";
            groupJSON.groupTypes = new JArray("Unified");
            HttpRequestMessage message = new HttpRequestMessage(HttpMethod.Post, string.Format("{0}groups", AADAppSettings.GraphResourceUrl));
            message.Content = new StringContent(groupJSON.ToString(), System.Text.Encoding.UTF8, "application/json");
            message.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
            message.Headers.Authorization = new AuthenticationHeaderValue("Bearer", graphAccessToken);
            using (HttpClient client = new HttpClient())
            {
                var responseMessage = await client.SendAsync(message);

                if (responseMessage.StatusCode != System.Net.HttpStatusCode.Created)
                    throw new System.Web.Http.HttpResponseException(responseMessage.StatusCode);

                var payload = await responseMessage.Content.ReadAsStringAsync();

                groupId = JObject.Parse(payload)["id"].ToString();
            }
            var group = await graphService.Groups[groupId].Request().GetAsync() as Graph.Group;

            // Add users to Office 365 Group
            var groupMembers = new HashSet<Graph.User>(members);
            var groupOwners = new HashSet<Graph.User>();
            var adminUserName = _currentUserName;
            var queryAdmins = (await graphService.Users.Request().Filter(string.Format("mail eq '{0}'", adminUserName)).GetAsync()).CurrentPage;
            var admin = queryAdmins.Count > 0 ? queryAdmins[0] : null;
            if (admin != null)
            {
                groupMembers.Add(admin);
                groupOwners.Add(admin);
            }
            if (propertyOwner != null)
            {
                groupMembers.Add(propertyOwner);
                groupOwners.Add(propertyOwner);
            }

            foreach (var user in groupMembers.OfType<Graph.User>())
            {
                try
                {
                    await GraphServiceExtension.AddUserToGroupMembersAsync(graphService, group, user, graphAccessToken);
                }
                catch{ }
            }

            foreach (var user in groupOwners.OfType<Graph.User>())
            {
                try
                {
                    await GraphServiceExtension.AddUserToGroupOwnersAsync(graphService, group, user, graphAccessToken);
                }
                catch{ }
            }

            return group;
        }
开发者ID:TBag,项目名称:Property-Inspection-Code-Sample,代码行数:70,代码来源:SiteProvisioning.cs


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