Example #1
0
        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);
        }
        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;
        }
Example #3
0
		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;
		}
Example #4
0
        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;
        }
Example #5
0
 /// <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>());
 }
        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);
                }
            }
        }
        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;
                    }
                }

            }
        }
        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;
        }