如何在C#中使用包含部分字符串但不完整的字符串的包含字典的密钥方法?

时间:2019-05-27 07:55:15

标签: c# dictionary concurrency

我有一个并发的字典,其键是字符串类型,值是类类型,现在我代码文件中的某些函数将值添加到字典中,即键是Windows计算机上的完整文件名,值是我的类类型。

现在我正在尝试做的是基于此的完整文件路径名的一部分,我想检查并发字典是否包含该值,如果是的话,我希望获取它的值,否则无需执行任何操作。

谢谢!

private ConcurrentDictionary<string, Record> RunningExportDic = new ConcurrentDictionary<string, Record>();


private MethodResult GetExportStatus(string CameraFolderPath)  //Here CameraFolderPath is a part of complete key string which was added to dictionary.
        {
            MethodResult mResult = new MethodResult();
            i2V_Record obj_i2vRecord = null; 

            if (RunningExportDic.ContainsKey(CameraFolderPath))
            {
                obj_i2vRecord = RunningExportDic[CameraFolderPath];
            }           

            if (obj_i2vRecord != null)
            {
                if (obj_i2vRecord.isExportSuccessfully && obj_i2vRecord.isThreadClosed)
                {
                    mResult.Result = ResultMessage.SUCCESS;
                    mResult.Obj_Result = "Exorted Successfully";
                }
                else
                {
                    mResult.Obj_Result = obj_i2vRecord.statusString;
                }
            }
            else
            {
                mResult.Obj_Result = "Error";
            }
            return mResult;
        }

0 个答案:

没有答案