コード例 #1
0
        void Build(DOMCommand command)
        {
            Assert.IsFalse(string.IsNullOrEmpty(command.name), "name is required for <command />");

            var pptName = NameUtility.SlugifyConstName(command.name);

            var parametricArgs = string.Empty;

            if (command.args != null && command.args.Length > 0)
            {
                var builder = new StringBuilder();
                builder.Append("<");
                for (int i = 0; i < command.args.Length; i++)
                {
                    if (i > 0)
                    {
                        builder.Append(", ");
                    }
                    builder.Append(command.args[i].type);
                }
                builder.Append(">");
                parametricArgs = builder.ToString();
            }

            m_Class.AddField(
                new CSField(
                    Scope.Private,
                    pptName,
                    "IClassMethod" + parametricArgs,
                    "new DynamicClassMethod" + parametricArgs + "(\"" + command.name + "\")",
                    CSField.Modifier.Static | CSField.Modifier.Readonly));
        }
コード例 #2
0
        public async Task NewColumnAsync()
        {
            var items = await this.Template.Dispatcher.InvokeAsync(() => this.Template.Select(item => item.Name).ToArray());

            var selectableTypes = await this.Template.Dispatcher.InvokeAsync(() => this.Template.SelectableTypes);

            var name   = NameUtility.GenerateNewName("Column", items);
            var dialog = new NewColumnViewModel(selectableTypes)
            {
                Name     = name,
                IsKey    = items.Any() == false,
                DataType = typeof(string).GetTypeName()
            };

            if (await dialog.ShowDialogAsync() == true)
            {
                var member = await this.Template.AddNewAsync(this.authentication);

                await member.SetNameAsync(this.authentication, dialog.Name);

                await member.SetDataTypeAsync(this.authentication, dialog.DataType);

                await member.SetCommentAsync(this.authentication, dialog.Comment);

                await member.SetIsKeyAsync(this.authentication, dialog.IsKey);

                await this.Template.EndNewAsync(this.authentication, member);
            }
        }
コード例 #3
0
        private static void WriteObject(JsonWriter writer, object value, JsonSerializer serializer)
        {
            if (value == null)
            {
                writer.WriteNull();
                return;
            }

            Type     valueType     = value.GetType();
            TypeInfo valueTypeInfo = valueType.GetTypeInfo();

            writer.WriteStartObject();

            writer.WritePropertyName("$type");
            writer.WriteValue(NameUtility.GetSimpleAssemblyQualifiedName(valueType));

            writer.WritePropertyName("$value");

            if (valueTypeInfo.IsPrimitive)
            {
                writer.WriteValue(value);
            }
            else
            {
                serializer.Serialize(writer, value);
            }

            writer.WriteEndObject();
        }
コード例 #4
0
ファイル: InternalDataTable.cs プロジェクト: teize001/Crema
        public InternalDataTable AddChild()
        {
            var childNames = from item in this.ChildItems select item.LocalName;
            var childName  = NameUtility.GenerateNewName(childNameString, childNames.ToArray());

            return(this.AddChild(childName));
        }
コード例 #5
0
        public static async Task GenerateStandardFlagsAsync(this ITypeCategory category, Authentication authentication)
        {
            var types     = category.GetService(typeof(ITypeCollection)) as ITypeCollection;
            var typeNames = await types.Dispatcher.InvokeAsync(() => types.Select(item => item.Name).ToArray());

            var newName  = NameUtility.GenerateNewName("Flag", typeNames);
            var template = await category.AddNewTypeAsync(authentication);

            await template.SetTypeNameAsync(authentication, newName);

            await template.SetIsFlagAsync(authentication, true);

            await template.SetCommentAsync(authentication, "Standard Flag");

            await template.AddMemberAsync(authentication, "None", 0, "None Value");

            await template.AddMemberAsync(authentication, "A", 1, "A Value");

            await template.AddMemberAsync(authentication, "B", 2, "B Value");

            await template.AddMemberAsync(authentication, "C", 4, "C Value");

            await template.AddMemberAsync(authentication, "D", 8, "D Value");

            await template.AddMemberAsync(authentication, "AC", 1 | 4, "AC Value");

            await template.AddMemberAsync(authentication, "ABC", 1 | 2 | 4, "AC Value");

            await template.AddMemberAsync(authentication, "BD", 2 | 8, "AC Value");

            await template.AddMemberAsync(authentication, "All", 1 | 2 | 4 | 8, "All Value");

            await template.EndEditAsync(authentication);
        }
