/// <summary> /// Creates the <see cref="CollectionItem"/> from information contained in the supplied <see cref="CollectionItemCreationContext"/>. /// </summary> /// <param name="collectionItemCreationContext">The <see cref="CollectionItemCreationContext"/>.</param> /// <exception cref="ArgumentNullException">The value of '<paramref name="collectionItemCreationContext"/>' cannot be null.</exception> /// <returns>The newly created derivation of the <see cref="CollectionItem"/>.</returns> public CollectionItem CreateCollectionItem(CollectionItemCreationContext collectionItemCreationContext) { if (collectionItemCreationContext == null) { throw new ArgumentNullException(nameof(collectionItemCreationContext)); } if (collectionItemCreationContext.ItemInstance == null) { return(new IgnorableCollectionItem()); } InstanceDescriptor instanceDescriptor; if (collectionItemCreationContext.InstanceDescriptorCreationContext.InstanceRelationStore.TryGetRelated(collectionItemCreationContext.ItemInstance, out instanceDescriptor)) { if (instanceDescriptor == null) { throw new InvalidOperationException(); } } if (instanceDescriptor == null) { instanceDescriptor = this.instanceDescriptorFactory.Value.CreateInstanceDescriptor(collectionItemCreationContext.InstanceDescriptorCreationContext.CreateChildContext(collectionItemCreationContext.ItemInstance)); } return(new InstanceCollectionItemAssociation(instanceDescriptor)); }
/// <summary> /// Creates the <see cref="CollectionItem"/> from information contained in the supplied <see cref="CollectionItemCreationContext"/>. /// </summary> /// <param name="collectionItemCreationContext">The <see cref="CollectionItemCreationContext"/>.</param> /// <exception cref="ArgumentNullException">The value of '<paramref name="collectionItemCreationContext"/>' cannot be null.</exception> /// <returns>The newly created derivation of the <see cref="CollectionItem"/>.</returns> public CollectionItem CreateCollectionItem(CollectionItemCreationContext collectionItemCreationContext) { if (collectionItemCreationContext == null) { throw new ArgumentNullException(nameof(collectionItemCreationContext)); } if (collectionItemCreationContext.ItemInstance == null) { return(new IgnorableCollectionItem()); } var value = Guid.Parse(collectionItemCreationContext.ItemInstance.ToString()); return(new GuidCollectionItem(value)); }
/// <summary> /// Creates the <see cref="CollectionItem"/> from information contained in the supplied <see cref="CollectionItemCreationContext"/>. /// </summary> /// <param name="collectionItemCreationContext">The <see cref="CollectionItemCreationContext"/>.</param> /// <exception cref="ArgumentNullException">The value of '<paramref name="collectionItemCreationContext"/>' cannot be null.</exception> /// <returns>The newly created derivation of the <see cref="CollectionItem"/>.</returns> public CollectionItem CreateCollectionItem(CollectionItemCreationContext collectionItemCreationContext) { if (collectionItemCreationContext == null) { throw new ArgumentNullException(nameof(collectionItemCreationContext)); } if (collectionItemCreationContext.ItemInstance == null) { return(new IgnorableCollectionItem()); } var value = (Byte[])collectionItemCreationContext.ItemInstance; return(new ByteArrayCollectionItem(value)); }
/// <summary> /// Creates the <see cref="CollectionItem"/> from information contained in the supplied <see cref="CollectionItemCreationContext"/>. /// </summary> /// <param name="collectionItemCreationContext">The <see cref="CollectionItemCreationContext"/>.</param> /// <exception cref="ArgumentNullException">The value of '<paramref name="collectionItemCreationContext"/>' cannot be null.</exception> /// <returns>The newly created derivation of the <see cref="CollectionItem"/>.</returns> public CollectionItem CreateCollectionItem(CollectionItemCreationContext collectionItemCreationContext) { if (collectionItemCreationContext == null) { throw new ArgumentNullException(nameof(collectionItemCreationContext)); } if (collectionItemCreationContext.ItemInstance == null) { return(new IgnorableCollectionItem()); } var underlyingEnumType = collectionItemCreationContext.ItemInstance.GetType().GetEnumUnderlyingType(); var collectionItemFactory = this.collectionItemFactoryProvider.Value.GetCollectionItemFactory(underlyingEnumType); return(collectionItemFactory.CreateCollectionItem(new CollectionItemCreationContext(Convert.ChangeType(collectionItemCreationContext.ItemInstance, underlyingEnumType), collectionItemCreationContext.InstanceDescriptorCreationContext))); }