private static void AnalyzeAccessorDeclaration(SyntaxNodeAnalysisContext context)
        {
            var accessor = (AccessorDeclarationSyntax)context.Node;

            BlockSyntax body = accessor.Body;

            if (body != null)
            {
                AnalyzeAccessorDeclarationBlock(context, accessor, body);
            }
            else
            {
                ArrowExpressionClauseSyntax expressionBody = accessor.ExpressionBody;

                if (expressionBody?.ContainsDirectives == false)
                {
                    BodyStyle style = context.GetBodyStyle();

                    if (style.IsDefault)
                        return;

                    if (style.UseBlock)
                    {
                        ReportDiagnostic(context, expressionBody);
                        return;
                    }

                    if (style.UseBlockWhenExpressionIsMultiLine == true
                        && expressionBody.Expression?.IsMultiLine() == true)
                    {
                        ReportDiagnostic(context, expressionBody);
                    }
                }
            }
        }
Пример #2
0
        public List <BodyStyle> GetAll()
        {
            List <BodyStyle> bodyStyles = new List <BodyStyle>();

            using (var cn = new SqlConnection(Settings.GetConnectionString()))
            {
                SqlCommand cmd = new SqlCommand("BodyStyleSelectAll", cn);
                cmd.CommandType = CommandType.StoredProcedure;

                cn.Open();

                using (SqlDataReader dr = cmd.ExecuteReader())
                {
                    while (dr.Read())
                    {
                        BodyStyle currentRow = new BodyStyle();
                        currentRow.BodyStyleID     = (int)dr["BodyStyleID"];
                        currentRow.BodyDescription = dr["BodyDescription"].ToString();

                        bodyStyles.Add(currentRow);
                    }
                }
            }
            return(bodyStyles);
        }
Пример #3
0
        public BodyStyle GetById(byte bodyStyleId)
        {
            BodyStyle bodyStyle = null;

            using (var cn = new SqlConnection(Settings.GetConnectionString()))
            {
                SqlCommand cmd = new SqlCommand("BodyStylesSelectById", cn);
                cmd.CommandType = CommandType.StoredProcedure;

                cmd.Parameters.AddWithValue("@BodyStyleId", bodyStyleId);

                cn.Open();

                using (SqlDataReader dr = cmd.ExecuteReader())
                {
                    if (dr.Read())
                    {
                        bodyStyle             = new BodyStyle();
                        bodyStyle.BodyStyleId = (byte)dr["BodyStyleId"];
                        bodyStyle.Name        = dr["Name"].ToString();
                    }
                }
            }

            return(bodyStyle);
        }
Пример #4
0
        public IEnumerable <BodyStyle> GetAll()
        {
            List <BodyStyle> bodyStyles = new List <BodyStyle>();

            using (var cn = new SqlConnection(Settings.GetConnectionString()))
            {
                SqlCommand cmd = new SqlCommand("BodyStylesSelectAll", cn);
                cmd.CommandType = CommandType.StoredProcedure;

                cn.Open();

                using (SqlDataReader dr = cmd.ExecuteReader())
                {
                    while (dr.Read())
                    {
                        BodyStyle currentRow = new BodyStyle();
                        currentRow.BodyStyleId = (byte)dr["BodyStyleId"];
                        currentRow.Name        = dr["Name"].ToString();

                        bodyStyles.Add(currentRow);
                    }
                }
            }

            return(bodyStyles);
        }
Пример #5
0
        public List <BodyStyle> GetBodyStyle()
        {
            List <BodyStyle> bodyStyle = new List <BodyStyle>();

            using (SqlConnection conn = new SqlConnection())
            {
                conn.ConnectionString = ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString;
                SqlCommand cmd = new SqlCommand();

                cmd.Connection  = conn;
                cmd.CommandType = CommandType.StoredProcedure;

                cmd.CommandText = "GetBodyStyle";


                conn.Open();
                using (SqlDataReader dr = cmd.ExecuteReader())
                {
                    while (dr.Read())
                    {
                        BodyStyle currentRow = new BodyStyle();

                        currentRow.body_ID   = (int)dr["body_ID"];
                        currentRow.bodyStyle = dr["bodyStyle"].ToString();

                        bodyStyle.Add(currentRow);
                    }
                }
            }
            return(bodyStyle);
        }
