//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:4.0.30319.225
//
//     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 4.0.50826.0
// 
namespace VideoDistanc.ChangeServiceReference {
    
    
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
    [System.ServiceModel.ServiceContractAttribute(Namespace="", ConfigurationName="ChangeServiceReference.ChangeService", CallbackContract=typeof(VideoDistanc.ChangeServiceReference.ChangeServiceCallback))]
    public interface ChangeService {
        
        [System.ServiceModel.OperationContractAttribute(AsyncPattern=true, Action="urn:ChangeService/Suscribe", ReplyAction="urn:ChangeService/SuscribeResponse")]
        System.IAsyncResult BeginSuscribe(string instance, System.AsyncCallback callback, object asyncState);
        
        void EndSuscribe(System.IAsyncResult result);
        
        [System.ServiceModel.OperationContractAttribute(AsyncPattern=true, Action="urn:ChangeService/Publish", ReplyAction="urn:ChangeService/PublishResponse")]
        System.IAsyncResult BeginPublish(string message, System.AsyncCallback callback, object asyncState);
        
        void EndPublish(System.IAsyncResult result);
    }
    
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
    public interface ChangeServiceCallback {
        
        [System.ServiceModel.OperationContractAttribute(IsOneWay=true, Action="urn:ChangeService/Notify")]
        void Notify(string message);
    }
    
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
    public interface ChangeServiceChannel : VideoDistanc.ChangeServiceReference.ChangeService, System.ServiceModel.IClientChannel {
    }
    
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
    public partial class ChangeServiceClient : System.ServiceModel.DuplexClientBase<VideoDistanc.ChangeServiceReference.ChangeService>, VideoDistanc.ChangeServiceReference.ChangeService {
        
        private BeginOperationDelegate onBeginSuscribeDelegate;
        
        private EndOperationDelegate onEndSuscribeDelegate;
        
        private System.Threading.SendOrPostCallback onSuscribeCompletedDelegate;
        
        private BeginOperationDelegate onBeginPublishDelegate;
        
        private EndOperationDelegate onEndPublishDelegate;
        
        private System.Threading.SendOrPostCallback onPublishCompletedDelegate;
        
        private bool useGeneratedCallback;
        
        private BeginOperationDelegate onBeginOpenDelegate;
        
        private EndOperationDelegate onEndOpenDelegate;
        
        private System.Threading.SendOrPostCallback onOpenCompletedDelegate;
        
        private BeginOperationDelegate onBeginCloseDelegate;
        
        private EndOperationDelegate onEndCloseDelegate;
        
        private System.Threading.SendOrPostCallback onCloseCompletedDelegate;
        
        public ChangeServiceClient(System.ServiceModel.InstanceContext callbackInstance) : 
                base(callbackInstance) {
        }
        
        public ChangeServiceClient(System.ServiceModel.InstanceContext callbackInstance, string endpointConfigurationName) : 
                base(callbackInstance, endpointConfigurationName) {
        }
        
        public ChangeServiceClient(System.ServiceModel.InstanceContext callbackInstance, string endpointConfigurationName, string remoteAddress) : 
                base(callbackInstance, endpointConfigurationName, remoteAddress) {
        }
        
        public ChangeServiceClient(System.ServiceModel.InstanceContext callbackInstance, string endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress) : 
                base(callbackInstance, endpointConfigurationName, remoteAddress) {
        }
        
        public ChangeServiceClient(System.ServiceModel.InstanceContext callbackInstance, System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) : 
                base(callbackInstance, binding, remoteAddress) {
        }
        
        public ChangeServiceClient(string endpointConfigurationName) : 
                this(new ChangeServiceClientCallback(), endpointConfigurationName) {
        }
        
        private ChangeServiceClient(ChangeServiceClientCallback callbackImpl, string endpointConfigurationName) : 
                this(new System.ServiceModel.InstanceContext(callbackImpl), endpointConfigurationName) {
            useGeneratedCallback = true;
            callbackImpl.Initialize(this);
        }
        
        public ChangeServiceClient(System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) : 
                this(new ChangeServiceClientCallback(), binding, remoteAddress) {
        }
        
        private ChangeServiceClient(ChangeServiceClientCallback callbackImpl, System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) : 
                this(new System.ServiceModel.InstanceContext(callbackImpl), binding, remoteAddress) {
            useGeneratedCallback = true;
            callbackImpl.Initialize(this);
        }
        
        public ChangeServiceClient() : 
                this(new ChangeServiceClientCallback()) {
        }
        
