static void CastleDynamicProxyObjectFactoryInitialize() { ObjectFactory.Initialize(x => { x.Scan(scan => { scan.TheCallingAssembly(); scan.WithDefaultConventions(); }); x.ForConcreteType<AuthorizedInterceptor>().Configure.Ctor<string>("role").Is("Manager").Named("ManagerAuth"); var proxyHelper = new ProxyHelper(); x.For<IBudgetService>() .EnrichAllWith(proxyHelper.Proxify<IBudgetService, CachedInterceptor>) .EnrichAllWith(o => proxyHelper.Proxify<IBudgetService, AuthorizedInterceptor>("ManagerAuth", o)); }); }
public static async Task EnsurePropertyLoadedAsync <TEntity, TPrimaryKey, TProperty>( this IRepository <TEntity, TPrimaryKey> repository, TEntity entity, Expression <Func <TEntity, TProperty> > propertyExpression, CancellationToken cancellationToken = default(CancellationToken) ) where TEntity : class, IEntity <TPrimaryKey> where TProperty : class { var repo = ProxyHelper.UnProxy(repository) as ISupportsExplicitLoading <TEntity, TPrimaryKey>; if (repo != null) { await repo.EnsurePropertyLoadedAsync(entity, propertyExpression, cancellationToken); } }
private void MainForm_FormClosing(object sender, FormClosingEventArgs e) { try { if (ClosingControl == "ToolStripMenuItem") { CloseAllTab(); var fi = new FileInfo(Config.DockSettingFileName); if (fi.Directory != null && !fi.Directory.Exists) { fi.Directory.Create(); } if (!_hasDockSettingExceptioin) { MainDockPanel.SaveAsXml(Config.DockSettingFileName); } if (!_hasViewSettingException) { SaveViewSetting(); } var ph = new ProxyHelper(); ph.SetIEProxy("", 0); try { XmlHelper.XmlSerialize(Config.LastProxyFileName, ProxyData.ProxyList, typeof(List <ProxyServer>)); //设置最后的列表 } catch { } notifyIconMain.Dispose(); Process.GetCurrentProcess().Kill(); } else { WindowState = FormWindowState.Minimized; e.Cancel = true; } } catch (Exception ex) { MsgBox.ShowExceptionMessage(ex); } }
protected void Page_Load(object sender, EventArgs e) { if (!this.Page.IsPostBack) { this.agentId = ProxyHelper.GetUserAgentId(this.UserId); object obj = Request.QueryString["incidentId"]; if (obj != null) { UcControlArgs args = new UcControlArgs(); Int32 i = 0; if (Int32.TryParse(obj.ToString(), out i)) { this.incidentId = i; string msg = ""; bool success = openIncident(this.incidentId, this.agentId, out msg); ucIncidentProfile.IncidentId = this.incidentId; //=================================== ucIncidentProfile.ReadOnly = false; pnlIncident.Visible = false; pnlIncidentProfile.Visible = true; pnlError.Visible = false; } else { this.incidentId = 0; pnlIncident.Visible = false; pnlIncidentProfile.Visible = false; pnlError.Visible = true; } //incidentId = Convert.ToInt32(obj); } else { pnlIncident.Visible = true; pnlIncidentProfile.Visible = false; pnlError.Visible = false; filterIncidents(); } } }
public MainPage() { ProxyHelper.ApplyProxySettings(); this.InitializeComponent(); silentMediaPlayer = new MediaPlayer { Source = MediaSource.CreateFromUri(new Uri("ms-appx:///Assets/Media/silent.wav")), IsLoopingEnabled = true, }; silentMediaPlayer.CommandManager.IsEnabled = false; WebViewHelper.Init(this.mainWebView); loadFailedAppVersionText.Text = PackageHelper.GetAppVersionString(); VisualStateManager.GoToState(this, "SplashScreen", false); }
private void UpdateAudioEvents(string confId, int incident) { string script = null; string samplesPerSec = ProxyHelper.GetSettingValueString("AudioSamplesPerSec", "KIOSK"); string speexQuality = ProxyHelper.GetSettingValueString("SpeexQuality", "KIOSK"); string audioOutputDeviceID = ProxyHelper.GetSettingValueString("AudioOutputDeviceID", "KIOSK"); string audioDeviceID = ProxyHelper.GetSettingValueString("VideoDeviceID", "KIOSK"); string fileName = AudioUploadHelper.GetFileName(incident, AudioUploadHelper.SOURCE_FACILITY); script = "StartAudioPublisher(6, " + confId + ", 1, 1, '" + audioDeviceID + "', '" + samplesPerSec + "', '" + speexQuality + "', '" + fileName + "', '');"; ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "StartAudioPublisher", script, true); script = "StartAudioSubscriber(6, " + confId + ", 1, 2, 1, '" + audioOutputDeviceID + "');"; ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "StartAudioSubscriber", script, true); }
/// <summary> /// 启用调试 /// </summary> /// <param name="proxyType"></param> /// <returns></returns> public static bool SetupDebug(ProxyType proxyType) { Type loadType = ProxyHelper.GetType(proxyType); if (loadType == null) { throw new ProxyServiceException(string.Format("proxyType {0},{1} is not exist", proxyType.FullName, proxyType.AssemblyName)); } AddConfig(proxyType); string debugID = GetDebugID(loadType.FullName); var instance = HarmonyInstance.Create(debugID); if (instance.HasAnyPatches(debugID)) { return(true); } var doMethods = GetDoMethods(loadType); if (doMethods.Count == 0) { throw new ProxyServiceException(string.Format("proxyType {0},{1} no find Do method", proxyType.FullName, proxyType.AssemblyName)); } Type debugClass = typeof(ProxyDebug); MethodInfo realPrefix = debugClass.GetMethod("BeforeDo"); HarmonyMethod prefixHarmonyMethod = new HarmonyMethod(realPrefix); HarmonyMethod postfixHarmonyMethod = null; Type returnType = AccessTools.GetReturnedType(doMethods[0]); if (returnType != typeof(void)) { MethodInfo realPostfix = debugClass.GetMethod("AfterDo"); if (realPostfix != null) { //获取泛型方法 MethodInfo realPostfixGenericMethod = realPostfix.MakeGenericMethod(returnType); postfixHarmonyMethod = new HarmonyMethod(realPostfixGenericMethod); } } PatchProcessor patcher = new PatchProcessor(instance, doMethods, prefixHarmonyMethod, postfixHarmonyMethod, null); patcher.Patch(); return(true); }
protected void Page_Load(object sender, EventArgs e) { UCTXHelper.AddUCTXObjectsToHeader(this); Uri uri = new Uri(ProxyHelper.GetSettingValueString("AudioUploadTargetPageUrl", "PLATFORM")); string script = string.Format ("var url_upload = {{ host: '{0}', port: {1}, path: '{2}' }};" , uri.Host , uri.Port , uri.PathAndQuery ); ScriptManager.RegisterClientScriptBlock(this, GetType(), "url_upload", script, true); ScriptManager.RegisterClientScriptInclude(this, GetType(), "common", this.ResolveClientUrl("~/dirJavascript/common.js")); ScriptManager.RegisterClientScriptInclude(this, GetType(), "upload", this.ResolveClientUrl("~/dirJavascript/async_upload.js")); }
static void Main(string[] args) { ObjectFactory.Initialize(x => { x.Scan(scan => { scan.TheCallingAssembly(); scan.WithDefaultConventions(); }); var proxyHelper = new ProxyHelper(); x.For <IMyService>().Use <MyService>().EnrichWith(proxyHelper.Proxify <IMyService, MyLoggingAspect>); }); var myObj = ObjectFactory.GetInstance <IMyService>(); myObj.DoSomething(); }
public void RemoveInterceptorAtRuntime_Test() { Person per = new ProxyGenerator().CreateClassProxy <Person>(new FreezableInterceptor()); per.FirstName = "Foo"; per.LastName = "Bar"; Assert.IsTrue(Freezable.RegisterFreezable(per)); Assert.IsTrue(Freezable.IsFreezable(per)); Assert.AreEqual(1, ProxyHelper.GetInterceptorsField(per).Count()); ProxyHelper.ExcudeInterceptors(per, typeof(FreezableInterceptor)); Assert.AreEqual(0, ProxyHelper.GetInterceptorsField(per).Count()); }
public QASearchResult ValidateAddress(QASearch search) { _log.Info("InvokeQasService.ValidateAddress() starting ..."); QAPortTypeClient client = null; QASearchResult result = null; try { client = new QAPortTypeClient(); _log.Info("InvokeQasService.ValidateAddress() client created ..."); int retryCount = 0; result = client.DoSearch(search); if (result == null && retryCount == 0) { // retry once result = client.DoSearch(search); retryCount++; } _log.Info("InvokeQasService.ValidateAddress() result was returned from service ..."); } catch (TimeoutException timeout) { _log.Error("InvokeQasService.ValidateAddress() Timeout Exception:" + timeout.Message); ProxyHelper.HandleServiceException(client); } catch (CommunicationException comm) { _log.Error("InvokeQasService.ValidateAddress() Communication Exception:" + comm.Message); ProxyHelper.HandleServiceException(client); } catch (Exception e) { _log.Error("InvokeQasService.ValidateAddress() Exception:" + e.Message); } finally { if (client != null && client.State != CommunicationState.Closed) { ProxyHelper.CloseChannel(client); } } _log.Info("InvokeQasService.ValidateAddress() ending ..."); return(result); }
public static void AddValidationErrors( [NotNull] IHasExtraProperties extensibleObject, [NotNull] List <ValidationResult> validationErrors, [NotNull] string propertyName, [CanBeNull] object value, [CanBeNull] ValidationContext objectValidationContext = null) { Check.NotNull(extensibleObject, nameof(extensibleObject)); Check.NotNull(validationErrors, nameof(validationErrors)); Check.NotNullOrWhiteSpace(propertyName, nameof(propertyName)); if (objectValidationContext == null) { objectValidationContext = new ValidationContext( extensibleObject, null, new Dictionary <object, object>() ); } var objectType = ProxyHelper.UnProxy(extensibleObject).GetType(); var objectExtensionInfo = ObjectExtensionManager.Instance .GetOrNull(objectType); if (objectExtensionInfo == null) { return; } var property = objectExtensionInfo.GetPropertyOrNull(propertyName); if (property == null) { return; } AddPropertyValidationErrors( extensibleObject, validationErrors, objectValidationContext, property, value ); }
/// <summary> /// Emits a proxy to a method that just calls the base method. /// </summary> /// <param name="invocationContext">The current invocation context.</param> /// <param name="methodBuilder">The method to implement.</param> /// <param name="baseMethod">The base method.</param> /// <param name="parameterMapping">The mapping of the parameters.</param> private void EmitDirectProxy(InvocationContext invocationContext, MethodBuilder methodBuilder, MethodInfo baseMethod, List <ParameterMapping> parameterMapping, List <Tuple <FieldInfo, object> > valuesToSet) { /* * This method assumes that a default return value has been pushed on the stack. * * base(params); * return (top of stack); */ ILGenerator mIL = methodBuilder.GetILGenerator(); // copy the parameters to the stack // arg.0 = this // so we go to length+1 mIL.Emit(OpCodes.Ldarg_0); for (int i = 0; i < parameterMapping.Count; i++) { var parameter = parameterMapping[i]; if (parameter.HasSource) { ProxyHelper.EmitSerializeValue( _typeBuilder, methodBuilder, invocationContext, _invocationContexts, _invocationContextsField, parameter, _serializationProvider, _serializationProviderField, valuesToSet); } else { // if this method supports context, then add a context parameter // note that we pass null in here and then build the context from within EmitCallWriteEvent mIL.Emit(OpCodes.Ldnull); } } // now that all of the parameters have been loaded, call the base method mIL.Emit(OpCodes.Call, baseMethod); mIL.Emit(OpCodes.Ret); }
protected virtual void TriggerEventWithEntity( IEventBus eventPublisher, Type genericEventType, object entityOrEto, object originalEntity) { var entityType = ProxyHelper.UnProxy(entityOrEto).GetType(); var eventType = genericEventType.MakeGenericType(entityType); var eventData = Activator.CreateInstance(eventType, entityOrEto); var currentUow = UnitOfWorkManager.Current; if (currentUow == null) { Logger.LogWarning("UnitOfWorkManager.Current is null! Can not publish the event."); return; } var eventRecord = new UnitOfWorkEventRecord(eventType, eventData, EventOrderGenerator.GetNext()) { Properties = { { UnitOfWorkEventRecordEntityPropName, originalEntity }, } }; /* We are trying to eliminate same events for the same entity. * In this way, for example, we don't trigger update event for an entity multiple times * even if it is updated multiple times in the current UOW. */ if (eventPublisher == DistributedEventBus) { currentUow.AddOrReplaceDistributedEvent( eventRecord, otherRecord => IsSameEntityEventRecord(eventRecord, otherRecord) ); } else { currentUow.AddOrReplaceLocalEvent( eventRecord, otherRecord => IsSameEntityEventRecord(eventRecord, otherRecord) ); } }
public void AddCountInterceptorAtRuntime_Test() { Person per = new ProxyGenerator().CreateClassProxy <Person>(); per.FirstName = "Foo"; per.LastName = "Bar"; var counter = new CounterInterceptor(); ProxyHelper.AddInterceptor(per, counter); Assert.AreEqual(1, ProxyHelper.GetInterceptorsField(per).Count()); Assert.AreEqual(per.FirstName, "Foo"); Assert.AreEqual(per.LastName, "Bar"); Assert.AreEqual(2, counter.CallsCount); }
public static async Task HardDeleteAsync <TEntity, TPrimaryKey>(this IRepository <TEntity, TPrimaryKey> repository, TEntity entity) where TEntity : class, IEntity <TPrimaryKey>, ISoftDelete { IRepository <TEntity, TPrimaryKey> repo = ProxyHelper.UnProxy(repository) as IRepository <TEntity, TPrimaryKey>; if (repo == null) { throw new ArgumentException($"Given {nameof(repository)} is not inherited from {typeof(IRepository<TEntity, TPrimaryKey>).AssemblyQualifiedName}"); } var items = ((IUnitOfWorkManagerAccessor)repo).UnitOfWorkManager.Current.Items; var hardDeleteEntities = items.GetOrAdd(UnitOfWorkExtensionDataTypes.HardDelete, () => new HashSet <string>()) as HashSet <string>; var hardDeleteKey = EntityHelper.GetHardDeleteKey(entity); hardDeleteEntities.Add(hardDeleteKey); await repo.DeleteAsync(entity); }
public void AddInterceptorAtRuntime_Test() { Person per = new ProxyGenerator().CreateClassProxy <Person>(); per.FirstName = "Foo"; per.LastName = "Bar"; // by the current implementation the object have to be registered before it can be recognized as a freezable! Assert.IsFalse(Freezable.IsFreezable(per)); Assert.IsFalse(Freezable.RegisterFreezable(per)); ProxyHelper.AddInterceptor <FreezableInterceptor>(per); Assert.IsTrue(Freezable.RegisterFreezable(per)); Assert.IsTrue(Freezable.IsFreezable(per)); }
protected virtual bool EqualsItems(Type leftRealType, Object leftId, T right, ITypeInfoItem idMember) { if (right == null) { return(false); } Type rightRealType = ProxyHelper.GetRealType(right.GetType()); if (!leftRealType.Equals(rightRealType)) { return(false); } Object rightId = idMember.GetValue(right); leftId = ConversionHelper.ConvertValueToType(idMember.RealType, leftId); return(Object.Equals(leftId, rightId)); }
private EntityChange CreateEntityChange(EntityEntry entityEntry) { var entityId = GetEntityId(entityEntry); var entityTypeFullName = ProxyHelper.GetUnproxiedType(entityEntry.Entity).FullName; EntityChangeType changeType; switch (entityEntry.State) { case EntityState.Added: changeType = EntityChangeType.Created; break; case EntityState.Deleted: changeType = EntityChangeType.Deleted; break; case EntityState.Modified: changeType = entityEntry.IsDeleted() ? EntityChangeType.Deleted : EntityChangeType.Updated; break; case EntityState.Detached: case EntityState.Unchanged: return(null); default: Logger.ErrorFormat("Unexpected {0} - {1}", nameof(entityEntry.State), entityEntry.State); return(null); } if (entityId == null && changeType != EntityChangeType.Created) { Logger.ErrorFormat("EntityChangeType {0} must have non-empty entity id", changeType); return(null); } return(new EntityChange { ChangeType = changeType, EntityEntry = entityEntry, // [NotMapped] EntityId = entityId, EntityTypeFullName = entityTypeFullName, TenantId = AbpSession.TenantId }); }
private void Execute(ShellShellExecutor executor) { ApplicationSettings config = ApplicationSettings.LoadSettings(); var environmentSets = ""; bool debug = executor.GetSwitch(SwitchesNames.Debug); bool useSysProxy = executor.GetSwitch(SwitchesNames.UseSysProxy); foreach (KeyValuePair <string, string> envVar in config.EnvironmentVariables) { if (debug) { Console.WriteLine($"set {envVar.Key}={envVar.Value}"); } environmentSets += $"set {envVar.Key}={envVar.Value}&"; } if (useSysProxy || (config.Settings.ContainsKey("usesystemproxy") && string.Equals(config.Settings["usesystemproxy"], "true", StringComparison.CurrentCultureIgnoreCase))) { string proxy = ProxyHelper.GetSystemProxy(); if (!string.IsNullOrEmpty(proxy)) { environmentSets += $"set HTTP_PROXY={proxy}&"; } string httpsProxy = ProxyHelper.GetSystemHttpsProxy(); if (!string.IsNullOrEmpty(proxy)) { environmentSets += $"set HTTPS_PROXY={httpsProxy}&"; } } var processInfo = new ProcessStartInfo { UseShellExecute = false, FileName = "cmd.exe", Arguments = @"/c " + environmentSets + executor.GetParameterAsString(ParameterNames.Program) }; Console.WriteLine("Executing " + executor.GetParameterAsString(ParameterNames.Program)); using (Process process = Process.Start(processInfo)) { process?.WaitForExit(); } }
public HttpStatusCode UpdateProxies() { var serviceProviders = _proxyProviderService.GetProxyProviders(); var testServers = _proxyTestServerService.GetTestProxies(); Parallel.ForEach(serviceProviders, provider => { try { IList <Proxy> proxyList = ProxyHelper.StartCrawler(provider); provider.LastFetchOn = DateTime.Now; provider.LastFetchProxyCount = proxyList.Count; provider.Exception = ""; if (proxyList.Count > 0) { _proxyService.BatchCreateOrUpdate(proxyList); IList <ProxyTest> proxyTestResults = ProxyHelper.TestProxies(proxyList.ToList(), testServers); if (proxyTestResults.Count > 0) { _proxyTestService.BatchCreateOrUpdate(proxyTestResults); } } } catch (Exception ex) { provider.LastFetchProxyCount = -1; provider.Exception = ex.InnerException?.Message; } _proxyProviderService.Update(provider); }); try { _proxyProviderService.SaveChanges(); return(HttpStatusCode.OK); } catch { return(HttpStatusCode.InternalServerError); } }
public ResultCodeModel SaveAppTool(AppToolCanonicalType AppTool) { _log.Info("InvokeAppToolService.SaveAppTool() starting ..."); AppToolClient client = null; Dictionary <string, string> paramList = null; ResponseMessageList messageList = new ResponseMessageList(); //try/catch here, and handle results/errors appropriately... ResultCodeModel result = new ResultCodeModel(); try { client = new AppToolClient(); result.ResultCode = client.SaveAppTool(paramList, ref AppTool, out messageList); } catch (TimeoutException timeout) { ErrorModel error = new ErrorModel("There was a timeout problem calling the AppTool Management Service", "InvokeAppToolMangementService"); result.ErrorList.Add(error); ProxyHelper.HandleServiceException(client); _log.Error("InvokeAppToolService.SaveAppTool() Timeout Exception:" + timeout.Message); } catch (CommunicationException comm) { ErrorModel error = new ErrorModel("There was a communication problem calling the AppTool Management Service", "InvokeAppToolMangementService"); result.ErrorList.Add(error); ProxyHelper.HandleServiceException(client); _log.Error("InvokeAppToolService.SaveAppTool() Communication Exception:" + comm.Message); } catch (Exception e) { _log.Error("InvokeAppToolService.SaveAppTool() Exception:" + e.Message); } finally { if (client != null && client.State != CommunicationState.Closed) { ProxyHelper.CloseChannel(client); } } _log.Info("InvokeAppToolService.SaveAppTool() ending ..."); return(result); }
private void UpdateFieldsValue() { if (_fields != null) { var schemeItem = SchemeItemAttribute.GetValueFromObject(this); if (_fields._schemeItemSource != null && schemeItem != null && (schemeItem.IdItemType != _fields._schemeItemSource.IdItemType || schemeItem.IdItem != _fields._schemeItemSource.IdItem)) { _fields = null; _fieldsNamed = null; } } var moduleLink = ModuleItemsCustomize._moduleLink; if (_fields == null && moduleLink != null) { moduleLink.RegisterToQuery(this); moduleLink.CheckDeffered(GetType()); if (_fields == null) { _fields = moduleLink.GetItemFields(this); if (_fields == null) { _fieldsNamed = null; } } } if (_fields == null) { _fields = ProxyHelper.CreateTypeObjectFromParent <DefaultSchemeWData, IField>(new DefaultScheme()); if (_fields == null) { _fieldsNamed = null; } } if (_fields != null && _fieldsNamed == null) { _fieldsNamed = new ReadOnlyDictionary <string, FieldData>(_fields.Where(x => !string.IsNullOrEmpty(x.Value.alias)).ToDictionary(x => x.Value.alias, x => x.Value)); } }
public async Task <GetQnAKnowledgeBaseResult> GetQnAKnowledgeBase() { QnAHelper qnaHelper = new QnAHelper { ProxyObj = ProxyHelper.GetProxyForQnA(), QnAHost = WebApiConstants.QnAHost, QnAKey = WebApiConstants.QnAKey, QnAService = WebApiConstants.QnAService, QnAKnowledgeBaseId = WebApiConstants.QnAKnowledgeBaseId }; logger.Info("Start get QnAs from QnA Maker"); var lstQuestionResponseString = await qnaHelper.GetAllQnAFromKB(WebApiConstants.QnAKnowledgeBaseId); logger.Info("Finish get QnAs from QnA Maker"); return(await Task.FromResult <GetQnAKnowledgeBaseResult>(lstQuestionResponseString)); }
public async Task <bool> PublishQnAKnowledgeBase() { QnAHelper qnaHelper = new QnAHelper { ProxyObj = ProxyHelper.GetProxyForQnA(), QnAHost = WebApiConstants.QnAHost, QnAKey = WebApiConstants.QnAKey, QnAService = WebApiConstants.QnAService, QnAKnowledgeBaseId = WebApiConstants.QnAKnowledgeBaseId }; logger.Info("Start Publish QnA Knowledge Base"); var result = await qnaHelper.PublishQnAKnowledgeBase(WebApiConstants.QnAKnowledgeBaseId); logger.Info("Finish Publish QnA Knowledge Base"); return(await Task.FromResult(result)); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddSwaggerGen(c => { c.SingleApiVersion(new Info { Version = "v1", Title = "API V1", TermsOfService = "None" }); c.DescribeAllEnumsAsStrings(); }); services.AddScoped(typeof(IGuidelineApi), x => ProxyHelper.CreateProxy <IGuidelineApi>(x)); // Add framework services. services.AddMvc(); }
private static IActiveUnitOfWork GetCurrentUnitOfWorkOrThrowException <TEntity, TPrimaryKey>(IRepository <TEntity, TPrimaryKey> repository) where TEntity : class, IEntity <TPrimaryKey>, ISoftDelete { var repo = ProxyHelper.UnProxy(repository) as IRepository <TEntity, TPrimaryKey>; if (repo == null) { throw new ArgumentException($"Given {nameof(repository)} is not inherited from {typeof(IRepository<TEntity, TPrimaryKey>).AssemblyQualifiedName}"); } var currentUnitOfWork = ((IUnitOfWorkManagerAccessor)repo).UnitOfWorkManager.Current; if (currentUnitOfWork == null) { throw new AbpException($"There is no unit of work in the current context, The hard delete function can only be used in a unit of work."); } return(currentUnitOfWork); }
static void Main(string[] args) { ObjectFactory.Initialize(x => { x.Scan(scan => { scan.TheCallingAssembly(); scan.WithDefaultConventions(); }); var proxyHelper = new ProxyHelper(); x.For<IMyClass>().EnrichAllWith(r => proxyHelper.Proxify<IMyClass, Aspect1>( proxyHelper.Proxify<IMyClass, Aspect2>(r)) ); }); var obj = ObjectFactory.GetInstance<IMyClass>(); obj.MyMethod(); }
public static IEnumerable <LocalizedString> GetAllStrings( this IStringLocalizer stringLocalizer, bool includeParentCultures, bool includeBaseLocalizers) { var internalLocalizer = (ProxyHelper.UnProxy(stringLocalizer) as IStringLocalizer).GetInternalLocalizer(); if (internalLocalizer is IStringLocalizerSupportsInheritance stringLocalizerSupportsInheritance) { return(stringLocalizerSupportsInheritance.GetAllStrings( includeParentCultures, includeBaseLocalizers )); } return(stringLocalizer.GetAllStrings( includeParentCultures )); }
private static IUnitOfWorkManager GetUnitOfWorkManager<TEntity>( this IBasicRepository<TEntity> repository, [CallerMemberName] string callingMethodName = nameof(GetUnitOfWorkManager) ) where TEntity : class, IEntity { if (ProxyHelper.UnProxy(repository) is not IUnitOfWorkManagerAccessor unitOfWorkManagerAccessor) { throw new AbpException($"The given repository (of type {repository.GetType().AssemblyQualifiedName}) should implement the " + $"{typeof(IUnitOfWorkManagerAccessor).AssemblyQualifiedName} interface in order to invoke the {callingMethodName} method!"); } if (unitOfWorkManagerAccessor.UnitOfWorkManager == null) { throw new AbpException($"{nameof(unitOfWorkManagerAccessor.UnitOfWorkManager)} property of the given {nameof(repository)} object is null!"); } return unitOfWorkManagerAccessor.UnitOfWorkManager; }
static void Main(string[] args) { ObjectFactory.Initialize(x => { var proxyHelper = new ProxyHelper(); x.For<ProxyHelper>().Singleton().Use(proxyHelper); x.Scan(scan => { scan.TheCallingAssembly(); scan.WithDefaultConventions(); scan.Convention<RepositoryAspectConvention>(); }); }); var obj = ObjectFactory.GetInstance<IMyClassRepository>(); obj.MyMethod(); var anotherObj = ObjectFactory.GetInstance<IAnotherRepository>(); anotherObj.AnotherMethod(); }
public static void SetCommonSettings(Page page) { if (!page.ClientScript.IsClientScriptBlockRegistered("setConferenceSetting")) { string server = ProxyHelper.GetSettingValueString("Server", "CTX_SERVER"); string[] ss = server.Split(':'); string script = string.Format ("setConferenceSetting('{0}', '{1}', '{2}', '{3}', '{4}', '{5}', '{6}');" , ss[0] , ss[1] , ss[2] , ss[3] , ProxyHelper.GetSettingValueString("TimerSpan", "CTX_SERVER") , ProxyHelper.GetSettingValueString("DifFrameCount", "CTX_SERVER") , ProxyHelper.GetSettingValueString("ServerApiKey", "CTX_SERVER") ); ScriptManager.RegisterClientScriptBlock(page, page.GetType(), "setConferenceSetting", script, true); } }
private void UpdateVideoEvents(string confId) { string script = null; string theoraBitrate = ProxyHelper.GetSettingValueString("TheoraBitrate", "KIOSK"); string theoraQuality = ProxyHelper.GetSettingValueString("TheoraQuality", "KIOSK"); string theoraKeyframe = ProxyHelper.GetSettingValueString("TheoraKeyframe", "KIOSK"); string videoWidth = ProxyHelper.GetSettingValueString("VideoWidth", "KIOSK"); string videoHeight = ProxyHelper.GetSettingValueString("VideoHeight", "KIOSK"); string timePerFrame = ProxyHelper.GetSettingValueString("VideoTimePerFrame", "KIOSK"); string videoDeviceID = ProxyHelper.GetSettingValueString("VideoDeviceID", "KIOSK"); string viewMethod = ProxyHelper.GetSettingValueString("VideoViewMethod", "KIOSK"); script = "StartVideoPublisher(4, " + confId + ", 1, 1, 'wye_uic_video_publisher'," + theoraBitrate + "," + theoraQuality + "," + theoraKeyframe + "," + videoWidth + "," + videoHeight + "," + timePerFrame + "," + videoDeviceID + ", '')"; ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "StartVideoPublisher", script, true); script = "StartVideoSubscriber(4, " + confId + ", 1, 2, 1, 'wye_uic_video_subscriber'," + viewMethod + " ,'')"; ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "StartVideoSubscriber", script, true); }