public QueryResult <T> QueryService <T>(NIType type) where T : class { if (typeof(T) == typeof(ITypeAssetProvider)) { if (type.IsRebarReferenceType()) { NIType innerType = type.GetReferentType(); ITypeAssetProvider innerTypeAssetProvider = StockResources.GetTypeAssets(null, innerType); int innerTypeDimensionality = StockDiagramUIResources.TypeToArraySize(innerType); ITypeAssetProvider outerTypeAssetProvider = type.IsMutableReferenceType() ? (ITypeAssetProvider) new MutableReferenceTypeAssetProvider(innerTypeAssetProvider, innerTypeDimensionality) : new ImmutableReferenceTypeAssetProvider(innerTypeAssetProvider, innerTypeDimensionality); return(new QueryResult <T>(outerTypeAssetProvider as T)); } if (type.IsLockingCellType()) { return(new QueryResult <T>(new GenericReferenceTypeAssetProvider("Locking Cell") as T)); } if (type.IsNonLockingCellType()) { return(new QueryResult <T>(new GenericReferenceTypeAssetProvider("Nonlocking Cell") as T)); } if (type.IsIteratorType()) { return(new QueryResult <T>(new GenericReferenceTypeAssetProvider("Iterator") as T)); } if (type.IsVectorType()) { return(new QueryResult <T>(new GenericReferenceTypeAssetProvider("Vector") as T)); } } return(new QueryResult <T>()); }
private ITypeAssetProvider GetTypeAssetProviderForType(NIType type) { if (type.IsRebarReferenceType()) { NIType innerType = type.GetReferentType(); ITypeAssetProvider innerTypeAssetProvider = GetTypeAssetProviderForType(innerType) ?? StockResources.GetTypeAssets((Element)null, innerType); int innerTypeDimensionality = StockDiagramUIResources.TypeToArraySize(innerType); ITypeAssetProvider outerTypeAssetProvider = type.IsMutableReferenceType() ? (ITypeAssetProvider) new MutableReferenceTypeAssetProvider(innerTypeAssetProvider, innerTypeDimensionality) : new ImmutableReferenceTypeAssetProvider(innerTypeAssetProvider, innerTypeDimensionality); return(outerTypeAssetProvider); } if (type.IsLockingCellType()) { return(new GenericReferenceTypeAssetProvider("Locking Cell")); } if (type.IsSharedType()) { return(new GenericReferenceTypeAssetProvider("Shared")); } if (type.IsIteratorType()) { return(new GenericReferenceTypeAssetProvider("Iterator")); } if (type.IsVectorType()) { return(new GenericReferenceTypeAssetProvider("Vector")); } if (type.IsUnion()) { return(new VariantTypeAssetProvider(type.GetName())); } return(null); }
private static WireRenderInfoEnumerable CreateVariableIdentityRenderInfo(VariableReference variable, StockDiagramUIResources stockResources) { NIType innerType = variable.Type.IsRebarReferenceType() ? variable.Type.GetUnderlyingTypeFromRebarType() : variable.Type; int id = variable.Id; ITypeAssetProvider innerTypeAssetProvider = new VariableIdentityTypeAssetProvider( stockResources.GetTypeAssets((Element)null, variable.Type).GetShortName(innerType), VariableIdentityTypeAssetProvider.GetColor(id)); ITypeAssetProvider outerTypeAssetProvider; if (variable.Type.IsMutableReferenceType()) { outerTypeAssetProvider = new MutableReferenceTypeAssetProvider( innerTypeAssetProvider, 0); } else if (variable.Type.IsImmutableReferenceType()) { outerTypeAssetProvider = new ImmutableReferenceTypeAssetProvider( innerTypeAssetProvider, 0); } else if (variable.Mutable) { outerTypeAssetProvider = new MutableValueTypeAssetProvider( innerTypeAssetProvider, 0); } else { outerTypeAssetProvider = new ImmutableValueTypeAssetProvider( innerTypeAssetProvider, 0); } return(outerTypeAssetProvider.GetWireRenderInfo(0)); }