当前位置: 首页>>代码示例>>C#>>正文


C# IUpdateModel.TryUpdateModel方法代码示例

本文整理汇总了C#中IUpdateModel.TryUpdateModel方法的典型用法代码示例。如果您正苦于以下问题:C# IUpdateModel.TryUpdateModel方法的具体用法?C# IUpdateModel.TryUpdateModel怎么用?C# IUpdateModel.TryUpdateModel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IUpdateModel的用法示例。


在下文中一共展示了IUpdateModel.TryUpdateModel方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TypePartEditorUpdate

        public override IEnumerable<TemplateViewModel> TypePartEditorUpdate(ContentTypePartDefinitionBuilder builder, IUpdateModel updateModel) {
            if (builder.Name != typeof (TermPart).Name) yield break;

            var settings = new ExtraTermPartSettings();
            updateModel.TryUpdateModel(settings, typeof (ExtraTermPartSettings).Name, null, null);
            builder.WithSetting("ExtraTermPartSettings.OnlyDirectChildren", settings.OnlyDirectChildren.ToString());
        }
开发者ID:Devqon,项目名称:Devq.Sellit,代码行数:7,代码来源:ExtraTermPartSettingsEvents.cs

示例2: PartFieldEditorUpdate

        public override IEnumerable<TemplateViewModel> PartFieldEditorUpdate(ContentPartFieldDefinitionBuilder builder, IUpdateModel updateModel)
        {
            if (!builder.FieldType.Equals(typeof(MoneyField).Name)) yield break;

            var model = new MoneyFieldSettings();

            if (updateModel.TryUpdateModel(model, typeof(MoneyFieldSettings).Name, null, null))
            {
                if (string.IsNullOrEmpty(model.DefaultCurrency))
                {
                    builder.WithSetting("MoneyFieldSettings.DefaultCurrency", Currency.FromCurrentCulture().Iso3LetterCode);
                }
                else
                {
                    Currency parsedCurrency;
                    if (Currency.TryParse(model.DefaultCurrency, out parsedCurrency))
                    {
                        builder.WithSetting("MoneyFieldSettings.DefaultCurrency", model.DefaultCurrency);
                    }
                    else
                    {
                        updateModel.AddModelError("InvalidCurrencyIsoCode", T("MoneyField - Invalid currency iso code was given."));
                    }
                }

                builder.WithSetting("MoneyFieldSettings.IsCurrencyReadOnly", model.IsCurrencyReadOnly.ToString(CultureInfo.InvariantCulture));
                builder.WithSetting("MoneyFieldSettings.Hint", model.Hint);
                builder.WithSetting("MoneyFieldSettings.Required", model.Required.ToString(CultureInfo.InvariantCulture));
            }
            yield return DefinitionTemplate(model);
        }
开发者ID:SmartFire,项目名称:Lombiq-Fields,代码行数:31,代码来源:MoneyFieldEditorEvents.cs

示例3: PartEditorUpdate

 public override IEnumerable<TemplateViewModel> PartEditorUpdate(ContentPartDefinitionBuilder builder, IUpdateModel updateModel)
 {
     var model = new ContentPartSettings();
     updateModel.TryUpdateModel(model, "ContentPartSettings", null, null);
     builder.Attachable(model.Attachable);
     yield return DefinitionTemplate(model);
 }
开发者ID:kerrjon,项目名称:MNFathers,代码行数:7,代码来源:EditorEvents.cs

示例4: TypePartEditorUpdate

        public override IEnumerable<TemplateViewModel> TypePartEditorUpdate(ContentTypePartDefinitionBuilder builder, IUpdateModel updateModel)
        {
            if (builder.Name != "RelatedContentPart") yield break;

            var viewModel = new PropertyFieldsViewModel();
            updateModel.TryUpdateModel(viewModel, "PropertyFieldsViewModel", null, null);
            var settings = new RelatedContentRelationshipSettings();
            foreach (var relationshipFieldsModel in viewModel.Fields)
            {
                settings.DisplayName += String.Format("<field>{0}</field>", relationshipFieldsModel.DisplayName);
                settings.RelatedContentFields += String.Format("<field>{0}</field>", relationshipFieldsModel.RelatedContentFields);
                settings.RelatedcontentType += String.Format("<field>{0}</field>", relationshipFieldsModel.RelatedcontentType);
            }

            builder.WithSetting("RelatedContentRelationshipSettings.RelatedcontentType",
                settings.RelatedcontentType);
            builder.WithSetting("RelatedContentRelationshipSettings.RelatedContentFields",
                settings.RelatedContentFields);
            builder.WithSetting("RelatedContentRelationshipSettings.DisplayName",
                settings.DisplayName);

            var model = GetModel(settings);

            yield return DefinitionTemplate(model);
        }
