本文整理汇总了C#中System.Reflection.GetSimpleName方法的典型用法代码示例。如果您正苦于以下问题:C# Reflection.GetSimpleName方法的具体用法?C# Reflection.GetSimpleName怎么用?C# Reflection.GetSimpleName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Reflection
的用法示例。
在下文中一共展示了Reflection.GetSimpleName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateViewModelDescriptors
private static void CreateViewModelDescriptors(IZetboxContext ctx, SR.Assembly srAssembly)
{
using (Logging.Log.InfoTraceMethodCallFormat("CreateViewModelDescriptors", "Creating ViewModelDescriptors"))
{
var liveDescriptors = new HashSet<ViewModelDescriptor>();
foreach (var type in GetTypes(srAssembly))
{
object attr;
// http://blogs.msdn.com/b/kaevans/archive/2005/10/24/484186.aspx
if (type.Assembly.ReflectionOnly)
{
attr = SR.CustomAttributeData.GetCustomAttributes(type).FirstOrDefault(i => i.Constructor.DeclaringType.FullName == typeof(ViewModelDescriptorAttribute).FullName);
}
else
{
attr = type.GetCustomAttributes(typeof(ViewModelDescriptorAttribute), false).FirstOrDefault() as ViewModelDescriptorAttribute;
}
if (attr != null)
{
var typeName = type.GetSimpleName();
var descr = ctx.GetQuery<ViewModelDescriptor>().FirstOrDefault(i => i.ViewModelTypeRef == typeName);
if (descr == null)
{
descr = ctx.Create<ViewModelDescriptor>();
descr.ViewModelTypeRef = typeName;
descr.Description = "TODO: Add description";
}
else
{
descr.Deleted = false;
}
liveDescriptors.Add(descr);
}
}
var simpleAssemblyName = srAssembly.GetSimpleName();
var deadDescriptors = ctx
.GetQuery<ViewModelDescriptor>()
.ToList()
.Where(vmd => TypeSpec.Parse(vmd.ViewModelTypeRef).AssemblyName.IfNullOrWhiteSpace(string.Empty).Split(',').FirstOrDefault().IfNullOrWhiteSpace(string.Empty).Trim() == simpleAssemblyName)
.Except(liveDescriptors);
foreach (var d in deadDescriptors)
{
d.Deleted = true;
}
}
}
示例2: CreateViewDescriptors
private static void CreateViewDescriptors(IZetboxContext ctx, SR.Assembly srAssembly)
{
using (Logging.Log.InfoTraceMethodCallFormat("CreateViewDescriptors", "Creating ViewDescriptors"))
{
var liveDescriptors = new HashSet<ViewDescriptor>();
foreach (var type in GetTypes(srAssembly))
{
object attr;
Toolkit? tk = null;
// http://blogs.msdn.com/b/kaevans/archive/2005/10/24/484186.aspx
if (type.Assembly.ReflectionOnly)
{
attr = SR.CustomAttributeData.GetCustomAttributes(type).FirstOrDefault(i => i.Constructor.DeclaringType.FullName == typeof(ViewDescriptorAttribute).FullName);
if (attr != null) tk = (Toolkit)((SR.CustomAttributeData)attr).ConstructorArguments.Single().Value;
}
else
{
attr = type.GetCustomAttributes(typeof(ViewDescriptorAttribute), false).FirstOrDefault() as ViewDescriptorAttribute;
if (attr != null) tk = ((ViewDescriptorAttribute)attr).Toolkit;
}
if (attr != null)
{
var typeName = type.GetSimpleName();
// if a view can be used under multiple ControlKinds, it needs to have multiple ViewDescriptors
var descrList = ctx.GetQuery<ViewDescriptor>().Where(i => i.ControlTypeRef == typeName).ToList();
if (descrList.Count == 0)
{
var descr = ctx.Create<ViewDescriptor>();
descr.ControlTypeRef = typeName;
if (tk != null) descr.Toolkit = tk.Value;
liveDescriptors.Add(descr);
}
else
{
foreach (var descr in descrList)
{
descr.Deleted = false;
liveDescriptors.Add(descr);
}
}
}
}
var simpleAssemblyName = srAssembly.GetSimpleName();
var deadDescriptors = ctx
.GetQuery<ViewDescriptor>()
.ToList()
.Where(vmd => TypeSpec.Parse(vmd.ControlTypeRef).AssemblyName.IfNullOrWhiteSpace(string.Empty).Split(',').FirstOrDefault().IfNullOrWhiteSpace(string.Empty).Trim() == simpleAssemblyName)
.Except(liveDescriptors);
foreach (var d in deadDescriptors)
{
d.Deleted = true;
}
}
}