CSDLDocument

open class CSDLDocument: ObjectBase

Encapsulates the definitions from a parsed Open Data Protocol (OData) service metadata (CSDL) document.

See also

CsdlParser.
  • A unique key to identify the CSDLDocument when it is inserted into the Decoder class’s userInfo property

    Declaration

    Swift

    public static let csdlInfoKey = CodingUserInfoKey(rawValue: "CSDLDocument")!
  • Allows any model element to be changed in the latest service metadata before calling DataService.refreshMetadata. Defaults to false. Warning: enabling this option can result in application instability (depending on the changes) if the application uses proxy classes!

    Declaration

    Swift

    final public var canChangeAnything: Bool = false
  • Allows any model element to be removed in the latest service metadata before calling DataService.refreshMetadata. Defaults to false. Warning: enabling this option can result in application instability unless the application checks isRemoved flags on model elements!

    Declaration

    Swift

    final public var canRemoveAnything: Bool = false
  • true if this metadata is associated with generated proxy classes. Defaults to false (generated proxies will override to true).

    Declaration

    Swift

    final public var hasGeneratedProxies: Bool = false
  • Allows addition of enumeration members in the latest service metadata before calling DataService.refreshMetadata. Defaults to false. Warning: enabling this option can result in application instability if the application uses proxy classes without -open:enumerations.

    Declaration

    Swift

    final public var hasOpenEnumerations: Bool = false
  • If this metadata was parsed by generated proxy classes, then the framework version that generated the proxies. Otherwise nil.

    Declaration

    Swift

    final public var proxyVersion: String?
  • Text for the OData version, e.g. 4.0.

    Declaration

    Swift

    final public var versionText: String = ""
  • Code for the OData version, e.g. 400. If the OData version is considered as a decimal number (e.g. 4.0), then multiplying by 100 will give the code (e.g. 400).

    See also

    DataVersion.

    Declaration

    Swift

    final public var versionCode: Int = (0 as Int)
  • Original CSDL (XML) text.

    See also

    CsdlOption.RETAIN_ORIGINAL_TEXT.

    Declaration

    Swift

    final public var originalText: String?
  • Resolved CSDL (XML) text, with inline references and expanded aliases.

    See also

    CsdlOption.RETAIN_RESOLVED_TEXT.

    Declaration

    Swift

    final public var resolvedText: String?
  • Main data schema defined by the CSDL (or nil if there are no schemas defined).

    Declaration

    Swift

    final public var mainSchema: DataSchema?
  • Top-level schemas defined by the CSDL (empty if there are no schemas defined).

    Declaration

    Swift

    final public var topSchemas: DataSchemaList = DataSchemaList()
  • Default entity container defined by the CSDL (or nil if there are no containers defined).

    Declaration

    Swift

    final public var defaultContainer: EntityContainer?
  • Default initializer.

    Declaration

    Swift

    override public init()
  • Register owner as an owner of this metadata document.

    Declaration

    Swift

    open func addOwner(_ owner: AnyObject) -> Void

    Parameters

    owner

    Metadata owner.

  • Map of annotation terms defined by the CSDL.

    Declaration

    Swift

    open var annotationTerms: AnnotationTermMap
  • Map of predefined CSDL data types.

    Declaration

    Swift

    open var builtinTypes: DataTypeMap
  • Lookup a complex type by qualified name. If the complex type does not exist it indicates a fundamental implementation problem, therefore a non-catchable FatalException will be thrown, and the app intentionally crashes. The reason behind this drastic behaviour is to avoid mismatch between server and client. It is still possible to avoid the FatalException by looking up simplet types before calling this method like in the following code snippet:

    Example checking if a complex type exists

    open func checkComplexTypeExistsExample() throws -> Void {
        let csdlDocument = self.service.metadata
        if csdlDocument.complexTypes.containsValue(forKey: "Microsoft.OData.Service.Sample.TrippinInMemory.Models.EventLocation") {
            _ = csdlDocument.complexType(withName: "Microsoft.OData.Service.Sample.TrippinInMemory.Models.EventLocation")
        } else {
        }
    }
    

    See also

    complexTypes, for looking up types that might not exist.

    Declaration

    Swift

    open func complexType(withName name: String) -> ComplexType

    Parameters

    name

    Name of the complex type to be returned.

    Return Value

    The complex type, which must exist.

  • Map of complex types defined by the CSDL.

    Declaration

    Swift

    open var complexTypes: ComplexTypeMap
  • Lookup a data method by qualified name (for function/action definitions) or by unqualified name (for function/action imports). If the data method does not exist it indicates a fundamental implementation problem, therefore a non-catchable FatalException will be thrown, and the app intentionally crashes. The reason behind this drastic behaviour is to avoid mismatch between server and client. It is still possible to avoid the FatalException by looking up data methods before calling this method like in the following code snippet:

    Example checking if a data method exists

    open func checkDataMethodInCsdlDocumentExistsExample() throws -> Void {
        let csdlDocument = self.service.metadata
        if csdlDocument.lookupMethods.containsValue(forKey: "Microsoft.OData.Service.Sample.TrippinInMemory.Models.Person.UpdatePersonLastName") {
            _ = csdlDocument.dataMethod(withName: "Microsoft.OData.Service.Sample.TrippinInMemory.Models.Person.UpdatePersonLastName")
        } else {
        }
    }
    

    See also

    dataMethods, for looking up methods that might not exist.

    Declaration

    Swift

    open func dataMethod(withName name: String) -> DataMethod

    Parameters

    name

    Name of the data method to be returned.

    Return Value

    The data method, which must exist.

  • Map of data methods (actions, functions) defined by the CSDL.

    Declaration

    Swift

    open var dataMethods: DataMethodMap
  • Lookup a data schema by name. If the data schema does not exist it indicates a fundamental implementation problem, therefore a non-catchable FatalException will be thrown, and the app intentionally crashes. The reason behind this drastic behaviour is to avoid mismatch between server and client. It is still possible to avoid the FatalException by looking up data schemas before calling this method like in the following code snippet:

    Example checking if a data schema exists

    open func checkDataSchemaExistsExample() throws -> Void {
        let csdlDocument = self.service.metadata
        if csdlDocument.dataSchemas.containsValue(forKey: "Microsoft.OData.Service.Sample.TrippinInMemory.Models") {
            _ = csdlDocument.dataSchema(withName: "Microsoft.OData.Service.Sample.TrippinInMemory.Models")
        } else {
        }
    }
    

    See also

    dataSchemas, for looking up schemas that might not exist.

    Declaration

    Swift

    open func dataSchema(withName name: String) -> DataSchema

    Parameters

    name

    Name of the data schema to be returned.

    Return Value

    The data schema, which must exist.

  • Map of data schemas defined by the CSDL.

    Declaration

    Swift

    open var dataSchemas: DataSchemaMap
  • Map of entity containers defined by the CSDL.

    Declaration

    Swift

    open var entityContainers: EntityContainerMap
  • Lookup an entity set (or singleton entity) by name. If the entity set does not exist it indicates a fundamental implementation problem, therefore a non-catchable FatalException will be thrown, and the app intentionally crashes. The reason behind this drastic behaviour is to avoid mismatch between server and client. It is still possible to avoid the FatalException by looking up simplet types before calling this method like in the following code snippet: Note that OData singleton entities are represented by entity sets where EntitySet.isSingleton is true.

    Example checking if a entity set exists

    open func checkEntitySetInCsdlDocumentExistsExample() throws -> Void {
        let csdlDocument = self.service.metadata
        if csdlDocument.entitySets.containsValue(forKey: "Microsoft.OData.Service.Sample.TrippinInMemory.Models.Airlines") {
            _ = csdlDocument.entitySet(withName: "Microsoft.OData.Service.Sample.TrippinInMemory.Models.Airlines")
        } else {
        }
    }
    

    See also

    entitySets, for looking up sets that might not exist.

    Declaration

    Swift

    open func entitySet(withName name: String) -> EntitySet

    Parameters

    name

    Name of the entity set to be returned.

    Return Value

    The entity set, which must exist.

  • Map of entity sets defined by the CSDL.

    Declaration

    Swift

    open var entitySets: EntitySetMap
  • Lookup an entity type by qualified name. If the entity type does not exist it indicates a fundamental implementation problem, therefore a non-catchable FatalException will be thrown, and the app intentionally crashes. The reason behind this drastic behaviour is to avoid mismatch between server and client. It is still possible to avoid the FatalException by looking up simplet types before calling this method like in the following code snippet:

    Example checking if a entity type exists

    open func checkEntityTypeExistsExample() throws -> Void {
        let csdlDocument = self.service.metadata
        if csdlDocument.entityTypes.containsValue(forKey: "Microsoft.OData.Service.Sample.TrippinInMemory.Models.Airport") {
            _ = csdlDocument.entityType(withName: "Microsoft.OData.Service.Sample.TrippinInMemory.Models.Airport")
        } else {
        }
    }
    

    See also

    entityTypes, for looking up types that might not exist.

    Declaration

    Swift

    open func entityType(withName name: String) -> EntityType

    Parameters

    name

    Name of the entity type to be returned.

    Return Value

    The entity type, which must exist.

  • Map of entity types defined by the CSDL.

    Declaration

    Swift

    open var entityTypes: EntityTypeMap
  • Lookup an enum type by qualified name. If the enum type does not exist it indicates a fundamental implementation problem, therefore a non-catchable FatalException will be thrown, and the app intentionally crashes. The reason behind this drastic behaviour is to avoid mismatch between server and client. It is still possible to avoid the FatalException by looking up simplet types before calling this method like in the following code snippet:

    Example checking if an enum type exists

    open func checkEnumTypeExistsExample() throws -> Void {
        let csdlDocument = self.service.metadata
        if csdlDocument.enumTypes.containsValue(forKey: "Microsoft.OData.Service.Sample.TrippinInMemory.Models.PersonGender") {
            _ = csdlDocument.enumType(withName: "Microsoft.OData.Service.Sample.TrippinInMemory.Models.PersonGender")
        } else {
        }
    }
    

    See also

    enumTypes, for looking up types that might not exist.

    Declaration

    Swift

    open func enumType(withName name: String) -> EnumType

    Parameters

    name

    Name of the enum type to be returned.

    Return Value

    The enum type, which must exist.

  • Map of enum types defined by the CSDL.

    Declaration

    Swift

    open var enumTypes: EnumTypeMap
  • Return all the current registered owners of this metadata document.

    Declaration

    Swift

    open func owners() -> ObjectList
  • Map of path annotations defined by the CSDL (where the TargetPath does not directly reference a model element).

    Declaration

    Swift

    open var pathAnnotations: PathAnnotationsMap
  • Unregister owner as an owner of this metadata document.

    Declaration

    Swift

    open func removeOwner(_ owner: AnyObject) -> Void

    Parameters

    owner

    Metadata owner.

  • Resolve the EntityValue.entitySet of `entity’ (if it is not already set).

    Throws

    DataServiceException if entity.entitySet is not set, and is not unique (i.e. multiple entity sets use the same entity type).

    Declaration

    Swift

    open func resolveEntity(_ entity: EntityValue) -> Void

    Parameters

    entity

    Entity to resolve.

  • Lookup a simple type by qualified name. If the simple type does not exist it indicates a fundamental implementation problem, therefore a non-catchable FatalException will be thrown, and the app intentionally crashes. The reason behind this drastic behaviour is to avoid mismatch between server and client. It is still possible to avoid the FatalException by looking up simplet types before calling this method like in the following code snippet:

    Example checking if a simple type exists

    open func checkSimpleTypeExistsExample() throws -> Void {
        let csdlDocument = self.service.metadata
        if csdlDocument.simpleTypes.containsValue(forKey: "Microsoft.OData.Service.Sample.TrippinInMemory.Models.MySimpleType") {
            _ = csdlDocument.simpleType(withName: "Microsoft.OData.Service.Sample.TrippinInMemory.Models.MySimpleType")
        } else {
        }
    }
    

    See also

    simpleTypes, for looking up types that might not exist.

    Declaration

    Swift

    open func simpleType(withName name: String) -> SimpleType

    Parameters

    name

    Name of the simple type to be returned.

    Return Value

    The simple type, which must exist.

  • Map of simple types defined by the CSDL.

    Declaration

    Swift

    open var simpleTypes: SimpleTypeMap
  • Lookup a singleton entity by name. If the singleton entity does not exist it indicates a fundamental implementation problem, therefore a non-catchable FatalException will be thrown, and the app intentionally crashes. The reason behind this drastic behaviour is to avoid mismatch between server and client. It is still possible to avoid the FatalException by looking up simplet types before calling this method like in the following code snippet: Note that OData singleton entities are represented by entity sets where EntitySet.isSingleton is true.

    Example checking if a ingleton entity exists

    open func checkSingletonExistsExample() throws -> Void {
        let csdlDocument = self.service.metadata
        if csdlDocument.singletons.containsValue(forKey: "Microsoft.OData.Service.Sample.TrippinInMemory.Models.Container/Me") {
            _ = csdlDocument.singleton(withName: "Microsoft.OData.Service.Sample.TrippinInMemory.Models.Container/Me")
        } else {
        }
    }
    

    See also

    entitySets, for looking up sets that might not exist.

    Declaration

    Swift

    open func singleton(withName name: String) -> EntitySet

    Parameters

    name

    Name of the entity set to be returned.

    Return Value

    The entity set, which must exist.

  • Map of singletons defined by the CSDL. Each singleton is represented by an EntitySet with isSingleton == true

    Declaration

    Swift

    open var singletons: EntitySetMap
  • Map of XML namespaces defined by the CSDL.

    Declaration

    Swift

    open var xmlNamespaces: StringMap