Show / Hide Table of Contents

Class View

Inheritance
System.Object
View
Implements
IView
IViewController
IObservable
Namespace: Eco.Shared.View
Assembly: Eco.Shared.dll
Syntax
public class View : Object, IView, IViewController, IObservable

Constructors

View(View.ViewData)

Declaration
protected View(View.ViewData data)
Parameters
Type Name Description
View.ViewData data

Fields

AutoSubscribeKey

Declaration
public const string AutoSubscribeKey = "a"
Field Value
Type Description
System.String

Data

Declaration
protected readonly View.ViewData Data
Field Value
Type Description
View.ViewData

DescribeView

Declaration
public static Func<View, string> DescribeView
Field Value
Type Description
System.Func<View, System.String>

IDKey

Declaration
public const string IDKey = "k"
Field Value
Type Description
System.String

NameKey

Declaration
public const string NameKey = "n"
Field Value
Type Description
System.String

PropertiesKey

Declaration
public const string PropertiesKey = "p"
Field Value
Type Description
System.String

SyncedViewRPCName

Declaration
public const string SyncedViewRPCName = "SyncedViewRPC"
Field Value
Type Description
System.String

TypeKey

Declaration
public const string TypeKey = "t"
Field Value
Type Description
System.String

ValueKey

Declaration
public const string ValueKey = "v"
Field Value
Type Description
System.String

ViewRPCName

Declaration
public const string ViewRPCName = "ViewRPC"
Field Value
Type Description
System.String

Properties

ClassInfo

Declaration
public ViewClassInfo ClassInfo { get; }
Property Value
Type Description
ViewClassInfo

ControllerID

Declaration
public int ControllerID { get; set; }
Property Value
Type Description
System.Int32

DebugName

Returns View name which may be used for debugging.

Declaration
public string DebugName { get; }
Property Value
Type Description
System.String

TypeName

Declaration
public string TypeName { get; }
Property Value
Type Description
System.String

ViewTypeID

Declaration
public int ViewTypeID { get; set; }
Property Value
Type Description
System.Int32

Methods

DescribeSubscriptions(StringBuilder, String)

Returns count of property subscriptions. Mostly for debugging purposes.

Declaration
public void DescribeSubscriptions(StringBuilder sb, string propertyName)
Parameters
Type Name Description
System.Text.StringBuilder sb
System.String propertyName

GetOrRecoverView(View.ViewData)

Exposes access to Eco.Shared.View.ViewManager.GetOrRecoverView(Eco.Shared.View.View.ViewData) from View derived classes.

Declaration
protected View GetOrRecoverView(View.ViewData viewData)
Parameters
Type Name Description
View.ViewData viewData
Returns
Type Description
View

GetValue(String, Int32)

Declaration
public object GetValue(string propName, int listIndex = -1)
Parameters
Type Name Description
System.String propName
System.Int32 listIndex
Returns
Type Description
System.Object

HasData(View.ViewData)

Checks if view is holding data.

Declaration
public bool HasData(View.ViewData data)
Parameters
Type Name Description
View.ViewData data
Returns
Type Description
System.Boolean

HasProperty(String)

Declaration
public bool HasProperty(string propertyName)
Parameters
Type Name Description
System.String propertyName
Returns
Type Description
System.Boolean

Initialize()

Declaration
public virtual void Initialize()

IsAvailable(ViewMemberInfo)

Check if a property is available (that is, if it needs requesting it has been received).

Declaration
public bool IsAvailable(ViewMemberInfo member)
Parameters
Type Name Description
ViewMemberInfo member
Returns
Type Description
System.Boolean

IsAvailable(String)

Check if a property is available (that is, if it needs requesting it has been received).

Declaration
public bool IsAvailable(string propname)
Parameters
Type Name Description
System.String propname
Returns
Type Description
System.Boolean

ManualRPC(String, Int32, Object[])

Declaration
public static void ManualRPC(string methodname, int viewId, params object[] args)
Parameters
Type Name Description
System.String methodname
System.Int32 viewId
System.Object[] args

ManualRPC<T>(String, Action<T>, Int32, Object[])

Makes RPC call on view with provided viewId.

Declaration
public static void ManualRPC<T>(string methodname, Action<T> response, int viewId, params object[] args)
Parameters
Type Name Description
System.String methodname
System.Action<T> response
System.Int32 viewId
System.Object[] args
Type Parameters
Name Description
T

NotifyAll()

Notifies all changed callbacks for all properties. Primarily intended for debugging.

Declaration
public void NotifyAll()

NotifyChanged(String)

Declaration
public virtual void NotifyChanged(string propertyName)
Parameters
Type Name Description
System.String propertyName

Recover()

Recovers View from Data. When original View was destroyed, but then a reference to it received from the server then it may need to perform some logic to correctly restore View from backup Data.

Declaration
protected virtual void Recover()

RPC(String, Action, Object[])

Makes RPC call on the View with callback with no return value. response callback doesn't wait while views changed with RPC synced back to the client, so you may have old View values when callback invoke. If you need to have synced values then use SyncedRPC(String, Action, Object[]) instead.

Declaration
public void RPC(string methodname, Action response, params object[] args)
Parameters
Type Name Description
System.String methodname
System.Action response
System.Object[] args

RPC(String, Object[])

Makes RPC call on the View.

