当前位置: 首页>>代码示例>>C#>>正文


C# Action.invoke方法代码示例

本文整理汇总了C#中System.Action.invoke方法的典型用法代码示例。如果您正苦于以下问题:C# Action.invoke方法的具体用法?C# Action.invoke怎么用?C# Action.invoke使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Action的用法示例。


在下文中一共展示了Action.invoke方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: createProjectFile

        public static string createProjectFile(this string projectName, string sourceFile, string pathToAssemblies, string targetDir, List<string> extraEmbebbedResources, Action<List<string>> beforeAddingReferences, Action<List<string>> beforeEmbedingFiles)
        {
            var apiCreateExe = new API_Create_Exe();
            if (sourceFile.empty())
                return null;

            sourceFile.file_Copy(targetDir);
            var assemblyFiles = pathToAssemblies.files(false,"*.dll","*.exe");

            var projectFile =  targetDir.pathCombine(projectName + ".csproj");

            var projectCollection = new ProjectCollection();

            var outputPath = "bin";
            Project project = new Project(projectCollection);
            project.SetProperty("DefaultTargets", "Build");

            var propertyGroup = project.Xml.CreatePropertyGroupElement();
            project.Xml.InsertAfterChild(propertyGroup, project.Xml.LastChild);
            //propertyGroup.AddProperty("TargetFrameworkVersion", "v4.0");
            propertyGroup.AddProperty("TargetFrameworkVersion", "v4.5");
            propertyGroup.AddProperty("ProjectGuid", Guid.NewGuid().str());
            propertyGroup.AddProperty("OutputType", "WinExe");
            propertyGroup.AddProperty("OutputPath", outputPath);
            propertyGroup.AddProperty("AssemblyName", projectName);
            propertyGroup.AddProperty("PlatformTarget", "x86");

            var targets = project.Xml.AddItemGroup();
            targets.AddItem("Compile", sourceFile.fileName());

            var references = project.Xml.AddItemGroup();
            references.AddItem("Reference", "mscorlib");
            references.AddItem("Reference", "System");
            references.AddItem("Reference", "System.Core");
            references.AddItem("Reference", "System.Windows.Forms");

            beforeAddingReferences.invoke(assemblyFiles);
            foreach(var assemblyFile in assemblyFiles)
            {
                var assembly =  assemblyFile.fileName().assembly(); // first load from local AppDomain (so that we don't lock the dll in the target folder)
                if (assembly.isNull())
                    assembly  =  assemblyFile.assembly();
                //only load the O2 assemblies
                if (assembly.str().lower().contains("o2") || assembly.str().lower().contains("fluentsharp"))
                {
                    var item = references.AddItem("Reference",assemblyFile.fileName_WithoutExtension());
                    item.AddMetadata("HintPath",assemblyFile.fileName());
                    item.AddMetadata("Private",@"False");
                }
            }

            var gzAssemblyFiles = new List<string>();
            beforeEmbedingFiles.invoke(assemblyFiles);

            var embeddedResources = project.Xml.AddItemGroup();

            foreach(var assemblyFile in gzAssemblyFiles)
                embeddedResources.AddItem("EmbeddedResource",assemblyFile.fileName());

            var defaultIcon = "O2Logo.ico";
            extraEmbebbedResources.add(assemblyFiles);

            foreach(var extraResource in extraEmbebbedResources)
            {
                if (extraResource.extension(".dll") || extraResource.extension(".exe"))
                {
                    //ignore these since they are already embded in the FluentSharp.REPL.exe dll
                    if(extraEmbebbedResources.fileNames().contains("FluentSharp.REPL.exe") &&
                       (extraResource.contains("Mono.Cecil.dll" )))
                    {
                        continue;
                    }
                    var gzFile = targetDir.pathCombine(extraResource.fileName() + ".gz");
                    extraResource.fileInfo().compress(gzFile);
                    extraResource.file_Copy(targetDir);
                    embeddedResources.AddItem("EmbeddedResource",gzFile.fileName());
                }
                else
                {
                    extraResource.file_Copy(targetDir);
                    embeddedResources.AddItem("EmbeddedResource",extraResource.fileName());
                    if (extraResource.extension(".ico"))
                        defaultIcon = extraResource;
                }
            }

            //add two extra folders (needs refactoring)
            Action<string> addSpecialResources =
                (resourceFolder)=>{
                                      var folder = targetDir.pathCombine(resourceFolder);
                                      if (folder.dirExists())
                                      {
                                          "found {0} Folder so adding it as a zip:{1}".debug(resourceFolder, folder);
                                          var zipFile = folder.zip_Folder(folder + ".zip");
                                          embeddedResources.AddItem("EmbeddedResource",zipFile.fileName());
                                          if (folder.files("*.ico").size()>0)
                                          {
                                              var icon = folder.files("*.ico").first();
                                              "Found default application ICON: {0}".debug(icon);
                                              defaultIcon = icon;
//.........这里部分代码省略.........
开发者ID:njmube,项目名称:FluentSharp,代码行数:101,代码来源:Package_Scripts_ExtensionMethods.cs

示例2: if_True

 public static bool if_True(this bool value, Action callback)
 {
     if(value.isTrue())
         callback.invoke();
     return value;
 }
开发者ID:SergeTruth,项目名称:OxyChart,代码行数:6,代码来源:Bool_ExtensionMethods.cs

示例3: if_Starts

 /// <summary>
 /// invokes callback if the target starts with value (note that the callback string is the target.subString_After(value)
 /// </summary>
 /// <param name="target"></param>
 /// <param name="value"></param>
 /// <param name="callback"></param>
 /// <returns></returns>
 public static string if_Starts(this string target, string value, Action<string> callback)
 {
     if(target.equal(value))
         callback.invoke(target.subString_After(value));
     return target;
 }
开发者ID:SergeTruth,项目名称:OxyChart,代码行数:13,代码来源:String_ExtensionMethods.cs

示例4: if_Equal

 public static string if_Equal(this string target, string value, Action<string> callback)
 {
     if(target.equal(value))
         callback.invoke(value);
     return target;
 }
开发者ID:SergeTruth,项目名称:OxyChart,代码行数:6,代码来源:String_ExtensionMethods.cs

示例5: onProcessChange

		public Ctrl_ProcessFinder onProcessChange(Action<Process> callback)
		{
			if(callback.notNull())
				this.ActiveWindowChanged  += (sender, e)=> callback.invoke(this.TargetProcess);	
			return this;
		}
开发者ID:paul-green,项目名称:O2.Platform.Scripts,代码行数:6,代码来源:Ctrl_ProcessFinder.cs


注:本文中的System.Action.invoke方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。