本文整理汇总了C#中FlatRedBall.Glue.SaveClasses.NamedObjectSave.DoesMemberNeedToBeSetByContainer方法的典型用法代码示例。如果您正苦于以下问题:C# NamedObjectSave.DoesMemberNeedToBeSetByContainer方法的具体用法?C# NamedObjectSave.DoesMemberNeedToBeSetByContainer怎么用?C# NamedObjectSave.DoesMemberNeedToBeSetByContainer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FlatRedBall.Glue.SaveClasses.NamedObjectSave
的用法示例。
在下文中一共展示了NamedObjectSave.DoesMemberNeedToBeSetByContainer方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: HandleGetTypeConverter
private TypeConverter HandleGetTypeConverter(IElement container, NamedObjectSave instance, TypedMemberBase typedMember)
{
Type memberType = typedMember.MemberType;
string memberName = typedMember.MemberName;
TypeConverter typeConverter = null;
// If the NOS references a FRB type, we need to adjust the type appropriately
bool wasTypeModified = false;
Type oldType = memberType;
bool handled = false;
if (instance.SourceType == SourceType.FlatRedBallType)
{
Type type = TypeManager.GetTypeFromString(instance.SourceClassType);
if (type == typeof(Sprite) && memberName == "CurrentChainName")
{
// special case handling for CurrentChainName
typeConverter = new AvailableAnimationChainsStringConverter(container, instance);
handled = true;
}
// Victor Chelaru
// October 26, 2015:
// I don't think we need this anymore - we should just let the CSVs do their job
// defining variables and not rely on reflection. That way plugins will be able to
// handle everything without relying on reflection
//if (!handled && type != null)
//{
// FieldInfo fieldInfo = type.GetField(memberName);
// if (fieldInfo != null)
// {
// memberType = fieldInfo.FieldType;
// wasTypeModified = true;
// }
// if (wasTypeModified == false)
// {
// PropertyInfo propertyInfo = type.GetProperty(memberName);
// if (propertyInfo != null)
// {
// memberType = propertyInfo.PropertyType;
// wasTypeModified = true;
// }
// }
//}
}
else if (instance.SourceType == SourceType.File)
{
if (instance.ClassType == "Sprite" && memberName == "CurrentChainName")
{
// special case handling for CurrentChainName
typeConverter = new AvailableAnimationChainsStringConverter(container, instance);
handled = true;
}
}
if (!handled)
{
if (instance.DoesMemberNeedToBeSetByContainer(memberName))
{
typeConverter = new AvailableNamedObjectsAndFiles(container);
}
else if (memberType.IsEnum)
{
typeConverter = new EnumConverter(memberType);
}
else if (memberType == typeof(Microsoft.Xna.Framework.Color))
{
typeConverter = new AvailableColorTypeConverter();
memberType = typeof(string);
}
else if (IsTypeFile(typedMember))
{
AvailableFileStringConverter availableFileStringConverter = new AvailableFileStringConverter(container);
availableFileStringConverter.QualifiedRuntimeTypeName = memberType.FullName;
if(!string.IsNullOrEmpty( typedMember.CustomTypeName ))
{
availableFileStringConverter.QualifiedRuntimeTypeName = typedMember.CustomTypeName;
}
availableFileStringConverter.RemovePathAndExtension = true;
typeConverter = availableFileStringConverter;
memberType = typeof(string);
}
else if (instance.SourceType == SourceType.Entity && !string.IsNullOrEmpty(instance.SourceClassType))
{
//.........这里部分代码省略.........
示例2: AppendCustomVariableInInstanceStandard
private static void AppendCustomVariableInInstanceStandard(NamedObjectSave namedObject, ICodeBlock codeBlock, InstructionSave instructionSave, AssetTypeInfo ati)
{
object objectToParse = instructionSave.Value;
#region Determine the right-side value to assign
CustomVariable customVariable = null;
EntitySave entitySave = null;
if (namedObject.SourceType == SourceType.Entity && !string.IsNullOrEmpty(namedObject.SourceClassType))
{
entitySave = ObjectFinder.Self.GetEntitySave(namedObject.SourceClassType);
if (entitySave != null)
{
customVariable = entitySave.GetCustomVariable(instructionSave.Member);
}
}
IElement rootElementForVariable = entitySave;
string rootVariable = instructionSave.Member;
while (customVariable != null && customVariable.IsTunneling)
{
NamedObjectSave referencedNamedObject = rootElementForVariable.GetNamedObjectRecursively(customVariable.SourceObject);
if (referencedNamedObject != null && referencedNamedObject.IsFullyDefined && referencedNamedObject.SourceType == SourceType.Entity)
{
rootElementForVariable = ObjectFinder.Self.GetIElement(referencedNamedObject.SourceClassType);
rootVariable = customVariable.SourceObjectProperty;
customVariable = rootElementForVariable.GetCustomVariable(customVariable.SourceObjectProperty);
}
else
{
break;
}
}
string value = CodeParser.ParseObjectValue(objectToParse);
if (CustomVariableExtensionMethods.GetIsFile(instructionSave.Type))
{
value = value.Replace("\"", "").Replace("-", "_");
if (value == "<NONE>")
{
value = "null";
}
}
else if (ShouldAssignToCsv(customVariable, value))
{
value = GetAssignmentToCsvItem(customVariable, entitySave, value);
}
else if (instructionSave.Type == "Color")
{
value = "Color." + value.Replace("\"", "");
}
else if ((customVariable != null && customVariable.GetIsVariableState()) || (customVariable == null && rootVariable == "CurrentState"))
{
//string type = "VariableState";
//if (customVariable != null && customVariable.Type.ToLower() != "string")
//{
// type = customVariable.Type;
//}
value = StateCodeGenerator.GetRightSideAssignmentValueAsString(entitySave, instructionSave);
}
else
{
value = CodeWriter.MakeLocalizedIfNecessary(namedObject, instructionSave.Member, objectToParse, value, null);
}
if (namedObject.DoesMemberNeedToBeSetByContainer(instructionSave.Member))
{
value = value.Replace("\"", "");
}
#endregion
string leftSideMember = instructionSave.Member;
bool makeRelative = !string.IsNullOrEmpty(InstructionManager.GetRelativeForAbsolute(leftSideMember));
if (makeRelative)
{
if (ati != null)
{
// If it can't attach, then don't try to set relative values
makeRelative &= ati.ShouldAttach;
}
}
var objectName = namedObject.InstanceName;
if (makeRelative)
{
codeBlock = codeBlock.If(objectName + ".Parent == null");
}
bool needsEndif = false;
if (value.StartsWith("FlatRedBall.Graphics.ColorOperation."))
//.........这里部分代码省略.........