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


C# Definitions.FieldDefinition类代码示例

本文整理汇总了C#中SPMeta2.Definitions.FieldDefinition的典型用法代码示例。如果您正苦于以下问题:C# FieldDefinition类的具体用法?C# FieldDefinition怎么用?C# FieldDefinition使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: Main

        static void Main(string[] args)
        {
            // Step 1, define site field
            var customerField = new FieldDefinition
            {
                Id = new Guid("26470917-fbbf-413b-9eb3-537f74797e4e"),
                Title = "Customer Name",
                InternalName = "cstm_CustomerName",
                Description = "Name of the target customer.",
                Group = "Hello SPMeta2",
                FieldType = BuiltInFieldTypes.Text
            };

            // Step 2, define site model and artifact relationships - add field to the site 
            var siteModel = SPMeta2Model
                             .NewSiteModel(site =>
                             {
                                 site.AddField(customerField);
                             });

            // Step 3, deploy model via CSOM
            using (var clientContext = new ClientContext(SampleConsts.CSOM_SiteUrl))
            {
                var csomProvisionService = new CSOMProvisionService();
                csomProvisionService.DeployModel(SPMeta2.CSOM.ModelHosts.SiteModelHost.FromClientContext(clientContext), siteModel);
            }

            // Step 4, deploy model via SSOM
            using (var site = new SPSite(SampleConsts.SSOM_SiteUrl))
            {
                var csomProvisionService = new SSOMProvisionService();
                csomProvisionService.DeployModel(SPMeta2.SSOM.ModelHosts.SiteModelHost.FromSite(site), siteModel);
            }
        }
开发者ID:Rtoribiog,项目名称:spmeta2.contoso,代码行数:34,代码来源:Program.cs

示例2: CustomFieldTypeValidation

        protected override void CustomFieldTypeValidation(AssertPair<FieldDefinition, Field> assert, Field spObject, FieldDefinition definition)
        {
            var typedObject = spObject.Context.CastTo<FieldLookup>(spObject);
            var typedDefinition = definition.WithAssertAndCast<LookupFieldDefinition>("model", value => value.RequireNotNull());

            // https://github.com/SubPointSolutions/spmeta2/issues/310
            // AllowMultipleValues - TRUE - LookupMulti
            // AllowMultipleValues - FALSE - Lookup
            assert.ShouldBeEqual((p, s, d) =>
            {
                var srcProp = s.GetExpressionValue(m => m.FieldType);
                var dstProp = d.GetExpressionValue(m => d.TypeAsString);

                var isValid = typedDefinition.AllowMultipleValues
                    ? typedObject.TypeAsString == "LookupMulti"
                    : typedObject.TypeAsString == "Lookup";

                return new PropertyValidationResult
                {
                    Tag = p.Tag,
                    Src = srcProp,
                    Dst = dstProp,
                    IsValid = isValid
                };
            });
        }
开发者ID:karayakar,项目名称:spmeta2,代码行数:26,代码来源:LookupFieldDefinitionValidator.cs

示例3: ProcessFieldProperties

        protected override void ProcessFieldProperties(SPField field, FieldDefinition fieldModel)
        {
            // let base setting be setup
            base.ProcessFieldProperties(field, fieldModel);

            var typedField = field as SPFieldUser;
            var typedFieldModel = fieldModel.WithAssertAndCast<UserFieldDefinition>("model", value => value.RequireNotNull());

            typedField.AllowDisplay = typedFieldModel.AllowDisplay;
            typedField.Presence = typedFieldModel.Presence;
            typedField.AllowMultipleValues = typedFieldModel.AllowMultipleValues;

            if (!string.IsNullOrEmpty(typedFieldModel.SelectionMode))
                typedField.SelectionMode = (SPFieldUserSelectionMode)Enum.Parse(typeof(SPFieldUserSelectionMode), typedFieldModel.SelectionMode);

            if (typedFieldModel.SelectionGroup.HasValue)
            {
                typedField.SelectionGroup = typedFieldModel.SelectionGroup.Value;
            }
            else if (!string.IsNullOrEmpty(typedFieldModel.SelectionGroupName))
            {
                var group = GetCurrentWeb().SiteGroups.OfType<SPGroup>().FirstOrDefault(g => g.Name.ToUpper() == typedFieldModel.SelectionGroupName.ToUpper());
                typedField.SelectionGroup = group.ID;
            }
        }
