Skip to content

Commit e6e3137

Browse files
committed
Add copy constructors to main library classes
1 parent fdf49b2 commit e6e3137

13 files changed

+131
-2
lines changed

OpenEphys.Onix1.Design/NeuropixelsV1Editor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public override bool EditComponent(ITypeDescriptorContext context, object compon
2222

2323
if (editorDialog.ShowDialog() == DialogResult.OK)
2424
{
25-
configureNeuropixelsV1.ProbeConfiguration = editorDialog.ProbeConfigurationDialog.ProbeConfiguration;
25+
DesignHelper.CopyProperties(editorDialog.ConfigureNode, configureNeuropixelsV1, DesignHelper.PropertiesToIgnore);
2626

2727
return true;
2828
}

OpenEphys.Onix1/ConfigureHeadstage64.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,22 @@ public ConfigureHeadstage64()
4444
PortControl.HubConfiguration = HubConfiguration.Standard;
4545
}
4646

47+
/// <summary>
48+
/// Initializes a copied instance of the <see cref="ConfigureHeadstage64"/> class.
49+
/// </summary>
50+
/// <param name="configureNode">Existing <see cref="ConfigureHeadstage64"/> instance.</param>
51+
public ConfigureHeadstage64(ConfigureHeadstage64 configureNode)
52+
{
53+
Name = configureNode.Name;
54+
Port = configureNode.Port;
55+
PortControl = configureNode.PortControl;
56+
Rhd2164 = new(configureNode.Rhd2164);
57+
Bno055 = new(configureNode.Bno055);
58+
TS4231 = new(configureNode.TS4231);
59+
ElectricalStimulator = new(configureNode.ElectricalStimulator);
60+
OpticalStimulator = new(configureNode.OpticalStimulator);
61+
}
62+
4763
/// <summary>
4864
/// Gets or sets the Rhd2164 configuration.
4965
/// </summary>

OpenEphys.Onix1/ConfigureHeadstageNeuropixelsV1e.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,19 @@ public ConfigureHeadstageNeuropixelsV1e()
3838
PortControl.HubConfiguration = HubConfiguration.Passthrough;
3939
}
4040

41+
/// <summary>
42+
/// Initializes a copied instance of the <see cref="ConfigureHeadstageNeuropixelsV1f"/> class.
43+
/// </summary>
44+
/// <param name="configureNode">Existing <see cref="ConfigureHeadstageNeuropixelsV1f"/> instance.</param>
45+
public ConfigureHeadstageNeuropixelsV1e(ConfigureHeadstageNeuropixelsV1e configureNode)
46+
{
47+
Name = configureNode.Name;
48+
Port = configureNode.Port;
49+
PortControl = configureNode.PortControl;
50+
NeuropixelsV1e = configureNode.NeuropixelsV1e.Clone() as ConfigureNeuropixelsV1e ?? throw new InvalidOperationException($"Unable to copy {nameof(NeuropixelsV1e)} property. Could not cast to the correct type.");
51+
Bno055 = new(configureNode.Bno055);
52+
}
53+
4154
/// <summary>
4255
/// Gets or sets the NeuropixelsV1e configuration.
4356
/// </summary>

OpenEphys.Onix1/ConfigureHeadstageNeuropixelsV1f.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,21 @@ public ConfigureHeadstageNeuropixelsV1f()
4040
PortControl.HubConfiguration = HubConfiguration.Standard;
4141
}
4242

43+
/// <summary>
44+
/// Initializes a copied instance of the <see cref="ConfigureHeadstageNeuropixelsV1f"/> class.
45+
/// </summary>
46+
/// <param name="configureNode">Existing <see cref="ConfigureHeadstageNeuropixelsV1f"/> instance.</param>
47+
public ConfigureHeadstageNeuropixelsV1f(ConfigureHeadstageNeuropixelsV1f configureNode)
48+
{
49+
Name = configureNode.Name;
50+
Port = configureNode.Port;
51+
PortControl = configureNode.PortControl;
52+
NeuropixelsV1A = configureNode.NeuropixelsV1A.Clone() as ConfigureNeuropixelsV1f ?? throw new InvalidOperationException($"Unable to copy {nameof(NeuropixelsV1A)} property. Could not cast to the correct type.");
53+
NeuropixelsV1B = configureNode.NeuropixelsV1B.Clone() as ConfigureNeuropixelsV1f ?? throw new InvalidOperationException($"Unable to copy {nameof(NeuropixelsV1B)} property. Could not cast to the correct type.");
54+
Bno055 = new(configureNode.Bno055);
55+
TS4231 = new(configureNode.TS4231);
56+
}
57+
4358
/// <summary>
4459
/// Gets or sets the NeuropixelsV1 probe A configuration.
4560
/// </summary>

OpenEphys.Onix1/ConfigureHeadstageNeuropixelsV2e.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,27 @@ public class ConfigureHeadstageNeuropixelsV2e : MultiDeviceFactory
2929
readonly ConfigureNeuropixelsV2ePortController PortControl = new();
3030

3131
/// <summary>
32-
/// Initializes a new instance of the <see cref="ConfigureNeuropixelsV2e"/> class.
32+
/// Initializes a new instance of the <see cref="ConfigureHeadstageNeuropixelsV2e"/> class.
3333
/// </summary>
3434
public ConfigureHeadstageNeuropixelsV2e()
3535
{
3636
Port = PortName.PortA;
3737
PortControl.HubConfiguration = HubConfiguration.Passthrough;
3838
}
3939

