private void DoMatch(Type expectedType, ISelectedType selectedType)
        {
            Assert.IsNotNull(selectedType);
            var actualType = selectedType.GetSelectedType();

            Assert.AreEqual(expectedType, actualType);
        }
 protected virtual int GetHashCodeFor(ISelectedType selectedType)
 {
     if (selectedType == null) { return string.Empty.GetHashCode(); }
     var type = selectedType.GetSelectedType();
     if (type == null) { return string.Empty.GetHashCode(); }
     return type.GetHashCode();
 }
        protected virtual void SetElement(XElement element, string name, ISelectedType value, Type defaultValue = null)
        {
            Type type = null;

            if (value != null)
            {
                type = value.GetSelectedType();
            }
            if (type == null)
            {
                type = defaultValue;
            }
            var element2 = element.Element(name);

            if (type == null && element2 == null)
            {
                return;
            }
            if (type == null)
            {
                element2.Remove();
                return;
            }
            if (element2 == null)
            {
                element2 = new XElement(name);
                element.Add(element2);
            }
            SetAttribute(element2, KEY_TYPE_NAME, type.AssemblyQualifiedName);
        }
 protected virtual void ResetType(ISelectedType currentSelectedType, Type newType, TextBox textBox)
 {
     if (ConfirmTypeReset(currentSelectedType, newType))
     {
         currentSelectedType.SetSelectedType(newType);
         textBox.Text = newType.AssemblyQualifiedName;
     }
 }
        private void AddAssemblyPath(ISelectedType selectedType, HashSet <string> paths)
        {
            if (selectedType == null || string.IsNullOrEmpty(selectedType.AssemblyLocation) || paths == null)
            {
                return;
            }
            var path = Path.GetDirectoryName(selectedType.AssemblyLocation);

            if (!string.IsNullOrEmpty(path) && !paths.Contains(path))
            {
                paths.Add(path);
            }
        }
        protected virtual bool ConfirmTypeReset(ISelectedType currentSelectedType, Type newType)
        {
            var currentType = (currentSelectedType == null) ? null : currentSelectedType.GetSelectedType();

            if (currentType == newType)
            {
                MessageBox.Show(this, "The type is already set to its default value.", "Reset Selected Type", MessageBoxButton.OK);
                return(false);
            }
            var result = MessageBox.Show(this, "Are you sure you want to reset this type to its default value?", "Reset Selected Type", MessageBoxButton.YesNo);

            return(result == MessageBoxResult.Yes);
        }
Example #7
0
        protected virtual int GetHashCodeFor(ISelectedType selectedType)
        {
            if (selectedType == null)
            {
                return(string.Empty.GetHashCode());
            }
            var type = selectedType.GetSelectedType();

            if (type == null)
            {
                return(string.Empty.GetHashCode());
            }
            return(type.GetHashCode());
        }
        private string GetValueFromSelectedType(ISelectedType selectedType)
        {
            if (selectedType == null)
            {
                return(null);
            }
            var type = selectedType.GetSelectedType();

            if (type == null)
            {
                return(null);
            }
            return(type.AssemblyQualifiedName);
        }
        protected virtual void AddAssemblyPathToList(ISelectedType selectedType, List <string> paths)
        {
            if (paths == null)
            {
                throw new ArgumentNullException("paths");
            }
            if (selectedType == null || string.IsNullOrEmpty(selectedType.AssemblyLocation))
            {
                return;
            }
            var path = Path.GetDirectoryName(selectedType.AssemblyLocation);

            if (!string.IsNullOrEmpty(path) && !paths.Contains(path))
            {
                paths.Add(path);
            }
        }
        private void ShowTypeSelectorDialog(ISelectedType selectedType, string dialogTitle, TextBox textBox)
        {
            var view = new SelectedTypeViewModel(selectedType)
            {
                DialogTitle = dialogTitle,
                TextBox     = textBox
            };
            var controller = new TypeSelectorController(view);

            controller.LoadView();
            var dialog = new TypeSelectorDialog()
            {
                Owner = this,
                WindowStartupLocation = WindowStartupLocation.CenterOwner,
                Model = view
            };

            view.SaveViewToModelCallback = controller.SaveView;
            if (dialog.ShowDialog() != true)
            {
                return;
            }
        }
 protected virtual bool ConfirmTypeReset(ISelectedType currentSelectedType, Type newType)
 {
     var currentType = (currentSelectedType == null) ? null : currentSelectedType.GetSelectedType();
     if (currentType == newType)
     {
         MessageBox.Show(this, "The type is already set to its default value.", "Reset Selected Type", MessageBoxButton.OK);
         return false;
     }
     var result = MessageBox.Show(this, "Are you sure you want to reset this type to its default value?", "Reset Selected Type", MessageBoxButton.YesNo);
     return (result == MessageBoxResult.Yes);
 }
 private string GetValueFromSelectedType(ISelectedType selectedType)
 {
     if (selectedType == null)
     {
         return null;
     }
     var type = selectedType.GetSelectedType();
     if (type == null)
     {
         return null;
     }
     return type.AssemblyQualifiedName;
 }
 private void ShowTypeSelectorDialog(ISelectedType selectedType, string dialogTitle, TextBox textBox)
 {
     var view = new SelectedTypeViewModel(selectedType)
     {
         DialogTitle = dialogTitle,
         TextBox = textBox
     };
     var controller = new TypeSelectorController(view);
     controller.LoadView();
     var dialog = new TypeSelectorDialog()
     {
         Owner = this,
         WindowStartupLocation = WindowStartupLocation.CenterOwner,
         Model = view
     };
     view.SaveViewToModelCallback = controller.SaveView;
     if (dialog.ShowDialog() != true)
     {
         return;
     }
 }
Example #14
0
 public SelectedTypeViewModel(ISelectedType model)
 {
     this.Model = model;
 }
 private void DoMatch(Type expectedType, ISelectedType selectedType)
 {
     Assert.IsNotNull(selectedType);
     var actualType = selectedType.GetSelectedType();
     Assert.AreEqual(expectedType, actualType);
 }
 private void AddAssemblyPath(ISelectedType selectedType, HashSet<string> paths)
 {
     if (selectedType == null || string.IsNullOrEmpty(selectedType.AssemblyLocation) || paths == null)
     {
         return;
     }
     var path = Path.GetDirectoryName(selectedType.AssemblyLocation);
     if (!string.IsNullOrEmpty(path) && !paths.Contains(path))
     {
         paths.Add(path);
     }
 }
 protected virtual void ResetType(ISelectedType currentSelectedType, Type newType, TextBox textBox)
 {
     if (ConfirmTypeReset(currentSelectedType, newType))
     {
         currentSelectedType.SetSelectedType(newType);
         textBox.Text = newType.AssemblyQualifiedName;
     }
 }