コード例 #1
0
        public static IEdmNavigationSource FindNavigationTarget(this IEdmNavigationSource navigationSource,
                                                                IEdmNavigationProperty navigationProperty, IList <PathSegment> parsedSegments, out IEdmPathExpression bindingPath)
        {
            bindingPath = null;

            if (navigationProperty.ContainsTarget)
            {
                return(navigationSource);
                // return navigationSource.FindNavigationTarget(navigationProperty);
            }

            IEnumerable <IEdmNavigationPropertyBinding> bindings =
                navigationSource.FindNavigationPropertyBindings(navigationProperty);

            if (bindings != null)
            {
                foreach (var binding in bindings)
                {
                    if (BindingPathHelper.MatchBindingPath(binding.Path, parsedSegments))
                    {
                        bindingPath = binding.Path;
                        return(binding.Target);
                    }
                }
            }

            return(null);
        }
コード例 #2
0
ファイル: BindingPathHelperTests.cs プロジェクト: ehmz11/aaa
        public void No_Redundant_Binding_Paths()
        {
            var assemblyLocation = GetType().Assembly.Location;
            var assemblyDir      = Path.GetDirectoryName(assemblyLocation);
            var bindingPaths     = new List <string> {
                assemblyDir
            };

            var paths = BindingPathHelper.FindRedundantBindingPaths(bindingPaths, assemblyLocation);

            Assert.That(paths, Does.Not.Contain(assemblyDir));
        }
コード例 #3
0
        async Task CheckBindingPathsAsync()
        {
            try
            {
                // When running in the Exp instance, ensure there is only one active binding path.
                // This is necessary when the regular (AllUsers) extension is also installed.
                // See: https://github.com/github/VisualStudio/issues/2006
                await JoinableTaskFactory.SwitchToMainThreadAsync();

                BindingPathHelper.CheckBindingPaths(GetType().Assembly, this);
            }
            catch (Exception e)
            {
                log.Error(e, nameof(CheckBindingPathsAsync));
            }
        }
コード例 #4
0
ファイル: BindingPathHelperTests.cs プロジェクト: ehmz11/aaa
        public void Redundant_Binding_Paths_Contains_Alternative_Path()
        {
            var alternativeLocation = GetType().Assembly.Location;
            var fileName            = Path.GetFileName(alternativeLocation);
            var alternativeDir      = Path.GetDirectoryName(alternativeLocation);
            var assemblyDir         = @"c:\target";
            var assemblyLocation    = Path.Combine(assemblyDir, fileName);
            var bindingPaths        = new List <string> {
                alternativeDir, assemblyDir
            };

            var paths = BindingPathHelper.FindRedundantBindingPaths(bindingPaths, assemblyLocation);

            Assert.That(paths, Contains.Item(alternativeDir));
            Assert.That(paths, Does.Not.Contain(assemblyDir));
        }
        private async Task CheckBindingPathsAsync()
        {
            await JoinableTaskFactory.SwitchToMainThreadAsync();

            BindingPathHelper.CheckBindingPaths(GetType().Assembly, this);
        }