質問

I am using COM interop for Word automation within my Silverlight-Ouf-Of-Browser application. This means that I can't reference COM directly but instead I rely on dynamic.

Now I would like to call the following method:

Range.Collapse(WdCollapseDirection direction).

How do I find out what values are mapped to the individual enum values (e.g.does wdCollapseEnd have a value of 1 or 2)?

Kind regards!

PS: For further info on the method signature see http://msdn.microsoft.com/de-de/library/microsoft.office.interop.word.range.collapse

役に立ちましたか?

解決

Tools like Reflector make that fairly simple. You could even use ILDASM that comes with part of the .NET Framework.

You can load the Primary Interop Assembly with either of those two tools. Reflector shows the C# source as:

public enum WdCollapseDirection
{
    wdCollapseEnd,
    wdCollapseStart
}

Since they have no explicit values, wdCollapseEnd is 0 and wdCollapseStart is 1. We can confirm with the IL view:

.class public auto ansi sealed WdCollapseDirection
    extends [mscorlib]System.Enum
{
    .field public specialname rtspecialname int32 value__

    .field public static literal valuetype Microsoft.Office.Interop.Word.WdCollapseDirection wdCollapseEnd = int32(0)

    .field public static literal valuetype Microsoft.Office.Interop.Word.WdCollapseDirection wdCollapseStart = int32(1)

}

ILDASM shows this:

.field public static literal valuetype Microsoft.Office.Interop.Word.WdCollapseDirection wdCollapseEnd = int32(0x00000000)

If you have a tool like Resharper, doing Ctrl+Q on it directly from within Visual Studio shows this:

enter image description here

You could have a dummy project that you can use to look up the values.

As an additional option, if you use LINQPad you could reference the Word Primary Interop Assembly (Microsoft.Office.Interop.Word - should be in the GAC) and run this:

void Main()
{
    var value = (int) Microsoft.Office.Interop.Word.WdCollapseDirection.wdCollapseStart;
    Console.Out.WriteLine("value = {0}", value);
}
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top