コード例 #1
0
        public Arguments MapArguments(Model.Arguments arguments)
        {
            var mapping = new Arguments();
            foreach (var argument in arguments)
                mapping.Add(argument.Key, argument.Value);

            return mapping;
        }
コード例 #2
0
ファイル: tripDestination.cs プロジェクト: arins/dotNetSlApi
        public Arguments GetArgument()
        {
            var result = new Arguments();
            var prePend = IsOrigin ? "origin" : "dest";
            if (CoordLat.HasValue)
            {
                result.Add(prePend + "CoordLat", CoordLat.Value.ToString());
            }

            if (CoordLong.HasValue)
            {
                result.Add(prePend + "CoordLong", CoordLong.Value.ToString());
            }
            if (!string.IsNullOrEmpty(CoordName))
            {
                result.Add(prePend + "CoordName", CoordName);
            }
            return result;
        }
コード例 #3
0
 public Arguments GetArgument()
 {
     var result = new Arguments
     {
         {"originCoordLat", OriginCoordLat.ToString()},
         {"originCoordLong", OriginCoordLong.ToString()}
     };
     if (MaxResults.HasValue)
     {
         result.Add("maxResults", MaxResults.Value.ToString());
     }
     if (Radius.HasValue)
     {
         result.Add("radius", Radius.Value.ToString());
     }
     if (Lang.HasValue)
     {
         result.Add("lang", Lang.Value.ToNearbyStationsRequestString());
     }
     return result;
 }
コード例 #4
0
        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);
        }
コード例 #5
0
 public DotnetRestoreCommand(ITestOutputHelper log, params string[] args) : base(log)
 {
     Arguments.Add("restore");
     Arguments.AddRange(args);
 }
コード例 #6
0
 public FFMpegArgumentOptions WithArgument(IArgument argument)
 {
     Arguments.Add(argument);
     return(this);
 }
コード例 #7
0
 /// <summary>
 /// Инициализирует новую команду.
 /// </summary>
 /// <param name="arcAddress">SC-адрес дуги у которой необходимо получить начальный и конечный элемент</param>
 public GetArcElementsCommand(ScAddress arcAddress)
     : base(CommandCode.GetArc)
 {
     Arguments.Add(this.arcAddress = arcAddress);
 }
コード例 #8
0
ファイル: Vote.cs プロジェクト: Ysovuka/DhtNet
 public Vote(NodeId id, NodeId target, byte vote)
     : base(id, _voteKey, _responseCreator)
 {
     Arguments.Add(_targetKey, target.BencodedString());
     Arguments.Add(_voteKey, new BEncodedNumber(vote));
 }
コード例 #9
0
ファイル: ScanScript.cs プロジェクト: martinmthomas/antidote
 public ScanScript(ScriptOptions scriptOptions, string sampleName, string ipAddress, string scannerName)
     : base(scriptOptions, sampleName)
 {
     Arguments.Add("IpAddress", ipAddress);
     Arguments.Add("ScannerName", scannerName);
 }
コード例 #10
0
ファイル: DotnetToolCommand.cs プロジェクト: vitek-karas/sdk
 public DotnetToolCommand(ITestOutputHelper log, params string[] args) : base(log)
 {
     Arguments.Add("tool");
     Arguments.AddRange(args);
 }
コード例 #11
0
 internal void AddArgument(string argName, object type, bool isArray, bool required, ExpressionResult defaultValue)
 {
     Arguments.Add(new GraphQlOperationArgument(argName, type, isArray, required, defaultValue));
 }
コード例 #12
0
ファイル: Distinct.cs プロジェクト: webJose/wj.AgnosticSql
 /// <summary>
 /// Creeates a new instance of this class.
 /// </summary>
 /// <param name="expr">Expression to be filtered out of repetitions.</param>
 public Distinct(IExpression expr)
     : base()
 {
     Guard.IsNotNull(expr, nameof(expr));
     Arguments.Add(expr);
 }
