mirror of
https://github.com/BepInEx/mono.git
synced 2026-11-19 01:31:17 -10:00
Adding reference source for System.Data System.Data.DataSetExtensions System.Data.Entity System.Data.Entity.Design System.Data.Linq System.Data.SqlXml System.ServiceModel System.ServiceModel.Activation System.ServiceModel.Activities System.ServiceModel.Channels System.ServiceModel.Discovery System.ServiceModel.Internals System.ServiceModel.Routing System.ServiceModel.WasHosting System.ServiceModel.Web System.Web System.Web.ApplicationServices System.Web.DynamicData System.Web.Entity System.Web.Entity.Design System.Web.Extensions System.Web.Mobile System.Web.Routing System.Web.Services System.Xml System.Xml.Linq
70 lines
2.3 KiB
C#
70 lines
2.3 KiB
C#
//----------------------------------------------------------------
|
|
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
//----------------------------------------------------------------
|
|
|
|
namespace System
|
|
{
|
|
using System.Collections.Specialized;
|
|
using System.Runtime;
|
|
using System.Text;
|
|
|
|
class UriTemplateVariablePathSegment : UriTemplatePathSegment
|
|
{
|
|
readonly string varName;
|
|
|
|
public UriTemplateVariablePathSegment(string originalSegment, bool endsWithSlash, string varName)
|
|
: base(originalSegment, UriTemplatePartType.Variable, endsWithSlash)
|
|
{
|
|
Fx.Assert(!string.IsNullOrEmpty(varName), "bad variable segment");
|
|
this.varName = varName;
|
|
}
|
|
|
|
public string VarName
|
|
{
|
|
get
|
|
{
|
|
return this.varName;
|
|
}
|
|
}
|
|
public override void Bind(string[] values, ref int valueIndex, StringBuilder path)
|
|
{
|
|
Fx.Assert(valueIndex < values.Length, "Not enough values to bind");
|
|
if (this.EndsWithSlash)
|
|
{
|
|
path.AppendFormat("{0}/", values[valueIndex++]);
|
|
}
|
|
else
|
|
{
|
|
path.Append(values[valueIndex++]);
|
|
}
|
|
}
|
|
|
|
public override bool IsEquivalentTo(UriTemplatePathSegment other, bool ignoreTrailingSlash)
|
|
{
|
|
if (other == null)
|
|
{
|
|
Fx.Assert("why would we ever call this?");
|
|
return false;
|
|
}
|
|
if (!ignoreTrailingSlash && (this.EndsWithSlash != other.EndsWithSlash))
|
|
{
|
|
return false;
|
|
}
|
|
return (other.Nature == UriTemplatePartType.Variable);
|
|
}
|
|
public override bool IsMatch(UriTemplateLiteralPathSegment segment, bool ignoreTrailingSlash)
|
|
{
|
|
if (!ignoreTrailingSlash && (this.EndsWithSlash != segment.EndsWithSlash))
|
|
{
|
|
return false;
|
|
}
|
|
return (!segment.IsNullOrEmpty());
|
|
}
|
|
public override void Lookup(string segment, NameValueCollection boundParameters)
|
|
{
|
|
Fx.Assert(!string.IsNullOrEmpty(segment), "How can that be? Lookup is expected to be called after IsMatch");
|
|
boundParameters.Add(this.varName, segment);
|
|
}
|
|
}
|
|
}
|