internal DynamicReferenceInstance(IReferenceInstance refInstance) : base((IValueSymbol)refInstance) { this.normalizedDict = new Dictionary <string, ISymbol>(StringComparer.OrdinalIgnoreCase); IReferenceType dataType = (IReferenceType)refInstance.DataType; IResolvableType type2 = (IResolvableType)dataType; this.resolvedReferenceType = (type2 == null) ? dataType : type2.ResolveType(DataTypeResolveStrategy.AliasReference); if (this.resolvedReferenceType.Category == DataTypeCategory.Struct) { ReadOnlySymbolCollection subSymbols = ((IReferenceInstanceAccess)refInstance).SubSymbols; this.normalizedDict = DynamicStructInstance.createMemberDictionary(false, subSymbols); } }
private IValueSymbol create(IValueSymbol symbol) { if (symbol == null) { throw new ArgumentNullException("symbol"); } DataTypeCategory category = symbol.Category; switch (category) { case DataTypeCategory.Alias: { IAliasInstance aliasInstance = symbol as IAliasInstance; if (aliasInstance != null) { return(new DynamicAliasInstance(aliasInstance)); } Module.Trace.TraceWarning($"'{symbol.InstancePath}' cannot be resolved to alias"); return(new DynamicSymbol(symbol)); } case DataTypeCategory.Enum: break; case DataTypeCategory.Array: if (symbol is IArrayInstance) { return(!(symbol is IOversamplingArrayInstance) ? new DynamicArrayInstance((IArrayInstance)symbol) : new DynamicOversamplingArrayInstance((IOversamplingArrayInstance)symbol)); } Module.Trace.TraceWarning($"'{symbol.InstancePath}' cannot be resolved to array"); return(new DynamicSymbol(symbol)); case DataTypeCategory.Struct: { IStructInstance instance3 = symbol as IStructInstance; if (instance3 != null) { return(!instance3.HasRpcMethods ? new DynamicStructInstance((IStructInstance)symbol) : new DynamicRpcStructInstance((IRpcStructInstance)symbol)); } Module.Trace.TraceWarning($"'{symbol.InstancePath}' cannot be resolved to struct"); return(new DynamicSymbol(symbol)); } default: switch (category) { case DataTypeCategory.Pointer: { IPointerInstance pointerInstance = symbol as IPointerInstance; if (pointerInstance != null) { return(new DynamicPointerInstance(pointerInstance)); } Module.Trace.TraceWarning($"'{symbol.InstancePath}' cannot be resolved to pointer"); return(new DynamicSymbol(symbol)); } case DataTypeCategory.Union: { IUnionInstance unionInstance = symbol as IUnionInstance; if (unionInstance != null) { return(new DynamicUnionInstance(unionInstance)); } Module.Trace.TraceWarning($"'{symbol.InstancePath}' cannot be resolved to union"); return(new DynamicSymbol(symbol)); } case DataTypeCategory.Reference: { IReferenceInstance refInstance = symbol as IReferenceInstance; if (refInstance != null) { return(new DynamicReferenceInstance(refInstance)); } Module.Trace.TraceWarning($"'{symbol.InstancePath}' cannot be resolved to reference"); return(new DynamicSymbol(symbol)); } default: break; } break; } return(new DynamicSymbol(symbol)); }