コード例 #1
0
 private bool Matches(TypeReference selfType, TypeDefinition composition)
 {
     var toMatch = composition.ResolveGenericArguments();
       if (composition.IsRole()) {
     // if the composition is a role with a self-type, the self-type must flow through it
     toMatch = _extractor.RetrieveSelfType(toMatch) ?? toMatch;
       }
       return TypeMatcher.IsMatch(toMatch, selfType);
 }
コード例 #2
0
        public RoleComposerResult ComposeRoles(MutationParameters parameters)
        {
            parameters.Validate();
              _targetType = parameters.SourceType;
              if (_targetType == null) throw new ArgumentException("parameters must contain a SourceType", "parameters");

              Tracer.TraceVerbose("Compose class: {0}", _targetType.ToString());

              var result = new RoleComposerResult();

              CheckComposition(result);
              if (!result.Success) { return result; }

              var roles = RetrieveRoles();

              var conflictDetector = new ConflictDetector(_targetType);
              {
            var memberProcessResult = conflictDetector.Process(roles);
            result.AddResult(memberProcessResult);
            if (!memberProcessResult.Success) {
              return result;
            }
              }

              if (_targetType.IsRole()) {
            // roles are not composed
            return result;
              }

              {
            _container = conflictDetector.Container;
            var composeResult = ComposeRoles(roles);
            result.AddResult(composeResult);
            if (!composeResult.Success) {
              return result;
            }
              }

              return result;
        }