Пример #6
0
        public List <BodyStyle> GetBodyStyles()
        {
            List <BodyStyle> bodyStyles = new List <BodyStyle>();

            using (var conn = new SqlConnection(Settings.GetConnectionString()))
            {
                SqlCommand cmd = new SqlCommand("BodyStylesSelectAll", conn);
                cmd.CommandType = System.Data.CommandType.StoredProcedure;

                conn.Open();

                using (SqlDataReader dr = cmd.ExecuteReader())
                {
                    while (dr.Read())
                    {
                        BodyStyle row = new BodyStyle();

                        row.BodyStyleID   = (int)dr["BodyStyleID"];
                        row.BodyStyleName = dr["BodyStyleName"].ToString();


                        bodyStyles.Add(row);
                    }
                }
            }

            return(bodyStyles);
        }
Пример #7
0
        public List <BodyStyle> GetAll()
        {
            List <BodyStyle> _bodies = new List <BodyStyle>();

            using (var conn = new SqlConnection())
            {
                conn.ConnectionString = ConfigurationManager.ConnectionStrings["DefaultConnection"].ToString();
                SqlCommand cmd = new SqlCommand("BodyStyleSelectAll", conn);
                cmd.CommandType = CommandType.StoredProcedure;

                conn.Open();

                using (SqlDataReader reader = cmd.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        BodyStyle row = new BodyStyle();
                        row.BodyStyleID   = (int)reader["BodyStyleID"];
                        row.BodyStyleName = reader["BodyStyle"].ToString();

                        _bodies.Add(row);
                    }
                }
            }
            return(_bodies);
        }
        private static void AnalyzeIndexerDeclaration(SyntaxNodeAnalysisContext context)
        {
            var indexerDeclaration = (IndexerDeclarationSyntax)context.Node;

            ArrowExpressionClauseSyntax expressionBody = indexerDeclaration.ExpressionBody;

            if (expressionBody?.ContainsDirectives == false)
            {
                BodyStyle style = context.GetBodyStyle();

                if (style.IsDefault)
                    return;

                if (style.UseBlock)
                {
                    ReportDiagnostic(context, expressionBody);
                    return;
                }

                if (style.UseBlockWhenDeclarationIsMultiLine == true
                    && indexerDeclaration.SyntaxTree.IsMultiLineSpan(indexerDeclaration.HeaderSpan()))
                {
                    ReportDiagnostic(context, expressionBody);
                    return;
                }

                if (style.UseBlockWhenExpressionIsMultiLine == true
                    && expressionBody.Expression?.IsMultiLine() == true)
                {
                    ReportDiagnostic(context, expressionBody);
                }
            }
        }
Пример #9
0
 public Car(Color bodyColor, BodyStyle bodyType, TransmissionType transmissionKind, CarMaker carCompany, DateTime yearCreated)
 {
     color            = bodyColor;
     bodyStyle        = bodyType;
     transmissionType = transmissionKind;
     carMaker         = carCompany;
     yearMade         = yearCreated;
 }
Пример #10
0
 public Car(Color bodyColor, BodyStyle bodyType, TransmissionType transmissionKind, CarMaker carCompany, DateTime yearCreated)
 {
     color = bodyColor;
     bodyStyle = bodyType;
     transmissionType = transmissionKind;
     carMaker = carCompany;
     yearMade = yearCreated;
 }
Пример #11
0
        public void CanGetBodyStyleById()
        {
            BodyStyleRepositoryADO repo = new BodyStyleRepositoryADO();

            BodyStyle bodyStyle = repo.GetAll().FirstOrDefault(b => b.BodyStyleId == 3);

            Assert.AreEqual(bodyStyle.BodyStyleId, 3);
            Assert.AreEqual(bodyStyle.BodyStyleType, "SUV");
        }
