private static object SetArraySlice(object target, object[] args) { var list = (IList)target; list[RuntimeServices.NormalizeIndex(list.Count, (int)args[0])] = args[1]; return(args[1]); }
private Dispatcher EmitFieldDispatcher(FieldInfo field, SetOrGet gos) { #if NO_SYSTEM_REFLECTION_EMIT switch (gos) { case SetOrGet.Get: return((target, args) => field.GetValue(target)); case SetOrGet.Set: return((target, args) => { var value = args[0]; field.SetValue(target, RuntimeServices.Coerce(value, field.FieldType)); return value; }); default: throw new ArgumentException(); } #else return(SetOrGet.Get == gos ? new Emitters.GetFieldEmitter(field).Emit() : new Emitters.SetFieldEmitter(field, GetArgumentTypes()[0]).Emit()); #endif }
// Token: 0x060003CF RID: 975 RVA: 0x0004C2F8 File Offset: 0x0004A4F8 public virtual void Update() { if (!this.HomeYandere.CanMove) { if (!this.Loaded) { this.StartCoroutine_Auto(this.PhotoGallery.GetPhotos()); this.Loaded = true; } if (!this.PhotoGallery.Adjusting && !this.PhotoGallery.Viewing && !this.PhotoGallery.LoadingScreen.active && Input.GetButtonDown("B")) { this.HomeCamera.Destination = this.HomeCamera.Destinations[0]; this.HomeCamera.Target = this.HomeCamera.Targets[0]; this.HomeCamera.CorkboardLabel.active = true; this.PhotoGallery.enabled = false; this.HomeYandere.CanMove = true; this.HomeYandere.active = true; this.HomeWindow.Show = false; this.enabled = false; this.Loaded = false; if (RuntimeServices.EqualityOperator(UnityRuntimeServices.GetProperty(this.HomeCamera, "DisablePost"), false)) { } } } }
public static IHostBuilder Boot(IHostBuilder hostBuilder, string[] args, ILogger logger, Action <ISImplHostBuilder> configureDelegate) { var diagnostics = DiagnosticsCollector.Create(); // Write welcome to console ConsoleWriteNameAndVersion(); // Parse command line arguments var flags = ParseArgs(args); // Init boot container var bootContainer = InitBootContainer(hostBuilder, logger ?? CreateLogger(), flags, diagnostics); // Init runtime services RuntimeServices.Init(bootContainer.Resolve <IRuntimeServices>()); // Create .NET Stack host builder var dotNetStackHostBuilder = bootContainer.Resolve <ISImplHostBuilder>(); // Start configuration of the host builder dotNetStackHostBuilder.Configure(dotNetStackHostBuilder, stack => { // Pre-installed module stack.Use(() => new StackRuntimeModule(bootContainer)); // Installed modules configureDelegate?.Invoke(stack); }); return(dotNetStackHostBuilder); }
public void Update() { if (RuntimeServices.EqualityOperator(Status.menuMode, "on")) { DepthOfFieldEffect depthOfFieldEffect = (DepthOfFieldEffect)this.GetComponent(typeof(DepthOfFieldEffect)); float deltaTime = Time.get_deltaTime(); if (Input.GetKey("1")) { depthOfFieldEffect.focalDistance -= (float)5 * deltaTime; } if (Input.GetKey("2")) { depthOfFieldEffect.focalDistance += (float)5 * deltaTime; } if (Input.GetKey("3")) { depthOfFieldEffect.focalRange -= (float)50 * deltaTime; } if (Input.GetKey("4")) { depthOfFieldEffect.focalRange += (float)50 * deltaTime; } depthOfFieldEffect.focalDistance = Mathf.Clamp(depthOfFieldEffect.focalDistance, 1f, 50f); depthOfFieldEffect.focalRange = Mathf.Clamp(depthOfFieldEffect.focalRange, 1f, 1000f); } }
public override void endFire() { this.fireStarted = false; if (this.burnP.GetComponent <ParticleEmitter>()) { this.burnP.GetComponent <ParticleEmitter>().emit = false; } IEnumerator enumerator = UnityRuntimeServices.GetEnumerator(this.burnP); while (enumerator.MoveNext()) { object arg_5E_0; object expr_44 = arg_5E_0 = enumerator.Current; if (!(expr_44 is Transform)) { arg_5E_0 = RuntimeServices.Coerce(expr_44, typeof(Transform)); } Transform transform = (Transform)arg_5E_0; if (transform.GetComponent <ParticleEmitter>()) { transform.GetComponent <ParticleEmitter>().emit = false; UnityRuntimeServices.Update(enumerator, transform); } } UnityEngine.Object.Destroy(this); }
public override void Awake() { this.moveDirection = this.get_transform().TransformDirection(Vector3.get_forward()); this._animation = this.GetComponent(typeof(Animation)); if (!RuntimeServices.ToBool(this._animation)) { Debug.Log("The character you would like to control doesn't have animations. Moving her might look weird."); } if (!this.idleAnimation) { this._animation = null; Debug.Log("No idle animation found. Turning off animations."); } if (!this.walkAnimation) { this._animation = null; Debug.Log("No walk animation found. Turning off animations."); } if (!this.runAnimation) { this._animation = null; Debug.Log("No run animation found. Turning off animations."); } if (!this.jumpPoseAnimation && this.canJump) { this._animation = null; Debug.Log("No jump animation found and the character has canJump enabled. Turning off animations."); } }
public override void SpawnPowerUp() { bool flag = false; int num = 0; int num2 = 10000; while (!flag) { object obj = this.worldSize * 0.5f; object value = Mathf.Lerp(RuntimeServices.UnboxSingle(RuntimeServices.InvokeUnaryOperator("op_UnaryNegation", obj)), RuntimeServices.UnboxSingle(obj), Random.get_value()); object value2 = Mathf.Lerp(RuntimeServices.UnboxSingle(RuntimeServices.InvokeUnaryOperator("op_UnaryNegation", obj)), RuntimeServices.UnboxSingle(obj), Random.get_value()); Renderer renderer = (Renderer)this.powerUpPrefab.GetComponent(typeof(Renderer)); float num3 = (renderer.get_bounds().get_max() - renderer.get_bounds().get_min()).get_magnitude() * 0.5f; if (!Physics.CheckSphere(new Vector3(RuntimeServices.UnboxSingle(value), (float)0, RuntimeServices.UnboxSingle(value2)), num3 * (float)2)) { PowerUp powerUp = (PowerUp)Object.Instantiate(this.powerUpPrefab); powerUp.get_transform().set_position(new Vector3(RuntimeServices.UnboxSingle(value), (float)0, RuntimeServices.UnboxSingle(value2))); flag = true; } checked { num++; if (num > num2) { break; } } } }
public virtual void init(RuntimeServices rs) { this.rsvc = rs; /* * if a logger is specified, we will use this instead of * the default */ System.String loggerName = (System.String) rsvc.getProperty("runtime.log.logsystem.avalon.logger"); if (loggerName != null) { this.logger = Hierarchy.DefaultHierarchy.getLoggerFor(loggerName); } else { /* * since this is a Velocity-provided logger, we will * use the Runtime configuration */ System.String logfile = (System.String) rsvc.getProperty(org.apache.velocity.runtime.RuntimeConstants_Fields.RUNTIME_LOG); /* * now init. If we can't, panic! */ try { init(logfile); logVelocityMessage(0, "AvalonLogSystem initialized using logfile '" + logfile + "'"); } catch (System.Exception e) { System.Console.Out.WriteLine("PANIC : Error configuring AvalonLogSystem : " + e); System.Console.Error.WriteLine("PANIC : Error configuring AvalonLogSystem : " + e); throw new System.Exception("Unable to configure AvalonLogSystem : " + e); } } }
static int test_0_reflection() { RuntimeServices r = new RuntimeServices(); r.Run(); return(0); }
public static int CalculateArgumentScore(Type paramType, Type argType) { if (null == argType) { return(!paramType.IsValueType ? ExactMatchScore : -1); } if (paramType == argType) { return(ExactMatchScore); } if (paramType.IsAssignableFrom(argType)) { return(UpCastScore); } if (argType.IsAssignableFrom(paramType)) { return(DowncastScore); } if (IsNumericPromotion(paramType, argType)) { return(NumericTypes.IsWideningPromotion(paramType, argType) ? WideningPromotion : NarrowingPromotion); } var conversion = RuntimeServices.FindImplicitConversionOperator(argType, paramType); if (null != conversion) { return(ImplicitConversionScore); } return(-1); }
public void Update() { if (this.first_time) { this.first_time = false; } checked { if (unchecked (Time.get_time() - this.allPinsTime) >= this.allPinsTimer) { if (!this.Awake) { this.basePinwheelSpeed = 0.2f; } this.allPinsTimer = Random.Range(this.allPinsTimerMin, this.allPinsTimerMax); for (int i = 0; i < Extensions.get_length(this.pinwheels); i++) { float[] expr_68 = this.pinwheelRunTimer; expr_68[RuntimeServices.NormalizeArrayIndex(expr_68, i)] = Random.Range(unchecked (this.allPinsTimer - (float)3), this.allPinsTimer); } this.allPinsTime = Time.get_time(); } for (int i = 0; i < Extensions.get_length(this.pinwheels); i++) { this.PinwheelControl(i); } } }
public void ShouldResolveAssembliesBasedOnScriptWorkingDirectory() { // arrange var fsmock = new Mock <IFileSystem>(); fsmock.Setup(a => a.GetWorkingDirectory(It.IsAny <string>())).Returns("c:/scripts"); var resolvermock = new Mock <IAssemblyResolver>(); resolvermock.Setup(a => a.GetAssemblyPaths("c:/scripts", false)).Returns(new[] { "foo.dll" }); _overrides[typeof(IFileSystem)] = fsmock.Object; _overrides[typeof(IAssemblyResolver)] = resolvermock.Object; var initializationServices = new InitializationServices(_mockLogger.Object, _overrides); var runtimeServices = new RuntimeServices( _mockLogger.Object, _overrides, _mockConsole.Object, _scriptEngineType, _scriptExecutorType, _replType, true, initializationServices, "c:/scriptcs/script.csx"); // act var container = runtimeServices.Container; // assert resolvermock.Verify(x => x.GetAssemblyPaths("c:/scripts", false), Times.Exactly(1)); }
public void Start() { this.Awake = true; this.first_time = true; this.pin_timers = new float[8]; this.current_rotation = new float[8]; this.spin_start_time = new float[8]; this.spinning_up = new bool[8]; this.pinwheelRunTimer = new float[8]; this.allPinsTimer = Random.Range(this.allPinsTimerMin, this.allPinsTimerMax); this.allPinsTime = Time.get_time(); this.allPinsSpeed = (float)1; int i = 0; checked { for (i = 0; i < 8; i++) { float[] expr_89 = this.pin_timers; expr_89[RuntimeServices.NormalizeArrayIndex(expr_89, i)] = (float)0; float[] expr_99 = this.current_rotation; expr_99[RuntimeServices.NormalizeArrayIndex(expr_99, i)] = (float)0; float[] expr_A9 = this.spin_start_time; expr_A9[RuntimeServices.NormalizeArrayIndex(expr_A9, i)] = Time.get_time(); bool[] expr_BC = this.spinning_up; expr_BC[RuntimeServices.NormalizeArrayIndex(expr_BC, i)] = true; float[] expr_D4 = this.pinwheelRunTimer; expr_D4[RuntimeServices.NormalizeArrayIndex(expr_D4, i)] = (float)10; } } }
public void OnDrawGizmosSelected() { if (AutoWayPoint.waypoints.get_length() == 0) { this.RebuildWaypointList(); } IEnumerator enumerator = UnityRuntimeServices.GetEnumerator(this.connected); while (enumerator.MoveNext()) { AutoWayPoint autoWayPoint = (AutoWayPoint)RuntimeServices.Coerce(enumerator.Current, typeof(AutoWayPoint)); if (Physics.Linecast(this.get_transform().get_position(), autoWayPoint.get_transform().get_position())) { Gizmos.set_color(Color.get_red()); Gizmos.DrawLine(this.get_transform().get_position(), autoWayPoint.get_transform().get_position()); UnityRuntimeServices.Update(enumerator, autoWayPoint); } else { Gizmos.set_color(Color.get_green()); Gizmos.DrawLine(this.get_transform().get_position(), autoWayPoint.get_transform().get_position()); UnityRuntimeServices.Update(enumerator, autoWayPoint); } } }
public virtual float GetBestScoreForLevel(int lvlNr, bool checkUserID) { if (MFPClassic.Hook.devMode) { return(0); } float num1 = 0.0f; for (float num2 = new float(); (double)num2 <= 2.0; ++num2) { int num3 = SavedData.GetInt(CryptoString.Encrypt(RuntimeServices.op_Addition(RuntimeServices.op_Addition(RuntimeServices.op_Addition("lvlScore", (object)lvlNr), "diff"), (object)num2))); if ((double)num3 > (double)num1) { if (checkUserID) { string str = SavedData.GetString(CryptoString.Encrypt(RuntimeServices.op_Addition(RuntimeServices.op_Addition(RuntimeServices.op_Addition(RuntimeServices.op_Addition("lvlScore", (object)lvlNr), "diff"), (object)num2), "ID"))); if (this.userID == "0" && str != "-1" && str != "-999" || str == this.userID) { num1 = (float)num3; } } else { num1 = (float)num3; } } } return(num1); }
public void BuildingAnimStart() { GameObject gameObject = GameObject.Find("sceneLight"); GameObject gameObject2 = GameObject.Find("PowerBuilding"); GameObject gameObject3 = GameObject.Find("PetShop"); GameObject gameObject4 = GameObject.Find("ClothesShop"); GameObject gameObject5 = GameObject.Find("CogPinata"); GameObject gameObject6 = GameObject.Find("GagShop"); GameObject gameObject7 = GameObject.Find("MusicShop"); if (gameObject2) { PWR_PowerBuildingControl pWR_PowerBuildingControl = (PWR_PowerBuildingControl)gameObject2.GetComponentInChildren(typeof(PWR_PowerBuildingControl)); bool flag = RuntimeServices.UnboxBoolean(RuntimeServices.GetProperty(gameObject2.GetComponentInChildren(typeof(PWR_PowerBuildingControl)), "Awake")); if (!pWR_PowerBuildingControl) { MonoBehaviour.print("no randomAnimScript"); flag = pWR_PowerBuildingControl.IsAwake(); } gameObject2.BroadcastMessage("ToggleSleepWake"); gameObject3.BroadcastMessage("ToggleSleepWake"); gameObject4.BroadcastMessage("ToggleSleepWake"); gameObject6.BroadcastMessage("ToggleSleepWake"); gameObject5.BroadcastMessage("ToggleSleepWake"); gameObject7.BroadcastMessage("ToggleSleepWake"); } }
public override void Swap(object a, object b) { object value = this.scoresArray[RuntimeServices.UnboxInt32(a)]; this.scoresArray[RuntimeServices.UnboxInt32(a)] = this.scoresArray[RuntimeServices.UnboxInt32(b)]; this.scoresArray[RuntimeServices.UnboxInt32(b)] = value; }
public void ShouldLogAGeneralWarningOnAnAssemblyLoadFailureWhenRunningInRepl() { // arrange var mock = new Mock <IAssemblyResolver>(); mock.Setup(a => a.GetAssemblyPaths(It.IsAny <string>(), false)).Returns(new[] { "/foo.dll" }); _overrides[typeof(IAssemblyResolver)] = mock.Object; var initializationServices = new InitializationServices(_mockLogger.Object, _overrides); var runtimeServices = new RuntimeServices( _mockLogger.Object, _overrides, _mockConsole.Object, _scriptEngineType, _scriptExecutorType, _replType, true, initializationServices, ""); // act var container = runtimeServices.Container; // assert _mockLogger.Verify(l => l.Warn( "Some assemblies failed to load. Launch with '-repl -loglevel debug' to see the details")); }
public void ShouldLogAGeneralWarningOnAnAssemblyLoadFailureWhenRunningScript() { // arrange var mockResolver = new Mock <IAssemblyResolver>(); mockResolver.Setup(a => a.GetAssemblyPaths(It.IsAny <string>(), false)).Returns(new[] { "/foo.dll" }); _overrides[typeof(IAssemblyResolver)] = mockResolver.Object; var mockAssemblyUtility = new Mock <IAssemblyUtility>(); mockAssemblyUtility.Setup(a => a.IsManagedAssembly(It.IsAny <string>())).Returns(true); _overrides[typeof(IAssemblyUtility)] = mockAssemblyUtility.Object; var initializationServices = new InitializationServices(_logProvider, _overrides); var runtimeServices = new RuntimeServices( _logProvider, _overrides, _mockConsole.Object, _scriptEngineType, _scriptExecutorType, _replType, true, initializationServices, "script.csx"); // act var container = runtimeServices.Container; // assert _logProvider.Output.ShouldContain( "WARN: Some assemblies failed to load. Launch with '-loglevel debug' to see the details"); }
public void ShouldLogOnDebugAnAssemblyLoadFailure() { // arrange var mockResolver = new Mock <IAssemblyResolver>(); mockResolver.Setup(a => a.GetAssemblyPaths(It.IsAny <string>(), false)).Returns(new[] { "/foo.dll" }); _overrides[typeof(IAssemblyResolver)] = mockResolver.Object; var mockAssemblyUtility = new Mock <IAssemblyUtility>(); mockAssemblyUtility.Setup(a => a.IsManagedAssembly(It.IsAny <string>())).Returns(true); _overrides[typeof(IAssemblyUtility)] = mockAssemblyUtility.Object; var initializationServices = new InitializationServices(_logProvider, _overrides); var runtimeServices = new RuntimeServices( _logProvider, _overrides, _mockConsole.Object, _scriptEngineType, _scriptExecutorType, _replType, true, initializationServices, "script.csx"); // act var container = runtimeServices.Container; // assert _logProvider.Output.ShouldContain( "DEBUG: Failure loading assembly: /foo.dll. Exception: Could not load file or assembly 'foo.dll' or one of its dependencies. The system cannot find the file specified."); }
public override void ExplodeShip() { GameObject gameObject = GameObject.Find("Astronaut"); if (!gameObject) { MonoBehaviour.print("NO AST"); } object target = Object.Instantiate(this.asteroidExplosion, gameObject.get_transform().get_position(), gameObject.get_transform().get_rotation()); object target2 = UnityRuntimeServices.Invoke(target, "GetComponent", new object[] { "Detonator" }, typeof(MonoBehaviour)); RuntimeServices.SetProperty(target2, "size", 22); AudioSource.PlayClipAtPoint(this.asteroidExplosionSound, gameObject.get_transform().get_position()); GameObject gameObject2 = GameObject.Find("CockpitLowerPlane"); GameObject gameObject3 = GameObject.Find("Windshield1"); GameObject gameObject4 = GameObject.Find("Windshield2"); GameObject gameObject5 = GameObject.Find("daiserCylinder"); Object.Destroy(gameObject2); Object.Destroy(gameObject); Object.Destroy(gameObject3); Object.Destroy(gameObject4); Object.Destroy(gameObject5); }
public static string NormalizeIndentation(string s) { var first = FirstNonEmptyLineOf(s); if (first.Length == 0) { return(s); } string indent = reg.Match(first).Value; if (indent.Length == 0) { return(s); } var result = new StringBuilder(); foreach (string line in TextReaderEnumerator.lines(new StringReader(s))) { if (line.StartsWith(indent)) { result.AppendLine(line.Substring(RuntimeServices.NormalizeStringIndex(line, indent.Length))); } else { result.AppendLine(line); } } return(result.ToString().Trim()); }
public void ShouldLogOnDebugAnAssemblyLoadFailure() { // arrange var mock = new Mock <IAssemblyResolver>(); mock.Setup(a => a.GetAssemblyPaths(It.IsAny <string>(), false)).Returns(new[] { "/foo.dll" }); _overrides[typeof(IAssemblyResolver)] = mock.Object; var initializationServices = new InitializationServices(_mockLogger.Object, _overrides); var runtimeServices = new RuntimeServices( _mockLogger.Object, _overrides, _mockConsole.Object, _scriptEngineType, _scriptExecutorType, _replType, true, initializationServices, "script.csx"); // act var container = runtimeServices.Container; // assert _mockLogger.Verify(l => l.DebugFormat( "Failure loading assembly: {0}. Exception: {1}", "/foo.dll", It.IsAny <string>())); }
/// <summary> The major meat of VelocimacroProxy, init() checks the # of arguments, patches the /// macro body, renders the macro into an AST, and then inits the AST, so it is ready /// for quick rendering. Note that this is only AST dependant stuff. Not context. /// </summary> public override void init(RuntimeServices rs, InternalContextAdapter context, INode node) { base.init(rs, context, node); /* * how many args did we get? */ int i = node.jjtGetNumChildren(); /* * right number of args? */ if (NumArgs != i) { rsvc.error("VM #" + macroName + ": error : too " + ((NumArgs > i) ? "few" : "many") + " arguments to macro. Wanted " + NumArgs + " got " + i); return; } /* * get the argument list to the instance use of the VM */ callingArgs = getArgArray(node); /* * now proxy each arg in the context */ setupMacro(callingArgs, callingArgTypes); return; }
public TheContainerProperty() { _overrides[typeof(ILineProcessor)] = new List <Type>(); var mockScriptExecutorType = new Mock <IScriptExecutor>(); _scriptExecutorType = mockScriptExecutorType.Object.GetType(); var mockReplType = new Mock <IRepl>(); _replType = mockReplType.Object.GetType(); var mockScriptEngineType = new Mock <IScriptEngine>(); _scriptEngineType = mockScriptEngineType.Object.GetType(); var initializationServices = new InitializationServices(_mockLogger.Object, _overrides); _runtimeServices = new RuntimeServices( _mockLogger.Object, _overrides, _mockConsole.Object, _scriptEngineType, _scriptExecutorType, _replType, false, initializationServices, "script.csx"); }
private Dispatcher CreateSetter(MemberInfo member) { switch (member.MemberType) { case MemberTypes.Field: { var field = (FieldInfo)member; return ((o, arguments) => RuntimeServices.SetSlice(field.GetValue(o), string.Empty, arguments)); } case MemberTypes.Property: { var property = (PropertyInfo)member; if (property.GetIndexParameters().Length > 0) { MethodInfo setter = property.GetSetMethod(true); if (null == setter) { throw MissingField(); } return(EmitMethodDispatcher(setter)); } return((o, arguments) => RuntimeServices.SetSlice(RuntimeServices.GetProperty(o, _name), string.Empty, arguments)); } default: { throw MissingField(); } } }
public override void Awake() { if (!this.cameraTransform && Camera.get_main()) { this.cameraTransform = Camera.get_main().get_transform(); } if (!this.cameraTransform) { Debug.Log("Please assign a camera to the ThirdPersonCamera script."); this.set_enabled(false); } this._target = this.get_transform(); if (this._target) { this.controller = (ThirdPersonController)this._target.GetComponent(typeof(ThirdPersonController)); } if (this.controller) { CharacterController characterController = (CharacterController)RuntimeServices.Coerce(this._target.get_collider(), typeof(CharacterController)); this.centerOffset = characterController.get_bounds().get_center() - this._target.get_position(); this.headOffset = this.centerOffset; this.headOffset.y = characterController.get_bounds().get_max().y - this._target.get_position().y; } else { Debug.Log("Please assign a target to the camera that has a ThirdPersonController script attached."); } this.Cut(this._target, this.centerOffset); }
public void Warnings_Adding(object sender, CompilerWarningEventArgs args) { if (RuntimeServices.op_Member(args.Warning.Code, (IList)this._suppressed)) { args.Cancel(); } }
public void PrintTag(object tagTransform) { if (RuntimeServices.ToBool(RuntimeServices.Invoke(tagTransform, "CompareTag", new object[] { "WayPointA" }))) { MonoBehaviour.print("FOLLOW: picked WayPointA"); } else if (RuntimeServices.ToBool(RuntimeServices.Invoke(tagTransform, "CompareTag", new object[] { "WayPointB" }))) { MonoBehaviour.print("FOLLOW: picked WayPointB"); } else if (RuntimeServices.ToBool(RuntimeServices.Invoke(tagTransform, "CompareTag", new object[] { "WayPointC" }))) { MonoBehaviour.print("FOLLOW: picked WayPointC"); } else { MonoBehaviour.print("FOLLOW: compare tag didn't return anything "); } }
public void Start() { float num = 0f; this.actionRateFloat = new float[Extensions.get_length(this.IdleActions)]; this.lastTimeRun = new float[Extensions.get_length(this.IdleActions)]; if (IdleLogic.firstTime) { IdleLogic.actionIndex = 0; checked { for (int i = 0; i < Extensions.get_length(this.IdleActions); i++) { float[] expr_53 = this.actionRateFloat; int arg_96_1 = RuntimeServices.NormalizeArrayIndex(expr_53, i); Animation arg_73_0 = this.get_animation(); AnimInfo[] expr_66 = this.IdleActions; float arg_95_0 = arg_73_0.get_Item(expr_66[RuntimeServices.NormalizeArrayIndex(expr_66, i)].anim).get_clip().get_length(); AnimInfo[] expr_88 = this.IdleActions; unchecked { expr_53[arg_96_1] = arg_95_0 * expr_88[RuntimeServices.NormalizeArrayIndex(expr_88, i)].max_dur; float[] expr_9D = this.lastTimeRun; expr_9D[RuntimeServices.NormalizeArrayIndex(expr_9D, i)] = 100f * (float)-1; } } IdleLogic.firstTime = false; this.lastTimeRun[0] = Time.get_time(); this.num_iter = (int)Random.Range((float)1, this.IdleActions[0].max_dur); } this.run_length = (float)this.num_iter * this.get_animation().get_Item(this.IdleActions[0].anim).get_clip().get_length(); this.get_animation().Play(this.IdleActions[0].anim); } }
public override void init(RuntimeServices rs, InternalContextAdapter context, Node node) { base.init(rs, context, node); /* * again, don't do squat. We want the AST of the macro * block to hang off of this but we don't want to * init it... it's useless... */ return ; }
public void ShouldLogOnDebugAnAssemblyLoadFailure() { var mock = new Mock<IAssemblyResolver>(); mock.Setup(a => a.GetAssemblyPaths(It.IsAny<string>())).Returns(new[] {"foo.dll"}); _overrides[typeof (IAssemblyResolver)] = mock.Object; var initializationServices = new InitializationServices(_mockLogger.Object, _overrides); var runtimeServices = new RuntimeServices(_mockLogger.Object, _overrides, new List<Type>(), _mockConsole.Object, _scriptEngineType, _scriptExecutorType, true, initializationServices, "script.csx"); var container = runtimeServices.Container; _mockLogger.Verify(l=>l.DebugFormat("Failure loading assembly: {0}. Exception: {1}", "foo.dll", "Could not load file or assembly 'foo.dll' or one of its dependencies. The system cannot find the file specified.")); }
public void ShouldLogAGeneralWarningOnAnAssemblyLoadFailureWhenRunningScript() { var mock = new Mock<IAssemblyResolver>(); mock.Setup(a => a.GetAssemblyPaths(It.IsAny<string>())).Returns(new[] { "foo.dll" }); _overrides[typeof(IAssemblyResolver)] = mock.Object; var initializationServices = new InitializationServices(_mockLogger.Object, _overrides); var runtimeServices = new RuntimeServices(_mockLogger.Object, _overrides, new List<Type>(), _mockConsole.Object, _scriptEngineType, _scriptExecutorType, true, initializationServices, "script.csx"); var container = runtimeServices.Container; _mockLogger.Verify(l => l.Warn("Some assemblies failed to load. Launch with '-loglevel debug' to see the details")); }
public TheCreateContainerMethod() { var mockScriptExecutorType = new Mock<IScriptExecutor>(); _scriptExecutorType = mockScriptExecutorType.Object.GetType(); var mockScriptEngineType = new Mock<IScriptEngine>(); _scriptEngineType = mockScriptEngineType.Object.GetType(); var initializationServices = new InitializationServices(_mockLogger.Object, _overrides); _runtimeServices = new RuntimeServices(_mockLogger.Object, _overrides, new List<Type>(), _mockConsole.Object, _scriptEngineType, _scriptExecutorType, false, initializationServices, "script.csx"); }
/// /// <summary> This constructor was added to allow the re-use of parsers. /// The normal constructor takes a single argument which /// an InputStream. This simply creates a re-usable parser /// object, we satisfy the requirement of an InputStream /// by using a newline character as an input stream. /// </summary> public Parser(RuntimeServices rs):this(new VelocityCharStream(new StringReader("\n"), 1, 1)) { InitBlock(); /* * now setup a VCS for later use */ velcharstream = new VelocityCharStream(new StringReader("\n"), 1, 1); /* * and save the RuntimeServices */ rsvc = rs; }
/// <summary> /// Used by Parser.java to process VMs withing the parsing process /// /// processAndRegister() doesn't actually render the macro to the output /// Processes the macro body into the internal representation used by the /// VelocimacroProxy objects, and if not currently used, adds it /// to the macro Factory /// </summary> public static void processAndRegister(RuntimeServices rs, Node node, System.String sourceTemplate) { /* * There must be at least one arg to #macro, * the name of the VM. Note that 0 following * args is ok for naming blocks of HTML */ int numArgs = node.jjtGetNumChildren(); /* * this number is the # of args + 1. The + 1 * is for the block tree */ if (numArgs < 2) { /* * error - they didn't name the macro or * define a block */ rs.error("#macro error : Velocimacro must have name as 1st " + "argument to #macro()"); return ; } /* * get the arguments to the use of the VM */ System.String[] argArray = getArgArray(node); /* * now, try and eat the code block. Pass the root. */ IList macroArray = getASTAsStringArray(node.jjtGetChild(numArgs - 1)); /* * make a big string out of our macro */ System.Text.StringBuilder temp = new System.Text.StringBuilder(); for (int i = 0; i < macroArray.Count; i++) temp.Append(macroArray[i]); System.String macroBody = temp.ToString(); /* * now, try to add it. The Factory controls permissions, * so just give it a whack... */ bool bRet = rs.addVelocimacro(argArray[0], macroBody, argArray, sourceTemplate); return ; }
/// <summary> /// Default constructor. /// </summary> public GetExecutor(RuntimeServices r, System.Type c, System.String key) { rsvc = r; args[0] = key; // NOTE: changed from get to get to get_Item - assumption is that get would be converted to an indexer in .Net // to keep some resembalance to the Java version, look for "Get" and "get" methods as well (both cases for .Net style and java) method = rsvc.Introspector.getMethod(c, "get_Item", args); if (method==null) { method = rsvc.Introspector.getMethod(c, "Get", args); if (method==null) { method = rsvc.Introspector.getMethod(c, "get", args); } } }
/// <summary> /// Gets the loader specified in the configuration file. /// </summary> /// <returns>TemplateLoader</returns> public static ResourceLoader getLoader(RuntimeServices rs, System.String loaderClassName) { ResourceLoader loader = null; try { // since properties are parsed into arrays with commas, something else needed to be used loaderClassName = loaderClassName.Replace(';', ','); Type loaderType = System.Type.GetType(loaderClassName); Object o = System.Activator.CreateInstance(loaderType); loader = (ResourceLoader) o; rs.info("Resource Loader Instantiated: " + loader.GetType().FullName); return loader; } catch (System.Exception e) { rs.error("Problem instantiating the template loader.\n" + "Look at your properties file and make sure the\n" + "name of the template loader is correct. Here is the\n" + "error: " + StringUtils.stackTrace(e)); throw new System.Exception("Problem initializing template loader: " + loaderClassName + "\nError is: " + StringUtils.stackTrace(e)); } }
/// <summary> This initialization is used by all resource /// loaders and must be called to set up common /// properties shared by all resource loaders /// </summary> public virtual void commonInit(RuntimeServices rs, ExtendedProperties configuration) { this.rsvc = rs; /* * these two properties are not required for all loaders. * For example, for ClasspathLoader, what would cache mean? * so adding default values which I think are the safest * * don't cache, and modCheckInterval irrelevant... */ isCachingOn_Renamed_Field = configuration.GetBoolean("cache", false); modificationCheckInterval = configuration.GetLong("modificationCheckInterval", 0); /* * this is a must! */ className = configuration.GetString("class"); }
public TheContainerProperty() { _overrides[typeof(ILineProcessor)] = new List<Type>(); var mockScriptExecutorType = new Mock<IScriptExecutor>(); _scriptExecutorType = mockScriptExecutorType.Object.GetType(); var mockReplType = new Mock<IRepl>(); _replType = mockReplType.Object.GetType(); var mockScriptEngineType = new Mock<IScriptEngine>(); _scriptEngineType = mockScriptEngineType.Object.GetType(); var initializationServices = new InitializationServices(_logProvider, _overrides); _runtimeServices = new RuntimeServices( _logProvider, _overrides, _mockConsole.Object, _scriptEngineType, _scriptExecutorType, _replType, false, initializationServices, "script.csx"); }
public void ShouldResolveAssembliesBasedOnScriptWorkingDirectory() { // arrange var fsmock = new Mock<IFileSystem>(); fsmock.Setup(a => a.GetWorkingDirectory(It.IsAny<string>())).Returns("c:/scripts"); var resolvermock = new Mock<IAssemblyResolver>(); resolvermock.Setup(a => a.GetAssemblyPaths("c:/scripts", false)).Returns(new[] { "foo.dll" }); _overrides[typeof(IFileSystem)] = fsmock.Object; _overrides[typeof(IAssemblyResolver)] = resolvermock.Object; var initializationServices = new InitializationServices(_logProvider, _overrides); var runtimeServices = new RuntimeServices( _logProvider, _overrides, _mockConsole.Object, _scriptEngineType, _scriptExecutorType, _replType, true, initializationServices, "c:/scriptcs/script.csx"); // act var container = runtimeServices.Container; // assert resolvermock.Verify(x => x.GetAssemblyPaths("c:/scripts", false), Times.Exactly(1)); }
/// <summary> Return name of this directive. /// </summary> /// <summary> Return type of this directive. /// </summary> /// <summary> Store the literal rendition of a node using /// the Node.literal(). /// </summary> public override void init(RuntimeServices rs, InternalContextAdapter context, INode node) { base.init(rs, context, node); literalText = node.jjtGetChild(0).literal(); }
public virtual void init(RuntimeServices rs) { rsvc = rs; /* * since this is a Velocity-provided logger, we will * use the Runtime configuration */ logfile = rsvc.getString(RuntimeConstants.RUNTIME_LOG); /* * now init. If we can't, panic! */ try { internalInit(); logVelocityMessage(0, "Log4JLogSystem initialized using logfile " + logfile); } catch (System.Exception e) { System.Console.Out.WriteLine("PANIC : error configuring Log4JLogSystem : " + e); } }
/// <summary> Initialize the ResourceManager. It is assumed /// that assembleSourceInitializers() has been /// called before this is run. /// </summary> public virtual void initialize(RuntimeServices rs) { rsvc = rs; rsvc.info("Default ResourceManager initializing. (" + this.GetType() + ")"); ResourceLoader resourceLoader; assembleResourceLoaderInitializers(); for (int i = 0; i < sourceInitializerList.Count; i++) { ExtendedProperties configuration = (ExtendedProperties) sourceInitializerList[i]; System.String loaderClass = configuration.GetString("class"); if (loaderClass == null) { rsvc.error("Unable to find '" + configuration.GetString(RESOURCE_LOADER_IDENTIFIER) + ".resource.loader.class' specification in configuation." + " This is a critical value. Please adjust configuration."); continue; } resourceLoader = ResourceLoaderFactory.getLoader(rsvc, loaderClass); resourceLoader.commonInit(rsvc, configuration); resourceLoader.init(configuration); resourceLoaders.Add(resourceLoader); } /* * now see if this is overridden by configuration */ logWhenFound = rsvc.getBoolean(NVelocity.Runtime.RuntimeConstants_Fields.RESOURCE_MANAGER_LOGWHENFOUND, true); /* * now, is a global cache specified? */ System.String claz = rsvc.getString(NVelocity.Runtime.RuntimeConstants_Fields.RESOURCE_MANAGER_CACHE_CLASS); System.Object o = null; if (claz != null && claz.Length > 0) { try { Type type = System.Type.GetType(claz); o = System.Activator.CreateInstance(type); } catch (System.Exception cnfe) { System.String err = "The specified class for ResourceCache (" + claz + ") does not exist (or is not accessible to the current classlaoder)."; rsvc.error(err); o = null; } if (!(o is ResourceCache)) { System.String err = "The specified class for ResourceCache (" + claz + ") does not implement NVelocity.Runtime.Resource.ResourceCache." + " Using default ResourceCache implementation."; rsvc.error(err); o = null; } } /* * if we didn't get through that, just use the default. */ if (o == null) { o = new ResourceCacheImpl(); } globalCache = (ResourceCache) o; globalCache.initialize(rsvc); rsvc.info("Default ResourceManager initialization complete."); }
public virtual void init(RuntimeServices rs) { /* don't need it...*/ }
/// <summary> ctor for current impl /// * /// takes the reference literal we are proxying for, the literal /// the VM we are for is called with... /// * /// </summary> /// <param name="contextRef">reference arg in the definition of the VM, used in the VM /// </param> /// <param name="callerRef"> reference used by the caller as an arg to the VM /// </param> /// <param name="t"> type of arg : JJTREFERENCE, JJTTRUE, etc /// /// </param> public VMProxyArg(RuntimeServices rs, System.String contextRef, System.String callerRef, int t) { rsvc = rs; contextReference = contextRef; callerReference = callerRef; type = t; /* * make our AST if necessary */ setup(); /* * if we are multi-node tree, then save the size to * avoid fn call overhead */ if (nodeTree != null) numTreeChildren = nodeTree.jjtGetNumChildren(); /* * if we are a reference, and 'scalar' (i.e. $foo ) * then get the de-dollared ref so we can * hit our context directly, avoiding the AST */ if (type == NVelocity.Runtime.Parser.ParserTreeConstants.JJTREFERENCE) { if (numTreeChildren == 0) { /* * do this properly and use the Reference node */ singleLevelRef = ((ASTReference) nodeTree).RootString; } } }
/// <summary> CTOR : requires a runtime services from now /// on /// </summary> public VelocimacroFactory(RuntimeServices rs) { this.rsvc = rs; /* * we always access in a synchronized(), so we * can use an unsynchronized hashmap */ libModMap = new Hashtable(); vmManager = new VelocimacroManager(rsvc); }
/// <summary> Creates a new logging system or returns an existing one /// specified by the application. /// </summary> public static LogSystem createLogSystem(RuntimeServices rsvc) { // if a logSystem was set as a configuation value, use that. // This is any class the user specifies. System.Object o = rsvc.getProperty(NVelocity.Runtime.RuntimeConstants_Fields.RUNTIME_LOG_LOGSYSTEM); if (o != null && o is LogSystem) { ((LogSystem) o).Init(rsvc); return (LogSystem) o; } // otherwise, see if a class was specified. You // can put multiple classes, and we use the first one we find. // // Note that the default value of this property contains both the // AvalonLogSystem and the SimpleLog4JLogSystem for convenience - // so we use whichever we find. IList classes = new ArrayList(); System.Object obj = rsvc.getProperty(NVelocity.Runtime.RuntimeConstants_Fields.RUNTIME_LOG_LOGSYSTEM_CLASS); // we might have a list, or not - so check if (obj is IList) { classes = (IList) obj; } else if (obj is System.String) { classes.Add(obj); } // now run through the list, trying each. It's ok to // fail with a class not found, as we do this to also // search out a default simple file logger foreach(String clazz in classes) { if (clazz != null && clazz.Length > 0) { rsvc.info("Trying to use logger class " + clazz); try { System.Type type = System.Type.GetType(clazz); o = System.Activator.CreateInstance(type); if (o is LogSystem) { ((LogSystem) o).Init(rsvc); rsvc.info("Using logger class " + clazz); return (LogSystem) o; } else { rsvc.error("The specifid logger class " + clazz + " isn't a valid LogSystem"); } } catch (System.ApplicationException ncdfe) { rsvc.info("Couldn't find class " + clazz + " or necessary supporting classes in classpath. Exception : " + ncdfe); } } } // if the above failed, then we are in deep doo-doo, as the // above means that either the user specified a logging class // that we can't find, there weren't the necessary // dependencies in the classpath for it, or there were no // dependencies for the default logger. // Since we really don't know, // then take a wack at the log4net as a last resort. LogSystem als = null; try { als = new SimpleLog4NetLogSystem(); als.Init(rsvc); } catch (System.ApplicationException ncdfe) { System.String errstr = "PANIC : NVelocity cannot find any of the" + " specified or default logging systems in the classpath," + " or the classpath doesn't contain the necessary classes" + " to support them." + " Please consult the documentation regarding logging." + " Exception : " + ncdfe; System.Console.Out.WriteLine(errstr); System.Console.Error.WriteLine(errstr); throw; } rsvc.info("Using log4net as logger of final resort."); return als; }
public void ShouldLogAGeneralWarningOnAnAssemblyLoadFailureWhenRunningScript() { // arrange var mockResolver = new Mock<IAssemblyResolver>(); mockResolver.Setup(a => a.GetAssemblyPaths(It.IsAny<string>(), false)).Returns(new[] { "/foo.dll" }); _overrides[typeof(IAssemblyResolver)] = mockResolver.Object; var mockAssemblyUtility = new Mock<IAssemblyUtility>(); mockAssemblyUtility.Setup(a => a.IsManagedAssembly(It.IsAny<string>())).Returns(true); _overrides[typeof(IAssemblyUtility)] = mockAssemblyUtility.Object; var initializationServices = new InitializationServices(_logProvider, _overrides); var runtimeServices = new RuntimeServices( _logProvider, _overrides, _mockConsole.Object, _scriptEngineType, _scriptExecutorType, _replType, true, initializationServices, "script.csx"); // act var container = runtimeServices.Container; // assert _logProvider.Output.ShouldContain( "WARN: Some assemblies failed to load. Launch with '-loglevel debug' to see the details"); }
public virtual void init(RuntimeServices rs) { // do nothing with it }
/// <summary> CTOR, wraps an ICA /// </summary> public VMContext(InternalContextAdapter inner, RuntimeServices rsvc) { InitBlock(); localcontextscope = rsvc.getBoolean(RuntimeConstants_Fields.VM_CONTEXT_LOCALSCOPE, false); wrappedContext = inner; innerContext = inner.BaseContext; }
/// <summary>for log msg purposes /// </summary> /// <summary>for log msg purposes /// </summary> /// <summary> How this directive is to be initialized. /// </summary> public virtual void init(RuntimeServices rs, InternalContextAdapter context, INode node) { rsvc = rs; // int i, k = node.jjtGetNumChildren(); //for (i = 0; i < k; i++) // node.jjtGetChild(i).init(context, rs); }
public void ShouldLogOnDebugAnAssemblyLoadFailure() { var mock = new Mock<IAssemblyResolver>(); mock.Setup(a => a.GetAssemblyPaths(It.IsAny<string>(), false)).Returns(new[] { "/foo.dll" }); _overrides[typeof(IAssemblyResolver)] = mock.Object; var initializationServices = new InitializationServices(_mockLogger.Object, _overrides); var runtimeServices = new RuntimeServices(_mockLogger.Object, _overrides, _mockConsole.Object, _scriptEngineType, _scriptExecutorType, _replType, true, initializationServices, "script.csx"); var container = runtimeServices.Container; _mockLogger.Verify(l => l.DebugFormat("Failure loading assembly: {0}. Exception: {1}", "/foo.dll", It.IsAny<string>())); }
/// <summary> The major meat of VelocimacroProxy, init() checks the # of arguments, patches the /// macro body, renders the macro into an AST, and then inits the AST, so it is ready /// for quick rendering. Note that this is only AST dependant stuff. Not context. /// </summary> public override void init(RuntimeServices rs, InternalContextAdapter context, INode node) { base.init(rs, context, node); /* * how many args did we get? */ int i = node.jjtGetNumChildren(); /* * right number of args? */ if (NumArgs != i) { rsvc.error("VM #" + macroName + ": error : too " + ((NumArgs > i)?"few":"many") + " arguments to macro. Wanted " + NumArgs + " got " + i); return ; } /* * get the argument list to the instance use of the VM */ callingArgs = getArgArray(node); /* * now proxy each arg in the context */ setupMacro(callingArgs, callingArgTypes); return ; }
public virtual void Init(RuntimeServices rs) { rsvc = rs; }
public virtual void initialize(RuntimeServices rs) { rsvc = rs; rsvc.info("ResourceCache : initialized. (" + this.GetType() + ")"); }
public void ShouldLogOnDebugAnAssemblyLoadFailure() { // arrange var mockResolver = new Mock<IAssemblyResolver>(); mockResolver.Setup(a => a.GetAssemblyPaths(It.IsAny<string>(), false)).Returns(new[] { "/foo.dll" }); _overrides[typeof(IAssemblyResolver)] = mockResolver.Object; var mockAssemblyUtility = new Mock<IAssemblyUtility>(); mockAssemblyUtility.Setup(a => a.IsManagedAssembly(It.IsAny<string>())).Returns(true); _overrides[typeof(IAssemblyUtility)] = mockAssemblyUtility.Object; var initializationServices = new InitializationServices(_logProvider, _overrides); var runtimeServices = new RuntimeServices( _logProvider, _overrides, _mockConsole.Object, _scriptEngineType, _scriptExecutorType, _replType, true, initializationServices, "script.csx"); // act var container = runtimeServices.Container; // assert _logProvider.Output.ShouldContain( "DEBUG: Failure loading assembly: /foo.dll. Exception: Could not load file or assembly 'foo.dll' or one of its dependencies. The system cannot find the file specified."); }
public virtual void Init(RuntimeServices rs) {}
/// <summary> Adds the global namespace to the hash. /// </summary> internal VelocimacroManager(RuntimeServices rs) { InitBlock(); this.rsvc = rs; /* * add the global namespace to the namespace hash. We always have that. */ addNamespace(GLOBAL_NAMESPACE); }