예제 #1
0
        public static TheClass Get(CsEntity pCsEntity, FactoryExpressionCreator pCreator)
        {
            if (pCsEntity == null)
            {
                return(null);
            }

            while (pCsEntity != null)
            {
                if (pCsEntity is CsEntityClass || pCsEntity is CsEntityStruct || pCsEntity is CsEntityInterface)
                {
                    break;
                }

                pCsEntity = pCsEntity.parent;
            }

            CsEntityClass entityKlass = pCsEntity as CsEntityClass;

            if (entityKlass != null && entityKlass.nodes.Count != 0 && entityKlass.nodes.First.Value != null)
            {
                return(Get(entityKlass.nodes.First.Value, pCreator));
            }

            CsEntityStruct entityStruct = pCsEntity as CsEntityStruct;

            if (entityStruct != null && entityStruct.nodes.Count != 0 && entityStruct.nodes.First.Value != null)
            {
                return(Get(entityStruct.nodes.First.Value, pCreator));
            }

            CsEntityInterface entityInterface = pCsEntity as CsEntityInterface;

            if (entityInterface != null && entityInterface.nodes.Count != 0 && entityInterface.nodes.First.Value != null)
            {
                return(Get(entityInterface.nodes.First.Value, pCreator));
            }

            if (pCsEntity != null)
            {
                if (!_entities.ContainsKey(pCsEntity))
                {
                    _entities[pCsEntity] = new TheClass(pCsEntity, pCreator);
                }

                return(_entities[pCsEntity]);
            }

            throw new Exception();
        }
예제 #2
0
        //public static TheClass Get(CsEntity pEntity) {
        //    CsEntityClass typeRef = pEntity as CsEntityClass;
        //    if (typeRef != null) {
        //        CsClass theClass = typeRef.nodes.First.Value as CsClass;
        //        if (theClass == null) {
        //            return get(typeRef);
        //        }

        //        if (!_classes.ContainsKey(theClass))
        //            _classes[theClass] = new TheClass(theClass);

        //        return _classes[theClass];
        //    }

        //    CsEntityInterface entityInterface = pEntity as CsEntityInterface;


        //}

        public static TheClass Get(CsEntityTypeRef pEntityTyperef, FactoryExpressionCreator pCreator)
        {
            if (pEntityTyperef == null)
            {
                return(null);
            }

            if (
                pEntityTyperef.u is CsEntityGenericParam ||
                pEntityTyperef.u is CsEntityArraySpecifier
                )
            {
                return(null);
            }

            CsEntityInstanceSpecifier entityInstanceSpecifier = pEntityTyperef.u as CsEntityInstanceSpecifier;

            CsEntity entityClass = entityInstanceSpecifier == null
                                                                                        ? (CsEntity)pEntityTyperef.u
                                                                                        : (CsEntity)entityInstanceSpecifier.type.u;

            return(Get(entityClass, pCreator));
            //return Get(entityClass.nodes.First.Value);
        }
예제 #3
0
		public static TheClass Get(CsEntity pCsEntity, FactoryExpressionCreator pCreator) {
			if (pCsEntity == null)
				return null;

			while (pCsEntity != null) {
				if (pCsEntity is CsEntityClass || pCsEntity is CsEntityStruct || pCsEntity is CsEntityInterface) {
					break;
				}

				pCsEntity = pCsEntity.parent;
			}

			CsEntityClass entityKlass = pCsEntity as CsEntityClass;
			if (entityKlass != null && entityKlass.nodes.Count != 0 && entityKlass.nodes.First.Value != null) {
				return Get(entityKlass.nodes.First.Value, pCreator);
			}

			CsEntityStruct entityStruct = pCsEntity as CsEntityStruct;
			if (entityStruct != null && entityStruct.nodes.Count != 0 && entityStruct.nodes.First.Value != null) {
				return Get(entityStruct.nodes.First.Value, pCreator);
			}

			CsEntityInterface entityInterface = pCsEntity as CsEntityInterface;
			if (entityInterface != null && entityInterface.nodes.Count != 0 && entityInterface.nodes.First.Value != null) {
				return Get(entityInterface.nodes.First.Value, pCreator);
			}

			if (pCsEntity != null) {
				if (!_entities.ContainsKey(pCsEntity))
					_entities[pCsEntity] = new TheClass(pCsEntity, pCreator);

				return _entities[pCsEntity];
			}

			throw new Exception();
		}
