示例#1
0
		public FieldKey(TypeKey typeKey, string type, string name, FieldDefinition fieldDefinition)
		{
			this.typeKey = typeKey;
			this.type = type;
			this.name = name;
			this.fieldDefinition = fieldDefinition;
		}
示例#2
0
 public FieldKey(TypeKey typeKey, string type, string name, FieldAttributes fieldAttributes)
 {
     this.typeKey = typeKey;
     this.type = type;
     this.name = name;
     this.fieldAttributes = fieldAttributes;
 }
示例#3
0
		public EventKey (TypeKey typeKey, string type, string name, EventDefinition eventDefinition)
		{
			this.typeKey = typeKey;
			this.type = type;
			this.name = name;
			this.eventDefinition = eventDefinition;
		}
 private void RecordType(Type type, TypeKey key)
 {
     if (type != null)
     {
         _typeMap.TryAdd(key, type);
     }
 }
示例#5
0
 public PropertyKey(TypeKey typeKey, PropertyDefinition prop)
 {
     this.typeKey = typeKey;
     this.type = prop.PropertyType.FullName;
     this.name = prop.Name;
     this.propertyDefinition = prop;
 }
示例#6
0
 public EventKey( TypeKey typeKey, string type, string name, MethodAttributes addMethodAttributes)
 {
     this.typeKey = typeKey;
     this.type = type;
     this.name = name;
     this.addMethodAttributes = addMethodAttributes;
 }
示例#7
0
 public PropertyKey( TypeKey typeKey, PropertyDefinition prop )
 {
     this.typeKey = typeKey;
     this.type = prop.PropertyType.FullName;
     this.name = prop.Name;
     this.getterMethodAttributes = prop.GetMethod != null ? prop.GetMethod.Attributes : 0;
 }
示例#8
0
 public AccessType(int key)
 {
     ISession sess = NHibernateManager.GetCurrentSession();
     ITransaction trans = sess.BeginTransaction();
     sess.Load(this, key);
     trans.Commit();
     this.typeKey = TypeKey.NORMAL;
 }
示例#9
0
 public bool ShouldVisit(TypeKey typeKey)
 {
   if (_types == null)
   {
     return true;
   }
   return _types.Contains(typeKey);
 }
 public override void Record(Type type)
 {
     if (type != null)
     {
         var key = new TypeKey(type.GetTypeInfo().Assembly.FullName, type.FullName);
         this.typeMap.TryAdd(key, type);
     }
 }
示例#11
0
 private Assembly FindAssembly(TypeKey key)
 {
   Assembly assembly = _assemblyRepository.FindAssembly(key.AssemblyKey);
   if (assembly == null)
   {
     assembly = new Assembly(key.AssemblyKey);
     _assemblyRepository.SaveAssembly(assembly);
   }
   return assembly;
 }
        public object GetInstance(TypeKey objectType)
        {
            if(_requestObjectBag == null)
                BeginRequest();

            if (_requestObjectBag != null
                && _requestObjectBag.ContainsKey(objectType))
                return _requestObjectBag[objectType];
            return null;
        }
示例#13
0
 public Type FindType(TypeKey key)
 {
   Assembly assembly = FindAssembly(key);
   Type type = assembly.FindType(key);
   if (type == null)
   {
     type = assembly.AddType(key);
   }
   return type;
 }
 public override void Record(Type type)
 {
     if (type != null)
     {
         var key = new TypeKey(type.GetTypeInfo().Assembly.FullName, type.FullName);
         if (!this.typeMap.ContainsKey(key))
         {
             this.typeMap.Add(key, type);
         }
     }
 }
示例#15
0
 public override bool TryGetTypeKey(Type type, out TypeKey key)
 {
     if (base.TryGetTypeKey(type, out key))
     {
         RecordType(type, key);
         return true;
     }
     else
     {
         return false;
     }
 }
示例#16
0
        //-------------------------------------------------------------------------------------------------------------------------------------------------
        public override bool Equals(TypeKey other)
        {
            var otherEntityKey = (other as EdmEntityTypeKey);

            if ( otherEntityKey != null )
            {
                return (otherEntityKey.EntityType.FullTypeName() == this.EntityType.FullTypeName());
            }
            else
            {
                return base.Equals(other);
            }
        }
