InstantiateAspect() public method

public InstantiateAspect ( ) : Aspect
return Aspect
Example #1
0
        private void EnsureRequiredAspect(RequiredAspectAttribute requiredAspAttrib)
        {
            bool hasAspect = this.aspects.Any(asp => asp.GetType() == requiredAspAttrib.AspectClassType);

            if (hasAspect)
            {
                return;
            }

            if (requiredAspAttrib.InstantiateIfMissing == WhenRequiredAspectIsMissing.DontInstantiate)
            {
                throw new Exception("Aspect {0} is required by \"{1}\", but is not in the caller's aspect collection.".SmartFormat(
                                        requiredAspAttrib.AspectClassType.FormatCSharp(),
                                        this.InterceptedCallMetaData.GetMethodSignature()
                                        )
                                    );
            }

            Aspect missingAspect = requiredAspAttrib.InstantiateAspect();

            this.AddAspect(missingAspect, requiredAspAttrib.InstantiateIfMissing == WhenRequiredAspectIsMissing.InstantiateAndAppend);
        }