Example #1
0
        /// <summary>
        /// Parse a single available types section. For composite R2R images this method is called multiple times
        /// as available types are stored separately for each component assembly of the composite R2R executable.
        /// </summary>
        /// <param name="availableTypesSection"></param>
        private void ParseAvailableTypesSection(ReadyToRunSection availableTypesSection, MetadataReader metadataReader)
        {
            int             availableTypesOffset = GetOffset(availableTypesSection.RelativeVirtualAddress);
            NativeParser    parser         = new NativeParser(Image, (uint)availableTypesOffset);
            NativeHashtable availableTypes = new NativeHashtable(Image, parser, (uint)(availableTypesOffset + availableTypesSection.Size));

            NativeHashtable.AllEntriesEnumerator allEntriesEnum = availableTypes.EnumerateAllEntries();
            NativeParser curParser = allEntriesEnum.GetNext();

            while (!curParser.IsNull())
            {
                uint rid = curParser.GetUnsigned();

                bool isExportedType = (rid & 1) != 0;
                rid = rid >> 1;

                if (isExportedType)
                {
                    ExportedTypeHandle exportedTypeHandle = MetadataTokens.ExportedTypeHandle((int)rid);
                    string             exportedTypeName   = GetExportedTypeFullName(metadataReader, exportedTypeHandle);
                    AvailableTypes.Add("exported " + exportedTypeName);
                }
                else
                {
                    TypeDefinitionHandle typeDefHandle = MetadataTokens.TypeDefinitionHandle((int)rid);
                    string typeDefName = MetadataNameFormatter.FormatHandle(metadataReader, typeDefHandle);
                    AvailableTypes.Add(typeDefName);
                }

                curParser = allEntriesEnum.GetNext();
            }
        }
Example #2
0
        /// <summary>
        /// 現在ロードされているすべてのアセンブリから name という名の型を探して返す
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        public static Type GetType(List <Assembly> assemblies, string name)
        {
            if (AvailableTypes.ContainsKey(name))
            {
                return(AvailableTypes[name]);
            }

            return(AvailableTypes[name] = Type.GetType(name) ?? assemblies.Select(asm => asm.GetType(name)).FirstOrDefault(t => t != null));
        }
Example #3
0
        protected override void OnInitialize()
        {
            if (AvailableTypes != null)
            {
                SelectedEventType = AvailableTypes.FirstOrDefault();
            }

            CloseWithInvoker(true);
            base.OnInitialize();
        }
Example #4
0
            public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
            {
                if (value is string stringValue)
                {
                    var matchingHosts = AvailableTypes.Where(x => x.FullName.EndsWithOrdinalIgnoreCase(stringValue)).ToList();
                    Assert.HasSingleItem(matchingHosts);
                    return(CreateHost(matchingHosts.Single()));
                }

                return(base.ConvertFrom(context, culture, value));
            }
Example #5
0
        private GenericOperation()
        {
            var type = typeof(T);

            if (!AvailableTypes.Contains(type))
            {
                throw new NotSupportedException(type.FullName);
            }

            _p1 = Expression.Parameter(type);
            _p2 = Expression.Parameter(type);
        }
 public override void CopyFrom(IPropertyModel property)
 {
     if (property is SubtypingProperty subtypingProperty)
     {
         // 具象型が未設定の時はコピー先も未設定にする
         if (subtypingProperty.SelectedType.Value != null)
         {
             SelectedType.Value = AvailableTypes.FirstOrDefault(x => x.Type == subtypingProperty.SelectedType.Value.Type);
             Model.Value.CopyFrom(subtypingProperty.Model.Value);
         }
     }
 }
        private void OnSearchTextUpdated()
        {
            var foundItem = AvailableTypes.FirstOrDefault(t => t.TypeName == SearchText);

            if (foundItem is null)
            {
                DestinationName = new(PrependedNamespace + SearchText);
                return;
            }

            DestinationName = foundItem;
        }
