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


C# IPersistentVector.count方法代码示例

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


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

示例1: GetMatchingParams

        internal static int GetMatchingParams(string methodName, List<ParameterInfo[]> parmlists, IPersistentVector argexprs, List<Type> rets)
        {
            // Assume matching lengths
            int matchIndex = -1;
            bool tied = false;
            bool foundExact = false;

            for (int i = 0; i < parmlists.Count; i++)
            {
                bool match = true;
                ISeq aseq = argexprs.seq();
                int exact = 0;
                for (int p = 0; match && p < argexprs.count() && aseq != null; ++p, aseq = aseq.next())
                {
                    Expr arg = (Expr)aseq.first();
                    Type atype = arg.HasClrType ? arg.ClrType : typeof(object);
                    Type ptype = parmlists[i][p].ParameterType;
                    if (arg.HasClrType && atype == ptype)
                        exact++;
                    else
                        match = Reflector.ParamArgTypeMatch(ptype, atype);
                }

                if (exact == argexprs.count())
                {
                    if ( !foundExact || matchIndex == -1 || rets[matchIndex].IsAssignableFrom(rets[i]))
                        matchIndex = i;
                    foundExact = true;
                }
                else if (match && !foundExact)
                {
                    if (matchIndex == -1)
                        matchIndex = i;
                    else
                    {
                        if (Reflector.Subsumes(parmlists[i], parmlists[matchIndex]))
                        {
                            matchIndex = i;
                            tied = false;
                        }
                        else if (Array.Equals(parmlists[i], parmlists[matchIndex]))
                            if (rets[matchIndex].IsAssignableFrom(rets[i]))
                                matchIndex = i;
                            else if (!Reflector.Subsumes(parmlists[matchIndex], parmlists[i]))
                                tied = true;
                    }
                }
            }

            if (tied)
                throw new ArgumentException("More than one matching method found: " + methodName);

            return matchIndex;
        }
开发者ID:jlomax,项目名称:clojure-clr,代码行数:54,代码来源:HostExpr.cs

示例2: InvokeExpr

        public InvokeExpr(string source, IPersistentMap spanMap, Symbol tag, Expr fexpr, IPersistentVector args)
        {
            _source = source;
            _spanMap = spanMap;
            _fexpr = fexpr;
            _args = args;

            VarExpr varFexpr = fexpr as VarExpr;

            if (varFexpr != null)
            {
                Var fvar = varFexpr.Var;
                Var pvar = (Var)RT.get(fvar.meta(), Compiler.ProtocolKeyword);
                if (pvar != null && Compiler.ProtocolCallsitesVar.isBound)
                {
                    _isProtocol = true;
                    _siteIndex = Compiler.RegisterProtocolCallsite(fvar);
                    Object pon = RT.get(pvar.get(), _onKey);
                    _protocolOn = HostExpr.MaybeType(pon, false);
                    if (_protocolOn != null)
                    {
                        IPersistentMap mmap = (IPersistentMap)RT.get(pvar.get(), _methodMapKey);
                        Keyword mmapVal = (Keyword)mmap.valAt(Keyword.intern(fvar.sym));
                        if (mmapVal == null)
                        {
                            throw new ArgumentException(String.Format("No method of interface: {0} found for function: {1} of protocol: {2} (The protocol method may have been defined before and removed.)",
                                _protocolOn.FullName, fvar.Symbol, pvar.Symbol));
                        }
                        String mname = Compiler.munge(mmapVal.Symbol.ToString());

                        IList<MethodBase> methods = Reflector.GetMethods(_protocolOn, mname, null, args.count() - 1,  false);
                        if (methods.Count != 1)
                            throw new ArgumentException(String.Format("No single method: {0} of interface: {1} found for function: {2} of protocol: {3}",
                                mname, _protocolOn.FullName, fvar.Symbol, pvar.Symbol));
                        _onMethod = (MethodInfo) methods[0];
                    }
                }
            }

            if (tag != null)
                _tag = tag;
            else if (varFexpr != null)
            {
                object arglists = RT.get(RT.meta(varFexpr.Var), Compiler.ArglistsKeyword);
                object sigTag = null;
                for (ISeq s = RT.seq(arglists); s != null; s = s.next())
                {
                    APersistentVector sig = (APersistentVector)s.first();
                    int restOffset = sig.IndexOf(Compiler.AmpersandSym);
                    if (args.count() == sig.count() || (restOffset > -1 && args.count() >= restOffset))
                    {
                        sigTag = Compiler.TagOf(sig);
                        break;
                    }
                }
                _tag = sigTag ?? varFexpr.Tag;
            }
            else
                _tag = null;
        }
