public async Task <bool> CheckUpdate(AssemblyType type)
        {
            try
            {
                type.LatestRelease = await Client.Repository.Release.GetLatest("MinecraftZenova", type.RepositoryName);

                type.TagInfo = (await Client.Repository.GetAllTags("MinecraftZenova", type.RepositoryName)).FirstOrDefault(x => x.Name == type.LatestRelease.TagName);

                if (type.InstalledVersion == null)
                {
                    return(true);
                }

                Version latestVersion = new Version(type.LatestRelease.TagName.Trim());
                Trace.WriteLine(type.RepositoryName + " Installed Version: " + type.InstalledVersion);
                Trace.WriteLine(type.RepositoryName + " Latest Version: " + latestVersion);
                if (latestVersion > type.InstalledVersion && type.InstalledVersion > new Version(0, 0, 0, 0))
                {
                    return(true);
                }
            }
            catch (Exception e)
            {
                Trace.WriteLine(type.RepositoryName + " Check for update failed:\n" + e.ToString());
            }
            return(false);
        }
        /// <summary>
        /// Gets the assembly of the specified type.
        /// </summary>
        /// <param name="assemblyType">The type of the assembly to look for.</param>
        public static Assembly GetAssembly(AssemblyType assemblyType)
        {
            Assembly assembly;

            switch (assemblyType)
            {
            case AssemblyType.APPLICATION:
                assembly = Assembly.GetEntryAssembly();
                break;

            case AssemblyType.LIBRARY:
                assembly = Assembly.GetExecutingAssembly();
                break;

            case AssemblyType.CURRENT:
                assembly = null;
                break;

            default:
                throw new ArgumentException($"Unsupported assembly type '{assemblyType}'.");
            }

            if (assembly == null)
            {
                assembly = Assembly.GetCallingAssembly();
            }
            if (assembly == null)
            {
                throw new Exception("Assembly information could not be found.");
            }

            return(assembly);
        }
        public static string ConvertToString(AssemblyType type)
        {
            var result = type.Modifier.ToString().ToLower() + " ";

            if (type.IsSealed && !type.IsStructure && !type.IsEnum)
            {
                result += "sealed ";
            }

            if (type.IsAbstract)
            {
                result += "abstract ";
            }

            if (type.IsEnum)
            {
                result += "enum ";
            }
            else if (type.IsStructure)
            {
                result += "structure ";
            }
            else if (type.IsInterface)
            {
                result = "interface " + type.Name;
                return(result);
            }
            else if (type.IsClass)
            {
                result += "class ";
            }

            return(result + type.Name);
        }
Exemple #4
0
        public void InitializeTest()
        {
            this.wizard   = new ItemWizardImplementation(new FormFactory(this.MockFactory), new ErrorDisplay(this.DisplayError));
            this.mockForm = null;

            this.wizardData                 = new WizardData();
            this.wizardData.TraceFile       = Path.GetTempFileName();
            this.wizardData.TraceFileSource = TraceFileSource.Dynamic;
            this.wizardData.Configuration   = new WcfUnitConfiguration();
            this.wizardData.Configuration.testMethodMode     = TestMethodMode.ScenarioMethodOnly;
            this.wizardData.Configuration.operationTimerMode = OperationTimerMode.IncludeOperationTimers;
            AssemblyType a = new AssemblyType();

            a.fileName = "ClientProxies.dll";
            this.wizardData.Configuration.assembly    = new AssemblyType[] { a };
            this.wizardData.Configuration.soapActions = new WcfUnitConfigurationSoapActions();
            this.wizardData.Configuration.soapActions.soapActionMode = SoapActionMode.Include;

            this.errorDisplayCalled = false;

            File.Copy(@"..\..\..\Library.Test\TestData\SampleWithNamespaces.svclog", this.wizardData.TraceFile, true);
            File.SetAttributes(this.wizardData.TraceFile, FileAttributes.Normal); // make sure not read only
            File.Delete("ignore.cs");
            File.Delete("test.cs");
            File.Delete("ignorestub.cs");
            File.Delete("teststub.cs");
        }
Exemple #5
0
 public void Clear()
 {
     assembly_files.Clear();
     assemblyType = AssemblyType.GAC;
     lvGac.Items.Clear();
     //lvCom.Items.Clear();
 }
Exemple #6
0
        public static SerializeResult Serialize()
        {
            if (!File.Exists("PolicyFileRequest.xml"))
            {
                return(SerializeResult.Broken);
            }

            PolicyFileRequest = Encoding.Default.GetBytes((File.ReadAllText("PolicyFileRequest.xml", Encoding.Default).Replace("\"\"", "\"/xml/dtds/cross-domain-policy.dtd\"") + "\x0"));

            Events = new Dictionary <int, IMessageEvent>();

            try
            {
                var Type = typeof(IMessageEvent);

                foreach (var AssemblyType in Assembly.GetExecutingAssembly().GetTypes())
                {
                    if (AssemblyType.GetInterfaces().Contains(Type))
                    {
                        var Constructed = (AssemblyType.GetConstructor(new Type[] {}).Invoke(new object[] {}) as IMessageEvent);

                        if (!Events.ContainsKey(Constructed.Id))
                        {
                            Events.Add(Constructed.Id, Constructed);
                        }
                    }
                }

                Solution.AppendLine("MessageHandler: Saved {0} Event-actions.", Events.Count);
            }
            catch { return(SerializeResult.Broken); }

            return(SerializeResult.Finished);
        }
