当前位置: 首页>>代码示例>>C#>>正文


C# StreamReader.Replace方法代码示例

本文整理汇总了C#中System.IO.StreamReader.Replace方法的典型用法代码示例。如果您正苦于以下问题:C# StreamReader.Replace方法的具体用法?C# StreamReader.Replace怎么用?C# StreamReader.Replace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.IO.StreamReader的用法示例。


在下文中一共展示了StreamReader.Replace方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Install

        /// <summary>
        /// Inject HTML that displays warning
        /// </summary>
        /// <param name="linkUrl">URL for 'learn more'</param>
        /// <param name="messageText">Override text for mail message</param>
        /// <param name="learnMoreText">Override text for 'Learn more' link</param>
        /// <param name="okText">Override text for OK button</param>
        /// <returns>HTML string that displays message on the bottom of the web page</returns>
        public string Install(string linkUrl = null, string messageText = null, string learnMoreText = null, string okText = null)
        {
            if (_cookieService.Read(CookieName) != "true")
            {
                var assembly = Assembly.GetAssembly(typeof(Consent));

                var hasLink = !IsEmpty(linkUrl);

                var fileName = hasLink ? "script.html" : "scriptnolink.html";

                var html = new StreamReader(assembly.GetManifestResourceStream("EUCookies." + fileName)).ReadToEnd();

                if (hasLink)
                    html = html.Replace("{learnmore}", IsEmpty(learnMoreText)
                                    ? Captions.LearnMore
                                    : learnMoreText)
                                .Replace("{link}", linkUrl);

                return html
                    .Replace("{text}", IsEmpty(messageText) ? Captions.Text : messageText)
                    .Replace("{ok}", IsEmpty(okText) ? Captions.Ok : okText);
            }

            return string.Empty;
        }
开发者ID:MscrmTools,项目名称:EUCookiesNET,代码行数:33,代码来源:Consent.cs

示例2: ReplaceGrey

        public static Stream ReplaceGrey(Stream stream, Color color)
        {
            string s = new StreamReader (stream).ReadToEnd ();
            s = s.Replace ("#808080", HexConvert(color));
            s = s.Replace ("#8F8F8F", HexConvert(color));
            s = s.Replace ("#6E6E6E", HexConvert(color));
            s = s.Replace ("#5C5C5C", HexConvert(color));
            s = s.Replace ("#737373", HexConvert(color));

            return GenerateStreamFromString (s);
        }
开发者ID:welb-studio,项目名称:ClothesAndWeather,代码行数:11,代码来源:ClothStreamReader.cs

示例3: RunBrowser

        public void RunBrowser(string url, string backUrl, string mdOrder, string paReq)
        {
            Assembly asm = Assembly.GetExecutingAssembly();
            string reqPage = new StreamReader(asm.GetManifestResourceStream("RbsPayments.Test.Secure3D.request.html")).ReadToEnd();

            reqPage = reqPage.Replace("{Url}", url);
            reqPage = reqPage.Replace("{BackUrl}", backUrl);
            reqPage = reqPage.Replace("{MdOrder}", mdOrder);
            reqPage = reqPage.Replace("{PaReq}", paReq);

            File.WriteAllText("req.html", reqPage);
            System.Diagnostics.Process.Start(Secure3DTest.Browser, "req.html");
        }
开发者ID:ExM,项目名称:RbsPayments,代码行数:13,代码来源:Secure3D_FromBrowser.cs

示例4: GenerateScript

        protected virtual void GenerateScript()
        {
            var sb = new StringBuilder();
            using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("Rabbit.WebForms.js"))
            {
                var webformjs = new StreamReader(stream).ReadToEnd();
                webformjs = webformjs.Replace("\r", "").Replace("\n", "");
                sb.Append("<script type=\"text/javascript\">\r\n" + webformjs);
            }
            sb.Append("\r\n$(function () { webForm.init();");

            var fields = this.GetType().GetFields(BindingFlags.Public| BindingFlags.Instance);

            foreach (var field in fields)
            {
                if(field.IsPublic)
                    sb.AppendFormat("webForm['{0}']={1};", field.Name, JsonConvert.SerializeObject(field.GetValue(this)));
            }

            var x = this.Request["__scroll_x"];
            var y = this.Request["__scroll_y"];
            if (!string.IsNullOrWhiteSpace(x) && !string.IsNullOrWhiteSpace(y))
            {
                sb.AppendFormat("window.scrollTo({0},{1});", x, y);
            }
            sb.Append("}); \r\n</script>");

            var script =  sb.ToString();
            this.Write(this.Html.Raw(script));
        }
