Skip to content

Commit a10349e

Browse files
author
Anouar Hassine
committed
Adding possibility to create an Api from an xcApi file path (#64)
1 parent e085a9c commit a10349e

1 file changed

Lines changed: 15 additions & 2 deletions

File tree

ReactiveXComponent/XComponentApi.cs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
using System;
2-
using System.IO;
1+
using System.IO;
2+
using ReactiveXComponent.Common;
33
using ReactiveXComponent.Configuration;
44
using ReactiveXComponent.Connection;
55
using ReactiveXComponent.Parser;
@@ -20,6 +20,19 @@ private XComponentApi(Stream xcApiStream, string privateCommunicationIdentifier
2020
_xcConnection = connectionFactory.CreateConnection(connectionType);
2121
}
2222

23+
public static IXComponentApi CreateFromXCApi(string xcApiFilePath, string privateCommunicationIdentifier = null)
24+
{
25+
if (!File.Exists(xcApiFilePath))
26+
{
27+
throw new ReactiveXComponentException($"The file {xcApiFilePath} doesn't exist");
28+
}
29+
30+
using (var stream = new FileStream(xcApiFilePath, FileMode.Open))
31+
{
32+
return CreateFromXCApi(stream, privateCommunicationIdentifier);
33+
}
34+
}
35+
2336
public static IXComponentApi CreateFromXCApi(Stream xcApiStream, string privateCommunicationIdentifier = null)
2437
{
2538
return new XComponentApi(xcApiStream, privateCommunicationIdentifier);

0 commit comments

Comments
 (0)