开发者ID:Uolifry,项目名称:spmeta2,代码行数:25,代码来源:UserFieldModelHandler.cs

示例4: PostProcessDefinitionTemplate

        protected override void PostProcessDefinitionTemplate(FieldDefinition def)
        {
            base.PostProcessDefinitionTemplate(def);

            def.Indexed = true;
            def.DefaultValue = defaultValue;
        }
开发者ID:karayakar,项目名称:spmeta2,代码行数:7,代码来源:MultiChoiceFieldDefinitionGenerator.cs

示例5: Deploy_NewSiteField

        public void Deploy_NewSiteField()
        {
            // Step 1, define site field
            var customerNameField = new FieldDefinition
            {
                Id = new Guid("26470917-fbbf-413b-9eb3-537f74797e4e"),
                Title = "Customer Name",
                InternalName = "cstm_CustomerName",
                Description = "Name of the target customer.",
                Group = SampleConsts.DefaultMetadataGroup,
                FieldType = BuiltInFieldTypes.Text
            };

            var customerDescriptionField = new FieldDefinition
             {
                 Id = new Guid("26470917-fbbf-413b-9eb3-537f74797e4e"),
                 Title = "Customer Description",
                 InternalName = "cstm_CustomerDescription",
                 Description = "Description of the target customer.",
                 Group = SampleConsts.DefaultMetadataGroup,
                 FieldType = BuiltInFieldTypes.Note
             };

            // Step 2, define site model and artifact relationships - add field to the site 
            var model = SPMeta2Model
                             .NewSiteModel(site =>
                             {
                                 site
                                     .AddField(customerNameField)
                                     .AddField(customerDescriptionField);
                             });

            // Step 3, deploy model
            DeploySiteModel(model);
        }
开发者ID:Rtoribiog,项目名称:spmeta2.contoso,代码行数:35,代码来源:HelloWorldProvision.cs

示例6: ProcessFieldProperties

        protected override void ProcessFieldProperties(Field field, FieldDefinition fieldModel)
        {
            var typedFieldModel = fieldModel.WithAssertAndCast<NoteFieldDefinition>("model", value => value.RequireNotNull());

            // the XML update goes first
            // then the rest of the normal props with base.ProcessFieldProperties(field, fieldModel);
            // then specific to NoteField props
            // as crazy as it sounds

            // RichTextMode  update
            // https://github.com/SubPointSolutions/spmeta2/issues/673
            if (!string.IsNullOrEmpty(typedFieldModel.RichTextMode))
            {
                var fieldXml = XDocument.Parse(field.SchemaXml);
                fieldXml.Root.SetAttribute("RichTextMode", typedFieldModel.RichTextMode);

                field.SchemaXml = fieldXml.ToString();
            }

            // let base setting be setup
            base.ProcessFieldProperties(field, fieldModel);

            var typedField = field.Context.CastTo<FieldMultiLineText>(field);

            typedField.NumberOfLines = typedFieldModel.NumberOfLines;
            typedField.AppendOnly = typedFieldModel.AppendOnly;
            typedField.RichText = typedFieldModel.RichText;
        }
开发者ID:karayakar,项目名称:spmeta2,代码行数:28,代码来源:NoteFieldModelHandler.cs

示例7: AddContentTypeFieldLink

 public static ModelNode AddContentTypeFieldLink(this ModelNode model, FieldDefinition definition, Action<ModelNode> action)
 {
     return AddContentTypeFieldLink(model, new ContentTypeFieldLinkDefinition
     {
         FieldId = definition.Id
     }, action);
 }
