public static IFile CreateFile(this IFolder folder, AbsoluteFilePath path, string utf8Contents, CollisionStrategy collisionStrategy = CollisionStrategy.FailIfExists) { return(CreateFile(folder, path, Encoding.UTF8.GetBytes(utf8Contents), collisionStrategy)); }
public bool CanReplyWith(Type requestType, Type responseType, CollisionStrategy collisionStrategy) { if (!TypesMatch(RequestType, requestType)) { return(false); } if (TypesMatch(ResponseType, responseType)) { return(true); } // The response type may be an awaitable! // (Task<TResponse>, ValueTask<TResponse>, ...) if (!ResponseType.IsAwaitableWithResult(out var awaitResponseType)) { return(false); } if (TypesMatch(awaitResponseType, responseType)) { return(true); } return(false); }
public static IFile CreateFile(this IFileSystem fileSystem, AbsoluteFilePath path, string utf8Contents, CollisionStrategy collisionStrategy = CollisionStrategy.FailIfExists) { return(fileSystem.CreateFolder(path.Folder) .CreateFile(path, utf8Contents, collisionStrategy)); }
public InstanceRecipientInvoker( TypeInspector inspector, IRecipientFactory factory, CollisionStrategy collisionStrategy) { _inspector = inspector; _factory = factory; _collisionStrategy = collisionStrategy; }
protected InstanceRecipient( object instance, IRecipientDescriptor descriptor, IRecipientInvoker invoker, string?name, CollisionStrategy collisionStrategy) : base(instance.GetType(), descriptor, invoker, name, Lifetime.Singleton, collisionStrategy) { _instance = instance; }
public static IFile Move(this IFile file, RelativeFilePath relativePath, CollisionStrategy collisionStrategy = CollisionStrategy.FailIfExists) { if (relativePath == null) { throw new ArgumentNullException("relativePath"); } AbsoluteFilePath newPath = file.Path + relativePath; return(file.Move(newPath, collisionStrategy)); }
protected TypeRecipient( Type type, IRecipientDescriptor descriptor, IRecipientInvoker invoker, string?name, Lifetime lifetime, CollisionStrategy collisionStrategy) : base(descriptor, invoker, name, lifetime, collisionStrategy) { Type = type; }
public static IFile CreateFile(this IFolder folder, AbsoluteFilePath path, byte[] contents, CollisionStrategy collisionStrategy = CollisionStrategy.FailIfExists) { var file = folder.CreateFile(path, collisionStrategy); using (var writer = file.OpenToWrite()) { writer.Write(contents, 0, contents.Length); } return(file); }
public void Deconstruct( out Guid id, out string?name, out Type?type, out Lifetime lifetime, out CollisionStrategy collisionStrategy) { id = Id; name = Name; type = Type; lifetime = Lifetime; collisionStrategy = CollisionStrategy; }
internal RecipientDescription( Guid id, string?name, Type?type, Lifetime lifetime, CollisionStrategy collisionStrategy) { Id = id; Name = name; Type = type; Lifetime = lifetime; CollisionStrategy = collisionStrategy; }
public Recipient( IRecipientDescriptor descriptor, IRecipientInvoker invoker, string?name, Lifetime lifetime, CollisionStrategy collisionStrategy) { _descriptor = descriptor; _invoker = invoker; Name = name; Lifetime = lifetime; CollisionStrategy = collisionStrategy; }
public static TypeRecipient Create <TRecipient>( TypeInspectorRegistry registry, Func <TRecipient> factoryMethod, string?name, Lifetime lifetime, CollisionStrategy collisionStrategy) { if (registry is null) { throw new ArgumentNullException(nameof(registry)); } if (factoryMethod is null) { throw new ArgumentNullException(nameof(factoryMethod)); } if (!lifetime.IsValid()) { throw new ArgumentException($"Invalid {nameof(lifetime)} value: {lifetime}"); } if (!collisionStrategy.IsValid()) { throw new ArgumentException($"Invalid {nameof(collisionStrategy)} value: {collisionStrategy}"); } var inspector = registry.For <TRecipient>(); IRecipientFactory factory = new RecipientFactory(() => factoryMethod() !); if (lifetime != Lifetime.Transient) { factory = new SingletonRecipientFactory(factory); } return(new TypeRecipient( typeof(TRecipient), new TypeRecipientDescriptor(inspector), new InstanceRecipientInvoker(inspector, factory, collisionStrategy), name, lifetime, collisionStrategy)); }
public static InstanceRecipient Create( TypeInspectorRegistry registry, object instance, string?name, CollisionStrategy collisionStrategy) { if (registry is null) { throw new ArgumentNullException(nameof(registry)); } if (instance is null) { throw new ArgumentNullException(nameof(instance)); } if (!collisionStrategy.IsValid()) { throw new ArgumentException($"Invalid {nameof(collisionStrategy)} value: {collisionStrategy}"); } var inspector = registry.For(instance.GetType()); var descriptor = new TypeRecipientDescriptor(inspector); var invoker = new InstanceRecipientInvoker( inspector, new SingletonRecipientFactory(instance), collisionStrategy); return(new InstanceRecipient( instance, descriptor, invoker, name, collisionStrategy)); }
public void HandleCollision(CollisionStrategy collisionStrategy, string elementId) { _state.Handle(collisionStrategy, this, elementId); //await collisionStrategy.ActionAsync(this, elementId); }
public abstract void Handle(CollisionStrategy collisionStrategy, PlayerObject playerObject, string elementId);
public bool CanAccept(Type requestType, CollisionStrategy collisionStrategy) { var requestTypeMatches = TypesMatch(RequestType, requestType); return(requestTypeMatches); }
public IFile CreateFile(string name, CollisionStrategy collisionStrategy = CollisionStrategy.FailIfExists) { throw new NotImplementedException("RamFolder.CreateFile"); }
public IFile Rename(string newFilenameWithExtension, CollisionStrategy collisionStrategy = CollisionStrategy.FailIfExists) { //move? throw new NotImplementedException("SpotFile.Rename"); }
public IFile Move(AbsoluteFilePath absolutePath, CollisionStrategy collisionStrategy = CollisionStrategy.FailIfExists) { //File.Move(); throw new NotImplementedException("SpotFile.Move"); }
public CollisionSolver(CollisionStrategy strategy) { this.strategy = strategy; }
public override async void Handle(CollisionStrategy collisionStrategy, PlayerObject playerObject, string elementId) { StartProtectedTimer(playerObject); await collisionStrategy.ActionAsync(playerObject, elementId); }
public bool CanAccept(Type requestType, CollisionStrategy collisionStrategy) { var accepts = _inspector.HasMethodsAccepting(requestType, collisionStrategy); return(accepts); }
public bool CanReplyWith(Type requestType, Type responseType, CollisionStrategy collisionStrategy) { var repliesWith = _inspector.HasMethodsReturning(requestType, responseType, collisionStrategy); return(repliesWith); }
public override async void Handle(CollisionStrategy collisionStrategy, PlayerObject playerObject, string elementId) { await collisionStrategy.ActionAsync(playerObject, elementId); goNext(playerObject); }
public override void Handle(CollisionStrategy collisionStrategy, PlayerObject playerObject, string elementId) { }