本文整理汇总了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");
}
}
示例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);
}
示例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
+ ";");
}
}
}
}