Exemplo n.º 1
0
        public static MessageContext AttributeProperty(MessageContext parent, CCI.AttributeNode attr, string property)
        {
            var loc = default(Location);

            if (attr.SourceContext.Document != null)
            {
                loc = attr.SourceContext.ToLocation();
            }
            return(new MessageContext
                       (parent,
                       loc,
                       sb =>
            {
                sb.Append("Custom attribute ");
                sb.Append(attr.Type.FullName);
                sb.Append(" property ");
                sb.Append(property);
            }));
        }
Exemplo n.º 2
0
        public bool GetValue <T>(MessageContext ctxt, CCI.AttributeNode attribute, CCI.TypeNode attrType, IProperty <T> property, ref T value)
        {
            var expr = default(CCI.Literal);

            if (property.Position >= 0)
            {
                expr = attribute.GetPositionalArgument(property.Position) as CCI.Literal;
            }
            if (expr == null)
            {
                expr = attribute.GetNamedArgument(CCI.Identifier.For(property.Name)) as CCI.Literal;
            }
            if (expr != null)
            {
                value = property.Value(RewriterMsgContext.AttributeProperty(ctxt, attribute, property.Name), expr.Value);
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 3
0
        // ----------------------------------------------------------------------
        // Finding attributes and properties
        // ----------------------------------------------------------------------

        public bool IsAttribute(CCI.AttributeNode attr, CCI.TypeNode attrType)
        {
            return(attr.Type.IsAssignableTo(attrType));
        }
Exemplo n.º 4
0
 public static MessageContext AttributeProperty(CCI.AttributeNode attr, string property)
 {
     return(AttributeProperty(null, attr, property));
 }