本文整理汇总了C#中DObject类的典型用法代码示例。如果您正苦于以下问题:C# DObject类的具体用法?C# DObject怎么用?C# DObject使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DObject类属于命名空间,在下文中一共展示了DObject类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DefineProperty
private void DefineProperty(DObject O, string name, DObject desc)
{
if (desc == null || O == null || name == null)
Trace.Fail("TypeError");
var getter = new DValue();
var setter = new DValue();
var value = new DValue();
var attributes = PropertyDescriptor.Attributes.NotEnumerable | PropertyDescriptor.Attributes.NotWritable | PropertyDescriptor.Attributes.NotConfigurable;
attributes = PropertyDescriptor.Attributes.NotEnumerable | PropertyDescriptor.Attributes.NotWritable | PropertyDescriptor.Attributes.NotConfigurable;
getter.SetUndefined();
setter.SetUndefined();
value.SetUndefined();
value = desc.HasProperty("value") ? desc.GetField("value") : value;
if (desc.HasProperty("enumerable"))
attributes &= desc.GetField("enumerable").AsBoolean() ? ~PropertyDescriptor.Attributes.NotEnumerable : attributes;
if (desc.HasProperty("configurable"))
attributes &= desc.GetField("configurable").AsBoolean() ? ~PropertyDescriptor.Attributes.NotConfigurable : attributes;
if (desc.HasProperty("writable"))
attributes &= desc.GetField("writable").AsBoolean() ? ~PropertyDescriptor.Attributes.NotWritable : attributes;
if (desc.HasProperty("get"))
{
getter = desc.GetField("get");
if (!ValueTypesHelper.IsUndefined(getter.ValueType) && !ValueTypesHelper.IsFunction(getter.ValueType))
Trace.Fail("TypeError");
}
if (desc.HasProperty("set"))
{
setter = desc.GetField("set");
if (!ValueTypesHelper.IsUndefined(setter.ValueType) && !ValueTypesHelper.IsFunction(setter.ValueType))
Trace.Fail("TypeError");
}
Trace.Assert(
!((desc.HasProperty("get") || desc.HasProperty("set"))
&& (desc.HasProperty("value") || desc.HasProperty("writable"))),
"If either getter or setter needs to be defined, value or writable shouldn't be defined.");
if (desc.HasProperty("value"))
O.DefineOwnProperty(name, ref value, attributes | PropertyDescriptor.Attributes.Data);
else
{
var property = new DProperty();
if (ValueTypesHelper.IsFunction(getter.ValueType))
property.Getter = getter.AsDFunction();
if (ValueTypesHelper.IsFunction(setter.ValueType))
property.Setter = setter.AsDFunction();
O.DefineOwnProperty(name, property, attributes | PropertyDescriptor.Attributes.Accessor);
}
}
示例2: Set
public void Set(DObject v)
{
if (v == null)
Object = DObject.Undefined;
else
v.CopyTo(this);
}
示例3: SimpleGetTest
private void SimpleGetTest(string path, DObject expected)
{
DObjectNavigator nav = new DObjectNavigator(_root);
DObjectNavigator selector = nav.Select(path);
Assert.AreEqual(expected, selector.Get());
}
示例4: ActorProxy
public ActorProxy(DObject dObject, ILogger logger)
{
this.dObject = dObject;
this.logger = logger;
handlers = new EventHandlersOnClientActor();
this.dObject.OnGetEvent += OnGetEvent;
handlers.ChangeColor += Handler_OnChangeColor;
}
示例5: Add
/*** Сложение двух матриц ***/
public DObject Add(DObject dobj)
{
if (sx != dobj.sx || sy != dobj.sy) return null;
DObject ret = new DObject(sx, sy);
for (int i = 0; i < matrix.Length; i++)
{
ret.matrix[i] = matrix[i] + dobj.matrix[i];
}
return ret;
}
示例6: clone
/*** Создать копию объекта ***/
public void clone(DObject dobj)
{
if ((sx * sy) != (dobj.sx * dobj.sy)) matrix = new double[dobj.sx * dobj.sy];
sx = dobj.sx;
sy = dobj.sy;
for (int i = 0; i < sx*sy; i++)
{
matrix[i] = dobj.matrix[i];
}
}
示例7: LinqContext
// variables may be null when the code is global
protected LinqContext(DObject outerType, Dictionary<string, object> variables, ScriptContext/*!*/ context, DTypeDesc typeHandle)
{
if (context == null)
throw new ArgumentNullException("context");
this.variables = variables;
this.outerType = outerType;
this.context = context;
this.typeHandle = typeHandle;
}
示例8: PropertyMapMetadata
public PropertyMapMetadata(DObject prototype)
{
Prototype = prototype;
if (Prototype == null)
Level = 0;
else
Level = Prototype.Map.Metadata.Level + 1;
//We create an empty ProperyDescriptor to avoid checking for null all the time
Root = new PropertyMap(this, null, new PropertyDescriptor(null, Runtime.InvalidFieldId, Runtime.InvalidFieldIndex, PropertyDescriptor.Attributes.NotEnumerable | PropertyDescriptor.Attributes.Undefined), null);
}
示例9: QuoteObject
public void QuoteObject(DObject obj)
{
Message msg = new Message
{
OpCode = MessageOpCode.Quote,
AckNumber = this._ackNumber
};
msg.Attributes["object"] = obj;
_channel.SendMessage(msg);
}
示例10: GetMapMetadataOfPrototype
public PropertyMapMetadata GetMapMetadataOfPrototype(DObject prototype, bool addIfMissing = true)
{
Debug.Assert(prototype != null, "cannot lookup type information for null prototype");
WeakReference emptyNode = null; //sice we use weakref, we might want to reuse emty elements of the list
#if !SEARCH_CHILDREN_LIST //TODO: we can explore the effect of the following by commening the next few lines
if (prototype.SubMapsMetadata != null)
return prototype.SubMapsMetadata;
var iter = _children.GetEnumerator();
while (iter.MoveNext())
{
var childRef = iter.Current;
if (!childRef.IsAlive)
{
emptyNode = childRef;
break;
}
}
#else
var iter = _children.GetEnumerator();
while (iter.MoveNext())
{
var childRef = iter.Current;
if (childRef.IsAlive)
{
var child = childRef.Target as PropertyMapMetadata;
if (child.Prototype == prototype)
return child;
}
else if (emptyNode == null)
emptyNode = childRef;
}
#endif
///Ok, we did not find any, let's add one to the list
if (!addIfMissing)
return null;
var newRoot = new PropertyMapMetadata(prototype);
if (emptyNode == null)
{
emptyNode = new WeakReference(newRoot);
_children.AddLast(emptyNode);
}
else
emptyNode.Target = newRoot;
prototype.SubMapsMetadata = newRoot;
return newRoot;
}
示例11: DForwardingProperty
public DForwardingProperty (DObject receiver, string field)
{
Receiver = receiver;
ReceiverPD = Receiver.Map.GetPropertyDescriptor(field);
Debug.Assert(ReceiverPD != null, "receiver field has null descriptor: " + field);
OnGetDValue = (DObject This, ref DValue v) =>
{
ReceiverPD.Get(Receiver, ref v);
};
OnSetDValue = (DObject This, ref DValue v) =>
{
ReceiverPD.Set(Receiver, ref v);
};
}
示例12: FrontEndServer
public FrontEndServer(IServerCommunicator communicator, ILogger logger, int sleepTimer, IServerDOManager dOManager)
{
this.communicator = communicator;
this.logger = logger;
this.sleepTimer = sleepTimer;
this.dOManager = dOManager;
// Create root DObject
// TODO - DObject should have OnGetEvent property.
DObject newObject = new DObject(dOManager);
newObject.OnGetEvent += RootDObjectHandler;
rootDObject = newObject;
dOManager.RegisterObject(newObject);
}
示例13: notsetOperation
static PhpReference notsetOperation(DObject self, string name, DTypeDesc caller, PhpReference refrnc)
{
bool getter_exists;
// the CT property has been unset -> try to invoke __get
PhpReference get_ref = self.InvokeGetterRef(name, caller, out getter_exists);
if (getter_exists) return get_ref ?? new PhpReference();
Debug.Assert(refrnc != null);
refrnc.IsAliased = true;
refrnc.IsSet = true;
return refrnc;
}
示例14: Get
//#region ToX
//public string ToString(DObject This) { return (OnGetString != null) ? OnGetString(This) : ToDValue().ToString(); }// base.ToString(); }
//public double ToDouble(DObject This) { return (OnGetDouble != null) ? OnGetDouble(This) : ToDValue().ToDouble(); }// base.ToDouble(); }
//public int ToInt(DObject This) { return (OnGetInt != null) ? OnGetInt(This) : ToDValue().ToInt32(); }// base.ToInt(); }
//public bool ToBoolean(DObject This) { return (OnGetBoolean != null) ? OnGetBoolean(This) : ToDValue().ToBoolean(); }// base.ToBoolean(); }
//public DObject ToDObject(DObject This) { return (OnGetDObject != null) ? OnGetDObject(This) : ToDValue().ToDObject(); }// base.ToDObject(); }
//public DValue ToDValue(DObject This)
//{
// if (OnGetDValue != null)
// {
// DValue temp = new DValue();
// OnGetDValue(This, ref temp);
// return temp;
// }
// else
// {
// return base.ToDValue();
// }
//}
//#endregion
#region Get
public void Get(DObject This, ref DValue v)
{
if (OnGetDValue != null)
OnGetDValue(This, ref v);
else if (Getter != null)
{
var callFrame = new CallFrame();
callFrame.Function = Getter;
callFrame.This = (This);
Getter.Call(ref callFrame);
v = callFrame.Return;
}
else
v = base.ToDValue();
}
示例15: SetProperties
public void SetProperties() {
var button1 = new Button();
var parentViewModel = new ViewModel();
var viewModel = new ViewModel();
ViewModelExtensions.SetParameter(button1, "test");
ViewModelExtensions.SetParentViewModel(button1, parentViewModel);
var dObject = new DObject();
ViewModelExtensions.SetParameter(dObject, "test");
ViewModelExtensions.SetParentViewModel(dObject, parentViewModel);
var button2 = new Button() { DataContext = viewModel };
ViewModelExtensions.SetParameter(button2, "test");
Assert.AreEqual("test", viewModel.With(x => x as ISupportParameter).Parameter);
ViewModelExtensions.SetParentViewModel(button2, parentViewModel);
Assert.AreEqual(parentViewModel, viewModel.With(x => x as ISupportParentViewModel).ParentViewModel);
}