Example #1
0
        private static ReadOnlyCollection <ContractInfo> ScanAssembly(Assembly assembly)
        {
            List <ContractInfo> contracts = new List <ContractInfo>();

            ReadOnlyCollection <CustomAttributeData> attributes = CustomAttributeHelper.GetCustomAttributes(assembly, typeof(ManagedServiceContractAssemblyAttribute));

            if (attributes.Count > 0)
            {
                foreach (Type type in assembly.GetTypes())
                {
                    bool isContractType = ScanType(type);
                    if (isContractType)
                    {
                        ContractInfo info = new ContractInfo()
                        {
                            ContractType = type
                        };
                        if (!contracts.Contains(info))
                        {
                            contracts.Add(info);
                        }
                    }
                }
            }

            return(contracts.AsReadOnly());
        }
Example #2
0
 private static bool ScanType(Type type)
 {
     return(CustomAttributeHelper.GetCustomAttributes(type, typeof(ManagedServiceContractAttribute)).Count > 0);
 }