Ejemplo n.º 1
0
 public object BuildItem(PluginItemMetadata itemData, PluginRuntime plugin)
 {
     BuilderHelper.CheckParameter("Type", itemData);
     BuilderHelper.CheckParameter("Directory", itemData);
     return(new PluginResource(
                (PluginResourceType)Enum.Parse(typeof(PluginResourceType), itemData.Attributes["Type"]),
                plugin.Metadata.GetAbsolutePath(itemData.Attributes["Directory"])));
 }
Ejemplo n.º 2
0
        public object BuildItem(PluginItemMetadata itemData, PluginRuntime plugin)
        {
            BuilderHelper.CheckParameter("ServiceClassName", itemData);
            string serviceClassName = itemData.Attributes["ServiceClassName"];
            object serviceInstance  = plugin.InstantiatePluginObject(serviceClassName);

            if (serviceInstance == null)
            {
                ServiceRegistration.Get <ILogger>().Warn("ServiceBuilder: Could not instantiate service class '{0}' in plugin '{1}' (id: '{2}')",
                                                         serviceClassName, itemData.PluginRuntime.Metadata.Name, itemData.PluginRuntime.Metadata.PluginId);
                return(null);
            }
            string registrationClassAssembly;

            if (!itemData.Attributes.TryGetValue("RegistrationClassAssembly", out registrationClassAssembly))
            {
                registrationClassAssembly = null;
            }
            string registrationClassName;

            if (!itemData.Attributes.TryGetValue("RegistrationClassName", out registrationClassName))
            {
                registrationClassName = null;
            }
            Type registrationType;

            if (string.IsNullOrEmpty(registrationClassName))
            {
                registrationType = serviceInstance.GetType();
            }
            else
            {
                registrationType = string.IsNullOrEmpty(registrationClassAssembly) ? plugin.GetPluginType(registrationClassName) :
                                   Type.GetType(registrationClassName + ", " + registrationClassAssembly);
            }
            if (registrationType == null)
            {
                ServiceRegistration.Get <ILogger>().Warn("ServiceBuilder: Could not instantiate service registration type '{0}' (Assembly: '{1}') in plugin '{2}' (id: '{3}')",
                                                         registrationClassName, registrationClassAssembly, itemData.PluginRuntime.Metadata.Name, itemData.PluginRuntime.Metadata.PluginId);
                return(null);
            }
            return(new ServiceItem(registrationType, serviceInstance));
        }
Ejemplo n.º 3
0
 public object BuildItem(PluginItemMetadata itemData, PluginRuntime plugin)
 {
     BuilderHelper.CheckParameter("ClassName", itemData);
     return(plugin.InstantiatePluginObject(itemData.Attributes["ClassName"]));
 }