Exemple #1
0
        private void AddTrackedMethod(MutableMethodInfo method)
        {
            _addedMethods.Add(method);

            UpdateAllMethods(method);
            UpdateAbstractMethods(method);

            method.BodyChanged += (sender, args) => UpdateAbstractMethods((MutableMethodInfo)sender);
            method.ExplicitBaseDefinitionAdded += (sender, args) => UpdateAbstractMethods((MutableMethodInfo)sender);
        }
Exemple #2
0
 public MutableEventInfo(
     MutableType declaringType,
     string name,
     EventAttributes attributes,
     MutableMethodInfo addMethod,
     MutableMethodInfo removeMethod,
     MutableMethodInfo raiseMethod)
     : base(declaringType, name, attributes, addMethod, removeMethod, raiseMethod)
 {
 }
Exemple #3
0
        public MutableEventInfo AddEvent(
            string name, EventAttributes attributes, MutableMethodInfo addMethod, MutableMethodInfo removeMethod, MutableMethodInfo raiseMethod = null)
        {
            ArgumentUtility.CheckNotNullOrEmpty("name", name);
            ArgumentUtility.CheckNotNull("addMethod", addMethod);
            ArgumentUtility.CheckNotNull("removeMethod", removeMethod);
            // Raise method may be null.

            var event_ = _mutableMemberFactory.CreateEvent(this, name, attributes, addMethod, removeMethod, raiseMethod);

            _addedEvents.Add(event_);

            return(event_);
        }
Exemple #4
0
        private void UpdateAbstractMethods(MutableMethodInfo method)
        {
            var baseDefinition          = MethodBaseDefinitionCache.GetBaseDefinition(method);
            var explicitBaseDefinitions = method.AddedExplicitBaseDefinitions;

            if (method.IsAbstract)
            {
                _baseDefinitionsOfAbstractMethods.Add(baseDefinition);
                _baseDefinitionsOfAbstractMethods.UnionWith(explicitBaseDefinitions);
            }
            else
            {
                _baseDefinitionsOfAbstractMethods.Remove(baseDefinition);
                _baseDefinitionsOfAbstractMethods.ExceptWith(explicitBaseDefinitions);
            }
        }
Exemple #5
0
        private void UpdateAllMethods(MutableMethodInfo method)
        {
            var overriddenBaseDefinition = MethodBaseDefinitionCache.GetBaseDefinition(method);
            int existingIndex;

            if (_allMethodsIndex.TryGetValue(overriddenBaseDefinition, out existingIndex))
            {
                // Remove overridden methods.
                _allMethods[existingIndex] = null;
                _allMethodsIndex.Remove(overriddenBaseDefinition);
            }
            _allMethods.Add(method);
            int newMethodIndex = _allMethods.Count - 1;

            _allMethodsIndex.Add(method, newMethodIndex);
        }
Exemple #6
0
        public MutablePropertyInfo(
            MutableType declaringType, string name, PropertyAttributes attributes, MutableMethodInfo getMethod, MutableMethodInfo setMethod)
            : base(declaringType, name, attributes, getMethod, setMethod)
        {
            IEnumerable <ParameterInfo> indexParameters;

            if (getMethod != null)
            {
                indexParameters = getMethod.GetParameters();
            }
            else
            {
                var setMethodParameters = setMethod.GetParameters();
                indexParameters = setMethodParameters.Take(setMethodParameters.Length - 1);
            }

            _indexParameters = indexParameters.Select(p => new PropertyParameterInfoWrapper(this, p)).ToList().AsReadOnly();
        }
Exemple #7
0
        public MutablePropertyInfo AddProperty(string name, PropertyAttributes attributes, MutableMethodInfo getMethod, MutableMethodInfo setMethod)
        {
            ArgumentUtility.CheckNotNullOrEmpty("name", name);
            // Set method may be null (for write-only properties).
            // Get method may be null (for read-only properties).

            var property = _mutableMemberFactory.CreateProperty(this, name, attributes, getMethod, setMethod);

            _addedProperties.Add(property);

            return(property);
        }