本文整理汇总了C#中System.Web.UI.TemplateParser.AddTypeDependency方法的典型用法代码示例。如果您正苦于以下问题:C# TemplateParser.AddTypeDependency方法的具体用法?C# TemplateParser.AddTypeDependency怎么用?C# TemplateParser.AddTypeDependency使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Web.UI.TemplateParser
的用法示例。
在下文中一共展示了TemplateParser.AddTypeDependency方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Init
private bool _fLateBinding; // Force latebinding when early binding could be done
/// <internalonly/>
/// <devdoc>
/// </devdoc>
public override void Init(TemplateParser parser, ControlBuilder parentBuilder,
Type type, string tagName,
string id, IDictionary attribs) {
if (id == null) {
throw new HttpException(
SR.GetString(SR.Object_tag_must_have_id));
}
ID = id;
// Get the scope attribute of the object tag
string scope = (string) attribs["scope"];
// Map it to an ObjectTagScope enum
if (scope == null)
_scope = ObjectTagScope.Default;
else if (StringUtil.EqualsIgnoreCase(scope, "page"))
_scope = ObjectTagScope.Page;
else if (StringUtil.EqualsIgnoreCase(scope, "session"))
_scope = ObjectTagScope.Session;
else if (StringUtil.EqualsIgnoreCase(scope, "application"))
_scope = ObjectTagScope.Application;
else if (StringUtil.EqualsIgnoreCase(scope, "appinstance"))
_scope = ObjectTagScope.AppInstance;
else
throw new HttpException(SR.GetString(SR.Invalid_scope, scope));
Util.GetAndRemoveBooleanAttribute(attribs, "latebinding",
ref _fLateBinding);
string tmp = (string) attribs["class"];
// Is there a 'class' attribute?
if (tmp != null) {
// Get a Type object from the type string
_type = parser.GetType(tmp);
}
// If we don't have a type, check for a classid attribute
if (_type == null) {
tmp = (string) attribs["classid"];
if (tmp != null) {
// Create a Guid out of it
Guid clsid = new Guid(tmp);
// Turn it into a type
_type = Type.GetTypeFromCLSID(clsid);
if (_type == null)
throw new HttpException(SR.GetString(SR.Invalid_clsid, tmp));
//
if (_fLateBinding || Util.IsLateBoundComClassicType(_type)) {
_lateBound = true;
_clsid = tmp;
}
else {
// Add a dependency to the type, so that the user can use it without
// having to import it
parser.AddTypeDependency(_type);
}
}
}
// If we don't have a type, check for a progid attribute
if (_type == null) {
tmp = (string) attribs["progid"];
if (tmp != null) {
#if !FEATURE_PAL // FEATURE_PAL does not enable COM
// Turn it into a type
_type = Type.GetTypeFromProgID(tmp);
#else // !FEATURE_PAL
throw new NotImplementedException("ROTORTODO");
#endif // !FEATURE_PAL
if (_type == null)
throw new HttpException(SR.GetString(SR.Invalid_progid, tmp));
Debug.Trace("Template", "<object> type: " + _type.FullName);
//
//.........这里部分代码省略.........
示例2: Init
public override void Init(TemplateParser parser, ControlBuilder parentBuilder, Type type, string tagName, string id, IDictionary attribs)
{
if (id == null)
{
throw new HttpException(System.Web.SR.GetString("Object_tag_must_have_id"));
}
base.ID = id;
string str = (string) attribs["scope"];
if (str == null)
{
this._scope = ObjectTagScope.Default;
}
else if (StringUtil.EqualsIgnoreCase(str, "page"))
{
this._scope = ObjectTagScope.Page;
}
else if (StringUtil.EqualsIgnoreCase(str, "session"))
{
this._scope = ObjectTagScope.Session;
}
else if (StringUtil.EqualsIgnoreCase(str, "application"))
{
this._scope = ObjectTagScope.Application;
}
else
{
if (!StringUtil.EqualsIgnoreCase(str, "appinstance"))
{
throw new HttpException(System.Web.SR.GetString("Invalid_scope", new object[] { str }));
}
this._scope = ObjectTagScope.AppInstance;
}
Util.GetAndRemoveBooleanAttribute(attribs, "latebinding", ref this._fLateBinding);
string typeName = (string) attribs["class"];
if (typeName != null)
{
this._type = parser.GetType(typeName);
}
if (this._type == null)
{
typeName = (string) attribs["classid"];
if (typeName != null)
{
Guid clsid = new Guid(typeName);
this._type = Type.GetTypeFromCLSID(clsid);
if (this._type == null)
{
throw new HttpException(System.Web.SR.GetString("Invalid_clsid", new object[] { typeName }));
}
if (this._fLateBinding || Util.IsLateBoundComClassicType(this._type))
{
this._lateBound = true;
this._clsid = typeName;
}
else
{
parser.AddTypeDependency(this._type);
}
}
}
if (this._type == null)
{
typeName = (string) attribs["progid"];
if (typeName != null)
{
this._type = Type.GetTypeFromProgID(typeName);
if (this._type == null)
{
throw new HttpException(System.Web.SR.GetString("Invalid_progid", new object[] { typeName }));
}
if (this._fLateBinding || Util.IsLateBoundComClassicType(this._type))
{
this._lateBound = true;
this._progid = typeName;
}
else
{
parser.AddTypeDependency(this._type);
}
}
}
if (this._type == null)
{
throw new HttpException(System.Web.SR.GetString("Object_tag_must_have_class_classid_or_progid"));
}
}