本文整理汇总了C#中IObject.HasProperty方法的典型用法代码示例。如果您正苦于以下问题:C# IObject.HasProperty方法的具体用法?C# IObject.HasProperty怎么用?C# IObject.HasProperty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IObject
的用法示例。
在下文中一共展示了IObject.HasProperty方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Iterator
public Iterator(IEnvironment environment, IDynamic iterable)
{
_environment = environment;
var o = iterable.ConvertToObject();
var createIterator = o.Get("createIterator") as ICallable;
if (createIterator == null)
throw environment.CreateTypeError("The object supplied does not contain a callable property named 'createIterator'.");
_iterator = createIterator.Call(environment, iterable, environment.EmptyArgs).ConvertToObject();
if (!_iterator.HasProperty("current"))
throw environment.CreateTypeError("The object returned from the iterable supplied does not have a property named 'current'.");
_next = _iterator.Get("next") as ICallable;
if (_next == null)
throw environment.CreateTypeError("The object returned from the iterable supplied does not have a callable property named 'next'.");
}
示例2: ToPropertyDescriptor
public IPropertyDescriptor ToPropertyDescriptor(IObject obj)
{
// 8.10.5 ToPropertyDescriptor ( Obj )
Debug.Assert(obj != null);
var desc = new SPropertyDescriptor();
if (obj.HasProperty("enumerable"))
{
desc.Enumerable = obj.Get("enumerable").ConvertToBoolean().BaseValue;
}
if (obj.HasProperty("configurable"))
{
desc.Enumerable = obj.Get("configurable").ConvertToBoolean().BaseValue;
}
if (obj.HasProperty("value"))
{
desc.Value = obj.Get("value");
}
if (obj.HasProperty("writable"))
{
desc.Writable = obj.Get("writable").ConvertToBoolean().BaseValue;
}
if (obj.HasProperty("get"))
{
var getter = obj.Get("get");
if (getter.TypeCode != LanguageTypeCode.Undefined && !(getter is ICallable))
{
throw CreateTypeError("");
}
desc.Get = getter;
}
if (obj.HasProperty("set"))
{
var setter = obj.Get("set");
if (setter.TypeCode != LanguageTypeCode.Undefined && !(setter is ICallable))
{
throw CreateTypeError("");
}
desc.Get = setter;
}
if (desc.Get != null || desc.Set != null)
{
if (desc.Value != null || desc.Writable != null)
{
throw CreateTypeError("");
}
}
return desc;
}