Skip to content

Commit 78d9d60

Browse files
Merge branch 'master' into bug/578
2 parents 476cc9e + fdd643b commit 78d9d60

33 files changed

+496
-219
lines changed

Changelog.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Not released
22

3+
# 11.5.2
4+
5+
# Released
6+
37
# 11.5.1
48

59
ElectronNET.CLI:
@@ -45,8 +49,6 @@ Example for consuming the activate event (MacOs only)
4549
* Fixed bug: Maintain references between socket.io connection events (thanks [danatcofo](https://github.com/danatcofo )) [\#468](https://github.com/ElectronNET/Electron.NET/pull/486)
4650
* Fixed bug: Set default WebPreferences.DefaultFontSize (thanks [duncanawoods](https://github.com/duncanawoods)) [\#468](https://github.com/ElectronNET/Electron.NET/pull/468)
4751

48-
# Released
49-
5052
# 9.31.2
5153

5254
* Electron-Builder fixed for Windows builds.

ElectronNET.API/Entities/Blob.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
namespace ElectronNET.API.Entities
2+
{
3+
/// <summary>
4+
///
5+
/// </summary>
6+
public class Blob : IPostData
7+
{
8+
/// <summary>
9+
/// The object represents a Blob
10+
/// </summary>
11+
public string Type { get; } = "blob";
12+
13+
/// <summary>
14+
/// The UUID of the Blob being uploaded
15+
/// </summary>
16+
public string BlobUUID { get; set; }
17+
}
18+
}

ElectronNET.API/Entities/BrowserViewConstructorOptions.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,17 @@ public class BrowserViewConstructorOptions
99
/// See BrowserWindow.
1010
/// </summary>
1111
public WebPreferences WebPreferences { get; set; }
12+
13+
/// <summary>
14+
/// A proxy to set on creation in the format host:port.
15+
/// The proxy can be alternatively set using the BrowserView.WebContents.SetProxyAsync function.
16+
/// </summary>
17+
public string Proxy { get; set; }
18+
19+
/// <summary>
20+
/// The credentials of the Proxy in the format username:password.
21+
/// These will only be used if the Proxy field is also set.
22+
/// </summary>
23+
public string ProxyCredentials { get; set; }
1224
}
1325
}

ElectronNET.API/Entities/BrowserWindowOptions.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,5 +258,17 @@ public class BrowserWindowOptions
258258
/// Settings of web page's features.
259259
/// </summary>
260260
public WebPreferences WebPreferences { get; set; }
261+
262+
/// <summary>
263+
/// A proxy to set on creation in the format host:port.
264+
/// The proxy can be alternatively set using the BrowserWindow.WebContents.SetProxyAsync function.
265+
/// </summary>
266+
public string Proxy { get; set; }
267+
268+
/// <summary>
269+
/// The credentials of the Proxy in the format username:password.
270+
/// These will only be used if the Proxy field is also set.
271+
/// </summary>
272+
public string ProxyCredentials { get; set; }
261273
}
262274
}

ElectronNET.API/Entities/IPostData.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
namespace ElectronNET.API.Entities
2+
{
3+
/// <summary>
4+
/// Interface to use Electrons PostData Object
5+
/// </summary>
6+
public interface IPostData
7+
{
8+
/// <summary>
9+
/// One of the following:
10+
/// rawData - <see cref="UploadRawData"/> The data is available as a Buffer, in the rawData field.
11+
/// file - <see cref="UploadFile"/> The object represents a file. The filePath, offset, length and modificationTime fields will be used to describe the file.
12+
/// blob - <see cref="Blob"/> The object represents a Blob. The blobUUID field will be used to describe the Blob.
13+
/// </summary>
14+
public string Type { get; }
15+
}
16+
}

