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


C# ScriptContext.DeclareType方法代码示例

本文整理汇总了C#中ScriptContext.DeclareType方法的典型用法代码示例。如果您正苦于以下问题:C# ScriptContext.DeclareType方法的具体用法?C# ScriptContext.DeclareType怎么用?C# ScriptContext.DeclareType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ScriptContext的用法示例。


在下文中一共展示了ScriptContext.DeclareType方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Declare

        /// <summary>
		/// Declares types unconditionally declared in this module on the given <see cref="ScriptContext"/>.
		/// Although, we can emit the Declare helper, it is not necessary as we can do it here for types 
		/// and functions. Only constants, which cannot be evaluated at compile time (they are dependent 
		/// on other eval-time evaluated constants are emitted (TODO).
		/// </summary>
        public void Declare(ScriptContext/*!*/ context)
		{
			if (bakedTypes != null)
			{
				foreach (KeyValuePair<string, PhpTypeDesc> entry in bakedTypes)
				{
					//// checks for conflict on AC:
					//if (module.Assembly.ApplicationContext.Types.ContainsKey(entry.Key))
					//  PhpException.Throw(PhpError.Error, CoreResources.GetString("type_redeclared", entry.Key));

					// checks for conflict on SC:
					if (entry.Value.IsGeneric)
						context.DeclareGenericType(entry.Value, entry.Key);
					else
						context.DeclareType(entry.Value, entry.Key);

                    // moved to TypesProvider.FindAndProvideType
                    //
                    //// When class is compiled in runtime, autoload is invoked on base class (if isn't already declared). 
                    //// We have to call autoload on the base class also in transient assembly
                    //if (entry.Value.Base is PhpTypeDesc)
                    //{
                    //    var baseDesc = context.ResolveType(entry.Value.Base.MakeSimpleName(), null, caller, null, ResolveTypeFlags.UseAutoload);
                    //    // if (baseDesc != entry.Value.Base) we have to invalidate the cache
                    //}
				}
			}
			
			if (bakedFunctions != null)
			{
				foreach (KeyValuePair<string, PhpRoutineDesc> entry in bakedFunctions)
				{
					//// checks for conflict on AC:
					//if (module.Assembly.ApplicationContext.Functions.ContainsKey(entry.Key))
					//  PhpException.Throw(PhpError.Error, CoreResources.GetString("type_redeclared", entry.Value));

					// checks for conflict on SC:
					context.DeclareFunction(new PhpRoutineDesc(entry.Value.MemberAttributes, entry.Value.ArglessStub, false), entry.Key);
				}
			}

            if (bakedConstants != null)
            {
                foreach (var entry in this.bakedConstants)
                {
                    // checks for conflict on SC:
                    //if (constant.HasValue)
                    context.DeclareConstant(entry.Key, entry.Value.LiteralValue);
                }	
            }
		}
开发者ID:MpApQ,项目名称:Phalanger,代码行数:57,代码来源:CompilationUnits.cs


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