本文整理汇总了C#中Attribute类的典型用法代码示例。如果您正苦于以下问题:C# Attribute类的具体用法?C# Attribute怎么用?C# Attribute使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Attribute类属于命名空间,在下文中一共展示了Attribute类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LoadAttribute
public static Attribute LoadAttribute( AttributeName name )
{
Attribute att = new Attribute();
att.BaseValue = PlayerPrefs.GetInt(((AttributeName)name).ToString() + BASE_VALUE, 0);
att.ExpToLevel = PlayerPrefs.GetInt(((AttributeName)name).ToString() + EXP_TO_LEVEL, Attribute.STARTING_EXP_COST);
return att;
}
示例2: AppendEntityReferences
public static void AppendEntityReferences(this XElement element, Eav.Entity entity, Attribute attribute)
{
var entityGuids = attribute.ToSIC_EAV_EntityRelationships.Where(rel => rel.ParentEntityID == entity.EntityID)
.Select(rel => rel.ChildEntity.EntityGUID);
var entityGuidsString = string.Join(",", entityGuids);
element.Append(attribute.StaticName, entityGuidsString);
}
示例3: DatumSchema
public DatumSchema(
Attribute[] attributes,
Predicate<string> answerValidator)
{
Attributes = attributes;
AnswerValidator = answerValidator;
}
示例4: AddAttribute
public Attribute AddAttribute(string name, string value, char quotechar, bool caseInsensitive)
{
Attribute a;
for (int i = 0, n = this.attributes.Count; i < n; i++)
{
a = (Attribute)this.attributes[i];
if (caseInsensitive && string.Compare(a.Name, name, true) == 0)
{
return null;
}
else if ((object)a.Name == (object)name)
{
return null;
}
}
a = (Attribute)this.attributes.Push();
if (a == null)
{
a = new Attribute();
this.attributes[this.attributes.Count - 1] = a;
}
a.Reset(name, value, quotechar);
return a;
}
示例5: SetupPrimaryAttributes
private void SetupPrimaryAttributes()
{
for (int cnt = 0; cnt < _primaryAttribute.Length; cnt++)
{
_primaryAttribute[cnt] = new Attribute();
}
}
示例6: ConvertToAttributeAstTypes
public static IEnumerable<Attribute> ConvertToAttributeAstTypes(this IEnumerable<IAttribute> attributes)
{
foreach (var attr in attributes)
{
var attributeAst = attr.AttributeType.ToAstSyntaxType();
var attribute =
new Attribute
{
Type = attributeAst,
Role = Roles.Attribute
};
foreach (var positionalArg in attr.PositionalArguments)
{
attribute.Arguments.Add(new PrimitiveExpression(positionalArg.ConstantValue));
}
foreach (var namedArg in attr.NamedArguments)
{
attribute.Arguments.Add(new NamedExpression(
namedArg.Key.Name,
new PrimitiveExpression(namedArg.Value.ConstantValue)));
}
yield return attribute;
}
}
示例7: DeserializePropertiesFromResources
protected void DeserializePropertiesFromResources (
IDesignerSerializationManager manager,
Object value,
Attribute[] filter )
{
}
示例8: ApplyAttribute
/// <summary>
/// Applies a loaded attribute
/// </summary>
/// <param name="attribute">attribute</param>
public void ApplyAttribute(Attribute attribute)
{
if (attribute.Key.EndsWith("Mana Amount")) {
manaBaseBox.Text = ((int)attribute.Initial).ToString();
manaBonusBox.Text = ((int)attribute.Scale).ToString();
}
}
示例9: Attribute
public void Attribute()
{
Attribute inter = new Attribute(controller);
inter.PositionalArguments.Add("asdfsadf");
Assert.That(inter.IsTheSame(inter.Clone(), ComparisonDepth.Outer), Is.True);
}
示例10: Gain
private double Gain(List<List<string>> Examples, Attribute A, string bestat)
{
double result;
int CountPositives = 0;
int[] CountPositivesA = new int[A.LValue.Count]; int[] CountNegativeA = new int[A.LValue.Count]; int Col = Attributes.IndexOf(A);
for (int i = 0; i < A.LValue.Count; i++)
{
CountPositivesA[i] = 0;
CountNegativeA[i] = 0;
}
for (int i = 0; i < Examples.Count; i++)
{
int j = A.LValue.IndexOf(Examples[i][Col].ToString());
if (Examples[i][Examples[0].Count - 1] == "yes")
{
CountPositives++;
CountPositivesA[j]++;
}
else
{
CountNegativeA[j]++;
}
}
result = GetEntropy(CountPositives, Examples.Count - CountPositives); for (int i = 0; i < A.LValue.Count; i++)
{
double RateValue = (double)(CountPositivesA[i] + CountNegativeA[i]) /
Examples.Count;
result = result - RateValue * GetEntropy(CountPositivesA[i], CountNegativeA[i]);
}
Solution = Solution + "\n * Gain(" + bestat + "," + A.Name + ") = " + result.ToString();
return result;
}
示例11: GetProperties
/// <summary>
/// <para>Gets a collection of properties for the type of array specified by the value parameter.</para>
/// </summary>
public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes)
{
if (value == null)
{
return null;
}
PropertyDescriptor[] props = null;
if (value.GetType().IsArray)
{
Array valueArray = (Array)value;
int length = valueArray.GetLength(0);
props = new PropertyDescriptor[length];
Type arrayType = value.GetType();
Type elementType = arrayType.GetElementType();
for (int i = 0; i < length; i++)
{
props[i] = new ArrayPropertyDescriptor(arrayType, elementType, i);
}
}
return new PropertyDescriptorCollection(props);
}
示例12: ApplyAttribute
/// <summary>
/// Applies a loaded attribute
/// </summary>
/// <param name="attribute">attribute</param>
public void ApplyAttribute(Attribute attribute)
{
if (attribute.Key.EndsWith("Mana Percent")) {
percentBaseBox.Text = attribute.Initial.ToString();
percentBonusBox.Text = attribute.Scale.ToString();
}
}
示例13: foreach
public int this[string name]
{
get
{
foreach (Attribute attribute in this)
{
if (attribute.Name == name)
return attribute.Value;
}
return int.MinValue;
}
set
{
foreach (Attribute attribute in this)
{
if (attribute.Name == name)
{
attribute.Value = value;
return;
}
}
var attr = new Attribute {Name = name, Value = value};
List.Add(attr);
}
}
示例14: AddAttribute
private void AddAttribute(
Attribute a)
{
DerObjectIdentifier oid = a.AttrType;
object obj = attributes[oid];
if (obj == null)
{
attributes[oid] = a;
}
else
{
IList v;
if (obj is Attribute)
{
v = Platform.CreateArrayList();
v.Add(obj);
v.Add(a);
}
else
{
v = (IList) obj;
v.Add(a);
}
attributes[oid] = v;
}
}
示例15: ApplyAttribute
/// <summary>
/// Applies a loaded attribute
/// </summary>
/// <param name="attribute">attribute</param>
public void ApplyAttribute(Attribute attribute)
{
if (attribute.Key.EndsWith("Push Speed")) {
pushBaseBox.Text = attribute.Initial.ToString();
pushBonusBox.Text = attribute.Scale.ToString();
}
}