public MoveStaticMembersOptions GetMoveMembersToTypeOptions(Document document, INamedTypeSymbol selectedType, ImmutableArray <ISymbol> selectedNodeSymbols) { if (!ExpectedPrecheckedMembers.IsEmpty) { // if we expect to have prechecked members and don't have the correct ones, error var actualPrecheckedMembers = selectedNodeSymbols.SelectAsArray(n => n.Name).Sort(); if (!ExpectedPrecheckedMembers.Sort().SequenceEqual(actualPrecheckedMembers)) { System.Diagnostics.Debug.Fail("Expected Prechecked members did not match recieved members"); var errMsg = string.Format("Expected: {0} \n Actual: {1}", ExpectedPrecheckedMembers, actualPrecheckedMembers); System.Diagnostics.Debug.Fail(errMsg); throw new InvalidOperationException(errMsg); } } var selectedMembers = selectedType.GetMembers().WhereAsArray(symbol => SelectedMembers.Contains(symbol.Name)); if (CreateNew) { var namespaceDisplay = selectedType.ContainingNamespace.IsGlobalNamespace ? string.Empty : selectedType.ContainingNamespace.ToDisplayString(); // just return all the selected members return(new MoveStaticMembersOptions( Filename !, string.Join(".", namespaceDisplay, DestinationName !), selectedMembers)); } var destination = selectedType.ContainingNamespace.GetAllTypes(CancellationToken.None).First(t => t.ToDisplayString() == DestinationName); return(new MoveStaticMembersOptions(destination, selectedMembers)); }
public MoveStaticMembersOptions GetMoveMembersToTypeOptions(Document document, INamedTypeSymbol selectedType, ISymbol?selectedNodeSymbol) { var selectedMembers = selectedType.GetMembers().WhereAsArray(symbol => SelectedMembers.Contains(symbol.Name)); var namespaceDisplay = selectedType.ContainingNamespace.IsGlobalNamespace ? string.Empty : selectedType.ContainingNamespace.ToDisplayString(); // just return all the selected members return(new MoveStaticMembersOptions( Filename !, string.Join(".", namespaceDisplay, DestinationType !), selectedMembers)); }
private void AddToCrewCommand_Execute(object parameter) { foreach (var item in SelectedMembers) { CrewMembers.Add(item); } SelectedMembers.Clear(); foreach (var item in CrewMembers) { AllMembers.Remove(item); } }
protected override void PopulateDisplayMembers() { List <T> allChildren = new List <T>(); if (typeof(T).Equals(typeof(ExtendedHierarchyMember))) { foreach (int selectedMember in SelectedMembers.Distinct()) { if (Members.FirstOrDefault(x => x.Id == selectedMember) is ExtendedHierarchyMember member) { allChildren.AddRange((Members as List <ExtendedHierarchyMember>).Where(x => x.Left > member.Left && x.Right < member.Right) as List <T>); } } } DisplayMembers = allChildren.Distinct(); }
protected override void PopulateDisplayMembers() { List <T> parents = new List <T>(); MetaDataManager metaDataManager = new MetaDataManager(); if (typeof(T).Equals(typeof(ExtendedHierarchyMember))) { foreach (int selectedMember in SelectedMembers.Distinct()) { T member = Members.FirstOrDefault(x => x.Id == selectedMember); if (member != null) { parents.Add(member); List <int> ancestors = metaDataManager.GetAncestors((member as ExtendedHierarchyMember).Lineage); List <ExtendedHierarchyMember> members = (Members as List <ExtendedHierarchyMember>).Where(x => ancestors.Contains(x.Id) && x.MemberType == MemberType.Rollup).ToList(); if (members != null && members.Count > 0) { parents.AddRange(members as List <T>); } } } } //else if (typeof(T).Equals(typeof(TimeHierarchy))) //{ // foreach (int selectedMember in SelectedMembers.Distinct()) // { // T member = Members.FirstOrDefault(x => x.Id == selectedMember); // if (member != null) // { // parents.Add(member); // List<int> ancestors = metaDataManager.GetAncestors((member as TimeHierarchy).Lineage); // List<TimeHierarchy> members = (Members as List<TimeHierarchy>).Where(x => ancestors.Contains(x.Id) && x.Level < 4).ToList(); // if (members != null && members.Count > 0) // { // parents.AddRange(members as List<T>); // } // } // } //} DisplayMembers = parents.Distinct(); }
protected virtual void PopulatePostProcessDeleteMemberIDs() { List <T> selectedAndAllChildren = new List <T>(); if (typeof(T).Equals(typeof(ExtendedHierarchyMember))) { foreach (int selectedMember in SelectedMembers.Distinct()) { if (Members.FirstOrDefault(x => x.Id == selectedMember) is ExtendedHierarchyMember member) { if (member != null) { List <ExtendedHierarchyMember> members = (Members as List <ExtendedHierarchyMember>).Where(x => x.Left >= member.Left && x.Right <= member.Right).ToList(); if (members != null && members.Count > 0) { selectedAndAllChildren.AddRange(members as List <T>); } } } } } else if (typeof(T).Equals(typeof(TimeHierarchy))) { foreach (int selectedMember in SelectedMembers.Distinct()) { if (Members.FirstOrDefault(x => x.Id == selectedMember) is TimeHierarchy member) { if (member != null) { List <TimeHierarchy> members = (Members as List <TimeHierarchy>).Where(x => x.Left >= member.Left && x.Right <= member.Right).ToList(); if (members != null && members.Count > 0) { selectedAndAllChildren.AddRange(members as List <T>); } } } } } PostProcessDeleteMemberIDs = selectedAndAllChildren.Distinct().Select(x => x.Id).Except(DisplayMembers.Select(z => z.Id)); }
protected virtual void PopulateRelevantLeafMembers() { List <T> leaves = new List <T>(); if (typeof(T).Equals(typeof(ExtendedHierarchyMember))) { foreach (int selectedMember in SelectedMembers.Distinct()) { if (Members.FirstOrDefault(x => x.Id == selectedMember) is ExtendedHierarchyMember member) { if (member != null) { List <ExtendedHierarchyMember> members = (Members as List <ExtendedHierarchyMember>).Where(x => x.Left >= member.Left && x.Right <= member.Right && x.MemberType == MemberType.Member).ToList(); if (members != null && members.Count > 0) { leaves.AddRange(members as List <T>); } } } } } else if (typeof(T).Equals(typeof(TimeHierarchy))) { foreach (int selectedMember in SelectedMembers.Distinct()) { if (Members.FirstOrDefault(x => x.Id == selectedMember) is TimeHierarchy member) { if (member != null) { List <TimeHierarchy> members = (Members as List <TimeHierarchy>).Where(x => x.Left >= member.Left && x.Right <= member.Right && x.Level == 4).ToList(); if (members != null && members.Count > 0) { leaves.AddRange(members as List <T>); } } } } } RelevantLeafIDs = leaves.Distinct().Select(x => x.Id); }
protected override void PopulateDisplayMembers() { List <T> selectedAndChildren = new List <T>(); if (typeof(T).Equals(typeof(ExtendedHierarchyMember))) { foreach (int selectedMember in SelectedMembers.Distinct()) { if (Members.FirstOrDefault(x => x.Id == selectedMember) is ExtendedHierarchyMember member) { if (member != null) { List <ExtendedHierarchyMember> members = (Members as List <ExtendedHierarchyMember>).Where(x => x.Id == member.Id || x.ParentId == member.Id).ToList(); if (members != null && members.Count > 0) { selectedAndChildren.AddRange(members as List <T>); } } } } } else if (typeof(T).Equals(typeof(TimeHierarchy))) { foreach (int selectedMember in SelectedMembers.Distinct()) { if (Members.FirstOrDefault(x => x.Id == selectedMember) is TimeHierarchy member) { if (member != null) { List <TimeHierarchy> members = (Members as List <TimeHierarchy>).Where(x => x.Id == member.Id || x.ParentId == member.Id).ToList(); if (members != null && members.Count > 0) { selectedAndChildren.AddRange(members as List <T>); } } } } } DisplayMembers = selectedAndChildren.Distinct(); }
protected override void PopulateDisplayMembers() { List <T> leaves = new List <T>(); if (typeof(T).Equals(typeof(ExtendedHierarchyMember))) { foreach (int selectedMember in SelectedMembers.Distinct()) { T member = Members.FirstOrDefault(x => x.Id == selectedMember); if (member != null) { leaves.Add(member); List <ExtendedHierarchyMember> members = (Members as List <ExtendedHierarchyMember>).Where(x => x.Left >= (member as ExtendedHierarchyMember).Left && x.Right <= (member as ExtendedHierarchyMember).Right && x.MemberType == MemberType.Member).ToList(); if (members != null && members.Count > 0) { leaves.AddRange(members as List <T>); } } } } else if (typeof(T).Equals(typeof(TimeHierarchy))) { foreach (int selectedMember in SelectedMembers.Distinct()) { T member = Members.FirstOrDefault(x => x.Id == selectedMember); if (member != null) { leaves.Add(member); List <TimeHierarchy> members = (Members as List <TimeHierarchy>).Where(x => x.Left >= (member as TimeHierarchy).Left && x.Right <= (member as TimeHierarchy).Right && x.Level == 4).ToList(); if (members != null && members.Count > 0) { leaves.AddRange(members as List <T>); } } } } DisplayMembers = leaves.Distinct(); }
public override void Run() { base.Run(); var selected = SelectedMembers.ToArray(); var originalValues = selected.Select(set => set.GetValue(this)).ToArray(); IEnumerable <decimal> range = LinearRange(SweepStart, SweepStop, (int)SweepPoints); if (SweepBehavior == SweepBehavior.Exponential) { range = ExponentialRange(SweepStart, SweepStop, (int)SweepPoints); } var disps = selected.Select(x => x.GetDisplayAttribute()).ToList(); string names = string.Join(", ", disps.Select(x => x.Name)); if (disps.Count > 1) { names = string.Format("{{{0}}}", names); } foreach (var Value in range) { var val = StringConvertProvider.GetString(Value, CultureInfo.InvariantCulture); foreach (var set in selected) { try { var value = StringConvertProvider.FromString(val, set.TypeDescriptor, this, CultureInfo.InvariantCulture); set.SetValue(this, value); } catch (TargetInvocationException ex) { Log.Error("Unable to set '{0}' to value '{2}': {1}", set.GetDisplayAttribute().Name, ex.InnerException.Message, Value); Log.Debug(ex.InnerException); } } // Notify that values might have changes OnPropertyChanged(""); var AdditionalParams = new ResultParameters(); foreach (var disp in disps) { AdditionalParams.Add(new ResultParameter(disp.Group.FirstOrDefault() ?? "", disp.Name, Value)); } Log.Info("Running child steps with {0} = {1} ", names, Value); var runs = RunChildSteps(AdditionalParams, BreakLoopRequested).ToList(); if (BreakLoopRequested.IsCancellationRequested) { break; } runs.ForEach(r => r.WaitForCompletion()); } for (int i = 0; i < selected.Length; i++) { selected[i].SetValue(this, originalValues[i]); } }
protected override void PopulateDisplayMembers() { if (typeof(T).Equals(typeof(ExtendedHierarchyMember))) { List <ExtendedHierarchyMember> members = (Members as List <ExtendedHierarchyMember>).Where(x => SelectedMembers.Distinct().Contains(x.ParentId)).ToList(); DisplayMembers = members as List <T>; } else if (typeof(T).Equals(typeof(TimeHierarchy))) { List <TimeHierarchy> members = (Members as List <TimeHierarchy>).Where(x => SelectedMembers.Distinct().Contains(x.ParentId)).ToList(); DisplayMembers = members as List <T>; } }
protected override void PopulateDisplayMembers() { DisplayMembers = Members.Where(x => SelectedMembers.Distinct().Contains(x.Id)).ToList(); }