当前位置: 首页>>代码示例>>C#>>正文


C# IDictionary.AddOrSet方法代码示例

本文整理汇总了C#中IDictionary.AddOrSet方法的典型用法代码示例。如果您正苦于以下问题:C# IDictionary.AddOrSet方法的具体用法?C# IDictionary.AddOrSet怎么用?C# IDictionary.AddOrSet使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IDictionary的用法示例。


在下文中一共展示了IDictionary.AddOrSet方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Setup

        public override void Setup(IDictionary<string, object> table)
        {
            table.AddOrSet("config", ConfigStr);

            table.AddOrSet("cpath",
                Environment.GetEnvironmentVariable("LUA_CPATH_5_2") ??
                    Environment.GetEnvironmentVariable("LUA_CPATH") ??
                        String.Join(";", new[]
                        {
                            "!\\?.dll",
                            "!\\loadall.dll",
                            ".\\?.dll"
                        }));

            table.AddOrSet("path",
                Environment.GetEnvironmentVariable("LUA_PATH_5_2") ??
                    Environment.GetEnvironmentVariable("LUA_PATH") ??
                        String.Join(";", new[]
                        {
                            "!\\lua\\" + "?.lua",
                            "!\\lua\\" + "?\\init.lua",
                            "!\\" + "?.lua",
                            "!\\" + "?\\init.lua",
                            ".\\?.lua"
                        }));

            table.AddOrSet("loaded", new LuaTable(Context));
            table.AddOrSet("preload", new LuaTable(Context));
            table.AddOrSet("searchers", new LuaTable(Context)); // TODO: fill with searchers

            table.AddOrSet("loadlib", (Func<string, string, object>)Loadlib);
            table.AddOrSet("searchpath", (Func<string, string, string, string, object>) SearchPath);
        }
开发者ID:SPARTAN563,项目名称:IronLua,代码行数:33,代码来源:PackageLibrary.cs

示例2: Setup

        public override void Setup(IDictionary<string, object> table)
        {
            table.AddOrSet("time", (Func<LuaTable, double>)Time );
            table.AddOrSet("difftime", (Func<double, double, double>) ((t2, t1) => t2 - t1));

            //table.AddOrSet("date", (Func<object, object>)Date); // TODO

            table.AddOrSet("exit", (Action<double>)(e => Environment.Exit((int)e)));
            table.AddOrSet("getenv", (Func<string, string>) Environment.GetEnvironmentVariable);

            table.AddOrSet("remove", (Func<string, object>) Delete);
            table.AddOrSet("rename", (Func<string, string, object>) Rename);
        }
开发者ID:SPARTAN563,项目名称:IronLua,代码行数:13,代码来源:OSLibrary.cs

示例3: Setup

 public override void Setup(IDictionary<string, object> table)
 {
     table.AddOrSet("import", (Func<string,object[], LuaTable>)ImportType);
     table.AddOrSet("method", (Func<object, string, object>)InteropGetMethod);
     table.AddOrSet("call", (Func<object, string, object[], object>)InteropCallMethod);
     table.AddOrSet("setvalue", (Func<object, string, object, object>)InteropSetValue);
     table.AddOrSet("getvalue", (Func<object, string, object>)InteropGetValue);
     table.AddOrSet("subscribe", (Action<object, string, Delegate>)InteropSubscribeEvent);
     table.AddOrSet("unsubscribe", (Action<object, string, Delegate>)InteropUnsubscribeEvent);
     table.AddOrSet("makearray", (Func<object, object, object>)MakeArray);
     table.AddOrSet("iterate", (Func<object, object[], object>)InteropEnumerate);
 }
开发者ID:SPARTAN563,项目名称:IronLua,代码行数:12,代码来源:InteropLibrary.cs

