本文整理汇总了C#中System.UrlInfo类的典型用法代码示例。如果您正苦于以下问题:C# UrlInfo类的具体用法?C# UrlInfo怎么用?C# UrlInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
UrlInfo类属于System命名空间,在下文中一共展示了UrlInfo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetUp
public void SetUp()
{
Layout = null;
PropertyBag = new Hashtable(StringComparer.InvariantCultureIgnoreCase);
Helpers = new HelperDictionary();
var services = new StubMonoRailServices
{
UrlBuilder = new DefaultUrlBuilder(new StubServerUtility(), new StubRoutingEngine()),
UrlTokenizer = new DefaultUrlTokenizer()
};
var urlInfo = new UrlInfo(
"example.org", "test", "/TestBrail", "http", 80,
"http://test.example.org/test_area/test_controller/test_action.tdd",
Area, ControllerName, Action, "tdd", "no.idea");
StubEngineContext = new StubEngineContext(new StubRequest(), new StubResponse(), services,
urlInfo);
StubEngineContext.AddService<IUrlBuilder>(services.UrlBuilder);
StubEngineContext.AddService<IUrlTokenizer>(services.UrlTokenizer);
ViewComponentFactory = new DefaultViewComponentFactory();
ViewComponentFactory.Service(StubEngineContext);
ViewComponentFactory.Initialize();
StubEngineContext.AddService<IViewComponentFactory>(ViewComponentFactory);
ControllerContext = new ControllerContext
{
Helpers = Helpers,
PropertyBag = PropertyBag
};
StubEngineContext.CurrentControllerContext = ControllerContext;
Helpers["formhelper"] = Helpers["form"] = new FormHelper(StubEngineContext);
Helpers["urlhelper"] = Helpers["url"] = new UrlHelper(StubEngineContext);
Helpers["dicthelper"] = Helpers["dict"] = new DictHelper(StubEngineContext);
Helpers["DateFormatHelper"] = Helpers["DateFormat"] = new DateFormatHelper(StubEngineContext);
var viewPath = Path.Combine(viewSourcePath, "Views");
var loader = new FileAssemblyViewSourceLoader(viewPath);
loader.AddAssemblySource(
new AssemblySourceInfo(Assembly.GetExecutingAssembly().FullName,
"Castle.MonoRail.Views.Brail.Tests.ResourcedViews"));
BooViewEngine = new BooViewEngine
{
Options = new BooViewEngineOptions
{
SaveDirectory = Environment.CurrentDirectory,
SaveToDisk = false,
Debug = true,
BatchCompile = false
}
};
BooViewEngine.SetViewSourceLoader(loader);
BooViewEngine.Initialize();
BeforEachTest();
}
示例2: MockRailsEngineContext
/// <summary>
/// Initializes a new instance of the <see cref="MockRailsEngineContext"/> class.
/// </summary>
/// <param name="request">The request.</param>
/// <param name="response">The response.</param>
/// <param name="trace">The trace.</param>
/// <param name="urlInfo">The URL info.</param>
public MockRailsEngineContext(IRequest request, IResponse response, ITrace trace, UrlInfo urlInfo) : this()
{
this.request = request;
this.response = response;
this.trace = trace;
this.urlInfo = urlInfo;
}
示例3: OverridingArea
public void OverridingArea()
{
var url = new UrlInfo("", "controller", "action", "", ".castle");
Assert.AreEqual("/admin/cars/new.castle",
urlBuilder.BuildUrl(url, DictHelper.Create("area=admin", "controller=cars", "action=new")));
}
示例4: UsesMoreThanASingleLevelAppPath
public void UsesMoreThanASingleLevelAppPath()
{
var url = new UrlInfo("", "controller", "action", "/app/some", ".castle");
Assert.AreEqual("/app/some/controller/new.castle",
urlBuilder.BuildUrl(url, DictHelper.Create("action=new")));
}
示例5: SetUp
public void SetUp()
{
string siteRoot = GetSiteRoot();
string viewPath = Path.Combine(siteRoot, "RenderingTests\\Views");
Layout = null;
PropertyBag = new Hashtable(StringComparer.InvariantCultureIgnoreCase);
Helpers = new HelperDictionary();
StubMonoRailServices services = new StubMonoRailServices();
services.UrlBuilder = new DefaultUrlBuilder(new StubServerUtility(), new StubRoutingEngine());
services.UrlTokenizer = new DefaultUrlTokenizer();
UrlInfo urlInfo = new UrlInfo(
"example.org", "test", "/TestBrail", "http", 80,
"http://test.example.org/test_area/test_controller/test_action.tdd",
Area, ControllerName, Action, "tdd", "no.idea");
StubEngineContext = new StubEngineContext(new StubRequest(), new StubResponse(), services,
urlInfo);
StubEngineContext.AddService<IUrlBuilder>(services.UrlBuilder);
StubEngineContext.AddService<IUrlTokenizer>(services.UrlTokenizer);
StubEngineContext.AddService<IViewComponentFactory>(ViewComponentFactory);
StubEngineContext.AddService<ILoggerFactory>(new ConsoleFactory());
StubEngineContext.AddService<IViewSourceLoader>(new FileAssemblyViewSourceLoader(viewPath));
ViewComponentFactory = new DefaultViewComponentFactory();
ViewComponentFactory.Service(StubEngineContext);
ViewComponentFactory.Initialize();
ControllerContext = new ControllerContext();
ControllerContext.Helpers = Helpers;
ControllerContext.PropertyBag = PropertyBag;
StubEngineContext.CurrentControllerContext = ControllerContext;
Helpers["urlhelper"] = Helpers["url"] = new UrlHelper(StubEngineContext);
Helpers["htmlhelper"] = Helpers["html"] = new HtmlHelper(StubEngineContext);
Helpers["dicthelper"] = Helpers["dict"] = new DictHelper(StubEngineContext);
Helpers["DateFormatHelper"] = Helpers["DateFormat"] = new DateFormatHelper(StubEngineContext);
//FileAssemblyViewSourceLoader loader = new FileAssemblyViewSourceLoader(viewPath);
// loader.AddAssemblySource(
// new AssemblySourceInfo(Assembly.GetExecutingAssembly().FullName,
// "Castle.MonoRail.Views.Brail.Tests.ResourcedViews"));
viewEngine = new AspViewEngine();
viewEngine.Service(StubEngineContext);
AspViewEngineOptions options = new AspViewEngineOptions();
options.CompilerOptions.AutoRecompilation = true;
options.CompilerOptions.KeepTemporarySourceFiles = false;
ICompilationContext context =
new CompilationContext(
new DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory),
new DirectoryInfo(siteRoot),
new DirectoryInfo(Path.Combine(siteRoot, "RenderingTests\\Views")),
new DirectoryInfo(siteRoot));
List<ICompilationContext> compilationContexts = new List<ICompilationContext>();
compilationContexts.Add(context);
viewEngine.Initialize(compilationContexts, options);
}
示例6: InheritsControllerAndAreaWhenCreatingUrl
public void InheritsControllerAndAreaWhenCreatingUrl()
{
var url = new UrlInfo("", "controller", "action", "", ".castle");
Assert.AreEqual("/controller/new.castle",
urlBuilder.BuildUrl(url, DictHelper.Create("action=new")));
}
示例7: UsesAppPath
public void UsesAppPath()
{
UrlInfo url = new UrlInfo("", "controller", "action", "/app", ".castle");
Assert.AreEqual("/app/controller/new.castle",
urlBuilder.BuildUrl(url, DictHelper.Create("action=new")));
}
示例8: Setup
public virtual void Setup()
{
response = new StubResponse();
var url = new UrlInfo("eleutian.com", "www", virtualDirectory, "http", 80,
Path.Combine(Path.Combine("Area", "Controller"), "Action"), "Area", "Controller", "Action", "rails", "");
var stubEngineContext = new StubEngineContext(new StubRequest(), response, new StubMonoRailServices(), url)
{
Server = MockRepository.GenerateMock<IServerUtility>()
};
railsContext = stubEngineContext;
serverUtility = railsContext.Server;
argumentConversionService = MockRepository.GenerateMock<IArgumentConversionService>();
controller = new TestController();
controller.Contextualize(railsContext, MockRepository.GenerateStub<IControllerContext>());
parameters = new Hashtable();
services = MockRepository.GenerateMock<ICodeGeneratorServices>();
services.Expect(s => s.ArgumentConversionService).Return(argumentConversionService).Repeat.Any();
services.Expect(s => s.Controller).Return(controller).Repeat.Any();
services.Expect(s => s.RailsContext).Return(railsContext).Repeat.Any();
argumentConversionService.Expect(s => s.CreateParameters()).Return(parameters).Repeat.Any();
}
示例9: BaseResponse
/// <summary>
/// Initializes a new instance of the <see cref="BaseResponse"/> class.
/// </summary>
/// <param name="currentUrl">The current URL.</param>
/// <param name="urlBuilder">The URL builder.</param>
/// <param name="serverUtility">The server utility.</param>
/// <param name="routeMatch">The route match.</param>
/// <param name="referrer">The referrer.</param>
protected BaseResponse(UrlInfo currentUrl, IUrlBuilder urlBuilder, IServerUtility serverUtility, RouteMatch routeMatch, string referrer)
{
this.currentUrl = currentUrl;
this.urlBuilder = urlBuilder;
this.serverUtility = serverUtility;
this.routeMatch = routeMatch;
this.referrer = referrer;
}
示例10: AddDefaultRule
/// <summary>
/// Adds the default rule mapping.
/// </summary>
/// <remarks>
/// A defautl rule can associate something like a 'default.castle'
/// to a controller/action like 'Home/index.castle'
/// </remarks>
/// <param name="url">The URL.</param>
/// <param name="area">The area.</param>
/// <param name="controller">The controller.</param>
/// <param name="action">The action.</param>
public void AddDefaultRule(string url, string area, string controller, string action)
{
if (area == null)
{
area = string.Empty;
}
defaultUrl2CustomUrlInfo[url] = new UrlInfo(area, controller, action);
}
示例11: GetDate
public static UrlSharer.UrlInfo GetDate()
{
UrlInfo uInfo = new UrlInfo();
uInfo.Description = "test";
uInfo.Title = "test";
uInfo.Images = new List<string>();
uInfo.Images.Add("http://google.com");
return uInfo;
}
示例12: StubEngineContext
/// <summary>
/// Initializes a new instance of the <see cref="StubEngineContext"/> class.
/// </summary>
/// <param name="request">The request.</param>
/// <param name="response">The response.</param>
/// <param name="services">The services.</param>
/// <param name="urlInfo">The URL info.</param>
public StubEngineContext(IMockRequest request, IMockResponse response, IMonoRailServices services, UrlInfo urlInfo)
{
this.request = request;
this.response = response;
this.services = services;
this.urlInfo = urlInfo;
if (response != null)
{
response.UrlInfo = urlInfo;
response.UrlBuilder = services.UrlBuilder;
}
}
示例13: bindShow
private void bindShow( ContentPost post ) {
ctx.SetItem( "ContentPost", post );
set( "post.Title", post.Title );
set( "post.CreateTime", post.Created );
set( "post.ReplyCount", post.Replies );
set( "post.Source", post.SourceLink );
set( "post.Hits", post.Hits );
String siteUrl = new UrlInfo( post.SourceLink ).SiteUrl;
set( "post.Source", siteUrl );
String val = WebHelper.GetFlash( post.SourceLink, 500, 400 );
set( "post.Content", val );
}
示例14: MunzeeDfxAtForm
public MunzeeDfxAtForm(Framework.Interfaces.ICore core): this()
{
_core = core;
this.Text = Utils.LanguageSupport.Instance.GetTranslation(STR_TITLE);
this.groupBox3.Text = Utils.LanguageSupport.Instance.GetTranslation(STR_MUNZEECOMACCOUNT);
this.groupBox2.Text = Utils.LanguageSupport.Instance.GetTranslation(STR_SELECTURL);
this.groupBox1.Text = Utils.LanguageSupport.Instance.GetTranslation(STR_ADD);
this.label7.Text = Utils.LanguageSupport.Instance.GetTranslation(STR_NAME);
this.label1.Text = Utils.LanguageSupport.Instance.GetTranslation(STR_URLS);
this.button2.Text = Utils.LanguageSupport.Instance.GetTranslation(STR_ADD);
this.button3.Text = Utils.LanguageSupport.Instance.GetTranslation(STR_REMOVE);
this.button4.Text = Utils.LanguageSupport.Instance.GetTranslation(STR_OK);
this.label2.Text = Utils.LanguageSupport.Instance.GetTranslation(STR_URL);
this.label5.Text = Utils.LanguageSupport.Instance.GetTranslation(STR_COMMENT);
this.label6.Text = Utils.LanguageSupport.Instance.GetTranslation(STR_INFO);
textBox3.Text = Properties.Settings.Default.AccountName;
try
{
_urlsFile = System.IO.Path.Combine( _core.PluginDataPath, "MunzeeDfxAt.xml" );
if (System.IO.File.Exists(_urlsFile))
{
XmlDocument doc = new XmlDocument();
doc.Load(_urlsFile);
XmlElement root = doc.DocumentElement;
XmlNodeList bmNodes = root.SelectNodes("url");
if (bmNodes != null)
{
foreach (XmlNode n in bmNodes)
{
UrlInfo bm = new UrlInfo();
bm.Url = n.SelectSingleNode("Url").InnerText;
bm.Comment = n.SelectSingleNode("Comment").InnerText;
_urlInfos.Add(bm);
}
}
listBox1.Items.AddRange(_urlInfos.ToArray());
}
}
catch
{
}
}
示例15: test
public void test()
{
Uri uri = new Uri( "http://zhangsan:[email protected]/myapp/Photo/1984?title=eee#top" );
UrlInfo u = new UrlInfo( uri, "/myapp/", "myPathInfo" );
Console.WriteLine( "Scheme=>" + u.Scheme );
Console.WriteLine( "UserName=>" + u.UserName );
Console.WriteLine( "Password=>" + u.Password );
Console.WriteLine( "Host=>" + u.Host );
Console.WriteLine( "Port=>" + u.Port );
Console.WriteLine( "Path=>" + u.Path );
Console.WriteLine( "PathAndQuery=>" + u.PathAndQuery );
Console.WriteLine( "PathInfo=>" + u.PathInfo );
Console.WriteLine( "AppPath=>" + u.AppPath );
Console.WriteLine( "PathAndQueryWithouApp=>" + u.PathAndQueryWithouApp );
Console.WriteLine( "Query=>" + u.Query );
Console.WriteLine( "Fragment=>" + u.Fragment );
Console.WriteLine( "SiteUrl=>" + u.SiteUrl );
Console.WriteLine( "SiteAndAppPath=>" + u.SiteAndAppPath );
Console.WriteLine( "ToString=>" + u.ToString() );
/*
Scheme=>http
UserName=>zhangsan
Password=>123
Host=>www.wojilu.net
Port=>80
Path=>/myapp/Photo/1984
PathAndQuery=>/myapp/Photo/1984?title=eee
PathInfo=>myPathInfo
AppPath=>/myapp/
PathAndQueryWithouApp=>/Photo/1984?title=eee
Query=>?title=eee
Fragment=>#top
SiteUrl=>http://zhangsan:[email protected]
SiteAndAppPath=>http://zhangsan:[email protected]/myapp/
ToString=>http://zhangsan:[email protected]/myapp/Photo/1984?title=eee#top
*/
}