本文整理汇总了C#中VersionOne.SDK.APIClient.Asset.GetAttribute方法的典型用法代码示例。如果您正苦于以下问题:C# Asset.GetAttribute方法的具体用法?C# Asset.GetAttribute怎么用?C# Asset.GetAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VersionOne.SDK.APIClient.Asset
的用法示例。
在下文中一共展示了Asset.GetAttribute方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Validate
/// <summary>
/// Validate single Asset attribute. If attribute is not loaded, it is just considered invalid.
/// </summary>
/// <param name="asset">Asset to validate</param>
/// <param name="attributeDefinition">Attribute definition of validated attribute</param>
/// <returns>Validation result</returns>
// TODO create separate private method to avoid excessive GetRequiredFields() calls
public bool Validate(Asset asset, IAttributeDefinition attributeDefinition)
{
GetRequiredFields(asset.AssetType);
asset.EnsureAttribute(attributeDefinition);
Attribute attribute = asset.GetAttribute(attributeDefinition);
bool result = attribute != null && !(IsMultiValueAndUnfilled(attribute) || IsSingleValueAndUnfilled(attribute));
if (!result && attribute != null)
{
result = !attribute.HasChanged && !isAttributeUnfilledOnServer(asset, attributeDefinition);
}
return result;
}
示例2: GetAttributeValue
private static string GetAttributeValue(Asset asset, IAttributeDefinition attributeDef)
{
var value = asset.GetAttribute(attributeDef).Value;
return (null != value) ? value.ToString() : "";
}
示例3: AssertMultiValueAttribute
private void AssertMultiValueAttribute(object expected, Asset subject, string attributeToken)
{
IAttributeDefinition def = _svc.StubCentral.MetaModel.GetAttributeDefinition(attributeToken);
IList values = subject.GetAttribute(def).ValuesList;
Assert.IsNotNull(values);
Assert.IsTrue(values.Contains(expected), "Attribute: {0}\n Values: {1}\n Expected: {2}", attributeToken, EnumerateValues(values), expected);
}
示例4: AssertSingleValueAttribute
private void AssertSingleValueAttribute(object expected, Asset subject, string attributeToken)
{
IAttributeDefinition def = _svc.StubCentral.MetaModel.GetAttributeDefinition(attributeToken);
object actual = subject.GetAttribute(def).Value;
Assert.AreEqual(expected, actual, attributeToken);
}
示例5: FindTimebox
private Oid FindTimebox(Asset test) {
if(createDefect == CreateDefect.CurrentIteration) {
return test.GetAttribute(TestTimeboxDef).Value as Oid;
}
return FindTimebox(test.GetAttribute(TestScheduleDef).Value as Oid);
}
示例6: GetProjectWrapperList
private IEnumerable<ProjectWrapper> GetProjectWrapperList(Asset asset, IAttributeDefinition attrName, int depth) {
var list = new List<ProjectWrapper>{new ProjectWrapper(asset, asset.GetAttribute(attrName).Value.ToString(), depth)};
foreach (var child in asset.Children) {
list.AddRange(GetProjectWrapperList(child, attrName, depth + 1));
}
return list;
}
示例7: CreateRelatedDefect
private Asset CreateRelatedDefect(string newDescription, Asset test) {
var defect = Services.New(DefectType, Oid.Null);
defect.AddAttributeValue(DefectAffectedWorkitemsDef, test.GetAttribute(TestParentDef).Value);
defect.SetAttributeValue(DefectScopeDef, test.GetAttribute(TestScopeDef).Value);
var parent = (Oid)test.GetAttribute(TestParentDef).Value;
defect.SetAttributeValue(DefectType.GetAttributeDefinition("Name"),
string.Format(
"{0} \"{1}\" has failing Acceptance Test(s)",
Services.Localization(parent.AssetType.DisplayName),
test.GetAttribute(TestParentNumberDef).Value));
defect.SetAttributeValue(DefectType.GetAttributeDefinition("Description"), newDescription);
var timeboxOid = FindTimebox(test);
if(!timeboxOid.IsNull) {
defect.SetAttributeValue(DefectTimeboxDef, timeboxOid);
}
return defect;
}
示例8: UpdateOpenTest
private void UpdateOpenTest(Oid newStatus, Asset test) {
var statusAttribute = test.GetAttribute(TestStatusDef);
var statusOid = (Oid)statusAttribute.Value;
if(newStatus != statusOid) {
test.SetAttributeValue(TestStatusDef, newStatus);
Services.Save(test, changeComment);
Logger.Log(string.Format("Updating status of Acceptance Test \"{0}\".", test.Oid.Token));
}
}
示例9: RelatedDefectExists
private bool RelatedDefectExists(Asset test) {
var primaryWorkitemQuery = new Query(PrimaryWorkitem);
var affectedTerm = new FilterTerm(DefectAffectedWorkitemsDef);
affectedTerm.Equal(test.GetAttribute(TestParentDef).Value);
var statusTerm = new FilterTerm(DefectAssetStateDef);
statusTerm.Equal(AssetState.Active);
primaryWorkitemQuery.Filter = new AndFilterTerm(affectedTerm, statusTerm);
return Services.Retrieve(primaryWorkitemQuery).Assets.Count > 0;
}
示例10: TimeboxIsCurrent
private bool TimeboxIsCurrent(Asset test) {
var timeboxOid = test.GetAttribute(TestTimeboxDef).Value as Oid;
if((timeboxOid == null) || timeboxOid.IsNull) {
return false;
}
var timeboxStateQuery = new Query(TimeboxType);
timeboxStateQuery.Selection.Add(TimeboxAssetStateDef);
var term = new FilterTerm(TimeboxType.GetAttributeDefinition("ID"));
term.Equal(timeboxOid.Token);
timeboxStateQuery.Filter = term;
var result = Services.Retrieve(timeboxStateQuery);
if(result.Assets.Count == 0) {
return false;
}
var timebox = result.Assets[0];
return ((AssetState)timebox.GetAttribute(TimeboxAssetStateDef).Value == AssetState.Active);
}
示例11: Link
internal Link(Asset asset) {
Title = asset.GetAttribute(asset.AssetType.GetAttributeDefinition(Entity.NameProperty)).Value.ToString();
Url = asset.GetAttribute(asset.AssetType.GetAttributeDefinition(UrlProperty)).Value.ToString();
OnMenu = (bool)asset.GetAttribute(asset.AssetType.GetAttributeDefinition(OnMenuProperty)).Value;
}
示例12: AssetPassesShowMyTasksFilter
/// <summary>
/// Check if asset should be used when Show My Tasks filter is on
/// </summary>
/// <param name="asset">Story, Task, Defect or Test</param>
/// <returns>true if current user is owner of asset, false - otherwise</returns>
public bool AssetPassesShowMyTasksFilter(Asset asset) {
if(asset.HasChanged || asset.Oid.IsNull) {
return true;
}
var definition = workitemType.GetAttributeDefinition(Entity.OwnersProperty);
var attribute = asset.GetAttribute(definition);
var owners = attribute.Values;
if(owners.Cast<Oid>().Any(oid => oid == MemberOid)) {
return true;
}
return asset.Children != null && asset.Children.Any(AssetPassesShowMyTasksFilter);
}
示例13: SaveChangeSetLink
private void SaveChangeSetLink(ChangeSetInfo info, Asset savedAsset)
{
var name = string.Format(info.Link.Name, info.Revision);
var url = string.Format(info.Link.Url, info.Revision);
var linkUrlAttribute = savedAsset.GetAttribute(ChangeSetType.GetAttributeDefinition("Links.URL"));
if(linkUrlAttribute != null)
{
foreach(string value in linkUrlAttribute.Values)
{
if(value.Equals(url, StringComparison.InvariantCultureIgnoreCase))
{
return;
}
}
}
var newlink = V1Connection.Data.New(LinkType, savedAsset.Oid.Momentless);
newlink.SetAttributeValue(LinkNameDef, name);
newlink.SetAttributeValue(LinkUrlDef, url);
newlink.SetAttributeValue(LinkOnMenuDef, info.Link.OnMenu);
V1Connection.Data.Save(newlink, changecomment);
}