Here are the examples of the csharp api System.Enum.IsDefined(System.Type, object) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
920 Examples
19
View Source File : Message.cs
License : zlib License
Project Creator : 0x0ade
License : zlib License
Project Creator : 0x0ade
public static string MsgToString(int msg) {
if (Enum.IsDefined(typeof(Messages), msg))
return Enum.GetName(typeof(Messages), msg);
if (((msg & (int) Messages.WM_REFLECT) == (int) Messages.WM_REFLECT)) {
string subtext = MsgToString(msg & (int) ~Messages.WM_REFLECT);
if (subtext == null) subtext = "???";
return "WM_REFLECT + " + subtext;
}
return null;
}
19
View Source File : JcApiHelper_InitParam.cs
License : MIT License
Project Creator : 279328316
License : MIT License
Project Creator : 279328316
private static bool IsIgnoreType(Type type)
{
bool result = false;
try
{
string typeName = TypeHelper.GetTypeName(type);
typeName = typeName.Replace("[]", ""); //获取数组 元类型
//基类为ValueType的值类型 或Type,*Attribute
result = type.BaseType?.Name == "ValueType"
|| typeName == "Type"
|| typeName.EndsWith("Attribute");
if (!result)
{ //排除 系统基本类型
result = Enum.IsDefined(typeof(TypeCode), typeName);
}
}
catch (Exception ex)
{
}
return result;
}
19
View Source File : EnumValidationAttribute.cs
License : GNU Lesser General Public License v3.0
Project Creator : 8720826
License : GNU Lesser General Public License v3.0
Project Creator : 8720826
public override bool IsValid(object value)
{
return Enum.IsDefined(_type, value);
}
19
View Source File : SetGrantsForUser.cs
License : Apache License 2.0
Project Creator : AantCoder
License : Apache License 2.0
Project Creator : AantCoder
private static Grants GetGrantsByStr(string value)
{
if (int.TryParse(value, out int res) && Enum.IsDefined(typeof(Grants), res))
{
return (Grants)res;
}
if (Enum.TryParse<Grants>(value, out Grants newGrants))
{
return newGrants;
}
return Grants.NoPermissions;
}
19
View Source File : FdbTuplePackers.cs
License : MIT License
Project Creator : abdullin
License : MIT License
Project Creator : abdullin
public static void SerializeTo(ref TupleWriter writer, FdbTupleAlias value)
{
Contract.Requires(Enum.IsDefined(typeof(FdbTupleAlias), value));
writer.Output.WriteByte((byte)value);
}
19
View Source File : CodeHighlighter.cs
License : MIT License
Project Creator : ABTSoftware
License : MIT License
Project Creator : ABTSoftware
private static void OnSourceLanguagePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
var value = (SourceLanguageType) e.NewValue;
if (!Enum.IsDefined(typeof (SourceLanguageType), value))
{
throw new ArgumentException("Invalid source language type.");
}
}
19
View Source File : SpellSQLWriter.cs
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator
public void CreateSQLINSERTStatement(Spell input, StreamWriter writer)
{
var spellLineHdr = "INSERT INTO `spell` (`id`, `name`";
var spellLine = $"VALUES ({input.Id}, {GetSQLString(input.Name)}";
if (input.StatModType.HasValue)
{
spellLineHdr += ", `stat_Mod_Type`";
spellLine += $", {input.StatModType} /* {((EnchantmentTypeFlags)input.StatModType).ToString()} */";
}
if (input.StatModKey.HasValue)
{
spellLineHdr += ", `stat_Mod_Key`";
spellLine += $", {input.StatModKey}";
if (input.StatModType.HasValue)
{
var smt = (EnchantmentTypeFlags)input.StatModType;
if (smt.HasFlag(EnchantmentTypeFlags.Skill))
{
if (Enum.IsDefined(typeof(Skill), (int)input.StatModKey))
spellLine += $" /* {Enum.GetName(typeof(Skill), input.StatModKey)} */";
}
else if (smt.HasFlag(EnchantmentTypeFlags.Attribute))
{
if (Enum.IsDefined(typeof(PropertyAttribute), (ushort)input.StatModKey))
spellLine += $" /* {Enum.GetName(typeof(PropertyAttribute), input.StatModKey)} */";
}
else if (smt.HasFlag(EnchantmentTypeFlags.SecondAtt))
{
if (Enum.IsDefined(typeof(PropertyAttribute2nd), (ushort)input.StatModKey))
spellLine += $" /* {Enum.GetName(typeof(PropertyAttribute2nd), input.StatModKey)} */";
}
else if (smt.HasFlag(EnchantmentTypeFlags.Int))
{
if (Enum.IsDefined(typeof(PropertyInt), (ushort)input.StatModKey))
spellLine += $" /* {Enum.GetName(typeof(PropertyInt), input.StatModKey)} */";
}
else if (smt.HasFlag(EnchantmentTypeFlags.Float))
{
if (Enum.IsDefined(typeof(PropertyFloat), (ushort)input.StatModKey))
spellLine += $" /* {Enum.GetName(typeof(PropertyFloat), input.StatModKey)} */";
}
}
}
if (input.StatModVal.HasValue)
{
spellLineHdr += ", `stat_Mod_Val`";
spellLine += $", {input.StatModVal:0.######}";
}
if (input.EType.HasValue)
{
spellLineHdr += ", `e_Type`";
spellLine += $", {input.EType} /* {Enum.GetName(typeof(DamageType), input.EType)} */";
}
if (input.BaseIntensity.HasValue)
{
spellLineHdr += ", `base_Intensity`";
spellLine += $", {input.BaseIntensity}";
}
if (input.Variance.HasValue)
{
spellLineHdr += ", `variance`";
spellLine += $", {input.Variance}";
}
if (input.Wcid.HasValue)
{
spellLineHdr += ", `wcid`";
if (WeenieNames != null && input.Wcid.Value > 0 && WeenieNames.ContainsKey(input.Wcid.Value))
spellLine += $", {input.Wcid} /* {WeenieNames[input.Wcid.Value]} */";
else
spellLine += $", {input.Wcid}";
}
if (input.NumProjectiles.HasValue)
{
spellLineHdr += ", `num_Projectiles`";
spellLine += $", {input.NumProjectiles}";
}
if (input.NumProjectilesVariance.HasValue)
{
spellLineHdr += ", `num_Projectiles_Variance`";
spellLine += $", {input.NumProjectilesVariance:0.######}";
}
if (input.SpreadAngle.HasValue)
{
spellLineHdr += ", `spread_Angle`";
spellLine += $", {input.SpreadAngle:0.######}";
}
if (input.VerticalAngle.HasValue)
{
spellLineHdr += ", `vertical_Angle`";
spellLine += $", {input.VerticalAngle:0.######}";
}
if (input.DefaultLaunchAngle.HasValue)
{
spellLineHdr += ", `default_Launch_Angle`";
spellLine += $", {input.DefaultLaunchAngle:0.######}";
}
if (input.NonTracking.HasValue)
{
spellLineHdr += ", `non_Tracking`";
spellLine += $", {input.NonTracking}";
}
if (input.CreateOffsetOriginX.HasValue)
{
spellLineHdr += ", `create_Offset_Origin_X`";
spellLine += $", {input.CreateOffsetOriginX:0.######}";
}
if (input.CreateOffsetOriginY.HasValue)
{
spellLineHdr += ", `create_Offset_Origin_Y`";
spellLine += $", {input.CreateOffsetOriginY:0.######}";
}
if (input.CreateOffsetOriginZ.HasValue)
{
spellLineHdr += ", `create_Offset_Origin_Z`";
spellLine += $", {input.CreateOffsetOriginZ:0.######}";
}
if (input.PaddingOriginX.HasValue)
{
spellLineHdr += ", `padding_Origin_X`";
spellLine += $", {input.PaddingOriginX:0.######}";
}
if (input.PaddingOriginY.HasValue)
{
spellLineHdr += ", `padding_Origin_Y`";
spellLine += $", {input.PaddingOriginY:0.######}";
}
if (input.PaddingOriginZ.HasValue)
{
spellLineHdr += ", `padding_Origin_Z`";
spellLine += $", {input.PaddingOriginZ:0.######}";
}
if (input.DimsOriginX.HasValue)
{
spellLineHdr += ", `dims_Origin_X`";
spellLine += $", {input.DimsOriginX:0.######}";
}
if (input.DimsOriginY.HasValue)
{
spellLineHdr += ", `dims_Origin_Y`";
spellLine += $", {input.DimsOriginY:0.######}";
}
if (input.DimsOriginZ.HasValue)
{
spellLineHdr += ", `dims_Origin_Z`";
spellLine += $", {input.DimsOriginZ:0.######}";
}
if (input.PeturbationOriginX.HasValue)
{
spellLineHdr += ", `peturbation_Origin_X`";
spellLine += $", {input.PeturbationOriginX:0.######}";
}
if (input.PeturbationOriginY.HasValue)
{
spellLineHdr += ", `peturbation_Origin_Y`";
spellLine += $", {input.PeturbationOriginY:0.######}";
}
if (input.PeturbationOriginZ.HasValue)
{
spellLineHdr += ", `peturbation_Origin_Z`";
spellLine += $", {input.PeturbationOriginZ:0.######}";
}
if (input.ImbuedEffect.HasValue)
{
spellLineHdr += ", `imbued_Effect`";
spellLine += $", {input.ImbuedEffect} /* {Enum.GetName(typeof(ImbuedEffectType), input.ImbuedEffect)} */";
}
if (input.SlayerCreatureType.HasValue)
{
spellLineHdr += ", `slayer_Creature_Type`";
spellLine += $", {input.SlayerCreatureType} /* {Enum.GetName(typeof(CreatureType), input.SlayerCreatureType)} */";
}
if (input.SlayerDamageBonus.HasValue)
{
spellLineHdr += ", `slayer_Damage_Bonus`";
spellLine += $", {input.SlayerDamageBonus}";
}
if (input.CritFreq.HasValue)
{
spellLineHdr += ", `crit_Freq`";
spellLine += $", {input.CritFreq}";
}
if (input.CritMultiplier.HasValue)
{
spellLineHdr += ", `crit_Multiplier`";
spellLine += $", {input.CritMultiplier}";
}
if (input.IgnoreMagicResist.HasValue)
{
spellLineHdr += ", `ignore_Magic_Resist`";
spellLine += $", {input.IgnoreMagicResist}";
}
if (input.ElementalModifier.HasValue)
{
spellLineHdr += ", `elemental_Modifier`";
spellLine += $", {input.ElementalModifier}";
}
if (input.DrainPercentage.HasValue)
{
spellLineHdr += ", `drain_Percentage`";
spellLine += $", {input.DrainPercentage:0.######}";
}
if (input.DamageRatio.HasValue)
{
spellLineHdr += ", `damage_Ratio`";
spellLine += $", {input.DamageRatio}";
}
if (input.DamageType.HasValue)
{
spellLineHdr += ", `damage_Type`";
spellLine += $", {(int)input.DamageType} /* {Enum.GetName(typeof(DamageType), input.DamageType)} */";
}
if (input.Boost.HasValue)
{
spellLineHdr += ", `boost`";
spellLine += $", {input.Boost}";
}
if (input.BoostVariance.HasValue)
{
spellLineHdr += ", `boost_Variance`";
spellLine += $", {input.BoostVariance}";
}
if (input.Source.HasValue)
{
spellLineHdr += ", `source`";
spellLine += $", {(int)input.Source} /* {Enum.GetName(typeof(PropertyAttribute2nd), input.Source)} */";
}
if (input.Destination.HasValue)
{
spellLineHdr += ", `destination`";
spellLine += $", {(int)input.Destination} /* {Enum.GetName(typeof(PropertyAttribute2nd), input.Destination)} */";
}
if (input.Proportion.HasValue)
{
spellLineHdr += ", `proportion`";
spellLine += $", {input.Proportion}";
}
if (input.LossPercent.HasValue)
{
spellLineHdr += ", `loss_Percent`";
spellLine += $", {input.LossPercent:0.######}";
}
if (input.SourceLoss.HasValue)
{
spellLineHdr += ", `source_Loss`";
spellLine += $", {input.SourceLoss}";
}
if (input.TransferCap.HasValue)
{
spellLineHdr += ", `transfer_Cap`";
spellLine += $", {input.TransferCap}";
}
if (input.MaxBoostAllowed.HasValue)
{
spellLineHdr += ", `max_Boost_Allowed`";
spellLine += $", {input.MaxBoostAllowed}";
}
if (input.TransferBitfield.HasValue)
{
spellLineHdr += ", `transfer_Bitfield`";
spellLine += $", {input.TransferBitfield} /* {((TransferFlags)input.TransferBitfield).ToString()} */";
}
if (input.Index.HasValue)
{
spellLineHdr += ", `index`";
spellLine += $", {input.Index} /* {(input.Name.Contains("Tie") ? ("PortalLinkType." + (PortalLinkType)input.Index).ToString() : ("PortalRecallType." + (PortalRecallType)input.Index).ToString())} */";
}
if (input.Link.HasValue)
{
spellLineHdr += ", `link`";
spellLine += $", {input.Link} /* PortalSummonType.{((PortalSummonType)input.Link).ToString()} */";
}
if (input.PositionObjCellId.HasValue)
{
spellLineHdr += ", `position_Obj_Cell_ID`";
spellLine += $", 0x{input.PositionObjCellId:X8}";
}
if (input.PositionOriginX.HasValue)
{
spellLineHdr += ", `position_Origin_X`";
spellLine += $", {TrimNegativeZero(input.PositionOriginX):0.######}";
}
if (input.PositionOriginY.HasValue)
{
spellLineHdr += ", `position_Origin_Y`";
spellLine += $", {TrimNegativeZero(input.PositionOriginY):0.######}";
}
if (input.PositionOriginZ.HasValue)
{
spellLineHdr += ", `position_Origin_Z`";
spellLine += $", {TrimNegativeZero(input.PositionOriginZ):0.######}";
}
if (input.PositionAnglesW.HasValue)
{
spellLineHdr += ", `position_Angles_W`";
spellLine += $", {TrimNegativeZero(input.PositionAnglesW):0.######}";
}
if (input.PositionAnglesX.HasValue)
{
spellLineHdr += ", `position_Angles_X`";
spellLine += $", {TrimNegativeZero(input.PositionAnglesX):0.######}";
}
if (input.PositionAnglesY.HasValue)
{
spellLineHdr += ", `position_Angles_Y`";
spellLine += $", {TrimNegativeZero(input.PositionAnglesY):0.######}";
}
if (input.PositionAnglesZ.HasValue)
{
spellLineHdr += ", `position_Angles_Z`";
spellLine += $", {TrimNegativeZero(input.PositionAnglesZ):0.######}";
}
if (input.MinPower.HasValue)
{
spellLineHdr += ", `min_Power`";
spellLine += $", {input.MinPower}";
}
if (input.MaxPower.HasValue)
{
spellLineHdr += ", `max_Power`";
spellLine += $", {input.MaxPower}";
}
if (input.PowerVariance.HasValue)
{
spellLineHdr += ", `power_Variance`";
spellLine += $", {input.PowerVariance:0.######}";
}
if (input.DispelSchool.HasValue)
{
spellLineHdr += ", `dispel_School`";
spellLine += $", {(int)input.DispelSchool} /* {Enum.GetName(typeof(MagicSchool), input.DispelSchool)} */";
}
if (input.Align.HasValue)
{
spellLineHdr += ", `align`";
spellLine += $", {input.Align}";
}
if (input.Number.HasValue)
{
spellLineHdr += ", `number`";
spellLine += $", {input.Number}";
}
if (input.NumberVariance.HasValue)
{
spellLineHdr += ", `number_Variance`";
spellLine += $", {input.NumberVariance:0.######}";
}
if (input.DotDuration.HasValue)
{
spellLineHdr += ", `dot_Duration`";
spellLine += $", {input.DotDuration}";
}
spellLineHdr += ", `last_Modified`";
spellLine += $", '{input.LastModified:yyyy-MM-dd HH:mm:ss}'";
spellLineHdr += ")";
spellLine += ");";
spellLine = FixNullFields(spellLine);
if (input.PositionObjCellId.HasValue && input.PositionOriginX.HasValue && input.PositionOriginY.HasValue && input.PositionOriginZ.HasValue && input.PositionAnglesX.HasValue && input.PositionAnglesY.HasValue && input.PositionAnglesZ.HasValue && input.PositionAnglesW.HasValue)
{
spellLine += Environment.NewLine + $"/* @teleloc 0x{input.PositionObjCellId.Value:X8} [{TrimNegativeZero(input.PositionOriginX.Value):F6} {TrimNegativeZero(input.PositionOriginY.Value):F6} {TrimNegativeZero(input.PositionOriginZ.Value):F6}] {TrimNegativeZero(input.PositionAnglesW.Value):F6} {TrimNegativeZero(input.PositionAnglesX.Value):F6} {TrimNegativeZero(input.PositionAnglesY.Value):F6} {TrimNegativeZero(input.PositionAnglesZ.Value):F6} */";
}
writer.WriteLine(spellLineHdr);
writer.WriteLine(spellLine);
}
19
View Source File : WeenieSQLWriter.cs
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator
public string GetDefaultSubfolder(Weenie input)
{
var subFolder = Enum.GetName(typeof(WeenieType), input.Type) + "\\";
if (input.Type == (int)WeenieType.Creature)
{
var property = input.WeeniePropertiesInt.FirstOrDefault(r => r.Type == (int)PropertyInt.CreatureType);
if (property != null)
{
Enum.TryParse(property.Value.ToString(), out CreatureType ct);
if (Enum.IsDefined(typeof(CreatureType), ct))
subFolder += Enum.GetName(typeof(CreatureType), property.Value) + "\\";
else
subFolder += "UnknownCT_" + property.Value + "\\";
}
else
subFolder += "Unsorted" + "\\";
}
else if (input.Type == (int)WeenieType.House)
{
var property = input.WeeniePropertiesInt.FirstOrDefault(r => r.Type == (int)PropertyInt.HouseType);
if (property != null)
{
Enum.TryParse(property.Value.ToString(), out HouseType ht);
if (Enum.IsDefined(typeof(HouseType), ht))
subFolder += Enum.GetName(typeof(HouseType), property.Value) + "\\";
else
subFolder += "UnknownHT_" + property.Value + "\\";
}
else
subFolder += "Unsorted" + "\\";
}
else
{
var property = input.WeeniePropertiesInt.FirstOrDefault(r => r.Type == (int)PropertyInt.ItemType);
if (property != null)
subFolder += Enum.GetName(typeof(ItemType), property.Value) + "\\";
else
subFolder += Enum.GetName(typeof(ItemType), ItemType.None) + "\\";
}
return subFolder;
}
19
View Source File : AccountCommands.cs
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator
[CommandHandler("accountcreate", AccessLevel.Admin, CommandHandlerFlag.None, 2,
"Creates a new account.",
"username preplacedword (accesslevel)\n" +
"accesslevel can be a number or enum name\n" +
"0 = Player | 1 = Advocate | 2 = Sentinel | 3 = Envoy | 4 = Developer | 5 = Admin")]
public static void HandleAccountCreate(Session session, params string[] parameters)
{
AccessLevel defaultAccessLevel = (AccessLevel)Common.ConfigManager.Config.Server.Accounts.DefaultAccessLevel;
if (!Enum.IsDefined(typeof(AccessLevel), defaultAccessLevel))
defaultAccessLevel = AccessLevel.Player;
var accessLevel = defaultAccessLevel;
if (parameters.Length > 2)
{
if (Enum.TryParse(parameters[2], true, out accessLevel))
{
if (!Enum.IsDefined(typeof(AccessLevel), accessLevel))
accessLevel = defaultAccessLevel;
}
}
string articleAorAN = "a";
if (accessLevel == AccessLevel.Advocate || accessLevel == AccessLevel.Admin || accessLevel == AccessLevel.Envoy)
articleAorAN = "an";
string message = "";
var accountExists = DatabaseManager.Authentication.GetAccountByName(parameters[0]);
if (accountExists != null)
{
message= "Account already exists. Try a new name.";
}
else
{
try
{
var account = DatabaseManager.Authentication.CreateAccount(parameters[0].ToLower(), parameters[1], accessLevel, IPAddress.Parse("127.0.0.1"));
if (DatabaseManager.AutoPromoteNextAccountToAdmin && accessLevel == AccessLevel.Admin)
DatabaseManager.AutoPromoteNextAccountToAdmin = false;
message = ("Account successfully created for " + account.AccountName + " (" + account.AccountId + ") with access rights as " + articleAorAN + " " + Enum.GetName(typeof(AccessLevel), accessLevel) + ".");
}
catch
{
message = "Account already exists. Try a new name.";
}
}
CommandHandlerHelper.WriteOutputInfo(session, message, ChatMessageType.WorldBroadcast);
}
19
View Source File : AccountCommands.cs
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator
[CommandHandler("set-accountaccess", AccessLevel.Admin, CommandHandlerFlag.None, 1,
"Change the access level of an account.",
"accountname (accesslevel)\n" +
"accesslevel can be a number or enum name\n" +
"0 = Player | 1 = Advocate | 2 = Sentinel | 3 = Envoy | 4 = Developer | 5 = Admin")]
public static void HandleAccountUpdateAccessLevel(Session session, params string[] parameters)
{
string accountName = parameters[0].ToLower();
var accountId = DatabaseManager.Authentication.GetAccountIdByName(accountName);
if (accountId == 0)
{
CommandHandlerHelper.WriteOutputInfo(session, "Account " + accountName + " does not exist.", ChatMessageType.Broadcast);
return;
}
AccessLevel accessLevel = AccessLevel.Player;
if (parameters.Length > 1)
{
if (Enum.TryParse(parameters[1], true, out accessLevel))
{
if (!Enum.IsDefined(typeof(AccessLevel), accessLevel))
accessLevel = AccessLevel.Player;
}
}
string articleAorAN = "a";
if (accessLevel == AccessLevel.Advocate || accessLevel == AccessLevel.Admin || accessLevel == AccessLevel.Envoy)
articleAorAN = "an";
if (accountId == 0)
{
CommandHandlerHelper.WriteOutputInfo(session, "Account " + accountName + " does not exist.", ChatMessageType.Broadcast);
return;
}
DatabaseManager.Authentication.UpdateAccountAccessLevel(accountId, accessLevel);
if (DatabaseManager.AutoPromoteNextAccountToAdmin && accessLevel == AccessLevel.Admin)
DatabaseManager.AutoPromoteNextAccountToAdmin = false;
CommandHandlerHelper.WriteOutputInfo(session, "Account " + accountName + " updated with access rights set as " + articleAorAN + " " + Enum.GetName(typeof(AccessLevel), accessLevel) + ".", ChatMessageType.Broadcast);
}
19
View Source File : CharacterCommands.cs
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator
[CommandHandler("set-characteraccess", AccessLevel.Admin, CommandHandlerFlag.None, 1,
"Sets the access level for the character",
"charactername (accesslevel)\n" +
"accesslevel can be a number or enum name\n" +
"0 = Player | 1 = Advocate | 2 = Sentinel | 3 = Envoy | 4 = Developer | 5 = Admin")]
public static void HandleCharacterTokenization(Session session, params string[] parameters)
{
string characterName = parameters[0];
AccessLevel accessLevel = AccessLevel.Player;
if (parameters.Length > 1)
if (Enum.TryParse(parameters[1], true, out accessLevel))
if (!Enum.IsDefined(typeof(AccessLevel), accessLevel))
accessLevel = AccessLevel.Player;
DatabaseManager.Shard.SetCharacterAccessLevelByName(characterName.ToLower(), accessLevel, ((uint characterId) =>
{
if (characterId > 0)
{
string articleAorAN = "a";
if (accessLevel == AccessLevel.Advocate || accessLevel == AccessLevel.Admin || accessLevel == AccessLevel.Envoy)
articleAorAN = "an";
CommandHandlerHelper.WriteOutputInfo(session, "Character " + characterName + " has been made " + articleAorAN + " " + Enum.GetName(typeof(AccessLevel), accessLevel) + ".", ChatMessageType.Broadcast);
}
else
{
CommandHandlerHelper.WriteOutputInfo(session, "There is no character by the name of " + characterName + " found in the database. Has it been deleted?", ChatMessageType.Broadcast);
}
}));
}
19
View Source File : SpellFormula.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 IsScarab(uint componentID)
{
return Enum.IsDefined(typeof(Scarab), (int)componentID);
}
19
View Source File : AuthenticationHandler.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 DoLogin(Session session, PacketInboundLoginRequest loginRequest)
{
var account = DatabaseManager.Authentication.GetAccountByName(loginRequest.Account);
if (account == null)
{
if (loginRequest.NetAuthType == NetAuthType.AccountPreplacedword && loginRequest.Preplacedword != "")
{
if (ConfigManager.Config.Server.Accounts.AllowAutoAccountCreation)
{
// no account, dynamically create one
if (WorldManager.WorldStatus == WorldManager.WorldStatusState.Open)
log.Info($"Auto creating account for: {loginRequest.Account}");
else
log.Debug($"Auto creating account for: {loginRequest.Account}");
var accessLevel = (AccessLevel)ConfigManager.Config.Server.Accounts.DefaultAccessLevel;
if (!System.Enum.IsDefined(typeof(AccessLevel), accessLevel))
accessLevel = AccessLevel.Player;
if (DatabaseManager.AutoPromoteNextAccountToAdmin)
{
accessLevel = AccessLevel.Admin;
DatabaseManager.AutoPromoteNextAccountToAdmin = false;
log.Warn($"Automatically setting account AccessLevel to Admin for account \"{loginRequest.Account}\" because there are no admin accounts in the current database.");
}
account = DatabaseManager.Authentication.CreateAccount(loginRequest.Account.ToLower(), loginRequest.Preplacedword, accessLevel, session.EndPoint.Address);
}
}
}
try
{
log.Debug($"new client connected: {loginRequest.Account}. setting session properties");
AccountSelectCallback(account, session, loginRequest);
}
catch (Exception ex)
{
log.Error("Error in HandleLoginRequest trying to find the account.", ex);
session.Terminate(SessionTerminationReason.AccountSelectCallbackException);
}
}
19
View Source File : Player_Character.cs
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator
public void Addreplacedle(uint replacedleId, bool setAsDisplayreplacedle = false)
{
if (!Enum.IsDefined(typeof(Characterreplacedle), replacedleId))
return;
Character.AddreplacedleToRegistry(replacedleId, CharacterDatabaseLock, out var replacedleAlreadyExists, out var numCharacterreplacedles);
bool sendMsg = false;
bool notifyNewreplacedle = false;
if (!replacedleAlreadyExists)
{
CharacterChangesDetected = true;
NumCharacterreplacedles = numCharacterreplacedles;
sendMsg = true;
notifyNewreplacedle = true;
}
if (setAsDisplayreplacedle && CharacterreplacedleId != replacedleId)
{
CharacterreplacedleId = (int)replacedleId;
sendMsg = true;
}
if (sendMsg && FirstEnterWorldDone)
{
Session.Network.EnqueueSend(new GameEventUpdatereplacedle(Session, replacedleId, setAsDisplayreplacedle));
if (notifyNewreplacedle)
Session.Network.EnqueueSend(new GameEventCommunicationTransientString(Session, "You have been granted a new replacedle."));
}
}
19
View Source File : MotionTable.cs
License : GNU General Public License v3.0
Project Creator : ACEmulator
License : GNU General Public License v3.0
Project Creator : ACEmulator
private static string GetLabel(uint combined)
{
var stanceKey = (ushort)(combined >> 16);
var motionKey = (ushort)combined;
if (RawToInterpreted.TryGetValue(stanceKey, out var stance) && RawToInterpreted.TryGetValue(motionKey, out var motion))
return $"{stance} - {motion}";
else if (System.Enum.IsDefined(typeof(MotionCommand), combined))
return $"{(MotionCommand)combined}";
else
return $"{combined:X8}";
}
19
View Source File : TaskResultUtil.cs
License : MIT License
Project Creator : actions
License : MIT License
Project Creator : actions
public static bool IsValidReturnCode(int returnCode)
{
int resultInt = returnCode - _returnCodeOffset;
return Enum.IsDefined(typeof(TaskResult), resultInt);
}
19
View Source File : TaskResultUtil.cs
License : MIT License
Project Creator : actions
License : MIT License
Project Creator : actions
public static TaskResult TranslateFromReturnCode(int returnCode)
{
int resultInt = returnCode - _returnCodeOffset;
if (Enum.IsDefined(typeof(TaskResult), resultInt))
{
return (TaskResult)resultInt;
}
else
{
return TaskResult.Failed;
}
}
19
View Source File : Requires.cs
License : MIT License
Project Creator : adamant
License : MIT License
Project Creator : adamant
[DebuggerHidden]
public static void ValidEnum<E>(string parameter, E value)
where E : Enum
{
if (!Enum.IsDefined(typeof(E), value))
throw new InvalidEnumArgumentException(parameter, Convert.ToInt32(value, CultureInfo.InvariantCulture), typeof(E));
}
19
View Source File : EntityListDataAdapter.cs
License : MIT License
Project Creator : Adoxio
License : MIT License
Project Creator : Adoxio
private static EnreplacedyListTimeZoneDisplayMode GetTimeZoneDisplayMode(OptionSetValue option)
{
if (option == null || !Enum.IsDefined(typeof(EnreplacedyListTimeZoneDisplayMode), option.Value))
{
return EnreplacedyListTimeZoneDisplayMode.UserLocalTimeZone;
}
return (EnreplacedyListTimeZoneDisplayMode)option.Value;
}
19
View Source File : Region.cs
License : GNU General Public License v3.0
Project Creator : aelariane
License : GNU General Public License v3.0
Project Creator : aelariane
public static CloudRegionCode Parse(string codereplacedtring)
{
codereplacedtring = codereplacedtring.ToLower();
CloudRegionCode result = CloudRegionCode.none;
if (Enum.IsDefined(typeof(CloudRegionCode), codereplacedtring))
{
result = (CloudRegionCode)((int)Enum.Parse(typeof(CloudRegionCode), codereplacedtring));
}
return result;
}
19
View Source File : MetadataAnalyzer.cs
License : MIT License
Project Creator : aerosoul94
License : MIT License
Project Creator : aerosoul94
private bool IsValidAttributes(FileAttribute attributes)
{
if (attributes == 0)
{
return true;
}
if (!Enum.IsDefined(typeof(FileAttribute), attributes))
{
return false;
}
return true;
}
19
View Source File : File.cs
License : GNU General Public License v3.0
Project Creator : ahmed605
License : GNU General Public License v3.0
Project Creator : ahmed605
public bool Open(string filename)
{
_stream = new FileStream(filename, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite);
var br = new BinaryReader(_stream);
Header.Read(br);
if (!Enum.IsDefined(typeof (MagicId), (int) Header.Identifier))
{
_stream.Close();
return false;
}
_stream.Seek(0x800, SeekOrigin.Begin);
TOC.Read(br);
return true;
}
19
View Source File : MainForm.cs
License : GNU General Public License v3.0
Project Creator : ahmed605
License : GNU General Public License v3.0
Project Creator : ahmed605
private void PopulateListView()
{
// Redisable some buttons (will be autoenabled based on selection)
tsbPreview.Enabled = false;
tsbEdit.Enabled = false;
Directory dir = _selectedDir;
string filterString = tstFilterBox.Text;
List<string> selectedFileNames = new List<string>();
foreach (var o in lvFiles.SelectedItems)
{
selectedFileNames.Add((o as ListViewItem).Text);
}
var comparer = lvFiles.ListViewItemSorter;
lvFiles.ListViewItemSorter = null;
lvFiles.BeginUpdate();
lvFiles.Items.Clear();
using (new WaitCursor(this))
{
foreach (var item in dir)
{
if (!item.IsDirectory)
{
File file = item as File;
if (filterString == "" || file.Name.IndexOf(filterString) > -1)
{
ListViewItem lvi = lvFiles.Items.Add(file.Name);
lvi.Tag = file;
lvi.SubItems.Add(FriendlySize(file.Size));
/*
string compressed = file.IsCompressed ? "Yes (" + FriendlySize(file.CompressedSize) + ")" : "No";
lvi.SubItems.Add(compressed);
*/
string resources = file.IsResource ? "Yes" : "No";
if (file.IsResource)
{
string rscType = Enum.IsDefined(file.ResourceType.GetType(), file.ResourceType)
?
file.ResourceType.ToString()
: string.Format("Unknown 0x{0:x}", (int)file.ResourceType);
resources += " (" + rscType + ")";
}
lvi.SubItems.Add(resources);
if (file.IsCustomData)
{
lvi.ForeColor = CustomDataForeColor;
}
if (selectedFileNames.Contains(file.Name))
{
lvi.Selected = true;
}
}
}
}
}
lvFiles.EndUpdate();
lvFiles.ListViewItemSorter = comparer;
lvFiles.Sort();
}
19
View Source File : Instruction.cs
License : GNU General Public License v3.0
Project Creator : ahmed605
License : GNU General Public License v3.0
Project Creator : ahmed605
protected virtual string GetInstructionTextInternal()
{
var str = new StringBuilder();
if (!Enum.IsDefined(typeof (OpCode), OpCode))
{
str.Append("Unknown_");
str.Append((int) OpCode);
}
else
{
str.Append(OpCode);
}
for (int i = 0; i < OperandCount; i++)
{
str.Append(i > 0 ? ", " : " ");
object opValue = Operands[i];
Type opType = opValue.GetType();
string opName = GetOperandName(i);
if (opName != null)
{
str.Append(opName);
str.Append("=");
}
if (opType == typeof (string))
{
str.Append(LiteralFormatter.FormatString(opValue.ToString()));
}
else if (opType == typeof(uint))
{
str.Append(LiteralFormatter.FormatInteger((int) (uint) opValue));
}
else if (opType == typeof(int))
{
str.Append(LiteralFormatter.FormatInteger((int) opValue));
}
else if (opType == typeof(float))
{
str.Append(LiteralFormatter.FormatFloat((float) opValue));
}
else
{
str.Append(opValue.ToString());
}
}
return str.ToString();
}
19
View Source File : MainForm.cs
License : GNU General Public License v3.0
Project Creator : ahmed605
License : GNU General Public License v3.0
Project Creator : ahmed605
private void UpdateUI()
{
var f = new FileInfo(_filename);
lblFileData.Text = f.Name;
string rscType = Enum.IsDefined(_resourceFile.Type.GetType(), _resourceFile.Type)
? _resourceFile.Type.ToString()
: string.Format("Unknown 0x{0:x}", (int) _resourceFile.Type);
lblTypeData.Text = rscType;
lblCompressionData.Text = _resourceFile.Compression.ToString();
lblSysMemSize.Text = string.Format("Size: {0} bytes", _resourceFile.SystemMemSize.ToString("N0"));
lblGfxMemSize.Text = string.Format("Size: {0} bytes", _resourceFile.GraphicsMemSize.ToString("N0"));
btnGfxMemExport.Enabled = true;
btnSysMemExport.Enabled = true;
btnGfxMemImport.Enabled = true;
btnSysMemImport.Enabled = true;
btnSaveResource.Enabled = true;
}
19
View Source File : ParamDrawer.cs
License : MIT License
Project Creator : aillieo
License : MIT License
Project Creator : aillieo
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
EnsureParamType();
switch (paramType)
{
case ParamType.Unknown:
Debug.LogError("Unknown type");
break;
case ParamType.Normal:
EditorGUI.PropertyField(position, property.FindPropertyRelative("value"), new GUIContent(property.FindPropertyRelative("key").stringValue));
break;
case ParamType.Array:
if (reorderableList == null)
{
CreateReorderableList(property);
}
reorderableList.DoList(position);
break;
case ParamType.Enum:
Type fieldType = fieldInfo.FieldType;
Type elementType = fieldType.GetElementType();
string enumTypeName = property.FindPropertyRelative("enumType").stringValue;
Type enumType = Type.GetType(enumTypeName);
var paramValue = property.FindPropertyRelative("value");
FieldInfo field = elementType.GetField("value", BindingFlags.Public | BindingFlags.Instance);
if (!Enum.IsDefined(enumType, paramValue.intValue))
{
paramValue.intValue = (int)Enum.GetValues(field.FieldType).GetValue(0);
}
paramValue.intValue = EditorGUI.Popup(position,property.FindPropertyRelative("key").stringValue, paramValue.intValue, enumType.GetEnumNames());
break;
}
}
19
View Source File : TimeCode.cs
License : MIT License
Project Creator : ailen0ada
License : MIT License
Project Creator : ailen0ada
private static void FrameRateSanityCheck(FrameRate frameRate, bool isDropFrame)
{
if (isDropFrame && frameRate != FrameRate.fps29_97 && frameRate != FrameRate.fps59_94)
{
throw new ArgumentException("Dropframe is supported with 29.97 or 59.94 fps.", nameof(isDropFrame));
}
if (!Enum.IsDefined(typeof(FrameRate), frameRate))
throw new ArgumentOutOfRangeException(nameof(frameRate),
"Value should be defined in the FrameRate enum.");
}
19
View Source File : SteamVR_TrackedObject.cs
License : MIT License
Project Creator : ajayyy
License : MIT License
Project Creator : ajayyy
public void SetDeviceIndex(int index)
{
if (System.Enum.IsDefined(typeof(EIndex), index))
this.index = (EIndex)index;
}
19
View Source File : JsonSchemaWriter.cs
License : MIT License
Project Creator : akaskela
License : MIT License
Project Creator : akaskela
private void WriteType(string propertyName, JsonWriter writer, JsonSchemaType type)
{
IList<JsonSchemaType> types;
if (System.Enum.IsDefined(typeof(JsonSchemaType), type))
{
types = new List<JsonSchemaType> { type };
}
else
{
types = EnumUtils.GetFlagsValues(type).Where(v => v != JsonSchemaType.None).ToList();
}
if (types.Count == 0)
{
return;
}
writer.WritePropertyName(propertyName);
if (types.Count == 1)
{
writer.WriteValue(JsonSchemaBuilder.MapType(types[0]));
return;
}
writer.WriteStartArray();
foreach (JsonSchemaType jsonSchemaType in types)
{
writer.WriteValue(JsonSchemaBuilder.MapType(jsonSchemaType));
}
writer.WriteEndArray();
}
19
View Source File : MapboxToken.cs
License : MIT License
Project Creator : alen-smajic
License : MIT License
Project Creator : alen-smajic
public static MapboxToken FromResponseData(byte[] data)
{
if (null == data || data.Length < 1)
{
return new MapboxToken()
{
HasError = true,
ErrorMessage = "No data received from token endpoint."
};
}
string jsonTxt = Encoding.UTF8.GetString(data);
MapboxToken token = new MapboxToken();
try
{
token = JsonConvert.DeserializeObject<MapboxToken>(jsonTxt);
MapboxTokenStatus status = (MapboxTokenStatus)Enum.Parse(typeof(MapboxTokenStatus), token.Code);
if (!Enum.IsDefined(typeof(MapboxTokenStatus), status))
{
throw new Exception(string.Format("could not convert token.code '{0}' to MapboxTokenStatus", token.Code));
}
token.Status = status;
}
catch (Exception ex)
{
token.HasError = true;
token.ErrorMessage = ex.Message;
}
return token;
}
19
View Source File : LightDataTableShared.cs
License : MIT License
Project Creator : AlenToma
License : MIT License
Project Creator : AlenToma
protected void TypeValidation(ref object value, Type dataType, bool loadDefaultOnError, object defaultValue = null)
{
try
{
ValidateCulture();
if (value == null || value is DBNull)
{
value = ValueByType(dataType, defaultValue);
return;
}
if (IgnoreTypeValidation)
return;
if (dataType == typeof(byte[]) && value.GetType() == typeof(string))
{
if (value.ToString().Length % 4 == 0) // its a valid base64string
value = Convert.FromBase64String(value.ToString());
return;
}
if (dataType == typeof(int?) || dataType == typeof(int))
{
if (double.TryParse(CleanValue(dataType, value).ToString(), NumberStyles.Float, Culture, out var douTal))
value = Convert.ToInt32(douTal);
else
if (loadDefaultOnError)
value = ValueByType(dataType, defaultValue);
return;
}
if (dataType == typeof(long?) || dataType == typeof(long))
{
if (double.TryParse(CleanValue(dataType, value).ToString(), NumberStyles.Float, Culture, out var douTal))
value = Convert.ToInt64(douTal);
else
if (loadDefaultOnError)
value = ValueByType(dataType, defaultValue);
return;
}
if (dataType == typeof(float?) || dataType == typeof(float))
{
if (float.TryParse(CleanValue(dataType, value).ToString(), NumberStyles.Float, Culture, out var douTal))
value = RoundingSettings.Round(douTal);
else
if (loadDefaultOnError)
value = ValueByType(dataType, defaultValue);
return;
}
if (dataType == typeof(decimal?) || dataType == typeof(decimal))
{
if (decimal.TryParse(CleanValue(dataType, value).ToString(), NumberStyles.Float, Culture, out var decTal))
value = RoundingSettings.Round(decTal);
else
if (loadDefaultOnError)
value = ValueByType(dataType, defaultValue);
return;
}
if (dataType == typeof(double?) || dataType == typeof(double))
{
if (double.TryParse(CleanValue(dataType, value).ToString(), NumberStyles.Float, Culture, out var douTal))
value = RoundingSettings.Round(douTal);
else
if (loadDefaultOnError)
value = ValueByType(dataType, defaultValue);
return;
}
if (dataType == typeof(DateTime?) || dataType == typeof(DateTime))
{
if (DateTime.TryParse(value.ToString(), Culture, DateTimeStyles.None, out var dateValue))
{
if (dateValue < SqlDateTime.MinValue)
dateValue = SqlDateTime.MinValue.Value;
value = dateValue;
}
else
if (loadDefaultOnError)
value = ValueByType(dataType, defaultValue);
return;
}
if (dataType == typeof(bool?) || dataType == typeof(bool))
{
if (bool.TryParse(value.ToString(), out var boolValue))
value = boolValue;
else
if (loadDefaultOnError)
value = ValueByType(dataType, defaultValue);
return;
}
if (dataType == typeof(TimeSpan?) || dataType == typeof(TimeSpan))
{
if (TimeSpan.TryParse(value.ToString(), Culture, out var timeSpanValue))
value = timeSpanValue;
else
if (loadDefaultOnError)
value = ValueByType(dataType, defaultValue);
return;
}
if (dataType.IsEnum || (dataType.GenericTypeArguments?.FirstOrDefault()?.IsEnum ?? false))
{
var type = dataType;
if ((dataType.GenericTypeArguments?.FirstOrDefault()?.IsEnum ?? false))
type = (dataType.GenericTypeArguments?.FirstOrDefault());
if (value is int || value is long)
{
if (Enum.IsDefined(type, Convert.ToInt32(value)))
value = Enum.ToObject(type, Convert.ToInt32(value));
}
else if (Enum.IsDefined(type, value))
value = Enum.Parse(type, value.ToString(), true);
else if (loadDefaultOnError)
value = Activator.CreateInstance(dataType);
}
else if (dataType == typeof(Guid) || dataType == typeof(Guid?))
{
if (Guid.TryParse(value.ToString(), out Guid v))
value = v;
else if (loadDefaultOnError)
value = ValueByType(dataType, defaultValue);
} else if (dataType == typeof(string))
{
value = value.ToString();
}
}
catch (Exception ex)
{
throw new Exception($"Error: InvalidType. ColumnType is {dataType.FullName} and the given value is of type {value.GetType().FullName} Original Exception {ex.Message}");
}
}
19
View Source File : Extensions.cs
License : MIT License
Project Creator : AlFasGD
License : MIT License
Project Creator : AlFasGD
public static bool Contains(this Enum e, int value) => Enum.IsDefined(e.GetType(), value);
19
View Source File : World.cs
License : MIT License
Project Creator : AlternateLife
License : MIT License
Project Creator : AlternateLife
private string ConvertWeatherTypeToName(WeatherType type)
{
if (Enum.IsDefined(typeof(WeatherType), type) == false)
{
return null;
}
return type.ToString().ToUpperInvariant();
}
19
View Source File : TestRS232OnlyTwoWayComPort.cs
License : GNU General Public License v3.0
Project Creator : alvaroyurrita
License : GNU General Public License v3.0
Project Creator : alvaroyurrita
void SetStopBits(string value)
{
string MessageHelp = "TSetStopBits" + _ComPort.Name + " [1,2]";
int mode = GetFirstParameterInteger(value, MessageHelp);
if (Enum.IsDefined(typeof(ComPort.eComStopBits), mode))
{
CrestronConsole.ConsoleCommandResponse("CMD:Changing Stop Bits to {0}", ((ComPort.eComStopBits)mode).ToString());
_ComPort.StopBits = ((ComPort.eComStopBits)mode);
}
else CrestronConsole.ConsoleCommandResponse(MessageHelp);
}
19
View Source File : TestTwoWayComPort.cs
License : GNU General Public License v3.0
Project Creator : alvaroyurrita
License : GNU General Public License v3.0
Project Creator : alvaroyurrita
void SetBaudRate(string value)
{
string MessageHelp = "TSetBaudRate" + _ComPort.Name + " [0,2,4,8,16,32,64,128,256,512,1024,2048,4096,8192,65536]";
int mode = GetFirstParameterInteger(value, MessageHelp);
if (Enum.IsDefined(typeof(ComPort.eComBaudRates), mode))
{
CrestronConsole.ConsoleCommandResponse("CMD:Changing Baud Rate to {0}", ((ComPort.eComBaudRates)mode).ToString());
_ComPort.BaudRate = ((ComPort.eComBaudRates)mode);
}
else CrestronConsole.ConsoleCommandResponse(MessageHelp);
}
19
View Source File : TestTwoWayComPort.cs
License : GNU General Public License v3.0
Project Creator : alvaroyurrita
License : GNU General Public License v3.0
Project Creator : alvaroyurrita
void SetHWHandshake(string value)
{
string MessageHelp = "TSetHWHandshake" + _ComPort.Name + " [0,1,2,3]";
int mode = GetFirstParameterInteger(value, MessageHelp);
if (Enum.IsDefined(typeof(ComPort.eComHardwareHandshakeType), mode))
{
CrestronConsole.ConsoleCommandResponse("CMD:Changing Hardware Handshake to {0}", ((ComPort.eComHardwareHandshakeType)mode).ToString());
_ComPort.HW_HandShake = ((ComPort.eComHardwareHandshakeType)mode);
}
else CrestronConsole.ConsoleCommandResponse(MessageHelp);
}
19
View Source File : TestTwoWayComPort.cs
License : GNU General Public License v3.0
Project Creator : alvaroyurrita
License : GNU General Public License v3.0
Project Creator : alvaroyurrita
void SetSWHandshake(string value)
{
string MessageHelp = "TSetSWHandshake" + _ComPort.Name + " [0,1,2,3]";
int mode = GetFirstParameterInteger(value, MessageHelp);
if (Enum.IsDefined(typeof(ComPort.eComSoftwareHandshakeType), mode))
{
CrestronConsole.ConsoleCommandResponse("CMD:Changing Software Handshake to {0}", ((ComPort.eComSoftwareHandshakeType)mode).ToString());
_ComPort.SW_HandShake = ((ComPort.eComSoftwareHandshakeType)mode);
}
else CrestronConsole.ConsoleCommandResponse(MessageHelp);
}
19
View Source File : TestRS232OnlyTwoWayComPort.cs
License : GNU General Public License v3.0
Project Creator : alvaroyurrita
License : GNU General Public License v3.0
Project Creator : alvaroyurrita
void SetParity(string value)
{
string MessageHelp = "TSetParity" + _ComPort.Name + " [0,1,2,3]";
int mode = GetFirstParameterInteger(value, MessageHelp);
if (Enum.IsDefined(typeof(ComPort.eComParityType), mode))
{
CrestronConsole.ConsoleCommandResponse("CMD:Changing Parity Bits to {0}", ((ComPort.eComParityType)mode).ToString());
_ComPort.Parity = ((ComPort.eComParityType)mode);
}
else CrestronConsole.ConsoleCommandResponse(MessageHelp);
}
19
View Source File : TestTwoWayComPort.cs
License : GNU General Public License v3.0
Project Creator : alvaroyurrita
License : GNU General Public License v3.0
Project Creator : alvaroyurrita
void SetProtocol(string value)
{
string MessageHelp = "TSetProtocol" + _ComPort.Name + " [0,1,2]";
int mode = GetFirstParameterInteger(value, MessageHelp);
if (Enum.IsDefined(typeof(ComPort.eComProtocolType), mode))
{
CrestronConsole.ConsoleCommandResponse("CMD:Changing Baud Rate to {0}", ((ComPort.eComProtocolType)mode).ToString());
_ComPort.Protocol = ((ComPort.eComProtocolType)mode);
}
else CrestronConsole.ConsoleCommandResponse(MessageHelp);
}
19
View Source File : TestDMRmc4KZ100C.cs
License : GNU General Public License v3.0
Project Creator : alvaroyurrita
License : GNU General Public License v3.0
Project Creator : alvaroyurrita
void SetParity(string value)
{
string MessageHelp = "TSetParityDMRX" + _ComPort.Name + " [0,1,2,3]";
int mode = GetFirstParameterInteger(value, MessageHelp);
if (Enum.IsDefined(typeof(ComPort.eComParityType), mode))
{
CrestronConsole.ConsoleCommandResponse("CMD:Changing Parity Bits to {0}", ((ComPort.eComParityType)mode).ToString());
_ComPort.Parity = ((ComPort.eComParityType)mode);
}
else CrestronConsole.ConsoleCommandResponse(MessageHelp);
}
19
View Source File : TestSystemMonitor.cs
License : GNU General Public License v3.0
Project Creator : alvaroyurrita
License : GNU General Public License v3.0
Project Creator : alvaroyurrita
static void CresnetStatisticsMode(string Mode)
{
string MessageHelp = "TCresnetStatisticsMode" + " [0,1]";
int mode = GetFirstParameterInteger(Mode, MessageHelp);
if (Enum.IsDefined(typeof(eStatisticMode), mode))
{
CrestronConsole.ConsoleCommandResponse("CMD:Changing Cresnet Statistic Mode to {0}", ((eStatisticMode)mode).ToString());
_SystemMonitor.CresnetStatisticsMode((eStatisticMode)mode);
}
else CrestronConsole.ConsoleCommandResponse(MessageHelp);
}
19
View Source File : TestSystemMonitor.cs
License : GNU General Public License v3.0
Project Creator : alvaroyurrita
License : GNU General Public License v3.0
Project Creator : alvaroyurrita
static void TCPStatisticsMode(string Mode)
{
string MessageHelp = "TTCPStatisticsMode" + " [0,1]";
int mode = GetFirstParameterInteger(Mode, MessageHelp);
if (Enum.IsDefined(typeof(eStatisticMode), mode))
{
CrestronConsole.ConsoleCommandResponse("CMD:Changing Cresnet Statistic Mode to {0}", ((eStatisticMode)mode).ToString());
_SystemMonitor.TCP_StatisticsMode((eStatisticMode)mode);
}
else CrestronConsole.ConsoleCommandResponse(MessageHelp);
}
19
View Source File : TestSystemMonitor.cs
License : GNU General Public License v3.0
Project Creator : alvaroyurrita
License : GNU General Public License v3.0
Project Creator : alvaroyurrita
static void CIPStatisticsMode(string Mode)
{
string MessageHelp = "CIPStatisticsMode" + " [0,1]";
int mode = GetFirstParameterInteger(Mode, MessageHelp);
if (Enum.IsDefined(typeof(eStatisticMode), mode))
{
CrestronConsole.ConsoleCommandResponse("CMD:Changing Cresnet Statistic Mode to {0}", ((eStatisticMode)mode).ToString());
_SystemMonitor.CIP_StatisticsMode((eStatisticMode)mode);
}
else CrestronConsole.ConsoleCommandResponse(MessageHelp);
}
19
View Source File : TestDMOutput.cs
License : GNU General Public License v3.0
Project Creator : alvaroyurrita
License : GNU General Public License v3.0
Project Creator : alvaroyurrita
void SclrDisplayMode(string value)
{
string MessageHelp = "TSclrDisplayMode" + _DMOutput.DMOutputPort + " [0,1,2,3]";
int mode = GetFirstParameterInteger(value, MessageHelp);
if (Enum.IsDefined(typeof(HDScalerScaler.eDisplayMode), mode))
{
CrestronConsole.ConsoleCommandResponse("CMD:Changing Scaler Display Mode to {0}", ((HDScalerScaler.eDisplayMode)mode).ToString());
_DMOutput.Scaler_Display_Mode((HDScalerScaler.eDisplayMode)mode);
}
else CrestronConsole.ConsoleCommandResponse(MessageHelp);
}
19
View Source File : TestDMRmc4KZ100C.cs
License : GNU General Public License v3.0
Project Creator : alvaroyurrita
License : GNU General Public License v3.0
Project Creator : alvaroyurrita
void SetBaudRate(string value)
{
string MessageHelp = "TSetBaudRateDMRX" + _ComPort.Name + " [0,2,4,8,16,32,64,128,256,512,1024,2048,4096,8192,65536]";
int mode = GetFirstParameterInteger(value, MessageHelp);
if (Enum.IsDefined(typeof(ComPort.eComBaudRates), mode))
{
CrestronConsole.ConsoleCommandResponse("CMD:Changing Baud Rate to {0}", ((ComPort.eComBaudRates)mode).ToString());
_ComPort.BaudRate = ((ComPort.eComBaudRates)mode);
}
else CrestronConsole.ConsoleCommandResponse(MessageHelp);
}
19
View Source File : TestDMRmc4KZ100C.cs
License : GNU General Public License v3.0
Project Creator : alvaroyurrita
License : GNU General Public License v3.0
Project Creator : alvaroyurrita
void SetStopBits(string value)
{
string MessageHelp = "TSetStopBitsDMRX" + _ComPort.Name + " [1,2]";
int mode = GetFirstParameterInteger(value, MessageHelp);
if (Enum.IsDefined(typeof(ComPort.eComStopBits), mode))
{
CrestronConsole.ConsoleCommandResponse("CMD:Changing Stop Bits to {0}", ((ComPort.eComStopBits)mode).ToString());
_ComPort.StopBits = ((ComPort.eComStopBits)mode);
}
else CrestronConsole.ConsoleCommandResponse(MessageHelp);
}
19
View Source File : TestDMRmc4KZ100C.cs
License : GNU General Public License v3.0
Project Creator : alvaroyurrita
License : GNU General Public License v3.0
Project Creator : alvaroyurrita
void SetHWHandshake(string value)
{
string MessageHelp = "TSetHWHandshakeDMRX" + _ComPort.Name + " [0,1,2,3]";
int mode = GetFirstParameterInteger(value, MessageHelp);
if (Enum.IsDefined(typeof(ComPort.eComHardwareHandshakeType), mode))
{
CrestronConsole.ConsoleCommandResponse("CMD:Changing Hardware Handshake to {0}", ((ComPort.eComHardwareHandshakeType)mode).ToString());
_ComPort.HW_HandShake = ((ComPort.eComHardwareHandshakeType)mode);
}
else CrestronConsole.ConsoleCommandResponse(MessageHelp);
}
19
View Source File : TestDMRmc4KZ100C.cs
License : GNU General Public License v3.0
Project Creator : alvaroyurrita
License : GNU General Public License v3.0
Project Creator : alvaroyurrita
void SetSWHandshake(string value)
{
string MessageHelp = "TSetSWHandshakeDMRX" + _ComPort.Name + " [0,1,2,3]";
int mode = GetFirstParameterInteger(value, MessageHelp);
if (Enum.IsDefined(typeof(ComPort.eComSoftwareHandshakeType), mode))
{
CrestronConsole.ConsoleCommandResponse("CMD:Changing Software Handshake to {0}", ((ComPort.eComSoftwareHandshakeType)mode).ToString());
_ComPort.SW_HandShake = ((ComPort.eComSoftwareHandshakeType)mode);
}
else CrestronConsole.ConsoleCommandResponse(MessageHelp);
}
19
View Source File : TestDMTx4K100C1G.cs
License : GNU General Public License v3.0
Project Creator : alvaroyurrita
License : GNU General Public License v3.0
Project Creator : alvaroyurrita
void SetBaudRate(string value)
{
string MessageHelp = "TSetBaudRateDMTX" + _ComPort.Name + " [0,2,4,8,16,32,64,128,256,512,1024,2048,4096,8192,65536]";
int mode = GetFirstParameterInteger(value, MessageHelp);
if (Enum.IsDefined(typeof(ComPort.eComBaudRates), mode))
{
CrestronConsole.ConsoleCommandResponse("CMD:Changing Baud Rate to {0}", ((ComPort.eComBaudRates)mode).ToString());
_ComPort.BaudRate = ((ComPort.eComBaudRates)mode);
}
else CrestronConsole.ConsoleCommandResponse(MessageHelp);
}
19
View Source File : TestDMOutput.cs
License : GNU General Public License v3.0
Project Creator : alvaroyurrita
License : GNU General Public License v3.0
Project Creator : alvaroyurrita
void SclrEnable(string value)
{
string MessageHelp = "TSclrEnable" + _DMOutput.DMOutputPort + " [0,1]";
int mode = GetFirstParameterInteger(value, MessageHelp);
if (Enum.IsDefined(typeof(eScalerEnableState),mode))
{
CrestronConsole.ConsoleCommandResponse("CMD:Changing Scaler to {0}", ((eScalerEnableState)mode).ToString());
_DMOutput.Scaler_Enabled((eScalerEnableState)mode);
}
else CrestronConsole.ConsoleCommandResponse(MessageHelp);
}
See More Examples