/// <summary> /// Creates a clone of this instance /// </summary> /// <returns>Clone of this instance</returns> public object Clone() { MachineModel clone = new MachineModel { Channels = (Channels)Channels.Clone(), Directories = (Directories)Directories.Clone(), Electronics = (Electronics)Electronics.Clone(), Heat = (Heat)Heat.Clone(), Job = (Job)Job.Clone(), MessageBox = (MessageBox)MessageBox.Clone(), Move = (Move)Move.Clone(), Network = (Network)Network.Clone(), Scanner = (Scanner)Scanner.Clone(), Sensors = (Sensors)Sensors.Clone(), State = (State)State.Clone() }; ListHelpers.CloneItems(clone.Fans, Fans); ListHelpers.CloneItems(clone.HttpEndpoints, HttpEndpoints); ListHelpers.CloneItems(clone.Lasers, Lasers); ListHelpers.CloneItems(clone.Messages, Messages); ListHelpers.CloneItems(clone.Spindles, Spindles); ListHelpers.CloneItems(clone.Storages, Storages); ListHelpers.CloneItems(clone.Tools, Tools); ListHelpers.CloneItems(clone.UserSessions, UserSessions); ListHelpers.CloneItems(clone.UserVariables, UserVariables); return(clone); }
/// <summary> /// Assigns every property from another instance /// </summary> /// <param name="from">Object to assign from</param> /// <exception cref="ArgumentNullException">other is null</exception> /// <exception cref="ArgumentException">Types do not match</exception> public void Assign(object from) { if (from == null) { throw new ArgumentNullException(); } if (!(from is MachineModel other)) { throw new ArgumentException("Invalid type"); } Channels.Assign(other.Channels); Directories.Assign(other.Directories); Electronics.Assign(other.Electronics); ListHelpers.AssignList(Fans, other.Fans); Heat.Assign(other.Heat); ListHelpers.AssignList(HttpEndpoints, other.HttpEndpoints); Job.Assign(other.Job); ListHelpers.AssignList(Lasers, other.Lasers); MessageBox.Assign(other.MessageBox); ListHelpers.AssignList(Messages, other.Messages); Move.Assign(other.Move); Network.Assign(other.Network); Scanner.Assign(other.Scanner); Sensors.Assign(other.Sensors); ListHelpers.AssignList(Spindles, other.Spindles); State.Assign(other.State); ListHelpers.AssignList(Storages, other.Storages); ListHelpers.AssignList(Tools, other.Tools); ListHelpers.AssignList(UserSessions, other.UserSessions); ListHelpers.AssignList(UserVariables, other.UserVariables); }
/// <summary> /// Creates a clone of this instance /// </summary> /// <returns>A clone of this instance</returns> public object Clone() { Sensors clone = new Sensors(); ListHelpers.CloneItems(clone.Endstops, Endstops); ListHelpers.CloneItems(clone.Probes, Probes); return(clone); }
/// <summary> /// Creates a duplicate of the full object model /// </summary> /// <returns>A clone of this model</returns> public object Clone() { return(new MachineModel { Channels = (Channels)Channels.Clone(), Electronics = (Electronics)Electronics.Clone(), Fans = Fans.Select(fan => (Fan)fan.Clone()).ToList(), Heat = (Heat)Heat.Clone(), Job = (Job)Job.Clone(), MessageBox = (MessageBox)MessageBox.Clone(), Move = (Move)Move.Clone(), Network = (Network)Network.Clone(), Messages = Messages.Select(item => (Message)item.Clone()).ToList(), Scanner = (Scanner)Scanner.Clone(), Sensors = (Sensors)Sensors.Clone(), Spindles = Spindles.Select(spindle => (Spindle)spindle.Clone()).ToList(), State = (State)State.Clone(), Storages = Storages.Select(storage => (Storage)storage.Clone()).ToList(), Tools = Tools.Select(tool => (Tool)tool.Clone()).ToList() }); }