/// <summary>
        /// Data constructor: Creates a Declaration Goo instance from another Declaration Goo instance.
        /// This creates a shallow copy of the passed Declaration Goo instance.
        /// </summary>
        /// <param name="declarationGoo"> Declaration Goo instance to copy. </param>
        public GH_Declaration(GH_Declaration declarationGoo)
        {
            if (declarationGoo == null)
            {
                declarationGoo = new GH_Declaration();
            }

            this.Value = declarationGoo.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 Declaration
            if (typeof(IDeclaration).IsAssignableFrom(source.GetType()))
            {
                Value = source as IDeclaration;
                return(true);
            }

            //Cast from Declaration Goo
            if (typeof(GH_Declaration).IsAssignableFrom(source.GetType()))
            {
                GH_Declaration declarationGoo = source as GH_Declaration;
                Value = declarationGoo.Value as IDeclaration;
                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 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 Zone Data: Custom Zone Data
            if (typeof(ZoneData).IsAssignableFrom(source.GetType()))
            {
                Value = (ZoneData)source;
                return(true);
            }

            //Cast from Number: Predefined Zone Data
            if (typeof(GH_Number).IsAssignableFrom(source.GetType()))
            {
                Value = new ZoneData((source as GH_Number).Value);
                return(true);
            }

            //Cast from Integer: Predefined Zone Data
            if (typeof(GH_Integer).IsAssignableFrom(source.GetType()))
            {
                Value = new ZoneData((source as GH_Integer).Value);
                return(true);
            }

            //Cast from Action
            if (typeof(RobotComponents.Actions.Action).IsAssignableFrom(source.GetType()))
            {
                if (source is ZoneData 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 ZoneData action)
                {
                    Value = action;
                    return(true);
                }
            }

            //Cast from Declaration
            if (typeof(IDeclaration).IsAssignableFrom(source.GetType()))
            {
                if (source is ZoneData zonedata)
                {
                    Value = zonedata;
                    return(true);
                }
            }

            //Cast from Declaration Goo
            if (typeof(GH_Declaration).IsAssignableFrom(source.GetType()))
            {
                GH_Declaration declarationGoo = source as GH_Declaration;
                if (declarationGoo.Value is ZoneData zonedata)
                {
                    Value = zonedata;
                    return(true);
                }
            }

            //Cast from Text: Predefined Zone Data
            if (typeof(GH_String).IsAssignableFrom(source.GetType()))
            {
                string text = (source as GH_String).Value;

                if (text == "fine")
                {
                    Value = new ZoneData(-1);
                    return(true);
                }

                else if (text.Contains("z"))
                {
                    if (ZoneData.ValidPredefinedNames.Contains(text))
                    {
                        try
                        {
                            text = text.Replace("z", String.Empty); // Changes z1 to 1, z5 to 5 etc.
                            double number = System.Convert.ToDouble(text);
                            Value = new ZoneData(number);
                            return(true);
                        }
                        catch
                        {
                            return(false);
                        }
                    }
                }

                else
                {
                    try
                    {
                        double number = System.Convert.ToDouble(text);
                        Value = new ZoneData(number);
                        return(true);
                    }
                    catch
                    {
                        return(false);
                    }
                }
            }

            return(false);
        }