コード例 #13
0
ファイル: nullable.cs プロジェクト: 0xd4d/NRefactory
		//
		// 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
				// dissimilar_label:
				//	ldc.i4.0
				// end_label:
				//

				Left.Emit (ec);
				Right.Emit (ec);

				ec.Emit (OpCodes.Bne_Un_S, dissimilar_label);

				//
				// Check both left and right expressions for Unwrap call in which
				// case we need to run get_HasValue() check because the type is
				// nullable and could have null value
				//
				if (UnwrapLeft != null)
					UnwrapLeft.EmitCheck (ec);

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

				if (UnwrapLeft != null && UnwrapRight != null) {
					if (Binary.Oper == Binary.Operator.Inequality)
						ec.Emit (OpCodes.Xor);
					else
						ec.Emit (OpCodes.Ceq);
				} else {
					if (Binary.Oper == Binary.Operator.Inequality) {
						ec.EmitInt (0);
						ec.Emit (OpCodes.Ceq);
					}
				}
			}

			ec.Emit (OpCodes.Br_S, end_label);

			ec.MarkLabel (dissimilar_label);
			if (Binary.Oper == Binary.Operator.Inequality)
				ec.EmitInt (1);
			else
				ec.EmitInt (0);

			ec.MarkLabel (end_label);
		}
コード例 #14
0
ファイル: nullable.cs プロジェクト: 0xd4d/NRefactory
		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);
		}
コード例 #15
0
 public void Add(string arg)
 {
     Args.Add(arg);
 }
コード例 #16
0
 /// <summary>
 /// Инициализирует новую команду.
 /// </summary>
 /// <param name="type">тип события</param>
 /// <param name="address">SC-адрес</param>
 public CreateSubscriptionCommand(EventType type, ScAddress address)
     : base(CommandCode.CreateSubscription)
 {
     Arguments.Add(new EventTypeArgument(this.type = type));
     Arguments.Add(this.address = address);
 }
コード例 #17
0
 /// <summary>
 /// Инициализирует новую команду.
 /// </summary>
 /// <param name="id">событие</param>
 public DeleteSubscriptionCommand(SubscriptionId id)
     : base(CommandCode.DeleteSubscription)
 {
     Arguments.Add(subscriptionId = id);
 }
コード例 #18
0
ファイル: nullable.cs プロジェクト: 0xd4d/NRefactory
		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);
		}
コード例 #19
0
        /// <summary>
        /// Updates the <see cref="ProcessStartInfo" /> of the specified
        /// <see cref="Process"/>.
        /// </summary>
        /// <param name="process">The <see cref="Process" /> of which the <see cref="ProcessStartInfo" /> should be updated.</param>
        protected override void PrepareProcess(Process process)
        {
            if (!SupportsAssemblyReferences)
            {
                // create instance of Copy task
                CopyTask ct = new CopyTask();

                // inherit project from current task
                ct.Project = Project;

                // inherit namespace manager from current task
                ct.NamespaceManager = NamespaceManager;

                // parent is current task
                ct.Parent = this;

                // inherit verbose setting from license task
                ct.Verbose = Verbose;

                // only output warning messages or higher, unless we're running
                // in verbose mode
                if (!ct.Verbose)
                {
                    ct.Threshold = Level.Warning;
                }

                // make sure framework specific information is set
                ct.InitializeTaskConfiguration();

                // set parent of child elements
                ct.CopyFileSet.Parent = ct;

                // inherit project from solution task for child elements
                ct.CopyFileSet.Project = ct.Project;

                // inherit namespace manager from solution task
                ct.CopyFileSet.NamespaceManager = ct.NamespaceManager;

                // set base directory of fileset
                ct.CopyFileSet.BaseDirectory = Assemblies.BaseDirectory;

                // copy all files to base directory itself
                ct.Flatten = true;

                // copy referenced assemblies
                foreach (string file in Assemblies.FileNames)
                {
                    ct.CopyFileSet.Includes.Add(file);
                }

                // copy command line tool to working directory
                ct.CopyFileSet.Includes.Add(base.ProgramFileName);

                // set destination directory
                ct.ToDirectory = BaseDirectory;

                // increment indentation level
                ct.Project.Indent();
                try {
                    // execute task
                    ct.Execute();
                } finally {
                    // restore indentation level
                    ct.Project.Unindent();
                }

                // change program to execute the tool in working directory as
                // that will allow this tool to resolve assembly references
                // using assemblies stored in the same directory
                _programFileName = Path.Combine(BaseDirectory.FullName,
                                                Path.GetFileName(base.ProgramFileName));

                // determine target directory
                string targetDir = Path.GetDirectoryName(Path.Combine(
                                                             BaseDirectory.FullName, Target));
                // ensure target directory exists
                if (!StringUtils.IsNullOrEmpty(targetDir) && !Directory.Exists(targetDir))
                {
                    Directory.CreateDirectory(targetDir);
                }
            }
            else
            {
                foreach (string assembly in Assemblies.FileNames)
                {
                    Arguments.Add(new Argument(string.Format(CultureInfo.InvariantCulture,
                                                             "/i:\"{0}\"", assembly)));
                }
            }

            // further delegate preparation to base class
            base.PrepareProcess(process);
        }
