本文整理汇总了C#中IGenericParameterProvider类的典型用法代码示例。如果您正苦于以下问题:C# IGenericParameterProvider类的具体用法?C# IGenericParameterProvider怎么用?C# IGenericParameterProvider使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IGenericParameterProvider类属于命名空间,在下文中一共展示了IGenericParameterProvider类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Fix
private TypeReference Fix(TypeReference type, IGenericParameterProvider context)
{
if (type == null || type.IsDefinition)
return type;
if (type.IsGenericParameter)
{
var genPar = (GenericParameter)type;
if (!fixedGenericParameters.Contains(genPar))
{
fixedGenericParameters.Add(genPar);
FixReferences(genPar.Constraints, context);
FixReferences(genPar.CustomAttributes, context);
}
return type;
}
if (type is TypeSpecification)
return Fix((TypeSpecification)type, context);
var t2 = repack.GetMergedTypeFromTypeRef(type);
if (t2 != null)
return t2;
if (type.IsNested)
type.DeclaringType = Fix(type.DeclaringType, context);
if (type.DeclaringType is TypeDefinition)
return ((TypeDefinition)type.DeclaringType).NestedTypes.FirstOrDefault(x => x.FullName == type.FullName);
return type;
}
示例2: Push
public void Push (IGenericParameterProvider provider)
{
if (stack == null)
stack = new Collection<IGenericParameterProvider> (1) { provider };
else
stack.Add (provider);
}
示例3: ImportGenericParameters
public static void ImportGenericParameters(IGenericParameterProvider imported, Type original)
{
var parameters = original.GetGenericTypeDefinition().GetGenericArguments();
var imported_parameters = imported.GenericParameters;
for (int i = 0; i < parameters.Length; i++)
imported_parameters.Add(new GenericParameter(parameters[i].Name, imported));
}
示例4: CheckProvider
internal void CheckProvider (IGenericParameterProvider provider, int count)
{
if (!AllowCreation)
return;
for (int i = provider.GenericParameters.Count; i < count; i++)
provider.GenericParameters.Add (new GenericParameter (provider));
}
示例5: CopyGenericParameters
public static void CopyGenericParameters(IGenericParameterProvider source, IGenericParameterProvider target, ReferenceResolver resolver)
{
if (!source.HasGenericParameters)
return;
foreach (var parameter in source.GenericParameters)
target.InjectGenericParameter(parameter, resolver);
}
示例6: GetGenericParameter
public TypeReference GetGenericParameter(GenericParameter genericParamter, IGenericParameterProvider[] paramProviders)
{
#if GENERIC
IGenericParameterProvider context = GetContext(genericParamter, paramProviders);
return context.GenericParameters[genericParamter.Position];
#else
return type;
#endif
}
示例7: GetGenericParameters
public static Collection<GenericParameter> GetGenericParameters(
IGenericParameterProvider self,
ref Collection<GenericParameter> collection,
ModuleDefinition module)
{
return Mixin.HasImage(module)
? module.Read(ref collection, self, (provider, reader) => reader.ReadGenericParameters(provider))
: collection = new GenericParameterCollection(self);
}
示例8: Process
static void Process (IGenericParameterProvider provider)
{
if (!provider.HasGenericParameters)
return;
foreach (var parameter in provider.GenericParameters)
Process (parameter);
}
示例9: GenericParameter
public GenericParameter(string name, IGenericParameterProvider owner)
: base(string.Empty, name)
{
if (owner == null)
throw new ArgumentNullException ();
this.owner = owner;
this.etype = owner.GenericParameterType == GenericParameterType.Type ? ElementType.Var : ElementType.MVar;
}
示例10: GenericContext
public GenericContext(IGenericParameterProvider provider)
{
if (provider is TypeReference)
m_type = provider as TypeReference;
else if (provider is MethodReference) {
MethodReference meth = provider as MethodReference;
m_method = meth;
m_type = meth.DeclaringType;
}
}
示例11: ContainsGenericParameter
public static bool ContainsGenericParameter(IGenericParameterProvider provider, TypeReference parameter)
{
foreach (var param in provider.GenericParameters)
{
if (param.MetadataToken == parameter.MetadataToken)
{
return true;
}
}
return false;
}
示例12: AssertGenericParametersAreIdentical
private void AssertGenericParametersAreIdentical(IGenericParameterProvider expected, IGenericParameterProvider actual)
{
Assert.Equal(expected.HasGenericParameters, actual.HasGenericParameters);
for (var i = 0; i < expected.GenericParameters.Count; i += 1)
{
var ap = expected.GenericParameters[i];
var bp = actual.GenericParameters[i];
Assert.Equal(ap.Name, bp.Name);
Assert.Equal(ap.Position, bp.Position);
}
}
示例13: Process
public void Process(IGenericParameterProvider provider)
{
if (!provider.HasGenericParameters)
{
return;
}
foreach (var parameter in provider.GenericParameters
.Where(x => x.HasCustomAttributes))
{
Process(parameter);
}
}
示例14: GenericTypeFor
static TypeReference GenericTypeFor (IGenericParameterProvider context)
{
var type = context as TypeReference;
if (type != null)
return type.GetElementType ();
var method = context as MethodReference;
if (method != null)
return method.DeclaringType.GetElementType ();
throw new InvalidOperationException ();
}
示例15: Fix
internal MethodReference Fix(MethodReference method, IGenericParameterProvider context)
{
TypeReference declaringType = Fix(method.DeclaringType, context);
if (method.IsGenericInstance)
{
return Fix((GenericInstanceMethod)method, context);
}
// if declaring type is in our new merged module, return the definition
if (declaringType.IsDefinition && !method.IsDefinition)
{
MethodDefinition def = new ReflectionHelper(repack).FindMethodDefinitionInType((TypeDefinition)declaringType, method);
if (def != null)
return def;
}
method.DeclaringType = declaringType;
method.ReturnType = Fix(method.ReturnType, method);
FixReferences(method.Parameters, method);
FixReferences(method.GenericParameters, method);
if (!method.IsDefinition &&
!method.DeclaringType.IsGenericInstance &&
!method.DeclaringType.IsArray &&
(method.ReturnType.IsDefinition || method.Parameters.Any(x => x.ParameterType.IsDefinition)))
{
var culprit = method.ReturnType.IsDefinition
? method.ReturnType
: method.Parameters.First(x => x.ParameterType.IsDefinition).ParameterType;
// warn about invalid merge assembly set, as this method is not gonna work fine (peverify would warn as well)
repack.WARN("Method reference is used with definition return type / parameter. Indicates a likely invalid set of assemblies, consider one of the following");
repack.WARN(" - Remove the assembly defining " + culprit + " from the merge");
repack.WARN(" - Add assembly defining " + method + " to the merge");
// one case where it'll work correctly however (but doesn't seem common):
// A references B
// C references A
// C is merged into B
}
return method;
}