本文整理汇总了C#中Operation.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# Operation.GetType方法的具体用法?C# Operation.GetType怎么用?C# Operation.GetType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Operation
的用法示例。
在下文中一共展示了Operation.GetType方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Optimize
public Operation Optimize(Operation operation, IFunctionRegistry functionRegistry)
{
if (!operation.DependsOnVariables && operation.GetType() != typeof(IntegerConstant)
&& operation.GetType() != typeof(FloatingPointConstant))
{
double result = executor.Execute(operation, functionRegistry);
return new FloatingPointConstant(result);
}
else
{
if (operation.GetType() == typeof(Addition))
{
Addition addition = (Addition)operation;
addition.Argument1 = Optimize(addition.Argument1, functionRegistry);
addition.Argument2 = Optimize(addition.Argument2, functionRegistry);
}
else if (operation.GetType() == typeof(Subtraction))
{
Subtraction substraction = (Subtraction)operation;
substraction.Argument1 = Optimize(substraction.Argument1, functionRegistry);
substraction.Argument2 = Optimize(substraction.Argument2, functionRegistry);
}
else if (operation.GetType() == typeof(Multiplication))
{
Multiplication multiplication = (Multiplication)operation;
multiplication.Argument1 = Optimize(multiplication.Argument1, functionRegistry);
multiplication.Argument2 = Optimize(multiplication.Argument2, functionRegistry);
}
else if (operation.GetType() == typeof(Division))
{
Division division = (Division)operation;
division.Dividend = Optimize(division.Dividend, functionRegistry);
division.Divisor = Optimize(division.Divisor, functionRegistry);
}
else if (operation.GetType() == typeof(Exponentiation))
{
Exponentiation division = (Exponentiation)operation;
division.Base = Optimize(division.Base, functionRegistry);
division.Exponent = Optimize(division.Exponent, functionRegistry);
}
return operation;
}
}
示例2: GenerateMethodBody
private void GenerateMethodBody(ILGenerator generator, Operation operation)
{
if (operation == null)
throw new ArgumentNullException("operation");
if (operation.GetType() == typeof(IntegerConstant))
{
IntegerConstant constant = (IntegerConstant)operation;
generator.Emit(OpCodes.Ldc_I4, constant.Value);
generator.Emit(OpCodes.Conv_R8);
}
else if (operation.GetType() == typeof(FloatingPointConstant))
{
FloatingPointConstant constant = (FloatingPointConstant)operation;
generator.Emit(OpCodes.Ldc_R8, constant.Value);
}
else if (operation.GetType() == typeof(Variable))
{
Type dictionaryType = typeof(Dictionary<string, double>);
Variable variable = (Variable)operation;
Label throwExceptionLabel = generator.DefineLabel();
Label returnLabel = generator.DefineLabel();
generator.Emit(OpCodes.Ldarg_0);
generator.Emit(OpCodes.Ldstr, variable.Name);
generator.Emit(OpCodes.Callvirt, dictionaryType.GetMethod("ContainsKey", new Type[] { typeof(string) }));
generator.Emit(OpCodes.Ldc_I4_0);
generator.Emit(OpCodes.Ceq);
generator.Emit(OpCodes.Brtrue_S, throwExceptionLabel);
generator.Emit(OpCodes.Ldarg_0);
generator.Emit(OpCodes.Ldstr, variable.Name);
generator.Emit(OpCodes.Callvirt, dictionaryType.GetMethod("get_Item", new Type[] { typeof(string) }));
generator.Emit(OpCodes.Br_S, returnLabel);
generator.MarkLabel(throwExceptionLabel);
generator.Emit(OpCodes.Ldstr, string.Format("The variable \"{0}\" used is not defined.", variable.Name));
generator.Emit(OpCodes.Newobj, typeof(VariableNotDefinedException).GetConstructor(new Type[] { typeof(string) }));
generator.Emit(OpCodes.Throw);
generator.MarkLabel(returnLabel);
}
else if (operation.GetType() == typeof(Multiplication))
{
Multiplication multiplication = (Multiplication)operation;
GenerateMethodBody(generator, multiplication.Argument1);
GenerateMethodBody(generator, multiplication.Argument2);
generator.Emit(OpCodes.Mul);
}
else if (operation.GetType() == typeof(Addition))
{
Addition addition = (Addition)operation;
GenerateMethodBody(generator, addition.Argument1);
GenerateMethodBody(generator, addition.Argument2);
generator.Emit(OpCodes.Add);
}
else if (operation.GetType() == typeof(Substraction))
{
Substraction addition = (Substraction)operation;
GenerateMethodBody(generator, addition.Argument1);
GenerateMethodBody(generator, addition.Argument2);
generator.Emit(OpCodes.Sub);
}
else if (operation.GetType() == typeof(Division))
{
Division division = (Division)operation;
GenerateMethodBody(generator, division.Dividend);
GenerateMethodBody(generator, division.Divisor);
generator.Emit(OpCodes.Div);
}
else if (operation.GetType() == typeof(Exponentiation))
{
Exponentiation exponentation = (Exponentiation)operation;
GenerateMethodBody(generator, exponentation.Base);
GenerateMethodBody(generator, exponentation.Exponent);
generator.Emit(OpCodes.Call, typeof(Math).GetMethod("Pow"));
}
else if (operation.GetType() == typeof(Function))
{
Function function = (Function)operation;
switch (function.FunctionType)
{
case FunctionType.Sine:
GenerateMethodBody(generator, function.Arguments[0]);
generator.Emit(OpCodes.Call, typeof(Math).GetMethod("Sin"));
break;
case FunctionType.Cosine:
GenerateMethodBody(generator, function.Arguments[0]);
//.........这里部分代码省略.........
示例3: GenerateMethodBody
private void GenerateMethodBody(ILGenerator generator, Operation operation,
IFunctionRegistry functionRegistry)
{
if (operation == null)
throw new ArgumentNullException("operation");
if (operation.GetType() == typeof(IntegerConstant))
{
IntegerConstant constant = (IntegerConstant)operation;
generator.Emit(OpCodes.Ldc_I4, constant.Value);
generator.Emit(OpCodes.Conv_R8);
}
else if (operation.GetType() == typeof(FloatingPointConstant))
{
FloatingPointConstant constant = (FloatingPointConstant)operation;
generator.Emit(OpCodes.Ldc_R8, constant.Value);
}
else if (operation.GetType() == typeof(Variable))
{
Type dictionaryType = typeof(Dictionary<string, double>);
Variable variable = (Variable)operation;
Label throwExceptionLabel = generator.DefineLabel();
Label returnLabel = generator.DefineLabel();
generator.Emit(OpCodes.Ldarg_0);
generator.Emit(OpCodes.Callvirt, typeof(FormulaContext).GetProperty("Variables").GetGetMethod());
generator.Emit(OpCodes.Ldstr, variable.Name);
generator.Emit(OpCodes.Callvirt, dictionaryType.GetMethod("ContainsKey", new Type[] { typeof(string) }));
generator.Emit(OpCodes.Ldc_I4_0);
generator.Emit(OpCodes.Ceq);
generator.Emit(OpCodes.Brtrue_S, throwExceptionLabel);
generator.Emit(OpCodes.Ldarg_0);
generator.Emit(OpCodes.Callvirt, typeof(FormulaContext).GetProperty("Variables").GetGetMethod());
generator.Emit(OpCodes.Ldstr, variable.Name);
generator.Emit(OpCodes.Callvirt, dictionaryType.GetMethod("get_Item", new Type[] { typeof(string) }));
generator.Emit(OpCodes.Br_S, returnLabel);
generator.MarkLabel(throwExceptionLabel);
generator.Emit(OpCodes.Ldstr, string.Format("The variable \"{0}\" used is not defined.", variable.Name));
generator.Emit(OpCodes.Newobj, typeof(VariableNotDefinedException).GetConstructor(new Type[] { typeof(string) }));
generator.Emit(OpCodes.Throw);
generator.MarkLabel(returnLabel);
}
else if (operation.GetType() == typeof(Multiplication))
{
Multiplication multiplication = (Multiplication)operation;
GenerateMethodBody(generator, multiplication.Argument1, functionRegistry);
GenerateMethodBody(generator, multiplication.Argument2, functionRegistry);
generator.Emit(OpCodes.Mul);
}
else if (operation.GetType() == typeof(Addition))
{
Addition addition = (Addition)operation;
GenerateMethodBody(generator, addition.Argument1, functionRegistry);
GenerateMethodBody(generator, addition.Argument2, functionRegistry);
generator.Emit(OpCodes.Add);
}
else if (operation.GetType() == typeof(Subtraction))
{
Subtraction addition = (Subtraction)operation;
GenerateMethodBody(generator, addition.Argument1, functionRegistry);
GenerateMethodBody(generator, addition.Argument2, functionRegistry);
generator.Emit(OpCodes.Sub);
}
else if (operation.GetType() == typeof(Division))
{
Division division = (Division)operation;
GenerateMethodBody(generator, division.Dividend, functionRegistry);
GenerateMethodBody(generator, division.Divisor, functionRegistry);
generator.Emit(OpCodes.Div);
}
else if (operation.GetType() == typeof(Modulo))
{
Modulo modulo = (Modulo)operation;
GenerateMethodBody(generator, modulo.Dividend, functionRegistry);
GenerateMethodBody(generator, modulo.Divisor, functionRegistry);
generator.Emit(OpCodes.Rem);
}
else if (operation.GetType() == typeof(Exponentiation))
{
Exponentiation exponentation = (Exponentiation)operation;
GenerateMethodBody(generator, exponentation.Base, functionRegistry);
GenerateMethodBody(generator, exponentation.Exponent, functionRegistry);
generator.Emit(OpCodes.Call, typeof(Math).GetMethod("Pow"));
}
else if (operation.GetType() == typeof(UnaryMinus))
{
UnaryMinus unaryMinus = (UnaryMinus)operation;
//.........这里部分代码省略.........
示例4: Execute
public double Execute(Operation operation, Dictionary<string, double> variables)
{
if (operation == null)
throw new ArgumentNullException("operation");
if (operation.GetType() == typeof(IntegerConstant))
{
IntegerConstant constant = (IntegerConstant)operation;
return constant.Value;
}
else if (operation.GetType() == typeof(FloatingPointConstant))
{
FloatingPointConstant constant = (FloatingPointConstant)operation;
return constant.Value;
}
else if (operation.GetType() == typeof(Variable))
{
Variable variable = (Variable)operation;
if (variables.ContainsKey(variable.Name))
return variables[variable.Name];
else
throw new VariableNotDefinedException(string.Format("The variable \"{0}\" used is not defined.", variable.Name));
}
else if (operation.GetType() == typeof(Multiplication))
{
Multiplication multiplication = (Multiplication)operation;
return Execute(multiplication.Argument1, variables) * Execute(multiplication.Argument2, variables);
}
else if (operation.GetType() == typeof(Addition))
{
Addition addition = (Addition)operation;
return Execute(addition.Argument1, variables) + Execute(addition.Argument2, variables);
}
else if (operation.GetType() == typeof(Substraction))
{
Substraction addition = (Substraction)operation;
return Execute(addition.Argument1, variables) - Execute(addition.Argument2, variables);
}
else if (operation.GetType() == typeof(Division))
{
Division division = (Division)operation;
return Execute(division.Dividend, variables) / Execute(division.Divisor, variables);
}
else if (operation.GetType() == typeof(Exponentiation))
{
Exponentiation exponentiation = (Exponentiation)operation;
return Math.Pow(Execute(exponentiation.Base, variables), Execute(exponentiation.Exponent, variables));
}
else if (operation.GetType() == typeof(Function))
{
Function function = (Function)operation;
switch (function.FunctionType)
{
case FunctionType.Sine:
return Math.Sin(Execute(function.Arguments[0], variables));
case FunctionType.Cosine:
return Math.Cos(Execute(function.Arguments[0], variables));
case FunctionType.Loge:
return Math.Log(Execute(function.Arguments[0], variables));
case FunctionType.Log10:
return Math.Log10(Execute(function.Arguments[0], variables));
case FunctionType.Logn:
return Math.Log(Execute(function.Arguments[0], variables), Execute(function.Arguments[1], variables));
default:
throw new ArgumentException(string.Format("Unsupported function \"{0}\".", function.FunctionType), "operation");
}
}
else
{
throw new ArgumentException(string.Format("Unsupported operation \"{0}\".", operation.GetType().FullName), "operation");
}
}
示例5: Update
private bool Update(Operation requestedOperation, Operation originalOperation, Operation newOperation)
{
bool updated = false;
// timestamps!!
Type t = requestedOperation.GetType();
foreach (PropertyInfo pi in t.GetProperties())
{
object serverValue = pi.GetValue(requestedOperation, null);
object origValue = pi.GetValue(originalOperation, null);
object newValue = pi.GetValue(newOperation, null);
// if the value has changed, process further
if (!Object.Equals(origValue, newValue))
{
// if the server has the original value, make the update
if (Object.Equals(serverValue, origValue))
{
pi.SetValue(requestedOperation, newValue, null);
updated = true;
}
}
}
return updated;
}
示例6: Execute
public double Execute(Operation operation, IFunctionRegistry functionRegistry,
Dictionary<string, double> variables)
{
if (operation == null)
throw new ArgumentNullException("operation");
if (operation.GetType() == typeof(IntegerConstant))
{
IntegerConstant constant = (IntegerConstant)operation;
return constant.Value;
}
else if (operation.GetType() == typeof(FloatingPointConstant))
{
FloatingPointConstant constant = (FloatingPointConstant)operation;
return constant.Value;
}
else if (operation.GetType() == typeof(Variable))
{
Variable variable = (Variable)operation;
if (variables.ContainsKey(variable.Name))
return variables[variable.Name];
else
throw new VariableNotDefinedException(string.Format("The variable \"{0}\" used is not defined.", variable.Name));
}
else if (operation.GetType() == typeof(Multiplication))
{
Multiplication multiplication = (Multiplication)operation;
return Execute(multiplication.Argument1, functionRegistry, variables) * Execute(multiplication.Argument2, functionRegistry, variables);
}
else if (operation.GetType() == typeof(Addition))
{
Addition addition = (Addition)operation;
return Execute(addition.Argument1, functionRegistry, variables) + Execute(addition.Argument2, functionRegistry, variables);
}
else if (operation.GetType() == typeof(Subtraction))
{
Subtraction addition = (Subtraction)operation;
return Execute(addition.Argument1, functionRegistry, variables) - Execute(addition.Argument2, functionRegistry, variables);
}
else if (operation.GetType() == typeof(Division))
{
Division division = (Division)operation;
return Execute(division.Dividend, functionRegistry, variables) / Execute(division.Divisor, functionRegistry, variables);
}
else if (operation.GetType() == typeof(Modulo))
{
Modulo division = (Modulo)operation;
return Execute(division.Dividend, functionRegistry, variables) % Execute(division.Divisor, functionRegistry, variables);
}
else if (operation.GetType() == typeof(Exponentiation))
{
Exponentiation exponentiation = (Exponentiation)operation;
return Math.Pow(Execute(exponentiation.Base, functionRegistry, variables), Execute(exponentiation.Exponent, functionRegistry, variables));
}
else if (operation.GetType() == typeof(UnaryMinus))
{
UnaryMinus unaryMinus = (UnaryMinus)operation;
return -Execute(unaryMinus.Argument, functionRegistry, variables);
}
else if (operation.GetType() == typeof(Function))
{
Function function = (Function)operation;
FunctionInfo functionInfo = functionRegistry.GetFunctionInfo(function.FunctionName);
double[] arguments = new double[functionInfo.NumberOfParameters];
for (int i = 0; i < arguments.Length; i++)
arguments[i] = Execute(function.Arguments[i], functionRegistry, variables);
return Invoke(functionInfo.Function, arguments);
}
else
{
throw new ArgumentException(string.Format("Unsupported operation \"{0}\".", operation.GetType().FullName), "operation");
}
}
示例7: CreateTreeViewItem
private TreeViewItem CreateTreeViewItem(Operation operation)
{
TreeViewItem item = new TreeViewItem();
item.Header = GetLabelText(operation);
if (operation.GetType() == typeof(Multiplication))
{
Multiplication multiplication = (Multiplication)operation;
item.Items.Add(CreateTreeViewItem(multiplication.Argument1));
item.Items.Add(CreateTreeViewItem(multiplication.Argument2));
}
else if (operation.GetType() == typeof(Addition))
{
Addition addition = (Addition)operation;
item.Items.Add(CreateTreeViewItem(addition.Argument1));
item.Items.Add(CreateTreeViewItem(addition.Argument2));
}
else if (operation.GetType() == typeof(Substraction))
{
Substraction addition = (Substraction)operation;
item.Items.Add(CreateTreeViewItem(addition.Argument1));
item.Items.Add(CreateTreeViewItem(addition.Argument2));
}
else if (operation.GetType() == typeof(Division))
{
Division division = (Division)operation;
item.Items.Add(CreateTreeViewItem(division.Dividend));
item.Items.Add(CreateTreeViewItem(division.Divisor));
}
else if (operation.GetType() == typeof(Exponentiation))
{
Exponentiation exponentiation = (Exponentiation)operation;
item.Items.Add(CreateTreeViewItem(exponentiation.Base));
item.Items.Add(CreateTreeViewItem(exponentiation.Exponent));
}
else if (operation.GetType() == typeof(Function))
{
Function function = (Function)operation;
foreach (Operation argument in function.Arguments)
item.Items.Add(CreateTreeViewItem(argument));
}
return item;
}
示例8: GetVariables
private void GetVariables(Operation operation, List<Variable> variables)
{
if (operation.DependsOnVariables)
{
if (operation.GetType() == typeof(Variable))
{
variables.Add((Variable)operation);
}
else if (operation.GetType() == typeof(Addition))
{
Addition addition = (Addition)operation;
GetVariables(addition.Argument1, variables);
GetVariables(addition.Argument2, variables);
}
else if (operation.GetType() == typeof(Multiplication))
{
Multiplication multiplication = (Multiplication)operation;
GetVariables(multiplication.Argument1, variables);
GetVariables(multiplication.Argument2, variables);
}
else if (operation.GetType() == typeof(Substraction))
{
Substraction substraction = (Substraction)operation;
GetVariables(substraction.Argument1, variables);
GetVariables(substraction.Argument2, variables);
}
else if (operation.GetType() == typeof(Division))
{
Division division = (Division)operation;
GetVariables(division.Dividend, variables);
GetVariables(division.Divisor, variables);
}
else if (operation.GetType() == typeof(Exponentiation))
{
Exponentiation exponentiation = (Exponentiation)operation;
GetVariables(exponentiation.Base, variables);
GetVariables(exponentiation.Exponent, variables);
}
else if (operation.GetType() == typeof(Function))
{
Function function = (Function)operation;
foreach (Operation argument in function.Arguments)
{
GetVariables(argument, variables);
}
}
}
}
示例9: GetLabelText
private string GetLabelText(Operation operation)
{
Type operationType = operation.GetType();
string name = operationType.Name;
string dataType = "" + operation.DataType;
string value = "";
IntegerConstant integerConstant = operation as IntegerConstant;
if (integerConstant != null)
{
value = "(" + integerConstant.Value + ")";
}
else
{
FloatingPointConstant floatingPointConstant = operation as FloatingPointConstant;
if (floatingPointConstant != null)
{
value = "(" + floatingPointConstant.Value + ")";
}
else
{
Variable variable = operation as Variable;
if (variable != null)
{
value = "(" + variable.Name + ")";
}
else
{
Function function = operation as Function;
if (function != null)
{
value = "(" + function.FunctionType + ")";
}
}
}
}
return string.Format(CultureInfo.InvariantCulture, "{0}<{1}>{2}", name, dataType, value);
}
示例10: Write74_Operation
private void Write74_Operation(string n, string ns, Operation o, bool isNullable, bool needType)
{
if (o == null)
{
if (isNullable)
{
base.WriteNullTagLiteral(n, ns);
}
}
else
{
if (!needType && !(o.GetType() == typeof(Operation)))
{
throw base.CreateUnknownTypeException(o);
}
base.WriteStartElement(n, ns, o, false, o.Namespaces);
if (needType)
{
base.WriteXsiType("Operation", "http://schemas.xmlsoap.org/wsdl/");
}
XmlAttribute[] extensibleAttributes = o.ExtensibleAttributes;
if (extensibleAttributes != null)
{
for (int i = 0; i < extensibleAttributes.Length; i++)
{
XmlAttribute node = extensibleAttributes[i];
base.WriteXmlAttribute(node, o);
}
}
base.WriteAttribute("name", "", o.Name);
if ((o.ParameterOrderString != null) && (o.ParameterOrderString.Length != 0))
{
base.WriteAttribute("parameterOrder", "", o.ParameterOrderString);
}
if ((o.DocumentationElement == null) && (o.DocumentationElement != null))
{
throw base.CreateInvalidAnyTypeException(o.DocumentationElement);
}
base.WriteElementLiteral(o.DocumentationElement, "documentation", "http://schemas.xmlsoap.org/wsdl/", false, true);
ServiceDescriptionFormatExtensionCollection extensions = o.Extensions;
if (extensions != null)
{
for (int j = 0; j < extensions.Count; j++)
{
if (!(extensions[j] is XmlNode) && (extensions[j] != null))
{
throw base.CreateInvalidAnyTypeException(extensions[j]);
}
base.WriteElementLiteral((XmlNode) extensions[j], "", null, false, true);
}
}
OperationMessageCollection messages = o.Messages;
if (messages != null)
{
for (int k = 0; k < messages.Count; k++)
{
OperationMessage message = messages[k];
if (message is OperationOutput)
{
this.Write72_OperationOutput("output", "http://schemas.xmlsoap.org/wsdl/", (OperationOutput) message, false, false);
}
else if (message is OperationInput)
{
this.Write71_OperationInput("input", "http://schemas.xmlsoap.org/wsdl/", (OperationInput) message, false, false);
}
else if (message != null)
{
throw base.CreateUnknownTypeException(message);
}
}
}
OperationFaultCollection faults = o.Faults;
if (faults != null)
{
for (int m = 0; m < faults.Count; m++)
{
this.Write73_OperationFault("fault", "http://schemas.xmlsoap.org/wsdl/", faults[m], false, false);
}
}
base.WriteEndElement(o);
}
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:82,代码来源:ServiceDescriptionSerializationWriter.cs
示例11: Execute
public double Execute(Operation operation, IFunctionRegistry functionRegistry,
IDictionary<string, double> variables)
{
if (operation == null)
throw new ArgumentNullException("operation");
if (operation.GetType() == typeof(IntegerConstant))
{
IntegerConstant constant = (IntegerConstant)operation;
return constant.Value;
}
else if (operation.GetType() == typeof(FloatingPointConstant))
{
FloatingPointConstant constant = (FloatingPointConstant)operation;
return constant.Value;
}
else if (operation.GetType() == typeof(Variable))
{
Variable variable = (Variable)operation;
double value;
bool variableFound = variables.TryGetValue(variable.Name, out value);
if (variableFound)
return value;
else
throw new VariableNotDefinedException(string.Format("The variable \"{0}\" used is not defined.", variable.Name));
}
else if (operation.GetType() == typeof(Multiplication))
{
Multiplication multiplication = (Multiplication)operation;
return Execute(multiplication.Argument1, functionRegistry, variables) * Execute(multiplication.Argument2, functionRegistry, variables);
}
else if (operation.GetType() == typeof(Addition))
{
Addition addition = (Addition)operation;
return Execute(addition.Argument1, functionRegistry, variables) + Execute(addition.Argument2, functionRegistry, variables);
}
else if (operation.GetType() == typeof(Subtraction))
{
Subtraction addition = (Subtraction)operation;
return Execute(addition.Argument1, functionRegistry, variables) - Execute(addition.Argument2, functionRegistry, variables);
}
else if (operation.GetType() == typeof(Division))
{
Division division = (Division)operation;
return Execute(division.Dividend, functionRegistry, variables) / Execute(division.Divisor, functionRegistry, variables);
}
else if (operation.GetType() == typeof(Modulo))
{
Modulo division = (Modulo)operation;
return Execute(division.Dividend, functionRegistry, variables) % Execute(division.Divisor, functionRegistry, variables);
}
else if (operation.GetType() == typeof(Exponentiation))
{
Exponentiation exponentiation = (Exponentiation)operation;
return Math.Pow(Execute(exponentiation.Base, functionRegistry, variables), Execute(exponentiation.Exponent, functionRegistry, variables));
}
else if (operation.GetType() == typeof(UnaryMinus))
{
UnaryMinus unaryMinus = (UnaryMinus)operation;
return -Execute(unaryMinus.Argument, functionRegistry, variables);
}
else if(operation.GetType() == typeof(LessThan))
{
LessThan lessThan = (LessThan)operation;
return (Execute(lessThan.Argument1, functionRegistry, variables) < Execute(lessThan.Argument2, functionRegistry, variables)) ? 1.0 : 0.0;
}
else if (operation.GetType() == typeof(LessOrEqualThan))
{
LessOrEqualThan lessOrEqualThan = (LessOrEqualThan)operation;
return (Execute(lessOrEqualThan.Argument1, functionRegistry, variables) <= Execute(lessOrEqualThan.Argument2, functionRegistry, variables)) ? 1.0 : 0.0;
}
else if (operation.GetType() == typeof(GreaterThan))
{
GreaterThan greaterThan = (GreaterThan)operation;
return (Execute(greaterThan.Argument1, functionRegistry, variables) > Execute(greaterThan.Argument2, functionRegistry, variables)) ? 1.0 : 0.0;
}
else if (operation.GetType() == typeof(GreaterOrEqualThan))
{
GreaterOrEqualThan greaterOrEqualThan = (GreaterOrEqualThan)operation;
return (Execute(greaterOrEqualThan.Argument1, functionRegistry, variables) >= Execute(greaterOrEqualThan.Argument2, functionRegistry, variables)) ? 1.0 : 0.0;
}
else if (operation.GetType() == typeof(Equal))
{
Equal equal = (Equal)operation;
return (Execute(equal.Argument1, functionRegistry, variables) == Execute(equal.Argument2, functionRegistry, variables)) ? 1.0 : 0.0;
}
else if (operation.GetType() == typeof(NotEqual))
{
NotEqual notEqual = (NotEqual)operation;
return (Execute(notEqual.Argument1, functionRegistry, variables) != Execute(notEqual.Argument2, functionRegistry, variables)) ? 1.0 : 0.0;
}
else if (operation.GetType() == typeof(Function))
{
Function function = (Function)operation;
FunctionInfo functionInfo = functionRegistry.GetFunctionInfo(function.FunctionName);
double[] arguments = new double[functionInfo.NumberOfParameters];
//.........这里部分代码省略.........