Exemplo n.º 1
0
        public PluginPipelineUser(RequiredPropertyInfo demand, ArgumentValueUIArgs args, object demanderInstance)
            : base(new Type[] { }) //makes it a design time use case
        {
            Getter = () =>
            {
                var p = (Pipeline)args.InitialValue;
                return(p);
            };

            Setter = v => args.Setter(v);

            var pipeDemander = demanderInstance as IDemandToUseAPipeline;

            if (pipeDemander == null)
            {
                throw new NotSupportedException("Class " + demanderInstance.GetType().Name + " does not implement interface IDemandToUseAPipeline despite having a property which is a Pipeline");
            }

            _useCase = pipeDemander.GetDesignTimePipelineUseCase(demand);

            ExplicitSource      = _useCase.ExplicitSource;
            ExplicitDestination = _useCase.ExplicitDestination;

            foreach (var o in _useCase.GetInitializationObjects())
            {
                AddInitializationObject(o);
            }

            GenerateContext();
        }
Exemplo n.º 2
0
        /// <summary>
        /// Declares that the given <paramref name="property"/> (which must be nullable int) stores the ID (or null) of a <see cref="Pipeline"/> declared
        /// in the RDMP platform databases.  The property must belong to <paramref name="user"/>
        /// </summary>
        /// <param name="property"></param>
        /// <param name="user"></param>
        /// <param name="repository"></param>
        public PipelineUser(PropertyInfo property, DatabaseEntity user, ICatalogueRepository repository = null)
        {
            _property = property;
            User      = user;

            if (property.PropertyType != typeof(int?))
            {
                throw new NotSupportedException("Property " + property + " must be of PropertyType nullable int");
            }

            //if user passed in an explicit one
            _catalogueRepository = repository;

            //otherwise get it from the user
            if (_catalogueRepository == null)
            {
                if (User.Repository == null)
                {
                    throw new Exception("User does not have a Repository! how can it be a DatabaseEntity!");
                }

                _catalogueRepository = User.Repository as ICatalogueRepository;
                var dataExportRepo = User.Repository as IDataExportRepository;

                if (dataExportRepo != null)
                {
                    _catalogueRepository = dataExportRepo.CatalogueRepository;
                }

                if (_catalogueRepository == null)
                {
                    throw new Exception("Repository of Host '" + User + "' was not an ICatalogueRepository or a IDataExportRepository.  user came from a Repository called '" + user.Repository.GetType().Name + "' in this case you will need to specify the ICatalogueRepository property to this method so we know where to fetch Pipelines from");
                }
            }
            Getter = Get;
            Setter = Set;
        }