using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ToRemObjects
{
public class TestClass
{
double m;
public double testProperty
{
get
{
return m;
}
set
{
m = value;
}
}
}
public class RemObjectsConsole
{
Dictionary<object, object> bag = new Dictionary<object, object>();
public RemObjectsConsole()
{
}
public double propDouble
{
get { return 1.2D; }
set { Console.WriteLine("propDouble:{0}", value); }
}
public double getDouble()
{
return 1.3D;
}
public void writeDouble(double value)
{
Console.WriteLine("writeDouble:{0}", value);
}
public double getDateAsDouble()
{
return 1357908756.0D;
}
public int getDateAsInt()
{
return 1357908756;
}
public int propInt
{
get { return 150; }
set { Console.WriteLine("propInt:{0}", value); }
}
public int getInt()
{
return 150;
}
public void writeInt(int value)
{
Console.WriteLine("writeInt:{0}", value);
}
public string propString
{
get { return "string.value"; }
set { Console.WriteLine("propString:{0}", (value == null ? "<<null>>" : value)); }
}
public void writeString(string value)
{
Console.WriteLine("writeString:{0}", (value == null ? "<<null>>" : value));
}
public string getString()
{
return "My get string...";
}
public bool propBoolean
{
get { return true; }
set { Console.WriteLine("propBoolean:{0}", value); }
}
public void writeBoolean(bool value)
{
Console.WriteLine("writeBoolean:{0}", value);
}
public bool getBoolean()
{
return true;
}
public DateTime propDate
{
get { return new DateTime(1974, 1, 1); }
set { Console.WriteLine("propDate:{0}", value); }
}
public void writeDate(DateTime value)
{
Console.WriteLine("writeDate:{0}", value);
}
public DateTime getDate()
{
return new DateTime(1974, 1, 1);
}
public object propObject
{
get { return this; }
set { Console.WriteLine("propObject:{0}:{1}", (null == value ? "<<null>>" : value.GetType().Name), (null == value ? "<<null>>" : value)); }
}
public void writeObject(object value)
{
Console.WriteLine("writeObject:{0}:{1}", (null == value ? "<<null>>" : value.GetType().Name), (null == value ? "<<null>>" : value));
}
public override string ToString()
{
return "My Console.ToString to string ...";
}
public void load(string commandText, params object[] parameters)
{
// do somting...
int i = 0;
}
public void load2(string commandText, object[] parameters)
{
// do somting...
int i = 0;
}
public void loadStrings(params string[] parameters)
{
// do somting...
int i = 0;
}
public void loadDoubles(params double[] parameters)
{
// do somting...
int i = 0;
}
public void loadStrings2(string[] parameters)
{
// do somting...
int i = 0;
}
public object this[string name]
{
get
{
object value;
bag.TryGetValue(name, out value);
return value;
}
set
{
bag[name] = value;
}
}
public object this[int index]
{
get
{
object value;
bag.TryGetValue(index.ToString(), out value);
return value;
}
set
{
bag[index.ToString()] = value;
}
}
public void ThrowException()
{
throw new ApplicationException("test exception ....");
}
}
class Program
{
static void Main(string[] args)
{
using (var esc = new RemObjects.Script.EcmaScriptComponent())
{
esc.Include("test1", @"
function testPropBoolean(cc) {
/*
If the Boolean object has no initial value, or if the passed value is one of the following:
0,-0,null,’’,false,undefined,NaN
the object is set to false. For any other value it is set to true (even with the string ‘false’)!
*/
var o = {};
cc.propBoolean = new Boolean(o);
cc.propBoolean = o;//Exception:Object must implement IConvertible.
}
");
RemObjectsConsole cc = new RemObjectsConsole();
var o = esc.RunFunction("testPropBoolean", cc);
Console.ReadLine();
}
}
}
}