本文整理汇总了C#中SObject类的典型用法代码示例。如果您正苦于以下问题:C# SObject类的具体用法?C# SObject怎么用?C# SObject使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SObject类属于命名空间,在下文中一共展示了SObject类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReadElement
private void ReadElement(XmlReader reader, SObject parent) {
var name = XmlConvert.DecodeName(reader.LocalName);
var type = reader["type"];
// is it a value node ? i.e. type=""
if (type != null) {
if (type == "Array") {
// go to first item
parent.SetMember(name, ReadArray(reader));
reader.Read();
}
else {
var typeCode = (TypeCode)Enum.Parse(typeof(TypeCode), type);
var value = SConvert.XmlDecode(typeCode, reader.ReadElementString());
parent.SetMember(name, value);
}
}
else {
var grappe = new SObject();
reader.Read();
parent.SetMember(name, grappe);
while (reader.MoveToContent() == XmlNodeType.Element) {
ReadElement(reader, grappe);
}
reader.Read();
}
}
示例2: ExecuteMethod
internal override SObject ExecuteMethod(ScriptProcessor processor, string methodName, SObject caller, SObject This, SObject[] parameters)
{
InitializeStatic();
AddObjectPrototypeAsExtends(processor);
bool isStaticCall = ReferenceEquals(caller, this);
// Call any static function defined in this prototype:
if (_prototypeMembers.ContainsKey(methodName) && _prototypeMembers[methodName].IsStatic)
{
if (_prototypeMembers[methodName].IsFunction)
{
var cFunction = (SFunction)_prototypeMembers[methodName].Data;
return cFunction.Call(processor, caller, this, parameters); // For a static method, the "This" attribute is the prototype.
}
else
{
return processor.ErrorHandler.ThrowError(ErrorType.TypeError, ErrorHandler.MESSAGE_TYPE_NOT_A_FUNCTION, methodName);
}
}
// Call the super class prototype, if one exists:
if (Extends != null)
{
return Extends.ExecuteMethod(processor, methodName, caller, This, parameters);
}
return processor.ErrorHandler.ThrowError(ErrorType.ReferenceError, ErrorHandler.MESSAGE_REFERENCE_NOT_DEFINED, methodName);
}
示例3: Update
public static void Update (this SalesforceClient self, SObject sobject)
{
var updateRequest = new UpdateRequest (sobject);
var result = self.ProcessAsync (updateRequest);
if (!result.Wait (TimeSpan.FromSeconds (SalesforceClient.DefaultNetworkTimeout)))
return; // TODO : Error handling/reporting
}
示例4: op1_zerop
/* Comparison Operations */
/* --------------------- */
public static void op1_zerop(SObject arg) {
if (arg is SFixnum) {
Reg.Result = Factory.makeBoolean(((SFixnum)arg).value == 0);
return;
} else if (arg is SVL) {
SVL a = (SVL) arg;
if (a.tag == Tags.RatnumTag) {
Reg.Result = Factory.False; // FIXME???
} else if (a.tag == Tags.RectnumTag) {
op2_numeric_equals(arg, Factory.makeFixnum(0));
return;
}
} else if (arg is SByteVL) {
SByteVL a = (SByteVL) arg;
if (a.tag == Tags.BignumTag) {
Reg.Result = Factory.makeBoolean(Number.getBignumLength(a) == 0);
return;
} else if (a.tag == Tags.FlonumTag) {
Reg.Result = Factory.makeBoolean(a.unsafeAsDouble(0) == 0.0);
return;
} else if (a.tag == Tags.CompnumTag) {
Reg.Result = Factory.makeBoolean
(a.unsafeAsDouble(0) == 0.0 &
a.unsafeAsDouble(1) == 0.0);
return;
}
}
Reg.Result = Factory.makeBoolean(false);
return;
}
示例5: ShouldAddArrays
public void ShouldAddArrays()
{
dynamic e = new SObject();
e.Owners = new[] { "Steve", "Bill" };
Assert.That(e.Owners[0], Is.EqualTo("Steve"));
Assert.That(e.Owners[1], Is.EqualTo("Bill"));
}
示例6: Create
public static SObject Create(ScriptProcessor processor, SObject instance, SObject This, SObject[] parameters)
{
Prototype prototype = null;
if (parameters.Length > 0)
{
var protoParam = parameters[0];
if (protoParam.TypeOf() == LITERAL_TYPE_STRING)
{
prototype = processor.Context.GetPrototype(((SString)protoParam).Value);
}
else if (IsPrototype(protoParam.GetType()))
{
prototype = (Prototype)protoParam;
}
else
{
return processor.ErrorHandler.ThrowError(ErrorType.TypeError, ErrorHandler.MESSAGE_REFERENCE_NO_PROTOTYPE, protoParam.TypeOf());
}
}
if (prototype != null)
{
var instParams = new SObject[parameters.Length - 1];
Array.Copy(parameters, 1, instParams, 0, parameters.Length - 1);
return processor.Context.CreateInstance(prototype, instParams);
}
else
{
return processor.ErrorHandler.ThrowError(ErrorType.TypeError, ErrorHandler.MESSAGE_REFERENCE_NO_PROTOTYPE, LITERAL_UNDEFINED);
}
}
示例7: IndexerSet
public static SObject IndexerSet(ScriptProcessor processor, SObject instance, SObject This, SObject[] parameters)
{
var arr = (SArray)instance;
if (parameters.Length >= 2)
{
var accessor = (int)parameters[0].ToNumber(processor).Value;
if (accessor >= 0)
{
if (accessor < arr.ArrayMembers.Length)
{
arr.ArrayMembers[accessor] = parameters[1];
}
else
{
var arrMembers = arr.ArrayMembers;
Array.Resize(ref arrMembers, accessor + 1);
arrMembers[accessor] = parameters[1];
arr.ArrayMembers = arrMembers;
}
}
}
return processor.Undefined;
}
示例8: ShouldAddAnonymousObject
public void ShouldAddAnonymousObject() {
dynamic e = new SObject();
e.Foos = new { Foo1 = "Bar1", Foo2 = "Bar2" };
Assert.That(e.Foos.Foo1, Is.EqualTo("Bar1"));
Assert.That(e.Foos.Foo2, Is.EqualTo("Bar2"));
}
示例9: ToSettings
public static ISItem ToSettings(object o) {
if (o is SValue) {
return (ISItem)o;
}
if (o is SObject) {
return (ISItem)o;
}
if (o is SArray) {
return (ISItem)o;
}
if (o is Array) {
return new SArray((Array)o);
}
if (IsAnonymousType(o.GetType())) {
dynamic grappe = new SObject();
foreach (var p in o.GetType().GetProperties()) {
grappe[p.Name] = p.GetValue(o, null);
}
return grappe;
}
return new SValue(o);
}
示例10: Unbox
/// <summary>
/// Unboxes an <see cref="SVariable"/> if the passed in object is one.
/// </summary>
internal static SObject Unbox(SObject obj)
{
while (obj is SVariable)
obj = ((SVariable)obj).Data;
return obj;
}
示例11: fault
public static CodeAddress fault (int blame, string m,
SObject arg1, SObject arg2, SObject arg3)
{
Reg.Result = arg1;
Reg.Second = arg2;
Reg.Third = arg3;
return Exn.fault (blame, m);
}
示例12: op1_syscall
/* // from <larceny_src>/Lib/Common/malcode.mal:
; Syscall has to be coded in mal because the arguments are passed in a
; non-standard way and because the compiler cannot handle a primitive
; with a variable, large, number of parameters. Syscall is simply a
; trampoline into a millicode procedure. RESULT has the number of
; arguments, and the arguments are passed in registers as usual.
*/
public static void op1_syscall(SObject arg) {
// subtract one 'cuz the first arg is just the value
// to which we want to dispatch.
// System.Console.WriteLine("*** syscall {0}", Reg.register2);
int num_args = ((SFixnum)arg).intValue() - 1;
Sys num_syscall = (Sys) ((SFixnum)Reg.register1).intValue();
Syscall.dispatch(num_args, num_syscall);
}
示例13: ShouldAddDynamicObjects
public void ShouldAddDynamicObjects() {
dynamic e = new SObject();
e.Address = new SObject();
e.Address.Street = "One Microsoft Way";
Assert.That(e["Address"]["Street"], Is.EqualTo("One Microsoft Way"));
Assert.That(e.Address.Street, Is.EqualTo("One Microsoft Way"));
}
示例14: op1_disable_interrupts
public static void op1_disable_interrupts(SObject arg) {
if (Reg.interruptsEnabled) {
Reg.interruptsEnabled = false;
Reg.Result = Factory.makeFixnum((int)Reg.timer);
} else {
Reg.Result = Factory.makeBoolean(false);
}
Exn.checkSignals();
}
示例15: PrototypeMember
public PrototypeMember(string identifier, SObject data, bool isStatic, bool isReadOnly, bool isIndexerGet, bool isIndexerSet)
{
Identifier = identifier;
Data = data;
IsStatic = isStatic;
IsReadOnly = isReadOnly;
IsIndexerGet = isIndexerGet;
IsIndexerSet = isIndexerSet;
}