Skip to content

Commit

Permalink
Merge pull request #12 from kalienvivian401/master
Browse files Browse the repository at this point in the history
added: update with foton name
pablocar80 authored Mar 31, 2023
2 parents 188ee28 + c4782bf commit 5726d10
Showing 51 changed files with 139 additions and 139 deletions.
Original file line number Diff line number Diff line change
@@ -6,13 +6,13 @@

using System;
using System.Diagnostics;
using Electrolite.Common.Main;
using Foton.Common.Main;

namespace Electrolite.Common.Adapters
namespace Foton.Common.Adapters
{
public interface IPlatformAdapter
{
ISession CreateSession(Uri url, ElectroliteOptions options);
ISession CreateSession(Uri url, FotonOptions options);
}

public interface IIpcPlatformAdapter : IPlatformAdapter
Original file line number Diff line number Diff line change
@@ -8,16 +8,16 @@
using System.Diagnostics;
using System.Threading;
using System.Threading.Tasks;
using Electrolite.Common.Ipc;
using Electrolite.Common.Main;
using Foton.Common.Ipc;
using Foton.Common.Main;
using Nito.AsyncEx;

namespace Electrolite.Common.Adapters
namespace Foton.Common.Adapters
{
public sealed class IpcSession : ISession
{
public Uri Url { get; }
public ElectroliteOptions StartupOptions { get; }
public FotonOptions StartupOptions { get; }
private readonly IIpcPlatformAdapter _adapter;
private readonly IpcPipeDuplex<IBrowserHost, IBrowserWindow> _duplex;
private readonly CancellationTokenSource _source;
@@ -27,17 +27,17 @@ public sealed class IpcSession : ISession
private TaskCompletionSource<bool> _startWaiter;
private TaskCompletionSource<bool> _stopWaiter;

public IpcSession(IIpcPlatformAdapter adapter, Uri url, ElectroliteOptions options)
public IpcSession(IIpcPlatformAdapter adapter, Uri url, FotonOptions options)
{
_adapter = adapter;
Url = url;
StartupOptions = options;
var processId = Process.GetCurrentProcess().Id;
_duplex = new IpcPipeDuplex<IBrowserHost, IBrowserWindow>(new IpcDuplexParameters<IBrowserHost>
{
ClientPipe = ElectroliteCommon.ElectroliteBrowser(processId),
ServerEndpoint = ElectroliteCommon.ElectroliteHostEndpoint(processId),
ServerPipe = ElectroliteCommon.ElectroliteHost(processId),
ClientPipe = FotonCommon.FotonBrowser(processId),
ServerEndpoint = FotonCommon.FotonHostEndpoint(processId),
ServerPipe = FotonCommon.FotonHost(processId),
ServerFactory = provider => new BrowserHost(this)
});
_source = new CancellationTokenSource();
@@ -148,7 +148,7 @@ private void Browser_Exited(object sender, EventArgs e)
Stop();
}

public async Task ModifySettings(ElectroliteOptions options)
public async Task ModifySettings(FotonOptions options)
{
await _duplex.Client.OrderAsync(x => x.ModifyOptions(options));
}
Original file line number Diff line number Diff line change
@@ -8,20 +8,20 @@
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using Electrolite.Common.Main;
using Foton.Common.Main;

namespace Electrolite.Common.Adapters
namespace Foton.Common.Adapters
{
internal sealed class LinuxAdapter : IIpcPlatformAdapter
{
#if DEBUG
private const string BasePath = "../Electrolite.Linux/bin/Debug";
private const string BasePath = "../Foton.Linux/bin/Debug";
#else
const string BasePath = "Linux";
#endif
private const string Filename = "Electrolite.Linux.dll";
private const string Filename = "Foton.Linux.dll";

public ISession CreateSession(Uri url, ElectroliteOptions options)
public ISession CreateSession(Uri url, FotonOptions options)
{
return new IpcSession(this, url, options);
}
Original file line number Diff line number Diff line change
@@ -8,10 +8,10 @@
using System.Diagnostics;
using System.IO;
using System.Reflection;
using Electrolite.Common.Ipc;
using Electrolite.Common.Main;
using Foton.Common.Ipc;
using Foton.Common.Main;

namespace Electrolite.Common.Adapters
namespace Foton.Common.Adapters
{
public static class PlatformCommon
{
@@ -52,9 +52,9 @@ public static IpcPipeDuplex<IBrowserWindow, IBrowserHost> CreateClientDuplex(int
{
return new IpcPipeDuplex<IBrowserWindow, IBrowserHost>(new IpcDuplexParameters<IBrowserWindow>
{
ClientPipe = ElectroliteCommon.ElectroliteHost(parentId),
ServerEndpoint = ElectroliteCommon.ElectroliteBrowserEndpoint(parentId),
ServerPipe = ElectroliteCommon.ElectroliteBrowser(parentId),
ClientPipe = FotonCommon.FotonHost(parentId),
ServerEndpoint = FotonCommon.FotonBrowserEndpoint(parentId),
ServerPipe = FotonCommon.FotonBrowser(parentId),
ServerFactory = (service => factory())
});
}
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@
using System;
using System.Runtime.InteropServices;

namespace Electrolite.Common.Adapters
namespace Foton.Common.Adapters
{
public static class PlatformFactory
{
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@

using System;

namespace Electrolite.Common.Adapters
namespace Foton.Common.Adapters
{
public sealed class ProcessArguments
{
Original file line number Diff line number Diff line change
@@ -8,18 +8,18 @@
using System.Diagnostics;
using System.IO;
using System.Runtime.InteropServices;
using Electrolite.Common.Main;
using Foton.Common.Main;

namespace Electrolite.Common.Adapters
namespace Foton.Common.Adapters
{
internal sealed class WindowsAdapter : IIpcPlatformAdapter
{
#if DEBUG
private const string BasePath = @"..\..\..\..\Electrolite.Windows\bin\x64\Debug";
private const string BasePath = @"..\..\..\..\Foton.Windows\bin\x64\Debug";
#else
const string BasePath = "Windows";
#endif
private const string Filename = "Electrolite.Windows.exe";
private const string Filename = "Foton.Windows.exe";

public Process LaunchBrowser(int parentProcessId, string splashPath)
{
@@ -39,7 +39,7 @@ private static string BuildArgs(int parentProcessId, string splashPath)
return args;
}

public ISession CreateSession(Uri url, ElectroliteOptions options)
public ISession CreateSession(Uri url, FotonOptions options)
{
return new IpcSession(this, url, options);
}
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@

using System;

namespace Electrolite.Common.Ipc
namespace Foton.Common.Ipc
{
public sealed class IpcDuplexParameters<TServer>
where TServer : class
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@
using JKang.IpcServiceFramework;
using Nito.AsyncEx;

namespace Electrolite.Common.Ipc
namespace Foton.Common.Ipc
{
public static class IpcExtensions
{
Original file line number Diff line number Diff line change
@@ -7,11 +7,11 @@
using System;
using System.Threading;
using System.Threading.Tasks;
using Electrolite.Common.Main;
using Foton.Common.Main;
using JKang.IpcServiceFramework;
using Microsoft.Extensions.DependencyInjection;

namespace Electrolite.Common.Ipc
namespace Foton.Common.Ipc
{
public sealed class IpcPipeDuplex<TServer, TClient>
where TServer : class
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@
Author: Pablo Carbonell
*/

namespace Electrolite.Common.Ipc
namespace Foton.Common.Ipc
{
public class Order
{
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@

using System;

namespace Electrolite.Common.Main
namespace Foton.Common.Main
{
public class BackgroundErrorEventArgs : EventArgs
{
Original file line number Diff line number Diff line change
@@ -4,10 +4,10 @@
Author: Pablo Carbonell
*/

using Electrolite.Common.Adapters;
using Electrolite.Common.Ipc;
using Foton.Common.Adapters;
using Foton.Common.Ipc;

namespace Electrolite.Common.Main
namespace Foton.Common.Main
{
internal sealed class BrowserHost : IBrowserHost
{
Original file line number Diff line number Diff line change
@@ -9,18 +9,18 @@
using System.IO;
using System.Reflection;

namespace Electrolite.Common.Main
namespace Foton.Common.Main
{
public static class ElectroliteCommon
public static class FotonCommon
{
public static string GetClientEndpointName(int processId)
{
return "ElectroliteClientEndpoint_" + processId.ToString(CultureInfo.InvariantCulture);
return "FotonClientEndpoint_" + processId.ToString(CultureInfo.InvariantCulture);
}

public static string GetClientPipeName(int processId)
{
return "ElectroliteClientPipe_" + processId.ToString(CultureInfo.InvariantCulture);
return "FotonClientPipe_" + processId.ToString(CultureInfo.InvariantCulture);
}

public static Icon LoadIcon(this Assembly assembly, string resourceName)
@@ -39,17 +39,17 @@ public static Image LoadImage(this Assembly assembly, string resourceName)
}
}

public static string ElectroliteHostEndpoint(int id)
=> NameElement("ElectroliteHostEndpoint_{0}", id);
public static string FotonHostEndpoint(int id)
=> NameElement("FotonHostEndpoint_{0}", id);

public static string ElectroliteBrowserEndpoint(int id)
=> NameElement("ElectroliteEndpoint_{0}", id);
public static string FotonBrowserEndpoint(int id)
=> NameElement("FotonEndpoint_{0}", id);

public static string ElectroliteBrowser(int id)
=> NameElement("ElectroliteBrowser_{0}", id);
public static string FotonBrowser(int id)
=> NameElement("FotonBrowser_{0}", id);

public static string ElectroliteHost(int id)
=> NameElement("ElectroliteHost_{0}", id);
public static string FotonHost(int id)
=> NameElement("FotonHost_{0}", id);

private static string NameElement(string template, int id)
{
Original file line number Diff line number Diff line change
@@ -6,19 +6,19 @@

using System.Runtime.Serialization;

namespace Electrolite.Common.Main
namespace Foton.Common.Main
{
[DataContract]
public class ElectroliteOptions : IElectroliteOptions
public class FotonOptions : IFotonOptions
{
[DataMember]
public ElectroliteSize Size { get; set; }
public FotonSize Size { get; set; }

[DataMember]
public ElectroliteSize MinSize { get; set; } = new ElectroliteSize(1000, 700);
public FotonSize MinSize { get; set; } = new FotonSize(1000, 700);

[DataMember]
public string Title { get; set; } = "Electrolite";
public string Title { get; set; } = "Foton";

[DataMember]
public bool MinButton { get; set; } = true;
Original file line number Diff line number Diff line change
@@ -6,22 +6,22 @@

using System.Runtime.Serialization;

namespace Electrolite.Common.Main
namespace Foton.Common.Main
{
[DataContract]
public sealed class ElectroliteSize
public sealed class FotonSize
{
[DataMember]
public int Width { get; set; }

[DataMember]
public int Height { get; set; }

public ElectroliteSize()
public FotonSize()
{
}

public ElectroliteSize(int width, int height)
public FotonSize(int width, int height)
{
Width = width;
Height = height;
Original file line number Diff line number Diff line change
@@ -4,9 +4,9 @@
Author: Pablo Carbonell
*/

using Electrolite.Common.Ipc;
using Foton.Common.Ipc;

namespace Electrolite.Common.Main
namespace Foton.Common.Main
{
public interface IBrowserHost
{
Original file line number Diff line number Diff line change
@@ -4,9 +4,9 @@
Author: Pablo Carbonell
*/

using Electrolite.Common.Ipc;
using Foton.Common.Ipc;

namespace Electrolite.Common.Main
namespace Foton.Common.Main
{
public enum PlatformType
{
@@ -18,6 +18,6 @@ public enum PlatformType
public interface IBrowserWindow
{
PlatformType PlatformType { get; }
Order ModifyOptions(ElectroliteOptions options);
Order ModifyOptions(FotonOptions options);
}
}
Original file line number Diff line number Diff line change
@@ -4,12 +4,12 @@
Author: Pablo Carbonell
*/

namespace Electrolite.Common.Main
namespace Foton.Common.Main
{
public interface IElectroliteOptions
public interface IFotonOptions
{
ElectroliteSize Size { get; set; }
ElectroliteSize MinSize { get; set; }
FotonSize Size { get; set; }
FotonSize MinSize { get; set; }
string Title { get; set; }
bool MinButton { get; set; }
bool MaxButton { get; set; }
Loading

0 comments on commit 5726d10

Please sign in to comment.