예제 #1
0
        protected BaseParseHelper(ParsingContext context)
        {
            Context = context;

            var assemblyTypes = typeof(T).Assembly.GetTypes();

            // 1. Load opcode handlers
            Handlers = new HandlerHelper(Context, assemblyTypes);

            // 2. Load opcode resolvers
            var opcodeResolver = default(IOpcodeResolver?);

            foreach (var type in assemblyTypes)
            {
                if (typeof(IOpcodeResolver).IsAssignableFrom(type))
                {
                    if (opcodeResolver != null)
                    {
                        throw new InvalidOperationException($"Two (or more) implementations of {nameof(IOpcodeResolver)} were found in {typeof(T).Assembly.FullName}. Fix this!");
                    }

                    opcodeResolver = (IOpcodeResolver)Activator.CreateInstance(type) !;
                }
            }

            OpcodeResolver = opcodeResolver ?? throw new InvalidOperationException($"No implementation of {nameof(IOpcodeResolver)} found in {typeof(T).Assembly.FullName}.");
            OpcodeResolver.Initialize();

            // 3. Load GUID resolvers
            GuidResolver = new GuidResolver(Context, assemblyTypes);

            // 4. Load updatefield resolvers
            UpdateFieldProvider = new UpdateFieldProvider(Context, assemblyTypes);
        }
예제 #2
0
        static IList <Guid> GetCandidatesGuids(
            WorkspaceInfo wkInfo,
            RepositorySpec repSpec,
            List <WorkspaceTreeNode> candidates)
        {
            RepositoryInfo repInfo = RepositorySpecResolverProvider.
                                     Get().GetRepInfo(repSpec);

            IList <long> ids = new List <long>(candidates.Count);

            foreach (WorkspaceTreeNode candidate in candidates)
            {
                ids.Add(candidate.RevInfo.ItemId);
            }

            return(GuidResolver.Get().GetObjectGuids(repInfo, wkInfo, ids));
        }