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


C# Operator.ToString方法代码示例

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


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

示例1: ExpressionQuery

        public static IMongoQuery ExpressionQuery(string name, Operator optor, BsonValue value)
        {
            switch (optor)
            {
                case Operator.EQ:
                    return M.Query.EQ(name, value);

                case Operator.GT:
                    return M.Query.GT(name, value);

                case Operator.GTE:
                    return M.Query.GTE(name, value);

                case Operator.ISNULL:
                    return M.Query.EQ(name, null);

                case Operator.LT:
                    return M.Query.LT(name, value);

                case Operator.LTE:
                    return M.Query.LTE(name, value);

                case Operator.NOTNULL:
                    return M.Query.NE(name, null);

                default:
                    throw new ArgumentException(String.Format("Invalid operator {0} on token parameter {1}", optor.ToString(), name));
            }
        }
开发者ID:raysearchlabs,项目名称:spark,代码行数:29,代码来源:CriteriaMongoExtensions.cs

示例2: test1

        // tests building and pretty-printing
        static void test1()
        {
            Template t = new Template();
            t.Add("a", ClassType.mark.PLUS);
            t.Add("b", ClassType.mark.MINUS);
            t.Add("c", ClassType.mark.HASH);

            Template t2 = new Template();
            t2.Add("a", ClassType.mark.PLUS);
            t2.Add("b", ClassType.mark.MINUS);
            t2.Add("c", ClassType.mark.MINUS);

            Scheme s = new Scheme();
            s.Add(t);
            s.Add(t2);

            Scheme s2 = new Scheme();

            Offering o = new Offering(1, 1);
            o.addInputScheme(1, s);
            o.addOutputScheme(1, s2);
            o.addFeedbackInputScheme(1, Scheme.SchemeAsAny());
            o.addFeedbackOutputScheme(1, Scheme.SchemeAsAny());

            Operator op = new Operator("SELECT", 1, 1);
            op.AddOffering(o);
            op.AddOffering(o);

            Console.WriteLine(op.ToString());
            Console.ReadLine();
        }
开发者ID:bdombrow,项目名称:CS-510-NiagaraST-Last-Known-Good,代码行数:32,代码来源:Program.cs

示例3: Join

 public static WhereClause Join(List<WhereClause> list, Operator oper)
 {
     WhereClause entity = new WhereClause();
     string join = string.Format(" {0} ", oper.ToString());
     if (list.Count > 0)
     {
         List<string> expr = new List<string>();
         expr.AddRange(list.Where(l => l.Expression.Length > 0).Select(l => l.Expression.ToString()));
         string str = string.Join(join, expr.ToArray());
         if (str.Length > 0)
         {
             entity.Expression.AppendFormat("( {0} )", str);
         }
     }
     return entity;
 }
开发者ID:vahtel65,项目名称:Aspect_loc,代码行数:16,代码来源:WhereClause.cs

示例4: Main

    static void Main()
    {
        Employee e1 = new Owner();
           Manager m1 = (Manager)e1;
           Boss b1 = (Boss)e1;
           Owner o1 = (Owner)e1;

           Employee e2 = new Operator();
           Operator opr2 = (Operator)e2;

           Console.WriteLine(e1.ToString()); // Owner
           Console.WriteLine(m1.ToString()); // I am a Boss
           Console.WriteLine(b1.ToString()); // I am a Boss
           Console.WriteLine(o1.ToString()); // I am a Owner

           Console.WriteLine(e2.ToString()); // I am a Operator
           Console.WriteLine(opr2.ToString()); // I am a Operator
    }
开发者ID:rcorveira,项目名称:ave-2013-14-sem1,代码行数:18,代码来源:App.cs

