/// <summary>
        /// This method creates an instance of the <see cref="DomainServiceDescriptionProvider"/>. Subclasses can override this
        /// method to provide their own construction logic.
        /// </summary>
        /// <param name="domainServiceType">The <see cref="DomainService"/> type to create a description provider for.</param>
        /// <param name="parent">The parent description provider. May be null.</param>
        /// <returns>The description provider</returns>
        public virtual DomainServiceDescriptionProvider CreateProvider(Type domainServiceType, DomainServiceDescriptionProvider parent)
        {
            if (domainServiceType == null)
            {
                throw new ArgumentNullException("domainServiceType");
            }

            if (!typeof(DomainService).IsAssignableFrom(domainServiceType))
            {
                throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Resource.InvalidType, domainServiceType.FullName, typeof(DomainService).FullName), "domainServiceType");
            }

            if (!typeof(DomainServiceDescriptionProvider).IsAssignableFrom(this._domainServiceDescriptionProviderType))
            {
                throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture, Resource.InvalidType, this._domainServiceDescriptionProviderType.FullName, typeof(DomainServiceDescriptionProvider).FullName));
            }

            // Verify the type has a .ctor(Type, DomainServiceDescriptionProvider).
            if (this._domainServiceDescriptionProviderType.GetConstructor(new Type[] { typeof(Type), typeof(DomainServiceDescriptionProvider) }) == null)
            {
                throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture, Resource.DomainServiceDescriptionProviderAttribute_MissingConstructor, this._domainServiceDescriptionProviderType.FullName));
            }

            DomainServiceDescriptionProvider descriptionProvider = (DomainServiceDescriptionProvider)Activator.CreateInstance(
                this._domainServiceDescriptionProviderType, domainServiceType, parent);

            return descriptionProvider;
        }
Beispiel #2
0
        /// <summary>
        /// This method creates an instance of the <see cref="DomainServiceDescriptionProvider"/>. Subclasses can override this
        /// method to provide their own construction logic.
        /// </summary>
        /// <param name="domainServiceType">The <see cref="DomainService"/> type to create a description provider for.</param>
        /// <param name="parent">The parent description provider. May be null.</param>
        /// <returns>The description provider</returns>
        public virtual DomainServiceDescriptionProvider CreateProvider(Type domainServiceType, DomainServiceDescriptionProvider parent)
        {
            if (domainServiceType == null)
            {
                throw new ArgumentNullException("domainServiceType");
            }

            if (!typeof(DomainService).IsAssignableFrom(domainServiceType))
            {
                throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Resource.InvalidType, domainServiceType.FullName, typeof(DomainService).FullName), "domainServiceType");
            }

            if (!typeof(DomainServiceDescriptionProvider).IsAssignableFrom(this._domainServiceDescriptionProviderType))
            {
                throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture, Resource.InvalidType, this._domainServiceDescriptionProviderType.FullName, typeof(DomainServiceDescriptionProvider).FullName));
            }

            // Verify the type has a .ctor(Type, DomainServiceDescriptionProvider).
            if (this._domainServiceDescriptionProviderType.GetConstructor(new Type[] { typeof(Type), typeof(DomainServiceDescriptionProvider) }) == null)
            {
                throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture, Resource.DomainServiceDescriptionProviderAttribute_MissingConstructor, this._domainServiceDescriptionProviderType.FullName));
            }

            DomainServiceDescriptionProvider descriptionProvider = (DomainServiceDescriptionProvider)Activator.CreateInstance(
                this._domainServiceDescriptionProviderType, domainServiceType, parent);

            return(descriptionProvider);
        }
        /// <summary>
        /// Protected Constructor
        /// </summary>
        /// <param name="domainServiceType">The <see cref="DomainService"/> type this provider will create a description for.</param>
        /// <param name="parent">The existing parent description provider. May be null.</param>
        protected DomainServiceDescriptionProvider(Type domainServiceType, DomainServiceDescriptionProvider parent)
        {
            if (domainServiceType == null)
            {
                throw new ArgumentNullException("domainServiceType");
            }

            this._domainServiceType = domainServiceType;
            this._parentDescriptionProvider = parent;
        }
        /// <summary>
        /// Protected Constructor
        /// </summary>
        /// <param name="domainServiceType">The <see cref="DomainService"/> type this provider will create a description for.</param>
        /// <param name="parent">The existing parent description provider. May be null.</param>
        protected DomainServiceDescriptionProvider(Type domainServiceType, DomainServiceDescriptionProvider parent)
        {
            if (domainServiceType == null)
            {
                throw new ArgumentNullException("domainServiceType");
            }

            this._domainServiceType         = domainServiceType;
            this._parentDescriptionProvider = parent;
        }
