public async Task ProcessAsyncShouldFailOnVerificationTokenMismatch() { _testOptions.SlackVerificationToken = "testToken"; var slackApi = new Mock <SlackClientWrapper>(_testOptions); slackApi.Setup(x => x.TestAuthAsync(It.IsAny <CancellationToken>())).Returns(Task.FromResult("mockedUserId")); slackApi.Setup(x => x.VerifySignature(It.IsAny <HttpRequest>(), It.IsAny <string>())).Returns(true); var slackAdapter = new SlackAdapter(_testOptions, slackClient: slackApi.Object); var payload = File.ReadAllText(Directory.GetCurrentDirectory() + @"/Files/MessageBody.json"); var stream = new MemoryStream(Encoding.UTF8.GetBytes(payload.ToString())); var httpRequest = new Mock <HttpRequest>(); httpRequest.SetupGet(req => req.Body).Returns(stream); var httpRequestHeader = new Mock <IHeaderDictionary>(); httpRequestHeader.SetupGet(x => x["Content-Type"]).Returns("application/json"); httpRequest.SetupGet(req => req.Headers).Returns(httpRequestHeader.Object); var httpResponse = new Mock <HttpResponse>(); httpResponse.SetupAllProperties(); var mockStream = new Mock <Stream>(); httpResponse.SetupGet(req => req.Body).Returns(mockStream.Object); await Assert.ThrowsAsync <Exception>(async() => { await slackAdapter.ProcessAsync(httpRequest.Object, httpResponse.Object, new Mock <IBot>().Object, default); }); }
/// <summary> /// 获取快递公司 /// </summary> /// <returns></returns> public string GetExpress() { var fileDir = Environment.CurrentDirectory; var result = File.ReadAllText(fileDir + @"\wwwroot\static\js\express.js"); return(result); }
private void RemoveScripts(string path) { //does it contain an export.lua? if (File.Exists(path + "\\Export.lua")) { var contents = File.ReadAllText(path + "\\Export.lua"); if (contents.Contains("SimpleRadioStandalone.lua")) { contents = contents.Replace("dofile(lfs.writedir()..[[Scripts\\DCS-SimpleRadioStandalone.lua]])", ""); contents = contents.Replace( "local dcsSr=require('lfs');dofile(dcsSr.writedir()..[[Scripts\\DCS-SimpleRadioStandalone.lua]])", ""); contents = contents.Trim(); File.WriteAllText(path + "\\Export.lua", contents); } } DeleteFileIfExists(path + "\\DCS-SimpleRadioStandalone.lua"); DeleteFileIfExists(path + "\\DCS-SRSGameGUI.lua"); DeleteFileIfExists(path + "\\DCS-SRS-AutoConnectGameGUI.lua"); DeleteFileIfExists(path + "\\DCS-SRS-Overlay.dlg"); DeleteFileIfExists(path + "\\DCS-SRS-OverlayGameGUI.lua"); DeleteFileIfExists(path + "\\Hooks\\DCS-SRS-Hook.lua"); }
public void ReadsEventsFromRawBufferFiles() { using var tmp = new TempFolder(); var fn = tmp.AllocateFilename("json"); var lines = IOFile.ReadAllText(Path.Combine("Resources", "ThreeBufferedEvents.json.txt"), Encoding.UTF8).Split(new [] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries); using (var f = IOFile.Create(fn)) using (var fw = new StreamWriter(f, Encoding.UTF8)) { foreach (var line in lines) { fw.WriteLine(line); } } var position = new FileSetPosition(0, fn); var count = 0; var payload = PayloadReader.ReadPayload(1000, null, ref position, ref count, out var mimeType); Assert.Equal(SeqIngestionApi.RawEventFormatMediaType, mimeType); Assert.Equal(3, count); Assert.Equal(576 + 3 * (Environment.NewLine.Length - 1), position.NextLineStart); Assert.Equal(fn, position.File); var data = JsonConvert.DeserializeObject <dynamic>(payload); var events = data["Events"]; Assert.NotNull(events); Assert.Equal(3, events.Count); }
public static void Main(string[] args) { if (File.Exists(NLogConfig)) { NLog.LogManager.Configuration = new NLog.Config.XmlLoggingConfiguration(NLogConfig); } MainLog.Trace("Started"); if (!File.Exists(ConfigPath)) { Save(new Config()); MainLog.Trace("Config saved"); return; } if (!File.Exists(DatabasePath)) { File.WriteAllText(DatabasePath, JsonConvert.SerializeObject(Data.Generatator.Generate()), Encoding.UTF8); } DB = JsonConvert.DeserializeObject <Data.Database>(File.ReadAllText(DatabasePath, Encoding.UTF8)); Config = JsonConvert.DeserializeObject <Config>(File.ReadAllText(ConfigPath, Encoding.UTF8)); TelegramBot = new TelegramBotClient(Config.TelegramToken); MLang = MachineLang.MLang.Load(Config.LangBase); AirBot = new AirBotWorker(MLang, TelegramBot, Config, DB); AirBot.Start(); new Thread(() => { while (true) { File.WriteAllText(DatabasePath, JsonConvert.SerializeObject(DB), Encoding.UTF8); Thread.Sleep(10000); } }).Start(); Task.Delay(Timeout.Infinite).Wait(); }
public static async Task <Options> GetOptions() { var solution = await VS.Solutions.GetCurrentSolutionAsync(); var solutionFilePath = solution?.FullPath; if (!File.Exists(solutionFilePath)) { return(new Options()); } var solutionFolder = Path.GetDirectoryName(solutionFilePath); var settingFilePath = Path.Combine(solutionFolder, ".vs", $"{ApplicationName}.json"); var oldSettingFilePath = Path.Combine(solutionFolder, $"{ApplicationName}.json"); if (File.Exists(settingFilePath)) { var json = File.ReadAllText(settingFilePath); return(JsonConvert.DeserializeObject <Options>(json)); } if (File.Exists(oldSettingFilePath)) { var json = File.ReadAllText(oldSettingFilePath); File.Delete(oldSettingFilePath); return(JsonConvert.DeserializeObject <Options>(json)); } return(new Options()); }
private void LaunchInformationDialog(string sourceName) { try { if (informationDialog == null) { informationDialog = new InformationDialog { Height = 500, Width = 400 }; informationDialog.Closed += (o, args) => { informationDialog = null; }; informationDialog.Closing += (o, args) => { }; } informationDialog.Height = 500; informationDialog.Width = 400; var filePath = AppDomain.CurrentDomain.BaseDirectory + @"HelpFiles\" + sourceName + ".html"; var helpFile = File.ReadAllText(filePath); informationDialog.HelpInfo.NavigateToString(helpFile); informationDialog.Launch(); } catch (Exception ex) { LogErrorMessage(ex); } }
public static void WriteMapModels(ARealmReversed realm, TerritoryType teriType) { Territory territory = Plot.StringToWard(teriType.Name); string inpath = FFXIVHSPaths.GetTerritoryJson(territory); if (!File.Exists(inpath)) { throw new FileNotFoundException(); } string outpath = FFXIVHSPaths.GetTerritoryObjectsDirectory(territory); string json = File.ReadAllText(inpath); Map map = JsonConvert.DeserializeObject <Map>(json); foreach (MapModel model in map.models.Values) { if (realm.Packs.TryGetFile(model.modelPath, out SaintCoinach.IO.File f)) { ObjectFileWriter.WriteObjectFile(outpath, (ModelFile)f); } } }
private async void Main_Load(object sender, EventArgs e) { textBox3.Text = File.ReadAllText(Path.Combine(FoldersFilesAndPaths.Logs, Logger.CurrentFile + ".txt")); _writer = new TextBoxStreamWriter(textBox3); Console.SetOut(_writer); LoadSettingsToGui(); metroLabel46.Text = Convert.ToString(await WebUtils.GetCurrentIpAddressAsync()); metroLabel49.Text = Convert.ToString(Settings.PremiumExpiryDate); ProductDatabase.Display(); MyReminder.Display(); LoadChangelogs(); if (Settings.IsPremium) { EnablePremium(); } else { DisablePremium(); } deleteOldLogs(this, null); metroTabControl1.SelectedTab = metroTabPage1; }
private void parseIPFSObjects() { try { if (File.Exists(jsonFilePath)) { File.SetAttributes(jsonFilePath, FileAttributes.Normal); string json = File.ReadAllText(jsonFilePath); File.SetAttributes(jsonFilePath, FileAttributes.Hidden); List <IPFSElement> tempElements = JsonConvert.DeserializeObject <List <IPFSElement> >(json); if (lastElementCount != tempElements.Count) { elements = new ArrayList(tempElements); this.objectListView1.SetObjects(elements); lastElementCount = elements.Count; } } else { new DirectoryInfo(Path.GetDirectoryName(jsonFilePath)).Create(); File.SetAttributes(jsonFilePath, FileAttributes.Normal); File.WriteAllText(jsonFilePath, "[]"); File.SetAttributes(jsonFilePath, FileAttributes.Hidden); } } catch (Exception ex) { Console.WriteLine(ex.ToString()); } }
public async Task ProcessAsyncShouldFailWithSignatureMismatch() { var slackApi = new Mock <SlackClientWrapper>(_testOptions); slackApi.Setup(x => x.TestAuthAsync(It.IsAny <CancellationToken>())).Returns(Task.FromResult("mockedUserId")); slackApi.Setup(x => x.VerifySignature(It.IsAny <HttpRequest>(), It.IsAny <string>())).Returns(false); var slackAdapter = new SlackAdapter(slackApi.Object, _adapterOptions); var payload = File.ReadAllText(Directory.GetCurrentDirectory() + @"/Files/MessageBody.json"); var stream = new MemoryStream(Encoding.UTF8.GetBytes(payload.ToString())); var httpRequest = new Mock <HttpRequest>(); httpRequest.SetupGet(req => req.Body).Returns(stream); var httpResponse = GetHttpResponseMock(); httpResponse.Setup(_ => _.Body.WriteAsync(It.IsAny <byte[]>(), It.IsAny <int>(), It.IsAny <int>(), It.IsAny <CancellationToken>())) .Callback((byte[] data, int offset, int length, CancellationToken token) => { if (length > 0) { var actual = Encoding.UTF8.GetString(data); } }); await Assert.ThrowsAsync <AuthenticationException>(async() => { await slackAdapter.ProcessAsync(httpRequest.Object, httpResponse.Object, new Mock <IBot>().Object, default); }); }
public void Provision(ClientContext ctx, Web web, string manifestJsonFileAbsolutePath) { try { IsHostWeb = !WebHasAppinstanceId(web); Ctx = ctx; Web = web; var json = File.ReadAllText(manifestJsonFileAbsolutePath); //TODO: Deal with fallout from Version problem var manifest = AppManifestBase.GetManifestFromJson(json); manifest.BaseFilePath = !string.IsNullOrEmpty(manifest.BaseFilePath) ? manifest.BaseFilePath : Path.GetDirectoryName(manifestJsonFileAbsolutePath); try { Provision(ctx, web, manifest); } catch (Exception ex) { var newEx = new Exception("Error provisioning to web at " + Web.Url, ex); throw newEx; } } catch (Exception ex) { var newEx = new Exception("Error provisioning to web at " + Web.Url, ex); throw newEx; } }
static JToken LoadJson() { try { string jsonStr = null; try { var path = Path.GetFullPath(Path.Combine(AppContext.BaseDirectory, "..\\..\\..\\..\\..\\", "test_token.json")); jsonStr = File.ReadAllText(path); } catch { var path = Path.GetFullPath(Path.Combine(AppContext.BaseDirectory, "..\\..\\..\\..\\..\\..\\", "test_token.json")); jsonStr = File.ReadAllText(path); } var jToken = JToken.Parse(jsonStr); return(jToken); } catch (Exception ex) { throw new Exception("Wrong token. Please, check 'test_token.json' exists in solution folder.", ex); } }
public async Task ProcessAsyncShouldSucceedWithUnknownEventType() { var slackApi = new Mock <SlackClientWrapper>(_testOptions); slackApi.Setup(x => x.TestAuthAsync(It.IsAny <CancellationToken>())).Returns(Task.FromResult("mockedUserId")); slackApi.Setup(x => x.VerifySignature(It.IsAny <HttpRequest>(), It.IsAny <string>())).Returns(true); var slackAdapter = new SlackAdapter(_testOptions, slackClient: slackApi.Object); var payload = File.ReadAllText(Directory.GetCurrentDirectory() + @"/Files/UnknownEvent.json"); var stream = new MemoryStream(Encoding.UTF8.GetBytes(payload.ToString())); var httpRequest = new Mock <HttpRequest>(); httpRequest.SetupGet(req => req.Body).Returns(stream); var httpRequestHeader = new Mock <IHeaderDictionary>(); httpRequestHeader.SetupGet(x => x["Content-Type"]).Returns("application/json"); httpRequest.SetupGet(req => req.Headers).Returns(httpRequestHeader.Object); var httpResponse = new Mock <HttpResponse>(); httpResponse.SetupAllProperties(); var mockStream = new Mock <Stream>(); httpResponse.SetupGet(req => req.Body).Returns(mockStream.Object); await slackAdapter.ProcessAsync(httpRequest.Object, httpResponse.Object, new Mock <IBot>().Object, default); Assert.Equal(httpResponse.Object.StatusCode, (int)HttpStatusCode.OK); }
public T Load <T>(IObjectSerializer <T> serializer, string path) { string str = File.ReadAllText(path); T item = serializer.Deserialize(str); return(item); }
public IActionResult RunAll(string constellation, string include, string exclude) { HashSet <string> includeSet = null, excludeSet = null; if (!String.IsNullOrEmpty(include)) { includeSet = new HashSet <string>(include.Split(',')); } if (!String.IsNullOrEmpty(exclude)) { excludeSet = new HashSet <string>(exclude.Split(',')); } var packageJson = IOFile.ReadAllText(Path.Combine(_env.ContentRootPath, "package.json")); var model = new RunAllViewModel { Constellation = constellation ?? "", CategoriesList = include, Version = JsonConvert.DeserializeObject <IDictionary>(packageJson)["version"].ToString(), Suites = UIModelHelper.GetAllSuites(HasDeviceModeFlag(), constellation, includeSet, excludeSet) }; AssignBaseRunProps(model); return(View(model)); }
public void SetUp() { Initializer.AllInit(); var dir = new DirectoryInfo(Path.GetDirectoryName( Assembly.GetExecutingAssembly().Location)); while (dir.Name != "bin") { dir = dir.Parent; } dir = dir.Parent; var path = Path.Combine(dir.FullName, "perftsuite.epd"); var file = ""; try { file = File.ReadAllText(path); } catch (Exception e) { throw new FileNotFoundException("Invalid file path"); } perftSuite = file.Split( new[] { Environment.NewLine }, StringSplitOptions.None ); perft = new Perft(); board = new Board(); moveList = new MoveList(); }
private static void TranscodeFile() { const string inputFile = @"c:\Users\Ben\Desktop\Bad Chemistry.flac"; const string outputFile = @"c:\Users\Ben\Desktop\Bad Chemistry.m4a"; const string errorsFile = @"c:\Users\Ben\Desktop\Bad Chemistry.log"; using (TagLib.File metadata = TagLib.File.Create(inputFile)) { TimeSpan duration = metadata.Properties.Duration; long inputFileSize = new FileInfo(inputFile).Length; // var converter = new DMCSCRIPTINGLib.Converter(); string encoder = "m4a FDK (AAC)"; // https://wiki.hydrogenaud.io/index.php?title=Fraunhofer_FDK_AAC#Usage_2 string compressionSettings = @"-cli_cmd=""-m 4 -p 2 --ignorelength -S -o {qt}[outfile]{qt} - """; Stopwatch stopwatch = Stopwatch.StartNew(); // converter.Convert(inputFile, outputFile, encoder, compressionSettings, errorsFile); stopwatch.Stop(); double relativeSpeed = duration.TotalMilliseconds / stopwatch.Elapsed.TotalMilliseconds; long outputFileSize = new FileInfo(outputFile).Length; Console.WriteLine( $"Converted {inputFile} to AAC-LC in {stopwatch.Elapsed.TotalSeconds:N} seconds\n{relativeSpeed:N}x speed\n{(double) outputFileSize / inputFileSize:P} file size\n{((double) inputFileSize - outputFileSize) / 1024 / 1024:N} MB saved"); string errorText = File.ReadAllText(errorsFile); if (string.IsNullOrWhiteSpace(errorText)) { errorText = "no errors"; } Console.WriteLine(errorText); File.Delete(errorsFile); } }
public List <NugetPackageInfo> GetNugetPackageDownloads() { var downloadsFile = $"{this._storageDirectory.EnsureEndsWith("/")}{this._downloadsFile}"; return((List <NugetPackageInfo>)ApplicationContext.Current.ApplicationCache.RuntimeCache.GetCacheItem( "NugetDownloads", () => { var downloads = new List <NugetPackageInfo>(); if (File.Exists(downloadsFile)) { var rawJson = File.ReadAllText(downloadsFile, Encoding.UTF8); if (!string.IsNullOrWhiteSpace(rawJson)) { try { downloads = JsonConvert.DeserializeObject <List <NugetPackageInfo> >(rawJson); } catch { // should we log this } } } return downloads; }, TimeSpan.FromHours(1), false, CacheItemPriority.Normal, null, new[] { downloadsFile })); }
public static void WriteOutHousingExteriorModels(ARealmReversed realm) { string inpath = FFXIVHSPaths.GetHousingExteriorJson(); if (!File.Exists(inpath)) { throw new FileNotFoundException(); } string outpath = FFXIVHSPaths.GetHousingExteriorObjectsDirectory(); string jsonText = File.ReadAllText(inpath); Dictionary <int, HousingExteriorFixture> fixtures = JsonConvert.DeserializeObject <Dictionary <int, HousingExteriorFixture> >(jsonText); foreach (HousingExteriorFixture fixture in fixtures.Values) { foreach (HousingExteriorFixtureVariant variant in fixture.variants) { foreach (HousingExteriorFixtureModel model in variant.models) { if (realm.Packs.TryGetFile(model.modelPath, out SaintCoinach.IO.File f)) { ObjectFileWriter.WriteObjectFile(outpath, (ModelFile)f); } } } } }
public void ReadsEventsFromBufferFiles() { using var tmp = new TempFolder(); var fn = tmp.AllocateFilename("clef"); var lines = IOFile.ReadAllText(Path.Combine("Resources", "ThreeBufferedEvents.clef.txt"), Encoding.UTF8).Split(new [] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries); using (var f = IOFile.Create(fn)) using (var fw = new StreamWriter(f, Encoding.UTF8)) { foreach (var line in lines) { fw.WriteLine(line); } } var position = new FileSetPosition(0, fn); var count = 0; PayloadReader.ReadPayload(1000, null, ref position, ref count, out var mimeType); Assert.Equal(SeqIngestionApi.CompactLogEventFormatMediaType, mimeType); Assert.Equal(3, count); Assert.Equal(465 + 3 * (Environment.NewLine.Length - 1), position.NextLineStart); Assert.Equal(fn, position.File); }
public static void WriteMapModels(ARealmReversed realm, TerritoryType teriType, SaintCoinach.Graphics.Territory teri = null) { string name = teri != null ? teri.Name : teriType.Name; //Plot.Ward ward = Plot.StringToWard(teriType.Name); string outpath = Path.Combine(FFXIVHSPaths.GetRootDirectory(), name, "objects\\"); string inpath = Path.Combine(FFXIVHSPaths.GetRootDirectory(), name + "\\", name + ".json"); if (!Directory.Exists(outpath)) { Directory.CreateDirectory(outpath); } //string inpath = FFXIVHSPaths.GetWardJson(ward); if (!File.Exists(inpath)) { throw new FileNotFoundException(); } //string outpath = FFXIVHSPaths.GetWardObjectsDirectory(ward); string json = File.ReadAllText(inpath); Map map = JsonConvert.DeserializeObject <Map>(json); foreach (MapModel model in map.models.Values) { if (realm.Packs.TryGetFile(model.modelPath, out SaintCoinach.IO.File f)) { ObjectFileWriter.WriteObjectFile(outpath, (ModelFile)f); } } }
private RelationDefinition ReadDefinition() { var versionPath = Path.Combine("thirdparty", "SaintCoinach", "SaintCoinach", "Definitions", "game.ver"); if (!File.Exists(versionPath)) { throw new InvalidOperationException("Definitions\\game.ver must exist."); } var version = File.ReadAllText(versionPath).Trim(); var def = new RelationDefinition() { Version = version }; foreach (var sheetFileName in Directory.EnumerateFiles(Path.Combine("thirdparty", "SaintCoinach", "SaintCoinach", "Definitions"), "*.json")) { var json = File.ReadAllText(Path.Combine(sheetFileName), Encoding.UTF8); var obj = JsonConvert.DeserializeObject <Newtonsoft.Json.Linq.JObject>(json); var sheetDef = SheetDefinition.FromJson(obj); def.SheetDefinitions.Add(sheetDef); if (!_GameData.SheetExists(sheetDef.Name)) { var msg = $"Defined sheet {sheetDef.Name} is missing."; Debug.WriteLine(msg); Console.WriteLine(msg); } } return(def); }
/// <summary> /// Initializes a new instance of the <see cref="ARealmReversed" /> class. /// </summary> /// <param name="gameDirectory">Directory of the game installation.</param> /// <param name="storeFile">File used for storing definitions and history.</param> /// <param name="language">Initial language to use.</param> /// <param name="libraFile">Location of the Libra Eorzea database file, or <c>null</c> if it should not be used.</param> public ARealmReversed(DirectoryInfo gameDirectory, FileInfo storeFile, Language language, FileInfo libraFile) { // Fix for being referenced in a .Net Core 2.1+ application (https://stackoverflow.com/questions/50449314/ibm437-is-not-a-supported-encoding-name => https://stackoverflow.com/questions/44659499/epplus-error-reading-file) // PM> dotnet add package System.Text.Encoding.CodePages Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); _GameDirectory = gameDirectory; _Packs = new PackCollection(Path.Combine(gameDirectory.FullName, "game", "sqpack")); _GameData = new XivCollection(Packs, libraFile) { ActiveLanguage = language }; _GameVersion = File.ReadAllText(Path.Combine(gameDirectory.FullName, "game", "ffxivgame.ver")); _StateFile = storeFile; _GameData.Definition = ReadDefinition(); using (ZipFile zipFile = new ZipFile(StateFile.FullName, ZipEncoding)) { if (!zipFile.ContainsEntry(VersionFile)) { Setup(zipFile); } } _GameData.Definition.Compile(); }
public void Load() { try { if (File.Exists(Common.SettingsPath)) { Directory.CreateDirectory(Path.GetDirectoryName(Common.SettingsPath) ?? ""); var json = File.ReadAllText(Common.SettingsPath); AppSettings localAppsettings = JsonConvert.DeserializeObject <AppSettings>(json); var config = new MapperConfiguration(cfg => { cfg.CreateMap <AppSettings, AppSettings>(); }); IMapper iMapper = config.CreateMapper(); iMapper.Map(localAppsettings, Settings); } else { Log.Debug("First time starting application. Creating save files"); Save(); } } catch (Exception e) { Log.Error("Could not load settings." + e.Message + e.StackTrace); } }
public void ContextMenuEncrypt() { PublicVar.openFileName = Path.GetFileName(args[1]); if (!args[1].Contains(".cnp")) { string opnfile = File.ReadAllText(args[1]); string NameWithotPath = Path.GetFileName(args[1]); customRTB.Text = opnfile; this.Text = appName + NameWithotPath; string cc2 = customRTB.Text.Length.ToString(CultureInfo.InvariantCulture); customRTB.Select(Convert.ToInt32(cc2), 0); currentFilename = Path.GetFileName(args[1]); filePath = OpenFile.FileName; } #region workaround, strange behavior with the cursor in customRTB fix customRTB.DetectUrls = false; customRTB.DetectUrls = true; customRTB.Modified = false; #endregion if (PublicVar.okPressed == true) { PublicVar.okPressed = false; } }
private ConnectionInfo GetConnectionInfo(string organizationId, string serverUrl, string deviceUuid) { ConnectionInfo connectionInfo; var connectionInfoPath = Path.Combine(InstallPath, "ConnectionInfo.json"); if (FileIO.Exists(connectionInfoPath)) { connectionInfo = Serializer.Deserialize <ConnectionInfo>(FileIO.ReadAllText(connectionInfoPath)); connectionInfo.ServerVerificationToken = null; } else { connectionInfo = new ConnectionInfo() { DeviceID = Guid.NewGuid().ToString() }; } if (!string.IsNullOrWhiteSpace(deviceUuid)) { // Clear the server verification token if we're installing this as a new device. if (connectionInfo.DeviceID != deviceUuid) { connectionInfo.ServerVerificationToken = null; } connectionInfo.DeviceID = deviceUuid; } connectionInfo.OrganizationID = organizationId; connectionInfo.Host = serverUrl; return(connectionInfo); }
private static void CreateProjectInfo(string path, string name, List <string> fileNames) { var filePath = Path.Combine(path, name + "." + "csproj"); var csFilesPath = Path.Combine(path, "Files", "cs"); List <string> refs = GetRefs(csFilesPath, fileNames); var descriptorPath = Path.Combine(path, "descriptor.json"); string descriptorContent = File.ReadAllText(descriptorPath); JsonObject jsonDoc = (JsonObject)JsonObject.Parse(descriptorContent); string maintainer = jsonDoc["Descriptor"]["Maintainer"]; var depends = new List <string>(); foreach (var depend in jsonDoc["Descriptor"]["DependsOn"]) { var curName = depend.ToString().Split("\": \"")[1].Split("\"")[0]; depends.Add(curName); } CreateFromTpl(GetTplPath(CreatioPackage.EditProjTpl), filePath, name, fileNames, maintainer, refs, depends); var propertiesDirPath = Path.Combine(path, "Properties"); Directory.CreateDirectory(propertiesDirPath); var propertiesFilePath = Path.Combine(propertiesDirPath, "AssemblyInfo.cs"); CreateFromTpl(GetTplPath(CreatioPackage.AssemblyInfoTpl), propertiesFilePath, name, new List <string>(), maintainer, refs, depends); var packagesConfigFilePath = Path.Combine(path, "packages.config"); CreateFromTpl(GetTplPath(CreatioPackage.PackageConfigTpl), packagesConfigFilePath, name, new List <string>(), maintainer, refs, depends); }
void OnValidate() { if (!import) { return; } import = false; var liveRemotePath = RemotePath + @"\lives\" + liveName; var liveLocalPath = LocalPath + @"\lives\" + liveName + ".json"; string liveJson = File.ReadAllText(liveRemotePath); Debug.Log(liveJson); File.WriteAllText(liveLocalPath, liveJson); var live = JsonUtility.FromJson <ApiLiveResponse>(liveJson).content; Debug.Log(live.live_name); var mapRemotePath = RemotePath + @"\maps\" + live.map_path; var mapLocalPath = LocalPath + @"\maps\" + live.map_path; string mapJson = ApiLiveMap.Transform(File.ReadAllText(mapRemotePath)); File.WriteAllText(mapLocalPath, mapJson); var bgmRemotePath = RemotePath + @"\bgms\" + live.bgm_path; var bgmLocalPath = LocalPath + @"\bgms\" + live.bgm_path; byte[] bgmBytes = File.ReadAllBytes(bgmRemotePath); File.WriteAllBytes(bgmLocalPath, bgmBytes); }
private Diff GetRevisionDiff(string pathForComparer, int revision) { Diff diff = new Diff(); SVNManager.GetInfo((res) => { int currentRevision = 0; string[] splits = res.Split(new string[] { "\n" }, System.StringSplitOptions.RemoveEmptyEntries); foreach (string s in splits) { if (s.StartsWith("Last Changed Rev: ", StringComparison.Ordinal)) { currentRevision = int.Parse(s.Replace("Last Changed Rev: ", "")); } if (s.StartsWith("Revision:", StringComparison.Ordinal)) { currentRevision = int.Parse(s.Replace("Revision: ", "")); } } SVNManager.GetFileInRevision(revision, pathForComparer.Replace("\\", "/").Replace(PathHelper.GetRepoPath().Replace("\\", "/") + "/", ""), (cont) => { diff.current = IOFile.ReadAllText(pathForComparer); diff.requested = cont; }); }); return(diff); }