Пример #1
0
        internal string MapObjectToString(object value, RdfMapperPredicateAttribute attribute)
        {
            var objectRdfMapperMethods = Activator.CreateInstance(attribute.IRdfMapperObjectMethods);

            return(attribute.IRdfMapperObjectMethods
                   .GetMethod(StaticReflection.GetMemberName((IRdfMapperObjectMethods m) => m.MapObjectToString(value)))
                   .Invoke(objectRdfMapperMethods, new object[] { value }).ToString());
        }
Пример #2
0
        private void ValidatePredicate(PropertyInfo property, out RdfMapperPredicateAttribute attribute)
        {
            property.TryGetAttribute(out attribute);

            if (attribute == null)
            {
                throw new ArgumentException(string.Format("{0} is missing", typeof(RdfMapperPredicateAttribute).Name));
            }
            else if (!attribute.IRdfMapperObjectMethods.IsClass)
            {
                throw new ArgumentException(string.Format("{0} must be a class",
                                                          StaticReflection.GetFullMemberName((RdfMapperPredicateAttribute a) => a.IRdfMapperObjectMethods)));
            }
            else if (!typeof(IRdfMapperObjectMethods).IsAssignableFrom(attribute.IRdfMapperObjectMethods))
            {
                throw new ArgumentException(string.Format("{0} must implement the interface {1}",
                                                          StaticReflection.GetFullMemberName((RdfMapperPredicateAttribute a) => a.IRdfMapperObjectMethods), typeof(IRdfMapperObjectMethods).Name));
            }
        }