/// <exception cref="System.Exception"></exception> public virtual void TestRetrieval() { Fixture().ResetConfig(); var config = Fixture().Config(); IReflector reflector = new ExcludingReflector(new[] { typeof(Before ) }); config.ReflectWith(reflector); var alias = new TypeAlias(typeof(Before), typeof(After)); config.AddAlias(alias); Reopen(); var after = ((After )RetrieveOnlyInstance(typeof(After))); Assert.AreEqual(0, after._id); config = Fixture().Config(); config.ReflectWith(new ExcludingReflector(new Type[] {})); config.RemoveAlias(alias); Reopen(); var before = ((Before )RetrieveOnlyInstance(typeof(Before))); Assert.AreEqual(42, before._id); }
/// <exception cref="System.Exception"></exception> public virtual void Test() { Fixture().ResetConfig(); IConfiguration config = Fixture().Config(); config.ReflectWith(((IReflector)ExcludingReflector.Value)); TypeAlias alias = new TypeAlias(typeof(RemovedClassRefactoringTestSuite.Sub), typeof( RemovedClassRefactoringTestSuite.NoSuper)); config.AddAlias(alias); if ((((bool)DoDefragment.Value))) { Defragment(); } else { Reopen(); } RemovedClassRefactoringTestSuite.NoSuper result = ((RemovedClassRefactoringTestSuite.NoSuper )RetrieveOnlyInstance(typeof(RemovedClassRefactoringTestSuite.NoSuper))); Assert.AreEqual("sub", result._subField); RemovedClassRefactoringTestSuite.NoSuper newSuper = new RemovedClassRefactoringTestSuite.NoSuper ("foo"); Store(newSuper); IQuery q = NewQuery(typeof(RemovedClassRefactoringTestSuite.NoSuper)); q.Descend("_subField").Constrain("foo"); IObjectSet objectSet = q.Execute(); Assert.AreEqual(1, objectSet.Count); result = ((RemovedClassRefactoringTestSuite.NoSuper)objectSet.Next()); Assert.AreEqual("foo", result._subField); Db().Refresh(result, int.MaxValue); }
/// <summary> /// Get parameter declaration for a method /// </summary> /// <param name="p"></param> /// <returns></returns> public static string GetParamDeclaration(ParameterInfo[] p) { StringBuilder s = new StringBuilder(); s.Append(Token.OPEN_PARENTHESE); if (p.HasElement()) { List <string> declaration = new List <string>(); for (int i = 0; i < p.Length; ++i) { string outRefParam = IsOut(p[i]) ? OUT : IsRef(p[i]) ? REF : IsParams(p[i]) ? PARAMS : DEFAULT; string d = string.Format("{0} {1} {2}", outRefParam, TypeAlias.GetName(p[i].ParameterType).Replace(Token.AMP, Token.EMPTY), p[i].Name); declaration.Add(d.Trim()); } s.Append(declaration.ListElementsToString(Token.COMMA + Token.SPACE)); } s.Append(Token.CLOSE_PERENTHESE); return(s.ToString()); }
/// <summary> /// Adds a named TypeAlias to the list of available TypeAlias. /// </summary> /// <param name="key">The key name.</param> /// <param name="typeAlias"> The TypeAlias.</param> public void AddTypeAlias(string key, TypeAlias typeAlias) { if (typeAliasMaps.ContainsKey(key)) { throw new DataMapperException(" Alias name conflict occurred. The type alias '" + key + "' is already mapped to the value '" + typeAlias + "'."); } typeAliasMaps.Add(key, typeAlias); }
/// <summary> /// Adds a named TypeAlias to the list of available TypeAlias. /// </summary> /// <param name="key">The key name.</param> /// <param name="typeAlias"> The TypeAlias.</param> internal void AddTypeAlias(string key, TypeAlias typeAlias) { if (_typeAliasMaps.Contains(key) == true) { throw new DataMapperException(" Alias name conflict occurred. The type alias '" + key + "' is already mapped to the value '" + typeAlias.ClassName + "'."); } _typeAliasMaps.Add(key, typeAlias); }
public override TypeAlias VisitTypeAlias(TypeAlias tAlias) { if (tAlias == null) { return(tAlias); } this.AddNodePositionAndInfo(tAlias, tAlias, IdentifierContexts.TypeContext); return(tAlias); }
internal Type GetType(string className) { TypeAlias typeAlias = this.GetTypeAlias(className); if (typeAlias != null) { return(typeAlias.Class); } return(TypeUtils.ResolveType(className)); }
/// <summary> /// Builds the type alias. /// </summary> /// <param name="store">The store.</param> private void BuildTypeAlias(IConfigurationStore store) { //_configScope.ErrorContext.Resource = nodeDataSource.OuterXml.ToString(); //_configScope.ErrorContext.MoreInfo = "parse DataSource"; for (int i = 0; i < store.Alias.Length; i++) { TypeAlias typeAlias = TypeAliasDeSerializer.Deserialize(store.Alias[i]); modelStore.DataExchangeFactory.TypeHandlerFactory.AddTypeAlias(typeAlias.Id, typeAlias); } }
public static string GetMethodSignature(MethodInfo methodInfo) { List <string> alias = new List <string>(); foreach (var param in methodInfo.GetParameters()) { alias.Add(TypeAlias.GetPrimitiveTypeAlias(param.ParameterType)); } return(string.Join(" ", alias)); }
protected override string GetResourceName(TypeAlias ta) { //if (!SimPe.Custom.Settings.SimNames) return base.GetResourceName(ta); ExtSDesc sdsc = FileTable.ProviderRegistry.SimDescriptionProvider.FindSim((ushort)this.FileDescriptor.Instance) as ExtSDesc; if (sdsc == null) { return(base.GetResourceName(ta)); } else { return(sdsc.SimName + " " + sdsc.SimFamilyName + " (Scores)"); } }
public static void Deserialize(XmlNode node, ConfigurationScope configScope) { TypeAlias typeAlias = new TypeAlias(); configScope.ErrorContext.MoreInfo = "loading type alias"; NameValueCollection attributes = NodeUtils.ParseAttributes(node, configScope.Properties); typeAlias.Name = NodeUtils.GetStringAttribute(attributes, "alias"); typeAlias.ClassName = NodeUtils.GetStringAttribute(attributes, "type"); configScope.ErrorContext.ObjectId = typeAlias.ClassName; configScope.ErrorContext.MoreInfo = "initialize type alias"; typeAlias.Initialize(); configScope.SqlMapper.TypeHandlerFactory.AddTypeAlias(typeAlias.Name, typeAlias); }
private void SetDefaultValues(ref MemberDeclaration d) { if (string.IsNullOrEmpty(d.accessModifier)) { d.accessModifier = AccessModifier.PUBLIC; } if (string.IsNullOrEmpty(d.inheritance)) { d.inheritance = Inheritance.DEFAULT; } if (string.IsNullOrEmpty(d.scope)) { d.scope = Scope.METHOD; } d.typeAlias = TypeAlias.GetName(d.type); }
/// <summary> /// Gets the type object from the specific class name. /// </summary> /// <param name="className">The supplied class name.</param> /// <returns>The correpsonding type. /// </returns> internal Type GetType(string className) { Type type = null; TypeAlias typeAlias = this.GetTypeAlias(className) as TypeAlias; if (typeAlias != null) { type = typeAlias.Class; } else { type = TypeUtils.ResolveType(className); } return(type); }
/// <exception cref="System.Exception"></exception> public virtual void Test() { TypeAlias alias = new TypeAlias(typeof(ReAddFieldTestCase.Version1), typeof(ReAddFieldTestCase.Version2 )); Fixture().Config().AddAlias(alias); Reopen(); Assert.AreEqual(42, ((ReAddFieldTestCase.Version2)RetrieveOnlyInstance(typeof(ReAddFieldTestCase.Version2 ))).id); Fixture().Config().RemoveAlias(alias); Reopen(); ReAddFieldTestCase.Version1 original = ((ReAddFieldTestCase.Version1)RetrieveOnlyInstance (typeof(ReAddFieldTestCase.Version1))); Assert.AreEqual("ltuae", original.name); Assert.AreEqual(42, original.id); }
/// <summary> /// Gets the type object from the specific class name. /// </summary> /// <param name="className">The supplied class name.</param> /// <returns>The correpsonding type. /// </returns> public Type GetType(string className) { Type type = null; if (typeAliasMaps.ContainsKey(className)) { TypeAlias typeAlias = GetTypeAlias(className); type = typeAlias.Type; } else { type = TypeUtils.ResolveType(className); } return(type); }
// // BUGBUG: temporary workaround for CCI bug // public override TypeAlias VisitTypeAlias(TypeAlias tAlias) { if (tAlias == null) return null; TypeAlias dup = (TypeAlias)this.DuplicateFor[tAlias.UniqueKey]; if (dup != null) return dup; this.DuplicateFor[tAlias.UniqueKey] = dup = (TypeAlias)tAlias.Clone(); dup.Name = tAlias.Name; if (tAlias.AliasedType is ConstrainedType) //The type alias defines the constrained type, rather than just referencing it dup.AliasedType = this.VisitConstrainedType((ConstrainedType)tAlias.AliasedType); else dup.AliasedType = this.VisitTypeReference(tAlias.AliasedType); dup.DeclaringType = this.TargetType; dup.DeclaringModule = this.TargetModule; dup.ProvideMembers(); return dup; }
/// <summary> /// Gets the type object from the specific class name. /// </summary> /// <param name="className">The supplied class name.</param> /// <returns>The correpsonding type. /// </returns> public Type GetType(string className) { Type type = null; //别名中是否包含所要的类名称 有取出 if (typeAliasMaps.ContainsKey(className)) { TypeAlias typeAlias = GetTypeAlias(className); type = typeAlias.Type; } else //否则,解析当前类名称 { type = TypeUtils.ResolveType(className); } return(type); }
internal static KotlinTypeAlias FromProtobuf(TypeAlias ta, JvmNameResolver resolver) { if (ta is null) { return(null); } return(new KotlinTypeAlias { Flags = ta.Flags, Name = resolver.GetString(ta.Name), TypeParameters = ta.TypeParameters?.Select(tp => KotlinTypeParameter.FromProtobuf(tp, resolver)).ToList(), UnderlyingType = KotlinType.FromProtobuf(ta.UnderlyingType, resolver), UnderlyingTypeId = ta.UnderlyingTypeId, ExpandedType = KotlinType.FromProtobuf(ta.ExpandedType, resolver), ExpandedTypeId = ta.ExpandedTypeId, VersionRequirements = ta.VersionRequirements }); }
/// <summary> /// Builds the type alias. /// </summary> /// <param name="store">The store.</param> private void BuildTypeAlias(IConfigurationStore store) { //_configScope.ErrorContext.Resource = nodeDataSource.OuterXml.ToString(); //_configScope.ErrorContext.MoreInfo = "parse DataSource"; /* * <alias> * <typeAlias alias="HundredsBool" type="MyBatis.DataMapper.SqlClient.Test.Domain.HundredsTypeHandlerCallback, MyBatis.DataMapper.SqlClient.Test"/> * <typeAlias alias="Category2" type="MyBatis.DataMapper.SqlClient.Test.Domain.Category, MyBatis.DataMapper.SqlClient.Test"/> * <typeAlias alias="genericList" type="MyBatis.DataMapper.SqlClient.Test.Domain.ListeEntiteMetier`1[[MyBatis.DataMapper.SqlClient.Test.Domain.Account, MyBatis.DataMapper.SqlClient.Test]], MyBatis.DataMapper.SqlClient.Test" /> * </alias> */ //store中的Alias字典直接保存的就是typeAlias节点信息 for (int i = 0; i < store.Alias.Length; i++) { TypeAlias typeAlias = TypeAliasDeSerializer.Deserialize(store.Alias[i]); modelStore.DataExchangeFactory.TypeHandlerFactory.AddTypeAlias(typeAlias.Id, typeAlias); } }
/// <exception cref="System.Exception"></exception> public virtual void TestRetrieval() { Fixture().ResetConfig(); IConfiguration config = Fixture().Config(); IReflector reflector = new ExcludingReflector(new Type[] { typeof(RemovedFieldDefragmentTestCase.Before ) }); config.ReflectWith(reflector); TypeAlias alias = new TypeAlias(typeof(RemovedFieldDefragmentTestCase.Before), typeof( RemovedFieldDefragmentTestCase.After)); config.AddAlias(alias); Defragment(); RemovedFieldDefragmentTestCase.After after = ((RemovedFieldDefragmentTestCase.After )RetrieveOnlyInstance(typeof(RemovedFieldDefragmentTestCase.After))); config = Fixture().Config(); config.ReflectWith(new ExcludingReflector(new Type[] { })); config.RemoveAlias(alias); Reopen(); RemovedFieldDefragmentTestCase.Before before = ((RemovedFieldDefragmentTestCase.Before )RetrieveOnlyInstance(typeof(RemovedFieldDefragmentTestCase.Before))); Assert.AreEqual(42, before._id); }
public override TypeAlias VisitTypeAlias(TypeAlias tAlias) { if (tAlias == null) return tAlias; this.AddNodePositionAndInfo(tAlias, tAlias, IdentifierContexts.TypeContext); return tAlias; }
public override TypePrinterResult VisitTypeAliasDecl(TypeAlias typeAlias) { return(VisitDeclaration(typeAlias)); }
public override TypeAlias VisitTypeAlias(TypeAlias tAlias){ if (tAlias == null) return null; this.VisitResolvedTypeReference(tAlias.AliasedType, tAlias.AliasedTypeExpression); return base.VisitTypeAlias(tAlias); }
public override TypeAlias VisitTypeAlias(TypeAlias tAlias){ if (this.currentType == null) this.currentType = tAlias; TypeAlias result = (TypeAlias)base.VisitTypeAlias(tAlias); if (this.currentType == tAlias) this.currentType = null; if (result == null) return null; result.ProvideMembers(); return result; }
private TypeAlias(TypeAlias.__Internal native, bool skipVTables = false) : this(__CopyValue(native), skipVTables) { __ownsNativeInstance = true; NativeToManagedMap[__Instance] = this; }
public override TypePrinterResult VisitTypeAliasDecl(TypeAlias typeAlias) { return(typeAlias.Name); }
public virtual TypeAlias VisitTypeAlias(TypeAlias tAlias, TypeAlias changes, TypeAlias deletions, TypeAlias insertions){ this.UpdateSourceContext(tAlias, changes); if (tAlias == null) return changes; if (changes != null){ if (deletions == null || insertions == null) Debug.Assert(false); else{ } }else if (deletions != null) return null; return tAlias; }
private void ParseNamespaceOrTypeDeclarations(Namespace parentNamespace, TokenSet followers){ if (this.currentToken == Token.Identifier){ TypeAlias ta = new TypeAlias(new TypeExpression(this.scanner.GetIdentifier()), Identifier.Empty); parentNamespace.Types.Add(ta); ta.SourceContext = this.scanner.CurrentSourceContext; this.GetNextToken(); return; } if (this.currentToken == Token.Private || this.currentToken == Token.Protected){ this.HandleError(Error.PrivateOrProtectedNamespaceElement); this.GetNextToken(); } if (this.currentToken == Token.Namespace){ SourceContext openContext = this.scanner.CurrentSourceContext; this.GetNextToken(); TokenSet nsFollowers = followers|Token.RightBrace; Identifier nsId = this.ParseNamespaceName(Identifier.Empty, false, nsFollowers|Token.LeftBrace); Identifier nsFullId = parentNamespace.Name == Identifier.Empty ? nsId : Identifier.For(parentNamespace.FullName+"."+nsId); Namespace ns = new Namespace(nsId, nsFullId, new AliasDefinitionList(), new UsedNamespaceList(), new NamespaceList(), new TypeNodeList()); ns.DeclaringNamespace = parentNamespace; ns.SourceContext = openContext; if (this.currentToken == Token.LeftBrace) openContext.EndPos = this.scanner.endPos; SourceContext nsBodyCtx = this.scanner.CurrentSourceContext; this.Skip(Token.LeftBrace); parentNamespace.NestedNamespaces.Add(ns); this.ParseExternalAliasDirectives(ns, nsFollowers|Parser.NamespaceOrTypeDeclarationStart|Token.Using|Token.LastIdentifier); this.ParseUsingDirectives(ns, nsFollowers|Token.LastIdentifier|Parser.NamespaceOrTypeDeclarationStart); this.ParseNamespaceMemberDeclarations(ns, nsFollowers); if (this.currentToken == Token.RightBrace && this.sink != null) this.sink.MatchPair(openContext, this.scanner.CurrentSourceContext); ns.SourceContext.EndPos = this.scanner.endPos; this.Skip(Token.RightBrace); if (this.currentToken == Token.Semicolon) this.GetNextToken(); if (this.sink != null){ nsBodyCtx.EndPos = this.scanner.endPos; this.sink.AddCollapsibleRegion(nsBodyCtx, false); } }else this.ParseTypeDeclarations(parentNamespace, followers); if (!followers[this.currentToken]) this.SkipTo(followers, Error.EOFExpected); }
private static string[] GenerateCode() { Type painterInterface = PainterType == PAINTER_TYPE_GEOMETRY_TEXTURE ? typeof(IGTexturePainter) : PainterType == PAINTER_TYPE_FOLIAGE ? typeof(IGFoliagePainter) : PainterType == PAINTER_TYPE_OBJECT ? typeof(IGObjectPainter) : null; //Declare it TypeDeclaration d = new TypeDeclaration.Builder() .SetAccessModifier(AccessModifier.PUBLIC) .SetIsStatic(false) .SetInheritance(Inheritance.DEFAULT) .SetScope(Scope.CLASS) .SetName(PainterName.RemoveSpecialCharacters()) .SetInterfaces(painterInterface) .Build(); //Import regularly used namespaces, just call a Using(...) if you need more UsingNode un = new UsingNode() .Using("UnityEngine") .Using("System.Collections") .Using("System.Collections.Generic") .Using("Pinwheel.Griffin") .Using("Pinwheel.Griffin.PaintTool"); //Import the base class namespace to simplify its name in the declaration string if (d.baseClass != null) { un.Using(d.baseClass.Namespace); } //The same for interfaces if (d.implementedInterface.HasElement()) { for (int i = 0; i < d.implementedInterface.Count; ++i) { un.Using(d.implementedInterface[i].Namespace); } } //Give it a hint to determine type names TypeAlias.SetUsingNode(un); List <string> code = new List <string>(); //Implement the type TypeNode tn = new TypeNode() .Declare(d) .Implement(code); //Put the new type into the namespace //NamespaceNode nn = new NamespaceNode() // .SetName("CustomPainter") // .SetTypes(tn); //Put everything into a script ScriptNode sn = new ScriptNode() .SetCompilationDirective("GRIFFIN") .SetUsing(un) //.SetNamespace(nn) .SetTypes(tn); //also set type in case namespace is empty //Now make the code look awesome CodeFormatter formatter = new CodeFormatter(); formatter.addSpaceAfterUsings = true; formatter.addSpaceBetweenMethods = true; formatter.bracketStyle = CodeFormatter.OpenCurlyBracketStyle.NewLine; string[] script = formatter.Format(sn); return(script); //phew... }
public bool VisitTypeAliasDecl(TypeAlias typeAlias) { throw new NotImplementedException(); }
public virtual TypeAlias VisitTypeAlias(TypeAlias tAlias1, TypeAlias tAlias2){ if (tAlias1 == null) return null; if (tAlias2 == null){ if (tAlias1.AliasedType is ConstrainedType) //The type alias defines the constrained type, rather than just referencing it tAlias1.AliasedType = this.VisitConstrainedType((ConstrainedType)tAlias1.AliasedType, null); else tAlias1.AliasedType = this.VisitTypeReference(tAlias1.AliasedType, null); }else{ if (tAlias1.AliasedType is ConstrainedType) //The type alias defines the constrained type, rather than just referencing it tAlias1.AliasedType = this.VisitConstrainedType((ConstrainedType)tAlias1.AliasedType, tAlias2.AliasedType as ConstrainedType); else tAlias1.AliasedType = this.VisitTypeReference(tAlias1.AliasedType, tAlias2.AliasedType); } return tAlias1; }
public override TypeAlias VisitTypeAlias(TypeAlias tAlias) { throw new NotImplementedException("Node type not yet supported"); }
public CSharpTypePrinterResult VisitTypeAliasDecl(TypeAlias typeAlias) { return(GetNestedQualifiedName(typeAlias)); }
public static TypeAlias __CreateInstance(TypeAlias.__Internal native, bool skipVTables = false) { return new TypeAlias(native, skipVTables); }
public bool VisitTypeAliasDecl(TypeAlias typeAlias) { return(false); }
private static void* __CopyValue(TypeAlias.__Internal native) { var ret = Marshal.AllocHGlobal(140); global::CppSharp.Parser.AST.TypeAlias.__Internal.cctor_1(ret, new global::System.IntPtr(&native)); return ret.ToPointer(); }
public virtual TypePrinterResult VisitTypeAliasDecl(TypeAlias typeAlias) { return(VisitDeclaration(typeAlias)); }
/// <summary> /// Builds the the MyBatis core model (statement, alias, resultMap, parameterMap, dataSource) /// from an <see cref="IConfigurationStore"/> and store all the refrences in an <see cref="IModelStore"/> . /// </summary> /// <param name="configurationSetting">The configuration setting.</param> /// <param name="store">The configuration store.</param> /// <returns>The model store</returns> public virtual void BuildModel(ConfigurationSetting configurationSetting, IConfigurationStore store) { IObjectFactory objectFactory = null; IGetAccessorFactory getAccessorFactory = null; ISetAccessorFactory setAccessorFactory = null; ISessionFactory sessionFactory = null; ISessionStore sessionStore = null; if (configurationSetting != null) { objectFactory = configurationSetting.ObjectFactory; setAccessorFactory = configurationSetting.SetAccessorFactory; getAccessorFactory = configurationSetting.GetAccessorFactory; dataSource = configurationSetting.DataSource; sessionFactory = configurationSetting.SessionFactory; sessionStore = configurationSetting.SessionStore; dynamicSqlEngine = configurationSetting.DynamicSqlEngine; isCacheModelsEnabled = configurationSetting.IsCacheModelsEnabled; useStatementNamespaces = configurationSetting.UseStatementNamespaces; useReflectionOptimizer = configurationSetting.UseReflectionOptimizer; preserveWhitespace = configurationSetting.PreserveWhitespace; } // Xml setting override code setting LoadSetting(store); if (objectFactory == null) { objectFactory = new ObjectFactory(useReflectionOptimizer); } if (setAccessorFactory == null) { setAccessorFactory = new SetAccessorFactory(useReflectionOptimizer); } if (getAccessorFactory == null) { getAccessorFactory = new GetAccessorFactory(useReflectionOptimizer); } AccessorFactory accessorFactory = new AccessorFactory(setAccessorFactory, getAccessorFactory); TypeHandlerFactory typeHandlerFactory = new TypeHandlerFactory(); TypeAlias alias = new TypeAlias("MEMORY", typeof(PerpetualCache)); typeHandlerFactory.AddTypeAlias(alias.Id, alias); alias = new TypeAlias("Perpetual", typeof(PerpetualCache)); typeHandlerFactory.AddTypeAlias(alias.Id, alias); alias = new TypeAlias("LRU", typeof(LruCache)); typeHandlerFactory.AddTypeAlias(alias.Id, alias); alias = new TypeAlias("Lru", typeof(LruCache)); typeHandlerFactory.AddTypeAlias(alias.Id, alias); alias = new TypeAlias("FIFO", typeof(FifoCache)); typeHandlerFactory.AddTypeAlias(alias.Id, alias); alias = new TypeAlias("Fifo", typeof(FifoCache)); typeHandlerFactory.AddTypeAlias(alias.Id, alias); alias = new TypeAlias("Weak", typeof(WeakCache)); typeHandlerFactory.AddTypeAlias(alias.Id, alias); alias = new TypeAlias("WEAK", typeof(WeakCache)); typeHandlerFactory.AddTypeAlias(alias.Id, alias); alias = new TypeAlias("AnsiStringTypeHandler", typeof(AnsiStringTypeHandler)); typeHandlerFactory.AddTypeAlias(alias.Id, alias); modelStore.DataExchangeFactory = new DataExchangeFactory(typeHandlerFactory, objectFactory, accessorFactory); if (sessionStore == null) { sessionStore = SessionStoreFactory.GetSessionStore(modelStore.Id); } modelStore.SessionStore = sessionStore; deSerializerFactory = new DeSerializerFactory(modelStore); ParameterMap emptyParameterMap = new ParameterMap( ConfigConstants.EMPTY_PARAMETER_MAP, string.Empty, string.Empty, typeof(string), modelStore.DataExchangeFactory.GetDataExchangeForClass(null), false); modelStore.AddParameterMap(emptyParameterMap); BuildProviders(store); BuildDataSource(store); if (sessionFactory == null) { sessionFactory = new DefaultSessionFactory( dataSource, modelStore.SessionStore, new DefaultTransactionManager(new AdoTransactionFactory())); } modelStore.SessionFactory = sessionFactory; BuildTypeAlias(store); BuildTypeHandlers(store); BuildCacheModels(store); BuildResultMaps(store); for (int i = 0; i < nestedProperties.Count; i++) { ResultProperty property = nestedProperties[i]; property.NestedResultMap = modelStore.GetResultMap(property.NestedResultMapName); } for (int i = 0; i < discriminators.Count; i++) { discriminators[i].Initialize(modelStore); } BuildParameterMaps(store); BuildMappedStatements(store, configurationSetting); for (int i = 0; i < store.CacheModels.Length; i++) { CacheModel cacheModel = modelStore.GetCacheModel(store.CacheModels[i].Id); for (int j = 0; j < cacheModel.StatementFlushNames.Count; j++) { string statement = cacheModel.StatementFlushNames[j]; IMappedStatement mappedStatement = modelStore.GetMappedStatement(statement); if (mappedStatement != null) { cacheModel.RegisterTriggerStatement(mappedStatement); if (logger.IsDebugEnabled) { logger.Debug("Registering trigger statement [" + statement + "] to cache model [" + cacheModel.Id + "]"); } } else { if (logger.IsWarnEnabled) { logger.Warn("Unable to register trigger statement [" + statement + "] to cache model [" + cacheModel.Id + "]. Statement does not exist."); } } } } if (logger.IsInfoEnabled) { logger.Info("Model Store"); logger.Info(modelStore.ToString()); } }
public virtual Differences VisitTypeAlias(TypeAlias tAlias1, TypeAlias tAlias2){ Differences differences = this.GetMemberDifferences(tAlias1, tAlias2); if (differences == null){Debug.Assert(false); differences = new Differences(tAlias1, tAlias2);} if (differences.NumberOfDifferences > 0 || differences.NumberOfSimilarities > 0) return differences; if (tAlias1 == null || tAlias2 == null){ if (tAlias1 != tAlias2) differences.NumberOfDifferences++; else differences.NumberOfSimilarities++; return differences; } TypeAlias changes = (TypeAlias)tAlias2.Clone(); TypeAlias deletions = (TypeAlias)tAlias2.Clone(); TypeAlias insertions = (TypeAlias)tAlias2.Clone(); Differences diff = this.VisitTypeNode(tAlias1.AliasedType, tAlias2.AliasedType); if (diff == null){Debug.Assert(false); return differences;} changes.AliasedType = diff.Changes as TypeNode; deletions.AliasedType = diff.Deletions as TypeNode; insertions.AliasedType = diff.Insertions as TypeNode; //Debug.Assert(diff.Changes == changes.AliasedType && diff.Deletions == deletions.AliasedType && diff.Insertions == insertions.AliasedType); differences.NumberOfDifferences += diff.NumberOfDifferences; differences.NumberOfSimilarities += diff.NumberOfSimilarities; AttributeList attrChanges, attrDeletions, attrInsertions; diff = this.VisitAttributeList(tAlias1.Attributes, tAlias2.Attributes, out attrChanges, out attrDeletions, out attrInsertions); if (diff == null){Debug.Assert(false); return differences;} changes.Attributes = attrChanges; deletions.Attributes = attrDeletions; insertions.Attributes = attrInsertions; differences.NumberOfDifferences += diff.NumberOfDifferences; differences.NumberOfSimilarities += diff.NumberOfSimilarities; if (tAlias1.Flags == tAlias2.Flags) differences.NumberOfSimilarities++; else differences.NumberOfDifferences++; diff = this.VisitIdentifier(tAlias1.Name, tAlias2.Name); if (diff == null){Debug.Assert(false); return differences;} changes.Name = diff.Changes as Identifier; deletions.Name = diff.Deletions as Identifier; insertions.Name = diff.Insertions as Identifier; Debug.Assert(diff.Changes == changes.Name && diff.Deletions == deletions.Name && diff.Insertions == insertions.Name); differences.NumberOfDifferences += diff.NumberOfDifferences; differences.NumberOfSimilarities += diff.NumberOfSimilarities; TypeNodeList typeChanges, typeDeletions, typeInsertions; diff = this.VisitTypeNodeList(tAlias1.TemplateParameters, tAlias2.TemplateParameters, out typeChanges, out typeDeletions, out typeInsertions); if (diff == null){Debug.Assert(false); return differences;} changes.TemplateParameters = typeChanges; deletions.TemplateParameters = typeDeletions; insertions.TemplateParameters = typeInsertions; differences.NumberOfDifferences += diff.NumberOfDifferences; differences.NumberOfSimilarities += diff.NumberOfSimilarities; if (differences.NumberOfDifferences == 0){ differences.Changes = null; differences.Deletions = null; differences.Insertions = null; }else{ differences.Changes = changes; differences.Deletions = deletions; differences.Insertions = insertions; } return differences; }
void AddReadAlias( Block block, TypeAlias alias, StatementList statements, Identifier reader, Expression target, Expression required, Expression result) { Local local = new Local(Identifier.Empty, alias.AliasedType, block); AddReadRequiredChild(block, statements, alias.Name, alias.AliasedType, local, reader, result, required, true, true); statements.Add(new AssignmentStatement(target, this.tempChecker.typeSystem.ImplicitCoercion(local, target.Type))); }
private static string[] GenerateCode() { //Declare it TypeDeclaration d = new TypeDeclaration.Builder() .SetAccessModifier(AccessModifier.PUBLIC) .SetIsStatic(true) .SetInheritance(Inheritance.DEFAULT) .SetScope(Scope.CLASS) .SetName(ExtensionName.RemoveSpecialCharacters()) .Build(); //Import regularly used namespaces, just call a Using(...) if you need more UsingNode un = new UsingNode() .Using("UnityEngine") .Using("System.Collections") .Using("System.Collections.Generic") .Using("UnityEditor"); //Import the base class namespace to simplify its name in the declaration string if (d.baseClass != null) { un.Using(d.baseClass.Namespace); } //The same for interfaces if (d.implementedInterface.HasElement()) { for (int i = 0; i < d.implementedInterface.Count; ++i) { un.Using(d.implementedInterface[i].Namespace); } } //Give it a hint to determine type names TypeAlias.SetUsingNode(un); List <string> code = new List <string>(); //add basic function for an extension code.Add(GetExtensionNameCode()); code.Add(GetPublisherNameCode()); code.Add(GetDescriptionCode()); code.Add(GetVersionCode()); code.Add(GetOpenUserGuideCode()); code.Add(GetOpenSupportLinkCode()); code.Add(GetButtonMethodCode()); code.Add(GetOnGUICode()); //Implement the type TypeNode tn = new TypeNode() .Declare(d) .Implement(code); //Put the new type into the namespace NamespaceNode nn = new NamespaceNode() .SetName(string.Format("{0}.GriffinExtension", PublisherName.RemoveSpecialCharacters())) .SetTypes(tn); //Put everything into a script ScriptNode sn = new ScriptNode() .SetCompilationDirective("GRIFFIN && UNITY_EDITOR") .SetUsing(un) .SetNamespace(nn) .SetTypes(tn); //also set type in case namespace is empty //Now make the code look awesome CodeFormatter formatter = new CodeFormatter(); formatter.addSpaceAfterUsings = true; formatter.addSpaceBetweenMethods = true; formatter.bracketStyle = CodeFormatter.OpenCurlyBracketStyle.NewLine; string[] script = formatter.Format(sn); return(script); //phew... }
public string VisitTypeAliasDecl(TypeAlias typeAlias) { return(typeAlias.Name); }
public virtual TypeAlias VisitTypeAlias(TypeAlias tAlias){ if (tAlias == null) return null; if (tAlias.AliasedType is ConstrainedType) //The type alias defines the constrained type, rather than just referencing it tAlias.AliasedType = this.VisitConstrainedType((ConstrainedType)tAlias.AliasedType); else tAlias.AliasedType = this.VisitTypeReference(tAlias.AliasedType); return tAlias; }
public virtual bool VisitTypeAliasDecl(TypeAlias typeAlias) { return(VisitTypedefNameDecl(typeAlias)); }
public EventingVisitor(Action<TypeAlias> visitTypeAlias) { VisitedTypeAlias += visitTypeAlias; } public event Action<TypeAlias> VisitedTypeAlias; public override TypeAlias VisitTypeAlias(TypeAlias tAlias) { if (VisitedTypeAlias != null) VisitedTypeAlias(tAlias); return base.VisitTypeAlias(tAlias); }