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


C# ObjectInstance.GetOwnPropertyDescriptor方法代码示例

本文整理汇总了C#中Jurassic.Library.ObjectInstance.GetOwnPropertyDescriptor方法的典型用法代码示例。如果您正苦于以下问题:C# ObjectInstance.GetOwnPropertyDescriptor方法的具体用法?C# ObjectInstance.GetOwnPropertyDescriptor怎么用?C# ObjectInstance.GetOwnPropertyDescriptor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Jurassic.Library.ObjectInstance的用法示例。


在下文中一共展示了ObjectInstance.GetOwnPropertyDescriptor方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DefineProperty

 public static ObjectInstance DefineProperty(ObjectInstance obj, object key, object attributes)
 {
     key = TypeConverter.ToPropertyKey(key);
     var defaults = obj.GetOwnPropertyDescriptor(key);
     if (!(attributes is ObjectInstance))
         throw new JavaScriptException(obj.Engine, ErrorType.TypeError, "Invalid descriptor for property '{propertyName}'.");
     var descriptor = PropertyDescriptor.FromObject((ObjectInstance)attributes, defaults);
     obj.DefineProperty(key, descriptor, true);
     return obj;
 }
开发者ID:paulbartrum,项目名称:jurassic,代码行数:10,代码来源:ObjectConstructor.cs

示例2: GetOwnPropertyDescriptor

 public static ObjectInstance GetOwnPropertyDescriptor(ObjectInstance obj, object key)
 {
     var descriptor = obj.GetOwnPropertyDescriptor(TypeConverter.ToPropertyKey(key));
     if (descriptor.Exists == false)
         return null;
     return descriptor.ToObject(obj.Engine);
 }
开发者ID:paulbartrum,项目名称:jurassic,代码行数:7,代码来源:ObjectConstructor.cs

示例3: SetObjectLiteralSetter

 /// <summary>
 /// Sets the value of a object literal property to a setter.  If the value already has a
 /// getter then it will be retained.
 /// </summary>
 /// <param name="obj"> The object to set the property on. </param>
 /// <param name="key"> The property key (can be a string or a symbol).</param>
 /// <param name="setter"> The setter function. </param>
 public static void SetObjectLiteralSetter(ObjectInstance obj, object key, UserDefinedFunction setter)
 {
     var descriptor = obj.GetOwnPropertyDescriptor(key);
     if (descriptor.Exists == false || !descriptor.IsAccessor)
         obj.DefineProperty(key, new PropertyDescriptor(null, setter, Library.PropertyAttributes.FullAccess), throwOnError: false);
     else
         obj.DefineProperty(key, new PropertyDescriptor(descriptor.Getter, setter, Library.PropertyAttributes.FullAccess), throwOnError: false);
 }
开发者ID:paulbartrum,项目名称:jurassic,代码行数:15,代码来源:ReflectionHelpers.cs


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