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


C# ICodeBlock类代码示例

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


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

示例1: GenerateInitialize

        public override ICodeBlock GenerateInitialize(ICodeBlock codeBlock, SaveClasses.IElement element)
        {

            // Do the named object saves

            // We're going to do all "Entire File" NOS's first so that they aren't null before 
            for (int i = 0; i < element.NamedObjects.Count; i++)
            {
                NamedObjectSave nos = element.NamedObjects[i];

                if (nos.IsEntireFile)
                {
                    WriteCodeForNamedObjectInitialize(nos, element, codeBlock, null);
                }
            }

            // Now do non-entire files:
            for (int i = 0; i < element.NamedObjects.Count; i++)
            {
                NamedObjectSave nos = element.NamedObjects[i];

                if (!nos.IsEntireFile)
                {
                    WriteCodeForNamedObjectInitialize(nos, element, codeBlock, null);

                }
            }



            return codeBlock;
        }
开发者ID:vchelaru,项目名称:FlatRedBall,代码行数:32,代码来源:NamedObjectSaveCodeGenerator.cs

示例2: GenerateFields

        public override ICodeBlock GenerateFields(ICodeBlock codeBlock, IElement element)
        {
            foreach (EventResponseSave ers in element.Events)
            {
                bool isTunneling = ers.GetIsTunneling();
                bool isExposing = ers.GetIsExposing();

                bool shouldCreateMember =
                    isExposing || isTunneling;

                if (!shouldCreateMember)
                {
                    shouldCreateMember = !string.IsNullOrEmpty(ers.DelegateType);
                }

                if (shouldCreateMember)
                {
                    string delegateType = ers.GetEffectiveDelegateType(element);

                    codeBlock.Line("public event " + delegateType + " " + ers.EventName + ";");

                }
            }

            return codeBlock;
        }
开发者ID:vchelaru,项目名称:FlatRedBall,代码行数:26,代码来源:EventCodeGenerator.cs

示例3: CodeBlockFinally

 public CodeBlockFinally(ICodeBlock pParent)
     : base(pParent)
 {
     PreCodeLines.Add(new CodeLine("finally"));
     PreCodeLines.Add(new CodeLine("{"));
     PostCodeLines.Add(new CodeLine("}"));
 }
开发者ID:vchelaru,项目名称:FlatRedBall,代码行数:7,代码来源:CodeBlockException.cs

示例4: CodeBlockCatch

 public CodeBlockCatch(ICodeBlock pParent, string pCondition)
     : base(pParent)
 {
     PreCodeLines.Add(new CodeLine("catch(" + (string.IsNullOrEmpty(pCondition) ? "" : pCondition) + ")"));
     PreCodeLines.Add(new CodeLine("{"));
     PostCodeLines.Add(new CodeLine("}"));
 }
开发者ID:vchelaru,项目名称:FlatRedBall,代码行数:7,代码来源:CodeBlockException.cs

示例5: CodeBlockEnum

 public CodeBlockEnum(ICodeBlock pParent, string pPre, string pName)
     : base(pParent)
 {
     PreCodeLines.Add(new CodeLine(StringHelper.SpaceStrings(pPre, "enum", pName)));
     PreCodeLines.Add(new CodeLine("{"));
     PostCodeLines.Add(new CodeLine("}"));
 }
开发者ID:vchelaru,项目名称:FlatRedBall,代码行数:7,代码来源:CodeBlockClass.cs

示例6: GenerateHandleFileChanged

        private void GenerateHandleFileChanged(ICodeBlock codeBlock)
        {
            var method = codeBlock.Function("private static void", "HandleFileChanged", "object sender, System.IO.FileSystemEventArgs e");
            {
                var tryBlock = method.Try();

                tryBlock.Line("System.Threading.Thread.Sleep(500);");

                tryBlock.Line("var fullFileName = e.FullPath;");
                tryBlock.Line("var relativeFileName = FlatRedBall.IO.FileManager.MakeRelative(FlatRedBall.IO.FileManager.Standardize(fullFileName));");

                foreach(var rfs in GlueState.Self.CurrentGlueProject.GlobalFiles)
                {
                    bool shouldGenerate = rfs.LoadedAtRuntime && rfs.IsDatabaseForLocalizing == false;

                    if(shouldGenerate)
                    {
                        var fileName = ProjectBase.AccessContentDirectory + rfs.Name.ToLower().Replace("\\", "/");
                        var instanceName = rfs.GetInstanceName();

                        var ifStatement = tryBlock.If($"relativeFileName == \"{fileName}\"");
                        {
                            ifStatement.Line($"Reload({instanceName});");
                        }
                    }
                }
                var catchBlock = tryBlock.End().Line("catch{}");
            }
        }
开发者ID:vchelaru,项目名称:FlatRedBall,代码行数:29,代码来源:FileSystemWatcherCodeGenerator.cs

