diff --git a/mRemoteV1/Connection/ConnectionInfo.cs b/mRemoteV1/Connection/ConnectionInfo.cs
index aeca82a61..cdd3bcfe1 100644
--- a/mRemoteV1/Connection/ConnectionInfo.cs
+++ b/mRemoteV1/Connection/ConnectionInfo.cs
@@ -197,7 +197,10 @@ namespace mRemoteNG.Connection
private bool ShouldThisPropertyBeInherited(string propertyName)
{
- return ParentIsValidInheritanceTarget() && IsInheritanceTurnedOnForThisProperty(propertyName);
+ return
+ Inheritance.InheritanceActive &&
+ ParentIsValidInheritanceTarget() &&
+ IsInheritanceTurnedOnForThisProperty(propertyName);
}
private bool ParentIsValidInheritanceTarget()
diff --git a/mRemoteV1/Connection/ConnectionInfoInheritance.cs b/mRemoteV1/Connection/ConnectionInfoInheritance.cs
index 08849dba1..47909de37 100644
--- a/mRemoteV1/Connection/ConnectionInfoInheritance.cs
+++ b/mRemoteV1/Connection/ConnectionInfoInheritance.cs
@@ -8,8 +8,6 @@ namespace mRemoteNG.Connection
{
public class ConnectionInfoInheritance
{
- private ConnectionInfoInheritance _tempInheritanceStorage;
-
#region Public Properties
#region General
@@ -20,8 +18,8 @@ namespace mRemoteNG.Connection
TypeConverter(typeof(MiscTools.YesNoTypeConverter))]
public bool EverythingInherited
{
- get { return EverythingIsInherited(); }
- set { SetAllValues(value); }
+ get => EverythingIsInherited();
+ set => SetAllValues(value);
}
#endregion
@@ -391,7 +389,16 @@ namespace mRemoteNG.Connection
TypeConverter(typeof(MiscTools.YesNoTypeConverter))]public bool VNCViewOnly {get; set;}
#endregion
- [Browsable(false)] public ConnectionInfo Parent { get; private set; }
+ [Browsable(false)]
+ public ConnectionInfo Parent { get; private set; }
+
+ ///
+ /// Indicates whether this inheritance object is enabled.
+ /// When false, users of this object should not respect inheritance
+ /// settings for individual properties.
+ ///
+ [Browsable(false)]
+ public bool InheritanceActive { get; set; }
#endregion
@@ -408,31 +415,17 @@ namespace mRemoteNG.Connection
{
var newInheritance = (ConnectionInfoInheritance)MemberwiseClone();
newInheritance.Parent = parent;
- newInheritance._tempInheritanceStorage = null;
return newInheritance;
}
public void EnableInheritance()
{
- if (_tempInheritanceStorage != null)
- UnstashInheritanceData();
- }
-
- private void UnstashInheritanceData()
- {
- SetAllValues(_tempInheritanceStorage);
- _tempInheritanceStorage = null;
+ InheritanceActive = true;
}
public void DisableInheritance()
{
- StashInheritanceData();
- TurnOffInheritanceCompletely();
- }
-
- private void StashInheritanceData()
- {
- _tempInheritanceStorage = Clone(Parent);
+ InheritanceActive = false;
}
public void TurnOnInheritanceCompletely()
@@ -466,15 +459,22 @@ namespace mRemoteNG.Connection
///
public IEnumerable GetEnabledInheritanceProperties()
{
- return GetProperties()
- .Where(property => (bool)property.GetValue(this))
- .Select(property => property.Name)
- .ToList();
+ return InheritanceActive
+ ? GetProperties()
+ .Where(property => (bool)property.GetValue(this))
+ .Select(property => property.Name)
+ .ToList()
+ : Enumerable.Empty();
}
private bool FilterProperty(PropertyInfo propertyInfo)
{
- var exclusions = new[] {"EverythingInherited", "Parent"};
+ var exclusions = new[]
+ {
+ nameof(EverythingInherited),
+ nameof(Parent),
+ nameof(InheritanceActive)
+ };
var valueShouldNotBeFiltered = !exclusions.Contains(propertyInfo.Name);
return valueShouldNotBeFiltered;
}