コード例 #1
0
        private static PredefinedDeclarationUse CreatePredefinedDeclarationUse(
            Type type,
            string typeName)
        {
            var predefinedDeclarationUse = new PredefinedDeclarationUse(
                new ReflectionPredefinedSyntaxNodeProvider(type),
                typeName);

            return(predefinedDeclarationUse);
        }
コード例 #2
0
        internal static bool TryGetPredefinedDeclarationUse(
            Type type,
            out PredefinedDeclarationUse typeUse)
        {
            typeUse = null;
            if (type == typeof(byte))
            {
                typeUse = CreatePredefinedDeclarationUse(type, "byte");
            }
            else if (type == typeof(short))
            {
                typeUse = CreatePredefinedDeclarationUse(type, "short");
            }
            else if (type == typeof(int))
            {
                typeUse = CreatePredefinedDeclarationUse(type, "int");
            }
            else if (type == typeof(long))
            {
                typeUse = CreatePredefinedDeclarationUse(type, "long");
            }
            else if (type == typeof(string))
            {
                typeUse = CreatePredefinedDeclarationUse(type, "string");
            }
            else if (type == typeof(object))
            {
                typeUse = CreatePredefinedDeclarationUse(type, "object");
            }
            else if (type == typeof(float))
            {
                typeUse = CreatePredefinedDeclarationUse(type, "float");
            }
            else if (type == typeof(double))
            {
                typeUse = CreatePredefinedDeclarationUse(type, "double");
            }
            else if (type == typeof(decimal))
            {
                typeUse = CreatePredefinedDeclarationUse(type, "decimal");
            }
            else if (type == typeof(char))
            {
                typeUse = CreatePredefinedDeclarationUse(type, "char");
            }

            return(typeUse != null);
        }