Some of the dialogue from this question turned ugly and it was requested that I ask a new question, but because there is an answer, I cannot delete it despite the similarity (pretty lame, Stackoverflow).
Please see this question:
Implementing a content-hashable HashSet in C# (like python's `frozenset`)
You need an ImmutableHashSet<>. Your timing is good, it is available through NuGet in the Microsoft.Collections.Immutable package.
For background, see Preview of Immmutable Collections Released on NuGet. The video Inside Immutable Collections is also available.
Related
I was recently looking through this Question and one of the answers provided uses the v7 Support library Sorted List and SortedList.Callback.
How would this be used with Xamarin.Android, particularly with RecyclerView?
Also, what is the purpose of SortedList.BatchedCallback
Resources:
https://developer.android.com/reference/android/support/v7/util/SortedList.html
https://developer.android.com/reference/android/support/v7/util/SortedList.Callback.html
https://developer.android.com/reference/android/support/v7/util/SortedList.BatchedCallback.html
Sample in Java:
https://github.com/Wrdlbrnft/Searchable-RecyclerView-Demo
Android.Support.V7.UtilSortedList is included in the Xamarin.Android.Support.v7.RecyclerView NuGet package (at least as of v25.3.1), if you can use RecyclerView you can use SortedList.
As the documentation describes in the link you posted, BatchedCallback is intended as a performance optimization to avoid bombarding the RecyclerView with many list operations that can be batched into a single operation.
Here's my question, how does one "hack" the CustomCommand in Enterprise Architect's API to figure out what it's capabilities are? Here's what I'm currently using it for, which seems to be an accepted (by the community) and usable function:
repository.CustomCommand("Repository", "ImportRefData", xml);
I want to see what else I can do with it, namely some exporting of said reference data.
Also, while Sparx cannot officially support this functionality since it's undocumented, what are the odds that this command will stay functional with updated versions of EA, do they have a history of breaking illegal code like this?
Thanks,
Alex
The answer is: you can't. The few commands I documented were from postings on the Sparx forum. Eventually they originated from Sparx support itself. I remember having read from someone who knew about one of the commands asking for more info. But Sparx did not unveil more than was known. I tried to find the strings in the EXE but to no avail.
Since the function is there for quite some years and Sparx is very reluctant to substantial changes in the API it will likely not change. So it's save to use the function in future. IIRC Sparx itself recommended the use in certain cases. But only on the forum...
I tried to google but didn't find a decent tutorial with snippet code.
Does anyone used typed DataSets\DataTable in c# ?
Is it from .net 3.5 and above?
To answer the second parts of the question (not the "how to..." from the title, but the "does anyone..." and "is it...") - the answer would be a yes, but a yes with a pained expression on my face. For new code, I would strongly recommend looking at a class-based model; pick your poison between the many ORMs, micro-ORMs, and raw ADO.NET. DataTable itself does still have a use, in particular for processing and storing unpredictable data (where you have no idea what the schema is in advance). By the time you are talking about typed data-sets, I would suggest you obviously know enough about the type that this no longer applies, and an object-model is a very valid alternative.
It is still a supported part of the framework, and it is still in use as a technology. It has some nice features like the diff-set. However, most (if not all) of that is also available against an object-based design, with classes and properties (without the added overhead of the DataTable abstraction).
MSDN has guidance. It really hasn't changed since typed datasets were first introduced.
http://msdn.microsoft.com/en-us/library/esbykkzb(v=VS.100).aspx
There are tons of videos available here: http://www.learnvisualstudio.net/series/aspdotnet_2_0_data_access_and_databinding/
And I found one more tutorial here: http://www.15seconds.com/issue/031223.htm
Sparingly.... Unless you need to know to maintain legacy software, learn an ORM or two, particularly in conjunction with LINQ.
Some of my colleagues have them, the software I work on doesn't use them at all, on account of some big mouth developer getting his way again...
Is there a (preferably free) .NET library for file compare and that returns enumerable collections off added, changed and deleted lines?
Basically everything beyond compare does but in .NET and returns collections you can interact with.
What you're looking for is a Diff generation library.
I would take a look at DiffPlex.
You'll have to read the files into memory yourself, but it wouldn't be hard to build a wrapper class around DiffPlex so that you can easily use files from that point on...
I've tried looking at DiffPlex, but find that there are a lack of code examples when it comes to Windows forms. I've tried to use the side-by-side but having serious difficulty implementing it. I've even tried contacting author but to no avail. The only sample code example I can find was using the InlineDiffBuilder class from DiffPlex.
It talks about a side-by-side example but only gives you an image. It would be really great if there were more tutorials and examples for this awesome code.
Relating to another question I asked yesterday with regards to logging I was introduced to TraceListeners which I'd never come across before and sorely wish I had. I can't count the amount of times I've written loggers needlessly to do this and nobody had ever pointed this out or asked my why I didn't use the built in tools. This leads me to wonder what other features I've overlooked and written into my applications needlessly because of features of .NET that I'm unaware of.
Does anyone else have features of .NET that would've completely changed the way they wrote applications or components of their applications had they only known that .NET already had a built in means of supporting it?
It would be handy if other developers posted scenarios where they frequently come across components or blocks of code that are completely needless in hindsight had the original developer only known of a built in .NET component - such as the TraceListeners that I previously noted.
This doesn't necessarily include newly added features of 3.5 per se, but could if pertinent to the scenario.
Edit - As per previous comments, I'm not really interested in the "Hidden Features" of the language which I agree have been documented before - I'm looking for often overlooked framework components that through my own (or the original developer's) ignorance have written/rewritten their own components/classes/methods needlessly.
The yield keyword changed the way I wrote code. It is an AMAZING little keyword that has a ton of implications for writing really great code.
Yield creates "differed invoke" with the data that allows you to string together several operations, but only ever traverse the list once. In the following example, with yield, you would only ever create one list, and traverse the data set once.
FindAllData().Filter("keyword").Transform(MyTransform).ToList()
The yield keyword is what the majority of LINQ extensions were built off of that gives you the performance that LINQ has.
Also:
Hidden Features of ASP.NET
Hidden Features of VB.NET?
Hidden Features of F#
The most frequently overlooked feature I came across is the ASP.net Health Monitoring system. A decent overview is here: https://web.archive.org/web/20210305134220/https://aspnet.4guysfromrolla.com/articles/031407-1.aspx
I know I personally recreated it on several apps before I actually saw anything in a book or on the web about it.
I spoke to someone at a conference one time and asked about it. They told me the developer at MS had bad communication skills so it was largely left undocumented :)
I re-wrote the System.Net.WebClient class a while back. I was doing some web scraping and started my own class to wrap HttpWebRequest/HttpWebReponse. Then I discovered WebClient part way through. I finished it anyway because I needed functionality that WebClient does not provide (control of cookies and user agent).
Something I'm thinking about re-writing is the String.Format() method. I want to reflect the code used to parse the input string and mimic it to build my own "CompiledFormat" class that you can use in a loop without having to re-parse your format string with each iteration. The result will allow efficient code like this:
var PhoneFormat = new CompiledFormat("({0}){1}-{2}x{3}");
foreach (PhoneNumber item in MyPhoneList)
{
Console.WriteLine(PhoneFormat.Apply(PhoneNumber.AreaCode, PhoneNumber.Prefix, PhoneNumber.Number, PhoneNumber.Extension));
}
Update:
This prompted me to finally go do it. See the results here: Performance issue: comparing to String.Format