예제 #4
0
        public TheClass(CsEntity pCsEntity, FactoryExpressionCreator pCreator)
        {
            IsEntity = true;
            List <string> name   = new List <string>();
            CsEntity      parent = pCsEntity.parent;

            while (parent != null && parent is CsEntityNamespace)
            {
                if (!string.IsNullOrEmpty(parent.name))
                {
                    name.Add(parent.name);
                }
                parent = parent.parent;
            }

            name.Reverse();

            NameSpace = string.Join(".", name.ToArray());
            //RealName = pCsEntity.name;
            //Name = Helpers.GetRealName(pCsEntity, RealName);
            Name = pCsEntity.name;

            FullName = NameSpace + "." + Name;
            //FullRealName = NameSpace + "." + RealName;

            CsEntityClass klass = pCsEntity as CsEntityClass;

            if (klass != null)
            {
                _baseEntityTyperef = klass.base_type;

                if (klass.base_type.type != cs_entity_type.et_object)
                {
                    Extends.Add(Helpers.GetType(klass.base_type));
                }

                if (klass.interfaces != null)
                {
                    foreach (CsEntityTypeRef @interface in klass.interfaces)
                    {
                        Implements.Add(Helpers.GetType(@interface));
                    }
                }

                Dictionary <string, int> methodNames = new Dictionary <string, int>();
                //bool constructorsDone = false;
                bool methodsDone = false;
                if (klass.method_implementations == null)
                {
                    return;
                }

                foreach (CsEntityMethodImplementation methodImplementation in klass.method_implementations)
                {
                    CsEntityMethod m  = methodImplementation.implementation_method;
                    TheMethod      tm = new TheMethod(m, this, pCreator);
                    if (methodNames.ContainsKey(tm.Name))
                    {
                        methodNames[tm.Name]++;
                        int index = tm._index = methodNames[tm.Name];

                        if (!methodsDone)
                        {
                            methodsDone = true;
                            foreach (KeyValuePair <CsMethod, TheMethod> method in _methods)
                            {
                                method.Value._isUnique = false;
                                method.Value._index    = --index;
                            }
                        }

                        tm._isUnique = false;
                    }
                    else
                    {
                        methodNames[tm.Name] = tm._index = 1;
                    }

                    _entityMethods.Add(m, tm);
                }

                return;
            }

            CsEntityInterface entityInterface = pCsEntity as CsEntityInterface;

            if (entityInterface != null)
            {
                _baseEntityTyperef = entityInterface.base_type;

                if (entityInterface.base_type.type != cs_entity_type.et_object)
                {
                    Extends.Add(Helpers.GetType(entityInterface.base_type));
                }

                if (entityInterface.interfaces != null)
                {
                    foreach (CsEntityTypeRef @interface in entityInterface.interfaces)
                    {
                        Implements.Add(Helpers.GetType(@interface));
                    }
                }

                Dictionary <string, int> methodNames = new Dictionary <string, int>();
                bool methodsDone = false;
                if (entityInterface.method_implementations == null)
                {
                    return;
                }

                foreach (CsEntityMethodImplementation methodImplementation in entityInterface.method_implementations)
                {
                    CsEntityMethod m  = methodImplementation.implementation_method;
                    TheMethod      tm = new TheMethod(m, this, pCreator);
                    if (methodNames.ContainsKey(tm.Name))
                    {
                        methodNames[tm.Name]++;
                        int index = tm._index = methodNames[tm.Name];

                        if (!methodsDone)
                        {
                            methodsDone = true;
                            foreach (KeyValuePair <CsMethod, TheMethod> method in _methods)
                            {
                                method.Value._isUnique = false;
                                method.Value._index    = --index;
                            }
                        }

                        tm._isUnique = false;
                    }
                    else
                    {
                        methodNames[tm.Name] = tm._index = 1;
                    }

                    _entityMethods.Add(m, tm);
                }

                return;
            }

            CsEntityStruct entityStruct = pCsEntity as CsEntityStruct;

            if (entityStruct != null)
            {
                _baseEntityTyperef = entityStruct.base_type;

                if (entityStruct.base_type.type != cs_entity_type.et_object)
                {
                    Extends.Add(Helpers.GetType(entityStruct.base_type));
                }

                if (entityStruct.interfaces != null)
                {
                    foreach (CsEntityTypeRef @interface in entityStruct.interfaces)
                    {
                        Implements.Add(Helpers.GetType(@interface));
                    }
                }

                Dictionary <string, int> methodNames = new Dictionary <string, int>();
                bool methodsDone = false;
                if (entityStruct.method_implementations == null)
                {
                    return;
                }

                foreach (CsEntityMethodImplementation methodImplementation in entityStruct.method_implementations)
                {
                    CsEntityMethod m  = methodImplementation.implementation_method;
                    TheMethod      tm = new TheMethod(m, this, pCreator);
                    if (methodNames.ContainsKey(tm.Name))
                    {
                        methodNames[tm.Name]++;
                        int index = tm._index = methodNames[tm.Name];

                        if (!methodsDone)
                        {
                            methodsDone = true;
                            foreach (KeyValuePair <CsMethod, TheMethod> method in _methods)
                            {
                                method.Value._isUnique = false;
                                method.Value._index    = --index;
                            }
                        }

                        tm._isUnique = false;
                    }
                    else
                    {
                        methodNames[tm.Name] = tm._index = 1;
                    }

                    _entityMethods.Add(m, tm);
                }

                return;
            }

            throw new NotImplementedException();
        }
