public void RequestData() { this.StartLoading(); var client = this.clientFactory.CreateClient(); client.GetTargetingTypePortfolioPickerCompleted += (sender, args) => RuntimeHelper.TakeCareOfResult("Getting data for the picker", args, x => x.Result, this.TakeData, this.FinishLoading); client.GetTargetingTypePortfolioPickerAsync(); }
public void RequestData() { this.StartLoading(); var client = this.clientFactory.CreateClient(); client.GetBottomUpPortfolioPickerCompleted += (sender, args) => RuntimeHelper.TakeCareOfResult("Getting picker data for the bottom up editor", args, x => x.Result, this.TakeData, this.FinishLoading); client.GetBottomUpPortfolioPickerAsync(this.clientFactory.GetUsername()); }
public void RequestSecurities(String pattern, Action <IEnumerable <ISecurity> > callback, Action <Exception> errorHandler) { var client = this.clientFactory.CreateClient(); client.GetIssuerSecuritiesCompleted += (sender, args) => RuntimeHelper.TakeCareOfResult( "Getting securities like \"" + pattern + "\" for security issuer (ID: " + this.securityShortName + ")", args, x => x.Result.Select(y => Helper.As <ISecurity>(y)), callback, errorHandler); client.GetIssuerSecuritiesAsync(pattern, MaxNumberOfSecurities, this.securityShortName); }
public static string GetExecutableArgs(string args) { if (RuntimeHelper.IsCoreClr()) { args = $"{Path.Combine(GetExeDirectory(), "gitversion.dll")} {args}"; } return(args); }
static HotKeyHelper() { _locks = new Dictionary <HotKeyAction, bool>(); foreach (HotKeyAction da in RuntimeHelper.GetEnumElements <HotKeyAction>()) { _locks.Add(da, false); } }
public void SetV2(int key, Vector2 value) { int keyX = RuntimeHelper.CombineHashCodes(key, "x"); int keyY = RuntimeHelper.CombineHashCodes(key, "y"); this[keyX] = value.x; this[keyY] = value.y; }
private bool CheckAvailability() { if (RuntimeHelper.IsWindows()) { return(_commandRunner.Execute(PathToNuget) == 0); } return(_commandRunner.Execute("mono", PathToNuget) == 0); }
public void Should_Determine_If_Toplevel_Interface() { Assert.IsTrue(RuntimeHelper.IsTopLevelInterface(typeof(IBar), typeof(Bar))); Assert.IsTrue(RuntimeHelper.IsTopLevelInterface(typeof(IBaz), typeof(Baz))); Assert.IsTrue(RuntimeHelper.IsTopLevelInterface(typeof(IBoo), typeof(Baz))); Assert.IsFalse(RuntimeHelper.IsTopLevelInterface(typeof(IBar), typeof(Baz))); Assert.IsFalse(RuntimeHelper.IsTopLevelInterface(typeof(IFoo), typeof(Bar))); Assert.IsFalse(RuntimeHelper.IsTopLevelInterface(typeof(IFoo), typeof(Baz))); }
void StoreValidRect() { if (!_storedValidRect && _validRect.HasValue) { var key = RuntimeHelper.CombineHashCodes(_id, "rabbit_coords"); _prefs.Vector3s[key] = new Vector3(_validRect.Value.x, _validRect.Value.y); _storedValidRect = true; } }
private void SetImageSize() { if (!imageLayout) { return; } RuntimeHelper.StartCoroutine(SetImageSizeCoro()); }
public void ShouldHandlePackageWithNativeLibraries() { // We have no story for this on *nix yet if (RuntimeHelper.IsWindows()) { var result = Execute(Path.Combine("NativeLibrary", "NativeLibrary.csx")); Assert.Contains("Connection successful", result.output); } }
public void Should_Create_Single_Arg_Action() { var call = RuntimeHelper.CreateCallOneArg( typeof(Handler).GetMethod("HandleOne")); var handler = new Handler(); call(handler, "Hello"); Assert.AreEqual("Hello", handler.Arg1); }
public void RequestTrackingAuthorization(Action <AppTrackingAuthorizationStatus> callback) { Util.NullArgumentTest(callback); callback = RuntimeHelper.ToMainThread(callback); ATTrackingManager.RequestTrackingAuthorization(status => { callback((AppTrackingAuthorizationStatus)status); }); }
public void OnNativeCallback(string error) { if (callback == null) { return; } RuntimeHelper.RunOnMainThread(() => callback(error)); }
private void InvokeCallback(string errorMessage, Contact contact) { if (callback == null) { return; } RuntimeHelper.RunOnMainThread(() => callback(errorMessage, contact)); }
public void Should_Create_Two_Args_Function() { var call = RuntimeHelper.CreateFuncTwoArgs( typeof(Provider).GetMethod("ProvideTwo")); var provider = new Provider(); Assert.AreEqual(new DateTime(2003, 4, 9), call(provider, 2, new DateTime(2003, 4, 7))); }
public void OnNativeCallback(string error, AndroidJavaObject result) { if (callback == null) { return; } RuntimeHelper.RunOnMainThread(() => callback(error, (MediaResult) new AndroidMediaResultBridge(result))); }
private void OnEnable() { if (prefs == null) { // TODO CHANGED: A common interface is now used for both cases. var t0 = target as IVFWObject; if (t0 != null) { if (t0.Prefs == null) { t0.Prefs = new EditorRecord(); } prefs = t0.Prefs; } //var t0 = target as BaseBehaviour; //if (t0 != null) //{ // if (t0.Prefs == null) // t0.Prefs = new EditorRecord(); // prefs = t0.Prefs; //} //else //{ // var t1 = target as BaseScriptableObject; // if (t1 != null) // { // if (t1.Prefs == null) // t1.Prefs = new EditorRecord(); // prefs = t1.Prefs; // } //} } var component = target as Component; gameObject = component == null ? null : component.gameObject; targetType = target.GetType(); id = RuntimeHelper.GetTargetID(target); Initialize(); var rabbit = gui as RabbitGUI; if (rabbit != null && _membersDrawnByUnityLayout.Length > 0) { rabbit.OnFinishedLayoutReserve = DoUnityLayout; } gui.OnEnable(); }
public virtual ScriptCompilationContext <TReturn> CreateCompilationContext <TReturn, THost>(ScriptContext context) { if (context == null) { throw new ArgumentNullException(nameof(context)); } var platformIdentifier = RuntimeHelper.GetPlatformIdentifier(); Logger.Verbose($"Current runtime is '{platformIdentifier}'."); var opts = CreateScriptOptions(context); var runtimeId = RuntimeHelper.GetRuntimeIdentifier(); var inheritedAssemblyNames = DependencyContext.Default.GetRuntimeAssemblyNames(runtimeId).Where(x => x.FullName.StartsWith("system.", StringComparison.OrdinalIgnoreCase) || x.FullName.StartsWith("microsoft.codeanalysis", StringComparison.OrdinalIgnoreCase) || x.FullName.StartsWith("mscorlib", StringComparison.OrdinalIgnoreCase)).ToArray(); IList <RuntimeDependency> runtimeDependencies = RuntimeDependencyResolver.GetDependencies(context.WorkingDirectory).ToList(); foreach (var runtimeDependency in runtimeDependencies) { Logger.Verbose("Adding reference to a runtime dependency => " + runtimeDependency); opts = opts.AddReferences(MetadataReference.CreateFromFile(runtimeDependency.Path)); } foreach (var inheritedAssemblyName in inheritedAssemblyNames) { Logger.Verbose("Adding reference to an inherited dependency => " + inheritedAssemblyName.FullName); // Always prefer the resolved runtime dependency rather than the inherited assembly. if (runtimeDependencies.All(rd => rd.Name.Name != inheritedAssemblyName.Name)) { var assembly = Assembly.Load(inheritedAssemblyName); opts = opts.AddReferences(assembly); } } var loader = new InteractiveAssemblyLoader(); var script = CSharpScript.Create <TReturn>(context.Code.ToString(), opts, typeof(THost), loader); var orderedDiagnostics = script.GetDiagnostics(SuppressedDiagnosticIds); if (orderedDiagnostics.Any(d => d.Severity == DiagnosticSeverity.Error)) { foreach (var diagnostic in orderedDiagnostics) { Logger.Log(diagnostic.ToString()); } throw new CompilationErrorException("Script compilation failed due to one or more errors.", orderedDiagnostics.ToImmutableArray()); } return(new ScriptCompilationContext <TReturn>(script, context.Code, loader, opts)); }
//重写Autofac管道Load方法,在这里注册注入 protected override void Load(ContainerBuilder builder) { var assemblys = RuntimeHelper.GetAllAssemblies().ToArray(); //builder.RegisterAssemblyTypes(assemblys).Where(t => t.Name.EndsWith("Repository") && !t.Name.StartsWith("I")).AsImplementedInterfaces(); //注册Service中的对象,Service中的类要以Service结尾,否则注册失败 builder.RegisterAssemblyTypes(GetAssemblyByName("CMS.Service")).Where(a => a.Name.EndsWith("Service")).AsImplementedInterfaces(); //注册Repository中的对象,Repository中的类要以Repository结尾,否则注册失败 builder.RegisterAssemblyTypes(GetAssemblyByName("CMS.Repository")).Where(a => a.Name.EndsWith("Repository")).AsImplementedInterfaces(); }
public static void ShouldHandleIssue166() { // System.Data.SqlClient loads native assets // No story on *nix yet. if (RuntimeHelper.IsWindows()) { var result = Execute(Path.Combine("Issue166", "Issue166.csx")); Assert.Contains("Connection successful", result.output); } }
public TextFilter(string[] values, int id, bool initialToggle, EditorRecord prefs, Action <string> setValue) { _prefs = prefs; _values = values; _setValue = setValue; _id = RuntimeHelper.CombineHashCodes(id, "Filter"); _toggle = _prefs.ValueOrDefault(this._id, initialToggle); _pattern = _prefs.ValueOrDefault(this._id, ""); }
public void ValidateEEARegionStatus(List <EEARegionValidationMethods> methods, Action <EEARegionStatus> callback) { if (isValidateCoroutineRunning) { Debug.Log("Another validation progress is running."); return; } RuntimeHelper.RunCoroutine(ValidateEEARegionStatusCoroutine(methods, callback)); }
public void Should_Create_Double_Arg_Action() { var call = RuntimeHelper.CreateCallTwoArgs( typeof(Handler).GetMethod("HandleTwo")); var handler = new Handler(); call(handler, false, new DateTime(2007, 6, 14)); Assert.AreEqual(false, handler.Arg1); Assert.AreEqual(new DateTime(2007, 6, 14), handler.Arg2); }
/// <summary> /// Raises the <see cref="RewardedAdSkipped"/> event on main thread. /// </summary> /// <param name="placement">Placement.</param> protected virtual void OnRewardedAdSkipped(AdPlacement placement) { RuntimeHelper.RunOnMainThread(() => { if (RewardedAdSkipped != null) { RewardedAdSkipped(this, placement); } }); }
/// <summary> /// Raises the <see cref="RewardedInterstitialAdCompleted"/> event on main thread. /// </summary> /// <param name="placement">Placement.</param> protected virtual void OnRewardedInterstitialAdCompleted(AdPlacement placement) { RuntimeHelper.RunOnMainThread(() => { if (RewardedInterstitialAdCompleted != null) { RewardedInterstitialAdCompleted(this, placement); } }); }
public void SetV3(int key, Vector3 value) { int keyX = RuntimeHelper.CombineHashCodes(key, "x"); int keyY = RuntimeHelper.CombineHashCodes(key, "y"); int keyZ = RuntimeHelper.CombineHashCodes(key, "z"); this[keyX] = value.x; this[keyY] = value.y; this[keyZ] = value.z; }
public void Prepare(TypeDef type) { var cotype = RuntimeHelper.GetRuntimeType("AsStrongAsFuck.Runtime.FuncMutation"); MethodDef todef = cotype.FindMethod("CharToInt"); todef.Name = Renamer.GetRandomName().Base64Representation(); todef.DeclaringType = null; type.Methods.Add(todef); Converter = todef; }
private static void LoadNativeAssets(RuntimeDependency[] runtimeDependencies) { foreach (var nativeAsset in runtimeDependencies.SelectMany(rtd => rtd.NativeAssets).Distinct()) { if (RuntimeHelper.IsWindows()) { LoadLibrary(nativeAsset); } } }
/// <summary> /// 添加自动扫描注入Service服务和Respository仓储 /// /// <para> /// 需要注意的是,遵循如下约定: /// IUserService --> UserService, IUserRepository --> UserRepository. /// </para> /// </summary> /// <param name="services">服务集合</param> /// <returns>服务集合</returns> public static IServiceCollection AddAutoScanInjection(this IServiceCollection services) { RuntimeHelper.GetAllYuebonAssemblies().ToList().ForEach(a => { a.GetTypes().Where(t => typeof(IPrivateDependency).IsAssignableFrom(t) && t.IsClass).ToList().ForEach(t => { var serviceType = t.GetInterface($"I{t.Name}"); if ((serviceType ?? t).GetInterface(typeof(ISingletonDependency).Name) != null) { if (serviceType != null) { services.AddSingleton(serviceType, t); } else { services.AddSingleton(t); } } else if ((serviceType ?? t).GetInterface(typeof(IScopedDependency).Name) != null) { if (serviceType != null) { services.AddScoped(serviceType, t); } else { services.AddScoped(t); } } else if ((serviceType ?? t).GetInterface(typeof(ITransientDependency).Name) != null) { if (serviceType != null) { services.AddTransient(serviceType, t); } else { services.AddTransient(t); } } else { if (serviceType != null) { services.AddTransient(serviceType, t); } else { services.AddTransient(t); } } }); }); return(services); }