public RecurseDepth(RecurseDepth depth) { curLevel = depth.curLevel + 1; maxLevel = depth.maxLevel; maxLevelReached = curLevel >= maxLevel; }
private void MigrateKey(RegistryKey p_FromKey, string p_ToDir) { // Subroutine used for one off copy of registry profile to new XML profile string[] ValueNames, SubKeyNames; RegistryKey FromKey; Generic.SortedList <string, string> Values = new Generic.SortedList <string, string>(); // Recusively copy contents from one key to the other Stopwatch swLocal; ; /* Cannot convert LocalDeclarationStatementSyntax, System.NotSupportedException: StaticKeyword not supported! * at ICSharpCode.CodeConverter.CSharp.SyntaxKindExtensions.ConvertToken(SyntaxKind t, TokenContext context) * at ICSharpCode.CodeConverter.CSharp.CommonConversions.ConvertModifier(SyntaxToken m, TokenContext context) * at ICSharpCode.CodeConverter.CSharp.CommonConversions.<ConvertModifiersCore>d__15.MoveNext() * at System.Linq.Enumerable.WhereEnumerableIterator`1.MoveNext() * at Microsoft.CodeAnalysis.SyntaxTokenList.CreateNode(IEnumerable`1 tokens) * at ICSharpCode.CodeConverter.CSharp.CommonConversions.ConvertModifiers(IEnumerable`1 modifiers, TokenContext context, Boolean isVariableOrConst) * at ICSharpCode.CodeConverter.CSharp.VisualBasicConverter.MethodBodyVisitor.VisitLocalDeclarationStatement(LocalDeclarationStatementSyntax node) * at Microsoft.CodeAnalysis.VisualBasic.Syntax.LocalDeclarationStatementSyntax.Accept[TResult](VisualBasicSyntaxVisitor`1 visitor) * at Microsoft.CodeAnalysis.VisualBasic.VisualBasicSyntaxVisitor`1.Visit(SyntaxNode node) * at ICSharpCode.CodeConverter.CSharp.CommentConvertingMethodBodyVisitor.ConvertWithTrivia(SyntaxNode node) * at ICSharpCode.CodeConverter.CSharp.CommentConvertingMethodBodyVisitor.DefaultVisit(SyntaxNode node) * * Input: * * Static RecurseDepth As Integer * */ RecurseDepth += 1; // Increment the recursion depth indicator swLocal = Stopwatch.StartNew(); TL.LogMessage("MigrateKeys " + RecurseDepth.ToString(), "To Directory: " + p_ToDir); try { TL.LogMessage("MigrateKeys" + RecurseDepth.ToString(), "From Key: " + p_FromKey.Name + ", SubKeyCount: " + p_FromKey.SubKeyCount.ToString() + ", ValueCount: " + p_FromKey.ValueCount.ToString()); } catch (Exception ex) { TL.LogMessage("MigrateKeys", "Exception processing \"" + p_ToDir + "\": " + ex.ToString()); TL.LogMessage("MigrateKeys", "Exception above: no action taken, continuing..."); } // First copy values from the from key to the to key ValueNames = p_FromKey.GetValueNames(); Values.Add(COLLECTION_DEFAULT_VALUE_NAME, COLLECTION_DEFAULT_UNSET_VALUE); foreach (string ValueName in ValueNames) { if (ValueName == "") { Values.Remove(COLLECTION_DEFAULT_VALUE_NAME); // Remove the default unset value and replace with actual value Values.Add(COLLECTION_DEFAULT_VALUE_NAME, p_FromKey.GetValue(ValueName).ToString()); } else { Values.Add(ValueName, p_FromKey.GetValue(ValueName).ToString()); } } WriteValues(p_ToDir, ref Values); // Write values to XML file // Now process the keys SubKeyNames = p_FromKey.GetSubKeyNames(); foreach (string SubKeyName in SubKeyNames) { FromKey = p_FromKey.OpenSubKey(SubKeyName); // Point at the source to copy to it CreateKey(p_ToDir + @"\" + SubKeyName); MigrateKey(FromKey, p_ToDir + @"\" + SubKeyName); // Recursively process each key FromKey.Close(); } swLocal.Stop(); TL.LogMessage(" ElapsedTime " + RecurseDepth.ToString(), " " + swLocal.ElapsedMilliseconds + " milliseconds, Completed Directory: " + p_ToDir); RecurseDepth -= 1; // Decrement the recursion depth counter swLocal = null; }