Esempio n. 1
0
        /// <summary>
        /// Adds the specified mapping info to the internal mappings table.
        /// </summary>
        /// <param name="mappingInfo">The mapping info targetProperty be added.</param>
        protected void AddMappingInfo(MemberMappingInfo <TSource, TTarget> mappingInfo)
        {
            if (this.CurrentStatus == MapperStatus.Active)
            {
                throw new InvalidOperationException("Cannot add mappings to an already active mapper");
            }
            else if (this.CurrentStatus == MapperStatus.New)
            {
                this.CurrentStatus = MapperStatus.Initialized;
            }

            this.TypeMapping.Add(mappingInfo);
        }
Esempio n. 2
0
        /// <summary>Initializes the internal mapping.</summary>
        private void InitializeMapping()
        {
            if (this.TypeMapping == null)
            {
                lock (this.syncRoot)
                {
                    if (this.TypeMapping == null)
                    {
                        this.TypeMapping = new TypeMappingInfo <TSource, TTarget>();
                    }
                }
            }

            var mappings = this.GetMappings();

            if (mappings != null)
            {
                this.TypeMapping.AddRange(this.GetMappings());
            }

            this.TypeMapping.Compile();

            this.CurrentStatus = MapperStatus.Active;
        }