Beispiel #1
0
        /// <summary>
        /// specify a special mapping, e.g. CLS ArrayList <=> java.util.ArrayList.
        /// </summary>
        /// <param name="clsType">the native cls type, e.g. ArrayList</param>
        /// <param name="idlType">the target idl type (mapped from idl to CLS)</param>
        /// <param name="idlFileName">the file containing the idl for the target idl-type</param>
        private void AddMapping(Type clsType, Type idlType, string idlFileName)
        {
            // check that idlType implements IIdlEntity:
            Type idlEntityType = typeof(IIdlEntity);

            if (!(idlEntityType.IsAssignableFrom(idlType)))
            {
                throw new Exception("illegal target type for custom mapping encountered: " + idlType.FullName);
            }
            // mapping must be bijective, i.e. for an idl type only one cls type is allowed and vice versa
            if (m_inverseMappingTable.ContainsKey(idlType) && (!((CustomMappingDesc)m_inverseMappingTable[idlType]).ClsType.Equals(clsType)))
            {
                throw new Exception("mapping constraint violated, tried to insert another cls type " + clsType +
                                    "mapped to the idl type " + idlType);
            }

            GeneratorCustomMappingDesc desc = new GeneratorCustomMappingDesc(clsType, idlType, idlFileName);

            m_mappingTable[clsType]        = desc;
            m_inverseMappingTable[idlType] = desc;
            // add also to the channel custom mapper reg for CLS to IDL mapper
            CustomMapperRegistry reg = CustomMapperRegistry.GetSingleton();

            reg.AddMapping(clsType, idlType, null);
        }
Beispiel #2
0
 static CustomMapperRegistry()
 {
     s_registry = new CustomMapperRegistry();
 }
 static CustomMapperRegistry() {
     s_registry = new CustomMapperRegistry();
 }