static void BuildSound() { ObjectResolver ob = new ObjectResolver("sound/", "Sound"); ob.Resolve(".mp3"); ob.Resolve(".wav"); EditorUtility.DisplayDialog("AssetBunlde", "Finish", "Close"); }
public void Setup() { _kernel = ObjectResolver.Create(); _kernel.Register <IA, A>(Lifestyle.Singleton); _kernel.Register <IB, B>(Lifestyle.Singleton); _kernel.Register <IC, C>(Lifestyle.Singleton); _kernel.Compile(); _kernel.Resolve(typeof(IA)); _kernel.Resolve(typeof(IB)); _kernel.Resolve(typeof(IC)); }
public void Setup() { _kernel = ObjectResolver.Create(); _kernel.Register <IA, A>(Lifestyle.Transient); _kernel.Register <IB, B>(Lifestyle.Transient); _kernel.Register <IC, C>(Lifestyle.Transient); _kernel.Compile(); _kernel.Resolve <IA>(); _kernel.Resolve <IB>(); _kernel.Resolve <IC>(); }
#pragma warning disable HAA0101 // rare call, don't care about params allocation private IComponentCollectionStorage ResolveStorage(Type componentType) { var storageType = typeof(IComponentCollection <>).MakeGenericType(componentType); var result = _resolver.Resolve(storageType); return((IComponentCollectionStorage)result); }
/// <summary> /// Initializes a new instance of the WebSec.Library.Engine.Context class. /// </summary> public Context() { this.CurrentCookies = new ConcurrentDictionary <string, CookieCollection>(); this.Vulnerabilities = new ConcurrentDictionary <string, Vulnerability>(); this.Payloads = ObjectResolver.Resolve <IPayloads>(); this.ActiveDetectors = new List <Type>(); }
/// <summary> /// Initializes a new instance of the <see cref="BrowserAbstract" /> class. /// </summary> /// <exception cref="InvalidOperationException"> /// Thrown when the requested operation is invalid. /// </exception> /// <param name="browser"> /// The Selenium driver to wrap. /// </param> /// <param name="windowTitleFormat"> /// The expected format for the browser window title. /// </param> protected BrowserAbstract(IWebDriver browser, string windowTitleFormat) { Require.NotNullOrEmpty(() => windowTitleFormat); this.browser = browser; this.alertMessageDisplayed = new HashSet <string>(); this.actionState = new ActionState(s => { // dialog is blocking page load, remember the message and unblock. string text; DismissIfAlertDisplayedImpl(out text); }); var script = browser as IJavaScriptExecutor; if (script == null) { throw new InvalidOperationException("Browser does not support script execution"); } string unique = Guid.NewGuid().ToString(); script.ExecuteScript($"document.title ='{unique}'"); var processManager = ObjectResolver.Resolve <IProcessManager>(); this.Process = processManager.GetProcessByWindowTitle(string.Format(windowTitleFormat, unique)); if (this.Process == null) { throw new InvalidOperationException("Browser process could not be found"); } }
static void BuildObjects() { ObjectResolver ob = new ObjectResolver("objs/", "Objects"); ob.Resolve(); EditorUtility.DisplayDialog("AssetBunlde", "Finish", "Close"); }
public DataSet Search(ref SearchContext searchContext) { DataSet dataSet = new DataSet(); try { /* Session Logic must be inserted here. (Need new table creation)*/ if (searchContext.MethodInformation != null) { Object[] data = null; Type type = ObjectResolver.Resolve(searchContext.MethodInformation.ObjectName, false); // using (IDataTransaction dataTransaction = Activator.CreateInstance(type) as IDataTransaction) { MethodInfo method = this.FindMethod(type, searchContext.MethodInformation.MethodName); // data = this.FindParameters(searchContext, method); // dataSet = method.Invoke(dataTransaction, data) as DataSet; } } else { using (IDataTransaction dataTransaction = Activator.CreateInstance(ObjectResolver.Resolve(searchContext)) as IDataTransaction) dataSet = dataTransaction.Search(ref searchContext); } } catch (Exception exception) { searchContext.ErrorMessage = Errors.Extract(exception); } // return(dataSet); }
static void ResolveEffects() { ObjectResolver ob = new ObjectResolver("effect/", "Effect"); ob.Resolve(); EditorUtility.DisplayDialog("AssetBunlde", "Finish", "Close"); }
public string Invoke(ref SearchContext searchContext) { string result = string.Empty; try { /* Session Logic must be inserted here. (Need new table creation)*/ if (searchContext.MethodInformation != null) { Object[] data = null; Object resultData = null; Type type = ObjectResolver.Resolve(searchContext.MethodInformation.ObjectName, false); // using (IDataTransaction dataTransaction = Activator.CreateInstance(type) as IDataTransaction) { MethodInfo method = this.FindMethod(type, searchContext.MethodInformation.MethodName); // data = this.FindParameters(searchContext, method); // resultData = method.Invoke(dataTransaction, data); result = Json.Serialize(resultData); } } else { throw new ArgumentException("Missing Method Information."); } } catch (Exception exception) { Errors.Extract(exception); } // return(result); }
/// <summary> /// Cleanup fiddler and browser instances. /// </summary> internal static void Cleanup() { FiddlerProxy.Cleanup(Constants.FiddlerPort); ((BrowserManager)ObjectResolver.Resolve <IBrowserManager>()).Dispose(); TestSetupHelpers.CleanupProcess(Constants.ChromeDriver); }
/// <summary> /// The release browser. /// </summary> /// <param name="browser"> /// The browser. /// </param> public static void ReleaseBrowser(BrowserAbstract browser) { if (browser != null) { var browserManager = ObjectResolver.Resolve <IBrowserManager>(); browserManager.ReleaseBrowser(browser); } }
public void TestRegisterInstance() { var testClass = new TestClass("default"); ObjectResolver.RegisterInstance(testClass); ObjectResolver.Resolve <TestClass>().Name.ShouldEqual("default"); }
public void Import() { var filePaths = Directory.GetFiles(_path, "*.csv"); foreach (var filePath in filePaths) { var fileName = Path.GetFileName(filePath); var className = fileName.Remove(fileName.Length - 4); using (var reader = new CsvFileReader(filePath)) { var row = new CsvRow(); var repository = (DaoBase)_objectResolver.Resolve("DAL.Repository", className + "Dao"); while (reader.ReadRow(row)) { var dtoInstance = (DtoBase)_objectResolver.Resolve("DAL.DTO", className + "Dto"); dtoInstance.FillInstance(row.ToArray()); repository.Save(dtoInstance); } } } }
public void TestRegisterMultipleInstances() { var testClassInstance1 = new TestClass("instance1"); var testClassInstance2 = new TestClass("instance2"); ObjectResolver.RegisterInstance(testClassInstance1, testClassInstance1.Name); ObjectResolver.RegisterInstance(testClassInstance2, testClassInstance2.Name); var instance1 = ObjectResolver.Resolve <TestClass>("instance1"); instance1.Name.ShouldEqual("instance1"); instance1.ShouldEqual(testClassInstance1); var instance2 = ObjectResolver.Resolve <TestClass>("instance2"); instance2.Name.ShouldEqual("instance2"); instance2.ShouldEqual(testClassInstance2); }
/// <summary> /// The dom xss test_integration_test. /// </summary> /// <param name="browserType"> /// The browser type. /// </param> private void DomXssTestIntegrationTest(BrowserType browserType) { ObjectResolver.RegisterType <IProcessManager, ProcessManager>(); var browserInstances = new Dictionary <BrowserType, int> { { browserType, 2 } }; ObjectResolver.RegisterInstance <IBrowserManager>(new BrowserManager(browserInstances)); var target = Target.Create($"{Constants.VulnerabilitiesAddress}vuln_domxss.html?a=1"); var context = new Context(); var instance = new TestableDomXssTest(); instance.Init(context, target); // introduce our known injection strings instance.InjectTestCaseStrings(new[] { "alert(" + TestBaseHelper.AttackSignature + ")", "%22+onload=%22javascript:alert(" + TestBaseHelper.AttackSignature + ")%22" }); instance.DoTests(); // cleanly shutdown the browser manager var disposable = ObjectResolver.Resolve <IBrowserManager>() as IDisposable; Assert.IsNotNull(disposable); disposable.Dispose(); // a vuln should be found instance.Vulnerabilities.ShouldNotBeNull(); instance.Vulnerabilities.Count.ShouldEqual(1); // the vuln record should be well formed var vuln = instance.Vulnerabilities.First(); vuln.Level.ShouldEqual(0); vuln.TestedParam.ShouldEqual("a"); vuln.TestedVal.ShouldEqual("alert(" + TestBaseHelper.AttackSignature + ")"); vuln.Evidence.ShouldEqual("Found by " + browserType); vuln.TestPlugin.ShouldStartWith("TestableDomXssTest"); vuln.Title.ShouldEqual("DOM XSS - Script injection"); instance.Vulnerabilities.Count(v => v.TestPlugin == "TestableDomXssTest") .ShouldEqual(1); }
/// <inheritdoc /> public BrowserAbstract AcquireBrowser(BrowserType browserType) { var browserManager = ObjectResolver.Resolve <IBrowserManager>(); // there is no browser pool created if (browserManager.AvailableBrowserTypes.All(t => t != browserType)) { throw new ArgumentException( $"There is no browser pool created for type {browserType}.", browserType.ToString()); } // try to acquire a browser BrowserAbstract browser = browserManager.AcquireBrowser(browserType); if (browser == null) { throw new ArgumentException( "Browser type {0} not available.".FormatIc(browserType.ToString()), browserType.ToString()); } return(browser); }
public object GetInstance(InstanceContext instanceContext, Message message) { return(ObjectResolver.Resolve(_serviceType)); }
/// <summary> /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged /// resources. /// </summary> public static void Dispose() { ((BrowserManager)ObjectResolver.Resolve <IBrowserManager>()).Dispose(); }
/// <summary> /// Browser navigate to page. /// </summary> /// <param name="contextSendRequestParameter"> /// The context send request parameter. /// </param> /// <param name="uri"> /// The uri. /// </param> /// <param name="webRequestContext"> /// The web request context. /// </param> private void BrowserNavigateToPage( ContextSendRequestParameter contextSendRequestParameter, Uri uri, WebRequestContext webRequestContext) { webRequestContext.ResponseHolder = new HttpWebResponseHolder(); BrowserAbstract browser = null; try { var browserManager = ObjectResolver.Resolve <IBrowserManager>(); // there is no browser pool created for this browser type if (browserManager.AvailableBrowserTypes.All(t => t != contextSendRequestParameter.BrowserType)) { return; } // try to acquire a browser if we don't have one already browser = webRequestContext.Browser ?? browserManager.AcquireBrowser(contextSendRequestParameter.BrowserType); if (browser == null) { Library.Logger.Logger.WriteWarning( "Browser pool failed allocation (measured by BrowserPoolCounters.FailedAllocationsPerMinute)."); return; } // in case we acquired then set this in the request context webRequestContext.Browser = browser; // Add request cookies. if (this.CurrentCookies.ContainsKey(uri.Host)) { foreach (Cookie cookie in this.CurrentCookies[uri.Host]) { browser.AddCookie(cookie.Name, cookie.Value, cookie.Domain, cookie.Path, cookie.Expires); } } var stopWatch = new Stopwatch(); stopWatch.Start(); browser.NavigateTo(uri.OriginalString); stopWatch.Stop(); // FireFox does not block on the presence of an alert dialog, so we manually check here. string alertText; browser.DismissedIfAlertDisplayed(out alertText); browser.WaitForPageLoad(Constants.BrowserWaitForPageLoadInMilliseconds); // check for messages again following page load - do this before querying other browser properties browser.DismissedIfAlertDisplayed(out alertText); var fiddlerResponseSessionKey = Library.Constants.FiddlerResponseSessionKey.FormatIc( browser.ProcessId, browser.Url); // get fiddler response var fiddlerResponse = FiddlerProxy.ResponseSession.ContainsKey(fiddlerResponseSessionKey) ? FiddlerProxy.ResponseSession[fiddlerResponseSessionKey].oResponse : null; var fiddlerRequest = FiddlerProxy.ResponseSession.ContainsKey(fiddlerResponseSessionKey) ? FiddlerProxy.ResponseSession[fiddlerResponseSessionKey].oRequest : null; // populate response holder webRequestContext.ResponseHolder.StatusCode = fiddlerResponse != null ? (HttpStatusCode)fiddlerResponse.headers.HTTPResponseCode : HttpStatusCode.OK; var source = browser.PageSource; webRequestContext.ResponseHolder.ResponseContent = source; webRequestContext.ResponseHolder.RequestAbsolutUri = uri.AbsoluteUri; webRequestContext.ResponseHolder.RequestHost = uri.Host; Uri resultUri; if (Uri.TryCreate(browser.Url, UriKind.Absolute, out resultUri)) { webRequestContext.ResponseHolder.ResponseUri = resultUri; } webRequestContext.ResponseHolder.ResponseDateTime = DateTime.UtcNow; webRequestContext.ResponseHolder.RequestUserAgent = contextSendRequestParameter.BrowserType.ToString(); webRequestContext.ResponseHolder.BrowserPageTitle = browser.PageTitle; webRequestContext.ResponseHolder.ResponseContentType = "text/html"; webRequestContext.ResponseHolder.Latency = new TimeSpan(0, 0, 0, 0, (int)stopWatch.Elapsed.TotalMilliseconds); // set headers from fiddler for this request if (fiddlerRequest != null) { webRequestContext.ResponseHolder.RequestHeaders = Regex.Replace(fiddlerRequest.headers.ToString().Trim(), @"[\u0000-\u001F]", string.Empty); } // set headers from fiddler for this response if (fiddlerResponse != null) { webRequestContext.ResponseHolder.SetResponseFiddlerHeaders(fiddlerResponse.headers); } // set back response cookies webRequestContext.ResponseHolder.Cookies = browser.AllCookies; } catch (Exception exception) { webRequestContext.ResponseHolder.HttpError = exception.Message; CheckForUnexpectedDialog(uri, browser, exception); } }
public static void ResolveNonGeneric(ObjectResolver container) { var resolvedInstance0 = container.Resolve(typeof(IInterface0)); var resolvedInstance1 = container.Resolve(typeof(IInterface1)); var resolvedInstance2 = container.Resolve(typeof(IInterface2)); var resolvedInstance3 = container.Resolve(typeof(IInterface3)); var resolvedInstance4 = container.Resolve(typeof(IInterface4)); var resolvedInstance5 = container.Resolve(typeof(IInterface5)); var resolvedInstance6 = container.Resolve(typeof(IInterface6)); var resolvedInstance7 = container.Resolve(typeof(IInterface7)); var resolvedInstance8 = container.Resolve(typeof(IInterface8)); var resolvedInstance9 = container.Resolve(typeof(IInterface9)); var resolvedInstance10 = container.Resolve(typeof(IInterface10)); var resolvedInstance11 = container.Resolve(typeof(IInterface11)); var resolvedInstance12 = container.Resolve(typeof(IInterface12)); var resolvedInstance13 = container.Resolve(typeof(IInterface13)); var resolvedInstance14 = container.Resolve(typeof(IInterface14)); var resolvedInstance15 = container.Resolve(typeof(IInterface15)); var resolvedInstance16 = container.Resolve(typeof(IInterface16)); var resolvedInstance17 = container.Resolve(typeof(IInterface17)); var resolvedInstance18 = container.Resolve(typeof(IInterface18)); var resolvedInstance19 = container.Resolve(typeof(IInterface19)); var resolvedInstance20 = container.Resolve(typeof(IInterface20)); var resolvedInstance21 = container.Resolve(typeof(IInterface21)); var resolvedInstance22 = container.Resolve(typeof(IInterface22)); var resolvedInstance23 = container.Resolve(typeof(IInterface23)); var resolvedInstance24 = container.Resolve(typeof(IInterface24)); var resolvedInstance25 = container.Resolve(typeof(IInterface25)); var resolvedInstance26 = container.Resolve(typeof(IInterface26)); var resolvedInstance27 = container.Resolve(typeof(IInterface27)); var resolvedInstance28 = container.Resolve(typeof(IInterface28)); var resolvedInstance29 = container.Resolve(typeof(IInterface29)); var resolvedInstance30 = container.Resolve(typeof(IInterface30)); var resolvedInstance31 = container.Resolve(typeof(IInterface31)); var resolvedInstance32 = container.Resolve(typeof(IInterface32)); var resolvedInstance33 = container.Resolve(typeof(IInterface33)); var resolvedInstance34 = container.Resolve(typeof(IInterface34)); var resolvedInstance35 = container.Resolve(typeof(IInterface35)); var resolvedInstance36 = container.Resolve(typeof(IInterface36)); var resolvedInstance37 = container.Resolve(typeof(IInterface37)); var resolvedInstance38 = container.Resolve(typeof(IInterface38)); var resolvedInstance39 = container.Resolve(typeof(IInterface39)); var resolvedInstance40 = container.Resolve(typeof(IInterface40)); var resolvedInstance41 = container.Resolve(typeof(IInterface41)); var resolvedInstance42 = container.Resolve(typeof(IInterface42)); var resolvedInstance43 = container.Resolve(typeof(IInterface43)); var resolvedInstance44 = container.Resolve(typeof(IInterface44)); var resolvedInstance45 = container.Resolve(typeof(IInterface45)); var resolvedInstance46 = container.Resolve(typeof(IInterface46)); var resolvedInstance47 = container.Resolve(typeof(IInterface47)); var resolvedInstance48 = container.Resolve(typeof(IInterface48)); var resolvedInstance49 = container.Resolve(typeof(IInterface49)); ; }
public static void ResolveGeneric(ObjectResolver container) { var resolvedInstance0 = container.Resolve <IInterface0>(); var resolvedInstance1 = container.Resolve <IInterface1>(); var resolvedInstance2 = container.Resolve <IInterface2>(); var resolvedInstance3 = container.Resolve <IInterface3>(); var resolvedInstance4 = container.Resolve <IInterface4>(); var resolvedInstance5 = container.Resolve <IInterface5>(); var resolvedInstance6 = container.Resolve <IInterface6>(); var resolvedInstance7 = container.Resolve <IInterface7>(); var resolvedInstance8 = container.Resolve <IInterface8>(); var resolvedInstance9 = container.Resolve <IInterface9>(); var resolvedInstance10 = container.Resolve <IInterface10>(); var resolvedInstance11 = container.Resolve <IInterface11>(); var resolvedInstance12 = container.Resolve <IInterface12>(); var resolvedInstance13 = container.Resolve <IInterface13>(); var resolvedInstance14 = container.Resolve <IInterface14>(); var resolvedInstance15 = container.Resolve <IInterface15>(); var resolvedInstance16 = container.Resolve <IInterface16>(); var resolvedInstance17 = container.Resolve <IInterface17>(); var resolvedInstance18 = container.Resolve <IInterface18>(); var resolvedInstance19 = container.Resolve <IInterface19>(); var resolvedInstance20 = container.Resolve <IInterface20>(); var resolvedInstance21 = container.Resolve <IInterface21>(); var resolvedInstance22 = container.Resolve <IInterface22>(); var resolvedInstance23 = container.Resolve <IInterface23>(); var resolvedInstance24 = container.Resolve <IInterface24>(); var resolvedInstance25 = container.Resolve <IInterface25>(); var resolvedInstance26 = container.Resolve <IInterface26>(); var resolvedInstance27 = container.Resolve <IInterface27>(); var resolvedInstance28 = container.Resolve <IInterface28>(); var resolvedInstance29 = container.Resolve <IInterface29>(); var resolvedInstance30 = container.Resolve <IInterface30>(); var resolvedInstance31 = container.Resolve <IInterface31>(); var resolvedInstance32 = container.Resolve <IInterface32>(); var resolvedInstance33 = container.Resolve <IInterface33>(); var resolvedInstance34 = container.Resolve <IInterface34>(); var resolvedInstance35 = container.Resolve <IInterface35>(); var resolvedInstance36 = container.Resolve <IInterface36>(); var resolvedInstance37 = container.Resolve <IInterface37>(); var resolvedInstance38 = container.Resolve <IInterface38>(); var resolvedInstance39 = container.Resolve <IInterface39>(); var resolvedInstance40 = container.Resolve <IInterface40>(); var resolvedInstance41 = container.Resolve <IInterface41>(); var resolvedInstance42 = container.Resolve <IInterface42>(); var resolvedInstance43 = container.Resolve <IInterface43>(); var resolvedInstance44 = container.Resolve <IInterface44>(); var resolvedInstance45 = container.Resolve <IInterface45>(); var resolvedInstance46 = container.Resolve <IInterface46>(); var resolvedInstance47 = container.Resolve <IInterface47>(); var resolvedInstance48 = container.Resolve <IInterface48>(); var resolvedInstance49 = container.Resolve <IInterface49>(); ; }