本文整理汇总了C#中IReference类的典型用法代码示例。如果您正苦于以下问题:C# IReference类的具体用法?C# IReference怎么用?C# IReference使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IReference类属于命名空间,在下文中一共展示了IReference类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PrintAttribute
public virtual void PrintAttribute(IReference target, ICustomAttribute attribute, bool newLine, string targetType) {
this.sourceEmitterOutput.Write("[", newLine);
if (targetType != null) {
this.sourceEmitterOutput.Write(targetType);
this.sourceEmitterOutput.Write(": ");
}
this.PrintTypeReferenceName(attribute.Constructor.ContainingType);
if (attribute.NumberOfNamedArguments > 0 || IteratorHelper.EnumerableIsNotEmpty(attribute.Arguments)) {
this.sourceEmitterOutput.Write("(");
bool first = true;
foreach (var argument in attribute.Arguments) {
if (first)
first = false;
else
this.sourceEmitterOutput.Write(", ");
this.Traverse(argument);
}
foreach (var namedArgument in attribute.NamedArguments) {
if (first)
first = false;
else
this.sourceEmitterOutput.Write(", ");
this.Traverse(namedArgument);
}
this.sourceEmitterOutput.Write(")");
}
this.sourceEmitterOutput.Write("]");
if (newLine) this.sourceEmitterOutput.WriteLine("");
}
示例2: ObjectContent
public ObjectContent(object value, ITypeDescriptor descriptor, bool isPrimitive, IReference reference)
: base(descriptor, isPrimitive, reference)
{
if (reference is ObjectReference)
throw new ArgumentException($"An {nameof(ObjectContent)} cannot contain an {nameof(ObjectReference)}");
this.value = value;
}
示例3: GetReferences
public IReference[] GetReferences(ITreeNode element, IReference[] oldReferences)
{
var literal = element as ILiteralExpression;
if (literal != null && literal.ConstantValue.Value is string)
{
var agument = literal.Parent as IVBArgument;
var attribute = AttributeNavigator.GetByArgument(agument);
if (attribute != null)
{
var @class = attribute.AttributeType.Reference.Resolve().DeclaredElement as IClass;
if (@class != null && Equals(@class.GetClrName(), DataAttributeName))
{
var typeElement = (from a in attribute.Arguments
where a is INamedArgument && a.ArgumentName == TypeMemberName
select GetTypeof(a.Expression as IGetTypeExpression)).FirstOrDefault();
var member = MethodDeclarationNavigator.GetByAttribute(attribute) as ITypeMemberDeclaration;
if (member != null && member.DeclaredElement != null && typeElement == null)
typeElement = member.DeclaredElement.GetContainingType();
if (typeElement == null)
return EmptyArray<IReference>.Instance;
var reference = CreateReference(typeElement, literal);
return oldReferences != null && oldReferences.Length == 1 && Equals(oldReferences[0], reference)
? oldReferences
: new[] { reference };
}
}
}
return EmptyArray<IReference>.Instance;
}
示例4: GetPrimaryDeclaredElement
public IDeclaredElement GetPrimaryDeclaredElement(IDeclaredElement declaredElement, IReference reference)
{
IDeclaredElement derivedElement = null;
var method = declaredElement as IMethod;
if (method != null)
{
derivedElement = DerivedDeclaredElementUtil.GetPrimaryDeclaredElementForMethod(method);
}
var @class = declaredElement as IClass;
if (@class != null)
derivedElement = DerivedDeclaredElementUtil.GetPrimaryDeclaredElementForClass(@class);
var @interface = declaredElement as IInterface;
if (@interface != null)
derivedElement = DerivedDeclaredElementUtil.GetPrimaryDeclaredElementForInterface(@interface);
if(derivedElement != null)
{
return derivedElement;
}
return declaredElement;
}
示例5: GetReferences
public IReference[] GetReferences(ITreeNode element, IReference[] oldReferences)
{
var literal = element as ILiteralExpression;
if (literal != null && literal.ConstantValue.Value is string)
{
var attribute = AttributeNavigator.GetByConstructorArgumentExpression(literal as ICSharpExpression);
if (attribute != null)
{
var @class = attribute.Name.Reference.Resolve().DeclaredElement as IClass;
if (@class != null && Equals(@class.GetClrName(), DataAttributeName))
{
var typeElement = (from a in attribute.PropertyAssignments
where a.PropertyNameIdentifier.Name == TypeMemberName
select GetTypeof(a.Source as ITypeofExpression)).FirstOrDefault();
var member = MethodDeclarationNavigator.GetByAttribute(attribute);
if (member != null && member.DeclaredElement != null && typeElement == null)
typeElement = member.DeclaredElement.GetContainingType();
if (typeElement == null)
return EmptyArray<IReference>.Instance;
var reference = CreateReference(typeElement, literal);
return oldReferences != null && oldReferences.Length == 1 && Equals(oldReferences[0], reference)
? oldReferences
: new[] {reference};
}
}
}
return EmptyArray<IReference>.Instance;
}
示例6: VisitMethodBodyReference
public void VisitMethodBodyReference(IReference reference)
{
var typeReference = reference as ITypeReference;
if (typeReference != null)
{
this.typeReferenceNeedsToken = true;
this.Visit(typeReference);
Debug.Assert(!this.typeReferenceNeedsToken);
}
else
{
var fieldReference = reference as IFieldReference;
if (fieldReference != null)
{
if (fieldReference.IsContextualNamedEntity)
{
((IContextualNamedEntity)fieldReference).AssociateWithMetadataWriter(this.metadataWriter);
}
this.Visit(fieldReference);
}
else
{
var methodReference = reference as IMethodReference;
if (methodReference != null)
{
this.Visit(methodReference);
}
}
}
}
示例7: CheckResolve
protected override bool CheckResolve(IReference reference, IElement element)
{
if (reference is TableReference && !DatabaseManager.GetInstance(element.GetManager().Solution).Enabled)
return false;
return base.CheckResolve(reference, element);
}
示例8: ContentBase
protected ContentBase(ITypeDescriptor descriptor, bool isPrimitive, IReference reference)
{
if (descriptor == null) throw new ArgumentNullException(nameof(descriptor));
Reference = reference;
Descriptor = descriptor;
IsPrimitive = isPrimitive;
}
示例9: MethodInvocation
public MethodInvocation(IReference reference, IType type, IMethod method, ISubstitution substitution)
{
Reference = reference;
Type = type;
Method = method;
Substitution = substitution;
}
示例10: From
public static AssetLogMessage From(Package package, IReference assetReference, ILogMessage logMessage, string assetPath, int line = 0, int character = 0)
{
// Transform to AssetLogMessage
var assetLogMessage = logMessage as AssetLogMessage;
if (assetLogMessage == null)
{
assetLogMessage = new AssetLogMessage(null, assetReference, logMessage.Type, AssetMessageCode.CompilationMessage, assetReference?.Location, logMessage.Text)
{
Exception = (logMessage as LogMessage)?.Exception
};
}
// Set file (and location if available)
assetLogMessage.File = assetPath;
assetLogMessage.Line = line;
assetLogMessage.Character = character;
// Generate location (if it's a Yaml exception)
var yamlException = (logMessage as LogMessage)?.Exception as YamlException;
if (yamlException != null)
{
assetLogMessage.Line = yamlException.Start.Line;
assetLogMessage.Character = yamlException.Start.Column;
// We've already got everything, no need to pollute log with stack trace of exception
assetLogMessage.Exception = null;
}
return assetLogMessage;
}
示例11: ReinstallPackageOn
public static bool ReinstallPackageOn(ILogger logger, IReference newPackage, string sourceDirectory, IEnumerable<string> installDirs)
{
foreach (string installDir in installDirs)
if (!InstallPackage(logger, newPackage, installDir, sourceDirectory))
return false;
return true;
}
示例12: Equals
public bool Equals(IReference obj)
{
if (obj == null) return false;
if (obj == this) return true;
var fr = obj as ProjectReference;
if (fr != null) return fr.Name == this.Name;
return false;
}
示例13: DeclareHelper
protected virtual IReference DeclareHelper(string name, IReference variable, Expression optionalInitialValue)
{
FuncBuilder.Instance.BindLocalVariableToRepresentation(variable, name);
if(!ReferenceEquals(optionalInitialValue, null)) {
Assignment.AssignAny(variable, optionalInitialValue);
}
return variable;
}
示例14: AddReference
public void AddReference(IReference reference)
{
var assembly = reference.GetAssembly();
references.Add(assembly);
compiler.Parameters.AddAssembly(assembly);
}
示例15: AssetLogger
public AssetLogger(Package package, IReference assetReference, string assetFullPath, ILogger loggerToForward)
{
this.package = package;
this.assetReference = assetReference;
this.assetFullPath = assetFullPath;
this.loggerToForward = loggerToForward;
ActivateLog(LogMessageType.Debug);
}