Exemple #7
0
        private static void ConvertScripts(AssemblyType assemblyType, IList <SourceFile> scripts, UnityScript2CSharpConverter converter, CommandLineArguments args, List <SymbolInfo> referencedSymbols, HashSet <CompilerError> compilerErrors)
        {
            IEnumerable <string> references = AssemblyReferencesFor(args, assemblyType);

            Console.WriteLine("Converting '{0}' ({1} scripts)", assemblyType, scripts.Count);

            Action <string, string, int> handler = (scriptPath, context, unsupportedCount) => HandleConvertedScript(scriptPath, context, args.RemoveOriginalFiles, args.Verbose, unsupportedCount);

            if (args.DryRun)
            {
                handler = (_, __, ___) => {}
            }
            ;

            converter.Convert(scripts, args.Symbols, references, handler);

            referencedSymbols.AddRange(converter.ReferencedPreProcessorSymbols);
            foreach (var error in converter.CompilerErrors)
            {
                compilerErrors.Add(error);
            }

            using (WithConsoleColors.SetTo(ConsoleColor.Yellow, ConsoleColor.Black))
            {
                foreach (var warning in converter.CompilerWarnings)
                {
                    Console.WriteLine("\t{0}", warning);
                }
            }
        }
        private void FillListViewIniData(ListView listView, AssemblyType assemblyType, string assemblyname,
                                         SA_Tools.IniData iniData, Dictionary <string, bool> itemsToExport)
        {
            listView.BeginUpdate();
            listView.Items.Clear();

            foreach (KeyValuePair <string, SA_Tools.FileInfo> item in iniData.Files)
            {
                KeyValuePair <string, bool> exportStatus = itemsToExport.First(export => export.Key == item.Key);

                bool modified = exportStatus.Value;

                listView.Items.Add(new ListViewItem
                                   (
                                       new[]
                {
                    item.Key, StructConverter.StructConverter.DataTypeList[item.Value.Type],
                    (modified ? "Yes" : "No")
                })
                {
                    Checked = modified
                });
            }

            listView.EndUpdate();
        }
		public void Clear()
		{
			assembly_files.Clear();
			assemblyType = AssemblyType.GAC;
			lvGac.Items.Clear();
			//lvCom.Items.Clear();
		}
        private static string GetAssemblyNameBaseOnAssemblyType(AssemblyType lookupIn)
        {
            string assemblyName;

            switch (lookupIn)
            {
            case AssemblyType.Common:
                assemblyName = "App.Common.dll";
                break;

            case AssemblyType.Context:
                assemblyName = "App.Context.dll";
                break;

            case AssemblyType.Repository:
                assemblyName = "App.Repository.dll";
                break;

            case AssemblyType.Service:
                assemblyName = "App.Service.dll";
                break;

            default:
                assemblyName = "App.Api.dll";
                break;
            }
            return(assemblyName);
        }
Exemple #11
0
        public void GenerateFullSampleTestWithProxy()
        {
            this.config = new WcfUnitConfiguration();
            this.config.testMethodMode     = TestMethodMode.ScenarioMethodOnly;
            this.config.operationTimerMode = OperationTimerMode.IncludeOperationTimers;
            AssemblyType a1 = new AssemblyType();

            a1.fileName = "ClientProxies.dll";
            AssemblyType a2 = new AssemblyType();

            a2.fileName = "Contracts.Custom.dll";
            AssemblyType a3 = new AssemblyType();

            a3.fileName             = "ClientProxies.Custom.dll";
            this.config.assembly    = new AssemblyType[] { a1, a2, a3 };
            this.config.soapActions = new WcfUnitConfigurationSoapActions();
            this.config.soapActions.soapActionMode = SoapActionMode.Include;

            Collection <string> proxies = this.sut.ProcessTraceFile("GeneratedSampleTest", "FullSampleTest.svclog", null, this.config);

            Assert.AreEqual <int>(3, proxies.Count);
            Assert.AreEqual <string>("ClientProxies", Path.GetFileNameWithoutExtension(proxies[0]));
            Assert.AreEqual <string>("Contracts.Custom", Path.GetFileNameWithoutExtension(proxies[1]));
            Assert.AreEqual <string>("ClientProxies.Custom", Path.GetFileNameWithoutExtension(proxies[2]));

            File.Copy("GeneratedSampleTest.cs", "..\\..\\..\\Library.Test.Integration\\GeneratedSampleTest.cs", true);
            File.Copy("GeneratedSampleTest.stubs", "..\\..\\..\\Library.Test.Integration\\GeneratedSampleTest.stubs", true);
        }
