本文整理汇总了C#中Template.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# Template.ToString方法的具体用法?C# Template.ToString怎么用?C# Template.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Template
的用法示例。
在下文中一共展示了Template.ToString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: setDbConfig
public void setDbConfig()
{
String dbType = ctx.Post( "dbType" );
String dbAddress = ctx.Post( "dbAddress" );
String dbName = ctx.Post( "dbName" );
String user = ctx.Post( "user" );
String pwd = ctx.Post( "pwd" );
String connectionString = createConnectionString( dbType, dbAddress, dbName, user, pwd );
String strConfig = getConfigTemplate();
Template t = new Template();
t.InitContent( strConfig );
t.Set( "connectionString", connectionString );
t.Set( "dbType", dbType );
String fileName = "/config/orm_test.config";
String filePath = strUtil.Join( cfgHelper.FrameworkRoot, fileName );
String dataPath = PathHelper.Map( filePath );
file.Write( dataPath, t.ToString() );
echoAjaxOk();
}
示例2: GenerateList
/// <summary>
/// Generates the API listing
/// </summary>
public string GenerateList()
{
var tmpl = new Template();
tmpl.Add("");
tmpl.Add("----");
tmpl.Add("");
tmpl.Add("== {TITLE} ==");
tmpl.Add("{DESCRIPTION}");
tmpl.Add("{CONTENT}");
tmpl.Add("");
tmpl.Add("=== Samples ===");
tmpl.Add("{SAMPLES}");
return Discovery.ListApis()
.GroupBy(api => api.Name)
.Select(grp => new { Title=GetApiTitle(grp.First()), APIs=grp })
.OrderBy(qry => qry.Title)
.Select(qry => tmpl.ToString(new Entries {
{ "TITLE", qry.Title.WithoutWikiLinks() },
{ "DESCRIPTION", qry.APIs.First().Description.WithoutWikiLinks().MakeSentence('.') },
{ "CONTENT", GenerateApiVersions(qry.APIs) },
{ "SAMPLES", GenerateSamples(qry.APIs.Key) } }))
.Aggregate(TextUtils.JoinLines);
}
示例3: TemplateDown
public void TemplateDown()
{
c_Template--;
if ( c_Template < 0 )
for( c_Template = 0; ; ++c_Template )
if ( c_Template.ToString().Length < 3 )
{
c_Template--;
return;
}
}
示例4: DesktopImagesAdd
public ActionResult DesktopImagesAdd(Template newItem)
{
using (log4net.NDC.Push(Guid.NewGuid().ToString()))
{
logger.Debug("Legit request to Create template " + newItem.ToString());
Task.Run(() => Template.CreateTemplate(newItem, CloudStackClient));
logger.Debug("Task running");
newItem.Ready = CreateStatus;
return RedirectToAction("DesktopImages", newItem);
}
}
示例5: ShowMore
public static void ShowMore(object sender, ShowPPageEventArgs e)
{
char[] trimStartChars = { '.', '/' };
string galleryPath = e.Slug;
if (galleryPath != null)
{
galleryPath = galleryPath.TrimEnd('/').TrimStart(trimStartChars);
}
else
{
galleryPath = "";
}
Gallery gallery;
if (galleryPath != "")
{
try
{
gallery = new Gallery(e.Core, e.Page.Owner, galleryPath);
if (!gallery.Access.Can("VIEW"))
{
e.Core.Functions.Generate403();
return;
}
}
catch (InvalidGalleryException)
{
return;
}
}
else
{
gallery = new Gallery(e.Core, e.Page.Owner);
}
Template template = new Template(Assembly.GetExecutingAssembly(), "pane_photo");
template.Medium = e.Core.Template.Medium;
template.SetProse(e.Core.Prose);
bool moreContent = false;
long lastId = 0;
List<GalleryItem> galleryItems = gallery.GetItems(e.Core, e.Page.TopLevelPageNumber, 12, e.Page.TopLevelPageOffset);
int i = 0;
foreach (GalleryItem galleryItem in galleryItems)
{
VariableCollection galleryVariableCollection = template.CreateChild("photo_list");
galleryVariableCollection.Parse("TITLE", galleryItem.ItemTitle);
galleryVariableCollection.Parse("PHOTO_URI", Gallery.BuildPhotoUri(e.Core, e.Page.Owner, galleryItem.ParentPath, galleryItem.Path));
galleryVariableCollection.Parse("COMMENTS", e.Core.Functions.LargeIntegerToString(galleryItem.Comments));
galleryVariableCollection.Parse("VIEWS", e.Core.Functions.LargeIntegerToString(galleryItem.ItemViews));
galleryVariableCollection.Parse("INDEX", i.ToString());
galleryVariableCollection.Parse("ID", galleryItem.Id.ToString());
galleryVariableCollection.Parse("TYPE_ID", galleryItem.ItemKey.TypeId.ToString());
galleryVariableCollection.Parse("ICON", galleryItem.IconUri);
galleryVariableCollection.Parse("TILE", galleryItem.TileUri);
galleryVariableCollection.Parse("SQUARE", galleryItem.SquareUri);
galleryVariableCollection.Parse("TINY", galleryItem.TinyUri);
galleryVariableCollection.Parse("THUMBNAIL", galleryItem.ThumbnailUri);
Display.RatingBlock(galleryItem.ItemRating, galleryVariableCollection, galleryItem.ItemKey);
if (galleryItem.Info.Likes > 0)
{
galleryVariableCollection.Parse("LIKES", string.Format(" {0:d}", galleryItem.Info.Likes));
galleryVariableCollection.Parse("DISLIKES", string.Format(" {0:d}", galleryItem.Info.Dislikes));
}
switch (i % 3)
{
case 0:
galleryVariableCollection.Parse("ABC", "a");
break;
case 1:
galleryVariableCollection.Parse("ABC", "b");
break;
case 2:
galleryVariableCollection.Parse("ABC", "c");
break;
}
switch (i % 4)
{
case 0:
galleryVariableCollection.Parse("ABCD", "a");
break;
case 1:
galleryVariableCollection.Parse("ABCD", "b");
break;
case 2:
galleryVariableCollection.Parse("ABCD", "c");
break;
case 3:
//.........这里部分代码省略.........
示例6: AccountGalleriesUpload_Save
void AccountGalleriesUpload_Save(object sender, EventArgs e)
{
ControlPanelSubModule.AuthoriseRequestSid(core);
long galleryId = core.Functions.FormLong("gallery-id", 0);
string title = core.Http.Form["title"];
string galleryTitle = core.Http.Form["gallery-title"];
string description = core.Http.Form["description"];
bool publishToFeed = (core.Http.Form["publish-feed"] != null);
bool highQualitySave = (core.Http.Form["high-quality"] != null);
bool submittedTitle = true;
if (string.IsNullOrEmpty(galleryTitle))
{
submittedTitle = false;
galleryTitle = "Uploaded " + core.Tz.Now.ToString("MMMM dd, yyyy");
}
bool newGallery = core.Http.Form["album"] == "create";
int filesUploaded = 0;
for (int i = 0; i < core.Http.Files.Count; i++)
{
if (core.Http.Files.GetKey(i).StartsWith("photo-file", StringComparison.Ordinal))
{
filesUploaded++;
if (core.Http.Files[i] == null || core.Http.Files[i].ContentLength == 0)
{
core.Response.ShowMessage("error", "No files selected", "You need to select some files to upload");
}
}
}
if (filesUploaded == 0)
{
core.Response.ShowMessage("error", "No files selected", "You need to select some files to upload");
return;
}
try
{
Gallery parent = null;
if (newGallery)
{
Gallery grandParent = null;
if (!submittedTitle)
{
string grandParentSlug = "photos-from-posts";
try
{
grandParent = new Gallery(core, Owner, grandParentSlug);
}
catch (InvalidGalleryException)
{
Gallery root = new Gallery(core, Owner);
grandParent = Gallery.Create(core, Owner, root, "Photos From Posts", ref grandParentSlug, "All my unsorted uploads");
}
}
else
{
grandParent = new Gallery(core, Owner);
}
string gallerySlug = string.Empty;
if (!submittedTitle)
{
gallerySlug = "photos-" + UnixTime.UnixTimeStamp().ToString();
}
else
{
gallerySlug = Gallery.GetSlugFromTitle(galleryTitle, "");
}
try
{
parent = Gallery.Create(core, LoggedInMember, grandParent, galleryTitle, ref gallerySlug, string.Empty);
}
catch (GallerySlugNotUniqueException)
{
core.Response.ShowMessage("error", "Gallery not unique", "Please give a different name to the gallery");
}
AccessControlLists acl = new AccessControlLists(core, parent);
acl.SaveNewItemPermissions();
}
else
{
parent = new Gallery(core, Owner, galleryId);
}
string slug = string.Empty;
try
{
for (int i = 0; i < core.Http.Files.Count; i++)
{
if (!core.Http.Files.GetKey(i).StartsWith("photo-file", StringComparison.Ordinal))
{
//.........这里部分代码省略.........
示例7: Write
public void Write(Template template)
{
Write(template.ToString());
}
示例8: AddPostPanel
public void AddPostPanel(string title, Template t)
{
VariableCollection panelVariableCollection = createPostPanel();
panelVariableCollection.ParseRaw("TITLE", title);
panelVariableCollection.ParseRaw("BODY", t.ToString());
}
示例9: AddPrimitiveHeadPanel
public void AddPrimitiveHeadPanel(Template t)
{
VariableCollection panelVariableCollection = createPrimitiveHeadPanel();
panelVariableCollection.ParseRaw("BODY", t.ToString());
}
示例10: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
bool isAjax = false;
long itemId;
long itemTypeId;
ItemKey itemKey = null;
IShareableItem item = null;
if (Request["ajax"] == "true")
{
isAjax = true;
}
if (!core.Session.IsLoggedIn)
{
core.Response.ShowMessage("notLoggedIn", "Not Logged In", "Sign in to share this item.");
}
string mode = Request.QueryString["mode"];
if (mode == "post")
{
template.SetTemplate("pane.share.post.html");
try
{
itemId = long.Parse((string)core.Http.Query["item"]);
itemTypeId = long.Parse((string)core.Http.Query["type"]);
itemKey = new ItemKey(itemId, itemTypeId);
item = (IShareableItem)NumberedItem.Reflect(core, itemKey);
TextBox messageTextBox = new TextBox("share-message");
PermissionGroupSelectBox permissionSelectBox = new PermissionGroupSelectBox(core, "share-permissions", core.Session.LoggedInMember.ItemKey);
template.Parse("S_SHARE_MESSAGE", messageTextBox);
template.Parse("S_SHARE_PERMISSIONS", permissionSelectBox);
template.Parse("S_SHARED_URI", item.Info.ShareUri);
core.Display.ParseBbcode(template, "S_SHARED_STRING", core.Functions.Tldr("[share=\"[iurl=\"" + item.Uri + "\"]" + item.Owner.DisplayName + "[/iurl]\"]" + item.ShareString + "[/share]"), item.Owner);
}
catch
{
core.Response.SendRawText("errorFetchingItem", "");
return;
}
core.Response.SendRawText("sharingForm", template.ToString());
return;
}
// Save the Share
try
{
itemId = long.Parse((string)core.Http.Form["item"]);
itemTypeId = long.Parse((string)core.Http.Form["type"]);
}
catch
{
core.Response.SendRawText("errorFetchingItem", "");
return;
}
itemKey = new ItemKey(itemId, itemTypeId);
item = (IShareableItem)NumberedItem.Reflect(core, itemKey);
if (item is IPermissibleItem)
{
IPermissibleItem pitem = (IPermissibleItem)item;
if (!pitem.Access.IsPublic())
{
core.Response.ShowMessage("cannotShare", "Cannot Share", "You can only share public items.");
return;
}
}
string message = (string)core.Http.Form["share-message"] + "\n\n" + core.Functions.Tldr("[share=\"[iurl=\"" + item.Uri + "\"]" + item.Owner.DisplayName + "[/iurl]\"]" + item.ShareString + "[/share]");
StatusMessage newStatus = StatusMessage.Create(core, core.Session.LoggedInMember, message);
AccessControlLists acl = new AccessControlLists(core, newStatus);
acl.SaveNewItemPermissions("share-permissions");
core.Search.Index(newStatus);
ApplicationEntry ae = core.GetApplication("Profile");
ae.PublishToFeed(core, core.Session.LoggedInMember, newStatus, Functions.SingleLine(core.Bbcode.Flatten(newStatus.Message)));
Share.ShareItem(core, itemKey);
if (Request.Form["ajax"] == "true")
{
Template template = new Template("pane.statusmessage.html");
template.Medium = core.Template.Medium;
template.SetProse(core.Prose);
VariableCollection statusMessageVariableCollection = template.CreateChild("status_messages");
core.Display.ParseBbcode(statusMessageVariableCollection, "STATUS_MESSAGE", core.Bbcode.FromStatusCode(newStatus.Message), core.Session.LoggedInMember, true, string.Empty, string.Empty);
statusMessageVariableCollection.Parse("STATUS_UPDATED", core.Tz.DateTimeToString(newStatus.GetTime(core.Tz)));
//.........这里部分代码省略.........
示例11: setDbConfig
public void setDbConfig()
{
String dbType = ctx.Post( "dbType" );
String dbName = ctx.Post( "dbName" );
String connectionStr = ctx.Post( "connectionStr" );
String connectionString = createConnectionString( dbType, dbName, connectionStr );
if (ctx.HasErrors) {
echoText( errors.ErrorsText );
return;
}
String strConfig = getConfigTemplate();
Template t = new Template();
t.InitContent( strConfig );
t.Set( "connectionString", connectionString );
t.Set( "dbType", dbType );
String fileName = "/config/orm.config";
String filePath = strUtil.Join( cfgHelper.FrameworkRoot, fileName );
String dataPath = PathHelper.Map( filePath );
file.Write( dataPath, t.ToString() );
sys.Clear.ClearAll();
echoAjaxOk();
}
示例12: BuildClassificationBox
public static string BuildClassificationBox(Core core, Classifications classification)
{
if (core == null)
{
throw new NullCoreException();
}
Template template = new Template(core.Http.TemplatePath, "std.classifications_box.html");
template.Medium = core.Template.Medium;
template.SetProse(core.Prose);
switch (classification)
{
case Classifications.None:
template.Parse("IS_NONE", boxChecked);
break;
case Classifications.Everyone:
template.Parse("IS_EVERYONE", boxChecked);
break;
case Classifications.Mature:
template.Parse("IS_MATURE", boxChecked);
break;
case Classifications.Restricted:
template.Parse("IS_RESTRICTED", boxChecked);
break;
}
return template.ToString();
}
示例13: AccountMessage_Poll
void AccountMessage_Poll(object sender, EventArgs e)
{
AuthoriseRequestSid();
long messageId = core.Functions.RequestLong("id", 0);
long newestId = core.Functions.RequestLong("newest-id", 0);
try
{
Template template = new Template(core.CallingApplication.Assembly, "pane_message");
template.Medium = core.Template.Medium;
template.SetProse(core.Prose);
MessageRecipient recipient = new MessageRecipient(core, core.Session.LoggedInMember, messageId);
Message threadStart = new Message(core, messageId);
template.Parse("S_ID", threadStart.Id.ToString());
List<Message> messages = threadStart.GetMessages(newestId, true);
// IF NOT DELETED THEN
foreach (Message message in messages)
{
RenderMessage(core, template, message);
newestId = message.Id;
}
threadStart.MarkRead();
Dictionary<string, string> returnValues = new Dictionary<string, string>();
returnValues.Add("update", "true");
returnValues.Add("template", template.ToString());
returnValues.Add("newest-id", newestId.ToString());
core.Response.SendDictionary("newMessages", returnValues);
}
catch (InvalidMessageRecipientException)
{
// Security, if not a recipeint, cannot see the message.
core.Functions.Generate404();
}
}
示例14: SendEmail
public override void SendEmail(string toAddress, string subject, Template message)
{
RestClient client = new RestClient();
client.BaseUrl = baseUri;
client.Authenticator = new HttpBasicAuthenticator("api", apiKey);
RestRequest request = new RestRequest();
request.AddParameter("domain", domain, ParameterType.UrlSegment);
request.Resource = "{domain}/messages";
request.AddParameter("from", fromName + " <" + fromEmail + ">");
request.AddParameter("to", toAddress);
request.AddParameter("subject", subject);
request.AddParameter("html", message.ToString());
request.Method = Method.POST;
client.Execute(request);
}
示例15: testMsgHtml
public void testMsgHtml()
{
String html = @"<!DOCTYPE html>
<html lang=""zh-CN"">
<head>
<meta http-equiv=""Content-Type"" content=""text/html; charset=utf-8"" />
<title>_{sysMsg}</title>
<link href=""~css/wojilu._common.css?v=#{cssVersion}"" rel=""stylesheet"" type=""text/css"" />
<script>var __funcList = []; var _run = function (aFunc) { __funcList.push(aFunc); }; var require = { urlArgs: 'v=#{jsVersion}' };</script>
</head>
<body style=""background:#fff;"">
<div style=""width:500px;margin:50px auto;background:#efefef; border:1px #ccc dotted; line-height:150%"">
<div style=""padding:15px; "">
<div>#{msg}</div>
<div style=""margin:20px 0px 10px 0px;font-size:14px;font-weight:bold; text-align:center;"" id=""msgInfoGlobalSite"">
<a href=""javascript:history.back();"">‹‹ _{return}</a>
<span id=""lnkHome"" class=""link"" data-link=""#{siteUrl}"" style=""margin-left:30px""><img src=""~img/home.gif""/>_{siteHome}</span>
</div>
</div>
</div>
<script>
_run( function() {
$('#lnkHome').click( function() {
wojilu.tool.forwardPage( $(this).attr('data-link') );
});
});
</script>
<script data-main=""~js/main"" src=""~js/lib/require-jquery-wojilu.js?v=#{jsVersion}""></script>
<script>require(['wojilu._nolayout']);</script>
</body>
</html>";
Template t = new Template();
t.InitContent( html );
String ret = t.ToString();
Console.WriteLine( ret );
}