• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# FunctionObject类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中FunctionObject的典型用法代码示例。如果您正苦于以下问题:C# FunctionObject类的具体用法?C# FunctionObject怎么用?C# FunctionObject使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



FunctionObject类属于命名空间,在下文中一共展示了FunctionObject类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Dir

 internal static void Dir(FunctionObject func, CommonObject that, object value)
 {
    Console.BackgroundColor = ConsoleColor.Black;
    Console.ForegroundColor = ConsoleColor.Yellow;
    ObjectDumper.Write(value, 15);
    Console.ResetColor();
 }
开发者ID:bondehagen,项目名称:Uglify.NET,代码行数:7,代码来源:ConsoleObject.cs


示例2: ScriptRunner

 public ScriptRunner()
 {
     _context = new CSharp.Context();
     var file = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Resources/calculate.js");
     _context.ExecuteFile(file);
     _calculate = _context.Globals.GetT<FunctionObject>("calculate");
 }
开发者ID:snoopie72,项目名称:NrImporter,代码行数:7,代码来源:ScriptRunner.cs


示例3: AppendJson

        /// <summary>
        /// Opens a file, appends the specified string to the file, and then closes the file. If the file does not exist, this method creates a file, writes the specified string to the file, then closes the file.
        /// </summary>
        internal static void AppendJson(FunctionObject ctx, ScriptObject instance, BoxedValue path, BoxedValue contents, BoxedValue onComplete, BoxedValue encodingName)
        {
            if (!path.IsString)
                throw new ArgumentException("[appendJson] First parameter should be defined and be a string.");
            if (!contents.IsStrictlyObject)
                throw new ArgumentException("[appendJson] Second parameter should be defined and be an object.");
            if (!onComplete.IsUndefined && !onComplete.IsFunction)
                throw new ArgumentException("[appendJson] Third parameter should be an onComplete function.");

            // Get the curent channel
            var channel = Channel.Current;

            // Dispatch the task
            channel.Async(() =>
            {
                // The encoding to use
                Encoding encoding = encodingName.IsString
                    ? TextEncoding.GetEncoding(encodingName.String)
                    : null;

                // Defaults to UTF8
                if (encoding == null)
                    encoding = TextEncoding.UTF8;

                // Unbox the array of lines and execute the append
                File.AppendAllText(
                    path.Unbox<string>(),
                    Native.Serialize(instance.Env, contents, false).Unbox<string>(),
                    encoding
                    );

                // Dispatch the on complete asynchronously
                channel.DispatchCallback(onComplete, instance);
            });
        }
开发者ID:mizzunet,项目名称:spike-box,代码行数:38,代码来源:FileObject.cs


示例4: AddHandler

 static void AddHandler(
     FunctionObject func, CommonObject that,
     string eventName, FunctionObject handler)
 {
     EventObject self = that.CastTo<EventObject>();
     self.AddHandler(eventName, handler);
 }
开发者ID:conradz,项目名称:Edit5,代码行数:7,代码来源:EventObject.cs


示例5: GetConnectedFor

        /// <summary>
        /// Gets the session time.
        /// </summary>
        /// <param name="ctx">The function context.</param>
        /// <param name="instance">The console object instance.</param>
        /// <param name="eventName">The name of the event.</param>
        internal static BoxedValue GetConnectedFor(FunctionObject ctx, ScriptObject instance)
        {
            // Get the first client
            var client = Channel.Current.First;
            if (client == null)
                return Undefined.Boxed;

            // Return the address
            return BoxedValue.Box(
                client.Channel.ConnectedFor
                );
        }
开发者ID:mizzunet,项目名称:spike-box,代码行数:18,代码来源:RemoteObject.cs


示例6: Log

        internal static void Log(FunctionObject func, CommonObject that, object value)
        {
            Console.BackgroundColor = ConsoleColor.Black;
            Console.ForegroundColor = ConsoleColor.Yellow;
            if(value is string)
                Console.WriteLine(value);
            else if (value is BoxedValue)
            {
                BoxedValue boxedValue = ((BoxedValue)value);
                Console.WriteLine(TypeConverter.ToString(boxedValue));
            }

            Console.ResetColor();
        }
