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


C# NamedObjectSave.GetInstructionFromMember方法代码示例

本文整理汇总了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);
        }
开发者ID:vchelaru,项目名称:FlatRedBall,代码行数:15,代码来源:GluxCommands.cs

示例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;
        }
开发者ID:gitter-badger,项目名称:FlatRedBall,代码行数:99,代码来源:NamedObjectVariableShowingLogic.cs

示例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);

//.........这里部分代码省略.........
开发者ID:vchelaru,项目名称:FlatRedBall,代码行数:101,代码来源:NamedObjectVariableShowingLogic.cs

示例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;
        }
开发者ID:gitter-badger,项目名称:FlatRedBall,代码行数:49,代码来源:AvailableAnimationChainsStringConverter.cs


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