internal LocalApplication( IComponentDirectory parentDirectory, ApplicationDesc application, Guid instanceGuid, ulong instanceNumber) { this.instanceGuid = instanceGuid; this.instanceNumber = instanceNumber; string iname = application.Name + " " + instanceGuid.ToString(); this.applicationDescriptor = application; localDirectory = new ComponentDirectory(parentDirectory, iname); localDirectory.Register( new Instance( localDirectory.GetInstance <DatabaseManager>().Find("/"), "WorkingDirectory")); localDirectory.Register(new Instance(this, "Process")); foreach (IComponentProvider provider in application.Components) { localDirectory.Register(provider); } }
public void Register(IComponentProvider provider, ExportScope scope, ProcessExitBehaviour onExit) { if (scope == ExportScope.Process) { /** register locally **/ Register(provider); } else if (scope == ExportScope.Parent) { parent.Register(provider); } else if (scope == ExportScope.Machine) { if (machineDirectory != null) { machineDirectory.Register(provider); } else { throw new NotSupportedException("Component directory does not support machine scope registration"); } } throw new NotSupportedException("Component directory does not support cluster scope registration"); }
public void Apply(IComponentDirectory toolDirectory) { string dum1, dum2; MatchThrow(path, out dum1, out dum2); Node <object> node = manager.Find(path); TypedStream <object> obj = node.Open(Type.GetType(typeName), attribute.OpenMode); toolDirectory.Register(new Instance(obj, name)); }
public void RegisterServiceComponent(IComponentProvider provider) { if (provider.MatchAgainstNameAllowed) { /* FIXME: We will need to do proper per-process cleanup in the future */ foreach (IComponentProvider prov in componentDirectory.FindByName(provider.MatchedName)) { componentDirectory.UnRegister(prov); } } componentDirectory.Register(provider); }
/// <summary> /// Performs auto-parametrization on arbitary object. /// </summary> /// <param name="arguments">The arguments that will be matched with properties.</param> /// <param name="directory">The component directory, to resolve links. May be null.</param> public static string[] PerformAutoParametrization(Type targetType, IComponentDirectory directory, string[] arguments) { List <string> unprocessed = new List <string>(); // We go for each. foreach (string argument in arguments) { // We check for '='. if (!argument.Contains("=")) { unprocessed.Add(argument); continue; } // We split to two parts on this index. int index = argument.IndexOf('='); string first = argument.Substring(0, index).Trim(); string last = argument.Substring(index + 1).Trim(); // We try to find target's type property with that name to find the correct mask. Type maskType = typeof(string); // We extract correct type. // FIXME: also consider aliases or "case invariant" matching! PropertyInfo info = targetType.GetProperty(first); if (info != null && info.CanWrite) { maskType = info.PropertyType; } IComponentProvider provider = ExtractValue(maskType, first, last, directory); if (provider != null) { directory.Register(provider); } else { unprocessed.Add(argument); } } return(unprocessed.ToArray());; }
public void Apply(IComponentDirectory toolDirectory) { // We apply as enum. toolDirectory.Register(new Instance(value, name)); }