本文整理汇总了C#中System.Item.GetAttributeValueAsText方法的典型用法代码示例。如果您正苦于以下问题:C# Item.GetAttributeValueAsText方法的具体用法?C# Item.GetAttributeValueAsText怎么用?C# Item.GetAttributeValueAsText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Item
的用法示例。
在下文中一共展示了Item.GetAttributeValueAsText方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CopyAllAttributeValues
private static void CopyAllAttributeValues(Item itemSource, Item itemDestination)
{
foreach (var attrib in itemSource.Story.Attributes)
{
if (itemSource.GetAttributeIsAssigned(attrib)) // only copy the value if its assigned
{
var attD = EnsureAttributeExists(attrib, itemDestination.Story);
itemDestination.SetAttributeValue(attD, itemSource.GetAttributeValueAsText(attrib));
}
}
}
示例2: SetAttributeWithLogging
private static void SetAttributeWithLogging(Logger log, Item item, Attribute att, string value)
{
try
{
Debug.WriteLine($"{att.Name} {value}");
item.SetAttributeValue(att, value);
Debug.WriteLine($"{att.Name} {item.GetAttributeValueAsText(att)}");
}
catch (Exception e)
{
log.Log($"Error: {e.Message}, value='{value}', item='{item.Name}', attribute='{att.Name}'");
}
}
示例3: AddAttributeButCheckForDiffernce
private static void AddAttributeButCheckForDiffernce(Item sourceItem, Attribute sourceAttrib, Item destItem, Attribute destAttrib)
{
var test = sourceItem.GetAttributeValueAsText(sourceAttrib);
if (destItem.GetAttributeIsAssigned(destAttrib))
{
// check values are same
var testDest = destItem.GetAttributeValueAsText(destAttrib);
if (test != testDest)
{
destItem.SetAttributeValue(destAttrib, _multipleValues);
return;
}
}
// else can set
destItem.SetAttributeValue(destAttrib, test);
}
示例4: ItemHasChanged
private bool ItemHasChanged(Item source, Item copy, Dictionary<string, List<string>> differences )
{
if (source.Id == copy.ExternalId)
{
var list = new List<string>();
differences.Add(source.Id, list);
if (source.Name != copy.Name)
list.Add("FileName has changed.");
if (source.Description != copy.Description)
list.Add("Description has changed.");
if (source.IsTransparent != copy.IsTransparent)
list.Add("Transparency has changed.");
if (source.ImageId != copy.ImageId || source.ImageMode != copy.ImageMode)
list.Add("Image has changed.");
if (source.StartDate != copy.StartDate)
list.Add("Start Date has changed.");
if (source.DurationInDays != copy.DurationInDays)
list.Add("Duration has changed.");
// tags
foreach (var tag in source.Tags)
{
if (copy.Tag_FindByName(tag.Text) == null)
list.Add(string.Format("Tag {0} has been added.", tag.Text));
}
// panels
foreach (var panel in source.Panels)
{
if (panel.IsVisible && (panel.Type == Panel.PanelType.Image || panel.Type == Panel.PanelType.RichText || panel.Type == Panel.PanelType.Video) )
{
// find matching panel
var pD = copy.Panel_FindByTitle(panel.Title);
if (pD == null)
list.Add(string.Format("Panel {0} has been added.",panel.Title));
else
{
if (pD.Data != panel.Data)
list.Add(string.Format("Panel {0} has been modified.", panel.Title));
}
}
}
// attributes
foreach (var att in source.Story.Attributes)
{
var val = source.GetAttributeValueAsText(att);
if (att.InUse && att.IsUserDefined && !string.IsNullOrEmpty(val) && source.GetAttributeIsAssigned(att))
{
// add a simailar attribute to the target if it is not already added
var newAtt = copy.Story.Attribute_FindByName(att.Name);
if (newAtt == null)
{
list.Add(string.Format("Attribute '{0}' does not exist in story.", att.Name));
}
else
{
var val2 = copy.GetAttributeValueAsText(newAtt);
if (!copy.GetAttributeIsAssigned(newAtt))
{
list.Add(string.Format("Attribute '{0}' does not exist on the item.", att.Name));
}
else if (val != val2)
{
if (att.Type == Attribute.AttributeType.Numeric)
{
var vald = source.GetAttributeValueAsDouble(att);
var val2d = copy.GetAttributeValueAsDouble(newAtt);
if (vald != val2d)
list.Add(string.Format("Attribute '{0}' has changed. {1} will replace {2}", att.Name, val, val2));
}
else
list.Add(string.Format("Attribute '{0}' has changed. '{1}' will replace '{2}'", att.Name, val, val2));
}
}
}
}
// relationships
foreach (var relationship in source.Relationships)
{
var item1 = copy.Story.Item_FindByExternalId(relationship.Item1.Id);
var item2 = copy.Story.Item_FindByExternalId(relationship.Item2.Id);
if (item1 != null && item2 != null)
{
// there is a relationship in the source and both items exist in the copy
// does the relationship exist in the copy
Relationship rel;
if (item1.Id == copy.Id)
{
rel = copy.Relationship_FindByItem(item2);
if (rel == null)
list.Add(string.Format("Relationship missing to {0}", item2.Name));
else
CheckIfRelationshipsAreDifferent(relationship, rel, list);
}
//.........这里部分代码省略.........