Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
G

Gabriel Szabo

@Gabriel Szabo
About
Posts
9
Topics
1
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Crosslinked post in LINQ discussion
    G Gabriel Szabo

    The date filter works as you wrote, I didn't notice this. By cross-linked I mean that I see an apparently unrelated reply for the "Data check in query" post, named "Re: Include nested object's property?". When I display the thread for that reply, it shows the correct thread. This is what I see:

    "Question Data check" in query vkEE 18-Nov-13 21:27
    "Re: Data check in query" ahmed zahmed 18-Nov-13 23:14
    "Re: include nested object's property?" ewohlman 4-Sep-13 15:39
    "Re: include nested object's property? [modified]" Gabriel Szabo 29-Nov-13 11:58

    Gabriel Szabo

    Site Bugs / Suggestions csharp database linq com question

  • Crosslinked post in LINQ discussion
    G Gabriel Szabo

    There is something wrong with the LINQ discussion forum. When I click Disussions / General programming / LINQ, I see a crosslinked post in the discussion named "Data check in query". Also the list of discussions seems to be incomplete and quite short. With following link I can see much more discussions: http://www.codeproject.com/Messages/4711722/Re-include-nested-objects-property.aspx[^] Can you confirm this, or is it just my browsing settings? I use IE10 and Firefox 18.0, with same results

    Gabriel Szabo

    Site Bugs / Suggestions csharp database linq com question

  • include nested object's property?
    G Gabriel Szabo

    Wow! This is the proof that time travel is actually possible ;). Now seriously, the above post is crosslinked into the LINQ discussion named "data check in query". Check here: http://www.codeproject.com/Forums/1004117/LINQ.aspx[^]

    Gabriel Szabo

    LINQ question csharp linq collaboration performance

  • Parsing a string with match groups
    G Gabriel Szabo

    You can use the alternation syntax "(a|b)". A match in your case is an expression in form "parameter=value", or an operator. Operator can be "or" or "and" and must have a space before and after. Following pattern produces the results you wanted. For an input string "Name=John or Name=Jane and Date=Now" you get matches "Name=John", " or ", "Name=Jane", " and ", "Date=Now":

    "(\w+=\w+|\s(or|and)\s)"

    If you want to use regex for validation only, you can do it this way (note that you get only a single match with this pattern):

    Regex.IsMatch(inputStr, "^(\w+=\w+|\s(or|and)\s)+$");

    And you can go even further with validation. Following pattern uses positive look ahead/behind syntax to ensure that operators are enclosed with valid expressions:

    Regex.IsMatch(inputStr, "^(\w+=\w+|(?<=\w+=\w+)\s(or|and)\s(?=\w+=\w+))+$");

    Gabriel Szabo

    Regular Expressions regex database json help tutorial

  • WPF View Data Template Questions
    G Gabriel Szabo

    The template selector can be made more general. Data templates and material type could be e.g. injected from the hosting xaml. So you don't really need write that many selectors ;). I see the selector and your loader template approach philosophically equivalent. However there is a difference from the testing point of view. A unit test for selector is pretty straightforward. But how would you test the data triggers in loader template?

    Gabriel Szabo

    WPF question csharp wpf help learning

  • WPF View Data Template Questions
    G Gabriel Szabo

    You can write custom DataTemplateSelector and then use it in e.g. ContentControl as a ContentTemplateSelector. For example the following selector looks for desired datatemplate in control's resources by MaterialType:

    public class MaterialDataTemplateSelector : DataTemplateSelector
    {
    public override DataTemplate SelectTemplate(object item, DependencyObject container)
    {
    FrameworkElement element = container as FrameworkElement;
    MaterialsViewModel materials = item as MaterialsViewModel;

        string resKey = "materialsTemplateFor" + Enum.GetName(typeof(MaterialType), materials.MaterialType);
        return element.FindResource(resKey) as DataTemplate;
    }
    

    }

    Here are the resources you need in your MaterialsView control:

    And this is how you use it in your control:

    Hope it helps.

    Gabriel Szabo

    WPF question csharp wpf help learning

  • Sorted Collection in C#
    G Gabriel Szabo

    You could use the OrderBy<TSource, TKey>(Func<TSource, TKey>) extension method. The actual sorting is deffered until result gets enumerated, so the call to OrderBy() itself is fast. It performs a stable sort, which means that the order of already sorted elements is preserved. it does not sort the original sequence in-place. Instead, the returned IEnumerable returns elements of the original sequence in sorted order. And you can speed things up a bit with parallel LINQ like:

    var result = sourceSequence.AsParallel().OrderBy(item => item.Key);

    Gabriel Szabo

    C# csharp algorithms data-structures

  • Girls Have it Easier
    G Gabriel Szabo

    Ha! Everyone know you would need eagle semen and lion eggs.

    Gabriel Szabo

    The Soapbox learning

  • DLL
    G Gabriel Szabo

    well, if cracked means modified - making an assembly strong-named provides a guarantee that the assembly have not been changed since it was built.

    Gabriel Szabo

    .NET (Core and Framework) csharp asp-net
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups