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


C# IokeObject.SetActivatable方法代码示例

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


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

示例1: Init

        public override void Init(IokeObject obj)
        {
            obj.Kind = "DefaultSyntax";
            obj.SetActivatable(true);

            obj.RegisterMethod(obj.runtime.NewNativeMethod("returns the name of the syntax",
                                                           new TypeCheckingNativeMethod.WithNoArguments("name", obj,
                                                                                                        (method, on, args, keywords, _context, message) => {
                                                                                                            return _context.runtime.NewText(((DefaultSyntax)IokeObject.dataOf(on)).name);
                                                                                                        })));

            obj.RegisterMethod(obj.runtime.NewNativeMethod("activates this syntax with the arguments given to call",
                                                           new NativeMethod("call", DefaultArgumentsDefinition.builder()
                                                                            .WithRestUnevaluated("arguments")
                                                                            .Arguments,
                                                                            (method, _context, message, on, outer) => {
                                                                                return Interpreter.Activate(IokeObject.As(on, _context), _context, message, _context.RealContext);
                                                                            })));

            obj.RegisterMethod(obj.runtime.NewNativeMethod("returns the result of activating this syntax without actually doing the replacement or execution part.",
                                                           new NativeMethod("expand", DefaultArgumentsDefinition.builder()
                                                                            .WithRestUnevaluated("arguments")
                                                                            .Arguments,
                                                                            (method, _context, message, on, outer) => {
                                                                                object onAsSyntax = _context.runtime.DefaultSyntax.ConvertToThis(on, message, _context);
                                                                                return ((DefaultSyntax)IokeObject.dataOf(onAsSyntax)).Expand(IokeObject.As(onAsSyntax, context), context, message, context.RealContext, null);
                                                                            })));

            obj.RegisterMethod(obj.runtime.NewNativeMethod("returns the message chain for this syntax",
                                                           new TypeCheckingNativeMethod.WithNoArguments("message", obj,
                                                                                                        (method, on, args, keywords, _context, message) => {
                                                                                                            return ((AssociatedCode)IokeObject.dataOf(on)).Code;
                                                                                                        })));

            obj.RegisterMethod(obj.runtime.NewNativeMethod("returns the code for the argument definition",
                                                           new TypeCheckingNativeMethod.WithNoArguments("argumentsCode", obj,
                                                                                                        (method, on, args, keywords, _context, message) => {
                                                                                                            return _context.runtime.NewText(((AssociatedCode)IokeObject.dataOf(on)).ArgumentsCode);
                                                                                                        })));

            obj.RegisterMethod(obj.runtime.NewNativeMethod("Returns a text inspection of the object",
                                                           new TypeCheckingNativeMethod.WithNoArguments("inspect", obj,
                                                                                                        (method, on, args, keywords, _context, message) => {
                                                                                                            return _context.runtime.NewText(DefaultSyntax.GetInspect(on));
                                                                                                        })));

            obj.RegisterMethod(obj.runtime.NewNativeMethod("Returns a brief text inspection of the object",
                                                           new TypeCheckingNativeMethod.WithNoArguments("notice", obj,
                                                                                                        (method, on, args, keywords, _context, message) => {
                                                                                                            return _context.runtime.NewText(DefaultSyntax.GetNotice(on));
                                                                                                        })));

            obj.RegisterMethod(obj.runtime.NewNativeMethod("returns the full code of this syntax, as a Text",
                                                           new TypeCheckingNativeMethod.WithNoArguments("code", obj,
                                                                                                        (method, on, args, keywords, _context, message) => {
                                                                                                            IokeData data = IokeObject.dataOf(on);
                                                                                                            if(data is DefaultSyntax) {
                                                                                                                return _context.runtime.NewText(((DefaultSyntax)data).CodeString);
                                                                                                            } else {
                                                                                                                return _context.runtime.NewText(((AliasMethod)data).CodeString);
                                                                                                            }
                                                                                                        })));

            obj.RegisterMethod(obj.runtime.NewNativeMethod("returns idiomatically formatted code for this syntax",
                                                           new TypeCheckingNativeMethod.WithNoArguments("formattedCode", obj,
                                                                                                        (method, on, args, keywords, _context, message) => {
                                                                                                            return _context.runtime.NewText(((AssociatedCode)IokeObject.dataOf(on)).FormattedCode(method));
                                                                                                        })));
        }
