本文整理汇总了C#中Data.SetA方法的典型用法代码示例。如果您正苦于以下问题:C# Data.SetA方法的具体用法?C# Data.SetA怎么用?C# Data.SetA使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Data
的用法示例。
在下文中一共展示了Data.SetA方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InnerCompare
private static bool InnerCompare(RegistryKey A, RegistryKey B, string root,ref Dictionary<string, Data> output)
{
bool current = true;
try
{
if (A != null)
{
// Process A
foreach (var Name in A.GetValueNames())
{
string EntryName = root + A.Name + "::" + Name;
var dat = new Data();
dat.SetA(A.GetValue(Name), A.GetValueKind(Name));
output.Add(EntryName, dat);
}
foreach (var keyName in A.GetSubKeyNames())
{
RegistryKey subA = A.OpenSubKey(keyName);
RegistryKey subB = B == null ? null : B.OpenSubKey(keyName);
current &= InnerCompare(subA, subB, root + keyName + @"\", ref output);
}
}
if (B != null)
{
foreach (var Name in B.GetValueNames())
{
string EntryName = root + B.Name + "::" + Name;
Data dat = output.ContainsKey(EntryName) ? output[EntryName] : new Data();
dat.SetB(B.GetValue(Name), B.GetValueKind(Name));
output[EntryName] = dat;
}
foreach (var keyName in B.GetSubKeyNames())
{
// when we get here, we have already cleared everything present in the A side
RegistryKey subB = B.OpenSubKey(keyName);
current &= InnerCompare(null, subB, root + keyName + @"\", ref output);
}
}
return current;
}
catch (Exception e)
{
return false;
}
}
示例2: BOnlyInnerCompare
private async Task<bool> BOnlyInnerCompare(RegistryKey A, RegistryKey B, string root)
{
List<Task<bool>> tasks = new List<Task<bool>>();
List<bool> bools = new List<bool>();
try
{
if (B != null)
{
// Process A
string[] bVals;
lock (HiveB)
bVals = B.GetValueNames();
string[] aVals = new string[0];
if (A != null)
lock (HiveA)
aVals = A.GetValueNames();
foreach (var Name in bVals)
{
string EntryName;
lock (HiveB)
EntryName = root + B.Name + "::" + Name;
var dat = new Data();
lock (HiveB)
dat.SetB(B.GetValue(Name), B.GetValueType(Name));
if (aVals.Contains(Name, StringComparer.CurrentCultureIgnoreCase))
lock (HiveA)
dat.SetA(A.GetValue(Name), A.GetValueType(Name));
lock(Output)
Output.Add(EntryName, dat);
}
string[] BSubKeys;
lock (HiveB)
BSubKeys = B.GetSubKeyNames();
string[] ASubKeys = new string[0];
if (A != null)
lock (HiveA)
ASubKeys = A.GetSubKeyNames();
tasks.AddRange(BSubKeys.Select(async keyName =>
{
RegistryKey aSub, bSub;
lock (HiveB)
bSub = B.OpenSubKey(keyName);
lock (HiveA)
aSub = A == null
? null
: ASubKeys.Contains(keyName, StringComparer.CurrentCultureIgnoreCase)
? A.OpenSubKey(keyName)
: null;
return await BOnlyInnerCompare(aSub, bSub, root + keyName + @"\");
}));
}
/*
return Task.Factory.StartNew(() =>
tasks.AsParallel().Aggregate(true, (ret, task) =>
{
task.Wait();
return ret && task.Result;
}), TaskCreationOptions.AttachedToParent);
*/
return tasks.AsParallel().Aggregate(true, (ret, task) =>
{
task.Wait();
return ret && task.Result;
});
}
catch (Exception e)
{
throw;
}
}
示例3: InnerCompare
private Task<bool> InnerCompare(RegistryKey A, RegistryKey B, string root) // TODO: Adjust to match the BOnly comparison (below)
{
List<Task<bool>> tasks = new List<Task<bool>>();
try
{
if (A != null)
{
// Process A
string[] aVals;
lock (HiveA)
aVals = A.GetValueNames();
foreach (var Name in aVals)
{
string EntryName;
lock (HiveA)
EntryName = root + A.Name + "::" + Name;
var dat = new Data();
lock (HiveA)
dat.SetA(A.GetValue(Name), A.GetValueType(Name));
Output.Add(EntryName, dat);
}
string[] ASubKeys;
lock (HiveA)
ASubKeys = A.GetSubKeyNames();
string[] BSubKeys = new string[0];
if (B != null)
lock (HiveB)
BSubKeys = B.GetSubKeyNames();
tasks.AddRange(ASubKeys.AsParallel().Select(keyName =>
{
RegistryKey aSub, bSub;
lock (HiveA)
aSub = A.OpenSubKey(keyName);
lock (HiveB)
bSub = B == null
? null
: BSubKeys.Contains(keyName, StringComparer.CurrentCultureIgnoreCase)
? B.OpenSubKey(keyName)
: null;
return InnerCompare(aSub, bSub, root + keyName + @"\");
}));
}
if (B != null)
{
// Process B
string[] bVals;
lock (HiveB)
bVals = B.GetValueNames();
foreach (var Name in bVals)
{
string EntryName;
lock (HiveB)
EntryName = root + B.Name + "::" + Name;
Data dat = Output.ContainsKey(EntryName) ? Output[EntryName] : new Data();
lock (HiveB)
dat.SetB(B.GetValue(Name), B.GetValueType(Name));
Output[EntryName] = dat;
}
string[] BSubKeys;
lock (HiveB)
BSubKeys = B.GetSubKeyNames();
tasks.AddRange(BSubKeys.AsParallel().Select(keyName =>
{
RegistryKey bSub;
lock (HiveB)
bSub = B.OpenSubKey(keyName);
return InnerCompare(null, bSub, root + keyName + @"\");
}));
}
return Task.Factory.StartNew(() =>
tasks.Aggregate(true, (ret, task) =>
{
task.Wait();
return ret && task.Result;
}), TaskCreationOptions.AttachedToParent);
}
catch (Exception e)
{
throw;
}
}