Example #8
0
        /// <summary>
        /// 現在ロードされているすべてのアセンブリから name という名の型を探して返す
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        public static Type GetType(string name)
        {
            if (AvailableTypes.ContainsKey(name))
            {
                return(AvailableTypes[name]);
            }
            Type type = Type.GetType(name);

            if (type == null)   // ロードされているすべてのアセンブリから探す
            {
                type = System.AppDomain.CurrentDomain.GetAssemblies().Select(
                    asm => asm.GetType(name)).FirstOrDefault(t => t != null);
            }
            return(AvailableTypes[name] = type);
        }
Example #9
0
        /// <summary>
        /// Iterates through a native hashtable to get all RIDs
        /// </summary>
        private void ParseAvailableTypes()
        {
            if (!R2RHeader.Sections.ContainsKey(R2RSection.SectionType.READYTORUN_SECTION_AVAILABLE_TYPES))
            {
                return;
            }

            HashSet <uint> added = new HashSet <uint>();

            R2RSection      availableTypesSection = R2RHeader.Sections[R2RSection.SectionType.READYTORUN_SECTION_AVAILABLE_TYPES];
            int             availableTypesOffset  = GetOffset(availableTypesSection.RelativeVirtualAddress);
            NativeParser    parser         = new NativeParser(Image, (uint)availableTypesOffset);
            NativeHashtable availableTypes = new NativeHashtable(Image, parser, (uint)(availableTypesOffset + availableTypesSection.Size));

            NativeHashtable.AllEntriesEnumerator allEntriesEnum = availableTypes.EnumerateAllEntries();
            NativeParser curParser = allEntriesEnum.GetNext();

            while (!curParser.IsNull())
            {
                uint rid = curParser.GetUnsigned();
                rid = rid >> 1;
                if (added.Contains(rid))
                {
                    continue;
                }

                TypeDefinitionHandle typeDefHandle    = MetadataTokens.TypeDefinitionHandle((int)rid);
                string             typeDefName        = MetadataNameFormatter.FormatHandle(MetadataReader, typeDefHandle);
                ExportedTypeHandle exportedTypeHandle = MetadataTokens.ExportedTypeHandle((int)rid);
                string             exportedTypeName   = GetExportedTypeFullName(MetadataReader, exportedTypeHandle);
                if (typeDefName == null && exportedTypeName == null)
                {
                    R2RDump.WriteWarning($"AvailableType with rid {rid} is not a TypeDef or ExportedType");
                }
                if (typeDefName != null)
                {
                    AvailableTypes.Add(typeDefName);
                    added.Add(rid);
                }
                if (exportedTypeName != null)
                {
                    AvailableTypes.Add("exported " + exportedTypeName);
                    added.Add(rid);
                }

                curParser = allEntriesEnum.GetNext();
            }
        }
    //editor methods------------------------------------------------------------------------------


#if UNITY_EDITOR
    protected override void Draw(ref Rect pos)
    {
        pos.height = SingleLineHeight;

        var selectedType = AvailableTypes.FirstOrDefault(x => selectedTypeName.Equals(x.FullName));

        if (selectedType == null)
        {
            EditorGUI.LabelField(pos, "please select a type in edit mode");
            pos.y += pos.height;
        }

        else
        {
            DrawObjectField(ref pos);
        }
    }
Example #11
0
        protected override void OnInitialize()
        {
            if (AvailableTypes != null)
            {
                SelectedEventType = AvailableTypes.FirstOrDefault();
            }

            var list = GetSelectedAgents(null).Cast <IAgent>().ToArray();

            EmployeeSelectionWay = list.Length > 1 ? 1 : 0;

            CurrentAgent  = list.Length > 0 ? list[0] : default(IAgent);
            SelectedCount = CurrentAgent.If <ISelectable>(o => o.IsSelected == true) ? list.Length : list.Length > 0 ? list.Length - 1 : 0;


            base.OnInitialize();
        }