Пример #12
0
 public void EditBodyStyle(BodyStyle bodyStyle)
 {
     using (var context = new ManufacturingDataContext(_connectionString))
     {
         var original = context.BodyStyles.Where(i => i.Id == bodyStyle.Id).FirstOrDefault();
         original.Name       = bodyStyle.Name.ToUpper();
         original.ModifiedOn = DateTime.Now;
         context.SubmitChanges();
     }
 }
Пример #13
0
 public Car()
 {
     //default boring car
     this.numOfCylinders = 4;
     this.hp = 136;
     this.bodyStyle = BodyStyle.SEDAN;
     this.brand = "Toyota";
     this.model = "Camry";
     this.year = 1999;
 }
Пример #14
0
 public Car()
 {
     //default boring car
     this.numOfCylinders = 4;
     this.hp             = 136;
     this.bodyStyle      = BodyStyle.SEDAN;
     this.brand          = "Toyota";
     this.model          = "Camry";
     this.year           = 1999;
 }
Пример #15
0
 public Car(int numOfCylinders, int hp, BodyStyle bodyStyle, string brand, string model, int year)
 {
     int currYear = Convert.ToInt32(DateTime.Now.Year.ToString());
     this.numOfCylinders = numOfCylinders;
     this.hp = hp;
     this.bodyStyle = bodyStyle;
     this.brand = brand;
     this.model = model;
     if (year > 1894 || year <= currYear)
     {
         this.year = year;
     }
 }
Пример #16
0
        public static List <Car> GetCarsByCategory(BodyStyle category)
        {
            List <Car> carsByCategory = new List <Car>();

            foreach (var car in CarYard.Instance.AllCars())
            {
                if (car.Bodystyle == category)
                {
                    carsByCategory.Add(car);
                }
            }

            return(carsByCategory);
        }
Пример #17
0
 public void Add(BodyStyle bodyStyle)
 {
     using (var sqlConnection = new System.Data.SqlClient.SqlConnection())
     {
         sqlConnection.ConnectionString = ConfigurationManager
                                          .ConnectionStrings["DefaultConnection"]
                                          .ConnectionString;
         DynamicParameters dynamicParameters = new DynamicParameters();
         dynamicParameters.Add("@BodyStyleId", dbType: DbType.Int32, direction: ParameterDirection.Output);
         dynamicParameters.Add("@BodyStyleName", bodyStyle.BodyStyleName);
         sqlConnection.Query <BodyStyle>("AddBodyStyle", dynamicParameters,
                                         commandType: CommandType.StoredProcedure);
     }
 }
Пример #18
0
        public Car(int numOfCylinders, int hp, BodyStyle bodyStyle, string brand, string model, int year)
        {
            int currYear = Convert.ToInt32(DateTime.Now.Year.ToString());

            this.numOfCylinders = numOfCylinders;
            this.hp             = hp;
            this.bodyStyle      = bodyStyle;
            this.brand          = brand;
            this.model          = model;
            if (year > 1894 || year <= currYear)
            {
                this.year = year;
            }
        }
Пример #19
0
        public BodyStyle GetBodyStyleById(int BodyStyleId)
        {
            BodyStyle BodyStyle = null;

            using (var dbConnection = new SqlConnection(Settings.GetConnectionString()))
            {
                try
                {
                    dbConnection.Open();

                    SqlCommand cmd = new SqlCommand("SelectBodyStyleById", dbConnection);
                    cmd.CommandType = CommandType.StoredProcedure;

                    cmd.Parameters.AddWithValue("@BodyStyleId", BodyStyleId);



                    using (SqlDataReader dr = cmd.ExecuteReader())
                    {
                        if (dr.Read())
                        {
                            BodyStyle               = new BodyStyle();
                            BodyStyle.BodyStyleId   = (int)dr["BodyStyleId"];
                            BodyStyle.BodyStyleType = dr["BodyStyleType"].ToString();
                        }
                    }

                    return(BodyStyle);
                }
                catch (Exception ex)
                {
                    string errorMessage = String.Format(CultureInfo.CurrentCulture,
                                                        "Exception Type: {0}, Message: {1}{2}",
                                                        ex.GetType(),
                                                        ex.Message,
                                                        ex.InnerException == null ? String.Empty :
                                                        String.Format(CultureInfo.CurrentCulture,
                                                                      " InnerException Type: {0}, Message: {1}",
                                                                      ex.InnerException.GetType(),
                                                                      ex.InnerException.Message));

                    System.Diagnostics.Debug.WriteLine(errorMessage);

                    dbConnection.Close();
                }

                return(BodyStyle);
            }
        }