示例#17
0
        //-------------------------------------------------------------------------------------------------------------------------------------------------
        public override bool Equals(TypeKey other)
        {
            var otherEntityKey = (other as EdmModelTypeKey);

            if ( otherEntityKey != null )
            {
                return (otherEntityKey.EntityNamespace == this.EntityNamespace);
            }
            else
            {
                return base.Equals(other);
            }
        }
示例#18
0
 public void Record(Type type)
 {
     if (type != null)
     {
         if (!HasType(type))
         {
             using (this.guard.DisposableWrite())
             {
                 var key = new TypeKey(type.GetTypeInfo().Assembly.FullName, type.FullName);
                 if (!this.typeMap.ContainsKey(key))
                 {
                     this.typeMap.Add(key, type);
                 }
             }
         }
     }
 }
示例#19
0
            //-------------------------------------------------------------------------------------------------------------------------------------------------

            protected override ClassType DefineNewClass(TypeKey key)
            {
                return(DeriveClassFrom <object>(key).DefaultConstructor());
            }
 public void NewInstance(TypeKey key, object obj)
 {
     if (!_requestObjectBag.ContainsKey(key))
         _requestObjectBag.Add(key, obj);
 }
示例#21
0
        public InheritMap(Project project)
        {
            this.project = project;

            // cache for assemblies not in the project
            AssemblyCache cache = new AssemblyCache (project);
            //string[] lPaths = project.
            cache.ExtraFolders.AddRange (project.ExtraPaths);

            foreach (AssemblyInfo info in project) {
                cache.ExtraFolders.Add (System.IO.Path.GetDirectoryName (info.Filename));
                foreach (TypeDefinition type in info.GetAllTypeDefinitions()) {
                    if (type.FullName == "<Module>")
                        continue;

                    TypeKey typeKey = new TypeKey (type);

                    baseTypes [typeKey] = GetBaseTypes (type);

                    int i = 0;
                    int j;

                    MethodKey[] methods = GetVirtualMethods (cache, type);
                    while (i < methods.Length) {
                        MethodGroup group;
                        if (!methodGroups.TryGetValue (methods [i], out group))
                            group = null;

                        for (j = i + 1; j < methods.Length; j++) {
                            if (!MethodsMatch(methods, i, j))
                                continue;

                            // found an override

                            // see if either method is already in a group
                            if (group != null)
                                group = AddToGroup (group, methods [j]);
                            else if (methodGroups.TryGetValue (methods [j], out group))
                                group = AddToGroup (group, methods [i]);
                            else {
                                group = new MethodGroup ();

                                group = AddToGroup (group, methods [i]);
                                group = AddToGroup (group, methods [j]);
                            }

                            // if the group isn't already external, see if it should be
                            Debug.Assert (group != null, "should have a group by now");
                            if (!group.External && !project.Contains (methods [j].TypeKey))
                                group.External = true;
                        }

                        // if the group isn't already external, see if it should be
                        if (group != null && !group.External && !project.Contains (methods [i].TypeKey))
                            group.External = true;

                        // move on to the next thing that doesn't match
                        i++;
                    }
                }
            }
        }
 private static void CheckTypeKeyInvariantsAfterInitializationWithType(Type type, TypeKey typeKey)
 {
     typeKey.Type.Should().BeSameAs(type);
     typeKey.HashCode.Should().Be(type.GetHashCode());
     typeKey.RegistrationName.Should().BeEmpty();
 }
示例#23
0
 public void HasAttribute(TypeKey typeKey)
 {
   if (typeKey == null) throw new ArgumentNullException("typeKey");
   Type type = _typeRepository.FindType(typeKey);
   GetCurrentCanHaveAttributes().AddAttribute(type);
 }
示例#24
0
 public void UseType(TypeKey key)
 {
   if (key == null) throw new ArgumentNullException("key");
   UseInCurrentContext(_typeRepository.FindType(key));
 }
 public void IsEmpty(TypeKey typeKey, bool expected)
 {
     typeKey.IsEmpty.Should().Be(expected);
 }
