public DotNetConstructorRegion(IPluginServiceModel model, ModelItem modelItem, ISourceToolRegion <IPluginSource> source, INamespaceToolRegion <INamespaceItem> namespaceItem) { try { Errors = new List <string>(); LabelWidth = 70; ToolRegionName = "DotNetConstructorRegion"; _modelItem = modelItem; _model = model; _source = source; _namespace = namespaceItem; _namespace.SomethingChanged += SourceOnSomethingChanged; Dependants = new List <IToolRegion>(); IsRefreshing = false; if (_source.SelectedSource != null) { Constructors = model.GetConstructors(_source.SelectedSource, _namespace.SelectedNamespace); } if (Method != null && Constructors != null) { SelectedConstructor = Constructors.FirstOrDefault(constructor => constructor.ConstructorName == Method.ConstructorName); } RefreshConstructorsCommand = new Microsoft.Practices.Prism.Commands.DelegateCommand(() => { IsRefreshing = true; if (_source.SelectedSource != null) { Constructors = model.GetConstructors(_source.SelectedSource, _namespace.SelectedNamespace); } IsRefreshing = false; }, CanRefresh); IsConstructorExpanded = false; IsEnabled = true; _modelItem = modelItem; } catch (Exception e) { Errors.Add(e.Message); } }
private void UpdateBasedOnNamespace() { if (_source?.SelectedSource != null) { Constructors = _model.GetConstructors(_source.SelectedSource, _namespace.SelectedNamespace); SelectedConstructor = null; if (Constructors.Count > 0) { SelectedConstructor = Constructors.FirstOrDefault(); } IsEnabled = true; } }