Пример #20
0
 public Car()
 {
     m_Make        = string.Empty;
     m_Model       = string.Empty;
     m_Year        = int.MinValue;
     m_Fuel        = Fuel.unknown;
     m_Gear        = Gear.unknown;
     m_BodyStyle   = BodyStyle.unknown;
     m_Transmition = Transmition.unknown;
     m_Condition   = Condition.fine;
     m_kW          = int.MinValue;
     m_Price       = int.MinValue;
     m_Mileage     = int.MinValue;
     m_PhotoUrls   = new List <string>();
 }
Пример #21
0
        public Response AddBodyStyle(BodyStyle bodyStyle)
        {
            Response response = new Response();

            if (bodyStyleRepository.GetAll().Any(t => t.BodyStyleName == bodyStyle.BodyStyleName))
            {
                response.Success = false;
                response.Message = "ERROR: BodyStyle name already exists";
            }
            else
            {
                bodyStyleRepository.Add(bodyStyle);
                response.Success = true;
                response.Message = "BodyStyle added";
            }
            return(response);
        }
Пример #22
0
        public IEnumerable <BodyStyle> GetAll()
        {
            List <BodyStyle> BodyStyles = new List <BodyStyle>();

            using (var dbConnection = new SqlConnection(Settings.GetConnectionString()))
            {
                try
                {
                    SqlCommand cmd = new SqlCommand("SelectAllBodyStyles", dbConnection);
                    cmd.CommandType = CommandType.StoredProcedure;

                    dbConnection.Open();

                    using (SqlDataReader dr = cmd.ExecuteReader())
                    {
                        while (dr.Read())
                        {
                            BodyStyle bodyStyle = new BodyStyle();

                            bodyStyle.BodyStyleId   = (int)dr["BodyStyleId"];
                            bodyStyle.BodyStyleType = dr["BodyStyleType"].ToString();

                            BodyStyles.Add(bodyStyle);
                        }
                    }
                    return(BodyStyles);
                }
                catch (Exception ex)
                {
                    string errorMessage = String.Format(CultureInfo.CurrentCulture,
                                                        "Exception Type: {0}, Message: {1}{2}",
                                                        ex.GetType(),
                                                        ex.Message,
                                                        ex.InnerException == null ? String.Empty :
                                                        String.Format(CultureInfo.CurrentCulture,
                                                                      " InnerException Type: {0}, Message: {1}",
                                                                      ex.InnerException.GetType(),
                                                                      ex.InnerException.Message));

                    System.Diagnostics.Debug.WriteLine(errorMessage);

                    dbConnection.Close();
                }
                return(BodyStyles);
            }
        }
Пример #23
0
        public void InsertBodyStyle(BodyStyle bodyStyle)
        {
            using (var conn = new SqlConnection(Settings.GetConnectionString()))
            {
                SqlCommand cmd = new SqlCommand("BodyStylesInsert", conn);
                cmd.CommandType = System.Data.CommandType.StoredProcedure;
                SqlParameter param = new SqlParameter("@BodyStyleID", SqlDbType.Int);
                param.Direction = ParameterDirection.Output;
                cmd.Parameters.Add(param);
                cmd.Parameters.AddWithValue("@BodyStyleName", bodyStyle.BodyStyleName);

                conn.Open();

                cmd.ExecuteNonQuery();

                bodyStyle.BodyStyleID = (int)param.Value;
            }
        }
