/// <summary> /// Provides an Adam instance for this item and field /// </summary> /// <param name="entity">The entity, often Content or similar</param> /// <param name="fieldName">The field name, like "Gallery" or "Pics"</param> /// <returns>An Adam object for navigating the assets</returns> public AdamNavigator AsAdam(DynamicEntity entity, string fieldName) => AsAdam(AsEntity(entity), fieldName);
public static App GetApp(int zoneId, int appId, PortalSettings ownerPS) { // Get appName from cache var eavAppName = ((BaseCache) DataSource.GetCache(zoneId, null)).ZoneApps[zoneId].Apps[appId]; App sexyApp = null; if(eavAppName != Constants.DefaultAppName) { EnsureAppIsConfigured(zoneId, appId); // Get app-describing entity var appMetaData = DataSource.GetMetaDataSource(zoneId, appId).GetAssignedEntities(AssignmentObjectTypeIDSexyContentApp, appId, AttributeSetStaticNameApps).FirstOrDefault(); var appResources = DataSource.GetMetaDataSource(zoneId, appId).GetAssignedEntities(AssignmentObjectTypeIDSexyContentApp, appId, AttributeSetStaticNameAppResources).FirstOrDefault(); var appSettings = DataSource.GetMetaDataSource(zoneId, appId).GetAssignedEntities(AssignmentObjectTypeIDSexyContentApp, appId, AttributeSetStaticNameAppSettings).FirstOrDefault(); if (appMetaData != null) { dynamic appMetaDataDynamic = new DynamicEntity(appMetaData, new[] { Thread.CurrentThread.CurrentCulture.Name }, null); dynamic appResourcesDynamic = appResources != null ? new DynamicEntity(appResources, new[] {Thread.CurrentThread.CurrentCulture.Name}, null) : null; dynamic appSettingsDynamic = appResources != null ? new DynamicEntity(appSettings, new[] {Thread.CurrentThread.CurrentCulture.Name}, null) : null; sexyApp = new App(appId, zoneId, ownerPS) { Name = appMetaDataDynamic.DisplayName, Folder = appMetaDataDynamic.Folder, Configuration = appMetaDataDynamic, Resources = appResourcesDynamic, Settings = appSettingsDynamic, Hidden = appMetaDataDynamic.Hidden is bool ? appMetaDataDynamic.Hidden : false, AppGuid = eavAppName }; } } // Handle default app else { sexyApp = new App(appId, zoneId, ownerPS) { AppId = appId, Name = "Content", Folder = "Content", Configuration = null, Resources = null, Settings = null, Hidden = true, AppGuid = eavAppName }; } return sexyApp; }
/// <summary> /// Provides an Adam instance for this item and field /// </summary> /// <param name="entity">The entity, often Content or similar</param> /// <param name="fieldName">The field name, like "Gallery" or "Pics"</param> /// <returns>An Adam object for navigating the assets</returns> public AdamNavigator AsAdam(DynamicEntity entity, string fieldName) { return(AsAdam(AsEntity(entity), fieldName)); }
internal Dictionary<string, object> GetDictionaryFromEntity(IEntity entity, string language) { var dynamicEntity = new DynamicEntity(entity, new[] { language }, this); bool propertyNotFound; // Convert DynamicEntity to dictionary var dictionary = ((from d in entity.Attributes select d.Value).ToDictionary(k => k.Name, v => { var value = dynamicEntity.GetEntityValue(v.Name, out propertyNotFound); if (v.Type == "Entity" && value is List<DynamicEntity>) return ((List<DynamicEntity>) value).Select(p => new { p.EntityId, p.EntityTitle }); return value; })); dictionary.Add("EntityId", entity.EntityId); dictionary.Add("Modified", entity.Modified); if (entity is EntityInContentGroup && !dictionary.ContainsKey("Presentation")) { var entityInGroup = (EntityInContentGroup) entity; if(entityInGroup.Presentation != null) dictionary.Add("Presentation", GetDictionaryFromEntity(entityInGroup.Presentation, language)); } if(entity is IHasEditingData) dictionary.Add("_2sxcEditInformation", new { sortOrder = ((IHasEditingData)entity).SortOrder }); else dictionary.Add("_2sxcEditInformation", new { entityId = entity.EntityId, title = entity.Title != null ? entity.Title[language] : "(no title)" }); return dictionary; }
#pragma warning restore 618 #endregion #region Adam /// <summary> /// Provides an Adam instance for this item and field /// </summary> /// <param name="entity">The entity, often Content or similar</param> /// <param name="fieldName">The field name, like "Gallery" or "Pics"</param> /// <returns>An Adam object for navigating the assets</returns> public FolderOfField AsAdam(DynamicEntity entity, string fieldName) => AsAdam(AsEntity(entity), fieldName);