/// <summary>
        /// Initializes a new instance of the <see cref="PackageLanguage"/> class.
        /// </summary>
        /// <param name="packageName">Name of the package that the language is for.</param>
        /// <param name="rootCulture">Culture of the non-translated message text in code.</param>
        /// <exception cref="System.ArgumentNullException">
        /// If <paramref name="packageName"/> or <paramref name="rootCulture"/> are <c>null</c>.
        /// </exception>
        /// <exception cref="System.ArgumentException">
        /// If <paramref name="packageName"/> is an empty string.
        /// </exception>
        protected PackageLanguage(string packageName, CultureInfo rootCulture)
        {
            ExceptionUtility.CheckExpectedStringArgument(packageName, "packageName");
            ExceptionUtility.CheckArgumentNotNull(rootCulture, "rootCulture");

            this.packageName = packageName;
            this.rootCulture = rootCulture;
        }
Esempio n. 2
0
        /// <summary>
        /// Does nothing if the specified <paramref name="assetPath"/> is valid;
        /// otherwise throws a <see cref="System.ArgumentException"/> exception.
        /// </summary>
        /// <param name="assetPath">Asset path.</param>
        /// <param name="paramName">Name of the parameter</param>
        /// <exception cref="System.ArgumentNullException">
        /// If <paramref name="assetPath"/> is <c>null</c>.
        /// </exception>
        /// <exception cref="System.ArgumentException">
        /// If <paramref name="assetPath"/> is not a valid asset path.
        /// </exception>
        public static void CheckAssetPathArgument(string assetPath, string paramName)
        {
            ExceptionUtility.CheckExpectedStringArgument(assetPath, paramName);

            string error = GetAssetPathError(assetPath);

            if (error != null)
            {
                throw new ArgumentException(error, paramName);
            }
        }
Esempio n. 3
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);
        }
Esempio n. 4
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);
        }
Esempio n. 5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="EditorMenuCommandEntry"/> class.
        /// </summary>
        /// <param name="fullPath">Full path of the command including its path, its label
        /// and any shortcut keys.</param>
        /// <exception cref="System.ArgumentNullException">
        /// If <paramref name="fullPath"/> is <c>null</c>.
        /// </exception>
        /// <exception cref="System.ArgumentException">
        /// If <paramref name="fullPath"/> is an invalid full command path.
        /// </exception>
        public EditorMenuCommandEntry(string fullPath)
        {
            ExceptionUtility.CheckExpectedStringArgument(fullPath, "fullPath");
            EditorMenuInternalUtility.CheckPathArgument(fullPath, "fullPath");

            int labelStartIndex = fullPath.LastIndexOf('/') + 1;

            this.Label    = fullPath.Substring(labelStartIndex);
            this.Path     = fullPath.Substring(0, labelStartIndex);
            this.FullPath = fullPath;

            this.IsEnabledPredicate = EditorMenuInternalUtility.AlwaysTruePredicate;
            this.IsCheckedPredicate = EditorMenuInternalUtility.AlwaysFalsePredicate;
        }
Esempio n. 6
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);
        }
Esempio n. 7
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;
        }