mirror of
https://github.com/xtool-org/xtool.git
synced 2026-11-16 20:41:53 +03:00
39 lines
952 B
Swift
39 lines
952 B
Swift
//
|
|
// Entitlement+DeveloperServicesFeature.swift
|
|
// Supersign
|
|
//
|
|
// Created by Kabir Oberai on 09/10/19.
|
|
// Copyright © 2019 Kabir Oberai. All rights reserved.
|
|
//
|
|
|
|
import Foundation
|
|
|
|
protocol BaseEntitlementWithFeature: Entitlement {
|
|
func baseFeature() -> DeveloperServicesFeature
|
|
}
|
|
|
|
protocol EntitlementWithFeature: BaseEntitlementWithFeature {
|
|
associatedtype Feature: DeveloperServicesFeature
|
|
func typedFeature() -> Feature
|
|
}
|
|
extension EntitlementWithFeature {
|
|
func baseFeature() -> DeveloperServicesFeature {
|
|
return typedFeature()
|
|
}
|
|
}
|
|
|
|
extension EntitlementWithFeature
|
|
where Self: RawRepresentable,
|
|
Feature: RawRepresentable,
|
|
RawValue == Feature.RawValue {
|
|
func typedFeature() -> Feature {
|
|
return Feature(rawValue: rawValue)!
|
|
}
|
|
}
|
|
|
|
public extension Entitlement {
|
|
func feature() -> DeveloperServicesFeature? {
|
|
return (self as? BaseEntitlementWithFeature)?.baseFeature()
|
|
}
|
|
}
|