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


C# FunctionObject类代码示例

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


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


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