当前位置: 首页>>代码示例>>C#>>正文


C# ICodeBlock._方法代码示例

本文整理汇总了C#中ICodeBlock._方法的典型用法代码示例。如果您正苦于以下问题:C# ICodeBlock._方法的具体用法?C# ICodeBlock._怎么用?C# ICodeBlock._使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ICodeBlock的用法示例。


在下文中一共展示了ICodeBlock._方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GenerateGeneralActivity

        internal static ICodeBlock GenerateGeneralActivity(ICodeBlock codeBlock, IElement saveObject)
        {


            bool isEntity = saveObject is EntitySave;

            EntitySave entitySave = saveObject as EntitySave;

            // This code might seem a little weird.  The reason we do this
            // is because when an Entity is paused, it has a method that is
            // called.  However, when it is unpaused, there's just an instruction
            // that is executed - there is no event.  But if a Screen is paused, then
            // objects within that Screen don't get unpaused....so we're going to bet on
            // the Activity function only being called in unpaused Screens.  If this causes
            // probelsm we may have to make something a little more standard like an Unpause
            // method.
            if (isEntity &&
                (entitySave.ImplementsIClickable || entitySave.ImplementsIWindow)
                && !entitySave.GetInheritsFromIWindowOrIClickable()
                )
            {
                codeBlock.Line("mIsPaused = false;");
            }

            #region Call base.Activity if it has a derived object

            // We only need to do this for EntitySaves.  Screens inherit from the
            // Screen class so they ALWAYS call base.Activity.  It's in the generated
            // Screen template.  
            if ( saveObject.InheritsFromEntity())
            {
                codeBlock.Line("base.Activity();");
            }

            #endregion

            codeBlock._();

            // Eventually do we want to move this in the generate activity for custom variable code gen.
            CustomVariableCodeGenerator.WriteVelocityForCustomVariables(saveObject.CustomVariables, codeBlock);


            foreach (ElementComponentCodeGenerator codeGenerator in CodeWriter.CodeGenerators)
            {

                codeGenerator.GenerateActivity(codeBlock, saveObject);
            }


            return codeBlock;
        }
开发者ID:GorillaOne,项目名称:FlatRedBall,代码行数:51,代码来源:CodeWriter.cs

示例2: GenerateLoadAsyncCode

        private static bool GenerateLoadAsyncCode(ICodeBlock classLevelBlock, ICodeBlock initializeBlock)
        {
            bool loadAsync = ProjectManager.GlueProjectSave.GlobalContentSettingsSave.LoadAsynchronously;

            if (loadAsync)
            {
                GenerateInitializeAsync(initializeBlock);
            }

            loadAsync = ProjectManager.GlueProjectSave.GlobalContentSettingsSave.LoadAsynchronously;
            if (loadAsync)
            {

                classLevelBlock._();


                classLevelBlock.Line("#if !REQUIRES_PRIMARY_THREAD_LOADING");

                classLevelBlock
                    .Function("static void", "RequestContentLoad", "string contentName")
                        .Lock("LoadMethodList")
                            .Line("int index = -1;")
                            .For("int i = 0; i < LoadMethodList.Count; i++")
                                .If("LoadMethodList[i].Name == contentName")
                                    .Line("index = i;")
                                    .Line("break;")
                                .End()
                            .End()
                            .If("index != -1")
                                .Line("NamedDelegate delegateToShuffle = LoadMethodList[index];")
                                .Line("LoadMethodList.RemoveAt(index);")
                                .Line("LoadMethodList.Insert(0, delegateToShuffle);")
                            .End()
                        .End()
                    .End();
                classLevelBlock.Line("#endif");

                classLevelBlock._();

                classLevelBlock.Line("#if !REQUIRES_PRIMARY_THREAD_LOADING");
                classLevelBlock
                    .Function("static void", "AsyncInitialize", "")

                        .Line("#if XBOX360")
                        .Line("// We can not use threads 0 or 2")
                        .Line("// Async screen loading uses thread 4, so we'll use 3 here")
                        .Line("Thread.CurrentThread.SetProcessorAffinity(3);")
                        .Line("#endif")

                        .Line("bool shouldLoop = LoadMethodList.Count != 0;")

                        .While("shouldLoop")
                            .Line("System.Action action = null;")
                            .Lock("LoadMethodList")

                                .Line("action = LoadMethodList[0].LoadMethod;")
                                .Line("LoadMethodList.RemoveAt(0);")
                                .Line("shouldLoop = LoadMethodList.Count != 0 && !ShouldStopLoading;")

                            .End()
                            .Line("action();")
                        .End()
                        .Line("IsInitialized = true;")
                        ._()
                    .End();
                classLevelBlock.Line("#endif");

                //stringBuilder.AppendLine("\t\t\tstring ContentManagerName = \"Global\";");

            }

            return loadAsync;
        }
开发者ID:vchelaru,项目名称:FlatRedBall,代码行数:73,代码来源:ContentLoadWriter.cs

示例3: GenerateInitializeAsync

        private static void GenerateInitializeAsync(ICodeBlock currentBlock)
        {
            currentBlock.Line("#if !REQUIRES_PRIMARY_THREAD_LOADING");
            currentBlock.Line("NamedDelegate namedDelegate = new NamedDelegate();");

            foreach (ReferencedFileSave rfs in ProjectManager.GlueProjectSave.GlobalFiles)
            {
                if (!IsRfsHighPriority(rfs) && !rfs.LoadedOnlyWhenReferenced && rfs.LoadedAtRuntime)
                {
                    currentBlock.Line("namedDelegate.Name = \"" + rfs.Name + "\";");
                    currentBlock.Line("namedDelegate.LoadMethod = Load" + rfs.Name.Replace("/", "_").Replace(".", "_") + ";");
                    currentBlock.Line("LoadMethodList.Add( namedDelegate );");
                }
            }

            currentBlock._();

            currentBlock.Line("#if WINDOWS_8");
            currentBlock.Line("System.Threading.Tasks.Task.Run((System.Action)AsyncInitialize);");
            currentBlock.Line("#else");

            currentBlock.Line("ThreadStart threadStart = new ThreadStart(AsyncInitialize);");
            currentBlock.Line("Thread thread = new Thread(threadStart);");
            currentBlock.Line("thread.Name = \"GlobalContent Async load\";");
            currentBlock.Line("thread.Start();");
            currentBlock.Line("#endif");
            currentBlock.Line("#endif");
        }
开发者ID:vchelaru,项目名称:FlatRedBall,代码行数:28,代码来源:ContentLoadWriter.cs

示例4: GenerateDestroy

        public override ICodeBlock GenerateDestroy(ICodeBlock codeBlock,  SaveClasses.IElement element)
        {
            for (int i = 0; i < element.ReferencedFiles.Count; i++)
            {
                codeBlock.InsertBlock(GetDestroyForReferencedFile(element, element.ReferencedFiles[i]));
            }
            codeBlock._();

            return codeBlock;
        }
开发者ID:gitter-badger,项目名称:FlatRedBall,代码行数:10,代码来源:ReferencedFileSaveCodeGenerator.cs


注:本文中的ICodeBlock._方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。