Here are the examples of the csharp api string.Equals(string, string) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
1105 Examples
19
View Source File : DiscKeyInfo.cs
License : MIT License
Project Creator : 13xforever
License : MIT License
Project Creator : 13xforever
protected bool Equals(DiscKeyInfo other)
{
return string.Equals(DecryptedKeyId, other.DecryptedKeyId)
&& string.Equals(KeyFileHash, other.KeyFileHash)
&& KeyType == other.KeyType;
}
19
View Source File : Seat.cs
License : MIT License
Project Creator : 42skillz
License : MIT License
Project Creator : 42skillz
protected bool Equals(Seat other)
{
return string.Equals(seat_number, other.seat_number) && string.Equals(coach, other.coach);
}
19
View Source File : WebContentFolderHelper.cs
License : MIT License
Project Creator : 52ABP
License : MIT License
Project Creator : 52ABP
private static bool DirectoryContains(string directory, string fileName)
{
return Directory.GetFiles(directory).Any(filePath => string.Equals(Path.GetFileName(filePath), fileName));
}
19
View Source File : Field.cs
License : MIT License
Project Creator : a1xd
License : MIT License
Project Creator : a1xd
private void TextToData()
{
if (double.TryParse(Box.Text, out double value) &&
value <= MaxData && value >= MinData)
{
_data = value;
}
Box.Text = DecimalString(Data);
if (string.Equals(Box.Text, DefaultText))
{
SetToDefault();
}
else
{
SetToEntered();
}
}
19
View Source File : Dialog_CreateWorld.cs
License : Apache License 2.0
Project Creator : AantCoder
License : Apache License 2.0
Project Creator : AantCoder
public override void DoWindowContents(Rect inRect)
{
const float mainListingSpacing = 6f;
var btnSize = new Vector2(140f, 40f);
var buttonYStart = inRect.height - btnSize.y;
var ev = Event.current;
if (Widgets.ButtonText(new Rect(0, buttonYStart, btnSize.x, btnSize.y), "OCity_Dialog_CreateWorld_BtnOk".Translate())
|| ev.isKey && ev.type == EventType.KeyDown && ev.keyCode == KeyCode.Return)
{
if (string.IsNullOrEmpty(InputSeed)
|| string.IsNullOrEmpty(InputScenario) || string.Equals("none", InputScenario)
|| string.IsNullOrEmpty(InputDifficulty) || string.Equals("none", InputDifficulty)
|| !(((int)InputPlanetCoverage) >= 5 && ((int)InputPlanetCoverage <= 100))
)
{
var errText = checkInvalidValue(string.IsNullOrEmpty(InputSeed),
string.IsNullOrEmpty(InputScenario) || string.Equals("none", InputScenario),
string.IsNullOrEmpty(InputDifficulty) || string.Equals("none", InputDifficulty),
!(((int)InputPlanetCoverage) >= 5 && ((int)InputPlanetCoverage <= 100)));
Find.WindowStack.Add(new Dialog_Input("OCity_Dialog_CreateWorld_Err".Translate(), "OCity_Dialog_CreateWorld_Err2".Translate(errText), true));
}
else
{
ResultOK = true;
Close();
}
}
if (Widgets.ButtonText(new Rect(inRect.width - btnSize.x, buttonYStart, btnSize.x, btnSize.y), "OCity_Dialog_CreateWorld_BtnCancel".Translate()))
{
Close();
}
var mainListing = new Listing_Standard();
mainListing.verticalSpacing = mainListingSpacing;
mainListing.Begin(inRect);
Text.Font = GameFont.Medium;
mainListing.Label(replacedleText);
Text.Font = GameFont.Small;
mainListing.GapLine();
mainListing.Gap();
var textEditSize = new Vector2(150f, 25f);
var rect = new Rect(0, 70f, inRect.width, textEditSize.y);
mainListing.Label("OCity_Dialog_CreateWorld_Seed".Translate(), -1f, null);
InputSeed = mainListing.TextEntry(InputSeed, 1);
/*
Widgets.Label(rect, "Общее количество осадков");
rect.y += textEditSize.y;
Input = GUI.TextField(rect, Input, 100);
rect.y += textEditSize.y;
*/
/*
Widgets.Label(rect, "Общая темпиратура");
rect.y += textEditSize.y;
Input = GUI.TextField(rect, Input, 100);
rect.y += textEditSize.y;
*/
mainListing.Gap(6f);
if (ScenarioList == null) ScenarioList = GameUtils.AllScenarios();
if (mainListing.ButtonTextLabeled("OCity_Dialog_CreateWorld_Scenario".Translate(), InputScenario))
{
List<FloatMenuOption> floatList1 = new List<FloatMenuOption>();
foreach (var s in ScenarioList)
{
floatList1.Add(new FloatMenuOption(s.Value.name, delegate
{
InputScenario = s.Value.name;
InputScenarioKey = s.Key;
}, MenuOptionPriority.Default, null, null, 0f, null, null));
}
Find.WindowStack.Add(new FloatMenu(floatList1));
}
mainListing.Gap(6f);
if (mainListing.ButtonTextLabeled("OCity_Dialog_CreateWorld_Difficulty".Translate(), InputDifficulty))
{
List<FloatMenuOption> floatList1 = new List<FloatMenuOption>();
foreach (DifficultyDef difficultyDef in DefDatabase<DifficultyDef>.AllDefs)
{
if(difficultyDef.LabelCap != "Custom")
floatList1.Add(new FloatMenuOption(difficultyDef.LabelCap, delegate
{
InputDifficulty = difficultyDef.LabelCap;
InputDifficultyDefName = difficultyDef.defName;
}, MenuOptionPriority.Default, null, null, 0f, null, null));
}
Find.WindowStack.Add(new FloatMenu(floatList1));
}
//это уже не надо, каждый выбирает при старте
//Widgets.Label(rect, "OCity_Dialog_CreateWorld_MapSize".Translate());
//rect.y += textEditSize.y;
//InputMapSize = GUI.TextField(rect, InputMapSize, 3);
//rect.y += textEditSize.y;
mainListing.Label("OCity_Dialog_CreateWorld_PercentWorld".Translate(Mathf.Round(InputPlanetCoverage).ToString()), -1f, null);
if (Prefs.DevMode)
{
InputPlanetCoverage = mainListing.Slider(Mathf.Round(InputPlanetCoverage), 5f, 100f);
}
else
{
InputPlanetCoverage = mainListing.Slider(Mathf.Round(InputPlanetCoverage), 30f, 100f);
}
if (NeedFockus)
{
NeedFockus = false;
GUI.FocusControl("StartTextField");
}
mainListing.End();
}
19
View Source File : Order.cs
License : Apache License 2.0
Project Creator : Aaronontheweb
License : Apache License 2.0
Project Creator : Aaronontheweb
public bool Equals(Order other)
{
return string.Equals(OrderId, other.OrderId);
}
19
View Source File : Match.cs
License : Apache License 2.0
Project Creator : Aaronontheweb
License : Apache License 2.0
Project Creator : Aaronontheweb
public bool Equals(Match other)
{
if (ReferenceEquals(null, other)) return false;
if (ReferenceEquals(this, other)) return true;
return string.Equals(StockId, other.StockId)
&& string.Equals(BuyOrderId, other.BuyOrderId)
&& string.Equals(SellOrderId, other.SellOrderId);
}
19
View Source File : Ping.cs
License : Apache License 2.0
Project Creator : Aaronontheweb
License : Apache License 2.0
Project Creator : Aaronontheweb
public bool Equals(Ping other)
{
if (ReferenceEquals(null, other)) return false;
if (ReferenceEquals(this, other)) return true;
return string.Equals(StockId, other.StockId);
}
19
View Source File : ExampleLoader.cs
License : MIT License
Project Creator : ABTSoftware
License : MIT License
Project Creator : ABTSoftware
protected bool Equals(ExampleKey other)
{
return string.Equals(ExampleCategory, other.ExampleCategory) && string.Equals(ChartGroup, other.ChartGroup) && string.Equals(Examplereplacedle, other.Examplereplacedle);
}
19
View Source File : PowerPlan.cs
License : MIT License
Project Creator : ABTSoftware
License : MIT License
Project Creator : ABTSoftware
protected bool Equals(PowerPlan other)
{
return string.Equals(Name, other.Name) && Guid.Equals(other.Guid);
}
19
View Source File : FileLocator.cs
License : MIT License
Project Creator : Accelerider
License : MIT License
Project Creator : Accelerider
public bool Equals(FileLocator other) => !Equals(other, null) && string.Equals(FullPath, other.FullPath);
19
View Source File : RunnerWebProxy.cs
License : MIT License
Project Creator : actions
License : MIT License
Project Creator : actions
private bool IsUriInBypreplacedList(Uri input)
{
foreach (var noProxy in _noProxyList)
{
var matchHost = false;
var matchPort = false;
if (string.IsNullOrEmpty(noProxy.Port))
{
matchPort = true;
}
else
{
matchPort = string.Equals(noProxy.Port, input.Port.ToString());
}
if (noProxy.Host.StartsWith('.'))
{
matchHost = input.Host.EndsWith(noProxy.Host, StringComparison.OrdinalIgnoreCase);
}
else
{
matchHost = string.Equals(input.Host, noProxy.Host, StringComparison.OrdinalIgnoreCase) || input.Host.EndsWith($".{noProxy.Host}", StringComparison.OrdinalIgnoreCase);
}
if (matchHost && matchPort)
{
return true;
}
}
return false;
}
19
View Source File : ContainerInfo.cs
License : MIT License
Project Creator : actions
License : MIT License
Project Creator : actions
public string TranslateToContainerPath(string path)
{
if (!string.IsNullOrEmpty(path))
{
foreach (var mapping in _pathMappings)
{
#if OS_WINDOWS
if (string.Equals(path, mapping.HostPath, StringComparison.OrdinalIgnoreCase))
{
return mapping.ContainerPath;
}
if (path.StartsWith(mapping.HostPath + Path.DirectorySeparatorChar, StringComparison.OrdinalIgnoreCase) ||
path.StartsWith(mapping.HostPath + Path.AltDirectorySeparatorChar, StringComparison.OrdinalIgnoreCase))
{
return mapping.ContainerPath + path.Remove(0, mapping.HostPath.Length);
}
#else
if (string.Equals(path, mapping.HostPath))
{
return mapping.ContainerPath;
}
if (path.StartsWith(mapping.HostPath + Path.DirectorySeparatorChar))
{
return mapping.ContainerPath + path.Remove(0, mapping.HostPath.Length);
}
#endif
}
}
return path;
}
19
View Source File : ContainerInfo.cs
License : MIT License
Project Creator : actions
License : MIT License
Project Creator : actions
public string TranslateToHostPath(string path)
{
if (!string.IsNullOrEmpty(path))
{
foreach (var mapping in _pathMappings)
{
#if OS_WINDOWS
if (string.Equals(path, mapping.ContainerPath, StringComparison.OrdinalIgnoreCase))
{
return mapping.HostPath;
}
if (path.StartsWith(mapping.ContainerPath + Path.DirectorySeparatorChar, StringComparison.OrdinalIgnoreCase) ||
path.StartsWith(mapping.ContainerPath + Path.AltDirectorySeparatorChar, StringComparison.OrdinalIgnoreCase))
{
return mapping.HostPath + path.Remove(0, mapping.ContainerPath.Length);
}
#else
if (string.Equals(path, mapping.ContainerPath))
{
return mapping.HostPath;
}
if (path.StartsWith(mapping.ContainerPath + Path.DirectorySeparatorChar))
{
return mapping.HostPath + path.Remove(0, mapping.ContainerPath.Length);
}
#endif
}
}
return path;
}
19
View Source File : DockerUtil.cs
License : MIT License
Project Creator : actions
License : MIT License
Project Creator : actions
public static string ParsePathFromConfigEnv(IList<string> configEnvLines)
{
// Config format is VAR=value per line
foreach (var line in configEnvLines)
{
var keyValue = line.Split("=", 2);
if (keyValue.Length == 2 && string.Equals(keyValue[0], "PATH"))
{
return keyValue[1];
}
}
return "";
}
19
View Source File : XmlSerializableDataContractExtensions.cs
License : MIT License
Project Creator : actions
License : MIT License
Project Creator : actions
private string ComputeSerializedNameForCameCaseCompat(bool enableCamelCaseNameCompat)
{
if (!enableCamelCaseNameCompat)
{
return null;
}
var upperCamelCaseName = ConvertToUpperCamelCase(SerializedName);
if (string.Equals(upperCamelCaseName, SerializedName))
{
return null;
}
return upperCamelCaseName;
}
19
View Source File : VssApiResourceLocation.cs
License : MIT License
Project Creator : actions
License : MIT License
Project Creator : actions
public bool Equals(ApiResourceLocation other)
{
return (Guid.Equals(Id, other.Id) &&
string.Equals(Area, other.Area) &&
string.Equals(ResourceName, other.ResourceName) &&
string.Equals(RouteTemplate, other.RouteTemplate) &&
string.Equals(RouteName, other.RouteName) &&
Version.Equals(ResourceVersion, other.ResourceVersion) &&
Version.Equals(MinVersion, other.MinVersion) &&
Version.Equals(MaxVersion, other.MaxVersion) &&
Version.Equals(ReleasedVersion, other.ReleasedVersion));
}
19
View Source File : DotnetsdkDownloadScriptL0.cs
License : MIT License
Project Creator : actions
License : MIT License
Project Creator : actions
[Fact]
[Trait("Level", "L0")]
[Trait("Category", "Runner")]
public async Task EnsureDotnetsdkPowershellDownloadScriptUpToDate()
{
if ((DateTime.UtcNow.Month - 1) % 3 != 0)
{
// Only check these script once a quater.
return;
}
string ps1DownloadUrl = "https://dot.net/v1/dotnet-install.ps1";
using (HttpClient downloadClient = new HttpClient())
{
var response = await downloadClient.GetAsync("https://www.bing.com");
if (!response.IsSuccessStatusCode)
{
return;
}
string ps1Script = await downloadClient.GetStringAsync(ps1DownloadUrl);
string existingPs1Script = File.ReadAllText(Path.Combine(TestUtil.GetSrcPath(), "Misc/dotnet-install.ps1"));
bool ps1ScriptMatched = string.Equals(ps1Script.TrimEnd('\n', '\r', '\0').Replace("\r\n", "\n").Replace("\r", "\n"), existingPs1Script.TrimEnd('\n', '\r', '\0').Replace("\r\n", "\n").Replace("\r", "\n"));
//replacedert.True(ps1ScriptMatched, "Fix the test by updating Src/Misc/dotnet-install.ps1 with content from https://dot.net/v1/dotnet-install.ps1");
}
}
19
View Source File : VssApiResourceVersionExtensions.cs
License : MIT License
Project Creator : actions
License : MIT License
Project Creator : actions
internal static void AddApiResourceVersionValues(this ICollection<NameValueHeaderValue> headerValues, ApiResourceVersion version, Boolean replaceExisting, Boolean useLegacyFormat)
{
String apiVersionHeaderValue = null;
String resVersionHeaderValue = null;
if (useLegacyFormat)
{
apiVersionHeaderValue = version.ApiVersionString;
if (version.ResourceVersion > 0)
{
resVersionHeaderValue = version.ResourceVersion.ToString();
}
}
else
{
apiVersionHeaderValue = version.ToString();
}
NameValueHeaderValue existingHeader = headerValues.FirstOrDefault(h => String.Equals(c_apiVersionHeaderKey, h.Name));
if (existingHeader != null)
{
if (replaceExisting)
{
existingHeader.Value = apiVersionHeaderValue;
if (!String.IsNullOrEmpty(resVersionHeaderValue))
{
NameValueHeaderValue existingResHeader = headerValues.FirstOrDefault(h => String.Equals(c_legacyResourceVersionHeaderKey, h.Name));
if (existingResHeader != null)
{
existingResHeader.Value = resVersionHeaderValue;
}
else
{
headerValues.Add(new NameValueHeaderValue(c_legacyResourceVersionHeaderKey, resVersionHeaderValue));
}
}
}
}
else
{
headerValues.Add(new NameValueHeaderValue(c_apiVersionHeaderKey, apiVersionHeaderValue));
if (!String.IsNullOrEmpty(resVersionHeaderValue))
{
headerValues.Add(new NameValueHeaderValue(c_legacyResourceVersionHeaderKey, resVersionHeaderValue));
}
}
}
19
View Source File : DotnetsdkDownloadScriptL0.cs
License : MIT License
Project Creator : actions
License : MIT License
Project Creator : actions
[Fact]
[Trait("Level", "L0")]
[Trait("Category", "Runner")]
public async Task EnsureDotnetsdkBashDownloadScriptUpToDate()
{
if ((DateTime.UtcNow.Month - 1) % 3 != 0)
{
// Only check these script once a quater.
return;
}
string shDownloadUrl = "https://dot.net/v1/dotnet-install.sh";
using (HttpClient downloadClient = new HttpClient())
{
var response = await downloadClient.GetAsync("https://www.bing.com");
if (!response.IsSuccessStatusCode)
{
return;
}
string shScript = await downloadClient.GetStringAsync(shDownloadUrl);
string existingShScript = File.ReadAllText(Path.Combine(TestUtil.GetSrcPath(), "Misc/dotnet-install.sh"));
bool shScriptMatched = string.Equals(shScript.TrimEnd('\n', '\r', '\0').Replace("\r\n", "\n").Replace("\r", "\n"), existingShScript.TrimEnd('\n', '\r', '\0').Replace("\r\n", "\n").Replace("\r", "\n"));
//replacedert.True(shScriptMatched, "Fix the test by updating Src/Misc/dotnet-install.sh with content from https://dot.net/v1/dotnet-install.sh");
}
}
19
View Source File : PortalBusMessage.cs
License : MIT License
Project Creator : Adoxio
License : MIT License
Project Creator : Adoxio
public virtual bool Validate(IOwinContext context, IDataProtector protector)
{
try
{
return string.Equals(Id, Encoding.UTF8.GetString(protector.Unprotect(Convert.FromBase64String(Token))));
}
catch (CryptographicException)
{
return false;
}
}
19
View Source File : ServiceDefinitionPortalBusProvider.cs
License : MIT License
Project Creator : Adoxio
License : MIT License
Project Creator : Adoxio
protected virtual IEnumerable<string> GetApplicationPaths(string endpointName, string internalEndpointName, IEnumerable<RoleSite> sites)
{
// return the root application path based on the basic configuration
if (string.Equals(endpointName, internalEndpointName)) yield return string.Empty;
// return paths based on the advanced configuration
var applications =
from site in sites ?? new RoleSite[] { }
from binding in site.Bindings ?? new Binding[] { }
where binding.EndpointName == endpointName
from application in site.VirtualApplications ?? new[] { new VirtualApplication() }
select string.IsNullOrWhiteSpace(application.Name) ? string.Empty : "/" + application.Name;
foreach (var application in applications)
{
// return the virtual application path
yield return application;
}
}
19
View Source File : WebAppSettings.cs
License : MIT License
Project Creator : Adoxio
License : MIT License
Project Creator : Adoxio
private static bool GetAppDataCachingEnabled()
{
// running in Azure Web Apps with a mode greater than "Limited"
var websiteMode = GetAppSettingOrEnvironmentVariable("WEBSITE_SKU");
return websiteMode != null && !string.Equals(websiteMode, "Free");
}
19
View Source File : IVisitorContext.cs
License : MIT License
Project Creator : adrianoc
License : MIT License
Project Creator : adrianoc
public bool Equals(DefinitionVariable other)
{
return string.Equals(MemberName, other.MemberName)
&& string.Equals(ParentName, other.ParentName)
&& Kind == other.Kind;
}
19
View Source File : HMACValidator.cs
License : MIT License
Project Creator : Adyen
License : MIT License
Project Creator : Adyen
public bool IsValidHmac(NotificationRequesreplacedem notificationRequesreplacedem, string key)
{
string expectedSign = CalculateHmac(notificationRequesreplacedem, key);
string merchantSign = notificationRequesreplacedem.AdditionalData[Constants.AdditionalData.HmacSignature];
return string.Equals(expectedSign, merchantSign);
}
19
View Source File : TerminalCommonNameValidator.cs
License : MIT License
Project Creator : Adyen
License : MIT License
Project Creator : Adyen
public static bool ValidateCertificate(string certificateSubject, Model.Enum.Environment environment)
{
var environmentName = environment.ToString().ToLower();
var regexPatternTerminalSpecificCert = _terminalApiCnRegex.Replace(_environmentWildcard, environmentName);
var regexPatternLegacyCert = _terminalApiLegacy.Replace(_environmentWildcard, environmentName);
var subject = certificateSubject.Split(',')
.Select(x => x.Split('='))
.ToDictionary(x => x[0].Trim(' '), x => x[1]);
if (subject.ContainsKey("CN"))
{
string commonNameValue = subject["CN"];
if (Regex.Match(commonNameValue, regexPatternTerminalSpecificCert).Success || string.Equals(commonNameValue, regexPatternLegacyCert))
{
return true;
}
}
return false;
}
19
View Source File : RedisLiteHelper.cs
License : MIT License
Project Creator : AElfProject
License : MIT License
Project Creator : AElfProject
protected bool Equals(RedisEndpoint other)
{
return string.Equals(Host, other.Host)
&& Port == other.Port
&& Ssl.Equals(other.Ssl)
&& ConnectTimeout == other.ConnectTimeout
&& SendTimeout == other.SendTimeout
&& ReceiveTimeout == other.ReceiveTimeout
&& RetryTimeout == other.RetryTimeout
&& IdleTimeOutSecs == other.IdleTimeOutSecs
&& Db == other.Db
&& string.Equals(Client, other.Client)
&& string.Equals(Preplacedword, other.Preplacedword)
&& string.Equals(NamespacePrefix, other.NamespacePrefix);
}
19
View Source File : DataMigrator.cs
License : MIT License
Project Creator : afaniuolo
License : MIT License
Project Creator : afaniuolo
private string GetFieldValue(string value, string data)
{
if (!string.IsNullOrEmpty(data) && !string.Equals(data, "multipleline") && !string.Equals(data, "medialink"))
{
return data;
}
return value;
}
19
View Source File : EntityValueChecker.cs
License : Mozilla Public License 2.0
Project Creator : agebullhu
License : Mozilla Public License 2.0
Project Creator : agebullhu
public static bool IsModify(this string txt,string val)
{
if (string.IsNullOrWhiteSpace(txt))
{
return !string.IsNullOrWhiteSpace(val);
}
return string.IsNullOrWhiteSpace(val) || string.Equals(txt, val.Trim());
}
19
View Source File : PasswordBoxHelper.cs
License : MIT License
Project Creator : ahmed-abdelrazek
License : MIT License
Project Creator : ahmed-abdelrazek
public static void SetBoundPreplacedword(DependencyObject d, string value)
{
if (string.Equals(value, GetBoundPreplacedword(d)))
{
return; // and this is how we prevent infinite recursion
}
d.SetValue(BoundPreplacedwordProperty, value);
}
19
View Source File : HttpServer.cs
License : GNU General Public License v3.0
Project Creator : aiportal
License : GNU General Public License v3.0
Project Creator : aiportal
private bool IsLoginReferrer(HttpListenerRequest req)
{
string url = req.GetFilePath(null);
if (string.Equals(url, _loginUrl))
return true;
string referrer = req.GetReferrer(null);
if (string.Equals(referrer, _loginUrl))
return true;
return false;
}
19
View Source File : JavaScriptUtils.cs
License : MIT License
Project Creator : akaskela
License : MIT License
Project Creator : akaskela
public static void WriteEscapedJavaScriptString(TextWriter writer, string s, char delimiter, bool appendDelimiters,
bool[] charEscapeFlags, StringEscapeHandling stringEscapeHandling, IArrayPool<char> bufferPool, ref char[] writeBuffer)
{
// leading delimiter
if (appendDelimiters)
{
writer.Write(delimiter);
}
if (s != null)
{
int lastWritePosition = 0;
for (int i = 0; i < s.Length; i++)
{
var c = s[i];
if (c < charEscapeFlags.Length && !charEscapeFlags[c])
{
continue;
}
string escapedValue;
switch (c)
{
case '\t':
escapedValue = @"\t";
break;
case '\n':
escapedValue = @"\n";
break;
case '\r':
escapedValue = @"\r";
break;
case '\f':
escapedValue = @"\f";
break;
case '\b':
escapedValue = @"\b";
break;
case '\\':
escapedValue = @"\\";
break;
case '\u0085': // Next Line
escapedValue = @"\u0085";
break;
case '\u2028': // Line Separator
escapedValue = @"\u2028";
break;
case '\u2029': // Paragraph Separator
escapedValue = @"\u2029";
break;
default:
if (c < charEscapeFlags.Length || stringEscapeHandling == StringEscapeHandling.EscapeNonAscii)
{
if (c == '\'' && stringEscapeHandling != StringEscapeHandling.EscapeHtml)
{
escapedValue = @"\'";
}
else if (c == '"' && stringEscapeHandling != StringEscapeHandling.EscapeHtml)
{
escapedValue = @"\""";
}
else
{
if (writeBuffer == null || writeBuffer.Length < UnicodeTextLength)
{
writeBuffer = BufferUtils.EnsureBufferSize(bufferPool, UnicodeTextLength, writeBuffer);
}
StringUtils.ToCharAsUnicode(c, writeBuffer);
// slightly hacky but it saves multiple conditions in if test
escapedValue = EscapedUnicodeText;
}
}
else
{
escapedValue = null;
}
break;
}
if (escapedValue == null)
{
continue;
}
bool isEscapedUnicodeText = string.Equals(escapedValue, EscapedUnicodeText);
if (i > lastWritePosition)
{
int length = i - lastWritePosition + ((isEscapedUnicodeText) ? UnicodeTextLength : 0);
int start = (isEscapedUnicodeText) ? UnicodeTextLength : 0;
if (writeBuffer == null || writeBuffer.Length < length)
{
char[] newBuffer = BufferUtils.RentBuffer(bufferPool, length);
// the unicode text is already in the buffer
// copy it over when creating new buffer
if (isEscapedUnicodeText)
{
Array.Copy(writeBuffer, newBuffer, UnicodeTextLength);
}
BufferUtils.ReturnBuffer(bufferPool, writeBuffer);
writeBuffer = newBuffer;
}
s.CopyTo(lastWritePosition, writeBuffer, start, length - start);
// write unchanged chars before writing escaped text
writer.Write(writeBuffer, start, length - start);
}
lastWritePosition = i + 1;
if (!isEscapedUnicodeText)
{
writer.Write(escapedValue);
}
else
{
writer.Write(writeBuffer, 0, UnicodeTextLength);
}
}
if (lastWritePosition == 0)
{
// no escaped text, write entire string
writer.Write(s);
}
else
{
int length = s.Length - lastWritePosition;
if (writeBuffer == null || writeBuffer.Length < length)
{
writeBuffer = BufferUtils.EnsureBufferSize(bufferPool, length, writeBuffer);
}
s.CopyTo(lastWritePosition, writeBuffer, 0, length);
// write remaining text
writer.Write(writeBuffer, 0, length);
}
}
// trailing delimiter
if (appendDelimiters)
{
writer.Write(delimiter);
}
}
19
View Source File : AssetTreeModel.cs
License : MIT License
Project Creator : akof1314
License : MIT License
Project Creator : akof1314
public void ThreadPoolCallback(System.Object threadContext)
{
try
{
string text = File.ReadAllText(m_Path);
// 搜索
if (string.IsNullOrEmpty(m_ReplaceStr))
{
for (int i = 0; i < m_Patterns.Count; i++)
{
if (text.Contains(m_Patterns[i]))
{
m_SearchRet[i] = true;
}
}
}
else
{
StringBuilder sb = new StringBuilder(text, text.Length * 2);
foreach (var pattern in m_Patterns)
{
sb.Replace(pattern, m_ReplaceStr);
}
string text2 = sb.ToString();
if (!string.Equals(text, text2))
{
File.WriteAllText(m_Path, text2);
}
}
}
catch (Exception ex)
{
exception = m_Path + "\n" + ex.Message;
}
doneEvent.Set();
}
19
View Source File : EmployeeService.cs
License : MIT License
Project Creator : aksoftware98
License : MIT License
Project Creator : aksoftware98
public async Task<ApiResponse> DeleteEmployeeAsync(string employeeId)
{
var employee = await _employeeRepository.GetByIdAsync(employeeId);
if (employee is null)
return new ApiResponse("Employee does not exist");
var imageFileName = Path.GetFileName(employee.User.ProfilePicture);
// Delete the employee
await _employeeRepository.DeleteAsync(employee);
// Delete the related application user
var response = await _userService.DeleteUserAsync(employee.User);
// Delete profile image if it is not the default one
if (!string.Equals(imageFileName, "default.png"))
{
var imagePhysicalPath = Path.Combine(_envProvider.WebRootPath, "Images", "Users", imageFileName);
File.Delete(imagePhysicalPath);
}
return new ApiResponse();
}
19
View Source File : WebContentDirectoryFinder.cs
License : MIT License
Project Creator : albyho
License : MIT License
Project Creator : albyho
public static string CalculateContentRootFolder()
{
var domainreplacedemblyDirectoryPath =
Path.GetDirectoryName(typeof(SampleDomainModule).replacedembly.Location);
if (domainreplacedemblyDirectoryPath == null)
{
throw new Exception(
$"Could not find location of {typeof(SampleDomainModule).replacedembly.FullName} replacedembly!");
}
var directoryInfo = new DirectoryInfo(domainreplacedemblyDirectoryPath);
if (Environment.GetEnvironmentVariable("NCrunch") == "1")
{
while (!DirectoryContains(directoryInfo.FullName, "Sample.Web.csproj", SearchOption.AllDirectories))
{
directoryInfo = directoryInfo.Parent ?? throw new Exception("Could not find content root folder!");
}
var webProject = Directory.GetFiles(directoryInfo.FullName, string.Empty, SearchOption.AllDirectories)
.First(filePath => string.Equals(Path.GetFileName(filePath), "Sample.Web.csproj"));
return Path.GetDirectoryName(webProject);
}
while (!DirectoryContains(directoryInfo.FullName, "Sample.sln"))
{
directoryInfo = directoryInfo.Parent ?? throw new Exception("Could not find content root folder!");
}
var webFolder = Path.Combine(directoryInfo.FullName, $"src{Path.DirectorySeparatorChar}Sample.Web");
if (Directory.Exists(webFolder))
{
return webFolder;
}
throw new Exception("Could not find root folder of the web project!");
}
19
View Source File : WebContentDirectoryFinder.cs
License : MIT License
Project Creator : albyho
License : MIT License
Project Creator : albyho
private static bool DirectoryContains(string directory, string fileName,
SearchOption searchOption = SearchOption.TopDirectoryOnly)
{
return Directory.GetFiles(directory, string.Empty, searchOption)
.Any(filePath => string.Equals(Path.GetFileName(filePath), fileName));
}
19
View Source File : LoggingAssert.cs
License : Apache License 2.0
Project Creator : alefranz
License : Apache License 2.0
Project Creator : alefranz
public bool Equals(KeyValuePair<string, object> x, KeyValuePair<string, object> y)
{
return string.Equals(x.Key, y.Key) && Equals(x.Value, y.Value);
}
19
View Source File : MapboxConfigurationWindow.cs
License : MIT License
Project Creator : alen-smajic
License : MIT License
Project Creator : alen-smajic
void DrawAccessTokenField()
{
EditorGUILayout.BeginHorizontal(_horizontalGroup);
//_accessToken is empty
if (string.IsNullOrEmpty(_accessToken))
{
_accessToken = EditorGUILayout.TextField("", _accessToken, _textFieldStyle);
EditorGUI.BeginDisabledGroup(true);
GUILayout.Button("Submit", _submitButtonStyle);
EditorGUI.EndDisabledGroup();
}
else
{
//_accessToken is being validated
if (_validating)
{
EditorGUI.BeginDisabledGroup(true);
_accessToken = EditorGUILayout.TextField("", _accessToken, _textFieldStyle);
GUILayout.Button("Checking", _submitButtonStyle);
EditorGUI.EndDisabledGroup();
}
//_accessToken is the same as the already submitted token
else if (string.Equals(_lastValidatedToken, _accessToken))
{
//valid token
if (_currentTokenStatus == MapboxTokenStatus.TokenValid)
{
GUI.backgroundColor = _validBackgroundColor;
GUI.contentColor = _validContentColor;
_accessToken = EditorGUILayout.TextField("", _accessToken, _textFieldStyle);
GUILayout.Button("Valid", _validButtonStyle);
GUI.contentColor = _defaultContentColor;
GUI.backgroundColor = _defaultBackgroundColor;
}
//invalid token
else
{
GUI.contentColor = _invalidContentColor;
GUI.backgroundColor = _invalidBackgroundColor;
_accessToken = EditorGUILayout.TextField("", _accessToken, _textFieldStyle);
GUILayout.Button("Invalid", _validButtonStyle);
GUI.contentColor = _defaultContentColor;
GUI.backgroundColor = _defaultBackgroundColor;
}
//Submit button
if (GUILayout.Button("Submit", _submitButtonStyle))
{
SubmitConfiguration();
}
}
//_accessToken is a new, unsubmitted token.
else
{
_accessToken = EditorGUILayout.TextField("", _accessToken, _textFieldStyle);
if (GUILayout.Button("Submit", _submitButtonStyle))
{
SubmitConfiguration();
}
}
}
EditorGUILayout.EndHorizontal();
}
19
View Source File : MapboxConfigurationWindow.cs
License : MIT License
Project Creator : alen-smajic
License : MIT License
Project Creator : alen-smajic
void DrawError()
{
//draw the error message, if one exists
EditorGUILayout.BeginHorizontal(_horizontalGroup);
if (_currentTokenStatus != MapboxTokenStatus.TokenValid
&& _currentTokenStatus != MapboxTokenStatus.StatusNotYetSet
&& string.Equals(_lastValidatedToken, _accessToken)
&& !_validating)
{
EditorGUILayout.LabelField(_currentTokenStatus.ToString(), _errorStyle);
}
EditorGUILayout.EndHorizontal();
}
19
View Source File : FixModel.cs
License : MIT License
Project Creator : alexleen
License : MIT License
Project Creator : alexleen
public bool Equals(FixModel other)
{
if (other is null)
{
return false;
}
if (ReferenceEquals(this, other))
{
return true;
}
return Flag == other.Flag && PerformanceImpact == other.PerformanceImpact && string.Equals(Description, other.Description);
}
19
View Source File : HistoricalValue.cs
License : MIT License
Project Creator : alexleen
License : MIT License
Project Creator : alexleen
public bool Equals(HistoricalValue other)
{
if (other is null)
{
return false;
}
return ReferenceEquals(this, other) || string.Equals(Value, other.Value);
}
19
View Source File : BitStampClient.cs
License : Apache License 2.0
Project Creator : AlexWan
License : Apache License 2.0
Project Creator : AlexWan
private void Converter()
{
while (true)
{
if (_isDisposed)
{
return;
}
try
{
if (!_newMessage.IsEmpty)
{
string mes;
if (_newMessage.TryDequeue(out mes))
{
List<string> values = new List<string>();
int firstInd = 0;
for (int i = 1; i < mes.Length - 1; i++)
{
if (string.Equals((mes[i].ToString() + mes[i + 1].ToString()), "}{"))
{
String newString = mes.Substring(firstInd, i - firstInd + 1);
firstInd = i + 1;
values.Add(newString);
}
}
String lastString = mes.Substring(firstInd, mes.Length - firstInd);
values.Add(lastString);
for (int i = 0; i < values.Count; i++)
{
ParseMessage(values[i]);
}
}
}
else
{
Thread.Sleep(1);
}
}
catch (Exception exception)
{
SendLogMessage(exception.ToString(), LogMessageType.Error);
}
}
}
19
View Source File : FolderFinder.cs
License : MIT License
Project Creator : aliakseiherman
License : MIT License
Project Creator : aliakseiherman
private static bool Contains(string dirname, string filename)
{
return Directory.GetFiles(dirname).Any(filePath => string.Equals(Path.GetFileName(filePath), filename));
}
19
View Source File : StringUtil.cs
License : Apache License 2.0
Project Creator : alipay
License : Apache License 2.0
Project Creator : alipay
public static string ToString(object obj)
{
if (obj == null)
{
return "null";
}
Type type = obj.GetType();
if (string.Equals("System", type.Namespace))
{
return "\"" + obj.ToString() + "\"";
}
// clreplaced
string result = "{";
PropertyInfo[] pis = type.GetProperties();
for (int i = 0; i < pis.Length; i++)
{
PropertyInfo pi = pis[i];
Type pType = pi.PropertyType;
MethodInfo getMethod = pi.GetGetMethod();
object value = getMethod.Invoke(obj, null);
if (value == null)
{
continue;
}
string valueString = "";
if (string.Equals("System", pType.Namespace))
{
valueString = "\"" + value.ToString() + "\"";
}
else if (string.Equals("System.Collections.Generic", pType.Namespace))
{
valueString = List2String(value);
}
else
{
valueString = ToString(value);
}
if (i != 0)
{
result += ",";
}
result += "\"" + pi.Name + "\":" + valueString + "";
}
result += "}";
return result;
}
19
View Source File : ErrorCode.cs
License : MIT License
Project Creator : aliyun
License : MIT License
Project Creator : aliyun
public override Boolean Equals(Object obj)
{
if (ReferenceEquals(null, obj))
{
return false;
}
if (ReferenceEquals(this, obj))
{
return true;
}
switch (obj)
{
case ErrorCode other:
return String.Equals(this.Code, other.Code);
case String other:
return String.Equals(this.Code, other);
default:
return false;
}
}
19
View Source File : JsonSchemaToInstanceModelGenerator.cs
License : BSD 3-Clause "New" or "Revised" License
Project Creator : Altinn
License : BSD 3-Clause "New" or "Revised" License
Project Creator : Altinn
public JsonObject ExpandPath(string path)
{
JsonObject startPoint = instanceModel.TryGetObject("Elements").TryGetObject(path);
if (startPoint == null)
{
throw new ApplicationException("Path does not exist in instance model");
}
string typeName = startPoint.TryGetString("TypeName");
string type = startPoint.TryGetString("Type");
if (typeName == null)
{
throw new ApplicationException("Path cannot be expanded");
}
JsonSchema jsonSchema = definitions.GetValueOrDefault(typeName);
if (jsonSchema == null || !string.Equals("Group", type))
{
throw new ApplicationException("Path cannot be expanded since type is not a group: " + typeName);
}
// Only handle properties below path
try
{
foreach (KeyValuePair<string, JsonSchema> def in jsonSchema.Properties())
{
TraverseModel(path, typeName, def.Key, def.Value, false, new HashSet<string>(), jsonSchema, string.Empty);
}
}
catch (Exception e)
{
throw new ApplicationException("Path already expanded or failure in expanding code", e);
}
return instanceModel;
}
19
View Source File : IssueRepositorySettings.cs
License : Apache License 2.0
Project Creator : AmpScm
License : Apache License 2.0
Project Creator : AmpScm
public bool Equals(IssueRepositorySettings other)
{
if (other == null)
return false;
if (!string.Equals(ConnectorName, other.ConnectorName))
return false;
if (!object.Equals(RepositoryUri, other.RepositoryUri))
return false;
if (!string.Equals(RepositoryId, other.RepositoryId))
return false;
return true;
}
19
View Source File : RegistryLifoList.cs
License : Apache License 2.0
Project Creator : AmpScm
License : Apache License 2.0
Project Creator : AmpScm
public bool Contains(string item)
{
using (RegistryKey key = OpenFifoKey(false))
{
foreach (string name in key.GetValueNames())
{
if (name.StartsWith("#"))
{
if (String.Equals(item, key.GetValue(name) as string))
return true;
}
}
}
return false;
}
19
View Source File : ProjectTracker.Rename.cs
License : Apache License 2.0
Project Creator : AmpScm
License : Apache License 2.0
Project Creator : AmpScm
private bool MaybeProcessAncestorRename(string oldName, string newName)
{
// If the name of the node itself doesn't change in a rename, it's most likely
// a parent rename.
if (!string.Equals(Path.GetFileName(oldName), Path.GetFileName(newName)))
return false;
string oldNode = SvnTools.GetNormalizedDirectoryName(oldName);
string newNode = SvnTools.GetNormalizedDirectoryName(newName);
if (oldNode == null || newNode == null || String.Equals(oldNode, newNode))
return false;
if (_alreadyProcessed.Contains(newNode))
return true;
if (MaybeProcessAncestorRename(oldNode, newNode))
return true;
if (!_fileOrigins.ContainsKey(newNode))
return false;
return ProcessRename(oldNode, newNode);
}
19
View Source File : PendingChangeManager.Map.cs
License : Apache License 2.0
Project Creator : AmpScm
License : Apache License 2.0
Project Creator : AmpScm
public IEnumerable<string> GetSuggestedChangeLists()
{
Dictionary<string, string> usedNames = new Dictionary<string, string>();
foreach (PendingChange pc in _pendingChanges.ToArray())
{
string cl = pc.ChangeList;
if (!string.IsNullOrEmpty(cl) && !string.Equals(cl, IgnoreOnCommit))
{
if (usedNames.ContainsKey(cl))
continue;
usedNames.Add(cl, cl);
yield return cl;
}
}
}
See More Examples