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


C# ICodeBlock.Set方法代码示例

本文整理汇总了C#中ICodeBlock.Set方法的典型用法代码示例。如果您正苦于以下问题:C# ICodeBlock.Set方法的具体用法?C# ICodeBlock.Set怎么用?C# ICodeBlock.Set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ICodeBlock的用法示例。


在下文中一共展示了ICodeBlock.Set方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: WriteSetterForProperty

        private static void WriteSetterForProperty(IElement saveObject, CustomVariable customVariable, ICodeBlock prop, bool isVisibleSetterOnList)
        {
            var setter = prop.Set();

            if (EventCodeGenerator.ShouldGenerateEventsForVariable(customVariable, saveObject))
            {
                EventCodeGenerator.GenerateEventRaisingCode(setter, BeforeOrAfter.Before, customVariable.Name, saveObject);
            }

            NamedObjectSave nos = saveObject.GetNamedObjectRecursively(customVariable.SourceObject);

            bool addOrRemoveOnValueChange = nos.RemoveFromManagersWhenInvisible && customVariable.SourceObjectProperty == "Visible";

            if (isVisibleSetterOnList)
            {
                setter.Line(customVariable.SourceObject + ".SetVisible(value);");
            }
            else if(customVariable.GetIsSourceFile(saveObject))
            {
                // We need to assign the property here on the NamedObjectSave, as if it's done in code in the AddToManagersBottomUp

                // We need to temporarily make the NOS act as if it's using the argument file as its SourceFile
                var oldSourceType = nos.SourceType;
                var oldSourceFile = nos.SourceFile;
                var oldSourceName = nos.SourceName;
                nos.SourceType = SourceType.File;
                nos.SourceFile = "value";
                nos.SourceName = "Entire File (" + customVariable.Type  + ")";

                
                NamedObjectSaveCodeGenerator.WriteCodeForNamedObjectInitialize(nos, saveObject, setter, "value");//WriteAddToManagersForNamedObject(saveObject, nos, setter);

                bool storeOldValue = nos.RemoveFromManagersWhenInvisible && customVariable.SourceObjectProperty == "Visible";

                bool canBeLayered = false;
                if (nos.GetAssetTypeInfo() != null)
                {
                    canBeLayered = nos.GetAssetTypeInfo().LayeredAddToManagersMethod.Count != 0;
                }


                if (canBeLayered)
                {
                    // This object may be 
                    // added to a Layer.  We
                    // will add it to the NOS's
                    // Layer if there is one.  If 
                    // not, we'll use the object's
                    // Layer
                    string layerName;
                    if (!string.IsNullOrEmpty(nos.LayerOn))
                    {
                        layerName = nos.LayerOn;
                    }
                    else if (saveObject is EntitySave)
                    {
                        layerName = "LayerProvidedByContainer";
                    }
                    else
                    {
                        // I don't remember if Screens
                        // have a Layer that they use by
                        // default.  If so, this has probably
                        // fallen out of style because of Glue.
                        layerName = "null";
                    }

                    // Glue has no way of knowing whether this property will be used or not:
                    setter.Line("#pragma warning disable");
                    setter.Line("");
                    setter.Line("FlatRedBall.Graphics.Layer layerToAddTo = " + layerName + ";");
                    setter.Line("#pragma warning enable");
                    // Wow, so crazy, but the automated
                    // tests revealed that the line following
                    // the #pragma wasn't ever being run on iOS.
                    // I suspect it has to do with line endings after
                    // the #pragma line?  Anyway, putting a new line in
                    // seems to fix the bug.
                    setter.Line("");
                }

                NamedObjectSaveCodeGenerator.WriteAddToManagersForNamedObject(saveObject, nos, setter, true);

                nos.SourceType = oldSourceType;
                nos.SourceFile = oldSourceFile;
                nos.SourceName = oldSourceName;
            }
            else
            {

                string relativeVersionOfProperty = InstructionManager.GetRelativeForAbsolute(customVariable.SourceObjectProperty);
                if (!string.IsNullOrEmpty(relativeVersionOfProperty))
                {
                    setter = setter.If(customVariable.SourceObject + ".Parent == null");
                }

                string value = "value";

                if (!string.IsNullOrEmpty(customVariable.OverridingPropertyType) &&
                    // If the overriding type is the same as the variable type then no conversion can be performed
//.........这里部分代码省略.........
开发者ID:vchelaru,项目名称:FlatRedBall,代码行数:101,代码来源:CustomVariableCodeGenerator.cs


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