标签: late-binding

如何从ASP Classic中的变量调用方法?

例如,我如何在下面运行me.test?

myvar = 'test'
me.myvar
Run Code Online (Sandbox Code Playgroud)

ASP查找方法"myvar"但找不到它.在PHP中,我可以简单地说$ me - > $ myvar,但ASP的语法不区分变量和方法.建议?

与此密切相关,ASP Classic中是否有method_exists函数?

提前致谢!

编辑:我正在写一个验证类,并希望通过管道分隔字符串调用方法列表.

例如,要验证名称字段,我会调用:

validate("required|min_length(3)|max_length(100)|alphanumeric")
Run Code Online (Sandbox Code Playgroud)

我喜欢有一条线来显示给定字段的所有验证方式.并且字符串的每个管道分隔部分是方法的名称.

如果您有更好的设置建议,我会全力以赴!

vbscript late-binding asp-classic

2
推荐指数
1
解决办法
3985
查看次数

我可以延迟绑定到C#中的事件处理程序吗?

我正在动态创建对象并将它们插入到html表中,对象是标签或链接按钮,如果它们是链接按钮,我需要为click事件订阅一个事件处理程序,但我很难找到一种方法来实际添加处理程序.到目前为止的代码是:

WebControl myControl;

if _createLabel)
{
    myControl = new Label();
}
else
{
    myControl = new LinkButton();
}

myControl.ID = "someID";
myControl.GetType().InvokeMember("Text", BindingFlags.SetProperty, null, myControl,  new object[] { "some text" });

if (!_createLabel)
{
    // somehow do myControl.Click += myControlHandler; here
}
Run Code Online (Sandbox Code Playgroud)

c# event-handling late-binding

2
推荐指数
1
解决办法
3231
查看次数

如何访问后期绑定的嵌套属性和方法?

我想知道当要访问的属性嵌套在另一个属性中时,从Delphi访问后期绑定属性或方法的正确方法是什么.让我解释.

检查此示例应用程序以检查防火墙是否处于活动状态,声明的3个函数使用HNetCfg.FwMgrCOM对象并返回相同的值.

{$APPTYPE CONSOLE}

uses
  Variants,
  ActiveX,
  Comobj,
  SysUtils;

//in this function i don't use any "helper" property to hold the temp value of the properties.
function FirewallIsActive1 : Boolean;
var
  Firewall : OleVariant;
begin
  Firewall := CreateOleObject('HNetCfg.FwMgr'); 
  Result   := Firewall.LocalPolicy.CurrentProfile.FirewallEnabled;
end;


//here i hold the value of the LocalPolicy property 
function FirewallIsActive2 : Boolean;
var
  Firewall : OleVariant;
  Policy   : OleVariant;
begin
  Firewall := CreateOleObject('HNetCfg.FwMgr');
  Policy   := Firewall.LocalPolicy;
  Result   := Policy.CurrentProfile.FirewallEnabled;
end;


//Here i use  a  "helper" …
Run Code Online (Sandbox Code Playgroud)

delphi variant late-binding

2
推荐指数
1
解决办法
430
查看次数

VB.NET如何将其解析为对象属性?

好吧,所以我是一个C#编码器,我甚至无法阅读VB.NET,所以请原谅可能会变成一个令人难以置信的愚蠢问题.但我有一些看起来像这样的代码:

Function GetName(sourceObject as Object) as String
    return sourceObject.Name
End Function
Run Code Online (Sandbox Code Playgroud)

因此,忽略语法可能错误的事实 - VB.NET如何从sourceObject获取Name属性?在运行时检查它会发现sourceObject是一种支持带有getter的名为Name的属性的类型,但VB.NET在这种情况下做了什么?是否有一些额外的代码由编译器生成,以某种方式在运行时自动转换?

你可能会说,我有点困惑.提前致谢!

vb.net properties late-binding

2
推荐指数
1
解决办法
356
查看次数

如何使用后期绑定从VB.Net调用位于C#DLL内的方法

我无法控制各种"Init","Accumulate"......方法如何工作,以便从VB.Net代码中调用位于DLL中的方法.

假设要调用的方法具有以下签名:

public double ComputeMeanPosition(ref SortedList<DateTime, double> posByTime)
Run Code Online (Sandbox Code Playgroud)

请您指出使用这些方法的实际示例,或者只是给我一些提示,如何将参数实际传递给方法,调用它并获取结果?

@Olivier Jacot-Descombes:我确实用名称空间名称为类名添加前缀,但却无法访问该对象.事实上,我很惊讶您的善意建议不涉及以下方法,通过内加加载的DLL显示:

Type: MyClassName
        Method: Void Init()
        Method: Void Accumulate(System.Data.SqlTypes.SqlDouble, System.Data.SqlTypes.SqlDateTime, System.Data.SqlTypes.SqlBoolean)
        Method: Void Merge(MyClassName)
        Method: System.Data.SqlTypes.SqlDouble Terminate()
        Method: Void Write(System.IO.BinaryWriter)
        Method: Void Read(System.IO.BinaryReader)
        Method: Boolean Equals(System.Object)
        Method: Int32 GetHashCode()
        Method: System.String ToString()
        Method: System.Type GetType()
Run Code Online (Sandbox Code Playgroud)