Пример #24
0
        private static void DemoValueTypeEnum()
        {
            WriteHeading("This is how enum values are used.");

            // Default value is the first item in the enum
            BodyStyle bodyStyle = default(BodyStyle);

            Console.WriteLine($"This is the default value {bodyStyle}");

            Console.WriteLine($"You can cast an enum to it's string representation '{BodyStyle.Van}' or the numerical representation '{(int)BodyStyle.Van}'");

            // You can set the value of an enum using a number as well
            BodyStyle unknownBodyStyle = (BodyStyle)100;

            Console.WriteLine($"Unknown body style is '{unknownBodyStyle}'");

            // So it is usually best to check if the enum is defined when passed a parameter to a public or protected method
            Console.WriteLine($"Is enum defined: {Enum.IsDefined(typeof(BodyStyle), unknownBodyStyle)}");

            AskIfThereAreQuestions();
        }
 /// <summary>
 /// This is a constructor we do NOT want to have
 /// </summary>
 public CarSearchCriteria(BodyStyle bodyStyle,
                          FuelType fuelType,
                          int?cylinderCount,
                          int?minMileage,
                          int?maxMileage,
                          int?minYear,
                          int?maxYear,
                          int?minPrice,
                          int?maxPrice,
                          bool?hasSunroof,
                          int?doorCount)
 {
     this.BodyStyle     = bodyStyle;
     this.FuelType      = fuelType;
     this.CylinderCount = cylinderCount;
     this.MinMileage    = minMileage;
     this.MaxMileage    = maxMileage;
     this.MinYear       = minYear;
     this.MaxYear       = maxYear;
     this.MinPrice      = minPrice;
     this.MaxPrice      = maxPrice;
     this.HasSunroof    = hasSunroof;
 }