Exemple #12
0
        private void PopulateClassOrStruct(TypeDefinition objType)
        {
            AssemblyType asmType = AssemblyType.Unknown;

            //delegates are seen as Class by Cecil, but we don't handle them here
            if (IsDelegate(objType))
            {
                PopulateDelegate(objType);
            }
            else if (objType.IsClass)
            {
                asmType = AssemblyType.Class;
            }
            else if (objType.IsValueType)
            {
                asmType = AssemblyType.Struct;
            }
            else if (objType.IsInterface)
            {
                asmType = AssemblyType.Interface;
            }

            AsmEntry asm = new AsmEntry(objType.Name, asmType)
            {
                CecilType = objType
            };
            var memberItem = HandleMemberAndSignature(GetTypeName(objType), objType.Name, asm, null);

            PopulateClassOrStructChildren(objType, memberItem);
        }
Exemple #13
0
        public static List <string> GetNamespaces(this AssemblyType assemblyType)
        {
            var assembly   = GetAssemblyType(assemblyType);
            var namespaces = RetrieveNamespaces(assembly);

            return(namespaces);
        }
 public AssemblyDataItem(AssemblyType at, TypeDefinition td, string n)
     : this()
 {
     assemblyType = at;
     cecilType = td;
     SimplifiedName = n;
 }
 public AssemblyDataItem(AssemblyType at, TypeDefinition td, AssemblyDataItem p)
     : this()
 {
     assemblyType = at;
     cecilType = td;
     Parent = p;
 }
        public async Task <bool> DoUpdate(AssemblyType type)
        {
            for (int asset = 0; asset < type.AssetsCount; asset++)
            {
                string dlPath = type.DownloadPath(type, asset);
                try
                {
                    DisplayText = type.RepositoryName;
                    await DownloadFile(type.LatestRelease.Assets[asset].BrowserDownloadUrl, dlPath, (current, total) =>
                    {
                        if (!IsDownloading)
                        {
                            Trace.WriteLine(type.RepositoryName + " download started");
                            IsDownloading = true;
                            if (total.HasValue)
                            {
                                DownloadSize = total.Value;
                            }
                        }
                        DownloadedBytes += current;
                    }, cancelSource.Token);

                    Trace.WriteLine(type.RepositoryName + " download finished");
                    IsDownloading = false;
                }
                catch (Exception e)
                {
                    Trace.WriteLine(type.RepositoryName + " download failed:\n" + e.ToString());
                    return(false);
                }
                await type.PostDownloadTask(dlPath);
            }
            return(true);
        }
        public static string AssemblyTypeNameForSignature(AssemblyType t)
        {
            switch (t)
            {
            case AssemblyType.Class: return("class");

            case AssemblyType.Constructor: return("function");

            case AssemblyType.Enum: return("enumeration");

            case AssemblyType.EnumValue: return("enumeration value");

            case AssemblyType.Field: return("var");

            case AssemblyType.Interface: return("interface");

            case AssemblyType.Method: return("function");

            case AssemblyType.Primitive: return("primitive type");

            case AssemblyType.Property: return("var");

            case AssemblyType.Struct: return("struct");

            case AssemblyType.Unknown: return("(not in assembly)");

            default: return("");
            }
        }
        public CompilationResult Compile(AssemblyType assemblyType, ITranslator translator, CompilationOptions compilationOptions, IEnumerable <IPluginHandler> pluginHandlers = null)
        {
            Stencil.PreProcessGraph(this);
            CompilationResult result;

            try
            {
                result = translator.TranslateAndCompile(this, assemblyType, compilationOptions);

                if (result.status == CompilationStatus.Failed)
                {
                    Stencil.OnCompilationFailed(this, result);
                }
                else
                {
                    Stencil.OnCompilationSucceeded(this, result);
                }
            }
            catch (Exception e)
            {
                result = null;
                Debug.LogException(e);
            }

            return(result);
        }
Exemple #19
0
        private void FillListViewDLLIniData(ListView listView, AssemblyType assemblyType, string assemblyName,
                                            DllIniData iniData, Dictionary <string, bool> itemsToExport)
        {
            listView.BeginUpdate();
            listView.Items.Clear();

            foreach (KeyValuePair <string, FileTypeHash> item in iniData.Files)
            {
                bool modified = itemsToExport[item.Key];

                listView.Items.Add(new ListViewItem(new[] { item.Key, modified ? "Yes" : "No" })
                {
                    Checked = modified
                });;
            }

            foreach (var item in iniData.DataItems)
            {
                bool modified = itemsToExport[item.Filename];

                listView.Items.Add(new ListViewItem(new[] { item.Filename, modified ? "Yes" : "No" })
                {
                    Checked = modified
                });;
            }

            listView.EndUpdate();
        }
