コード例 #1
0
 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;
     });
 }
コード例 #2
0
		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);
			});
		}
コード例 #3
0
		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;
			});
		}
コード例 #4
0
        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;
        }
コード例 #5
0
 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;
     });
 }
コード例 #6
0
		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;
			});
		}
コード例 #7
0
        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"));
            }
        }
コード例 #8
0
 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;
     });
 }
コード例 #9
0
 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;
     });            
 }
コード例 #10
0
        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));
        }
コード例 #11
0
 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);
     }
 }
コード例 #12
0
        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;
            });
        }
コード例 #13
0
        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;
            }
        }
コード例 #14
0
ファイル: ReferenceHandler.cs プロジェクト: wezmag/Coevery
        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;
                });
        }
コード例 #16
0
        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;
        }
コード例 #17
0
ファイル: MenuPartHandler.cs プロジェクト: anycall/Orchard
        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)
            );
        }
コード例 #18
0
ファイル: ThreadPartHandler.cs プロジェクト: six006/NGM.Forum
        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));
        }
コード例 #19
0
        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;
            }
        }
コード例 #20
0
        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;
            });
        }
コード例 #21
0
 private static void DefaultSettings(ActivatedContentContext context, MediaSettings settings) {
     settings.Record.RootMediaFolder = "~/Media";
 }
コード例 #22
0
        void ComputedFieldsInitializerHandler(ActivatedContentContext context, ResourceFormPart part)
        {



        }
コード例 #23
0
ファイル: PollHandler.cs プロジェクト: SmartFire/DarkSky.Poll
		private void OnPollActivated(ActivatedContentContext context, PollPart part) {
			part.OptionsField.Loader(() => _pollService.GetOptions(part.Id).ToList());
			part.SubmissionsField.Loader(() => _pollService.GetSubmissions(part.Id).ToList());
		}
コード例 #24
0
 protected virtual void Activated(ActivatedContentContext context, TPart instance)
 {
 }
コード例 #25
0
ファイル: ContentHandler.cs プロジェクト: zaieda/Coevery
 protected virtual void Activated(ActivatedContentContext context)
 {
 }
コード例 #26
0
 private void SetupFields(ActivatedContentContext context, CloudVideoPart part) {
     part._assetManager = _assetManager;
     part._jobManager = _jobManager;
 } 
コード例 #27
0
 public virtual void Activated(ActivatedContentContext context, TPart instance)
 {
 }
コード例 #28
0
        private void SetupLazyFields(ActivatedContentContext context, RelatedContentPart part)
        {
            part.RelatedContentTypesField.Loader(() => relatedContentService.GetRelatedContent(part));

        }
コード例 #29
0
 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;
     });
 }
コード例 #30
0
ファイル: ReferenceHandler.cs プロジェクト: wezmag/Coevery
 protected override void Activated(ActivatedContentContext context) {
     foreach(var part in context.ContentItem.Parts) {
         PropertySetHandlers(context, part);
     }
 }
コード例 #31
0
 public void Activated(ActivatedContentContext context)
 {
 }
コード例 #32
0
 public virtual void Activated(ActivatedContentContext context)
 {
 }
コード例 #33
0
 void IContentHandler.Activated(ActivatedContentContext context)
 {
 }
コード例 #34
0
 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; });
 }