/// <inheritdoc /> protected override void ModifyResourceAttribute(Type type, RESTarAttribute attribute) { if (type.IsSubclassOf(typeof(ElasticSQLiteTable))) { attribute.AllowDynamicConditions = true; attribute.FlagStaticMembers = true; } }
public _PayloadTarget(RESTarAttribute attribute) { Name = typeof(T).RESTarTypeName(); Description = attribute?.Description; Type = typeof(T); (_, ConditionBindingRule) = typeof(T).GetDynamicConditionHandling(attribute); Members = typeof(T).GetDeclaredProperties(); }
internal static void ValidateRuntimeInsertion(Type type, string fullName, RESTarAttribute attribute) { string name; if (fullName != null) { if (fullName.StartsWith("RESTar.", StringComparison.OrdinalIgnoreCase) && !type.Assembly.Equals(typeof(ResourceValidator).Assembly)) { throw new InvalidResourceDeclarationException($"Cannot add resource '{fullName}'. A resource name cannot start with 'RESTar'"); } name = fullName; } else { name = type.RESTarTypeName(); } if (name == null) { throw new InvalidResourceDeclarationException( "Encountered an unknown type. No further information is available."); } if (RESTarConfig.ResourceByType.ContainsKey(type)) { throw new InvalidResourceDeclarationException( $"Cannot add resource '{name}'. A resource with the same type ('{type.RESTarTypeName()}') has already been added to RESTar"); } if (RESTarConfig.ResourceByName.ContainsKey(name)) { throw new InvalidResourceDeclarationException( $"Cannot add resource '{name}'. A resource with the same name has already been added to RESTar"); } attribute = attribute ?? type.GetCustomAttribute <RESTarAttribute>(); if (attribute == null) { throw new InvalidResourceDeclarationException( $"Cannot add resource '{name}'. The type was not decorated with the RESTarAttribute attribute, and " + "no additional attribute instance was included in the insertion."); } Validate(type); }