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


C# Arguments.Add方法代码示例

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


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

示例1: GetArgument

 public Arguments GetArgument()
 {
     var result = new Arguments();
     if (TransportMode.HasValue)
     {
         result.Add("TransportMode", TransportMode.Value.ToTrafficDeviationInformationString());
     }
     if (!string.IsNullOrEmpty(LineNumber))
     {
         result.Add("LineNumber", LineNumber);
     }
     if (SiteId.HasValue)
     {
         result.Add("SiteId",SiteId.Value.ToString());
     }
     if (FromDate.HasValue && ToDate.HasValue)
     {
         result.Add("FromDate", FromDate.Value.ToString("yyyy-MM-dd"));
         result.Add("ToDate", ToDate.Value.ToString("yyyy-MM-dd"));
     }
     if (FromDate.HasValue ^ ToDate.HasValue)
     {
         throw new ArgumentException("if any of the parameters FromDate or ToDate is set then both must be set");
     }
     return result;
 }
开发者ID:arins,项目名称:dotNetSlApi,代码行数:26,代码来源:TrafficDeviationInformationRequest.cs

示例2: GetArguments

		protected virtual IDictionary GetArguments(MethodInfo method, object[] arguments)
		{
			var argumentMap = new Arguments();
			var parameters = method.GetParameters();
			for (int i = 0; i < parameters.Length; i++)
			{
				argumentMap.Add(parameters[i].Name, arguments[i]);
			}
			return argumentMap;
		}
开发者ID:mdavis,项目名称:Castle.InversionOfControl,代码行数:10,代码来源:DefaultTypedFactoryComponentSelector.cs

示例3: WriteJson

 public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
 {
     var items = value as IEnumerable;
     var innerValues = new Arguments();
     foreach( var item in items )
     {
         innerValues.Add(Util.ToReqlAst(item));
     }
     var makeArray = new MakeArray(innerValues, null);
     serializer.Serialize(writer, makeArray.Build());
 }
开发者ID:gitter-badger,项目名称:RethinkDb.Driver,代码行数:11,代码来源:PocoArrayConverter.cs

示例4: GetArgument

 public Arguments GetArgument()
 {
     var result = new Arguments();
     if (!string.IsNullOrEmpty(Ref))
     {
         result.Add("ref", new Argument(Ref) {UrlEncode = false});
     }
     else
     {
         throw new ArgumentException("ref can not be null or empty");
     }
     return result;
 }
开发者ID:arins,项目名称:dotNetSlApi,代码行数:13,代码来源:JourneyRequest.cs

示例5: GetArgument

        public Arguments GetArgument()
        {
            var result = new Arguments();
            if (!string.IsNullOrEmpty(SearchString))
            {
                result.Add("SearchString", SearchString);
            }
            else
            {
                throw new ArgumentException("search string can not be null or empty!");
            }

            if (StationsOnly.HasValue)
            {
                result.Add("StationsOnly", StationsOnly.Value.ToString().ToLower());
            }

            if (MaxResults.HasValue)
            {
                result.Add("MaxResults", MaxResults.Value.ToString());
            }
            return result;
        }
开发者ID:arins,项目名称:dotNetSlApi,代码行数:23,代码来源:PlaceSearchRequest.cs

示例6: CreateArguments

		protected virtual void CreateArguments (ResolveContext ec, Parameter parameter, ref Arguments args)
		{
			args = new Arguments (2);

			LambdaExpression selector = new LambdaExpression (loc);

			block.SetParameter (parameter);
			selector.Block = block;
			selector.Block.AddStatement (new ContextualReturn (expr));

			args.Add (new Argument (selector));
		}
开发者ID:alisci01,项目名称:mono,代码行数:12,代码来源:linq.cs

