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


C# Operations类代码示例

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


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

示例1: btnCalculate_Click

        private void btnCalculate_Click(object sender, RoutedEventArgs e)
        {
            Operations o = new Operations();

            if (optAdd.IsChecked == true)
            {
                double addResult = add(Convert.ToDouble(txtFirstNumber.Text), Convert.ToDouble(txtSecondNumber.Text));
                txtResult.Text = "" + addResult;
            }
            else if (optSub.IsChecked == true)
            {
                double subResult = sub(Convert.ToDouble(txtFirstNumber.Text), Convert.ToDouble(txtSecondNumber.Text));
                txtResult.Text = "" + subResult;
            }
            else if (optMult.IsChecked == true)
            {
                double multResult = mult(Convert.ToDouble(txtFirstNumber.Text), Convert.ToDouble(txtSecondNumber.Text));
                txtResult.Text = "" + multResult;
            }
            else if (optDiv.IsChecked == true)
            {
                double divResult = sub(Convert.ToDouble(txtFirstNumber.Text), Convert.ToDouble(txtSecondNumber.Text));
                txtResult.Text = "" + divResult;
            }
        }
开发者ID:VanilsonWDD,项目名称:silverlight_calculator,代码行数:25,代码来源:MainPage.xaml.cs

示例2: TestOperation

        internal static void TestOperation(double number, Operations operation)
        {
            storeResults.Clear();
            for (int i = 0; i < OperationRepeatCount; i++)
            {
                watchTime.Reset();
                watchTime.Start();
                for (int j = 0; j < LoopsCount; j++)
                {
                    switch (operation)
                    {
                        case Operations.Sqrt:
                            result = Math.Sqrt(number);
                            break;
                        case Operations.Log:
                            result = Math.Log(number);
                            break;
                        case Operations.Sin:
                            result = Math.Sin(number);
                            break;
                        default:
                            throw new InvalidOperationException("You have entered an invalid operation");
                    }
                }

                watchTime.Stop();
                storeResults.Add(watchTime.Elapsed.Milliseconds);
            }

            double averageResult = storeResults.Average();
            Console.WriteLine("Math {0} with double finished in {1} miliseconds", operation, averageResult);
        }
开发者ID:tddold,项目名称:TelerikAcademyHomework,代码行数:32,代码来源:TestMethods.cs

示例3: ValueAssignEx

		public ValueAssignEx(Text.Span span, Operations operation, VariableUse/*!*/ lvalue, Expression/*!*/ rvalue)
			: base(span)
		{
			this.lvalue = lvalue;
			this.rvalue = rvalue;
			this.operation = operation;
		}
开发者ID:dw4dev,项目名称:Phalanger,代码行数:7,代码来源:AssignEx.cs

示例4: GetOperation

        public static CalculationHandler GetOperation(Operations op)
        {
            switch (op)
            {
                case Operations.Addition:
                    return (x, y) => x + y + "";
                case Operations.Division:
                    return (x, y) =>
                    {
                        if (y.Equals(0))
                            return " Cannot divide by zero";

                        return x/y + "";
                    };
                case Operations.Multiplication:
                    return (x, y) => x*y + "";
                case Operations.Substraction:
                    return (x, y) => x - y + "";
                case Operations.Sqrt:
                    return (x, y) => Math.Sqrt(x) + "";
                case Operations.Mod:
                    return (x, y) => x%y + "";
                case Operations.Reciprocal:
                    return (x, y) =>
                    {
                        if (x.Equals(0))
                            return " Cannot divide by zero";
                        return 1/x + "";
                    };
            }
            return null;
        }
开发者ID:Dagothversur,项目名称:Calculator,代码行数:32,代码来源:CalculationManager.cs

示例5: CalculatorViewModel

        public CalculatorViewModel()
        {
            _calculator = new CalculatorSimple();
            _operation = Operations.None;

            AddCommand = new ActionCommand(Add);
            SubtractCommand = new ActionCommand(Subtract);
            MultiplyCommand = new ActionCommand(Multiply);
            DivideCommand = new ActionCommand(Divide);
            EquateCommand = new ActionCommand(Equate);

            ZeroCommand = new ActionCommand(() => InputSymbol('0'));
            OneCommand = new ActionCommand(() => InputSymbol('1'));
            TwoCommand = new ActionCommand(() => InputSymbol('2'));
            ThreeCommand = new ActionCommand(() => InputSymbol('3'));
            FourCommand = new ActionCommand(() => InputSymbol('4'));
            FiveCommand = new ActionCommand(() => InputSymbol('5'));
            SixCommand = new ActionCommand(() => InputSymbol('6'));
            SevenCommand = new ActionCommand(() => InputSymbol('7'));
            EightCommand = new ActionCommand(() => InputSymbol('8'));
            NineCommand = new ActionCommand(() => InputSymbol('9'));
            MarkCommand = new ActionCommand(() => InputSymbol(','));

            RemoveLastDigitCommand = new ActionCommand(RemoveLastDigit);
            ClearCommand = new ActionCommand(Clear);
            PlusMinusCommand = new ActionCommand(ChangeSign);
        }
