Exemple #1
0
 internal DynamicUnionInstance(IUnionInstance unionInstance) : base((IValueSymbol)unionInstance)
 {
     this.normalizedDict = new Dictionary <string, ISymbol>(StringComparer.OrdinalIgnoreCase);
     foreach (DynamicSymbol symbol in this.FieldInstances)
     {
         this.normalizedDict.Add(symbol.NormalizedName, symbol);
     }
 }
Exemple #2
0
        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));
        }