示例7: Emit

		public override void Emit (EmitContext ec)
		{
			if (IsBitwiseBoolean && UserOperator == null) {
				EmitBitwiseBoolean (ec);
				return;
			}

			if ((Binary.Oper & Binary.Operator.EqualityMask) != 0) {
				EmitEquality (ec);
				return;
			}

			Label is_null_label = ec.DefineLabel ();
			Label end_label = ec.DefineLabel ();

			if (ec.HasSet (BuilderContext.Options.AsyncBody) && Right.ContainsEmitWithAwait ()) {
				Left = Left.EmitToField (ec);
				Right = Right.EmitToField (ec);
			}

			if (UnwrapLeft != null) {
				UnwrapLeft.EmitCheck (ec);
			}

			//
			// Don't emit HasValue check when left and right expressions are same
			//
			if (UnwrapRight != null && !Binary.Left.Equals (Binary.Right)) {
				UnwrapRight.EmitCheck (ec);
				if (UnwrapLeft != null) {
					ec.Emit (OpCodes.And);
				}
			}

			ec.Emit (OpCodes.Brfalse, is_null_label);

			if (UserOperator != null) {
				var args = new Arguments (2);
				args.Add (new Argument (Left));
				args.Add (new Argument (Right));

				var call = new CallEmitter ();
				call.EmitPredefined (ec, UserOperator, args);
			} else {
				Binary.EmitOperator (ec, Left, Right);
			}

			//
			// Wrap the result when the operator return type is nullable type
			//
			if (type.IsNullableType)
				ec.Emit (OpCodes.Newobj, NullableInfo.GetConstructor (type));

			ec.Emit (OpCodes.Br_S, end_label);
			ec.MarkLabel (is_null_label);

			if ((Binary.Oper & Binary.Operator.ComparisonMask) != 0) {
				ec.EmitInt (0);
			} else {
				LiftedNull.Create (type, loc).Emit (ec);
			}

			ec.MarkLabel (end_label);
		}
开发者ID:Paccc,项目名称:SharpDevelop,代码行数:64,代码来源:nullable.cs

