本文整理汇总了C#中Sandbox类的典型用法代码示例。如果您正苦于以下问题:C# Sandbox类的具体用法?C# Sandbox怎么用?C# Sandbox使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Sandbox类属于命名空间,在下文中一共展示了Sandbox类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OutputChainBuffer
public OutputChainBuffer(Sandbox sb, OutputChainBuffer prev, OutputChainBuffer targetOrigin)
{
_prevItem = prev;
if (prev != null)
{
prev._nextItem = this;
_caps = prev is OutputChainArticleBuffer && prev.Caps == Capitalization.First ? Capitalization.None : prev._caps;
}
_buffer = targetOrigin._buffer;
sandbox = sb;
}
示例2: Run
public override IEnumerator<RantAction> Run(Sandbox sb)
{
yield return _expr;
var expr = sb.ScriptObjectStack.Pop();
if (!(expr is REAList) && !(expr is REAObject))
throw new RantRuntimeException(sb.Pattern, Range, "Provided expression is not a list or object.");
if (expr is REAList)
{
yield return expr as REAList;
var list = sb.ScriptObjectStack.Pop() as REAList;
var items = (list as REAList).Items;
for (var i = 0; i < items.Count; i++)
{
sb.Objects.EnterScope();
sb.Objects[_indexName] = new ObjectModel.RantObject(i);
yield return _body;
sb.Objects.ExitScope();
}
yield break;
}
else if (expr is REAObject)
{
var items = (expr as REAObject).Values.Keys.ToList();
foreach (string key in items)
{
sb.Objects.EnterScope();
sb.Objects[_indexName] = new ObjectModel.RantObject(key);
yield return _body;
sb.Objects.ExitScope();
}
yield break;
}
}
示例3: Run
public override IEnumerator<RantAction> Run(Sandbox sb)
{
foreach (RichActionBase action in Group.Actions)
yield return action;
if (sb.ScriptObjectStack.Any())
{
var obj = sb.ScriptObjectStack.Pop();
if (obj is RichList)
{
var list = (obj as RichList);
// don't make a block from a list with zero items
if (list.Items.Count == 0)
yield break;
List<RantAction> actions = new List<RantAction>();
foreach (RichActionBase action in list.Items)
{
yield return action;
var item = sb.ScriptObjectStack.Pop();
if (item is RichPatternString)
actions.Add((item as RichPatternString).Pattern.Action);
else
actions.Add(new RAText(action.Range, item.ToString()));
}
yield return new RABlock(list.Range, actions.ToArray());
}
else if (obj is RichPatternString)
yield return (obj as RichPatternString).Pattern.Action;
else if (obj is bool)
sb.Print((bool)obj ? "true" : "false");
else if(!(obj is RantObject && (obj as RantObject).Type == RantObjectType.Undefined))
sb.Print(obj);
}
yield break;
}
示例4: Init
public override void Init(Sandbox.Common.ObjectBuilders.MyObjectBuilder_CubeBlock objectBuilder, Sandbox.Game.Entities.MyCubeGrid cubeGrid)
{
base.Init(objectBuilder, cubeGrid);
m_oxygenFarmDefinition = BlockDefinition as MyOxygenFarmDefinition;
IsWorkingChanged += OnIsWorkingChanged;
NeedsUpdate = MyEntityUpdateEnum.EACH_10TH_FRAME | MyEntityUpdateEnum.EACH_100TH_FRAME;
InitializeConveyorEndpoint();
PowerReceiver = new MyPowerReceiver(
MyConsumerGroupEnum.Factory,
false,
m_oxygenFarmDefinition.OperationalPowerConsumption,
ComputeRequiredPower);
PowerReceiver.IsPoweredChanged += PowerReceiver_IsPoweredChanged;
PowerReceiver.Update();
GameLogic = new MySolarGameLogicComponent();
m_solarComponent = GameLogic as MySolarGameLogicComponent;
m_solarComponent.Initialize(m_oxygenFarmDefinition.PanelOrientation, m_oxygenFarmDefinition.IsTwoSided, m_oxygenFarmDefinition.PanelOffset, this);
AddDebugRenderComponent(new Components.MyDebugRenderComponentSolarPanel(this));
}
示例5: Run
public override IEnumerator<RantAction> Run(Sandbox sb)
{
if (sb.Objects[Name] == null)
throw new RantRuntimeException(sb.Pattern, _name, $"The subroutine '{Name}' does not exist.");
var sub = (RADefineSubroutine)sb.Objects[Name].Value;
if (sub.Parameters.Keys.Count != Arguments.Count)
throw new RantRuntimeException(sb.Pattern, _name, "Argument mismatch on subroutine call.");
var action = sub.Body;
var args = new Dictionary<string, RantAction>();
var parameters = sub.Parameters.Keys.ToArray();
for (var i = 0; i < Arguments.Count; i++)
{
if (sub.Parameters[parameters[i]] == SubroutineParameterType.Greedy)
{
sb.AddOutputWriter();
yield return Arguments[i];
var output = sb.Return();
args[parameters[i]] = new RAText(_name, output.Main);
}
else
args[parameters[i]] = Arguments[i];
}
sb.SubroutineArgs.Push(args);
yield return action;
sb.SubroutineArgs.Pop();
yield break;
}
示例6: OutputChain
public OutputChain(Sandbox sb, string name)
{
sandbox = sb;
_first = new OutputChainBuffer(sb, null);
_last = _first;
Name = name;
}
示例7: RunTests
public void RunTests(IEnumerable<TestCase> tests, IRunContext runContext, IFrameworkHandle frameworkHandle)
{
this.frameworkHandle = frameworkHandle;
var testLogger = new TestLogger(frameworkHandle);
testLogger.SendMainMessage("Execution started");
foreach (var group in tests.GroupBy(t => t.Source))
{
testLogger.SendInformationalMessage(String.Format("Running selected: '{0}'", group.Key));
try
{
using (var sandbox = new Sandbox<Executor>(group.Key))
{
var assemblyDirectory = new DirectoryInfo(Path.GetDirectoryName(group.Key));
Directory.SetCurrentDirectory(assemblyDirectory.FullName);
sandbox.Content.Execute(this, group.Select(t => t.FullyQualifiedName).ToArray());
}
}
catch (Exception ex)
{
testLogger.SendErrorMessage(ex, String.Format("Exception found while executing tests in group '{0}'", group.Key));
// just go on with the next
}
}
testLogger.SendMainMessage("Execution finished");
}
示例8: Execute
public IEnumerator<RichActionBase> Execute(Sandbox sb)
{
List<object> args = new List<object>();
for (var i = 0; i < _argCount; i++)
args.Add(new RantObject(sb.ScriptObjectStack.Pop()));
args.Add(That);
args.Reverse();
IEnumerator<RantAction> iterator = null;
while (true)
{
try
{
if(iterator == null)
iterator = _function.Invoke(sb, args.ToArray());
if (!iterator.MoveNext())
break;
}
// attach token to it and throw it up
catch (RantRuntimeException e)
{
e.SetToken(Range);
throw e;
}
yield return iterator.Current as RichActionBase;
}
}
示例9: Discover
public static IEnumerable<TestCase> Discover(IEnumerable<string> sources, ITestCaseDiscoverySink discoverySink)
{
List<TestCase> result = new List<TestCase>();
// System.Diagnostics.Debugger.Launch();
var specList = new List<dynamic>();
foreach (var source in sources)
{
using (var sandbox = new Sandbox<Discover>(source))
{
List<DefinitionSource> discoveredDefinitions = new List<DefinitionSource>();
try
{
discoveredDefinitions = sandbox.Content.DiscoverSpecsFromCurrentAssembly();
}
catch (Exception a)
{
Console.WriteLine(a.Message);
}
discoveredDefinitions
.Select(x => AddToSink(source, x, discoverySink))
.ToList()
.ForEach(x => result.Add(x));
}
}
return result;
}
示例10: Run
public override IEnumerator<RantAction> Run(Sandbox sb)
{
var iterator = _function.Invoke(sb, new object[] { });
while (iterator.MoveNext())
yield return iterator.Current;
yield break;
}
示例11: Run
public override IEnumerator<RantAction> Run(Sandbox sb)
{
if (Items == null || ItemsChanged)
{
List<RichActionBase> tempItems = new List<RichActionBase>();
for (var i = 0; i < _items.Count; i++)
{
var item = _items[i];
if (item is RichActionBase)
{
yield return item;
var val = sb.ScriptObjectStack.Pop();
if (val is RichList && _concatSyntax)
tempItems.AddRange((val as RichList).Items);
else
tempItems.Add(Util.ConvertToAction(item.Range, val));
}
else
tempItems.Add(item);
}
Items = tempItems;
ItemsChanged = false;
}
yield break;
}
示例12: OutputWriter
public OutputWriter(Sandbox sb)
{
sandbox = sb;
mainChain = chains[MainChannelName] = new OutputChain(sb, MainChannelName);
chainStack.Push(mainChain);
activeChains.Add(mainChain);
}
示例13: RunImpl
protected internal override TestResult RunImpl(ITestCommand rootTestCommand, Model.Tree.TestStep parentTestStep, TestExecutionOptions options, IProgressMonitor progressMonitor)
{
using (progressMonitor.BeginTask("Running tests.", rootTestCommand.TestCount))
{
// Note: We do not check options.SkipTestExecution here because we want to build up
// the tree of data-driven test steps. So we actually check it later on in the
// PatternTestExecutor. This is different from framework adapters
// at this time (because they do not generally support dynamically generated data-driven tests).
Sandbox sandbox = new Sandbox();
EventHandler canceledHandler = delegate { sandbox.Abort(TestOutcome.Canceled, "The user canceled the test run."); };
try
{
progressMonitor.Canceled += canceledHandler;
TestAssemblyExecutionParameters.Reset();
PatternTestExecutor executor = new PatternTestExecutor(options, progressMonitor, formatter, converter, environmentManager);
// Inlined to minimize stack depth.
var action = executor.CreateActionToRunTest(rootTestCommand, parentTestStep, sandbox, null);
action.Run();
return action.Result;
}
finally
{
progressMonitor.Canceled -= canceledHandler;
sandbox.Dispose();
}
}
}
示例14: DiscoverTests
public void DiscoverTests(IEnumerable<string> sources, IDiscoveryContext discoveryContext, IMessageLogger logger, ITestCaseDiscoverySink discoverySink)
{
testLogger = new TestLogger(logger);
testLogger.SendMainMessage("Discovery started");
foreach (var source in sources)
{
testLogger.SendDebugMessage(String.Format("Processing: '{0}'", source));
try
{
using (var sandbox = new Sandbox<Discoverer>(source))
{
if (sandbox.Content != null)
{
sandbox.Content
.DiscoverTests()
.Select(name => name.ToTestCase(source))
.ForEach(discoverySink.SendTestCase);
}
}
}
catch (Exception ex)
{
testLogger.SendErrorMessage(ex, String.Format("Exception found while discovering tests in source '{0}'", source));
// just go on with the next
}
}
testLogger.SendMainMessage("Discovery finished");
}
示例15: Run
public override IEnumerator<RantAction> Run(Sandbox sb)
{
if (LeftSide == null || RightSide == null)
throw new RantRuntimeException(sb.Pattern, Origin, "Missing part of infix operation.");
yield return RightSide;
yield return LeftSide;
yield break;
}