本文整理汇总了C#中Function类的典型用法代码示例。如果您正苦于以下问题:C# Function类的具体用法?C# Function怎么用?C# Function使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Function类属于命名空间,在下文中一共展示了Function类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Data
//Converts the bytes into an object of type Data
public Data(byte[] data)
{
//The first four bytes store the length of the name
int nameLen = BitConverter.ToInt32(data, 0);
//This check makes sure that strName has been passed in the array of bytes
if (nameLen > 0)
this.strName = Encoding.UTF8.GetString(data, 4, nameLen);
else
this.strName = null;
//The next four store the function
this.function = (Function)BitConverter.ToInt32(data, 4 + nameLen);
//The rest store the dynamically stored parameters
byte[] objectData = new byte[1024];
//I am making a new array with only the parameters, could probably find a better way
Array.Copy(data, 8 + nameLen, objectData, 0, 512);
BinaryFormatter formatter = new BinaryFormatter();
MemoryStream ms = new MemoryStream(objectData);
this.objects = (object[])formatter.Deserialize(ms);
}
示例2: AddSubFunction
public void AddSubFunction(Function f)
{
if (_subFunctions.Contains(f) || f == this)
return;
_subFunctions.Add(f);
OnPropertyChanged("SubFunctions");
}
示例3: Insert
/// <summary>
/// Insert a <see cref="Function"/> passed as an argument via Stored Procedure that returns the newly inserted Function Key
/// </summary>
/// <param name="aFunction">A <see cref="Function"/>.</param>
/// <exception cref="ArgumentNullException">If <c>aFunction</c> argument is <c>null</c>.</exception>
public static void Insert(Function aFunction)
{
if (aFunction == null)
{
throw new ArgumentNullException("aFunction");
}
using (var vSqlCommand = new SqlCommand()
{
CommandType = CommandType.Text,
Connection = new SqlConnection(Connection.Instance.SqlConnectionString)
})
{
var vStringBuilder = new StringBuilder();
vStringBuilder.AppendLine("insert into FNC_Function");
vStringBuilder.AppendLine(" (FNC_Code, FNC_Name)");
vStringBuilder.AppendLine("values");
vStringBuilder.AppendLine(" (@FNCCode, @FNCName)");
vStringBuilder.AppendLine(";");
vStringBuilder.AppendLine("select SCOPE_IDENTITY()");
ObjectToData(vSqlCommand, aFunction);
vSqlCommand.CommandText = vStringBuilder.ToString();
vSqlCommand.Connection.Open();
aFunction.FncKey = Convert.ToInt32(vSqlCommand.ExecuteScalar());
vSqlCommand.Connection.Close();
}
}
示例4: GetFunctions
public static IQueryable<Function> GetFunctions(List<string> functionMethodList)
{
var data = dataAccess();
var autoAdded = false;
//var functionMethodList = FSM.Functions.FSMFunctionLoader.GetFunctionList();
var functions = data.GetFunctions();
var functionList = functions.ToDictionary(f => f.FunctionName, f => f);
foreach (var functionName in functionMethodList)
{
if(!functionList.ContainsKey(functionName))
{
autoAdded = true;
var newFunction = new Function();
newFunction.FunctionName = functionName;
newFunction.Description = functionName + " @Added Automatically";
newFunction.FunctionURI = "";
CreateFunction(newFunction);
}
}
functions = autoAdded ? data.GetFunctions() : functions;
return functions;
}
示例5: VisitFunctionDecl
public override bool VisitFunctionDecl(Function function)
{
if (!VisitDeclaration(function))
return false;
var ret = function.ReturnType;
string msg;
if (HasInvalidType(ret.Type, out msg))
{
function.ExplicitlyIgnore();
Log.Debug("Function '{0}' was ignored due to {1} return decl",
function.Name, msg);
return false;
}
foreach (var param in function.Parameters)
{
if (HasInvalidDecl(param, out msg))
{
function.ExplicitlyIgnore();
Log.Debug("Function '{0}' was ignored due to {1} param",
function.Name, msg);
return false;
}
if (HasInvalidType(param.Type, out msg))
{
function.ExplicitlyIgnore();
Log.Debug("Function '{0}' was ignored due to {1} param",
function.Name, msg);
return false;
}
var decayedType = param.Type.Desugar() as DecayedType;
if (decayedType != null)
{
function.ExplicitlyIgnore();
Log.Debug("Function '{0}' was ignored due to unsupported decayed type param",
function.Name);
return false;
}
if (param.Kind == ParameterKind.IndirectReturnType)
{
Class retClass;
param.Type.Desugar().TryGetClass(out retClass);
if (retClass == null)
{
function.ExplicitlyIgnore();
Log.Debug(
"Function '{0}' was ignored due to an indirect return param not of a tag type",
function.Name);
return false;
}
}
}
return true;
}
示例6: Integrate
public double Integrate(Function f, int numberOfNodes)
{
this.initializeListOfQuadratures(numberOfNodes);
double result = this.Integrator(f);
this.quadratures.Clear();
return result;
}
示例7: GetTopFunctionList
public string GetTopFunctionList()
{
string sql = "SELECT * FROM dbo.FunctionList WHERE parentId IS NULL ORDER BY orderFlag";
IList<Function> TopFunctionList = new List<Function>();
using (DataTable table = SqlHelper.ExecuteDataset(CommonInfo.ConQJVRMS, CommandType.Text, sql).Tables[0])
{
foreach (DataRow row in table.Rows)
{
Function f = new Function();
f.Description = row["Description"].ToString();
f.FunctionName = row["FunctionName"].ToString();
f.UrlPath = row["UrlPath"].ToString();
f.FunctionID = new Guid(row["FunctionId"].ToString());
f.OrderFlag = int.Parse(row["orderFlag"].ToString());
if (row["parentid"] == DBNull.Value)
{
f.ParentFunctionId = null;
}
else
{
f.ParentFunctionId = new Guid(row["parentId"].ToString());
}
TopFunctionList.Add(f);
}
}
SerializeObjectFactory sof = new SerializeObjectFactory();
return sof.SerializeToBase64(TopFunctionList);
}
示例8: Parse
public void Parse(string stmt)
{
if (string.IsNullOrEmpty(stmt)) throw new Exception("Syntax Error: nil statement");
stmt = stmt.Trim();
if (string.IsNullOrEmpty(stmt)) throw new Exception("Syntax Error: nil statement");
if (!Regex.IsMatch(stmt, @"^(\w{1}|\w+(.*)(\w+|\)))$")) {
throw new Exception("Syntax Error: Invalid statement.");
}
List<Identifier> idlist = new List<Identifier>();
var funcs = Regex.Matches(stmt, @"\b[a-zA-Z]\w*\((\s*\w+(\s*\,\s*\w+)*)\s*\)");
int lastFuncEnd = 0;
foreach (Match m in funcs) {
Function func = new Function(m.Groups[0].Value, m.Groups[1].Value);
//parse any identifiers before the function
ParseIdentifiers(idlist, stmt, lastFuncEnd, m.Index);
lastFuncEnd = m.Index + m.Length;
idlist.Add(func);
}
//parse the identifiers after the last function
ParseIdentifiers(idlist, stmt, lastFuncEnd, stmt.Length);
_identifiers = idlist.ToArray();
}
示例9: VisitFunctionDecl
public override bool VisitFunctionDecl(Function function)
{
if (!VisitDeclaration(function))
return false;
if (function.IsReturnIndirect)
{
var indirectParam = new Parameter()
{
Kind = ParameterKind.IndirectReturnType,
QualifiedType = function.ReturnType,
Name = "return",
};
function.Parameters.Insert(0, indirectParam);
function.ReturnType = new QualifiedType(new BuiltinType(
PrimitiveType.Void));
}
if (function.HasThisReturn)
{
// This flag should only be true on methods.
var method = (Method) function;
var classType = new QualifiedType(new TagType(method.Namespace),
new TypeQualifiers {IsConst = true});
function.ReturnType = new QualifiedType(new PointerType(classType));
}
// TODO: Handle indirect parameters
return true;
}
示例10: CreateProcess
public ProcessDescriptor CreateProcess(Process.EProcessKind kind, Function func, params ISignalOrPortDescriptor[] sensitivity)
{
func.Name = _dpb._psName + "_FuPs" + _dpb._nextFUProcessIndex + "_" + func.Name;
var result = _orgBinder.CreateProcess(kind, func, sensitivity);
++_dpb._nextFUProcessIndex;
return result;
}
示例11: Process
public Documentation Process(Function f, EnumProcessor processor)
{
Documentation docs = null;
if (DocumentationCache.ContainsKey(f.WrappedDelegate.Name))
{
return DocumentationCache[f.WrappedDelegate.Name];
}
else
{
var file = Settings.FunctionPrefix + f.WrappedDelegate.Name + ".xml";
if (!DocumentationFiles.ContainsKey(file))
file = Settings.FunctionPrefix + f.TrimmedName + ".xml";
if (!DocumentationFiles.ContainsKey(file))
file = Settings.FunctionPrefix + f.TrimmedName.TrimEnd(numbers) + ".xml";
docs =
(DocumentationFiles.ContainsKey(file) ? ProcessFile(DocumentationFiles[file], processor) : null) ??
new Documentation
{
Summary = String.Empty,
Parameters = f.Parameters.Select(p =>
new DocumentationParameter(p.Name, String.Empty)).ToList()
};
DocumentationCache.Add(f.WrappedDelegate.Name, docs);
}
return docs;
}
示例12: Prepare
public void Prepare(Function fn, ClassRemotes.Remote remote)
{
remoteDisplay.Clear();
remoteDisplay.AnyTextChanged += SomeTextChanged;
// Do things differently basen on whether we are using this
// form to add a new remote repo, rename it or we are editing
// an existing remote repo
switch (fn)
{
case Function.Add:
remoteDisplay.Enable(true, true);
remote.Name = "origin";
remote.PushCmd = "";
remoteDisplay.Set(remote);
Text = "Add a new remote repository";
btOK.Enabled = false;
break;
case Function.Edit:
Text = "Edit remote repository '" + remote.Name + "'";
remoteDisplay.Enable(false, true);
remoteDisplay.Set(remote);
break;
case Function.Rename:
Text = "Rename remote repository '" + remote.Name + "'";
remoteDisplay.Enable(true, false);
remoteDisplay.Set(remote);
break;
}
}
示例13: CachedFunction
CachedFunction(Function f, Cache c)
{
this.f = f;
this.cache = c;
this.unique_id = count; ++count;
}
示例14: PopulateFunctionInfoFromDeclaration
private void PopulateFunctionInfoFromDeclaration(Function aFunction)
{
var functionSections = Regex.Match(aFunction.Declaration, @"(\w+)( \w+)? (\w+)\((.+?)\)");
ReturnType = functionSections.Groups[1].Value;
Parameters = functionSections.Groups[4].Value;
FunctionName = functionSections.Groups[3].Value;
}
示例15: GetArgumentDependentVariables
public void GetArgumentDependentVariables()
{
IFunction f = new Function();
IVariable c1 = new Variable<int>("c1");
IVariable c2 = new Variable<int>("c2");
IVariable x = new Variable<int>("x");
f.Components.Add(c1);
f.Components.Add(c2);
IDictionary<IVariable, IEnumerable<IVariable>> dependentVariables = MemoryFunctionStoreHelper.GetDependentVariables(f.Store.Functions);
//no argument dependencies yet
Assert.AreEqual(2, dependentVariables.Count);
Assert.AreEqual(new IVariable[0],dependentVariables[c1].ToArray());
Assert.AreEqual(new IVariable[0], dependentVariables[c2].ToArray());
f.Arguments.Add(x);
dependentVariables = MemoryFunctionStoreHelper.GetDependentVariables(f.Store.Functions);
Assert.AreEqual(3, dependentVariables.Count);
Assert.AreEqual(2, dependentVariables[x].Count());
Assert.AreEqual(new[]{c1,c2},dependentVariables[x]);
//Assert.IsTrue(dependentVariables[x].Contains(c1));
}