public void Encrypt() { if (this.SourceType == ZeusConstants.SourceTypes.SOURCE) { this.SourceType = ZeusConstants.SourceTypes.ENCRYPTED; if (_bodySegment.CodeUnparsed.Length > 0) { this._bodySegment.CodeUnparsed = ZeusEncryption.Encrypt(_bodySegment.CodeUnparsed); } if (_guiSegment.CodeUnparsed.Length > 0) { this._guiSegment.CodeUnparsed = ZeusEncryption.Encrypt(_guiSegment.CodeUnparsed); } } }
public static void ParseCode(ZeusCodeSegment segment) { StringReader reader; StringBuilder builder; IZeusScriptingEngine engine; segment.ExtraData.Clear(); // If this is a compiled template, don't try to parse it! if ((segment.Template.SourceType == ZeusConstants.SourceTypes.COMPILED) && (segment.CachedAssembly != null)) { return; } if (!segment.IsEmpty) { if (segment.Template.SourceType == ZeusConstants.SourceTypes.ENCRYPTED) { reader = new StringReader(ZeusEncryption.Decrypt(segment.CodeUnparsed)); } else { reader = new StringReader(segment.CodeUnparsed); } builder = new StringBuilder(); engine = ZeusFactory.GetEngine(segment.Engine); if (segment.Mode == ZeusConstants.Modes.MARKUP) { ParseMarkup(engine, segment, reader, builder); } else { ParsePure(engine, segment, reader, builder); } segment.Code = builder.ToString(); } }
public static void ParseCode(ZeusCodeSegment segment) { StringReader reader; StringBuilder builder; IZeusScriptingEngine engine; segment.ExtraData.Clear(); // If this is a compiled template, don't try to parse it! if ((segment.Template.SourceType == ZeusConstants.SourceTypes.COMPILED) && (segment.CachedAssembly != null)) { return; } if (!segment.IsEmpty) { if (segment.Template.SourceType == ZeusConstants.SourceTypes.ENCRYPTED) { reader = new StringReader(ZeusEncryption.Decrypt(segment.CodeUnparsed)); } else { reader = new StringReader(segment.CodeUnparsed); } builder = new StringBuilder(); engine = ZeusFactory.GetEngine(segment.Engine); if (segment.Mode == ZeusConstants.Modes.MARKUP) { ParseMarkup(engine, segment, reader, builder); } else { ParsePure(engine, segment, reader, builder); } segment.Code = builder.ToString(); string language = segment.Language; if (language.Equals(ZeusConstants.Languages.CSHARP) || language.Equals(ZeusConstants.Languages.VBNET)) { /**/ IList <string> lisUsings = new List <string>(); //TODO:HuyNH change some code to modfify using statement try { Regex regexObj = new Regex(ZeusConstants.Namespace.CSHARP_USING_REGEX); if (language.Equals(ZeusConstants.Languages.VBNET)) { regexObj = new Regex(ZeusConstants.Namespace.VBNET_IMPORT_REGEX); } Match matchResults = regexObj.Match(segment.Code); while (matchResults.Success) { // matched text: matchResults.Value // match start: matchResults.Index // match length: matchResults.Length lisUsings.Add(matchResults.Value); matchResults = matchResults.NextMatch(); } } catch (ArgumentException ex) { // Syntax error in the regular expression } lisUsings = lisUsings.Distinct().ToList(); foreach (string usingStatement in lisUsings) { segment.Code = segment.Code.Replace(usingStatement, string.Empty); } foreach (string usingStatement in lisUsings) { segment.Code = usingStatement + "\n" + segment.Code; } /**/ //TODO:HuyNH remove more empty line; segment.Code = Regex.Replace(segment.Code, "[\t ]+[\r\n]+", "\n", RegexOptions.Multiline); segment.Code = Regex.Replace(segment.Code, "[\r\n]+", "\n", RegexOptions.Multiline); } } }