internal protected CompilationArchiveBase AddArchive1()
		{
			if (InternalArchive1 == null)
			{
				InternalArchive1 = new CompilationArchiveBaseTemplate { DeclaringCompilation = this };
			}

			return InternalArchive1;
		}
Пример #2
0
        internal protected CompilationArchiveBase AddArchive1()
        {
            if (InternalArchive1 == null)
            {
                InternalArchive1 = new CompilationArchiveBaseTemplate {
                    DeclaringCompilation = this
                };
            }

            return(InternalArchive1);
        }
        private void RenderAssemblies(
            CompilationArchiveBase archive,
            IHTMLElement parent,
            Func<string, IHTMLDiv> AllTypes,
            Action<string> UpdateLocation,
            Action<Action<Action>> YieldLoadAction)
        {
            var Assemblies = archive.GetAssemblies();

            foreach (var Assembly in Assemblies)
            {
                Console.WriteLine(new { Assembly.Name });

            }

            var q = from a in Assemblies
                    where a.Name.StartsWith("ScriptCoreLib")
                    orderby a.Name
                    select a;

            // limit to only first one for speedup

            foreach (var item2 in q.Take(1))
            {
                var item = item2;

                var div = new IHTMLDiv().AttachTo(parent);

                div.style.marginTop = "0.1em";
                div.style.fontFamily = ScriptCoreLib.JavaScript.DOM.IStyle.FontFamilyEnum.Verdana;
                div.style.whiteSpace = ScriptCoreLib.JavaScript.DOM.IStyle.WhiteSpaceEnum.nowrap;


                var i = new Assembly().AttachTo(div);

                i.style.verticalAlign = "middle";
                i.style.marginRight = "0.5em";

                var s = new IHTMLAnchor { innerText = item2.Name }.AttachTo(div);

                //s.style.color = JSColor.Gray;

                s.href = "#";
                s.style.textDecoration = "none";
                s.style.color = JSColor.System.GrayText;

                Action onclick = delegate
                {

                };

                s.onclick +=
                    e =>
                    {
                        e.PreventDefault();

                        s.focus();

                        UpdateLocation(item.Name);

                        onclick();
                    };

                s.onfocus +=
                    delegate
                    {

                        s.style.backgroundColor = JSColor.System.Highlight;
                        s.style.color = JSColor.System.HighlightText;
                    };

                s.onblur +=
                    delegate
                    {

                        s.style.backgroundColor = JSColor.None;
                        s.style.color = JSColor.System.WindowText;
                    };

                var NamespaceLookup = new Dictionary<string, IHTMLDiv>();

                Func<IHTMLDiv, CompilationType, IHTMLDiv> GetNamespaceContainer =
                    (Container, SourceType) =>
                    {
                        if (!NamespaceLookup.ContainsKey(SourceType.Namespace))
                        {
                            NamespaceLookup[SourceType.Namespace] = null;

                            var NextNamespaceOrDefault = default(IHTMLDiv);

                            //var NextNamespaceOrDefault = NamespaceLookup.Keys.OrderBy(k => k).SkipWhile(k => k == SourceType.Namespace).Select(k => NamespaceLookup[k]).FirstOrDefault();

                            NamespaceLookup[SourceType.Namespace] = AddNamespace(Container, NextNamespaceOrDefault, SourceType.Namespace, UpdateLocation);
                        }

                        return NamespaceLookup[SourceType.Namespace];
                    };


                var children = new IHTMLDiv().AttachTo(div);

                children.style.paddingLeft = "1em";
                Action<Action> LoadAction =
                    done =>
                    {
                        Console.WriteLine("enter LoadAction");

                        s.style.color = JSColor.System.Highlight;

                        Action done_ = delegate
                        {
                            done();
                        };



                        item.WhenReady(
                            a =>
                            {
                                Console.WriteLine("enter WhenReady");

                                s.style.color = JSColor.System.WindowText;

                                Console.WriteLine("before GetTypes ToArray");
                                var TypesArray = a.GetTypes().ToArray();


                                //Console.WriteLine("before TypesByName");

                                //var TypesByName = TypesArray.OrderBy(k => k.Name);

                                //Console.WriteLine("before TypesByName ToArray");
                                //// chokes on android?
                                //var TypesByNameArray = TypesByName.ToArray();

                                //Console.WriteLine("before ForEach");

                                TypesArray.ForEach(
                                    (Current, Index, Next) =>
                                    {
                                        Console.WriteLine("AddType");

                                        if (!Current.IsNested)
                                        {
                                            AddType(
                                                GetNamespaceContainer(children, Current),
                                                Current,
                                                UpdateLocation
                                            );

                                            AddType(
                                                AllTypes(Current.Namespace),
                                                Current,
                                                UpdateLocation
                                            );
                                        }


                                        if (Index % 8 == 0)
                                        {
                                            ScriptCoreLib.Shared.Avalon.Extensions.AvalonSharedExtensions.AtDelay(
                                                7,
                                                Next
                                            );
                                        }
                                        else
                                        {
                                            Next();
                                        }
                                    }
                                )(done_);

                                Console.WriteLine("exit WhenReady");

                            }
                        );
                    };

                Console.WriteLine("before YieldLoadAction");
                YieldLoadAction(LoadAction);
                Console.WriteLine("after YieldLoadAction");


                var NextClickHide = default(Action);
                var NextClickShow = default(Action);

                NextClickHide =
                    delegate
                    {
                        children.Hide();

                        onclick = NextClickShow;
                    };

                NextClickShow =
                    delegate
                    {
                        children.Show();

                        onclick = NextClickHide;
                    };


                NextClickHide();
            }
        }