微软的ASP.NET AJAX能写出丰富的,可交互的JavaScript程序,我们可以通过Type类来注册命名空间,类,枚举等,反射对象的内部性质,Type类是Asp.net Ajax的一个很重要类。
    Type.registerNamespace(namespacePath)  注册一个命名空间。
    Type.isNamespace(object)  判断一个对象是否是命名空间。
    classInstanceVar.registerClass(typeName, baseType, interfaceTypes)   注册一个类,typeName,要注册的类名,baseType继承的类,可以为空,interfaceTypes,继承的接口,可以为空。
    Type.isClass(type)  判断一个对象是否是一个类。
    typeInstanceVar.getName()  获取一个对象的类型名。typeInstanceVar是一个类型,可以用Object.getType(对象实例)来获取。
    TypeA.isInstanceOfType(instance) 判断一个实例是否是某个类的实例。
    typeInstanceVar.registerInterface(typeName)  注册一个接口。
    Type.isInterface(type)    判断一个类型是否是接口。    
    aType.isImplementedBy(typeInstanceVar)  判断一个类是否实现了接口。typeInstanceVar为类实例
    typeInstanceVar.implementsInterface(interfaceType)  也是判断一个类是否实现了接口,interfaceType为要判断的接口
Asp.net Ajax 客户端编程(二)——Type 类,面向对象编程的开始<script language="javascript" type="text/javascript">
Asp.net Ajax 客户端编程(二)——Type 类,面向对象编程的开始         
//Demo:http://young18.cnblogs.com
Asp.net Ajax 客户端编程(二)——Type 类,面向对象编程的开始
         //注册命名空间
Asp.net Ajax 客户端编程(二)——Type 类,面向对象编程的开始
         Type.registerNamespace("Arcadia");
Asp.net Ajax 客户端编程(二)——Type 类,面向对象编程的开始         
>
    TypeA.inheritsFrom(parentType)  判断类TypeA是否继承自基类parentType。
    instanceVar.callBaseMethod(instance, name, baseArguments)  调用基类方法,instance 为instanceVar的类型,通常为this,name 为要调用的方法名,baseArguments为调用时传入的参数(数组)。
     typeInstanceVar.getBaseType() 获取基类类型
     typeVar.getInterfaces()  获取一个基类继承的所有接口。
     Type.getRootNamespaces()   获取当前客户端应用程序的所有根命名空间。
     typeVar.baseClassName.initializeBase(instance, baseArguments )   实例化基类,instance为要实例化的基类名,baseArguments 为实例化时传递的参数。
Asp.net Ajax 客户端编程(二)——Type 类,面向对象编程的开始<form id="form1" runat="server">
Asp.net Ajax 客户端编程(二)——Type 类,面向对象编程的开始   
<%--Demo:http://young18.cnblogs.com--%>
Asp.net Ajax 客户端编程(二)——Type 类,面向对象编程的开始
   <asp:ScriptManager ID="ScriptManager1" runat="server" />
Asp.net Ajax 客户端编程(二)——Type 类,面向对象编程的开始    
Asp.net Ajax 客户端编程(二)——Type 类,面向对象编程的开始    
<script language="javascript" type="text/javascript">
Asp.net Ajax 客户端编程(二)——Type 类,面向对象编程的开始        
//注册一个命名空间
Asp.net Ajax 客户端编程(二)——Type 类,面向对象编程的开始
        Type.registerNamespace("Arcadia");
>

ANamespace.AnEnum.registerEnum(name, flags)  注册一个枚举
         alert(Arcadia.Sex.boy);

相关文章:

  • 2022-01-17
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-27
  • 2021-12-08
  • 2021-11-26
猜你喜欢
  • 2021-10-26
  • 2021-11-01
  • 2021-06-20
  • 2021-05-09
  • 2021-07-24
  • 2022-12-23
  • 2021-05-30
相关资源
相似解决方案