Exemplo n.º 1
0
 /// <summary>
 /// Initializes the class with the given <paramref name="container"/> instance.
 /// </summary>
 /// <param name="container">The target service container.</param>
 public DefaultGetServiceBehavior(IServiceContainer container)
 {
     _container     = container;
     _creator       = new DefaultCreator();
     _preProcessor  = new CompositePreProcessor(container.PreProcessors);
     _postProcessor = new CompositePostProcessor(container.PostProcessors);
 }
Exemplo n.º 2
0
        public ProcessAttribute(bool authorize = false)
        {
            this.Authorize = authorize;
            Type preProcessorType = typeof(TracePreProcessor);

            this.p1 = Activator.CreateInstance(preProcessorType) as IPreProcessor;
            if (this.p1 == null)
            {
                throw new ArgumentException(String.Format("The type '{0}' does not implement interface IPreProcessor", preProcessorType.Name, "processorType"));
            }

            Type postProcessorType = typeof(TracePostProcessor);

            this.p2 = Activator.CreateInstance(postProcessorType) as IPostProcessor;
            if (this.p2 == null)
            {
                throw new ArgumentException(String.Format("The type '{0}' does not implement interface IPostProcessor", postProcessorType.Name, "postProcessorType"));
            }

            Type exceptionProcessorType = typeof(TraceExceptionProcessor);

            this.p3 = Activator.CreateInstance(exceptionProcessorType) as IPostProcessor;
            if (this.p3 == null)
            {
                throw new ArgumentException(String.Format("The type '{0}' does not implement interface IPostProcessor", exceptionProcessorType.Name, "exceptionProcessorType"));
            }

            if (Dependency.DependencyContainer.ServiceAuthorization != null)
            {
                this.p1.AddAuthorization(Dependency.DependencyContainer.ServiceAuthorization);
            }
        }
 /// <summary>
 /// Initializes the class with the given <paramref name="container"/> instance.
 /// </summary>
 /// <param name="container">The target service container.</param>
 /// <param name="creator">The <see cref="ICreateInstance"/> instance responsible for instantiating service types.</param>
 /// <param name="preProcessor">The <see cref="IPreProcessor"/> that will allow users to intercept a given service request.</param>
 /// <param name="postProcessor">The <see cref="IPostProcessor"/> instance that will handle the results of a given service request.</param>
 public DefaultGetServiceBehavior(IServiceContainer container, ICreateInstance creator, IPreProcessor preProcessor, IPostProcessor postProcessor)
 {
     _container     = container;
     _creator       = creator;
     _preProcessor  = preProcessor;
     _postProcessor = postProcessor;
 }
Exemplo n.º 4
0
 /// <summary>
 /// Initializes the class with the given <paramref name="container"/> instance.
 /// </summary>
 /// <param name="container">The target service container.</param>
 public DefaultGetServiceBehavior(IServiceContainer container)
 {
     _container = container;
     _creator = new DefaultCreator();
     _preProcessor = new CompositePreProcessor(container.PreProcessors);
     _postProcessor = new CompositePostProcessor(container.PostProcessors);
 }
Exemplo n.º 5
0
        public MainForm()
        {
            InitializeComponent();

            videoGroupBox.MinimumSize   = new Size(endingBias.Right + 1, controlGroupBox.Height);
            maskGroupBox.MinimumSize    = new Size(maskGroupBox.Width, controlGroupBox.Height);
            controlGroupBox.MinimumSize = controlGroupBox.Size;

            //TODO: this could be calculated more preciselly
            MinimumSize =
                new Size(videoGroupBox.MinimumSize.Width + maskGroupBox.MinimumSize.Width + controlGroupBox.MinimumSize.Width + 4 * controlGroupBox.Left + 3,
                         controlGroupBox.Bottom + fpsLabel.Height + mainMenuStrip.Height + 50);

            openDialog.Filter           = Constants.FileExtensions;
            openDialog.FilterIndex      = 1;
            openDialog.RestoreDirectory = true;

            initParams(parameters: null);

            pictureProcessor = new BitmapPreProcessor(this);
            blobCounter      = new PictureBlobCounter(this);
            blobKeepers      = new List <IKeeper <Blob, double, double, AForge.Point> >();

            DisplayControl.SelectedIndex = 0;


            refreshActualFrame();
        }
Exemplo n.º 6
0
		public OfflineCompiler(ICodeProviderAdapterFactory codeProviderAdapterFactory, IPreProcessor preProcessor, ICompilationContext context, AspViewCompilerOptions options, IFileSystemAdapter fileSystem)
			: base(codeProviderAdapterFactory, preProcessor, context, options)
		{
			this.fileSystem = fileSystem;
			parameters.GenerateInMemory = false;
			parameters.OutputAssembly = Path.Combine(context.BinFolder.FullName, "CompiledViews.dll");
		}
