Exemplo n.º 1
0
        private GroupInfo[] GetUserGroups(Guid userID, IncludeType includeType, Guid?categoryId)
        {
            var result             = new List <GroupInfo>();
            var distinctUserGroups = new List <GroupInfo>();

            var refs = GetRefsInternal();
            IEnumerable <UserGroupRef> userRefs = null;

            if (refs is UserGroupRefStore)
            {
                userRefs = ((UserGroupRefStore)refs).GetRefsByUser(userID);
            }

            foreach (var g in GetGroupsInternal().Where(g => !categoryId.HasValue || g.CategoryID == categoryId))
            {
                if (((g.CategoryID == Constants.SysGroupCategoryId || userRefs == null) && IsUserInGroupInternal(userID, g.ID, refs)) ||
                    (userRefs != null && userRefs.Any(r => !r.Removed && r.RefType == UserGroupRefType.Contains && r.GroupId == g.ID)))
                {
                    distinctUserGroups.Add(g);
                }
            }

            if (IncludeType.Distinct == (includeType & IncludeType.Distinct))
            {
                result.AddRange(distinctUserGroups);
            }

            result.Sort((group1, group2) => String.Compare(group1.Name, group2.Name, StringComparison.Ordinal));

            return(result.ToArray());
        }
        /// <summary>
        /// シェーダ#includeファイルの内容を開き、読み取るためのユーザーによって実施されるメソッド。
        /// </summary>
        /// <param name="type">#includeファイルの場所を示すD3D_INCLUDE_TYPE型の値</param>
        /// <param name="fileName">#includeファイルの名前</param>
        /// <param name="parentStream"> #includeファイルが含まれていコンテナ。</param>
        /// <returns></returns>
        public Stream Open(IncludeType type, string fileName, Stream parentStream)
        {
            var    assm   = Assembly.GetExecutingAssembly();
            Stream stream = assm.GetManifestResourceStream(m_prefix + "." + fileName);

            return(stream);
        }
Exemplo n.º 3
0
    public Stream Open(IncludeType type, string fileName, Stream parentStream)
    {
        var filename = $"shaders/{fileName}";
        var content  = _fs.ReadBinaryFile(filename);

        return(new MemoryStream(content));
    }
Exemplo n.º 4
0
        /* FILE IO METHODS */
        /// <summary>
        /// Open a text file containing HLSL shader byte code. Search nearby directories if an absolute path
        /// to the file isn't provided.
        /// </summary>
        /// <param name="type"></param>
        /// <param name="fileName">The name of the shader file or absolute path to it (including the name).</param>
        /// <returns></returns>
        public Stream Open(IncludeType type, string fileName, Stream parentStream)
        {
            // Pull the working directory, or use the environment's if one isn't provided
            string currentDir = CurrentDirectory.Peek();
            if (currentDir == null) { currentDir = Environment.CurrentDirectory; }

            // Examine the current working directory & subdirectories for the shader files to include
            string filePath = fileName;
            if (!Path.IsPathRooted(fileName))
            {
                List<string> dirsToSearch = new List<string> { currentDir };
                dirsToSearch.AddRange(IncludeDirectories);
                foreach (var dirPath in dirsToSearch)
                {
                    string currentFile = Path.Combine(dirPath, fileName);
                    if (NativeFile.Exists(currentFile))
                    {
                        filePath = currentFile;
                        break;
                    }
                }
            }
            if (filePath == null || !NativeFile.Exists(filePath)) { throw new FileNotFoundException(String.Format("Unable to find the shader file [{0}]", filePath ?? fileName)); }

            // Open & read the found file
            NativeFileStream fileStream = new NativeFileStream(filePath, NativeFileMode.Open, NativeFileAccess.Read);
            CurrentDirectory.Push(Path.GetDirectoryName(filePath));
            return fileStream;
        }
Exemplo n.º 5
0
 public Include(IncludeType type, string uri, string content, DateTime lastModifiedAt)
 {
     Type = type;
     Source = uri;
     Content = content;
     LastModifiedAt = lastModifiedAt;
 }
Exemplo n.º 6
0
        public Include RegisterInclude(string source, IncludeType type)
        {
            var include = _reader.Read(source, type);

            _storage.Store(include);
            return(include);
        }
Exemplo n.º 7
0
 public Include(IncludeType type, string uri, string content, DateTime lastModifiedAt)
 {
     Type           = type;
     Source         = uri;
     Content        = content;
     LastModifiedAt = lastModifiedAt;
 }
