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); }
public static NodeAttribute GetNodeAttribute(IntAttribute attr) { switch (attr) { case IntAttribute.Id: return(NodeAttribute.Id); case IntAttribute.IsDeleted: return(NodeAttribute.IsDeleted); case IntAttribute.IsInherited: return(NodeAttribute.IsInherited); case IntAttribute.Index: return(NodeAttribute.Index); case IntAttribute.Locked: return(NodeAttribute.Locked); case IntAttribute.LockType: return(NodeAttribute.LockType); case IntAttribute.LockTimeout: return(NodeAttribute.LockTimeout); case IntAttribute.MajorVersion: return(NodeAttribute.MajorVersion); case IntAttribute.MinorVersion: return(NodeAttribute.MinorVersion); case IntAttribute.FullTextRank: return(NodeAttribute.FullTextRank); case IntAttribute.ParentId: return(NodeAttribute.ParentId); case IntAttribute.LockedById: return(NodeAttribute.LockedById); case IntAttribute.CreatedById: return(NodeAttribute.CreatedById); case IntAttribute.ModifiedById: return(NodeAttribute.ModifiedById); case IntAttribute.IsSystem: return(NodeAttribute.IsSystem); case IntAttribute.ClosestSecurityNodeId: return(NodeAttribute.ClosestSecurityNodeId); case IntAttribute.SavingState: return(NodeAttribute.SavingState); default: throw new NotImplementedException("Unknown IntAttribute"); } }
public IntExpression(IntAttribute property, ValueOperator op, PropertyType value) { if (value == null) throw new ArgumentNullException("value"); if (value.DataType != DataType.Int) throw GetWrongPropertyDataTypeException("value", DataType.Int); _binExp = new BinaryExpression((NodeAttribute)property, BinaryExpression.GetOperator(op), value); }
protected void PlayersOnIslandChangeHandler(IntAttribute sender, int oldVlaue, int newValue) { Debug.WriteLine("Number of players on island " + island.Name + " changed from " + oldVlaue + " to " + newValue); if (newValue == 0) { lastPlayerLeftAt = Game.Instance.Simulation.Time.At; } }
private void GamePadIndexChanged( IntAttribute sender, int oldValue, int newValue ) { ChangeInt("GamePadIndex", newValue); }
private void MaxFuelChanged( IntAttribute sender, int oldValue, int newValue ) { ChangeInt("MaxFuel", newValue); }
private void FrozenChanged( IntAttribute sender, int oldValue, int newValue ) { ChangeInt("Frozen", newValue); }
private void LivesChanged( IntAttribute sender, int oldValue, int newValue ) { ChangeInt("Lives", newValue); }
public IntExpression(PropertyType property, ValueOperator op, IntAttribute value) { if (property == null) throw new ArgumentNullException("property"); if (property.DataType != DataType.Int) throw GetWrongPropertyDataTypeException("property", DataType.Int); _binExp = new BinaryExpression(property, BinaryExpression.GetOperator(op), BinaryExpression.GetNodeAttribute(value)); }
public IntExpression(IntAttribute property, ValueOperator op, PropertyType value) { if (value == null) { throw new ArgumentNullException("value"); } if (value.DataType != DataType.Int) { throw GetWrongPropertyDataTypeException("value", DataType.Int); } _binExp = new BinaryExpression((NodeAttribute)property, BinaryExpression.GetOperator(op), value); }
public IntExpression(PropertyType property, ValueOperator op, IntAttribute value) { if (property == null) { throw new ArgumentNullException("property"); } if (property.DataType != DataType.Int) { throw GetWrongPropertyDataTypeException("property", DataType.Int); } _binExp = new BinaryExpression(property, BinaryExpression.GetOperator(op), BinaryExpression.GetNodeAttribute(value)); }
private void FrozenChanged( IntAttribute sender, int oldValue, int newValue ) { if (newValue > 0) { ChangeBool("Frozen", true); } else { ChangeBool("Frozen", false); } }
public SearchOrder(IntAttribute propertyToOrder, OrderDirection direction) : this((NodeAttribute)propertyToOrder, direction) { }
private static Expression ParseIntExpression(XmlNode node, XmlNamespaceManager nsmgr, SchemaRoot schema) { ValueOperator op = ParseValueOperator(node); object leftValue = ParseLeftValue(node, nsmgr, schema); object rightValue = ParseRightValue(node, nsmgr, schema); PropertyType leftProp = leftValue as PropertyType; if (leftProp != null) { if (rightValue == null) { return(new IntExpression(leftProp, op, (int?)null)); } PropertyType rightProp = rightValue as PropertyType; if (rightProp != null) { return(new IntExpression(leftProp, op, rightProp)); } string rightString = rightValue as String; if (rightString != null) { return(new IntExpression(leftProp, op, XmlConvert.ToInt32(rightString))); } try { IntAttribute rightAttr = (IntAttribute)rightValue; return(new IntExpression(leftProp, op, rightAttr)); } catch (Exception e) //rethrow { throw new ApplicationException(String.Concat("Unrecognized IntAttribute: '", rightValue, "'. Source: ", node.OuterXml), e); } } else { IntAttribute leftAttr = (IntAttribute)leftValue; if (rightValue == null) { return(new IntExpression(leftAttr, op, (int?)null)); } PropertyType rightProp = rightValue as PropertyType; if (rightProp != null) { return(new IntExpression(leftAttr, op, rightProp)); } string rightString = rightValue as String; if (rightString != null) { return(new IntExpression(leftAttr, op, XmlConvert.ToInt32(rightString))); } try { IntAttribute rightAttr = (IntAttribute)rightValue; return(new IntExpression(leftAttr, op, rightAttr)); } catch (Exception e) //rethrow { throw new ApplicationException(String.Concat("Unrecognized IntAttribute: '", rightValue, "'. Source: ", node.OuterXml), e); } } }
public IntExpression(IntAttribute property, ValueOperator op, IntAttribute value) { _binExp = new BinaryExpression((NodeAttribute)property, BinaryExpression.GetOperator(op), BinaryExpression.GetNodeAttribute(value)); }
public SearchOrder(IntAttribute propertyToOrder) : this(propertyToOrder, OrderDirection.Asc) { }
private Element ConvertXElementToElement(XElement element) { var elementValues = new List <string>(); if (!element.Elements().Any()) { var tElem = _oldRoot.Descendants(element.Name).Where(x => GetParentsAsString(x, -1) == GetParentsAsString(element, -1) && !x.Elements().Any()).Select(e => e.Value); elementValues.AddRange(tElem); } var xElementList = _oldRoot.Descendants(element.Name).GroupBy(el => el.Parent).Select(g => new { g.Key, Count = g.Count() }).Where(x => x.Count > 1); Element returnElement; var elementName = element.Name.LocalName; var elementType = DataType.GetDataTypeFromList(elementValues, _dateFormat, _dateTimeFormat); switch (elementType.type) { case DataType.Type.Date: returnElement = new DateTimeElement(elementName, _dateFormat); break; case DataType.Type.DateTime: returnElement = new DateTimeElement(elementName, _dateTimeFormat); break; case DataType.Type.Bool: returnElement = new BoolElement(elementName, "True", "False"); break; case DataType.Type.@bool: returnElement = new BoolElement(elementName, "true", "false"); break; case DataType.Type.@int: returnElement = new IntElement(elementName); break; case DataType.Type.@decimal: returnElement = new DecimalElement(elementName); break; case DataType.Type.@string: returnElement = new StringElement(elementName); break; default: returnElement = new Element(elementName); break; } returnElement.Enumerable = xElementList.Any(); returnElement.Type = elementType; returnElement.OriginalElement = element; foreach (var xElement in element.Elements()) { returnElement.Elements.Add(ConvertXElementToElement(xElement)); } foreach (var xAttribute in element.Attributes()) { var tElements = _oldRoot.DescendantsAndSelf(element.Name).Where(x => GetParentsAsString(x, -1) == GetParentsAsString(element, -1)).ToList(); var xAttr = xAttribute; var attributeValues = tElements.Select(tElement => tElement.Attribute(xAttr.Name)).Select(attribute => attribute != null ? attribute.Value : "").ToList(); Attribute thisAttribute; var attributeName = xAttribute.Name.LocalName; if (xAttribute.IsNamespaceDeclaration) { returnElement.NamespaceAttributes.Add(xAttribute); continue; } if (attributeName == "schemaLocation") { thisAttribute = new SchemaLocationAttribute(attributeName, xAttribute.Value); returnElement.Attributes.Add(thisAttribute); continue; } var attributeType = DataType.GetDataTypeFromList(attributeValues, _dateFormat, _dateTimeFormat); switch (attributeType.type) { case DataType.Type.Date: thisAttribute = new DateTimeAttribute(attributeName, _dateFormat); break; case DataType.Type.DateTime: thisAttribute = new DateTimeAttribute(attributeName, _dateTimeFormat); break; case DataType.Type.Bool: thisAttribute = new BoolAttribute(attributeName, "True", "False"); break; case DataType.Type.@bool: thisAttribute = new BoolAttribute(attributeName, "true", "false"); break; case DataType.Type.@int: thisAttribute = new IntAttribute(attributeName); break; case DataType.Type.@decimal: thisAttribute = new DecimalAttribute(attributeName); break; case DataType.Type.@string: thisAttribute = new StringAttribute(attributeName); break; default: thisAttribute = new Attribute(attributeName); break; } thisAttribute.Type = attributeType; returnElement.Attributes.Add(thisAttribute); } return(returnElement); }
private CarPartAttribute GetPreparedAttribute(CarPartAttributeData attributeData) { var attributeName = HashMapper.ResolveHash(attributeData.NameHash); CarPartAttribute attribute; switch (attributeName) { case "PARTID_UPGRADE_GROUP": attribute = new PartIdAttribute(); break; case "LANGUAGEHASH": attribute = new LanguageHashAttribute(); break; case "KITNUMBER": attribute = new KitNumberAttribute(); break; case "LOD_NAME_PREFIX_SELECTOR": attribute = new LodNamePrefixAttribute(); break; case "LOD_BASE_NAME": attribute = new LodBaseNameAttribute(); break; case "NAME_OFFSET": attribute = new NameOffsetAttribute(); break; case "LOD_CHARACTERS_OFFSET": attribute = new LodCharactersOffsetAttribute(); break; case "LOD_NAME_PREFIX_NAMEHASH": attribute = new LodNamePrefixNameHashAttribute(); break; case "ONLINE": case "STOCK": case "CARBONFIBRE": case "CENTER": case "0x87557E1E": case "0xF9661A07": case "STOCK_MATERIAL": case "USEMARKER1": case "FULLBODY": case "MIRROR": case "ISDECAL": attribute = new BoolAttribute(attributeName); break; case "TEXTURE": attribute = new TextureAttribute(); break; case "0x10C98090": case "MAX_LOD": case "COLOR0ID": case "COLOR1ID": case "COLOR2ID": case "COLOR3ID": case "VINYLLANGUAGEHASH": case "TEXTUREHASH": case "CV": case "SPECIFICCARNAME": case "0x6BA02C05": case "MAT0": case "MAT1": case "MAT2": case "MAT3": case "MAT4": case "MAT5": case "MAT6": case "MAT7": case "0xC9818DFC": case "0xEBB03E66": case "MATNAMEA": case "MATNAMEB": case "0xD68A7BAB": case "RED": case "GREEN": case "BLUE": case "SWATCH": case "GROUPLANGUAGEHASH": case "0x04B39858": case "0x5412A1D9": case "MODEL_TABLE_OFFSET": case "MORPHTARGET_NUM": case "0xCE7D8DB5": case "0x7D29CF3E": case "0x65F58556": case "GLOSS": case "0xB5548ED7": case "0x1B0EA1A9": case "0xEB0101E2": case "0xE80A3B62": case "PAINTGROUP": case "DAMAGELEVEL": attribute = new IntAttribute(attributeName); break; case "BLEND": case "0x9A9B6DDC": attribute = new FloatAttribute(attributeName); break; default: attribute = new IntAttribute(attributeName); Debug.WriteLine("WARNING: Unimplemented attribute {0}; value={1} (0x{1:X8})", attributeName, attributeData.UnsignedParam); break; } attribute.LoadValue(attributeData); if (attribute is StringBasedAttribute sba) { sba.ReadStrings(_stringsDictionary); } return(attribute); }
public static NodeAttribute GetNodeAttribute(IntAttribute attr) { switch (attr) { case IntAttribute.Id: return NodeAttribute.Id; case IntAttribute.IsDeleted: return NodeAttribute.IsDeleted; case IntAttribute.IsInherited: return NodeAttribute.IsInherited; case IntAttribute.Index: return NodeAttribute.Index; case IntAttribute.Locked: return NodeAttribute.Locked; case IntAttribute.LockType: return NodeAttribute.LockType; case IntAttribute.LockTimeout: return NodeAttribute.LockTimeout; case IntAttribute.MajorVersion: return NodeAttribute.MajorVersion; case IntAttribute.MinorVersion: return NodeAttribute.MinorVersion; case IntAttribute.FullTextRank: return NodeAttribute.FullTextRank; case IntAttribute.ParentId: return NodeAttribute.ParentId; case IntAttribute.LockedById: return NodeAttribute.LockedById; case IntAttribute.CreatedById: return NodeAttribute.CreatedById; case IntAttribute.ModifiedById: return NodeAttribute.ModifiedById; default: throw new NotImplementedException("Unknown IntAttribute"); } }
public static void labelAttribute(this IntAttribute _p0) { }