コード例 #20
0
ファイル: CSCACommand.cs プロジェクト: mirror222/qi4net
 public CscaCommand()
 {
     Arguments.Add("?");
 }
コード例 #21
0
        /// <summary>
        /// Generates the license file.
        /// </summary>
        protected override void ExecuteTask()
        {
            FileInfo licensesFile = null;

            // ensure base directory is set, even if fileset was not initialized
            // from XML
            if (Assemblies.BaseDirectory == null)
            {
                Assemblies.BaseDirectory = new DirectoryInfo(Project.BaseDirectory);
            }

            // get the output .licenses file
            if (OutputFile == null)
            {
                try {
                    licensesFile = new FileInfo(Project.GetFullPath(Target + ".licenses"));
                } catch (Exception ex) {
                    throw new BuildException(string.Format(CultureInfo.InvariantCulture,
                                                           ResourceUtils.GetString("NA2015"), Target), Location, ex);
                }
            }
            else
            {
                licensesFile = OutputFile;
            }

            // make sure the directory for the .licenses file exists
            if (!licensesFile.Directory.Exists)
            {
                licensesFile.Directory.Create();
            }

            // determine whether .licenses file need to be recompiled
            if (!NeedsCompiling(licensesFile))
            {
                return;
            }

            Log(Level.Verbose, ResourceUtils.GetString("String_CompilingLicenseUsingTarget"),
                InputFile.FullName, licensesFile.FullName, Target);

            if (HasCommandLineCompiler)
            {
                // the command line compiler does not allow us to specify the
                // full path to the output file, so we have it create the licenses
                // file in a temp directory, and copy it to its actual output
                // location

                // use a newly created temporary directory as working directory
                BaseDirectory = FileUtils.GetTempDirectory();

                try {
                    // set target assembly for generated licenses file
                    Arguments.Add(new Argument(string.Format(CultureInfo.InvariantCulture,
                                                             "/target:\"{0}\"", Target)));
                    // set input filename
                    Arguments.Add(new Argument(string.Format(CultureInfo.InvariantCulture,
                                                             "/complist:\"{0}\"", InputFile.FullName)));
                    // set output directory
                    Arguments.Add(new Argument(string.Format(CultureInfo.InvariantCulture,
                                                             "/outdir:\"{0}\"", BaseDirectory.FullName)));
                    // suppress display of startup banner
                    Arguments.Add(new Argument("/nologo"));
                    // adjust verbosity of tool if necessary
                    if (Verbose)
                    {
                        Arguments.Add(new Argument("/v"));
                    }
                    // use command line tool to compile licenses file
                    base.ExecuteTask();

                    // delete any existing output file
                    if (File.Exists(licensesFile.FullName))
                    {
                        File.Delete(licensesFile.FullName);
                    }

                    // copy licenses file to output file (with overwrite)
                    File.Copy(Path.Combine(BaseDirectory.FullName, Target + ".licenses"),
                              licensesFile.FullName, true);
                } finally {
                    // delete temporary directory and all files in it
                    DeleteTask deleteTask = new DeleteTask();
                    deleteTask.Project = Project;
                    deleteTask.Parent  = this;
                    deleteTask.InitializeTaskConfiguration();
                    deleteTask.Directory = BaseDirectory;
                    deleteTask.Threshold = Level.None; // no output in build log
                    deleteTask.Execute();
                }
            }
            else
            {
                // create new domain
                AppDomain newDomain = AppDomain.CreateDomain("LicenseGatheringDomain",
                                                             AppDomain.CurrentDomain.Evidence);

                LicenseGatherer licenseGatherer = (LicenseGatherer)
                                                  newDomain.CreateInstanceAndUnwrap(typeof(LicenseGatherer).Assembly.FullName,
                                                                                    typeof(LicenseGatherer).FullName, false, BindingFlags.Public | BindingFlags.Instance,
                                                                                    null, new object[0], CultureInfo.InvariantCulture, new object[0],
                                                                                    AppDomain.CurrentDomain.Evidence);
                licenseGatherer.CreateLicenseFile(this, licensesFile.FullName);

                // unload newly created domain
                AppDomain.Unload(newDomain);
            }
        }
