Show / Hide Table of Contents

Class ControllerManager

Manages all controllers on server-side. Controllers are server objects which has view on the client. See ContorllerPacking.md for details.

Inheritance
System.Object
ControllerManager
Implements
IThreadedPlugin
IShutdownablePlugin
IDisplayablePlugin
IGUIPlugin
IHasDisplayTabs
IDisplayTab
IInitializablePlugin
IServerPlugin
System.IDisposable
Namespace: Eco.Core.Controller
Assembly: Eco.Core.dll
Syntax
public sealed class ControllerManager : Singleton<ControllerManager>, IThreadedPlugin, IShutdownablePlugin, IDisplayablePlugin, IGUIPlugin, IHasDisplayTabs, IDisplayTab, IInitializablePlugin, IServerPlugin, IDisposable
Remarks

For debugging purposes you may run build with /p:DefineConstants=LOG_VIEW_SYSTEM or you can enable it in .csproj file. In this mode it will produce ViewData-{date}.txt file with sorted view data in stable order.

Constructors

ControllerManager()

Declaration
public ControllerManager()

Fields

ClientGotLotsPendingViews

Declaration
public static ThreadSafeAction<IMvcNetClient> ClientGotLotsPendingViews
Field Value
Type Description
ThreadSafeAction<IMvcNetClient>

ControllerPropertyNotification

Declaration
public static ThreadSafeAction<IController, string, IMvcNetClient> ControllerPropertyNotification
Field Value
Type Description
ThreadSafeAction<IController, System.String, IMvcNetClient>

TypeToMarkedUpName

Declaration
public static Func<Type, LocString> TypeToMarkedUpName
Field Value
Type Description
System.Func<System.Type, LocString>

TypeToTags

Declaration
public static Func<Type, IEnumerable<string>> TypeToTags
Field Value
Type Description
System.Func<System.Type, System.Collections.Generic.IEnumerable<System.String>>

ViewNameToID

Declaration
public ConcurrentDictionary<string, int> ViewNameToID
Field Value
Type Description
System.Collections.Concurrent.ConcurrentDictionary<System.String, System.Int32>

ViewNameToMarshaler

Declaration
public ConcurrentDictionary<string, IControllerMarshaler> ViewNameToMarshaler
Field Value
Type Description
System.Collections.Concurrent.ConcurrentDictionary<System.String, IControllerMarshaler>

ViewTypeData

Declaration
public ViewTypeData ViewTypeData
Field Value
Type Description
ViewTypeData

Properties

Marshalers

Declaration
public IEnumerable<IControllerMarshaler> Marshalers { get; }
Property Value
Type Description
System.Collections.Generic.IEnumerable<IControllerMarshaler>

MarshalersBasestTypes

Find basest types which implements both IPropertyChanged and INotifyPropertyChanged

Declaration
public IEnumerable<Type> MarshalersBasestTypes { get; }
Property Value
Type Description
System.Collections.Generic.IEnumerable<System.Type>

MarshalersControllerTypes

Declaration
public IEnumerable<Type> MarshalersControllerTypes { get; }
Property Value
Type Description
System.Collections.Generic.IEnumerable<System.Type>

ViewData

Declaration
public static BSONValue ViewData { get; }
Property Value
Type Description
BSONValue

Methods

ClearSingleton()

Declaration
public override void ClearSingleton()

ControllerIsRegisteredOrSubscribed(IController)

Declaration
public static bool ControllerIsRegisteredOrSubscribed(IController controller)
Parameters
Type Name Description
IController controller
Returns
Type Description
System.Boolean

Dispose()

Declaration
public void Dispose()

DoWork()

Declaration
public TimeSpan DoWork()
Returns
Type Description
System.TimeSpan

FromBson(BSONObject)

Declaration
public static object FromBson(BSONObject bson)
Parameters
Type Name Description
BSONObject bson
Returns
Type Description
System.Object

GetCategory()

Declaration
public string GetCategory()
Returns
Type Description
System.String

GetController(Int32)

Declaration
public static IController GetController(int id)
Parameters
Type Name Description
System.Int32 id
Returns
Type Description
IController

GetControllerType(Type)

Declaration
public static Type GetControllerType(Type type)
Parameters
Type Name Description
System.Type type
Returns
Type Description
System.Type

GetControllerTypeId(Type)

Returns controller type id (TypeID) for type.

