/// <summary> /// Validate single attribute of an entity. /// </summary> /// <param name="entity">Entity</param> /// <param name="attribute">Name of attribute to be validated</param> /// <returns>true, if attribute value is valid; false, otherwise.</returns> public bool Validate(Entity entity, string attribute) { Asset asset = V1Instance.GetAsset(entity.InstanceKey) ?? V1Instance.GetAsset(entity); IAttributeDefinition attributeDefinition = asset.AssetType.GetAttributeDefinition(attribute); return(validator.Validate(asset, attributeDefinition)); }
private Attribute ResolveAssetState(AssetID id, bool validate) { Oid oid = GetOid(id); IAttributeDefinition assetStateDef = oid.AssetType.GetAttributeDefinition("AssetState"); Asset asset = validate ? null : _instance.GetAsset(id); if (asset == null) { asset = GetAsset(oid); if (asset == null) { return(null); } _instance.SetAsset(id, asset); } Attribute attrib = asset.GetAttribute(assetStateDef); if (attrib == null) { attrib = GetAsset(oid).GetAttribute(assetStateDef); } return(attrib); }