Exemplo n.º 1
0
        /// <summary>
        /// Extract information about a single property from its declaration in the syntax tree
        /// </summary>
        /// <param name="extractionContext">The definition extraction context in which the extraction is being performed</param>
        /// <param name="targetTypeDeclaration">The PropertyDeclarationSyntax from which to extract the necessary data</param>
        /// <returns>A readonly list of ExtractedPropertyDefinition containing the data extracted from the syntax tree</returns>
        public static ExtractedPropertyDefinition ExtractPropertyDefinition(DefinitionExtractionContext extractionContext, PropertyDeclarationSyntax propertyDeclaration)
        {
            ExtractedPropertyDefinition propertyDefinition = new ExtractedPropertyDefinition();

            propertyDefinition.PropertyName                           = GetPropertyName(extractionContext, propertyDeclaration);
            propertyDefinition.TypeDefinition.TypeName                = GetPropertyTypeName(extractionContext, propertyDeclaration);
            propertyDefinition.TypeDefinition.TypeNamespace           = extractionContext.GetTypeNamespace(propertyDeclaration.Type);
            propertyDefinition.TypeDefinition.IsAutoSerializable      = extractionContext.IsTypeAutoSerializable(propertyDeclaration.Type);
            propertyDefinition.TypeDefinition.ImplementsIMobileObject = extractionContext.DoesTypeImplementIMobileObject(propertyDeclaration.Type);

            return(propertyDefinition);
        }
        /// <summary>
        /// Extract information about a single field from its declaration in the syntax tree
        /// </summary>
        /// <param name="extractionContext">The definition extraction context in which the extraction is being performed</param>
        /// <param name="fieldDeclaration">The FieldDeclarationSyntax from which to extract the necessary data</param>
        /// <returns>A readonly list of ExtractedFieldDefinition containing the data extracted from the syntax tree</returns>
        public static ExtractedFieldDefinition ExtractFieldDefinition(DefinitionExtractionContext extractionContext, FieldDeclarationSyntax fieldDeclaration)
        {
            ExtractedFieldDefinition fieldDefinition = new ExtractedFieldDefinition();

            fieldDefinition.FieldName = GetFieldName(extractionContext, fieldDeclaration);
            fieldDefinition.TypeDefinition.TypeName                = GetFieldTypeName(extractionContext, fieldDeclaration);
            fieldDefinition.TypeDefinition.TypeNamespace           = extractionContext.GetTypeNamespace(fieldDeclaration.Declaration.Type);
            fieldDefinition.TypeDefinition.IsAutoSerializable      = extractionContext.IsTypeAutoSerializable(fieldDeclaration.Declaration.Type);
            fieldDefinition.TypeDefinition.ImplementsIMobileObject = extractionContext.DoesTypeImplementIMobileObject(fieldDeclaration.Declaration.Type);

            return(fieldDefinition);
        }