public TypeManager() { _predefTypes = null; // Initialized via the Init call. _BSymmgr = null; // Initialized via the Init call. _typeFactory = new TypeFactory(); _typeTable = new TypeTable(); // special types with their own symbol kind. _errorType = _typeFactory.CreateError(null, null, null, null, null); _voidType = _typeFactory.CreateVoid(); _nullType = _typeFactory.CreateNull(); _typeUnit = _typeFactory.CreateUnit(); _typeAnonMeth = _typeFactory.CreateAnonMethod(); _typeMethGrp = _typeFactory.CreateMethodGroup(); _argListType = _typeFactory.CreateArgList(); InitType(_errorType); _errorType.SetErrors(true); InitType(_voidType); InitType(_nullType); InitType(_typeUnit); InitType(_typeAnonMeth); InitType(_typeMethGrp); _stvcMethod = new StdTypeVarColl(); _stvcClass = new StdTypeVarColl(); }
private static void InitFactory (string section, TypeFactory factory) { try { IDictionary d = (IDictionary) ConfigurationSettings.GetConfig (section); foreach (DictionaryEntry de in d) { try { string[] keys = de.Key.ToString().Split (':'); string key = keys[0]; string desc = keys.Length > 1 ? keys[1] : key; factory.Add ( new TypeFactoryEntry ( key, desc, Type.GetType (de.Value.ToString(), true))); } catch (Exception e) { Trace.WriteLineIf (console.Enabled, string.Format ("Error adding {0} ({1}): {2}", de.Key, de.Value, e.Message)); } } } catch { Trace.WriteLineIf (console.Enabled, string.Format ("Unable to open section: {0}", section)); } }
public void UnregisterTest() { TypeFactory<Stream> factory = new TypeFactory<Stream>(); factory.Register<MemoryStream>(); factory.Unregister<MemoryStream>(); Assert.AreEqual(factory.Create("System.IO.MemoryStream"), null); }
public void RegisterTest() { TypeFactory<Stream> factory = new TypeFactory<Stream>(); factory.Register<MemoryStream>(); Stream newStream = factory.Create("System.IO.MemoryStream"); Assert.AreNotEqual(newStream, null); Assert.AreEqual(newStream.GetType(), typeof(MemoryStream)); }
/// <summary> /// Handles when a <see cref="Type"/> is loaded into the <see cref="TypeFactory"/>. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The <see cref="NetGore.Collections.TypeFactoryLoadedEventArgs"/> instance containing the event data.</param> void LoadTypeHandler(TypeFactory sender, TypeFactoryLoadedEventArgs e) { // Skip private nested types as they cannot be called by the controller anyways if (e.LoadedType.IsNested && !e.LoadedType.IsPublic) return; // Filter out types to ignore if (_typesToIgnore != null && _typesToIgnore.Contains(e.LoadedType)) return; // Check for attribute var attribs = e.LoadedType.GetCustomAttributes(false); if (attribs == null || attribs.Length == 0) _missingAttributeHandler(this, EventArgsHelper.Create(e.LoadedType)); }
public static IRuntimeTypeSource FromAttributes(IEnumerable<Assembly> assemblies) { var allExportedTypes = assemblies.AllExportedTypes(); var typeFactory = new TypeFactory(); var xamlNamespaceRegistry = new NamespaceRegistry(); xamlNamespaceRegistry.FillFromAttributes(assemblies); var typeFeatureProvider = new TypeFeatureProvider(new TypeConverterProvider()); typeFeatureProvider.FillFromAttributes(allExportedTypes); var xamlTypeRepo = new TypeRepository(xamlNamespaceRegistry, typeFactory, typeFeatureProvider); return new RuntimeTypeSource(xamlTypeRepo, xamlNamespaceRegistry); }
// todo: containing type type parameters? public IDeclaredType GetAttributeType() => TypeFactory.CreateTypeByCLRName(Attr.GetClrName(), Module);
private bool IsCastRequired(Expression expression, System.Type toType, out bool existType) { existType = false; return(toType != typeof(object) && expression.Type.UnwrapIfNullable() != toType.UnwrapIfNullable() && IsCastRequired(ExpressionsHelper.GetType(_parameters, expression), TypeFactory.GetDefaultTypeFor(toType), out existType)); }
private ChannelTypeFactory() { _typeImages = new Dictionary<string, string>(19); _typeImages.Add("VIP尊享", "/Images/Channels/vip.png"); _typeImages.Add("电影", "/Images/Channels/movie.png"); _typeImages.Add("电视剧", "/Images/Channels/teleplay.png"); _typeImages.Add("动漫", "/Images/Channels/cartoon.png"); _typeImages.Add("综艺", "/Images/Channels/show.png"); _typeImages.Add("体育", "/Images/Channels/sports.png"); _typeImages.Add("热点", "/Images/Channels/hot.png"); _typeImages.Add("游戏", "/Images/Channels/game.png"); //_typeImages.Add("推荐分类", "/Images/Channels/recommend.png"); _typeImages.Add("旅游", "/Images/Channels/travel.png"); //_typeImages.Add("生活", "/Images/Channels/life.png"); //_typeImages.Add("时尚", "/Images/Channels/modern.png"); _typeImages.Add("音乐", "/Images/Channels/music.png"); _typeImages.Add("娱乐", "/Images/Channels/flower.png"); //_typeImages.Add("搞笑", "/Images/Channels/funny.png"); _typeImages.Add("最近观看", "/Images/Channels/history.png"); _typeImages.Add("我的收藏", "/Images/Channels/favoriten.png"); _typeImages.Add("我的下载", "/Images/Channels/downloaded.png"); //_typeImages.Add("直播", "/Images/Channels/live.png"); _defaultImage = "/Images/Channels/default.png"; _channelTypeSettingKey = "ChannelTypeSettingKey"; _localTypes = new ChannelTypeItem[] { new ChannelTypeItem(){TypeId = RecentTypeId, TypeName="最近观看", ImageUri=_typeImages["最近观看"]}, new ChannelTypeItem(){TypeId = FavoritenTypeId, TypeName="我的收藏", ImageUri=_typeImages["我的收藏"]}, new ChannelTypeItem(){TypeId = DownloadedTypeId, TypeName="我的下载", ImageUri=_typeImages["我的下载"], Count = DownloadViewModel.Instance.DownloadingItems.Count} //new ChannelTypeItem(){TypeId = LiveTypeId, TypeName="直播", ImageUri = _defaultImage} }; _allViewModel = new ChannelTypeViewModel(); _selectedViewModel = new ObservableCollection<ChannelTypeItem>(); var selectGroup = new ChannelTypeGroup(); selectGroup.GroupName = "已固定"; var unSelectGroup = new ChannelTypeGroup(); unSelectGroup.GroupName = "未固定"; _allViewModel.Add(selectGroup); _allViewModel.Add(unSelectGroup); _typeFactory = new TypeFactory(); _typeFactory.HttpSucessHandler += typeFactory_HttpSucess; _typeFactory.HttpFailorTimeOut += HttpFailorTimeOut; }
public static IType GetType([NotNull] FSharpType fsType, [CanBeNull] IList <ITypeParameter> typeParamsFromContext, [NotNull] IPsiModule psiModule, bool isFromMethodSig = false, bool isFromReturn = false) { var type = GetStrippedType(fsType); if (type?.IsUnresolved ?? true) { return(TypeFactory.CreateUnknownType(psiModule)); } // F# 4.0 specs 18.1.3 if (isFromMethodSig && type.IsNativePtr && !HasGenericTypeParams(fsType)) { try { var argType = GetSingleTypeArgument(fsType, typeParamsFromContext, psiModule, true); return(TypeFactory.CreatePointerType(argType)); } catch (Exception e) { Logger.LogMessage(LoggingLevel.WARN, "Could not map pointer type: {0}", fsType); Logger.LogExceptionSilently(e); } } if (type.IsGenericParameter) { return(FindTypeParameterByName(type, typeParamsFromContext, psiModule)); } if (!type.HasTypeDefinition) { return(TypeFactory.CreateUnknownType(psiModule)); } var entity = type.TypeDefinition; // F# 4.0 specs 5.1.4 if (entity.IsArrayType) { var argType = GetSingleTypeArgument(type, typeParamsFromContext, psiModule, isFromMethodSig); return(TypeFactory.CreateArrayType(argType, type.TypeDefinition.ArrayRank)); } // e.g. byref<int>, we need int if (entity.IsByRef) { return(GetType(type.GenericArguments[0], typeParamsFromContext, psiModule, isFromMethodSig, isFromReturn)); } if (entity.IsProvidedAndErased) { var fsBaseType = GetFSharpBaseType(entity); if (fsBaseType != null) { return(GetType(fsBaseType.Value, typeParamsFromContext, psiModule, isFromMethodSig, isFromReturn)); } } var clrName = GetClrName(entity); if (clrName == null) { // bug Microsoft/visualfsharp#3532 // e.g. byref<int>, we need int return(entity.CompiledName == "byref`1" && entity.AccessPath == "Microsoft.FSharp.Core" ? GetType(type.GenericArguments[0], typeParamsFromContext, psiModule, isFromMethodSig, isFromReturn) : TypeFactory.CreateUnknownType(psiModule)); } var declaredType = TypeFactory.CreateTypeByCLRName(clrName, psiModule); var typeElement = declaredType.GetTypeElement(); if (typeElement == null) { return(TypeFactory.CreateUnknownType(psiModule)); } var args = type.GenericArguments; return(args.Count != 0 ? GetTypeWithSubstitution(typeElement, args, typeParamsFromContext, psiModule, isFromMethodSig) ?? declaredType : declaredType); }
private static object ReadValue(Type inst_type, JsonReader reader) { reader.Read(); var inst_typeInfo = TypeFactory.GetTypeInfo(inst_type); if (reader.Token == JsonToken.ArrayEnd) { return(null); } //support for nullable types Type underlying_type = Nullable.GetUnderlyingType(inst_type); Type value_type = underlying_type ?? inst_type; if (reader.Token == JsonToken.Null) { if (inst_typeInfo.IsClass || underlying_type != null) { return(null); } throw new JsonException(String.Format( "Can't assign null to an instance of type {0}", inst_type)); } if (reader.Token == JsonToken.Double || reader.Token == JsonToken.Int || reader.Token == JsonToken.UInt || reader.Token == JsonToken.Long || reader.Token == JsonToken.ULong || reader.Token == JsonToken.String || reader.Token == JsonToken.Boolean) { Type json_type = reader.Value.GetType(); var json_typeInfo = TypeFactory.GetTypeInfo(json_type); if (inst_typeInfo.IsAssignableFrom(json_typeInfo)) { return(reader.Value); } // If there's a custom importer that fits, use it if (custom_importers_table.ContainsKey(json_type) && custom_importers_table[json_type].ContainsKey( value_type)) { ImporterFunc importer = custom_importers_table[json_type][value_type]; return(importer(reader.Value)); } // Maybe there's a base importer that works if (base_importers_table.ContainsKey(json_type) && base_importers_table[json_type].ContainsKey( value_type)) { ImporterFunc importer = base_importers_table[json_type][value_type]; return(importer(reader.Value)); } // Maybe it's an enum if (inst_typeInfo.IsEnum) { return(Enum.ToObject(value_type, reader.Value)); } // Try using an implicit conversion operator MethodInfo conv_op = GetConvOp(value_type, json_type); if (conv_op != null) { return(conv_op.Invoke(null, new object[] { reader.Value })); } // No luck throw new JsonException(String.Format( "Can't assign value '{0}' (type {1}) to type {2}", reader.Value, json_type, inst_type)); } object instance = null; if (reader.Token == JsonToken.ArrayStart) { AddArrayMetadata(inst_type); ArrayMetadata t_data = array_metadata[inst_type]; if (!t_data.IsArray && !t_data.IsList) { throw new JsonException(String.Format( "Type {0} can't act as an array", inst_type)); } IList list; Type elem_type; if (!t_data.IsArray) { list = (IList)Activator.CreateInstance(inst_type); elem_type = t_data.ElementType; } else { list = new List <object> (); elem_type = inst_type.GetElementType(); } while (true) { object item = ReadValue(elem_type, reader); if (reader.Token == JsonToken.ArrayEnd) { break; } list.Add(item); } if (t_data.IsArray) { int n = list.Count; instance = Array.CreateInstance(elem_type, n); for (int i = 0; i < n; i++) { ((Array)instance).SetValue(list[i], i); } } else { instance = list; } } else if (reader.Token == JsonToken.ObjectStart) { AddObjectMetadata(value_type); ObjectMetadata t_data = object_metadata[value_type]; instance = Activator.CreateInstance(value_type); while (true) { reader.Read(); if (reader.Token == JsonToken.ObjectEnd) { break; } string property = (string)reader.Value; if (t_data.Properties.ContainsKey(property)) { PropertyMetadata prop_data = t_data.Properties[property]; if (prop_data.IsField) { ((FieldInfo)prop_data.Info).SetValue( instance, ReadValue(prop_data.Type, reader)); } else { PropertyInfo p_info = (PropertyInfo)prop_data.Info; if (p_info.CanWrite) { p_info.SetValue( instance, ReadValue(prop_data.Type, reader), null); } else { ReadValue(prop_data.Type, reader); } } } else { if (!t_data.IsDictionary) { throw new JsonException(String.Format( "The type {0} doesn't have the " + "property '{1}'", inst_type, property)); } ((IDictionary)instance).Add( property, ReadValue( t_data.ElementType, reader)); } } } ValidateRequiredFields(instance, inst_type); return(instance); }
public ProductionBomMap() { Mutable(false); Table("PRODBOM"); Id(x => x.Id, map => { map.Column("RECID"); map.Generator(Generators.Assigned); map.Type((IIdentifierType)TypeFactory.Basic(typeof(long).FullName)); }); ManyToOne(x => x.Production, map => { map.Access(Accessor.Property); map.Column("PRODID"); map.NotNullable(false); map.Lazy(LazyRelation.Proxy); map.Cascade(Cascade.None); map.Class(typeof(Production)); map.NotFound(NotFoundMode.Ignore); map.NotNullable(false); }); ManyToOne(x => x.Unit, map => { map.Cascade(Cascade.None); map.Class(typeof(Unit)); map.Column("UNITID"); map.Lazy(LazyRelation.Proxy); map.NotNullable(false); map.NotFound(NotFoundMode.Ignore); }); ManyToOne(x => x.Item, map => { map.Cascade(Cascade.None); map.Class(typeof(Item)); map.Column("ITEMID"); map.Lazy(LazyRelation.Proxy); map.NotNullable(false); map.NotFound(NotFoundMode.Ignore); }); ManyToOne(x => x.Dimensions, map => { map.Cascade(Cascade.None); map.Class(typeof(Dimensions)); map.Column("INVENTDIMID"); map.Lazy(LazyRelation.Proxy); map.NotNullable(false); map.NotFound(NotFoundMode.Ignore); }); Property(x => x.BomId, map => { map.Column("BOMID"); map.Length(40); map.NotNullable(true); map.Type(TypeFactory.Basic(typeof(string).FullName)); }); Property(x => x.BOMConsump, map => { map.Column("BOMCONSUMP"); map.NotNullable(true); map.Type(TypeFactory.Basic(typeof(int).FullName)); }); Property(x => x.BOMQty, map => { map.Column("BOMQTY"); map.NotNullable(true); map.Type(TypeFactory.Basic(typeof(double).FullName)); }); Property(x => x.LineNum, map => { map.Column("LINENUM"); map.NotNullable(true); map.Type(TypeFactory.Basic(typeof(double).FullName)); }); Property(x => x.OprNum, map => { map.Column("OPRNUM"); map.NotNullable(true); map.Type(TypeFactory.Basic(typeof(int).FullName)); }); Property(x => x.Position, map => { map.Column("POSITION"); map.Length(30); map.NotNullable(true); map.Type(TypeFactory.Basic(typeof(string).FullName)); }); Property(x => x.ProdLineType, map => { map.Column("PRODLINETYPE"); map.NotNullable(true); map.Type(TypeFactory.Basic(typeof(int).FullName)); }); Property(x => x.QtyBOMCalc, map => { map.Column("QTYBOMCALC"); map.NotNullable(true); map.Type(TypeFactory.Basic(typeof(double).FullName)); }); }
public void DefaultType() { Assert.That(TypeFactory.GetDefaultTypeFor(_replacedType), Is.EqualTo(_testDefaultStringType)); }
public EntityMetamodel(PersistentClass persistentClass, ISessionFactoryImplementor sessionFactory) { this.sessionFactory = sessionFactory; name = persistentClass.EntityName; rootName = persistentClass.RootClazz.EntityName; entityType = TypeFactory.ManyToOne(name); type = persistentClass.MappedClass; rootType = persistentClass.RootClazz.MappedClass; rootTypeAssemblyQualifiedName = rootType == null ? null : rootType.AssemblyQualifiedName; identifierProperty = PropertyFactory.BuildIdentifierProperty(persistentClass, sessionFactory.GetIdentifierGenerator(rootName)); versioned = persistentClass.IsVersioned; bool lazyAvailable = persistentClass.HasPocoRepresentation && FieldInterceptionHelper.IsInstrumented(persistentClass.MappedClass); bool hasLazy = false; propertySpan = persistentClass.PropertyClosureSpan; properties = new StandardProperty[propertySpan]; List <int> naturalIdNumbers = new List <int>(); propertyNames = new string[propertySpan]; propertyTypes = new IType[propertySpan]; propertyUpdateability = new bool[propertySpan]; propertyInsertability = new bool[propertySpan]; insertInclusions = new ValueInclusion[propertySpan]; updateInclusions = new ValueInclusion[propertySpan]; nonlazyPropertyUpdateability = new bool[propertySpan]; propertyCheckability = new bool[propertySpan]; propertyNullability = new bool[propertySpan]; propertyVersionability = new bool[propertySpan]; propertyLaziness = new bool[propertySpan]; cascadeStyles = new CascadeStyle[propertySpan]; int i = 0; int tempVersionProperty = NoVersionIndex; bool foundCascade = false; bool foundCollection = false; bool foundMutable = false; bool foundInsertGeneratedValue = false; bool foundUpdateGeneratedValue = false; bool foundNonIdentifierPropertyNamedId = false; HasPocoRepresentation = persistentClass.HasPocoRepresentation; // NH: WARNING if we have to disable lazy/unproxy properties we have to do it in the whole process. lazy = persistentClass.IsLazy && (!persistentClass.HasPocoRepresentation || !ReflectHelper.IsFinalClass(persistentClass.ProxyInterface)); lazyAvailable &= lazy; // <== Disable lazy properties if the class is marked with lazy=false bool hadLazyProperties = false; bool hadNoProxyRelations = false; foreach (Mapping.Property prop in persistentClass.PropertyClosureIterator) { if (prop.IsLazy) { hadLazyProperties = true; } if (prop.UnwrapProxy) { hadNoProxyRelations = true; } // NH: A lazy property is a simple property marked with lazy=true bool islazyProperty = prop.IsLazy && lazyAvailable && (!prop.IsEntityRelation || prop.UnwrapProxy); // NH: A Relation (in this case many-to-one or one-to-one) marked as "no-proxy" var isUnwrapProxy = prop.UnwrapProxy && lazyAvailable; if (islazyProperty || isUnwrapProxy) { // NH: verify property proxiability var getter = prop.GetGetter(persistentClass.MappedClass); if (getter.Method == null || getter.Method.IsDefined(typeof(CompilerGeneratedAttribute), false) == false) { log.ErrorFormat("Lazy or no-proxy property {0}.{1} is not an auto property, which may result in uninitialized property access", persistentClass.EntityName, prop.Name); } } if (prop == persistentClass.Version) { tempVersionProperty = i; properties[i] = PropertyFactory.BuildVersionProperty(prop, islazyProperty); } else { properties[i] = PropertyFactory.BuildStandardProperty(prop, islazyProperty); } if (prop.IsNaturalIdentifier) { naturalIdNumbers.Add(i); } if ("id".Equals(prop.Name)) { foundNonIdentifierPropertyNamedId = true; } if (islazyProperty) { hasLazy = true; } if (isUnwrapProxy) { hasUnwrapProxyForProperties = true; } propertyLaziness[i] = islazyProperty; propertyNames[i] = properties[i].Name; propertyTypes[i] = properties[i].Type; propertyNullability[i] = properties[i].IsNullable; propertyUpdateability[i] = properties[i].IsUpdateable; propertyInsertability[i] = properties[i].IsInsertable; insertInclusions[i] = DetermineInsertValueGenerationType(prop, properties[i]); updateInclusions[i] = DetermineUpdateValueGenerationType(prop, properties[i]); propertyVersionability[i] = properties[i].IsVersionable; nonlazyPropertyUpdateability[i] = properties[i].IsUpdateable && !islazyProperty; propertyCheckability[i] = propertyUpdateability[i] || (propertyTypes[i].IsAssociationType && ((IAssociationType)propertyTypes[i]).IsAlwaysDirtyChecked); cascadeStyles[i] = properties[i].CascadeStyle; if (properties[i].IsLazy) { hasLazy = true; } if (properties[i].CascadeStyle != CascadeStyle.None) { foundCascade = true; } if (IndicatesCollection(properties[i].Type)) { foundCollection = true; } if (propertyTypes[i].IsMutable && propertyCheckability[i]) { foundMutable = true; } if (insertInclusions[i] != ValueInclusion.None) { foundInsertGeneratedValue = true; } if (updateInclusions[i] != ValueInclusion.None) { foundUpdateGeneratedValue = true; } MapPropertyToIndex(prop, i); i++; } if (naturalIdNumbers.Count == 0) { naturalIdPropertyNumbers = null; } else { naturalIdPropertyNumbers = naturalIdNumbers.ToArray(); } hasCascades = foundCascade; hasInsertGeneratedValues = foundInsertGeneratedValue; hasUpdateGeneratedValues = foundUpdateGeneratedValue; hasNonIdentifierPropertyNamedId = foundNonIdentifierPropertyNamedId; versionPropertyIndex = tempVersionProperty; hasLazyProperties = hasLazy; if (hadLazyProperties && !hasLazy) { log.WarnFormat("Disabled lazy property fetching for {0} because it does not support lazy at the entity level", name); } if (hasLazy) { log.Info("lazy property fetching available for: " + name); } if (hadNoProxyRelations && !hasUnwrapProxyForProperties) { log.WarnFormat("Disabled ghost property fetching for {0} because it does not support lazy at the entity level", name); } if (hasUnwrapProxyForProperties) { log.Info("no-proxy property fetching available for: " + name); } mutable = persistentClass.IsMutable; if (!persistentClass.IsAbstract.HasValue) { // legacy behavior (with no abstract attribute specified) isAbstract = persistentClass.HasPocoRepresentation && ReflectHelper.IsAbstractClass(persistentClass.MappedClass); } else { isAbstract = persistentClass.IsAbstract.Value; if (!isAbstract && persistentClass.HasPocoRepresentation && ReflectHelper.IsAbstractClass(persistentClass.MappedClass)) { //Modified by OneGeo: Concating the type without the null log.Warn("entity [" + (type == null? persistentClass.EntityName : type.FullName) + "] is abstract-class/interface explicitly mapped as non-abstract; be sure to supply entity-names"); } } selectBeforeUpdate = persistentClass.SelectBeforeUpdate; dynamicUpdate = persistentClass.DynamicUpdate; dynamicInsert = persistentClass.DynamicInsert; polymorphic = persistentClass.IsPolymorphic; explicitPolymorphism = persistentClass.IsExplicitPolymorphism; inherited = persistentClass.IsInherited; superclass = inherited ? persistentClass.Superclass.EntityName : null; superclassType = inherited ? persistentClass.Superclass.MappedClass : null; hasSubclasses = persistentClass.HasSubclasses; optimisticLockMode = persistentClass.OptimisticLockMode; if (optimisticLockMode > Versioning.OptimisticLock.Version && !dynamicUpdate) { //Modified by OneGeo: Concating the type without the null throw new MappingException("optimistic-lock setting requires dynamic-update=\"true\": " + (type == null ? persistentClass.EntityName : type.FullName)); } hasCollections = foundCollection; hasMutableProperties = foundMutable; foreach (Subclass obj in persistentClass.SubclassIterator) { subclassEntityNames.Add(obj.EntityName); } subclassEntityNames.Add(name); EntityMode = persistentClass.HasPocoRepresentation ? EntityMode.Poco : EntityMode.Map; var entityTuplizerFactory = new EntityTuplizerFactory(); var tuplizerClassName = persistentClass.GetTuplizerImplClassName(EntityMode); Tuplizer = tuplizerClassName == null ? entityTuplizerFactory.BuildDefaultEntityTuplizer(EntityMode, this, persistentClass) : entityTuplizerFactory.BuildEntityTuplizer(tuplizerClassName, this, persistentClass); }
public TypeTransformer(TypeFactory factory, TypeStore store, Program prog) : this(factory, store, prog, new NullDecompilerEventListener()) { }
public ProductionMap() { Mutable(false); Table("PRODTABLE"); Id(x => x.Id, map => { map.Column("PRODID"); map.Length(40); map.Generator(Generators.Assigned); map.Type((IIdentifierType)TypeFactory.Basic(typeof(string).FullName)); }); Property(x => x.RecId, map => { map.Column("RECID"); map.NotNullable(true); }); Set(p => p.Routes, cm => { cm.Access(Accessor.Field); cm.Cascade(Cascade.None); cm.Fetch(CollectionFetchMode.Select); cm.Inverse(true); cm.Key(km => { km.Column("ROUTEID"); km.NotNullable(false); }); cm.Lazy(CollectionLazy.Lazy); }, m => m.OneToMany(om => om.Class(typeof(Route)))); Set(p => p.ProductionRoutes, cm => { cm.Access(Accessor.Field); cm.Cascade(Cascade.None); cm.Fetch(CollectionFetchMode.Select); cm.Inverse(true); cm.Key(km => { km.Column("PRODID"); km.NotNullable(false); }); cm.Lazy(CollectionLazy.Lazy); }, m => m.OneToMany(om => om.Class(typeof(ProductionRoute)))); Set(p => p.Boms, cm => { cm.Access(Accessor.Field); cm.Cascade(Cascade.None); cm.Fetch(CollectionFetchMode.Select); cm.Inverse(true); cm.Key(km => { km.Column("PRODID"); km.NotNullable(false); }); cm.Lazy(CollectionLazy.Lazy); }, m => m.OneToMany(om => om.Class(typeof(ProductionBOM)))); ManyToOne(x => x.Item, map => { map.Cascade(Cascade.None); map.Class(typeof(Item)); map.Column("ITEMID"); map.Lazy(LazyRelation.Proxy); map.NotNullable(false); map.NotFound(NotFoundMode.Ignore); }); ManyToOne(x => x.Sale, map => { map.Cascade(Cascade.None); map.Class(typeof(Sale)); map.Column("INVENTREFID"); map.Lazy(LazyRelation.Proxy); map.NotNullable(false); map.NotFound(NotFoundMode.Ignore); }); ManyToOne(x => x.Dimensions, map => { map.Cascade(Cascade.None); map.Class(typeof(Dimensions)); map.Column("INVENTDIMID"); map.Lazy(LazyRelation.Proxy); map.NotNullable(false); map.NotFound(NotFoundMode.Ignore); }); Property(p => p.ProductionStatus, m => { m.Access(Accessor.Property); m.Column("fiaxProdStatus"); m.Type(NHibernate.NHibernateUtil.GuessType(typeof(StatusImport))); }); Property(x => x.Name, map => { map.Column("NAME"); map.Length(140); map.NotNullable(false); }); Property(x => x.GroupId, map => { map.Column("PRODGROUPID"); map.Length(10); map.NotNullable(false); }); //Property(x => x.ProductionStatus, map => { map.Column("PRODSTATUS"); map.NotNullable(false); }); Property(x => x.Priority, map => { map.Column("PRODPRIO"); map.NotNullable(false); }); Property(x => x.DataAreaId, map => { map.Column("DATAAREAID"); map.NotNullable(false); }); Property(x => x.RouteId, map => { map.Column("ROUTEID"); map.Length(40); map.NotNullable(false); }); //ManyToOne(x => x.DataImported, map => // { // map.PropertyRef("RecId"); // map.Cascade(Cascade.None); // map.Class(typeof(Domain.Interface.DataImported)); // map.Column("RECID"); // map.NotNullable(false); // }); Property(x => x.CreatedBy, map => { map.Column("CreatedBy"); map.Length(10); map.NotNullable(false); }); Property(x => x.DeliveryDate, map => { map.Column("DLVDATE"); map.NotNullable(false); }); Property(x => x.CollectRefProdId, map => { map.Column("COLLECTREFPRODID"); map.Length(20); map.NotNullable(false); }); Property(x => x.InventRefType, map => { map.Column("INVENTREFTYPE"); map.NotNullable(false); }); Property(x => x.QuantityStUp, map => { map.Column("QTYSTUP"); map.NotNullable(false); }); Property(x => x.SF_ProdTaskNum, map => { map.Column("SF_PRODTASKNUM"); map.Length(10); map.NotNullable(false); }); Property(x => x.SF_InventLocationIssueId, map => { map.Column("SF_INVENTLOCATIONISSUEID"); map.Length(10); map.NotNullable(false); }); Property(x => x.SF_NOSTANDART, map => { map.Column("SF_NOSTANDART"); map.NotNullable(false); }); Property(x => x.QtyCalc, map => { map.Column("QTYCALC"); map.NotNullable(false); }); Property(x => x.sf_RFIDCommentsID_1, map => { map.Column("SF_RFIDCOMMENTSID_1"); map.Length(20); map.NotNullable(false); }); Property(x => x.sf_RFIDCommentsID_2, map => { map.Column("SF_RFIDCOMMENTSID_2"); map.Length(20); map.NotNullable(false); }); Property(x => x.sf_RFIDCommentsID_3, map => { map.Column("SF_RFIDCOMMENTSID_3"); map.Length(20); map.NotNullable(false); }); Property(x => x.sf_RFIDCommentsID_4, map => { map.Column("SF_RFIDCOMMENTSID_4"); map.Length(20); map.NotNullable(false); }); Property(x => x.SF_OBLTYPE, map => { map.Column("SF_OBLTYPE"); map.Length(10); map.NotNullable(false); }); Property(x => x.SF_LAKTYPE_1, map => { map.Column("SF_LAKTYPE_1"); map.NotNullable(false); }); Property(x => x.SF_LAKTYPE_2, map => { map.Column("SF_LAKTYPE_2"); map.NotNullable(false); }); Property(x => x.SF_LogisticColors, map => { map.Column("SF_LOGISTICCOLORS"); map.NotNullable(false); }); Property(x => x.BomId, map => { map.Column("BOMID"); map.Length(40); map.NotNullable(false); }); }
internal IType ResultType(ICriteria criteria) { return(TypeFactory.ManyToOne(GetEntityName(criteria))); //return Factory.getTypeResolver().getTypeFactory().manyToOne(getEntityName(criteria)); }
public static T FastCreateInstance <T>() { return(TypeFactory <T> .Create()); }
public void GetConcreteType_NoTypeGeneratedIfNoConfig() { Assert.That(MixinConfiguration.ActiveConfiguration.ClassContexts.ContainsWithInheritance(typeof(object)), Is.False); Assert.That(TypeFactory.GetConcreteType(typeof(object)), Is.SameAs(typeof(object))); }
public static bool IsPrimitive(Type type) { var typeWrapper = TypeFactory.GetTypeInfo(type); return(PrimitiveTypeInfos.Any(ti => typeWrapper.IsAssignableFrom(ti))); }
protected override void DropSchema() { base.DropSchema(); TypeFactory.ClearCustomRegistrations(); Assert.That(TypeFactory.GetDefaultTypeFor(_replacedType), Is.Not.EqualTo(_testDefaultStringType)); }
/// <summary> /// Initializes a new instance of the <see cref="CallbackHandler{TService, TServiceImplementation}"/> class. /// </summary> /// <param name="interceptorHandler">The intercetor handler.</param> /// <param name="proxyFactory">The proxy factory. If <c>null</c>, <see cref="ProxyFactory.Default" /> will be used.</param> /// <param name="serviceLocator">The service locator. If <c>null</c>, <see cref="ServiceLocator.Default" /> will be used.</param> /// <param name="typeFactory">The type factory. If <c>null</c>, <see cref="TypeFactory.Default" /> will be used.</param> /// <exception cref="ArgumentNullException">The <paramref name="interceptorHandler"/> is <c>null</c>.</exception> public CallbackHandler(InterceptorHandler <TService, TServiceImplementation> interceptorHandler, IProxyFactory proxyFactory = null, IServiceLocator serviceLocator = null, ITypeFactory typeFactory = null) : base(interceptorHandler.ServiceType, interceptorHandler.Tag, serviceLocator, interceptorHandler.TargetInstanceToUse, typeFactory) { Argument.IsNotNull(() => interceptorHandler); _interceptorHandler = interceptorHandler; _proxyFactory = proxyFactory ?? ProxyFactory.Default; _target = TargetInstanceToUse is TService ? (TService)TargetInstanceToUse : TypeFactory.CreateInstance <TServiceImplementation>(); }
protected IType GetType([CanBeNull] FSharpType fsType) => fsType != null ? fsType.MapType(AllTypeParameters, Module) : TypeFactory.CreateUnknownType(Module);
public void Setup() { factory = new TypeFactory(); un = new Unifier(factory); }
private static void AddObjectMetadata(Type type) { if (object_metadata.ContainsKey(type)) { return; } ObjectMetadata data = new ObjectMetadata(); var typeInfo = TypeFactory.GetTypeInfo(type); if (typeInfo.GetInterface("System.Collections.IDictionary") != null) { data.IsDictionary = true; } data.Properties = new Dictionary <string, PropertyMetadata> (); foreach (PropertyInfo p_info in typeInfo.GetProperties()) { if (p_info.Name == "Item") { ParameterInfo[] parameters = p_info.GetIndexParameters(); if (parameters.Length != 1) { continue; } if (parameters[0].ParameterType == typeof(string)) { data.ElementType = p_info.PropertyType; } continue; } if (data.IsDictionary && dictionary_properties_to_ignore.Contains(p_info.Name)) { continue; } PropertyMetadata p_data = new PropertyMetadata(); p_data.Info = p_info; p_data.Type = p_info.PropertyType; data.Properties.Add(p_info.Name, p_data); } foreach (FieldInfo f_info in typeInfo.GetFields()) { PropertyMetadata p_data = new PropertyMetadata(); p_data.Info = f_info; p_data.IsField = true; p_data.Type = f_info.FieldType; data.Properties.Add(f_info.Name, p_data); } lock (object_metadata_lock) { try { object_metadata.Add(type, data); } catch (ArgumentException) { return; } } }
public List <int> GetShareByUserId(Guid Userid) { List <int> lstShareCount = new List <int>(); using (NHibernate.ISession session = SessionFactory.GetNewSession()) { using (NHibernate.ITransaction transaction = session.BeginTransaction()) { try { int year = DateTime.Now.Year; for (int i = 1; i < 13; i++) { string month = "0"; if (i < 10) { month = month + i.ToString(); } else { month = i.ToString(); } List <FacebookStats> lstFacebookStats = session.CreateQuery("from FacebookStats where EntryDate Like :yearMonth and UserId= :userId ") .SetParameter("userId", Userid) .SetParameter("yearMonth", "%" + year + "-" + (month) + "%", TypeFactory.GetAnsiStringType(15)).List <FacebookStats>().ToList <FacebookStats>(); //"%" + year + "-" + (month) + "%" lstShareCount.Add(lstFacebookStats.Count); } } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } return(lstShareCount); } } }
public FramePointerFragment(TypeFactory factory) { this.factory = factory; }
public DataImportedMap() { Mutable(false); Table("FIAXINTFTABLE"); Where("REFTABLEID in (175, 152, 262)"); Id(x => x.Id, map => { map.Column("RECID"); map.Generator(Generators.Assigned); map.Type((IIdentifierType)TypeFactory.Basic(typeof(long).FullName)); }); Discriminator(dm => { dm.Column("REFTABLEID"); dm.NotNullable(true); dm.Insert(false); }); Property(p => p.TypeData, m => { m.Access(Accessor.Field); m.Column("REFTABLEID"); m.Type(NHibernate.NHibernateUtil.GuessType(typeof(TypeData))); }); //Property(x => x.REFID, map => { map.Column("REFID"); map.Length(40); map.NotNullable(false); }); //Property(x => x.REFID1, map => { map.Column("REFID1"); map.Length(40); map.NotNullable(false); }); Property(x => x.Action, map => { map.Column("ACTION"); map.NotNullable(false); map.Type(NHibernate.NHibernateUtil.GuessType(typeof(Domain.Interface.Action))); }); Property(x => x.Status, map => { map.Column("STATUS"); map.NotNullable(false); map.Type(NHibernate.NHibernateUtil.GuessType(typeof(Domain.Interface.Status))); }); Property(x => x.Message, map => { map.Column("MESSAGE"); map.Length(254); map.NotNullable(false); }); //Property(x => x.REFID2, map => { map.Column("REFID2"); map.Length(40); map.NotNullable(false); }); Property(x => x.RecId, map => { map.Column("REFRECID"); map.NotNullable(false); }); Property(x => x.ModifiedDate, map => { map.Column("MODIFIEDDATE"); map.NotNullable(false); }); Property(x => x.ModifiedTime, map => { map.Column("MODIFIEDTIME"); map.NotNullable(false); }); //Property(x => x.CREATEDDATE, map => { map.Column("CREATEDDATE"); map.NotNullable(false); }); //Property(x => x.CREATEDTIME, map => { map.Column("CREATEDTIME"); map.NotNullable(false); }); Property(x => x.CreatedBy, map => { map.Column("CREATEDBY"); map.Length(5); map.NotNullable(false); }); Property(x => x.DataAreaId, map => { map.Column("DATAAREAID"); map.Length(3); map.NotNullable(false); }); //Property(x => x.RECVERSION, map => { map.Column("RECVERSION"); map.NotNullable(false); }); }
public async Task MappedAsShouldUseExplicitSizeAsync() { Driver.ClearCommands(); using (var session = OpenSession()) using (var transaction = session.BeginTransaction()) { await(session.Query <Entity>().Where(x => x.Name == "Bob".MappedAs(TypeFactory.Basic("AnsiString(200)"))).ToListAsync()); Assert.That(Driver.LastCommandParameters.First().Size, Is.EqualTo(200)); Assert.That(Driver.LastCommandParameters.First().SqlDbType, Is.EqualTo(SqlDbType.VarChar)); } }
public FSharpValField([NotNull] ValField declaration, [NotNull] FSharpField field) : base(declaration) { Field = field; Type = FSharpTypesUtil.GetType(field.FieldType, declaration, Module) ?? TypeFactory.CreateUnknownType(Module); }
public static TypeFactory GetInstance() { if (instance == null) instance = new TypeFactory(); return instance; }
public void GetConcreteType_NoTypeGenerated_IfGeneratedTypeIsGiven() { Type concreteType = TypeFactory.GetConcreteType(typeof(BaseType1)); Assert.That(TypeFactory.GetConcreteType(concreteType), Is.SameAs(concreteType)); }
/// <GetTaskCommentByUserIdAndYear> /// Get Task Comment By User Id And Year /// </summary> /// <param name="Userid">User id (Guid)</param> /// <returns>List of comment count according to year.(List<int>)</returns> public List <int> GetTaskCommentByUserIdAndYear(Guid Userid) { List <int> lstShareCount = new List <int>(); //Creates a database connection and opens up a session using (NHibernate.ISession session = SessionFactory.GetNewSession()) { //After Session creation, start Transaction. using (NHibernate.ITransaction transaction = session.BeginTransaction()) { try { //int year = DateTime.Now.Year; List <string> lstYear = GetLastYears(); for (int i = 0; i < 12; i++) { //Get the year from list. string year = lstYear[i]; //Proceed action, to get the data according to year and user id. List <TaskComment> lstFacebookStats = session.CreateQuery("from TaskComment where CommentDate Like :year and UserId= :userId ") .SetParameter("userId", Userid) .SetParameter("year", "%" + year + "%", TypeFactory.GetAnsiStringType(15)).List <TaskComment>().ToList <TaskComment>(); //add in list lstShareCount.Add(lstFacebookStats.Count); }//End For loop } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } return(lstShareCount); } //End Transaction } //End Session }
private static IList <CustomerOrderHistory> GetCustomerOrderHistory(string customerId, IResultTransformer transformer) { var query = UnitOfWork.CurrentSession.GetNamedQuery("NSoft.NFramework.Data.NHibernateEx.Domain.Northwind.GetCustomerOrderHistory", new NHParameter("CustomerId", customerId, TypeFactory.GetStringType(255))); query.SetResultTransformer(transformer); return(query.List <CustomerOrderHistory>()); }
private ChannelTypeFactory() { _typeImages = new Dictionary<string, string>(19); _typeImages.Add("VIP尊享", "ms-appx:///Images/Channels/vip.png"); _typeImages.Add("电影", "ms-appx:///Images/Channels/movie.png"); _typeImages.Add("电视剧", "ms-appx:///Images/Channels/teleplay.png"); _typeImages.Add("动漫", "ms-appx:///Images/Channels/cartoon.png"); _typeImages.Add("综艺", "ms-appx:///Images/Channels/show.png"); _typeImages.Add("体育", "ms-appx:///Images/Channels/sports.png"); _typeImages.Add("热点", "ms-appx:///Images/Channels/hot.png"); _typeImages.Add("游戏", "ms-appx:///Images/Channels/game.png"); _typeImages.Add("推荐分类", "ms-appx:///Images/Channels/recommend.png"); _typeImages.Add("旅游", "ms-appx:///Images/Channels/travel.png"); _typeImages.Add("生活", "ms-appx:///Images/Channels/life.png"); _typeImages.Add("时尚", "ms-appx:///Images/Channels/modern.png"); _typeImages.Add("音乐", "ms-appx:///Images/Channels/music.png"); _typeImages.Add("娱乐", "ms-appx:///Images/Channels/flower.png"); _typeImages.Add("搞笑", "ms-appx:///Images/Channels/funny.png"); _typeImages.Add("最近观看", "ms-appx:///Images/Channels/history.png"); _typeImages.Add("我的收藏", "ms-appx:///Images/Channels/favoriten.png"); _typeImages.Add("已下载", "ms-appx:///Images/Channels/downed.png"); _typeImages.Add("直播", "ms-appx:///Images/Channels/live.png"); _defaultImage = "ms-appx:///Images/Channels/default.png"; _channelTypeSettingKey = "ChannelTypeSettingKey"; _localTypes = new ChannelTypeItem[] { new ChannelTypeItem(){TypeId = RecentTypeId, TypeName="最近观看", ImageUri=_defaultImage}, new ChannelTypeItem(){TypeId = FavoritenTypeId, TypeName="我的收藏", ImageUri=_defaultImage}, new ChannelTypeItem(){TypeId = DownloadedTypeId, TypeName="已下载", ImageUri=_defaultImage}, new ChannelTypeItem(){TypeId = LiveTypeId, TypeName="直播", ImageUri = _defaultImage} }; _allViewModel = new ChannelTypeViewModel(); _allViewModel.Groups = new ObservableCollection<ChannelTypeGroup>(); _selectedViewModel = new ObservableCollection<ChannelTypeItem>(); _selectedViewModel.CollectionChanged += selectedTypes_CollectionChanged; _typeFactory = new TypeFactory(); _typeFactory.HttpSucessHandler += typeFactory_HttpSucess; _typeFactory.HttpFailorTimeOut += HttpFailorTimeOut; }
public void Setup() { store = new TypeStore(); factory = new TypeFactory(); pb = new ProgramBuilder(); }
public AddAttributesAndAttributeDependencies(IType type, TypeDefinition typeDefinition, TypeFactory typeFactory) { _type = type; _typeDefinition = typeDefinition; _typeFactory = typeFactory; }
public void Setup() { store = new TypeStore(); factory = new TypeFactory(); nct = new NestedComplexTypeExtractor(factory, store); }
/// <summary></summary> static TypeFactory() { Instance = new TypeFactory(); // set up the mappings of .NET Classes/Structs to their NHibernate types. RegisterDefaultNetTypes(); // add the mappings of the NHibernate specific names that are used in type="" RegisterBuiltInTypes(); }
private void DoToken(string token, QueryTranslator q) { if (q.IsName(StringHelper.Root(token))) //path expression { DoPathExpression(q.Unalias(token), q); } else if (token.StartsWith(ParserHelper.HqlVariablePrefix)) //named query parameter { q.AddNamedParameter(token.Substring(1)); // this is only a temporary parameter to help with the parsing of hql - // when the type becomes known then this will be converted to its real // parameter type. AppendToken(q, new SqlString(new object[] { new Parameter(StringHelper.SqlParameter) })); } else if (token.Equals(StringHelper.SqlParameter)) { //if the token is a "?" then we have a Parameter so convert it to a SqlCommand.Parameter // instead of appending a "?" to the WhereTokens q.AppendWhereToken(new SqlString(new object[] { new Parameter(StringHelper.SqlParameter) })); } else { IQueryable persister = q.GetPersisterUsingImports(token); if (persister != null) // the name of a class { object discrim = persister.DiscriminatorSQLValue; if (InFragment.Null == discrim || InFragment.NotNull == discrim) { throw new QueryException("subclass test not allowed for null or not null discriminator"); } AppendToken(q, discrim.ToString()); } else { object constant; string fieldName = null; string typeName = null; string importedName = null; int indexOfDot = token.IndexOf(StringHelper.Dot); // don't even bother to do the lookups if the indexOfDot is not // greater than -1. This will save all the string modifications. // This allows us to resolve to the full type before obtaining the value e.g. FooStatus.OFF -> NHibernate.Model.FooStatus.OFF if (indexOfDot > -1) { fieldName = StringHelper.Unqualify(token); typeName = StringHelper.Qualifier(token); importedName = q.factory.GetImportedClassName(typeName); } if (indexOfDot > -1 && (constant = ReflectHelper.GetConstantValue(importedName, fieldName)) != null) { // need to get the NHibernate Type so we can convert the Enum or field from // a class into it's string representation for hql. IType type; try { type = TypeFactory.HeuristicType(constant.GetType().AssemblyQualifiedName); } catch (MappingException me) { throw new QueryException(me); } if (type == null) { throw new QueryException(string.Format("Could not determin the type of: {0}", token)); } try { AppendToken(q, (( ILiteralType )type).ObjectToSQLString(constant)); } catch (Exception e) { throw new QueryException("Could not format constant value to SQL literal: " + token, e); } } else { //anything else string negatedToken = negated ? ( string )negations[token.ToLower(System.Globalization.CultureInfo.InvariantCulture)] : null; if (negatedToken != null && (!betweenSpecialCase || !"or".Equals(negatedToken))) { AppendToken(q, negatedToken); } else { AppendToken(q, token); } } } } }