本文整理汇总了C#中mdr.DefineOwnProperty方法的典型用法代码示例。如果您正苦于以下问题:C# mdr.DefineOwnProperty方法的具体用法?C# mdr.DefineOwnProperty怎么用?C# mdr.DefineOwnProperty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mdr
的用法示例。
在下文中一共展示了mdr.DefineOwnProperty方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CustomFillPrototype
static partial void CustomFillPrototype(mdr.DObject prototype)
{
var window = mwr.HTMLRuntime.Instance.GlobalContext;
prototype.DefineOwnProperty("onblur", new mdr.DForwardingProperty(window, "onblur"));
prototype.DefineOwnProperty("onerror", new mdr.DForwardingProperty(window, "onerror"));
prototype.DefineOwnProperty("onfocus", new mdr.DForwardingProperty(window, "onfocus"));
prototype.DefineOwnProperty("onload", new mdr.DForwardingProperty(window, "onload"));
prototype.DefineOwnProperty("onscroll", new mdr.DForwardingProperty(window, "onscroll"));
}
示例2: CustomFillPrototype
static partial void CustomFillPrototype(mdr.DObject prototype)
{
Debug.WriteLine("++$> adding geolocation to Navigator props");
prototype.DefineOwnProperty("geolocation", new mdr.DProperty()
{
TargetValueType = mdr.ValueTypes.String,
OnGetDValue = (mdr.DObject This, ref mdr.DValue v) =>
{
v.Set((This as Navigator).Geolocation);
},
}, mdr.PropertyDescriptor.Attributes.NotWritable);
}
示例3: JSBuiltinConstructor
protected JSBuiltinConstructor(mdr.DObject prototype, string Class)
: base(null, null)
{
TargetPrototype = prototype;
TargetDType = mdr.Runtime.Instance.GetRootMapOfPrototype(TargetPrototype);
TargetDType.Metadata.Name = Class;
//var protoPD = PrototypePropertyDescriptor;
//protoPD.SetAttributes(mdr.PropertyDescriptor.Attributes.NotConfigurable | mdr.PropertyDescriptor.Attributes.NotWritable | mdr.PropertyDescriptor.Attributes.NotEnumerable, true);
//protoPD.Set(this, prototype);
SetField("prototype", prototype);
prototype.DefineOwnProperty(
"constructor"
, this
, mdr.PropertyDescriptor.Attributes.Data | mdr.PropertyDescriptor.Attributes.NotEnumerable
);
//prototype.SetField("constructor", this);
}
示例4: Init
internal static void Init(mdr.DObject obj)
{
obj.SetField("global", obj);
//obj.SetField("null", mdr.Runtime.Instance.DefaultDNull);
obj.DefineOwnProperty("undefined", mdr.Runtime.Instance.DefaultDUndefined, mdr.PropertyDescriptor.Attributes.Data | mdr.PropertyDescriptor.Attributes.NotWritable | mdr.PropertyDescriptor.Attributes.NotEnumerable | mdr.PropertyDescriptor.Attributes.NotConfigurable);
obj.DefineOwnProperty("NaN", double.NaN, mdr.PropertyDescriptor.Attributes.Data | mdr.PropertyDescriptor.Attributes.NotWritable | mdr.PropertyDescriptor.Attributes.NotEnumerable | mdr.PropertyDescriptor.Attributes.NotConfigurable);
obj.DefineOwnProperty("Infinity", double.PositiveInfinity, mdr.PropertyDescriptor.Attributes.Data | mdr.PropertyDescriptor.Attributes.NotWritable | mdr.PropertyDescriptor.Attributes.NotEnumerable | mdr.PropertyDescriptor.Attributes.NotConfigurable);
obj.SetField("Object", new JSObject());
obj.SetField("Function", new JSFunction());
obj.SetField("Array", new JSArray());
obj.SetField("ArrayBuffer", new JSArrayBuffer());
obj.SetField("Int8Array", new JSInt8Array());
obj.SetField("Uint8Array", new JSUint8Array());
obj.SetField("Int16Array", new JSInt16Array());
obj.SetField("Uint16Array", new JSUint16Array());
obj.SetField("Int32Array", new JSInt32Array());
obj.SetField("Uint32Array", new JSUint32Array());
obj.SetField("Float32Array", new JSFloat32Array());
obj.SetField("Float64Array", new JSFloat64Array());
obj.SetField("Math", new JSMath());
obj.SetField("String", new JSString());
obj.SetField("Number", new JSNumber());
obj.SetField("Date", new JSDate());
obj.SetField("Boolean", new JSBoolean());
obj.SetField("Error", new JSError());
obj.SetField("RegExp", new JSRegExp());
obj.SetField("eval", BuiltinEval);
AddStandardMethods(obj);
AddExtendedMethods(obj);
}
示例5: PreparePrototype
public static new void PreparePrototype(mdr.DObject prototype)
{
prototype.DefineOwnProperty("latitude", new mdr.DProperty()
{
OnGetDValue = (mdr.DObject This, ref mdr.DValue v) =>
{
var ev = This.FirstInPrototypeChainAs<JSPosition>();
v.Set(ev.Data.latitude);
},
}, mdr.PropertyDescriptor.Attributes.NotWritable);
prototype.DefineOwnProperty("longitude", new mdr.DProperty()
{
OnGetDValue = (mdr.DObject This, ref mdr.DValue v) =>
{
var ev = This.FirstInPrototypeChainAs<JSPosition>();
v.Set(ev.Data.longitude);
},
}, mdr.PropertyDescriptor.Attributes.NotWritable);
prototype.DefineOwnProperty("altitude", new mdr.DProperty()
{
OnGetDValue = (mdr.DObject This, ref mdr.DValue v) =>
{
var ev = This.FirstInPrototypeChainAs<JSPosition>();
v.Set(ev.Data.altitude);
},
}, mdr.PropertyDescriptor.Attributes.NotWritable);
prototype.DefineOwnProperty("accuracy", new mdr.DProperty()
{
OnGetDValue = (mdr.DObject This, ref mdr.DValue v) =>
{
var ev = This.FirstInPrototypeChainAs<JSPosition>();
v.Set(ev.Data.accuracy);
},
}, mdr.PropertyDescriptor.Attributes.NotWritable);
prototype.DefineOwnProperty("altitudeAccuracy", new mdr.DProperty()
{
OnGetDValue = (mdr.DObject This, ref mdr.DValue v) =>
{
var ev = This.FirstInPrototypeChainAs<JSPosition>();
v.Set(ev.Data.altitudeAccuracy);
},
}, mdr.PropertyDescriptor.Attributes.NotWritable);
prototype.DefineOwnProperty("heading", new mdr.DProperty()
{
OnGetDValue = (mdr.DObject This, ref mdr.DValue v) =>
{
var ev = This.FirstInPrototypeChainAs<JSPosition>();
v.Set(ev.Data.heading);
},
}, mdr.PropertyDescriptor.Attributes.NotWritable);
prototype.DefineOwnProperty("speed", new mdr.DProperty()
{
OnGetDValue = (mdr.DObject This, ref mdr.DValue v) =>
{
var ev = This.FirstInPrototypeChainAs<JSPosition>();
v.Set(ev.Data.speed);
},
}, mdr.PropertyDescriptor.Attributes.NotWritable);
prototype.DefineOwnProperty("lciid", new mdr.DProperty()
{
OnGetDValue = (mdr.DObject This, ref mdr.DValue v) =>
{
var ev = This.FirstInPrototypeChainAs<JSPosition>();
v.Set(ev.Data.lciid);
},
}, mdr.PropertyDescriptor.Attributes.NotWritable);
prototype.DefineOwnProperty("timestamp", new mdr.DProperty()
{
OnGetDValue = (mdr.DObject This, ref mdr.DValue v) =>
{
var ev = This.FirstInPrototypeChainAs<JSPosition>();
v.Set(ev.Data.timestamp);
},
}, mdr.PropertyDescriptor.Attributes.NotWritable);
prototype.DefineOwnProperty("status", new mdr.DProperty()
{
OnGetDValue = (mdr.DObject This, ref mdr.DValue v) =>
{
var ev = This.FirstInPrototypeChainAs<JSPosition>();
v.Set(ev.Data.status);
},
}, mdr.PropertyDescriptor.Attributes.NotWritable);
}
示例6: InitDFunctionPrototype
internal static void InitDFunctionPrototype(mdr.DObject dFunctionProto,
string protoFieldName,
int prototypeFieldId)
{
dFunctionProto.DefineOwnProperty(
protoFieldName
, new DProperty()
{
TargetValueType = ValueTypes.Object,
OnGetDValue = (DObject This, ref DValue v) =>
{
//This is the first time This["prototype"] is accessed
//So, we create the object, and add it to the object with a new PropertyDescriptor so that the current code is not executed again later
var func = This.ToDFunction();
var prototype = func.Map.AddOwnProperty(func, protoFieldName, prototypeFieldId, PropertyDescriptor.Attributes.Data | PropertyDescriptor.Attributes.NotEnumerable);
func.PrototypePropertyDescriptor = prototype;
func.Fields[prototype.Index].Set(new DObject());
v.Set(ref func.Fields[prototype.Index]);
},
OnSetDValue = (DObject This, ref DValue v) =>
{
//This is the first time This["prototype"] is accessed
//So, we add a new PropertyDescriptor so that the current code is not executed again later
var func = This.ToDFunction();
var prototype = func.Map.AddOwnProperty(func, protoFieldName, prototypeFieldId, PropertyDescriptor.Attributes.Data | PropertyDescriptor.Attributes.NotEnumerable);
func.PrototypePropertyDescriptor = prototype;
func.Fields[prototype.Index].Set(ref v);
},
}
, PropertyDescriptor.Attributes.Accessor
| PropertyDescriptor.Attributes.NotEnumerable
);
}
示例7: InitDStringPrototype
internal static void InitDStringPrototype(mdr.DObject dStringProto,
string protoFieldName)
{
dStringProto.DefineOwnProperty(
protoFieldName
, new DProperty()
{
TargetValueType = ValueTypes.Int32,
OnGetInt = (This) =>
{
var str = This as DString;
if (str.PrimitiveValue.AsString() != null)
return str.PrimitiveValue.AsString().Length;
else
return 0;
},
OnGetDValue = (DObject This, ref DValue v) =>
{
var str = This as DString;
if (str != null && str.PrimitiveValue.AsString() != null)
v.Set(str.PrimitiveValue.AsString().Length);
else
v.Set(0);
},
OnSetDValue = (DObject This, ref DValue v) => { },
}
, PropertyDescriptor.Attributes.Accessor
| PropertyDescriptor.Attributes.NotEnumerable
| PropertyDescriptor.Attributes.NotConfigurable
| PropertyDescriptor.Attributes.NotWritable
);
}
示例8: InitDArrayPrototype
internal static void InitDArrayPrototype(mdr.DObject dArrayProto,
string protoFieldName)
{
dArrayProto.DefineOwnProperty(
protoFieldName
, new DProperty()
{
TargetValueType = ValueTypes.Int32,
OnGetInt = (This) => { return (This as DArray).Length; },
OnSetInt = (This, v) => { (This as DArray).Length = v; },
OnGetDValue = (DObject This, ref DValue v) =>
{
var array = This.FirstInPrototypeChainAs<DArray>(false);
if (array != null)
v.Set(array.Length);
else
v.Set(0);
},
OnSetDValue = (DObject This, ref DValue v) =>
{
var array = This.FirstInPrototypeChainAs<DArray>(false);
if (array != null)
array.Length = v.AsInt32();
},
}
, PropertyDescriptor.Attributes.Accessor
| PropertyDescriptor.Attributes.NotEnumerable
| PropertyDescriptor.Attributes.NotConfigurable
);
}