开发者ID:yysun,项目名称:Rabbit,代码行数:30,代码来源:WebForm.cs

示例5: RetroShaderPreset

		/// <summary>
		/// Parses an instance from a stream to a CGP file
		/// </summary>
		public RetroShaderPreset(Stream stream)
		{
			var content = new StreamReader(stream).ReadToEnd();
			Dictionary<string, string> dict = new Dictionary<string, string>();

			//parse the key-value-pair format of the file
			content = content.Replace("\r", "");
			foreach (var _line in content.Split('\n'))
			{
				var line = _line.Trim();
				if (line.StartsWith("#")) continue; //lines that are solely comments
				if (line == "") continue; //empty line
				int eq = line.IndexOf('=');
				var key = line.Substring(0, eq).Trim();
				var value = line.Substring(eq + 1).Trim();
				int quote = value.IndexOf('\"');
				if (quote != -1)
					value = value.Substring(quote + 1, value.IndexOf('\"', quote + 1) - (quote + 1));
				else
				{
					//remove comments from end of value. exclusive from above condition, since comments after quoted strings would be snipped by the quoted string extraction
					int hash = value.IndexOf('#');
					if (hash != -1)
						value = value.Substring(0, hash);
					value = value.Trim();
				}
				dict[key.ToLower()] = value;
			}

			//process the keys
			int nShaders = FetchInt(dict, "shaders", 0);
			for (int i = 0; i < nShaders; i++)
			{
				ShaderPass sp = new ShaderPass();
				sp.Index = i;
				Passes.Add(sp);

				sp.InputFilterLinear = FetchBool(dict, "filter_linear" + i, false); //Should this value not be defined, the filtering option is implementation defined.
				sp.OuputFloat = FetchBool(dict, "float_framebuffer" + i, false);
				sp.FrameCountMod = FetchInt(dict, "frame_count_mod" + i, 1);
				sp.ShaderPath = FetchString(dict, "shader" + i, "?"); //todo - change extension to .cg for better compatibility? just change .cg to .glsl transparently at last second?

				//If no scale type is assumed, it is assumed that it is set to "source" with scaleN set to 1.0.
				//It is possible to set scale_type_xN and scale_type_yN to specialize the scaling type in either direction. scale_typeN however overrides both of these.
				sp.ScaleTypeX = (ScaleType)Enum.Parse(typeof(ScaleType), FetchString(dict, "scale_type_x" + i, "Source"), true);
				sp.ScaleTypeY = (ScaleType)Enum.Parse(typeof(ScaleType), FetchString(dict, "scale_type_y" + i, "Source"), true);
				ScaleType st = (ScaleType)Enum.Parse(typeof(ScaleType), FetchString(dict, "scale_type" + i, "NotSet"), true);
				if (st != ScaleType.NotSet)
					sp.ScaleTypeX = sp.ScaleTypeY = st;

				//scaleN controls both scaling type in horizontal and vertical directions. If scaleN is defined, scale_xN and scale_yN have no effect.
				sp.Scale.X = FetchFloat(dict, "scale_x" + i, 1);
				sp.Scale.Y = FetchFloat(dict, "scale_y" + i, 1);
				float scale = FetchFloat(dict, "scale" + i, -999);
				if (scale != -999)
					sp.Scale.X = sp.Scale.Y = FetchFloat(dict, "scale" + i, 1);

				//TODO - LUTs
			}
		}
开发者ID:ddugovic,项目名称:RASuite,代码行数:63,代码来源:Retro.cs