Exemplo n.º 8
0
        /// <summary>
        /// Obtains index range of selected text.
        /// </summary>
        /// <param name="min"></param>
        /// <param name="max"></param>
        /// <returns></returns>
        public Vector2i GetRange(Vector2f min, Vector2f max, IncludeType includeType)
        {
            // FIXME: more optimal
            Vector2i range = new Vector2i(int.MaxValue, int.MinValue);

            for (int i = 0; i < glyphs.Length; i++)
            {
                if (glyphs[i].IsIncluded(min, max, includeType))
                {
                    int idx = (int)glyphs[i].IndexInArray;
                    if (range.X > idx)
                    {
                        range.X = idx;
                    }
                    if (range.Y < idx)
                    {
                        range.Y = idx;
                    }
                }
            }

            if (range.X == int.MaxValue)
            {
                return(new Vector2i(0, -1));
            }
            return(range);
        }
Exemplo n.º 9
0
 public SearchQueryInclude(IncludeType IncludeType)
 {
     this.Type = IncludeType;
     this.SearchParameterList = new List <DomainModel.SearchParameter>();
     this.IsIterate           = false;
     this.IsRecurse           = false;
 }
Exemplo n.º 10
0
 public IncludeParameter(bool Iterate, bool Recurse, IncludeType Type, string Value)
 {
     this.Type    = Type;
     this.Iterate = Iterate;
     this.Recurse = Recurse;
     this.Value   = Value;
 }
 public static void Include(this HtmlHelper helper, IncludeType type, params string[] sources)
 {
     foreach (var path in sources)
     {
         helper.Include(type, path);
     }
 }
Exemplo n.º 12
0
            public Stream Open(IncludeType type, string fileName, Stream parentStream)
            {
                var s = File.OpenRead(Path.Combine(_SourceDirectory.FullName, fileName));

                _OpenStreams.Add(s);
                return(s);
            }
Exemplo n.º 13
0
    public void AddHeaderContent(IncludeType CType, string Content, bool IsRelative)
    {
        if (string.IsNullOrEmpty(Content))
        {
            return;
        }
        Literal ltrHeader = new Literal();

        ltrHeader.ID = string.Format("ltr{0}", Content.GetHashCode().ToString("X"));
        string ltrText = null;

        switch (CType)
        {
        case IncludeType.Js:
            ltrText = string.Format("<script type='text/javascript' src='{0}'></script>", GetContentPath(Content, IsRelative));
            break;

        case IncludeType.Css:
            ltrText = string.Format("<link rel='stylesheet' href='{0}' type='text/css' />", GetContentPath(Content, IsRelative));
            break;

        case IncludeType.RawContent:
            ltrText = Content;
            break;
        }
        ltrHeader.Text = string.Concat(ltrText, Environment.NewLine);
        this.Header.Controls.Add(ltrHeader);
    }
 public static void Include(this HtmlHelper helper, IncludeType type, params string[] sources)
 {
     foreach (var path in sources)
     {
         helper.Include(type, path);
     }
 }
Exemplo n.º 15
0
        public Stream Open(IncludeType type, string fileName, Stream parentStream)
        {
            string baseDir;

            if (type == IncludeType.Local)
            {
                baseDir = String.Concat(m_pathStacks.FindAll(item => item != "\\"));
            }
            else
            {
                baseDir = m_pathStacks.First();
            }

            string fullFileName = Path.Combine(baseDir, fileName);
            string localPath    = Path.GetDirectoryName(fullFileName.Substring(baseDir.Length));

            m_pathStacks.Add(localPath);

            if (MyFileSystem.FileExists(fullFileName))
            {
                return(new FileStream(fullFileName, FileMode.Open, FileAccess.Read));
            }
            else
            {
                return(Stream.Null);
            }
        }
Exemplo n.º 16
0
        /// <summary>
        /// Include resolution method. Override it to provide a custom include resolution. Note that
        /// this Options instance must have been created with enableIncludes set to 'true'.
        /// </summary>
        /// <returns><c>true</c>, if find include was tryed, <c>false</c> otherwise.</returns>
        /// <param name="sourcePath">requesting source name</param>
        /// <param name="includePath">include name to search for.</param>
        /// <param name="incType">As in c, relative include or global</param>
        /// <param name="incFile">the resolved name of the include, empty if resolution failed</param>
        /// <param name="incContent">if resolution succeeded, contain the source code in plain text of the include</param>
        protected virtual bool TryFindInclude(string sourcePath, string includePath, IncludeType incType, out string incFile, out string incContent)
        {
            if (incType == IncludeType.Relative)
            {
                incFile = Path.Combine(Path.GetDirectoryName(sourcePath), includePath);
                if (File.Exists(incFile))
                {
                    using (StreamReader sr = new StreamReader(incFile))
                        incContent = sr.ReadToEnd();
                    return(true);
                }
            }
            else
            {
                foreach (string incDir in IncludeDirectories)
                {
                    incFile = Path.Combine(incDir, includePath);
                    if (File.Exists(incFile))
                    {
                        using (StreamReader sr = new StreamReader(incFile))
                            incContent = sr.ReadToEnd();
                        return(true);
                    }
                }
            }

            incFile    = "";
            incContent = "";
            return(false);
        }