コード例 #6
0
        private static void FillColumns(CremaDataTable diffTable, CremaDataTable dataTable, List <DiffPiece> lines)
        {
            var index = 0;

            foreach (var item in lines)
            {
                var diffColumn = diffTable.Columns.Add();
                if (item.Text != null && dataTable != null)
                {
                    var dataColumn = dataTable.Columns[index];
                    diffColumn.ColumnName = dataColumn.ColumnName;
                    diffColumn.CopyFrom(dataColumn);
                    index++;
                }
                else
                {
                    diffColumn.ColumnName = GenerateDummyName();
                }
                DiffUtility.SetDiffState(diffColumn, (DiffState)item.Type);
            }

            string GenerateDummyName()
            {
                return(NameUtility.GenerateNewName(DiffUtility.DiffDummyKey, diffTable.Columns.Select(item => item.ColumnName)));
            }
        }
コード例 #7
0
ファイル: InternalDataTable.cs プロジェクト: teize001/Crema
        public InternalDataColumn AddColumn()
        {
            var columnNames = from DataColumn item in this.Columns select item.ColumnName;
            var columnName  = NameUtility.GenerateNewName(columnNameString, columnNames.ToArray());

            return(this.AddColumn(columnName));
        }
コード例 #8
0
    //public void SaveFile(AudioClip clip)
    //{

    //    print("SAVING");

    //    uiManager.StartSave();



    //    string wavFile = SaveWav.Save("recording.wav", clip);

    //    mp3Bytes = null;

    //    FindObjectOfType<NetworkingHandler>().SendFileToConvert(wavFile);

    //    checkIfConversionDone = true;


    //}

    //public void UploadAudioFile()
    //{
    //    string name = ConstructName() + ".mp3";

    //    FindObjectOfType<NetworkingHandler>().SendAudioFileToServer(mp3Bytes, name);

    //    uiManager.StartUpload();
    //    print("UPLOAD AWAY! >>>>>>>>>>>>>>>>>>>>>>>");

    //}

    public string ConstructName()
    {
        Vector3 localLocation = myLocation.GetLocalLocation();
        string  name          = NameUtility.CreateNameFromCoord(localLocation, DateTime.UtcNow.ToLongTimeString());

        return(name);
    }
コード例 #9
0
        protected override async Task <CremaTemplate> CreateSourceAsync(Authentication authentication)
        {
            if (this.parent is TableCategory category)
            {
                var typeContext  = category.GetService(typeof(TypeContext)) as TypeContext;
                var tableContext = category.GetService(typeof(TableContext)) as TableContext;
                var dataSet      = await category.ReadDataForNewTemplateAsync(authentication);

                var tableNames = await tableContext.Dispatcher.InvokeAsync(() => tableContext.Tables.Select((Table item) => item.Name).ToArray());

                var newName        = NameUtility.GenerateNewName(nameof(Table), tableNames);
                var templateSource = CremaTemplate.Create(dataSet, newName, category.Path);
                return(templateSource);
            }
            else if (this.parent is Table table)
            {
                var dataSet = await table.ReadDataForNewTemplateAsync(authentication);

                var dataTable  = dataSet.Tables[table.Name, table.Category.Path];
                var childNames = await table.Dispatcher.InvokeAsync(() => table.Childs.Select(item => item.TableName).Concat(new string[] { table.TableName }).ToArray());

                var newName  = NameUtility.GenerateNewName(ChildString, childNames);
                var template = CremaTemplate.Create(dataTable);
                template.TableName = newName;
                return(template);
            }
            throw new NotImplementedException();
        }
コード例 #10
0
        public CremaDataTable Inherit()
        {
            var tables    = this.DataSet != null ? this.DataSet.Tables : Enumerable.Empty <CremaDataTable>();
            var tableName = NameUtility.GenerateNewName("DerivedTable", tables.Select(item => item.TableName));

            return(this.Inherit(tableName));
        }
コード例 #11
0
        // -------------------------------------------------------------------------
        /// Deletes the generate code files.
        ///
        /// @param iStorage The VS storage to convert to code.
        ///
        public void DeleteGeneratedFilesFor(iCS_IStorage iStorage)
        {
            var fileName = NameUtility.ToTypeName(iStorage.TypeName);
            var folder   = CodeGenerationUtility.GetCodeGenerationFolder(iStorage);

            CSharpFileUtils.DeleteCSharpFile(folder, fileName);
        }
