public static ServiceTypeIdentifier FromType(Type type, ILogger logger = null)
        {
            logger = logger ?? Log.Default;
            FileInfo commitFile  = new FileInfo(Path.Combine(Assembly.GetEntryAssembly().GetFileInfo().Directory.FullName, "commit"));
            string   buildNumber = "UNKNOWN";

            if (!commitFile.Exists)
            {
                logger.Warning("commit file not found: {0}", commitFile.FullName);
            }
            else
            {
                buildNumber = commitFile.ReadAllText().Trim();
            }
            FileInfo assemblyFileInfo    = type.Assembly.GetFileInfo();
            ServiceTypeIdentifier result = new ServiceTypeIdentifier
            {
                BuildNumber      = buildNumber,
                Namespace        = type.Namespace,
                TypeName         = type.Name,
                AssemblyName     = assemblyFileInfo.Name,
                AssemblyFileHash = assemblyFileInfo.Sha1()
            };

            result.SetDurableHashes();
            return(result);
        }
Esempio n. 2
0
 public ServiceDescriptor(Type forType, Type useType)
 {
     ForTypeIdentifier           = ServiceTypeIdentifier.FromType(forType);
     UseTypeIdentifier           = ServiceTypeIdentifier.FromType(useType);
     ForTypeDurableHash          = ForTypeIdentifier.DurableHash;
     UseTypeDurableHash          = UseTypeIdentifier.DurableHash;
     ForTypeDurableSecondaryHash = ForTypeIdentifier.DurableSecondaryHash;
     UseTypeDurableSecondaryHash = UseTypeIdentifier.DurableSecondaryHash;
 }