Stability-AI / StableSwarmUI

StableSwarmUI, A Modular Stable Diffusion Web-User-Interface, with an emphasis on making powertools easily accessible, high performance, and extensibility.
MIT License
4.12k stars 333 forks source link

solve TODO in NetworkBackendUtils.cs #413

Closed neverbiasu closed 2 weeks ago

neverbiasu commented 2 weeks ago

the syntax is right, and I try to optimize it. before:

if (typeof(JType) == typeof(JObject)) // TODO: Surely C# has syntax for this?
{
    return JObject.Parse(content) as JType;
}
...

after:

switch (typeof(JType))
{
     case Type t when t == typeof(JObject):
         return JObject.Parse(content) as JType;
     ...
}
mcmonkey4eva commented 2 weeks ago

Still not ideal (overrepetition of type) but that's improved, thank you

mcmonkey4eva commented 2 weeks ago

once i had the file open in Visual Studio it autosuggested https://github.com/Stability-AI/StableSwarmUI/commit/6071f8f685dfdde8a8cab1ae5feb06e5865d70fc to me

neverbiasu commented 2 weeks ago

once i had the file open in Visual Studio it autosuggested 6071f8f to me

I thought the suggestion is better, more clear.