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


C# IObject.HasProperty方法代码示例

本文整理汇总了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'.");
        }
开发者ID:ChaosPandion,项目名称:Machete,代码行数:15,代码来源:Iterator.cs

示例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;
        }
开发者ID:ChaosPandion,项目名称:Machete,代码行数:58,代码来源:Environment.cs


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