Microsoft.Practices.Prism.Regions.RegionAdapterMappings.RegisterMapping C# (CSharp) Method

RegisterMapping() public method

Registers the mapping between a type and an adapter.
When any of or are . If a mapping for already exists.
public RegisterMapping ( Type controlType, IRegionAdapter adapter ) : void
controlType System.Type The type of the control.
adapter IRegionAdapter The adapter to use with the type.
return void
        public void RegisterMapping(Type controlType, IRegionAdapter adapter)
        {
            if (controlType == null) throw new ArgumentNullException("controlType");
            if (adapter == null) throw new ArgumentNullException("adapter");
            Contract.EndContractBlock();

            if (mappings.ContainsKey(controlType))
            {
                throw new InvalidOperationException(String.Format(CultureInfo.CurrentCulture,
                                                                  Resources.MappingExistsException, controlType.Name));
            }

            mappings.Add(controlType, adapter);
        }

Usage Example

        public void RegisterAMappingThatAlreadyExistsThrows()
        {
            var regionAdapterMappings = new RegionAdapterMappings();
            var regionAdapter = new MockRegionAdapter();

            regionAdapterMappings.RegisterMapping(typeof(ItemsControl), regionAdapter);
            regionAdapterMappings.RegisterMapping(typeof(ItemsControl), regionAdapter);
        }
All Usage Examples Of Microsoft.Practices.Prism.Regions.RegionAdapterMappings::RegisterMapping
RegionAdapterMappings