Example #1
0
 void IExtensionAttachmentStrategy.Attach(ExtensionAttachmentContext context, CustomAttributeData attribute)
 {
     if (IsSuitable(attribute))
     {
         Attach(context, attribute);
     }
 }
Example #2
0
 ///<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)));
 }
Example #4
0
        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));
        }
Example #6
0
        ///<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));
        }
Example #7
0
        /// <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));
        }
Example #9
0
 public override MenuProviderInfo CreateElement(
     ExtensionAttachmentContext context,
     MenuProviderAttribute attr)
 {
     return(new MenuProviderInfo(context.Type));
 }
Example #10
0
 /// <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));
 }
Example #12
0
 /// <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();
 }
Example #15
0
 /// <summary>
 /// Создать реализацию сервиса.
 /// </summary>
 protected virtual IRegElementsService <TInfo> CreateService(ExtensionAttachmentContext context, TAttribute attr)
 {
     return(new RegElementsService <TInfo>());
 }
Example #16
0
 /// <summary>
 /// Создать элемент.
 /// </summary>
 public abstract TInfo CreateElement(ExtensionAttachmentContext context, TAttribute attr);
Example #17
0
        /// <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>());
 }
Example #19
0
 /// <summary>
 /// Подключает расширение.
 /// </summary>
 protected abstract void Attach(ExtensionAttachmentContext context, TAttribute attribute);
Example #20
0
 /// <summary>
 /// Создать элемент.
 /// </summary>
 public override FruitInfo CreateElement(
     ExtensionAttachmentContext context,
     FruitAttribute attr)
 {
     return(new FruitInfo(attr.Name, context.Type));
 }