        private ChangeServiceClient(ChangeServiceClientCallback callbackImpl) : 
                this(new System.ServiceModel.InstanceContext(callbackImpl)) {
            useGeneratedCallback = true;
            callbackImpl.Initialize(this);
        }
        
        public System.Net.CookieContainer CookieContainer {
            get {
                System.ServiceModel.Channels.IHttpCookieContainerManager httpCookieContainerManager = this.InnerChannel.GetProperty<System.ServiceModel.Channels.IHttpCookieContainerManager>();
                if ((httpCookieContainerManager != null)) {
                    return httpCookieContainerManager.CookieContainer;
                }
                else {
                    return null;
                }
            }
            set {
                System.ServiceModel.Channels.IHttpCookieContainerManager httpCookieContainerManager = this.InnerChannel.GetProperty<System.ServiceModel.Channels.IHttpCookieContainerManager>();
                if ((httpCookieContainerManager != null)) {
                    httpCookieContainerManager.CookieContainer = value;
                }
                else {
                    throw new System.InvalidOperationException("Unable to set the CookieContainer. Please make sure the binding contains an HttpC" +
                            "ookieContainerBindingElement.");
                }
            }
        }
        
        public event System.EventHandler<System.ComponentModel.AsyncCompletedEventArgs> SuscribeCompleted;
        
        public event System.EventHandler<System.ComponentModel.AsyncCompletedEventArgs> PublishCompleted;
        
        public event System.EventHandler<NotifyReceivedEventArgs> NotifyReceived;
        
        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 VideoDistanc.ChangeServiceReference.ChangeService.BeginSuscribe(string instance, System.AsyncCallback callback, object asyncState) {
            return base.Channel.BeginSuscribe(instance, callback, asyncState);
        }
        
