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


C# ICodeBlock.AutoProperty方法代码示例

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


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

示例1: GenerateIgnoresParentVisibility

 private void GenerateIgnoresParentVisibility(ICodeBlock codeBlock, EntitySave entitySave)
 {
     if (!entitySave.GetInheritsFromIVisible())
     {
         codeBlock.AutoProperty("public bool", "IgnoresParentVisibility");
     }
 }
开发者ID:vchelaru,项目名称:FlatRedBall,代码行数:7,代码来源:IVisibleCodeGenerator.cs

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

        }
开发者ID:gitter-badger,项目名称:FlatRedBall,代码行数:69,代码来源:ReferencedFileSaveCodeGenerator.cs

示例3: CreateNewVariableMember


//.........这里部分代码省略.........
            if (needsToBeProperty)
            {
                // If the variable
                // creates an event
                // then it needs to have
                // custom code (it can't be
                // an automatic property).
                bool isWholeNumberWithVelocity = IsVariableWholeNumberWithVelocity(customVariable);

                if (customVariable.CreatesEvent || isWholeNumberWithVelocity || customVariable.DefaultValue != null )
                {
                    string variableToAssignInProperty = "base." + customVariable.Name;
                    // create a field for this, unless it's defined by base - then the base creates a field for it
                    if (!isExposing && !customVariable.DefinedByBase)
                    {
                        variableToAssignInProperty = "m" + customVariable.Name;

                        // First we make the field that will get set here:
                        codeBlock.Line(StringHelper.Modifiers(Public: false, Static: customVariable.IsShared, Type: memberType, Name: variableToAssignInProperty) + variableAssignment + ";");
                    }

                    string propertyHeader = null;

                    if (isExposing)
                    {
                        propertyHeader = "public new " + memberType + " " + customVariable.Name;
                    }
                    else if (customVariable.DefinedByBase)
                    {
                        propertyHeader = "public override " + memberType + " " + customVariable.Name;
                    }
                    else if (customVariable.SetByDerived)
                    {
                        propertyHeader = "public virtual " + memberType + " " + customVariable.Name;
                    }
                    else
                    {
                        propertyHeader = "public " + memberType + " " + customVariable.Name;
                    }

                    ICodeBlock set = codeBlock.Property(propertyHeader, Static:customVariable.IsShared)
                        .Set();

                    if (EventCodeGenerator.ShouldGenerateEventsForVariable(customVariable, element))
                    {
                        EventCodeGenerator.GenerateEventRaisingCode(set, BeforeOrAfter.Before, customVariable.Name, element);
                    }

                    set.Line(variableToAssignInProperty + " = value;");
                    if (IsVariableWholeNumberWithVelocity(customVariable))
                    {
                        set.Line(customVariable.Name + "ModifiedByVelocity = value;");
                    }
                    if (EventCodeGenerator.ShouldGenerateEventsForVariable(customVariable, element))
                    {
                        EventCodeGenerator.GenerateEventRaisingCode(set, BeforeOrAfter.After, customVariable.Name, element);
                    }

                    ICodeBlock get = set.End().Get();

                    codeBlock = get.Line("return " + variableToAssignInProperty + ";")
                        .End().End(); // end the getter, end the property
                }
                else
                {
                    // Static vars can't be virtual
                    bool isVirtual = !customVariable.IsShared;
                    codeBlock.AutoProperty(customVariable.Name, Public: true, Virtual: isVirtual, Static: customVariable.IsShared, Type: memberType);
                }
            }
            else
            {
                if (!customVariable.GetIsVariableState())
                {


                    codeBlock.Line(StringHelper.Modifiers(Public: true, Static: customVariable.IsShared, Type: memberType, Name: customVariable.Name) + variableAssignment + ";");


                }
                else
                {
                    if (IsVariableTunnelingToDisabledObject(customVariable, element))
                    {
                        // If it's a varaible
                        // that is exposing a
                        // state variable for a
                        // disabled object, we still
                        // want to generate something:
                        codeBlock.Line(StringHelper.Modifiers(Public: true, Static: customVariable.IsShared, Type: memberType, Name: customVariable.Name)
                            // No assignment for now.  Do we eventually want this?  The reason
                            // this even exists is to satisfy a variable that may be needed by other
                            // code which would point to a disabled object.
                            //+ variableAssignment 
                            + ";");
                        
                    }
                }
            }
        }
开发者ID:vchelaru,项目名称:FlatRedBall,代码行数:101,代码来源:CustomVariableCodeGenerator.cs


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