本文整理汇总了C#中SortedSet.Except方法的典型用法代码示例。如果您正苦于以下问题:C# SortedSet.Except方法的具体用法?C# SortedSet.Except怎么用?C# SortedSet.Except使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SortedSet
的用法示例。
在下文中一共展示了SortedSet.Except方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetSObjectsAsXML
public static Dictionary<string, string> GetSObjectsAsXML(IEnumerable<string> monikers)
{
var sw = Stopwatch.StartNew();
var loaded = SObjectManager.Instance().LoadMultipleSObjectsAsXML(monikers);
var allRequests = new SortedSet<string>(monikers);
// TO DO: group requests by calculator and aggregate for bulk load from database
foreach(var remainingRequest in allRequests.Except(loaded.Select(l => l.Key)))
{
try
{
// can we create?
var calculated = SObjectCalculator.CalculateObject(remainingRequest);
if (calculated != null)
{
var xml = SObjectManager.Serialize(calculated);
loaded.Add(remainingRequest, xml);
// add to cache
SObjectManager.Instance().AddToCache(remainingRequest, xml);
}
} catch (Exception ex)
{
SLog.log.Error("Error calculating moniker " + remainingRequest, ex);
}
}
SLog.log.DebugFormat("{0} objects bulk loaded in {1} ms", loaded.Count(), sw.ElapsedMilliseconds);
return loaded;
}
示例2: GetSetupStatus
public SetupStatus GetSetupStatus()
{
var setupStatus = new SetupStatus();
try
{
if (string.IsNullOrEmpty(Configuration.ContextType))
return null;
if (string.IsNullOrEmpty(Configuration.ScriptsBase))
return null;
var schemaContext = (ISchemaContext)Activator.CreateInstanceFrom(_executingAssembly, Configuration.ContextType).Unwrap();
if (schemaContext == null)
return null;
var abstractList = schemaContext.GetScriptsInstalled();
schemaContext.Dispose();
var allEntries = abstractList
.Select(a => new SchemaVersion
{
ScriptPath = a.ScriptPath,
MajorVersion = a.MajorVersion,
MinorVersion = a.MinorVersion,
ScriptVersion = a.ScriptVersion
})
.ToList();
allEntries.Sort(new SchemaVersionComparer());
var schemaInstance = allEntries.LastOrDefault();
if (schemaInstance == null)
{
setupStatus.StatusCode = SetupStatusCode.NotInstalled;
setupStatus.Message = "None of the scripts have been run";
return setupStatus;
}
var sortedList = new SortedSet<SchemaVersion>();
var filePath = HostingEnvironment.MapPath(Configuration.ScriptsBase);
if (filePath != null)
{
var files = Directory.GetFiles(filePath).ToList();
files.ForEach(f =>
{
var schemaItem = f.Parse();
sortedList.Add(schemaItem);
});
}
var lastInstance = sortedList.LastOrDefault();
if (lastInstance != null && lastInstance.Equals(schemaInstance))
{
setupStatus.StatusCode = SetupStatusCode.NoUpdates;
setupStatus.Message = "Your instance is up to date!";
return setupStatus;
}
var scriptsToBeRan = sortedList.Except(allEntries, new SchemaVersionEqualityComparer()).ToList();
setupStatus.StatusCode = SetupStatusCode.HasUpdates;
setupStatus.Message = "Your instance has some updates";
setupStatus.FullPathsOfScripts = scriptsToBeRan;
setupStatus.ScriptsPending = scriptsToBeRan.Select(s => Path.GetFileName(s.ScriptPath)).ToList();
return setupStatus;
}
catch (Exception exception)
{
if (exception.Message.Contains("Invalid object name"))
{
setupStatus.StatusCode = SetupStatusCode.DatabaseNotSetup;
setupStatus.Message = "Database has not been setup";
}
else
{
setupStatus.StatusCode = SetupStatusCode.DatabaseError;
setupStatus.Message = exception.Message;
}
}
return setupStatus;
}
示例3: DoRequest
override public void DoRequest(IDictionary<string, QueuedRequest> requests)
{
var allMonikers = new SortedSet<string>(requests.Select(r => r.Key));
// get the data
if (allMonikers.Count > 0)
{
var executionStart = DateTime.Now;
SLog.log.DebugFormat("About to request {0} monikers...", allMonikers.Count);
SLog.log.DebugFormat("Just so I know {0}", "ben");
try
{
var receivedObjects = getObjects(allMonikers.ToArray());
//SObjectDTO[] receivedObjects = new ServiceClient.SymmetryServiceClient().GetMultipleObjects(allMonikers.ToArray());
foreach (var response in receivedObjects)
{
try
{
SObjectProvider.Instance().AddToCache(response.Moniker, response);
}
catch (Exception ex)
{
SLog.log.Error("Error adding moniker to cache " + response.Moniker, ex);
}
try
{
QueuedRequest request = null;
if (requests.TryGetValue(response.Moniker, out request))
{
request.ReponseEvent.Response = response;
request.ReponseEvent.Event.Set();
}
}
catch (Exception ex)
{
SLog.log.Error("Error retrieving moniker " + response.Moniker, ex);
}
}
// check for errors
var receivedMonikers = new SortedSet<string>(receivedObjects.Where(o => o != null).Select(o => o.Moniker));
foreach (var erroredRequest in allMonikers.Except(receivedMonikers))
{
SObjectProvider.Instance().AddToErrorQueue(erroredRequest);
try
{
QueuedRequest request = null;
if (requests.TryGetValue(erroredRequest, out request))
{
request.ReponseEvent.Event.Set();
}
}
catch (Exception ex)
{
SLog.log.ErrorFormat("Error retrieving moniker {0} : {1}", erroredRequest, ex);
}
}
SLog.log.DebugFormat("Success retrieving {0} of {1} monikers in {2} ms.", receivedObjects.Length, allMonikers.Count, (DateTime.Now - executionStart).TotalMilliseconds);
}
catch (Exception ex)
{
SLog.log.Error("Error retrieving monikers from the service.", ex);
}
}
}