/// <summary> /// Sets the current <see cref = "Head" /> to the specified commit and optionally resets the <see cref = "Index" /> and /// the content of the working tree to match. /// </summary> /// <param name = "resetOptions">Flavor of reset operation to perform.</param> /// <param name = "shaOrReferenceName">The sha or reference canonical name of the target commit object.</param> public void Reset(ResetOptions resetOptions, string shaOrReferenceName) { Ensure.ArgumentNotNullOrEmptyString(shaOrReferenceName, "shaOrReferenceName"); if (resetOptions.Has(ResetOptions.Mixed) && Info.IsBare) { throw new LibGit2Exception("Mixed reset is not allowed in a bare repository"); } var commit = LookupCommit(shaOrReferenceName); //TODO: Check for unmerged entries string refToUpdate = Info.IsHeadDetached ? "HEAD" : Head.CanonicalName; Refs.UpdateTarget(refToUpdate, commit.Sha); if (resetOptions == ResetOptions.Soft) { return; } Index.ReplaceContentWithTree(commit.Tree); if (resetOptions == ResetOptions.Mixed) { return; } throw new NotImplementedException(); }
public static int Run(ILogger logger, ResetOptions options) { try { logger.LogInformation($"Try to reset \"{AppSettings.DatabaseName}\" database"); SettingsUpdate.Run(logger, options);//@"localhost\sqlexpress", "Test", "5432", "sysad", "admin"); if (Drop.Run(logger) > 0) { throw new Exception("There was some errors with dropping database"); } if (Create.Run(logger) > 0) { throw new Exception("There was some errors with creating database"); } if (Migrate.Run(logger) > 0) { throw new Exception("There was some errors with migrating database"); } logger.LogInformation($"{AppSettings.DatabaseName} database successfully reseted"); return(0); } catch (Exception exception) { logger.LogError(exception.Message); return(1); } }
public void ResetInstance_should_honor_options(ResetOptions resetOptions, bool shouldResetNoCleanField, bool shouldResetReadonlyField, bool shouldResetNoCleanProperty, bool shouldResetNoCleanReadonlyField, bool shouldResetField, bool shouldDispose) { var noCleanField = new Mock <IDisposable>(); var readonlyField = new Mock <IDisposable>(); var noCleanProperty = new Mock <IDisposable>(); var noCleanReadonlyField = new Mock <IDisposable>(); var field = new Mock <IDisposable>(); var current = new Options.Current( noCleanField.Object, readonlyField.Object, noCleanProperty.Object, noCleanReadonlyField.Object, field.Object ); StateCleaner.ResetInstance(current, HierarchyOptions.All, VisibilityOptions.All, resetOptions); Assert.That(current.NoCleanField == null, Is.EqualTo(shouldResetNoCleanField)); noCleanField.Verify(d => d.Dispose(), Times.Exactly(shouldResetNoCleanField && shouldDispose ? 1 : 0)); Assert.That(current.ReadonlyField == null, Is.EqualTo(shouldResetReadonlyField)); readonlyField.Verify(d => d.Dispose(), Times.Exactly(shouldResetReadonlyField && shouldDispose ? 1 : 0)); Assert.That(current.NoCleanProperty == null, Is.EqualTo(shouldResetNoCleanProperty)); noCleanProperty.Verify(d => d.Dispose(), Times.Exactly(shouldResetNoCleanProperty && shouldDispose ? 1 : 0)); Assert.That(current.NoCleanReadonlyField == null, Is.EqualTo(shouldResetNoCleanReadonlyField)); noCleanReadonlyField.Verify(d => d.Dispose(), Times.Exactly(shouldResetNoCleanReadonlyField && shouldDispose ? 1 : 0)); Assert.That(current.Field == null, Is.EqualTo(shouldResetField)); field.Verify(d => d.Dispose(), Times.Exactly(shouldResetField && shouldDispose ? 1 : 0)); }
public ResetWork(ResetOptions opts_in) { opts = opts_in; AzureServiceFactory.Init(opts.WorkerCount); folderDoneSet = AzureServiceFactory.GetFolderDoneSet(); LargeFilesQueue = AzureServiceFactory.GetLargeFilesQueue(); }
/// <summary> /// Sets the current <see cref="Head"/> to the specified commit and optionally resets the <see cref="Index"/> and /// the content of the working tree to match. /// </summary> /// <param name = "resetOptions">Flavor of reset operation to perform.</param> /// <param name = "shaOrReferenceName">The sha or reference canonical name of the target commit object.</param> public void Reset(ResetOptions resetOptions, string shaOrReferenceName) { Ensure.ArgumentNotNullOrEmptyString(shaOrReferenceName, "shaOrReferenceName"); if (resetOptions.Has(ResetOptions.Mixed) && Info.IsBare) { throw new LibGit2Exception("Mixed reset is not allowed in a bare repository"); } GitObject commit = Lookup(shaOrReferenceName, GitObjectType.Any, LookUpOptions.ThrowWhenNoGitObjectHasBeenFound | LookUpOptions.DereferenceResultToCommit | LookUpOptions.ThrowWhenCanNotBeDereferencedToACommit); //TODO: Check for unmerged entries string refToUpdate = Info.IsHeadDetached ? "HEAD" : Head.CanonicalName; Refs.UpdateTarget(refToUpdate, commit.Sha); if (resetOptions == ResetOptions.Soft) { return; } Index.ReplaceContentWithTree(((Commit)commit).Tree); if (resetOptions == ResetOptions.Mixed) { return; } throw new NotImplementedException(); }
private void ResetColor(ResetOptions resetOption) { if (resetOption == ResetOptions.Zero) { if (fadeChildren) { for (int i = 0; i < graphics.Length; i++) { graphics[i].color = new Color(initialColorsOfChildren[i].r, initialColorsOfChildren[i].g, initialColorsOfChildren[i].b, 0); } } else { // because the index 0 is for the componet on this game object. graphics[0].color = new Color(initialColorsOfChildren[0].r, initialColorsOfChildren[0].g, initialColorsOfChildren[0].b, 0); } } else if (resetOption == ResetOptions.One) { if (fadeChildren) { for (int i = 0; i < graphics.Length; i++) { graphics[i].color = initialColorsOfChildren[i]; } } else { graphics[0].color = initialColorsOfChildren[0]; } } }
/// <summary> /// Sets the current <see cref="Repository.Head"/> to the specified commit and optionally resets the <see cref="Index"/> and /// the content of the working tree to match. /// </summary> /// <param name="repository">The <see cref="Repository"/> being worked with.</param> /// <param name="resetOptions">Flavor of reset operation to perform.</param> /// <param name="committish">A revparse spec for the target commit object.</param> public static void Reset(this IRepository repository, ResetOptions resetOptions, string committish = "HEAD") { Ensure.ArgumentNotNullOrEmptyString(committish, "committish"); Commit commit = LookUpCommit(repository, committish); repository.Reset(resetOptions, commit); }
/// <summary> /// Sets the current <see cref="Head"/> to the specified commit and optionally resets the <see cref="Index"/> and /// the content of the working tree to match. /// </summary> /// <param name="resetOptions">Flavor of reset operation to perform.</param> /// <param name="commit">The target commit object.</param> public void Reset(ResetOptions resetOptions, Commit commit) { Ensure.ArgumentNotNull(commit, "commit"); Proxy.git_reset(handle, commit.Id, resetOptions); Refs.Log(Refs.Head).Append(commit.Id, string.Format("reset: moving to {0}", commit.Sha)); }
private void ResetScale(ResetOptions resetOption) { if (resetOption == ResetOptions.Zero) { transform.localScale = Vector3.zero; } else if (resetOption == ResetOptions.One) { transform.localScale = initialScale; } }
public static int Run( ILogger logger, DatabaseConnectionSettings appsettings, ResetOptions options, DepartmentService departmentService ) { try { bool databaseInitialized = appsettings != null; if (databaseInitialized) { logger.LogInformation($"Try to reset \"{appsettings.DatabaseName}\" database"); } else { logger.LogInformation($"Try to initialize project database"); } SettingsUpdate.Run(logger, appsettings, options); appsettings = JsonConvert.DeserializeObject <DatabaseConnectionSettings>(File.ReadAllText(Path.Combine(Directory.GetCurrentDirectory(), "appsettings.json"))); if (databaseInitialized) { if (Drop.Run(logger, appsettings) > 0) { throw new Exception("There was some errors with dropping database"); } } if (Create.Run(logger, appsettings) > 0) { throw new Exception("There was some errors with creating database"); } if (MigrateUp.Run(logger, appsettings) > 0) { throw new Exception("There was some errors with migrating database"); } if (Seed.Run(logger, departmentService) > 0) { throw new Exception("There was some errors with migrating database"); } logger.LogInformation($"{appsettings.DatabaseName} database successfully reseted"); return(0); } catch (Exception exception) { logger.LogError(exception.Message); return(1); } }
private void ResetRotation(ResetOptions resetOption, bool show) { if (resetOption == ResetOptions.Zero) { transform.rotation = initialRotation; } else if (resetOption == ResetOptions.One && show) { transform.rotation = Quaternion.Euler(rotateFrom); } else if (resetOption == ResetOptions.One && !show) { transform.rotation = Quaternion.Euler(rotateTo); } }
static async Task <int> RunResetAndReturnExitCode(ResetOptions opts) { CancellationTokenSource tokenSource = new CancellationTokenSource(); var locoClient = new LocoClient(); locoClient.Log += (sender, args) => { Console.WriteLine(args.Log); }; await locoClient.ConnectAsync(tokenSource.Token); await locoClient.SendResetAsync(opts.RoadNumber, tokenSource.Token); return(0); }
private static async Task <int> Main(string[] args) { try { ResetOptions options = null; var parserResult = Parser.Default.ParseArguments <ResetOptions>(args) .WithParsed <ResetOptions>(parsedOptions => options = parsedOptions); if (parserResult.Tag == ParserResultType.NotParsed) { return(-1); } return(await OnReset(options)); } catch (Exception ex) { Console.WriteLine("Error: player data reset failed"); Console.WriteLine(ex.Message); return(-1); } }
private static bool RunReset(ResetOptions opts) { Storage.Wipe(); return true; }
/// <summary> /// Resets state of specified instance fields/auto-properties to their defaults (null for classes, default value for structs). /// If given instance field implements IDisposable interface, it would be disposed before reset. /// /// It is possible to control which fields/auto-properties would be cleaned with hierarchy, visibility and reset options. /// </summary> /// <typeparam name="T">Target type.</typeparam> /// <param name="target">Target instance to be reset.</param> /// <param name="hierarchyOptions">Options controlling which members would be cleaned, depending on which type in type hierarchy they belongs to.</param> /// <param name="visibilityOptions">Options controlling which members would be cleaned, depending on their visibility flags.</param> /// <param name="resetOptions">An additional reset options.</param> public static void ResetInstance <T>(T target, HierarchyOptions hierarchyOptions = HierarchyOptions.All, VisibilityOptions visibilityOptions = VisibilityOptions.All, ResetOptions resetOptions = ResetOptions.None) where T : class { if (target == null) { return; } Debug.WriteLine(string.Format("Resetting instance of: {0}", target.GetType())); foreach (var field in GetAllFields(target, typeof(T), hierarchyOptions) .Where(f => IsApplicable(f, visibilityOptions, resetOptions))) { if ((resetOptions & ResetOptions.DoNotDispose) == 0) { DisposeField(field, target); } ResetField(field, target); } }
private static bool CheckNoAutoCleanFilter(MemberInfo member, ResetOptions resetOptions) { return(resetOptions.IsSet(ResetOptions.OverruleNoAutoClean) || member.GetCustomAttributes(typeof(NoAutoCleanAttribute), true).Length == 0); }
private static bool IsApplicable(FieldInfo field, VisibilityOptions visibility, ResetOptions resetOptions) { if (visibility == 0) { throw new ArgumentException("VisibilityOptions are not specified."); } if (IsBackendField(field)) { var propertyInfo = ExtractPropertyForBackendField(field); if (!CheckMethodVisibility(propertyInfo.GetSetMethod(true), visibility)) { return(false); } if (!CheckNoAutoCleanFilter(propertyInfo, resetOptions)) { return(false); } } else { if (!CheckFieldVisibility(field, visibility)) { return(false); } if (!CheckReadonlyFilter(field, resetOptions)) { return(false); } if (!CheckNoAutoCleanFilter(field, resetOptions)) { return(false); } } return(true); }
static int RunReset(ILogger logger, Appsettings appsettings, ResetOptions options) => Reset.Run(logger, appsettings, options);
private static bool CheckReadonlyFilter(FieldInfo field, ResetOptions resetOptions) { return(!field.IsInitOnly || resetOptions.IsSet(ResetOptions.IncludeReadOnlyMembers)); }
public static int ResetHandler(ResetOptions opts) { Database.Reset(); return(0); }
public void Reset(string sha, ResetOptions resetOptions) { _repository.Reset(resetOptions, sha); }
private static bool RunReset(ResetOptions opts) { Storage.Wipe(); return(true); }
/// <summary> /// Sets the current <see cref = "Head" /> to the specified commit and optionally resets the <see cref = "Index" /> and /// the content of the working tree to match. /// </summary> /// <param name = "resetOptions">Flavor of reset operation to perform.</param> /// <param name = "commit">The target commit object.</param> public void Reset(ResetOptions resetOptions, Commit commit) { Ensure.ArgumentNotNull(commit, "commit"); Proxy.git_reset(handle, commit.Id, resetOptions); }
public void Reset(ResetOptions resetOptions, Commit commit) { throw new System.NotImplementedException(); }
private static async Task <int> OnReset(ResetOptions options) { string xuid = string.Empty; if (options == null) { Console.WriteLine("Unknown parameter error"); return(-1); } if (!string.IsNullOrEmpty(options.TestAccount)) { TestAccount testAccount = await ToolAuthentication.SignInTestAccountAsync(options.TestAccount, options.Sandbox); if (testAccount == null) { Console.Error.WriteLine($"Failed to log in to test account {options.TestAccount}."); return(-1); } xuid = testAccount.Xuid; Console.WriteLine($"Using Test account {options.TestAccount} ({testAccount.Gamertag}) with xuid {xuid}"); } else if (!string.IsNullOrEmpty(options.XboxUserId)) { DevAccount account = ToolAuthentication.LoadLastSignedInUser(); if (account == null) { Console.Error.WriteLine("Resetting by XUID requires a signed in Partner Center account. Please use \"XblDevAccount.exe signin\" to log in."); return(-1); } xuid = options.XboxUserId; Console.WriteLine($"Using Dev account {account.Name} from {account.AccountSource}"); } Console.WriteLine($"Resetting data for player with XUID {xuid} for SCID {options.ServiceConfigurationId} in sandbox {options.Sandbox}"); try { UserResetResult result = await PlayerReset.ResetPlayerDataAsync( options.ServiceConfigurationId, options.Sandbox, xuid); switch (result.OverallResult) { case ResetOverallResult.Succeeded: Console.WriteLine("Player data has been reset successfully."); return(0); case ResetOverallResult.CompletedError: Console.WriteLine("An error occurred while resetting player data:"); if (!string.IsNullOrEmpty(result.HttpErrorMessage)) { Console.WriteLine($"\t{result.HttpErrorMessage}"); } PrintProviderDetails(result.ProviderStatus); return(-1); case ResetOverallResult.Timeout: Console.WriteLine("Player data reset has timed out:"); PrintProviderDetails(result.ProviderStatus); return(-1); default: Console.WriteLine("An unknown error occurred while resetting player data."); return(-1); } } catch (HttpRequestException ex) { Console.WriteLine("Error: player data reset failed"); if (ex.Message.Contains(Convert.ToString((int)HttpStatusCode.Unauthorized))) { Console.WriteLine( $"Unable to authorize the account with Xbox Live and scid : {options.ServiceConfigurationId} and sandbox : {options.Sandbox}, please contact your administrator."); } else if (ex.Message.Contains(Convert.ToString((int)HttpStatusCode.Forbidden))) { Console.WriteLine( "Your account doesn't have access to perform the operation, please contact your administrator."); } else { Console.WriteLine(ex.Message); } return(-1); } }
static int RunReset(ILogger logger, ResetOptions options) => Reset.Run(logger, options);
static int RunReset(ILogger logger, DatabaseConnectionSettings appsettings, ResetOptions options, DepartmentService departmentService) => Reset.Run(logger, appsettings, options, departmentService);
private static async Task <int> OnReset(ResetOptions options) { if (options == null) { Console.WriteLine("Unknown parameter error"); return(-1); } DevAccount account = ToolAuthentication.LoadLastSignedInUser(); if (account == null) { Console.Error.WriteLine("Didn't found dev sign in info, please use \"XblDevAccount.exe signin\" to initiate."); return(-1); } Console.WriteLine($"Using Dev account {account.Name} from {account.AccountSource}"); Console.WriteLine($"Resetting player {options.XboxUserId} data for scid {options.ServiceConfigurationId}, sandbox {options.Sandbox}"); try { UserResetResult result = await PlayerReset.ResetPlayerDataAsync( options.ServiceConfigurationId, options.Sandbox, options.XboxUserId); switch (result.OverallResult) { case ResetOverallResult.Succeeded: Console.WriteLine("Resetting has completed successfully."); return(0); case ResetOverallResult.CompletedError: Console.WriteLine("Resetting has completed with some error:"); if (!string.IsNullOrEmpty(result.HttpErrorMessage)) { Console.WriteLine($"\t{result.HttpErrorMessage}"); } PrintProviderDetails(result.ProviderStatus); return(-1); case ResetOverallResult.Timeout: Console.WriteLine("Resetting has timed out:"); PrintProviderDetails(result.ProviderStatus); return(-1); default: Console.WriteLine("has completed with unknown error"); return(-1); } } catch (HttpRequestException ex) { Console.WriteLine("Error: player data reset failed"); if (ex.Message.Contains(Convert.ToString((int)HttpStatusCode.Unauthorized))) { Console.WriteLine( $"Unable to authorize the account with XboxLive service with scid : {options.ServiceConfigurationId} and sandbox : {options.Sandbox}, please contact your administrator."); } else if (ex.Message.Contains(Convert.ToString((int)HttpStatusCode.Forbidden))) { Console.WriteLine( "Your account doesn't have access to perform the operation, please contact your administrator."); } else { Console.WriteLine(ex.Message); } return(-1); } }
internal static extern int git_reset( RepositorySafeHandle repo, GitObjectSafeHandle target, ResetOptions reset_type);
public static int ResetHandler(ResetOptions opts) { Database.Reset(); return 0; }