开发者ID:nklychnikov,项目名称:spmeta2,代码行数:7,代码来源:FieldLinkDefinitionSyntax.cs

示例8: PostProcessFieldDefinitionInstance

        protected override void PostProcessFieldDefinitionInstance(FieldDefinition def, FieldReverseHost typedReverseHost, ReverseOptions options)
        {
            var context = typedReverseHost.HostClientContext;

            var typedField = context.CastTo<FieldLookup>(typedReverseHost.Field);
            var typedDef = def.WithAssertAndCast<LookupFieldDefinition>("modelHost", m => m.RequireNotNull());

            typedDef.AllowMultipleValues = typedField.AllowMultipleValues;

            if (typedDef.AllowMultipleValues)
                typedDef.FieldType = BuiltInFieldTypes.LookupMulti;
            else
                typedDef.FieldType = BuiltInFieldTypes.Lookup;

            //typedDef.AppendOnly = typedField.AppendOnly;
            //typedDef.RichText = typedField.RichText;

            //typedDef.NumberOfLines = typedField.NumberOfLines;

            //var xml = XDocument.Parse(typedField.SchemaXml);
            //var fieldXml = xml.Root;

            //var unlimValue = ConvertUtils.ToBool(fieldXml.GetAttributeValue("UnlimitedLengthInDocumentLibrary"));
            //typedDef.UnlimitedLengthInDocumentLibrary = unlimValue.HasValue ? unlimValue.Value : false;

            //var richTextMode = ConvertUtils.ToString(fieldXml.GetAttributeValue("RichTextMode"));
            //typedDef.RichTextMode = richTextMode;
        }
开发者ID:SubPointSolutions,项目名称:spmeta2-reverse,代码行数:28,代码来源:LookupFieldReverseHandler.cs

示例9: ProcessFieldProperties

        protected override void ProcessFieldProperties(Field field, FieldDefinition fieldModel)
        {
            var site = HostSite;
            var context = site.Context;

            // let base setting be setup
            base.ProcessFieldProperties(field, fieldModel);

            var typedField = field.Context.CastTo<FieldLookup>(field);
            var typedFieldModel = fieldModel.WithAssertAndCast<DependentLookupFieldDefinition>("model", value => value.RequireNotNull());

            var primaryLookupField = GetPrimaryField(typedFieldModel);

            typedField.Context.Load(primaryLookupField);
            typedField.Context.ExecuteQueryWithTrace();

            if (string.IsNullOrEmpty(typedField.PrimaryFieldId))
            {
                typedField.PrimaryFieldId = primaryLookupField.Id.ToString();
            }
            typedField.ReadOnlyField = true;

            if (!string.IsNullOrEmpty(typedFieldModel.RelationshipDeleteBehavior))
            {
                var value = (RelationshipDeleteBehaviorType)Enum.Parse(typeof(RelationshipDeleteBehaviorType), typedFieldModel.RelationshipDeleteBehavior);
                typedField.RelationshipDeleteBehavior = value;
            }

            // unsupported in CSOM yet
            //dependentLookupField.UnlimitedLengthInDocumentLibrary = primaryLookupField.UnlimitedLengthInDocumentLibrary;
            typedField.Direction = primaryLookupField.Direction;
        }
开发者ID:maratbakirov,项目名称:spmeta2,代码行数:32,代码来源:DependentLookupFieldModelHandler.cs

