本文整理汇总了C#中FlatRedBall.Glue.SaveClasses.NamedObjectSave.GetInstructionFromMember方法的典型用法代码示例。如果您正苦于以下问题:C# NamedObjectSave.GetInstructionFromMember方法的具体用法?C# NamedObjectSave.GetInstructionFromMember怎么用?C# NamedObjectSave.GetInstructionFromMember使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FlatRedBall.Glue.SaveClasses.NamedObjectSave
的用法示例。
在下文中一共展示了NamedObjectSave.GetInstructionFromMember方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetVariableOn
public void SetVariableOn(NamedObjectSave nos, string memberName, Type memberType, object value)
{
object oldValue = null;
var instruction = nos.GetInstructionFromMember(memberName);
if (instruction != null)
{
oldValue = instruction.Value;
}
NamedObjectPropertyGridDisplayer.SetVariableOn(nos, memberName, memberType, value);
PluginManager.ReactToChangedProperty(memberName, oldValue);
}
示例2: CreateInstanceMember
private static InstanceMember CreateInstanceMember(NamedObjectSave instance, IElement container, TypedMemberBase typedMember, AssetTypeInfo ati)
{
bool shouldBeSkipped = GetIfShouldBeSkipped(typedMember, instance, ati);
DataGridItem instanceMember = null;
if (!shouldBeSkipped)
{
var memberType = typedMember.MemberType;
VariableDefinition variableDefinition = null;
if (ati != null)
{
variableDefinition = ati.VariableDefinitions.FirstOrDefault(item => item.Name == typedMember.MemberName);
}
instanceMember = new DataGridItem();
instanceMember.FirstGridLength = new System.Windows.GridLength(140);
instanceMember.UnmodifiedVariableName = typedMember.MemberName;
string displayName = StringFunctions.InsertSpacesInCamelCaseString(typedMember.MemberName);
instanceMember.DisplayName = displayName;
instanceMember.TypeConverter = PluginManager.GetTypeConverter(
container, instance, typedMember);
instanceMember.CustomGetTypeEvent += (throwaway) => memberType;
instanceMember.IsDefault = instance.GetInstructionFromMember(typedMember.MemberName) == null;
instanceMember.CustomGetEvent += (throwaway) =>
{
var instruction = instance.GetInstructionFromMember(typedMember.MemberName);
if (instruction == null)
{
if (variableDefinition != null)
{
var toReturn = variableDefinition.DefaultValue;
if (memberType == typeof(bool))
{
bool boolToReturn = false;
bool.TryParse(variableDefinition.DefaultValue, out boolToReturn);
return boolToReturn;
}
else
{
return toReturn;
}
}
else
{
return null;
}
}
else
{
return instruction.Value;
}
};
instanceMember.CustomSetEvent += (owner, value) =>
{
instanceMember.IsDefault = false;
RefreshLogic.IgnoreNextRefresh();
GlueCommands.Self.GluxCommands.SetVariableOn(
instance,
typedMember.MemberName,
memberType,
value);
GlueCommands.Self.GluxCommands.SaveGlux();
GlueCommands.Self.RefreshCommands.RefreshPropertyGrid();
GlueCommands.Self.GenerateCodeCommands.GenerateCurrentElementCode();
};
instanceMember.IsDefaultSet += (owner, args) =>
{
MakeDefault(instance, typedMember.MemberName);
};
instanceMember.SetValueError += (newValue) =>
{
if (newValue is string && string.IsNullOrEmpty(newValue as string))
{
MakeDefault(instance, typedMember.MemberName);
}
};
}
return instanceMember;
}
示例3: CreateInstanceMember
private static InstanceMember CreateInstanceMember(NamedObjectSave instance, IElement container, TypedMemberBase typedMember, AssetTypeInfo ati)
{
bool shouldBeSkipped = GetIfShouldBeSkipped(typedMember, instance, ati);
DataGridItem instanceMember = null;
if (!shouldBeSkipped)
{
var typeConverter = PluginManager.GetTypeConverter(
container, instance, typedMember);
bool isObjectInFile = typeConverter is IObjectsInFileConverter;
var memberType = typedMember.MemberType;
VariableDefinition variableDefinition = null;
if (ati != null)
{
variableDefinition = ati.VariableDefinitions.FirstOrDefault(item => item.Name == typedMember.MemberName);
}
if(isObjectInFile)
{
var fileInstanceMember = new FileInstanceMember();
instanceMember = fileInstanceMember;
fileInstanceMember.View += () =>
{
var rfs = (typeConverter as IObjectsInFileConverter).ReferencedFileSave;
if (rfs != null)
{
var value = fileInstanceMember.Value as string;
GlueCommands.Self.SelectCommands.Select(
rfs,
value);
}
};
instanceMember.PreferredDisplayer = typeof(FileReferenceComboBox);
}
else
{
instanceMember = new DataGridItem();
}
instanceMember.FirstGridLength = new System.Windows.GridLength(140);
instanceMember.UnmodifiedVariableName = typedMember.MemberName;
string displayName = StringFunctions.InsertSpacesInCamelCaseString(typedMember.MemberName);
instanceMember.DisplayName = displayName;
instanceMember.TypeConverter = typeConverter;
instanceMember.CustomRefreshOptions += () =>
{
if (typeConverter != null)
{
instanceMember.CustomOptions.Clear();
var values = typeConverter.GetStandardValues();
foreach (var value in values)
{
instanceMember.CustomOptions.Add(value);
}
}
};
instanceMember.CustomGetTypeEvent += (throwaway) => memberType;
instanceMember.IsDefault = instance.GetInstructionFromMember(typedMember.MemberName) == null;
instanceMember.CustomGetEvent += (throwaway) =>
{
var instruction = instance.GetInstructionFromMember(typedMember.MemberName);
if (instruction == null)
{
if (variableDefinition != null)
{
var toReturn = variableDefinition.DefaultValue;
if (memberType == typeof(bool))
{
bool boolToReturn = false;
bool.TryParse(variableDefinition.DefaultValue, out boolToReturn);
//.........这里部分代码省略.........
示例4: GetReferencedAclsThroughSetVariables
private static AnimationChainListSave GetReferencedAclsThroughSetVariables(IElement element, NamedObjectSave referencedNos, StateSave stateSave)
{
AnimationChainListSave foundAcls = null;
// Give states the priority
if(stateSave != null)
{
foreach(var item in stateSave.InstructionSaves)
{
var customVariable = element.CustomVariables.FirstOrDefault(variable => variable.Name == item.Member);
if(customVariable != null && customVariable.SourceObject == referencedNos.InstanceName && customVariable.SourceObjectProperty == "AnimationChains")
{
string value = (string)item.Value;
foundAcls = LoadAnimationChainListSave(element, value);
}
}
}
if (foundAcls == null)
{
// Does this have a set AnimationChainList?
foreach (CustomVariable customVariable in element.CustomVariables)
{
if (customVariable.SourceObject == referencedNos.InstanceName && customVariable.SourceObjectProperty == "AnimationChains")
{
string value = (string)customVariable.DefaultValue;
foundAcls = LoadAnimationChainListSave(element, value);
}
}
}
// If the acls is null that means that it hasn't been set by custom variables, but the NOS itself may have a value set right on the Sprite for the current AnimationChain
if (foundAcls == null)
{
var instruction = referencedNos.GetInstructionFromMember("AnimationChains");
if (instruction != null)
{
foundAcls = LoadAnimationChainListSave(element, (string)instruction.Value);
}
}
return foundAcls;
}