/// <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 Analog Output
            if (typeof(AnalogOutput).IsAssignableFrom(source.GetType()))
            {
                Value = source as AnalogOutput;
                return(true);
            }

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

            //Cast from Instruction
            if (typeof(IInstruction).IsAssignableFrom(source.GetType()))
            {
                if (source is AnalogOutput 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 AnalogOutput instruction)
                {
                    Value = instruction;
                    return(true);
                }
            }

            return(false);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Data constructor: Creates a Instruction Goo instance from another Instruction Goo instance.
        /// This creates a shallow copy of the passed Instruction Goo instance.
        /// </summary>
        /// <param name="instructionGoo"> Instruction Goo instance to copy. </param>
        public GH_Instruction(GH_Instruction instructionGoo)
        {
            if (instructionGoo == null)
            {
                instructionGoo = new GH_Instruction();
            }

            this.Value = instructionGoo.Value;
        }
Exemplo n.º 3
0
        /// <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 Instruction
            if (typeof(IInstruction).IsAssignableFrom(source.GetType()))
            {
                Value = source as IInstruction;
                return(true);
            }

            //Cast from Instruction Goo
            if (typeof(GH_Instruction).IsAssignableFrom(source.GetType()))
            {
                GH_Instruction instructionGoo = source as GH_Instruction;
                Value = instructionGoo.Value as IInstruction;
                return(true);
            }

            return(false);
        }
Exemplo n.º 4
0
        /// <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);
        }
        /// <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 Wait Time
            if (typeof(WaitTime).IsAssignableFrom(source.GetType()))
            {
                Value = source as WaitTime;
                return(true);
            }

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

            // Cast from Number
            if (typeof(GH_Number).IsAssignableFrom(source.GetType()))
            {
                GH_Number ghNumber = (GH_Number)source;
                Value = new WaitTime(ghNumber.Value);
                return(true);
            }

            //Cast from Instruction
            if (typeof(IInstruction).IsAssignableFrom(source.GetType()))
            {
                if (source is WaitTime 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 WaitTime instruction)
                {
                    Value = instruction;
                    return(true);
                }
            }

            return(false);
        }
Exemplo n.º 6
0
        /// <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 Linear Configuration Control
            if (typeof(LinearConfigurationControl).IsAssignableFrom(source.GetType()))
            {
                Value = source as LinearConfigurationControl;
                return(true);
            }

            //Cast from Boolean
            if (typeof(GH_Boolean).IsAssignableFrom(source.GetType()))
            {
                GH_Boolean ghBoolean = source as GH_Boolean;
                Value = new LinearConfigurationControl(ghBoolean.Value);
                return(true);
            }

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

            //Cast from Instruction
            if (typeof(IInstruction).IsAssignableFrom(source.GetType()))
            {
                if (source is LinearConfigurationControl 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 LinearConfigurationControl instruction)
                {
                    Value = instruction;
                    return(true);
                }
            }
            return(false);
        }
Exemplo n.º 7
0
        /// <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 Override Robot Tool
            if (typeof(OverrideRobotTool).IsAssignableFrom(source.GetType()))
            {
                Value = source as OverrideRobotTool;
                return(true);
            }

            //Cast from Robot Tool Goo
            if (typeof(GH_RobotTool).IsAssignableFrom(source.GetType()))
            {
                GH_RobotTool robotToolGoo = source as GH_RobotTool;
                Value = new OverrideRobotTool(robotToolGoo.Value);
                return(true);
            }

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

            //Cast from Instruction
            if (typeof(IInstruction).IsAssignableFrom(source.GetType()))
            {
                if (source is OverrideRobotTool 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 OverrideRobotTool instruction)
                {
                    Value = instruction;
                    return(true);
                }
            }

            return(false);
        }