Exemplo n.º 1
0
 /// <summary>
 /// Method reads all the CodeAttributeAnnotation defined as a part of EntityType and MemberProperty on an EntityModelSchema
 /// and generates appropiate codedom snippet for it.
 /// </summary>
 /// <param name="codeClass">CodeDom class to apply annotation on</param>
 /// <param name="codeAttributeAnnotations">Annotateditem which is to be read and interpreted</param>
 protected virtual void AddCodeAttributeAnnotationAsCustomAttribute(CodeTypeMember codeClass, IEnumerable <CodeAttributeAnnotation> codeAttributeAnnotations)
 {
     foreach (CodeAttributeAnnotation caa in codeAttributeAnnotations)
     {
         codeClass.AddCustomAttribute(caa.TypeOfAttribute, Code.CustomAttributeArguments(caa.Arguments));
     }
 }
Exemplo n.º 2
0
        public static CodeAttributeDeclaration AddCustomAttribute(this CodeTypeMember member, string name, string value)
        {
            CodeExpression expression;

            // Use convention that if string starts with $ its a const
            if (value.StartsWith(SnippetIndicator.ToString()))
            {
                expression = new CodeSnippetExpression(value.TrimStart(SnippetIndicator));
            }
            else
            {
                expression = new CodePrimitiveExpression(value);
            }

            return(member.AddCustomAttribute(name, expression));
        }
Exemplo n.º 3
0
 public static CodeAttributeDeclaration AddCustomAttribute(this CodeTypeMember member, string name, object value)
 {
     return(member.AddCustomAttribute(name, new CodePrimitiveExpression(value)));
 }