示例#26
0
 public void SetMethodPrototype(TypeKey returnTypeKey, ICollection<TypeKey> parameterTypeNames)
 {
   if (returnTypeKey == null) throw new ArgumentNullException("returnTypeKey");
   if (parameterTypeNames == null) throw new ArgumentNullException("parameterTypeNames");
   List<Parameter> parameters = new List<Parameter>();
   foreach (TypeKey name in parameterTypeNames)
   {
     parameters.Add(new Parameter(_typeRepository.FindType(name)));
   }
   Method method = GetCurrentMethod();
   method.ReturnType = _typeRepository.FindType(returnTypeKey);
   method.SetParameters(parameters);
 }
示例#27
0
 /// <summary>
 /// Builds a tactical metadata type string.
 /// </summary>
 /// <param name="pTarget">The target tactical data type.</param>
 /// <param name="pType">The user type.</param>
 /// <returns>The type as string.</returns>
 public string BuildTypeAsString(TargetKey pTarget, TypeKey pType)
 {
     return(string.Format("{0}" + TYPE_AS_STRING_SEP + "{1}", (string)pTarget, (string)pType));
 }
示例#28
0
        void saveObjKey()
        {
            objk.Components.Clear();
            objk.ComponentData.Clear();
            foreach (string name in ComponentNames)
            {
                if (!hasComponent(name))
                {
                    continue;
                }
                objk.Components.Add(new ObjKeyResource.ObjKeyResource.ComponentElement(0, null, (ObjKeyResource.ObjKeyResource.Component)Enum.Parse(typeof(ObjKeyResource.ObjKeyResource.Component), name)));
                if (ComponentDataTypeMap.ContainsKey(name))
                {
                    int row = ComponentNames.IndexOf(name);
                    row++;
                    if (name.Equals("Sim") && !((CheckBox)tableLayoutPanel1.GetControlFromPosition(1, row)).Checked)
                    {
                        continue;
                    }

                    TypeKey tk   = ComponentDataTypeMap[name];
                    string  type = tk.type.Name.Substring(3);
                    if (type == "String")
                    {
                        TextBox tb    = (TextBox)tableLayoutPanel1.GetControlFromPosition(2, row);
                        string  value = tb.Text;
                        objk.ComponentData.Add(new ObjKeyResource.ObjKeyResource.CDTString(0, null, tk.key, 0x00, value));
                    }
                    else if (type == "ResourceKey")
                    {
                        TGIBlockCombo cb    = (TGIBlockCombo)tableLayoutPanel1.GetControlFromPosition(2, row);
                        Int32         value = cb.SelectedIndex;
                        objk.ComponentData.Add(new ObjKeyResource.ObjKeyResource.CDTResourceKey(0, null, tk.key, 0x01, value));
                    }
                    else if (type == "AssetResourceName")
                    {
                        TGIBlockCombo cb    = (TGIBlockCombo)tableLayoutPanel1.GetControlFromPosition(2, row);
                        Int32         value = cb.SelectedIndex;
                        objk.ComponentData.Add(new ObjKeyResource.ObjKeyResource.CDTAssetResourceName(0, null, tk.key, 0x02, value));
                    }
                    else if (type == "SteeringInstance")
                    {
                        TextBox tb    = (TextBox)tableLayoutPanel1.GetControlFromPosition(2, row);
                        string  value = tb.Text;
                        objk.ComponentData.Add(new ObjKeyResource.ObjKeyResource.CDTSteeringInstance(0, null, tk.key, 0x03, value));
                    }
                    else if (type == "UInt32")
                    {
                        TextBox tb = (TextBox)tableLayoutPanel1.GetControlFromPosition(2, row);
                        string  s  = tb.Text.ToLower().Trim();
                        UInt32  value;
                        if (s.StartsWith("0x"))
                        {
                            value = uint.Parse(s.Substring(2), System.Globalization.NumberStyles.HexNumber);
                        }
                        else
                        {
                            value = uint.Parse(s);
                        }
                        objk.ComponentData.Add(new ObjKeyResource.ObjKeyResource.CDTUInt32(0, null, tk.key, 0x04, value));
                    }
                }
            }
            if (ckbAllowObjectHiding.Checked)
            {
                objk.ComponentData.Add(new ObjKeyResource.ObjKeyResource.CDTUInt32(0, null, "allowObjectHiding", 0x04, 0));
            }

            result = (byte[])objk.AsBytes.Clone();
        }
