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


C# IFn类代码示例

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


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

示例1: tap

        public IFn tap()
        {
            if (_tap != null)
            throw new InvalidOperationException("Stream already tapped");

            return _tap = makeTap(_xform, _src);
        }
开发者ID:kmartin,项目名称:clojure-contrib,代码行数:7,代码来源:Stream.cs

示例2: Create

        public static Delegate Create(Type delegateType, IFn fn)
        {
            MethodInfo invokeMI = delegateType.GetMethod("Invoke");
            Type returnType = invokeMI.ReturnType;

            ParameterInfo[] delParams = invokeMI.GetParameters();

            List<ParameterExpression> parms = new List<ParameterExpression>();
            List<Expression> callArgs = new List<Expression>();

            foreach (ParameterInfo pi in delParams)
            {
                ParameterExpression pe = Expression.Parameter(pi.ParameterType, pi.Name);
                parms.Add(pe);
                callArgs.Add(MaybeBox(pe));
            }

            Expression call =                    
                Expression.Call(
                    Expression.Constant(fn),
                    Compiler.Methods_IFn_invoke[parms.Count], 
                    callArgs);

            Expression body =  returnType == typeof(void)
                ? (Expression)Expression.Block(call,Expression.Default(typeof(void)))
                : (Expression)Expression.Convert(call, returnType);

            LambdaExpression lambda = Expression.Lambda(delegateType, body, true, parms);

            return lambda.Compile();
        }
开发者ID:TerabyteX,项目名称:clojure-clr,代码行数:31,代码来源:GenDelegate.cs

示例3: UpdateSettings

        public void UpdateSettings(DataSource_ClojureFunction_Config sender)
        {
            minXVal = sender.MinX;
            maxXVal = sender.MaxX;
            minYVal = sender.MinY;
            maxYVal = sender.MaxY;
            precision = sender.Precision;

            clojureFunctionText1 = sender.ClojureFunction1.Trim();
            clojureFunctionText2 = sender.ClojureFunction2.Trim();

            clojureFunction1 = null;
            clojureFunction2 = null;

            if (clojureFunctionText1 != "")
            {
                try { clojureFunction1 = (IFn)ClojureEngine.EvalRaw("(fn [x y z t] " + clojureFunctionText1 + ")"); }
                catch { }
            }

            if (clojureFunctionText2 != "")
            {
                try { clojureFunction2 = (IFn)ClojureEngine.EvalRaw("(fn [x y z t] " + clojureFunctionText2 + ")"); }
                catch { }
            }
        }
开发者ID:danm36,项目名称:CLRGraph,代码行数:26,代码来源:DataSource_ClojureFunction.cs

示例4: reduce

 public object reduce(IFn f, object start)
 {
     object ret = f.invoke(start, _array[_off]);
     for (int x = _off + 1; x < _end; x++)
         ret = f.invoke(ret, _array[x]);
     return ret;
 }
开发者ID:jlomax,项目名称:clojure-clr,代码行数:7,代码来源:ArrayChunk.cs

示例5: FnSeq

 /// <summary>
 /// Initialize from given metatadata, plus first, restFn, rest.
 /// </summary>
 /// <param name="meta">The metadata to attach</param>
 /// <param name="first">The first of the sequence.</param>
 /// <param name="restFn">The function to generate the next value.</param>
 /// <param name="rest">The rest of the sequence..</param>
 FnSeq(IPersistentMap meta, object first, IFn restFn, ISeq rest)
     : base(meta)
 {
     _first = first;
     _restFn = restFn;
     _rest = rest;
 }
开发者ID:arohner,项目名称:clojure-contrib,代码行数:14,代码来源:FnSeq.cs

示例6: Future

 public Future(IFn fn)
 {
     // TODO: Use a cached thread pool when agents have one.
     _t = new Thread(new ParameterizedThreadStart(ComputeFuture));
     _t.Name = "Future";
     _t.Start(fn);
 }
开发者ID:TerabyteX,项目名称:clojure-clr,代码行数:7,代码来源:Future.cs

示例7: Iterate

 private Iterate(IPersistentMap meta, IFn f, Object prevSeed, Object seed, ISeq next)
     :base(meta)
 {
     _f = f;
     _prevSeed = prevSeed;
     _seed = seed;
     _next = next;
 }
开发者ID:TerabyteX,项目名称:clojure-clr,代码行数:8,代码来源:Iterate.cs

示例8: MultiFn

 /// Construct a multifunction.
 /// </summary>
 /// <param name="name">The name</param>
 /// <param name="dispatchFn">The dispatch function.</param>
 /// <param name="defaultDispatchVal">The default dispatch value.</param>
 /// <param name="hierarchy">The hierarchy for this multifunction</param>
 public MultiFn(string name, IFn dispatchFn, object defaultDispatchVal, IRef hierarchy)
 {
     _name = name;
     _dispatchFn = dispatchFn;
     _defaultDispatchVal = defaultDispatchVal;
     _methodTable = PersistentHashMap.EMPTY;
     _methodCache = MethodTable;
     _preferTable = PersistentHashMap.EMPTY;
     _hierarchy = hierarchy;
     _cachedHierarchy = null;
 }
