コード例 #1
0
        private void OnRecommendMovie(object obj)
        {
            var dataRepository = Container.GetInstance <IDataRepository>();
            var userMovies     = dataRepository.TrainingRatings.Where(r => r.User == SelectedUser).Select(r => r.Movie);

            var unratedMovies = new ConcurrentBag <Movie>();

            Parallel.ForEach(dataRepository.Movies, movie =>
            {
                if (!userMovies.Contains(movie))
                {
                    unratedMovies.Add(movie);
                }
            });

            var results = new ConcurrentBag <IRating>();

            Parallel.ForEach(unratedMovies, m =>
            {
                try
                {
                    var rating = SelectedMethod.RecommendSubject(SelectedUser, m);
                    if (rating != null)
                    {
                        results.Add(rating);
                    }
                }
                catch (Exception)
                {
                }
            });

            RecommendedMovies = new ObservableCollection <IRating>(results.OrderBy(r => r.Value).Reverse().Take(10));
        }
コード例 #2
0
        /// <summary>
        /// Return the sequence of methods to call while building the target object.
        /// </summary>
        /// <param name="context">Current build context.</param>
        /// <param name="resolverPolicyDestination">The <see cref='IPolicyList'/> to add any
        /// generated resolver objects into.</param>
        /// <returns>Sequence of methods to call.</returns>
        public IEnumerable <SelectedMethod> SelectMethods(IBuilderContext context, IPolicyList resolverPolicyDestination)
        {
            foreach (Pair <MethodInfo, IEnumerable <InjectionParameterValue> > method in methods)
            {
                Type                   typeToBuild = context.BuildKey.Type;
                SelectedMethod         selectedMethod;
                ReflectionHelper       typeReflector   = new ReflectionHelper(method.First.DeclaringType);
                MethodReflectionHelper methodReflector = new MethodReflectionHelper(method.First);
                if (!methodReflector.MethodHasOpenGenericParameters && !typeReflector.IsOpenGeneric)
                {
                    selectedMethod = new SelectedMethod(method.First);
                }
                else
                {
                    Type[] closedMethodParameterTypes =
                        methodReflector.GetClosedParameterTypes(typeToBuild.GetTypeInfo().GenericTypeArguments);
                    selectedMethod = new SelectedMethod(
                        typeToBuild.GetMethodHierarchical(method.First.Name, closedMethodParameterTypes));
                }

                SpecifiedMemberSelectorHelper.AddParameterResolvers(
                    typeToBuild,
                    resolverPolicyDestination,
                    method.Second,
                    selectedMethod);
                yield return(selectedMethod);
            }
        }
コード例 #3
0
 private void Sort()
 {
     //var result = SelectedMethod.Command(array);
     //Document = result.CreateDocument();
     Result   = SelectedMethod.Command(array);
     Document = Result.CreateDocument();
 }
コード例 #4
0
 /// <summary>
 /// Return the sequence of methods to call while building the target object.
 /// </summary>
 /// <param name="context">Current build context.</param>
 /// <returns>Sequence of methods to call.</returns>
 public IEnumerable <SelectedMethod> SelectMethods(IBuilderContext context)
 {
     foreach (Pair <MethodInfo, IEnumerable <InjectionParameterValue> > method in methods)
     {
         Type                   typeToBuild = BuildKey.GetType(context.BuildKey);
         SelectedMethod         selectedMethod;
         ReflectionHelper       typeReflector   = new ReflectionHelper(method.First.DeclaringType);
         MethodReflectionHelper methodReflector = new MethodReflectionHelper(method.First);
         if (!methodReflector.MethodHasOpenGenericParameters && !typeReflector.IsOpenGeneric)
         {
             selectedMethod = new SelectedMethod(method.First);
         }
         else
         {
             Type[] closedMethodParameterTypes =
                 methodReflector.GetClosedParameterTypes(typeToBuild.GetGenericArguments());
             selectedMethod = new SelectedMethod(
                 typeToBuild.GetMethod(method.First.Name, closedMethodParameterTypes));
         }
         SpecifiedMemberSelectorHelper.AddParameterResolvers(
             typeToBuild,
             context.PersistentPolicies,
             method.Second,
             selectedMethod);
         yield return(selectedMethod);
     }
 }
コード例 #5
0
ファイル: AnalyserViewModel.cs プロジェクト: pierrekhoury/MWA
 private void NotifyFrameChanged()
 {
     if (SelectedMethod != null)
     {
         SelectedMethod.PropagateFrameChangedNotifications(IndexNumber);
     }
 }
