Exemple #1
0
        // Public Methods 

        public bool TryGetPhpString(out string txt)
        {
            switch (kind)
            {
            case Kinds.StringConstant:
                if (PhpValues.TryGetPhpStringValue(phpValue, out txt))
                {
                    return(true);
                }
                throw new NotSupportedException();

            case Kinds.Bool:
                txt = (bool)sourceValue ? "1" : "";
                return(true);

            case Kinds.Int:
            case Kinds.OctalInt:
                txt = ((int)sourceValue).ToString();
                return(true);

            case Kinds.Double:
                txt = phpValue;
                return(true);

            case Kinds.DefinedConst:
                txt = "";
                return(false);

            case Kinds.Null:
                txt = "";
                return(true);

            default:
                throw new NotSupportedException();
            }
        }
Exemple #2
0
        public void AddFormat(string f, params object[] o)
        {
            var oo = o.Select(i => PhpValues.ToPhpCodeValue(i)).ToArray();

            s.AppendFormat(f, oo);
        }
Exemple #3
0
 public void Add(object o)
 {
     s.Append(PhpValues.ToPhpCodeValue(o));
 }
Exemple #4
0
 public static PhpCodeValue FromString(string txt)
 {
     return(new PhpCodeValue(PhpValues.PhpStringEmit(txt, true), txt, Kinds.StringConstant));
 }
Exemple #5
0
        public static PhpCodeValue FromInt(int v, bool octal = false)
        {
            var txt = octal ? PhpValues.Dec2Oct(v) : v.ToString();

            return(new PhpCodeValue(txt, v, octal ? Kinds.OctalInt : Kinds.Int));
        }