Пример #1
0
        private void SetPropertyOrField(Type propertyOrFieldType, object entity, Action <object> setIdentifier, string id)
        {
            if (propertyOrFieldType == typeof(string))
            {
                setIdentifier(id);
            }
            else             // need converting
            {
                var converter =
                    conventions.IdentityTypeConvertors.FirstOrDefault(x => x.CanConvertFrom(propertyOrFieldType));
                if (converter == null)
                {
                    throw new ArgumentException("Could not convert identity to type " + propertyOrFieldType +
                                                " because there is not matching type converter registered in the conventions' IdentityTypeConvertors");
                }

                setIdentifier(converter.ConvertTo(conventions.FindIdValuePartForValueTypeConversion(entity, id)));
            }
        }