ElectronNET.API/Entities/LoadURLOptions.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,11 @@ public class LoadURLOptions
2626
/// Extra headers for the request.
2727
/// </summary>
2828
public string ExtraHeaders { get; set; }
29+
30+
/// <summary>
31+
/// PostData Object for the request.
32+
/// Can be <see cref="UploadRawData"/>, <see cref="UploadFile"/> or <see cref="Blob"/>
33+
/// </summary>
34+
public IPostData[] PostData { get; set; }
2935
}
3036
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
namespace ElectronNET.API.Entities
2+
{
3+
/// <summary>
4+
///
5+
/// </summary>
6+
public class UploadFile : IPostData
7+
{
8+
/// <summary>
9+
/// The object represents a file.
10+
/// </summary>
11+
public string Type { get; } = "file";
12+
13+
/// <summary>
14+
/// The path of the file being uploaded.
15+
/// </summary>
16+
public string FilePath { get; set; }
17+
18+
/// <summary>
19+
/// The offset from the beginning of the file being uploaded, in bytes. Defaults to 0.
20+
/// </summary>
21+
public long Offset { get; set; } = 0;
22+
23+
/// <summary>
24+
/// The length of the file being uploaded, <see cref="Offset"/>. Defaults to 0.
25+
/// If set to -1, the whole file will be uploaded.
26+
/// </summary>
27+
public long Length { get; set; } = 0;
28+
29+
/// <summary>
30+
/// The modification time of the file represented by a double, which is the number of seconds since the UNIX Epoch (Jan 1, 1970)
31+
/// </summary>
32+
public double ModificationTime { get; set; }
33+
}
34+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
namespace ElectronNET.API.Entities
2+
{
3+
/// <summary>
4+
///
5+
/// </summary>
6+
public class UploadRawData : IPostData
7+
{
8+
/// <summary>
9+
/// The data is available as a Buffer, in the rawData field.
10+
/// </summary>
11+
public string Type { get; } = "rawData";
12+
13+
/// <summary>
14+
/// The raw bytes of the post data in a Buffer.
15+
/// </summary>
16+
public byte[] Bytes { get; set; }
17+
}
18+
}

ElectronNET.API/Entities/Vibrancy.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using Newtonsoft.Json;
1+
using System.Runtime.Serialization;
22

33
namespace ElectronNET.API.Entities
44
{
@@ -10,7 +10,7 @@ public enum Vibrancy
1010
/// <summary>
1111
/// The appearance based
1212
/// </summary>
13-
[JsonProperty("appearance-based")]
13+
[EnumMember(Value = "appearance-based")]
1414
appearanceBased,
1515

1616
/// <summary>
@@ -51,13 +51,13 @@ public enum Vibrancy
5151
/// <summary>
5252
/// The medium light
5353
/// </summary>
54-
[JsonProperty("medium-light")]
54+
[EnumMember(Value = "medium-light")]
5555
mediumLight,
5656

5757
/// <summary>
5858
/// The ultra dark
5959
/// </summary>
60-
[JsonProperty("ultra-dark")]
60+
[EnumMember(Value = "ultra-dark")]
6161
ultraDark
6262
}
6363
}

ElectronNET.API/IpcMain.cs

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,45 @@ public void Send(BrowserWindow browserWindow, string channel, params object[] da
179179
}
180180
}
181181

182+
/// <summary>
183+
/// Send a message to the BrowserView renderer process asynchronously via channel, you can also send
184+
/// arbitrary arguments. Arguments will be serialized in JSON internally and hence
185+
/// no functions or prototype chain will be included. The renderer process handles it by
186+
/// listening for channel with ipcRenderer module.
187+
/// </summary>
188+
/// <param name="browserView">BrowserView with channel.</param>
189+
/// <param name="channel">Channelname.</param>
190+
/// <param name="data">Arguments data.</param>
191+
public void Send(BrowserView browserView, string channel, params object[] data)
192+
{
193+
List<JObject> jobjects = new List<JObject>();
194+
List<JArray> jarrays = new List<JArray>();
195+
List<object> objects = new List<object>();
196+
197+
foreach (var parameterObject in data)
198+
{
199+
if(parameterObject.GetType().IsArray || parameterObject.GetType().IsGenericType && parameterObject is IEnumerable)
200+
{
201+
jarrays.Add(JArray.FromObject(parameterObject, _jsonSerializer));
202+
} else if(parameterObject.GetType().IsClass && !parameterObject.GetType().IsPrimitive && !(parameterObject is string))
203+
{
204+
jobjects.Add(JObject.FromObject(parameterObject, _jsonSerializer));
205+
} else if(parameterObject.GetType().IsPrimitive || (parameterObject is string))
206+
{
207+
objects.Add(parameterObject);
208+
}
209+
}
210+
211+
if(jobjects.Count > 0 || jarrays.Count > 0)
212+
{
213+
BridgeConnector.Socket.Emit("sendToIpcRendererBrowserView", browserView.Id, channel, jarrays.ToArray(), jobjects.ToArray(), objects.ToArray());
214+
}
215+
else
216+
{
217+
BridgeConnector.Socket.Emit("sendToIpcRendererBrowserView", browserView.Id, channel, data);
218+
}
219+
}
220+
182221
private JsonSerializer _jsonSerializer = new JsonSerializer()
183222
{
184223
ContractResolver = new CamelCasePropertyNamesContractResolver(),

0 commit comments

Comments
 (0)