unosquare / swan Goto Github PK
View Code? Open in Web Editor NEWSwan stands for Stuff We All Need. Unosquare's collection of C# extension methods and classes.
Home Page: https://unosquare.github.io/swan
License: MIT License
Swan stands for Stuff We All Need. Unosquare's collection of C# extension methods and classes.
Home Page: https://unosquare.github.io/swan
License: MIT License
Add a Model Validator component, allowing to include validation by expression or attributes.
Hi,
I've read the doc but i don't know how to catch exception from SmtpClient.SendMailAsync() ?
Sometimes, error happen (unknown recipient, server unreachable...) and i want to log them.
Thanks for your help.
Fix network issues with Unit Test Travis
Add all the contents available in the wiki to the doc website
Class A is defined as:
public class A {}
Serializing to JSON returns a string
"Namespace.A"
But it should really return
{}
Deserializing fails miserably too
Self explanatory title
This is the code being used (From RaspberryIO Playground):
` public bool SetupWirelessNetwork(string adapterName, string networkSsid, string password = null)
{
var payload = "ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev\nupdate_config=1\n";
payload += string.IsNullOrEmpty(password) ?
$"network={{\n\tssid=\"{networkSsid}\"\n\t}}\n" :
$"network={{\n\tssid=\"{networkSsid}\"\n\tpsk=\"{password}\"\n\t}}\n";
try
{
File.WriteAllText("/etc/wpa_supplicant/wpa_supplicant.conf", payload);
ProcessRunner.GetProcessOutputAsync("ifconfig >> /home/pi/ifconfig.txt");
//ProcessRunner.GetProcessOutputAsync("sudo pkill -f wpa_supplicant >> /home/pi/Documents/kill_wpa.txt");
//ProcessRunner.GetProcessOutputAsync("sudo wpa_supplicant", $"-B -D wext -i {adapterName} -c /etc/wpa_supplicant/wpa_supplicant.conf >> /home/pi/Documents/run_wpa.txt");
}
catch
{
return false;
}
return true;
}`
After a while testing on raspberry, realized the "ProcessRunner.GetProcessOutputAsync" does nothing at all. Used the line "ProcessRunner.GetProcessOutputAsync("ifconfig >> /home/pi/ifconfig.txt");" to be sure and it did not created any file, but command worked on command line.
Am I using this the wrong way?
TinyIoC renamed to Unosquare.Swan.Injector
Title self-descriptive
Similar to CommandLineParser...
Provide StandardOutput and StandardError output Textwriters to Terminal
Remove the Source from the Message when call the OnLogMessageReceived event.
Similar to AutoMapper, but lightweight.
Please include JsonPropertyAttribute example.
Add LDAPClient section at README file.
Document ProcessRunner
Use tags for XML documentation
Implement CSProjectHelper as new dotnet-sshdeploy
Migrate the following classes to the solution:
Should be based off https://github.com/gsscoder/commandline
If the logic has a task writing to the Terminal but the main thread is waiting for ReadKey, the messages are not shown:
Task.Factory.StartNew(async () =>
{
while (true)
{
await Task.Delay(TimeSpan.FromSeconds(1));
"OK".Info();
}
});
"Press any key".Info();
Terminal.ReadKey(true);
``
If possible, add an SNMP client
Please check unit test DeserializeObjectWithArrayWithDataTest for code sample where the error is located.
Include a MessageHub
section at README file. Check the Wiki for more information.
Document ArgumentParser component Verb options
Now the data is decoded using the default coding (for me ANSI). Please add the option to choose another type of encoding. Specifically, it would be great utf-8. (I encountered this when processing the output from ffprobe, which is in utf-8.)
So far, it can be handled by RunProcessAsync. The data can be read as follows:
Encoding.GetEncoding("utf-8").GetString(data).WriteLine();
Similar to:
var flags = Enum.GetValues(typeof(Status)) .Cast<int>() .Where(f=> f & o == f) .ToList();
ManualResetEventSlim causes spinwaits (high CPU usage)
Terminal.cs - Lines 21 and 22 need to be changed to:
private static readonly ManualResetEvent OutputDone = new ManualResetEvent(false);
private static readonly ManualResetEvent InputDone = new ManualResetEvent(true);
Change DequeueOutputTask to a background (NOT THREADPOOL PLEASE) Thread with BelowNormalPriority. Here are all the changes:
// Change declaration
private static readonly Thread DequeueOutputTask;
// Here we start the output task, fire-and-forget
DequeueOutputTask = new Thread(DequeueOutputAsync)
{
IsBackground = true,
Name = nameof(DequeueOutputTask),
Priority = ThreadPriority.BelowNormal
};
// Change signature:
private static void DequeueOutputAsync()
// wrap the outer loop of DequeueOutputAsync with:
using (var tickLock = new ManualResetEvent(false))
{
// Change await Task.Delay(1) to
tickLock.WaitOne(1);
...
I need this fixed to continue one of my projects.
And you need this fixed to continue the AccessCore project as well
Cannot deploy ASP.NET Core project with SSHDeploy which depends on SWAN.
Unhandled Exception: System.ArgumentException: Project file is not of the new .csproj type.
at Unosquare.Swan.Components.CsProjFile`1..ctor(Stream stream, Boolean leaveOpen)
at Unosquare.Labs.SshDeploy.Program.Main(String[] args)
It is because the CsProjFile
class checks for Sdk="Microsoft.NET.Sdk"
, and assumes that it is what makes it the new .csproj-format, but there is also Microsoft.NET.Sdk.Web
for web projects.
Is that really the only way to check if it is the new csproj-format?
Allow the solution to build SWAN Lite (no networking) to reduce overhead of DLL when you don't require the network related classes.
Hi,
we use Embed IO in one of our apps, which uses SWAN. Wenn we try to publish the app to the Windows Store, we get the error "API CopyMemory in kernel32.dll is not supported for this application type. Unosquare.Swan.dll calls this API."
We checked the code for Embed IO and did not found any reference to CircularBuffer() which causes the problem in SWAN:
[DllImport("kernel32")]
public static extern void CopyMemory(IntPtr destination, IntPtr source, uint length);
As a workaround for us we code remove the CircularBuffer Class from SWAN and resubmit but this is not a long term solution.
Could you implement a managed alternative and not using the unmanaged Windows API anymore?
Thanks and regards
Guido
Add Unosquare Smtp Client (MailerIO Client)
I'm trying to process the output data from ffprobe
. I have a problem processing with RunProcessAsync
. The output is duplicated and garbled. Can you look at it, please?
Here is my code:
private async Task RunTest()
{
string output = "";
string output2 = "";
var result = await ProcessRunner.RunProcessAsync(
@"C:\Users\Test\Documents\ff\ffprobe.exe",
"-v quiet -print_format xml -show_format \"b.mp4\"",
// A success callback with a reference to the output and the process itself
(data, proc) =>
{
output = Encoding.GetEncoding("utf-8").GetString(data);
output2 += output;
Console.WriteLine("Success callback. Length: " + output.Length);
},
// An error callback with a reference to the error and the process itself
(data, proc) =>
{
}
);
Console.WriteLine("Complete length:" + output2.Length);
Console.WriteLine(output2);
}
The console output is:
Success callback. Length: 517
Success callback. Length: 2048
Complete length:2565
<?xml version="1.0" encoding="UTF-8"?>
<ffprobe>
<format filename="b.mp4" nb_streams="4" nb_programs="0" format_name="mov,mp4,m4a,3gp,3g2,mj2" format_long_name="QuickTime / MOV" start_time="0.000000" duration="60.095000" size="5510872" bit_rate="733621" probe_score="100">
<tag key="major_brand" value="mp42"/>
<tag key="minor_version" value="1"/>
<tag key="compatible_brands" value="mp42avc1"/>
<tag key="creation_time" value="2010-02-09T01:55:39.000000Z"/>
</format>
</ffprobe>
n="1.0" encoding="UTF-8"?>
<ffprobe>
<format filename="b.mp4" nb_streams="4" nb_programs="0" format_name="mov,mp4,m4a,3gp,3g2,mj2" format_long_name="QuickTime / MOV" start_time="0.000000" duration="60.095000" size="5510872" bit_rate="733621" probe_score="100">
<tag key="major_brand" value="mp42"/>
<tag key="minor_version" value="1"/>
<tag key="compatible_brands" value="mp42avc1"/>
<tag key="creation_time" value="2010-02-09T01:55:39.000000Z"/>
</format>
???????????????????????????????????????????????????????????????????????????????????????????????
Here is sample video: b.zip
Similar to GetFlagsValues but returns a List with the string names from an enum value.
Verify that System.Console and System.Collections.Nongeneric are indeed needed
Current documentation is not enough.
If possible, support pure LDAP/LDAPs connectors
Add true/false serialization
Add parser
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.