コード例 #6
0
        /// <summary>
        /// called after we've safely navigated the browser to about:blank
        /// to avoid the situation where we try to over-write but can't
        /// </summary>
        private void ContinueConversionAndNavigation()
        {
            if (IsAlreadyOpenElsewhere(_incomingPath))
            {
                ErrorReport.NotifyUserOfProblem("That file appears to be open. First close it, then try again.");
            }

            _pathToCurrentlyDisplayedPdf = Path.Combine(Path.GetTempPath(),
                                                        Path.GetFileNameWithoutExtension(_incomingPath) +
                                                        "-booklet.pdf");
            //                _pathToCurrentlyDisplayedPdf = Path.Combine(Path.GetDirectoryName(_incomingPath), Path.GetFileNameWithoutExtension(_incomingPath) + "-booklet.pdf");

            if (!DeleteFileThatMayBeInUse(_pathToCurrentlyDisplayedPdf))
            {
                ErrorReport.NotifyUserOfProblem("For some reason that file is stuck... please try that again.");
            }


            try
            {
                SelectedMethod.Layout(_inputPdf, _incomingPath, _pathToCurrentlyDisplayedPdf, PaperTarget, Settings.Default.RightToLeft, Settings.Default.ShowCropMarks);
                _view.Navigate(_pathToCurrentlyDisplayedPdf);
            }
            catch (Exception error)
            {
                ErrorReport.NotifyUserOfProblem(error, "PdfBooklet was unable to convert that file.");
            }
            _view.UpdateDisplay();
        }
コード例 #7
0
 /// <summary>
 ///   Return the sequence of methods to call while building the target object.
 /// </summary>
 /// <param name = "context">Current build context.</param>
 /// <param name = "resolverPolicyDestination">The <see cref = 'IPolicyList' /> to add any
 ///   generated resolver objects into.</param>
 /// <returns>Sequence of methods to call.</returns>
 public IEnumerable<SelectedMethod> SelectMethods(IBuilderContext context, IPolicyList resolverPolicyDestination)
 {
     foreach (Pair<MethodInfo, IEnumerable<InjectionParameterValue>> method in methods)
     {
         Type typeToBuild = context.BuildKey.Type;
         SelectedMethod selectedMethod;
         var typeReflector = new ReflectionHelper(method.First.DeclaringType);
         var methodReflector = new MethodReflectionHelper(method.First);
         if (!methodReflector.MethodHasOpenGenericParameters && !typeReflector.IsOpenGeneric)
         {
             selectedMethod = new SelectedMethod(method.First);
         }
         else
         {
             Type[] closedMethodParameterTypes =
                 methodReflector.GetClosedParameterTypes(typeToBuild.GetGenericArguments());
             selectedMethod = new SelectedMethod(
                 typeToBuild.GetMethod(method.First.Name, closedMethodParameterTypes));
         }
         SpecifiedMemberSelectorHelper.AddParameterResolvers(
             typeToBuild,
             resolverPolicyDestination,
             method.Second,
             selectedMethod);
         yield return selectedMethod;
     }
 }
コード例 #8
0
        /// <summary>
        /// Return the sequence of methods to call while building the target object.
        /// </summary>
        /// <param name="context">Current build context.</param>
        /// <param name="resolverPolicyDestination">The <see cref='IPolicyList'/> to add any
        /// generated resolver objects into.</param>
        /// <returns>Sequence of methods to call.</returns>
        public IEnumerable <SelectedMethod> SelectMethods(IBuilderContext context, IPolicyList resolverPolicyDestination)
        {
            foreach (Tuple <MethodInfo, IEnumerable <InjectionParameterValue> > method in _methods)
            {
                Type           typeToBuild = context.BuildKey.Type;
                SelectedMethod selectedMethod;
                var            info = method.Item1.DeclaringType.GetTypeInfo();
                var            methodHasOpenGenericParameters = method.Item1.GetParameters()
                                                                .Select(p => p.ParameterType.GetTypeInfo())
                                                                .Any(i => i.IsGenericType && i.ContainsGenericParameters);
                if (!methodHasOpenGenericParameters && !(info.IsGenericType && info.ContainsGenericParameters))
                {
                    selectedMethod = new SelectedMethod(method.Item1);
                }
                else
                {
                    var closedMethodParameterTypes = method.Item1
                                                     .GetClosedParameterTypes(typeToBuild.GetTypeInfo().GenericTypeArguments);

                    selectedMethod = new SelectedMethod(typeToBuild.GetMethodsHierarchical()
                                                        .Single(m => m.Name.Equals(method.Item1.Name) &&
                                                                m.GetParameters().ParametersMatch(closedMethodParameterTypes)));
                }

                AddParameterResolvers(typeToBuild, resolverPolicyDestination,
                                      method.Item2, selectedMethod);

                yield return(selectedMethod);
            }
        }
コード例 #9
0
 /// <summary>
 /// Return the sequence of methods to call while building the target object.
 /// </summary>
 /// <param name="context">Current build context.</param>
 /// <returns>Sequence of methods to call.</returns>
 public IEnumerable<SelectedMethod> SelectMethods(IBuilderContext context)
 {
     foreach(Pair<MethodInfo, IEnumerable<InjectionParameterValue>> method in methods)
     {
         SelectedMethod selectedMethod = new SelectedMethod(method.First);
         SpecifiedMemberSelectorHelper.AddParameterResolvers(context.PersistentPolicies, method.Second, selectedMethod);
         yield return selectedMethod;
     }
 }
