当前位置: 首页>>代码示例>>C#>>正文


C# Uri.GetType方法代码示例

本文整理汇总了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);
        }
开发者ID:JesperSchultz,项目名称:NEST,代码行数:26,代码来源:Connection.cs

示例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;
 }
开发者ID:hellogithubtesting,项目名称:LGame,代码行数:40,代码来源:Resources.cs

示例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));
        }
开发者ID:kornarakis,项目名称:DynamicExpresso,代码行数:17,代码来源:ParametersTest.cs

示例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
        }
开发者ID:aws,项目名称:aws-sdk-net,代码行数:41,代码来源:SynthesizeSpeechUtil.cs

示例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;
        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:17,代码来源:SecurityHelper.cs


注:本文中的System.Uri.GetType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。