开发者ID:EricThorsen,项目名称:clojure-clr,代码行数:60,代码来源:InvokeExpr.cs

示例3: Parse

        public static Expr Parse(ParserContext pcon, IPersistentVector form)
        {
            ParserContext pconToUse = pcon.EvEx();
            bool constant = true;

            IPersistentVector args = PersistentVector.EMPTY;
            for (int i = 0; i < form.count(); i++ )
            {
                Expr v = Compiler.Analyze(pconToUse, form.nth(i));
                args = (IPersistentVector)args.cons(v);
                if ( !(v is LiteralExpr) )
                    constant = false;
            }

            Expr ret = new VectorExpr(args);
            if ( form is IObj && ((IObj)form).meta() != null )
                return Compiler.OptionallyGenerateMetaInit(pcon,form, ret);
            else if ( constant )
            {
                IPersistentVector rv = PersistentVector.EMPTY;
                for ( int i=0; i<args.count(); i++ )
                {
                    LiteralExpr ve = (LiteralExpr)args.nth(i);
                    rv = (IPersistentVector)rv.cons(ve.Val);
                }
                return new ConstantExpr(rv);
            }
            else
                return ret;
        }
开发者ID:101v,项目名称:clojure-clr,代码行数:30,代码来源:VectorExpr.cs

示例4: Parse

        public static Expr Parse(IPersistentVector form)
        {
            IPersistentVector args = PersistentVector.EMPTY;
            for (int i = 0; i < form.count(); i++ )
                args = (IPersistentVector)args.cons(Compiler.GenerateAST(form.nth(i),false));

            Expr ret = new VectorExpr(args);
            return Compiler.OptionallyGenerateMetaInit(form, ret);
        }
开发者ID:starapor,项目名称:clojure-clr,代码行数:9,代码来源:VectorExpr.cs

示例5: InvokeExpr

        public InvokeExpr(string source, IPersistentMap spanMap, Symbol tag, Expr fexpr, IPersistentVector args)
        {
            _source = source;
            _spanMap = spanMap;
            _fexpr = fexpr;
            _args = args;

            if (fexpr is VarExpr)
            {
                Var fvar = ((VarExpr)fexpr).Var;
                Var pvar = (Var)RT.get(fvar.meta(), Compiler.PROTOCOL_KEY);
                if (pvar != null && Compiler.PROTOCOL_CALLSITES.isBound)
                {
                    _isProtocol = true;
                    _siteIndex = Compiler.RegisterProtocolCallsite(fvar);
                    Object pon = RT.get(pvar.get(), _onKey);
                    _protocolOn = HostExpr.MaybeType(pon, false);
                    if (_protocolOn != null)
                    {
                        IPersistentMap mmap = (IPersistentMap)RT.get(pvar.get(), _methodMapKey);
                        Keyword mmapVal = (Keyword)mmap.valAt(Keyword.intern(fvar.sym));
                        if (mmapVal == null)
                        {
                            throw new ArgumentException(String.Format("No method of interface: {0} found for function: {1} of protocol: {2} (The protocol method may have been defined before and removed.)",
                                _protocolOn.FullName, fvar.Symbol, pvar.Symbol));
                        }
                        String mname = Compiler.munge(mmapVal.Symbol.ToString());

                        List<MethodBase> methods = Reflector.GetMethods(_protocolOn, mname, null, args.count() - 1,  false);
                        if (methods.Count != 1)
                            throw new ArgumentException(String.Format("No single method: {0} of interface: {1} found for function: {2} of protocol: {3}",
                                mname, _protocolOn.FullName, fvar.Symbol, pvar.Symbol));
                        _onMethod = (MethodInfo) methods[0];
                    }
                }
            }

            _tag = tag ?? (fexpr is VarExpr ? ((VarExpr)fexpr).Tag : null);
        }