Exemplo n.º 17
0
        public int Next(int minValue, int maxValue, IncludeType type)
        {
            CheckInts(minValue, maxValue);
            var returnVal = 0;

            switch (type)
            {
            case IncludeType.None:
                returnVal = _rand.Next(minValue + 1, maxValue);
                break;

            case IncludeType.StartOnly:
                returnVal = _rand.Next(minValue, maxValue);
                break;

            case IncludeType.EndOnly:
                returnVal = _rand.Next(minValue + 1, maxValue + 1);
                break;

            case IncludeType.Both:
                returnVal = _rand.Next(minValue, maxValue + 1);
                break;
            }
            return(returnVal);
        }
Exemplo n.º 18
0
        public Stream Open(IncludeType type, string fileName, Stream parentStream)
        {
            Stream stream;

            if (type == IncludeType.Local)
            {
                string path = Path.Combine(this.BaseShaderPath, fileName);
                if (File.Exists(path))
                {
                    string content = File.ReadAllText(path);
                    stream = new MemoryStream();
                    StreamWriter writer = new StreamWriter(stream);
                    writer.Write(content);
                    writer.Flush();
                    stream.Position = 0;
                }
                else
                {
                    stream = null;
                }
            }
            else
            {
                stream = null;
            }

            return(stream);
        }
Exemplo n.º 19
0
        public IIncludeResult OpenInclude(IncludeType eType, string path, string includerPath)
        {
            if (!String.IsNullOrEmpty(includerPath))
            {
                string         fileDir = Path.GetDirectoryName(includerPath);
                IIncludeResult r       = DoPath(fileDir, path);
                if (r != null)
                {
                    return(r);
                }
            }

            foreach (string s in m_SearchDirs)
            {
                if (Directory.Exists(s))
                {
                    IIncludeResult r = DoPath(s, path);
                    if (r != null)
                    {
                        return(r);
                    }
                }
            }

            return(null);
        }
		public static string RenderIncludes(this HtmlHelper helper, IncludeType type, bool isInDebugMode)
		{
			var sources = helper.ViewData[getViewDataKey(type)] as IList<string> ?? new List<string>();
			var toRender = helper.RenderIncludes(sources, type, isInDebugMode);
			helper.ViewData[getViewDataKey(type)] = new List<string>();
			return toRender;
		}
        public static string RenderIncludes(this HtmlHelper helper, IncludeType type, bool isInDebugMode)
        {
            var sources  = helper.ViewData[getViewDataKey(type)] as IList <string> ?? new List <string>();
            var toRender = helper.RenderIncludes(sources, type, isInDebugMode);

            helper.ViewData[getViewDataKey(type)] = new List <string>();
            return(toRender);
        }
Exemplo n.º 22
0
        public void Open(IncludeType type, string fileName, Stream parentStream, out Stream stream)
        {
            string fullPath = Global.FXPath + fileName;
            if (!File.Exists(fullPath))
                Error.MessageMissingFile(Properties.Resources.ERR_IO_EffectMissingIncludeFile, fullPath, effectFile);

            stream = new FileStream(fullPath, FileMode.Open, FileAccess.Read);
        }
Exemplo n.º 23
0
        //file name - #include "./Shaders/Common.fx"
        //public Stream Open(IncludeType type, string fileName, Stream parentStream) {
        //    var key = Path.GetFileNameWithoutExtension(fileName);
        //    stream = this.GetType().Assembly.GetManifestResourceStream(resources[key]);

        //    return stream;
        //}
        public Stream Open(IncludeType type, string fileName, Stream parentStream)
        {
            var key = Path.GetFileNameWithoutExtension(fileName);

            stream = resources[key].GetResourceStream();

            return(stream);
        }
Exemplo n.º 24
0
        public Stream Open(IncludeType type, string fileName, Stream parentStream)
        {
            // Look for shaders in the startup directory.
            string shaderPath = Environment.CurrentDirectory + "\\" + fileName;

            // Open the shader in a new file stream.
            return(new FileStream(shaderPath, FileMode.Open, FileAccess.Read, FileShare.Read));
        }
