/// <summary> /// Creates a <see cref="ValueComputationActionModel"/> for a given property. /// </summary> public static IEnumerable <ValueComputationActionModel> GetComputedValueAction <TResource, TPropertyConfiguration, TModelConfiguration>( IResourceConfiguration <TPropertyConfiguration, TModelConfiguration> resourceConfiguration) where TResource : class, IRestResource where TPropertyConfiguration : class, IPropertyConfiguration where TModelConfiguration : class, IModelConfiguration { TPropertyConfiguration[] configs = resourceConfiguration.AllPropertyConfigurations.Where(c => c.ValueComputationFunc != null).ToArray(); var paramResource = Expression.Parameter(typeof(object), "resourceObject"); var typedResource = Expression.Variable(typeof(TResource), "typedResource"); var assignTyped = Expression.Assign(typedResource, Expression.Convert(paramResource, typeof(TResource))); var actionModels = new ValueComputationActionModel[configs.Length]; for (int i = 0; i < configs.Length; i++) { var property = Expression.Property(assignTyped, configs[i].PropertyName); var assignProperty = Expression.Assign( Expression.MakeMemberAccess(assignTyped, property.Member), Expression.Convert(configs[i].ValueComputationFunc.ValueComputationFunc.Body, property.Type)); var lambda = Expression.Lambda <Action <object> >( Expression.Block(new[] { typedResource }, assignTyped, assignProperty), paramResource); var compiled = lambda.Compile(); actionModels[i] = new ValueComputationActionModel(compiled, configs[i].ValueComputationFunc.EndpointTriggers); } return(actionModels); }
private Func <object, object> CreatePrimaryKeyFunc(IResourceConfiguration <TPropertyConfiguration, TModelConfiguration> configuration) { return(typeof(ExpressionBuilder) .GetMethod(nameof(ExpressionBuilder.GetPrimaryKeyValueFunc)) .MakeGenericMethod(configuration.ResourceType, typeof(TPropertyConfiguration), typeof(TModelConfiguration)) .Invoke(null, new[] { configuration }) as Func <object, object>); }
/// <summary> /// Instantiates a new instance of <see cref="BootProcedure" /> /// </summary> /// <param name="systemsThatKnowAboutEventProcessors">Provides <see cref="IEventProcessor">Event Processors</see></param> /// <param name="tenants">A collection of all <see cref="ITenants">tenants</see></param> /// <param name="processingHub">An instance of <see cref="IScopedEventProcessingHub" /> for processing <see cref="CommittedEventStream">Committed Event Streams</see></param> /// <param name="getOffsetRepository">A factory function to return a correctly scoped instance of <see cref="IEventProcessorOffsetRepository" /></param> /// <param name="getUnprocessedEventsFetcher">A factory function to return a correctly scoped instance of <see cref="IFetchUnprocessedEvents" /></param> /// <param name="executionContextManager">The <see cref="ExecutionContextManager" /> for setting the correct execution context for the Event Processors </param> /// <param name="resourceConfiguration"></param> /// <param name="boundedContextLoader"></param> /// <param name="environment"></param> /// <param name="logger">An instance of <see cref="ILogger" /> for logging</param> public BootProcedure( IInstancesOf <IKnowAboutEventProcessors> systemsThatKnowAboutEventProcessors, ITenants tenants, IScopedEventProcessingHub processingHub, FactoryFor <IEventProcessorOffsetRepository> getOffsetRepository, FactoryFor <IFetchUnprocessedEvents> getUnprocessedEventsFetcher, IExecutionContextManager executionContextManager, IResourceConfiguration resourceConfiguration, IBoundedContextLoader boundedContextLoader, Execution.Environment environment, ILogger logger) { _processingHub = processingHub; _logger = logger; _tenants = tenants; _systemsThatKnowAboutEventProcessors = systemsThatKnowAboutEventProcessors; _getOffsetRepository = getOffsetRepository; _getUnprocessedEventsFetcher = getUnprocessedEventsFetcher; _executionContextManager = executionContextManager; _resourceConfiguration = resourceConfiguration; _logger = logger; var boundedContextConfig = boundedContextLoader.Load(); _executionContextManager.SetConstants(boundedContextConfig.Application, boundedContextConfig.BoundedContext, environment); }
/// <summary> /// Initialises a new instance of the <see cref="BaseRuntimeConfiguration{TPropertyConfiguration, TModelConfiguration, TResource}"/> class. /// </summary> /// <param name="configuration">The resource configuration.</param> protected BaseRuntimeConfiguration(IResourceConfiguration <TPropertyConfiguration, TModelConfiguration> configuration) { GetPrimaryKeyValue = CreatePrimaryKeyFunc(configuration); ValueComputationActions = CreateValueComputationActions(configuration); AllowedVerbsFlags = configuration.AllowedVerbsFlags; Route = configuration.Route; }
/// <summary> /// Initializes a new instance of the <see cref="BootProcedure"/> class. /// </summary> /// <param name="boundedContextConfiguration"><see cref="BoundedContextConfiguration"/> to use.</param> /// <param name="executionContextManager"><see cref="IExecutionContextManager"/> to use for <see cref="ExecutionContext"/>.</param> /// <param name="resourceConfiguration"><see cref="IResourceConfiguration">Configuration</see> of resources.</param> public BootProcedure( BoundedContextConfiguration boundedContextConfiguration, IExecutionContextManager executionContextManager, IResourceConfiguration resourceConfiguration) { _executionContextManager = executionContextManager; _resourceConfiguration = resourceConfiguration; _boundedContextConfiguration = boundedContextConfiguration; }
public Swiff(IResourceConfiguration config) : base( new EmbeddedLocation(typeof(Swiff).Assembly, "Calyptus.ClientSide.Lib.CompiledSwiff.Upload.swf"), "Upload_Swiff", config.GetResource(new EmbeddedLocation(typeof(Swiff).Assembly, "Calyptus.SwiffClass.js")), new Dictionary<string, string> { { "wMode", "transparent" } } ) { }
public ResourcePackage(IResourceConfiguration configuration, IResourceLocation packageLocation, IEnumerable<IResourceLocation> locations) { _package = configuration.GetResource(packageLocation); if (locations == null) return; List<IResource> res = new List<IResource>(); foreach (IResourceLocation l in locations) { IResource r = configuration.GetResource(l); if (r != null) res.Add(r); } _includedResources = res.Count > 0 ? res.ToArray() : null; }
/// <summary> /// Initializes a new instance of the <see cref="BootProcedure"/> class. /// </summary> /// <param name="eventHorizons"><see cref="EventHorizonsConfiguration">Event horizons configuration</see>.</param> /// <param name="barrier"><see cref="IBarrier">Barrier</see> to penetrate towards an <see cref="IEventHorizon"/>.</param> /// <param name="resourceConfiguration"><see cref="IResourceConfiguration"/> for resources.</param> /// <param name="executionContextManager"><see cref="IExecutionContextManager"/> for working with <see cref="ExecutionContext"/>.</param> /// <param name="application">The running <see cref="Application"/>.</param> /// <param name="boundedContext">The running <see cref="BoundedContext"/>.</param> /// <param name="environment">The running environment.</param> public BootProcedure( EventHorizonsConfiguration eventHorizons, IBarrier barrier, IResourceConfiguration resourceConfiguration, IExecutionContextManager executionContextManager, Application application, BoundedContext boundedContext, Environment environment) { _eventHorizons = eventHorizons; _barrier = barrier; _resourceConfiguration = resourceConfiguration; executionContextManager.SetConstants(application, boundedContext, environment); }
/// <summary> /// Creates a func that returns the primary key value given a resource object. /// </summary> public static Func <object, object> GetPrimaryKeyValueFunc <TResource, TPropertyConfiguration, TModelConfiguration>( IResourceConfiguration <TPropertyConfiguration, TModelConfiguration> config) where TResource : class, IRestResource where TPropertyConfiguration : class, IPropertyConfiguration where TModelConfiguration : class, IModelConfiguration { var paramResource = Expression.Parameter(typeof(object), "resourceObject"); var property = Expression.Convert( Expression.Property(Expression.Convert(paramResource, typeof(TResource)), config.PrimaryIdentifier.PropertyName), typeof(object)); var lambda = Expression.Lambda <Func <object, object> >( property, paramResource); return(lambda.Compile()); }
/// <summary> /// Initializes a new instance of <see cref="BootProcedure"/> /// </summary> /// <param name="configuration"><see cref="IEventHorizonsConfigurationManager">Configuration mananger</see></param> /// <param name="barrier"><see cref="IBarrier">Barrier</see> to penetrate towards an <see cref="IEventHorizon"/></param> /// <param name="resourceConfiguration"></param> /// <param name="boundedContextLoader"></param> /// <param name="executionContextManager"></param> /// <param name="environment">The running environment</param> public BootProcedure( IEventHorizonsConfigurationManager configuration, IBarrier barrier, IResourceConfiguration resourceConfiguration, IBoundedContextLoader boundedContextLoader, IExecutionContextManager executionContextManager, Environment environment) { _configuration = configuration; _barrier = barrier; _resourceConfiguration = resourceConfiguration; _boundedContextLoader = boundedContextLoader; var boundedContextConfig = boundedContextLoader.Load(); executionContextManager.SetConstants(boundedContextConfig.Application, boundedContextConfig.BoundedContext, environment); }
/// <summary> /// Não usaremos, mas se o nosso "Recurso" tivesse "botões customizaddos", este código seria chamado em resposta aos "clicks" /// </summary> /// <param name="helperId">ID do botão clicado na tela de recursos</param> /// <param name="resourceData">Dados do recurso</param> public void InvokeResourceHelper(string helperId, IResourceConfiguration resourceData) { // This method receives an updateable Resource object and the name of the helper button that was pressed. // In order to get a property from the Resource: // string myProperty = resourceData.GetPropertyValue("ResourcePropertyName"); // You should open your own configuration dialogs // MessageBox.Show("Define your configuration dialogs and update the Resource if required"); // In order to set a properties of the Resource: /* * using (IResourceConfigurationWriter writer = resourceData.BeginEditing()) * { * writer.SetPropertyValue("property1","Val1"); * writer.SetPropertyValue("property2","Val2"); * writer.AcceptChanges(); * } */ }
public MooTools(IResourceConfiguration configuration) : base( configuration, new ExternalLocation("http://ajax.googleapis.com/ajax/libs/mootools/1.11/mootools-yui-compressed.js"), ResourceLocations.GetLocations(Assembly.GetExecutingAssembly(), "MooTools.*.js") ) {}
public ResourcePackage(IResourceConfiguration configuration, IResourceLocation packageLocation, params IResourceLocation[] locations) : this(configuration, packageLocation, (IEnumerable<IResourceLocation>)locations) { }
protected override bool IsResourceSupported(IResourceConfiguration resource) { return(resource is MaterialConfiguration); }
protected override bool IsResourceSupported(IResourceConfiguration resource) { return(resource is ComputeProgramConfiguration); }
protected virtual bool IsResourceSupported(IResourceConfiguration resource) { return(resource.Type == targetType); }
private IEnumerable <ValueComputationActionModel> CreateValueComputationActions(IResourceConfiguration <TPropertyConfiguration, TModelConfiguration> configuration) { return(typeof(ExpressionBuilder) .GetMethod(nameof(ExpressionBuilder.GetComputedValueAction)) .MakeGenericMethod(configuration.ResourceType, typeof(TPropertyConfiguration), typeof(TModelConfiguration)) .Invoke(null, new[] { configuration }) as IEnumerable <ValueComputationActionModel>); }
/// <summary> /// Instantiates an instance of <see cref="BootProcedure"/> /// </summary> /// <param name="boundedContextLoader"></param> /// <param name="executionContextManager"></param> /// <param name="resourceConfiguration"></param> public BootProcedure(IBoundedContextLoader boundedContextLoader, IExecutionContextManager executionContextManager, IResourceConfiguration resourceConfiguration) { _boundedContextLoader = boundedContextLoader; _executionContextManager = executionContextManager; _resourceConfiguration = resourceConfiguration; }