开发者ID:davidadsit,项目名称:clojure-clr,代码行数:39,代码来源:InvokeExpr.cs

示例6: GenerateFnClass

        private void GenerateFnClass(IPersistentVector interfaces, GenContext context)
        {
            string publicTypeName = IsDefType || (IsStatic && Compiler.IsCompiling) ? _internalName : _internalName + "__" + RT.nextID();

            //Console.WriteLine("DefFn {0}, {1}", publicTypeName, context.AssemblyBuilder.GetName().Name);

            _typeBuilder = context.AssemblyGen.DefinePublicType(publicTypeName, _baseType, true);
            for (int i = 0; i < interfaces.count(); i++)
                _typeBuilder.AddInterfaceImplementation((Type)interfaces.nth(i));

            MarkAsSerializable(_typeBuilder);

            GenInterface.SetCustomAttributes(_typeBuilder, _classMeta);

            GenerateStaticConstructor(_typeBuilder, _baseType, context.IsDebuggable);
            _ctorInfo = GenerateConstructor(_typeBuilder, _baseType);

            if (_altCtorDrops > 0)
                GenerateFieldOnlyConstructor(_typeBuilder, _baseType);

            if (SupportsMeta)
            {
                _nonmetaCtorInfo = GenerateNonMetaConstructor(_typeBuilder, _baseType);
            }
            GenerateMetaFunctions(_typeBuilder);

            //GenerateReloadVarsMethod(_typeBuilder, context);

            // The incoming context holds info on the containing function.
            // That is the one that holds the closed-over variable values.

            //GenContext newContext = CreateContext(context, _typeBuilder, _baseType);
            //GenerateMethods(newContext);
            GenerateStatics(context);
            GenerateMethods(context);
        }
开发者ID:davidadsit,项目名称:clojure-clr,代码行数:36,代码来源:ObjExpr.cs

示例7: Compile

        public Type Compile(Type superType, Type stubType, IPersistentVector interfaces, bool onetimeUse, GenContext context)
        {
            if (_compiledType != null)
                return _compiledType;

            string publicTypeName = IsDefType || (_isStatic && Compiler.IsCompiling) ? InternalName : InternalName + "__" + RT.nextID();

            _typeBuilder = context.AssemblyGen.DefinePublicType(publicTypeName, superType, true);
            context = context.WithNewDynInitHelper().WithTypeBuilder(_typeBuilder);

            Var.pushThreadBindings(RT.map(Compiler.CompilerContextVar, context));

            try
            {
                if (interfaces != null)
                {
                    for (int i = 0; i < interfaces.count(); i++)
                        _typeBuilder.AddInterfaceImplementation((Type)interfaces.nth(i));
                }

                ObjExpr.MarkAsSerializable(_typeBuilder);
                GenInterface.SetCustomAttributes(_typeBuilder, _classMeta);

                try
                {
                    if (IsDefType)
                    {
                        Compiler.RegisterDuplicateType(_typeBuilder);

                        Var.pushThreadBindings(RT.map(
                            Compiler.CompileStubOrigClassVar, stubType
                            ));
                        //,
                        //Compiler.COMPILE_STUB_CLASS, _baseType));
                    }
                    EmitConstantFieldDefs(_typeBuilder);
                    EmitKeywordCallsiteDefs(_typeBuilder);

                    DefineStaticConstructor(_typeBuilder);

                    if (SupportsMeta)
                        _metaField = _typeBuilder.DefineField("__meta", typeof(IPersistentMap), FieldAttributes.Public | FieldAttributes.InitOnly);

                    // If this IsDefType, then it has already emitted the closed-over fields on the base class.
                    if ( ! IsDefType )
                        EmitClosedOverFields(_typeBuilder);
                    EmitProtocolCallsites(_typeBuilder);

                    _ctorInfo = EmitConstructor(_typeBuilder, superType);

                    if (_altCtorDrops > 0)
                        EmitFieldOnlyConstructor(_typeBuilder, superType);

                    if (SupportsMeta)
                    {
                        EmitNonMetaConstructor(_typeBuilder, superType);
                        EmitMetaFunctions(_typeBuilder);
                    }

                    EmitStatics(_typeBuilder);
                    EmitMethods(_typeBuilder);

                    //if (KeywordCallsites.count() > 0)
                    //    EmitSwapThunk(_typeBuilder);

                    _compiledType = _typeBuilder.CreateType();

                    if (context.DynInitHelper != null)
                        context.DynInitHelper.FinalizeType();

                    _ctorInfo = GetConstructorWithArgCount(_compiledType, CtorTypes().Length);

                    return _compiledType;
                }
                finally
                {
                    if (IsDefType)
                        Var.popThreadBindings();
                }
            }
            finally
            {
                Var.popThreadBindings();
            }
        }
