/// <summary> /// Initializes a new instance of the <see cref="GroupDefinition"/> class. /// </summary> /// <param name="groupName">The unique name of the group.</param> /// <exception cref="ArgumentNullException"> /// Thrown if <paramref name="groupName"/> is <see langword="null" />. /// </exception> /// <exception cref="ArgumentException"> /// Thrown if <paramref name="groupName"/> is an empty string. /// </exception> public GroupDefinition(string groupName) { { Lokad.Enforce.Argument(() => groupName); Lokad.Enforce.Argument(() => groupName, Lokad.Rules.StringIs.NotEmpty); } m_Id = new GroupRegistrationId(groupName); }
public void Create() { var groupId = new GroupRegistrationId("a"); var contractName = "b"; var imports = new List <ExportRegistrationId> { new ExportRegistrationId(typeof(string), 0, "a") }; var obj = GroupExportDefinition.CreateDefinition(contractName, groupId, imports); Assert.AreEqual(groupId, obj.ContainingGroup); Assert.AreEqual(contractName, obj.ContractName); Assert.That(obj.ProvidedExports, Is.EquivalentTo(imports)); }
/// <summary> /// Returns the group that was registered with the given ID. /// </summary> /// <param name="groupRegistrationId">The registration ID.</param> /// <returns>The requested type.</returns> public GroupDefinition Group(GroupRegistrationId groupRegistrationId) { lock (m_Lock) { { Lokad.Enforce.Argument(() => groupRegistrationId); Lokad.Enforce.With <UnknownGroupDefinitionException>( m_Groups.ContainsKey(groupRegistrationId), Resources.Exceptions_Messages_UnknownGroupDefinition); } return(m_Groups[groupRegistrationId].Item1); } }
/// <summary> /// Creates a new instance of the <see cref="ScheduleDefinition"/> class. /// </summary> /// <param name="containingGroup">The ID of the group that has registered the schedule.</param> /// <param name="schedule">The schedule.</param> /// <param name="actions">The collection that maps a schedule element to an action.</param> /// <param name="conditions">The collection that maps a schedule element to a condition.</param> /// <returns>The newly created definition.</returns> /// <exception cref="ArgumentNullException"> /// Thrown if <paramref name="containingGroup"/> is <see langword="null" />. /// </exception> /// <exception cref="ArgumentNullException"> /// Thrown if <paramref name="schedule"/> is <see langword="null" />. /// </exception> /// <exception cref="ArgumentNullException"> /// Thrown if <paramref name="actions"/> is <see langword="null" />. /// </exception> /// <exception cref="ArgumentNullException"> /// Thrown if <paramref name="conditions"/> is <see langword="null" />. /// </exception> public static ScheduleDefinition CreateDefinition( GroupRegistrationId containingGroup, ISchedule schedule, IDictionary <ScheduleElementId, ScheduleActionRegistrationId> actions, IDictionary <ScheduleElementId, ScheduleConditionRegistrationId> conditions) { { Lokad.Enforce.Argument(() => containingGroup); Lokad.Enforce.Argument(() => schedule); Lokad.Enforce.Argument(() => actions); Lokad.Enforce.Argument(() => conditions); } return(new ScheduleDefinition(containingGroup, schedule, actions, conditions)); }
/// <summary> /// Initializes a new instance of the <see cref="GroupExportDefinition"/> class. /// </summary> /// <param name="contractName">The contract name for the import.</param> /// <param name="containingGroup">The ID of the group that has registered the import.</param> /// <param name="providedExports">The object exports that are provided with the current export.</param> private GroupExportDefinition( string contractName, GroupRegistrationId containingGroup, IEnumerable <ExportRegistrationId> providedExports) { { Debug.Assert(containingGroup != null, "The ID of the group registering the export should not be null."); Debug.Assert(!string.IsNullOrEmpty(contractName), "The contract name for the export should not be empty."); Debug.Assert(providedExports != null, "The collection of object exports should not be null."); } m_ContractName = contractName; m_Id = containingGroup; m_ProvidedExports = providedExports; }
public void Create() { var groupId = new GroupRegistrationId("a"); var contractName = "b"; var vertex = new InsertVertex(0, 1); var imports = new List <ImportRegistrationId> { new ImportRegistrationId(typeof(string), 0, "a") }; var obj = GroupImportDefinition.CreateDefinition(contractName, groupId, vertex, imports); Assert.AreEqual(groupId, obj.ContainingGroup); Assert.AreEqual(contractName, obj.ContractName); Assert.AreEqual(vertex, obj.ScheduleInsertPosition); Assert.That(obj.ImportsToMatch, Is.EquivalentTo(imports)); }
/// <summary> /// Creates a new instance of the <see cref="GroupExportDefinition"/> class. /// </summary> /// <param name="contractName">The contract name for the import.</param> /// <param name="containingGroup">The ID of the group that has registered the import.</param> /// <param name="providedExports">The object exports that are provided with the current export.</param> /// <returns>The serialized export definition for the group.</returns> /// <exception cref="ArgumentNullException"> /// Thrown if <paramref name="contractName"/> is <see langword="null" />. /// </exception> /// <exception cref="ArgumentNullException"> /// Thrown if <paramref name="contractName"/> is an empty string. /// </exception> /// <exception cref="ArgumentNullException"> /// Thrown if <paramref name="containingGroup"/> is <see langword="null" />. /// </exception> public static GroupExportDefinition CreateDefinition( string contractName, GroupRegistrationId containingGroup, IEnumerable <ExportRegistrationId> providedExports) { { Lokad.Enforce.Argument(() => contractName); Lokad.Enforce.Argument(() => contractName, Lokad.Rules.StringIs.NotEmpty); Lokad.Enforce.Argument(() => containingGroup); } return(new GroupExportDefinition( contractName, containingGroup, providedExports ?? Enumerable.Empty <ExportRegistrationId>())); }
/// <summary> /// Initializes a new instance of the <see cref="GroupImportDefinition"/> class. /// </summary> /// <param name="contractName">The contract name for the import.</param> /// <param name="containingGroup">The ID of the group that has registered the import.</param> /// <param name="insertPoint">The schedule import point at which a sub-schedule can be provided.</param> /// <param name="importsToMatch">The object imports that need to be provided for the current imports.</param> private GroupImportDefinition( string contractName, GroupRegistrationId containingGroup, InsertVertex insertPoint, IEnumerable <ImportRegistrationId> importsToMatch) { { Debug.Assert(!string.IsNullOrEmpty(contractName), "The contract name for the import should not be empty."); Debug.Assert(importsToMatch != null, "The collection of object imports should not be null."); Debug.Assert(containingGroup != null, "The ID of the group registering the import should not be null."); } m_ContainingGroup = containingGroup; m_ContractName = contractName; m_InsertPoint = insertPoint; m_ImportsToMatch = importsToMatch; }
/// <summary> /// Initializes a new instance of the <see cref="ScheduleDefinition"/> class. /// </summary> /// <param name="containingGroup">The ID of the group that has registered the schedule.</param> /// <param name="schedule">The schedule.</param> /// <param name="actions">The collection that maps a schedule element to an action.</param> /// <param name="conditions">The collection that maps a schedule element to a condition.</param> private ScheduleDefinition( GroupRegistrationId containingGroup, ISchedule schedule, IDictionary <ScheduleElementId, ScheduleActionRegistrationId> actions, IDictionary <ScheduleElementId, ScheduleConditionRegistrationId> conditions) { { Debug.Assert(containingGroup != null, "The containing group ID should not be a null reference."); Debug.Assert(schedule != null, "The schedule should not be a null reference."); Debug.Assert(actions != null, "The collection of actions should not be a null reference."); Debug.Assert(conditions != null, "The collection of conditions should not be a null reference."); } m_GroupId = containingGroup; m_Schedule = schedule; m_Actions = actions; m_Conditions = conditions; }
/// <summary> /// Creates a new instance of the <see cref="GroupImportDefinition"/> class. /// </summary> /// <param name="contractName">The contract name for the import.</param> /// <param name="containingGroup">The ID of the group that has registered the import.</param> /// <param name="insertPoint">The schedule insert point at which a sub-schedule can be provided.</param> /// <param name="importsToMatch">The object imports that have to be provided for the current import.</param> /// <returns>The serialized import definition for the group.</returns> /// <exception cref="ArgumentNullException"> /// Thrown if <paramref name="contractName"/> is <see langword="null" />. /// </exception> /// <exception cref="ArgumentNullException"> /// Thrown if <paramref name="contractName"/> is an empty string. /// </exception> /// <exception cref="ArgumentNullException"> /// Thrown if <paramref name="containingGroup"/> is <see langword="null" />. /// </exception> public static GroupImportDefinition CreateDefinition( string contractName, GroupRegistrationId containingGroup, InsertVertex insertPoint, IEnumerable <ImportRegistrationId> importsToMatch) { { Lokad.Enforce.Argument(() => contractName); Lokad.Enforce.Argument(() => contractName, Lokad.Rules.StringIs.NotEmpty); Lokad.Enforce.Argument(() => containingGroup); } return(new GroupImportDefinition( contractName, containingGroup, insertPoint, importsToMatch ?? Enumerable.Empty <ImportRegistrationId>())); }
public void Create() { var groupId = new GroupRegistrationId("a"); var schedule = BuildSchedule(); var actions = new Dictionary <ScheduleElementId, ScheduleActionRegistrationId> { { new ScheduleElementId(), new ScheduleActionRegistrationId(typeof(string), 0, "a") } }; var conditions = new Dictionary <ScheduleElementId, ScheduleConditionRegistrationId> { { new ScheduleElementId(), new ScheduleConditionRegistrationId(typeof(string), 0, "a") } }; var obj = ScheduleDefinition.CreateDefinition( groupId, schedule, actions, conditions); Assert.AreEqual(groupId, obj.ContainingGroup); Assert.AreEqual(schedule, obj.Schedule); Assert.That(obj.Actions, Is.EquivalentTo(actions)); Assert.That(obj.Conditions, Is.EquivalentTo(conditions)); }
/// <summary> /// Returns the group that was registered with the given ID. /// </summary> /// <param name="groupRegistrationId">The registration ID.</param> /// <returns>The requested type.</returns> public GroupDefinition Group(GroupRegistrationId groupRegistrationId) { lock (m_Lock) { { Lokad.Enforce.Argument(() => groupRegistrationId); Lokad.Enforce.With<UnknownGroupDefinitionException>( m_Groups.ContainsKey(groupRegistrationId), Resources.Exceptions_Messages_UnknownGroupDefinition); } return m_Groups[groupRegistrationId].Item1; } }
/// <summary> /// Returns the group that was registered with the given ID. /// </summary> /// <param name="groupRegistrationId">The registration ID.</param> /// <returns>The requested type.</returns> public GroupDefinition Group(GroupRegistrationId groupRegistrationId) { return m_Repository.Group(groupRegistrationId); }
/// <summary> /// Returns the group that was registered with the given ID. /// </summary> /// <param name="groupRegistrationId">The registration ID.</param> /// <returns>The requested type.</returns> public GroupDefinition Group(GroupRegistrationId groupRegistrationId) { return(m_Repository.Group(groupRegistrationId)); }