示例7: GenerateAddToManagers

        public override ICodeBlock GenerateAddToManagers(ICodeBlock codeBlock, IElement element)
        {
            if (ShouldGenerate)
            {
                foreach (var layer in GetObjectsForGumLayers(element))
                {
                    var rfs = GetScreenRfsIn(element);
                    if (rfs != null)
                    {

                        codeBlock.Line(layer.InstanceName + "Gum = RenderingLibrary.SystemManagers.Default.Renderer.AddLayer();");


                        codeBlock.Line(rfs.GetInstanceName() + ".AddGumLayerToFrbLayer(" + layer.InstanceName + "Gum, " + layer.InstanceName + ");");
                    }
                }
                // todo:  Need to register the layer here
                foreach (var item in element.AllNamedObjects.Where(item =>
                    GumPluginCodeGenerator.IsGue(item) &&
                    !string.IsNullOrEmpty(item.LayerOn) &&
                    NamedObjectSaveCodeGenerator.GetFieldCodeGenerationType(item) == CodeGenerationType.Full))
                {
                    codeBlock.Line(item.FieldName + ".MoveToLayer(" + item.LayerOn + "Gum);");
                }
            }
            return base.GenerateAddToManagers(codeBlock, element);
        }
开发者ID:GorillaOne,项目名称:FlatRedBall,代码行数:27,代码来源:GumLayerCodeGenerator.cs

示例8: CodeBlockSet

 public CodeBlockSet(ICodeBlock pParent, string pPre)
     : base(pParent)
 {
     PreCodeLines.Add(new CodeLine(StringHelper.SpaceStrings(pPre,"set")));
     PreCodeLines.Add(new CodeLine("{"));
     PostCodeLines.Add(new CodeLine("}"));
 }
开发者ID:vchelaru,项目名称:FlatRedBall,代码行数:7,代码来源:CodeBlockProperty.cs