Exemplo n.º 7
0
 /// <summary>
 /// Initializes the class with the given <paramref name="container"/> instance.
 /// </summary>
 /// <param name="container">The target service container.</param>
 /// <param name="creator">The <see cref="ICreateInstance"/> instance responsible for instantiating service types.</param>
 /// <param name="preProcessor">The <see cref="IPreProcessor"/> that will allow users to intercept a given service request.</param>
 /// <param name="postProcessor">The <see cref="IPostProcessor"/> instance that will handle the results of a given service request.</param>
 public DefaultGetServiceBehavior(IServiceContainer container, ICreateInstance creator, IPreProcessor preProcessor, IPostProcessor postProcessor)
 {
     _container = container;
     _creator = creator;
     _preProcessor = preProcessor;
     _postProcessor = postProcessor;
 }
Exemplo n.º 8
0
 /// <summary>Puts a collection of given items through the preprocessor.</summary>
 /// <typeparam name="T">The type of object to process.</typeparam>
 /// <typeparam name="TypeContext">The type of the context.</typeparam>
 /// <param name="Processor">The processor to use.</param>
 /// <param name="Items">The items to process.</param>
 /// <param name="Context">The context needed to process.</param>
 public static void Preprocess <T, TypeContext>(this IPreProcessor <T, TypeContext> Processor, IEnumerable <T> Items, TypeContext Context)
 {
     foreach (T Item in Items)
     {
         Processor.Preprocess(Item, Context);
     }
 }
Exemplo n.º 9
0
 public Processor(
     IPreProcessor preProcessor,
     IAnalyzer analyzer)
 {
     this.preProcessor = preProcessor;
     this.analyzer     = analyzer;
 }
Exemplo n.º 10
0
 /// <summary>Puts a collection of given items through the preprocessor.</summary>
 /// <typeparam name="T">The type of object to process.</typeparam>
 /// <param name="Processor">The processor to use.</param>
 /// <param name="Items">The items to process.</param>
 /// <returns>Puts a collection of given items through the processor.</returns>
 public static void Preprocess <T>(this IPreProcessor <T> Processor, IEnumerable <T> Items)
 {
     foreach (T Item in Items)
     {
         Processor.Preprocess(Item);
     }
 }
Exemplo n.º 11
0
        public void Setup()
        {
            this.productDataValidator = new Mock <IProductDataValidator>(MockBehavior.Strict);
            this.queryValidator       = new Mock <IQueryValidator>(MockBehavior.Strict);

            this.preprocessor = new PreProcessor(this.productDataValidator.Object, this.queryValidator.Object);
        }
Exemplo n.º 12
0
 public PreProcessAttribute(Type preProcessorType)
 {
     this.p = Activator.CreateInstance(preProcessorType) as IPreProcessor;
     if (this.p == null)
     {
         throw new ArgumentException(String.Format("The type '{0}' does not implement interface IPreProcessor", preProcessorType.Name, "processorType"));
     }
 }
Exemplo n.º 13
0
 protected AbstractCompiler(ICodeProviderAdapterFactory codeProviderAdapterFactory, IPreProcessor preProcessor, ICompilationContext context, AspViewCompilerOptions options)
 {
     this.preProcessor = preProcessor;
     this.context      = context;
     this.options      = options;
     codeProvider      = codeProviderAdapterFactory.GetAdapter();
     InitialiseCompilerParameters(options.Debug);
 }
Exemplo n.º 14
0
		protected AbstractCompiler(ICodeProviderAdapterFactory codeProviderAdapterFactory, IPreProcessor preProcessor, ICompilationContext context, AspViewCompilerOptions options)
		{
			this.preProcessor = preProcessor;
			this.context = context;
			this.options = options;
			codeProvider = codeProviderAdapterFactory.GetAdapter();
			InitialiseCompilerParameters(options.Debug);
		}
Exemplo n.º 15
0
        /// <summary>Puts a collection of given items through the preprocessor.</summary>
        /// <typeparam name="T">The type of object to process.</typeparam>
        /// <param name="Processor">The processor to use.</param>
        /// <param name="Items">The items to process.</param>
        /// <returns>Puts a collection of given items through the processor.</returns>
        public static void Preprocess <T>(this IPreProcessor <T> Processor, IList <T> Items)
        {
            Int32 Count = Items.Count;

            for (Int32 I = 0; I < Count; I++)
            {
                Processor.Preprocess(Items[I]);
            }
        }
