void ProcessExcel(string path) { AssertThat.IsNotNullOrEmpty(path); var excelApp = new Application(); var workbooks = excelApp.Workbooks.Open(path); try { int pageCount = workbooks.Sheets.Count; AssertThat.IsTrue(pageCount > 1, "Excel's page count MUST > 1"); var sheet = workbooks.Sheets[2]; AssertThat.IsNotNull(sheet, "Excel's sheet is null"); Worksheet worksheet = sheet as Worksheet; AssertThat.IsNotNull(sheet, "Excel's worksheet is null"); var usedRange = worksheet.UsedRange; var name = Path.GetFileNameWithoutExtension(path); new ProtoGenerator(name, usedRange).Process(); } catch (Exception e) { Console.WriteLine(e); throw; } finally { workbooks.Close(); excelApp.Quit(); System.Runtime.InteropServices.Marshal.ReleaseComObject(excelApp); } }
/// <summary> /// Connect to server /// </summary> /// <param name="ip">ipv4/ipv6</param> /// <param name="port"></param> public void Connect(string ip, int port) { AssertThat.IsNotNullOrEmpty(ip); var iep = new IPEndPoint(IPAddress.Parse(ip), port); Connect(iep); }
/// <summary> /// Connect to server /// </summary> /// <param name="ip">ipv4/ipv6</param> /// <param name="port"></param> public void Connect(string ip, int port) { lock (_locker) { AssertThat.IsNotNullOrEmpty(ip, "ip is null or empty"); var iep = new IPEndPoint(IPAddress.Parse(ip), port); Connect(iep); } }
void ProcessExcel(string path) { AssertThat.IsNotNullOrEmpty(path); var fileInfo = new FileInfo(path); ExcelPackage.LicenseContext = LicenseContext.NonCommercial; using (ExcelPackage excelPackage = new ExcelPackage(fileInfo)) { var count = excelPackage.Workbook.Worksheets.Count; var worksheet = excelPackage.Workbook.Worksheets[0]; AssertThat.IsNotNull(worksheet, "Excel's sheet is null"); var rowCount = worksheet.Dimension.Rows; var columnCount = worksheet.Dimension.Columns; var name = Path.GetFileNameWithoutExtension(path); new ProtoGenerater(name, rowCount, columnCount, worksheet).Process(); } }
void ProcessExcel(string excelFilePath) { AssertThat.IsNotNullOrEmpty(excelFilePath); var excelApp = new Application(); var workbooks = excelApp.Workbooks.Open(excelFilePath); try { var sheet = workbooks.Sheets[1]; AssertThat.IsNotNull(sheet, "Excel's sheet is null"); Worksheet worksheet = sheet as Worksheet; AssertThat.IsNotNull(sheet, "Excel's worksheet is null"); var usedRange = worksheet.UsedRange; //int rowCount = usedRange.Rows.Count; //int colCount = usedRange.Columns.Count; //for (int i = 1; i <= rowCount; i++) //{ // for (int j = 1; j <= colCount; j++) // { // var value = ((Range)usedRange.Cells[i, j]).Value2; // var str = value.ToString(); // } //} var protoName = Path.GetFileNameWithoutExtension(excelFilePath); new ProtoGenerator(protoName, usedRange).Generate(); } catch (Exception e) { Console.WriteLine(e); throw; } finally { workbooks.Close(); excelApp.Quit(); System.Runtime.InteropServices.Marshal.ReleaseComObject(excelApp); } }
public void RemovePlugin(string name) { AssertThat.IsNotNullOrEmpty(name); plugins.Remove(name); }
public IPlugin GetPlugin(string name) { AssertThat.IsNotNullOrEmpty(name); return(plugins[name]); }
/// <summary> /// Remove plugin /// </summary> /// <param name="name">plugin's name</param> public void RemovePlugin(string name) { AssertThat.IsNotNullOrEmpty(name, "Name is null or empty"); _plugins.Remove(name); }
public bool IsPluginExist(string name) { AssertThat.IsNotNullOrEmpty(name, "Name is null or empty"); return(_plugins.ContainsKey(name)); }
/// <summary> /// Get plugin by name /// </summary> /// <param name="name">plugin's name</param> /// <returns>plugin</returns> public IPlugin GetPlugin(string name) { AssertThat.IsNotNullOrEmpty(name, "Name is null or empty"); return(_plugins[name]); }
/// <summary> /// Dispatch message from socket /// </summary> /// <param name="key"></param> /// <param name="bytes"></param> public static void Dispatch(string key, byte[] bytes) { AssertThat.IsNotNullOrEmpty(key); AssertThat.IsTrue(_msgs.ContainsKey(key)); _msgs[key].OnBytes(bytes); }