コード例 #22
0
        /// <summary>
        /// Build up the command line arguments, determine which executable is being
        ///     used and find the path to that executable and set the working
        ///     directory.
        /// </summary>
        /// <param name="process">The process to prepare.</param>
        protected override void PrepareProcess(Process process)
        {
            // Although a global property can be set, take the property closest
            //  to the task execution, which is the attribute on the task itself.
            if (!_isUseSharpCvsLibSet &&
                (null == Properties || null == Properties[UseSharpCvsLibProp]))
            {
                // if not set and the global property is null then use the default
                _useSharpCvsLib = UseSharpCvsLib;
            }
            else if (!_isUseSharpCvsLibSet &&
                     null != Properties[UseSharpCvsLibProp])
            {
                try {
                    _useSharpCvsLib =
                        System.Convert.ToBoolean(Properties[UseSharpCvsLibProp]);
                } catch (Exception) {
                    throw new BuildException(UseSharpCvsLib + " must be convertable to a boolean.");
                }
            }

            Logger.Debug("number of arguments: " + Arguments.Count);

            // if set, pass cvsroot to command line tool
            if (Root != null)
            {
                Arguments.Add(new Argument(string.Format(CultureInfo.InvariantCulture,
                                                         "-d{0}", Root)));
            }

            if (this.UseSharpCvsLib)
            {
                Managed = ManagedExecution.Auto;
            }

            // Set verbose logging on the #cvslib client if used.
            if (this.UseSharpCvsLib && this.Verbose)
            {
                SetGlobalOption("verbose", String.Format("-verbose"), true);
            }

            AppendGlobalOptions();
            Arguments.Add(new Argument(CommandName));

            AppendCommandOptions();

            Log(Level.Debug, "Commandline args are null: {0}",
                ((null == CommandLineArguments) ? "yes" : "no"));
            Log(Level.Debug, "Commandline: {0}", CommandLineArguments);
            if (null != CommandLineArguments)
            {
                Arguments.Add(new Argument(CommandLineArguments));
            }

            AppendSubCommandArgs();
            AppendFiles();

            if (IsModuleNeeded && null == Module)
            {
                throw new BuildException(string.Format(CultureInfo.InvariantCulture,
                                                       "Cvs module is required for this action."),
                                         Location);
            }
            if (IsModuleNeeded)
            {
                Arguments.Add(new Argument(Module));
            }

            if (!Directory.Exists(DestinationDirectory.FullName))
            {
                Directory.CreateDirectory(DestinationDirectory.FullName);
            }
            base.PrepareProcess(process);
            process.StartInfo.FileName = ExeName;

            process.StartInfo.WorkingDirectory = DestinationDirectory.FullName;

            Log(Level.Verbose, "Working directory: {0}", process.StartInfo.WorkingDirectory);
            Log(Level.Verbose, "Executable: {0}", process.StartInfo.FileName);
            Log(Level.Verbose, "Arguments: {0}", process.StartInfo.Arguments);
        }
コード例 #23
0
 /// <summary>
 /// Инициализирует новую команду.
 /// </summary>
 /// <param name="identifier">идентификатор</param>
 public FindElementCommand(Identifier identifier)
     : base(CommandCode.FindElement)
 {
     Arguments.Add(this.identifier = identifier);
 }
コード例 #24
0
 private void AddArgumentExecute() => Arguments.Add(default(ArgumentTypeViewModel));
