コード例 #1
0
ファイル: TypeSignature.cs プロジェクト: CharliePoole/website
 /// <summary>
 /// Initializes a new instance of the <see cref="TypeSignature" /> class.
 /// </summary>
 /// <param name="identity">The Identity.</param>
 /// <param name="name">The name.</param>
 /// <param name="url">The type URL.</param>
 /// <param name="namespace">The namespace.</param>
 /// <param name="genericArguments">The generic arguments.</param>
 /// <param name="genericParameters">The generic parameters.</param>
 public TypeSignature(
     string identity,
     string name,
     string url,
     NamespaceSignature @namespace,
     IEnumerable<string> genericArguments,
     IEnumerable<TypeSignature> genericParameters)
 {
     Name = name;
     Url = url ?? "#unresolved";
     Identity = identity;
     Namespace = @namespace;
     GenericArguments = new List<string>(genericArguments);
     GenericParameters = new List<TypeSignature>(genericParameters);
 }
コード例 #2
0
ファイル: TypeSignature.cs プロジェクト: kcamp/cake-website
 /// <summary>
 /// Initializes a new instance of the <see cref="TypeSignature" /> class.
 /// </summary>
 /// <param name="identity">The Identity.</param>
 /// <param name="name">The name.</param>
 /// <param name="url">The type URL.</param>
 /// <param name="namespace">The namespace.</param>
 /// <param name="genericArguments">The generic arguments.</param>
 /// <param name="genericParameters">The generic parameters.</param>
 public TypeSignature(
     string identity,
     string name,
     string url,
     NamespaceSignature @namespace,
     IEnumerable <string> genericArguments,
     IEnumerable <TypeSignature> genericParameters)
 {
     Name              = name;
     Url               = url ?? "#unresolved";
     Identity          = identity;
     Namespace         = @namespace;
     GenericArguments  = new List <string>(genericArguments);
     GenericParameters = new List <TypeSignature>(genericParameters);
 }
コード例 #3
0
        /// <summary>
        /// Gets a type description for the specified type.
        /// </summary>
        /// <param name="type">The type reference.</param>
        /// <param name="resolver">The link resolver.</param>
        /// <returns>A type description for the specified type.</returns>
        public static TypeSignature GetTypeSignature(this TypeReference type, IUrlResolver resolver)
        {
            // Get the namespace of the type.
            var ns = new NamespaceSignature(type.Namespace);

            // Get the identity.
            var identity = CRefGenerator.GetTypeCRef(type);

            // Get the type name.
            var name = type.Name;
            var index = name.IndexOf('`');
            if (index != -1)
            {
                name = name.Substring(0, index);
            }

            if (name.EndsWith("&"))
            {
                name = name.TrimEnd('&');
            }

            // Get generic parameters and arguments.
            var genericParameters = new List<string>();
            var genericArguments = new List<TypeSignature>();
            if (type.IsGenericInstance)
            {
                // Generic arguments
                var genericInstanceType = type as GenericInstanceType;
                if (genericInstanceType != null)
                {
                    genericArguments.AddRange(
                        genericInstanceType.GenericArguments.Select(
                        reference => GetTypeSignature(reference, resolver)));
                }
            }
            else if (type.HasGenericParameters)
            {
                // Generic parameters
                genericParameters.AddRange(
                    type.GenericParameters.Select(
                        genericParameter => genericParameter.Name));
            }

            // Return the type description.
            var url = resolver?.GetUrl(identity);
            return new TypeSignature(identity, name, url, ns, genericParameters, genericArguments);
        }