public static ApiRequestCommand GetCommand(IApplicationReader reader, String path) { var parts = path.Split('/'); // dir/dir/dir/acton/{id}; int len = parts.Length; if (len < 2) { throw new ApiV2Exception($"invalid path: {path}"); } var p1 = String.Join("/", new ArraySegment <String>(parts, 0, len - 1)); String id = null; String action = null; String relPath = $"_apiv2/{p1}"; String filePath = reader.MakeFullPath(relPath, "model.json"); if (!reader.FileExists(filePath)) { // try to read with id if (len < 3) { throw new ApiV2Exception($"invalid path: {path}"); } p1 = String.Join("/", new ArraySegment <String>(parts, 0, len - 2)); relPath = $"_apiv2/{p1}"; filePath = reader.MakeFullPath(relPath, "model.json"); id = parts[len - 1]; if (!reader.FileExists(filePath)) { throw new ApiV2Exception($"path not found: {path}"); } action = parts[len - 2]; } else { action = parts[len - 1]; } var json = reader.FileReadAllText(filePath); var rm = JsonConvert.DeserializeObject <ApiV2RequestModel>(json, JsonHelpers.CamelCaseSerializerSettings); if (rm == null) { throw new ApiV2Exception($"invalid model.json"); } rm.SetParent(); if (rm.Commands.TryGetValue(action, out ApiRequestCommand cmd)) { cmd.SetId(id); cmd.SetPath(relPath); return(cmd); } throw new ApiV2Exception($"command '{action}' not found"); }
public Stream GetStream(IApplicationReader reader) { if (!String.IsNullOrEmpty(ReportPath)) { return(reader.FileStreamFullPathRO(ReportPath)); } else if (ReportStream != null) { return(new MemoryStream(ReportStream)); } throw new InvalidOperationException("Invalid report stream mode"); }
public void StartApplication(Boolean bAdmin) { var file = ZipApplicationFile; String key = bAdmin ? "admin" : AppKey; if (file != null) { _reader = new ZipApplicationReader(AppPath, key); } else { _reader = new FileApplicationReader(AppPath, key); } }
public bool DeleteReader(IApplicationReader reader) { if (reader == null) { throw new ArgumentNullException(); } if (ReaderExists(reader)) { Readers.Remove(reader); return(true); } else { return(false); } }
public bool AddReader(IApplicationReader reader) { if (reader == null) { throw new ArgumentNullException(); } if (!ReaderExists(reader.Login)) { Readers.Add(reader); return(true); } else { return(false); } }
static void CreateReader() { var file = ZipApplicationFileName(CurrentAppPath, CurrentAppKey); String key = CurrentAppKey; if (file != null) { _reader = new ZipApplicationReader(CurrentAppPath, key); } else { _reader = new FileApplicationReader(CurrentAppPath, key) { EmulateBox = true } }; }
IEnumerable <String> ReadLines(IApplicationReader reader, String path) { using (var stream = reader.FileStreamFullPathRO(path)) { using (var rdr = new StreamReader(stream)) { while (!rdr.EndOfStream) { var s = rdr.ReadLine(); if (String.IsNullOrEmpty(s) || s.StartsWith(";")) { continue; } yield return(s); } } } }
public void StartApplication(Boolean bAdmin) { var file = ZipApplicationFile; String key = bAdmin ? "admin" : AppKey; if (file != null) { _reader = new ZipApplicationReader(AppPath, key); } else if (AppPath.StartsWith("db:")) { throw new NotImplementedException("DbApplicationReader"); } else { _reader = new FileApplicationReader(AppPath, key); } }
public void AddBook(IApplicationReader user, string title, string author) { if (String.IsNullOrEmpty(title) || String.IsNullOrEmpty(author)) { throw new ArgumentNullException(); } if (title == null || author == null) { throw new ArgumentNullException(); } if (!ReaderExists(user)) { throw new Exception(); } var newBook = new Book(user, title, author); user.BookCollection.Add(newBook); Books.Add(newBook); }
public ExecuteJavaScriptCommand(IJavaScriptEngine engine, IApplicationReader reader) { _engine = engine; _reader = reader; }
public void StartApplication(Boolean bAdmin) { _appReader = new FileApplicationReader(AppPath, AppKey); }
public ApplicationsController(IApplicationWriter applicationWriter, IApplicationReader applicationReader) { writer = applicationWriter; reader = applicationReader; }
public TypeChecker(IApplicationReader reader, String path) { _reader = reader; _path = path; }
public Book(IApplicationReader user, string title, string author) { Title = title; Author = author; }
public void Render(RenderInfo info) { if (String.IsNullOrEmpty(info.FileName)) { throw new XamlException("No source for render"); } IProfileRequest request = _profile.CurrentRequest; String fileName = String.Empty; UIElementBase uiElem = null; using (request.Start(ProfileAction.Render, $"load: {info.FileTitle}")) { try { // XamlServices.Load sets IUriContext if (!String.IsNullOrEmpty(info.FileName)) { using (var fileStream = _host.ApplicationReader.FileStreamFullPath(info.FileName)) { RootFileName = info.FileName; ApplicationReader = _host.ApplicationReader; uiElem = XamlServices.Load(fileStream) as UIElementBase; } } else if (!String.IsNullOrEmpty(info.Text)) { uiElem = XamlServices.Parse(info.Text) as UIElementBase; } else { throw new XamlException("Xaml. There must be either a 'FileName' or a 'Text' property"); } if (uiElem == null) { throw new XamlException("Xaml. Root is not 'UIElement'"); } using (var stylesStream = _host.ApplicationReader.FileStream(String.Empty, "styles.xaml")) { if (stylesStream != null) { if (!(XamlServices.Load(stylesStream) is Styles styles)) { throw new XamlException("Xaml. Styles is not 'Styles'"); } if (uiElem is RootContainer root) { root.Styles = styles; root?.OnSetStyles(); } } } } finally { RootFileName = null; ApplicationReader = null; } } using (request.Start(ProfileAction.Render, $"render: {info.FileTitle}")) { RenderContext ctx = new RenderContext(uiElem, info) { RootId = info.RootId, Path = info.Path }; if (info.SecondPhase) { if (!(uiElem is ISupportTwoPhaseRendering twoPhaseRender)) { throw new XamlException("The two-phase rendering is not available"); } twoPhaseRender.RenderSecondPhase(ctx); } else { uiElem.RenderElement(ctx); } Grid.ClearAttached(); Splitter.ClearAttached(); FullHeightPanel.ClearAttached(); Toolbar.ClearAttached(); } if (uiElem is IDisposable disp) { disp.Dispose(); } }
public TSDefParser(IApplicationReader reader, String path) { _reader = reader; _path = path; _mm = new ModelMetadata(); }
public AppVersions(String dbConnectionString, IApplicationReader reader) { _reader = reader; _cnnString = dbConnectionString; }