public override bool TryEvaluate(DynamicResources resources, IValue root, JsonLocationNode lastNode, IValue current, ProcessingFlags options, out IValue result) { JsonLocationNode?ancestor = lastNode; int index = 0; while (ancestor != null && index < _ancestorDepth) { ancestor = ancestor.Parent; ++index; } if (ancestor != null) { JsonLocation path = new JsonLocation(ancestor); IValue value; if (TryGetValue(root, path, out value)) { return(this.TryEvaluateTail(resources, root, path.Last, value, options, out result)); } else { result = JsonConstants.Null; return(true); } } else { result = JsonConstants.Null; return(true); } }
public override void Select(DynamicResources resources, IValue root, JsonLocationNode lastNode, IValue current, INodeReceiver receiver, ProcessingFlags options, int depth) { JsonLocationNode?ancestor = lastNode; int index = 0; while (ancestor != null && index < _ancestorDepth) { ancestor = ancestor.Parent; ++index; } if (ancestor != null) { JsonLocation path = new JsonLocation(ancestor); IValue value; if (TryGetValue(root, path, out value)) { this.TailSelect(resources, root, path.Last, value, receiver, options, depth); } } }
public override void Select(DynamicResources resources, IValue root, JsonLocationNode lastNode, IValue current, INodeReceiver receiver, ProcessingFlags options, int depth) { if (current.ValueKind == JsonValueKind.Array) { Int32 index = 0; foreach (var item in current.EnumerateArray()) { this.TailSelect(resources, root, PathGenerator.Generate(lastNode, index, options), item, receiver, options, depth); ++index; } } else if (current.ValueKind == JsonValueKind.Object) { foreach (var prop in current.EnumerateObject()) { this.TailSelect(resources, root, PathGenerator.Generate(lastNode, prop.Name, options), prop.Value, receiver, options, depth); } } }
public void Dequeue(ProcessingFlags flags) { lock (_lock) { _queue &= ~flags; } }
public abstract void Select(DynamicResources resources, IValue root, JsonLocationNode lastNode, IValue current, INodeReceiver receiver, ProcessingFlags options, int depth);
private bool CheckEntity(ProcessingFlags pProcessingFlags, out string pReport) { bool reportOnlyIssues = pProcessingFlags.HasFlag(ProcessingFlags.JustReportIssues); // bool showAddonContents = pProcessingFlags.HasFlag(ProcessingFlags.ShowAddonContents); string versionString = null; try { byte[] headerBytes = File.ReadAllBytes(AbsolutePath); versionString = GetVersionString(headerBytes); if (versionString == null) { pReport = $"{ErrorTokenString} Invalid file/unknown format"; return(false); } if (!versionString.StartsWith("6.")) { pReport = $"{ErrorTokenString} Format not importable [{versionString}]"; return(false); } } catch { } pReport = $"OK [{versionString}]"; return(true); }
public static Configuration EnableProcessors(this Configuration that, ProcessingFlags processingFlags = Configuration.AllProcessingFlags) { that.Accept(container => { if ((processingFlags & ProcessingFlags.Command) == ProcessingFlags.Command) { container.RegisterType <IProcessor, CommandConsumer>("command"); } if ((processingFlags & ProcessingFlags.Event) == ProcessingFlags.Event) { container.RegisterType <IProcessor, EventConsumer>("event"); } if ((processingFlags & ProcessingFlags.PublishableException) == ProcessingFlags.PublishableException) { container.RegisterType <IProcessor, PublishableExceptionConsumer>("exception"); } if ((processingFlags & ProcessingFlags.Query) == ProcessingFlags.Query) { container.RegisterType <IProcessor, QueryConsumer>("query"); } if ((processingFlags & ProcessingFlags.Result) == ProcessingFlags.Result) { container.RegisterType <IProcessor, ResultConsumer>("result"); } }); return(that); }
public static Configuration UseLocalQueue(this Configuration that, ProcessingFlags flags = Configuration.AllProcessingFlags) { that.Accept(container => { if ((flags & ProcessingFlags.Command) == ProcessingFlags.Command) { container.RegisterType <IMessageBus <ICommand>, MessageProducer <ICommand> >(); container.RegisterType <IMessageReceiver <Envelope <ICommand> >, MessageProducer <ICommand> >(); } if ((flags & ProcessingFlags.Event) == ProcessingFlags.Event) { container.RegisterType <IMessageBus <IEvent>, MessageProducer <IEvent> >(); container.RegisterType <IMessageReceiver <Envelope <IEvent> >, MessageProducer <IEvent> >(); } if ((flags & ProcessingFlags.PublishableException) == ProcessingFlags.PublishableException) { container.RegisterType <IMessageBus <IPublishableException>, MessageProducer <IPublishableException> >(); container.RegisterType <IMessageReceiver <Envelope <IPublishableException> >, MessageProducer <IPublishableException> >(); } if ((flags & ProcessingFlags.Query) == ProcessingFlags.Query) { container.RegisterType <IMessageBus <IQuery>, MessageProducer <IQuery> >(); container.RegisterType <IMessageReceiver <Envelope <IQuery> >, MessageProducer <IQuery> >(); } if ((flags & ProcessingFlags.Result) == ProcessingFlags.Result) { container.RegisterType <IMessageBus <IResult>, MessageProducer <IResult> >(); container.RegisterType <IMessageReceiver <Envelope <IResult> >, MessageProducer <IResult> >(); } }); return(that.EnableProcessors(flags)); }
public bool InProgress(ProcessingFlags flags) { lock (_lock) { return ((_current & flags) != 0); } }
public void Enqueue(ProcessingFlags flags) { lock (_lock) { _queue |= flags; } }
public void End(ProcessingFlags flags) { lock (_lock) { _current &= ~flags; } }
public override void Select(DynamicResources resources, IValue root, JsonLocationNode lastNode, IValue current, INodeReceiver receiver, ProcessingFlags options, int depth) { if (current.ValueKind == JsonValueKind.Array) { if (_index >= 0 && _index < current.GetArrayLength()) { this.TailSelect(resources, root, PathGenerator.Generate(lastNode, _index, options), current[_index], receiver, options, depth); } else { Int32 index = current.GetArrayLength() + _index; if (index >= 0 && index < current.GetArrayLength()) { this.TailSelect(resources, root, PathGenerator.Generate(lastNode, _index, options), current[index], receiver, options, depth); } } } }
public override bool TryEvaluate(DynamicResources resources, IValue root, JsonLocationNode lastNode, IValue current, ProcessingFlags options, out IValue value) { return(this.TryEvaluateTail(resources, root, lastNode, current, options, out value)); }
private ProcessingFlags _queue; // operations queued on this object #endregion Fields #region Methods public void Begin(ProcessingFlags flags) { lock (_lock) { _queue &= ~flags; _current |= flags; } }
/// <summary> /// Initializes a new instance of the <see cref="MessageConsumer{TMessage}" /> class. /// </summary> protected MessageConsumer(IMessageReceiver <Envelope <TMessage> > receiver, CheckHandlerMode checkHandlerMode, ProcessingFlags processingFlag) : base(receiver, processingFlag) { _handlerDescriptors = new Dictionary <Type, ICollection <HandlerDescriptor> >(); _envelopeHandlerDescriptors = new Dictionary <Type, ICollection <HandlerDescriptor> >(); _checkHandlerMode = checkHandlerMode; }
private static bool CheckArguments(string[] pArgs) { if (pArgs.Length == 0) { return(false); } _processingFlags = ProcessingFlags.None; foreach (string arg in pArgs) { if (arg.StartsWith("-")) { string argLower = arg.ToLower(); if (argLower == "-showaddoncontents" || argLower == "-c") { _processingFlags |= ProcessingFlags.ShowAddonContents; continue; } if (argLower == "-justreportissues" || argLower == "-i") { _processingFlags |= ProcessingFlags.JustReportIssues; continue; } if (argLower == "-listallanimationfiles" || argLower == "-laa") { _processingFlags |= ProcessingFlags.ListAllAnimationFiles; continue; } if (argLower == "-listgesturegaitsanimations" || argLower == "-lga") { _processingFlags |= ProcessingFlags.ListGestureGaitsAnimations; continue; } if (argLower == "-listweirdgesturegaitsverbs" || argLower == "-lw") { _processingFlags |= ProcessingFlags.ListWeirdGestureGaitsVerbs; continue; } if (argLower == "-listcompactdupverbsbyname" || argLower == "-lcdv") { _processingFlags |= ProcessingFlags.ListCompactDupVerbsByName; continue; } if (argLower == "-correctdisguisedfiles" || argLower == "-cdf") { _processingFlags |= ProcessingFlags.CorrectDisguisedFiles; continue; } continue; } _diskEntity = arg; } return(_diskEntity != null); }
internal JsonSelector(ISelector selector, bool pathsRequired) { _selector = selector; if (pathsRequired) { _requiredFlags = ProcessingFlags.Path; } }
public override void Select(DynamicResources resources, IValue root, JsonLocationNode lastNode, IValue current, INodeReceiver receiver, ProcessingFlags options, int depth) { this.TailSelect(resources, root, lastNode, current, receiver, options, depth); }
public override void Select(DynamicResources resources, IValue root, JsonLocationNode lastNode, IValue current, INodeReceiver receiver, ProcessingFlags options, int depth) { if (current.ValueKind == JsonValueKind.Array) { Int32 start = _slice.GetStart(current.GetArrayLength()); Int32 end = _slice.GetStop(current.GetArrayLength()); Int32 step = _slice.Step; if (step > 0) { if (start < 0) { start = 0; } if (end > current.GetArrayLength()) { end = current.GetArrayLength(); } for (Int32 i = start; i < end; i += step) { this.TailSelect(resources, root, PathGenerator.Generate(lastNode, i, options), current[i], receiver, options, depth); } } else if (step < 0) { if (start >= current.GetArrayLength()) { start = current.GetArrayLength() - 1; } if (end < -1) { end = -1; } for (Int32 i = start; i > end; i += step) { if (i < current.GetArrayLength()) { this.TailSelect(resources, root, PathGenerator.Generate(lastNode, i, options), current[i], receiver, options, depth); } } } } }
private bool CheckEntity(ProcessingFlags pProcessingFlags, out string pReport) { pReport = null; bool reportOnlyIssues = pProcessingFlags.HasFlag(ProcessingFlags.JustReportIssues); // bool showAddonContents = pProcessingFlags.HasFlag(ProcessingFlags.ShowAddonContents); DirectoryInfo directoryInfo = new DirectoryInfo(EntityPath); FileInfo[] addonInfoList = directoryInfo.GetFiles("*.addon", SearchOption.TopDirectoryOnly); foreach (FileInfo item in addonInfoList) { new DiskEntityAddon(item.FullName, ArchivedPath, ReportWriter).CheckEntity(pProcessingFlags); } FileInfo[] sketchupInfoList = directoryInfo.GetFiles("*.skp", SearchOption.TopDirectoryOnly); foreach (FileInfo item in sketchupInfoList) { new DiskEntitySketchup(item.FullName, null, ReportWriter).CheckEntity(pProcessingFlags); } FileInfo[] archiveInfoList = directoryInfo.GetFiles("*.zip", SearchOption.TopDirectoryOnly); FileInfo[] rarInfoList = directoryInfo.GetFiles("*.rar", SearchOption.TopDirectoryOnly); archiveInfoList = archiveInfoList.Concat(rarInfoList).ToArray(); FileInfo[] s7InfoList = directoryInfo.GetFiles("*.7z", SearchOption.TopDirectoryOnly); archiveInfoList = archiveInfoList.Concat(s7InfoList).ToArray(); foreach (FileInfo item in archiveInfoList) { new DiskEntityArchive(item.FullName, ArchivedPath, ReportWriter).CheckEntity(pProcessingFlags); } if (!pProcessingFlags.HasFlag(ProcessingFlags.FolderTopOnlySearch)) { DirectoryInfo[] subdirectories = directoryInfo.GetDirectories(); if (subdirectories.Length > 0) { foreach (DirectoryInfo subdirectoryInfo in subdirectories) { new DiskEntityFolder(subdirectoryInfo.FullName, null, ReportWriter).CheckEntity(pProcessingFlags); } } } return(true); }
static internal JsonLocationNode Generate(JsonLocationNode lastNode, string identifier, ProcessingFlags options) { if ((options & ProcessingFlags.Path) != 0) { return(new JsonLocationNode(lastNode, identifier)); } else { return(lastNode); } }
// --------------------------------------------------------------------------------------------------------------- public bool CheckEntity(ProcessingFlags pProcessingFlags, string pNamePrinted = null) { string report; bool checkOk = CheckEntity(pProcessingFlags, out report); if (checkOk && pProcessingFlags.HasFlag(ProcessingFlags.JustReportIssues)) { return(false); } ReportWriter.WriteReportLineFeed($"{Name} : {report}"); return(checkOk); }
static internal JsonLocationNode Generate(JsonLocationNode lastNode, Int32 index, ProcessingFlags options) { if ((options & ProcessingFlags.Path) != 0) { return(new JsonLocationNode(lastNode, index)); } else { return(lastNode); } }
public ComponentSystem() { try { ComponentSystemAttribute attr = AttributeOf(this.GetType()); this.SystemName = attr.SystemName; this.ProcessingCycles = attr.ProcessingCycles; this.ProcessingFlags = attr.ProcessingFlags; this.Watching = attr.Watching; this.Listening = attr.Listening; } catch (Exception ex) { throw new AttributeException( $"Required attribute of class 'ComponentSystemAttribute' not found in derived class '{GetType()}'", ex); } }
protected bool TryEvaluateTail(DynamicResources resources, IValue root, JsonLocationNode lastNode, IValue current, ProcessingFlags options, out IValue value) { if (Tail == null) { value = current; return(true); } else { return(Tail.TryEvaluate(resources, root, lastNode, current, options, out value)); } }
protected void TailSelect(DynamicResources resources, IValue root, JsonLocationNode lastNode, IValue current, INodeReceiver receiver, ProcessingFlags options, int depth) { if (Tail == null) { receiver.Add(lastNode, current); } else { Tail.Select(resources, root, lastNode, current, receiver, options, depth); } }
private bool CheckEntity(ProcessingFlags pProcessingFlags, out string pReport) { // bool reportOnlyIssues = pProcessingFlags.HasFlag(ProcessingFlags.JustReportIssues); // bool showAddonContents = pProcessingFlags.HasFlag(ProcessingFlags.ShowAddonContents); pReport = null; SevenZipArchiver archiver = new SevenZipArchiver(AbsolutePath); List <ArchiveFileInfo> archiveEntryList; List <string> fileList = GetFileList(archiver, out archiveEntryList); if ((fileList?.Count ?? -1) <= 0) { return(false); } return(CheckFiles(pProcessingFlags, archiver, archiveEntryList, fileList, out pReport)); }
// ------------------------------------------------------------------------------------------- // TODO - Print report public bool CheckEntity(ProcessingFlags pProcessingFlags, string pNamePrinted = null) { ReportWriter.WriteReportLineFeed($"+{Name} : "); ReportWriter.IncreaseReportLevel(); string report; bool checkOk = CheckEntity(pProcessingFlags, out report); if (!string.IsNullOrEmpty(report)) { ReportWriter.WriteReportLineFeed(report); ReportWriter.DecreaseReportLevel(); return(checkOk); } ReportWriter.DecreaseReportLevel(); ReportWriter.WriteReportLineFeed(""); return(checkOk); }
// ------------------------------------------------------------------------------------------ public bool CheckEntity(ProcessingFlags pProcessingFlags, string pNamePrinted = null) { if (IsAddonFolder(EntityPath)) { new DiskEntityAddonFolder(EntityPath, ArchivedPath, ReportWriter).CheckEntity(pProcessingFlags); return(true); } ReportWriter.WriteReportLineFeed($"\n/{Name} :"); ReportWriter.IncreaseReportLevel(); string report; bool checkOk = CheckEntity(pProcessingFlags, out report); ReportWriter.DecreaseReportLevel(); ReportWriter.WriteReportLineFeed(""); return(checkOk); }
public override void Select(DynamicResources resources, IValue root, JsonLocationNode lastNode, IValue current, INodeReceiver receiver, ProcessingFlags options, int depth) { if (current.ValueKind == JsonValueKind.Object) { IValue value; if (current.TryGetProperty(_identifier, out value)) { this.TailSelect(resources, root, PathGenerator.Generate(lastNode, _identifier, options), value, receiver, options, depth); } } }
private bool CheckEntity(ProcessingFlags pProcessingFlags, out string pReport) { pReport = null; bool showDetailedContents = pProcessingFlags.HasFlag(ProcessingFlags.ShowAddonContents); bool appendToPackageSet = pProcessingFlags.HasFlag(ProcessingFlags.AppendToAddonPackageSet); if (!showDetailedContents) { pReport = BriefReport(); if (!appendToPackageSet) { return(true); } } string tempPath = Utils.GetTempDirectory(); AddonPackage package = new AddonPackage(AbsolutePath, pProcessingFlags, tempPath); if (showDetailedContents) { pReport = package?.ToString(); } if (appendToPackageSet && (AddonPackageSet != null) && (package != null)) { if (package.HasIssues) { pReport += " >>> NOT inserted/updated into Catalogue (has problems!)"; } else { if (AddonPackageSet.Append(package, pProcessingFlags.HasFlag(ProcessingFlags.AppendToAddonPackageSetForceRefresh))) { pReport += " >>> Inserted/updated into Catalogue"; } } } return(true); }
public override bool TryEvaluate(DynamicResources resources, IValue root, JsonLocationNode lastNode, IValue current, ProcessingFlags options, out IValue result) { if (resources.TryRetrieveFromCache(_id, out result)) { return(true); } else { if (!this.TryEvaluateTail(resources, root, lastNode, root, options, out result)) { result = JsonConstants.Null; return(false); } resources.AddToCache(_id, result); return(true); } }
public void InitializeDatabase() { Addons = null; List <string> files = new List <string>(); foreach (string folder in Directory.EnumerateDirectories(_moviestormPaths.ContentPacksPath, "*", SearchOption.TopDirectoryOnly)) { files.Add(folder); } string moddersWorkshop = Path.Combine(_moviestormPaths.AddonsPath, "ModdersWorkshop").ToLower(); foreach (string folder in Directory.EnumerateDirectories(_moviestormPaths.AddonsPath, "*", SearchOption.TopDirectoryOnly)) { if (folder.ToLower() != moddersWorkshop) { files.Add(folder); } } ProcessingFlags processingFlags = ProcessingFlags.AppendToAddonPackageSet | ProcessingFlags.AppendToAddonPackageSetForceRefresh; foreach (string argument in files) { IDiskEntity asset = DiskEntityHelper.GetEntity(argument, null, new NullReportWriter()); if (asset == null) { continue; } asset.CheckEntity(processingFlags); } LastUpdate = DateTime.Now; }
public override bool TryEvaluate(DynamicResources resources, IValue root, JsonLocationNode lastNode, IValue current, ProcessingFlags options, out IValue value) { if (current.ValueKind == JsonValueKind.Object) { IValue element; if (current.TryGetProperty(_identifier, out element)) { return(this.TryEvaluateTail(resources, root, PathGenerator.Generate(lastNode, _identifier, options), element, options, out value)); } else { value = JsonConstants.Null; return(true); } } else if (current.ValueKind == JsonValueKind.Array && _identifier == "length") { value = new DecimalValue(new Decimal(current.GetArrayLength())); return(true); } else if (current.ValueKind == JsonValueKind.String && _identifier == "length") { byte[] bytes = Encoding.UTF32.GetBytes(current.GetString().ToCharArray()); value = new DecimalValue(new Decimal(current.GetString().Length)); return(true); } else { value = JsonConstants.Null; return(true); } }
public override bool TryEvaluate(DynamicResources resources, IValue root, JsonLocationNode lastNode, IValue current, ProcessingFlags options, out IValue results) { var elements = new List <IValue>(); INodeReceiver receiver = new ValueReceiver(elements); if (resources.Options.ExecutionMode == PathExecutionMode.Parallel) { receiver = new SynchronizedNodeReceiver(receiver); } Select(resources, root, lastNode, current, receiver, options, 0); results = new ArrayValue(elements); return(true); }
/// <summary> /// Queues the chunk for processing, passthrough to the background processor /// </summary> public static void QueueChunk(Chunk chunk, ProcessingFlags flags) { if (null == _instance) CreateInstance (); _instance._backgroundProcessor.QueueChunk(chunk, flags); }
/// <summary> /// Queues the chunk for processing /// </summary> public void QueueChunk(Chunk chunk, ProcessingFlags flags) { chunk.processSynchronizer.Enqueue(flags); _jobs.Add(chunk); }
public bool IsQueued(ProcessingFlags flags) { lock (_lock) { return ((_queue & flags) != 0); } }