Exemple #1
0
        /// <summary>
        /// Determines whether a value is currently defined for a given shared property.
        /// </summary>
        /// <typeparam name="T">The type of value of interest.</typeparam>
        /// <param name="context">The <see cref="IBrushCreatorContext"/>.</param>
        /// <param name="key">Key of the shared property.</param>
        /// <returns>
        /// A value of <see langref="true"/>  if the shared property is defined with a
        /// compatible type; otherwise, a value of <see langref="false"/>.
        /// </returns>
        /// <exception cref="System.ArgumentNullException">
        /// If <paramref name="key"/> is <c>null</c>.
        /// </exception>
        /// <exception cref="System.ArgumentException">
        /// If <paramref name="key"/> is empty or is not a string.
        /// </exception>
        public static bool IsSharedPropertyDefined <T>(this IBrushCreatorContext context, string key)
        {
            ExceptionUtility.CheckExpectedStringArgument(key, "key");

            object value;

            if (context.SharedProperties.TryGetValue(key, out value))
            {
                return(value != null && typeof(T).IsAssignableFrom(value.GetType()));
            }
            return(false);
        }
Exemple #2
0
        /// <summary>
        /// Determines whether a value is currently defined for a given shared property.
        /// </summary>
        /// <param name="context">The <see cref="IBrushCreatorContext"/>.</param>
        /// <param name="key">Key of the shared property.</param>
        /// <returns>
        /// A value of <see langref="true"/>  if the shared property is defined;
        /// otherwise, a value of <see langref="false"/>.
        /// </returns>
        /// <exception cref="System.ArgumentNullException">
        /// If <paramref name="key"/> is <c>null</c>.
        /// </exception>
        /// <exception cref="System.ArgumentException">
        /// If <paramref name="key"/> is empty or is not a string.
        /// </exception>
        public static bool IsSharedPropertyDefined(this IBrushCreatorContext context, string key)
        {
            ExceptionUtility.CheckExpectedStringArgument(key, "key");

            object value;

            if (context.SharedProperties.TryGetValue(key, out value))
            {
                return(value != null);
            }
            return(false);
        }
Exemple #3
0
        /// <summary>
        /// Gets the value of a shared property.
        /// </summary>
        /// <remarks>
        /// <para>Refer to <see cref="BrushCreatorSharedPropertyKeys"/> for the built-in
        /// shared property keys.</para>
        /// </remarks>
        /// <typeparam name="T">The type of value.</typeparam>
        /// <param name="context">The <see cref="IBrushCreatorContext"/>.</param>
        /// <param name="key">Key of the shared property.</param>
        /// <param name="defaultValue">The default value to assume if the shared property
        /// has not been defined yet.</param>
        /// <exception cref="System.ArgumentNullException">
        /// If <paramref name="key"/> is <c>null</c>.
        /// </exception>
        /// <exception cref="System.ArgumentException">
        /// If <paramref name="key"/> is empty or is not a string.
        /// </exception>
        public static T GetSharedProperty <T>(this IBrushCreatorContext context, string key, T defaultValue = default(T))
        {
            ExceptionUtility.CheckExpectedStringArgument(key, "key");

            object value;

            if (context.SharedProperties.TryGetValue(key, out value))
            {
                if (value != null && typeof(T).IsAssignableFrom(value.GetType()))
                {
                    return((T)value);
                }
            }
            return(defaultValue);
        }
Exemple #4
0
        /// <summary>
        /// Sets the value of a shared property.
        /// </summary>
        /// <remarks>
        /// <para>Refer to <see cref="BrushCreatorSharedPropertyKeys"/> for the built-in
        /// shared property keys.</para>
        /// <para>DO NOT use square brackets around custom shared property key names.
        /// This is a convention used only for the built-in shared properties to avoid
        /// clashes if new built-in's are added in the future.</para>
        /// </remarks>
        /// <typeparam name="T">The type of value of interest.</typeparam>
        /// <param name="context">The <see cref="IBrushCreatorContext"/>.</param>
        /// <param name="key">Key of the shared property.</param>
        /// <param name="value">The value to assign.</param>
        /// <exception cref="System.ArgumentNullException">
        /// If <paramref name="key"/> is <c>null</c>.
        /// </exception>
        /// <exception cref="System.ArgumentException">
        /// If <paramref name="key"/> is empty or is not a string.
        /// </exception>
        public static void SetSharedProperty(this IBrushCreatorContext context, string key, object value)
        {
            ExceptionUtility.CheckExpectedStringArgument(key, "key");

            context.SharedProperties[key] = value;
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="AliasBrushCreator"/> class.
 /// </summary>
 /// <param name="context">The context of the creator.</param>
 public AliasBrushCreator(IBrushCreatorContext context)
     : base(context)
 {
 }
Exemple #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="OrientedBrushCreator"/> class.
 /// </summary>
 /// <param name="context">The context of the creator.</param>
 public OrientedBrushCreator(IBrushCreatorContext context)
     : base(context)
 {
 }
Exemple #7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BrushCreator"/> class.
 /// </summary>
 /// <param name="context">The context of the creator.</param>
 public BrushCreator(IBrushCreatorContext context)
 {
     this.Context = context;
 }
Exemple #8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="EmptyBrushCreator"/> class.
 /// </summary>
 /// <param name="context">The context of the creator.</param>
 public EmptyBrushCreator(IBrushCreatorContext context)
     : base(context)
 {
 }
Exemple #9
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AutotileCreator"/> class.
 /// </summary>
 /// <param name="context">The context of the creator.</param>
 public AutotileCreator(IBrushCreatorContext context)
     : base(context)
 {
 }
Exemple #10
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TilesetCreator"/> class.
 /// </summary>
 /// <param name="context">The context of the creator.</param>
 public TilesetCreator(IBrushCreatorContext context)
     : base(context)
 {
 }
Exemple #11
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DuplicateBrushCreator"/> class.
 /// </summary>
 /// <param name="context">The context of the creator.</param>
 public DuplicateBrushCreator(IBrushCreatorContext context)
     : base(context)
 {
 }