Ejemplo n.º 1
0
        public Either <string, bool> HasStateTypeOf <T>()
        {
            if (Cluster.Exists(ActorInboxCommon.ClusterMetaDataKey(ProcessId)))
            {
                var meta = Cluster.GetValue <ProcessMetaData>(ActorInboxCommon.ClusterMetaDataKey(ProcessId));
                if (meta == null)
                {
                    return(true);
                }

                return(TypeHelper.HasStateTypeOf(typeof(T), meta.StateTypeInterfaces));
            }
            else
            {
                return(true);
            }
        }
        public bool HasStateTypeOf <T>()
        {
            Try <bool> valid = () =>
            {
                if (Cluster.Exists(ActorInboxCommon.ClusterMetaDataKey(ProcessId)))
                {
                    var meta = Cluster.GetValue <ProcessMetaData>(ActorInboxCommon.ClusterMetaDataKey(ProcessId));

                    var rhsType = meta == null
                        ? null
                        : Type.GetType(meta.StateTypeName)?.GetTypeInfo();

                    return(meta == null || rhsType == null
                        ? true
                        : typeof(T).GetTypeInfo().IsAssignableFrom(rhsType));
                }
                else
                {
                    return(true);
                }
            };

            return(valid.IfFail(true));
        }