Пример #26
0
        // car search
        /// <summary>
        /// <para>Performs the Search Method:
        /// Search Used Motors.
        /// Creates a query string based on the parameters provided, can be null if the parameter is not required for the request.
        /// </para>
        /// DOES NOT REQUIRE AUTHENTICATION.
        /// </summary>
        /// <param name="searchString">One or more keywords to use in a search query.</param>
        /// <param name="userRegion">Restricts search results to items from sellers located in the specified region.</param>
        /// <param name="sortOrder">Sort the returned record-set by a single specified sort order.</param>
        /// <param name="priceMin">Minimum price.</param>
        /// <param name="priceMax">Maximum price.</param>
        /// <param name="make">Car make.</param>
        /// <param name="model">Car model.</param>
        /// <param name="bodyStyle">Car body style.</param>
        /// <param name="doorsMin">Minimum number of doors (range from 2 to 5).</param>
        /// <param name="doorsMax">Maximum number of doors. </param>
        /// <param name="transmission">Transmission type.</param>
        /// <param name="yearMax">Maximum year of manufacture.</param>
        /// <param name="yearMin">Minimum year of manufacture.</param>
        /// <param name="energySizeMin">Minimum engine size in cubic centimetres (e.g. 2000 for 2 litre engine). </param>
        /// <param name="energySizeMax">Maximum engine size.</param>
        /// <param name="odometerMin">	Minimum odometer value in kilometres.</param>
        /// <param name="odometerMax">Maximum odometer value.</param>
        /// <param name="listingType">Type of listing.</param>
        /// <param name="dateFrom">Return only listings started from this date.</param>
        /// <param name="page">Page number.</param>
        /// <param name="rows">Number of rows per page.</param>
        /// <returns>Cars.</returns>
        public Cars SearchUsedMotors(
            string searchString,
            int? userRegion,
            SortOrder sortOrder,
            decimal priceMin,
            decimal priceMax,
            string make,
            string model,
            BodyStyle bodyStyle,
            int? doorsMin,
            int? doorsMax,
            Transmission transmission,
            int? yearMax,
            int? yearMin,
            int? energySizeMin,
            int? energySizeMax,
            int? odometerMin,
            int? odometerMax,
            ListingType listingType,
            DateTime dateFrom,
            int? page,
            int? rows)
        {
            var url = String.Format(Constants.Culture, "{0}/{1}/Used{2}", Constants.SEARCH, Constants.MOTORS, Constants.XML);
            _addAnd = false;
            var conditions = "?";

            // create the parameters for the query string
            conditions += SearchMethods.ConstructQueryHelper(Constants.SEARCH_STRING, searchString, _addAnd);
            conditions += SearchMethods.ConstructQueryHelper(Constants.USER_REGION, string.Empty + userRegion, _addAnd);
            conditions += SearchMethods.ConstructQueryHelper(Constants.PRICE_MIN, string.Empty + priceMin, _addAnd);
            conditions += SearchMethods.ConstructQueryHelper(Constants.SORT_ORDER, string.Empty + sortOrder, _addAnd);
            conditions += SearchMethods.ConstructQueryHelper(Constants.PRICE_MAX, string.Empty + priceMax, _addAnd);
            conditions += SearchMethods.ConstructQueryHelper(Constants.MAKE, make, _addAnd);
            conditions += SearchMethods.ConstructQueryHelper(Constants.MODEL, model, _addAnd);
            conditions += SearchMethods.ConstructQueryHelper(Constants.BODY_STYLE, bodyStyle.ToString(), _addAnd);
            conditions += SearchMethods.ConstructQueryHelper(Constants.DOORS_MIN, string.Empty + doorsMin, _addAnd);
            conditions += SearchMethods.ConstructQueryHelper(Constants.DOORS_MAX, string.Empty + doorsMax, _addAnd);
            conditions += SearchMethods.ConstructQueryHelper(Constants.TRANSMISSION, transmission.ToString(), _addAnd);
            conditions += SearchMethods.ConstructQueryHelper(Constants.YEAR_MIN, string.Empty + yearMin, _addAnd);
            conditions += SearchMethods.ConstructQueryHelper(Constants.YEAR_MAX, string.Empty + yearMax, _addAnd);
            conditions += SearchMethods.ConstructQueryHelper(Constants.ENERGY_SIZE_MAX, string.Empty + energySizeMax, _addAnd);
            conditions += SearchMethods.ConstructQueryHelper(Constants.ENERGY_SIZE_MIN, string.Empty + energySizeMin, _addAnd);
            conditions += SearchMethods.ConstructQueryHelper(Constants.ODOMETER_MIN, string.Empty + odometerMin, _addAnd);
            conditions += SearchMethods.ConstructQueryHelper(Constants.ODOMETER_MAX, string.Empty + odometerMax, _addAnd);
            conditions += SearchMethods.ConstructQueryHelper(Constants.LISTING_TYPE, listingType.ToString(), _addAnd);
            conditions += SearchMethods.ConstructQueryHelper(Constants.DATE_FROM, Client.DateToStringConverter(dateFrom), _addAnd);
            conditions += SearchMethods.ConstructQueryHelper(Constants.PAGE, string.Empty + page, _addAnd);
            conditions += SearchMethods.ConstructQueryHelper(Constants.ROWS, string.Empty + rows, _addAnd);

            // add the parameters to the query string if there are any
            if (conditions.Equals("?"))
            {
                url += conditions;
            }

            // perform the request
            return this.SearchUsedMotors(url);
        }
        private static void AnalyzeAccessorDeclarationBlock(
            SyntaxNodeAnalysisContext context,
            AccessorDeclarationSyntax accessor,
            BlockSyntax body)
        {
            if (body.ContainsDirectives)
                return;

            if (accessor.AttributeLists.Any())
                return;

            BodyStyle style = context.GetBodyStyle();

            if (style.IsDefault)
                return;

            bool isGetter = accessor.IsKind(SyntaxKind.GetAccessorDeclaration);

            BlockExpressionAnalysis analysis = BlockExpressionAnalysis.Create(body, allowExpressionStatement: !isGetter);

            ExpressionSyntax expression = analysis.Expression;

            if (expression == null)
                return;

            if (!style.UseExpression)
                return;

            if (style.UseBlockWhenExpressionIsMultiLine == true
                && expression.IsMultiLine())
            {
                return;
            }

            if (isGetter
                && accessor.Parent is AccessorListSyntax accessorList
                && accessorList.Accessors.Count == 1)
            {
                if (!SyntaxTriviaAnalysis.IsExteriorTriviaEmptyOrWhitespace(accessorList.OpenBraceToken))
                    return;

                if (!SyntaxTriviaAnalysis.IsExteriorTriviaEmptyOrWhitespace(accessor.Keyword))
                    return;

                if (!SyntaxTriviaAnalysis.IsExteriorTriviaEmptyOrWhitespace(body.OpenBraceToken))
                    return;

                if (style.UseBlockWhenDeclarationIsMultiLine == true)
                {
                    switch (accessorList.Parent.Kind())
                    {
                        case SyntaxKind.PropertyDeclaration:
                            {
                                if (accessor.SyntaxTree.IsMultiLineSpan(((PropertyDeclarationSyntax)accessorList.Parent).HeaderSpan()))
                                    return;

                                break;
                            }
                        case SyntaxKind.IndexerDeclaration:
                            {
                                if (accessor.SyntaxTree.IsMultiLineSpan(((IndexerDeclarationSyntax)accessorList.Parent).HeaderSpan()))
                                    return;

                                break;
                            }
                        default:
                            {
                                SyntaxDebug.Fail(accessorList.Parent);
                                break;
                            }
                    }

                    return;
                }

                ReportDiagnostic(context, accessorList);
                return;
            }

            if (!accessor.Keyword.TrailingTrivia.IsEmptyOrWhitespace())
                return;

            if (!SyntaxTriviaAnalysis.IsExteriorTriviaEmptyOrWhitespace(body.OpenBraceToken))
                return;

            if (!accessor.Keyword.LeadingTrivia.IsEmptyOrWhitespace())
                return;

            ReportDiagnostic(context, body);
        }
        private static void AnalyzeMethodDeclaration(SyntaxNodeAnalysisContext context)
        {
            var methodDeclaration = (MethodDeclarationSyntax)context.Node;

            BlockSyntax body = methodDeclaration.Body;
            if (body != null)
            {
                if (body.ContainsDirectives)
                    return;

                BodyStyle style = context.GetBodyStyle();

                if (style.IsDefault)
                    return;

                BlockExpressionAnalysis analysis = BlockExpressionAnalysis.Create(body);

                if (!analysis.Success)
                    return;

                if (!style.UseExpression)
                    return;

                if (style.UseBlockWhenDeclarationIsMultiLine == true
                    && methodDeclaration.SyntaxTree.IsMultiLineSpan(methodDeclaration.HeaderSpan()))
                {
                    return;
                }

                AnalyzeBlock(context, body, analysis, style);
            }
            else
            {
                ArrowExpressionClauseSyntax expressionBody = methodDeclaration.ExpressionBody;

                if (expressionBody?.ContainsDirectives == false)
                {
                    BodyStyle style = context.GetBodyStyle();

                    if (style.IsDefault)
                        return;

                    if (style.UseBlock)
                    {
                        ReportDiagnostic(context, expressionBody);
                        return;
                    }

                    if (style.UseBlockWhenDeclarationIsMultiLine == true
                        && methodDeclaration.SyntaxTree.IsMultiLineSpan(methodDeclaration.HeaderSpan()))
                    {
                        ReportDiagnostic(context, expressionBody);
                        return;
                    }

                    if (style.UseBlockWhenExpressionIsMultiLine == true
                        && expressionBody.Expression?.IsMultiLine() == true)
                    {
                        ReportDiagnostic(context, expressionBody);
                    }
                }
            }
        }