开发者ID:Denver140390,项目名称:RamekCalculator,代码行数:27,代码来源:CalculatorViewModel.cs

示例6: UnaryEx

        public UnaryEx(Text.Span span, Operations operation, Expression/*!*/ expr)
			: base(span)
		{
			Debug.Assert(expr != null);
			this.operation = operation;
			this.expr = expr;
		}
开发者ID:dw4dev,项目名称:Phalanger,代码行数:7,代码来源:UnaryEx.cs

示例7: ValueAssignEx

		public ValueAssignEx(Position position, Operations operation, VariableUse/*!*/ lvalue, Expression/*!*/ rvalue)
			: base(position)
		{
			this.lvalue = lvalue;
			this.rvalue = rvalue;
			this.operation = operation;
		}
开发者ID:kripper,项目名称:Phalanger,代码行数:7,代码来源:AssignEx.cs

示例8: ImportOneUnit

        private void ImportOneUnit(MCS.Library.SOA.DataObjects.Security.SCObjectSet objectSet, Operations.IFacade exec, ImportContextWrapper wrapper, SchemaObjectBase parent, int totalSteps, AdminUnit unit)
        {
            int currentStep = 0;
            var scopes = (from m in objectSet.Membership where m.ContainerID == unit.ID && m.MemberSchemaType == AUCommon.SchemaAUAdminScope && m.Status == Schemas.SchemaProperties.SchemaObjectStatus.Normal join o in objectSet.Objects on m.ID equals o.ID where o.SchemaType == AUCommon.SchemaAUAdminScope && o.Status == Schemas.SchemaProperties.SchemaObjectStatus.Normal select (AUAdminScope)o).ToArray();
            var roles = (from m in objectSet.Membership where m.ContainerID == unit.ID && m.MemberSchemaType == AUCommon.SchemaAdminUnitRole && m.Status == Schemas.SchemaProperties.SchemaObjectStatus.Normal join o in objectSet.Objects on m.ID equals o.ID where o.SchemaType == AUCommon.SchemaAdminUnitRole && o.Status == Schemas.SchemaProperties.SchemaObjectStatus.Normal select (AURole)o).ToArray();
            try
            {
                currentStep++;
                wrapper.SetStatusAndLog(currentStep, totalSteps, "正在导入管理单元" + unit.GetQualifiedName());
                exec.AddAdminUnitWithMembers(unit, (AdminUnit)parent, roles, scopes);
                ImportRoleMembers(objectSet, exec, wrapper, totalSteps, unit, currentStep, roles);

                ImportConditions(objectSet, exec, wrapper, totalSteps, unit, currentStep, scopes);

                if (this.ImportSubUnits)
                {
                    wrapper.IncreaseLevel();
                    var subs = (from r in objectSet.Relations where r.ParentID == unit.ID && r.ChildSchemaType == AUCommon.SchemaAdminUnit && r.Status == Schemas.SchemaProperties.SchemaObjectStatus.Normal join o in objectSet.Objects on r.ID equals o.ID where o.Status == Schemas.SchemaProperties.SchemaObjectStatus.Normal && o.SchemaType == AUCommon.SchemaAdminUnit select (AdminUnit)o).ToArray();
                    int count = subs.Length;
                    foreach (AdminUnit s in subs)
                    {
                        ImportOneUnit(objectSet, exec, wrapper, unit, count, s);
                    }

                    wrapper.DecreaseLevel();
                }
            }
            catch (Exception ex)
            {
                wrapper.IncreaseError();
                wrapper.SetStatusAndLog(currentStep, totalSteps, string.Format("导入单元 {0} 失败,原因是:{1}", unit.GetQualifiedName(), ex.ToString()));
            }
        }
开发者ID:jerryshi2007,项目名称:AK47Source,代码行数:33,代码来源:AdminUnitImportAction.cs

示例9: UnaryEx

		public UnaryEx(Position position, Operations operation, Expression/*!*/ expr)
			: base(position)
		{
			Debug.Assert(expr != null);
			this.operation = operation;
			this.expr = expr;
		}
开发者ID:Ashod,项目名称:Phalanger,代码行数:7,代码来源:UnaryEx.cs