示例6: ReadResource

 private string ReadResource(string resourceName)
 {
     using (var s = Assembly.GetExecutingAssembly().GetManifestResourceStream("Knockout.Tests." + resourceName)) {
         var result = new StreamReader(s).ReadToEnd();
         return result.Replace("\r\n", "\n");
     }
 }
开发者ID:Saltarelle,项目名称:SaltarelleKnockout,代码行数:7,代码来源:EndToEndTest.cs

示例7: buttonParse_Click

        private void buttonParse_Click( object sender , EventArgs e )
        {
            var req = WebRequest.Create(this.textBoxInputUrl.Text);
            string html = new StreamReader(req.GetResponse().GetResponseStream()).ReadToEnd();

            HtmlDocument htmlDocument;
            XmlDocument  doc = new XmlDocument();

            //html = Regex.Match(html, @"/^<([a-z]+)([^<]+)*(?:>(.*)<\/\1>|\s+\/>)$/").Value;
            doc.LoadXml(html.Replace("\n","").Replace("\r",""));
            var table = doc.GetElementsByTagName("table").Item(0);

            var nodes =table.FirstChild.ChildNodes;

            string lastVersion = "-1";
            int rowCount = 0;

            XmlDocument document = new XmlDocument();

            StringBuilder str = new StringBuilder();

            foreach (XmlNode nodeTr in nodes)
            {
                str.Append( "{ ");
                str.Append ( System.Environment.NewLine );
                //if (nodeTr.FirstChild.Attributes["rowspan"]!=null)
                //{
                //	lastVersion = nodeTr.FirstChild.FirstChild.Value;
                //}
                //else
                //{
                //	str.Append ( lastVersion + ", " );
                //}
                for (int i = 1; i < nodeTr.ChildNodes.Count-1; i++)
                {
                    try {
                        str.Append ( "MaskPatterns.Pattern"+nodeTr.ChildNodes[i].FirstChild.Value + ", " );
                    }
                    catch ( NullReferenceException ) {

                    }
                }

                str.Append ( System.Environment.NewLine );
                try {
                    str.Append ("new bool[] {"+ nodeTr.ChildNodes[nodeTr.ChildNodes.Count - 1].FirstChild.Value.Replace("0","false, ").Replace("1","true,")+"}" + System.Environment.NewLine+ " },");
                }
                catch ( NullReferenceException ) {

                    str.Append ( System.Environment.NewLine );
                    str.Append ( " }," );
                }
                str.Append( System.Environment.NewLine);
            }

            this.textBoxOutput.Text = str.ToString ().Replace ( "QR Version " , "" );
            //this.textBoxOutput.Text = str.ToString();
        }
开发者ID:alexey-aristov,项目名称:JustFun,代码行数:58,代码来源:Form1.cs

示例8: GetTestDataTemplate

 public static string GetTestDataTemplate(int index, string table, string filename, string tableName)
 {
     var template = new StreamReader(Assembly.GetExecutingAssembly().GetManifestResourceStream("DatabaseVersionControl.Cmd.Templates.TestSqlTemplate.txt")).ReadToEnd();
     template = template.Replace("%Index%", index.ToString())
         .Replace("%Description%", "Insert test data for table "+table)
         .Replace("%DateTime%", DateTime.Now.ToExactFormatString())
         .Replace("%Filename%", Path.GetFileName(filename))
         .Replace("%TableName%", tableName);
     return template;
 }
开发者ID:rolfwessels,项目名称:databaseversioncontrol,代码行数:10,代码来源:TemplateHelper.cs

示例9: GetFileTemplate

 public static string GetFileTemplate(string exportSchemaFileName, string connectionString, string outputFileName, string schemaFileName, string[] additionalUpdates)
 {
     var template = new StreamReader(Assembly.GetExecutingAssembly().GetManifestResourceStream("DatabaseVersionControl.Cmd.Templates.NewExportTemplate.txt")).ReadToEnd();
     template = template.Replace("%ConnectionString%", connectionString)
         .Replace("%DatabaseName%", Path.GetFileNameWithoutExtension(outputFileName))
         .Replace("%DateTime%", DateTime.Now.ToExactFormatString())
         .Replace("%ExportFileName%", Path.GetFileName(schemaFileName))
         .Replace("%AdditionalUpdates%", string.Join("\n", additionalUpdates));
     return template;
 }
