当前位置: 首页>>代码示例>>C#>>正文


C# IReadOnlyDictionary.Add方法代码示例

本文整理汇总了C#中IReadOnlyDictionary.Add方法的典型用法代码示例。如果您正苦于以下问题:C# IReadOnlyDictionary.Add方法的具体用法?C# IReadOnlyDictionary.Add怎么用?C# IReadOnlyDictionary.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IReadOnlyDictionary的用法示例。


在下文中一共展示了IReadOnlyDictionary.Add方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: requestState

        public void requestState(IReadOnlyList<string> listOfParameters, IMethodResult oResult)
        {
            Logger.Write("requestState call");
            Logger.Write("listOfParameters:", listOfParameters);

            IReadOnlyDictionary<string, object> resultHash = new IReadOnlyDictionary<string, object>();

            if (m_connection != null && m_connection.IsConnected() && m_printer != null)
            {
                PrinterStatus currStatus = getStatus();
                
                if (currStatus != null)
                {
                    resultHash.Add(ZebraConstants.HK_STATUS, ZebraConstants.PRINTER_STATUS_SUCCESS);
                    resultHash.Add(ZebraConstants.HK_MESSAGE, "");

                    foreach (string parameter in listOfParameters)
                    {
                        switch(parameter)
                        {
                        case ZebraConstants.PRINTER_STATE_IS_HEAD_COLD:
                            resultHash.Add(ZebraConstants.PRINTER_STATE_IS_HEAD_COLD, currStatus.IsHeadCold);
                            break;
                        case ZebraConstants.PRINTER_STATE_IS_HEAD_OPEN:
                            resultHash.Add(ZebraConstants.PRINTER_STATE_IS_HEAD_OPEN, currStatus.IsHeadOpen);
                            break;
                        case ZebraConstants.PRINTER_STATE_IS_HEAD_TOO_HOT:
                            resultHash.Add(ZebraConstants.PRINTER_STATE_IS_HEAD_TOO_HOT, currStatus.IsHeadTooHot);
                            break;
                        case ZebraConstants.PRINTER_STATE_IS_PAPER_OUT:
                            resultHash.Add(ZebraConstants.PRINTER_STATE_IS_PAPER_OUT, currStatus.IsPaperOut);
                            break;
                        case ZebraConstants.PRINTER_STATE_IS_PARTIAL_FORMAT_IN_PROGRESS:
                            resultHash.Add(ZebraConstants.PRINTER_STATE_IS_PARTIAL_FORMAT_IN_PROGRESS, currStatus.IsPartialFormatInProgress);
                            break;
                        case ZebraConstants.PRINTER_STATE_IS_PAUSED:
                            resultHash.Add(ZebraConstants.PRINTER_STATE_IS_BATTERY_LOW, currStatus.IsPaused);
                            break;
                        case ZebraConstants.PRINTER_STATE_IS_READY_TO_PRINT:
                            resultHash.Add(ZebraConstants.PRINTER_STATE_IS_READY_TO_PRINT, currStatus.IsReadyToPrint);
                            break;
                        case ZebraConstants.PRINTER_STATE_IS_RECEIVE_BUFFER_FULL:
                            resultHash.Add(ZebraConstants.PRINTER_STATE_IS_RECEIVE_BUFFER_FULL, currStatus.IsReceiveBufferFull);
                            break;
                        case ZebraConstants.PRINTER_STATE_IS_RIBBON_OUT:
                            resultHash.Add(ZebraConstants.PRINTER_STATE_IS_RIBBON_OUT, currStatus.IsRibbonOut);
                            break;
                        case ZebraConstants.PRINTER_STATE_LABELS_REMAINING_IN_BATCH:
                            resultHash.Add(ZebraConstants.PRINTER_STATE_LABELS_REMAINING_IN_BATCH, currStatus.LabelsRemainingInBatch);
                            break;
                        case ZebraConstants.PRINTER_STATE_LABEL_LENGTH_IN_DOTS:
                            resultHash.Add(ZebraConstants.PRINTER_STATE_LABEL_LENGTH_IN_DOTS, currStatus.LabelLengthInDots);
                            break;
                        case ZebraConstants.PRINTER_STATE_NUMBER_OF_FORMATS_IN_RECEIVE_BUFFER:
                            resultHash.Add(ZebraConstants.PRINTER_STATE_NUMBER_OF_FORMATS_IN_RECEIVE_BUFFER, currStatus.NumberOfFormatsInReceiveBuffer);
                            break;
                        case ZebraConstants.PRINTER_STATE_PRINT_MODE:
                            switch (currStatus.PrintMode)
                            {
                                case ZplPrintMode.REWIND:
                                    resultHash.Add(ZebraConstants.PRINTER_STATE_PRINT_MODE, ZebraConstants.PRINT_MODE_REWIND);
                                    break;
                                case ZplPrintMode.PEEL_OFF:
                                    resultHash.Add(ZebraConstants.PRINTER_STATE_PRINT_MODE, ZebraConstants.PRINT_MODE_PEEL_OFF);
                                    break;
                                case ZplPrintMode.TEAR_OFF:
                                    resultHash.Add(ZebraConstants.PRINTER_STATE_PRINT_MODE, ZebraConstants.PRINT_MODE_TEAR_OFF);
                                    break;
                                case ZplPrintMode.CUTTER:
                                    resultHash.Add(ZebraConstants.PRINTER_STATE_PRINT_MODE, ZebraConstants.PRINT_MODE_CUTTER);
                                    break;
                                case ZplPrintMode.APPLICATOR:
                                    resultHash.Add(ZebraConstants.PRINTER_STATE_PRINT_MODE, ZebraConstants.PRINT_MODE_APPLICATOR);
                                    break;
                                case ZplPrintMode.DELAYED_CUT:
                                    resultHash.Add(ZebraConstants.PRINTER_STATE_PRINT_MODE, ZebraConstants.PRINT_MODE_DELAYED_CUT);
                                    break;
                                case ZplPrintMode.LINERLESS_PEEL:
                                    resultHash.Add(ZebraConstants.PRINTER_STATE_PRINT_MODE, ZebraConstants.PRINT_MODE_LINERLESS_PEEL);
                                    break;
                                case ZplPrintMode.LINERLESS_REWIND:
                                    resultHash.Add(ZebraConstants.PRINTER_STATE_PRINT_MODE, ZebraConstants.PRINT_MODE_REWIND);
                                    break;
                                case ZplPrintMode.PARTIAL_CUTTER:
                                    resultHash.Add(ZebraConstants.PRINTER_STATE_PRINT_MODE, ZebraConstants.PRINT_MODE_PARTIAL_CUTTER);
                                    break;
                                case ZplPrintMode.RFID:
                                    resultHash.Add(ZebraConstants.PRINTER_STATE_PRINT_MODE, ZebraConstants.PRINT_MODE_RFID);
                                    break;
                                case ZplPrintMode.KIOSK:
                                    resultHash.Add(ZebraConstants.PRINTER_STATE_PRINT_MODE, ZebraConstants.PRINT_MODE_KIOSK);
                                    break;
                                case ZplPrintMode.UNKNOWN:
                                    resultHash.Add(ZebraConstants.PRINTER_STATE_PRINT_MODE, ZebraConstants.PRINT_MODE_UNKNOWN);
                                    break;
                            }
                            break;
                        }
                    }
                }
//.........这里部分代码省略.........
开发者ID:rhomobile,项目名称:rhodes,代码行数:101,代码来源:PrinterZebra_impl.cs

示例2: retrieveFileNamesWithExtensions

        public void retrieveFileNamesWithExtensions(IReadOnlyList<string> extensions, IMethodResult oResult)
        {
            Logger.Write("retrieveFileNamesWithExtensions call");
            Logger.Write("extensions:", extensions);

            IReadOnlyDictionary<string, object> resultHash = new IReadOnlyDictionary<string, object>();

            if (m_printer != null)
            {
                RetriveParser parser = new RetriveParser(m_connection);

                List<string> resultNames = parser.getAllFileNames(extensions);

                resultHash.Add(ZebraConstants.HK_STATUS, ZebraConstants.PRINTER_STATUS_SUCCESS);
                resultHash.Add(ZebraConstants.HK_FILE_NAMES, resultNames);
                oResult.set(resultHash);

                return;
            }

            resultHash.Add(ZebraConstants.HK_STATUS, ZebraConstants.PRINTER_STATUS_ERROR);
            resultHash.Add(ZebraConstants.HK_FILE_NAMES, new List<string>());
            oResult.set(resultHash);
        }
开发者ID:rhomobile,项目名称:rhodes,代码行数:24,代码来源:PrinterZebra_impl.cs

示例3: enumerateSupportedControlLanguages

        public void enumerateSupportedControlLanguages(IMethodResult oResult)
        {
            Logger.Write("enumerateSupportedControlLanguages call");

            if (m_printer != null)
            {
                IReadOnlyDictionary<string, string> controlLanguage = new IReadOnlyDictionary<string, string>();

                switch (m_printer.GetPrinterControlLanguage())
                {
                    case PrinterLanguage.CPCL:
                        controlLanguage.Add(ZebraConstants.PRINTER_LANGUAGE_CPCL, "");
                        break;
                    case PrinterLanguage.ZPL:
                        controlLanguage.Add(ZebraConstants.PRINTER_LANGUAGE_ZPL, "");
                        controlLanguage.Add(ZebraConstants.PRINTER_LANGUAGE_CPCL, "");
                        break;
                }

                oResult.set(controlLanguage);
                return;
            }

            oResult.set(ZebraConstants.PRINTER_STATUS_ERR_NOT_CONNECTED);
        }
开发者ID:rhomobile,项目名称:rhodes,代码行数:25,代码来源:PrinterZebra_impl.cs

示例4: retrieveFileNames

        public void retrieveFileNames(IMethodResult oResult)
        {
            Logger.Write("call retrieveFileNames ");

            IReadOnlyDictionary<string, object> resultHash = new IReadOnlyDictionary<string, object>();

            if (m_connection != null && m_connection.IsConnected())
            {
                RetriveParser parser = new RetriveParser(m_connection);

                List<string> resultNames = parser.getAllFileNames();
                
                resultHash.Add(ZebraConstants.HK_STATUS, ZebraConstants.PRINTER_STATUS_SUCCESS);
                resultHash.Add(ZebraConstants.HK_FILE_NAMES, resultNames);
                oResult.set(resultHash);

                return;
            }

            resultHash.Add(ZebraConstants.HK_STATUS, ZebraConstants.PRINTER_STATUS_ERROR);
            resultHash.Add(ZebraConstants.HK_FILE_NAMES, new List<string>());
            oResult.set(resultHash);
        }
开发者ID:rhomobile,项目名称:rhodes,代码行数:23,代码来源:PrinterZebra_impl.cs

示例5: printRawString

        public void printRawString(string command, IReadOnlyDictionary<string, string> options, IMethodResult oResult)
        {
            Logger.Write("printRawString call: " + command);
            Logger.Write("command: " + command);
            Logger.Write("options:", options);

            if (m_connection != null && m_printer != null)
            {
                try
                {                    
                    byte[] commandStr = Encoding.UTF8.GetBytes(command);
                    m_connection.Write(commandStr);
                    
                    Thread.Sleep(500);
                                        
                    byte[] printerResponse = m_connection.Read();
                    string printerResponseStr = Encoding.UTF8.GetString(printerResponse, 0, printerResponse.Length);

                    IReadOnlyDictionary<string, string> response = new IReadOnlyDictionary<string, string>();

                    response.Add(ZebraConstants.HK_STATUS, ZebraConstants.PRINTER_STATUS_SUCCESS);
                    response.Add(ZebraConstants.HK_STRING_RESPONCE, printerResponseStr);

                    oResult.set(response);
                }
                catch (Exception ex)
                {
                    IReadOnlyDictionary<string, string> errResponse = new IReadOnlyDictionary<string, string>();

                    errResponse.Add(ZebraConstants.HK_STATUS, ZebraConstants.PRINTER_STATUS_ERROR);
                    errResponse.Add(ZebraConstants.HK_MESSAGE, ex.Message.ToString());

                    oResult.set(errResponse);
                }
            }
            else
            {
                oResult.set(ZebraConstants.PRINTER_STATUS_ERR_NOT_CONNECTED);
            }
        }
开发者ID:rhomobile,项目名称:rhodes,代码行数:40,代码来源:PrinterZebra_impl.cs


注:本文中的IReadOnlyDictionary.Add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。