示例5: NumberQuery

        //No modifiers allowed on number parameters, hence not in the method signature.
        private static IMongoQuery NumberQuery(String parameterName, Operator optor, ValueExpression operand)
        {
            string typedOperand;
            try
            {
                typedOperand = ((UntypedValue)operand).AsNumberValue().ToString();
            }
            catch (InvalidCastException)
            {
                throw new ArgumentException(String.Format("Invalid number value {0} on number parameter {1}", operand, parameterName));
            }
            catch (FormatException)
            {
                throw new ArgumentException(String.Format("Invalid number value {0} on number parameter {1}", operand, parameterName));
            }

            switch (optor)
            {
                case Operator.APPROX:
                //TODO
                case Operator.CHAIN:
                //Invalid in this context
                case Operator.EQ:
                    return M.Query.EQ(parameterName, typedOperand);
                case Operator.GT:
                    return M.Query.GT(parameterName, typedOperand);
                case Operator.GTE:
                    return M.Query.GTE(parameterName, typedOperand);
                case Operator.IN:
                    IEnumerable<ValueExpression> opMultiple = ((ChoiceValue)operand).Choices;
                    return M.Query.In(parameterName, new BsonArray(opMultiple.Cast<UntypedValue>().Select(uv => uv.AsNumberValue().ToString())));
                case Operator.ISNULL:
                    return M.Query.EQ(parameterName, null);
                case Operator.LT:
                    return M.Query.LT(parameterName, typedOperand);
                case Operator.LTE:
                    return M.Query.LTE(parameterName, typedOperand);
                case Operator.NOTNULL:
                    return M.Query.NE(parameterName, null);
                default:
                    throw new ArgumentException(String.Format("Invalid operator {0} on number parameter {1}", optor.ToString(), parameterName));
            }
        }
开发者ID:Condeti,项目名称:spark,代码行数:44,代码来源:CriteriaMongoExtensions.cs

示例6: StringQuery

 private static IMongoQuery StringQuery(String parameterName, Operator optor, String modifier, ValueExpression operand)
 {
     switch (optor)
     {
         case Operator.EQ:
             var typedOperand = ((UntypedValue)operand).AsStringValue().ToString();
             switch (modifier)
             {
                 case Modifier.EXACT:
                     return M.Query.EQ(parameterName, typedOperand);
                 case Modifier.TEXT: //the same behaviour as :phonetic in previous versions.
                     return M.Query.Matches(parameterName + "soundex", "^" + typedOperand);
                 //case Modifier.BELOW:
                 //    return M.Query.Matches(parameterName, typedOperand + ".*")
                 case Modifier.NONE:
                 case null:
                     //partial from begin
                     return M.Query.Matches(parameterName, new BsonRegularExpression("^" + typedOperand, "i"));
                 default:
                     throw new ArgumentException(String.Format("Invalid modifier {0} on string parameter {1}", modifier, parameterName));
             }
         case Operator.IN: //We'll only handle choice like :exact
             IEnumerable<ValueExpression> opMultiple = ((ChoiceValue)operand).Choices;
             return M.Query.In(parameterName, new BsonArray(opMultiple.Cast<UntypedValue>().Select(uv => uv.AsStringValue().ToString())));
         case Operator.ISNULL:
             return M.Query.Or(M.Query.NotExists(parameterName), M.Query.EQ(parameterName, BsonNull.Value)); //With only M.Query.NotExists, that would exclude resources that have this field with an explicit null in it.
         case Operator.NOTNULL:
             return M.Query.NE(parameterName, BsonNull.Value); //We don't use M.Query.Exists, because that would include resources that have this field with an explicit null in it.
         default:
             throw new ArgumentException(String.Format("Invalid operator {0} on string parameter {1}", optor.ToString(), parameterName));
     }
 }
开发者ID:Condeti,项目名称:spark,代码行数:32,代码来源:CriteriaMongoExtensions.cs