コード例 #10
0
 /// <summary>
 /// Return the sequence of methods to call while building the target object.
 /// </summary>
 /// <param name="context">Current build context.</param>
 /// <returns>Sequence of methods to call.</returns>
 public IEnumerable <SelectedMethod> SelectMethods(IBuilderContext context)
 {
     foreach (Pair <MethodInfo, IEnumerable <InjectionParameterValue> > method in methods)
     {
         SelectedMethod selectedMethod = new SelectedMethod(method.First);
         AddParameterResolvers(context.PersistentPolicies, method.Second, selectedMethod);
         yield return(selectedMethod);
     }
 }
コード例 #11
0
            public IEnumerable <SelectedMethod> SelectMethods(IBuilderContext context, IPolicyList resolverPolicyDestination)
            {
                var method =
                    new SelectedMethod(
                        typeof(T).GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.DeclaredOnly)[0]);

                method.AddParameterResolver(this.resolverPolicy);

                yield return(method);
            }
コード例 #12
0
        private SelectedMethod CreateSelectedMethod(MethodInfo method)
        {
            var result = new SelectedMethod(method);

            foreach (var parameter in method.GetParameters())
            {
                result.AddParameterResolver(CreateResolver(parameter));
            }

            return(result);
        }
コード例 #13
0
 private void OnGetRecommendationValue(object obj)
 {
     try
     {
         RecommendationValue = SelectedMethod.RecommendSubject(SelectedUser, SelectedMovie);
     }
     catch (Exception e)
     {
         MessageBox.Show("Problem z wyznaczeniem wartości rekomendacji", "Błąd", MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }
コード例 #14
0
            public IEnumerable <SelectedMethod> SelectMethods(IBuilderContext context, IPolicyList resolverPolicyDestination)
            {
                var key = Guid.NewGuid().ToString();

                resolverPolicyDestination.Set <IDependencyResolverPolicy>(this.resolverPolicy, key);
                var method =
                    new SelectedMethod(
                        typeof(T).GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.DeclaredOnly)[0]);

                method.AddParameterKey(key);

                yield return(method);
            }
コード例 #15
0
 public void ScrambleText()
 {
     if (SelectedMethod.Equals("Scramble"))
     {
         Output = ScrambleText(Input);
     }
     else if (SelectedMethod.Equals("Caesar Shuffle"))
     {
         Output = CeasarShuffleText(Input);
     }
     else
     {
         Output = Input;
     }
 }
コード例 #16
0
ファイル: AnalyserViewModel.cs プロジェクト: pierrekhoury/MWA
        private void Export()
        {
            //Get save location
            string fileLocation = FileBrowser.SaveFile("Excel|*.xlsx");

            //Make sure user hasn't pressed cancel
            if (string.IsNullOrWhiteSpace(fileLocation))
            {
                return;
            }

            //Get data
            object[,] data = SelectedMethod.ExportResults();

            if (data == null)
            {
                return;
            }

            //Export
            ExcelService.WriteData(data, fileLocation, false);
        }
コード例 #17
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// ------------------------------------------------------------------------------------
        private void btnClose_Click(object sender, EventArgs e)
        {
            ErrorReportSettings.Default.ReportingMethod = ((ReportingMethod)(_methodCombo.SelectedItem)).Id;
            ErrorReportSettings.Default.Save();

            if (ModifierKeys.Equals(Keys.Shift))
            {
                return;
            }
            GatherData();

            // Clipboard.SetDataObject(_details.Text, true);

            if (SelectedMethod.Method())
            {
                CloseUp();
            }
            else
            {
                PutOnClipboard();
                CloseUp();
            }
        }
コード例 #18
0
        private IEnumerable <Expression> BuildMethodParameterExpressions(DynamicBuildPlanGenerationContext context, SelectedMethod method, string methodSignature)
        {
            int i = 0;
            var methodParameters = method.Method.GetParameters();

            foreach (IResolverPolicy parameterResolver in method.GetParameterResolvers())
            {
                yield return(context.CreateParameterExpression(
                                 parameterResolver,
                                 methodParameters[i].ParameterType,
                                 Expression.Call(null,
                                                 SetCurrentOperationToResolvingParameterMethod,
                                                 Expression.Constant(methodParameters[i].Name, typeof(string)),
                                                 Expression.Constant(methodSignature),
                                                 context.ContextParameter)));

                i++;
            }
        }
コード例 #19
0
        private IEnumerable<Expression> BuildMethodParameterExpressions(DynamicBuildPlanGenerationContext context, SelectedMethod method, string methodSignature)
        {
            int i = 0;
            var methodParameters = method.Method.GetParameters();

            foreach (IDependencyResolverPolicy parameterResolver in method.GetParameterResolvers())
            {
                yield return context.CreateParameterExpression(
                                parameterResolver,
                                methodParameters[i].ParameterType,
                                Expression.Call(null,
                                    SetCurrentOperationToResolvingParameterMethod,
                                    Expression.Constant(methodParameters[i].Name, typeof(string)),
                                    Expression.Constant(methodSignature),
                                    context.ContextParameter));
                i++;
            }
        }