Exemplo n.º 1
0
        public override void AppendCSS(Env env, Context context)
        {
            ImportAction action = GetImportAction(env.Parser.Importer);

            if (action == ImportAction.ImportNothing)
            {
                return;
            }

            if (action == ImportAction.ImportCss)
            {
                env.Output.Append(InnerContent);
                return;
            }

            env.Output.Append("@import ")
            .Append(OriginalPath.ToCSS(env));

            if (Features)
            {
                env.Output
                .Append(" ")
                .Append(Features);
            }
            env.Output.Append(";");

            if (!env.Compress)
            {
                env.Output.Append("\n");
            }
        }
        // Converts the fully qualified user path returned by InternalGetFileDirectoryNames
        // into fullpath by combining the relevant portion of it with the fullpath of this directory
        // For ex, converts  foo\bar.txt into 'c:\temp\foo\bar.txt', where FullPath is 'c:\temp\foo'
        // and OriginalPath (aka userpath) is 'foo'
        private string FixupFileDirFullPath(String fileDirUserPath)
        {
            BCLDebug.Assert(fileDirUserPath != null, "InternalGetFileDirectoryNames returned paths should not be null!");
            BCLDebug.Assert(fileDirUserPath.StartsWith(OriginalPath, StringComparison.Ordinal), "InternalGetFileDirectoryNames returned paths should start with user path!");

            String fileDirFullPath;

            if (OriginalPath.Length == 0)
            {
                fileDirFullPath = Path.InternalCombine(FullPath, fileDirUserPath);
            }
            else if (OriginalPath.EndsWith(Path.DirectorySeparatorChar) || OriginalPath.EndsWith(Path.AltDirectorySeparatorChar))
            {
                BCLDebug.Assert((fileDirUserPath[OriginalPath.Length - 1] == Path.DirectorySeparatorChar) ||
                                (fileDirUserPath[OriginalPath.Length - 1] == Path.AltDirectorySeparatorChar), "InternalGetFileDirectoryNames returned incorrect user path!");
                fileDirFullPath = Path.InternalCombine(FullPath, fileDirUserPath.Substring(OriginalPath.Length));
            }
            else
            {
                BCLDebug.Assert((fileDirUserPath[OriginalPath.Length] == Path.DirectorySeparatorChar), "InternalGetFileDirectoryNames returned incorrect user path!");
                fileDirFullPath = Path.InternalCombine(FullPath, fileDirUserPath.Substring(OriginalPath.Length + 1));
            }

            return(fileDirFullPath);
        }
Exemplo n.º 3
0
        public override IFile GetFile(string name)
        {
            var parts = name.Split(InternalZipDirectory.PathSplit, StringSplitOptions.RemoveEmptyEntries);

            if (parts.Length <= 1)
            {
                var compledetPath = OriginalPath.CombinePath(name);
                return(new InZipFile(this, compledetPath, _file, _dic, _file[compledetPath]));
            }

            var dic         = _dic;
            var inZipParent = this;

            var originalPath = new StringBuilder(OriginalPath);

            for (var i = 0; i < parts.Length; i++)
            {
                if (i == parts.Length - 1)
                {
                    return(new InZipFile(inZipParent, originalPath.Append('\\').Append(parts[i]).ToString(), _file, dic,
                                         _file[originalPath.ToString()]));
                }

                dic = dic.GetOrAdd(parts[i]);
                originalPath.Append('\\').Append(parts[i]);
                inZipParent = new InZipDirectory(inZipParent, originalPath.ToString(), dic, _file, name);
            }

            throw new InvalidOperationException();
        }
Exemplo n.º 4
0
        private void DoRefresh()
        {
            var uri = new Uri(OriginalPath);

            if (uri.HostNameType.ToString() == "Dns")
            {
                CurrentPath = OriginalPath.Replace(uri.Host, mDotNetDns.GetIPAddress(uri.Host));
            }
        }