示例9: GenerateFields

        public override ICodeBlock GenerateFields(ICodeBlock codeBlock,  SaveClasses.IElement element)
        {
            #region Get the ContentManager variable to use

            string contentManagerName = "ContentManagerName";

            if (element is ScreenSave)
            {
                contentManagerName = (element as ScreenSave).ContentManagerForCodeGeneration;
            }

            #endregion

            if (element is EntitySave)
            {
                codeBlock.Line("static object mLockObject = new object();");
                codeBlock.Line("static System.Collections.Generic.List<string> mRegisteredUnloads = new System.Collections.Generic.List<string>();");

                #region Keep track of whether we've already registered an unload method and if StaticContent has been loaded
                codeBlock.Line("static System.Collections.Generic.List<string> LoadedContentManagers = new System.Collections.Generic.List<string>();");
                #endregion
            }

            for (int i = 0; i < element.ReferencedFiles.Count; i++)
            {
                AppendFieldOrPropertyForReferencedFile(codeBlock,
                    element.ReferencedFiles[i], element.Name, element, contentManagerName);

                //stringBuilder.AppendLine(GetFieldForReferencedFile(mSaveObject.ReferencedFiles[i]));

            }

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

示例10: GenerateFields

        public override ICodeBlock GenerateFields(ICodeBlock codeBlock, SaveClasses.IElement element)
        {


            var currentBlock = codeBlock;

            if (element.HasStates)
            {
                List<StateSave> statesForThisCategory = GetSharedVariableStates(element);

                const string enumName = "VariableState";

                currentBlock = AppendEnum(currentBlock, statesForThisCategory, enumName, element);
                GenerateCurrentStateProperty(element, codeBlock, "VariableState", statesForThisCategory);

                //Build State Categories
                var stateCategories = GetAllStateCategoryNames(element, false);

                foreach (var stateCategory in stateCategories)
                {
                    var states = GetAllStatesForCategory(element, stateCategory);

                    AppendEnum(currentBlock, states, stateCategory, element);
                    GenerateCurrentStateProperty(element, codeBlock, stateCategory, states);
                }
            }

            return codeBlock;
        }
开发者ID:vchelaru,项目名称:FlatRedBall,代码行数:29,代码来源:StateCodeGenerator.cs

示例11: GenerateInitialize

 public override ICodeBlock GenerateInitialize(ICodeBlock codeBlock, SaveClasses.IElement element)
 {
     // Before August 23, 2010 Custom Variables used to be set
     // here in Initialize before the AddToManagers method.  This
     // is problematic because:
     // 1.   We probably want these
     //      variables reset whenever
     //      this object is recycled. 
     // 2.   If we set the position of 
     //      the Entity before its children
     //      have been attached, then the attachment
     //      will not work as expected.  Therefore, I've
     //      decided to move custom variable code to AddToManagers.
     // UPDATE:  Actually, we do want variables set here so that they
     // are available in Custom Initialize.
     // UPDATE2:  This was moved to its own method so that inheritance works.
     // UPDATE3:  It turns out there's 2 types of variables.  
     // 1.   Variables that are not set by derived.  These variables should get set
     //      in the base class or else they'll never get set for derived objects.
     // 2.   Variables that are set by derived.  These variables should get set in the
     //      "SetCustomVariables" method so that they get overridden by derived objects.
     // This means that we're going to set variables that are not set by derived here, and the
     // rest will get set in SetCustomVariables.
     // UPDATE4:  This has all moved to PostInitialize, which is called
     //           bottom-up.  This means there is no more split on variables.
     // UPDATE5:  This has been moved out of BaseElementTreeNode int CustomVariableCodeGenerator.
     return codeBlock;
 }
开发者ID:vchelaru,项目名称:FlatRedBall,代码行数:28,代码来源:CustomVariableCodeGenerator.cs

示例12: GenerateStart

 public static void GenerateStart(IElement saveObject, ICodeBlock codeBlock, string appendName)
 {
     if (ObjectFinder.Self.GlueProject.PerformanceSettingsSave.RecordInitializeSegments)
     {
         StartMeasurement(saveObject, codeBlock, appendName, true);
     }
 }
开发者ID:vchelaru,项目名称:FlatRedBall,代码行数:7,代码来源:PerformancePluginCodeGenerator.cs

示例13: GenerateAdditionalMethods

        public override ICodeBlock GenerateAdditionalMethods(ICodeBlock codeBlock, IElement element)
        {
            EntitySave entitySave = element as EntitySave;

            if (entitySave == null || (!entitySave.ImplementsIClickable && !entitySave.ImplementsIWindow))
            {
                return codeBlock;
            }


            if (entitySave.ImplementsIWindow)
            {
                bool inheritsFromIWindow = entitySave.GetInheritsFromIWindow();

                // Add all the code that never changes if this is the base IWindow (doesn't have a parent IWindow)
                if (!inheritsFromIWindow)
                {
                    GenerateEnabledVariable(codeBlock, element);      
                }
            }

            IWindowCodeGenerator.WriteCodeForHasCursorOver(
                entitySave, codeBlock, entitySave.GetInheritsFromIWindowOrIClickable());

            var isVirtual = string.IsNullOrEmpty(entitySave.BaseEntity) || entitySave.GetInheritsFromIWindowOrIClickable() == false;

            codeBlock
                .Function("WasClickedThisFrame", "FlatRedBall.Gui.Cursor cursor", Public: true, Virtual: isVirtual, Override: !isVirtual, Type: "bool")
                .Line("return cursor.PrimaryClick && HasCursorOver(cursor);")
                .End();

            return codeBlock;
        }
开发者ID:vchelaru,项目名称:FlatRedBall,代码行数:33,代码来源:IWindowCodeGenerator.cs

示例14: TryGenerateRemoveShapeCollectionFromManagers

 private static void TryGenerateRemoveShapeCollectionFromManagers(ICodeBlock codeBlock, IElement element)
 {
     if (element.IsICollidable())
     {
         codeBlock.Line("mGeneratedCollision.RemoveFromManagers(clearThis: false);");
     }
 }
开发者ID:vchelaru,项目名称:FlatRedBall,代码行数:7,代码来源:CollidableCodeGenerator.cs

示例15: GenerateInterpolateToStateAdvanced

        private ICodeBlock GenerateInterpolateToStateAdvanced(ICodeBlock codeBlock, string enumName)
        {
            codeBlock = codeBlock.Function("public void", "InterpolateToState",
                enumName + " fromState, " + enumName + " toState, double secondsToTake, FlatRedBall.Glue.StateInterpolation.InterpolationType interpolationType, FlatRedBall.Glue.StateInterpolation.Easing easing");

            string variableName;
            if (enumName == "VariableState")
            {
                variableName = "CurrentState";
            }
            else
            {
                variableName = "Current" + enumName + "State";
            }

            codeBlock = codeBlock.If("secondsToTake <= 0");
            codeBlock.Line(variableName + " = toState;");
            codeBlock = codeBlock.End().Else();

            // Immediately set the state to the from state:
            codeBlock.Line(variableName + " = fromState;");
            
            codeBlock.Line("mFrom" + enumName + "Tween = fromState;");
            codeBlock.Line("mTo" + enumName + "Tween = toState;");

            codeBlock.Line(
                TweenerNameFor(enumName) + ".Start(0, 1, (float)secondsToTake, FlatRedBall.Glue.StateInterpolation.Tweener.GetInterpolationFunction(interpolationType, easing));");
            codeBlock = codeBlock.End();// else
            codeBlock = codeBlock.End();
            return codeBlock;
        }
开发者ID:vchelaru,项目名称:FlatRedBall,代码行数:31,代码来源:StateInterpolationCodeGenerator.cs


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