Skip to content

Commit

Permalink
use c# string alias
Browse files Browse the repository at this point in the history
  • Loading branch information
tibel committed Jun 5, 2014
1 parent 8a35356 commit 55423f3
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 32 deletions.
2 changes: 1 addition & 1 deletion src/Caliburn.Core/Validation/ValidationResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public static ValidationResult Success()
/// <returns></returns>
public static ValidationResult Failure(IFormatProvider provider, string format, params object[] args)
{
var formattedMessage = String.Format(provider, format, args);
var formattedMessage = string.Format(provider, format, args);
return new ValidationResult(false, formattedMessage);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Caliburn.Xaml/RegExHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public static class RegExHelper
/// <returns>Regular expression capture group with the specified group name</returns>
public static string GetCaptureGroup(string groupName, string regEx)
{
return String.Concat(@"(?<", groupName, ">", regEx, ")");
return string.Concat(@"(?<", groupName, ">", regEx, ")");
}

/// <summary>
Expand Down
24 changes: 12 additions & 12 deletions src/Caliburn.Xaml/ViewLocator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,17 @@ static ViewLocator()
/// <param name="config">An instance of TypeMappingConfiguration that provides the settings for configuration</param>
public static void ConfigureTypeMappings(TypeMappingConfiguration config)
{
if (String.IsNullOrEmpty(config.DefaultSubNamespaceForViews))
if (string.IsNullOrEmpty(config.DefaultSubNamespaceForViews))
{
throw new ArgumentException("DefaultSubNamespaceForViews field cannot be blank.");
}

if (String.IsNullOrEmpty(config.DefaultSubNamespaceForViewModels))
if (string.IsNullOrEmpty(config.DefaultSubNamespaceForViewModels))
{
throw new ArgumentException("DefaultSubNamespaceForViewModels field cannot be blank.");
}

if (String.IsNullOrEmpty(config.NameFormat))
if (string.IsNullOrEmpty(config.NameFormat))
{
throw new ArgumentException("NameFormat field cannot be blank.");
}
Expand Down Expand Up @@ -111,7 +111,7 @@ public static void AddDefaultTypeMapping(string viewSuffix = "View")
}

//Check for <Namespace>.<BaseName><ViewSuffix> construct
AddNamespaceMapping(String.Empty, String.Empty, viewSuffix);
AddNamespaceMapping(string.Empty, string.Empty, viewSuffix);

//Check for <Namespace>.ViewModels.<NameSpace>.<BaseName><ViewSuffix> construct
AddSubNamespaceMapping(_defaultSubNsViewModels, _defaultSubNsViews, viewSuffix);
Expand Down Expand Up @@ -195,7 +195,7 @@ public static void AddNamespaceMapping(string nsSource, string[] nsTargets, stri

//Start pattern search from beginning of string ("^")
//unless original string was blank (i.e. special case to indicate "append target to source")
if (!String.IsNullOrEmpty(nsSource))
if (!string.IsNullOrEmpty(nsSource))
{
nsencoded = "^" + nsencoded;
}
Expand Down Expand Up @@ -230,9 +230,9 @@ public static void AddSubNamespaceMapping(string nsSource, string[] nsTargets, s
var nsencoded = RegExHelper.NamespaceToRegEx(nsSource + ".");

string rxbeforetgt, rxaftersrc, rxaftertgt;
var rxbeforesrc = rxbeforetgt = rxaftersrc = rxaftertgt = String.Empty;
var rxbeforesrc = rxbeforetgt = rxaftersrc = rxaftertgt = string.Empty;

if (!String.IsNullOrEmpty(nsSource))
if (!string.IsNullOrEmpty(nsSource))
{
if (!nsSource.StartsWith("*"))
{
Expand All @@ -248,9 +248,9 @@ public static void AddSubNamespaceMapping(string nsSource, string[] nsTargets, s
}

var rxmid = RegExHelper.GetCaptureGroup("subns", nsencoded);
var nsreplace = String.Concat(rxbeforesrc, rxmid, rxaftersrc);
var nsreplace = string.Concat(rxbeforesrc, rxmid, rxaftersrc);

var nsTargetsRegEx = nsTargets.Select(t => String.Concat(rxbeforetgt, t, ".", rxaftertgt)).ToArray();
var nsTargetsRegEx = nsTargets.Select(t => string.Concat(rxbeforetgt, t, ".", rxaftertgt)).ToArray();
AddTypeMapping(nsreplace, null, nsTargetsRegEx, viewSuffix);
}

Expand Down Expand Up @@ -326,16 +326,16 @@ public static void AddSubNamespaceMapping(string nsSource, string nsTarget, stri
}
var contextstr = ContextSeparator + context;
string grpsuffix = String.Empty;
string grpsuffix = string.Empty;
if (_useNameSuffixesInMappings)
{
//Create RegEx for matching any of the synonyms registered
var synonymregex = "(" + String.Join("|", ViewSuffixList.ToArray()) + ")";
var synonymregex = "(" + string.Join("|", ViewSuffixList.ToArray()) + ")";
grpsuffix = RegExHelper.GetCaptureGroup("suffix", synonymregex);
}
const string grpbase = @"\${basename}";
var patternregex = String.Format(_nameFormat, grpbase, grpsuffix) + "$";
var patternregex = string.Format(_nameFormat, grpbase, grpsuffix) + "$";
//Strip out any synonym by just using contents of base capture group with context string
var replaceregex = "${basename}" + contextstr;
Expand Down
36 changes: 18 additions & 18 deletions src/Caliburn.Xaml/ViewModelLocator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,17 @@ static ViewModelLocator()
/// <param name="config">An instance of TypeMappingConfiguration that provides the settings for configuration</param>
public static void ConfigureTypeMappings(TypeMappingConfiguration config)
{
if (String.IsNullOrEmpty(config.DefaultSubNamespaceForViews))
if (string.IsNullOrEmpty(config.DefaultSubNamespaceForViews))
{
throw new ArgumentException("DefaultSubNamespaceForViews field cannot be blank.");
}

if (String.IsNullOrEmpty(config.DefaultSubNamespaceForViewModels))
if (string.IsNullOrEmpty(config.DefaultSubNamespaceForViewModels))
{
throw new ArgumentException("DefaultSubNamespaceForViewModels field cannot be blank.");
}

if (String.IsNullOrEmpty(config.NameFormat))
if (string.IsNullOrEmpty(config.NameFormat))
{
throw new ArgumentException("NameFormat field cannot be blank.");
}
Expand Down Expand Up @@ -103,7 +103,7 @@ public static void AddDefaultTypeMapping(string viewSuffix = "View")
}

//Check for <Namespace>.<BaseName><ViewSuffix> construct
AddNamespaceMapping(String.Empty, String.Empty, viewSuffix);
AddNamespaceMapping(string.Empty, string.Empty, viewSuffix);

//Check for <Namespace>.Views.<NameSpace>.<BaseName><ViewSuffix> construct
AddSubNamespaceMapping(_defaultSubNsViews, _defaultSubNsViewModels, viewSuffix);
Expand All @@ -129,7 +129,7 @@ public static void AddTypeMapping(string nsSourceReplaceRegEx, string nsSourceFi
{
if (_viewModelSuffix.Contains(viewSuffix) || !_includeViewSuffixInVmNames)
{
var nameregex = String.Format(_nameFormat, basegrp, _viewModelSuffix);
var nameregex = string.Format(_nameFormat, basegrp, _viewModelSuffix);
func = t =>
{
replist.Add(t + "I" + nameregex + interfacegrp);
Expand All @@ -140,7 +140,7 @@ public static void AddTypeMapping(string nsSourceReplaceRegEx, string nsSourceFi
}
else
{
var nameregex = String.Format(_nameFormat, basegrp, "${suffix}" + _viewModelSuffix);
var nameregex = string.Format(_nameFormat, basegrp, "${suffix}" + _viewModelSuffix);
func = t =>
{
replist.Add(t + "I" + nameregex + interfacegrp);
Expand All @@ -159,18 +159,18 @@ public static void AddTypeMapping(string nsSourceReplaceRegEx, string nsSourceFi

nsTargetsRegEx.ToList().ForEach(t => func(t));

string suffix = _useNameSuffixesInMappings ? viewSuffix : String.Empty;
string suffix = _useNameSuffixesInMappings ? viewSuffix : string.Empty;

var srcfilterregx = String.IsNullOrEmpty(nsSourceFilterRegEx)
var srcfilterregx = string.IsNullOrEmpty(nsSourceFilterRegEx)
? null
: String.Concat(nsSourceFilterRegEx, String.Format(_nameFormat, RegExHelper.NameRegEx, suffix), "$");
: string.Concat(nsSourceFilterRegEx, string.Format(_nameFormat, RegExHelper.NameRegEx, suffix), "$");
var rxbase = RegExHelper.GetNameCaptureGroup("basename");
var rxsuffix = RegExHelper.GetCaptureGroup("suffix", suffix);

//Add a dummy capture group -- place after the "$" so it can never capture anything
var rxinterface = RegExHelper.GetCaptureGroup(InterfaceCaptureGroupName, String.Empty);
var rxinterface = RegExHelper.GetCaptureGroup(InterfaceCaptureGroupName, string.Empty);
NameTransformer.AddRule(
String.Concat(nsSourceReplaceRegEx, String.Format(_nameFormat, rxbase, rxsuffix), "$", rxinterface),
string.Concat(nsSourceReplaceRegEx, string.Format(_nameFormat, rxbase, rxsuffix), "$", rxinterface),
replist.ToArray(),
srcfilterregx
);
Expand Down Expand Up @@ -202,7 +202,7 @@ public static void AddNamespaceMapping(string nsSource, string[] nsTargets, stri

//Start pattern search from beginning of string ("^")
//unless original string was blank (i.e. special case to indicate "append target to source")
if (!String.IsNullOrEmpty(nsSource))
if (!string.IsNullOrEmpty(nsSource))
{
nsencoded = "^" + nsencoded;
}
Expand Down Expand Up @@ -237,9 +237,9 @@ public static void AddSubNamespaceMapping(string nsSource, string[] nsTargets, s
var nsencoded = RegExHelper.NamespaceToRegEx(nsSource + ".");

string rxbeforetgt, rxaftersrc, rxaftertgt;
string rxbeforesrc = rxbeforetgt = rxaftersrc = rxaftertgt = String.Empty;
string rxbeforesrc = rxbeforetgt = rxaftersrc = rxaftertgt = string.Empty;

if (!String.IsNullOrEmpty(nsSource))
if (!string.IsNullOrEmpty(nsSource))
{
if (!nsSource.StartsWith("*"))
{
Expand All @@ -255,9 +255,9 @@ public static void AddSubNamespaceMapping(string nsSource, string[] nsTargets, s
}

var rxmid = RegExHelper.GetCaptureGroup("subns", nsencoded);
var nsreplace = String.Concat(rxbeforesrc, rxmid, rxaftersrc);
var nsreplace = string.Concat(rxbeforesrc, rxmid, rxaftersrc);

var nsTargetsRegEx = nsTargets.Select(t => String.Concat(rxbeforetgt, t, ".", rxaftertgt)).ToArray();
var nsTargetsRegEx = nsTargets.Select(t => string.Concat(rxbeforetgt, t, ".", rxaftertgt)).ToArray();
AddTypeMapping(nsreplace, null, nsTargetsRegEx, viewSuffix);
}

Expand Down Expand Up @@ -311,9 +311,9 @@ public static string MakeInterface(string typeName)
else
{
var interfacegrpregex = @"\${" + InterfaceCaptureGroupName + @"}$";
getReplaceString = r => Regex.IsMatch(r, interfacegrpregex) ? String.Empty : r;
getReplaceString = r => Regex.IsMatch(r, interfacegrpregex) ? string.Empty : r;
}
return NameTransformer.Transform(typeName, getReplaceString).Where(n => n != String.Empty);
return NameTransformer.Transform(typeName, getReplaceString).Where(n => n != string.Empty);
};

/// <summary>
Expand Down

0 comments on commit 55423f3

Please sign in to comment.