开发者ID:rolfwessels,项目名称:databaseversioncontrol,代码行数:10,代码来源:TemplateHelper.cs

示例10: OnCreate

        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);
            EditText myName = FindViewById<EditText>(Resource.Id.txtName);
            EditText myPwd = FindViewById<EditText>(Resource.Id.txtPwd);
            Button login = FindViewById<Button>(Resource.Id.btnLogin);

            login.Click += delegate
           {
               string name = myName.Text;
               string pwd = myPwd.Text;

               if (string.IsNullOrEmpty(name) || string.IsNullOrEmpty(pwd))
               {
                   Toast.MakeText(this, "请输入用户名和密码!!", ToastLength.Long).Show();
                   return;
               }
               else
               {
                   string loginUrl = string.Format("http://192.168.1.102:8077/User/LogOn?userName={0}&userPwd={1}", name, pwd);

                   var httpReq = (HttpWebRequest)HttpWebRequest.Create(new Uri(loginUrl));
                   var httpRes = (HttpWebResponse)httpReq.GetResponse();
                   if (httpRes.StatusCode == HttpStatusCode.OK)
                   {
                       string result = new StreamReader(httpRes.GetResponseStream()).ReadToEnd();

                       result = result.Replace("\"", "'");

                       ReturnModel s = JsonConvert.DeserializeObject<ReturnModel>(result);

                       if (s.Code == "00000")
                       {
                           var intent = new Intent(this, typeof(UserActivity));

                           intent.PutExtra("name", name);

                           StartActivity(intent);
                       }
                       else
                       {
                           Toast.MakeText(this, "用户名或密码不正确!!", ToastLength.Long).Show();
                           return;
                       }
                   }
               }
           };
        }
开发者ID:hwqdt,项目名称:Demos,代码行数:51,代码来源:MainActivity.cs

示例11: ReplaceInDocument

        internal static string ReplaceInDocument(string documentPath, IEnumerable<Replacement> replacements)
        {
            string newString;
            using (var stream = new FileStream(documentPath, FileMode.Open, FileAccess.Read, FileShare.Read))
            {
                newString = new StreamReader(stream).ReadToEnd();

                foreach (Replacement replacement in replacements)
                {
                    newString = newString.Replace(replacement.OldString, replacement.NewString);
                }
            }
            return newString;
        }
开发者ID:arenhag,项目名称:BizUnitCompare,代码行数:14,代码来源:XmlDocumentCleaner.cs

示例12: Main

 public static void Main(string [] args)
 {
     var imp = new DominoModuleXmlImporter ();
     var ds = new DataContractJsonSerializer (typeof (MidiModuleDefinition));
     foreach (string arg in args) {
         var mod = imp.Import (arg);
         var ms = new MemoryStream ();
         ds.WriteObject (ms, mod);
         ms.Position = 0;
         var s = new StreamReader (ms).ReadToEnd ();
         s = s.Replace ("},", "},\n");
         using (var sw = File.CreateText (Path.ChangeExtension (arg, "midimod")))
             sw.Write (s);
     }
 }
开发者ID:atsushieno,项目名称:portmidi-sharp,代码行数:15,代码来源:domino-importer.cs

示例13: BindModel

        public override object BindModel( ControllerContext controllerContext, ModelBindingContext bindingContext )
        {
            if ( EhRequisicaoJson( controllerContext ) )
            {
                string jsonData = new StreamReader( controllerContext.RequestContext.HttpContext.Request.InputStream ).ReadToEnd();

                if ( jsonData.StartsWith( Root ) )
                {
                    jsonData = jsonData.Replace( Root, "" );
                    jsonData = jsonData.Substring( 0, jsonData.Length - 1 );
                }

                JavaScriptSerializer serializer = new JavaScriptSerializer();

                return serializer.Deserialize( jsonData, bindingContext.ModelMetadata.ModelType );
            }

            return base.BindModel( controllerContext, bindingContext );
        }
