DynamicSugarStandard 1.0.8

There is a newer version of this package available.
See the version list below for details.
dotnet add package DynamicSugarStandard --version 1.0.8                
NuGet\Install-Package DynamicSugarStandard -Version 1.0.8                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="DynamicSugarStandard" Version="1.0.8" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add DynamicSugarStandard --version 1.0.8                
#r "nuget: DynamicSugarStandard, 1.0.8"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install DynamicSugarStandard as a Cake Addin
#addin nuget:?package=DynamicSugarStandard&version=1.0.8

// Install DynamicSugarStandard as a Cake Tool
#tool nuget:?package=DynamicSugarStandard&version=1.0.8                

DynamicSugar.net /Standard

What is DynamicSugar.Net?

  • In 2011 I created the DynamicSugar.net Library which provides methods and classes inspired by the dynamic languages Python and JavaScript to write shorter and more readable source code in C# 4.0.

  • From 2011 to 2020, the C# language evolved and some features in DynamicSugar became obsolete, like the DynamicSugar string interpolation feature. But most of the features are still useful and I want to use them in my .NET 4.6.1 and .NET Core development in 2023.

  • In 2023 I moved the library to .NET Standard 2.0, so it can be used with .NET 4.6.1 and .NET Core.

Logo

Examples:

List


var intList   = DS.List(1,2,3);
var intString = DS.List("a","b");
var l1        = DS.Range(10);

var b = l1.Include(5);
var l2 = l1.Without(0, 2, 4, 6, 8);
var l3 = l1.Without(DS.List(0, 2, 4, 6, 8));
var b = l1.IsEmpty();
Console.WriteLine(l2.Format()); // => 1, 3, 5, 7, 9
Console.WriteLine(l3.Format()); // => 1, 3, 5, 7, 9

var l = DS.List(1,2,3,4).Map( e => e*e );

int i = 1;
if(i.In(1,2,3)) {
  // ...
}

var l = DS.List(1,2,3);
if(i.In(l)) {
  // ...
}

String Processing


var LastName = "TORRES";
var Age      = 45;
var s1 = "LastName:{LastName}, Age:{Age:000}".Template( new { LastName, Age } );

s1 = "LastName:[LastName], Age:[Age]".Template(new { LastName, Age }, "[", "]");

Reflection


var dic = DS.Dictionary(TestDataInstanceManager.TestPersonInstance);
Assert.AreEqual("TORRES", dic["LastName"]);
Assert.AreEqual("Frederic", dic["FirstName"]);
Assert.AreEqual(45, dic["Age"]);
Assert.AreEqual(new DateTime(1964, 12, 11), dic["BirthDay"]);

var dic = DS.Dictionary(TestDataInstanceManager.TestPersonInstance, isPrivate: false);

var lastName = ReflectionHelper.GetProperty(TestDataInstanceManager.TestPersonInstance, "LastName").ToString();

var b = ReflectionHelper.MethodExist(TestDataInstanceManager.TestPersonInstance, "GetLastName");

var privateTitle = ReflectionHelper.GetProperty(TestDataInstanceManager.TestPersonInstance, "PrivateTitle", isPrivate: true);


License:

You may use DynamicSugar.Net under the terms of the MIT License.

NuGet

Install-Package DynamicSugarStandard

Blog Posts:

How to Write a Spelling Corrector? From Python to C# with Dynamic Sugar

Screen Casts:

Platforms:

  • Microsoft Windows and Windows Phone, .NET v 4.x
  • Xamarin iOS and Android

Outdated

  • The extension methods string.Format() and and string.Template() are now out dated, since C# support string interpolation.
  • The class MultiValues was an attempt to create functions returning multiple values, which is now supported by C#.

A lot of the features are still useful see Examples

License:

You may use DynamicSugar.Net under the terms of the MIT License.

NuGet

  • TODO: Create NuGet Package and publish
Install-Package DynamicSugarCore

Platforms:

  • Microsoft Windows and Windows Phone, .NET v 4.x - 2011 - Source
  • Xamarin iOS and Android - 2011
  • Dot Net Standard 2.0 - 2019
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.0

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on DynamicSugarStandard:

Package Downloads
fAI

Fred's experimentation with AI

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.44 81 9/27/2024
1.0.43 86 9/27/2024
1.0.42 88 9/27/2024
1.0.41 84 9/26/2024
1.0.40 84 9/26/2024
1.0.39 82 9/26/2024
1.0.38 106 7/19/2024
1.0.37 107 7/13/2024
1.0.36 87 7/13/2024
1.0.35 96 7/12/2024
1.0.34 85 7/12/2024
1.0.33 101 7/12/2024
1.0.32 103 7/12/2024
1.0.31 118 5/20/2024
1.0.30 125 4/18/2024
1.0.29 119 3/22/2024
1.0.28 127 3/21/2024
1.0.27 121 3/21/2024
1.0.26 124 3/21/2024
1.0.25 223 3/16/2024
1.0.24 147 3/2/2024
1.0.23 283 2/6/2024
1.0.22 119 2/6/2024
1.0.21 94 2/3/2024
1.0.20 104 2/3/2024
1.0.19 114 2/3/2024
1.0.18 113 1/27/2024
1.0.17 172 1/5/2024
1.0.16 127 1/5/2024
1.0.15 119 1/3/2024
1.0.14 108 1/3/2024
1.0.13 134 1/3/2024
1.0.12 158 12/28/2023
1.0.11 136 12/28/2023
1.0.10 323 12/27/2023
1.0.9 144 12/17/2023
1.0.8 133 12/17/2023
1.0.7 127 12/17/2023
1.0.6 208 12/4/2023
1.0.5 138 12/2/2023
1.0.4 207 11/24/2023
1.0.3 137 11/24/2023
1.0.2 316 11/12/2023
1.0.0 245 2/9/2023