Пример #29
0
 public void setBodyStyle(BodyStyle bodyStyle)
 {
     this.bodyStyle = bodyStyle;
 }
Пример #30
0
 public void Add(BodyStyle bodyStyle)
 {
     bodyStyles.Add(bodyStyle);
 }
Пример #31
0
        public void Remove(int id)
        {
            BodyStyle style = bodyStyles.Where(b => b.BodyStyleId == id).FirstOrDefault();

            bodyStyles.Remove(style);
        }
Пример #32
0
        // car search
        /// <summary>
        /// <para>Performs the Search Method:
        /// Search Used Motors.
        /// Creates a query string based on the parameters provided, can be null if the parameter is not required for the request.
        /// </para>
        /// DOES NOT REQUIRE AUTHENTICATION.
        /// </summary>
        /// <param name="searchString">One or more keywords to use in a search query.</param>
        /// <param name="userRegion">Restricts search results to items from sellers located in the specified region.</param>
        /// <param name="sortOrder">Sort the returned record-set by a single specified sort order.</param>
        /// <param name="priceMin">Minimum price.</param>
        /// <param name="priceMax">Maximum price.</param>
        /// <param name="make">Car make.</param>
        /// <param name="model">Car model.</param>
        /// <param name="bodyStyle">Car body style.</param>
        /// <param name="doorsMin">Minimum number of doors (range from 2 to 5).</param>
        /// <param name="doorsMax">Maximum number of doors. </param>
        /// <param name="transmission">Transmission type.</param>
        /// <param name="yearMax">Maximum year of manufacture.</param>
        /// <param name="yearMin">Minimum year of manufacture.</param>
        /// <param name="energySizeMin">Minimum engine size in cubic centimetres (e.g. 2000 for 2 litre engine). </param>
        /// <param name="energySizeMax">Maximum engine size.</param>
        /// <param name="odometerMin">	Minimum odometer value in kilometres.</param>
        /// <param name="odometerMax">Maximum odometer value.</param>
        /// <param name="listingType">Type of listing.</param>
        /// <param name="dateFrom">Return only listings started from this date.</param>
        /// <param name="page">Page number.</param>
        /// <param name="rows">Number of rows per page.</param>
        /// <returns>Cars.</returns>
        public Cars SearchUsedMotors(
            string searchString,
            int? userRegion,
            SortOrder sortOrder,
            decimal priceMin,
            decimal priceMax,
            string make,
            string model,
            BodyStyle bodyStyle,
            int? doorsMin,
            int? doorsMax,
            Transmission transmission,
            int? yearMax,
            int? yearMin,
            int? energySizeMin,
            int? energySizeMax,
            int? odometerMin,
            int? odometerMax,
            ListingType listingType,
            DateTime dateFrom,
            int? page,
            int? rows)
        {
            if (_search == null)
            {
                _search = new SearchMethods(_connection);
            }

            return _search.SearchUsedMotors(searchString, userRegion, sortOrder, priceMin, priceMax, make, model, bodyStyle, doorsMin, doorsMax, transmission, yearMax, yearMin, energySizeMin, energySizeMax, odometerMin, odometerMax, listingType, dateFrom, page, rows);
        }
        private static void AnalyzeBlock(SyntaxNodeAnalysisContext context, BlockSyntax block, BlockExpressionAnalysis analysis, BodyStyle style)
        {
            if (style.UseBlockWhenExpressionIsMultiLine == true
                && analysis.Expression.IsMultiLine())
            {
                return;
            }

            if (!style.UseExpression)
                return;

            if (!SyntaxTriviaAnalysis.IsExteriorTriviaEmptyOrWhitespace(block.OpenBraceToken))
                return;

            if (!analysis.ReturnOrThrowKeyword.LeadingTrivia.IsEmptyOrWhitespace())
                return;

            ReportDiagnostic(context, analysis.Block);
        }
Пример #34
0
        public void UpdateBodyStyle(BodyStyle bodyStyle)
        {
            var repo = new ItemRepository(Properties.Settings.Default.ManufacturingConStr);

            repo.EditBodyStyle(bodyStyle);
        }
Пример #35
0
 public void InsertBodyStyle(BodyStyle bodyStyle)
 {
     throw new NotImplementedException();
 }
Пример #36
0
        // Constructor
        public Car(string engineNumber, DateTime wofDueAt, DateTime registrationDueDate, string colour, BodyStyle bodystyle, CarModel model, decimal price)
        {
            if (string.IsNullOrWhiteSpace(engineNumber))
            {
                throw new ArgumentException("Engine Number can't be blank.");
            }

            this.engineNumber        = engineNumber;
            this.WOFDueAt            = wofDueAt;
            this.RegistrationDueDate = registrationDueDate;
            if (string.IsNullOrWhiteSpace(colour))
            {
                throw new ArgumentException("Car colour can't be blank.");
            }

            this.Colour    = colour;
            this.Bodystyle = bodystyle;
            this.Model     = model;
            this.Price     = price;
        }