当前位置: 首页>>代码示例>>C#>>正文


C# Reflection.GetSimpleName方法代码示例

本文整理汇总了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;
                }
            }
        }
开发者ID:daszat,项目名称:zetbox,代码行数:50,代码来源:AssemblyActions.cs

示例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;
                }
            }
        }
开发者ID:daszat,项目名称:zetbox,代码行数:57,代码来源:AssemblyActions.cs


注:本文中的System.Reflection.GetSimpleName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。