Add() 공개 메소드

public Add ( string key, object value ) : Transformation
key string
value object
리턴 Transformation
예제 #1
0
        public Transformation Clone()
        {
            Transformation t = (Transformation)this.MemberwiseClone();

            t.m_transformParams = new Dictionary <string, object>();

            foreach (var key in m_transformParams.Keys)
            {
                if (m_transformParams[key] is Array)
                {
                    t.Add(key, ((Array)m_transformParams[key]).Clone());
                }
                else if (m_transformParams[key] is String || m_transformParams[key] is ValueType)
                {
                    t.Add(key, m_transformParams[key]);
                }
                else
                {
                    throw new ApplicationException(String.Format("Couldn't clone parameter '{0}'!", key));
                }
            }

            if (m_nestedTransforms != null)
            {
                t.m_nestedTransforms = new List <Transformation>();
                foreach (var nestedTransform in m_nestedTransforms)
                {
                    t.m_nestedTransforms.Add(nestedTransform.Clone());
                }
            }

            return(t);
        }
예제 #2
0
        /// <summary>
        /// Get a deep cloned copy of this transformation.
        /// </summary>
        /// <returns>A deep cloned copy of this transformation.</returns>
        public Transformation Clone()
        {
            Transformation t = (Transformation)this.MemberwiseClone();

            t.m_transformParams = new Dictionary <string, object>();

            foreach (var key in m_transformParams.Keys)
            {
                var value = m_transformParams[key];

                if (value is Array)
                {
                    t.Add(key, ((Array)value).Clone());
                }
                else if (value is string || value is ValueType || value is BaseExpression)
                {
                    t.Add(key, value);
                }
                else if (value is Core.ICloneable)
                {
                    t.Add(key, ((Core.ICloneable)value).Clone());
                }
                else if (value is Dictionary <string, string> )
                {
                    t.Add(key, new Dictionary <string, string>((Dictionary <string, string>)value));
                }
                else
                {
                    throw new Exception(string.Format("Couldn't clone parameter '{0}'!", key));
                }
            }

            if (m_nestedTransforms != null)
            {
                t.m_nestedTransforms = new List <Transformation>();
                foreach (var nestedTransform in m_nestedTransforms)
                {
                    t.m_nestedTransforms.Add(nestedTransform.Clone());
                }
            }

            return(t);
        }