Beispiel #1
0
        internal ActionResult InvokeWithCachedArgs(IRSRuntimeEntity inTarget, ExecutionScope inContext)
        {
            if (CheckEntityActive && !inTarget.IsActive())
            {
                inContext.Logger?.Warn("Unable to perform action {0} on Entity \"{1}\" ({2}) - entity is inactive", Id, inTarget.Name, inTarget.Id);
                return(ActionResult.Inactive());
            }

            object thisArg;
            bool   bValid = PrepContext(inTarget, inContext, out thisArg);

            if (!bValid)
            {
                if (m_MethodSettings.ComponentType != null)
                {
                    inContext.Logger?.Error("Unable to perform action {0} on Entity \"{1}\" ({2}) - missing component type {3}", Id, inTarget?.Name, inTarget != null ? inTarget.Id : RSEntityId.Null, m_MethodSettings.ComponentType);
                    return(ActionResult.NoComponent(m_MethodSettings.ComponentType));
                }
                else
                {
                    inContext.Logger?.Error("Unable to perform action {0} on Entity \"{1}\" ({2})", Id, inTarget?.Name, inTarget != null ? inTarget.Id : RSEntityId.Null);
                    return(ActionResult.NoEntity());
                }
            }

            object result = m_MethodInfo.Invoke(thisArg, m_CachedArguments);

            return(new ActionResult(result));
        }
Beispiel #2
0
        public void RegisterDataLoader(Type type,
                                       string key,
                                       ExecutionScope scope,
                                       Func <IServiceProvider, object> loaderFactory             = null,
                                       Func <object, CancellationToken, Task> triggerLoaderAsync = null)
        {
            if (key == null)
            {
                throw new ArgumentNullException(nameof(key));
            }

            Func <IServiceProvider, object> factory = null;

            if (loaderFactory != null)
            {
                factory = loaderFactory;
            }

            TriggerDataLoaderAsync trigger = null;

            if (triggerLoaderAsync != null)
            {
                trigger = (o, c) => triggerLoaderAsync(o, c);
            }

            var descriptor = new DataLoaderDescriptor(
                key, type, scope,
                factory,
                trigger);

            _dataLoaders[key] = descriptor;
        }
Beispiel #3
0
        public IDisposable CreateExecutionScope()
        {
            var scope = new ExecutionScope(x => m_scopes.Pop());

            m_scopes.Push(scope);
            return(scope);
        }
        public void TestDefaultScope()
        {
            IExecutionScope scope = new ExecutionScope();

            TestScope(scope, "x", "y", "test");
            TestSubScope(scope, "x", "y", "test");
        }
 public static void RegisterDataLoader <TLoader>(
     this ISchemaConfiguration configuration,
     ExecutionScope scope)
     where TLoader : class, IDataLoader
 {
     throw new NotSupportedException(
               "This method is no longer supported.");
 }
 public bool HasSetup(ExecutionScope scope)
 {
     if (scope == ExecutionScope.OncePerMethod)
     {
         return(SetupAction != null);
     }
     return(PerPassSetupAction != null);
 }
Beispiel #7
0
        public static void RegisterDataLoader(
            this ISchemaConfiguration configuration,
            Type type,
            ExecutionScope scope)

        {
            RegisterDataLoader(configuration, type, type.FullName, scope);
        }
Beispiel #8
0
        protected void Application_Start()
        {
            var executionScope = new ExecutionScope();

            executionScope.Configure();

            GlobalConfiguration.Configure(WebApiConfig.Register);
        }
Beispiel #9
0
 public static void RegisterDataLoader <TLoader>(
     this ISchemaConfiguration configuration,
     ExecutionScope scope)
     where TLoader : class, IDispatchableDataLoader
 {
     RegisterDataLoader <TLoader>(
         configuration, typeof(TLoader).FullName, scope);
 }
 public void RegisterDataLoader <T>(
     string key,
     ExecutionScope scope,
     Func <IServiceProvider, T> loaderFactory             = null,
     Func <T, CancellationToken, Task> triggerLoaderAsync = null)
 {
     throw new NotSupportedException();
 }
 public bool HasTeardown(ExecutionScope scope)
 {
     if (scope == ExecutionScope.OncePerMethod)
     {
         return(TeardownAction != null);
     }
     return(PerPassTeardownAction != null);
 }
 private static ISchema CreateSchema(ExecutionScope scope)
 {
     return(Schema.Create(c =>
     {
         c.Options.ExecutionTimeout = TimeSpan.FromSeconds(30);
         c.RegisterDataLoader <TestDataLoader>(scope);
         c.RegisterQueryType <Query>();
     }));
 }
Beispiel #13
0
 public static void RegisterDataLoader(
     this ISchemaConfiguration configuration,
     Type type,
     ExecutionScope scope,
     Func <IServiceProvider, IDispatchableDataLoader> loaderFactory)
 {
     RegisterDataLoader(configuration, type,
                        type.FullName, scope, loaderFactory);
 }
 public static void RegisterLoader <T>(
     this IDataLoaderConfiguration configuration,
     ExecutionScope scope,
     Func <IServiceProvider, T> loaderFactory             = null,
     Func <T, CancellationToken, Task> triggerLoaderAsync = null)
 {
     configuration.RegisterLoader <T>(
         typeof(T).FullName, scope, loaderFactory, triggerLoaderAsync);
 }
        public static void RegisterDataLoader(
            this ISchemaConfiguration configuration,
            Type type,
            ExecutionScope scope)

        {
            throw new NotSupportedException(
                      "This method is no longer supported.");
        }
Beispiel #16
0
 public static void RegisterDataLoader <TLoader>(
     this ISchemaConfiguration configuration,
     ExecutionScope scope,
     Func <IServiceProvider, TLoader> loaderFactory)
     where TLoader : IDispatchableDataLoader
 {
     RegisterDataLoader <TLoader>(configuration,
                                  typeof(TLoader).FullName, scope, loaderFactory);
 }
Beispiel #17
0
        public string StopPropagationAction1(bool cancel = false)
        {
            if (cancel)
            {
                ExecutionScope.StopPropagation();
            }

            return("StopPropagationCommand2.StopPropagationAction1");
        }
 public static void RegisterDataLoader(
     this ISchemaConfiguration configuration,
     Type type,
     ExecutionScope scope,
     Func <IServiceProvider, IDataLoader> loaderFactory)
 {
     throw new NotSupportedException(
               "This method is no longer supported.");
 }
Beispiel #19
0
 public static void RegisterDataLoader <TLoader>(
     this ISchemaConfiguration configuration,
     string key,
     ExecutionScope scope)
     where TLoader : class, IDispatchableDataLoader
 {
     configuration.RegisterDataLoader <TLoader>(key, scope,
                                                triggerLoaderAsync: (d, c) => d.DispatchAsync());
 }
        private static ISchema CreateSchema(ExecutionScope scope)
        {
            return(Schema.Create(c =>
            {
                c.Options.DeveloperMode = true;

                c.RegisterDataLoader <TestDataLoader>(scope);
                c.RegisterQueryType <Query>();
            }));
        }
 public CustomContextDescriptor(
     Type type,
     Func <IServiceProvider, object> factory,
     ExecutionScope scope)
 {
     Type = type
            ?? throw new ArgumentNullException(nameof(type));
     Factory = factory;
     Scope   = scope;
 }
Beispiel #22
0
 public static void RegisterDataLoader <TLoader>(
     this ISchemaConfiguration configuration,
     string key,
     ExecutionScope scope,
     Func <IServiceProvider, TLoader> loaderFactory)
     where TLoader : IDispatchableDataLoader
 {
     configuration.RegisterDataLoader <TLoader>(
         key, scope, loaderFactory, (d, c) => d.DispatchAsync());
 }
 public static void RegisterDataLoader <TLoader>(
     this ISchemaConfiguration configuration,
     string key,
     ExecutionScope scope,
     Func <IServiceProvider, TLoader> loaderFactory)
     where TLoader : IDataLoader
 {
     throw new NotSupportedException(
               "This method is no longer supported.");
 }
Beispiel #24
0
        public static void RegisterDataLoader(
            this ISchemaConfiguration configuration,
            Type type,
            string key,
            ExecutionScope scope,
            Func <IServiceProvider, IDispatchableDataLoader> loaderFactory)

        {
            configuration.RegisterDataLoader(type, key, scope, loaderFactory,
                                             (d, c) => ((IDispatchableDataLoader)d).DispatchAsync());
        }
Beispiel #25
0
        public static void RegisterDataLoader(
            this ISchemaConfiguration configuration,
            Type type,
            string key,
            ExecutionScope scope)

        {
            configuration.RegisterDataLoader(type, key, scope,
                                             triggerLoaderAsync: (d, c) => ((IDispatchableDataLoader)d)
                                             .DispatchAsync());
        }
Beispiel #26
0
 internal void PrepArguments(RSValue[] inArgs, ExecutionScope inScope)
 {
     if (inArgs != null && inArgs.Length > 0)
     {
         for (int i = 0; i < inArgs.Length && i + m_MethodSettings.EditorArgsStartIndex < m_CachedArguments.Length; ++i)
         {
             int idx = m_MethodSettings.EditorArgsStartIndex + i;
             m_CachedArguments[idx] = RSInterop.ToObject(m_Parameters[idx].ParameterType, inArgs[i], inScope);
         }
     }
 }
Beispiel #27
0
 public DataLoaderDescriptor(
     string key,
     Type type,
     ExecutionScope scope,
     Func <IServiceProvider, object> factory,
     TriggerDataLoaderAsync triggerLoadAsync)
 {
     Key              = key ?? throw new ArgumentNullException(nameof(key));
     Type             = type ?? throw new ArgumentNullException(nameof(type));
     Scope            = scope;
     Factory          = factory;
     TriggerLoadAsync = triggerLoadAsync;
 }
        private void Initialize(ExecutionScope scope, Privileges privileges, int iMinimumSimilarity, MatchCommand mcConfirmationCommand, string strFailedRequirementsMessage) {
            this.ExecutionScope = scope;
            this.RequiredPrivileges = privileges;
            this.MinimumMatchSimilarity = iMinimumSimilarity;
            this.ConfirmationCommand = mcConfirmationCommand;

            if (strFailedRequirementsMessage.Length < 100) {
                this.FailedRequirementsMessage = strFailedRequirementsMessage;
            }
            else {
                this.FailedRequirementsMessage = strFailedRequirementsMessage.Substring(0, 100);
            }
        }
Beispiel #29
0
 private static ISchema CreateSchema(ExecutionScope scope)
 {
     return(Schema.Create("type Query { a: String }", c =>
     {
         c.RegisterCustomContext <MyCustomContext>(scope);
         c.BindResolver(ctx =>
         {
             MyCustomContext cctx = ctx.CustomContext <MyCustomContext>();
             cctx.Count = cctx.Count + 1;
             return cctx.Count.ToString();
         }).To("Query", "a");
     }));
 }
Beispiel #30
0
        private void Initialize(ExecutionScope scope, Privileges privileges, int iMinimumSimilarity, MatchCommand mcConfirmationCommand, string strFailedRequirementsMessage)
        {
            this.ExecutionScope         = scope;
            this.RequiredPrivileges     = privileges;
            this.MinimumMatchSimilarity = iMinimumSimilarity;
            this.ConfirmationCommand    = mcConfirmationCommand;

            if (strFailedRequirementsMessage.Length < 100)
            {
                this.FailedRequirementsMessage = strFailedRequirementsMessage;
            }
            else
            {
                this.FailedRequirementsMessage = strFailedRequirementsMessage.Substring(0, 100);
            }
        }
Beispiel #31
0
        public void RegisterCustomContext <T>(
            ExecutionScope scope,
            Func <IServiceProvider, T> contextFactory = null)
        {
            Func <IServiceProvider, object> factory = null;

            if (contextFactory != null)
            {
                factory = new Func <IServiceProvider, object>(
                    sp => contextFactory(sp));
            }

            var descriptor = new CustomContextDescriptor(
                typeof(T), factory, scope);

            _customContexts[typeof(T)] = descriptor;
        }
 public ExecutionRequirements(ExecutionScope scope, int iMinimumSimilarity, MatchCommand mcConfirmationCommand)
 {
     this.Initialize(scope, Privileges.CanLogin, iMinimumSimilarity, mcConfirmationCommand, string.Empty);
 }
 public ExecutionRequirements(ExecutionScope scope)
 {
     this.Initialize(scope, Privileges.CanLogin, int.MaxValue, null, string.Empty);
 }
 public ExecutionRequirements(ExecutionScope scope, Privileges privileges, string strFailedRequirementsMessage)
 {
     this.Initialize(scope, privileges, int.MaxValue, null, strFailedRequirementsMessage);
 }
 public ExecutionRequirements(ExecutionScope scope, Privileges privileges, int iMinimumSimilarity, MatchCommand mcConfirmationCommand, string strFailedRequirementsMessage)
 {
     this.Initialize(scope, privileges, iMinimumSimilarity, mcConfirmationCommand, strFailedRequirementsMessage);
 }