CreateValueExpression() static private method

static private CreateValueExpression ( string builtInType, string strValue ) : System.CodeDom.CodeExpression
builtInType string
strValue string
return System.CodeDom.CodeExpression
        internal static CodeExpression CreateFixedDefaultValueExpression(CodeTypeReference type, string value)
        {
            CodeExpression codeExpression;
            string         baseType = type.BaseType;

            if (baseType.Contains("Nullable"))
            {
                Debug.Assert(type.TypeArguments.Count == 1);
                baseType       = type.TypeArguments[0].BaseType;
                codeExpression = SimpleTypeCodeDomHelper.CreateValueExpression(baseType, value);
            }
            else if (type.ArrayRank != 0)
            {
                baseType       = type.ArrayElementType.BaseType;
                codeExpression = SimpleTypeCodeDomHelper.CreateFixedDefaultArrayValueInit(baseType, value);
            }
            else if (!baseType.Contains("List"))
            {
                codeExpression = SimpleTypeCodeDomHelper.CreateValueExpression(baseType, value);
            }
            else
            {
                Debug.Assert(type.TypeArguments.Count == 1);
                baseType       = type.TypeArguments[0].BaseType;
                codeExpression = SimpleTypeCodeDomHelper.CreateFixedDefaultArrayValueInit(baseType, value);
            }
            return(codeExpression);
        }
        internal static CodeArrayCreateExpression CreateFixedDefaultArrayValueInit(string baseType, string value)
        {
            CodeArrayCreateExpression array = new CodeArrayCreateExpression(baseType, new CodeExpression[0]);

            string[] strArrays = value.Split(new char[] { ' ' });
            for (int i = 0; i < (int)strArrays.Length; i++)
            {
                string s = strArrays[i];
                array.Initializers.Add(SimpleTypeCodeDomHelper.CreateValueExpression(baseType, s));
            }
            return(array);
        }