Exemplo n.º 1
0
        //--- Class Methods ---
        private static string ConvertDate(XDoc date)
        {
            long?epoch = date.AsLong;

            if (!epoch.HasValue)
            {
                return(null);
            }
            var datetime = DateTimeUtil.FromEpoch((uint)(epoch.Value / 1000));

            return(DekiScriptLibrary.CultureDateTime(datetime));
        }
Exemplo n.º 2
0
        public static DekiScriptLiteral FromNativeValue(object value)
        {
            if (value is DekiScriptLiteral)
            {
                return((DekiScriptLiteral)value);
            }
            if (value != null)
            {
                switch (AsScriptType(value.GetType()))
                {
                case DekiScriptType.BOOL:
                    return(Constant((bool)value));

                case DekiScriptType.NUM:
                    return(Constant(SysUtil.ChangeType <double>(value)));

                case DekiScriptType.STR:
                    if (value is DateTime)
                    {
                        return(Constant(DekiScriptLibrary.CultureDateTime((DateTime)value)));
                    }
                    return(Constant(value.ToString()));

                case DekiScriptType.MAP:
                    return(new DekiScriptMap((Hashtable)value));

                case DekiScriptType.LIST:
                    return(new DekiScriptList((ArrayList)value));

                case DekiScriptType.XML:
                    return(Constant((XDoc)value));

                case DekiScriptType.URI:
                    return(Constant((XUri)value));
                }
            }
            return(DekiScriptNil.Value);
        }