Esempio n. 1
0
        /// <summary>
        /// Add filter type
        /// </summary>
        /// <param name="filterType">Filter type</param>
        public void AddFilterType(FilterTypeElement filterType)
        {
            if (filterType == null)
            {
                throw new ArgumentNullException("filterType");
            }

            _filterTypes.Add(filterType);
        }
Esempio n. 2
0
        public void AcceptReturnActionTest()
        {
            FilterTypeElement target = new FilterTypeElement();

            string val = null; // TODO: Assign to an appropriate value for the property

            target.AcceptReturnAction = val;


            Assert.AreEqual(val, target.AcceptReturnAction, "Composestar.StarLight.Entities.Configuration.FilterTypeElement.AcceptReturnAction" +
                            " was not set correctly.");
            Assert.Inconclusive("Verify the correctness of this test method.");
        }
Esempio n. 3
0
        /// <summary>
        /// Extracts the type of the filter.
        /// </summary>
        /// <param name="type">The type.</param>
        private void ExtractFilterType(TypeDefinition type)
        {
            // We use .NET reflection here, because Cecil can not read the enumerations

            // TODO Loading an assembly locks the assembly for the duration of the appdomain.
            // The weaver can no loner access the file to weave in it.
            // We now use ShadowCopy to overcome this. It is an obsolete method
            // Switch to a separate appdomain.

            SetupReflectionAssembly(type.Module.Image.FileInformation.Directory.FullName);

            Assembly assembly = Assembly.LoadFrom(type.Module.Image.FileInformation.FullName);

            if (assembly == null)
            {
                throw new ILAnalyzerException(string.Format(CultureInfo.CurrentCulture, Properties.Resources.CouldNotFindAssembly, type.Module.Image.FileInformation.FullName));
            }

            Type refType = assembly.GetType(type.FullName);

            if (refType == null)
            {
                throw new ILAnalyzerException(string.Format(CultureInfo.CurrentCulture, Properties.Resources.CouldNotFindType, type.FullName));
            }

            FilterTypeAttribute[] ftas = (FilterTypeAttribute[])refType.GetCustomAttributes(typeof(FilterTypeAttribute), true);
            foreach (FilterTypeAttribute fta in ftas)
            {
                FilterTypeElement ftEl = new FilterTypeElement();
                _filterTypes.Add(ftEl);

                ftEl.Name               = fta.Name;
                ftEl.AcceptCallAction   = fta.AcceptCallAction;
                ftEl.RejectCallAction   = fta.RejectCallAction;
                ftEl.AcceptReturnAction = fta.AcceptReturnAction;
                ftEl.RejectReturnAction = fta.RejectReturnAction;
            }
        }