开发者ID:telefunkenvf14,项目名称:clojure-clr,代码行数:85,代码来源:ObjExpr.cs

示例8: EmitArgsAsArray

        internal static void EmitArgsAsArray(IPersistentVector args, ObjExpr objx, CljILGen ilg)
        {
            ilg.EmitInt(args.count());
            ilg.Emit(OpCodes.Newarr, typeof(Object));

            for (int i = 0; i < args.count(); i++)
            {
                ilg.Emit(OpCodes.Dup);
                ilg.EmitInt(i);
                ((Expr)args.nth(i)).Emit(RHC.Expression, objx, ilg);
                ilg.Emit(OpCodes.Stelem_Ref);
            }
        }
开发者ID:chrisortman,项目名称:clojure-clr,代码行数:13,代码来源:MethodExpr.cs

示例9: doEquiv

        static bool doEquiv(IPersistentVector v, object obj)
        {
            if (obj is IList || obj is IPersistentVector)
            {
                ICollection ma = (ICollection)obj;
                if (ma.Count != v.count())
                    return false;
                IEnumerator ima = ma.GetEnumerator();
                foreach (object ov in ((IList)v))
                {
                    ima.MoveNext();
                    if (!Util.equiv(ov, ima.Current))
                        return false;
                }
                return true;
            }
            else
            {
                // Example in Java of Sequential / IPersistentCollection conflation
                //if (!(obj is Sequential))
                //    return false;
                //ISeq ms = ((IPersistentCollection)obj).seq();

                ISeq ms = obj as ISeq;
                if (ms == null)
                {
                    IPersistentCollection mc = obj as IPersistentCollection;
                    if (mc == null)
                        return false;
                    ms = mc.seq();
                }

                // Once we have the ISeq, we're ready to go.

                for (int i = 0; i < v.count(); i++, ms = ms.rest())
                {
                    if (ms == null || !Util.equiv(v.nth(i), ms.first()))
                        return false;
                }
                if (ms != null)
                    return false;
            }

            return true;
        }
开发者ID:arohner,项目名称:clojure-contrib,代码行数:45,代码来源:APersistentVector.cs

示例10: GenerateVectorExpr

        private static Expression GenerateVectorExpr(IPersistentVector v)
        {
            int n = v.count();
            Expression[] args = new Expression[v.count()];
            for (int i = 0; i < n; i++)
                args[i] = Generate(v.nth(i));

            Expression arrayExpr = Expression.NewArrayInit(typeof(object), MaybeBox(args));
            Expression ret = Expression.Call(Method_RT_vector, arrayExpr);
            ret = OptionallyGenerateMetaInit(v,ret);

            return ret;
        }
开发者ID:kmartin,项目名称:clojure-contrib,代码行数:13,代码来源:Generator.cs

示例11: SeqToTypeArray

        private static Type[] SeqToTypeArray(IPersistentVector interfaces)
        {
            Type[] types = new Type[interfaces.count()];
            for (int i = 0; i < interfaces.count(); i++)
                types[i] = (Type)interfaces.nth(i);

            return types;
        }
开发者ID:christianblunden,项目名称:clojure-clr,代码行数:8,代码来源:NewInstanceExpr.cs