Exemplo n.º 25
0
 public Stream Open(IncludeType type, string fileName, Stream parentStream)
 {
     Log.Debug("...include: {0}", fileName);
     if (!Includes.Contains(fileName))
     {
         Includes.Add(fileName);
     }
     return(File.OpenRead(buildContext.ResolveContentPath(fileName)));
 }
Exemplo n.º 26
0
 private void RadioButton_CheckedChanged(object sender, EventArgs e)
 {
     if (radioCopy.Checked)
         Responce = IncludeType.Copy;
     else if (radioLink.Checked)
         Responce = IncludeType.Link;
     else
         Responce = IncludeType.Skip;
 }
Exemplo n.º 27
0
        public void GetDirectoryListLATs(string fileMask, IncludeType includeType, IEnumerable <string> expectedLATs)
        {
            var options = new Options {
                FileMask = fileMask, IncludeType = includeType
            };
            var result = CreateSftpTaskInstance().ListDirectoryInternal(_dummyParams, options, new System.Threading.CancellationToken());

            Assert.That(result.Select(f => f.LastAccessTime.ToString(CultureInfo.InvariantCulture)), Is.EquivalentTo(expectedLATs));
        }
Exemplo n.º 28
0
        public Stream Open(IncludeType type, string fileName, Stream parentStream)
        {
            var stream =
                Assembly.GetExecutingAssembly().GetManifestResourceStream($"dEngine.Graphics.Shaders.{fileName}.shader");

            _includeStream = stream;

            return(_includeStream);
        }
Exemplo n.º 29
0
        public void GetDirectoryList(string fileMask, IncludeType includeType, IEnumerable <string> expectedFileNames)
        {
            var options = new Options {
                FileMask = fileMask, IncludeType = includeType
            };
            var result = CreateSftpTaskInstance().ListDirectoryInternal(_dummyParams, options, new System.Threading.CancellationToken());

            Assert.That(result.Select(f => f.Name), Is.EquivalentTo(expectedFileNames));
        }
Exemplo n.º 30
0
        public Stream Open(IncludeType type, string fileName, Stream parentStream)
        {
            var currentDirectory = CurrentDirectory.Peek();

            if (currentDirectory == null)
            {
                currentDirectory = Environment.CurrentDirectory;
            }

            var filePath = fileName;

            if (!Path.IsPathRooted(filePath))
            {
                var directoryToSearch = new List <string> {
                    currentDirectory
                };
                directoryToSearch.AddRange(IncludeDirectories);
                foreach (var dirPath in directoryToSearch)
                {
                    var selectedFile = Path.Combine(dirPath, fileName);
                    if (File.Exists(selectedFile))
                    {
                        filePath = selectedFile;
                        break;
                    }
                }
            }

            Stream stream = null;

            // Make sure that this file is not in the resolved list
            FileResolved.Remove(fileName);

            if (filePath == null || !File.Exists(filePath))
            {
                // Else try to use the include file callback
                if (IncludeFileCallback != null)
                {
                    stream = IncludeFileCallback(type == IncludeType.System, fileName);
                    if (stream != null)
                    {
                        FileResolved.Add(fileName, new FileItem(fileName, CleanPath(fileName), DateTime.Now));
                        return(stream);
                    }
                }

                Logger.Error("Unable to find file [{0}]", CurrentSpan, filePath ?? fileName);
                return(null);
            }

            stream = new FileStream(filePath, FileMode.Open, FileAccess.Read);
            CurrentDirectory.Push(Path.GetDirectoryName(Path.GetFullPath(filePath)));
            var fullPath = Path.GetFullPath(filePath);

            FileResolved.Add(fileName, new FileItem(fileName, CleanPath(fullPath), File.GetLastWriteTime(fullPath)));
            return(stream);
        }
Exemplo n.º 31
0
            private static Result OpenImpl(IntPtr thisPtr, IncludeType includeType, IntPtr fileNameRef, IntPtr pParentData, ref IntPtr dataRef, ref int bytesRef)
            {
                unsafe
                {
                    try
                    {
                        var shadow   = ToShadow <IncludeShadow>(thisPtr);
                        var callback = (Include)shadow.Callback;

                        Stream stream       = null;
                        Stream parentStream = null;

                        if (shadow._frames.ContainsKey(pParentData))
                        {
                            parentStream = shadow._frames[pParentData].Stream;
                        }

                        stream = callback.Open(includeType, Marshal.PtrToStringAnsi(fileNameRef), parentStream);
                        if (stream == null)
                        {
                            return(Result.Fail);
                        }

                        GCHandle handle;

                        //if (stream is DataStream)
                        //{
                        //    // Magic shortcut if we happen to get a DataStream
                        //    var data = (DataStream)stream;
                        //    dataRef = data.PositionPointer;
                        //    bytesRef = (int)(data.Length - data.Position);
                        //    handle = new GCHandle();
                        //}
                        //else
                        {
                            // Read the stream into a byte array and pin it
                            byte[] data = ReadStream(stream);
                            handle   = GCHandle.Alloc(data, GCHandleType.Pinned);
                            dataRef  = handle.AddrOfPinnedObject();
                            bytesRef = data.Length;
                        }

                        shadow._frames.Add(dataRef, new Frame(stream, handle));

                        return(Result.Ok);
                    }
                    catch (SharpGenException exception)
                    {
                        return(exception.ResultCode.Code);
                    }
                    catch (Exception)
                    {
                        return(Result.Fail);
                    }
                }
            }