示例7: TokenQuery

        private static IMongoQuery TokenQuery(String parameterName, Operator optor, String modifier, ValueExpression operand)
        {
            string systemfield = parameterName + ".system";
            string codefield = parameterName + ".code";
            string displayfield = parameterName + ".display";
            string textfield = parameterName + "_text";

            switch (optor)
            {
                case Operator.EQ:
                    var typedOperand = ((UntypedValue)operand).AsTokenValue();
                    switch (modifier)
                    {
                        case Modifier.TEXT:
                            return M.Query.Or(
                                M.Query.Matches(textfield, new BsonRegularExpression(typedOperand.Value, "i")),
                                M.Query.Matches(displayfield, new BsonRegularExpression(typedOperand.Value, "i")));

                        default:
                            if (typedOperand.AnyNamespace)
                                return M.Query.EQ(codefield, typedOperand.Value);
                            else if (String.IsNullOrWhiteSpace(typedOperand.Namespace))
                                return M.Query.ElemMatch(parameterName,
                                        M.Query.And(
                                            M.Query.NotExists("system"),
                                            M.Query.EQ("code", typedOperand.Value)
                                        ));
                            else
                                return M.Query.ElemMatch(parameterName,
                                        M.Query.And(
                                            M.Query.EQ("system", typedOperand.Namespace),
                                            M.Query.EQ("code", typedOperand.Value)
                                        ));
                    }
                case Operator.IN:
                    IEnumerable<ValueExpression> opMultiple = ((ChoiceValue)operand).Choices;
                    return M.Query.Or(opMultiple.Select(choice => TokenQuery(parameterName, Operator.EQ, modifier, choice)));
                case Operator.ISNULL:
                    return M.Query.And(M.Query.EQ(parameterName, BsonNull.Value), M.Query.EQ(textfield, BsonNull.Value)); //We don't use M.Query.NotExists, because that would exclude resources that have this field with an explicit null in it.
                case Operator.NOTNULL:
                    return M.Query.Or(M.Query.NE(parameterName, BsonNull.Value), M.Query.EQ(textfield, BsonNull.Value)); //We don't use M.Query.Exists, because that would include resources that have this field with an explicit null in it.
                default:
                    throw new ArgumentException(String.Format("Invalid operator {0} on token parameter {1}", optor.ToString(), parameterName));
            }
        }
开发者ID:TonyAbell,项目名称:spark,代码行数:45,代码来源:CriteriaMongoExtensions.cs

示例8: InsertBinaryOperationMethod

        private static void InsertBinaryOperationMethod(Core core, ProtoCore.AST.Node root, Operator op, PrimitiveType r, PrimitiveType op1, PrimitiveType op2, int retRank = 0, int op1rank = 0, int op2rank = 0)
        {
            ProtoCore.AST.AssociativeAST.FunctionDefinitionNode funcDefNode = new ProtoCore.AST.AssociativeAST.FunctionDefinitionNode();
            funcDefNode.access = ProtoCore.DSASM.AccessSpecifier.kPublic;
            funcDefNode.IsAssocOperator = true;
            funcDefNode.IsBuiltIn = true;
            funcDefNode.Name = ProtoCore.DSASM.Constants.kInternalNamePrefix + op.ToString();
            funcDefNode.ReturnType = new ProtoCore.Type() { Name = core.TypeSystem.GetType((int)r), UID = (int)r, rank = retRank, IsIndexable = (retRank > 0)};
            ProtoCore.AST.AssociativeAST.ArgumentSignatureNode args = new ProtoCore.AST.AssociativeAST.ArgumentSignatureNode();
            args.AddArgument(new ProtoCore.AST.AssociativeAST.VarDeclNode()
            {
            memregion = ProtoCore.DSASM.MemoryRegion.kMemStack,
            access = ProtoCore.DSASM.AccessSpecifier.kPublic,
            NameNode = BuildAssocIdentifier(core, ProtoCore.DSASM.Constants.kLHS),
            ArgumentType = new ProtoCore.Type { Name = core.TypeSystem.GetType((int)op1), UID = (int)op1, rank = op1rank, IsIndexable = (op1rank > 0)}
            });
            args.AddArgument(new ProtoCore.AST.AssociativeAST.VarDeclNode()
            {
            memregion = ProtoCore.DSASM.MemoryRegion.kMemStack,
            access = ProtoCore.DSASM.AccessSpecifier.kPublic,
            NameNode = BuildAssocIdentifier(core, ProtoCore.DSASM.Constants.kRHS),
            ArgumentType = new ProtoCore.Type { Name = core.TypeSystem.GetType((int)op2), UID = (int)op2, rank = op2rank, IsIndexable = (op2rank > 0)}
            });
            funcDefNode.Singnature = args;

            ProtoCore.AST.AssociativeAST.CodeBlockNode body = new ProtoCore.AST.AssociativeAST.CodeBlockNode();
            ProtoCore.AST.AssociativeAST.IdentifierNode _return = BuildAssocIdentifier(core, ProtoCore.DSDefinitions.Kw.kw_return, ProtoCore.PrimitiveType.kTypeReturn);

            ProtoCore.AST.AssociativeAST.IdentifierNode lhs = BuildAssocIdentifier(core, ProtoCore.DSASM.Constants.kLHS);
            ProtoCore.AST.AssociativeAST.IdentifierNode rhs = BuildAssocIdentifier(core, ProtoCore.DSASM.Constants.kRHS);
            body.Body.Add(new ProtoCore.AST.AssociativeAST.BinaryExpressionNode() { LeftNode = _return, Optr = ProtoCore.DSASM.Operator.assign, RightNode = new ProtoCore.AST.AssociativeAST.BinaryExpressionNode() { LeftNode = lhs, RightNode = rhs, Optr = op } });
            funcDefNode.FunctionBody = body;
            (root as ProtoCore.AST.AssociativeAST.CodeBlockNode).Body.Add(funcDefNode);
        }
