/// <summary> /// Instantiates the <paramref name="targetType"/> with the given <paramref name="activator"/> and <paramref name="constructorArguments"/>. /// </summary> /// <param name="activator">The <see cref="IActivator{T}"/> instance that will be responsible for creating the <paramref name="targetType"/>.</param> /// <param name="targetType">The type to be created.</param> /// <param name="constructorArguments">The arguments that will be passed to the constructor.</param> /// <returns>An object reference that matches the given <paramref name="targetType"/>.</returns> public static object CreateInstance(this IActivator <IActivationContext> activator, Type targetType, object[] constructorArguments) { var context = new ActivationContext(targetType, constructorArguments); return(activator.CreateInstance(context)); }
void Start() { _activator = GetComponent <Activator>(); Register(_activator); IsActive = false; }
public static ConstructionCall CreateConstructionCall(Type type, string activationUrl, object[] activationAttributes) { ConstructionCall constructionCall = new ConstructionCall(type); if (!type.IsContextful) { constructionCall.Activator = new AppDomainLevelActivator(activationUrl, ActivationServices.ConstructionActivator); constructionCall.IsContextOk = false; return(constructionCall); } IActivator activator = ActivationServices.ConstructionActivator; activator = new ContextLevelActivator(activator); ArrayList arrayList = new ArrayList(); if (activationAttributes != null) { arrayList.AddRange(activationAttributes); } bool flag = activationUrl == ChannelServices.CrossContextUrl; Context currentContext = Thread.CurrentContext; if (flag) { foreach (object obj in arrayList) { IContextAttribute contextAttribute = (IContextAttribute)obj; if (!contextAttribute.IsContextOK(currentContext, constructionCall)) { flag = false; break; } } } object[] customAttributes = type.GetCustomAttributes(true); foreach (object obj2 in customAttributes) { if (obj2 is IContextAttribute) { flag = (flag && ((IContextAttribute)obj2).IsContextOK(currentContext, constructionCall)); arrayList.Add(obj2); } } if (!flag) { constructionCall.SetActivationAttributes(arrayList.ToArray()); foreach (object obj3 in arrayList) { IContextAttribute contextAttribute2 = (IContextAttribute)obj3; contextAttribute2.GetPropertiesForNewContext(constructionCall); } } if (activationUrl != ChannelServices.CrossContextUrl) { activator = new AppDomainLevelActivator(activationUrl, activator); } constructionCall.Activator = activator; constructionCall.IsContextOk = flag; return(constructionCall); }
void activateIn() { IActivator activator = getActivatorInRange(); if (activator != null) { if (activator.canBeActivatedByCharacter(character.assignedCharacterTypes)) { if (activator.getPlayerMarker() != null) { transform.position = activator.getPlayerMarker().position; transform.rotation = activator.getPlayerMarker().rotation; } if (activateAnimName != "0") { playAnimationWithoutInterruption(activateAnimName); actionsBlocked = true; } else { activateMid(); } } } }
public void RaiseTest_1() { // Setup and constants String name = "event0"; IEvent ev = new Event(name); Boolean activated1 = false; ActivatorCallback onactivate1 = (self, signal) => { activated1 = true; }; Boolean activated2 = false; ActivatorCallback onactivate2 = (self, signal) => { activated2 = true; }; // Test proper IActivator sub1 = ev.Subscribe(onactivate1); IActivator sub2 = ev.Subscribe(onactivate2); sub1.SelfActivate = true; sub1.Raise(); // Assertions Assert.NotEqual(sub1.Name, sub2.Name); Assert.True(activated1); Assert.True(activated2); }
internal override void InitMethodProperty(string key, object value) { switch (key) { case "__Activator": _activator = (IActivator)value; return; case "__CallSiteActivationAttributes": _activationAttributes = (object[])value; return; case "__ActivationType": _activationType = (Type)value; return; case "__ContextProperties": _contextProperties = (IList)value; return; case "__ActivationTypeName": _activationTypeName = (string)value; return; default: base.InitMethodProperty(key, value); return; } }
public void SubscriptionTest_1() { // Setup and constants String name = "event0"; // no relation to the video game IEvent ev = new Event(name); Boolean activated1 = false; Boolean disposed1 = false; ActivatorCallback onactivate1 = (self, signal) => { activated1 = true; }; Action <IActivator> onunsub1 = (self) => { disposed1 = true; }; // Test proper IActivator sub1 = ev.Subscribe(onactivate1); sub1.SelfActivate = true; sub1.OnUnsubscribe = onunsub1; sub1.Raise(); sub1.Unsubscribe(); // Assertions Assert.True(activated1); Assert.True(disposed1); }
public void BlockTest_1() { // Setup and constants String name = "event0"; IEvent ev = new Event(name); Boolean activated1 = false; ActivatorCallback onactivate1 = (self, signal) => { activated1 = self.Blocking; }; Boolean activated2 = false; ActivatorCallback onactivate2 = (self, signal) => { activated2 = true; }; // Test proper IActivator sub1 = ev.Subscribe(onactivate1); IActivator sub2 = ev.Subscribe(onactivate2); sub1.SelfActivate = false; // sub1 blocking should always make sub1 get the signal. sub1.Block(); sub1.Raise(); // Assertions Assert.NotEqual(sub1.Name, sub2.Name); Assert.True(activated1); Assert.False(activated2); }
public object GetOrCreateInstance( Type concreteType, IActivator activator, IResolvingContext context, string registrationName) { if (!Monitor.TryEnter(_syncRoot, TimeSpan.FromSeconds(5))) { throw new InvalidOperationException("Potentially deadlock"); } try { if (HasInstance(concreteType, registrationName)) { return(GetInstance(concreteType, registrationName)); } else { var instance = activator.Activate(concreteType, _parent, context);; PutInstance(concreteType, instance, registrationName); return(instance); } } finally { Monitor.Exit(_syncRoot); } }
public RyuContainer( RyuContainer parent, IActivator activator ) : this(parent, activator, new ConcurrentDictionary<Type, RyuType>()) { }
// Messages will be intercepted here and redirected // to another object. public override IMessage Invoke(IMessage msg) { if (msg is IConstructionCallMessage) { IActivator remActivator = (IActivator)RemotingServices.Connect(typeof(IActivator), "tcp://localhost:1234/RemoteActivationService.rem"); IConstructionReturnMessage crm = remActivator.Activate((IConstructionCallMessage)msg); return(crm); } else { methodOverloaded = RemotingServices.IsMethodOverloaded((IMethodMessage)msg); _mthBase = RemotingServices.GetMethodBaseFromMethodMessage((IMethodMessage)msg); MethodCallMessageWrapper mcm = new MethodCallMessageWrapper((IMethodCallMessage)msg); mcm.Uri = RemotingServices.GetObjectUri((MarshalByRefObject)target); MarshalByRefObject objRem = (MarshalByRefObject)Activator.CreateInstance(GetProxiedType()); RemotingServices.ExecuteMessage((MarshalByRefObject)objRem, (IMethodCallMessage)msg); IMessage rtnMsg = null; try { rtnMsg = _sink.SyncProcessMessage(msg); } catch (Exception e) { Console.WriteLine(e.Message); } return(rtnMsg); } }
/// ================================================= /// <summary> /// Default layer constructor /// </summary> /// /// <param name="lastNeurons">The neuron count of the previous layer</param> /// <param name="neuronCount">Current layer neuron count</param> /// <param name="activator"></param> public Layer(int lastNeurons, int neuronCount, IActivator activator) { this.weights = new Matrix(neuronCount, lastNeurons); this.bias = new Matrix(neuronCount, 1); this.activator = activator; }
public HttpServiceListener(IActivator activator, IWorker worker, IServiceEndPointDefinition serviceEndPointDefinition, ICertificateLocator certificateLocator, ILog log, IEventPublisher <ServiceCallEvent> eventPublisher, IEnumerable <ICustomEndpoint> customEndpoints, JsonExceptionSerializer exceptionSerializer, ServiceSchema serviceSchema, Func <LoadShedding> loadSheddingConfig, IServerRequestPublisher serverRequestPublisher) { ServiceSchema = serviceSchema; _serverRequestPublisher = serverRequestPublisher; ServiceEndPointDefinition = serviceEndPointDefinition; Worker = worker; Activator = activator; Log = log; EventPublisher = eventPublisher; CustomEndpoints = customEndpoints.ToArray(); ExceptionSerializer = exceptionSerializer; LoadSheddingConfig = loadSheddingConfig; if (serviceEndPointDefinition.UseSecureChannel) { ServerRootCertHash = certificateLocator.GetCertificate("Service").GetHashOfRootCertificate(); } var urlPrefixTemplate = ServiceEndPointDefinition.UseSecureChannel ? "https://+:{0}/" : "http://+:{0}/"; Prefix = string.Format(urlPrefixTemplate, ServiceEndPointDefinition.HttpPort); Listener = new HttpListener { IgnoreWriteExceptions = true, Prefixes = { Prefix } }; }
public RequestExecutor( ISchema schema, IServiceProvider applicationServices, IServiceProvider executorServices, IErrorHandler errorHandler, ITypeConverter converter, IActivator activator, IDiagnosticEvents diagnosticEvents, RequestDelegate requestDelegate) { Schema = schema ?? throw new ArgumentNullException(nameof(schema)); _services = applicationServices ?? throw new ArgumentNullException(nameof(applicationServices)); Services = executorServices ?? throw new ArgumentNullException(nameof(executorServices)); _errorHandler = errorHandler ?? throw new ArgumentNullException(nameof(errorHandler)); _converter = converter ?? throw new ArgumentNullException(nameof(converter)); _activator = activator ?? throw new ArgumentNullException(nameof(activator)); _diagnosticEvents = diagnosticEvents ?? throw new ArgumentNullException(nameof(diagnosticEvents)); _requestDelegate = requestDelegate ?? throw new ArgumentNullException(nameof(requestDelegate)); _batchExecutor = new BatchExecutor(this, errorHandler, converter); }
public override void GetPropertiesForNewContext(IConstructionCallMessage ctorMsg) { if (!ctorMsg.Properties.Contains((object)"Remote")) { return; } AppDomainLevelActivator domainLevelActivator = new AppDomainLevelActivator((string)ctorMsg.Properties[(object)"Remote"]); IActivator activator = ctorMsg.Activator; if (activator.Level < ActivatorLevel.AppDomain) { domainLevelActivator.NextActivator = activator; ctorMsg.Activator = (IActivator)domainLevelActivator; } else if (activator.NextActivator == null) { activator.NextActivator = (IActivator)domainLevelActivator; } else { while (activator.NextActivator.Level >= ActivatorLevel.AppDomain) { activator = activator.NextActivator; } domainLevelActivator.NextActivator = activator.NextActivator; activator.NextActivator = (IActivator)domainLevelActivator; } }
public IConstructionReturnMessage Activate(IConstructionCallMessage ctorCall) { IActivator activator = (IActivator)RemotingServices.Connect(typeof(IActivator), this._activationUrl); ctorCall.Activator = ctorCall.Activator.NextActivator; IConstructionReturnMessage constructionReturnMessage; try { constructionReturnMessage = activator.Activate(ctorCall); } catch (Exception e) { return(new ConstructionResponse(e, ctorCall)); } ObjRef objRef = (ObjRef)constructionReturnMessage.ReturnValue; if (RemotingServices.GetIdentityForUri(objRef.URI) != null) { throw new RemotingException("Inconsistent state during activation; there may be two proxies for the same object"); } object obj; Identity orCreateClientIdentity = RemotingServices.GetOrCreateClientIdentity(objRef, null, out obj); RemotingServices.SetMessageTargetIdentity(ctorCall, orCreateClientIdentity); return(constructionReturnMessage); }
public void EnsureLifecycle(IActivator activator) { if (Lifecycle == null) { Lifecycle = (ILifecycle)activator.Create(LifecycleType, activator); } }
internal override bool FillSpecialHeader(string key, object value) { if (key != null) { if (key.Equals("__ActivationType")) { this._activationType = (Type)null; } else if (key.Equals("__ContextProperties")) { this._contextProperties = (IList)value; } else if (key.Equals("__CallSiteActivationAttributes")) { this._callSiteActivationAttributes = (object[])value; } else if (key.Equals("__Activator")) { this._activator = (IActivator)value; } else { if (!key.Equals("__ActivationTypeName")) { return(base.FillSpecialHeader(key, value)); } this._activationTypeName = (string)value; } } return(true); }
/// <summary> /// Sets the current activator. /// </summary> /// <param name="activator">Activator to use. </param> /// <returns>Returns previously used value. </returns> public static IActivator SetCurrent(IActivator activator) { var old = Current; Current = activator; return(old); }
/// <summary> /// Creates an <see cref="XmlKeyManager"/>. /// </summary> /// <param name="keyManagementOptions">The <see cref="IOptions{KeyManagementOptions}"/> instance that provides the configuration.</param> /// <param name="activator">The <see cref="IActivator"/>.</param> /// <param name="loggerFactory">The <see cref="ILoggerFactory"/>.</param> public XmlKeyManager(IOptions <KeyManagementOptions> keyManagementOptions, IActivator activator, ILoggerFactory loggerFactory) { _loggerFactory = loggerFactory ?? throw new ArgumentNullException(nameof(loggerFactory)); _logger = _loggerFactory.CreateLogger <XmlKeyManager>(); KeyRepository = keyManagementOptions.Value.XmlRepository; KeyEncryptor = keyManagementOptions.Value.XmlEncryptor; if (KeyRepository == null) { if (KeyEncryptor != null) { throw new InvalidOperationException( Resources.FormatXmlKeyManager_IXmlRepositoryNotFound(nameof(IXmlRepository), nameof(IXmlEncryptor))); } else { var keyRepositoryEncryptorPair = GetFallbackKeyRepositoryEncryptorPair(); KeyRepository = keyRepositoryEncryptorPair.Key; KeyEncryptor = keyRepositoryEncryptorPair.Value; } } _authenticatedEncryptorConfiguration = keyManagementOptions.Value.AuthenticatedEncryptorConfiguration; var escrowSinks = keyManagementOptions.Value.KeyEscrowSinks; _keyEscrowSink = escrowSinks.Count > 0 ? new AggregateKeyEscrowSink(escrowSinks) : null; _activator = activator; TriggerAndResetCacheExpirationToken(suppressLogging: true); _internalKeyManager = _internalKeyManager ?? this; _encryptorFactories = keyManagementOptions.Value.AuthenticatedEncryptorFactories; }
public HealthEndpoint(IServiceEndPointDefinition serviceEndPointDefinition, IServiceInterfaceMapper serviceInterfaceMapper, IActivator activator, IServiceDrainListener drainListener) { _drainListener = drainListener; ServiceEndPointDefinition = serviceEndPointDefinition; ServiceInterfaceMapper = serviceInterfaceMapper; Activator = activator; }
/// <summary> /// Creates an <see cref="XmlKeyManager"/>. /// </summary> /// <param name="repository">The repository where keys are stored.</param> /// <param name="configuration">Configuration for newly-created keys.</param> /// <param name="services">A provider of optional services.</param> public XmlKeyManager( IXmlRepository repository, IAuthenticatedEncryptorConfiguration configuration, IServiceProvider services) { if (repository == null) { throw new ArgumentNullException(nameof(repository)); } if (configuration == null) { throw new ArgumentNullException(nameof(configuration)); } KeyEncryptor = services.GetService <IXmlEncryptor>(); // optional KeyRepository = repository; _activator = services.GetActivator(); // returns non-null _authenticatedEncryptorConfiguration = configuration; _internalKeyManager = services.GetService <IInternalXmlKeyManager>() ?? this; _keyEscrowSink = services.GetKeyEscrowSink(); // not required _logger = services.GetLogger <XmlKeyManager>(); // not required TriggerAndResetCacheExpirationToken(suppressLogging: true); }
// single layer network public static NeuralNetwork<Vector> Create(IDataSet<Vector, Vector> dataSet, IActivator activator) { var workLayer = new FullyConnectedLayer(dataSet.FirstInput.Size, dataSet.FirstOutput.Size, activator); var outputLayer = new OutputLayer<Vector>(); var layers = new CompositeLayer<Vector, Vector, Vector>(workLayer, outputLayer); return new NeuralNetwork<Vector>(layers); }
public EngineConfiguration( IActivator activator, IRazorTemplateCompiler razorTemplateCompiler, ICompilerService compilerService) { if (activator == null) { throw new ArgumentNullException(nameof(activator)); } if (razorTemplateCompiler == null) { throw new ArgumentNullException(nameof(razorTemplateCompiler)); } if (compilerService == null) { throw new ArgumentNullException(nameof(compilerService)); } this.Activator = activator; this.RazorTemplateCompiler = razorTemplateCompiler; this.CompilerService = compilerService; this.Namespaces = new HashSet <string>(); this.PreRenderCallbacks = new PreRenderActionList(); }
private async Task Activate(IActivator activator) { Hide(); await activator.Activate(); Close(); }
/// <summary> /// Sets the activator. /// </summary> /// <param name="activator">The activator instance.</param> /// <returns>The current configuration builder.</returns> public IConfigurationBuilder ActivateUsing(IActivator activator) { Contract.Requires(activator != null); _config.Activator = activator; return(this); }
private static IXmlDecryptor CreateDecryptor(IActivator activator, string decryptorTypeName) { var resolvedTypeName = TypeForwardingActivator.TryForwardTypeName(decryptorTypeName, out var forwardedTypeName) ? forwardedTypeName : decryptorTypeName; var type = Type.GetType(resolvedTypeName, throwOnError: false); if (type == typeof(DpapiNGXmlDecryptor)) { return(activator.CreateInstance <DpapiNGXmlDecryptor>(decryptorTypeName)); } else if (type == typeof(DpapiXmlDecryptor)) { return(activator.CreateInstance <DpapiXmlDecryptor>(decryptorTypeName)); } else if (type == typeof(EncryptedXmlDecryptor)) { return(activator.CreateInstance <EncryptedXmlDecryptor>(decryptorTypeName)); } else if (type == typeof(NullXmlDecryptor)) { return(activator.CreateInstance <NullXmlDecryptor>(decryptorTypeName)); } return(activator.CreateInstance <IXmlDecryptor>(decryptorTypeName)); }
public override void GetPropertiesForNewContext(IConstructionCallMessage ctorMsg) { if (ctorMsg.Properties.Contains("Remote")) { string remActivatorURL = (string)ctorMsg.Properties["Remote"]; AppDomainLevelActivator appDomainLevelActivator = new AppDomainLevelActivator(remActivatorURL); IActivator activator = ctorMsg.Activator; if (activator.Level < ActivatorLevel.AppDomain) { appDomainLevelActivator.NextActivator = activator; ctorMsg.Activator = appDomainLevelActivator; return; } if (activator.NextActivator == null) { activator.NextActivator = appDomainLevelActivator; return; } while (activator.NextActivator.Level >= ActivatorLevel.AppDomain) { activator = activator.NextActivator; } appDomainLevelActivator.NextActivator = activator.NextActivator; activator.NextActivator = appDomainLevelActivator; } }
private void Load(XDocument xDoc) { foreach (var adapterElement in xDoc.Elements("Adapter")) { IAdapter adapter = null; string adapterType = GetAttribute(adapterElement, "Type"); string adapterName = GetAttribute(adapterElement, "Name"); _currentAdapterName = adapterName; Dictionary <string, object> adapterObjects = new Dictionary <string, object>(); _adapterObjects.Add(adapterName, adapterObjects); adapter = GetAdapter(adapterElement); _adapters.Add(adapter.Name, adapter); foreach (var activatorElement in adapterElement.Elements("Activator")) { IActivator activator = GetActivator(activatorElement, adapter.GetChannel()); adapter.AddActivator(activator); } if (adapterElement.Element("EventConnecter") != null) { foreach (var eventConnecterElement in adapterElement.Elements("EventConnecter")) { GetEventConnecter(eventConnecterElement); } } } }
public MigrationRunner(IMigrationProvider migrationProvider, IMigrationLog migrationLog, IMigrationSynchronizationContext synchronizationContext, IActivator <IMigration> activator) { this.migrationProvider = migrationProvider; this.migrationLog = migrationLog; this.activator = activator; this.synchronizationContext = synchronizationContext; }
public Bootstrapper(IAssemblyLoader assemblyLoader, IModuleLoader moduleLoader, IActivator activator, IModuleImporter moduleImporter) { this.assemblyLoader = assemblyLoader; this.moduleLoader = moduleLoader; this.activator = activator; this.moduleImporter = moduleImporter; }
/// <summary> /// Sets the activator used to create types. /// </summary> /// <param name="activator">The activator to use.</param> private void SetActivatorInternal(IActivator activator) { lock (syncObject2) { this.activator = activator; } }
internal XmlKeyManager(IServiceProvider services) { // First, see if an explicit encryptor or repository was specified. // If either was specified, then we won't use the fallback. KeyEncryptor = services.GetService <IXmlEncryptor>(); // optional KeyRepository = (KeyEncryptor != null) ? services.GetRequiredService <IXmlRepository>() // required if encryptor is specified : services.GetService <IXmlRepository>(); // optional if encryptor not specified // If the repository is missing, then we get both the encryptor and the repository from the fallback. // If the fallback is missing, the final call to GetRequiredService below will throw. if (KeyRepository == null) { var defaultKeyServices = services.GetService <IDefaultKeyServices>(); KeyEncryptor = defaultKeyServices?.GetKeyEncryptor(); // optional KeyRepository = defaultKeyServices?.GetKeyRepository() ?? services.GetRequiredService <IXmlRepository>(); } _activator = services.GetActivator(); // returns non-null _authenticatedEncryptorConfiguration = services.GetRequiredService <IAuthenticatedEncryptorConfiguration>(); _internalKeyManager = services.GetService <IInternalXmlKeyManager>() ?? this; _keyEscrowSink = services.GetKeyEscrowSink(); // not required _logger = services.GetLogger <XmlKeyManager>(); // not required TriggerAndResetCacheExpirationToken(suppressLogging: true); }
/// <summary> /// Creates an <see cref="XmlKeyManager"/>. /// </summary> /// <param name="repository">The repository where keys are stored.</param> /// <param name="configuration">Configuration for newly-created keys.</param> /// <param name="services">A provider of optional services.</param> public XmlKeyManager( IXmlRepository repository, IAuthenticatedEncryptorConfiguration configuration, IServiceProvider services) { if (repository == null) { throw new ArgumentNullException(nameof(repository)); } if (configuration == null) { throw new ArgumentNullException(nameof(configuration)); } KeyEncryptor = services.GetService<IXmlEncryptor>(); // optional KeyRepository = repository; _activator = services.GetActivator(); // returns non-null _authenticatedEncryptorConfiguration = configuration; _internalKeyManager = services.GetService<IInternalXmlKeyManager>() ?? this; _keyEscrowSink = services.GetKeyEscrowSink(); // not required _logger = services.GetLogger<XmlKeyManager>(); // not required TriggerAndResetCacheExpirationToken(suppressLogging: true); }
public DynamicProxyActivator(IMachineContainer container, IProxyBuilder proxyBuilder, IActivator target, ServiceEntry entry) { _container = container; _entry = entry; _proxyBuilder = proxyBuilder; _target = target; _proxyGenerator = new ProxyGenerator(_proxyBuilder); }
internal AppDomainLevelActivator(SerializationInfo info, StreamingContext context) { if (info == null) { throw new ArgumentNullException("info"); } this.m_NextActivator = (IActivator) info.GetValue("m_NextActivator", typeof(IActivator)); }
public virtual void Bind(IActivator activator) { if (_activator != null && activator != null && _activator != activator) { throw new InvalidOperationException(); } _activator = activator; }
public virtual IDbCommand CreateCommand() { if (commandActivator == null) { commandActivator = ActivatorFactory.CreateActivator(CommandType); } return (IDbCommand)commandActivator.CreateInstance(); }
public virtual IDbConnection CreateConnection() { if (connectionActivator == null) { connectionActivator = ActivatorFactory.CreateActivator(ConnectionType); } return (IDbConnection)connectionActivator.CreateInstance(); }
public BottleService(IActivator activator, IPackageLog log) { _activator = activator; _log = log; if(!IsBottleService(activator)) { throw new ArgumentException("Activator must also implement {0}".ToFormat(typeof(IDeactivator).Name), "activator"); } }
/// <inheritdoc/> public virtual void Init(IActivator activator, IKernel kernel, IComponentInfo info, Action<IComponentInfo, object> onDestroying, Action<IComponentContext> onFetch) { Guard.NotNull(activator, "activator"); Guard.NotNull(kernel, "kernel"); Guard.NotNull(info, "info"); this.Activator = activator; this.Kernel = kernel; this.Info = info; OnDestroying = onDestroying; OnFetch = onFetch; }
/// <summary> /// Initializes a new instance of the <see cref="SubstituteTypeExpressionVisitor"/> class. /// </summary> /// <param name="activator">The activator.</param> public SubstituteTypeExpressionVisitor(IActivator activator) : this( activator, new ISubstituteTypeConstantHandler[] { new ListSubstituteTypeConstantHandler(), new EnumerableQuerySubstituteTypeConstantHandler(), new DataContextQueryableSubstituteTypeConstantHandler(), }) { }
public virtual void Bind(IActivator activator) { if (this._activator == activator) { return; } if (activator != null && this._activator != null) { throw new InvalidOperationException(); } this._activator = activator; }
public void AddActivator(ServiceEntry entry, IActivator activator) { using (RWLock.AsWriter(_lock)) { if (_cache.ContainsKey(entry)) { throw new ServiceContainerException("Multiple activators for one entry!"); } _log.Info("Adding: " + entry + " " + activator); _cache[entry] = activator; } }
public void Bind(IActivator activator) { if (_activator == activator) { return; } if (activator != null && null != _activator) { throw new System.InvalidOperationException(); } _activator = activator; }
public virtual void Bind(IActivator activator) { if (_activator == activator) { return; } if (_activator != null && activator != null) { throw new Exception(); } _activator = activator; }
public void Bind(IActivator activator) { if (this.activator == activator) { return; } if (activator != null && null != this.activator) { throw new InvalidOperationException("Object can only be bound to one activator"); } this.activator = activator; }
public static XElement DecryptElement(this XElement element, IActivator activator) { // If no decryption necessary, return original element. if (!DoesElementOrDescendentRequireDecryption(element)) { return element; } // Deep copy the element (since we're going to mutate) and put // it into a document to guarantee it has a parent. var doc = new XDocument(new XElement(element)); // We remove elements from the document as we decrypt them and perform // fix-up later. This keeps us from going into an infinite loop in // the case of a null decryptor (which returns its original input which // is still marked as 'requires decryption'). var placeholderReplacements = new Dictionary<XElement, XElement>(); while (true) { var elementWhichRequiresDecryption = doc.Descendants(XmlConstants.EncryptedSecretElementName).FirstOrDefault(); if (elementWhichRequiresDecryption == null) { // All encryption is finished. break; } // Decrypt the clone so that the decryptor doesn't inadvertently modify // the original document or other data structures. The element we pass to // the decryptor should be the child of the 'encryptedSecret' element. var clonedElementWhichRequiresDecryption = new XElement(elementWhichRequiresDecryption); var innerDoc = new XDocument(clonedElementWhichRequiresDecryption); string decryptorTypeName = (string)clonedElementWhichRequiresDecryption.Attribute(XmlConstants.DecryptorTypeAttributeName); var decryptorInstance = activator.CreateInstance<IXmlDecryptor>(decryptorTypeName); var decryptedElement = decryptorInstance.Decrypt(clonedElementWhichRequiresDecryption.Elements().Single()); // Put a placeholder into the original document so that we can continue our // search for elements which need to be decrypted. var newPlaceholder = new XElement("placeholder"); placeholderReplacements[newPlaceholder] = decryptedElement; elementWhichRequiresDecryption.ReplaceWith(newPlaceholder); } // Finally, perform fixup. Debug.Assert(placeholderReplacements.Count > 0); foreach (var entry in placeholderReplacements) { entry.Key.ReplaceWith(entry.Value); } return doc.Root; }
public void Bind(IActivator activator) { if (activator == _activator) { return; } if (activator != null && _activator != null) { throw new InvalidOperationException(); } _activator = activator; }
public OracleDPDriver() { string connectionClassName = "Oracle.DataAccess.Client.OracleConnection, Oracle.DataAccess"; string commandClassName = "Oracle.DataAccess.Client.OracleCommand, Oracle.DataAccess"; string parameterClassName = "Oracle.DataAccess.Client.OracleParameter, Oracle.DataAccess"; string dbtypeClassName = "Oracle.DataAccess.Client.OracleDbType, Oracle.DataAccess"; // try to get the Types from an already loaded assembly connectionType = Utils.GetType(connectionClassName); commandType = Utils.GetType(commandClassName); parameterType = Utils.GetType(parameterClassName); dbtypeType = Utils.GetType(dbtypeClassName); commandTypeActivator = ActivatorFactory.CreateActivator(commandType); if( connectionType == null || commandType == null ) throw new SqlMapperException("The IDbCommand and IDbConnection implementation in Oracle.DataAccess.Client could not be found. "); }
public static NeuralNetwork<Vector> Create(IDataSet<Vector, Vector> dataSet, IActivator activator, List<int> hiddenSizes) { if (hiddenSizes.Count == 0) return Create(dataSet, activator); var inputSize = dataSet.FirstInput.Size; var outputSize = dataSet.FirstOutput.Size; var sizes = new List<int>{inputSize}; sizes.AddRange(hiddenSizes); sizes.Add(outputSize); var layerCount = sizes.Count - 1; var layers = new ISingleLayer<Vector, Vector>[layerCount]; for (var i = 0; i < layerCount; ++i) layers[i] = new FullyConnectedLayer(sizes[i], sizes[i + 1], activator); var compositeLayer = LayerCompositor.ComposeGeteroneneous(layers); return new NeuralNetwork<Vector>(compositeLayer); }
internal override bool FillSpecialHeader(string key, object value) { if (key != null) { if (!key.Equals("__ActivationType")) { if (!key.Equals("__ContextProperties")) { if (!key.Equals("__CallSiteActivationAttributes")) { if (!key.Equals("__Activator")) { if (!key.Equals("__ActivationTypeName")) { return base.FillSpecialHeader(key, value); } this._activationTypeName = (string) value; } else { this._activator = (IActivator) value; } } else { this._callSiteActivationAttributes = (object[]) value; } } else { this._contextProperties = (IList) value; } } else { this._activationType = null; } } return true; }
public void Bind(IActivator activator) { }
public void Activator(IActivator activator) { addConfigurableAction(g => g.AddActivator(activator)); }
public void AddActivator(IActivator activator) { _activators.Add(activator); _diagnostics.LogObject(activator, currentProvenance); }
public ResolvedServiceEntry(ServiceEntry entry, IActivator activator, IObjectInstances objectInstances) { _entry = entry; _objectInstances = objectInstances; _activator = activator; }
private static IReadOnlyCollection<IKey> RunGetAllKeysCore(string xml, IActivator activator, ILoggerFactory loggerFactory = null) { // Arrange - mocks var mockXmlRepository = new Mock<IXmlRepository>(); mockXmlRepository.Setup(o => o.GetAllElements()).Returns(XElement.Parse(xml).Elements().ToArray()); // Arrange - services var serviceCollection = new ServiceCollection(); serviceCollection.AddSingleton<IXmlRepository>(mockXmlRepository.Object); serviceCollection.AddSingleton<IActivator>(activator); serviceCollection.AddSingleton<IAuthenticatedEncryptorConfiguration>(new Mock<IAuthenticatedEncryptorConfiguration>().Object); if (loggerFactory != null) { serviceCollection.AddSingleton<ILoggerFactory>(loggerFactory); } var services = serviceCollection.BuildServiceProvider(); var keyManager = new XmlKeyManager(services); // Act return keyManager.GetAllKeys(); }
public virtual void Initialize() { _defaultActivator = _activatorFactory.CreateDefaultActivator(_entry); }
public virtual void Bind(IActivator activator) { _activator = activator; }
public static BottleService For(IActivator service) { return new BottleService(service, new PackageLog()); }