了解WMI对象路径格式

Eta*_*tan 9 .net c# regex wmi parsing

我想编写一个与.NET ManagementPath类具有相似功能的类.在MSDN上是一组处理对象路径格式的文章.但是,我对所有特殊情况都不了解

  • 处理对象路径的字符串比较始终不区分大小写.==>在查询对象实例时,这是否也适用于键的值?

  • 整数的十六进制常量.==>它们会在哪里发生?只在键的值?

  • 具有带布尔值的键的类的布尔常量.==>常数是什么?真假?0/1?

  • 具有部分命名空间路径的假定本地服务器.因此,指定root和default命名空间意味着本地服务器上的root和default命名空间.==>这只是意味着如果我没有指定服务器,那么"." 用作服务器?

  • 元素内或元素之间没有空格.==>为什么原始的.NET实现允许服务器名称中的空格呢?

  • 允许在对象路径中使用嵌入式引号,但必须使用转义字符分隔引号,如在C或C++应用程序中那样.==> ???

  • 只有十进制值被识别为键的数字部分.==> ???

  • 此页面上的所有内容:http://msdn.microsoft.com/en-us/library/aa389223( v = VS.85).aspx ==>?

那么,我认为有效的基本路径看起来像

\\Server\Namespace
        \Namespace
\\Server\Namespace:Class
        \Namespace:Class
                   Class
\\Server\Namespace:Class.KeyName=KeyValue
        \Namespace:Class.KeyName=KeyValue
                   Class.KeyName=KeyValue
\\Server\Namespace:Class=KeyValue
        \Namespace:Class=KeyValue
                   Class=KeyValue
\\Server\Namespace:Class.FirstKey=FirstValue,SecondKey=SecondValue
        \Namespace:Class.FirstKey=FirstValue,SecondKey=SecondValue
                   Class.FirstKey=FirstValue,SecondKey=SecondValue
\\Server\Namespace:Class=@
        \Namespace:Class=@
                   Class=@
as well as all combinations were the \\ is replaced by a // and/or the 
\ between server and namespace is replaced by /
Run Code Online (Sandbox Code Playgroud)

我忘记了什么吗?

这是可以从MSDN中提取的内容.但是,个人令牌怎么样?这是我认为它可能是:

KeyValue = "string"      <-- string
           1             <-- numeric
           0x1           <-- hex
           ??????????    <-- about the "decimal value" thing and 
                             "embedded quitation mark" thing. 
                             Also, what about whitespaces? 
                             do they have to be abreviated by %20?

KeyName / Class / Server
         = string without : or / or \ inside and maybe only [a-z0-9_] ? 

Namespace 
         = string without : or / inside and maybe only [a-z0-9_\]
        (.NET implementation also buggy here. accepts forward slashes regardless of 
          "You cannot use forward slashes within namespace names." on MSDN)
            Also, are they allowed to start with \ and end with a : ?
Run Code Online (Sandbox Code Playgroud)

如果对于每个令牌,可以给出正则表达式,它将是非常有用的.

rob*_*les 1

也许您可以通过查看该类的源代码获得有用的信息。

如果你想测试一个字符串是否与正则表达式匹配,你可以使用tester

祝你好运。