示例10: ProcessFieldProperties

        protected override void ProcessFieldProperties(SPField field, FieldDefinition fieldModel)
        {
            // let base setting be setup
            base.ProcessFieldProperties(field, fieldModel);

            if (!string.IsNullOrEmpty(fieldModel.ValidationMessage))
                field.ValidationMessage = fieldModel.ValidationMessage;

            if (!string.IsNullOrEmpty(fieldModel.ValidationFormula))
                field.ValidationFormula = fieldModel.ValidationFormula;


            var typedFieldModel = fieldModel.WithAssertAndCast<DateTimeFieldDefinition>("model", value => value.RequireNotNull());
            var typedField = field as SPFieldDateTime;

            if (!string.IsNullOrEmpty(typedFieldModel.CalendarType))
                typedField.CalendarType = (SPCalendarType)Enum.Parse(typeof(SPCalendarType), typedFieldModel.CalendarType);

            if (!string.IsNullOrEmpty(typedFieldModel.DisplayFormat))
                typedField.DisplayFormat = (SPDateTimeFieldFormatType)Enum.Parse(typeof(SPDateTimeFieldFormatType), typedFieldModel.DisplayFormat);

#if !NET35
            if (!string.IsNullOrEmpty(typedFieldModel.FriendlyDisplayFormat))
                typedField.FriendlyDisplayFormat = (SPDateTimeFieldFriendlyFormatType)Enum.Parse(typeof(SPDateTimeFieldFriendlyFormatType), typedFieldModel.FriendlyDisplayFormat);
#endif
        }
开发者ID:karayakar,项目名称:spmeta2,代码行数:26,代码来源:DateTimeFieldModelHandler.cs

示例11: ProcessSPFieldXElement

        protected override void ProcessSPFieldXElement(XElement fieldTemplate, FieldDefinition fieldModel)
        {
            base.ProcessSPFieldXElement(fieldTemplate, fieldModel);

            var typedFieldModel = fieldModel.WithAssertAndCast<SummaryLinkFieldDefinition>("model", value => value.RequireNotNull());

            //fieldTemplate.SetAttribute(BuiltInFieldAttributes.Format, typedFieldModel.EditFormat);
        }
开发者ID:Uolifry,项目名称:spmeta2,代码行数:8,代码来源:SummaryLinkFieldModelHandler.cs

示例12: ProcessFieldProperties

        protected override void ProcessFieldProperties(SPField field, FieldDefinition fieldModel)
        {
            // let base setting be setup
            base.ProcessFieldProperties(field, fieldModel);

            var typedFieldModel = fieldModel.WithAssertAndCast<SummaryLinkFieldDefinition>("model", value => value.RequireNotNull());
            var typedField = field as SummaryLinkField;
        }
开发者ID:karayakar,项目名称:spmeta2,代码行数:8,代码来源:SummaryLinkFieldModelHandler.cs

示例13: CanSerializeAndDeserializeXML

        public void CanSerializeAndDeserializeXML()
        {
            var obj = new FieldDefinition();
            var service = new DefaultXMLSerializationService();

            var strValue = service.Serialize(obj);
            service.Deserialize(obj.GetType(), strValue);
        }
开发者ID:maratbakirov,项目名称:spmeta2,代码行数:8,代码来源:SerializationServicesTests.cs

示例14: ProcessSPFieldXElement

        protected override void ProcessSPFieldXElement(XElement fieldTemplate, FieldDefinition fieldModel)
        {
            base.ProcessSPFieldXElement(fieldTemplate, fieldModel);

            var typedFieldModel = fieldModel.WithAssertAndCast<CurrencyFieldDefinition>("model", value => value.RequireNotNull());

            fieldTemplate.SetAttribute(BuiltInFieldAttributes.LCID, typedFieldModel.CurrencyLocaleId);
        }
开发者ID:karayakar,项目名称:spmeta2,代码行数:8,代码来源:CurrencyFieldModelHandler.cs

示例15: ProcessCommonProperties

        private static void ProcessCommonProperties(SPField siteField, FieldDefinition fieldModel)
        {
            siteField.Title = fieldModel.Title;
            siteField.Group = fieldModel.Group;

            // SPBug, description cannot be null
            siteField.Description = fieldModel.Description ?? string.Empty;
        }
开发者ID:nklychnikov,项目名称:spmeta2,代码行数:8,代码来源:FieldModelHandler.cs


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