public static JSBCollection FromCollection(IEnumerable collection) { JSBCollection col = new JSBCollection(); foreach (object obj in collection) { col.Collection.Add(JSBObject.FromAnonymous(obj)); } return(col); }
public static JSBObject FromObject(object obj) { JSBObject o = new JSBObject(); foreach (PropertyInfo p in obj.GetType().GetProperties()) { o.AddObject(p.Name, p.GetValue(obj)); } return(o); }
public override string BuildCode(int indented = 0) { StringBuilder b = new StringBuilder(); b.Append(JSBuilder.GetIndented(indented)); b.Append(VariableName); b.Append(" = "); if (!IsValueType) { b.Append(((JSBObject)VariableValue).BuildCode(indented)); } else { b.Append(JSBObject.BuildValue(VariableValue, indented)); } b.Append(";"); return(b.ToString()); }
public JSBAssignOperation(string name, object obj) { Type = JSBOperations.Asignment; VariableName = name; Type t = obj.GetType(); if (!t.IsObject()) { VariableValue = obj; IsValueType = true; } else if (obj.GetType() != typeof(JSBObject)) { VariableValue = JSBObject.FromAnonymous(obj); } else { VariableValue = (JSBObject)obj; } }
public string BuildCode(int indented = 0) { StringBuilder builder = new StringBuilder(); builder.Append("["); int i = 0; foreach (object obj in Collection) { builder.Append(JSBObject.BuildValue(obj, indented)); if (i < Collection.Count - 1) { builder.Append(", "); } i++; } builder.Append("]"); return(builder.ToString()); }