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


C# IElement.InheritsFromElement方法代码示例

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


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

示例1: GenerateAddToManagers

        internal static ICodeBlock GenerateAddToManagers(IElement saveObject)
        {
            ICodeBlock codeBlock = new CodeDocument(2);
            ICodeBlock currentBlock = codeBlock;

            bool isEntity = saveObject is EntitySave;
            bool isScreen = !isEntity;

            bool inheritsFromNonFrbType = 
                !string.IsNullOrEmpty(saveObject.BaseElement) && !saveObject.InheritsFromFrbType();
            GenerateReAddToManagers(saveObject, currentBlock);


            #region Generate the method header

            if (isScreen)
            {
                currentBlock = currentBlock
                    .Function("public override void", "AddToManagers", "");
            }
            else if (saveObject.InheritsFromElement()) // it's an EntitySave
            {
                currentBlock = currentBlock
                    .Function("public override void", "AddToManagers", "FlatRedBall.Graphics.Layer layerToAddTo");
            }
            else // It's a base EntitySave
            {
                currentBlock = currentBlock
                    .Function("public virtual void", "AddToManagers", "FlatRedBall.Graphics.Layer layerToAddTo");
            }
            #endregion



            PerformancePluginCodeGenerator.SaveObject = saveObject;
            PerformancePluginCodeGenerator.CodeBlock = currentBlock;

            PerformancePluginCodeGenerator.GenerateStart("Pooled PostInitialize");

            #region Call PostInitialize *again* if this is a pooled, base Entity

            FactoryCodeGenerator.CallPostInitializeIfNecessary(saveObject, currentBlock);


            #endregion

            PerformancePluginCodeGenerator.GenerateEnd();

            PerformancePluginCodeGenerator.GenerateStart("Layer for this code");


            #region Generate layer if a screen

            if (IsOnOwnLayer(saveObject))
            {
                // Only Screens need to define a layer.  Otherwise, the layer is fed to the Entity
                if (isScreen)
                {
                    currentBlock.Line("mLayer = SpriteManager.AddLayer();");
                }
            }

            #endregion

            #region Assign the layer so that custom code can get to it

            if (isEntity)
            {
                currentBlock.Line("LayerProvidedByContainer = layerToAddTo;");
            }


            #endregion

            PerformancePluginCodeGenerator.GenerateEnd();

            GenerateAddThisEntityToManagers(saveObject, currentBlock);

            const string addFilesToManagers = "Add Files to Managers";
            PerformancePluginCodeGenerator.GenerateStart(saveObject, currentBlock, addFilesToManagers);


            #region Add all ReferencedFileSaves

            // Add referenced files before adding objects because the objects
            // may be aliases for the files (if using Entire File) and may add them
            // to layers.
            for (int i = 0; i < saveObject.ReferencedFiles.Count; i++)
            {

                PerformancePluginCodeGenerator.GenerateStart("Adding file " + saveObject.ReferencedFiles[i].GetInstanceName());
                currentBlock.InsertBlock(ReferencedFileSaveCodeGenerator.GetAddToManagersForReferencedFile(saveObject, saveObject.ReferencedFiles[i]));
                PerformancePluginCodeGenerator.GenerateEnd();
            }

            #endregion
            PerformancePluginCodeGenerator.GenerateEnd(saveObject, currentBlock, addFilesToManagers);
            PerformancePluginCodeGenerator.GenerateStart("Create layer instances");

            #region First generate all code for Layers before other stuff
//.........这里部分代码省略.........
开发者ID:GorillaOne,项目名称:FlatRedBall,代码行数:101,代码来源:CodeWriter.cs

示例2: GenerateRemoveFromManagers

        private static void GenerateRemoveFromManagers(ICodeBlock currentBlock, IElement saveObject)
        {
            if (saveObject.InheritsFromElement())
            {
                currentBlock = currentBlock.Function("public override void", "RemoveFromManagers", "");
                currentBlock.Line("base.RemoveFromManagers();");
            }
            else
            {
                currentBlock = currentBlock.Function("public virtual void", "RemoveFromManagers", "");

            }

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

            // The Screen template already includes a call to base.Destroy
            if (saveObject.InheritsFromEntity())
            {
                currentBlock.Line("base.RemoveFromManagers();");
            }

            #endregion

            if (saveObject is EntitySave)
            {
                if (saveObject.InheritsFromFrbType())
                {
                    AssetTypeInfo ati = AvailableAssetTypes.Self.GetAssetTypeFromRuntimeType(saveObject.BaseObject);

                    if (ati != null)
                    {
                        EntitySave asEntitySave = saveObject as EntitySave;

                        if (asEntitySave.CreatedByOtherEntities && !string.IsNullOrEmpty(ati.RecycledDestroyMethod))
                        {
                            currentBlock.Line(ati.RecycledDestroyMethod + ";");
                        }
                        else
                        {
                            currentBlock.Line(ati.DestroyMethod + ";");
                        }
                    }
                }

                else if (!saveObject.InheritsFromElement())
                {
                    currentBlock.Line("FlatRedBall.SpriteManager.ConvertToManuallyUpdated(this);");
                }

                if ((saveObject as EntitySave).ImplementsIWindow && !(saveObject as EntitySave).GetInheritsFromIWindow())
                {
                    currentBlock.Line("FlatRedBall.Gui.GuiManager.RemoveWindow(this);");
                }
            }

            foreach (ElementComponentCodeGenerator codeGenerator in CodeWriter.CodeGenerators)
            {
                codeGenerator.GenerateRemoveFromManagers(currentBlock, saveObject);
            }
        }
开发者ID:GorillaOne,项目名称:FlatRedBall,代码行数:60,代码来源:CodeWriter.cs

示例3: GenerateInitialize

        internal static ICodeBlock GenerateInitialize(IElement saveObject)
        {

            ICodeBlock codeBlock = new CodeDocument(3);
            ICodeBlock currentBlock = codeBlock;

            // Start measuring performance before anything else
            PerformancePluginCodeGenerator.GenerateStartTimingInitialize(saveObject, codeBlock);

            PerformancePluginCodeGenerator.SaveObject = saveObject;
            PerformancePluginCodeGenerator.CodeBlock = codeBlock;

            PerformancePluginCodeGenerator.GenerateStart("CustomLoadStaticContent from Initialize");

            // Load static content before looping through the CodeGenerators
            // The reason for this is there is a ReferencedFileSaveCodeGenerator
            // which needs to work with static RFS's which are instantiated here
            currentBlock.Line("LoadStaticContent(ContentManagerName);");

            PerformancePluginCodeGenerator.GenerateEnd();


            PerformancePluginCodeGenerator.GenerateStart("General Initialize internals");

            foreach (ElementComponentCodeGenerator codeGenerator in CodeGenerators)
            {
                codeGenerator.GenerateInitialize(codeBlock, saveObject);
            }




            foreach (ElementComponentCodeGenerator codeGenerator in CodeGenerators)
            {
                codeGenerator.GenerateInitializeLate(codeBlock, saveObject);
            }

            if (saveObject is ScreenSave)
            {
                ScreenSave asScreenSave = saveObject as ScreenSave;
                codeBlock._();

                if (asScreenSave.IsRequiredAtStartup)
                {
                    string startupScreen = ProjectManager.StartUpScreen;

                    string qualifiedName = ProjectManager.ProjectNamespace + "." + startupScreen.Replace("\\", ".");

                    codeBlock.Line(string.Format("this.NextScreen = typeof({0}).FullName;", qualifiedName));
                }

                if (asScreenSave.UseGlobalContent)
                {
                    // no need to do anything here because Screens are smart enough to know to not load if they
                    // are using global content
                }

                if (!string.IsNullOrEmpty(asScreenSave.NextScreen))
                {
                    string nameToUse = ProjectManager.ProjectNamespace + "." + asScreenSave.NextScreen.Replace("\\", ".");

                    codeBlock.Line(string.Format("this.NextScreen = typeof({0}).FullName;", nameToUse));
                }

            }











            codeBlock._();
            PerformancePluginCodeGenerator.GenerateEnd();

            #region PostInitializeCode

            PerformancePluginCodeGenerator.GenerateStart("Post Initialize");


            if (saveObject.InheritsFromElement() == false)
            {
                codeBlock.Line("PostInitialize();");
            }
            PerformancePluginCodeGenerator.GenerateEnd();

            #endregion

            PerformancePluginCodeGenerator.GenerateStart("Base.Initialize");


            InheritanceCodeWriter.Self.WriteBaseInitialize(saveObject, codeBlock);

            PerformancePluginCodeGenerator.GenerateEnd();

            // I think we want to set this after calling base.Initialize so that the base
//.........这里部分代码省略.........
开发者ID:GorillaOne,项目名称:FlatRedBall,代码行数:101,代码来源:CodeWriter.cs

示例4: GenerateUnloadStaticContent

        internal static ICodeBlock GenerateUnloadStaticContent(ICodeBlock codeBlock, IElement saveObject)
        {
            var currentBlock = codeBlock;

            #region Generate UnloadStaticContent

            // Vic says - originally the code would only
            // generate UnloadStaticContent for entities IF they had
            // static content.  Well, we want to simplify the interface 
            // so all entities will always generate this method.  That way
            // all Entities can just clone elements in the loaded data.

            if (saveObject is EntitySave)
            {
                currentBlock = currentBlock
                    .Function("UnloadStaticContent", "", Public: true, Static: true,
                              New: saveObject.InheritsFromElement(), Type: "void");

                // We only want to unload if this isn't using global content
                // If so, then unloading should be a no-op
                if (saveObject.UseGlobalContent == false)
                {

                    foreach (ElementComponentCodeGenerator codeGenerator in CodeWriter.CodeGenerators)
                    {
                        currentBlock = codeGenerator.GenerateUnloadStaticContent(currentBlock, saveObject);
                    }

                }
                else
                {
                    currentBlock.Line("// Intentionally left blank because this element uses global content, so it should never be unloaded");
                }


                // June 21, 2011
                // Previously elements
                // used to call the base
                // UnloadStaticContent, but
                // this is no longer needed now
                // because each Entity will add its
                // own call to UnloadStaticContent to
                // the given ContentManager.
                //if (DoesSaveObjectInherit)
                //{
                //    if (SaveObject is EntitySave)
                //    {
                //        string baseName = (SaveObject as EntitySave).BaseEntity;

                //        stringBuilder.AppendLine(tabs + FileManager.RemovePath(baseName) + ".UnloadStaticContent();");
                //        stringBuilder.AppendLine();
                //    }
                //}
            }

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

示例5: GenerateConvertToManuallyUpdated

        internal static void GenerateConvertToManuallyUpdated(ICodeBlock codeBlock, IElement saveObject, List<string[]> reusableEntireFileRfses)
        {
            bool hasBase = saveObject.InheritsFromElement();

            ICodeBlock currentBlock = codeBlock;

            currentBlock = currentBlock
                .Function("ConvertToManuallyUpdated", "", Public: true, Override: hasBase, Virtual: !hasBase,
                          Type: "void");

            if (hasBase)
            {
                currentBlock.Line("base.ConvertToManuallyUpdated();");
            }

            if (saveObject is EntitySave)
            {

                // It's possible that an Entity may be converted to ManuallyUpdated before
                // any Draw calls get made - this means that UpdateDependencies will never get called.
                // This should happen before the other manual updates are called so that everything is positioned
                // right when verts are created.
                currentBlock.Line("this.ForceUpdateDependenciesDeep();");

                if (saveObject.InheritsFromFrbType())
                {
                    AssetTypeInfo ati = AvailableAssetTypes.Self.GetAssetTypeFromRuntimeType(saveObject.BaseElement);

                    if (ati != null)
                    {
                        currentBlock.Line(ati.MakeManuallyUpdatedMethod + ";");
                    }
                }
                else
                {

                    // Convert the Entity itself to manually updated
                    currentBlock.Line("FlatRedBall.SpriteManager.ConvertToManuallyUpdated(this);");
                }
            }

            foreach (ReferencedFileSave rfs in saveObject.ReferencedFiles)
            {
                ReferencedFileSaveCodeGenerator.GenerateConvertToManuallyUpdated(currentBlock, rfs);
            }

            NamedObjectSaveCodeGenerator.WriteConvertToManuallyUpdated(currentBlock, saveObject, reusableEntireFileRfses);
        }
开发者ID:GorillaOne,项目名称:FlatRedBall,代码行数:48,代码来源:CodeWriter.cs

示例6: GenerateLoadStaticContent

        public static void GenerateLoadStaticContent(ICodeBlock codeBlock, IElement saveObject)
        {
            var curBlock = codeBlock;

            bool inheritsFromElement = saveObject.InheritsFromElement();

            curBlock = curBlock.Function(StringHelper.SpaceStrings(
                                                        "public",
                                                        "static",
                                                        inheritsFromElement ? "new" : null,
                                                        "void"),
                                         "LoadStaticContent",
                                         "string contentManagerName");


            PerformancePluginCodeGenerator.GenerateStart(saveObject, curBlock, "LoadStaticContent");

            curBlock.If("string.IsNullOrEmpty(contentManagerName)")
                .Line("throw new System.ArgumentException(\"contentManagerName cannot be empty or null\");")
                .End();

            #region Set the ContentManagerName ( do this BEFORE checking for IsStaticContentLoaded )

            if (saveObject is EntitySave)
            {
                if ((saveObject as EntitySave).UseGlobalContent)
                {
                    curBlock.Line("// Set to use global content");
                    curBlock.Line("contentManagerName = FlatRedBall.FlatRedBallServices.GlobalContentManager;");
                }
                curBlock.Line("ContentManagerName = contentManagerName;");
            }

            #endregion


            if (inheritsFromElement)
            {
                curBlock.Line(ProjectManager.ProjectNamespace + "." + saveObject.BaseElement.Replace("\\", ".")  + ".LoadStaticContent(contentManagerName);");
            }

            foreach (ElementComponentCodeGenerator codeGenerator in CodeGenerators
                .OrderBy(item=>(int)item.CodeLocation))
            {
                curBlock = codeGenerator.GenerateLoadStaticContent(curBlock, saveObject);
            }




            #region Register the unload for EntitySaves

            // Vic says - do we want this for Screens too?
            // I don't think we do because Screens can just null- out stuff in their Destroy method.  There's only one of them around at a time.

            if (saveObject is EntitySave)
            {
                if (!(saveObject as EntitySave).UseGlobalContent)
                {
                    var ifBlock = curBlock.If("registerUnload && ContentManagerName != FlatRedBall.FlatRedBallServices.GlobalContentManager");
                    ReferencedFileSaveCodeGenerator.AppendAddUnloadMethod(ifBlock, saveObject.Name);
                }
            }

            #endregion




            curBlock.Line("CustomLoadStaticContent(contentManagerName);");
            PerformancePluginCodeGenerator.GenerateEnd(saveObject, curBlock, "LoadStaticContent");
        }
开发者ID:GorillaOne,项目名称:FlatRedBall,代码行数:72,代码来源:CodeWriter.cs

示例7: GenerateAddToManagersBottomUp

        internal static void GenerateAddToManagersBottomUp(ICodeBlock codeBlock, IElement element, List<string[]> reusableEntireFileRfses)
        {
            bool isEntity = element is EntitySave;
            bool isScreen = element is ScreenSave;

            bool inheritsFromElement = element.InheritsFromElement();

            string layerArgs = "";

            if (isEntity)
            {
                layerArgs = "FlatRedBall.Graphics.Layer layerToAddTo";
            }

            var currentBlock = codeBlock;

            currentBlock = currentBlock
                .Function("AddToManagersBottomUp", layerArgs, Public: true, Override: inheritsFromElement,
                          Virtual: !inheritsFromElement, Type: "void");

            if (inheritsFromElement)
            {
                if (isEntity)
                {
                    currentBlock.Line("base.AddToManagersBottomUp(layerToAddTo);");
                }
                else
                {
                    currentBlock.Line("base.AddToManagersBottomUp();");
                }
            }

            if (isScreen && string.IsNullOrEmpty(element.BaseElement))
            {
                currentBlock.Line("CameraSetup.ResetCamera(SpriteManager.Camera);");
            }

            if (!element.InheritsFromElement())
            {
                currentBlock.Line("AssignCustomVariables(false);");
            }
        }
开发者ID:GorillaOne,项目名称:FlatRedBall,代码行数:42,代码来源:CodeWriter.cs

示例8: GeneratePostInitialize

        public static void GeneratePostInitialize(ICodeBlock codeBlock, IElement saveObject)
        {
            var currentBlock = codeBlock;
            bool inheritsFromElement = saveObject.InheritsFromElement();
            currentBlock = currentBlock
                .Function("PostInitialize", "", Public: true, Override: inheritsFromElement, Virtual: !inheritsFromElement, Type: "void");

            // PostInitialize may happen async - but setting Visible = true on a shape
            // adds it to the ShapeManager.  This is bad because:
            // 1.  It's not thread safe
            // 2.  Another Screen may be visible
            // 3.  The ScreenManager checks for the presence of objects in the managers after a Screen is destroyed.  An addition would (and has) cause a crash here
            currentBlock.Line("bool oldShapeManagerSuppressAdd = FlatRedBall.Math.Geometry.ShapeManager.SuppressAddingOnVisibilityTrue;");
            currentBlock.Line("FlatRedBall.Math.Geometry.ShapeManager.SuppressAddingOnVisibilityTrue = true;");


            // Events need to come first here
            // in case other generators set properties
            // that raise events.
            EventCodeGenerator.GeneratePostInitialize(currentBlock, saveObject);

            if (inheritsFromElement)
            {
                currentBlock.Line("base.PostInitialize();");
            }


            // Do attachments before setting any variables (which may call events)
            NamedObjectSaveCodeGenerator.GetPostInitializeForNamedObjectList(null, saveObject.NamedObjects, currentBlock, saveObject);

            // July 24, 2013
            // Victor Chelaru
            // Why do we initialize here in PostInitialize?  The variable gets set in AddToManagersBottomUp. 
            // I'm going to remove this to see if it causes problems:
            //for (int i = 0; i < saveObject.CustomVariables.Count; i++)
            //{
            //    CustomVariable customVariable = saveObject.CustomVariables[i];

            //    if (!IsCustomVariableAssignedInAddToManagers(customVariable, saveObject))
            //    {
            //        CustomVariableCodeGenerator.AppendAssignmentForCustomVariableInElement(currentBlock, customVariable, saveObject);
            //    }
            //}
            foreach (ElementComponentCodeGenerator codeGenerator in CodeGenerators
                .OrderBy(item => (int)item.CodeLocation))
            {
                currentBlock = codeGenerator.GeneratePostInitialize(currentBlock, saveObject);
            }
            foreach (ReferencedFileSave rfs in saveObject.ReferencedFiles)
            {
                AssetTypeInfo ati = rfs.GetAssetTypeInfo();

                if (!rfs.IsSharedStatic && ati != null && !string.IsNullOrEmpty(ati.PostInitializeCode))
                {
                    currentBlock.InsertBlock(ReferencedFileSaveCodeGenerator.GetPostInitializeForReferencedFile(rfs));
                }
            }
            currentBlock.Line("FlatRedBall.Math.Geometry.ShapeManager.SuppressAddingOnVisibilityTrue = oldShapeManagerSuppressAdd;");
        }
开发者ID:GorillaOne,项目名称:FlatRedBall,代码行数:59,代码来源:CodeWriter.cs

示例9: GenerateCode


//.........这里部分代码省略.........
                {
                    string relativeDirectory = FileManager.MakeRelative(directory);
                    relativeDirectory = relativeDirectory.Substring(0, relativeDirectory.Length - 1);
                    relativeDirectory = relativeDirectory.Replace('/', '.');

                    projectNamespace += "." + relativeDirectory;
                }
            }
            else if (element is ScreenSave)
            {
                projectNamespace += ".Screens";
            }

            string contentManagerName = element.UseGlobalContent ? "\"Global\"" : null;
            ScreenSave asScreenSave = element as ScreenSave;
            if (asScreenSave != null &&
                !string.IsNullOrEmpty(asScreenSave.ContentManagerMethod))
            {
                contentManagerName = asScreenSave.ContentManagerMethod;
            }

            var whatToInheritFrom = GetInheritance(element);
            CodeWriter.SetClassNameAndNamespace(
                projectNamespace,
                objectName,
                stringBuilder,
                !string.IsNullOrEmpty(contentManagerName),
                contentManagerName,
                whatToInheritFrom
                );

            #region Make Activity, Initialize, PostInitalize, and Destroy "override" if necessary

            if ( element.InheritsFromElement())
            {

                if (stringBuilder.Contains("virtual void Initialize"))
                {
                    stringBuilder.Replace("virtual void Initialize", "override void Initialize");
                }

                if (stringBuilder.Contains("virtual void Activity"))
                {
                    stringBuilder.Replace("virtual void Activity", "override void Activity");
                }

                if (stringBuilder.Contains("virtual void Destroy"))
                {
                    stringBuilder.Replace("virtual void Destroy", "override void Destroy");
                }
            }

            #endregion

            try
            {
                CodeWriter.GenerateUsings(stringBuilder, element);
            }
            catch (Exception e)
            {
                string stackTrace = e.StackTrace;

                throw new Exception("Error trying to generate using statements for " + element + "\n\n" + stackTrace, e);
            }

            #region Generate Fields
开发者ID:GorillaOne,项目名称:FlatRedBall,代码行数:67,代码来源:CodeWriter.cs

示例10: GenerateDestroy

        internal static ICodeBlock GenerateDestroy(IElement saveObject)
        {
            bool isScreen = saveObject is ScreenSave;
            ICodeBlock codeBlock = new CodeDocument(3);
            var currentBlock = codeBlock;

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

            // The Screen template already includes a call to base.Destroy
            if ( saveObject.InheritsFromEntity() )
            {
                currentBlock.Line("base.Destroy();");
            }

            #endregion


            #region If Entity, remove from managers (SpriteManager, GuiManager)

            if (saveObject is EntitySave)
            {
                if (saveObject.InheritsFromFrbType())
                {
                    AssetTypeInfo ati = AvailableAssetTypes.Self.GetAssetTypeFromRuntimeType(saveObject.BaseObject);

                    if (ati != null)
                    {
                        currentBlock.Line(ati.DestroyMethod + ";");
                    }
                }
                else if (! saveObject.InheritsFromElement())
                {
                    currentBlock.Line("FlatRedBall.SpriteManager.RemovePositionedObject(this);");
                }
                
                if ((saveObject as EntitySave).ImplementsIWindow && !(saveObject as EntitySave).GetInheritsFromIWindow())
                {
                    currentBlock.Line("FlatRedBall.Gui.GuiManager.RemoveWindow(this);");
                }

            }

            #endregion

            foreach (ElementComponentCodeGenerator codeGenerator in CodeWriter.CodeGenerators)
            {
                codeGenerator.GenerateDestroy(currentBlock, saveObject);
            }

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

示例11: GenerateAddThisEntityToManagers

        private static void GenerateAddThisEntityToManagers(IElement saveObject, ICodeBlock currentBlock)
        {
            bool isEntity = saveObject is EntitySave;
            if (isEntity)
            {
                PerformancePluginCodeGenerator.GenerateStart("Add this to managers");

                if (saveObject.InheritsFromFrbType())
                {
                    int m = 3;
                    AssetTypeInfo ati = AvailableAssetTypes.Self.GetAssetTypeFromRuntimeType(saveObject.BaseObject);

                    if (ati != null)
                    {
                        int addMethodIndex = 0;

                        var isContainerNos = saveObject.AllNamedObjects.FirstOrDefault(item => item.IsContainer);

                        if (isContainerNos != null && isContainerNos.IsZBuffered &&
                            (isContainerNos.SourceClassType == "Sprite" || isContainerNos.SourceClassType == "SpriteFrame"))
                        {
                            addMethodIndex = 1;
                        }


                        if (ati.LayeredAddToManagersMethod.Count != 0)
                        {
                            // just use the method as-is, because the template is already using "this"
                            currentBlock.Line(ati.LayeredAddToManagersMethod[addMethodIndex].Replace("mLayer", "layerToAddTo") + ";");
                        }
                        else if (ati.AddToManagersMethod.Count != 0)
                        {
                            currentBlock.Line(ati.AddToManagersMethod[addMethodIndex] + ";");
                        }
                    }
                }
                else if (!saveObject.InheritsFromElement())
                {
                    currentBlock.Line("FlatRedBall.SpriteManager.AddPositionedObject(this);");
                }


                IWindowCodeGenerator.TryGenerateAddToManagers(currentBlock, saveObject);

                PerformancePluginCodeGenerator.GenerateEnd();
            }
        }
开发者ID:GorillaOne,项目名称:FlatRedBall,代码行数:47,代码来源:CodeWriter.cs

示例12: LoadNamedObjects

        private void LoadNamedObjects(IElement elementSave)
        {
            if (elementSave == null)
            {
                throw new ArgumentNullException("Argument elementSave is null", "elementSave");
            }

            elementSave.UpdateCustomProperties();

            var layers = elementSave.AllNamedObjects.Where(item=>item.IsLayer);
            var entireFiles = elementSave.AllNamedObjects.Where(item => item.IsEntireFile);
            var everythingElse = elementSave.AllNamedObjects.Where(item => !item.IsLayer && !item.IsEntireFile);

            var ordered = layers.Concat(entireFiles).Concat(everythingElse);

            PositionedObjectList<ElementRuntime> listToPopulate = mContainedElements;
            PositionedObject parentElementRuntime = this;

            CreateNamedObjectElementRuntime(elementSave, CreationOptions.LayerProvidedByContainer, ordered.ToList(), listToPopulate, parentElementRuntime);

            LoadEmbeddedNamedObjects(elementSave, CreationOptions.LayerProvidedByContainer);

            if (elementSave.InheritsFromElement())
            {
                var elementSaveBaseElement = ObjectFinder.Self.GetIElement(elementSave.BaseElement);
                if (elementSaveBaseElement != null)
                {
                    LoadNamedObjects(elementSaveBaseElement);
                }
            }
        }
开发者ID:vchelaru,项目名称:FlatRedBall,代码行数:31,代码来源:ElementRuntime.cs


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