本文整理汇总了C#中FlatRedBall.Glue.SaveClasses.ReferencedFileSave.GetInstanceName方法的典型用法代码示例。如果您正苦于以下问题:C# ReferencedFileSave.GetInstanceName方法的具体用法?C# ReferencedFileSave.GetInstanceName怎么用?C# ReferencedFileSave.GetInstanceName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FlatRedBall.Glue.SaveClasses.ReferencedFileSave
的用法示例。
在下文中一共展示了ReferencedFileSave.GetInstanceName方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GenerateTimedEmit
public static void GenerateTimedEmit(ICodeBlock codeBlock, ReferencedFileSave rfs, IElement element)
{
if (rfs.LoadedAtRuntime && !rfs.LoadedOnlyWhenReferenced && (element is ScreenSave || rfs.IsSharedStatic == false)
&& !string.IsNullOrEmpty(rfs.Name) && FileManager.GetExtension(rfs.Name) == "emix")
{
codeBlock.Line(rfs.GetInstanceName() + ".TimedEmit();");
}
}
示例2: GenerateCsvDeserializationCode
private static void GenerateCsvDeserializationCode(ReferencedFileSave referencedFile, ICodeBlock codeBlock, string variableName, string fileName, LoadType loadType)
{
#region Get the typeName (type as a string)
string typeName;
if (FileManager.GetExtension(fileName) == "csv" || referencedFile.TreatAsCsv)
{
// The CustomClass interface keeps a name just as it appears in Glue, so we want to use
// the referencedFile.Name instead of the fileName because fileName will have "Content/" on it
// and this shouldn't be the case for XNA 4 games
typeName = CsvCodeGenerator.GetEntireGenericTypeForCsvFile(referencedFile);
}
else
{
typeName = "System.Collections.Generic.List<" + FileManager.RemovePath(FileManager.RemoveExtension(fileName)) + ">";
}
if (typeName.ToLower().EndsWith("file"))
{
typeName = typeName.Substring(0, typeName.Length - "file".Length);
}
#endregion
#region Apply the delimiter change
// Use the delimiter specified in Glue
var block = codeBlock.Block();
block.Line("// We put the { and } to limit the scope of oldDelimiter");
block.Line("char oldDelimiter = FlatRedBall.IO.Csv.CsvFileManager.Delimiter;");
char delimiterAsChar = referencedFile.CsvDelimiter.ToChar();
block.Line(@"FlatRedBall.IO.Csv.CsvFileManager.Delimiter = '" + delimiterAsChar + "';");
#endregion
string whatToLoadInto;
if (loadType == LoadType.CompleteLoad)
{
whatToLoadInto = "temporaryCsvObject";
block.Line(string.Format("{0} {1} = new {0}();", typeName, whatToLoadInto));
}
else
{
whatToLoadInto = referencedFile.GetInstanceName();
block.Line(string.Format("{0}.Clear();", whatToLoadInto));
}
#region Call CsvFileManager.CsvDeserializeList/Dictionary
if (referencedFile.CreatesDictionary)
{
string keyType;
string valueType;
CsvCodeGenerator.GetDictionaryTypes(referencedFile, out keyType, out valueType);
if (keyType == null)
{
System.Windows.Forms.MessageBox.Show("Could not find the key type for:\n\n" + referencedFile.Name + "\n\nYou need to mark one of the headers as required or not load this file as a dictionary.");
keyType = "UNKNOWN_TYPE";
}
// CsvFileManager.CsvDeserializeDictionary<string, CarData>("Content/CarData.csv", carDataDictionary);
block.Line(string.Format("FlatRedBall.IO.Csv.CsvFileManager.CsvDeserializeDictionary<{2}, {3}>(\"{0}\", {1});", ProjectBase.AccessContentDirectory + fileName,
whatToLoadInto, keyType, valueType));
}
else
{
string elementType = referencedFile.GetTypeForCsvFile();
block.Line(string.Format("FlatRedBall.IO.Csv.CsvFileManager.CsvDeserializeList(typeof({0}), \"{1}\", {2});",
elementType, ProjectBase.AccessContentDirectory + fileName, whatToLoadInto));
}
#endregion
block.Line("FlatRedBall.IO.Csv.CsvFileManager.Delimiter = oldDelimiter;");
if (loadType == LoadType.CompleteLoad)
{
block.Line(string.Format("{0} = temporaryCsvObject;", variableName));
}
}
示例3: AddCodeforFileLoad
private static void AddCodeforFileLoad(ReferencedFileSave referencedFile, ref ICodeBlock codeBlock,
bool loadsUsingGlobalContentManager, ref bool directives, bool isProjectSpecific,
ref string fileName, ProjectBase project, LoadType loadType, string containerName)
{
if (project != null)
{
if (ProjectManager.IsContent(fileName))
{
fileName = (ProjectManager.ContentProject.ContainedFilePrefix + fileName).ToLower();
}
if (isProjectSpecific)
{
if (directives == true)
{
codeBlock = codeBlock.End()
.Line("#elif " + project.PrecompilerDirective)
.CodeBlockIndented();
}
else
{
directives = true;
codeBlock = codeBlock
.Line("#if " + project.PrecompilerDirective)
.CodeBlockIndented();
}
}
else
{
if (directives == true)
{
codeBlock = codeBlock.End()
.Line("#else")
.CodeBlockIndented();
}
}
if (referencedFile.IsDatabaseForLocalizing)
{
GenerateCodeForLocalizationDatabase(referencedFile, codeBlock, fileName, loadType);
}
else
{
AssetTypeInfo ati = referencedFile.GetAssetTypeInfo();
// I think we can set the field rather than the property, and then Set() the MRE if necessary afterwards:
//string variableName = referencedFile.GetInstanceName();
string variableName = null;
if (NeedsFullProperty(referencedFile, containerName))
{
variableName = "m" + referencedFile.GetInstanceName();
}
else
{
variableName = referencedFile.GetInstanceName();
}
if (!referencedFile.IsCsvOrTreatedAsCsv && ati != null)
{
// If it's not a CSV, then we only support loading if the load type is complete
// I don't know if I'll want to change this (or if I can) in the future.
if (loadType == LoadType.CompleteLoad)
{
GenerateInitializationForAssetTypeInfoRfs(referencedFile, codeBlock, loadsUsingGlobalContentManager, variableName, fileName, ati, project);
}
}
else if(referencedFile.IsCsvOrTreatedAsCsv)
{
GenerateInitializationForCsvRfs(referencedFile, codeBlock, variableName, fileName, loadType);
}
}
NamedObjectSaveCodeGenerator.WriteTextSpecificInitialization(referencedFile, codeBlock);
}
}
示例4: AppendFieldOrPropertyForReferencedFile
public static void AppendFieldOrPropertyForReferencedFile(ICodeBlock codeBlock, ReferencedFileSave referencedFile,
string containerName, IElement element, string contentManagerName)
{
/////////////////////////////////////EARLY OUT//////////////////////////////////////////////
// If the referenced file is a database for localizing, it will just be stuffed right into the localization manager
if (!referencedFile.LoadedAtRuntime || referencedFile.IsDatabaseForLocalizing) return;
///////////////////////////////////END EARLY OUT/////////////////////////////////////////////
string fileName = referencedFile.Name;
string extension = FileManager.GetExtension(fileName);
AssetTypeInfo ati = referencedFile.GetAssetTypeInfo();
string variableName = referencedFile.GetInstanceName();
#region Get the typeName
string typeName = null;
if (ati != null && !referencedFile.TreatAsCsv && ati.QualifiedRuntimeTypeName.QualifiedType != null)
{
typeName = ati.QualifiedRuntimeTypeName.QualifiedType;
}
else if (extension == "csv" || referencedFile.TreatAsCsv)
{
typeName = CsvCodeGenerator.GetEntireGenericTypeForCsvFile(referencedFile);
}
#endregion
//////////////////////////////EARLY OUT///////////////////////////////////////
if (typeName == null) return;
///////////////////////////END EARLY OUT//////////////////////////////////////
AddIfConditionalSymbolIfNecesssary(codeBlock, referencedFile);
if (NeedsFullProperty(referencedFile, containerName))
{
AppendPropertyForReferencedFileSave(codeBlock, referencedFile, containerName, element, contentManagerName, ati, variableName, typeName);
}
else
{
if (containerName == ContentLoadWriter.GlobalContentContainerName)
{
// Global Content will always have the content as properties. This is so that you can switch between
// async and sync loading and not have to change reflection code
codeBlock.AutoProperty(variableName,
Public: referencedFile.HasPublicProperty,
// Should be protected so derived classes can access this
Protected: !referencedFile.HasPublicProperty,
Static: referencedFile.IsSharedStatic,
Type: typeName);
}
else
{
codeBlock.Line(StringHelper.Modifiers(
Public: referencedFile.HasPublicProperty,
// Should be protected so derived classes can access this
Protected: !referencedFile.HasPublicProperty,
Static: referencedFile.IsSharedStatic,
Type: typeName,
Name: variableName) + ";");
}
}
AddEndIfIfNecessary(codeBlock, referencedFile);
}
示例5: GenerateConvertToManuallyUpdated
public static void GenerateConvertToManuallyUpdated(ICodeBlock currentBlock, ReferencedFileSave rfs)
{
if (rfs.LoadedAtRuntime && !rfs.LoadedOnlyWhenReferenced)
{
AssetTypeInfo ati = rfs.GetAssetTypeInfo();
if (!rfs.IsSharedStatic && ati != null && !string.IsNullOrEmpty(ati.MakeManuallyUpdatedMethod))
{
AddIfConditionalSymbolIfNecesssary(currentBlock, rfs);
currentBlock.Line(ati.MakeManuallyUpdatedMethod.Replace("this", rfs.GetInstanceName()) + ";");
AddEndIfIfNecessary(currentBlock, rfs);
}
}
}
示例6: GetAddToManagersForReferencedFile
public static ICodeBlock GetAddToManagersForReferencedFile(IElement mSaveObject, ReferencedFileSave referencedFile)
{
bool shouldAddToManagers = GetIfShouldAddToManagers(mSaveObject, referencedFile);
ICodeBlock codeBlock = new CodeDocument(3);
// We don't want to add shared static stuff to the manager - it's just used to pull and clone objects out of.
// Update September 12, 2012
// We actually do want to add
// static objects if they are part
// of a Screen.
if (shouldAddToManagers)
{
ICodeBlock currentBlock = codeBlock;
AssetTypeInfo ati = referencedFile.GetAssetTypeInfo();
string fileName = referencedFile.Name;
AddIfConditionalSymbolIfNecesssary(codeBlock, referencedFile);
string typeName = ati.RuntimeTypeName;
string variableName = referencedFile.GetInstanceName();
if (BaseElementTreeNode.IsOnOwnLayer(mSaveObject) && ati.LayeredAddToManagersMethod.Count != 0 && !string.IsNullOrEmpty(ati.LayeredAddToManagersMethod[0]))
{
string layerAddToManagersMethod = ati.LayeredAddToManagersMethod[0];
if (mSaveObject is EntitySave)
{
layerAddToManagersMethod = layerAddToManagersMethod.Replace("mLayer", "layerToAddTo");
}
currentBlock.Line(layerAddToManagersMethod.Replace("this", variableName) + ";");
}
else if (ati.LayeredAddToManagersMethod.Count != 0 && !string.IsNullOrEmpty(ati.LayeredAddToManagersMethod[0]) && mSaveObject is ScreenSave)
{
string layerAddToManagersMethod = ati.LayeredAddToManagersMethod[0];
// The Screen has an mLayer
//layerAddToManagersMethod = layerAddToManagersMethod.Replace("mLayer", "layerToAddTo");
currentBlock.Line(layerAddToManagersMethod.Replace("this", variableName) + ";");
}
else
{
currentBlock.Line(ati.AddToManagersMethod[0].Replace("this", variableName) + ";");
}
if (referencedFile.IsManuallyUpdated && !string.IsNullOrEmpty(ati.MakeManuallyUpdatedMethod))
{
currentBlock.Line(ati.MakeManuallyUpdatedMethod.Replace("this", variableName) + ";");
}
AddEndIfIfNecessary(codeBlock, referencedFile);
}
return codeBlock;
}
示例7: 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));
}
}
//.........这里部分代码省略.........
示例8: GetPostCustomActivityForReferencedFile
public static ICodeBlock GetPostCustomActivityForReferencedFile(ReferencedFileSave referencedFile)
{
ICodeBlock codeBlock = new CodeDocument();
if (!referencedFile.LoadedAtRuntime)
{
return codeBlock;
}
AssetTypeInfo ati = referencedFile.GetAssetTypeInfo();
// January 8, 2012
// This used to not
// check LoadedOnlyWhenReferenced
// but I think it should otherwise
// this code will always load Scenes
// that are LoadedOnlyWhenReferenced by
// calling their ManageAll method - so I
// added a check for LoadedOnlyWhenReferenced.
if (ati != null && !referencedFile.IsSharedStatic && !referencedFile.LoadedOnlyWhenReferenced && ati.AfterCustomActivityMethod != null)
{
AddIfConditionalSymbolIfNecesssary(codeBlock, referencedFile);
string variableName = referencedFile.GetInstanceName();
codeBlock.Line(ati.AfterCustomActivityMethod.Replace("this", variableName) + ";");
AddEndIfIfNecessary(codeBlock, referencedFile);
return codeBlock;
}
else
{
return codeBlock;
}
}
示例9: GetPostInitializeForReferencedFile
public static ICodeBlock GetPostInitializeForReferencedFile(ReferencedFileSave referencedFile)
{
AssetTypeInfo ati = referencedFile.GetAssetTypeInfo();
ICodeBlock codeBlock = new CodeDocument();
if (ati != null && !referencedFile.IsSharedStatic)
{
string variableName = referencedFile.GetInstanceName();
if (!string.IsNullOrEmpty(ati.PostInitializeCode))
{
codeBlock.Line(ati.PostInitializeCode.Replace("this", variableName) + ";");
}
}
return codeBlock;
}
示例10: GetActivityForReferencedFile
static ICodeBlock GetActivityForReferencedFile(ReferencedFileSave referencedFile, IElement element)
{
ICodeBlock codeBlock = new CodeDocument();
/////////////////////EARLY OUT/////////////////////////
if (!referencedFile.LoadedAtRuntime)
{
return codeBlock;
}
//////////////////END EARLY OUT//////////////////////
AssetTypeInfo ati = referencedFile.GetAssetTypeInfo();
// If it's an emitter, call TimedEmit:
ParticleCodeGenerator.GenerateTimedEmit(codeBlock, referencedFile, element);
if (ati != null && (!referencedFile.IsSharedStatic || element is ScreenSave )&& !referencedFile.LoadedOnlyWhenReferenced && ati.ActivityMethod != null)
{
AddIfConditionalSymbolIfNecesssary(codeBlock, referencedFile);
string variableName = referencedFile.GetInstanceName();
codeBlock.Line(ati.ActivityMethod.Replace("this", variableName) + ";");
AddEndIfIfNecessary(codeBlock, referencedFile);
return codeBlock;
}
else
{
return codeBlock;
}
}
示例11: WriteMethodForClone
private static string WriteMethodForClone(NamedObjectSave namedObject, ICodeBlock codeBlock,
List<string[]> referencedFilesAlreadyUsingFullFile, AssetTypeInfo nosAti, string objectName,
ReferencedFileSave rfs, IElement container, string containerName, string overridingName)
{
int lastParen = namedObject.SourceName.LastIndexOf(" (");
string nameOfSourceInContainer = namedObject.SourceName.Substring(0, lastParen);
// This could have a quote in the name. If so we want to escape it since this will be put in code:
nameOfSourceInContainer = nameOfSourceInContainer.Replace("\"", "\\\"");
string cloneString = ".Clone()";
string namedObjectToPullFrom = null;
foreach (string[] stringPair in referencedFilesAlreadyUsingFullFile)
{
if (rfs != null && stringPair[0] == rfs.Name && !namedObject.SourceName.StartsWith("Entire File ("))
{
namedObjectToPullFrom = stringPair[1];
break;
}
}
// September 30, 2012
// Now all files - whether
// they are part of an Entity
// or part of a Screen, are static.
// This means that the rfs.IsSharedStatic
// check will usually fail. However, Screens
// will still add to managers even for static
// object, so we want to make sure that we don't
// clone an object already added to managers, so we
// need the last check to see if the container is a ScreenSave.
if (nosAti == null || !nosAti.CanBeCloned || namedObjectToPullFrom != null || (rfs != null && rfs.IsSharedStatic == false) || container is ScreenSave)
{
cloneString = "";
}
if (nosAti != null && !string.IsNullOrEmpty(nosAti.CustomCloneMethod))
{
cloneString = nosAti.CustomCloneMethod;
}
AssetTypeInfo rfsAti = null;
if (rfs != null)
{
rfsAti = rfs.GetAssetTypeInfo();
}
bool usesFullConversion = false;
if (rfsAti != null && rfsAti.Conversion.Count != 0)
{
var foundConversion = rfsAti.Conversion.FirstOrDefault(item => item.ToType == namedObject.InstanceType);
if (foundConversion != null)
{
cloneString = foundConversion.ConversionPattern.Replace("{NEW}", objectName);
cloneString = cloneString.Replace("{THIS}", rfs.GetInstanceName());
usesFullConversion = true;
}
}
if (namedObjectToPullFrom != null)
{
containerName = namedObjectToPullFrom;
}
if (!string.IsNullOrEmpty(overridingName))
{
containerName = overridingName;
}
string listMemberName = ContentParser.GetMemberNameForList(FileManager.GetExtension(namedObject.SourceFile), namedObject.InstanceType);
if (!string.IsNullOrEmpty(listMemberName))
{
listMemberName += ".";
}
if (nameOfSourceInContainer == "Entire File" && string.IsNullOrEmpty(listMemberName))
{
if (usesFullConversion)
{
codeBlock.Line(cloneString + ";");
}
else if (cloneString.Contains("{THIS}"))
{
string entireString = cloneString.Replace("{THIS}", objectName);
entireString = entireString.Replace("{SOURCE_FILE}", containerName);
codeBlock.Line(entireString);
}
else
{
codeBlock.Line(string.Format("{0} = {1}{2};",
objectName,
containerName,
cloneString));
}
}
else
{
//.........这里部分代码省略.........
示例12: ResetVariablesReferencing
public static void ResetVariablesReferencing(this NamedObjectSave namedObject, ReferencedFileSave rfs)
{
for(int i = namedObject.InstructionSaves.Count - 1; i > -1 ; i--)
{
var variable = namedObject.InstructionSaves[i];
if (CustomVariableExtensionMethods.GetIsFile(variable.Type) && (string)(variable.Value) == rfs.GetInstanceName())
{
// We're going to make it null, but
// we don't save null instructions in
// NOS's so that our .glux stays small
// and so there's less chances of conflicts
// occurring because of undefined sorting behavior.
namedObject.InstructionSaves.RemoveAt(i);
}
}
}
示例13: GetReload
public static void GetReload(ReferencedFileSave referencedFile, IElement container,
ICodeBlock codeBlock, bool loadsUsingGlobalContentManager, LoadType loadType)
{
bool shouldGenerateInitialize = GetIfShouldGenerateInitialize(referencedFile);
if(shouldGenerateInitialize)
{
if(referencedFile.IsCsvOrTreatedAsCsv && referencedFile.CreatesDictionary)
{
var fileName = ProjectBase.AccessContentDirectory + referencedFile.Name.ToLower().Replace("\\", "/");
var instanceName = referencedFile.GetInstanceName();
string line =
$"FlatRedBall.IO.Csv.CsvFileManager.UpdateDictionaryValuesFromCsv({instanceName}, \"{fileName}\");";
codeBlock.Line(line);
}
else
{
GetInitializationForReferencedFile(referencedFile, container, codeBlock, loadsUsingGlobalContentManager, loadType);
}
}
}