Exemplo n.º 5
0
        internal string Compile()
        {
            // write new IL
            byte[] buffer = UTF8Encoding.UTF8.GetBytes(XIL.ToString());

            using (FileStream outFile = new FileStream(ILPath, FileMode.Truncate))
                outFile.Write(buffer);

            string windir = Environment.GetEnvironmentVariable("windir");
            string ilasm  = Path.Combine(windir, "Microsoft.NET\\Framework\\v4.0.30319\\ilasm.exe");
            //string ilasm = Path.Combine(windir, "Microsoft.NET\\Framework\\v2.0.50727\\ilasm.exe");

            // C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\ilasm.exe RiseOp

            // assemble file
            ProcessStartInfo info = new ProcessStartInfo(ilasm, Path.GetFileName(ILPath));

            info.WorkingDirectory       = AsmDir;
            info.UseShellExecute        = false;
            info.RedirectStandardOutput = true;
            info.Arguments += " /optimize"; // turn br instructions to br.s

            if (OriginalPath.EndsWith(".dll"))
            {
                info.Arguments += " /DLL ";
            }

            Process process = Process.Start(info);
            string  output  = process.StandardOutput.ReadToEnd();

            process.WaitForExit();

            if (!output.Contains("Operation completed successfully"))
            {
                // for some reason running ilasm manually will give error details, while the process above will not
                output += "\r\n\r\nTry running ilasm manually for error details.";

                throw new CompileError("Error Recompiling", DasmPath, output);
            }

            // copy compiled file
            string newName = Path.GetFileName(OriginalPath);

            if (!Build.ReplaceOriginal)
            {
                newName = "XRay." + newName;
            }

            string recompiledPath = Path.Combine(Build.OutputDir, newName);

            File.Delete(recompiledPath); // delete prev compiled file

            File.Copy(DasmPath, recompiledPath, true);

            return(recompiledPath);
        }
