本文整理汇总了C#中UrlString类的典型用法代码示例。如果您正苦于以下问题:C# UrlString类的具体用法?C# UrlString怎么用?C# UrlString使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
UrlString类属于命名空间,在下文中一共展示了UrlString类的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: Edit
public void Edit(ClientPipelineArgs args)
{
if (args.IsPostBack)
{
if (!args.HasResult)
return;
Value = args.Result;
SetModified();
SheerResponse.Refresh(this);
}
else
{
Assert.IsNotNull(DialogUrl, "Dialog URL");
var urlString = new UrlString(UIUtil.GetUri(DialogUrl));
var itemUri = new ItemUri(ItemId, Sitecore.Configuration.Factory.GetDatabase("master"));
var fieldItem = Sitecore.Context.ContentDatabase.GetItem(FieldId);
urlString["itemUri"] = itemUri.ToString();
urlString["fieldName"] = fieldItem.Name;
Sitecore.Context.ClientPage.ClientResponse.ShowModalDialog(urlString.ToString(), "650px", "700px", string.Empty, true);
args.WaitForPostBack();
}
}
示例3: 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());
}
}
}
}
示例4: 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);
});
}
示例5: Execute
public override void Execute(CommandContext context)
{
SheerResponse.DisableOutput();
var subMenu = new ContextMenu();
var menuItems = new List<Control>();
var menuItemId = "iseSettingsDropdown"; //context.Parameters["Id"];
if (string.IsNullOrEmpty(menuItemId))
{
// a bit of a hacky way to determine the caller so we can display the menu
// in proximity to the triggering control
var parameters = new UrlString("?" + Context.Items["SC_FORM"]);
menuItemId = parameters.Parameters["__EVENTTARGET"];
}
var menuRootItem =
Factory.GetDatabase("core")
.GetItem("/sitecore/content/Applications/PowerShell/PowerShellIse/Menus/Settings");
GetMenuItems(menuItems, menuRootItem);
foreach (var item in menuItems)
{
var menuItem = item as MenuItem;
if (menuItem != null)
{
var subItem = subMenu.Add(menuItem.ID, menuItem.Header, menuItem.Icon, menuItem.Hotkey,
menuItem.Click,
menuItem.Checked, menuItem.Radiogroup, menuItem.Type);
subItem.Disabled = menuItem.Disabled;
}
}
SheerResponse.EnableOutput();
subMenu.Visible = true;
SheerResponse.ShowContextMenu(menuItemId, "down", subMenu);
}
示例6: 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();
}
}
示例7: GetDialogUrl
protected virtual UrlString GetDialogUrl(string value)
{
var uri = UIUtil.GetUri("control:Sitecore.Shell.Applications.Dialogs.DateTimeSelectors.DateTimeSelectorEx");
var url = new UrlString(uri);
url["value"] = value;
return url;
}
示例8: Process
/// <summary>
/// rewrite CDN urls from /path/to/file!cf!a=1!b=2.ext to original form /path/to/file.ext?a=1&b=2
/// </summary>
/// <param name="args"></param>
public override void Process(PreprocessRequestArgs args)
{
Assert.ArgumentNotNull(args, "args");
// rehydrate original url
string fullPath = Sitecore.Context.RawUrl;
var url = new UrlString(fullPath);
// if this item is a minifiable css or js
// rewrite for ~/minify handler
if (CDNSettings.Enabled &&
CDNSettings.MinifyEnabled &&
url["min"] == "1" &&
!url.Path.StartsWith(Settings.Media.DefaultMediaPrefix) &&
(url.Path.EndsWith(".css") || url.Path.EndsWith(".js")))
{
args.Context.Items["MinifyPath"] = fullPath; // set this for the Minifier handler
args.Context.RewritePath("/~/minify" + url.Path, string.Empty, url.Query); // rewrite with ~/minify to trigger custom handler
}
// NOTE: DOREL CHANGE: Commented to make WCF services (*.svc) workable
// else
// {
// args.Context.RewritePath(url.Path, string.Empty, url.Query); // rewrite proper url
// }
}
示例9: 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");
}
}
示例10: 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;
}
}
示例11: Run
protected virtual void Run(ClientPipelineArgs args)
{
string databaseName = args.Parameters["databasename"];
string id = args.Parameters["id"];
Database database = Factory.GetDatabase(databaseName);
Assert.IsNotNull(database, typeof (Database), "Database \"" + database + "\" not found.", new object[0]);
Item item = database.Items[id];
if (item != null)
{
if (item.Fields[FieldIDs.LayoutField] != null && item.Fields[FieldIDs.LayoutField].Value != string.Empty)
{
if (!args.IsPostBack)
{
UrlString url = new UrlString(UIUtil.GetUri("control:Calendar.ConfigureControls"));
url.Append("id", item.ID.ToString());
url.Append("db", item.Database.Name);
Windows.RunApplication("Calendar ConfigureControls", url.GetUrl());
}
}
else
{
Context.ClientPage.ClientResponse.Alert(ResourceManager.Localize("ITEM_HAS_NO_LAYOUT"));
}
}
else
{
SheerResponse.Alert("Item not found.", new string[0]);
}
}
示例12: Execute
/// <summary>
/// Macro main entry method
/// </summary>
/// <param name="element">
/// The element.
/// </param>
/// <param name="name">
/// The name.
/// </param>
/// <param name="parameters">
/// The parameters.
/// </param>
/// <param name="value">
/// The value.
/// </param>
public void Execute(XElement element, string name, UrlString parameters, string value)
{
Assert.ArgumentNotNull(element, "element");
Assert.ArgumentNotNull(name, "name");
Assert.ArgumentNotNull(parameters, "parameters");
Assert.ArgumentNotNull(value, "value");
SelectAccountOptions options = SelectAccountOptions.Parse();
string securityType = parameters["type"];
if (!string.IsNullOrEmpty(securityType))
{
if (securityType.Equals("role", StringComparison.InvariantCultureIgnoreCase))
{
options.ExcludeUsers = true;
}
else if (securityType.Equals("user", StringComparison.InvariantCultureIgnoreCase))
{
options.ExcludeRoles = true;
}
}
string multipleSelection = parameters["multiselect"];
if (!string.IsNullOrEmpty(multipleSelection))
{
options.Multiple = multipleSelection.Equals("true", StringComparison.InvariantCultureIgnoreCase);
}
SheerResponse.ShowModalDialog(options.ToUrlString().ToString(), true);
}
示例13: 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");
}
示例14: 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);
}
}
示例15: 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());
// }
}
}