コード例 #12
0
        public async Task Build()
        {
            FsBuilder.EnsureDirectoryEmpty();

            Data = (from x in Data orderby x.CreationTime descending select x).ToArray();

            await BuildIndexType().ConfigureAwait(false);

            await BuildIndexKeyword().ConfigureAwait(false);

            await BuildIndexCategory().ConfigureAwait(false);

            foreach (var v in Data)
            {
                Post post = v;
                using var st = FsBuilder.GetFileRewriteStream($"{NameUtility.Encode(post.Id)}.json");
                await JsonSerializer.SerializeAsync(st, post).ConfigureAwait(false);
            }

            {
                PagingProvider <string> paging = new PagingProvider <string>(Path.Join(RootPath, "pages"));

                await paging.Build(Data.Select(x => x.Id).ToArray(),
                                   PagingConfig).ConfigureAwait(false);
            }
        }
コード例 #13
0
ファイル: CremaTableTest.cs プロジェクト: teize001/Crema
        public static void RenameTest(this IType type, Authentication authentication)
        {
            var types   = type.GetService(typeof(ITypeCollection)) as ITypeCollection;
            var newName = NameUtility.GenerateNewName(RandomUtility.NextIdentifier(), types.Select(item => item.Name));

            type.Rename(authentication, newName);
        }
コード例 #14
0
        // ----------------------------------------------------------------------
        // Removes the non needed fix ports.
        public bool CleanupExistingProposedPorts(iCS_EditorObject node, PortInfo[] neededPorts)
        {
            bool changed = false;
            var  currentProposedPorts = GetCurrentProposedPorts(node);

            foreach (var cp in currentProposedPorts)
            {
                bool found = false;
                foreach (var np in neededPorts)
                {
                    if (NameUtility.ToDisplayName(np.Name) == cp.DisplayName &&
                        np.PortType == cp.ObjectType &&
                        np.ValueType == cp.RuntimeType)
                    {
                        found = true;
                    }
                }
                if (!found)
                {
                    DestroyInstance(cp);
                    changed = true;
                }
            }
            return(changed);
        }
コード例 #15
0
 public static Task <string> GenerateNewCategoryNameAsync(this ITableCategory tableCategory, string name)
 {
     return(tableCategory.Dispatcher.InvokeAsync(() =>
     {
         var names = tableCategory.Categories.Select(item => item.Name);
         return NameUtility.GenerateNewName(name, names);
     }));
 }
コード例 #16
0
        public CremaDataTable Copy()
        {
            var tables    = this.Parent != null ? this.Parent.Childs : (this.DataSet != null ? this.DataSet.Tables : Enumerable.Empty <CremaDataTable>());
            var tableName = NameUtility.GenerateNewName("CopiedTable", tables.Select(item => item.TableName));
            var name      = CremaDataTable.GenerateName(this.ParentName, tableName);

            return(this.Copy(name));
        }
コード例 #17
0
ファイル: CremaTableTest.cs プロジェクト: teize001/Crema
        public static void RenameTest(this ITypeCategory category, Authentication authentication)
        {
            Assert.AreNotEqual(null, category.Parent);
            var parent  = category.Parent;
            var newName = NameUtility.GenerateNewName(RandomUtility.NextIdentifier(), parent.Categories.Select(item => item.Name));

            category.Rename(authentication, newName);
        }
コード例 #18
0
        protected override CremaTemplate CreateSource(Authentication authentication)
        {
            var typeContext    = this.category.GetService(typeof(TypeContext)) as TypeContext;
            var dataSet        = typeContext.Root.ReadData(authentication, true);
            var newName        = NameUtility.GenerateNewName("Table", this.category.Context.Tables.Select((Table item) => item.Name));
            var templateSource = CremaTemplate.Create(dataSet, newName, this.category.Path);

            return(templateSource);
        }
コード例 #19
0
 public void Add(CremaDataType type)
 {
     this.ValidateAdd(type);
     if (type.TypeName == string.Empty)
     {
         type.TypeName = NameUtility.GenerateNewName("Type", this.Select(item => item.TypeName).ToArray());
     }
     this.tables.Add(type.InternalObject);
 }
コード例 #20
0
        // =================================================================================
        // Helpers
        // ---------------------------------------------------------------------------------
        static string GetVariableName(LibraryObject libraryObject)
        {
            var rawName = libraryObject.rawName;

            if (rawName.StartsWith("set_") || rawName.StartsWith("get_"))
            {
                rawName = rawName.Substring(4);
            }
            return(NameUtility.ToDisplayName(rawName));
        }
コード例 #21
0
ファイル: CremaRandomUtility.cs プロジェクト: teize001/Crema
        public static bool GenerateUser(this IUserContext context, Authentication authentication)
        {
            var category = context.Categories.Random();
            var newID    = NameUtility.GenerateNewName("Test", context.Users.Select(item => item.ID).ToArray());
            var newName  = newID.Replace("Test", "테스트");

            category.AddNewUser(authentication, newID, null, newName, Authority.Member);

            return(true);
        }