Exemple #20
0
        public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
        {
            var jObject = JObject.Load(reader);
            var type    = (string)jObject["$type"];

            object result = null;

            switch (type)
            {
            case "AssemblyType":
                result = new AssemblyType();
                break;

            case "AssetType":
                result = new AssetType();
                break;

            case "Zone":
                result = new Zone();
                break;

            default:
                result = new AssemblyType();
                break;
            }
            serializer.Populate(jObject.CreateReader(), result);
            return(result);
        }
 public void AddDependency(string name, FourPartVersion version, Architecture arch, string publicKeyToken, string language = "*", AssemblyType assemblyType = AssemblyType.win32, BindingRedirect bindingRedirect = null)
 {
     if (!(from dat in DependentAssemblyElements
         let assemblyIdentity = new AssemblyIdentity(dat)
         where
             assemblyIdentity.Name == name &&
                 assemblyIdentity.Version == version &&
                     assemblyIdentity.Architecture == arch &&
                         assemblyIdentity.PublicKeyToken == publicKeyToken &&
                             ((language == "*" && string.IsNullOrEmpty(assemblyIdentity.Language)) || assemblyIdentity.Language == language)
         select assemblyIdentity).Any()) {
         // add another.
         var dat = new XElement(DependencyTag, new XElement(DependentAssemblyTag));
         var identity = new AssemblyIdentity(dat.Elements().FirstOrDefault()) {
             AssemblyType = assemblyType,
             Name = name,
             Version = version,
             Architecture = arch,
             PublicKeyToken = publicKeyToken,
             Language = language,
             BindingRedirect = bindingRedirect
         };
         _parentElement.Add(dat);
     }
 }
Exemple #22
0
        public Type GetType(AssemblyType asmType, string name)
        {
            Type[] tps = GetTypes(asmType, null);

            foreach (var item in tps)
            {
                if (item.Name == name)
                {
                    return(item);
                }
            }

            switch (asmType)
            {
            case AssemblyType.Executing:
                return(Assembly.GetExecutingAssembly().GetType(name));

            case AssemblyType.Entry:
                return(Assembly.GetEntryAssembly().GetType(name));

            case AssemblyType.Calling:
                return(Assembly.GetCallingAssembly().GetType(name));

            default:
                return(null);
            }
        }
Exemple #23
0
        private void PopulateMethods(TypeDefinition cecilType, MemberItem parentItem)
        {
            foreach (var method in cecilType.Methods)
            {
                if (!m_ScanForPrivateMembers && !method.IsPublic)
                {
                    continue;
                }

                if (method.IsGetter || method.IsSetter)
                {
                    continue;
                }

                AssemblyType asmType = AssemblyType.Method;

                var methodName = method.Name;
                if (method.IsConstructor)
                {
                    methodName = "constructor";
                    asmType    = AssemblyType.Constructor;
                }
                else if (methodName.StartsWith("op_Implicit"))
                {
                    methodName = method.ReturnType.ToString().SimplifyTypes();
                    asmType    = AssemblyType.ImplOperator;
                }
                else if (methodName.StartsWith("op_"))
                {
                    methodName = StringConvertUtils.ConvertOperatorFromAssembly(methodName).Substring(3);                     // Skip the op_ part
                    asmType    = AssemblyType.Operator;
                }

                string modifier = "";
                if (method.IsStatic)
                {
                    modifier = "static";
                }

                var asmEntry = new AsmEntry(methodName, asmType, modifier);
                foreach (var param in method.Parameters)
                {
                    string paramType      = param.ParameterType.ToString().SimplifyTypes();
                    bool   paramAttribute = IsParams(param);
                    string paramModifiers = paramAttribute? "params": "";
                    var    paramElement   = new ParamElement(param.Name, paramType, paramModifiers);
                    asmEntry.ParamList.Add(paramElement);
                }
                foreach (GenericParameter param in method.GenericParameters)
                {
                    string paramType = param.GetElementType().ToString().SimplifyTypes();
                    asmEntry.GenericParamList.Add(paramType);
                }
                asmEntry.ReturnType = method.ReturnType.ToString().SimplifyTypes();

                var signatureName = MemberNameGenerator.SignatureNameFromMethodDefinition(method);
                HandleMemberAndSignature(GetMemberName(method), signatureName, asmEntry, parentItem);
            }
        }
Exemple #24
0
 /// <summary>
 ///     Constructor
 /// </summary>
 /// <param name="name">Assembly name</param>
 /// <param name="directory">directory to save the assembly (if left blank, the assembly is run only and will not be saved)</param>
 /// <param name="type">Assembly type (exe or dll)</param>
 public Assembly(string name, string directory = "", AssemblyType type = AssemblyType.Dll)
 {
     if (string.IsNullOrEmpty(name))
     {
         throw new ArgumentNullException("name");
     }
     Setup(name, directory, type);
 }
Exemple #25
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="Name">Assembly name</param>
 /// <param name="Directory">Directory to save the assembly (if left blank, the assembly is run only and will not be saved)</param>
 /// <param name="Type">Assembly type (exe or dll)</param>
 public Assembly(string Name, string Directory = "", AssemblyType Type = AssemblyType.DLL)
 {
     if (string.IsNullOrEmpty(Name))
     {
         throw new ArgumentNullException("Name");
     }
     Setup(Name, Directory, Type);
 }
