public Boolean RemoveParameter(CILParameter parameter) { this.ThrowIfNotCapableOfChanging(); var result = LogicalUtils.RemoveFromResettableLazyList(this.parameters, parameter); if (result) { this.context.Cache.ForAllGenericInstancesOf <CILMethodBase, CILMethodBaseInternal>(this, method => method.ResetParameterList()); } return(result); }
public CILEvent ChangeDeclaringType(params CILTypeBase[] args) { LogicalUtils.ThrowIfDeclaringTypeNotGeneric(this, args); CILEvent evtToGive = this; CILType dt = this.declaringType.Value; if (dt.GenericDefinition != null) { evtToGive = dt.GenericDefinition.DeclaredEvents[dt.DeclaredEvents.IndexOf(this)]; } return(this.context.Cache.MakeEventWithGenericType(evtToGive, args)); }
public CILProperty ChangeDeclaringType(params CILTypeBase[] args) { LogicalUtils.ThrowIfDeclaringTypeNotGeneric(this, args); CILProperty propToGive = this; CILType dt = this.declaringType.Value; if (dt.GenericDefinition != null) { propToGive = dt.GenericDefinition.DeclaredProperties[dt.DeclaredProperties.IndexOf(this)]; } return(this.context.Cache.MakePropertyWithGenericType(propToGive, args)); }
public CILMethodBase ChangeDeclaringTypeUT(params CILTypeBase[] args) { // TODO return this if decl type has no gArgs and args is empty. LogicalUtils.ThrowIfDeclaringTypeNotGeneric(this, args); var gDef = this.declaringType.Value.GenericDefinition; var thisMethod = this.ThisOrGDef(); return(this.MakeGenericIfNeeded(this.context.Cache.MakeMethodWithGenericDeclaringType( gDef == null ? this : (API.MethodKind.Method == this.methodKind ? (CILMethodBase)gDef.DeclaredMethods[this.declaringType.Value.DeclaredMethods.IndexOf((CILMethod)thisMethod)] : gDef.Constructors[this.declaringType.Value.Constructors.IndexOf((CILConstructor)thisMethod)]), args ))); }
public CILField ChangeDeclaringType(params CILTypeBase[] args) { LogicalUtils.ThrowIfDeclaringTypeNotGeneric(this, args); CILField fieldToGive = this; CILType dt = this.declaringType.Value; if (dt.GenericDefinition != null) { fieldToGive = dt.GenericDefinition.DeclaredFields[dt.DeclaredFields.IndexOf(this)]; } return(this.context.Cache.MakeFieldWithGenericDeclaringType(fieldToGive, args)); }
public void AddOverriddenMethods(params CILMethod[] explicitlyOverriddenMethods) { this.ThrowIfNotCapableOfChanging(); foreach (var method in explicitlyOverriddenMethods) { if (Object.ReferenceEquals(this, method.GetTrueGenericDefinition())) { throw new ArgumentException("Method must not be itself."); } //else if ( !this.declaringType.Value.FullInheritanceChain().Contains( method.DeclaringType ) ) //{ // throw new ArgumentException( "Given methods must be all from inheritance hierarchy of this method's (" + this + ") declaring type (" + this.DeclaringType + ")." ); //} } lock (this.overriddenMethodsLock) { this.overriddenMethods.Value.AddRange(explicitlyOverriddenMethods); LogicalUtils.CheckMethodAttributesForOverriddenMethods(this.methodAttributes, this.overriddenMethods.Value); } }
public CILTypeParameter[] DefineGenericParameters(String[] names) { CILTypeParameter[] result; this.ThrowIfNotCapableOfChanging(); lock (this.gArgsLock) { LogicalUtils.CheckWhenDefiningGArgs(this.gArgs.Value, names); if (names != null && names.Length > 0) { result = Enumerable.Range(0, names.Length).Select(idx => this.context.Cache.NewBlankTypeParameter(this.declaringType.Value, this, names[idx], idx)).ToArray(); this.gArgs.Value.AddRange(result); this.gDef.Value = this; } else { result = CILTypeImpl.EMPTY_TYPE_PARAMS; } } return(result); }