public void Diff( [Argument( Name = "KV-STORE", Description = KVStoreArgumentDescription)] string kvStoreUri, [Argument( Name = "STATE-ROOT-HASH", Description = "The state root hash to compare.")] string stateRootHashHex, [Argument( Name = "OTHER-KV-STORE", Description = KVStoreArgumentDescription)] string otherKvStoreUri, [Argument( Name = "OTHER-STATE-ROOT-HASH", Description = "Another state root hash to compare.")] string otherStateRootHashHex, [FromService] IConfigurationService <ToolConfiguration> configurationService) { ToolConfiguration toolConfiguration = configurationService.Load(); kvStoreUri = ConvertKVStoreUri(kvStoreUri, toolConfiguration); otherKvStoreUri = ConvertKVStoreUri(otherKvStoreUri, toolConfiguration); IKeyValueStore keyValueStore = LoadKVStoreFromURI(kvStoreUri); IKeyValueStore otherKeyValueStore = LoadKVStoreFromURI(otherKvStoreUri); var trie = new MerkleTrie( keyValueStore, HashDigest <SHA256> .FromString(stateRootHashHex)); var otherTrie = new MerkleTrie( otherKeyValueStore, HashDigest <SHA256> .FromString(otherStateRootHashHex)); var codec = new Codec(); Dictionary <string, Dictionary <string, string> > dictionary = trie.DifferentNodes(otherTrie).ToDictionary( group => group.Key, group => group.ToDictionary( pair => ByteUtil.Hex(pair.Root.ByteArray), pair => ByteUtil.Hex(codec.Encode(pair.Value)))); Console.Write(JsonSerializer.Serialize(dictionary)); }
/// <summary> /// This method is called BY REFLECTION through the mediator from LinkListener.FollowActiveLink, because the assembly dependencies /// are in the wrong direction. It finds the name of the tool we need to invoke to edit a given list. /// </summary> /// <param name="parameters"></param> /// <returns></returns> public bool OnGetToolForList(object parameters) { var realParams = (object[])parameters; var list = (ICmPossibilityList)realParams[0]; var windowConfiguration = (XmlNode)m_mediator.PropertyTable.GetValue("WindowConfiguration"); foreach (XmlNode tool in windowConfiguration.SelectSingleNode(GetListToolsXPath()).ChildNodes) { var toolName = XmlUtils.GetManditoryAttributeValue(tool, "value"); var paramsNode = tool.SelectSingleNode(".//control/parameters[@clerk]"); if (paramsNode == null) { continue; } var clerkNode = ToolConfiguration.GetClerkNodeFromToolParamsNode(paramsNode); if (clerkNode == null) { continue; } var listNode = clerkNode.SelectSingleNode("recordList"); if (listNode == null) { continue; } var owner = XmlUtils.GetOptionalAttributeValue(listNode, "owner"); var listName = XmlUtils.GetOptionalAttributeValue(listNode, "property"); if (string.IsNullOrEmpty(owner) || string.IsNullOrEmpty(listName)) { continue; } var possibleList = PossibilityRecordList.GetListFromOwnerAndProperty(list.Cache, owner, listName); if (possibleList == list) { realParams[1] = toolName; return(true); } } // If it's not a known list, try custom. realParams[1] = GetCustomListToolName(list); return(true); }
public void Diff_PrintsAsJson() { using StringWriter stringWriter = new StringWriter { NewLine = "\n" }; var originalOutWriter = Console.Out; try { Console.SetOut(stringWriter); var kvStoreUri = $"default://{_pathA}"; var otherKvStoreUri = $"default://{_pathB}"; var configuration = new ToolConfiguration(new MptConfiguration(new Dictionary <string, string>())); string stateRootHashHex = ByteUtil.Hex(_trieA.Hash.ByteArray); string otherStateRootHashHex = ByteUtil.Hex(_trieB.Hash.ByteArray); _command.Diff( kvStoreUri, stateRootHashHex, otherKvStoreUri, otherStateRootHashHex, new TestToolConfigurationService(configuration)); string expected = string.Format( @"{{""Key"":""636f6d6d6f6e"",""StateRootHashToValue"":" + @"{{""{0}"":""75363a6265666f7265"",""{1}"":""75353a6166746572""}}}}" + "\n" + @"{{""Key"":""64656c65746564""," + @"""StateRootHashToValue"":{{""{0}"":""6e"",""{1}"":""null""}}}}" + "\n", stateRootHashHex, otherStateRootHashHex); Assert.Equal( expected, stringWriter.ToString()); } finally { Console.SetOut(originalOutWriter); } }
static string GetCommandLine( string triggerType, string triggerName, string executablePath, string server) { if (PlatformUtils.IsWindows) { return(string.Format( "cm maketrigger {0} \"{1}\" \"{2} trigger {0}\" --server={3}", triggerType, triggerName, executablePath, server)); } ToolConfiguration toolConfig = ToolConfiguration.Load(); return(string.Format( "cm maketrigger {0} \"{1}\" \"{2} {3} trigger {0}\" --server={4}", triggerType, triggerName, toolConfig.RuntimeConfig.MonoRuntimePath, executablePath, server)); }
/// <summary> /// Adds tool configuration which can be used for generation of the UI for tool. /// </summary> protected virtual void Configure(IAppContext context, ToolConfiguration configuration) { configuration.Layers = context.Layers; }
public void Given_File_When_ReadToolInfoInvoked_Exptected_FileNotFound() { ToolConfiguration toolConfiguration = new ToolConfiguration(); toolConfiguration.ReadToolInfo("abc"); }
public void GivenMinorHigherVersionItHasNoWarning() { ToolConfiguration toolConfiguration = ToolConfigurationDeserializer.Deserialize("DotnetToolSettingsGolden.xml"); toolConfiguration.Warnings.Should().BeEmpty(); }
public void GivenMajorHigherVersionItHasWarningReflectIt() { ToolConfiguration toolConfiguration = ToolConfigurationDeserializer.Deserialize("DotnetToolSettingsMajorHigherVersion.xml"); toolConfiguration.Warnings.First().Should().Be(CommonLocalizableStrings.FormatVersionIsHigher); }
protected override void Configure(IAppContext context, ToolConfiguration configuration) { base.Configure(context, configuration); configuration.Get <BufferTool>().SetDefault(t => t.BufferDistance, 50).SetDefault(t => t.NumSegments, 30); }
public void InitializeControlPanel(ToolConfiguration toolConfiguration, Action <Command> handleCommand) { ControlPanel.Initialize(handleCommand); ControlPanel.UpdateUI(toolConfiguration); }
void ICmd.Execute(string[] args) { if (args.Length == 1 || args.Length > 5) { Logger.LogError( $"RunCmd executed with wrong parameters: {string.Join(", ", args)}"); Environment.Exit(1); } Logger.LogInfo("Started running..."); ToolConfiguration toolConfig = ToolConfiguration.Load(); List <string> filteredRepos = toolConfig.RepoFilterConfig.GetFilteredRepos(); List <string> dstServers = toolConfig.ServerConfig.GetServers(); List <RepoMapping> repoMappings = toolConfig.RepoMapConfig.GetMappedRepos(); ErrorEmailSender emailSender = new ErrorEmailSender(toolConfig.EmailConfig); if (args.Length == 3 && args[1] == Trigger.Types.AfterCi) { RunAfterCheckin( filteredRepos, dstServers, repoMappings, args[2], emailSender); } if (args.Length == 3 && args[1] == Trigger.Types.AfterRW) { RunAfterReplicationWrite( filteredRepos, dstServers, repoMappings, args[2], emailSender); } if (args.Length == 5 && args[1] == Trigger.Types.AfterMkLb) { RunAfterMakeLabel( filteredRepos, dstServers, repoMappings, args[2], args[3], args[4], emailSender); } if (args.Length == 5 && args[1] == Trigger.Types.AfterChAttVal) { RunAfterChangeAttributeValue( filteredRepos, dstServers, repoMappings, args[2], args[3], args[4], emailSender); } }
public void GivenMajorHigherVersionItHasWarningReflectIt() { ToolConfiguration toolConfiguration = ToolConfigurationDeserializer.Deserialize("DotnetToolSettingsMajorHigherVersion.xml"); toolConfiguration.Warnings.First().Should().Be("Format version indicate this tool may not be fully supported in this SDK version. Please update SDK version."); }
public void GivenMissingVersionItHasWarningReflectIt() { ToolConfiguration toolConfiguration = ToolConfigurationDeserializer.Deserialize("DotnetToolSettingsMissingVersion.xml"); toolConfiguration.Warnings.First().Should().Be("Format version is missing, this tool may not be supported in this SDK version. Please contact the author."); }
void ICmd.Execute(string[] args) { if (args.Length == 1 || args.Length > 3) { Console.Error.WriteLine(HELP); Environment.Exit(1); } string srcServer = args[1]; if (!Utils.CheckServerSpec(srcServer)) { Console.Error.WriteLine( "The server spec is not correct: {0}", srcServer); Environment.Exit(1); } Console.WriteLine( "Installing the necessary triggers on server {1}:{0}" + "* after-checkin{0}" + "* after-replicationwrite{0}" + "* after-mklabel{0}" + "* after-chattvalue", Environment.NewLine, srcServer); string executablePath = Utils.GetAssemblyLocation(); Console.WriteLine( "Using syncservertrigger located at {0}.", executablePath); if (!PlatformUtils.IsWindows) { InitializeMonoRuntimePath(); } if (!InstallTrigger(Trigger.Types.AfterCi, Trigger.Names.AfterCi, executablePath, srcServer) || !InstallTrigger(Trigger.Types.AfterRW, Trigger.Names.AfterRW, executablePath, srcServer) || !InstallTrigger(Trigger.Types.AfterMkLb, Trigger.Names.AfterMkLb, executablePath, srcServer) || !InstallTrigger(Trigger.Types.AfterChAttVal, Trigger.Names.AfterChAttVal, executablePath, srcServer)) { Environment.Exit(1); } Console.WriteLine( "Triggers successfully installed in {0}!", srcServer); if (args.Length != 3) { return; } string dstServer = args[2]; if (!Utils.CheckServerSpec(dstServer)) { Console.Error.WriteLine( "The server spec is not correct: {0}", dstServer); Environment.Exit(1); } Console.WriteLine( "Adding '{0}' as the first destination server.", dstServer); ToolConfiguration toolConfig = ToolConfiguration.Load(); toolConfig.ServerConfig.AddServer(dstServer); toolConfig.Save(); Console.WriteLine( "Server '{0}' correctly added!", dstServer); }