public static SyntaxList <MemberDeclarationSyntax> AddProperties(this SyntaxList <MemberDeclarationSyntax> memberList, JSchema schema, Dictionary <string, MemberDeclarationSyntax> typeContext, INamingRule namingRule)
        {
            var result = memberList;

            if (schema.Properties != null)
            {
                foreach (var property in schema.Properties)
                {
                    var propertyName = namingRule.GetPropertyName(property.Key);

                    result =
                        result.Add(Syntax.PropertyDeclaration(
                                       GetPropertyType(property.Value, typeContext, propertyName, namingRule).WithTrailingTrivia(Syntax.Space),
                                       propertyName)
                                   .WithModifiers(new SyntaxTokenList().Add(Syntax.Token(SyntaxKind.PublicKeyword)))
                                   .WithAccessorList(Syntax.AccessorList(Syntax.List(
                                                                             Syntax.AccessorDeclaration(SyntaxKind.GetAccessorDeclaration)
                                                                             .WithSemicolonToken(Syntax.Token(SyntaxKind.SemicolonToken)),
                                                                             Syntax.AccessorDeclaration(SyntaxKind.SetAccessorDeclaration)
                                                                             .WithSemicolonToken(Syntax.Token(SyntaxKind.SemicolonToken))
                                                                             ))));
                }
            }

            return(result);
        }
Exemplo n.º 2
0
 public override MemberInfo FindMember(Type modelType, string name, MemberTypes types)
 {
     name = _namingRule.GetPropertyName(name);
     return(base.FindMember(modelType, _namingRule.GetPropertyName(name), types));
 }
Exemplo n.º 3
0
		public static SyntaxList<MemberDeclarationSyntax> AddProperties(this SyntaxList<MemberDeclarationSyntax> memberList, JSchema schema, Dictionary<string, MemberDeclarationSyntax> typeContext, INamingRule namingRule)
		{
			var result = memberList;
			if (schema.Properties != null)
			{
				foreach (var property in schema.Properties)
				{
					var propertyName = namingRule.GetPropertyName(property.Key);

					result =
						result.Add(Syntax.PropertyDeclaration(
							GetPropertyType(property.Value, typeContext, propertyName, namingRule).WithTrailingTrivia(Syntax.Space),
							propertyName)
							.WithModifiers(new SyntaxTokenList().Add(Syntax.Token(SyntaxKind.PublicKeyword)))
							.WithAccessorList(Syntax.AccessorList(Syntax.List(
								Syntax.AccessorDeclaration(SyntaxKind.GetAccessorDeclaration)
									.WithSemicolonToken(Syntax.Token(SyntaxKind.SemicolonToken)),
								Syntax.AccessorDeclaration(SyntaxKind.SetAccessorDeclaration)
									.WithSemicolonToken(Syntax.Token(SyntaxKind.SemicolonToken))
								))));
				}
			}

			return result;
		}