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; }
protected override void PostProcessFieldDefinitionInstance(FieldDefinition def, FieldReverseHost typedReverseHost, ReverseOptions options) { var context = typedReverseHost.HostClientContext; var typedField = context.CastTo<FieldText>(typedReverseHost.Field); var typedDef = def.WithAssertAndCast<TextFieldDefinition>("modelHost", m => m.RequireNotNull()); typedDef.MaxLength = typedField.MaxLength; }
protected override void PostProcessFieldDefinitionInstance(FieldDefinition def, FieldReverseHost typedReverseHost, ReverseOptions options) { var context = typedReverseHost.HostClientContext; var typedField = context.CastTo<FieldCurrency>(typedReverseHost.Field); var typedDef = def.WithAssertAndCast<CurrencyFieldDefinition>("modelHost", m => m.RequireNotNull()); if (typedField.CurrencyLocaleId > 0) typedDef.CurrencyLocaleId = typedField.CurrencyLocaleId; }
protected override void PostProcessFieldDefinitionInstance(FieldDefinition def, FieldReverseHost typedReverseHost, ReverseOptions options) { var context = typedReverseHost.HostClientContext; var typedField = context.CastTo<FieldDateTime>(typedReverseHost.Field); var typedDef = def.WithAssertAndCast<DateTimeFieldDefinition>("modelHost", m => m.RequireNotNull()); typedDef.CalendarType = typedField.DateTimeCalendarType.ToString(); typedDef.DisplayFormat = typedField.DisplayFormat.ToString(); typedDef.FriendlyDisplayFormat = typedField.FriendlyDisplayFormat.ToString(); }
protected override void PostProcessFieldDefinitionInstance(FieldDefinition def, FieldReverseHost typedReverseHost, ReverseOptions options) { var context = typedReverseHost.HostClientContext; var typedField = context.CastTo<FieldUrl>(typedReverseHost.Field); var typedDef = def.WithAssertAndCast<URLFieldDefinition>("modelHost", m => m.RequireNotNull()); var xml = XDocument.Parse(typedField.SchemaXml); var fieldXml = xml.Root; var displayFormat = ConvertUtils.ToString(fieldXml.GetAttributeValue(BuiltInFieldAttributes.Format)); typedDef.DisplayFormat = displayFormat; }
protected override void PostProcessFieldDefinitionInstance(FieldDefinition def, FieldReverseHost typedReverseHost, ReverseOptions options) { var context = typedReverseHost.HostClientContext; var typedField = context.CastTo<FieldUser>(typedReverseHost.Field); var typedDef = def.WithAssertAndCast<UserFieldDefinition>("modelHost", m => m.RequireNotNull()); typedDef.Presence = typedField.Presence; if (typedField.SelectionGroup > 0) { typedDef.SelectionGroup = typedField.SelectionGroup; } typedDef.AllowDisplay = typedField.AllowDisplay; typedDef.SelectionMode = typedField.SelectionMode.ToString(); }
protected override void PostProcessFieldDefinitionInstance(FieldDefinition def, FieldReverseHost typedReverseHost, ReverseOptions options) { var context = typedReverseHost.HostClientContext; var typedField = context.CastTo<FieldMultiChoice>(typedReverseHost.Field); var typedDef = def.WithAssertAndCast<MultiChoiceFieldDefinition>("modelHost", m => m.RequireNotNull()); var xml = XDocument.Parse(typedField.SchemaXml); var fieldXml = xml.Root; var choices = fieldXml.Descendants("CHOICE") .Select(v => v.Value) .ToList(); if (choices.Any()) typedDef.Choices = new Collection<string>(choices); var mappings = fieldXml.Descendants("MAPPING") .Select(v => v.Value) .ToList(); if (mappings.Any()) typedDef.Mappings = new Collection<string>(mappings); }
protected override void PostProcessFieldDefinitionInstance(FieldDefinition def, FieldReverseHost typedReverseHost, ReverseOptions options) { }
protected override void PostProcessFieldDefinitionInstance(FieldDefinition def, FieldReverseHost typedReverseHost, ReverseOptions options) { var context = typedReverseHost.HostClientContext; var typedField = context.CastTo<FieldNumber>(typedReverseHost.Field); var typedDef = def.WithAssertAndCast<NumberFieldDefinition>("modelHost", m => m.RequireNotNull()); if (double.MinValue != typedField.MinimumValue) typedDef.MinimumValue = typedField.MinimumValue; if (double.MaxValue != typedField.MaximumValue) typedDef.MaximumValue = typedField.MaximumValue; var xml = XDocument.Parse(typedField.SchemaXml); var fieldXml = xml.Root; var showAsPercentage = ConvertUtils.ToBool(fieldXml.GetAttributeValue("Percentage")); typedDef.ShowAsPercentage = showAsPercentage.HasValue ? showAsPercentage.Value : false; var decimals = ConvertUtils.ToString(fieldXml.GetAttributeValue("Decimals")); if (!string.IsNullOrEmpty(decimals)) { var decimalsIntValue = ConvertUtils.ToInt(decimals); if (decimalsIntValue.HasValue) { switch (decimalsIntValue) { case -1: { typedDef.DisplayFormat = BuiltInNumberFormatTypes.Automatic; } break; case 0: { typedDef.DisplayFormat = BuiltInNumberFormatTypes.NoDecimal; } break; case 1: { typedDef.DisplayFormat = BuiltInNumberFormatTypes.OneDecimal; } break; case 2: { typedDef.DisplayFormat = BuiltInNumberFormatTypes.TwoDecimals; } break; case 3: { typedDef.DisplayFormat = BuiltInNumberFormatTypes.ThreeDecimals; } break; case 4: { typedDef.DisplayFormat = BuiltInNumberFormatTypes.FourDecimals; } break; case 5: { typedDef.DisplayFormat = BuiltInNumberFormatTypes.FiveDecimals; } break; } } } }
protected virtual void PostProcessFieldDefinitionInstance(FieldDefinition def, FieldReverseHost typedReverseHost, ReverseOptions options) { // implement typed field mapping here }