开发者ID:kubo08,项目名称:Orchard,代码行数:25,代码来源:RelatedContentRelationshipSettingsEvents.cs

示例5: PartFieldEditorUpdate

        public override IEnumerable<TemplateViewModel> PartFieldEditorUpdate(ContentPartFieldDefinitionBuilder builder, IUpdateModel updateModel) {
            if (builder.FieldType != "ReferenceField") {
                yield break;
            }
            var model = new ReferenceFieldSettings();
            if (updateModel.TryUpdateModel(model, "ReferenceFieldSettings", null, null)) {
                UpdateSettings(model, builder, "ReferenceFieldSettings");

                if (model.QueryId <= 0) {
                    model.QueryId = CreateQuery(model.ContentTypeName.ToString(CultureInfo.InvariantCulture));
                }

                if (model.RelationshipId <= 0) {
                    var httpContext = _httpContextAccessor.Current();
                    var routeValues = httpContext.Request.RequestContext.RouteData.Values;
                    var entityName = routeValues["id"].ToString();
                    model.RelationshipId = _relationshipService.CreateOneToManyRelationship(builder.Name, model.RelationshipName, model.ContentTypeName, entityName);
                }

                if (model.QueryId <= 0 || model.RelationshipId <= 0) {
                    updateModel.AddModelError("QueryOrRelation", T("Invalid Query or Relationship Id"));
                    yield break;
                }

                UpdateSettings(model, builder, "ReferenceFieldSettings");
                builder.WithSetting("ReferenceFieldSettings.DisplayAsLink", model.DisplayAsLink.ToString(CultureInfo.InvariantCulture));
                builder.WithSetting("ReferenceFieldSettings.ContentTypeName", model.ContentTypeName.ToString(CultureInfo.InvariantCulture));
                builder.WithSetting("ReferenceFieldSettings.RelationshipName", model.RelationshipName.ToString(CultureInfo.InvariantCulture));
                builder.WithSetting("ReferenceFieldSettings.RelationshipId", model.RelationshipId.ToString(CultureInfo.InvariantCulture));
                builder.WithSetting("ReferenceFieldSettings.QueryId", model.QueryId.ToString(CultureInfo.InvariantCulture));
            }
            yield return DefinitionTemplate(model);
        }
开发者ID:jgtaveras,项目名称:Coevery,代码行数:33,代码来源:ReferenceFieldEditorEvents.cs

示例6: TypeEditorUpdate

        public override IEnumerable<TemplateViewModel> TypeEditorUpdate(ContentTypeDefinitionBuilder builder, IUpdateModel updateModel) {
            var model = new SecurableContentItemsSettingsViewModel();
            updateModel.TryUpdateModel(model, "SecurableContentItemsSettingsViewModel", null, null);

            builder.WithSetting("ContentPermissionsTypeSettings.SecurableContentItems", model.SecurableContentItems.ToString());

            yield return DefinitionTemplate(model);
        }
开发者ID:SunRobin2015,项目名称:RobinWithOrchard,代码行数:8,代码来源:SecurableContentItemsEditorEvents.cs

示例7: TypeEditorUpdate

        public override IEnumerable<TemplateViewModel> TypeEditorUpdate(ContentTypeDefinitionBuilder builder, IUpdateModel updateModel) {
            var model = new ContentTypeSettings();
            updateModel.TryUpdateModel(model, "ContentTypeSettings", null, null);
            builder.Creatable(model.Creatable);
            builder.Draftable(model.Draftable);

            yield return DefinitionTemplate(model);
        }
开发者ID:sjbisch,项目名称:Orchard,代码行数:8,代码来源:EditorEvents.cs

示例8: TypeEditorUpdate

        public override IEnumerable<TemplateViewModel> TypeEditorUpdate(ContentTypeDefinitionBuilder builder, IUpdateModel updateModel)
        {
            var model = new AssociativyTaxonomiesAdapterTypeSettings();
            updateModel.TryUpdateModel(model, "AssociativyTaxonomiesAdapterTypeSettings", null, null);
            builder.WithSetting("AssociativyTaxonomiesAdapterTypeSettings.GraphNamesSerialized", model.GraphNamesSerialized);

            yield return DefinitionTemplate(model);
        }
开发者ID:Lombiq,项目名称:Associativy-Taxonomies-Adapter,代码行数:8,代码来源:TypeSettings.cs

