Example #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);
        }
Example #2
0
 /// <summary>get the name of the idl-file for the mapped type</summary>
 public string GetIdlFileForMappedType(MapTypeInfo mapped)
 {
     if (!IsCustomMappedToIdlType(mapped.Type))
     {
         object res = m_filesForMappedTypes[mapped];
         return((string)res);
     }
     else
     {
         GeneratorMappingPlugin     mappingPlugin = GeneratorMappingPlugin.GetSingleton();
         GeneratorCustomMappingDesc mappingDesc   = mappingPlugin.GetMappingForIdlTarget(mapped.Type);
         return(mappingDesc.IdlFileName);
     }
 }
        /// <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);
        }