本文整理汇总了C#中IEntity.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# IEntity.ToString方法的具体用法?C# IEntity.ToString怎么用?C# IEntity.ToString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IEntity
的用法示例。
在下文中一共展示了IEntity.ToString方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetMemberText
static string GetMemberText(IAmbience ambience, IEntity member)
{
StringBuilder text = new StringBuilder();
if (member is IField) {
text.Append(ambience.Convert(member as IField));
} else if (member is IProperty) {
text.Append(ambience.Convert(member as IProperty));
} else if (member is IEvent) {
text.Append(ambience.Convert(member as IEvent));
} else if (member is IMethod) {
text.Append(ambience.Convert(member as IMethod));
} else if (member is IClass) {
text.Append(ambience.Convert(member as IClass));
} else {
text.Append("unknown member ");
text.Append(member.ToString());
}
string documentation = member.Documentation;
if (documentation != null && documentation.Length > 0) {
text.Append('\n');
text.Append(CodeCompletionData.XmlDocumentationToText(documentation));
}
return text.ToString();
}
示例2: Convert
public virtual string Convert(IEntity entity)
{
if (entity == null)
throw new ArgumentNullException("entity");
IClass c = entity as IClass;
if (c != null)
return Convert(c);
IMethod m = entity as IMethod;
if (m != null)
return Convert(m);
IField f = entity as IField;
if (f != null)
return Convert(f);
IProperty p = entity as IProperty;
if (p != null)
return Convert(p);
IEvent e = entity as IEvent;
if (e != null)
return Convert(e);
return entity.ToString();
}
示例3: GetText
/// <summary>
/// Converts a member to text.
/// Returns the declaration of the member as C# or VB code, e.g.
/// "public void MemberName(string parameter)"
/// </summary>
private static string GetText(IEntity entity)
{
IAmbience ambience = MainForm.IsVisualBasic ? (IAmbience)vbAmbience : csharpAmbience;
if (entity is IMethod)
return ambience.Convert(entity as IMethod);
if (entity is IProperty)
return ambience.Convert(entity as IProperty);
if (entity is IEvent)
return ambience.Convert(entity as IEvent);
if (entity is IField)
return ambience.Convert(entity as IField);
if (entity is IClass)
return ambience.Convert(entity as IClass);
// unknown entity:
return entity.ToString();
}
示例4: GetText
string GetText(IEntity entity)
{
return o2CodeCompletion.TextEditor.invokeOnThread(
()=> {
IAmbience ambience = csharpAmbience;
if (entity is IMethod)
return ambience.Convert(entity as IMethod);
if (entity is IProperty)
return ambience.Convert(entity as IProperty);
if (entity is IEvent)
return ambience.Convert(entity as IEvent);
if (entity is IField)
return ambience.Convert(entity as IField);
if (entity is IClass)
return ambience.Convert(entity as IClass);
// unknown entity:
return entity.ToString();
});
}
示例5: AssertParameters
bool AssertParameters(Node sourceNode, IEntity sourceEntity, ICallableType method, ExpressionCollection args)
{
if (CheckParameters(method, args, true))
return true;
if (IsLikelyMacroExtensionMethodInvocation(sourceNode, sourceEntity, args))
Error(CompilerErrorFactory.MacroExpansionError(sourceNode));
else
Error(CompilerErrorFactory.MethodSignature(sourceNode, sourceEntity.ToString(), GetSignature(args)));
return false;
}
示例6: GetText
/// <summary>
/// Converts a member to text.
/// Returns the declaration of the member as C# or VB code, e.g.
/// "public void MemberName(string parameter)"
/// </summary>
static string GetText(IEntity entity)
{
IAmbience ambience = IntellisenseForm.SupportedLanguage == ESupportedLanguage.VisualBasic ? (IAmbience)new VBNetAmbience() : new CSharpAmbience();
if (entity is IMethod)
return ambience.Convert(entity as IMethod);
if (entity is IProperty)
return ambience.Convert(entity as IProperty);
if (entity is IEvent)
return ambience.Convert(entity as IEvent);
if (entity is IField)
return ambience.Convert(entity as IField);
if (entity is IClass)
return ambience.Convert(entity as IClass);
// unknown entity:
return entity.ToString();
}
示例7: GetMemberText
static string GetMemberText(IAmbience ambience, IEntity member, string expression, out bool debuggerCanShowValue)
{
bool tryDisplayValue = false;
debuggerCanShowValue = false;
StringBuilder text = new StringBuilder();
if (member is IField) {
text.Append(ambience.Convert(member as IField));
tryDisplayValue = true;
} else if (member is IProperty) {
text.Append(ambience.Convert(member as IProperty));
tryDisplayValue = true;
} else if (member is IEvent) {
text.Append(ambience.Convert(member as IEvent));
} else if (member is IMethod) {
text.Append(ambience.Convert(member as IMethod));
} else if (member is IClass) {
text.Append(ambience.Convert(member as IClass));
} else {
text.Append("unknown member ");
text.Append(member.ToString());
}
if (tryDisplayValue && currentDebugger != null) {
LoggingService.Info("asking debugger for value of '" + expression + "'");
string currentValue = currentDebugger.GetValueAsString(expression);
if (currentValue != null) {
debuggerCanShowValue = true;
text.Append(" = ");
text.Append(currentValue);
}
}
string documentation = member.Documentation;
if (documentation != null && documentation.Length > 0) {
text.Append('\n');
text.Append(ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor.CodeCompletionData.ConvertDocumentation(documentation));
}
return text.ToString();
}
示例8: UnsafeVisit
public JsNode UnsafeVisit(IEntity me)
{
if (CompilerConfiguration.Current.EnableLogging)
{
Log.Debug("JsTypeImporter: Visit Entity: " + me.ToString());
}
if (BeforeVisitEntity != null)
BeforeVisitEntity(me);
JsNode node2 = null;
switch (me.SymbolKind)
{
#region switch case
//case EntityType.ent_anonymous_method:
// node2 = _Visit((CsEntityAnonymousMethod)me); break;
//case EntityType.ent_block:
// node2 = _Visit((CsEntityBlock)me); break;
//case EntityType.ent_block_variable:
// node2 = _Visit((CsEntityBlockVariable)me); break;
case SymbolKind.TypeDefinition:
node2 = _Visit((ITypeDefinition)me); break;
//case EntityType.ent_constant:
// node2 = _Visit((IConst)me); break;
//case EntityType.ent_delegate:
// node2 = _Visit((IDelegate)me); break;
//case EntityType.ent_enum:
// node2 = _Visit((CsEntityEnum)me); break;
case SymbolKind.Event:
node2 = _Visit((IEvent)me); break;
//case EntityType.ent_formal_parameter:
// node2 = _Visit((CsEntityFormalParameter)me); break;
//case EntityType.ent_generic_param:
// node2 = _Visit((CsEntityGenericParam)me); break;
//case EntityType.Interface:
// node2 = _Visit((IInterface)me); break;
//case EntityType.ent_local_constant:
// node2 = _Visit((CsEntityLocalConstant)me); break;
//case EntityType.ent_local_variable:
// node2 = _Visit((CsEntityLocalVariable)me); break;
case SymbolKind.Method:
case SymbolKind.Constructor:
case SymbolKind.Operator:
case SymbolKind.Accessor:
node2 = _Visit((IMethod)me); break;
//case EntityType.ent_namespace:
// node2 = _Visit((CsEntityNamespace)me); break;
case SymbolKind.Property:
case SymbolKind.Indexer:
node2 = _Visit((IProperty)me); break;
//case EntityType.ent_struct:
// node2 = _Visit((IStruct)me); break;
case SymbolKind.Field:
node2 = _Visit((IField)me); break;
#endregion
}
if (AfterVisitEntity != null)
AfterVisitEntity(me, node2);
return node2;
}
示例9: AssertParameters
bool AssertParameters(Node sourceNode, IEntity sourceEntity, ICallableType method, ExpressionCollection args)
{
if (CheckParameters(method, args, true)) return true;
Error(CompilerErrorFactory.MethodSignature(sourceNode, sourceEntity.ToString(), GetSignature(args)));
return false;
}
示例10: GetOtherEntity
/// <summary>
/// Gets the entity in the reference that wasn't provided. Hence the "other" entity.
/// </summary>
/// <param name="entity"></param>
/// <returns></returns>
public IEntity GetOtherEntity(IEntity entity)
{
IEntity otherEntity = null;
//using (LogGroup logGroup = LogGroup.Start("Retrieving the entity from the reference that is not the one provided (ie. the other entity).", NLog.LogLevel.Debug))
//{
if (entity == null)
throw new ArgumentNullException("entity");
if (referenceEntity == null)
throw new InvalidOperationException("The referenced entity is null.");
if (sourceEntity == null)
throw new InvalidOperationException("The source entity is null.");
if (referenceEntity.ID == entity.ID)
otherEntity = sourceEntity;
else if (sourceEntity.ID == entity.ID)
otherEntity = referenceEntity;
else
throw new InvalidOperationException("Can't get the other entity. Neither entity matches.\nParameter entity type: " + entity.ToString() + "\nParameter entity ID: " + entity.ID.ToString() + "\nEntity #1 type: " + Type1Name + "\nEntity #2 type: " + Type2Name + "\nProperty #1 type: " + Property1Name + "\nProperty #2 type: " + Property2Name + "\nEntity #1 ID: " + Entity1ID.ToString() + "\nEntity #2 ID: " + Entity2ID.ToString());
//LogWriter.Debug("Other entity type: " + otherEntity.GetType().ToString());
//LogWriter.Debug("Other entity ID: " + otherEntity.ID.ToString());
//}
return otherEntity;
}
示例11: EntityNotAvailableException
public EntityNotAvailableException(IEntity entity)
: base(string.Format(CultureInfo.CurrentCulture, MathNet.Symbolics.Properties.Resources.ex_NotAvailable_Entity, (entity == null ? "N/A" : entity.ToString())))
{
_entity = entity;
}
示例12: CreateFriendlyUrl
/// <summary>
/// Creates a friendly URL to the page corresponding with the specified action and specified type.
/// </summary>
/// <param name="action">The action to be performed at the target page.</param>
/// <param name="typeName">The name of the type being acted upon at the target page.</param>
/// <param name="propertyName">The name of the property to filter the type by.</param>
/// <param name="entity">The entity to link to.</param>
/// <returns>The URL to the page handling the provided action in relation to the provided type.</returns>
public string CreateFriendlyUrl(string action, IEntity entity)
{
string link = String.Empty;
using (LogGroup logGroup = LogGroup.StartDebug("Creating a friendly URL for the specified action and provided entity type."))
{
if (entity == null)
throw new ArgumentNullException("entity");
LogWriter.Debug("Action: " + action);
LogWriter.Debug("Entity type: " + entity.ShortTypeName);
link = ApplicationPath
+ "/" + PrepareForUrl(action)
+ "-" + PrepareForUrl(entity.ShortTypeName);
link = link + "/" + entity.ID.ToString();
if (entity.ToString() != entity.GetType().FullName)
link = link + "/" + PrepareForUrl(Utilities.Summarize(entity.ToString(), 80));
link = link + ".aspx";
link = AddResult(link);
LogWriter.Debug("Link: " + link);
}
return link;
}
示例13: Authorise
public override IEntity Authorise(IEntity toEntity)
{
IEntity authorisedEntity = null;
using (LogGroup logGroup = LogGroup.StartDebug("Authorising the creation of a reference on the '" + SourceProperty + "' property of the '" + SourceEntity.ShortTypeName + "' type to referenced entity '" + toEntity.ToString() + "' of type '" + toEntity.ShortTypeName + "'."))
{
if (IsAuthorised(toEntity))
{
LogWriter.Debug("Entity IS authorised.");
authorisedEntity = toEntity;
}
else
LogWriter.Debug("Entity is NOT authorised.");
}
return authorisedEntity;
}
示例14: GetText
/// <summary>
/// Converts a member to text.
/// Returns the declaration of the member as C# or VB code, e.g.
/// "public void MemberName(string parameter)"
/// </summary>
static string GetText(IEntity entity)
{
IAmbience ambience = csharpAmbience;
if (entity is IMethod)
return ambience.Convert(entity as IMethod);
if (entity is IProperty)
return ambience.Convert(entity as IProperty);
if (entity is IEvent)
return ambience.Convert(entity as IEvent);
if (entity is IField)
return ambience.Convert(entity as IField);
if (entity is IClass)
return ambience.Convert(entity as IClass);
// unknown entity:
return entity.ToString();
}