开发者ID:goking,项目名称:ioke,代码行数:69,代码来源:DefaultSyntax.cs

示例2: Init

        public override void Init(IokeObject obj)
        {
            obj.Kind = "DefaultMacro";
            obj.SetActivatable(true);

            obj.RegisterMethod(obj.runtime.NewNativeMethod("returns the name of the macro",
                                                           new TypeCheckingNativeMethod.WithNoArguments("name", obj,
                                                                                                        (method, on, args, keywords, _context, message) => {
                                                                                                            return _context.runtime.NewText(((DefaultMacro)IokeObject.dataOf(on)).name);
                                                                                                        })));

            obj.RegisterMethod(obj.runtime.NewNativeMethod("activates this macro with the arguments given to call",
                                                           new NativeMethod("call", DefaultArgumentsDefinition.builder()
                                                                            .WithRestUnevaluated("arguments")
                                                                            .Arguments,
                                                                            (method, _context, message, on, outer) => {
                                                                                return Interpreter.Activate(IokeObject.As(on, _context), _context, message, _context.RealContext);
                                                                            })));

            obj.RegisterMethod(obj.runtime.NewNativeMethod("returns the message chain for this macro",
                                                           new TypeCheckingNativeMethod.WithNoArguments("message", obj,
                                                                                                        (method, on, args, keywords, _context, message) => {
                                                                                                            return ((DefaultMacro)IokeObject.dataOf(on)).Code;
                                                                                                        })));

            obj.RegisterMethod(obj.runtime.NewNativeMethod("returns the code for the argument definition",
                                                           new TypeCheckingNativeMethod.WithNoArguments("argumentsCode", obj,
                                                                                                        (method, on, args, keywords, _context, message) => {
                                                                                                            return _context.runtime.NewText(((AssociatedCode)IokeObject.dataOf(on)).ArgumentsCode);
                                                                                                        })));

            obj.RegisterMethod(obj.runtime.NewNativeMethod("Returns a text inspection of the object",
                                                           new TypeCheckingNativeMethod.WithNoArguments("inspect", obj,
                                                                                                        (method, on, args, keywords, _context, message) => {
                                                                                                            return _context.runtime.NewText(DefaultMacro.GetInspect(on));
                                                                                                        })));

            obj.RegisterMethod(obj.runtime.NewNativeMethod("Returns a brief text inspection of the object",
                                                           new TypeCheckingNativeMethod.WithNoArguments("notice", obj,
                                                                                                        (method, on, args, keywords, _context, message) => {
                                                                                                            return _context.runtime.NewText(DefaultMacro.GetNotice(on));
                                                                                                        })));

            obj.RegisterMethod(obj.runtime.NewNativeMethod("returns the full code of this macro, as a Text",
                                                           new TypeCheckingNativeMethod.WithNoArguments("code", obj,
                                                                                                        (method, on, args, keywords, _context, message) => {
                                                                                                            IokeData data = IokeObject.dataOf(on);
                                                                                                            if(data is DefaultMacro) {
                                                                                                                return _context.runtime.NewText(((DefaultMacro)data).CodeString);
                                                                                                            } else {
                                                                                                                return _context.runtime.NewText(((AliasMethod)data).CodeString);
                                                                                                            }
                                                                                                        })));

            obj.RegisterMethod(obj.runtime.NewNativeMethod("returns idiomatically formatted code for this macro",
                                                           new TypeCheckingNativeMethod.WithNoArguments("formattedCode", obj,
                                                                                                        (method, on, args, keywords, _context, message) => {
                                                                                                            return _context.runtime.NewText(((AssociatedCode)IokeObject.dataOf(on)).FormattedCode(method));
                                                                                                        })));
        }
开发者ID:goking,项目名称:ioke,代码行数:60,代码来源:DefaultMacro.cs


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