Esempio n. 1
0
 protected AbstractTest(Assembly assembly, String path)
 {
     _assembly = assembly;
     _helper = new InspectionHelper(_assembly);
     _faults = new List<MemberInfo>();
     _assemblyLocation = path;
 }
Esempio n. 2
0
        public FeatureExpression(Type featureType,
                                 string name,
                                 Func <Expression, Expression> valueExpressionFactory,
                                 List <Func <Expression, Expression> > valueValidExpressionFactories = null,
                                 NewFeatureExpressionDelegate featureExpressionFactory = null,
                                 string @namespace   = null,
                                 char?featureGroup   = null,
                                 bool enumerize      = false,
                                 string variableName = null,
                                 int?order           = null,
                                 bool addAnchor      = false,
                                 StringProcessing stringProcessing  = StringProcessing.Split,
                                 MethodInfo overrideSerializeMethod = null,
                                 bool?dictify = null)
        {
            if (featureType == null)
            {
                throw new ArgumentNullException("featureType");
            }

            if (valueExpressionFactory == null)
            {
                throw new ArgumentNullException("valueExpressionFactory");
            }

            Contract.EndContractBlock();

            if (featureType.IsGenericType &&
                featureType.GetGenericTypeDefinition() == typeof(Nullable <>))
            {
                this.IsNullable  = true;
                this.FeatureType = featureType.GetGenericArguments()[0];
            }
            else
            {
                this.IsNullable  = false;
                this.FeatureType = featureType;
            }

            this.Name = name;
            this.ValueExpressionFactory        = valueExpressionFactory;
            this.ValueValidExpressionFactories = valueValidExpressionFactories;
            this.FeatureExpressionFactory      = featureExpressionFactory;
            this.Namespace               = @namespace;
            this.FeatureGroup            = featureGroup;
            this.Enumerize               = enumerize;
            this.VariableName            = variableName ?? name;
            this.Order                   = order ?? 1;
            this.AddAnchor               = addAnchor;
            this.Dictify                 = dictify ?? false;
            this.StringProcessing        = stringProcessing;
            this.OverrideSerializeMethod = overrideSerializeMethod;
            this.Dictify                 = dictify ?? false;

            this.DenseFeatureValueElementType = InspectionHelper.GetDenseFeatureValueElementType(featureType);
        }
Esempio n. 3
0
        public void Initialize()
        {
            if (!initialized)
            {
                initialized = true;

                List <QuestionPage> pages = InspectionHelper.GenerateQuestionPages(section.Questions, inspection, this);
                foreach (ContentPage page in pages)
                {
                    Children.Add(page);
                }
            }
        }
Esempio n. 4
0
        public PartPage(SectionPart part, Inspection inspection, SectionWithPartsPage sectionPage)
        {
            this.part       = part;
            this.inspection = inspection;
            Title           = "Part " + part.Label;
            Icon            = "TabIconGreenNoBG.png";
            List <QuestionPage> pages = InspectionHelper.GenerateQuestionPages(part.Questions, inspection, sectionPage);

            foreach (ContentPage page in pages)
            {
                Children.Add(page);
            }
            UpdateIcon(true);
            this.CurrentPageChanged += PartPage_CurrentPageChanged;
        }
Esempio n. 5
0
        public PartPage(SectionPart part, Inspection inspection, SectionWithPartsPage sectionPage)
        {
            this.part       = part;
            this.inspection = inspection;
            parentPage      = sectionPage;
            Title           = "Part " + part.Label;
            List <QuestionPage> pages = InspectionHelper.GenerateQuestionPages(part.Questions, inspection, sectionPage);

            foreach (ContentPage page in pages)
            {
                Children.Add(page);
            }
            //InspectionHelper.InitializePages(pages);
            UpdateIcon();
            this.CurrentPageChanged += PartPage_CurrentPageChanged;
        }
Esempio n. 6
0
        public static IVowpalWabbitSerializerCompiler <TExample> TryCreate <TExample>(VowpalWabbitSettings settings, Schema schema)
        {
            // check for _multi
            var multiFeature = schema.Features.FirstOrDefault(fe => fe.Name == settings.PropertyConfiguration.MultiProperty);

            if (multiFeature == null)
            {
                return(null);
            }

            // multi example path
            // IEnumerable<> or Array
            var adfType = InspectionHelper.GetEnumerableElementType(multiFeature.FeatureType);

            if (adfType == null)
            {
                throw new ArgumentException(settings.PropertyConfiguration.MultiProperty + " property must be array or IEnumerable<>. Actual type: " + multiFeature.FeatureType);
            }

            var compilerType = typeof(VowpalWabbitMultiExampleSerializerCompilerImpl <,>).MakeGenericType(typeof(TExample), adfType);

            return((IVowpalWabbitSerializerCompiler <TExample>)Activator.CreateInstance(compilerType, settings, schema, multiFeature));
        }
        internal static IVowpalWabbitSerializerCompiler <TExample> TryCreate <TExample>(VowpalWabbitSettings settings, List <FeatureExpression> allFeatures)
        {
            // check for _multi
            var multiFeature = allFeatures.FirstOrDefault(fe => fe.Name == VowpalWabbitConstants.MultiProperty);

            if (multiFeature == null)
            {
                return(null);
            }

            // multi example path
            // IEnumerable<> or Array
            var adfType = InspectionHelper.GetEnumerableElementType(multiFeature.FeatureType);

            if (adfType == null)
            {
                throw new ArgumentException("_multi property must be array or IEnumerable<>. Actual type: " + multiFeature.FeatureType);
            }

            var compilerType = typeof(VowpalWabbitMultiExampleSerializerCompilerImpl <,>).MakeGenericType(typeof(TExample), adfType);

            return((IVowpalWabbitSerializerCompiler <TExample>)Activator.CreateInstance(compilerType, settings, allFeatures, multiFeature));
        }