Exemplo n.º 16
0
        /// <summary>Puts a collection of given items through the preprocessor.</summary>
        /// <typeparam name="T">The type of object to process.</typeparam>
        /// <typeparam name="TypeContext">The type of the context.</typeparam>
        /// <param name="Processor">The processor to use.</param>
        /// <param name="Items">The items to process.</param>
        /// <param name="Context">The context needed to process.</param>
        public static void Preprocess <T, TypeContext>(this IPreProcessor <T, TypeContext> Processor, IList <T> Items, TypeContext Context)
        {
            Int32 Count = Items.Count;

            for (Int32 I = 0; I < Count; I++)
            {
                Processor.Preprocess(Items[I], Context);
            }
        }
Exemplo n.º 17
0
        /// <summary>Puts a collection of given items through the preprocessor.</summary>
        /// <typeparam name="T">The type of object to process.</typeparam>
        /// <param name="Processor">The processor to use.</param>
        /// <param name="Items">The items to process.</param>
        /// <returns>Puts a collection of given items through the processor.</returns>
        public static void Preprocess <T>(this IPreProcessor <T> Processor, T[] Items)
        {
            Int32 Count = Items.Length;

            for (Int32 I = 0; I < Count; I++)
            {
                Processor.Preprocess(Items[I]);
            }
        }
Exemplo n.º 18
0
    /// <inheritdoc/>
    public IEnumerable <CToken> Expand(IPreProcessor preProcessor, IReadOnlyList <IReadOnlyList <CToken> > arguments)
    {
        var isVariadic = this.Parameters is not null &&
                         this.Parameters.Count > 0 &&
                         this.Parameters[this.Parameters.Count - 1] == "...";
        var hasVariadicArgs = true;

        if (this.Parameters is not null && this.Parameters.Count != arguments.Count)
        {
            // This can still be ok if we are variadic and the count is only one less
            if (!isVariadic || this.Parameters.Count != arguments.Count + 1)
            {
                // TODO: Proper error handling
                throw new NotImplementedException();
            }
            if (isVariadic)
            {
                hasVariadicArgs = false;
            }
        }

        // Assign the arguments
        var argDict = new Dictionary <string, IReadOnlyList <CToken> >();

        if (this.Parameters is not null)
        {
            for (var i = 0; i < arguments.Count;)
            {
                var paramName = this.Parameters[i];
                if (paramName == "...")
                {
                    paramName = "__VA_ARGS__";
                }
                // We expand each argument to conform standards
                argDict[paramName] = preProcessor.Expand(arguments[i]).ToList();
                ++i;
            }
        }

        // If we have no variadic arguments but need it, just define it as empty
        if (!hasVariadicArgs)
        {
            argDict["__VA_ARGS__"] = Array.Empty <CToken>();
        }

        // Do the substitution
        var result = new List <CToken>();

        foreach (var element in this.body)
        {
            result.AddRange(ExpandElement(argDict, element));
        }
        return(result);
    }
        public PreProcessorPipelineBuilder Add(string pattern, IPreProcessor processor)
        {
            if (!_preProcessors.TryGetValue(pattern, out var preProcessorsByPattern))
            {
                _preProcessors[pattern] = new List <IPreProcessor>();
            }

            _preProcessors[pattern].Add(processor);

            return(this);
        }
Exemplo n.º 20
0
        public NetworkTopology()
        {
            hiddenLayers = null;
            inputLayer = null;
            outputLayer = null;

            preProcessor = null;
            postProcessor = null;

            TrainingPreProcessor = null;
            TrainingAlgorithm = null;
        }
Exemplo n.º 21
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Translator"/> class.
        /// </summary>
        /// <param name="apiKey">Your subscription key for the Microsoft Translator Text API.</param>
        /// <param name="httpClient">An alternate HTTP client to use.</param>
        public Translator(string apiKey, HttpClient httpClient = null)
        {
            if (string.IsNullOrWhiteSpace(apiKey))
            {
                throw new ArgumentNullException(nameof(apiKey));
            }

            _preProcessor          = new TranslatorPreProcessor();
            _requestBuilder        = new TranslatorRequestBuilder(apiKey);
            _responseGenerator     = new TranslatorResponseGenerator(httpClient);
            attachedPostProcessors = new List <IPostProcessor>();
        }
Exemplo n.º 22
0
        public NetworkTopology()
        {
            hiddenLayers = null;
            inputLayer   = null;
            outputLayer  = null;

            preProcessor  = null;
            postProcessor = null;

            TrainingPreProcessor = null;
            TrainingAlgorithm    = null;
        }
Exemplo n.º 23
0
 /// <summary>
 /// Defines the __COUNTER__ macro extension.
 /// </summary>
 /// <param name="preProcessor">The <see cref="IPreProcessor"/> to define the macro in.</param>
 /// <returns>The <see cref="IPreProcessor"/> to be able to chain calls.</returns>
 public static IPreProcessor DefineCounter(this IPreProcessor preProcessor) =>
 preProcessor.Define <CounterMacro>();
