CSE.Exps.CseObject.Clone C# (CSharp) Method

Clone() public method

Creates a shallow copy of this object with a new value
public Clone ( dynamic newValue ) : CseObject
newValue dynamic Value to give the cloned object
return CseObject
		public CseObject Clone(dynamic newValue) {
			return new CseObject(newValue) {
				CallMod = this.CallMod,
				CompileTimeType = this.CompileTimeType,
				IsLiteral = this.IsLiteral,
				EnvChain = this.EnvChain,
				EnvNames = this.EnvNames,
				EnvIndices = this.EnvIndices
			};
		}
	}

Same methods

CseObject::Clone ( ) : object

Usage Example

Ejemplo n.º 1
0
        ///
        /// <summary>
        ///		Applies numeric affirmation (i.e. unary plus) to numeric values
        /// </summary>
        ///
        /// <param name="obj">The CseObject with the value to affirm</param>
        ///
        /// <returns>The CseObject after affirmation</returns>
        ///
        /// <exception cref="CseLogicExceptionType.CANT_AFFIRM_NON_NUM" />
        ///
        internal static CseObject Affirm(CseObject obj)
        {
            CseObject result = (CseObject)obj.Clone();

            dynamic value = obj.Value;
            double  numValue;

            if (value is string)
            {
                throw new CseLogicException(CseLogicExceptionType.CANT_AFFIRM_NON_NUM, value.ToString());
            }
            else if (!double.TryParse(value.ToString(), out numValue))
            {
                MethodInfo mi = value.GetType().GetMethod(OpOverloadNames.UPLUS);
                if (null != mi)
                {
                    result.Value = value.GetType().InvokeMember(OpOverloadNames.UPLUS, OpOverloadNames.Flags, null, CsEval.evalEnvironment, new object[] { value });
                    return(result);
                }
                else
                {
                    throw new CseLogicException(CseLogicExceptionType.CANT_AFFIRM_NON_NUM, value.ToString());
                }
            }

            return(result);
        }
All Usage Examples Of CSE.Exps.CseObject::Clone