Skip to content
This repository has been archived by the owner on Mar 5, 2024. It is now read-only.

Commit

Permalink
Merge pull request #58 from finos-plexus/db-contrib/db_contrib_develop
Browse files Browse the repository at this point in the history
Allow shared access for reading registry files
  • Loading branch information
nikoant authored Jun 27, 2018
2 parents 0bddcbd + 1c693cc commit 3efdd6b
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 9 deletions.
10 changes: 6 additions & 4 deletions desktop/src/Plexus.Interop.Apps.Manager/Internal/AppsDto.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
namespace Plexus.Interop.Apps.Internal
namespace Plexus.Interop.Apps.Internal
{
using Newtonsoft.Json;
using System.Collections.Generic;
using System.IO;
using System.Text;

internal sealed class AppsDto
{
Expand All @@ -27,11 +28,12 @@ internal sealed class AppsDto

public static AppsDto Load(string filePath)
{
using (var file = File.OpenText(filePath))
using (var reader = new JsonTextReader(file))
using (var stream = File.Open(filePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
using (var streamReader = new StreamReader(stream, Encoding.UTF8))
using (var jsonReader = new JsonTextReader(streamReader))
{
var serializer = new JsonSerializer();
return serializer.Deserialize<AppsDto>(reader);
return serializer.Deserialize<AppsDto>(jsonReader);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ namespace Plexus.Interop.Metamodel.Json.Internal
using Newtonsoft.Json;
using System.Collections.Generic;
using System.IO;
using System.Text;

internal sealed class RegistryDto
{
Expand All @@ -30,8 +31,9 @@ internal sealed class RegistryDto

public static RegistryDto LoadFromFile(string filePath)
{
using (var file = File.OpenText(filePath))
using (var reader = new JsonTextReader(file))
using (var stream = File.Open(filePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
using (var streamReader = new StreamReader(stream, Encoding.UTF8))
using (var reader = new JsonTextReader(streamReader))
{
var serializer = new JsonSerializer();
return serializer.Deserialize<RegistryDto>(reader);
Expand Down
2 changes: 1 addition & 1 deletion desktop/src/Plexus.Interop.Metamodel.Json/JsonRegistry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public static class JsonRegistry
{
public static IRegistry LoadRegistry(string fileName)
{
using (var stream = File.Open(fileName, FileMode.Open))
using (var stream = File.Open(fileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
{
return LoadRegistry(stream);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,11 @@ private void Configure(IApplicationBuilder app)
{
using (var webSocket = await context.WebSockets.AcceptWebSocketAsync().ConfigureAwait(false))
{
using (var stream = File.OpenText(physicalPath))
using (var stream = File.Open(physicalPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
using (var streamReader = new StreamReader(stream))
{
var bytes = Encoding.UTF8.GetBytes(
await stream.ReadToEndAsync().ConfigureAwait(false));
await streamReader.ReadToEndAsync().ConfigureAwait(false));
await webSocket
.SendAsync(
new ArraySegment<byte>(bytes),
Expand Down

0 comments on commit 3efdd6b

Please sign in to comment.