Here are the examples of the csharp api string.Equals(string, System.StringComparison) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
4087 Examples
19
View Source File : MainWindow.xaml.cs
License : GNU General Public License v3.0
Project Creator : 00000vish
License : GNU General Public License v3.0
Project Creator : 00000vish
private void initVariables()
{
LaunchedViaStartup = Environment.GetCommandLineArgs() != null && Environment.GetCommandLineArgs().Any(arg => arg.Equals("startup", StringComparison.CurrentCultureIgnoreCase));
encrypted = SteamTwoProperties.jsonSetting.encryptedSetting;
currentHandle = this;
}
19
View Source File : HeifEncoder.cs
License : GNU Lesser General Public License v3.0
Project Creator : 0xC0000054
License : GNU Lesser General Public License v3.0
Project Creator : 0xC0000054
private static bool TryConvertStringToBoolean(string value, out bool result)
{
if (!string.IsNullOrWhiteSpace(value))
{
if (bool.TryParse(value, out result))
{
return true;
}
else if (value.Equals("1", StringComparison.Ordinal))
{
result = true;
return true;
}
else if (value.Equals("0", StringComparison.Ordinal))
{
result = false;
return true;
}
}
result = false;
return false;
}
19
View Source File : GmicPipeServer.cs
License : GNU General Public License v3.0
Project Creator : 0xC0000054
License : GNU General Public License v3.0
Project Creator : 0xC0000054
private void WaitForConnectionCallback(IAsyncResult result)
{
if (server == null)
{
return;
}
try
{
server.EndWaitForConnection(result);
}
catch (ObjectDisposedException)
{
return;
}
byte[] replySizeBuffer = new byte[sizeof(int)];
server.ProperRead(replySizeBuffer, 0, replySizeBuffer.Length);
int messageLength = BitConverter.ToInt32(replySizeBuffer, 0);
byte[] messageBytes = new byte[messageLength];
server.ProperRead(messageBytes, 0, messageLength);
List<string> parameters = DecodeMessageBuffer(messageBytes);
if (!TryGetValue(parameters[0], "command=", out string command))
{
throw new InvalidOperationException("The first item must be a command.");
}
if (command.Equals("gmic_qt_get_max_layer_size", StringComparison.Ordinal))
{
if (!TryGetValue(parameters[1], "mode=", out string mode))
{
throw new InvalidOperationException("The second item must be the input mode.");
}
InputMode inputMode = ParseInputMode(mode);
#if DEBUG
System.Diagnostics.Debug.WriteLine("'gmic_qt_get_max_layer_size' received. mode=" + inputMode.ToString());
#endif
string reply = GetMaxLayerSize(inputMode);
SendMessage(server, reply);
}
else if (command.Equals("gmic_qt_get_cropped_images", StringComparison.Ordinal))
{
if (!TryGetValue(parameters[1], "mode=", out string mode))
{
throw new InvalidOperationException("The second item must be the input mode.");
}
if (!TryGetValue(parameters[2], "croprect=", out string packedCropRect))
{
throw new InvalidOperationException("The third item must be the crop rectangle.");
}
InputMode inputMode = ParseInputMode(mode);
RectangleF cropRect = GetCropRectangle(packedCropRect);
#if DEBUG
System.Diagnostics.Debug.WriteLine(string.Format(CultureInfo.InvariantCulture,
"'gmic_qt_get_cropped_images' received. mode={0}, cropRect={1}",
inputMode.ToString(), cropRect.ToString()));
#endif
string reply = PrepareCroppedLayers(inputMode, cropRect);
SendMessage(server, reply);
}
else if (command.Equals("gmic_qt_output_images", StringComparison.Ordinal))
{
if (!TryGetValue(parameters[1], "mode=", out string mode))
{
throw new InvalidOperationException("The second item must be the output mode.");
}
OutputMode outputMode = ParseOutputMode(mode);
#if DEBUG
System.Diagnostics.Debug.WriteLine("'gmic_qt_output_images' received. mode=" + outputMode.ToString());
#endif
List<string> outputLayers = parameters.GetRange(2, parameters.Count - 2);
string reply = ProcessOutputImage(outputLayers, outputMode);
SendMessage(server, reply);
}
else if (command.Equals("gmic_qt_release_shared_memory", StringComparison.Ordinal))
{
#if DEBUG
System.Diagnostics.Debug.WriteLine("'gmic_qt_release_shared_memory' received.");
#endif
for (int i = 0; i < memoryMappedFiles.Count; i++)
{
memoryMappedFiles[i].Dispose();
}
memoryMappedFiles.Clear();
SendMessage(server, "done");
}
else if (command.Equals("gmic_qt_get_max_layer_data_length", StringComparison.Ordinal))
{
// This command is used to prevent images larger than 4GB from being used on a 32-bit version of G'MIC.
// Attempting to map an image that size into memory would cause an integer overflow when casting a 64-bit
// integer to the unsigned 32-bit size_t type.
long maxDataLength = 0;
foreach (GmicLayer layer in layers)
{
maxDataLength = Math.Max(maxDataLength, layer.Surface.Scan0.Length);
}
server.Write(BitConverter.GetBytes(sizeof(long)), 0, 4);
server.Write(BitConverter.GetBytes(maxDataLength), 0, 8);
}
// Wait for the acknowledgment that the client is done reading.
if (server.IsConnected)
{
byte[] doneMessageBuffer = new byte[4];
int bytesRead = 0;
int bytesToRead = doneMessageBuffer.Length;
do
{
int n = server.Read(doneMessageBuffer, bytesRead, bytesToRead);
bytesRead += n;
bytesToRead -= n;
} while (bytesToRead > 0 && server.IsConnected);
}
// Start a new server and wait for the next connection.
server.Dispose();
server = new NamedPipeServerStream(pipeName, PipeDirection.InOut, 1, PipeTransmissionMode.Byte, PipeOptions.Asynchronous);
server.BeginWaitForConnection(WaitForConnectionCallback, null);
}
19
View Source File : Program.cs
License : MIT License
Project Creator : 0xDivyanshu
License : MIT License
Project Creator : 0xDivyanshu
public bool IsTrue(string argument)
{
replacedertSingle(argument);
var arg = this[argument];
return arg != null && arg[0].Equals("true", StringComparison.OrdinalIgnoreCase);
}
19
View Source File : EntityMapperProvider.cs
License : Apache License 2.0
Project Creator : 1448376744
License : Apache License 2.0
Project Creator : 1448376744
public DataReaderCellInfo FindConstructorParameter(DataReaderCellInfo[] dataInfos, ParameterInfo parameterInfo)
{
foreach (var item in dataInfos)
{
if (item.DataName.Equals(parameterInfo.Name, StringComparison.OrdinalIgnoreCase))
{
return item;
}
else if (item.DataName.Replace("_", "").Equals(parameterInfo.Name, StringComparison.OrdinalIgnoreCase))
{
return item;
}
}
return null;
}
19
View Source File : EntityMapperProvider.cs
License : Apache License 2.0
Project Creator : 1448376744
License : Apache License 2.0
Project Creator : 1448376744
public MemberInfo FindMember(MemberInfo[] properties, DataReaderCellInfo dataInfo)
{
foreach (var item in properties)
{
if (item.Name.Equals(dataInfo.DataName, StringComparison.OrdinalIgnoreCase))
{
return item;
}
else if (item.Name.Equals(dataInfo.DataName.Replace("_", ""), StringComparison.OrdinalIgnoreCase))
{
return item;
}
}
return null;
}
19
View Source File : StringExtensions.cs
License : MIT License
Project Creator : 17MKH
License : MIT License
Project Creator : 17MKH
public static bool EqualsIgnoreCase(this string s, string value)
{
return s.Equals(value, StringComparison.OrdinalIgnoreCase);
}
19
View Source File : LProjectConfigurationPlatforms.cs
License : MIT License
Project Creator : 3F
License : MIT License
Project Creator : 3F
protected LineAttr GetAttribute(string raw)
{
if(raw.Equals("ActiveCfg", StringComparison.InvariantCulture)) {
return LineAttr.ActiveCfg;
}
if(raw.Equals("Build.0", StringComparison.InvariantCulture)) {
return LineAttr.Build0;
}
if(raw.Equals("Deploy.0", StringComparison.InvariantCulture)) {
return LineAttr.Deploy0;
}
return LineAttr.InvalidOrUnknown;
}
19
View Source File : PackagesConfig.cs
License : MIT License
Project Creator : 3F
License : MIT License
Project Creator : 3F
protected XElement Locate(string id, bool icase = false)
{
if(id == null) throw new ArgumentNullException(nameof(id));
StringComparison flag = icase ? StringComparison.OrdinalIgnoreCase : StringComparison.Ordinal;
return root.Elements().FirstOrDefault(p =>
id.Equals(GetAttr(PackageInfo.ATTR_ID, p), flag)
);
}
19
View Source File : DynamicInvoke.cs
License : GNU General Public License v3.0
Project Creator : 3xpl01tc0d3r
License : GNU General Public License v3.0
Project Creator : 3xpl01tc0d3r
public static IntPtr GetExportAddress(IntPtr ModuleBase, string ExportName)
{
IntPtr FunctionPtr = IntPtr.Zero;
try
{
Int32 PeHeader = Marshal.ReadInt32((IntPtr)(ModuleBase.ToInt64() + 0x3C));
Int16 OptHeaderSize = Marshal.ReadInt16((IntPtr)(ModuleBase.ToInt64() + PeHeader + 0x14));
Int64 OptHeader = ModuleBase.ToInt64() + PeHeader + 0x18;
Int16 Magic = Marshal.ReadInt16((IntPtr)OptHeader);
Int64 pExport = 0;
if (Magic == 0x010b)
{
pExport = OptHeader + 0x60;
}
else
{
pExport = OptHeader + 0x70;
}
Int32 ExportRVA = Marshal.ReadInt32((IntPtr)pExport);
Int32 OrdinalBase = Marshal.ReadInt32((IntPtr)(ModuleBase.ToInt64() + ExportRVA + 0x10));
Int32 NumberOfFunctions = Marshal.ReadInt32((IntPtr)(ModuleBase.ToInt64() + ExportRVA + 0x14));
Int32 NumberOfNames = Marshal.ReadInt32((IntPtr)(ModuleBase.ToInt64() + ExportRVA + 0x18));
Int32 FunctionsRVA = Marshal.ReadInt32((IntPtr)(ModuleBase.ToInt64() + ExportRVA + 0x1C));
Int32 NamesRVA = Marshal.ReadInt32((IntPtr)(ModuleBase.ToInt64() + ExportRVA + 0x20));
Int32 OrdinalsRVA = Marshal.ReadInt32((IntPtr)(ModuleBase.ToInt64() + ExportRVA + 0x24));
for (int i = 0; i < NumberOfNames; i++)
{
string FunctionName = Marshal.PtrToStringAnsi((IntPtr)(ModuleBase.ToInt64() + Marshal.ReadInt32((IntPtr)(ModuleBase.ToInt64() + NamesRVA + i * 4))));
if (FunctionName.Equals(ExportName, StringComparison.OrdinalIgnoreCase))
{
Int32 FunctionOrdinal = Marshal.ReadInt16((IntPtr)(ModuleBase.ToInt64() + OrdinalsRVA + i * 2)) + OrdinalBase;
Int32 FunctionRVA = Marshal.ReadInt32((IntPtr)(ModuleBase.ToInt64() + FunctionsRVA + (4 * (FunctionOrdinal - OrdinalBase))));
FunctionPtr = (IntPtr)((Int64)ModuleBase + FunctionRVA);
break;
}
}
}
catch
{
throw new InvalidOperationException("Failed to parse module exports.");
}
if (FunctionPtr == IntPtr.Zero)
{
throw new MissingMethodException(ExportName + ", export function not found.");
}
return FunctionPtr;
}
19
View Source File : AssemblyLoading.cs
License : MIT License
Project Creator : 71
License : MIT License
Project Creator : 71
private static replacedembly Resolving(replacedemblyLoadContext ctx, replacedemblyName replacedemblyName)
{
var compilation = CurrentCompilation;
if (Loaded.TryGetValue(replacedemblyName.Name, out replacedembly result))
return result;
if (compilation == null)
return null;
foreach (var reference in compilation.References)
{
if (!(reference is PortableExecutableReference pe) ||
!Path.GetFileNameWithoutExtension(pe.Display).Equals(replacedemblyName.Name, StringComparison.OrdinalIgnoreCase))
continue;
try
{
replacedembly replacedembly = LoadCore(ctx, pe.FilePath);
Loaded[replacedemblyName.Name] = replacedembly;
return replacedembly;
}
catch
{
// ReSharper disable once RedundantJumpStatement
continue;
}
}
return null;
}
19
View Source File : StringExtension.cs
License : GNU Lesser General Public License v3.0
Project Creator : 8720826
License : GNU Lesser General Public License v3.0
Project Creator : 8720826
public static bool Eq(this string input, string toCompare, StringComparison comparison = StringComparison.OrdinalIgnoreCase)
{
if (input == null)
{
return toCompare == null;
}
return input.Equals(toCompare, comparison);
}
19
View Source File : HTTP.cs
License : MIT License
Project Creator : 944095635
License : MIT License
Project Creator : 944095635
private byte[] GetByte()
{
byte[] ResponseByte = null;
using (MemoryStream _stream = new MemoryStream())
{
//GZIIP处理
if (response.ContentEncoding != null && response.ContentEncoding.Equals("gzip", StringComparison.InvariantCultureIgnoreCase))
{
//开始读取流并设置编码方式
new GZipStream(response.GetResponseStream(), CompressionMode.Decompress).CopyTo(_stream, 10240);
}
else
{
//开始读取流并设置编码方式
response.GetResponseStream().CopyTo(_stream, 10240);
}
//获取Byte
ResponseByte = _stream.ToArray();
}
return ResponseByte;
}
19
View Source File : Attributes.cs
License : Apache License 2.0
Project Creator : aadreja
License : Apache License 2.0
Project Creator : aadreja
public bool Equals(ColumnAttribute other)
{
if (!Name.Equals(other?.Name, StringComparison.OrdinalIgnoreCase) || ColumnDbType != other?.ColumnDbType) return false;
else return true;
}
19
View Source File : EntityCache.cs
License : Apache License 2.0
Project Creator : aadreja
License : Apache License 2.0
Project Creator : aadreja
internal static TableAttribute PrepareTableAttribute(Type enreplacedy)
{
TableAttribute result = (TableAttribute)enreplacedy.GetCustomAttributes(typeof(TableAttribute), false).FirstOrDefault();
if (result == null)
{
result = new TableAttribute
{
Name = enreplacedy.Name, //replaceduming enreplacedy clreplaced name is table name
NeedsHistory = Config.NeedsHistory,
NoCreatedBy = Config.NoCreatedBy,
NoCreatedOn = Config.NoCreatedOn,
NoUpdatedBy = Config.NoUpdatedBy,
NoUpdatedOn = Config.NoUpdatedOn,
NoVersionNo = Config.NoVersionNo,
NoIsActive = Config.NoIsActive
};
}
if (string.IsNullOrEmpty(result.Name)) result.Name = enreplacedy.Name;
//find all properties
var properties = enreplacedy.GetProperties(BindingFlags.Public | BindingFlags.Instance);
foreach (PropertyInfo property in properties)
{
//TODO: check for valid property types to be added in list
if ((property.Name.Equals("keyid", StringComparison.OrdinalIgnoreCase) ||
property.Name.Equals("operation", StringComparison.OrdinalIgnoreCase)))
continue;
//check for ignore property attribute
var ignoreInfo = (IgnoreColumnAttribute)property.GetCustomAttribute(typeof(IgnoreColumnAttribute));
var primaryKey = (PrimaryKeyAttribute)property.GetCustomAttribute(typeof(PrimaryKeyAttribute));
var column = (ColumnAttribute)property.GetCustomAttribute(typeof(ColumnAttribute));
if (column == null) column = new ColumnAttribute();
if (string.IsNullOrEmpty(column.Name)) column.Name = property.Name;
if (property.Name.Equals("CreatedBy", StringComparison.OrdinalIgnoreCase))
column.Name = Config.CreatedByColumnName;
else if (property.Name.Equals("CreatedByName"))
column.Name = Config.CreatedByNameColumnName;
else if (property.Name.Equals("CreatedOn"))
column.Name = Config.CreatedOnColumnName;
else if (property.Name.Equals("UpdatedBy"))
column.Name = Config.UpdatedByColumnName;
else if (property.Name.Equals("UpdatedByName"))
column.Name = Config.UpdatedByNameColumnName;
else if (property.Name.Equals("UpdatedOn"))
column.Name = Config.UpdatedOnColumnName;
else if (property.Name.Equals("VersionNo"))
column.Name = Config.VersionNoColumnName;
else if (property.Name.Equals("IsActive"))
column.Name = Config.IsActiveColumnName;
if (!column.IsColumnDbTypeDefined)
{
if (column.Name.Equals(Config.CreatedByColumnName, StringComparison.OrdinalIgnoreCase) ||
column.Name.Equals(Config.UpdatedByColumnName, StringComparison.OrdinalIgnoreCase))
column.ColumnDbType = Config.CreatedUpdatedByColumnType;
else if (property.PropertyType.IsEnum)
column.ColumnDbType = TypeCache.TypeToDbType[property.PropertyType.GetEnumUnderlyingType()];
else if (property.PropertyType.IsValueType)
column.ColumnDbType = TypeCache.TypeToDbType[property.PropertyType];
else
{
TypeCache.TypeToDbType.TryGetValue(property.PropertyType, out DbType columnDbType);
column.ColumnDbType = columnDbType;
}
}
column.SetPropertyInfo(property, enreplacedy);
column.IgnoreInfo = ignoreInfo ?? new IgnoreColumnAttribute(false);
//Primary Key details
if (primaryKey != null)
{
column.PrimaryKeyInfo = primaryKey;
var virtualForeignKeys = (IEnumerable<ForeignKey>)property.GetCustomAttributes(typeof(ForeignKey));
if (virtualForeignKeys != null && virtualForeignKeys.Count() > 0)
{
if (result.VirtualForeignKeys == null) result.VirtualForeignKeys = new List<ForeignKey>();
result.VirtualForeignKeys.AddRange(virtualForeignKeys);
}
}
if (result.NoCreatedBy && (column.Name.Equals(Config.CreatedByColumnName, StringComparison.OrdinalIgnoreCase)
|| column.Name.Equals(Config.CreatedByNameColumnName, StringComparison.OrdinalIgnoreCase)))
continue;
else if (result.NoCreatedOn && column.Name.Equals(Config.CreatedOnColumnName, StringComparison.OrdinalIgnoreCase))
continue;
else if (result.NoUpdatedBy && ((column.Name.Equals(Config.UpdatedByColumnName, StringComparison.OrdinalIgnoreCase)
|| column.Name.Equals(Config.UpdatedByNameColumnName, StringComparison.OrdinalIgnoreCase))))
continue;
else if (result.NoUpdatedOn && column.Name.Equals(Config.UpdatedOnColumnName, StringComparison.OrdinalIgnoreCase))
continue;
else if (result.NoIsActive && column.Name.Equals(Config.IsActiveColumnName, StringComparison.OrdinalIgnoreCase))
continue;
else if (result.NoVersionNo && column.Name.Equals(Config.VersionNoColumnName, StringComparison.OrdinalIgnoreCase))
continue;
else
{
if (!column.IgnoreInfo.Insert)
result.DefaultInsertColumns.Add(column.Name);
//isactive,createdon,createdby column shall not be included in default update columns
if (!column.IgnoreInfo.Update
&& !column.Name.Equals(Config.IsActiveColumnName, StringComparison.OrdinalIgnoreCase)
&& !column.Name.Equals(Config.CreatedByColumnName, StringComparison.OrdinalIgnoreCase)
&& !column.Name.Equals(Config.CreatedOnColumnName, StringComparison.OrdinalIgnoreCase))
result.DefaultUpdateColumns.Add(column.Name);
if (!column.IgnoreInfo.Read)
result.DefaultReadColumns.Add(column.Name);
result.Columns[column.Name] = column;
}
}
if(result.Columns.LongCount(p=>p.Value.IsPrimaryKey && p.Value.PrimaryKeyInfo.IsIdenreplacedy) > 1)
{
throw new NotSupportedException("Primary key with multiple Idenreplacedy is not supported on " + result.Name);
}
if (result.Columns.LongCount(p => p.Value.IsPrimaryKey) > 1 && result.NeedsHistory)
{
throw new NotSupportedException($"History for {result.Name} is not supported as it has composite Primary key");
}
return result;
}
19
View Source File : StringExtensions.cs
License : MIT License
Project Creator : Abdulrhman5
License : MIT License
Project Creator : Abdulrhman5
public static bool EqualsIC(this string value, string value2)
{
return value.Equals(value2, StringComparison.OrdinalIgnoreCase);
}
19
View Source File : PathHelper.cs
License : MIT License
Project Creator : absurd-joy
License : MIT License
Project Creator : absurd-joy
public static string MakeRelativePath(string fromPath, string toPath)
{
var fromUri = new Uri(Path.GetFullPath(fromPath));
var toUri = new Uri(Path.GetFullPath(toPath));
if (fromUri.Scheme != toUri.Scheme)
{
return toPath;
}
var relativeUri = fromUri.MakeRelativeUri(toUri);
var relativePath = Uri.UnescapeDataString(relativeUri.ToString());
if (toUri.Scheme.Equals("file", StringComparison.InvariantCultureIgnoreCase))
{
relativePath = relativePath.Replace(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar);
}
return relativePath;
}
19
View Source File : IOExtensions.cs
License : MIT License
Project Creator : Accelerider
License : MIT License
Project Creator : Accelerider
public static long GetLocalDiskAvailableFreeSpace(this string path)
{
var targetDriveName = Directory.GetDirectoryRoot(path);
return DriveInfo
.GetDrives()
.FirstOrDefault(item => item.Name.Equals(targetDriveName, StringComparison.InvariantCultureIgnoreCase))?
.AvailableFreeSpace ?? 0L;
}
19
View Source File : FileDownloaderBuilder.cs
License : MIT License
Project Creator : Accelerider
License : MIT License
Project Creator : Accelerider
public IDownloaderBuilder To(string path)
{
Guards.ThrowIfNullOrEmpty(path);
if (!path.Equals(_localPath, StringComparison.InvariantCultureIgnoreCase))
{
_localPath = path;
}
return this;
}
19
View Source File : PlayerCommands.cs
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator
[CommandHandler("castmeter", AccessLevel.Player, CommandHandlerFlag.RequiresWorld, "Shows the fast casting efficiency meter")]
public static void HandleCastMeter(Session session, params string[] parameters)
{
if (parameters.Length == 0)
{
session.Player.MagicState.CastMeter = !session.Player.MagicState.CastMeter;
}
else
{
if (parameters[0].Equals("on", StringComparison.OrdinalIgnoreCase))
session.Player.MagicState.CastMeter = true;
else
session.Player.MagicState.CastMeter = false;
}
session.Network.EnqueueSend(new GameMessageSystemChat($"Cast efficiency meter {(session.Player.MagicState.CastMeter ? "enabled" : "disabled")}", ChatMessageType.Broadcast));
}
19
View Source File : PlayerCommands.cs
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator
[CommandHandler("config", AccessLevel.Player, CommandHandlerFlag.RequiresWorld, 1, "Manually sets a character option on the server.\nUse /config list to see a list of settings.", "<setting> <on/off>")]
public static void HandleConfig(Session session, params string[] parameters)
{
if (!PropertyManager.GetBool("player_config_command").Item)
{
session.Network.EnqueueSend(new GameMessageSystemChat("The command \"config\" is not currently enabled on this server.", ChatMessageType.Broadcast));
return;
}
// /config list - show character options
if (parameters[0].Equals("list", StringComparison.OrdinalIgnoreCase))
{
foreach (var line in configList)
session.Network.EnqueueSend(new GameMessageSystemChat(line, ChatMessageType.Broadcast));
return;
}
// translate GDLE CharacterOptions for existing plugins
if (!translateOptions.TryGetValue(parameters[0], out var param) || !Enum.TryParse(param, out CharacterOption characterOption))
{
session.Network.EnqueueSend(new GameMessageSystemChat($"Unknown character option: {parameters[0]}", ChatMessageType.Broadcast));
return;
}
var option = session.Player.GetCharacterOption(characterOption);
// modes of operation:
// on / off / toggle
// - if none specified, default to toggle
var mode = "toggle";
if (parameters.Length > 1)
{
if (parameters[1].Equals("on", StringComparison.OrdinalIgnoreCase))
mode = "on";
else if (parameters[1].Equals("off", StringComparison.OrdinalIgnoreCase))
mode = "off";
}
// set character option
if (mode.Equals("on"))
option = true;
else if (mode.Equals("off"))
option = false;
else
option = !option;
session.Player.SetCharacterOption(characterOption, option);
session.Network.EnqueueSend(new GameMessageSystemChat($"Character option {parameters[0]} is now {(option ? "on" : "off")}.", ChatMessageType.Broadcast));
// update client
session.Network.EnqueueSend(new GameEventPlayerDescription(session));
}
19
View Source File : EventManager.cs
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator
public static bool StartEvent(string e, WorldObject source, WorldObject target)
{
var eventName = GetEventName(e);
if (eventName.Equals("EventIsPKWorld", StringComparison.OrdinalIgnoreCase)) // special event
return false;
if (!Events.TryGetValue(eventName, out Event evnt))
return false;
var state = (GameEventState)evnt.State;
if (state == GameEventState.Disabled)
return false;
if (state == GameEventState.Enabled || state == GameEventState.Off)
{
evnt.State = (int)GameEventState.On;
if (Debug)
Console.WriteLine($"Starting event {evnt.Name}");
}
log.Debug($"[EVENT] {(source == null ? "SYSTEM" : $"{source.Name} (0x{source.Guid}|{source.WeenieClreplacedId})")}{(target == null ? "" : $", triggered by {target.Name} (0x{target.Guid}|{target.WeenieClreplacedId}),")} started an event: {evnt.Name}{((int)state == evnt.State ? (source == null ? ", which is the default state for this event." : ", which had already been started.") : "")}");
return true;
}
19
View Source File : EventManager.cs
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator
public static bool StopEvent(string e, WorldObject source, WorldObject target)
{
var eventName = GetEventName(e);
if (eventName.Equals("EventIsPKWorld", StringComparison.OrdinalIgnoreCase)) // special event
return false;
if (!Events.TryGetValue(eventName, out Event evnt))
return false;
var state = (GameEventState)evnt.State;
if (state == GameEventState.Disabled)
return false;
if (state == GameEventState.Enabled || state == GameEventState.On)
{
evnt.State = (int)GameEventState.Off;
if (Debug)
Console.WriteLine($"Stopping event {evnt.Name}");
}
log.Debug($"[EVENT] {(source == null ? "SYSTEM" : $"{source.Name} (0x{source.Guid}|{source.WeenieClreplacedId})")}{(target == null ? "" : $", triggered by {target.Name} (0x{target.Guid}|{target.WeenieClreplacedId}),")} stopped an event: {evnt.Name}{((int)state == evnt.State ? (source == null ? ", which is the default state for this event." : ", which had already been stopped.") : "")}");
return true;
}
19
View Source File : EventManager.cs
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator
public static GameEventState GetEventStatus(string e)
{
var eventName = GetEventName(e);
if (eventName.Equals("EventIsPKWorld", StringComparison.OrdinalIgnoreCase)) // special event
{
if (PropertyManager.GetBool("pk_server").Item)
return GameEventState.On;
else
return GameEventState.Off;
}
if (!Events.TryGetValue(eventName, out Event evnt))
return GameEventState.Undef;
return (GameEventState)evnt.State;
}
19
View Source File : EventManager.cs
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator
public static bool IsEventStarted(string e, WorldObject source, WorldObject target)
{
var eventName = GetEventName(e);
if (eventName.Equals("EventIsPKWorld", StringComparison.OrdinalIgnoreCase)) // special event
{
var serverPkState = PropertyManager.GetBool("pk_server").Item;
return serverPkState;
}
if (!Events.TryGetValue(eventName, out Event evnt))
return false;
if (evnt.State != (int)GameEventState.Disabled && (evnt.StartTime != -1 || evnt.EndTime != -1))
{
var prevState = (GameEventState)evnt.State;
var now = (int)Time.GetUnixTime();
var start = (now > evnt.StartTime) && (evnt.StartTime > -1);
var end = (now > evnt.EndTime) && (evnt.EndTime > -1);
if (prevState == GameEventState.On && end)
return !StopEvent(evnt.Name, source, target);
else if ((prevState == GameEventState.Off || prevState == GameEventState.Enabled) && start && !end)
return StartEvent(evnt.Name, source, target);
}
return evnt.State == (int)GameEventState.On;
}
19
View Source File : Lock.cs
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator
public static UnlockResults Unlock(WorldObject target, Key key, string keyCode = null)
{
if (keyCode == null)
keyCode = key?.KeyCode;
string myLockCode = GetLockCode(target);
if (myLockCode == null) return UnlockResults.IncorrectKey;
if (target.IsOpen)
return UnlockResults.Open;
// there is only 1 instance of an 'opens all' key in PY16 data, 'keysonicscrewdriver'
// which uses keyCode '_bohemund's_magic_key_'
// when LSD added the rare skeleton key (keyrarevolatileuniversal),
// they used PropertyBool.OpensAnyLock, which appears to have been used for something else in retail on Writables:
// https://github.com/ACEmulator/ACE-World-16PY/blob/master/Database/3-Core/9%20WeenieDefaults/SQL/Key/Key/09181%20Sonic%20Screwdriver.sql
// https://github.com/ACEmulator/ACE-World-16PY/search?q=OpensAnyLock
if (keyCode != null && (keyCode.Equals(myLockCode, StringComparison.OrdinalIgnoreCase) || keyCode.Equals("_bohemund's_magic_key_")) ||
key != null && key.OpensAnyLock)
{
if (!target.IsLocked)
return UnlockResults.AlreadyUnlocked;
target.IsLocked = false;
var updateProperty = new GameMessagePublicUpdatePropertyBool(target, PropertyBool.Locked, target.IsLocked);
var sound = new GameMessageSound(target.Guid, Sound.LockSuccess, 1.0f);
target.EnqueueBroadcast(updateProperty, sound);
return UnlockResults.UnlockSuccess;
}
return UnlockResults.IncorrectKey;
}
19
View Source File : Program_Setup.cs
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator
private static void DoOutOfBoxSetup(string configFile)
{
var exeLocation = Path.GetDirectoryName(System.Reflection.replacedembly.GetExecutingreplacedembly().Location);
var configJsExample = Path.Combine(exeLocation, "Config.js.example");
var exampleFile = new FileInfo(configJsExample);
if (!exampleFile.Exists)
{
log.Error("config.js.example Configuration file is missing. Please copy the file config.js.example to config.js and edit it to match your needs before running ACE.");
throw new Exception("missing config.js configuration file");
}
else
{
if (!IsRunningInContainer)
{
Console.WriteLine("config.js Configuration file is missing, cloning from example file.");
File.Copy(configJsExample, configFile, true);
}
else
{
Console.WriteLine("config.js Configuration file is missing, ACEmulator is running in a container, cloning from docker file.");
var configJsDocker = Path.Combine(exeLocation, "Config.js.docker");
File.Copy(configJsDocker, configFile, true);
}
}
var fileText = File.ReadAllText(configFile);
var config = JsonConvert.DeserializeObject<MasterConfiguration>(new JsMinifier().Minify(fileText));
Console.WriteLine("Performing setup for ACEmulator...");
Console.WriteLine();
Console.WriteLine();
Console.WriteLine();
Console.WriteLine("Welcome to ACEmulator! To configure your world for first use, please follow the instructions below. Press enter at each prompt to accept default values.");
Console.WriteLine();
Console.WriteLine();
Console.Write($"Enter the name for your World (default: \"{config.Server.WorldName}\"): ");
var variable = Console.ReadLine();
if (IsRunningInContainer) variable = Environment.GetEnvironmentVariable("ACE_WORLD_NAME");
if (!string.IsNullOrWhiteSpace(variable))
config.Server.WorldName = variable.Trim();
Console.WriteLine();
Console.WriteLine();
Console.WriteLine();
Console.WriteLine("The next two entries should use defaults, unless you have specific network environments...");
Console.WriteLine();
Console.WriteLine();
Console.Write($"Enter the Host address for your World (default: \"{config.Server.Network.Host}\"): ");
variable = Console.ReadLine();
if (!string.IsNullOrWhiteSpace(variable))
config.Server.Network.Host = variable.Trim();
Console.WriteLine();
Console.Write($"Enter the Port for your World (default: \"{config.Server.Network.Port}\"): ");
variable = Console.ReadLine();
if (!string.IsNullOrWhiteSpace(variable))
config.Server.Network.Port = Convert.ToUInt32(variable.Trim());
Console.WriteLine();
Console.WriteLine();
Console.WriteLine();
Console.Write($"Enter the directory location for your DAT files (default: \"{config.Server.DatFilesDirectory}\"): ");
variable = Console.ReadLine();
if (IsRunningInContainer) variable = Environment.GetEnvironmentVariable("ACE_DAT_FILES_DIRECTORY");
if (!string.IsNullOrWhiteSpace(variable))
{
var path = Path.GetFullPath(variable.Trim());
if (!Path.EndsInDirectorySeparator(path))
path += Path.DirectorySeparatorChar;
//path = path.Replace($"{Path.DirectorySeparatorChar}", $"{Path.DirectorySeparatorChar}{Path.DirectorySeparatorChar}");
config.Server.DatFilesDirectory = path;
}
Console.WriteLine();
Console.WriteLine();
Console.WriteLine();
Console.WriteLine("Next we will configure your SQL server connections. You will need to know your database name, username and preplacedword for each.");
Console.WriteLine("Default names for the databases are recommended, and it is also recommended you not use root for login to database. The preplacedword must not be blank.");
Console.WriteLine("It is also recommended the SQL server be hosted on the same machine as this server, so defaults for Host and Port would be ideal as well.");
Console.WriteLine("As before, pressing enter will use default value.");
Console.WriteLine();
Console.WriteLine();
Console.Write($"Enter the database name for your authentication database (default: \"{config.MySql.Authentication.Database}\"): ");
variable = Console.ReadLine();
if (IsRunningInContainer) variable = Environment.GetEnvironmentVariable("ACE_SQL_AUTH_DATABASE_NAME");
if (!string.IsNullOrWhiteSpace(variable))
config.MySql.Authentication.Database = variable.Trim();
Console.WriteLine();
Console.Write($"Enter the database name for your shard database (default: \"{config.MySql.Shard.Database}\"): ");
variable = Console.ReadLine();
if (IsRunningInContainer) variable = Environment.GetEnvironmentVariable("ACE_SQL_SHARD_DATABASE_NAME");
if (!string.IsNullOrWhiteSpace(variable))
config.MySql.Shard.Database = variable.Trim();
Console.WriteLine();
Console.Write($"Enter the database name for your world database (default: \"{config.MySql.World.Database}\"): ");
variable = Console.ReadLine();
if (IsRunningInContainer) variable = Environment.GetEnvironmentVariable("ACE_SQL_WORLD_DATABASE_NAME");
if (!string.IsNullOrWhiteSpace(variable))
config.MySql.World.Database = variable.Trim();
Console.WriteLine();
Console.WriteLine();
Console.WriteLine();
Console.Write("Typically, all three databases will be on the same SQL server, is this how you want to proceed? (Y/n) ");
variable = Console.ReadLine();
if (IsRunningInContainer) variable = "n";
if (!variable.Equals("n", StringComparison.OrdinalIgnoreCase) && !variable.Equals("no", StringComparison.OrdinalIgnoreCase))
{
Console.Write($"Enter the Host address for your SQL server (default: \"{config.MySql.World.Host}\"): ");
variable = Console.ReadLine();
if (!string.IsNullOrWhiteSpace(variable))
{
config.MySql.Authentication.Host = variable.Trim();
config.MySql.Shard.Host = variable.Trim();
config.MySql.World.Host = variable.Trim();
}
Console.WriteLine();
Console.Write($"Enter the Port for your SQL server (default: \"{config.MySql.World.Port}\"): ");
variable = Console.ReadLine();
if (!string.IsNullOrWhiteSpace(variable))
{
config.MySql.Authentication.Port = Convert.ToUInt32(variable.Trim());
config.MySql.Shard.Port = Convert.ToUInt32(variable.Trim());
config.MySql.World.Port = Convert.ToUInt32(variable.Trim());
}
Console.WriteLine();
}
else
{
Console.Write($"Enter the Host address for your authentication database (default: \"{config.MySql.Authentication.Host}\"): ");
variable = Console.ReadLine();
if (IsRunningInContainer) variable = Environment.GetEnvironmentVariable("ACE_SQL_AUTH_DATABASE_HOST");
if (!string.IsNullOrWhiteSpace(variable))
config.MySql.Authentication.Host = variable.Trim();
Console.WriteLine();
Console.Write($"Enter the Port for your authentication database (default: \"{config.MySql.Authentication.Port}\"): ");
variable = Console.ReadLine();
if (IsRunningInContainer) variable = Environment.GetEnvironmentVariable("ACE_SQL_AUTH_DATABASE_PORT");
if (!string.IsNullOrWhiteSpace(variable))
config.MySql.Authentication.Port = Convert.ToUInt32(variable.Trim());
Console.WriteLine();
Console.Write($"Enter the Host address for your shard database (default: \"{config.MySql.Shard.Host}\"): ");
variable = Console.ReadLine();
if (IsRunningInContainer) variable = Environment.GetEnvironmentVariable("ACE_SQL_SHARD_DATABASE_HOST");
if (!string.IsNullOrWhiteSpace(variable))
config.MySql.Shard.Host = variable.Trim();
Console.WriteLine();
Console.Write($"Enter the Port for your shard database (default: \"{config.MySql.Shard.Port}\"): ");
variable = Console.ReadLine();
if (IsRunningInContainer) variable = Environment.GetEnvironmentVariable("ACE_SQL_SHARD_DATABASE_PORT");
if (!string.IsNullOrWhiteSpace(variable))
config.MySql.Shard.Port = Convert.ToUInt32(variable.Trim());
Console.WriteLine();
Console.Write($"Enter the Host address for your world database (default: \"{config.MySql.World.Host}\"): ");
variable = Console.ReadLine();
if (IsRunningInContainer) variable = Environment.GetEnvironmentVariable("ACE_SQL_WORLD_DATABASE_HOST");
if (!string.IsNullOrWhiteSpace(variable))
config.MySql.World.Host = variable.Trim();
Console.WriteLine();
Console.Write($"Enter the Port for your world database (default: \"{config.MySql.World.Port}\"): ");
variable = Console.ReadLine();
if (IsRunningInContainer) variable = Environment.GetEnvironmentVariable("ACE_SQL_WORLD_DATABASE_PORT");
if (!string.IsNullOrWhiteSpace(variable))
config.MySql.World.Port = Convert.ToUInt32(variable.Trim());
Console.WriteLine();
}
Console.WriteLine();
Console.WriteLine();
Console.Write("Typically, all three databases will be on the using the same SQL server credentials, is this how you want to proceed? (Y/n) ");
variable = Console.ReadLine();
if (IsRunningInContainer) variable = "y";
if (!variable.Equals("n", StringComparison.OrdinalIgnoreCase) && !variable.Equals("no", StringComparison.OrdinalIgnoreCase))
{
Console.Write($"Enter the username for your SQL server (default: \"{config.MySql.World.Username}\"): ");
variable = Console.ReadLine();
if (IsRunningInContainer) variable = Environment.GetEnvironmentVariable("MYSQL_USER");
if (!string.IsNullOrWhiteSpace(variable))
{
config.MySql.Authentication.Username = variable.Trim();
config.MySql.Shard.Username = variable.Trim();
config.MySql.World.Username = variable.Trim();
}
Console.WriteLine();
Console.Write($"Enter the preplacedword for your SQL server (default: \"{config.MySql.World.Preplacedword}\"): ");
variable = Console.ReadLine();
if (IsRunningInContainer) variable = Environment.GetEnvironmentVariable("MYSQL_PreplacedWORD");
if (!string.IsNullOrWhiteSpace(variable))
{
config.MySql.Authentication.Preplacedword = variable.Trim();
config.MySql.Shard.Preplacedword = variable.Trim();
config.MySql.World.Preplacedword = variable.Trim();
}
}
else
{
Console.Write($"Enter the username for your authentication database (default: \"{config.MySql.Authentication.Username}\"): ");
variable = Console.ReadLine();
if (!string.IsNullOrWhiteSpace(variable))
config.MySql.Authentication.Username = variable.Trim();
Console.WriteLine();
Console.Write($"Enter the preplacedword for your authentication database (default: \"{config.MySql.Authentication.Preplacedword}\"): ");
variable = Console.ReadLine();
if (!string.IsNullOrWhiteSpace(variable))
config.MySql.Authentication.Preplacedword = variable.Trim();
Console.WriteLine();
Console.Write($"Enter the username for your shard database (default: \"{config.MySql.Shard.Username}\"): ");
variable = Console.ReadLine();
if (!string.IsNullOrWhiteSpace(variable))
config.MySql.Shard.Username = variable.Trim();
Console.WriteLine();
Console.Write($"Enter the preplacedword for your shard database (default: \"{config.MySql.Shard.Preplacedword}\"): ");
variable = Console.ReadLine();
if (!string.IsNullOrWhiteSpace(variable))
config.MySql.Shard.Preplacedword = variable.Trim();
Console.WriteLine();
Console.Write($"Enter the username for your world database (default: \"{config.MySql.World.Username}\"): ");
variable = Console.ReadLine();
if (!string.IsNullOrWhiteSpace(variable))
config.MySql.World.Username = variable.Trim();
Console.WriteLine();
Console.Write($"Enter the preplacedword for your world database (default: \"{config.MySql.World.Preplacedword}\"): ");
variable = Console.ReadLine();
if (!string.IsNullOrWhiteSpace(variable))
config.MySql.World.Preplacedword = variable.Trim();
}
Console.WriteLine("commiting configuration to memory...");
using (StreamWriter file = File.CreateText(configFile))
{
JsonSerializer serializer = new JsonSerializer();
serializer.Formatting = Formatting.Indented;
//serializer.NullValueHandling = NullValueHandling.Ignore;
//serializer.DefaultValueHandling = DefaultValueHandling.Ignore;
serializer.Serialize(file, config);
}
Console.WriteLine();
Console.WriteLine();
Console.WriteLine();
Console.WriteLine();
Console.Write("Do you want to ACEmulator to attempt to initilize your SQL databases? This will erase any existing ACEmulator specific databases that may already exist on the server (Y/n): ");
variable = Console.ReadLine();
if (IsRunningInContainer) variable = Convert.ToBoolean(Environment.GetEnvironmentVariable("ACE_SQL_INITIALIZE_DATABASES")) ? "y" : "n";
if (!variable.Equals("n", StringComparison.OrdinalIgnoreCase) && !variable.Equals("no", StringComparison.OrdinalIgnoreCase))
{
Console.WriteLine();
Console.Write($"Waiting for connection to SQL server at {config.MySql.World.Host}:{config.MySql.World.Port} .... ");
for (; ; )
{
try
{
using (var sqlTestConnection = new MySql.Data.MySqlClient.MySqlConnection($"server={config.MySql.World.Host};port={config.MySql.World.Port};user={config.MySql.World.Username};preplacedword={config.MySql.World.Preplacedword};DefaultCommandTimeout=120"))
{
Console.Write(".");
sqlTestConnection.Open();
}
break;
}
catch (MySql.Data.MySqlClient.MySqlException)
{
Console.Write(".");
Thread.Sleep(5000);
}
}
Console.WriteLine(" connected!");
if (IsRunningInContainer)
{
Console.Write("Clearing out temporary ace% database .... ");
var sqlDBFile = "DROP DATABASE `ace%`;";
var sqlConnectInfo = $"server={config.MySql.World.Host};port={config.MySql.World.Port};user={config.MySql.World.Username};preplacedword={config.MySql.World.Preplacedword};DefaultCommandTimeout=120";
var sqlConnect = new MySql.Data.MySqlClient.MySqlConnection(sqlConnectInfo);
var script = new MySql.Data.MySqlClient.MySqlScript(sqlConnect, sqlDBFile);
Console.Write($"Importing into SQL server at {config.MySql.World.Host}:{config.MySql.World.Port} .... ");
try
{
script.StatementExecuted += new MySql.Data.MySqlClient.MySqlStatementExecutedEventHandler(OnStatementExecutedOutputDot);
var count = script.Execute();
}
catch (MySql.Data.MySqlClient.MySqlException)
{
}
Console.WriteLine(" done!");
}
Console.WriteLine("Searching for base SQL scripts .... ");
foreach (var file in new DirectoryInfo($"DatabaseSetupScripts{Path.DirectorySeparatorChar}Base").GetFiles("*.sql").OrderBy(f => f.Name))
{
Console.Write($"Found {file.Name} .... ");
var sqlDBFile = File.ReadAllText(file.FullName);
var sqlConnectInfo = $"server={config.MySql.World.Host};port={config.MySql.World.Port};user={config.MySql.World.Username};preplacedword={config.MySql.World.Preplacedword};DefaultCommandTimeout=120";
switch (file.Name)
{
case "AuthenticationBase":
sqlConnectInfo = $"server={config.MySql.Authentication.Host};port={config.MySql.Authentication.Port};user={config.MySql.Authentication.Username};preplacedword={config.MySql.Authentication.Preplacedword};DefaultCommandTimeout=120";
break;
case "ShardBase":
sqlConnectInfo = $"server={config.MySql.Shard.Host};port={config.MySql.Shard.Port};user={config.MySql.Shard.Username};preplacedword={config.MySql.Shard.Preplacedword};DefaultCommandTimeout=120";
break;
}
var sqlConnect = new MySql.Data.MySqlClient.MySqlConnection(sqlConnectInfo);
var script = new MySql.Data.MySqlClient.MySqlScript(sqlConnect, sqlDBFile);
Console.Write($"Importing into SQL server at {config.MySql.World.Host}:{config.MySql.World.Port} .... ");
try
{
script.StatementExecuted += new MySql.Data.MySqlClient.MySqlStatementExecutedEventHandler(OnStatementExecutedOutputDot);
var count = script.Execute();
}
catch (MySql.Data.MySqlClient.MySqlException)
{
}
Console.WriteLine(" complete!");
}
Console.WriteLine("Base SQL scripts import complete!");
Console.WriteLine("Searching for Update SQL scripts .... ");
PatchDatabase("Authentication", config.MySql.Authentication.Host, config.MySql.Authentication.Port, config.MySql.Authentication.Username, config.MySql.Authentication.Preplacedword, config.MySql.Authentication.Database);
PatchDatabase("Shard", config.MySql.Shard.Host, config.MySql.Shard.Port, config.MySql.Shard.Username, config.MySql.Shard.Preplacedword, config.MySql.Shard.Database);
PatchDatabase("World", config.MySql.World.Host, config.MySql.World.Port, config.MySql.World.Username, config.MySql.World.Preplacedword, config.MySql.World.Database);
}
Console.WriteLine();
Console.WriteLine();
Console.WriteLine();
Console.WriteLine();
Console.Write("Do you want to download the latest world database and import it? (Y/n): ");
variable = Console.ReadLine();
if (IsRunningInContainer) variable = Convert.ToBoolean(Environment.GetEnvironmentVariable("ACE_SQL_DOWNLOAD_LATEST_WORLD_RELEASE")) ? "y" : "n";
if (!variable.Equals("n", StringComparison.OrdinalIgnoreCase) && !variable.Equals("no", StringComparison.OrdinalIgnoreCase))
{
Console.WriteLine();
if (IsRunningInContainer)
{
Console.WriteLine(" ");
Console.WriteLine("This process will take a while, depending on many factors, and may look stuck while reading and importing the world database, please be patient! ");
Console.WriteLine(" ");
}
Console.Write("Looking up latest release from ACEmulator/ACE-World-16PY-Patches .... ");
// webrequest code provided by OptimShi
var url = "https://api.github.com/repos/ACEmulator/ACE-World-16PY-Patches/releases";
var request = (HttpWebRequest)WebRequest.Create(url);
request.UserAgent = "Mozilla//5.0 (Windows NT 10.0; Win64; x64; rv:72.0) Gecko//20100101 Firefox//72.0";
request.UserAgent = "ACE.Server";
var response = request.GetResponse();
var reader = new StreamReader(response.GetResponseStream(), System.Text.Encoding.UTF8);
var html = reader.ReadToEnd();
reader.Close();
response.Close();
dynamic json = JsonConvert.DeserializeObject(html);
string tag = json[0].tag_name;
string dbURL = json[0].replacedets[0].browser_download_url;
string dbFileName = json[0].replacedets[0].name;
// webrequest code provided by OptimShi
Console.WriteLine($"Found {tag} !");
Console.Write($"Downloading {dbFileName} .... ");
using (var client = new WebClient())
{
client.DownloadFile(dbURL, dbFileName);
}
Console.WriteLine("download complete!");
Console.Write($"Extracting {dbFileName} .... ");
ZipFile.ExtractToDirectory(dbFileName, ".", true);
Console.WriteLine("extraction complete!");
Console.Write($"Deleting {dbFileName} .... ");
File.Delete(dbFileName);
Console.WriteLine("Deleted!");
var sqlFile = dbFileName.Substring(0, dbFileName.Length - 4);
Console.Write($"Importing {sqlFile} into SQL server at {config.MySql.World.Host}:{config.MySql.World.Port} (This will take a while, please be patient) .... ");
using (var sr = File.OpenText(sqlFile))
{
var sqlConnect = new MySql.Data.MySqlClient.MySqlConnection($"server={config.MySql.World.Host};port={config.MySql.World.Port};user={config.MySql.World.Username};preplacedword={config.MySql.World.Preplacedword};DefaultCommandTimeout=120");
var line = string.Empty;
var completeSQLline = string.Empty;
while ((line = sr.ReadLine()) != null)
{
//do minimal amount of work here
if (line.EndsWith(";"))
{
completeSQLline += line + Environment.NewLine;
var script = new MySql.Data.MySqlClient.MySqlScript(sqlConnect, completeSQLline);
try
{
script.StatementExecuted += new MySql.Data.MySqlClient.MySqlStatementExecutedEventHandler(OnStatementExecutedOutputDot);
var count = script.Execute();
}
catch (MySql.Data.MySqlClient.MySqlException)
{
}
completeSQLline = string.Empty;
}
else
completeSQLline += line + Environment.NewLine;
}
}
Console.WriteLine(" complete!");
Console.Write($"Deleting {sqlFile} .... ");
File.Delete(sqlFile);
Console.WriteLine("Deleted!");
}
Console.WriteLine("exiting setup for ACEmulator.");
}
19
View Source File : SheetFilter.cs
License : GNU Lesser General Public License v3.0
Project Creator : acnicholas
License : GNU Lesser General Public License v3.0
Project Creator : acnicholas
public Predicate<object> GetFilter()
{
string properyName = FilterPropertyName;
switch (FilterPropertyName)
{
case "Export Name":
var m = FirstDigitOfLastNumberInString(FilterValue);
if (m == null)
{
return null;
}
return item => m == FirstDigitOfLastNumberInString((item as ExportSheet).FullExportName);
case "Number":
var n = FirstDigitOfLastNumberInString(FilterValue);
if (n == null)
{
return null;
}
return item => n == FirstDigitOfLastNumberInString((item as ExportSheet).SheetNumber);
case "Name":
properyName = "SheetDescription";
var noNumbers = Regex.Replace(FilterValue, "[0-9-]", @" ");
string[] parts = noNumbers.Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries);
return item => parts.Any(item.GetType().GetProperty(properyName).GetValue(item, null).ToString().Contains);
case "Revision":
properyName = "SheetRevision";
break;
case "Revision Description":
properyName = "SheetRevisionDescription";
break;
case "Revision Date":
properyName = "SheetRevisionDate";
break;
case "Scale":
properyName = "Scale";
break;
case "North Point":
properyName = "NorthPointVisibilityString";
break;
default:
return null;
}
return item => item.GetType().GetProperty(properyName).GetValue(item, null).ToString().Equals(FilterValue, StringComparison.InvariantCulture);
}
19
View Source File : FileHandle.cs
License : MIT License
Project Creator : action-bi-toolkit
License : MIT License
Project Creator : action-bi-toolkit
public static bool TryCreate(ulong processId, ulong handle, ushort rawType, out FileHandle fileHandle)
{
SafeGenericHandle inProcessSafeHandle;
fileHandle = null;
using (var sourceProcessHandle =
NativeMethods.OpenProcess(PROCESS_ACCESS_RIGHTS.PROCESS_DUP_HANDLE, true,
(uint)processId))
{
// To read info about a handle owned by another process we must duplicate it into ours
if (!NativeMethods.DuplicateHandle(sourceProcessHandle,
(IntPtr)handle,
NativeMethods.GetCurrentProcess(),
out inProcessSafeHandle,
0,
false,
DUPLICATE_HANDLE_OPTIONS.DUPLICATE_SAME_ACCESS))
{
inProcessSafeHandle = null;
}
}
if (inProcessSafeHandle == null || inProcessSafeHandle.IsInvalid)
return false;
using (inProcessSafeHandle)
{
var typeString = ResolveTypeString(rawType, inProcessSafeHandle);
if (!typeString.Equals("File", StringComparison.InvariantCultureIgnoreCase))
{
return false;
}
var name = ResolveName(inProcessSafeHandle);
var dosFilePath = ResolveDosFilePath(name);
fileHandle = new FileHandle((uint) processId, name, dosFilePath);
return true;
}
}
19
View Source File : GitSourceProvider.cs
License : MIT License
Project Creator : actions
License : MIT License
Project Creator : actions
private string GetRemoteRefName(string refName)
{
if (string.IsNullOrEmpty(refName))
{
// If the refName is empty return the remote name for master
refName = _remoteRefsPrefix + "master";
}
else if (refName.Equals("master", StringComparison.OrdinalIgnoreCase))
{
// If the refName is master return the remote name for master
refName = _remoteRefsPrefix + refName;
}
else if (refName.StartsWith(_refsPrefix, StringComparison.OrdinalIgnoreCase))
{
// If the refName is refs/heads change it to the remote version of the name
refName = _remoteRefsPrefix + refName.Substring(_refsPrefix.Length);
}
else if (refName.StartsWith(_pullRefsPrefix, StringComparison.OrdinalIgnoreCase))
{
// If the refName is refs/pull change it to the remote version of the name
refName = refName.Replace(_pullRefsPrefix, _remotePullRefsPrefix);
}
return refName;
}
19
View Source File : Validators.cs
License : MIT License
Project Creator : actions
License : MIT License
Project Creator : actions
public static bool ServerUrlValidator(string value)
{
try
{
Uri uri;
if (Uri.TryCreate(value, UriKind.Absolute, out uri))
{
if (uri.Scheme.Equals(UriHttpScheme, StringComparison.OrdinalIgnoreCase)
|| uri.Scheme.Equals(UriHttpsScheme, StringComparison.OrdinalIgnoreCase))
{
return true;
}
}
}
catch (Exception)
{
return false;
}
return false;
}
19
View Source File : Program.cs
License : MIT License
Project Creator : actions
License : MIT License
Project Creator : actions
static int Main(String[] args)
{
if (args != null && args.Length == 1 && args[0].Equals("init", StringComparison.InvariantCultureIgnoreCase))
{
// TODO: LOC all strings.
if (!EventLog.Exists("Application"))
{
Console.WriteLine("[ERROR] Application event log doesn't exist on current machine.");
return 1;
}
EventLog applicationLog = new EventLog("Application");
if (applicationLog.OverflowAction == OverflowAction.DoNotOverwrite)
{
Console.WriteLine("[WARNING] The retention policy for Application event log is set to \"Do not overwrite events\".");
Console.WriteLine("[WARNING] Make sure manually clear logs as needed, otherwise RunnerService will stop writing output to event log.");
}
try
{
EventLog.WriteEntry(RunnerService.EventSourceName, "create event log trace source for actions-runner service", EventLogEntryType.Information, 100);
return 0;
}
catch (Win32Exception ex)
{
Console.WriteLine("[ERROR] Unable to create '{0}' event source under 'Application' event log.", RunnerService.EventSourceName);
Console.WriteLine("[ERROR] {0}",ex.Message);
Console.WriteLine("[ERROR] Error Code: {0}", ex.ErrorCode);
return 1;
}
}
ServiceBase[] ServicesToRun;
ServicesToRun = new ServiceBase[]
{
new RunnerService(args.Length > 0 ? args[0] : "ActionsRunnerService")
};
ServiceBase.Run(ServicesToRun);
return 0;
}
19
View Source File : TypeExtensionMethods.cs
License : MIT License
Project Creator : actions
License : MIT License
Project Creator : actions
private static PropertyInfo GetPublicInstancePropertyInfo(Type type, string name)
{
Type typeToCheck = type;
PropertyInfo propertyInfo = null;
while (propertyInfo == null && typeToCheck != null)
{
TypeInfo typeInfo = typeToCheck.GetTypeInfo();
propertyInfo = typeInfo.DeclaredProperties.FirstOrDefault(p => p.Name.Equals(name, StringComparison.OrdinalIgnoreCase) && p.GetMethod.Attributes.HasFlag(MethodAttributes.Public) && !p.GetMethod.Attributes.HasFlag(MethodAttributes.Static));
typeToCheck = typeInfo.BaseType;
}
return propertyInfo;
}
19
View Source File : ExpectedExceptionExtensions.cs
License : MIT License
Project Creator : actions
License : MIT License
Project Creator : actions
public static bool IsExpected(this Exception ex, string area)
{
if (string.IsNullOrEmpty(area))
{
return false;
}
// An exception's Data property is an IDictionary, which returns null for keys that do not exist.
return area.Equals(ex.Data[c_expectedKey] as string, StringComparison.OrdinalIgnoreCase);
}
19
View Source File : TypeExtensionMethods.cs
License : MIT License
Project Creator : actions
License : MIT License
Project Creator : actions
private static FieldInfo GetPublicInstanceFieldInfo(Type type, string name)
{
Type typeToCheck = type;
FieldInfo fieldInfo = null;
while (fieldInfo == null && typeToCheck != null)
{
TypeInfo typeInfo = typeToCheck.GetTypeInfo();
fieldInfo = typeInfo.DeclaredFields.FirstOrDefault(f => f.Name.Equals(name, StringComparison.OrdinalIgnoreCase) && f.IsPublic && !f.IsStatic);
typeToCheck = typeInfo.BaseType;
}
return fieldInfo;
}
19
View Source File : ServiceEndpoint.cs
License : MIT License
Project Creator : actions
License : MIT License
Project Creator : actions
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
{
if (reader.TokenType == JsonToken.Boolean || reader.TokenType == JsonToken.Integer)
{
return serializer.Deserialize<T>(reader);
}
else if (reader.TokenType == JsonToken.String)
{
var s = (string)reader.Value;
if (s.Equals("false", StringComparison.OrdinalIgnoreCase) || s.Equals("0", StringComparison.OrdinalIgnoreCase))
{
return false;
}
return true;
}
else
{
return true;
}
}
19
View Source File : VssOAuthTokenHttpClient.cs
License : MIT License
Project Creator : actions
License : MIT License
Project Creator : actions
private static HttpMessageHandler CreateMessageHandler(Uri requestUri)
{
var retryOptions = new VssHttpRetryOptions()
{
RetryableStatusCodes =
{
HttpStatusCode.InternalServerError,
VssNetworkHelper.TooManyRequests,
},
};
HttpClientHandler messageHandler = new HttpClientHandler()
{
UseDefaultCredentials = false
};
// Inherit proxy setting from VssHttpMessageHandler
if (VssHttpMessageHandler.DefaultWebProxy != null)
{
messageHandler.Proxy = VssHttpMessageHandler.DefaultWebProxy;
messageHandler.UseProxy = true;
}
if (requestUri.Scheme.Equals("https", StringComparison.OrdinalIgnoreCase) &&
VssClientHttpRequestSettings.Default.ClientCertificateManager != null &&
VssClientHttpRequestSettings.Default.ClientCertificateManager.ClientCertificates != null &&
VssClientHttpRequestSettings.Default.ClientCertificateManager.ClientCertificates.Count > 0)
{
messageHandler.ClientCertificates.AddRange(VssClientHttpRequestSettings.Default.ClientCertificateManager.ClientCertificates);
}
if (requestUri.Scheme.Equals("https", StringComparison.OrdinalIgnoreCase) &&
VssClientHttpRequestSettings.Default.ServerCertificateValidationCallback != null)
{
messageHandler.ServerCertificateCustomValidationCallback = VssClientHttpRequestSettings.Default.ServerCertificateValidationCallback;
}
return new VssHttpRetryMessageHandler(retryOptions, messageHandler);
}
19
View Source File : SuppressionFile.cs
License : GNU General Public License v3.0
Project Creator : Acumatica
License : GNU General Public License v3.0
Project Creator : Acumatica
internal static bool IsSuppressionFile(string path)
{
return SuppressionFileExtension.Equals(System.IO.Path.GetExtension(path), StringComparison.Ordinal);
}
19
View Source File : SuppressMessage.cs
License : GNU General Public License v3.0
Project Creator : Acumatica
License : GNU General Public License v3.0
Project Creator : Acumatica
public bool Equals(SuppressMessage other) =>
other.Id.Equals(Id, StringComparison.Ordinal) &&
other.Target.Equals(Target, StringComparison.Ordinal) &&
other.SyntaxNode.Equals(SyntaxNode, StringComparison.Ordinal);
19
View Source File : BoolToVisibilityConverter.cs
License : GNU General Public License v3.0
Project Creator : Acumatica
License : GNU General Public License v3.0
Project Creator : Acumatica
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (!(value is bool visible))
return Visibility.Collapsed;
if (InverseVisibilityValue.Equals(parameter as string, StringComparison.Ordinal))
{
visible = !visible;
}
return visible ? Visibility.Visible : Visibility.Collapsed;
}
19
View Source File : AnnotationDataAdapter.cs
License : MIT License
Project Creator : Adoxio
License : MIT License
Project Creator : Adoxio
private static void SetResponseParameters(HttpContextBase context,
Enreplacedy annotation, Enreplacedy webfile, ICollection<byte> data)
{
context.Response.StatusCode = (int)HttpStatusCode.OK;
context.Response.ContentType = annotation.GetAttributeValue<string>("mimetype");
var contentDispositionText = "attachment";
if (_allowDisplayInlineContentTypes.Any(contentType => contentType.Equals(context.Response.ContentType, StringComparison.OrdinalIgnoreCase)))
{
contentDispositionText = "inline";
}
var contentDisposition = new StringBuilder(contentDispositionText);
AppendFilenameToContentDisposition(annotation, contentDisposition);
context.Response.AppendHeader("Content-Disposition", contentDisposition.ToString());
context.Response.AppendHeader("Content-Length", data.Count.ToString(CultureInfo.InvariantCulture));
if (webfile?.Attributes != null && webfile.Attributes.ContainsKey("adx_alloworigin"))
{
var allowOrigin = webfile["adx_alloworigin"] as string;
Web.Extensions.SetAccessControlAllowOriginHeader(context, allowOrigin);
}
}
19
View Source File : FederationRequestValidator.cs
License : MIT License
Project Creator : Adoxio
License : MIT License
Project Creator : Adoxio
protected override bool IsValidRequestString(
HttpContext context,
string value,
RequestValidationSource requestValidationSource,
string collectionKey,
out int validationFailureIndex)
{
validationFailureIndex = 0;
if (requestValidationSource == RequestValidationSource.Form
&& collectionKey.Equals(WSFederationConstants.Parameters.Result, StringComparison.Ordinal))
{
var message = WSFederationMessage.CreateFromFormPost(context.Request) as SignInResponseMessage;
if (message != null)
{
return true;
}
}
return base.IsValidRequestString(context, value, requestValidationSource, collectionKey, out validationFailureIndex);
}
19
View Source File : StringHelper.cs
License : Mozilla Public License 2.0
Project Creator : agebullhu
License : Mozilla Public License 2.0
Project Creator : agebullhu
public static bool IsEquals(this string a, string b)
{
var aNull = string.IsNullOrWhiteSpace(a);
var bNull = string.IsNullOrWhiteSpace(b);
return aNull && bNull || (aNull == bNull && a.Equals(b, StringComparison.OrdinalIgnoreCase));
}
19
View Source File : StringHelper.cs
License : Mozilla Public License 2.0
Project Creator : agebullhu
License : Mozilla Public License 2.0
Project Creator : agebullhu
public static bool IsNullOrDefault(this string word, string def = "无")
{
return string.IsNullOrWhiteSpace(word) || word.Equals(def, StringComparison.OrdinalIgnoreCase);
}
19
View Source File : WebSocketClient.cs
License : Mozilla Public License 2.0
Project Creator : agebullhu
License : Mozilla Public License 2.0
Project Creator : agebullhu
private bool ValidateClientHandshake(string[] lines, out string key)
{
key = null;
// first line should be the GET
if (lines.Length == 0 || !lines[0].StartsWith("GET"))
return false;
if (!lines.Any(l => l.StartsWith("Host:")))
return false;
// look for upgrade command
if (!lines.Any(l => l.Trim().Equals("Upgrade: websocket", StringComparison.OrdinalIgnoreCase)))
return false;
if (!lines.Any(l =>
{
var lt = l.Trim();
return lt.StartsWith("Connection: ", StringComparison.OrdinalIgnoreCase) && lt
.Split(',', ':')
.Any(p => p.Trim().Equals("Upgrade", StringComparison.OrdinalIgnoreCase));
}))
return false;
if (!lines.Any(l => l.Trim().Equals("Sec-WebSocket-Version: 13", StringComparison.OrdinalIgnoreCase)))
return false;
// look for websocket key
string keyLine =
lines.FirstOrDefault(l => l.StartsWith("Sec-WebSocket-Key:", StringComparison.OrdinalIgnoreCase));
if (string.IsNullOrEmpty(keyLine))
return false;
key = keyLine.Substring(keyLine.IndexOf(':') + 1).Trim();
return true;
}
19
View Source File : ChainOfResponsibilityPattern.cs
License : The Unlicense
Project Creator : ahotko
License : The Unlicense
Project Creator : ahotko
public override void HandleRequest(string deviceName, int request)
{
if (deviceName.Equals("network", StringComparison.OrdinalIgnoreCase))
{
Console.WriteLine($"Handled Request {request} for device {deviceName} by {this.GetType().Name}");
}
else Successor?.HandleRequest(deviceName, request);
}
19
View Source File : ChainOfResponsibilityPattern.cs
License : The Unlicense
Project Creator : ahotko
License : The Unlicense
Project Creator : ahotko
public override void HandleRequest(string deviceName, int request)
{
if (deviceName.Equals("keyboard", StringComparison.OrdinalIgnoreCase))
{
Console.WriteLine($"Handled Request {request} for device {deviceName} by {this.GetType().Name}");
}
else Successor?.HandleRequest(deviceName, request);
}
19
View Source File : ChainOfResponsibilityPattern.cs
License : The Unlicense
Project Creator : ahotko
License : The Unlicense
Project Creator : ahotko
public override void HandleRequest(string deviceName, int request)
{
if (deviceName.Equals("mouse", StringComparison.OrdinalIgnoreCase))
{
Console.WriteLine($"Handled Request {request} for device {deviceName} by {this.GetType().Name}");
}
else Successor?.HandleRequest(deviceName, request);
}
19
View Source File : Program.cs
License : The Unlicense
Project Creator : AigioL
License : The Unlicense
Project Creator : AigioL
static void Main(string[] args)
{
TryMain();
void TryMain()
{
try
{
Main();
}
catch (Exception ex)
{
var index = byte.MinValue;
while (ex != null)
{
if (index++ > sbyte.MaxValue) break;
Console.WriteLine(ex.Message);
Console.WriteLine(ex.StackTrace);
ex = ex.InnerException;
}
}
Console.ReadLine();
}
void Main()
{
// ReSharper disable PossibleNullReferenceException
var entryreplacedembly = replacedembly.GetEntryreplacedembly();
var replacedle = entryreplacedembly.FullName.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).FirstOrDefault();
// ReSharper disable once replacedignNullToNotNullAttribute
if (!replacedle.IsNullOrWhiteSpace()) Console.replacedle = replacedle;
var rootPath = Path.GetDirectoryName(entryreplacedembly.Location);
if (rootPath == null) throw new ArgumentNullException(nameof(rootPath));
var sofilepath = args?.FirstOrDefault(x => x != null && File.Exists(x) && Path.GetExtension(x).Equals(GetSoFileExtension(), StringComparison.OrdinalIgnoreCase));
if (sofilepath == null)
{
var sofilepaths = Directory.GetFiles(rootPath).Where(x => Path.GetExtension(x).Equals(GetSoFileExtension(), StringComparison.OrdinalIgnoreCase)).ToArray();
sofilepath =
sofilepaths.FirstOrDefault(x => Path.GetFileName(x).Equals(GetSoDefaultFileName(), StringComparison.OrdinalIgnoreCase)) ??
sofilepaths.FirstOrDefault();
}
if (sofilepath == null) ReadLineAndExit("Can not find the .so file.");
// ReSharper disable once replacedignNullToNotNullAttribute
var bytes = File.ReadAllBytes(sofilepath);
var elf = Elf.FromFile(sofilepath);
var rodata = elf.Header.SectionHeaders.FirstOrDefault(x => x.Name.Equals(".rodata"));
if (rodata == null) ReadLineAndExit(".rodata not found.");
var packedFiles = new List<string>();
var addr = (uint)rodata.Addr;
while (true)
{
//up to 16 bytes of alignment
uint i;
for (i = 0; i < 16; i++)
if (bytes[addr + i] != 0)
break;
if (i == 16)
break; //We found all the files
addr += i;
var name = GetString(bytes, addr);
if (name.IsNullOrWhiteSpace())
break;
//We only care about dlls
if (!name.EndsWith(".dll"))
break;
packedFiles.Add(name);
addr += (uint)name.Length + 1u;
}
var data = elf.Header.SectionHeaders.FirstOrDefault(x => x.Name.Equals(".data"));
if (data == null) ReadLineAndExit(".data not found.");
int ixGzip = 0;
addr = (uint)data.Offset;
var output = Path.Combine(rootPath, "replacedemblies");
if (!Directory.Exists(output)) Directory.CreateDirectory(output);
Console.WriteLine($"output:{output}");
foreach (var item in packedFiles)
{
ixGzip = findNextGZIPIndex(bytes, ixGzip);
if (ixGzip > 0)
{
var ptr = ixGzip;
var length = GetBigEndianUInt32(bytes, addr + 8);
var compressedbytes = new byte[length];
if (ptr + length <= bytes.LongLength)
{
Array.Copy(bytes, ptr, compressedbytes, 0, length);
try
{
var decompbytes = Decompress(compressedbytes);
var path = Path.Combine(output, item);
File.WriteAllBytes(path, decompbytes);
Console.WriteLine($"file:{item}");
addr += 0x10;
}
catch (Exception e)
{
Console.WriteLine($"Failed to decompress file: {item} {e.Message}.");
}
}
}
}
TryOpenDir(output);
// ReSharper restore PossibleNullReferenceException
}
void ReadLineAndExit(string writeLine = null)
{
if (writeLine != null) Console.WriteLine(writeLine);
Console.ReadLine();
Environment.Exit(0);
}
string GetSoFileExtension() => ".so";
string GetSoDefaultFileName() => "libmonodroid_bundle_app" + GetSoFileExtension();
string GetString(byte[] bytes, uint address)
{
int maxLength = 255;
for (int i = (int)address; i < address + maxLength; i++)
{
if (bytes[i] == 0)
{
maxLength = i - (int)address;
break;
}
}
var buffer = new byte[maxLength];
Array.Copy(bytes, address, buffer, 0, maxLength);
return Encoding.ASCII.GetString(buffer);
}
int findNextGZIPIndex(byte[] bytes, int ixGzip)
{
for (var j = ixGzip + 2; j < bytes.Length; j++)
{
if (bytes[j - 1] == 0x1f && bytes[j] == 0x8b)
{
ixGzip = j - 1;
return ixGzip;
}
}
return 0;
}
byte[] Decompress(byte[] data)
{
using (var compressedStream = new MemoryStream(data))
using (var zipStream = new GZipStream(compressedStream, CompressionMode.Decompress))
using (var resultStream = new MemoryStream())
{
zipStream.CopyTo(resultStream);
return resultStream.ToArray();
}
}
uint GetBigEndianUInt32(byte[] bytes, uint address)
{
var byte1 = (uint)bytes[(int)address + 3] << 24;
var byte2 = (uint)bytes[(int)address + 2] << 16;
var byte3 = (uint)bytes[(int)address + 1] << 8;
var byte4 = bytes[(int)address];
return byte1 + byte2 + byte3 + byte4;
}
void TryOpenDir(string dirpath)
{
try
{
Process.Start(dirpath);
}
catch
{
// ignored
}
}
}
19
View Source File : AutoCompleteService.cs
License : MIT License
Project Creator : aivarasatk
License : MIT License
Project Creator : aivarasatk
public void TryAddAutoCompleteEntry(string entry)
{
if (string.IsNullOrWhiteSpace(entry)
|| _autoCompletes.Any(a => a.Equals(entry, StringComparison.InvariantCultureIgnoreCase)))
return;
if (_autoCompletes.Count is MaxEntries)
_autoCompletes.RemoveAt(0);
_autoCompletes.Add(entry);
}
See More Examples