zoukankan      html  css  js  c++  java
  • 根据handle转换成ObjectId

     /// <summary>
        /// 从句柄转换成ObjectId
        /// Version : 2010.03.29 Sieben
        /// </summary>
        /// <param name="handle">句柄,可以是Handle,string,int,long数据类型</param>
        /// <returns>成功返回句柄所对应的ObjectId,否则返回ObjectId.Null</returns>
        public static ObjectId HandleToObjectId(object handle)
        {
          try
          {
            if (handle == null) return ObjectId.Null;
            ObjectId tId2 = ObjectId.Null;
            if (handle is Handle)
              return sc.db.GetObjectId(false, (Handle)handle, 0);
            else if (handle is string)
            {
              string tStr = handle.ToString().Trim();

              if (tStr == "")
                return ObjectId.Null;
              else if (tStr == "0")
                return ObjectId.Null;
              else
              {
                long lNum = Convert.ToInt64(tStr, 16);
                if (lNum == 0L)
                  return ObjectId.Null;
                else
                  return sc.db.GetObjectId(false, new Handle(lNum), 0);
              }
            }
            else if (handle is int || handle is long)
            {
              long lNum = (long)handle;
              if (lNum == 0L)
                return ObjectId.Null;
              else
                return sc.db.GetObjectId(false, new Handle(lNum), 0);
            }
            else
              return ObjectId.Null;
          }
          catch
          {
            return ObjectId.Null;
          }
        }

  • 相关阅读:
    C语言修炼-第2天
    static_cast, dynamic_cast, reinterpret_cast, const_cast的区别
    构造函数不能为虚函数的原因
    matlab2016b ubuntu命令行安装 + matconvnet的安装
    python debug open_files
    构造函数不能被继承的原因
    NNVM代码阅读
    ncnn阅读
    Deep TEN: Texture Encoding Network
    git命令笔记
  • 原文地址:https://www.cnblogs.com/swtool/p/3828991.html
Copyright © 2011-2022 走看看