示例#29
0
        //-----------------------------------------------------------------------------------------------------------------------------------------------------

        internal ClassType(DynamicModule module, TypeKey key, string classFullName, Type baseType)
            : this(module, key, classFullName, baseType, containingClass : null)
        {
        }
        public void GetHashCodeReturnsHashCode(Type type, string registrationName)
        {
            var typeKey = new TypeKey(type, registrationName);

            typeKey.GetHashCode().Should().Be(typeKey.HashCode);
        }
 public void DifferentTypeKeysAreNotEqual(TypeKey first, TypeKey second)
 {
     (first == second).Should().BeFalse();
     (first != second).Should().BeTrue();
 }
示例#32
0
 public void SetBaseType(TypeKey baseTypeKey)
 {
   if (baseTypeKey == null) throw new ArgumentNullException("baseTypeKey");
   Type type = _typeRepository.FindType(baseTypeKey);
   GetCurrentType().BaseType = type;
 }
示例#33
0
 /// <summary>
 /// Возвращает обьект типа адресного обьекта.
 /// </summary>
 /// <param name="key"></param>
 /// <returns></returns>
 public AddressObjectType GetAOType(TypeKey key)
 {
     key.abbreviatedName = key.abbreviatedName.ToLower();
     return(objectTypes[key]);
 }
示例#34
0
 public void SetEventType(TypeKey key)
 {
   if (key == null) throw new ArgumentNullException("key");
   GetCurrentEvent().EventType = _typeRepository.FindType(key);
 }
 public bool HasOverriddenInstance(TypeKey typeKey) => _overriddenRegistrations?.ContainsKey(typeKey) ?? false;
示例#36
0
 public void ImplementsInterface(TypeKey interfaceTypeKey)
 {
   if (interfaceTypeKey == null) throw new ArgumentNullException("interfaceTypeKey");
   Type type = _typeRepository.FindType(interfaceTypeKey);
   GetCurrentType().AddInterface(type);
 }
示例#37
0
        public NetType GetPrimitiveType(PrimitiveTypeCode typeCode)
        {
            switch (typeCode)
            {
            case PrimitiveTypeCode.Boolean:
                return(_factory.CreateTypeModel(TypeKey.FromType <bool>()));

            case PrimitiveTypeCode.Byte:
                return(_factory.CreateTypeModel(TypeKey.FromType <byte>()));

            case PrimitiveTypeCode.SByte:
                return(_factory.CreateTypeModel(TypeKey.FromType <sbyte>()));

            case PrimitiveTypeCode.Char:
                return(_factory.CreateTypeModel(TypeKey.FromType <char>()));

            case PrimitiveTypeCode.Int16:
                return(_factory.CreateTypeModel(TypeKey.FromType <short>()));

            case PrimitiveTypeCode.UInt16:
                return(_factory.CreateTypeModel(TypeKey.FromType <ushort>()));

            case PrimitiveTypeCode.Int32:
                return(_factory.CreateTypeModel(TypeKey.FromType <int>()));

            case PrimitiveTypeCode.UInt32:
                return(_factory.CreateTypeModel(TypeKey.FromType <uint>()));

            case PrimitiveTypeCode.Int64:
                return(_factory.CreateTypeModel(TypeKey.FromType <long>()));

            case PrimitiveTypeCode.UInt64:
                return(_factory.CreateTypeModel(TypeKey.FromType <ulong>()));

            case PrimitiveTypeCode.Single:
                return(_factory.CreateTypeModel(TypeKey.FromType <float>()));

            case PrimitiveTypeCode.Double:
                return(_factory.CreateTypeModel(TypeKey.FromType <double>()));

            case PrimitiveTypeCode.IntPtr:
                return(_factory.CreateTypeModel(TypeKey.FromType <IntPtr>()));

            case PrimitiveTypeCode.UIntPtr:
                return(_factory.CreateTypeModel(TypeKey.FromType <UIntPtr>()));

            case PrimitiveTypeCode.Object:
                return(_factory.CreateTypeModel(TypeKey.FromType <object>()));

            case PrimitiveTypeCode.String:
                return(_factory.CreateTypeModel(TypeKey.FromType <string>()));

            case PrimitiveTypeCode.TypedReference:
                // todo: not sure
                return(_factory.CreateTypeModel(TypeKey.FromType <TypeReference>()));

            case PrimitiveTypeCode.Void:
                return(_factory.CreateTypeModel(TypeKey.FromType(typeof(void))));

            default:
                throw new ArgumentOutOfRangeException(nameof(typeCode), typeCode, null);
            }
        }