编辑

实际上我有一个类似于下面的代码,它成功地设法检查DLL并从中获取了几种类型和方法,给出了我想要调用的方法的上述结果.

这是代码

        For Each oneModule As Reflection.Module In useAssembly.GetLoadedModules()
            Console.WriteLine("   - " & oneModule.Name)
            For Each oneType As System.Type In oneModule.GetTypes()
                Console.WriteLine("     Type: " & oneType.Name)
                For Each oneField As Reflection.FieldInfo In oneType.GetFields()
                    Console.WriteLine(" …
Run Code Online (Sandbox Code Playgroud)

.net c# vb.net late-binding

1
推荐指数
1
解决办法
6949
查看次数

PHP Late Static Binding - 解析错误:语法错误,意外T_STRING,期待T_VARIABLE

测试一些后期静态绑定并在第5行获取此错误:

Parse error: syntax error, unexpected T_STRING, expecting T_VARIABLE

第5行:

protected static test = 'A TEST';

这是来源:

class A {

    protected static test = 'A TEST';

    public static function test() {
        echo $this->test;
    }
}

Class B extends A {
    public static test = "B TEST";
    public function static_test() {
        echo static::$test;
    }
}

$a = new A;
$b = new B;

echo '$a->test()<br />';
echo $a->test();
echo '<br /> <br />';
echo '$b->test()<br />';
echo $b->test();
echo '<br /> …
Run Code Online (Sandbox Code Playgroud)

php static late-binding

1
推荐指数
1
解决办法
2985
查看次数

如何释放后期绑定的COM对象?

我想我也必须释放后期绑定的COM对象.
但这是如何直接完成的?

在我的情况下,我使用C#中的以下代码来获取Google Earth的重点(简化):

Type oClassType = Type.GetTypeFromProgID("GoogleEarth.ApplicationGE");
object oGE = Activator.CreateInstance(oClassType);
object oCamera = oGE.GetType().InvokeMember("GetCamera", System.Reflection.BindingFlags.InvokeMethod, null, oGE, new object[] { 0 });
double dFocusLatitude = (double)oCamera.GetType().InvokeMember("FocusPointLatitude", System.Reflection.BindingFlags.GetProperty, null, oCamera, null);
double dFocusLongitude = (double)oCamera.GetType().InvokeMember("FocusPointLongitude", System.Reflection.BindingFlags.GetProperty, null, oCamera, null);
Run Code Online (Sandbox Code Playgroud)

那么如何在这种情况下释放相机和Google Earth对象呢?

.net c# com release late-binding

0
推荐指数
1
解决办法
590
查看次数

Action <T>基于字符串值调用方法

有没有办法使用Action来调用基于包含该方法名称的字符串值的方法?

.net dynamic late-binding

0
推荐指数
1
解决办法
153
查看次数

宽松的后期绑定与严格的后期绑定

在阅读 Python\xe2\x80\x99s执行模型文档时,我意识到 Python\xe2\x80\x99s 自由变量似乎没有严格的后期绑定属性,其中任何代码块中发生的名称绑定都可以用于名称解析。事实上,执行:

\n
def f():\n    return x\n\ndef g():\n    x = 0\n    return f()\n\nprint(g())\n
Run Code Online (Sandbox Code Playgroud)\n

提高:

\n
NameError: name \'x\' is not defined\n
Run Code Online (Sandbox Code Playgroud)\n

它们具有相当松散的后期绑定属性,其中只有在引入自由变量的代码块的外部代码块中发生的名称绑定才能用于名称解析。确实执行

\n
NameError: name \'x\' is not defined\n
Run Code Online (Sandbox Code Playgroud)\n

印刷:

\n
0\n
Run Code Online (Sandbox Code Playgroud)\n

与严格的后期绑定属性相比,松散的后期绑定属性有哪些优点和缺点?

\n

python language-design late-binding free-variable

0
推荐指数
1
解决办法
577
查看次数

后期绑定有哪些优点?在C++中的函数指针的上下文中给出一个示例

首先,让我澄清这个问题并不能清楚地解释我的怀疑.设置上下文清晰.我在C/C++中专门针对函数指针问这个问题.

我知道早期绑定和后期绑定之间的区别以及它是如何工作的.我想要了解的是以下一个使用C/C++中的函数指针的示例:

在许多教科书中,已经提到:

后期绑定的优点是它比早期绑定更灵活,因为关于调用哪个函数的决定不需要在运行时进行.

另外,它提到:

使用后期绑定,程序必须读取指针中保存的地址,然后跳转到该地址.这涉及一个额外的步骤,使其稍慢.

#include <iostream>
using namespace std;

int Add(int nX, int nY)
{
    return nX + nY;
}

int Subtract(int nX, int nY)
{
    return nX - nY;
}

int Multiply(int nX, int nY)
{
    return nX * nY;
}

int main()
{
    int nX;
    cout << "Enter a number: ";
    cin >> nX;

    int nY;
    cout << "Enter another number: ";
    cin >> nY;

    int nOperation;
    do
    {
        cout << "Enter an operation …
Run Code Online (Sandbox Code Playgroud)

c c++ function-pointers late-binding

-1
推荐指数
1
解决办法
1519
查看次数