开发者ID:hvitorino,项目名称:jornada7,代码行数:19,代码来源:ExtJsModelBinder.cs

示例14: getXS1ActuatorList

        public XS1ActuatorList getXS1ActuatorList(String XS1_URL, String Username, String Password)
        {
            // TODO: more error handling !!!

            // check if we already cached something
            if (ActuatorListCache != null)
            {
                if ((DateTime.Now - LastActuatorListUpdated).TotalMinutes < ConfigurationCacheMinutes)
                    return ActuatorListCache;
            }

            // now we got the parameters, we need to find out which actors and which functions shall be called
            WebRequest wrGetURL = WebRequest.Create("http://" + XS1_URL + "/control?user=" + Username + "&pwd=" + Password + "&callback=actorlist&cmd=get_list_actuators");

            String _UsernameAndPassword = Username + ":" + Password;
            String _AuthorizationHeader = "Basic " + Convert.ToBase64String(new ASCIIEncoding().GetBytes(_UsernameAndPassword));

            wrGetURL.Credentials = new NetworkCredential(Username, Password);
            wrGetURL.Headers.Add("Authorization", _AuthorizationHeader);
            HttpWebResponse response = (HttpWebResponse)wrGetURL.GetResponse();
            // check for eventual errors
            if (response.StatusCode != HttpStatusCode.OK)
            {
                // TODO: refactor to correct http response codes
                return null;
            }
            // we will read data via the response stream
            String actuator_config_json = new StreamReader(response.GetResponseStream()).ReadToEnd();

            JavaScriptSerializer ser = new JavaScriptSerializer();
            ser.MaxJsonLength = 20000000;

            // remove the javascript callback/definitions
            actuator_config_json = actuator_config_json.Replace("actorlist(", "");
            actuator_config_json = actuator_config_json.Remove(actuator_config_json.Length - 4, 4);

            // deserialize the XS1 configuration json stream
            ActuatorListCache = ser.Deserialize<XS1ActuatorList>(actuator_config_json);

            LastActuatorListUpdated = DateTime.Now;

            return ActuatorListCache;
        }
开发者ID:pereritob,项目名称:hacs,代码行数:43,代码来源:XS1-Configuration.cs

示例15: OCR

		public static string OCR(string filename) {
			string str2;
			object obj2;
			Monitor.Enter(obj2 = mutex);
			try {
				string str;

				string workingDirectory = Path.GetTempPath();
				if (File.Exists(workingDirectory + @"\tesseract.exe") == false) {
					using (Stream s = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("GodLesZ.Library.Captcha.tesseract.exe")) {
						byte[] buf = new byte[s.Length];
						s.Read(buf, 0, buf.Length);
						File.WriteAllBytes(workingDirectory + @"\tesseract.exe", buf);
					}
				}
				Run("tesseract.exe", Path.GetFileName(filename) + " tesseract-output", workingDirectory, 0);

				using (FileStream stream = new FileStream(workingDirectory + @"\tesseract-output.txt", FileMode.Open)) {
					str = new StreamReader(stream).ReadToEnd();
				}
				try {
					File.Delete(workingDirectory + @"\tesseract-output.txt");
				} catch { }
				try {
					File.Delete(workingDirectory + @"\tesseract.exe");
				} catch { }

				str = str.Replace(" ", "").Replace("\n", "").Replace("\r", "").Replace("\t", "");
				if (str.Length == 0) {
					return null;
				}
				str2 = str;
			} catch (ThreadAbortException) {
				throw;
			} catch (Exception) {
				str2 = null;
			} finally {
				Monitor.Exit(obj2);
			}
			return str2;
		}
开发者ID:GodLesZ,项目名称:svn-dump,代码行数:41,代码来源:CaptchaKiller.cs


注:本文中的System.IO.StreamReader.Replace方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。