示例10: ComparePerformance

        public static void ComparePerformance(float value, Operations funcion)
        {
            var result = value;
            Stopwatch stopwatch = new Stopwatch();

            for (var j = 0; j < TestsCount; j++)
            {
                var testNumber = value;
                stopwatch.Start();

                for (var i = 0; i < RepeatFunctionsCount; i++)
                {
                    switch (funcion)
                    {
                        case Operations.Add: testNumber += anotherValue; break;
                        case Operations.Division: testNumber %= anotherValue; break;
                        case Operations.Substraction: testNumber -= anotherValue; break;
                        case Operations.Multiply: testNumber *= anotherValue; break;
                        case Operations.Increment: testNumber++; break;
                    }
                }

                stopwatch.Stop();
            }
            Console.WriteLine(value.GetType().ToString() + " time in milliseconds: " + stopwatch.Elapsed.Milliseconds / TestsCount);
        }
开发者ID:matioa,项目名称:TelerikAcademyHomeworks,代码行数:26,代码来源:SimpleMathFunctions.cs

示例11: BinaryEx

		public BinaryEx(Position position, Operations operation, Expression/*!*/ leftExpr, Expression/*!*/ rightExpr)
			: base(position)
		{
			Debug.Assert(leftExpr != null && rightExpr != null);
			this.operation = operation;
			this.leftExpr = leftExpr;
			this.rightExpr = rightExpr;
		}
开发者ID:Ashod,项目名称:Phalanger,代码行数:8,代码来源:BinaryEx.cs

示例12: Operation

 public void Operation(Operations operation)
 {
     Random rand = new Random(84329);
     Vector4 v1 = new Vector4(Convert.ToSingle(rand.NextDouble()), Convert.ToSingle(rand.NextDouble()), Convert.ToSingle(rand.NextDouble()), Convert.ToSingle(rand.NextDouble()));
     Vector4 v2 = new Vector4(Convert.ToSingle(rand.NextDouble()), Convert.ToSingle(rand.NextDouble()), Convert.ToSingle(rand.NextDouble()), Convert.ToSingle(rand.NextDouble()));
     foreach (var iteration in Benchmark.Iterations)
         using (iteration.StartMeasurement())
             ExecuteTest(operation, 1000000, v1, v2);
 }
开发者ID:ESgarbi,项目名称:corefx,代码行数:9,代码来源:Perf.Vector4.cs

示例13: OperationValidity

 public bool OperationValidity(Operations operation)
 {
     switch(operation)
     {
         case Operations.EditClient:
             return CanEditClient();
     }
     return false;
 }
开发者ID:sauravdebp,项目名称:AE-Manager,代码行数:9,代码来源:Client.cs

示例14: Run

        public static void Run(string[] args)
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            ProgramOptions options = new ProgramOptions();

            string settingPath = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "Oxel.Settings.xml");
            VoxelizationInput input = VoxelizationInput.Load(settingPath);
            if (input == null)
                input = new VoxelizationInput();

            if (args.Contains("-c"))
            {
                // Make sure user can see console output
                AttachConsole(PARENT_PROCESS_ID);

                input.Clone(options);

                if (!CommandLineParser.Parse<ProgramOptions>(args, ref options))
                    return;

                options.Clone(input);
            }
            else
            {
                CommandLineParser.Parse<VoxelizationInput>(args, ref input);
            }

            if (options.UseCommandLine)
            {
                Logger.IsCommandLine = true;

                Operations operations = new Operations();
                operations.Initialize(input);
                operations.Open(options.InputMesh, input.WindingOrder);
                WaitHandle waitHandle = operations.GenerateOccluder((VoxelizationProgress vp) => {
                    string coverage =
                        String.Format("Volume Coverage     : {0,5:0.##}%", (100 * vp.VolumeCoverage)) + "    " +
                        String.Format("Silhouette Coverage : {0,5:0.##}%", (100 * vp.SilhouetteCoverage));

                    if (!String.IsNullOrEmpty(vp.Status))
                        Console.WriteLine(vp.Status + "\r\n");

                    Console.WriteLine(coverage);
                }, new Action(() => { }));
                waitHandle.WaitOne();
                operations.Save(options.OutputMesh);
            }
            else
            {
                using (MainWindow window = new MainWindow(input))
                {
                    window.ShowDialog();
                }
            }
        }
开发者ID:kingofthebongo2008,项目名称:examples,代码行数:57,代码来源:Program.cs

示例15: DeleteController

		public DeleteController(Operations.Delete delete)
		{
			if (delete == null)
			{
				throw new ArgumentNullException(nameof(delete));
			}

			Delete = delete;
		}
开发者ID:okhosting,项目名称:OKHOSTING.ORM,代码行数:9,代码来源:DeleteController.cs


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