示例12: GetMatchingMethodAux

        private static MethodInfo GetMatchingMethodAux(Type targetType, IPersistentVector args, string methodName, bool getStatics)
        {
            MethodInfo method = null;

            List<MethodInfo> methods = HostExpr.GetMethods(targetType, args.count(), methodName, getStatics);

            if (methods.Count == 0)
                method = null;
            else
            {

                int index = 0;
                if (methods.Count > 1)
                {
                    List<ParameterInfo[]> parms = new List<ParameterInfo[]>(methods.Count);
                    List<Type> rets = new List<Type>(methods.Count);

                    foreach (MethodInfo mi in methods)
                    {
                        parms.Add(mi.GetParameters());
                        rets.Add(mi.ReturnType);
                    }
                    index = GetMatchingParams(methodName, parms, args, rets);
                }
                method = (index >= 0 ? methods[index] : null);
            }

            return method;
        }
开发者ID:jlomax,项目名称:clojure-clr,代码行数:29,代码来源:HostExpr.cs

示例13: Build

        internal static ObjExpr Build(
            IPersistentVector interfaceSyms, 
            IPersistentVector fieldSyms, 
            Symbol thisSym,
            string tagName, 
            Symbol className, 
            Symbol typeTag, 
            ISeq methodForms,
            Object frm,
            IPersistentMap opts)
        {
            NewInstanceExpr ret = new NewInstanceExpr(null);
            ret.Src = frm;
            ret.Name = className.ToString();
            ret.ClassMeta = GenInterface.ExtractAttributes(RT.meta(className));
            ret.InternalName = ret.Name;  // ret.Name.Replace('.', '/');
            // Java: ret.objtype = Type.getObjectType(ret.internalName);
            ret.Opts = opts;

            if (thisSym != null)
                ret.ThisName = thisSym.Name;

            if (fieldSyms != null)
            {
                IPersistentMap fmap = PersistentHashMap.EMPTY;
                object[] closesvec = new object[2 * fieldSyms.count()];
                for (int i = 0; i < fieldSyms.count(); i++)
                {
                    Symbol sym = (Symbol)fieldSyms.nth(i);
                    LocalBinding lb = new LocalBinding(-1, sym, null, new MethodParamExpr(Compiler.TagType(Compiler.TagOf(sym))), false, false, false);
                    fmap = fmap.assoc(sym, lb);
                    closesvec[i * 2] = lb;
                    closesvec[i * 2 + 1] = lb;
                }
                // Java TODO: inject __meta et al into closes - when?
                // use array map to preserve ctor order
                ret.Closes = new PersistentArrayMap(closesvec);
                ret.Fields = fmap;
                for (int i = fieldSyms.count() - 1; i >= 0 && (((Symbol)fieldSyms.nth(i)).Name.Equals("__meta") || ((Symbol)fieldSyms.nth(i)).Name.Equals("__extmap")); --i)
                    ret.AltCtorDrops++;
            }

            // Java TODO: set up volatiles
            //ret._volatiles = PersistentHashSet.create(RT.seq(RT.get(ret._optionsMap, volatileKey)));

            IPersistentVector interfaces = PersistentVector.EMPTY;
            for (ISeq s = RT.seq(interfaceSyms); s != null; s = s.next())
            {
                Type t = (Type)Compiler.Resolve((Symbol)s.first());
                if (!t.IsInterface)
                    throw new ParseException("only interfaces are supported, had: " + t.Name);
                interfaces = interfaces.cons(t);
            }
            Type superClass = typeof(Object);

            Dictionary<IPersistentVector, IList<MethodInfo>> overrideables;
            Dictionary<IPersistentVector, IList<MethodInfo>> explicits;
            GatherMethods(superClass, RT.seq(interfaces), out overrideables, out explicits);

            ret._methodMap = overrideables;

  
            GenContext context = Compiler.IsCompiling
                ? Compiler.CompilerContextVar.get() as GenContext
                : (ret.IsDefType
                    ? GenContext.CreateWithExternalAssembly("deftype" + RT.nextID().ToString(), ".dll", true)
                    : (Compiler.CompilerContextVar.get() as GenContext
                        ??
                        Compiler.EvalContext));

            GenContext genC = context.WithNewDynInitHelper(ret.InternalName + "__dynInitHelper_" + RT.nextID().ToString());

            Type baseClass = ret.CompileBaseClass(genC, superClass, SeqToTypeArray(interfaces), frm);
            Symbol thisTag = Symbol.intern(null, baseClass.FullName);

            try
            {
                Var.pushThreadBindings(
                    RT.mapUniqueKeys(
                        Compiler.ConstantsVar, PersistentVector.EMPTY,
                        Compiler.ConstantIdsVar, new IdentityHashMap(),
                        Compiler.KeywordsVar, PersistentHashMap.EMPTY,
                        Compiler.VarsVar, PersistentHashMap.EMPTY,
                        Compiler.KeywordCallsitesVar, PersistentVector.EMPTY,
                        Compiler.ProtocolCallsitesVar, PersistentVector.EMPTY,
                        Compiler.VarCallsitesVar, Compiler.EmptyVarCallSites(),
                        Compiler.NoRecurVar, null,
                        Compiler.CompilerContextVar, genC
                        ));

                if (ret.IsDefType)
                {
                    Var.pushThreadBindings(
                        RT.mapUniqueKeys(
                            Compiler.MethodVar, null,
                            Compiler.LocalEnvVar, ret.Fields,
                            Compiler.CompileStubSymVar, Symbol.intern(null, tagName),
                            Compiler.CompileStubClassVar, baseClass
                            ));
                    ret.HintedFields = RT.subvec(fieldSyms, 0, fieldSyms.count() - ret.AltCtorDrops);
//.........这里部分代码省略.........
开发者ID:TerabyteX,项目名称:clojure-clr,代码行数:101,代码来源:NewInstanceExpr.cs

示例14: doEquiv

        static bool doEquiv(IPersistentVector v, object obj)
        {
            if (obj is IList || obj is IPersistentVector)
            {
                ICollection ma = (ICollection)obj;
                if (ma.Count != v.count())
                    return false;
                IEnumerator ima = ma.GetEnumerator();
                foreach (object ov in ((IList)v))
                {
                    ima.MoveNext();
                    if (!Util.equiv(ov, ima.Current))
                        return false;
                }
                return true;
            }
            else
            {
                if (!(obj is Sequential))
                    return false;

                ISeq ms = RT.seq(obj);

                for (int i = 0; i < v.count(); i++, ms = ms.next())
                {
                    if (ms == null || !Util.equiv(v.nth(i), ms.first()))
                        return false;
                }
                if (ms != null)
                    return false;
            }
            return true;
        }
开发者ID:jlomax,项目名称:clojure-clr,代码行数:33,代码来源:APersistentVector.cs

示例15: doEquals

        /// <summary>
        /// Compares an <see cref="IPersistentVector">IPersistentVector</see> to another object for equality.
        /// </summary>
        /// <param name="v">The <see cref="IPersistentVector">IPersistentVector</see> to compare.</param>
        /// <param name="obj">The other object to compare.</param>
        /// <returns><value>true</value> if the specified Object is equal to the current Object; 
        /// otherwise, <value>false</value>.
        /// </returns>
        public static bool doEquals(IPersistentVector v, object obj)
        {
            if (obj is IList || obj is IPersistentVector)
            {
                IList ma = obj as IList;

                if (ma.Count != v.count() || ma.GetHashCode() != v.GetHashCode())
                    return false;

                for (int i = 0; i < v.count(); i++)
                {
                    if (!Util.equals(v.nth(i), ma[i]))
                        return false;
                }
                return true;
            }
            else
            {
                if (!(obj is Sequential))
                    return false;

                ISeq ms = RT.seq(obj);

                for (int i = 0; i < v.count(); i++, ms = ms.next())
                {
                    if (ms == null || !Util.equals(v.nth(i), ms.first()))
                        return false;
                }
                if (ms != null)
                    return false;
            }
            return true;
        }
开发者ID:jlomax,项目名称:clojure-clr,代码行数:41,代码来源:APersistentVector.cs


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