Beispiel #5
0
        public DomainTypeDescriptionProvider(Type type, DomainServiceDescriptionProvider descriptionProvider)
            : base(TypeDescriptor.GetProvider(type))
        {
            if (descriptionProvider == null)
            {
                throw new ArgumentNullException("descriptionProvider");
            }

            this._type = type;
            this._descriptionProvider = descriptionProvider;
        }
        public DomainTypeDescriptionProvider(Type type, DomainServiceDescriptionProvider descriptionProvider)
            : base(TypeDescriptor.GetProvider(type))
        {
            if (descriptionProvider == null)
            {
                throw new ArgumentNullException("descriptionProvider");
            }

            this._type = type;
            this._descriptionProvider = descriptionProvider;
        }
 public LinqToSqlDomainServiceDescriptionProvider(Type domainServiceType, Type dataContextType, DomainServiceDescriptionProvider parent)
     : base(domainServiceType, parent)
 {
     lock (tdpContextMap)
     {
         if (!tdpContextMap.TryGetValue(dataContextType, out this._typeDescriptionContext))
         {
             // create and cache a context for this provider type
             this._typeDescriptionContext = new LinqToSqlTypeDescriptionContext(dataContextType);
             tdpContextMap.Add(dataContextType, this._typeDescriptionContext);
         }
     }
 }
        public override DomainServiceDescriptionProvider CreateProvider(Type domainServiceType, DomainServiceDescriptionProvider parent)
        {
            string currentDir = AppDomain.CurrentDomain.BaseDirectory;
            Configuration cfg = null;
            try
            {
                cfg = new Configuration();
                cfg.Configure(_nHibernateConfigurationPath);
                cfg.AddDirectory(new DirectoryInfo(currentDir));
            }
            catch
            {
                throw;
            }

            return new NHibernateTypeDescriptionProvider(domainServiceType, parent, cfg);
        }
        /// <summary>
        /// This method creates an instance of the <see cref="TypeDescriptionProvider"/>.
        /// </summary>
        /// <param name="domainServiceType">The <see cref="DomainService"/> Type to create a description provider for.</param>
        /// <param name="parent">The existing parent description provider.</param>
        /// <returns>The description provider.</returns>
        public override DomainServiceDescriptionProvider CreateProvider(Type domainServiceType, DomainServiceDescriptionProvider parent)
        {
            if (domainServiceType == null)
            {
                throw new ArgumentNullException("domainServiceType");
            }

            if (this._objectContextType == null)
            {
                this._objectContextType = GetContextType(domainServiceType);
            }

            if (!typeof(ObjectContext).IsAssignableFrom(this._objectContextType))
            {
                throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture, 
                    Resource.InvalidLinqToEntitiesDomainServiceDescriptionProviderSpecification, 
                    this._objectContextType));
            }

            return new LinqToEntitiesDomainServiceDescriptionProvider(domainServiceType, this._objectContextType, parent);
        }
 public NHibernateTypeDescriptionProvider(Type domainServiceType, DomainServiceDescriptionProvider parent, Configuration configuration)
     : base(domainServiceType, parent)
 {
     _domainServiceType = domainServiceType;
     _nhConfiguration = configuration;
 }
 public TableMetadataProvider(Type domainServiceType, DomainServiceDescriptionProvider parent)
     : base(domainServiceType, parent)
 {
 }
 /// <summary>
 /// Register our DomainTypeDescriptionProvider for the specfied Type. This provider is responsible for surfacing the
 /// custom TDs returned by description providers.
 /// </summary>
 /// <param name="type">The Type that we should register for.</param>
 /// <param name="descriptionProvider">The description provider.</param>
 private static void RegisterDomainTypeDescriptionProvider(Type type, DomainServiceDescriptionProvider descriptionProvider)
 {
     DomainTypeDescriptionProvider domainTdp = new DomainTypeDescriptionProvider(type, descriptionProvider);
     RegisterCustomTypeDescriptor(domainTdp, type);
 }