本文整理汇总了C#中Workspace.Add方法的典型用法代码示例。如果您正苦于以下问题:C# Workspace.Add方法的具体用法?C# Workspace.Add怎么用?C# Workspace.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Workspace
的用法示例。
在下文中一共展示了Workspace.Add方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Signature
/// <summary> Allows to create the generic signature definition. </summary>
private Signature(Workspace workspace)
: base(new[] { new VariableSet(DefaultNotions.OverarchingSet, "TParameter"), new VariableSet(DefaultNotions.OverarchingSet, "TResult") }.ToReadOnlyList(), signatureVariances, "signature definition")
{
workspace.Add(SetRelationType.Subset, this, DefaultNotions.SetDefinition);
}
示例2: DefaultNotions
static DefaultNotions()
{
workspace = (Workspace)AppDomain.CurrentDomain.CreateInstance("ASDE.SemanticsEngine", "JBSnorro.Reas.SemanticsEngine.Workspace2").Unwrap();
//defines the only two sets with null parent set. The
Unknown = Set.CreateOverarchingOrUnknownSet(workspace, "?", appendable: false, setSelfAsDomain: false);
OverarchingSet = Set.CreateOverarchingOrUnknownSet(workspace, "set", appendable: true, setSelfAsDomain: OverarchingSetContainsItself);
EmptySet = new Set(workspace, "∅");
var variableSet = new VariableSet(OverarchingSet, "var<set>");
SetDefinition = new GenericSet(variableSet, EmptyCollection<ISet>.ReadOnlyList, variableSet.ToSingletonReadOnlyList(), Variance.Covariant.ToSingletonReadOnlyList(), "set<>");
//AllAppendables is defined by appendable : set<var appendable>, just like set : set<set> (well, actually, set : appendable<set>)
//in what set would the variable appendables then be? Could be OverarchingSet: then we have the consistent appendable ⊆ set<var<appendable>> ⊆ var<appendable> ⊆ OverarchingSet
//alternatively, I can create it just as appendable : set<set>. I'll do that for now, as it's simpler.
//Anyway, this does not impose the constraint that any set appended to appendables is in fact appendable (just like any other constraint isn't implemented at the moment).
//Anyway, we can choose the above consistent more convoluted definition of appendables by uncommenting:
//var variableAppendableSet = Set.CreateGenericSetParameter(workspace, "var<appendable>", OverarchingSet, appendable: true); //hmmm?
//AllAppendables = new GenericSet(SetDefinition, variableAppendableSet.ToSingletonReadOnlyList(), "AllAppendables", appendable: true);
//Another alternative, yet less elegant, is to have AllAppendables as singleton (per workspace) type deriving from generic set, such that it can have a variable itself as generic set parameter
AllAppendables = new GenericSet(SetDefinition, OverarchingSet.ToSingletonReadOnlyList<ISet>(), "AllAppendables", appendable: true);
workspace.Add(SetRelationType.Subset, SetDefinition, OverarchingSet);
workspace.Add(SetRelationType.Subset, OverarchingSet, SetDefinition);
//defines the sets that will contain ∈, × and →
InDefiningSet = Signature.From(Unknown, OverarchingSet, OverarchingSet);//?×set→set
CartesianAndSignatureProductType = Signature.From(OverarchingSet, OverarchingSet, OverarchingSet);//set×set→set
//defines the notions of ∈, × and → (not their implementations)
InDefining = new Notion(InDefiningSet, "∈");
CartesianProduct = new Notion(CartesianAndSignatureProductType, "×");
SignatureProduct = new Notion(CartesianAndSignatureProductType, "→");
NaturalNumbers = new Set(workspace, "Gets the notion representing the natural numbers");
GenericTypeOpeningDelimiterSet = new Set(workspace, "⟨");//Contains the single name that represents the opening delimiter of the special construct in which you can specify type arguments");
GenericTypeClosingDelimiterSet = new Set(workspace, "⟩");//Contains the single name that represents the closing delimiter of the special construct in which you can specify type arguments");
//GenericTypeOpeningDelimiter = new Notion(GenericTypeOpeningDelimiterSet, true, "The type argument/parameter list opening delimiter");
//GenericTypeClosingDelimiter = new Notion(GenericTypeClosingDelimiterSet, true, "The type argument/parameter list closing delimiter");
Booleans = Set.Create(workspace, "Booleans",
_ => new Notion(_, "true"),
_ => new Notion(_, "false"));
BinarySetRelations = Signature.From(OverarchingSet, OverarchingSet, Booleans);//set×set→bool
ProperSubset = new Notion(BinarySetRelations, "⊂");
Subset = new Notion(BinarySetRelations, "⊆");
ProperSuperset = new Notion(BinarySetRelations, "⊃");
Superset = new Notion(BinarySetRelations, "⊇");
Intersect = new Notion(CartesianAndSignatureProductType, "∩");
//I believe these two are so far only used in sets (not say integer), hence are in set×set→bool
EqualityOperator = new Notion(BinarySetRelations, "=");
InequalityOperator = new Notion(BinarySetRelations, "≠");
SetBuilderOpeningBraces = new Set(workspace, "Opening set builder braces. ");
SetBuilderClosingBraces = new Set(workspace, "Closing set builder braces. ");
SetBuilderEnumerationDelimiters = new Set(workspace, "Enumeration delimiters");
//the set that contains the information on the precedence of linear notations
//it is an appendable set of appendable sets of sets: Appendable<Appendable<Set>>
//is this the actual set or just its signature?
//the operator sets accept all functions of their respective signatures. The LinearAPSet makes sure these functions are transformed into operators
//binary operators : set<LHS×RHS→TResult>
BinaryOperators = LinearAPSet.Create(Signature.From(new VariableSet(workspace, "LHS"), new VariableSet(workspace, "RHS"), new VariableSet(workspace, "TResult")), DomainKind.Binary);
UnaryOperators = LinearAPSet.Create(Signature.From(new VariableSet(workspace, "TOperand"), new VariableSet(workspace, "TResult")), LinearSet.Unary);
UnaryPreOperators = LinearAPSet.Create((Signature)UnaryOperators.GenericSetArguments[0], DomainKind.UnaryPrefix);
UnaryPostOperators = LinearAPSet.Create((Signature)UnaryOperators.GenericSetArguments[0], DomainKind.UnaryPostfix);
//generic operators : ? nothing?
NullaryOperators = new LinearAPSet(workspace, "nullary");
workspace.Add(SetRelationType.Subset, UnaryOperators, UnaryPostOperators);
workspace.Add(SetRelationType.Subset, UnaryOperators, UnaryPreOperators);
Operators = new Set(workspace, "Binary, unary and nullary operators");//Operators is not appendable, even though elements can be appended to it (indirectly). TODO: think about that: hence even a set that is not appendable may not be static
workspace.Add(SetRelationType.Subset, BinaryOperators, Operators);
workspace.Add(SetRelationType.Subset, UnaryOperators, Operators);//contains unary pre and unary post operators
workspace.Add(SetRelationType.Subset, NullaryOperators, Operators);
//It is the actual set, but the generic type argument should also be constant. The fact that the generic type argument is specified, is unrelated to appending the generic type argument "as element" (which we don't want to do)
//the associativity sets accept all functions of their respective signatures. The LinearAPSet makes sure these functions are transformed into operators
AssociativeOperators = new LinearAPSet(workspace, Associativity.Associative);
LeftAssociativeOperators = new LinearAPSet(workspace, Associativity.Left);
RightAssociativeOperators = new LinearAPSet(workspace, Associativity.Right);
UnassociativeOperators = new LinearAPSet(workspace, Associativity.Undefined);
//the equal precedence sets accept all functions of operator signature. The LinearAPSet makes sure these functions are transformed into operators.
//The function appending to Precedences should do that
//Precedences = Operators.CreateSubset("appendable set of operators", isConstant: false).CreateSubset("appendable set of appendable sets of operators", appendable: true, isConstant: true);
Precedences = new GenericSet(SetDefinition, Operators.CreateSubset(appendable: true, isConstant: true).ToSingletonReadOnlyList(), "Precedences", appendable: true);
PrecedenceElements = new FacadeMapCollection<Notion, Set>((IReadOnlyList<Notion>)workspace.TryGetElements(Precedences), equalPrecOperators => (Set)equalPrecOperators);
//.........这里部分代码省略.........