Skip to main content
Commonmark migration
Source Link
"(?<message>.{2})(\\(?<parameter>[^\\]{2,}))*"
 

all messages contain 2 Letter message code and a variable number of parameters, each parameter with a 2 letter identifier and an arbitrary value.

"(?<message>.{2})(\\(?<parameter>[^\\]{2,}))*"
 

all messages contain 2 Letter message code and a variable number of parameters, each parameter with a 2 letter identifier and an arbitrary value.

"(?<message>.{2})(\\(?<parameter>[^\\]{2,}))*"

all messages contain 2 Letter message code and a variable number of parameters, each parameter with a 2 letter identifier and an arbitrary value.

Source Link
t3chb0t
  • 44.3k
  • 9
  • 84
  • 190

Just top down a few things that I noticed... assuming you can use C# 7.

"(?<message>.{2})(\\(?<parameter>[^\\]{2,}))*"

all messages contain 2 Letter message code and a variable number of parameters, each parameter with a 2 letter identifier and an arbitrary value.

By multiple parameters I guess you mean for example: EC\RBHello\RBWorld? Are you sure this wors like that? I'm asking because as far as I know for this to work the the inner group should be repeating but it's not and the outher group is optional so EC is a valid message here. Since you didn't post code parsing this I cannot comment on that. Maybe you use some workarounds for it.


public Message MapTo()

There is something missing because reading this I automatically think MapToWhat?


public void Validate() { }

Not implemented?


// ReSharper disable NonReadonlyMemberInGetHashCode

You can get rid of such comments if you make your properties get only.


public override bool Equals(object obj)
{
    var other = obj as Message;
    if (other == null)
    {
        return false;
    }

    return other.MessageCode == MessageCode;
}

This could just be:

return obj is Message as m && Message == m.MessageCode;

if (GetType() == typeof(MessageProcessor<DummyMessage>))

There should be a helper variable for this. It's not clear what you are checking here especially that a DummyMessage is used.


protected IProcessor FindProcessor(Message message)
{
    if (!_processors.ContainsKey(message))
    {
        return null;
    }
    return _processors[message];
}

It's not necessary to read the dictionary twice. You can use TryGetValue.


public string Name
{
    get { return GetType().Name; }
}

or just

public string Name => GetType().Name;

// The class is instantiated via reflection
// ReSharper disable once ClassNeverInstantiated.Local

Reshaper has an attribute for this. Just decorate the class with the UsedImplicitlyAttribute that:

Indicates that the marked symbol is used implicitly (e.g. via reflection, in external library), so this symbol will not be marked as unused (as well as by other usage inspections).


public static int? ParseInt(this string value)

I find all these methods should be called like ParseIntOrNull so it's clear that they don't fail but return some defaul value similar to linq methods ElementAtOrDefault etc.


public static int? ParseInt(this string value)
{
    int v;
    if (int.TryParse(value, out v))
    {
        return v;
    }
    return null;
}

You can make it a one liner:

return int.TryParse(value, out var x) ? x : (int?)null;

GetSubclassesOfType

This should be called CreateSublassesOfType as this is what it does. It does not search for instances of the subclasses but it creates them.