BadScript 2
Loading...
Searching...
No Matches
BadScript2.Parser.BadMetaData Class Reference

Implements a Meta Data container for an expression. More...

Inheritance diagram for BadScript2.Parser.BadMetaData:
BadScript2.Runtime.Objects.BadObject

Public Member Functions

 BadMetaData (string description, string returnDescription, string returnType, Dictionary< string, BadParameterMetaData > parameterDescriptions)
 Creates a new Meta Data Object.
 
override BadClassPrototype GetPrototype ()
 
override bool HasProperty (string propName, BadScope? caller=null)
 Returns true if the object contains a given property or there exists an extension for the current Instance.
Parameters
propNameThe Property Name
callerThe caller Scope
Returns
True if the Property or an Extension with that name exists

 
override BadObjectReference GetProperty (string propName, BadScope? caller=null)
 Returns a Reference to the Property with the given Name.
Parameters
propNameThe Property Name
callerThe caller Scope
Returns
The Property Reference

 
override string ToSafeString (List< BadObject > done)
 
- Public Member Functions inherited from BadScript2.Runtime.Objects.BadObject
BadClassPrototype GetPrototype ()
 Returns the Prototype of this Object.
 
string ToSafeString (List< BadObject > done)
 Returns a String Representation of this Object. This function is recursion proof and supports circular references.
 
override string ToString ()
 Returns a String Representation of this Object.
 

Public Attributes

readonly string Description
 The Description of the Expression.
 
readonly Dictionary< string, BadParameterMetaDataParameterDescriptions
 The Description of the Function Parameters.
 
readonly string ReturnDescription
 The Description of the Return Value.
 
readonly string ReturnType
 The Return Type of the Expression.
 

Static Public Attributes

static readonly BadMetaData Empty
 An empty Meta Data object.
 
- Static Public Attributes inherited from BadScript2.Runtime.Objects.BadObject
static readonly BadObject Null = new BadNullObject()
 The Null Value for the BadScript Language.
 
static readonly BadObject True = new BadBoolean(true)
 The True Value for the BadScript Language.
 
static readonly BadObject False = new BadBoolean(false)
 The False Value for the BadScript Language.
 

Additional Inherited Members

- Static Public Member Functions inherited from BadScript2.Runtime.Objects.BadObject
static bool CanWrap (object? o)
 Returns true if the given object cam be wrapped.
 
static BadObject Wrap< T > (T obj, bool allowNative=true)
 Wraps the given object into a BadObject Instance.
 
static implicit operator BadObject (bool b)
 Implicit Converstion from Boolean to BadObject.
 
static implicit operator BadObject (BadNullable< bool > b)
 Converts the given object to a BadObject Instance.
 
static implicit operator BadObject (DateTimeOffset d)
 
static implicit operator BadObject (TimeSpan t)
 
static implicit operator BadObject (decimal d)
 Implicit Converstion from Number to BadObject.
 
static implicit operator BadObject (BadNullable< decimal > b)
 Converts the given object to a BadObject Instance.
 
static implicit operator BadObject (string s)
 Implicit Converstion from String to BadObject.
 
static implicit operator BadObject (BadNullable< string > b)
 Converts the given object to a BadObject Instance.
 

Detailed Description

Implements a Meta Data container for an expression.

Definition at line 15 of file BadMetaData.cs.

Constructor & Destructor Documentation

◆ BadMetaData()

BadScript2.Parser.BadMetaData.BadMetaData ( string  description,
string  returnDescription,
string  returnType,
Dictionary< string, BadParameterMetaData parameterDescriptions 
)

Creates a new Meta Data Object.

Parameters
descriptionThe Description of the Expression
returnDescriptionThe Description of the Return Value
returnTypeThe Return Type of the Expression
parameterDescriptionsThe Description of the Function Parameters

Definition at line 50 of file BadMetaData.cs.

54 {
55 Description = description;
56 ReturnDescription = returnDescription;
57 ParameterDescriptions = parameterDescriptions;
58 ReturnType = returnType;
59 }
readonly string ReturnDescription
The Description of the Return Value.
readonly string Description
The Description of the Expression.
readonly string ReturnType
The Return Type of the Expression.
readonly Dictionary< string, BadParameterMetaData > ParameterDescriptions
The Description of the Function Parameters.

Member Function Documentation

◆ GetProperty()

override BadObjectReference BadScript2.Parser.BadMetaData.GetProperty ( string  propName,
BadScope caller = null 
)
virtual