示例#38
0
 public void StartType(TypeKey key)
 {
   if (key == null) throw new ArgumentNullException("key");
   _types.Push(key);
   GetCurrentType();
 }
示例#39
0
        private bool ShouldSkip(TypeKey type, TypeAffectFlags flag, InheritMap map)
        {
            if (ShouldSkip (type.Namespace, map)) {
                return true;
            }

            foreach (TypeTester typeTester in skipTypes) {
                if ((typeTester.AffectFlags & flag) > 0 && typeTester.Test (type, map))
                    return true;
            }

            return false;
        }
示例#40
0
 public TypeKey[] GetBaseTypes(TypeKey typeKey)
 {
     return baseTypes [typeKey];
 }
示例#41
0
 public ParameterKey(TypeKey type, RefKind refKind)
 {
     _type    = type;
     _refKind = refKind;
 }
示例#42
0
 public Registration CreateDefaultRegistration(TypeKey typeKey, DependencyInjectionContainer container)
 {
     throw new ResolveException($"There is no registration for {typeKey} and the container is configured to not perform automatic registrations.");
 }
        public void InitializationWithoutRegistrationName(Type type)
        {
            var typeKey = new TypeKey(type);

            CheckTypeKeyInvariantsAfterInitializationWithType(type, typeKey);
        }
示例#44
0
 public static void WriteTypeKey(TypeKey key, BinaryTokenStreamWriter writer)
 {
     writer.Write(key.HashCode);
     writer.Write((ushort)key.TypeName.Length);
     writer.Write(key.TypeName);
 }
示例#45
0
        /// <summary>
        /// Retrieves the matadata type for the given tactical data type (e.g: Area2D, Area3D and so on..)
        /// </summary>
        /// <param name="pParentType">The parent metadata type.</param>
        /// <param name="pTarget">The target tactical data type.</param>
        /// <param name="pType">The user type.</param>
        /// <returns>The found type, null otherwise.</returns>
        public MetadataSetType GetType(MetadataSetType pParentType, TargetKey pTarget, TypeKey pType)
        {
            if (pParentType == null)
            {
                Dictionary <string, MetadataSetType> lTypes;
                if (sTacticalMetadataTypes.TryGetValue(pTarget, out lTypes))
                {
                    MetadataSetType lType;
                    if (lTypes.TryGetValue(pType, out lType))
                    {
                        return(lType);
                    }
                }
            }

            if (pParentType != null)
            {
                return(pParentType.NestedTypes.FirstOrDefault(pNestedType => pNestedType.GetTypeAsString() == this.BuildTypeAsString(pTarget, pType)) as MetadataSetType);
            }

            return(null);
        }
示例#46
0
        public bool ShouldSkip(TypeKey type, InheritMap map, bool keepPublicApi, bool hidePrivateApi, bool markedOnly, out string message)
        {
            var attribute = type.TypeDefinition.MarkedToRename ();
            if (attribute != null) {
                message = "attribute";
                return !attribute.Value;
            }

            if (markedOnly) {
                message = "MarkedOnly option in configuration";
                return true;
            }

            if (forceTypes.IsMatch (type, map)) {
                message = "type rule in configuration";
                return false;
            }

            if (ShouldForce (type.Namespace, map)) {
                message = "namespace rule in configuration";
                return false;
            }

            if (skipTypes.IsMatch (type, map)) {
                message = "type rule in configuration";
                return true;
            }

            if (ShouldSkip (type.Namespace, map)) {
                message = "namespace rule in configuration";
                return true;
            }

            if (type.TypeDefinition.IsEnum && skipEnums) {
                message = "enum rule in configuration";
                return true;
            }

            if (type.TypeDefinition.IsTypePublic ()) {
                message = "KeepPublicApi option in configuration";
                return keepPublicApi;
            }

            message = "HidePrivateApi option in configuration";
            return !hidePrivateApi;
        }
