示例#1
0
        public static JSBCollection FromCollection(IEnumerable collection)
        {
            JSBCollection col = new JSBCollection();

            foreach (object obj in collection)
            {
                col.Collection.Add(JSBObject.FromAnonymous(obj));
            }
            return(col);
        }
示例#2
0
        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);
        }
示例#3
0
        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());
        }
示例#4
0
        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;
            }
        }
示例#5
0
        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());
        }