Exemplo n.º 32
0
            public Stream Open(IncludeType type, string fileName, Stream parentStream)
            {
                string fullFileName = Path.Combine(m_effectPath, fileName);
                DateTime sourceTime = File.GetLastWriteTime(fullFileName);

                if (sourceTime > m_mostUpdateDateTime)
                    m_mostUpdateDateTime = sourceTime;

                return new FileStream(fullFileName, FileMode.Open, FileAccess.Read);
            }
 public void Open(IncludeType type, string fileName, out Stream stream)
 {
     if (type == IncludeType.System)
         stream = fileSystem.GetAssetStream(fileName);
     else
     {
         string path = Path.Combine(Path.GetDirectoryName(fileSystem.GetAssetFullPath(originalAssetName)), fileName);
         stream = fileSystem.GetAssetStream(path);
     }
 }
Exemplo n.º 34
0
        public void Open(IncludeType type, string fileName, Stream parentStream, out Stream stream)
        {
            string s = Utils.GetRootPath() + "\\Content\\Shaders\\" + fileName;

            using (StreamReader sr = new StreamReader(s))
            {
                string str = sr.ReadToEnd();
                stream = new MemoryStream(System.Text.Encoding.Default.GetBytes(str));
            }
        }
 public static void Include(this HtmlHelper helper, IncludeType type, string source)
 {
     var sourcesToInclude =
         helper.ViewData[getViewDataKey(type)] as IList<string> ?? new List<string>();
     if (!sourcesToInclude.Contains(source))
     {
         sourcesToInclude.Add(source);
     }
     helper.ViewData[getViewDataKey(type)] = sourcesToInclude;
 }
Exemplo n.º 36
0
        public bool CopyOrLinkFile(string file, bool exists, out IncludeType action, out bool applyforall)
        {
            var dialog = new AddItemDialog(file, exists, FileType.File);
            var result = dialog.ShowModal(this);

            action      = dialog.Responce;
            applyforall = dialog.ApplyForAll;

            return(result);
        }
Exemplo n.º 37
0
        public override void ParseParameter(string[] parameters, FileInfo sourceFilePath, int lineNumber, IAssemblerContext context)
        {
            string      includeFilename = parameters[0];
            IncludeType matchType       = IncludeType.Relative;

            if (parameters.Length > 1)
            {
                string incType = parameters[1].Replace("Sharpmake.", "");
                incType = incType.Replace("IncludeType.", "");
                if (!Enum.TryParse <IncludeType>(incType, out matchType))
                {
                    throw new Error("\t" + sourceFilePath.FullName + "(" + lineNumber + "): error: Sharpmake.Include invalid include type used ({0})", parameters[1]);
                }
            }
            string includeAbsolutePath = Path.IsPathRooted(includeFilename) ? includeFilename : null;

            if (Util.IsPathWithWildcards(includeFilename))
            {
                if (matchType != IncludeType.Relative)
                {
                    throw new Error("\t" + sourceFilePath.FullName + "(" + lineNumber + "): error: Sharpmake.Include with non-relative match types, wildcards are not supported ({0})", includeFilename);
                }
                includeAbsolutePath = includeAbsolutePath ?? Path.Combine(sourceFilePath.DirectoryName, includeFilename);
                context.AddSourceFiles(Util.DirectoryGetFilesWithWildcards(includeAbsolutePath));
            }
            else
            {
                includeAbsolutePath = includeAbsolutePath ?? Util.PathGetAbsolute(sourceFilePath.DirectoryName, includeFilename);

                if (matchType == IncludeType.Relative)
                {
                    if (!Util.FileExists(includeAbsolutePath))
                    {
                        includeAbsolutePath = Util.GetCapitalizedPath(includeAbsolutePath);
                    }
                }
                else
                {
                    string matchIncludeInParentPath = MatchIncludeInParentPath(includeFilename, sourceFilePath.DirectoryName, matchType);
                    if (matchIncludeInParentPath == null)
                    {
                        throw new Error("\t" + sourceFilePath.FullName + "(" + lineNumber + "): error: Sharpmake.Include file not found '{0}'[{1}]. Search started from '{2}'", includeFilename, matchType, sourceFilePath.DirectoryName);
                    }

                    includeAbsolutePath = Util.GetCapitalizedPath(matchIncludeInParentPath);
                }

                if (!Util.FileExists(includeAbsolutePath))
                {
                    throw new Error("\t" + sourceFilePath.FullName + "(" + lineNumber + "): error: Sharpmake.Include file not found {0}", includeFilename);
                }

                context.AddSourceFile(includeAbsolutePath);
            }
        }
