Пример #1
0
        /// <summary>
        /// Obtain a namespace for a specific NET type
        /// </summary>
        /// <param name="t"></param>
        /// <param name="converter"></param>
        /// <returns></returns>
        internal static string GetDartNamespace(Type t, DartFileNameConverter converter = null)
        {
            // Convert the namespace to flutter file path in package ==> /models/index.dart
            DartFileNameConverter fileNameConverter = converter ?? new DartFileNameConverter();

            char[]        separator   = { '.' };
            StringBuilder pathBuilder = new StringBuilder();

            pathBuilder.Clear();

            string ns = t.Namespace;

            pathBuilder.Append(DartProject.DartSeparator); // Add "/"

            if (!string.IsNullOrEmpty(ns))
            {
                string[] nsFolders = ns.Split(separator);

                foreach (string folder in nsFolders)
                {
                    pathBuilder.Append(fileNameConverter.Convert(folder));
                    pathBuilder.Append(DartProject.DartSeparator);
                }
            }

            return(pathBuilder.ToString());
        }
Пример #2
0
        /// <summary>
        /// Obtain the partial filename (.g) for a specific NET type
        /// </summary>
        /// <param name="t"></param>
        /// <param name="converter"></param>
        /// <returns></returns>
        internal static string GetDartPartialFilename(Type t, DartFileNameConverter converter = null)
        {
            // Convert the namespace to flutter file path in package ==> /models/index.dart
            DartFileNameConverter fileNameConverter = converter ?? new DartFileNameConverter();

            // Dart filename
            string dartFileName = fileNameConverter.Convert(t.Name) + ".g.dart";

            return(dartFileName);
        }