internal static void Patch <T>(this IPass <T> self, T item) { if (self.ShouldPatch(item)) { self.ApplyPatch(item); } }
public void PassStarted(IPass pass) { if (pass == null) { throw new ArgumentNullException(nameof(pass)); } logger.Info(pass.Name + " pass"); OnPassStarted.Fire(pass); }
public async Task <bool> Update(IPass newPassword) { var keys = Keys.FromSeed(UserNameData.Key, newPassword); var isValid = await ValidateKeys(keys); keys.Dispose(); if (isValid) { password?.Dispose(); password = newPassword; }
public void Reset() { #if BY_PASS password?.Dispose(); password = null; #elif BY_WIF wif?.Dispose(); wif = null; #else #endif }
public static Keys FromSeed(string userName, IPass password) { var keys = new Dictionary <AuthorityClassification, KeyPair>(); var roles = new[] { AuthorityClassification.Active, AuthorityClassification.Echorand }; foreach (var role in roles) { keys[role] = new KeyPair(role, userName, password, EDDSA.KeyFactory.Create()); } return(new Keys(keys)); }
public void TestStartingPass() { EventData <IPass> .OnEvent onEvent = Substitute.For <EventData <IPass> .OnEvent>(); progress.OnPassStarted.Add(onEvent); IPass pass1 = Substitute.For <IPass>(); pass1.Name.Returns(":SOME_PASS"); progress.PassStarted(pass1); logger.Received().Log(LogType.Log, ":SOME_PASS pass"); onEvent.Received()(pass1); }
public KeyPair(AuthorityClassification role, string userName, IPass password, IPrivateKeyFactory factory) { var buffer = new ByteBuffer(ByteBuffer.LITTLE_ENDING); var data = Encoding.UTF8.GetBytes(userName.Trim()); buffer.WriteBytes(data, false); data.Clear(); data = GetRoleData(role); buffer.WriteBytes(data, false); data.Clear(); data = password.Get(); buffer.WriteBytes(data, false); data.Clear(); var seed = buffer.ToArray(); buffer.Dispose(); privateKey = factory.FromSeed(seed); seed.Clear(); }
private void ApplyPatches(LinkedList <IProtoUrlConfig> databaseConfigs, IPass pass) { progress.PassStarted(pass); foreach (IPatch patch in pass) { try { patch.Apply(databaseConfigs, progress, logger); if (patch.CountsAsPatch) { progress.PatchApplied(); } } catch (Exception e) { progress.Exception(patch.UrlConfig, "Exception while processing node : " + patch.UrlConfig.SafeUrl(), e); logger.Error("Processed node was\n" + patch.UrlConfig.PrettyPrint()); } } }
public void Add(IPass pass) { var passInfo = new PassInfo(); // Get the dependencies pass.SetPassInfo(ref passInfo); var tuple = Tuple.Create(pass, passInfo); if (passInfo.Dependencies != null) { // We could be more sophisticatd here and try to optimise // the list of passes so we don't run redundant analyses // Leave this for now // The pass has Dependencies so Add them // It is not safe to iterate over a dictionary and modify it // at the same time so do it in two stages. // 1. Collect all the KeyValue Pairs in the dictionary // 2. Iterate over the collected KeyValue pairs and modify the dictionary var depList = new List <KeyValuePair <System.Type, IPass> >(); foreach (var keyValuePair in passInfo.Dependencies) { depList.Add(keyValuePair); } foreach (var keyValuePair in depList) { // Create dependency. This requires that the pass has a default constructor IPass dependencyOfPass = Activator.CreateInstance(keyValuePair.Key) as IPass; passInfo.Dependencies[keyValuePair.Key] = dependencyOfPass; // Do this recursively so we handle any dependencies of the dependencies (of the...)* Add(dependencyOfPass); } } Passes.Add(tuple); }
private void ApplyPatches(IEnumerable <UrlDir.UrlFile> configFiles, IPass pass) { logger.Info(pass.Name + " pass"); Activity = "ModuleManager " + pass.Name; foreach (IPatch patch in pass) { try { foreach (UrlDir.UrlFile file in configFiles) { patch.Apply(file, progress, logger); } progress.PatchApplied(); } catch (Exception e) { progress.Exception(patch.UrlConfig, "Exception while processing node : " + patch.UrlConfig.SafeUrl(), e); logger.Error("Processed node was\n" + patch.UrlConfig.PrettyPrint()); } } }
static void Main(string[] args) { IPass card = new IPass(); StudentIPass s_card = new StudentIPass(); int distance; // 距離 //hallo Console.WriteLine(card.CardType); for (distance = 1; distance < 31; distance++) { Console.WriteLine(distance + "km->" + card.pay(distance)); } Console.WriteLine(s_card.CardType); for (distance = 1; distance < 31; distance = distance + 1) { Console.WriteLine(distance + "km->" + s_card.pay(distance)); } Console.ReadKey(); }
private IPromise <AuthorizationResult> AuthorizationBy(UserNameFullAccountDataPair dataPair, IPass password)
public IPromise <AuthorizationResult> AuthorizationBy(string userName, IPass password)
public PassManagerEventArgs(IPass pass, Program program) { ThePass = pass; TheProgram = program; }
/// <summary> /// Adds a new render pass to this technique /// </summary> /// <param name="pass"> The pass to add </param> public void Add( IPass pass ) { Arguments.CheckNotNull( pass, "pass" ); m_Passes.Add( pass ); }
public AuthorizationData(UserNameFullAccountDataPair userNameData, IPass password) { this.password = password;
/// <summary> /// Specifies a list of arguments which are to be passed to the procedure. The parameter values have to be passed in the order of parameters as declared in the procedure. /// </summary> /// <param name="prev">A predecessor object.</param> /// <param name="arguments">Are the arguments to pass.</param> public static PassChainer Pass(this IPass prev, params ParameterArgument[] arguments) { return(new PassChainer((Chainer)prev, arguments)); }
/// <summary> /// /// </summary> /// <param name="pass"></param> /// <param name="index"></param> public void InsertPass(IPass pass, int index) { this.passes.Insert(index, pass); }
/// <summary> /// /// </summary> /// <param name="pass"></param> public void AddPass(IPass pass) { this.passes.Add(pass); }
private IPromise <AuthorizationResult> AuthorizationBy(uint id, IPass password)
public void TestApplyPatches() { IBasicLogger logger = Substitute.For <IBasicLogger>(); IPatchProgress progress = Substitute.For <IPatchProgress>(); PatchApplier patchApplier = new PatchApplier(progress, logger); IPass pass1 = Substitute.For <IPass>(); IPass pass2 = Substitute.For <IPass>(); IPass pass3 = Substitute.For <IPass>(); pass1.Name.Returns(":PASS1"); pass2.Name.Returns(":PASS2"); pass3.Name.Returns(":PASS3"); UrlDir.UrlConfig[] patchUrlConfigs = new UrlDir.UrlConfig[9]; IPatch[] patches = new IPatch[9]; for (int i = 0; i < patches.Length; i++) { patches[i] = Substitute.For <IPatch>(); } patches[0].CountsAsPatch.Returns(false); patches[1].CountsAsPatch.Returns(false); patches[2].CountsAsPatch.Returns(false); patches[3].CountsAsPatch.Returns(true); patches[4].CountsAsPatch.Returns(true); patches[5].CountsAsPatch.Returns(true); patches[6].CountsAsPatch.Returns(true); patches[7].CountsAsPatch.Returns(true); patches[8].CountsAsPatch.Returns(true); pass1.GetEnumerator().Returns(new ArrayEnumerator <IPatch>(patches[0], patches[1], patches[2])); pass2.GetEnumerator().Returns(new ArrayEnumerator <IPatch>(patches[3], patches[4], patches[5])); pass3.GetEnumerator().Returns(new ArrayEnumerator <IPatch>(patches[6], patches[7], patches[8])); IPass[] patchList = new IPass[] { pass1, pass2, pass3 }; LinkedList <IProtoUrlConfig> databaseConfigs = Assert.IsType <LinkedList <IProtoUrlConfig> >(patchApplier.ApplyPatches(new[] { pass1, pass2, pass3 })); progress.DidNotReceiveWithAnyArgs().Error(null, null); progress.DidNotReceiveWithAnyArgs().Exception(null, null); progress.DidNotReceiveWithAnyArgs().Exception(null, null, null); logger.AssertNoWarning(); logger.AssertNoError(); logger.AssertNoException(); Received.InOrder(delegate { progress.PassStarted(pass1); patches[0].Apply(databaseConfigs, progress, logger); patches[1].Apply(databaseConfigs, progress, logger); patches[2].Apply(databaseConfigs, progress, logger); progress.PassStarted(pass2); patches[3].Apply(databaseConfigs, progress, logger); progress.PatchApplied(); patches[4].Apply(databaseConfigs, progress, logger); progress.PatchApplied(); patches[5].Apply(databaseConfigs, progress, logger); progress.PatchApplied(); progress.PassStarted(pass3); patches[6].Apply(databaseConfigs, progress, logger); progress.PatchApplied(); patches[7].Apply(databaseConfigs, progress, logger); progress.PatchApplied(); patches[8].Apply(databaseConfigs, progress, logger); progress.PatchApplied(); }); }
public void TestApplyPatches() { IBasicLogger logger = Substitute.For <IBasicLogger>(); IPatchProgress progress = Substitute.For <IPatchProgress>(); PatchApplier patchApplier = new PatchApplier(progress, logger); UrlDir.UrlFile file1 = UrlBuilder.CreateFile("abc/def.cfg"); UrlDir.UrlFile file2 = UrlBuilder.CreateFile("ghi/jkl.cfg"); IPass pass1 = Substitute.For <IPass>(); IPass pass2 = Substitute.For <IPass>(); IPass pass3 = Substitute.For <IPass>(); pass1.Name.Returns(":PASS1"); pass2.Name.Returns(":PASS2"); pass3.Name.Returns(":PASS3"); UrlDir.UrlConfig[] patchUrlConfigs = new UrlDir.UrlConfig[9]; IPatch[] patches = new IPatch[9]; for (int i = 0; i < patches.Length; i++) { patches[i] = Substitute.For <IPatch>(); } pass1.GetEnumerator().Returns(new ArrayEnumerator <IPatch>(patches[0], patches[1], patches[2])); pass2.GetEnumerator().Returns(new ArrayEnumerator <IPatch>(patches[3], patches[4], patches[5])); pass3.GetEnumerator().Returns(new ArrayEnumerator <IPatch>(patches[6], patches[7], patches[8])); IPass[] patchList = new IPass[] { pass1, pass2, pass3 }; patchApplier.ApplyPatches(new[] { file1, file2 }, new[] { pass1, pass2, pass3 }); progress.DidNotReceiveWithAnyArgs().Error(null, null); progress.DidNotReceiveWithAnyArgs().Exception(null, null); progress.DidNotReceiveWithAnyArgs().Exception(null, null, null); logger.DidNotReceive().Log(LogType.Warning, Arg.Any <string>()); logger.DidNotReceive().Log(LogType.Error, Arg.Any <string>()); logger.DidNotReceiveWithAnyArgs().Exception(null, null); Received.InOrder(delegate { logger.Log(LogType.Log, ":PASS1 pass"); patches[0].Apply(file1, progress, logger); patches[0].Apply(file2, progress, logger); progress.PatchApplied(); patches[1].Apply(file1, progress, logger); patches[1].Apply(file2, progress, logger); progress.PatchApplied(); patches[2].Apply(file1, progress, logger); patches[2].Apply(file2, progress, logger); progress.PatchApplied(); logger.Log(LogType.Log, ":PASS2 pass"); patches[3].Apply(file1, progress, logger); patches[3].Apply(file2, progress, logger); progress.PatchApplied(); patches[4].Apply(file1, progress, logger); patches[4].Apply(file2, progress, logger); progress.PatchApplied(); patches[5].Apply(file1, progress, logger); patches[5].Apply(file2, progress, logger); progress.PatchApplied(); logger.Log(LogType.Log, ":PASS3 pass"); patches[6].Apply(file1, progress, logger); patches[6].Apply(file2, progress, logger); progress.PatchApplied(); patches[7].Apply(file1, progress, logger); patches[7].Apply(file2, progress, logger); progress.PatchApplied(); patches[8].Apply(file1, progress, logger); patches[8].Apply(file2, progress, logger); progress.PatchApplied(); }); }