Exemplo n.º 38
0
        internal GroupInfo[] GetGroups(IncludeType includeType, Guid?categoryId)
        {
            var groups = groupCache.Get(ID.ToString(), () => CoreContext.UserManager.GetUserGroups(ID, IncludeType.Distinct, null));

            if (categoryId.HasValue)
            {
                return(groups.Where(r => r.CategoryID.Equals(categoryId.Value)).ToArray());
            }

            return(groups);
        }
Exemplo n.º 39
0
 public void Open(IncludeType type, string fileName, Stream parentStream, out Stream stream)
 {
     if (type == IncludeType.Local)
     {
         stream = new FileStream(Path.Combine(ParentPath, fileName), FileMode.Open, FileAccess.Read);
     }
     else
     {
         this.sysHandler.Open(type, fileName, parentStream, out stream);
     }
 }
Exemplo n.º 40
0
 public string RegisterCombination(IEnumerable<string> sources, IncludeType type, DateTime now)
 {
     var combinedContent = new StringBuilder();
     foreach (var source in sources)
     {
         var include = RegisterInclude(source, type);
         combinedContent.Append(include.Content).AppendLine();
     }
     var combination = new IncludeCombination(type, sources, combinedContent.ToString(), now, _settings.Types[type]);
     var key = _storage.Store(combination);
     return key;
 }
Exemplo n.º 41
0
        public Stream Open(IncludeType type, string fileName, Stream parentStream)
        {
            var currentDirectory = CurrentDirectory.Peek();
            if (currentDirectory == null)
                currentDirectory = Environment.CurrentDirectory;

            var filePath = fileName;

            if (!Path.IsPathRooted(filePath))
            {
                var directoryToSearch = new List<string> {currentDirectory};
                directoryToSearch.AddRange(IncludeDirectories);
                foreach (var dirPath in directoryToSearch)
                {
                    var selectedFile = Path.Combine(dirPath, fileName);
                    if (File.Exists(selectedFile))
                    {
                        filePath = selectedFile;
                        break;
                    }
                }
            }

            Stream stream = null;

            // Make sure that this file is not in the resolved list
            FileResolved.Remove(fileName);

            if (filePath == null || !File.Exists(filePath))
            {
                // Else try to use the include file callback
                if (IncludeFileCallback != null)
                {
                    stream = IncludeFileCallback(type == IncludeType.System, fileName);
                    if (stream != null)
                    {
                        FileResolved.Add(fileName, new FileItem(fileName, CleanPath(fileName), DateTime.Now));
                        return stream;
                    }
                }

                Logger.Error("Unable to find file [{0}]", CurrentSpan, filePath ?? fileName);
                return null;
            }

            stream = new FileStream(filePath, FileMode.Open, FileAccess.Read);
            CurrentDirectory.Push(Path.GetDirectoryName(Path.GetFullPath(filePath)));
            var fullPath = Path.GetFullPath(filePath);
            FileResolved.Add(fileName, new FileItem(fileName, CleanPath(fullPath), File.GetLastWriteTime(fullPath)));
            return stream;
        }
        public Include Read(string source, IncludeType type)
        {
            if (String.IsNullOrEmpty(source))
            {
                throw new ArgumentException("source must have a value", source);
            }

            var abs = ToFileSystem(source);
            var file = new FileInfo(abs);
            if (!file.Exists)
            {
                throw new InvalidOperationException(string.Format("{0} does not exist", source));
            }

            var content = File.ReadAllText(abs);
            var lastModifiedAt = File.GetLastWriteTimeUtc(abs);
            return new Include(type, source, content, lastModifiedAt);
        }
Exemplo n.º 43
0
        public void Open(IncludeType type, string fileName, Stream parentStream, out Stream stream)
        {
            if (type == IncludeType.Local)
            {
                stream = new FileStream(Path.Combine(ParentPath, fileName), FileMode.Open, FileAccess.Read);
            }
            else
            {
                if (systemincludes.ContainsKey(fileName))
                {
                    stream = systemincludes[fileName].ToStream();
                }

                stream = new FileStream(fileName, FileMode.Open, FileAccess.Read);
            }

            //set include type, so the factory can know
            LastIncludeType = type;
        }
