private void SetupLazyFields(ActivatedContentContext context, AjaxWidgetPart part) { part._selectedContentItemField.Loader(() => part.SelectedContentItemId != null ? _contentManager.Get(part.SelectedContentItemId.Value) : null); part._selectedContentItemField.Setter(x => { part.SelectedContentItemId = x != null ? x.Id : default(int?); return x; }); }
private void OnPollWidgetActivated(ActivatedContentContext context, PollWidgetPart part) { part.PollField.Loader(() => { var pollField = ((dynamic) part.Fields.Single(x => x.Name == "Poll")); var poll = ((IEnumerable<ContentItem>) pollField.ContentItems).FirstOrDefault(); return poll != null ? poll.As<PollPart>() : default(PollPart); }); }
private void SetupCustomUserPart(ActivatedContentContext context, CustomUserPart customUserPart) { customUserPart.UserLazyField.Loader(() => customUserPart.Record.UserPartRecord == null ? null : this.contentManager.Get<UserPart>(customUserPart.Record.UserPartRecord.Id)); customUserPart.UserLazyField.Setter(userPart => { if ( userPart != null ) { var exists = this.contentManager.Query<CustomUserPart, CustomUserRecord>() .Where(x => x.UserPartRecord != null && x.UserPartRecord.Id == userPart.Record.Id) .List() .Any(); if ( exists ) { throw new ArgumentException("This user record is already assigned to a custom user"); } customUserPart.Record.UserPartRecord = userPart.Record; } else { customUserPart.Record.UserPartRecord = null; } return userPart; }); }
public virtual ContentItem New(string contentType) { var contentTypeDefinition = _contentDefinitionManager.GetTypeDefinition(contentType); if (contentTypeDefinition == null) { contentTypeDefinition = new ContentTypeDefinitionBuilder().Named(contentType).Build(); } // create a new kernel for the model instance var context = new ActivatingContentContext { ContentType = contentTypeDefinition.Name, Definition = contentTypeDefinition, Builder = new ContentItemBuilder(contentTypeDefinition) }; // invoke handlers to weld aspects onto kernel Handlers.Invoke(handler => handler.Activating(context), _logger); var context2 = new ActivatedContentContext { ContentType = contentType, ContentItem = context.Builder.Build() }; Handlers.Invoke(handler => handler.Activated(context2), _logger); var context3 = new InitializingContentContext { ContentType = context2.ContentType, ContentItem = context2.ContentItem, }; Handlers.Invoke(handler => handler.Initializing(context3), _logger); Handlers.Invoke(handler => handler.Initialized(context3), _logger); // composite result is returned return context3.ContentItem; }
private void SetupFields(ActivatedContentContext context, WidgetExPart part) { part._hostField.Loader(() => part.HostId != null ? _contentManager.Get(part.HostId.Value) : null); part._hostField.Setter(x => { part.HostId = x != null ? x.Id : default(int?); return x; }); }
private void OnPollOptionActivated(ActivatedContentContext context, PollOptionPart part) { part.PollField.Loader(() => _pollService.GetPoll(part.Record.PollId)); part.PollField.Setter(x => { part.Record.PollId = x.Id; return x; }); }
protected override void Activated(ActivatedContentContext context) { if (!context.ContentItem.TypeDefinition.Settings.ContainsKey("Stereotype") || context.ContentItem.TypeDefinition.Settings["Stereotype"] != "Widget") return; if (!context.ContentItem.Is<WidgetExPart>()) { _contentDefinitionManager.AlterTypeDefinition(context.ContentType, type => type.WithPart("WidgetExPart")); } }
private void SetupLazyFields(ActivatedContentContext context, AuditTrailSettingsPart part) { part._eventProviderSettingsField.Loader(() => _auditTrailManager.DeserializeProviderConfiguration(part.Retrieve<string>("Events"))); part._eventProviderSettingsField.Setter(value => { part.Store("Events", _auditTrailManager.SerializeProviderConfiguration(value)); _signals.Trigger("AuditTrail.EventSettings"); return value; }); }
protected static void PropertySetHandlers(ActivatedContentContext context, LocalizationPart localizationPart) { localizationPart.CultureField.Setter(cultureRecord => { localizationPart.Record.CultureId = cultureRecord.Id; return cultureRecord; }); localizationPart.MasterContentItemField.Setter(masterContentItem => { localizationPart.Record.MasterContentItemId = masterContentItem.ContentItem.Id; return masterContentItem; }); }
void ComputedFieldsInitializerHandler(ActivatedContentContext context, LdapDirectoryPart part) { Func<string> failureHandler = () => { Logger.Error("ServiceAccountPassword could not be decrypted. It might be corrupted, try to reset it."); return null; }; part.ServiceAccountPasswordField.Getter(() => PasswordUtils.DecodePassword(part.Record.ServiceAccountPassword, encryptionService, failureHandler)); part.ServiceAccountPasswordField.Setter(v => part.Record.ServiceAccountPassword = PasswordUtils.EncodePassword(v, encryptionService)); }
protected override void Activated(ActivatedContentContext context) { var connector = context.ContentItem.As<ConnectorPart>(); if (connector != null) { ConnectorPropertySetHandlers(context, connector); } var socket = context.ContentItem.As<SocketsPart>(); if (socket != null) { LazyLoadSocketHandlers(socket); } }
private void SetupConversationPart(ActivatedContentContext ctx, ConversationPart part) { // Setup getter part._subjectField.Loader(subject => _contentManager.Get(part.Record.SubjectId)); // Setup setter part._subjectField.Setter(subject => { part.Record.SubjectId = subject == null ? 0 : subject.Id; return subject; }); }
protected static void PropertySetHandlers(ActivatedContentContext context, VersionInfoPart part) { part.AuthorField.Setter( user => { part.Record.Author = user == null ? 0 : user.ContentItem.Id; return user; }); if (part.AuthorField.Value != null) { part.AuthorField.Value = part.AuthorField.Value; } }
protected static void PropertySetHandlers(ActivatedContentContext context, ContentPart part) { // add handlers that will update ID when ContentItem is assigned foreach (ReferenceField field in part.Fields.Where(f => f.FieldDefinition.Name.Equals("ReferenceField"))) { var field1 = field; field1.ContentItemField.Setter(contentItem => { field1.Value = contentItem == null ? new int?() : contentItem.Id; return contentItem; }); // Force call to setter if we had already set a value if (field1.ContentItemField.Value != null) field1.ContentItemField.Value = field1.ContentItemField.Value; } }
protected override void Activated(ActivatedContentContext context) { if (_controller == null) return; var pageContext = context.PageContext(); if (pageContext.Group != FrontendsPageConfigs.Group) return; pageContext.Page.Weld<AssociativyFrontendCommonPart>(part => { part.GraphDescriptor = _graphManager.FindGraph(_controller.GraphContext); part.EngineContext = _controller.EngineContext; }); }
protected static void PropertySetHandlers(ActivatedContentContext context, ThreadPart part) { // add handlers that will update records when part properties are set part.ClosedByField.Setter(user => { part.Record.ClosedById = user == null ? 0 : user.ContentItem.Id; return user; }); // Force call to setter if we had already set a value if (part.ClosedByField.Value != null) part.ClosedByField.Value = part.ClosedByField.Value; }
protected void PropertySetHandlers(ActivatedContentContext context, MenuPart menuPart) { menuPart.MenuField.Setter(menu => { if(menu == null || menu.ContentItem == null) { menuPart.Record.MenuId = 0; } else { menuPart.Record.MenuId = menu.ContentItem.Id; } return menu; }); menuPart.MenuField.Loader(ctx => _contentManager.Get(menuPart.Record.MenuId, menuPart.IsPublished() ? VersionOptions.Published : VersionOptions.Latest) ); }
protected void PropertyHandlers(ActivatedContentContext context, ThreadPart part) { // Add handlers that will update records when part properties are set part.ClosedByField.Setter(user => { part.Record.ClosedById = user == null ? 0 : user.ContentItem.Id; return user; }); // Force call to setter if we had already set a value if (part.ClosedByField.Value != null) part.ClosedByField.Value = part.ClosedByField.Value; // Setup FirstPost & LatestPost fields part.FirstPostField.Loader(() => _postService.GetPositional(part, ThreadPostPositional.First)); part.LatestPostField.Loader(() => _postService.GetPositional(part, ThreadPostPositional.Latest)); }
protected static void PropertySetHandlers(ActivatedContentContext context, ExtendedMenuItemPart part) { part.MenuVersionField.Setter(version => { // Adding consistency checks. Menu version set must be a version of the current menu var menu = part.As<MenuPart>().Menu; if (version == null || version.ContentItem == null || menu == null || menu.ContentItem.Id != version.ContentItem.Id) { part.Record.MenuVersionRecord = null; } else { part.Record.MenuVersionRecord = version.ContentItem.VersionRecord; } return version; }); if (part.MenuVersionField.Value != null) { part.MenuVersionField.Value = part.MenuVersionField.Value; } }
private void SetupGrapevinePart(ActivatedContentContext context, GrapevinePart part) { // Setup the getter of the lazy field part.RecipientField.Loader(grapevinePart => _contentManager.Get<IUser>(part.Record.RecipientId)); part.SenderField.Loader(grapevinePart => _contentManager.Get<IUser>(part.Record.SenderId)); // Setup the setter of the lazy field part.RecipientField.Setter(grapevinePart => { part.Record.RecipientId = grapevinePart != null ? grapevinePart.Id : 0; return grapevinePart; }); part.SenderField.Setter(grapevinePart => { part.Record.SenderId = grapevinePart != null ? grapevinePart.Id : 0; return grapevinePart; }); }
private static void DefaultSettings(ActivatedContentContext context, MediaSettings settings) { settings.Record.RootMediaFolder = "~/Media"; }
void ComputedFieldsInitializerHandler(ActivatedContentContext context, ResourceFormPart part) { }
private void OnPollActivated(ActivatedContentContext context, PollPart part) { part.OptionsField.Loader(() => _pollService.GetOptions(part.Id).ToList()); part.SubmissionsField.Loader(() => _pollService.GetSubmissions(part.Id).ToList()); }
protected virtual void Activated(ActivatedContentContext context, TPart instance) { }
protected virtual void Activated(ActivatedContentContext context) { }
private void SetupFields(ActivatedContentContext context, CloudVideoPart part) { part._assetManager = _assetManager; part._jobManager = _jobManager; }
public virtual void Activated(ActivatedContentContext context, TPart instance) { }
private void SetupLazyFields(ActivatedContentContext context, RelatedContentPart part) { part.RelatedContentTypesField.Loader(() => relatedContentService.GetRelatedContent(part)); }
protected static void ConnectorPropertySetHandlers(ActivatedContentContext context, ConnectorPart part) { // add handlers that will update records when part properties are set part.LeftContentField.Setter(sock => { part.Record.LeftContentItem_id = sock == null // TODO: Throw exception for null socket? ? 0 : sock.ContentItem.Id; part.Record.LeftContentVersionId = sock == null ? 0 : (sock.ContentItem.VersionRecord == null ? (int?)null : sock.ContentItem.VersionRecord.Id); return sock; }); part.RightContentField.Setter(sock => { part.Record.RightContentItem_id = sock == null // TODO: Throw exception for null socket? ? 0 : sock.ContentItem.Id; part.Record.RightContentVersionId = sock == null ? 0 : (sock.ContentItem.VersionRecord == null ? (int?)null : sock.ContentItem.VersionRecord.Id); return sock; }); part.InverseConnectorField.Setter(conn => { part.Record.InverseConnector_id = conn == null // TODO: Throw exception for null socket? ? 0 : conn.ContentItem.Id; part.Record.InverseConnectorVersionId = conn == null ? 0 : (conn.ContentItem.VersionRecord == null ? (int?)null : conn.ContentItem.VersionRecord.Id); return conn; }); }
protected override void Activated(ActivatedContentContext context) { foreach(var part in context.ContentItem.Parts) { PropertySetHandlers(context, part); } }
public void Activated(ActivatedContentContext context) { }
public virtual void Activated(ActivatedContentContext context) { }
void IContentHandler.Activated(ActivatedContentContext context) { }
private void PropertyHandlers(ActivatedContentContext context, MessageTemplatePart part) { part.LayoutField.Loader(x => part.Record.LayoutId != null ? _messageTemplateService.GetTemplate(part.Record.LayoutId.Value) : null); part.LayoutField.Setter(x => { part.Record.LayoutId = x != null ? x.Id : default(int?); return x; }); }