示例8: EmitEquality

		//
		// Emits optimized equality or inequality operator when possible
		//
		void EmitEquality (EmitContext ec)
		{
			//
			// Either left or right is null
			// 
			if (UnwrapLeft != null && Binary.Right.IsNull) { // TODO: Optimize for EmitBranchable
				//
				// left.HasValue == false 
				//
				UnwrapLeft.EmitCheck (ec);
				if (Binary.Oper == Binary.Operator.Equality) {
					ec.EmitInt (0);
					ec.Emit (OpCodes.Ceq);
				}
				return;
			}

			if (UnwrapRight != null && Binary.Left.IsNull) {
				//
				// right.HasValue == false 
				//
				UnwrapRight.EmitCheck (ec);
				if (Binary.Oper == Binary.Operator.Equality) {
					ec.EmitInt (0);
					ec.Emit (OpCodes.Ceq);
				}
				return;
			}

			Label dissimilar_label = ec.DefineLabel ();
			Label end_label = ec.DefineLabel ();

			if (UserOperator != null) {
				var left = Left;

				if (UnwrapLeft != null) {
					UnwrapLeft.EmitCheck (ec);
				} else {
					// Keep evaluation order same
					if (!(Left is VariableReference)) {
						Left.Emit (ec);
						var lt = new LocalTemporary (Left.Type);
						lt.Store (ec);
						left = lt;
					}
				}

				if (UnwrapRight != null) {
					UnwrapRight.EmitCheck (ec);

					if (UnwrapLeft != null) {
						ec.Emit (OpCodes.Bne_Un, dissimilar_label);

						Label compare_label = ec.DefineLabel ();
						UnwrapLeft.EmitCheck (ec);
						ec.Emit (OpCodes.Brtrue, compare_label);

						if (Binary.Oper == Binary.Operator.Equality)
							ec.EmitInt (1);
						else
							ec.EmitInt (0);

						ec.Emit (OpCodes.Br, end_label);

						ec.MarkLabel (compare_label);
					} else {
						ec.Emit (OpCodes.Brfalse, dissimilar_label);
					}
				} else {
					ec.Emit (OpCodes.Brfalse, dissimilar_label);
				}

				var args = new Arguments (2);
				args.Add (new Argument (left));
				args.Add (new Argument (Right));

				var call = new CallEmitter ();
				call.EmitPredefined (ec, UserOperator, args);
			} else {
				if (ec.HasSet (BuilderContext.Options.AsyncBody) && Binary.Right.ContainsEmitWithAwait ()) {
					Left = Left.EmitToField (ec);
					Right = Right.EmitToField (ec);
				}

				//
				// Emit underlying value comparison first.
				//
				// For this code: int? a = 1; bool b = a == 1;
				//
				// We emit something similar to this. Expressions with side effects have local
				// variable created by Unwrap expression
				//
				//	left.GetValueOrDefault ()
				//	right
				//	bne.un.s   dissimilar_label
				//  left.HasValue
				//	br.s       end_label
//.........这里部分代码省略.........
开发者ID:Paccc,项目名称:SharpDevelop,代码行数:101,代码来源:nullable.cs

示例9: CreateArguments

		protected override void CreateArguments (ResolveContext ec, out Arguments args)
		{
			base.CreateArguments (ec, out args);

			if (element_selector != null) {
				LambdaExpression lambda = new LambdaExpression (element_selector.Location);
				lambda.Block = element_block;
				lambda.Block.AddStatement (new ContextualReturn (element_selector));
				args.Add (new Argument (lambda));
			}
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:11,代码来源:linq.cs

示例10: CreateExpressionTree

		public override Expression CreateExpressionTree (ResolveContext rc)
		{
			if (UserOperator != null) {
				Arguments args = new Arguments (2);
				args.Add (new Argument (Binary.Left));
				args.Add (new Argument (Binary.Right));

				var method = new UserOperatorCall (UserOperator, args, Binary.CreateExpressionTree, loc);
				return method.CreateExpressionTree (rc);
			}

			return Binary.CreateExpressionTree (rc);
		}
开发者ID:Paccc,项目名称:SharpDevelop,代码行数:13,代码来源:nullable.cs

示例11: CreateExpressionTree

		public override Expression CreateExpressionTree (ResolveContext ec)
		{
			if (left is NullLiteral)
				ec.Report.Error (845, loc, "An expression tree cannot contain a coalescing operator with null left side");

			UserCast uc = left as UserCast;
			Expression conversion = null;
			if (uc != null) {
				left = uc.Source;

				Arguments c_args = new Arguments (2);
				c_args.Add (new Argument (uc.CreateExpressionTree (ec)));
				c_args.Add (new Argument (left.CreateExpressionTree (ec)));
				conversion = CreateExpressionFactoryCall (ec, "Lambda", c_args);
			}

			Arguments args = new Arguments (3);
			args.Add (new Argument (left.CreateExpressionTree (ec)));
			args.Add (new Argument (right.CreateExpressionTree (ec)));
			if (conversion != null)
				args.Add (new Argument (conversion));
			
			return CreateExpressionFactoryCall (ec, "Coalesce", args);
		}
开发者ID:saga,项目名称:mono,代码行数:24,代码来源:nullable.cs

示例12: GetArgument

        public Arguments GetArgument()
        {
            var result = new Arguments();
            if (Lang.HasValue)
            {
                result.Add("lang", Lang.Value.ToTripLanguageString());
            }
            if (DateTime.HasValue)
            {
                result.Add("date", DateTime.Value.Date.ToString("yyyy-MM-dd"));
                result.Add("time", DateTime.Value.ToString("HH:mm"));
            }
            if (SearchForArrival.HasValue)
            {
                result.Add("searchForArrival", SearchForArrival.Value ? "1" : "0");
            }
            if (NumberOfChanges.HasValue)
            {
                result.Add("numChg", NumberOfChanges.Value.ToString());
            }
            if (MinimumChangeTime.HasValue)
            {
                result.Add("minChgTime", MinimumChangeTime.Value.ToString());
            }
            if (!string.IsNullOrEmpty(OriginId))
            {
                result.Add("originId", OriginId);
            }

            foreach (var arg in Origin.GetArgument())
            {
                result.Add(arg.Key, arg.Value);
            }
            foreach (var arg in Destination.GetArgument())
            {
                result.Add(arg.Key, arg.Value);
            }

            if (!string.IsNullOrEmpty(DestId))
            {
                result.Add("destId", DestId);
            }
            if (ViaIds.Any())
            {
                var sb = new StringBuilder();
                var counter = 0;
                var length = ViaIds.Length;
                foreach (var viaId in ViaIds)
                {
                    sb.Append(viaId);
                    if (counter + 1 < length)
                    {
                        sb.Append(",");
                    }
                    counter++;
                }
                result.Add("viaId", sb.ToString());
            }
            if (ViaStopOver.HasValue)
            {
                result.Add("viaStopOver", ViaStopOver.Value.ToString());
            }
            if (Unsharp.HasValue)
            {
                result.Add("unsharp", Unsharp.Value ? "1" : "0");
            }

            if (SearchFirstLastTrip.HasValue)
            {
                result.Add("searchFirstLastTrip", SearchFirstLastTrip.Value ? "first" : "last");
            }

            if (MaxWalkDist.HasValue)
            {
                result.Add("maxWalkDist", MaxWalkDist.Value.ToString());

            }
            if (UseTrain.HasValue)
            {
                result.Add("useTrain", UseTrain.Value ? "1" : "0");
            }
            if (UseMetro.HasValue)
            {
                result.Add("useMetro", UseTrain.Value ? "1" : "0");
            }

            if (UseTram.HasValue)
            {
                result.Add("useTram", UseTram.Value ? "1" : "0");
            }

            if (UseBus.HasValue)
            {
                result.Add("useBus", UseTram.Value ? "1" : "0");
            }

            if (UseFerry.HasValue)
            {
                result.Add("useFerry", UseTram.Value ? "1" : "0");
            }
//.........这里部分代码省略.........
开发者ID:arins,项目名称:dotNetSlApi,代码行数:101,代码来源:TripRequest.cs

示例13: ToReqlAst

        private static ReqlAst ToReqlAst(object val, int remainingDepth, Func<object, ReqlAst> hook = null )
        {
            if( remainingDepth <= 0 )
            {
                throw new ReqlDriverCompileError("Recursion limit reached converting to ReqlAst");
            }
            if( hook != null )
            {
                var converted = hook(val);
                if( !ReferenceEquals(converted, null) )
                {
                    return converted;
                }
            }
            var ast = val as ReqlAst;
            if( !ReferenceEquals(ast, null) )
            {
                return ast;
            }

            var token = val as JToken;
            if( token != null )
            {
                return new Poco(token);
            }

            var lst = val as IList;
            if( lst != null )
            {
                Arguments innerValues = new Arguments();
                foreach( object innerValue in lst )
                {
                    innerValues.Add(ToReqlAst(innerValue, remainingDepth - 1));
                }
                return new MakeArray(innerValues, null);
            }

            var dict = val as IDictionary;
            if( dict != null )
            {
                var obj = new Dictionary<string, ReqlAst>();
                foreach( var keyObj in dict.Keys )
                {
                    var key = keyObj as string;
                    if( key == null )
                    {
                        throw new ReqlDriverCompileError("Object keys can only be strings");
                    }

                    obj[key] = ToReqlAst(dict[keyObj]);
                }
                return MakeObj.fromMap(obj);
            }

            var del = val as Delegate;
            if( del != null )
            {
                return Func.FromLambda(del);
            }

            var dt = val as DateTime?;
            if (dt != null)
            {
                return new Poco(dt);
            }
            var dto = val as DateTimeOffset?;
            if (dto != null)
            {
                return new Poco(dto);
            }

            var @int = val as int?;
            if( @int != null )
            {
                return new Datum(@int);
            }

            if( IsNumber(val) )
            {
                return new Datum(val);
            }

            var @bool = val as bool?;
            if( @bool != null )
            {
                return new Datum(@bool);
            }

            var str = val as string;
            if( str != null )
            {
                return new Datum(str);
            }
            if( val == null )
            {
                return new Datum(null);
            }

            return new Poco(val);
        }
开发者ID:fjsnogueira,项目名称:RethinkDb.Driver,代码行数:100,代码来源:Util.cs

示例14: ToReqlAst

        //TODO: don't use "is" for performance
		private static ReqlAst ToReqlAst(object val, int remainingDepth)
		{
			if (val is ReqlAst)
			{
				return (ReqlAst) val;
			}

			if (val is IList)
			{
				Arguments innerValues = new Arguments();
				foreach (object innerValue in (IList) val)
				{
					innerValues.Add(ToReqlAst(innerValue, remainingDepth - 1));
				}
				return new MakeArray(innerValues, null);
			}

			if (val is IDictionary)
			{
				var obj = new Dictionary<string, ReqlAst>();
				foreach (var entry in val as IDictionary<string, object>)
				{
					if (!(entry.Key is string))
					{
						throw new ReqlError("Object key can only be strings");
					}

					obj[(string) entry.Key] = ToReqlAst(entry.Value);
				}
				return MakeObj.FromMap(obj);
			}

			if (val is ReqlLambda)
			{
			    return Func.FromLambda((ReqlLambda)val);
			}
			
			if (val is DateTime)
			{
			    var dt = (DateTime)val;
			    var isoStr = dt.ToUniversalTime().ToString("o");
				return Iso8601.FromString(isoStr);
			}

			if (val is int?)
			{
				return new Datum((int?) val);
			}
			if (IsNumber(val))
			{
				return new Datum(val);
			}
			if (val is bool?)
			{
				return new Datum((bool?) val);
			}
			if (val is string)
			{
				return new Datum((string) val);
			}
		    if( val == null )
		    {
		        return new Datum(null);
		    }

			throw new ReqlDriverError($"Can't convert {val} to a ReqlAst");
		}
开发者ID:cadabloom,项目名称:RethinkDb.Driver,代码行数:68,代码来源:Util.cs

示例15: ToReqlAst

        private static ReqlAst ToReqlAst(object val, int remainingDepth)
        {
            if( remainingDepth <= 0 )
            {
                throw new ReqlDriverCompileError("Recursion limit reached converting to ReqlAst");
            }
            var ast = val as ReqlAst;
            if( ast != null )
            {
                return ast;
            }

            var lst = val as IList;
            if( lst != null )
            {
                Arguments innerValues = new Arguments();
                foreach( object innerValue in lst )
                {
                    innerValues.Add(ToReqlAst(innerValue, remainingDepth - 1));
                }
                return new MakeArray(innerValues, null);
            }

            var dict = val as IDictionary;
            if( dict != null )
            {
                var obj = new Dictionary<string, ReqlAst>();
                foreach( var keyObj in dict.Keys )
                {
                    var key = keyObj as string;
                    if( key == null )
                    {
                        throw new ReqlDriverCompileError("Object keys can only be strings");
                    }

                    obj[key] = ToReqlAst(dict[keyObj]);
                }
                return MakeObj.fromMap(obj);
            }

            var del = val as Delegate;
            if( del != null )
            {
                return Func.FromLambda(del);
            }


            if( val is DateTime )
            {
                var dt = (DateTime)val;
                var isoStr = dt.ToString("o");
                return Iso8601.FromString(isoStr);
            }
            if( val is DateTimeOffset )
            {
                var dt = (DateTimeOffset)val;
                var isoStr = dt.ToString("o");
                return Iso8601.FromString(isoStr);
            }


            var @int = val as int?;
            if( @int != null )
            {
                return new Datum(@int);
            }

            if( IsNumber(val) )
            {
                return new Datum(val);
            }

            var @bool = val as bool?;
            if( @bool != null )
            {
                return new Datum(@bool);
            }

            var str = val as string;
            if( str != null )
            {
                return new Datum(str);
            }
            if( val == null )
            {
                return new Datum(null);
            }

            return new Poco(val);
        }
开发者ID:fiLLLip,项目名称:RethinkDb.Driver,代码行数:90,代码来源:Util.cs


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