当前位置: 首页>>代码示例>>C#>>正文


C# Sandbox类代码示例

本文整理汇总了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;
		}
开发者ID:W-h-a-t-s,项目名称:Rant,代码行数:13,代码来源:OutputChainBuffer.cs

示例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;
     }
 }
开发者ID:inkadnb,项目名称:Rant,代码行数:33,代码来源:REAFor.cs

示例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;
		}
开发者ID:W-h-a-t-s,项目名称:Rant,代码行数:34,代码来源:RAExpression.cs

示例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));
        }
开发者ID:Krulac,项目名称:SpaceEngineers,代码行数:25,代码来源:MyOxygenFarm.cs

示例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;
		}
开发者ID:katnapper323,项目名称:Rant,代码行数:27,代码来源:RACallSubroutine.cs

示例6: OutputChain

		public OutputChain(Sandbox sb, string name)
		{
			sandbox = sb;
			_first = new OutputChainBuffer(sb, null);
			_last = _first;
			Name = name;
		}
开发者ID:strogonoff,项目名称:Rant,代码行数:7,代码来源:OutputChain.cs

示例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");
        }
开发者ID:laynor,项目名称:NSpecTestAdapter,代码行数:31,代码来源:NSpecExecutor.cs

示例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;
     }
 }
开发者ID:W-h-a-t-s,项目名称:Rant,代码行数:26,代码来源:RichNativeFunction.cs

示例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;
        }
开发者ID:leohinojosa,项目名称:spec,代码行数:28,代码来源:specTestDiscoverer.cs

示例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;
 }
开发者ID:W-h-a-t-s,项目名称:Rant,代码行数:7,代码来源:RichFunctionInfo.cs

示例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;
		}
开发者ID:W-h-a-t-s,项目名称:Rant,代码行数:25,代码来源:RichList.cs

示例12: OutputWriter

		public OutputWriter(Sandbox sb)
		{
			sandbox = sb;
			mainChain = chains[MainChannelName] = new OutputChain(sb, MainChannelName);
			chainStack.Push(mainChain);
			activeChains.Add(mainChain);
		}
开发者ID:W-h-a-t-s,项目名称:Rant,代码行数:7,代码来源:OutputWriter.cs

示例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();
                }
            }
        }
开发者ID:dougrathbone,项目名称:mbunit-v3,代码行数:30,代码来源:PatternTestController.cs

示例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");
        }
开发者ID:laynor,项目名称:NSpecTestAdapter,代码行数:33,代码来源:NSpecTestDiscoverer.cs

示例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;
		}
开发者ID:W-h-a-t-s,项目名称:Rant,代码行数:8,代码来源:RichInfixOperator.cs


注:本文中的Sandbox类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。