开发者ID:Benglin,项目名称:designscript,代码行数:34,代码来源:CoreUtils.cs

示例9: NewOperator

 /// <summary>
 /// 新建一个客服
 /// </summary>
 /// <param name="op"></param>
 public static void NewOperator(Operator op)
 {
     Trace.WriteLine(string.Format("OperatorService.NewOperator(Operator = {0})", op.ToString()));
     if (GetOperatorById(op.OperatorId) != null)
     {
         Trace.WriteLine(string.Format("Error:OperatorService.NewOperator(Operator = {0}) error operator is aleady exsit", op.ToString()));
         return;
     }
     operators.Add(op);
     Provider.NewOperator(op);
 }
开发者ID:honj51,项目名称:ideacode,代码行数:15,代码来源:OperatorService.cs

示例10: CompositeQuery

        private static IMongoQuery CompositeQuery(ModelInfo.SearchParamDefinition parameterDef, Operator optor, String modifier, ValueExpression operand)
        {
            if (optor == Operator.IN)
            {
                var choices = ((ChoiceValue)operand);
                var queries = new List<IMongoQuery>();
                foreach (var choice in choices.Choices)
                {
                    queries.Add(CompositeQuery(parameterDef, Operator.EQ, modifier, choice));
                }
                return M.Query.Or(queries);
            }
            else if (optor == Operator.EQ)
            {
                var typedOperand = (CompositeValue)operand;
                var queries = new List<IMongoQuery>();
                var components = typedOperand.Components;
                var subParams = parameterDef.CompositeParams;

                if (components.Count() != subParams.Count())
                {
                    throw new ArgumentException(String.Format("Parameter {0} requires exactly {1} composite values, not the currently provided {2} values.", parameterDef.Name, subParams.Count(), components.Count()));
                }

                for (int i = 0; i < subParams.Count(); i++)
                {
                    var subCrit = new Criterium();
                    subCrit.Operator = Operator.EQ;
                    subCrit.ParamName = subParams[i];
                    subCrit.Operand = components[i];
                    subCrit.Modifier = modifier;
                    queries.Add(subCrit.ToFilter(parameterDef.Resource));
                }
                return M.Query.And(queries);
            }
            throw new ArgumentException(String.Format("Invalid operator {0} on composite parameter {1}", optor.ToString(), parameterDef.Name));
        }
开发者ID:Condeti,项目名称:spark,代码行数:37,代码来源:CriteriaMongoExtensions.cs

示例11: BuildExpression

        /// <summary>
        /// </summary>
        /// <param name="t">
        /// </param>
        /// <param name="o">
        /// </param>
        /// <param name="statId">
        /// </param>
        /// <param name="statValue">
        /// </param>
        /// <returns>
        /// </returns>
        /// <exception cref="NotImplementedException">
        /// </exception>
        public static Expression<Func<IInstancedEntity, bool>> BuildExpression(
            ItemTarget t, 
            Operator o, 
            int statId, 
            int statValue)
        {
            switch (o)
            {
                case Operator.GreaterThan:
                case Operator.LessThan:
                case Operator.EqualTo:
                case Operator.TestNumPets:
                case Operator.BitAnd:
                case Operator.NotBitAnd:
                case Operator.BitOr:
                case Operator.Unequal:
                    Func<int, int, bool> tmp = SwitchStatOperator((int)o).Compile();
                    Func<IInstancedEntity, IInstancedEntity> tmp2 = GetTarget(t).Compile();
                    return k => tmp.Invoke(tmp2.Invoke(k).Stats[statId].Value, statValue);
                case Operator.HasNotFormula:

                    return k => ((Character)GetTarget(t).Compile().Invoke(k)).HasNano(statValue);
                default:

                    throw new NotImplementedException("Operator " + o.ToString() + " not implemented yet.");
            }
        }
开发者ID:kittin,项目名称:CellAO-NightPredator,代码行数:41,代码来源:RequirementLambdaCreator.cs

示例12: AddOperator

        /// <summary>
        /// Overrides the default operarors associated with a property and provides a means of explicitely specifying which operators
        /// are to be supported for the property.
        /// </summary>
        /// <param name="op"><seealso cref="Operator"/> enum identifying the operator to support.</param>
        /// <returns><seealso cref="IProperty"/> to continue defining the property.</returns>
        public IProperty AddOperator(Operator op)
        {
            // Change the method by which we identify supported operators.
            if (OperatorsDefinedBy != OperatorsDefinedBy.AddOperator)
            {
                OperatorsDefinedBy = OperatorsDefinedBy.AddOperator;
                Operators.Clear();
            }

            // Verify the operator is supported by the type.
            if(!OperatorSupport.IsOperatorSupportedByType(PropertyInfo.PropertyType, op))
                throw new ArgumentException(string.Format("AddOperator called with invalid combination of property type ({0}) and operator ({1}).", PropertyInfo.PropertyType.ToString(), op.ToString()));

            // Verify the operator has not already been added.
            if (Operators.Any(p => p.OperatorType == op))
                throw new ArgumentException(string.Format("AddOperator already called for operator {0}.", op));

            // Add to the collection.
            Operators.Add(OperatorSupport.Operators[op]);

            return this;
        }
开发者ID:jhurrell,项目名称:Searchable,代码行数:28,代码来源:Property.cs

示例13: RemoveOperator

        /// <summary>
        /// Removes the specified operator from the list of those supported by the property.
        /// </summary>
        /// <param name="op"><seealso cref="Operator"/> enum identifying the operator to remove.</param>
        /// <returns><seealso cref="IProperty"/> to continue defining the property.</returns>
        public IProperty RemoveOperator(Operator op)
        {
            // Change the method by which we identify supported operators.
            if (OperatorsDefinedBy != OperatorsDefinedBy.RemoveOperator)
            {
                OperatorsDefinedBy = OperatorsDefinedBy.RemoveOperator;
            }

            // Verify the operator is supported by the type.
            if (!OperatorSupport.IsOperatorSupportedByType(PropertyInfo.PropertyType, op))
                throw new ArgumentException(string.Format("RemoveOperator called with invalid combination of property type ({0}) and operator ({1}).", PropertyInfo.PropertyType.ToString(), op.ToString()));

            // Make sure the operator has not already been removed.
            if (!Operators.Any(p => p.OperatorType == op))
                throw new ArgumentException(string.Format("RemoveOperator already called for operator {0}.", op.ToString()));

            // Remove from the collection.
            var toRemove = Operators.Where(o => o.OperatorType == op).FirstOrDefault();
            Operators.Remove(toRemove);

            return this;
        }