コード例 #22
0
        protected override CremaDataType CreateSource(Authentication authentication)
        {
            var newName  = NameUtility.GenerateNewName("Type", this.Types.Select((Type item) => item.Name).ToArray());
            var dataSet  = CremaDataSet.Create(new SignatureDateProvider(authentication.ID));
            var dataType = dataSet.Types.Add();

            dataType.TypeName     = newName;
            dataType.CategoryPath = this.category.Path;
            return(dataType);
        }
コード例 #23
0
        static string GetTypeName(LibraryObject libraryObject)
        {
            var type = GetVariableType(libraryObject);

            if (type == null)
            {
                return(null);
            }
            return(NameUtility.ToDisplayName(iCS_Types.TypeName(type)));
        }
コード例 #24
0
        // ----------------------------------------------------------------------
        internal override string GetNodeName()
        {
            var name = NameUtility.ToDisplayName(memberInfo.Name);

            if (isGeneric)
            {
                name += NameUtility.ToDisplayGenericArguments(genericArguments);
            }
            return(name);
        }
コード例 #25
0
        public async Task CreateAsync()
        {
            var authentication = this.CommandContext.GetAuthentication(this);
            var category       = await this.GetCategoryAsync(this.CategoryPath ?? this.GetCurrentDirectory());

            var typeNames = await this.GetTypeNamesAsync();

            var template = await category.AddNewTypeAsync(authentication);

            var typeName = NameUtility.GenerateNewName("Type", typeNames);
            var typeInfo = JsonTypeInfo.Default;

            typeInfo.TypeName = typeName;

            try
            {
                if (JsonEditorHost.TryEdit(ref typeInfo) == false)
                {
                    return;
                }
                if (this.CommandContext.ReadYesOrNo($"do you want to create type '{typeInfo.TypeName}'?") == false)
                {
                    return;
                }

                await template.SetTypeNameAsync(authentication, typeInfo.TypeName);

                await template.SetIsFlagAsync(authentication, typeInfo.IsFlag);

                await template.SetCommentAsync(authentication, typeInfo.Comment);

                foreach (var item in typeInfo.Members)
                {
                    var member = await template.AddNewAsync(authentication);

                    await member.SetNameAsync(authentication, item.Name);

                    await member.SetValueAsync(authentication, item.Value);

                    await member.SetCommentAsync(authentication, item.Comment);

                    await template.EndNewAsync(authentication, member);
                }
                await template.EndEditAsync(authentication);

                template = null;
            }
            finally
            {
                if (template != null)
                {
                    await template.CancelEditAsync(authentication);
                }
            }
        }
コード例 #26
0
        public CremaDataTableNamespace(string name, string categoryPath, string baseNamespace)
        {
            NameValidator.ValidateName(name);
            NameValidator.ValidateCategoryPath(categoryPath);

            var tableName = NameUtility.GetName(name);

            this.Name           = name;
            this.TableName      = tableName;
            this.TableNamespace = baseNamespace + categoryPath + name;
        }
コード例 #27
0
        // ========================================================================
        /// Extracts the engine namespace from the project name.
        public string GetEngineNamespace()
        {
            // -- Translate '-' to '_' for the namespace. --
            var formattedProjectName = NameUtility.ToTypeName(myPackageName.Replace('-', '_'));

            if (myParentPackage == null)
            {
                return(formattedProjectName);
            }
            return(myParentPackage.EngineNamespace + "." + formattedProjectName);
        }
コード例 #28
0
        internal override string GetNodeName()
        {
            var displayName = new StringBuilder(64);

            displayName.Append(NameUtility.ToDisplayName(memberInfo.Name));
            if (isGeneric)
            {
                displayName.Append(NameUtility.ToDisplayGenericArguments(genericArguments));
            }
            return(displayName.ToString());
        }
コード例 #29
0
        protected override async Task <CremaDataType> CreateSourceAsync(Authentication authentication)
        {
            var dataSet = await this.category.ReadDataForNewTemplateAsync(authentication);

            var typeName = NameUtility.GenerateNewName(nameof(Type), this.Types.Select((Type item) => item.Name).ToArray());
            var dataType = dataSet.Types.Add();

            dataType.TypeName     = typeName;
            dataType.CategoryPath = this.category.Path;
            return(dataType);
        }
コード例 #30
0
ファイル: TypeMember.cs プロジェクト: teize001/Crema
        public TypeMember(TypeTemplateBase template, DataTable table)
            : base(template.Domain, table)
        {
            this.template = template;
            var query = from DataRow item in table.Rows
                        select item.Field <string>("Name");

            var newName = NameUtility.GenerateNewName("Type", query);

            this.SetField(null, "Name", newName);
        }