本文整理汇总了C#中System.Uri.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# Uri.GetType方法的具体用法?C# Uri.GetType怎么用?C# Uri.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Uri
的用法示例。
在下文中一共展示了Uri.GetType方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LeaveDotsAndSlashesEscaped
public static void LeaveDotsAndSlashesEscaped(Uri uri)
{
if (uri == null)
{
throw new ArgumentNullException("uri");
}
FieldInfo fieldInfo = uri.GetType().GetField("m_Syntax", BindingFlags.Instance | BindingFlags.NonPublic);
if (fieldInfo == null)
{
throw new MissingFieldException("'m_Syntax' field not found");
}
object uriParser = fieldInfo.GetValue(uri);
fieldInfo = typeof(UriParser).GetField("m_Flags", BindingFlags.Instance | BindingFlags.NonPublic);
if (fieldInfo == null)
{
throw new MissingFieldException("'m_Flags' field not found");
}
object uriSyntaxFlags = fieldInfo.GetValue(uriParser);
// Clear the flag that we don't want
uriSyntaxFlags = (int)uriSyntaxFlags & ~UnEscapeDotsAndSlashes;
fieldInfo.SetValue(uriParser, uriSyntaxFlags);
}
示例2: ApplicationResourceStream
/// <summary>
/// �Է��䷽ʽ������ͨ��Application��ȡ����
/// </summary>
/// <param name="pathUri"></param>
/// <returns></returns>
public static System.IO.Stream ApplicationResourceStream(Uri pathUri)
{
if (!supportApplication)
{
return null;
}
try
{
if (appType == null)
{
try
{
appType = JavaRuntime.ClassforName("System.Windows.Application");
supportApplication = true;
}
catch
{
supportApplication = false;
}
}
object o = JavaRuntime.NewInstance(appType);
System.Reflection.MethodInfo method = JavaRuntime.GetMethod(appType, "GetResourceStream", pathUri.GetType());
object res = JavaRuntime.Invoke(method, o, pathUri);
if (res != null)
{
System.Reflection.MethodInfo info = res.GetType().GetMethod("get_Stream");
object open = JavaRuntime.Invoke(info, res);
return open as System.IO.Stream;
}
}
catch
{
}
return null;
}
示例3: Complex_parameters
public void Complex_parameters()
{
var target = new Interpreter();
var x = new MyTestService();
var y = new Uri("http://www.google.com");
var z = CultureInfo.GetCultureInfo("en-US");
var parameters = new[] {
new Parameter("x", x.GetType(), x),
new Parameter("y", y.GetType(), y),
new Parameter("z", z.GetType(), z)
};
Assert.AreEqual(x, target.Eval("x", parameters));
Assert.AreEqual(y, target.Eval("y", parameters));
Assert.AreEqual(z, target.Eval("z", parameters));
}
示例4: DontUnescapePathDotsAndSlashes
/// <summary>
/// This method was copied as-is from AmazonServiceClient.
/// TODO When the SDK supports arrays in request parameters remove this method.
/// </summary>
/// <param name="uri"></param>
/// <returns></returns>
private static void DontUnescapePathDotsAndSlashes(Uri uri)
{
#if BCL
// System.UriSyntaxFlags is internal
const int UnEscapeDotsAndSlashes = 0x2000000;
if (uri == null)
throw new ArgumentNullException("uri");
try
{
// currently prefer silent return than exceptions or log messages if reflection fails to
// find the fields we need, otherwise we could generate a lot of noise if someone
// runs on a platform without these fields
FieldInfo fieldInfo = uri.GetType().GetField("m_Syntax", BindingFlags.Instance | BindingFlags.NonPublic);
if (fieldInfo == null)
return;
var uriParser = fieldInfo.GetValue(uri);
fieldInfo = typeof(UriParser).GetField("m_Flags", BindingFlags.Instance | BindingFlags.NonPublic);
if (fieldInfo == null)
return;
var uriSyntaxFlags = fieldInfo.GetValue(uriParser);
uriSyntaxFlags = (int)uriSyntaxFlags & ~UnEscapeDotsAndSlashes;
fieldInfo.SetValue(uriParser, uriSyntaxFlags);
}
catch (Exception)
{
// swallow the exception because this platform doesn't support the hack to fix the big in the Uri class.
}
#endif
}
示例5: CreateUriReadPermission
internal static CodeAccessPermission CreateUriReadPermission(Uri uri)
{
// explicitly disallow sub-classed Uris to guard against
// exploits where we "lie" about some of the properties on the Uri.
// and then later change the value returned
// ( e.g. supply a different uri from what checked here)
if (uri.GetType().IsSubclassOf(typeof(Uri)))
{
DemandInfrastructurePermission();
}
if (uri.IsFile)
return new FileIOPermission(FileIOPermissionAccess.Read, uri.LocalPath);
// Add appropriate demands for other Uri types here.
return null;
}