Exemplo n.º 44
0
 public Stream Open(IncludeType type, string fileName, Stream parentStream) {
     switch (type) {
         case IncludeType.Local:
             fileName = Path.Combine(_baseDirectory, fileName);
             break;
         case IncludeType.System:
             break;
         default:
             break;
     }
     // .fx 支持的字符集是 ASCII,而不是 UTF-8 或其他,这就是为什么 SharpDX 在进行文件预处理的时候使用的是 Encoding.ASCII。不过 fxc 看起来更智能一些,即使是带 BOM 头
     // 的 UTF-8 也是能读取和编译的。有些 .fx(在 Windows 下)保存时选择的“UTF-8”实际上都是带 BOM 头的,所以这些文件就出现了 BOM 头。但是为什么 ShaderBytecode.CompileFromFile
     // 又是正常的?
     // 我这里仿照的是(推测的)fxc 的处理逻辑。
     using (var streamReader = new StreamReader(fileName, Encoding.UTF8, true)) {
         var text = streamReader.ReadToEnd();
         var textBytes = Encoding.ASCII.GetBytes(text);
         return new MemoryStream(textBytes);
     }
 }
		public string RenderIncludes(IEnumerable<string> sources, IncludeType type, bool isInDebugMode)
		{
			var toRender = new StringBuilder();
			if (sources.Count() > 0)
			{
				if (_http.Context.IsDebuggingEnabled && isInDebugMode)
				{
					Clear();
					foreach (var source in sources)
					{
						var url = _reader.ToAbsolute(source);
						toRender.AppendFormat(_includeFormatStrings[type], url).AppendLine();
					}
				}
				else
				{
					var hash = RegisterCombination(sources, type, DateTime.UtcNow);
					var outputUrl = _reader.ToAbsolute(string.Format(_settings.Types[type].Path, type.ToString().ToLowerInvariant(), HttpUtility.UrlEncode(hash)));
					toRender.AppendFormat(_includeFormatStrings[type], outputUrl);
				}
			}
			return toRender.ToString();
		}
        public Stream Open(IncludeType type, string fileName, Stream parentStream)
        {
            var currentDirectory = CurrentDirectory.Peek();
            if (currentDirectory == null)
            #if NETFX_CORE
                currentDirectory = Windows.ApplicationModel.Package.Current.InstalledLocation.Path;
            #else
                currentDirectory = Environment.CurrentDirectory;
            #endif

            var filePath = fileName;

            if (!Path.IsPathRooted(filePath))
            {
                var directoryToSearch = new List<string> {currentDirectory};
                directoryToSearch.AddRange(IncludeDirectories);
                foreach (var dirPath in directoryToSearch)
                {
                    var selectedFile = Path.Combine(dirPath, fileName);
                    if (NativeFile.Exists(selectedFile))
                    {
                        filePath = selectedFile;
                        break;
                    }
                }
            }

            if (filePath == null || !NativeFile.Exists(filePath))
            {
                throw new FileNotFoundException(String.Format("Unable to find file [{0}]", filePath ?? fileName));
            }

            NativeFileStream fs = new NativeFileStream(filePath, NativeFileMode.Open, NativeFileAccess.Read);
            CurrentDirectory.Push(Path.GetDirectoryName(filePath));
            return fs;
        }
Exemplo n.º 47
0
 public void Open(IncludeType type, string fileName, Stream parentStream, out Stream stream)
 {
     if (type == IncludeType.Local)
     {
         string path = this.BaseShaderPath + "\\" + fileName;
         if (File.Exists(path))
         {
             string content = File.ReadAllText(path);
             stream = new MemoryStream();
             StreamWriter writer = new StreamWriter(stream);
             writer.Write(content);
             writer.Flush();
             stream.Position = 0;
         }
         else
         {
             stream = null;
         }
     }
     else
     {
         stream = null;
     }
 }
Exemplo n.º 48
0
			public Stream Open( IncludeType type, string fileName, Stream parentStream )
			{
				Log.Debug("...include: {0}", fileName);
				if (!Includes.Contains(fileName)) {
					Includes.Add(fileName);
				}
				return File.OpenRead( buildContext.ResolveContentPath( fileName ) );
			}
