Click here to Skip to main content
15,892,298 members
Articles / Desktop Programming / WPF

A Silverlight Introduction for Line-of-Business Applications

Rate me:
Please Sign up or sign in to vote.
4.71/5 (15 votes)
30 Aug 2009CPOL18 min read 54.3K   660   56  
An introduction on Silverlight for developers of administrative applications. The article starts by explaining the basics of WPF and then delves deeper in the business-oriented aspects.
//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:2.0.50727.3074
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

// 
// This code was auto-generated by Microsoft.Silverlight.ServiceReference, version 2.0.5.0
// 
namespace CarSelector.CarService {
    using System.Runtime.Serialization;
    
    
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "3.0.0.0")]
    [System.Runtime.Serialization.DataContractAttribute(Name="SimpleCar", Namespace="http://schemas.datacontract.org/2004/07/CarSelector.Web")]
    public partial class SimpleCar : object, System.ComponentModel.INotifyPropertyChanged {
        
        private int IDField;
        
        private string MakeField;
        
        private string ModelField;
        
        private string TypeField;
        
        [System.Runtime.Serialization.DataMemberAttribute()]
        public int ID {
            get {
                return this.IDField;
            }
            set {
                if ((this.IDField.Equals(value) != true)) {
                    this.IDField = value;
                    this.RaisePropertyChanged("ID");
                }
            }
        }
        
        [System.Runtime.Serialization.DataMemberAttribute()]
        public string Make {
            get {
                return this.MakeField;
            }
            set {
                if ((object.ReferenceEquals(this.MakeField, value) != true)) {
                    this.MakeField = value;
                    this.RaisePropertyChanged("Make");
                }
            }
        }
        
        [System.Runtime.Serialization.DataMemberAttribute()]
        public string Model {
            get {
                return this.ModelField;
            }
            set {
                if ((object.ReferenceEquals(this.ModelField, value) != true)) {
                    this.ModelField = value;
                    this.RaisePropertyChanged("Model");
                }
            }
        }
        
        [System.Runtime.Serialization.DataMemberAttribute()]
        public string Type {
            get {
                return this.TypeField;
            }
            set {
                if ((object.ReferenceEquals(this.TypeField, value) != true)) {
                    this.TypeField = value;
                    this.RaisePropertyChanged("Type");
                }
            }
        }
        
        public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;
        
        protected void RaisePropertyChanged(string propertyName) {
            System.ComponentModel.PropertyChangedEventHandler propertyChanged = this.PropertyChanged;
            if ((propertyChanged != null)) {
                propertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName));
            }
        }
    }
    
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "3.0.0.0")]
    [System.Runtime.Serialization.DataContractAttribute(Name="Car", Namespace="http://schemas.datacontract.org/2004/07/CarSelector.Web")]
    public partial class Car : object, System.ComponentModel.INotifyPropertyChanged {
        
        private string CO2Field;
        
        private int DoorsField;
        
        private int GearsField;
        
        private int IdField;
        
        private string MakeField;
        
        private string ModelField;
        
        private byte[] PictureField;
        
        private decimal PriceField;
        
        private string TypeField;
        
        private CarSelector.CarService.Binary VersionField;
        
        private int WeightField;
        
        [System.Runtime.Serialization.DataMemberAttribute()]
        public string CO2 {
            get {
                return this.CO2Field;
            }
            set {
                if ((object.ReferenceEquals(this.CO2Field, value) != true)) {
                    this.CO2Field = value;
                    this.RaisePropertyChanged("CO2");
                }
            }
        }
        
        [System.Runtime.Serialization.DataMemberAttribute()]
        public int Doors {
            get {
                return this.DoorsField;
            }
            set {
                if ((this.DoorsField.Equals(value) != true)) {
                    this.DoorsField = value;
                    this.RaisePropertyChanged("Doors");
                }
            }
        }
        
        [System.Runtime.Serialization.DataMemberAttribute()]
        public int Gears {
            get {
                return this.GearsField;
            }
            set {
                if ((this.GearsField.Equals(value) != true)) {
                    this.GearsField = value;
                    this.RaisePropertyChanged("Gears");
                }
            }
        }
        
        [System.Runtime.Serialization.DataMemberAttribute()]
        public int Id {
            get {
                return this.IdField;
            }
            set {
                if ((this.IdField.Equals(value) != true)) {
                    this.IdField = value;
                    this.RaisePropertyChanged("Id");
                }
            }
        }
        
        [System.Runtime.Serialization.DataMemberAttribute()]
        public string Make {
            get {
                return this.MakeField;
            }
            set {
                if ((object.ReferenceEquals(this.MakeField, value) != true)) {
                    this.MakeField = value;
                    this.RaisePropertyChanged("Make");
                }
            }
        }
        
        [System.Runtime.Serialization.DataMemberAttribute()]
        public string Model {
            get {
                return this.ModelField;
            }
            set {
                if ((object.ReferenceEquals(this.ModelField, value) != true)) {
                    this.ModelField = value;
                    this.RaisePropertyChanged("Model");
                }
            }
        }
        
        [System.Runtime.Serialization.DataMemberAttribute()]
        public byte[] Picture {
            get {
                return this.PictureField;
            }
            set {
                if ((object.ReferenceEquals(this.PictureField, value) != true)) {
                    this.PictureField = value;
                    this.RaisePropertyChanged("Picture");
                }
            }
        }
        
        [System.Runtime.Serialization.DataMemberAttribute()]
        public decimal Price {
            get {
                return this.PriceField;
            }
            set {
                if ((this.PriceField.Equals(value) != true)) {
                    this.PriceField = value;
                    this.RaisePropertyChanged("Price");
                }
            }
        }
        
        [System.Runtime.Serialization.DataMemberAttribute()]
        public string Type {
            get {
                return this.TypeField;
            }
            set {
                if ((object.ReferenceEquals(this.TypeField, value) != true)) {
                    this.TypeField = value;
                    this.RaisePropertyChanged("Type");
                }
            }
        }
        
        [System.Runtime.Serialization.DataMemberAttribute()]
        public CarSelector.CarService.Binary Version {
            get {
                return this.VersionField;
            }
            set {
                if ((object.ReferenceEquals(this.VersionField, value) != true)) {
                    this.VersionField = value;
                    this.RaisePropertyChanged("Version");
                }
            }
        }
        
        [System.Runtime.Serialization.DataMemberAttribute()]
        public int Weight {
            get {
                return this.WeightField;
            }
            set {
                if ((this.WeightField.Equals(value) != true)) {
                    this.WeightField = value;
                    this.RaisePropertyChanged("Weight");
                }
            }
        }
        
        public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;
        
        protected void RaisePropertyChanged(string propertyName) {
            System.ComponentModel.PropertyChangedEventHandler propertyChanged = this.PropertyChanged;
            if ((propertyChanged != null)) {
                propertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName));
            }
        }
    }
    
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "3.0.0.0")]
    [System.Runtime.Serialization.DataContractAttribute(Name="Binary", Namespace="http://schemas.datacontract.org/2004/07/System.Data.Linq")]
    public partial class Binary : object, System.ComponentModel.INotifyPropertyChanged {
        
        private byte[] BytesField;
        
        [System.Runtime.Serialization.DataMemberAttribute()]
        public byte[] Bytes {
            get {
                return this.BytesField;
            }
            set {
                if ((object.ReferenceEquals(this.BytesField, value) != true)) {
                    this.BytesField = value;
                    this.RaisePropertyChanged("Bytes");
                }
            }
        }
        
        public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;
        
        protected void RaisePropertyChanged(string propertyName) {
            System.ComponentModel.PropertyChangedEventHandler propertyChanged = this.PropertyChanged;
            if ((propertyChanged != null)) {
                propertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName));
            }
        }
    }
    
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")]
    [System.ServiceModel.ServiceContractAttribute(ConfigurationName="CarService.ICarService")]
    public interface ICarService {
        
        [System.ServiceModel.OperationContractAttribute(AsyncPattern=true, Action="http://tempuri.org/ICarService/GetCarsOverview", ReplyAction="http://tempuri.org/ICarService/GetCarsOverviewResponse")]
        System.IAsyncResult BeginGetCarsOverview(System.AsyncCallback callback, object asyncState);
        
        System.Collections.ObjectModel.ObservableCollection<CarSelector.CarService.SimpleCar> EndGetCarsOverview(System.IAsyncResult result);
        
        [System.ServiceModel.OperationContractAttribute(AsyncPattern=true, Action="http://tempuri.org/ICarService/GetCar", ReplyAction="http://tempuri.org/ICarService/GetCarResponse")]
        System.IAsyncResult BeginGetCar(int carId, System.AsyncCallback callback, object asyncState);
        
        CarSelector.CarService.Car EndGetCar(System.IAsyncResult result);
        
        [System.ServiceModel.OperationContractAttribute(AsyncPattern=true, Action="http://tempuri.org/ICarService/UpdateCar", ReplyAction="http://tempuri.org/ICarService/UpdateCarResponse")]
        System.IAsyncResult BeginUpdateCar(CarSelector.CarService.Car car, System.AsyncCallback callback, object asyncState);
        
        bool EndUpdateCar(System.IAsyncResult result);
    }
    
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")]
    public interface ICarServiceChannel : CarSelector.CarService.ICarService, System.ServiceModel.IClientChannel {
    }
    
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")]
    public partial class GetCarsOverviewCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs {
        
        private object[] results;
        
        public GetCarsOverviewCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) : 
                base(exception, cancelled, userState) {
            this.results = results;
        }
        
        public System.Collections.ObjectModel.ObservableCollection<CarSelector.CarService.SimpleCar> Result {
            get {
                base.RaiseExceptionIfNecessary();
                return ((System.Collections.ObjectModel.ObservableCollection<CarSelector.CarService.SimpleCar>)(this.results[0]));
            }
        }
    }
    
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")]
    public partial class GetCarCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs {
        
        private object[] results;
        
        public GetCarCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) : 
                base(exception, cancelled, userState) {
            this.results = results;
        }
        
        public CarSelector.CarService.Car Result {
            get {
                base.RaiseExceptionIfNecessary();
                return ((CarSelector.CarService.Car)(this.results[0]));
            }
        }
    }
    
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")]
    public partial class UpdateCarCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs {
        
        private object[] results;
        
        public UpdateCarCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) : 
                base(exception, cancelled, userState) {
            this.results = results;
        }
        
        public bool Result {
            get {
                base.RaiseExceptionIfNecessary();
                return ((bool)(this.results[0]));
            }
        }
    }
    
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")]
    public partial class CarServiceClient : System.ServiceModel.ClientBase<CarSelector.CarService.ICarService>, CarSelector.CarService.ICarService {
        
        private BeginOperationDelegate onBeginGetCarsOverviewDelegate;
        
        private EndOperationDelegate onEndGetCarsOverviewDelegate;
        
        private System.Threading.SendOrPostCallback onGetCarsOverviewCompletedDelegate;
        
        private BeginOperationDelegate onBeginGetCarDelegate;
        
        private EndOperationDelegate onEndGetCarDelegate;
        
        private System.Threading.SendOrPostCallback onGetCarCompletedDelegate;
        
        private BeginOperationDelegate onBeginUpdateCarDelegate;
        
        private EndOperationDelegate onEndUpdateCarDelegate;
        
        private System.Threading.SendOrPostCallback onUpdateCarCompletedDelegate;
        
        private BeginOperationDelegate onBeginOpenDelegate;
        
        private EndOperationDelegate onEndOpenDelegate;
        
        private System.Threading.SendOrPostCallback onOpenCompletedDelegate;
        
        private BeginOperationDelegate onBeginCloseDelegate;
        
        private EndOperationDelegate onEndCloseDelegate;
        
        private System.Threading.SendOrPostCallback onCloseCompletedDelegate;
        
        public CarServiceClient() {
        }
        
        public CarServiceClient(string endpointConfigurationName) : 
                base(endpointConfigurationName) {
        }
        
        public CarServiceClient(string endpointConfigurationName, string remoteAddress) : 
                base(endpointConfigurationName, remoteAddress) {
        }
        
        public CarServiceClient(string endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress) : 
                base(endpointConfigurationName, remoteAddress) {
        }
        
        public CarServiceClient(System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) : 
                base(binding, remoteAddress) {
        }
        
        public event System.EventHandler<GetCarsOverviewCompletedEventArgs> GetCarsOverviewCompleted;
        
        public event System.EventHandler<GetCarCompletedEventArgs> GetCarCompleted;
        
        public event System.EventHandler<UpdateCarCompletedEventArgs> UpdateCarCompleted;
        
        public event System.EventHandler<System.ComponentModel.AsyncCompletedEventArgs> OpenCompleted;
        
        public event System.EventHandler<System.ComponentModel.AsyncCompletedEventArgs> CloseCompleted;
        
        [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
        System.IAsyncResult CarSelector.CarService.ICarService.BeginGetCarsOverview(System.AsyncCallback callback, object asyncState) {
            return base.Channel.BeginGetCarsOverview(callback, asyncState);
        }
        
        [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
        System.Collections.ObjectModel.ObservableCollection<CarSelector.CarService.SimpleCar> CarSelector.CarService.ICarService.EndGetCarsOverview(System.IAsyncResult result) {
            return base.Channel.EndGetCarsOverview(result);
        }
        
        private System.IAsyncResult OnBeginGetCarsOverview(object[] inValues, System.AsyncCallback callback, object asyncState) {
            return ((CarSelector.CarService.ICarService)(this)).BeginGetCarsOverview(callback, asyncState);
        }
        
        private object[] OnEndGetCarsOverview(System.IAsyncResult result) {
            System.Collections.ObjectModel.ObservableCollection<CarSelector.CarService.SimpleCar> retVal = ((CarSelector.CarService.ICarService)(this)).EndGetCarsOverview(result);
            return new object[] {
                    retVal};
        }
        
        private void OnGetCarsOverviewCompleted(object state) {
            if ((this.GetCarsOverviewCompleted != null)) {
                InvokeAsyncCompletedEventArgs e = ((InvokeAsyncCompletedEventArgs)(state));
                this.GetCarsOverviewCompleted(this, new GetCarsOverviewCompletedEventArgs(e.Results, e.Error, e.Cancelled, e.UserState));
            }
        }
        
        public void GetCarsOverviewAsync() {
            this.GetCarsOverviewAsync(null);
        }
        
        public void GetCarsOverviewAsync(object userState) {
            if ((this.onBeginGetCarsOverviewDelegate == null)) {
                this.onBeginGetCarsOverviewDelegate = new BeginOperationDelegate(this.OnBeginGetCarsOverview);
            }
            if ((this.onEndGetCarsOverviewDelegate == null)) {
                this.onEndGetCarsOverviewDelegate = new EndOperationDelegate(this.OnEndGetCarsOverview);
            }
            if ((this.onGetCarsOverviewCompletedDelegate == null)) {
                this.onGetCarsOverviewCompletedDelegate = new System.Threading.SendOrPostCallback(this.OnGetCarsOverviewCompleted);
            }
            base.InvokeAsync(this.onBeginGetCarsOverviewDelegate, null, this.onEndGetCarsOverviewDelegate, this.onGetCarsOverviewCompletedDelegate, userState);
        }
        
        [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
        System.IAsyncResult CarSelector.CarService.ICarService.BeginGetCar(int carId, System.AsyncCallback callback, object asyncState) {
            return base.Channel.BeginGetCar(carId, callback, asyncState);
        }
        
        [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
        CarSelector.CarService.Car CarSelector.CarService.ICarService.EndGetCar(System.IAsyncResult result) {
            return base.Channel.EndGetCar(result);
        }
        
        private System.IAsyncResult OnBeginGetCar(object[] inValues, System.AsyncCallback callback, object asyncState) {
            int carId = ((int)(inValues[0]));
            return ((CarSelector.CarService.ICarService)(this)).BeginGetCar(carId, callback, asyncState);
        }
        
        private object[] OnEndGetCar(System.IAsyncResult result) {
            CarSelector.CarService.Car retVal = ((CarSelector.CarService.ICarService)(this)).EndGetCar(result);
            return new object[] {
                    retVal};
        }
        
        private void OnGetCarCompleted(object state) {
            if ((this.GetCarCompleted != null)) {
                InvokeAsyncCompletedEventArgs e = ((InvokeAsyncCompletedEventArgs)(state));
                this.GetCarCompleted(this, new GetCarCompletedEventArgs(e.Results, e.Error, e.Cancelled, e.UserState));
            }
        }
        
        public void GetCarAsync(int carId) {
            this.GetCarAsync(carId, null);
        }
        
        public void GetCarAsync(int carId, object userState) {
            if ((this.onBeginGetCarDelegate == null)) {
                this.onBeginGetCarDelegate = new BeginOperationDelegate(this.OnBeginGetCar);
            }
            if ((this.onEndGetCarDelegate == null)) {
                this.onEndGetCarDelegate = new EndOperationDelegate(this.OnEndGetCar);
            }
            if ((this.onGetCarCompletedDelegate == null)) {
                this.onGetCarCompletedDelegate = new System.Threading.SendOrPostCallback(this.OnGetCarCompleted);
            }
            base.InvokeAsync(this.onBeginGetCarDelegate, new object[] {
                        carId}, this.onEndGetCarDelegate, this.onGetCarCompletedDelegate, userState);
        }
        
        [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
        System.IAsyncResult CarSelector.CarService.ICarService.BeginUpdateCar(CarSelector.CarService.Car car, System.AsyncCallback callback, object asyncState) {
            return base.Channel.BeginUpdateCar(car, callback, asyncState);
        }
        
        [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
        bool CarSelector.CarService.ICarService.EndUpdateCar(System.IAsyncResult result) {
            return base.Channel.EndUpdateCar(result);
        }
        
        private System.IAsyncResult OnBeginUpdateCar(object[] inValues, System.AsyncCallback callback, object asyncState) {
            CarSelector.CarService.Car car = ((CarSelector.CarService.Car)(inValues[0]));
            return ((CarSelector.CarService.ICarService)(this)).BeginUpdateCar(car, callback, asyncState);
        }
        
        private object[] OnEndUpdateCar(System.IAsyncResult result) {
            bool retVal = ((CarSelector.CarService.ICarService)(this)).EndUpdateCar(result);
            return new object[] {
                    retVal};
        }
        
        private void OnUpdateCarCompleted(object state) {
            if ((this.UpdateCarCompleted != null)) {
                InvokeAsyncCompletedEventArgs e = ((InvokeAsyncCompletedEventArgs)(state));
                this.UpdateCarCompleted(this, new UpdateCarCompletedEventArgs(e.Results, e.Error, e.Cancelled, e.UserState));
            }
        }
        
        public void UpdateCarAsync(CarSelector.CarService.Car car) {
            this.UpdateCarAsync(car, null);
        }
        
        public void UpdateCarAsync(CarSelector.CarService.Car car, object userState) {
            if ((this.onBeginUpdateCarDelegate == null)) {
                this.onBeginUpdateCarDelegate = new BeginOperationDelegate(this.OnBeginUpdateCar);
            }
            if ((this.onEndUpdateCarDelegate == null)) {
                this.onEndUpdateCarDelegate = new EndOperationDelegate(this.OnEndUpdateCar);
            }
            if ((this.onUpdateCarCompletedDelegate == null)) {
                this.onUpdateCarCompletedDelegate = new System.Threading.SendOrPostCallback(this.OnUpdateCarCompleted);
            }
            base.InvokeAsync(this.onBeginUpdateCarDelegate, new object[] {
                        car}, this.onEndUpdateCarDelegate, this.onUpdateCarCompletedDelegate, userState);
        }
        
        private System.IAsyncResult OnBeginOpen(object[] inValues, System.AsyncCallback callback, object asyncState) {
            return ((System.ServiceModel.ICommunicationObject)(this)).BeginOpen(callback, asyncState);
        }
        
        private object[] OnEndOpen(System.IAsyncResult result) {
            ((System.ServiceModel.ICommunicationObject)(this)).EndOpen(result);
            return null;
        }
        
        private void OnOpenCompleted(object state) {
            if ((this.OpenCompleted != null)) {
                InvokeAsyncCompletedEventArgs e = ((InvokeAsyncCompletedEventArgs)(state));
                this.OpenCompleted(this, new System.ComponentModel.AsyncCompletedEventArgs(e.Error, e.Cancelled, e.UserState));
            }
        }
        
        public void OpenAsync() {
            this.OpenAsync(null);
        }
        
        public void OpenAsync(object userState) {
            if ((this.onBeginOpenDelegate == null)) {
                this.onBeginOpenDelegate = new BeginOperationDelegate(this.OnBeginOpen);
            }
            if ((this.onEndOpenDelegate == null)) {
                this.onEndOpenDelegate = new EndOperationDelegate(this.OnEndOpen);
            }
            if ((this.onOpenCompletedDelegate == null)) {
                this.onOpenCompletedDelegate = new System.Threading.SendOrPostCallback(this.OnOpenCompleted);
            }
            base.InvokeAsync(this.onBeginOpenDelegate, null, this.onEndOpenDelegate, this.onOpenCompletedDelegate, userState);
        }
        
        private System.IAsyncResult OnBeginClose(object[] inValues, System.AsyncCallback callback, object asyncState) {
            return ((System.ServiceModel.ICommunicationObject)(this)).BeginClose(callback, asyncState);
        }
        
        private object[] OnEndClose(System.IAsyncResult result) {
            ((System.ServiceModel.ICommunicationObject)(this)).EndClose(result);
            return null;
        }
        
        private void OnCloseCompleted(object state) {
            if ((this.CloseCompleted != null)) {
                InvokeAsyncCompletedEventArgs e = ((InvokeAsyncCompletedEventArgs)(state));
                this.CloseCompleted(this, new System.ComponentModel.AsyncCompletedEventArgs(e.Error, e.Cancelled, e.UserState));
            }
        }
        
        public void CloseAsync() {
            this.CloseAsync(null);
        }
        
        public void CloseAsync(object userState) {
            if ((this.onBeginCloseDelegate == null)) {
                this.onBeginCloseDelegate = new BeginOperationDelegate(this.OnBeginClose);
            }
            if ((this.onEndCloseDelegate == null)) {
                this.onEndCloseDelegate = new EndOperationDelegate(this.OnEndClose);
            }
            if ((this.onCloseCompletedDelegate == null)) {
                this.onCloseCompletedDelegate = new System.Threading.SendOrPostCallback(this.OnCloseCompleted);
            }
            base.InvokeAsync(this.onBeginCloseDelegate, null, this.onEndCloseDelegate, this.onCloseCompletedDelegate, userState);
        }
        
        protected override CarSelector.CarService.ICarService CreateChannel() {
            return new CarServiceClientChannel(this);
        }
        
        private class CarServiceClientChannel : ChannelBase<CarSelector.CarService.ICarService>, CarSelector.CarService.ICarService {
            
            public CarServiceClientChannel(System.ServiceModel.ClientBase<CarSelector.CarService.ICarService> client) : 
                    base(client) {
            }
            
            public System.IAsyncResult BeginGetCarsOverview(System.AsyncCallback callback, object asyncState) {
                object[] _args = new object[0];
                System.IAsyncResult _result = base.BeginInvoke("GetCarsOverview", _args, callback, asyncState);
                return _result;
            }
            
            public System.Collections.ObjectModel.ObservableCollection<CarSelector.CarService.SimpleCar> EndGetCarsOverview(System.IAsyncResult result) {
                object[] _args = new object[0];
                System.Collections.ObjectModel.ObservableCollection<CarSelector.CarService.SimpleCar> _result = ((System.Collections.ObjectModel.ObservableCollection<CarSelector.CarService.SimpleCar>)(base.EndInvoke("GetCarsOverview", _args, result)));
                return _result;
            }
            
            public System.IAsyncResult BeginGetCar(int carId, System.AsyncCallback callback, object asyncState) {
                object[] _args = new object[1];
                _args[0] = carId;
                System.IAsyncResult _result = base.BeginInvoke("GetCar", _args, callback, asyncState);
                return _result;
            }
            
            public CarSelector.CarService.Car EndGetCar(System.IAsyncResult result) {
                object[] _args = new object[0];
                CarSelector.CarService.Car _result = ((CarSelector.CarService.Car)(base.EndInvoke("GetCar", _args, result)));
                return _result;
            }
            
            public System.IAsyncResult BeginUpdateCar(CarSelector.CarService.Car car, System.AsyncCallback callback, object asyncState) {
                object[] _args = new object[1];
                _args[0] = car;
                System.IAsyncResult _result = base.BeginInvoke("UpdateCar", _args, callback, asyncState);
                return _result;
            }
            
            public bool EndUpdateCar(System.IAsyncResult result) {
                object[] _args = new object[0];
                bool _result = ((bool)(base.EndInvoke("UpdateCar", _args, result)));
                return _result;
            }
        }
    }
}

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
CEO TRI-S bvba, Cogenius bvba
Belgium Belgium
I'm working since 1999 in an IT environment: started developing in PROGRESS 4GL, then VB6 and am working since 2003 with C#. I'm currently transitioning to HTML5, CSS3 and JavaScript for the front-end development.
I started my own company (TRI-S) in 2007 and co-founded another one (Cogenius) in 2012.
Besides being a Microsoft Certified Professional Developer (MCPD) I'm also a Microsoft Certified Trainer (MCT) and am teaching .NET and JavaScript courses.

Comments and Discussions