icarus-consulting / yaapii.atoms Goto Github PK
View Code? Open in Web Editor NEWObject-Oriented .Net primitives. A port of cactoos library by Yegor Bugayenko, author of the "Elegant Objects" books.
License: MIT License
Object-Oriented .Net primitives. A port of cactoos library by Yegor Bugayenko, author of the "Elegant Objects" books.
License: MIT License
We need a contains Enumerable.
It should implement IScalar and be able to test if a given item is in the list.
It should also work by applying a function to test an item.
Accuracy of the number as double is the same like the accuracy of the number as string
An test is existing.
DoubleOf() rounds the value
No Test exists
DoubleOf(Math.Pi.ToString()) == Math.Pi;
With linq select it is posible to get the Index and value of current element in List.
It would be nice to have in Mapped-Class.
Getting index and value of Mapped not posible!?
lst.Select((tValue, tIndex)=> new { Value=tValue, Index=tIndex});
We need a ctor accepting params in class joined. I'll add it.
A Atoms class is needed to replace Linq 'Any' method.
No Atoms class exists, using Linq instead.
add new ctor for contains, which takes a function and a bool (Contains for all => Default:false)
We need a class NotNull : ICallable. It must not accept when null is the output and raise an exception.
The exception message must be possible to inject into ctor.
The exception itself must be possible to inject into ctor.
Interfaces whose purpose is to wrap C# classes Func and Action are named IFunc and IAction.
Methods are called Invoke.
IFunc is called ICallable and IAction is called IProc. Methods are callled Call() and Run().
We have a class which accepts a IEnumerable and can execute a function for each element.
Origin: @ICACLE wanted to do: collection.ToList().ForEach(). We need a convenient and intuitive way to do it in OOP world.
Lets discuss fist, how it should be called or if an existing class can be extended to accomplish it.
When discussion is finished, remove the question label.
We need a Scalar "CharOf" which accepts multiple other types and returns a Char as value.
We need a generic fork which represents a switch case construct
I'll do it
I fix em.
FailWhen ctor should accept bool.
I'll implement it.
all yaapii classes have a MIT-license as header
not all yaapii classes have a MIT-license as header
And has a ctor accepting Action<> (C# Lambda) and IEnumerable<>. It is for executing the Action for all elements in the IEnumerable<>, its input is an element from the list.
We need a new class replacing Foreach() of LinQ
Action ctors has to be deleated out of And
class
Ctor is not there :(
No Class exists, but some ctors exist in and
And like in the examples does not need generic parameter.
Expected two classes: One which needs no generic and another that needs generic parameter.
And needs generic parameter in every ctor.
We can make a Joined and inject a source and params T[] to be joined.
I can make a Text of a double
No possiblity to call 'new TextOf(Math.Pi)'
To convert a double to a String it should be used '.ToString("G17")'. Not losing accuracy.
A enconding problem exists in test: public void WritesContentToFile()
ItemNeighbourEnumerator does not notice when requested neighbour position is out of range in negative direction.
A Atoms class is needed to replace Linq 'Any' and 'All' method.
No Atoms class exists, using Linq instead.
Perhaps And class can be extended to offer the requested behaviour.
see #40
see #36
we need a NotNull Scalar.
It should throw an ArgumentNullException, if asked for a value and its value is null.
It should accept a custom string as message to put in the Exception.
Development IDE shows XMLDOC when using the library.
No Docs are shown.
instanciate a class: new FormattedText( and navigate through constructors. Nothing there.
<DocumentationFile>bin\Release\net45\blabla.xml</DocumentationFile>
This should be included in the csproj file. Also, Xml Doc creation must be activated for the project.
Read file content from where the path to the file is provided with a Uri.
Reading file content fails if the Uri contains whitespaces in path
[Fact]
public void ReadsSimpleFileContentWithWhitespacesInUri()
{
var dir = "artifacts/Input StreamOf Test"; var file = "txt-1"; var path = Path.GetFullPath(Path.Combine(dir, file));
Directory.CreateDirectory(dir);
if (File.Exists(path)) File.Delete(path);
String content = "Hello, товарищ!";
File.WriteAllBytes(path, new BytesOf(new TextOf(content, Encoding.UTF8)).AsBytes());
Assert.True(
new TextOf(
new InputAsBytes(
new InputOf(
new InputStreamOf(
new Uri(path))))
).AsString() == content,
"Can't read file content");
}
Message: System.IO.DirectoryNotFoundException : Could not find a part of the path 'D:\Daten\GITHUB\Yaapii.Atoms\tests\Yaapii.Atoms.Tests\bin\Debug\netcoreapp1.1\artifacts\Input%20StreamOf%20Test\txt-1'.
The comment on the example does not reflect the correct result.
We need a callable that accepts a fallback function and value.
The function can be invoked to retrieve a fallback value.
The value can also be injected directly.
This works:
var list = new ArrayList(); //IEnumerable, NOT IEnumerable<T>!
new LengthOf(list).Value()
I have to do:
new LengthOf<string>(new List<string());
Generic Parameter is a must.
There are more classes in which sometimes it is not necessary to give a generic parameter.
For example, And. There is an And ctor which accepts Actions. Actions do not need a generic parameter. So And should be split into more classes. There are some more classes like this.
These should be split up, for example.
We have a Scalar which delivers a fallback value if fails.
We need a consistent argument order in constructors of objects.
Example:
Filtered accepts a list and a filter function. Sometimes the function is the first argument, sometimes the last. This has to change.
Since all arguments using params keyword need to appear last, I think all lists have to go last and functions have to go first.
We need a new ctor here which accepts System.Action as input.
I can force a reload by method or can give a reload condition (function) to Ctor
No reload posibility
I think reload condition is more OOP, right?
JObject.Parse(new TextOf(new InputOf(new Uri("file:///<attached_file>"))).AsString()); //does not work.
JObject.Parse(File.ReadAllText("<attached_file>")); //does work.
Dispose will close stream, independent of used ctor.
I think, the stream will not be closed by dispose methode, when getting stream by function...
Edit:
I wrote a test for it:
The Dispose-Methode will not only not close the given Stream, it produces a exception, because it will create another strem on a blocked item.
Atoms are NetStandard. They reference NetStandard Nuget package System.Threading.Thread.
This package can't be loaded by Net461 projects. It should be removed/replaced.
We need a scalar that accepts a fallback function and value.
The function can be invoked to retrieve a fallback value.
The value can also be injected directly.
We need classes for getting the Previous() or the Next() Item in an enumerable.
They could be a Scalar and accept a Collection and an Item.
They need to serve a fallback if no item is present.
Since Runnable is now called IAction, RunnableOf must be called ActionOf.
A class wich takes two strings and a bool (optional): inputValue, containingValue, ignoreCase
Returns true if 'inputValue' contains 'containingValue'.
Ignore case switch.
Does not exist
Replaces CLEs Extension method:
public static bool Contains(this string value, StringComparison strComparison)
ItemAt accepts a BiFunc fallback function, where the occured Exception is the first function parameter.
ItemAt accepts only a IFunc<IEnumerable<T>,T>
ItemAt throws NoSuchElementException, this is not true for every case.
For example, if the inserted IEnumerable and its IEnumerator does not support Reset(), there is a NoSuchElementException. This is not correct.
The fallback function in ItemAt<T>
and in ItemAtEnumerator
should be a BiFunc<Exception, IEnumerable<T>, T>
We need a constructor on And.
I want to do the following:
string s = "AB"
new And(
s,
str => str.Contains("A"),
str => str.Contains("B"),
str => str.Contains("C")).Value() //should be false
Or a solution with a different object
OutputTo cannot append to existing data. We need a solution for appending.
Appending mechanism must be available through all ctors that can point to existing data, like OutputTo(string path).
ICARUS is the author
Miro Tunk is the Author
We need a function that can be bound to a thread.
The thread should be injected.
Also, it has to be possible to inject just the thread id.
We can inject a specific Exception into a ctor of a fail so that it gets thrown.
We cannot inject specific Exceptions into ctor
ItemAt throws a specific Exception
it throws a NullReferenceException
new ItemAt<string>(
new List<string>()
).Value();
Ternary delivers third argument if condition is false
Ternary tries to deliver from second argument
var stack = new Stack<string>();
var eql = new Ternary<bool, bool>(
stack.Count > 0,
new ItemAt<string>(
new List<string>(stack)
).Value() == cmd,
false
).Value();
We can remove IoChecked and IoUnchecked classes.
These classes have been ported, but are irrelevant in .Net: In java, exception throwing has two faces: Checked or Unchecked. In .Net, this is not true.
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.