using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"\s(\w*)Command\.Register\((([\S]*,([^;\n\r])*)+)typeof\((.*)Values\)\);";
string substitution = @"GridObjectModel.Register$1Reference$2($3, $4TypeIdString);";
string input = @"public static readonly SimpleCommand ReadTemperatureCommand =
SimpleCommand.Register(ReadTemperatureCommandId, ""ReadTemperature"", ""showtemp.py"", "", 5, typeof(TemperatureListCommandResultProcessor), typeof(TemperatureListDeviceValues));
public static readonly SimpleCommand GetDataType1Command =
SimpleCommand.Register(
GetDataType1CommandTypeId,
""GetData"",
""HttpClient2.py"",
@""""/data/ajax.txt?CAN=1&HASH=00200403&TYPE=1"" ""GET"" """""",
5,
typeof(SunwaysSolarInverterDataType1CommandResultProcessor),
typeof(SunwaysSolarInverterDeviceValues));
public static readonly ArgumentedCommand UpdateAsyncCommandsCommand =
ArgumentedCommand.Register(
UpdateAsyncCommandsCommandId,
""UpdateAsyncCommands"",
""UpdateAsyncCommands.py"",
"",
5,
UpdateAsyncCommandsCreateArguments,
new[] { typeof(AsynchronousCommand[]) },
typeof(UpdateAsyncCommandsCommandResultProcessor),
typeof(GridboxCommunicationObjectValues));
public static readonly SimpleDynamicObjectAttribute<bool> AsynchronousCommandsChangedProperty =
SimpleDynamicObjectAttribute<bool>.Register(""AsynchronousCommandsChanged"", false, typeof(BusyGridObjectValues), false, false);
public static readonly SimpleDynamicObjectAttribute<string> MailProperty =
SimpleDynamicObjectAttribute<string>.Register(""Mail"", typeof(DefaultUserValues));
public static readonly ProtectedSimpleDynamicObjectAttribute<int> PasswordStorageMethodVersionProperty =
ProtectedSimpleDynamicObjectAttribute<int>.Register(""PasswordStorageMethodVersion"", 2, typeof(DefaultUserValues));
public static readonly ListSetDynamicObjectAttribute<string> LocalIpNetworksProperty =
ListSetDynamicObjectAttribute<string>.Register(""LocalIpNetworks"", typeof(GridboxCommunicationObjectValues));
public static readonly DictionaryDynamicObjectAttribute<Guid, GridObjectTypeContentFilter> ContentFiltersProperty =
DictionaryDynamicObjectAttribute<Guid, GridObjectTypeContentFilter>.Register(""ContentFilters"", typeof(DefaultContentFilterValues));
public static readonly StrongGridObjectReference ContentFilterListContentFilterIdProperty =
StrongGridObjectReference.Register(""ContentFilterListContentFilterId"", new Guid(""ce06d088-1b5e-4cab-98d2-b0fd63bc0d5b""), typeof(ContentFilterValues));
public static readonly GridObjectReference ContentFilterListContentFilterIdProperty =
GridObjectReference.Register(""ContentFilterListContentFilterId"", new Guid(""ce06d088-1b5e-4cab-98d2-b0fd63bc0d5b""), typeof(ContentFilterValues));
public static readonly GridObjectReference ContentFilterListContentFilterIdProperty =
GridObjectReference.Register(""ContentFilterListContentFilterId"", new Guid(""ce06d088-1b5e-4cab-98d2-b0fd63bc0d5b""), typeof(ContentFilterValues));
public static readonly GridObjectReferenceList PermissionIdsProperty =
GridObjectReferenceList.Register(""PermissionIds"", typeof(DefaultRoleValues));";
Regex regex = new Regex(pattern);
string result = regex.Replace(input, substitution);
}
}
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for C#, please visit: https://msdn.microsoft.com/en-us/library/system.text.regularexpressions.regex(v=vs.110).aspx