示例4: Setup

        public override void Setup(IDictionary<string, object> table)
        {
            table.AddOrSet("len", (Func<string, double>) (s => s.Length));
            table.AddOrSet("upper", (Func<string, string>) (s => s.ToUpperInvariant()));
            table.AddOrSet("lower", (Func<string, string>)(s => s.ToLowerInvariant()));
            table.AddOrSet("rep", (Func<string, double, string>) ((s, r) => s.Repeat((int)Math.Round(r, MidpointRounding.ToEven))));

            table.AddOrSet("sub", (Func<string, double, double, string>)Subst); // TODO: varargs
            table.AddOrSet("char", (Func<double[], string>) Char); // TODO: varargs
            table.AddOrSet("byte", (Func<string, double, double, double[]>) Byte); // TODO: varargs

            table.AddOrSet("find", (Func<string, string, int?, bool?, object[]>)Find);
        }
开发者ID:SPARTAN563,项目名称:IronLua,代码行数:13,代码来源:StringLibrary.cs

示例5: Setup

 public override void Setup(IDictionary<string, object> table)
 {
     table.AddOrSet("getlocal", (Func<object, object, Varargs>)GetLocal);
     table.AddOrSet("setlocal", (Func<object, object, object, object>)SetLocal);
 }
开发者ID:SPARTAN563,项目名称:IronLua,代码行数:5,代码来源:DebugLibrary.cs

示例6: Setup

        public override void Setup(IDictionary<string,object> table)
        {
            const double Math_Tau = 2.0 * Math.PI; // http://tauday.com

            table.AddOrSet("huge", Double.MaxValue);

            // Basic operations
            table.AddOrSet("abs", (Func<double, double>)Math.Abs);
            table.AddOrSet("mod", (Func<double, double, double>)((a, b) => a % b));
            table.AddOrSet("modf", (Func<double, double, Varargs>)((a, b) =>
            {
                long r;
                long q = Math.DivRem((long) a, (long) b, out r);
                return new Varargs(q, r);
            }));
            table.AddOrSet("floor", (Func<double, double>) Math.Floor);
            table.AddOrSet("ceil", (Func<double, double>) Math.Ceiling);
            table.AddOrSet("min", (Func<double, double, double>) Math.Min);
            table.AddOrSet("max", (Func<double, double, double>) Math.Max);

            // Exponetial and logarithmic
            table.AddOrSet("sqrt", (Func<double, double>) Math.Sqrt);
            table.AddOrSet("pow", (Func<double, double, double>) Math.Pow);
            table.AddOrSet("exp", (Func<double, double>) Math.Exp);
            table.AddOrSet("log", (Func<double, double>) Math.Log);
            table.AddOrSet("log10", (Func<double, double>) Math.Log10);

            // Trigonometrical
            table.AddOrSet("pi", Math.PI);
            table.AddOrSet("tau", Math_Tau);
            table.AddOrSet("deg", (Func<double, double>)(r => r * 360.0 / Math_Tau));
            table.AddOrSet("rad", (Func<double, double>)(d => d / 360.0 * Math_Tau));
            table.AddOrSet("cos", (Func<double, double>) Math.Cos);
            table.AddOrSet("sin", (Func<double, double>) Math.Sin);
            table.AddOrSet("tan", (Func<double, double>)Math.Tan);
            table.AddOrSet("acos", (Func<double, double>)Math.Acos);
            table.AddOrSet("asin", (Func<double, double>)Math.Asin);
            table.AddOrSet("atan", (Func<double, double>)Math.Atan);
            table.AddOrSet("atan2", (Func<double, double, double>)Math.Atan2);

            // Splitting on powers of 2
            //table.AddOrSet("frexp", (Func<double, double>) Math.??);
            //table.AddOrSet("ldexp", (Func<double, double, double>) Math.??);

            // Pseudo-random numbers
            table.AddOrSet("randomseed", (Func<double, double>)(x => { rand = new Random((int)x); return rand.NextDouble(); }));
            table.AddOrSet("random", (Func<Varargs, double>)Random); // overloaded
        }
开发者ID:SPARTAN563,项目名称:IronLua,代码行数:48,代码来源:MathLibrary.cs


注:本文中的IDictionary.AddOrSet方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。