/// <summary>
        /// Creates the control builder.
        /// </summary>
        private IControlBuilder CreateControlBuilder(MarkupFile file)
        {
            var lockId = (file.GetHashCode() & 0x7fffffff) % compilationLocks.Length;
            // do not compile the same view multiple times
            lock (compilationLocks[lockId])
            {
                if (controlBuilders.ContainsKey(file)) return controlBuilders[file];

                var namespaceName = GetNamespaceFromFileName(file.FileName, file.LastWriteDateTimeUtc);
                var assemblyName = namespaceName;
                var className = GetClassFromFileName(file.FileName) + "ControlBuilder";
                try
                {
                    return ViewCompilerFactory().CompileView(file.ContentsReaderFactory(), file.FileName, assemblyName, namespaceName, className);
                }
                catch (DotvvmCompilationException ex)
                {
                    if (ex.FileName == null)
                        ex.FileName = file.FullPath;
                    else if (!Path.IsPathRooted(ex.FileName))
                        ex.FileName = Path.Combine(
                            file.FullPath.Remove(file.FullPath.Length - file.FileName.Length),
                            ex.FileName);
                    throw;
                }
            }
        }
        /// <summary>
        /// Creates the control builder.
        /// </summary>
        private IControlBuilder CreateControlBuilder(MarkupFile file)
        {
            // TODO: thread safety: do not call it multiple times for single View

            var namespaceName = GetNamespaceFromFileName(file.FileName, file.LastWriteDateTimeUtc);
            var assemblyName = namespaceName;
            var className = GetClassFromFileName(file.FileName) + "ControlBuilder";
            
            return ViewCompilerFactory().CompileView(file.ContentsReaderFactory(), file.FileName, assemblyName, namespaceName, className);
        }
Пример #3
0
 protected bool Equals(MarkupFile other)
 {
     return string.Equals(FullPath, other.FullPath, StringComparison.CurrentCultureIgnoreCase) && LastWriteDateTimeUtc.Equals(other.LastWriteDateTimeUtc);
 }
Пример #4
0
 protected bool Equals(MarkupFile other)
 {
     return(string.Equals(FullPath, other.FullPath, StringComparison.CurrentCultureIgnoreCase) && LastWriteDateTimeUtc.Equals(other.LastWriteDateTimeUtc));
 }