| | | 1 | | namespace FirebaseAdapter.Configuration; |
| | | 2 | | |
| | | 3 | | /// <summary> |
| | | 4 | | /// Configuration options for Firebase database connection. |
| | | 5 | | /// </summary> |
| | | 6 | | public class FirebaseOptions |
| | | 7 | | { |
| | | 8 | | /// <summary> |
| | | 9 | | /// The section name for configuration binding. |
| | | 10 | | /// </summary> |
| | | 11 | | public const string SectionName = "Firebase"; |
| | | 12 | | |
| | | 13 | | /// <summary> |
| | | 14 | | /// Firebase project ID. |
| | | 15 | | /// </summary> |
| | 1 | 16 | | public string ProjectId { get; set; } = string.Empty; |
| | | 17 | | |
| | | 18 | | /// <summary> |
| | | 19 | | /// Firebase service account private key JSON content. |
| | | 20 | | /// This should contain the complete JSON service account key. |
| | | 21 | | /// </summary> |
| | 1 | 22 | | public string ServiceAccountJson { get; set; } = string.Empty; |
| | | 23 | | |
| | | 24 | | /// <summary> |
| | | 25 | | /// Optional: Path to the service account JSON file. |
| | | 26 | | /// If specified, this will be used instead of ServiceAccountJson. |
| | | 27 | | /// </summary> |
| | 1 | 28 | | public string? ServiceAccountPath { get; set; } |
| | | 29 | | |
| | | 30 | | /// <summary> |
| | | 31 | | /// Validates that the required configuration is present. |
| | | 32 | | /// </summary> |
| | | 33 | | public void Validate() |
| | | 34 | | { |
| | 1 | 35 | | if (string.IsNullOrWhiteSpace(ProjectId)) |
| | | 36 | | { |
| | 1 | 37 | | throw new InvalidOperationException("Firebase ProjectId is required."); |
| | | 38 | | } |
| | | 39 | | |
| | 1 | 40 | | if (string.IsNullOrWhiteSpace(ServiceAccountJson) && string.IsNullOrWhiteSpace(ServiceAccountPath)) |
| | | 41 | | { |
| | 1 | 42 | | throw new InvalidOperationException("Either Firebase ServiceAccountJson or ServiceAccountPath must be provid |
| | | 43 | | } |
| | 1 | 44 | | } |
| | | 45 | | } |