        [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
        void VideoDistanc.ChangeServiceReference.ChangeService.EndSuscribe(System.IAsyncResult result) {
            base.Channel.EndSuscribe(result);
        }
        
        private System.IAsyncResult OnBeginSuscribe(object[] inValues, System.AsyncCallback callback, object asyncState) {
            this.VerifyCallbackEvents();
            string instance = ((string)(inValues[0]));
            return ((VideoDistanc.ChangeServiceReference.ChangeService)(this)).BeginSuscribe(instance, callback, asyncState);
        }
        
        private object[] OnEndSuscribe(System.IAsyncResult result) {
            ((VideoDistanc.ChangeServiceReference.ChangeService)(this)).EndSuscribe(result);
            return null;
        }
        
        private void OnSuscribeCompleted(object state) {
            if ((this.SuscribeCompleted != null)) {
                InvokeAsyncCompletedEventArgs e = ((InvokeAsyncCompletedEventArgs)(state));
                this.SuscribeCompleted(this, new System.ComponentModel.AsyncCompletedEventArgs(e.Error, e.Cancelled, e.UserState));
            }
        }
        
        public void SuscribeAsync(string instance) {
            this.SuscribeAsync(instance, null);
        }
        
        public void SuscribeAsync(string instance, object userState) {
            if ((this.onBeginSuscribeDelegate == null)) {
                this.onBeginSuscribeDelegate = new BeginOperationDelegate(this.OnBeginSuscribe);
            }
            if ((this.onEndSuscribeDelegate == null)) {
                this.onEndSuscribeDelegate = new EndOperationDelegate(this.OnEndSuscribe);
            }
            if ((this.onSuscribeCompletedDelegate == null)) {
                this.onSuscribeCompletedDelegate = new System.Threading.SendOrPostCallback(this.OnSuscribeCompleted);
            }
            base.InvokeAsync(this.onBeginSuscribeDelegate, new object[] {
                        instance}, this.onEndSuscribeDelegate, this.onSuscribeCompletedDelegate, userState);
        }
        
        [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
        System.IAsyncResult VideoDistanc.ChangeServiceReference.ChangeService.BeginPublish(string message, System.AsyncCallback callback, object asyncState) {
            return base.Channel.BeginPublish(message, callback, asyncState);
        }
        
        [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
        void VideoDistanc.ChangeServiceReference.ChangeService.EndPublish(System.IAsyncResult result) {
            base.Channel.EndPublish(result);
        }
        
        private System.IAsyncResult OnBeginPublish(object[] inValues, System.AsyncCallback callback, object asyncState) {
            this.VerifyCallbackEvents();
            string message = ((string)(inValues[0]));
            return ((VideoDistanc.ChangeServiceReference.ChangeService)(this)).BeginPublish(message, callback, asyncState);
        }
        
        private object[] OnEndPublish(System.IAsyncResult result) {
            ((VideoDistanc.ChangeServiceReference.ChangeService)(this)).EndPublish(result);
            return null;
        }
        
        private void OnPublishCompleted(object state) {
            if ((this.PublishCompleted != null)) {
                InvokeAsyncCompletedEventArgs e = ((InvokeAsyncCompletedEventArgs)(state));
                this.PublishCompleted(this, new System.ComponentModel.AsyncCompletedEventArgs(e.Error, e.Cancelled, e.UserState));
            }
        }
        
        public void PublishAsync(string message) {
            this.PublishAsync(message, null);
        }
        
        public void PublishAsync(string message, object userState) {
            if ((this.onBeginPublishDelegate == null)) {
                this.onBeginPublishDelegate = new BeginOperationDelegate(this.OnBeginPublish);
            }
            if ((this.onEndPublishDelegate == null)) {
                this.onEndPublishDelegate = new EndOperationDelegate(this.OnEndPublish);
            }
            if ((this.onPublishCompletedDelegate == null)) {
                this.onPublishCompletedDelegate = new System.Threading.SendOrPostCallback(this.OnPublishCompleted);
            }
            base.InvokeAsync(this.onBeginPublishDelegate, new object[] {
                        message}, this.onEndPublishDelegate, this.onPublishCompletedDelegate, userState);
        }
        
        private void OnNotifyReceived(object state) {
            if ((this.NotifyReceived != null)) {
                object[] results = ((object[])(state));
                this.NotifyReceived(this, new NotifyReceivedEventArgs(results, null, false, null));
            }
        }
        
        private void VerifyCallbackEvents() {
            if (((this.useGeneratedCallback != true) 
                        && (this.NotifyReceived != null))) {
                throw new System.InvalidOperationException("Callback events cannot be used when the callback InstanceContext is specified. Pl" +
                        "ease choose between specifying the callback InstanceContext or subscribing to th" +
                        "e callback events.");
            }
        }
        
        private System.IAsyncResult OnBeginOpen(object[] inValues, System.AsyncCallback callback, object asyncState) {
            this.VerifyCallbackEvents();
            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 VideoDistanc.ChangeServiceReference.ChangeService CreateChannel() {
            return new ChangeServiceClientChannel(this);
        }
        
        private class ChangeServiceClientCallback : object, ChangeServiceCallback {
            
            private ChangeServiceClient proxy;
            
            public void Initialize(ChangeServiceClient proxy) {
                this.proxy = proxy;
            }
            
            public void Notify(string message) {
                this.proxy.OnNotifyReceived(new object[] {
                            message});
            }
        }
        
        private class ChangeServiceClientChannel : ChannelBase<VideoDistanc.ChangeServiceReference.ChangeService>, VideoDistanc.ChangeServiceReference.ChangeService {
            
            public ChangeServiceClientChannel(System.ServiceModel.DuplexClientBase<VideoDistanc.ChangeServiceReference.ChangeService> client) : 
                    base(client) {
            }
            
            public System.IAsyncResult BeginSuscribe(string instance, System.AsyncCallback callback, object asyncState) {
                object[] _args = new object[1];
                _args[0] = instance;
                System.IAsyncResult _result = base.BeginInvoke("Suscribe", _args, callback, asyncState);
                return _result;
            }
            
            public void EndSuscribe(System.IAsyncResult result) {
                object[] _args = new object[0];
                base.EndInvoke("Suscribe", _args, result);
            }
            
            public System.IAsyncResult BeginPublish(string message, System.AsyncCallback callback, object asyncState) {
                object[] _args = new object[1];
                _args[0] = message;
                System.IAsyncResult _result = base.BeginInvoke("Publish", _args, callback, asyncState);
                return _result;
            }
            
            public void EndPublish(System.IAsyncResult result) {
                object[] _args = new object[0];
                base.EndInvoke("Publish", _args, result);
            }
        }
    }
    
    public class NotifyReceivedEventArgs : System.ComponentModel.AsyncCompletedEventArgs {
        
        private object[] results;
        
        public NotifyReceivedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) : 
                base(exception, cancelled, userState) {
            this.results = results;
        }
        
        public string message {
            get {
                base.RaiseExceptionIfNecessary();
                return ((string)(this.results[0]));
            }
        }
    }
}
