Click here to Skip to main content
15,881,248 members
Articles / Desktop Programming / XAML

Silverlight Advanced View Model Style Video Player

Rate me:
Please Sign up or sign in to vote.
4.91/5 (35 votes)
16 May 2010Ms-PL12 min read 83.4K   4K   48  
A full featured Silverlight View Model Style Video Player
//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:4.0.30128.1
//
//     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.50303.0
// 
namespace MVVMVideoPlayer_Test.wsVideos {
    using System.Runtime.Serialization;
    
    
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "4.0.0.0")]
    [System.Runtime.Serialization.CollectionDataContractAttribute(Name="ArrayOfString", Namespace="http://OpenLightGroup.net/", ItemName="string")]
    public class ArrayOfString : System.Collections.Generic.List<string> {
    }
    
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
    [System.ServiceModel.ServiceContractAttribute(Namespace="http://OpenLightGroup.net/", ConfigurationName="wsVideos.WebServiceSoap")]
    public interface WebServiceSoap {
        
        [System.ServiceModel.OperationContractAttribute(AsyncPattern=true, Action="http://OpenLightGroup.net/GetVideos", ReplyAction="*")]
        System.IAsyncResult BeginGetVideos(MVVMVideoPlayer_Test.wsVideos.GetVideosRequest request, System.AsyncCallback callback, object asyncState);
        
        MVVMVideoPlayer_Test.wsVideos.GetVideosResponse EndGetVideos(System.IAsyncResult result);
    }
    
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
    [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
    [System.ServiceModel.MessageContractAttribute(IsWrapped=false)]
    public partial class GetVideosRequest {
        
        [System.ServiceModel.MessageBodyMemberAttribute(Name="GetVideos", Namespace="http://OpenLightGroup.net/", Order=0)]
        public MVVMVideoPlayer_Test.wsVideos.GetVideosRequestBody Body;
        
        public GetVideosRequest() {
        }
        
        public GetVideosRequest(MVVMVideoPlayer_Test.wsVideos.GetVideosRequestBody Body) {
            this.Body = Body;
        }
    }
    
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
    [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
    [System.Runtime.Serialization.DataContractAttribute()]
    public partial class GetVideosRequestBody {
        
        public GetVideosRequestBody() {
        }
    }
    
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
    [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
    [System.ServiceModel.MessageContractAttribute(IsWrapped=false)]
    public partial class GetVideosResponse {
        
        [System.ServiceModel.MessageBodyMemberAttribute(Name="GetVideosResponse", Namespace="http://OpenLightGroup.net/", Order=0)]
        public MVVMVideoPlayer_Test.wsVideos.GetVideosResponseBody Body;
        
        public GetVideosResponse() {
        }
        
        public GetVideosResponse(MVVMVideoPlayer_Test.wsVideos.GetVideosResponseBody Body) {
            this.Body = Body;
        }
    }
    
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
    [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
    [System.Runtime.Serialization.DataContractAttribute(Namespace="http://OpenLightGroup.net/")]
    public partial class GetVideosResponseBody {
        
        [System.Runtime.Serialization.DataMemberAttribute(EmitDefaultValue=false, Order=0)]
        public MVVMVideoPlayer_Test.wsVideos.ArrayOfString GetVideosResult;
        
        public GetVideosResponseBody() {
        }
        
        public GetVideosResponseBody(MVVMVideoPlayer_Test.wsVideos.ArrayOfString GetVideosResult) {
            this.GetVideosResult = GetVideosResult;
        }
    }
    
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
    public interface WebServiceSoapChannel : MVVMVideoPlayer_Test.wsVideos.WebServiceSoap, System.ServiceModel.IClientChannel {
    }
    
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
    public partial class GetVideosCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs {
        
        private object[] results;
        
        public GetVideosCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) : 
                base(exception, cancelled, userState) {
            this.results = results;
        }
        
        public MVVMVideoPlayer_Test.wsVideos.ArrayOfString Result {
            get {
                base.RaiseExceptionIfNecessary();
                return ((MVVMVideoPlayer_Test.wsVideos.ArrayOfString)(this.results[0]));
            }
        }
    }
    
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
    public partial class WebServiceSoapClient : System.ServiceModel.ClientBase<MVVMVideoPlayer_Test.wsVideos.WebServiceSoap>, MVVMVideoPlayer_Test.wsVideos.WebServiceSoap {
        
        private BeginOperationDelegate onBeginGetVideosDelegate;
        
        private EndOperationDelegate onEndGetVideosDelegate;
        
        private System.Threading.SendOrPostCallback onGetVideosCompletedDelegate;
        
        private BeginOperationDelegate onBeginOpenDelegate;
        
        private EndOperationDelegate onEndOpenDelegate;
        
        private System.Threading.SendOrPostCallback onOpenCompletedDelegate;
        
        private BeginOperationDelegate onBeginCloseDelegate;
        
        private EndOperationDelegate onEndCloseDelegate;
        
        private System.Threading.SendOrPostCallback onCloseCompletedDelegate;
        
        public WebServiceSoapClient() {
        }
        
        public WebServiceSoapClient(string endpointConfigurationName) : 
                base(endpointConfigurationName) {
        }
        
        public WebServiceSoapClient(string endpointConfigurationName, string remoteAddress) : 
                base(endpointConfigurationName, remoteAddress) {
        }
        
        public WebServiceSoapClient(string endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress) : 
                base(endpointConfigurationName, remoteAddress) {
        }
        
        public WebServiceSoapClient(System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) : 
                base(binding, remoteAddress) {
        }
        
        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<GetVideosCompletedEventArgs> GetVideosCompleted;
        
        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 MVVMVideoPlayer_Test.wsVideos.WebServiceSoap.BeginGetVideos(MVVMVideoPlayer_Test.wsVideos.GetVideosRequest request, System.AsyncCallback callback, object asyncState) {
            return base.Channel.BeginGetVideos(request, callback, asyncState);
        }
        
        [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
        private System.IAsyncResult BeginGetVideos(System.AsyncCallback callback, object asyncState) {
            MVVMVideoPlayer_Test.wsVideos.GetVideosRequest inValue = new MVVMVideoPlayer_Test.wsVideos.GetVideosRequest();
            inValue.Body = new MVVMVideoPlayer_Test.wsVideos.GetVideosRequestBody();
            return ((MVVMVideoPlayer_Test.wsVideos.WebServiceSoap)(this)).BeginGetVideos(inValue, callback, asyncState);
        }
        
        [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
        MVVMVideoPlayer_Test.wsVideos.GetVideosResponse MVVMVideoPlayer_Test.wsVideos.WebServiceSoap.EndGetVideos(System.IAsyncResult result) {
            return base.Channel.EndGetVideos(result);
        }
        
        [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
        private MVVMVideoPlayer_Test.wsVideos.ArrayOfString EndGetVideos(System.IAsyncResult result) {
            MVVMVideoPlayer_Test.wsVideos.GetVideosResponse retVal = ((MVVMVideoPlayer_Test.wsVideos.WebServiceSoap)(this)).EndGetVideos(result);
            return retVal.Body.GetVideosResult;
        }
        
        private System.IAsyncResult OnBeginGetVideos(object[] inValues, System.AsyncCallback callback, object asyncState) {
            return this.BeginGetVideos(callback, asyncState);
        }
        
        private object[] OnEndGetVideos(System.IAsyncResult result) {
            MVVMVideoPlayer_Test.wsVideos.ArrayOfString retVal = this.EndGetVideos(result);
            return new object[] {
                    retVal};
        }
        
        private void OnGetVideosCompleted(object state) {
            if ((this.GetVideosCompleted != null)) {
                InvokeAsyncCompletedEventArgs e = ((InvokeAsyncCompletedEventArgs)(state));
                this.GetVideosCompleted(this, new GetVideosCompletedEventArgs(e.Results, e.Error, e.Cancelled, e.UserState));
            }
        }
        
        public void GetVideosAsync() {
            this.GetVideosAsync(null);
        }
        
        public void GetVideosAsync(object userState) {
            if ((this.onBeginGetVideosDelegate == null)) {
                this.onBeginGetVideosDelegate = new BeginOperationDelegate(this.OnBeginGetVideos);
            }
            if ((this.onEndGetVideosDelegate == null)) {
                this.onEndGetVideosDelegate = new EndOperationDelegate(this.OnEndGetVideos);
            }
            if ((this.onGetVideosCompletedDelegate == null)) {
                this.onGetVideosCompletedDelegate = new System.Threading.SendOrPostCallback(this.OnGetVideosCompleted);
            }
            base.InvokeAsync(this.onBeginGetVideosDelegate, null, this.onEndGetVideosDelegate, this.onGetVideosCompletedDelegate, 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 MVVMVideoPlayer_Test.wsVideos.WebServiceSoap CreateChannel() {
            return new WebServiceSoapClientChannel(this);
        }
        
        private class WebServiceSoapClientChannel : ChannelBase<MVVMVideoPlayer_Test.wsVideos.WebServiceSoap>, MVVMVideoPlayer_Test.wsVideos.WebServiceSoap {
            
            public WebServiceSoapClientChannel(System.ServiceModel.ClientBase<MVVMVideoPlayer_Test.wsVideos.WebServiceSoap> client) : 
                    base(client) {
            }
            
            public System.IAsyncResult BeginGetVideos(MVVMVideoPlayer_Test.wsVideos.GetVideosRequest request, System.AsyncCallback callback, object asyncState) {
                object[] _args = new object[1];
                _args[0] = request;
                System.IAsyncResult _result = base.BeginInvoke("GetVideos", _args, callback, asyncState);
                return _result;
            }
            
            public MVVMVideoPlayer_Test.wsVideos.GetVideosResponse EndGetVideos(System.IAsyncResult result) {
                object[] _args = new object[0];
                MVVMVideoPlayer_Test.wsVideos.GetVideosResponse _result = ((MVVMVideoPlayer_Test.wsVideos.GetVideosResponse)(base.EndInvoke("GetVideos", _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 Microsoft Public License (Ms-PL)


Written By
Software Developer (Senior) http://ADefWebserver.com
United States United States
Michael Washington is a Microsoft MVP. He is a ASP.NET and
C# programmer.
He is the founder of
AiHelpWebsite.com,
LightSwitchHelpWebsite.com, and
HoloLensHelpWebsite.com.

He has a son, Zachary and resides in Los Angeles with his wife Valerie.

He is the Author of:

Comments and Discussions