本文整理汇总了C#中DObject类的典型用法代码示例。如果您正苦于以下问题:C# DObject类的具体用法?C# DObject怎么用?C# DObject使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DObject类属于命名空间,在下文中一共展示了DObject类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
}
开发者ID:reshadi2,项目名称:mcjs,代码行数:60,代码来源:JSObject.cs
示例2: Set
public void Set(DObject v)
{
if (v == null)
Object = DObject.Undefined;
else
v.CopyTo(this);
}
开发者ID:reshadi2,项目名称:mcjs,代码行数:7,代码来源:DVar.cs
示例3: SimpleGetTest
private void SimpleGetTest(string path, DObject expected)
{
DObjectNavigator nav = new DObjectNavigator(_root);
DObjectNavigator selector = nav.Select(path);
Assert.AreEqual(expected, selector.Get());
}
开发者ID:vogon,项目名称:Demotic,代码行数:7,代码来源:DObjectNavigatorTest.cs
示例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;
}
开发者ID:JetCrusherTorpedo,项目名称:raknetdotnet,代码行数:9,代码来源:Client.cs
示例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;
}
开发者ID:YaStark,项目名称:ShazamO,代码行数:11,代码来源:DObject.cs
示例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];
}
}
开发者ID:YaStark,项目名称:ShazamO,代码行数:11,代码来源:DObject.cs
示例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;
}
开发者ID:tiaohai,项目名称:Phalanger,代码行数:12,代码来源:LinqHelper.cs
示例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);
}
开发者ID:reshadi2,项目名称:mcjs,代码行数:11,代码来源:PropertyMapMetadata.cs
示例9: QuoteObject
public void QuoteObject(DObject obj)
{
Message msg = new Message
{
OpCode = MessageOpCode.Quote,
AckNumber = this._ackNumber
};
msg.Attributes["object"] = obj;
_channel.SendMessage(msg);
}
开发者ID:vogon,项目名称:Demotic,代码行数:12,代码来源:RequestContext.cs
示例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;
}
开发者ID:reshadi2,项目名称:mcjs,代码行数:52,代码来源:PropertyMapMetadata.cs
示例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);
};
}
开发者ID:reshadi2,项目名称:mcjs,代码行数:14,代码来源:DForwardingProperty.cs
示例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);
}
开发者ID:JetCrusherTorpedo,项目名称:raknetdotnet,代码行数:14,代码来源:FrontEndServer.cs
示例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;
}
开发者ID:dw4dev,项目名称:Phalanger,代码行数:14,代码来源:PhpGetMemberBinder.cs
示例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();
}
开发者ID:reshadi2,项目名称:mcjs,代码行数:37,代码来源:DProperty.cs
示例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);
}
开发者ID:sk8tz,项目名称:DevExpress.Mvvm.Free,代码行数:17,代码来源:ViewModelExtensionsTests.cs
示例16: Replace
public static object Replace(ScriptContext/*!*/context, DObject self, Dictionary<string, object> definedVariables,
object pattern, object replacement, object data)
{
int count = Int32.MinValue; // disables counting
return Replace(context, self, definedVariables, pattern, replacement, null, data, -1, ref count);
}
开发者ID:proff,项目名称:Phalanger,代码行数:6,代码来源:RegExpPerl.cs
示例17: InvokeStaticMethod
public static PhpReference InvokeStaticMethod(DTypeDesc type, object methodName, DObject self,
DTypeDesc caller, ScriptContext context)
{
if (type == null)
{
// error thrown earlier
return new PhpReference();
}
// verify that methodName is a string
string name = PhpVariable.AsString(methodName);
if (String.IsNullOrEmpty(name))
{
context.Stack.RemoveFrame();
PhpException.Throw(PhpError.Error, CoreResources.GetString("invalid_method_name"));
return new PhpReference();
}
// find the method desc
bool isCallStaticMethod;
DRoutineDesc method = GetStaticMethodDesc(type, name, ref self, caller, context, false, true, out isCallStaticMethod);
if (method == null) return new PhpReference();
// invoke the method
object result;
var stack = context.Stack;
stack.LateStaticBindType = type;
if (isCallStaticMethod)
{
// __callStatic was found instead, not {methodName}
PhpArray args = stack.CollectFrame(); // get array with args, remove the previous stack
// original parameters are passed to __callStatic in an array as the second parameter
stack.AddFrame(methodName, args);
result = method.Invoke(self, stack, caller);
}
else
{
// try
// {
result = method.Invoke(self, stack, caller);
// }
// catch (NullReferenceException)
// {
// if (self == null && !method.IsStatic)
// { // $this was null, it is probably caused by accessing $this
//#if DEBUG
// throw;
//#else
// PhpException.ThisUsedOutOfObjectContext();
// result = null;
//#endif
// }
// else
// {
// throw; // $this was not null, this should not be handled here
// }
// }
}
return PhpVariable.MakeReference(PhpVariable.Copy(result, CopyReason.ReturnedByCopy));
}
开发者ID:kaviarasankk,项目名称:Phalanger,代码行数:64,代码来源:Operators.cs
示例18: GetStaticMethodDesc
/// <summary>
/// Attemps to find a method desc according to a given class name and method name. Used when
/// a non-virtual dispatch is about to be performed and when a <c>array(class, method)</c>
/// callback is being bound.
/// </summary>
/// <param name="requestedType">The type whose method should be returned.</param>
/// <param name="methodName">The method name.</param>
/// <param name="self">Current <c>$this</c>. Will be set to an instance, on which the resulting
/// CLR method should be invoked (<B>null</B> if the CLR method is static).</param>
/// <param name="caller"><see cref="Type"/> of the object that request the lookup.</param>
/// <param name="context">Current <see cref="ScriptContext"/>.</param>
/// <param name="quiet">If <B>true</B>, no exceptions will be thrown if an error occurs.</param>
/// <param name="removeFrame">If <B>true</B>, <see cref="PhpStack.RemoveFrame"/> will be called
/// before throwing an exception.</param>
/// <param name="isCallerMethod">Will be set to true, if required method was not found but __callStatic was.</param>
/// <returns>The <see cref="DRoutineDesc"/> or <B>null</B> on error.</returns>
internal static DRoutineDesc GetStaticMethodDesc(DTypeDesc requestedType, string methodName, ref DObject self,
DTypeDesc caller, ScriptContext context, bool quiet, bool removeFrame, out bool isCallerMethod)
{
Debug.Assert(requestedType != null);
isCallerMethod = false;
DRoutineDesc method;
GetMemberResult result = requestedType.GetMethod(new Name(methodName), caller, out method);
if (result == GetMemberResult.NotFound)
{
// if not found, perform __callStatic or __call 'magic' method lookup
Name callMethod = (self != null && requestedType.IsAssignableFrom(self.TypeDesc)) ?
Name.SpecialMethodNames.Call : Name.SpecialMethodNames.CallStatic;
if ((result = requestedType.GetMethod(callMethod, caller, out method)) != GetMemberResult.NotFound)
{
isCallerMethod = true;
}
else
{
// there is no such method in the class
if (removeFrame) context.Stack.RemoveFrame();
if (!quiet) PhpException.UndefinedMethodCalled(requestedType.MakeFullName(), methodName);
return null;
}
}
if (result == GetMemberResult.BadVisibility)
{
if (removeFrame) context.Stack.RemoveFrame();
if (!quiet)
{
PhpException.MethodNotAccessible(
method.DeclaringType.MakeFullName(),
method.MakeFullName(),
(caller == null ? String.Empty : caller.MakeFullName()),
method.IsProtected);
}
return null;
}
// check whether the method is abstract
if (method.IsAbstract)
{
if (removeFrame) context.Stack.RemoveFrame();
if (!quiet) PhpException.AbstractMethodCalled(method.DeclaringType.MakeFullName(), method.MakeFullName());
return null;
}
if (method.IsStatic)
{
self = null;
}
else
{
// check whether self is of acceptable type
if (self != null && !method.DeclaringType.RealType.IsInstanceOfType(self.RealObject)) self = null;
/*
// PHP allows for static invocations of instance method
if (self == null &&
(requestedType.IsAbstract || !(requestedType is PhpTypeDesc)) &&
(method.DeclaringType.IsAbstract || !(method.DeclaringType is PhpTypeDesc)))
{
// calling instance methods declared in abstract classes statically through abstract classes
// is unsupported - passing null as 'this' to such instance method could result in
// NullReferenceException even if the method does not touch $this
if (removeFrame) context.Stack.RemoveFrame();
if (!quiet)
{
PhpException.Throw(PhpError.Error, CoreResources.GetString("nonstatic_method_called_statically",
method.DeclaringType.MakeFullName(), method.MakeFullName()));
}
return null;
}
if (self == null)
{
if (!quiet && !context.Config.Variables.ZendEngineV1Compatible)
//.........这里部分代码省略.........
开发者ID:kaviarasankk,项目名称:Phalanger,代码行数:101,代码来源:Operators.cs
示例19: SetObjectFieldDirectRef
public static void SetObjectFieldDirectRef(PhpReference value, DObject/*!*/ obj, ref PhpReference/*!*/ field,
string/*!*/ name, DTypeDesc caller)
{
Debug.Assert(obj != null && field != null && name != null);
if (field.IsSet)
{
field = value;
}
else
{
SetObjectProperty(obj, name, value, caller);
}
}
开发者ID:kaviarasankk,项目名称:Phalanger,代码行数:14,代码来源:Operators.cs
示例20: SetObjectProperty
public static void SetObjectProperty(DObject/*!*/ obj, string name, object value, DTypeDesc caller)
{
Debug.Assert(obj != null && name != null);
if (ReferenceEquals(obj, ScriptContext.SetterChainSingletonObject))
{
ScriptContext context = ScriptContext.CurrentContext;
if (value is PhpReference)
{
context.AbortSetterChain(false);
return;
}
// extend and finish the setter chain
context.ExtendSetterChain(new RuntimeChainProperty(name));
context.FinishSetterChain(value);
return;
}
obj.SetProperty(name, value, caller);
}
开发者ID:kaviarasankk,项目名称:Phalanger,代码行数:22,代码来源:Operators.cs
注:本文中的DObject类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论