protected NavigationSourceConfiguration(ODataModelBuilder modelBuilder, EntityTypeConfiguration entityType, string name) { if (modelBuilder == null) { throw Error.ArgumentNull("modelBuilder"); } if (entityType == null) { throw Error.ArgumentNull("entityType"); } if (String.IsNullOrEmpty(name)) { throw Error.ArgumentNullOrEmpty("name"); } _modelBuilder = modelBuilder; Name = name; EntityType = entityType; ClrType = entityType.ClrType; DerivedTypeConstraints = new DerivedTypeConstraintConfiguration(); _url = Name; _editLinkBuilder = null; _readLinkBuilder = null; _navigationPropertyLinkBuilders = new Dictionary <NavigationPropertyConfiguration, NavigationLinkBuilder>(); }
/// <summary> /// Adds TDerivedType to the list of derived type constraints for the return type. /// </summary> /// <returns>Updated configuration object.</returns> public ActionConfiguration HasDerivedTypeConstraintForReturnType <TDerivedType>() { if (ReturnType == null) { throw Error.InvalidOperation(SRResources.ReturnTypeOfOperationNotSpecified); } if (ReturnTypeConstraints == null) { ReturnTypeConstraints = new DerivedTypeConstraintConfiguration(); } ReturnTypeConstraints.AddConstraint <TDerivedType>(); return(this); }
/// <summary> /// Adds subtypes to the list of derived type constraints for the return type. /// </summary> /// <param name="subtypes">The subtypes for which the constraint needs to be added.</param> /// <returns>Updated configuration object.</returns> public FunctionConfiguration HasDerivedTypeConstraintsForReturnType(params Type[] subtypes) { if (ReturnType == null) { throw Error.InvalidOperation(SRResources.ReturnTypeOfOperationNotSpecified); } if (ReturnTypeConstraints == null) { ReturnTypeConstraints = new DerivedTypeConstraintConfiguration(); } ReturnTypeConstraints.AddConstraints(subtypes); return(this); }
/// <summary> /// Initializes a new instance of the <see cref="PropertyConfiguration"/> class. /// </summary> /// <param name="property">The name of the property.</param> /// <param name="declaringType">The declaring EDM type of the property.</param> protected PropertyConfiguration(PropertyInfo property, StructuralTypeConfiguration declaringType) { if (property == null) { throw Error.ArgumentNull("property"); } if (declaringType == null) { throw Error.ArgumentNull("declaringType"); } PropertyInfo = property; DeclaringType = declaringType; AddedExplicitly = true; _name = property.Name; QueryConfiguration = new QueryConfiguration(); DerivedTypeConstraints = new DerivedTypeConstraintConfiguration(); }
/// <summary> /// Initializes a new instance of the <see cref="ParameterConfiguration"/> class. /// </summary> /// <param name="name">The name of the parameter.</param> /// <param name="parameterType">The EDM type of the parameter.</param> protected ParameterConfiguration(string name, IEdmTypeConfiguration parameterType) { if (name == null) { throw Error.ArgumentNull("name"); } if (parameterType == null) { throw Error.ArgumentNull("parameterType"); } Name = name; TypeConfiguration = parameterType; DerivedTypeConstraints = new DerivedTypeConstraintConfiguration(); Type elementType; Nullable = TypeHelper.IsCollection(parameterType.ClrType, out elementType) ? EdmLibHelpers.IsNullable(elementType) : EdmLibHelpers.IsNullable(parameterType.ClrType); }