本文整理汇总了C#中FlatRedBall.Glue.SaveClasses.ReferencedFileSave.GetGeneratesMember方法的典型用法代码示例。如果您正苦于以下问题:C# ReferencedFileSave.GetGeneratesMember方法的具体用法?C# ReferencedFileSave.GetGeneratesMember怎么用?C# ReferencedFileSave.GetGeneratesMember使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FlatRedBall.Glue.SaveClasses.ReferencedFileSave
的用法示例。
在下文中一共展示了ReferencedFileSave.GetGeneratesMember方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetDestroyForReferencedFile
protected ICodeBlock GetDestroyForReferencedFile(IElement element, ReferencedFileSave referencedFile)
{
ICodeBlock codeBlock = new CodeDocument(3);
///////////////////////////////EARLY OUT///////////////////////
if (!referencedFile.LoadedAtRuntime || !referencedFile.DestroyOnUnload)
{
return codeBlock;
}
if (referencedFile.GetGeneratesMember() == false)
{
return codeBlock;
}
/////////////////////////////END EARLY OUT/////////////////////
AddIfConditionalSymbolIfNecesssary(codeBlock, referencedFile);
string fileName = referencedFile.Name;
AssetTypeInfo ati = referencedFile.GetAssetTypeInfo();
string variableName = referencedFile.GetInstanceName();
bool isScreenSave = element is ScreenSave;
if (referencedFile.LoadedOnlyWhenReferenced)
{
variableName = "m" + variableName;
codeBlock = codeBlock.If(variableName + " != null");
}
if (ati != null && (!referencedFile.IsSharedStatic || isScreenSave))
{
string typeName = ati.RuntimeTypeName;
string destroyMethod = ati.DestroyMethod;
string recycleMethod = ati.RecycledDestroyMethod;
if (string.IsNullOrEmpty(recycleMethod))
{
recycleMethod = destroyMethod;
}
if (!string.IsNullOrEmpty(ati.DestroyMethod))
{
if (isScreenSave && recycleMethod != destroyMethod)
{
codeBlock = codeBlock.If("this.UnloadsContentManagerWhenDestroyed && ContentManagerName != \"Global\"");
codeBlock.Line(destroyMethod.Replace("this", variableName) + ";");
if (referencedFile.LoadedOnlyWhenReferenced)
{
codeBlock = codeBlock.End().ElseIf(variableName + " != null");
}
else
{
codeBlock = codeBlock.End().Else();
}
codeBlock.Line(recycleMethod.Replace("this", variableName) + ";");
codeBlock = codeBlock.End();
}
else
{
codeBlock.Line(destroyMethod.Replace("this", variableName) + ";");
}
}
if (ati.ShouldBeDisposed && element.UseGlobalContent == false)
{
codeBlock = codeBlock.If("this.UnloadsContentManagerWhenDestroyed && ContentManagerName != \"Global\"");
codeBlock.Line(string.Format("{0}.Dispose();", variableName));
codeBlock = codeBlock.End();
}
}
if (element is ScreenSave && referencedFile.IsSharedStatic)
{
if (referencedFile.LoadedOnlyWhenReferenced)
{
variableName = "m" + referencedFile.GetInstanceName();
}
// We used to do this here, but we want to do it after all Objects have been destroyed
// because we may need to make the file one way before the destruction of the objects.
if (ati != null && ati.SupportsMakeOneWay)
{
codeBlock = codeBlock.If("this.UnloadsContentManagerWhenDestroyed && ContentManagerName != \"Global\"");
codeBlock.Line(string.Format("{0} = null;", variableName));
codeBlock = codeBlock.End().Else();
codeBlock.Line(string.Format("{0}.MakeOneWay();", variableName));
codeBlock = codeBlock.End();
}
else
{
codeBlock.Line(string.Format("{0} = null;", variableName));
}
}
//.........这里部分代码省略.........
示例2: GetInitializationForReferencedFile
public static void GetInitializationForReferencedFile(ReferencedFileSave referencedFile, IElement container,
ICodeBlock codeBlock, bool loadsUsingGlobalContentManager, LoadType loadType)
{
#region early-outs (not loaded at runtime, loaded only when referenced)
if (referencedFile.LoadedOnlyWhenReferenced)
{
return;// "";
}
if (referencedFile.IsDatabaseForLocalizing == false && !referencedFile.GetGeneratesMember())
{
return; // There is no qualified type to load to, so let's not generate code to load it
}
#endregion
// I'm going to only do this if we're non-null so that we don't add it for global content. Global Content may load
// async and cause bad data
if (container != null)
{
PerformancePluginCodeGenerator.GenerateStart(container, codeBlock, "LoadStaticContent" + FileManager.RemovePath(referencedFile.Name));
}
AddIfConditionalSymbolIfNecesssary(codeBlock, referencedFile);
bool directives = false;
for (int i = referencedFile.ProjectSpecificFiles.Count; i >= 0; i--)
{
bool isProjectSpecific = i != 0;
string fileName;
ProjectBase project;
if (isProjectSpecific)
{
fileName = referencedFile.ProjectSpecificFiles[i - 1].FilePath.ToLower().Replace("\\", "/");
// At one point
// the project specific
// files were platform specific
// but instead we want them to be
// based off of the project name instead.
// The reason for this is because a user could
// create a synced project that targets the same
// platform.
project = ProjectManager.GetProjectByName(referencedFile.ProjectSpecificFiles[i - 1].ProjectId);
if (project == null)
{
project = ProjectManager.GetProjectByTypeId(referencedFile.ProjectSpecificFiles[i - 1].ProjectId);
}
}
else
{
fileName = referencedFile.Name.ToLower().Replace("\\", "/");
project = ProjectManager.ProjectBase;
}
string containerName = ContentLoadWriter.GlobalContentContainerName;
if (container != null)
{
containerName = container.Name;
}
AddCodeforFileLoad(referencedFile, ref codeBlock, loadsUsingGlobalContentManager,
ref directives, isProjectSpecific, ref fileName, project, loadType, containerName);
}
if (directives == true)
{
codeBlock = codeBlock.End()
.Line("#endif");
}
AddEndIfIfNecessary(codeBlock, referencedFile);
// See above why this if-statement exists
if (container != null)
{
PerformancePluginCodeGenerator.GenerateEnd(container, codeBlock, "LoadStaticContent" + FileManager.RemovePath(referencedFile.Name));
}
}
示例3: GetIfShouldGenerateInitialize
private static bool GetIfShouldGenerateInitialize(ReferencedFileSave referencedFile)
{
bool shouldGenerateInitialize = true;
if (referencedFile.LoadedOnlyWhenReferenced)
{
shouldGenerateInitialize = false;
}
if (referencedFile.IsDatabaseForLocalizing == false && !referencedFile.GetGeneratesMember())
{
shouldGenerateInitialize = false; // There is no qualified type to load to, so let's not generate code to load it
}
if (referencedFile.IsDatabaseForLocalizing && !referencedFile.LoadedAtRuntime)
{
shouldGenerateInitialize = false;
}
return shouldGenerateInitialize;
}