/// <summary> /// Data constructor: Creates a Joint Target Goo instance from another Joint Target instance. /// This creates a shallow copy of the passed Joint Target Goo instance. /// </summary> /// <param name="jointTargetGoo"> Joint Target Goo instance to copy. </param> public GH_JointTarget(GH_JointTarget jointTargetGoo) { if (jointTargetGoo == null) { jointTargetGoo = new GH_JointTarget(); } this.Value = jointTargetGoo.Value; }
/// <summary> /// Attempt a cast from generic object. /// </summary> /// <param name="source"> Reference to source of cast. </param> /// <returns> True on success, false on failure. </returns> public override bool CastFrom(object source) { if (source == null) { return(false); } //Cast from Target if (typeof(ITarget).IsAssignableFrom(source.GetType())) { if (source is JointTarget target) { Value = target; return(true); } } //Cast from Target Goo if (typeof(GH_Target).IsAssignableFrom(source.GetType())) { GH_Target targetGoo = source as GH_Target; if (targetGoo.Value is JointTarget target) { Value = target; return(true); } } //Cast from Action if (typeof(Action).IsAssignableFrom(source.GetType())) { if (source is JointTarget action) { Value = action; return(true); } } //Cast from Action Goo if (typeof(GH_Action).IsAssignableFrom(source.GetType())) { GH_Action actionGoo = source as GH_Action; if (actionGoo.Value is JointTarget action) { Value = action; return(true); } } //Cast from Joint Target if (typeof(JointTarget).IsAssignableFrom(source.GetType())) { Value = source as JointTarget; return(true); } //Cast from Joint Target Goo if (typeof(GH_JointTarget).IsAssignableFrom(source.GetType())) { GH_JointTarget targetGoo = source as GH_JointTarget; Value = targetGoo.Value; return(true); } //Cast from Declaration if (typeof(IDeclaration).IsAssignableFrom(source.GetType())) { if (source is JointTarget target) { Value = target; return(true); } } //Cast from Declaration Goo if (typeof(GH_Declaration).IsAssignableFrom(source.GetType())) { GH_Declaration declarationGoo = source as GH_Declaration; if (declarationGoo.Value is JointTarget target) { Value = target; return(true); } } return(false); }
/// <summary> /// Attempt a cast from generic object. /// </summary> /// <param name="source"> Reference to source of cast. </param> /// <returns> True on success, false on failure. </returns> public override bool CastFrom(object source) { if (source == null) { return(false); } //Cast from Movement if (typeof(Movement).IsAssignableFrom(source.GetType())) { Value = source as Movement; return(true); } //Cast from Target if (typeof(ITarget).IsAssignableFrom(source.GetType())) { Value = new Movement(source as ITarget); return(true); } //Cast from Target Goo if (typeof(GH_Target).IsAssignableFrom(source.GetType())) { GH_Target targetGoo = source as GH_Target; Value = new Movement(targetGoo.Value); return(true); } //Cast from Robot Target if (typeof(RobotTarget).IsAssignableFrom(source.GetType())) { RobotTarget target = (RobotTarget)source; Value = new Movement(target); return(true); } //Cast from Robot Target Goo if (typeof(GH_RobotTarget).IsAssignableFrom(source.GetType())) { GH_RobotTarget targetGoo = (GH_RobotTarget)source; Value = new Movement(targetGoo.Value); return(true); } //Cast from Joint Target if (typeof(JointTarget).IsAssignableFrom(source.GetType())) { JointTarget target = (JointTarget)source; Value = new Movement(target); return(true); } //Cast from Joint Target Goo if (typeof(GH_JointTarget).IsAssignableFrom(source.GetType())) { GH_JointTarget targetGoo = (GH_JointTarget)source; Value = new Movement(targetGoo.Value); return(true); } //Cast from Action if (typeof(Action).IsAssignableFrom(source.GetType())) { if (source is Movement action) { Value = action; return(true); } } //Cast from Action Goo if (typeof(GH_Action).IsAssignableFrom(source.GetType())) { GH_Action actionGoo = source as GH_Action; if (actionGoo.Value is Movement action) { Value = action; return(true); } } //Cast from Instruction if (typeof(IInstruction).IsAssignableFrom(source.GetType())) { if (source is Movement instruction) { Value = instruction; return(true); } } //Cast from Instruction Goo if (typeof(GH_Instruction).IsAssignableFrom(source.GetType())) { GH_Instruction instructionGoo = source as GH_Instruction; if (instructionGoo.Value is Movement instruction) { Value = instruction; return(true); } } return(false); }