Click here to Skip to main content
15,881,757 members
Articles / Programming Languages / C#

Integrate Validation Block with WCF

Rate me:
Please Sign up or sign in to vote.
5.00/5 (3 votes)
23 Sep 2011CPOL4 min read 42.3K   1.1K   25  
Introduces how to integrate and use the validation block features in Microsoft Enterprise Library 5.0 with WCF.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;

namespace SalaryCalculator
{
    public class SalaryService : ISalaryService
    {
        private string Calculate(int EducationLevel, int ExperienceInYears, string Currency, bool HasCertificate, bool InvolvedInManagement)
        {
            // Make our calculations with the input given by the clients
            int estimatedSalary = EducationLevel * 100 + ExperienceInYears * 10 + (HasCertificate ? 50 : 0) + (InvolvedInManagement ? 100 : 0);

            return String.Format("Your estimated salary is {1}{0}", Currency, estimatedSalary);
        }

        public string CalculatePartial(int EducationLevel, int ExperienceInYears, string Currency, bool HasCertificate, bool InvolvedInManagement)
        {
            return Calculate(EducationLevel,
                        ExperienceInYears,
                        Currency,
                        HasCertificate,
                        InvolvedInManagement);
        }

        public string CalculateFull(string EducationLevel, string ExperienceInYears, string Currency, string HasCertificate, string InvolvedInManagement)
        {
            return Calculate(Convert.ToInt32(EducationLevel),
                        Convert.ToInt32(ExperienceInYears),
                        Currency,
                        Convert.ToBoolean(HasCertificate),
                        Convert.ToBoolean(InvolvedInManagement));
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer
Turkey Turkey
I am interested in innovation and creativity in software development and passionate in learning new stuff.

Comments and Discussions