本文整理汇总了C#中Parameter.GetAttribute方法的典型用法代码示例。如果您正苦于以下问题:C# Parameter.GetAttribute方法的具体用法?C# Parameter.GetAttribute怎么用?C# Parameter.GetAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Parameter
的用法示例。
在下文中一共展示了Parameter.GetAttribute方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WriteParameter
protected virtual void WriteParameter(TextWriter writer, IEnumerable<ParameterSet> sets, Parameter parameter)
{
writer.Write('-');
writer.Write(parameter.Name);
writer.Write(' ');
if (parameter.Type == typeof(Switch))
{
writer.WriteLine("[<" + typeof(Switch).Name + ">]");
}
else
{
writer.Write('<');
writer.Write(parameter.Type.Name);
writer.Write('>');
writer.WriteLine();
}
writer.WriteLine();
writer.Write(" ");
writer.WriteLine(parameter.HelpMessage());
writer.WriteLine();
writer.WriteLine(" {0,-25}{1}", "Required?", parameter.GetAttribute<RequiredAttribute>() != null);
writer.WriteLine(" {0,-25}{1}", "Position?", parameter.Position.HasValue ? parameter.Position.Value.ToString() : "named");
string defValue;
var defValueAttr = parameter.GetAttribute<DefaultValueAttribute>();
if (defValueAttr == null)
defValue = "None";
else
defValue = defValueAttr.Value.ToString();
writer.WriteLine(" {0,-25}{1}", "Default value", defValue);
writer.WriteLine(" {0,-25}{1}",
"Parameter sets",
string.Join(", ", sets.Where(s => s.Contains(parameter)).Select(s => s.Name)));
}
示例2: IsDeclaredEscaping
public static bool IsDeclaredEscaping(Parameter p, out bool owned) {
if (WorstCase) {
owned = true;
return true;
}
bool res = false;
owned = false;
if (p.GetAttribute(SystemTypes.CapturedAttribute) != null) {
owned = true;
return true;
}
if (p is This) {
Method m = ((This)p).DeclaringMethod;
return IsEscaping(m, out owned);
}
AttributeNode attr = p.GetAttribute(SystemTypes.EscapesAttribute);
if (attr != null) {
EscapesAttribute escAttr = (EscapesAttribute)attr.GetRuntimeAttribute();
if (escAttr != null) {
res = escAttr.Value;
owned = escAttr.Owned;
}
}
return res;
}
示例3: IsDeclaredRead
public static bool IsDeclaredRead(Parameter p) {
if (WorstCase)
return true;
bool res = true;
AttributeNode attr = p.GetAttribute(SystemTypes.ReadAttribute);
if (attr != null) {
ReadAttribute rAttr = (ReadAttribute)attr.GetRuntimeAttribute();
res = rAttr.Value;
}
return res;
}
示例4: IsDeclaredWrite
public static bool IsDeclaredWrite(Parameter p) {
if (WorstCase)
return true;
bool res = true;
AttributeNode attr = p.GetAttribute(SystemTypes.WriteAttribute);
if (attr != null) {
WriteAttribute wAttr = (WriteAttribute)attr.GetRuntimeAttribute();
res = wAttr.Value;
}
else
res = true;
return res;
}
示例5: IsDeclaredWriteConfined
public static bool IsDeclaredWriteConfined(Parameter p) {
if (WorstCase)
return false;
if (PointsToAndEffectsAnnotations.writeConfinedByDefault) return true;
bool res = false;
AttributeNode attr = p.GetAttribute(SystemTypes.WriteConfinedAttribute);
if (attr != null) {
WriteConfinedAttribute wAttr = (WriteConfinedAttribute)attr.GetRuntimeAttribute();
res = wAttr.Value;
}
else
res = false;
// res = p.GetAttribute(SystemTypes.WriteConfinedAttribute) != null;
return res;
}
示例6: IsDeclaredFresh
public static bool IsDeclaredFresh(Parameter p) {
if (WorstCase)
return false;
bool res = false;
res = p.GetAttribute(SystemTypes.FreshAttribute) != null;
return res;
}
示例7: IsAssumedPureDelegate
public static bool IsAssumedPureDelegate(Parameter p) {
if (WorstCase)
return false;
bool res = false;
res = p.GetAttribute(SystemTypes.PureAttribute) != null;
return res;
}