예제 #1
0
        /// <summary>
        /// Queues a request to create an IMapper.
        /// </summary>
        /// <param name="mapperRequest"></param>
        /// <returns>The 'true' key present in the dictionary. This will be the key given if no previous matching registration has occured.</returns>

        public IAutoMapperRequestKeyGen RegisterAutoMapperRequest(IAutoMapperRequestKeyGen mapperRequest)
        {
            IAutoMapperRequestKeyGen result;

            if (_sealedAutoMappers.ContainsKey(mapperRequest))
            {
                //ICollection<IAutoMapperRequestKeyGen> keys = _sealedAutoMappers.Keys;

                //// TODO: This is relatively resource intensive, perhaps there's a better way.
                //IAutoMapperRequestKeyGen existingKey = keys.FirstOrDefault(x => x.DestinationTypeGenDef.Equals(autoMapperRequestKeyGen.DestinationTypeGenDef));

                //if(!ReferenceEquals(existingKey, autoMapperRequestKeyGen))
                //{
                //    System.Diagnostics.Debug.WriteLine("The mapRequest given to RegisterRawAutoMapperRequest was not the original key.");
                //}
                //result = existingKey;
                result = mapperRequest;
            }
            else
            {
                _unSealedAutoMappers.GetOrAdd(mapperRequest);
                result = mapperRequest;
            }

            return(result);
        }
예제 #2
0
        /// <summary>
        /// Queues a request to create and IMapper and a new PropBagMapper to be created from the IMapper.
        /// </summary>
        /// <param name="mapperRequest"></param>
        /// <returns>The 'true' key present in the dictionary. This will be the key given if no previous matching registration has occured.</returns>
        public IPropBagMapperRequestKeyGen RegisterPropBagMapperRequest(IPropBagMapperRequestKeyGen mapperRequest)
        {
            IPropBagMapperRequestKeyGen result;

            if (_propBagMappers.ContainsKey(mapperRequest))
            {
                //ICollection<IPropBagMapperKeyGen> keys = _propBagMappers.Keys;

                //// TODO: This is relatively resource intensive, perhaps there's a better way.
                //IPropBagMapperKeyGen existingRequest = keys.FirstOrDefault
                //    (
                //    x => x.DestinationTypeGenDef.Equals(mapperRequest.DestinationTypeGenDef)
                //    );

                //result = existingRequest;
                result = mapperRequest;
            }
            else
            {
                IPropBagMapperRequestKeyGen newOrExistingRequest = _requests.GetOrAdd(mapperRequest);
                result = newOrExistingRequest;
            }

            return(result);
        }
예제 #3
0
 // TODO: Need to aquire a lock here.
 public void Register(IPropBagMapperKeyGen mapRequest)
 {
     if (!_sealedPropBagMappers.ContainsKey(mapRequest))
     {
         _unSealedPropBagMappers.GetOrAdd(mapRequest);
     }
 }