示例#47
0
        //-----------------------------------------------------------------------------------------------------------------------------------------------------

        public void EnsureResourceHandlersCompiled(Type txType)
        {
            var key = new TypeKey(this.GetType(), txType);

            base.GetOrBuildTypeMember(ref key);
        }
示例#48
0
        void AddRow(TableLayoutPanel tlp, string name, ref int tabIndex)
        {
            tlp.RowCount++;
            tlp.RowStyles.Insert(tlp.RowCount - 2, new RowStyle(SizeType.AutoSize));

            ObjKeyResource.ObjKeyResource.Component        component = (ObjKeyResource.ObjKeyResource.Component)Enum.Parse(typeof(ObjKeyResource.ObjKeyResource.Component), name);
            ObjKeyResource.ObjKeyResource.ComponentElement ce        = objk.Components.Find(component);

            CheckBox ckb = new CheckBox();

            ckb.Anchor          = AnchorStyles.Left;
            ckb.AutoSize        = true;
            ckb.Checked         = ce != null;
            ckb.Enabled         = !unused.Contains(name);
            ckb.Name            = "ckb" + name;
            ckb.TabIndex        = tabIndex++;
            ckb.Text            = name + (unused.Contains(name) ? " (unused)" : "");
            ckb.CheckedChanged += new EventHandler(ckb_CheckedChanged);
            tlp.Controls.Add(ckb, 0, tlp.RowCount - 2);

            if (ComponentDataTypeMap.ContainsKey(name))
            {
                TypeKey tk   = ComponentDataTypeMap[name];
                string  type = tk.type.Name.Substring(3);
                ObjKeyResource.ObjKeyResource.ComponentDataType cdt = null;
                if (objk.ComponentData.ContainsKey(tk.key))
                {
                    cdt = objk.ComponentData[tk.key];
                }

                if (name.Equals("Sim"))
                {
                    CheckBox ckb2 = new CheckBox();
                    ckb2.Anchor          = AnchorStyles.Right;
                    ckb2.AutoSize        = true;
                    ckb2.Enabled         = ckb.Checked;
                    ckb2.Checked         = cdt != null;
                    ckb2.Name            = "ckbData" + tabIndex;
                    ckb2.TabIndex        = tabIndex++;
                    ckb2.Text            = type + ":";
                    ckb2.CheckedChanged += new EventHandler(ckb2_CheckedChanged);
                    tlp.Controls.Add(ckb2, 1, tlp.RowCount - 2);
                }
                else
                {
                    Label lb = new Label();
                    lb.Anchor   = AnchorStyles.Right;
                    lb.AutoSize = true;
                    lb.Name     = "lbData" + tabIndex;
                    lb.TabIndex = tabIndex++;
                    lb.Text     = type + ":";
                    tlp.Controls.Add(lb, 1, tlp.RowCount - 2);
                }
                if (type == "String" || type == "SteeringInstance")
                {
                    tlp.Controls.Add(StringEditor(ckb.Checked, name, ref tabIndex, cdt), 2, tlp.RowCount - 2);
                }
                else if (type == "UInt32")
                {
                    tlp.Controls.Add(UInt32Editor(ckb.Checked, name, ref tabIndex, cdt), 2, tlp.RowCount - 2);
                }
                else
                {
                    tlp.Controls.Add(ResourceKeyEditor(ckb.Checked, name, ref tabIndex, cdt), 2, tlp.RowCount - 2);
                }
            }
        }
示例#49
0
            //-------------------------------------------------------------------------------------------------------------------------------------------------

            protected override ClassType DefineNewClass(TypeKey key)
            {
                return(DeriveClassFrom <object>(key)
                       .DefaultConstructor()
                       .ImplementBase <TypeTemplate.TPrimary>());
            }