Exemplo n.º 1
0
        public virtual void GenerateCodeFromExpression(CodeExpression expression, TextWriter writer, CodeGeneratorOptions options)
        {
            ICodeGenerator cg = CreateGenerator();

            if (cg == null)
            {
                throw GetNotImplemented();
            }
            cg.GenerateCodeFromExpression(expression, writer, options);
        }
Exemplo n.º 2
0
        public void GenerateCodeFromExpression(CodeExpression e, TextWriter w, CodeGeneratorOptions o)
        {
            ICustomCodeDomObject co = e as ICustomCodeDomObject;

            if (co != null)
            {
                co.GenerateCode(GetLang());
            }

            _generator.GenerateCodeFromExpression(e, w, o);
        }
Exemplo n.º 3
0
 private string Generate(CodeExpression expression, StringWriter sw)
 {
     generator.GenerateCodeFromExpression(expression, sw, options);
     return(sw.ToString());
 }
 public override void GenerateCodeFromExpression(CodeExpression e, TextWriter w, CodeGeneratorOptions o)
 {
     generator.GenerateCodeFromExpression(e, w, o);
 }
        internal string GetTypeName(Type symType, bool useSimplifiedNamespaces)
        {
            if (symType == null)
            {
                return(null);
            }
            if ((symType.IsGenericType) &&
                (symType.Namespace == "System") &&
                (symType.GetGenericArguments().Length == 1))
            {
                if (symType == typeof(bool?))
                {
                    return("bool?");
                }
                if (symType == typeof(sbyte?))
                {
                    return("sbyte?");
                }
                if (symType == typeof(byte?))
                {
                    return("byte?");
                }
                if (symType == typeof(char?))
                {
                    return("char?");
                }
                if (symType == typeof(short?))
                {
                    return("short?");
                }
                if (symType == typeof(ushort?))
                {
                    return("ushort?");
                }
                if (symType == typeof(int?))
                {
                    return("int?");
                }
                if (symType == typeof(uint?))
                {
                    return("uint?");
                }
                if (symType == typeof(long?))
                {
                    return("long?");
                }
                if (symType == typeof(ulong?))
                {
                    return("ulong?");
                }
                if (symType == typeof(float?))
                {
                    return("float?");
                }
                if (symType == typeof(double?))
                {
                    return("double?");
                }
                if (symType == typeof(decimal?))
                {
                    return("decimal?");
                }
                if ((symType == typeof(Guid?)) ||
                    (symType == typeof(DateTime?)))
                {
                    return(GetTypeName(symType.GetGenericArguments()[0],
                                       useSimplifiedNamespaces) + "?");
                }
            }
            string symTypeName;

            using (StringWriter stringWriter = new StringWriter())
            {
                gen.GenerateCodeFromExpression(new System.CodeDom.
                                               CodeTypeReferenceExpression(symType), stringWriter, null);
                symTypeName = stringWriter.ToString();
            }
            if (useSimplifiedNamespaces)
            {
                foreach (string namespacePrefix in new string[]
                {
                    "System.Collections.Generic.",
                    "System.Collections.",
                    "System."
                })
                {
                    symTypeName = symTypeName.Replace(namespacePrefix, "");
                }
            }
            return(symTypeName);
        }