private static void QueryInspectableInterfaces(IntPtr punk, HashSet <COMInterfaceInstance> list) { if (punk == IntPtr.Zero) { return; } object obj = Marshal.GetObjectForIUnknown(punk); IInspectable inspectable = obj as IInspectable; if (inspectable != null) { IntPtr iids = IntPtr.Zero; try { int iid_count; inspectable.GetIids(out iid_count, out iids); for (int i = 0; i < iid_count; ++i) { byte[] buffer = new byte[16]; Marshal.Copy(iids + i * 16, buffer, 0, buffer.Length); list.Add(new COMInterfaceInstance(new Guid(buffer))); } } catch { } finally { if (iids != IntPtr.Zero) { Marshal.FreeCoTaskMem(iids); } } } }
public MainPage() { this.InitializeComponent(); var setup = new ScriptRuntimeSetup(); setup.HostType = typeof(DlrHost); setup.AddRubySetup(); var runtime = Ruby.CreateRuntime(setup); this.engine = Ruby.GetEngine(runtime); this.scope = engine.CreateScope(); this.scope.SetVariable("Main", this); runtime.LoadAssembly(typeof(object).GetTypeInfo().Assembly); runtime.LoadAssembly(typeof(TextSetOptions).GetTypeInfo().Assembly); runtime.LoadAssembly(typeof(TextAlignment).GetTypeInfo().Assembly); string outputText = @" box = main.find_name('OutputBox') p box.text_alignment box.text_alignment = Windows::UI::Xaml::TextAlignment.Right p box.text_alignment "; InputBox.IsSpellCheckEnabled = false; OutputBox.IsSpellCheckEnabled = false; InputBox.Document.SetText(TextSetOptions.None, outputText); // http://msdn.microsoft.com/en-us/library/windows/apps/br211377.aspx IInspectable insp = (IInspectable)InputBox.Document; string winTypeName; insp.GetRuntimeClassName(out winTypeName); Guid[] iids; int iidCount; insp.GetIids(out iidCount, out iids); // winTypeName = "Windows.Foundation.Collections.IIterator`1<Windows.Foundation.Collections.IMapView`2<Windows.Foundation.Collections.IVector`1<String>, String>>"; var parts = ParseWindowsTypeName(winTypeName); Type type = MakeWindowsType(parts); var guid = type.GetTypeInfo().GUID; }