Declaration
public static int GetControllerTypeId(Type type)
Parameters
Type Name Description
System.Type type
Returns
Type Description
System.Int32

GetDisplayText()

Declaration
public string GetDisplayText()
Returns
Type Description
System.String

GetPropertySyncFlags(Type, String)

Declaration
public SyncFlags GetPropertySyncFlags(Type controllerType, string propertyName)
Parameters
Type Name Description
System.Type controllerType
System.String propertyName
Returns
Type Description
SyncFlags

GetStatus()

Declaration
public string GetStatus()
Returns
Type Description
System.String

GetViewClassInfo(Int32)

Declaration
public ViewClassInfo GetViewClassInfo(int id)
Parameters
Type Name Description
System.Int32 id
Returns
Type Description
ViewClassInfo

GetViewClassInfo(String)

Declaration
public ViewClassInfo GetViewClassInfo(string viewTypeName)
Parameters
Type Name Description
System.String viewTypeName
Returns
Type Description
ViewClassInfo

GetViewClassInfo(Type)

Declaration
public ViewClassInfo GetViewClassInfo(Type type)
Parameters
Type Name Description
System.Type type
Returns
Type Description
ViewClassInfo

HandleBoundView(INetClient, Int32)

Declaration
public static void HandleBoundView(INetClient client, int controllerId)
Parameters
Type Name Description
INetClient client
System.Int32 controllerId

HandleReleaseViews(INetClient, ReadOnlySpan<Int32>)

Declaration
public static void HandleReleaseViews(INetClient client, ReadOnlySpan<int> controllerIds)
Parameters
Type Name Description
INetClient client
System.ReadOnlySpan<System.Int32> controllerIds

HandleViewRPC(INetClient, IController, String, BSONObject)

Declaration
public static object HandleViewRPC(INetClient client, IController controller, string methodIdOrName, BSONObject bson)
Parameters
Type Name Description
INetClient client
IController controller
System.String methodIdOrName
BSONObject bson
Returns
Type Description
System.Object

HandleViewRPC(INetClient, Int32, String, BSONObject)

Declaration
public static object HandleViewRPC(INetClient client, int universalID, string methodIdOrName, BSONObject bson)
Parameters
Type Name Description
INetClient client
System.Int32 universalID
System.String methodIdOrName
BSONObject bson
Returns
Type Description
System.Object

HasViewType(Type)

Checks if corresponding View type exists for the controller.

Declaration
public static bool HasViewType(Type type)
Parameters
Type Name Description
System.Type type
Returns
Type Description
System.Boolean
Remarks

Generic types can't have views themselves, so in their case this method checks if generic type definition has a view.

Initialize(TimedTask)

Declaration
public void Initialize(TimedTask timer)
Parameters
Type Name Description
TimedTask timer

NotifyPropertyForClient(IController, String, IMvcNetClient)

Used when needed to notify property to specific client. I.e. when he requested property with attribute MustRequest.

Declaration
public static void NotifyPropertyForClient(IController controller, string propertyName, IMvcNetClient client)
Parameters
Type Name Description
IController controller
System.String propertyName
IMvcNetClient client

PackageBigController(IController, INetClient, PackageFlags)

Declaration
public static BSONValue PackageBigController(IController obj, INetClient client, PackageFlags flags)
Parameters
Type Name Description
IController obj
INetClient client
PackageFlags flags
Returns
Type Description
BSONValue

PackageChanges(IController, String, PoolableListWrapper<ClientNotification>, IMvcNetClient[])

Package all changes into bson. It generates BSON->Clients since same BSON can be notifies to multiply clients.

Declaration
public void PackageChanges(IController controller, string propertyName, PoolableListWrapper<ClientNotification> notifications, IMvcNetClient[] clients = null)
Parameters
Type Name Description
IController controller
System.String propertyName
PoolableListWrapper<ClientNotification> notifications
IMvcNetClient[] clients

PackageController(IController, INetClient, PackageFlags)

You can use it when you don't carry about recollection of related views

Declaration
public static BSONValue PackageController(IController controller, INetClient boundClient, PackageFlags flags)
Parameters
Type Name Description
IController controller
INetClient boundClient
PackageFlags flags
Returns
Type Description
BSONValue

PackageController(IController, in BsonSerializationContext, PackageFlags)

