private void RetrieveAdditionalProperties(ref ArchetypeModel archetype, ArchetypePreValue preValue) { if (preValue == null) { return; } foreach (var fieldset in preValue.Fieldsets) { var fieldsetAlias = fieldset.Alias; foreach (var fieldsetInst in archetype.Fieldsets.Where(x => x.Alias == fieldsetAlias)) { foreach (var property in fieldset.Properties) { foreach (var propertyInst in fieldsetInst.Properties.Where(x => x.Alias == property.Alias)) { propertyInst.DataTypeGuid = property.DataTypeGuid.ToString(); Guid dataTypeGuid; if (Guid.TryParse(propertyInst.DataTypeGuid, out dataTypeGuid) == false) { throw new InvalidOperationException($"Could not parse DataTypeGuid as a guid: '{propertyInst.DataTypeGuid}'."); } var dataTypeDefinition = _dataTypeService.GetDataTypeDefinitionById(dataTypeGuid); if (dataTypeDefinition == null) { throw new NullReferenceException($"Could not find DataType with guid: '{dataTypeGuid}'"); } propertyInst.DataTypeId = dataTypeDefinition.Id; propertyInst.PropertyEditorAlias = property.PropertyEditorAlias; } } } } }
/// <summary> /// Retrieves additional metadata that isn't available on the stored model of an ArchetypePreValue /// </summary> /// <param name="archetype">The Archetype to add the additional metadata to</param> /// <param name="preValue">The configuration of the Archetype</param> private void RetrieveAdditionalProperties(ref ArchetypePreValue preValue) { foreach (var fieldset in preValue.Fieldsets) { foreach (var property in fieldset.Properties) { property.PropertyEditorAlias = GetDataTypeByGuid(property.DataTypeGuid).PropertyEditorAlias; } } }
private void RetrieveAdditionalProperties(ref ArchetypePreValue preValue) { if (preValue == null) { return; } foreach (var fieldset in preValue.Fieldsets) { foreach (var property in fieldset.Properties) { var errorMessage = $"Could not find DataType with guid: '{property.DataTypeGuid}'"; var dataType = GetDataTypeDefinitionById(property.DataTypeGuid, errorMessage); property.PropertyEditorAlias = dataType.PropertyEditorAlias; } } }
/// <summary> /// Retrieves additional metadata that isn't available on the stored model of an Archetype /// </summary> /// <param name="archetype">The Archetype to add the additional metadata to</param> /// <param name="preValue">The configuration of the Archetype</param> private void RetrieveAdditionalProperties(ref ArchetypeModel archetype, ArchetypePreValue preValue, PublishedContentType hostContentType = null) { foreach (var fieldset in preValue.Fieldsets) { var fieldsetAlias = fieldset.Alias; foreach (var fieldsetInst in archetype.Fieldsets.Where(x => x.Alias == fieldsetAlias)) { foreach (var property in fieldset.Properties) { var propertyAlias = property.Alias; foreach (var propertyInst in fieldsetInst.Properties.Where(x => x.Alias == propertyAlias)) { propertyInst.DataTypeGuid = property.DataTypeGuid.ToString(); propertyInst.DataTypeId = GetDataTypeByGuid(property.DataTypeGuid).Id; propertyInst.PropertyEditorAlias = property.PropertyEditorAlias; propertyInst.HostContentType = hostContentType; } } } } }
/// <summary> /// Retrieves the additional properties. /// </summary> /// <param name="archetype">The archetype.</param> /// <param name="preValue">The pre value.</param> private void RetrieveAdditionalProperties(ref ArchetypeModel archetype, ArchetypePreValue preValue) { foreach (var fieldset in preValue.Fieldsets) { var fieldsetAlias = fieldset.Alias; foreach (var fieldsetInst in archetype.Fieldsets.Where(x => x.Alias == fieldsetAlias)) { foreach (var property in fieldset.Properties) { var propertyAlias = property.Alias; foreach (var propertyInst in fieldsetInst.Properties.Where(x => x.Alias == propertyAlias)) { propertyInst.DataTypeGuid = property.DataTypeGuid.ToString(); propertyInst.DataTypeId = ExecutionContext.DatabasePersistence.GetNodeId( property.DataTypeGuid, UmbracoNodeObjectTypeIds.DataType); propertyInst.PropertyEditorAlias = property.PropertyEditorAlias; } } } } }
private void RetrieveAdditionalProperties(ref ArchetypePreValue preValue) { if (preValue == null) { return; } foreach (var fieldset in preValue.Fieldsets) { foreach (var property in fieldset.Properties) { var dataType = _dataTypeService.GetDataTypeDefinitionById(property.DataTypeGuid); if (dataType == null) { throw new NullReferenceException($"Could not find DataType with guid: '{property.DataTypeGuid}'"); } property.PropertyEditorAlias = dataType.PropertyEditorAlias; } } }
private void RetrieveAdditionalProperties(ref ArchetypePreValue preValue) { if (preValue == null) { return; } foreach (var fieldset in preValue.Fieldsets) { foreach (var property in fieldset.Properties) { var dataType = ExecutionContext.DatabasePersistence.RetrieveItem <DataType>( new ItemIdentifier(property.DataTypeGuid.ToString(), ProviderIDCollection.dataTypeItemProviderGuid)); if (dataType == null) { continue; } property.PropertyEditorAlias = dataType.PropertyEditorAlias; } } }