开发者ID:jhurrell,项目名称:Searchable,代码行数:27,代码来源:Property.cs

示例14: TokenQuery

        private static IMongoQuery TokenQuery(String parameterName, Operator optor, String modifier, ValueExpression operand)
        {
            //$elemMatch only works on array values. But the MongoIndexMapper only creates an array if there are multiple values for a given parameter.
            //So we also construct a query for when there is only one set of values in the searchIndex, hence there is no array.
            string systemfield = parameterName + ".system";
            string codefield = parameterName + ".code";
            string displayfield = parameterName + ".display";
            string textfield = parameterName + "_text";

            switch (optor)
            {
                case Operator.EQ:
                    var typedOperand = ((UntypedValue)operand).AsTokenValue();
                    switch (modifier)
                    {
                        case Modifier.TEXT:
                            return M.Query.Or(
                                M.Query.Matches(textfield, new BsonRegularExpression(typedOperand.Value, "i")),
                                M.Query.Matches(displayfield, new BsonRegularExpression(typedOperand.Value, "i")));

                        default:
                            var arrayQueries = new List<IMongoQuery>() { M.Query.EQ("code", typedOperand.Value) };
                            var noArrayQueries = new List<IMongoQuery>() { M.Query.Not(M.Query.Type(parameterName, BsonType.Array)), M.Query.EQ(codefield, typedOperand.Value) };
                            if (!typedOperand.AnyNamespace)
                            {
                                if (String.IsNullOrWhiteSpace(typedOperand.Namespace))
                                {
                                    arrayQueries.Add(M.Query.NotExists("system"));
                                    noArrayQueries.Add(M.Query.NotExists(systemfield));
                                }
                                else
                                {
                                    arrayQueries.Add(M.Query.EQ("system", typedOperand.Namespace));
                                    noArrayQueries.Add(M.Query.EQ(systemfield, typedOperand.Namespace));
                                }
                            }
                            var arrayQuery = M.Query.ElemMatch(parameterName, M.Query.And(arrayQueries));
                            var noArrayQuery = M.Query.And(noArrayQueries);
                            return M.Query.Or(arrayQuery, noArrayQuery);
                    }
                case Operator.IN:
                    IEnumerable<ValueExpression> opMultiple = ((ChoiceValue)operand).Choices;
                    return M.Query.Or(opMultiple.Select(choice => TokenQuery(parameterName, Operator.EQ, modifier, choice)));
                case Operator.ISNULL:
                    return M.Query.And(M.Query.EQ(parameterName, BsonNull.Value), M.Query.EQ(textfield, BsonNull.Value)); //We don't use M.Query.NotExists, because that would exclude resources that have this field with an explicit null in it.
                case Operator.NOTNULL:
                    return M.Query.Or(M.Query.NE(parameterName, BsonNull.Value), M.Query.EQ(textfield, BsonNull.Value)); //We don't use M.Query.Exists, because that would include resources that have this field with an explicit null in it.
                default:
                    throw new ArgumentException(String.Format("Invalid operator {0} on token parameter {1}", optor.ToString(), parameterName));
            }
        }
开发者ID:Condeti,项目名称:spark,代码行数:51,代码来源:CriteriaMongoExtensions.cs

示例15: GetOpFunction

 /// <summary>
 /// Return the internal function name for operator.
 /// </summary>
 /// <param name="op"></param>
 /// <returns></returns>
 public static string GetOpFunction(Operator op)
 {
     return Constants.kInternalNamePrefix + op.ToString();
 }
开发者ID:dimven,项目名称:Dynamo,代码行数:9,代码来源:DSasmDefs.cs


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