Example #12
0
        private void ParseAvailableTypes()
        {
            R2RSection      availableTypesSection = R2RHeader.Sections[R2RSection.SectionType.READYTORUN_SECTION_AVAILABLE_TYPES];
            int             availableTypesOffset  = GetOffset(availableTypesSection.RelativeVirtualAddress);
            NativeParser    parser         = new NativeParser(Image, (uint)availableTypesOffset);
            NativeHashtable availableTypes = new NativeHashtable(Image, parser, (uint)(availableTypesOffset + availableTypesSection.Size));

            NativeHashtable.AllEntriesEnumerator allEntriesEnum = availableTypes.EnumerateAllEntries();
            NativeParser curParser = allEntriesEnum.GetNext();

            while (!curParser.IsNull())
            {
                uint rid = curParser.GetUnsigned();
                rid = rid >> 1;
                TypeDefinitionHandle typeDefHandle = MetadataTokens.TypeDefinitionHandle((int)rid);
                AvailableTypes.Add(GetTypeDefFullName(_mdReader, typeDefHandle));
                curParser = allEntriesEnum.GetNext();
            }
        }
Example #13
0
        /// <summary>
        /// Iterates through a native hashtable to get all RIDs
        /// </summary>
        private void ParseAvailableTypes()
        {
            if (!R2RHeader.Sections.ContainsKey(R2RSection.SectionType.READYTORUN_SECTION_AVAILABLE_TYPES))
            {
                return;
            }

            R2RSection      availableTypesSection = R2RHeader.Sections[R2RSection.SectionType.READYTORUN_SECTION_AVAILABLE_TYPES];
            int             availableTypesOffset  = GetOffset(availableTypesSection.RelativeVirtualAddress);
            NativeParser    parser         = new NativeParser(Image, (uint)availableTypesOffset);
            NativeHashtable availableTypes = new NativeHashtable(Image, parser, (uint)(availableTypesOffset + availableTypesSection.Size));

            NativeHashtable.AllEntriesEnumerator allEntriesEnum = availableTypes.EnumerateAllEntries();
            NativeParser curParser = allEntriesEnum.GetNext();

            while (!curParser.IsNull())
            {
                uint rid = curParser.GetUnsigned();

                bool isExportedType = (rid & 1) != 0;
                rid = rid >> 1;

                if (isExportedType)
                {
                    ExportedTypeHandle exportedTypeHandle = MetadataTokens.ExportedTypeHandle((int)rid);
                    string             exportedTypeName   = GetExportedTypeFullName(MetadataReader, exportedTypeHandle);
                    AvailableTypes.Add("exported " + exportedTypeName);
                }
                else
                {
                    TypeDefinitionHandle typeDefHandle = MetadataTokens.TypeDefinitionHandle((int)rid);
                    string typeDefName = MetadataNameFormatter.FormatHandle(MetadataReader, typeDefHandle);
                    AvailableTypes.Add(typeDefName);
                }

                curParser = allEntriesEnum.GetNext();
            }
        }
Example #14
0
        public async Task RestoreIndexTypeSettingFromFileOrFull()
        {
            var doc = await _serializer.LoadXml(string.Format("{0}.xml", CountryType.ToString()), roaming : true);

            if (doc == null)
            {
                IndexTypeSettings = AvailableTypes
                                    .Select(x => new IndexTypeSetting {
                    IndexType = x, On = true
                });
                return;
            }

            var a = doc.Element("TypeSettings").Elements().Select(x => x.Name.LocalName).ToArray();

            var elem = doc.Element("TypeSettings");

            IndexTypeSettings = AvailableTypes
                                .Select(x => new IndexTypeSetting
            {
                IndexType = x,
                On        = GetOnOff(elem, x),
            });
        }
 //methods-------------------------------------------------------------------------------------
 void UpdateFilteredList()
 {
     FilteredTypes = AvailableTypes.Where(x => x.Name.ToLower().Contains((filterString ?? "").ToLower())).ToList();
 }
Example #16
0
 public InvalidTypeConversion(AvailableTypes from, AvailableTypes to)
     : base($"Error while converting from {from} to {to}.")
 {
 }
Example #17
0
 public InvalidTypeConversion(AvailableTypes from, AvailableTypes to, Exception inner)
     : base($"Error while converting from {from} to {to}.", inner)
 {
 }
Example #18
0
 private Type GetTypeByFullName(string name) => AvailableTypes
 .FirstOrDefault(i => string.Equals(i.FullName, name, StringComparison.OrdinalIgnoreCase));