本文整理汇总了C#中FunctionCollection类的典型用法代码示例。如果您正苦于以下问题:C# FunctionCollection类的具体用法?C# FunctionCollection怎么用?C# FunctionCollection使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
FunctionCollection类属于命名空间,在下文中一共展示了FunctionCollection类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CalculateTest2
public void CalculateTest2()
{
var functions = new FunctionCollection();
var func = new UserFunction("f", new IExpression[] { new Number(1) }, 1);
Assert.AreEqual(Math.Log(1), func.Calculate(functions));
}
示例2: Generator
public Generator(Settings settings)
{
if (settings == null)
throw new ArgumentNullException("settings");
Settings = settings.Clone();
glTypemap = "GL2/gl.tm";
csTypemap = Settings.LanguageTypeMapFile;
enumSpec = Path.Combine("GL2", "signatures.xml");
enumSpecExt = String.Empty;
glSpec = Path.Combine("GL2", "signatures.xml");
glSpecExt = String.Empty;
Settings.ImportsClass = "Core";
Settings.DelegatesClass = "Delegates";
Settings.OutputClass = "GL";
Delegates = new DelegateCollection();
Enums = new EnumCollection();
Wrappers = new FunctionCollection();
SpecReader = new XmlSpecReader(Settings);
}
示例3: WriteBindings
void WriteBindings(DelegateCollection delegates, FunctionCollection wrappers, EnumCollection enums)
{
Console.WriteLine("Writing bindings to {0}", Settings.OutputPath);
if (!Directory.Exists(Settings.OutputPath))
Directory.CreateDirectory(Settings.OutputPath);
// Hack: Fix 3dfx extension category so it doesn't start with a digit
if (wrappers.ContainsKey("3dfx"))
{
var three_dee_fx = wrappers["3dfx"];
wrappers.Remove("3dfx");
wrappers.Add(DigitPrefix + "3dfx", three_dee_fx);
}
using (var sw = sw_h)
{
WriteLicense(sw);
sw.WriteLine("package {0}.{1};", Settings.OutputNamespace, Settings.GLClass);
sw.WriteLine();
sw.WriteLine("import java.nio.*;");
sw.WriteLine();
WriteDefinitions(sw, enums, wrappers, Type.CSTypes);
sw.Flush();
sw.Close();
}
string output_header = Path.Combine(Settings.OutputPath, OutputFileHeader);
Move(sw_h.File, output_header);
}
示例4: NewFunctionCollection
public static FunctionCollection NewFunctionCollection()
{
var result = new FunctionCollection();
FunctionCollections.Add(result);
return result;
}
示例5: ExecuteTest2
public void ExecuteTest2()
{
var functions = new FunctionCollection();
var func = new UserFunction("f", new IExpression[] { new Number(1) }, 1);
Assert.Throws<KeyNotFoundException>(() => func.Execute(functions));
}
示例6: CalculateTest1
public void CalculateTest1()
{
var functions = new FunctionCollection();
functions.Add(new UserFunction("f", new IExpression[] { new Variable("x") }, 1), new Ln(new Variable("x")));
var func = new UserFunction("f", new IExpression[] { new Number(1) }, 1);
Assert.AreEqual(Math.Log(1), func.Calculate(functions));
}
示例7: WriteBindings
void WriteBindings(DelegateCollection delegates, FunctionCollection wrappers, EnumCollection enums)
{
Console.WriteLine("Writing bindings to {0}", Settings.OutputPath);
if (!Directory.Exists(Settings.OutputPath))
Directory.CreateDirectory(Settings.OutputPath);
// Hack: Fix 3dfx extension category so it doesn't start with a digit
if (wrappers.ContainsKey("3dfx"))
{
var three_dee_fx = wrappers["3dfx"];
wrappers.Remove("3dfx");
wrappers.Add(DigitPrefix + "3dfx", three_dee_fx);
}
Settings.DefaultOutputNamespace = "OpenTK";
// Enums
using (var sw = sw_h_enums)
{
WriteEnums(sw, enums);
sw.Flush();
sw.Close();
}
// Core definitions
using (var sw = sw_h)
{
WriteDefinitions(sw, enums, wrappers, Type.CSTypes, false);
sw.Flush();
sw.Close();
}
// Compatibility definitions
using (var sw = sw_h_compat)
{
WriteDefinitions(sw, enums, wrappers, Type.CSTypes, true);
sw.Flush();
sw.Close();
}
// Core & compatibility declarations
using (var sw = sw_cpp)
{
WriteDeclarations(sw, wrappers, Type.CSTypes);
sw.Flush();
sw.Close();
}
string output_header = Path.Combine(Settings.OutputPath, OutputFileHeader);
string output_cpp = Path.Combine(Settings.OutputPath, OutputFileCpp);
string output_header_compat = Path.Combine(Settings.OutputPath, OutputFileHeaderCompat);
string output_header_enums = Path.Combine(Settings.OutputPath, OutputFileHeaderEnums);
Move(sw_h.File, output_header);
Move(sw_cpp.File, output_cpp);
Move(sw_h_compat.File, output_header_compat);
Move(sw_h_enums.File, output_header_enums);
}
示例8: MvcFunctionBase
protected MvcFunctionBase(string @namespace, string name, string description, FunctionCollection functionCollection)
{
Verify.ArgumentNotNullOrEmpty(@namespace, "namespace");
Verify.ArgumentNotNullOrEmpty(name, "name");
Verify.ArgumentNotNull(functionCollection, "functionCollection");
Namespace = @namespace;
Name = @name;
Description = description;
_functionCollection = functionCollection;
}
示例9: CalculateTest3
public void CalculateTest3()
{
var uf1 = new UserFunction("func", new[] { new Variable("x") }, 1);
var func = new DelegateExpression(p => (double)p.Parameters["x"] == 10 ? 0 : 1);
var funcs = new FunctionCollection();
funcs.Add(uf1, func);
var uf2 = new UserFunction("func", new[] { new Number(12) }, 1);
var result = uf2.Calculate(new ExpressionParameters(funcs));
Assert.AreEqual(1.0, result);
}
示例10: MvcActionFunction
public MvcActionFunction(Type controllerType, string actionName, string @namespace, string name, string description,
FunctionCollection functionCollection)
: base(@namespace, name, description, functionCollection)
{
_controllerDescriptor = new ReflectedControllerDescriptor(controllerType);
_actionName = actionName;
var actions = _controllerDescriptor.GetCanonicalActions().Where(a => a.ActionName == actionName);
Verify.That(actions.Any(), "Action name '{0}' isn't recognized", actionName);
_routeToRender = "~/{0}/{1}".FormatWith(_controllerDescriptor.ControllerName, actionName);
}
示例11: UndefFuncTest
public void UndefFuncTest()
{
var key1 = new UserFunction("f", 0);
var key2 = new UserFunction("f", 1);
var functions = new FunctionCollection { { key1, new Number(1) }, { key2, new Number(2) } };
var undef = new Undefine(key1);
undef.Calculate(functions);
Assert.IsFalse(functions.ContainsKey(key1));
Assert.IsTrue(functions.ContainsKey(key2));
}
示例12: UndefFuncWithParamsTest
public void UndefFuncWithParamsTest()
{
var key1 = new UserFunction("f", new IExpression[0], 0);
var key2 = new UserFunction("f", 1);
var functions = new FunctionCollection { { key1, new Number(1) }, { key2, new Number(2) } };
var undef = new Undefine(key2);
var result = undef.Execute(functions);
Assert.True(functions.ContainsKey(key1));
Assert.False(functions.ContainsKey(key2));
Assert.Equal("The 'f(x1)' function is removed.", result);
}
示例13: MvcControllerFunction
public MvcControllerFunction(ReflectedControllerDescriptor controllerDescriptor,
string @namespace, string name, string description, FunctionCollection functionCollection)
: base(@namespace, name, description, functionCollection)
{
Verify.ArgumentNotNull(controllerDescriptor, "controllerDescriptor");
_controllerDescriptor = controllerDescriptor;
RequireAsyncHandler = _controllerDescriptor.ControllerType
.GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)
.Any(method => method.ReturnType == typeof(Task)
|| (method.ReturnType.IsGenericType
&& method.ReturnType.GetGenericTypeDefinition() == typeof(Task<>)));
}
示例14: DataContext
public DataContext(MetadataContext metadataContext)
{
_metadataContext = metadataContext;
_tables = new TableCollection(this);
_tables.Changed += member_Changed;
_tableRelations = new TableRelationCollection(this);
_tableRelations.Changed += member_Changed;
_constants = new ConstantCollection();
_constants.Changed += member_Changed;
_aggregates = new AggregateCollection();
_aggregates.AddDefaults();
_aggregates.Changed += member_Changed;
_functions = new FunctionCollection();
_functions.AddDefaults();
_functions.Changed += member_Changed;
}
示例15: Generator
public Generator()
{
if (Settings.Compatibility == Settings.Legacy.Tao)
{
Settings.OutputNamespace = "Tao.OpenGl";
Settings.OutputClass = "Gl";
}
else
{
// Defaults
}
Settings.ImportsFile = "GLCore.cs";
Settings.DelegatesFile = "GLDelegates.cs";
Settings.EnumsFile = "GLEnums.cs";
Settings.WrappersFile = "GL.cs";
Delegates = new DelegateCollection();
Enums = new EnumCollection();
Wrappers = new FunctionCollection();
}