/// <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 idl type (mapped from idl to CLS) used to describe serialisation / deserialisation, e.g. java.util.ArrayListImpl</param> /// <param name="mapper">the mapper, knowing how to map instances of CLS ArrayList to java.util.ArrayListImpl and in the other direction</param> public void AddMapping(Type clsType, Type idlType, ICustomMapper mapper) { // check that idlType implements IIdlEntity: if (!(ReflectionHelper.IIdlEntityType.IsAssignableFrom(idlType))) { throw new Exception("illegal type for custom mapping encountered: " + idlType.FullName); } // be aware: mapping is not bijektive, because of impl classes; however for an idl type only one // cls type is allowed if (m_mappingsIdl.ContainsKey(idlType) && (!((CustomMappingDesc)m_mappingsIdl[idlType]).ClsType.Equals(clsType))) { throw new Exception("mapping constraint violated, tried to insert another cls type " + clsType + "mapped to the idl type " + idlType); } CustomMappingDesc desc = new CustomMappingDesc(clsType, idlType, mapper); m_mappingsCls[clsType] = desc; m_mappingsIdl[idlType] = desc; // check for impl class attribute, if present: add impl class here too object[] implAttr = idlType.GetCustomAttributes(ReflectionHelper.ImplClassAttributeType, false); if ((implAttr != null) && (implAttr.Length > 0)) { ImplClassAttribute implCl = (ImplClassAttribute)implAttr[0]; // get the type Type implIdlType = Repository.GetValueTypeImplClass(implCl.ImplClass); if (implIdlType != null) // if impl type not found, (test needed e.g. when called from CLSToIDLGen) { CustomMappingDesc descImpl = new CustomMappingDesc(clsType, implIdlType, mapper); m_mappingsIdl[implIdlType] = descImpl; } } }
/// <summary> /// See <see cref="System.Attribute.Equals"/>. /// </summary> public override bool Equals(object obj) { ImplClassAttribute other = obj as ImplClassAttribute; if (other == null) { return(false); } return(m_implClass != null ? m_implClass == other.m_implClass : other.m_implClass == null); }