本文整理汇总了C#中AttributeValue类的典型用法代码示例。如果您正苦于以下问题:C# AttributeValue类的具体用法?C# AttributeValue怎么用?C# AttributeValue使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AttributeValue类属于命名空间,在下文中一共展示了AttributeValue类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestCreateAttributeValueWithNullDisplayValue
public void TestCreateAttributeValueWithNullDisplayValue()
{
AttributeValue attributeValue = new AttributeValue("Value", null);
Assert.AreEqual<string>("Value", attributeValue.Value);
Assert.AreEqual<string>("Value", attributeValue.DisplayValue);
}
示例2: Save
/// <summary>
/// Saves the specified item.
/// </summary>
/// <param name="item">The item.</param>
/// <param name="personId">The person identifier.</param>
/// <returns></returns>
public override bool Save( AttributeValue item, int? personId )
{
if ( item.Attribute != null )
{
// ensure that the BinaryFile.IsTemporary flag is set to false for any BinaryFiles that are associated with this record
var fieldTypeImage = Rock.Web.Cache.FieldTypeCache.Read( Rock.SystemGuid.FieldType.IMAGE.AsGuid() );
var fieldTypeBinaryFile = Rock.Web.Cache.FieldTypeCache.Read( Rock.SystemGuid.FieldType.BINARY_FILE.AsGuid() );
if ( item.Attribute.FieldTypeId == fieldTypeImage.Id || item.Attribute.FieldTypeId == fieldTypeBinaryFile.Id )
{
int? binaryFileId = item.Value.AsInteger();
if ( binaryFileId.HasValue )
{
BinaryFileService binaryFileService = new BinaryFileService( this.RockContext );
var binaryFile = binaryFileService.Get( binaryFileId.Value );
if ( binaryFile != null && binaryFile.IsTemporary )
{
binaryFile.IsTemporary = false;
}
}
}
}
return base.Save( item, personId );
}
示例3: TestChangingAttributeValueProperties
public void TestChangingAttributeValueProperties()
{
AttributeValue attribute = new AttributeValue("Value");
object oldValue = null;
object newValue = null;
string propertyChanged = string.Empty;
attribute.PropertyChanged += (object sender, PropertyChangedEventArgs<object> e) =>
{
propertyChanged = e.PropertyName;
oldValue = e.OldValue;
newValue = e.NewValue;
};
// Change Value
EnqueueCallback(() => attribute.Value = "New Value");
EnqueueConditional(() => propertyChanged != string.Empty);
EnqueueCallback(() => Assert.AreEqual<string>("Value", propertyChanged));
EnqueueCallback(() => Assert.AreEqual<string>("Value", (string)oldValue));
EnqueueCallback(() => Assert.AreEqual<string>("New Value", (string)newValue));
EnqueueCallback(() => propertyChanged = string.Empty);
// Change DisplayValue
EnqueueCallback(() => attribute.DisplayValue = "New Display Value");
EnqueueConditional(() => propertyChanged != string.Empty);
EnqueueCallback(() => Assert.AreEqual<string>("DisplayValue", propertyChanged));
EnqueueCallback(() => Assert.AreEqual<string>(null, (string)oldValue));
EnqueueCallback(() => Assert.AreEqual<string>("New Display Value", (string)newValue));
EnqueueCallback(() => propertyChanged = string.Empty);
EnqueueTestComplete();
}
示例4: Execute
/// <summary>
/// Executes the specified workflow.
/// </summary>
/// <param name="rockContext">The rock context.</param>
/// <param name="action">The action.</param>
/// <param name="entity">The entity.</param>
/// <param name="errorMessages">The error messages.</param>
/// <returns></returns>
public override bool Execute( RockContext rockContext, WorkflowAction action, Object entity, out List<string> errorMessages )
{
errorMessages = new List<string>();
if ( entity is Model.BinaryFile )
{
var binaryFile = (Model.BinaryFile) entity;
if ( binaryFile.BinaryFileType.Guid != new Guid( SystemGuid.BinaryFiletype.CHECKIN_LABEL ) )
{
errorMessages.Add( "Binary file is not a check-in label" );
action.AddLogEntry( "Binary file is not a check-in label", true );
return false;
}
StringBuilder sb = new StringBuilder();
var contentString = binaryFile.ContentsToString();
foreach ( Match match in Regex.Matches(
contentString,
@"(?<=\^FD)[^\^FS]*(?=\^FS)" ) )
{
sb.AppendFormat( "{0}^|", match.Value );
}
binaryFile.LoadAttributes();
var attributeValue = new AttributeValue();
attributeValue.Value = sb.ToString();
binaryFile.AttributeValues["MergeCodes"] = attributeValue;
binaryFile.SaveAttributeValues( rockContext );
}
return true;
}
示例5: MakeDecision
public AttributeValue MakeDecision(AttributeValue[] Data, bool Print = false)
{
Dictionary<AttributeValue, int> P = new Dictionary<AttributeValue, int>();
foreach (DecisionTree D in _Trees)
{
AttributeValue V = D.MakeDecision(Data, Print);
bool Found = false;
foreach (AttributeValue Key in P.Keys.ToList())
{
if (Key.CompareTo(V) == 0)
{
P[Key]++;
Found = true;
}
}
if (!Found)
{
P.Add(V, 1);
}
}
AttributeValue M = null;
int N = 0;
foreach(KeyValuePair<AttributeValue, int> p in P)
{
if (p.Value > N)
{
N = p.Value;
M = p.Key;
}
}
return M;
}
示例6: ResolveAttributeValue
public ResolveResult ResolveAttributeValue(XamlContext context, AttributeValue value, out string typeNameString)
{
typeNameString = value.IsString
? value.StringValue
: GetTypeNameFromTypeExtension(value.ExtensionValue, context);
return ResolveExpression(typeNameString, context);
}
示例7: AddEntry
public void AddEntry(AttributeValue[] Entry)
{
for (int i = 0; i < Entry.Length;++i)
{
_Values[i].Add(Entry[i]);
}
}
示例8: Execute
/// <summary>
/// Job that updates the JobPulse setting with the current date/time.
/// This will allow us to notify an admin if the jobs stop running.
///
/// Called by the <see cref="IScheduler" /> when a
/// <see cref="ITrigger" /> fires that is associated with
/// the <see cref="IJob" />.
/// </summary>
public virtual void Execute(IJobExecutionContext context)
{
using ( new Rock.Data.UnitOfWorkScope() )
{
AttributeService attribService = new AttributeService();
AttributeValueService attributeValueService = new AttributeValueService();
Rock.Core.Attribute jobPulseAttrib = attribService.GetGlobalAttribute( "JobPulse" );
Rock.Core.AttributeValue jobPulseAttribValue = jobPulseAttrib.AttributeValues.FirstOrDefault();
// create attribute value if one does not exist
if ( jobPulseAttribValue == null )
{
jobPulseAttribValue = new AttributeValue();
jobPulseAttribValue.AttributeId = jobPulseAttrib.Id;
attributeValueService.Add( jobPulseAttribValue, null );
}
// store todays date and time
jobPulseAttribValue.Value = DateTime.Now.ToString();
// save attribute
attributeValueService.Save( jobPulseAttribValue, null );
}
}
示例9: SatisfiesCondition
private bool SatisfiesCondition(AttributeValue value)
{
if (m_bSearchForKey)
{
if (m_bFullText)
{
if (!value.Key.Contains(m_sSearchKey))
return false;
}
else if (value.Key != m_sSearchKey)
return false;
}
if (m_bSearchForValue)
{
if (value.DataType != AttributeDataType.String)
return false;
if (m_bFullText)
{
if (!(value.Data as string).Contains(m_sSearchValue))
return false;
}
else if ((value.Data as string) != m_sSearchValue)
return false;
}
return true;
}
示例10: getDetailProbability
public double getDetailProbability(AttributeValue ATTRIBUTE_VALUE = AttributeValue.IsTrue)
{
string value;
switch (ATTRIBUTE_VALUE)
{
case AttributeValue.IsFalse:
value = "False";
break;
case AttributeValue.IsMissing:
value = "Missing";
break;
case AttributeValue.IsNull:
value = "0";
break;
case AttributeValue.IsTrue:
default:
value = "True";
break;
}
try
{
return Node.DecisionTreeNodeDistributions.First(nd => nd.ATTRIBUTE_VALUE == value).PROBABILITY;
}
catch (Exception)
{
return 0;
}
}
示例11: TestAddingExistingAttribute
public void TestAddingExistingAttribute()
{
bool exceptionThrown;
AttributeCollection attributes = new AttributeCollection();
AttributeValue newAttributeValue = new AttributeValue("Test Value");
// Add attribute and attribute value
attributes.Add("Test", newAttributeValue);
Assert.AreEqual<string>(newAttributeValue.Value, attributes["Test"].Value);
AttributeValue existingAttributeValue = new AttributeValue("Test Value");
try
{
attributes.Add("Test", existingAttributeValue);
exceptionThrown = false;
}
catch (ArgumentException)
{
exceptionThrown = true;
}
Assert.IsTrue(exceptionThrown);
}
示例12: Discriminator
public Discriminator(int Index, AttributeValue Split, bool Equality)
{
_Index = Index;
_Split = Split;
_Equality = Equality;
if (Split == null) _Function = delegate(AttributeValue[] E) { return E[_Index]; };
else _Function = delegate(AttributeValue[] E) { return new BooleanValue(E[_Index].CompareTo(Split) == (Equality ? 0: -1));};
}
示例13: StringEqualIgnoreCaseMatch
public StringEqualIgnoreCaseMatch(
AttributeDesignator designator,
AttributeValue value)
: base("urn:oasis:names:tc:xacml:3.0:function:string-equal-ignore-case",
designator,
value)
{
}
示例14: AttributeEventArgs
public AttributeEventArgs(Attribute _attribute, AttributeValue _newValue, AttributeValue _oldValue, NotifyCollectionChangedAction _action)
: base()
{
this.attribute = _attribute;
this.newValue = _newValue;
this.oldValue = _oldValue;
this.action = _action;
}
示例15: assertCharacterValue
private void assertCharacterValue(AttributeValue attr, char value)
{
Assert.IsInstanceOfType(attr.getValue(), typeof(PrimitiveObjectBlock));
PrimitiveObjectBlock pob = (PrimitiveObjectBlock)attr.getValue();
Assert.IsInstanceOfType(pob.getSimpleValue(), typeof(CharacterValue));
CharacterValue actual = (CharacterValue)pob.getSimpleValue();
Character expected = new Character(value);
Assert.AreEqual(actual.getValue(), expected);
}