Esempio n. 1
0
            }             // proc UpdateCallSite

            protected override string MatchEvaluatorImpl(Match m)
            {
                string[] args = new string[m.Groups.Count - 1];
                for (int i = 1; i < m.Groups.Count; i++)
                {
                    args[i - 1] = m.Groups[i].Value;
                }

                return((string)Lua.RtConvertValue(Lua.RtInvokeSite(callSite, callInfo => new Lua.LuaInvokeBinder(null, callInfo), UpdateCallSite, funcCall, args), typeof(string)));
            }     // func MatchEvaluator
Esempio n. 2
0
 private static string LuaToString(object v)
 {
     if (v == null)
     {
         return("nil");
     }
     else
     {
         return((string)Lua.RtConvertValue(v, typeof(string)));
     }
 }         // func LuaToString
Esempio n. 3
0
        }         // func type

        /// <summary>Implementation of http://www.lua.org/manual/5.3/manual.html#pdf-math.tointeger </summary>
        /// <param name="x"></param>
        /// <returns></returns>
        public static object tointeger(object x)
        {
            try
            {
                return((long)Lua.RtConvertValue(x, typeof(long)));
            }
            catch
            {
                return(null);
            }
        }         // func tointeger
Esempio n. 4
0
        }         // func read

        #endregion

        #region -- Write, Seek ------------------------------------------------------------

        private void WriteValue(object v)
        {
            if (v == null)
            {
                return;
            }
            else
            {
                WriteValue((string)Lua.RtConvertValue(v, typeof(string)));
            }
        }         // proc WriteValue
Esempio n. 5
0
        }         // func GetTypeCode

        /// <summary></summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="iIndex"></param>
        /// <param name="default"></param>
        /// <returns></returns>
        public T GetValueOrDefault <T>(int iIndex, T @default)
        {
            object v = this[iIndex];

            try
            {
                return((T)Lua.RtConvertValue(v, typeof(T)));
            }
            catch
            {
                return(@default);
            }
        }         // func GetValueOrDefault
Esempio n. 6
0
        /// <summary>Converts a number representing the date and time back to some higher-level representation.</summary>
        /// <param name="format">Format string. Same format as the C <see href="http://www.cplusplus.com/reference/ctime/strftime/">strftime()</see> function.</param>
        /// <param name="time">Numeric date-time. It defaults to the current date and time.</param>
        /// <returns>Formatted date string, or table of time information.</returns>
        /// <remarks>by PapyRef</remarks>
        public static object date(string format, object time)
        {
            // Unix timestamp is seconds past epoch. Epoch date for time_t is 00:00:00 UTC, January 1, 1970.
            DateTime dt;

            var toUtc = format != null && format.Length > 0 && format[0] == '!';

            if (time == null)
            {
                dt = toUtc ? DateTime.UtcNow : DateTime.Now;
            }
            else if (time is DateTime)
            {
                dt = (DateTime)time;
                switch (dt.Kind)
                {
                case DateTimeKind.Utc:
                    if (!toUtc)
                    {
                        dt = dt.ToLocalTime();
                    }
                    break;

                default:
                    if (toUtc)
                    {
                        dt = dt.ToUniversalTime();
                    }
                    break;
                }
            }
            else
            {
                dt = unixStartTime.AddSeconds((long)Lua.RtConvertValue(time, typeof(long)));
                if (toUtc)
                {
                    dt = dt.ToUniversalTime();
                }
            }

            // Date and time expressed as coordinated universal time (UTC).
            if (toUtc)
            {
                format = format.Substring(1);
            }

            if (String.Compare(format, "*t", false) == 0)
            {
                var lt = new LuaTable
                {
                    ["year"]  = dt.Year,
                    ["month"] = dt.Month,
                    ["day"]   = dt.Day,
                    ["hour"]  = dt.Hour,
                    ["min"]   = dt.Minute,
                    ["sec"]   = dt.Second,
                    ["wday"]  = (int)dt.DayOfWeek,
                    ["yday"]  = dt.DayOfYear,
                    ["isdst"] = (dt.Kind == DateTimeKind.Local ? true : false)
                };
                return(lt);
            }
            else
            {
                return(AT.MIN.Tools.ToStrFTime(dt, format));
            }
        }         // func date
Esempio n. 7
0
            }             // ctor

            protected override string MatchEvaluatorImpl(Match m)
            {
                return((string)Lua.RtConvertValue(t.GetMemberValue(m.Groups[1].Value, lIgnoreCase), typeof(string)));
            }     // func MatchEvaluator
Esempio n. 8
0
 public GSubLuaTableMatchEvaluator(LuaTable t)
 {
     this.t           = t;
     this.lIgnoreCase = (bool)Lua.RtConvertValue(t.GetMemberValue("__IgnoreCase"), typeof(bool));
 }             // ctor
Esempio n. 9
0
        } // proc Dispose

        public object GetPropertyValue(TaskPropertyInfo property)
        {
            return(Lua.RtConvertValue(global[property.Name], property.PropertyType));
        } // func GetPropertyValue
Esempio n. 10
0
        }         // proc Dispose

        public object GetPropertyValue(TaskPropertyInfo property)
        => Lua.RtConvertValue(global[property.Name], property.PropertyType);