예제 #5
0
		public TheClass(CsEntity pCsEntity, FactoryExpressionCreator pCreator) {
			IsEntity = true;
			List<string> name = new List<string>();
			CsEntity parent = pCsEntity.parent;

			while (parent != null && parent is CsEntityNamespace) {
				if (!string.IsNullOrEmpty(parent.name))
					name.Add(parent.name);
				parent = parent.parent;
			}

			name.Reverse();

			NameSpace = string.Join(".", name.ToArray());
			//RealName = pCsEntity.name;
			//Name = Helpers.GetRealName(pCsEntity, RealName);
			Name = pCsEntity.name;

			FullName = NameSpace + "." + Name;
			//FullRealName = NameSpace + "." + RealName;

			CsEntityClass klass = pCsEntity as CsEntityClass;
			if (klass != null) {
				_baseEntityTyperef = klass.base_type;

				if (klass.base_type.type != cs_entity_type.et_object)
					Extends.Add(Helpers.GetType(klass.base_type));

				if (klass.interfaces != null) {
					foreach (CsEntityTypeRef @interface in klass.interfaces) {
						Implements.Add(Helpers.GetType(@interface));
					}
				}

				Dictionary<string, int> methodNames = new Dictionary<string, int>();
				//bool constructorsDone = false;
				bool methodsDone = false;
				if (klass.method_implementations == null) {
					return;
				}

				foreach (CsEntityMethodImplementation methodImplementation in klass.method_implementations) {
					CsEntityMethod m = methodImplementation.implementation_method;
					TheMethod tm = new TheMethod(m, this, pCreator);
					if (methodNames.ContainsKey(tm.Name)) {
						methodNames[tm.Name]++;
						int index = tm._index = methodNames[tm.Name];

						if (!methodsDone) {
							methodsDone = true;
							foreach (KeyValuePair<CsMethod, TheMethod> method in _methods) {
								method.Value._isUnique = false;
								method.Value._index = --index;
							}
						}

						tm._isUnique = false;

					} else {
						methodNames[tm.Name] = tm._index = 1;
					}

					_entityMethods.Add(m, tm);
				}

				return;
			}

			CsEntityInterface entityInterface = pCsEntity as CsEntityInterface;

			if (entityInterface != null) {

				_baseEntityTyperef = entityInterface.base_type;

				if (entityInterface.base_type.type != cs_entity_type.et_object)
					Extends.Add(Helpers.GetType(entityInterface.base_type));

				if (entityInterface.interfaces != null) {
					foreach (CsEntityTypeRef @interface in entityInterface.interfaces) {
						Implements.Add(Helpers.GetType(@interface));
					}
				}

				Dictionary<string, int> methodNames = new Dictionary<string, int>();
				bool methodsDone = false;
				if (entityInterface.method_implementations == null) {
					return;
				}

				foreach (CsEntityMethodImplementation methodImplementation in entityInterface.method_implementations) {
					CsEntityMethod m = methodImplementation.implementation_method;
					TheMethod tm = new TheMethod(m, this, pCreator);
					if (methodNames.ContainsKey(tm.Name)) {
						methodNames[tm.Name]++;
						int index = tm._index = methodNames[tm.Name];

						if (!methodsDone) {
							methodsDone = true;
							foreach (KeyValuePair<CsMethod, TheMethod> method in _methods) {
								method.Value._isUnique = false;
								method.Value._index = --index;
							}
						}

						tm._isUnique = false;

					} else {
						methodNames[tm.Name] = tm._index = 1;
					}

					_entityMethods.Add(m, tm);
				}

				return;
			}

			CsEntityStruct entityStruct = pCsEntity as CsEntityStruct;
			if (entityStruct != null) {
				_baseEntityTyperef = entityStruct.base_type;

				if (entityStruct.base_type.type != cs_entity_type.et_object)
					Extends.Add(Helpers.GetType(entityStruct.base_type));

				if (entityStruct.interfaces != null) {
					foreach (CsEntityTypeRef @interface in entityStruct.interfaces) {
						Implements.Add(Helpers.GetType(@interface));
					}
				}

				Dictionary<string, int> methodNames = new Dictionary<string, int>();
				bool methodsDone = false;
				if (entityStruct.method_implementations == null) {
					return;
				}

				foreach (CsEntityMethodImplementation methodImplementation in entityStruct.method_implementations) {
					CsEntityMethod m = methodImplementation.implementation_method;
					TheMethod tm = new TheMethod(m, this, pCreator);
					if (methodNames.ContainsKey(tm.Name)) {
						methodNames[tm.Name]++;
						int index = tm._index = methodNames[tm.Name];

						if (!methodsDone) {
							methodsDone = true;
							foreach (KeyValuePair<CsMethod, TheMethod> method in _methods) {
								method.Value._isUnique = false;
								method.Value._index = --index;
							}
						}

						tm._isUnique = false;

					} else {
						methodNames[tm.Name] = tm._index = 1;
					}

					_entityMethods.Add(m, tm);
				}

				return;
			}

			throw new NotImplementedException();
		}