Exemplo n.º 1
0
        /// <summary>
        /// Gets element details.
        /// </summary>
        /// <param name="tenantId">Identifies the tenant that element belongs to.</param>
        /// <param name="elementTypeId">The type of the element.</param>
        /// <param name="elementId">Identifies the element to return.</param>
        /// <param name="unitOfWork">Unit of work.</param>
        /// <returns>Element settings (or null if element not found).</returns>
        public IElementSettings Read(long tenantId, Guid elementTypeId, long elementId, IUnitOfWork unitOfWork = null)
        {
            // Construct instance of element settings
            IBasicElementService customElementService = _elementFactory.GetElementService(elementTypeId);
            IElementSettings     settings             = customElementService.New(tenantId);

            // Populate element ID
            settings.ElementId = elementId;

            // Populate for advanced elements
            if (customElementService is IAdvancedElementService)
            {
                // Populate element with common settings
                _elementRepository.Read(settings, unitOfWork);

                // Populate with custom settings
                ((IAdvancedElementService)customElementService).Read(settings, unitOfWork);
            }

            // Return fully populated element
            return(settings);
        }