Returns a Reference to the Property with the given Name.

Parameters
propNameThe Property Name
callerThe caller Scope
Returns
The Property Reference

Reimplemented from BadScript2.Runtime.Objects.BadObject.

Definition at line 75 of file BadMetaData.cs.

76 {
77 switch (propName)
78 {
79 case "Description":
80 return BadObjectReference.Make("BadMetaData.Description", (p) => Description);
81 case "Return":
82 return BadObjectReference.Make("BadMetaData.Return",
83 (p) => new BadTable(new Dictionary<string, BadObject>
84 {
85 { "Type", ReturnType },
86 { "Description", ReturnDescription },
87 }
88 )
89 );
90 case "Parameters":
91 return BadObjectReference.Make("BadMetaData.Parameters",
92 (p) => new BadTable(ParameterDescriptions.ToDictionary(x => x.Key,
93 x => (BadObject)
94 new BadTable(new Dictionary<string,
96 {
97 { "Type", x.Value.Type },
98 {
99 "Description",
100 x.Value.Description
101 },
102 }
103 )
104 )
105 )
106 );
107 }
108
109 return base.GetProperty(propName, caller);
110 }
The Base Class for all BadScript Objects.
Definition BadObject.cs:14
virtual BadObjectReference GetProperty(string propName, BadScope? caller=null)
Returns a Reference to the Property with the given Name.
Definition BadObject.cs:141
Implements the base functionality for a BadScript Reference.
static BadObjectReference Make(string refText, Func< BadSourcePosition?, BadObject > getter, Action< BadObject, BadSourcePosition?, BadPropertyInfo?>? setter=null, Action< BadSourcePosition?>? delete=null)
Creates a new Reference Object.
Implements a Table Structure for the BadScript Language.
Definition BadTable.cs:14

◆ GetPrototype()

override BadClassPrototype BadScript2.Parser.BadMetaData.GetPrototype ( )

Definition at line 62 of file BadMetaData.cs.

63 {
64 throw new NotSupportedException();
65 }

◆ HasProperty()

override bool BadScript2.Parser.BadMetaData.HasProperty ( string  propName,
BadScope caller = null 
)
virtual

Returns true if the object contains a given property or there exists an extension for the current Instance.

Parameters
propNameThe Property Name
callerThe caller Scope
Returns
True if the Property or an Extension with that name exists

Reimplemented from BadScript2.Runtime.Objects.BadObject.

Definition at line 68 of file BadMetaData.cs.

69 {
70 return propName is "Description" or "Return" or "Parameters" ||
71 base.HasProperty(propName, caller);
72 }

◆ ToSafeString()

override string BadScript2.Parser.BadMetaData.ToSafeString ( List< BadObject done)

Definition at line 113 of file BadMetaData.cs.

114 {
115 StringBuilder sb = new StringBuilder();
116
117 sb.AppendLine(Description);
118
119 foreach (KeyValuePair<string, BadParameterMetaData> kv in ParameterDescriptions)
120 {
121 sb.AppendLine($"Parameter {kv.Key} {kv.Value.Type}: {kv.Value.Description}");
122 }
123
124 sb.AppendLine("Returns: " + ReturnDescription);
125
126 return sb.ToString();
127 }

Member Data Documentation

◆ Description

readonly string BadScript2.Parser.BadMetaData.Description

The Description of the Expression.

Definition at line 26 of file BadMetaData.cs.

◆ Empty

readonly BadMetaData BadScript2.Parser.BadMetaData.Empty
static
Initial value:
=
new BadMetaData("", "", "any", new Dictionary<string, BadParameterMetaData>())
BadMetaData(string description, string returnDescription, string returnType, Dictionary< string, BadParameterMetaData > parameterDescriptions)
Creates a new Meta Data Object.

An empty Meta Data object.

Definition at line 20 of file BadMetaData.cs.

◆ ParameterDescriptions

readonly Dictionary<string, BadParameterMetaData> BadScript2.Parser.BadMetaData.ParameterDescriptions

The Description of the Function Parameters.

Definition at line 31 of file BadMetaData.cs.

◆ ReturnDescription

readonly string BadScript2.Parser.BadMetaData.ReturnDescription

The Description of the Return Value.

Definition at line 36 of file BadMetaData.cs.

◆ ReturnType

readonly string BadScript2.Parser.BadMetaData.ReturnType

The Return Type of the Expression.

Definition at line 41 of file BadMetaData.cs.


The documentation for this class was generated from the following file: