當前位置: 首頁>>代碼示例>>C#>>正文


C# Context.GetDeclaredType方法代碼示例

本文整理匯總了C#中Pchp.Core.Context.GetDeclaredType方法的典型用法代碼示例。如果您正苦於以下問題:C# Context.GetDeclaredType方法的具體用法?C# Context.GetDeclaredType怎麽用?C# Context.GetDeclaredType使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Pchp.Core.Context的用法示例。


在下文中一共展示了Context.GetDeclaredType方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: interface_exists

        /// <summary>
		/// Tests whether a given interface is defined.
		/// </summary>
        /// <param name="ctx">Current runtime context.</param>
        /// <param name="ifaceName">The name of the interface.</param>
		/// <param name="autoload">Whether to attempt to call <c>__autoload</c>.</param>
		/// <returns><B>true</B> if the interface given by <paramref name="ifaceName"/> has been defined,
		/// <B>false</B> otherwise.</returns>
		public static bool interface_exists(Context ctx, string ifaceName, bool autoload = true)
        {
            var info = ctx.GetDeclaredType(ifaceName);
            if (info == null && autoload)
            {
                throw new NotImplementedException("autoload");
            }

            //
            return info != null && info.Type.GetTypeInfo().IsInterface;
        }
開發者ID:iolevel,項目名稱:peachpie,代碼行數:19,代碼來源:Objects.cs

示例2: class_exists

        /// <summary>
		/// Tests whether a given class is defined.
		/// </summary>
        /// <param name="ctx">Current runtime context.</param>
        /// <param name="className">The name of the class.</param>
		/// <param name="autoload">Whether to attempt to call <c>__autoload</c>.</param>
		/// <returns><B>true</B> if the class given by <paramref name="className"/> has been defined,
		/// <B>false</B> otherwise.</returns>
		public static bool class_exists(Context ctx, string className, bool autoload = true)
        {
            var info = ctx.GetDeclaredType(className);
            if (info == null && autoload)
            {
                throw new NotImplementedException("autoload");
            }

            //
            return info != null;
        }
開發者ID:iolevel,項目名稱:peachpie,代碼行數:19,代碼來源:Objects.cs

示例3: BindCore

            protected override PhpCallable BindCore(Context ctx)
            {
                PhpTypeInfo tinfo;
                
                if (_item1.IsObject)
                {
                    tinfo = _item1.Object.GetType().GetPhpTypeInfo();
                }
                else
                {
                    tinfo = ctx.GetDeclaredType(_item1.ToString(ctx));
                }

                var method = _item2.ToString(ctx);

                for (; tinfo != null; tinfo = tinfo.BaseType)
                {
                    var routine = (PhpMethodInfo)tinfo.DeclaredMethods[method];
                    if (routine != null)
                    {
                        return routine.PhpInvokable.Bind(_item1.IsObject ? _item1.Object : null);
                    }
                }

                return null;
            }
開發者ID:iolevel,項目名稱:peachpie,代碼行數:26,代碼來源:PhpCallback.cs


注:本文中的Pchp.Core.Context.GetDeclaredType方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。