本文整理汇总了C#中Microsoft.Office.Interop.Word.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# Microsoft.Office.Interop.Word.GetType方法的具体用法?C# Microsoft.Office.Interop.Word.GetType怎么用?C# Microsoft.Office.Interop.Word.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Office.Interop.Word
的用法示例。
在下文中一共展示了Microsoft.Office.Interop.Word.GetType方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CopyCustomDocumentProperties
static void CopyCustomDocumentProperties(Wd.Document target, Wd.Document source)
{
//dynamic source_props = source.CustomDocumentProperties;
//dynamic target_props = target.CustomDocumentProperties;
//foreach (dynamic prop in source_props)
// target_props.Add(prop.Name, prop.LinkToContent, prop.Type, prop.Value, prop.LinkSource);
object source_props = source.GetType().InvokeMember("CustomDocumentProperties", BindingFlags.Default | BindingFlags.GetProperty, null, source, null);
object target_props = target.GetType().InvokeMember("CustomDocumentProperties", BindingFlags.Default | BindingFlags.GetProperty, null, target, null);
Type soure_typeProps = source_props.GetType();
Type target_typeProps = target_props.GetType();
int count = (int)soure_typeProps.InvokeMember("Count", BindingFlags.Default | BindingFlags.GetProperty, null, source_props, new object[] { });
for (int i = 1; i <= count; i++)
{
object prop = soure_typeProps.InvokeMember("Item", BindingFlags.Default | BindingFlags.GetProperty, null, source_props, new object[] { i });
Type typeProp = prop.GetType();
var name = typeProp.InvokeMember("Name", BindingFlags.Default | BindingFlags.GetProperty, null, prop, new object[] { }).ToString();
var value = typeProp.InvokeMember("Value", BindingFlags.Default | BindingFlags.GetProperty, null, prop, new object[] { }).ToString();
object[] oArgs = { name, false, O.MsoDocProperties.msoPropertyTypeString, value };
target_typeProps.InvokeMember("Add", BindingFlags.Default | BindingFlags.InvokeMethod, null, target_props, oArgs);
}
}