开发者ID:bondehagen,项目名称:Uglify.NET,代码行数:14,代码来源:ConsoleObject.cs


示例7: ScriptEngineContext

        public ScriptEngineContext(IResourceManager resourceManager)
        {
            var envJs = resourceManager.GetStringFromAssemblyOf<ScriptEngine>("Forseti.Scripting.Scripts.env.js");

            _context = Context.enter();
            _context.setOptimizationLevel(-1);
            _scope = _context.initStandardObjects();

            Class myJClass = typeof(SystemConsole);
            Member method = myJClass.getMethod("Print", typeof(string));
            Scriptable function = new FunctionObject("print", method, _scope);
            _scope.put("print", _scope, function);

            SystemConsole.LoggingEnabled = false;
            _context.evaluateString(_scope, envJs, "env.js", 1, null);
            SystemConsole.LoggingEnabled = true;
        }
开发者ID:TomasEkeli,项目名称:Forseti,代码行数:17,代码来源:ScriptEngineContext.cs


示例8: AddGlobalMethodsFromStaticMethodsInType

        void AddGlobalMethodsFromStaticMethodsInType(System.Type type, params string[] methodNames)
        {
            MethodInfo[] methods;
            var query = type.GetMethods(BindingFlags.Public | BindingFlags.Static).Select(m => m);
            if( methodNames.Length > 0 ) 
                query = query.Where(m => methodNames.Contains(m.Name));

            methods = query.ToArray();

            Class javaClass = type;
            foreach (var method in methods)
            {
                Member methodMember = javaClass.getMethod(method.Name, GetParametersForMethod(method));
                var functionName = method.Name.ToCamelCase();
                Scriptable methodFunction = new FunctionObject(functionName, methodMember, _scope);
                _scope.put(functionName, _scope, methodFunction);
            }
        }
开发者ID:dolittle,项目名称:Forseti,代码行数:18,代码来源:ScriptEngineContext.cs


示例9: CreateDelegate

 public Delegate CreateDelegate(object instance, EventInfo event_info, FunctionObject f, object script_delegate)
 {
     Type eventHandlerType = event_info.EventHandlerType;
     string name = event_info.Name;
     for (int i = 0; i < this.registered_event_handlers.Count; i++)
     {
         EventRec rec = this.registered_event_handlers[i] as EventRec;
         Delegate hostDelegate = rec.HostDelegate;
         if ((eventHandlerType == rec.EventHandlerType) && (name == rec.EventName))
         {
             EventRec rec2 = new EventRec();
             rec2.Sender = instance;
             rec2.EventHandlerType = eventHandlerType;
             rec2.ScriptDelegate = script_delegate;
             rec2.HostDelegate = hostDelegate;
             rec2.EventName = name;
             this.event_rec_list.Add(rec2);
             return hostDelegate;
         }
     }
     return null;
 }
开发者ID:RainsSoft,项目名称:CSLiteScript,代码行数:22,代码来源:EventDispatcher.cs


示例10: Use

 public static void Use(FunctionObject _, CommonObject that, CommonObject obj)
 {
     var configObj = that.CastTo<ConfigJsObject>();
     configObj.configBase.Use(typeof(JavaScriptApp), obj);
 }
开发者ID:kevinswiber,项目名称:NRack.Mashups,代码行数:5,代码来源:ConfigJsObject.cs


示例11: Map

 public static void Map(FunctionObject _, CommonObject that, string str, BoxedValue func)
 {
     var configObj = that.CastTo<ConfigJsObject>();
     configObj.configBase.Map(str, BuilderJsObject.MapBuilder(func.Func));
 }
开发者ID:kevinswiber,项目名称:NRack.Mashups,代码行数:5,代码来源:ConfigJsObject.cs


示例12: GroupCollapsed

 /// <summary>
 /// Creates a new inline group, indenting all following output by another level; unlike group(),
 /// this starts with the inline group collapsed, requiring the use of a disclosure button to
 /// expand it. To move back out a level, call groupEnd()
 /// </summary>
 /// <param name="ctx">The function context.</param>
 /// <param name="instance">The console object instance.</param>
 /// <param name="eventName">The name of the event.</param>
 /// <param name="eventValue">The value of the event.</param>
 internal static void GroupCollapsed(FunctionObject ctx, ScriptObject instance, BoxedValue eventValue)
 {
     ConsoleObject.SendEvent("groupCollapsed", eventValue);
 }
