当前位置: 首页>>代码示例>>C#>>正文


C# Parameter.GetAttribute方法代码示例

本文整理汇总了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)));
        }
开发者ID:redoz,项目名称:LBi.Cli.Arguments,代码行数:41,代码来源:HelpWriter.cs

示例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;
   }
开发者ID:tapicer,项目名称:resource-contracts-.net,代码行数:25,代码来源:PointsToAndEffectsAnnotations.cs

示例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;
   }
开发者ID:tapicer,项目名称:resource-contracts-.net,代码行数:11,代码来源:PointsToAndEffectsAnnotations.cs

示例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;
      }
开发者ID:tapicer,项目名称:resource-contracts-.net,代码行数:14,代码来源:PointsToAndEffectsAnnotations.cs

示例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;
   }
开发者ID:tapicer,项目名称:resource-contracts-.net,代码行数:15,代码来源:PointsToAndEffectsAnnotations.cs

示例6: IsDeclaredFresh

    public static bool IsDeclaredFresh(Parameter p) {
      if (WorstCase)
        return false;

      bool res = false;
      res = p.GetAttribute(SystemTypes.FreshAttribute) != null;
      return res;
      }
开发者ID:tapicer,项目名称:resource-contracts-.net,代码行数:8,代码来源:PointsToAndEffectsAnnotations.cs

示例7: IsAssumedPureDelegate

    public static bool IsAssumedPureDelegate(Parameter p) {
      if (WorstCase)
        return false;

      bool res = false;
      res = p.GetAttribute(SystemTypes.PureAttribute) != null;
      return res;

      }
开发者ID:tapicer,项目名称:resource-contracts-.net,代码行数:9,代码来源:PointsToAndEffectsAnnotations.cs


注:本文中的Parameter.GetAttribute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。