private bool TryAddAssemblyReference([NotNull] FileSystemPath path)
        {
            var cookie = AssemblyFactory.AddRef(path, "T4", ResolveContext);

            if (cookie != null)
            {
                MyAssemblyReferences.Add(path, cookie);
            }
            return(true);
        }
        private bool TryAddAssemblyReference([NotNull] VirtualFileSystemPath path)
        {
            var cookie = AssemblyFactory.AddRef(new AssemblyLocation(path), "T4", ResolveContext);

            if (cookie == null)
            {
                return(false);
            }
            MyAssemblyReferences.Add(path, cookie);
            return(true);
        }
Beispiel #3
0
        private bool TryAddReference([NotNull] T4ResolvedPath pathWithMacros)
        {
            var path = AssemblyReferenceResolver.ResolveWithoutCaching(pathWithMacros);

            if (path == null)
            {
                return(false);
            }
            if (MyAssemblyReferences.ContainsKey(path))
            {
                return(false);
            }
            if (MyProjectReferences.ContainsKey(path))
            {
                return(false);
            }
            return(TryAddProjectReference(path) || TryAddAssemblyReference(path));
        }
        private bool TryAddReference(IT4PathWithMacros pathWithMacros)
        {
            var path = AssemblyReferenceResolver.Resolve(pathWithMacros);

            if (path == null)
            {
                return(false);
            }
            if (MyAssemblyReferences.ContainsKey(path))
            {
                return(false);
            }
            if (MyProjectReferences.ContainsKey(path))
            {
                return(false);
            }
            return(TryAddProjectReference(path) || TryAddAssemblyReference(path));
        }
Beispiel #5
0
        public void Dispose()
        {
            var assemblyCookies = MyAssemblyReferences.Values.ToArray();

            if (assemblyCookies.Length == 0)
            {
                return;
            }
            ShellLocks.ExecuteWithWriteLock(
                () =>
            {
                foreach (var assemblyCookie in assemblyCookies)
                {
                    assemblyCookie.Dispose();
                }
            }
                );
            MyAssemblyReferences.Clear();
        }
Beispiel #6
0
        private bool TryRemoveReference([NotNull] T4ResolvedPath pathWithMacros)
        {
            var path = AssemblyReferenceResolver.ResolveWithoutCaching(pathWithMacros);

            if (path == null)
            {
                return(false);
            }
            if (MyAssemblyReferences.TryGetValue(path, out var cookie))
            {
                MyAssemblyReferences.Remove(path);
                cookie.Dispose();
                return(true);
            }

            if (MyProjectReferences.ContainsKey(path))
            {
                MyProjectReferences.Remove(path);
                return(true);
            }

            return(false);
        }