public SreCodeset(string columnName, string value, AttributeTypes type, string formula, string minimum, string maximum, bool isAssociatedWithSystemRow, int recordPosition, SqlClientManager sqlClientManager, List <IdpeKey> dataSourceKeys) : base(columnName, value, type, formula, minimum, maximum, isAssociatedWithSystemRow, recordPosition, sqlClientManager, dataSourceKeys) { //prevent null error; _ValueEnumValue = string.Empty; _ReferenceKey = string.Empty; }
public override void Deserialize(JToken rootNode) { foreach (JProperty property in rootNode.Children <JProperty>()) { if (property.Name == "Key") { this.Key = property.ToObject <string>(); } else if (property.Name == "AttributeType") { // Sanity check, make sure we are an int. AttributeTypes type = (AttributeTypes)property.ToObject <long>(); if (type != base.AttributeType) { throw new ValidationException("Attribute type is not set to " + base.AttributeType); } } else if (property.Name == "Required") { this.Required = property.ToObject <bool>(); } else if (property.Name == "DefaultValue") { // Do nothing for now, this is not set. } else if (property.Name == "PossibleValues") { // Do nothing for now, this is not set. } } }
static void Bastard_Prepare() { // TODO TODO TODO if (Config.DumpInfo) { Utils.Bastard.Fail("**** Not implemented yet! ****"); } if (Config.DebugLog) { var debugLog = Path.Combine(MyDirectory, "debug.log"); if (File.Exists(debugLog)) { File.Delete(debugLog); } Snoopy = new TextWriterTraceListener(debugLog, "DEBUG_LOG"); Debug.AutoFlush = true; Debug.Listeners.Clear(); Debug.Listeners.Add(Snoopy); } if (Config.Silent) { Console.SetOut(TextWriter.Null); Console.SetError(TextWriter.Null); } StringHasher.Initialize(MyDirectory); AttributeTypes.Initialize(MyDirectory); ResourceFactory.Initialize(MyDirectory); }
void UpdateNodeAttributes(XmlReader xmlrd, BaseNode node) { bool moreAttributes = xmlrd.MoveToFirstAttribute(); while (moreAttributes) { AttributeTypes attrID = Attributes.GetAttribute(xmlrd.Name); if (attrID != AttributeTypes.unknown) { bool success = node.SetAttribute(attrID, xmlrd.Value); if (!success) { if (attrID == AttributeTypes.type) { NodeTypes nodeType = NodeTypes.nodeNode; bool typeIsKnown = NodeFactory.GetNodeType(xmlrd.Value, ref nodeType); if (typeIsKnown && nodeType != NodeFactory.NodeType(node)) { // Error: Tried to change the type of an existing node. } } // Unhandled attribute found in xml. } } else { // Unhandled attribute found in xml. } moreAttributes = xmlrd.MoveToNextAttribute(); } }
private void CheckType(AttributeTypes type) { if (type != Type) { throw new Exception("Unexpected value type."); } }
private void MapMultiSelectAttributes() { if (!_unmappedData.ContainsKey("MultiSelectAttributes") || string.IsNullOrWhiteSpace(_unmappedData["MultiSelectAttributes"]?.Value <string>())) { return; } try { var attributes = JsonConvert.DeserializeObject <List <MpObjectAttribute> >(_unmappedData["MultiSelectAttributes"].Value <string>()); foreach (var a in attributes) { if (!AttributeTypes.ContainsKey(a.AttributeTypeId)) { AttributeTypes.Add(a.AttributeTypeId, new MpObjectAttributeType { AttributeTypeId = a.AttributeTypeId, Name = a.AttributeTypeName }); } a.Selected = true; AttributeTypes[a.AttributeTypeId].Attributes.Add(a); } } catch (Exception) { // we are intentionally suppressing error on parsing group attributes so the user will continue to see valid results - // consider refactoring to add logging for bad group data post-MVP } }
public Attribute(int line, AttributeTypes atttype, string attributeValue, AttributeValueType type) { Line = line; AttributeType = atttype; AttributeValue = attributeValue; ValueType = type; }
public override void Deserialize(JToken rootNode) { foreach (JProperty property in rootNode.Children <JProperty>()) { if (property.Name == "Key") { this.Key = property.ToObject <string>(); } else if (property.Name == "AttributeType") { // Sanity check, make sure we are an int. AttributeTypes type = (AttributeTypes)property.ToObject <long>(); if (type != AttributeTypes.Integer) { throw new ValidationException("Attribute type is not set to " + nameof(AttributeTypes.Integer)); } } else if (property.Name == "Required") { this.Required = property.ToObject <bool>(); } else if (property.Name == "DefaultValue") { this.DefaultValue = property.ToObject <int?>(); } else if (property.Name == "PossibleValues") { if (property.First is JObject possibleValuesObject) { DeserializePossibleValuesJson(possibleValuesObject); } } } }
private void TestArray <T>(AttributeTypes type) { AttributeType test = new AttributeType("test", typeof(T[]), 2); Assert.AreEqual(test.ClrType, typeof(T[])); Assert.AreEqual(test.Type, type); Assert.AreEqual(test.Length, 2); Assert.True(test.IsArray); //since length < int.MaxValue, default has 'length' elements Assert.AreEqual(test.GetDefault(), new T[] { default(T), default(T) }); test = new AttributeType("testUnbounded", typeof(T[]), Int32.MaxValue); Assert.AreEqual(test.ClrType, typeof(T[])); Assert.AreEqual(test.Type, type); Assert.AreEqual(test.Length, Int32.MaxValue); Assert.True(test.IsArray); //since length == int.MaxValue, default has zero elements Assert.AreEqual(test.GetDefault(), new T[] { }); test = new AttributeType("testDefaultLength", typeof(T[])); //default is length of 1 Assert.AreEqual(test.ClrType, typeof(T[])); Assert.AreEqual(test.Type, type); Assert.AreEqual(test.Length, 1); Assert.True(test.IsArray); //since length == 1, default is T[] with 1 element Assert.AreEqual(test.GetDefault(), new T[] { default(T) }); }
private void AssertType(AttributeTypes _check) { if (Attribute.Type != _check) { throw new SphinxClientException(string.Format("Incorrect attribute type, expected {0} got {1}", Attribute.Type, _check)); } }
public static List <INode> FindAny(this INode node, string data, AttributeTypes type, int indexOfFeature = -1) { List <INode> nodes = new List <INode>(); var cs = node.PullChildren(); for (int i = 0, j = cs.Count; i < j; i++) { switch (type) { case AttributeTypes.ID: if (data.IsNum() && cs[i].ID == int.Parse(data)) { nodes.Add(cs[i]); } break; case AttributeTypes.Name: if (cs[i].Name.Contains(data)) { nodes.Add(cs[i]); } break; case AttributeTypes.Feature: if (indexOfFeature > -1 && cs[i].Features.Count > indexOfFeature && cs[i].Features[indexOfFeature].Contains(data)) { nodes.Add(cs[i]); } break; } nodes.AddRange(cs[i].FindAny(data, type, indexOfFeature)); } return(nodes); }
/// <summary> /// Convert a resources.arsc AttributeTypes to an AttributeFormat. /// </summary> private static AttributeFormat AttributeTypeToFormat(AttributeTypes attributeTypes) { AttributeFormat result = 0; if ((attributeTypes & AttributeTypes.TYPE_REFERENCE) != 0) result |= AttributeFormat.Reference; if ((attributeTypes & AttributeTypes.TYPE_STRING) != 0) result |= AttributeFormat.String; if ((attributeTypes & AttributeTypes.TYPE_INTEGER) != 0) result |= AttributeFormat.Integer; if ((attributeTypes & AttributeTypes.TYPE_BOOLEAN) != 0) result |= AttributeFormat.Boolean; if ((attributeTypes & AttributeTypes.TYPE_COLOR) != 0) result |= AttributeFormat.Color; if ((attributeTypes & AttributeTypes.TYPE_FLOAT) != 0) result |= AttributeFormat.Float; if ((attributeTypes & AttributeTypes.TYPE_DIMENSION) != 0) result |= AttributeFormat.Dimension; if ((attributeTypes & AttributeTypes.TYPE_FRACTION) != 0) result |= AttributeFormat.Fraction; if ((attributeTypes & AttributeTypes.TYPE_ENUM) != 0) result |= AttributeFormat.Enum; if ((attributeTypes & AttributeTypes.TYPE_FLAGS) != 0) result |= AttributeFormat.Flag; return result; }
public void AddAttribute(string name, AttributeTypes type, string value) { Attribute attribute = null; switch (type) { case AttributeTypes.String: attribute = new StringAttribute(name); break; case AttributeTypes.Int: attribute = new IntAttribute(name); break; case AttributeTypes.Float: attribute = new FloatAttribute(name); break; case AttributeTypes.Vector2: attribute = new Vector2Attribute(name); break; case AttributeTypes.Vector3: attribute = new Vector3Attribute(name); break; case AttributeTypes.Quaternion: attribute = new QuaternionAttribute(name); break; case AttributeTypes.Matrix: attribute = new MatrixAttribute(name); break; case AttributeTypes.Bool: attribute = new BoolAttribute(name); break; default: throw new System.Exception("AttributeType '" + type + "' does not exist!"); } attribute.Initialize(value); AddAttribute(attribute); }
internal AttributeInfo(Reader reader) { Name = new NameIdentifier(reader); Type = (AttributeTypes)reader.ReadByte(); string attribute = Objects.GetAttributeName(Name); if (attribute != null) { // Type mismatch //if (attribute.Type != Type) return; Name.Name = attribute; } else { var everyAttribute = Objects.AttributeNames; string hashString = Name.HashString(); foreach (System.Collections.Generic.KeyValuePair <string, string> s in everyAttribute) { NameIdentifier currentName = new NameIdentifier(s.Value); String currentHashedName = currentName.HashString(); if (currentHashedName == hashString) { Name = currentName; break; } } } }
public Attribute(AttributeTypes type, int level) { AttributeType = type; AttributeLevel = level; SetupTypeOfAttribute(); SetStatName(); }
public int length; //the length of string public Attribute(string attribute_name, AttributeTypes type, bool is_unique, int length) { this.attribute_name = attribute_name; this.type = type; this.is_unique = is_unique; this.length = length; }
private void OnDeserialized(StreamingContext context) { if (!_unmappedData.Any()) { return; } if (Address == null) { MapAddressFields(); } if (AttributeTypes == null || !AttributeTypes.Any()) { MapMultiSelectAttributes(); } if (SingleAttributes == null || !SingleAttributes.Any()) { MapSingleSelectAttributes(); } if (Participants == null || !Participants.Any()) { MapParticipants(); } }
/// <summary> /// Creates a new effect that increases or decreases a specified stat or skill over time. /// </summary> /// <param name="effectType">Effect type.</param> /// <param name="attributeType">Attribute type.</param> /// <param name="rounds">Rounds.</param> public Effect(EffectTypes effectType, AttributeTypes attributeType, int rounds, int effectValue) { EffectType = effectType; AttributeType = attributeType; PeriodType = PeriodTypes.EffectOverTime; Rounds = rounds; EffectValue = effectValue; }
public Type[] FindClassesInAssemblyContaining <T>(AttributeTypes attributeType) { return(typeof(T).Assembly.GetTypes() .Where(type => type.GetCustomAttributes(false) .Any(attribute => attribute is ReferencesEnumAttribute && ((ReferencesEnumAttribute)attribute).AttributeType == attributeType)) .ToArray()); }
/// <summary> /// Creates an on going effect that increases or decreases a specified stat or skill /// </summary> /// <param name="effectType">Effect type.</param> /// <param name="attributeType">Attribute type.</param> public Effect(EffectTypes effectType, AttributeTypes attributeType, int effectValue) { EffectType = effectType; AttributeType = attributeType; PeriodType = PeriodTypes.OnGoing; Rounds = -1; EffectValue = effectValue; }
private void CheckType(AttributeTypes type) { if (type != Type) { //throw new Exception("Unexpected value type."); switch (type) { case AttributeTypes.UINT8: value_uint8 = 0; break; case AttributeTypes.UINT16: value_uint16 = 0; break; case AttributeTypes.UINT32: value_uint32 = 0; break; case AttributeTypes.INT8: value_int8 = 0; break; case AttributeTypes.INT16: value_int16 = 0; break; case AttributeTypes.INT32: value_int32 = 0; break; case AttributeTypes.ENUM: value_enum = 0; break; case AttributeTypes.BOOL: value_bool = false; break; case AttributeTypes.COLOR: value_color = Color.EMPTY; break; case AttributeTypes.VECTOR2: case AttributeTypes.VECTOR3: value_vector2 = no_position; break; case AttributeTypes.STRING: value_string = string.Empty; break; default: throw new Exception("Unexpected value type."); } } }
public ActionEntityAttributeChange(SceneEntity entity, string tag, object oldValue, object newValue, AttributeTypes type, Action <SceneEntity, string, object, object, AttributeTypes> setValue) { this.entity = entity; this.name = tag; this.oldValue = oldValue; this.newValue = newValue; this.setValue = setValue; this.type = type; }
internal Attribute(int line, AttributeTypes atttype, string value, AttributeValueType type, bool isGlobal = false) { Line = line; AttributeType = atttype; Value = value; ValueType = type; IsGlobal = isGlobal; AttributeValueCheck(); }
public void AddAttributesFromAssembly(Assembly a) { foreach (var attributeType in a.GetExportedTypes() .Where(t => typeof(Attribute).IsAssignableFrom(t) && !t.IsAbstract)) { AttributeTypes.Add(attributeType); } }
// Mark a given attribute as changed. public void SetAttributeChanged(AttributeTypes attribID) { if (attributeChanges == 0) { // Notify the node tree that a change has been applied. SetNodeChanged(); } attributeChanges |= (1U << (int)attribID); touchedAttributes |= attributeChanges; }
// I'd recommend using string parameters for your buttons instead // of enum parameters, but you can do it either way public void ModifyUnitButtonHandler(ArmyTypes army, UnitTypes unit, AttributeTypes attribute, int value) { // I'm not sure if the ? operator exists in Unity's default .NET version. // If not, you can use a few if/then statements to make sure that nothing // returns null GetArmy(army.ToString())? .GetUnit(unit.ToString())? .GetAttribute(attribute.ToString())? .Add(value); }
private Weapon CreateWeaponSword(EffectTypes effectType, AttributeTypes attributeTypes, int value, string name) { List <Effect> effects = new List <Effect>(); Effect tempEffect = new Effect(effectType, attributeTypes, value); effects.Add(tempEffect); return(new Weapon(6, WeaponTypes.Sword, Handedness.Single, DamageTypes.Slashing, name, ItemTypes.Weapon, MaterialTypes.Steel, 400, effects)); }
private void button3_Click(object sender, EventArgs e) { DataGridViewSelectedRowCollection rows = dataGridView1.SelectedRows; if (rows.Count != 1) { return; } AttributeTypes attr = (AttributeTypes)rows[0].Cells[0].Value; //rows[0].Cells[1].Value; }
public Type[] FindClassesInAssemblyContaining <TContains, TInheritsFrom>(AttributeTypes attributeType) where TInheritsFrom : class { return(typeof(TContains).Assembly.GetTypes() .Where(type => type.IsAssignableFrom(typeof(TInheritsFrom)) && type.GetCustomAttributes(false) .Any(attribute => attribute is ReferencesEnumAttribute && ((ReferencesEnumAttribute)attribute).AttributeType == attributeType)) .ToArray()); }
private static ValueTypes AttrToValType(AttributeTypes attrType) { if (attrType == AttributeTypes.ATTR_ID || attrType == AttributeTypes.ATTR_IDS) { return(ValueTypes.ValueId); } else { return(ValueTypes.Text); } }
/// <summary> /// Try to get the type (types because it can be multiple) of this entry instance. /// </summary> public bool TryGetAttributeType(out AttributeTypes attributeType) { var map = maps.FirstOrDefault(x => x.AttributeResourceType == AttributeResourceTypes.ATTR_TYPE); if (map != null) { attributeType = map.ValueAsAttributeType; return true; } attributeType = AttributeTypes.TYPE_ANY; return false; }
public override void LoadFromTGSerializedObject(TGSerializedObject _tg) { base.LoadFromTGSerializedObject(_tg); Name = _tg.GetString("Name"); Value = _tg.GetString("Value"); string temp = _tg.GetString("AttributeType"); AttributeType = (AttributeTypes)Enum.Parse(typeof(AttributeTypes), temp); }
/// <summary> /// Try to get the type (types because it can be multiple) of this entry instance. /// </summary> public bool TryGetAttributeType(out AttributeTypes attributeType) { var map = maps.FirstOrDefault(x => x.AttributeResourceType == AttributeResourceTypes.ATTR_TYPE); if (map != null) { attributeType = map.ValueAsAttributeType; return(true); } attributeType = AttributeTypes.TYPE_ANY; return(false); }
public static string GetTypeString(AttributeTypes type) { for (int i = 0; i < stringTypeMappings.Length; ++i) { if (((AttributeTypes)stringTypeMappings[i, 1]) == type) { return((string)stringTypeMappings[i, 0]); } } throw new System.Exception(string.Format("{0} is not a valid type!", type)); }
public int GetModifier(AttributeTypes attribute) { switch (attribute) { case AttributeTypes.Str: return (Strength + StrBonus - 10)/2; case AttributeTypes.Dex: return (Dexterity + DexBonus - 10)/2; case AttributeTypes.Con: return (Constitution + ConBonus - 10)/2; case AttributeTypes.Int: return (Intelligence + IntBonus - 10)/2; case AttributeTypes.Wis: return (Wisdom + WisBonus - 10)/2; case AttributeTypes.Cha: return (Charisma + ChaBonus - 10)/2; default: return 0; } }
/// <summary> /// /// </summary> /// <param name="type"></param> public Attribute(AttributeTypes type) { this.mType = type; }
internal AttributeUsage(AttributeTypes AttributeType, bool IsOptional) { this.AttributeType = AttributeType; this.IsOptional = IsOptional; }
public DykAttribute(AttributeTypes type, int ArgCount) { gType = type; gnArgCount = ArgCount; }
private static ValueTypes AttrToValType(AttributeTypes attrType) { if( attrType == AttributeTypes.ATTR_ID || attrType == AttributeTypes.ATTR_IDS ) return ValueTypes.ValueId; else return ValueTypes.Text; }
public string ParseAttribute(string valueIn, AttributeTypes type) { try { switch (type) { case AttributeTypes.Text: return ParseAttributeText(valueIn); case AttributeTypes.List: return ParseAttributeList(valueIn); case AttributeTypes.Src: return ParseAttributeUrl(valueIn, false); case AttributeTypes.Href: return ParseAttributeUrl(valueIn, true); case AttributeTypes.Number: return ParseAttributeNumber(valueIn); case AttributeTypes.Style: return ParseAttributeStyle(valueIn); case AttributeTypes.Colour: return ParseAttributeColour(valueIn); case AttributeTypes.UseMap: return ParseAttributeUseMap(valueIn); case AttributeTypes.Remove: return ""; default: return ""; } } catch { return ""; } }
public Filter(string attributeName, string value, FilterOperation operation, AttributeTypes attributeType) : this(attributeName, value, operation) { AttributeType = attributeType; }
public ExtendedAttributes(byte[] data, uint FileBlockCount) { if (data == null) { throw new ArgumentNullException(nameof(data)); } using (MemoryStream ms = new MemoryStream(data)) { using (BinaryReader br = new BinaryReader(ms)) { // Initial length (without any attributes) should be at least 8 bytes uint expectedDataLength = 8; if (data.Length < expectedDataLength) { this.Version = 0; this.AttributesPresent = 0; this.FileAttributes = null; } else { this.Version = br.ReadUInt32(); this.AttributesPresent = (AttributeTypes)br.ReadUInt32(); List<uint> CRC32s = new List<uint>(); if (this.AttributesPresent.HasFlag(AttributeTypes.CRC32)) { expectedDataLength += sizeof(uint) * FileBlockCount; for (int i = 0; i < FileBlockCount; ++i) { if (data.Length >= expectedDataLength) { CRC32s.Add(br.ReadUInt32()); } else { CRC32s.Add(0); } } } else { for (int i = 0; i < FileBlockCount; ++i) { CRC32s.Add(0); } } List<ulong> Timestamps = new List<ulong>(); if (this.AttributesPresent.HasFlag(AttributeTypes.Timestamp)) { expectedDataLength += sizeof(ulong) * FileBlockCount; for (int i = 0; i < FileBlockCount; ++i) { if (data.Length >= expectedDataLength) { Timestamps.Add(br.ReadUInt64()); } else { Timestamps.Add(0); } } } else { for (int i = 0; i < FileBlockCount; ++i) { Timestamps.Add(0); } } List<string> MD5s = new List<string>(); if (this.AttributesPresent.HasFlag(AttributeTypes.MD5)) { expectedDataLength += 16 * FileBlockCount; for (int i = 0; i < FileBlockCount; ++i) { if (data.Length >= expectedDataLength) { byte[] md5Data = br.ReadBytes(16); string md5 = BitConverter.ToString(md5Data).Replace("-", ""); MD5s.Add(md5); } else { MD5s.Add(""); } } } else { for (int i = 0; i < FileBlockCount; ++i) { MD5s.Add(""); } } this.FileAttributes = new List<FileAttributes>(); for (int i = 0; i < FileBlockCount; ++i) { this.FileAttributes.Add(new FileAttributes(CRC32s[i], Timestamps[i], MD5s[i])); } } } } }
// ----------------------------------------------- // ----------------------------------------------- static bool _enterElementAttribute(StringBuilder s, AttributeTypes AttributeType, object value, bool firstAttributeOrSubBranch) { if (value == null) return false; if (!firstAttributeOrSubBranch) s.Append(","); s.Append("\n\""); s.Append(JSONSerializationFormatter.JSONAttributeNames[(int)AttributeType]); s.Append("\": \""); s.Append(Tools.TranscodeToJSONCompatibleString(value.ToString())); s.Append("\""); return true; }
bool _enterElementAttribute(ref ChannelInfos channelInfos, AttributeTypes AttributeType, object value) { if (value == null) return false; this.ChannelWriteStringToStream(ref channelInfos, " "); this.ChannelWriteStringToStream(ref channelInfos, XmlSerializationFormatter.XmlAttributeNames[(int)AttributeType]); this.ChannelWriteStringToStream(ref channelInfos, "=\""); this.ChannelWriteStringToStream(ref channelInfos, Tools.TranscodeToXmlCompatibleString(value.ToString())); this.ChannelWriteStringToStream(ref channelInfos, "\""); return true; }