Exemple #26
0
 public AsmEntry(string name, AssemblyType type, string mods = "")
 {
     Name             = name;
     EntryType        = type;
     ParamList        = new List <ParamElement> ();
     GenericParamList = new List <string> ();
     Modifiers        = mods;
 }
Exemple #27
0
        protected virtual void RegisterObjects <T>(
            AssemblyType assemblyType,
            string nameSpace,
            bool useCollectionName,
            string switchName = null,
            params object[] arguments)
        {
            var appConfigParameters        = AppConfigManager.Instance().Property.AppConfigParameters;
            var appConfigParametersSection = appConfigParameters.Keys;

            var classes = GetCatalogue(assemblyType, nameSpace);

            foreach (var construct in classes)
            {
                foreach (var collectionName in appConfigParametersSection.Keys)
                {
                    if (useCollectionName && !construct.Equals(collectionName))
                    {
                        continue;
                    }

                    try
                    {
                        var value =
                            string.IsNullOrEmpty(switchName)
                                ? appConfigParametersSection[collectionName].Collection[construct]
                                : appConfigParametersSection[collectionName].Collection[switchName];

                        bool tryParse;
                        if (bool.TryParse(value, out tryParse) && !Convert.ToBoolean(value))
                        {
                            continue;
                        }

                        var stringIsNullOrEmpty = string.IsNullOrEmpty(value);
                        if (stringIsNullOrEmpty)
                        {
                            continue;
                        }

                        var instance = Instantiate <T>(assemblyType, construct, arguments);
                        if (instance == null)
                        {
                            continue;
                        }

                        RegisterInstance(instance);
                    }
                    // ReSharper disable once EmptyGeneralCatchClause
                    catch (Exception)
                    {
                        // do nothing with exception
                    }
                }
            }

            LogObjects();
        }
Exemple #28
0
 public static bool MultipleSignaturesPossibleForType(AssemblyType asmType)
 {
     return
         (asmType == AssemblyType.Method ||
          asmType == AssemblyType.Operator ||
          asmType == AssemblyType.Constructor ||
          asmType == AssemblyType.Property ||
          asmType == AssemblyType.Unknown);
 }
Exemple #29
0
        public bool SaveAssemblyItem(AssemblyType info)
        {
            string sql = @"INSERT INTO AssemblyType (FAssemblyName) VALUES (@Name) ";

            using (var conn = new DbHelperSQL(config).GetConnection())
            {
                return(conn.Execute(sql, new { Name = info.FAssemblyName }) > 0);
            }
        }
Exemple #30
0
        public bool UpdateAssemblyItem(AssemblyType info)
        {
            string sql = @"UPDATE AssemblyType SET FAssemblyName = @Name WHERE FInterID = @Id ";

            using (var conn = new DbHelperSQL(config).GetConnection())
            {
                return(conn.Execute(sql, new { Name = info.FAssemblyName, Id = info.FInterID }) > 0);
            }
        }
