public static void Main(string[] argv) { ClientApi client = new ClientApi(); // ClientUser ui = new ClientUser(); SampleUI ui = new SampleUI(); Error error = new Error(); client.Init(error); client.Run("info", ui); client.SetArgv(new string[] { "-u", "cmarshall" }); client.Run("clients", ui); client.Final(error); }
private void EstablishConnection(bool tagged, KeepAlive keepAlive) { if (m_ClientApi != null && m_ClientApi.Dropped() != 0) { // I can't figure out how to force this artificially, so currently untested :-( CloseConnection(); } if (m_ClientApi == null) { m_ClientApi = new ClientApi(); } if (!_Initialized) { Error err = null; try { _tagged = tagged; err = m_ClientApi.CreateError(); // Always use the specstring protocol. We'll controll form output via SetTag // before each run m_ClientApi.SetProtocol("specstring", ""); //May have lost our settings... reset here if (_Client != null) m_ClientApi.SetClient(_Client); if (_User != null) m_ClientApi.SetUser(_User); if (_CWD != null) m_ClientApi.SetCwd(_CWD); if (_Charset != null) m_ClientApi.SetCharset(_Charset); if (_Host != null) m_ClientApi.SetHost(_Host); if (_Port != null) m_ClientApi.SetPort(_Port); if (_Password != null) m_ClientApi.SetPassword(_Password); if (_TicketFile != null) m_ClientApi.SetTicketFile(_TicketFile); if (_maxResults != 0) m_ClientApi.SetMaxResults(_maxResults); if (_maxScanRows != 0) m_ClientApi.SetMaxScanRows(_maxResults); if (_maxLockTime != 0) m_ClientApi.SetMaxLockTime(_maxLockTime); if (_ApiLevel != 0) m_ClientApi.SetProtocol("api", _ApiLevel.ToString()); m_ClientApi.Init(err); if (err.Severity == Error.ErrorSeverity.Failed || err.Severity == Error.ErrorSeverity.Fatal) { throw new Exception("Unable to connect to Perforce!"); } _Initialized = true; err.Dispose(); } catch (Exception e) { string message = "Perforce connection error."; try { m_ClientApi.Final(err); message = e.Message; err.Dispose(); m_ClientApi.Dispose(); m_ClientApi = null; } catch { } throw new PerforceInitializationError(message); } } if (tagged) m_ClientApi.SetTag(); if (_CallingProgram != null) m_ClientApi.SetProg(_CallingProgram); if (_CallingProgramVersion != null) m_ClientApi.SetVersion(_CallingProgramVersion); m_ClientApi.SetBreak(keepAlive); }
private void CloseConnection() { // Need to reset the connection if (_Initialized) { Error err = m_ClientApi.CreateError(); m_ClientApi.Final(err); err.Dispose(); } if (m_ClientApi != null) { m_ClientApi.Dispose(); m_ClientApi = null; } _Initialized = false; }
internal static HandleRef getCPtr(ClientApi obj) { return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr; }