本文整理汇总了C#中IParameter类的典型用法代码示例。如果您正苦于以下问题:C# IParameter类的具体用法?C# IParameter怎么用?C# IParameter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IParameter类属于命名空间,在下文中一共展示了IParameter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WithParameter
public PendingBinaryStateOutputActuatorState WithParameter(IParameter parameter)
{
if (parameter == null) throw new ArgumentNullException(nameof(parameter));
Parameters.Add(parameter);
return this;
}
示例2: GetParameterTypeReference
internal static CodeTypeReference GetParameterTypeReference(CodeTypeDeclaration classDeclaration,
IParameter param)
{
Type underlyingType = GetParameterType(param);
CodeTypeReference paramTypeRef = new CodeTypeReference(underlyingType);
bool isValueType = underlyingType.IsValueType;
// Check if we need to declare a custom type for this parameter.
// If the parameter is an enum, try finding the matching enumeration in the current class
if (!param.EnumValues.IsNullOrEmpty())
{
// Naming scheme: MethodnameParametername
CodeTypeReference enumReference = DecoratorUtil.FindFittingEnumeration(
classDeclaration, param.EnumValues, param.EnumValueDescriptions);
if (enumReference != null)
{
paramTypeRef = enumReference;
isValueType = true;
}
}
// Check if this is an optional value parameter.
if (isValueType && !param.IsRequired)
{
paramTypeRef = new CodeTypeReference(typeof(Nullable<>))
{
TypeArguments = { paramTypeRef.BaseType }
};
// An optional value parameter has to be nullable.
}
return paramTypeRef;
}
示例3: ProcessParameter
private void ProcessParameter(IParameter parameter, int index, StringBuilder preMemberCodeBulider)
{
// Dispatch to the typed parameter handler method.
Type key = parameter.GetType().GetInterfaces().First(t => t.Namespace == typeof(IParameter).Namespace && t.Name.StartsWith("I") && t.Name.EndsWith("Parameter"));
Action<IParameter, int, StringBuilder> method = _parameterCodeGeneratorMethodMap[key];
method(parameter, index, preMemberCodeBulider);
}
示例4: ConstructorInjectionComponentAdapter
public ConstructorInjectionComponentAdapter(object componentKey, Type componentImplementation,
IParameter[] parameters, bool allowNonPublicClasses,
IComponentMonitor componentMonitor)
: base(componentKey, componentImplementation, parameters, allowNonPublicClasses)
{
this.componentMonitor = componentMonitor;
}
示例5: ParameterCollection
public ParameterCollection(IParameter[] parameters)
{
foreach (IParameter parameter in parameters)
{
AddParameter(parameter);
}
}
示例6: CreateComponentAdapter
public IComponentAdapter CreateComponentAdapter(object componentKey, Type componentImplementation,
IParameter[] parameters)
{
return
new CachingComponentAdapter(
new ConstructorInjectionComponentAdapter(componentKey, componentImplementation, parameters));
}
示例7: CreatePresenterInstance
protected override IPresenter CreatePresenterInstance(Type presenterType, TypedPageData pageData, Type viewType, IEPiView view)
{
// Unfortunately, Ninject needs the bloody names of the parameters,
// so we need to figure them out by reflecting.
string pageDataParameterName = null;
string viewParameterName = null;
foreach (var constructor in presenterType.GetConstructors())
{
var constructorParameters = constructor.GetParameters();
foreach (var parameter in constructorParameters)
{
if (parameter.ParameterType.IsAssignableFrom(pageData.GetType()))
pageDataParameterName = parameter.Name;
if (parameter.ParameterType.IsAssignableFrom(view.GetType()))
viewParameterName = parameter.Name;
}
}
var parameters = new IParameter[]
{
new ConstructorArgument(viewParameterName, view),
new ConstructorArgument(pageDataParameterName, pageData)
};
return (IPresenter)Kernel.Get(presenterType, parameters);
}
示例8: Resolve
public object[] Resolve(object requestParameters, IParameter[] targetParameters)
{
// Convert to array
var parameters = ((IEnumerable) requestParameters).Cast<object>().ToArray();
// If length does not match, throw.
if (parameters.Length != targetParameters.Length)
{
throw new ParameterLengthMismatchException();
}
var result = new List<object>();
// Loop through and parse parameters
for (var i = 0; i < parameters.Length; i++)
{
var request = parameters[i];
var target = targetParameters[i];
// If the target parameter is `object`, do not try to convert it.
if (target.ParameterType == typeof (object))
{
result.Add(request);
}
else
{
var serialized = _serializer.SerializeObject(request);
var converted = _serializer.DeserializeObject(serialized, target.ParameterType);
result.Add(converted);
}
}
return result.ToArray();
}
示例9: btnOK_Click
private void btnOK_Click(object sender, EventArgs e)
{
this.NewParameter = this.cboxNewName.SelectedItem as IParameter;
this.OldParameter = this.cboxOldName.SelectedItem as IParameter;
this.DialogResult = DialogResult.OK;
this.Close();
}
示例10: WrapComponentInstances
protected virtual IPicoContainer WrapComponentInstances(Type decoratingComponentAdapterClass,
IPicoContainer picoContainer,
object[] wrapperDependencies)
{
Assert.IsTrue(typeof (DecoratingComponentAdapter).IsAssignableFrom(decoratingComponentAdapterClass));
IMutablePicoContainer mutablePicoContainer = new DefaultPicoContainer();
int size = (wrapperDependencies != null ? wrapperDependencies.Length : 0) + 1;
ICollection allComponentAdapters = picoContainer.ComponentAdapters;
foreach (object adapter in allComponentAdapters)
{
IParameter[] parameters = new IParameter[size];
parameters[0] = new ConstantParameter(adapter);
for (int i = 1; i < parameters.Length; i++)
{
parameters[i] = new ConstantParameter(wrapperDependencies[i - 1]);
}
IMutablePicoContainer instantiatingPicoContainer =
new DefaultPicoContainer(new ConstructorInjectionComponentAdapterFactory());
instantiatingPicoContainer.RegisterComponentImplementation("decorator", decoratingComponentAdapterClass,
parameters);
mutablePicoContainer.RegisterComponent(
(IComponentAdapter) instantiatingPicoContainer.GetComponentInstance("decorator"));
}
return mutablePicoContainer;
}
示例11: DefaultParameter
public DefaultParameter(IParameter p)
{
this.name = p.Name;
this.region = p.Region;
this.modifier = p.Modifiers;
this.returnType = p.ReturnType;
}
示例12: InstantiatingComponentAdapter
/// <summary>
/// Constructor
/// </summary>
/// <param name="componentKey">The component's key</param>
/// <param name="componentImplementation">The component implementing type</param>
/// <param name="parameters">Parameters used to initialize the component</param>
/// <param name="allowNonPublicClasses">flag to allow instantiation of non-public classes.</param>
public InstantiatingComponentAdapter(object componentKey, Type componentImplementation, IParameter[] parameters,
bool allowNonPublicClasses)
: base(componentKey, componentImplementation)
{
this.parameters = parameters;
this.allowNonPublicClasses = allowNonPublicClasses;
}
示例13: ParseParameterValue
public override bool ParseParameterValue(IParameter parameter, string parameterValue)
{
bool returnValue = base.ParseParameterValue(parameter, parameterValue);
if (returnValue)
{
switch (parameter.Name)
{
case _ParameterAlternateNameSource:
case _ParameterNameSource:
parameterValue = parameterValue.Trim();
if (Directory.Exists(parameterValue))
{
((Parameter<string>)parameter).Value = parameterValue;
}
else
{
returnValue = false;
}
break;
}
}
return returnValue;
}
示例14: ValidateParameter
/// <summary>
/// Validates a parameter.
///
/// Checks to see if it is required, or if it needs regex validation.
/// </summary>
/// <param name="param">
/// A <see cref="IParameter"/>
/// </param>
/// <returns>
/// A <see cref="System.Boolean"/>
/// </returns>
public bool ValidateParameter(IParameter param)
{
if (Parameters == null)
{
return false;
}
string currentParam;
bool parameterPresent = Parameters.TryGetValue(param.Name, out currentParam);
// If a required parameter is not present, fail.
if (String.IsNullOrEmpty(currentParam) || !parameterPresent)
{
return !param.IsRequired;
}
// The parameter is present, validate the regex.
bool isValidData = ValidateRegex(param, currentParam) && ValidateEnum(param, currentParam);
if (isValidData == false)
{
return false;
}
return true;
}
示例15: AddParameter
public void AddParameter(IParameter parameter)
{
if (parameter == null)
throw new ArgumentNullException("parameter");
parameters.Add(parameter.Name, parameter.Value);
}