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


C# Types.findTypeByName方法代码示例

本文整理汇总了C#中Types.findTypeByName方法的典型用法代码示例。如果您正苦于以下问题:C# Types.findTypeByName方法的具体用法?C# Types.findTypeByName怎么用?C# Types.findTypeByName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Types的用法示例。


在下文中一共展示了Types.findTypeByName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: FindType

        /// <summary>
        ///     Provides the type associated to the name
        /// </summary>
        /// <param name="nameSpace">the namespace in which the name should be found</param>
        /// <param name="name"></param>
        /// <returns></returns>
        public Type FindType(Types.NameSpace nameSpace, string name)
        {
            Type retVal = null;

            if (name != null)
            {
                if (nameSpace != null)
                {
                    if (!_cache.ContainsKey(nameSpace))
                    {
                        _cache[nameSpace] = new Dictionary<string, Type>();
                    }
                    Dictionary<string, Type> subCache = _cache[nameSpace];

                    if (!subCache.ContainsKey(name))
                    {
                        Type tmp = null;

                        if (!Utils.Util.isEmpty(name))
                        {
                            tmp = nameSpace.findTypeByName(name);

                            if (tmp == null)
                            {
                                if (DefinedTypes.ContainsKey(name))
                                {
                                    tmp = DefinedTypes[name];
                                }
                            }

                            if (tmp == null && DefinedTypes.ContainsKey("Default." + name))
                            {
                                tmp = DefinedTypes["Default." + name];
                            }
                        }

                        subCache[name] = tmp;
                    }

                    retVal = subCache[name];
                }
                else
                {
                    if (DefinedTypes.ContainsKey(name))
                    {
                        retVal = DefinedTypes[name];
                    }
                    else if (DefinedTypes.ContainsKey("Default." + name))
                    {
                        retVal = DefinedTypes["Default." + name];
                    }
                }
            }

            return retVal;
        }
开发者ID:nikiforovandrey,项目名称:ERTMSFormalSpecs,代码行数:62,代码来源:Dictionary.cs

示例2: FindType

        /// <summary>
        ///     Provides the type associated to the name
        /// </summary>
        /// <param name="nameSpace">the namespace in which the name should be found</param>
        /// <param name="name"></param>
        /// <returns></returns>
        public Type FindType(Types.NameSpace nameSpace, string name)
        {
            Type retVal = null;

            Dictionary<string, Type> definedTypes = DefinedTypes;
            if (name != null)
            {
                if (nameSpace != null)
                {
                                        CriticalSection.WaitOne();
                    try
                    {

                        if (!_cache.ContainsKey(nameSpace))
                        {
                            _cache[nameSpace] = new Dictionary<string, Type>();
                        }
                        Dictionary<string, Type> subCache = _cache[nameSpace];

                        if (!subCache.ContainsKey(name))
                        {
                            Type tmp = null;

                            if (!Utils.Util.isEmpty(name))
                            {
                                tmp = nameSpace.findTypeByName(name);

                                if (tmp == null)
                                {
                                    if (definedTypes.ContainsKey(name))
                                    {
                                        tmp = definedTypes[name];
                                    }
                                }

                                if (tmp == null && definedTypes.ContainsKey("Default." + name))
                                {
                                    tmp = definedTypes["Default." + name];
                                }
                            }

                            subCache[name] = tmp;
                        }

                        retVal = subCache[name];
                    }
                    finally
                    {
                        CriticalSection.ReleaseMutex();
                    }
                }
                else
                {
                    if (definedTypes.ContainsKey(name))
                    {
                        retVal = definedTypes[name];
                    }
                    else if (definedTypes.ContainsKey("Default." + name))
                    {
                        retVal = definedTypes["Default." + name];
                    }
                }
            }

            return retVal;
        }
开发者ID:GautierBerck,项目名称:ERTMSFormalSpecs,代码行数:72,代码来源:Dictionary.cs


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