Structure of the Alias Map component
The Alias Map component is based on five main object interfaces; IMapper, IGenerator, IDictionary, IAlias, and IAliasCollection.
The generator can produce several suggestions for an alias when given an input name. The dictionary keeps track of the aliases that have already been used. The generator is not concerned about which aliases have been used, and the dictionary is not concerned with how the aliases are generated. This means that you can use different generators for different problems, while using the same dictionary to avoid duplicates.
IMapper gives access to a simple helper object that points to a generator and a dictionary. IMapper is designed to simplify interaction with the generator and dictionary. IMapper.CreateAlias(text)->IAlias uses the generator repeatedly until it gets an alias name that it cannot find in the dictionary. It stores that name in the dictionary and returns the resulting Alias object. IMapper.MaxAttempts is a safety valve that can be used to prevent the generator repeating itself indefinitely. The default value is 0, which means unlimited and can result in an infinite loop if the generator is not configured appropriately.
The IDictionary interface gives access to an Alias object for each stored alias name. The Alias object can store a reference to a COM object, and this feature can be used to associate the alias with an object. Typically this object has a Name property, which is used as the input for the generator, but this is not a requirement; the name can come from anywhere. The dictionary can be case sensitive or case insensitive. However, this must be decided while the dictionary is still empty.
IAliasCollection is used when more than one alias is created from a single input text. IAliasCollection can also be used by user objects to store a list of aliases that have something in common, such as referencing the same object.
The overall principle of the Alias Map component object model is that you cannot create an object and insert it into a collection. The object model creates its own objects and gives them to you. The only exception is IMapper and IAliasCollection, which operate on the public interfaces alone.
See also