示例9: PartFieldEditorUpdate

        public override IEnumerable<TemplateViewModel> PartFieldEditorUpdate(ContentPartFieldDefinitionBuilder builder, IUpdateModel updateModel) {
            var model = new DateTimeFieldSettings();
            if(updateModel.TryUpdateModel(model, "DateTimeFieldSettings", null, null)) {
                builder.WithSetting("DateTimeFieldSettings.Display", model.Display.ToString());
            }

            yield return DefinitionTemplate(model);
        }
开发者ID:dminik,项目名称:voda_code,代码行数:8,代码来源:DateTimeFieldEditorEvents.cs

示例10: TypeEditorUpdate

        public override IEnumerable<TemplateViewModel> TypeEditorUpdate(ContentTypeDefinitionBuilder builder, IUpdateModel updateModel) {
            var model = new ExperimentalSettings();
            updateModel.TryUpdateModel(model, "ExperimentalSettings", null, null);
            builder
                .WithSetting("ExperimentalSettings.ShowDebugLinks", model.ShowDebugLinks ? true.ToString() : null);

            yield return DefinitionTemplate(model);
        }
开发者ID:sjbisch,项目名称:Orchard,代码行数:8,代码来源:ExperimentalSettings.cs

示例11: PartFieldEditorUpdate

        public override IEnumerable<TemplateViewModel> PartFieldEditorUpdate(ContentPartFieldDefinitionBuilder builder, IUpdateModel updateModel) {
            var model = new FieldIndexing();
            updateModel.TryUpdateModel(model, "FieldIndexing", null, null);
            builder.WithSetting("FieldIndexing.Included", model.Included ? true.ToString() : null);

            CreateIndexingTasks();

            yield return DefinitionTemplate(model);
        }
开发者ID:kanujhun,项目名称:orchard,代码行数:9,代码来源:EditorEvents.cs

示例12: TypeEditorUpdate

        public override IEnumerable<TemplateViewModel> TypeEditorUpdate(ContentTypeDefinitionBuilder builder, IUpdateModel updateModel) {
            var model = new TypeIndexing();
            updateModel.TryUpdateModel(model, "TypeIndexing", null, null);
            builder.WithSetting("TypeIndexing.Indexes", model.Indexes);

            CreateIndexingTasks();
            
            yield return DefinitionTemplate(model);
        }
开发者ID:kanujhun,项目名称:orchard,代码行数:9,代码来源:EditorEvents.cs

示例13: PartFieldEditorUpdate

        public override IEnumerable<TemplateViewModel> PartFieldEditorUpdate(ContentPartFieldDefinitionBuilder builder, IUpdateModel updateModel)
        {
            var model = new HtmlFieldSettings();
            if (updateModel.TryUpdateModel(model, "HtmlFieldSettings", null, null)) {
                builder.WithSetting("HtmlFieldSettings.FlavorDefault", model.FlavorDefault);
            }

            yield return DefinitionTemplate(model);
        }
开发者ID:ryankeeter,项目名称:Orchard-Theme,代码行数:9,代码来源:HtmlFieldEditorEvents.cs

示例14: TypePartEditorUpdate

        public override IEnumerable<TemplateViewModel> TypePartEditorUpdate(ContentTypePartDefinitionBuilder builder, IUpdateModel updateModel) {
            if (builder.Name != typeof(AuthorablePart).Name) yield break;

            var model = new AuthorablePartSettings();
            updateModel.TryUpdateModel(model, typeof (AuthorablePartSettings).Name, null, null);
            builder.WithSetting(string.Format("{0}.{1}", typeof(AuthorablePartSettings).Name, model.AutomaticallyAssignEditorToAuthors.GetType().Name), model.AutomaticallyAssignEditorToAuthors.ToString());

            yield return DefinitionTemplate(model);
        }
开发者ID:Devqon,项目名称:Devq.ExtendedBlog,代码行数:9,代码来源:AuthorablePartSettingsHooks.cs

示例15: TypeEditorUpdate

        public override IEnumerable<TemplateViewModel> TypeEditorUpdate(ContentTypeDefinitionBuilder builder, IUpdateModel updateModel)
        {
            var model = new DynamicTypeSettingsViewModel();
            updateModel.TryUpdateModel(model, "DynamicTypeSettingsViewModel", null, null);

            builder.WithSetting("DynamicTypeSettings.IsDeployed", model.IsDeployed.ToString());

            yield return DefinitionTemplate(model);
        }
开发者ID:jgtaveras,项目名称:Coevery,代码行数:9,代码来源:DynamicTypeEditorEvents.cs


注:本文中的IUpdateModel.TryUpdateModel方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。