示例#1
0
 /// <summary>
 /// Adds a type mapper to the chain with given priority. If mapper privided as an external MBean, the
 /// <paramref name="objectName"/> arguments is the name of this MBean; otherwise it is null.
 /// </summary>
 /// <param name="mapper">The mapper instance. In case of external mapper this is a reference to proxy of the MBean.</param>
 /// <param name="objectName">In case of external mapper, this is its <see cref="ObjectName"/>.</param>
 /// <param name="priority">The priority of a mapper. Must be unique.</param>
 /// <exception cref="NonUniquePriorityException">Another mapper with privided priority is already registered.</exception>
 public void AddTypeMapper(ITypeMapper mapper, ObjectName objectName, int priority)
 {
     TypeMapperInfo newMapperInfo = new TypeMapperInfo(priority, objectName == null ? mapper.GetType().AssemblyQualifiedName : null, objectName);
      if (_mappers.ContainsKey(priority))
      {
     TypeMapperInfo exisingMapperInfo = _mapperInfos.Find(delegate(TypeMapperInfo info)
                                                             {
                                                                return info.Priority == priority;
                                                             });
     throw new NonUniquePriorityException(
        newMapperInfo.ObjectName != null ? newMapperInfo.ObjectName.ToString() : newMapperInfo.TypeName,
        exisingMapperInfo.ObjectName != null ? exisingMapperInfo.ObjectName.ToString() : exisingMapperInfo.TypeName,
        priority
        );
      }
      _mappers.Add(priority, mapper);
      _mapperInfos.Add(newMapperInfo);
 }
示例#2
0
        /// <summary>
        /// Adds a type mapper to the chain with given priority. If mapper privided as an external MBean, the
        /// <paramref name="objectName"/> arguments is the name of this MBean; otherwise it is null.
        /// </summary>
        /// <param name="mapper">The mapper instance. In case of external mapper this is a reference to proxy of the MBean.</param>
        /// <param name="objectName">In case of external mapper, this is its <see cref="ObjectName"/>.</param>
        /// <param name="priority">The priority of a mapper. Must be unique.</param>
        /// <exception cref="NonUniquePriorityException">Another mapper with privided priority is already registered.</exception>
        public void AddTypeMapper(ITypeMapper mapper, ObjectName objectName, int priority)
        {
            TypeMapperInfo newMapperInfo = new TypeMapperInfo(priority, objectName == null ? mapper.GetType().AssemblyQualifiedName : null, objectName);

            if (_mappers.ContainsKey(priority))
            {
                TypeMapperInfo exisingMapperInfo = _mapperInfos.Find(delegate(TypeMapperInfo info)
                {
                    return(info.Priority == priority);
                });
                throw new NonUniquePriorityException(
                          newMapperInfo.ObjectName != null ? newMapperInfo.ObjectName.ToString() : newMapperInfo.TypeName,
                          exisingMapperInfo.ObjectName != null ? exisingMapperInfo.ObjectName.ToString() : exisingMapperInfo.TypeName,
                          priority
                          );
            }
            _mappers.Add(priority, mapper);
            _mapperInfos.Add(newMapperInfo);
        }