コード例 #25
0
 /// <summary>
 /// Instantiates the endpoints which allows to see if this IP is secured.
 /// </summary>
 /// <param name="token">A valid user token.</param>
 public SecureIP(string accessToken)
 {
     Address = new Uri("https://api.mojang.com/user/security/location");
     Arguments.Add(accessToken);
 }
コード例 #26
0
 public DotnetCommand(ITestOutputHelper log, string commandName, params string[] args) : base(log)
 {
     Arguments.Add(commandName);
     Arguments.AddRange(args);
     this.commandName = commandName;
 }
コード例 #27
0
 /// <summary>
 /// Refreshes the access token. Must be the same instance as authenticate.
 /// </summary>
 public Refresh(string accessToken)
 {
     Address = new Uri($"https://authserver.mojang.com/refresh");
     Arguments.Add(accessToken);
 }
コード例 #28
0
        //
        // Emits optimized equality or inequality operator when possible
        //
        private 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
                // dissimilar_label:
                //	ldc.i4.0
                // end_label:
                //

                Left.Emit(ec);
                Right.Emit(ec);

                ec.Emit(OpCodes.Bne_Un_S, dissimilar_label);

                //
                // Check both left and right expressions for Unwrap call in which
                // case we need to run get_HasValue() check because the type is
                // nullable and could have null value
                //
                if (UnwrapLeft != null)
                {
                    UnwrapLeft.EmitCheck(ec);
                }

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

                if (UnwrapLeft != null && UnwrapRight != null)
                {
                    if (Binary.Oper == Binary.Operator.Inequality)
                    {
                        ec.Emit(OpCodes.Xor);
                    }
                    else
                    {
                        ec.Emit(OpCodes.Ceq);
                    }
                }
                else
                {
                    if (Binary.Oper == Binary.Operator.Inequality)
                    {
                        ec.EmitInt(0);
                        ec.Emit(OpCodes.Ceq);
                    }
                }
            }

            ec.Emit(OpCodes.Br_S, end_label);

            ec.MarkLabel(dissimilar_label);
            if (Binary.Oper == Binary.Operator.Inequality)
            {
                ec.EmitInt(1);
            }
            else
            {
                ec.EmitInt(0);
            }

            ec.MarkLabel(end_label);
        }
コード例 #29
0
 /// <summary>
 /// Refreshes the access token. Must be the same instance as authenticate.
 /// </summary>
 public Signout(Credentials credentials)
 {
     Address = new Uri($"https://authserver.mojang.com/signout");
     Arguments.Add(credentials.Username);
     Arguments.Add(credentials.Password);
 }
コード例 #30
0
 public AnalysisScript(ScriptOptions scriptOptions, string fileName) : base(scriptOptions, fileName)
 {
     Arguments.Add("SampleFileName", fileName);
 }
コード例 #31
0
 /// <summary>
 /// Refreshes the access token. Must be the same instance as authenticate.
 /// </summary>
 public Invalidate(string accessToken)
 {
     Address = new Uri($"https://authserver.mojang.com/invalidate");
     Arguments.Add(accessToken);
 }
コード例 #32
0
 public void AddArgument(string argumentName, string argumentValue)
 {
     Arguments.Add(argumentName, argumentValue);
 }
コード例 #33
0
 /// <summary>
 /// Sends a request of authentication
 /// </summary>
 public Authenticate(Credentials credentials)
 {
     Address = new Uri($"https://authserver.mojang.com/authenticate");
     Arguments.Add(credentials.Username);
     Arguments.Add(credentials.Password);
 }
コード例 #34
0
ファイル: CmgsCommand.cs プロジェクト: mirror222/qi4net
 public CmgsCommand()
 {
     Arguments.Add("");
 }
コード例 #35
0
 public DotnetNewCommand WithoutBuiltInTemplates()
 {
     Arguments.Add("--debug:disable-sdk-templates");
     return(this);
 }
コード例 #36
0
 public DotnetNewCommand Quietly()
 {
     Arguments.Add("--quiet");
     return(this);
 }
コード例 #37
0
ファイル: nullable.cs プロジェクト: 0xd4d/NRefactory
		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);
		}