public SPModelFieldAssociation(SPModelDescriptor descriptor, SPFieldAttribute attribute, PropertyInfo queryProperty) { CommonHelper.ConfirmNotNull(descriptor, "descriptor"); CommonHelper.ConfirmNotNull(attribute, "attribute"); this.descriptor = descriptor; this.attribute = attribute; this.queryProperty = queryProperty; }
// This method returns object as IFieldUpdate and ILookupFieldUpdate share no common base type private object ToFieldUpdateType(object listModel, PropertyInfo propertyInfo, SPFieldAttribute attribute) { return(attribute switch { SpLookupFieldAttribute lookupFieldAttribute => ToLookupFieldUpdate(listModel, propertyInfo, lookupFieldAttribute), SPFieldAttribute fieldAttribute => ToFieldUpdate(listModel, propertyInfo, fieldAttribute), _ => throw new ArgumentOutOfRangeException($"Unexpected type '{attribute.GetType()}'", nameof(attribute)), });