本文整理汇总了C#中Operations类的典型用法代码示例。如果您正苦于以下问题:C# Operations类的具体用法?C# Operations怎么用?C# Operations使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Operations类属于命名空间,在下文中一共展示了Operations类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: ExecuteTest
public void ExecuteTest(Operations operation, int innerIterations, Vector3 v1, Vector3 v2)
{
Vector3 res;
switch (operation)
{
case Operations.Add_Operator:
for (int i = 0; i < innerIterations; i++)
{ res = v1 + v2; res = v1 + v2; res = v1 + v2; res = v1 + v2; res = v1 + v2; res = v1 + v2; res = v1 + v2; res = v1 + v2; res = v1 + v2; res = v1 + v2; }
break;
case Operations.Add_Function:
for (int i = 0; i < innerIterations; i++)
{ Vector3.Add(v1, v2); Vector3.Add(v1, v2); Vector3.Add(v1, v2); Vector3.Add(v1, v2); Vector3.Add(v1, v2); Vector3.Add(v1, v2); Vector3.Add(v1, v2); Vector3.Add(v1, v2); Vector3.Add(v1, v2); Vector3.Add(v1, v2); }
break;
case Operations.Sub_Operator:
for (int i = 0; i < innerIterations; i++)
{ res = v1 - v2; res = v1 - v2; res = v1 - v2; res = v1 - v2; res = v1 - v2; res = v1 - v2; res = v1 - v2; res = v1 - v2; res = v1 - v2; res = v1 - v2; }
break;
case Operations.Sub_Function:
for (int i = 0; i < innerIterations; i++)
{ Vector3.Subtract(v1, v2); Vector3.Subtract(v1, v2); Vector3.Subtract(v1, v2); Vector3.Subtract(v1, v2); Vector3.Subtract(v1, v2); Vector3.Subtract(v1, v2); Vector3.Subtract(v1, v2); Vector3.Subtract(v1, v2); Vector3.Subtract(v1, v2); Vector3.Subtract(v1, v2); }
break;
case Operations.Mul_Operator:
for (int i = 0; i < innerIterations; i++)
{ res = v1 * v2; res = v1 * v2; res = v1 * v2; res = v1 * v2; res = v1 * v2; res = v1 * v2; res = v1 * v2; res = v1 * v2; res = v1 * v2; res = v1 * v2; }
break;
case Operations.Mul_Function:
for (int i = 0; i < innerIterations; i++)
{ Vector3.Multiply(v1, v2); Vector3.Multiply(v1, v2); Vector3.Multiply(v1, v2); Vector3.Multiply(v1, v2); Vector3.Multiply(v1, v2); Vector3.Multiply(v1, v2); Vector3.Multiply(v1, v2); Vector3.Multiply(v1, v2); Vector3.Multiply(v1, v2); Vector3.Multiply(v1, v2); }
break;
case Operations.Dot:
for (int i = 0; i < innerIterations; i++)
{ Vector3.Dot(v1, v2); Vector3.Dot(v1, v2); Vector3.Dot(v1, v2); Vector3.Dot(v1, v2); Vector3.Dot(v1, v2); Vector3.Dot(v1, v2); Vector3.Dot(v1, v2); Vector3.Dot(v1, v2); Vector3.Dot(v1, v2); Vector3.Dot(v1, v2); }
break;
case Operations.SquareRoot:
for (int i = 0; i < innerIterations; i++)
{ Vector3.SquareRoot(v1); Vector3.SquareRoot(v1); Vector3.SquareRoot(v1); Vector3.SquareRoot(v1); Vector3.SquareRoot(v1); Vector3.SquareRoot(v1); Vector3.SquareRoot(v1); Vector3.SquareRoot(v1); Vector3.SquareRoot(v1); Vector3.SquareRoot(v1); }
break;
case Operations.Length_Squared:
for (int i = 0; i < innerIterations; i++)
{ v1.LengthSquared(); v1.LengthSquared(); v1.LengthSquared(); v1.LengthSquared(); v1.LengthSquared(); v1.LengthSquared(); v1.LengthSquared(); v1.LengthSquared(); v1.LengthSquared(); v1.LengthSquared(); }
break;
case Operations.Normalize:
for (int i = 0; i < innerIterations; i++)
{ Vector3.Normalize(v1); Vector3.Normalize(v1); Vector3.Normalize(v1); Vector3.Normalize(v1); Vector3.Normalize(v1); Vector3.Normalize(v1); Vector3.Normalize(v1); Vector3.Normalize(v1); Vector3.Normalize(v1); Vector3.Normalize(v1); }
break;
case Operations.Distance_Squared:
for (int i = 0; i < innerIterations; i++)
{ Vector3.DistanceSquared(v1, v2); Vector3.DistanceSquared(v1, v2); Vector3.DistanceSquared(v1, v2); Vector3.DistanceSquared(v1, v2); Vector3.DistanceSquared(v1, v2); Vector3.DistanceSquared(v1, v2); Vector3.DistanceSquared(v1, v2); Vector3.DistanceSquared(v1, v2); Vector3.DistanceSquared(v1, v2); Vector3.DistanceSquared(v1, v2); }
break;
case Operations.Cross:
for (int i = 0; i < innerIterations; i++)
{ Vector3.Cross(v1, v2); Vector3.Cross(v1, v2); Vector3.Cross(v1, v2); Vector3.Cross(v1, v2); Vector3.Cross(v1, v2); Vector3.Cross(v1, v2); Vector3.Cross(v1, v2); Vector3.Cross(v1, v2); Vector3.Cross(v1, v2); Vector3.Cross(v1, v2); }
break;
}
}
开发者ID:noahfalk,项目名称:corefx,代码行数:55,代码来源:Perf.Vector3.cs
示例17: ParseExpression
/// <summary>
/// Parses a given expression into a graph.
/// </summary>
/// <returns>The built graph.</returns>
/// <param name="expression">The expression to create the graph from.</param>
/// <param name="initGraph">The graph to append too. Used for recursion.</param>
public Graph ParseExpression(string expression, Graph initGraph = null)
{
var lang = new Language ();
var ops = new Operations ();
expression = expression.Trim ();
var opStack = new Stack<Word>();
foreach (char letter in expression) {
//find the language mapping
var inLanguage = lang
.DefaultIfEmpty(null)
.FirstOrDefault (w => w.Letter == letter);
//find the operation mapping
var inOps = ops
.DefaultIfEmpty(null)
.FirstOrDefault(w => w.Letter == letter);
//not in the language or operators
if(inLanguage == null && inOps == null){
throw new InvalidLanguageException("Invalid input: " + letter);
}
//it is valid language input, so add it to the list.
if(inLanguage != null){
opStack.Push(inLanguage);
continue;
}
else{
//not a letter, so must be an operation
//verify that it has the correct arg count for that type of operation.
if (opStack.Count != inOps.MinArgCount && initGraph == null) {
throw new InvalidLanguageException (
string.Format(
"Unbalanced arguement count for operation (expected {0}, but got {1}.",
inOps.MinArgCount, opStack.Count
));
}
//operation, so stop, and process graph
initGraph = ProcessOperation(initGraph, inOps, opStack);
}
}
//expression was given with no operation, so error out.
if (opStack.Count > 0) {
throw new InvalidLanguageException ("No operation was specified in the given expression.");
}
//once done with graph, renumber the states.
initGraph.RenumberStates ();
//return the completed graph.
return initGraph;
}
开发者ID:tvand7093,项目名称:Xpressional,代码行数:60,代码来源:InputManager.cs
示例18: ChangeValue
private void ChangeValue(dynamic calculator, Operations operation)
{
dynamic addvalue = null;
if (CurrentVal.Text != "Write your Value:")
{
if (state.CalcEnum == CalcEnum.IntCalc)
{
addvalue = new Real<int>(int.Parse(CurrentVal.Text));
}
if (state.CalcEnum == CalcEnum.FloatCalc)
{
addvalue = new Real<double>(double.Parse(CurrentVal.Text));
}
if (state.CalcEnum == CalcEnum.ComCalc)
{
addvalue = new Complecs(CurrentVal.Text);
}
switch (operation)
{
case Operations.Add:
calculator.Add(addvalue);
break;
case Operations.Remove:
calculator.Remove(addvalue);
break;
case Operations.Divide:
calculator.Divide(addvalue);
break;
case Operations.Multiply:
calculator.Multiply(addvalue);
break;
case Operations.Clear:
calculator.Clear(addvalue);
break;
case Operations.Sqrt:
try
{
calculator.Sqrt(addvalue);
}
catch (Exception)
{
MessageBox.Show("Eror: Divide at 0");
}
break;
case Operations.Modul:
calculator.Modul(addvalue);
break;
}
}
else
{
MessageBox.Show("Write Value!!!!");
}
}
开发者ID:DevelNet,项目名称:Calculator,代码行数:54,代码来源:MainWindow.xaml.cs
示例19: OperationValidity
public bool OperationValidity(Operations operation)
{
switch(operation)
{
case Operations.GenerateChallan:
return CanGenerateChallan();
case Operations.ViewChallan:
return CanViewChallan();
}
return false;
}
开发者ID:sauravdebp,项目名称:AE-Manager,代码行数:11,代码来源:Challan.cs
示例20: GetPortraitOperation
public IOperation<Portrait> GetPortraitOperation()
{
var ops = new Operations<Portrait>();
foreach (var portraitOperation in _portraitOperations)
{
ops.Register(portraitOperation);
}
return ops;
}
开发者ID:dalinhuang,项目名称:appcollection,代码行数:11,代码来源:SearchLineFilters.cs
注:本文中的Operations类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论