/// <summary> ///Renders the code as defined in the source script file. ///</summary> ///<param name="setting"></param> public virtual void RenderConnectionString(SettingsFileSetting setting) { this.Output.Write(@" [global::System.Configuration.ApplicationScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Configuration.SpecialSettingAttribute(global::System.Configuration.SpecialSetting.ConnectionString)] [global::System.Configuration.DefaultSettingValueAttribute("); this.Output.Write( GetDefaultSetting(setting) ); this.Output.Write(")]\r\n\t\tpublic string "); this.Output.Write( setting.Name ); this.Output.Write(" {\r\n\t\t\tget {\r\n\t\t\t\treturn ((string)(this[\""); this.Output.Write( setting.Name ); this.Output.Write("\"]));\r\n\t\t\t}\r\n\t\t}\r\n"); this.Output.WriteLine(); }
/// <summary> /// Transforms the default value of a setting into a string that can be used as an /// attribute value in the rendered code. /// </summary> private string GetDefaultSetting(SettingsFileSetting setting) { if (setting.Value == null || string.IsNullOrEmpty(setting.Value.Value)) return "\"\""; // value not specified, just return an empty string. // massage the string so that it can be as an attribute value // (the value sometimes does not contain \r\n but only \r or only \n. string value = setting.Value.Value; if (!value.Contains("\n") && !value.Contains("\r")) return string.Concat("\"", value.Replace(@"\", @"\\").Replace("\"", "\\\""), "\""); value = value.Replace(Environment.NewLine, "\n"); value = value.Replace("\r", "\n"); value = value.Replace("\n", Environment.NewLine); return string.Concat("@\"", value.Replace("\"", "\"\""), "\""); }
/// <summary> ///Renders the code as defined in the source script file. ///</summary> ///<param name="setting"></param> public virtual void RenderSetting(SettingsFileSetting setting) { this.Output.Write(" \t\t[global::System.Configuration."); this.Output.Write( setting.Scope ); this.Output.Write("ScopedSettingAttribute()]\r\n\t\t[global::System.Diagnostics.DebuggerNonUserCodeAttri" + "bute()]\r\n\t\t[global::System.Configuration.DefaultSettingValueAttribute("); this.Output.Write( GetDefaultSetting(setting) ); this.Output.Write(")]\r\n\t\tpublic "); this.Output.Write( setting.LangType ); this.Output.Write(" "); this.Output.Write( setting.PropertyName ); this.Output.Write(" {\r\n\t\t\tget {\r\n\t\t\t\treturn (("); this.Output.Write( setting.LangType ); this.Output.Write(")(this[\""); this.Output.Write( setting.PropertyName ); this.Output.Write("\"]));\r\n\t\t\t} "); if (setting.Scope != "Application" && !setting.IsReadOnly) { this.Output.Write("\r\n\t\t\tset {\r\n\t\t\t\tthis[\""); this.Output.Write( setting.PropertyName ); this.Output.Write("\"] = value;\r\n\t\t\t} "); } this.Output.Write("\r\n\t\t}"); this.Output.WriteLine(); }
/// <summary> ///Renders the code as defined in the source script file. ///</summary> ///<param name="setting"></param> public virtual void RenderWebServiceUrl(SettingsFileSetting setting) { this.Output.Write(" \t\t[global::System.Configuration."); this.Output.Write( setting.Scope ); this.Output.Write(@"ScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Configuration.SpecialSettingAttribute(global::System.Configuration.SpecialSetting.WebServiceUrl)] [global::System.Configuration.DefaultSettingValueAttribute("); this.Output.Write( GetDefaultSetting(setting) ); this.Output.Write(")]\r\n\t\tpublic string "); this.Output.Write( setting.Name ); this.Output.Write(" {\r\n\t\t\tget {\r\n\t\t\t\treturn ((string)(this[\""); this.Output.Write( setting.Name ); this.Output.Write("\"]));\r\n\t\t\t} "); if (setting.Scope != "Application") { this.Output.Write("\r\n\t\t\tset {\r\n\t\t\t\tthis[\""); this.Output.Write( setting.Name ); this.Output.Write("\"] = value;\r\n\t\t\t} "); } this.Output.Write("\r\n\t\t}"); this.Output.WriteLine(); }