Exemple #31
0
        public static List <string> GetClasses(
            this AssemblyType assemblyType,
            string nameSpace)
        {
            var assembly = GetAssemblyType(assemblyType);
            var classes  = RetrieveClasses(assembly, nameSpace);

            return(classes);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="AssemblyGeneratorContext"/> class.
 /// </summary>
 /// <param name="process">The process.</param>
 /// <param name="assemblyType">The assembly type.</param>
 /// <param name="pubInfo">The pub info.</param>
 public AssemblyGeneratorContext(
     IProcessDefinition process,
     AssemblyType assemblyType = AssemblyType.Client,
     PublisherInformation pubInfo = null)
 {
     PubInfo = pubInfo;
     AssemblyType = assemblyType;
     Process = process;
 }
Exemple #33
0
        public void ProcessorWhenMoreThanOneTimedCommentBeforeAMessageLastOneOnlyIsInserted()
        {
            List <DateTime> messageTimeStamps = new List <DateTime>();

            // Get the timestamps of the messages in the trace file to be used.
            using (Parser parser = TestHelper.CreateWcfParserFromFile("FullSampleTest.svclog", true, false, SoapActionMode.Include))
            {
                ParsedMessage m;
                do
                {
                    m = parser.ReadNextRequest();
                    if (m != null)
                    {
                        messageTimeStamps.Add(m.Timestamp);
                    }
                }while (m != null);
            }

            // Build timedComments file to place a message before the first and third messages
            DateTime      time1 = messageTimeStamps[0] - new TimeSpan(2);
            DateTime      time2 = messageTimeStamps[0] - new TimeSpan(1);
            DateTime      time3 = messageTimeStamps[2] - new TimeSpan(2);
            StringBuilder sb    = new StringBuilder();

            sb.Append(time1.ToUniversalTime().ToString(@"yyyy-MM-dd\THH:mm:ss.ffffffK", CultureInfo.InvariantCulture));
            sb.Append("Comment1");
            sb.AppendLine();
            sb.Append(time2.ToUniversalTime().ToString(@"yyyy-MM-dd\THH:mm:ss.ffffffK", CultureInfo.InvariantCulture));
            sb.Append("Comment2");
            sb.AppendLine();
            sb.Append(time3.ToUniversalTime().ToString(@"yyyy-MM-dd\THH:mm:ss.ffffffK", CultureInfo.InvariantCulture));
            sb.Append("Comment3");
            sb.AppendLine();
            sb.Append(time3.ToUniversalTime().ToString(@"yyyy-MM-dd\THH:mm:ss.ffffffK", CultureInfo.InvariantCulture));
            sb.Append("Comment4");
            sb.AppendLine();

            string comment1 = time2.ToUniversalTime().ToString(CultureInfo.CurrentCulture) + " Comment2";
            string comment2 = time3.ToUniversalTime().ToString(CultureInfo.CurrentCulture) + " Comment4";

            using (Stream timedCommentsFile = TestHelper.BuildFile(sb.ToString()))
            {
                this.config = new WcfUnitConfiguration();
                this.config.testMethodMode     = TestMethodMode.ScenarioMethodOnly;
                this.config.operationTimerMode = OperationTimerMode.IncludeOperationTimers;
                AssemblyType a = new AssemblyType();
                a.fileName              = "ClientProxies.dll";
                this.config.assembly    = new AssemblyType[] { a };
                this.config.soapActions = new WcfUnitConfigurationSoapActions();
                this.config.soapActions.soapActionMode = SoapActionMode.Include;

                this.sut.ProcessTraceFile("Comment", "FullSampleTest.svclog", timedCommentsFile, this.config);

                TestHelper.CheckFileContains("Comment.cs", @"public void Comment\(\)\s*\{\s*// " + comment1 + @"\s*this.*this.*// " + comment2 + @"\s*this", 1);
            }
        }
        /// <summary>
        /// Gets the assembly information of the specified type.
        /// <para>
        /// AssemblyType.CURRENT and AssemblyType.APPLICATION are not allowed.
        /// </para>
        /// </summary>
        /// <param name="assemblyType">The type of the assembly to look for.</param>
        public static AssemblyInformation GetAssemblyInformation(AssemblyType assemblyType)
        {
            if (assemblyType == AssemblyType.CURRENT || assemblyType == AssemblyType.APPLICATION)
            {
                throw new InvalidEnumArgumentException("AssemblyType.Current and AssemblyType.Application are not allowed when getting the assembly information. Use GetAssembly() to get the assembly first, then call GetAssemblyInformation(Assembly) with it.");
            }
            var assembly = GetAssembly(assemblyType);

            return(GetAssemblyInformation(assembly));
        }
Exemple #35
0
 void OpenFileDialog1FileOk(object sender, System.ComponentModel.CancelEventArgs e)
 {
     foreach (string s in openFileDialog1.FileNames)
     {
         assembly_files.Add(s);
     }
     assemblyType = AssemblyType.File;
     DialogResult = DialogResult.OK;
     Close();
 }
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="paraAppFile"></param>
 /// <param name="paraProtocolNameSpace"></param>
 /// <param name="paraProtocolClass"></param>
 /// <param name="paraAssemblyType"></param>
 public TaskAssembly(string paraAppFile,
     string paraProtocolNameSpace,
     string paraProtocolClass,
     AssemblyType paraAssemblyType,
     string paraUserName)
 {
     _AppFile = paraAppFile;
     _AssemblyType = paraAssemblyType;
     _ProtocolClass = paraProtocolClass;
     _ProtocolNameSpace = paraProtocolNameSpace;
     _UserName = paraUserName;
 }
Exemple #37
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Bootstrapper"/> class.
 /// </summary>
 /// <param name="unityContainer">The unity container.</param>
 /// <param name="assemblyLocation">The application path where the assemblies are located or the long name of the assembly.</param>
 /// <param name="assemblyType">Type of the assembly.</param>
 public Bootstrapper(IUnityContainer unityContainer, string assemblyLocation, AssemblyType assemblyType)
 {
     if (unityContainer == null)
     {
         throw new ArgumentNullException("unityContainer");
     }
     if (string.IsNullOrEmpty(assemblyLocation))
     {
         throw new ArgumentNullException("assemblyLocation");
     }
     UnityContainer = unityContainer;
     _assemblyLocation = assemblyLocation;
     _assemblyType = assemblyType;
 }
Exemple #38
0
        /// <summary>
        /// Gets the worker.
        /// </summary>
        /// <param name="wt">The wt.</param>
        /// <param name="bll">The BLL.</param>
        /// <param name="asType">As type.</param>
        /// <returns></returns>
        internal static IWorker GetWorker(WorkingTask wt, IBLLLogic bll, AssemblyType asType)
        {
            switch (asType)
            {
                case AssemblyType.Dll:
                    return new Worker_Assembly(wt, bll);
                    break;

                case AssemblyType.Exe:
                    return new Worker_Excutable(wt, bll);
                    break;
                default:
                    throw new Exception("尚未定义的工作类型,AssemblyType:" + asType.ToString());
                    break;

            }
        }
Exemple #39
0
 /// <summary>
 /// Sets up the assembly
 /// </summary>
 /// <param name="Name">Assembly name</param>
 /// <param name="Directory">Directory to save the assembly (if left blank, the assembly is run only and will not be saved)</param>
 /// <param name="Type">Assembly type (dll or exe)</param>
 private void Setup(string Name, string Directory = "", AssemblyType Type = AssemblyType.DLL)
 {
     this.Name = Name;
     this.Directory = Directory;
     this.Type = Type;
     AssemblyName AssemblyName = new AssemblyName(Name);
     AppDomain Domain = Thread.GetDomain();
     if (!string.IsNullOrEmpty(Directory))
     {
         Builder = Domain.DefineDynamicAssembly(AssemblyName, AssemblyBuilderAccess.RunAndSave, Directory);
         Module = Builder.DefineDynamicModule(Name, Name + (Type == AssemblyType.DLL ? ".dll" : ".exe"), true);
     }
     else
     {
         Builder = Domain.DefineDynamicAssembly(AssemblyName, AssemblyBuilderAccess.Run);
         Module = Builder.DefineDynamicModule(Name);
     }
     Classes = new List<TypeBuilder>();
     Enums = new List<EnumBuilder>();
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ExportAsAssemblyGeneratorAttribute"/> class.
 /// </summary>
 /// <param name="generatorType">Type of the generator.</param>
 /// <param name="databaseType">Type of the database.</param>
 protected ExportAsAssemblyGeneratorAttribute(AssemblyType generatorType, string databaseType) : base(typeof(IAssemblyGenerator))
 {
     GeneratorType = generatorType;
     DatabaseType = databaseType;
 }
Exemple #41
0
        private AssemblyInformation GetCurrentAsm(string directory, string filename, AssemblyType type)
        {
            string path = Path.Combine(directory, filename);
            byte[] asmBytes;

            AssemblyInformation newAsm = new AssemblyInformation();
            newAsm.FileName = filename;
            asmBytes = File.ReadAllBytes(path);

            GetAssemblyInfoFromBin(directory, asmBytes, newAsm);
            // calculate MD5 based on all binary, so if something changes trigger a full directory update.
            newAsm.MD5 = FileUpdate.MD5Sum(asmBytes);
            newAsm.Size = asmBytes.Length;
            newAsm.Date = DateTime.Now;
            newAsm.Type = type;

            return newAsm;
        }
		void OpenFileDialog1FileOk(object sender, System.ComponentModel.CancelEventArgs e)
		{
			foreach (string s in openFileDialog1.FileNames)
			{
				assembly_files.Add(s);
			}
			assemblyType = AssemblyType.File;
			DialogResult = DialogResult.OK;
			Close();
		}
Exemple #43
0
 private AssemblyInformation UpdateModuleDBAssembly(AssemblyInformation asm, AssemblyType assemblyType)
 {
     try
     {
         AssemblyInformation newAsm = GetCurrentAsm(AppDomain.CurrentDomain.BaseDirectory, asm.FileName, assemblyType);
         AssemblyInformation savedAsm = SaveIfNotExistsOrDifferent(asm, newAsm, AppDomain.CurrentDomain.BaseDirectory);
         Logger.Info(string.Format(Messages.FileUpdated, savedAsm.Name, savedAsm.Version));
         return savedAsm;
     }
     catch (FileNotFoundException)
     {
         // Ignore it, use DB version.
         Logger.Warn(string.Format(Messages.FileMissing, asm.Name, "?"));
         return asm;
     }
 }
Exemple #44
0
 /// <summary>
 /// Generates the business object code.
 /// </summary>
 /// <param name="process">The process.</param>
 /// <param name="assemblyType">Type of the assembly.</param>
 /// <param name="pubInfo">The pub information.</param>
 /// <returns>System.String.</returns>
 public string GenerateBusinessObjectCode(IProcessDefinition process, AssemblyType assemblyType, PublisherInformation pubInfo = null)
 {
     return
         AssemblyGenerators.Where(
             a =>
             a.Metadata.GeneratorType == assemblyType &&
             (assemblyType == AssemblyType.Client || a.Metadata.DatabaseType == DatabaseType)).Select(
                 generator => generator.Value.GenerateCode(process)).FirstOrDefault();
 }
Exemple #45
0
        /// <summary>
        /// Generates the business object assembly.
        /// </summary>
        /// <param name="process">The process.</param>
        /// <param name="assemblyType">Type of the assembly.</param>
        /// <param name="pubInfo">The pub information.</param>
        /// <param name="settings">The settings.</param>
        /// <returns>IList{ErrorInfo}.</returns>
        public IList<ErrorInfo> GenerateBusinessObjectAssembly(IProcessDefinition process,
                                                               AssemblyType assemblyType,
                                                               PublisherInformation pubInfo = null,
                                                               GenerationSettings settings = GenerationSettings.GenerateAndCompile)
        {
            var errors = new List<ErrorInfo>();

            foreach (
                var errorList in
                    AssemblyGenerators.Where(a => a.Metadata.GeneratorType == assemblyType && (assemblyType == AssemblyType.Client || a.Metadata.DatabaseType == DatabaseType))
                                      .Select(generator => generator.Value.GenerateBusinessObjectAssembly(new AssemblyGeneratorContext(process, assemblyType, pubInfo)))
                                      .Where(errorList => errorList != null && errorList.Count > 0))
                errors.AddRange(errorList);

            return errors;
        }
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="Name">Assembly name</param>
 /// <param name="Directory">Directory to save the assembly (if left blank, the assembly is run only and will not be saved)</param>
 /// <param name="Type">Assembly type (exe or dll)</param>
 public Assembly(string Name, string Directory = "", AssemblyType Type = AssemblyType.DLL)
 {
     Contract.Requires<ArgumentNullException>(!string.IsNullOrEmpty(Name),"Name");
     Setup(Name, Directory, Type);
 }
Exemple #47
0
 public void AddDependency(string name, FourPartVersion version, Architecture arch, string publicKeyToken, string language = "*", AssemblyType assemblyType = AssemblyType.win32, BindingRedirect redirect = null)
 {
     Modified = true;
     _dependentAssemblies.AddDependency(name, version, arch, publicKeyToken, language, assemblyType, redirect);
 }
Exemple #48
0
 /// <summary>
 ///     Sets up the assembly
 /// </summary>
 /// <param name="name">Assembly name</param>
 /// <param name="directory">directory to save the assembly (if left blank, the assembly is run only and will not be saved)</param>
 /// <param name="type">Assembly type (dll or exe)</param>
 private void Setup(string name, string directory = "", AssemblyType type = AssemblyType.Dll)
 {
     Name = name;
     Directory = directory;
     Type = type;
     var assemblyName = new AssemblyName(name);
     AppDomain domain = Thread.GetDomain();
     if (!string.IsNullOrEmpty(directory))
     {
         Builder = domain.DefineDynamicAssembly(assemblyName, AssemblyBuilderAccess.RunAndSave, directory);
         Module = Builder.DefineDynamicModule(name, name + (type == AssemblyType.Dll ? ".dll" : ".exe"), true);
     }
     else
     {
         Builder = domain.DefineDynamicAssembly(assemblyName, AssemblyBuilderAccess.Run);
         Module = Builder.DefineDynamicModule(name);
     }
     Classes = new List<TypeBuilder>();
     Enums = new List<EnumBuilder>();
 }
Exemple #49
0
 public Tests(AssemblyType assemblyType, PropertyChangedWeaver propertyChangedWeaver)
 {
     _assemblyType = assemblyType;
     _propertyChangedWeaver = propertyChangedWeaver;
 }
Exemple #50
0
 /// <summary>
 ///     Constructor
 /// </summary>
 /// <param name="name">Assembly name</param>
 /// <param name="directory">directory to save the assembly (if left blank, the assembly is run only and will not be saved)</param>
 /// <param name="type">Assembly type (exe or dll)</param>
 public Assembly(string name, string directory = "", AssemblyType type = AssemblyType.Dll)
 {
     if (string.IsNullOrEmpty(name))
         throw new ArgumentNullException("name");
     Setup(name, directory, type);
 }
Exemple #51
0
 internal override List<AssemblyInformation> GetAssembliesInformation(AssemblyType type)
 {
     String sql = string.Format(this.GetSQL("GetAssembliesInformation.sql"), AssemblyInformation.ConvertTypeToCode(type));
     return b1DAO.ExecuteSqlForList<AssemblyInformation>(sql);
 }
Exemple #52
0
 internal override string GetAssemblyCode(string addinName, string addinNamespace, AssemblyType type)
 {
     return b1DAO.ExecuteSqlForObject<string>(string.Format(this.GetSQL("GetAssemblyCode.sql"),
         addinName, addinNamespace, AssemblyInformation.ConvertTypeToCode(type)));
 }
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="Name">Assembly name</param>
 /// <param name="Directory">Directory to save the assembly (if left blank, the assembly is run only and will not be saved)</param>
 /// <param name="Type">Assembly type (exe or dll)</param>
 public Assembly(string Name, string Directory = "", AssemblyType Type = AssemblyType.DLL)
 {
     if (string.IsNullOrEmpty(Name))
         throw new ArgumentNullException("Name");
     Setup(Name, Directory, Type);
 }
 public AssemblyGeneratorMetadata(AssemblyType generatorType, string databaseType)
 {
     this.generatorType = generatorType;
     this.databaseType = databaseType;
 }
 public DisassembledAssembly(Pathname path, AssemblyType type)
 {
   _path = path;
   _type = type;
 }