开发者ID:mizzunet,项目名称:spike-box,代码行数:13,代码来源:ConsoleObject.cs


示例13: Run

 public static void Run(FunctionObject _, CommonObject that, BoxedValue obj)
 {
     var configObj = that.CastTo<ConfigJsObject>();
     configObj.configBase.Run(new JavaScriptApp(obj.Object));
 }
开发者ID:kevinswiber,项目名称:NRack.Mashups,代码行数:5,代码来源:ConfigJsObject.cs


示例14: Dir

 /// <summary>
 /// Displays an interactive listing of the properties of a specified JavaScript object. This 
 /// listing lets you use disclosure triangles to examine the contents of child objects.
 /// </summary>
 /// <param name="ctx">The function context.</param>
 /// <param name="instance">The console object instance.</param>
 /// <param name="eventName">The name of the event.</param>
 /// <param name="eventValue">The value of the event.</param>
 internal static void Dir(FunctionObject ctx, ScriptObject instance, BoxedValue eventValue)
 {
     ConsoleObject.SendEvent("dir", eventValue);
 }
开发者ID:mizzunet,项目名称:spike-box,代码行数:12,代码来源:ConsoleObject.cs


示例15: FindApplicableConstructorList

 private void FindApplicableConstructorList(IntegerList a, IntegerList param_mod, ref FunctionObject best, ref IntegerList applicable_list)
 {
     for (int i = 0; i < base.Members.Count; i++) {
         MemberObject obj2 = base.Members[i];
         if ((obj2.Kind == MemberKind.Constructor) && !obj2.HasModifier(Modifier.Static)) {
             FunctionObject f = (FunctionObject)obj2;
             this.AddApplicableMethod(f, a, param_mod, 0, ref best, ref applicable_list);
         }
     }
     ClassObject ancestorClass = this.AncestorClass;
     if (!base.Imported) {
         if ((ancestorClass != null) && (best == null)) {
             ancestorClass.FindApplicableConstructorList(a, param_mod, ref best, ref applicable_list);
         }
     }
     else {
         IntegerList list = new IntegerList(false);
         foreach (ConstructorInfo info in this.ImportedType.GetConstructors()) {
             list.Add(base.Scripter.symbol_table.RegisterConstructor(info, base.Id));
         }
         if (base.Scripter.SearchProtected) {
             foreach (ConstructorInfo info2 in this.ImportedType.GetConstructors(base.Scripter.protected_binding_flags)) {
                 list.Add(base.Scripter.symbol_table.RegisterConstructor(info2, base.Id));
             }
         }
         for (int j = 0; j < list.Count; j++) {
             FunctionObject functionObject = base.Scripter.GetFunctionObject(list[j]);
             this.AddApplicableMethod(functionObject, a, param_mod, 0, ref best, ref applicable_list);
         }
         if ((ancestorClass != null) && (best == null)) {
             ancestorClass.FindApplicableConstructorList(a, param_mod, ref best, ref applicable_list);
         }
     }
 }
开发者ID:RainsSoft,项目名称:CSLiteScript,代码行数:34,代码来源:ClassObject.cs


示例16: ConstructHttp

 static CommonObject ConstructHttp(FunctionObject ctor, CommonObject _, string x)
 {
     var prototype = ctor.GetT<CommonObject>("prototype");
     return new HttpObject(x, ctor.Env, prototype);
 }
开发者ID:brooklynDev,项目名称:jibbr,代码行数:5,代码来源:BotHostModule.cs


示例17: NewEditor

 static CommonObject NewEditor(FunctionObject func, CommonObject that)
 {
     var self = that.CastTo<EditorProviderObject>();
     IEditor editor = self.provider.NewEditor();
     return new EditorObject(func.Env, self.editorPrototype, editor);
 }
开发者ID:conradz,项目名称:Edit5,代码行数:6,代码来源:EditorProviderObject.cs


