Beispiel #1
0
 public static Panel LoadControl(DSTDContext context, string location,string class_, string id)
 {
     CompileDSTD d = CompileDSTD.CompileDSTDPanel(context, location, class_, id);
     if (d.Compiled==null)
         return null;
     return (Panel) d.Compiled;
 }
Beispiel #2
0
        public static CompileDSTD CompileDSTDPanel(DSTDContext context, string location, string class_, string id)
        {
            CompileDSTD d = new CompileDSTD();

            d.Context = context;
            XmlDocument doc = new XmlDocument();
            doc.Load(location + ".dstdp");
            d.Location = location.Substring(0, location.LastIndexOf("\\"));

            d.Location += d.Location.EndsWith("\\") ? "" : "\\";
            if (context.myServer.GetTypeFromString(class_) == null)
            {
                return d;
            }

            d.panel = (Panel)context.myServer.GetTypeFromString(class_).GetConstructor(new[] { typeof(string) }).Invoke(new object[] { id });

            Control nn = d.getControlFromNode(doc.FirstChild);

            if (nn.id!="")
              d. panel.id = nn.id;
            if (nn.Style != "")
                d.panel.Style = nn.Style;
            if (nn.Value != "")
                d.panel.Value = nn.Value;

            foreach (XmlNode n in doc.FirstChild.ChildNodes)
            {
                d.panel.Children.Add(d.CompileXML(n));
            }
            d.Compiled = d.panel;
            return d;
        }
Beispiel #3
0
 public DSTDRequest(DSTDContext that, DSTDQuery q, XmlDocument state, Page.GetApplication p)
 {
     Context = that;
     State = state;
     Query = q;
     getApplication = p;
     Page h;
     if (File.Exists(Context.myServer.localDirectory + Query.File.TrimStart('/') + ".dstd")) {
         CompileDSTD compile = CompileDSTD.CompileDSTDPage(Context, Context.myServer.localDirectory + Query.File.TrimStart('/'), Query.File.TrimStart('/'));
         h = (Page)compile.Compiled;
     }
     else {
         return;
     }
     h.UserQuery = q.UserQuery;
     CurrentPage = h;
 }
Beispiel #4
0
        public static CompileDSTD CompileDSTDPage(DSTDContext context, string location, string class_)
        {
            CompileDSTD d=new CompileDSTD();

            d.Context = context;
            XmlDocument doc = new XmlDocument();
            doc.Load(location + ".dstd");
            d.Location = location.Substring(0, location.LastIndexOf("\\"));
            d.Location += d.Location.EndsWith("\\") ? "" : "\\";

            d.page = (Page)context.myServer.GetTypeFromString.Invoke(class_).GetConstructor(Type.EmptyTypes).Invoke(null);

            foreach (XmlNode n in doc.FirstChild.ChildNodes)
            {
                d.page.Children.Add(d.CompileXML(n));
            }
            d.Compiled = d.page;
            return d;
        }
Beispiel #5
0
        private void ReadHeader(Socket sock, DSTDData ds)
        {
            string d = ds.sb.ToString();
            if (d.Contains("<top>") && !d.Contains("</top>"))
                d += "</top>";

            DSTDQuery q = new DSTDQuery(DSTDContext.getURL(d));

            if (q.File.TrimStart('/')=="favicon.ico")
                return;

            localDirectory = Directory.GetCurrentDirectory() + "\\";
            if (File.Exists(localDirectory + q.File.TrimStart('/'))) {
                StreamReader sr = new StreamReader(File.OpenRead(localDirectory + q.File.TrimStart('/')));
                writeBack(sr.ReadToEnd(), sock);
                sr.Close();
                return;
            }
            //K:\My Applications\Sals\WebServer\WebServer\
            if (File.Exists(@"" + q.File.TrimStart('/'))) {
                StreamReader sr = new StreamReader(File.OpenRead(@"" + q.File.TrimStart('/')));
                writeBack(sr.ReadToEnd(), sock);
                sr.Close();
                return;
            }

            DSTDContext context = new DSTDContext(this,ds.sb.ToString(), GrabSession, SetSession, GrabApplication);
            string str = context.Request.CurrentPage.OnRender();

            string ty = "";
            if (context.Request.CurrentPage.PanelToUpdate != "" || !context.Request.CurrentPage.FullRender )
                ty = "text/xml";
            else
                ty = "text/html";

            context.SetSession(context.Request.CurrentPage.CurrentGUID, context.Request.CurrentPage.Session, context.Request.CurrentPage.GetPrivateSession());

            string s = GetHeader(str.Length, "200", ty);
            s += str;
            writeBack(s, sock);
            ds.Start.Stop();
            average += ds.Start.Elapsed.TotalMilliseconds;
            averagecount++;
            Console.WriteLine(ds.Start.Elapsed.TotalMilliseconds.ToString() + "       " + (average / averagecount));
        }