/// <summary> /// Initializes a new instance of the <see cref="PartCompositionInfo"/> class. /// </summary> /// <param name="definition">The definition of the part.</param> /// <exception cref="ArgumentNullException"> /// Thrown if <paramref name="definition"/> is <see langword="null" />. /// </exception> public PartCompositionInfo(GroupPartDefinition definition) { { Lokad.Enforce.Argument(() => definition); } m_Definition = definition; }
/// <summary> /// Registers a new instance of the given type. /// </summary> /// <param name="type">The type to create a new instance from.</param> /// <returns> /// An object that provides a unique ID for the registered object and provides the IDs for the imports, exports, /// conditions and actions on that object. /// </returns> public IPartRegistration RegisterObject(Type type) { var plugin = m_Repository.Parts().FirstOrDefault(p => p.Identity.Equals(type)); if (plugin == null) { throw new UnknownPluginTypeException(); } if (!m_Objects.ContainsKey(type)) { m_Objects.Add(type, new List <GroupPartDefinition>()); } var collection = m_Objects[type]; var exports = plugin.Exports.ToDictionary( e => new ExportRegistrationId(type, collection.Count, e.ContractName), e => e); var imports = plugin.Imports.ToDictionary( i => new ImportRegistrationId(type, collection.Count, i.ContractName), i => i); var actions = plugin.Actions.ToDictionary( a => new ScheduleActionRegistrationId(type, collection.Count, a.ContractName), a => a); var conditions = plugin.Conditions.ToDictionary( c => new ScheduleConditionRegistrationId(type, collection.Count, c.ContractName), c => c); var registration = new GroupPartDefinition( m_IdentityGenerator(type), collection.Count, exports, imports, actions, conditions); collection.Add(registration); return(registration); }