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


C# TypeDeclaration.ToString方法代码示例

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


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

示例1: handle

        private void handle(TypeDeclaration type, DirectoryInfo projectFolder)
        {
            if (type.ClassType != ClassType.Enum)
                return;

            Dictionary<String, String> textDict = new Dictionary<string, string>();
            foreach (AttributeSection attribute in type.Attributes)
            {
                String attributeText = attribute.ToString();
                Match attributeNameMatch = getAttrubuteNameRegex.Match(attribute.ToString());

                Group attributeNameGroup = attributeNameMatch.Groups["name"];
                if (!attributeNameGroup.Success || attributeNameGroup.Value != "TextResource")
                    continue;

                foreach (Match match in regex.Matches(type.ToString()))
                {
                    Group keyGroup = match.Groups["key"];
                    Group valueGroup = match.Groups["value"];
                    if (!keyGroup.Success || !valueGroup.Success)
                        continue;
                    String key = keyGroup.Value.Trim();
                    String value = valueGroup.Value.Trim();
                    textDict.Add(key, value);
                }
            }
            if (textDict.Count == 0)
                return;

            TypeDeclaration currentType = type;
            String typeFullName = null;
            while (true)
            {
                if (typeFullName == null)
                    typeFullName = type.Name;
                else
                    typeFullName = String.Format("{0}+{1}", currentType.Name, typeFullName);
                if (currentType.Parent is TypeDeclaration)
                {
                    currentType = (TypeDeclaration)currentType.Parent;
                    continue;
                }
                else if (currentType.Parent is NamespaceDeclaration)
                {
                    NamespaceDeclaration namesp = (NamespaceDeclaration)currentType.Parent;
                    typeFullName = String.Format("{0}.{1}", namesp.FullName, typeFullName);
                    break;
                }
                else
                    throw new ApplicationException("Type's parent unknown!");
            }
            handle(typeFullName, textDict, projectFolder);
        }
开发者ID:aaasoft,项目名称:Quick.OwinMVC,代码行数:53,代码来源:CsFileHandler.cs

示例2: renderInterface

        InterfaceRenderInformation renderInterface(TypeDeclaration interfaceDecl)
        {
            var ret = new InterfaceRenderInformation();

            ret.isRoutableViewModel = interfaceDecl.BaseTypes
                .OfType<SimpleType>()
                .Any(x => x.Identifier == "IRoutableViewModel") ? ret : null;

            ret.definition = "public " + chompedString(interfaceDecl.ToString().Replace("[Once]", ""));
            ret.interfaceName = chompedString(interfaceDecl.Name);
            ret.implClassName = ret.interfaceName.Substring(1); // Skip the 'I'

            ret.properties = interfaceDecl.Children
                .Where(x => x is PropertyDeclaration || x is MethodDeclaration)
                .Select(renderPropertyDeclaration)
                .ToArray();

            ret.onceProperties = ret.properties
                .Where(x => x.onceProp != null)
                .Select(x => x.onceProp)
                .ToArray();

            return ret;
        }
开发者ID:gluck,项目名称:ReactiveUI,代码行数:24,代码来源:ScaffoldRenderer.cs

示例3: Set

        public static TypeCode Set(TypeDeclaration typedecl, CSharpAstResolver resolver)
        {
            var ns = typedecl.Parent as NamespaceDeclaration;
            var nsName = ns == null ? "" : ns.FullName;
            var name = typedecl.Name;

            var usings =
                resolver.RootNode.Descendants.
                OfType<UsingDeclaration> ().
                Select (x => x.ToString ().Trim ()).
                ToList ();

            var code = typedecl.ToString ();

            var deps = new List<String> ();
            foreach (var d in typedecl.Descendants.OfType<SimpleType> ()) {
                deps.Add (d.Identifier);
            }

            return Set (name, usings, code, deps, nsName);
        }
开发者ID:Applied-Duality,项目名称:LiveCode,代码行数:21,代码来源:TypeCode.cs

示例4: WriteTypeDeclaration

		private static void WriteTypeDeclaration(TypeDeclaration value, TextWriter writer)
		{
			writer.Write(value.ToString());
		}
开发者ID:adisik,项目名称:simple-assembly-explorer,代码行数:4,代码来源:BamlTranslator.cs


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