コード例 #1
0
        protected void WriteBlock(string toReplace, CodeGenerationTypeData[] codeGenerationTypeData,
                                  Func <CodeGenerationTypeData, string> writeSingle, bool withNewline = true, Func <string, string> afterAll = null)
        {
            m_Builder.Clear();
            var length = codeGenerationTypeData.Length;

            for (var i = 0; i < length; i++)
            {
                var block = writeSingle(codeGenerationTypeData[i]);
                if (string.IsNullOrEmpty(block))
                {
                    continue;
                }

                m_Builder.Append(block);
                if (withNewline && i < length - 1)
                {
                    m_Builder.Append(NewLine);
                }
            }

            var builtString = m_Builder.ToString();

            builtString = afterAll == null ? builtString : afterAll.Invoke(builtString);

            // Capture the newline in search string to overwrite it
            toReplace     += NewLine;
            BufferContents = BufferContents.Replace(toReplace, builtString);
        }
 public override bool TryGenerateCode(CodeGenerationTypeData[] typeData)
 {
     WriteRateConditionsInternal(typeData);
     WriteRateConditionTypeInternal(typeData);
     BufferContents = BufferContents.Replace("{TraitCollectionClassName}", nameof(CachedTraitCollection));
     return(TryWriteToFile());
 }
        public override bool TryGenerateCode(CodeGenerationTypeData[] typeData)
        {
            WriteFindTraitsInternal(typeData);
            WriteFillRequirementType(typeData);
            WriteUpdateRequirementType(typeData);
            WriteUpdateQueryMatch(typeData);
            WriteDataPassesAllConditionsInternal(typeData);

            BufferContents = BufferContents.Replace("{TraitCollectionClassName}", nameof(CachedTraitCollection));
            return(TryWriteToFile());
        }
コード例 #4
0
 public override bool TryGenerateCode(CodeGenerationTypeData[] typeData)
 {
     WriteBackingFields(typeData);
     WriteGetTraitProviderBlock(typeData);
     WriteStartBufferingBlock(typeData);
     WriteStopBufferingBlock(typeData);
     WriteInitializeTraitProviders(typeData);
     WriteUnloadTraitsBlock(typeData);
     WriteClearTraitsBlock(typeData);
     BufferContents = BufferContents.Replace("{TraitCollectionClassName}", nameof(CachedTraitCollection));
     return(TryWriteToFile());
 }
コード例 #5
0
 public override bool TryGenerateCode(CodeGenerationTypeData[] codeGenerationTypeRegistry)
 {
     WriteTraitDataFields(codeGenerationTypeRegistry);
     WriteClearBlock(codeGenerationTypeRegistry);
     WriteTakeSnapshotBlock(codeGenerationTypeRegistry);
     WriteGetTraitsBlock(codeGenerationTypeRegistry);
     WriteTryGetTraitBlock(codeGenerationTypeRegistry);
     WriteGetPotentialConditionsBlock(codeGenerationTypeRegistry);
     WriteCollectPotentialRelationsBlock(codeGenerationTypeRegistry);
     WriteGetAllTraitNamesBlock(codeGenerationTypeRegistry);
     BufferContents = BufferContents.Replace("{TraitCollectionClassName}", nameof(CachedTraitCollection));
     return(TryWriteToFile());
 }