Ejemplo n.º 1
0
 public static void RequiresVersion(IVimClient _client, VimVersion _version)
 {
     if (_client.Version < _version)
     {
         throw new NotSupportedException(string.Format(Resources.MethodNotSupported, _client.ServiceContent.About.ApiVersion));
     }
 }
Ejemplo n.º 2
0
 public ServiceContent Connect()
 {
     if (string.IsNullOrEmpty(this._serviceUrl))
     {
         throw new InvalidOperationException(Resources.InvalidServiceUrl);
     }
     try
     {
         this._vimService = this.CreateClientChannel();
         ServiceContent content = new ServiceInstance((VimClient)this, new ManagedObjectReference()
         {
             Type  = "ServiceInstance",
             Value = "ServiceInstance"
         }).RetrieveServiceContent();
         this._version        = VersionUtils.GetVIServerVersion(content);
         this._serviceContent = content;
         return(this._serviceContent);
     }
     catch (ProtocolException ex)
     {
         throw new VimProtocolException(ex.Message, (Exception)ex);
     }
     catch (EndpointNotFoundException ex)
     {
         throw new VimEndpointNotFoundException(ex.Message, (Exception)ex);
     }
     catch (SecurityNegotiationException ex)
     {
         throw new VimSecurityNegotiationException(ex.Message, (Exception)ex);
     }
     catch (CommunicationException ex)
     {
         throw new VimException(ex.Message, (Exception)ex);
     }
 }
Ejemplo n.º 3
0
        public bool IsVimVersionOrHigher(VimVersion version)
        {
            int result1;

            int.TryParse(this.Version.ToString().Substring(3).PadRight(3, '0'), out result1);
            int result2;

            int.TryParse(version.ToString().Substring(3).PadRight(3, '0'), out result2);
            return(result1 >= result2);
        }