Declaration
public static BSONValue PackageController(IController controller, in BsonSerializationContext context, PackageFlags flags)
Parameters
Type Name Description
IController controller
BsonSerializationContext context
PackageFlags flags
Returns
Type Description
BSONValue

Run()

Declaration
public void Run()

ShutdownAsync()

Declaration
public Task ShutdownAsync()
Returns
Type Description
System.Threading.Tasks.Task

SubscribeController(IController, ISubscriptions<ThreadSafeSubscriptions>, String, Action)

Subscribes to controller and registers subscription in subscriptions.

Declaration
public static void SubscribeController(IController controller, ISubscriptions<ThreadSafeSubscriptions> subscriptions, string propName, Action changedCallback)
Parameters
Type Name Description
IController controller
ISubscriptions<ThreadSafeSubscriptions> subscriptions
System.String propName
System.Action changedCallback

SubscribeController(IController, String, Action, Boolean)

Subscribe on property propName changes for the controller.

Declaration
public static void SubscribeController(IController controller, string propName, Action changedCallback, bool unique = false)
Parameters
Type Name Description
IController controller
System.String propName
System.Action changedCallback
System.Boolean unique

SubscribeControllerAndCall(IController, ISubscriptions<ThreadSafeSubscriptions>, String, Action)

Subscribes to controller, registers subscription in subscriptions and calls changedCallback.

Declaration
public static void SubscribeControllerAndCall(IController controller, ISubscriptions<ThreadSafeSubscriptions> subscriptions, string propName, Action changedCallback)
Parameters
Type Name Description
IController controller
ISubscriptions<ThreadSafeSubscriptions> subscriptions
System.String propName
System.Action changedCallback

SubscribeControllerUnique(IController, ISubscriptions<ThreadSafeSubscriptions>, String, Action)

Subscribes to controller (unique) and registers subscription in subscriptions.

Declaration
public static void SubscribeControllerUnique(IController controller, ISubscriptions<ThreadSafeSubscriptions> subscriptions, string propName, Action changedCallback)
Parameters
Type Name Description
IController controller
ISubscriptions<ThreadSafeSubscriptions> subscriptions
System.String propName
System.Action changedCallback

SubscribeControllerUniqueAndCall(IController, ISubscriptions<ThreadSafeSubscriptions>, String, Action)

Subscribes to controller, registers subscription in subscriptions and calls changedCallback.

Declaration
public static void SubscribeControllerUniqueAndCall(IController controller, ISubscriptions<ThreadSafeSubscriptions> subscriptions, string propName, Action changedCallback)
Parameters
Type Name Description
IController controller
ISubscriptions<ThreadSafeSubscriptions> subscriptions
System.String propName
System.Action changedCallback

SubscribeWithoutTracking(IController, String, Action)

Creates a subscription but doesnt track it within a Subscriptions object. Should only be used when something is subscribing to its own properties, meaning both 'watched' and 'watcher' are a single object and die at the same time.

Declaration
public static ISubscription SubscribeWithoutTracking(IController controller, string propname, Action callback)
Parameters
Type Name Description
IController controller
System.String propname
System.Action callback
Returns
Type Description
ISubscription

ToString()

Declaration
public override string ToString()
Returns
Type Description
System.String

TryGetViewClassInfo(Type, out ViewClassInfo)

Declaration
public bool TryGetViewClassInfo(Type type, out ViewClassInfo viewClassInfo)
Parameters
Type Name Description
System.Type type
ViewClassInfo viewClassInfo
Returns
Type Description
System.Boolean

UnsubscribeController(IController, String, Action)

Declaration
public static bool UnsubscribeController(IController controller, string propname, Action changedCallback)
Parameters
Type Name Description
IController controller
System.String propname
System.Action changedCallback
Returns
Type Description
System.Boolean

Implements

IThreadedPlugin
IShutdownablePlugin
IDisplayablePlugin
IGUIPlugin
IHasDisplayTabs
IDisplayTab
IInitializablePlugin
IServerPlugin
System.IDisposable

Extension Methods

PropertyChanges.FirePropertyChanged(Object, String)
PropertyChanges.FirePropertyChanged(Object, String, Object, Object)
PropertyChanges.FirePropertyChanged(Object, MemberChangedBeforeAfterEventArgs)
☀
☾
In This Article
Back to top
Copyright (c) Strange Loop Games 2021
☀
☾