本文整理汇总了C#中ParameterInfo类的典型用法代码示例。如果您正苦于以下问题:C# ParameterInfo类的具体用法?C# ParameterInfo怎么用?C# ParameterInfo使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ParameterInfo类属于命名空间,在下文中一共展示了ParameterInfo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnSerializing
private void OnSerializing() {
Animator animator = GetComponent<Animator>();
// Store the current state for each layer
layerData = new LayerInfo[animator.layerCount];
for (int i = 0; i < animator.layerCount; i++) {
layerData[i] = new LayerInfo {
index = i,
currentHash = animator.GetCurrentAnimatorStateInfo(i).shortNameHash,
nextHash = animator.GetNextAnimatorStateInfo(i).shortNameHash,
normalizedTimeCurrent = animator.GetCurrentAnimatorStateInfo(i).normalizedTime,
normalizedTimeNext = animator.GetNextAnimatorStateInfo(i).normalizedTime,
weight = animator.GetLayerWeight(i)
};
}
// Store every parameter
parameterData = new ParameterInfo[animator.parameterCount];
for (int i = 0; i < animator.parameterCount; i++) {
parameterData[i] = new ParameterInfo {
number = animator.parameters[i].nameHash,
type = animator.parameters[i].type,
value = GetParameterValue(animator.parameters[i].nameHash, animator.parameters[i].type, animator)
};
}
}
示例2: ConvertParameters
public static void ConvertParameters(EngineManager manager, ParameterInfo[] parameterInfo, ref object[] parameters)
{
for (int i = 0; i < parameterInfo.Length; i++)
{
if (Common.TypeInheritsFrom(parameterInfo[i].ParameterType, typeof(EngineObject)) && parameters[i].GetType() == typeof(int))
{
parameters[i] = manager.GetObject<EngineObject>((int)parameters[i]);
}
if (parameterInfo[i].ParameterType == typeof(object[]))
{
object[] tempObjects = new object[parameters.Length - i];
for (int j = 0; j < tempObjects.Length; j++)
{
tempObjects[j] = parameters[i + j];
}
parameters[i] = tempObjects;
object[] newParameters = new object[i + 1];
for (int j = 0; j < newParameters.Length; j++)
{
newParameters[j] = parameters[j];
}
parameters = newParameters;
}
}
}
示例3: CreateUrl
public override string CreateUrl(ParameterInfo yeepay)
{
var info = yeepay as YeePayParasInfo;
if (info == null) return "";
//签名
var sb = "Buy";
sb += Configs.GetPartnerId();
sb += info.OrderNum;
sb += info.Amount.ToString("0.00");
sb += info.Cur;
sb += info.ProName;
sb += info.ProCate;
sb += info.ProDesc;
sb += info.ReturnUrl;
sb += info.Saf;
sb += info.ExtentInfo;
sb += info.FrpId;
sb += (info.NeedResponse ? "1" : "0");
var hmac = Digest.HmacSign(sb, Configs.GetKey());
var url = Configs.RequestPayUrl;
url += string.Format(Configs.Paras, Configs.GetPartnerId(),
HttpUtility.UrlEncode(info.OrderNum, Configs.DefCoding), info.Amount.ToString("0.00"), info.Cur,
HttpUtility.UrlEncode(info.ProName, Configs.DefCoding),
HttpUtility.UrlEncode(info.ProCate, Configs.DefCoding),
HttpUtility.UrlEncode(info.ProDesc, Configs.DefCoding),
HttpUtility.UrlEncode(info.ReturnUrl, Configs.DefCoding),
info.Saf, HttpUtility.UrlEncode(info.ExtentInfo, Configs.DefCoding), info.FrpId,
(info.NeedResponse ? "1" : "0"), hmac);
return url;
}
示例4: VisitParameter
public override void VisitParameter(ParameterAttribute parameter)
{
_parameterInfo = new ParameterInfo(CurrentProperty, parameter);
_cmdletInfo.AddParameter(_parameterInfo);
base.VisitParameter(parameter);
}
示例5: CreateNewConcepts
public IEnumerable<IConceptInfo> CreateNewConcepts(IEnumerable<IConceptInfo> existingConcepts)
{
var newConcepts = new List<IConceptInfo>();
ParameterInfo filterParameter;
var filterNameElements = FilterName.Split('.');
if (filterNameElements.Count() == 2)
filterParameter = new ParameterInfo { Module = new ModuleInfo { Name = filterNameElements[0] }, Name = filterNameElements[1] };
else
filterParameter = new ParameterInfo { Module = Source.Module, Name = FilterName };
if (!existingConcepts.OfType<DataStructureInfo>() // Existing filter parameter does not have to be a ParameterInfo. Any DataStructureInfo is allowed.
.Any(item => item.Module.Name == filterParameter.Module.Name && item.Name == filterParameter.Name))
newConcepts.Add(filterParameter);
var composableFilter = new ComposableFilterByInfo
{
Source = Source,
Parameter = filterParameter.GetKeyProperties(),
Expression = "(source, repository, parameter) => source.Where(" + Expression + ")"
};
newConcepts.Add(composableFilter);
return newConcepts;
}
示例6: GetValueFactory
public Expression<Func<object>> GetValueFactory(string key, ParameterInfo parameter = null)
{
Guard.EnsureIsNotNullOrEmpty("key", key);
if (!Delegates.ContainsKey(key))
{
return null;
}
var expression = Delegates[key];
var parameterExpression = expression.Parameters
.SafeSelect(p => p)
.FirstOrDefault();
if (parameter.IsNull() || parameterExpression.IsNull())
{
return Expression.Lambda<Func<object>>(expression.Body, null);
}
var blockExpression = Expression.Block(
new[] { parameterExpression },
// ReSharper disable AssignNullToNotNullAttribute
// ReSharper disable once PossibleNullReferenceException
Expression.Assign(parameterExpression, Expression.Constant(parameter.Value)),
//Expression.Constant(parameter.Value, parameter.Type)),
// ReSharper restore AssignNullToNotNullAttribute
expression.Body);
return Expression.Lambda<Func<object>>(blockExpression, null);
}
示例7: CreateNewConcepts
public IEnumerable<IConceptInfo> CreateNewConcepts(IEnumerable<IConceptInfo> existingConcepts)
{
var filterParameter = new ParameterInfo
{
Module = Property.DataStructure.Module,
Name = Property.Name + "_RegExMatchFilter",
};
string filterExpression = string.Format(@"(source, repository, parameter) =>
{{
var items = source.Where(item => !string.IsNullOrEmpty(item.{0})).Select(item => new {{ item.ID, item.{0} }}).ToList();
var regex = new System.Text.RegularExpressions.Regex({1});
var invalidItemIds = items.Where(item => !regex.IsMatch(item.{0})).Select(item => item.ID).ToList();
return Filter(source, invalidItemIds);
}}",
Property.Name,
CsUtility.QuotedString("^" + RegularExpression + "$"));
var itemFilterRegExMatchProperty = new ComposableFilterByInfo
{
Expression = filterExpression,
Parameter = filterParameter.Module.Name + "." + filterParameter.Name,
Source = Property.DataStructure
};
var invalidDataRegExMatchProperty = new InvalidDataMarkPropertyInfo
{
DependedProperty = Property,
FilterType = itemFilterRegExMatchProperty.Parameter,
ErrorMessage = ErrorMessage,
Source = Property.DataStructure
};
return new IConceptInfo[] { filterParameter, itemFilterRegExMatchProperty, invalidDataRegExMatchProperty };
}
示例8: ParameterInfo
private ParameterInfo(ParameterInfo accessor, MemberInfo member)
{
this.MemberImpl = member;
this.NameImpl = accessor.Name;
this.ClassImpl = accessor.ParameterType;
this.PositionImpl = accessor.Position;
this.AttrsImpl = accessor.Attributes;
}
示例9: GetDefaultValuesForParameters
private static object[] GetDefaultValuesForParameters(ParameterInfo[] paramTypes)
{
Object[] parameters = new Object[paramTypes.Length];
for (int i = 0; i < paramTypes.Length; i++)
{
parameters[i] = Activator.CreateInstance(paramTypes[i].ParameterType);
}
return parameters;
}
示例10: ParameterName
static string ParameterName (ParameterInfo parameter)
{
switch (parameter.Name) {
case "break":
case "continue":
case "finally":
return "@" + parameter.Name;
}
return parameter.Name;
}
示例11: CalculatorBot
public CalculatorBot(string token)
: base("calculator", token)
{
var command = new CommandInfo("/start");
command.StaticAcceptMessage = "Ok you started the calculator";
Configuration.Commands.Add(command);
Configuration.StaticUnknownCommandMessage = "Unknown command. Please try another command. Send /start to get a list of available comands.";
var command2 = new CommandInfo("/newbrand");
command2.StaticAcceptMessage = "New brand is saved.";
var parameter = new ParameterInfo() { Name = "Name", Type = ParameterTypes.Text, Optional = false, StaticPrompt = "Ok, enter new brand name." };
command2.Parameters.Add(parameter);
Configuration.Commands.Add(command2);
}
示例12: GetParameters
public sealed override ParameterInfo[] GetParameters()
{
if (ReflectionTrace.Enabled)
ReflectionTrace.MethodBase_GetParameters(this);
RuntimeParameterInfo[] runtimeParametersAndReturn = this.RuntimeParametersAndReturn;
if (runtimeParametersAndReturn.Length == 1)
return Array.Empty<ParameterInfo>();
ParameterInfo[] result = new ParameterInfo[runtimeParametersAndReturn.Length - 1];
for (int i = 0; i < result.Length; i++)
result[i] = runtimeParametersAndReturn[i + 1];
return result;
}
示例13: GenerateParam
public static MySqlParameter[] GenerateParam(ParameterInfo[] methodParameters, params object[] Values)
{
int length = methodParameters.Length;
MySqlParameter[] sqlParams = new MySqlParameter[length];
for (int i = 0; i < length; i++)
{
MySqlParameter parameter = new MySqlParameter();
parameter.ParameterName = "@" + methodParameters[i].Name;
parameter.Value = Values[i];
sqlParams[i] = parameter;
}
return sqlParams;
}
示例14: AddValueFactory
protected void AddValueFactory(ValueFactoryModelBase model,
string loaderKey, ParameterInfo parameter = null)
{
if (model.IsNull())
{
return;
}
Guard.EnsureIsNotNullOrEmpty("loaderKey", loaderKey);
var valueExpression = ValueFactory.GetValueFactory(
loaderKey, parameter);
valueExpression.Do(() =>
model.ValueFactories.Add(loaderKey, valueExpression.Compile()));
}
示例15: StoredProcedureInfo
/// <summary>
/// Creates a new instance of the StoredProcedureInfo class.
/// This constructor is private; call the static GetInfo() method instead.
/// </summary>
/// <param name="connectionName">Name of the database connection.</param>
/// <param name="schema">Name of the database schema.</param>
/// <param name="procedureName">Name of the stored procedure.</param>
private StoredProcedureInfo(string connectionName, string schema, string procedureName)
{
this.ConnectionName = connectionName;
this.Schema = schema;
this.ProcedureName = procedureName;
// query the database for the procedure's parameters;
// if the procedure doesn't exist, zero parameters will be found, successfully (no error)
var parametersQuery = new StoredProcedureQuery("SelectStoredProcedureParameters", connectionName);
parametersQuery.Parameters.Add("Schema", this.Schema);
parametersQuery.Parameters.Add("ProcedureName", this.ProcedureName);
DataSet results = parametersQuery.ReturnAllTables();
var parameters = results.Tables[0]; // no rows if the procedure has no parameters
var columnNames = results.Tables[1]; // no rows if the procedure has no TVPs; all TVPs' columns otherwise
foreach (DataRow parameter in parameters.Rows)
{
var param = new ParameterInfo
{
Name = parameter["ParameterName"] as string,
TypeString = parameter["DataType"] as string,
UserDefinedTypeName = parameter["UserDefinedTypeName"] as string,
MaxLength = parameter["MaxLength"] as int?
};
// TODO: switch this logic around when we internationalize the db to use nvarchar columns
if (param.TypeString == "varchar")
param.Type = SqlDbType.VarChar;
else if (param.TypeString == "char")
param.Type = SqlDbType.Char;
else if (param.TypeString == "nvarchar")
param.Type = SqlDbType.NVarChar;
else if (param.TypeString == "nchar")
param.Type = SqlDbType.NChar;
else if (param.TypeString == "table type")
{
param.Type = SqlDbType.Structured;
// get the table type's column names
param.ColumnNames = columnNames.Select("ParameterName = '" + param.Name + "'")
.Select(dr => dr["ColumnName"] as string).ToArray();
}
this.Parameters.Add(param);
}
}