Exemple #1
0
        static void Main(string[] args)
        {
            var webBuilder = Statik.GetWebBuilder();

            webBuilder.RegisterMvcServices();
            webBuilder.RegisterMvc("/hello", new
            {
                controller = "Example",
                action     = "Index",
                other      = 1 /* You can pass other values to the action, traditional MVC */
            });

            using (var host = webBuilder.BuildWebHost())
            {
                host.Listen();
                Console.WriteLine($"Listening on port {StatikDefaults.DefaultPort}...");
                Console.WriteLine($"Try visiting http://localhost:{StatikDefaults.DefaultPort}/hello");
                Console.WriteLine("Press enter to exit...");
                Console.ReadLine();

                // NOTE: You can export this host to a directory.
                // Useful for GitHub pages, etc.
                // await Statik.ExportHost(host, "./somewhere");
            }
        }
Exemple #2
0
        static void Main(string[] args)
        {
            var webBuilder = Statik.GetWebBuilder();

            webBuilder.RegisterMvcServices();

            var pagesDirectory = Path.Combine(Directory.GetCurrentDirectory(), "pages");

            var rootTreeItem = Statik.GetPageDirectoryLoader().LoadFiles(new PhysicalFileProvider(pagesDirectory),
                                                                         "*.md",
                                                                         "index.md");

            void RegisterTreeItem(PageTreeItem <IFileInfo> treeItem)
            {
                if (!treeItem.Data.IsDirectory)
                {
                    webBuilder.RegisterMvc(treeItem.Path,
                                           new
                    {
                        controller = "Pages",
                        action     = "Index",
                        treeItem
                    });
                }

                foreach (var child in treeItem.Children)
                {
                    RegisterTreeItem(child);
                }
            }

            RegisterTreeItem(rootTreeItem);

            using (var host = webBuilder.BuildWebHost())
            {
                host.Listen();
                Console.WriteLine($"Listening on port {StatikDefaults.DefaultPort}...");
                Console.WriteLine($"Try visiting http://localhost:{StatikDefaults.DefaultPort}/hello");
                Console.WriteLine("Press enter to exit...");
                Console.ReadLine();
            }
        }
Exemple #3
0
        static void Main(string[] args)
        {
            var webBuilder = Statik.GetWebBuilder();

            webBuilder.Register("/hello", async context =>
            {
                await context.Response.WriteAsync($"The time is {DateTime.Now.ToLongTimeString()}");
            });

            using (var host = webBuilder.BuildWebHost())
            {
                host.Listen();
                Console.WriteLine($"Listening on port {StatikDefaults.DefaultPort}...");
                Console.WriteLine($"Try visiting http://localhost:{StatikDefaults.DefaultPort}/hello");
                Console.WriteLine("Press enter to exit...");
                Console.ReadLine();

                // NOTE: You can export this host to a directory.
                // Useful for GitHub pages, etc.
                // await Statik.ExportHost(host, "./somewhere");
            }
        }
 public PageDirectoryLoaderTests()
 {
     _pageDirectoryLoader = Statik.GetPageDirectoryLoader();
     _directory           = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, Guid.NewGuid().ToString());
     Directory.CreateDirectory(_directory);
 }
Exemple #5
0
        public object Convert(object value, System.Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (parameter == null || parameter.ToString() == "1")
            {
                var data = (PacketProp)(value as TextBlock).DataContext;
                return(data.CustomValue != null ? data.CustomValue : data.ValueS);
            }
            if (value is Image)
            {
                var imgC = value as Image;

                var data = (PacketProp)(value as Image).DataContext;

                #region Player
                if ((data.PType == EPacketPropType.INT || data.PType == EPacketPropType.UINT) && parameter.ToString() == "2")
                { // Player
                    if (data.PType == EPacketPropType.INT && data.Value != null)
                    {
                        if (Statik.Players.Where(x => x.netid == (int)data.Value).Count() > 0)
                        {
                            var img = Statik.getIcon(Statik.Players.Where(x => x.netid == (int)data.Value).FirstOrDefault());
                            if (img != null)
                            {
                                imgC.Source = img;
                            }
                            return(Visibility.Visible);
                        }
                        else
                        {
                            return(Visibility.Collapsed);
                        }
                    }


                    if (data.PType == EPacketPropType.UINT && data.Value != null)
                    {
                        if (Statik.Players.Where(x => x.netid == (uint)data.Value).Count() > 0)
                        {
                            var img = Statik.getIcon(Statik.Players.Where(x => x.netid == (uint)data.Value).FirstOrDefault());
                            if (img != null)
                            {
                                imgC.Source = img;
                            }
                            return(Visibility.Visible);
                        }
                        else
                        {
                            return(Visibility.Collapsed);
                        }
                    }
                }
                #endregion

                #region Spell
                if ((data.PType == EPacketPropType.INT || data.PType == EPacketPropType.UINT) && parameter.ToString() == "3")
                { // Spell
                    if (data.PType == EPacketPropType.INT && data.Value != null)
                    {
                        if (Statik.Spells.Where(x => x.HashID == (int)data.Value).Count() > 0)
                        {
                            return(Visibility.Visible);
                        }
                        else
                        {
                            return(Visibility.Collapsed);
                        }
                    }
                    if (data.PType == EPacketPropType.UINT && data.Value != null)
                    {
                        if (Statik.Spells.Where(x => x.HashID == (uint)data.Value).Count() > 0)
                        {
                            return(Visibility.Visible);
                        }
                        else
                        {
                            return(Visibility.Collapsed);
                        }
                    }
                }
                #endregion

                #region Item
                if ((data.PType == EPacketPropType.INT || data.PType == EPacketPropType.UINT || data.PType == EPacketPropType.Short) && parameter.ToString() == "4")
                { // Item
                    if (data.PType == EPacketPropType.INT && data.Value != null)
                    {
                        if (Statik.Items.Where(x => x.ItemID == (int)data.Value).Count() > 0)
                        {
                            var img = Statik.getIcon(Statik.Items.Where(x => x.ItemID == (int)data.Value).FirstOrDefault());
                            if (img != null)
                            {
                                imgC.Source = img;
                            }
                            return(Visibility.Visible);
                        }
                        else
                        {
                            return(Visibility.Collapsed);
                        }
                    }
                    if (data.PType == EPacketPropType.UINT && data.Value != null)
                    {
                        if (Statik.Items.Where(x => x.ItemID == (uint)data.Value).Count() > 0)
                        {
                            var img = Statik.getIcon(Statik.Items.Where(x => x.ItemID == (uint)data.Value).FirstOrDefault());
                            if (img != null)
                            {
                                imgC.Source = img;
                            }
                            return(Visibility.Visible);
                        }
                        else
                        {
                            return(Visibility.Collapsed);
                        }
                    }
                    if (data.PType == EPacketPropType.Short && data.Value != null)
                    {
                        if (Statik.Items.Where(x => x.ItemID == (short)data.Value).Count() > 0)
                        {
                            var img = Statik.getIcon(Statik.Items.Where(x => x.ItemID == (short)data.Value).FirstOrDefault());
                            if (img != null)
                            {
                                imgC.Source = img;
                            }
                            return(Visibility.Visible);
                        }
                        else
                        {
                            return(Visibility.Collapsed);
                        }
                    }
                }
                #endregion

                return(Visibility.Collapsed);
            }
            return(null);
        }