public bool ContainsName(string instanceName) { if (string.IsNullOrEmpty(instanceName)) { throw new ArgumentNullException("instanceName"); } string actName = instanceName; bool flag = instanceName.EndsWith("^"); if (flag) { actName = instanceName.Substring(0, instanceName.Length - 1); } T local = default(T); local = Enumerable.SingleOrDefault <T>(this._list, p => string.CompareOrdinal(p.InstanceName, actName) == 0); foreach (T local2 in this._list) { if (string.CompareOrdinal(local2.InstanceName, actName) == 0) { local = local2; break; } } if ((local != null) & flag) { IPointerInstance instance = local as IPointerInstance; local = (instance == null) ? default(T) : ((T)instance.Reference); } return(local != null); }
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)); }
public virtual bool TryGetInstanceByName(string instanceName, out IList <T> instances) { if (string.IsNullOrEmpty(instanceName)) { throw new ArgumentNullException("instanceName2"); } List <T> list = null; bool flag = false; bool flag2 = instanceName.EndsWith("^"); string actName = instanceName; if (flag2) { actName = instanceName.Substring(0, instanceName.Length - 1); } if (this.mode == InstanceCollectionMode.Path) { StringComparer cmp = StringComparer.OrdinalIgnoreCase; list = new List <T>(from p in this._pathDict.Values where cmp.Compare(p.InstanceName, actName) == 0 select p); if (flag2) { list = new List <T>(from pi in Enumerable.Cast <IPointerInstance>((IEnumerable)(from p in list where p is IPointerInstance select p)) select(T) pi.Reference); } } else { T reference = default(T); if (this._pathDict.TryGetValue(actName, out reference)) { list = new List <T>(); if (!flag2) { list.Add(reference); } else { IPointerInstance instance = reference as IPointerInstance; if (instance != null) { reference = (T)instance.Reference; if (reference != null) { list.Add(reference); } } } } } if ((list == null) || (list.Count <= 0)) { instances = null; flag = false; } else { instances = list.AsReadOnly(); flag = true; } return(flag); }
internal DynamicPointerInstance(IPointerInstance pointerInstance) : base((IValueSymbol)pointerInstance) { }