本文整理汇总了C#中MindTouch.Dream.XUri类的典型用法代码示例。如果您正苦于以下问题:C# XUri类的具体用法?C# XUri怎么用?C# XUri使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
XUri类属于MindTouch.Dream命名空间,在下文中一共展示了XUri类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: CouchBase
protected CouchBase(XUri aBaseUri, string aUserName = null, string aPassword = null)
{
if (aBaseUri == null)
throw new ArgumentNullException("aBaseUri");
BasePlug = Plug.New(aBaseUri).WithCredentials(aUserName, aPassword);
}
开发者ID:willemda,项目名称:DreamSeat,代码行数:7,代码来源:CouchBase.cs
示例2: CallbackHandler
//--- Methods ---
private void CallbackHandler(Plug plug, string verb, XUri uri, DreamMessage request, Result<DreamMessage> response) {
if(uri.Segments.Length == 0) {
response.Return(DreamMessage.Ok());
return;
}
var segments = uri.Segments;
var wikiId = segments[0];
if(wikiId.StartsWith("=")) {
var id = (HostLookupOverride == null) ? DefaultWikiId : HostLookupOverride(wikiId.Substring(1));
response.Return(DreamMessage.Ok(new XDoc("wiki").Attr("id", id)));
return;
}
if(segments.Length == 2 && segments[1] == "license") {
XDoc license;
if(LicenseOverride == null) {
_log.Debug("returning license from disk");
license = XDocFactory.LoadFrom(Utils.Settings.LicensePath, MimeType.TEXT_XML);
} else {
_log.Debug("returning license from override callback");
license = LicenseOverride(wikiId);
}
response.Return(DreamMessage.Ok(license));
return;
}
var config = (ConfigOverride == null) ? DefaultConfig : ConfigOverride(wikiId);
response.Return(DreamMessage.Ok(config));
}
开发者ID:heran,项目名称:DekiWiki,代码行数:28,代码来源:RemoteInstanceService.cs
示例3: Invoke
public Yield Invoke(Plug plug, string verb, XUri uri, DreamMessage request, Result<DreamMessage> response)
{
// NOTE (steveb): we convert 'xri://@name/path?params' into 'http://xri.net/@name/path?params'
// prepend segments with authority
List<string> segments = new List<string>();
segments.Add(uri.Authority);
if(uri.Segments != null) {
segments.AddRange(uri.Segments);
}
// build new plug
List<PlugHandler> preHandlers = (plug.PreHandlers != null) ? new List<PlugHandler>(plug.PreHandlers) : null;
List<PlugHandler> postHandlers = (plug.PostHandlers != null) ? new List<PlugHandler>(plug.PostHandlers) : null;
Plug xri = new Plug(new XUri("http", null, null, "xri.net", 80, segments.ToArray(), uri.TrailingSlash, uri.Params, uri.Fragment), plug.Timeout, request.Headers, preHandlers, postHandlers, plug.Credentials, plug.CookieJar, plug.MaxAutoRedirects);
// add 'Accept' header for 'application/xrds+xml' mime-type
if((xri.Headers == null) || (xri.Headers.Accept == null)) {
xri = xri.WithHeader(DreamHeaders.ACCEPT, MimeType.RenderAcceptHeader(MimeType.XRDS));
}
// BUGBUGBUG (steveb): this will probably fail in some cases since we may exit this coroutine before the call has completed!
xri.InvokeEx(verb, request, response);
yield break;
}
开发者ID:maximmass,项目名称:DReAM,代码行数:26,代码来源:XriPlugEndpoint.cs
示例4: Exporter_hits_export_feature_on_creation_using_reltopath
public void Exporter_hits_export_feature_on_creation_using_reltopath() {
// Arrange
XUri dekiApiUri = new XUri("http://mock/@api/deki");
XDoc exportDocument = new XDoc("export")
.Start("page")
.Attr("path", "/")
.Attr("recursive", "true")
.Attr("exclude", "all")
.End();
XDoc exportResponse = new XDoc("export")
.Start("requests")
.End()
.Start("manifest")
.Elem("justanode")
.End();
AutoMockPlug mock = MockPlug.Register(dekiApiUri);
mock.Expect("POST", dekiApiUri.At("site", "export").With("reltopath", "/foo/bar"), exportDocument, DreamMessage.Ok(exportResponse));
// Act
Exporter exporter = Exporter.CreateAsync(Plug.New(dekiApiUri), exportDocument, "/foo/bar", new Result<Exporter>()).Wait();
//Assert
Assert.IsTrue(mock.WaitAndVerify(TimeSpan.FromSeconds(1)));
Assert.AreEqual(exportResponse["manifest"], exporter.Manifest);
}
开发者ID:heran,项目名称:DekiWiki,代码行数:26,代码来源:ExportTests.cs
示例5: GetUrlLocalUri
public static string GetUrlLocalUri(XUri confBaseUri, string url, bool includeQuery, bool decode) {
if(string.IsNullOrEmpty(url)) {
return null;
}
if(url.StartsWithInvariantIgnoreCase(confBaseUri.ToString())) {
//Remove the wiki path prefix (everything before display generally)
url = confBaseUri.SchemeHostPort + url.Substring(confBaseUri.ToString().Length);
}
XUri uri = XUri.TryParse(url);
if(uri == null) {
return null;
}
string ret = uri.Path;
if(decode) {
ret = XUri.Decode(ret);
}
if(includeQuery && !string.IsNullOrEmpty(uri.QueryFragment)) {
ret += uri.QueryFragment;
}
return ret;
}
开发者ID:heran,项目名称:DekiWiki,代码行数:26,代码来源:Utils.cs
示例6: AwsEndpoint
public AwsEndpoint(string locationConstraint, string s3Uri, string sqsUri, string name)
{
S3Uri = new XUri(s3Uri);
SqsUri = new XUri(sqsUri);
LocationConstraint = locationConstraint;
Name = name;
}
开发者ID:danice,项目名称:DReAM,代码行数:7,代码来源:AwsEndpoint.cs
示例7: RemoteInstanceManager
// --- Constructors ---
public RemoteInstanceManager(DekiWikiService dekiService, XUri directoryUri) : base(dekiService) {
_directory = Plug.New(directoryUri);
DreamMessage testMsg = _directory.GetAsync().Wait();
if (!testMsg.IsSuccessful)
throw new DreamInternalErrorException(string.Format("Error validating remote deki portal service at '{0}'", directoryUri.ToString()));
}
开发者ID:StackableRegiments,项目名称:metl2011,代码行数:8,代码来源:RemoteInstanceManager.cs
示例8: RequestLog_Insert
//--- Class Methods ---
public void RequestLog_Insert(XUri requestUri, string requestVerb, string requestHostHeader, string origin, string serviceHost, string serviceFeature, DreamStatus responseStatus, string username, uint executionTime, string response) {
string host = requestUri.HostPort;
if( !host.Contains(":"))
host = host + ":80";
//Schema for request log in "trunk/product/deki/web/maintenance/apirequestlog.sql"
Catalog.NewQuery(@" /* RequestLog_Insert */
insert delayed into requestlog (
`rl_requesthost`, `rl_requesthostheader`, `rl_requestpath`, `rl_requestparams`, `rl_requestverb`,
`rl_dekiuser`, `rl_origin`, `rl_servicehost`, `rl_servicefeature`, `rl_responsestatus`, `rl_executiontime`,
`rl_response`
) values (
?REQUESTHOST, ?REQUESTHOSTHEADER, ?REQUESTPATH, ?REQUESTPARAMS, ?REQUESTVERB,
?DEKIUSER, ?ORIGIN, ?SERVICEHOST, ?SERVICEFEATURE, ?RESPONSESTATUS, ?EXECUTIONTIME,
?RESPONSE
);")
.With("REQUESTHOST", host)
.With("REQUESTHOSTHEADER", requestHostHeader)
.With("REQUESTPATH", requestUri.Path)
.With("REQUESTPARAMS", requestUri.Query)
.With("REQUESTVERB", requestVerb)
.With("DEKIUSER", username)
.With("ORIGIN", origin == null ? String.Empty : origin.ToLowerInvariant())
.With("SERVICEHOST", serviceHost)
.With("SERVICEFEATURE", serviceFeature)
.With("RESPONSESTATUS", (int)responseStatus)
.With("EXECUTIONTIME", executionTime)
.With("RESPONSE", response)
.Execute();
}
开发者ID:StackableRegiments,项目名称:metl2011,代码行数:31,代码来源:RequestLogDA.cs
示例9: RegisterFunction
public void RegisterFunction(string functionName, MethodInfo method, DekiScriptNativeInvocationTarget.Parameter[] parameters) {
var target = new DekiScriptNativeInvocationTarget(null, method, parameters.ToArray());
var function = new DekiScriptInvocationTargetDescriptor(target.Access, false, false, functionName, target.Parameters, target.ReturnType, "", "", target);
var functionPointer = new XUri("native:///").At(function.SystemName);
Functions[functionPointer] = function;
_funcMap[functionName] = functionPointer;
}
开发者ID:heran,项目名称:DekiWiki,代码行数:7,代码来源:DekiScriptTestRuntime.cs
示例10: CouchBase
protected CouchBase(XUri baseUri, string username = null,
string password = null)
{
if (baseUri == null)
throw new ArgumentNullException("baseUri");
BasePlug = Plug.New(baseUri).WithCredentials(username, password);
}
开发者ID:jvdgeest,项目名称:chesterfield,代码行数:8,代码来源:CouchBase.cs
示例11: ExportManager_chains_exporter_to_packager
public void ExportManager_chains_exporter_to_packager() {
// Arrange
XUri dekiApiUri = new XUri("http://mock/@api/deki");
XDoc exportDocument = new XDoc("export");
XUri item1Uri = dekiApiUri.At("foo", "bar", "abc");
XDoc item1Doc = new XDoc("item1");
XUri item2Uri = dekiApiUri.At("foo", "bar", "def");
XDoc item2Doc = new XDoc("item2");
XDoc exportResponse = new XDoc("export")
.Start("requests")
.Start("request")
.Attr("method", "GET")
.Attr("dataid", "abc")
.Attr("href", item1Uri)
.Start("header").Attr("name", "h_1").Attr("value", "v_1").End()
.Start("header").Attr("name", "h_2").Attr("value", "v_2").End()
.End()
.Start("request")
.Attr("method", "GET")
.Attr("dataid", "def")
.Attr("href", item2Uri)
.End()
.End()
.Start("manifest")
.Start("foo").Attr("dataid", "abc").End()
.Start("bar").Attr("dataid", "def").End()
.End();
AutoMockPlug mock = MockPlug.Register(dekiApiUri);
mock.Expect().Verb("POST").Uri(dekiApiUri.At("site", "export").With("relto", "0")).RequestDocument(exportDocument).Response(DreamMessage.Ok(exportResponse));
mock.Expect().Verb("GET").Uri(item1Uri).RequestHeader("h_1", "v_1").RequestHeader("h_2", "v_2").Response(DreamMessage.Ok(item1Doc));
mock.Expect().Verb("GET").Uri(item2Uri).Response(DreamMessage.Ok(item2Doc));
var writes = new List<string>();
var mockPackageWriter = new Mock<IPackageWriter>();
mockPackageWriter.Setup(x => x.WriteDataAsync(It.IsAny<ExportItem>(), It.IsAny<Result>()))
.Returns(() => new Result().WithReturn())
.Callback((ExportItem item, Result result) => writes.Add(item.DataId))
.AtMost(2)
.Verifiable();
mockPackageWriter.Setup(x => x.WriteManifest(It.IsAny<XDoc>(), It.IsAny<Result>()))
.Returns(() => new Result().WithReturn())
.AtMostOnce()
.Verifiable();
// Act
ExportManager manager = ExportManager.CreateAsync(Plug.New(dekiApiUri), exportDocument, 0, mockPackageWriter.Object, new Result<ExportManager>()).Wait();
manager.ExportAsync(new Result()).Wait();
// Assert
Assert.IsTrue(mock.WaitAndVerify(TimeSpan.FromSeconds(1)), mock.VerificationFailure);
Assert.AreEqual(2, manager.TotalItems);
Assert.AreEqual(2, manager.CompletedItems);
Assert.AreEqual(new[] { "abc", "def" }, writes.ToArray());
mockPackageWriter.Verify(x => x.Dispose(), Times.Once());
mockPackageWriter.VerifyAll();
}
开发者ID:heran,项目名称:DekiWiki,代码行数:56,代码来源:ExportManagerTests.cs
示例12: GetScoreWithNormalizedUri
//--- Methods ---
public int GetScoreWithNormalizedUri(XUri uri, out XUri normalized)
{
normalized = uri;
switch(uri.Scheme) {
case "resource":
return Plug.BASE_ENDPOINT_SCORE;
default:
return 0;
}
}
开发者ID:nataren,项目名称:DReAM,代码行数:11,代码来源:ResourcePlugEndpoint.cs
示例13: GetScoreWithNormalizedUri
//--- Methods ---
public int GetScoreWithNormalizedUri(XUri uri, out XUri normalized)
{
normalized = uri;
switch(uri.Scheme) {
case "xri":
return 1;
default:
return 0;
}
}
开发者ID:maximmass,项目名称:DReAM,代码行数:11,代码来源:XriPlugEndpoint.cs
示例14: lock
//--- Interface Methods ---
int IPlugEndpoint.GetScoreWithNormalizedUri(XUri uri, out XUri normalized)
{
XDoc doc;
normalized = uri;
lock(_map) {
if(!_map.TryGetValue(uri, out doc)) {
return 0;
}
}
return uri.MaxSimilarity;
}
开发者ID:maximmass,项目名称:DReAM,代码行数:12,代码来源:ProxyPlugEndpoint.cs
示例15: Add
//--- Class Methods ---
/// <summary>
/// Add a document for a uri.
/// </summary>
/// <param name="uri">Uri to intercept.</param>
/// <param name="doc">Document to return for interception.</param>
public static void Add(XUri uri, XDoc doc)
{
if(uri == null) {
throw new ArgumentException("uri");
}
if(doc == null) {
throw new ArgumentException("doc");
}
lock(_map) {
_map[uri] = doc;
}
}
开发者ID:maximmass,项目名称:DReAM,代码行数:18,代码来源:ProxyPlugEndpoint.cs
示例16: ParserResult
//--- Constructors ---
public ParserResult(XDoc content, string contentType, Title redirectsTo, XUri redirectToUri, bool hasScriptContent, List<Title> links, List<Title> templates, List<string> tags) {
this.Content = content;
this.ContentType = contentType;
this.RedirectsToTitle = redirectsTo;
this.RedirectsToUri = redirectToUri;
this.HasScriptContent = hasScriptContent;
this.Links = links;
this.Templates = templates;
this.Tags = tags;
_bodyText = null;
_summary = null;
}
开发者ID:StackableRegiments,项目名称:metl2011,代码行数:13,代码来源:DekiXmlParser.cs
示例17: RemoteInstanceManager
//--- Constructors ---
public RemoteInstanceManager(DekiWikiService dekiService, TaskTimerFactory timerFactory, XUri directoryUri, string tempPath) : base(dekiService, timerFactory) {
// validate temp folder
_tempPath = tempPath;
if(!Directory.Exists(_tempPath)) {
throw new ArgumentException("temp folder does not exist", "tempPath");
}
// check remote directory
_directory = Plug.New(directoryUri);
var testMsg = _directory.GetAsync().Wait();
if(!testMsg.IsSuccessful) {
_log.WarnFormat("Error validating remote deki portal service at '{0}'", directoryUri);
}
}
开发者ID:heran,项目名称:DekiWiki,代码行数:16,代码来源:RemoteInstanceManager.cs
示例18: ResolveRegisteredFunctionUri
public override DekiScriptInvocationTargetDescriptor ResolveRegisteredFunctionUri(XUri uri) {
var result = base.ResolveRegisteredFunctionUri(uri);
if(result != null) {
return result;
}
var deki = DekiContext.Current.Instance;
var found = (from extension in deki.RunningServices.ExtensionServices
from function in extension.Extension.Functions where function.Uri == uri
select function).FirstOrDefault();
if(found != null) {
// TODO (steveb): we shouldn't have to create a descriptor on the fly
return new DekiScriptInvocationTargetDescriptor(DreamAccess.Public, false, false, found.Name, new DekiScriptParameter[0], DekiScriptType.ANY, null, null, null);
}
return null;
}
开发者ID:StackableRegiments,项目名称:metl2011,代码行数:16,代码来源:ExtensionRuntime.cs
示例19: ImportManager_chains_reader_to_importer
public void ImportManager_chains_reader_to_importer() {
// Arrange
var dekiApiUri = new XUri("http://mock/@api/deki");
var importManifest = new XDoc("manifest");
var item1Uri = dekiApiUri.At("foo", "bar", "abc");
var item1Doc = new XDoc("item1");
var item2Uri = dekiApiUri.At("foo", "bar", "def");
var item2Doc = new XDoc("item2");
var importResponse = new XDoc("requests")
.Start("request")
.Attr("method", "POST")
.Attr("dataid", "abc")
.Attr("href", item1Uri)
.Start("header").Attr("name", "h_1").Attr("value", "v_1").End()
.Start("header").Attr("name", "h_2").Attr("value", "v_2").End()
.End()
.Start("request")
.Attr("method", "PUT")
.Attr("dataid", "def")
.Attr("href", item2Uri)
.End();
var mock = MockPlug.Register(dekiApiUri);
mock.Expect().Verb("POST").Uri(dekiApiUri.At("site", "import").With("relto", "0")).RequestDocument(importManifest).Response(DreamMessage.Ok(importResponse));
mock.Expect().Verb("POST").Uri(item1Uri).RequestHeader("h_1", "v_1").RequestHeader("h_2", "v_2").RequestDocument(item1Doc);
mock.Expect().Verb("PUT").Uri(item2Uri).RequestDocument(item2Doc);
var mockPackageReader = new Mock<IPackageReader>();
mockPackageReader.Setup(x => x.ReadManifest(It.IsAny<Result<XDoc>>())).Returns(importManifest.AsResult()).Verifiable("didn't get manifest");
var item1stream = new MemoryStream(item1Doc.ToBytes());
mockPackageReader.Setup(x => x.ReadData(It.Is<ImportItem>(y => y.DataId == "abc"), It.IsAny<Result<ImportItem>>()))
.Returns(() => new ImportItem("abc", importResponse["request[@dataid='abc']"], null, item1stream, item1stream.Length).AsResult())
.Verifiable();
var item2stream = new MemoryStream(item2Doc.ToBytes());
mockPackageReader.Setup(x => x.ReadData(It.Is<ImportItem>(y => y.DataId == "def"), It.IsAny<Result<ImportItem>>()))
.Returns(() => new ImportItem("def", importResponse["request[@dataid='def']"], null, item2stream, item2stream.Length).AsResult())
.Verifiable();
mockPackageReader.Setup(x => x.Dispose()).Verifiable();
// Act
var manager = ImportManager.CreateAsync(Plug.New(dekiApiUri), 0, mockPackageReader.Object, new Result<ImportManager>()).Wait();
manager.ImportAsync(new Result()).Wait();
//Assert
Assert.IsTrue(mock.WaitAndVerify(TimeSpan.FromSeconds(1)), mock.VerificationFailure);
mockPackageReader.VerifyAll();
}
开发者ID:StackableRegiments,项目名称:metl2011,代码行数:47,代码来源:ImportManagerTests.cs
示例20: ToXml
//--- Methods ---
public XDoc ToXml(XUri uri) {
XDoc result = new XDoc("function");
result.Attr("transform", Transform);
if(IsProperty) {
result.Attr("usage", "property");
}
result.Elem("name", Name);
result.Elem("uri", uri);
result.Elem("description", Description);
if(Access != DreamAccess.Public) {
result.Elem("access", Access.ToString().ToLowerInvariant());
}
foreach(DekiScriptParameter param in Parameters) {
param.AppendXml(result);
}
result.Start("return").Attr("type", DekiScriptLiteral.AsScriptTypeName(ReturnType)).End();
return result;
}
开发者ID:StackableRegiments,项目名称:metl2011,代码行数:19,代码来源:DekiScriptInvocationTargetDescriptor.cs
注:本文中的MindTouch.Dream.XUri类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论