示例18: FindApplicableMethodList

 private void FindApplicableMethodList(int name_index, IntegerList a, IntegerList param_mod, int res_id, ref FunctionObject best, ref IntegerList applicable_list, bool upcase)
 {
     string upcaseNameByNameIndex = base.Scripter.GetUpcaseNameByNameIndex(name_index);
     for (int i = 0; i < base.Members.Count; i++) {
         MemberObject obj2 = base.Members[i];
         if (obj2.Kind == MemberKind.Method) {
             bool flag;
             if (upcase) {
                 flag = upcaseNameByNameIndex == obj2.UpcaseName;
             }
             else {
                 flag = obj2.NameIndex == name_index;
             }
             if (flag) {
                 FunctionObject f = (FunctionObject)obj2;
                 this.AddApplicableMethod(f, a, param_mod, res_id, ref best, ref applicable_list);
             }
         }
     }
     ClassObject ancestorClass = this.AncestorClass;
     if (!base.Imported) {
         if (ancestorClass != null) {
             ancestorClass.FindApplicableMethodList(name_index, a, param_mod, res_id, ref best, ref applicable_list, upcase);
         }
     }
     else {
         string str2 = base.Scripter.names[name_index];
         IntegerList list = new IntegerList(false);
         foreach (MethodInfo info in this.ImportedType.GetMethods()) {
             if (str2 == info.Name) {
                 bool flag2 = true;
                 foreach (Attribute attribute in Attribute.GetCustomAttributes(info)) {
                     if (attribute is CSLite_ScriptForbid) {
                         flag2 = false;
                     }
                 }
                 if (flag2) {
                     int avalue = base.Scripter.symbol_table.RegisterMethod(info, base.Id);
                     list.Add(avalue);
                 }
             }
         }
         if (base.Scripter.SearchProtected) {
             foreach (MethodInfo info2 in this.ImportedType.GetMethods(base.Scripter.protected_binding_flags)) {
                 if (str2 == info2.Name) {
                     bool flag3 = true;
                     foreach (Attribute attribute2 in Attribute.GetCustomAttributes(info2)) {
                         if (attribute2 is CSLite_ScriptForbid) {
                             flag3 = false;
                         }
                     }
                     if (flag3) {
                         int num3 = base.Scripter.symbol_table.RegisterMethod(info2, base.Id);
                         list.Add(num3);
                     }
                 }
             }
         }
         for (int j = 0; j < list.Count; j++) {
             FunctionObject functionObject = base.Scripter.GetFunctionObject(list[j]);
             this.AddApplicableMethod(functionObject, a, param_mod, res_id, ref best, ref applicable_list);
         }
         if (ancestorClass != null) {
             ancestorClass.FindApplicableMethodList(name_index, a, param_mod, res_id, ref best, ref applicable_list, upcase);
         }
         for (int k = 0; k < this.AncestorIds.Count; k++) {
             ClassObject classObject = base.Scripter.GetClassObject(this.AncestorIds[k]);
             if (classObject.IsInterface) {
                 classObject.FindApplicableMethodList(name_index, a, param_mod, res_id, ref best, ref applicable_list, upcase);
             }
         }
     }
 }
开发者ID:RainsSoft,项目名称:CSLiteScript,代码行数:73,代码来源:ClassObject.cs


示例19: GetHashCode

 /// <summary>
 /// Gets the hash code reference of the channel.
 /// </summary>
 /// <param name="ctx">The function context.</param>
 /// <param name="instance">The console object instance.</param>
 /// <param name="eventName">The name of the event.</param>
 internal static BoxedValue GetHashCode(FunctionObject ctx, ScriptObject instance)
 {
     // Return the address
     return BoxedValue.Box(
         Channel.Current.GetHashCode()
         );
 }
开发者ID:mizzunet,项目名称:spike-box,代码行数:13,代码来源:RemoteObject.cs


示例20: Trigger

 static void Trigger(
     FunctionObject func, CommonObject that,
     string eventName, BoxedValue data)
 {
     EventObject self = that.CastTo<EventObject>();
     self.Trigger(eventName, data);
 }
开发者ID:conradz,项目名称:Edit5,代码行数:7,代码来源:EventObject.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# FunctionTemplate类代码示例发布时间:2022-05-24
下一篇:
C# FunctionId类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap