Beispiel #1
0
 public static void SetVoid(this RdEndpoint <Unit, Unit> endpoint, Action handler)
 {
     endpoint.Set(req =>
     {
         handler();
         return(Unit.Instance);
     });
 }
Beispiel #2
0
 public static void SetVoid <TReq>(this RdEndpoint <TReq, Unit> endpoint, Action <TReq> handler)
 {
     endpoint.Set(req =>
     {
         handler(req);
         return(Unit.Instance);
     });
 }
Beispiel #3
0
 public static void SetAndLogErrors <TReq, TRes>(this RdEndpoint <TReq, TRes> endpoint, Func <TReq, TRes> handler, ILog logger)
 {
     endpoint.Set(req =>
     {
         try
         {
             return(handler(req));
         }
         catch (Exception ex)
         {
             logger.Error(ex);
             throw;
         }
     });
 }
Beispiel #4
0
 public static void SetAndLogErrors <TReq, TRes>(this RdEndpoint <TReq, TRes> endpoint, Action <TReq, RdTask <TRes> > handler, ILog logger)
 {
     endpoint.Set((lifetime, req) =>
     {
         try
         {
             var task = new RdTask <TRes>();
             handler(req, task);
             return(task);
         }
         catch (Exception ex)
         {
             logger.Error(ex);
             throw;
         }
     });
 }
        //primary constructor
        public UnityModel(
            [NotNull] RdProperty <bool> play,
            [NotNull] RdProperty <bool> pause,
            [NotNull] RdCall <RdVoid, RdVoid> step,
            [NotNull] RdProperty <string> unityPluginVersion,
            [NotNull] RdProperty <int> riderProcessId,
            [NotNull] RdProperty <string> applicationPath,
            [NotNull] RdProperty <string> applicationVersion,
            [NotNull] RdProperty <UnityLogModelInitialized> logModelInitialized,
            [NotNull] RdEndpoint <RdVoid, bool> isClientConnected,
            [NotNull] RdEndpoint <RdOpenFileArgs, bool> openFileLineCol,
            [NotNull] RdCall <string, bool> updateUnityPlugin,
            [NotNull] RdCall <RdVoid, RdVoid> refresh
            )
        {
            if (play == null)
            {
                throw new ArgumentNullException("play");
            }
            if (pause == null)
            {
                throw new ArgumentNullException("pause");
            }
            if (step == null)
            {
                throw new ArgumentNullException("step");
            }
            if (unityPluginVersion == null)
            {
                throw new ArgumentNullException("unityPluginVersion");
            }
            if (riderProcessId == null)
            {
                throw new ArgumentNullException("riderProcessId");
            }
            if (applicationPath == null)
            {
                throw new ArgumentNullException("applicationPath");
            }
            if (applicationVersion == null)
            {
                throw new ArgumentNullException("applicationVersion");
            }
            if (logModelInitialized == null)
            {
                throw new ArgumentNullException("logModelInitialized");
            }
            if (isClientConnected == null)
            {
                throw new ArgumentNullException("isClientConnected");
            }
            if (openFileLineCol == null)
            {
                throw new ArgumentNullException("openFileLineCol");
            }
            if (updateUnityPlugin == null)
            {
                throw new ArgumentNullException("updateUnityPlugin");
            }
            if (refresh == null)
            {
                throw new ArgumentNullException("refresh");
            }

            _Play  = play;
            _Pause = pause;
            _Step  = step;
            _UnityPluginVersion   = unityPluginVersion;
            _RiderProcessId       = riderProcessId;
            _ApplicationPath      = applicationPath;
            _ApplicationVersion   = applicationVersion;
            _LogModelInitialized  = logModelInitialized;
            _IsClientConnected    = isClientConnected;
            _OpenFileLineCol      = openFileLineCol;
            _UpdateUnityPlugin    = updateUnityPlugin;
            _Refresh              = refresh;
            _Play.OptimizeNested  = true;
            _Pause.OptimizeNested = true;
            _UnityPluginVersion.OptimizeNested = true;
            _RiderProcessId.OptimizeNested     = true;
            _ApplicationPath.OptimizeNested    = true;
            _ApplicationVersion.OptimizeNested = true;
        }
        //primary constructor
        private UnityModel(
            [NotNull] RdProperty <bool> play,
            [NotNull] RdProperty <bool> pause,
            [NotNull] RdEndpoint <RdVoid, RdVoid> step,
            [NotNull] RdProperty <string> unityPluginVersion,
            [NotNull] RdProperty <int> riderProcessId,
            [NotNull] RdProperty <string> applicationPath,
            [NotNull] RdProperty <string> applicationVersion,
            [NotNull] RdProperty <UnityLogModelInitialized> logModelInitialized,
            [NotNull] RdCall <RdVoid, bool> isBackendConnected,
            [NotNull] RdEndpoint <RdVoid, UnityEditorState> getUnityEditorState,
            [NotNull] RdCall <RdOpenFileArgs, bool> openFileLineCol,
            [NotNull] RdEndpoint <string, bool> updateUnityPlugin,
            [NotNull] RdEndpoint <bool, RdVoid> refresh,
            [NotNull] RdProperty <JetBrains.Platform.Unity.Model.UnitTestLaunch> unitTestLaunch
            )
        {
            if (play == null)
            {
                throw new ArgumentNullException("play");
            }
            if (pause == null)
            {
                throw new ArgumentNullException("pause");
            }
            if (step == null)
            {
                throw new ArgumentNullException("step");
            }
            if (unityPluginVersion == null)
            {
                throw new ArgumentNullException("unityPluginVersion");
            }
            if (riderProcessId == null)
            {
                throw new ArgumentNullException("riderProcessId");
            }
            if (applicationPath == null)
            {
                throw new ArgumentNullException("applicationPath");
            }
            if (applicationVersion == null)
            {
                throw new ArgumentNullException("applicationVersion");
            }
            if (logModelInitialized == null)
            {
                throw new ArgumentNullException("logModelInitialized");
            }
            if (isBackendConnected == null)
            {
                throw new ArgumentNullException("isBackendConnected");
            }
            if (getUnityEditorState == null)
            {
                throw new ArgumentNullException("getUnityEditorState");
            }
            if (openFileLineCol == null)
            {
                throw new ArgumentNullException("openFileLineCol");
            }
            if (updateUnityPlugin == null)
            {
                throw new ArgumentNullException("updateUnityPlugin");
            }
            if (refresh == null)
            {
                throw new ArgumentNullException("refresh");
            }
            if (unitTestLaunch == null)
            {
                throw new ArgumentNullException("unitTestLaunch");
            }

            _Play  = play;
            _Pause = pause;
            _Step  = step;
            _UnityPluginVersion   = unityPluginVersion;
            _RiderProcessId       = riderProcessId;
            _ApplicationPath      = applicationPath;
            _ApplicationVersion   = applicationVersion;
            _LogModelInitialized  = logModelInitialized;
            _IsBackendConnected   = isBackendConnected;
            _GetUnityEditorState  = getUnityEditorState;
            _OpenFileLineCol      = openFileLineCol;
            _UpdateUnityPlugin    = updateUnityPlugin;
            _Refresh              = refresh;
            _UnitTestLaunch       = unitTestLaunch;
            _Play.OptimizeNested  = true;
            _Pause.OptimizeNested = true;
            _UnityPluginVersion.OptimizeNested = true;
            _RiderProcessId.OptimizeNested     = true;
            _ApplicationPath.OptimizeNested    = true;
            _ApplicationVersion.OptimizeNested = true;
            BindableChildren.Add(new KeyValuePair <string, object>("play", _Play));
            BindableChildren.Add(new KeyValuePair <string, object>("pause", _Pause));
            BindableChildren.Add(new KeyValuePair <string, object>("step", _Step));
            BindableChildren.Add(new KeyValuePair <string, object>("unityPluginVersion", _UnityPluginVersion));
            BindableChildren.Add(new KeyValuePair <string, object>("riderProcessId", _RiderProcessId));
            BindableChildren.Add(new KeyValuePair <string, object>("applicationPath", _ApplicationPath));
            BindableChildren.Add(new KeyValuePair <string, object>("applicationVersion", _ApplicationVersion));
            BindableChildren.Add(new KeyValuePair <string, object>("logModelInitialized", _LogModelInitialized));
            BindableChildren.Add(new KeyValuePair <string, object>("isBackendConnected", _IsBackendConnected));
            BindableChildren.Add(new KeyValuePair <string, object>("getUnityEditorState", _GetUnityEditorState));
            BindableChildren.Add(new KeyValuePair <string, object>("openFileLineCol", _OpenFileLineCol));
            BindableChildren.Add(new KeyValuePair <string, object>("updateUnityPlugin", _UpdateUnityPlugin));
            BindableChildren.Add(new KeyValuePair <string, object>("refresh", _Refresh));
            BindableChildren.Add(new KeyValuePair <string, object>("unitTestLaunch", _UnitTestLaunch));
        }
Beispiel #7
0
 public static void Write(SerializationCtx ctx, UnsafeWriter writer, RdEndpoint <TReq, TRes> value)
 {
     RdId.Write(writer, value.RdId);
 }
Beispiel #8
0
 public static void Set <TReq, TRes>(this RdEndpoint <TReq, TRes> endpoint, Func <Lifetime, TReq, Task <TRes> > handler)
 {
     endpoint.Set((lt, req) => handler(lt, req).ToRdTask(lt));
 }
Beispiel #9
0
 public static void SetVoid <TRes>(this RdEndpoint <Unit, TRes> endpoint, Func <TRes> handler)
 {
     endpoint.Set(req => handler());
 }