Patcher.Data.Plugins.PluginReferenceMapper.PluginReferenceMapper C# (CSharp) Method

PluginReferenceMapper() public method

public PluginReferenceMapper ( Plugin plugin ) : System
plugin Plugin
return System
        public PluginReferenceMapper(Plugin plugin)
        {
            var masters = plugin.MasterFiles.ToList();
            var all = plugin.Context.Plugins.Select(p => p.FileName).ToList();

            allNames = all.ToArray();

            localToContext = new byte[masters.Count + 1];
            for (int i = 0; i < masters.Count; i++)
            {
                localToContext[i] = (byte)all.IndexOf(masters[i]);
            }
            localToContext[masters.Count] = plugin.Context.Plugins.GetPluginNumber(plugin);

            contextToLocal = new byte[all.Count];
            for (int i = 0; i < all.Count; i++)
            {
                if (all[i] == plugin.FileName)
                {
                    contextToLocal[i] = (byte)masters.Count;
                }
                else
                {
                    int index = masters.IndexOf(all[i]);
                    if (index == -1)
                        contextToLocal[i] = byte.MaxValue;
                    else
                        contextToLocal[i] = (byte)index;
                }
            }
        }