Exemplo n.º 24
0
 /// <summary>
 /// Defines a default-constructible <see cref="IMacro"/> in the given <see cref="IPreProcessor"/>.
 /// </summary>
 /// <typeparam name="TMacro">The type of the <see cref="IMacro"/> to define.</typeparam>
 /// <param name="preProcessor">The <see cref="IPreProcessor"/> to define the macro in.</param>
 /// <returns>The <see cref="IPreProcessor"/> to be able to chain calls.</returns>
 public static IPreProcessor Define <TMacro>(this IPreProcessor preProcessor)
     where TMacro : IMacro, new() => preProcessor.Define(_ => new TMacro());
Exemplo n.º 25
0
 /// <summary>
 /// Defines a new <see cref="IMacro"/> with a factory function in the given <see cref="IPreProcessor"/>.
 /// </summary>
 /// <param name="preProcessor">The <see cref="IPreProcessor"/> to define the macro in.</param>
 /// <param name="makeMacro">The factory function that constructs the <see cref="IMacro"/>.</param>
 /// <returns>The <see cref="IPreProcessor"/> to be able to chain calls.</returns>
 public static IPreProcessor Define(this IPreProcessor preProcessor, Func <IPreProcessor, IMacro> makeMacro)
 {
     preProcessor.Define(makeMacro(preProcessor));
     return(preProcessor);
 }
Exemplo n.º 26
0
 public OfflineCompiler(ICodeProviderAdapterFactory codeProviderAdapterFactory, IPreProcessor preProcessor, ICompilationContext context, AspViewCompilerOptions options, IFileSystemAdapter fileSystem)
     : base(codeProviderAdapterFactory, preProcessor, context, options)
 {
     this.fileSystem             = fileSystem;
     parameters.GenerateInMemory = false;
     parameters.OutputAssembly   = Path.Combine(context.BinFolder.FullName, "CompiledViews.dll");
 }
 public ModelTransformationTypedBindings(IPreProcessor preProcessor)
 {
     this.preProcessor = preProcessor;
 }
Exemplo n.º 28
0
 public static void RegisterPreProcessor(IPreProcessor preProcessor)
 {
     PreProcessors.Add(preProcessor);
 }
Exemplo n.º 29
0
 public ProcessAttribute(Type processorType)
 {
     this.postProcessor = Activator.CreateInstance(processorType) as IPostProcessor;
     if (this.postProcessor == null)
         throw new ArgumentException(String.Format("The type '{0}' does not implement interface IPostProcessor", processorType.Name, "processorType"));
     this.preProcesser = Activator.CreateInstance(processorType) as IPreProcessor;
     if (this.preProcesser == null)
         throw new ArgumentException(String.Format("The type '{0}' does not implement interface IPreProcessor", processorType.Name, "processorType"));
 }
Exemplo n.º 30
0
 public ProviderWrapper(IProvider provider, IPreProcessor preProcessor, IHandler handler)
 {
     _provider     = provider;
     _preProcessor = preProcessor;
     _handler      = handler;
 }
Exemplo n.º 31
0
 public DefaultPreProcessorBindings(IPreProcessor preProcessor)
 {
     this.preProcessor = preProcessor;
 }
Exemplo n.º 32
0
 public MailProvider(IHandler handler,
                     IPreProcessor preProcessor)
 {
     this.handler      = handler;
     this.preProcessor = preProcessor;
 }
Exemplo n.º 33
0
 /// <inheritdoc/>
 public IEnumerable <CToken> Expand(IPreProcessor preProcessor, IReadOnlyList <IReadOnlyList <CToken> > arguments)
 {
     var str = (this.count++).ToString();
     // TODO: Proper range?
     var token = new CToken(default, str, default, str, CTokenType.IntLiteral);
Exemplo n.º 34
0
 public PreProcessorExpression(IPreProcessor preProcessor, string text)
 {
     this.preProcessor = preProcessor;
     this.text         = text;
 }
Exemplo n.º 35
0
		public OnlineCompiler(ICodeProviderAdapterFactory codeProviderAdapterFactory, IPreProcessor preProcessor, ICompilationContext context, AspViewCompilerOptions options) : base(codeProviderAdapterFactory, preProcessor, context, options)
		{
			parameters.GenerateInMemory = true;
		}
Exemplo n.º 36
0
 public OnlineCompiler(ICodeProviderAdapterFactory codeProviderAdapterFactory, IPreProcessor preProcessor, ICompilationContext context, AspViewCompilerOptions options) : base(codeProviderAdapterFactory, preProcessor, context, options)
 {
     parameters.GenerateInMemory = true;
 }