本文整理汇总了C#中UrlString.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# UrlString.ToString方法的具体用法?C# UrlString.ToString怎么用?C# UrlString.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UrlString
的用法示例。
在下文中一共展示了UrlString.ToString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Execute
/// <summary>
/// Add a new Content Editor Tab to Content Editor so that users can search for hidden content
/// </summary>
/// <param name="context">Context of Call</param>
public override void Execute(CommandContext context)
{
Assert.ArgumentNotNull(context, "context");
if (context.Items.Length == 1)
{
var itemId = context.Parameters[0];
if (WebUtil.GetFormValue("scEditorTabs").Contains("contenteditor:launchtab") && WebUtil.GetFormValue("scEditorTabs").Contains(itemId))
{
SheerResponse.Eval("scContent.onEditorTabClick(null, null, '" + itemId + "')");
}
else
{
var urlString = new UrlString("/sitecore/shell/sitecore/content/Applications/Content%20Editor.aspx");
urlString.Add(Util.Constants.OpenItemEditorQueryStringKeyName, itemId);
TrackOpenTab(context);
context.Items[0].Uri.AddToUrlString(urlString);
UIUtil.AddContentDatabaseParameter(urlString);
urlString.Add(Util.Constants.ModeQueryStringKeyName, "preview");
urlString.Add(Util.Constants.RibbonQueryStringKeyName, "{D3A2D76F-02E6-49DE-BE90-D23C9771DC8D}");
var language = context.Parameters["la"].IsNull() ? Sitecore.Context.Language.CultureInfo.TwoLetterISOLanguageName : context.Parameters["la"];
urlString.Add("la", language);
AddLatestVersionToUrlString(urlString, itemId, language);
SheerResponse.Eval(new ShowEditorTab { Command = "contenteditor:launchtab", Header = Translate.Text(Context.ContentDatabase.GetItem(itemId).Name), Icon = Images.GetThemedImageSource("Applications/16x16/text_view.png"), Url = urlString.ToString(), Id = itemId, Closeable = true, Activate = Util.Constants.SettingsItem.Fields[Util.Constants.OpenSearchResult].Value == "New Tab Not Selected" ? false : true }.ToString());
}
}
}
示例2: ProcessRecord
protected override void ProcessRecord()
{
LogErrors(() =>
{
string response = null;
if (!string.IsNullOrEmpty(Url))
{
response = JobContext.ShowModalDialog(Url, WidthString, HeightString);
}
else if (!string.IsNullOrEmpty(Control))
{
UrlString url = new UrlString(UIUtil.GetUri("control:" + Control));
url["te"] = Title ?? "Sitecore";
if (Parameters != null)
{
foreach (string key in Parameters.Keys)
{
url.Add(key, WebUtil.SafeEncode(Parameters[key].ToString()));
}
}
var message = new ShowModalDialogPsMessage(url.ToString(), WidthString, HeightString, HandleParameters);
PutMessage(message);
response = (string)GetSheerResult(message);
}
WriteObject(response);
});
}
示例3: GetMediaUrl
/// <summary>
/// If CDN is enabled for this request, replace the outgoing media url with the cdn version
/// </summary>
/// <param name="item"></param>
/// <param name="options"></param>
/// <returns></returns>
public override string GetMediaUrl(Sitecore.Data.Items.MediaItem item, MediaUrlOptions options)
{
string hostname = CDNManager.GetCDNHostName();
string url = base.GetMediaUrl(item, options);
bool shouldReplace = !string.IsNullOrEmpty(hostname) && // cdnHostname exists for site
Sitecore.Context.PageMode.IsNormal; // PageMode is normal
bool dontReplace = !CDNManager.IsMediaPubliclyAccessible(item) || // media is publicly accessible
CDNManager.IsMediaAnalyticsTracked(item); // media is analytics tracked
CDNUrlState contextState = CDNUrlSwitcher.CurrentValue;
if (contextState == CDNUrlState.Enabled)
{
shouldReplace = true;
}
else if (contextState == CDNUrlState.Disabled)
{
UrlString url2 = new UrlString(url);
url2[CDNManager.StopToken] = "1";
url = url2.ToString();
shouldReplace = false;
}
if (shouldReplace && !dontReplace) // media not DMS tracked
{
return CDNManager.ReplaceMediaUrl(url, hostname);
}
else
{
return url;
}
}
示例4: Execute
/// <summary>
/// Executes the command in the specified context.
/// </summary>
/// <param name="context">The context.</param>
public override void Execute(CommandContext context)
{
// updated to publish the site configuration nodes. flushing will be handled by publish end events
UrlString str = new UrlString(UIUtil.GetUri("control:MultisitesManager.FlushSites"));
SheerResponse.ShowModalDialog(str.ToString());
}
示例5: Execute
/// <summary>
/// Add a new Content Editor Tab to Content Editor so that users can search for hidden content
/// </summary>
/// <param name="context">Context of Call</param>
public override void Execute(CommandContext context)
{
Assert.ArgumentNotNull(context, "context");
if (context.Items.Length == 1)
{
var itemId = context.Parameters[0];
//if (WebUtil.GetFormValue("scEditorTabs").Contains("contenteditor:launchtab") && WebUtil.GetFormValue("scEditorTabs").Contains(itemId))
//{
// SheerResponse.Eval("scContent.onEditorTabClick(null, null, '" + itemId + "')");
//}
//else
//{
var urlString = new UrlString("/sitecore%20modules/Shell/Sitecore/ItemBuckets/ShowResult.aspx");
urlString.Add(Util.Constants.OpenItemEditorQueryStringKeyName, itemId);
context.Items[0].Uri.AddToUrlString(urlString);
UIUtil.AddContentDatabaseParameter(urlString);
urlString.Add(Util.Constants.ModeQueryStringKeyName, "preview");
urlString.Add(Util.Constants.RibbonQueryStringKeyName, "{D3A2D76F-02E6-49DE-BE90-D23C9771DC8D}");
var language = context.Parameters["la"].IsNull() ? Sitecore.Context.Language.CultureInfo.TwoLetterISOLanguageName : context.Parameters["la"];
urlString.Add("la", language);
//SheerResponse.Eval(new ShowEditorTab { Command = "contenteditor:launchtab", Header = "Another Search", Icon = Images.GetThemedImageSource("Applications/16x16/text_view.png"), Url = urlString.ToString(), Id = Id, Closeable = true, Activate = true }.ToString());
SheerResponse.Eval(new ShowEditorTab { Command = "contenteditor:launchblanktab", Header = "Search " + DateTime.Now.ToLongTimeString(), Icon = Images.GetThemedImageSource("Applications/16x16/text_view.png"), Url = urlString.ToString(), Id = new Random().Next(0, 99999999).ToString(), Closeable = true, Activate = true }.ToString());
// }
}
}
示例6: Process
public void Process(WorkflowPipelineArgs args)
{
Assert.ArgumentNotNull(args, "args");
var processorItem = args.ProcessorItem;
if (processorItem == null)
{
return;
}
var actionItem = processorItem.InnerItem;
var dataItem = args.DataItem;
if (string.IsNullOrEmpty(actionItem[ScriptItemFieldNames.Script]))
{
return;
}
var scriptItem = actionItem.Database.GetItem(new ID(actionItem[ScriptItemFieldNames.Script]));
if (RulesUtils.EvaluateRules(actionItem[ScriptItemFieldNames.EnableRule], dataItem) &&
RulesUtils.EvaluateRules(scriptItem[ScriptItemFieldNames.EnableRule], dataItem))
{
var str = new UrlString(UIUtil.GetUri("control:PowerShellRunner"));
str.Append("id", dataItem.ID.ToString());
str.Append("db", dataItem.Database.Name);
str.Append("lang", dataItem.Language.Name);
str.Append("ver", dataItem.Version.Number.ToString(CultureInfo.InvariantCulture));
str.Append("scriptId", scriptItem.ID.ToString());
str.Append("scriptDb", scriptItem.Database.Name);
Context.ClientPage.ClientResponse.Broadcast(
SheerResponse.ShowModalDialog(str.ToString(), "400", "220", "PowerShell Script Results", false),
"Shell");
}
}
示例7: Process
public virtual void Process(RenderingPropertiesFieldEditorArgs args)
{
Assert.ArgumentNotNull(args, "args");
Assert.ArgumentNotNull(args.StandardValuesItem, "args.StandardValuesItem");
Assert.ArgumentNotNullOrEmpty(args.Handle, "args.Handle");
Assert.ArgumentNotNull(args.RenderingDefinition, "args.RenderingDefinition");
var renderingDef = args.RenderingDefinition;
var fieldCol = args.StandardValuesItem.Fields;
var parameters = new UrlString();
var options = RenderingParametersFieldEditorOptions.Parse(args.Handle);
//
//save the parameters that have already been set
if (! string.IsNullOrEmpty(args.RenderingDefinition.Parameters))
{
var currentParams = new UrlString(args.RenderingDefinition.Parameters);
foreach (var key in currentParams.Parameters.AllKeys)
{
var name = key;
var value = currentParams[key];
SetValue(renderingDef, parameters, name, value);
}
}
foreach (var field in options.Fields)
{
SetValue(renderingDef, parameters, fieldCol[field.FieldID].Name, field.Value);
}
args.RenderingDefinition.Parameters = parameters.ToString();
}
示例8: Execute
public override void Execute(CommandContext context)
{
var urlString = new UrlString(UIUtil.GetUri("control:PowerShellExternalView"));
var keys = context.Parameters.AllKeys;
using (var session = ScriptSessionManager.GetSession(string.Empty, ApplicationNames.Default, false))
{
session.ExecuteScriptPart("");
foreach (var key in keys)
{
var param =
context.Parameters[key]
.Replace("{spe}", GetType().Assembly.GetName().Version.ToString())
.Replace("{ps}", ScriptSession.PsVersion.Major + "." + ScriptSession.PsVersion.Minor)
.Replace("{sc}",
SitecoreVersion.Current.Major + "." +
SitecoreVersion.Current.Minor);
urlString.Add(key, param);
}
}
var width = keys.Contains("spe_w", StringComparer.OrdinalIgnoreCase)
? context.Parameters["spe_w"]
: keys.Contains("width", StringComparer.OrdinalIgnoreCase) ? context.Parameters["width"] : "800";
var height = keys.Contains("spe_h", StringComparer.OrdinalIgnoreCase)
? context.Parameters["spe_h"]
: keys.Contains("height", StringComparer.OrdinalIgnoreCase) ? context.Parameters["height"] : "800";
SheerResponse.ShowModalDialog(urlString.ToString(), width, height);
}
示例9: SelectFields
public void SelectFields(ClientPipelineArgs args)
{
Assert.ArgumentNotNull(args, "args");
if (!args.IsPostBack)
{
UrlString urlString = new UrlString(UIUtil.GetUri("control:TreeListExEditor"));
UrlHandle urlHandle = new UrlHandle();
urlHandle["title"] = PullUpFieldsSettings.SelectFieldsDialogTitle;
urlHandle["text"] = PullUpFieldsSettings.SelectFieldsDialogText;
urlHandle["source"] = GetSelectFieldsDialogSource(args);
urlHandle.Add(urlString);
SheerResponse.ShowModalDialog
(
urlString.ToString(),
PullUpFieldsSettings.SelectFieldsDialogWidth,
PullUpFieldsSettings.SelectFieldsDialogHeight,
string.Empty,
true
);
args.WaitForPostBack();
}
else if (args.HasResult)
{
args.Parameters["fieldIds"] = args.Result;
args.IsPostBack = false;
}
else
{
CancelOperation(args);
}
}
示例10: Execute
public override void Execute(CommandContext context)
{
var scriptId = context.Parameters["script"];
var scriptDb = context.Parameters["scriptDb"];
var itemId = string.Empty;
var itemDb = string.Empty;
var itemLang = string.Empty;
var itemVer = string.Empty;
if (context.Items.Length > 0)
{
itemId = context.Items[0].ID.ToString();
itemDb = context.Items[0].Database.Name;
itemLang = context.Items[0].Language.Name;
itemVer = context.Items[0].Version.Number.ToString(CultureInfo.InvariantCulture);
}
var str = new UrlString(UIUtil.GetUri("control:PowerShellRunner"));
str.Append("id", itemId);
str.Append("db", itemDb);
str.Append("lang", itemLang);
str.Append("ver", itemVer);
str.Append("scriptId", scriptId);
str.Append("scriptDb", scriptDb);
Context.ClientPage.ClientResponse.Broadcast(
SheerResponse.ShowModalDialog(str.ToString(), "400", "260", "PowerShell Script Results", false),
"Shell");
}
示例11: Execute
/// <summary>
/// Add a new Content Editor Tab to Content Editor so that users can search for hidden content
/// </summary>
/// <param name="context">Context of Call</param>
public override void Execute(CommandContext context)
{
Assert.ArgumentNotNull(context, "context");
if (context.Items.Length == 1)
{
string s = context.Parameters[0];
if (s.IsGuid())
{
if (WebUtil.GetFormValue("scEditorTabs").Contains("contenteditor:launchtab") && WebUtil.GetFormValue("scEditorTabs").Contains(s))
{
SheerResponse.Eval("scContent.onEditorTabClick(null, null, '" + s + "')");
}
else
{
UrlString urlString = new UrlString(Util.Constants.ContentEditorRawUrlAddress);
urlString.Add(Util.Constants.OpenItemEditorQueryStringKeyName, s);
TrackOpenTab(context);
context.Items[0].Uri.AddToUrlString(urlString);
UIUtil.AddContentDatabaseParameter(urlString);
urlString.Add(Util.Constants.ModeQueryStringKeyName, "preview");
urlString.Add("il", "0");
urlString.Add(Util.Constants.RibbonQueryStringKeyName, "{D3A2D76F-02E6-49DE-BE90-D23C9771DC8D}");
string str3 = context.Parameters["la"] ?? Context.Language.CultureInfo.TwoLetterISOLanguageName;
urlString.Add("la", str3);
AddLatestVersionToUrlString(urlString, s, str3);
SheerResponse.Eval(new ShowEditorTab { Command = "contenteditor:launchtab", Header = Translate.Text(Context.ContentDatabase.GetItem(s).Name), Icon = Images.GetThemedImageSource("Applications/16x16/text_view.png"), Url = urlString.ToString(), Id = s, Closeable = true, Activate = Util.Constants.SettingsItem[Util.Constants.OpenSearchResult] != "New Tab Not Selected" }.ToString());
}
}
}
}
示例12: RunEditForm
/// <summary>
/// This method runs the rotating image modal
/// </summary>
/// <param name="args"></param>
public void RunEditForm(ClientPipelineArgs args)
{
if (!args.IsPostBack)
{
//get url for field type selector modal
UrlString ustr = new UrlString(UIUtil.GetUri("control:FieldSuiteEditForm"));
ustr.Parameters.Add(args.Parameters);
//open field type selector
Sitecore.Context.ClientPage.ClientResponse.ShowModalDialog(ustr.ToString(), "712", "485", "", true);
//wait for response
args.WaitForPostBack();
}
else
{
string itemId = args.Parameters["id"];
if(!string.IsNullOrEmpty(itemId) && Sitecore.Context.ContentDatabase != null)
{
Item item = Sitecore.Context.ContentDatabase.GetItem(itemId);
if(item.IsNotNull())
{
UnlockItem(item);
//send command to update list update's field gutter
if (args.Parameters["fieldid"] != null && !string.IsNullOrEmpty(args.Parameters["fieldid"]))
{
string fieldGutterHtml = GetFieldGutterHtml(new FieldGutterArgs(item, args.Parameters["fieldid"]));
SheerResponse.Eval("FieldSuite.Fields.UpdateItemFieldGutter(\"" + args.Parameters["fieldid"] + "\",\"" + HttpUtility.HtmlEncode(fieldGutterHtml) + "\",\"" + item.ID + "\")");
}
}
}
}
}
示例13: Run
protected void Run(ClientPipelineArgs args)
{
Assert.ArgumentNotNull(args, "args");
string dbName = args.Parameters["databasename"];
string id = args.Parameters["id"];
string lang = args.Parameters["language"];
string ver = args.Parameters["version"];
Database database = Factory.GetDatabase(dbName);
Assert.IsNotNull(database, dbName);
Item obj = database.Items[id, Language.Parse(lang), Version.Parse(ver)];
if (obj == null)
{
SheerResponse.Alert("Item not found.");
}
else
{
if (!SheerResponse.CheckModified())
return;
if (args.IsPostBack)
{
return;
}
UrlString urlString = new UrlString(UIUtil.GetUri("control:SchedulePublish"));
urlString.Append("id", obj.ID.ToString());
urlString.Append("unpublish", args.Parameters["unpublish"]);
SheerResponse.ShowModalDialog(urlString.ToString(), "600", "600", string.Empty, true);
args.WaitForPostBack();
}
}
示例14: Run
public void Run(ClientPipelineArgs args)
{
Assert.ArgumentNotNull(args, "args");
string controlId = args.Parameters["controlid"];
if (args.IsPostBack)
{
if (!args.HasResult) return;
SheerResponse.SetAttribute("scHtmlValue", "value", YouTubeVideoField.FormatValueForPageEditorDisplay(args.Result));
SheerResponse.SetAttribute("scPlainValue", "value", args.Result);
SheerResponse.Eval("scSetHtmlValue('" + controlId + "', false, true)");
}
else
{
var urlString = new UrlString(UIUtil.GetUri(DialogUrl));
urlString["val"] = args.Parameters.Get("fieldValue");
Context.ClientPage.ClientResponse.ShowModalDialog(urlString.ToString(), "650px", "700px", string.Empty, true);
args.WaitForPostBack();
}
}
示例15: Execute
public override void Execute(CommandContext context)
{
string scriptId = context.Parameters["script"];
string scriptDb = context.Parameters["scriptDb"];
Item scriptItem = Factory.GetDatabase(scriptDb).GetItem(new ID(scriptId));
string showResults = scriptItem[ScriptItemFieldNames.ShowResults];
string itemId = string.Empty;
string itemDb = string.Empty;
if (context.Items.Length > 0)
{
itemId = context.Items[0].ID.ToString();
itemDb = context.Items[0].Database.Name;
}
var str = new UrlString(UIUtil.GetUri("control:PowerShellRunner"));
str.Append("id", itemId);
str.Append("db", itemDb);
str.Append("scriptId", scriptId);
str.Append("scriptDb", scriptDb);
str.Append("autoClose", showResults);
Context.ClientPage.ClientResponse.Broadcast(
SheerResponse.ShowModalDialog(str.ToString(), "400", "220", "PowerShell Script Results", false),
"Shell");
}