public bool IsSatisfiedBy(ISourceContext context) { if (RequestedType == context.SourceType) { TypeToUse = context.SourceType; return(true); } var discovered = RequestedType.BaseType; while (discovered != null) { if (discovered == context.SourceType) { TypeToUse = discovered; return(true); } discovered = discovered.BaseType; } if (RequestedType.GetInterfaces().Length <= 0) { return(false); } foreach (var theInterfaceType in RequestedType.GetInterfaces()) { if (context.SourceType == theInterfaceType) { TypeToUse = theInterfaceType; return(true); } } return(false); }
public bool IsSatisfiedBy(ISourceContext context) { if(RequestedType==context.SourceType) { TypeToUse = context.SourceType; return true; } var discovered = RequestedType.BaseType; while (discovered != null) { if(discovered==context.SourceType) { TypeToUse = discovered; return true; } discovered = discovered.BaseType; } if (RequestedType.GetInterfaces().Length <= 0) { return false; } foreach (var theInterfaceType in RequestedType.GetInterfaces()) { if (context.SourceType == theInterfaceType) { TypeToUse = theInterfaceType; return true; } } return false; }
public ExtractPagesTests() { this.persistence = Substitute.For <ISourcesPersistence>(); this.sourceRepository = Substitute.For <ISourcesRepository>(); this.context = Substitute.For <ISourceContext>(); this.imageService = new FakeImageService(); var matcher = Substitute.For <IUriTemplateMatcher>(); this.httpMessageHandler = new MockHttpMessageHandler(); matcher.Match <Brochure>(Arg.Any <Uri>()) .Returns(new UriTemplateMatches(new Dictionary <string, object> { { "id", 10 }, })); this.sourceRepository.GetBrochure(Arg.Any <Uri>()) .Returns(Task.FromResult(new Brochure { Id = new Uri(SourceId), })); this.functions = new ExtractPages( this.sourceRepository, this.imageService, matcher, this.context, this.persistence); this.functions.Client = this.httpMessageHandler.ToHttpClient(); }
public DestinationConfigurationMemento(Type destinationType, IDescribeMappableProperty[] destinationProperties, ISourceContext[] sourceContexts, Convention[] conventions) { DestinationType = destinationType; DestinationProperties = destinationProperties; SourceContexts = sourceContexts; Conventions = conventions; }
/// <summary> /// Inicializa a instancia com os parametros informados. /// </summary> /// <param name="parameters">Dicionário com os parametros de inicialização.</param> public void Init(System.Collections.IDictionary parameters) { var sourceContext = parameters["sourceContext"] as ISourceContext; var manager = parameters["manager"] as IDataCacheManager; var logger = parameters["logger"] as Colosoft.Logging.ILogger; var typeSchema = parameters["typeSchema"] as Colosoft.Data.Schema.ITypeSchema; var cacheLoaderObserver = parameters["cacheLoaderObserver"] as ICacheLoaderObserver; var typesMetadata = parameters["typesMetadata"] as IList <ITypeMetadata>; sourceContext.Require("sourceContext").NotNull(); manager.Require("manager").NotNull(); if (typesMetadata == null) { typeSchema.Require("typeSchema").NotNull(); } logger.Require("logger").NotNull(); _sourceContext = sourceContext; _manager = manager; _logger = logger; _typeSchema = typeSchema; _typesMetadata = typesMetadata; _started = false; if (cacheLoaderObserver != null) { _observer += cacheLoaderObserver; } }
public SourcesRepository( ISourceContext context, EntityFactory factory, IUriTemplateMatcher matcher) { this.context = context; this.factory = factory; this.matcher = matcher; }
public SourceStorageLocationModule( IModelTemplateProvider provider, ISourceContext sourcesContext) : base(provider) { this.RequiresPermissions(Permissions.AdminSources); this.sourcesContext = sourcesContext; this.Put <StorageLocation>(this.UpdateStorageLocation); }
public EntityFactory( IUriTemplateExpander expander, IWikibusConfiguration configuration, [AllowNull] ClaimsPrincipal principal, ISourceContext context) { this.expander = expander; this.configuration = configuration; this.principal = principal; this.context = context; }
public GoogleDriveImport( IDriveServiceFacade drive, ISourceContext context, ISourcesPersistence persistence, IPdfService pdfService) { this.drive = drive; this.context = context; this.persistence = persistence; this.pdfService = pdfService; }
public void Run(ISourceContext <long> ctx) { while (_isRunning && _counter < 1000) { lock (ctx.GetCheckpointLock()) { ctx.Collect(_counter); _counter++; } } }
public void Run(ISourceContext <T> ctx) { var stream = new MemoryStream(_elementsSerialized); var input = new DataInputViewStreamWrapper(stream); // if we are restored from a checkpoint and need to skip elements, skip them now. var toSkip = _numElementsToSkip; if (toSkip <= 0) { return; } try { while (toSkip > 0) { _serializer.Deserialize(input); toSkip--; } } catch (Exception e) { throw new IOException("Failed to deserialize an element from the source. " + "If you are using user-defined serialization (Value and Writable types), check the " + "serialization functions.\nSerializer is " + _serializer, e); } _numElementsEmitted = _numElementsToSkip; var mutex = ctx.GetCheckpointLock(); while (_isRunning && _numElementsEmitted < _numElements) { T next; try { next = _serializer.Deserialize(input); } catch (Exception e) { throw new IOException("Failed to deserialize an element from the source. " + "If you are using user-defined serialization (Value and Writable types), check the " + "serialization functions.\nSerializer is " + _serializer, e); } lock (mutex) { ctx.Collect(next); _numElementsEmitted++; } } }
public GoogleDriveImportTests() { this.context = Substitute.For <ISourceContext>(); this.drive = Substitute.For <IDriveServiceFacade>(); this.pdfService = Substitute.For <IPdfService>(); this.persistence = Substitute.For <ISourcesPersistence>(); this.sut = new GoogleDriveImport( this.drive, this.context, this.persistence, this.pdfService); }
public ExtractPages( ISourcesRepository sources, ISourceImageService imageService, IUriTemplateMatcher matcher, ISourceContext sourcesContext, ISourcesPersistence persistence) { this.sources = sources; this.imageService = imageService; this.matcher = matcher; this.sourcesContext = sourcesContext; this.persistence = persistence; this.Client = new HttpClient(); }
/// <summary> /// Initializes a new instance of the <see cref="SourceImagesModule"/> class. /// </summary> public SourceImagesModule( IImageStorage storage, ISourceContext data) { this.RequiresAnyPermissions(Permissions.WriteSources, Permissions.AdminSources); this.imageService = new SourceImageService(storage, data); this.storage = storage; this.data = data; this.Post("/book/{id}/images", request => this.UploadImages((int)request.id)); this.Post("/brochure/{id}/images", request => this.UploadImages((int)request.id)); this.Delete("image/{publicId*}", this.DeleteImage); this.Post("image/{publicId*}", this.ReorderImages); }
/// <summary> /// Construtor padrão. /// </summary> /// <param name="sourceContext"></param> /// <param name="sourceProvider"></param> public LinqSourceContext(ISourceContext sourceContext, ISourceProvider sourceProvider) { _sourceContext = sourceContext; _sourceProvider = sourceProvider; }
public SourcesPersistence(ISourceContext context, IUriTemplateMatcher matcher, IUriTemplateExpander expander) { this.context = context; this.matcher = matcher; this.expander = expander; }
public PropertyChangedNotifyingProperty(ISourceContext <TSource> sourceContext, string name) { this.sourceContext = sourceContext; this.Name = name; }
public WishlistRepository(ISourceContext context, IUriTemplateExpander expander) { this.context = context; this.expander = expander; }
public CloningSourceContext(ISourceContext inner) { this.inner = inner; }
public DependencyNotifyingProperty(ISourceContext <TSource> sourceContext, DependencyProperty dependencyProperty) { this.sourceContext = sourceContext; this.DependencyProperty = dependencyProperty; }
public EventNotifyingProperty(ISourceContext <TSource> sourceContext, Func <TSource, Action, TEventHandler> subscribe, Action <TSource, TEventHandler> unsubscribe) { this.sourceContext = sourceContext; this.subscribe = subscribe; this.unsubscribe = unsubscribe; }
public User(ManagementClientFactory clientFactory, IConfiguration configuration, ISourceContext context) { this.clientFactory = clientFactory; this.configuration = configuration; this.context = context; }
public SourceImageService([AllowNull] IImageStorage storage, [AllowNull] ISourceContext data) { this.storage = storage; this.data = data; }