开发者ID:kmartin,项目名称:clojure-contrib,代码行数:17,代码来源:MultiFn.cs

示例9: reduce

 public object reduce(IFn f, object start)
 {
     object ret = f.invoke(start, _array[_off]);
     if (RT.isReduced(ret))
         return ret;
     for (int x = _off + 1; x < _end; x++)
     {
         ret = f.invoke(ret, _array[x]);
         if (RT.isReduced(ret))
             return ((IDeref)ret).deref();
     }
     return ret;
 }
开发者ID:TerabyteX,项目名称:clojure-clr,代码行数:13,代码来源:ArrayChunk.cs

示例10: swap

 public object swap(IFn f)
 {
     for (; ; )
     {
         object v = deref();
         object newv = f.invoke(v);
         Validate(newv);
         if (_state.CompareAndSet(v, newv))
         {
             NotifyWatches(v,newv);
             return newv;
         }
     }
 }
开发者ID:TerabyteX,项目名称:clojure-clr,代码行数:14,代码来源:Atom.cs

示例11: Validate

        /// <summary>
        /// Invoke an <see cref="IFn">IFn</see> on a value to validate it.
        /// </summary>
        /// <param name="vf">The <see cref="IFn">IFn</see> to invoke.</param>
        /// <param name="val">The value to validate.</param>
        /// <remarks>Uneventful return marks a successful validation.  
        /// To indicate a failed validation, the validation function should return <value>false</value> or throw an exception.
        /// <para>This appears in multiple places.  Should find it a common home?</para></remarks>
        protected internal static void Validate(IFn vf, object val)
        {
            if (vf == null)
                return;

            bool ret = false;

            try
            {
               ret = RT.booleanCast(vf.invoke(val));
            }
            catch (Exception e)
            {
                throw new InvalidOperationException("Invalid reference state", e);
            }

            if ( ! ret )
                throw new InvalidOperationException("Invalid reference state");
        }
开发者ID:TerabyteX,项目名称:clojure-clr,代码行数:27,代码来源:ARef.cs

示例12: AddClojureDropDownBox

        public static void AddClojureDropDownBox(string labelText, Var variable, PersistentVector vals, IFn func)
        {
            string variableSymbolName = null;

            if(variable != null)
                variableSymbolName = variable.sym.Name;

            Label label = new Label();
            label.AutoSize = true;
            label.Text = labelText;

            Dictionary<string, object> labelCodeAssoc = new Dictionary<string, object>();

            ComboBox comboBox = new ComboBox();
            for (int i = 0; i < vals.Count; i += 2)
            {
                labelCodeAssoc.Add(vals[i].ToString(), vals[i + 1]);
                comboBox.Items.Add(vals[i]);
            }

            comboBox.SelectedIndex = 0;
            comboBox.DropDownStyle = ComboBoxStyle.DropDownList;
            comboBox.SelectedIndexChanged += (s, e) =>
                {
                    if (comboBox.SelectedItem == null)
                        return;

                    object code = labelCodeAssoc[comboBox.SelectedItem.ToString()];

                     if(variableSymbolName != null)
                    {
                        string newVal = code.ToString();
                        ClojureEngine.Eval("(def " + variableSymbolName + " " + newVal + ")");
                    }

                    if (func != null)
                        ClojureEngine.Log(func.invoke());
                };

            self.AddNewClojureControls(new Control[] { label, comboBox });
        }
开发者ID:danm36,项目名称:CLRGraph,代码行数:41,代码来源:ClojureDefinedUI.cs

示例13: addWatch

 public IRef addWatch(Agent watcher, IFn action, bool sendOff)
 {
     _watchers = _watchers.assoc(watcher, new object[] { action, sendOff });
      return this;
 }
开发者ID:arohner,项目名称:clojure-contrib,代码行数:5,代码来源:ARef.cs

示例14: setValidator

 /// <summary>
 /// Sets the validator.
 /// </summary>
 /// <param name="vf">The new validtor</param>
 /// <remarks>The current value must validate in order for this validator to be accepted.  If not, an exception will be thrown.</remarks>
 public virtual void setValidator(IFn vf)
 {
     Validate(vf, deref());
     _validator = vf;
 }
开发者ID:arohner,项目名称:clojure-contrib,代码行数:10,代码来源:ARef.cs

示例15: setValidator

 /// <summary>
 /// Sets the validator.
 /// </summary>
 /// <param name="vf">The new validtor</param>
 public override void setValidator(IFn vf)
 {
     if (hasRoot())
         Validate(vf, _root);
     _validator = vf;
 }
开发者ID:telefunkenvf14,项目名称:clojure-clr,代码行数:10,代码来源:Var.cs


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