Beispiel #1
0
        private void ExportI1(XElement x, bool isRoot = false)
        {
            XElement xCur = isRoot ? x : new XElement("i", new XAttribute("n", this.name));

            var tmp = JsLib.GetField(this._manifest, "attr");

            if (tmp.IsNumber && (((int)tmp) & 0x0C) != 0 && this._state.Exists)
            {
                xCur.Add(new XAttribute("s", JsLib.Stringify(this._state)));
            }
            tmp = JsLib.GetField(this._manifest, "version");
            string  vs;
            Version v;

            if (tmp.ValueType == JSC.JSValueType.String && !string.IsNullOrEmpty(vs = tmp.Value as string) && vs.StartsWith("¤VR") && Version.TryParse(vs.Substring(3), out v))
            {
                tmp = JsLib.Clone(this._manifest);
                tmp.DeleteProperty("version");
                xCur.Add(new XAttribute("m", JsLib.Stringify(tmp)));
                if (!isRoot)
                {
                    xCur.Add(new XAttribute("ver", v.ToString()));
                }
            }
            else
            {
                xCur.Add(new XAttribute("m", JsLib.Stringify(this._manifest)));
            }
            if (isRoot)
            {
                var now = DateTime.Now;
                xCur.Add(new XAttribute("ver", (new Version(0, 4, (now.Year % 100) * 100 + now.Month, now.Day * 1000 + (int)(now.TimeOfDay.TotalDays * 1000)).ToString())));
            }
            else
            {
                x.Add(xCur);
            }
            if (this._children != null)
            {
                var ch = this._children.ToArray();
                for (int i = 0; i < ch.Length; i++)
                {
                    var tt = ch[i].GetAsync(null);
                    tt.Wait();
                    if (tt.IsCompleted && !tt.IsFaulted && tt.Result != null)
                    {
                        tt.Result.ExportI1(xCur);
                    }
                }
            }
        }