public static Implementations FromAttributes(Type t, PropertyRoute route, ImplementedByAttribute ib, ImplementedByAllAttribute iba) { Implementations?imp = TryFromAttributes(t, route, ib, iba); if (imp == null) { var message = Error(t) + @". Set implementations for {0}.".FormatWith(route); if (t.IsInterface || t.IsAbstract) { message += @"\r\n" + ConsiderMessage(route, "typeof(YourConcrete" + t.TypeName() + ")"); } throw new InvalidOperationException(message); } return(imp.Value); }
public static Implementations FromAttributes(Type t, PropertyRoute route, ImplementedByAttribute ib, ImplementedByAllAttribute iba) { Implementations?imp = TryFromAttributes(t, route, ib, iba); if (imp == null) { var message = Error(t) + @". Set implementations for {0}.".FormatWith(route); if (t.IsInterface || t.IsAbstract) { message += @"\r\nConsider writing something like this in your Starter class: sb.Schema.Settings.FieldAttributes(({0} a) => a.{1}).Replace(new ImplementedByAttribute(typeof(YourConcrete{2})));" .FormatWith(route.RootType.TypeName(), route.PropertyString().Replace("/", ".First()."), t.TypeName()); } throw new InvalidOperationException(message); } return(imp.Value); }
public static Implementations?TryFromAttributes(Type t, PropertyRoute route, ImplementedByAttribute ib, ImplementedByAllAttribute iba) { if (ib != null && iba != null) { throw new NotSupportedException("Route {0} contains both {1} and {2}".FormatWith(route, ib.GetType().Name, iba.GetType().Name)); } if (ib != null) { return(Implementations.By(ib.ImplementedTypes)); } if (iba != null) { return(Implementations.ByAll); } if (Error(t) == null) { return(Implementations.By(t)); } return(null); }