/// <summary> /// Registers a type for conversion inside the TypeProperties of an ADF resource. /// </summary> /// <typeparam name="T">The type to register.</typeparam> /// <param name="force">If true, register the type <typeparamref name="T"/> /// even if it has already been registered.</param> /// <param name="wrapperType">The type to use for displaying any error messages.</param> public virtual void RegisterType <T>(bool force, Type wrapperType = null) { this.EnsureIsAssignableRegisteredType <T>(); Type type = typeof(T); string typeName = DataFactoryUtilities.GetResourceTypeName(type); string wrapperTypeName = wrapperType != null ? wrapperType.Name : typeof(TRegistered).Name; lock (RegistrationLock) { if (this.TypeMap.ContainsKey(typeName)) { if (force) { this.TypeMap.Remove(typeName); } else { throw new InvalidOperationException(string.Format( CultureInfo.InvariantCulture, "A {0} type with the name '{1}' is already registered.", wrapperTypeName, typeName)); } } this.TypeMap.Add(typeName, type); } }
public bool TypeIsRegistered <T>() { this.EnsureIsAssignableRegisteredType <T>(); string typeName = DataFactoryUtilities.GetResourceTypeName(typeof(T)); lock (RegistrationLock) { return(this.TypeMap.ContainsKey(typeName)); } }
private void SetTypeProperties(TExtensibleTypeProperties properties, string typeName = null) { this.typeProperties = properties; Type type = properties.GetType(); Type genericTypePropertiesType = typeof(TGenericTypeProperties); if (type == genericTypePropertiesType) { Ensure.IsNotNullOrEmpty(typeName, "typeName", string.Format( CultureInfo.InvariantCulture, "'typeName' cannot be null if 'properties' is a {0} instance. The setter " + "for 'typeProperties' cannot be used if its value is GenericLinkedService, GenericTable or GenericActivity.", genericTypePropertiesType.Name)); this.Type = typeName; } else { this.Type = DataFactoryUtilities.GetResourceTypeName(type); } }
protected static string GetTypeName(Type type, string actualTypeName) { return(type == typeof(TGenericTypeProperties) ? actualTypeName : DataFactoryUtilities.GetResourceTypeName(type)); }