40+
/// <summary>
41+
/// Initializes a copied instance of the <see cref="ConfigureHeadstageNeuropixelsV2e"/> class.
42+
/// </summary>
43+
/// <param name="configureNode">Existing <see cref="ConfigureHeadstageNeuropixelsV2e"/> instance.</param>
44+
public ConfigureHeadstageNeuropixelsV2e(ConfigureHeadstageNeuropixelsV2e configureNode)
45+
{
46+
Name = configureNode.Name;
47+
Port = configureNode.Port;
48+
PortControl = configureNode.PortControl;
49+
NeuropixelsV2e = configureNode.NeuropixelsV2e.Clone() as ConfigureNeuropixelsV2e ?? throw new InvalidOperationException($"Unable to copy {nameof(NeuropixelsV2e)} property. Could not cast to the correct type.");
50+
Bno055 = new(configureNode.Bno055);
51+
}
52+
4053
/// <summary>
4154
/// Gets or sets the NeuropixelsV2e configuration.
4255
/// </summary>

OpenEphys.Onix1/ConfigureHeadstageNeuropixelsV2eBeta.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,19 @@ public ConfigureHeadstageNeuropixelsV2eBeta()
3737
PortControl.HubConfiguration = HubConfiguration.Passthrough;
3838
}
3939

40+
/// <summary>
41+
/// Initializes a copied instance of the <see cref="ConfigureHeadstageNeuropixelsV2e"/> class.
42+
/// </summary>
43+
/// <param name="configureNode">Existing <see cref="ConfigureHeadstageNeuropixelsV2eBeta"/> instance.</param>
44+
public ConfigureHeadstageNeuropixelsV2eBeta(ConfigureHeadstageNeuropixelsV2eBeta configureNode)
45+
{
46+
Name = configureNode.Name;
47+
Port = configureNode.Port;
48+
PortControl = configureNode.PortControl;
49+
NeuropixelsV2eBeta = configureNode.NeuropixelsV2eBeta.Clone() as ConfigureNeuropixelsV2eBeta ?? throw new InvalidOperationException($"Unable to copy {nameof(NeuropixelsV2eBeta)} property. Could not cast to the correct type.");
50+
Bno055 = new(configureNode.Bno055);
51+
}
52+
4053
/// <summary>
4154
/// Gets or sets the NeuropixelsV2eBeta configuration.
4255
/// </summary>

OpenEphys.Onix1/ConfigureHeadstageRhs2116.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,19 @@ public ConfigureHeadstageRhs2116()
3838
LinkController.HubConfiguration = HubConfiguration.Standard;
3939
}
4040

41+
/// <summary>
42+
/// Initializes a copied instance of the <see cref="ConfigureHeadstageRhs2116"/> class.
43+
/// </summary>
44+
/// <param name="configureNode">Existing <see cref="ConfigureHeadstageRhs2116"/> instance.</param>
45+
public ConfigureHeadstageRhs2116(ConfigureHeadstageRhs2116 configureNode)
46+
{
47+
Name = configureNode.Name;
48+
Port = configureNode.Port;
49+
LinkController = configureNode.LinkController;
50+
Rhs2116Pair = new(configureNode.Rhs2116Pair);
51+
StimulusTrigger = new(configureNode.StimulusTrigger);
52+
}
53+
4154
/// <summary>
4255
/// Gets or sets the Rhs2116Pair configuration.
4356
/// </summary>

OpenEphys.Onix1/ConfigureNeuropixelsV1e.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,15 @@ public ConfigureNeuropixelsV1e(ConfigureNeuropixelsV1e configureNeuropixelsV1e)
4040
DeviceAddress = configureNeuropixelsV1e.DeviceAddress;
4141
}
4242

43+
/// <summary>
44+
/// Returns a deep copy of the current <see cref="ConfigureNeuropixelsV1e"/> instance.
45+
/// </summary>
46+
/// <returns><see cref="ConfigureNeuropixelsV1e"/> instance.</returns>
47+
public IConfigureNeuropixelsV1 Clone()
48+
{
49+
return new ConfigureNeuropixelsV1e(this);
50+
}
51+
4352
/// <inheritdoc/>
4453
/// <remarks>
4554
/// If set to true, <see cref="NeuropixelsV1eData"/> will produce data. If set to false,

OpenEphys.Onix1/ConfigureNeuropixelsV1f.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,15 @@ public ConfigureNeuropixelsV1f(ConfigureNeuropixelsV1f configureNeuropixelsV1f)
4848
DeviceAddress = configureNeuropixelsV1f.DeviceAddress;
4949
}
5050

51+
/// <summary>
52+
/// Returns a deep copy of the current <see cref="ConfigureNeuropixelsV1f"/> instance.
53+
/// </summary>
54+
/// <returns><see cref="ConfigureNeuropixelsV1f"/> instance.</returns>
55+
public IConfigureNeuropixelsV1 Clone()
56+
{
57+
return new ConfigureNeuropixelsV1f(this);
58+
}
59+
5160
/// <inheritdoc/>
5261
/// <remarks>
5362
/// If set to true, <see cref="NeuropixelsV1fData"/> will produce data. If set to false,

OpenEphys.Onix1/ConfigureNeuropixelsV2e.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,15 @@ public ConfigureNeuropixelsV2e(ConfigureNeuropixelsV2e configureNode)
3636
DeviceAddress = configureNode.DeviceAddress;
3737
}
3838

39+
/// <summary>
40+
/// Returns a deep copy of the current <see cref="ConfigureNeuropixelsV2e"/> instance.
41+
/// </summary>
42+
/// <returns><see cref="ConfigureNeuropixelsV2e"/> instance.</returns>
43+
public IConfigureNeuropixelsV2 Clone()
44+
{
45+
return new ConfigureNeuropixelsV2e(this);
46+
}
47+
3948
/// <inheritdoc/>
4049
/// <remarks>
4150
/// If set to true, <see cref="NeuropixelsV2eData"/> will produce data. If set to false,

0 commit comments

Comments
 (0)