Exemplo n.º 6
0
 public override int GetHashCode()
 {
     unchecked
     {
         int hashCode = AutoRefresh.GetHashCode();
         hashCode = (hashCode * 397) ^ (OriginalPath != null ? OriginalPath.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (int)SubType;
         return(hashCode);
     }
 }
Exemplo n.º 7
0
 public PathParse(string path)
 {
     if (string.IsNullOrEmpty(path))
     {
         throw new ArgumentNullException(string.Format("{0}不能为空", nameof(path)));
     }
     this.OriginalPath = path;
     this.Levles       = OriginalPath.Split('-').ToList();
     this.Current      = GetCurrent();
 }
Exemplo n.º 8
0
        public override IDirectory MoveTo(string location)
        {
            if (location == OriginalPath)
            {
                return(this);
            }

            OriginalPath.MoveTo(location);

            return(new LocalDirectory(location));
        }
Exemplo n.º 9
0
        public void UpdateOriginalHotKey()
        {
            int startIndex;

            OriginalHotKey = MenuItemHotKey.Create(OriginalPath, out startIndex);

            if (startIndex > -1)
            {
                OriginalName = OriginalPath.Substring(0, startIndex - 1);
            }
        }
Exemplo n.º 10
0
        public override int GetHashCode()
        {
            unchecked
            {
                var hashCode = Entity is not null ? EqualityComparer <TEntity> .Default.GetHashCode(Entity) : base.GetHashCode();

                hashCode = (hashCode * 397) ^ NewParentId;
                hashCode = (hashCode * 397) ^ OriginalPath.GetHashCode();
                return(hashCode);
            }
        }
Exemplo n.º 11
0
        public override Node Evaluate(Env env)
        {
            if (Css)
            {
                return(new NodeList(new TextNode("@import " + OriginalPath.ToCSS(env) + ";\n")));
            }

            NodeHelper.ExpandNodes <Import>(env, InnerRoot.Rules);

            return(new NodeList(InnerRoot.Rules).ReducedFrom <NodeList>(this));
        }
Exemplo n.º 12
0
 protected override Task HandleChallengeAsync(AuthenticationProperties properties)
 {
     //Don't challenge API requests
     if (OriginalPath.StartsWithSegments("/api"))
     {
         Response.StatusCode = StatusCodes.Status401Unauthorized;
         Response.BodyWriter.Complete();
         return(Task.CompletedTask);
     }
     //Redirect to login page
     Response.Redirect($"/auth/login?ReturnUrl={Uri.EscapeDataString(OriginalPath)}");
     return(Task.CompletedTask);
 }
Exemplo n.º 13
0
 protected override Task HandleForbiddenAsync(AuthenticationProperties properties)
 {
     //Don't show error page for api requests
     if (OriginalPath.StartsWithSegments("/api"))
     {
         Response.StatusCode = StatusCodes.Status403Forbidden;
         Response.BodyWriter.Complete();
         return(Task.CompletedTask);
     }
     //Show Error page
     Response.Redirect($"/error/{StatusCodes.Status403Forbidden}");
     return(Task.CompletedTask);
 }
Exemplo n.º 14
0
        protected override void AppendCSS(Env env, Context context)
        {
            env.Output.Append("@import ")
            .Append(OriginalPath.ToCSS(env));

            if (Features)
            {
                env.Output
                .Append(" ")
                .Append(Features);
            }
            env.Output.Append(";");

            if (!env.Compress)
            {
                env.Output.Append("\n");
            }
        }
Exemplo n.º 15
0
        private void SetOriginalPathAddExtNameAndObjectName(string originalPath, string objectName)
        {
            if (string.IsNullOrWhiteSpace(originalPath))
            {
                throw new ArgumentException("message", nameof(originalPath));
            }

            if (OriginalPath.Equals(originalPath))
            {
                return;
            }

            OriginalPath = originalPath;
            ExtName      = Path.GetExtension(originalPath);

            objectName = objectName ?? originalPath.ToObjectName();

            if (!ObjectName.Equals(objectName))
            {
                ObjectName = objectName;
            }
        }
Exemplo n.º 16
0
 public override int GetHashCode() => 11 *OriginalPath.GetHashCode();
Exemplo n.º 17
0
        public override Node Evaluate(Env env)
        {
            OriginalPath = OriginalPath.Evaluate(env);
            var quoted = OriginalPath as Quoted;

            if (quoted != null)
            {
                Path = quoted.Value;
            }

            ImportAction action = GetImportAction(env.Parser.Importer);

            if (action == Importers.ImportAction.ImportNothing)
            {
                return(new NodeList().ReducedFrom <NodeList>(this));
            }

            Node features = null;

            if (Features)
            {
                features = Features.Evaluate(env);
            }

            if (action == ImportAction.LeaveImport)
            {
                return(new Import(OriginalPath, features));
            }

            if (action == ImportAction.ImportCss)
            {
                var importCss = new Import(OriginalPath, null)
                {
                    _importAction = ImportAction.ImportCss, InnerContent = InnerContent
                };
                if (features)
                {
                    return(new Media(features, new NodeList()
                    {
                        importCss
                    }));
                }
                return(importCss);
            }

            using (env.Parser.Importer.BeginScope(this))
            {
                if (IsReference || IsOptionSet(ImportOptions, ImportOptions.Reference))
                {
                    // Walk the parse tree and mark all nodes as references.
                    IsReference = true;

                    IVisitor referenceImporter = null;
                    referenceImporter = DelegateVisitor.For <Node>(node => {
                        var ruleset = node as Ruleset;
                        if (ruleset != null)
                        {
                            if (ruleset.Selectors != null)
                            {
                                ruleset.Selectors.Accept(referenceImporter);
                                ruleset.Selectors.IsReference = true;
                            }

                            if (ruleset.Rules != null)
                            {
                                ruleset.Rules.Accept(referenceImporter);
                                ruleset.Rules.IsReference = true;
                            }
                        }

                        var media = node as Media;
                        if (media != null)
                        {
                            media.Ruleset.Accept(referenceImporter);
                        }

                        var nodeList = node as NodeList;
                        if (nodeList != null)
                        {
                            nodeList.Accept(referenceImporter);
                        }
                        node.IsReference = true;

                        return(node);
                    });
                    Accept(referenceImporter);
                }
                NodeHelper.ExpandNodes <Import>(env, InnerRoot.Rules);
            }

            var rulesList = new NodeList(InnerRoot.Rules).ReducedFrom <NodeList>(this);

            if (features)
            {
                return(new Media(features, rulesList));
            }

            return(rulesList);
        }
Exemplo n.º 18
0
        public override Node Evaluate(Env env)
        {
            OriginalPath = OriginalPath.Evaluate(env);
            var quoted = OriginalPath as Quoted;

            if (quoted != null)
            {
                Path = quoted.Value;
            }

            ImportAction action = GetImportAction(env.Parser.Importer);

            if (action == Importers.ImportAction.ImportNothing)
            {
                return(new NodeList().ReducedFrom <NodeList>(this));
            }

            Node features = null;

            if (Features)
            {
                features = Features.Evaluate(env);
            }

            if (action == ImportAction.LeaveImport)
            {
                return(new Import(OriginalPath, features));
            }

            if (action == ImportAction.ImportCss)
            {
                var importCss = new Import(OriginalPath, null)
                {
                    _importAction = ImportAction.ImportCss, InnerContent = InnerContent
                };
                if (features)
                {
                    return(new Media(features, new NodeList()
                    {
                        importCss
                    }));
                }
                return(importCss);
            }

            using (env.Parser.Importer.BeginScope(this))
            {
                if (IsReference || IsOptionSet(ImportOptions, ImportOptions.Reference))
                {
                    // Walk the parse tree and mark all nodes as references.
                    IsReference = true;

                    Accept(referenceVisitor);
                }
                NodeHelper.RecursiveExpandNodes <Import>(env, InnerRoot);
            }

            var rulesList = new NodeList(InnerRoot.Rules).ReducedFrom <NodeList>(this);

            if (features)
            {
                return(new Media(features, rulesList));
            }

            return(rulesList);
        }
Exemplo n.º 19
0
 public void ReParse()
 {
     this.Levles = OriginalPath.Split('-').ToList();
 }
Exemplo n.º 20
0
 public string GetFileName()
 {
     return(OriginalPath
            .Remove(OriginalPath.LastIndexOf('\\'))
            .Replace(".MEASURE", ""));
 }
Exemplo n.º 21
0
 public override IFile GetFile(string name)
 => new LocalFile(OriginalPath.CombinePath(name), this);