Declaration
public void RPC(string methodname, params object[] args)
Parameters
Type Name Description
System.String methodname
System.Object[] args

RPC<T>(String, Action<T>, Object[])

Makes RPC call on the View with callback having return value. response callback doesn't wait while views changed with RPC synced back to the client, so you may have old View values when callback invoke. If you need to have synced values then use SyncedRPC<T>(String, Action<T>, Object[]) instead.

Declaration
public void RPC<T>(string methodname, Action<T> response, params object[] args)
Parameters
Type Name Description
System.String methodname
System.Action<T> response
System.Object[] args
Type Parameters
Name Description
T

SetFieldViewData<T>(out T, View)

Sets field's View.ViewData from view. We need this method because of accessibility restrictions.

Declaration
protected void SetFieldViewData<T>(out T field, View view)
    where T : View.ViewData
Parameters
Type Name Description
T field
View view
Type Parameters
Name Description
T

Subscribe(IPropertySubscription)

Declaration
public void Subscribe(IPropertySubscription subscription)
Parameters
Type Name Description
IPropertySubscription subscription

SubscribeUnique(IPropertySubscription)

Declaration
public bool SubscribeUnique(IPropertySubscription subscription)
Parameters
Type Name Description
IPropertySubscription subscription
Returns
Type Description
System.Boolean

SyncedRPC(String, Action, Object[])

Makes RPC call on the View with callback with no return value. Callback will be synced with view updates initiated by RPC. I.e. if it changes a property then that property will be synced back to the client before callback invoked. Should be used when RPC callback expects view changes to be synced on the client. I.e. after SetProperty you want to make some calculations based on value of that property.

view.RPC("SetDateOfBirth", () => age = DateTime.Today - view.DateOfBirth, date);
When non-synced RPC used there no guarantee that DateOfBirth will have new value just set with RPC, because it synced asynchronously to RPC. It may still have old value (actually in most cases it will have previous value).

Declaration
public void SyncedRPC(string methodname, Action response, params object[] args)
Parameters
Type Name Description
System.String methodname
System.Action response
System.Object[] args

SyncedRPC<T>(String, Action<T>, Object[])

Makes RPC call on the View with callback having return value. Callback will be synced with view updates initiated by RPC. I.e. if it changes a property then that property will be synced back to the client before callback invoked. See SyncedRPC(String, Action, Object[]) for more details and examples.

Declaration
public void SyncedRPC<T>(string methodname, Action<T> response, params object[] args)
Parameters
Type Name Description
System.String methodname
System.Action<T> response
System.Object[] args
Type Parameters
Name Description
T

ThrottledRPC(String, Object[])

Makes RPC call on the View with ensurence that it won't be sent again if server still didn't confirmed previous request.

Declaration
public void ThrottledRPC(string methodname, params object[] args)
Parameters
Type Name Description
System.String methodname
System.Object[] args

ToString()

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

TryGetValue<T>(String, out T, Int32)

Get a dynamic value by property name, querying both reflection and the list of dynamic properties sent by the server. Returns false if the property doesnt exist in either, or if referencing a list, the list index doesn't exist.

Declaration
public bool TryGetValue<T>(string propName, out T retVal, int listIndex = -1)
Parameters
Type Name Description
System.String propName
T retVal
System.Int32 listIndex
Returns
Type Description
System.Boolean
Type Parameters
Name Description
T

Unsubscribe(IPropertySubscription)

Removes subscription from Eco.Shared.View.View.changedCallbacks.

Declaration
public void Unsubscribe(IPropertySubscription subscription)
Parameters
Type Name Description
IPropertySubscription subscription

UpdateProperty(BSONValue, BSONObject)

Declaration
public void UpdateProperty(BSONValue propNameID, BSONObject bson)
Parameters
Type Name Description
BSONValue propNameID
BSONObject bson

VerifyPropReceived(String)

Declaration
protected void VerifyPropReceived(string name)
Parameters
Type Name Description
System.String name

Implements

IView
IViewController
IObservable

Extension Methods

CommandLine.FeedFromCommandLine(Object)
CommandLine.ToCommandLineArgs(Object, Func<Object, Boolean>)
ListUtil.DepthFirstTraversal<T>(T, Func<T, IEnumerable<T>>)
EnumerableExtensions.SingleItemAsEnumerable<T>(T)
EventUtils.RaiseEvent<TEventArgs>(Object, String, TEventArgs)
PredicateUtils.MatchesAll<TEnumerable, T>(T, TEnumerable)
PredicateUtils.MatchesAll<T>(T, Func<T, Boolean>[])
PredicateUtils.MatchesAny<TEnumerable, T>(T, TEnumerable)
ReflectionUtils.PropertyValue<T>(Object, PropertyInfo)
ReflectionUtils.TryGetPropertyValueByName<T>(Object, String, out T)
ReflectionUtils.GetPropertyValueByName<T>(Object, String)
ReflectionUtils.SetPropertyByName(Object, String, Object)
ReflectionUtils.GetStructPropertyByName<T>(Object, String)
ReflectionUtils.GetStringPropertyByName(Object, String)
ReflectionUtils.ZipByProperty<T>(Object, Object, Object, Func<T, T, T>)
☀
☾
In This Article
Back to top
Copyright (c) Strange Loop Games 2021
☀
☾