本文整理汇总了C#中Script类的典型用法代码示例。如果您正苦于以下问题:C# Script类的具体用法?C# Script怎么用?C# Script使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Script类属于命名空间,在下文中一共展示了Script类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Interpret
internal static int Interpret(Script script, string prefix)
{
IEnumerable<Frame> frames = script.CreateFrames();
double range;
{
double maxDist = (script.Config.Width + script.Config.Height) * 10;
range = maxDist * maxDist;
}
IDictionary<IVariable, VariableWithValue> previousState = new Dictionary<IVariable, VariableWithValue>();
foreach (var f in frames) {
var bitmap = new Bitmap(script.Config.Width, script.Config.Height);
Graphics drawingPane = Graphics.FromImage(bitmap);
// Compute locations for each anchor of each thing.
Dictionary<string, double> debugExpectedResults;
script.DebugExpectedResults.TryGetValue(f.FrameNo, out debugExpectedResults);
IDictionary<string, IDictionary<string, ConstVector>> anchorLocations =
f.SolveConstraints(range, ref previousState, debugExpectedResults);
foreach (var th in script.Things) {
th.Draw(drawingPane, anchorLocations[th.Name]);
}
bitmap.Save(string.Format("{0}{1:000000}.jpg", prefix, f.FrameNo), ImageFormat.Jpeg);
}
return frames.Count();
}
示例2: ScriptInvocation
public ScriptInvocation(dynamic function = null, WorldObject associate = null, WorldObject invoker = null, Script script = null)
{
Function = function;
Associate = associate;
Invoker = invoker;
Script = null;
}
示例3: TfsHelper
public TfsHelper(IContainer container, TextWriter stdout, Script script)
{
_container = container;
_stdout = stdout;
_script = script;
_versionControlServer = new FakeVersionControlServer(_script);
}
示例4: ChangeWallToken
/// <summary>
///
/// </summary>
/// <param name="script"></param>
public ChangeWallToken(Script script)
: base(script)
{
Type = script.ReadByte();
switch (Type)
{
// All sides
case 0xf7:
{
Target = Location.FromScript(script); // script.ReadPosition();
To = script.ReadByte();
From = script.ReadByte();
}
break;
// One side
case 0xe9:
{
Target = Location.FromScript(script); // script.ReadPosition();
Side = script.ReadByte();
To = script.ReadByte();
From = script.ReadByte();
}
break;
// Open door
case 0xea:
{
Target = Location.FromScript(script); // script.ReadPosition();
}
break;
}
}
示例5: ConvertToWhileLoop
static void ConvertToWhileLoop(Script script, DoWhileStatement originalStatement)
{
script.Replace(originalStatement, new WhileStatement {
Condition = originalStatement.Condition.Clone(),
EmbeddedStatement = originalStatement.EmbeddedStatement.Clone()
});
}
示例6: DecorateMessage
internal void DecorateMessage(Script script)
{
if (Token != null)
{
DecorateMessage(script, Token.GetSourceRef(false));
}
}
示例7: LoadChunk
internal static int LoadChunk(Script script, SourceCode source, ByteCode bytecode)
{
ScriptLoadingContext lcontext = CreateLoadingContext(script, source);
try
{
Statement stat;
using (script.PerformanceStats.StartStopwatch(Diagnostics.PerformanceCounter.AstCreation))
stat = new ChunkStatement(lcontext);
int beginIp = -1;
//var srcref = new SourceRef(source.SourceID);
using (script.PerformanceStats.StartStopwatch(Diagnostics.PerformanceCounter.Compilation))
using (bytecode.EnterSource(null))
{
bytecode.Emit_Nop(string.Format("Begin chunk {0}", source.Name));
beginIp = bytecode.GetJumpPointForLastInstruction();
stat.Compile(bytecode);
bytecode.Emit_Nop(string.Format("End chunk {0}", source.Name));
}
//Debug_DumpByteCode(bytecode, source.SourceID);
return beginIp;
}
catch (SyntaxErrorException ex)
{
ex.DecorateMessage(script);
throw;
}
}
示例8: Execute
public void Execute(Script script, Regex procedure_pattern) {
var textwriter = new StringWriter();
var wscript = new WScript(script.Path, script.Arguments);
wscript.OnEcho += textwriter.WriteLine;
if (!_compiler.Compile(wscript, script))
return;
var list_procedures = ListProcedures(script, procedure_pattern);
if (_compiler.Run(list_procedures.ProcInitialize)) {
foreach (var procedure in list_procedures) {
if (_compiler.Run(list_procedures.ProcSetup)) {
if (_compiler.Run(procedure, true)) {
OnSuccess(new ScriptSuccees(script, procedure));
} else {
var error = _compiler.Error;
if (list_procedures.ProcOnError != null) {
list_procedures.ProcOnError.Params = new object[] { procedure.Name, _compiler.Error.ToString() };
if (_compiler.Run(list_procedures.ProcOnError))
error.AddInformation((string)_compiler.Result);
}
OnError(error);
}
_compiler.Run(list_procedures.ProcTearDown);
}
}
_compiler.Run(list_procedures.ProcTerminate);
}
if (list_procedures.Count == 0 && script.Succeed)
OnSuccess(new ScriptSuccees(script));
OnInfo(script, textwriter.ToString().CleanEnd());
}
示例9: ChangeLevelToken
/// <summary>
///
/// </summary>
/// <param name="script"></param>
public ChangeLevelToken(Script script)
: base(script)
{
Type = script.ReadByte();
switch (Type)
{
// Inter level
case 0xe5:
{
Level = script.ReadByte();
Target = script.ReadPosition();
Direction = script.ReadByte();
Unknown0 = script.ReadByte();
}
break;
// Intra level
case 0x00:
{
Target = script.ReadPosition();
Direction = script.ReadByte();
}
break;
}
}
示例10: DebugScript
private void DebugScript(string filename)
{
m_Script = new Script(CoreModules.Preset_HardSandbox);
m_Script.Options.UseLuaErrorLocations = true;
m_Script.Options.DebugPrint = s => { Console_WriteLine("{0}", s); };
((ScriptLoaderBase)m_Script.Options.ScriptLoader).ModulePaths = ScriptLoaderBase.UnpackStringPaths("Modules/?;Modules/?.lua");
try
{
m_Script.LoadFile(filename, null, filename.Replace(':', '|'));
}
catch (Exception ex)
{
txtOutput.Text = "";
Console_WriteLine("{0}", ex.Message);
return;
}
m_Script.AttachDebugger(this);
Thread m_Debugger = new Thread(DebugMain);
m_Debugger.Name = "MoonSharp Execution Thread";
m_Debugger.IsBackground = true;
m_Debugger.Start();
}
示例11: Engine
public Engine()
{
mRenderer = new vRenderer();
mInput = new Input();
mNetwork = new Network();
mScript = new Script();
mWorld = new cWorld();
bool other = false;
for (int y = 0; y < 10; y++)
{
for (int x = 0; x < 10; x++)
{
World_Geom geom = new World_Geom(new Vector2(x*64, y*64), "tex_bookshelf.bmp");
if (!other)
{
//geom = new World_Geom(new Vector2(x, y), "tex2.bmp");
e_pillar door = new e_pillar(new Vector2(x+0.5f, y+0.5f), "tex_3.bmp");
mWorld.AddEntity(door);
}
mWorld.AddGeometry(geom);
other = !other;
}
other = !other;
}
}
示例12: AddScript
private void AddScript(Script script)
{
lock (_padlock)
{
if (_scripts.ContainsKey(script))
{
return;
}
var files = new string[0];
if (Directory.Exists(_configuration.ScriptFolder))
{
files = Directory.GetFiles(_configuration.ScriptFolder, script.FileName, SearchOption.AllDirectories);
}
if (files.Length == 0)
{
AddEmbeddedScript(script);
return;
}
if (files.Length > 1)
{
throw new ScriptException(string.Format(SqlResources.ScriptCountException, _configuration.ScriptFolder, script.FileName, files.Length));
}
_scripts.Add(script, File.ReadAllText(files[0]));
}
}
示例13: UpdateAutocompleteCacheThread
private static void UpdateAutocompleteCacheThread()
{
while (true)
{
Thread.Sleep(50);
if (_scriptToUpdateInBackground != null)
{
Script scriptToUpdate;
lock (_scriptLockObject)
{
scriptToUpdate = _scriptToUpdateInBackground;
_scriptToUpdateInBackground = null;
}
try
{
OnBackgroundCacheUpdateStatusChanged(BackgroundAutoCompleteStatus.Processing, null);
ConstructCache(scriptToUpdate, true);
OnBackgroundCacheUpdateStatusChanged(BackgroundAutoCompleteStatus.Finished, null);
}
catch (Exception ex)
{
OnBackgroundCacheUpdateStatusChanged(BackgroundAutoCompleteStatus.Error, ex);
}
}
}
}
示例14: RequestBackgroundCacheUpdate
public static void RequestBackgroundCacheUpdate(Script scriptToUpdate)
{
lock (_scriptLockObject)
{
_scriptToUpdateInBackground = scriptToUpdate;
}
}
示例15: CheckScriptOwnership
public static void CheckScriptOwnership(this IScriptPrivateResource resource, Script script)
{
if (resource.OwnerScript != null && resource.OwnerScript != script && script != null)
{
throw new ScriptRuntimeException("Attempt to access a resource owned by a script, from another script");
}
}