Exemplo n.º 49
0
        public void Open(IncludeType type, string fileName, Stream parentStream, out Stream stream)
        {
            string path;

            if (type == IncludeType.Local)
            {
                FileStream ps = parentStream as FileStream;

                // Attempt to include relative to current file
                if( ps != null ){
                    path = Path.Combine(Path.GetDirectoryName(ps.Name), fileName);
                    if (File.Exists(path))
                    {
                        stream = new FileStream(path, FileMode.Open, FileAccess.Read);
                        return;
                    }
                }

                // Attempt to include relative to origin file
                path = Path.Combine(this.BaseShaderPath, fileName);
                if (File.Exists(path))
                {
                    stream = new FileStream(path, FileMode.Open, FileAccess.Read);
                    return;
                }
            }

            // If system type include or if the file was not found for a local include
            path = Path.Combine(this.sysincludepath, fileName);
            if (File.Exists(path))
            {
                stream = new FileStream(path, FileMode.Open, FileAccess.Read);
            }
            else
            {
                stream = null;
            }
        }
Exemplo n.º 50
0
 Include(IncludeType type, EntityOperation operation)
 {
     Type = type;
     Operation = operation;
 }
		private static string getViewDataKey(IncludeType type)
		{
			return typeof (IncludeCombinerHtmlExtensions).FullName + "_" + type;
		}
Exemplo n.º 52
0
            public void Open(IncludeType type, string fileName, Stream parentStream, out Stream stream)
            {
                stream = null;
                foreach (string searchPath in m_IncludeDirs)
                {
                    string includePath = Path.Combine(searchPath, fileName);
                    if (File.Exists(includePath))
                    {
                        stream = new FileStream(includePath, FileMode.Open);
                        break;
                    }
                }

                Debug.Helper.Assert(stream != null, "Include file not found " + fileName);
            }
 public Stream Open(IncludeType type, string path, Stream parentStream)
 {
     var bytes = ReadAllBytes(path);
     var stream = new MemoryStream(bytes);
     return stream;
 }
Exemplo n.º 54
0
			public Stream Open( IncludeType type, string fileName, Stream parentStream )
			{
				//Log.Information("{0} {1} {2}", type, fileName, parentStream );

				return File.OpenRead( buildContext.Resolve( fileName ) );
			}
Exemplo n.º 55
0
 /// <summary>
 /// Locates the appropriate format string for the requirement type
 /// </summary>
 /// <param name="versionType"></param>
 /// <param name="spType"></param>
 /// <param name="productType"></param>
 /// <param name="architectureType"></param>
 /// <param name="includeType"></param>
 /// <returns></returns>
 private string GetDescriptionFormat(VersionType versionType, ServicePackType spType, ProductType productType, ArchitectureType architectureType, IncludeType includeType)
 {
     return DescriptionFormats[(int)versionType, (int)spType, (int)productType, (int)architectureType, (int)includeType];
 }
Exemplo n.º 56
0
 public Stream Open(IncludeType type, string fileName, Stream parentStream)
 {
     var s = File.OpenRead(Path.Combine(_SourceDirectory.FullName, fileName));
     _OpenStreams.Add(s);
     return s;
 }
Exemplo n.º 57
0
 public void Open(IncludeType type, string fileName, Stream parentStream, out Stream stream)
 {
     stream = new FileStream(includeDirectory + fileName, FileMode.Open, FileAccess.Read);
 }
Exemplo n.º 58
0
            public Stream Open(IncludeType type, string fileName, Stream parentStream)
            {
                var codeString = Properties.Resources.ResourceManager.GetString(Path.GetFileNameWithoutExtension(fileName), System.Globalization.CultureInfo.InvariantCulture);

                MemoryStream stream = new MemoryStream();
                StreamWriter writer = new StreamWriter(stream);
                writer.Write(codeString);
                writer.Flush();
                stream.Position = 0;
                return stream;
            }
Exemplo n.º 59
0
        public Stream Open(IncludeType type, string fileName, Stream parentStream)
        {
            string baseDir;
            if (type == IncludeType.Local)
            {
                baseDir = String.Concat(m_pathStacks.FindAll(item => item != "\\"));
            }
            else
            {
                baseDir = m_pathStacks.First();
            }

            string fullFileName = Path.Combine(baseDir, fileName);
            string localPath = Path.GetDirectoryName(fullFileName.Substring(baseDir.Length));
            m_pathStacks.Add(localPath);

            if (MyFileSystem.FileExists(fullFileName))
            {
                return new FileStream(fullFileName, FileMode.Open, FileAccess.Read);
            }
            else
            {
                return Stream.Null;
            }
            
        }
Exemplo n.º 60
0
 public Stream Open(IncludeType type, string fileName, Stream parentStream)
 {
     stream = new StreamReader(fileName).BaseStream;
     return stream;
 }