void IExtensionAttachmentStrategy.Attach(ExtensionAttachmentContext context, CustomAttributeData attribute) { if (IsSuitable(attribute)) { Attach(context, attribute); } }
///<summary> /// Создать элемент. ///</summary> public override JanusDBDriverInfo CreateElement( ExtensionAttachmentContext context, JanusDBDriverAttribute attr) { if (!typeof(IDBDriver).IsAssignableFrom(context.Type)) { throw new ExtensibilityException( "Type '{0}' must implement interface '{1}'" .FormatStr(context.Type, typeof(IDBDriver))); } return(new JanusDBDriverInfo( attr.Name, () => RetreiveResource( context.Type, attr.TextResourceFile, attr.DisplayNameResource, attr.Name), () => RetreiveResource( context.Type, attr.TextResourceFile, attr.DescriptionResource, ""), context.Type, attr.LockRequired)); }
/// <summary> /// Создать элемент. /// </summary> public override ConfigSectionInfo CreateElement(ExtensionAttachmentContext context, ConfigSectionAttribute attr) { return (new ConfigSectionInfo( attr.Name, attr.Namespace, attr.AllowMerge, context.Type, attr.CreateSerializer(context.Type))); }
private IRegElementsService <TInfo> GetService(ExtensionAttachmentContext context, TAttribute attr) { var regSvc = Publisher.GetService <IRegElementsService <TInfo> >(); if (regSvc == null) { regSvc = CreateService(context, attr); Publisher.Publish(regSvc); } return(regSvc); }
/// <summary> /// See base.CreateElement. /// </summary> public override CommandLineRulesProviderInfo CreateElement( ExtensionAttachmentContext context, CommandLineRulesProviderAttribute attr) { var contract = typeof(ICommandLineRulesProvider); if (contract.IsAssignableFrom(context.Type)) { throw new ExtensibilityException( "Type '{0}' must implement interface '{1}".FormatWith(context.Type, contract)); } return(new CommandLineRulesProviderInfo(context.Type)); }
///<summary> /// Создать элемент. ///</summary> public override StatisticsFormatterInfo CreateElement( ExtensionAttachmentContext context, StatisticsFormatterAttribute attr) { var type = typeof(IStatisticsFormatter); if (!type.IsAssignableFrom(context.Type)) { throw new ExtensibilityException( "Type '{0}' must implement interface '{1}'" .FormatStr(context.Type, type)); } return(new StatisticsFormatterInfo(attr.Name, attr.Description, context.Type)); }
/// <summary> /// Подключает расширение. /// </summary> protected override void Attach(ExtensionAttachmentContext context, CustomAttributeData attributeData) { var ctor = attributeData.Constructor; var srcType = ctor.DeclaringType; Debug.Assert(srcType != null, "attrType != null"); var roMode = srcType.Assembly.ReflectionOnly; if (roMode) { if (srcType.AssemblyQualifiedName == null) { throw new ExtensibilityException("Invalid attribute type"); } srcType = Type.GetType(srcType.AssemblyQualifiedName, true); ctor = srcType .GetConstructor( ctor .GetParameters() .Select(info => info.ParameterType) .ToArray()); Debug.Assert(ctor != null, "ctor != null"); } var attr = ctor .Invoke( attributeData .ConstructorArguments .Select <CustomAttributeTypedArgument, object>(GetArgValue) .ToArray()); if (attributeData.NamedArguments != null) { foreach (var arg in attributeData.NamedArguments) { var propInfo = !roMode ? (PropertyInfo)arg.MemberInfo : srcType.GetProperty(arg.MemberInfo.Name); propInfo.SetValue(attr, arg.TypedValue.Value, null); } } Attach(context, (TAttribute)attr); }
///<summary> /// Создать элемент. ///</summary> public override ExtensionInfoProviderInfo CreateElement( ExtensionAttachmentContext context, ExtensionInfoProviderAttribute attr) { if (!typeof(IExtensionInfoProvider).IsAssignableFrom(context.Type)) { throw new ExtensibilityException("Type '{0}' must implement interface '{1}'" .FormatStr(context.Type, typeof(IExtensionInfoProvider))); } var infSvc = context.GetService <IBootTimeInformer>(); if (infSvc != null) { var prov = JanusExtensionManager.CreateProvider(context, context.Type); infSvc.AddItem(prov.GetDisplayName(), prov.GetIcon()); } return(new ExtensionInfoProviderInfo(context.Type)); }
public override MenuProviderInfo CreateElement( ExtensionAttachmentContext context, MenuProviderAttribute attr) { return(new MenuProviderInfo(context.Type)); }
/// <summary> /// Подключает расширение. /// </summary> protected override void Attach(ExtensionAttachmentContext context, SimpleExtensionAttribute attribute) { _writer.WriteLine($"{attribute.Name}({context.Type.FullName})"); }
public override NavigationTreeProviderInfo CreateElement( ExtensionAttachmentContext context, NavigationTreeProviderAttribute attr) { return(new NavigationTreeProviderInfo(context.Type)); }
/// <summary> /// Attach specified type. /// </summary> protected abstract void Attach(ExtensionAttachmentContext context, CustomAttributeData attribute);
public override TextMacrosProviderInfo CreateElement( ExtensionAttachmentContext context, TextMacrosProviderAttribute attr) { return(new TextMacrosProviderInfo(context.Type)); }
/// <summary> /// Подключает расширение. /// </summary> protected override void Attach(ExtensionAttachmentContext context, TAttribute attribute) { base.Attach(context, attribute); CheckService(); }
/// <summary> /// Создать реализацию сервиса. /// </summary> protected virtual IRegElementsService <TInfo> CreateService(ExtensionAttachmentContext context, TAttribute attr) { return(new RegElementsService <TInfo>()); }
/// <summary> /// Создать элемент. /// </summary> public abstract TInfo CreateElement(ExtensionAttachmentContext context, TAttribute attr);
/// <summary> /// Подключает расширение. /// </summary> protected override void Attach(ExtensionAttachmentContext context, TAttribute attribute) { var regSvc = GetService(context, attribute); regSvc.Register(CreateElement(context, attribute)); }
/// <summary> /// Создать реализацию сервиса. /// </summary> protected override IRegElementsService <TInfo> CreateService(ExtensionAttachmentContext context, TAttribute attr) { return(new RegKeyedElementsService <TKey, TInfo>()); }
/// <summary> /// Подключает расширение. /// </summary> protected abstract void Attach(ExtensionAttachmentContext context, TAttribute attribute);
/// <summary> /// Создать элемент. /// </summary> public override FruitInfo CreateElement( ExtensionAttachmentContext context, FruitAttribute attr) { return(new FruitInfo(attr.Name, context.Type)); }